Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve polycli fund #167

Merged
merged 50 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
be118ea
chore: refactor flags
leovct Nov 23, 2023
e3a9d8d
chore: move cobra logic to `app`, use `RunE` and check flags in `PreR…
leovct Nov 23, 2023
c9b94b7
chore: nit
leovct Nov 23, 2023
608ea16
chore: rename file
leovct Nov 27, 2023
853e4d0
chore: update doc
leovct Nov 27, 2023
51d639d
Merge branch 'main' into chore/improve-fund
leovct Nov 27, 2023
68e438a
feat: add `Funder` contract
leovct Nov 27, 2023
c1cf6af
chore: update `Funder`
leovct Nov 27, 2023
221b297
feat: use `ethereum-go` lib instead of `web3`
leovct Nov 27, 2023
49c2676
chore: update makefiles
leovct Nov 27, 2023
a18b36e
Revert "chore: update makefiles"
leovct Nov 27, 2023
1912065
fix: makefile cmd
leovct Nov 27, 2023
54955b4
fix: same thing
leovct Nov 27, 2023
cb199bc
chore: `blockUntilSuccessful` clean up
leovct Nov 27, 2023
4ddfbac
chore: gen files and update ci
leovct Nov 27, 2023
0f98242
ci: remove `go-bindigns` workflow
leovct Nov 27, 2023
1469def
fix: ci
leovct Nov 27, 2023
d8bd722
ci: update dependencies
leovct Nov 27, 2023
855b685
fix: typo
leovct Nov 27, 2023
f3e1310
ci: nit
leovct Nov 27, 2023
34fcd47
ci: fix
leovct Nov 27, 2023
48d5861
chore: nit
leovct Nov 27, 2023
94e2bec
fix: funding issue
leovct Nov 27, 2023
d794ca2
chore: update doc
leovct Nov 27, 2023
c5e00bc
chore: revert ci changes
leovct Nov 27, 2023
5192515
chore: nit
leovct Nov 27, 2023
0c7945d
chore: lint
leovct Nov 27, 2023
ee92d4c
chore: nit
leovct Nov 27, 2023
b768767
ci: update ci job
leovct Nov 27, 2023
8136351
chore: revert makefile change
leovct Nov 27, 2023
01a9256
fix: makefile
leovct Nov 27, 2023
6b90732
doc: update usage
leovct Nov 27, 2023
a998f9c
chore: lint
leovct Nov 27, 2023
e1c2dbd
chore: specify funding amount in eth
leovct Nov 28, 2023
bc31249
chore: update doc
leovct Nov 28, 2023
b14f642
chore: convert `polycli loadtest --send-amount` flag from wei in hex …
leovct Nov 28, 2023
bb4dfb7
chore: nit
leovct Nov 28, 2023
8da1c61
chore: clean artifacts before generating new bindings
leovct Nov 28, 2023
77bd219
chore: nit
leovct Nov 28, 2023
63d4a77
chore: clean up, simplify and add hdderivation flag
leovct Nov 28, 2023
7633cec
chore: update doc
leovct Nov 28, 2023
fca308b
feat: fund input list of addresses
leovct Nov 28, 2023
0c5d3fc
chore: nits and doc
leovct Nov 28, 2023
33668c0
feat: derive addresses from mnemonic
leovct Nov 28, 2023
c7fb86a
Merge remote-tracking branch 'origin' into chore/improve-fund
leovct Nov 29, 2023
6eebaa3
Merge remote-tracking branch 'origin' into chore/improve-fund
leovct Nov 29, 2023
afe8988
chore: merge hd wallet changes
leovct Nov 29, 2023
ef2f628
chore: clean up
leovct Nov 29, 2023
ec3ecfc
Merge remote-tracking branch 'origin' into chore/improve-fund
leovct Nov 29, 2023
68a179a
chore: `make gen-doc`
leovct Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
Expand All @@ -26,12 +26,47 @@ jobs:
- name: Run all the linter tools against code
run: make lint

go-bindings:
name: Check go bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install abigen
run: |
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
abigen --version

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install dependencies
working-directory: contracts
run: forge install

- name: Generate go bindings
run: make gen-go-bindings
- name: Check if the go bindings are up to date
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Error: Go bindings are not up to date. Please run \`make gen-go-bindings\`."
git diff
exit 1
else
echo "✅ Go bindings are up to date."
fi

doc:
name: Check documentation
runs-on: ubuntu-latest
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
Expand All @@ -52,7 +87,7 @@ jobs:
runs-on: ubuntu-latest
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
Expand All @@ -67,7 +102,7 @@ jobs:
matrix:
tool: [geth, anvil]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
Expand Down
52 changes: 0 additions & 52 deletions .github/workflows/go-bindings.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install go
uses: actions/setup-go@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ coverage.out
.idea
*.swp
*.swo

wallets.json
37 changes: 11 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ help: ## Display this help.
$(BUILD_DIR): ## Create the build folder.
mkdir -p $(BUILD_DIR)

.PHONY: generate
generate: ## Generate protobuf stubs.
protoc --proto_path=proto --go_out=proto/gen/pb --go_opt=paths=source_relative $(wildcard proto/*.proto)

.PHONY: build
build: $(BUILD_DIR) ## Build go binary.
go build -ldflags "$(VERSION_FLAGS)" -o $(BUILD_DIR)/$(BIN_NAME) main.go
Expand Down Expand Up @@ -78,36 +74,25 @@ test: ## Run tests.

##@ Generation

.PHONY: gen
gen: gen-doc gen-proto gen-go-bindings gen-loadtest-modes gen-json-rpctypes ## Generate everything.

.PHONY: gen-doc
gen-doc: ## Generate documentation for `polycli`.
go run docutil/*.go

.PHONY: gen-loadtest-modes
gen-loadtest-modes: ## Generate loadtest modes strings.
cd cmd/loadtest && stringer -type=loadTestMode
.PHONY: gen-proto
gen-proto: ## Generate protobuf stubs.
protoc --proto_path=proto --go_out=proto/gen/pb --go_opt=paths=source_relative $(wildcard proto/*.proto)

.PHONY: gen-go-bindings
gen-go-bindings: ## Generate go bindings for smart contracts.
cd contracts && make gen-go-bindings

.PHONY: gen-loadtest-modes
gen-loadtest-modes: ## Generate loadtest modes strings.
cd cmd/loadtest && stringer -type=loadTestMode

.PHONY: gen-json-rpctypes
gen-json-rpctypes: ## Generate go bindings for smart contracts.
gen-json-rpctypes: ## Generate JSON rpc types.
./scripts/rpctypes.sh rpctypes/jsonschemas/

# Generate go binding.
# - $1: input_dir
# - $2: name
# - $3: pkg
# - $4: output_dir
define gen_go_binding
solc $1/$2.sol --abi --bin --output-dir $1 --overwrite --evm-version paris
abigen --abi $1/$2.abi --bin $1/$2.bin --pkg $3 --type $2 --out $4/$2.go
endef

# Example for the ERC20 contract.
# solc contracts/tokens/ERC20/ERC20.sol --abi --bin --output-dir contracts/tokens/ERC20 --overwrite
# abigen --abi contracts/tokens/ERC20/ERC20.abi --bin contracts/tokens/ERC20/ERC20.bin --pkg tokens --type ERC20 --out contracts/tokens/ERC20.go

# Example for the LoadTester contract.
# solc contracts/loadtester/LoadTester.sol --abi --bin --output-dir contracts/loadtester --overwrite
# abigen --abi contracts/loadtester/LoadTester.abi --bin contracts/loadtester/LoadTester.bin --pkg contracts --type LoadTester --out contracts/LoadTester.go
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Note: Do not modify this section! It is auto-generated by `cobra` using `make ge

- [polycli fork](doc/polycli_fork.md) - Take a forked block and walk up the chain to do analysis.

- [polycli fund](doc/polycli_fund.md) - Bulk fund many crypto wallets automatically.
- [polycli fund](doc/polycli_fund.md) - Bulk fund crypto wallets automatically.

- [polycli hash](doc/polycli_hash.md) - Provide common crypto hashing functions.

Expand Down
56 changes: 56 additions & 0 deletions bindings/funder/Funder.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
"type": "constructor",
"inputs": [
{
"name": "_amount",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "receive",
"stateMutability": "payable"
},
{
"type": "function",
"name": "amount",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "bulkFund",
"inputs": [
{
"name": "_addresses",
"type": "address[]",
"internalType": "address[]"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "fund",
"inputs": [
{
"name": "_address",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
}
]
1 change: 1 addition & 0 deletions bindings/funder/Funder.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x608060405234801561001057600080fd5b506040516105bf3803806105bf83398101604081905261002f91610069565b600081116100585760405162461bcd60e51b815260040161004f90610092565b60405180910390fd5b6000556100e4565b80515b92915050565b60006020828403121561007e5761007e600080fd5b600061008a8484610060565b949350505050565b6020808252810161006381602e81527f5468652066756e64696e6720616d6f756e742073686f756c642062652067726560208201526d61746572207468616e207a65726f60901b604082015260600190565b6104cc806100f36000396000f3fe6080604052600436106100385760003560e01c80632302440814610044578063a4626b8514610066578063aa8c217c1461008657600080fd5b3661003f57005b600080fd5b34801561005057600080fd5b5061006461005f366004610229565b6100b2565b005b34801561007257600080fd5b506100646100813660046102a4565b610185565b34801561009257600080fd5b5061009c60005481565b6040516100a991906102ec565b60405180910390f35b6001600160a01b0381166100e15760405162461bcd60e51b81526004016100d890610355565b60405180910390fd5b6000544710156101035760405162461bcd60e51b81526004016100d8906103ab565b6000816001600160a01b031660005460405161011e906103bb565b60006040518083038185875af1925050503d806000811461015b576040519150601f19603f3d011682016040523d82523d6000602084013e610160565b606091505b50509050806101815760405162461bcd60e51b81526004016100d8906103c3565b5050565b600054610193908290610405565b4710156101b25760405162461bcd60e51b81526004016100d890610470565b60005b818110156101ef576101e78383838181106101d2576101d2610480565b905060200201602081019061005f9190610229565b6001016101b5565b505050565b60006001600160a01b0382165b92915050565b610210816101f4565b811461021b57600080fd5b50565b803561020181610207565b60006020828403121561023e5761023e600080fd5b600061024a848461021e565b949350505050565b60008083601f84011261026757610267600080fd5b50813567ffffffffffffffff81111561028257610282600080fd5b60208301915083602082028301111561029d5761029d600080fd5b9250929050565b600080602083850312156102ba576102ba600080fd5b823567ffffffffffffffff8111156102d4576102d4600080fd5b6102e085828601610252565b92509250509250929050565b81815260208101610201565b603d81526000602082017f5468652066756e64656420616464726573732073686f756c642062652064696681527f666572656e74207468616e7420746865207a65726f2061646472657373000000602082015291505b5060400190565b60208082528101610201816102f8565b602981526000602082017f496e73756666696369656e7420636f6e74726163742062616c616e636520666f815268722066756e64696e6760b81b6020820152915061034e565b6020808252810161020181610365565b600081610201565b6020808252810161020181600e81526d119d5b991a5b99c819985a5b195960921b602082015260400190565b634e487b7160e01b600052601160045260246000fd5b81810280821583820485141761041d5761041d6103ef565b5092915050565b602f81526000602082017f496e73756666696369656e7420636f6e74726163742062616c616e636520666f81526e722062617463682066756e64696e6760881b6020820152915061034e565b6020808252810161020181610424565b634e487b7160e01b600052603260045260246000fdfea2646970667358221220f1e106cd2c49bd593de753bb15e330898ef011ddb84ba9fc2f05ff29961cacaa64736f6c63430008170033
Loading