erc20 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +4 -3
- data/README.md +13 -0
- data/lib/erc20/erc20.rb +1 -1
- data/lib/erc20/fake_wallet.rb +41 -26
- data/lib/erc20/wallet.rb +47 -54
- data/test/erc20/test_fake_wallet.rb +20 -13
- data/test/erc20/test_wallet.rb +9 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c6a14d29c4065075aa4c50b8101930a95b3ed09eff93ef8e37f145da576a27e
|
4
|
+
data.tar.gz: cd4ab161e890ba8cd4fdf4d60782c3d1550cadae6b6c74f4d2cec2967e3cda04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73ba1ba539a7d25fe7cf2ecb022ddf5d7fbdcd61cf1653d987b9cf29b5337229a2756853bc538f2ae7385bf141945cea50a5198214e8da8d29088a34dea63c9
|
7
|
+
data.tar.gz: 318f3270b986d11fb901af11181e457f89a53bc7ae89898a4c3231659edc1537933637285d51c9bac046f5be15b723d9709989def4532d0013ae872e50dadabd
|
data/.rubocop.yml
CHANGED
@@ -28,6 +28,7 @@ AllCops:
|
|
28
28
|
SuggestExtensions: false
|
29
29
|
NewCops: enable
|
30
30
|
plugins:
|
31
|
+
- rubocop-rspec
|
31
32
|
- rubocop-performance
|
32
33
|
- rubocop-rake
|
33
34
|
- rubocop-minitest
|
@@ -63,4 +64,3 @@ Security/MarshalLoad:
|
|
63
64
|
Enabled: false
|
64
65
|
Layout/MultilineAssignmentLayout:
|
65
66
|
Enabled: true
|
66
|
-
require: []
|
data/Gemfile.lock
CHANGED
@@ -223,11 +223,12 @@ GEM
|
|
223
223
|
lint_roller (~> 1.1)
|
224
224
|
rubocop (>= 1.72.1, < 2.0)
|
225
225
|
rubocop-ast (>= 1.38.0, < 2.0)
|
226
|
-
rubocop-rake (0.7.
|
226
|
+
rubocop-rake (0.7.1)
|
227
227
|
lint_roller (~> 1.1)
|
228
228
|
rubocop (>= 1.72.1)
|
229
|
-
rubocop-rspec (3.
|
230
|
-
|
229
|
+
rubocop-rspec (3.5.0)
|
230
|
+
lint_roller (~> 1.1)
|
231
|
+
rubocop (~> 1.72, >= 1.72.1)
|
231
232
|
ruby-progressbar (1.13.0)
|
232
233
|
rubyzip (2.4.1)
|
233
234
|
scrypt (3.0.8)
|
data/README.md
CHANGED
@@ -83,6 +83,19 @@ You can use [squid-proxy] [Docker] image to set up your own [HTTP proxy] server.
|
|
83
83
|
Of course, this library works with [Polygon], [Optimism],
|
84
84
|
and other forks of [Etherium].
|
85
85
|
|
86
|
+
## How to use in tests
|
87
|
+
|
88
|
+
You can use `ERC20::FakeWallet` class that behaves exactly like
|
89
|
+
`ERC20::Wallet`, but doesn't make any network connections to the provider.
|
90
|
+
Also, it remembers all requests that were sent to it:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
require 'erc20'
|
94
|
+
w = ERC20::FakeWallet.new
|
95
|
+
w.pay(priv, address, 42_000)
|
96
|
+
assert w.history.include?({ method: :pay, params: [priv, address, 42_000] })
|
97
|
+
```
|
98
|
+
|
86
99
|
## How to contribute
|
87
100
|
|
88
101
|
Read
|
data/lib/erc20/erc20.rb
CHANGED
data/lib/erc20/fake_wallet.rb
CHANGED
@@ -32,6 +32,9 @@ class ERC20::FakeWallet
|
|
32
32
|
# Fakes:
|
33
33
|
attr_reader :host, :port, :ssl, :chain, :contract, :ws_path, :http_path
|
34
34
|
|
35
|
+
# Full history of all method calls:
|
36
|
+
attr_reader :history
|
37
|
+
|
35
38
|
# Ctor.
|
36
39
|
def initialize
|
37
40
|
@host = 'example.com'
|
@@ -41,40 +44,47 @@ class ERC20::FakeWallet
|
|
41
44
|
@contract = ERC20::Wallet::USDT
|
42
45
|
@ws_path = '/'
|
43
46
|
@http_path = '/'
|
47
|
+
@history = []
|
44
48
|
end
|
45
49
|
|
46
50
|
# Get ERC20 balance of a public address.
|
47
51
|
#
|
48
|
-
# @param [String]
|
52
|
+
# @param [String] address Public key, in hex, starting from '0x'
|
49
53
|
# @return [Integer] Balance, in tokens
|
50
|
-
def balance(
|
51
|
-
42_000_000
|
54
|
+
def balance(address)
|
55
|
+
b = 42_000_000
|
56
|
+
@history << { method: :balance, address:, result: b }
|
57
|
+
b
|
52
58
|
end
|
53
59
|
|
54
60
|
# Get ETH balance of a public address.
|
55
61
|
#
|
56
|
-
# @param [String]
|
62
|
+
# @param [String] address Public key, in hex, starting from '0x'
|
57
63
|
# @return [Integer] Balance, in tokens
|
58
|
-
def eth_balance(
|
59
|
-
|
64
|
+
def eth_balance(address)
|
65
|
+
b = 77_000_000_000_000_000
|
66
|
+
@history << { method: :eth_balance, address:, result: b }
|
67
|
+
b
|
60
68
|
end
|
61
69
|
|
62
|
-
# How much
|
70
|
+
# How much gas units is required in order to send ERC20 transaction.
|
63
71
|
#
|
64
|
-
# @param [String]
|
65
|
-
# @param [String]
|
66
|
-
# @
|
67
|
-
|
68
|
-
|
72
|
+
# @param [String] from The departing address, in hex
|
73
|
+
# @param [String] to Arriving address, in hex
|
74
|
+
# @param [Integer] amount How many ERC20 tokens to send
|
75
|
+
# @return [Integer] How many gas units required
|
76
|
+
def gas_estimate(from, to, amount)
|
77
|
+
gas = 66_000
|
78
|
+
@history << { method: :gas_estimate, from:, to:, amount:, result: gas }
|
79
|
+
gas
|
69
80
|
end
|
70
81
|
|
71
|
-
#
|
72
|
-
#
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
66_000
|
82
|
+
# What is the price of gas unit in gwei?
|
83
|
+
# @return [Integer] Price of gas unit, in gwei (0.000000001 ETH)
|
84
|
+
def gas_price
|
85
|
+
gwei = 55_555
|
86
|
+
@history << { method: :gas_price, result: gwei }
|
87
|
+
gwei
|
78
88
|
end
|
79
89
|
|
80
90
|
# Send a single ERC20 payment from a private address to a public one.
|
@@ -83,18 +93,22 @@ class ERC20::FakeWallet
|
|
83
93
|
# @param [String] _address Public key, in hex
|
84
94
|
# @param [Integer] _amount The amount of ERC20 tokens to send
|
85
95
|
# @return [String] Transaction hash
|
86
|
-
def pay(
|
87
|
-
'0x172de9cda30537eae68ab4a96163ebbb8f8a85293b8737dd2e5deb4714b14623'
|
96
|
+
def pay(priv, address, amount, gas_limit: nil, gas_price: nil)
|
97
|
+
hex = '0x172de9cda30537eae68ab4a96163ebbb8f8a85293b8737dd2e5deb4714b14623'
|
98
|
+
@history << { method: :pay, priv:, address:, amount:, gas_limit:, gas_price:, result: hex }
|
99
|
+
hex
|
88
100
|
end
|
89
101
|
|
90
102
|
# Send a single ETH payment from a private address to a public one.
|
91
103
|
#
|
92
|
-
# @param [String]
|
93
|
-
# @param [String]
|
94
|
-
# @param [Integer]
|
104
|
+
# @param [String] priv Private key, in hex
|
105
|
+
# @param [String] address Public key, in hex
|
106
|
+
# @param [Integer] amount The amount of ETHs to send
|
95
107
|
# @return [String] Transaction hash
|
96
|
-
def eth_pay(
|
97
|
-
'0x172de9cda30537eae68ab4a96163ebbb8f8a85293b8737dd2e5deb4714b14623'
|
108
|
+
def eth_pay(priv, address, amount, gas_price: nil)
|
109
|
+
hex = '0x172de9cda30537eae68ab4a96163ebbb8f8a85293b8737dd2e5deb4714b14623'
|
110
|
+
@history << { method: :eth_pay, priv:, address:, amount:, gas_price:, result: hex }
|
111
|
+
hex
|
98
112
|
end
|
99
113
|
|
100
114
|
# Wait and accept.
|
@@ -104,6 +118,7 @@ class ERC20::FakeWallet
|
|
104
118
|
# @param [Boolean] raw TRUE if you need to get JSON events as they arrive from Websockets
|
105
119
|
# @param [Integer] delay How many seconds to wait between +eth_subscribe+ calls
|
106
120
|
def accept(addresses, active = [], raw: false, delay: 1)
|
121
|
+
@history << { method: :accept, addresses:, active:, raw:, delay: }
|
107
122
|
addresses.to_a.each { |a| active.append(a) }
|
108
123
|
loop do
|
109
124
|
sleep(delay)
|
data/lib/erc20/wallet.rb
CHANGED
@@ -159,22 +159,33 @@ class ERC20::Wallet
|
|
159
159
|
b
|
160
160
|
end
|
161
161
|
|
162
|
-
# How much
|
162
|
+
# How much gas units is required in order to send ERC20 transaction.
|
163
163
|
#
|
164
164
|
# @param [String] from The departing address, in hex
|
165
|
-
# @param [String] to Arriving address, in hex
|
166
|
-
# @
|
167
|
-
|
168
|
-
|
165
|
+
# @param [String] to Arriving address, in hex
|
166
|
+
# @param [Integer] amount How many ERC20 tokens to send
|
167
|
+
# @return [Integer] How many gas units required
|
168
|
+
def gas_estimate(from, to, amount)
|
169
|
+
raise 'Address can\'t be nil' unless from
|
170
|
+
raise 'Address must be a String' unless from.is_a?(String)
|
171
|
+
raise 'Invalid format of the address' unless /^0x[0-9a-fA-F]{40}$/.match?(from)
|
172
|
+
raise 'Address can\'t be nil' unless to
|
173
|
+
raise 'Address must be a String' unless to.is_a?(String)
|
174
|
+
raise 'Invalid format of the address' unless /^0x[0-9a-fA-F]{40}$/.match?(to)
|
175
|
+
raise 'Amount can\'t be nil' unless amount
|
176
|
+
raise "Amount (#{amount}) must be an Integer" unless amount.is_a?(Integer)
|
177
|
+
raise "Amount (#{amount}) must be a positive Integer" unless amount.positive?
|
178
|
+
gas = jsonrpc.eth_estimateGas({ from:, to: @contract, data: to_pay_data(to, amount) }, 'latest').to_i(16)
|
179
|
+
@log.debug("It would take #{gas} gas units to send #{amount} tokens from #{from} to #{to}")
|
180
|
+
gas
|
169
181
|
end
|
170
182
|
|
171
|
-
#
|
172
|
-
#
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
gas_estimate(from, to)
|
183
|
+
# What is the price of gas unit in gwei?
|
184
|
+
# @return [Integer] Price of gas unit, in gwei (0.000000001 ETH)
|
185
|
+
def gas_price
|
186
|
+
gwei = jsonrpc.eth_getBlockByNumber('latest', false)['baseFeePerGas'].to_i(16)
|
187
|
+
@log.debug("The cost of one gas unit is #{gwei} gwei")
|
188
|
+
gwei
|
178
189
|
end
|
179
190
|
|
180
191
|
# Send a single ERC20 payment from a private address to a public one.
|
@@ -182,10 +193,10 @@ class ERC20::Wallet
|
|
182
193
|
# @param [String] priv Private key, in hex
|
183
194
|
# @param [String] address Public key, in hex
|
184
195
|
# @param [Integer] amount The amount of ERC20 tokens to send
|
185
|
-
# @param [Integer]
|
186
|
-
# @param [Integer]
|
196
|
+
# @param [Integer] limit How much gas you're ready to spend
|
197
|
+
# @param [Integer] price How much gas you pay per computation unit
|
187
198
|
# @return [String] Transaction hash
|
188
|
-
def pay(priv, address, amount,
|
199
|
+
def pay(priv, address, amount, limit: nil, price: gas_price)
|
189
200
|
raise 'Private key can\'t be nil' unless priv
|
190
201
|
raise 'Private key must be a String' unless priv.is_a?(String)
|
191
202
|
raise 'Invalid format of private key' unless /^[0-9a-fA-F]{64}$/.match?(priv)
|
@@ -193,30 +204,29 @@ class ERC20::Wallet
|
|
193
204
|
raise 'Address must be a String' unless address.is_a?(String)
|
194
205
|
raise 'Invalid format of the address' unless /^0x[0-9a-fA-F]{40}$/.match?(address)
|
195
206
|
raise 'Amount can\'t be nil' unless amount
|
196
|
-
raise
|
197
|
-
raise
|
198
|
-
if
|
199
|
-
raise 'Gas limit must be an Integer' unless
|
200
|
-
raise 'Gas limit must be a positive Integer' unless
|
207
|
+
raise "Amount (#{amount}) must be an Integer" unless amount.is_a?(Integer)
|
208
|
+
raise "Amount (#{amount}) must be a positive Integer" unless amount.positive?
|
209
|
+
if limit
|
210
|
+
raise 'Gas limit must be an Integer' unless limit.is_a?(Integer)
|
211
|
+
raise 'Gas limit must be a positive Integer' unless limit.positive?
|
201
212
|
end
|
202
|
-
if
|
203
|
-
raise 'Gas price must be an Integer' unless
|
204
|
-
raise 'Gas price must be a positive Integer' unless
|
213
|
+
if price
|
214
|
+
raise 'Gas price must be an Integer' unless price.is_a?(Integer)
|
215
|
+
raise 'Gas price must be a positive Integer' unless price.positive?
|
205
216
|
end
|
206
217
|
key = Eth::Key.new(priv: priv)
|
207
218
|
from = key.address.to_s
|
208
|
-
data = to_pay_data(address, amount)
|
209
219
|
tnx =
|
210
220
|
@mutex.synchronize do
|
211
221
|
nonce = jsonrpc.eth_getTransactionCount(from, 'pending').to_i(16)
|
212
222
|
tx = Eth::Tx.new(
|
213
223
|
{
|
214
224
|
nonce:,
|
215
|
-
gas_price:
|
216
|
-
gas_limit:
|
225
|
+
gas_price: price,
|
226
|
+
gas_limit: limit || gas_estimate(from, address, amount),
|
217
227
|
to: @contract,
|
218
228
|
value: 0,
|
219
|
-
data
|
229
|
+
data: to_pay_data(address, amount),
|
220
230
|
chain_id: @chain
|
221
231
|
}
|
222
232
|
)
|
@@ -233,10 +243,10 @@ class ERC20::Wallet
|
|
233
243
|
# @param [String] priv Private key, in hex
|
234
244
|
# @param [String] address Public key, in hex
|
235
245
|
# @param [Integer] amount The amount of ERC20 tokens to send
|
236
|
-
# @param [Integer]
|
237
|
-
# @param [Integer]
|
246
|
+
# @param [Integer] limit How much gas you're ready to spend
|
247
|
+
# @param [Integer] price How much gas you pay per computation unit
|
238
248
|
# @return [String] Transaction hash
|
239
|
-
def eth_pay(priv, address, amount,
|
249
|
+
def eth_pay(priv, address, amount, price: gas_price)
|
240
250
|
raise 'Private key can\'t be nil' unless priv
|
241
251
|
raise 'Private key must be a String' unless priv.is_a?(String)
|
242
252
|
raise 'Invalid format of private key' unless /^[0-9a-fA-F]{64}$/.match?(priv)
|
@@ -244,15 +254,11 @@ class ERC20::Wallet
|
|
244
254
|
raise 'Address must be a String' unless address.is_a?(String)
|
245
255
|
raise 'Invalid format of the address' unless /^0x[0-9a-fA-F]{40}$/.match?(address)
|
246
256
|
raise 'Amount can\'t be nil' unless amount
|
247
|
-
raise
|
248
|
-
raise
|
249
|
-
if
|
250
|
-
raise 'Gas
|
251
|
-
raise 'Gas
|
252
|
-
end
|
253
|
-
if gas_price
|
254
|
-
raise 'Gas price must be an Integer' unless gas_price.is_a?(Integer)
|
255
|
-
raise 'Gas price must be a positive Integer' unless gas_price.positive?
|
257
|
+
raise "Amount (#{amount}) must be an Integer" unless amount.is_a?(Integer)
|
258
|
+
raise "Amount (#{amount}) must be a positive Integer" unless amount.positive?
|
259
|
+
if price
|
260
|
+
raise 'Gas price must be an Integer' unless price.is_a?(Integer)
|
261
|
+
raise 'Gas price must be a positive Integer' unless price.positive?
|
256
262
|
end
|
257
263
|
key = Eth::Key.new(priv: priv)
|
258
264
|
from = key.address.to_s
|
@@ -263,8 +269,8 @@ class ERC20::Wallet
|
|
263
269
|
{
|
264
270
|
chain_id: @chain,
|
265
271
|
nonce:,
|
266
|
-
gas_price:
|
267
|
-
gas_limit:
|
272
|
+
gas_price: price,
|
273
|
+
gas_limit: 22_000,
|
268
274
|
to: address,
|
269
275
|
value: amount
|
270
276
|
}
|
@@ -426,15 +432,6 @@ class ERC20::Wallet
|
|
426
432
|
JSONRPC::Client.new(url, connection:)
|
427
433
|
end
|
428
434
|
|
429
|
-
# How much gas should be spent in order to send a transaction from one
|
430
|
-
# public address to another public address, possible carrying some data
|
431
|
-
# inside the transaction.
|
432
|
-
def gas_estimate(from, to, data = '')
|
433
|
-
gas = jsonrpc.eth_estimateGas({ from:, to:, data: }, 'latest').to_i(16)
|
434
|
-
@log.debug("Estimated gas is #{gas} ETH#{data.empty? ? '' : ', for ERC20 transfer'}")
|
435
|
-
gas
|
436
|
-
end
|
437
|
-
|
438
435
|
def to_pay_data(address, amount)
|
439
436
|
func = 'a9059cbb' # transfer(address,uint256)
|
440
437
|
to_clean = address.downcase.sub(/^0x/, '')
|
@@ -443,8 +440,4 @@ class ERC20::Wallet
|
|
443
440
|
amt_padded = ('0' * (64 - amt_hex.size)) + amt_hex
|
444
441
|
"0x#{func}#{to_padded}#{amt_padded}"
|
445
442
|
end
|
446
|
-
|
447
|
-
def gas_best_price
|
448
|
-
jsonrpc.eth_getBlockByNumber('latest', false)['baseFeePerGas'].to_i(16)
|
449
|
-
end
|
450
443
|
end
|
@@ -38,30 +38,34 @@ require_relative '../test__helper'
|
|
38
38
|
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
39
39
|
# License:: MIT
|
40
40
|
class TestFakeWallet < Minitest::Test
|
41
|
-
def
|
42
|
-
b = ERC20::FakeWallet.new.
|
41
|
+
def test_checks_gas_estimate
|
42
|
+
b = ERC20::FakeWallet.new.gas_estimate(
|
43
43
|
'0xEB2fE8872A6f1eDb70a2632Effffffffffffffff',
|
44
|
-
'
|
44
|
+
'0xfadef8ba4a5d709a2bf55b7a8798c9b438c640c1',
|
45
|
+
44_000
|
45
46
|
)
|
46
47
|
refute_nil(b)
|
47
48
|
end
|
48
49
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
'0xEB2fE8872A6f1eDb70a2632Effffffffffffffff'
|
53
|
-
)
|
54
|
-
refute_nil(b)
|
50
|
+
def test_checks_gas_price
|
51
|
+
gwei = ERC20::FakeWallet.new.gas_price
|
52
|
+
refute_nil(gwei)
|
55
53
|
end
|
56
54
|
|
57
55
|
def test_checks_fake_balance
|
58
|
-
|
56
|
+
w = ERC20::FakeWallet.new
|
57
|
+
a = '0xEB2fE8872A6f1eDb70a2632Effffffffffffffff'
|
58
|
+
b = w.balance(a)
|
59
59
|
refute_nil(b)
|
60
|
+
assert_includes(w.history, { method: :balance, result: b, address: a })
|
60
61
|
end
|
61
62
|
|
62
63
|
def test_checks_fake_eth_balance
|
63
|
-
|
64
|
+
a = '0xEB2fE8872A6f1eDb70a2632Effffffffffffffff'
|
65
|
+
w = ERC20::FakeWallet.new
|
66
|
+
b = w.eth_balance(a)
|
64
67
|
refute_nil(b)
|
68
|
+
assert_includes(w.history, { method: :eth_balance, result: b, address: a })
|
65
69
|
end
|
66
70
|
|
67
71
|
def test_returns_host
|
@@ -70,10 +74,13 @@ class TestFakeWallet < Minitest::Test
|
|
70
74
|
|
71
75
|
def test_pays_fake_money
|
72
76
|
priv = '81a9b2114d53731ecc84b261ef6c0387dde34d5907fe7b441240cc21d61bf80a'
|
73
|
-
|
74
|
-
|
77
|
+
address = '0xfadef8ba4a5d709a2bf55b7a8798c9b438c640c1'
|
78
|
+
w = ERC20::FakeWallet.new
|
79
|
+
amount = 555_000
|
80
|
+
txn = w.pay(priv, address, amount)
|
75
81
|
assert_equal(66, txn.length)
|
76
82
|
assert_match(/^0x[a-f0-9]{64}$/, txn)
|
83
|
+
assert_includes(w.history, { method: :pay, result: txn, priv:, address:, amount:, gas_limit: nil, gas_price: nil })
|
77
84
|
end
|
78
85
|
|
79
86
|
def test_pays_fake_eths
|
data/test/erc20/test_wallet.rb
CHANGED
@@ -67,16 +67,11 @@ class TestWallet < Minitest::Test
|
|
67
67
|
assert_equal(0, b)
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
b = mainnet.
|
72
|
-
refute_nil(b)
|
73
|
-
assert_predicate(b, :positive?)
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_checks_same_address_gas_required_on_mainnet
|
77
|
-
b = mainnet.gas_required(STABLE, STABLE)
|
70
|
+
def test_checks_gas_estimate_on_mainnet
|
71
|
+
b = mainnet.gas_estimate(STABLE, Eth::Key.new(priv: JEFF).address.to_s, 44_000)
|
78
72
|
refute_nil(b)
|
79
73
|
assert_predicate(b, :positive?)
|
74
|
+
assert_operator(b, :>, 1000)
|
80
75
|
end
|
81
76
|
|
82
77
|
def test_fails_with_invalid_infura_key
|
@@ -106,28 +101,15 @@ class TestWallet < Minitest::Test
|
|
106
101
|
assert_predicate(b, :zero?)
|
107
102
|
end
|
108
103
|
|
109
|
-
def
|
110
|
-
|
111
|
-
b1 = wallet.gas_required(
|
112
|
-
Eth::Key.new(priv: JEFF).address.to_s,
|
113
|
-
Eth::Key.new(priv: WALTER).address.to_s
|
114
|
-
)
|
115
|
-
assert_equal(21_597, b1)
|
116
|
-
b2 = wallet.gas_required(
|
117
|
-
Eth::Key.new(priv: JEFF).address.to_s,
|
118
|
-
Eth::Key.new(priv: JEFF).address.to_s
|
119
|
-
)
|
120
|
-
assert_equal(b1, b2)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_checks_eth_gas_required_on_hardhat
|
104
|
+
def test_checks_gas_estimate_on_hardhat
|
105
|
+
sum = 100_000
|
125
106
|
on_hardhat do |wallet|
|
126
|
-
|
107
|
+
b1 = wallet.gas_estimate(
|
127
108
|
Eth::Key.new(priv: JEFF).address.to_s,
|
128
|
-
Eth::Key.new(priv: WALTER).address.to_s
|
109
|
+
Eth::Key.new(priv: WALTER).address.to_s,
|
110
|
+
sum
|
129
111
|
)
|
130
|
-
|
112
|
+
assert_operator(b1, :>, 21_000)
|
131
113
|
end
|
132
114
|
end
|
133
115
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erc20
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eth
|