Class: TonSdkRubySmc::Jetton

Inherits:
Object
  • Object
show all
Extended by:
TonSdkRuby, TonSdkRubySmc
Defined in:
lib/ton-sdk-ruby-smc/tokens/jetton.rb

Constant Summary

Constants included from TonSdkRubySmc

PWV2_CODE, TOKEN_ATTRIBUTES_SHA256, VERSION

Class Method Summary collapse

Methods included from TonSdkRubySmc

require_type

Class Method Details

.build_burn(query_id, amount, response_destination, custom_payload = nil) ⇒ Object

burn#595f07bc query_id:uint64 amount:(VarUInteger 16)

response_destination:MsgAddress custom_payload:(Maybe ^Cell)
= InternalMsgBody;


69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ton-sdk-ruby-smc/tokens/jetton.rb', line 69

def self.build_burn(query_id, amount, response_destination, custom_payload = nil)
  require_type('query_id', query_id, Integer)
  require_type('amount', amount, Coins)
  require_type('response_destionation', response_destionation, Address)
  require_type('custom_payload', custom_payload, Cell) unless custom_payload.nil?

  body = Builder.new
  body.store_uint(0x595f07bc, 32)
  body.store_uint(query_id, 64)
  body.store_coins(amount)
  body.store_address(response_destionation)
  body.store_maybe_ref(custom_payload)
  body.cell
end

.build_transfer(query_id, amount, destination, response_destionation, forward_ton_amount, forward_payload, custom_payload = nil) ⇒ Object

transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16) destination:MsgAddress

response_destination:MsgAddress custom_payload:(Maybe ^Cell)
forward_ton_amount:(VarUInteger 16) forward_payload:(Either Cell ^Cell)
= InternalMsgBody;


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ton-sdk-ruby-smc/tokens/jetton.rb', line 37

def self.build_transfer(query_id, amount, destination, response_destionation, forward_ton_amount, forward_payload, custom_payload = nil)
  require_type('query_id', query_id, Integer)
  require_type('amount', amount, Coins)
  require_type('destination', destination, Address)
  require_type('response_destionation', response_destionation, Address)
  require_type('forward_ton_amount', forward_ton_amount, Coins)
  require_type('forward_payload', forward_payload, Cell)
  require_type('custom_payload', custom_payload, Cell) unless custom_payload.nil?

  body = Builder.new
  body.store_uint(0x0f8a7ea5, 32)
  body.store_uint(query_id, 64)
  body.store_coins(amount)
  body.store_address(destination)
  body.store_address(response_destionation)
  body.store_maybe_ref(custom_payload)
  body.store_coins(forward_ton_amount)
  if (body.bits.size + forward_payload.bits.size > 1023) || body.refs.size + forward_payload.refs.size > 4
    body.store_bit(1)
    body.store_ref(forward_payload)
  else
    body.store_bit(0)
    body.store_slice(forward_payload.parse)
  end
  body.cell
end