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

Support multiple function call actions with Near.call #59

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

evgenykuzyakov
Copy link
Contributor

@evgenykuzyakov evgenykuzyakov commented Dec 5, 2022

Near.call now supports taking a single argument: TX object or an array of TX objects as a first argument.
Note, the old interface is also supported.

TX object keys:

  • contractName (required): the account ID of the contract to call
  • methodName (required): the method name to call
  • args (optional, default {}): object to pass as arguments
  • deposit (optional, default 0): the attached deposit amount in yoctoNEAR, should be a number,string or Big
  • gas (optional, defaults to "30000000000000" or 30 Tgas): the amount of gas, should be a number,string or Big

Near.call will group function calls towards the same contract Name into one transaction up to 250 TGas.

Example:

return (
  <button
    onClick={() => {
      Near.call([
        {
          contractName: "test.testnet",
          methodName: "test1",
          args: { test: "true" },
          deposit: 1,
          gas: Big(10).pow(12).mul(50),
        },
        {
          contractName: "test2.testnet",
          methodName: "test1",
          args: { test: true },
          deposit: 0,
          gas: Big(10).pow(12).mul(50),
        },
        {
          contractName: "test2.testnet",
          methodName: "test2",
          args: { test: "true" },
          deposit: 1,
          gas: Big(10).pow(12).mul(50),
        },
        {
          contractName: "test.testnet",
          methodName: "test2",
          args: { test: false },
          deposit: Big(10).pow(25),
          gas: Big(10).pow(12).mul(250),
        },
      ]);
    }}
  >
    Test Transactions
  </button>
);

@ciocan
Copy link

ciocan commented Dec 6, 2022

Is this a breaking change for existing widgets using Near.call without an array?

@evgenykuzyakov
Copy link
Contributor Author

Is this a breaking change for existing widgets using Near.call without an array?

No it still supports the old interface.

@evgenykuzyakov evgenykuzyakov merged commit 048edbd into master Dec 6, 2022
@evgenykuzyakov evgenykuzyakov deleted the near-multi-call branch December 6, 2022 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants