Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1110 from near/fix-add-key
Browse files Browse the repository at this point in the history
fix: fixed error on empty methods
  • Loading branch information
gagdiez authored Mar 19, 2024
2 parents 15cb2fc + 05fad3d commit 8518cec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion commands/keys/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
desc: 'Method names to limit access key to (example: --method-names meth1 meth2)',
type: 'array',
required: false,
default: []
})
.option('allowance', {
desc: 'Allowance in $NEAR for the key (default 0)',
Expand Down Expand Up @@ -47,7 +48,7 @@ async function addAccessKey(options) {
await assertCredentials(options.accountId, options.networkId, options.keyStore, options.useLedgerKey);

console.log(`Adding ${options.contractId ? 'function call access' : 'full access'} key ${options.publicKey} to ${options.accountId}.`);
if (options.contractId) console.log(`Limited to: ${options.allowance} $NEAR and methods: ${options.methodNames.join(' ')}.`);
if (options.contractId) console.log(`Limited to: ${options.allowance} $NEAR and methods: [${options.methodNames.join(' ')}].`);

const near = await connect(options);
const account = await near.account(options.accountId);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-cli",
"version": "4.0.10",
"version": "4.0.11",
"description": "Simple CLI for interacting with NEAR Protocol",
"engines": {
"node": ">= 16"
Expand Down
3 changes: 3 additions & 0 deletions test/test_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ testaccount=test-keys-${timestamp}.testnet
# Can create an account with a given public key
./bin/near add-key $testaccount "78MziB9aTNsu19MHHVrfWy762S5mAqXgCB6Vgvrv9uGV"

# Add a function call key
./bin/near add-key $testaccount "ed25519:DReZmNmnGhpsYcCFFeYgPsJ9YCm9xH16GGujCPe3KQEq" --contractId multichain-testnet-2.testnet --allowance 1

RESULT=$(./bin/near list-keys $testaccount)
EXPECTED=".*78MziB9aTNsu19MHHVrfWy762S5mAqXgCB6Vgvrv9uGV.*"
if [[ ! "$RESULT" =~ $EXPECTED ]]; then
Expand Down

0 comments on commit 8518cec

Please sign in to comment.