klay 0.0.2 → 0.0.5

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.
@@ -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
  # Provides the `Tx` module supporting various transaction types.
@@ -75,8 +75,8 @@ module Klay
75
75
  # @option params [Integer] :nonce the signer nonce.
76
76
  # @option params [Integer] :gas_price the gas price.
77
77
  # @option params [Integer] :gas_limit the gas limit.
78
- # @option params [Eth::Address] :from the sender address.
79
- # @option params [Eth::Address] :to the reciever address.
78
+ # @option params [Klay::Address] :from the sender address.
79
+ # @option params [Klay::Address] :to the reciever address.
80
80
  # @option params [Integer] :value the transaction value.
81
81
  # @option params [String] :data the transaction data payload.
82
82
  # @option params [Array] :access_list an optional access list.
@@ -124,11 +124,11 @@ module Klay
124
124
  # Overloads the constructor for decoding raw transactions and creating unsigned copies.
125
125
  konstructor :decode, :unsigned_copy
126
126
 
127
- # Decodes a raw transaction hex into an {Eth::Tx::Eip2930}
127
+ # Decodes a raw transaction hex into an {Klay::Tx::Eip2930}
128
128
  # transaction object.
129
129
  #
130
130
  # @param hex [String] the raw transaction hex-string.
131
- # @return [Eth::Tx::Eip2930] transaction payload.
131
+ # @return [Klay::Tx::Eip2930] transaction payload.
132
132
  # @raise [TransactionTypeError] if transaction type is invalid.
133
133
  # @raise [ParameterError] if transaction is missing fields.
134
134
  # @raise [DecoderError] if transaction decoding fails.
@@ -189,8 +189,8 @@ module Klay
189
189
 
190
190
  # Creates an unsigned copy of a transaction payload.
191
191
  #
192
- # @param tx [Eth::Tx::Eip2930] an EIP-2930 transaction payload.
193
- # @return [Eth::Tx::Eip2930] an unsigned EIP-2930 transaction payload.
192
+ # @param tx [Klay::Tx::Eip2930] an EIP-2930 transaction payload.
193
+ # @return [Klay::Tx::Eip2930] an unsigned EIP-2930 transaction payload.
194
194
  # @raise [TransactionTypeError] if transaction type does not match.
195
195
  def unsigned_copy(tx)
196
196
 
@@ -219,7 +219,7 @@ module Klay
219
219
 
220
220
  # Sign the transaction with a given key.
221
221
  #
222
- # @param key [Eth::Key] the key-pair to use for signing.
222
+ # @param key [Klay::Key] the key-pair to use for signing.
223
223
  # @return [String] a transaction hash.
224
224
  # @raise [Signature::SignatureError] if transaction is already signed.
225
225
  # @raise [Signature::SignatureError] if sender address does not match signing key.
@@ -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
  # Provides the `Tx` module supporting various transaction types.
@@ -67,8 +67,8 @@ module Klay
67
67
  # @option params [Integer] :nonce the signer nonce.
68
68
  # @option params [Integer] :gas_price the gas price.
69
69
  # @option params [Integer] :gas_limit the gas limit.
70
- # @option params [Eth::Address] :from the sender address.
71
- # @option params [Eth::Address] :to the reciever address.
70
+ # @option params [Klay::Address] :from the sender address.
71
+ # @option params [Klay::Address] :to the reciever address.
72
72
  # @option params [Integer] :value the transaction value.
73
73
  # @option params [String] :data the transaction data payload.
74
74
  # @param chain_id [Integer] the EIP-155 Chain ID.
@@ -113,11 +113,11 @@ module Klay
113
113
  # overloads the constructor for decoding raw transactions and creating unsigned copies
114
114
  konstructor :decode, :unsigned_copy
115
115
 
116
- # Decodes a raw transaction hex into an {Eth::Tx::Legacy}
116
+ # Decodes a raw transaction hex into an {Klay::Tx::Legacy}
117
117
  # transaction object.
118
118
  #
119
119
  # @param hex [String] the raw transaction hex-string.
120
- # @return [Eth::Tx::Legacy] transaction object.
120
+ # @return [Klay::Tx::Legacy] transaction object.
121
121
  # @raise [ParameterError] if transaction misses fields.
122
122
  def decode(hex)
123
123
  bin = Util.hex_to_bin hex
@@ -170,8 +170,8 @@ module Klay
170
170
 
171
171
  # Creates an unsigned copy of a transaction.
172
172
  #
