klay 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS.txt +5 -4
- data/LICENSE.txt +0 -1
- data/README.md +30 -84
- data/bin/setup +1 -1
- data/klay.gemspec +1 -1
- data/lib/klay/abi/type.rb +8 -8
- data/lib/klay/abi.rb +7 -7
- data/lib/klay/address.rb +5 -5
- data/lib/klay/api.rb +84 -84
- data/lib/klay/chain.rb +2 -2
- data/lib/klay/client/http.rb +2 -2
- data/lib/klay/client/ipc.rb +2 -2
- data/lib/klay/client.rb +18 -18
- data/lib/klay/constant.rb +2 -2
- data/lib/klay/eip712.rb +2 -2
- data/lib/klay/key/decrypter.rb +9 -9
- data/lib/klay/key/encrypter.rb +8 -8
- data/lib/klay/key.rb +12 -12
- data/lib/klay/rlp/decoder.rb +3 -3
- data/lib/klay/rlp/encoder.rb +4 -4
- data/lib/klay/rlp/sedes/big_endian_int.rb +2 -2
- data/lib/klay/rlp/sedes/binary.rb +3 -3
- data/lib/klay/rlp/sedes/list.rb +2 -2
- data/lib/klay/rlp/sedes.rb +6 -6
- data/lib/klay/rlp.rb +4 -4
- data/lib/klay/signature.rb +10 -11
- data/lib/klay/tx/eip1559.rb +9 -9
- data/lib/klay/tx/eip2930.rb +9 -9
- data/lib/klay/tx/legacy.rb +9 -9
- data/lib/klay/tx.rb +7 -7
- data/lib/klay/unit.rb +9 -21
- data/lib/klay/util.rb +5 -5
- data/lib/klay/version.rb +4 -4
- data/lib/klay.rb +3 -3
- metadata +2 -4
- data/.github/workflows/codeql.yml +0 -48
- data/.github/workflows/docs.yml +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adb9b83c9f7962e5888e5788c5d51edda5d6d4babedd909f451a8e1f4624da22
|
4
|
+
data.tar.gz: 7b25cf0f089a7806484742e80d51ae10697756826fc0df7a024414eb24187751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffc70a3cb8f242b24114a6cb2d4d86161df63474aadd369d11c211059c6a0222e53bae756b78444982629824788a8c8ab9b6337ddc1d24afb2f568c82eaac9e8
|
7
|
+
data.tar.gz: 2c695bf6d4ab5046b701aaaf4638f29dba43550055e14540107a888bbe588e0cf28a87c36981bf2a4c6febaf393955a4a311db4e8c857180455a1628900975c9
|
data/AUTHORS.txt
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
The Ruby-Eth Contributors are:
|
2
|
-
*
|
2
|
+
* Steve Ellis @se3000
|
3
|
+
* Afri Schoedon @q9f
|
4
|
+
* John Omar @chainoperator
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
* https://github.com/noMacGuffins/ruby-klay
|
6
|
+
See also:
|
7
|
+
* https://github.com/q9f/eth.rb/graphs/contributors
|
7
8
|
|
8
9
|
The Ruby-Eth project was maintained 2016-2020 in Steve Ellis's (@se3000)
|
9
10
|
repository licensed under MIT conditions:
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,58 +1,40 @@
|
|
1
|
+
![Klay.rb](https://s3.ap-northeast-2.amazonaws.com/klay.rb/repository-open-graph-template.png)
|
2
|
+
|
1
3
|
# Klay for Ruby
|
2
4
|
|
3
|
-
A simple library to build and sign
|
5
|
+
A simple library to build and sign Klaytn transactions. Allows separation of key and node management. Sign transactions and handle keys anywhere you can run ruby, broadcast transactions through any node. Sign messages and recover signatures for authentication.
|
4
6
|
|
5
7
|
What you get:
|
6
|
-
- [x] Secp256k1 Key-Pairs and Encrypted
|
7
|
-
- [x] EIP-55 Checksummed
|
8
|
+
- [x] Secp256k1 Key-Pairs and Encrypted Klaytn Key-Stores (JSON)
|
9
|
+
- [x] EIP-55 Checksummed Klaytn Addresses
|
8
10
|
- [x] EIP-155 Replay protection with Chain IDs (with presets)
|
9
|
-
- [x] EIP-191
|
10
|
-
- [x] EIP-712
|
11
|
-
- [x] EIP-1559
|
11
|
+
- [x] EIP-191 Klaytn Signed Messages (with prefix and type)
|
12
|
+
- [x] EIP-712 Klaytn Signed Type Data
|
13
|
+
- [x] EIP-1559 Klaytn Type-2 Transactions (with priority fee and max gas fee)
|
12
14
|
- [x] EIP-2028 Call-data intrinsic gas cost estimates (plus access lists)
|
13
|
-
- [x] EIP-2718
|
14
|
-
- [x] EIP-2930
|
15
|
+
- [x] EIP-2718 Klaytn Transaction Envelopes (and types)
|
16
|
+
- [x] EIP-2930 Klaytn Type-1 Transactions (with access lists)
|
15
17
|
- [x] ABI-Encoder and Decoder (including type parser)
|
16
18
|
- [x] RLP-Encoder and Decoder (including sedes)
|
17
19
|
- [x] RPC-Client (IPC/HTTP) for Execution-Layer APIs
|
18
20
|
|
19
|
-
Soon (TM):
|
20
|
-
- [ ] Smart Contracts and Solidity Support
|
21
|
-
- [ ] EIP-1271 Smart-Contract Authentification
|
22
|
-
- [ ] HD-Wallets (BIP-32) and Mnemonics (BIP-39)
|
23
|
-
|
24
|
-
Contents:
|
25
|
-
- [1. Installation](#1-installation)
|
26
|
-
- [2. Usage](#2-usage)
|
27
|
-
- [2.1. Klayereum Keys and Addresses (EIP-55)](#21-ethereum-keys-and-addresses-eip-55)
|
28
|
-
- [2.2. Klayereum Signatures (EIP-191, EIP-712)](#22-ethereum-signatures-eip-191-eip-712)
|
29
|
-
- [2.3. Klayereum Chains (EIP-155)](#23-ethereum-chains-eip-155)
|
30
|
-
- [2.4. Klayereum Transactions (EIP-1559, EIP-2718, EIP-2930)](#24-ethereum-transactions-eip-1559-eip-2718-eip-2930)
|
31
|
-
- [2.5. Klayereum ABI Encoder and Decoder](#25-ethereum-abi-encoder-and-decoder)
|
32
|
-
- [2.6. Klayereum RLP Encoder and Decoder](#26-ethereum-rlp-encoder-and-decoder)
|
33
|
-
- [2.7. Klayereum RPC-Client](#27-ethereum-rpc-client)
|
34
|
-
- [3. Documentation](#3-documentation)
|
35
|
-
- [4. Testing](#4-testing)
|
36
|
-
- [5. Contributing](#5-contributing)
|
37
|
-
- [6. License and Credits](#6-license-and-credits)
|
38
|
-
|
39
21
|
## 1. Installation
|
40
22
|
|
41
23
|
Add this line to your application's Gemfile:
|
42
24
|
|
43
25
|
```ruby
|
44
|
-
gem "
|
26
|
+
gem "klay"
|
45
27
|
```
|
46
28
|
|
47
29
|
Or install it yourself as:
|
48
30
|
|
49
31
|
```shell
|
50
|
-
gem install
|
32
|
+
gem install klay
|
51
33
|
```
|
52
34
|
|
53
35
|
## 2. Usage
|
54
36
|
|
55
|
-
### 2.1.
|
37
|
+
### 2.1. Klaytn Keys and Addresses (EIP-55)
|
56
38
|
|
57
39
|
Generate a random Secp256k1 key-pair.
|
58
40
|
|
@@ -61,7 +43,7 @@ key = Klay::Key.new
|
|
61
43
|
# => #<Klay::Key:0x00005574a6ba80b8 @private_key=#<Secp256k1::PrivateKey:0x00005574a6b9a0a8 @data=")&\x86P\xB5\x16\xD9]\xFA;\x1F\xF6\xD9\xCF\xE3Vj/\xE2\x81\xC0\x9D\xE9\x05o!q\x82G\x9A\x10Q">, @public_key=#<Secp256k1::PublicKey:0x00005574a6b9bf98>>
|
62
44
|
```
|
63
45
|
|
64
|
-
Create an password-encrypted
|
46
|
+
Create an password-encrypted Klaytn key-store.
|
65
47
|
|
66
48
|
```ruby
|
67
49
|
my_key = Klay::Key.new priv: "30137644b564785d01420f8043f043d74dcca64008e57c59f8ce713a0005a54b"
|
@@ -71,7 +53,7 @@ restored_key = Klay::Key::Decrypter.perform key_store, "secret-password-1337"
|
|
71
53
|
# => "30137644b564785d01420f8043f043d74dcca64008e57c59f8ce713a0005a54b"
|
72
54
|
```
|
73
55
|
|
74
|
-
Manage
|
56
|
+
Manage Klaytn address objects adhering to EIP-55 checksum format.
|
75
57
|
|
76
58
|
```ruby
|
77
59
|
address = Klay::Address.new "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"
|
@@ -84,7 +66,7 @@ address.checksummed # EIP 55
|
|
84
66
|
|
85
67
|
See `/spec` or [Documentation](https://q9f.github.io/eth.rb/) for more details about key-pairs, encrypting/decrypting key-stores with a secret, and checksummed addresses.
|
86
68
|
|
87
|
-
### 2.2.
|
69
|
+
### 2.2. Klaytn Signatures (EIP-191, EIP-712)
|
88
70
|
|
89
71
|
Manage keypairs to sign messages in EIP-191 (`personal_sign`) format or typed data in EIP-712 (`sign_typed_data`) format.
|
90
72
|
|
@@ -116,9 +98,9 @@ Klay::Signature.verify "Hello World!", signature, address, Klay::Chain::GOERLI
|
|
116
98
|
|
117
99
|
See `/spec` or [Documentation](https://q9f.github.io/eth.rb/) for signing typed data as per EIP-712.
|
118
100
|
|
119
|
-
### 2.3.
|
101
|
+
### 2.3. Klaytn Chains (EIP-155)
|
120
102
|
|
121
|
-
Manage
|
103
|
+
Manage Klaytn chain IDs for EIP-155 replay protection.
|
122
104
|
|
123
105
|
```ruby
|
124
106
|
chain_id = Klay::Chain::OPTIMISM
|
@@ -131,7 +113,7 @@ chain_id = Klay::Chain.to_chain_id v
|
|
131
113
|
# => 10
|
132
114
|
```
|
133
115
|
|
134
|
-
### 2.4.
|
116
|
+
### 2.4. Klaytn Transactions (EIP-1559, EIP-2718, EIP-2930)
|
135
117
|
|
136
118
|
Create an EIP-1559-conform transaction:
|
137
119
|
|
@@ -139,11 +121,11 @@ Create an EIP-1559-conform transaction:
|
|
139
121
|
payload = {
|
140
122
|
chain_id: Klay::Chain::GOERLI,
|
141
123
|
nonce: 5,
|
142
|
-
priority_fee: 3 * Klay::Unit::
|
143
|
-
max_gas_fee: 69 * Klay::Unit::
|
124
|
+
priority_fee: 3 * Klay::Unit::GPEB,
|
125
|
+
max_gas_fee: 69 * Klay::Unit::GPEB,
|
144
126
|
gas_limit: 230_420,
|
145
127
|
to: "0xCaA29806044A08E533963b2e573C1230A2cd9a2d",
|
146
|
-
value: 0.069423 * Klay::Unit::
|
128
|
+
value: 0.069423 * Klay::Unit::KLAY,
|
147
129
|
}
|
148
130
|
# => {:chain_id=>5, :nonce=>5, :priority_fee=>0.3e10, :max_gas_fee=>0.69e11, :gas_limit=>230420, :to=>"0xCaA29806044A08E533963b2e573C1230A2cd9a2d", :value=>0.69423e17}
|
149
131
|
tx = Klay::Tx.new payload
|
@@ -158,9 +140,9 @@ tx.hex
|
|
158
140
|
|
159
141
|
This gem also supports access lists and ABI-encoded data payloads. See `/spec` or [Documentation](https://q9f.github.io/eth.rb/) for more details about the various supported transaction types (legacy, type-1, type-2), payload parameters, and how to estimate intrinsic gas costs.
|
160
142
|
|
161
|
-
### 2.5.
|
143
|
+
### 2.5. Klaytn ABI Encoder and Decoder
|
162
144
|
|
163
|
-
Encode and decode
|
145
|
+
Encode and decode Klaytn application binary interface data (ABI).
|
164
146
|
|
165
147
|
```ruby
|
166
148
|
Klay::Util.bin_to_hex Klay::Abi.encode(["string", "address"], ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"])
|
@@ -169,9 +151,9 @@ Klay::Abi.decode(["string", "address"], "000000000000000000000000000000000000000
|
|
169
151
|
# => ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"]
|
170
152
|
```
|
171
153
|
|
172
|
-
### 2.6.
|
154
|
+
### 2.6. Klaytn RLP Encoder and Decoder
|
173
155
|
|
174
|
-
Serialize and deserialize
|
156
|
+
Serialize and deserialize Klaytn recursive-length prefix data (RLP).
|
175
157
|
|
176
158
|
```ruby
|
177
159
|
Klay::Util.bin_to_hex Klay::Rlp.encode ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"]
|
@@ -187,7 +169,7 @@ Klay::Rlp.decode "c7c0c1c0c3c0c1c0"
|
|
187
169
|
# => [[], [[]], [[], [[]]]]
|
188
170
|
```
|
189
171
|
|
190
|
-
### 2.7.
|
172
|
+
### 2.7. Klaytn RPC-Client
|
191
173
|
|
192
174
|
Create an IPC- or HTTP-RPC-API client to seamlessly query the chain state, e.g., Infura over HTTPS with access token:
|
193
175
|
|
@@ -207,7 +189,7 @@ cli = Klay::Client.create "/tmp/geth.ipc"
|
|
207
189
|
# => #<Klay::Client::Ipc:0x000055d43f51c390 @gas_limit=21000, @id=0, @max_fee_per_gas=0.2e11, @max_priority_fee_per_gas=0, @path="/tmp/geth.ipc">
|
208
190
|
cli.eth_coinbase
|
209
191
|
# => {"jsonrpc"=>"2.0", "id"=>1, "result"=>"0x6868074fb21c48dfad0c448fbabd99383a6598e4"}
|
210
|
-
tx = cli.transfer_and_wait(Klay::Key.new.address, 1337 * Klay::Unit::
|
192
|
+
tx = cli.transfer_and_wait(Klay::Key.new.address, 1337 * Klay::Unit::KLAY)
|
211
193
|
# => "0x141c6dff40df34fe4fce5a65588d2161dab3e0e977fb8049ff7d79bc901034f7"
|
212
194
|
cli.eth_get_transaction_by_hash tx
|
213
195
|
# => {"jsonrpc"=>"2.0", "id"=>8, "result"=> {"blockHash"=>"0x47e742038c75851348dbda87b15fde044d54c442c371f43bea881a44d5589de3", "blockNumber"=>"0x1", "from"=>"0x6868074fb21c48dfad0c448fbabd99383a6598e4", "gas"=>"0x5208", "gasPrice"=>"0x342770c1", "maxFeePerGas"=>"0x77359401", "maxPriorityFeePerGas"=>"0x1", "hash"=>"0x141c6dff40df34fe4fce5a65588d2161dab3e0e977fb8049ff7d79bc901034f7", "input"=>"0x", "nonce"=>"0x0", "to"=>"0x311c61e5dc6123ad016bb7fd687d283c327bcd5f", "transactionIndex"=>"0x0", "value"=>"0x487a9a304539440000", "type"=>"0x2", "accessList"=>[], "chainId"=>"0x539", "v"=>"0x0", "r"=>"0xb42477d69eae65a3a3d91d9cb173e4a45a403fb0a15fa729dbfdc9d13211d7b5", "s"=>"0x4a2f98fc2b61c2d7c907520bc8c6ebe42ea6fe1cb6824f95e4b30e9464395100"}}
|
@@ -217,46 +199,10 @@ cli.get_nonce cli.eth_coinbase["result"]
|
|
217
199
|
# => 1
|
218
200
|
```
|
219
201
|
|
220
|
-
## 3.
|
221
|
-
|
222
|
-
For any specific version, docs can be generated by `yard`:
|
223
|
-
|
224
|
-
```shell
|
225
|
-
gem install bundler rdoc yard
|
226
|
-
git checkout v0.0.1
|
227
|
-
yard doc
|
228
|
-
```
|
229
|
-
|
230
|
-
The goal is to have 100% API documentation available.
|
231
|
-
|
232
|
-
## 4. Testing
|
233
|
-
|
234
|
-
To run tests, simply use `rspec`. Note, that the Klayereum tests fixtures are required.
|
235
|
-
|
236
|
-
```shell
|
237
|
-
git submodule update --init --recursive
|
238
|
-
bundle install
|
239
|
-
rspec
|
240
|
-
```
|
241
|
-
|
242
|
-
The goal is to have 100% specification coverage for all code inside this gem.
|
243
|
-
|
244
|
-
## 5. Contributing
|
202
|
+
## 3. Contributing
|
245
203
|
|
246
204
|
Pull requests are welcome! To contribute, please consider the following:
|
247
205
|
* Code should be fully documented. Run `yard doc` and make sure it does not yield any warnings or undocumented sets.
|
248
206
|
* Code should be fully covered by tests. Run `rspec` to make sure all tests pass. The CI has an integration that will assis you to identify uncovered lines of code and get coverage up to 100%.
|
249
207
|
* Code should be formatted properly. Try to eliminate the most common issues such as trailing white-spaces or duplicate new-lines. Usage of the `rufo` gem is recommended.
|
250
|
-
* Submit pull requests, questions, or issues to Github: https://github.com/noMacGuffins/klay
|
251
|
-
|
252
|
-
## 6. License and Credits
|
253
|
-
The `eth` gem is licensed under the conditions of [Apache 2.0](./LICENSE.txt). Please see [AUTHORS](./AUTHORS.txt) for contributors and copyright notices.
|
254
|
-
|
255
|
-
This gem is a complete rewrite of the old `eth` gem by Steve Ellis.
|
256
|
-
* https://github.com/se3000/ruby-eth/ (MIT)
|
257
|
-
|
258
|
-
It also contains a revised version the ABI gem by Jan Xie and Zhang Yaning.
|
259
|
-
* https://github.com/cryptape/ruby-ethereum-abi (MIT)
|
260
|
-
|
261
|
-
It also contains a revised version the RLP gem by Jan Xie and Zhang Yaning.
|
262
|
-
* https://github.com/cryptape/ruby-rlp (MIT)
|
208
|
+
* Submit pull requests, questions, or issues to Github: https://github.com/noMacGuffins/klay
|
data/bin/setup
CHANGED
data/klay.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.platform = Gem::Platform::RUBY
|
34
34
|
spec.required_ruby_version = ">= 2.6", "< 4.0"
|
35
35
|
|
36
|
-
# keccak for hashing everything in
|
36
|
+
# keccak for hashing everything in klaytn
|
37
37
|
spec.add_dependency "keccak", "~> 1.3"
|
38
38
|
|
39
39
|
# konstructor gem for overloading constructors
|
data/lib/klay/abi/type.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-2022 The Ruby-
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Klay Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -14,10 +14,10 @@
|
|
14
14
|
|
15
15
|
# -*- encoding : ascii-8bit -*-
|
16
16
|
|
17
|
-
# Provides the {
|
17
|
+
# Provides the {Klay} module.
|
18
18
|
module Klay
|
19
19
|
|
20
|
-
# Provides a Ruby implementation of the
|
20
|
+
# Provides a Ruby implementation of the Klaytn Applicatoin Binary Interface (ABI).
|
21
21
|
module Abi
|
22
22
|
|
23
23
|
# Provides a class to handle and parse common ABI types.
|
@@ -41,7 +41,7 @@ module Klay
|
|
41
41
|
# @param base_type [String] the base-type attribute.
|
42
42
|
# @param sub_type [String] the sub-type attribute.
|
43
43
|
# @param dimensions [Array] the dimension attribute.
|
44
|
-
# @return [
|
44
|
+
# @return [Klay::Abi::Type] an ABI type object.
|
45
45
|
def initialize(base_type, sub_type, dimensions)
|
46
46
|
sub_type = sub_type.to_s
|
47
47
|
@base_type = base_type
|
@@ -56,7 +56,7 @@ module Klay
|
|
56
56
|
# Creates a new Type upon success (using konstructor).
|
57
57
|
#
|
58
58
|
# @param type [String] a common Solidity type.
|
59
|
-
# @return [
|
59
|
+
# @return [Klay::Abi::Type] a parsed Type object.
|
60
60
|
# @raise [ParseError] if it fails to parse the type.
|
61
61
|
def parse(type)
|
62
62
|
_, base_type, sub_type, dimension = /([a-z]*)([0-9]*x?[0-9]*)((\[[0-9]*\])*)/.match(type).to_a
|
@@ -77,14 +77,14 @@ module Klay
|
|
77
77
|
|
78
78
|
# Creates a new uint256 type used for size.
|
79
79
|
#
|
80
|
-
# @return [
|
80
|
+
# @return [Klay::Abi::Type] a uint256 size type.
|
81
81
|
def self.size_type
|
82
82
|
@size_type ||= new("uint", 256, [])
|
83
83
|
end
|
84
84
|
|
85
85
|
# Compares two types for their attributes.
|
86
86
|
#
|
87
|
-
# @param another_type [
|
87
|
+
# @param another_type [Klay::Abi::Type] another type to be compared.
|
88
88
|
# @return [Boolean] true if all attributes match.
|
89
89
|
def ==(another_type)
|
90
90
|
base_type == another_type.base_type and
|
@@ -120,7 +120,7 @@ module Klay
|
|
120
120
|
|
121
121
|
# Types can have nested sub-types in arrays.
|
122
122
|
#
|
123
|
-
# @return [
|
123
|
+
# @return [Klay::Abi::Type] nested sub-type.
|
124
124
|
def nested_sub
|
125
125
|
@nested_sub ||= self.class.new(base_type, sub_type, dimensions[0...-1])
|
126
126
|
end
|
data/lib/klay/abi.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-2022 The Ruby-
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Klay Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -18,10 +18,10 @@ require "konstructor"
|
|
18
18
|
|
19
19
|
require "klay/abi/type"
|
20
20
|
|
21
|
-
# Provides the {
|
21
|
+
# Provides the {Klay} module.
|
22
22
|
module Klay
|
23
23
|
|
24
|
-
# Provides a Ruby implementation of the
|
24
|
+
# Provides a Ruby implementation of the Klaytn Applicatoin Binary Interface (ABI).
|
25
25
|
# ref: https://docs.soliditylang.org/en/develop/abi-spec.html
|
26
26
|
module Abi
|
27
27
|
extend self
|
@@ -68,7 +68,7 @@ module Klay
|
|
68
68
|
|
69
69
|
# Encodes a specific value, either static or dynamic.
|
70
70
|
#
|
71
|
-
# @param type [
|
71
|
+
# @param type [Klay::Abi::Type] type to be encoded.
|
72
72
|
# @param arg [String|Number] value to be encoded.
|
73
73
|
# @return [String] the encoded type.
|
74
74
|
# @raise [EncodingError] if value does not match type.
|
@@ -110,7 +110,7 @@ module Klay
|
|
110
110
|
|
111
111
|
# Encodes primitive types.
|
112
112
|
#
|
113
|
-
# @param type [
|
113
|
+
# @param type [Klay::Abi::Type] type to be encoded.
|
114
114
|
# @param arg [String|Number] value to be encoded.
|
115
115
|
# @return [String] the encoded primitive type.
|
116
116
|
# @raise [EncodingError] if value does not match type.
|
@@ -198,7 +198,7 @@ module Klay
|
|
198
198
|
|
199
199
|
# Decodes a specific value, either static or dynamic.
|
200
200
|
#
|
201
|
-
# @param type [
|
201
|
+
# @param type [Klay::Abi::Type] type to be decoded.
|
202
202
|
# @param arg [String] encoded type data string.
|
203
203
|
# @return [String] the decoded data for the type.
|
204
204
|
# @raise [DecodingError] if decoding fails for type.
|
@@ -234,7 +234,7 @@ module Klay
|
|
234
234
|
|
235
235
|
# Decodes primitive types.
|
236
236
|
#
|
237
|
-
# @param type [
|
237
|
+
# @param type [Klay::Abi::Type] type to be decoded.
|
238
238
|
# @param data [String] encoded primitive type data string.
|
239
239
|
# @return [String] the decoded data for the type.
|
240
240
|
# @raise [DecodingError] if decoding fails for type.
|
data/lib/klay/address.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-2022 The Ruby-
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Klay Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,19 +12,19 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Provides the {
|
15
|
+
# Provides the {Klay} module.
|
16
16
|
module Klay
|
17
17
|
|
18
|
-
# The {
|
18
|
+
# The {Klay::Address} class to handle checksummed Klaytn addresses.
|
19
19
|
class Address
|
20
20
|
|
21
21
|
# Provides a special checksum error if EIP-55 is violated.
|
22
22
|
class CheckSumError < StandardError; end
|
23
23
|
|
24
|
-
# The prefixed and checksummed
|
24
|
+
# The prefixed and checksummed Klaytn address.
|
25
25
|
attr_reader :address
|
26
26
|
|
27
|
-
# Constructor of the {
|
27
|
+
# Constructor of the {Klay::Address} class. Creates a new hex
|
28
28
|
# prefixed address.
|
29
29
|
#
|
30
30
|
# @param address [String] hex string representing an ethereum address.
|
data/lib/klay/api.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-2022 The Ruby-
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Klay Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,10 +12,10 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Provides the {
|
15
|
+
# Provides the {Klay} module.
|
16
16
|
module Klay
|
17
17
|
|
18
|
-
# Provides the `
|
18
|
+
# Provides the `Klay::Api` module grouping known RPC commands.
|
19
19
|
module Api
|
20
20
|
|
21
21
|
# Implements the available RPC-APIs provided by Geth version 1.10.15.
|
@@ -99,86 +99,86 @@ module Klay
|
|
99
99
|
"debug_writeBlockProfile",
|
100
100
|
"debug_writeMemProfile",
|
101
101
|
"debug_writeMutexProfile",
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
105
|
-
"
|
106
|
-
"
|
107
|
-
"
|
108
|
-
"
|
109
|
-
"
|
110
|
-
"
|
111
|
-
"
|
112
|
-
"
|
113
|
-
"
|
114
|
-
"
|
115
|
-
"
|
116
|
-
"
|
117
|
-
"
|
118
|
-
"
|
119
|
-
"
|
120
|
-
"
|
121
|
-
"
|
122
|
-
"
|
123
|
-
"
|
124
|
-
"
|
125
|
-
"
|
126
|
-
"
|
127
|
-
"
|
128
|
-
"
|
129
|
-
"
|
130
|
-
"
|
131
|
-
"
|
132
|
-
"
|
133
|
-
"
|
134
|
-
"
|
135
|
-
"
|
136
|
-
"
|
137
|
-
"
|
138
|
-
"
|
139
|
-
"
|
140
|
-
"
|
141
|
-
"
|
142
|
-
"
|
143
|
-
"
|
144
|
-
"
|
145
|
-
"
|
146
|
-
"
|
147
|
-
"
|
148
|
-
"
|
149
|
-
"
|
150
|
-
"
|
151
|
-
"
|
152
|
-
"
|
153
|
-
"
|
154
|
-
"
|
155
|
-
"
|
156
|
-
"
|
157
|
-
"
|
158
|
-
"
|
159
|
-
"
|
160
|
-
"
|
161
|
-
"
|
162
|
-
"
|
163
|
-
"
|
164
|
-
"
|
165
|
-
"
|
166
|
-
"
|
167
|
-
"
|
168
|
-
"
|
169
|
-
"
|
170
|
-
"
|
171
|
-
"
|
172
|
-
"
|
173
|
-
"
|
174
|
-
"
|
175
|
-
"
|
176
|
-
"
|
177
|
-
"
|
178
|
-
"
|
179
|
-
"
|
180
|
-
"
|
181
|
-
"
|
102
|
+
"klay_accounts",
|
103
|
+
"klay_blockNumber",
|
104
|
+
"klay_call",
|
105
|
+
"klay_chainId",
|
106
|
+
"klay_coinbase",
|
107
|
+
"klay_compile",
|
108
|
+
"klay_contract",
|
109
|
+
"klay_createAccessList",
|
110
|
+
"klay_defaultAccount",
|
111
|
+
"klay_defaultBlock",
|
112
|
+
"klay_estimateGas",
|
113
|
+
"klay_feeHistory",
|
114
|
+
"klay_fillTransaction",
|
115
|
+
"klay_filter",
|
116
|
+
"klay_gasPrice",
|
117
|
+
"klay_getAccounts",
|
118
|
+
"klay_getBalance",
|
119
|
+
"klay_getBlock",
|
120
|
+
"klay_getBlockByHash",
|
121
|
+
"klay_getBlockByNumber",
|
122
|
+
"klay_getBlockNumber",
|
123
|
+
"klay_getBlockTransactionCount",
|
124
|
+
"klay_getBlockTransactionCountByHash",
|
125
|
+
"klay_getBlockTransactionCountByNumber",
|
126
|
+
"klay_getBlockUncleCount",
|
127
|
+
"klay_getCode",
|
128
|
+
"klay_getCoinbase",
|
129
|
+
"klay_getCompilers",
|
130
|
+
"klay_getFilterChanges",
|
131
|
+
"klay_getFilterLogs",
|
132
|
+
"klay_getGasPrice",
|
133
|
+
"klay_gklayashrate",
|
134
|
+
"klay_gklayeaderByHash",
|
135
|
+
"klay_gklayeaderByNumber",
|
136
|
+
"klay_getLogs",
|
137
|
+
"klay_getMaxPriorityFeePerGas",
|
138
|
+
"klay_getMining",
|
139
|
+
"klay_getPendingTransactions",
|
140
|
+
"klay_getProof",
|
141
|
+
"klay_getProtocolVersion",
|
142
|
+
"klay_getRawTransaction",
|
143
|
+
"klay_getRawTransactionFromBlock",
|
144
|
+
"klay_getStorageAt",
|
145
|
+
"klay_getSyncing",
|
146
|
+
"klay_getTransaction",
|
147
|
+
"klay_getTransactionByBlockHashAndIndex",
|
148
|
+
"klay_getTransactionByBlockNumberAndIndex",
|
149
|
+
"klay_getTransactionByHash",
|
150
|
+
"klay_getTransactionCount",
|
151
|
+
"klay_getTransactionFromBlock",
|
152
|
+
"klay_getTransactionReceipt",
|
153
|
+
"klay_getUncle",
|
154
|
+
"klay_getUncleCountByBlockHash",
|
155
|
+
"klay_getUncleCountByBlockNumber",
|
156
|
+
"klay_getWork",
|
157
|
+
"klay_hashrate",
|
158
|
+
"klay_iban",
|
159
|
+
"klay_icapNamereg",
|
160
|
+
"klay_isSyncing",
|
161
|
+
"klay_maxPriorityFeePerGas",
|
162
|
+
"klay_mining",
|
163
|
+
"klay_namereg",
|
164
|
+
"klay_newBlockFilter",
|
165
|
+
"klay_newFilter",
|
166
|
+
"klay_newPendingTransactionFilter",
|
167
|
+
"klay_pendingTransactions",
|
168
|
+
"klay_protocolVersion",
|
169
|
+
"klay_resend",
|
170
|
+
"klay_sendIBANTransaction",
|
171
|
+
"klay_sendRawTransaction",
|
172
|
+
"klay_sendTransaction",
|
173
|
+
"klay_sign",
|
174
|
+
"klay_signTransaction",
|
175
|
+
"klay_submitHashrate",
|
176
|
+
"klay_submitTransaction",
|
177
|
+
"klay_submitWork",
|
178
|
+
"klay_subscribe",
|
179
|
+
"klay_syncing",
|
180
|
+
"klay_uninstallFilter",
|
181
|
+
"klay_unsubscribe",
|
182
182
|
"les_addBalance",
|
183
183
|
"les_clientInfo",
|
184
184
|
"les_getCheckpoint",
|
@@ -189,7 +189,7 @@ module Klay
|
|
189
189
|
"les_setClientParams",
|
190
190
|
"les_setDefaultParams",
|
191
191
|
"miner_getHashrate",
|
192
|
-
"
|
192
|
+
"miner_setKlayerbase",
|
193
193
|
"miner_setExtra",
|
194
194
|
"miner_setGasLimit",
|
195
195
|
"miner_setGasPrice",
|
data/lib/klay/chain.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Provides the {
|
15
|
+
# Provides the {Klay} module.
|
16
16
|
module Klay
|
17
17
|
|
18
18
|
# Encapsulates {Eth::Chain} IDs and utilities for EIP-155 compatibility.
|
@@ -108,7 +108,7 @@ module Klay
|
|
108
108
|
# @param chain_id [Integer] the chain id the signature was generated on.
|
109
109
|
# @return [Integer] the recovery id corresponding to `v`.
|
110
110
|
# @raise [ReplayProtectionError] if the given `v` is invalid.
|
111
|
-
def to_recovery_id(v, chain_id =
|
111
|
+
def to_recovery_id(v, chain_id = CYPRESS)
|
112
112
|
e = 0 + 2 * chain_id + 35
|
113
113
|
i = 1 + 2 * chain_id + 35
|
114
114
|
if [0, 1].include? v
|
data/lib/klay/client/http.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-2022 The Ruby-
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Klay Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
require "net/http"
|
16
16
|
|
17
|
-
# Provides the {
|
17
|
+
# Provides the {Klay} module.
|
18
18
|
module Klay
|
19
19
|
|
20
20
|
# Provides an HTTP/S-RPC client.
|