klay 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8986fd6d80e3681e563bd7e54150159d8f4d5f965c2c78f1a20cd3bf8d6ba57c
4
- data.tar.gz: aa908017c60bd2ca4655a08763aaec318de7aaabf5a064d9bab624ba3d0c9c56
3
+ metadata.gz: 3ea9c15c1513dcc85173e2d227930d6cc8359c65aa6679edab4778b9aa186696
4
+ data.tar.gz: 4f703b56159737e8fc9f59217a56ec8f61069756db6bf6e900749736b1b98d86
5
5
  SHA512:
6
- metadata.gz: 60d093d6d7c16a96cf453ce2303d1098bb00b8171f88b55d09aa4e2d0772c250fbb185da0946d6ff420a2c6c56d4eb5dd87931d8261a998c2e939c73b32765f8
7
- data.tar.gz: 57e532d640d093d7049c71b66b110567ada2626cb2f03b69ca731c209968eecd02e96f136053b342cc7755407b6c05ed4790a929239b100810946189b31bc3f0
6
+ metadata.gz: 0a9550b4ce05cb34cc05e115b4ce3571de89fdabe0974412a2eaf1bb50be66ae1942c5c14f0c2ca83693cd563929e747e21b118966af7be040bd9f1ecd73af1e
7
+ data.tar.gz: c516d72d741edcc3b051f0cc808b34f1777017f4fbab081664d144bf69a85fa0a4adef7d8225adb09d09170c5a40698aa52a06a791a296936b068de2f6e18565
data/AUTHORS.txt CHANGED
@@ -1,10 +1,6 @@
1
- The Ruby-Eth Contributors are:
1
+ Ruby Klay Contributors are:
2
2
  * Sehan Park @noMacGuffins
3
3
 
4
- The Ruby-Klay project is maintained by Sehan Park's (@noMacGuffins)
5
- repository licenced under MIT conditions:
6
- * https://github.com/noMacGuffins/ruby-klay
7
-
8
4
  The Ruby-Eth project was maintained 2016-2020 in Steve Ellis's (@se3000)
9
5
  repository licensed under MIT conditions:
10
6
  * https://github.com/se3000/ruby-eth
data/LICENSE.txt CHANGED
@@ -1,4 +1,3 @@
1
- A
2
1
  Apache License
3
2
  Version 2.0, January 2004
4
3
  http://www.apache.org/licenses/
data/README.md CHANGED
@@ -1,58 +1,38 @@
1
1
  # Klay for Ruby
2
2
 
3
- A simple library to build and sign Klayereum 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.
3
+ 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
4
 
5
5
  What you get:
6
- - [x] Secp256k1 Key-Pairs and Encrypted Klayereum Key-Stores (JSON)
7
- - [x] EIP-55 Checksummed Klayereum Addresses
6
+ - [x] Secp256k1 Key-Pairs and Encrypted Klaytn Key-Stores (JSON)
7
+ - [x] EIP-55 Checksummed Klaytn Addresses
8
8
  - [x] EIP-155 Replay protection with Chain IDs (with presets)
9
- - [x] EIP-191 Klayereum Signed Messages (with prefix and type)
10
- - [x] EIP-712 Klayereum Signed Type Data
11
- - [x] EIP-1559 Klayereum Type-2 Transactions (with priority fee and max gas fee)
9
+ - [x] EIP-191 Klaytn Signed Messages (with prefix and type)
10
+ - [x] EIP-712 Klaytn Signed Type Data
11
+ - [x] EIP-1559 Klaytn Type-2 Transactions (with priority fee and max gas fee)
12
12
  - [x] EIP-2028 Call-data intrinsic gas cost estimates (plus access lists)
13
- - [x] EIP-2718 Klayereum Transaction Envelopes (and types)
14
- - [x] EIP-2930 Klayereum Type-1 Transactions (with access lists)
13
+ - [x] EIP-2718 Klaytn Transaction Envelopes (and types)
14
+ - [x] EIP-2930 Klaytn Type-1 Transactions (with access lists)
15
15
  - [x] ABI-Encoder and Decoder (including type parser)
