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

Waggle sign API server #11

Merged
merged 10 commits into from
Aug 24, 2023
Merged
204 changes: 128 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
2. Manage signing accounts
3. Send drop claims to the Moonstream Engine API

### Installation
## Installation

```
```bash
go install github.com/moonstream-to/waggle@latest
```

### Usage
## Usage as CLI

```
```bash
waggle -h
```

#### Manage accounts

You can import a signing account from an external wallet using its private key:

```
```bash
waggle accounts import -k <path at which to save keystore file>
```

Expand Down Expand Up @@ -63,34 +63,34 @@ claims (`batch.json` below):

```json
[
{
"dropId": "2",
"requestID": "5",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "6",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "7",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "8",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
}
{
"dropId": "2",
"requestID": "5",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "6",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "7",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "8",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
}
]
```

Expand All @@ -108,42 +108,42 @@ This results in a file that looks like this:

```json
[
{
"dropId": "2",
"requestID": "5",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "408...",
"signer": "<redacted Ethereum address>"
},
{
"dropId": "2",
"requestID": "6",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "667...",
"signer": "<redacted Ethereum address>"
},
{
"dropId": "2",
"requestID": "7",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "5c6...",
"signer": "<redacted Ethereum address>"
},
{
"dropId": "2",
"requestID": "8",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "85f...",
"signer": "<redacted Ethereum address>"
}
{
"dropId": "2",
"requestID": "5",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "408...",
"signer": "<redacted Ethereum address>"
},
{
"dropId": "2",
"requestID": "6",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "667...",
"signer": "<redacted Ethereum address>"
},
{
"dropId": "2",
"requestID": "7",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "5c6...",
"signer": "<redacted Ethereum address>"
},
{
"dropId": "2",
"requestID": "8",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000",
"signature": "85f...",
"signer": "<redacted Ethereum address>"
}
]
```

Expand All @@ -160,7 +160,7 @@ You can generate an access token at https://moonstream.to/app

Then:

```
```bash
waggle moonstream drop \
--contract-id a035f3f8-7301-45b7-940a-109585419774 \
--infile signed_batch.json
Expand All @@ -183,10 +183,9 @@ https://engineapi.moonstream.to/contracts/requests?contract_id=$CONTRACT_ID&call
Here, `$CONTRACT_ID` should be the same contract ID you used in `waggle moonstream drop`. `$USER_ADDRESS`
is the user's Ethereum account address.


#### Get claim requests from Bugout journal

```
```bash
waggle sign dropper pull \
--cursor <cursor name> \
-j <Bugout Journal ID> \
Expand All @@ -196,7 +195,7 @@ waggle sign dropper pull \
This expects a `BUGOUT_ACCESS_TOKEN` environment variable to be set. You can generate an access token
at https://bugout.dev/account/tokens. Once you have generated a token, set it in your shell session using:

```
```bash
export BUGOUT_ACCESS_TOKEN=<token>
```

Expand All @@ -215,7 +214,7 @@ dropId,requestID,claimant,blockDeadline,amount,signer,signature
You can sign this using the `waggle sign dropper batch command` by passing the CSV file as the `--infile`
argument and setting the `--csv` flag:

```
```bash
waggle sign dropper batch -k signer.json \
--chain-id 80001 \
--dropper 0x4ec36E288E1b5d6914851a141cb041152Cf95328 \
Expand All @@ -227,13 +226,66 @@ waggle sign dropper batch -k signer.json \

### Build

```
```bash
go build ./...
./waggle -h
```

### Test

```
```bash
go test ./... -v
```

## Waggle API Server Extension

The Waggle API Server Extension is designed to offer a RESTfull API access for `waggle` functionalities. It builds over existing waggle features, enhancing operational efficiency and automating routine tasks.

Executes `sign dropper` functionalities such as certifying drop claims for Dropper v0.2.0 by sending POST requests:

```json
{
"chain_id": 80001,
"dropper": "0x4ec36E288E1b5d6914851a141cb041152Cf95328",
"signer": "0x629c51488a18fc75f4b8993743f3c132316951c9",
"requests": [
{
"dropId": "2",
"requestID": "5",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
},
{
"dropId": "2",
"requestID": "6",
"claimant": "0x000000000000000000000000000000000000dEaD",
"blockDeadline": "40000000",
"amount": "3000000000000000000"
}
]
}
```

With configuration file you can specify list of signers and sign drops with chosen one. Example of server configuration file `config.json`:

```json
[
{
"keyfile_path": "dev.json",
"keyfile_password_path": "password.txt"
}
]
```

Config also could be generated with command:

```bash
waggle server configure --keyfile dev.json --outfile config.json
```

Run server:

```bash
waggle server run --host 0.0.0.0 --config config.json
```
Loading
Loading