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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,10 +0,0 @@
1
- .bundle/
2
- .DS_Store
3
- .idea/
4
- .yardoc/
5
- *.gem
6
- coverage/
7
- doc/
8
- node_modules/
9
- rdoc/
10
- vendor/
data/.gitleaksignore DELETED
@@ -1,2 +0,0 @@
1
- hardhat/hardhat.config.js:generic-api-key:38
2
- hardhat/hardhat.config.js:generic-api-key:42
data/.pdd DELETED
@@ -1,7 +0,0 @@
1
- --source=.
2
- --verbose
3
- --exclude target/**/*
4
- --exclude coverage/**/*
5
- --rule min-words:20
6
- --rule min-estimate:15
7
- --rule max-estimate:90
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,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:base"
5
- ]
6
- }
@@ -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