16
16
  - [x] RLP-Encoder and Decoder (including sedes)
17
17
  - [x] RPC-Client (IPC/HTTP) for Execution-Layer APIs
18
18
 
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
19
  ## 1. Installation
40
20
 
41
21
  Add this line to your application's Gemfile:
42
22
 
43
23
  ```ruby
44
- gem "eth"
24
+ gem "klay"
45
25
  ```
46
26
 
47
27
  Or install it yourself as:
48
28
 
49
29
  ```shell
50
- gem install eth
30
+ gem install klay
51
31
  ```
52
32
 
53
33
  ## 2. Usage
54
34
 
55
- ### 2.1. Klayereum Keys and Addresses (EIP-55)
35
+ ### 2.1. Klaytn Keys and Addresses (EIP-55)
56
36
 
57
37
  Generate a random Secp256k1 key-pair.
58
38
 
@@ -61,7 +41,7 @@ key = Klay::Key.new
61
41
  # => #<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
42
  ```
63
43
 
64
- Create an password-encrypted Klayereum key-store.
44
+ Create an password-encrypted Klaytn key-store.
65
45
 
66
46
  ```ruby
67
47
  my_key = Klay::Key.new priv: "30137644b564785d01420f8043f043d74dcca64008e57c59f8ce713a0005a54b"
@@ -71,7 +51,7 @@ restored_key = Klay::Key::Decrypter.perform key_store, "secret-password-1337"
71
51
  # => "30137644b564785d01420f8043f043d74dcca64008e57c59f8ce713a0005a54b"
72
52
  ```
73
53
 
74
- Manage Klayereum address objects adhering to EIP-55 checksum format.
54
+ Manage Klaytn address objects adhering to EIP-55 checksum format.
75
55
 
76
56
  ```ruby
77
57
  address = Klay::Address.new "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"
@@ -84,7 +64,7 @@ address.checksummed # EIP 55
84
64
 
85
65
  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
66
 
87
- ### 2.2. Klayereum Signatures (EIP-191, EIP-712)
67
+ ### 2.2. Klaytn Signatures (EIP-191, EIP-712)
88
68
 
89
69
  Manage keypairs to sign messages in EIP-191 (`personal_sign`) format or typed data in EIP-712 (`sign_typed_data`) format.
90
70
 
@@ -116,9 +96,9 @@ Klay::Signature.verify "Hello World!", signature, address, Klay::Chain::GOERLI
116
96
 
