erc20 0.1.6 → 0.2.1
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/Gemfile +12 -12
- data/Gemfile.lock +86 -75
- data/REUSE.toml +11 -11
- data/Rakefile +1 -0
- data/bin/erc20 +6 -3
- data/erc20.gemspec +2 -2
- data/hardhat/Dockerfile +5 -7
- data/hardhat/package.json +1 -1
- data/lib/erc20/erc20.rb +1 -1
- data/lib/erc20/fake_wallet.rb +8 -0
- data/lib/erc20/wallet.rb +25 -3
- metadata +5 -28
- data/.0pdd.yml +0 -5
- data/.gitattributes +0 -7
- data/.github/workflows/actionlint.yml +0 -25
- data/.github/workflows/codecov.yml +0 -27
- data/.github/workflows/copyrights.yml +0 -19
- data/.github/workflows/markdown-lint.yml +0 -23
- data/.github/workflows/pdd.yml +0 -19
- data/.github/workflows/rake.yml +0 -38
- data/.github/workflows/reuse.yml +0 -19
- data/.github/workflows/shellcheck.yml +0 -19
- data/.github/workflows/xcop.yml +0 -19
- data/.github/workflows/yamllint.yml +0 -21
- data/.gitignore +0 -10
- data/.gitleaksignore +0 -2
- data/.pdd +0 -7
- data/.rubocop.yml +0 -49
- data/.rultor.yml +0 -26
- data/.yamllint.yml +0 -12
- data/renovate.json +0 -6
- data/test/erc20/test_fake_wallet.rb +0 -113
- data/test/erc20/test_wallet.rb +0 -334
- data/test/erc20/test_wallet_live.rb +0 -126
- data/test/test__helper.rb +0 -206
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43359f4b933cb54b433cc7479b5b3e1a3fc76f0ae927a89a8b4c3719579810fe
|
|
4
|
+
data.tar.gz: f93d84a17c65475e59704c984b0fb272b6f8e94f7c1c5f3012f53b8fbe250642
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '03119d9cb7d868e8df6efe5d55d0ce6421db6399776da6c0c0f03d22de41a1dca6e4f318c3db69b0fe9f01c7a886ea37a48d6c4f0da2a4d5ade8c7b23e16d5dc'
|
|
7
|
+
data.tar.gz: b87819d174d7e905d59482d6f8fe426b1cfa54cf8c10c887717c15b1dbd5ad15cff3d5805a45e53dc3fab3470ac379e85c4e9c192b998df74209668b47bf7220
|
data/Gemfile
CHANGED
|
@@ -6,26 +6,26 @@
|
|
|
6
6
|
source 'https://rubygems.org'
|
|
7
7
|
gemspec
|
|
8
8
|
|
|
9
|
-
gem 'backtrace', '
|
|
9
|
+
gem 'backtrace', '~>0.4', require: false
|
|
10
10
|
gem 'concurrent-ruby', '~>1.2', require: false
|
|
11
11
|
gem 'cucumber', '~>9.2', require: false
|
|
12
|
-
gem 'donce', '
|
|
13
|
-
gem 'faraday', '
|
|
14
|
-
gem 'loog', '
|
|
12
|
+
gem 'donce', '~>0.2', require: false
|
|
13
|
+
gem 'faraday', '~>2.14', require: false
|
|
14
|
+
gem 'loog', '~>0.6', require: false
|
|
15
15
|
gem 'minitest', '~>5.25', require: false
|
|
16
16
|
gem 'minitest-reporters', '~>1.7', require: false
|
|
17
17
|
gem 'minitest-retry', '~>0.2', require: false
|
|
18
|
-
gem 'qbash', '
|
|
18
|
+
gem 'qbash', '~>0.4', require: false
|
|
19
19
|
gem 'rake', '~>13.2', require: false
|
|
20
|
-
gem 'random-port', '
|
|
20
|
+
gem 'random-port', '~>0.7', require: false
|
|
21
|
+
gem 'rdoc', '~>6.17', require: false
|
|
21
22
|
gem 'rubocop', '~>1.75', require: false
|
|
22
|
-
gem 'rubocop-minitest', '
|
|
23
|
-
gem 'rubocop-performance', '
|
|
24
|
-
gem 'rubocop-rake', '
|
|
25
|
-
gem 'rubocop-rspec', '>0', require: false
|
|
23
|
+
gem 'rubocop-minitest', '~>0.38', require: false
|
|
24
|
+
gem 'rubocop-performance', '~>1.25', require: false
|
|
25
|
+
gem 'rubocop-rake', '~>0.7', require: false
|
|
26
26
|
gem 'simplecov', '~>0.22', require: false
|
|
27
|
-
gem 'simplecov-cobertura', '~>
|
|
27
|
+
gem 'simplecov-cobertura', '~>3.1', require: false
|
|
28
28
|
gem 'threads', '~>0.4', require: false
|
|
29
|
-
gem 'typhoeus', '
|
|
29
|
+
gem 'typhoeus', '~>1.4', require: false
|
|
30
30
|
gem 'webmock', '~>3.23', require: false
|
|
31
31
|
gem 'yard', '~>0.9', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -12,16 +12,16 @@ PATH
|
|
|
12
12
|
GEM
|
|
13
13
|
remote: https://rubygems.org/
|
|
14
14
|
specs:
|
|
15
|
-
addressable (2.8.
|
|
16
|
-
public_suffix (>= 2.0.2, <
|
|
15
|
+
addressable (2.8.8)
|
|
16
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
17
17
|
ansi (1.5.0)
|
|
18
18
|
ast (2.4.3)
|
|
19
|
-
backtrace (0.4.
|
|
20
|
-
base64 (0.
|
|
21
|
-
bigdecimal (
|
|
19
|
+
backtrace (0.4.1)
|
|
20
|
+
base64 (0.3.0)
|
|
21
|
+
bigdecimal (4.0.1)
|
|
22
22
|
builder (3.3.0)
|
|
23
|
-
concurrent-ruby (1.3.
|
|
24
|
-
crack (1.0.
|
|
23
|
+
concurrent-ruby (1.3.6)
|
|
24
|
+
crack (1.0.1)
|
|
25
25
|
bigdecimal
|
|
26
26
|
rexml
|
|
27
27
|
cucumber (9.2.1)
|
|
@@ -45,39 +45,41 @@ GEM
|
|
|
45
45
|
bigdecimal
|
|
46
46
|
cucumber-gherkin (27.0.0)
|
|
47
47
|
cucumber-messages (>= 19.1.4, < 23)
|
|
48
|
-
cucumber-html-formatter (21.
|
|
48
|
+
cucumber-html-formatter (21.15.1)
|
|
49
49
|
cucumber-messages (> 19, < 28)
|
|
50
50
|
cucumber-messages (22.0.0)
|
|
51
51
|
cucumber-tag-expressions (6.1.2)
|
|
52
|
-
|
|
52
|
+
date (3.5.1)
|
|
53
|
+
diff-lcs (1.6.2)
|
|
53
54
|
docile (1.4.1)
|
|
54
55
|
donce (0.2.4)
|
|
55
56
|
backtrace (~> 0.3)
|
|
56
57
|
os (~> 1.1)
|
|
57
58
|
qbash (~> 0.3)
|
|
58
|
-
elapsed (0.0
|
|
59
|
-
loog (
|
|
60
|
-
tago (
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
elapsed (0.2.0)
|
|
60
|
+
loog (~> 0.6)
|
|
61
|
+
tago (~> 0.1)
|
|
62
|
+
erb (6.0.1)
|
|
63
|
+
eth (0.5.13)
|
|
63
64
|
forwardable (~> 1.3)
|
|
64
65
|
keccak (~> 1.3)
|
|
65
66
|
konstructor (~> 1.0)
|
|
66
67
|
openssl (>= 2.2, < 4.0)
|
|
67
68
|
rbsecp256k1 (~> 6.0)
|
|
68
69
|
scrypt (~> 3.0)
|
|
69
|
-
ethon (0.
|
|
70
|
+
ethon (0.18.0)
|
|
70
71
|
ffi (>= 1.15.0)
|
|
72
|
+
logger
|
|
71
73
|
eventmachine (1.2.7)
|
|
72
|
-
faraday (2.
|
|
74
|
+
faraday (2.14.0)
|
|
73
75
|
faraday-net_http (>= 2.0, < 3.5)
|
|
74
76
|
json
|
|
75
77
|
logger
|
|
76
|
-
faraday-net_http (3.4.
|
|
77
|
-
net-http (
|
|
78
|
-
faye-websocket (0.
|
|
78
|
+
faraday-net_http (3.4.2)
|
|
79
|
+
net-http (~> 0.5)
|
|
80
|
+
faye-websocket (0.12.0)
|
|
79
81
|
eventmachine (>= 0.12.0)
|
|
80
|
-
websocket-driver (>= 0.
|
|
82
|
+
websocket-driver (>= 0.8.0)
|
|
81
83
|
ffi (1.17.2-arm64-darwin)
|
|
82
84
|
ffi (1.17.2-x64-mingw-ucrt)
|
|
83
85
|
ffi (1.17.2-x86_64-darwin)
|
|
@@ -86,20 +88,22 @@ GEM
|
|
|
86
88
|
ffi (>= 1.15.5)
|
|
87
89
|
rake
|
|
88
90
|
forwardable (1.3.3)
|
|
89
|
-
hashdiff (1.1
|
|
90
|
-
json (2.
|
|
91
|
+
hashdiff (1.2.1)
|
|
92
|
+
json (2.18.0)
|
|
91
93
|
jsonrpc-client (0.1.4)
|
|
92
94
|
faraday
|
|
93
95
|
multi_json (>= 1.1.0)
|
|
94
96
|
keccak (1.3.2)
|
|
95
97
|
konstructor (1.0.2)
|
|
96
|
-
language_server-protocol (3.17.0.
|
|
98
|
+
language_server-protocol (3.17.0.5)
|
|
97
99
|
lint_roller (1.1.0)
|
|
98
100
|
logger (1.7.0)
|
|
99
|
-
loog (0.6.
|
|
101
|
+
loog (0.6.1)
|
|
102
|
+
logger (~> 1.0)
|
|
103
|
+
memoist3 (1.0.0)
|
|
100
104
|
mini_mime (1.1.5)
|
|
101
|
-
mini_portile2 (2.8.
|
|
102
|
-
minitest (5.
|
|
105
|
+
mini_portile2 (2.8.9)
|
|
106
|
+
minitest (5.27.0)
|
|
103
107
|
minitest-reporters (1.7.1)
|
|
104
108
|
ansi
|
|
105
109
|
builder
|
|
@@ -107,36 +111,43 @@ GEM
|
|
|
107
111
|
ruby-progressbar
|
|
108
112
|
minitest-retry (0.2.5)
|
|
109
113
|
minitest (>= 5.0)
|
|
110
|
-
multi_json (1.
|
|
114
|
+
multi_json (1.18.0)
|
|
111
115
|
multi_test (1.1.0)
|
|
112
|
-
net-http (0.
|
|
113
|
-
uri
|
|
114
|
-
openssl (3.3.
|
|
116
|
+
net-http (0.9.1)
|
|
117
|
+
uri (>= 0.11.1)
|
|
118
|
+
openssl (3.3.2)
|
|
115
119
|
os (1.1.4)
|
|
116
120
|
parallel (1.27.0)
|
|
117
|
-
parser (3.3.
|
|
121
|
+
parser (3.3.10.0)
|
|
118
122
|
ast (~> 2.4.1)
|
|
119
123
|
racc
|
|
120
|
-
pkg-config (1.6.
|
|
121
|
-
prism (1.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
pkg-config (1.6.5)
|
|
125
|
+
prism (1.6.0)
|
|
126
|
+
psych (5.3.1)
|
|
127
|
+
date
|
|
128
|
+
stringio
|
|
129
|
+
public_suffix (7.0.0)
|
|
130
|
+
qbash (0.4.8)
|
|
124
131
|
backtrace (> 0)
|
|
125
132
|
elapsed (> 0)
|
|
126
133
|
loog (> 0)
|
|
127
134
|
tago (> 0)
|
|
128
135
|
racc (1.8.1)
|
|
129
136
|
rainbow (3.1.1)
|
|
130
|
-
rake (13.
|
|
131
|
-
random-port (0.7.
|
|
132
|
-
tago (
|
|
137
|
+
rake (13.3.1)
|
|
138
|
+
random-port (0.7.6)
|
|
139
|
+
tago (~> 0.0)
|
|
133
140
|
rbsecp256k1 (6.0.0)
|
|
134
141
|
mini_portile2 (~> 2.8)
|
|
135
142
|
pkg-config (~> 1.5)
|
|
136
143
|
rubyzip (~> 2.3)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
rdoc (6.17.0)
|
|
145
|
+
erb
|
|
146
|
+
psych (>= 4.0.0)
|
|
147
|
+
tsort
|
|
148
|
+
regexp_parser (2.11.3)
|
|
149
|
+
rexml (3.4.4)
|
|
150
|
+
rubocop (1.82.0)
|
|
140
151
|
json (~> 2.3)
|
|
141
152
|
language_server-protocol (~> 3.17.0.2)
|
|
142
153
|
lint_roller (~> 1.1.0)
|
|
@@ -144,62 +155,62 @@ GEM
|
|
|
144
155
|
parser (>= 3.3.0.2)
|
|
145
156
|
rainbow (>= 2.2.2, < 4.0)
|
|
146
157
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
147
|
-
rubocop-ast (>= 1.
|
|
158
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
148
159
|
ruby-progressbar (~> 1.7)
|
|
149
160
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
150
|
-
rubocop-ast (1.
|
|
161
|
+
rubocop-ast (1.48.0)
|
|
151
162
|
parser (>= 3.3.7.2)
|
|
152
163
|
prism (~> 1.4)
|
|
153
|
-
rubocop-minitest (0.38.
|
|
164
|
+
rubocop-minitest (0.38.2)
|
|
154
165
|
lint_roller (~> 1.1)
|
|
155
166
|
rubocop (>= 1.75.0, < 2.0)
|
|
156
167
|
rubocop-ast (>= 1.38.0, < 2.0)
|
|
157
|
-
rubocop-performance (1.
|
|
168
|
+
rubocop-performance (1.26.1)
|
|
158
169
|
lint_roller (~> 1.1)
|
|
159
170
|
rubocop (>= 1.75.0, < 2.0)
|
|
160
|
-
rubocop-ast (>= 1.
|
|
171
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
161
172
|
rubocop-rake (0.7.1)
|
|
162
173
|
lint_roller (~> 1.1)
|
|
163
174
|
rubocop (>= 1.72.1)
|
|
164
|
-
rubocop-rspec (3.6.0)
|
|
165
|
-
lint_roller (~> 1.1)
|
|
166
|
-
rubocop (~> 1.72, >= 1.72.1)
|
|
167
175
|
ruby-progressbar (1.13.0)
|
|
168
176
|
rubyzip (2.4.1)
|
|
169
|
-
scrypt (3.0
|
|
177
|
+
scrypt (3.1.0)
|
|
170
178
|
ffi-compiler (>= 1.0, < 2.0)
|
|
171
|
-
rake (
|
|
179
|
+
rake (~> 13)
|
|
172
180
|
simplecov (0.22.0)
|
|
173
181
|
docile (~> 1.1)
|
|
174
182
|
simplecov-html (~> 0.11)
|
|
175
183
|
simplecov_json_formatter (~> 0.1)
|
|
176
|
-
simplecov-cobertura (
|
|
184
|
+
simplecov-cobertura (3.1.0)
|
|
177
185
|
rexml
|
|
178
186
|
simplecov (~> 0.19)
|
|
179
|
-
simplecov-html (0.13.
|
|
187
|
+
simplecov-html (0.13.2)
|
|
180
188
|
simplecov_json_formatter (0.1.4)
|
|
181
189
|
slop (4.10.1)
|
|
182
|
-
|
|
190
|
+
stringio (3.2.0)
|
|
191
|
+
sys-uname (1.4.1)
|
|
183
192
|
ffi (~> 1.1)
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
memoist3 (~> 1.0.0)
|
|
194
|
+
tago (0.6.0)
|
|
195
|
+
threads (0.5.0)
|
|
186
196
|
backtrace (~> 0)
|
|
187
197
|
concurrent-ruby (~> 1.0)
|
|
198
|
+
tsort (0.2.0)
|
|
188
199
|
typhoeus (1.4.1)
|
|
189
200
|
ethon (>= 0.9.0)
|
|
190
|
-
unicode-display_width (3.
|
|
191
|
-
unicode-emoji (~> 4.
|
|
192
|
-
unicode-emoji (4.0
|
|
193
|
-
uri (1.
|
|
194
|
-
webmock (3.
|
|
201
|
+
unicode-display_width (3.2.0)
|
|
202
|
+
unicode-emoji (~> 4.1)
|
|
203
|
+
unicode-emoji (4.1.0)
|
|
204
|
+
uri (1.1.1)
|
|
205
|
+
webmock (3.26.1)
|
|
195
206
|
addressable (>= 2.8.0)
|
|
196
207
|
crack (>= 0.3.2)
|
|
197
208
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
198
|
-
websocket-driver (0.
|
|
209
|
+
websocket-driver (0.8.0)
|
|
199
210
|
base64
|
|
200
211
|
websocket-extensions (>= 0.1.0)
|
|
201
212
|
websocket-extensions (0.1.5)
|
|
202
|
-
yard (0.9.
|
|
213
|
+
yard (0.9.38)
|
|
203
214
|
|
|
204
215
|
PLATFORMS
|
|
205
216
|
arm64-darwin-22
|
|
@@ -211,28 +222,28 @@ PLATFORMS
|
|
|
211
222
|
x86_64-linux
|
|
212
223
|
|
|
213
224
|
DEPENDENCIES
|
|
214
|
-
backtrace (
|
|
225
|
+
backtrace (~> 0.4)
|
|
215
226
|
concurrent-ruby (~> 1.2)
|
|
216
227
|
cucumber (~> 9.2)
|
|
217
|
-
donce (
|
|
228
|
+
donce (~> 0.2)
|
|
218
229
|
erc20!
|
|
219
|
-
faraday (
|
|
220
|
-
loog (
|
|
230
|
+
faraday (~> 2.14)
|
|
231
|
+
loog (~> 0.6)
|
|
221
232
|
minitest (~> 5.25)
|
|
222
233
|
minitest-reporters (~> 1.7)
|
|
223
234
|
minitest-retry (~> 0.2)
|
|
224
|
-
qbash (
|
|
235
|
+
qbash (~> 0.4)
|
|
225
236
|
rake (~> 13.2)
|
|
226
|
-
random-port (
|
|
237
|
+
random-port (~> 0.7)
|
|
238
|
+
rdoc (~> 6.17)
|
|
227
239
|
rubocop (~> 1.75)
|
|
228
|
-
rubocop-minitest (
|
|
229
|
-
rubocop-performance (
|
|
230
|
-
rubocop-rake (
|
|
231
|
-
rubocop-rspec (> 0)
|
|
240
|
+
rubocop-minitest (~> 0.38)
|
|
241
|
+
rubocop-performance (~> 1.25)
|
|
242
|
+
rubocop-rake (~> 0.7)
|
|
232
243
|
simplecov (~> 0.22)
|
|
233
|
-
simplecov-cobertura (~>
|
|
244
|
+
simplecov-cobertura (~> 3.1)
|
|
234
245
|
threads (~> 0.4)
|
|
235
|
-
typhoeus (
|
|
246
|
+
typhoeus (~> 1.4)
|
|
236
247
|
webmock (~> 3.23)
|
|
237
248
|
yard (~> 0.9)
|
|
238
249
|
|
data/REUSE.toml
CHANGED
|
@@ -4,10 +4,19 @@
|
|
|
4
4
|
version = 1
|
|
5
5
|
[[annotations]]
|
|
6
6
|
path = [
|
|
7
|
+
".DS_Store",
|
|
8
|
+
".gitattributes",
|
|
9
|
+
".gitignore",
|
|
10
|
+
".gitleaksignore",
|
|
11
|
+
".pdd",
|
|
7
12
|
"**.json",
|
|
8
13
|
"**.md",
|
|
9
14
|
"**.png",
|
|
10
15
|
"**.txt",
|
|
16
|
+
"**/.DS_Store",
|
|
17
|
+
"**/.gitignore",
|
|
18
|
+
"**/.gitleaksignore",
|
|
19
|
+
"**/.pdd",
|
|
11
20
|
"**/*.csv",
|
|
12
21
|
"**/*.jpg",
|
|
13
22
|
"**/*.json",
|
|
@@ -17,23 +26,14 @@ path = [
|
|
|
17
26
|
"**/*.svg",
|
|
18
27
|
"**/*.txt",
|
|
19
28
|
"**/*.vm",
|
|
20
|
-
"**/.DS_Store",
|
|
21
|
-
"**/.gitignore",
|
|
22
|
-
"**/.gitleaksignore",
|
|
23
|
-
"**/.pdd",
|
|
24
|
-
"**/CNAME",
|
|
25
29
|
"**/Cargo.toml",
|
|
30
|
+
"**/CNAME",
|
|
26
31
|
"**/Gemfile.lock",
|
|
27
|
-
".DS_Store",
|
|
28
|
-
".gitattributes",
|
|
29
|
-
".gitignore",
|
|
30
|
-
".gitleaksignore",
|
|
31
|
-
".pdd",
|
|
32
32
|
"Cargo.toml",
|
|
33
33
|
"Gemfile.lock",
|
|
34
|
-
"README.md",
|
|
35
34
|
"hardhat/.gitignore",
|
|
36
35
|
"hardhat/package.json",
|
|
36
|
+
"README.md",
|
|
37
37
|
"renovate.json",
|
|
38
38
|
]
|
|
39
39
|
precedence = "override"
|
data/Rakefile
CHANGED
data/bin/erc20
CHANGED
|
@@ -116,10 +116,13 @@ Options are:"
|
|
|
116
116
|
raise 'Address is required' if address.nil?
|
|
117
117
|
log.debug("Sending ERC20 tokens to #{address}")
|
|
118
118
|
amount = opts.arguments[3]
|
|
119
|
-
raise 'Amount argument is required' if amount.nil?
|
|
119
|
+
raise 'Amount argument is required (for example, "19.9usdt")' if amount.nil?
|
|
120
120
|
raise 'Amount is not valid' unless /^[0-9]+(usdt)?$/.match?(amount)
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
if /^[0-9]+$/.match?(amount)
|
|
122
|
+
amount = amount.to_i
|
|
123
|
+
elsif /^[0-9]usdt+$/.match?(amount)
|
|
124
|
+
amount = (amount.gsub(/usdt^/, '').to_f * 1_000_000).to_i
|
|
125
|
+
end
|
|
123
126
|
log.debug("Sending #{amount} ERC20 tokens")
|
|
124
127
|
puts wallet.pay(priv.private_hex, address, amount)
|
|
125
128
|
when 'eth_pay'
|
data/erc20.gemspec
CHANGED
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
'Ethereum node to provide JSON RPC and Websockets API.'
|
|
21
21
|
s.authors = ['Yegor Bugayenko']
|
|
22
22
|
s.email = 'yegor256@gmail.com'
|
|
23
|
-
s.homepage = '
|
|
24
|
-
s.files = `git ls-files`.split($RS)
|
|
23
|
+
s.homepage = 'https://github.com/yegor256/erc20.rb'
|
|
24
|
+
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
|
25
25
|
s.rdoc_options = ['--charset=UTF-8']
|
|
26
26
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
27
27
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
data/hardhat/Dockerfile
CHANGED
|
@@ -14,14 +14,12 @@ RUN npm install
|
|
|
14
14
|
ARG PORT=8080
|
|
15
15
|
ARG HOST=localhost
|
|
16
16
|
COPY hardhat.config.js .
|
|
17
|
-
RUN sed -i "s/PORT/$PORT/g" hardhat.config.js
|
|
18
|
-
|
|
17
|
+
RUN sed -i "s/PORT/$PORT/g" hardhat.config.js \
|
|
18
|
+
&& sed -i "s/HOST/$HOST/g" hardhat.config.js
|
|
19
19
|
|
|
20
20
|
COPY contracts contracts
|
|
21
21
|
COPY ignition ignition
|
|
22
22
|
|
|
23
|
-
RUN rm -rf ignition/deployments
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
RUN rm -rf cache
|
|
23
|
+
RUN rm -rf ignition/deployments \
|
|
24
|
+
&& npx hardhat compile \
|
|
25
|
+
&& rm -rf cache
|
data/hardhat/package.json
CHANGED
data/lib/erc20/erc20.rb
CHANGED
data/lib/erc20/fake_wallet.rb
CHANGED
|
@@ -69,6 +69,14 @@ class ERC20::FakeWallet
|
|
|
69
69
|
b
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
# Get ERC20 amount (in tokens) that was sent in the given transaction.
|
|
73
|
+
#
|
|
74
|
+
# @param [String] _txn Hex of transaction
|
|
75
|
+
# @return [Integer] Balance, in ERC20 tokens
|
|
76
|
+
def sum_of(_txn)
|
|
77
|
+
42_000_000
|
|
78
|
+
end
|
|
79
|
+
|
|
72
80
|
# How much gas units is required in order to send ERC20 transaction.
|
|
73
81
|
#
|
|
74
82
|
# @param [String] from The departing address, in hex
|
data/lib/erc20/wallet.rb
CHANGED
|
@@ -130,7 +130,7 @@ class ERC20::Wallet
|
|
|
130
130
|
# An address in Ethereum may have many balances. One of them is the main
|
|
131
131
|
# balance in ETH crypto. This balance is checked by this method.
|
|
132
132
|
#
|
|
133
|
-
# @param [String]
|
|
133
|
+
# @param [String] address Public key, in hex, starting from '0x'
|
|
134
134
|
# @return [Integer] Balance, in ETH
|
|
135
135
|
def eth_balance(address)
|
|
136
136
|
raise 'Address can\'t be nil' unless address
|
|
@@ -142,6 +142,28 @@ class ERC20::Wallet
|
|
|
142
142
|
b
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
+
# Get ERC20 amount (in tokens) that was sent in the given transaction.
|
|
146
|
+
#
|
|
147
|
+
# @param [String] txn Hex of transaction
|
|
148
|
+
# @return [Integer] Balance, in ERC20 tokens
|
|
149
|
+
def sum_of(txn)
|
|
150
|
+
raise 'Transaction hash can\'t be nil' unless txn
|
|
151
|
+
raise 'Transaction hash must be a String' unless txn.is_a?(String)
|
|
152
|
+
raise 'Invalid format of the transaction hash' unless /^0x[0-9a-fA-F]{64}$/.match?(txn)
|
|
153
|
+
receipt = jsonrpc.eth_getTransactionReceipt(txn)
|
|
154
|
+
raise "Transaction not found: #{txn}" if receipt.nil?
|
|
155
|
+
logs = receipt['logs'] || []
|
|
156
|
+
transfer_event = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
|
|
157
|
+
logs.each do |log|
|
|
158
|
+
next unless log['topics'] && log['topics'][0] == transfer_event
|
|
159
|
+
next unless log['address'].downcase == @contract.downcase
|
|
160
|
+
amount = log['data'].to_i(16)
|
|
161
|
+
log_it(:debug, "Found transfer of #{amount} tokens in transaction #{txn}")
|
|
162
|
+
return amount
|
|
163
|
+
end
|
|
164
|
+
raise "No transfer event found in transaction #{txn}"
|
|
165
|
+
end
|
|
166
|
+
|
|
145
167
|
# How many gas units are required to send an ERC20 transaction.
|
|
146
168
|
#
|
|
147
169
|
# @param [String] from The sending address, in hex
|
|
@@ -336,7 +358,7 @@ class ERC20::Wallet
|
|
|
336
358
|
u = url(http: false)
|
|
337
359
|
log_it(:debug, "Connecting ##{subscription_id} to #{u.hostname}:#{u.port}...")
|
|
338
360
|
contract = @contract
|
|
339
|
-
log_url = "ws#{
|
|
361
|
+
log_url = "ws#{'s' if @ssl}://#{u.hostname}:#{u.port}"
|
|
340
362
|
ws = Faye::WebSocket::Client.new(u.to_s, [], proxy: @proxy ? { origin: @proxy } : {}, ping: 60)
|
|
341
363
|
timer = nil
|
|
342
364
|
ws.on(:open) do
|
|
@@ -449,7 +471,7 @@ class ERC20::Wallet
|
|
|
449
471
|
end
|
|
450
472
|
|
|
451
473
|
def url(http: true)
|
|
452
|
-
URI.parse("#{http ? 'http' : 'ws'}#{
|
|
474
|
+
URI.parse("#{http ? 'http' : 'ws'}#{'s' if @ssl}://#{@host}:#{@port}#{http ? @http_path : @ws_path}")
|
|
453
475
|
end
|
|
454
476
|
|
|
455
477
|
def jsonrpc
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: erc20
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: eth
|
|
@@ -102,27 +102,9 @@ executables:
|
|
|
102
102
|
- erc20
|
|
103
103
|
extensions: []
|
|
104
104
|
extra_rdoc_files:
|
|
105
|
-
- README.md
|
|
106
105
|
- LICENSE.txt
|
|
106
|
+
- README.md
|
|
107
107
|
files:
|
|
108
|
-
- ".0pdd.yml"
|
|
109
|
-
- ".gitattributes"
|
|
110
|
-
- ".github/workflows/actionlint.yml"
|
|
111
|
-
- ".github/workflows/codecov.yml"
|
|
112
|
-
- ".github/workflows/copyrights.yml"
|
|
113
|
-
- ".github/workflows/markdown-lint.yml"
|
|
114
|
-
- ".github/workflows/pdd.yml"
|
|
115
|
-
- ".github/workflows/rake.yml"
|
|
116
|
-
- ".github/workflows/reuse.yml"
|
|
117
|
-
- ".github/workflows/shellcheck.yml"
|
|
118
|
-
- ".github/workflows/xcop.yml"
|
|
119
|
-
- ".github/workflows/yamllint.yml"
|
|
120
|
-
- ".gitignore"
|
|
121
|
-
- ".gitleaksignore"
|
|
122
|
-
- ".pdd"
|
|
123
|
-
- ".rubocop.yml"
|
|
124
|
-
- ".rultor.yml"
|
|
125
|
-
- ".yamllint.yml"
|
|
126
108
|
- Gemfile
|
|
127
109
|
- Gemfile.lock
|
|
128
110
|
- LICENSE.txt
|
|
@@ -146,12 +128,7 @@ files:
|
|
|
146
128
|
- lib/erc20/erc20.rb
|
|
147
129
|
- lib/erc20/fake_wallet.rb
|
|
148
130
|
- lib/erc20/wallet.rb
|
|
149
|
-
|
|
150
|
-
- test/erc20/test_fake_wallet.rb
|
|
151
|
-
- test/erc20/test_wallet.rb
|
|
152
|
-
- test/erc20/test_wallet_live.rb
|
|
153
|
-
- test/test__helper.rb
|
|
154
|
-
homepage: http://github.com/yegor256/erc20.rb
|
|
131
|
+
homepage: https://github.com/yegor256/erc20.rb
|
|
155
132
|
licenses:
|
|
156
133
|
- MIT
|
|
157
134
|
metadata:
|
|
@@ -171,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
171
148
|
- !ruby/object:Gem::Version
|
|
172
149
|
version: '0'
|
|
173
150
|
requirements: []
|
|
174
|
-
rubygems_version: 3.6.
|
|
151
|
+
rubygems_version: 3.6.9
|
|
175
152
|
specification_version: 4
|
|
176
153
|
summary: Sending and receiving ERC20 tokens in Ethereum network
|
|
177
154
|
test_files: []
|
data/.0pdd.yml
DELETED
data/.gitattributes
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: actionlint
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
actionlint:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- name: Download actionlint
|
|
20
|
-
id: get_actionlint
|
|
21
|
-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
22
|
-
shell: bash
|
|
23
|
-
- name: Check workflow files
|
|
24
|
-
run: ${{ steps.get_actionlint.outputs.executable }} -color
|
|
25
|
-
shell: bash
|