erc20 0.2.0 → 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 +81 -71
- data/Rakefile +1 -0
- data/bin/erc20 +6 -3
- data/erc20.gemspec +2 -2
- data/hardhat/package.json +1 -1
- data/lib/erc20/erc20.rb +1 -1
- data/lib/erc20/fake_wallet.rb +1 -1
- data/lib/erc20/wallet.rb +3 -3
- metadata +3 -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/hadolint.yml +0 -16
- 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/typos.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 -118
- data/test/erc20/test_wallet.rb +0 -343
- data/test/erc20/test_wallet_live.rb +0 -126
- data/test/test__helper.rb +0 -206
data/.github/workflows/rake.yml
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: rake
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
rake:
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
os: [ubuntu-24.04]
|
|
18
|
-
ruby: [3.3]
|
|
19
|
-
runs-on: ${{ matrix.os }}
|
|
20
|
-
env:
|
|
21
|
-
INFURA_KEY: ${{ secrets.INFURA_KEY }}
|
|
22
|
-
GETBLOCK_KEY: ${{ secrets.GETBLOCK_KEY }}
|
|
23
|
-
GETBLOCK_SEPOILA_KEY: ${{ secrets.GETBLOCK_SEPOILA_KEY }}
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v4
|
|
26
|
-
- run: |
|
|
27
|
-
sudo apt-get update --yes --fix-missing
|
|
28
|
-
sudo apt-get install --yes autoconf
|
|
29
|
-
if: matrix.os == 'ubuntu-24.04'
|
|
30
|
-
- run: brew install automake
|
|
31
|
-
if: matrix.os == 'macos-15'
|
|
32
|
-
- uses: ruby/setup-ruby@v1
|
|
33
|
-
with:
|
|
34
|
-
ruby-version: ${{ matrix.ruby }}
|
|
35
|
-
bundler-cache: true
|
|
36
|
-
- run: bundle config set --global path "$(pwd)/vendor/bundle"
|
|
37
|
-
- run: bundle install --no-color
|
|
38
|
-
- run: bundle exec rake
|
data/.github/workflows/reuse.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: reuse
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
reuse:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: fsfe/reuse-action@v5
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: shellcheck
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
shellcheck:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: ludeeus/action-shellcheck@master
|
data/.github/workflows/typos.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: typos
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
typos:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: crate-ci/typos@v1.32.0
|
data/.github/workflows/xcop.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: xcop
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
xcop:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: g4s8/xcop-action@master
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
name: yamllint
|
|
6
|
-
'on':
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
jobs:
|
|
14
|
-
yamllint:
|
|
15
|
-
timeout-minutes: 15
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: ibiqlik/action-yamllint@v3
|
|
20
|
-
with:
|
|
21
|
-
config_file: .yamllint.yml
|
data/.gitignore
DELETED
data/.gitleaksignore
DELETED
data/.pdd
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
AllCops:
|
|
5
|
-
Exclude:
|
|
6
|
-
- 'bin/**/*'
|
|
7
|
-
- 'assets/**/*'
|
|
8
|
-
- 'vendor/**/**'
|
|
9
|
-
DisplayCopNames: true
|
|
10
|
-
TargetRubyVersion: 3.2
|
|
11
|
-
SuggestExtensions: false
|
|
12
|
-
NewCops: enable
|
|
13
|
-
plugins:
|
|
14
|
-
- rubocop-performance
|
|
15
|
-
- rubocop-rake
|
|
16
|
-
- rubocop-minitest
|
|
17
|
-
Minitest/EmptyLineBeforeAssertionMethods:
|
|
18
|
-
Enabled: false
|
|
19
|
-
Gemspec/RequiredRubyVersion:
|
|
20
|
-
Enabled: false
|
|
21
|
-
Metrics/MethodLength:
|
|
22
|
-
Enabled: false
|
|
23
|
-
Style/ClassAndModuleChildren:
|
|
24
|
-
Enabled: false
|
|
25
|
-
Layout/MultilineMethodCallIndentation:
|
|
26
|
-
Enabled: false
|
|
27
|
-
Metrics/AbcSize:
|
|
28
|
-
Enabled: false
|
|
29
|
-
Metrics/ParameterLists:
|
|
30
|
-
Enabled: false
|
|
31
|
-
Metrics/BlockLength:
|
|
32
|
-
Max: 100
|
|
33
|
-
Metrics/CyclomaticComplexity:
|
|
34
|
-
Max: 25
|
|
35
|
-
Metrics/PerceivedComplexity:
|
|
36
|
-
Max: 30
|
|
37
|
-
Metrics/ClassLength:
|
|
38
|
-
Enabled: false
|
|
39
|
-
Layout/EmptyLineAfterGuardClause:
|
|
40
|
-
Enabled: false
|
|
41
|
-
Naming/MethodParameterName:
|
|
42
|
-
MinNameLength: 2
|
|
43
|
-
Layout/EndOfLine:
|
|
44
|
-
EnforcedStyle: lf
|
|
45
|
-
Security/MarshalLoad:
|
|
46
|
-
Enabled: false
|
|
47
|
-
Layout/MultilineAssignmentLayout:
|
|
48
|
-
Enabled: true
|
|
49
|
-
require: []
|
data/.rultor.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
# yamllint disable rule:line-length
|
|
5
|
-
docker:
|
|
6
|
-
image: yegor256/ruby
|
|
7
|
-
assets:
|
|
8
|
-
rubygems.yml: yegor256/home#assets/rubygems.yml
|
|
9
|
-
install: |
|
|
10
|
-
pdd -f /dev/null
|
|
11
|
-
bundle install --no-color
|
|
12
|
-
release:
|
|
13
|
-
pre: false
|
|
14
|
-
script: |-
|
|
15
|
-
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
|
16
|
-
DONCE_SUDO=true bundle exec rake
|
|
17
|
-
rm -rf *.gem
|
|
18
|
-
sed -i "s/0\.0\.0/${tag}/g" lib/erc20/erc20.rb
|
|
19
|
-
git add lib/erc20/erc20.rb
|
|
20
|
-
git commit -m "version set to ${tag}"
|
|
21
|
-
gem build erc20.gemspec
|
|
22
|
-
chmod 0600 ../rubygems.yml
|
|
23
|
-
gem push *.gem --config-file ../rubygems.yml
|
|
24
|
-
merge:
|
|
25
|
-
script: |-
|
|
26
|
-
DONCE_SUDO=true bundle exec rake
|
data/.yamllint.yml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
---
|
|
4
|
-
extends: default
|
|
5
|
-
rules:
|
|
6
|
-
line-length: disable
|
|
7
|
-
brackets:
|
|
8
|
-
min-spaces-inside: 0
|
|
9
|
-
max-spaces-inside: 2
|
|
10
|
-
truthy:
|
|
11
|
-
level: warning
|
|
12
|
-
allowed-values: [ 'on', 'true', 'false', 'yes', 'no' ]
|
data/renovate.json
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
4
|
-
# SPDX-License-Identifier: MIT
|
|
5
|
-
|
|
6
|
-
require 'backtrace'
|
|
7
|
-
require 'donce'
|
|
8
|
-
require 'eth'
|
|
9
|
-
require 'faraday'
|
|
10
|
-
require 'loog'
|
|
11
|
-
require 'random-port'
|
|
12
|
-
require 'shellwords'
|
|
13
|
-
require 'threads'
|
|
14
|
-
require 'typhoeus'
|
|
15
|
-
require_relative '../test__helper'
|
|
16
|
-
require_relative '../../lib/erc20/fake_wallet'
|
|
17
|
-
|
|
18
|
-
# Test.
|
|
19
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
20
|
-
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
|
21
|
-
# License:: MIT
|
|
22
|
-
class TestFakeWallet < ERC20::Test
|
|
23
|
-
def test_checks_gas_estimate
|
|
24
|
-
b = ERC20::FakeWallet.new.gas_estimate(
|
|
25
|
-
'0xEB2fE8872A6f1eDb70a2632Effffffffffffffff',
|
|
26
|
-
'0xfadef8ba4a5d709a2bf55b7a8798c9b438c640c1',
|
|
27
|
-
44_000
|
|
28
|
-
)
|
|
29
|
-
refute_nil(b)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_checks_gas_price
|
|
33
|
-
gwei = ERC20::FakeWallet.new.gas_price
|
|
34
|
-
refute_nil(gwei)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_checks_fake_balance
|
|
38
|
-
w = ERC20::FakeWallet.new
|
|
39
|
-
a = '0xEB2fE8872A6f1eDb70a2632Effffffffffffffff'
|
|
40
|
-
b = w.balance(a)
|
|
41
|
-
refute_nil(b)
|
|
42
|
-
assert_equal(42_000_000, b)
|
|
43
|
-
assert_includes(w.history, { method: :balance, result: b, address: a })
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_checks_preset_fake_balance
|
|
47
|
-
w = ERC20::FakeWallet.new
|
|
48
|
-
a = '0xEB2fE8872A6f1eDb70a2632Effffffffeefbbfaa'
|
|
49
|
-
b = 55_555
|
|
50
|
-
w.set_balance(a, b)
|
|
51
|
-
assert_equal(b, w.balance(a))
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_checks_fake_eth_balance
|
|
55
|
-
a = '0xEB2fE8872A6f1eDb70a2632Ebbffffff66fff77f'
|
|
56
|
-
w = ERC20::FakeWallet.new
|
|
57
|
-
b = w.eth_balance(a)
|
|
58
|
-
refute_nil(b)
|
|
59
|
-
assert_equal(77_000_000_000_000_000, b)
|
|
60
|
-
assert_includes(w.history, { method: :eth_balance, result: b, address: a })
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def test_checks_preset_fake_eth_balance
|
|
64
|
-
a = '0xEB2fE8872A6f1eDb70a2632Eff88fff99fff33ff'
|
|
65
|
-
w = ERC20::FakeWallet.new
|
|
66
|
-
b = 33_333
|
|
67
|
-
w.set_eth_balance(a, b)
|
|
68
|
-
assert_equal(b, w.eth_balance(a))
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_reads_sum_of_payment
|
|
72
|
-
txn = '0xcf0598d640d4bea3367e6af28a08c54342a39156afd292a31453778e4755945d'
|
|
73
|
-
assert_predicate(ERC20::FakeWallet.new.sum_of(txn), :positive?)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def test_returns_host
|
|
77
|
-
assert_equal('example.com', ERC20::FakeWallet.new.host)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def test_pays_fake_money
|
|
81
|
-
priv = '81a9b2114d53731ecc84b261ef6c0387dde34d5907fe7b441240cc21d61bf80a'
|
|
82
|
-
address = '0xfadef8ba4a5d709a2bf55b7a8798c9b438c640c1'
|
|
83
|
-
w = ERC20::FakeWallet.new
|
|
84
|
-
amount = 555_000
|
|
85
|
-
txn = w.pay(priv, address, amount)
|
|
86
|
-
assert_equal(66, txn.length)
|
|
87
|
-
assert_match(/^0x[a-f0-9]{64}$/, txn)
|
|
88
|
-
assert_equal(ERC20::FakeWallet::TXN_HASH, txn)
|
|
89
|
-
assert_includes(w.history, { method: :pay, result: txn, priv:, address:, amount:, gas_limit: nil, gas_price: nil })
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def test_pays_fake_eths
|
|
93
|
-
priv = '81a9b2114d53731ecc84b261ef6c0387dde34d5907fe7b441240cc21d61bf80a'
|
|
94
|
-
to = '0xfadef8ba4a5d709a2bf55b7a8798c9b438c640c1'
|
|
95
|
-
txn = ERC20::FakeWallet.new.eth_pay(Eth::Key.new(priv:), to, 555)
|
|
96
|
-
assert_equal(66, txn.length)
|
|
97
|
-
assert_match(/^0x[a-f0-9]{64}$/, txn)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def test_accepts_payments_on_hardhat
|
|
101
|
-
active = Primitivo.new([])
|
|
102
|
-
addresses = Primitivo.new(['0xfadef8ba4a5d709a2bf55b7a8798c9b438c640c1'])
|
|
103
|
-
event = nil
|
|
104
|
-
daemon =
|
|
105
|
-
Thread.new do
|
|
106
|
-
ERC20::FakeWallet.new.accept(addresses, active, delay: 0.1) do |e|
|
|
107
|
-
event = e
|
|
108
|
-
end
|
|
109
|
-
rescue StandardError => e
|
|
110
|
-
fake_loog.error(Backtrace.new(e))
|
|
111
|
-
end
|
|
112
|
-
wait_for { !active.to_a.empty? }
|
|
113
|
-
wait_for { !event.nil? }
|
|
114
|
-
daemon.kill
|
|
115
|
-
daemon.join(30)
|
|
116
|
-
refute_nil(event)
|
|
117
|
-
end
|
|
118
|
-
end
|