Skip to content

Commit

Permalink
Merge pull request #734 from near/fix/remove-evm-commands
Browse files Browse the repository at this point in the history
remove evm commands
  • Loading branch information
thisisjoshford authored May 5, 2021
2 parents be63a8d + 13a12e0 commit 160b654
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 363 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ _Click on a command for more information and examples._
| [`near dev-deploy`](#near-dev-deploy) | creates a development account and deploys a contract to it _(`testnet` only)_ |
| [`near call`](#near-call) | makes a contract call which can invoke `change` _or_ `view` methods |
| [`near view`](#near-view) | makes a contract call which can **only** invoke a `view` method |
| **NEAR EVM CONTRACTS** | |
| [`near evm-view`](#near-evm-view) | makes an EVM contract call which can **only** invoke a `view` method |
| [`near evm-call`](#near-evm-call) | an EVM contract call which can invoke `change` _or_ `view` methods |
| [`near evm-dev-init`](#near-evm-dev-init) | creates test accounts for the specified network |
| **TRANSACTIONS** | |
| [`near tx-status`](#near-tx-status) | queries a transaction's status by `txHash` |
| **VALIDATORS** | |
Expand All @@ -45,6 +41,8 @@ _Click on a command for more information and examples._

[ [**OPTIONS**](#options) ]

> For EVM support see [Project Aurora's](https://aurora.dev) [`aurora-cli`](https://github.com/aurora-is-near/aurora-cli).
---

## Setup
Expand Down
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) });
}
12 changes: 2 additions & 10 deletions commands/evm-dev-init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const exitOnError = require('../utils/exit-on-error');
const { utils } = require('near-web3-provider');
const connect = require('../utils/connect');
const { evmDeprecated } = require('../utils/deprecation-warning');

module.exports = {
command: 'evm-dev-init <accountId> [numAccounts]',
Expand All @@ -16,11 +14,5 @@ module.exports = {
type: 'number',
default: '5'
}),
handler: exitOnError(scheduleEVMDevInit)
handler: () => console.log(evmDeprecated)
};

async function scheduleEVMDevInit(options) {
const near = await connect(options);
const account = await near.account(options.accountId);
await utils.createTestAccounts(account, options.numAccounts);
}
24 changes: 2 additions & 22 deletions commands/evm-view.js
Original file line number Diff line number Diff line change
@@ -1,7 +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 { evmDeprecated } = require('../utils/deprecation-warning');

module.exports = {
command: 'evm-view <evmAccount> <contractName> <methodName> [args]',
Expand All @@ -21,22 +18,5 @@ module.exports = {
desc: 'Path to ABI for given contract',
type: 'string',
}),
handler: exitOnError(scheduleEVMFunctionView)
handler: () => console.log(evmDeprecated)
};

async function scheduleEVMFunctionView(options) {
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,
}));
const contract = new web.eth.Contract(options.abi, options.contractName);
const args = JSON.parse(options.args || '[]');
assert(options.methodName in contract.methods, `${options.methodName} is not present in ABI`);
const result = await contract.methods[options.methodName](...args).call({ from: utils.nearAccountToEvmAddress(options.accountId) });
console.log(result);
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@
"ncp": "^2.0.0",
"near-api-js": "^0.39.0",
"near-seed-phrase": "^0.1.0",
"near-web3-provider": "^1.0.6",
"open": "^7.0.1",
"rimraf": "^3.0.0",
"stoppable": "^1.1.0",
"tcp-port-used": "^1.0.1",
"update-notifier": "^5.0.0",
"uuid": "^8.0.0",
"v8flags": "^3.1.3",
"web3": "^1.2.11",
"yargs": "^16.0.3"
},
"optionalDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions utils/deprecation-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const chalk = require('chalk');

module.exports = {
evmDeprecated: chalk`{bold.white EVM support has been {bold.yellow deprecated} from [ {bold.green near-cli} ] and relocated to Project Aurora's [ {bold.blue aurora-cli} ]. More info @ {bold.blue http://github.com/aurora-is-near/aurora-cli}}`,
};
Loading

0 comments on commit 160b654

Please sign in to comment.