173
- # @param tx [Eth::Tx::Legacy] an legacy transaction object.
174
- # @return [Eth::Tx::Legacy] an unsigned transaction object.
173
+ # @param tx [Klay::Tx::Legacy] an legacy transaction object.
174
+ # @return [Klay::Tx::Legacy] an unsigned transaction object.
175
175
  # @raise [TransactionTypeError] if transaction type does not match.
176
176
  def unsigned_copy(tx)
177
177
 
@@ -199,7 +199,7 @@ module Klay
199
199
 
200
200
  # Sign the transaction with a given key.
201
201
  #
202
- # @param key [Eth::Key] the key-pair to use for signing.
202
+ # @param key [Klay::Key] the key-pair to use for signing.
203
203
  # @return [String] a transaction hash.
204
204
  # @raise [Signature::SignatureError] if transaction is already signed.
205
205
  # @raise [Signature::SignatureError] if sender address does not match signing key.
data/lib/klay/tx.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.
@@ -20,7 +20,7 @@ require "klay/tx/eip2930"
20
20
  require "klay/tx/legacy"
21
21
  require "klay/unit"
22
22
 
23
- # Provides the {Eth} module.
23
+ # Provides the {Klay} module.
24
24
  module Klay
25
25
 
26
26
  # Provides the `Tx` module supporting various transaction types.
@@ -39,8 +39,8 @@ module Klay
39
39
  # The minimum transaction gas limit required for a value transfer.
40
40
  DEFAULT_GAS_LIMIT = 21_000.freeze
41
41
 
42
- # The "default" transaction gas price of 20 GWei. Do not use.
43
- DEFAULT_GAS_PRICE = (20 * Unit::GWEI).freeze
42
+ # The "default" transaction gas price of 25 GPeb.
43
+ DEFAULT_GAS_PRICE = (25 * Unit::GPEB).freeze
44
44
 
45
45
  # The calldata gas cost of a non-zero byte as per EIP-2028.
46
46
  COST_NON_ZERO_BYTE = 16.freeze
@@ -101,7 +101,7 @@ module Klay
101
101
  # Decodes a transaction hex of any known type (2, 1, or legacy).
102
102
  #
103
103
  # @param hex [String] the raw transaction hex-string.
104
- # @return [Eth::Tx] transaction payload.
104
+ # @return [Klay::Tx] transaction payload.
105
105
  # @raise [TransactionTypeError] if the transaction type is unknown.
106
106
  def decode(hex)
107
107
  hex = Util.remove_hex_prefix hex
@@ -128,8 +128,8 @@ module Klay
128
128
 
129
129
  # Creates an unsigned copy of any transaction object.
130
130
  #
131
- # @param tx [Eth::Tx] any transaction payload.
132
- # @return [Eth::Tx] an unsigned transaction payload of the same type.
131
+ # @param tx [Klay::Tx] any transaction payload.
132
+ # @return [Klay::Tx] an unsigned transaction payload of the same type.
133
133
  # @raise [TransactionTypeError] if the transaction type is unknown.
134
134
  def unsigned_copy(tx)
135
135
  case tx.type
data/lib/klay/unit.rb CHANGED
@@ -14,36 +14,24 @@
14
14
 
15
15
  require "bigdecimal"
16
16
 
17
- # Provides the {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
20
  # Provides constants for common Ethereum units.
21
21
  module Unit
22
22
  extend self
23
23
 
24
- # Ethereum unit 1 wei := 0.000000000000000001 Ether.
25
- WEI = BigDecimal("1e0").freeze
24
+ # Ethereum unit 1 peb := 0.000000000000000001 Klay.
25
+ PEB = BigDecimal("1e0").freeze
26
26
 
27
- # Ethereum unit 1 babbage := 0.000000000000001 Ether or 1_000 wei.
28
- BABBAGE = BigDecimal("1e3").freeze
27
+ # Ethereum unit 1 ston := 0.000000001 Klay or 1_000_000_000 peb.
28
+ STON = BigDecimal("1e9").freeze
29
29
 
30
- # Ethereum unit 1 lovelace := 0.000000000001 Ether or 1_000_000 wei.
31
- LOVELACE = BigDecimal("1e6").freeze
32
-
33
- # Ethereum unit 1 shannon := 0.000000001 Ether or 1_000_000_000 wei.
34
- SHANNON = BigDecimal("1e9").freeze
35
-
36
- # Ethereum unit 1 szabo := 0.000_001 Ether or 1_000_000_000_000 wei.
37
- SZABO = BigDecimal("1e12").freeze
38
-
39
- # Ethereum unit 1 finney := 0.001 Ether or 1_000_000_000_000_000 wei.
40
- FINNEY = BigDecimal("1e15").freeze
41
-
42
- # Ethereum unit 1 Ether := 1_000_000_000_000_000_000 wei.
30
+ # Ethereum unit 1 Klay := 1_000_000_000_000_000_000 peb.
43
31
  ETHER = BigDecimal("1e18").freeze
