├── .husky ├── .gitignore └── pre-commit ├── src ├── core │ ├── Denom.ts │ ├── crisis │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── intertx │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── forwarding │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── ibc │ │ ├── applications │ │ │ ├── perm │ │ │ │ ├── index.ts │ │ │ │ └── msgs │ │ │ │ │ └── index.ts │ │ │ ├── transfer │ │ │ │ ├── authorizations │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ ├── msgs │ │ │ │ │ └── index.ts │ │ │ │ ├── DenomTrace.ts │ │ │ │ └── IbcTransferParams.ts │ │ │ ├── index.ts │ │ │ ├── nft-transfer │ │ │ │ ├── index.ts │ │ │ │ ├── msgs │ │ │ │ │ └── index.ts │ │ │ │ └── NftClassTrace.ts │ │ │ ├── fee │ │ │ │ ├── index.ts │ │ │ │ ├── msgs │ │ │ │ │ └── index.ts │ │ │ │ └── Metadata.ts │ │ │ └── interchain-account │ │ │ │ ├── index.ts │ │ │ │ ├── controller │ │ │ │ └── Params.ts │ │ │ │ └── host │ │ │ │ └── Params.ts │ │ ├── lightclient │ │ │ └── index.ts │ │ ├── index.ts │ │ └── core │ │ │ ├── commitment │ │ │ ├── index.ts │ │ │ ├── MerkleRoot.ts │ │ │ └── MerklePrefix.ts │ │ │ ├── index.ts │ │ │ ├── connection │ │ │ ├── index.ts │ │ │ ├── msgs │ │ │ │ └── index.ts │ │ │ ├── IbcVersion.ts │ │ │ └── IbcConnectionParams.ts │ │ │ ├── client │ │ │ ├── index.ts │ │ │ ├── msgs │ │ │ │ └── index.ts │ │ │ ├── IbcClientParams.ts │ │ │ └── IdentifiedClient.ts │ │ │ └── channel │ │ │ ├── index.ts │ │ │ ├── IbcChannelParams.ts │ │ │ ├── ChannelCounterparty.ts │ │ │ ├── msgs │ │ │ └── index.ts │ │ │ └── PacketId.ts │ ├── params │ │ ├── proposals │ │ │ └── index.ts │ │ └── index.ts │ ├── upgrade │ │ ├── index.ts │ │ ├── Plan.spec.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── Plan.ts │ ├── auction │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── authz │ │ ├── index.ts │ │ ├── authorizations │ │ │ └── index.ts │ │ └── msgs │ │ │ ├── MsgRevokeAuthorization.data.json │ │ │ ├── MsgExecAuthorized.spec.ts │ │ │ ├── MsgGrantAuthorization.spec.ts │ │ │ ├── MsgRevokeAuthorization.spec.ts │ │ │ ├── MsgExecAuthorized.data.json │ │ │ ├── index.ts │ │ │ └── MsgGrantAuthorization.data.json │ ├── feegrant │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── allowances │ │ │ ├── index.ts │ │ │ └── BasicAllowance.spec.ts │ ├── reward │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── tokenfactory │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── celestia │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── BlobTx.ts │ ├── move │ │ └── index.ts │ ├── evm │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── AccessTuple.ts │ ├── ibchooks │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ ├── ACL.ts │ │ └── IbcHooksParams.ts │ ├── evidence │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── Evidence.ts │ ├── oracle │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── CurrencyPair.ts │ ├── gov │ │ ├── proposals │ │ │ ├── index.ts │ │ │ └── Content.ts │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── distribution │ │ ├── index.ts │ │ ├── msgs │ │ │ ├── MsgSetWithdrawAddress.spec.ts │ │ │ ├── MsgWithdrawDelegatorReward.spec.ts │ │ │ ├── MsgWithdrawValidatorCommission.spec.ts │ │ │ └── index.ts │ │ └── RewardWeight.ts │ ├── slashing │ │ ├── index.ts │ │ └── msgs │ │ │ ├── index.ts │ │ │ └── MsgUnjail.spec.ts │ ├── opchild │ │ ├── index.ts │ │ └── msgs │ │ │ └── index.ts │ ├── auth │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ ├── Account.ts │ │ └── BaseAccount.data.json │ ├── bank │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ ├── SendEnabled.ts │ │ └── DenomUnit.ts │ ├── marketmap │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ └── MarketmapParams.ts │ ├── consensus │ │ ├── index.ts │ │ ├── msgs │ │ │ └── index.ts │ │ ├── ValidatorParams.ts │ │ ├── ABCIParams.ts │ │ └── BlockParams.ts │ ├── wasm │ │ ├── index.ts │ │ ├── authorizations │ │ │ ├── index.ts │ │ │ ├── ContractLimit.ts │ │ │ ├── AllowAllMessagesFilter.ts │ │ │ └── MaxCallsLimit.ts │ │ └── AccessConfig.ts │ ├── tx │ │ ├── SignMode.ts │ │ ├── index.ts │ │ └── SignatureV2.spec.ts │ ├── ophost │ │ ├── index.ts │ │ ├── BatchInfo.ts │ │ └── OphostParams.ts │ ├── mstaking │ │ ├── index.ts │ │ ├── Delegation.spec.ts │ │ ├── msgs │ │ │ ├── MsgDelegate.spec.ts │ │ │ ├── MsgUndelegate.spec.ts │ │ │ ├── MsgEditValidator.spec.ts │ │ │ ├── MsgBeginRedelegate.spec.ts │ │ │ ├── MsgCreateValidator.spec.ts │ │ │ └── index.ts │ │ └── Delegation.data.json │ ├── group │ │ ├── index.ts │ │ └── policies │ │ │ └── index.ts │ ├── num.ts │ ├── index.ts │ ├── Block.ts │ └── PublicKey.spec.ts ├── util │ ├── index.ts │ ├── hash.ts │ ├── bcs.spec.ts │ ├── json.spec.ts │ ├── hash.spec.ts │ └── json.ts ├── index.ts ├── key │ ├── index.ts │ ├── ledger │ │ ├── index.ts │ │ ├── types.ts │ │ └── constants.ts │ └── RawKey.ts └── client │ ├── rest │ └── api │ │ ├── BaseAPI.ts │ │ ├── AuctionAPI.spec.ts │ │ ├── ForwardingAPI.spec.ts │ │ ├── GroupAPI.spec.ts │ │ ├── EvidenceAPI.spec.ts │ │ ├── AuctionAPI.ts │ │ ├── IbcHooksAPI.spec.ts │ │ ├── IbcNftAPI.spec.ts │ │ ├── OphostAPI.spec.ts │ │ ├── SlashingAPI.spec.ts │ │ ├── MarketmapAPI.spec.ts │ │ ├── OracleAPI.spec.ts │ │ ├── RewardAPI.spec.ts │ │ ├── IbcTransferAPI.spec.ts │ │ ├── InterTxAPI.ts │ │ ├── MoveAPI.spec.ts │ │ ├── UpgradeAPI.spec.ts │ │ ├── DistributionAPI.spec.ts │ │ ├── index.ts │ │ ├── BankAPI.spec.ts │ │ ├── GovAPI.spec.ts │ │ ├── EvidenceAPI.ts │ │ ├── AuthAPI.spec.ts │ │ ├── OracleAPI.ts │ │ ├── RewardAPI.ts │ │ ├── IbcPermAPI.ts │ │ ├── IbcHooksAPI.ts │ │ ├── AuthAPI.ts │ │ ├── TendermintAPI.spec.ts │ │ ├── SlashingAPI.ts │ │ ├── UpgradeAPI.ts │ │ ├── MstakingAPI.spec.ts │ │ └── ForwardingAPI.ts │ └── index.ts ├── vitest.config.mjs ├── prettier.config.mjs ├── .github ├── ISSUE_TEMPLATE │ ├── gui_issue.md │ ├── good_first_issue.md │ ├── feature_request.md │ ├── ISSUE_TEMPLATE.md │ ├── bug_report.md │ └── Release_notes.md ├── workflows │ ├── npm-publish.yml │ └── dependency-review.yml └── PULL_REQUEST_TEMPLATE.md ├── vite.config.ts ├── tsconfig.json ├── eslint.config.mjs └── .gitignore /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged 2 | -------------------------------------------------------------------------------- /src/core/Denom.ts: -------------------------------------------------------------------------------- 1 | export type Denom = string 2 | -------------------------------------------------------------------------------- /src/core/crisis/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | -------------------------------------------------------------------------------- /src/core/intertx/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | -------------------------------------------------------------------------------- /src/core/forwarding/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | -------------------------------------------------------------------------------- /src/core/ibc/applications/perm/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | -------------------------------------------------------------------------------- /src/core/ibc/lightclient/index.ts: -------------------------------------------------------------------------------- 1 | export * from './tendermint/Header' 2 | -------------------------------------------------------------------------------- /src/core/ibc/index.ts: -------------------------------------------------------------------------------- 1 | export * from './applications' 2 | export * from './core' 3 | -------------------------------------------------------------------------------- /src/core/params/proposals/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ParameterChangeProposal' 2 | -------------------------------------------------------------------------------- /src/core/upgrade/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Plan' 3 | -------------------------------------------------------------------------------- /src/core/auction/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './AuctionParams' 3 | -------------------------------------------------------------------------------- /src/core/authz/index.ts: -------------------------------------------------------------------------------- 1 | export * from './authorizations' 2 | export * from './msgs' 3 | -------------------------------------------------------------------------------- /src/core/feegrant/index.ts: -------------------------------------------------------------------------------- 1 | export * from './allowances' 2 | export * from './msgs' 3 | -------------------------------------------------------------------------------- /src/core/reward/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './RewardParams' 3 | -------------------------------------------------------------------------------- /src/core/params/index.ts: -------------------------------------------------------------------------------- 1 | export * from './proposals' 2 | export * from './ParamChange' 3 | -------------------------------------------------------------------------------- /src/core/tokenfactory/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './TokenfactoryParams' 3 | -------------------------------------------------------------------------------- /src/util/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bcs' 2 | export * from './hash' 3 | export * from './json' 4 | -------------------------------------------------------------------------------- /src/core/ibc/core/commitment/index.ts: -------------------------------------------------------------------------------- 1 | export * from './MerklePrefix' 2 | export * from './MerkleRoot' 3 | -------------------------------------------------------------------------------- /src/core/celestia/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Blob' 3 | export * from './BlobTx' 4 | -------------------------------------------------------------------------------- /src/core/move/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Module' 3 | export * from './MoveParams' 4 | -------------------------------------------------------------------------------- /src/core/evm/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './EvmParams' 3 | export * from './AccessTuple' 4 | -------------------------------------------------------------------------------- /src/core/ibchooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './ACL' 3 | export * from './IbcHooksParams' 4 | -------------------------------------------------------------------------------- /src/core/evidence/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Equivocation' 3 | export * from './Evidence' 4 | -------------------------------------------------------------------------------- /src/core/oracle/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './CurrencyPair' 3 | export * from './QuotePrice' 4 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './client' 2 | export * from './core' 3 | export * from './key' 4 | export * from './util' 5 | -------------------------------------------------------------------------------- /src/core/gov/proposals/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Content' 2 | export * from './Proposal' 3 | export * from './TextProposal' 4 | -------------------------------------------------------------------------------- /src/core/distribution/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './DistributionParams' 3 | export * from './RewardWeight' 4 | -------------------------------------------------------------------------------- /src/core/slashing/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './ValidatorSigningInfo' 3 | export * from './SlashingParams' 4 | -------------------------------------------------------------------------------- /src/core/ibc/applications/transfer/authorizations/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Allocation' 2 | export * from './TransferAuthorization' 3 | -------------------------------------------------------------------------------- /src/key/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ledger' 2 | export * from './Key' 3 | export * from './MnemonicKey' 4 | export * from './RawKey' 5 | -------------------------------------------------------------------------------- /src/core/ibc/applications/index.ts: -------------------------------------------------------------------------------- 1 | export * from './fee' 2 | export * from './nft-transfer' 3 | export * from './perm' 4 | export * from './transfer' 5 | -------------------------------------------------------------------------------- /src/core/ibc/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './channel' 2 | export * from './client' 3 | export * from './commitment' 4 | export * from './connection' 5 | -------------------------------------------------------------------------------- /src/core/opchild/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './BridgeInfo' 3 | export * from './OpchildParams' 4 | export * from './OpValidator' 5 | -------------------------------------------------------------------------------- /src/client/rest/api/BaseAPI.ts: -------------------------------------------------------------------------------- 1 | import { APIRequester } from '../APIRequester' 2 | 3 | export abstract class BaseAPI { 4 | constructor(protected c: APIRequester) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/core/auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Account' 3 | export * from './BaseAccount' 4 | export * from './ModuleAccount' 5 | export * from './AuthParams' 6 | -------------------------------------------------------------------------------- /src/key/ledger/index.ts: -------------------------------------------------------------------------------- 1 | import InitiaApp from './app' 2 | export * from './types' 3 | export * from './constants' 4 | export * from './LedgerKey' 5 | 6 | export default InitiaApp 7 | -------------------------------------------------------------------------------- /src/core/bank/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './BankParams' 3 | export * from './SendEnabled' 4 | export * from './DenomMetadata' 5 | export * from './DenomUnit' 6 | -------------------------------------------------------------------------------- /src/core/marketmap/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Market' 3 | export * from './ProviderConfig' 4 | export * from './Ticker' 5 | export * from './MarketmapParams' 6 | -------------------------------------------------------------------------------- /src/core/consensus/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './BlockParams' 3 | export * from './EvidenceParams' 4 | export * from './ValidatorParams' 5 | export * from './ABCIParams' 6 | -------------------------------------------------------------------------------- /src/core/ibc/applications/nft-transfer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './NonFungibleTokenPacketData' 3 | export * from './NftClassTrace' 4 | export * from './IbcNftParams' 5 | -------------------------------------------------------------------------------- /src/core/wasm/index.ts: -------------------------------------------------------------------------------- 1 | export * from './authorizations' 2 | export * from './msgs' 3 | export * from './AbsoluteTxPosition' 4 | export * from './AccessConfig' 5 | export * from './WasmParams' 6 | -------------------------------------------------------------------------------- /src/core/gov/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './proposals' 3 | export * from './Deposit' 4 | export * from './Vote' 5 | export * from './TallyResult' 6 | export * from './GovParams' 7 | -------------------------------------------------------------------------------- /src/core/ibc/applications/fee/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Metadata' 3 | export * from './IdentifiedPacketFee' 4 | export * from './PacketFee' 5 | export * from './IbcFee' 6 | -------------------------------------------------------------------------------- /src/core/ibc/core/connection/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ConnectionCounterparty' 2 | export * from './IbcVersion' 3 | export * from './IdentifiedConnection' 4 | export * from './IbcConnectionParams' 5 | -------------------------------------------------------------------------------- /src/core/tx/SignMode.ts: -------------------------------------------------------------------------------- 1 | import { SignMode as SignMode_pb } from '@initia/initia.proto/cosmos/tx/signing/v1beta1/signing' 2 | 3 | export const SignMode = SignMode_pb 4 | export type SignMode = SignMode_pb 5 | -------------------------------------------------------------------------------- /src/core/ibc/applications/transfer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './authorizations' 2 | export * from './msgs' 3 | export * from './DenomTrace' 4 | export * from './FungibleTokenPacketData' 5 | export * from './IbcTransferParams' 6 | -------------------------------------------------------------------------------- /src/core/ophost/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './BatchInfo' 3 | export * from './BridgeConfig' 4 | export * from './OphostParams' 5 | export * from './Output' 6 | export * from './BatchInfoWithOutput' 7 | -------------------------------------------------------------------------------- /src/core/mstaking/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Delegation' 3 | export * from './MstakingParams' 4 | export * from './Redelegation' 5 | export * from './UnbondingDelegation' 6 | export * from './Validator' 7 | -------------------------------------------------------------------------------- /src/core/tx/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Fee' 2 | export * from './MultiSignature' 3 | export * from './SignatureV2' 4 | export * from './SignDoc' 5 | export * from './SignMode' 6 | export * from './Tx' 7 | export * from './TxInfo' 8 | -------------------------------------------------------------------------------- /src/client/index.ts: -------------------------------------------------------------------------------- 1 | // REST Client 2 | export * from './rest/APIRequester' 3 | export * from './rest/RESTClient' 4 | export * from './rest/Wallet' 5 | export * from './rest/api' 6 | 7 | // WebSocketClient 8 | export * from './WebSocketClient' 9 | -------------------------------------------------------------------------------- /src/core/ibc/applications/interchain-account/index.ts: -------------------------------------------------------------------------------- 1 | export { Params as ControllerParams } from './controller/Params' 2 | export { Params as HostParams } from './host/Params' 3 | 4 | export * from './Account' 5 | export * from './Metadata' 6 | -------------------------------------------------------------------------------- /src/core/group/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './policies' 3 | export * from './GroupInfo' 4 | export * from './GroupMember' 5 | export * from './GroupPolicyInfo' 6 | export * from './GroupProposal' 7 | export * from './GroupVote' 8 | -------------------------------------------------------------------------------- /src/core/ibc/core/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './ClientConsensusStates' 3 | export * from './ConsensusStateWithHeight' 4 | export * from './Height' 5 | export * from './IdentifiedClient' 6 | export * from './IbcClientParams' 7 | -------------------------------------------------------------------------------- /vitest.config.mjs: -------------------------------------------------------------------------------- 1 | // vitest.config.mjs 2 | import { defineConfig } from 'vitest/config' 3 | 4 | export default defineConfig({ 5 | test: { 6 | // Test options here, e.g.: 7 | globals: true, 8 | environment: 'node', 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /src/core/authz/authorizations/index.ts: -------------------------------------------------------------------------------- 1 | export * from './StakeAuthorization' 2 | export * from './SendAuthorization' 3 | export * from './GenericAuthorization' 4 | export * from './Authorization' 5 | export * from './PublishAuthorization' 6 | export * from './ExecuteAuthorization' 7 | -------------------------------------------------------------------------------- /prettier.config.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @see https://prettier.io/docs/en/configuration.html 3 | * @type {import("prettier").Config} 4 | */ 5 | const config = { 6 | trailingComma: 'es5', 7 | tabWidth: 2, 8 | semi: false, 9 | singleQuote: true, 10 | } 11 | 12 | export default config 13 | -------------------------------------------------------------------------------- /src/core/ibc/core/channel/index.ts: -------------------------------------------------------------------------------- 1 | export * from './msgs' 2 | export * from './Channel' 3 | export * from './ChannelCounterparty' 4 | export * from './IbcChannelParams' 5 | export * from './IdentifiedChannel' 6 | export * from './Packet' 7 | export * from './PacketId' 8 | export * from './Timeout' 9 | -------------------------------------------------------------------------------- /src/core/celestia/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgPayForBlobs } from './MsgPayForBlobs' 2 | 3 | export * from './MsgPayForBlobs' 4 | 5 | export type CelestiaMsg = MsgPayForBlobs 6 | 7 | export namespace CelestiaMsg { 8 | export type Data = MsgPayForBlobs.Data 9 | export type Proto = MsgPayForBlobs.Proto 10 | } 11 | -------------------------------------------------------------------------------- /src/core/authz/msgs/MsgRevokeAuthorization.data.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "type": "cosmos-sdk/MsgRevoke", 3 | "value": { 4 | "grantee": "init1ruz7ugyh8sazpswsvt2fj54xcp68zu7wwsrsf4", 5 | "granter": "init1na2r5d5ele6hh2fz44avgzw5cxvem2j0aaz0nk", 6 | "msg_type_url": "/cosmos.bank.v1beta1.MsgSend" 7 | } 8 | }] 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/gui_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: An issue or feature request related to the GUI 3 | about: Any report, issue or feature request related to the GUI should be reported to initia support team 4 | title: Any report, issue or feature request related to the GUI should be reported to initia support team 5 | labels: GUI 6 | assignees: '' 7 | 8 | --- -------------------------------------------------------------------------------- /src/core/auth/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgUpdateAuthParams } from './MsgUpdateAuthParams' 2 | 3 | export * from './MsgUpdateAuthParams' 4 | 5 | export type AuthMsg = MsgUpdateAuthParams 6 | export namespace AuthMsg { 7 | export type Amino = MsgUpdateAuthParams.Amino 8 | export type Data = MsgUpdateAuthParams.Data 9 | export type Proto = MsgUpdateAuthParams.Proto 10 | } 11 | -------------------------------------------------------------------------------- /src/core/evidence/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgSubmitEvidence } from './MsgSubmitEvidence' 2 | 3 | export * from './MsgSubmitEvidence' 4 | 5 | export type EvidenceMsg = MsgSubmitEvidence 6 | 7 | export namespace EvidenceMsg { 8 | export type Amino = MsgSubmitEvidence.Amino 9 | export type Data = MsgSubmitEvidence.Data 10 | export type Proto = MsgSubmitEvidence.Proto 11 | } 12 | -------------------------------------------------------------------------------- /src/core/num.ts: -------------------------------------------------------------------------------- 1 | import { BigNumber } from 'bignumber.js' 2 | 3 | export function num(number: number | string): BigNumber { 4 | return new BigNumber(number) 5 | } 6 | 7 | export function checkDecimal(amount: number | string): boolean { 8 | return typeof amount === 'string' 9 | ? amount.includes('.') 10 | : !num(amount).isInteger() 11 | } 12 | 13 | export * from 'bignumber.js' 14 | -------------------------------------------------------------------------------- /src/core/reward/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgUpdateRewardParams } from './MsgUpdateRewardParams' 2 | 3 | export * from './MsgUpdateRewardParams' 4 | 5 | export type RewardMsg = MsgUpdateRewardParams 6 | export namespace RewardMsg { 7 | export type Amino = MsgUpdateRewardParams.Amino 8 | export type Data = MsgUpdateRewardParams.Data 9 | export type Proto = MsgUpdateRewardParams.Proto 10 | } 11 | -------------------------------------------------------------------------------- /src/core/consensus/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgUpdateConsensusParams } from './MsgUpdateConsensusParams' 2 | 3 | export * from './MsgUpdateConsensusParams' 4 | 5 | export type ConsensusMsg = MsgUpdateConsensusParams 6 | export namespace ConsensusMsg { 7 | export type Amino = MsgUpdateConsensusParams.Amino 8 | export type Data = MsgUpdateConsensusParams.Data 9 | export type Proto = MsgUpdateConsensusParams.Proto 10 | } 11 | -------------------------------------------------------------------------------- /src/core/authz/msgs/MsgExecAuthorized.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgExecAuthorized } from './MsgExecAuthorized' 3 | const examples = require('./MsgExecAuthorized.data.json') 4 | 5 | describe('MsgExecAuthorized', () => { 6 | it('deserializes', () => { 7 | examples.forEach((data: MsgExecAuthorized.Amino) => { 8 | expect(MsgExecAuthorized.fromAmino(data).toAmino()).toEqual(data) 9 | }) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /src/core/mstaking/Delegation.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | const delgsAmino = require('./Delegation.data.json') 3 | import { Delegation } from './Delegation' 4 | 5 | describe('Delegation', () => { 6 | it('deserializes', () => { 7 | delgsAmino.forEach((delgExample: Delegation.Amino) => { 8 | const delg = Delegation.fromAmino(delgExample) 9 | expect(delg.toAmino()).toMatchObject(delgExample) 10 | }) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /src/core/upgrade/Plan.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { Plan } from './Plan' 3 | 4 | describe('Plan', () => { 5 | it('deserializes', () => { 6 | const plan = Plan.fromAmino({ 7 | name: `v0.5.2`, 8 | height: '5330001', 9 | info: 'testinfo', 10 | }) 11 | 12 | expect(plan).toMatchObject({ 13 | name: `v0.5.2`, 14 | height: 5330001, 15 | info: 'testinfo', 16 | }) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /src/core/authz/msgs/MsgGrantAuthorization.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgGrantAuthorization } from './MsgGrantAuthorization' 3 | const examples = require('./MsgGrantAuthorization.data.json') 4 | 5 | describe('MsgGrantAuthorization', () => { 6 | it('deserializes', () => { 7 | examples.forEach((data: MsgGrantAuthorization.Amino) => { 8 | expect(MsgGrantAuthorization.fromAmino(data).toAmino()).toEqual(data) 9 | }) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /src/core/authz/msgs/MsgRevokeAuthorization.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgRevokeAuthorization } from './MsgRevokeAuthorization' 3 | const examples = require('./MsgRevokeAuthorization.data.json') 4 | 5 | describe('MsgRevokeAuthorization', () => { 6 | it('deserializes', () => { 7 | examples.forEach((data: MsgRevokeAuthorization.Amino) => { 8 | expect(MsgRevokeAuthorization.fromAmino(data).toAmino()).toEqual(data) 9 | }) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /src/core/wasm/authorizations/index.ts: -------------------------------------------------------------------------------- 1 | export * from './StoreCodeAuthorization' 2 | export * from './ContractExecutionAuthorization' 3 | export * from './ContractMigrationAuthorization' 4 | export * from './CodeGrant' 5 | export * from './ContractGrant' 6 | export * from './MaxCallsLimit' 7 | export * from './MaxFundsLimit' 8 | export * from './CombinedLimit' 9 | export * from './AllowAllMessagesFilter' 10 | export * from './AcceptedMessageKeysFilter' 11 | export * from './AcceptedMessagesFilter' 12 | -------------------------------------------------------------------------------- /src/core/authz/msgs/MsgExecAuthorized.data.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "type": "cosmos-sdk/MsgExec", 3 | "value": { 4 | "grantee": "ini...", 5 | "msgs": [{ 6 | "type": "cosmos-sdk/MsgSend", 7 | "value": { 8 | "from_address": "ini...", 9 | "to_address": "ini...", 10 | "amount": [{ 11 | "denom": "uinit", 12 | "amount": "999" 13 | }] 14 | } 15 | }] 16 | } 17 | }] 18 | -------------------------------------------------------------------------------- /src/client/rest/api/AuctionAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { AuctionAPI } from './AuctionAPI' 4 | import { AuctionParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new AuctionAPI(c) 8 | 9 | describe('AuctionAPI', () => { 10 | it('params', async () => { 11 | const params = await api.parameters() 12 | expect(params).toEqual(expect.any(AuctionParams)) 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /src/core/intertx/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgRegisterAccount } from './MsgRegisterAccount' 2 | import { MsgSubmitTx } from './MsgSubmitTx' 3 | 4 | export * from './MsgRegisterAccount' 5 | export * from './MsgSubmitTx' 6 | 7 | export type InterTxMsg = MsgRegisterAccount | MsgSubmitTx 8 | export namespace InterTxMsg { 9 | export type Amino = MsgRegisterAccount.Amino | MsgSubmitTx.Amino 10 | export type Data = MsgRegisterAccount.Data | MsgSubmitTx.Data 11 | export type Proto = MsgRegisterAccount.Proto | MsgSubmitTx.Proto 12 | } 13 | -------------------------------------------------------------------------------- /src/client/rest/api/ForwardingAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { ForwardingAPI } from './ForwardingAPI' 4 | 5 | const c = new APIRequester('https://rest.testnet.initia.xyz') 6 | const api = new ForwardingAPI(c) 7 | 8 | describe('ForwardingAPI', () => { 9 | it('denoms', async () => { 10 | const denoms = await api.denoms() 11 | for (const denom of denoms[0]) { 12 | expect(denom).toEqual(expect.any(String)) 13 | } 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /src/core/slashing/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgUnjail } from './MsgUnjail' 2 | import { MsgUpdateSlashingParams } from './MsgUpdateSlashingParams' 3 | 4 | export * from './MsgUnjail' 5 | export * from './MsgUpdateSlashingParams' 6 | 7 | export type SlashingMsg = MsgUnjail | MsgUpdateSlashingParams 8 | export namespace SlashingMsg { 9 | export type Amino = MsgUnjail.Amino | MsgUpdateSlashingParams.Amino 10 | export type Data = MsgUnjail.Data | MsgUpdateSlashingParams.Data 11 | export type Proto = MsgUnjail.Proto | MsgUpdateSlashingParams.Proto 12 | } 13 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: NPM publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | # Setup .npmrc file to publish to npm 13 | - uses: actions/setup-node@v3 14 | with: 15 | node-version: '20' 16 | registry-url: 'https://registry.npmjs.org' 17 | - run: npm install 18 | - run: npm publish 19 | env: 20 | NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} 21 | -------------------------------------------------------------------------------- /src/client/rest/api/GroupAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { GroupAPI } from './GroupAPI' 4 | import { GroupInfo } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new GroupAPI(c) 8 | 9 | describe('GroupAPI', () => { 10 | it('groups', async () => { 11 | const groups = await api.groups() 12 | for (const group of groups[0]) { 13 | expect(group).toEqual(expect.any(GroupInfo)) 14 | } 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/core/upgrade/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgSoftwareUpgrade } from './MsgSoftwareUpgrade' 2 | import { MsgCancelUpgrade } from './MsgCancelUpgrade' 3 | 4 | export * from './MsgSoftwareUpgrade' 5 | export * from './MsgCancelUpgrade' 6 | 7 | export type UpgradeMsg = MsgSoftwareUpgrade | MsgCancelUpgrade 8 | export namespace UpgradeMsg { 9 | export type Amino = MsgSoftwareUpgrade.Amino | MsgCancelUpgrade.Amino 10 | export type Data = MsgSoftwareUpgrade.Data | MsgCancelUpgrade.Data 11 | export type Proto = MsgSoftwareUpgrade.Proto | MsgCancelUpgrade.Proto 12 | } 13 | -------------------------------------------------------------------------------- /src/core/auction/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgAuctionBid } from './MsgAuctionBid' 2 | import { MsgUpdateAuctionParams } from './MsgUpdateAuctionParams' 3 | 4 | export * from './MsgAuctionBid' 5 | export * from './MsgUpdateAuctionParams' 6 | 7 | export type AuctionMsg = MsgAuctionBid | MsgUpdateAuctionParams 8 | export namespace AuctionMsg { 9 | export type Amino = MsgAuctionBid.Amino | MsgUpdateAuctionParams.Amino 10 | export type Data = MsgAuctionBid.Data | MsgUpdateAuctionParams.Data 11 | export type Proto = MsgAuctionBid.Proto | MsgUpdateAuctionParams.Proto 12 | } 13 | -------------------------------------------------------------------------------- /src/core/ibc/applications/transfer/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgTransfer } from './MsgTransfer' 2 | import { MsgUpdateIbcTransferParams } from './MsgUpdateIbcTransferParams' 3 | 4 | export * from './MsgTransfer' 5 | export * from './MsgUpdateIbcTransferParams' 6 | 7 | export type IbcTransferMsg = MsgTransfer | MsgUpdateIbcTransferParams 8 | export namespace IbcTransferMsg { 9 | export type Amino = MsgTransfer.Amino 10 | export type Data = MsgTransfer.Data | MsgUpdateIbcTransferParams.Data 11 | export type Proto = MsgTransfer.Proto | MsgUpdateIbcTransferParams.Proto 12 | } 13 | -------------------------------------------------------------------------------- /src/core/slashing/msgs/MsgUnjail.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgUnjail } from './MsgUnjail' 3 | const MsgUnjailAmino = require('./MsgUnjail.data.json') 4 | 5 | describe('MsgUnjail', () => { 6 | it('deserializes', () => { 7 | MsgUnjailAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgUnjail') { 10 | const e = MsgUnjail.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/core/feegrant/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgGrantAllowance } from './MsgGrantAllowance' 2 | import { MsgRevokeAllowance } from './MsgRevokeAllowance' 3 | 4 | export * from './MsgGrantAllowance' 5 | export * from './MsgRevokeAllowance' 6 | 7 | export type FeeGrantMsg = MsgGrantAllowance | MsgRevokeAllowance 8 | 9 | export namespace FeeGrantMsg { 10 | export type Amino = MsgGrantAllowance.Amino | MsgRevokeAllowance.Amino 11 | export type Data = MsgGrantAllowance.Data | MsgRevokeAllowance.Data 12 | export type Proto = MsgGrantAllowance.Proto | MsgRevokeAllowance.Proto 13 | } 14 | -------------------------------------------------------------------------------- /src/core/ibchooks/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgUpdateACL } from './MsgUpdateACL' 2 | import { MsgUpdateIbcHooksParams } from './MsgUpdateIbcHooksParams' 3 | 4 | export * from './MsgUpdateACL' 5 | export * from './MsgUpdateIbcHooksParams' 6 | 7 | export type IbcHooksMsg = MsgUpdateACL | MsgUpdateIbcHooksParams 8 | 9 | export namespace IbcHooksMsg { 10 | export type Amino = MsgUpdateACL.Amino | MsgUpdateIbcHooksParams.Amino 11 | export type Data = MsgUpdateACL.Data | MsgUpdateIbcHooksParams.Data 12 | export type Proto = MsgUpdateACL.Proto | MsgUpdateIbcHooksParams.Proto 13 | } 14 | -------------------------------------------------------------------------------- /src/core/ibc/applications/nft-transfer/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgNftTransfer } from './MsgNftTransfer' 2 | import { MsgUpdateIbcNftParams } from './MsgUpdateIbcNftParams' 3 | 4 | export * from './MsgNftTransfer' 5 | export * from './MsgUpdateIbcNftParams' 6 | 7 | export type IbcNftMsg = MsgNftTransfer | MsgUpdateIbcNftParams 8 | export namespace IbcNftMsg { 9 | export type Amino = MsgNftTransfer.Amino | MsgUpdateIbcNftParams.Amino 10 | export type Data = MsgNftTransfer.Data | MsgUpdateIbcNftParams.Data 11 | export type Proto = MsgNftTransfer.Proto | MsgUpdateIbcNftParams.Proto 12 | } 13 | -------------------------------------------------------------------------------- /src/core/mstaking/msgs/MsgDelegate.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgDelegate } from './MsgDelegate' 3 | const MsgDelegateAmino = require('./MsgDelegate.data.json') 4 | 5 | describe('MsgDelegate', () => { 6 | it('deserializes', () => { 7 | MsgDelegateAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgDelegate') { 10 | const e = MsgDelegate.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/good_first_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Good first issue 3 | about: '(Regular devs only): Suggest a new good first issue' 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | #### Useful skills: 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/core/crisis/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgVerifyInvariant } from './MsgVerifyInvariant' 2 | import { MsgUpdateCrisisParams } from './MsgUpdateCrisisParams' 3 | 4 | export * from './MsgVerifyInvariant' 5 | export * from './MsgUpdateCrisisParams' 6 | 7 | export type CrisisMsg = MsgVerifyInvariant | MsgUpdateCrisisParams 8 | export namespace CrisisMsg { 9 | export type Amino = MsgVerifyInvariant.Amino | MsgUpdateCrisisParams.Amino 10 | export type Data = MsgVerifyInvariant.Data | MsgUpdateCrisisParams.Data 11 | export type Proto = MsgVerifyInvariant.Proto | MsgUpdateCrisisParams.Proto 12 | } 13 | -------------------------------------------------------------------------------- /src/client/rest/api/EvidenceAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { EvidenceAPI } from './EvidenceAPI' 4 | import { Equivocation } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new EvidenceAPI(c) 8 | 9 | describe('EvidenceAPI', () => { 10 | it('evidences', async () => { 11 | const evidences = await api.evidences() 12 | for (const evidence of evidences[0]) { 13 | expect(evidence).toEqual(expect.any(Equivocation)) 14 | } 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/core/mstaking/msgs/MsgUndelegate.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgUndelegate } from './MsgUndelegate' 3 | const MsgUndelegateAmino = require('./MsgUndelegate.data.json') 4 | 5 | describe('MsgUndelegate', () => { 6 | it('deserializes', () => { 7 | MsgUndelegateAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgUndelegate') { 10 | const e = MsgUndelegate.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/core/oracle/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgAddCurrencyPairs } from './MsgAddCurrencyPairs' 2 | import { MsgRemoveCurrencyPairs } from './MsgRemoveCurrencyPairs' 3 | 4 | export * from './MsgAddCurrencyPairs' 5 | export * from './MsgRemoveCurrencyPairs' 6 | 7 | export type OracleMsg = MsgAddCurrencyPairs | MsgRemoveCurrencyPairs 8 | 9 | export namespace OracleMsg { 10 | export type Amino = MsgAddCurrencyPairs.Amino | MsgRemoveCurrencyPairs.Amino 11 | export type Data = MsgAddCurrencyPairs.Data | MsgRemoveCurrencyPairs.Data 12 | export type Proto = MsgAddCurrencyPairs.Proto | MsgRemoveCurrencyPairs.Proto 13 | } 14 | -------------------------------------------------------------------------------- /src/core/mstaking/msgs/MsgEditValidator.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgEditValidator } from './MsgEditValidator' 3 | const MsgEditValidatorAmino = require('./MsgEditValidator.data.json') 4 | 5 | describe('MsgEditValidator', () => { 6 | it('deserializes', () => { 7 | MsgEditValidatorAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgEditValidator') { 10 | const e = MsgEditValidator.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/client/rest/api/AuctionAPI.ts: -------------------------------------------------------------------------------- 1 | import { AuctionParams } from '../../../core/auction' 2 | import { APIParams } from '../APIRequester' 3 | import { BaseAPI } from './BaseAPI' 4 | 5 | export class AuctionAPI extends BaseAPI { 6 | /** 7 | * Query the parameters of the auction module. 8 | */ 9 | public async parameters( 10 | params: APIParams = {}, 11 | headers: Record = {} 12 | ): Promise { 13 | return this.c 14 | .get<{ 15 | params: AuctionParams.Data 16 | }>(`/block-sdk/auction/v1/params`, params, headers) 17 | .then((d) => AuctionParams.fromData(d.params)) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/core/mstaking/msgs/MsgBeginRedelegate.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgBeginRedelegate } from './MsgBeginRedelegate' 3 | const MsgBeginRedelegateAmino = require('./MsgBeginRedelegate.data.json') 4 | 5 | describe('MsgBeginRedelegate', () => { 6 | it('deserializes', () => { 7 | MsgBeginRedelegateAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgBeginRedelegate') { 10 | const e = MsgBeginRedelegate.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/core/mstaking/msgs/MsgCreateValidator.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgCreateValidator } from './MsgCreateValidator' 3 | const MsgCreateValidatorAmino = require('./MsgCreateValidator.data.json') 4 | 5 | describe('MsgCreateValidator', () => { 6 | it('deserializes', () => { 7 | MsgCreateValidatorAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgCreateValidator') { 10 | const e = MsgCreateValidator.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/core/distribution/msgs/MsgSetWithdrawAddress.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgSetWithdrawAddress } from './MsgSetWithdrawAddress' 3 | const MsgSetWithdrawAddressAmino = require('./MsgSetWithdrawAddress.data.json') 4 | 5 | describe('MsgSetWithdrawAddress', () => { 6 | it('deserializes', () => { 7 | MsgSetWithdrawAddressAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgModifyWithdrawAddress') { 10 | const e = MsgSetWithdrawAddress.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/client/rest/api/IbcHooksAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { IbcHooksAPI } from './IbcHooksAPI' 4 | import { ACL, IbcHooksParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new IbcHooksAPI(c) 8 | 9 | describe('IbcHooksAPI', () => { 10 | it('acls', async () => { 11 | const acls = await api.acls() 12 | for (const acl of acls[0]) { 13 | expect(acl).toEqual(expect.any(ACL)) 14 | } 15 | }) 16 | 17 | it('params', async () => { 18 | const params = await api.parameters() 19 | expect(params).toEqual(expect.any(IbcHooksParams)) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/core/distribution/msgs/MsgWithdrawDelegatorReward.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgWithdrawDelegatorReward } from './MsgWithdrawDelegatorReward' 3 | const MsgWithdrawDelegatorRewardAmino = require('./MsgWithdrawDelegatorReward.data.json') 4 | 5 | describe('MsgWithdrawDelegatorReward', () => { 6 | it('deserializes', () => { 7 | MsgWithdrawDelegatorRewardAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgWithdrawDelegationReward') { 10 | const e = MsgWithdrawDelegatorReward.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /src/client/rest/api/IbcNftAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { IbcNftAPI } from './IbcNftAPI' 4 | import { IbcNftParams, NftClassTrace } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new IbcNftAPI(c) 8 | 9 | describe('IbcNftAPI', () => { 10 | it('class traces', async () => { 11 | const traces = await api.classTraces() 12 | for (const trace of traces[0]) { 13 | expect(trace).toEqual(expect.any(NftClassTrace)) 14 | } 15 | }) 16 | 17 | it('params', async () => { 18 | const params = await api.parameters() 19 | expect(params).toEqual(expect.any(IbcNftParams)) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/core/ibc/applications/perm/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgUpdateIbcPermAdmin } from './MsgUpdateIbcPermAdmin' 2 | import { MsgUpdatePermissionedRelayers } from './MsgUpdatePermissionedRelayers' 3 | 4 | export * from './MsgUpdateIbcPermAdmin' 5 | export * from './MsgUpdatePermissionedRelayers' 6 | 7 | export type IbcPermMsg = MsgUpdateIbcPermAdmin | MsgUpdatePermissionedRelayers 8 | export namespace IbcPermMsg { 9 | export type Amino = 10 | | MsgUpdateIbcPermAdmin.Amino 11 | | MsgUpdatePermissionedRelayers.Amino 12 | export type Data = 13 | | MsgUpdateIbcPermAdmin.Data 14 | | MsgUpdatePermissionedRelayers.Data 15 | export type Proto = 16 | | MsgUpdateIbcPermAdmin.Proto 17 | | MsgUpdatePermissionedRelayers.Proto 18 | } 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: Feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | 12 | 13 | **Describe the solution you'd like** 14 | 15 | 16 | **Describe alternatives you've considered** 17 | 18 | 19 | **Additional context** 20 | 21 | -------------------------------------------------------------------------------- /src/client/rest/api/OphostAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { OphostAPI } from './OphostAPI' 4 | import { BridgeInfo, OphostParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new OphostAPI(c) 8 | 9 | describe('OphostAPI', () => { 10 | it('bridge infos', async () => { 11 | const bridgeInfos = await api.bridgeInfos() 12 | for (const info of bridgeInfos[0]) { 13 | expect(info).toEqual(expect.any(BridgeInfo)) 14 | } 15 | }) 16 | 17 | it('params', async () => { 18 | const params = await api.parameters() 19 | expect(params).toEqual(expect.any(OphostParams)) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/core/distribution/msgs/MsgWithdrawValidatorCommission.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { MsgWithdrawValidatorCommission } from './MsgWithdrawValidatorCommission' 3 | const MsgWithdrawValidatorCommissionAmino = require('./MsgWithdrawValidatorCommission.data.json') 4 | 5 | describe('MsgWithdrawValidatorCommission', () => { 6 | it('deserializes', () => { 7 | MsgWithdrawValidatorCommissionAmino.txs.forEach((txinfo: any) => { 8 | txinfo.tx.value.msg.forEach((msg: any) => { 9 | if (msg.type == 'cosmos-sdk/MsgWithdrawValidatorCommission') { 10 | const e = MsgWithdrawValidatorCommission.fromAmino(msg) 11 | expect(e.toAmino()).toEqual(msg) 12 | } 13 | }) 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path' 2 | import { defineConfig } from 'vite' 3 | import dts from 'vite-plugin-dts' 4 | 5 | export default defineConfig({ 6 | plugins: [dts()], 7 | build: { 8 | lib: { 9 | entry: resolve(__dirname, 'src/index.ts'), 10 | fileName: (format) => (format === 'es' ? 'index.mjs' : 'index.cjs'), 11 | formats: ['es', 'cjs'], 12 | }, 13 | rollupOptions: { 14 | external: [ 15 | new RegExp('^@ledgerhq/.*'), 16 | '@bitcoinerlab/secp256k1', 17 | '@mysten/bcs', 18 | 'axios', 19 | 'bech32', 20 | 'bip32', 21 | 'bip39', 22 | 'keccak256', 23 | 'ripemd160', 24 | 'semver', 25 | 'ws', 26 | ], 27 | }, 28 | }, 29 | }) 30 | -------------------------------------------------------------------------------- /src/client/rest/api/SlashingAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { SlashingAPI } from './SlashingAPI' 4 | import { SlashingParams, ValidatorSigningInfo } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new SlashingAPI(c) 8 | 9 | describe('SlashingAPI', () => { 10 | it('signing infos', async () => { 11 | const infos = await api.signingInfos() 12 | for (const info of infos[0]) { 13 | expect(info).toEqual(expect.any(ValidatorSigningInfo)) 14 | } 15 | }) 16 | 17 | it('params', async () => { 18 | const params = await api.parameters() 19 | expect(params).toEqual(expect.any(SlashingParams)) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/client/rest/api/MarketmapAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { MarketmapAPI } from './MarketmapAPI' 4 | import { Market, MarketmapParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new MarketmapAPI(c) 8 | 9 | describe('MarketmapAPI', () => { 10 | it('market map', async () => { 11 | const marketMap = await api.marketMap() 12 | for (const market of Object.values(marketMap.markets)) { 13 | expect(market).toEqual(expect.any(Market)) 14 | } 15 | }) 16 | 17 | it('params', async () => { 18 | const params = await api.parameters() 19 | expect(params).toEqual(expect.any(MarketmapParams)) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/client/rest/api/OracleAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { OracleAPI } from './OracleAPI' 4 | import { CurrencyPair, QuotePrice } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new OracleAPI(c) 8 | 9 | describe('OracleAPI', () => { 10 | it('currency pairs', async () => { 11 | const pairs = await api.currencyPairs() 12 | for (const pair of pairs) { 13 | expect(pair).toEqual(expect.any(CurrencyPair)) 14 | } 15 | }) 16 | 17 | it('price', async () => { 18 | const pairs = await api.currencyPairs() 19 | const price = await api.price(pairs[0]) 20 | expect(price).toEqual(expect.any(QuotePrice)) 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /src/core/forwarding/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgRegisterForwardingAccount } from './MsgRegisterForwardingAccount' 2 | import { MsgClearForwardingAccount } from './MsgClearForwardingAccount' 3 | 4 | export * from './MsgRegisterForwardingAccount' 5 | export * from './MsgClearForwardingAccount' 6 | 7 | export type ForwardingMsg = 8 | | MsgRegisterForwardingAccount 9 | | MsgClearForwardingAccount 10 | 11 | export namespace ForwardingMsg { 12 | export type Amino = 13 | | MsgRegisterForwardingAccount.Amino 14 | | MsgClearForwardingAccount.Amino 15 | 16 | export type Data = 17 | | MsgRegisterForwardingAccount.Data 18 | | MsgClearForwardingAccount.Data 19 | 20 | export type Proto = 21 | | MsgRegisterForwardingAccount.Proto 22 | | MsgClearForwardingAccount.Proto 23 | } 24 | -------------------------------------------------------------------------------- /src/client/rest/api/RewardAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { RewardAPI } from './RewardAPI' 4 | import { RewardParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new RewardAPI(c) 8 | 9 | describe('RewardAPI', () => { 10 | it('last_dilution_timestamp', async () => { 11 | await expect(api.last_dilution_timestamp()).resolves.toEqual( 12 | expect.any(String) 13 | ) 14 | }) 15 | 16 | it('annual provisions', async () => { 17 | await expect(api.annualProvisions()).resolves.toEqual(expect.any(String)) 18 | }) 19 | 20 | it('params', async () => { 21 | const params = await api.parameters() 22 | expect(params).toEqual(expect.any(RewardParams)) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /src/client/rest/api/IbcTransferAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { IbcTransferAPI } from './IbcTransferAPI' 4 | import { DenomTrace, IbcTransferParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new IbcTransferAPI(c) 8 | 9 | describe('IbcTransferAPI', () => { 10 | it('denomTraces', async () => { 11 | const denomTraces = await api.denomTraces().then((v) => v[0]) 12 | denomTraces.forEach(function (denomTrace: DenomTrace.Data) { 13 | expect(denomTrace.path).toMatch('transfer/channel-') 14 | expect(denomTrace.base_denom).not.toBeUndefined() 15 | }) 16 | }) 17 | 18 | it('params', async () => { 19 | const params = await api.parameters() 20 | expect(params).toEqual(expect.any(IbcTransferParams)) 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /src/core/evm/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgCreate } from './MsgCreate' 2 | import { MsgCreate2 } from './MsgCreate2' 3 | import { MsgCall } from './MsgCall' 4 | import { MsgUpdateEvmParams } from './MsgUpdateEvmParams' 5 | 6 | export * from './MsgCreate' 7 | export * from './MsgCreate2' 8 | export * from './MsgCall' 9 | export * from './MsgUpdateEvmParams' 10 | 11 | export type EvmMsg = MsgCreate | MsgCreate2 | MsgCall | MsgUpdateEvmParams 12 | 13 | export namespace EvmMsg { 14 | export type Amino = 15 | | MsgCreate.Amino 16 | | MsgCreate2.Amino 17 | | MsgCall.Amino 18 | | MsgUpdateEvmParams.Amino 19 | export type Data = 20 | | MsgCreate.Data 21 | | MsgCreate2.Data 22 | | MsgCall.Data 23 | | MsgUpdateEvmParams.Data 24 | export type Proto = 25 | | MsgCreate.Proto 26 | | MsgCreate2.Proto 27 | | MsgCall.Proto 28 | | MsgUpdateEvmParams.Proto 29 | } 30 | -------------------------------------------------------------------------------- /src/client/rest/api/InterTxAPI.ts: -------------------------------------------------------------------------------- 1 | import { AccAddress } from '../../../core' 2 | import { BaseAPI } from './BaseAPI' 3 | import { APIParams } from '../APIRequester' 4 | 5 | export class InterTxAPI extends BaseAPI { 6 | /** 7 | * Query the interchain account for given owner address on a given connection pair. 8 | * @param owner owner address 9 | * @param connection_id unique connection identifier 10 | */ 11 | public async interchainAccount( 12 | owner: AccAddress, 13 | connection_id: string, 14 | params: APIParams = {}, 15 | headers: Record = {} 16 | ): Promise { 17 | return this.c 18 | .get<{ 19 | interchain_account_address: string 20 | }>( 21 | `/inter-tx/interchain_account/owner/${owner}/connection/${connection_id}`, 22 | params, 23 | headers 24 | ) 25 | .then((d) => d.interchain_account_address) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/core/authz/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgGrantAuthorization } from './MsgGrantAuthorization' 2 | import { MsgRevokeAuthorization } from './MsgRevokeAuthorization' 3 | import { MsgExecAuthorized } from './MsgExecAuthorized' 4 | 5 | export * from './MsgGrantAuthorization' 6 | export * from './MsgRevokeAuthorization' 7 | export * from './MsgExecAuthorized' 8 | 9 | export type AuthzMsg = 10 | | MsgGrantAuthorization 11 | | MsgRevokeAuthorization 12 | | MsgExecAuthorized 13 | 14 | export namespace AuthzMsg { 15 | export type Amino = 16 | | MsgGrantAuthorization.Amino 17 | | MsgRevokeAuthorization.Amino 18 | | MsgExecAuthorized.Amino 19 | export type Data = 20 | | MsgGrantAuthorization.Data 21 | | MsgRevokeAuthorization.Data 22 | | MsgExecAuthorized.Data 23 | export type Proto = 24 | | MsgGrantAuthorization.Proto 25 | | MsgRevokeAuthorization.Proto 26 | | MsgExecAuthorized.Proto 27 | } 28 | -------------------------------------------------------------------------------- /src/client/rest/api/MoveAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { MoveAPI } from './MoveAPI' 4 | import { Module, MoveParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new MoveAPI(c) 8 | 9 | describe('MoveAPI', () => { 10 | it('modules', async () => { 11 | const modules = await api.modules('0x1') 12 | for (const module of modules[0]) { 13 | expect(module).toEqual(expect.any(Module)) 14 | } 15 | }) 16 | 17 | it('denom&metadata', async () => { 18 | const metadata = await api.metadata('uinit') 19 | expect(metadata).toEqual(expect.any(String)) 20 | const denom = await api.denom(metadata) 21 | expect(denom).toEqual('uinit') 22 | }) 23 | 24 | it('params', async () => { 25 | const params = await api.parameters() 26 | expect(params).toEqual(expect.any(MoveParams)) 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /src/client/rest/api/UpgradeAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { UpgradeAPI } from './UpgradeAPI' 4 | import { Plan } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new UpgradeAPI(c) 8 | 9 | describe('UpgradeAPI', () => { 10 | describe('applied_plan', () => { 11 | it('0 for invalid name', async () => { 12 | const height = await api.appliedPlan('there_is_no_plan_like_this') 13 | expect(height).toEqual(0) 14 | }) 15 | }) 16 | 17 | describe('current_plan', () => { 18 | it('null plan', async () => { 19 | const plan = await api.currentPlan() 20 | expect(plan == null || plan instanceof Plan) 21 | }) 22 | }) 23 | 24 | describe('node_versions', () => { 25 | it('module count', async () => { 26 | expect(await api.moduleVersions()).toHaveLength(34) 27 | }) 28 | }) 29 | }) 30 | -------------------------------------------------------------------------------- /src/client/rest/api/DistributionAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { DistributionAPI } from './DistributionAPI' 4 | import { Coins, DistributionParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new DistributionAPI(c) 8 | 9 | describe('DistributionAPI', () => { 10 | it('withdrawAddress', async () => { 11 | await expect( 12 | api.withdrawAddress( 13 | 'init1wlvk4e083pd3nddlfe5quy56e68atra3gu9xfs' 14 | ) 15 | ).resolves.toEqual('init1wlvk4e083pd3nddlfe5quy56e68atra3gu9xfs') 16 | }) 17 | 18 | it('communityPool', async () => { 19 | await expect(api.communityPool()).resolves.toEqual( 20 | expect.any(Coins) 21 | ) 22 | }) 23 | 24 | it('params', async () => { 25 | const params = await api.parameters() 26 | expect(params).toEqual(expect.any(DistributionParams)) 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /src/util/hash.ts: -------------------------------------------------------------------------------- 1 | import { SHA256 } from 'jscrypto/SHA256' 2 | import { RIPEMD160 } from 'jscrypto/RIPEMD160' 3 | import { Base64 } from 'jscrypto/Base64' 4 | import { Word32Array } from 'jscrypto' 5 | import KECCAK256 from 'keccak256' 6 | 7 | /** 8 | * Calculates the transaction hash from Amino-encoded string. 9 | * @param data amino-encoded string (base64) 10 | */ 11 | export function hashToHex(data: string): string { 12 | return SHA256.hash(Base64.parse(data)).toString().toUpperCase() 13 | } 14 | 15 | /** 16 | * Calculates the transaction hash from Amino-encoded string. 17 | * @param data raw bytes 18 | */ 19 | export function sha256(data: Uint8Array): Uint8Array { 20 | return SHA256.hash(new Word32Array(data)).toUint8Array() 21 | } 22 | 23 | export function keccak256(data: Uint8Array): Uint8Array { 24 | return KECCAK256(Buffer.from(data)) 25 | } 26 | 27 | export function ripemd160(data: Uint8Array): Uint8Array { 28 | return RIPEMD160.hash(new Word32Array(data)).toUint8Array() 29 | } 30 | -------------------------------------------------------------------------------- /src/client/rest/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AuctionAPI' 2 | export * from './AuthAPI' 3 | export * from './AuthzAPI' 4 | export * from './BankAPI' 5 | export * from './DistributionAPI' 6 | export * from './EvidenceAPI' 7 | export * from './EvmAPI' 8 | export * from './FeeGrantAPI' 9 | export * from './ForwardingAPI' 10 | export * from './GovAPI' 11 | export * from './GroupAPI' 12 | export * from './IbcAPI' 13 | export * from './IbcHooksAPI' 14 | export * from './IbcNftAPI' 15 | export * from './IbcTransferAPI' 16 | export * from './IbcPermAPI' 17 | export * from './InterTxAPI' 18 | export * from './MarketmapAPI' 19 | export * from './MoveAPI' 20 | export * from './MstakingAPI' 21 | export * from './OpchildAPI' 22 | export * from './OphostAPI' 23 | export * from './OracleAPI' 24 | export * from './RewardAPI' 25 | export * from './SlashingAPI' 26 | export * from './TendermintAPI' 27 | export * from './TokenfactoryAPI' 28 | export * from './TxAPI' 29 | export * from './UpgradeAPI' 30 | export * from './WasmAPI' 31 | -------------------------------------------------------------------------------- /src/core/ibc/applications/fee/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgPayPacketFee } from './MsgPayPacketFee' 2 | import { MsgPayPacketFeeAsync } from './MsgPayPacketFeeAsync' 3 | import { MsgRegisterCounterpartyPayee } from './MsgRegisterCounterpartyPayee' 4 | import { MsgRegisterPayee } from './MsgRegisterPayee' 5 | 6 | export * from './MsgPayPacketFee' 7 | export * from './MsgPayPacketFeeAsync' 8 | export * from './MsgRegisterPayee' 9 | export * from './MsgRegisterCounterpartyPayee' 10 | 11 | export type IbcFeeMsg = 12 | | MsgPayPacketFee 13 | | MsgPayPacketFeeAsync 14 | | MsgRegisterPayee 15 | | MsgRegisterCounterpartyPayee 16 | 17 | export namespace IbcFeeMsg { 18 | export type Data = 19 | | MsgPayPacketFee.Data 20 | | MsgPayPacketFeeAsync.Data 21 | | MsgRegisterPayee.Data 22 | | MsgRegisterCounterpartyPayee.Data 23 | export type Proto = 24 | | MsgPayPacketFee.Proto 25 | | MsgPayPacketFeeAsync.Proto 26 | | MsgRegisterPayee.Proto 27 | | MsgRegisterCounterpartyPayee.Proto 28 | } 29 | -------------------------------------------------------------------------------- /src/client/rest/api/BankAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { BankAPI } from './BankAPI' 4 | import { BankParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new BankAPI(c) 8 | 9 | describe('BankAPI', () => { 10 | describe('balance', () => { 11 | it('account exists', async () => { 12 | await api.balance('init1wlvk4e083pd3nddlfe5quy56e68atra3gu9xfs') 13 | }) 14 | 15 | it('invalid account', async () => { 16 | await expect(api.balance('1234')).rejects.toThrow() 17 | }) 18 | }) 19 | 20 | it('total supply', async () => { 21 | const totalSupply = await api.total() 22 | expect(totalSupply[0].toArray().length).toBeGreaterThan(0) 23 | }) 24 | 25 | describe('parameters', () => { 26 | it('params', async () => { 27 | const params = await api.parameters() 28 | expect(params).toEqual(expect.any(BankParams)) 29 | }) 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "types"], 3 | "exclude": ["/node_modules/", "./src/**/*.spec.ts"], 4 | "compilerOptions": { 5 | "module": "ESNext", 6 | "declaration": true, 7 | "removeComments": true, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "allowSyntheticDefaultImports": true, 11 | "target": "es2022", 12 | "moduleResolution": "node", 13 | "lib": ["es2019", "esnext", "dom"], 14 | "sourceMap": true, 15 | "outDir": "./dist", 16 | "rootDir": "src", 17 | "baseUrl": "./", 18 | "incremental": true, 19 | "strict": false, 20 | "noImplicitAny": true, 21 | "alwaysStrict": true, 22 | "strictNullChecks": true, 23 | "noImplicitReturns": true, 24 | "noImplicitThis": true, 25 | "noUnusedLocals": false, 26 | "noFallthroughCasesInSwitch": true, 27 | "skipLibCheck": true, 28 | "esModuleInterop": true, 29 | "noUnusedParameters": true, 30 | "strictFunctionTypes": true, 31 | "strictPropertyInitialization": true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/util/bcs.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { bcs } from './bcs' 3 | 4 | describe('bcs', () => { 5 | it('bignumber test', () => { 6 | let biguint = 0n 7 | const sampleBytes = [1, 2, 4, 8, 16, 32, 64, 128, 255] 8 | const num = 0xff8040201008040201n 9 | for (let i = sampleBytes.length - 1; i >= 0; i--) { 10 | biguint = (biguint << 8n) + BigInt(sampleBytes[i]) 11 | } 12 | 13 | expect(bcs.biguint().serialize(biguint).toBytes()).toEqual( 14 | bcs.vector(bcs.u8()).serialize(sampleBytes).toBytes() 15 | ) 16 | 17 | expect( 18 | bcs.biguint().parse(bcs.biguint().serialize(biguint).toBytes()) 19 | ).toEqual(num) 20 | 21 | const bigdecimal = '123.123456789012345678' 22 | 23 | expect(bcs.bigdecimal().serialize(bigdecimal).toBytes()).toEqual( 24 | bcs.biguint().serialize(bigdecimal.replace('.', '')).toBytes() 25 | ) 26 | 27 | expect( 28 | bcs.bigdecimal().parse(bcs.bigdecimal().serialize(bigdecimal).toBytes()) 29 | ).toEqual(Number(bigdecimal)) 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /src/core/evidence/Evidence.ts: -------------------------------------------------------------------------------- 1 | import { Any } from '@initia/initia.proto/google/protobuf/any' 2 | import { Equivocation } from './Equivocation' 3 | 4 | export type Evidence = Equivocation 5 | 6 | export namespace Evidence { 7 | export type Amino = Equivocation.Amino 8 | export type Data = Equivocation.Data 9 | export type Proto = Equivocation.Proto 10 | 11 | export function fromAmino(data: Evidence.Amino): Evidence { 12 | switch (data.type) { 13 | case 'cosmos-sdk/Equivocation': 14 | return Equivocation.fromAmino(data) 15 | } 16 | } 17 | 18 | export function fromData(data: Evidence.Data): Evidence { 19 | switch (data['@type']) { 20 | case '/cosmos.evidence.v1beta1.Equivocation': 21 | return Equivocation.fromData(data) 22 | } 23 | } 24 | 25 | export function fromProto(proto: Any): Evidence { 26 | const typeUrl = proto.typeUrl 27 | switch (typeUrl) { 28 | case '/cosmos.evidence.v1beta1.Equivocation': 29 | return Equivocation.unpackAny(proto) 30 | } 31 | 32 | throw new Error(`Evidence type ${typeUrl} not recognized`) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Block' 2 | export * from './Coin' 3 | export * from './Coins' 4 | export * from './Denom' 5 | export * from './Duration' 6 | export * from './Msg' 7 | export * from './PublicKey' 8 | export * from './bech32' 9 | export * from './num' 10 | 11 | export * from './auction' 12 | export * from './auth' 13 | export * from './authz' 14 | export * from './bank' 15 | export * from './celestia' 16 | export * from './consensus' 17 | export * from './crisis' 18 | export * from './distribution' 19 | export * from './evidence' 20 | export * from './evm' 21 | export * from './feegrant' 22 | export * from './forwarding' 23 | export * from './gov' 24 | export * from './group' 25 | export * from './ibc' 26 | export * from './ibchooks' 27 | export * from './intertx' 28 | export * from './marketmap' 29 | export * from './move' 30 | export * from './mstaking' 31 | export * from './opchild' 32 | export * from './ophost' 33 | export * from './oracle' 34 | export * from './params' 35 | export * from './reward' 36 | export * from './slashing' 37 | export * from './tokenfactory' 38 | export * from './tx' 39 | export * from './upgrade' 40 | export * from './wasm' 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/client/rest/api/GovAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { GovAPI } from './GovAPI' 4 | import { Deposit, Proposal, TallyResult, GovParams } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new GovAPI(c) 8 | 9 | describe('GovAPI', () => { 10 | it('tally', async () => { 11 | const tally = await api.tally(1) 12 | expect(tally).toEqual(expect.any(TallyResult)) 13 | }) 14 | 15 | it('proposals', async () => { 16 | const proposals = await api.proposals() 17 | for (const proposal of proposals[0]) { 18 | expect(proposal).toEqual(expect.any(Proposal)) 19 | } 20 | }) 21 | 22 | it('deposits', async () => { 23 | const proposals = await api.proposals().then(v => v[0]) 24 | const proposalId = proposals[0].id 25 | const deposits = await api.deposits(proposalId).then(v => v[0][0]) 26 | if (deposits !== undefined) { 27 | expect(deposits).toEqual(expect.any(Deposit)) 28 | } 29 | }) 30 | 31 | it('params', async () => { 32 | const params = await api.parameters() 33 | expect(params).toEqual(expect.any(GovParams)) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /src/util/json.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { removeNull } from './json' 3 | 4 | describe('removeNull', () => { 5 | const object = { 6 | a: 'abc', 7 | b: { 8 | a: null, 9 | b: 123, 10 | }, 11 | c: null, 12 | d: [123], 13 | e: { 14 | a: { 15 | a: null, 16 | b: 'abc', 17 | }, 18 | b: 123, 19 | }, 20 | } 21 | 22 | it('removes null values from object', () => { 23 | const newObject = removeNull(object) 24 | expect(newObject).toEqual({ 25 | a: 'abc', 26 | b: { 27 | b: 123, 28 | }, 29 | d: [123], 30 | e: { 31 | a: { 32 | b: 'abc', 33 | }, 34 | b: 123, 35 | }, 36 | }) 37 | }) 38 | 39 | it('does not mutate object', () => { 40 | removeNull(object) 41 | expect(object).toEqual(object) 42 | }) 43 | 44 | it('returns object or primitive if not Object', () => { 45 | const string = 'string' 46 | const number = 1 47 | const boolean = false 48 | 49 | expect(removeNull(string)).toEqual(string) 50 | expect(removeNull(number)).toEqual(number) 51 | expect(removeNull(boolean)).toEqual(boolean) 52 | }) 53 | }) 54 | -------------------------------------------------------------------------------- /src/core/bank/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgSend } from './MsgSend' 2 | import { MsgMultiSend } from './MsgMultiSend' 3 | import { MsgUpdateBankParams } from './MsgUpdateBankParams' 4 | import { MsgSetSendEnabled } from './MsgSetSendEnabled' 5 | import { MsgSetDenomMetadata } from './MsgSetDenomMetadata' 6 | 7 | export * from './MsgSend' 8 | export * from './MsgMultiSend' 9 | export * from './MsgUpdateBankParams' 10 | export * from './MsgSetSendEnabled' 11 | export * from './MsgSetDenomMetadata' 12 | 13 | export type BankMsg = 14 | | MsgSend 15 | | MsgMultiSend 16 | | MsgUpdateBankParams 17 | | MsgSetSendEnabled 18 | | MsgSetDenomMetadata 19 | export namespace BankMsg { 20 | export type Amino = 21 | | MsgSend.Amino 22 | | MsgMultiSend.Amino 23 | | MsgUpdateBankParams.Amino 24 | | MsgSetSendEnabled.Amino 25 | | MsgSetDenomMetadata.Amino 26 | export type Data = 27 | | MsgSend.Data 28 | | MsgMultiSend.Data 29 | | MsgUpdateBankParams.Data 30 | | MsgSetSendEnabled.Data 31 | | MsgSetDenomMetadata.Data 32 | export type Proto = 33 | | MsgSend.Proto 34 | | MsgMultiSend.Proto 35 | | MsgUpdateBankParams.Proto 36 | | MsgSetSendEnabled.Proto 37 | | MsgSetDenomMetadata.Proto 38 | } 39 | -------------------------------------------------------------------------------- /src/client/rest/api/EvidenceAPI.ts: -------------------------------------------------------------------------------- 1 | import { BaseAPI } from './BaseAPI' 2 | import { APIParams, Pagination, PaginationOptions } from '../APIRequester' 3 | import { Evidence } from '../../../core' 4 | 5 | export class EvidenceAPI extends BaseAPI { 6 | /** 7 | * Query evidences of misbehavior (e.g. equivocation). 8 | */ 9 | public async evidences( 10 | params: Partial = {}, 11 | headers: Record = {} 12 | ): Promise<[Evidence[], Pagination]> { 13 | return this.c 14 | .get<{ 15 | evidence: Evidence.Data[] 16 | pagination: Pagination 17 | }>(`/cosmos/evidence/v1beta1/evidence`, params, headers) 18 | .then((d) => [d.evidence.map(Evidence.fromData), d.pagination]) 19 | } 20 | 21 | /** 22 | * Query evidence of a given hash. 23 | * @param hash hash to look up 24 | */ 25 | public async evidence( 26 | hash: string, 27 | params: APIParams = {}, 28 | headers: Record = {} 29 | ): Promise { 30 | return this.c 31 | .get<{ 32 | evidence: Evidence.Data 33 | }>(`/cosmos/evidence/v1beta1/evidence/${hash}`, params, headers) 34 | .then((d) => Evidence.fromData(d.evidence)) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/client/rest/api/AuthAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { AuthAPI } from './AuthAPI' 4 | import { AuthParams, BaseAccount } from '../../../core' 5 | import { MnemonicKey } from '../../../key' 6 | 7 | const c = new APIRequester('https://rest.testnet.initia.xyz') 8 | const api = new AuthAPI(c) 9 | 10 | describe('AuthAPI', () => { 11 | describe('accounts', () => { 12 | it('account exists', async () => { 13 | const acct = await api.accountInfo( 14 | 'init1hk0asaef9nxvnj7gjwawv0zz0yd7adcysktpqu' 15 | ) 16 | 17 | expect(acct instanceof BaseAccount).toBe(true) 18 | }) 19 | 20 | it('invalid account', async () => { 21 | await expect(api.accountInfo('1234')).rejects.toThrow() 22 | }) 23 | 24 | it("account doesn't exist (valid but new account)", async () => { 25 | const mk = new MnemonicKey() 26 | await expect(api.accountInfo(mk.accAddress)).rejects.toThrow( 27 | 'status code 404' 28 | ) 29 | }) 30 | }) 31 | 32 | describe('parameters', () => { 33 | it('params', async () => { 34 | const params = await api.parameters() 35 | expect(params).toEqual(expect.any(AuthParams)) 36 | }) 37 | }) 38 | }) 39 | -------------------------------------------------------------------------------- /src/core/ibc/core/connection/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgConnectionOpenAck } from './MsgConnectionOpenAck' 2 | import { MsgConnectionOpenConfirm } from './MsgConnectionOpenConfirm' 3 | import { MsgConnectionOpenInit } from './MsgConnectionOpenInit' 4 | import { MsgConnectionOpenTry } from './MsgConnectionOpenTry' 5 | import { MsgUpdateIbcConnectionParams } from './MsgUpdateIbcConnectionParams' 6 | 7 | export * from './MsgConnectionOpenInit' 8 | export * from './MsgConnectionOpenTry' 9 | export * from './MsgConnectionOpenConfirm' 10 | export * from './MsgConnectionOpenAck' 11 | export * from './MsgUpdateIbcConnectionParams' 12 | 13 | export type IbcConnectionMsg = 14 | | MsgConnectionOpenInit 15 | | MsgConnectionOpenTry 16 | | MsgConnectionOpenConfirm 17 | | MsgConnectionOpenAck 18 | | MsgUpdateIbcConnectionParams 19 | 20 | export namespace IbcConnectionMsg { 21 | export type Data = 22 | | MsgConnectionOpenInit.Data 23 | | MsgConnectionOpenTry.Data 24 | | MsgConnectionOpenConfirm.Data 25 | | MsgConnectionOpenAck.Data 26 | | MsgUpdateIbcConnectionParams.Data 27 | 28 | export type Proto = 29 | | MsgConnectionOpenInit.Proto 30 | | MsgConnectionOpenTry.Proto 31 | | MsgConnectionOpenConfirm.Proto 32 | | MsgConnectionOpenAck.Proto 33 | | MsgUpdateIbcConnectionParams.Proto 34 | } 35 | -------------------------------------------------------------------------------- /src/client/rest/api/OracleAPI.ts: -------------------------------------------------------------------------------- 1 | import { BaseAPI } from './BaseAPI' 2 | import { APIParams } from '../APIRequester' 3 | import { CurrencyPair, QuotePrice } from '../../../core' 4 | 5 | export class OracleAPI extends BaseAPI { 6 | /** 7 | * Query all the currency pairs the oracle module is tracking price-data for. 8 | */ 9 | public async currencyPairs( 10 | params: APIParams = {}, 11 | headers: Record = {} 12 | ): Promise { 13 | return this.c 14 | .get<{ 15 | currency_pairs: CurrencyPair.Data[] 16 | }>(`/connect/oracle/v2/get_all_tickers`, params, headers) 17 | .then((d) => d.currency_pairs.map(CurrencyPair.fromData)) 18 | } 19 | 20 | /** 21 | * Query the latest quote price for the given currency pair. 22 | * @param pair the pair that the user wishes to query 23 | */ 24 | public async price( 25 | pair: CurrencyPair, 26 | params: APIParams = {}, 27 | headers: Record = {} 28 | ): Promise { 29 | return this.c 30 | .get<{ price: QuotePrice.Data }>( 31 | `/connect/oracle/v2/get_price`, 32 | { 33 | ...params, 34 | currency_pair: pair.toString(), 35 | }, 36 | headers 37 | ) 38 | .then((d) => QuotePrice.fromData(d.price)) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/key/ledger/types.ts: -------------------------------------------------------------------------------- 1 | export interface JSONBuffer { 2 | type: 'Buffer' 3 | data: number[] 4 | } 5 | 6 | export interface CommonResponse { 7 | return_code: number 8 | error_message: string 9 | device_locked?: boolean 10 | } 11 | 12 | export interface PublicKeyResponse extends CommonResponse { 13 | bech32_address: string 14 | pk: 'OBSOLETE PROPERTY' 15 | compressed_pk: JSONBuffer 16 | } 17 | 18 | export interface AddressResponse extends CommonResponse { 19 | bech32_address: string 20 | compressed_pk: JSONBuffer 21 | } 22 | 23 | export interface SignResponse extends CommonResponse { 24 | signature: JSONBuffer 25 | } 26 | 27 | export interface AppInfoResponse extends CommonResponse { 28 | app_name: string 29 | app_version: string 30 | flag_len: number 31 | flags_value: number 32 | flag_recovery: boolean 33 | flag_signed_mcu_code: boolean 34 | flag_onboarded: boolean 35 | flag_pin_validated: boolean 36 | } 37 | 38 | export interface VersionResponse extends CommonResponse { 39 | test_mode: boolean 40 | major: number 41 | minor: number 42 | patch: number 43 | target_id: string 44 | } 45 | 46 | export interface DeviceInfoResponse extends CommonResponse { 47 | target_id: string // '31100004', 48 | se_version: string // '1.6.0', 49 | flag: string // 'a6000000', 50 | mcu_version: string // '1.11' 51 | } 52 | -------------------------------------------------------------------------------- /src/core/authz/msgs/MsgGrantAuthorization.data.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "type": "cosmos-sdk/MsgGrant", 3 | "value": { 4 | "granter": "init1nty4ku4a79zj45jl0fy5rrjun07ny0nrve7j99", 5 | "grantee": "init1qfqa2eu9wp272ha93lj4yhcenrc6ymng079nu8", 6 | "grant": { 7 | "authorization": { 8 | "type": "cosmos-sdk/SendAuthorization", 9 | "value": { 10 | "spend_limit": [{ 11 | "denom": "uinit", 12 | "amount": "1000000" 13 | }] 14 | } 15 | }, 16 | "expiration": "2022-06-29T08:18:15.000Z" 17 | } 18 | } 19 | }, 20 | { 21 | "type": "cosmos-sdk/MsgGrant", 22 | "value": { 23 | "granter": "init1nty4ku4a79zj45jl0fy5rrjun07ny0nrve7j99", 24 | "grantee": "init1qfqa2eu9wp272ha93lj4yhcenrc6ymng079nu8", 25 | "grant": { 26 | "authorization": { 27 | "type": "cosmos-sdk/GenericAuthorization", 28 | "value": { 29 | "msg": "/cosmos.bank.v1beta1.MsgSend" 30 | } 31 | }, 32 | "expiration": "2022-06-29T08:18:15.000Z" 33 | } 34 | } 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /src/core/Block.ts: -------------------------------------------------------------------------------- 1 | export interface BlockInfo { 2 | block_id: BlockID 3 | block: Block 4 | } 5 | 6 | export interface Block { 7 | header: Header 8 | data: { txs?: string[] } 9 | evidence: EvidenceList 10 | last_commit: LastCommit 11 | } 12 | 13 | export interface EvidenceList { 14 | evidence: string[] 15 | } 16 | 17 | export interface Header { 18 | version: Version 19 | 20 | /** blockchain ID */ 21 | chain_id: string 22 | 23 | /** block's height */ 24 | height: string 25 | 26 | /** time the block was included */ 27 | time: string 28 | last_block_id: BlockID 29 | last_commit_hash: string 30 | data_hash: string 31 | validators_hash: string 32 | next_validators_hash: string 33 | consensus_hash: string 34 | app_hash: string 35 | last_results_hash: string 36 | evidence_hash: string 37 | proposer_address: string 38 | } 39 | 40 | export interface BlockID { 41 | hash: string 42 | part_set_header: Parts 43 | } 44 | 45 | export interface Parts { 46 | total: string 47 | hash: string 48 | } 49 | 50 | export interface Version { 51 | block: string 52 | app: string 53 | } 54 | 55 | export interface LastCommit { 56 | height: string 57 | round: number 58 | block_id: BlockID 59 | signatures: Signature[] 60 | } 61 | 62 | export interface Signature { 63 | block_id_flag: string 64 | validator_address: string 65 | timestamp: string 66 | signature: string 67 | } 68 | -------------------------------------------------------------------------------- /src/key/ledger/constants.ts: -------------------------------------------------------------------------------- 1 | export const CLA = 0x55 2 | export const CHUNK_SIZE = 250 3 | export const APP_KEY = 'CSM' 4 | 5 | export const INS = { 6 | GET_VERSION: 0x00, 7 | INS_PUBLIC_KEY_SECP256K1: 0x01, // Obsolete 8 | SIGN_SECP256K1: 0x02, 9 | GET_ADDR_SECP256K1: 0x04, 10 | } 11 | 12 | export const PAYLOAD_TYPE = { 13 | INIT: 0x00, 14 | ADD: 0x01, 15 | LAST: 0x02, 16 | } 17 | 18 | export const P1_VALUES = { 19 | ONLY_RETRIEVE: 0x00, 20 | SHOW_ADDRESS_IN_DEVICE: 0x01, 21 | } 22 | 23 | export const ERROR_CODE = { 24 | NoError: 0x9000, 25 | } 26 | 27 | export const ERROR_DESCRIPTION: Record = { 28 | 1: 'U2F: Unknown', 29 | 2: 'U2F: Bad request', 30 | 3: 'U2F: Configuration unsupported', 31 | 4: 'U2F: Device Ineligible', 32 | 5: 'U2F: Timeout', 33 | 14: 'Timeout', 34 | 0x9000: 'No errors', 35 | 0x9001: 'Device is busy', 36 | 0x6802: 'Error deriving keys', 37 | 0x6400: 'Execution Error', 38 | 0x6700: 'Wrong Length', 39 | 0x6982: 'Empty Buffer', 40 | 0x6983: 'Output buffer too small', 41 | 0x6984: 'Data is invalid', 42 | 0x6985: 'Conditions not satisfied', 43 | 0x6986: 'Transaction rejected', 44 | 0x6a80: 'Bad key handle', 45 | 0x6b00: 'Invalid P1/P2', 46 | 0x6b0c: 'Ledger is locked', 47 | 0x6d00: 'Instruction not supported', 48 | 0x6e00: 'App does not seem to be open', 49 | 0x6f00: 'Unknown error', 50 | 0x6f01: 'Sign/verify error', 51 | } 52 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve (use this for suspected bugs only, if not sure, open a regular issue below) 4 | title: '' 5 | labels: Bug 6 | assignees: '' 7 | --- 8 | 9 | 14 | 15 | 16 | 17 | **Expected behavior** 18 | 19 | 20 | 21 | **Actual behavior** 22 | 23 | 25 | 26 | **To reproduce** 27 | 28 | 29 | 30 | **System information** 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | 26 | 27 | 33 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | import eslint from '@eslint/js' 4 | import tseslint from 'typescript-eslint' 5 | import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' 6 | 7 | export default tseslint.config( 8 | eslint.configs.recommended, 9 | ...tseslint.configs.recommended, 10 | ...tseslint.configs.stylistic, 11 | ...tseslint.configs.recommendedTypeChecked, 12 | { 13 | languageOptions: { 14 | parserOptions: { 15 | project: './tsconfig.json', 16 | tsconfigRootDir: import.meta.dirname, 17 | }, 18 | }, 19 | rules: { 20 | '@typescript-eslint/no-namespace': 'off', 21 | '@typescript-eslint/unbound-method': [ 22 | "error", 23 | { 24 | "ignoreStatic": true 25 | } 26 | ], 27 | '@typescript-eslint/no-explicit-any': 'off', 28 | '@typescript-eslint/no-unsafe-assignment': 'off', 29 | '@typescript-eslint/no-unsafe-return': 'off', 30 | '@typescript-eslint/no-unused-vars': [ 31 | 'error', 32 | { 33 | argsIgnorePattern: '^_', 34 | varsIgnorePattern: '^_', 35 | }, 36 | ], 37 | } 38 | }, 39 | { 40 | files: ['**/*.js'], 41 | ...tseslint.configs.disableTypeChecked, 42 | }, 43 | eslintPluginPrettierRecommended, 44 | { 45 | ignores: ['dist/**/*', 'integration-tests/**/*', '**/*.config.js', '**/*.config.mjs', '**/*.spec.ts', '**/*.config.ts'], 46 | }, 47 | ) 48 | -------------------------------------------------------------------------------- /src/core/mstaking/Delegation.data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "delegation": { 4 | "delegator_address": "init1y3qwj2nf2x9gc6ctgt4vzh6e3q23cy9xk032t4", 5 | "validator_address": "initvaloper1y3qwj2nf2x9gc6ctgt4vzh6e3q23cy9xz2gn99", 6 | "shares": [ 7 | { 8 | "denom": "move/975343fbd246bd169757499d5220021114bb32acede722c65180e9f199d19615", 9 | "amount": "100000000.000000000000000000" 10 | }, 11 | { 12 | "denom": "ustake", 13 | "amount": "20000000.000000000000000000" 14 | } 15 | ] 16 | }, 17 | "balance": [ 18 | { 19 | "denom": "move/975343fbd246bd169757499d5220021114bb32acede722c65180e9f199d19615", 20 | "amount": "100000000" 21 | }, 22 | { 23 | "denom": "ustake", 24 | "amount": "20000000" 25 | } 26 | ] 27 | }, 28 | { 29 | "delegation": { 30 | "delegator_address": "init1lf0swvvhy3vqautdemmvunfmp0grfrjgzznx9s", 31 | "validator_address": "initvaloper1y3qwj2nf2x9gc6ctgt4vzh6e3q23cy9xz2gn99", 32 | "shares": [ 33 | { 34 | "denom": "move/975343fbd246bd169757499d5220021114bb32acede722c65180e9f199d19615", 35 | "amount": "5625331862.000000000000000000" 36 | } 37 | ] 38 | }, 39 | "balance": [ 40 | { 41 | "denom": "move/975343fbd246bd169757499d5220021114bb32acede722c65180e9f199d19615", 42 | "amount": "5625331862" 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /src/util/hash.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { hashToHex } from './hash' 3 | 4 | describe('hashToHex', () => { 5 | it('hashes correctly', () => { 6 | expect( 7 | hashToHex( 8 | '2gbGwQI/ClDeU+EsChIyNjc4NzI5ODA2ODA4OTgxNTQSBDlkYmMaBHV1c2QiFFvGfiBRs1FeYdwYQmKwm3W+3+TNKhSwR4zq2Hn7r74oEK5S3SHokyzgSQpT3lPhLAoVMzExMDA1ODg4MDMwMTM2MzYxNTIyEgQzN2NjGgR1a3J3IhRbxn4gUbNRXmHcGEJisJt1vt/kzSoUsEeM6th5+6++KBCuUt0h6JMs4EkKUN5T4SwKEjE5NDQzNzc0NjAxMTA3NTM4NRIEYTBhMhoEdXNkciIUW8Z+IFGzUV5h3BhCYrCbdb7f5M0qFLBHjOrYefuvvigQrlLdIeiTLOBJClPeU+EsChU3Mjk5NTM4NzIzNTU0NDc1MTU0NzQSBGMxNzgaBHVtbnQiFFvGfiBRs1FeYdwYQmKwm3W+3+TNKhSwR4zq2Hn7r74oEK5S3SHokyzgSQpgcVjB3gooYTU3MjBkNWE0NjJiN2Y4NjdhZjc1NWJmYzNmZTM1NjI3YzM3MzgyYhIEdXVzZBoUW8Z+IFGzUV5h3BhCYrCbdb7f5M0iFLBHjOrYefuvvigQrlLdIeiTLOBJCmBxWMHeCig4NDM4ZGY5MWIyZTRjY2IzNzg0Y2FiZDRlODRjZjIwZjQxODAwOTEwEgR1a3J3GhRbxn4gUbNRXmHcGEJisJt1vt/kzSIUsEeM6th5+6++KBCuUt0h6JMs4EkKYHFYwd4KKDRjMjA5ODFlMGM2NjA5OGVlMzlmMGU0YWZiYmFmYmMwNTEzNmUxYmESBHVzZHIaFFvGfiBRs1FeYdwYQmKwm3W+3+TNIhSwR4zq2Hn7r74oEK5S3SHokyzgSQpgcVjB3gooYmIxNTE5NDdjYWQxYTBhYmNlOWNiNzgwYTVmYWE1MWQwYjdmOWY1MBIEdW1udBoUW8Z+IFGzUV5h3BhCYrCbdb7f5M0iFLBHjOrYefuvvigQrlLdIeiTLOBJEhIKDAoEdWtydxIENDAwMBDAmgwaagom61rphyEDhEN2CNA81Z+AmzAQE1jn2oSTodQUbDXsn2Hu38eFQJYSQJEFGtcrE5JUrEDxfOQTBjbPQKMN0nvqpkC1hbqkBLeUCVpal4LI+IwyQDHF1NwQCRgB0k0MeoD4ZkzzAh6igws=' 9 | ) 10 | ).toEqual( 11 | 'E2969CFC525D852234EAF30F7F2A71ACC1A89261543E0343220FD4030F58A140' 12 | ) 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /src/client/rest/api/RewardAPI.ts: -------------------------------------------------------------------------------- 1 | import { RewardParams } from '../../../core' 2 | import { APIParams } from '../APIRequester' 3 | import { BaseAPI } from './BaseAPI' 4 | 5 | export class RewardAPI extends BaseAPI { 6 | /** 7 | * Query the last release rate dilution timestamp. 8 | */ 9 | public async last_dilution_timestamp( 10 | params: APIParams = {}, 11 | headers: Record = {} 12 | ): Promise { 13 | return this.c 14 | .get<{ 15 | last_dilution_timestamp: string 16 | }>(`/initia/reward/v1/last_dilution_timestamp`, params, headers) 17 | .then((d) => d.last_dilution_timestamp) 18 | } 19 | 20 | /** 21 | * Query the current annual provisions value. 22 | */ 23 | public async annualProvisions( 24 | params: APIParams = {}, 25 | headers: Record = {} 26 | ): Promise { 27 | return this.c 28 | .get<{ 29 | annual_provisions: string 30 | }>(`/initia/reward/v1/annual_provisions`, params, headers) 31 | .then((d) => d.annual_provisions) 32 | } 33 | 34 | /** 35 | * Query the parameters of the reward module. 36 | */ 37 | public async parameters( 38 | params: APIParams = {}, 39 | headers: Record = {} 40 | ): Promise { 41 | return this.c 42 | .get<{ 43 | params: RewardParams.Data 44 | }>(`/initia/reward/v1/params`, params, headers) 45 | .then((d) => RewardParams.fromData(d.params)) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/client/rest/api/IbcPermAPI.ts: -------------------------------------------------------------------------------- 1 | import { BaseAPI } from './BaseAPI' 2 | import { APIParams, Pagination, PaginationOptions } from '../APIRequester' 3 | 4 | export interface ChannelState { 5 | port_id: string 6 | channel_id: string 7 | admin: string 8 | relayers: string[] 9 | } 10 | 11 | export class IbcPermAPI extends BaseAPI { 12 | /** 13 | * Query all the channel states. 14 | */ 15 | public async channelStates( 16 | params: Partial = {}, 17 | headers: Record = {} 18 | ): Promise<[ChannelState[], Pagination]> { 19 | return this.c 20 | .get<{ 21 | channel_states: ChannelState[] 22 | pagination: Pagination 23 | }>(`/ibc/apps/perm/v1/channel_states`, params, headers) 24 | .then((d) => [d.channel_states, d.pagination]) 25 | } 26 | 27 | /** 28 | * Query the channel state for the specific port-id:channel-id pair. 29 | * @param channel_id unique channel identifier 30 | * @param port_id unique port identifier 31 | */ 32 | public async channelState( 33 | channel_id: string, 34 | port_id: string, 35 | params: APIParams = {}, 36 | headers: Record = {} 37 | ): Promise { 38 | return this.c 39 | .get<{ 40 | channel_state: ChannelState 41 | }>( 42 | `/ibc/apps/perm/v1/channel_states/${channel_id}/${port_id}`, 43 | params, 44 | headers 45 | ) 46 | .then((d) => d.channel_state) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/core/ibc/core/commitment/MerkleRoot.ts: -------------------------------------------------------------------------------- 1 | import { MerkleRoot as MerkleRoot_pb } from '@initia/initia.proto/ibc/core/commitment/v1/commitment' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * MerkleRoot defines a merkle root hash. 6 | * In the Cosmos SDK, the AppHash of a block header becomes the root. 7 | */ 8 | export class MerkleRoot extends JSONSerializable< 9 | MerkleRoot.Amino, 10 | MerkleRoot.Data, 11 | MerkleRoot.Proto 12 | > { 13 | /** 14 | * @param hash 15 | */ 16 | constructor(public hash: string) { 17 | super() 18 | } 19 | 20 | public static fromAmino(_: any): MerkleRoot { 21 | throw new Error('Amino not supported') 22 | } 23 | 24 | public toAmino(): any { 25 | throw new Error('Amino not supported') 26 | } 27 | 28 | public static fromData(data: MerkleRoot.Data): MerkleRoot { 29 | return new MerkleRoot(data.hash) 30 | } 31 | 32 | public toData(): MerkleRoot.Data { 33 | return { hash: this.hash } 34 | } 35 | 36 | public static fromProto(proto: MerkleRoot.Proto): MerkleRoot { 37 | return new MerkleRoot(Buffer.from(proto.hash).toString('base64')) 38 | } 39 | 40 | public toProto(): MerkleRoot.Proto { 41 | return MerkleRoot_pb.fromPartial({ 42 | hash: Buffer.from(this.hash, 'base64'), 43 | }) 44 | } 45 | } 46 | 47 | export namespace MerkleRoot { 48 | export interface Amino { 49 | hash: string 50 | } 51 | 52 | export interface Data { 53 | hash: string 54 | } 55 | 56 | export type Proto = MerkleRoot_pb 57 | } 58 | -------------------------------------------------------------------------------- /src/core/PublicKey.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { 3 | EthPublicKey, 4 | LegacyAminoMultisigPublicKey, 5 | SimplePublicKey, 6 | ValConsPublicKey, 7 | } from './PublicKey' 8 | 9 | describe('PublicKey', () => { 10 | it('Multisig address', () => { 11 | const pubkey = new LegacyAminoMultisigPublicKey(2, [ 12 | new SimplePublicKey('A/PwvW/JLEnhb0/o5g+AnOqMN+FFT24gjJfDtA1tBsBv'), 13 | new SimplePublicKey('A9XR3uRxAD5L9kkYotz094hH6ye92YLraSO/sGhWalxb'), 14 | new SimplePublicKey('AyETa9Y9ihObzeRPWMP0MBAa0Mqune3I+5KonOCPTtkv'), 15 | ]) 16 | 17 | expect(pubkey.address()).toEqual( 18 | 'init1gufrav46pnpwf03yu7xz76ylkmatsxtph3uqj6' 19 | ) 20 | }) 21 | 22 | it('SimplePubkey address', () => { 23 | const pubkey = new SimplePublicKey( 24 | 'AjszqFJDRAYbEjZMuiD+ChqzbUSGq/RRu3zr0R6iJB5b' 25 | ) 26 | expect(pubkey.address()).toEqual( 27 | 'init1x46rqay4d3cssq8gxxvqz8xt6nwlz4tdzavzww' 28 | ) 29 | }) 30 | 31 | it('ValCons address', () => { 32 | const pubkey = new ValConsPublicKey( 33 | 'zC1zhckGr/0ZjlXkRbD575N0KC+yhWKYcEFDueBTX5o=' 34 | ) 35 | expect(pubkey.address()).toEqual( 36 | 'initvalcons1mlhj044zpxqdeaajfxpnav59rp4ap38tgp3hzm' 37 | ) 38 | }) 39 | 40 | it('EthPubkey address', () => { 41 | const pubkey = new EthPublicKey( 42 | 'Ahng0jM7JGSIWF38ey+qwH7T5EcUvzQqued27hn5kSgl' 43 | ) 44 | expect(pubkey.address()).toEqual( 45 | 'init18cuwmw9f423hgfl9k8d6an8p6ffvvghvtmu6l7' 46 | ) 47 | }) 48 | }) 49 | -------------------------------------------------------------------------------- /src/core/ibc/core/client/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgCreateClient } from './MsgCreateClient' 2 | import { MsgSubmitMisbehaviour } from './MsgSubmitMisbehaviour' 3 | import { MsgUpdateClient } from './MsgUpdateClient' 4 | import { MsgUpgradeClient } from './MsgUpgradeClient' 5 | import { MsgRecoverClient } from './MsgRecoverClient' 6 | import { MsgIBCSoftwareUpgrade } from './MsgIBCSoftwareUpgrade' 7 | import { MsgUpdateIbcClientParams } from './MsgUpdateIbcClientParams' 8 | 9 | export * from './MsgCreateClient' 10 | export * from './MsgUpdateClient' 11 | export * from './MsgUpgradeClient' 12 | export * from './MsgSubmitMisbehaviour' 13 | export * from './MsgRecoverClient' 14 | export * from './MsgIBCSoftwareUpgrade' 15 | export * from './MsgUpdateIbcClientParams' 16 | 17 | export type IbcClientMsg = 18 | | MsgCreateClient 19 | | MsgUpdateClient 20 | | MsgUpgradeClient 21 | | MsgSubmitMisbehaviour 22 | | MsgRecoverClient 23 | | MsgIBCSoftwareUpgrade 24 | | MsgUpdateIbcClientParams 25 | 26 | export namespace IbcClientMsg { 27 | export type Data = 28 | | MsgCreateClient.Data 29 | | MsgUpdateClient.Data 30 | | MsgUpgradeClient.Data 31 | | MsgSubmitMisbehaviour.Data 32 | | MsgRecoverClient.Data 33 | | MsgIBCSoftwareUpgrade.Data 34 | | MsgUpdateIbcClientParams.Data 35 | 36 | export type Proto = 37 | | MsgCreateClient.Proto 38 | | MsgUpdateClient.Proto 39 | | MsgUpgradeClient.Proto 40 | | MsgSubmitMisbehaviour.Proto 41 | | MsgRecoverClient.Proto 42 | | MsgIBCSoftwareUpgrade.Proto 43 | | MsgUpdateIbcClientParams.Proto 44 | } 45 | -------------------------------------------------------------------------------- /src/core/auth/Account.ts: -------------------------------------------------------------------------------- 1 | import { Any } from '@initia/initia.proto/google/protobuf/any' 2 | import { BaseAccount } from './BaseAccount' 3 | import { ModuleAccount } from './ModuleAccount' 4 | 5 | export type Account = BaseAccount | ModuleAccount 6 | 7 | /** 8 | * Stores information about an account fetched from the blockchain. 9 | */ 10 | export namespace Account { 11 | export type Amino = BaseAccount.Amino | ModuleAccount.Amino 12 | export type Data = BaseAccount.Data | ModuleAccount.Data 13 | export type Proto = Any 14 | 15 | export function fromAmino(amino: Account.Amino): Account { 16 | switch (amino.type) { 17 | case 'cosmos-sdk/BaseAccount': 18 | return BaseAccount.fromAmino(amino) 19 | case 'cosmos-sdk/ModuleAccount': 20 | return ModuleAccount.fromAmino(amino) 21 | } 22 | } 23 | 24 | export function fromData(data: Account.Data): Account { 25 | switch (data['@type']) { 26 | case '/cosmos.auth.v1beta1.BaseAccount': 27 | return BaseAccount.fromData(data) 28 | case '/cosmos.auth.v1beta1.ModuleAccount': 29 | return ModuleAccount.fromData(data) 30 | } 31 | } 32 | 33 | export function fromProto(accountAny: Account.Proto): Account { 34 | const typeUrl = accountAny.typeUrl 35 | if (typeUrl === '/cosmos.auth.v1beta1.BaseAccount') { 36 | return BaseAccount.unpackAny(accountAny) 37 | } else if (typeUrl === '/cosmos.auth.v1beta1.ModuleAccount') { 38 | return ModuleAccount.unpackAny(accountAny) 39 | } 40 | 41 | throw new Error(`Account type ${typeUrl} not recognized`) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/core/marketmap/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgCreateMarkets } from './MsgCreateMarkets' 2 | import { MsgUpdateMarkets } from './MsgUpdateMarkets' 3 | import { MsgUpsertMarkets } from './MsgUpsertMarkets' 4 | import { MsgRemoveMarkets } from './MsgRemoveMarkets' 5 | import { MsgRemoveMarketAuthorities } from './MsgRemoveMarketAuthorities' 6 | import { MsgUpdateMarketmapParams } from './MsgUpdateMarketmapParams' 7 | 8 | export * from './MsgCreateMarkets' 9 | export * from './MsgUpdateMarkets' 10 | export * from './MsgUpsertMarkets' 11 | export * from './MsgRemoveMarkets' 12 | export * from './MsgRemoveMarketAuthorities' 13 | export * from './MsgUpdateMarketmapParams' 14 | 15 | export type MarketmapMsg = 16 | | MsgCreateMarkets 17 | | MsgUpdateMarkets 18 | | MsgUpsertMarkets 19 | | MsgRemoveMarkets 20 | | MsgRemoveMarketAuthorities 21 | | MsgUpdateMarketmapParams 22 | 23 | export namespace MarketmapMsg { 24 | export type Amino = 25 | | MsgCreateMarkets.Amino 26 | | MsgUpdateMarkets.Amino 27 | | MsgUpsertMarkets.Amino 28 | | MsgRemoveMarkets.Amino 29 | | MsgRemoveMarketAuthorities.Amino 30 | | MsgUpdateMarketmapParams.Amino 31 | 32 | export type Data = 33 | | MsgCreateMarkets.Data 34 | | MsgUpdateMarkets.Data 35 | | MsgUpsertMarkets.Data 36 | | MsgRemoveMarkets.Data 37 | | MsgRemoveMarketAuthorities.Data 38 | | MsgUpdateMarketmapParams.Data 39 | 40 | export type Proto = 41 | | MsgCreateMarkets.Proto 42 | | MsgUpdateMarkets.Proto 43 | | MsgUpsertMarkets.Proto 44 | | MsgRemoveMarkets.Proto 45 | | MsgRemoveMarketAuthorities.Proto 46 | | MsgUpdateMarketmapParams.Proto 47 | } 48 | -------------------------------------------------------------------------------- /src/util/json.ts: -------------------------------------------------------------------------------- 1 | export function prepareSignBytes(obj: any): any { 2 | if (Array.isArray(obj)) { 3 | return obj.map(prepareSignBytes) 4 | } 5 | 6 | // string, number, or null 7 | if (typeof obj !== `object` || obj === null) { 8 | return obj 9 | } 10 | 11 | const sorted: any = {} 12 | 13 | // eslint-disable-next-line @typescript-eslint/no-unsafe-argument 14 | Object.keys(obj) 15 | .sort() 16 | .forEach((key) => { 17 | if (obj[key] === undefined || obj[key] === null) return // eslint-disable-line @typescript-eslint/no-unsafe-member-access 18 | sorted[key] = prepareSignBytes(obj[key]) // eslint-disable-line @typescript-eslint/no-unsafe-member-access 19 | }) 20 | return sorted 21 | } 22 | 23 | export abstract class JSONSerializable { 24 | public abstract toAmino(): A 25 | public abstract toData(): D 26 | public abstract toProto(): P 27 | public toJSON(): string { 28 | return JSON.stringify(prepareSignBytes(this.toData())) 29 | } 30 | public toAminoJSON(): string { 31 | return JSON.stringify(prepareSignBytes(this.toAmino())) 32 | } 33 | } 34 | 35 | export function removeNull(obj: any): any { 36 | if (obj !== null && typeof obj === 'object') { 37 | // eslint-disable-line @typescript-eslint/no-unsafe-argument 38 | return Object.entries(obj) // eslint-disable-line @typescript-eslint/no-unsafe-argument 39 | .filter(([, v]) => v != null) 40 | .reduce( 41 | (acc, [k, v]) => ({ 42 | ...acc, 43 | [k]: v === Object(v) && !Array.isArray(v) ? removeNull(v) : v, 44 | }), 45 | {} 46 | ) 47 | } 48 | 49 | return obj 50 | } 51 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Release_notes.md: -------------------------------------------------------------------------------- 1 | Release Notes 2 | ================== 3 | 4 | Initia version 0.45.12 is now available from: 5 | 6 | 7 | 8 | This release includes new features, various bug fixes and performance 9 | improvements, as well as updated translations. 10 | 11 | Please report bugs using the issue tracker at GitHub: 12 | 13 | 14 | 15 | To receive security and update notifications, please join our discord channel. 16 | 17 | 18 | What's Changed 19 | ============== 20 | ### Initia 21 | - upgrade to cosmos-sdk v0.45.12 by @zkst in #102 22 | 23 | ### RPC and other APIs 24 | 25 | - #25220 rpc: fix incorrect warning for address type p2sh-segwit in createmultisig 26 | - #25237 rpc: Capture UniValue by ref for rpcdoccheck 27 | - #25983 Prevent data race for pathHandlers 28 | - #26275 Fix crash on deriveaddresses when index is 2147483647 (2^31-1) 29 | 30 | ### Build system 31 | 32 | - #25201 windeploy: Renewed windows code signing certificate 33 | - #25788 guix: patch NSIS to remove .reloc sections from installer stubs 34 | - #25861 guix: use --build={arch}-guix-linux-gnu in cross toolchain 35 | - #25985 Revert "build: Use Homebrew's sqlite package if it is available" 36 | 37 | ### GUI 38 | 39 | - gui#631 Disallow encryption of watchonly wallets 40 | - gui#680 Fixes MacOS 13 segfault by preventing certain notifications 41 | 42 | ### Tests 43 | 44 | - #24454 tests: Fix calculation of external input weights 45 | 46 | ### Miscellaneous 47 | 48 | - #26321 Adjust .tx/config for new Transifex CLI 49 | 50 | Full Changelog: Initia-node-v1.0.0...Initia-node-v1.0.1 [link] -------------------------------------------------------------------------------- /src/client/rest/api/IbcHooksAPI.ts: -------------------------------------------------------------------------------- 1 | import { BaseAPI } from './BaseAPI' 2 | import { APIParams, Pagination, PaginationOptions } from '../APIRequester' 3 | import { AccAddress, ACL, IbcHooksParams } from '../../../core' 4 | 5 | export class IbcHooksAPI extends BaseAPI { 6 | /** 7 | * Query all the ACL entries. 8 | */ 9 | public async acls( 10 | params: Partial = {}, 11 | headers: Record = {} 12 | ): Promise<[ACL[], Pagination]> { 13 | return this.c 14 | .get<{ 15 | acls: ACL.Data[] 16 | pagination: Pagination 17 | }>(`/initia/ibchooks/v1/acls`, params, headers) 18 | .then((d) => [d.acls.map(ACL.fromData), d.pagination]) 19 | } 20 | 21 | /** 22 | * Query the ACL entry of an address. 23 | * @param address a contract address (wasm, evm) or a contract deployer address (move) 24 | */ 25 | public async acl( 26 | address: AccAddress, 27 | params: APIParams = {}, 28 | headers: Record = {} 29 | ): Promise { 30 | return this.c 31 | .get<{ 32 | acl: ACL.Data 33 | }>(`/initia/ibchooks/v1/acls/${address}`, params, headers) 34 | .then((d) => ACL.fromData(d.acl)) 35 | } 36 | 37 | /** 38 | * Query the parameters of the ibc hooks module. 39 | */ 40 | public async parameters( 41 | params: APIParams = {}, 42 | headers: Record = {} 43 | ): Promise { 44 | return this.c 45 | .get<{ 46 | params: IbcHooksParams.Data 47 | }>(`/initia/ibchooks/v1/params`, params, headers) 48 | .then((d) => IbcHooksParams.fromData(d.params)) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/core/ibchooks/ACL.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { AccAddress } from '../bech32' 3 | import { ACL as ACL_pb } from '@initia/initia.proto/initia/ibchooks/v1/types' 4 | 5 | /** 6 | * ACL defines the ACL entry of an address. 7 | */ 8 | export class ACL extends JSONSerializable { 9 | /** 10 | * @param address 11 | * @param allowed 12 | */ 13 | constructor( 14 | public address: AccAddress, 15 | public allowed: boolean 16 | ) { 17 | super() 18 | } 19 | 20 | public static fromAmino(data: ACL.Amino): ACL { 21 | const { address, allowed } = data 22 | return new ACL(address, allowed) 23 | } 24 | 25 | public toAmino(): ACL.Amino { 26 | const { address, allowed } = this 27 | return { address, allowed } 28 | } 29 | 30 | public static fromData(data: ACL.Data): ACL { 31 | const { address, allowed } = data 32 | return new ACL(address, allowed) 33 | } 34 | 35 | public toData(): ACL.Data { 36 | const { address, allowed } = this 37 | return { address, allowed } 38 | } 39 | 40 | public static fromProto(data: ACL.Proto): ACL { 41 | return new ACL(data.address, data.allowed) 42 | } 43 | 44 | public toProto(): ACL.Proto { 45 | const { address, allowed } = this 46 | return ACL_pb.fromPartial({ 47 | address, 48 | allowed, 49 | }) 50 | } 51 | } 52 | 53 | export namespace ACL { 54 | export interface Amino { 55 | address: AccAddress 56 | allowed: boolean 57 | } 58 | 59 | export interface Data { 60 | address: AccAddress 61 | allowed: boolean 62 | } 63 | 64 | export type Proto = ACL_pb 65 | } 66 | -------------------------------------------------------------------------------- /src/core/gov/proposals/Content.ts: -------------------------------------------------------------------------------- 1 | import { ParameterChangeProposal } from '../../params/proposals' 2 | import { TextProposal } from './TextProposal' 3 | import { Any } from '@initia/initia.proto/google/protobuf/any' 4 | 5 | export type Content = TextProposal | ParameterChangeProposal 6 | 7 | export namespace Content { 8 | export type Amino = TextProposal.Amino | ParameterChangeProposal.Amino 9 | 10 | export type Data = TextProposal.Data | ParameterChangeProposal.Data 11 | 12 | export type Proto = TextProposal.Proto | ParameterChangeProposal.Proto 13 | 14 | export function fromAmino(data: Content.Amino): Content { 15 | switch (data.type) { 16 | case 'cosmos-sdk/TextProposal': 17 | return TextProposal.fromAmino(data) 18 | case 'cosmos-sdk/ParameterChangeProposal': 19 | return ParameterChangeProposal.fromAmino(data) 20 | } 21 | } 22 | 23 | export function fromData(data: Content.Data): Content { 24 | switch (data['@type']) { 25 | case '/cosmos.gov.v1beta1.TextProposal': 26 | return TextProposal.fromData(data) 27 | case '/cosmos.params.v1beta1.ParameterChangeProposal': 28 | return ParameterChangeProposal.fromData(data) 29 | } 30 | } 31 | 32 | export function fromProto(anyProto: Any): Content { 33 | const typeUrl = anyProto.typeUrl 34 | switch (typeUrl) { 35 | case '/cosmos.gov.v1beta1.TextProposal': 36 | return TextProposal.unpackAny(anyProto) 37 | case '/cosmos.params.v1beta1.ParameterChangeProposal': 38 | return ParameterChangeProposal.unpackAny(anyProto) 39 | } 40 | 41 | throw new Error(`Proposal content ${typeUrl} not recognized`) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/core/consensus/ValidatorParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { ValidatorParams as ValidatorParams_pb } from '@initia/initia.proto/tendermint/types/params' 3 | 4 | /** 5 | * ValidatorParams defines the set of validator parameters. 6 | */ 7 | export class ValidatorParams extends JSONSerializable< 8 | ValidatorParams.Amino, 9 | ValidatorParams.Data, 10 | ValidatorParams.Proto 11 | > { 12 | /** 13 | * @param pub_key_types 14 | */ 15 | constructor(public pub_key_types: string[]) { 16 | super() 17 | } 18 | 19 | public static fromAmino(data: ValidatorParams.Amino): ValidatorParams { 20 | return new ValidatorParams(data.pub_key_types) 21 | } 22 | 23 | public toAmino(): ValidatorParams.Amino { 24 | return { 25 | pub_key_types: this.pub_key_types, 26 | } 27 | } 28 | 29 | public static fromData(data: ValidatorParams.Data): ValidatorParams { 30 | return new ValidatorParams(data.pub_key_types) 31 | } 32 | 33 | public toData(): ValidatorParams.Data { 34 | return { 35 | pub_key_types: this.pub_key_types, 36 | } 37 | } 38 | 39 | public static fromProto(data: ValidatorParams.Proto): ValidatorParams { 40 | return new ValidatorParams(data.pubKeyTypes) 41 | } 42 | 43 | public toProto(): ValidatorParams.Proto { 44 | return ValidatorParams_pb.fromPartial({ 45 | pubKeyTypes: this.pub_key_types, 46 | }) 47 | } 48 | } 49 | 50 | export namespace ValidatorParams { 51 | export interface Amino { 52 | pub_key_types: string[] 53 | } 54 | 55 | export interface Data { 56 | pub_key_types: string[] 57 | } 58 | 59 | export type Proto = ValidatorParams_pb 60 | } 61 | -------------------------------------------------------------------------------- /src/client/rest/api/AuthAPI.ts: -------------------------------------------------------------------------------- 1 | import { 2 | AccAddress, 3 | Account, 4 | ModuleAccount, 5 | BaseAccount, 6 | AuthParams, 7 | } from '../../../core' 8 | import { BaseAPI } from './BaseAPI' 9 | import { APIParams } from '../APIRequester' 10 | 11 | export class AuthAPI extends BaseAPI { 12 | /** 13 | * Query the account info. 14 | * @param address address of account to look up 15 | */ 16 | public async accountInfo( 17 | address: AccAddress, 18 | params: APIParams = {}, 19 | headers: Record = {} 20 | ): Promise { 21 | const { account } = await this.c.get<{ 22 | account: BaseAccount.Data | ModuleAccount.Data 23 | }>(`/cosmos/auth/v1beta1/accounts/${address}`, params, headers) 24 | return Account.fromData(account) 25 | } 26 | 27 | /** 28 | * Query the module account info. 29 | * @param address name of module account to look up 30 | */ 31 | public async moduleAccount( 32 | name: string, 33 | params: APIParams = {}, 34 | headers: Record = {} 35 | ): Promise { 36 | const { account } = await this.c.get<{ account: ModuleAccount.Data }>( 37 | `/cosmos/auth/v1beta1/module_accounts/${name}`, 38 | params, 39 | headers 40 | ) 41 | return ModuleAccount.fromData(account) 42 | } 43 | 44 | /** 45 | * Query the parameters of the auth module. 46 | */ 47 | public async parameters( 48 | params: APIParams = {}, 49 | headers: Record = {} 50 | ): Promise { 51 | return this.c 52 | .get<{ 53 | params: AuthParams.Data 54 | }>(`/cosmos/auth/v1beta1/params`, params, headers) 55 | .then((d) => AuthParams.fromData(d.params)) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/core/tokenfactory/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgCreateDenom } from './MsgCreateDenom' 2 | import { MsgMint } from './MsgMint' 3 | import { MsgBurn } from './MsgBurn' 4 | import { MsgChangeAdmin } from './MsgChangeAdmin' 5 | import { MsgSetDenomMetadataWasm } from './MsgSetDenomMetadataWasm' 6 | import { MsgSetBeforeSendHook } from './MsgSetBeforeSendHook' 7 | import { MsgUpdateTokenfactoryParams } from './MsgUpdateTokenfactoryParams' 8 | 9 | export * from './MsgCreateDenom' 10 | export * from './MsgMint' 11 | export * from './MsgBurn' 12 | export * from './MsgChangeAdmin' 13 | export * from './MsgSetDenomMetadataWasm' 14 | export * from './MsgSetBeforeSendHook' 15 | export * from './MsgUpdateTokenfactoryParams' 16 | 17 | export type TokenfactoryMsg = 18 | | MsgCreateDenom 19 | | MsgMint 20 | | MsgBurn 21 | | MsgChangeAdmin 22 | | MsgSetDenomMetadataWasm 23 | | MsgSetBeforeSendHook 24 | | MsgUpdateTokenfactoryParams 25 | 26 | export namespace TokenfactoryMsg { 27 | export type Amino = 28 | | MsgCreateDenom.Amino 29 | | MsgMint.Amino 30 | | MsgBurn.Amino 31 | | MsgChangeAdmin.Amino 32 | | MsgSetDenomMetadataWasm.Amino 33 | | MsgSetBeforeSendHook.Amino 34 | | MsgUpdateTokenfactoryParams.Amino 35 | 36 | export type Data = 37 | | MsgCreateDenom.Data 38 | | MsgMint.Data 39 | | MsgBurn.Data 40 | | MsgChangeAdmin.Data 41 | | MsgSetDenomMetadataWasm.Data 42 | | MsgSetBeforeSendHook.Data 43 | | MsgUpdateTokenfactoryParams.Data 44 | 45 | export type Proto = 46 | | MsgCreateDenom.Proto 47 | | MsgMint.Proto 48 | | MsgBurn.Proto 49 | | MsgChangeAdmin.Proto 50 | | MsgSetDenomMetadataWasm.Proto 51 | | MsgSetBeforeSendHook.Proto 52 | | MsgUpdateTokenfactoryParams.Proto 53 | } 54 | -------------------------------------------------------------------------------- /src/core/mstaking/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgDelegate } from './MsgDelegate' 2 | import { MsgUndelegate } from './MsgUndelegate' 3 | import { MsgBeginRedelegate } from './MsgBeginRedelegate' 4 | import { MsgCreateValidator } from './MsgCreateValidator' 5 | import { MsgEditValidator } from './MsgEditValidator' 6 | import { MsgCancelUnbondingDelegation } from './MsgCancelUnbondingDelegation' 7 | import { MsgUpdateMstakingParams } from './MsgUpdateMstakingParams' 8 | 9 | export * from './MsgDelegate' 10 | export * from './MsgUndelegate' 11 | export * from './MsgBeginRedelegate' 12 | export * from './MsgCreateValidator' 13 | export * from './MsgEditValidator' 14 | export * from './MsgCancelUnbondingDelegation' 15 | export * from './MsgUpdateMstakingParams' 16 | 17 | export type MstakingMsg = 18 | | MsgDelegate 19 | | MsgUndelegate 20 | | MsgBeginRedelegate 21 | | MsgCreateValidator 22 | | MsgEditValidator 23 | | MsgCancelUnbondingDelegation 24 | | MsgUpdateMstakingParams 25 | 26 | export namespace MstakingMsg { 27 | export type Amino = 28 | | MsgDelegate.Amino 29 | | MsgUndelegate.Amino 30 | | MsgBeginRedelegate.Amino 31 | | MsgCreateValidator.Amino 32 | | MsgEditValidator.Amino 33 | | MsgCancelUnbondingDelegation.Amino 34 | | MsgUpdateMstakingParams.Amino 35 | export type Data = 36 | | MsgDelegate.Data 37 | | MsgUndelegate.Data 38 | | MsgBeginRedelegate.Data 39 | | MsgCreateValidator.Data 40 | | MsgEditValidator.Data 41 | | MsgCancelUnbondingDelegation.Data 42 | | MsgUpdateMstakingParams.Data 43 | export type Proto = 44 | | MsgDelegate.Proto 45 | | MsgUndelegate.Proto 46 | | MsgBeginRedelegate.Proto 47 | | MsgCreateValidator.Proto 48 | | MsgEditValidator.Proto 49 | | MsgCancelUnbondingDelegation.Proto 50 | | MsgUpdateMstakingParams.Proto 51 | } 52 | -------------------------------------------------------------------------------- /src/core/consensus/ABCIParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { ABCIParams as ABCIParams_pb } from '@initia/initia.proto/tendermint/types/params' 3 | 4 | /** 5 | * ABCIParams defines the set of abci parameters. 6 | */ 7 | export class ABCIParams extends JSONSerializable< 8 | ABCIParams.Amino, 9 | ABCIParams.Data, 10 | ABCIParams.Proto 11 | > { 12 | /** 13 | * @param vote_extensions_enable_height 14 | */ 15 | constructor(public vote_extensions_enable_height: number) { 16 | super() 17 | } 18 | 19 | public static fromAmino(data: ABCIParams.Amino): ABCIParams { 20 | return new ABCIParams(parseInt(data.vote_extensions_enable_height)) 21 | } 22 | 23 | public toAmino(): ABCIParams.Amino { 24 | return { 25 | vote_extensions_enable_height: 26 | this.vote_extensions_enable_height.toFixed(), 27 | } 28 | } 29 | 30 | public static fromData(data: ABCIParams.Data): ABCIParams { 31 | return new ABCIParams(parseInt(data.vote_extensions_enable_height)) 32 | } 33 | 34 | public toData(): ABCIParams.Data { 35 | return { 36 | vote_extensions_enable_height: 37 | this.vote_extensions_enable_height.toFixed(), 38 | } 39 | } 40 | 41 | public static fromProto(data: ABCIParams.Proto): ABCIParams { 42 | return new ABCIParams(Number(data.voteExtensionsEnableHeight)) 43 | } 44 | 45 | public toProto(): ABCIParams.Proto { 46 | return ABCIParams_pb.fromPartial({ 47 | voteExtensionsEnableHeight: BigInt(this.vote_extensions_enable_height), 48 | }) 49 | } 50 | } 51 | 52 | export namespace ABCIParams { 53 | export interface Amino { 54 | vote_extensions_enable_height: string 55 | } 56 | 57 | export interface Data { 58 | vote_extensions_enable_height: string 59 | } 60 | 61 | export type Proto = ABCIParams_pb 62 | } 63 | -------------------------------------------------------------------------------- /src/core/bank/SendEnabled.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Denom } from '../Denom' 3 | import { SendEnabled as SendEnabled_pb } from '@initia/initia.proto/cosmos/bank/v1beta1/bank' 4 | 5 | /** 6 | * SendEnabled maps coin denom to a send_enabled status (whether a denom is sendable). 7 | */ 8 | export class SendEnabled extends JSONSerializable< 9 | SendEnabled.Amino, 10 | SendEnabled.Data, 11 | SendEnabled.Proto 12 | > { 13 | /** 14 | * @param denom 15 | * @param enabled 16 | */ 17 | constructor( 18 | public denom: Denom, 19 | public enabled: boolean 20 | ) { 21 | super() 22 | } 23 | 24 | public static fromAmino(data: SendEnabled.Amino): SendEnabled { 25 | const { denom, enabled } = data 26 | return new SendEnabled(denom, enabled) 27 | } 28 | 29 | public toAmino(): SendEnabled.Amino { 30 | const { denom, enabled } = this 31 | return { denom, enabled } 32 | } 33 | 34 | public static fromData(data: SendEnabled.Data): SendEnabled { 35 | const { denom, enabled } = data 36 | return new SendEnabled(denom, enabled) 37 | } 38 | 39 | public toData(): SendEnabled.Data { 40 | const { denom, enabled } = this 41 | return { denom, enabled } 42 | } 43 | 44 | public static fromProto(data: SendEnabled.Proto): SendEnabled { 45 | return new SendEnabled(data.denom, data.enabled) 46 | } 47 | 48 | public toProto(): SendEnabled.Proto { 49 | const { denom, enabled } = this 50 | return SendEnabled_pb.fromPartial({ 51 | denom, 52 | enabled, 53 | }) 54 | } 55 | } 56 | 57 | export namespace SendEnabled { 58 | export interface Amino { 59 | denom: Denom 60 | enabled: boolean 61 | } 62 | 63 | export interface Data { 64 | denom: Denom 65 | enabled: boolean 66 | } 67 | 68 | export type Proto = SendEnabled_pb 69 | } 70 | -------------------------------------------------------------------------------- /src/core/ibc/core/commitment/MerklePrefix.ts: -------------------------------------------------------------------------------- 1 | import { MerklePrefix as MerklePrefix_pb } from '@initia/initia.proto/ibc/core/commitment/v1/commitment' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * MerklePrefix is merkle path prefixed to the key. 6 | * The constructed key from the Path and the key will be append(Path.KeyPath, 7 | * append(Path.KeyPrefix, key...)) 8 | */ 9 | export class MerklePrefix extends JSONSerializable< 10 | MerklePrefix.Amino, 11 | MerklePrefix.Data, 12 | MerklePrefix.Proto 13 | > { 14 | /** 15 | * @param key_prefix 16 | */ 17 | constructor(public key_prefix: string) { 18 | super() 19 | } 20 | 21 | public static fromAmino(data: MerklePrefix.Amino): MerklePrefix { 22 | const { key_prefix } = data 23 | return new MerklePrefix(key_prefix) 24 | } 25 | 26 | public toAmino(): MerklePrefix.Amino { 27 | const { key_prefix } = this 28 | return { key_prefix } 29 | } 30 | 31 | public static fromData(data: MerklePrefix.Data): MerklePrefix { 32 | const { key_prefix } = data 33 | return new MerklePrefix(key_prefix) 34 | } 35 | 36 | public toData(): MerklePrefix.Data { 37 | const { key_prefix } = this 38 | return { key_prefix } 39 | } 40 | 41 | public static fromProto(proto: MerklePrefix.Proto): MerklePrefix { 42 | return new MerklePrefix(Buffer.from(proto.keyPrefix).toString('base64')) 43 | } 44 | 45 | public toProto(): MerklePrefix.Proto { 46 | const { key_prefix } = this 47 | return MerklePrefix_pb.fromPartial({ 48 | keyPrefix: Buffer.from(key_prefix, 'base64'), 49 | }) 50 | } 51 | } 52 | 53 | export namespace MerklePrefix { 54 | export interface Amino { 55 | key_prefix: string 56 | } 57 | 58 | export interface Data { 59 | key_prefix: string 60 | } 61 | 62 | export type Proto = MerklePrefix_pb 63 | } 64 | -------------------------------------------------------------------------------- /src/core/ibchooks/IbcHooksParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Params as Params_pb } from '@initia/initia.proto/initia/ibchooks/v1/types' 3 | 4 | /** 5 | * IbcHooksParams defines the set of ibc hooks parameters. 6 | */ 7 | export class IbcHooksParams extends JSONSerializable< 8 | IbcHooksParams.Amino, 9 | IbcHooksParams.Data, 10 | IbcHooksParams.Proto 11 | > { 12 | /** 13 | * @param default_allowed 14 | */ 15 | constructor(public default_allowed: boolean) { 16 | super() 17 | } 18 | 19 | public static fromAmino(data: IbcHooksParams.Amino): IbcHooksParams { 20 | return new IbcHooksParams(data.value.default_allowed) 21 | } 22 | 23 | public toAmino(): IbcHooksParams.Amino { 24 | return { 25 | type: 'ibchooks/Params', 26 | value: { default_allowed: this.default_allowed }, 27 | } 28 | } 29 | 30 | public static fromData(data: IbcHooksParams.Data): IbcHooksParams { 31 | return new IbcHooksParams(data.default_allowed) 32 | } 33 | 34 | public toData(): IbcHooksParams.Data { 35 | return { 36 | '@type': '/initia.ibchooks.v1.Params', 37 | default_allowed: this.default_allowed, 38 | } 39 | } 40 | 41 | public static fromProto(data: IbcHooksParams.Proto): IbcHooksParams { 42 | return new IbcHooksParams(data.defaultAllowed) 43 | } 44 | 45 | public toProto(): IbcHooksParams.Proto { 46 | return Params_pb.fromPartial({ 47 | defaultAllowed: this.default_allowed, 48 | }) 49 | } 50 | } 51 | 52 | export namespace IbcHooksParams { 53 | export interface Amino { 54 | type: 'ibchooks/Params' 55 | value: { 56 | default_allowed: boolean 57 | } 58 | } 59 | 60 | export interface Data { 61 | '@type': '/initia.ibchooks.v1.Params' 62 | default_allowed: boolean 63 | } 64 | 65 | export type Proto = Params_pb 66 | } 67 | -------------------------------------------------------------------------------- /src/core/ibc/core/client/IbcClientParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../../util/json' 2 | import { Params as Params_pb } from '@initia/initia.proto/ibc/core/client/v1/client' 3 | 4 | /** 5 | * IbcClientParams defines the set of ibc client parameters. 6 | */ 7 | export class IbcClientParams extends JSONSerializable< 8 | IbcClientParams.Amino, 9 | IbcClientParams.Data, 10 | IbcClientParams.Proto 11 | > { 12 | /** 13 | * @param allowed_clients the list of allowed client state types 14 | */ 15 | constructor(public allowed_clients: string[]) { 16 | super() 17 | } 18 | 19 | public static fromAmino(data: IbcClientParams.Amino): IbcClientParams { 20 | const { allowed_clients } = data 21 | return new IbcClientParams(allowed_clients) 22 | } 23 | 24 | public toAmino(): IbcClientParams.Amino { 25 | const { allowed_clients } = this 26 | return { 27 | allowed_clients, 28 | } 29 | } 30 | 31 | public static fromData(data: IbcClientParams.Data): IbcClientParams { 32 | const { allowed_clients } = data 33 | return new IbcClientParams(allowed_clients) 34 | } 35 | 36 | public toData(): IbcClientParams.Data { 37 | const { allowed_clients } = this 38 | return { 39 | allowed_clients, 40 | } 41 | } 42 | 43 | public static fromProto(proto: IbcClientParams.Proto): IbcClientParams { 44 | return new IbcClientParams(proto.allowedClients) 45 | } 46 | 47 | public toProto(): IbcClientParams.Proto { 48 | const { allowed_clients } = this 49 | return Params_pb.fromPartial({ 50 | allowedClients: allowed_clients, 51 | }) 52 | } 53 | } 54 | 55 | export namespace IbcClientParams { 56 | export interface Amino { 57 | allowed_clients: string[] 58 | } 59 | 60 | export interface Data { 61 | allowed_clients: string[] 62 | } 63 | 64 | export type Proto = Params_pb 65 | } 66 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, 4 | # surfacing known-vulnerable versions of the packages declared or updated in the PR. 5 | # Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable 6 | # packages will be blocked from merging. 7 | # 8 | # Source repository: https://github.com/actions/dependency-review-action 9 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement 10 | name: 'Dependency review' 11 | on: 12 | pull_request: 13 | branches: [ "main" ] 14 | 15 | # If using a dependency submission action in this workflow this permission will need to be set to: 16 | # 17 | # permissions: 18 | # contents: write 19 | # 20 | # https://docs.github.com/en/enterprise-cloud@latest/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api 21 | permissions: 22 | contents: read 23 | # Write permissions for pull-requests are required for using the `comment-summary-in-pr` option, comment out if you aren't using this option 24 | pull-requests: write 25 | 26 | jobs: 27 | dependency-review: 28 | runs-on: ubuntu-latest 29 | steps: 30 | - name: 'Checkout repository' 31 | uses: actions/checkout@v4 32 | - name: 'Dependency Review' 33 | uses: actions/dependency-review-action@v4 34 | # Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options. 35 | with: 36 | comment-summary-in-pr: always 37 | fail-on-severity: moderate 38 | deny-licenses: GPL-1.0-or-later, LGPL-2.0-or-later 39 | retry-on-snapshot-warnings: true 40 | -------------------------------------------------------------------------------- /src/core/oracle/CurrencyPair.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { CurrencyPair as CurrencyPair_pb } from '@initia/initia.proto/connect/types/v2/currency_pair' 3 | 4 | /** 5 | * CurrencyPair is the standard representation of a pair of assets, where one 6 | * (Base) is priced in terms of the other (Quote). 7 | */ 8 | export class CurrencyPair extends JSONSerializable< 9 | CurrencyPair.Amino, 10 | CurrencyPair.Data, 11 | CurrencyPair.Proto 12 | > { 13 | /** 14 | * @param Base 15 | * @param Quote 16 | */ 17 | constructor( 18 | public Base: string, 19 | public Quote: string 20 | ) { 21 | super() 22 | } 23 | 24 | public toString(): string { 25 | return `${this.Base}/${this.Quote}` 26 | } 27 | 28 | public static fromAmino(data: CurrencyPair.Amino): CurrencyPair { 29 | return new CurrencyPair(data.Base, data.Quote) 30 | } 31 | 32 | public toAmino(): CurrencyPair.Amino { 33 | return { 34 | Base: this.Base, 35 | Quote: this.Quote, 36 | } 37 | } 38 | 39 | public static fromData(data: CurrencyPair.Data): CurrencyPair { 40 | return new CurrencyPair(data.Base, data.Quote) 41 | } 42 | 43 | public toData(): CurrencyPair.Data { 44 | return { 45 | Base: this.Base, 46 | Quote: this.Quote, 47 | } 48 | } 49 | 50 | public static fromProto(proto: CurrencyPair.Proto): CurrencyPair { 51 | return new CurrencyPair(proto.Base, proto.Quote) 52 | } 53 | 54 | public toProto(): CurrencyPair.Proto { 55 | return CurrencyPair_pb.fromPartial({ 56 | Base: this.Base, 57 | Quote: this.Quote, 58 | }) 59 | } 60 | } 61 | 62 | export namespace CurrencyPair { 63 | export interface Amino { 64 | Base: string 65 | Quote: string 66 | } 67 | 68 | export interface Data { 69 | Base: string 70 | Quote: string 71 | } 72 | 73 | export type Proto = CurrencyPair_pb 74 | } 75 | -------------------------------------------------------------------------------- /src/core/distribution/RewardWeight.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Denom } from '../Denom' 3 | import { RewardWeight as RewardWeight_pb } from '@initia/initia.proto/initia/distribution/v1/distribution' 4 | 5 | /** 6 | * RewardWeight represents reward allocation ratio between pools. 7 | */ 8 | export class RewardWeight extends JSONSerializable< 9 | RewardWeight.Amino, 10 | RewardWeight.Data, 11 | RewardWeight.Proto 12 | > { 13 | /** 14 | * @param denom 15 | * @param weight 16 | */ 17 | constructor( 18 | public denom: Denom, 19 | public weight: string 20 | ) { 21 | super() 22 | } 23 | 24 | public static fromAmino(data: RewardWeight.Amino): RewardWeight { 25 | const { denom, weight } = data 26 | return new RewardWeight(denom, weight) 27 | } 28 | 29 | public toAmino(): RewardWeight.Amino { 30 | const { denom, weight } = this 31 | return { 32 | denom, 33 | weight, 34 | } 35 | } 36 | 37 | public static fromData(data: RewardWeight.Data): RewardWeight { 38 | const { denom, weight } = data 39 | return new RewardWeight(denom, weight) 40 | } 41 | 42 | public toData(): RewardWeight.Data { 43 | const { denom, weight } = this 44 | return { 45 | denom, 46 | weight, 47 | } 48 | } 49 | 50 | public static fromProto(data: RewardWeight.Proto): RewardWeight { 51 | return new RewardWeight(data.denom, data.weight) 52 | } 53 | 54 | public toProto(): RewardWeight.Proto { 55 | const { denom, weight } = this 56 | return RewardWeight_pb.fromPartial({ 57 | denom, 58 | weight, 59 | }) 60 | } 61 | } 62 | 63 | export namespace RewardWeight { 64 | export interface Amino { 65 | denom: Denom 66 | weight: string 67 | } 68 | 69 | export interface Data { 70 | denom: Denom 71 | weight: string 72 | } 73 | 74 | export type Proto = RewardWeight_pb 75 | } 76 | -------------------------------------------------------------------------------- /src/core/ibc/applications/interchain-account/controller/Params.ts: -------------------------------------------------------------------------------- 1 | import { Params as Params_pb } from '@initia/initia.proto/ibc/applications/interchain_accounts/controller/v1/controller' 2 | import { JSONSerializable } from '../../../../../util/json' 3 | 4 | /** 5 | * Params defines the set of on-chain interchain accounts parameters. 6 | * The following parameters may be used to disable the controller submodule. 7 | */ 8 | export class Params extends JSONSerializable< 9 | Params.Amino, 10 | Params.Data, 11 | Params.Proto 12 | > { 13 | /** 14 | * @param controller_enabled controller_enabled enables or disables the controller submodule 15 | */ 16 | constructor(public controller_enabled: boolean) { 17 | super() 18 | } 19 | 20 | public static fromAmino(data: Params.Amino): Params { 21 | const { controller_enabled } = data 22 | return new Params(controller_enabled) 23 | } 24 | 25 | public toAmino(): Params.Amino { 26 | const { controller_enabled } = this 27 | return { 28 | controller_enabled, 29 | } 30 | } 31 | 32 | public static fromData(data: Params.Data): Params { 33 | const { controller_enabled } = data 34 | return new Params(controller_enabled) 35 | } 36 | 37 | public toData(): Params.Data { 38 | const { controller_enabled } = this 39 | return { 40 | controller_enabled, 41 | } 42 | } 43 | 44 | public static fromProto(proto: Params.Proto): Params { 45 | return new Params(proto.controllerEnabled) 46 | } 47 | 48 | public toProto(): Params.Proto { 49 | const { controller_enabled } = this 50 | return Params_pb.fromPartial({ 51 | controllerEnabled: controller_enabled, 52 | }) 53 | } 54 | } 55 | 56 | export namespace Params { 57 | export interface Amino { 58 | controller_enabled: boolean 59 | } 60 | 61 | export interface Data { 62 | controller_enabled: boolean 63 | } 64 | 65 | export type Proto = Params_pb 66 | } 67 | -------------------------------------------------------------------------------- /src/core/ibc/core/channel/IbcChannelParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../../util/json' 2 | import { Params as Params_pb } from '@initia/initia.proto/ibc/core/channel/v1/channel' 3 | import { Timeout } from './Timeout' 4 | 5 | /** 6 | * IbcChannelParams defines the set of ibc channel parameters. 7 | */ 8 | export class IbcChannelParams extends JSONSerializable< 9 | IbcChannelParams.Amino, 10 | IbcChannelParams.Data, 11 | IbcChannelParams.Proto 12 | > { 13 | /** 14 | * @param upgrade_timeout the relative timeout after which channel upgrades will time out 15 | */ 16 | constructor(public upgrade_timeout: Timeout) { 17 | super() 18 | } 19 | 20 | public static fromAmino(data: IbcChannelParams.Amino): IbcChannelParams { 21 | return new IbcChannelParams(Timeout.fromAmino(data.upgrade_timeout)) 22 | } 23 | 24 | public toAmino(): IbcChannelParams.Amino { 25 | return { 26 | upgrade_timeout: this.upgrade_timeout.toAmino(), 27 | } 28 | } 29 | 30 | public static fromData(data: IbcChannelParams.Data): IbcChannelParams { 31 | return new IbcChannelParams(Timeout.fromData(data.upgrade_timeout)) 32 | } 33 | 34 | public toData(): IbcChannelParams.Data { 35 | return { 36 | upgrade_timeout: this.upgrade_timeout.toData(), 37 | } 38 | } 39 | 40 | public static fromProto(data: IbcChannelParams.Proto): IbcChannelParams { 41 | return new IbcChannelParams( 42 | Timeout.fromProto(data.upgradeTimeout as Timeout.Proto) 43 | ) 44 | } 45 | 46 | public toProto(): IbcChannelParams.Proto { 47 | return Params_pb.fromPartial({ 48 | upgradeTimeout: this.upgrade_timeout.toProto(), 49 | }) 50 | } 51 | } 52 | 53 | export namespace IbcChannelParams { 54 | export interface Amino { 55 | upgrade_timeout: Timeout.Amino 56 | } 57 | 58 | export interface Data { 59 | upgrade_timeout: Timeout.Data 60 | } 61 | 62 | export type Proto = Params_pb 63 | } 64 | -------------------------------------------------------------------------------- /src/core/auth/BaseAccount.data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "cosmos-sdk/BaseAccount", 4 | "value": { 5 | "address": "init1h0d5kq5p64jcyqysvja3h2gysxnfudk9h73fnn", 6 | "public_key": { 7 | "type": "tendermint/PubKeySecp256k1", 8 | "value": "Av0uQ9R72aq0dgu1H+F1+1p2daQLl0JsWhwkA07ftTq/" 9 | }, 10 | "account_number": "572696", 11 | "sequence": "251409" 12 | } 13 | }, 14 | { 15 | "type": "cosmos-sdk/BaseAccount", 16 | "value": { 17 | "address": "init1fex9f78reuwhfsnc8sun6mz8rl9zwqh03fhwf3", 18 | "public_key": { 19 | "type": "tendermint/PubKeySecp256k1", 20 | "value": "AxYEJ7m2BMIzrugTG5Rl8Pz2RNU6eGfnsn2TfMXWEruf" 21 | }, 22 | "account_number": "238665", 23 | "sequence": "1650113" 24 | } 25 | }, 26 | { 27 | "type": "cosmos-sdk/BaseAccount", 28 | "value": { 29 | "address": "init12fm3tql2uu0gheuj3st9cwz7ml97tq9mla88c2", 30 | "public_key": { 31 | "type": "tendermint/PubKeySecp256k1", 32 | "value": "AvBeqhogW0wd7OtF8M8hJ/P1A/IBY1+uNvBO/tbVlfq2" 33 | }, 34 | "account_number": "251248", 35 | "sequence": "58" 36 | } 37 | }, 38 | { 39 | "type": "cosmos-sdk/BaseAccount", 40 | "value": { 41 | "address": "init1kcc65k0ru6qq946ztqljxd67d5wltqstln5d5k", 42 | "public_key": { 43 | "type": "tendermint/PubKeySecp256k1", 44 | "value": "AsPdLO1QwuajkAP/MlVe17WwTimT7gUAE2iXDjaScrxH" 45 | }, 46 | "account_number": "987828", 47 | "sequence": "28" 48 | } 49 | }, 50 | { 51 | "type": "cosmos-sdk/BaseAccount", 52 | "value": { 53 | "address": "init1ax7xtll5v6u6vdnymxa4k4648w80zhkggl0u24", 54 | "public_key": { 55 | "type": "tendermint/PubKeySecp256k1", 56 | "value": "A/vzuSK9wCAvmFXorv/KTbUFsF9Av5r9XuplqF+4OLfR" 57 | }, 58 | "account_number": "712869", 59 | "sequence": "65" 60 | } 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /src/client/rest/api/TendermintAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { TendermintAPI } from './TendermintAPI' 4 | import { Tx } from '../../../core' 5 | import { Tx as Tx_pb } from '@initia/initia.proto/cosmos/tx/v1beta1/tx' 6 | 7 | const c = new APIRequester('https://rest.testnet.initia.xyz') 8 | const api = new TendermintAPI(c) 9 | 10 | describe('TendermintAPI', () => { 11 | it('load block and decode txs', async () => { 12 | const blockInfo = await api.blockInfo(1) 13 | if (blockInfo.block.data.txs != null) { 14 | blockInfo.block.data.txs.every((txBytes) => { 15 | const txProto = Tx_pb.decode(Buffer.from(txBytes, 'base64')) 16 | expect(Tx.fromProto(txProto)).toBeDefined() 17 | }) 18 | } 19 | }) 20 | 21 | it('node info', async () => { 22 | await expect(api.nodeInfo()).resolves.toBeInstanceOf(Object) 23 | }) 24 | 25 | it('validator set (latest)', async () => { 26 | const vals = await api.validatorSet() 27 | 28 | expect(vals[0]).toContainEqual({ 29 | address: expect.any(String), 30 | pub_key: { 31 | '@type': expect.any(String), 32 | key: expect.any(String), 33 | }, 34 | proposer_priority: expect.any(String), 35 | voting_power: expect.any(String), 36 | }) 37 | }) 38 | 39 | it('validator set (1)', async () => { 40 | const vals = await api.validatorSet(1) 41 | 42 | expect(vals[0]).toContainEqual({ 43 | address: expect.any(String), 44 | pub_key: { 45 | '@type': expect.any(String), 46 | key: expect.any(String), 47 | }, 48 | proposer_priority: expect.any(String), 49 | voting_power: expect.any(String), 50 | }) 51 | }) 52 | 53 | it('block info', async () => { 54 | const block = await api.blockInfo() 55 | 56 | expect(block).toMatchObject({ 57 | block: expect.any(Object), 58 | }) 59 | }) 60 | }) 61 | -------------------------------------------------------------------------------- /src/client/rest/api/SlashingAPI.ts: -------------------------------------------------------------------------------- 1 | import { BaseAPI } from './BaseAPI' 2 | import { 3 | ValConsAddress, 4 | SlashingParams, 5 | ValidatorSigningInfo, 6 | } from '../../../core' 7 | import { APIParams, Pagination, PaginationOptions } from '../APIRequester' 8 | 9 | export class SlashingAPI extends BaseAPI { 10 | /** 11 | * Query the signing infos of all validators. 12 | */ 13 | public async signingInfos( 14 | params: Partial = {}, 15 | headers: Record = {} 16 | ): Promise<[ValidatorSigningInfo[], Pagination]> { 17 | return this.c 18 | .get<{ 19 | info: ValidatorSigningInfo.Data[] 20 | pagination: Pagination 21 | }>(`/cosmos/slashing/v1beta1/signing_infos`, params, headers) 22 | .then((d) => [d.info.map(ValidatorSigningInfo.fromData), d.pagination]) 23 | } 24 | 25 | /** 26 | * Query the signing info of given cons address. 27 | * @param val_cons_address the address to query signing info of 28 | */ 29 | public async signingInfo( 30 | val_cons_address: ValConsAddress, 31 | params: APIParams = {}, 32 | headers: Record = {} 33 | ): Promise { 34 | return this.c 35 | .get<{ 36 | val_signing_info: ValidatorSigningInfo.Data 37 | }>( 38 | `/cosmos/slashing/v1beta1/signing_infos/${val_cons_address}`, 39 | params, 40 | headers 41 | ) 42 | .then((d) => ValidatorSigningInfo.fromData(d.val_signing_info)) 43 | } 44 | 45 | /** 46 | * Query the parameters of the slashing module. 47 | */ 48 | public async parameters( 49 | params: APIParams = {}, 50 | headers: Record = {} 51 | ): Promise { 52 | return this.c 53 | .get<{ 54 | params: SlashingParams.Data 55 | }>(`/cosmos/slashing/v1beta1/params`, params, headers) 56 | .then((d) => SlashingParams.fromData(d.params)) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/core/group/policies/index.ts: -------------------------------------------------------------------------------- 1 | import { ThresholdDecisionPolicy } from './ThresholdDecisionPolicy' 2 | import { PercentageDecisionPolicy } from './PercentageDecisionPolicy' 3 | import { Any } from '@initia/initia.proto/google/protobuf/any' 4 | 5 | export * from './ThresholdDecisionPolicy' 6 | export * from './PercentageDecisionPolicy' 7 | export * from './DecisionPolicyWindows' 8 | 9 | export type DecisionPolicy = ThresholdDecisionPolicy | PercentageDecisionPolicy 10 | export namespace DecisionPolicy { 11 | export type Amino = 12 | | ThresholdDecisionPolicy.Amino 13 | | PercentageDecisionPolicy.Amino 14 | export type Data = 15 | | ThresholdDecisionPolicy.Data 16 | | PercentageDecisionPolicy.Data 17 | export type Proto = Any 18 | 19 | export function fromAmino(data: DecisionPolicy.Amino): DecisionPolicy { 20 | switch (data.type) { 21 | case 'cosmos-sdk/ThresholdDecisionPolicy': 22 | return ThresholdDecisionPolicy.fromAmino(data) 23 | case 'cosmos-sdk/PercentageDecisionPolicy': 24 | return PercentageDecisionPolicy.fromAmino(data) 25 | } 26 | } 27 | 28 | export function fromData(data: DecisionPolicy.Data): DecisionPolicy { 29 | switch (data['@type']) { 30 | case '/cosmos.group.v1.ThresholdDecisionPolicy': 31 | return ThresholdDecisionPolicy.fromData(data) 32 | case '/cosmos.group.v1.PercentageDecisionPolicy': 33 | return PercentageDecisionPolicy.fromData(data) 34 | } 35 | } 36 | 37 | export function fromProto(proto: DecisionPolicy.Proto): DecisionPolicy { 38 | const typeUrl = proto.typeUrl 39 | switch (typeUrl) { 40 | case '/cosmos.group.v1.ThresholdDecisionPolicy': 41 | return ThresholdDecisionPolicy.unpackAny(proto) 42 | case '/cosmos.group.v1.PercentageDecisionPolicy': 43 | return PercentageDecisionPolicy.unpackAny(proto) 44 | } 45 | 46 | throw new Error(`DecisionPolicy type ${typeUrl} not recognized`) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/core/ibc/applications/transfer/DenomTrace.ts: -------------------------------------------------------------------------------- 1 | import { DenomTrace as DenomTrace_pb } from '@initia/initia.proto/ibc/applications/transfer/v1/transfer' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * DenomTrace contains the base denomination for ICS20 fungible tokens and the 6 | * source tracing information path. 7 | */ 8 | export class DenomTrace extends JSONSerializable< 9 | DenomTrace.Amino, 10 | DenomTrace.Data, 11 | DenomTrace.Proto 12 | > { 13 | /** 14 | * @param path the revision that the client is currently on 15 | * @param base_denom the height within the given revision 16 | */ 17 | constructor( 18 | public path: string, 19 | public base_denom: string 20 | ) { 21 | super() 22 | } 23 | 24 | public static fromAmino(data: DenomTrace.Amino): DenomTrace { 25 | const { path, base_denom } = data 26 | return new DenomTrace(path, base_denom) 27 | } 28 | 29 | public toAmino(): DenomTrace.Amino { 30 | const { path, base_denom } = this 31 | return { 32 | path, 33 | base_denom, 34 | } 35 | } 36 | 37 | public static fromData(data: DenomTrace.Data): DenomTrace { 38 | const { path, base_denom } = data 39 | return new DenomTrace(path, base_denom) 40 | } 41 | 42 | public toData(): DenomTrace.Data { 43 | const { path, base_denom } = this 44 | return { 45 | path, 46 | base_denom, 47 | } 48 | } 49 | 50 | public static fromProto(proto: DenomTrace.Proto): DenomTrace { 51 | return new DenomTrace(proto.path, proto.baseDenom) 52 | } 53 | 54 | public toProto(): DenomTrace.Proto { 55 | const { path, base_denom } = this 56 | return DenomTrace_pb.fromPartial({ path, baseDenom: base_denom }) 57 | } 58 | } 59 | 60 | export namespace DenomTrace { 61 | export interface Amino { 62 | path: string 63 | base_denom: string 64 | } 65 | 66 | export interface Data { 67 | path: string 68 | base_denom: string 69 | } 70 | 71 | export type Proto = DenomTrace_pb 72 | } 73 | -------------------------------------------------------------------------------- /src/core/ibc/core/connection/IbcVersion.ts: -------------------------------------------------------------------------------- 1 | import { Version as Version_pb } from '@initia/initia.proto/ibc/core/connection/v1/connection' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * IbcVersion defines the versioning scheme used to negotiate the IBC version in the connection handshake. 6 | */ 7 | export class IbcVersion extends JSONSerializable< 8 | IbcVersion.Amino, 9 | IbcVersion.Data, 10 | IbcVersion.Proto 11 | > { 12 | /** 13 | * @param identifier unique version identifier 14 | * @param features list of features compatible with the specified identifier 15 | */ 16 | constructor( 17 | public identifier: string, 18 | public features: string[] 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino(data: IbcVersion.Amino): IbcVersion { 24 | const { identifier, features } = data 25 | return new IbcVersion(identifier, features) 26 | } 27 | 28 | public toAmino(): IbcVersion.Amino { 29 | const { identifier, features } = this 30 | return { 31 | identifier, 32 | features, 33 | } 34 | } 35 | 36 | public static fromData(data: IbcVersion.Data): IbcVersion { 37 | const { identifier, features } = data 38 | return new IbcVersion(identifier, features) 39 | } 40 | 41 | public toData(): IbcVersion.Data { 42 | const { identifier, features } = this 43 | return { 44 | identifier, 45 | features, 46 | } 47 | } 48 | 49 | public static fromProto(proto: IbcVersion.Proto): IbcVersion { 50 | return new IbcVersion(proto.identifier, proto.features) 51 | } 52 | 53 | public toProto(): IbcVersion.Proto { 54 | const { identifier, features } = this 55 | return Version_pb.fromPartial({ identifier, features }) 56 | } 57 | } 58 | 59 | export namespace IbcVersion { 60 | export interface Amino { 61 | identifier: string 62 | features: string[] 63 | } 64 | 65 | export interface Data { 66 | identifier: string 67 | features: string[] 68 | } 69 | 70 | export type Proto = Version_pb 71 | } 72 | -------------------------------------------------------------------------------- /src/client/rest/api/UpgradeAPI.ts: -------------------------------------------------------------------------------- 1 | import { BaseAPI } from './BaseAPI' 2 | import { Plan } from '../../../core' 3 | import { APIParams, PaginationOptions } from '../APIRequester' 4 | 5 | export interface ModuleVersion { 6 | name: string 7 | version: number 8 | } 9 | 10 | export namespace ModuleVersion { 11 | export interface Data { 12 | name: string 13 | version: string 14 | } 15 | } 16 | 17 | export class UpgradeAPI extends BaseAPI { 18 | /** 19 | * Query a previously applied upgrade plan by its name. 20 | * It returns the height of the plan. If there's no plan with given name, it returns 0. 21 | * @param name the name of the applied plan to query for 22 | */ 23 | public async appliedPlan( 24 | name: string, 25 | params: Partial = {}, 26 | headers: Record = {} 27 | ): Promise { 28 | return this.c 29 | .get<{ 30 | height: string 31 | }>(`/cosmos/upgrade/v1beta1/applied_plan/${name}`, params, headers) 32 | .then((d) => parseInt(d.height)) 33 | } 34 | 35 | /** 36 | * Query the current plan. 37 | */ 38 | public async currentPlan( 39 | params: APIParams = {}, 40 | headers: Record = {} 41 | ): Promise { 42 | return this.c 43 | .get<{ 44 | plan?: Plan.Data 45 | }>(`/cosmos/upgrade/v1beta1/current_plan`, params, headers) 46 | .then((d) => (d.plan ? Plan.fromData(d.plan) : undefined)) 47 | } 48 | 49 | /** 50 | * Query the versions of the modules. 51 | */ 52 | public async moduleVersions( 53 | params: APIParams = {}, 54 | headers: Record = {} 55 | ): Promise { 56 | return this.c 57 | .get<{ 58 | module_versions: ModuleVersion.Data[] 59 | }>(`/cosmos/upgrade/v1beta1/module_versions`, params, headers) 60 | .then((d) => 61 | d.module_versions.map((mv) => { 62 | return { name: mv.name, version: parseInt(mv.version) } 63 | }) 64 | ) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/core/wasm/authorizations/ContractLimit.ts: -------------------------------------------------------------------------------- 1 | import { MaxCallsLimit } from './MaxCallsLimit' 2 | import { MaxFundsLimit } from './MaxFundsLimit' 3 | import { CombinedLimit } from './CombinedLimit' 4 | import { Any } from '@initia/initia.proto/google/protobuf/any' 5 | 6 | export type ContractLimit = MaxCallsLimit | MaxFundsLimit | CombinedLimit 7 | 8 | export namespace ContractLimit { 9 | export type Amino = 10 | | MaxCallsLimit.Amino 11 | | MaxFundsLimit.Amino 12 | | CombinedLimit.Amino 13 | export type Data = 14 | | MaxCallsLimit.Data 15 | | MaxFundsLimit.Data 16 | | CombinedLimit.Data 17 | export type Proto = 18 | | MaxCallsLimit.Proto 19 | | MaxFundsLimit.Proto 20 | | CombinedLimit.Proto 21 | 22 | export function fromAmino(data: ContractLimit.Amino): ContractLimit { 23 | switch (data.type) { 24 | case 'wasm/MaxCallsLimit': 25 | return MaxCallsLimit.fromAmino(data) 26 | case 'wasm/MaxFundsLimit': 27 | return MaxFundsLimit.fromAmino(data) 28 | case 'wasm/CombinedLimit': 29 | return CombinedLimit.fromAmino(data) 30 | } 31 | } 32 | 33 | export function fromData(data: ContractLimit.Data): ContractLimit { 34 | switch (data['@type']) { 35 | case '/cosmwasm.wasm.v1.MaxCallsLimit': 36 | return MaxCallsLimit.fromData(data) 37 | case '/cosmwasm.wasm.v1.MaxFundsLimit': 38 | return MaxFundsLimit.fromData(data) 39 | case '/cosmwasm.wasm.v1.CombinedLimit': 40 | return CombinedLimit.fromData(data) 41 | } 42 | } 43 | 44 | export function fromProto(proto: Any): ContractLimit { 45 | const typeUrl = proto.typeUrl 46 | switch (typeUrl) { 47 | case '/cosmwasm.wasm.v1.MaxCallsLimit': 48 | return MaxCallsLimit.unpackAny(proto) 49 | case '/cosmwasm.wasm.v1.MaxFundsLimit': 50 | return MaxFundsLimit.unpackAny(proto) 51 | case '/cosmwasm.wasm.v1.CombinedLimit': 52 | return CombinedLimit.unpackAny(proto) 53 | } 54 | 55 | throw new Error(`ContractLimit type ${typeUrl} not recognized`) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/core/upgrade/Plan.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Plan as Plan_pb } from '@initia/initia.proto/cosmos/upgrade/v1beta1/upgrade' 3 | 4 | /** 5 | * Plan specifies information about a planned upgrade and when it should occur. 6 | */ 7 | export class Plan extends JSONSerializable { 8 | /** 9 | * @param name the name for the upgrade 10 | * @param height the height at which the upgrade must be performed 11 | * @param info any application specific upgrade info to be included on-chain 12 | */ 13 | constructor( 14 | public name: string, 15 | public height: number, 16 | public info: string 17 | ) { 18 | super() 19 | } 20 | 21 | public static fromAmino(data: Plan.Amino): Plan { 22 | const { name, height, info } = data 23 | return new Plan(name, parseInt(height), info) 24 | } 25 | 26 | public toAmino(): Plan.Amino { 27 | const { name, height, info } = this 28 | return { 29 | name, 30 | height: height.toFixed(), 31 | info, 32 | } 33 | } 34 | 35 | public static fromData(data: Plan.Data): Plan { 36 | const { name, height, info } = data 37 | return new Plan(name, parseInt(height), info) 38 | } 39 | 40 | public toData(): Plan.Data { 41 | const { name, height, info } = this 42 | return { 43 | name, 44 | height: height.toFixed(), 45 | info, 46 | } 47 | } 48 | 49 | public static fromProto(proto: Plan.Proto): Plan { 50 | return new Plan(proto.name, Number(proto.height), proto.info) 51 | } 52 | 53 | public toProto(): Plan.Proto { 54 | const { name, height, info } = this 55 | return Plan_pb.fromPartial({ 56 | name, 57 | height: BigInt(height), 58 | info, 59 | }) 60 | } 61 | } 62 | 63 | export namespace Plan { 64 | export interface Amino { 65 | name: string 66 | height: string 67 | info: string 68 | } 69 | 70 | export interface Data { 71 | name: string 72 | height: string 73 | info: string 74 | } 75 | 76 | export type Proto = Plan_pb 77 | } 78 | -------------------------------------------------------------------------------- /src/core/evm/AccessTuple.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { AccAddress } from '../bech32' 3 | import { AccessTuple as AccessTuple_pb } from '@initia/initia.proto/minievm/evm/v1/types' 4 | 5 | /** 6 | * AccessTuple is the tuple for address and storage keys. 7 | */ 8 | export class AccessTuple extends JSONSerializable< 9 | AccessTuple.Amino, 10 | AccessTuple.Data, 11 | AccessTuple.Proto 12 | > { 13 | /** 14 | * @param address address of the contract that will be accessed during the transaction execution 15 | * @param storage_keys list of storage keys that the transaction will interact with within the specified contract 16 | */ 17 | constructor( 18 | public address: AccAddress, 19 | public storage_keys: string[] 20 | ) { 21 | super() 22 | } 23 | 24 | public static fromAmino(data: AccessTuple.Amino): AccessTuple { 25 | const { address, storage_keys } = data 26 | return new AccessTuple(address, storage_keys) 27 | } 28 | 29 | public toAmino(): AccessTuple.Amino { 30 | const { address, storage_keys } = this 31 | return { address, storage_keys } 32 | } 33 | 34 | public static fromData(data: AccessTuple.Data): AccessTuple { 35 | const { address, storage_keys } = data 36 | return new AccessTuple(address, storage_keys) 37 | } 38 | 39 | public toData(): AccessTuple.Data { 40 | const { address, storage_keys } = this 41 | return { address, storage_keys } 42 | } 43 | 44 | public static fromProto(data: AccessTuple.Proto): AccessTuple { 45 | return new AccessTuple(data.address, data.storageKeys) 46 | } 47 | 48 | public toProto(): AccessTuple.Proto { 49 | const { address, storage_keys } = this 50 | return AccessTuple_pb.fromPartial({ 51 | address, 52 | storageKeys: storage_keys, 53 | }) 54 | } 55 | } 56 | 57 | export namespace AccessTuple { 58 | export interface Amino { 59 | address: AccAddress 60 | storage_keys: string[] 61 | } 62 | 63 | export interface Data { 64 | address: AccAddress 65 | storage_keys: string[] 66 | } 67 | 68 | export type Proto = AccessTuple_pb 69 | } 70 | -------------------------------------------------------------------------------- /src/core/tx/SignatureV2.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { CompactBitArray } from './CompactBitArray' 3 | import { SimplePublicKey } from '../PublicKey' 4 | import { SignatureV2 } from './SignatureV2' 5 | 6 | describe('SignatureV2', () => { 7 | it('conversion: single sign', () => { 8 | const sequence = 1234 9 | //const data = new SignatureV2.Descriptor( 10 | const signMode = SignatureV2.SignMode.SIGN_MODE_DIRECT 11 | const signature = 'fakesignature' 12 | 13 | const sigv2 = new SignatureV2( 14 | new SimplePublicKey('A/PwvW/JLEnhb0/o5g+AnOqMN+FFT24gjJfDtA1tBsBv'), 15 | new SignatureV2.Descriptor( 16 | new SignatureV2.Descriptor.Single(signMode, signature) 17 | ), 18 | sequence 19 | ) 20 | 21 | const toData = sigv2.toData() 22 | const fromData = SignatureV2.fromData(toData) 23 | const toData2 = fromData.toData() 24 | 25 | expect(toData.public_key).toEqual(toData2.public_key) 26 | expect(toData.sequence).toEqual(toData2.sequence) 27 | expect(toData.data).toEqual(toData2.data) 28 | }) 29 | 30 | it('conversion: multi sign', () => { 31 | const sequence = 1234 32 | //const data = new SignatureV2.Descriptor( 33 | const signMode = SignatureV2.SignMode.SIGN_MODE_LEGACY_AMINO_JSON 34 | const signature = 'fakesignature' 35 | const single = new SignatureV2.Descriptor( 36 | new SignatureV2.Descriptor.Single(signMode, signature) 37 | ) 38 | 39 | const sigv2 = new SignatureV2( 40 | new SimplePublicKey('A/PwvW/JLEnhb0/o5g+AnOqMN+FFT24gjJfDtA1tBsBv'), 41 | new SignatureV2.Descriptor( 42 | new SignatureV2.Descriptor.Multi(CompactBitArray.fromBits(2), [ 43 | single, 44 | single, 45 | ]) 46 | ), 47 | sequence 48 | ) 49 | 50 | const toData = sigv2.toData() 51 | const fromData = SignatureV2.fromData(toData) 52 | const toData2 = fromData.toData() 53 | 54 | expect(toData.public_key).toEqual(toData2.public_key) 55 | expect(toData.sequence).toEqual(toData2.sequence) 56 | expect(toData.data).toEqual(toData2.data) 57 | }) 58 | }) 59 | -------------------------------------------------------------------------------- /src/core/distribution/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgSetWithdrawAddress } from './MsgSetWithdrawAddress' 2 | import { MsgWithdrawDelegatorReward } from './MsgWithdrawDelegatorReward' 3 | import { MsgWithdrawValidatorCommission } from './MsgWithdrawValidatorCommission' 4 | import { MsgFundCommunityPool } from './MsgFundCommunityPool' 5 | import { MsgUpdateDistrParams } from './MsgUpdateDistrParams' 6 | import { MsgCommunityPoolSpend } from './MsgCommunityPoolSpend' 7 | import { MsgDepositValidatorRewardsPool } from './MsgDepositValidatorRewardsPool' 8 | 9 | export * from './MsgSetWithdrawAddress' 10 | export * from './MsgWithdrawDelegatorReward' 11 | export * from './MsgWithdrawValidatorCommission' 12 | export * from './MsgFundCommunityPool' 13 | export * from './MsgUpdateDistrParams' 14 | export * from './MsgCommunityPoolSpend' 15 | export * from './MsgDepositValidatorRewardsPool' 16 | 17 | export type DistributionMsg = 18 | | MsgSetWithdrawAddress 19 | | MsgWithdrawDelegatorReward 20 | | MsgWithdrawValidatorCommission 21 | | MsgFundCommunityPool 22 | | MsgUpdateDistrParams 23 | | MsgCommunityPoolSpend 24 | | MsgDepositValidatorRewardsPool 25 | 26 | export namespace DistributionMsg { 27 | export type Amino = 28 | | MsgSetWithdrawAddress.Amino 29 | | MsgWithdrawDelegatorReward.Amino 30 | | MsgWithdrawValidatorCommission.Amino 31 | | MsgFundCommunityPool.Amino 32 | | MsgUpdateDistrParams.Amino 33 | | MsgCommunityPoolSpend.Amino 34 | | MsgDepositValidatorRewardsPool.Amino 35 | 36 | export type Data = 37 | | MsgSetWithdrawAddress.Data 38 | | MsgWithdrawDelegatorReward.Data 39 | | MsgWithdrawValidatorCommission.Data 40 | | MsgFundCommunityPool.Data 41 | | MsgUpdateDistrParams.Data 42 | | MsgCommunityPoolSpend.Data 43 | | MsgDepositValidatorRewardsPool.Data 44 | 45 | export type Proto = 46 | | MsgSetWithdrawAddress.Proto 47 | | MsgWithdrawDelegatorReward.Proto 48 | | MsgWithdrawValidatorCommission.Proto 49 | | MsgFundCommunityPool.Proto 50 | | MsgUpdateDistrParams.Proto 51 | | MsgCommunityPoolSpend.Proto 52 | | MsgDepositValidatorRewardsPool.Proto 53 | } 54 | -------------------------------------------------------------------------------- /src/core/marketmap/MarketmapParams.ts: -------------------------------------------------------------------------------- 1 | import { AccAddress } from '../bech32' 2 | import { JSONSerializable } from '../../util/json' 3 | import { Params as Params_pb } from '@initia/initia.proto/connect/marketmap/v2/params' 4 | 5 | /** 6 | * MarketmapParams defines the set of marketmap parameters. 7 | */ 8 | export class MarketmapParams extends JSONSerializable< 9 | MarketmapParams.Amino, 10 | MarketmapParams.Data, 11 | MarketmapParams.Proto 12 | > { 13 | /** 14 | * @param market_authorities the list of authority accounts that are able to control updating the marketmap 15 | * @param admin the address that can remove addresses from the MarketAuthorities list 16 | */ 17 | constructor( 18 | public market_authorities: AccAddress[], 19 | public admin: AccAddress 20 | ) { 21 | super() 22 | } 23 | 24 | public static fromAmino(data: MarketmapParams.Amino): MarketmapParams { 25 | return new MarketmapParams(data.market_authorities, data.admin) 26 | } 27 | 28 | public toAmino(): MarketmapParams.Amino { 29 | const { market_authorities, admin } = this 30 | return { market_authorities, admin } 31 | } 32 | 33 | public static fromData(data: MarketmapParams.Data): MarketmapParams { 34 | return new MarketmapParams(data.market_authorities, data.admin) 35 | } 36 | 37 | public toData(): MarketmapParams.Data { 38 | const { market_authorities, admin } = this 39 | return { market_authorities, admin } 40 | } 41 | 42 | public static fromProto(data: MarketmapParams.Proto): MarketmapParams { 43 | return new MarketmapParams(data.marketAuthorities, data.admin) 44 | } 45 | 46 | public toProto(): MarketmapParams.Proto { 47 | const { market_authorities, admin } = this 48 | return Params_pb.fromPartial({ 49 | marketAuthorities: market_authorities, 50 | admin, 51 | }) 52 | } 53 | } 54 | 55 | export namespace MarketmapParams { 56 | export interface Amino { 57 | market_authorities: AccAddress[] 58 | admin: AccAddress 59 | } 60 | 61 | export interface Data { 62 | market_authorities: AccAddress[] 63 | admin: AccAddress 64 | } 65 | 66 | export type Proto = Params_pb 67 | } 68 | -------------------------------------------------------------------------------- /src/key/RawKey.ts: -------------------------------------------------------------------------------- 1 | import { SHA256, Word32Array } from 'jscrypto' 2 | import * as secp256k1 from 'secp256k1' 3 | import { Key } from './Key' 4 | import { EthPublicKey, SimplePublicKey } from '../core' 5 | import keccak256 from 'keccak256' 6 | 7 | /** 8 | * RawKey is an implementation of the Key interfaces that uses a raw private key. 9 | */ 10 | export class RawKey extends Key { 11 | /** 12 | * Raw private key, in bytes. 13 | */ 14 | public privateKey: Buffer 15 | /** 16 | * Whether to use eth pubkey 17 | */ 18 | public eth: boolean 19 | 20 | constructor(privateKey: Buffer, eth = true) { 21 | const publicKey = secp256k1.publicKeyCreate( 22 | new Uint8Array(privateKey), 23 | true 24 | ) 25 | 26 | if (eth) { 27 | super(new EthPublicKey(Buffer.from(publicKey).toString('base64'))) 28 | } else { 29 | super(new SimplePublicKey(Buffer.from(publicKey).toString('base64'))) 30 | } 31 | 32 | this.privateKey = privateKey 33 | this.eth = eth 34 | } 35 | 36 | public static fromHex(key: string): RawKey { 37 | const hex = key.startsWith('0x') ? key.slice(2) : key 38 | if (hex.length !== 64) throw new Error('Invalid private key length') 39 | return new RawKey(Buffer.from(hex, 'hex')) 40 | } 41 | 42 | // eslint-disable-next-line @typescript-eslint/require-await 43 | public async sign(payload: Buffer): Promise { 44 | if (this.eth) return this.signWithKeccak256(payload) 45 | 46 | const hash = Buffer.from( 47 | SHA256.hash(new Word32Array(payload)).toString(), 48 | 'hex' 49 | ) 50 | 51 | const { signature } = secp256k1.ecdsaSign( 52 | Uint8Array.from(hash), 53 | Uint8Array.from(this.privateKey) 54 | ) 55 | 56 | return Buffer.from(signature) 57 | } 58 | 59 | // eslint-disable-next-line @typescript-eslint/require-await 60 | public async signWithKeccak256(payload: Buffer): Promise { 61 | const hash = keccak256(payload) 62 | 63 | const { signature } = secp256k1.ecdsaSign( 64 | Uint8Array.from(hash), 65 | Uint8Array.from(this.privateKey) 66 | ) 67 | 68 | return Buffer.from(signature) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/core/consensus/BlockParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { BlockParams as BlockParams_pb } from '@initia/initia.proto/tendermint/types/params' 3 | 4 | /** 5 | * BlockParams defines the set of block parameters. 6 | */ 7 | export class BlockParams extends JSONSerializable< 8 | BlockParams.Amino, 9 | BlockParams.Data, 10 | BlockParams.Proto 11 | > { 12 | /** 13 | * @param max_bytes max block size in bytes, must be greater than 0 14 | * @param max_gas max gas per block, must be greater or equal to -1 15 | */ 16 | constructor( 17 | public max_bytes: number, 18 | public max_gas: number 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino(data: BlockParams.Amino): BlockParams { 24 | const { max_bytes, max_gas } = data 25 | return new BlockParams(parseInt(max_bytes), parseInt(max_gas)) 26 | } 27 | 28 | public toAmino(): BlockParams.Amino { 29 | const { max_bytes, max_gas } = this 30 | return { 31 | max_bytes: max_bytes.toFixed(), 32 | max_gas: max_gas.toFixed(), 33 | } 34 | } 35 | 36 | public static fromData(data: BlockParams.Data): BlockParams { 37 | const { max_bytes, max_gas } = data 38 | return new BlockParams(parseInt(max_bytes), parseInt(max_gas)) 39 | } 40 | 41 | public toData(): BlockParams.Data { 42 | const { max_bytes, max_gas } = this 43 | return { 44 | max_bytes: max_bytes.toFixed(), 45 | max_gas: max_gas.toFixed(), 46 | } 47 | } 48 | 49 | public static fromProto(data: BlockParams.Proto): BlockParams { 50 | return new BlockParams(Number(data.maxBytes), Number(data.maxGas)) 51 | } 52 | 53 | public toProto(): BlockParams.Proto { 54 | const { max_bytes, max_gas } = this 55 | return BlockParams_pb.fromPartial({ 56 | maxBytes: BigInt(max_bytes), 57 | maxGas: BigInt(max_gas), 58 | }) 59 | } 60 | } 61 | 62 | export namespace BlockParams { 63 | export interface Amino { 64 | max_bytes: string 65 | max_gas: string 66 | } 67 | 68 | export interface Data { 69 | max_bytes: string 70 | max_gas: string 71 | } 72 | 73 | export type Proto = BlockParams_pb 74 | } 75 | -------------------------------------------------------------------------------- /src/core/ibc/applications/interchain-account/host/Params.ts: -------------------------------------------------------------------------------- 1 | import { Params as Params_pb } from '@initia/initia.proto/ibc/applications/interchain_accounts/host/v1/host' 2 | import { JSONSerializable } from '../../../../../util/json' 3 | 4 | /** 5 | * Params defines the set of on-chain interchain accounts parameters. 6 | * The following parameters may be used to disable the host submodule. 7 | */ 8 | export class Params extends JSONSerializable< 9 | Params.Amino, 10 | Params.Data, 11 | Params.Proto 12 | > { 13 | /** 14 | * @param host_enabled host_enabled enables or disables the host submodule 15 | */ 16 | constructor( 17 | public host_enabled: boolean, 18 | public allowed_messages: string[] 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino(data: Params.Amino): Params { 24 | const { host_enabled, allowed_messages } = data 25 | return new Params(host_enabled, allowed_messages) 26 | } 27 | 28 | public toAmino(): Params.Amino { 29 | const { host_enabled, allowed_messages } = this 30 | return { 31 | host_enabled, 32 | allowed_messages, 33 | } 34 | } 35 | 36 | public static fromData(data: Params.Data): Params { 37 | const { host_enabled, allowed_messages } = data 38 | return new Params(host_enabled, allowed_messages) 39 | } 40 | 41 | public toData(): Params.Data { 42 | const { host_enabled, allowed_messages } = this 43 | return { 44 | host_enabled, 45 | allowed_messages, 46 | } 47 | } 48 | 49 | public static fromProto(proto: Params.Proto): Params { 50 | return new Params(proto.hostEnabled, proto.allowMessages) 51 | } 52 | 53 | public toProto(): Params.Proto { 54 | const { host_enabled, allowed_messages } = this 55 | return Params_pb.fromPartial({ 56 | hostEnabled: host_enabled, 57 | allowMessages: allowed_messages, 58 | }) 59 | } 60 | } 61 | 62 | export namespace Params { 63 | export interface Amino { 64 | host_enabled: boolean 65 | allowed_messages: string[] 66 | } 67 | 68 | export interface Data { 69 | host_enabled: boolean 70 | allowed_messages: string[] 71 | } 72 | 73 | export type Proto = Params_pb 74 | } 75 | -------------------------------------------------------------------------------- /src/core/ibc/applications/nft-transfer/NftClassTrace.ts: -------------------------------------------------------------------------------- 1 | import { ClassTrace as NftClassTrace_pb } from '@initia/initia.proto/ibc/applications/nft_transfer/v1/types' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * NftClassTrace contains the base class id for ICS721 non fungible tokens and the source tracing information path. 6 | */ 7 | export class NftClassTrace extends JSONSerializable< 8 | NftClassTrace.Amino, 9 | NftClassTrace.Data, 10 | NftClassTrace.Proto 11 | > { 12 | /** 13 | * @param path the chain of port/channel identifiers used for tracing the source of the non fungible token 14 | * @param base_class_id base class id of the relayed non fungible token 15 | */ 16 | constructor( 17 | public path: string, 18 | public base_class_id: string 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino(data: NftClassTrace.Amino): NftClassTrace { 24 | const { path, base_class_id } = data 25 | return new NftClassTrace(path, base_class_id) 26 | } 27 | 28 | public toAmino(): NftClassTrace.Amino { 29 | const { path, base_class_id } = this 30 | return { 31 | path, 32 | base_class_id, 33 | } 34 | } 35 | 36 | public static fromData(data: NftClassTrace.Data): NftClassTrace { 37 | const { path, base_class_id } = data 38 | return new NftClassTrace(path, base_class_id) 39 | } 40 | 41 | public toData(): NftClassTrace.Data { 42 | const { path, base_class_id } = this 43 | return { 44 | path, 45 | base_class_id, 46 | } 47 | } 48 | 49 | public static fromProto(proto: NftClassTrace.Proto): NftClassTrace { 50 | return new NftClassTrace(proto.path, proto.baseClassId) 51 | } 52 | 53 | public toProto(): NftClassTrace.Proto { 54 | const { path, base_class_id } = this 55 | return NftClassTrace_pb.fromPartial({ path, baseClassId: base_class_id }) 56 | } 57 | } 58 | 59 | export namespace NftClassTrace { 60 | export interface Amino { 61 | path: string 62 | base_class_id: string 63 | } 64 | 65 | export interface Data { 66 | path: string 67 | base_class_id: string 68 | } 69 | 70 | export type Proto = NftClassTrace_pb 71 | } 72 | -------------------------------------------------------------------------------- /src/core/celestia/BlobTx.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Tx } from '../tx/Tx' 3 | import { Blob } from './Blob' 4 | import { BlobTx as BlobTx_pb } from '@initia/initia.proto/celestia/blob/v1/blob' 5 | 6 | /** 7 | * BlobTx wraps an encoded sdk.Tx with a second field to contain blobs of data. 8 | * The raw bytes of the blobs are not signed over, instead we verify each blob 9 | * using the relevant MsgPayForBlobs that is signed over in the encoded sdk.Tx. 10 | */ 11 | export class BlobTx extends JSONSerializable { 12 | /** 13 | * @param tx 14 | * @param blobs 15 | * @param type_id 16 | */ 17 | constructor( 18 | public tx: Tx, 19 | public blobs: Blob[], 20 | public type_id: string 21 | ) { 22 | super() 23 | } 24 | 25 | public static fromAmino(_: any): BlobTx { 26 | throw new Error('Amino not supported') 27 | } 28 | 29 | public toAmino(): any { 30 | throw new Error('Amino not supported') 31 | } 32 | 33 | public static fromData(data: BlobTx.Data): BlobTx { 34 | const { tx, blobs, type_id } = data 35 | return new BlobTx(Tx.fromData(tx), blobs.map(Blob.fromData), type_id) 36 | } 37 | 38 | public toData(): BlobTx.Data { 39 | const { tx, blobs, type_id } = this 40 | return { 41 | tx: tx.toData(), 42 | blobs: blobs.map((blob) => blob.toData()), 43 | type_id, 44 | } 45 | } 46 | 47 | public static fromProto(data: BlobTx.Proto): BlobTx { 48 | return new BlobTx( 49 | Tx.fromBuffer(Buffer.from(data.tx)), 50 | data.blobs.map(Blob.fromProto), 51 | data.typeId 52 | ) 53 | } 54 | 55 | public toProto(): BlobTx.Proto { 56 | const { tx, blobs, type_id } = this 57 | return BlobTx_pb.fromPartial({ 58 | tx: tx.toBytes(), 59 | blobs: blobs.map((blob) => blob.toProto()), 60 | typeId: type_id, 61 | }) 62 | } 63 | 64 | public toBytes(): Uint8Array { 65 | return BlobTx_pb.encode(this.toProto()).finish() 66 | } 67 | } 68 | 69 | export namespace BlobTx { 70 | export interface Data { 71 | tx: Tx.Data 72 | blobs: Blob.Data[] 73 | type_id: string 74 | } 75 | 76 | export type Proto = BlobTx_pb 77 | } 78 | -------------------------------------------------------------------------------- /src/core/ophost/BatchInfo.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { AccAddress } from '../bech32' 3 | import { 4 | BatchInfo as BatchInfo_pb, 5 | BatchInfo_ChainType as ChainType, 6 | batchInfo_ChainTypeFromJSON as chainTypeFromJSON, 7 | batchInfo_ChainTypeToJSON as chainTypeToJSON, 8 | } from '@initia/opinit.proto/opinit/ophost/v1/types' 9 | 10 | /** 11 | * BatchInfo defines the set of batch information. 12 | */ 13 | export class BatchInfo extends JSONSerializable< 14 | BatchInfo.Amino, 15 | BatchInfo.Data, 16 | BatchInfo.Proto 17 | > { 18 | /** 19 | * @param submitter the address of the batch submitter 20 | * @param chain_type the target chain type 21 | */ 22 | constructor( 23 | public submitter: AccAddress, 24 | public chain_type: ChainType 25 | ) { 26 | super() 27 | } 28 | 29 | public static fromAmino(data: BatchInfo.Amino): BatchInfo { 30 | const { submitter, chain_type } = data 31 | return new BatchInfo(submitter, chainTypeFromJSON(chain_type)) 32 | } 33 | 34 | public toAmino(): BatchInfo.Amino { 35 | const { submitter, chain_type } = this 36 | return { submitter, chain_type: chainTypeToJSON(chain_type) } 37 | } 38 | 39 | public static fromData(data: BatchInfo.Data): BatchInfo { 40 | const { submitter, chain_type } = data 41 | return new BatchInfo(submitter, chainTypeFromJSON(chain_type)) 42 | } 43 | 44 | public toData(): BatchInfo.Data { 45 | const { submitter, chain_type } = this 46 | return { submitter, chain_type: chainTypeToJSON(chain_type) } 47 | } 48 | 49 | public static fromProto(data: BatchInfo.Proto): BatchInfo { 50 | return new BatchInfo(data.submitter, data.chainType) 51 | } 52 | 53 | public toProto(): BatchInfo.Proto { 54 | const { submitter, chain_type } = this 55 | return BatchInfo_pb.fromPartial({ 56 | submitter, 57 | chainType: chain_type, 58 | }) 59 | } 60 | } 61 | 62 | export namespace BatchInfo { 63 | export interface Amino { 64 | submitter: AccAddress 65 | chain_type: string 66 | } 67 | 68 | export interface Data { 69 | submitter: AccAddress 70 | chain_type: string 71 | } 72 | 73 | export type Proto = BatchInfo_pb 74 | } 75 | -------------------------------------------------------------------------------- /src/client/rest/api/MstakingAPI.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { APIRequester } from '../APIRequester' 3 | import { MstakingAPI } from './MstakingAPI' 4 | import { Coins, MstakingParams, ValConsPublicKey } from '../../../core' 5 | 6 | const c = new APIRequester('https://rest.testnet.initia.xyz') 7 | const api = new MstakingAPI(c) 8 | 9 | describe('MstakingAPI', () => { 10 | it('delegations without parameter should throw an error', async () => { 11 | await expect(api.delegations()).rejects.toThrowError() 12 | }) 13 | 14 | it('unbondingDelegations without parameter should throw an error', async () => { 15 | await expect(api.unbondingDelegations()).rejects.toThrowError() 16 | }) 17 | 18 | it('validators', async () => { 19 | const validators = await api.validators().then((v) => v[0]) 20 | 21 | expect(validators).toContainEqual({ 22 | operator_address: expect.any(String), 23 | consensus_pubkey: expect.any(ValConsPublicKey), 24 | jailed: expect.any(Boolean), 25 | status: expect.any(String), 26 | tokens: expect.any(Coins), 27 | delegator_shares: expect.any(Coins), 28 | description: { 29 | moniker: expect.any(String), 30 | identity: expect.any(String), 31 | website: expect.any(String), 32 | details: expect.any(String), 33 | security_contact: expect.any(String), 34 | }, 35 | unbonding_height: expect.any(Number), 36 | unbonding_time: expect.any(Date), 37 | commission: { 38 | commission_rates: { 39 | rate: expect.any(String), 40 | max_rate: expect.any(String), 41 | max_change_rate: expect.any(String), 42 | }, 43 | update_time: expect.any(Date), 44 | }, 45 | voting_powers: expect.any(Coins), 46 | voting_power: expect.any(String), 47 | }) 48 | }) 49 | 50 | it('pool', async () => { 51 | await expect(api.pool()).resolves.toMatchObject({ 52 | bonded_tokens: expect.any(Coins), 53 | not_bonded_tokens: expect.any(Coins), 54 | }) 55 | }) 56 | 57 | it('params', async () => { 58 | const params = await api.parameters() 59 | expect(params).toEqual(expect.any(MstakingParams)) 60 | }) 61 | }) 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | # IDEs 107 | .vscode/ 108 | .idea/ 109 | 110 | # MacOS 111 | .DS_Store 112 | -------------------------------------------------------------------------------- /src/client/rest/api/ForwardingAPI.ts: -------------------------------------------------------------------------------- 1 | import { AccAddress, Coin } from '../../../core' 2 | import { APIParams } from '../APIRequester' 3 | import { BaseAPI } from './BaseAPI' 4 | 5 | export interface ForwardingStats { 6 | num_of_accounts: number 7 | num_of_forwards: number 8 | total_forwarded: Coin 9 | } 10 | 11 | export namespace ForwardingStats { 12 | export interface Data { 13 | num_of_accounts: string 14 | num_of_forwards: string 15 | total_forwarded: Coin.Data 16 | } 17 | } 18 | 19 | export class ForwardingAPI extends BaseAPI { 20 | /** 21 | * Query all the denoms that are allowed to be forwarded. 22 | */ 23 | public async denoms( 24 | params: APIParams = {}, 25 | headers: Record = {} 26 | ): Promise { 27 | return this.c 28 | .get<{ 29 | allowed_denoms: string[] 30 | }>(`/noble/forwarding/v1/denoms`, params, headers) 31 | .then((d) => d.allowed_denoms) 32 | } 33 | 34 | /** 35 | * Query the forwarding address by channel and recipient. 36 | * @param channel 37 | * @param recipient 38 | * @param fallback 39 | */ 40 | public async address( 41 | channel: string, 42 | recipient: string, 43 | fallback: string, 44 | params: APIParams = {}, 45 | headers: Record = {} 46 | ): Promise { 47 | return this.c 48 | .get<{ 49 | address: AccAddress 50 | }>( 51 | `/noble/forwarding/v1/address/${channel}/${recipient}/${fallback}`, 52 | params, 53 | headers 54 | ) 55 | .then((d) => d.address) 56 | } 57 | 58 | /** 59 | * Query the forwarding stats by channel. 60 | * @param channel 61 | */ 62 | public async stats( 63 | channel: string, 64 | params: APIParams = {}, 65 | headers: Record = {} 66 | ): Promise { 67 | return this.c 68 | .get( 69 | `/noble/forwarding/v1/stats/${channel}`, 70 | params, 71 | headers 72 | ) 73 | .then((d) => ({ 74 | num_of_accounts: parseInt(d.num_of_accounts), 75 | num_of_forwards: parseInt(d.num_of_forwards), 76 | total_forwarded: Coin.fromData(d.total_forwarded), 77 | })) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/core/ibc/core/channel/ChannelCounterparty.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../../util/json' 2 | import { Counterparty as Counterparty_pb } from '@initia/initia.proto/ibc/core/channel/v1/channel' 3 | 4 | /** 5 | * ChannelCounterparty defines a channel end ChannelCounterparty. 6 | */ 7 | export class ChannelCounterparty extends JSONSerializable< 8 | ChannelCounterparty.Amino, 9 | ChannelCounterparty.Data, 10 | ChannelCounterparty.Proto 11 | > { 12 | /** 13 | * @param port_id port on the ChannelCounterparty chain which owns the other end of the channel 14 | * @param channel_id channel end on the ChannelCounterparty chain 15 | */ 16 | constructor( 17 | public port_id: string, 18 | public channel_id: string 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino( 24 | data: ChannelCounterparty.Amino 25 | ): ChannelCounterparty { 26 | const { port_id, channel_id } = data 27 | return new ChannelCounterparty(port_id, channel_id) 28 | } 29 | 30 | public toAmino(): ChannelCounterparty.Amino { 31 | const { port_id, channel_id } = this 32 | return { 33 | port_id, 34 | channel_id, 35 | } 36 | } 37 | 38 | public static fromData(data: ChannelCounterparty.Data): ChannelCounterparty { 39 | const { port_id, channel_id } = data 40 | return new ChannelCounterparty(port_id, channel_id) 41 | } 42 | 43 | public toData(): ChannelCounterparty.Data { 44 | const { port_id, channel_id } = this 45 | return { 46 | port_id, 47 | channel_id, 48 | } 49 | } 50 | 51 | public static fromProto( 52 | proto: ChannelCounterparty.Proto 53 | ): ChannelCounterparty { 54 | return new ChannelCounterparty(proto.portId, proto.channelId) 55 | } 56 | 57 | public toProto(): ChannelCounterparty.Proto { 58 | const { port_id, channel_id } = this 59 | return Counterparty_pb.fromPartial({ 60 | portId: port_id, 61 | channelId: channel_id, 62 | }) 63 | } 64 | } 65 | 66 | export namespace ChannelCounterparty { 67 | export interface Amino { 68 | port_id: string 69 | channel_id: string 70 | } 71 | 72 | export interface Data { 73 | port_id: string 74 | channel_id: string 75 | } 76 | 77 | export type Proto = Counterparty_pb 78 | } 79 | -------------------------------------------------------------------------------- /src/core/wasm/AccessConfig.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { AccAddress } from '../bech32' 3 | import { 4 | AccessConfig as AccessConfig_pb, 5 | AccessType, 6 | accessTypeFromJSON, 7 | accessTypeToJSON, 8 | } from '@initia/initia.proto/cosmwasm/wasm/v1/types' 9 | 10 | /** 11 | * AccessConfig defines access control type. 12 | */ 13 | export class AccessConfig extends JSONSerializable< 14 | AccessConfig.Amino, 15 | AccessConfig.Data, 16 | AccessConfig.Proto 17 | > { 18 | /** 19 | * @param permission 20 | * @param addresses 21 | */ 22 | constructor( 23 | public permission: AccessType, 24 | public addresses: AccAddress[] 25 | ) { 26 | super() 27 | } 28 | 29 | public static fromAmino(data: AccessConfig.Amino): AccessConfig { 30 | const { permission, addresses } = data 31 | return new AccessConfig(accessTypeFromJSON(permission), addresses) 32 | } 33 | 34 | public toAmino(): AccessConfig.Amino { 35 | const { permission, addresses } = this 36 | return { 37 | permission: accessTypeToJSON(permission), 38 | addresses, 39 | } 40 | } 41 | 42 | public static fromData(data: AccessConfig.Data): AccessConfig { 43 | const { permission, addresses } = data 44 | return new AccessConfig(accessTypeFromJSON(permission), addresses) 45 | } 46 | 47 | public toData(): AccessConfig.Data { 48 | const { permission, addresses } = this 49 | return { 50 | permission: accessTypeToJSON(permission), 51 | addresses, 52 | } 53 | } 54 | 55 | public static fromProto(data: AccessConfig.Proto): AccessConfig { 56 | return new AccessConfig(data.permission, data.addresses) 57 | } 58 | 59 | public toProto(): AccessConfig.Proto { 60 | const { permission, addresses } = this 61 | return AccessConfig_pb.fromPartial({ 62 | permission, 63 | addresses, 64 | }) 65 | } 66 | } 67 | 68 | export namespace AccessConfig { 69 | export type Type = AccessType 70 | export const Type = AccessType 71 | 72 | export interface Amino { 73 | permission: string 74 | addresses: AccAddress[] 75 | } 76 | 77 | export interface Data { 78 | permission: string 79 | addresses: AccAddress[] 80 | } 81 | 82 | export type Proto = AccessConfig_pb 83 | } 84 | -------------------------------------------------------------------------------- /src/core/ibc/applications/fee/Metadata.ts: -------------------------------------------------------------------------------- 1 | import { Metadata as Metadata_pb } from '@initia/initia.proto/ibc/applications/fee/v1/metadata' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring. 6 | * See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning 7 | */ 8 | export class Metadata extends JSONSerializable< 9 | Metadata.Amino, 10 | Metadata.Data, 11 | Metadata.Proto 12 | > { 13 | /** 14 | * @param fee_version fee_version defines the ICS29 fee version 15 | * @param app_version app_version defines the underlying application version, which may or may not be a JSON encoded bytestring 16 | */ 17 | constructor( 18 | public fee_version: string, 19 | public app_version: string 20 | ) { 21 | super() 22 | } 23 | 24 | public static fromAmino(data: Metadata.Amino): Metadata { 25 | const { fee_version, app_version } = data 26 | return new Metadata(fee_version, app_version) 27 | } 28 | 29 | public toAmino(): Metadata.Amino { 30 | const { fee_version, app_version } = this 31 | return { 32 | fee_version, 33 | app_version, 34 | } 35 | } 36 | 37 | public static fromData(data: Metadata.Data): Metadata { 38 | const { fee_version, app_version } = data 39 | return new Metadata(fee_version, app_version) 40 | } 41 | 42 | public toData(): Metadata.Data { 43 | const { fee_version, app_version } = this 44 | return { 45 | fee_version, 46 | app_version, 47 | } 48 | } 49 | 50 | public static fromProto(proto: Metadata.Proto): Metadata { 51 | return new Metadata(proto.feeVersion, proto.appVersion) 52 | } 53 | 54 | public toProto(): Metadata.Proto { 55 | const { fee_version, app_version } = this 56 | return Metadata_pb.fromPartial({ 57 | feeVersion: fee_version, 58 | appVersion: app_version, 59 | }) 60 | } 61 | } 62 | 63 | export namespace Metadata { 64 | export interface Amino { 65 | fee_version: string 66 | app_version: string 67 | } 68 | 69 | export interface Data { 70 | fee_version: string 71 | app_version: string 72 | } 73 | 74 | export type Proto = Metadata_pb 75 | } 76 | -------------------------------------------------------------------------------- /src/core/ophost/OphostParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Coins } from '../Coins' 3 | import { Params as Params_pb } from '@initia/opinit.proto/opinit/ophost/v1/types' 4 | 5 | /** 6 | * OphostParams defines the set of ophost parameters. 7 | */ 8 | export class OphostParams extends JSONSerializable< 9 | OphostParams.Amino, 10 | OphostParams.Data, 11 | OphostParams.Proto 12 | > { 13 | public registration_fee: Coins 14 | 15 | /** 16 | * @param registration_fee the amount to be paid by l2 creator 17 | */ 18 | constructor(registration_fee: Coins.Input) { 19 | super() 20 | this.registration_fee = new Coins(registration_fee) 21 | } 22 | 23 | public static fromAmino(data: OphostParams.Amino): OphostParams { 24 | return new OphostParams( 25 | data.value.registration_fee 26 | ? Coins.fromAmino(data.value.registration_fee) 27 | : new Coins() 28 | ) 29 | } 30 | 31 | public toAmino(): OphostParams.Amino { 32 | return { 33 | type: 'ophost/Params', 34 | value: { 35 | registration_fee: 36 | this.registration_fee.toArray().length > 0 37 | ? this.registration_fee.toAmino() 38 | : null, 39 | }, 40 | } 41 | } 42 | 43 | public static fromData(data: OphostParams.Data): OphostParams { 44 | return new OphostParams(Coins.fromData(data.registration_fee)) 45 | } 46 | 47 | public toData(): OphostParams.Data { 48 | return { 49 | '@type': '/opinit.ophost.v1.Params', 50 | registration_fee: this.registration_fee.toData(), 51 | } 52 | } 53 | 54 | public static fromProto(data: OphostParams.Proto): OphostParams { 55 | return new OphostParams(Coins.fromProto(data.registrationFee)) 56 | } 57 | 58 | public toProto(): OphostParams.Proto { 59 | return Params_pb.fromPartial({ 60 | registrationFee: this.registration_fee.toProto(), 61 | }) 62 | } 63 | } 64 | 65 | export namespace OphostParams { 66 | export interface Amino { 67 | type: 'ophost/Params' 68 | value: { 69 | registration_fee: Coins.Amino | null 70 | } 71 | } 72 | 73 | export interface Data { 74 | '@type': '/opinit.ophost.v1.Params' 75 | registration_fee: Coins.Data 76 | } 77 | 78 | export type Proto = Params_pb 79 | } 80 | -------------------------------------------------------------------------------- /src/core/wasm/authorizations/AllowAllMessagesFilter.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../util/json' 2 | import { AllowAllMessagesFilter as AllowAllMessagesFilter_pb } from '@initia/initia.proto/cosmwasm/wasm/v1/authz' 3 | import { Any } from '@initia/initia.proto/google/protobuf/any' 4 | 5 | /** 6 | * AllowAllMessagesFilter is a wildcard to allow any type of contract payload message. 7 | */ 8 | export class AllowAllMessagesFilter extends JSONSerializable< 9 | AllowAllMessagesFilter.Amino, 10 | AllowAllMessagesFilter.Data, 11 | AllowAllMessagesFilter.Proto 12 | > { 13 | constructor() { 14 | super() 15 | } 16 | 17 | public static fromAmino( 18 | _: AllowAllMessagesFilter.Amino 19 | ): AllowAllMessagesFilter { 20 | return new AllowAllMessagesFilter() 21 | } 22 | 23 | public toAmino(): AllowAllMessagesFilter.Amino { 24 | return { 25 | type: 'wasm/AllowAllMessagesFilter', 26 | value: {}, 27 | } 28 | } 29 | 30 | public static fromData( 31 | _: AllowAllMessagesFilter.Data 32 | ): AllowAllMessagesFilter { 33 | return new AllowAllMessagesFilter() 34 | } 35 | 36 | public toData(): AllowAllMessagesFilter.Data { 37 | return { 38 | '@type': '/cosmwasm.wasm.v1.AllowAllMessagesFilter', 39 | } 40 | } 41 | 42 | public static fromProto( 43 | _: AllowAllMessagesFilter.Proto 44 | ): AllowAllMessagesFilter { 45 | return new AllowAllMessagesFilter() 46 | } 47 | 48 | public toProto(): AllowAllMessagesFilter.Proto { 49 | return AllowAllMessagesFilter_pb.fromPartial({}) 50 | } 51 | 52 | public packAny(): Any { 53 | return Any.fromPartial({ 54 | typeUrl: '/cosmwasm.wasm.v1.AllowAllMessagesFilter', 55 | value: AllowAllMessagesFilter_pb.encode(this.toProto()).finish(), 56 | }) 57 | } 58 | 59 | public static unpackAny(msgAny: Any): AllowAllMessagesFilter { 60 | return AllowAllMessagesFilter.fromProto( 61 | AllowAllMessagesFilter_pb.decode(msgAny.value) 62 | ) 63 | } 64 | } 65 | 66 | export namespace AllowAllMessagesFilter { 67 | export interface Amino { 68 | type: 'wasm/AllowAllMessagesFilter' 69 | value: object 70 | } 71 | 72 | export interface Data { 73 | '@type': '/cosmwasm.wasm.v1.AllowAllMessagesFilter' 74 | } 75 | 76 | export type Proto = AllowAllMessagesFilter_pb 77 | } 78 | -------------------------------------------------------------------------------- /src/core/feegrant/allowances/index.ts: -------------------------------------------------------------------------------- 1 | import { BasicAllowance } from './BasicAllowance' 2 | import { PeriodicAllowance } from './PeriodicAllowance' 3 | import { AllowedMsgAllowance } from './AllowedMsgAllowance' 4 | 5 | export * from './BasicAllowance' 6 | export * from './PeriodicAllowance' 7 | export * from './AllowedMsgAllowance' 8 | import { Any } from '@initia/initia.proto/google/protobuf/any' 9 | 10 | export type Allowance = BasicAllowance | PeriodicAllowance | AllowedMsgAllowance 11 | 12 | export namespace Allowance { 13 | export type Amino = 14 | | BasicAllowance.Amino 15 | | PeriodicAllowance.Amino 16 | | AllowedMsgAllowance.Amino 17 | 18 | export type Data = 19 | | BasicAllowance.Data 20 | | PeriodicAllowance.Data 21 | | AllowedMsgAllowance.Data 22 | 23 | export type Proto = 24 | | BasicAllowance.Proto 25 | | PeriodicAllowance.Proto 26 | | AllowedMsgAllowance.Proto 27 | 28 | export function fromAmino(data: Allowance.Amino): Allowance { 29 | switch (data.type) { 30 | case 'cosmos-sdk/BasicAllowance': 31 | return BasicAllowance.fromAmino(data) 32 | case 'cosmos-sdk/PeriodicAllowance': 33 | return PeriodicAllowance.fromAmino(data) 34 | case 'cosmos-sdk/AllowedMsgAllowance': 35 | return AllowedMsgAllowance.fromAmino(data) 36 | } 37 | } 38 | 39 | export function fromData(data: Allowance.Data): Allowance { 40 | switch (data['@type']) { 41 | case '/cosmos.feegrant.v1beta1.PeriodicAllowance': 42 | return PeriodicAllowance.fromData(data) 43 | case '/cosmos.feegrant.v1beta1.BasicAllowance': 44 | return BasicAllowance.fromData(data) 45 | case '/cosmos.feegrant.v1beta1.AllowedMsgAllowance': 46 | return AllowedMsgAllowance.fromData(data) 47 | } 48 | } 49 | 50 | export function fromProto(proto: Any): Allowance { 51 | switch (proto.typeUrl) { 52 | case '/cosmos.feegrant.v1beta1.PeriodicAllowance': 53 | return PeriodicAllowance.unpackAny(proto) 54 | case '/cosmos.feegrant.v1beta1.BasicAllowance': 55 | return BasicAllowance.unpackAny(proto) 56 | case '/cosmos.feegrant.v1beta1.AllowedMsgAllowance': 57 | return AllowedMsgAllowance.unpackAny(proto) 58 | } 59 | 60 | throw new Error(`not supported allowance ${proto.typeUrl}`) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/core/ibc/core/connection/IbcConnectionParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../../util/json' 2 | import { Params as Params_pb } from '@initia/initia.proto/ibc/core/connection/v1/connection' 3 | 4 | /** 5 | * IbcConnectionParams defines the set of ibc connection parameters. 6 | */ 7 | export class IbcConnectionParams extends JSONSerializable< 8 | IbcConnectionParams.Amino, 9 | IbcConnectionParams.Data, 10 | IbcConnectionParams.Proto 11 | > { 12 | /** 13 | * @param max_expected_time_per_block maximum expected time per block (in nanoseconds), used to enforce block delay 14 | */ 15 | constructor(public max_expected_time_per_block: number) { 16 | super() 17 | } 18 | 19 | public static fromAmino( 20 | data: IbcConnectionParams.Amino 21 | ): IbcConnectionParams { 22 | const { max_expected_time_per_block } = data 23 | return new IbcConnectionParams(parseInt(max_expected_time_per_block)) 24 | } 25 | 26 | public toAmino(): IbcConnectionParams.Amino { 27 | const { max_expected_time_per_block } = this 28 | return { 29 | max_expected_time_per_block: max_expected_time_per_block.toFixed(), 30 | } 31 | } 32 | 33 | public static fromData(data: IbcConnectionParams.Data): IbcConnectionParams { 34 | const { max_expected_time_per_block } = data 35 | return new IbcConnectionParams(parseInt(max_expected_time_per_block)) 36 | } 37 | 38 | public toData(): IbcConnectionParams.Data { 39 | const { max_expected_time_per_block } = this 40 | return { 41 | max_expected_time_per_block: max_expected_time_per_block.toFixed(), 42 | } 43 | } 44 | 45 | public static fromProto( 46 | proto: IbcConnectionParams.Proto 47 | ): IbcConnectionParams { 48 | return new IbcConnectionParams(Number(proto.maxExpectedTimePerBlock)) 49 | } 50 | 51 | public toProto(): IbcConnectionParams.Proto { 52 | const { max_expected_time_per_block } = this 53 | return Params_pb.fromPartial({ 54 | maxExpectedTimePerBlock: BigInt(max_expected_time_per_block), 55 | }) 56 | } 57 | } 58 | 59 | export namespace IbcConnectionParams { 60 | export interface Amino { 61 | max_expected_time_per_block: string 62 | } 63 | 64 | export interface Data { 65 | max_expected_time_per_block: string 66 | } 67 | 68 | export type Proto = Params_pb 69 | } 70 | -------------------------------------------------------------------------------- /src/core/ibc/core/client/IdentifiedClient.ts: -------------------------------------------------------------------------------- 1 | import { IdentifiedClientState as IdentifiedClientState_pb } from '@initia/initia.proto/ibc/core/client/v1/client' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * IdentifiedClientState defines a client state with an additional client identifier field. 6 | */ 7 | export class IdentifiedClientState extends JSONSerializable< 8 | IdentifiedClientState.Amino, 9 | IdentifiedClientState.Data, 10 | IdentifiedClientState.Proto 11 | > { 12 | /** 13 | * @param client_id client identifier 14 | * @param client_state client state 15 | */ 16 | constructor( 17 | public client_id: string, 18 | public client_state: any 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino( 24 | data: IdentifiedClientState.Amino 25 | ): IdentifiedClientState { 26 | const { client_id, client_state } = data 27 | return new IdentifiedClientState(client_id, client_state) 28 | } 29 | 30 | public toAmino(): IdentifiedClientState.Amino { 31 | const { client_id, client_state } = this 32 | return { 33 | client_id, 34 | client_state, 35 | } 36 | } 37 | 38 | public static fromData( 39 | data: IdentifiedClientState.Data 40 | ): IdentifiedClientState { 41 | const { client_id, client_state } = data 42 | return new IdentifiedClientState(client_id, client_state) 43 | } 44 | 45 | public toData(): IdentifiedClientState.Data { 46 | const { client_id, client_state } = this 47 | return { 48 | client_id, 49 | client_state, 50 | } 51 | } 52 | 53 | public static fromProto( 54 | proto: IdentifiedClientState.Proto 55 | ): IdentifiedClientState { 56 | return new IdentifiedClientState(proto.clientId, proto.clientState) 57 | } 58 | 59 | public toProto(): IdentifiedClientState.Proto { 60 | const { client_id, client_state } = this 61 | return IdentifiedClientState_pb.fromPartial({ 62 | clientId: client_id, 63 | clientState: client_state, 64 | }) 65 | } 66 | } 67 | 68 | export namespace IdentifiedClientState { 69 | export interface Amino { 70 | client_id: string 71 | client_state: any 72 | } 73 | 74 | export interface Data { 75 | client_id: string 76 | client_state: any 77 | } 78 | 79 | export type Proto = IdentifiedClientState_pb 80 | } 81 | -------------------------------------------------------------------------------- /src/core/opchild/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgAddValidator } from './MsgAddValidator' 2 | import { MsgRemoveValidator } from './MsgRemoveValidator' 3 | import { MsgFinalizeTokenDeposit } from './MsgFinalizeTokenDeposit' 4 | import { MsgInitiateTokenWithdrawal } from './MsgInitiateTokenWithdrawal' 5 | import { MsgExecuteMessages } from './MsgExecuteMessages' 6 | import { MsgSpendFeePool } from './MsgSpendFeePool' 7 | import { MsgSetBridgeInfo } from './MsgSetBridgeInfo' 8 | import { MsgUpdateOracle } from './MsgUpdateOracle' 9 | import { MsgUpdateOpchildParams } from './MsgUpdateOpchildParams' 10 | 11 | export * from './MsgAddValidator' 12 | export * from './MsgRemoveValidator' 13 | export * from './MsgFinalizeTokenDeposit' 14 | export * from './MsgInitiateTokenWithdrawal' 15 | export * from './MsgExecuteMessages' 16 | export * from './MsgSpendFeePool' 17 | export * from './MsgSetBridgeInfo' 18 | export * from './MsgUpdateOracle' 19 | export * from './MsgUpdateOpchildParams' 20 | 21 | export type OpchildMsg = 22 | | MsgAddValidator 23 | | MsgRemoveValidator 24 | | MsgFinalizeTokenDeposit 25 | | MsgInitiateTokenWithdrawal 26 | | MsgExecuteMessages 27 | | MsgSpendFeePool 28 | | MsgSetBridgeInfo 29 | | MsgUpdateOracle 30 | | MsgUpdateOpchildParams 31 | 32 | export namespace OpchildMsg { 33 | export type Amino = 34 | | MsgAddValidator.Amino 35 | | MsgRemoveValidator.Amino 36 | | MsgFinalizeTokenDeposit.Amino 37 | | MsgInitiateTokenWithdrawal.Amino 38 | | MsgExecuteMessages.Amino 39 | | MsgSpendFeePool.Amino 40 | | MsgSetBridgeInfo.Amino 41 | | MsgUpdateOracle.Amino 42 | | MsgUpdateOpchildParams.Amino 43 | 44 | export type Data = 45 | | MsgAddValidator.Data 46 | | MsgRemoveValidator.Data 47 | | MsgFinalizeTokenDeposit.Data 48 | | MsgInitiateTokenWithdrawal.Data 49 | | MsgExecuteMessages.Data 50 | | MsgSpendFeePool.Data 51 | | MsgSetBridgeInfo.Data 52 | | MsgUpdateOracle.Data 53 | | MsgUpdateOpchildParams.Data 54 | 55 | export type Proto = 56 | | MsgAddValidator.Proto 57 | | MsgRemoveValidator.Proto 58 | | MsgFinalizeTokenDeposit.Proto 59 | | MsgInitiateTokenWithdrawal.Proto 60 | | MsgExecuteMessages.Proto 61 | | MsgSpendFeePool.Proto 62 | | MsgSetBridgeInfo.Proto 63 | | MsgUpdateOracle.Proto 64 | | MsgUpdateOpchildParams.Proto 65 | } 66 | -------------------------------------------------------------------------------- /src/core/gov/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgCancelProposal } from './MsgCancelProposal' 2 | import { MsgSubmitProposalLegacy } from './MsgSubmitProposalLegacy' 3 | import { MsgSubmitProposal } from './MsgSubmitProposal' 4 | import { MsgVoteLegacy } from './MsgVoteLegacy' 5 | import { MsgVote } from './MsgVote' 6 | import { MsgDepositLegacy } from './MsgDepositLegacy' 7 | import { MsgDeposit } from './MsgDeposit' 8 | import { MsgVoteWeightedLegacy } from './MsgVoteWeightedLegacy' 9 | import { MsgVoteWeighted } from './MsgVoteWeighted' 10 | import { MsgUpdateGovParams } from './MsgUpdateGovParams' 11 | 12 | export * from './MsgCancelProposal' 13 | export * from './MsgDepositLegacy' 14 | export * from './MsgDeposit' 15 | export * from './MsgSubmitProposalLegacy' 16 | export * from './MsgSubmitProposal' 17 | export * from './MsgVoteLegacy' 18 | export * from './MsgVote' 19 | export * from './MsgVoteWeightedLegacy' 20 | export * from './MsgVoteWeighted' 21 | export * from './MsgUpdateGovParams' 22 | 23 | export type GovMsg = 24 | | MsgCancelProposal 25 | | MsgDepositLegacy 26 | | MsgDeposit 27 | | MsgSubmitProposalLegacy 28 | | MsgSubmitProposal 29 | | MsgVoteLegacy 30 | | MsgVote 31 | | MsgVoteWeightedLegacy 32 | | MsgVoteWeighted 33 | | MsgUpdateGovParams 34 | 35 | export namespace GovMsg { 36 | export type Amino = 37 | | MsgCancelProposal.Amino 38 | | MsgDepositLegacy.Amino 39 | | MsgDeposit.Amino 40 | | MsgSubmitProposalLegacy.Amino 41 | | MsgSubmitProposal.Amino 42 | | MsgVoteLegacy.Amino 43 | | MsgVote.Amino 44 | | MsgVoteWeightedLegacy.Amino 45 | | MsgVoteWeighted.Amino 46 | | MsgUpdateGovParams.Amino 47 | export type Data = 48 | | MsgCancelProposal.Data 49 | | MsgDepositLegacy.Data 50 | | MsgDeposit.Data 51 | | MsgSubmitProposalLegacy.Data 52 | | MsgSubmitProposal.Data 53 | | MsgVoteLegacy.Data 54 | | MsgVote.Data 55 | | MsgVoteWeightedLegacy.Data 56 | | MsgVoteWeighted.Data 57 | | MsgUpdateGovParams.Data 58 | export type Proto = 59 | | MsgCancelProposal.Proto 60 | | MsgDepositLegacy.Proto 61 | | MsgDeposit.Proto 62 | | MsgSubmitProposalLegacy.Proto 63 | | MsgSubmitProposal.Proto 64 | | MsgVoteLegacy.Proto 65 | | MsgVote.Proto 66 | | MsgVoteWeightedLegacy.Proto 67 | | MsgVoteWeighted.Proto 68 | | MsgUpdateGovParams.Proto 69 | } 70 | -------------------------------------------------------------------------------- /src/core/wasm/authorizations/MaxCallsLimit.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../util/json' 2 | import { MaxCallsLimit as MaxCallsLimit_pb } from '@initia/initia.proto/cosmwasm/wasm/v1/authz' 3 | import { Any } from '@initia/initia.proto/google/protobuf/any' 4 | 5 | /** 6 | * MaxCallsLimit is limited number of calls to the contract. No funds transferable. 7 | */ 8 | export class MaxCallsLimit extends JSONSerializable< 9 | MaxCallsLimit.Amino, 10 | MaxCallsLimit.Data, 11 | MaxCallsLimit.Proto 12 | > { 13 | /** 14 | * @param remaining remaining number that is decremented on each execution 15 | */ 16 | constructor(public remaining: number) { 17 | super() 18 | } 19 | 20 | public static fromAmino(data: MaxCallsLimit.Amino): MaxCallsLimit { 21 | return new MaxCallsLimit(parseInt(data.value.remaining)) 22 | } 23 | 24 | public toAmino(): MaxCallsLimit.Amino { 25 | return { 26 | type: 'wasm/MaxCallsLimit', 27 | value: { remaining: this.remaining.toFixed() }, 28 | } 29 | } 30 | 31 | public static fromData(data: MaxCallsLimit.Data): MaxCallsLimit { 32 | return new MaxCallsLimit(parseInt(data.remaining)) 33 | } 34 | 35 | public toData(): MaxCallsLimit.Data { 36 | return { 37 | '@type': '/cosmwasm.wasm.v1.MaxCallsLimit', 38 | remaining: this.remaining.toFixed(), 39 | } 40 | } 41 | 42 | public static fromProto(data: MaxCallsLimit.Proto): MaxCallsLimit { 43 | return new MaxCallsLimit(Number(data.remaining)) 44 | } 45 | 46 | public toProto(): MaxCallsLimit.Proto { 47 | return MaxCallsLimit_pb.fromPartial({ 48 | remaining: BigInt(this.remaining), 49 | }) 50 | } 51 | 52 | public packAny(): Any { 53 | return Any.fromPartial({ 54 | typeUrl: '/cosmwasm.wasm.v1.MaxCallsLimit', 55 | value: MaxCallsLimit_pb.encode(this.toProto()).finish(), 56 | }) 57 | } 58 | 59 | public static unpackAny(msgAny: Any): MaxCallsLimit { 60 | return MaxCallsLimit.fromProto(MaxCallsLimit_pb.decode(msgAny.value)) 61 | } 62 | } 63 | 64 | export namespace MaxCallsLimit { 65 | export interface Amino { 66 | type: 'wasm/MaxCallsLimit' 67 | value: { remaining: string } 68 | } 69 | 70 | export interface Data { 71 | '@type': '/cosmwasm.wasm.v1.MaxCallsLimit' 72 | remaining: string 73 | } 74 | 75 | export type Proto = MaxCallsLimit_pb 76 | } 77 | -------------------------------------------------------------------------------- /src/core/ibc/applications/transfer/IbcTransferParams.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../../../util/json' 2 | import { Params as Params_pb } from '@initia/initia.proto/ibc/applications/transfer/v1/transfer' 3 | 4 | /** 5 | * IbcTransferParams defines the set of ibc transfer parameters. 6 | */ 7 | export class IbcTransferParams extends JSONSerializable< 8 | IbcTransferParams.Amino, 9 | IbcTransferParams.Data, 10 | IbcTransferParams.Proto 11 | > { 12 | /** 13 | * @param send_enabled enables or disables all cross-chain token transfers from this chain 14 | * @param receive_enabled enables or disables all cross-chain token transfers to this chain 15 | */ 16 | constructor( 17 | public send_enabled: boolean, 18 | public receive_enabled: boolean 19 | ) { 20 | super() 21 | } 22 | 23 | public static fromAmino(data: IbcTransferParams.Amino): IbcTransferParams { 24 | const { send_enabled, receive_enabled } = data 25 | return new IbcTransferParams(send_enabled, receive_enabled) 26 | } 27 | 28 | public toAmino(): IbcTransferParams.Amino { 29 | const { send_enabled, receive_enabled } = this 30 | return { 31 | send_enabled, 32 | receive_enabled, 33 | } 34 | } 35 | 36 | public static fromData(data: IbcTransferParams.Data): IbcTransferParams { 37 | const { send_enabled, receive_enabled } = data 38 | return new IbcTransferParams(send_enabled, receive_enabled) 39 | } 40 | 41 | public toData(): IbcTransferParams.Data { 42 | const { send_enabled, receive_enabled } = this 43 | return { 44 | send_enabled, 45 | receive_enabled, 46 | } 47 | } 48 | 49 | public static fromProto(data: IbcTransferParams.Proto): IbcTransferParams { 50 | return new IbcTransferParams(data.sendEnabled, data.receiveEnabled) 51 | } 52 | 53 | public toProto(): IbcTransferParams.Proto { 54 | const { send_enabled, receive_enabled } = this 55 | return Params_pb.fromPartial({ 56 | sendEnabled: send_enabled, 57 | receiveEnabled: receive_enabled, 58 | }) 59 | } 60 | } 61 | 62 | export namespace IbcTransferParams { 63 | export interface Amino { 64 | send_enabled: boolean 65 | receive_enabled: boolean 66 | } 67 | 68 | export interface Data { 69 | send_enabled: boolean 70 | receive_enabled: boolean 71 | } 72 | 73 | export type Proto = Params_pb 74 | } 75 | -------------------------------------------------------------------------------- /src/core/ibc/core/channel/msgs/index.ts: -------------------------------------------------------------------------------- 1 | import { MsgChannelOpenInit } from './MsgChannelOpenInit' 2 | import { MsgChannelOpenTry } from './MsgChannelOpenTry' 3 | import { MsgChannelOpenConfirm } from './MsgChannelOpenConfirm' 4 | import { MsgChannelOpenAck } from './MsgChannelOpenAck' 5 | import { MsgChannelCloseInit } from './MsgChannelCloseInit' 6 | import { MsgChannelCloseConfirm } from './MsgChannelCloseConfirm' 7 | import { MsgRecvPacket } from './MsgRecvPacket' 8 | import { MsgAcknowledgement } from './MsgRecvAcknowledgement' 9 | import { MsgTimeout } from './MsgTimeout' 10 | import { MsgTimeoutOnClose } from './MsgTimeoutClose' 11 | import { MsgUpdateIbcChannelParams } from './MsgUpdateIbcChannelParams' 12 | 13 | export * from './MsgChannelOpenInit' 14 | export * from './MsgChannelOpenTry' 15 | export * from './MsgChannelOpenConfirm' 16 | export * from './MsgChannelOpenAck' 17 | export * from './MsgChannelCloseInit' 18 | export * from './MsgChannelCloseConfirm' 19 | export * from './MsgRecvPacket' 20 | export * from './MsgRecvAcknowledgement' 21 | export * from './MsgTimeout' 22 | export * from './MsgTimeoutClose' 23 | export * from './MsgUpdateIbcChannelParams' 24 | 25 | export type IbcChannelMsg = 26 | | MsgChannelOpenInit 27 | | MsgChannelOpenTry 28 | | MsgChannelOpenConfirm 29 | | MsgChannelOpenAck 30 | | MsgChannelCloseInit 31 | | MsgChannelCloseConfirm 32 | | MsgRecvPacket 33 | | MsgAcknowledgement 34 | | MsgTimeout 35 | | MsgTimeoutOnClose 36 | | MsgUpdateIbcChannelParams 37 | 38 | export namespace IbcChannelMsg { 39 | export type Data = 40 | | MsgChannelOpenInit.Data 41 | | MsgChannelOpenTry.Data 42 | | MsgChannelOpenConfirm.Data 43 | | MsgChannelOpenAck.Data 44 | | MsgChannelCloseInit.Data 45 | | MsgChannelCloseConfirm.Data 46 | | MsgRecvPacket.Data 47 | | MsgAcknowledgement.Data 48 | | MsgTimeout.Data 49 | | MsgTimeoutOnClose.Data 50 | | MsgUpdateIbcChannelParams.Data 51 | 52 | export type Proto = 53 | | MsgChannelOpenInit.Proto 54 | | MsgChannelOpenTry.Proto 55 | | MsgChannelOpenConfirm.Proto 56 | | MsgChannelOpenAck.Proto 57 | | MsgChannelCloseInit.Proto 58 | | MsgChannelCloseConfirm.Proto 59 | | MsgRecvPacket.Proto 60 | | MsgAcknowledgement.Proto 61 | | MsgTimeout.Proto 62 | | MsgTimeoutOnClose.Proto 63 | | MsgUpdateIbcChannelParams.Proto 64 | } 65 | -------------------------------------------------------------------------------- /src/core/bank/DenomUnit.ts: -------------------------------------------------------------------------------- 1 | import { JSONSerializable } from '../../util/json' 2 | import { Denom } from '../Denom' 3 | import { DenomUnit as DenomUnit_pb } from '@initia/initia.proto/cosmos/bank/v1beta1/bank' 4 | 5 | /** 6 | * DenomUnit represents a struct that describes a given denomination unit of the basic token. 7 | */ 8 | export class DenomUnit extends JSONSerializable< 9 | DenomUnit.Amino, 10 | DenomUnit.Data, 11 | DenomUnit.Proto 12 | > { 13 | /** 14 | * @param denom the string name of the given denom unit 15 | * @param exponent power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 16 | * @param aliases list of string aliases for the given denom 17 | */ 18 | constructor( 19 | public denom: Denom, 20 | public exponent: number, 21 | public aliases: string[] 22 | ) { 23 | super() 24 | } 25 | 26 | public static fromAmino(data: DenomUnit.Amino): DenomUnit { 27 | const { denom, exponent, aliases } = data 28 | return new DenomUnit(denom, parseInt(exponent), aliases) 29 | } 30 | 31 | public toAmino(): DenomUnit.Amino { 32 | const { denom, exponent, aliases } = this 33 | return { 34 | denom, 35 | exponent: exponent.toFixed(), 36 | aliases, 37 | } 38 | } 39 | 40 | public static fromData(data: DenomUnit.Data): DenomUnit { 41 | const { denom, exponent, aliases } = data 42 | return new DenomUnit(denom, parseInt(exponent), aliases) 43 | } 44 | 45 | public toData(): DenomUnit.Data { 46 | const { denom, exponent, aliases } = this 47 | return { 48 | denom, 49 | exponent: exponent.toFixed(), 50 | aliases, 51 | } 52 | } 53 | 54 | public static fromProto(data: DenomUnit.Proto): DenomUnit { 55 | return new DenomUnit(data.denom, data.exponent, data.aliases) 56 | } 57 | 58 | public toProto(): DenomUnit.Proto { 59 | const { denom, exponent, aliases } = this 60 | return DenomUnit_pb.fromPartial({ 61 | denom, 62 | exponent, 63 | aliases, 64 | }) 65 | } 66 | } 67 | 68 | export namespace DenomUnit { 69 | export interface Amino { 70 | denom: Denom 71 | exponent: string 72 | aliases: string[] 73 | } 74 | 75 | export interface Data { 76 | denom: Denom 77 | exponent: string 78 | aliases: string[] 79 | } 80 | 81 | export type Proto = DenomUnit_pb 82 | } 83 | -------------------------------------------------------------------------------- /src/core/feegrant/allowances/BasicAllowance.spec.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import { Coins } from '../../Coins' 3 | import { BasicAllowance } from './BasicAllowance' 4 | 5 | describe('BasicAllowance', () => { 6 | it('both set', () => { 7 | const now = new Date() 8 | const ba = new BasicAllowance('1000uinit', now) 9 | 10 | expect(ba.toData().spend_limit).toEqual(new Coins('1000uinit').toData()) 11 | expect(ba.toData().expiration).toEqual(now.toISOString()) 12 | expect(ba.toProto().spendLimit).toEqual(new Coins('1000uinit').toProto()) 13 | expect(ba.toProto().expiration).toEqual(now) 14 | expect(ba.toAmino().value.spend_limit).toEqual( 15 | new Coins('1000uinit').toAmino() 16 | ) 17 | expect(ba.toAmino().value.expiration).toEqual(now.toISOString()) 18 | }) 19 | 20 | it('spend_limit only', () => { 21 | const ba = new BasicAllowance('1000uinit', undefined) 22 | 23 | expect(ba.toData().spend_limit).toEqual(new Coins('1000uinit').toData()) 24 | expect(ba.toData().expiration).toBeUndefined() 25 | expect(ba.toProto().spendLimit).toEqual(new Coins('1000uinit').toProto()) 26 | expect(ba.toProto().expiration).toBeUndefined() 27 | expect(ba.toAmino().value.spend_limit).toEqual( 28 | new Coins('1000uinit').toAmino() 29 | ) 30 | expect(ba.toAmino().value.expiration).toBeUndefined() 31 | }) 32 | 33 | it('expiration only', () => { 34 | const now = new Date() 35 | const ba = new BasicAllowance(undefined, now) 36 | 37 | expect(ba.toData().spend_limit).toEqual(undefined) 38 | expect(ba.toData().expiration).toEqual(now.toISOString()) 39 | expect(ba.toProto().spendLimit).toHaveLength(0) 40 | expect(ba.toProto().expiration).toEqual(now) 41 | expect(ba.toAmino().value.spend_limit).toBeUndefined() 42 | expect(ba.toAmino().value.expiration).toEqual(now.toISOString()) 43 | }) 44 | 45 | it('spend_limit has zero amount', () => { 46 | expect(() => new BasicAllowance('1uinit,-1uinit', undefined)).toThrowError() 47 | expect(() => new BasicAllowance('0uinit', undefined)).toThrowError() 48 | expect(() => new BasicAllowance('-1204uinit', undefined)).toThrowError() 49 | }) 50 | 51 | it('allow both empty', () => { 52 | const ba = new BasicAllowance() 53 | expect(ba.spend_limit).toBeUndefined() 54 | expect(ba.expiration).toBeUndefined() 55 | }) 56 | }) 57 | -------------------------------------------------------------------------------- /src/core/ibc/core/channel/PacketId.ts: -------------------------------------------------------------------------------- 1 | import { PacketId as PacketId_pb } from '@initia/initia.proto/ibc/core/channel/v1/channel' 2 | import { JSONSerializable } from '../../../../util/json' 3 | 4 | /** 5 | * PacketId is an identifier for a unique Packet. 6 | * Source chains refer to packets by source port/channel. 7 | * Destination chains refer to packets by destination port/channel. 8 | */ 9 | export class PacketId extends JSONSerializable< 10 | PacketId.Amino, 11 | PacketId.Data, 12 | PacketId.Proto 13 | > { 14 | /** 15 | * @param port_id channel port identifier 16 | * @param channel_id channel unique identifier 17 | * @param sequence packet sequence 18 | */ 19 | constructor( 20 | public port_id: string, 21 | public channel_id: string, 22 | public sequence: number 23 | ) { 24 | super() 25 | } 26 | 27 | public static fromAmino(data: PacketId.Amino): PacketId { 28 | const { port_id, channel_id, sequence } = data 29 | return new PacketId(port_id, channel_id, parseInt(sequence)) 30 | } 31 | 32 | public toAmino(): PacketId.Amino { 33 | const { port_id, channel_id, sequence } = this 34 | return { 35 | port_id, 36 | channel_id, 37 | sequence: sequence.toFixed(), 38 | } 39 | } 40 | 41 | public static fromData(data: PacketId.Data): PacketId { 42 | const { port_id, channel_id, sequence } = data 43 | return new PacketId(port_id, channel_id, parseInt(sequence)) 44 | } 45 | 46 | public toData(): PacketId.Data { 47 | const { port_id, channel_id, sequence } = this 48 | return { 49 | port_id, 50 | channel_id, 51 | sequence: sequence.toFixed(), 52 | } 53 | } 54 | 55 | public static fromProto(proto: PacketId.Proto): PacketId { 56 | return new PacketId(proto.portId, proto.channelId, Number(proto.sequence)) 57 | } 58 | 59 | public toProto(): PacketId.Proto { 60 | const { port_id, channel_id, sequence } = this 61 | return PacketId_pb.fromPartial({ 62 | portId: port_id, 63 | channelId: channel_id, 64 | sequence: BigInt(sequence), 65 | }) 66 | } 67 | } 68 | 69 | export namespace PacketId { 70 | export interface Amino { 71 | port_id: string 72 | channel_id: string 73 | sequence: string 74 | } 75 | 76 | export interface Data { 77 | port_id: string 78 | channel_id: string 79 | sequence: string 80 | } 81 | 82 | export type Proto = PacketId_pb 83 | } 84 | --------------------------------------------------------------------------------