Module: EverSdk::Utils

Defined in:
lib/ever_sdk_client/utils.rb

Defined Under Namespace

Classes: AddressStringFormat

Constant Summary collapse

ParamsOfConvertAddress =
KwStruct.new(:address, :output_format) do
  def to_h
    {
      address: address,
      output_format: output_format.to_h
    }
  end
end
ResultOfConvertAddress =
KwStruct.new(:address)
ParamsOfCalcStorageFee =
KwStruct.new(:account, :period)
ResultOfCalcStorageFee =
KwStruct.new(:fee)
ParamsOfCompressZstd =
KwStruct.new(:uncompressed, :level)
ResultOfCompressZstd =
KwStruct.new(:compressed)
ParamsOfDecompressZstd =
KwStruct.new(:compressed)
ResultOfDecompressZstd =
KwStruct.new(:decompressed)
ParamsOfGetAddressType =
KwStruct.new(:address)
ResultOfGetAddressType =
KwStruct.new(:address_type)

Class Method Summary collapse

Class Method Details

.calc_storage_fee(ctx, params) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ever_sdk_client/utils.rb', line 74

def self.calc_storage_fee(ctx, params)
  Interop::request_to_native_lib(ctx, "utils.calc_storage_fee", params) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfCalcStorageFee.new(fee: resp.result["fee"])
      )
    else
      yield resp
    end
  end
end

.compress_zstd(ctx, params) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ever_sdk_client/utils.rb', line 86

def self.compress_zstd(ctx, params)
  Interop::request_to_native_lib(ctx, "utils.compress_zstd", params) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfCompressZstd.new(compressed: resp.result["compressed"])
      )
    else
      yield resp
    end
  end
end

.convert_address(ctx, params) ⇒ Object

functions



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ever_sdk_client/utils.rb', line 62

def self.convert_address(ctx, params)
  Interop::request_to_native_lib(ctx, "utils.convert_address", params) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfConvertAddress.new(address: resp.result["address"])
      )
    else
      yield resp
    end
  end
end

.decompress_zstd(ctx, params) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ever_sdk_client/utils.rb', line 98

def self.decompress_zstd(ctx, params)
  Interop::request_to_native_lib(ctx, "utils.decompress_zstd", params) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfDecompressZstd.new(decompressed: resp.result["decompressed"])
      )
    else
      yield resp
    end
  end
end

.get_address_type(ctx, params) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/ever_sdk_client/utils.rb', line 110

def self.get_address_type(ctx, params)
  Interop::request_to_native_lib(ctx, "utils.get_address_type", params) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfGetAddressType.new(address_type: resp.result["address_type"])
      )
    else
      yield resp
    end
  end
end