klay 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,27 +12,27 @@
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::Key::Decrypter} class to handle PBKDF2-SHA-256 decryption.
18
+ # The {Klay::Key::Decrypter} class to handle PBKDF2-SHA-256 decryption.
19
19
  class Key::Decrypter
20
20
 
21
21
  # Provides a specific decrypter error if decryption fails.
22
22
  class DecrypterError < StandardError; end
23
23
 
24
- # Class method {Eth::Key::Decrypter.perform} to perform an keystore
24
+ # Class method {Klay::Key::Decrypter.perform} to perform an keystore
25
25
  # decryption.
26
26
  #
27
27
  # @param data [JSON] encryption data including cypherkey.
28
28
  # @param password [String] password to decrypt the key.
29
- # @return [Eth::Key] decrypted key-pair.
29
+ # @return [Klay::Key] decrypted key-pair.
30
30
  def self.perform(data, password)
31
31
  new(data, password).perform
32
32
  end
33
33
 
34
- # Constructor of the {Eth::Key::Decrypter} class for secret key
35
- # decryption. Should not be used; use {Eth::Key::Decrypter.perform}
34
+ # Constructor of the {Klay::Key::Decrypter} class for secret key
35
+ # decryption. Should not be used; use {Klay::Key::Decrypter.perform}
36
36
  # instead.
37
37
  #
38
38
  # @param data [JSON] encryption data including cypherkey.
@@ -45,12 +45,12 @@ module Klay
45
45
 
46
46
  # Method to decrypt key using password.
47
47
  #
48
- # @return [Eth::Key] decrypted key.
48
+ # @return [Klay::Key] decrypted key.
49
49
  def perform
50
50
  derive_key password
51
51
  check_macs
52
52
  private_key = Util.bin_to_hex decrypted_data
53
- Eth::Key.new priv: private_key
53
+ Klay::Key.new priv: private_key
54
54
  end
55
55
 
56
56
  private
@@ -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::Key::Encrypter} class to handle PBKDF2-SHA-256 encryption.
18
+ # The {Klay::Key::Encrypter} class to handle PBKDF2-SHA-256 encryption.
19
19
  class Key::Encrypter
20
20
 
21
21
  # Provides a specific encrypter error if decryption fails.
22
22
  class EncrypterError < StandardError; end
23
23
 
24
- # Class method {Eth::Key::Encrypter.perform} to performa an key-store
24
+ # Class method {Klay::Key::Encrypter.perform} to performa an key-store
25
25
  # encryption.
26
26
  #
27
- # @param key [Eth::Key] representing a secret key-pair used for encryption.
27
+ # @param key [Klay::Key] representing a secret key-pair used for encryption.
28
28
  # @param options [Hash] the options to encrypt with.
29
29
  # @option options [String] :kdf key derivation function defaults to pbkdf2.
30
30
  # @option options [String] :id uuid given to the secret key.
@@ -38,11 +38,11 @@ module Klay
38
38
  new(key, options).perform(password)
39
39
  end
40
40
 
41
- # Constructor of the {Eth::Key::Encrypter} class for secret key
42
- # encryption. Should not be used; use {Eth::Key::Encrypter.perform}
41
+ # Constructor of the {Klay::Key::Encrypter} class for secret key
42
+ # encryption. Should not be used; use {Klay::Key::Encrypter.perform}
43
43
  # instead.
44
44
  #
45
- # @param key [Eth::Key] representing a secret key-pair used for encryption.
45
+ # @param key [Klay::Key] representing a secret key-pair used for encryption.
46
46
  # @param options [Hash] the options to encrypt with.
47
47
  # @option options [String] :kdf key derivation function defaults to pbkdf2.
48
48
  # @option options [String] :id uuid given to the secret key.
data/lib/klay/key.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,25 +18,25 @@ require "rbsecp256k1"
18
18
  require "scrypt"
19
19
  require "securerandom"
20
20
 
21
- # Provides the {Eth} module.
21
+ # Provides the {Klay} module.
22
22
  module Klay
23
23
 
24
- # The {Eth::Key} class to handle Secp256k1 private/public key-pairs.
24
+ # The {Klay::Key} class to handle Secp256k1 private/public key-pairs.
25
25
  class Key
26
26
 
27
- # The {Eth::Key::Decrypter} class to handle PBKDF2-SHA-256 decryption.
27
+ # The {Klay::Key::Decrypter} class to handle PBKDF2-SHA-256 decryption.
28
28
  autoload :Decrypter, "eth/key/decrypter"
29
29
 
30
- # The {Eth::Key::Encrypter} class to handle PBKDF2-SHA-256 encryption.
30
+ # The {Klay::Key::Encrypter} class to handle PBKDF2-SHA-256 encryption.
31
31
  autoload :Encrypter, "eth/key/encrypter"
32
32
 
33
- # The `Secp256k1::PrivateKey` of the {Eth::Key} pair.
33
+ # The `Secp256k1::PrivateKey` of the {Klay::Key} pair.
34
34
  attr_reader :private_key
35
35
 
36
- # The `Secp256k1::PublicKey` of the {Eth::Key} pair.
36
+ # The `Secp256k1::PublicKey` of the {Klay::Key} pair.
37
37
  attr_reader :public_key
38
38
 
39
- # Constructor of the {Eth::Key} class. Creates a new random key-pair
39
+ # Constructor of the {Klay::Key} class. Creates a new random key-pair
40
40
  # if no `priv` key is provided.
41
41
  #
42
42
  # @param priv [String] binary string of private key data.
@@ -82,7 +82,7 @@ module Klay
82
82
  Util.bin_to_hex signature.pack "c*"
83
83
  end
84
84
 
85
- # Prefixes a message with `\x19Ethereum Signed Message:` and signs
85
+ # Prefixes a message with `\u0019Klaytn Signed Message:` and signs
86
86
  # it in the common way used by many web3 wallets. Complies with
87
87
  # EIP-191 prefix `0x19` and version byte `0x45` (`E`). See also
88
88
  # {Signature.personal_recover}.
@@ -119,7 +119,7 @@ module Klay
119
119
  end
120
120
 
121
121
  # Exports the private key bytes in a wrapper function to maintain
122
- # backward-compatibility with older versions of {Eth::Key}.
122
+ # backward-compatibility with older versions of {Klay::Key}.
123
123
  #
124
124
  # @return [String] private key as packed byte-string.
125
125
  def private_bytes
@@ -143,7 +143,7 @@ module Klay
143
143
  end
144
144
 
145
145
  # Exports the uncompressed public key bytes in a wrapper function to
146
- # maintain backward-compatibility with older versions of {Eth::Key}.
146
+ # maintain backward-compatibility with older versions of {Klay::Key}.
147
147
  #
148
148
  # @return [String] uncompressed public key as packed byte-string.
149
149
  def public_bytes
@@ -159,7 +159,7 @@ module Klay
159
159
 
160
160
  # Exports the checksummed public address.
161
161
  #
162
- # @return [Eth::Address] compressed address as packed hex prefixed string.
162
+ # @return [Klay::Address] compressed address as packed hex prefixed string.
163
163
  def address
164
164
  Util.public_key_to_address public_bytes
165
165
  end
@@ -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 an recursive-length prefix (RLP) encoder and decoder.
@@ -28,7 +28,7 @@ module Klay
28
28
  #
29
29
  # @param rlp [String] an RLP-encoded object.
30
30
  # @return [Object] the decoded and maybe deserialized object.
31
- # @raise [Eth::Rlp::DecodingError] if the input string does not end after
31
+ # @raise [Klay::Rlp::DecodingError] if the input string does not end after
32
32
  # the root item.
33
33
  def perform(rlp)
34
34
  rlp = Util.hex_to_bin rlp if Util.is_hex? rlp
@@ -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 an recursive-length prefix (RLP) encoder and decoder.
@@ -28,9 +28,9 @@ module Klay
28
28
  #
29
29
  # @param obj [Object] a Ruby object.
30
30
  # @return [String] the RLP encoded item.
31
- # @raise [Eth::Rlp::EncodingError] in the rather unlikely case that the item
31
+ # @raise [Klay::Rlp::EncodingError] in the rather unlikely case that the item
32
32
  # is too big to encode (will not happen).
33
- # @raise [Eth::Rlp::SerializationError] if the serialization fails.
33
+ # @raise [Klay::Rlp::SerializationError] if the serialization fails.
34
34
  def perform(obj)
35
35
  item = Sedes.infer(obj).serialize(obj)
36
36
  result = encode_raw item
@@ -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 an recursive-length prefix (RLP) encoder and decoder.
@@ -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 an recursive-length prefix (RLP) encoder and decoder.
@@ -33,7 +33,7 @@ module Klay
33
33
  #
34
34
  # @param l [Integer] the fixed size of the binary.
35
35
  # @param allow_empty [Boolean] indicator wether empty binaries should be allowed.
36
- # @return [Eth::Rlp::Sedes::Binary] a serializable binary of fixed size.
36
+ # @return [Klay::Rlp::Sedes::Binary] a serializable binary of fixed size.
37
37
  def fixed_length(l, allow_empty: false)
38
38
  new(min_length: l, max_length: l, allow_empty: allow_empty)
39
39
  end
@@ -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 an recursive-length prefix (RLP) encoder and decoder.
@@ -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,7 +18,7 @@ require "klay/rlp/sedes/big_endian_int"
18
18
  require "klay/rlp/sedes/binary"
19
19
  require "klay/rlp/sedes/list"
20
20
 
21
- # Provides the {Eth} module.
21
+ # Provides the {Klay} module.
22
22
  module Klay
23
23
 
24
24
  # Provides an recursive-length prefix (RLP) encoder and decoder.
@@ -27,13 +27,13 @@ module Klay
27
27
  # Provides serializable and deserializable types (SeDes).
28
28
  module Sedes
29
29
 
30
- # Provides a singleton {Eth::Rlp::Sedes} class to infer objects and types.
30
+ # Provides a singleton {Klay::Rlp::Sedes} class to infer objects and types.
31
31
  class << self
32
32
 
33
33
  # Tries to find a sedes objects suitable for a given Ruby object.
34
34
  #
35
35
  # The sedes objects considered are `obj`'s class, {big_endian_int} and
36
- # {binary}. If `obj` is a list, an {Eth::Rlp::Sedes::List} will be
36
+ # {binary}. If `obj` is a list, an {Klay::Rlp::Sedes::List} will be
37
37
  # constructed recursively.
38
38
  #
39
39
  # @param obj [Object] the Ruby object for which to find a sedes object.
@@ -57,14 +57,14 @@ module Klay
57
57
  # A utility to use a big-endian, unsigned integer sedes type with
58
58
  # unspecified length.
59
59
  #
60
- # @return [Eth::Rlp::Sedes::BigEndianInt] a big-endian, unsigned integer sedes.
60
+ # @return [Klay::Rlp::Sedes::BigEndianInt] a big-endian, unsigned integer sedes.
61
61
  def big_endian_int
62
62
  @big_endian_int ||= BigEndianInt.new
63
63
  end
64
64
 
65
65
  # A utility to use a binary sedes type.
66
66
  #
67
- # @return [Eth::Rlp::Sedes::Binary] a binary sedes.
67
+ # @return [Klay::Rlp::Sedes::Binary] a binary sedes.
68
68
  def binary
69
69
  @binary ||= Binary.new
70
70
  end
data/lib/klay/rlp.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.
@@ -19,7 +19,7 @@ require "klay/rlp/encoder"
19
19
  require "klay/rlp/sedes"
20
20
  require "klay/util"
21
21
 
22
- # Provides the {Eth} module.
22
+ # Provides the {Klay} module.
23
23
  module Klay
24
24
 
25
25
  # Provides an recursive-length prefix (RLP) encoder and decoder.
@@ -44,7 +44,7 @@ module Klay
44
44
  # A wrapper to represent already RLP-encoded data.
45
45
  class Data < String; end
46
46
 
47
- # Performes an {Eth::Rlp::Encoder} on any ruby object.
47
+ # Performes an {Klay::Rlp::Encoder} on any ruby object.
48
48
  #
49
49
  # @param obj [Object] any ruby object.
50
50
  # @return [String] a packed, RLP-encoded item.
@@ -52,7 +52,7 @@ module Klay
52
52
  Rlp::Encoder.perform obj
53
53
  end
54
54
 
55
- # Performes an {Eth::Rlp::Decoder} on any RLP-encoded item.
55
+ # Performes an {Klay::Rlp::Decoder} on any RLP-encoded item.
56
56
  #
57
57
  # @param rlp [String] a packed, RLP-encoded item.
58
58
  # @return [Object] a decoded ruby object.
@@ -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 "rbsecp256k1"
16
16
 
17
- # Provides the {Eth} module.
17
+ # Provides the {Klay} module.
18
18
  module Klay
19
19
 
20
20
  # Defines handy tools for verifying and recovering signatures.
@@ -79,20 +79,6 @@ module Klay
79
79
  Util.bin_to_hex public_key.uncompressed
80
80
  end
81
81
 
82
- # def to_recovery_id(v)
83
- # if (v == 0 || v == 1) {
84
- # return v;
85
- # }
86
- # if (v < 27) {
87
- # raise new SignatureError("v byte out of range: " + v);
88
- # }
89
- # if(v < 35) {
90
- # // v = parity value {0,1} + 27
91
- # return v - 27;
92
- # }
93
- # return ((v - 35) % 2) == 0 ? 0 : 1;
94
- # end
95
-
96
82
  # Recovers a public key from a prefixed, personal message and
97
83
  # a signature on a given chain. (EIP-191)
98
84
  # Ref: https://eips.ethereum.org/EIPS/eip-191
@@ -124,7 +110,7 @@ module Klay
124
110
  #
125
111
  # @param blob [String] that arbitrary data to be verified.
126
112
  # @param signature [String] the hex string containing the signature.
127
- # @param public_key [String] either a public key or an Ethereum address.
113
+ # @param public_key [String] either a public key or an Klaytn address.
128
114
  # @param chain_id [Integer] the chain ID used to sign.
129
115
  # @return [Boolean] true if signature matches provided public key.
130
116
  # @raise [SignatureError] if it cannot determine the type of data or public key.
@@ -149,7 +135,7 @@ module Klay
149
135
 
150
136
  if public_key.instance_of? Address
151
137
 
152
- # recovering using an Eth::Address
138
+ # recovering using an Klay::Address
153
139
  address = public_key.to_s
154
140
  recovered_address = Util.public_key_to_address(recovered_key).to_s
155
141
  return address == recovered_address
@@ -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.
@@ -77,8 +77,8 @@ module Klay
77
77
  # @option params [Integer] :priority_fee the max priority fee per gas.
78
78
  # @option params [Integer] :max_gas_fee the max transaction fee per gas.
79
79
  # @option params [Integer] :gas_limit the gas limit.
80
- # @option params [Eth::Address] :from the sender address.
81
- # @option params [Eth::Address] :to the reciever address.
80
+ # @option params [Klay::Address] :from the sender address.
81
+ # @option params [Klay::Address] :to the reciever address.
82
82
  # @option params [Integer] :value the transaction value.
83
83
  # @option params [String] :data the transaction data payload.
84
84
  # @option params [Array] :access_list an optional access list.
@@ -127,11 +127,11 @@ module Klay
127
127
  # Overloads the constructor for decoding raw transactions and creating unsigned copies.
128
128
  konstructor :decode, :unsigned_copy
129
129
 
130
- # Decodes a raw transaction hex into an {Eth::Tx::Eip1559}
130
+ # Decodes a raw transaction hex into an {Klay::Tx::Eip1559}
131
131
  # transaction object.
132
132
  #
133
133
  # @param hex [String] the raw transaction hex-string.
134
- # @return [Eth::Tx::Eip1559] transaction payload.
134
+ # @return [Klay::Tx::Eip1559] transaction payload.
135
135
  # @raise [TransactionTypeError] if transaction type is invalid.
136
136
  # @raise [ParameterError] if transaction is missing fields.
137
137
  # @raise [DecoderError] if transaction decoding fails.
@@ -194,8 +194,8 @@ module Klay
194
194
 
195
195
  # Creates an unsigned copy of a transaction payload.
196
196
  #
197
- # @param tx [Eth::Tx::Eip1559] an EIP-1559 transaction payload.
198
- # @return [Eth::Tx::Eip1559] an unsigned EIP-1559 transaction payload.
197
+ # @param tx [Klay::Tx::Eip1559] an EIP-1559 transaction payload.
198
+ # @return [Klay::Tx::Eip1559] an unsigned EIP-1559 transaction payload.
199
199
  # @raise [TransactionTypeError] if transaction type does not match.
200
200
  def unsigned_copy(tx)
201
201
 
@@ -225,7 +225,7 @@ module Klay
225
225
 
226
226
  # Sign the transaction with a given key.
227
227
  #
228
- # @param key [Eth::Key] the key-pair to use for signing.
228
+ # @param key [Klay::Key] the key-pair to use for signing.
229
229
  # @return [String] a transaction hash.
230
230
  # @raise [Signature::SignatureError] if transaction is already signed.
231
231
  # @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.
@@ -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