Class: IOSTSdk::Models::Query::Transaction

Inherits:
Object
  • Object
show all
Includes:
IOSTSdk::Models
Defined in:
lib/iost_sdk/models/query/transaction.rb

Constant Summary

Constants included from IOSTSdk::Models

MODEL_REGISTRY

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IOSTSdk::Models

included, #parse, #raw_data

Instance Attribute Details

#chain_idObject

Returns the value of attribute chain_id.



15
16
17
# File 'lib/iost_sdk/models/query/transaction.rb', line 15

def chain_id
  @chain_id
end

Class Method Details

.attr_namesObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/iost_sdk/models/query/transaction.rb', line 17

def self.attr_names
  [
    'time',
    'expiration',
    'gas_ratio',
    'gas_limit',
    'delay',
    'chain_id',
    'reserved',
    'signers',
    'actions',
    'amount_limit',
    'signatures'
  ]
end

Instance Method Details

#add_action(contract_id:, action_name:, action_data:) ⇒ Object

Add an action to the transaction

Parameters:

  • contract_id (String)

    a Contract’s ID

  • action_name (String)

    the name of an action

  • action_data (any)

    args to the action



50
51
52
53
54
55
56
57
58
# File 'lib/iost_sdk/models/query/transaction.rb', line 50

def add_action(contract_id:, action_name:, action_data:)
  @actions << IOSTSdk::Models::Action.new.populate(
    model_data: {
      'contract' => contract_id,
      'action_name' => action_name.to_s,
      'data' => JSON.generate(action_data)
    }
  )
end

#add_approve(token:, amount:) ⇒ Object

Add an amount limit to the transaction

Parameters:

  • token (String)

    name of the token

  • amount (Integer|String)

    amount of the token or ‘unlimited’



64
65
66
67
68
69
70
71
# File 'lib/iost_sdk/models/query/transaction.rb', line 64

def add_approve(token:, amount:)
  @amount_limit << IOSTSdk::Models::AmountLimit.new.populate(
    model_data: {
      'token' => token.to_s,
      'value' => amount.to_s
    }
  )
end

#set_time_params(expiration:, delay:) ⇒ Object

set the time implicitly, and set expiration and delay explicitly

Parameters:

  • expiration (Integer)

    number of seconds, since creation, the transaction will expire in

  • delay (Integer)

    the delay



37
38
39
40
41
42
43
# File 'lib/iost_sdk/models/query/transaction.rb', line 37

def set_time_params(expiration:, delay:)
  time_now = (Time.now.utc.to_f * 1000).to_i * 1_000_000

  @time = time_now
  @expiration = @time + expiration * 1_000_000_000
  @delay = delay
end