From 275a3fcf257081f6a0dd067f65eb1fb0aa16d8b2 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 21 May 2024 00:18:18 +0800 Subject: [PATCH 1/3] add linter --- .github/workflows/lint.yml | 26 ++++++++++++++++++++++++++ .golangci.yml | 0 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c3c106f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +name: golangci-lint +on: + push: + branches: + - main + - master + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e69de29 From 2a25cf107dcc7b4e1ca25c9b9778fd2d9e83c3c4 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 21 May 2024 00:38:45 +0800 Subject: [PATCH 2/3] add address prefix to config --- go.mod | 1 - go.sum | 9 ++------- internal/types/types.go | 1 + 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 060d8cf..c1e664b 100644 --- a/go.mod +++ b/go.mod @@ -105,7 +105,6 @@ require ( github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.27.0 golang.org/x/crypto v0.21.0 // indirect diff --git a/go.sum b/go.sum index 447287d..cb8bccf 100644 --- a/go.sum +++ b/go.sum @@ -50,9 +50,6 @@ github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJ github.com/btcsuite/btcd/btcutil v1.1.2/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -457,11 +454,9 @@ github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1U go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= diff --git a/internal/types/types.go b/internal/types/types.go index 5c14e25..6e8c070 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -6,6 +6,7 @@ import ( type Config struct { GRPCServerAddress string `toml:"grpc_server_address"` + AddressPrefix string `toml:"address_prefix"` RPCServerAddress string `toml:"rpc_server_address"` CoinID string `toml:"coin_id"` } From 64bbcb8845ec5100baec3d049370995adeb9fc4f Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 21 May 2024 01:31:39 +0800 Subject: [PATCH 3/3] use a fixed address prefix --- internal/chains/airdrop.go | 2 +- internal/utils/utils.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/chains/airdrop.go b/internal/chains/airdrop.go index f005d9c..3cbe576 100644 --- a/internal/chains/airdrop.go +++ b/internal/chains/airdrop.go @@ -117,7 +117,7 @@ func Airdrop(stakingClient stakingtypes.QueryClient, configPath, blockHeight str } for address, amount := range airdropMap { // Skip addresses that receive less than 1 token - if amount == 0 { + if amount <= 1000000 { // 1 token = 100000 continue } checkAmount += amount diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 1e6b9da..23172a7 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -44,7 +44,7 @@ func ConvertBech32Address(dstChainAddress, srcDenom string) (string, error) { if err != nil { return "", fmt.Errorf("error decoding address: %w", err) } - newBech32DelAddr, err := bech32.ConvertAndEncode(srcDenom, bz) + newBech32DelAddr, err := bech32.ConvertAndEncode("pica", bz) if err != nil { return "", fmt.Errorf("error converting address: %w", err) }