Module: NEAR::CLI::Transaction
- Included in:
- NEAR::CLI
- Defined in:
- lib/near/cli/transaction.rb
Overview
Instance Method Summary collapse
-
#construct_transaction(signer_id, receiver_id, actions) ⇒ String
Constructs a new transaction with multiple actions.
-
#reconstruct_transaction(tx_hash) ⇒ Hash
Reconstructs a CLI command from an existing transaction.
-
#send_meta_transaction(signed_tx) ⇒ Hash
Sends a meta transaction (relayed transaction).
-
#send_signed_transaction(signed_tx) ⇒ Hash
Sends a signed transaction.
-
#sign_transaction(unsigned_tx, options = {}) ⇒ String
Signs a previously prepared unsigned transaction.
-
#view_status(tx_hash) ⇒ Hash
Views status of a transaction.
Instance Method Details
#construct_transaction(signer_id, receiver_id, actions) ⇒ String
Constructs a new transaction with multiple actions.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/near/cli/transaction.rb', line 47 def construct_transaction(signer_id, receiver_id, actions) args = [ 'transaction', 'construct-transaction', signer_id, receiver_id ] actions.each do |action| args += construct_action_args(action) end args += [ 'network-config', @network ] stdout, _ = execute(*args) extract_unsigned_transaction(stdout) end |
#reconstruct_transaction(tx_hash) ⇒ Hash
Reconstructs a CLI command from an existing transaction.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/near/cli/transaction.rb', line 27 def reconstruct_transaction(tx_hash) stdout, _ = execute( 'transaction', 'reconstruct-transaction', tx_hash, 'network-config', @network ) { transaction: parse_transaction_reconstruction(stdout), cli_command: extract_cli_command(stdout) } end |
#send_meta_transaction(signed_tx) ⇒ Hash
Sends a meta transaction (relayed transaction).
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/near/cli/transaction.rb', line 120 def (signed_tx) stdout, stderr = execute( 'transaction', 'send-meta-transaction', signed_tx, 'network-config', @network ) parse_transaction_result(stderr) end |
#send_signed_transaction(signed_tx) ⇒ Hash
Sends a signed transaction.
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/near/cli/transaction.rb', line 104 def send_signed_transaction(signed_tx) stdout, stderr = execute( 'transaction', 'send-signed-transaction', signed_tx, 'network-config', @network ) parse_transaction_result(stderr) end |
#sign_transaction(unsigned_tx, options = {}) ⇒ String
Signs a previously prepared unsigned transaction.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/near/cli/transaction.rb', line 73 def sign_transaction(unsigned_tx, = {}) args = [ 'transaction', 'sign-transaction', unsigned_tx, 'network-config', @network ] args += case [:method] when :keychain ['sign-with-keychain'] when :ledger ['sign-with-ledger'] when :private_key [ 'sign-with-plaintext-private-key', [:private_key] ] else raise ArgumentError, "Invalid signing method: #{[:method]}" end stdout, _ = execute(*args) extract_signed_transaction(stdout) end |
#view_status(tx_hash) ⇒ Hash
Views status of a transaction.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/near/cli/transaction.rb', line 11 def view_status(tx_hash) stdout, _ = execute( 'transaction', 'view-status', tx_hash, 'network-config', @network ) # Parse the transaction details from the output parse_transaction_status(stdout) end |