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

fix: check response before unmarshaling #46

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 1 addition & 36 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: docker_publish
on:
push:
branches:
- 'chore/ci-publish-docker'
- 'main'
tags:
- '*'
Expand All @@ -28,38 +27,4 @@ jobs:
secrets: inherit
with:
publish: true
repoName: finality-gadget

test_finality_provider:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Clone finality-provider repository
run: |
current_hash=$(git rev-parse HEAD)
remote_url=$(git remote get-url origin)
if [[ $remote_url == https://* ]]; then
# For HTTPS URLs
repo_path=$(echo $remote_url | sed -E 's|https://github.com/(.+)(\.git)*|\1|')
else
# For SSH URLs
repo_path=$(echo $remote_url | sed -E 's/.*:(.+)\.git/\1/')
fi
fp_version=$(go list -m github.com/$repo_path@$current_hash)

git clone https://github.com/babylonlabs-io/finality-provider
cd finality-provider
git checkout base/consumer-chain-support
sed -i "s|github\.com\/babylonlabs-io\/finality-gadget.*|$fp_version|g" go.mod
go mod tidy

- name: Run op e2e tests
run: |
export PATH=${PATH}:$(go env GOPATH)/bin
cd finality-provider
make op-e2e-devnet
make test-e2e-op
repoName: finality-gadget
9 changes: 7 additions & 2 deletions cwclient/cwclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (cwClient *CosmWasmClient) QueryListOfVotedFinalityProviders(
if err != nil {
return nil, err
}
// BlockVoters's return type is Option<HashSet<String>> in contract
// Check empty response before unmarshaling
if len(resp.Data) == 0 {
return nil, nil
}

votedFpPkHexList := &[]string{}
if err := json.Unmarshal(resp.Data, votedFpPkHexList); err != nil {
Expand Down Expand Up @@ -114,9 +119,9 @@ func createBlockVotersQueryData(queryParams *types.Block) ([]byte, error) {
}

type contractConfigResponse struct {
ConsumerId string `json:"consumer_id"`
ActivatedHeight uint64 `json:"activated_height"`
ConsumerId string `json:"consumer_id"`
}

type ContractQueryMsgs struct {
Config *contractConfig `json:"config,omitempty"`
BlockVoters *blockVotersQuery `json:"block_voters,omitempty"`
Expand Down
Loading