Skip to content

Commit

Permalink
Merge pull request #34 from radianceteam/1.27.0
Browse files Browse the repository at this point in the history
1.27.0 Update
  • Loading branch information
Paprikas authored Dec 7, 2021
2 parents bcb7959 + 7cbce40 commit fbc00c0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

all the changes are always according to the ones of the main TON SDK library; and on top on that, there may be additional ones

1.27.0
-----
* Changes `1.27.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1270--2021-12-03

1.26.0
-----
* Changes `1.26.0` https://github.com/tonlabs/TON-SDK/blob/master/CHANGELOG.md#1260--2021-11-25
Expand Down
27 changes: 27 additions & 0 deletions lib/ton_sdk_client/abi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,19 @@ def to_h

ResultOfUpdateInitialData = KwStruct.new(:data)

ParamsOfEncodeInitialData = KwStruct.new(:abi, :initial_data, :initial_pubkey, :boc_cache) do
def to_h
{
abi: abi&.to_h,
initial_data: initial_data,
initial_pubkey: initial_pubkey,
boc_cache: boc_cache&.to_h
}
end
end

ResultOfEncodeInitialData = KwStruct.new(:data)

ParamsOfDecodeInitialData = KwStruct.new(:data, :abi) do
def to_h
{
Expand Down Expand Up @@ -923,6 +936,20 @@ def self.update_initial_data(ctx, params)
end
end

def self.encode_initial_data(ctx, params)
Interop::request_to_native_lib(ctx, "abi.encode_initial_data", params) do |resp|
if resp.success?
yield NativeLibResponseResult.new(
result: ResultOfEncodeInitialData.new(
data: resp.result["data"]
)
)
else
yield resp
end
end
end

def self.decode_initial_data(ctx, params)
Interop::request_to_native_lib(ctx, "abi.decode_initial_data", params) do |resp|
if resp.success?
Expand Down
4 changes: 2 additions & 2 deletions lib/ton_sdk_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module TonSdk
VERSION = "1.26.0"
NATIVE_SDK_VERSION = "1.26.0"
VERSION = "1.27.0"
NATIVE_SDK_VERSION = "1.27.0"
end
18 changes: 16 additions & 2 deletions spec/abi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
match_events.call(expected, decode_events.call("te6ccgEBAQEAVQAApeACvg5/pmQpY4m61HmJ0ne+zjHJu3MNG8rJxUDLbHKBu/AAAAAAAAAMKr6z6rxK3xYJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA"))
end

it "#decode_update_initial_data" do
fit "#decode_update_initial_data" do
initdata_abi_json = File.read("#{TESTS_DATA_DIR}/contracts/abi_v2/t24_initdata.abi.json")
abi = TonSdk::Abi::Abi.new(
type_: :json,
Expand All @@ -296,6 +296,8 @@
expect(decoded.initial_pubkey).to eq('00' * 32)
expect(decoded.initial_data).to eq({})

encode_initial_data = 'te6ccgEBBwEARwABAcABAgPPoAQCAQFIAwAWc29tZSBzdHJpbmcCASAGBQADHuAAQQiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIoA=='

# Update initial data
initial_data = {'a': "123", 's': 'some string'}
initial_pubkey = '22' * 32
Expand All @@ -305,7 +307,19 @@
TonSdk::Abi.update_initial_data(@c_ctx.context, params) { |r| @response = r }
data_updated = @response.result.data

expect(data_updated).to eq('te6ccgEBBwEARwABAcABAgPPoAQCAQFIAwAWc29tZSBzdHJpbmcCASAGBQADHuAAQQiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIoA==')
expect(data_updated).to eq(encode_initial_data)

result = test_client.request(
"abi.encode_initial_data",
TonSdk::Abi::ParamsOfEncodeInitialData.new(
abi: abi,
initial_data: initial_data,
initial_pubkey: initial_pubkey,
boc_cache: nil
)
)

expect(result.data).to eq(encode_initial_data)

# Decode updated data
params = TonSdk::Abi::ParamsOfDecodeInitialData.new(data: data_updated, abi: abi)
Expand Down

0 comments on commit fbc00c0

Please sign in to comment.