Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callContractMethod should accept token also #59

Open
ohager opened this issue Apr 19, 2023 · 0 comments
Open

callContractMethod should accept token also #59

ohager opened this issue Apr 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ohager
Copy link
Member

ohager commented Apr 19, 2023

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(),
          });
@ohager ohager added the enhancement New feature or request label Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant