Skip to content

Commit

Permalink
feat: upgrade starport to v0.19.5 (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Shahbaz Nazir <[email protected]>
  • Loading branch information
helder-moreira and Shahbaz Nazir authored Mar 25, 2022
1 parent 8558b8e commit 7bdcccd
Show file tree
Hide file tree
Showing 7 changed files with 769 additions and 160 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Test

on:
pull_request:
push:
branches:
- master
- develop
on: [push]

jobs:
test:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM golang:alpine AS builder
WORKDIR /src/app/
RUN apk add git
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Since the faucet only uses the CLI binary, it is compatible with practically any
[cosmos-sdk](https://github.com/cosmos/cosmos-sdk) even if different types of keys are used (such as in
[ethermint](https://github.com/cosmos/ethermint) for example).


## Installation

### Using cURL
Expand All @@ -30,7 +29,7 @@ $ curl https://get.starport.network/faucet! | bash

### Use docker image

Use docker image `ghcr.io/tendermint/faucet`. You can use it in a Kubernetes pod with
Use docker image `ghcr.io/tendermint/faucet`. You can use it in a Kubernetes pod with
[shareProcessNamespace](https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/#configure-a-pod)
or mount the chain binary using docker:

Expand All @@ -39,6 +38,7 @@ $ docker run -it -v ~/go/bin/gaiad:/usr/local/bin/gaiad ghcr.io/tendermint/fauce
```

### From Source

You can build the faucet with:

```bash
Expand All @@ -58,21 +58,21 @@ $ make install
You can configure the faucet either using command line flags or environment variables. The following table
shows the available configuration options and respective defaults:

| flag | env | description | default |
|------------------ |------------------ |-------------------------------------------------------------- |------------------------------ |
| port | PORT | tcp port where faucet will be listening for requests | 8000 |
| account-name | ACCOUNT_NAME | name of the account to be used by the faucet | faucet |
| mnemonic | MNEMONIC | mnemonic for restoring an account | |
| keyring-password | KEYRING_PASSWORD | password for accessing keyring | |
| cli-name | CLI_NAME | name of the cli executable | gaiad |
| denom | DENOM | denomination of the coins sent by default (comma separated) | uatom |
| credit-amount | CREDIT_AMOUNT | amount to credit in each request | 10000000 |
| max-credit | MAX_CREDIT | maximum credit per account | 100000000 |
| sdk-version | SDK_VERSION | version of sdk (launchpad or stargate) | stargate |
| node | NODE | address of tendermint RPC endpoint for this chain | |
| keyring-backend | KEYRING_BACKEND | keyring backend to be used | |
| legacy-send | LEGACY_SEND | whether to use legacy send command | false |
| | | | |
| flag | env | description | default |
|---------------------|-------------------|-------------------------------------------------------------- |-----------|
| port | PORT | tcp port where faucet will be listening for requests | 8000 |
| account-name | ACCOUNT_NAME | name of the account to be used by the faucet | faucet |
| mnemonic | MNEMONIC | mnemonic for restoring an account | |
| keyring-password | KEYRING_PASSWORD | password for accessing keyring | |
| cli-name | DENOMS | denomination of the coins sent by default (comma separated) | uatom |
| credit-amount | CREDIT_AMOUNT | amount to credit in each request | 10000000 |
| max-credit | MAX_CREDIT | maximum credit per account | 100000000 |
| sdk-version | SDK_VERSION | version of sdk (launchpad or stargate) | stargate |
| node | NODE | address of tendermint RPC endpoint for this chain | |
| keyring-backend | KEYRING_BACKEND | keyring backend to be used | |
| legacy-send | LEGACY_SEND | whether to use legacy send command | false |
| coin-type | COIN_TYPE | registered coin type number for HD derivation (BIP-0044) | 118 |
| | | | |

### [gaia](https://github.com/cosmos/gaia) example

Expand Down Expand Up @@ -144,4 +144,4 @@ For requesting specific coins, use:
```bash
$ curl -X POST -d '{"address": "cosmos1kd63kkhtswlh5vcx5nd26fjmr9av74yd4sf8ve", "coins": ["10uatom", "20ueth"]}' http://localhost:8000
{"transfers":[{"coin":"10uatom","status":"ok"}, {"coin":"20ueth","status":"ok"}]}
```
```
9 changes: 7 additions & 2 deletions cmd/faucet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
maxCredit uint64
nodeAddress string
legacySendCmd bool
coinType string
)

func init() {
Expand All @@ -37,8 +38,8 @@ func init() {
"keyring backend to be used",
)
flag.StringVar(&sdkVersion, "sdk-version",
environ.GetString("SDK_VERSION", "stargate"),
"version of sdk (launchpad or stargate)",
environ.GetString("SDK_VERSION", "latest"),
"version of sdk (launchpad, stargate-40, stargate-44 or latest)",
)
flag.StringVar(&keyName, "account-name",
environ.GetString("ACCOUNT_NAME", cosmosfaucet.DefaultAccountName),
Expand Down Expand Up @@ -77,4 +78,8 @@ func init() {
environ.GetBool("LEGACY_SEND", false),
"whether to use legacy send command",
)
flag.StringVar(&coinType, "coin-type",
environ.GetString("COIN_TYPE", "118"),
"registered coin type number for HD derivation (BIP-0044), defaults from (satoshilabs/SLIP-0044)",
)
}
19 changes: 14 additions & 5 deletions cmd/faucet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ func main() {
ccoptions = append(ccoptions, chaincmd.WithLegacySendCommand())
}

if sdkVersion == string(cosmosver.Stargate) {
switch sdkVersion {
case "stargate-44":
ccoptions = append(ccoptions,
chaincmd.WithVersion(cosmosver.StargateZeroFourtyAndAbove),
chaincmd.WithVersion(cosmosver.StargateFortyFourVersion),
)
} else {
case "stargate-40":
ccoptions = append(ccoptions,
chaincmd.WithVersion(cosmosver.LaunchpadAny),
chaincmd.WithVersion(cosmosver.StargateFortyVersion),
)
case "launchpad":
ccoptions = append(ccoptions,
chaincmd.WithVersion(cosmosver.MaxLaunchpadVersion),
chaincmd.WithLaunchpadCLI(appCli),
)
default:
ccoptions = append(ccoptions,
chaincmd.WithVersion(cosmosver.Latest),
)
}

cr, err := chaincmdrunner.New(context.Background(), chaincmd.New(appCli, ccoptions...))
Expand All @@ -57,7 +66,7 @@ func main() {
faucetOptions[i] = cosmosfaucet.Coin(creditAmount, maxCredit, coin)
}

faucetOptions = append(faucetOptions, cosmosfaucet.Account(keyName, keyMnemonic))
faucetOptions = append(faucetOptions, cosmosfaucet.Account(keyName, keyMnemonic, coinType))

faucet, err := cosmosfaucet.New(context.Background(), cr, faucetOptions...)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/tendermint/faucet
go 1.16

require (
github.com/sirupsen/logrus v1.8.0
github.com/tendermint/starport v0.17.3
github.com/sirupsen/logrus v1.8.1
github.com/tendermint/starport v0.19.5
)

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Loading

0 comments on commit 7bdcccd

Please sign in to comment.