From 795100b42dba2bdfb320d0aefafc347de60b1b40 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Sun, 24 Dec 2023 00:43:57 +0700 Subject: [PATCH 01/16] feat: api v1 - contract migration table --- CHANGELOG.md | 1 + src/lib/app-provider/env.ts | 2 +- .../tables/RelatedProposalsTable.tsx | 10 +-- src/lib/query/proposal.ts | 29 -------- src/lib/services/proposal.ts | 74 ++++++++++++++++--- src/lib/services/proposalService.ts | 55 +++++--------- 6 files changed, 87 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f519353e2..b1dbfbc01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#697](https://github.com/alleslabs/celatone-frontend/pull/697) api v1 - contract tables (migrations and related proposals) - [#696](https://github.com/alleslabs/celatone-frontend/pull/696) api v1 - block details - [#667](https://github.com/alleslabs/celatone-frontend/pull/667) Adjust for search bar consistency - [#692](https://github.com/alleslabs/celatone-frontend/pull/692) Add verify link for mahalo diff --git a/src/lib/app-provider/env.ts b/src/lib/app-provider/env.ts index 82398825a..4de35a268 100644 --- a/src/lib/app-provider/env.ts +++ b/src/lib/app-provider/env.ts @@ -64,7 +64,7 @@ export enum CELATONE_QUERY_KEYS { // FAUCET FAUCET_INFO = "CELATONE_QUERY_FAUCET_INFO", // X/GOV - RELATED_PROPOSALS_BY_CONTRACT_ADDRESS_PAGINATION = "CELATONE_QUERY_RELATED_PROPOSALS_BY_CONTRACT_ADDRESS_PAGINATION", + RELATED_PROPOSALS_BY_CONTRACT_ADDRESS = "CELATONE_QUERY_RELATED_PROPOSALS_BY_CONTRACT_ADDRESS", RELATED_PROPOSALS_BY_CONTRACT_ADDRESS_COUNT = "CELATONE_QUERY_RELATED_PROPOSALS_BY_CONTRACT_ADDRESS_COUNT", PROPOSALS_BY_WALLET_ADDRESS_PAGINATION = "CELATONE_QUERY_PROPOSALS_BY_WALLET_ADDRESS_PAGINATION", PROPOSALS_BY_WALLET_ADDRESS_COUNT = "CELATONE_QUERY_PROPOSALS_BY_WALLET_ADDRESS_COUNT", diff --git a/src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx b/src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx index 38c44a3dc..2541ed62e 100644 --- a/src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx +++ b/src/lib/pages/contract-details/components/tables/RelatedProposalsTable.tsx @@ -4,7 +4,7 @@ import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; import { EmptyState, ErrorFetching } from "lib/components/state"; import { ProposalsTable } from "lib/components/table"; -import { useRelatedProposalsByContractAddressPagination } from "lib/services/proposalService"; +import { useRelatedProposalsByContractAddress } from "lib/services/proposalService"; import type { ContractAddr, Option } from "lib/types"; interface RelatedProposalsTableProps { @@ -40,11 +40,7 @@ export const RelatedProposalsTable = ({ data: relatedProposals, isLoading, error, - } = useRelatedProposalsByContractAddressPagination( - contractAddress, - offset, - pageSize - ); + } = useRelatedProposalsByContractAddress(contractAddress, offset, pageSize); const onPageChange = (nextPage: number) => { refetchCount(); @@ -61,7 +57,7 @@ export const RelatedProposalsTable = ({ return ( <> ; +export type ProposalsResponse = z.infer; export const getProposalsByAddress = async ( endpoint: string, address: Addr, limit: number, offset: number -): Promise => +): Promise => axios .get(`${endpoint}/${encodeURIComponent(address)}/proposals`, { params: { @@ -108,4 +108,54 @@ export const getProposalsByAddress = async ( offset, }, }) - .then((res) => zProposalResponse.parse(res.data)); + .then((res) => zProposalsResponse.parse(res.data)); + +const zRelatedProposalsResponseItem = z + .object({ + deposit_end_time: zUtcDate, + proposal_id: z.number().nonnegative(), + is_expedited: z.boolean(), + proposer: zAddr, + resolved_height: z.number().nullish(), + status: z.string().transform(parseProposalStatus), + title: z.string(), + type: z.string(), + voting_end_time: zUtcDate, + }) + .transform((val) => ({ + depositEndTime: val.deposit_end_time, + proposalId: val.proposal_id, + isExpedited: val.is_expedited, + proposer: val.proposer, + resolvedHeight: val.resolved_height, + status: val.status, + title: val.title, + type: val.type as ProposalType, // TODO: remove type assertion + votingEndTime: val.voting_end_time, + })); + +const zRelatedProposalsResponse = z.object({ + items: z.array(zRelatedProposalsResponseItem), +}); + +export type RelatedProposalsResponse = z.infer< + typeof zRelatedProposalsResponse +>; + +export const getRelatedProposalsByContractAddress = async ( + endpoint: string, + contractAddress: ContractAddr, + limit: number, + offset: number +): Promise => + axios + .get( + `${endpoint}/${encodeURIComponent(contractAddress)}/related-proposals`, + { + params: { + limit, + offset, + }, + } + ) + .then((res) => zRelatedProposalsResponse.parse(res.data)); diff --git a/src/lib/services/proposalService.ts b/src/lib/services/proposalService.ts index ca12c0d18..3d2583bea 100644 --- a/src/lib/services/proposalService.ts +++ b/src/lib/services/proposalService.ts @@ -14,7 +14,6 @@ import { getProposalsByWalletAddressPagination, getProposalsCountByWalletAddress, getProposalTypes, - getRelatedProposalsByContractAddressPagination, getRelatedProposalsByModuleIdPagination, getRelatedProposalsCountByContractAddress, getRelatedProposalsCountByModuleId, @@ -44,7 +43,8 @@ import { useAssetInfos } from "./assetService"; import { useProposalListExpression } from "./expression"; import type { DepositParamsInternal, - ProposalResponse, + ProposalsResponse, + RelatedProposalsResponse, UploadAccess, VotingParamsInternal, } from "./proposal"; @@ -53,49 +53,34 @@ import { fetchGovDepositParams, fetchGovUploadAccessParams, getProposalsByAddress, + getRelatedProposalsByContractAddress, } from "./proposal"; -export const useRelatedProposalsByContractAddressPagination = ( +export const useRelatedProposalsByContractAddress = ( contractAddress: ContractAddr, offset: number, - pageSize: number -): UseQueryResult => { - const { indexerGraphClient } = useCelatoneApp(); - - const queryFn = useCallback(async () => { - return indexerGraphClient - .request(getRelatedProposalsByContractAddressPagination, { - contractAddress, - offset, - pageSize, - }) - .then(({ contract_proposals }) => - contract_proposals.map((proposal) => ({ - proposalId: proposal.proposal_id, - title: proposal.proposal.title, - status: parseProposalStatus(proposal.proposal.status), - votingEndTime: parseDate(proposal.proposal.voting_end_time), - depositEndTime: parseDate(proposal.proposal.deposit_end_time), - resolvedHeight: proposal.resolved_height, - type: proposal.proposal.type as ProposalType, - proposer: proposal.proposal.account?.address as Addr, - isExpedited: Boolean(proposal.proposal.is_expedited), - })) - ); - }, [contractAddress, offset, pageSize, indexerGraphClient]); + limit: number +) => { + const endpoint = useBaseApiRoute("contracts"); - return useQuery( + return useQuery( [ - CELATONE_QUERY_KEYS.RELATED_PROPOSALS_BY_CONTRACT_ADDRESS_PAGINATION, + CELATONE_QUERY_KEYS.RELATED_PROPOSALS_BY_CONTRACT_ADDRESS, + endpoint, contractAddress, + limit, offset, - pageSize, - indexerGraphClient, ], - queryFn, + async () => + getRelatedProposalsByContractAddress( + endpoint, + contractAddress, + limit, + offset + ), { + retry: 1, keepPreviousData: true, - enabled: !!contractAddress, } ); }; @@ -134,7 +119,7 @@ export const useProposalsByAddress = ( address: Addr, offset: number, limit: number -): UseQueryResult => { +): UseQueryResult => { const endpoint = useBaseApiRoute("accounts"); return useQuery( From dbc2deca74c6a4e126aa111a975e917ff42cb462 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Sun, 24 Dec 2023 02:06:46 +0700 Subject: [PATCH 02/16] feat: api v1 - contract migration table --- src/lib/app-provider/env.ts | 2 +- src/lib/app-provider/hooks/useBaseApiRoute.ts | 2 +- .../components/tables/migration/index.tsx | 40 +++++------ src/lib/pages/contract-details/data.ts | 37 +++++----- src/lib/query/contract.ts | 32 --------- src/lib/services/account.ts | 4 +- src/lib/services/asset.ts | 2 +- src/lib/services/balance.ts | 2 +- src/lib/services/block.ts | 4 +- src/lib/services/code.ts | 2 +- src/lib/services/contract.ts | 67 +++++++++++++++---- src/lib/services/contractService.ts | 56 ++++++---------- src/lib/services/delegation.ts | 2 +- src/lib/services/move/module.ts | 4 +- src/lib/services/move/pool.ts | 2 +- src/lib/services/move/resource.ts | 2 +- src/lib/services/overview.ts | 2 +- src/lib/services/proposal.ts | 4 +- src/lib/services/tx.ts | 10 +-- src/lib/types/contract.ts | 23 ++++--- src/lib/types/tx/transaction.ts | 4 +- 21 files changed, 149 insertions(+), 154 deletions(-) diff --git a/src/lib/app-provider/env.ts b/src/lib/app-provider/env.ts index 4de35a268..acb633529 100644 --- a/src/lib/app-provider/env.ts +++ b/src/lib/app-provider/env.ts @@ -45,7 +45,7 @@ export enum CELATONE_QUERY_KEYS { INSTANTIATED_LIST_BY_WALLET_ADDRESS = "CELATONE_QUERY_INSTANTIATED_LIST_BY_WALLET_ADDRESS", ADMIN_CONTRACTS_BY_ADDRESS = "CELATONE_QUERY_ADMIN_CONTRACTS_BY_ADDRESS", ADMINS_BY_CONTRACTS = "CELATONE_QUERY_ADMINS_BY_CONTRACTS", - CONTRACT_MIGRATION_HISTORIES_PAGINATION = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_PAGINATION", + CONTRACT_MIGRATION_HISTORIES = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES", CONTRACT_MIGRATION_HISTORIES_COUNT = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_COUNT", CONTRACTS_BY_CODE_ID_PAGINATION = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_PAGINATION", CONTRACTS_BY_CODE_ID_COUNT = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_COUNT", diff --git a/src/lib/app-provider/hooks/useBaseApiRoute.ts b/src/lib/app-provider/hooks/useBaseApiRoute.ts index e52f774f3..6ada0d430 100644 --- a/src/lib/app-provider/hooks/useBaseApiRoute.ts +++ b/src/lib/app-provider/hooks/useBaseApiRoute.ts @@ -46,7 +46,7 @@ export const useBaseApiRoute = ( case "projects": return `${api}/projects/${chain}/${currentChainId}`; case "contracts": - return `${api}/contracts/${chain}/${currentChainId}`; + return `${api}/v1/${chain}/${currentChainId}/contracts`; case "codes": return `${api}/codes/${chain}/${currentChainId}`; case "legacy.accounts": diff --git a/src/lib/pages/contract-details/components/tables/migration/index.tsx b/src/lib/pages/contract-details/components/tables/migration/index.tsx index 70d45e1bf..1f9d946bd 100644 --- a/src/lib/pages/contract-details/components/tables/migration/index.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/index.tsx @@ -1,9 +1,8 @@ -import type { ChangeEvent } from "react"; - import { useMobile } from "lib/app-provider"; +import { Loading } from "lib/components/Loading"; import { Pagination } from "lib/components/pagination"; import { usePaginator } from "lib/components/pagination/usePaginator"; -import { EmptyState } from "lib/components/state"; +import { EmptyState, ErrorFetching } from "lib/components/state"; import { MobileTableContainer, TableContainer } from "lib/components/table"; import { useMigrationHistories } from "lib/pages/contract-details/data"; import type { ContractAddr, Option } from "lib/types"; @@ -42,26 +41,15 @@ export const MigrationTable = ({ }, }); - // TODO: loading state - const migrationHistories = useMigrationHistories( + const { data, isLoading, error } = useMigrationHistories( contractAddress, offset, pageSize ); - const onPageChange = (nextPage: number) => { - refetchCount(); - setCurrentPage(nextPage); - }; - - const onPageSizeChange = (e: ChangeEvent) => { - const size = Number(e.target.value); - refetchCount(); - setPageSize(size); - setCurrentPage(1); - }; - - if (!migrationHistories?.length) + if (isLoading) return ; + if (error) return ; + if (!data?.items.length) return ( {isMobile ? ( - {migrationHistories.map((history, idx) => ( + {data.items.map((history, idx) => ( - {migrationHistories.map((history, idx) => ( + {data.items.map((history, idx) => ( { + refetchCount(); + setCurrentPage(nextPage); + }} + onPageSizeChange={(e) => { + const size = Number(e.target.value); + refetchCount(); + setPageSize(size); + setCurrentPage(1); + }} /> )} diff --git a/src/lib/pages/contract-details/data.ts b/src/lib/pages/contract-details/data.ts index b1676c01a..ec2ee0038 100644 --- a/src/lib/pages/contract-details/data.ts +++ b/src/lib/pages/contract-details/data.ts @@ -12,13 +12,13 @@ import { queryContract, queryContractCw2Info } from "lib/services/contract"; import { useContractDetailByContractAddress, useInstantiateDetailByContractQuery, - useMigrationHistoriesByContractAddressPagination, + useMigrationHistoriesByContractAddress, } from "lib/services/contractService"; import { usePublicProjectByContractAddress, usePublicProjectBySlug, } from "lib/services/publicProjectService"; -import type { ContractAddr, ContractMigrationHistory, Option } from "lib/types"; +import type { ContractAddr, ContractMigrationHistory } from "lib/types"; import { coinToTokenWithValue, compareTokenWithValues } from "lib/utils"; import type { ContractData } from "./types"; @@ -101,22 +101,23 @@ export const useMigrationHistories = ( contractAddress: ContractAddr, offset: number, pageSize: number -): Option => { - const { data: migrationData } = - useMigrationHistoriesByContractAddressPagination( - contractAddress, - offset, - pageSize - ); +) => { const { getCodeLocalInfo } = useCodeStore(); + const { data, ...res } = useMigrationHistoriesByContractAddress( + contractAddress, + offset, + pageSize + ); - if (!migrationData) return undefined; - - return migrationData.map((data) => { - const localInfo = getCodeLocalInfo(data.codeId); - return { - ...data, - codeName: localInfo?.name, - }; - }); + return { + data: data + ? { + items: data.items.map((migration) => ({ + ...migration, + codeName: getCodeLocalInfo(migration.codeId)?.name, + })), + } + : undefined, + ...res, + }; }; diff --git a/src/lib/query/contract.ts b/src/lib/query/contract.ts index 899a788af..8ae577ad2 100644 --- a/src/lib/query/contract.ts +++ b/src/lib/query/contract.ts @@ -184,38 +184,6 @@ export const getContractListCountByCodeId = graphql(` } `); -export const getMigrationHistoriesByContractAddressPagination = graphql(` - query getMigrationHistoriesByContractAddress( - $contractAddress: String! - $offset: Int! - $pageSize: Int! - ) { - contract_histories( - where: { contract: { address: { _eq: $contractAddress } } } - order_by: { block: { timestamp: desc } } - limit: $pageSize - offset: $offset - ) { - code_id - account { - address - } - block { - height - timestamp - } - remark - code { - account { - address - } - cw2_contract - cw2_version - } - } - } -`); - export const getMigrationHistoriesCountByContractAddress = graphql(` query getMigrationHistoriesCountByContractAddress($contractAddress: String!) { contract_histories_aggregate( diff --git a/src/lib/services/account.ts b/src/lib/services/account.ts index 4847f3823..39576cdd2 100644 --- a/src/lib/services/account.ts +++ b/src/lib/services/account.ts @@ -28,7 +28,7 @@ export const getAccountInfo = async ( ): Promise => axios .get(`${endpoint}/${encodeURIComponent(address)}/info`) - .then((res) => zAccountInfo.parse(res.data)); + .then(({ data }) => zAccountInfo.parse(data)); const zAccountTableCounts = z .object({ @@ -61,4 +61,4 @@ export const getAccountTableCounts = async ( is_wasm: isWasm, }, }) - .then((res) => zAccountTableCounts.parse(res.data)); + .then(({ data }) => zAccountTableCounts.parse(data)); diff --git a/src/lib/services/asset.ts b/src/lib/services/asset.ts index f4184d003..5df6b3b0c 100644 --- a/src/lib/services/asset.ts +++ b/src/lib/services/asset.ts @@ -14,4 +14,4 @@ export const getAssetInfos = async ( with_prices: withPrices, }, }) - .then((res) => z.array(zAssetInfo).parse(res.data)); + .then(({ data }) => z.array(zAssetInfo).parse(data)); diff --git a/src/lib/services/balance.ts b/src/lib/services/balance.ts index bacf6644d..8657450f9 100644 --- a/src/lib/services/balance.ts +++ b/src/lib/services/balance.ts @@ -19,4 +19,4 @@ export const getBalances = async ( ): Promise => axios .get(`${endpoint}/${encodeURIComponent(address)}/balances`) - .then((res) => zBalancesResponse.parse(res.data)); + .then(({ data }) => zBalancesResponse.parse(data)); diff --git a/src/lib/services/block.ts b/src/lib/services/block.ts index 0a9c4752e..7f61a8e4e 100644 --- a/src/lib/services/block.ts +++ b/src/lib/services/block.ts @@ -54,7 +54,7 @@ export const getBlocks = async ( offset, }, }) - .then((res) => zBlocksResponse.parse(res.data)); + .then(({ data }) => zBlocksResponse.parse(data)); const zBlockDataResponse = z .object({ @@ -77,4 +77,4 @@ const zBlockDataResponse = z export const getBlockData = async (endpoint: string, height: number) => axios .get(`${endpoint}/${height}/info`) - .then((res) => zBlockDataResponse.parse(res.data)); + .then(({ data }) => zBlockDataResponse.parse(data)); diff --git a/src/lib/services/code.ts b/src/lib/services/code.ts index 248837306..1e9210bc1 100644 --- a/src/lib/services/code.ts +++ b/src/lib/services/code.ts @@ -72,4 +72,4 @@ export const getCodesByAddress = async ( offset, }, }) - .then((res) => zCodesResponse.parse(res.data)); + .then(({ data }) => zCodesResponse.parse(data)); diff --git a/src/lib/services/contract.ts b/src/lib/services/contract.ts index 64290963f..78c137296 100644 --- a/src/lib/services/contract.ts +++ b/src/lib/services/contract.ts @@ -7,10 +7,14 @@ import type { Option, PublicInfo, ContractInfo, - ContractHistoryRemark, - RemarkType, + ContractMigrationHistory, +} from "lib/types"; +import { + zAddr, + zContractAddr, + zContractHistoryRemark, + zUtcDate, } from "lib/types"; -import { RemarkOperation, zAddr, zContractAddr, zUtcDate } from "lib/types"; import { encode, libDecode } from "lib/utils"; export interface ContractCw2InfoRaw { @@ -105,17 +109,7 @@ const zContractsResponseItem = z instantiator: zAddr, latest_updated: zUtcDate, latest_updater: zAddr, - remark: z - .object({ - operation: z.nativeEnum(RemarkOperation), - type: z.string(), - value: z.string(), - }) - .transform((val) => ({ - operation: val.operation, - type: val.type as RemarkType, // TODO: remove type assertion, - value: val.value, - })), + remark: zContractHistoryRemark, }) .transform((val) => ({ contractAddress: val.contract_address, @@ -166,3 +160,48 @@ export const getAdminContractsByAddress = async ( }, }) .then(({ data }) => zContractsResponse.parse(data)); + +const zMigrationHistoriesResponseItem = z + .object({ + code_id: z.number(), + cw2_contract: z.string().nullable(), + cw2_version: z.string().nullable(), + height: z.number(), + remark: zContractHistoryRemark, + sender: zAddr, + timestamp: zUtcDate, + uploader: zAddr, + }) + .transform((val) => ({ + codeId: val.code_id, + cw2Contract: val.cw2_contract, + cw2Version: val.cw2_version, + height: val.height, + remark: val.remark, + sender: val.sender, + timestamp: val.timestamp, + uploader: val.uploader, + })); + +const zMigrationHistoriesResponse = z.object({ + items: z.array(zMigrationHistoriesResponseItem), +}); + +export type MigrationHistoriesResponse = z.infer< + typeof zMigrationHistoriesResponse +>; + +export const getMigrationHistoriesByContractAddress = async ( + endpoint: string, + contractAddress: ContractAddr, + limit: number, + offset: number +) => + axios + .get(`${endpoint}/${encodeURIComponent(contractAddress)}/migrations`, { + params: { + limit, + offset, + }, + }) + .then(({ data }) => zMigrationHistoriesResponse.parse(data)); diff --git a/src/lib/services/contractService.ts b/src/lib/services/contractService.ts index 2a9b27bb7..953b184a0 100644 --- a/src/lib/services/contractService.ts +++ b/src/lib/services/contractService.ts @@ -22,14 +22,12 @@ import { getInstantiatedCountByUserQueryDocument, getInstantiateDetailByContractQueryDocument, getInstantiatedListByUserQueryDocument, - getMigrationHistoriesByContractAddressPagination, getMigrationHistoriesCountByContractAddress, } from "lib/query"; import { createQueryFnWithTimeout } from "lib/query-utils"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { ContractAddr, - ContractMigrationHistory, HumanAddr, Option, Dict, @@ -37,13 +35,14 @@ import type { ContractInfo, Nullable, } from "lib/types"; -import { parseDate, parseTxHashOpt, parseDateOpt } from "lib/utils"; +import { parseTxHashOpt, parseDateOpt } from "lib/utils"; import { getCodeIdInfo } from "./code"; +import type { ContractsResponse, MigrationHistoriesResponse } from "./contract"; import { - type ContractsResponse, getAdminContractsByAddress, getInstantiatedContractsByAddress, + getMigrationHistoriesByContractAddress, } from "./contract"; export interface ContractDetail extends ContractLocalInfo { @@ -308,48 +307,31 @@ export const useAdminByContractAddresses = ( ); }; -export const useMigrationHistoriesByContractAddressPagination = ( +export const useMigrationHistoriesByContractAddress = ( contractAddress: ContractAddr, offset: number, - pageSize: number -): UseQueryResult[]> => { - const { indexerGraphClient } = useCelatoneApp(); - - const queryFn = useCallback(async () => { - return indexerGraphClient - .request(getMigrationHistoriesByContractAddressPagination, { - contractAddress, - offset, - pageSize, - }) - .then(({ contract_histories }) => - contract_histories.map>( - (history) => ({ - codeId: history.code_id, - sender: history.account.address as Addr, - height: history.block.height, - timestamp: parseDate(history.block.timestamp), - remark: history.remark, - uploader: history.code.account.address as Addr, - cw2Contract: history.code.cw2_contract, - cw2Version: history.code.cw2_version, - }) - ) - ); - }, [contractAddress, offset, pageSize, indexerGraphClient]); + limit: number +) => { + const endpoint = useBaseApiRoute("contracts"); - return useQuery( + return useQuery( [ - CELATONE_QUERY_KEYS.CONTRACT_MIGRATION_HISTORIES_PAGINATION, + CELATONE_QUERY_KEYS.CONTRACT_MIGRATION_HISTORIES, + endpoint, contractAddress, + limit, offset, - pageSize, - indexerGraphClient, ], - queryFn, + async () => + getMigrationHistoriesByContractAddress( + endpoint, + contractAddress, + limit, + offset + ), { keepPreviousData: true, - enabled: Boolean(contractAddress), + retry: 1, } ); }; diff --git a/src/lib/services/delegation.ts b/src/lib/services/delegation.ts index 15fda6a46..5d29e37ef 100644 --- a/src/lib/services/delegation.ts +++ b/src/lib/services/delegation.ts @@ -339,4 +339,4 @@ export const getAccountDelegations = async ( ): Promise => axios .get(`${endpoint}/${encodeURIComponent(address)}/delegations`) - .then((res) => zAccountDelegations.parse(res.data)); + .then(({ data }) => zAccountDelegations.parse(data)); diff --git a/src/lib/services/move/module.ts b/src/lib/services/move/module.ts index 7b3615b5a..c861cae80 100644 --- a/src/lib/services/move/module.ts +++ b/src/lib/services/move/module.ts @@ -51,7 +51,7 @@ export const getAPIAccountModules = async ( ): Promise => axios .get(`${endpoint}/${encodeURIComponent(address)}/move/modules`) - .then((res) => zAccountModulesResponse.parse(res.data)); + .then(({ data }) => zAccountModulesResponse.parse(data)); export const getAccountModules = async ( baseEndpoint: string, @@ -196,4 +196,4 @@ export const getModules = async ( offset, }, }) - .then((res) => zModulesResponse.parse(res.data)); + .then(({ data }) => zModulesResponse.parse(data)); diff --git a/src/lib/services/move/pool.ts b/src/lib/services/move/pool.ts index 0a0e8d845..d15992d04 100644 --- a/src/lib/services/move/pool.ts +++ b/src/lib/services/move/pool.ts @@ -43,4 +43,4 @@ const zPairResponse = z export const getMovePoolInfos = async (endpoint: string) => axios .get(`${endpoint}/pools`) - .then((res) => z.array(zPairResponse).parse(res.data)); + .then(({ data }) => z.array(zPairResponse).parse(data)); diff --git a/src/lib/services/move/resource.ts b/src/lib/services/move/resource.ts index 8d5e322f9..08d914c12 100644 --- a/src/lib/services/move/resource.ts +++ b/src/lib/services/move/resource.ts @@ -29,4 +29,4 @@ export const getAccountResources = async ( ): Promise => axios .get(`${endpoint}/${encodeURIComponent(address)}/move/resources`) - .then((res) => zResourcesResponse.parse(res.data)); + .then(({ data }) => zResourcesResponse.parse(data)); diff --git a/src/lib/services/overview.ts b/src/lib/services/overview.ts index 1b0381635..03919207c 100644 --- a/src/lib/services/overview.ts +++ b/src/lib/services/overview.ts @@ -20,4 +20,4 @@ export const getOverviewsStats = async ( ): Promise => axios .get(`${endpoint}/stats`) - .then((res) => zOverviewsStatsResponse.parse(res.data)); + .then(({ data }) => zOverviewsStatsResponse.parse(data)); diff --git a/src/lib/services/proposal.ts b/src/lib/services/proposal.ts index 8ccd78c8e..44e1a0be3 100644 --- a/src/lib/services/proposal.ts +++ b/src/lib/services/proposal.ts @@ -108,7 +108,7 @@ export const getProposalsByAddress = async ( offset, }, }) - .then((res) => zProposalsResponse.parse(res.data)); + .then(({ data }) => zProposalsResponse.parse(data)); const zRelatedProposalsResponseItem = z .object({ @@ -158,4 +158,4 @@ export const getRelatedProposalsByContractAddress = async ( }, } ) - .then((res) => zRelatedProposalsResponse.parse(res.data)); + .then(({ data }) => zRelatedProposalsResponse.parse(data)); diff --git a/src/lib/services/tx.ts b/src/lib/services/tx.ts index ab4af4f96..b8fa5d7ba 100644 --- a/src/lib/services/tx.ts +++ b/src/lib/services/tx.ts @@ -179,7 +179,7 @@ export const getTxs = async ( is_initia: isInitia, }, }) - .then((res) => zTxsResponse.parse(res.data)); + .then(({ data }) => zTxsResponse.parse(data)); const zAccountTxsResponseItem = zBaseTxsResponseItem .extend({ @@ -259,7 +259,7 @@ export const getTxsByAddress = async ( ...(search !== undefined && { search }), }, }) - .then((res) => zAccountTxsResponse.parse(res.data)); + .then(({ data }) => zAccountTxsResponse.parse(data)); }; const zBlockTxsResponse = z.object({ @@ -287,7 +287,7 @@ export const getTxsByBlockHeight = async ( is_initia: isInitia, }, }) - .then((res) => zBlockTxsResponse.parse(res.data)); + .then(({ data }) => zBlockTxsResponse.parse(data)); const zModuleTxsResponse = z.object({ items: z.array(zTxsResponseItem), @@ -317,7 +317,7 @@ export const getTxsByModule = async ( }, } ) - .then((res) => zModuleTxsResponse.parse(res.data)); + .then(({ data }) => zModuleTxsResponse.parse(data)); const zTxsCountResponse = z .object({ @@ -344,5 +344,5 @@ export const getAPITxsCountByAddress = async ( ...(search !== undefined && { search }), }, }) - .then((res) => zTxsCountResponse.parse(res.data)); + .then(({ data }) => zTxsCountResponse.parse(data)); }; diff --git a/src/lib/types/contract.ts b/src/lib/types/contract.ts index 249be4e80..03693d2da 100644 --- a/src/lib/types/contract.ts +++ b/src/lib/types/contract.ts @@ -1,5 +1,10 @@ +import { z } from "zod"; + import type { ContractLocalInfo } from "lib/stores/contract"; -import type { Addr, Nullable, Option, RemarkType } from "lib/types"; + +import type { Addr } from "./addrs"; +import type { Nullable, Option } from "./common"; +import { zRemarkType } from "./tx"; export enum RemarkOperation { CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT", @@ -7,11 +12,13 @@ export enum RemarkOperation { CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS", } -export interface ContractHistoryRemark { - operation: RemarkOperation; - type: RemarkType; - value: string | number; -} +export const zContractHistoryRemark = z.object({ + operation: z.nativeEnum(RemarkOperation), + type: zRemarkType, + value: z.union([z.string(), z.number()]), +}); + +export type ContractHistoryRemark = z.infer; export interface ContractInfo extends ContractLocalInfo { admin: Option; @@ -28,6 +35,6 @@ export interface ContractMigrationHistory { timestamp: Date; remark: ContractHistoryRemark; uploader: Addr; - cw2Contract: Option>; - cw2Version: Option>; + cw2Contract: Nullable; + cw2Version: Nullable; } diff --git a/src/lib/types/tx/transaction.ts b/src/lib/types/tx/transaction.ts index 0507c8ad0..256fdb0e3 100644 --- a/src/lib/types/tx/transaction.ts +++ b/src/lib/types/tx/transaction.ts @@ -1,4 +1,5 @@ import type { Log } from "@cosmjs/stargate/build/logs"; +import { z } from "zod"; import type { Addr, Option } from "lib/types"; @@ -81,4 +82,5 @@ export type PoolTxFilter = | "is_collect" | "is_migrate"; -export type RemarkType = "genesis" | "governance" | "transaction"; +export const zRemarkType = z.enum(["genesis", "governance", "transaction"]); +export type RemarkType = z.infer; From a1babf0682251102b084b510ae7989391a34f9f3 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Sun, 24 Dec 2023 02:10:44 +0700 Subject: [PATCH 03/16] fix: revert file --- src/lib/app-provider/hooks/useBaseApiRoute.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/app-provider/hooks/useBaseApiRoute.ts b/src/lib/app-provider/hooks/useBaseApiRoute.ts index 6ada0d430..e52f774f3 100644 --- a/src/lib/app-provider/hooks/useBaseApiRoute.ts +++ b/src/lib/app-provider/hooks/useBaseApiRoute.ts @@ -46,7 +46,7 @@ export const useBaseApiRoute = ( case "projects": return `${api}/projects/${chain}/${currentChainId}`; case "contracts": - return `${api}/v1/${chain}/${currentChainId}/contracts`; + return `${api}/contracts/${chain}/${currentChainId}`; case "codes": return `${api}/codes/${chain}/${currentChainId}`; case "legacy.accounts": From d6d795e71b8d5a3a928e2e2b7138a96cb083d24c Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Sun, 24 Dec 2023 02:14:03 +0700 Subject: [PATCH 04/16] fix: rename query key --- src/lib/app-provider/env.ts | 2 +- src/lib/services/contractService.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/app-provider/env.ts b/src/lib/app-provider/env.ts index acb633529..51251db24 100644 --- a/src/lib/app-provider/env.ts +++ b/src/lib/app-provider/env.ts @@ -45,7 +45,7 @@ export enum CELATONE_QUERY_KEYS { INSTANTIATED_LIST_BY_WALLET_ADDRESS = "CELATONE_QUERY_INSTANTIATED_LIST_BY_WALLET_ADDRESS", ADMIN_CONTRACTS_BY_ADDRESS = "CELATONE_QUERY_ADMIN_CONTRACTS_BY_ADDRESS", ADMINS_BY_CONTRACTS = "CELATONE_QUERY_ADMINS_BY_CONTRACTS", - CONTRACT_MIGRATION_HISTORIES = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES", + CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS", CONTRACT_MIGRATION_HISTORIES_COUNT = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_COUNT", CONTRACTS_BY_CODE_ID_PAGINATION = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_PAGINATION", CONTRACTS_BY_CODE_ID_COUNT = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_COUNT", diff --git a/src/lib/services/contractService.ts b/src/lib/services/contractService.ts index 953b184a0..66609b307 100644 --- a/src/lib/services/contractService.ts +++ b/src/lib/services/contractService.ts @@ -316,7 +316,7 @@ export const useMigrationHistoriesByContractAddress = ( return useQuery( [ - CELATONE_QUERY_KEYS.CONTRACT_MIGRATION_HISTORIES, + CELATONE_QUERY_KEYS.CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS, endpoint, contractAddress, limit, From 2f1fbbac061dde246e566fdf58b72f21e8d0b00e Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 25 Dec 2023 15:03:19 +0700 Subject: [PATCH 05/16] feat: add ledger --- CHANGELOG.md | 1 + package.json | 10 +-- yarn.lock | 191 +++++++++++++++++++++++++-------------------------- 3 files changed, 99 insertions(+), 103 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d04a3ce0f..087004138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#698](https://github.com/alleslabs/celatone-frontend/pull/698) Add ledger - [#686](https://github.com/alleslabs/celatone-frontend/pull/686) Add amp module list, my published module, and resources/module tab - [#664](https://github.com/alleslabs/celatone-frontend/pull/664) Add Vercel speed insights and analytics - [#677](https://github.com/alleslabs/celatone-frontend/pull/677) Add minimove-1 and miniwasm-1 diff --git a/package.json b/package.json index 1d119a9ae..3cfcfb7c0 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,11 @@ "@cosmjs/encoding": "0.31.3", "@cosmjs/proto-signing": "0.31.3", "@cosmjs/stargate": "0.31.3", - "@cosmos-kit/compass": "2.4.5", - "@cosmos-kit/core": "2.7.4", - "@cosmos-kit/keplr": "2.4.6", - "@cosmos-kit/react": "2.9.5", - "@cosmos-kit/station": "2.4.4", + "@cosmos-kit/compass": "2.5.1", + "@cosmos-kit/core": "2.7.11", + "@cosmos-kit/keplr": "2.5.1", + "@cosmos-kit/react": "2.9.15", + "@cosmos-kit/station": "2.4.11", "@emotion/react": "^11", "@emotion/styled": "^11", "@graphql-codegen/cli": "^2.13.12", diff --git a/yarn.lock b/yarn.lock index 736eac7e0..8f619ddf4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -658,10 +658,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@chain-registry/keplr@1.25.0": - version "1.25.0" - resolved "https://registry.yarnpkg.com/@chain-registry/keplr/-/keplr-1.25.0.tgz#581a10760951c1d1185c6874199df08283a21d46" - integrity sha512-mEr5HypYEaQnYcuGp3PBTqo67WV0MQyBP2dOtl+ab2fkyB5PYa01D5B2Yu5V6V7eXLmKDvvvfiRO23NWQzFHxg== +"@chain-registry/keplr@1.28.0": + version "1.28.0" + resolved "https://registry.yarnpkg.com/@chain-registry/keplr/-/keplr-1.28.0.tgz#c53d52ff0487eb6798722eb1cf5bd4dc82a141be" + integrity sha512-MRAEgUpafyGLRDQc4SPB+R/If4CL2SREqdbxZMKHX9aeqzKXhJlEM5IPjJTZCWTbUP/eGXC9JNjxPNUYd92PqQ== dependencies: "@babel/runtime" "^7.21.0" "@chain-registry/types" "^0.17.0" @@ -1836,102 +1836,101 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.31.3.tgz#f97bbfda35ad69e80cd5c7fe0a270cbda16db1ed" integrity sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA== -"@cosmos-kit/compass-extension@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/compass-extension/-/compass-extension-2.4.5.tgz#27f812e85f3e952efed5ae6ae0bd1714b0bbba7e" - integrity sha512-Krz8qfz/Tp/KEEhMIMvCQrEMePo2rW5vT7BWPwIPRcRcZ0FdpbWS2tNk+gW1P8mMk9wnO1te0dYg09pCXswc6Q== +"@cosmos-kit/compass-extension@^2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/compass-extension/-/compass-extension-2.5.1.tgz#5ac69f9862519bf69ef5de63ff1c3b0be6197caa" + integrity sha512-iSX3Jzugve8MxzYhy0JM/MCSPtpwATrFdsR+cZ92+UILIh/K3eznl+akmI6nBMfBBZWdSo8ijsD9jkSkyY+nAQ== dependencies: - "@chain-registry/keplr" "1.25.0" - "@cosmos-kit/core" "^2.7.4" + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" -"@cosmos-kit/compass@2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/compass/-/compass-2.4.5.tgz#faecb19b61630f558a51230c63721bcf8799104d" - integrity sha512-lOrDDBpkq21TkjytmRf0Q7462ZuX2Bcx+IJ6d8PFCMYFzvtNlTpXhFCejcqzEy0hAXdKIlG6F59rSaGnVjfjIA== +"@cosmos-kit/compass@2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/compass/-/compass-2.5.1.tgz#71e3872752ddd04cc7dae4c1e28704d356f30763" + integrity sha512-9F8iHz7oFkvwyn8exQgWpt/Ep11t5YxIfCl0XdTuvNv3LSXFJlK5U3K5DOrsV5FySIvtF0LQh0+x48qvNdLQvA== dependencies: - "@cosmos-kit/compass-extension" "^2.4.5" + "@cosmos-kit/compass-extension" "^2.5.1" -"@cosmos-kit/core@2.7.4", "@cosmos-kit/core@^2.7.4": - version "2.7.4" - resolved "https://registry.yarnpkg.com/@cosmos-kit/core/-/core-2.7.4.tgz#8d028c3b99ab4d11aed47bf5d1c22d0157bca694" - integrity sha512-/G2ucBgEooSzKYBzwNC7/NksDVuXGorEgP8dPTR7iAxfFLSg0j/lDPFH4tezVJSV/NZxbw4Suptk+KyUGDEzNw== +"@cosmos-kit/core@2.7.11", "@cosmos-kit/core@^2.7.11": + version "2.7.11" + resolved "https://registry.yarnpkg.com/@cosmos-kit/core/-/core-2.7.11.tgz#f213985ba7af37b5a1fa50181ed29d35e0f64430" + integrity sha512-WlUbrFMtLvtZ2O9h81wQ7nJMLkCCc0iqY6owgxAvUIvFIoCvhl7P49TIfeni7+jIuVLpcU8CYO8sdjMfPMUOoA== dependencies: "@chain-registry/types" "0.17.0" - "@walletconnect/types" "2.7.2" + "@walletconnect/types" "2.10.4" bowser "2.11.0" events "3.3.0" uuid "^9.0.1" -"@cosmos-kit/keplr-extension@^2.5.6": - version "2.5.6" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.5.6.tgz#f918e9f1cd4d29ca89c8764cf6314bfb41d22329" - integrity sha512-RAnoYJVeufGb9wxknMimqhkntxZKofSeHW6ChjpzGLE2WScHTmWBdgcdxtGxdNe2Yua3wtjAzyiGSuUq64b1OA== +"@cosmos-kit/keplr-extension@^2.6.1": + version "2.6.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.6.1.tgz#2d149591e90d6d05ee20ca449047529c46f99984" + integrity sha512-lTxYCWyoO3Vy5DEoUEkICgi37CkQm2MFfftNY6llRLz0uq89hNcDZfF9a9g6KKNtwwxriNN+X1ppYDbOlG80Ow== dependencies: - "@chain-registry/keplr" "1.25.0" - "@cosmos-kit/core" "^2.7.4" + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" -"@cosmos-kit/keplr-mobile@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-mobile/-/keplr-mobile-2.4.5.tgz#407b8c31afd1ec49cb4e600e84dbfe8224f59ab2" - integrity sha512-4cF0MfcJEGvWqL31YVMoahP4WlSSe5Nyj2NMGCzuMsOdRWCSpdB06c9RJ+erI0JyVDXjam7tTA9WTlyT+dgAKg== +"@cosmos-kit/keplr-mobile@^2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-mobile/-/keplr-mobile-2.5.1.tgz#8d573e3ab445912c8e670299e0d08f51fa7412b1" + integrity sha512-1oELwcnYkMxuxwQPXetoI/E5QCot6BWnwccNA9G20u+TG7gjv2H1TjHeWyuSop2tNiYFnszMa0ws2R4FF0UtFA== dependencies: - "@chain-registry/keplr" "1.25.0" - "@cosmos-kit/core" "^2.7.4" - "@cosmos-kit/walletconnect" "^2.4.5" + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/walletconnect" "^2.4.14" -"@cosmos-kit/keplr@2.4.6": - version "2.4.6" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr/-/keplr-2.4.6.tgz#be323aeb4ad9165b397dd57847b6bb1bf0dd2161" - integrity sha512-bUjgEePB0u2jbWJ7oZfr5J9O/00pRbyMeZQHN1TWh3KIcxBLMZcQdeglWMwep8V/ETond0Mr5hKR8S/ZsLgCuA== +"@cosmos-kit/keplr@2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr/-/keplr-2.5.1.tgz#e188927070705c94036e4c8001137681b76dd210" + integrity sha512-DwAk+QWX/VOqADfBkgTD98zHOsgVVV0z7EgQUnyDBKTcLrGhZ4cs/02WK0EO4huG20bheUFnD8YTQmASHESsLQ== dependencies: - "@cosmos-kit/keplr-extension" "^2.5.6" - "@cosmos-kit/keplr-mobile" "^2.4.5" + "@cosmos-kit/keplr-extension" "^2.6.1" + "@cosmos-kit/keplr-mobile" "^2.5.1" -"@cosmos-kit/react-lite@^2.5.5": - version "2.5.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.5.5.tgz#905107aadcc87ae268ea7d8927ff74601b6df8f7" - integrity sha512-i1FTkMMLDOUkO+lPbUS3RRQoewgX79ux+gTctB/6wJqBhZkzoINCCn2XHYrKioXqhe2a1xn5n+EUWkBEPsZK8w== +"@cosmos-kit/react-lite@^2.5.13": + version "2.5.13" + resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.5.13.tgz#b053df94faad8a76f3421c1cd148e74b0c086854" + integrity sha512-CSnySfwcTBWYpmBaewKPz0hjvmIFeKnXi2GW6eaKR2LqUPuXVQCkx8biUpYKYsvQghlLmnL2+7+tmvZI5sTnmQ== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/core" "^2.7.11" -"@cosmos-kit/react@2.9.5": - version "2.9.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/react/-/react-2.9.5.tgz#937ee4f5b9f4071d5c5efba2f170eb8c03213b59" - integrity sha512-AYtDY5bC1OUMMyfNbwRzxIfx6aqpdRWMxrsZApQBLaVvzbQwwfZx0FUwWLN4BZ+CaSOm7F1RssbysF+6S405hg== +"@cosmos-kit/react@2.9.15": + version "2.9.15" + resolved "https://registry.yarnpkg.com/@cosmos-kit/react/-/react-2.9.15.tgz#a532c712ef79d7a8a990b04e4e94c5c1dcb074fd" + integrity sha512-EwH5T6/joNJUALFvGLQfMjjvAbxuAlSke5/tXB5yzY6trFhJXPIJ9mJqC/r6GxgNKIwxAlXfWnOStflC0wwjXg== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.4" - "@cosmos-kit/react-lite" "^2.5.5" - "@interchain-ui/react" "^1.11.0" + "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/react-lite" "^2.5.13" "@react-icons/all-files" "^4.1.0" -"@cosmos-kit/station-extension@^2.5.4": - version "2.5.4" - resolved "https://registry.yarnpkg.com/@cosmos-kit/station-extension/-/station-extension-2.5.4.tgz#8fbb42cacf0c8664f2b2e4ae2a121417eb0e63b4" - integrity sha512-o5mbbHMqYnTI+4R/C07j4Ys2PUnIadymA4gjPfhXyR+Y5e8dlP95prPiX4L+0ZJ3Y381mvAsDzHTouQA6Myavg== +"@cosmos-kit/station-extension@^2.5.11": + version "2.5.11" + resolved "https://registry.yarnpkg.com/@cosmos-kit/station-extension/-/station-extension-2.5.11.tgz#95176e53155a00c60b010076570130aa60627a75" + integrity sha512-Ca0fDDZ8hy9d455fHOdAmisiDEkrdcJqPMSqlszfIqx/aYen663jpKZdOLDuvHcZhQrjep/y+roZ3Z5PA8tx/Q== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/core" "^2.7.11" "@terra-money/feather.js" "^1.0.8" "@terra-money/station-connector" "^1.0.5" "@terra-money/wallet-types" "^3.11.2" -"@cosmos-kit/station@2.4.4": - version "2.4.4" - resolved "https://registry.yarnpkg.com/@cosmos-kit/station/-/station-2.4.4.tgz#026aaf0defc81ff77c760640d828ea810b3f4615" - integrity sha512-53IbnLslmWbqgkgqb2FVXvP0XMV/HEbnQSfxu9goKdvcoOb3nsnst/roKQNeAtEqPcDOVfhNCUaDnCZ7sSJG6A== +"@cosmos-kit/station@2.4.11": + version "2.4.11" + resolved "https://registry.yarnpkg.com/@cosmos-kit/station/-/station-2.4.11.tgz#503655e3587622622e6abd5c1910f48d4fbb7781" + integrity sha512-CyXXNsSXjPHMSTk5dz0ozxZOUBYjtp69z1NGHmJDA0/gXqD36Kt67iZQpkY0xA724Vs/Y2Z6JC8LSk8PLttiAQ== dependencies: - "@cosmos-kit/station-extension" "^2.5.4" + "@cosmos-kit/station-extension" "^2.5.11" -"@cosmos-kit/walletconnect@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/walletconnect/-/walletconnect-2.4.5.tgz#b9119ba09f88a18e229ccdb5a8907d0fa2bbbc64" - integrity sha512-ZTE8xh1yKJjqpQDI1wux2Sda1lMxr0Zx/iT4ZDaVuFr1pSzlIoM8SKqAySCr43JNCwF/Y9Uq1HAwLs1vq8lS6w== +"@cosmos-kit/walletconnect@^2.4.14": + version "2.4.14" + resolved "https://registry.yarnpkg.com/@cosmos-kit/walletconnect/-/walletconnect-2.4.14.tgz#60146a5e055893d3411e94c741fafbeabfa31752" + integrity sha512-wIWfx0KiW+QNJDfMVNv6M5ZWR+/NMZrOMqJ4Nqy3y87h4ce/BPatuASRFvcYsFnJQ19hbgzzKWzAtYMit0ML8w== dependencies: - "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/core" "^2.7.11" "@walletconnect/sign-client" "^2.9.0" - "@walletconnect/types" "^2.9.0" + "@walletconnect/types" "2.10.4" "@walletconnect/utils" "^2.9.0" events "3.3.0" @@ -2999,7 +2998,22 @@ long "^5.2.0" protobufjs "^7.1.1" -"@interchain-ui/react@1.11.4", "@interchain-ui/react@^1.11.0": +"@initia/initia.proto@^0.1.20": + version "0.1.20" + resolved "https://registry.yarnpkg.com/@initia/initia.proto/-/initia.proto-0.1.20.tgz#5b91f75ead7b4c4ecdf893bfa338cb8c95a47189" + integrity sha512-J57d5o1ikF37D2T3TEsPU+pMe1c7U+qD8nASPUfa33Fv1V/AAJV1j2OnM/QbQChxlqDaOsEmxmvlo7+1TRU38w== + dependencies: + "@improbable-eng/grpc-web" "^0.15.0" + google-protobuf "^3.21.0" + long "^5.2.0" + protobufjs "^7.1.1" + +"@initia/shared@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@initia/shared/-/shared-0.6.0.tgz#e537c1ff24e84505b36cd2a3f55a54dc5a986a4d" + integrity sha512-qU4VDt6u14heaMA+YuUBFatLkMs9/F1kGs2ddhLxkFIBV/Nu1+s2Nz4EEf5+5UpLtEs3EwSLMzTCUuLNH2jrPQ== + +"@interchain-ui/react@1.11.4": version "1.11.4" resolved "https://registry.yarnpkg.com/@interchain-ui/react/-/react-1.11.4.tgz#62ec06ebed6e9f434f1f406962565e86c34b9b6c" integrity sha512-jUx02LyyUjSKANcpNJ9DPOkVlD2nERmQZsqEnUeJQ6wsG4rgO5yd0jHDUgqotvwxkRisYSy8jqDGe3r4pYsNBw== @@ -4481,18 +4495,6 @@ resolved "https://registry.yarnpkg.com/@vanilla-extract/recipes/-/recipes-0.4.0.tgz#7bb2edb0757b6f40c244d72569da7f74d6afa427" integrity sha512-gFgB7BofUYbtbxINHK6DhMv1JDFDXp/YI/Xm+cqKar+1I/2dfxPepeDxSexL6YB4ftfeaDw8Kn5zydMvHcGOEQ== -"@vercel/analytics@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@vercel/analytics/-/analytics-1.1.1.tgz#2a712378a95014a548b4f9d2ae1ea0721433908d" - integrity sha512-+NqgNmSabg3IFfxYhrWCfB/H+RCUOCR5ExRudNG2+pcRehq628DJB5e1u1xqwpLtn4pAYii4D98w7kofORAGQA== - dependencies: - server-only "^0.0.1" - -"@vercel/speed-insights@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@vercel/speed-insights/-/speed-insights-1.0.1.tgz#ea801f639594cbd5121d80a0ea1103e08ac5edc9" - integrity sha512-cm8KTTsDgS1AbWsgIEZuMoyPUjclzeqJihyLp0tnA21B/x9iTE8hu2S5zM+/DBzihuHxWL1dx9pCWk22ctMFWQ== - "@walletconnect/core@2.10.4": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.4.tgz#da9396b56f63806c165389cbf98d2373d36854df" @@ -4641,7 +4643,7 @@ dependencies: tslib "1.14.1" -"@walletconnect/types@2.10.4", "@walletconnect/types@^2.9.0": +"@walletconnect/types@2.10.4": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.4.tgz#23f6e4bd785671812dc6ea96848a6bd7ea78f038" integrity sha512-eQpOElyiwJp3tepuOS3TS9dXTl9jVVlrC3iVA8bytnbLagkAUxmiv/s7PyDFx+ndXwQVh8PFBkWg1oxGwgCSBA== @@ -4653,18 +4655,6 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@walletconnect/types@2.7.2": - version "2.7.2" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.7.2.tgz#508d1755110864dee294f955e09b7da3f8ee0064" - integrity sha512-1O2UefakZpT0ErRfEAXY7Ls3qdUrKDky/DsK088xR6klyfkQOx+aSVH0fJYLhmnqPTuvp3lrqNbsDc0s6/6nvg== - dependencies: - "@walletconnect/events" "^1.0.1" - "@walletconnect/heartbeat" "1.2.1" - "@walletconnect/jsonrpc-types" "^1.0.2" - "@walletconnect/keyvaluestorage" "^1.0.2" - "@walletconnect/logger" "^2.0.1" - events "^3.3.0" - "@walletconnect/utils@2.10.4", "@walletconnect/utils@^2.9.0": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.4.tgz#5f17938e7ea481541ec2dbae0df5cd494c72523f" @@ -6348,6 +6338,16 @@ cosmjs-types@^0.8.0: long "^4.0.0" protobufjs "~6.11.2" +cosmos-kit-initia-extension@^2.6.4: + version "2.6.4" + resolved "https://registry.yarnpkg.com/cosmos-kit-initia-extension/-/cosmos-kit-initia-extension-2.6.4.tgz#c566c5bb8733d2bdd41adf36a4476d7f53a505ec" + integrity sha512-hLyV6eFKTUopOHvt+LKYGkaYQm+yXeBoGYA8MjNYxxE2SLVvgRNqZj4YKr22NGy2D/BGzAH505DhBUcR9GYEMw== + dependencies: + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" + "@initia/initia.proto" "^0.1.20" + "@initia/shared" "^0.6.0" + create-ecdh@^4.0.0: version "4.0.4" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" @@ -11174,11 +11174,6 @@ sentence-case@^3.0.4: tslib "^2.0.3" upper-case-first "^2.0.2" -server-only@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/server-only/-/server-only-0.0.1.tgz#0f366bb6afb618c37c9255a314535dc412cd1c9e" - integrity sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA== - set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" From bfa3d3a1b1fdc096e4d19b6e28d0f19124ec6020 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 25 Dec 2023 17:45:14 +0700 Subject: [PATCH 06/16] feat: try on execute --- src/lib/app-provider/hooks/index.ts | 1 + .../app-provider/hooks/useGetSigningClient.ts | 63 +++++++++++++++++++ src/lib/app-provider/tx/execute.ts | 9 +-- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 src/lib/app-provider/hooks/useGetSigningClient.ts diff --git a/src/lib/app-provider/hooks/index.ts b/src/lib/app-provider/hooks/index.ts index 29afb13d7..89ef0f329 100644 --- a/src/lib/app-provider/hooks/index.ts +++ b/src/lib/app-provider/hooks/index.ts @@ -8,6 +8,7 @@ export * from "./useMediaQuery"; export * from "./useNetworkChange"; export * from "./useRestrictedInput"; export * from "./useSelectChain"; +export * from "./useGetSigningClient"; export * from "./useBaseApiRoute"; export * from "./useRPCEndpoint"; export * from "./useConfig"; diff --git a/src/lib/app-provider/hooks/useGetSigningClient.ts b/src/lib/app-provider/hooks/useGetSigningClient.ts new file mode 100644 index 000000000..2708675e9 --- /dev/null +++ b/src/lib/app-provider/hooks/useGetSigningClient.ts @@ -0,0 +1,63 @@ +/* eslint-disable */ +import type { WalletClient } from "@cosmos-kit/core"; + +import { useCurrentChain } from "./useCurrentChain"; +import { useCallback } from "react"; +import { useWalletClient } from "@cosmos-kit/react"; +import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; +import { useRPCEndpoint } from "./useRPCEndpoint"; +import { Option } from "lib/types"; + +type MergedWalletClient = + | WalletClient + // | import("@cosmos-kit/cosmostation-extension/cjs/extension/client").CosmostationClient + | import("@cosmos-kit/keplr-extension/cjs/extension/client").KeplrClient + | import("@cosmos-kit/station-extension/cjs/extension/client").StationClient; + +export const isLedger = async < + T extends + | WalletClient + | import("@cosmos-kit/keplr-extension/cjs/extension/client").KeplrClient, +>( + walletClient: T, + chainID: string +) => { + // mostly everything else + if ("client" in walletClient && "getKey" in walletClient.client) { + const key = await walletClient.client.getKey(chainID); + return key.isNanoLedger; + } + + // cosmostation + // if ("client" in walletClient && "cosmos" in walletClient.client) { + // const account = await walletClient.client.cosmos.request({ + // method: "cos_account", + // params: { chainName: chainID }, + // }); + // return Boolean(account.isLedger); + // } + + return false; +}; + +export const useGetSigningClient = () => { + const { client: walletClient } = useWalletClient(); + const { + chain: { chain_id: chainId }, + getSigningCosmWasmClient, + } = useCurrentChain(); + + return useCallback(async () => { + if (walletClient && (await isLedger(walletClient, chainId))) { + const rpcEndpoint = useRPCEndpoint(); + const signer = + walletClient.getOfflineSignerAmino?.(chainId) ?? + (await walletClient.getOfflineSigner?.(chainId, "amino")); + + if (!signer || !("signAmino" in signer)) return undefined; + + return SigningCosmWasmClient.connectWithSigner(rpcEndpoint, signer); + } + return await getSigningCosmWasmClient(); + }, []); +}; diff --git a/src/lib/app-provider/tx/execute.ts b/src/lib/app-provider/tx/execute.ts index cf1de6790..1216852ac 100644 --- a/src/lib/app-provider/tx/execute.ts +++ b/src/lib/app-provider/tx/execute.ts @@ -1,7 +1,7 @@ import type { Coin, StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { executeContractTx } from "lib/app-fns/tx/execute"; import type { Activity } from "lib/stores/contract"; @@ -17,7 +17,8 @@ export interface ExecuteStreamParams { } export const useExecuteContractTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -28,7 +29,7 @@ export const useExecuteContractTx = () => { msg, funds, }: ExecuteStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -47,6 +48,6 @@ export const useExecuteContractTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; From 698fedb32311333224990c058ffa8a0c9e9ec4f1 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 25 Dec 2023 17:57:19 +0700 Subject: [PATCH 07/16] fix: type --- src/lib/app-provider/hooks/useGetSigningClient.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lib/app-provider/hooks/useGetSigningClient.ts b/src/lib/app-provider/hooks/useGetSigningClient.ts index 2708675e9..6ea8b24c4 100644 --- a/src/lib/app-provider/hooks/useGetSigningClient.ts +++ b/src/lib/app-provider/hooks/useGetSigningClient.ts @@ -6,7 +6,6 @@ import { useCallback } from "react"; import { useWalletClient } from "@cosmos-kit/react"; import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { useRPCEndpoint } from "./useRPCEndpoint"; -import { Option } from "lib/types"; type MergedWalletClient = | WalletClient @@ -14,11 +13,7 @@ type MergedWalletClient = | import("@cosmos-kit/keplr-extension/cjs/extension/client").KeplrClient | import("@cosmos-kit/station-extension/cjs/extension/client").StationClient; -export const isLedger = async < - T extends - | WalletClient - | import("@cosmos-kit/keplr-extension/cjs/extension/client").KeplrClient, ->( +export const isLedger = async ( walletClient: T, chainID: string ) => { From 9d6a67dc19d231c0d8a6d57471e68d3a31118b17 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 26 Dec 2023 01:04:51 +0700 Subject: [PATCH 08/16] fix: remove unused query key --- src/lib/app-provider/env.ts | 1 - src/lib/pages/contract-details/data.ts | 2 +- src/lib/services/contract.ts | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/app-provider/env.ts b/src/lib/app-provider/env.ts index 21c63432f..95163c888 100644 --- a/src/lib/app-provider/env.ts +++ b/src/lib/app-provider/env.ts @@ -43,7 +43,6 @@ export enum CELATONE_QUERY_KEYS { INSTANTIATED_LIST_BY_WALLET_ADDRESS = "CELATONE_QUERY_INSTANTIATED_LIST_BY_WALLET_ADDRESS", ADMINS_BY_CONTRACTS = "CELATONE_QUERY_ADMINS_BY_CONTRACTS", CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS", - CONTRACT_MIGRATION_HISTORIES_COUNT = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_COUNT", CONTRACTS_BY_CODE_ID_PAGINATION = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_PAGINATION", CONTRACTS_BY_CODE_ID_COUNT = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_COUNT", // X/STAKING diff --git a/src/lib/pages/contract-details/data.ts b/src/lib/pages/contract-details/data.ts index ec2ee0038..10198afa0 100644 --- a/src/lib/pages/contract-details/data.ts +++ b/src/lib/pages/contract-details/data.ts @@ -102,12 +102,12 @@ export const useMigrationHistories = ( offset: number, pageSize: number ) => { - const { getCodeLocalInfo } = useCodeStore(); const { data, ...res } = useMigrationHistoriesByContractAddress( contractAddress, offset, pageSize ); + const { getCodeLocalInfo } = useCodeStore(); return { data: data diff --git a/src/lib/services/contract.ts b/src/lib/services/contract.ts index 9dc2ac585..0fec49158 100644 --- a/src/lib/services/contract.ts +++ b/src/lib/services/contract.ts @@ -176,6 +176,7 @@ export const getMigrationHistoriesByContractAddress = async ( }, }) .then(({ data }) => zMigrationHistoriesResponse.parse(data)); + const zContractTableCounts = z .object({ tx: z.number().nullish(), From eb0042c498bfac310b37b7fc903ad33e91f9c2e7 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:38:21 +0700 Subject: [PATCH 09/16] fix: rpc hook --- src/lib/app-provider/hooks/useGetSigningClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/app-provider/hooks/useGetSigningClient.ts b/src/lib/app-provider/hooks/useGetSigningClient.ts index 6ea8b24c4..7de7c18aa 100644 --- a/src/lib/app-provider/hooks/useGetSigningClient.ts +++ b/src/lib/app-provider/hooks/useGetSigningClient.ts @@ -41,10 +41,10 @@ export const useGetSigningClient = () => { chain: { chain_id: chainId }, getSigningCosmWasmClient, } = useCurrentChain(); + const rpcEndpoint = useRPCEndpoint(); return useCallback(async () => { if (walletClient && (await isLedger(walletClient, chainId))) { - const rpcEndpoint = useRPCEndpoint(); const signer = walletClient.getOfflineSignerAmino?.(chainId) ?? (await walletClient.getOfflineSigner?.(chainId, "amino")); @@ -54,5 +54,5 @@ export const useGetSigningClient = () => { return SigningCosmWasmClient.connectWithSigner(rpcEndpoint, signer); } return await getSigningCosmWasmClient(); - }, []); + }, [chainId, rpcEndpoint, JSON.stringify(walletClient)]); }; From 7824218e6e264068d47acd0af84d4ed1b480001d Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:08:16 +0700 Subject: [PATCH 10/16] feat: apply to all txs --- src/lib/app-provider/tx/clearAdmin.ts | 14 ++++++++++---- src/lib/app-provider/tx/instantiate.ts | 9 +++++---- src/lib/app-provider/tx/migrate.ts | 9 +++++---- src/lib/app-provider/tx/move/executeModule.ts | 9 +++++---- src/lib/app-provider/tx/publish.tsx | 9 +++++---- src/lib/app-provider/tx/resend.ts | 9 +++++---- src/lib/app-provider/tx/script.tsx | 9 +++++---- src/lib/app-provider/tx/submitProposal.ts | 9 +++++---- src/lib/app-provider/tx/updateAdmin.ts | 9 +++++---- src/lib/app-provider/tx/upload.ts | 9 +++++---- 10 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/lib/app-provider/tx/clearAdmin.ts b/src/lib/app-provider/tx/clearAdmin.ts index 2881a260a..b70935f03 100644 --- a/src/lib/app-provider/tx/clearAdmin.ts +++ b/src/lib/app-provider/tx/clearAdmin.ts @@ -2,7 +2,12 @@ import { useQueryClient } from "@tanstack/react-query"; import { useCallback } from "react"; import { CELATONE_QUERY_KEYS } from "../env"; -import { useCurrentChain, useFabricateFee, useWasmConfig } from "../hooks"; +import { + useCurrentChain, + useFabricateFee, + useGetSigningClient, + useWasmConfig, +} from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { clearAdminTx } from "lib/app-fns/tx/clearAdmin"; import type { ContractAddr, HumanAddr } from "lib/types"; @@ -12,14 +17,15 @@ export interface ClearAdminStreamParams { } export const useClearAdminTx = (contractAddress: ContractAddr) => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); const queryClient = useQueryClient(); const fabricateFee = useFabricateFee(); const wasm = useWasmConfig({ shouldRedirect: false }); return useCallback( async ({ onTxSucceed }: ClearAdminStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); @@ -50,7 +56,7 @@ export const useClearAdminTx = (contractAddress: ContractAddr) => { }); }, [ - getSigningCosmWasmClient, + getSigningClient, address, wasm, fabricateFee, diff --git a/src/lib/app-provider/tx/instantiate.ts b/src/lib/app-provider/tx/instantiate.ts index d081f2330..094f129d0 100644 --- a/src/lib/app-provider/tx/instantiate.ts +++ b/src/lib/app-provider/tx/instantiate.ts @@ -2,7 +2,7 @@ import type { InstantiateResult } from "@cosmjs/cosmwasm-stargate"; import type { Coin, StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { instantiateContractTx } from "lib/app-fns/tx/instantiate"; @@ -18,7 +18,8 @@ export interface InstantiateStreamParams { } export const useInstantiateTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -31,7 +32,7 @@ export const useInstantiateTx = () => { onTxSucceed, onTxFailed, }: InstantiateStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -52,6 +53,6 @@ export const useInstantiateTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/migrate.ts b/src/lib/app-provider/tx/migrate.ts index cef562c7a..195dfc010 100644 --- a/src/lib/app-provider/tx/migrate.ts +++ b/src/lib/app-provider/tx/migrate.ts @@ -1,7 +1,7 @@ import type { StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { migrateContractTx } from "lib/app-fns/tx/migrate"; import type { ContractAddr, HumanAddr, Option } from "lib/types"; @@ -16,7 +16,8 @@ export interface MigrateStreamParams { } export const useMigrateTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -27,7 +28,7 @@ export const useMigrateTx = () => { onTxSucceed, onTxFailed, }: MigrateStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -46,6 +47,6 @@ export const useMigrateTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/move/executeModule.ts b/src/lib/app-provider/tx/move/executeModule.ts index 2d7b3babc..67ad79f03 100644 --- a/src/lib/app-provider/tx/move/executeModule.ts +++ b/src/lib/app-provider/tx/move/executeModule.ts @@ -4,7 +4,7 @@ import { useCallback } from "react"; import { trackTxSucceed } from "lib/amplitude"; import { executeModuleTx } from "lib/app-fns/tx/move/executeModule"; -import { useCurrentChain } from "lib/app-provider/hooks"; +import { useCurrentChain, useGetSigningClient } from "lib/app-provider/hooks"; import type { HexAddr, HumanAddr } from "lib/types"; import { toEncodeObject } from "lib/utils"; @@ -20,7 +20,8 @@ export interface ExecuteModuleStreamParams { } export const useExecuteModuleTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -33,7 +34,7 @@ export const useExecuteModuleTx = () => { onTxSucceed, onTxFailed, }: ExecuteModuleStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); @@ -61,6 +62,6 @@ export const useExecuteModuleTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/publish.tsx b/src/lib/app-provider/tx/publish.tsx index 4f1a1f5c0..199cc3cac 100644 --- a/src/lib/app-provider/tx/publish.tsx +++ b/src/lib/app-provider/tx/publish.tsx @@ -2,7 +2,7 @@ import type { EncodeObject } from "@cosmjs/proto-signing"; import type { StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { publishModuleTx } from "lib/app-fns/tx/publish"; import type { HumanAddr } from "lib/types"; @@ -24,7 +24,8 @@ export interface PublishModuleStreamParams { } export const usePublishModuleTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -33,7 +34,7 @@ export const usePublishModuleTx = () => { estimatedFee, messages, }: PublishModuleStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -49,6 +50,6 @@ export const usePublishModuleTx = () => { messages, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/resend.ts b/src/lib/app-provider/tx/resend.ts index 7dc4379e0..623491aac 100644 --- a/src/lib/app-provider/tx/resend.ts +++ b/src/lib/app-provider/tx/resend.ts @@ -2,7 +2,7 @@ import type { EncodeObject } from "@cosmjs/proto-signing"; import type { StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { resendTx } from "lib/app-fns/tx/resend"; import type { HumanAddr } from "lib/types"; @@ -15,7 +15,8 @@ export interface ResendStreamParams { } export const useResendTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -24,7 +25,7 @@ export const useResendTx = () => { estimatedFee, messages, }: ResendStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -40,6 +41,6 @@ export const useResendTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/script.tsx b/src/lib/app-provider/tx/script.tsx index 689a48689..e7a24c41e 100644 --- a/src/lib/app-provider/tx/script.tsx +++ b/src/lib/app-provider/tx/script.tsx @@ -2,7 +2,7 @@ import type { EncodeObject } from "@cosmjs/proto-signing"; import type { StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { deployScriptTx } from "lib/app-fns/tx/script"; import type { HumanAddr } from "lib/types"; @@ -15,7 +15,8 @@ export interface DeployScriptStreamParams { } export const useDeployScriptTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -24,7 +25,7 @@ export const useDeployScriptTx = () => { estimatedFee, messages, }: DeployScriptStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -40,6 +41,6 @@ export const useDeployScriptTx = () => { messages, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/submitProposal.ts b/src/lib/app-provider/tx/submitProposal.ts index 159bda2c5..7fa78a883 100644 --- a/src/lib/app-provider/tx/submitProposal.ts +++ b/src/lib/app-provider/tx/submitProposal.ts @@ -2,7 +2,7 @@ import type { EncodeObject } from "@cosmjs/proto-signing"; import type { StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { submitStoreCodeProposalTx, @@ -20,7 +20,8 @@ export interface SubmitWhitelistProposalStreamParams { } export const useSubmitWhitelistProposalTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -31,7 +32,7 @@ export const useSubmitWhitelistProposalTx = () => { whitelistNumber, amountToVote, }: SubmitWhitelistProposalStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -49,7 +50,7 @@ export const useSubmitWhitelistProposalTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/updateAdmin.ts b/src/lib/app-provider/tx/updateAdmin.ts index 008c46d99..7bbfe6203 100644 --- a/src/lib/app-provider/tx/updateAdmin.ts +++ b/src/lib/app-provider/tx/updateAdmin.ts @@ -1,7 +1,7 @@ import type { StdFee } from "@cosmjs/stargate"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { updateAdminTx } from "lib/app-fns/tx/updateAdmin"; import type { Addr, ContractAddr, HumanAddr, Option } from "lib/types"; @@ -15,7 +15,8 @@ export interface UpdateAdminStreamParams { } export const useUpdateAdminTx = () => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -25,7 +26,7 @@ export const useUpdateAdminTx = () => { onTxSucceed, onTxFailed, }: UpdateAdminStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!estimatedFee) return null; @@ -43,6 +44,6 @@ export const useUpdateAdminTx = () => { onTxFailed, }); }, - [address, getSigningCosmWasmClient] + [address, getSigningClient] ); }; diff --git a/src/lib/app-provider/tx/upload.ts b/src/lib/app-provider/tx/upload.ts index 7e121872f..21d311b29 100644 --- a/src/lib/app-provider/tx/upload.ts +++ b/src/lib/app-provider/tx/upload.ts @@ -2,7 +2,7 @@ import type { StdFee } from "@cosmjs/stargate"; import { gzip } from "node-gzip"; import { useCallback } from "react"; -import { useCurrentChain } from "../hooks"; +import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { uploadContractTx } from "lib/app-fns/tx/upload"; import type { AccessType, Addr, HumanAddr, Option } from "lib/types"; @@ -29,7 +29,8 @@ export interface UploadStreamParams { } export const useUploadContractTx = (isMigrate: boolean) => { - const { address, getSigningCosmWasmClient } = useCurrentChain(); + const { address } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); return useCallback( async ({ @@ -41,7 +42,7 @@ export const useUploadContractTx = (isMigrate: boolean) => { estimatedFee, onTxSucceed, }: UploadStreamParams) => { - const client = await getSigningCosmWasmClient(); + const client = await getSigningClient(); if (!address || !client) throw new Error("Please check your wallet connection."); if (!wasmFileName || !wasmCode || !estimatedFee) return null; @@ -67,6 +68,6 @@ export const useUploadContractTx = (isMigrate: boolean) => { }, }); }, - [address, getSigningCosmWasmClient, isMigrate] + [address, getSigningClient, isMigrate] ); }; From 30e15c73d4d6765cae964d9dc6c1a97ff9eb06c1 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:03:29 +0700 Subject: [PATCH 11/16] fix: simulate with custom client --- src/lib/app-provider/queries/simulateFee.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/app-provider/queries/simulateFee.ts b/src/lib/app-provider/queries/simulateFee.ts index 535fcafa8..36fbae427 100644 --- a/src/lib/app-provider/queries/simulateFee.ts +++ b/src/lib/app-provider/queries/simulateFee.ts @@ -5,7 +5,12 @@ import type { UseQueryOptions } from "@tanstack/react-query"; import { gzip } from "node-gzip"; import { CELATONE_QUERY_KEYS } from "../env"; -import { useCurrentChain, useDummyWallet, useRPCEndpoint } from "../hooks"; +import { + useCurrentChain, + useDummyWallet, + useGetSigningClient, + useRPCEndpoint, +} from "../hooks"; import type { AccessType, Addr, @@ -33,7 +38,8 @@ export const useSimulateFeeQuery = ({ onSuccess, onError, }: SimulateQueryParams) => { - const { address, getSigningCosmWasmClient, chain } = useCurrentChain(); + const { address, chain } = useCurrentChain(); + const getSigningClient = useGetSigningClient(); const { dummyWallet, dummyAddress } = useDummyWallet(); const rpcEndpoint = useRPCEndpoint(); const userAddress = isDummyUser ? dummyAddress : address || dummyAddress; @@ -50,7 +56,7 @@ export const useSimulateFeeQuery = ({ rpcEndpoint, dummyWallet ) - : await getSigningCosmWasmClient(); + : await getSigningClient(); if (!client) { throw new Error("Fail to get SigningCosmWasmClient"); From 6f064874b031144cfd6b370bf796a2eb457f0765 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 27 Dec 2023 01:57:32 +0700 Subject: [PATCH 12/16] fix: reordering --- src/lib/app-provider/tx/clearAdmin.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/app-provider/tx/clearAdmin.ts b/src/lib/app-provider/tx/clearAdmin.ts index b70935f03..4480f05d3 100644 --- a/src/lib/app-provider/tx/clearAdmin.ts +++ b/src/lib/app-provider/tx/clearAdmin.ts @@ -56,12 +56,12 @@ export const useClearAdminTx = (contractAddress: ContractAddr) => { }); }, [ - getSigningClient, address, - wasm, - fabricateFee, contractAddress, + fabricateFee, + getSigningClient, queryClient, + wasm, ] ); }; From dbd00f7cc6f75708644a71164ea0c04e3fb205d7 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 27 Dec 2023 10:53:37 +0700 Subject: [PATCH 13/16] fix: revert package --- package.json | 30 ++++++-- yarn.lock | 191 ++++++++++++++++++++++++++------------------------- 2 files changed, 122 insertions(+), 99 deletions(-) diff --git a/package.json b/package.json index 3cfcfb7c0..d437d7696 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,25 @@ { "name": "celatone", - "version": "1.3.0", + "version": "1.4.0", "author": "Alles Labs", + "contributors": [ + { + "name": "Kanisorn", + "email": "kanisorn@alleslabs.com" + }, + { + "name": "Beeb", + "email": "beeb@alleslabs.com" + }, + { + "name": "Pakin", + "email": "pakin@alleslabs.com" + }, + { + "name": "Songwong", + "email": "songwong@alleslabs.com" + } + ], "scripts": { "dev": "next dev", "build": "next build", @@ -37,11 +55,11 @@ "@cosmjs/encoding": "0.31.3", "@cosmjs/proto-signing": "0.31.3", "@cosmjs/stargate": "0.31.3", - "@cosmos-kit/compass": "2.5.1", - "@cosmos-kit/core": "2.7.11", - "@cosmos-kit/keplr": "2.5.1", - "@cosmos-kit/react": "2.9.15", - "@cosmos-kit/station": "2.4.11", + "@cosmos-kit/compass": "2.4.5", + "@cosmos-kit/core": "2.7.4", + "@cosmos-kit/keplr": "2.4.6", + "@cosmos-kit/react": "2.9.5", + "@cosmos-kit/station": "2.4.4", "@emotion/react": "^11", "@emotion/styled": "^11", "@graphql-codegen/cli": "^2.13.12", diff --git a/yarn.lock b/yarn.lock index 8f619ddf4..736eac7e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -658,10 +658,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@chain-registry/keplr@1.28.0": - version "1.28.0" - resolved "https://registry.yarnpkg.com/@chain-registry/keplr/-/keplr-1.28.0.tgz#c53d52ff0487eb6798722eb1cf5bd4dc82a141be" - integrity sha512-MRAEgUpafyGLRDQc4SPB+R/If4CL2SREqdbxZMKHX9aeqzKXhJlEM5IPjJTZCWTbUP/eGXC9JNjxPNUYd92PqQ== +"@chain-registry/keplr@1.25.0": + version "1.25.0" + resolved "https://registry.yarnpkg.com/@chain-registry/keplr/-/keplr-1.25.0.tgz#581a10760951c1d1185c6874199df08283a21d46" + integrity sha512-mEr5HypYEaQnYcuGp3PBTqo67WV0MQyBP2dOtl+ab2fkyB5PYa01D5B2Yu5V6V7eXLmKDvvvfiRO23NWQzFHxg== dependencies: "@babel/runtime" "^7.21.0" "@chain-registry/types" "^0.17.0" @@ -1836,101 +1836,102 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.31.3.tgz#f97bbfda35ad69e80cd5c7fe0a270cbda16db1ed" integrity sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA== -"@cosmos-kit/compass-extension@^2.5.1": - version "2.5.1" - resolved "https://registry.yarnpkg.com/@cosmos-kit/compass-extension/-/compass-extension-2.5.1.tgz#5ac69f9862519bf69ef5de63ff1c3b0be6197caa" - integrity sha512-iSX3Jzugve8MxzYhy0JM/MCSPtpwATrFdsR+cZ92+UILIh/K3eznl+akmI6nBMfBBZWdSo8ijsD9jkSkyY+nAQ== +"@cosmos-kit/compass-extension@^2.4.5": + version "2.4.5" + resolved "https://registry.yarnpkg.com/@cosmos-kit/compass-extension/-/compass-extension-2.4.5.tgz#27f812e85f3e952efed5ae6ae0bd1714b0bbba7e" + integrity sha512-Krz8qfz/Tp/KEEhMIMvCQrEMePo2rW5vT7BWPwIPRcRcZ0FdpbWS2tNk+gW1P8mMk9wnO1te0dYg09pCXswc6Q== dependencies: - "@chain-registry/keplr" "1.28.0" - "@cosmos-kit/core" "^2.7.11" + "@chain-registry/keplr" "1.25.0" + "@cosmos-kit/core" "^2.7.4" -"@cosmos-kit/compass@2.5.1": - version "2.5.1" - resolved "https://registry.yarnpkg.com/@cosmos-kit/compass/-/compass-2.5.1.tgz#71e3872752ddd04cc7dae4c1e28704d356f30763" - integrity sha512-9F8iHz7oFkvwyn8exQgWpt/Ep11t5YxIfCl0XdTuvNv3LSXFJlK5U3K5DOrsV5FySIvtF0LQh0+x48qvNdLQvA== +"@cosmos-kit/compass@2.4.5": + version "2.4.5" + resolved "https://registry.yarnpkg.com/@cosmos-kit/compass/-/compass-2.4.5.tgz#faecb19b61630f558a51230c63721bcf8799104d" + integrity sha512-lOrDDBpkq21TkjytmRf0Q7462ZuX2Bcx+IJ6d8PFCMYFzvtNlTpXhFCejcqzEy0hAXdKIlG6F59rSaGnVjfjIA== dependencies: - "@cosmos-kit/compass-extension" "^2.5.1" + "@cosmos-kit/compass-extension" "^2.4.5" -"@cosmos-kit/core@2.7.11", "@cosmos-kit/core@^2.7.11": - version "2.7.11" - resolved "https://registry.yarnpkg.com/@cosmos-kit/core/-/core-2.7.11.tgz#f213985ba7af37b5a1fa50181ed29d35e0f64430" - integrity sha512-WlUbrFMtLvtZ2O9h81wQ7nJMLkCCc0iqY6owgxAvUIvFIoCvhl7P49TIfeni7+jIuVLpcU8CYO8sdjMfPMUOoA== +"@cosmos-kit/core@2.7.4", "@cosmos-kit/core@^2.7.4": + version "2.7.4" + resolved "https://registry.yarnpkg.com/@cosmos-kit/core/-/core-2.7.4.tgz#8d028c3b99ab4d11aed47bf5d1c22d0157bca694" + integrity sha512-/G2ucBgEooSzKYBzwNC7/NksDVuXGorEgP8dPTR7iAxfFLSg0j/lDPFH4tezVJSV/NZxbw4Suptk+KyUGDEzNw== dependencies: "@chain-registry/types" "0.17.0" - "@walletconnect/types" "2.10.4" + "@walletconnect/types" "2.7.2" bowser "2.11.0" events "3.3.0" uuid "^9.0.1" -"@cosmos-kit/keplr-extension@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.6.1.tgz#2d149591e90d6d05ee20ca449047529c46f99984" - integrity sha512-lTxYCWyoO3Vy5DEoUEkICgi37CkQm2MFfftNY6llRLz0uq89hNcDZfF9a9g6KKNtwwxriNN+X1ppYDbOlG80Ow== +"@cosmos-kit/keplr-extension@^2.5.6": + version "2.5.6" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.5.6.tgz#f918e9f1cd4d29ca89c8764cf6314bfb41d22329" + integrity sha512-RAnoYJVeufGb9wxknMimqhkntxZKofSeHW6ChjpzGLE2WScHTmWBdgcdxtGxdNe2Yua3wtjAzyiGSuUq64b1OA== dependencies: - "@chain-registry/keplr" "1.28.0" - "@cosmos-kit/core" "^2.7.11" + "@chain-registry/keplr" "1.25.0" + "@cosmos-kit/core" "^2.7.4" -"@cosmos-kit/keplr-mobile@^2.5.1": - version "2.5.1" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-mobile/-/keplr-mobile-2.5.1.tgz#8d573e3ab445912c8e670299e0d08f51fa7412b1" - integrity sha512-1oELwcnYkMxuxwQPXetoI/E5QCot6BWnwccNA9G20u+TG7gjv2H1TjHeWyuSop2tNiYFnszMa0ws2R4FF0UtFA== +"@cosmos-kit/keplr-mobile@^2.4.5": + version "2.4.5" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-mobile/-/keplr-mobile-2.4.5.tgz#407b8c31afd1ec49cb4e600e84dbfe8224f59ab2" + integrity sha512-4cF0MfcJEGvWqL31YVMoahP4WlSSe5Nyj2NMGCzuMsOdRWCSpdB06c9RJ+erI0JyVDXjam7tTA9WTlyT+dgAKg== dependencies: - "@chain-registry/keplr" "1.28.0" - "@cosmos-kit/core" "^2.7.11" - "@cosmos-kit/walletconnect" "^2.4.14" + "@chain-registry/keplr" "1.25.0" + "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/walletconnect" "^2.4.5" -"@cosmos-kit/keplr@2.5.1": - version "2.5.1" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr/-/keplr-2.5.1.tgz#e188927070705c94036e4c8001137681b76dd210" - integrity sha512-DwAk+QWX/VOqADfBkgTD98zHOsgVVV0z7EgQUnyDBKTcLrGhZ4cs/02WK0EO4huG20bheUFnD8YTQmASHESsLQ== +"@cosmos-kit/keplr@2.4.6": + version "2.4.6" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr/-/keplr-2.4.6.tgz#be323aeb4ad9165b397dd57847b6bb1bf0dd2161" + integrity sha512-bUjgEePB0u2jbWJ7oZfr5J9O/00pRbyMeZQHN1TWh3KIcxBLMZcQdeglWMwep8V/ETond0Mr5hKR8S/ZsLgCuA== dependencies: - "@cosmos-kit/keplr-extension" "^2.6.1" - "@cosmos-kit/keplr-mobile" "^2.5.1" + "@cosmos-kit/keplr-extension" "^2.5.6" + "@cosmos-kit/keplr-mobile" "^2.4.5" -"@cosmos-kit/react-lite@^2.5.13": - version "2.5.13" - resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.5.13.tgz#b053df94faad8a76f3421c1cd148e74b0c086854" - integrity sha512-CSnySfwcTBWYpmBaewKPz0hjvmIFeKnXi2GW6eaKR2LqUPuXVQCkx8biUpYKYsvQghlLmnL2+7+tmvZI5sTnmQ== +"@cosmos-kit/react-lite@^2.5.5": + version "2.5.5" + resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.5.5.tgz#905107aadcc87ae268ea7d8927ff74601b6df8f7" + integrity sha512-i1FTkMMLDOUkO+lPbUS3RRQoewgX79ux+gTctB/6wJqBhZkzoINCCn2XHYrKioXqhe2a1xn5n+EUWkBEPsZK8w== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/core" "^2.7.4" -"@cosmos-kit/react@2.9.15": - version "2.9.15" - resolved "https://registry.yarnpkg.com/@cosmos-kit/react/-/react-2.9.15.tgz#a532c712ef79d7a8a990b04e4e94c5c1dcb074fd" - integrity sha512-EwH5T6/joNJUALFvGLQfMjjvAbxuAlSke5/tXB5yzY6trFhJXPIJ9mJqC/r6GxgNKIwxAlXfWnOStflC0wwjXg== +"@cosmos-kit/react@2.9.5": + version "2.9.5" + resolved "https://registry.yarnpkg.com/@cosmos-kit/react/-/react-2.9.5.tgz#937ee4f5b9f4071d5c5efba2f170eb8c03213b59" + integrity sha512-AYtDY5bC1OUMMyfNbwRzxIfx6aqpdRWMxrsZApQBLaVvzbQwwfZx0FUwWLN4BZ+CaSOm7F1RssbysF+6S405hg== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.11" - "@cosmos-kit/react-lite" "^2.5.13" + "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/react-lite" "^2.5.5" + "@interchain-ui/react" "^1.11.0" "@react-icons/all-files" "^4.1.0" -"@cosmos-kit/station-extension@^2.5.11": - version "2.5.11" - resolved "https://registry.yarnpkg.com/@cosmos-kit/station-extension/-/station-extension-2.5.11.tgz#95176e53155a00c60b010076570130aa60627a75" - integrity sha512-Ca0fDDZ8hy9d455fHOdAmisiDEkrdcJqPMSqlszfIqx/aYen663jpKZdOLDuvHcZhQrjep/y+roZ3Z5PA8tx/Q== +"@cosmos-kit/station-extension@^2.5.4": + version "2.5.4" + resolved "https://registry.yarnpkg.com/@cosmos-kit/station-extension/-/station-extension-2.5.4.tgz#8fbb42cacf0c8664f2b2e4ae2a121417eb0e63b4" + integrity sha512-o5mbbHMqYnTI+4R/C07j4Ys2PUnIadymA4gjPfhXyR+Y5e8dlP95prPiX4L+0ZJ3Y381mvAsDzHTouQA6Myavg== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/core" "^2.7.4" "@terra-money/feather.js" "^1.0.8" "@terra-money/station-connector" "^1.0.5" "@terra-money/wallet-types" "^3.11.2" -"@cosmos-kit/station@2.4.11": - version "2.4.11" - resolved "https://registry.yarnpkg.com/@cosmos-kit/station/-/station-2.4.11.tgz#503655e3587622622e6abd5c1910f48d4fbb7781" - integrity sha512-CyXXNsSXjPHMSTk5dz0ozxZOUBYjtp69z1NGHmJDA0/gXqD36Kt67iZQpkY0xA724Vs/Y2Z6JC8LSk8PLttiAQ== +"@cosmos-kit/station@2.4.4": + version "2.4.4" + resolved "https://registry.yarnpkg.com/@cosmos-kit/station/-/station-2.4.4.tgz#026aaf0defc81ff77c760640d828ea810b3f4615" + integrity sha512-53IbnLslmWbqgkgqb2FVXvP0XMV/HEbnQSfxu9goKdvcoOb3nsnst/roKQNeAtEqPcDOVfhNCUaDnCZ7sSJG6A== dependencies: - "@cosmos-kit/station-extension" "^2.5.11" + "@cosmos-kit/station-extension" "^2.5.4" -"@cosmos-kit/walletconnect@^2.4.14": - version "2.4.14" - resolved "https://registry.yarnpkg.com/@cosmos-kit/walletconnect/-/walletconnect-2.4.14.tgz#60146a5e055893d3411e94c741fafbeabfa31752" - integrity sha512-wIWfx0KiW+QNJDfMVNv6M5ZWR+/NMZrOMqJ4Nqy3y87h4ce/BPatuASRFvcYsFnJQ19hbgzzKWzAtYMit0ML8w== +"@cosmos-kit/walletconnect@^2.4.5": + version "2.4.5" + resolved "https://registry.yarnpkg.com/@cosmos-kit/walletconnect/-/walletconnect-2.4.5.tgz#b9119ba09f88a18e229ccdb5a8907d0fa2bbbc64" + integrity sha512-ZTE8xh1yKJjqpQDI1wux2Sda1lMxr0Zx/iT4ZDaVuFr1pSzlIoM8SKqAySCr43JNCwF/Y9Uq1HAwLs1vq8lS6w== dependencies: - "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/core" "^2.7.4" "@walletconnect/sign-client" "^2.9.0" - "@walletconnect/types" "2.10.4" + "@walletconnect/types" "^2.9.0" "@walletconnect/utils" "^2.9.0" events "3.3.0" @@ -2998,22 +2999,7 @@ long "^5.2.0" protobufjs "^7.1.1" -"@initia/initia.proto@^0.1.20": - version "0.1.20" - resolved "https://registry.yarnpkg.com/@initia/initia.proto/-/initia.proto-0.1.20.tgz#5b91f75ead7b4c4ecdf893bfa338cb8c95a47189" - integrity sha512-J57d5o1ikF37D2T3TEsPU+pMe1c7U+qD8nASPUfa33Fv1V/AAJV1j2OnM/QbQChxlqDaOsEmxmvlo7+1TRU38w== - dependencies: - "@improbable-eng/grpc-web" "^0.15.0" - google-protobuf "^3.21.0" - long "^5.2.0" - protobufjs "^7.1.1" - -"@initia/shared@^0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@initia/shared/-/shared-0.6.0.tgz#e537c1ff24e84505b36cd2a3f55a54dc5a986a4d" - integrity sha512-qU4VDt6u14heaMA+YuUBFatLkMs9/F1kGs2ddhLxkFIBV/Nu1+s2Nz4EEf5+5UpLtEs3EwSLMzTCUuLNH2jrPQ== - -"@interchain-ui/react@1.11.4": +"@interchain-ui/react@1.11.4", "@interchain-ui/react@^1.11.0": version "1.11.4" resolved "https://registry.yarnpkg.com/@interchain-ui/react/-/react-1.11.4.tgz#62ec06ebed6e9f434f1f406962565e86c34b9b6c" integrity sha512-jUx02LyyUjSKANcpNJ9DPOkVlD2nERmQZsqEnUeJQ6wsG4rgO5yd0jHDUgqotvwxkRisYSy8jqDGe3r4pYsNBw== @@ -4495,6 +4481,18 @@ resolved "https://registry.yarnpkg.com/@vanilla-extract/recipes/-/recipes-0.4.0.tgz#7bb2edb0757b6f40c244d72569da7f74d6afa427" integrity sha512-gFgB7BofUYbtbxINHK6DhMv1JDFDXp/YI/Xm+cqKar+1I/2dfxPepeDxSexL6YB4ftfeaDw8Kn5zydMvHcGOEQ== +"@vercel/analytics@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@vercel/analytics/-/analytics-1.1.1.tgz#2a712378a95014a548b4f9d2ae1ea0721433908d" + integrity sha512-+NqgNmSabg3IFfxYhrWCfB/H+RCUOCR5ExRudNG2+pcRehq628DJB5e1u1xqwpLtn4pAYii4D98w7kofORAGQA== + dependencies: + server-only "^0.0.1" + +"@vercel/speed-insights@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@vercel/speed-insights/-/speed-insights-1.0.1.tgz#ea801f639594cbd5121d80a0ea1103e08ac5edc9" + integrity sha512-cm8KTTsDgS1AbWsgIEZuMoyPUjclzeqJihyLp0tnA21B/x9iTE8hu2S5zM+/DBzihuHxWL1dx9pCWk22ctMFWQ== + "@walletconnect/core@2.10.4": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.4.tgz#da9396b56f63806c165389cbf98d2373d36854df" @@ -4643,7 +4641,7 @@ dependencies: tslib "1.14.1" -"@walletconnect/types@2.10.4": +"@walletconnect/types@2.10.4", "@walletconnect/types@^2.9.0": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.4.tgz#23f6e4bd785671812dc6ea96848a6bd7ea78f038" integrity sha512-eQpOElyiwJp3tepuOS3TS9dXTl9jVVlrC3iVA8bytnbLagkAUxmiv/s7PyDFx+ndXwQVh8PFBkWg1oxGwgCSBA== @@ -4655,6 +4653,18 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" +"@walletconnect/types@2.7.2": + version "2.7.2" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.7.2.tgz#508d1755110864dee294f955e09b7da3f8ee0064" + integrity sha512-1O2UefakZpT0ErRfEAXY7Ls3qdUrKDky/DsK088xR6klyfkQOx+aSVH0fJYLhmnqPTuvp3lrqNbsDc0s6/6nvg== + dependencies: + "@walletconnect/events" "^1.0.1" + "@walletconnect/heartbeat" "1.2.1" + "@walletconnect/jsonrpc-types" "^1.0.2" + "@walletconnect/keyvaluestorage" "^1.0.2" + "@walletconnect/logger" "^2.0.1" + events "^3.3.0" + "@walletconnect/utils@2.10.4", "@walletconnect/utils@^2.9.0": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.4.tgz#5f17938e7ea481541ec2dbae0df5cd494c72523f" @@ -6338,16 +6348,6 @@ cosmjs-types@^0.8.0: long "^4.0.0" protobufjs "~6.11.2" -cosmos-kit-initia-extension@^2.6.4: - version "2.6.4" - resolved "https://registry.yarnpkg.com/cosmos-kit-initia-extension/-/cosmos-kit-initia-extension-2.6.4.tgz#c566c5bb8733d2bdd41adf36a4476d7f53a505ec" - integrity sha512-hLyV6eFKTUopOHvt+LKYGkaYQm+yXeBoGYA8MjNYxxE2SLVvgRNqZj4YKr22NGy2D/BGzAH505DhBUcR9GYEMw== - dependencies: - "@chain-registry/keplr" "1.28.0" - "@cosmos-kit/core" "^2.7.11" - "@initia/initia.proto" "^0.1.20" - "@initia/shared" "^0.6.0" - create-ecdh@^4.0.0: version "4.0.4" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" @@ -11174,6 +11174,11 @@ sentence-case@^3.0.4: tslib "^2.0.3" upper-case-first "^2.0.2" +server-only@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/server-only/-/server-only-0.0.1.tgz#0f366bb6afb618c37c9255a314535dc412cd1c9e" + integrity sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA== + set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" From c26a5880520c8ded499e7f546ba64cfae496f4da Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:53:42 +0700 Subject: [PATCH 14/16] fix: comment --- .../components/tables/migration/RemarkRender.tsx | 5 +++-- src/lib/services/contract.ts | 2 +- src/lib/services/proposal.ts | 11 +++++------ src/lib/types/contract.ts | 2 +- src/lib/types/proposal.ts | 12 ++++++++---- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/lib/pages/contract-details/components/tables/migration/RemarkRender.tsx b/src/lib/pages/contract-details/components/tables/migration/RemarkRender.tsx index ec09ae880..f692bb46e 100644 --- a/src/lib/pages/contract-details/components/tables/migration/RemarkRender.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/RemarkRender.tsx @@ -1,5 +1,5 @@ import { Flex, Text } from "@chakra-ui/react"; -import { capitalize } from "lodash"; +import { capitalize, isUndefined } from "lodash"; import { ExplorerLink } from "lib/components/ExplorerLink"; import type { ContractMigrationHistory } from "lib/types"; @@ -10,7 +10,8 @@ export const RemarkRender = ({ remark: ContractMigrationHistory["remark"]; }) => { const { operation, type, value } = remark; - if (type === "genesis") return Genesis; + if (type === "genesis" || isUndefined(value)) + return Genesis; const isGovernance = type === "governance"; const prefix = capitalize(operation.split("_").pop()); diff --git a/src/lib/services/contract.ts b/src/lib/services/contract.ts index 0fec49158..5db7e015c 100644 --- a/src/lib/services/contract.ts +++ b/src/lib/services/contract.ts @@ -134,7 +134,7 @@ export const getAdminContractsByAddress = async ( const zMigrationHistoriesResponseItem = z .object({ - code_id: z.number(), + code_id: z.number().positive(), cw2_contract: z.string().nullable(), cw2_version: z.string().nullable(), height: z.number(), diff --git a/src/lib/services/proposal.ts b/src/lib/services/proposal.ts index 44e1a0be3..40bebceba 100644 --- a/src/lib/services/proposal.ts +++ b/src/lib/services/proposal.ts @@ -2,14 +2,13 @@ import type { Coin } from "@cosmjs/stargate"; import axios from "axios"; import { z } from "zod"; -import { zAddr, zUtcDate } from "lib/types"; +import { zAddr, zUtcDate, zProposalType } from "lib/types"; import type { ContractAddr, AccessConfigPermission, Addr, SnakeToCamelCaseNested, Proposal, - ProposalType, } from "lib/types"; import { parseProposalStatus, snakeToCamel } from "lib/utils"; @@ -73,7 +72,7 @@ const zProposalsResponseItem = z resolved_height: z.number().nullish(), status: z.string().transform(parseProposalStatus), title: z.string(), - type: z.string(), + type: zProposalType, voting_end_time: zUtcDate, }) .transform((val) => ({ @@ -84,7 +83,7 @@ const zProposalsResponseItem = z resolvedHeight: val.resolved_height, status: val.status, title: val.title, - type: val.type as ProposalType, // TODO: remove type assertion + type: val.type, votingEndTime: val.voting_end_time, })); @@ -119,7 +118,7 @@ const zRelatedProposalsResponseItem = z resolved_height: z.number().nullish(), status: z.string().transform(parseProposalStatus), title: z.string(), - type: z.string(), + type: zProposalType, voting_end_time: zUtcDate, }) .transform((val) => ({ @@ -130,7 +129,7 @@ const zRelatedProposalsResponseItem = z resolvedHeight: val.resolved_height, status: val.status, title: val.title, - type: val.type as ProposalType, // TODO: remove type assertion + type: val.type, votingEndTime: val.voting_end_time, })); diff --git a/src/lib/types/contract.ts b/src/lib/types/contract.ts index 03693d2da..29ff4516b 100644 --- a/src/lib/types/contract.ts +++ b/src/lib/types/contract.ts @@ -15,7 +15,7 @@ export enum RemarkOperation { export const zContractHistoryRemark = z.object({ operation: z.nativeEnum(RemarkOperation), type: zRemarkType, - value: z.union([z.string(), z.number()]), + value: z.union([z.string(), z.number()]).optional(), }); export type ContractHistoryRemark = z.infer; diff --git a/src/lib/types/proposal.ts b/src/lib/types/proposal.ts index 24aaf3c89..5e6db17fc 100644 --- a/src/lib/types/proposal.ts +++ b/src/lib/types/proposal.ts @@ -1,3 +1,5 @@ +import { z } from "zod"; + import type { Addr, Nullable, Option } from "lib/types"; export enum ProposalStatus { @@ -44,10 +46,12 @@ enum ProposalTypeOsmosis { SET_PROTOREV_ADMIN_ACCOUNT = "SetProtoRevAdminAccount", } -export type ProposalType = - | ProposalTypeCosmos - | ProposalTypeCosmWasm - | ProposalTypeOsmosis; +export const zProposalType = z.union([ + z.nativeEnum(ProposalTypeCosmos), + z.nativeEnum(ProposalTypeCosmWasm), + z.nativeEnum(ProposalTypeOsmosis), +]); +export type ProposalType = z.infer; export interface Proposal { proposalId: number; From 97d9281727e3708c5236d9e976018af2365c5d95 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:59:16 +0700 Subject: [PATCH 15/16] fix: add custom signing option --- src/lib/app-provider/hooks/useGetSigningClient.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/app-provider/hooks/useGetSigningClient.ts b/src/lib/app-provider/hooks/useGetSigningClient.ts index 7de7c18aa..fd49566d2 100644 --- a/src/lib/app-provider/hooks/useGetSigningClient.ts +++ b/src/lib/app-provider/hooks/useGetSigningClient.ts @@ -6,6 +6,7 @@ import { useCallback } from "react"; import { useWalletClient } from "@cosmos-kit/react"; import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { useRPCEndpoint } from "./useRPCEndpoint"; +import { getCustomedSigningCosmwasm } from "lib/providers/cosmos-kit/options"; type MergedWalletClient = | WalletClient @@ -51,7 +52,11 @@ export const useGetSigningClient = () => { if (!signer || !("signAmino" in signer)) return undefined; - return SigningCosmWasmClient.connectWithSigner(rpcEndpoint, signer); + return SigningCosmWasmClient.connectWithSigner( + rpcEndpoint, + signer, + getCustomedSigningCosmwasm() + ); } return await getSigningCosmWasmClient(); }, [chainId, rpcEndpoint, JSON.stringify(walletClient)]); From f3515c7e1539c133e562b18d32855994974d5297 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 27 Dec 2023 12:39:20 +0700 Subject: [PATCH 16/16] fix: add move amino converter --- src/lib/providers/cosmos-kit/move.ts | 41 +++++++++++++++++++++++++ src/lib/providers/cosmos-kit/options.ts | 4 +-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/lib/providers/cosmos-kit/move.ts b/src/lib/providers/cosmos-kit/move.ts index 7cd51e50b..e9868e8ef 100644 --- a/src/lib/providers/cosmos-kit/move.ts +++ b/src/lib/providers/cosmos-kit/move.ts @@ -1,4 +1,10 @@ import type { GeneratedType } from "@cosmjs/proto-signing"; +import type { AminoConverters } from "@cosmjs/stargate"; +import { + MsgExecute as MsgExecuteClass, + MsgPublish as MsgPublishClass, + MsgScript as MsgScriptClass, +} from "@initia/initia.js"; import { MsgExecute, MsgPublish, @@ -10,3 +16,38 @@ export const moveTypes: ReadonlyArray<[string, GeneratedType]> = [ ["/initia.move.v1.MsgPublish", MsgPublish], ["/initia.move.v1.MsgScript", MsgScript], ]; + +export const createMoveAminoConverters = (): AminoConverters => { + return { + "/initia.move.v1.MsgExecute": { + aminoType: "move/MsgExecute", + toAmino: (data: MsgExecuteClass.Proto) => + MsgExecuteClass.fromProto(data).toAmino().value, + fromAmino: (data: MsgExecuteClass.Amino["value"]) => + MsgExecuteClass.fromAmino({ + type: "move/MsgExecute", + value: data, + }).toProto(), + }, + "/initia.move.v1.MsgPublish": { + aminoType: "move/MsgPublish", + toAmino: (data: MsgPublishClass.Proto) => + MsgPublishClass.fromProto(data).toAmino().value, + fromAmino: (data: MsgPublishClass.Amino["value"]) => + MsgPublishClass.fromAmino({ + type: "move/MsgPublish", + value: data, + }).toProto(), + }, + "/initia.move.v1.MsgScript": { + aminoType: "move/MsgScript", + toAmino: (data: MsgScriptClass.Proto) => + MsgScriptClass.fromProto(data).toAmino().value, + fromAmino: (data: MsgScriptClass.Amino["value"]) => + MsgScriptClass.fromAmino({ + type: "move/MsgScript", + value: data, + }).toProto(), + }, + }; +}; diff --git a/src/lib/providers/cosmos-kit/options.ts b/src/lib/providers/cosmos-kit/options.ts index d4e90c238..ebacbb8c9 100644 --- a/src/lib/providers/cosmos-kit/options.ts +++ b/src/lib/providers/cosmos-kit/options.ts @@ -10,7 +10,7 @@ import { defaultRegistryTypes as defaultStargateTypes, } from "@cosmjs/stargate"; -import { moveTypes } from "./move"; +import { createMoveAminoConverters, moveTypes } from "./move"; /** * Remark: This is the custom signerOptions for the SigningCosmWasmClient. @@ -20,7 +20,7 @@ export const getCustomedSigningCosmwasm = (): SigningCosmWasmClientOptions => { const aminoTypes = { ...createDefaultAminoConverters(), ...createWasmAminoConverters(), - // TODO: move amino converters to be implemented + ...createMoveAminoConverters(), }; return {