117
97
  See `/spec` or [Documentation](https://q9f.github.io/eth.rb/) for signing typed data as per EIP-712.
118
98
 
119
- ### 2.3. Klayereum Chains (EIP-155)
99
+ ### 2.3. Klaytn Chains (EIP-155)
120
100
 
121
- Manage Klayereum chain IDs for EIP-155 replay protection.
101
+ Manage Klaytn chain IDs for EIP-155 replay protection.
122
102
 
123
103
  ```ruby
124
104
  chain_id = Klay::Chain::OPTIMISM
@@ -131,7 +111,7 @@ chain_id = Klay::Chain.to_chain_id v
131
111
  # => 10
132
112
  ```
133
113
 
134
- ### 2.4. Klayereum Transactions (EIP-1559, EIP-2718, EIP-2930)
114
+ ### 2.4. Klaytn Transactions (EIP-1559, EIP-2718, EIP-2930)
135
115
 
136
116
  Create an EIP-1559-conform transaction:
137
117
 
@@ -139,11 +119,11 @@ Create an EIP-1559-conform transaction:
139
119
  payload = {
140
120
  chain_id: Klay::Chain::GOERLI,
141
121
  nonce: 5,
142
- priority_fee: 3 * Klay::Unit::GWEI,
143
- max_gas_fee: 69 * Klay::Unit::GWEI,
122
+ priority_fee: 3 * Klay::Unit::GPEB,
123
+ max_gas_fee: 69 * Klay::Unit::GPEB,
144
124
  gas_limit: 230_420,
145
125
  to: "0xCaA29806044A08E533963b2e573C1230A2cd9a2d",
146
- value: 0.069423 * Klay::Unit::ETHER,
126
+ value: 0.069423 * Klay::Unit::KLAY,
147
127
  }
148
128
  # => {:chain_id=>5, :nonce=>5, :priority_fee=>0.3e10, :max_gas_fee=>0.69e11, :gas_limit=>230420, :to=>"0xCaA29806044A08E533963b2e573C1230A2cd9a2d", :value=>0.69423e17}
149
129
  tx = Klay::Tx.new payload
@@ -158,9 +138,9 @@ tx.hex
158
138
 
159
139
  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
140
 
161
- ### 2.5. Klayereum ABI Encoder and Decoder
141
+ ### 2.5. Klaytn ABI Encoder and Decoder
162
142
 
163
- Encode and decode Klayereum application binary interface data (ABI).
143
+ Encode and decode Klaytn application binary interface data (ABI).
164
144
 
165
145
  ```ruby
166
146
  Klay::Util.bin_to_hex Klay::Abi.encode(["string", "address"], ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"])
@@ -169,9 +149,9 @@ Klay::Abi.decode(["string", "address"], "000000000000000000000000000000000000000
169
149
  # => ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"]
170
150
  ```
171
151
 
172
- ### 2.6. Klayereum RLP Encoder and Decoder
152
+ ### 2.6. Klaytn RLP Encoder and Decoder
173
153
 
174
- Serialize and deserialize Klayereum recursive-length prefix data (RLP).
154
+ Serialize and deserialize Klaytn recursive-length prefix data (RLP).
175
155
 
176
156
  ```ruby
177
157
  Klay::Util.bin_to_hex Klay::Rlp.encode ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"]
@@ -187,7 +167,7 @@ Klay::Rlp.decode "c7c0c1c0c3c0c1c0"
187
167
  # => [[], [[]], [[], [[]]]]
188
168
  ```
189
169
 
190
- ### 2.7. Klayereum RPC-Client
170
+ ### 2.7. Klaytn RPC-Client
191
171
 
192
172
  Create an IPC- or HTTP-RPC-API client to seamlessly query the chain state, e.g., Infura over HTTPS with access token:
193
173
 
@@ -207,7 +187,7 @@ cli = Klay::Client.create "/tmp/geth.ipc"
207
187
  # => #<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
188
  cli.eth_coinbase
209
189
  # => {"jsonrpc"=>"2.0", "id"=>1, "result"=>"0x6868074fb21c48dfad0c448fbabd99383a6598e4"}
210
- tx = cli.transfer_and_wait(Klay::Key.new.address, 1337 * Klay::Unit::ETHER)
190
+ tx = cli.transfer_and_wait(Klay::Key.new.address, 1337 * Klay::Unit::KLAY)
211
191
  # => "0x141c6dff40df34fe4fce5a65588d2161dab3e0e977fb8049ff7d79bc901034f7"
212
192
  cli.eth_get_transaction_by_hash tx
213
193
  # => {"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 +197,10 @@ cli.get_nonce cli.eth_coinbase["result"]
217
197
  # => 1
218
198
  ```
219
199
 
220
- ## 3. Documentation
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
200
+ ## 3. Contributing
245
201
 
246
202
  Pull requests are welcome! To contribute, please consider the following:
247
203
  * Code should be fully documented. Run `yard doc` and make sure it does not yield any warnings or undocumented sets.
248
204
  * 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
205
  * 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.rb
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)
206
+ * Submit pull requests, questions, or issues to Github: https://github.com/noMacGuffins/klay
data/bin/setup CHANGED
@@ -6,4 +6,4 @@ rufo .
6
6
  yard doc
7
7
  rspec
8
8
 
9
- echo "Tests fail? Run \`geth --dev --http --ipcpath /tmp/geth.ipc\` in background and try again."
9
+ # echo "Tests fail? Run \`geth --dev --http --ipcpath /tmp/geth.ipc\` in background and try again."
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 ethereum
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-Eth Contributors
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 {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
- # Provides a Ruby implementation of the Ethereum Applicatoin Binary Interface (ABI).
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 [Eth::Abi::Type] an ABI type object.
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 [Eth::Abi::Type] a parsed Type object.
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 [Eth::Abi::Type] a uint256 size type.
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 [Eth::Abi::Type] another type to be compared.
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 [Eth::Abi::Type] nested sub-type.
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-Eth Contributors
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 {Eth} module.
21
+ # Provides the {Klay} module.
22
22
  module Klay
23
23
 
24
- # Provides a Ruby implementation of the Ethereum Applicatoin Binary Interface (ABI).
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 [Eth::Abi::Type] type to be encoded.
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 [Eth::Abi::Type] type to be encoded.
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 [Eth::Abi::Type] type to be decoded.
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 [Eth::Abi::Type] type to be decoded.
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-Eth Contributors
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 {Eth} module.
15
+ # Provides the {Klay} module.
16
16
  module Klay
17
17
 
18
- # The {Eth::Address} class to handle checksummed Ethereum addresses.
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 Ethereum address.
24
+ # The prefixed and checksummed Klaytn address.
25
25
  attr_reader :address
26
26
 
27
- # Constructor of the {Eth::Address} class. Creates a new hex
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-Eth Contributors
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 {Eth} module.
15
+ # Provides the {Klay} module.
16
16
  module Klay
17
17
 
18
- # Provides the `Eth::Api` module grouping known RPC commands.
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.
@@ -189,7 +189,7 @@ module Klay
189
189
  "les_setClientParams",
190
190
  "les_setDefaultParams",
191
191
  "miner_getHashrate",
192
- "miner_setEtherbase",
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 {Eth} module.
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 = ETHEREUM)
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2016-2022 The Ruby-Eth Contributors
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 {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
20
  # Provides an HTTP/S-RPC client.
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2016-2022 The Ruby-Eth Contributors
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 "socket"
16
16
 
17
- # Provides the {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
20
  # Provides an IPC-RPC client.
data/lib/klay/client.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2016-2022 The Ruby-Eth Contributors
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 {Eth} module.
15
+ # Provides the {Klay} module.
16
16
  module Klay
17
17
 
18
- # Provides the {Eth::Client} super-class to connect to Ethereum
18
+ # Provides the {Klay::Client} super-class to connect to Klaytn
19
19
  # network's RPC-API endpoints (IPC or HTTP).
20
20
  class Client
21
21
 
@@ -41,8 +41,8 @@ module Klay
41
41
  # an IPC path.
42
42
  #
43
43
  # @param host [String] either an HTTP/S host or an IPC path.
44
- # @return [Eth::Client::Ipc] an IPC client.
45
- # @return [Eth::Client::Http] an HTTP client.
44
+ # @return [Klay::Client::Ipc] an IPC client.
45
+ # @return [Klay::Client::Http] an HTTP client.
46
46
  # @raise [ArgumentError] in case it cannot determine the client type.
47
47
  def self.create(host)
48
48
  return Client::Ipc.new host if host.end_with? ".ipc"
@@ -50,7 +50,7 @@ module Klay
50
50
  raise ArgumentError, "Unable to detect client type!"
51
51
  end
52
52
 
53
- # Constructor for the {Eth::Client} super-class. Should not be used;
53
+ # Constructor for the {Klay::Client} super-class. Should not be used;
54
54
  # use {Client.create} intead.
55
55
  def initialize(_)
56
56
  @id = 0
@@ -61,7 +61,7 @@ module Klay
61
61
 
62
62
  # Gets the default account (coinbase) of the connected client.
63
63
  #
64
- # @return [Eth::Address] the coinbase account address.
64
+ # @return [Klay::Address] the coinbase account address.
65
65
  def default_account
66
66
  @default_account ||= Address.new eth_coinbase["result"]
67
67
  end
@@ -75,7 +75,7 @@ module Klay
75
75
 
76
76
  # Gets the balance for an address.
77
77
  #
78
- # @param address [Eth::Address] the address to get the balance for.
78
+ # @param address [Klay::Address] the address to get the balance for.
79
79
  # @return [Integer] the balance in Wei.
80
80
  def get_balance(address)
81
81
  eth_get_balance(address)["result"].to_i 16
@@ -83,32 +83,32 @@ module Klay
83
83
 
84
84
  # Gets the next nonce for an address used to draft new transactions.
85
85
  #
86
- # @param address [Eth::Address] the address to get the nonce for.
86
+ # @param address [Klay::Address] the address to get the nonce for.
87
87
  # @return [Integer] the next nonce to be used.
88
88
  def get_nonce(address)
89
89
  eth_get_transaction_count(address, "pending")["result"].to_i 16
90
90
  end
91
91
 
92
- # Simply transfer Ether to an account and waits for it to be mined.
92
+ # Simply transfer Klay to an account and waits for it to be mined.
93
93
  # Uses `eth_coinbase` and external signer if no sender key is
94
94
  # provided.
95
95
  #
96
- # @param destination [Eth::Address] the destination address.
96
+ # @param destination [Klay::Address] the destination address.
97
97
  # @param amount [Integer] the transfer amount in Wei.
98
- # @param sender_key [Eth::Key] the sender private key.
98
+ # @param sender_key [Klay::Key] the sender private key.
99
99
  # @param legacy [Boolean] enables legacy transactions (pre-EIP-1559).
100
100
  # @return [String] the transaction hash.
101
101
  def transfer_and_wait(destination, amount, sender_key = nil, legacy = false)
102
102
  wait_for_tx(transfer(destination, amount, sender_key, legacy))
103
103
  end
104
104
 
105
- # Simply transfer Ether to an account without any call data or
105
+ # Simply transfer Klay to an account without any call data or
106
106
  # access lists attached. Uses `eth_coinbase` and external signer
107
107
  # if no sender key is provided.
108
108
  #
109
- # @param destination [Eth::Address] the destination address.
109
+ # @param destination [Klay::Address] the destination address.
110
110
  # @param amount [Integer] the transfer amount in Wei.
111
- # @param sender_key [Eth::Key] the sender private key.
111
+ # @param sender_key [Klay::Key] the sender private key.
112
112
  # @param legacy [Boolean] enables legacy transactions (pre-EIP-1559).
113
113
  # @return [String] the transaction hash.
114
114
  def transfer(destination, amount, sender_key = nil, legacy = false)
@@ -135,7 +135,7 @@ module Klay
135
135
  from: sender_key.address,
136
136
  nonce: get_nonce(sender_key.address),
137
137
  })
138
- tx = Eth::Tx.new(params)
138
+ tx = Klay::Tx.new(params)
139
139
  tx.sign sender_key
140
140
  return eth_send_raw_transaction(tx.hex)["result"]
141
141
  else
@@ -183,7 +183,7 @@ module Klay
183
183
  end
184
184
 
185
185
  # Metafunction to provide all known RPC commands defined in
186
- # Eth::Api as snake_case methods to the Eth::Client classes.
186
+ # Klay::Api as snake_case methods to the Klay::Client classes.
187
187
  Api::COMMANDS.each do |cmd|
188
188
  method_name = cmd.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
189
189
  define_method method_name do |*args|
data/lib/klay/constant.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2016-2022 The Ruby-Eth Contributors
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
  # -*- encoding : ascii-8bit -*-
16
16
 
17
- # Provides the {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
20
  # Provides commonly used constants, such as zero bytes or zero keys.
data/lib/klay/eip712.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2016-2022 The Ruby-Eth Contributors
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,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 {Eth} module.
15
+ # Provides the {Klay} module.
16
16
  module Klay
17
17
 
18
18
  # Defines handy tools for encoding typed structured data as per EIP-712.