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

fix: fixed error on empty methods #1110

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading