@signumjs/core
Version:
Principal package with functions and models for building Signum Network applications.
52 lines • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.callContractMethod = void 0;
const attachment_1 = require("../../../typings/attachment");
const transaction_1 = require("../transaction");
const contracts_1 = require("@signumjs/contracts");
const asset_1 = require("../asset");
/**
* Use with {@link ApiComposer} and belongs to {@link ContractApi}.
*
* See details at {@link ContractApi.callContractMethod}
*
* @category factories
*/
const callContractMethod = (service) => async (args) => {
const callMessage = (0, contracts_1.generateMethodCall)({
methodId: args.methodId,
methodArgs: args.methodArgs,
});
const attachment = new attachment_1.AttachmentMessage({
message: callMessage,
messageIsText: false,
});
if (args.assetId && args.assetQuantity) {
return (0, asset_1.transferAsset)(service)({
amountPlanck: args.assetId,
assetId: args.assetId,
quantity: args.assetQuantity,
attachment,
deadline: args.deadline,
senderPublicKey: args.senderPublicKey,
referencedTransactionFullHash: args.referencedTransactionFullHash,
feePlanck: args.feePlanck,
recipientId: args.contractId,
senderPrivateKey: args.senderPrivateKey,
skipAdditionalSecurityCheck: args.skipAdditionalSecurityCheck
});
}
return (0, transaction_1.sendAmountToSingleRecipient)(service)({
amountPlanck: args.amountPlanck,
attachment,
deadline: args.deadline,
feePlanck: args.feePlanck,
recipientId: args.contractId,
senderPrivateKey: args.senderPrivateKey,
senderPublicKey: args.senderPublicKey,
referencedTransactionFullHash: args.referencedTransactionFullHash,
skipAdditionalSecurityCheck: args.skipAdditionalSecurityCheck
});
};
exports.callContractMethod = callContractMethod;
//# sourceMappingURL=callContractMethod.js.map