radianceteam/everscale-client-ruby

Problem with abi

Closed this issue · 2 comments

Log:
keys public: {:public_=>"6eb71b616aadabf7aa61422007a0078d1f7951814db18efe97b68136d780ca13", :secret=>"11cdad43e860e5d26d594a3cff71a977ef505f4967748f6cac96de84c33c04a6"}
keys secret:
[*] to interrupt the loop press Ctrl+C
Invalid parameters: missing field abi at line 1 column 27
params: {"message_encode_params":{},"send_events":null}
Tip: Field "abi" value is expected, but not provided.
Tip: Field "signer" value is expected, but not provided.

require 'base64'
require 'ton_sdk_client'

PRINT_RESULT_MAX_LEN = 500

def cut_off_long_string(s)
  s2 = s[0..PRINT_RESULT_MAX_LEN]
  "#{s2} ...<cut off>"
end

cfg = TonSdk::ClientConfig.new(
  network: TonSdk::NetworkConfig.new(
    endpoints: ["net.ton.dev"]
  )
)
@c_ctx = TonSdk::ClientContext.new(cfg.to_h.to_json)

graphql_cfg = TonSdk::ClientConfig.new(
  network: TonSdk::NetworkConfig.new(
    endpoints: ["net.ton.dev/graphql"]
  )
)
@graphql_c_ctx = TonSdk::ClientContext.new(graphql_cfg.to_h.to_json)


cont_json = File.read("./grant.abi.json")
abi1 = TonSdk::Abi::Abi.new(
  type_: :contract,
  value: TonSdk::Abi::AbiContract.from_json(JSON.parse(cont_json))
)



TonSdk::Crypto::generate_random_sign_keys(@c_ctx.context) do |res|
  if res.success?
    @keys = res.result
  end
end

sleep(0.1) until @keys

puts "keys public: #{@keys.public_}"
puts "keys secret: #{@keys.secret}"

encode_params = TonSdk::Abi::ParamsOfEncodeMessage.new(
  abi: abi1,
  address: "0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd",
  call_set: TonSdk::Abi::CallSet.new(
    function_name: "grant",
    input: {addr:"0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780da"}
  ),
  signer: TonSdk::Abi::Signer.new(type_: :none)
)

cb = Proc.new do |a|
  puts "process_message > event: #{a}"
end

pr1 = TonSdk::Processing::ParamsOfProcessMessage.new(
  message_encode_params: encode_params,
  send_events: true
)

TonSdk::Processing.process_message(@c_ctx.context, pr1, cb) do |res|
  if res.success?
    puts res.result
  else
    puts res.error.message
  end
end

# required, to keep the main thread alive
loop do
  puts "[*] to interrupt the loop press Ctrl+C\r\n"
  sleep 1
end

The same code on python

    giver_abi = Abi.from_path(
        path='grant.abi.json')
    call_set = CallSet(
        function_name='grant', input={'addr': address})
    encode_params = ParamsOfEncodeMessage(
        abi=giver_abi, signer=Signer.NoSigner(), address="0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd",
        call_set=call_set)
    process_params = ParamsOfProcessMessage(
        message_encode_params=encode_params, send_events=False)
    client.processing.process_message(params=process_params)

abi grant.abi.jsoni:

{ "ABI version": 2, "header": ["time"], "functions": [ { "name": "grant", "inputs": [ {"name":"addr","type":"address"} ], "outputs": [ ] }, { "name": "constructor", "inputs": [ ], "outputs": [ ] } ], "data": [ ], "events": [ ] }

Please try branch of the upcoming release

gem "ton_sdk_client", github: "Paprikas/ton-client-ruby", branch: "1.23.0"

Fixed in 1.24.0