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

[tss] support query signature #6

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f447207
fix getResult and add getSigning
nkitlabs May 15, 2024
22f119a
fix requester to support new oracleResult
nkitlabs May 15, 2024
b71f23d
fix example to support new oracleResult
nkitlabs May 15, 2024
9a644d6
fix SigningResult object
nkitlabs May 16, 2024
c1c60ed
add getSigningResult
nkitlabs May 16, 2024
5d91a1e
fix example
nkitlabs May 16, 2024
482d19e
fix wording
nkitlabs May 16, 2024
0f0f568
rename variables & functions
nkitlabs May 17, 2024
71e3a7a
fix example
nkitlabs May 17, 2024
a4cdd74
fix from comments
nkitlabs May 18, 2024
ef81145
remove unused param
nkitlabs May 18, 2024
bcdbad7
add logic redefine error types
nkitlabs May 18, 2024
cbeb30d
fix SendRequest
nkitlabs May 21, 2024
c8a8258
add getProof in client
nkitlabs May 22, 2024
33f7a33
add middleware to expose errOut channel
nkitlabs May 22, 2024
2ef93aa
add InsufficientExecuteGasHandler
nkitlabs May 22, 2024
bbea8c2
add new type handler and fix log
nkitlabs May 22, 2024
c5bb7e9
remove sizeCh params
nkitlabs May 22, 2024
66bb2c2
fix example
nkitlabs May 22, 2024
dacd4e5
fix types and changelog
nkitlabs May 23, 2024
700ced6
fix struct
nkitlabs May 23, 2024
fb2d675
fix type on client and fix test
nkitlabs May 27, 2024
7a4d5c9
fix go mod on example
nkitlabs May 27, 2024
b4248d1
change msg type to sdk.msg
May 27, 2024
88c5478
fix format
nkitlabs May 28, 2024
6f70e0b
add signing retry
May 28, 2024
21f6e79
add comment
May 28, 2024
85966f3
update feed type
May 28, 2024
1fc446d
fix getRequestProofByID
nkitlabs May 28, 2024
4058560
add msg
Jun 4, 2024
bfe3d5a
add event subscription
nkitlabs Jun 5, 2024
95a4b53
fix lint
nkitlabs Jun 5, 2024
e568920
add print signature msg
Jun 5, 2024
7d44d93
fix format
nkitlabs May 28, 2024
4cb031e
fix getRequestProofByID
nkitlabs May 28, 2024
f60c0c8
add event subscription
nkitlabs Jun 5, 2024
6710d89
fix lint
nkitlabs Jun 5, 2024
6b8c11a
Merge branch 'tss-support-signature' into tss-support-request-feeds-s…
nkitlabs Jun 6, 2024
0c13e34
fix lint and move helper function from client to requester
nkitlabs Jun 6, 2024
ab69a60
fix log and example
nkitlabs Jun 6, 2024
9a612c1
Merge pull request #7 from bandprotocol/tss-support-request-feeds-sig…
nkitlabs Jun 6, 2024
bd52970
add
Jun 7, 2024
3440bdc
fix example
nkitlabs Jun 10, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
examples/requester/configs/*
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

- (bump) use cosmos-sdk package v0.47.11
- (bump) replace github.com/tendermint/tendermint by github.com/cometbft/cometbft v0.37.5
- update example folder
- (example) update example folder
- (requester) remove channel size for initializing middleware, watcher and sender objects
- (requester) expose error channel on middleware object
- (requester) add logic for converting errors when receiving oracle request result on request watcher
- (requester) rearrange folder structure
- (requester) add a new type of retryHandler (retryHandler with condition)
- (client) add GetSigning and GetRequestProofByID

## [v1.0.1]

Expand Down
10 changes: 6 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package client

import (
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
ctypes "github.com/cometbft/cometbft/rpc/core/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand All @@ -11,10 +10,13 @@ import (
type Client interface {
GetAccount(account sdk.AccAddress) (client.Account, error)
GetTx(txHash string) (*sdk.TxResponse, error)
GetResult(id uint64) (*oracletypes.Result, error)
GetSignature(id uint64) ([]byte, error)
GetResult(id uint64) (*OracleResult, error)
GetSignature(id uint64) (*SigningResult, error)
GetBlockResult(height int64) (*ctypes.ResultBlockResults, error)
QueryRequestFailureReason(id uint64) (string, error)
GetBalance(account sdk.AccAddress) (uint64, error)
SendRequest(msg *oracletypes.MsgRequestData, gasPrice float64, key keyring.Record) (*sdk.TxResponse, error)
SendRequest(msg sdk.Msg, gasPrice float64, key keyring.Record) (*sdk.TxResponse, error)
GetRequestProofByID(reqID uint64) ([]byte, error)
Subscribe(name, query string) (*SubscriptionInfo, error)
Unsubscribe(name string) error
}
20 changes: 10 additions & 10 deletions client/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/bandprotocol/go-band-sdk/client

go 1.21

toolchain go1.21.6
go 1.22.3

require (
github.com/bandprotocol/chain/v2 v2.5.5-0.20240503145406-b6ed5a969335
github.com/bandprotocol/go-band-sdk/utils v1.0.1
github.com/cometbft/cometbft v0.37.5
github.com/cosmos/cosmos-sdk v0.47.11
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.4.0
)
Expand Down Expand Up @@ -57,7 +56,7 @@ require (
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
github.com/cosmos/iavl v0.20.1 // indirect
github.com/cosmos/ibc-go/v7 v7.4.0 // indirect
github.com/cosmos/ibc-go/v7 v7.5.0 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
Expand Down Expand Up @@ -139,7 +138,6 @@ require (
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
Expand Down Expand Up @@ -174,8 +172,7 @@ require (
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.23.0 // indirect
Expand All @@ -188,10 +185,10 @@ require (
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -201,6 +198,9 @@ require (
)

replace (
// TODO: for testing on local only; remove before merging
github.com/bandprotocol/chain/v2 => ../../private-chain

github.com/bandprotocol/go-band-sdk/utils => ../utils
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// cosmos-sdk v0.47.11 is incompatible with gogoproto 1.4.10
Expand Down
24 changes: 10 additions & 14 deletions client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX
github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U=
github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/bandprotocol/chain/v2 v2.5.5-0.20240503145406-b6ed5a969335 h1:nvczUzYXFYfgedisAjdZcDtfDXL9OZgSQRZ8VmWH804=
github.com/bandprotocol/chain/v2 v2.5.5-0.20240503145406-b6ed5a969335/go.mod h1:/1U8SLzMbg0gI6y3+Uwkqawk5juN+RssXuFOmmqGyUg=
github.com/bandprotocol/go-owasm v0.3.1 h1:L38qAEmb0KyTICHBHJaBoo6yy5+BlbOzQeQ+ioUV5Uw=
github.com/bandprotocol/go-owasm v0.3.1/go.mod h1:SAzGihlBl8eZDXA1dO2aeAZLm8J2QkNd+KvnA2Dw9Kg=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -354,8 +352,8 @@ github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoK
github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek=
github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg=
github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A=
github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M=
github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo=
github.com/cosmos/ibc-go/v7 v7.5.0 h1:tvPyuTsNqS1hZK69Wq7MZIvZIg8AblMkcnkAndtQet0=
github.com/cosmos/ibc-go/v7 v7.5.0/go.mod h1:ktFg5GvKOyrGCqTWtW7Grj5uweU4ZapxrNeVS1CLLbo=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw=
Expand Down Expand Up @@ -1054,14 +1052,12 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
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/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
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.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
Expand Down Expand Up @@ -1567,10 +1563,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s=
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0=
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae h1:AH34z6WAGVNkllnKs5raNq3yRq93VnjBG6rpfub/jYk=
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 h1:DujSIu+2tC9Ht0aPNA7jgj23Iq8Ewi5sgkQ++wdvonE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
Expand Down Expand Up @@ -1630,8 +1626,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
71 changes: 52 additions & 19 deletions client/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package client
import (
"context"
"fmt"
"strconv"
"time"

band "github.com/bandprotocol/chain/v2/app"
proofservice "github.com/bandprotocol/chain/v2/client/grpc/oracle/proof"
bandtsstypes "github.com/bandprotocol/chain/v2/x/bandtss/types"
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
tsstypes "github.com/bandprotocol/chain/v2/x/tss/types"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -18,6 +20,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/pkg/errors"
)

func NewClientCtx(chainID string) client.Context {
Expand All @@ -34,18 +37,13 @@ func NewClientCtx(chainID string) client.Context {
WithViper("requester")
}

func newRPCClient(addr, timeout string) (*rpchttp.HTTP, error) {
to, err := time.ParseDuration(timeout)
if err != nil {
return nil, err
}

func newRPCClient(addr string, timeout time.Duration) (*rpchttp.HTTP, error) {
httpClient, err := libclient.DefaultHTTPClient(addr)
if err != nil {
return nil, err
}

httpClient.Timeout = to
httpClient.Timeout = timeout
rpcClient, err := rpchttp.NewWithClient(addr, "/websocket", httpClient)
if err != nil {
return nil, err
Expand All @@ -58,7 +56,7 @@ func createTxFactory(chainID, gasPrice string, keyring keyring.Keyring) tx.Facto
return tx.Factory{}.
WithChainID(chainID).
WithTxConfig(band.MakeEncodingConfig().TxConfig).
WithGasAdjustment(1.1).
WithGasAdjustment(1.2).
WithGasPrices(gasPrice).
WithKeybase(keyring).
WithSignMode(signing.SignMode_SIGN_MODE_DIRECT)
Expand All @@ -77,21 +75,56 @@ func getRequest(clientCtx client.Context, id uint64) (*oracletypes.QueryRequestR
return queryClient.Request(context.Background(), &oracletypes.QueryRequestRequest{RequestId: id})
}

func getSigning(clientCtx client.Context, signingID uint64) (*bandtsstypes.QuerySigningResponse, error) {
queryClient := bandtsstypes.NewQueryClient(clientCtx)
return queryClient.Signing(context.Background(), &bandtsstypes.QuerySigningRequest{SigningId: signingID})
}

func estimateGas(clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) (uint64, error) {
_, gas, err := tx.CalculateGas(clientCtx, txf, msgs...)
return gas, err
}

func GetRequestID(events []sdk.StringEvent) (uint64, error) {
for _, event := range events {
if event.Type == oracletypes.EventTypeRequest {
rid, err := strconv.ParseUint(event.Attributes[0].Value, 10, 64)
if err != nil {
return 0, err
}
func convertSigningResultToSigningInfo(res *tsstypes.SigningResult) SigningInfo {
if res == nil {
return SigningInfo{}
}

evmSig := tsstypes.EVMSignature{}
if res.EVMSignature != nil {
evmSig = *res.EVMSignature
}

return SigningInfo{
SigningID: res.Signing.ID,
Message: res.Signing.Message,
PubKey: res.Signing.GroupPubKey,
PubNonce: res.Signing.GroupPubNonce,
Status: res.Signing.Status,
EVMSignature: evmSig,
}
}

func getRequestProof(clientCtx client.Context, reqID uint64) ([]byte, error) {
queryClient := proofservice.NewProofServer(clientCtx)
resp, err := queryClient.Proof(
context.Background(), &proofservice.QueryProofRequest{RequestId: reqID, Height: 0},
)
if err != nil {
return nil, errors.Wrapf(err, "failed to get proof")
}

return rid, nil
}
b, err := clientCtx.Client.Block(context.Background(), nil)
if err != nil {
return nil, errors.Wrapf(err, "failed to get current block")
}
return 0, fmt.Errorf("cannot find request id")
if resp.Height >= b.Block.Height {
return nil, fmt.Errorf(
"proof is not ready; current height: %d, proof height: %d",
b.Block.Height,
resp.Height,
)
}

return resp.Result.EvmProofBytes, nil
}
Loading
Loading