-
Notifications
You must be signed in to change notification settings - Fork 190
/
querier.go
67 lines (58 loc) · 2.03 KB
/
querier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package types
import (
"encoding/json"
"fmt"
"github.com/cosmos/peggy/x/oracle"
)
// query endpoints supported by the oracle Querier
const (
QueryEthProphecy = "prophecies"
)
// QueryEthProphecyParams defines the params for the following queries:
// - 'custom/ethbridge/prophecies/'
type QueryEthProphecyParams struct {
EthereumChainID int `json:"ethereum_chain_id"`
BridgeContractAddress EthereumAddress `json:"bridge_registry_contract_address"`
Nonce int `json:"nonce"`
Symbol string `json:"symbol"`
TokenContractAddress EthereumAddress `json:"token_contract_address"`
EthereumSender EthereumAddress `json:"ethereum_sender"`
}
// NewQueryEthProphecyParams creates a new QueryEthProphecyParams
func NewQueryEthProphecyParams(
ethereumChainID int, bridgeContractAddress EthereumAddress, nonce int, symbol string,
tokenContractAddress EthereumAddress, ethereumSender EthereumAddress,
) QueryEthProphecyParams {
return QueryEthProphecyParams{
EthereumChainID: ethereumChainID,
BridgeContractAddress: bridgeContractAddress,
Nonce: nonce,
Symbol: symbol,
TokenContractAddress: tokenContractAddress,
EthereumSender: ethereumSender,
}
}
// QueryEthProphecyResponse defines the result payload for an eth prophecy query
type QueryEthProphecyResponse struct {
ID string `json:"id"`
Status oracle.Status `json:"status"`
Claims []EthBridgeClaim `json:"claims"`
}
// NewQueryEthProphecyResponse creates a new QueryEthProphecyResponse instance
func NewQueryEthProphecyResponse(
id string, status oracle.Status, claims []EthBridgeClaim,
) QueryEthProphecyResponse {
return QueryEthProphecyResponse{
ID: id,
Status: status,
Claims: claims,
}
}
// String implements fmt.Stringer interface
func (response QueryEthProphecyResponse) String() string {
prophecyJSON, err := json.Marshal(response)
if err != nil {
return fmt.Sprintf("Error marshalling json: %v", err)
}
return string(prophecyJSON)
}