Module: EverSdk::Tvm

Defined in:
lib/ever_sdk_client/tvm.rb

Defined Under Namespace

Modules: ErrorCode Classes: AccountForExecutor, ParamsOfRunGet, ParamsOfRunTvm

Constant Summary collapse

ExecutionOptions =
KwStruct.new(:blockchain_config, :block_time, :block_lt, :transaction_lt, :chksig_always_succeed) do
  def initialize(blockchain_config: nil, block_time: nil, block_lt: nil, transaction_lt: nil, chksig_always_succeed: false)
    super
  end
end
ParamsOfRunExecutor =
KwStruct.new(
  :message,
  :account,
  :execution_options,
  :abi,
  :skip_transaction_check,
  :boc_cache,
  :return_updated_account
) do
  def initialize(
    message:,
    account:,
    execution_options: nil,
    abi: nil,
    skip_transaction_check: nil,
    boc_cache: nil,
    return_updated_account: nil
  )
    super
  end

  def to_h
    h = super
    h[:account] = self..to_h
    h[:execution_options] = self.execution_options&.to_h
    h[:abi] = self.abi&.to_h
    h[:boc_cache] = self.boc_cache&.to_h
    h
  end
end
ResultOfRunExecutor =
KwStruct.new(:transaction, :out_messages, :decoded, :account, :fees) do
  def initialize(transaction:, out_messages:, decoded: nil, account:, fees:)
    super
  end
end
ResultOfRunTvm =
KwStruct.new(:out_messages, :decoded, :account) do
  def initialize(out_messages:, decoded: nil, account:)
    super
  end
end
ResultOfRunGet =
KwStruct.new(:output)
TransactionFees =
KwStruct.new(
  :in_msg_fwd_fee,
  :storage_fee,
  :gas_fee,
  :out_msgs_fwd_fee,
  :total_account_fees,
  :total_output,
  :ext_in_msg_fee,
  :total_fwd_fees,
  :account_fees
) do
  def initialize(
    in_msg_fwd_fee:,
    storage_fee:,
    gas_fee:,
    out_msgs_fwd_fee:,
    total_account_fees:,
    total_output:,
    ext_in_msg_fee:,
    total_fwd_fees:,
    account_fees:
  )
    super
  end
end

Class Method Summary collapse

Class Method Details

.run_executor(ctx, params) ⇒ Object

functions



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/ever_sdk_client/tvm.rb', line 190

def self.run_executor(ctx, params)
  Interop::request_to_native_lib(
    ctx,
    "tvm.run_executor",
    params,
    is_single_thread_only: false
  ) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfRunExecutor.new(
          transaction: resp.result["transaction"],
          out_messages: resp.result["out_messages"],
          decoded: resp.result["decoded"],
          account: resp.result["account"],
          fees: resp.result["fees"]
        )
      )
    else
      yield resp
    end
  end
end

.run_get(ctx, params) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/ever_sdk_client/tvm.rb', line 234

def self.run_get(ctx, params)
  Interop::request_to_native_lib(
    ctx,
    "tvm.run_get",
    params,
    is_single_thread_only: false
  ) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfRunGet.new(output: resp.result["output"])
      )
    else
      yield resp
    end
  end
end

.run_tvm(ctx, params) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/ever_sdk_client/tvm.rb', line 213

def self.run_tvm(ctx, params)
  Interop::request_to_native_lib(
    ctx,
    "tvm.run_tvm",
    params,
    is_single_thread_only: false
  ) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfRunTvm.new(
          out_messages: resp.result["out_messages"],
          decoded: resp.result["decoded"],
          account: resp.result["account"]
        )
      )
    else
      yield resp
    end
  end
end