-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from godwokenrises/feat-batch-workflows
feat: batch deposit&withdraw workflow
- Loading branch information
Showing
63 changed files
with
14,742 additions
and
2,202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Batch Deposit & Withdraw On Alphanet_v1 | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 */4 * * *' # runs every 4 hour | ||
|
||
jobs: | ||
check-secrets: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'godwokenrises/godwoken-tests' | ||
outputs: | ||
available: ${{ steps.check.outputs.available }} | ||
steps: | ||
- id: check | ||
env: | ||
KEY1: '${{ secrets.GODWOKEN_TEST_PRIVATE_KEY }}' | ||
if: ${{ env.KEY1 != '' }} | ||
run: echo "::set-output name=available::true" | ||
|
||
batch-deposit-and-withdraw: | ||
runs-on: ubuntu-latest | ||
needs: check-secrets | ||
if: needs.check-secrets.outputs.available | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
- uses: actions/github-script@v6 | ||
id: start-time | ||
with: | ||
script: return Date.now() | ||
result-encoding: string | ||
|
||
- name: Print start-time | ||
run: echo "${{ steps.start-time.outputs.result }}" | ||
|
||
- name: Setup Light-Godwoken-CLI | ||
working-directory: scripts/light-godwoken-cli | ||
run: ./init.sh | ||
|
||
- name: Run batch-deposit-withdraw | ||
working-directory: scripts/light-godwoken-cli | ||
run: | | ||
lgc batch-deposit-withdraw \ | ||
--private-key ${{ secrets.GODWOKEN_TEST_PRIVATE_KEY }} \ | ||
--start-time ${{ steps.start-time.outputs.result }} \ | ||
--duration 240 \ | ||
--network alphanet_v1 | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: batch-deposit-withdraw | ||
path: ${{ github.workspace }}/scripts/light-godwoken-cli/artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Batch Prepare For Derived Accounts | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
prepare-sudt: | ||
type: boolean | ||
required: true | ||
default: false | ||
description: "Prepare sUDT for derived accounts (optional)" | ||
schedule: | ||
- cron: '0 22 * * 0,2,4' # at 06:00 AM on Monday & Wednesday & Friday (UTC+8) | ||
|
||
jobs: | ||
check-secrets: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'godwokenrises/godwoken-tests' | ||
outputs: | ||
available: ${{ steps.check.outputs.available }} | ||
steps: | ||
- id: check | ||
env: | ||
KEY1: '${{ secrets.GODWOKEN_TEST_PRIVATE_KEY }}' | ||
if: ${{ env.KEY1 != '' }} | ||
run: echo "::set-output name=available::true" | ||
|
||
batch-claim: | ||
needs: check-secrets | ||
if: needs.check-secrets.outputs.available | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
command: [ batch-claim-l1, batch-claim-l2 ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'npm' | ||
cache-dependency-path: scripts/account-faucet/package-lock.json | ||
|
||
- name: Setup Account-Faucet | ||
working-directory: scripts/account-faucet | ||
run: npm i && npm run build | ||
|
||
- name: Claim for derived accounts | ||
working-directory: scripts/account-faucet | ||
run: | | ||
account-faucet ${{ matrix.command }} \ | ||
--private-key ${{ secrets.GODWOKEN_TEST_PRIVATE_KEY }} \ | ||
--network alphanet_v1 | ||
batch-prepare-sudt: | ||
runs-on: ubuntu-latest | ||
needs: [check-secrets, batch-claim] | ||
if: needs.check-secrets.outputs.available && ${{ github.event.inputs.prepare-sudt }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
- name: Setup Light-Godwoken-CLI | ||
working-directory: scripts/light-godwoken-cli | ||
run: ./init.sh | ||
|
||
- name: Run batch-prepare-sudt | ||
working-directory: scripts/light-godwoken-cli | ||
run: | | ||
lgc batch-prepare-sudt \ | ||
--private-key ${{ secrets.GODWOKEN_TEST_PRIVATE_KEY }} \ | ||
--network alphanet_v1 | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: batch-prepare-sudt | ||
path: ${{ github.workspace }}/scripts/light-godwoken-cli/artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule light-godwoken
updated
from 855d30 to b7b087
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,81 @@ | ||
# Account-Faucet | ||
|
||
## What is this? | ||
This is Account-Faucet, a CLI tool to claim faucet for your Godwoken layer 2 accounts. | ||
|
||
## Why should I use it? | ||
Originally, when you need to claim faucet to your Godwoken layer 2 wallet, you need to go through all these steps: | ||
Originally, when you're claiming faucet for your Godwoken L2 account, you need to go through the following steps: | ||
1. Go to [Faucet](https://faucet.nervos.org) page and claim faucet to your CKB account | ||
2. Go to [Godwoken Bridge](https://testnet.bridge.godwoken.io/) and deposit CKB to your Godwoken layer 2 account | ||
|
||
The steps above are fairly simple, but not so easy if you do it manually, every day. | ||
With this CLI tool, you can actually finish the entire process in one command, which can save you a lot of time. | ||
2. Go to [Godwoken Bridge](https://testnet.bridge.godwoken.io/) and deposit CKB to your Godwoken L2 account | ||
|
||
All you need to prepare is your `ETH address`, or your `CKB private key`. | ||
With this CLI tool, you can actually finish the entire process in one command, which should save you a lot of time. And this is Account-Faucet, a CLI tool to claim faucet for your Godwoken L2 accounts. | ||
|
||
## Ready | ||
1. Go to `Account-Faucet` folder in `Godwoken-Tests`: | ||
## Setup environment | ||
Go to `Account-Faucet` folder in `Godwoken-Tests` and set up the tool: | ||
```bash | ||
# Position: godwoken-tests/ | ||
$ cd scripts/account-faucet | ||
$ npm install && npm run build | ||
``` | ||
2. Install dependencies: | ||
|
||
## Claim faucet for L2 | ||
If you want to claim faucet directly to your L2 account, you can try the `claim-l2` command. | ||
The `claim-l2` command calculates your `L2 Deposit Address`, then automatically claim faucet to the address, so you don't waste extra fee or time doing them all manually. | ||
|
||
### Claim with ETH Address (Recommended) or with Private Key | ||
You can use `-e` or `--eth-address` to claim faucet for L2: | ||
```bash | ||
$ npm install | ||
$ account-faucet claim-l2 --eth-address <ETH_ADDRESS> | ||
``` | ||
Or if you only have a private key on hand, you can use `-p` or `--private-key` option to claim faucet for your L2 account: | ||
```bash | ||
$ account-faucet claim-l2 --private-key <PRIVATE_KEY> | ||
``` | ||
|
||
## Claim faucet | ||
|
||
### Claim with ETH Address | ||
If you're more familiar with your `ETH address`, we recommend you to use this command: | ||
### Claim on different networks | ||
You can use `-n` or `--network` option to claim faucet on different network: | ||
```bash | ||
$ npm run faucet -- claim -e <ETH_ADDRESS> | ||
$ account-faucet claim-l2 --private-key <PRIVATE_KEY> --network <NETWORK> | ||
``` | ||
Right now the tool supports these networks: | ||
- testnet_v1 | ||
- alphanet_v1 | ||
|
||
### Claim with CKB Private Key | ||
If you prefer to claim faucet with your `CKB Layer 1 Private Key`: | ||
## Claim faucet for L1 | ||
If you only want to claim faucet to your L1 account instead of L2 account, you can try the `claim-l1` command. | ||
The `claim-l1` command takes either `--private-key` or `--ckb-address`, and will automatically claim faucet to your L1 account, so you don't need to do it by yourself. | ||
|
||
### Claim with Private Key or CKB Address | ||
You can use `-p` or `--private-key` to claim faucet for L1: | ||
```bash | ||
$ account-faucet claim-l1 -p <PRIVATE_KEY> | ||
``` | ||
Or you can use `-c` or `--ckb-address`: | ||
```bash | ||
$ npm run faucet -- claim -p <CKB_PRIVATE_KEY> | ||
$ account-faucet claim-l1 -c <CKB_ADDRESS> | ||
``` | ||
|
||
### Claim faucet on different networks | ||
### Claim on different networks | ||
You can use `-n` or `--network` option to claim faucet on different network: | ||
```bash | ||
$ $ npm run faucet -- claim -p <CKB_PRIVATE_KEY> -n <NETWORK> | ||
$ account-faucet claim-l1 --private-key <PRIVATE_KEY> --network <NETWORK> | ||
``` | ||
|
||
One thing to be noted, `mainnet_v1` is not available for the `--network` option. | ||
|
||
## Get Layer2 Deposit Address | ||
## Get L2 Deposit Address | ||
|
||
### Calculate with ETH Address or CKB Private Key | ||
This is an util command to calculate the Layer2 Deposit Address. | ||
It's a very similar command to the `claim` command, you can pass a ETH address: | ||
This is an util command to calculate the `L2 Deposit Address` of your account. | ||
|
||
L2 Deposit Address is an CKB address which if you transfer capacity to the specific address, Godwoken will take it away and then give you capacity on L2. The process of transferring capacity to a L2 Deposit Address is what we called "Deposit". | ||
|
||
It's a very similar command to the `claim-l1` or `claim-l2` command, you can either pass an ETH address (`-e` or `--eth-address`): | ||
```bash | ||
$ npm run faucet -- get-l2-address -e <ETH_ADDRESS> | ||
$ account-faucet get-l2-address --eth-address <ETH_ADDRESS> | ||
``` | ||
Or pass a CKB Private Key: | ||
Or pass a Private Key (`-p` or `--private-key`): | ||
```bash | ||
$ npm run faucet -- get-l2-address -p <CKB_PRIVATE_KEY> | ||
$ account-faucet get-l2-address --private-key <PRIVATE_KEY> | ||
``` | ||
|
||
### Address on different networks | ||
You can use `-n` or `--network` option to calculate the Layer2 Deposit Address on different network: | ||
You can use `-n` or `--network` option to calculate the `L2 Deposit Address` on different network: | ||
```bash | ||
$ npm run faucet -- get-l2-address -e <ETH_ADDRESS> -n <NETWORK> | ||
$ account-faucet get-l2-address --eth-address <ETH_ADDRESS> --network <NETWORK> | ||
``` | ||
|
||
Right now the supported networks are: | ||
- testnet_v1 | ||
- alphanet_v1 |
File renamed without changes.
Oops, something went wrong.