Skip to content

callContractMethod should accept token also #59

@ohager

Description

@ohager

Is your feature request related to a problem? Please describe.
The current version for callContractMethod allows only SIGNA to be sent. If calls depend on sent tokens, this method cannot be used yet. Allowing token transfers to contract in combination with methods would simplify the usage

Describe the solution you'd like
Add optional assetId and quantity for as calling parameters

Describe alternatives you've considered

Current way to do is like this:

        // generate the arguments string
        const methodCall = generateMethodCall({
          methodHash: "99",
          methodArgs: [airdropTokenId],
        });

       // mount as attachment
        const attachment = new AttachmentMessage({
          message: methodCall,
          messageIsText: false,
        });

        // use transferAsset method
        const { unsignedTransactionBytes } = await ledger.asset.transferAsset({
          assetId: contractData.getPledgeTokenId(),
          quantity: quantity.getAtomic(),
          recipientId: this.contractId,
          amountPlanck: contractData.getActivationAmount().getPlanck(),
          feePlanck: fees.cheap.toString(10),
          senderPublicKey: this.getAccount().getPublicKey(),
          attachment,
        });

desired would be:

        const { unsignedTransactionBytes } =
          await ledger.contract.callContractMethod({
            methodHash: "99",
            methodArgs: [],
            contractId: this.contractId,
            assetId: contractData.getPledgeTokenId(),
            assetQuantity: quantity.getAtomic(),
            amountPlanck: contractData.getActivationAmount().getPlanck(),
            feePlanck: fees.cheap.toString(10),
            senderPublicKey: this.getAccount().getPublicKey(),
          });

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions