module FlowClient::Utils
Public Class Methods
left_pad_bytes(byte_array, length)
click to toggle source
Left pads a byte array with 0 to length
# File lib/flow_client/utils.rb, line 6 def self.left_pad_bytes(byte_array, length) required_pad_count = length - byte_array.count padding = [] (1..required_pad_count).each do |_i| padding << 0 end padding + byte_array end
right_pad_bytes(byte_array, length)
click to toggle source
Right pads a byte array with 0 to length
# File lib/flow_client/utils.rb, line 16 def self.right_pad_bytes(byte_array, length) required_pad_count = length - byte_array.count padding = [] (1..required_pad_count).each do |_i| padding << 0 end byte_array + padding end
substitute_address_aliases(script_or_transaction, aliases = {})
click to toggle source
Substitutes Candence import statements using aliases with addresses e.g. import FungibleToken from 0xFUNGIBLE_TOKEN_ADDRESS.
aliases is a hash with aliases as string keys and addresses as values, e.g. { “0xFUNGIBLE_TOKEN_ADDRESS”: “0x0” }
# File lib/flow_client/utils.rb, line 30 def self.substitute_address_aliases(script_or_transaction, aliases = {}) new_string = script_or_transaction aliases.each do |key, value| new_string = new_string.gsub(key.to_s, value.to_s) end new_string end