Module: Xpring::Signer

Defined in:
lib/xpring/signer.rb

Overview

Signs transactions

Class Method Summary collapse

Class Method Details

.sign(transaction_hash:, from_wallet:) ⇒ String

Parameters:

  • transaction_hash (Hash)
  • from_wallet (Wallet)

Returns:

  • (String)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xpring/signer.rb', line 13

def self.sign(transaction_hash:, from_wallet:)
  bytes = Javascript.run do
    <<~JAVASCRIPT
      #{Javascript::ENTRY_POINT}.Signer.signTransactionFromJSON(
        JSON.parse('#{JSON.generate(transaction_hash)}'),
        #{from_wallet.to_javascript},
      );
    JAVASCRIPT
  end.values
  Util.byte_string_from_hex_bytes(bytes)
end