44
32
 
45
- # Ethereum unit 1 Gwei := 0.000000001 Ether or 1_000_000_000 wei.
46
- # Same as shannon, but more commonly used (billion wei).
47
- GWEI = SHANNON.freeze
33
+ # Ethereum unit 1 Gpeb := 0.000000001 Ether or 1_000_000_000 peb.
34
+ # Same as shannon, but more commonly used (billion peb).
35
+ GPEB = STON.freeze
48
36
  end
49
37
  end
data/lib/klay/util.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,18 +14,18 @@
14
14
 
15
15
  require "digest/keccak"
16
16
 
17
- # Provides the {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
- # Defines handy tools for the {Eth} gem for convenience.
20
+ # Defines handy tools for the {Klay} gem for convenience.
21
21
  module Util
22
22
  extend self
23
23
 
24
- # Generates an Ethereum address from a given compressed or
24
+ # Generates an Klaytn address from a given compressed or
25
25
  # uncompressed binary or hexadecimal public key string.
26
26
  #
27
27
  # @param str [String] the public key to be converted.
28
- # @return [Eth::Address] an Ethereum address.
28
+ # @return [Klay::Address] an Klaytn address.
29
29
  def public_key_to_address(str)
30
30
  str = hex_to_bin str if is_hex? str
31
31
  bytes = keccak256(str[1..-1])[-20..-1]
data/lib/klay/version.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,9 +12,9 @@
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
- # Defines the version of the {Eth} module.
19
- VERSION = "0.0.2".freeze
18
+ # Defines the version of the {Klay} module.
19
+ VERSION = "0.0.5".freeze
20
20
  end
data/lib/klay.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,11 +12,11 @@
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
  end
18
18
 
19
- # Loads the {Eth} module classes.
19
+ # Loads the {Klay} module classes.
20
20
  require "klay/abi"
21
21
  require "klay/api"
22
22
  require "klay/address"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sehan Park
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: keccak
@@ -87,8 +87,6 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".github/workflows/codeql.yml"
91
- - ".github/workflows/docs.yml"
92
90
  - ".github/workflows/spec.yml"
93
91
  - ".gitignore"
94
92
  - ".gitmodules"
@@ -1,48 +0,0 @@
1
- ---
2
- name: CodeQL
3
-
4
- on:
5
- pull_request:
6
- branches:
7
- - main
8
- push:
9
- branches:
10
- - main
11
-
12
- jobs:
13
- analyze:
14
- name: Analyze
15
- runs-on: ubuntu-latest
16
- permissions:
17
- actions: read
18
- contents: read
19
- security-events: write
20
- strategy:
21
- fail-fast: false
22
- matrix:
23
- language:
24
- - ruby
25
- steps:
26
- - name: "Checkout repository"
27
- uses: actions/checkout@v2
28
- - name: "Initialize CodeQL"
29
- uses: github/codeql-action/init@v1
30
- with:
31
- languages: "${{ matrix.language }}"
32
- - name: Autobuild
33
- uses: github/codeql-action/autobuild@v1
34
- - name: "Perform CodeQL Analysis"
35
- uses: github/codeql-action/analyze@v1
36
- - uses: ruby/setup-ruby@v1
37
- with:
38
- ruby-version: '2.7'
39
- bundler-cache: true
40
- - name: "Run rufo code formatting checks"
41
- run: |
42
- gem install rufo
43
- rufo --check ./lib
44
- rufo --check ./spec
45
- - name: "Run yard documentation checks"
46
- run: |
47
- gem install yard
48
- yard doc --fail-on-warning
@@ -1,26 +0,0 @@
1
- ---
2
- name: Docs
3
-
4
- on:
5
- push:
6
- branches:
7
- - main
8
-
9
- jobs:
10
- docs:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v2
14
- - uses: ruby/setup-ruby@v1
15
- with:
16
- ruby-version: '2.7'
17
- bundler-cache: true
18
- - name: Run Yard Doc
19
- run: |
20
- gem install yard
21
- yard doc
22
- - name: Deploy GH Pages
23
- uses: JamesIves/github-pages-deploy-action@4.1.7
24
- with:
25
- branch: gh-pages
26
- folder: doc/