Skip to content

Commit

Permalink
add evmDeprecated and update evm-call
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisjoshford committed May 5, 2021
1 parent f13b273 commit 1f4ace1
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions commands/evm-call.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const exitOnError = require('../utils/exit-on-error');
const web3 = require('web3');
const { NearProvider, utils } = require('near-web3-provider');
const assert = require('assert');
const checkCredentials = require('../utils/check-credentials');
const { evmDeprecated } = require('../utils/deprecation-warning');

module.exports = {
command: 'evm-call <evmAccount> <contractName> <methodName> [args]',
Expand Down Expand Up @@ -33,27 +29,5 @@ module.exports = {
desc: 'Path to ABI for given contract',
type: 'string',
}),
handler: exitOnError(scheduleEVMFunctionCall)
handler: () => console.log(evmDeprecated)
};

async function scheduleEVMFunctionCall(options) {
await checkCredentials(options.accountId, options.networkId, options.keyStore);
const args = JSON.parse(options.args || '[]');
console.log(`Scheduling a call inside ${options.evmAccount} EVM:`);
console.log(`${options.contractName}.${options.methodName}()` +
(options.amount && options.amount !== '0' ? ` with attached ${options.amount} NEAR` : ''));
console.log(' with args', args);
const web = new web3();
web.setProvider(new NearProvider({
nodeUrl: options.nodeUrl,
// TODO: make sure near-api-js has the same version between near-web3-provider.
// keyStore: options.keyStore,
masterAccountId: options.accountId,
networkId: options.networkId,
evmAccountId: options.evmAccount,
keyPath: options.keyPath,
}));
const contract = new web.eth.Contract(options.abi, options.contractName);
assert(options.methodName in contract.methods, `${options.methodName} is not present in ABI`);
await contract.methods[options.methodName](...args).send({ from: utils.nearAccountToEvmAddress(options.accountId) });
}

0 comments on commit 1f4ace1

Please sign in to comment.