Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Create Protubuf type registry (#171)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom <[email protected]>
Co-authored-by: Sandoche ADITTANE <[email protected]>
  • Loading branch information
3 people authored May 16, 2023
1 parent 089da3d commit 8216395
Show file tree
Hide file tree
Showing 58 changed files with 495 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/proto/src/messages/authz/authz.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createGenericAuthorization } from './generic'
import { GenericAuthorization } from '../../proto/cosmos/authz/authz'
import { MsgGrant, MsgRevoke } from '../../proto/cosmos/authz/tx'
import { from, to } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

const msgType = 'cosmos-sdk/MsgSend'

Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/authz/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './authz.js'
export * from './generic.js'
export * from './registry.js'
export * from './stake.js'
24 changes: 24 additions & 0 deletions packages/proto/src/messages/authz/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { authzRegistryTypes } from './registry'

import { MsgGrant, MsgRevoke, MsgExec } from '../../proto/cosmos/authz/tx'
import { Grant, GenericAuthorization } from '../../proto/cosmos/authz/authz'
import {
StakeAuthorization,
// eslint-disable-next-line camelcase
StakeAuthorization_Validators,
} from '../../proto/cosmos/staking/authz'

describe('test authz registry types against expected', () => {
it('exactly equals expected types', () => {
expect(authzRegistryTypes).toStrictEqual([
Grant,
MsgGrant,
MsgRevoke,
MsgExec,
GenericAuthorization,
StakeAuthorization,
// eslint-disable-next-line camelcase
StakeAuthorization_Validators,
])
})
})
18 changes: 18 additions & 0 deletions packages/proto/src/messages/authz/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MsgGrant, MsgRevoke, MsgExec } from '../../proto/cosmos/authz/tx.js'
import { Grant, GenericAuthorization } from '../../proto/cosmos/authz/authz.js'
import {
StakeAuthorization,
// eslint-disable-next-line camelcase
StakeAuthorization_Validators,
} from '../../proto/cosmos/staking/authz.js'

export const authzRegistryTypes = [
Grant,
MsgGrant,
MsgRevoke,
MsgExec,
GenericAuthorization,
StakeAuthorization,
// eslint-disable-next-line camelcase
StakeAuthorization_Validators,
]
2 changes: 1 addition & 1 deletion packages/proto/src/messages/authz/stake.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createStakeAuthorization } from './stake'
import { StakeAuthorization } from '../../proto/cosmos/staking/authz'
import { denom, val, val2 } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

const validateStakeAuthorization = (validators: string | string[]) => {
const authorization = 1
Expand Down
2 changes: 1 addition & 1 deletion packages/proto/src/messages/bank/bank.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMsgSend } from './msgSend'
import { MsgSend } from '../../proto/cosmos/bank/tx'
import { from, to, denom } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test Bank Module message generation', () => {
it('correctly wraps MsgSend', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/bank/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './msgSend.js'
export * from './registry.js'
10 changes: 10 additions & 0 deletions packages/proto/src/messages/bank/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { bankRegistryTypes } from './registry'

import { MsgSend, MsgMultiSend } from '../../proto/cosmos/bank/tx'
import { Metadata } from '../../proto/cosmos/bank/bank.js'

describe('test bank registry types against expected', () => {
it('exactly equals expected types', () => {
expect(bankRegistryTypes).toStrictEqual([MsgSend, MsgMultiSend, Metadata])
})
})
4 changes: 4 additions & 0 deletions packages/proto/src/messages/bank/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { MsgSend, MsgMultiSend } from '../../proto/cosmos/bank/tx.js'
import { Metadata } from '../../proto/cosmos/bank/bank.js'

export const bankRegistryTypes = [MsgSend, MsgMultiSend, Metadata]
9 changes: 9 additions & 0 deletions packages/proto/src/messages/baseRegistry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Timestamp } from '@bufbuild/protobuf'
import { baseRegistryTypes } from './baseRegistry'
import { Coin } from '../proto/cosmos/base/coin'

describe('test base registry types against expected', () => {
it('exactly equals expected types', () => {
expect(baseRegistryTypes).toStrictEqual([Timestamp, Coin])
})
})
4 changes: 4 additions & 0 deletions packages/proto/src/messages/baseRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Timestamp } from '@bufbuild/protobuf'
import { Coin } from '../proto/cosmos/base/coin.js'

export const baseRegistryTypes = [Timestamp, Coin]
2 changes: 1 addition & 1 deletion packages/proto/src/messages/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createED25519PubKey } from './keys'
import { PubKey } from '../../proto/cosmos/crypto/ed25519/keys'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test Crypto Module message generation', () => {
it('correctly wraps ED25519PubKey', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/crypto/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './keys.js'
export * from './registry.js'
13 changes: 13 additions & 0 deletions packages/proto/src/messages/crypto/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { cryptoRegistryTypes } from './registry'

import { PubKey as ED25519PubKey } from '../../proto/cosmos/crypto/ed25519/keys'
import { PubKey as EthSecp256k1PubKey } from '../../proto/ethermint/crypto/keys.js'

describe('test crypto registry types against expected', () => {
it('exactly equals expected types', () => {
expect(cryptoRegistryTypes).toStrictEqual([
ED25519PubKey,
EthSecp256k1PubKey,
])
})
})
4 changes: 4 additions & 0 deletions packages/proto/src/messages/crypto/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PubKey as ED25519PubKey } from '../../proto/cosmos/crypto/ed25519/keys.js'
import { PubKey as EthSecp256k1PubKey } from '../../proto/ethermint/crypto/keys.js'

export const cryptoRegistryTypes = [ED25519PubKey, EthSecp256k1PubKey]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../../proto/cosmos/distribution/tx'

import { from, to, val } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test Distribution Module message generation', () => {
it('correctly wraps msgWithdrawDelegatorReward', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/distribution/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './distribution.js'
export * from './registry.js'
19 changes: 19 additions & 0 deletions packages/proto/src/messages/distribution/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { distributionRegistryTypes } from './registry'

import {
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
MsgSetWithdrawAddress,
MsgFundCommunityPool,
} from '../../proto/cosmos/distribution/tx'

describe('test distribution registry types against expected', () => {
it('exactly equals expected types', () => {
expect(distributionRegistryTypes).toStrictEqual([
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
MsgSetWithdrawAddress,
MsgFundCommunityPool,
])
})
})
13 changes: 13 additions & 0 deletions packages/proto/src/messages/distribution/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
MsgSetWithdrawAddress,
MsgFundCommunityPool,
} from '../../proto/cosmos/distribution/tx.js'

export const distributionRegistryTypes = [
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
MsgSetWithdrawAddress,
MsgFundCommunityPool,
]
2 changes: 1 addition & 1 deletion packages/proto/src/messages/erc20/erc20.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../../proto/evmos/erc20/erc20'

import { from, to, denom, hex, ibcDenom } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test ERC20 Module message generation', () => {
it('correctly wraps msgConvertCoin', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/erc20/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './msgConvertERC20.js'
export * from './msgRegisterERC20.js'
export * from './msgRegisterCoin.js'
export * from './aminoRegistry.js'
export * from './registry.js'
2 changes: 1 addition & 1 deletion packages/proto/src/messages/erc20/msgRegisterCoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Metadata } from '../../proto/cosmos/bank/bank'
import { Metadata } from '../../proto/cosmos/bank/bank.js'
import { RegisterCoinProposal } from '../../proto/evmos/erc20/erc20.js'

export function createMsgRegisterCoin(
Expand Down
18 changes: 18 additions & 0 deletions packages/proto/src/messages/erc20/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { erc20RegistryTypes } from './registry'

import { MsgConvertCoin, MsgConvertERC20 } from '../../proto/evmos/erc20/tx'
import {
RegisterCoinProposal,
RegisterERC20Proposal,
} from '../../proto/evmos/erc20/erc20'

describe('test erc20 registry types against expected', () => {
it('exactly equals expected types', () => {
expect(erc20RegistryTypes).toStrictEqual([
MsgConvertCoin,
MsgConvertERC20,
RegisterCoinProposal,
RegisterERC20Proposal,
])
})
})
12 changes: 12 additions & 0 deletions packages/proto/src/messages/erc20/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MsgConvertCoin, MsgConvertERC20 } from '../../proto/evmos/erc20/tx.js'
import {
RegisterCoinProposal,
RegisterERC20Proposal,
} from '../../proto/evmos/erc20/erc20.js'

export const erc20RegistryTypes = [
MsgConvertCoin,
MsgConvertERC20,
RegisterCoinProposal,
RegisterERC20Proposal,
]
2 changes: 1 addition & 1 deletion packages/proto/src/messages/evm/dynamicFee.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createDynamicFeeExtension } from './dynamicFee'

import { ExtensionOptionDynamicFeeTx } from '../../proto/ethermint/types/dynamicFee'

import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test DynamicFeeExtension message generation', () => {
it('correctly wraps dynamic fee extension', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/evm/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './msgEthereumTx.js'
export * from './web3Extension.js'
export * from './dynamicFee.js'
export * from './registry.js'
2 changes: 1 addition & 1 deletion packages/proto/src/messages/evm/msgEthereumTx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

import { MsgEthereumTx, LegacyTx } from '../../proto/ethermint/evm/tx'

import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test MsgEthereumTx payload conversions', () => {
const blockchainTx =
Expand Down
23 changes: 23 additions & 0 deletions packages/proto/src/messages/evm/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { evmRegistryTypes } from './registry'

import { ExtensionOptionDynamicFeeTx } from '../../proto/ethermint/types/dynamicFee'
import {
MsgEthereumTx,
LegacyTx,
AccessListTx,
DynamicFeeTx,
} from '../../proto/ethermint/evm/tx'
import { ExtensionOptionsWeb3Tx } from '../../proto/ethermint/types/web3'

describe('test evm registry types against expected', () => {
it('exactly equals expected types', () => {
expect(evmRegistryTypes).toStrictEqual([
ExtensionOptionDynamicFeeTx,
MsgEthereumTx,
LegacyTx,
AccessListTx,
DynamicFeeTx,
ExtensionOptionsWeb3Tx,
])
})
})
17 changes: 17 additions & 0 deletions packages/proto/src/messages/evm/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ExtensionOptionDynamicFeeTx } from '../../proto/ethermint/types/dynamicFee.js'
import {
MsgEthereumTx,
LegacyTx,
AccessListTx,
DynamicFeeTx,
} from '../../proto/ethermint/evm/tx.js'
import { ExtensionOptionsWeb3Tx } from '../../proto/ethermint/types/web3.js'

export const evmRegistryTypes = [
ExtensionOptionDynamicFeeTx,
MsgEthereumTx,
LegacyTx,
AccessListTx,
DynamicFeeTx,
ExtensionOptionsWeb3Tx,
]
2 changes: 1 addition & 1 deletion packages/proto/src/messages/evm/web3Extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createWeb3Extension } from './web3Extension'
import { ExtensionOptionsWeb3Tx } from '../../proto/ethermint/types/web3'

import { from } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test Web3Extension message generation', () => {
it('correctly wraps web3Extension', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/proto/src/messages/gov/gov.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
MsgDeposit,
} from '../../proto/cosmos/gov/tx'
import { from, denom } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

describe('test Gov Module message generation', () => {
it('correctly wraps MsgVote', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/gov/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './msgDeposit.js'
export * from './msgSubmitProposal.js'
export * from './msgVote.js'
export * from './registry.js'
19 changes: 19 additions & 0 deletions packages/proto/src/messages/gov/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { govRegistryTypes } from './registry'

import {
MsgDeposit,
MsgSubmitProposal,
MsgVote,
MsgVoteWeighted,
} from '../../proto/cosmos/gov/tx'

describe('test gov registry types against expected', () => {
it('exactly equals expected types', () => {
expect(govRegistryTypes).toStrictEqual([
MsgDeposit,
MsgSubmitProposal,
MsgVote,
MsgVoteWeighted,
])
})
})
13 changes: 13 additions & 0 deletions packages/proto/src/messages/gov/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
MsgDeposit,
MsgSubmitProposal,
MsgVote,
MsgVoteWeighted,
} from '../../proto/cosmos/gov/tx.js'

export const govRegistryTypes = [
MsgDeposit,
MsgSubmitProposal,
MsgVote,
MsgVoteWeighted,
]
2 changes: 1 addition & 1 deletion packages/proto/src/messages/ibc/ibc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createIBCMsgTransfer } from './ibcMsgTransfer'
import { MsgTransfer } from '../../proto/cosmos-ibc/ibc/applications/tx'

import { from, to, denom } from '../../proto/tests/utils'
import { JSONOptions } from '../../proto/tests/common'
import { JSONOptions } from '../../registry/registry'

interface MsgTransferParams {
sourcePort: string
Expand Down
1 change: 1 addition & 0 deletions packages/proto/src/messages/ibc/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './ibcMsgTransfer.js'
export * from './registry.js'
10 changes: 10 additions & 0 deletions packages/proto/src/messages/ibc/registry.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ibcRegistryTypes } from './registry'

import { MsgTransfer } from '../../proto/cosmos-ibc/ibc/applications/tx'
import { Height } from '../../proto/cosmos-ibc/ibc/core/client'

describe('test ibc registry types against expected', () => {
it('exactly equals expected types', () => {
expect(ibcRegistryTypes).toStrictEqual([MsgTransfer, Height])
})
})
4 changes: 4 additions & 0 deletions packages/proto/src/messages/ibc/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { MsgTransfer } from '../../proto/cosmos-ibc/ibc/applications/tx.js'
import { Height } from '../../proto/cosmos-ibc/ibc/core/client.js'

export const ibcRegistryTypes = [MsgTransfer, Height]
2 changes: 2 additions & 0 deletions packages/proto/src/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export * from './revenue/index.js'
// TODO: Find out why export * from './staking' doesn't work
export * from './staking/staking.js'
export * from './staking/validator.js'
export * from './staking/registry.js'
export * from './transactions/index.js'
export * from './vesting/index.js'
export * from './common.js'
export * from './baseRegistry.js'
Loading

0 comments on commit 8216395

Please sign in to comment.