wormchain: remove tokenbridge
Change-Id: I582f55143cff793a1b90e51a81c034705a9a3e18
This commit is contained in:
parent
a1598b2769
commit
206d10cacf
|
@ -92,9 +92,6 @@ import (
|
|||
"github.com/tendermint/spm/openapiconsole"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/docs"
|
||||
tokenbridgemodule "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge"
|
||||
tokenbridgemodulekeeper "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
tokenbridgemoduletypes "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
wormholemodule "github.com/wormhole-foundation/wormhole-chain/x/wormhole"
|
||||
wormholeclient "github.com/wormhole-foundation/wormhole-chain/x/wormhole/client"
|
||||
wormholemodulekeeper "github.com/wormhole-foundation/wormhole-chain/x/wormhole/keeper"
|
||||
|
@ -162,22 +159,20 @@ var (
|
|||
transfer.AppModuleBasic{},
|
||||
vesting.AppModuleBasic{},
|
||||
wormholemodule.AppModuleBasic{},
|
||||
tokenbridgemodule.AppModuleBasic{},
|
||||
// this line is used by starport scaffolding # stargate/app/moduleBasic
|
||||
wasm.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
maccPerms = map[string][]string{
|
||||
authtypes.FeeCollectorName: nil,
|
||||
distrtypes.ModuleName: nil,
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
govtypes.ModuleName: {authtypes.Burner},
|
||||
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
wormholemoduletypes.ModuleName: nil,
|
||||
tokenbridgemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
|
||||
authtypes.FeeCollectorName: nil,
|
||||
distrtypes.ModuleName: nil,
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
govtypes.ModuleName: {authtypes.Burner},
|
||||
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
wormholemoduletypes.ModuleName: nil,
|
||||
// this line is used by starport scaffolding # stargate/app/maccPerms
|
||||
wasm.ModuleName: {authtypes.Burner},
|
||||
}
|
||||
|
@ -237,7 +232,6 @@ type App struct {
|
|||
|
||||
WormholeKeeper wormholemodulekeeper.Keeper
|
||||
|
||||
TokenbridgeKeeper tokenbridgemodulekeeper.Keeper
|
||||
// this line is used by starport scaffolding # stargate/app/keeperDeclaration
|
||||
wasmKeeper wasm.Keeper
|
||||
scopedWasmKeeper capabilitykeeper.ScopedKeeper
|
||||
|
@ -277,7 +271,6 @@ func New(
|
|||
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
|
||||
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
|
||||
wormholemoduletypes.StoreKey,
|
||||
tokenbridgemoduletypes.StoreKey,
|
||||
// this line is used by starport scaffolding # stargate/app/storeKey
|
||||
wasm.StoreKey,
|
||||
)
|
||||
|
@ -388,17 +381,6 @@ func New(
|
|||
|
||||
govRouter.AddRoute(wormholemoduletypes.RouterKey, wormholemodule.NewWormholeGovernanceProposalHandler(app.WormholeKeeper))
|
||||
|
||||
app.TokenbridgeKeeper = *tokenbridgemodulekeeper.NewKeeper(
|
||||
appCodec,
|
||||
keys[tokenbridgemoduletypes.StoreKey],
|
||||
keys[tokenbridgemoduletypes.MemStoreKey],
|
||||
|
||||
app.AccountKeeper,
|
||||
app.BankKeeper,
|
||||
app.WormholeKeeper,
|
||||
)
|
||||
tokenbridgeModule := tokenbridgemodule.NewAppModule(appCodec, app.TokenbridgeKeeper)
|
||||
|
||||
app.GovKeeper = govkeeper.NewKeeper(
|
||||
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||
&stakingKeeper, govRouter,
|
||||
|
@ -472,7 +454,6 @@ func New(
|
|||
params.NewAppModule(app.ParamsKeeper),
|
||||
transferModule,
|
||||
wormholeModule,
|
||||
tokenbridgeModule,
|
||||
// this line is used by starport scaffolding # stargate/app/appModule
|
||||
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
||||
)
|
||||
|
@ -500,7 +481,6 @@ func New(
|
|||
feegrant.ModuleName,
|
||||
paramstypes.ModuleName,
|
||||
wormholemoduletypes.ModuleName,
|
||||
tokenbridgemoduletypes.ModuleName,
|
||||
// this line is used by starport scaffolding # stargate/app/beginBlockers
|
||||
wasm.ModuleName,
|
||||
)
|
||||
|
@ -524,7 +504,6 @@ func New(
|
|||
ibchost.ModuleName,
|
||||
ibctransfertypes.ModuleName,
|
||||
wormholemoduletypes.ModuleName,
|
||||
tokenbridgemoduletypes.ModuleName,
|
||||
// this line is used by starport scaffolding # stargate/app/endBlockers
|
||||
wasm.ModuleName,
|
||||
)
|
||||
|
@ -556,7 +535,6 @@ func New(
|
|||
upgradetypes.ModuleName,
|
||||
ibctransfertypes.ModuleName,
|
||||
feegrant.ModuleName,
|
||||
tokenbridgemoduletypes.ModuleName,
|
||||
// this line is used by starport scaffolding # stargate/app/initGenesis
|
||||
wasm.ModuleName,
|
||||
)
|
||||
|
@ -747,7 +725,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
|
|||
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
||||
paramsKeeper.Subspace(ibchost.ModuleName)
|
||||
paramsKeeper.Subspace(wormholemoduletypes.ModuleName)
|
||||
paramsKeeper.Subspace(tokenbridgemoduletypes.ModuleName)
|
||||
// this line is used by starport scaffolding # stargate/app/paramSubspace
|
||||
paramsKeeper.Subspace(wasm.ModuleName)
|
||||
|
||||
|
|
|
@ -295,12 +295,6 @@
|
|||
"unbonding_delegations": [],
|
||||
"validators": []
|
||||
},
|
||||
"tokenbridge": {
|
||||
"chainRegistrationList": [],
|
||||
"coinMetaRollbackProtectionList": [],
|
||||
"config": null,
|
||||
"replayProtectionList": []
|
||||
},
|
||||
"transfer": {
|
||||
"denom_traces": [],
|
||||
"params": {
|
||||
|
|
|
@ -58,7 +58,7 @@ Client tests, run against the chain. Wormchain must be running via `starport cha
|
|||
You can interact with the blockchain by using the go binary:
|
||||
|
||||
```shell
|
||||
./build/wormhole-chaind tx tokenbridge execute-governance-vaa 01000000000100e86068bfd49c7209f259110dc061012ca6d65318f3879325528c57cf3e4950ff1295dbde77a4c72f3aee29a32a07099257521674725be8eb8bbd801349a828c30100000001000000010001000000000000000000000000000000000000000000000000000000000000000400000000038502e100000000000000000000000000000000000000000000546f6b656e4272696467650100000001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f --from tiltGuardian --home build
|
||||
./build/wormhole-chaind tx --from tiltGuardian --home build
|
||||
```
|
||||
|
||||
Note the flags `--from tiltGuardian --home build`. These have to be passed
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
# Register wormhole chain on other chains
|
||||
|
||||
The token bridge emitter address is
|
||||
|
||||
```
|
||||
wormhole1zugu6cajc4z7ue29g9wnes9a5ep9cs7yu7rn3z
|
||||
```
|
||||
|
||||
The wormhole (core module) address is:
|
||||
|
||||
```
|
||||
|
@ -14,32 +8,6 @@ wormhole1ap5vgur5zlgys8whugfegnn43emka567dtq0jl
|
|||
|
||||
This is deterministically generated from the module.
|
||||
|
||||
## Tiltnet
|
||||
|
||||
The VAA signed with the tiltnet guardian:
|
||||
|
||||
```
|
||||
0100000000010047464c64a843f49766edc85c9b94b8b142a3315d6cad6c0045fe171f969b68bf52db1f81b9f40ec749b2ca27ebfe7da304c432f278bb9845448595d93a3519af0000000000d1ffc017000100000000000000000000000000000000000000000000000000000000000000045f2397a84b3f90ce20000000000000000000000000000000000000000000546f6b656e4272696467650100000c200000000000000000000000001711cd63b2c545ee6545415d3cc0bda6425c43c4
|
||||
```
|
||||
|
||||
Rendered:
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Wormhole VAA v1 │ nonce: 3523198999 │ time: 0 │
|
||||
│ guardian set #0 │ #6855489806860783822 │ consistency: 32 │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Signature: │
|
||||
│ #0: 47464c64a843f49766edc85c9b94b8b142a3315d6cad6c0045fe171f969b... │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Emitter: 11111111111111111111111111111115 (Solana) │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Chain registration (TokenBridge) │
|
||||
│ Emitter chain: Wormhole │
|
||||
│ Emitter address: wormhole1zugu6cajc4z7ue29g9wnes9a5ep9cs7yu7rn3z (Wormhole) │
|
||||
└──────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Testnet
|
||||
|
||||
TBD (need to be signed by testnet guardian)
|
||||
|
|
|
@ -4,527 +4,6 @@ info:
|
|||
name: ''
|
||||
description: ''
|
||||
paths:
|
||||
/certusone/wormholechain/tokenbridge/chainRegistration:
|
||||
get:
|
||||
summary: Queries a list of chainRegistration items.
|
||||
operationId: CertusoneWormholechainTokenbridgeChainRegistrationAll
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
chainRegistration:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
chainID:
|
||||
type: integer
|
||||
format: int64
|
||||
emitterAddress:
|
||||
type: string
|
||||
format: byte
|
||||
pagination:
|
||||
type: object
|
||||
properties:
|
||||
next_key:
|
||||
type: string
|
||||
format: byte
|
||||
title: |-
|
||||
next_key is the key to be passed to PageRequest.key to
|
||||
query the next page most efficiently
|
||||
total:
|
||||
type: string
|
||||
format: uint64
|
||||
title: >-
|
||||
total is total number of results available if
|
||||
PageRequest.count_total
|
||||
|
||||
was set, its value is undefined otherwise
|
||||
description: >-
|
||||
PageResponse is to be embedded in gRPC response messages where
|
||||
the
|
||||
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
parameters:
|
||||
- name: pagination.key
|
||||
description: |-
|
||||
key is a value returned in PageResponse.next_key to begin
|
||||
querying the next page most efficiently. Only one of offset or key
|
||||
should be set.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: byte
|
||||
- name: pagination.offset
|
||||
description: >-
|
||||
offset is a numeric offset that can be used when key is unavailable.
|
||||
|
||||
It is less efficient than using key. Only one of offset or key
|
||||
should
|
||||
|
||||
be set.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: uint64
|
||||
- name: pagination.limit
|
||||
description: >-
|
||||
limit is the total number of results to be returned in the result
|
||||
page.
|
||||
|
||||
If left empty it will default to a value to be set by each app.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: uint64
|
||||
- name: pagination.count_total
|
||||
description: >-
|
||||
count_total is set to true to indicate that the result set should
|
||||
include
|
||||
|
||||
a count of the total number of items available for pagination in
|
||||
UIs.
|
||||
|
||||
count_total is only respected when offset is used. It is ignored
|
||||
when key
|
||||
|
||||
is set.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
- name: pagination.reverse
|
||||
description: >-
|
||||
reverse is set to true if results are to be returned in the
|
||||
descending order.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
tags:
|
||||
- Query
|
||||
'/certusone/wormholechain/tokenbridge/chainRegistration/{chainID}':
|
||||
get:
|
||||
summary: Queries a chainRegistration by index.
|
||||
operationId: CertusoneWormholechainTokenbridgeChainRegistration
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
chainRegistration:
|
||||
type: object
|
||||
properties:
|
||||
chainID:
|
||||
type: integer
|
||||
format: int64
|
||||
emitterAddress:
|
||||
type: string
|
||||
format: byte
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
parameters:
|
||||
- name: chainID
|
||||
in: path
|
||||
required: true
|
||||
type: integer
|
||||
format: int64
|
||||
tags:
|
||||
- Query
|
||||
/certusone/wormholechain/tokenbridge/coinMetaRollbackProtection:
|
||||
get:
|
||||
summary: Queries a list of coinMetaRollbackProtection items.
|
||||
operationId: CertusoneWormholechainTokenbridgeCoinMetaRollbackProtectionAll
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
coinMetaRollbackProtection:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
lastUpdateSequence:
|
||||
type: string
|
||||
format: uint64
|
||||
pagination:
|
||||
type: object
|
||||
properties:
|
||||
next_key:
|
||||
type: string
|
||||
format: byte
|
||||
title: |-
|
||||
next_key is the key to be passed to PageRequest.key to
|
||||
query the next page most efficiently
|
||||
total:
|
||||
type: string
|
||||
format: uint64
|
||||
title: >-
|
||||
total is total number of results available if
|
||||
PageRequest.count_total
|
||||
|
||||
was set, its value is undefined otherwise
|
||||
description: >-
|
||||
PageResponse is to be embedded in gRPC response messages where
|
||||
the
|
||||
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
parameters:
|
||||
- name: pagination.key
|
||||
description: |-
|
||||
key is a value returned in PageResponse.next_key to begin
|
||||
querying the next page most efficiently. Only one of offset or key
|
||||
should be set.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: byte
|
||||
- name: pagination.offset
|
||||
description: >-
|
||||
offset is a numeric offset that can be used when key is unavailable.
|
||||
|
||||
It is less efficient than using key. Only one of offset or key
|
||||
should
|
||||
|
||||
be set.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: uint64
|
||||
- name: pagination.limit
|
||||
description: >-
|
||||
limit is the total number of results to be returned in the result
|
||||
page.
|
||||
|
||||
If left empty it will default to a value to be set by each app.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: uint64
|
||||
- name: pagination.count_total
|
||||
description: >-
|
||||
count_total is set to true to indicate that the result set should
|
||||
include
|
||||
|
||||
a count of the total number of items available for pagination in
|
||||
UIs.
|
||||
|
||||
count_total is only respected when offset is used. It is ignored
|
||||
when key
|
||||
|
||||
is set.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
- name: pagination.reverse
|
||||
description: >-
|
||||
reverse is set to true if results are to be returned in the
|
||||
descending order.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
tags:
|
||||
- Query
|
||||
'/certusone/wormholechain/tokenbridge/coinMetaRollbackProtection/{index}':
|
||||
get:
|
||||
summary: Queries a coinMetaRollbackProtection by index.
|
||||
operationId: CertusoneWormholechainTokenbridgeCoinMetaRollbackProtection
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
coinMetaRollbackProtection:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
lastUpdateSequence:
|
||||
type: string
|
||||
format: uint64
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
parameters:
|
||||
- name: index
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
tags:
|
||||
- Query
|
||||
/certusone/wormholechain/tokenbridge/config:
|
||||
get:
|
||||
summary: Queries a config by index.
|
||||
operationId: CertusoneWormholechainTokenbridgeConfig
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
Config:
|
||||
type: object
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
tags:
|
||||
- Query
|
||||
/certusone/wormholechain/tokenbridge/replayProtection:
|
||||
get:
|
||||
summary: Queries a list of replayProtection items.
|
||||
operationId: CertusoneWormholechainTokenbridgeReplayProtectionAll
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
replayProtection:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
pagination:
|
||||
type: object
|
||||
properties:
|
||||
next_key:
|
||||
type: string
|
||||
format: byte
|
||||
title: |-
|
||||
next_key is the key to be passed to PageRequest.key to
|
||||
query the next page most efficiently
|
||||
total:
|
||||
type: string
|
||||
format: uint64
|
||||
title: >-
|
||||
total is total number of results available if
|
||||
PageRequest.count_total
|
||||
|
||||
was set, its value is undefined otherwise
|
||||
description: >-
|
||||
PageResponse is to be embedded in gRPC response messages where
|
||||
the
|
||||
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
parameters:
|
||||
- name: pagination.key
|
||||
description: |-
|
||||
key is a value returned in PageResponse.next_key to begin
|
||||
querying the next page most efficiently. Only one of offset or key
|
||||
should be set.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: byte
|
||||
- name: pagination.offset
|
||||
description: >-
|
||||
offset is a numeric offset that can be used when key is unavailable.
|
||||
|
||||
It is less efficient than using key. Only one of offset or key
|
||||
should
|
||||
|
||||
be set.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: uint64
|
||||
- name: pagination.limit
|
||||
description: >-
|
||||
limit is the total number of results to be returned in the result
|
||||
page.
|
||||
|
||||
If left empty it will default to a value to be set by each app.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
format: uint64
|
||||
- name: pagination.count_total
|
||||
description: >-
|
||||
count_total is set to true to indicate that the result set should
|
||||
include
|
||||
|
||||
a count of the total number of items available for pagination in
|
||||
UIs.
|
||||
|
||||
count_total is only respected when offset is used. It is ignored
|
||||
when key
|
||||
|
||||
is set.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
- name: pagination.reverse
|
||||
description: >-
|
||||
reverse is set to true if results are to be returned in the
|
||||
descending order.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
tags:
|
||||
- Query
|
||||
'/certusone/wormholechain/tokenbridge/replayProtection/{index}':
|
||||
get:
|
||||
summary: Queries a replayProtection by index.
|
||||
operationId: CertusoneWormholechainTokenbridgeReplayProtection
|
||||
responses:
|
||||
'200':
|
||||
description: A successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
replayProtection:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
'@type':
|
||||
type: string
|
||||
additionalProperties: {}
|
||||
parameters:
|
||||
- name: index
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
tags:
|
||||
- Query
|
||||
/certusone/wormholechain/wormhole/config:
|
||||
get:
|
||||
summary: Queries a config by index.
|
||||
|
@ -28840,186 +28319,6 @@ paths:
|
|||
tags:
|
||||
- Query
|
||||
definitions:
|
||||
certusone.wormholechain.tokenbridge.ChainRegistration:
|
||||
type: object
|
||||
properties:
|
||||
chainID:
|
||||
type: integer
|
||||
format: int64
|
||||
emitterAddress:
|
||||
type: string
|
||||
format: byte
|
||||
certusone.wormholechain.tokenbridge.CoinMetaRollbackProtection:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
lastUpdateSequence:
|
||||
type: string
|
||||
format: uint64
|
||||
certusone.wormholechain.tokenbridge.Config:
|
||||
type: object
|
||||
certusone.wormholechain.tokenbridge.MsgAttestTokenResponse:
|
||||
type: object
|
||||
certusone.wormholechain.tokenbridge.MsgExecuteGovernanceVAAResponse:
|
||||
type: object
|
||||
certusone.wormholechain.tokenbridge.MsgExecuteVAAResponse:
|
||||
type: object
|
||||
certusone.wormholechain.tokenbridge.MsgTransferResponse:
|
||||
type: object
|
||||
certusone.wormholechain.tokenbridge.QueryAllChainRegistrationResponse:
|
||||
type: object
|
||||
properties:
|
||||
chainRegistration:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
chainID:
|
||||
type: integer
|
||||
format: int64
|
||||
emitterAddress:
|
||||
type: string
|
||||
format: byte
|
||||
pagination:
|
||||
type: object
|
||||
properties:
|
||||
next_key:
|
||||
type: string
|
||||
format: byte
|
||||
title: |-
|
||||
next_key is the key to be passed to PageRequest.key to
|
||||
query the next page most efficiently
|
||||
total:
|
||||
type: string
|
||||
format: uint64
|
||||
title: >-
|
||||
total is total number of results available if
|
||||
PageRequest.count_total
|
||||
|
||||
was set, its value is undefined otherwise
|
||||
description: |-
|
||||
PageResponse is to be embedded in gRPC response messages where the
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
certusone.wormholechain.tokenbridge.QueryAllCoinMetaRollbackProtectionResponse:
|
||||
type: object
|
||||
properties:
|
||||
coinMetaRollbackProtection:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
lastUpdateSequence:
|
||||
type: string
|
||||
format: uint64
|
||||
pagination:
|
||||
type: object
|
||||
properties:
|
||||
next_key:
|
||||
type: string
|
||||
format: byte
|
||||
title: |-
|
||||
next_key is the key to be passed to PageRequest.key to
|
||||
query the next page most efficiently
|
||||
total:
|
||||
type: string
|
||||
format: uint64
|
||||
title: >-
|
||||
total is total number of results available if
|
||||
PageRequest.count_total
|
||||
|
||||
was set, its value is undefined otherwise
|
||||
description: |-
|
||||
PageResponse is to be embedded in gRPC response messages where the
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
certusone.wormholechain.tokenbridge.QueryAllReplayProtectionResponse:
|
||||
type: object
|
||||
properties:
|
||||
replayProtection:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
pagination:
|
||||
type: object
|
||||
properties:
|
||||
next_key:
|
||||
type: string
|
||||
format: byte
|
||||
title: |-
|
||||
next_key is the key to be passed to PageRequest.key to
|
||||
query the next page most efficiently
|
||||
total:
|
||||
type: string
|
||||
format: uint64
|
||||
title: >-
|
||||
total is total number of results available if
|
||||
PageRequest.count_total
|
||||
|
||||
was set, its value is undefined otherwise
|
||||
description: |-
|
||||
PageResponse is to be embedded in gRPC response messages where the
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
certusone.wormholechain.tokenbridge.QueryGetChainRegistrationResponse:
|
||||
type: object
|
||||
properties:
|
||||
chainRegistration:
|
||||
type: object
|
||||
properties:
|
||||
chainID:
|
||||
type: integer
|
||||
format: int64
|
||||
emitterAddress:
|
||||
type: string
|
||||
format: byte
|
||||
certusone.wormholechain.tokenbridge.QueryGetCoinMetaRollbackProtectionResponse:
|
||||
type: object
|
||||
properties:
|
||||
coinMetaRollbackProtection:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
lastUpdateSequence:
|
||||
type: string
|
||||
format: uint64
|
||||
certusone.wormholechain.tokenbridge.QueryGetConfigResponse:
|
||||
type: object
|
||||
properties:
|
||||
Config:
|
||||
type: object
|
||||
certusone.wormholechain.tokenbridge.QueryGetReplayProtectionResponse:
|
||||
type: object
|
||||
properties:
|
||||
replayProtection:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
certusone.wormholechain.tokenbridge.ReplayProtection:
|
||||
type: object
|
||||
properties:
|
||||
index:
|
||||
type: string
|
||||
cosmos.base.query.v1beta1.PageRequest:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
--------------------------------------------------------------------------------
|
||||
Registration (polygon)
|
||||
|
||||
ckiss@R2F2R41 wormhole-chaind % ./main tx tokenbridge execute-governance-vaa 0100000000010019db40bb49a6519e3d15d94cd3569c7a587152862ec99717d42df5dd57882d0e66dee89ff51c9e9b9517fda0d3237946412d0da31a468c18b0a6b50b4e46d5ec01000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000489b7ee00000000000000000000000000000000000000000000546f6b656e4272696467650100000005000000000000000000000000377d55a7928c046e18eebb61977e714d2a76472a --from tiltGuardian --home ../../build
|
||||
|
||||
code: 0
|
||||
codespace: ""
|
||||
data: 0A3E0A3C2F6365727475736F6E652E776F726D686F6C65636861696E2E746F6B656E6272696467652E4D736745786563757465476F7665726E616E6365564141
|
||||
gas_used: "49411"
|
||||
gas_wanted: "200000"
|
||||
height: "1686"
|
||||
info: ""
|
||||
logs:
|
||||
- events:
|
||||
- attributes:
|
||||
- key: emitterAddress
|
||||
value: '"AAAAAAAAAAAAAAAAN31Vp5KMBG4Y7rthl35xTSp2Ryo="'
|
||||
- key: chainID
|
||||
value: "5"
|
||||
type: certusone.wormholechain.tokenbridge.EventChainRegistered
|
||||
- attributes:
|
||||
- key: action
|
||||
value: ExecuteGovernanceVAA
|
||||
type: message
|
||||
log: ""
|
||||
msg_index: 0
|
||||
raw_log: '[{"events":[{"type":"certusone.wormholechain.tokenbridge.EventChainRegistered","attributes":[{"key":"emitterAddress","value":"\"AAAAAAAAAAAAAAAAN31Vp5KMBG4Y7rthl35xTSp2Ryo=\""},{"key":"chainID","value":"5"}]},{"type":"message","attributes":[{"key":"action","value":"ExecuteGovernanceVAA"}]}]}]'
|
||||
timestamp: ""
|
||||
tx: null
|
||||
txhash: BA52B1E363322730E40BB203D73FBDBD93853CD1057C0DC975F2BC36B7E8A907
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Send 100 utest out
|
||||
./main tx tokenbridge transfer 100utest 5 000000000000000000000000e99c31abdcbed4e6d31d276b04e02a6fd4b1a861 0 --from tiltGuardian --home ../../build
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Devnet guardian #2 keypair:
|
||||
|
||||
λ> toHexString (Crypto.exportKey devnetGuardianSecret')
|
||||
"bfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0"
|
||||
|
||||
λ> deriveEthPubkey devnetGuardianSecret'
|
||||
a75a14f140c22d691bb0b19b4a51fae5b77f9d89
|
||||
|
||||
Create new
|
||||
|
||||
λ> myGuardianSetUpgrade
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Wormhole VAA v1 │ nonce: 1155723085 │ time: 0 │
|
||||
│ guardian set #0 │ #5045183322996712854 │ consistency: 32 │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Signature: │
|
||||
│ #0: 35a5da3648df687185296528e404d101f5a20f4f8915d94046e0e4243f6b... │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Emitter: 11111111111111111111111111111115 (Solana) │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Guardian set upgrade to #1 │
|
||||
│ Keys: │
|
||||
│ #0 : 0xa75a14f140c22d691bb0b19b4a51fae5b77f9d89 │
|
||||
└──────────────────────────────────────────────────────────────────────────────┘
|
||||
λ> serialiseVAA it
|
||||
"0100000000010035a5da3648df687185296528e404d101f5a20f4f8915d94046e0e4243f6b443d12d5899f50a8b83fe77c9970c08f458068f7f48555b6fb11269d959d3372a7fd000000000044e2ef4d000100000000000000000000000000000000000000000000000000000000000000044604178071f1a5962000000000000000000000000000000000000000000000000000000000436f72650200000000000101a75a14f140c22d691bb0b19b4a51fae5b77f9d89"
|
||||
|
||||
λ> transfer uwormAddress solanaTokenBridge devnetWallet1 10000000000000000 Nothing
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Wormhole VAA v1 │ nonce: 1856355419 │ time: 0 │
|
||||
│ guardian set #0 │ #2252519879372323853 │ consistency: 32 │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Signature: │
|
||||
│ #0: 167fddaf3b94aa48975829abfa0f52b6f48ad97f67a6d62c928ad5159964... │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Emitter: ENG1wQ7CQKH8ibAJ1hSLmJgL9Ucg6DRDbj752ZAfidLA (Solana) │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Token transfer │
|
||||
│ Amount: 100000000.0 │
|
||||
│ Token: 2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ (Solana) │
|
||||
│ Recipient: wormhole1cyyzpxplxdzkeea7kwsydadg87357qna3zg3tq (Wormhole) │
|
||||
│ Fee: 0.0 │
|
||||
└──────────────────────────────────────────────────────────────────────────────┘
|
||||
λ> serialiseVAA it
|
||||
"01000000000100167fddaf3b94aa48975829abfa0f52b6f48ad97f67a6d62c928ad5159964471d3b3f465077aa08dc5311f3adbc92e76d6e7a2c114cad4a09297cd150336520b100000000006ea5bc5b0001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f1f428ee55b7e3c0d2001000000000000000000000000000000000000000000000000002386f26fc10000165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d0c200000000000000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
|
||||
λ> transfer uwormAddress solanaTokenBridge devnetWallet2 20000000000000000 Nothing
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Wormhole VAA v1 │ nonce: 376017944 │ time: 0 │
|
||||
│ guardian set #0 │ #95069053037693418 │ consistency: 32 │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Signature: │
|
||||
│ #0: 03319407d687b0e337905d85e6bb23ca3cb04167c49e6585e5c6f2d5da4b... │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Emitter: ENG1wQ7CQKH8ibAJ1hSLmJgL9Ucg6DRDbj752ZAfidLA (Solana) │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Token transfer │
|
||||
│ Amount: 200000000.0 │
|
||||
│ Token: 2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ (Solana) │
|
||||
│ Recipient: wormhole1wqwywkce50mg6077huy4j9y8lt80943ks5udzr (Wormhole) │
|
||||
│ Fee: 0.0 │
|
||||
└──────────────────────────────────────────────────────────────────────────────┘
|
||||
λ> serialiseVAA it
|
||||
"0100000000010003319407d687b0e337905d85e6bb23ca3cb04167c49e6585e5c6f2d5da4b1d5739e865bcf38e3ae8ba5bc9c967b3477a33df0ce659e9879f488dc3ccf176fb5e0000000000166994180001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f0151c0cccf71c9ea200100000000000000000000000000000000000000000000000000470de4df820000165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000701c475b19a3f68d3fdebf09591487facef2d6360c200000000000000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
λ> transfer uwormAddress solanaTokenBridge devnetWallet1 11000000000000000 Nothing
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Wormhole VAA v1 │ nonce: 1672020332 │ time: 0 │
|
||||
│ guardian set #1 │ #14601047132816392294 │ consistency: 32 │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Signature: │
|
||||
│ #0: 938362116fc18edca1adec84515c7a62387cff995e65d0833696f911284a... │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Emitter: ENG1wQ7CQKH8ibAJ1hSLmJgL9Ucg6DRDbj752ZAfidLA (Solana) │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Token transfer │
|
||||
│ Amount: 110000000.0 │
|
||||
│ Token: 2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ (Solana) │
|
||||
│ Recipient: wormhole1cyyzpxplxdzkeea7kwsydadg87357qna3zg3tq (Wormhole) │
|
||||
│ Fee: 0.0 │
|
||||
└──────────────────────────────────────────────────────────────────────────────┘
|
||||
λ> serialiseVAA it
|
||||
"01000000010100938362116fc18edca1adec84515c7a62387cff995e65d0833696f911284a539e068a3097af551683bd07c92a5d5df53f8b7b2cce10a8ccf7fe136344815d995f010000000063a9016c0001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4fcaa15701f441c06620010000000000000000000000000000000000000000000000000027147114878000165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d0c200000000000000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
λ> transfer uwormAddress solanaTokenBridge devnetWallet2 21000000000000000 Nothing
|
||||
┌──────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Wormhole VAA v1 │ nonce: 2352732195 │ time: 0 │
|
||||
│ guardian set #1 │ #1862301672562311566 │ consistency: 32 │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Signature: │
|
||||
│ #0: cf6d0dac8dd15eb86f185bf9ebf53f7a15424b35adbc6a50c352e2b91c15... │
|
||||
├──────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Emitter: ENG1wQ7CQKH8ibAJ1hSLmJgL9Ucg6DRDbj752ZAfidLA (Solana) │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Token transfer │
|
||||
│ Amount: 210000000.0 │
|
||||
│ Token: 2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ (Solana) │
|
||||
│ Recipient: wormhole1wqwywkce50mg6077huy4j9y8lt80943ks5udzr (Wormhole) │
|
||||
│ Fee: 0.0 │
|
||||
└──────────────────────────────────────────────────────────────────────────────┘
|
||||
λ> serialiseVAA it
|
||||
"01000000010100cf6d0dac8dd15eb86f185bf9ebf53f7a15424b35adbc6a50c352e2b91c15a298411f79f5a7ed9989db4bf79c50d5d278182b73789dbb825d2a7e4c0a4c15d81601000000008c3bd8230001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f19d8398119b1418e2001000000000000000000000000000000000000000000000000004a9b6384488000165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000701c475b19a3f68d3fdebf09591487facef2d6360c200000000000000000000000000000000000000000000000000000000000000000"
|
|
@ -1,12 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
|
||||
|
||||
message ChainRegistration {
|
||||
uint32 chainID = 1;
|
||||
bytes emitterAddress = 2;
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
|
||||
|
||||
message CoinMetaRollbackProtection {
|
||||
string index = 1;
|
||||
uint64 lastUpdateSequence = 2;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
|
||||
message Config {
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
message EventChainRegistered{
|
||||
uint32 chainID = 1;
|
||||
bytes emitterAddress = 2;
|
||||
}
|
||||
|
||||
message EventAssetRegistrationUpdate{
|
||||
uint32 tokenChain = 1;
|
||||
bytes tokenAddress = 2;
|
||||
string name = 3;
|
||||
string symbol = 4;
|
||||
uint32 decimals = 5;
|
||||
}
|
||||
|
||||
message EventTransferReceived{
|
||||
uint32 tokenChain = 1;
|
||||
bytes tokenAddress = 2;
|
||||
string to = 3;
|
||||
string feeRecipient = 4;
|
||||
string amount = 5;
|
||||
string fee = 6;
|
||||
string localDenom = 7;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
import "tokenbridge/config.proto";
|
||||
import "tokenbridge/replay_protection.proto";
|
||||
import "tokenbridge/chain_registration.proto";
|
||||
import "tokenbridge/coin_meta_rollback_protection.proto";
|
||||
// this line is used by starport scaffolding # genesis/proto/import
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
// GenesisState defines the tokenbridge module's genesis state.
|
||||
message GenesisState {
|
||||
Config config = 1;
|
||||
repeated ReplayProtection replayProtectionList = 2 [(gogoproto.nullable) = false];
|
||||
repeated ChainRegistration chainRegistrationList = 3 [(gogoproto.nullable) = false];
|
||||
repeated CoinMetaRollbackProtection coinMetaRollbackProtectionList = 4 [(gogoproto.nullable) = false];
|
||||
// this line is used by starport scaffolding # genesis/proto/state
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
import "tokenbridge/config.proto";
|
||||
import "tokenbridge/replay_protection.proto";
|
||||
import "tokenbridge/chain_registration.proto";
|
||||
import "tokenbridge/coin_meta_rollback_protection.proto";
|
||||
// this line is used by starport scaffolding # 1
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
// Query defines the gRPC querier service.
|
||||
service Query {
|
||||
// Queries a config by index.
|
||||
rpc Config(QueryGetConfigRequest) returns (QueryGetConfigResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/config";
|
||||
}
|
||||
// Queries a replayProtection by index.
|
||||
rpc ReplayProtection(QueryGetReplayProtectionRequest) returns (QueryGetReplayProtectionResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/replayProtection/{index}";
|
||||
}
|
||||
|
||||
// Queries a list of replayProtection items.
|
||||
rpc ReplayProtectionAll(QueryAllReplayProtectionRequest) returns (QueryAllReplayProtectionResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/replayProtection";
|
||||
}
|
||||
|
||||
// Queries a chainRegistration by index.
|
||||
rpc ChainRegistration(QueryGetChainRegistrationRequest) returns (QueryGetChainRegistrationResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/chainRegistration/{chainID}";
|
||||
}
|
||||
|
||||
// Queries a list of chainRegistration items.
|
||||
rpc ChainRegistrationAll(QueryAllChainRegistrationRequest) returns (QueryAllChainRegistrationResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/chainRegistration";
|
||||
}
|
||||
|
||||
// Queries a coinMetaRollbackProtection by index.
|
||||
rpc CoinMetaRollbackProtection(QueryGetCoinMetaRollbackProtectionRequest) returns (QueryGetCoinMetaRollbackProtectionResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/coinMetaRollbackProtection/{index}";
|
||||
}
|
||||
|
||||
// Queries a list of coinMetaRollbackProtection items.
|
||||
rpc CoinMetaRollbackProtectionAll(QueryAllCoinMetaRollbackProtectionRequest) returns (QueryAllCoinMetaRollbackProtectionResponse) {
|
||||
option (google.api.http).get = "/wormhole_foundation/wormholechain/tokenbridge/coinMetaRollbackProtection";
|
||||
}
|
||||
|
||||
// this line is used by starport scaffolding # 2
|
||||
}
|
||||
|
||||
message QueryGetConfigRequest {}
|
||||
|
||||
message QueryGetConfigResponse {
|
||||
Config Config = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
message QueryGetReplayProtectionRequest {
|
||||
string index = 1;
|
||||
|
||||
}
|
||||
|
||||
message QueryGetReplayProtectionResponse {
|
||||
ReplayProtection replayProtection = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message QueryAllReplayProtectionRequest {
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
message QueryAllReplayProtectionResponse {
|
||||
repeated ReplayProtection replayProtection = 1 [(gogoproto.nullable) = false];
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
message QueryGetChainRegistrationRequest {
|
||||
uint32 chainID = 1;
|
||||
|
||||
}
|
||||
|
||||
message QueryGetChainRegistrationResponse {
|
||||
ChainRegistration chainRegistration = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message QueryAllChainRegistrationRequest {
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
message QueryAllChainRegistrationResponse {
|
||||
repeated ChainRegistration chainRegistration = 1 [(gogoproto.nullable) = false];
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
message QueryGetCoinMetaRollbackProtectionRequest {
|
||||
string index = 1;
|
||||
|
||||
}
|
||||
|
||||
message QueryGetCoinMetaRollbackProtectionResponse {
|
||||
CoinMetaRollbackProtection coinMetaRollbackProtection = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message QueryAllCoinMetaRollbackProtectionRequest {
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
message QueryAllCoinMetaRollbackProtectionResponse {
|
||||
repeated CoinMetaRollbackProtection coinMetaRollbackProtection = 1 [(gogoproto.nullable) = false];
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// this line is used by starport scaffolding # 3
|
|
@ -1,12 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
|
||||
|
||||
message ReplayProtection {
|
||||
string index = 1;
|
||||
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package wormhole_foundation.wormholechain.tokenbridge;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// this line is used by starport scaffolding # proto/tx/import
|
||||
|
||||
option go_package = "github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types";
|
||||
|
||||
// Msg defines the Msg service.
|
||||
service Msg {
|
||||
rpc ExecuteGovernanceVAA(MsgExecuteGovernanceVAA) returns (MsgExecuteGovernanceVAAResponse);
|
||||
rpc ExecuteVAA(MsgExecuteVAA) returns (MsgExecuteVAAResponse);
|
||||
rpc AttestToken(MsgAttestToken) returns (MsgAttestTokenResponse);
|
||||
rpc Transfer(MsgTransfer) returns (MsgTransferResponse);
|
||||
// this line is used by starport scaffolding # proto/tx/rpc
|
||||
}
|
||||
|
||||
message MsgExecuteGovernanceVAA {
|
||||
string creator = 1;
|
||||
bytes vaa = 2;
|
||||
}
|
||||
|
||||
message MsgExecuteGovernanceVAAResponse {
|
||||
}
|
||||
|
||||
message MsgExecuteVAA {
|
||||
string creator = 1;
|
||||
bytes vaa = 2;
|
||||
}
|
||||
|
||||
message MsgExecuteVAAResponse {
|
||||
}
|
||||
|
||||
message MsgAttestToken {
|
||||
string creator = 1;
|
||||
string denom = 2;
|
||||
}
|
||||
|
||||
message MsgAttestTokenResponse {
|
||||
}
|
||||
|
||||
message MsgTransfer {
|
||||
string creator = 1;
|
||||
cosmos.base.v1beta1.Coin amount = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
uint32 toChain = 3;
|
||||
bytes toAddress = 4;
|
||||
cosmos.base.v1beta1.Coin fee = 5 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
message MsgTransferResponse {
|
||||
}
|
||||
|
||||
// this line is used by starport scaffolding # proto/tx/message
|
|
@ -1,12 +0,0 @@
|
|||
echo "entered CHAIN_REGISTRATION script"
|
||||
cd ./cmd/wormhole-chaind
|
||||
go build main.go
|
||||
# Solana bridge registration
|
||||
./main tx tokenbridge execute-governance-vaa 01000000000100c9f4230109e378f7efc0605fb40f0e1869f2d82fda5b1dfad8a5a2dafee85e033d155c18641165a77a2db6a7afbf2745b458616cb59347e89ae0c7aa3e7cc2d400000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e4272696467650100000001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f --from tiltGuardian --home ../../validators/first_validator --trace --node tcp://localhost:26657 --chain-id wormholechain --yes
|
||||
# Eth bridge
|
||||
./main tx tokenbridge execute-governance-vaa 01000000000100e2e1975d14734206e7a23d90db48a6b5b6696df72675443293c6057dcb936bf224b5df67d32967adeb220d4fe3cb28be515be5608c74aab6adb31099a478db5c01000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e42726964676501000000020000000000000000000000000290fb167208af455bb137780163b7b7a9a10c16 --from tiltGuardian --home ../../validators/first_validator --trace --node tcp://localhost:26657 --chain-id wormholechain --yes
|
||||
#Terra bridge
|
||||
./main tx tokenbridge execute-governance-vaa 010000000001009a895e8b42444fdf60a71666121d7e84b3a49579ba3b84fff1dbdf9ec93360390c05a88f66c90df2034cb38427ba9b01632e780ce7b84df559a1bf44c316447d01000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e4272696467650100000003000000000000000000000000784999135aaa8a3ca5914468852fdddbddd8789d --from tiltGuardian --home ../../validators/first_validator --trace --node tcp://localhost:26657 --chain-id wormholechain --yes
|
||||
#Bsc bridge
|
||||
./main tx tokenbridge execute-governance-vaa 01000000000100719b4ada436f614489dbf87593c38ba9aea35aa7b997387f8ae09f819806f5654c8d45b6b751faa0e809ccbc294794885efa205bd8a046669464c7cbfb03d183010000000100000001000100000000000000000000000000000000000000000000000000000000000000040000000002c8bb0600000000000000000000000000000000000000000000546f6b656e42726964676501000000040000000000000000000000000290fb167208af455bb137780163b7b7a9a10c16 --from tiltGuardian --home ../../validators/first_validator --trace --node tcp://localhost:26657 --chain-id wormholechain --yes
|
||||
exit 0
|
|
@ -1,76 +0,0 @@
|
|||
import { describe, expect, jest, test } from "@jest/globals";
|
||||
import {
|
||||
getAddress,
|
||||
getWallet,
|
||||
getWormchainSigningClient,
|
||||
} from "wormhole-chain-sdk";
|
||||
import { WORM_DENOM, TENDERMINT_URL, TEST_WALLET_MNEMONIC_2 } from "../consts";
|
||||
import { getBalance, getZeroFee } from "../utils/walletHelpers";
|
||||
|
||||
jest.setTimeout(60000);
|
||||
|
||||
describe("Token bridge tests", () => {
|
||||
test("simple VAA redeem", async () => {
|
||||
// try {
|
||||
// const wallet1 = await getWallet(TEST_WALLET_MNEMONIC_1);
|
||||
// const wallet1Address = await getAddress(wallet1);
|
||||
// const wallet1InitialBalance = await getBalance(
|
||||
// WORM_DENOM,
|
||||
// wallet1Address
|
||||
// );
|
||||
// //VAA for 100 worm to this specific wallet
|
||||
// const msg = redeemVaaMsg(TEST_TRANSFER_VAA);
|
||||
// await signSendAndConfirm(wallet1, [msg]);
|
||||
// const wallet1BalanceAfterTransfer = await getBalance(
|
||||
// WORM_DENOM,
|
||||
// wallet1Address
|
||||
// );
|
||||
// expect(wallet1BalanceAfterTransfer - wallet1InitialBalance).toBe(
|
||||
// 100000000
|
||||
// ); //100 worm = 100000000 uworm
|
||||
// } catch (e) {
|
||||
// expect(true).toBe(false);
|
||||
// console.error(e);
|
||||
// }
|
||||
});
|
||||
test("simple transfer out", async () => {
|
||||
try {
|
||||
const wallet2 = await getWallet(TEST_WALLET_MNEMONIC_2);
|
||||
const wallet2Address = await getAddress(wallet2);
|
||||
const wallet2InitialBalance = await getBalance(
|
||||
wallet2Address,
|
||||
WORM_DENOM
|
||||
);
|
||||
//VAA for 100 worm to this specific wallet
|
||||
const client = await getWormchainSigningClient(TENDERMINT_URL, wallet2);
|
||||
|
||||
const msg = client.tokenbridge.msgTransfer({
|
||||
creator: wallet2Address,
|
||||
amount: { amount: "100", denom: WORM_DENOM },
|
||||
toChain: 2,
|
||||
toAddress: new Uint8Array(32),
|
||||
fee: "0",
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
const receipt = await client.signAndBroadcast(
|
||||
wallet2Address,
|
||||
[msg],
|
||||
getZeroFee()
|
||||
);
|
||||
|
||||
const wallet2BalanceAfterTransfer = await getBalance(
|
||||
wallet2Address,
|
||||
WORM_DENOM
|
||||
);
|
||||
console.log("balance before bridge ", wallet2InitialBalance);
|
||||
console.log("balance after bridge ", wallet2BalanceAfterTransfer);
|
||||
expect(
|
||||
parseInt(wallet2InitialBalance) - parseInt(wallet2BalanceAfterTransfer)
|
||||
).toBe(100);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
expect(true).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -91,18 +91,6 @@ async function fullBootstrapProcess() {
|
|||
const guardianSet = response4.data || null;
|
||||
expectEqual("Guardian set 0", guardianSet.GuardianSet?.keys, [TILTNET_GUARDIAN_PUBKEY])
|
||||
|
||||
//bridge in uworm tokens to wallet 2
|
||||
const transferMsg1 = signingClient.tokenbridge.msgExecuteVAA({
|
||||
creator: wallet2Address,
|
||||
vaa: fromHex(TEST_TRANSFER_VAA_1),
|
||||
});
|
||||
const transferreceipt = await signingClient.signAndBroadcast(
|
||||
wallet2Address,
|
||||
[transferMsg1],
|
||||
getZeroFee()
|
||||
);
|
||||
expectTxSuccess("initial bridge redeem VAA", transferreceipt)
|
||||
|
||||
//process upgrade VAA
|
||||
const msg = signingClient.core.msgExecuteGovernanceVAA({
|
||||
signer: await getAddress(wallet2Signer),
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmdb "github.com/tendermint/tm-db"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func TokenbridgeKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
||||
storeKey := sdk.NewKVStoreKey(types.StoreKey)
|
||||
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
|
||||
|
||||
db := tmdb.NewMemDB()
|
||||
stateStore := store.NewCommitMultiStore(db)
|
||||
stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db)
|
||||
stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil)
|
||||
require.NoError(t, stateStore.LoadLatestVersion())
|
||||
|
||||
registry := codectypes.NewInterfaceRegistry()
|
||||
k := keeper.NewKeeper(
|
||||
codec.NewProtoCodec(registry),
|
||||
storeKey,
|
||||
memStoreKey,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
|
||||
return k, ctx
|
||||
}
|
|
@ -10,7 +10,6 @@ import {
|
|||
setupTxExtension,
|
||||
} from "@cosmjs/stargate";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { Api as tokenbridgeApi } from "../modules/certusone.wormholechain.tokenbridge/rest";
|
||||
import { Api as coreApi } from "../modules/certusone.wormholechain.wormhole/rest";
|
||||
import { Api as authApi } from "../modules/cosmos.auth.v1beta1/rest";
|
||||
import { Api as bankApi } from "../modules/cosmos.bank.v1beta1/rest";
|
||||
|
@ -30,7 +29,6 @@ import { Api as vestingApi } from "../modules/cosmos.vesting.v1beta1/rest";
|
|||
|
||||
export type WormchainQueryClient = {
|
||||
core: coreApi<any>;
|
||||
tokenbridge: tokenbridgeApi<any>;
|
||||
auth: authApi<any>;
|
||||
bank: bankApi<any>;
|
||||
base: baseApi<any>;
|
||||
|
@ -58,7 +56,6 @@ export function getWormholeQueryClient(
|
|||
globalThis.fetch = fetch;
|
||||
}
|
||||
const core = new coreApi({ baseUrl: lcdAddress });
|
||||
const tokenbridge = new tokenbridgeApi({ baseUrl: lcdAddress });
|
||||
const auth = new authApi({ baseUrl: lcdAddress });
|
||||
const bank = new bankApi({ baseUrl: lcdAddress });
|
||||
const base = new baseApi({ baseUrl: lcdAddress });
|
||||
|
@ -77,7 +74,6 @@ export function getWormholeQueryClient(
|
|||
|
||||
return {
|
||||
core,
|
||||
tokenbridge,
|
||||
auth,
|
||||
bank,
|
||||
base,
|
||||
|
|
|
@ -26,14 +26,11 @@ import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|||
import {
|
||||
RpcStatus,
|
||||
HttpResponse,
|
||||
} from "../modules/certusone.wormholechain.tokenbridge/rest";
|
||||
} from "../modules/certusone.wormholechain.wormhole/rest";
|
||||
import {
|
||||
txClient,
|
||||
queryClient,
|
||||
} from "../modules/certusone.wormholechain.wormhole";
|
||||
import {
|
||||
txClient as tokenBridgeClient,
|
||||
} from "../modules/certusone.wormholechain.tokenbridge";
|
||||
import { keccak256 } from "ethers/lib/utils";
|
||||
import { MsgRegisterAccountAsGuardian } from "../modules/certusone.wormholechain.wormhole/types/wormhole/tx";
|
||||
import { GuardianKey } from "../modules/certusone.wormholechain.wormhole/types/wormhole/guardian_key";
|
||||
|
@ -92,45 +89,6 @@ export async function getAddress(
|
|||
return address;
|
||||
}
|
||||
|
||||
//TODO recipient chain should be chainID
|
||||
export async function transferTokens(
|
||||
wallet: DirectSecp256k1HdWallet,
|
||||
denom: string,
|
||||
amount: string,
|
||||
recipientAddress: Uint8Array,
|
||||
recipientChain: number,
|
||||
fee: string
|
||||
) {
|
||||
const offline: OfflineSigner = wallet;
|
||||
|
||||
const client = await tokenBridgeClient(offline, { addr: TENDERMINT_URL });
|
||||
const msg: EncodeObject = client.msgTransfer({
|
||||
amount: { amount, denom },
|
||||
toChain: recipientChain,
|
||||
fee: fee,
|
||||
toAddress: recipientAddress,
|
||||
creator: await getAddress(wallet),
|
||||
}); //TODO convert type
|
||||
|
||||
//const output = await client.signAndBroadcast([msg]);
|
||||
|
||||
const signingClient = await SigningStargateClient.connectWithSigner(
|
||||
TENDERMINT_URL,
|
||||
wallet
|
||||
//{ gasPrice: { amount: Decimal.fromUserInput("0.0", 0), denom: "uworm" } }
|
||||
);
|
||||
|
||||
//TODO investigate signing with the stargate client, as the module txClients can't do 100% of the operations
|
||||
const output = signingClient.signAndBroadcast(
|
||||
await getAddress(wallet),
|
||||
[msg],
|
||||
getZeroFee(),
|
||||
"executing governance VAA"
|
||||
);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
export async function executeGovernanceVAA(
|
||||
wallet: DirectSecp256k1HdWallet,
|
||||
hexVaa: string
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
StargateClient,
|
||||
} from "@cosmjs/stargate";
|
||||
import { getTypeParameterOwner } from "typescript";
|
||||
import * as tokenBridgeModule from "../modules/certusone.wormholechain.tokenbridge";
|
||||
import * as coreModule from "../modules/certusone.wormholechain.wormhole";
|
||||
import * as authModule from "../modules/cosmos.auth.v1beta1";
|
||||
import * as bankModule from "../modules/cosmos.bank.v1beta1";
|
||||
|
@ -35,8 +34,6 @@ protobuf.configure();
|
|||
//@ts-ignore
|
||||
const coreTypes = coreModule.registry.types;
|
||||
//@ts-ignore
|
||||
const tokenBridgeTypes = tokenBridgeModule.registry.types;
|
||||
//@ts-ignore
|
||||
const authTypes = authModule.registry.types;
|
||||
//@ts-ignore
|
||||
const bankTypes = bankModule.registry.types;
|
||||
|
@ -69,7 +66,6 @@ const vestingTypes = vestingModule.registry.types;
|
|||
|
||||
const aggregateTypes = [
|
||||
...coreTypes,
|
||||
...tokenBridgeTypes,
|
||||
...authTypes,
|
||||
...bankTypes,
|
||||
...baseTypes,
|
||||
|
@ -102,10 +98,6 @@ export const getWormchainSigningClient = async (
|
|||
addr: tendermintAddress,
|
||||
});
|
||||
|
||||
const tokenBridgeClient = await tokenBridgeModule.txClient(wallet, {
|
||||
addr: tendermintAddress,
|
||||
});
|
||||
|
||||
const authClient = await authModule.txClient(wallet, {
|
||||
addr: tendermintAddress,
|
||||
});
|
||||
|
@ -186,12 +178,6 @@ export const getWormchainSigningClient = async (
|
|||
};
|
||||
delete coreShell.signAndBroadcast;
|
||||
|
||||
const tokenBridgeShell = {
|
||||
...tokenBridgeClient,
|
||||
signAndBroadcast: undefined,
|
||||
};
|
||||
delete tokenBridgeShell.signAndBroadcast;
|
||||
|
||||
const authShell = {
|
||||
...authClient,
|
||||
signAndBroadcast: undefined,
|
||||
|
@ -283,7 +269,6 @@ export const getWormchainSigningClient = async (
|
|||
delete vestingShell.signAndBroadcast;
|
||||
|
||||
type CoreType = Omit<typeof coreShell, "signAndBroadcast">;
|
||||
type TokenBridgeType = Omit<typeof tokenBridgeShell, "signAndBroadcast">;
|
||||
type AuthzType = Omit<typeof authShell, "signAndBroadcast">;
|
||||
type BankType = Omit<typeof bankShell, "signAndBroadcast">;
|
||||
type BaseType = Omit<typeof baseShell, "signAndBroadcast">;
|
||||
|
@ -301,7 +286,6 @@ export const getWormchainSigningClient = async (
|
|||
type VestingType = Omit<typeof vestingShell, "signAndBroadcast">;
|
||||
type WormholeFunctions = {
|
||||
core: CoreType;
|
||||
tokenbridge: TokenBridgeType;
|
||||
auth: AuthzType;
|
||||
bank: BankType;
|
||||
base: BaseType;
|
||||
|
@ -323,7 +307,6 @@ export const getWormchainSigningClient = async (
|
|||
const output: WormholeSigningClient = client as WormholeSigningClient;
|
||||
|
||||
output.core = coreShell;
|
||||
output.tokenbridge = tokenBridgeShell;
|
||||
output.auth = authShell;
|
||||
output.bank = bankShell;
|
||||
output.base = baseShell;
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
//@ts-nocheck
|
||||
// THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY.
|
||||
|
||||
import { StdFee } from "@cosmjs/launchpad";
|
||||
import { SigningStargateClient } from "@cosmjs/stargate";
|
||||
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Api } from "./rest";
|
||||
import { MsgExecuteVAA } from "./types/tokenbridge/tx";
|
||||
import { MsgExecuteGovernanceVAA } from "./types/tokenbridge/tx";
|
||||
import { MsgTransfer } from "./types/tokenbridge/tx";
|
||||
import { MsgAttestToken } from "./types/tokenbridge/tx";
|
||||
|
||||
|
||||
const types = [
|
||||
["/certusone.wormholechain.tokenbridge.MsgExecuteVAA", MsgExecuteVAA],
|
||||
["/certusone.wormholechain.tokenbridge.MsgExecuteGovernanceVAA", MsgExecuteGovernanceVAA],
|
||||
["/certusone.wormholechain.tokenbridge.MsgTransfer", MsgTransfer],
|
||||
["/certusone.wormholechain.tokenbridge.MsgAttestToken", MsgAttestToken],
|
||||
|
||||
];
|
||||
export const MissingWalletError = new Error("wallet is required");
|
||||
|
||||
export const registry = new Registry(<any>types);
|
||||
|
||||
const defaultFee = {
|
||||
amount: [],
|
||||
gas: "200000",
|
||||
};
|
||||
|
||||
interface TxClientOptions {
|
||||
addr: string
|
||||
}
|
||||
|
||||
interface SignAndBroadcastOptions {
|
||||
fee: StdFee,
|
||||
memo?: string
|
||||
}
|
||||
|
||||
const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = { addr: "http://localhost:26657" }) => {
|
||||
if (!wallet) throw MissingWalletError;
|
||||
let client;
|
||||
if (addr) {
|
||||
client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry });
|
||||
}else{
|
||||
client = await SigningStargateClient.offline( wallet, { registry });
|
||||
}
|
||||
const { address } = (await wallet.getAccounts())[0];
|
||||
|
||||
return {
|
||||
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
|
||||
msgExecuteVAA: (data: MsgExecuteVAA): EncodeObject => ({ typeUrl: "/certusone.wormholechain.tokenbridge.MsgExecuteVAA", value: MsgExecuteVAA.fromPartial( data ) }),
|
||||
msgExecuteGovernanceVAA: (data: MsgExecuteGovernanceVAA): EncodeObject => ({ typeUrl: "/certusone.wormholechain.tokenbridge.MsgExecuteGovernanceVAA", value: MsgExecuteGovernanceVAA.fromPartial( data ) }),
|
||||
msgTransfer: (data: MsgTransfer): EncodeObject => ({ typeUrl: "/certusone.wormholechain.tokenbridge.MsgTransfer", value: MsgTransfer.fromPartial( data ) }),
|
||||
msgAttestToken: (data: MsgAttestToken): EncodeObject => ({ typeUrl: "/certusone.wormholechain.tokenbridge.MsgAttestToken", value: MsgAttestToken.fromPartial( data ) }),
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
interface QueryClientOptions {
|
||||
addr: string
|
||||
}
|
||||
|
||||
const queryClient = async ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => {
|
||||
return new Api({ baseUrl: addr });
|
||||
};
|
||||
|
||||
export {
|
||||
txClient,
|
||||
queryClient,
|
||||
};
|
|
@ -1,521 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
/* tslint:disable */
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
||||
* ## ##
|
||||
* ## AUTHOR: acacode ##
|
||||
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
||||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
export interface ProtobufAny {
|
||||
"@type"?: string;
|
||||
}
|
||||
|
||||
export interface RpcStatus {
|
||||
/** @format int32 */
|
||||
code?: number;
|
||||
message?: string;
|
||||
details?: ProtobufAny[];
|
||||
}
|
||||
|
||||
export interface TokenbridgeChainRegistration {
|
||||
/** @format int64 */
|
||||
chainID?: number;
|
||||
|
||||
/** @format byte */
|
||||
emitterAddress?: string;
|
||||
}
|
||||
|
||||
export interface TokenbridgeCoinMetaRollbackProtection {
|
||||
index?: string;
|
||||
|
||||
/** @format uint64 */
|
||||
lastUpdateSequence?: string;
|
||||
}
|
||||
|
||||
export type TokenbridgeConfig = object;
|
||||
|
||||
export type TokenbridgeMsgAttestTokenResponse = object;
|
||||
|
||||
export type TokenbridgeMsgExecuteGovernanceVAAResponse = object;
|
||||
|
||||
export type TokenbridgeMsgExecuteVAAResponse = object;
|
||||
|
||||
export type TokenbridgeMsgTransferResponse = object;
|
||||
|
||||
export interface TokenbridgeQueryAllChainRegistrationResponse {
|
||||
chainRegistration?: TokenbridgeChainRegistration[];
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
pagination?: V1Beta1PageResponse;
|
||||
}
|
||||
|
||||
export interface TokenbridgeQueryAllCoinMetaRollbackProtectionResponse {
|
||||
coinMetaRollbackProtection?: TokenbridgeCoinMetaRollbackProtection[];
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
pagination?: V1Beta1PageResponse;
|
||||
}
|
||||
|
||||
export interface TokenbridgeQueryAllReplayProtectionResponse {
|
||||
replayProtection?: TokenbridgeReplayProtection[];
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
pagination?: V1Beta1PageResponse;
|
||||
}
|
||||
|
||||
export interface TokenbridgeQueryGetChainRegistrationResponse {
|
||||
chainRegistration?: TokenbridgeChainRegistration;
|
||||
}
|
||||
|
||||
export interface TokenbridgeQueryGetCoinMetaRollbackProtectionResponse {
|
||||
coinMetaRollbackProtection?: TokenbridgeCoinMetaRollbackProtection;
|
||||
}
|
||||
|
||||
export interface TokenbridgeQueryGetConfigResponse {
|
||||
Config?: TokenbridgeConfig;
|
||||
}
|
||||
|
||||
export interface TokenbridgeQueryGetReplayProtectionResponse {
|
||||
replayProtection?: TokenbridgeReplayProtection;
|
||||
}
|
||||
|
||||
export interface TokenbridgeReplayProtection {
|
||||
index?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
|
||||
NOTE: The amount field is an Int which implements the custom method
|
||||
signatures required by gogoproto.
|
||||
*/
|
||||
export interface V1Beta1Coin {
|
||||
denom?: string;
|
||||
amount?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* message SomeRequest {
|
||||
Foo some_parameter = 1;
|
||||
PageRequest pagination = 2;
|
||||
}
|
||||
*/
|
||||
export interface V1Beta1PageRequest {
|
||||
/**
|
||||
* key is a value returned in PageResponse.next_key to begin
|
||||
* querying the next page most efficiently. Only one of offset or key
|
||||
* should be set.
|
||||
* @format byte
|
||||
*/
|
||||
key?: string;
|
||||
|
||||
/**
|
||||
* offset is a numeric offset that can be used when key is unavailable.
|
||||
* It is less efficient than using key. Only one of offset or key should
|
||||
* be set.
|
||||
* @format uint64
|
||||
*/
|
||||
offset?: string;
|
||||
|
||||
/**
|
||||
* limit is the total number of results to be returned in the result page.
|
||||
* If left empty it will default to a value to be set by each app.
|
||||
* @format uint64
|
||||
*/
|
||||
limit?: string;
|
||||
|
||||
/**
|
||||
* count_total is set to true to indicate that the result set should include
|
||||
* a count of the total number of items available for pagination in UIs.
|
||||
* count_total is only respected when offset is used. It is ignored when key
|
||||
* is set.
|
||||
*/
|
||||
count_total?: boolean;
|
||||
|
||||
/** reverse is set to true if results are to be returned in the descending order. */
|
||||
reverse?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
corresponding request message has used PageRequest.
|
||||
|
||||
message SomeResponse {
|
||||
repeated Bar results = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
*/
|
||||
export interface V1Beta1PageResponse {
|
||||
/** @format byte */
|
||||
next_key?: string;
|
||||
|
||||
/** @format uint64 */
|
||||
total?: string;
|
||||
}
|
||||
|
||||
export type QueryParamsType = Record<string | number, any>;
|
||||
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
|
||||
|
||||
export interface FullRequestParams extends Omit<RequestInit, "body"> {
|
||||
/** set parameter to `true` for call `securityWorker` for this request */
|
||||
secure?: boolean;
|
||||
/** request path */
|
||||
path: string;
|
||||
/** content type of request body */
|
||||
type?: ContentType;
|
||||
/** query params */
|
||||
query?: QueryParamsType;
|
||||
/** format of response (i.e. response.json() -> format: "json") */
|
||||
format?: keyof Omit<Body, "body" | "bodyUsed">;
|
||||
/** request body */
|
||||
body?: unknown;
|
||||
/** base url */
|
||||
baseUrl?: string;
|
||||
/** request cancellation token */
|
||||
cancelToken?: CancelToken;
|
||||
}
|
||||
|
||||
export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
|
||||
|
||||
export interface ApiConfig<SecurityDataType = unknown> {
|
||||
baseUrl?: string;
|
||||
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
|
||||
securityWorker?: (securityData: SecurityDataType) => RequestParams | void;
|
||||
}
|
||||
|
||||
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
|
||||
data: D;
|
||||
error: E;
|
||||
}
|
||||
|
||||
type CancelToken = Symbol | string | number;
|
||||
|
||||
export enum ContentType {
|
||||
Json = "application/json",
|
||||
FormData = "multipart/form-data",
|
||||
UrlEncoded = "application/x-www-form-urlencoded",
|
||||
}
|
||||
|
||||
export class HttpClient<SecurityDataType = unknown> {
|
||||
public baseUrl: string = "";
|
||||
private securityData: SecurityDataType = null as any;
|
||||
private securityWorker: null | ApiConfig<SecurityDataType>["securityWorker"] = null;
|
||||
private abortControllers = new Map<CancelToken, AbortController>();
|
||||
|
||||
private baseApiParams: RequestParams = {
|
||||
credentials: "same-origin",
|
||||
headers: {},
|
||||
redirect: "follow",
|
||||
referrerPolicy: "no-referrer",
|
||||
};
|
||||
|
||||
constructor(apiConfig: ApiConfig<SecurityDataType> = {}) {
|
||||
Object.assign(this, apiConfig);
|
||||
}
|
||||
|
||||
public setSecurityData = (data: SecurityDataType) => {
|
||||
this.securityData = data;
|
||||
};
|
||||
|
||||
private addQueryParam(query: QueryParamsType, key: string) {
|
||||
const value = query[key];
|
||||
|
||||
return (
|
||||
encodeURIComponent(key) +
|
||||
"=" +
|
||||
encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`)
|
||||
);
|
||||
}
|
||||
|
||||
protected toQueryString(rawQuery?: QueryParamsType): string {
|
||||
const query = rawQuery || {};
|
||||
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
|
||||
return keys
|
||||
.map((key) =>
|
||||
typeof query[key] === "object" && !Array.isArray(query[key])
|
||||
? this.toQueryString(query[key] as QueryParamsType)
|
||||
: this.addQueryParam(query, key),
|
||||
)
|
||||
.join("&");
|
||||
}
|
||||
|
||||
protected addQueryParams(rawQuery?: QueryParamsType): string {
|
||||
const queryString = this.toQueryString(rawQuery);
|
||||
return queryString ? `?${queryString}` : "";
|
||||
}
|
||||
|
||||
private contentFormatters: Record<ContentType, (input: any) => any> = {
|
||||
[ContentType.Json]: (input: any) =>
|
||||
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
|
||||
[ContentType.FormData]: (input: any) =>
|
||||
Object.keys(input || {}).reduce((data, key) => {
|
||||
data.append(key, input[key]);
|
||||
return data;
|
||||
}, new FormData()),
|
||||
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
|
||||
};
|
||||
|
||||
private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams {
|
||||
return {
|
||||
...this.baseApiParams,
|
||||
...params1,
|
||||
...(params2 || {}),
|
||||
headers: {
|
||||
...(this.baseApiParams.headers || {}),
|
||||
...(params1.headers || {}),
|
||||
...((params2 && params2.headers) || {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => {
|
||||
if (this.abortControllers.has(cancelToken)) {
|
||||
const abortController = this.abortControllers.get(cancelToken);
|
||||
if (abortController) {
|
||||
return abortController.signal;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
|
||||
const abortController = new AbortController();
|
||||
this.abortControllers.set(cancelToken, abortController);
|
||||
return abortController.signal;
|
||||
};
|
||||
|
||||
public abortRequest = (cancelToken: CancelToken) => {
|
||||
const abortController = this.abortControllers.get(cancelToken);
|
||||
|
||||
if (abortController) {
|
||||
abortController.abort();
|
||||
this.abortControllers.delete(cancelToken);
|
||||
}
|
||||
};
|
||||
|
||||
public request = <T = any, E = any>({
|
||||
body,
|
||||
secure,
|
||||
path,
|
||||
type,
|
||||
query,
|
||||
format = "json",
|
||||
baseUrl,
|
||||
cancelToken,
|
||||
...params
|
||||
}: FullRequestParams): Promise<HttpResponse<T, E>> => {
|
||||
const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {};
|
||||
const requestParams = this.mergeRequestParams(params, secureParams);
|
||||
const queryString = query && this.toQueryString(query);
|
||||
const payloadFormatter = this.contentFormatters[type || ContentType.Json];
|
||||
|
||||
return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, {
|
||||
...requestParams,
|
||||
headers: {
|
||||
...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}),
|
||||
...(requestParams.headers || {}),
|
||||
},
|
||||
signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
|
||||
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body),
|
||||
}).then(async (response) => {
|
||||
const r = response as HttpResponse<T, E>;
|
||||
r.data = (null as unknown) as T;
|
||||
r.error = (null as unknown) as E;
|
||||
|
||||
const data = await response[format]()
|
||||
.then((data) => {
|
||||
if (r.ok) {
|
||||
r.data = data;
|
||||
} else {
|
||||
r.error = data;
|
||||
}
|
||||
return r;
|
||||
})
|
||||
.catch((e) => {
|
||||
r.error = e;
|
||||
return r;
|
||||
});
|
||||
|
||||
if (cancelToken) {
|
||||
this.abortControllers.delete(cancelToken);
|
||||
}
|
||||
|
||||
if (!response.ok) throw data;
|
||||
return data;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @title tokenbridge/chain_registration.proto
|
||||
* @version version not set
|
||||
*/
|
||||
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryChainRegistrationAll
|
||||
* @summary Queries a list of chainRegistration items.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/chainRegistration
|
||||
*/
|
||||
queryChainRegistrationAll = (
|
||||
query?: {
|
||||
"pagination.key"?: string;
|
||||
"pagination.offset"?: string;
|
||||
"pagination.limit"?: string;
|
||||
"pagination.count_total"?: boolean;
|
||||
"pagination.reverse"?: boolean;
|
||||
},
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
this.request<TokenbridgeQueryAllChainRegistrationResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/chainRegistration`,
|
||||
method: "GET",
|
||||
query: query,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryChainRegistration
|
||||
* @summary Queries a chainRegistration by index.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/chainRegistration/{chainID}
|
||||
*/
|
||||
queryChainRegistration = (chainID: number, params: RequestParams = {}) =>
|
||||
this.request<TokenbridgeQueryGetChainRegistrationResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/chainRegistration/${chainID}`,
|
||||
method: "GET",
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryCoinMetaRollbackProtectionAll
|
||||
* @summary Queries a list of coinMetaRollbackProtection items.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/coinMetaRollbackProtection
|
||||
*/
|
||||
queryCoinMetaRollbackProtectionAll = (
|
||||
query?: {
|
||||
"pagination.key"?: string;
|
||||
"pagination.offset"?: string;
|
||||
"pagination.limit"?: string;
|
||||
"pagination.count_total"?: boolean;
|
||||
"pagination.reverse"?: boolean;
|
||||
},
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
this.request<TokenbridgeQueryAllCoinMetaRollbackProtectionResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/coinMetaRollbackProtection`,
|
||||
method: "GET",
|
||||
query: query,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryCoinMetaRollbackProtection
|
||||
* @summary Queries a coinMetaRollbackProtection by index.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/coinMetaRollbackProtection/{index}
|
||||
*/
|
||||
queryCoinMetaRollbackProtection = (index: string, params: RequestParams = {}) =>
|
||||
this.request<TokenbridgeQueryGetCoinMetaRollbackProtectionResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/coinMetaRollbackProtection/${index}`,
|
||||
method: "GET",
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryConfig
|
||||
* @summary Queries a config by index.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/config
|
||||
*/
|
||||
queryConfig = (params: RequestParams = {}) =>
|
||||
this.request<TokenbridgeQueryGetConfigResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/config`,
|
||||
method: "GET",
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryReplayProtectionAll
|
||||
* @summary Queries a list of replayProtection items.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/replayProtection
|
||||
*/
|
||||
queryReplayProtectionAll = (
|
||||
query?: {
|
||||
"pagination.key"?: string;
|
||||
"pagination.offset"?: string;
|
||||
"pagination.limit"?: string;
|
||||
"pagination.count_total"?: boolean;
|
||||
"pagination.reverse"?: boolean;
|
||||
},
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
this.request<TokenbridgeQueryAllReplayProtectionResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/replayProtection`,
|
||||
method: "GET",
|
||||
query: query,
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
|
||||
/**
|
||||
* No description
|
||||
*
|
||||
* @tags Query
|
||||
* @name QueryReplayProtection
|
||||
* @summary Queries a replayProtection by index.
|
||||
* @request GET:/certusone/wormholechain/tokenbridge/replayProtection/{index}
|
||||
*/
|
||||
queryReplayProtection = (index: string, params: RequestParams = {}) =>
|
||||
this.request<TokenbridgeQueryGetReplayProtectionResponse, RpcStatus>({
|
||||
path: `/certusone/wormholechain/tokenbridge/replayProtection/${index}`,
|
||||
method: "GET",
|
||||
format: "json",
|
||||
...params,
|
||||
});
|
||||
}
|
|
@ -1,325 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import * as Long from "long";
|
||||
import { util, configure, Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.query.v1beta1";
|
||||
|
||||
/**
|
||||
* PageRequest is to be embedded in gRPC request messages for efficient
|
||||
* pagination. Ex:
|
||||
*
|
||||
* message SomeRequest {
|
||||
* Foo some_parameter = 1;
|
||||
* PageRequest pagination = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageRequest {
|
||||
/**
|
||||
* key is a value returned in PageResponse.next_key to begin
|
||||
* querying the next page most efficiently. Only one of offset or key
|
||||
* should be set.
|
||||
*/
|
||||
key: Uint8Array;
|
||||
/**
|
||||
* offset is a numeric offset that can be used when key is unavailable.
|
||||
* It is less efficient than using key. Only one of offset or key should
|
||||
* be set.
|
||||
*/
|
||||
offset: number;
|
||||
/**
|
||||
* limit is the total number of results to be returned in the result page.
|
||||
* If left empty it will default to a value to be set by each app.
|
||||
*/
|
||||
limit: number;
|
||||
/**
|
||||
* count_total is set to true to indicate that the result set should include
|
||||
* a count of the total number of items available for pagination in UIs.
|
||||
* count_total is only respected when offset is used. It is ignored when key
|
||||
* is set.
|
||||
*/
|
||||
count_total: boolean;
|
||||
/** reverse is set to true if results are to be returned in the descending order. */
|
||||
reverse: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageResponse {
|
||||
/**
|
||||
* next_key is the key to be passed to PageRequest.key to
|
||||
* query the next page most efficiently
|
||||
*/
|
||||
next_key: Uint8Array;
|
||||
/**
|
||||
* total is total number of results available if PageRequest.count_total
|
||||
* was set, its value is undefined otherwise
|
||||
*/
|
||||
total: number;
|
||||
}
|
||||
|
||||
const basePageRequest: object = {
|
||||
offset: 0,
|
||||
limit: 0,
|
||||
count_total: false,
|
||||
reverse: false,
|
||||
};
|
||||
|
||||
export const PageRequest = {
|
||||
encode(message: PageRequest, writer: Writer = Writer.create()): Writer {
|
||||
if (message.key.length !== 0) {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
}
|
||||
if (message.offset !== 0) {
|
||||
writer.uint32(16).uint64(message.offset);
|
||||
}
|
||||
if (message.limit !== 0) {
|
||||
writer.uint32(24).uint64(message.limit);
|
||||
}
|
||||
if (message.count_total === true) {
|
||||
writer.uint32(32).bool(message.count_total);
|
||||
}
|
||||
if (message.reverse === true) {
|
||||
writer.uint32(40).bool(message.reverse);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): PageRequest {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.offset = longToNumber(reader.uint64() as Long);
|
||||
break;
|
||||
case 3:
|
||||
message.limit = longToNumber(reader.uint64() as Long);
|
||||
break;
|
||||
case 4:
|
||||
message.count_total = reader.bool();
|
||||
break;
|
||||
case 5:
|
||||
message.reverse = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PageRequest {
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
if (object.offset !== undefined && object.offset !== null) {
|
||||
message.offset = Number(object.offset);
|
||||
} else {
|
||||
message.offset = 0;
|
||||
}
|
||||
if (object.limit !== undefined && object.limit !== null) {
|
||||
message.limit = Number(object.limit);
|
||||
} else {
|
||||
message.limit = 0;
|
||||
}
|
||||
if (object.count_total !== undefined && object.count_total !== null) {
|
||||
message.count_total = Boolean(object.count_total);
|
||||
} else {
|
||||
message.count_total = false;
|
||||
}
|
||||
if (object.reverse !== undefined && object.reverse !== null) {
|
||||
message.reverse = Boolean(object.reverse);
|
||||
} else {
|
||||
message.reverse = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PageRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(
|
||||
message.key !== undefined ? message.key : new Uint8Array()
|
||||
));
|
||||
message.offset !== undefined && (obj.offset = message.offset);
|
||||
message.limit !== undefined && (obj.limit = message.limit);
|
||||
message.count_total !== undefined &&
|
||||
(obj.count_total = message.count_total);
|
||||
message.reverse !== undefined && (obj.reverse = message.reverse);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PageRequest>): PageRequest {
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
if (object.offset !== undefined && object.offset !== null) {
|
||||
message.offset = object.offset;
|
||||
} else {
|
||||
message.offset = 0;
|
||||
}
|
||||
if (object.limit !== undefined && object.limit !== null) {
|
||||
message.limit = object.limit;
|
||||
} else {
|
||||
message.limit = 0;
|
||||
}
|
||||
if (object.count_total !== undefined && object.count_total !== null) {
|
||||
message.count_total = object.count_total;
|
||||
} else {
|
||||
message.count_total = false;
|
||||
}
|
||||
if (object.reverse !== undefined && object.reverse !== null) {
|
||||
message.reverse = object.reverse;
|
||||
} else {
|
||||
message.reverse = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const basePageResponse: object = { total: 0 };
|
||||
|
||||
export const PageResponse = {
|
||||
encode(message: PageResponse, writer: Writer = Writer.create()): Writer {
|
||||
if (message.next_key.length !== 0) {
|
||||
writer.uint32(10).bytes(message.next_key);
|
||||
}
|
||||
if (message.total !== 0) {
|
||||
writer.uint32(16).uint64(message.total);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): PageResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.next_key = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.total = longToNumber(reader.uint64() as Long);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PageResponse {
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
if (object.next_key !== undefined && object.next_key !== null) {
|
||||
message.next_key = bytesFromBase64(object.next_key);
|
||||
}
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
message.total = Number(object.total);
|
||||
} else {
|
||||
message.total = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PageResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.next_key !== undefined &&
|
||||
(obj.next_key = base64FromBytes(
|
||||
message.next_key !== undefined ? message.next_key : new Uint8Array()
|
||||
));
|
||||
message.total !== undefined && (obj.total = message.total);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PageResponse>): PageResponse {
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
if (object.next_key !== undefined && object.next_key !== null) {
|
||||
message.next_key = object.next_key;
|
||||
} else {
|
||||
message.next_key = new Uint8Array();
|
||||
}
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
message.total = object.total;
|
||||
} else {
|
||||
message.total = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
function longToNumber(long: Long): number {
|
||||
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
||||
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
||||
}
|
||||
return long.toNumber();
|
||||
}
|
||||
|
||||
if (util.Long !== Long) {
|
||||
util.Long = Long as any;
|
||||
configure();
|
||||
}
|
|
@ -1,302 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.v1beta1";
|
||||
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
*
|
||||
* NOTE: The amount field is an Int which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface Coin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* DecCoin defines a token with a denomination and a decimal amount.
|
||||
*
|
||||
* NOTE: The amount field is an Dec which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface DecCoin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/** IntProto defines a Protobuf wrapper around an Int object. */
|
||||
export interface IntProto {
|
||||
int: string;
|
||||
}
|
||||
|
||||
/** DecProto defines a Protobuf wrapper around a Dec object. */
|
||||
export interface DecProto {
|
||||
dec: string;
|
||||
}
|
||||
|
||||
const baseCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const Coin = {
|
||||
encode(message: Coin, writer: Writer = Writer.create()): Writer {
|
||||
if (message.denom !== "") {
|
||||
writer.uint32(10).string(message.denom);
|
||||
}
|
||||
if (message.amount !== "") {
|
||||
writer.uint32(18).string(message.amount);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): Coin {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCoin } as Coin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Coin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Coin>): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const DecCoin = {
|
||||
encode(message: DecCoin, writer: Writer = Writer.create()): Writer {
|
||||
if (message.denom !== "") {
|
||||
writer.uint32(10).string(message.denom);
|
||||
}
|
||||
if (message.amount !== "") {
|
||||
writer.uint32(18).string(message.amount);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): DecCoin {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecCoin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecCoin>): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseIntProto: object = { int: "" };
|
||||
|
||||
export const IntProto = {
|
||||
encode(message: IntProto, writer: Writer = Writer.create()): Writer {
|
||||
if (message.int !== "") {
|
||||
writer.uint32(10).string(message.int);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): IntProto {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.int = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = String(object.int);
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: IntProto): unknown {
|
||||
const obj: any = {};
|
||||
message.int !== undefined && (obj.int = message.int);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<IntProto>): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = object.int;
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecProto: object = { dec: "" };
|
||||
|
||||
export const DecProto = {
|
||||
encode(message: DecProto, writer: Writer = Writer.create()): Writer {
|
||||
if (message.dec !== "") {
|
||||
writer.uint32(10).string(message.dec);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): DecProto {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.dec = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = String(object.dec);
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecProto): unknown {
|
||||
const obj: any = {};
|
||||
message.dec !== undefined && (obj.dec = message.dec);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecProto>): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = object.dec;
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
|
@ -1,3 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
export const protobufPackage = "gogoproto";
|
|
@ -1,3 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
export const protobufPackage = "google.api";
|
|
@ -1,707 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "google.api";
|
||||
|
||||
/**
|
||||
* Defines the HTTP configuration for an API service. It contains a list of
|
||||
* [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
|
||||
* to one or more HTTP REST API methods.
|
||||
*/
|
||||
export interface Http {
|
||||
/**
|
||||
* A list of HTTP configuration rules that apply to individual API methods.
|
||||
*
|
||||
* **NOTE:** All service configuration rules follow "last one wins" order.
|
||||
*/
|
||||
rules: HttpRule[];
|
||||
/**
|
||||
* When set to true, URL path parmeters will be fully URI-decoded except in
|
||||
* cases of single segment matches in reserved expansion, where "%2F" will be
|
||||
* left encoded.
|
||||
*
|
||||
* The default behavior is to not decode RFC 6570 reserved characters in multi
|
||||
* segment matches.
|
||||
*/
|
||||
fully_decode_reserved_expansion: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* `HttpRule` defines the mapping of an RPC method to one or more HTTP
|
||||
* REST API methods. The mapping specifies how different portions of the RPC
|
||||
* request message are mapped to URL path, URL query parameters, and
|
||||
* HTTP request body. The mapping is typically specified as an
|
||||
* `google.api.http` annotation on the RPC method,
|
||||
* see "google/api/annotations.proto" for details.
|
||||
*
|
||||
* The mapping consists of a field specifying the path template and
|
||||
* method kind. The path template can refer to fields in the request
|
||||
* message, as in the example below which describes a REST GET
|
||||
* operation on a resource collection of messages:
|
||||
*
|
||||
*
|
||||
* service Messaging {
|
||||
* rpc GetMessage(GetMessageRequest) returns (Message) {
|
||||
* option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}";
|
||||
* }
|
||||
* }
|
||||
* message GetMessageRequest {
|
||||
* message SubMessage {
|
||||
* string subfield = 1;
|
||||
* }
|
||||
* string message_id = 1; // mapped to the URL
|
||||
* SubMessage sub = 2; // `sub.subfield` is url-mapped
|
||||
* }
|
||||
* message Message {
|
||||
* string text = 1; // content of the resource
|
||||
* }
|
||||
*
|
||||
* The same http annotation can alternatively be expressed inside the
|
||||
* `GRPC API Configuration` YAML file.
|
||||
*
|
||||
* http:
|
||||
* rules:
|
||||
* - selector: <proto_package_name>.Messaging.GetMessage
|
||||
* get: /v1/messages/{message_id}/{sub.subfield}
|
||||
*
|
||||
* This definition enables an automatic, bidrectional mapping of HTTP
|
||||
* JSON to RPC. Example:
|
||||
*
|
||||
* HTTP | RPC
|
||||
* -----|-----
|
||||
* `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))`
|
||||
*
|
||||
* In general, not only fields but also field paths can be referenced
|
||||
* from a path pattern. Fields mapped to the path pattern cannot be
|
||||
* repeated and must have a primitive (non-message) type.
|
||||
*
|
||||
* Any fields in the request message which are not bound by the path
|
||||
* pattern automatically become (optional) HTTP query
|
||||
* parameters. Assume the following definition of the request message:
|
||||
*
|
||||
*
|
||||
* service Messaging {
|
||||
* rpc GetMessage(GetMessageRequest) returns (Message) {
|
||||
* option (google.api.http).get = "/v1/messages/{message_id}";
|
||||
* }
|
||||
* }
|
||||
* message GetMessageRequest {
|
||||
* message SubMessage {
|
||||
* string subfield = 1;
|
||||
* }
|
||||
* string message_id = 1; // mapped to the URL
|
||||
* int64 revision = 2; // becomes a parameter
|
||||
* SubMessage sub = 3; // `sub.subfield` becomes a parameter
|
||||
* }
|
||||
*
|
||||
*
|
||||
* This enables a HTTP JSON to RPC mapping as below:
|
||||
*
|
||||
* HTTP | RPC
|
||||
* -----|-----
|
||||
* `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))`
|
||||
*
|
||||
* Note that fields which are mapped to HTTP parameters must have a
|
||||
* primitive type or a repeated primitive type. Message types are not
|
||||
* allowed. In the case of a repeated type, the parameter can be
|
||||
* repeated in the URL, as in `...?param=A¶m=B`.
|
||||
*
|
||||
* For HTTP method kinds which allow a request body, the `body` field
|
||||
* specifies the mapping. Consider a REST update method on the
|
||||
* message resource collection:
|
||||
*
|
||||
*
|
||||
* service Messaging {
|
||||
* rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
|
||||
* option (google.api.http) = {
|
||||
* put: "/v1/messages/{message_id}"
|
||||
* body: "message"
|
||||
* };
|
||||
* }
|
||||
* }
|
||||
* message UpdateMessageRequest {
|
||||
* string message_id = 1; // mapped to the URL
|
||||
* Message message = 2; // mapped to the body
|
||||
* }
|
||||
*
|
||||
*
|
||||
* The following HTTP JSON to RPC mapping is enabled, where the
|
||||
* representation of the JSON in the request body is determined by
|
||||
* protos JSON encoding:
|
||||
*
|
||||
* HTTP | RPC
|
||||
* -----|-----
|
||||
* `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
|
||||
*
|
||||
* The special name `*` can be used in the body mapping to define that
|
||||
* every field not bound by the path template should be mapped to the
|
||||
* request body. This enables the following alternative definition of
|
||||
* the update method:
|
||||
*
|
||||
* service Messaging {
|
||||
* rpc UpdateMessage(Message) returns (Message) {
|
||||
* option (google.api.http) = {
|
||||
* put: "/v1/messages/{message_id}"
|
||||
* body: "*"
|
||||
* };
|
||||
* }
|
||||
* }
|
||||
* message Message {
|
||||
* string message_id = 1;
|
||||
* string text = 2;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* The following HTTP JSON to RPC mapping is enabled:
|
||||
*
|
||||
* HTTP | RPC
|
||||
* -----|-----
|
||||
* `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
|
||||
*
|
||||
* Note that when using `*` in the body mapping, it is not possible to
|
||||
* have HTTP parameters, as all fields not bound by the path end in
|
||||
* the body. This makes this option more rarely used in practice of
|
||||
* defining REST APIs. The common usage of `*` is in custom methods
|
||||
* which don't use the URL at all for transferring data.
|
||||
*
|
||||
* It is possible to define multiple HTTP methods for one RPC by using
|
||||
* the `additional_bindings` option. Example:
|
||||
*
|
||||
* service Messaging {
|
||||
* rpc GetMessage(GetMessageRequest) returns (Message) {
|
||||
* option (google.api.http) = {
|
||||
* get: "/v1/messages/{message_id}"
|
||||
* additional_bindings {
|
||||
* get: "/v1/users/{user_id}/messages/{message_id}"
|
||||
* }
|
||||
* };
|
||||
* }
|
||||
* }
|
||||
* message GetMessageRequest {
|
||||
* string message_id = 1;
|
||||
* string user_id = 2;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* This enables the following two alternative HTTP JSON to RPC
|
||||
* mappings:
|
||||
*
|
||||
* HTTP | RPC
|
||||
* -----|-----
|
||||
* `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
|
||||
* `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
|
||||
*
|
||||
* # Rules for HTTP mapping
|
||||
*
|
||||
* The rules for mapping HTTP path, query parameters, and body fields
|
||||
* to the request message are as follows:
|
||||
*
|
||||
* 1. The `body` field specifies either `*` or a field path, or is
|
||||
* omitted. If omitted, it indicates there is no HTTP request body.
|
||||
* 2. Leaf fields (recursive expansion of nested messages in the
|
||||
* request) can be classified into three types:
|
||||
* (a) Matched in the URL template.
|
||||
* (b) Covered by body (if body is `*`, everything except (a) fields;
|
||||
* else everything under the body field)
|
||||
* (c) All other fields.
|
||||
* 3. URL query parameters found in the HTTP request are mapped to (c) fields.
|
||||
* 4. Any body sent with an HTTP request can contain only (b) fields.
|
||||
*
|
||||
* The syntax of the path template is as follows:
|
||||
*
|
||||
* Template = "/" Segments [ Verb ] ;
|
||||
* Segments = Segment { "/" Segment } ;
|
||||
* Segment = "*" | "**" | LITERAL | Variable ;
|
||||
* Variable = "{" FieldPath [ "=" Segments ] "}" ;
|
||||
* FieldPath = IDENT { "." IDENT } ;
|
||||
* Verb = ":" LITERAL ;
|
||||
*
|
||||
* The syntax `*` matches a single path segment. The syntax `**` matches zero
|
||||
* or more path segments, which must be the last part of the path except the
|
||||
* `Verb`. The syntax `LITERAL` matches literal text in the path.
|
||||
*
|
||||
* The syntax `Variable` matches part of the URL path as specified by its
|
||||
* template. A variable template must not contain other variables. If a variable
|
||||
* matches a single path segment, its template may be omitted, e.g. `{var}`
|
||||
* is equivalent to `{var=*}`.
|
||||
*
|
||||
* If a variable contains exactly one path segment, such as `"{var}"` or
|
||||
* `"{var=*}"`, when such a variable is expanded into a URL path, all characters
|
||||
* except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the
|
||||
* Discovery Document as `{var}`.
|
||||
*
|
||||
* If a variable contains one or more path segments, such as `"{var=foo/*}"`
|
||||
* or `"{var=**}"`, when such a variable is expanded into a URL path, all
|
||||
* characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables
|
||||
* show up in the Discovery Document as `{+var}`.
|
||||
*
|
||||
* NOTE: While the single segment variable matches the semantics of
|
||||
* [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2
|
||||
* Simple String Expansion, the multi segment variable **does not** match
|
||||
* RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion
|
||||
* does not expand special characters like `?` and `#`, which would lead
|
||||
* to invalid URLs.
|
||||
*
|
||||
* NOTE: the field paths in variables and in the `body` must not refer to
|
||||
* repeated fields or map fields.
|
||||
*/
|
||||
export interface HttpRule {
|
||||
/**
|
||||
* Selects methods to which this rule applies.
|
||||
*
|
||||
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
|
||||
*/
|
||||
selector: string;
|
||||
/** Used for listing and getting information about resources. */
|
||||
get: string | undefined;
|
||||
/** Used for updating a resource. */
|
||||
put: string | undefined;
|
||||
/** Used for creating a resource. */
|
||||
post: string | undefined;
|
||||
/** Used for deleting a resource. */
|
||||
delete: string | undefined;
|
||||
/** Used for updating a resource. */
|
||||
patch: string | undefined;
|
||||
/**
|
||||
* The custom pattern is used for specifying an HTTP method that is not
|
||||
* included in the `pattern` field, such as HEAD, or "*" to leave the
|
||||
* HTTP method unspecified for this rule. The wild-card rule is useful
|
||||
* for services that provide content to Web (HTML) clients.
|
||||
*/
|
||||
custom: CustomHttpPattern | undefined;
|
||||
/**
|
||||
* The name of the request field whose value is mapped to the HTTP body, or
|
||||
* `*` for mapping all fields not captured by the path pattern to the HTTP
|
||||
* body. NOTE: the referred field must not be a repeated field and must be
|
||||
* present at the top-level of request message type.
|
||||
*/
|
||||
body: string;
|
||||
/**
|
||||
* Optional. The name of the response field whose value is mapped to the HTTP
|
||||
* body of response. Other response fields are ignored. When
|
||||
* not set, the response message will be used as HTTP body of response.
|
||||
*/
|
||||
response_body: string;
|
||||
/**
|
||||
* Additional HTTP bindings for the selector. Nested bindings must
|
||||
* not contain an `additional_bindings` field themselves (that is,
|
||||
* the nesting may only be one level deep).
|
||||
*/
|
||||
additional_bindings: HttpRule[];
|
||||
}
|
||||
|
||||
/** A custom pattern is used for defining custom HTTP verb. */
|
||||
export interface CustomHttpPattern {
|
||||
/** The name of this custom HTTP verb. */
|
||||
kind: string;
|
||||
/** The path matched by this custom verb. */
|
||||
path: string;
|
||||
}
|
||||
|
||||
const baseHttp: object = { fully_decode_reserved_expansion: false };
|
||||
|
||||
export const Http = {
|
||||
encode(message: Http, writer: Writer = Writer.create()): Writer {
|
||||
for (const v of message.rules) {
|
||||
HttpRule.encode(v!, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.fully_decode_reserved_expansion === true) {
|
||||
writer.uint32(16).bool(message.fully_decode_reserved_expansion);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): Http {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseHttp } as Http;
|
||||
message.rules = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.rules.push(HttpRule.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 2:
|
||||
message.fully_decode_reserved_expansion = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Http {
|
||||
const message = { ...baseHttp } as Http;
|
||||
message.rules = [];
|
||||
if (object.rules !== undefined && object.rules !== null) {
|
||||
for (const e of object.rules) {
|
||||
message.rules.push(HttpRule.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (
|
||||
object.fully_decode_reserved_expansion !== undefined &&
|
||||
object.fully_decode_reserved_expansion !== null
|
||||
) {
|
||||
message.fully_decode_reserved_expansion = Boolean(
|
||||
object.fully_decode_reserved_expansion
|
||||
);
|
||||
} else {
|
||||
message.fully_decode_reserved_expansion = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Http): unknown {
|
||||
const obj: any = {};
|
||||
if (message.rules) {
|
||||
obj.rules = message.rules.map((e) =>
|
||||
e ? HttpRule.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.rules = [];
|
||||
}
|
||||
message.fully_decode_reserved_expansion !== undefined &&
|
||||
(obj.fully_decode_reserved_expansion =
|
||||
message.fully_decode_reserved_expansion);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Http>): Http {
|
||||
const message = { ...baseHttp } as Http;
|
||||
message.rules = [];
|
||||
if (object.rules !== undefined && object.rules !== null) {
|
||||
for (const e of object.rules) {
|
||||
message.rules.push(HttpRule.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (
|
||||
object.fully_decode_reserved_expansion !== undefined &&
|
||||
object.fully_decode_reserved_expansion !== null
|
||||
) {
|
||||
message.fully_decode_reserved_expansion =
|
||||
object.fully_decode_reserved_expansion;
|
||||
} else {
|
||||
message.fully_decode_reserved_expansion = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseHttpRule: object = { selector: "", body: "", response_body: "" };
|
||||
|
||||
export const HttpRule = {
|
||||
encode(message: HttpRule, writer: Writer = Writer.create()): Writer {
|
||||
if (message.selector !== "") {
|
||||
writer.uint32(10).string(message.selector);
|
||||
}
|
||||
if (message.get !== undefined) {
|
||||
writer.uint32(18).string(message.get);
|
||||
}
|
||||
if (message.put !== undefined) {
|
||||
writer.uint32(26).string(message.put);
|
||||
}
|
||||
if (message.post !== undefined) {
|
||||
writer.uint32(34).string(message.post);
|
||||
}
|
||||
if (message.delete !== undefined) {
|
||||
writer.uint32(42).string(message.delete);
|
||||
}
|
||||
if (message.patch !== undefined) {
|
||||
writer.uint32(50).string(message.patch);
|
||||
}
|
||||
if (message.custom !== undefined) {
|
||||
CustomHttpPattern.encode(
|
||||
message.custom,
|
||||
writer.uint32(66).fork()
|
||||
).ldelim();
|
||||
}
|
||||
if (message.body !== "") {
|
||||
writer.uint32(58).string(message.body);
|
||||
}
|
||||
if (message.response_body !== "") {
|
||||
writer.uint32(98).string(message.response_body);
|
||||
}
|
||||
for (const v of message.additional_bindings) {
|
||||
HttpRule.encode(v!, writer.uint32(90).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): HttpRule {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseHttpRule } as HttpRule;
|
||||
message.additional_bindings = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.selector = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.get = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.put = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.post = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.delete = reader.string();
|
||||
break;
|
||||
case 6:
|
||||
message.patch = reader.string();
|
||||
break;
|
||||
case 8:
|
||||
message.custom = CustomHttpPattern.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 7:
|
||||
message.body = reader.string();
|
||||
break;
|
||||
case 12:
|
||||
message.response_body = reader.string();
|
||||
break;
|
||||
case 11:
|
||||
message.additional_bindings.push(
|
||||
HttpRule.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): HttpRule {
|
||||
const message = { ...baseHttpRule } as HttpRule;
|
||||
message.additional_bindings = [];
|
||||
if (object.selector !== undefined && object.selector !== null) {
|
||||
message.selector = String(object.selector);
|
||||
} else {
|
||||
message.selector = "";
|
||||
}
|
||||
if (object.get !== undefined && object.get !== null) {
|
||||
message.get = String(object.get);
|
||||
} else {
|
||||
message.get = undefined;
|
||||
}
|
||||
if (object.put !== undefined && object.put !== null) {
|
||||
message.put = String(object.put);
|
||||
} else {
|
||||
message.put = undefined;
|
||||
}
|
||||
if (object.post !== undefined && object.post !== null) {
|
||||
message.post = String(object.post);
|
||||
} else {
|
||||
message.post = undefined;
|
||||
}
|
||||
if (object.delete !== undefined && object.delete !== null) {
|
||||
message.delete = String(object.delete);
|
||||
} else {
|
||||
message.delete = undefined;
|
||||
}
|
||||
if (object.patch !== undefined && object.patch !== null) {
|
||||
message.patch = String(object.patch);
|
||||
} else {
|
||||
message.patch = undefined;
|
||||
}
|
||||
if (object.custom !== undefined && object.custom !== null) {
|
||||
message.custom = CustomHttpPattern.fromJSON(object.custom);
|
||||
} else {
|
||||
message.custom = undefined;
|
||||
}
|
||||
if (object.body !== undefined && object.body !== null) {
|
||||
message.body = String(object.body);
|
||||
} else {
|
||||
message.body = "";
|
||||
}
|
||||
if (object.response_body !== undefined && object.response_body !== null) {
|
||||
message.response_body = String(object.response_body);
|
||||
} else {
|
||||
message.response_body = "";
|
||||
}
|
||||
if (
|
||||
object.additional_bindings !== undefined &&
|
||||
object.additional_bindings !== null
|
||||
) {
|
||||
for (const e of object.additional_bindings) {
|
||||
message.additional_bindings.push(HttpRule.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: HttpRule): unknown {
|
||||
const obj: any = {};
|
||||
message.selector !== undefined && (obj.selector = message.selector);
|
||||
message.get !== undefined && (obj.get = message.get);
|
||||
message.put !== undefined && (obj.put = message.put);
|
||||
message.post !== undefined && (obj.post = message.post);
|
||||
message.delete !== undefined && (obj.delete = message.delete);
|
||||
message.patch !== undefined && (obj.patch = message.patch);
|
||||
message.custom !== undefined &&
|
||||
(obj.custom = message.custom
|
||||
? CustomHttpPattern.toJSON(message.custom)
|
||||
: undefined);
|
||||
message.body !== undefined && (obj.body = message.body);
|
||||
message.response_body !== undefined &&
|
||||
(obj.response_body = message.response_body);
|
||||
if (message.additional_bindings) {
|
||||
obj.additional_bindings = message.additional_bindings.map((e) =>
|
||||
e ? HttpRule.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.additional_bindings = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<HttpRule>): HttpRule {
|
||||
const message = { ...baseHttpRule } as HttpRule;
|
||||
message.additional_bindings = [];
|
||||
if (object.selector !== undefined && object.selector !== null) {
|
||||
message.selector = object.selector;
|
||||
} else {
|
||||
message.selector = "";
|
||||
}
|
||||
if (object.get !== undefined && object.get !== null) {
|
||||
message.get = object.get;
|
||||
} else {
|
||||
message.get = undefined;
|
||||
}
|
||||
if (object.put !== undefined && object.put !== null) {
|
||||
message.put = object.put;
|
||||
} else {
|
||||
message.put = undefined;
|
||||
}
|
||||
if (object.post !== undefined && object.post !== null) {
|
||||
message.post = object.post;
|
||||
} else {
|
||||
message.post = undefined;
|
||||
}
|
||||
if (object.delete !== undefined && object.delete !== null) {
|
||||
message.delete = object.delete;
|
||||
} else {
|
||||
message.delete = undefined;
|
||||
}
|
||||
if (object.patch !== undefined && object.patch !== null) {
|
||||
message.patch = object.patch;
|
||||
} else {
|
||||
message.patch = undefined;
|
||||
}
|
||||
if (object.custom !== undefined && object.custom !== null) {
|
||||
message.custom = CustomHttpPattern.fromPartial(object.custom);
|
||||
} else {
|
||||
message.custom = undefined;
|
||||
}
|
||||
if (object.body !== undefined && object.body !== null) {
|
||||
message.body = object.body;
|
||||
} else {
|
||||
message.body = "";
|
||||
}
|
||||
if (object.response_body !== undefined && object.response_body !== null) {
|
||||
message.response_body = object.response_body;
|
||||
} else {
|
||||
message.response_body = "";
|
||||
}
|
||||
if (
|
||||
object.additional_bindings !== undefined &&
|
||||
object.additional_bindings !== null
|
||||
) {
|
||||
for (const e of object.additional_bindings) {
|
||||
message.additional_bindings.push(HttpRule.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseCustomHttpPattern: object = { kind: "", path: "" };
|
||||
|
||||
export const CustomHttpPattern = {
|
||||
encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer {
|
||||
if (message.kind !== "") {
|
||||
writer.uint32(10).string(message.kind);
|
||||
}
|
||||
if (message.path !== "") {
|
||||
writer.uint32(18).string(message.path);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCustomHttpPattern } as CustomHttpPattern;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.kind = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.path = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): CustomHttpPattern {
|
||||
const message = { ...baseCustomHttpPattern } as CustomHttpPattern;
|
||||
if (object.kind !== undefined && object.kind !== null) {
|
||||
message.kind = String(object.kind);
|
||||
} else {
|
||||
message.kind = "";
|
||||
}
|
||||
if (object.path !== undefined && object.path !== null) {
|
||||
message.path = String(object.path);
|
||||
} else {
|
||||
message.path = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: CustomHttpPattern): unknown {
|
||||
const obj: any = {};
|
||||
message.kind !== undefined && (obj.kind = message.kind);
|
||||
message.path !== undefined && (obj.path = message.path);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<CustomHttpPattern>): CustomHttpPattern {
|
||||
const message = { ...baseCustomHttpPattern } as CustomHttpPattern;
|
||||
if (object.kind !== undefined && object.kind !== null) {
|
||||
message.kind = object.kind;
|
||||
} else {
|
||||
message.kind = "";
|
||||
}
|
||||
if (object.path !== undefined && object.path !== null) {
|
||||
message.path = object.path;
|
||||
} else {
|
||||
message.path = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
File diff suppressed because it is too large
Load Diff
|
@ -1,129 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
export interface ChainRegistration {
|
||||
chainID: number;
|
||||
emitterAddress: Uint8Array;
|
||||
}
|
||||
|
||||
const baseChainRegistration: object = { chainID: 0 };
|
||||
|
||||
export const ChainRegistration = {
|
||||
encode(message: ChainRegistration, writer: Writer = Writer.create()): Writer {
|
||||
if (message.chainID !== 0) {
|
||||
writer.uint32(8).uint32(message.chainID);
|
||||
}
|
||||
if (message.emitterAddress.length !== 0) {
|
||||
writer.uint32(18).bytes(message.emitterAddress);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): ChainRegistration {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseChainRegistration } as ChainRegistration;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.chainID = reader.uint32();
|
||||
break;
|
||||
case 2:
|
||||
message.emitterAddress = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ChainRegistration {
|
||||
const message = { ...baseChainRegistration } as ChainRegistration;
|
||||
if (object.chainID !== undefined && object.chainID !== null) {
|
||||
message.chainID = Number(object.chainID);
|
||||
} else {
|
||||
message.chainID = 0;
|
||||
}
|
||||
if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
|
||||
message.emitterAddress = bytesFromBase64(object.emitterAddress);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ChainRegistration): unknown {
|
||||
const obj: any = {};
|
||||
message.chainID !== undefined && (obj.chainID = message.chainID);
|
||||
message.emitterAddress !== undefined &&
|
||||
(obj.emitterAddress = base64FromBytes(
|
||||
message.emitterAddress !== undefined
|
||||
? message.emitterAddress
|
||||
: new Uint8Array()
|
||||
));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ChainRegistration>): ChainRegistration {
|
||||
const message = { ...baseChainRegistration } as ChainRegistration;
|
||||
if (object.chainID !== undefined && object.chainID !== null) {
|
||||
message.chainID = object.chainID;
|
||||
} else {
|
||||
message.chainID = 0;
|
||||
}
|
||||
if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
|
||||
message.emitterAddress = object.emitterAddress;
|
||||
} else {
|
||||
message.emitterAddress = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
|
@ -1,140 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import * as Long from "long";
|
||||
import { util, configure, Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
export interface CoinMetaRollbackProtection {
|
||||
index: string;
|
||||
lastUpdateSequence: number;
|
||||
}
|
||||
|
||||
const baseCoinMetaRollbackProtection: object = {
|
||||
index: "",
|
||||
lastUpdateSequence: 0,
|
||||
};
|
||||
|
||||
export const CoinMetaRollbackProtection = {
|
||||
encode(
|
||||
message: CoinMetaRollbackProtection,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
if (message.index !== "") {
|
||||
writer.uint32(10).string(message.index);
|
||||
}
|
||||
if (message.lastUpdateSequence !== 0) {
|
||||
writer.uint32(16).uint64(message.lastUpdateSequence);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: Reader | Uint8Array,
|
||||
length?: number
|
||||
): CoinMetaRollbackProtection {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = {
|
||||
...baseCoinMetaRollbackProtection,
|
||||
} as CoinMetaRollbackProtection;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.index = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.lastUpdateSequence = longToNumber(reader.uint64() as Long);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): CoinMetaRollbackProtection {
|
||||
const message = {
|
||||
...baseCoinMetaRollbackProtection,
|
||||
} as CoinMetaRollbackProtection;
|
||||
if (object.index !== undefined && object.index !== null) {
|
||||
message.index = String(object.index);
|
||||
} else {
|
||||
message.index = "";
|
||||
}
|
||||
if (
|
||||
object.lastUpdateSequence !== undefined &&
|
||||
object.lastUpdateSequence !== null
|
||||
) {
|
||||
message.lastUpdateSequence = Number(object.lastUpdateSequence);
|
||||
} else {
|
||||
message.lastUpdateSequence = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: CoinMetaRollbackProtection): unknown {
|
||||
const obj: any = {};
|
||||
message.index !== undefined && (obj.index = message.index);
|
||||
message.lastUpdateSequence !== undefined &&
|
||||
(obj.lastUpdateSequence = message.lastUpdateSequence);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(
|
||||
object: DeepPartial<CoinMetaRollbackProtection>
|
||||
): CoinMetaRollbackProtection {
|
||||
const message = {
|
||||
...baseCoinMetaRollbackProtection,
|
||||
} as CoinMetaRollbackProtection;
|
||||
if (object.index !== undefined && object.index !== null) {
|
||||
message.index = object.index;
|
||||
} else {
|
||||
message.index = "";
|
||||
}
|
||||
if (
|
||||
object.lastUpdateSequence !== undefined &&
|
||||
object.lastUpdateSequence !== null
|
||||
) {
|
||||
message.lastUpdateSequence = object.lastUpdateSequence;
|
||||
} else {
|
||||
message.lastUpdateSequence = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
function longToNumber(long: Long): number {
|
||||
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
||||
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
||||
}
|
||||
return long.toNumber();
|
||||
}
|
||||
|
||||
if (util.Long !== Long) {
|
||||
util.Long = Long as any;
|
||||
configure();
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
export interface Config {}
|
||||
|
||||
const baseConfig: object = {};
|
||||
|
||||
export const Config = {
|
||||
encode(_: Config, writer: Writer = Writer.create()): Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): Config {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseConfig } as Config;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): Config {
|
||||
const message = { ...baseConfig } as Config;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: Config): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<Config>): Config {
|
||||
const message = { ...baseConfig } as Config;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
|
@ -1,468 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
export interface EventChainRegistered {
|
||||
chainID: number;
|
||||
emitterAddress: Uint8Array;
|
||||
}
|
||||
|
||||
export interface EventAssetRegistrationUpdate {
|
||||
tokenChain: number;
|
||||
tokenAddress: Uint8Array;
|
||||
name: string;
|
||||
symbol: string;
|
||||
decimals: number;
|
||||
}
|
||||
|
||||
export interface EventTransferReceived {
|
||||
tokenChain: number;
|
||||
tokenAddress: Uint8Array;
|
||||
to: string;
|
||||
feeRecipient: string;
|
||||
amount: string;
|
||||
fee: string;
|
||||
localDenom: string;
|
||||
}
|
||||
|
||||
const baseEventChainRegistered: object = { chainID: 0 };
|
||||
|
||||
export const EventChainRegistered = {
|
||||
encode(
|
||||
message: EventChainRegistered,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
if (message.chainID !== 0) {
|
||||
writer.uint32(8).uint32(message.chainID);
|
||||
}
|
||||
if (message.emitterAddress.length !== 0) {
|
||||
writer.uint32(18).bytes(message.emitterAddress);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): EventChainRegistered {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseEventChainRegistered } as EventChainRegistered;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.chainID = reader.uint32();
|
||||
break;
|
||||
case 2:
|
||||
message.emitterAddress = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): EventChainRegistered {
|
||||
const message = { ...baseEventChainRegistered } as EventChainRegistered;
|
||||
if (object.chainID !== undefined && object.chainID !== null) {
|
||||
message.chainID = Number(object.chainID);
|
||||
} else {
|
||||
message.chainID = 0;
|
||||
}
|
||||
if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
|
||||
message.emitterAddress = bytesFromBase64(object.emitterAddress);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: EventChainRegistered): unknown {
|
||||
const obj: any = {};
|
||||
message.chainID !== undefined && (obj.chainID = message.chainID);
|
||||
message.emitterAddress !== undefined &&
|
||||
(obj.emitterAddress = base64FromBytes(
|
||||
message.emitterAddress !== undefined
|
||||
? message.emitterAddress
|
||||
: new Uint8Array()
|
||||
));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<EventChainRegistered>): EventChainRegistered {
|
||||
const message = { ...baseEventChainRegistered } as EventChainRegistered;
|
||||
if (object.chainID !== undefined && object.chainID !== null) {
|
||||
message.chainID = object.chainID;
|
||||
} else {
|
||||
message.chainID = 0;
|
||||
}
|
||||
if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
|
||||
message.emitterAddress = object.emitterAddress;
|
||||
} else {
|
||||
message.emitterAddress = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseEventAssetRegistrationUpdate: object = {
|
||||
tokenChain: 0,
|
||||
name: "",
|
||||
symbol: "",
|
||||
decimals: 0,
|
||||
};
|
||||
|
||||
export const EventAssetRegistrationUpdate = {
|
||||
encode(
|
||||
message: EventAssetRegistrationUpdate,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
if (message.tokenChain !== 0) {
|
||||
writer.uint32(8).uint32(message.tokenChain);
|
||||
}
|
||||
if (message.tokenAddress.length !== 0) {
|
||||
writer.uint32(18).bytes(message.tokenAddress);
|
||||
}
|
||||
if (message.name !== "") {
|
||||
writer.uint32(26).string(message.name);
|
||||
}
|
||||
if (message.symbol !== "") {
|
||||
writer.uint32(34).string(message.symbol);
|
||||
}
|
||||
if (message.decimals !== 0) {
|
||||
writer.uint32(40).uint32(message.decimals);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: Reader | Uint8Array,
|
||||
length?: number
|
||||
): EventAssetRegistrationUpdate {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = {
|
||||
...baseEventAssetRegistrationUpdate,
|
||||
} as EventAssetRegistrationUpdate;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.tokenChain = reader.uint32();
|
||||
break;
|
||||
case 2:
|
||||
message.tokenAddress = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
message.name = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.symbol = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.decimals = reader.uint32();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): EventAssetRegistrationUpdate {
|
||||
const message = {
|
||||
...baseEventAssetRegistrationUpdate,
|
||||
} as EventAssetRegistrationUpdate;
|
||||
if (object.tokenChain !== undefined && object.tokenChain !== null) {
|
||||
message.tokenChain = Number(object.tokenChain);
|
||||
} else {
|
||||
message.tokenChain = 0;
|
||||
}
|
||||
if (object.tokenAddress !== undefined && object.tokenAddress !== null) {
|
||||
message.tokenAddress = bytesFromBase64(object.tokenAddress);
|
||||
}
|
||||
if (object.name !== undefined && object.name !== null) {
|
||||
message.name = String(object.name);
|
||||
} else {
|
||||
message.name = "";
|
||||
}
|
||||
if (object.symbol !== undefined && object.symbol !== null) {
|
||||
message.symbol = String(object.symbol);
|
||||
} else {
|
||||
message.symbol = "";
|
||||
}
|
||||
if (object.decimals !== undefined && object.decimals !== null) {
|
||||
message.decimals = Number(object.decimals);
|
||||
} else {
|
||||
message.decimals = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: EventAssetRegistrationUpdate): unknown {
|
||||
const obj: any = {};
|
||||
message.tokenChain !== undefined && (obj.tokenChain = message.tokenChain);
|
||||
message.tokenAddress !== undefined &&
|
||||
(obj.tokenAddress = base64FromBytes(
|
||||
message.tokenAddress !== undefined
|
||||
? message.tokenAddress
|
||||
: new Uint8Array()
|
||||
));
|
||||
message.name !== undefined && (obj.name = message.name);
|
||||
message.symbol !== undefined && (obj.symbol = message.symbol);
|
||||
message.decimals !== undefined && (obj.decimals = message.decimals);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(
|
||||
object: DeepPartial<EventAssetRegistrationUpdate>
|
||||
): EventAssetRegistrationUpdate {
|
||||
const message = {
|
||||
...baseEventAssetRegistrationUpdate,
|
||||
} as EventAssetRegistrationUpdate;
|
||||
if (object.tokenChain !== undefined && object.tokenChain !== null) {
|
||||
message.tokenChain = object.tokenChain;
|
||||
} else {
|
||||
message.tokenChain = 0;
|
||||
}
|
||||
if (object.tokenAddress !== undefined && object.tokenAddress !== null) {
|
||||
message.tokenAddress = object.tokenAddress;
|
||||
} else {
|
||||
message.tokenAddress = new Uint8Array();
|
||||
}
|
||||
if (object.name !== undefined && object.name !== null) {
|
||||
message.name = object.name;
|
||||
} else {
|
||||
message.name = "";
|
||||
}
|
||||
if (object.symbol !== undefined && object.symbol !== null) {
|
||||
message.symbol = object.symbol;
|
||||
} else {
|
||||
message.symbol = "";
|
||||
}
|
||||
if (object.decimals !== undefined && object.decimals !== null) {
|
||||
message.decimals = object.decimals;
|
||||
} else {
|
||||
message.decimals = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseEventTransferReceived: object = {
|
||||
tokenChain: 0,
|
||||
to: "",
|
||||
feeRecipient: "",
|
||||
amount: "",
|
||||
fee: "",
|
||||
localDenom: "",
|
||||
};
|
||||
|
||||
export const EventTransferReceived = {
|
||||
encode(
|
||||
message: EventTransferReceived,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
if (message.tokenChain !== 0) {
|
||||
writer.uint32(8).uint32(message.tokenChain);
|
||||
}
|
||||
if (message.tokenAddress.length !== 0) {
|
||||
writer.uint32(18).bytes(message.tokenAddress);
|
||||
}
|
||||
if (message.to !== "") {
|
||||
writer.uint32(26).string(message.to);
|
||||
}
|
||||
if (message.feeRecipient !== "") {
|
||||
writer.uint32(34).string(message.feeRecipient);
|
||||
}
|
||||
if (message.amount !== "") {
|
||||
writer.uint32(42).string(message.amount);
|
||||
}
|
||||
if (message.fee !== "") {
|
||||
writer.uint32(50).string(message.fee);
|
||||
}
|
||||
if (message.localDenom !== "") {
|
||||
writer.uint32(58).string(message.localDenom);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): EventTransferReceived {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseEventTransferReceived } as EventTransferReceived;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.tokenChain = reader.uint32();
|
||||
break;
|
||||
case 2:
|
||||
message.tokenAddress = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
message.to = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.feeRecipient = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
case 6:
|
||||
message.fee = reader.string();
|
||||
break;
|
||||
case 7:
|
||||
message.localDenom = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): EventTransferReceived {
|
||||
const message = { ...baseEventTransferReceived } as EventTransferReceived;
|
||||
if (object.tokenChain !== undefined && object.tokenChain !== null) {
|
||||
message.tokenChain = Number(object.tokenChain);
|
||||
} else {
|
||||
message.tokenChain = 0;
|
||||
}
|
||||
if (object.tokenAddress !== undefined && object.tokenAddress !== null) {
|
||||
message.tokenAddress = bytesFromBase64(object.tokenAddress);
|
||||
}
|
||||
if (object.to !== undefined && object.to !== null) {
|
||||
message.to = String(object.to);
|
||||
} else {
|
||||
message.to = "";
|
||||
}
|
||||
if (object.feeRecipient !== undefined && object.feeRecipient !== null) {
|
||||
message.feeRecipient = String(object.feeRecipient);
|
||||
} else {
|
||||
message.feeRecipient = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
if (object.fee !== undefined && object.fee !== null) {
|
||||
message.fee = String(object.fee);
|
||||
} else {
|
||||
message.fee = "";
|
||||
}
|
||||
if (object.localDenom !== undefined && object.localDenom !== null) {
|
||||
message.localDenom = String(object.localDenom);
|
||||
} else {
|
||||
message.localDenom = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: EventTransferReceived): unknown {
|
||||
const obj: any = {};
|
||||
message.tokenChain !== undefined && (obj.tokenChain = message.tokenChain);
|
||||
message.tokenAddress !== undefined &&
|
||||
(obj.tokenAddress = base64FromBytes(
|
||||
message.tokenAddress !== undefined
|
||||
? message.tokenAddress
|
||||
: new Uint8Array()
|
||||
));
|
||||
message.to !== undefined && (obj.to = message.to);
|
||||
message.feeRecipient !== undefined &&
|
||||
(obj.feeRecipient = message.feeRecipient);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
message.fee !== undefined && (obj.fee = message.fee);
|
||||
message.localDenom !== undefined && (obj.localDenom = message.localDenom);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(
|
||||
object: DeepPartial<EventTransferReceived>
|
||||
): EventTransferReceived {
|
||||
const message = { ...baseEventTransferReceived } as EventTransferReceived;
|
||||
if (object.tokenChain !== undefined && object.tokenChain !== null) {
|
||||
message.tokenChain = object.tokenChain;
|
||||
} else {
|
||||
message.tokenChain = 0;
|
||||
}
|
||||
if (object.tokenAddress !== undefined && object.tokenAddress !== null) {
|
||||
message.tokenAddress = object.tokenAddress;
|
||||
} else {
|
||||
message.tokenAddress = new Uint8Array();
|
||||
}
|
||||
if (object.to !== undefined && object.to !== null) {
|
||||
message.to = object.to;
|
||||
} else {
|
||||
message.to = "";
|
||||
}
|
||||
if (object.feeRecipient !== undefined && object.feeRecipient !== null) {
|
||||
message.feeRecipient = object.feeRecipient;
|
||||
} else {
|
||||
message.feeRecipient = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
if (object.fee !== undefined && object.fee !== null) {
|
||||
message.fee = object.fee;
|
||||
} else {
|
||||
message.fee = "";
|
||||
}
|
||||
if (object.localDenom !== undefined && object.localDenom !== null) {
|
||||
message.localDenom = object.localDenom;
|
||||
} else {
|
||||
message.localDenom = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
|
@ -1,191 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Config } from "../tokenbridge/config";
|
||||
import { ReplayProtection } from "../tokenbridge/replay_protection";
|
||||
import { ChainRegistration } from "../tokenbridge/chain_registration";
|
||||
import { CoinMetaRollbackProtection } from "../tokenbridge/coin_meta_rollback_protection";
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
/** GenesisState defines the tokenbridge module's genesis state. */
|
||||
export interface GenesisState {
|
||||
config: Config | undefined;
|
||||
replayProtectionList: ReplayProtection[];
|
||||
chainRegistrationList: ChainRegistration[];
|
||||
/** this line is used by starport scaffolding # genesis/proto/state */
|
||||
coinMetaRollbackProtectionList: CoinMetaRollbackProtection[];
|
||||
}
|
||||
|
||||
const baseGenesisState: object = {};
|
||||
|
||||
export const GenesisState = {
|
||||
encode(message: GenesisState, writer: Writer = Writer.create()): Writer {
|
||||
if (message.config !== undefined) {
|
||||
Config.encode(message.config, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.replayProtectionList) {
|
||||
ReplayProtection.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.chainRegistrationList) {
|
||||
ChainRegistration.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.coinMetaRollbackProtectionList) {
|
||||
CoinMetaRollbackProtection.encode(v!, writer.uint32(34).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): GenesisState {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseGenesisState } as GenesisState;
|
||||
message.replayProtectionList = [];
|
||||
message.chainRegistrationList = [];
|
||||
message.coinMetaRollbackProtectionList = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.config = Config.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.replayProtectionList.push(
|
||||
ReplayProtection.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
message.chainRegistrationList.push(
|
||||
ChainRegistration.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
message.coinMetaRollbackProtectionList.push(
|
||||
CoinMetaRollbackProtection.decode(reader, reader.uint32())
|
||||
);
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): GenesisState {
|
||||
const message = { ...baseGenesisState } as GenesisState;
|
||||
message.replayProtectionList = [];
|
||||
message.chainRegistrationList = [];
|
||||
message.coinMetaRollbackProtectionList = [];
|
||||
if (object.config !== undefined && object.config !== null) {
|
||||
message.config = Config.fromJSON(object.config);
|
||||
} else {
|
||||
message.config = undefined;
|
||||
}
|
||||
if (
|
||||
object.replayProtectionList !== undefined &&
|
||||
object.replayProtectionList !== null
|
||||
) {
|
||||
for (const e of object.replayProtectionList) {
|
||||
message.replayProtectionList.push(ReplayProtection.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (
|
||||
object.chainRegistrationList !== undefined &&
|
||||
object.chainRegistrationList !== null
|
||||
) {
|
||||
for (const e of object.chainRegistrationList) {
|
||||
message.chainRegistrationList.push(ChainRegistration.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (
|
||||
object.coinMetaRollbackProtectionList !== undefined &&
|
||||
object.coinMetaRollbackProtectionList !== null
|
||||
) {
|
||||
for (const e of object.coinMetaRollbackProtectionList) {
|
||||
message.coinMetaRollbackProtectionList.push(
|
||||
CoinMetaRollbackProtection.fromJSON(e)
|
||||
);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: GenesisState): unknown {
|
||||
const obj: any = {};
|
||||
message.config !== undefined &&
|
||||
(obj.config = message.config ? Config.toJSON(message.config) : undefined);
|
||||
if (message.replayProtectionList) {
|
||||
obj.replayProtectionList = message.replayProtectionList.map((e) =>
|
||||
e ? ReplayProtection.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.replayProtectionList = [];
|
||||
}
|
||||
if (message.chainRegistrationList) {
|
||||
obj.chainRegistrationList = message.chainRegistrationList.map((e) =>
|
||||
e ? ChainRegistration.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.chainRegistrationList = [];
|
||||
}
|
||||
if (message.coinMetaRollbackProtectionList) {
|
||||
obj.coinMetaRollbackProtectionList = message.coinMetaRollbackProtectionList.map(
|
||||
(e) => (e ? CoinMetaRollbackProtection.toJSON(e) : undefined)
|
||||
);
|
||||
} else {
|
||||
obj.coinMetaRollbackProtectionList = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
|
||||
const message = { ...baseGenesisState } as GenesisState;
|
||||
message.replayProtectionList = [];
|
||||
message.chainRegistrationList = [];
|
||||
message.coinMetaRollbackProtectionList = [];
|
||||
if (object.config !== undefined && object.config !== null) {
|
||||
message.config = Config.fromPartial(object.config);
|
||||
} else {
|
||||
message.config = undefined;
|
||||
}
|
||||
if (
|
||||
object.replayProtectionList !== undefined &&
|
||||
object.replayProtectionList !== null
|
||||
) {
|
||||
for (const e of object.replayProtectionList) {
|
||||
message.replayProtectionList.push(ReplayProtection.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (
|
||||
object.chainRegistrationList !== undefined &&
|
||||
object.chainRegistrationList !== null
|
||||
) {
|
||||
for (const e of object.chainRegistrationList) {
|
||||
message.chainRegistrationList.push(ChainRegistration.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (
|
||||
object.coinMetaRollbackProtectionList !== undefined &&
|
||||
object.coinMetaRollbackProtectionList !== null
|
||||
) {
|
||||
for (const e of object.coinMetaRollbackProtectionList) {
|
||||
message.coinMetaRollbackProtectionList.push(
|
||||
CoinMetaRollbackProtection.fromPartial(e)
|
||||
);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
File diff suppressed because it is too large
Load Diff
|
@ -1,75 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Writer, Reader } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
export interface ReplayProtection {
|
||||
index: string;
|
||||
}
|
||||
|
||||
const baseReplayProtection: object = { index: "" };
|
||||
|
||||
export const ReplayProtection = {
|
||||
encode(message: ReplayProtection, writer: Writer = Writer.create()): Writer {
|
||||
if (message.index !== "") {
|
||||
writer.uint32(10).string(message.index);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): ReplayProtection {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseReplayProtection } as ReplayProtection;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.index = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ReplayProtection {
|
||||
const message = { ...baseReplayProtection } as ReplayProtection;
|
||||
if (object.index !== undefined && object.index !== null) {
|
||||
message.index = String(object.index);
|
||||
} else {
|
||||
message.index = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ReplayProtection): unknown {
|
||||
const obj: any = {};
|
||||
message.index !== undefined && (obj.index = message.index);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ReplayProtection>): ReplayProtection {
|
||||
const message = { ...baseReplayProtection } as ReplayProtection;
|
||||
if (object.index !== undefined && object.index !== null) {
|
||||
message.index = object.index;
|
||||
} else {
|
||||
message.index = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
|
@ -1,674 +0,0 @@
|
|||
//@ts-nocheck
|
||||
/* eslint-disable */
|
||||
import { Reader, Writer } from "protobufjs/minimal";
|
||||
import { Coin } from "../cosmos/base/v1beta1/coin";
|
||||
|
||||
export const protobufPackage = "certusone.wormholechain.tokenbridge";
|
||||
|
||||
export interface MsgExecuteGovernanceVAA {
|
||||
creator: string;
|
||||
vaa: Uint8Array;
|
||||
}
|
||||
|
||||
export interface MsgExecuteGovernanceVAAResponse {}
|
||||
|
||||
export interface MsgExecuteVAA {
|
||||
creator: string;
|
||||
vaa: Uint8Array;
|
||||
}
|
||||
|
||||
export interface MsgExecuteVAAResponse {}
|
||||
|
||||
export interface MsgAttestToken {
|
||||
creator: string;
|
||||
denom: string;
|
||||
}
|
||||
|
||||
export interface MsgAttestTokenResponse {}
|
||||
|
||||
export interface MsgTransfer {
|
||||
creator: string;
|
||||
amount: Coin | undefined;
|
||||
toChain: number;
|
||||
toAddress: Uint8Array;
|
||||
fee: string;
|
||||
}
|
||||
|
||||
export interface MsgTransferResponse {}
|
||||
|
||||
const baseMsgExecuteGovernanceVAA: object = { creator: "" };
|
||||
|
||||
export const MsgExecuteGovernanceVAA = {
|
||||
encode(
|
||||
message: MsgExecuteGovernanceVAA,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
if (message.creator !== "") {
|
||||
writer.uint32(10).string(message.creator);
|
||||
}
|
||||
if (message.vaa.length !== 0) {
|
||||
writer.uint32(18).bytes(message.vaa);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgExecuteGovernanceVAA {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = {
|
||||
...baseMsgExecuteGovernanceVAA,
|
||||
} as MsgExecuteGovernanceVAA;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.vaa = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgExecuteGovernanceVAA {
|
||||
const message = {
|
||||
...baseMsgExecuteGovernanceVAA,
|
||||
} as MsgExecuteGovernanceVAA;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.vaa !== undefined && object.vaa !== null) {
|
||||
message.vaa = bytesFromBase64(object.vaa);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgExecuteGovernanceVAA): unknown {
|
||||
const obj: any = {};
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.vaa !== undefined &&
|
||||
(obj.vaa = base64FromBytes(
|
||||
message.vaa !== undefined ? message.vaa : new Uint8Array()
|
||||
));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(
|
||||
object: DeepPartial<MsgExecuteGovernanceVAA>
|
||||
): MsgExecuteGovernanceVAA {
|
||||
const message = {
|
||||
...baseMsgExecuteGovernanceVAA,
|
||||
} as MsgExecuteGovernanceVAA;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.vaa !== undefined && object.vaa !== null) {
|
||||
message.vaa = object.vaa;
|
||||
} else {
|
||||
message.vaa = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgExecuteGovernanceVAAResponse: object = {};
|
||||
|
||||
export const MsgExecuteGovernanceVAAResponse = {
|
||||
encode(
|
||||
_: MsgExecuteGovernanceVAAResponse,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: Reader | Uint8Array,
|
||||
length?: number
|
||||
): MsgExecuteGovernanceVAAResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = {
|
||||
...baseMsgExecuteGovernanceVAAResponse,
|
||||
} as MsgExecuteGovernanceVAAResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgExecuteGovernanceVAAResponse {
|
||||
const message = {
|
||||
...baseMsgExecuteGovernanceVAAResponse,
|
||||
} as MsgExecuteGovernanceVAAResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgExecuteGovernanceVAAResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(
|
||||
_: DeepPartial<MsgExecuteGovernanceVAAResponse>
|
||||
): MsgExecuteGovernanceVAAResponse {
|
||||
const message = {
|
||||
...baseMsgExecuteGovernanceVAAResponse,
|
||||
} as MsgExecuteGovernanceVAAResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgExecuteVAA: object = { creator: "" };
|
||||
|
||||
export const MsgExecuteVAA = {
|
||||
encode(message: MsgExecuteVAA, writer: Writer = Writer.create()): Writer {
|
||||
if (message.creator !== "") {
|
||||
writer.uint32(10).string(message.creator);
|
||||
}
|
||||
if (message.vaa.length !== 0) {
|
||||
writer.uint32(18).bytes(message.vaa);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgExecuteVAA {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgExecuteVAA } as MsgExecuteVAA;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.vaa = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgExecuteVAA {
|
||||
const message = { ...baseMsgExecuteVAA } as MsgExecuteVAA;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.vaa !== undefined && object.vaa !== null) {
|
||||
message.vaa = bytesFromBase64(object.vaa);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgExecuteVAA): unknown {
|
||||
const obj: any = {};
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.vaa !== undefined &&
|
||||
(obj.vaa = base64FromBytes(
|
||||
message.vaa !== undefined ? message.vaa : new Uint8Array()
|
||||
));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgExecuteVAA>): MsgExecuteVAA {
|
||||
const message = { ...baseMsgExecuteVAA } as MsgExecuteVAA;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.vaa !== undefined && object.vaa !== null) {
|
||||
message.vaa = object.vaa;
|
||||
} else {
|
||||
message.vaa = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgExecuteVAAResponse: object = {};
|
||||
|
||||
export const MsgExecuteVAAResponse = {
|
||||
encode(_: MsgExecuteVAAResponse, writer: Writer = Writer.create()): Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgExecuteVAAResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgExecuteVAAResponse } as MsgExecuteVAAResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgExecuteVAAResponse {
|
||||
const message = { ...baseMsgExecuteVAAResponse } as MsgExecuteVAAResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgExecuteVAAResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgExecuteVAAResponse>): MsgExecuteVAAResponse {
|
||||
const message = { ...baseMsgExecuteVAAResponse } as MsgExecuteVAAResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgAttestToken: object = { creator: "", denom: "" };
|
||||
|
||||
export const MsgAttestToken = {
|
||||
encode(message: MsgAttestToken, writer: Writer = Writer.create()): Writer {
|
||||
if (message.creator !== "") {
|
||||
writer.uint32(10).string(message.creator);
|
||||
}
|
||||
if (message.denom !== "") {
|
||||
writer.uint32(18).string(message.denom);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgAttestToken {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgAttestToken } as MsgAttestToken;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgAttestToken {
|
||||
const message = { ...baseMsgAttestToken } as MsgAttestToken;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgAttestToken): unknown {
|
||||
const obj: any = {};
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgAttestToken>): MsgAttestToken {
|
||||
const message = { ...baseMsgAttestToken } as MsgAttestToken;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgAttestTokenResponse: object = {};
|
||||
|
||||
export const MsgAttestTokenResponse = {
|
||||
encode(_: MsgAttestTokenResponse, writer: Writer = Writer.create()): Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgAttestTokenResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgAttestTokenResponse } as MsgAttestTokenResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgAttestTokenResponse {
|
||||
const message = { ...baseMsgAttestTokenResponse } as MsgAttestTokenResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgAttestTokenResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgAttestTokenResponse>): MsgAttestTokenResponse {
|
||||
const message = { ...baseMsgAttestTokenResponse } as MsgAttestTokenResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgTransfer: object = { creator: "", toChain: 0, fee: "" };
|
||||
|
||||
export const MsgTransfer = {
|
||||
encode(message: MsgTransfer, writer: Writer = Writer.create()): Writer {
|
||||
if (message.creator !== "") {
|
||||
writer.uint32(10).string(message.creator);
|
||||
}
|
||||
if (message.amount !== undefined) {
|
||||
Coin.encode(message.amount, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.toChain !== 0) {
|
||||
writer.uint32(24).uint32(message.toChain);
|
||||
}
|
||||
if (message.toAddress.length !== 0) {
|
||||
writer.uint32(34).bytes(message.toAddress);
|
||||
}
|
||||
if (message.fee !== "") {
|
||||
writer.uint32(42).string(message.fee);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgTransfer {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgTransfer } as MsgTransfer;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = Coin.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.toChain = reader.uint32();
|
||||
break;
|
||||
case 4:
|
||||
message.toAddress = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
message.fee = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgTransfer {
|
||||
const message = { ...baseMsgTransfer } as MsgTransfer;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = Coin.fromJSON(object.amount);
|
||||
} else {
|
||||
message.amount = undefined;
|
||||
}
|
||||
if (object.toChain !== undefined && object.toChain !== null) {
|
||||
message.toChain = Number(object.toChain);
|
||||
} else {
|
||||
message.toChain = 0;
|
||||
}
|
||||
if (object.toAddress !== undefined && object.toAddress !== null) {
|
||||
message.toAddress = bytesFromBase64(object.toAddress);
|
||||
}
|
||||
if (object.fee !== undefined && object.fee !== null) {
|
||||
message.fee = String(object.fee);
|
||||
} else {
|
||||
message.fee = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgTransfer): unknown {
|
||||
const obj: any = {};
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.amount !== undefined &&
|
||||
(obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined);
|
||||
message.toChain !== undefined && (obj.toChain = message.toChain);
|
||||
message.toAddress !== undefined &&
|
||||
(obj.toAddress = base64FromBytes(
|
||||
message.toAddress !== undefined ? message.toAddress : new Uint8Array()
|
||||
));
|
||||
message.fee !== undefined && (obj.fee = message.fee);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgTransfer>): MsgTransfer {
|
||||
const message = { ...baseMsgTransfer } as MsgTransfer;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = Coin.fromPartial(object.amount);
|
||||
} else {
|
||||
message.amount = undefined;
|
||||
}
|
||||
if (object.toChain !== undefined && object.toChain !== null) {
|
||||
message.toChain = object.toChain;
|
||||
} else {
|
||||
message.toChain = 0;
|
||||
}
|
||||
if (object.toAddress !== undefined && object.toAddress !== null) {
|
||||
message.toAddress = object.toAddress;
|
||||
} else {
|
||||
message.toAddress = new Uint8Array();
|
||||
}
|
||||
if (object.fee !== undefined && object.fee !== null) {
|
||||
message.fee = object.fee;
|
||||
} else {
|
||||
message.fee = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgTransferResponse: object = {};
|
||||
|
||||
export const MsgTransferResponse = {
|
||||
encode(_: MsgTransferResponse, writer: Writer = Writer.create()): Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgTransferResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgTransferResponse } as MsgTransferResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgTransferResponse {
|
||||
const message = { ...baseMsgTransferResponse } as MsgTransferResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgTransferResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgTransferResponse>): MsgTransferResponse {
|
||||
const message = { ...baseMsgTransferResponse } as MsgTransferResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Msg defines the Msg service. */
|
||||
export interface Msg {
|
||||
ExecuteGovernanceVAA(
|
||||
request: MsgExecuteGovernanceVAA
|
||||
): Promise<MsgExecuteGovernanceVAAResponse>;
|
||||
ExecuteVAA(request: MsgExecuteVAA): Promise<MsgExecuteVAAResponse>;
|
||||
AttestToken(request: MsgAttestToken): Promise<MsgAttestTokenResponse>;
|
||||
/** this line is used by starport scaffolding # proto/tx/rpc */
|
||||
Transfer(request: MsgTransfer): Promise<MsgTransferResponse>;
|
||||
}
|
||||
|
||||
export class MsgClientImpl implements Msg {
|
||||
private readonly rpc: Rpc;
|
||||
constructor(rpc: Rpc) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
ExecuteGovernanceVAA(
|
||||
request: MsgExecuteGovernanceVAA
|
||||
): Promise<MsgExecuteGovernanceVAAResponse> {
|
||||
const data = MsgExecuteGovernanceVAA.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"certusone.wormholechain.tokenbridge.Msg",
|
||||
"ExecuteGovernanceVAA",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
MsgExecuteGovernanceVAAResponse.decode(new Reader(data))
|
||||
);
|
||||
}
|
||||
|
||||
ExecuteVAA(request: MsgExecuteVAA): Promise<MsgExecuteVAAResponse> {
|
||||
const data = MsgExecuteVAA.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"certusone.wormholechain.tokenbridge.Msg",
|
||||
"ExecuteVAA",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
MsgExecuteVAAResponse.decode(new Reader(data))
|
||||
);
|
||||
}
|
||||
|
||||
AttestToken(request: MsgAttestToken): Promise<MsgAttestTokenResponse> {
|
||||
const data = MsgAttestToken.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"certusone.wormholechain.tokenbridge.Msg",
|
||||
"AttestToken",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
MsgAttestTokenResponse.decode(new Reader(data))
|
||||
);
|
||||
}
|
||||
|
||||
Transfer(request: MsgTransfer): Promise<MsgTransferResponse> {
|
||||
const data = MsgTransfer.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"certusone.wormholechain.tokenbridge.Msg",
|
||||
"Transfer",
|
||||
data
|
||||
);
|
||||
return promise.then((data) => MsgTransferResponse.decode(new Reader(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
request(
|
||||
service: string,
|
||||
method: string,
|
||||
data: Uint8Array
|
||||
): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob ||
|
||||
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa ||
|
||||
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
|
@ -35,17 +35,6 @@ spec:
|
|||
app: guardian-validator
|
||||
spec:
|
||||
containers:
|
||||
- name: chain-initialization
|
||||
image: wormhole-chaind-image
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- "/app/scripts/chainRegistration.sh && nc -l -k 0.0.0.0 2000"
|
||||
readinessProbe:
|
||||
periodSeconds: 1
|
||||
failureThreshold: 300
|
||||
tcpSocket:
|
||||
port: 2000
|
||||
- name: wormhole-chaind
|
||||
image: wormhole-chaind-image
|
||||
command:
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
// "github.com/cosmos/cosmos-sdk/client/flags"
|
||||
// sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for this module
|
||||
func GetQueryCmd(queryRoute string) *cobra.Command {
|
||||
// Group tokenbridge queries under a subcommand
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(CmdShowConfig())
|
||||
cmd.AddCommand(CmdListReplayProtection())
|
||||
cmd.AddCommand(CmdShowReplayProtection())
|
||||
cmd.AddCommand(CmdListChainRegistration())
|
||||
cmd.AddCommand(CmdShowChainRegistration())
|
||||
cmd.AddCommand(CmdListCoinMetaRollbackProtection())
|
||||
cmd.AddCommand(CmdShowCoinMetaRollbackProtection())
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func CmdListChainRegistration() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list-chain-registration",
|
||||
Short: "list all ChainRegistration",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryAllChainRegistrationRequest{
|
||||
Pagination: pageReq,
|
||||
}
|
||||
|
||||
res, err := queryClient.ChainRegistrationAll(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func CmdShowChainRegistration() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "show-chain-registration [chainID]",
|
||||
Short: "shows a ChainRegistration",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
chainID, err := strconv.ParseUint(args[0], 10, 16)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params := &types.QueryGetChainRegistrationRequest{
|
||||
ChainID: uint32(chainID),
|
||||
}
|
||||
|
||||
res, err := queryClient.ChainRegistration(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/network"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/client/cli"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func networkWithChainRegistrationObjects(t *testing.T, n int) (*network.Network, []types.ChainRegistration) {
|
||||
t.Helper()
|
||||
cfg := network.DefaultConfig()
|
||||
state := types.GenesisState{}
|
||||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
state.ChainRegistrationList = append(state.ChainRegistrationList, types.ChainRegistration{
|
||||
ChainID: uint32(i),
|
||||
})
|
||||
}
|
||||
buf, err := cfg.Codec.MarshalJSON(&state)
|
||||
require.NoError(t, err)
|
||||
cfg.GenesisState[types.ModuleName] = buf
|
||||
return network.New(t, cfg), state.ChainRegistrationList
|
||||
}
|
||||
|
||||
func TestShowChainRegistration(t *testing.T) {
|
||||
net, objs := networkWithChainRegistrationObjects(t, 2)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
common := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
idIndex string
|
||||
|
||||
args []string
|
||||
err error
|
||||
obj types.ChainRegistration
|
||||
}{
|
||||
{
|
||||
desc: "found",
|
||||
idIndex: strconv.FormatUint(uint64(objs[0].ChainID), 10),
|
||||
|
||||
args: common,
|
||||
obj: objs[0],
|
||||
},
|
||||
{
|
||||
desc: "not found",
|
||||
idIndex: strconv.Itoa(100000),
|
||||
|
||||
args: common,
|
||||
err: status.Error(codes.InvalidArgument, "not found"),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
args := []string{
|
||||
tc.idIndex,
|
||||
}
|
||||
args = append(args, tc.args...)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowChainRegistration(), args)
|
||||
if tc.err != nil {
|
||||
stat, ok := status.FromError(tc.err)
|
||||
require.True(t, ok)
|
||||
require.ErrorIs(t, stat.Err(), tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryGetChainRegistrationResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NotNil(t, resp.ChainRegistration)
|
||||
require.Equal(t, tc.obj, resp.ChainRegistration)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestListChainRegistration(t *testing.T) {
|
||||
net, objs := networkWithChainRegistrationObjects(t, 5)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
request := func(next []byte, offset, limit uint64, total bool) []string {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
if next == nil {
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset))
|
||||
} else {
|
||||
args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next))
|
||||
}
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit))
|
||||
if total {
|
||||
args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal))
|
||||
}
|
||||
return args
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(nil, uint64(i), uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListChainRegistration(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllChainRegistrationResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.ChainRegistration), step)
|
||||
require.Subset(t, objs, resp.ChainRegistration)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(next, 0, uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListChainRegistration(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllChainRegistrationResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.ChainRegistration), step)
|
||||
require.Subset(t, objs, resp.ChainRegistration)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
args := request(nil, 0, uint64(len(objs)), true)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListChainRegistration(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllChainRegistrationResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(objs), int(resp.Pagination.Total))
|
||||
require.Equal(t, objs, resp.ChainRegistration)
|
||||
})
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func CmdListCoinMetaRollbackProtection() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list-coin-meta-rollback-protection",
|
||||
Short: "list all CoinMetaRollbackProtection",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryAllCoinMetaRollbackProtectionRequest{
|
||||
Pagination: pageReq,
|
||||
}
|
||||
|
||||
res, err := queryClient.CoinMetaRollbackProtectionAll(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func CmdShowCoinMetaRollbackProtection() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "show-coin-meta-rollback-protection [index]",
|
||||
Short: "shows a CoinMetaRollbackProtection",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
argIndex := args[0]
|
||||
|
||||
params := &types.QueryGetCoinMetaRollbackProtectionRequest{
|
||||
Index: argIndex,
|
||||
}
|
||||
|
||||
res, err := queryClient.CoinMetaRollbackProtection(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/network"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/client/cli"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func networkWithCoinMetaRollbackProtectionObjects(t *testing.T, n int) (*network.Network, []types.CoinMetaRollbackProtection) {
|
||||
t.Helper()
|
||||
cfg := network.DefaultConfig()
|
||||
state := types.GenesisState{}
|
||||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
state.CoinMetaRollbackProtectionList = append(state.CoinMetaRollbackProtectionList, types.CoinMetaRollbackProtection{
|
||||
Index: strconv.Itoa(i),
|
||||
})
|
||||
}
|
||||
buf, err := cfg.Codec.MarshalJSON(&state)
|
||||
require.NoError(t, err)
|
||||
cfg.GenesisState[types.ModuleName] = buf
|
||||
return network.New(t, cfg), state.CoinMetaRollbackProtectionList
|
||||
}
|
||||
|
||||
func TestShowCoinMetaRollbackProtection(t *testing.T) {
|
||||
net, objs := networkWithCoinMetaRollbackProtectionObjects(t, 2)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
common := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
idIndex string
|
||||
|
||||
args []string
|
||||
err error
|
||||
obj types.CoinMetaRollbackProtection
|
||||
}{
|
||||
{
|
||||
desc: "found",
|
||||
idIndex: objs[0].Index,
|
||||
|
||||
args: common,
|
||||
obj: objs[0],
|
||||
},
|
||||
{
|
||||
desc: "not found",
|
||||
idIndex: strconv.Itoa(100000),
|
||||
|
||||
args: common,
|
||||
err: status.Error(codes.InvalidArgument, "not found"),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
args := []string{
|
||||
tc.idIndex,
|
||||
}
|
||||
args = append(args, tc.args...)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowCoinMetaRollbackProtection(), args)
|
||||
if tc.err != nil {
|
||||
stat, ok := status.FromError(tc.err)
|
||||
require.True(t, ok)
|
||||
require.ErrorIs(t, stat.Err(), tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryGetCoinMetaRollbackProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NotNil(t, resp.CoinMetaRollbackProtection)
|
||||
require.Equal(t, tc.obj, resp.CoinMetaRollbackProtection)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestListCoinMetaRollbackProtection(t *testing.T) {
|
||||
net, objs := networkWithCoinMetaRollbackProtectionObjects(t, 5)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
request := func(next []byte, offset, limit uint64, total bool) []string {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
if next == nil {
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset))
|
||||
} else {
|
||||
args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next))
|
||||
}
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit))
|
||||
if total {
|
||||
args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal))
|
||||
}
|
||||
return args
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(nil, uint64(i), uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListCoinMetaRollbackProtection(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllCoinMetaRollbackProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.CoinMetaRollbackProtection), step)
|
||||
require.Subset(t, objs, resp.CoinMetaRollbackProtection)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(next, 0, uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListCoinMetaRollbackProtection(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllCoinMetaRollbackProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.CoinMetaRollbackProtection), step)
|
||||
require.Subset(t, objs, resp.CoinMetaRollbackProtection)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
args := request(nil, 0, uint64(len(objs)), true)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListCoinMetaRollbackProtection(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllCoinMetaRollbackProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(objs), int(resp.Pagination.Total))
|
||||
require.Equal(t, objs, resp.CoinMetaRollbackProtection)
|
||||
})
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func CmdShowConfig() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "show-config",
|
||||
Short: "shows Config",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryGetConfigRequest{}
|
||||
|
||||
res, err := queryClient.Config(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/network"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/client/cli"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func networkWithConfigObjects(t *testing.T) (*network.Network, types.Config) {
|
||||
t.Helper()
|
||||
cfg := network.DefaultConfig()
|
||||
state := types.GenesisState{}
|
||||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))
|
||||
|
||||
state.Config = &types.Config{}
|
||||
buf, err := cfg.Codec.MarshalJSON(&state)
|
||||
require.NoError(t, err)
|
||||
cfg.GenesisState[types.ModuleName] = buf
|
||||
return network.New(t, cfg), *state.Config
|
||||
}
|
||||
|
||||
func TestShowConfig(t *testing.T) {
|
||||
net, obj := networkWithConfigObjects(t)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
common := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
args []string
|
||||
err error
|
||||
obj types.Config
|
||||
}{
|
||||
{
|
||||
desc: "get",
|
||||
args: common,
|
||||
obj: obj,
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
var args []string
|
||||
args = append(args, tc.args...)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowConfig(), args)
|
||||
if tc.err != nil {
|
||||
stat, ok := status.FromError(tc.err)
|
||||
require.True(t, ok)
|
||||
require.ErrorIs(t, stat.Err(), tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryGetConfigResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NotNil(t, resp.Config)
|
||||
require.Equal(t, tc.obj, resp.Config)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func CmdListReplayProtection() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list-replay-protection",
|
||||
Short: "list all ReplayProtection",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryAllReplayProtectionRequest{
|
||||
Pagination: pageReq,
|
||||
}
|
||||
|
||||
res, err := queryClient.ReplayProtectionAll(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func CmdShowReplayProtection() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "show-replay-protection [index]",
|
||||
Short: "shows a ReplayProtection",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
argIndex := args[0]
|
||||
|
||||
params := &types.QueryGetReplayProtectionRequest{
|
||||
Index: argIndex,
|
||||
}
|
||||
|
||||
res, err := queryClient.ReplayProtection(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/network"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/client/cli"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func networkWithReplayProtectionObjects(t *testing.T, n int) (*network.Network, []types.ReplayProtection) {
|
||||
t.Helper()
|
||||
cfg := network.DefaultConfig()
|
||||
state := types.GenesisState{}
|
||||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
state.ReplayProtectionList = append(state.ReplayProtectionList, types.ReplayProtection{
|
||||
Index: strconv.Itoa(i),
|
||||
})
|
||||
}
|
||||
buf, err := cfg.Codec.MarshalJSON(&state)
|
||||
require.NoError(t, err)
|
||||
cfg.GenesisState[types.ModuleName] = buf
|
||||
return network.New(t, cfg), state.ReplayProtectionList
|
||||
}
|
||||
|
||||
func TestShowReplayProtection(t *testing.T) {
|
||||
net, objs := networkWithReplayProtectionObjects(t, 2)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
common := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
idIndex string
|
||||
|
||||
args []string
|
||||
err error
|
||||
obj types.ReplayProtection
|
||||
}{
|
||||
{
|
||||
desc: "found",
|
||||
idIndex: objs[0].Index,
|
||||
|
||||
args: common,
|
||||
obj: objs[0],
|
||||
},
|
||||
{
|
||||
desc: "not found",
|
||||
idIndex: strconv.Itoa(100000),
|
||||
|
||||
args: common,
|
||||
err: status.Error(codes.InvalidArgument, "not found"),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
args := []string{
|
||||
tc.idIndex,
|
||||
}
|
||||
args = append(args, tc.args...)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowReplayProtection(), args)
|
||||
if tc.err != nil {
|
||||
stat, ok := status.FromError(tc.err)
|
||||
require.True(t, ok)
|
||||
require.ErrorIs(t, stat.Err(), tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryGetReplayProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NotNil(t, resp.ReplayProtection)
|
||||
require.Equal(t, tc.obj, resp.ReplayProtection)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestListReplayProtection(t *testing.T) {
|
||||
net, objs := networkWithReplayProtectionObjects(t, 5)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
request := func(next []byte, offset, limit uint64, total bool) []string {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
if next == nil {
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset))
|
||||
} else {
|
||||
args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next))
|
||||
}
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit))
|
||||
if total {
|
||||
args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal))
|
||||
}
|
||||
return args
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(nil, uint64(i), uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListReplayProtection(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllReplayProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.ReplayProtection), step)
|
||||
require.Subset(t, objs, resp.ReplayProtection)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(next, 0, uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListReplayProtection(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllReplayProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.ReplayProtection), step)
|
||||
require.Subset(t, objs, resp.ReplayProtection)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
args := request(nil, 0, uint64(len(objs)), true)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListReplayProtection(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllReplayProtectionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(objs), int(resp.Pagination.Total))
|
||||
require.Equal(t, objs, resp.ReplayProtection)
|
||||
})
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
// "github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// GetTxCmd returns the transaction commands for this module
|
||||
func GetTxCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(CmdExecuteGovernanceVAA())
|
||||
cmd.AddCommand(CmdExecuteVAA())
|
||||
cmd.AddCommand(CmdAttestToken())
|
||||
cmd.AddCommand(CmdTransfer())
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdAttestToken() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "attest-token [denom]",
|
||||
Short: "Broadcast message AttestToken",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
argDenom := args[0]
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgAttestToken(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
argDenom,
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdExecuteGovernanceVAA() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "execute-governance-vaa [vaa]",
|
||||
Short: "Broadcast message ExecuteGovernanceVAA",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
argVaa := args[0]
|
||||
vaaBytes, err := hex.DecodeString(argVaa)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid vaa hex: %w", err)
|
||||
}
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgExecuteGovernanceVAA(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
vaaBytes,
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdExecuteVAA() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "execute-vaa [vaa]",
|
||||
Short: "Broadcast message ExecuteVAA",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
argVaa := args[0]
|
||||
vaaBytes, err := hex.DecodeString(argVaa)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid vaa hex: %w", err)
|
||||
}
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgExecuteVAA(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
vaaBytes,
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdTransfer() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "transfer [amount] [to_chain] [to_address] [fee]",
|
||||
Short: "Broadcast message Transfer",
|
||||
Args: cobra.ExactArgs(4),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
coins, err := sdk.ParseCoinNormalized(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
chainID, err := strconv.ParseUint(args[1], 10, 16)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
toAddress, err := hex.DecodeString(args[2])
|
||||
if err != nil {
|
||||
return fmt.Errorf("to address invalid: %w", err)
|
||||
}
|
||||
|
||||
fee, err := sdk.ParseCoinNormalized(args[3])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid fee: %w", err)
|
||||
}
|
||||
|
||||
msg := types.NewMsgTransfer(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
coins,
|
||||
uint16(chainID),
|
||||
toAddress,
|
||||
fee,
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package tokenbridge
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the capability module's state from a provided genesis
|
||||
// state.
|
||||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
|
||||
// Set if defined
|
||||
if genState.Config != nil {
|
||||
k.SetConfig(ctx, *genState.Config)
|
||||
}
|
||||
// Set all the replayProtection
|
||||
for _, elem := range genState.ReplayProtectionList {
|
||||
k.SetReplayProtection(ctx, elem)
|
||||
}
|
||||
// Set all the chainRegistration
|
||||
for _, elem := range genState.ChainRegistrationList {
|
||||
k.SetChainRegistration(ctx, elem)
|
||||
}
|
||||
// Set all the coinMetaRollbackProtection
|
||||
for _, elem := range genState.CoinMetaRollbackProtectionList {
|
||||
k.SetCoinMetaRollbackProtection(ctx, elem)
|
||||
}
|
||||
// this line is used by starport scaffolding # genesis/module/init
|
||||
}
|
||||
|
||||
// ExportGenesis returns the capability module's exported genesis.
|
||||
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
||||
genesis := types.DefaultGenesis()
|
||||
|
||||
// Get all config
|
||||
config, found := k.GetConfig(ctx)
|
||||
if found {
|
||||
genesis.Config = &config
|
||||
}
|
||||
genesis.ReplayProtectionList = k.GetAllReplayProtection(ctx)
|
||||
genesis.ChainRegistrationList = k.GetAllChainRegistration(ctx)
|
||||
genesis.CoinMetaRollbackProtectionList = k.GetAllCoinMetaRollbackProtection(ctx)
|
||||
// this line is used by starport scaffolding # genesis/module/export
|
||||
|
||||
return genesis
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package tokenbridge_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func TestGenesis(t *testing.T) {
|
||||
genesisState := types.GenesisState{
|
||||
Config: &types.Config{},
|
||||
ReplayProtectionList: []types.ReplayProtection{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "1",
|
||||
},
|
||||
},
|
||||
ChainRegistrationList: []types.ChainRegistration{
|
||||
{
|
||||
ChainID: 0,
|
||||
},
|
||||
{
|
||||
ChainID: 1,
|
||||
},
|
||||
},
|
||||
CoinMetaRollbackProtectionList: []types.CoinMetaRollbackProtection{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "1",
|
||||
},
|
||||
},
|
||||
// this line is used by starport scaffolding # genesis/test/state
|
||||
}
|
||||
|
||||
k, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
tokenbridge.InitGenesis(ctx, *k, genesisState)
|
||||
got := tokenbridge.ExportGenesis(ctx, *k)
|
||||
require.NotNil(t, got)
|
||||
|
||||
require.Equal(t, genesisState.Config, got.Config)
|
||||
require.Len(t, got.ReplayProtectionList, len(genesisState.ReplayProtectionList))
|
||||
require.Subset(t, genesisState.ReplayProtectionList, got.ReplayProtectionList)
|
||||
require.Len(t, got.ChainRegistrationList, len(genesisState.ChainRegistrationList))
|
||||
require.Subset(t, genesisState.ChainRegistrationList, got.ChainRegistrationList)
|
||||
require.Len(t, got.CoinMetaRollbackProtectionList, len(genesisState.CoinMetaRollbackProtectionList))
|
||||
require.Subset(t, genesisState.CoinMetaRollbackProtectionList, got.CoinMetaRollbackProtectionList)
|
||||
// this line is used by starport scaffolding # genesis/test/assert
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package tokenbridge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// NewHandler ...
|
||||
func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||
msgServer := keeper.NewMsgServerImpl(k)
|
||||
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *types.MsgExecuteGovernanceVAA:
|
||||
res, err := msgServer.ExecuteGovernanceVAA(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
case *types.MsgExecuteVAA:
|
||||
res, err := msgServer.ExecuteVAA(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
case *types.MsgAttestToken:
|
||||
res, err := msgServer.AttestToken(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
case *types.MsgTransfer:
|
||||
res, err := msgServer.Transfer(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
// this line is used by starport scaffolding # 1
|
||||
default:
|
||||
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// SetChainRegistration set a specific chainRegistration in the store from its index
|
||||
func (k Keeper) SetChainRegistration(ctx sdk.Context, chainRegistration types.ChainRegistration) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainRegistrationKeyPrefix))
|
||||
b := k.cdc.MustMarshal(&chainRegistration)
|
||||
store.Set(types.ChainRegistrationKey(
|
||||
chainRegistration.ChainID,
|
||||
), b)
|
||||
}
|
||||
|
||||
// GetChainRegistration returns a chainRegistration from its index
|
||||
func (k Keeper) GetChainRegistration(
|
||||
ctx sdk.Context,
|
||||
chainID uint32,
|
||||
|
||||
) (val types.ChainRegistration, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainRegistrationKeyPrefix))
|
||||
|
||||
b := store.Get(types.ChainRegistrationKey(chainID))
|
||||
if b == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
// RemoveChainRegistration removes a chainRegistration from the store
|
||||
func (k Keeper) RemoveChainRegistration(
|
||||
ctx sdk.Context,
|
||||
chainID uint32,
|
||||
|
||||
) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainRegistrationKeyPrefix))
|
||||
store.Delete(types.ChainRegistrationKey(
|
||||
chainID,
|
||||
))
|
||||
}
|
||||
|
||||
// GetAllChainRegistration returns all chainRegistration
|
||||
func (k Keeper) GetAllChainRegistration(ctx sdk.Context) (list []types.ChainRegistration) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainRegistrationKeyPrefix))
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte{})
|
||||
|
||||
defer iterator.Close()
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var val types.ChainRegistration
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &val)
|
||||
list = append(list, val)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func createNChainRegistration(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.ChainRegistration {
|
||||
items := make([]types.ChainRegistration, n)
|
||||
for i := range items {
|
||||
items[i].ChainID = uint32(i)
|
||||
|
||||
keeper.SetChainRegistration(ctx, items[i])
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func TestChainRegistrationGet(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNChainRegistration(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
rst, found := keeper.GetChainRegistration(ctx,
|
||||
item.ChainID,
|
||||
)
|
||||
require.True(t, found)
|
||||
require.Equal(t, item, rst)
|
||||
}
|
||||
}
|
||||
func TestChainRegistrationRemove(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNChainRegistration(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
keeper.RemoveChainRegistration(ctx,
|
||||
item.ChainID,
|
||||
)
|
||||
_, found := keeper.GetChainRegistration(ctx,
|
||||
item.ChainID,
|
||||
)
|
||||
require.False(t, found)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChainRegistrationGetAll(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNChainRegistration(keeper, ctx, 10)
|
||||
require.ElementsMatch(t, items, keeper.GetAllChainRegistration(ctx))
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// SetCoinMetaRollbackProtection set a specific coinMetaRollbackProtection in the store from its index
|
||||
func (k Keeper) SetCoinMetaRollbackProtection(ctx sdk.Context, coinMetaRollbackProtection types.CoinMetaRollbackProtection) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CoinMetaRollbackProtectionKeyPrefix))
|
||||
b := k.cdc.MustMarshal(&coinMetaRollbackProtection)
|
||||
store.Set(types.CoinMetaRollbackProtectionKey(
|
||||
coinMetaRollbackProtection.Index,
|
||||
), b)
|
||||
}
|
||||
|
||||
// GetCoinMetaRollbackProtection returns a coinMetaRollbackProtection from its index
|
||||
func (k Keeper) GetCoinMetaRollbackProtection(
|
||||
ctx sdk.Context,
|
||||
index string,
|
||||
|
||||
) (val types.CoinMetaRollbackProtection, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CoinMetaRollbackProtectionKeyPrefix))
|
||||
|
||||
b := store.Get(types.CoinMetaRollbackProtectionKey(
|
||||
index,
|
||||
))
|
||||
if b == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
// RemoveCoinMetaRollbackProtection removes a coinMetaRollbackProtection from the store
|
||||
func (k Keeper) RemoveCoinMetaRollbackProtection(
|
||||
ctx sdk.Context,
|
||||
index string,
|
||||
|
||||
) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CoinMetaRollbackProtectionKeyPrefix))
|
||||
store.Delete(types.CoinMetaRollbackProtectionKey(
|
||||
index,
|
||||
))
|
||||
}
|
||||
|
||||
// GetAllCoinMetaRollbackProtection returns all coinMetaRollbackProtection
|
||||
func (k Keeper) GetAllCoinMetaRollbackProtection(ctx sdk.Context) (list []types.CoinMetaRollbackProtection) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CoinMetaRollbackProtectionKeyPrefix))
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte{})
|
||||
|
||||
defer iterator.Close()
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var val types.CoinMetaRollbackProtection
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &val)
|
||||
list = append(list, val)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func createNCoinMetaRollbackProtection(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.CoinMetaRollbackProtection {
|
||||
items := make([]types.CoinMetaRollbackProtection, n)
|
||||
for i := range items {
|
||||
items[i].Index = strconv.Itoa(i)
|
||||
|
||||
keeper.SetCoinMetaRollbackProtection(ctx, items[i])
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func TestCoinMetaRollbackProtectionGet(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNCoinMetaRollbackProtection(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
rst, found := keeper.GetCoinMetaRollbackProtection(ctx,
|
||||
item.Index,
|
||||
)
|
||||
require.True(t, found)
|
||||
require.Equal(t, item, rst)
|
||||
}
|
||||
}
|
||||
func TestCoinMetaRollbackProtectionRemove(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNCoinMetaRollbackProtection(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
keeper.RemoveCoinMetaRollbackProtection(ctx,
|
||||
item.Index,
|
||||
)
|
||||
_, found := keeper.GetCoinMetaRollbackProtection(ctx,
|
||||
item.Index,
|
||||
)
|
||||
require.False(t, found)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoinMetaRollbackProtectionGetAll(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNCoinMetaRollbackProtection(keeper, ctx, 10)
|
||||
require.ElementsMatch(t, items, keeper.GetAllCoinMetaRollbackProtection(ctx))
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// SetConfig set config in the store
|
||||
func (k Keeper) SetConfig(ctx sdk.Context, config types.Config) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ConfigKey))
|
||||
b := k.cdc.MustMarshal(&config)
|
||||
store.Set([]byte{0}, b)
|
||||
}
|
||||
|
||||
// GetConfig returns config
|
||||
func (k Keeper) GetConfig(ctx sdk.Context) (val types.Config, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ConfigKey))
|
||||
|
||||
b := store.Get([]byte{0})
|
||||
if b == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
// RemoveConfig removes config from the store
|
||||
func (k Keeper) RemoveConfig(ctx sdk.Context) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ConfigKey))
|
||||
store.Delete([]byte{0})
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func createTestConfig(keeper *keeper.Keeper, ctx sdk.Context) types.Config {
|
||||
item := types.Config{}
|
||||
keeper.SetConfig(ctx, item)
|
||||
return item
|
||||
}
|
||||
|
||||
func TestConfigGet(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
item := createTestConfig(keeper, ctx)
|
||||
rst, found := keeper.GetConfig(ctx)
|
||||
require.True(t, found)
|
||||
require.Equal(t, item, rst)
|
||||
}
|
||||
func TestConfigRemove(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
createTestConfig(keeper, ctx)
|
||||
keeper.RemoveConfig(ctx)
|
||||
_, found := keeper.GetConfig(ctx)
|
||||
require.False(t, found)
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Keeper{}
|
|
@ -1,62 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) ChainRegistrationAll(c context.Context, req *types.QueryAllChainRegistrationRequest) (*types.QueryAllChainRegistrationResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
|
||||
var chainRegistrations []types.ChainRegistration
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
chainRegistrationStore := prefix.NewStore(store, types.KeyPrefix(types.ChainRegistrationKeyPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(chainRegistrationStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
var chainRegistration types.ChainRegistration
|
||||
if err := k.cdc.Unmarshal(value, &chainRegistration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
chainRegistrations = append(chainRegistrations, chainRegistration)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &types.QueryAllChainRegistrationResponse{ChainRegistration: chainRegistrations, Pagination: pageRes}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) ChainRegistration(c context.Context, req *types.QueryGetChainRegistrationRequest) (*types.QueryGetChainRegistrationResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
if req.ChainID > math.MaxUint16 {
|
||||
return nil, status.Error(codes.InvalidArgument, "chainID must be uint16")
|
||||
}
|
||||
|
||||
val, found := k.GetChainRegistration(
|
||||
ctx,
|
||||
req.ChainID,
|
||||
)
|
||||
if !found {
|
||||
return nil, status.Error(codes.InvalidArgument, "not found")
|
||||
}
|
||||
|
||||
return &types.QueryGetChainRegistrationResponse{ChainRegistration: val}, nil
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func TestChainRegistrationQuerySingle(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNChainRegistration(keeper, ctx, 2)
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
request *types.QueryGetChainRegistrationRequest
|
||||
response *types.QueryGetChainRegistrationResponse
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "First",
|
||||
request: &types.QueryGetChainRegistrationRequest{
|
||||
ChainID: msgs[0].ChainID,
|
||||
},
|
||||
response: &types.QueryGetChainRegistrationResponse{ChainRegistration: msgs[0]},
|
||||
},
|
||||
{
|
||||
desc: "Second",
|
||||
request: &types.QueryGetChainRegistrationRequest{
|
||||
ChainID: msgs[1].ChainID,
|
||||
},
|
||||
response: &types.QueryGetChainRegistrationResponse{ChainRegistration: msgs[1]},
|
||||
},
|
||||
{
|
||||
desc: "KeyNotFound",
|
||||
request: &types.QueryGetChainRegistrationRequest{
|
||||
ChainID: 10000,
|
||||
},
|
||||
err: status.Error(codes.InvalidArgument, "not found"),
|
||||
},
|
||||
{
|
||||
desc: "InvalidRequest",
|
||||
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
response, err := keeper.ChainRegistration(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
} else {
|
||||
require.Equal(t, tc.response, response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChainRegistrationQueryPaginated(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNChainRegistration(keeper, ctx, 5)
|
||||
|
||||
request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllChainRegistrationRequest {
|
||||
return &types.QueryAllChainRegistrationRequest{
|
||||
Pagination: &query.PageRequest{
|
||||
Key: next,
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
CountTotal: total,
|
||||
},
|
||||
}
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.ChainRegistrationAll(wctx, request(nil, uint64(i), uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.ChainRegistration), step)
|
||||
require.Subset(t, msgs, resp.ChainRegistration)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.ChainRegistrationAll(wctx, request(next, 0, uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.ChainRegistration), step)
|
||||
require.Subset(t, msgs, resp.ChainRegistration)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
resp, err := keeper.ChainRegistrationAll(wctx, request(nil, 0, 0, true))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(msgs), int(resp.Pagination.Total))
|
||||
})
|
||||
t.Run("InvalidRequest", func(t *testing.T) {
|
||||
_, err := keeper.ChainRegistrationAll(wctx, nil)
|
||||
require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request"))
|
||||
})
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) CoinMetaRollbackProtectionAll(c context.Context, req *types.QueryAllCoinMetaRollbackProtectionRequest) (*types.QueryAllCoinMetaRollbackProtectionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
|
||||
var coinMetaRollbackProtections []types.CoinMetaRollbackProtection
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
coinMetaRollbackProtectionStore := prefix.NewStore(store, types.KeyPrefix(types.CoinMetaRollbackProtectionKeyPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(coinMetaRollbackProtectionStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
var coinMetaRollbackProtection types.CoinMetaRollbackProtection
|
||||
if err := k.cdc.Unmarshal(value, &coinMetaRollbackProtection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
coinMetaRollbackProtections = append(coinMetaRollbackProtections, coinMetaRollbackProtection)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &types.QueryAllCoinMetaRollbackProtectionResponse{CoinMetaRollbackProtection: coinMetaRollbackProtections, Pagination: pageRes}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) CoinMetaRollbackProtection(c context.Context, req *types.QueryGetCoinMetaRollbackProtectionRequest) (*types.QueryGetCoinMetaRollbackProtectionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
val, found := k.GetCoinMetaRollbackProtection(
|
||||
ctx,
|
||||
req.Index,
|
||||
)
|
||||
if !found {
|
||||
return nil, status.Error(codes.InvalidArgument, "not found")
|
||||
}
|
||||
|
||||
return &types.QueryGetCoinMetaRollbackProtectionResponse{CoinMetaRollbackProtection: val}, nil
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func TestCoinMetaRollbackProtectionQuerySingle(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNCoinMetaRollbackProtection(keeper, ctx, 2)
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
request *types.QueryGetCoinMetaRollbackProtectionRequest
|
||||
response *types.QueryGetCoinMetaRollbackProtectionResponse
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "First",
|
||||
request: &types.QueryGetCoinMetaRollbackProtectionRequest{
|
||||
Index: msgs[0].Index,
|
||||
},
|
||||
response: &types.QueryGetCoinMetaRollbackProtectionResponse{CoinMetaRollbackProtection: msgs[0]},
|
||||
},
|
||||
{
|
||||
desc: "Second",
|
||||
request: &types.QueryGetCoinMetaRollbackProtectionRequest{
|
||||
Index: msgs[1].Index,
|
||||
},
|
||||
response: &types.QueryGetCoinMetaRollbackProtectionResponse{CoinMetaRollbackProtection: msgs[1]},
|
||||
},
|
||||
{
|
||||
desc: "KeyNotFound",
|
||||
request: &types.QueryGetCoinMetaRollbackProtectionRequest{
|
||||
Index: strconv.Itoa(100000),
|
||||
},
|
||||
err: status.Error(codes.InvalidArgument, "not found"),
|
||||
},
|
||||
{
|
||||
desc: "InvalidRequest",
|
||||
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
response, err := keeper.CoinMetaRollbackProtection(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
} else {
|
||||
require.Equal(t, tc.response, response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoinMetaRollbackProtectionQueryPaginated(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNCoinMetaRollbackProtection(keeper, ctx, 5)
|
||||
|
||||
request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllCoinMetaRollbackProtectionRequest {
|
||||
return &types.QueryAllCoinMetaRollbackProtectionRequest{
|
||||
Pagination: &query.PageRequest{
|
||||
Key: next,
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
CountTotal: total,
|
||||
},
|
||||
}
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.CoinMetaRollbackProtectionAll(wctx, request(nil, uint64(i), uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.CoinMetaRollbackProtection), step)
|
||||
require.Subset(t, msgs, resp.CoinMetaRollbackProtection)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.CoinMetaRollbackProtectionAll(wctx, request(next, 0, uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.CoinMetaRollbackProtection), step)
|
||||
require.Subset(t, msgs, resp.CoinMetaRollbackProtection)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
resp, err := keeper.CoinMetaRollbackProtectionAll(wctx, request(nil, 0, 0, true))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(msgs), int(resp.Pagination.Total))
|
||||
})
|
||||
t.Run("InvalidRequest", func(t *testing.T) {
|
||||
_, err := keeper.CoinMetaRollbackProtectionAll(wctx, nil)
|
||||
require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request"))
|
||||
})
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) Config(c context.Context, req *types.QueryGetConfigRequest) (*types.QueryGetConfigResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
val, found := k.GetConfig(ctx)
|
||||
if !found {
|
||||
return nil, status.Error(codes.InvalidArgument, "not found")
|
||||
}
|
||||
|
||||
return &types.QueryGetConfigResponse{Config: val}, nil
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func TestConfigQuery(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
item := createTestConfig(keeper, ctx)
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
request *types.QueryGetConfigRequest
|
||||
response *types.QueryGetConfigResponse
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "First",
|
||||
request: &types.QueryGetConfigRequest{},
|
||||
response: &types.QueryGetConfigResponse{Config: item},
|
||||
},
|
||||
{
|
||||
desc: "InvalidRequest",
|
||||
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
response, err := keeper.Config(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
} else {
|
||||
require.Equal(t, tc.response, response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) ReplayProtectionAll(c context.Context, req *types.QueryAllReplayProtectionRequest) (*types.QueryAllReplayProtectionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
|
||||
var replayProtections []types.ReplayProtection
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
replayProtectionStore := prefix.NewStore(store, types.KeyPrefix(types.ReplayProtectionKeyPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(replayProtectionStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
var replayProtection types.ReplayProtection
|
||||
if err := k.cdc.Unmarshal(value, &replayProtection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
replayProtections = append(replayProtections, replayProtection)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &types.QueryAllReplayProtectionResponse{ReplayProtection: replayProtections, Pagination: pageRes}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) ReplayProtection(c context.Context, req *types.QueryGetReplayProtectionRequest) (*types.QueryGetReplayProtectionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
val, found := k.GetReplayProtection(
|
||||
ctx,
|
||||
req.Index,
|
||||
)
|
||||
if !found {
|
||||
return nil, status.Error(codes.InvalidArgument, "not found")
|
||||
}
|
||||
|
||||
return &types.QueryGetReplayProtectionResponse{ReplayProtection: val}, nil
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func TestReplayProtectionQuerySingle(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNReplayProtection(keeper, ctx, 2)
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
request *types.QueryGetReplayProtectionRequest
|
||||
response *types.QueryGetReplayProtectionResponse
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "First",
|
||||
request: &types.QueryGetReplayProtectionRequest{
|
||||
Index: msgs[0].Index,
|
||||
},
|
||||
response: &types.QueryGetReplayProtectionResponse{ReplayProtection: msgs[0]},
|
||||
},
|
||||
{
|
||||
desc: "Second",
|
||||
request: &types.QueryGetReplayProtectionRequest{
|
||||
Index: msgs[1].Index,
|
||||
},
|
||||
response: &types.QueryGetReplayProtectionResponse{ReplayProtection: msgs[1]},
|
||||
},
|
||||
{
|
||||
desc: "KeyNotFound",
|
||||
request: &types.QueryGetReplayProtectionRequest{
|
||||
Index: strconv.Itoa(100000),
|
||||
},
|
||||
err: status.Error(codes.InvalidArgument, "not found"),
|
||||
},
|
||||
{
|
||||
desc: "InvalidRequest",
|
||||
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
response, err := keeper.ReplayProtection(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
} else {
|
||||
require.Equal(t, tc.response, response)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayProtectionQueryPaginated(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNReplayProtection(keeper, ctx, 5)
|
||||
|
||||
request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllReplayProtectionRequest {
|
||||
return &types.QueryAllReplayProtectionRequest{
|
||||
Pagination: &query.PageRequest{
|
||||
Key: next,
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
CountTotal: total,
|
||||
},
|
||||
}
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.ReplayProtectionAll(wctx, request(nil, uint64(i), uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.ReplayProtection), step)
|
||||
require.Subset(t, msgs, resp.ReplayProtection)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.ReplayProtectionAll(wctx, request(next, 0, uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.ReplayProtection), step)
|
||||
require.Subset(t, msgs, resp.ReplayProtection)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
resp, err := keeper.ReplayProtectionAll(wctx, request(nil, 0, 0, true))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(msgs), int(resp.Pagination.Total))
|
||||
})
|
||||
t.Run("InvalidRequest", func(t *testing.T) {
|
||||
_, err := keeper.ReplayProtectionAll(wctx, nil)
|
||||
require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request"))
|
||||
})
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
type (
|
||||
Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
memKey sdk.StoreKey
|
||||
|
||||
accountKeeper types.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
wormholeKeeper types.WormholeKeeper
|
||||
}
|
||||
)
|
||||
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
storeKey,
|
||||
memKey sdk.StoreKey,
|
||||
|
||||
accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, wormholeKeeper types.WormholeKeeper,
|
||||
) *Keeper {
|
||||
return &Keeper{
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
memKey: memKey,
|
||||
|
||||
accountKeeper: accountKeeper, bankKeeper: bankKeeper, wormholeKeeper: wormholeKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
type msgServer struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the MsgServer interface
|
||||
// for the provided Keeper.
|
||||
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{Keeper: keeper}
|
||||
}
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
|
@ -1,95 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
whtypes "github.com/wormhole-foundation/wormhole-chain/x/wormhole/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func (k msgServer) AttestToken(goCtx context.Context, msg *types.MsgAttestToken) (*types.MsgAttestTokenResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
wormholeConfig, ok := k.wormholeKeeper.GetConfig(ctx)
|
||||
if !ok {
|
||||
return nil, whtypes.ErrNoConfig
|
||||
}
|
||||
|
||||
meta, found := k.bankKeeper.GetDenomMetaData(ctx, msg.Denom)
|
||||
if !found {
|
||||
return nil, types.ErrNoDenomMetadata
|
||||
}
|
||||
|
||||
// Don't attest wrapped assets (including uworm)
|
||||
_, _, wrapped := types.GetWrappedCoinMeta(meta.Display)
|
||||
if wrapped {
|
||||
return nil, types.ErrAttestWormholeToken
|
||||
}
|
||||
|
||||
// The display denom should have the most common decimal places
|
||||
var displayDenom *banktypes.DenomUnit
|
||||
for _, denom := range meta.DenomUnits {
|
||||
if denom.Denom == meta.Display {
|
||||
displayDenom = denom
|
||||
break
|
||||
}
|
||||
}
|
||||
if displayDenom == nil {
|
||||
return nil, types.ErrDisplayUnitNotFound
|
||||
}
|
||||
if displayDenom.Exponent > math.MaxUint8 {
|
||||
return nil, types.ErrExponentTooLarge
|
||||
}
|
||||
exponent := uint8(displayDenom.Exponent)
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
// PayloadID
|
||||
buf.WriteByte(2)
|
||||
tokenChain, tokenAddress, err := types.GetTokenMeta(wormholeConfig, meta.Base)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TokenAddress
|
||||
buf.Write(tokenAddress[:])
|
||||
// TokenChain
|
||||
MustWrite(buf, binary.BigEndian, tokenChain)
|
||||
// Decimals
|
||||
MustWrite(buf, binary.BigEndian, exponent)
|
||||
// Symbol
|
||||
symbolBytes, err := types.PadStringToByte32(meta.Symbol)
|
||||
if err != nil {
|
||||
return nil, types.ErrSymbolTooLong
|
||||
}
|
||||
buf.Write(symbolBytes[:])
|
||||
// Name
|
||||
nameBytes, err := types.PadStringToByte32(meta.Name)
|
||||
if err != nil {
|
||||
return nil, types.ErrNameTooLong
|
||||
}
|
||||
buf.Write(nameBytes[:])
|
||||
|
||||
// Post message
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
emitterAddress := whtypes.EmitterAddressFromAccAddress(moduleAddress)
|
||||
err = k.wormholeKeeper.PostMessage(ctx, emitterAddress, 0, buf.Bytes())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgAttestTokenResponse{}, nil
|
||||
}
|
||||
|
||||
// MustWrite calls binary.Write and panics on errors
|
||||
func MustWrite(w io.Writer, order binary.ByteOrder, data interface{}) {
|
||||
if err := binary.Write(w, order, data); err != nil {
|
||||
panic(fmt.Errorf("failed to write binary data: %v", data).Error())
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/wormhole/keeper"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
whtypes "github.com/wormhole-foundation/wormhole-chain/x/wormhole/types"
|
||||
)
|
||||
|
||||
type GovernanceAction uint8
|
||||
|
||||
// TokenBridgeModule is the identifier of the TokenBridge module (which is used for governance messages)
|
||||
// TODO(csongor): where's the best place to put this? CoreModule is in the node code, why is TokenBridgeModule not?
|
||||
var TokenBridgeModule = [32]byte{00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65}
|
||||
|
||||
var (
|
||||
ActionRegisterChain GovernanceAction = 1
|
||||
)
|
||||
|
||||
func (k msgServer) ExecuteGovernanceVAA(goCtx context.Context, msg *types.MsgExecuteGovernanceVAA) (*types.MsgExecuteGovernanceVAAResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
// Parse VAA
|
||||
v, err := keeper.ParseVAA(msg.Vaa)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Verify VAA
|
||||
action, payload, err := k.wormholeKeeper.VerifyGovernanceVAA(ctx, v, TokenBridgeModule)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wormholeConfig, ok := k.wormholeKeeper.GetConfig(ctx)
|
||||
if !ok {
|
||||
return nil, whtypes.ErrNoConfig
|
||||
}
|
||||
|
||||
// Execute action
|
||||
switch GovernanceAction(action) {
|
||||
case ActionRegisterChain:
|
||||
if len(payload) != 34 {
|
||||
return nil, types.ErrInvalidGovernancePayloadLength
|
||||
}
|
||||
// Add chain registration
|
||||
chainId := binary.BigEndian.Uint16(payload[:2])
|
||||
bridgeEmitter := payload[2:34]
|
||||
|
||||
if chainId == uint16(wormholeConfig.ChainId) {
|
||||
return nil, types.ErrRegisterWormholeChain
|
||||
}
|
||||
|
||||
if _, found := k.GetChainRegistration(ctx, uint32(chainId)); found {
|
||||
return nil, types.ErrChainAlreadyRegistered
|
||||
}
|
||||
|
||||
k.SetChainRegistration(ctx, types.ChainRegistration{
|
||||
ChainID: uint32(chainId),
|
||||
EmitterAddress: bridgeEmitter,
|
||||
})
|
||||
|
||||
// Emit event
|
||||
err = ctx.EventManager().EmitTypedEvent(&types.EventChainRegistered{
|
||||
ChainID: uint32(chainId),
|
||||
EmitterAddress: bridgeEmitter,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, types.ErrUnknownGovernanceAction
|
||||
|
||||
}
|
||||
|
||||
return &types.MsgExecuteGovernanceVAAResponse{}, nil
|
||||
}
|
|
@ -1,257 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
btypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/wormhole/keeper"
|
||||
whtypes "github.com/wormhole-foundation/wormhole-chain/x/wormhole/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
type PayloadID uint8
|
||||
|
||||
var (
|
||||
PayloadIDTransfer PayloadID = 1
|
||||
PayloadIDAssetMeta PayloadID = 2
|
||||
)
|
||||
|
||||
func (k msgServer) ExecuteVAA(goCtx context.Context, msg *types.MsgExecuteVAA) (*types.MsgExecuteVAAResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
// Parse VAA
|
||||
v, err := keeper.ParseVAA(msg.Vaa)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Verify VAA
|
||||
err = k.wormholeKeeper.VerifyVAA(ctx, v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wormholeConfig, ok := k.wormholeKeeper.GetConfig(ctx)
|
||||
if !ok {
|
||||
return nil, whtypes.ErrNoConfig
|
||||
}
|
||||
|
||||
// Replay protection
|
||||
_, known := k.GetReplayProtection(ctx, v.HexDigest())
|
||||
if known {
|
||||
return nil, types.ErrVAAAlreadyExecuted
|
||||
}
|
||||
|
||||
// Check if emitter is a registered chain
|
||||
registration, found := k.GetChainRegistration(ctx, uint32(v.EmitterChain))
|
||||
if !found {
|
||||
return nil, types.ErrUnregisteredChain
|
||||
}
|
||||
if !bytes.Equal(v.EmitterAddress[:], registration.EmitterAddress) {
|
||||
return nil, types.ErrUnregisteredEmitter
|
||||
}
|
||||
|
||||
if len(v.Payload) < 1 {
|
||||
return nil, types.ErrVAAPayloadInvalid
|
||||
}
|
||||
|
||||
payloadID := PayloadID(v.Payload[0])
|
||||
payload := v.Payload[1:]
|
||||
|
||||
switch payloadID {
|
||||
case PayloadIDTransfer:
|
||||
if len(payload) != 132 {
|
||||
return nil, types.ErrVAAPayloadInvalid
|
||||
}
|
||||
unnormalizedAmount := new(big.Int).SetBytes(payload[:32])
|
||||
var tokenAddress [32]byte
|
||||
copy(tokenAddress[:], payload[32:64])
|
||||
tokenChain := binary.BigEndian.Uint16(payload[64:66])
|
||||
var to [20]byte
|
||||
copy(to[:], payload[78:98])
|
||||
toChain := binary.BigEndian.Uint16(payload[98:100])
|
||||
unnormalizedFee := new(big.Int).SetBytes(payload[100:132])
|
||||
|
||||
// Check that the transfer is to this chain
|
||||
if uint32(toChain) != wormholeConfig.ChainId {
|
||||
return nil, types.ErrInvalidTargetChain
|
||||
}
|
||||
|
||||
identifier := ""
|
||||
var wrapped bool
|
||||
if types.IsWORMToken(tokenChain, tokenAddress) {
|
||||
identifier = "uworm"
|
||||
// We mint wormhole tokens because they are not native to wormhole chain
|
||||
wrapped = true
|
||||
} else if uint32(tokenChain) != wormholeConfig.ChainId {
|
||||
// Mint new wrapped assets if the coin is from another chain
|
||||
identifier = "b" + types.GetWrappedCoinIdentifier(tokenChain, tokenAddress)
|
||||
wrapped = true
|
||||
} else {
|
||||
// Recover the coin denom from the token address if it's a native coin
|
||||
identifier = strings.TrimLeft(string(tokenAddress[:]), "\x00")
|
||||
wrapped = false
|
||||
}
|
||||
|
||||
meta, found := k.bankKeeper.GetDenomMetaData(ctx, identifier)
|
||||
if !found {
|
||||
if !wrapped {
|
||||
return nil, types.ErrNoDenomMetadata
|
||||
} else {
|
||||
return nil, types.ErrAssetNotRegistered
|
||||
}
|
||||
}
|
||||
|
||||
amt := sdk.NewCoin(identifier, sdk.NewIntFromBigInt(unnormalizedAmount))
|
||||
if err := amt.Validate(); err != nil {
|
||||
return nil, fmt.Errorf("%w: %s", types.ErrInvalidAmount, err)
|
||||
}
|
||||
amount, err := types.Untruncate(amt, meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to untruncate amount: %w", err)
|
||||
}
|
||||
|
||||
f := sdk.NewCoin(identifier, sdk.NewIntFromBigInt(unnormalizedFee))
|
||||
if err := f.Validate(); err != nil {
|
||||
return nil, fmt.Errorf("%w: %s", types.ErrInvalidFee, err)
|
||||
}
|
||||
fee, err := types.Untruncate(f, meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to untruncate fee: %w", err)
|
||||
}
|
||||
|
||||
if amount.IsLT(fee) {
|
||||
return nil, types.ErrFeeTooHigh
|
||||
}
|
||||
|
||||
if wrapped {
|
||||
if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.Coins{amount}); err != nil {
|
||||
return nil, fmt.Errorf("failed to mint coins (%s): %w", amount, err)
|
||||
}
|
||||
}
|
||||
|
||||
moduleAccount := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
|
||||
amtLessFees := amount.Sub(fee)
|
||||
|
||||
if err := k.bankKeeper.SendCoins(ctx, moduleAccount, to[:], sdk.Coins{amtLessFees}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
txSender, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Transfer fee to tx sender if it is not 0
|
||||
if fee.IsPositive() {
|
||||
if err := k.bankKeeper.SendCoins(ctx, moduleAccount, txSender, sdk.Coins{fee}); err != nil {
|
||||
return nil, fmt.Errorf("failed to send fees (%s) to tx sender: %w", fee, err)
|
||||
}
|
||||
}
|
||||
|
||||
err = ctx.EventManager().EmitTypedEvent(&types.EventTransferReceived{
|
||||
TokenChain: uint32(tokenChain),
|
||||
TokenAddress: tokenAddress[:],
|
||||
To: sdk.AccAddress(to[:]).String(),
|
||||
FeeRecipient: txSender.String(),
|
||||
Amount: amount.Amount.String(),
|
||||
Fee: fee.Amount.String(),
|
||||
LocalDenom: identifier,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case PayloadIDAssetMeta:
|
||||
if len(payload) != 99 {
|
||||
return nil, types.ErrVAAPayloadInvalid
|
||||
}
|
||||
var tokenAddress [32]byte
|
||||
copy(tokenAddress[:], payload[:32])
|
||||
tokenChain := binary.BigEndian.Uint16(payload[32:34])
|
||||
decimals := payload[34]
|
||||
symbol := string(payload[35:67])
|
||||
symbol = strings.Trim(symbol, "\x00")
|
||||
name := string(payload[67:99])
|
||||
name = strings.Trim(name, "\x00")
|
||||
|
||||
// Don't allow native assets to be registered as wrapped asset
|
||||
if uint32(tokenChain) == wormholeConfig.ChainId {
|
||||
return nil, types.ErrNativeAssetRegistration
|
||||
}
|
||||
|
||||
if types.IsWORMToken(tokenChain, tokenAddress) {
|
||||
return nil, types.ErrNativeAssetRegistration
|
||||
}
|
||||
|
||||
if _, found := k.GetChainRegistration(ctx, uint32(tokenChain)); !found {
|
||||
return nil, types.ErrUnregisteredEmitter
|
||||
}
|
||||
|
||||
identifier := types.GetWrappedCoinIdentifier(tokenChain, tokenAddress)
|
||||
baseDenom := "b" + identifier
|
||||
rollBackProtection, found := k.GetCoinMetaRollbackProtection(ctx, identifier)
|
||||
if found && rollBackProtection.LastUpdateSequence >= v.Sequence {
|
||||
return nil, types.ErrAssetMetaRollback
|
||||
}
|
||||
|
||||
if meta, found := k.bankKeeper.GetDenomMetaData(ctx, baseDenom); found {
|
||||
if meta.Display != identifier {
|
||||
return nil, fmt.Errorf("mis-matched display denom; %s != %s", meta.Display, identifier)
|
||||
}
|
||||
|
||||
for _, d := range meta.DenomUnits {
|
||||
if d.Denom == identifier && d.Exponent != uint32(decimals) {
|
||||
return nil, types.ErrChangeDecimals
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
k.bankKeeper.SetDenomMetaData(ctx, btypes.Metadata{
|
||||
Description: fmt.Sprintf("Portal wrapped asset from chain %d with address %x", tokenChain, tokenAddress),
|
||||
DenomUnits: []*btypes.DenomUnit{
|
||||
{
|
||||
Denom: baseDenom,
|
||||
Exponent: 0,
|
||||
},
|
||||
{
|
||||
Denom: identifier,
|
||||
Exponent: uint32(decimals),
|
||||
},
|
||||
},
|
||||
Base: baseDenom,
|
||||
Display: identifier,
|
||||
Name: name,
|
||||
Symbol: symbol,
|
||||
})
|
||||
k.SetCoinMetaRollbackProtection(ctx, types.CoinMetaRollbackProtection{
|
||||
Index: identifier,
|
||||
LastUpdateSequence: v.Sequence,
|
||||
})
|
||||
|
||||
err = ctx.EventManager().EmitTypedEvent(&types.EventAssetRegistrationUpdate{
|
||||
TokenChain: uint32(tokenChain),
|
||||
TokenAddress: tokenAddress[:],
|
||||
Name: name,
|
||||
Symbol: symbol,
|
||||
Decimals: uint32(decimals),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, types.ErrUnknownPayloadType
|
||||
}
|
||||
|
||||
// Prevent replay
|
||||
k.SetReplayProtection(ctx, types.ReplayProtection{Index: v.HexDigest()})
|
||||
|
||||
return &types.MsgExecuteVAAResponse{}, nil
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) {
|
||||
k, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx)
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
whtypes "github.com/wormhole-foundation/wormhole-chain/x/wormhole/types"
|
||||
)
|
||||
|
||||
func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
msg.Amount = sdk.NormalizeCoin(msg.Amount)
|
||||
msg.Fee = sdk.NormalizeCoin(msg.Fee)
|
||||
|
||||
wormholeConfig, ok := k.wormholeKeeper.GetConfig(ctx)
|
||||
if !ok {
|
||||
return nil, whtypes.ErrNoConfig
|
||||
}
|
||||
|
||||
userAcc, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, found := k.GetChainRegistration(ctx, msg.ToChain); !found {
|
||||
return nil, types.ErrInvalidTargetChain
|
||||
}
|
||||
|
||||
meta, found := k.bankKeeper.GetDenomMetaData(ctx, msg.Amount.Denom)
|
||||
if !found {
|
||||
return nil, types.ErrNoDenomMetadata
|
||||
}
|
||||
|
||||
moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName)
|
||||
bridgeBalance, err := types.Truncate(k.bankKeeper.GetBalance(ctx, moduleAddress, msg.Amount.Denom), meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to truncate bridge balance: %w", err)
|
||||
}
|
||||
amount, err := types.Truncate(msg.Amount, meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %s", types.ErrInvalidAmount, err)
|
||||
}
|
||||
|
||||
fees, err := types.Truncate(msg.Fee, meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %s", types.ErrInvalidFee, err)
|
||||
}
|
||||
|
||||
if amount.IsLT(fees) {
|
||||
return nil, types.ErrFeeTooHigh
|
||||
}
|
||||
|
||||
if !amount.Amount.IsUint64() || !bridgeBalance.Amount.IsUint64() {
|
||||
return nil, types.ErrAmountTooHigh
|
||||
}
|
||||
|
||||
// Check that the total outflow of this asset does not exceed u64
|
||||
if !bridgeBalance.Add(amount).Amount.IsUint64() {
|
||||
return nil, types.ErrAmountTooHigh
|
||||
}
|
||||
|
||||
_, _, wrapped := types.GetWrappedCoinMeta(msg.Amount.Denom)
|
||||
if wrapped {
|
||||
// We previously minted these coins so just burn them now.
|
||||
if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.Coins{amount}); err != nil {
|
||||
return nil, sdkerrors.Wrap(err, "failed to burn wrapped coins")
|
||||
}
|
||||
} else {
|
||||
// Collect coins in the module account.
|
||||
if err := k.bankKeeper.SendCoins(ctx, userAcc, moduleAddress, sdk.Coins{amount}); err != nil {
|
||||
return nil, sdkerrors.Wrap(err, "failed to send coins to module account")
|
||||
}
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
// PayloadID
|
||||
buf.WriteByte(1)
|
||||
// Amount
|
||||
tokenAmountBytes32 := bytes32(amount.Amount.BigInt())
|
||||
buf.Write(tokenAmountBytes32[:])
|
||||
tokenChain, tokenAddress, err := types.GetTokenMeta(wormholeConfig, msg.Amount.Denom)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TokenAddress
|
||||
buf.Write(tokenAddress[:])
|
||||
// TokenChain
|
||||
MustWrite(buf, binary.BigEndian, tokenChain)
|
||||
// To
|
||||
buf.Write(msg.ToAddress)
|
||||
// ToChain
|
||||
MustWrite(buf, binary.BigEndian, uint16(msg.ToChain))
|
||||
// Fee
|
||||
feeBytes32 := bytes32(fees.Amount.BigInt())
|
||||
buf.Write(feeBytes32[:])
|
||||
|
||||
// Post message
|
||||
emitterAddress := whtypes.EmitterAddressFromAccAddress(moduleAddress)
|
||||
err = k.wormholeKeeper.PostMessage(ctx, emitterAddress, 0, buf.Bytes())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgTransferResponse{}, nil
|
||||
}
|
||||
|
||||
func bytes32(i *big.Int) [32]byte {
|
||||
var out [32]byte
|
||||
|
||||
i.FillBytes(out[:])
|
||||
|
||||
return out
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// SetReplayProtection set a specific replayProtection in the store from its index
|
||||
func (k Keeper) SetReplayProtection(ctx sdk.Context, replayProtection types.ReplayProtection) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReplayProtectionKeyPrefix))
|
||||
b := k.cdc.MustMarshal(&replayProtection)
|
||||
store.Set(types.ReplayProtectionKey(
|
||||
replayProtection.Index,
|
||||
), b)
|
||||
}
|
||||
|
||||
// GetReplayProtection returns a replayProtection from its index
|
||||
func (k Keeper) GetReplayProtection(
|
||||
ctx sdk.Context,
|
||||
index string,
|
||||
|
||||
) (val types.ReplayProtection, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReplayProtectionKeyPrefix))
|
||||
|
||||
b := store.Get(types.ReplayProtectionKey(
|
||||
index,
|
||||
))
|
||||
if b == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
// RemoveReplayProtection removes a replayProtection from the store
|
||||
func (k Keeper) RemoveReplayProtection(
|
||||
ctx sdk.Context,
|
||||
index string,
|
||||
|
||||
) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReplayProtectionKeyPrefix))
|
||||
store.Delete(types.ReplayProtectionKey(
|
||||
index,
|
||||
))
|
||||
}
|
||||
|
||||
// GetAllReplayProtection returns all replayProtection
|
||||
func (k Keeper) GetAllReplayProtection(ctx sdk.Context) (list []types.ReplayProtection) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReplayProtectionKeyPrefix))
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte{})
|
||||
|
||||
defer iterator.Close()
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var val types.ReplayProtection
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &val)
|
||||
list = append(list, val)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
keepertest "github.com/wormhole-foundation/wormhole-chain/testutil/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func createNReplayProtection(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.ReplayProtection {
|
||||
items := make([]types.ReplayProtection, n)
|
||||
for i := range items {
|
||||
items[i].Index = strconv.Itoa(i)
|
||||
|
||||
keeper.SetReplayProtection(ctx, items[i])
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func TestReplayProtectionGet(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNReplayProtection(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
rst, found := keeper.GetReplayProtection(ctx,
|
||||
item.Index,
|
||||
)
|
||||
require.True(t, found)
|
||||
require.Equal(t, item, rst)
|
||||
}
|
||||
}
|
||||
func TestReplayProtectionRemove(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNReplayProtection(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
keeper.RemoveReplayProtection(ctx,
|
||||
item.Index,
|
||||
)
|
||||
_, found := keeper.GetReplayProtection(ctx,
|
||||
item.Index,
|
||||
)
|
||||
require.False(t, found)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayProtectionGetAll(t *testing.T) {
|
||||
keeper, ctx := keepertest.TokenbridgeKeeper(t)
|
||||
items := createNReplayProtection(keeper, ctx, 10)
|
||||
require.ElementsMatch(t, items, keeper.GetAllReplayProtection(ctx))
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
package tokenbridge
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/client/cli"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/keeper"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AppModuleBasic
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// AppModuleBasic implements the AppModuleBasic interface for the capability module.
|
||||
type AppModuleBasic struct {
|
||||
cdc codec.BinaryCodec
|
||||
}
|
||||
|
||||
func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic {
|
||||
return AppModuleBasic{cdc: cdc}
|
||||
}
|
||||
|
||||
// Name returns the capability module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the module's interface types
|
||||
func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(reg)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns the capability module's default genesis state.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(types.DefaultGenesis())
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the capability module.
|
||||
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
|
||||
var genState types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
return genState.Validate()
|
||||
}
|
||||
|
||||
// RegisterRESTRoutes registers the capability module's REST service handlers.
|
||||
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
}
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
|
||||
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
||||
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
||||
}
|
||||
|
||||
// GetTxCmd returns the capability module's root tx command.
|
||||
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.GetTxCmd()
|
||||
}
|
||||
|
||||
// GetQueryCmd returns the capability module's root query command.
|
||||
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd(types.StoreKey)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AppModule
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// AppModule implements the AppModule interface for the capability module.
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: NewAppModuleBasic(cdc),
|
||||
keeper: keeper,
|
||||
}
|
||||
}
|
||||
|
||||
// Name returns the capability module's name.
|
||||
func (am AppModule) Name() string {
|
||||
return am.AppModuleBasic.Name()
|
||||
}
|
||||
|
||||
// Route returns the capability module's message routing key.
|
||||
func (am AppModule) Route() sdk.Route {
|
||||
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
|
||||
}
|
||||
|
||||
// QuerierRoute returns the capability module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return types.QuerierRoute }
|
||||
|
||||
// LegacyQuerierHandler returns the capability module's Querier.
|
||||
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterServices registers a GRPC query service to respond to the
|
||||
// module-specific GRPC queries.
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
||||
}
|
||||
|
||||
// RegisterInvariants registers the capability module's invariants.
|
||||
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
|
||||
|
||||
// InitGenesis performs the capability module's genesis initialization It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genState types.GenesisState
|
||||
// Initialize global index to index in genesis state
|
||||
cdc.MustUnmarshalJSON(gs, &genState)
|
||||
|
||||
InitGenesis(ctx, am.keeper, genState)
|
||||
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
genState := ExportGenesis(ctx, am.keeper)
|
||||
return cdc.MustMarshalJSON(genState)
|
||||
}
|
||||
|
||||
// ConsensusVersion implements ConsensusVersion.
|
||||
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
||||
|
||||
// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
|
||||
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
|
||||
|
||||
// EndBlock executes all ABCI EndBlock logic respective to the capability module. It
|
||||
// returns no validator updates.
|
||||
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
math "math"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
btypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
whtypes "github.com/wormhole-foundation/wormhole-chain/x/wormhole/types"
|
||||
)
|
||||
|
||||
// Truncate an amount
|
||||
func Truncate(coin sdk.Coin, meta btypes.Metadata) (normalized sdk.Coin, err error) {
|
||||
factor, err := truncFactor(meta)
|
||||
if err != nil {
|
||||
return normalized, err
|
||||
}
|
||||
|
||||
amt := new(big.Int).Div(coin.Amount.BigInt(), factor)
|
||||
return sdk.NewCoin(coin.Denom, sdk.NewIntFromBigInt(amt)), nil
|
||||
}
|
||||
|
||||
// Untruncate an amount
|
||||
func Untruncate(coin sdk.Coin, meta btypes.Metadata) (normalized sdk.Coin, err error) {
|
||||
factor, err := truncFactor(meta)
|
||||
if err != nil {
|
||||
return normalized, err
|
||||
}
|
||||
|
||||
amt := new(big.Int).Mul(coin.Amount.BigInt(), factor)
|
||||
return sdk.NewCoin(coin.Denom, sdk.NewIntFromBigInt(amt)), nil
|
||||
}
|
||||
|
||||
// Compute truncation factor for a given token meta.
|
||||
// This is max(1, exponent - 8). If you divide an amount by this number, the
|
||||
// result will have 8 decimals.
|
||||
func truncFactor(meta btypes.Metadata) (factor *big.Int, err error) {
|
||||
// Find the display denom to figure out decimals
|
||||
var displayDenom *btypes.DenomUnit
|
||||
for _, denom := range meta.DenomUnits {
|
||||
if denom.Denom == meta.Display {
|
||||
displayDenom = denom
|
||||
break
|
||||
}
|
||||
}
|
||||
if displayDenom == nil {
|
||||
return new(big.Int), ErrDisplayUnitNotFound
|
||||
}
|
||||
|
||||
if displayDenom.Exponent > math.MaxUint8 {
|
||||
return nil, ErrExponentTooLarge
|
||||
}
|
||||
|
||||
if displayDenom.Exponent > 8 {
|
||||
return new(big.Int).SetInt64(int64(math.Pow10(int(displayDenom.Exponent - 8)))), nil
|
||||
} else {
|
||||
return big.NewInt(1), nil
|
||||
}
|
||||
}
|
||||
|
||||
var uwormChain uint16 = 1
|
||||
var uwormAddress = [32]byte{0x16, 0x58, 0x09, 0x73, 0x92, 0x40, 0xa0, 0xac, 0x03, 0xb9, 0x84, 0x40, 0xfe, 0x89, 0x85, 0x54, 0x8e, 0x3a, 0xa6, 0x83, 0xcd, 0x0d, 0x4d, 0x9d, 0xf5, 0xb5, 0x65, 0x96, 0x69, 0xfa, 0xa3, 0x01}
|
||||
|
||||
func IsWORMToken(tokenChain uint16, tokenAddress [32]byte) bool {
|
||||
// TODO(csongor): figure out WORM token address on Solana
|
||||
// TODO(csongor): this should be configurable in the genesis
|
||||
return tokenChain == uwormChain && tokenAddress == uwormAddress
|
||||
}
|
||||
|
||||
// Derive the name of a wrapped token based on its origin chain and token address
|
||||
//
|
||||
// For most tokens, this looks something like
|
||||
//
|
||||
// "wh/00001/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300"
|
||||
//
|
||||
// where the string "wh" is followed by the token chain (fixed 5 characters)
|
||||
// in decimal, followed by the token address in hex (fixed 64 character).
|
||||
//
|
||||
// For the special case of the wormhole token it returns
|
||||
//
|
||||
// "uworm"
|
||||
func GetWrappedCoinIdentifier(tokenChain uint16, tokenAddress [32]byte) string {
|
||||
if IsWORMToken(tokenChain, tokenAddress) {
|
||||
return "uworm"
|
||||
} else {
|
||||
// log10(2^16) = 5, so we print token chain in 5 decimals
|
||||
return fmt.Sprintf("wh/%05d/%064x", tokenChain, tokenAddress)
|
||||
}
|
||||
}
|
||||
|
||||
// From a given wrapped token identifier, return the token chain and the token
|
||||
// address.
|
||||
func GetWrappedCoinMeta(identifier string) (tokenChain uint16, tokenAddress [32]byte, wrapped bool) {
|
||||
if identifier == "uworm" {
|
||||
return uwormChain, uwormAddress, true
|
||||
}
|
||||
|
||||
parts := strings.Split(identifier, "/")
|
||||
if len(parts) != 3 {
|
||||
return 0, [32]byte{}, false
|
||||
}
|
||||
if parts[0] != "wh" && parts[0] != "bwh" {
|
||||
return 0, [32]byte{}, false
|
||||
}
|
||||
if len(parts[1]) != 5 {
|
||||
return 0, [32]byte{}, false
|
||||
}
|
||||
if len(parts[2]) != 64 {
|
||||
return 0, [32]byte{}, false
|
||||
}
|
||||
|
||||
tokenChain64, err := strconv.ParseUint(parts[1], 10, 16)
|
||||
if err != nil {
|
||||
return 0, [32]byte{}, false
|
||||
}
|
||||
tokenChain = uint16(tokenChain64)
|
||||
|
||||
tokenAddressBytes, err := hex.DecodeString(parts[2])
|
||||
if err != nil {
|
||||
return 0, [32]byte{}, false
|
||||
}
|
||||
copy(tokenAddress[:], tokenAddressBytes[:])
|
||||
|
||||
return tokenChain, tokenAddress, true
|
||||
}
|
||||
|
||||
// Get the token chain and address. For wrapped assets, this is the address on
|
||||
// the original chain, for native assets, it's the (left-padded) display name.
|
||||
func GetTokenMeta(config whtypes.Config, identifier string) (chainId uint16, tokenAddress [32]byte, err error) {
|
||||
tokenChain, tokenAddress, wrapped := GetWrappedCoinMeta(identifier)
|
||||
|
||||
if wrapped {
|
||||
return tokenChain, tokenAddress, nil
|
||||
} else {
|
||||
padded, err := PadStringToByte32(identifier)
|
||||
if err != nil {
|
||||
return 0, [32]byte{}, err
|
||||
}
|
||||
return uint16(config.ChainId), padded, nil
|
||||
}
|
||||
}
|
||||
|
||||
// PadStringToByte32 left zero pads a string to the ethereum type bytes32
|
||||
func PadStringToByte32(s string) (padded [32]byte, err error) {
|
||||
if len(s) > 32 {
|
||||
return [32]byte{}, fmt.Errorf("string is too long; %d > 32", len(s))
|
||||
}
|
||||
|
||||
b := []byte(s)
|
||||
|
||||
left := make([]byte, 32-len(s))
|
||||
copy(padded[:], append(left[:], b[:]...))
|
||||
return padded, nil
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var testToken [32]byte = [32]byte{0x16, 0x58, 0x09, 0x73, 0x92, 0x40, 0xa0, 0xac, 0x03, 0xb9, 0x84, 0x40, 0xfe, 0x89, 0x85, 0x54, 0x8e, 0x3a, 0xa6, 0x83, 0xcd, 0x0d, 0x4d, 0x9d, 0xf5, 0xb5, 0x65, 0x96, 0x69, 0xfa, 0xa3, 0x00}
|
||||
var uworm [32]byte = [32]byte{0x16, 0x58, 0x09, 0x73, 0x92, 0x40, 0xa0, 0xac, 0x03, 0xb9, 0x84, 0x40, 0xfe, 0x89, 0x85, 0x54, 0x8e, 0x3a, 0xa6, 0x83, 0xcd, 0x0d, 0x4d, 0x9d, 0xf5, 0xb5, 0x65, 0x96, 0x69, 0xfa, 0xa3, 0x01}
|
||||
|
||||
func TestGetWrappedTokenIdentifier(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
tokenChain uint16
|
||||
tokenAddress [32]byte
|
||||
result string
|
||||
}{
|
||||
{
|
||||
name: "Wrapped token from Solana",
|
||||
tokenChain: 1,
|
||||
tokenAddress: testToken,
|
||||
result: "wh/00001/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300",
|
||||
},
|
||||
{
|
||||
name: "uworm token (from Solana)",
|
||||
tokenChain: 1,
|
||||
tokenAddress: uworm,
|
||||
result: "uworm",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := GetWrappedCoinIdentifier(tt.tokenChain, tt.tokenAddress)
|
||||
require.EqualValues(t, tt.result, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetWrappedCoinMeta(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
identifier string
|
||||
tokenChain uint16
|
||||
tokenAddress [32]byte
|
||||
wrapped bool
|
||||
}{
|
||||
{
|
||||
name: "Wrapped token from Solana",
|
||||
identifier: "wh/00001/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300",
|
||||
tokenChain: 1,
|
||||
tokenAddress: testToken,
|
||||
wrapped: true,
|
||||
},
|
||||
{
|
||||
name: "uworm token (from Solana)",
|
||||
identifier: "uworm",
|
||||
tokenChain: 1,
|
||||
tokenAddress: uworm,
|
||||
wrapped: true,
|
||||
},
|
||||
{
|
||||
name: "Too large token chain",
|
||||
identifier: "wh/99999/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300",
|
||||
tokenChain: 0,
|
||||
tokenAddress: [32]byte{},
|
||||
wrapped: false,
|
||||
},
|
||||
{
|
||||
name: "Native token",
|
||||
identifier: "asdasd",
|
||||
tokenChain: 0,
|
||||
tokenAddress: [32]byte{},
|
||||
wrapped: false,
|
||||
},
|
||||
{
|
||||
name: "Not matching format",
|
||||
identifier: "wh/999/150794aa0b98440fe8985548e3aa683cd0d4d9df5b5659669faa300",
|
||||
tokenChain: 0,
|
||||
tokenAddress: [32]byte{},
|
||||
wrapped: false,
|
||||
},
|
||||
{
|
||||
name: "negative chain id",
|
||||
identifier: "wh/-0222/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300",
|
||||
tokenChain: 0,
|
||||
tokenAddress: [32]byte{},
|
||||
wrapped: false,
|
||||
},
|
||||
{
|
||||
name: "base denom",
|
||||
identifier: fmt.Sprintf("bwh/00008/%s", hex.EncodeToString(testToken[:])),
|
||||
tokenChain: 8,
|
||||
tokenAddress: testToken,
|
||||
wrapped: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tokenChain, tokenAddress, wrapped := GetWrappedCoinMeta(tt.identifier)
|
||||
require.EqualValues(t, tt.tokenChain, tokenChain)
|
||||
require.EqualValues(t, tt.tokenAddress, tokenAddress)
|
||||
require.EqualValues(t, tt.wrapped, wrapped)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
func RegisterCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgExecuteGovernanceVAA{}, "tokenbridge/ExecuteGovernanceVAA", nil)
|
||||
cdc.RegisterConcrete(&MsgExecuteVAA{}, "tokenbridge/ExecuteVAA", nil)
|
||||
cdc.RegisterConcrete(&MsgAttestToken{}, "tokenbridge/AttestToken", nil)
|
||||
cdc.RegisterConcrete(&MsgTransfer{}, "tokenbridge/Transfer", nil)
|
||||
// this line is used by starport scaffolding # 2
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgExecuteGovernanceVAA{},
|
||||
)
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgExecuteVAA{},
|
||||
)
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgAttestToken{},
|
||||
)
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgTransfer{},
|
||||
)
|
||||
// this line is used by starport scaffolding # 3
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var (
|
||||
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
|
||||
)
|
|
@ -1,41 +0,0 @@
|
|||
package types
|
||||
|
||||
// DONTCOVER
|
||||
|
||||
import (
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// x/tokenbridge module sentinel errors
|
||||
var (
|
||||
ErrUnknownGovernanceModule = sdkerrors.Register(ModuleName, 1105, "invalid governance module")
|
||||
ErrInvalidGovernanceEmitter = sdkerrors.Register(ModuleName, 1107, "invalid governance emitter")
|
||||
ErrUnknownGovernanceAction = sdkerrors.Register(ModuleName, 1108, "unknown governance action")
|
||||
ErrGovernanceHeaderTooShort = sdkerrors.Register(ModuleName, 1109, "governance header too short")
|
||||
ErrInvalidGovernanceTargetChain = sdkerrors.Register(ModuleName, 1110, "governance target chain does not match")
|
||||
ErrInvalidGovernancePayloadLength = sdkerrors.Register(ModuleName, 1111, "governance payload has incorrect length")
|
||||
ErrVAAAlreadyExecuted = sdkerrors.Register(ModuleName, 1113, "VAA was already executed")
|
||||
ErrChainAlreadyRegistered = sdkerrors.Register(ModuleName, 1114, "Chain already registered")
|
||||
ErrUnregisteredEmitter = sdkerrors.Register(ModuleName, 1115, "emitter is not registered")
|
||||
ErrVAAPayloadInvalid = sdkerrors.Register(ModuleName, 1116, "invalid VAA payload")
|
||||
ErrAssetNotRegistered = sdkerrors.Register(ModuleName, 1117, "asset not registered")
|
||||
ErrInvalidTargetChain = sdkerrors.Register(ModuleName, 1118, "invalid target chain on transfer")
|
||||
ErrUnknownPayloadType = sdkerrors.Register(ModuleName, 1119, "unknown payload type")
|
||||
ErrNativeAssetRegistration = sdkerrors.Register(ModuleName, 1120, "cannot register native asset")
|
||||
ErrNoDenomMetadata = sdkerrors.Register(ModuleName, 1121, "denom does not have metadata")
|
||||
ErrAttestWormholeToken = sdkerrors.Register(ModuleName, 1122, "cannot attest wormhole wrapped asset")
|
||||
ErrNameTooLong = sdkerrors.Register(ModuleName, 1124, "name too long for attestation")
|
||||
ErrSymbolTooLong = sdkerrors.Register(ModuleName, 1125, "symbol too long for attestation")
|
||||
ErrDisplayUnitNotFound = sdkerrors.Register(ModuleName, 1126, "display denom unit not found")
|
||||
ErrExponentTooLarge = sdkerrors.Register(ModuleName, 1127, "exponent of display unit must be uint8")
|
||||
ErrInvalidToAddress = sdkerrors.Register(ModuleName, 1128, "to address is invalid (must be 32 bytes)")
|
||||
ErrInvalidFee = sdkerrors.Register(ModuleName, 1130, "fee is invalid (must fit in uint256)")
|
||||
ErrInvalidAmount = sdkerrors.Register(ModuleName, 1131, "amount is invalid (must fit in uint256)")
|
||||
ErrFeeTooHigh = sdkerrors.Register(ModuleName, 1132, "fee must be < amount")
|
||||
ErrAmountTooHigh = sdkerrors.Register(ModuleName, 1133, "the amount would exceed the bridges capacity of u64")
|
||||
ErrAssetMetaRollback = sdkerrors.Register(ModuleName, 1134, "asset meta must have a higher sequence than the last update")
|
||||
ErrNegativeFee = sdkerrors.Register(ModuleName, 1135, "fee cannot be negative")
|
||||
ErrRegisterWormholeChain = sdkerrors.Register(ModuleName, 1136, "cannot register an emitter for wormhole-chain on wormhole-chain")
|
||||
ErrChangeDecimals = sdkerrors.Register(ModuleName, 1137, "cannot change decimals of registered asset metadata")
|
||||
ErrUnregisteredChain = sdkerrors.Register(ModuleName, 1138, "chain is not registered")
|
||||
)
|
|
@ -1,31 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
btypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/wormhole/types"
|
||||
"github.com/wormhole-foundation/wormhole/sdk/vaa"
|
||||
)
|
||||
|
||||
type AccountKeeper interface {
|
||||
// Methods imported from account should be defined here
|
||||
GetModuleAddress(moduleName string) sdk.AccAddress
|
||||
}
|
||||
|
||||
type BankKeeper interface {
|
||||
// Methods imported from bank should be defined here
|
||||
MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
|
||||
BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
|
||||
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
SetDenomMetaData(ctx sdk.Context, denomMetaData btypes.Metadata)
|
||||
GetDenomMetaData(ctx sdk.Context, denom string) (denomMetaData btypes.Metadata, found bool)
|
||||
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
||||
}
|
||||
|
||||
type WormholeKeeper interface {
|
||||
// Methods imported from wormhole should be defined here
|
||||
VerifyVAA(ctx sdk.Context, vaa *vaa.VAA) error
|
||||
VerifyGovernanceVAA(ctx sdk.Context, v *vaa.VAA, module [32]byte) (action byte, payload []byte, err error)
|
||||
GetConfig(ctx sdk.Context) (val types.Config, found bool)
|
||||
PostMessage(ctx sdk.Context, emitter types.EmitterAddress, nonce uint32, data []byte) error
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DefaultIndex is the default capability global index
|
||||
const DefaultIndex uint64 = 1
|
||||
|
||||
// DefaultGenesis returns the default Capability genesis state
|
||||
func DefaultGenesis() *GenesisState {
|
||||
return &GenesisState{
|
||||
Config: nil,
|
||||
ReplayProtectionList: []ReplayProtection{},
|
||||
ChainRegistrationList: []ChainRegistration{},
|
||||
CoinMetaRollbackProtectionList: []CoinMetaRollbackProtection{},
|
||||
// this line is used by starport scaffolding # genesis/types/default
|
||||
}
|
||||
}
|
||||
|
||||
// Validate performs basic genesis state validation returning an error upon any
|
||||
// failure.
|
||||
func (gs GenesisState) Validate() error {
|
||||
// Check for duplicated index in replayProtection
|
||||
replayProtectionIndexMap := make(map[string]struct{})
|
||||
|
||||
for _, elem := range gs.ReplayProtectionList {
|
||||
index := string(ReplayProtectionKey(elem.Index))
|
||||
if _, ok := replayProtectionIndexMap[index]; ok {
|
||||
return fmt.Errorf("duplicated index for replayProtection")
|
||||
}
|
||||
replayProtectionIndexMap[index] = struct{}{}
|
||||
}
|
||||
// Check for duplicated index in chainRegistration
|
||||
chainRegistrationIndexMap := make(map[string]struct{})
|
||||
|
||||
for _, elem := range gs.ChainRegistrationList {
|
||||
index := string(ChainRegistrationKey(elem.ChainID))
|
||||
if _, ok := chainRegistrationIndexMap[index]; ok {
|
||||
return fmt.Errorf("duplicated index for chainRegistration")
|
||||
}
|
||||
chainRegistrationIndexMap[index] = struct{}{}
|
||||
}
|
||||
// Check for duplicated index in coinMetaRollbackProtection
|
||||
coinMetaRollbackProtectionIndexMap := make(map[string]struct{})
|
||||
|
||||
for _, elem := range gs.CoinMetaRollbackProtectionList {
|
||||
index := string(CoinMetaRollbackProtectionKey(elem.Index))
|
||||
if _, ok := coinMetaRollbackProtectionIndexMap[index]; ok {
|
||||
return fmt.Errorf("duplicated index for coinMetaRollbackProtection")
|
||||
}
|
||||
coinMetaRollbackProtectionIndexMap[index] = struct{}{}
|
||||
}
|
||||
// this line is used by starport scaffolding # genesis/types/validate
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/wormhole-foundation/wormhole-chain/x/tokenbridge/types"
|
||||
)
|
||||
|
||||
func TestGenesisState_Validate(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
genState *types.GenesisState
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
desc: "default is valid",
|
||||
genState: types.DefaultGenesis(),
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
desc: "valid genesis state",
|
||||
genState: &types.GenesisState{
|
||||
Config: &types.Config{},
|
||||
ReplayProtectionList: []types.ReplayProtection{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "1",
|
||||
},
|
||||
},
|
||||
ChainRegistrationList: []types.ChainRegistration{
|
||||
{
|
||||
ChainID: 0,
|
||||
},
|
||||
{
|
||||
ChainID: 1,
|
||||
},
|
||||
},
|
||||
CoinMetaRollbackProtectionList: []types.CoinMetaRollbackProtection{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "1",
|
||||
},
|
||||
},
|
||||
// this line is used by starport scaffolding # types/genesis/validField
|
||||
},
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
desc: "duplicated replayProtection",
|
||||
genState: &types.GenesisState{
|
||||
ReplayProtectionList: []types.ReplayProtection{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
desc: "duplicated chainRegistration",
|
||||
genState: &types.GenesisState{
|
||||
ChainRegistrationList: []types.ChainRegistration{
|
||||
{
|
||||
ChainID: 0,
|
||||
},
|
||||
{
|
||||
ChainID: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
desc: "duplicated coinMetaRollbackProtection",
|
||||
genState: &types.GenesisState{
|
||||
CoinMetaRollbackProtectionList: []types.CoinMetaRollbackProtection{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
valid: false,
|
||||
},
|
||||
// this line is used by starport scaffolding # types/genesis/testcase
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
err := tc.genState.Validate()
|
||||
if tc.valid {
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package types
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
var _ binary.ByteOrder
|
||||
|
||||
const (
|
||||
// ChainRegistrationKeyPrefix is the prefix to retrieve all ChainRegistration
|
||||
ChainRegistrationKeyPrefix = "ChainRegistration/value/"
|
||||
)
|
||||
|
||||
// ChainRegistrationKey returns the store key to retrieve a ChainRegistration from the index fields
|
||||
func ChainRegistrationKey(
|
||||
index uint32,
|
||||
) []byte {
|
||||
key := make([]byte, 4)
|
||||
binary.BigEndian.PutUint32(key, index)
|
||||
key = append(key, []byte("/")...)
|
||||
|
||||
return key
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package types
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
var _ binary.ByteOrder
|
||||
|
||||
const (
|
||||
// CoinMetaRollbackProtectionKeyPrefix is the prefix to retrieve all CoinMetaRollbackProtection
|
||||
CoinMetaRollbackProtectionKeyPrefix = "CoinMetaRollbackProtection/value/"
|
||||
)
|
||||
|
||||
// CoinMetaRollbackProtectionKey returns the store key to retrieve a CoinMetaRollbackProtection from the index fields
|
||||
func CoinMetaRollbackProtectionKey(
|
||||
index string,
|
||||
) []byte {
|
||||
var key []byte
|
||||
|
||||
indexBytes := []byte(index)
|
||||
key = append(key, indexBytes...)
|
||||
key = append(key, []byte("/")...)
|
||||
|
||||
return key
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package types
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
var _ binary.ByteOrder
|
||||
|
||||
const (
|
||||
// ReplayProtectionKeyPrefix is the prefix to retrieve all ReplayProtection
|
||||
ReplayProtectionKeyPrefix = "ReplayProtection/value/"
|
||||
)
|
||||
|
||||
// ReplayProtectionKey returns the store key to retrieve a ReplayProtection from the index fields
|
||||
func ReplayProtectionKey(
|
||||
index string,
|
||||
) []byte {
|
||||
var key []byte
|
||||
|
||||
indexBytes := []byte(index)
|
||||
key = append(key, indexBytes...)
|
||||
key = append(key, []byte("/")...)
|
||||
|
||||
return key
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package types
|
||||
|
||||
const (
|
||||
// ModuleName defines the module name
|
||||
ModuleName = "tokenbridge"
|
||||
|
||||
// StoreKey defines the primary module store key
|
||||
StoreKey = ModuleName
|
||||
|
||||
// RouterKey is the message route for slashing
|
||||
RouterKey = ModuleName
|
||||
|
||||
// QuerierRoute defines the module's query routing key
|
||||
QuerierRoute = ModuleName
|
||||
|
||||
// MemStoreKey defines the in-memory store key
|
||||
MemStoreKey = "mem_tokenbridge"
|
||||
)
|
||||
|
||||
func KeyPrefix(p string) []byte {
|
||||
return []byte(p)
|
||||
}
|
||||
|
||||
const (
|
||||
ConfigKey = "Config-value-"
|
||||
)
|
|
@ -1,44 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _ sdk.Msg = &MsgAttestToken{}
|
||||
|
||||
func NewMsgAttestToken(creator string, denom string) *MsgAttestToken {
|
||||
return &MsgAttestToken{
|
||||
Creator: creator,
|
||||
Denom: denom,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgAttestToken) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgAttestToken) Type() string {
|
||||
return "AttestToken"
|
||||
}
|
||||
|
||||
func (msg *MsgAttestToken) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgAttestToken) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgAttestToken) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/sample"
|
||||
)
|
||||
|
||||
func TestMsgAttestToken_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgAttestToken
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgAttestToken{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
name: "valid address",
|
||||
msg: MsgAttestToken{
|
||||
Creator: sample.AccAddress(),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _ sdk.Msg = &MsgExecuteGovernanceVAA{}
|
||||
|
||||
func NewMsgExecuteGovernanceVAA(creator string, vaa []byte) *MsgExecuteGovernanceVAA {
|
||||
return &MsgExecuteGovernanceVAA{
|
||||
Creator: creator,
|
||||
Vaa: vaa,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteGovernanceVAA) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteGovernanceVAA) Type() string {
|
||||
return "ExecuteGovernanceVAA"
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteGovernanceVAA) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteGovernanceVAA) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteGovernanceVAA) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/sample"
|
||||
)
|
||||
|
||||
func TestMsgExecuteGovernanceVAA_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgExecuteGovernanceVAA
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgExecuteGovernanceVAA{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
name: "valid address",
|
||||
msg: MsgExecuteGovernanceVAA{
|
||||
Creator: sample.AccAddress(),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _ sdk.Msg = &MsgExecuteVAA{}
|
||||
|
||||
func NewMsgExecuteVAA(creator string, vaa []byte) *MsgExecuteVAA {
|
||||
return &MsgExecuteVAA{
|
||||
Creator: creator,
|
||||
Vaa: vaa,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteVAA) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteVAA) Type() string {
|
||||
return "ExecuteVAA"
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteVAA) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteVAA) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgExecuteVAA) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/sample"
|
||||
)
|
||||
|
||||
func TestMsgExecuteVAA_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgExecuteVAA
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgExecuteVAA{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
name: "valid address",
|
||||
msg: MsgExecuteVAA{
|
||||
Creator: sample.AccAddress(),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _ sdk.Msg = &MsgTransfer{}
|
||||
|
||||
func NewMsgTransfer(creator string, amount sdk.Coin, toChain uint16, toAddress []byte, fee sdk.Coin) *MsgTransfer {
|
||||
return &MsgTransfer{
|
||||
Creator: creator,
|
||||
Amount: amount,
|
||||
ToChain: uint32(toChain),
|
||||
ToAddress: toAddress,
|
||||
Fee: fee,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgTransfer) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgTransfer) Type() string {
|
||||
return "Transfer"
|
||||
}
|
||||
|
||||
func (msg *MsgTransfer) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgTransfer) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgTransfer) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
|
||||
if err := msg.Amount.Validate(); err != nil {
|
||||
return fmt.Errorf("%w: %s", ErrInvalidAmount, err)
|
||||
}
|
||||
|
||||
if msg.ToChain > uint32(^uint16(0)) {
|
||||
return ErrInvalidTargetChain
|
||||
}
|
||||
|
||||
if len(msg.ToAddress) != 32 {
|
||||
return ErrInvalidToAddress
|
||||
}
|
||||
|
||||
if err := msg.Fee.Validate(); err != nil {
|
||||
return fmt.Errorf("%w: %s", ErrInvalidFee, err)
|
||||
}
|
||||
|
||||
if msg.Amount.Denom != msg.Fee.Denom {
|
||||
return fmt.Errorf("%w: Fee must have the same denom as Amount", ErrInvalidFee)
|
||||
}
|
||||
|
||||
if msg.Amount.Amount.BigInt().Cmp(msg.Fee.Amount.BigInt()) != 1 {
|
||||
return ErrFeeTooHigh
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/wormhole-foundation/wormhole-chain/testutil/sample"
|
||||
)
|
||||
|
||||
func TestMsgTransfer_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgTransfer
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgTransfer{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
name: "valid address",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)),
|
||||
ToChain: 1,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)),
|
||||
},
|
||||
}, {
|
||||
name: "negative amount",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(-10)},
|
||||
ToChain: 0,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)),
|
||||
},
|
||||
err: ErrInvalidAmount,
|
||||
}, {
|
||||
name: "invalid amount denom",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.Coin{Denom: "007test", Amount: sdk.NewInt(10)},
|
||||
ToChain: 0,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)),
|
||||
},
|
||||
err: ErrInvalidAmount,
|
||||
}, {
|
||||
name: "negative fee",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)),
|
||||
ToChain: 0,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(-10)},
|
||||
},
|
||||
err: ErrInvalidFee,
|
||||
}, {
|
||||
name: "invalid fee denom",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)),
|
||||
ToChain: 0,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.Coin{Denom: "007test", Amount: sdk.NewInt(10)},
|
||||
},
|
||||
err: ErrInvalidFee,
|
||||
}, {
|
||||
name: "invalid target chain",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)),
|
||||
ToChain: uint32(^uint16(0)) + 1,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)),
|
||||
},
|
||||
err: ErrInvalidTargetChain,
|
||||
}, {
|
||||
name: "invalid target address",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)),
|
||||
ToChain: 1,
|
||||
ToAddress: make([]byte, 16),
|
||||
Fee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)),
|
||||
},
|
||||
err: ErrInvalidToAddress,
|
||||
}, {
|
||||
name: "mismatched denoms",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)),
|
||||
ToChain: 1,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.NewCoin("test", sdk.NewInt(1)),
|
||||
},
|
||||
err: ErrInvalidFee,
|
||||
}, {
|
||||
name: "fee too high",
|
||||
msg: MsgTransfer{
|
||||
Creator: sample.AccAddress(),
|
||||
Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)),
|
||||
ToChain: 1,
|
||||
ToAddress: make([]byte, 32),
|
||||
Fee: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10)),
|
||||
},
|
||||
err: ErrFeeTooHigh,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,705 +0,0 @@
|
|||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: tokenbridge/query.proto
|
||||
|
||||
/*
|
||||
Package types is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/descriptor"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
var _ = metadata.Join
|
||||
|
||||
func request_Query_Config_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetConfigRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.Config(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Config_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetConfigRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.Config(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_ReplayProtection_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetReplayProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["index"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "index")
|
||||
}
|
||||
|
||||
protoReq.Index, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "index", err)
|
||||
}
|
||||
|
||||
msg, err := client.ReplayProtection(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ReplayProtection_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetReplayProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["index"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "index")
|
||||
}
|
||||
|
||||
protoReq.Index, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "index", err)
|
||||
}
|
||||
|
||||
msg, err := server.ReplayProtection(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_ReplayProtectionAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_ReplayProtectionAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllReplayProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ReplayProtectionAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ReplayProtectionAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ReplayProtectionAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllReplayProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ReplayProtectionAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ReplayProtectionAll(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_ChainRegistration_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetChainRegistrationRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["chainID"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chainID")
|
||||
}
|
||||
|
||||
protoReq.ChainID, err = runtime.Uint32(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chainID", err)
|
||||
}
|
||||
|
||||
msg, err := client.ChainRegistration(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ChainRegistration_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetChainRegistrationRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["chainID"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chainID")
|
||||
}
|
||||
|
||||
protoReq.ChainID, err = runtime.Uint32(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chainID", err)
|
||||
}
|
||||
|
||||
msg, err := server.ChainRegistration(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_ChainRegistrationAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_ChainRegistrationAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllChainRegistrationRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChainRegistrationAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ChainRegistrationAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_ChainRegistrationAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllChainRegistrationRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChainRegistrationAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ChainRegistrationAll(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_CoinMetaRollbackProtection_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetCoinMetaRollbackProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["index"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "index")
|
||||
}
|
||||
|
||||
protoReq.Index, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "index", err)
|
||||
}
|
||||
|
||||
msg, err := client.CoinMetaRollbackProtection(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_CoinMetaRollbackProtection_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetCoinMetaRollbackProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["index"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "index")
|
||||
}
|
||||
|
||||
protoReq.Index, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "index", err)
|
||||
}
|
||||
|
||||
msg, err := server.CoinMetaRollbackProtection(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_CoinMetaRollbackProtectionAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_CoinMetaRollbackProtectionAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllCoinMetaRollbackProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CoinMetaRollbackProtectionAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.CoinMetaRollbackProtectionAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_CoinMetaRollbackProtectionAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllCoinMetaRollbackProtectionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CoinMetaRollbackProtectionAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.CoinMetaRollbackProtectionAll(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Config_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_Config_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Config_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ReplayProtection_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ReplayProtection_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ReplayProtection_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ReplayProtectionAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ReplayProtectionAll_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ReplayProtectionAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ChainRegistration_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ChainRegistration_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ChainRegistration_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ChainRegistrationAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_ChainRegistrationAll_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ChainRegistrationAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_CoinMetaRollbackProtection_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_CoinMetaRollbackProtection_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_CoinMetaRollbackProtection_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_CoinMetaRollbackProtectionAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_CoinMetaRollbackProtectionAll_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_CoinMetaRollbackProtectionAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterQueryHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers the http handlers for service Query to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerClient registers the http handlers for service Query
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "QueryClient" to call the correct interceptors.
|
||||
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Config_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_Config_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Config_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ReplayProtection_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ReplayProtection_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ReplayProtection_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ReplayProtectionAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ReplayProtectionAll_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ReplayProtectionAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ChainRegistration_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ChainRegistration_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ChainRegistration_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_ChainRegistrationAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_ChainRegistrationAll_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_ChainRegistrationAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_CoinMetaRollbackProtection_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_CoinMetaRollbackProtection_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_CoinMetaRollbackProtection_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_CoinMetaRollbackProtectionAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_CoinMetaRollbackProtectionAll_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_CoinMetaRollbackProtectionAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Config_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "config"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_ReplayProtection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "replayProtection", "index"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_ReplayProtectionAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "replayProtection"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_ChainRegistration_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "chainRegistration", "chainID"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_ChainRegistrationAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "chainRegistration"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_CoinMetaRollbackProtection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "coinMetaRollbackProtection", "index"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_CoinMetaRollbackProtectionAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"wormhole_foundation", "wormholechain", "tokenbridge", "coinMetaRollbackProtection"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Query_Config_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ReplayProtection_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ReplayProtectionAll_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ChainRegistration_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_ChainRegistrationAll_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_CoinMetaRollbackProtection_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_CoinMetaRollbackProtectionAll_0 = runtime.ForwardResponseMessage
|
||||
)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue