erc20 0.0.6 → 0.0.7
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/README.md +2 -1
- data/lib/erc20/wallet.rb +2 -1
- data/lib/erc20.rb +1 -1
- data/test/erc20/test_wallet.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47883e48393686ed5d357fb9f5f762e0744a30a8f0999724dd2ddba369ac75ae
|
4
|
+
data.tar.gz: bad63b9aa6269a79cc2276c10c0f6aec02d8bf94bf18057b89fc0e9f896833be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf78c2548b09b33c9e67ba7476d9e14576f9be07ca1cbb1620067899451c96c587a87849d7c86c88ec449254362db9d921a4d0fde9534954b8ad9c48405f4b51
|
7
|
+
data.tar.gz: 224500ace20e3abaa25bbdc4a6be32fe7fca7b57b7d7b2bf4a4b01a8dac50a3fb45bf2a70c13f2f737b502a5ea80c4f452eeda5d0737ed6c5087d1458b590f20
|
data/README.md
CHANGED
@@ -37,7 +37,8 @@ hex = w.pay(private_key, to_address, amount)
|
|
37
37
|
# Stay waiting, and trigger the block when new ERC20 payments show up:
|
38
38
|
addresses = ['0x...', '0x...'] # only wait for payments to these addresses
|
39
39
|
w.accept(addresses) do |event|
|
40
|
-
puts event[:
|
40
|
+
puts event[:txt] # hash of transaction
|
41
|
+
puts event[:amount] # how much, in tokens (1000000 = $1 USDT)
|
41
42
|
puts event[:from] # who sent the payment
|
42
43
|
puts event[:to] # who was the receiver
|
43
44
|
end
|
data/lib/erc20/wallet.rb
CHANGED
@@ -178,7 +178,8 @@ class ERC20::Wallet
|
|
178
178
|
event = {
|
179
179
|
amount: event['data'].to_i(16),
|
180
180
|
from: "0x#{event['topics'][1][26..].downcase}",
|
181
|
-
to: "0x#{event['topics'][2][26..].downcase}"
|
181
|
+
to: "0x#{event['topics'][2][26..].downcase}",
|
182
|
+
txn: event['transactionHash']
|
182
183
|
}
|
183
184
|
log.debug("Payment of #{event[:amount]} tokens arrived from #{event[:from]} to #{event[:to]}")
|
184
185
|
end
|
data/lib/erc20.rb
CHANGED
data/test/erc20/test_wallet.rb
CHANGED
@@ -39,7 +39,7 @@ require_relative '../test__helper'
|
|
39
39
|
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
40
40
|
# License:: MIT
|
41
41
|
class TestWallet < Minitest::Test
|
42
|
-
# At this address, in Etherium mainnet, there are a
|
42
|
+
# At this address, in Etherium mainnet, there are a ~$27 USDT. I won't
|
43
43
|
# move them anyway, that's why tests can use this address forever.
|
44
44
|
STABLE = '0xEB2fE8872A6f1eDb70a2632EA1f869AB131532f6'
|
45
45
|
|
@@ -111,7 +111,8 @@ class TestWallet < Minitest::Test
|
|
111
111
|
sum = 42_000
|
112
112
|
from = Eth::Key.new(priv: JEFF).address.to_s
|
113
113
|
assert_operator(wallet.balance(from), :>, sum * 2)
|
114
|
-
wallet.pay(JEFF, to, sum)
|
114
|
+
txn = wallet.pay(JEFF, to, sum)
|
115
|
+
assert_equal(66, txn.length)
|
115
116
|
assert_equal(before + sum, wallet.balance(to))
|
116
117
|
end
|
117
118
|
end
|
@@ -152,6 +153,7 @@ class TestWallet < Minitest::Test
|
|
152
153
|
assert_equal(sum, event[:amount])
|
153
154
|
assert_equal(jeff, event[:from])
|
154
155
|
assert_equal(walter, event[:to])
|
156
|
+
assert_equal(66, event[:txn].length)
|
155
157
|
end
|
156
158
|
end
|
157
159
|
|