klaytn 0.0.8 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 104348459f6c2ddacedc247f7332cf17f859f11a29ae52bd1bd52f866e9208b3
4
- data.tar.gz: 0c2494aa524a6088b1e9f3f54729a668dfcd0b2a61c69c52e15a4b3082184f13
3
+ metadata.gz: d7771ed81d24129ae58f55b94a87ed18e8b6b1bd43fa174342acb7708a2de033
4
+ data.tar.gz: 5e7a878c2f6f7584cd81ef4c6fcdca8afd28ae702220f12567810519ca369fcf
5
5
  SHA512:
6
- metadata.gz: 874a809cceb44239aebfa05d50a9cf3369ddabfde41ff855a3d24c1e25ea4fd8c77a646260e303139f9689ae6c3cc0130ba858156aa85527b1425d30722e785e
7
- data.tar.gz: 984aa44b345566a9e0787171840432f67a8578db3ded083034e1e3a3025a7de9550f31b6a61023223fc6d4d736931e5e13bb4f5ab053c955c447dde8a3f6cf63
6
+ metadata.gz: e380aa08abbf8eb071e76911c2ad9fd4d77d08eb9b10d229a3a3c64bd6c5faa52ad3bf983a996e2872f10409511ebbb2787399f40409bcbacc3ecb52c05f5756
7
+ data.tar.gz: 54a213ea27fdf0f5d21663e304f241a986d777bfe2f1ce7074b3d8085c000cfb1165e6705d07b983ae831b4ba1584f8b7173a5d155f1d37c0fc3e7b58f1e2a12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- klaytn (0.0.7)
4
+ klaytn (0.1.1)
5
5
  activesupport (>= 4.2)
6
6
  httparty (~> 0.20.0)
7
7
  keccak (~> 1.3)
@@ -17,11 +17,11 @@ module Klaytn
17
17
  super
18
18
  end
19
19
 
20
- def deploy(bytecode, submit: true)
20
+ def deploy(bytecode, submit: true, gas: 900000)
21
21
  body = {
22
22
  from: kas_account_wallet_address, # must be created inside KAS console > Account Pool, and MUST be capital version from Klaytn Scope!
23
23
  input: bytecode,
24
- gas: 900000, # needs to be high for deploy to work
24
+ gas: gas,
25
25
  submit: submit
26
26
  }
27
27
 
@@ -34,7 +34,7 @@ module Klaytn
34
34
  # inputs ex: [OpenStruct.new({ "internalType": "address", "name": "addr", "type": "address" })] - array of dot-notation object from ABI
35
35
  # params ex: ['0x0xxxx'] - array of arguments accepted by function
36
36
 
37
- def invoke_function(definition, params)
37
+ def invoke_function(definition, params, gas: 0)
38
38
  raise MISSING_CONTRACT if contract_address.blank?
39
39
  raise MISSING_ABI if abi.blank?
40
40
 
@@ -44,17 +44,30 @@ module Klaytn
44
44
  built_defintion = "#{definition}(#{found_function[:inputs].map {|i| i[:type]}.join(',')})"
45
45
  built_inputs = found_function[:inputs].map { |i| OpenStruct.new(i) }
46
46
 
47
- body = function_body_builder(built_defintion, built_inputs, params)
47
+ body = function_body_builder(built_defintion, built_inputs, params, gas)
48
48
  resp = HTTParty.post(BASE_URL + '/execute', body: body.to_json, headers: headers.merge('x-krn' => kas_account_pool_krn), basic_auth: basic_auth)
49
49
  JSON.parse(resp.body)
50
50
  end
51
51
 
52
- def function_body_builder(definition, inputs, params)
52
+ def raw_transaction(input_data, gas: 0)
53
+ raise MISSING_CONTRACT if contract_address.blank?
54
+ body = {
55
+ from: kas_account_wallet_address,
56
+ to: contract_address,
57
+ input: input_data,
58
+ gas: gas,
59
+ submit: true
60
+ }
61
+ resp = HTTParty.post(BASE_URL + '/execute', body: body.to_json, headers: headers.merge('x-krn' => kas_account_pool_krn), basic_auth: basic_auth)
62
+ JSON.parse(resp.body)
63
+ end
64
+
65
+ def function_body_builder(definition, inputs, params, gas)
53
66
  {
54
67
  from: kas_account_wallet_address,
55
68
  to: contract_address,
56
69
  input: encoder.encode_function(definition, inputs, params),
57
- # gas: 900000, # better to exclude, otherwise 'insufficient funds' error is common
70
+ gas: gas,
58
71
  submit: true
59
72
  }
60
73
  end
@@ -1,3 +1,3 @@
1
1
  module Klaytn
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klaytn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Kulp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-03-05 00:00:00.000000000 Z
12
+ date: 2022-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec