klaytn 0.1.1 → 0.1.2

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: d7771ed81d24129ae58f55b94a87ed18e8b6b1bd43fa174342acb7708a2de033
4
- data.tar.gz: 5e7a878c2f6f7584cd81ef4c6fcdca8afd28ae702220f12567810519ca369fcf
3
+ metadata.gz: 1c620946e62b78ff80bd0278595c2c361746ae3410aeb29ac9643dcda742a59f
4
+ data.tar.gz: c4783ec33c0f850229432f504732d881b767e4c79e9f3eed4d054bd0bf7ee584
5
5
  SHA512:
6
- metadata.gz: e380aa08abbf8eb071e76911c2ad9fd4d77d08eb9b10d229a3a3c64bd6c5faa52ad3bf983a996e2872f10409511ebbb2787399f40409bcbacc3ecb52c05f5756
7
- data.tar.gz: 54a213ea27fdf0f5d21663e304f241a986d777bfe2f1ce7074b3d8085c000cfb1165e6705d07b983ae831b4ba1584f8b7173a5d155f1d37c0fc3e7b58f1e2a12
6
+ metadata.gz: bfca0a8b675e50ec7fb3a616bcaa2817017601c8a4add61d1b269ef05620aef24149740c05b20d97f251d463a693e7b9e02506929452362d620ab4e4905f8af3
7
+ data.tar.gz: 96cb03c757b0306c232274dddf995450a0e6d0160fee84c6a99d27ec27b95ebf65f03b7bef0d2ca6f0ad544780b69f198b97d18eebce9ba25ed5db2c71f79a43
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- klaytn (0.1.1)
4
+ klaytn (0.1.2)
5
5
  activesupport (>= 4.2)
6
6
  httparty (~> 0.20.0)
7
7
  keccak (~> 1.3)
data/lib/klaytn/base.rb CHANGED
@@ -8,5 +8,6 @@ module Klaytn
8
8
  MISSING_ACCOUNT_POOL_KRN = 'Please provide a KAS Account Pool KRN id to finish linking your KAS Wallet (ex: krn:XXXX:wallet:yyyy...).'.freeze # KAS > Service > Wallet > Account Pool > KRN
9
9
  MISSING_ABI = 'Please provide the contract ABI, an array-like object returned by the compiler.'.freeze
10
10
  FUNCTION_NOT_FOUND = 'Function with definition XXX not found.'.freeze
11
+ MISSING_JSONRPC_METHOD = 'RPC method name required, e.g. klay_blockNumber.'.freeze
11
12
  end
12
13
  end
@@ -29,8 +29,7 @@ module Klaytn
29
29
  JSON.parse(resp.body)
30
30
  end
31
31
 
32
- ## DEPRECATE: definition ex: 'addAddressToWhitelist(address)' - string literal Solidity function definition
33
- # definition ex: 'addAddressToWhitelist' - string literal Solidity function definition, without parameters/parens
32
+ # definition ex: 'addAddressToWhitelist' - string literal Solidity function definition, without params/parens
34
33
  # inputs ex: [OpenStruct.new({ "internalType": "address", "name": "addr", "type": "address" })] - array of dot-notation object from ABI
35
34
  # params ex: ['0x0xxxx'] - array of arguments accepted by function
36
35
 
@@ -0,0 +1,22 @@
1
+ module Klaytn
2
+ class JsonRpc < Client
3
+ BASE_URL = 'https://node-api.klaytnapi.com/v1/klaytn'.freeze
4
+
5
+ def invoke_function(opts)
6
+ raise MISSING_JSONRPC_METHOD if opts[:method].blank?
7
+
8
+ body = function_body_builder(opts)
9
+ resp = HTTParty.post(BASE_URL, body: body.to_json, headers: headers.merge('content-type' => 'application/json'), basic_auth: basic_auth)
10
+ JSON.parse(resp.body)
11
+ end
12
+
13
+ def function_body_builder(opts)
14
+ {
15
+ id: opts[:id] || 1,
16
+ jsonrpc: opts[:jsonrpc_version] || "2.0",
17
+ method: opts[:method], # => klay_isContractAccount
18
+ params: opts[:params] # => ["0x4319c81f7894f60c70600cf29ee440ed62e7401e", "earliest"]
19
+ }
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Klaytn
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/klaytn.rb CHANGED
@@ -11,6 +11,7 @@ module Klaytn
11
11
  require 'klaytn/contract'
12
12
  require 'klaytn/decoder'
13
13
  require 'klaytn/encoder'
14
+ require 'klaytn/json_rpc'
14
15
  require 'klaytn/token'
15
16
  require 'klaytn/transaction'
16
17
  require 'klaytn/wallet'
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Kulp
@@ -93,6 +93,7 @@ files:
93
93
  - lib/klaytn/contract.rb
94
94
  - lib/klaytn/decoder.rb
95
95
  - lib/klaytn/encoder.rb
96
+ - lib/klaytn/json_rpc.rb
96
97
  - lib/klaytn/token.rb
97
98
  - lib/klaytn/transaction.rb
98
99
  - lib/klaytn/version.rb