Class: TonSdkRubySmc::WalletV3
- Inherits:
-
Object
- Object
- TonSdkRubySmc::WalletV3
- Extended by:
- TonSdkRuby, TonSdkRubySmc
- Includes:
- TonSdkRuby
- Defined in:
- lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb
Constant Summary collapse
- WALLET_V3_CODE =
"B5EE9C724101010100710000DEFF0020DD2082014C97BA218201339CBAB19F71B0ED44D0D31FD31F31D70BFFE304E0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED5410BD6DAD"
- SUB_WALLET_ID =
698983191
Constants included from TonSdkRubySmc
PWV2_CODE, TOKEN_ATTRIBUTES_SHA256, VERSION
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#code ⇒ Object
Returns the value of attribute code.
-
#init ⇒ Object
Returns the value of attribute init.
-
#pubkey ⇒ Object
Returns the value of attribute pubkey.
-
#sub_wallet_id ⇒ Object
Returns the value of attribute sub_wallet_id.
Class Method Summary collapse
Instance Method Summary collapse
- #build_transfer(transfers, seqno, private_key, is_init = false, timeout = 60) ⇒ Object
-
#initialize(pubkey, wc = 0, sub_wallet_id = SUB_WALLET_ID) ⇒ WalletV3
constructor
A new instance of WalletV3.
Methods included from TonSdkRubySmc
Constructor Details
#initialize(pubkey, wc = 0, sub_wallet_id = SUB_WALLET_ID) ⇒ WalletV3
Returns a new instance of WalletV3.
69 70 71 72 73 74 75 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 69 def initialize(pubkey, wc = 0, sub_wallet_id = SUB_WALLET_ID) @pubkey = pubkey @sub_wallet_id = sub_wallet_id @code = deserialize(hex_to_bytes(WALLET_V3_CODE)).first @init = build_state_init @address = Address.new("#{wc}:#{init.cell.hash}") end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
67 68 69 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 67 def address @address end |
#code ⇒ Object
Returns the value of attribute code.
67 68 69 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 67 def code @code end |
#init ⇒ Object
Returns the value of attribute init.
67 68 69 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 67 def init @init end |
#pubkey ⇒ Object
Returns the value of attribute pubkey.
67 68 69 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 67 def pubkey @pubkey end |
#sub_wallet_id ⇒ Object
Returns the value of attribute sub_wallet_id.
67 68 69 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 67 def sub_wallet_id @sub_wallet_id end |
Class Method Details
.parse_storage(storage_slice) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 77 def self.parse_storage(storage_slice) raise 'Must be a Slice' unless storage_slice.is_a?(Slice) { seqno: storage_slice.load_uint(32), sub_wallet_id: storage_slice.load_uint(32), pubkey: storage_slice.load_bytes(32) } end |
Instance Method Details
#build_transfer(transfers, seqno, private_key, is_init = false, timeout = 60) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb', line 86 def build_transfer(transfers, seqno, private_key, is_init = false, timeout = 60) raise 'Transfers must be an [WalletV3Transfer]' unless transfers.size > 0 && transfers.first.is_a?(WalletV3Transfer) raise "Wallet v3 can handle only 4 transfers at once" unless transfers.size <= 4 body = Builder.new() body.store_uint(sub_wallet_id, 32) body.store_uint((Time.now.to_i + timeout), 32) body.store_uint(seqno, 32) transfers.each do |t| info = CommonMsgInfo.new( IntMsgInfo.new( dest: t.destination, bounce: t.bounce, value: t.value, ) ) = Message.new( MessageOptions.new( info: info, body: t.body, init: t.init, ) ) body.store_uint(t.mode, 8) body.store_ref(.cell) end sign = sign_cell(body.cell, private_key) = Builder.new .store_bytes(sign.unpack('C*')) .store_slice(body.cell.parse) info = CommonMsgInfo.new( ExtInMsgInfo.new( dest: address ) ) init_t = is_init ? init : nil body_cell = .cell Message.new( MessageOptions.new( info: info, init: init_t, body: body_cell ) ) end |