mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
[lib] Use build and broadcast tx from cosmos-sdk (#189)
* [tests] Avoid potential data races * Revert "[lib] Switch from RPC (REST) to gRPC (#183)" This reverts commit db5f4fb3fe6899bcfdadf3471f826a6a97035440. * [lib] DRY: Use build and broadcast tx from cosmos-sdk This is in preparation for: https://github.com/rddl-network/issues/issues/46 Without this patch broadcasting a transaction in "offline mode" (setting the sequence number manually) would not work consistently. Every so often the endpoint would report back, that it got an unexpected sequence number. Executing the request with the same sequence number couple of seconds later would be successful. I decided to better use the same source code, that the CLI uses, because I know that offline mode works there. Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
c40394e8a8
commit
ec6bd1f755
@ -51,6 +51,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {
|
||||
// Initialize library
|
||||
libConfig := lib.GetConfig()
|
||||
libConfig.SetEncodingConfig(encodingConfig)
|
||||
libConfig.SetBech32PrefixForAccount("plmnt")
|
||||
initClientCtx := client.Context{}.
|
||||
WithCodec(encodingConfig.Marshaler).
|
||||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
||||
|
@ -13,7 +13,6 @@ For debugging purposes we print the transaction that we send as JSON.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
@ -21,16 +20,16 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/planetmint/planetmint-go/app"
|
||||
"github.com/planetmint/planetmint-go/lib"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func main() {
|
||||
goCtx := context.Background()
|
||||
encodingConfig := app.MakeEncodingConfig()
|
||||
|
||||
libConfig := lib.GetConfig()
|
||||
libConfig.SetEncodingConfig(encodingConfig)
|
||||
libConfig.SetGRPCEndpoint("testnet-grpc.rddl.io:443")
|
||||
libConfig.SetGRPCTLSCert("/etc/ssl/certs/ca-certificates.crt")
|
||||
libConfig.SetAPIEndpoint("https://testnet-api.rddl.io")
|
||||
libConfig.SetRPCEndpoint("https://testnet-rpc.rddl.io:443")
|
||||
|
||||
addr0 := sdk.MustAccAddressFromBech32("plmnt168z8fyyzap0nw75d4atv9ucr2ye60d57dzlzaf")
|
||||
addr1 := sdk.MustAccAddressFromBech32("plmnt1vklujvmr9hsk9zwpquk4waecr2u5vcyjd8vgm8")
|
||||
@ -42,19 +41,14 @@ func main() {
|
||||
msg2 := banktypes.NewMsgSend(addr0, addr2, coin)
|
||||
msg3 := banktypes.NewMsgSend(addr0, addr3, coin)
|
||||
|
||||
txBytes, txJSON, err := lib.BuildAndSignTx(goCtx, addr0, msg1, msg2, msg3)
|
||||
ctx := context.Background()
|
||||
txJSON, err := lib.BuildUnsignedTx(ctx, addr0, msg1, msg2, msg3)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(txJSON)
|
||||
|
||||
// Optional
|
||||
_, err = lib.SimulateTx(goCtx, txBytes)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = lib.BroadcastTx(goCtx, txBytes)
|
||||
_, err = lib.BroadcastTx(ctx, addr0, msg1, msg2, msg3)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -107,20 +101,7 @@ $ go run main.go|jq
|
||||
"non_critical_extension_options": []
|
||||
},
|
||||
"auth_info": {
|
||||
"signer_infos": [
|
||||
{
|
||||
"public_key": {
|
||||
"@type": "/cosmos.crypto.secp256k1.PubKey",
|
||||
"key": "AzthjTLaH+NCBBRH4NImcxSa9Ma59TJ0ntQE9S5TJ/wb"
|
||||
},
|
||||
"mode_info": {
|
||||
"single": {
|
||||
"mode": "SIGN_MODE_DIRECT"
|
||||
}
|
||||
},
|
||||
"sequence": "6"
|
||||
}
|
||||
],
|
||||
"signer_infos": [],
|
||||
"fee": {
|
||||
"amount": [
|
||||
{
|
||||
@ -134,8 +115,6 @@ $ go run main.go|jq
|
||||
},
|
||||
"tip": null
|
||||
},
|
||||
"signatures": [
|
||||
"iolwpJtcFPKshQWMfgvYO+EMSavdq0auicWZCNI46AIBWH6aPEca7esfqdv2m6VE4hCHzxCNx58wnfVNnutEEQ=="
|
||||
]
|
||||
"signatures": []
|
||||
}
|
||||
```
|
||||
|
@ -1,26 +1,19 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/planetmint/planetmint-go/lib/params"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
// Config defines library top level configuration.
|
||||
type Config struct {
|
||||
APIEndpoint string `json:"api-endpoint" mapstructure:"api-endpoint"`
|
||||
ChainID string `json:"chain-id" mapstructure:"chain-id"`
|
||||
EncodingConfig params.EncodingConfig `json:"encoding-config" mapstructure:"encoding-config"`
|
||||
GRPCEndpoint string `json:"grpc-endpoint" mapstructure:"grpc-endpoint"`
|
||||
GRPCTLSCert string `json:"grpc-tls-cert" mapstructure:"grpc-tls-cert"` //nolint: tagliatelle // json(kebab): got 'grpc-tls-cert' want 'grpctls-cert'
|
||||
RootDir string `json:"root-dir" mapstructure:"root-dir"`
|
||||
RPCEndpoint string `json:"rpc-endpoint" mapstructure:"rpc-endpoint"`
|
||||
}
|
||||
|
||||
// lib wide global singleton
|
||||
@ -33,11 +26,11 @@ var (
|
||||
// DefaultConfig returns library default configuration.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
APIEndpoint: "http://127.0.0.1:1317",
|
||||
ChainID: "planetmint-testnet-1",
|
||||
EncodingConfig: params.EncodingConfig{},
|
||||
GRPCEndpoint: "127.0.0.1:9090",
|
||||
GRPCTLSCert: "",
|
||||
RootDir: "~/.planetmint-go/",
|
||||
RPCEndpoint: "http://127.0.0.1:26657",
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,29 +44,10 @@ func GetConfig() *Config {
|
||||
return libConfig
|
||||
}
|
||||
|
||||
func (config *Config) GetGRPCConn() (grpcConn *grpc.ClientConn, err error) {
|
||||
creds := insecure.NewCredentials()
|
||||
// Configure TLS for remote connection.
|
||||
if !strings.Contains(config.GRPCEndpoint, "127.0.0.1") && !strings.Contains(config.GRPCEndpoint, "localhost") {
|
||||
cert, err := os.ReadFile(config.GRPCTLSCert)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
certPool := x509.NewCertPool()
|
||||
ok := certPool.AppendCertsFromPEM(cert)
|
||||
if !ok {
|
||||
return nil, err
|
||||
}
|
||||
tlsConfig := &tls.Config{
|
||||
RootCAs: certPool,
|
||||
}
|
||||
creds = credentials.NewTLS(tlsConfig)
|
||||
}
|
||||
grpcConn, err = grpc.Dial(
|
||||
config.GRPCEndpoint,
|
||||
grpc.WithTransportCredentials(creds),
|
||||
)
|
||||
return
|
||||
// SetAPIEndpoint sets the API endpoint to send requests to.
|
||||
func (config *Config) SetAPIEndpoint(apiEndpoint string) *Config {
|
||||
config.APIEndpoint = apiEndpoint
|
||||
return config
|
||||
}
|
||||
|
||||
// SetBech32PrefixForAccount sets the bech32 account prefix.
|
||||
@ -88,18 +62,6 @@ func (config *Config) SetEncodingConfig(encodingConfig params.EncodingConfig) *C
|
||||
return config
|
||||
}
|
||||
|
||||
// SetGRPCEndpoint sets the gRPC endpoint to send requests to.
|
||||
func (config *Config) SetGRPCEndpoint(grpcEndpoint string) *Config {
|
||||
config.GRPCEndpoint = grpcEndpoint
|
||||
return config
|
||||
}
|
||||
|
||||
// SetGRPCTLSCert sets the gRPC TLS certificate to use for communication.
|
||||
func (config *Config) SetGRPCTLSCert(grpcTLSCert string) *Config {
|
||||
config.GRPCTLSCert = grpcTLSCert
|
||||
return config
|
||||
}
|
||||
|
||||
// SetChainID sets the chain ID parameter.
|
||||
func (config *Config) SetChainID(chainID string) *Config {
|
||||
config.ChainID = chainID
|
||||
@ -111,3 +73,9 @@ func (config *Config) SetRoot(root string) *Config {
|
||||
config.RootDir = root
|
||||
return config
|
||||
}
|
||||
|
||||
// SetRPCEndpoint sets the RPC endpoint to send requests to.
|
||||
func (config *Config) SetRPCEndpoint(rpcEndpoint string) *Config {
|
||||
config.RPCEndpoint = rpcEndpoint
|
||||
return config
|
||||
}
|
||||
|
14
lib/go.mod
14
lib/go.mod
@ -5,13 +5,9 @@ go 1.20
|
||||
require (
|
||||
github.com/99designs/keyring v1.2.1
|
||||
github.com/cosmos/cosmos-sdk v0.47.5
|
||||
google.golang.org/grpc v1.56.3
|
||||
)
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.3.1 // indirect
|
||||
cosmossdk.io/core v0.5.1 // indirect
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
|
||||
cosmossdk.io/errors v1.0.0 // indirect
|
||||
cosmossdk.io/math v1.1.2 // indirect
|
||||
filippo.io/edwards25519 v1.0.0 // indirect
|
||||
@ -23,9 +19,6 @@ require (
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/cockroachdb/errors v1.10.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||
github.com/cometbft/cometbft v0.37.2 // indirect
|
||||
github.com/cometbft/cometbft-db v0.7.0 // indirect
|
||||
github.com/confio/ics23/go v0.9.0 // indirect
|
||||
@ -45,7 +38,6 @@ require (
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.23.0 // indirect
|
||||
github.com/go-kit/kit v0.12.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
@ -57,7 +49,6 @@ require (
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||
github.com/gtank/merlin v0.1.1 // indirect
|
||||
@ -67,12 +58,9 @@ require (
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
|
||||
github.com/huandu/skiplist v1.2.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.16.3 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
@ -89,7 +77,6 @@ require (
|
||||
github.com/prometheus/common v0.42.0 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/rs/cors v1.8.3 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
@ -116,6 +103,7 @@ require (
|
||||
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
|
||||
google.golang.org/grpc v1.56.3 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
|
40
lib/go.sum
40
lib/go.sum
@ -36,17 +36,12 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE=
|
||||
cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw=
|
||||
cosmossdk.io/core v0.5.1 h1:vQVtFrIYOQJDV3f7rw4pjjVqc1id4+mE0L9hHP66pyI=
|
||||
cosmossdk.io/core v0.5.1/go.mod h1:KZtwHCLjcFuo0nmDc24Xy6CRNEL9Vl/MeimQ2aC7NLE=
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc=
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU=
|
||||
cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04=
|
||||
cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0=
|
||||
cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk=
|
||||
cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM=
|
||||
cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0=
|
||||
cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
|
||||
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||
@ -80,8 +75,6 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
@ -90,7 +83,6 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
|
||||
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
|
||||
@ -99,12 +91,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU=
|
||||
github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE=
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
|
||||
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
|
||||
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
|
||||
github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA=
|
||||
github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc=
|
||||
github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
|
||||
github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo=
|
||||
@ -130,12 +118,10 @@ github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38=
|
||||
github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A=
|
||||
github.com/cosmos/ledger-cosmos-go v0.12.1 h1:sMBxza5p/rNK/06nBSNmsI/WDqI0pVJFVNihy1Y984w=
|
||||
github.com/cosmos/ledger-cosmos-go v0.12.1/go.mod h1:dhO6kj+Y+AHIOgAe4L9HL/6NDdyyth4q238I9yFpD2g=
|
||||
github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJFxv2Li8=
|
||||
github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
|
||||
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -144,7 +130,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I=
|
||||
github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o=
|
||||
github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk=
|
||||
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||
@ -176,9 +161,7 @@ github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmV
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE=
|
||||
github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
@ -280,7 +263,6 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
|
||||
@ -307,13 +289,9 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
|
||||
github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU=
|
||||
github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
|
||||
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
|
||||
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
|
||||
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
@ -335,19 +313,15 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
|
||||
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
@ -383,7 +357,6 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
|
||||
github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
|
||||
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
@ -392,8 +365,6 @@ github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha
|
||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
|
||||
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU=
|
||||
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
|
||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@ -421,17 +392,13 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
|
||||
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
|
||||
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo=
|
||||
github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
|
||||
@ -505,9 +472,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@ -789,7 +753,6 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
@ -868,8 +831,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@ -877,7 +838,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
|
||||
pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA=
|
||||
pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
|
257
lib/tx.go
257
lib/tx.go
@ -1,29 +1,24 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
comethttp "github.com/cometbft/cometbft/rpc/client/http"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
cryptokeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
// KeyPair defines a public/private key pair to e.g. sign a transaction.
|
||||
type KeyPair struct {
|
||||
Pub cryptotypes.PubKey
|
||||
Priv cryptotypes.PrivKey
|
||||
}
|
||||
|
||||
// Result defines a generic way to receive responses from the RPC endpoint.
|
||||
type Result struct {
|
||||
Info map[string]interface{} `json:"info" mapstructure:"info"`
|
||||
@ -33,145 +28,116 @@ func init() {
|
||||
GetConfig()
|
||||
}
|
||||
|
||||
func getKeyPairFromKeyring(address sdk.AccAddress) (keyPair KeyPair, err error) {
|
||||
ring, err := keyring.Open(keyring.Config{
|
||||
AllowedBackends: []keyring.BackendType{keyring.FileBackend},
|
||||
FileDir: filepath.Join(libConfig.RootDir, "keyring-test"),
|
||||
FilePasswordFunc: func(_ string) (string, error) {
|
||||
return "test", nil
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
name := hex.EncodeToString([]byte(address)) + ".address"
|
||||
i, err := ring.Get(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
name = string(i.Data)
|
||||
i, err = ring.Get(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
s := hex.EncodeToString(i.Data)
|
||||
privKey := s[len(s)-64:]
|
||||
|
||||
decodedPriv, err := hex.DecodeString(privKey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
algo, err := cryptokeyring.NewSigningAlgoFromString("secp256k1", cryptokeyring.SigningAlgoList{hd.Secp256k1})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
priv := algo.Generate()(decodedPriv)
|
||||
pub := priv.PubKey()
|
||||
|
||||
keyPair = KeyPair{
|
||||
Pub: pub,
|
||||
Priv: priv,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getAccountNumberAndSequence(goCtx context.Context, address sdk.AccAddress) (accountNumber, sequence uint64, err error) {
|
||||
grpcConn, err := libConfig.GetGRPCConn()
|
||||
url := fmt.Sprintf("%s/cosmos/auth/v1beta1/account_info/%s", libConfig.APIEndpoint, address.String())
|
||||
req, err := http.NewRequestWithContext(goCtx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer grpcConn.Close()
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
client := authtypes.NewQueryClient(grpcConn)
|
||||
grpcRes, err := client.AccountInfo(
|
||||
goCtx,
|
||||
&authtypes.QueryAccountInfoRequest{
|
||||
Address: address.String(),
|
||||
},
|
||||
)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
accountNumber = grpcRes.Info.AccountNumber
|
||||
sequence = grpcRes.Info.Sequence
|
||||
var result Result
|
||||
err = json.Unmarshal(bodyBytes, &result)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
accountNumber, err = strconv.ParseUint(result.Info["account_number"].(string), 10, 64)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
sequence, err = strconv.ParseUint(result.Info["sequence"].(string), 10, 64)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BuildAndSignTx constructs the transaction from address' private key and messages.
|
||||
func BuildAndSignTx(goCtx context.Context, address sdk.AccAddress, msgs ...sdk.Msg) (txBytes []byte, txJSON string, err error) {
|
||||
func getClientContextAndTxFactory(goCtx context.Context, address sdk.AccAddress) (clientCtx client.Context, txf tx.Factory, err error) {
|
||||
encodingConfig := GetConfig().EncodingConfig
|
||||
if encodingConfig.TxConfig == nil {
|
||||
err = errors.New("encoding config must not be nil")
|
||||
return
|
||||
}
|
||||
txBuilder := encodingConfig.TxConfig.NewTxBuilder()
|
||||
|
||||
err = txBuilder.SetMsgs(msgs...)
|
||||
rootDir := GetConfig().RootDir
|
||||
input := os.Stdin
|
||||
codec := encodingConfig.Marshaler
|
||||
keyringOptions := []keyring.Option{}
|
||||
|
||||
keyring, err := keyring.New("lib", keyring.BackendTest, rootDir, input, codec, keyringOptions...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
txBuilder.SetFeeAmount(sdk.Coins{sdk.NewInt64Coin("plmnt", 1)})
|
||||
txBuilder.SetGasLimit(200000)
|
||||
txBuilder.SetTimeoutHeight(0)
|
||||
|
||||
keyPair, err := getKeyPairFromKeyring(address)
|
||||
record, err := keyring.KeyByAddress(address)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
remote := GetConfig().RPCEndpoint
|
||||
wsClient, err := comethttp.New(remote, "/websocket")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var output bytes.Buffer
|
||||
|
||||
clientCtx = client.Context{
|
||||
BroadcastMode: "sync",
|
||||
ChainID: "planetmint-testnet-1",
|
||||
Client: wsClient,
|
||||
Codec: codec,
|
||||
From: address.String(),
|
||||
FromAddress: address,
|
||||
FromName: record.Name,
|
||||
HomeDir: rootDir,
|
||||
Input: input,
|
||||
Keyring: keyring,
|
||||
KeyringDir: rootDir,
|
||||
KeyringOptions: keyringOptions,
|
||||
NodeURI: remote,
|
||||
Offline: true,
|
||||
Output: &output,
|
||||
SkipConfirm: true,
|
||||
TxConfig: encodingConfig.TxConfig,
|
||||
}
|
||||
|
||||
accountNumber, sequence, err := getAccountNumberAndSequence(goCtx, address)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// First round: we gather all the signer infos. We use the "set empty signature" hack to do that.
|
||||
var sigsV2 []signing.SignatureV2
|
||||
sigV2 := signing.SignatureV2{
|
||||
PubKey: keyPair.Pub,
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: encodingConfig.TxConfig.SignModeHandler().DefaultMode(),
|
||||
Signature: nil,
|
||||
},
|
||||
Sequence: sequence,
|
||||
}
|
||||
sigsV2 = append(sigsV2, sigV2)
|
||||
err = txBuilder.SetSignatures(sigsV2...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
txf = tx.Factory{}.
|
||||
WithAccountNumber(accountNumber).
|
||||
WithChainID(clientCtx.ChainID).
|
||||
WithGas(200000).
|
||||
WithGasPrices("0.000005plmnt").
|
||||
WithKeybase(clientCtx.Keyring).
|
||||
WithSequence(sequence).
|
||||
WithTxConfig(clientCtx.TxConfig)
|
||||
|
||||
// Second round: all signer infos are set, so each signer can sign.
|
||||
sigsV2 = []signing.SignatureV2{}
|
||||
signerData := xauthsigning.SignerData{
|
||||
ChainID: libConfig.ChainID,
|
||||
AccountNumber: accountNumber,
|
||||
Sequence: sequence,
|
||||
}
|
||||
sigV2, err = tx.SignWithPrivKey(encodingConfig.TxConfig.SignModeHandler().DefaultMode(), signerData, txBuilder, keyPair.Priv, encodingConfig.TxConfig, sequence)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
sigsV2 = append(sigsV2, sigV2)
|
||||
err = txBuilder.SetSignatures(sigsV2...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Generated Protobuf-encoded bytes.
|
||||
txBytes, err = encodingConfig.TxConfig.TxEncoder()(txBuilder.GetTx())
|
||||
// BuildUnsignedTx builds a transaction to be signed given a set of messages.
|
||||
// Once created, the fee, memo, and messages are set.
|
||||
func BuildUnsignedTx(goCtx context.Context, address sdk.AccAddress, msgs ...sdk.Msg) (txJSON string, err error) {
|
||||
clientCtx, txf, err := getClientContextAndTxFactory(goCtx, address)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
txBuilder, err := txf.BuildUnsignedTx(msgs...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Generate a JSON string.
|
||||
txJSONBytes, err := encodingConfig.TxConfig.TxJSONEncoder()(txBuilder.GetTx())
|
||||
txJSONBytes, err := clientCtx.TxConfig.TxJSONEncoder()(txBuilder.GetTx())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -179,47 +145,18 @@ func BuildAndSignTx(goCtx context.Context, address sdk.AccAddress, msgs ...sdk.M
|
||||
return
|
||||
}
|
||||
|
||||
// BroadcastTx broadcasts a transaction via gRPC.
|
||||
func BroadcastTx(goCtx context.Context, txBytes []byte) (txResponse *sdk.TxResponse, err error) {
|
||||
grpcConn, err := libConfig.GetGRPCConn()
|
||||
// BroadcastTx broadcasts a transaction via RPC.
|
||||
func BroadcastTx(goCtx context.Context, address sdk.AccAddress, msgs ...sdk.Msg) (broadcastTxResponseJSON string, err error) {
|
||||
clientCtx, txf, err := getClientContextAndTxFactory(goCtx, address)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer grpcConn.Close()
|
||||
|
||||
client := sdktx.NewServiceClient(grpcConn)
|
||||
grpcRes, err := client.BroadcastTx(
|
||||
goCtx,
|
||||
&sdktx.BroadcastTxRequest{
|
||||
Mode: sdktx.BroadcastMode_BROADCAST_MODE_SYNC,
|
||||
TxBytes: txBytes,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
err = tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msgs...)
|
||||
output, ok := clientCtx.Output.(*bytes.Buffer)
|
||||
if !ok {
|
||||
err = errors.New("type assertion failed")
|
||||
return
|
||||
}
|
||||
txResponse = grpcRes.TxResponse
|
||||
return
|
||||
}
|
||||
|
||||
// SimulateTx simulates broadcasting a transaction via gRPC.
|
||||
func SimulateTx(goCtx context.Context, txBytes []byte) (result *sdk.Result, err error) {
|
||||
grpcConn, err := libConfig.GetGRPCConn()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer grpcConn.Close()
|
||||
|
||||
client := sdktx.NewServiceClient(grpcConn)
|
||||
grpcRes, err := client.Simulate(
|
||||
goCtx,
|
||||
&sdktx.SimulateRequest{
|
||||
TxBytes: txBytes,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result = grpcRes.Result
|
||||
broadcastTxResponseJSON = output.String()
|
||||
return
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ func buildSignBroadcastTx(goCtx context.Context, sendingValidatorAddress string,
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
logger := ctx.Logger()
|
||||
addr := sdk.MustAccAddressFromBech32(sendingValidatorAddress)
|
||||
txBytes, txJSON, err := lib.BuildAndSignTx(goCtx, addr, msg)
|
||||
txJSON, err := lib.BuildUnsignedTx(goCtx, addr, msg)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
logger.Debug("REISSUE: tx: " + txJSON)
|
||||
_, err = lib.BroadcastTx(goCtx, txBytes)
|
||||
_, err = lib.BroadcastTx(goCtx, addr, msg)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func TestQueryGetMintRequestByHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
keeper, ctx := keepertest.DaoKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
items := createNMintRequests(keeper, ctx, sample.ConstBech32Addr, 1)
|
||||
@ -35,9 +34,7 @@ func TestQueryGetMintRequestByHash(t *testing.T) {
|
||||
err: status.Error(codes.NotFound, "mint request not found"),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
res, err := keeper.GetMintRequestsByHash(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
func TestQueryGetReissuance(t *testing.T) {
|
||||
t.Parallel()
|
||||
keeper, ctx := keepertest.DaoKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
items := createNReissuances(keeper, ctx, 1)
|
||||
@ -34,9 +33,7 @@ func TestQueryGetReissuance(t *testing.T) {
|
||||
err: status.Error(codes.NotFound, "reissuance not found"),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
res, err := keeper.GetReissuance(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func TestGetTrustAnchorQuery(t *testing.T) {
|
||||
t.Parallel()
|
||||
keeper, ctx := keepertest.MachineKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNTrustAnchor(t, keeper, ctx, 2)
|
||||
@ -39,9 +38,7 @@ func TestGetTrustAnchorQuery(t *testing.T) {
|
||||
err: status.Error(codes.NotFound, "trust anchor not found"),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
response, err := keeper.GetTrustAnchorStatus(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user