Module: NEAR::CLI::Account
- Included in:
- NEAR::CLI
- Defined in:
- lib/near/cli/account.rb
Overview
Instance Method Summary collapse
-
#add_full_access_key(account_id, public_key) ⇒ String
Adds a full access key to an account.
-
#add_function_call_key(account_id, public_key, receiver_id, method_names, allowance) ⇒ String
Adds a function call access key to an account.
-
#create_account_with_faucet(new_account, public_key: nil) ⇒ String
Creates a new account sponsored by the faucet service.
-
#create_account_with_funding(new_account, signer:, public_key: nil, deposit: nil) ⇒ String
Creates a new account funded by another account.
-
#create_implicit_account(save_path) ⇒ String
Creates an implicit account.
-
#delete_account(account, beneficiary: nil) ⇒ String
Deletes an account and transfers remaining balance to beneficiary.
-
#delete_key(account_id, public_key) ⇒ String
Deletes an access key from an account.
-
#import_account_with_private_key(private_key) ⇒ String
Imports an existing account using a private key.
-
#import_account_with_seed_phrase(seed_phrase, hd_path: "m/44'/397'/0'") ⇒ String
Imports an existing account using a seed phrase.
-
#list_keys(account_id, block: :now) ⇒ String
Lists access keys for an account.
-
#make_storage_deposit(contract_id, account_id, deposit, sign_as) ⇒ String
Makes a storage deposit for an account.
-
#view_account_summary(account_id, block: :now) ⇒ String
Views properties for an account.
-
#view_storage_balance(contract_id, account_id, block: :now) ⇒ String
Views storage balance for an account.
-
#withdraw_storage_deposit(contract_id, amount, account_id) ⇒ String
Withdraws storage deposit for an account.
Instance Method Details
#add_full_access_key(account_id, public_key) ⇒ String
Adds a full access key to an account.
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/near/cli/account.rb', line 161 def add_full_access_key(account_id, public_key) stdout, stderr = execute( 'account', 'add-key', account_id, 'grant-full-access', 'use-manually-provided-public-key', public_key, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |
#add_function_call_key(account_id, public_key, receiver_id, method_names, allowance) ⇒ String
Adds a function call access key to an account.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/near/cli/account.rb', line 183 def add_function_call_key(account_id, public_key, receiver_id, method_names, allowance) stdout, stderr = execute( 'account', 'add-key', account_id, 'grant-function-call-access', '--allowance', allowance, '--receiver-account-id', receiver_id, '--method-names', method_names.join(', '), 'use-manually-provided-public-key', public_key, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |
#create_account_with_faucet(new_account, public_key: nil) ⇒ String
Creates a new account sponsored by the faucet service.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/near/cli/account.rb', line 76 def create_account_with_faucet(new_account, public_key: nil) stdout, stderr = execute( 'account', 'create-account', 'sponsor-by-faucet-service', new_account.to_s, *case public_key when nil then ['autogenerate-new-keypair', 'save-to-keychain'] when String then ['use-manually-provided-public-key', public_key] when Array then public_key else raise ArgumentError end, 'network-config', @network, 'create' ) stderr end |
#create_account_with_funding(new_account, signer:, public_key: nil, deposit: nil) ⇒ String
Creates a new account funded by another account.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/near/cli/account.rb', line 101 def create_account_with_funding(new_account, signer:, public_key: nil, deposit: nil) stdout, stderr = execute( 'account', 'create-account', 'fund-myself', new_account.to_s, (deposit ? deposit.to_s : '0') + ' NEAR', *case public_key when nil then ['autogenerate-new-keypair', 'save-to-keychain'] when String then ['use-manually-provided-public-key', public_key] when Array then public_key else raise ArgumentError end, 'sign-as', signer.to_s, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |
#create_implicit_account(save_path) ⇒ String
Creates an implicit account.
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/near/cli/account.rb', line 125 def create_implicit_account(save_path) stdout, stderr = execute( 'account', 'create-account', 'fund-later', 'use-auto-generation', 'save-to-folder', save_path ) stderr end |
#delete_account(account, beneficiary: nil) ⇒ String
Deletes an account and transfers remaining balance to beneficiary.
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/near/cli/account.rb', line 142 def delete_account(account, beneficiary: nil) account = NEAR::Account.parse(account) stdout, stderr = execute( 'account', 'delete-account', account.to_s, 'beneficiary', (beneficiary || account.parent).to_s, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |
#delete_key(account_id, public_key) ⇒ String
Deletes an access key from an account.
205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/near/cli/account.rb', line 205 def delete_key(account_id, public_key) stdout, stderr = execute( 'account', 'delete-key', account_id, public_key, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |
#import_account_with_private_key(private_key) ⇒ String
Imports an existing account using a private key.
60 61 62 63 64 65 66 67 68 |
# File 'lib/near/cli/account.rb', line 60 def import_account_with_private_key(private_key) _, stderr = execute( 'account', 'import-account', 'using-private-key', private_key, 'network-config', @network ) stderr end |
#import_account_with_seed_phrase(seed_phrase, hd_path: "m/44'/397'/0'") ⇒ String
Imports an existing account using a seed phrase.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/near/cli/account.rb', line 44 def import_account_with_seed_phrase(seed_phrase, hd_path: "m/44'/397'/0'") _, stderr = execute( 'account', 'import-account', 'using-seed-phrase', seed_phrase, '--seed-phrase-hd-path', hd_path, 'network-config', @network ) stderr end |
#list_keys(account_id, block: :now) ⇒ String
Lists access keys for an account.
28 29 30 31 32 33 34 35 36 |
# File 'lib/near/cli/account.rb', line 28 def list_keys(account_id, block: :now) stdout, _ = execute( 'account', 'list-keys', account_id, 'network-config', @network, *block_args(block) ) stdout end |
#make_storage_deposit(contract_id, account_id, deposit, sign_as) ⇒ String
Makes a storage deposit for an account.
243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/near/cli/account.rb', line 243 def make_storage_deposit(contract_id, account_id, deposit, sign_as) stdout, stderr = execute( 'account', 'manage-storage-deposit', contract_id, 'deposit', account_id, deposit, 'sign-as', sign_as, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |
#view_account_summary(account_id, block: :now) ⇒ String
Views properties for an account.
12 13 14 15 16 17 18 19 20 |
# File 'lib/near/cli/account.rb', line 12 def view_account_summary(account_id, block: :now) stdout, _ = execute( 'account', 'view-account-summary', account_id, 'network-config', @network, *block_args(block) ) stdout end |
#view_storage_balance(contract_id, account_id, block: :now) ⇒ String
Views storage balance for an account.
224 225 226 227 228 229 230 231 232 233 |
# File 'lib/near/cli/account.rb', line 224 def view_storage_balance(contract_id, account_id, block: :now) stdout, _ = execute( 'account', 'manage-storage-deposit', contract_id, 'view-balance', account_id, 'network-config', @network, *block_args(block) ) stdout end |
#withdraw_storage_deposit(contract_id, amount, account_id) ⇒ String
Withdraws storage deposit for an account.
263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/near/cli/account.rb', line 263 def withdraw_storage_deposit(contract_id, amount, account_id) stdout, stderr = execute( 'account', 'manage-storage-deposit', contract_id, 'withdraw', amount, 'sign-as', account_id, 'network-config', @network, 'sign-with-keychain', 'send' ) stderr end |