diff --git a/README.md b/README.md index 150008d8c..6f75161fc 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ The website will then be live on [http://localhost:3000](http://localhost:3000) chain: "localinitia", registryChainName: "localinitia", prettyName: "Local Initia", - lcd: "http://localhost:1317", + rest: "http://localhost:1317", rpc: "http://localhost:26657", wallets: ["initia"], // keplr, initia, compass, station features: { diff --git a/package.json b/package.json index f393ce137..d23b24c60 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "dependencies": { "@alleslabs/legacy-bcs": "0.0.3", - "@alleslabs/shared": "1.0.0-dev6", + "@alleslabs/shared": "file:../celatone-core/shared", "@amplitude/analytics-browser": "^2.3.3", "@amplitude/analytics-types": "^2.3.0", "@amplitude/plugin-user-agent-enrichment-browser": "^1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e96788a44..2f79da353 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: 0.0.3 version: 0.0.3(bufferutil@4.0.9)(utf-8-validate@5.0.10) '@alleslabs/shared': - specifier: 1.0.0-dev6 - version: 1.0.0-dev6 + specifier: file:../celatone-core/shared + version: file:../celatone-core/shared '@amplitude/analytics-browser': specifier: ^2.3.3 version: 2.11.11 @@ -415,8 +415,8 @@ packages: resolution: {integrity: sha512-93dSIOMsviBYqGP3sXO04vbTwLR8LOlb40fy24f851Ii8Bwi/W7fnIie9GAyo2F1JzRcUd5oo9YequhcA7LejQ==} engines: {node: '>=14'} - '@alleslabs/shared@1.0.0-dev6': - resolution: {integrity: sha512-JFkD+EhzUYLlnxplNBFgjzPh5zaZlpZ4Gg3sWzVdwrX3RAJgdvLJ0Xz2pUazEbzgr4Kszso0SRsmIod7O2/NsQ==} + '@alleslabs/shared@file:../celatone-core/shared': + resolution: {directory: ../celatone-core/shared, type: directory} '@amplitude/analytics-browser@2.11.11': resolution: {integrity: sha512-AdpNNPwoNPezojeeU2ITcyqKcrrW8edVBHlCEvDNIXYkf5Y0i5Blbes3x6rgONsOeV2hx85trTXhhVkilWgHcg==} @@ -10597,7 +10597,7 @@ snapshots: - debug - utf-8-validate - '@alleslabs/shared@1.0.0-dev6': + '@alleslabs/shared@file:../celatone-core/shared': dependencies: '@chain-registry/types': 0.45.20 diff --git a/src/config/chain/devChainConfigs.ts b/src/config/chain/devChainConfigs.ts index 91f0d0eb9..7c38930b9 100644 --- a/src/config/chain/devChainConfigs.ts +++ b/src/config/chain/devChainConfigs.ts @@ -9,7 +9,7 @@ export const devChainConfigs: ChainConfig[] = [ chain: "localinitia", registryChainName: "localinitia", prettyName: "Local Initia", - lcd: "http://localhost:1317", + rest: "http://localhost:1317", rpc: "http://localhost:26657", wallets: ["initia"], features: { diff --git a/src/lib/app-provider/contexts/default.ts b/src/lib/app-provider/contexts/default.ts index 3e727cbda..958f29651 100644 --- a/src/lib/app-provider/contexts/default.ts +++ b/src/lib/app-provider/contexts/default.ts @@ -6,7 +6,7 @@ export const DEFAULT_CHAIN_CONFIG: ChainConfig = { chain: "", registryChainName: "", prettyName: "", - lcd: "", + rest: "", rpc: "", wallets: [], features: { diff --git a/src/lib/app-provider/env.ts b/src/lib/app-provider/env.ts index 950164a1c..fb02c5d8c 100644 --- a/src/lib/app-provider/env.ts +++ b/src/lib/app-provider/env.ts @@ -14,56 +14,56 @@ export enum CELATONE_QUERY_KEYS { // ACCOUNT ACCOUNT_DATA = "CELATONE_QUERY_ACCOUNT_DATA", ACCOUNT_TYPE = "CELATONE_QUERY_ACCOUNT_TYPE", - ACCOUNT_BECH_32_LCD = "CELATONE_QUERY_ACCOUNT_BECH_32_LCD", + ACCOUNT_BECH_32_REST = "CELATONE_QUERY_ACCOUNT_BECH_32_REST", // ASSET ASSET_INFOS = "CELATONE_QUERY_ASSET_INFOS", // BLOCK BLOCKS = "CELATONE_QUERY_BLOCKS", BLOCK_DATA = "CELATONE_QUERY_BLOCK_DATA", - BLOCK_DATA_LCD = "CELATONE_QUERY_BLOCK_DATA_LCD", + BLOCK_DATA_REST = "CELATONE_QUERY_BLOCK_DATA_REST", BLOCK_DATA_SEQUENCER = "CELATONE_QUERY_BLOCK_DATA_SEQUENCER", BLOCK_DATA_JSON_RPC = "CELATONE_QUERY_BLOCK_DATA_JSON_RPC", - BLOCK_LATEST_HEIGHT_LCD = "CELATONE_QUERY_BLOCK_LATEST_HEIGHT_LCD", + BLOCK_LATEST_HEIGHT_REST = "CELATONE_QUERY_BLOCK_LATEST_HEIGHT_REST", BLOCK_TIME_AVERAGE_SEQUENCER = "CELATONE_QUERY_BLOCK_TIME_AVERAGE_SEQUENCER", BLOCKS_SEQUENCER = "CELATONE_QUERY_BLOCKS_SEQUENCER", // CODE GQL CODES = "CELATONE_QUERY_CODES", - CODES_LCD = "CELATONE_QUERY_CODES_LCD", + CODES_REST = "CELATONE_QUERY_CODES_REST", CODES_BY_ADDRESS = "CELATONE_QUERY_CODES_BY_ADDRESS", ALL_CODES_BY_ADDRESS = "CELATONE_QUERY_ALL_CODES_BY_ADDRESS", CODE_LIST = "CELATONE_QUERY_CODE_LIST", CODE_DATA = "CELATONE_QUERY_CODE_DATA", - CODE_DATA_LCD = "CELATONE_QUERY_CODE_DATA_LCD", + CODE_DATA_REST = "CELATONE_QUERY_CODE_DATA_REST", // CONTRACT CONTRACTS = "CELATONE_QUERY_CONTRACTS", CONTRACT_DATA = "CELATONE_QUERY_CONTRACT_DATA", CONTRACT_QUERY_MSGS = "CELATONE_QUERY_CONTRACT_QUERY_MSGS", - CONTRACT_QUERY_LCD = "CELATONE_QUERY_CONTRACT_QUERY_LCD", - CONTRACT_STATES_LCD = "CELATONE_QUERY_CONTRACT_STATES_LCD", + CONTRACT_QUERY_REST = "CELATONE_QUERY_CONTRACT_QUERY_REST", + CONTRACT_STATES_REST = "CELATONE_QUERY_CONTRACT_STATES_REST", CONTRACTS_BY_CODE_ID = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID", - CONTRACTS_BY_CODE_ID_LCD = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_LCD", + CONTRACTS_BY_CODE_ID_REST = "CELATONE_QUERY_CONTRACTS_BY_CODE_ID_REST", INSTANTIATED_CONTRACTS_BY_ADDRESS = "CELATONE_QUERY_INSTANTIATED_CONTRACTS_BY_ADDRESS", ALL_INSTANTIATED_CONTRACTS_BY_ADDRESS = "CELATONE_QUERY_ALL_INSTANTIATED_CONTRACTS_BY_ADDRESS", - INSTANTIATED_CONTRACTS_BY_ADDRESS_LCD = "CELATONE_QUERY_INSTANTIATED_CONTRACTS_BY_ADDRESS_LCD", + INSTANTIATED_CONTRACTS_BY_ADDRESS_REST = "CELATONE_QUERY_INSTANTIATED_CONTRACTS_BY_ADDRESS_REST", ADMIN_CONTRACTS_BY_ADDRESS = "CELATONE_QUERY_ADMIN_CONTRACTS_BY_ADDRESS", ALL_ADMIN_CONTRACTS_BY_ADDRESS = "CELATONE_QUERY_ALL_ADMIN_CONTRACTS_BY_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_BY_CONTRACT_ADDRESS_LCD = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_LCD", - CONTRACT_CW2_INFO_LCD = "CELATONE_QUERY_CONTRACT_CW2_INFO_LCD", + CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_REST = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_REST", + CONTRACT_CW2_INFO_REST = "CELATONE_QUERY_CONTRACT_CW2_INFO_REST", // X/STAKING - STAKING_PARAMS_LCD = "CELATONE_QUERY_STAKING_PARAMS_LCD", - DELEGATIONS_BY_ADDRESS_LCD = "CELATONE_QUERY_DELEGATIONS_BY_ADDRESS_LCD", - UNBONDINGS_BY_ADDRESS_LCD = "CELATONE_QUERY_UNBONDINGS_BY_ADDRESS_LCD", - REDELEGATIONS_BY_ADDRESS_LCD = "CELATONE_QUERY_REDELEGATIONS_BY_ADDRESS_LCD", - DELEGATION_REWARDS_BY_ADDRESS_LCD = "CELATONE_QUERY_DELEGATION_REWARDS_BY_ADDRESS_LCD", - COMMISSIONS_BY_VALIDATOR_ADDRESS_LCD = "CELATONE_QUERY_COMMISSION_BY_VALIDATOR_ADDRESS_LCD", + STAKING_PARAMS_REST = "CELATONE_QUERY_STAKING_PARAMS_REST", + DELEGATIONS_BY_ADDRESS_REST = "CELATONE_QUERY_DELEGATIONS_BY_ADDRESS_REST", + UNBONDINGS_BY_ADDRESS_REST = "CELATONE_QUERY_UNBONDINGS_BY_ADDRESS_REST", + REDELEGATIONS_BY_ADDRESS_REST = "CELATONE_QUERY_REDELEGATIONS_BY_ADDRESS_REST", + DELEGATION_REWARDS_BY_ADDRESS_REST = "CELATONE_QUERY_DELEGATION_REWARDS_BY_ADDRESS_REST", + COMMISSIONS_BY_VALIDATOR_ADDRESS_REST = "CELATONE_QUERY_COMMISSION_BY_VALIDATOR_ADDRESS_REST", DELEGATIONS_BY_ADDRESS = "CELATONE_QUERY_DELEGATIONS_BY_ADDRESS", // VALIDATOR VALIDATORS = "CELATONE_QUERY_VALIDATORS", - VALIDATORS_LCD = "CELATONE_QUERY_VALIDATORS_LCD", + VALIDATORS_REST = "CELATONE_QUERY_VALIDATORS_REST", VALIDATOR_DATA = "CELATONE_QUERY_VALIDATOR_DATA", - VALIDATOR_DATA_LCD = "CELATONE_QUERY_VALIDATOR_DATA_LCD", + VALIDATOR_DATA_REST = "CELATONE_QUERY_VALIDATOR_DATA_REST", VALIDATOR_IDENTITY = "CELATONE_QUERY_VALIDATOR_IDENTITY", VALIDATOR_UPTIME = "CELATONE_QUERY_VALIDATOR_UPTIME", VALIDATOR_HISTORICAL_POWERS = "CELATONE_QUERY_VALIDATOR_HISTORICAL_POWERS", @@ -77,8 +77,8 @@ export enum CELATONE_QUERY_KEYS { FAUCET_INFO = "CELATONE_QUERY_FAUCET_INFO", // X/GOV PROPOSAL_DATA = "CELATONE_QUERY_PROPOSAL_DATA", - PROPOSAL_DATA_LCD = "CELATONE_QUERY_PROPOSAL_DATA_LCD", - PROPOSAL_DEPOSITS_LCD = "CELATONE_QUERY_PROPOSAL_DEPOSITS_LCD", + PROPOSAL_DATA_REST = "CELATONE_QUERY_PROPOSAL_DATA_REST", + PROPOSAL_DEPOSITS_REST = "CELATONE_QUERY_PROPOSAL_DEPOSITS_REST", PROPOSAL_VOTES_INFO = "CELATONE_QUERY_PROPOSAL_VOTES_INFO", PROPOSAL_VOTES = "CELATONE_QUERY_PROPOSAL_VOTES", PROPOSAL_VALIDATOR_VOTES = "CELATONE_QUERY_PROPOSAL_VALIDATOR_VOTES", @@ -86,10 +86,10 @@ export enum CELATONE_QUERY_KEYS { RELATED_PROPOSALS_BY_CONTRACT_ADDRESS = "CELATONE_QUERY_RELATED_PROPOSALS_BY_CONTRACT_ADDRESS", PROPOSALS_BY_ADDRESS = "CELATONE_QUERY_PROPOSALS_BY_ADDRESS", PROPOSALS = "CELATONE_QUERY_PROPOSALS", - PROPOSALS_LCD = "CELATONE_QUERY_PROPOSALS_LCD", + PROPOSALS_REST = "CELATONE_QUERY_PROPOSALS_REST", PROPOSAL_PARAMS = "CELATONE_QUERY_PROPOSAL_PARAMS", PROPOSAL_TYPES = "CELATONE_QUERY_PROPOSAL_TYPES", - UPLOAD_ACCESS_PARAMS_LCD = "CELATONE_QUERY_UPLOAD_ACCESS_PARAMS_LCD", + UPLOAD_ACCESS_PARAMS_REST = "CELATONE_QUERY_UPLOAD_ACCESS_PARAMS_REST", // PUBLIC PROJECT PUBLIC_PROJECTS = "CELATONE_QUERY_PUBLIC_PROJECTS", PUBLIC_PROJECT_BY_SLUG = "CELATONE_QUERY_PUBLIC_PROJECT_BY_SLUG", @@ -103,17 +103,17 @@ export enum CELATONE_QUERY_KEYS { TXS_BY_ADDRESS = "CELATONE_QUERY_TXS_BY_ADDRESS", TXS_COUNT_SEQUENCER = "CELATONE_QUERY_TXS_COUNT_SEQUENCER", TXS_COUNT_BY_ADDRESS = "CELATONE_QUERY_TXS_COUNT_BY_ADDRESS", - TXS_BY_ADDRESS_LCD = "CELATONE_QUERY_TXS_BY_ADDRESS_LCD", + TXS_BY_ADDRESS_REST = "CELATONE_QUERY_TXS_BY_ADDRESS_REST", TXS_BY_ADDRESS_SEQUENCER = "CELATONE_QUERY_TXS_BY_ADDRESS_SEQUENCER", TXS_BY_ADDRESS_PAGINATION_SEQUENCER = "CELATONE_QUERY_TXS_BY_ADDRESS_PAGINATION_SEQUENCER", - TXS_BY_CONTRACT_ADDRESS_LCD = "CELATONE_QUERY_TXS_BY_CONTRACT_ADDRESS_LCD", + TXS_BY_CONTRACT_ADDRESS_REST = "CELATONE_QUERY_TXS_BY_CONTRACT_ADDRESS_REST", TXS = "CELATONE_QUERY_TXS", TXS_SEQUENCER = "CELATONE_QUERY_TXS_SEQUENCER", TXS_BY_BLOCK_HEIGHT = "CELATONE_QUERY_TXS_BY_BLOCK_HEIGHT", TXS_BY_BLOCK_HEIGHT_SEQUENCER = "CELATONE_QUERY_TXS_BY_BLOCK_HEIGHT_SEQUENCER", // ICNS - ICNS_NAMES_BY_ADDRESS_LCD = "CELATONE_QUERY_ICNS_NAMES_BY_ADDRESS_LCD", - ADDRESS_BY_ICNS_NAME_LCD = "CELATONE_QUERY_ADDRESS_BY_ICNS_NAME_LCD", + ICNS_NAMES_BY_ADDRESS_REST = "CELATONE_QUERY_ICNS_NAMES_BY_ADDRESS_REST", + ADDRESS_BY_ICNS_NAME_REST = "CELATONE_QUERY_ADDRESS_BY_ICNS_NAME_REST", // INITA USERNAME INITIA_USERNAME_BY_ADDRESS = "CELATONE_QUERY_INITIA_USERNAME_BY_ADDRESS", ADDRESS_BY_INITIA_USERNAME = "CELATONE_QUERY_ADDRESS_BY_INITIA_USERNAME", @@ -128,7 +128,7 @@ export enum CELATONE_QUERY_KEYS { // MODULES MODULE_DATA = "CELATONE_QUERY_MODULE_DATA", MODULES_BY_ADDRESS = "CELATONE_QUERY_MODULES_BY_ADDRESS", - MODULE_BY_ADDRESS_LCD = "CELATONE_QUERY_MODULE_BY_ADDRESS_LCD", + MODULE_BY_ADDRESS_REST = "CELATONE_QUERY_MODULE_BY_ADDRESS_REST", MODULES = "CELATONE_QUERY_MODULES", FUNCTION_VIEW = "CELATONE_QUERY_FUNCTION_VIEW", MODULE_DECODE = "CELATONE_QUERY_MODULE_DECODE", @@ -138,8 +138,8 @@ export enum CELATONE_QUERY_KEYS { MODULE_PROPOSALS = "CELATONE_QUERY_MODULE_PROPOSALS", SCRIPT_DECODE = "CELATONE_QUERY_SCRIPT_DECODE", // EVM - EVM_PARAMS_LCD = "CELATONE_QUERY_EVM_PARAMS_LCD", - EVM_CODES_BY_ADDRESS_LCD = "CELATONE_QUERY_EVM_CODES_BY_ADDRESS_LCD", + EVM_PARAMS_REST = "CELATONE_QUERY_EVM_PARAMS_REST", + EVM_CODES_BY_ADDRESS_REST = "CELATONE_QUERY_EVM_CODES_BY_ADDRESS_REST", EVM_CONTRACT_INFO_SEQUENCER = "CELATONE_QUERY_EVM_CONTRACT_INFO_SEQUENCER", EVM_TX_HASH_BY_COSMOS_TX_HASH = "CELATONE_QUERY_EVM_TX_HASH_BY_COSMOS_TX_HASH", EVM_TX_HASHES_BY_COSMOS_TX_HASHES = "CELATONE_QUERY_EVM_TX_HASHES_BY_COSMOS_TX_HASHES", @@ -158,7 +158,7 @@ export enum CELATONE_QUERY_KEYS { NFT_COLLECTIONS_BY_ACCOUNT = "CELATONE_QUERY_NFT_COLLECTIONS_BY_ACCOUNT", NFTS = "CELATONE_QUERY_NFTS", NFT_BY_NFT_ADDRESS = "CELATONE_QUERY_NFT_BY_NFT_ADDRESS", - NFT_BY_NFT_ADDRESS_LCD = "CELATONE_QUERY_NFT_BY_NFT_ADDRESS_LCD", + NFT_BY_NFT_ADDRESS_REST = "CELATONE_QUERY_NFT_BY_NFT_ADDRESS_REST", NFT_TOKEN_MINT_INFO = "CELATONE_QUERY_NFT_TOKEN_MINT_INFO", NFT_METADATA = "CELATONE_QUERY_NFT_METADATA", NFT_TRANSACTIONS = "CELATONE_QUERY_NFT_TRANSACTIONS", diff --git a/src/lib/components/AlertPaginationLcd.tsx b/src/lib/components/AlertPaginationRest.tsx similarity index 64% rename from src/lib/components/AlertPaginationLcd.tsx rename to src/lib/components/AlertPaginationRest.tsx index 548926c52..1eeffb451 100644 --- a/src/lib/components/AlertPaginationLcd.tsx +++ b/src/lib/components/AlertPaginationRest.tsx @@ -1,9 +1,9 @@ import { Alert, AlertDescription } from "@chakra-ui/react"; -export const AlertPaginationLcd = () => ( +export const AlertPaginationRest = () => ( - Error fetching data from LCD. Please try again later. + Error fetching data from REST. Please try again later. ); diff --git a/src/lib/components/modal/MoveCodeSnippet.tsx b/src/lib/components/modal/MoveCodeSnippet.tsx index 0d0336ec8..4e1708f12 100644 --- a/src/lib/components/modal/MoveCodeSnippet.tsx +++ b/src/lib/components/modal/MoveCodeSnippet.tsx @@ -65,7 +65,7 @@ const MoveCodeSnippet = ({ const { isOpen, onClose, onOpen } = useDisclosure(); const { currentChainId, - chainConfig: { chain, lcd: lcdEndpoint, rpc: rpcEndpoint }, + chainConfig: { chain, rest: restEndpoint, rpc: rpcEndpoint }, theme, } = useCelatoneApp(); const gasPrice = useGas(); @@ -126,7 +126,7 @@ const MoveCodeSnippet = ({ { name: "Curl", mode: "sh", - snippet: `\n\ncurl '${lcdEndpoint}/initia/move/v1/accounts/${moduleAddress}/modules/${moduleName}/view_functions/${fn.name}' \\ + snippet: `\n\ncurl '${restEndpoint}/initia/move/v1/accounts/${moduleAddress}/modules/${moduleName}/view_functions/${fn.name}' \\ --data-raw '${formatedAbiData}'`, }, { @@ -149,7 +149,7 @@ ${daemonName} query move view $MODULE_ADDRESS \\ mode: "javascript", snippet: `import { LCDClient } from '@initia/initia.js' -const lcd = new LCDClient('${lcdEndpoint}', { +const lcd = new LCDClient('${restEndpoint}', { chainId: '${currentChainId}', }); const moduleAddress = @@ -178,7 +178,7 @@ viewModule(moduleAddress, moduleName, fnName);`, mode: "javascript", snippet: `import { LCDClient, Wallet, MnemonicKey, MsgExecute } from '@initia/initia.js'; -const lcd = new LCDClient('${lcdEndpoint}', { +const lcd = new LCDClient('${restEndpoint}', { chainId: '${currentChainId}', gasPrices: '${gasPriceStr}', gasAdjustment: '2.0', diff --git a/src/lib/components/modal/WasmCodeSnippet.tsx b/src/lib/components/modal/WasmCodeSnippet.tsx index dc9655b40..3e1481d91 100644 --- a/src/lib/components/modal/WasmCodeSnippet.tsx +++ b/src/lib/components/modal/WasmCodeSnippet.tsx @@ -59,7 +59,7 @@ const WasmCodeSnippet = ({ const isDisabled = !contractAddress || !message.length; const { currentChainId, - chainConfig: { chain, lcd: lcdEndpoint, rpc: rpcEndpoint }, + chainConfig: { chain, rest: restEndpoint, rpc: rpcEndpoint }, theme, } = useCelatoneApp(); const gasPrice = useGas(); @@ -93,7 +93,7 @@ ${daemonName} query wasm contract-state smart $CONTRACT_ADDRESS $QUERY_MSG \\ snippet: `import base64 import requests\n CONTRACT_ADDRESS = "${contractAddress}" -LCD_URL = "${lcdEndpoint}" +LCD_URL = "${restEndpoint}" QUERY_MSG = b'''${message}'''\n query_b64encoded = base64.b64encode(QUERY_MSG).decode("ascii") res = requests.get( @@ -123,7 +123,7 @@ queryContract(rpcURL, contractAddress, queryMsg);`, name: "Axios", mode: "javascript", snippet: `const axios = require('axios');\n -const lcdURL = '${lcdEndpoint}'; +const lcdURL = '${restEndpoint}'; const contractAddress = "${contractAddress}"; const queryMsg = ${message};\n diff --git a/src/lib/components/modal/code/SaveNewCode.tsx b/src/lib/components/modal/code/SaveNewCode.tsx index 1655d90b9..2f972b439 100644 --- a/src/lib/components/modal/code/SaveNewCode.tsx +++ b/src/lib/components/modal/code/SaveNewCode.tsx @@ -9,7 +9,7 @@ import { NumberInput, TextInput } from "lib/components/forms"; import { CustomIcon } from "lib/components/icon"; import { useGetMaxLengthError } from "lib/hooks"; import { useCodeStore } from "lib/providers/store"; -import { useCodeLcd } from "lib/services/wasm/code"; +import { useCodeRest } from "lib/services/wasm/code"; import type { BechAddr } from "lib/types"; import { getNameAndDescriptionDefault, @@ -59,7 +59,7 @@ export function SaveNewCodeModal({ buttonProps }: SaveNewCodeModalProps) { const { isCodeIdSaved, saveNewCode, updateCodeInfo, getCodeLocalInfo } = useCodeStore(); - const { refetch, isFetching, isRefetching } = useCodeLcd(Number(codeId), { + const { refetch, isFetching, isRefetching } = useCodeRest(Number(codeId), { enabled: false, retry: false, cacheTime: 0, diff --git a/src/lib/components/select-code/CodeSelect.tsx b/src/lib/components/select-code/CodeSelect.tsx index 8a43c1fd7..80a524ca0 100644 --- a/src/lib/components/select-code/CodeSelect.tsx +++ b/src/lib/components/select-code/CodeSelect.tsx @@ -6,7 +6,7 @@ import { UploadIcon } from "lib/components/icon"; import { useCodeStore } from "lib/providers/store"; import type { Code } from "lib/services/types"; import { useDerivedWasmVerifyInfo } from "lib/services/verification/wasm"; -import { useCodeLcd } from "lib/services/wasm/code"; +import { useCodeRest } from "lib/services/wasm/code"; import { AccessConfigPermission } from "lib/types"; import { getWasmVerifyStatus } from "lib/utils"; @@ -31,7 +31,7 @@ export const CodeSelect = ({ }: CodeSelectProps) => { const { getCodeLocalInfo } = useCodeStore(); const name = getCodeLocalInfo(codeId)?.name; - const { data } = useCodeLcd(codeId, { + const { data } = useCodeRest(codeId, { enabled: !!codeId, onSuccess: setCodeHash, }); diff --git a/src/lib/components/wallet-section/index.tsx b/src/lib/components/wallet-section/index.tsx index a89130bfd..2dc9d8c58 100644 --- a/src/lib/components/wallet-section/index.tsx +++ b/src/lib/components/wallet-section/index.tsx @@ -3,7 +3,7 @@ import type { MouseEventHandler } from "react"; import { AmpEvent, track } from "lib/amplitude"; import { useCurrentChain, useInitia } from "lib/app-provider"; -import { useIcnsNamesByAddressLcd } from "lib/services/name"; +import { useIcnsNamesByAddressRest } from "lib/services/name"; import { useInitiaUsernameByAddress } from "lib/services/username"; import { truncate } from "lib/utils"; @@ -20,7 +20,7 @@ export const WalletSection = () => { address, isInitia ); - const { data: icnsNames } = useIcnsNamesByAddressLcd(address, !isInitia); + const { data: icnsNames } = useIcnsNamesByAddressRest(address, !isInitia); const onClickConnect: MouseEventHandler = async (e) => { track(AmpEvent.USE_CLICK_WALLET); diff --git a/src/lib/hooks/useOpenTab.ts b/src/lib/hooks/useOpenTab.ts index 638d4db63..84ad570ef 100644 --- a/src/lib/hooks/useOpenTab.ts +++ b/src/lib/hooks/useOpenTab.ts @@ -8,10 +8,10 @@ import { import type { Option } from "lib/types"; import { openNewTab } from "lib/utils"; -export const useOpenTxTab = (type: "lcd" | "tx-page") => { +export const useOpenTxTab = (type: "rest" | "tx-page") => { const { currentChainId } = useCelatoneApp(); const txsApiRoute = useBaseApiRoute("txs"); - const baseUrl = type === "lcd" ? txsApiRoute : `/${currentChainId}/txs`; + const baseUrl = type === "rest" ? txsApiRoute : `/${currentChainId}/txs`; return useCallback( (txHash: Option) => { @@ -25,7 +25,7 @@ export const useOpenAssetTab = () => { const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useCallback( @@ -33,10 +33,10 @@ export const useOpenAssetTab = () => { openNewTab( isFullTier ? `${apiEndpoint}/${walletAddr}/balances` - : `${lcdEndpoint}/cosmos/bank/v1beta1/balances/${walletAddr}?pagination.limit=1000` + : `${restEndpoint}/cosmos/bank/v1beta1/balances/${walletAddr}?pagination.limit=1000` ); }, - [apiEndpoint, isFullTier, lcdEndpoint] + [apiEndpoint, isFullTier, restEndpoint] ); }; diff --git a/src/lib/layout/InformationFooter.tsx b/src/lib/layout/InformationFooter.tsx index 18aec1670..bdc828dae 100644 --- a/src/lib/layout/InformationFooter.tsx +++ b/src/lib/layout/InformationFooter.tsx @@ -6,7 +6,7 @@ import { useTierConfig } from "lib/app-provider"; import type { IconKeys } from "lib/components/icon"; import { CustomIcon } from "lib/components/icon"; import { USER_GUIDE_DOCS_LINK } from "lib/data"; -import { useLatestBlockLcd } from "lib/services/block"; +import { useLatestBlockRest } from "lib/services/block"; import { useOverviewsStats } from "lib/services/stats"; const FOOTER_BUTTONS = [ @@ -23,7 +23,7 @@ export const InformationFooter = () => { const { isFullTier } = useTierConfig(); const { data: overviewsStats, isLoading: isLoadingFull } = useOverviewsStats(isFullTier); - const { data: latestHeight, isLoading: isLoadingLite } = useLatestBlockLcd(); + const { data: latestHeight, isLoading: isLoadingLite } = useLatestBlockRest(); const latest = isFullTier ? overviewsStats?.latestBlock : latestHeight; const isLoading = isFullTier ? isLoadingFull : isLoadingLite; diff --git a/src/lib/model/account/index.ts b/src/lib/model/account/index.ts index 263fd7597..d2071d191 100644 --- a/src/lib/model/account/index.ts +++ b/src/lib/model/account/index.ts @@ -7,7 +7,7 @@ import { big } from "lib/types"; import { totalValueTokenWithValue } from "lib/utils"; import { useAccountDelegationInfosApi } from "./api"; -import { useAccountDelegationInfosLcd } from "./lcd"; +import { useAccountDelegationInfosRest } from "./rest"; // ------------------------------------------// // ----------------DELEGATIONS---------------// @@ -15,10 +15,10 @@ import { useAccountDelegationInfosLcd } from "./lcd"; export const useAccountDelegationInfos = (address: BechAddr) => { const isInitia = useInitia(); - const resLcd = useAccountDelegationInfosLcd(address, !isInitia); + const resRest = useAccountDelegationInfosRest(address, !isInitia); const resApi = useAccountDelegationInfosApi(address, isInitia); - return isInitia ? resApi : resLcd; + return isInitia ? resApi : resRest; }; export const useAccountTotalValue = (address: BechAddr) => { diff --git a/src/lib/model/account/lcd.ts b/src/lib/model/account/rest.ts similarity index 91% rename from src/lib/model/account/lcd.ts rename to src/lib/model/account/rest.ts index fb39d3916..0f918370b 100644 --- a/src/lib/model/account/lcd.ts +++ b/src/lib/model/account/rest.ts @@ -3,17 +3,17 @@ import { useMemo } from "react"; import { useValidateAddress } from "lib/app-provider"; import { useAssetInfos } from "lib/services/assetService"; import { - useCommissionsByValidatorAddressLcd, - useDelegationRewardsByAddressLcd, + useCommissionsByValidatorAddressRest, + useDelegationRewardsByAddressRest, } from "lib/services/distribution"; import { useMovePoolInfos } from "lib/services/move/poolService"; import { - useDelegationsByAddressLcd, - useRedelegationsByAddressLcd, - useStakingParamsLcd, - useUnbondingsByAddressLcd, + useDelegationsByAddressRest, + useRedelegationsByAddressRest, + useStakingParamsRest, + useUnbondingsByAddressRest, } from "lib/services/staking"; -import { useValidatorsLcd } from "lib/services/validator"; +import { useValidatorsRest } from "lib/services/validator"; import type { BechAddr, BechAddr20, @@ -33,7 +33,7 @@ import { import type { DelegationInfos } from "./types"; import { calBonded } from "./utils"; -export const useAccountDelegationInfosLcd = ( +export const useAccountDelegationInfosRest = ( address: BechAddr, enabled: boolean ) => { @@ -52,21 +52,21 @@ export const useAccountDelegationInfosLcd = ( }); const { data: stakingParams, isFetching: isStakingParamsLoading } = - useStakingParamsLcd(enabled); + useStakingParamsRest(enabled); const { data: delegations, isFetching: isDelegationsLoading } = - useDelegationsByAddressLcd(address, enabled); + useDelegationsByAddressRest(address, enabled); const { data: unbondings, isFetching: isUnbondingsLoading } = - useUnbondingsByAddressLcd(address, enabled); + useUnbondingsByAddressRest(address, enabled); const { data: redelegations, isFetching: isRedelegationsLoading } = - useRedelegationsByAddressLcd(address, enabled); + useRedelegationsByAddressRest(address, enabled); const { data: rewards, isFetching: isRewardsLoading } = - useDelegationRewardsByAddressLcd(address, enabled); + useDelegationRewardsByAddressRest(address, enabled); const { data: commissions, isFetching: isCommissionsLoading } = - useCommissionsByValidatorAddressLcd(valAddr, enabled); + useCommissionsByValidatorAddressRest(valAddr, enabled); const { data: validators, isFetching: isValidatorsLoading } = - useValidatorsLcd(enabled); + useValidatorsRest(enabled); const validatorsMap = useMemo( () => validators?.reduce>( diff --git a/src/lib/model/contract.ts b/src/lib/model/contract.ts index b9e5f0fed..3618b92b6 100644 --- a/src/lib/model/contract.ts +++ b/src/lib/model/contract.ts @@ -3,7 +3,7 @@ import { INSTANTIATED_LIST_NAME } from "lib/data"; import { useContractStore } from "lib/providers/store"; import { useAllInstantiatedContractsByAddress, - useInstantiatedContractsByAddressLcd, + useInstantiatedContractsByAddressRest, } from "lib/services/wasm/contract"; import type { ContractListInfo } from "lib/stores/contract"; import { formatSlugName, getCurrentDate } from "lib/utils"; @@ -19,12 +19,12 @@ export const useInstantiatedByMe = (enable: boolean): InstantiatedByMeState => { const { data: dataApi, isLoading: isApiLoading } = useAllInstantiatedContractsByAddress(address, enable && isFullTier); - const { data: dataLcd, isLoading: isLcdLoading } = - useInstantiatedContractsByAddressLcd(address, enable && !isFullTier); + const { data: dataRest, isLoading: isRestLoading } = + useInstantiatedContractsByAddressRest(address, enable && !isFullTier); const [contracts = [], isLoading] = isFullTier ? [dataApi?.items, isApiLoading] - : [dataLcd, isLcdLoading]; + : [dataRest, isRestLoading]; const { getContractLocalInfo } = useContractStore(); return { diff --git a/src/lib/pages/account-details/components/tables/instantiated-contracts/Lite.tsx b/src/lib/pages/account-details/components/tables/instantiated-contracts/Lite.tsx index 2401b5c8a..4a95fda7d 100644 --- a/src/lib/pages/account-details/components/tables/instantiated-contracts/Lite.tsx +++ b/src/lib/pages/account-details/components/tables/instantiated-contracts/Lite.tsx @@ -3,7 +3,7 @@ import { Box } from "@chakra-ui/react"; import { useInternalNavigate, useMobile } from "lib/app-provider"; import { ErrorFetching } from "lib/components/state"; import { ContractsTable, MobileTitle, ViewMore } from "lib/components/table"; -import { useAccountContractsLcd } from "lib/pages/account-details/data"; +import { useAccountContractsRest } from "lib/pages/account-details/data"; import type { BechAddr32 } from "lib/types"; import type { InstantiatedContractsTableProps } from "./types"; @@ -21,7 +21,7 @@ export const InstantiatedContractsTableLite = ({ pathname: "/contracts/[contract]", query: { contract }, }); - const { contracts, isLoading } = useAccountContractsLcd(address); + const { contracts, isLoading } = useAccountContractsRest(address); const contractsCount = contracts?.length; const isMobileOverview = isMobile && !!onViewMore; diff --git a/src/lib/pages/account-details/components/tables/txs/lite.tsx b/src/lib/pages/account-details/components/tables/txs/lite.tsx index 851be95c6..cceee0c81 100644 --- a/src/lib/pages/account-details/components/tables/txs/lite.tsx +++ b/src/lib/pages/account-details/components/tables/txs/lite.tsx @@ -11,7 +11,7 @@ import { TransactionsTable, ViewMore, } from "lib/components/table"; -import { useTxsByAddressLcd } from "lib/services/tx"; +import { useTxsByAddressRest } from "lib/services/tx"; import type { BechAddr20 } from "lib/types"; import type { TxsTableProps } from "./types"; @@ -40,7 +40,7 @@ export const TxsTableLite = ({ }, }); - const { data, isLoading, error } = useTxsByAddressLcd( + const { data, isLoading, error } = useTxsByAddressRest( address as BechAddr20, undefined, onViewMore ? 5 : pageSize, @@ -76,8 +76,8 @@ export const TxsTableLite = ({ color="warning.main" /> - Please note that account transactions are queried from the LCD and - may have pruned transactions that will not be displayed. + Please note that account transactions are queried from the Rest + and may have pruned transactions that will not be displayed. {!isMobileOverview && ( @@ -91,7 +91,7 @@ export const TxsTableLite = ({ ) } diff --git a/src/lib/pages/account-details/components/tables/txs/sequencer.tsx b/src/lib/pages/account-details/components/tables/txs/sequencer.tsx index a5671bfae..02474b3de 100644 --- a/src/lib/pages/account-details/components/tables/txs/sequencer.tsx +++ b/src/lib/pages/account-details/components/tables/txs/sequencer.tsx @@ -57,7 +57,7 @@ export const TxsTableSequencer = ({ address, onViewMore }: TxsTableProps) => { ) } diff --git a/src/lib/pages/account-details/data.ts b/src/lib/pages/account-details/data.ts index f26bd841f..b3646135a 100644 --- a/src/lib/pages/account-details/data.ts +++ b/src/lib/pages/account-details/data.ts @@ -6,7 +6,7 @@ import { useCodesByAddress } from "lib/services/wasm/code"; import { useAdminContractsByAddress, useInstantiatedContractsByAddress, - useInstantiatedContractsByAddressLcd, + useInstantiatedContractsByAddressRest, } from "lib/services/wasm/contract"; import type { BechAddr, @@ -110,8 +110,10 @@ export const useAccountContracts = ( }; }; -export const useAccountContractsLcd = (address: BechAddr): AccountContracts => { - const { data: contracts, isLoading } = useInstantiatedContractsByAddressLcd( +export const useAccountContractsRest = ( + address: BechAddr +): AccountContracts => { + const { data: contracts, isLoading } = useInstantiatedContractsByAddressRest( address, true ); diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index 63e014958..bdf48802c 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -29,7 +29,7 @@ import { useAccountDelegationInfos } from "lib/model/account"; import { useAccountStore } from "lib/providers/store"; import { useAccountData } from "lib/services/account"; import { useModulesByAddress } from "lib/services/move/module"; -import { useResourcesByAddressLcd } from "lib/services/move/resource"; +import { useResourcesByAddressRest } from "lib/services/move/resource"; import { useNftsByAccountAddress, useNftsByAccountByCollectionSequencer, @@ -119,7 +119,7 @@ const AccountDetailsBody = ({ const { data: modulesData, isFetching: isModulesLoading } = useModulesByAddress({ address: accountAddress }); const { data: resourcesData, isFetching: isResourceLoading } = - useResourcesByAddressLcd(accountAddress); + useResourcesByAddressRest(accountAddress); // nft const { data: nfts, isFetching: isNftsCountLoading } = useNftsByAccountAddress(hexAddress, 10, 0, undefined, "", { diff --git a/src/lib/pages/block-details/components/BlockDetailsTop.tsx b/src/lib/pages/block-details/components/BlockDetailsTop.tsx index 4dc21d8c7..ee065c86c 100644 --- a/src/lib/pages/block-details/components/BlockDetailsTop.tsx +++ b/src/lib/pages/block-details/components/BlockDetailsTop.tsx @@ -31,13 +31,13 @@ interface BlockDetailsTopProps { export const BlockDetailsTop = ({ blockData }: BlockDetailsTopProps) => { const block = Number(blockData.height); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - const openLcdPage = () => { + const openRestPage = () => { trackUseViewJSON("Block Details"); openNewTab( - `${lcdEndpoint}/cosmos/base/tendermint/v1beta1/blocks/${blockData.height}` + `${restEndpoint}/cosmos/base/tendermint/v1beta1/blocks/${blockData.height}` ); }; @@ -89,7 +89,7 @@ export const BlockDetailsTop = ({ blockData }: BlockDetailsTopProps) => { variant="ghost-gray" size={{ base: "sm", md: "md" }} rightIcon={} - onClick={openLcdPage} + onClick={openRestPage} > View in JSON diff --git a/src/lib/pages/block-details/components/BlockTxsTableLite.tsx b/src/lib/pages/block-details/components/BlockTxsTableLite.tsx index 0d30829d6..3a023e74e 100644 --- a/src/lib/pages/block-details/components/BlockTxsTableLite.tsx +++ b/src/lib/pages/block-details/components/BlockTxsTableLite.tsx @@ -1,13 +1,13 @@ import { EmptyState } from "lib/components/state"; import { TableTitle, TransactionsTable } from "lib/components/table"; -import { useBlockDataLcd } from "lib/services/block"; +import { useBlockDataRest } from "lib/services/block"; interface BlockTxsTableProps { height: number; } export const BlockTxsTableLite = ({ height }: BlockTxsTableProps) => { - const { data, isLoading } = useBlockDataLcd(height); + const { data, isLoading } = useBlockDataRest(height); const total = data?.transactions.length; return ( diff --git a/src/lib/pages/block-details/data.ts b/src/lib/pages/block-details/data.ts index c360a8b48..b0cb56f6d 100644 --- a/src/lib/pages/block-details/data.ts +++ b/src/lib/pages/block-details/data.ts @@ -1,19 +1,19 @@ import { useMemo } from "react"; -import { useBlockDataLcd } from "lib/services/block"; -import { useValidatorsLcd } from "lib/services/validator"; +import { useBlockDataRest } from "lib/services/block"; +import { useValidatorsRest } from "lib/services/validator"; import type { BlockData, Nullable, Option, Validator } from "lib/types"; -export const useBlockDataWithValidatorLcd = ( +export const useBlockDataWithValidatorRest = ( height: number ): { data: Option; isLoading: boolean; } => { const { data: blockData, isLoading: isLoadingBlockData } = - useBlockDataLcd(height); + useBlockDataRest(height); const { data: validators, isLoading: isLoadingValidators } = - useValidatorsLcd(); + useValidatorsRest(); const proposer = useMemo>(() => { if (!blockData || !validators) return null; diff --git a/src/lib/pages/block-details/lite.tsx b/src/lib/pages/block-details/lite.tsx index a647d15a9..3166f3d86 100644 --- a/src/lib/pages/block-details/lite.tsx +++ b/src/lib/pages/block-details/lite.tsx @@ -2,23 +2,23 @@ import { Breadcrumb } from "lib/components/Breadcrumb"; import { Loading } from "lib/components/Loading"; import { EmptyState } from "lib/components/state"; import { UserDocsLink } from "lib/components/UserDocsLink"; -import { useLatestBlockLcd } from "lib/services/block"; +import { useLatestBlockRest } from "lib/services/block"; import { BlockDetailsTop, BlockInfo, BlockTxsTableLite } from "./components"; import { InvalidBlock } from "./components/InvalidBlock"; -import { useBlockDataWithValidatorLcd } from "./data"; +import { useBlockDataWithValidatorRest } from "./data"; export const BlockDetailsLite = ({ height }: { height: number }) => { - const { data, isLoading } = useBlockDataWithValidatorLcd(height); + const { data, isLoading } = useBlockDataWithValidatorRest(height); const { data: latestHeight, isLoading: isLatestHeightLoading } = - useLatestBlockLcd(); + useLatestBlockRest(); if (isLoading || isLatestHeightLoading) return ; if (latestHeight && latestHeight > height && !data) return ( navigate({ @@ -33,7 +33,7 @@ export const CodeContractsTableLite = observer( return ( <> - {data && !!error && } + {data && !!error && } { - const { data, isLoading } = useCodeLcd(codeId, { +export const useCodeDataRest = (codeId: number, enabled: boolean) => { + const { data, isLoading } = useCodeRest(codeId, { enabled, }); @@ -56,9 +56,9 @@ export const useCodeContracts = ( }; }; -export const useCodeContractsLcd = (codeId: number) => { +export const useCodeContractsRest = (codeId: number) => { const { getContractLocalInfo } = useContractStore(); - const { data, ...rest } = useContractsByCodeIdLcd(codeId); + const { data, ...rest } = useContractsByCodeIdRest(codeId); return { data: data?.pages.flatMap((page) => diff --git a/src/lib/pages/code-details/index.tsx b/src/lib/pages/code-details/index.tsx index 310b39c63..03f7206db 100644 --- a/src/lib/pages/code-details/index.tsx +++ b/src/lib/pages/code-details/index.tsx @@ -30,7 +30,7 @@ import { } from "./components/code-info"; import { CodeSchemaSection } from "./components/code-schema-section"; import { CodeVerificationSection } from "./components/CodeVerificationSection"; -import { useCodeDataLcd } from "./data"; +import { useCodeDataRest } from "./data"; import { TabIndex, zCodeDetailsQueryParams } from "./types"; const codeTabId = "codeDetailsTab"; @@ -51,8 +51,8 @@ const CodeDetailsBody = observer(({ codeId, tab }: CodeDetailsBodyProps) => { const { getSchemaByCodeHash } = useSchemaStore(); const resApi = useCodeData(codeId, isFullTier); - const resLcd = useCodeDataLcd(codeId, !isFullTier); - const { data, isLoading } = isFullTier ? resApi : resLcd; + const resRest = useCodeDataRest(codeId, !isFullTier); + const { data, isLoading } = isFullTier ? resApi : resRest; const { data: derivedWasmVerifyInfo, diff --git a/src/lib/pages/codes/components/RecentCodesTableLite.tsx b/src/lib/pages/codes/components/RecentCodesTableLite.tsx index 05d2d7981..270b51a10 100644 --- a/src/lib/pages/codes/components/RecentCodesTableLite.tsx +++ b/src/lib/pages/codes/components/RecentCodesTableLite.tsx @@ -1,11 +1,11 @@ import { observer } from "mobx-react-lite"; import { useInternalNavigate } from "lib/app-provider"; -import { AlertPaginationLcd } from "lib/components/AlertPaginationLcd"; +import { AlertPaginationRest } from "lib/components/AlertPaginationRest"; import { LoadNext } from "lib/components/LoadNext"; import { EmptyState } from "lib/components/state"; import { CodesTable } from "lib/components/table"; -import { useRecentCodesLcd } from "../data"; +import { useRecentCodesRest } from "../data"; export const RecentCodesTableLite = observer(() => { const navigate = useInternalNavigate(); @@ -16,7 +16,7 @@ export const RecentCodesTableLite = observer(() => { hasNextPage, isLoading, isFetchingNextPage, - } = useRecentCodesLcd(); + } = useRecentCodesRest(); const onRowSelect = (codeId: number) => navigate({ @@ -26,7 +26,7 @@ export const RecentCodesTableLite = observer(() => { return ( <> - {data && !!error && } + {data && !!error && } { +export const useRecentCodesRest = () => { const { getCodeLocalInfo, isCodeIdSaved } = useCodeStore(); - const { data, ...rest } = useCodesLcd(); + const { data, ...rest } = useCodesRest(); return { data: data?.pages.flatMap((page) => diff --git a/src/lib/pages/contract-details/components/InstantiateInfo.tsx b/src/lib/pages/contract-details/components/InstantiateInfo.tsx index fc16d5ee1..fb4f4cd9b 100644 --- a/src/lib/pages/contract-details/components/InstantiateInfo.tsx +++ b/src/lib/pages/contract-details/components/InstantiateInfo.tsx @@ -11,7 +11,7 @@ import { ExplorerLink } from "lib/components/ExplorerLink"; import { LabelText } from "lib/components/LabelText"; import { WasmVerifySubmitModal } from "lib/components/modal"; import { WasmVerifyBadge } from "lib/components/WasmVerifyBadge"; -import type { Contract, ContractRest } from "lib/services/types"; +import type { Contract, ContractRestApi } from "lib/services/types"; import type { CodeLocalInfo } from "lib/stores/code"; import type { Nullable, Nullish, Option, WasmVerifyInfo } from "lib/types"; import { WasmVerifyStatus } from "lib/types"; @@ -25,7 +25,7 @@ import { getAddressTypeText } from "lib/utils/address"; interface InstantiateInfoProps { contract: Contract; - contractRest: Nullable; + contractRest: Nullable; codeLocalInfo: Option; wasmVerifyInfo: Nullish; } diff --git a/src/lib/pages/contract-details/components/command-section/index.tsx b/src/lib/pages/contract-details/components/command-section/index.tsx index aa9ebe253..f0299368e 100644 --- a/src/lib/pages/contract-details/components/command-section/index.tsx +++ b/src/lib/pages/contract-details/components/command-section/index.tsx @@ -1,7 +1,7 @@ import { Flex, Text } from "@chakra-ui/react"; import { useExecuteCmds } from "lib/hooks"; -import { useContractQueryMsgsLcd } from "lib/services/wasm/contract"; +import { useContractQueryMsgsRest } from "lib/services/wasm/contract"; import type { BechAddr32, Nullish, WasmVerifyInfo } from "lib/types"; import { CommandSectionHeader } from "./CommandSectionHeader"; @@ -19,7 +19,7 @@ export const CommandSection = ({ ...props }: CommandSectionProps) => { const { isFetching: isQueryCmdsFetching, data: queryCmds = [] } = - useContractQueryMsgsLcd(contractAddress); + useContractQueryMsgsRest(contractAddress); const { isFetching: isExecuteCmdsFetching, execCmds } = useExecuteCmds(contractAddress); diff --git a/src/lib/pages/contract-details/components/contract-states/index.tsx b/src/lib/pages/contract-details/components/contract-states/index.tsx index 81dd981f7..105fc36e9 100644 --- a/src/lib/pages/contract-details/components/contract-states/index.tsx +++ b/src/lib/pages/contract-details/components/contract-states/index.tsx @@ -11,7 +11,7 @@ import { useMemo, useState } from "react"; import { AmpEvent, track, trackContractStatesLoad } from "lib/amplitude"; import InputWithIcon from "lib/components/InputWithIcon"; -import { useContractStatesLcd } from "lib/services/wasm/contractState"; +import { useContractStatesRest } from "lib/services/wasm/contractState"; import type { BechAddr32 } from "lib/types"; import { groupContractStatesByFirstIndex } from "lib/utils"; @@ -39,7 +39,7 @@ export const ContractStates = ({ contractAddress }: ContractStatesProps) => { hasNextPage, isFetching, isFetchingNextPage, - } = useContractStatesLcd(contractAddress, limit); + } = useContractStatesRest(contractAddress, limit); const [selectedNamespace, setSelectedNamespace] = useState("all"); const [keyword, setKeyword] = useState(""); @@ -120,7 +120,7 @@ export const ContractStates = ({ contractAddress }: ContractStatesProps) => { {!!error && ( - Error fetching data from LCD. Please refresh to try again. + Error fetching data from REST. Please refresh to try again. )} diff --git a/src/lib/pages/contract-details/components/tables/TxsTable.tsx b/src/lib/pages/contract-details/components/tables/TxsTable.tsx index 99afde049..aa03b36c1 100644 --- a/src/lib/pages/contract-details/components/tables/TxsTable.tsx +++ b/src/lib/pages/contract-details/components/tables/TxsTable.tsx @@ -4,7 +4,7 @@ import { usePaginator } from "lib/components/pagination/usePaginator"; import { EmptyState, ErrorFetching } from "lib/components/state"; import { TransactionsTable } from "lib/components/table"; import { DEFAULT_TX_FILTERS } from "lib/data"; -import { useTxsByAddress, useTxsByContractAddressLcd } from "lib/services/tx"; +import { useTxsByAddress, useTxsByContractAddressRest } from "lib/services/tx"; import type { BechAddr32, Option } from "lib/types"; interface TxsTableProps { @@ -48,12 +48,17 @@ export const TxsTable = ({ offset, { enabled: isFullTier } ); - const resLcd = useTxsByContractAddressLcd(contractAddress, pageSize, offset, { - enabled: !isFullTier, - onSuccess: ({ total }) => setTotalData(total), - }); + const resRest = useTxsByContractAddressRest( + contractAddress, + pageSize, + offset, + { + enabled: !isFullTier, + onSuccess: ({ total }) => setTotalData(total), + } + ); - const { data, isLoading, error } = isFullTier ? resApi : resLcd; + const { data, isLoading, error } = isFullTier ? resApi : resRest; return ( <> @@ -70,7 +75,7 @@ export const TxsTable = ({ message={ isFullTier ? "This contract does not have any transactions." - : "This contract does not have any transactions, or they are too old and have been pruned from the LCD." + : "This contract does not have any transactions, or they are too old and have been pruned from the REST." } /> ) diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationTableLite.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationTableLite.tsx index 62053f0cb..a23c03fd3 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationTableLite.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationTableLite.tsx @@ -2,7 +2,7 @@ import { useMobile } from "lib/app-provider"; import { Loading } from "lib/components/Loading"; import { EmptyState, ErrorFetching } from "lib/components/state"; import { MobileTableContainer, TableContainer } from "lib/components/table"; -import { useMigrationHistoriesLcd } from "lib/pages/contract-details/data"; +import { useMigrationHistoriesRest } from "lib/pages/contract-details/data"; import { useWasmVerifyInfos } from "lib/services/verification/wasm"; import type { BechAddr32 } from "lib/types"; @@ -18,7 +18,7 @@ export const MigrationTableLite = ({ contractAddress, }: MigrationTableLiteProps) => { const isMobile = useMobile(); - const { data, error, isLoading } = useMigrationHistoriesLcd(contractAddress); + const { data, error, isLoading } = useMigrationHistoriesRest(contractAddress); const { data: wasmVerifyInfos, isLoading: isWasmVerifyInfosLoading } = useWasmVerifyInfos(data?.map((history) => history.codeId) ?? [], !!data); diff --git a/src/lib/pages/contract-details/data.ts b/src/lib/pages/contract-details/data.ts index 3b3afbeab..383b02264 100644 --- a/src/lib/pages/contract-details/data.ts +++ b/src/lib/pages/contract-details/data.ts @@ -3,31 +3,34 @@ import type { UseQueryResult } from "@tanstack/react-query"; import { useTierConfig } from "lib/app-provider"; import { useCodeStore, useContractStore } from "lib/providers/store"; import type { ContractData } from "lib/services/types"; -import { useCodeLcd } from "lib/services/wasm/code"; +import { useCodeRest } from "lib/services/wasm/code"; import { - useContractCw2InfoLcd, + useContractCw2InfoRest, useContractData, useMigrationHistoriesByContractAddress, - useMigrationHistoriesByContractAddressLcd, + useMigrationHistoriesByContractAddressRest, } from "lib/services/wasm/contract"; import { RemarkOperation } from "lib/types"; import type { BechAddr32, ContractMigrationHistory } from "lib/types"; -const useContractDataLcd = ( +const useContractDataRest = ( contractData: UseQueryResult, contractAddress: BechAddr32 ) => { const { isFullTier } = useTierConfig(); - const { data: code } = useCodeLcd( + const { data: code } = useCodeRest( Number(contractData.data?.contract.codeId), { enabled: !isFullTier && !!contractData.data?.contract.codeId, } ); - const { data: cw2Info } = useContractCw2InfoLcd(contractAddress, !isFullTier); + const { data: cw2Info } = useContractCw2InfoRest( + contractAddress, + !isFullTier + ); const { data: migrationHistories } = - useMigrationHistoriesByContractAddressLcd(contractAddress, !isFullTier); + useMigrationHistoriesByContractAddressRest(contractAddress, !isFullTier); return !isFullTier && contractData.data ? { @@ -56,7 +59,7 @@ export const useContractDataWithLocalInfos = (contractAddress: BechAddr32) => { const { getContractLocalInfo } = useContractStore(); let result = useContractData(contractAddress); - result = useContractDataLcd(result, contractAddress); + result = useContractDataRest(result, contractAddress); const codeLocalInfo = result.data?.contract ? getCodeLocalInfo(Number(result.data.contract.codeId)) @@ -95,9 +98,9 @@ export const useMigrationHistories = ( }; }; -export const useMigrationHistoriesLcd = (contractAddress: BechAddr32) => { +export const useMigrationHistoriesRest = (contractAddress: BechAddr32) => { const { data, ...res } = - useMigrationHistoriesByContractAddressLcd(contractAddress); + useMigrationHistoriesByContractAddressRest(contractAddress); const { getCodeLocalInfo } = useCodeStore(); diff --git a/src/lib/pages/custom-network/edit/index.tsx b/src/lib/pages/custom-network/edit/index.tsx index 9e50442f9..8e337cc44 100644 --- a/src/lib/pages/custom-network/edit/index.tsx +++ b/src/lib/pages/custom-network/edit/index.tsx @@ -66,7 +66,7 @@ const NetworkConfigBody = ({ chainId }: NetworkConfigBodyProps) => { registryChainName: chainConfig.registryChainName, prettyName: chainConfig.prettyName, logo_URIs: chainConfig.logo_URIs, - lcd: chainConfig.lcd, + rest: chainConfig.rest, rpc: chainConfig.rpc, features: pick(chainConfig.features, ["wasm", "move", "evm"]), gas: chainConfig.gas, diff --git a/src/lib/pages/custom-network/manual/components/NetworkDetails.tsx b/src/lib/pages/custom-network/manual/components/NetworkDetails.tsx index f1f99b0f6..ebb5dc20d 100644 --- a/src/lib/pages/custom-network/manual/components/NetworkDetails.tsx +++ b/src/lib/pages/custom-network/manual/components/NetworkDetails.tsx @@ -108,16 +108,16 @@ export const NetworkDetails = ({ control, errors }: NetworkDetailsProps) => { error={errors.prettyName?.message} /> { }; export const WalletRegistry = ({ control, errors }: WalletRegistryProps) => { - const [lcd, bech32Prefix] = useWatch({ + const [rest, bech32Prefix] = useWatch({ control, - name: ["lcd", "bech32_prefix"], + name: ["rest", "bech32_prefix"], }); const { data: accountBech32, isLoading: isAccountBech32Loading } = - useAccountBech32(lcd); + useAccountBech32(rest); const { field: { onChange }, @@ -167,7 +167,7 @@ export const WalletRegistry = ({ control, errors }: WalletRegistryProps) => { @@ -202,7 +202,7 @@ export const WalletRegistry = ({ control, errors }: WalletRegistryProps) => { <> - * Bech32 and Slip44 data is not available from LCD. The input + * Bech32 and Slip44 data is not available from REST. The input above will be set as default. diff --git a/src/lib/pages/custom-network/manual/index.tsx b/src/lib/pages/custom-network/manual/index.tsx index 9b8f6a8a0..513d1966c 100644 --- a/src/lib/pages/custom-network/manual/index.tsx +++ b/src/lib/pages/custom-network/manual/index.tsx @@ -48,7 +48,7 @@ export const AddNetworkManual = () => { defaultValues: { ...DEFAULT_GAS, prettyName: "", - lcd: "", + rest: "", rpc: "", chainId: "", registryChainName: "", @@ -67,7 +67,7 @@ export const AddNetworkManual = () => { const { vm, prettyName, - lcd, + rest, rpc, chainId, registryChainName, @@ -111,7 +111,7 @@ export const AddNetworkManual = () => { }).safeParse({ vm, prettyName, - lcd, + rest, rpc, chainId, registryChainName, diff --git a/src/lib/pages/custom-network/types.ts b/src/lib/pages/custom-network/types.ts index 359af42e6..d8d83e34a 100644 --- a/src/lib/pages/custom-network/types.ts +++ b/src/lib/pages/custom-network/types.ts @@ -3,7 +3,7 @@ import { capitalize } from "lodash"; import type { RefinementCtx } from "zod"; import { z, ZodIssueCode } from "zod"; -import { getAccountBech32Lcd } from "lib/services/account/lcd"; +import { getAccountBech32Rest } from "lib/services/account/rest"; import { zAsset, zChainConfig, @@ -68,7 +68,7 @@ const zNetworkDetails = zChainConfig .innerType() .pick({ prettyName: true, - lcd: true, + rest: true, rpc: true, chainId: true, registryChainName: true, @@ -354,7 +354,7 @@ export const zAddNetworkManualChainConfigJson = ({ registryChainName, prettyName, logoUri, - lcd, + rest, rpc, vm, gasAdjustment, @@ -376,7 +376,7 @@ export const zAddNetworkManualChainConfigJson = ({ logo_URIs: { png: logoUri || undefined, }, - lcd, + rest, rpc, features: { wasm: vm.type === "wasm" ? DEFAULT_WASM_CONFIG : { enabled: false }, @@ -442,7 +442,7 @@ export const zAddNetworkJsonChainConfigJson = zChainConfig registryChainName: true, prettyName: true, logo_URIs: true, - lcd: true, + rest: true, rpc: true, gas: true, fees: true, @@ -476,7 +476,7 @@ export type AddNetworkJsonChainConfigJson = z.infer< export const zAddNetworkLinkChainConfigJson = z .object({ chainId: z.string().min(1, "Chain ID cannot be empty"), - lcd: zHttpsUrl, + rest: zHttpsUrl, rpc: zHttpsUrl, jsonRpc: zHttpsUrl.optional(), vm: z.nativeEnum(VmType), @@ -493,7 +493,7 @@ export const zAddNetworkLinkChainConfigJson = z } }) .transform(async (val) => { - const bech32Prefix = await getAccountBech32Lcd(val.lcd) + const bech32Prefix = await getAccountBech32Rest(val.rest) .then((res) => res.bech32Prefix) .catch(() => DEFAULT_BECH32_PREFIX); @@ -502,7 +502,7 @@ export const zAddNetworkLinkChainConfigJson = z chainId: val.chainId, registryChainName: val.chainId, prettyName: capitalize(val.chainId), - lcd: val.lcd, + rest: val.rest, rpc: val.rpc, features: { wasm: val.vm === VmType.WASM ? DEFAULT_WASM_CONFIG : { enabled: false }, diff --git a/src/lib/pages/deploy/index.tsx b/src/lib/pages/deploy/index.tsx index 7658cf8d8..a6c1c0ab6 100644 --- a/src/lib/pages/deploy/index.tsx +++ b/src/lib/pages/deploy/index.tsx @@ -18,7 +18,7 @@ import { Loading } from "lib/components/Loading"; import { CelatoneSeo } from "lib/components/Seo"; import { Stepper } from "lib/components/stepper"; import { UserDocsLink } from "lib/components/UserDocsLink"; -import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; +import { useUploadAccessParamsRest } from "lib/services/wasm/code"; const getAlertContent = ( enabled: boolean, @@ -55,7 +55,7 @@ const Deploy = () => { const { chainConfig: { prettyName: chainPrettyName }, } = useCelatoneApp(); - const { data, isFetching } = useUploadAccessParamsLcd(); + const { data, isFetching } = useUploadAccessParamsRest(); const enableUpload = !data?.isPermissionedNetwork || diff --git a/src/lib/pages/home/lite.tsx b/src/lib/pages/home/lite.tsx index 03a2f32cc..8f30a72ce 100644 --- a/src/lib/pages/home/lite.tsx +++ b/src/lib/pages/home/lite.tsx @@ -3,7 +3,7 @@ import { Flex, Heading, Spinner, Text } from "@chakra-ui/react"; import { useCelatoneApp, useMobile } from "lib/app-provider"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; import PageContainer from "lib/components/PageContainer"; -import { useLatestBlockLcd } from "lib/services/block"; +import { useLatestBlockRest } from "lib/services/block"; import { QuickMenuLite, QuickMenuMobileLite } from "./components"; @@ -14,7 +14,7 @@ export const HomeLite = () => { theme, } = useCelatoneApp(); - const { data: latestHeight, isLoading } = useLatestBlockLcd(); + const { data: latestHeight, isLoading } = useLatestBlockRest(); return ( diff --git a/src/lib/pages/home/sequencer.tsx b/src/lib/pages/home/sequencer.tsx index 438596319..0b514a4dc 100644 --- a/src/lib/pages/home/sequencer.tsx +++ b/src/lib/pages/home/sequencer.tsx @@ -7,7 +7,7 @@ import { RecentBlocksTableSequencer } from "lib/pages/blocks/components/RecentBl import { TxsTableSequencer } from "lib/pages/txs/components/TxsTableSequencer"; import { useBlockTimeAverageSequencer, - useLatestBlockLcd, + useLatestBlockRest, } from "lib/services/block"; import { useTxsCountSequencer } from "lib/services/tx"; @@ -20,7 +20,7 @@ export const HomeSequencer = () => { const { data: txsCount, isLoading: isTxsCountLoading } = useTxsCountSequencer(); const { data: latestBlock, isLoading: isLatestBlockLoading } = - useLatestBlockLcd(); + useLatestBlockRest(); const { data: blockTimeAverage, isLoading: isBlockTimeAverageLoading } = useBlockTimeAverageSequencer(); diff --git a/src/lib/pages/instantiate/InstantiateFormPage.tsx b/src/lib/pages/instantiate/InstantiateFormPage.tsx index da422c977..df47dfa25 100644 --- a/src/lib/pages/instantiate/InstantiateFormPage.tsx +++ b/src/lib/pages/instantiate/InstantiateFormPage.tsx @@ -51,7 +51,7 @@ import { useSchemaStore } from "lib/providers/store"; import { useSimulateFeeQuery } from "lib/services/tx"; import type { Code } from "lib/services/types"; import { useDerivedWasmVerifyInfo } from "lib/services/verification/wasm"; -import { useCodeLcd } from "lib/services/wasm/code"; +import { useCodeRest } from "lib/services/wasm/code"; import type { BechAddr, BechAddr20, BechAddr32, ComposedMsg } from "lib/types"; import { MsgType } from "lib/types"; import { @@ -197,7 +197,7 @@ const InstantiateFormPage = ({ onComplete }: InstantiateFormPageProps) => { }, }); - const { refetch } = useCodeLcd(Number(codeId), { + const { refetch } = useCodeRest(Number(codeId), { enabled: false, retry: false, cacheTime: 0, diff --git a/src/lib/pages/interact-contract/components/query-area/JsonQuery.tsx b/src/lib/pages/interact-contract/components/query-area/JsonQuery.tsx index 83e406ccf..b3109f5f7 100644 --- a/src/lib/pages/interact-contract/components/query-area/JsonQuery.tsx +++ b/src/lib/pages/interact-contract/components/query-area/JsonQuery.tsx @@ -22,8 +22,8 @@ import { LoadingOverlay } from "lib/components/LoadingOverlay"; import { DEFAULT_RPC_ERROR } from "lib/data"; import { useContractStore } from "lib/providers/store"; import { - useContractQueryLcd, - useContractQueryMsgsLcd, + useContractQueryMsgsRest, + useContractQueryRest, } from "lib/services/wasm/contract"; import type { BechAddr32, RpcQueryError } from "lib/types"; import { @@ -49,7 +49,7 @@ interface JsonQueryProps { export const JsonQuery = ({ contractAddress, initialMsg }: JsonQueryProps) => { const isMobile = useMobile(); const { data: queryCmds = [], isFetching: isCmdsFetching } = - useContractQueryMsgsLcd(contractAddress); + useContractQueryMsgsRest(contractAddress); const { addActivity } = useContractStore(); const { address } = useCurrentChain(); @@ -61,7 +61,7 @@ export const JsonQuery = ({ contractAddress, initialMsg }: JsonQueryProps) => { setRes(""); }, [contractAddress, initialMsg]); - const { refetch, isFetching } = useContractQueryLcd(contractAddress, msg, { + const { refetch, isFetching } = useContractQueryRest(contractAddress, msg, { enabled: false, retry: false, cacheTime: 0, diff --git a/src/lib/pages/interact-contract/components/query-area/schema-query/SchemaQueryComponent.tsx b/src/lib/pages/interact-contract/components/query-area/schema-query/SchemaQueryComponent.tsx index 5b98553c1..5327bef9d 100644 --- a/src/lib/pages/interact-contract/components/query-area/schema-query/SchemaQueryComponent.tsx +++ b/src/lib/pages/interact-contract/components/query-area/schema-query/SchemaQueryComponent.tsx @@ -25,7 +25,7 @@ import { OutputMessageTabs, } from "lib/components/json-schema"; import { DEFAULT_RPC_ERROR } from "lib/data"; -import { useContractQueryLcd } from "lib/services/wasm/contract"; +import { useContractQueryRest } from "lib/services/wasm/contract"; import type { Activity } from "lib/stores/contract"; import type { BechAddr20, @@ -79,7 +79,7 @@ export const SchemaQueryComponent = ({ const [queryError, setQueryError] = useState(""); const [timestamp, setTimestamp] = useState(); - const { refetch, isFetching } = useContractQueryLcd(contractAddress, msg, { + const { refetch, isFetching } = useContractQueryRest(contractAddress, msg, { enabled: !msgSchema.inputRequired && opened, retry: false, cacheTime: 0, diff --git a/src/lib/pages/interact/data.ts b/src/lib/pages/interact/data.ts index d048a43fb..46906dcc0 100644 --- a/src/lib/pages/interact/data.ts +++ b/src/lib/pages/interact/data.ts @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { - useModuleByAddressLcd, + useModuleByAddressRest, useModulesByAddress, } from "lib/services/move/module"; import type { Addr, IndexedModule, Option } from "lib/types"; @@ -20,7 +20,7 @@ export const useSearchModules = ({ onError: (err: unknown) => void; }) => { const { refetch: refetchModule, isFetching: isModuleFetching } = - useModuleByAddressLcd({ + useModuleByAddressRest({ address, moduleName: moduleName ?? "", options: { diff --git a/src/lib/pages/interact/index.tsx b/src/lib/pages/interact/index.tsx index 05aac4800..23c58c2bc 100644 --- a/src/lib/pages/interact/index.tsx +++ b/src/lib/pages/interact/index.tsx @@ -17,7 +17,7 @@ import { PageHeader } from "lib/components/PageHeader"; import { CelatoneSeo } from "lib/components/Seo"; import { EmptyState } from "lib/components/state"; import { useOpenNewTab } from "lib/hooks"; -import { useModuleByAddressLcd } from "lib/services/move/module"; +import { useModuleByAddressRest } from "lib/services/move/module"; import { useMoveVerifyInfo } from "lib/services/verification/move"; import type { Addr, ExposedFunction, IndexedModule } from "lib/types"; import { resolveMoveVerifyStatus } from "lib/utils"; @@ -190,7 +190,7 @@ const InteractBody = ({ module?.moduleName ); - const { refetch } = useModuleByAddressLcd({ + const { refetch } = useModuleByAddressRest({ address: address as Addr, moduleName, options: { diff --git a/src/lib/pages/migrate/components/MigrateContract.tsx b/src/lib/pages/migrate/components/MigrateContract.tsx index 2c5f0d681..b22c74cd6 100644 --- a/src/lib/pages/migrate/components/MigrateContract.tsx +++ b/src/lib/pages/migrate/components/MigrateContract.tsx @@ -26,7 +26,7 @@ import { useSchemaStore } from "lib/providers/store"; import { useSimulateFeeQuery } from "lib/services/tx"; import type { Code } from "lib/services/types"; import { useDerivedWasmVerifyInfo } from "lib/services/verification/wasm"; -import { useCodeLcd } from "lib/services/wasm/code"; +import { useCodeRest } from "lib/services/wasm/code"; import type { BechAddr32, ComposedMsg, Option } from "lib/types"; import { MsgType } from "lib/types"; import { composeMsg, jsonValidate, resolvePermission } from "lib/utils"; @@ -128,7 +128,7 @@ export const MigrateContract = ({ }, }); - const { refetch } = useCodeLcd(codeId, { + const { refetch } = useCodeRest(codeId, { enabled: false, retry: false, cacheTime: 0, diff --git a/src/lib/pages/migrate/index.tsx b/src/lib/pages/migrate/index.tsx index 314830f32..c4570fd8d 100644 --- a/src/lib/pages/migrate/index.tsx +++ b/src/lib/pages/migrate/index.tsx @@ -21,7 +21,7 @@ import { CelatoneSeo } from "lib/components/Seo"; import { Stepper } from "lib/components/stepper"; import { TierSwitcher } from "lib/components/TierSwitcher"; import { useUploadCode } from "lib/hooks"; -import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; +import { useUploadAccessParamsRest } from "lib/services/wasm/code"; import { useContractData } from "lib/services/wasm/contract"; import type { BechAddr32, Option } from "lib/types"; @@ -49,7 +49,7 @@ const MigrateBody = ({ }: MigrateBodyProps) => { useWasmConfig({ shouldRedirect: true }); const navigate = useInternalNavigate(); - const { data: uploadAccessParams, isFetching } = useUploadAccessParamsLcd(); + const { data: uploadAccessParams, isFetching } = useUploadAccessParamsRest(); const { proceed, formData, diff --git a/src/lib/pages/module-details/index.tsx b/src/lib/pages/module-details/index.tsx index 5386f4683..b1eb5a5e5 100644 --- a/src/lib/pages/module-details/index.tsx +++ b/src/lib/pages/module-details/index.tsx @@ -20,7 +20,7 @@ import { StatusMessageBox } from "lib/components/StatusMessageBox"; import { UserDocsLink } from "lib/components/UserDocsLink"; import { useFormatAddresses } from "lib/hooks/useFormatAddresses"; import { - useModuleByAddressLcd, + useModuleByAddressRest, useModulePublishInfo, useModuleTableCounts, } from "lib/services/move/module"; @@ -63,7 +63,7 @@ const ModuleDetailsBody = ({ const currentTab = !isFullTier && tab === TabIndex.TxsHistories ? TabIndex.Overview : tab; - const { data, isLoading: isModuleLoading } = useModuleByAddressLcd({ + const { data, isLoading: isModuleLoading } = useModuleByAddressRest({ address: vmAddress, moduleName, }); diff --git a/src/lib/pages/nft-collection-details/data.ts b/src/lib/pages/nft-collection-details/data.ts index cbeb94e95..13215f0f8 100644 --- a/src/lib/pages/nft-collection-details/data.ts +++ b/src/lib/pages/nft-collection-details/data.ts @@ -1,5 +1,5 @@ import { useFormatAddresses } from "lib/hooks/useFormatAddresses"; -import { useResourcesByAddressLcd } from "lib/services/move/resource"; +import { useResourcesByAddressRest } from "lib/services/move/resource"; import type { HexAddr, HexAddr32, Option } from "lib/types"; interface SupplyData { @@ -24,7 +24,8 @@ export const useCollectionInfos = ( ): { collectionInfos: Option; isLoading: boolean } => { const formatAddress = useFormatAddresses(); const { address } = formatAddress(collectionAddress); - const { data: resourcesData, isFetching } = useResourcesByAddressLcd(address); + const { data: resourcesData, isFetching } = + useResourcesByAddressRest(address); if (!resourcesData) return { collectionInfos: undefined, isLoading: isFetching }; diff --git a/src/lib/pages/past-txs/lite.tsx b/src/lib/pages/past-txs/lite.tsx index 44d27642d..321876779 100644 --- a/src/lib/pages/past-txs/lite.tsx +++ b/src/lib/pages/past-txs/lite.tsx @@ -12,7 +12,7 @@ import { EmptyState, ErrorFetching } from "lib/components/state"; import { TransactionsTableWithWallet } from "lib/components/table"; import { UserDocsLink } from "lib/components/UserDocsLink"; import { useDebounce } from "lib/hooks"; -import { useTxsByAddressLcd } from "lib/services/tx"; +import { useTxsByAddressRest } from "lib/services/tx"; interface PastTxsLiteTransactionsTableWithWalletEmptyStateProps { search: string; @@ -65,7 +65,7 @@ export const PastTxsLite = () => { }, }); - const { data, isLoading, error } = useTxsByAddressLcd( + const { data, isLoading, error } = useTxsByAddressRest( address, debouncedSearch, pageSize, diff --git a/src/lib/pages/pools/components/pool-details/header/index.tsx b/src/lib/pages/pools/components/pool-details/header/index.tsx index be96a70ca..7d36f399f 100644 --- a/src/lib/pages/pools/components/pool-details/header/index.tsx +++ b/src/lib/pages/pools/components/pool-details/header/index.tsx @@ -19,10 +19,10 @@ export const PoolTopSection = ({ pool }: PoolTopSectionProps) => { // Remark: the empty string has never been used when poolConfig is disabled const poolUrl = poolConfig.enabled ? poolConfig.url : ""; - const lcdEndpoint = useBaseApiRoute("rest"); - const openPoolLcd = () => { - trackUseViewJSON("pool_page_pool_lcd"); - openNewTab(`${lcdEndpoint}/osmosis/poolmanager/v1beta1/pools/${pool.id}`); + const restEndpoint = useBaseApiRoute("rest"); + const openPoolRest = () => { + trackUseViewJSON("pool_page_pool_rest"); + openNewTab(`${restEndpoint}/osmosis/poolmanager/v1beta1/pools/${pool.id}`); }; const openOsmosisPool = () => { trackWebsite(`${poolUrl}/${pool.id}`); @@ -49,7 +49,7 @@ export const PoolTopSection = ({ pool }: PoolTopSectionProps) => { rightIcon={ } - onClick={openPoolLcd} + onClick={openPoolRest} > View in JSON diff --git a/src/lib/pages/pools/components/pool-details/tables/pool-txs/messages/superfluid/MsgLockAndSuperfluidDelegateDetail.tsx b/src/lib/pages/pools/components/pool-details/tables/pool-txs/messages/superfluid/MsgLockAndSuperfluidDelegateDetail.tsx index f86469933..0a285e00f 100644 --- a/src/lib/pages/pools/components/pool-details/tables/pool-txs/messages/superfluid/MsgLockAndSuperfluidDelegateDetail.tsx +++ b/src/lib/pages/pools/components/pool-details/tables/pool-txs/messages/superfluid/MsgLockAndSuperfluidDelegateDetail.tsx @@ -4,7 +4,7 @@ import { ExplorerLink } from "lib/components/ExplorerLink"; import { Loading } from "lib/components/Loading"; import { ValidatorBadge } from "lib/components/ValidatorBadge"; import { useTxData } from "lib/services/tx"; -import { useValidatorDataLcd } from "lib/services/validator"; +import { useValidatorDataRest } from "lib/services/validator"; import type { AssetInfos, Option, PoolData } from "lib/types"; import { coinToTokenWithValue, extractMsgType } from "lib/utils"; import type { MsgLockAndSuperfluidDelegateDetails } from "lib/utils/tx/types"; @@ -52,7 +52,7 @@ export const MsgLockAndSuperfluidDelegateDetail = ({ isOpened ); const { data: validator, isLoading: isValidatorLoading } = - useValidatorDataLcd(msg.val_addr, isOpened); + useValidatorDataRest(msg.val_addr, isOpened); if (isTxDataLoading || isValidatorLoading) return ; diff --git a/src/lib/pages/proposal-details/components/proposal-top/ViewProposalJson.tsx b/src/lib/pages/proposal-details/components/proposal-top/ViewProposalJson.tsx index edf1202a5..a5fc6d25b 100644 --- a/src/lib/pages/proposal-details/components/proposal-top/ViewProposalJson.tsx +++ b/src/lib/pages/proposal-details/components/proposal-top/ViewProposalJson.tsx @@ -14,17 +14,17 @@ interface ViewProposalJsonProps { export const ViewProposalJson = ({ id, status }: ViewProposalJsonProps) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const config = useGovConfig({ shouldRedirect: false }); const isInitia = useInitia(); if (!config.enabled) return null; - const openLcdPage = () => { + const openRestPage = () => { trackUseViewJSON("Proposal Details"); openNewTab( - `${lcdEndpoint}/${isInitia ? "initia" : "cosmos"}/gov/${config.version}/proposals/${encodeURIComponent(id)}` + `${restEndpoint}/${isInitia ? "initia" : "cosmos"}/gov/${config.version}/proposals/${encodeURIComponent(id)}` ); }; @@ -42,7 +42,7 @@ export const ViewProposalJson = ({ id, status }: ViewProposalJsonProps) => { minWidth={{ md: "150px" }} size={{ base: "sm", md: "md" }} rightIcon={} - onClick={openLcdPage} + onClick={openRestPage} isDisabled={disabled} > View in JSON diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx index 0d78bd768..b8949e018 100644 --- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx +++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx @@ -26,7 +26,7 @@ export const DepositorsTable = ({ if (isPruned) return ( - + ); if (depositors.length === 0) diff --git a/src/lib/pages/proposal-details/data.ts b/src/lib/pages/proposal-details/data.ts index 407e75cf6..f878cf5a7 100644 --- a/src/lib/pages/proposal-details/data.ts +++ b/src/lib/pages/proposal-details/data.ts @@ -3,8 +3,8 @@ import { useAssetInfos } from "lib/services/assetService"; import { useMovePoolInfos } from "lib/services/move/poolService"; import { useProposalData, - useProposalDataLcd, - useProposalDepositsLcd, + useProposalDataRest, + useProposalDepositsRest, useProposalVotesInfo, } from "lib/services/proposal"; import type { @@ -32,26 +32,26 @@ export const useDerivedProposalData = ( id, isFullTier ); - const { data: dataLcd, isLoading: isLcdLoading } = useProposalDataLcd( + const { data: dataRest, isLoading: isRestLoading } = useProposalDataRest( id, !isFullTier ); - const { data: dataDepositsLcd, isLoading: isDepositsLcdLoading } = - useProposalDepositsLcd(id, !isFullTier); + const { data: dataDepositsRest, isLoading: isDepositsRestLoading } = + useProposalDepositsRest(id, !isFullTier); const [data, isLoading, isDepositsLoading] = isFullTier ? [dataApi, isApiLoading, isApiLoading] : [ - dataLcd + dataRest ? { info: { - ...dataLcd, - proposalDeposits: dataDepositsLcd ?? [], + ...dataRest, + proposalDeposits: dataDepositsRest ?? [], }, } : undefined, - isLcdLoading, - isDepositsLcdLoading, + isRestLoading, + isDepositsRestLoading, ]; const { data: assetInfos, isLoading: isAssetInfosLoading } = useAssetInfos({ diff --git a/src/lib/pages/proposal/store-code/index.tsx b/src/lib/pages/proposal/store-code/index.tsx index a2515a961..5963cc988 100644 --- a/src/lib/pages/proposal/store-code/index.tsx +++ b/src/lib/pages/proposal/store-code/index.tsx @@ -50,7 +50,7 @@ import { import { useGetMaxLengthError, useTxBroadcast } from "lib/hooks"; import { useGovParamsDeprecated } from "lib/model/proposal"; import { useSimulateFeeForProposalStoreCode } from "lib/services/tx"; -import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; +import { useUploadAccessParamsRest } from "lib/services/wasm/code"; import type { BechAddr, SimulateStatus, UploadSectionState } from "lib/types"; import { AccessType } from "lib/types"; import { @@ -99,7 +99,7 @@ const StoreCodeProposal = () => { const { address: walletAddress } = useCurrentChain(); const fabricateFee = useFabricateFee(); const { data: govParams } = useGovParamsDeprecated(); - const { data: uploadAccessParams } = useUploadAccessParamsLcd(); + const { data: uploadAccessParams } = useUploadAccessParamsRest(); const minDeposit = govParams?.depositParams.minDeposit; const { validateUserAddress, validateContractAddress } = useValidateAddress(); diff --git a/src/lib/pages/proposal/whitelist/index.tsx b/src/lib/pages/proposal/whitelist/index.tsx index cc1cefcc2..4d13fc7b7 100644 --- a/src/lib/pages/proposal/whitelist/index.tsx +++ b/src/lib/pages/proposal/whitelist/index.tsx @@ -39,7 +39,7 @@ import { StickySidebar } from "lib/components/StickySidebar"; import { useGetMaxLengthError, useTxBroadcast } from "lib/hooks"; import { useGovParamsDeprecated } from "lib/model/proposal"; import { useSimulateFeeQuery } from "lib/services/tx"; -import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; +import { useUploadAccessParamsRest } from "lib/services/wasm/code"; import type { BechAddr } from "lib/types"; import { AccessConfigPermission } from "lib/types"; import { composeSubmitWhitelistProposalMsg, getAmountToVote } from "lib/utils"; @@ -74,7 +74,7 @@ const ProposalToWhitelist = () => { } = useCelatoneApp(); const fabricateFee = useFabricateFee(); const { data: govParams } = useGovParamsDeprecated(); - const { data: uploadAccessParams } = useUploadAccessParamsLcd(); + const { data: uploadAccessParams } = useUploadAccessParamsRest(); const submitProposalTx = useSubmitWhitelistProposalTx(); const { broadcast } = useTxBroadcast(); const { diff --git a/src/lib/pages/proposals/components/ProposalsTableLite.tsx b/src/lib/pages/proposals/components/ProposalsTableLite.tsx index e10c3d6ef..a8730f6b9 100644 --- a/src/lib/pages/proposals/components/ProposalsTableLite.tsx +++ b/src/lib/pages/proposals/components/ProposalsTableLite.tsx @@ -7,7 +7,7 @@ import { LoadNext } from "lib/components/LoadNext"; import { EmptyState, ErrorFetching } from "lib/components/state"; import { ProposalsTable } from "lib/components/table"; import { useDebounce } from "lib/hooks"; -import { useProposalDataLcd, useProposalsLcd } from "lib/services/proposal"; +import { useProposalDataRest, useProposalsRest } from "lib/services/proposal"; import type { ProposalStatus } from "lib/types"; import { isPositiveInt } from "lib/utils"; @@ -26,10 +26,13 @@ export const ProposalsTableLite = () => { hasNextPage, isLoading: isProposalsLoading, isFetchingNextPage, - } = useProposalsLcd(status[0]); + } = useProposalsRest(status[0]); const { data: proposalData, isFetching: isProposalDataFetching } = - useProposalDataLcd(Number(debouncedSearch), isPositiveInt(debouncedSearch)); + useProposalDataRest( + Number(debouncedSearch), + isPositiveInt(debouncedSearch) + ); const proposal = proposalData ? [proposalData] : []; const proposals = diff --git a/src/lib/pages/stored-codes/index.tsx b/src/lib/pages/stored-codes/index.tsx index 2a73705da..4c9bbdf45 100644 --- a/src/lib/pages/stored-codes/index.tsx +++ b/src/lib/pages/stored-codes/index.tsx @@ -19,7 +19,7 @@ import { MyStoredCodesTable } from "lib/components/table"; import { UserDocsLink } from "lib/components/UserDocsLink"; import type { PermissionFilterValue } from "lib/hooks"; import { useMyCodesData } from "lib/model/code"; -import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; +import { useUploadAccessParamsRest } from "lib/services/wasm/code"; import { ProposalButton } from "./components/ProposalButton"; import { UploadButton } from "./components/UploadButton"; @@ -50,7 +50,7 @@ const StoredCodes = observer(() => { isStoredCodesLoading, } = useMyCodesData(keyword, permissionValue); const { data, isFetching: isUploadAccessFetching } = - useUploadAccessParamsLcd(); + useUploadAccessParamsRest(); const isAllowed = Boolean(address && data?.addresses?.includes(address)); diff --git a/src/lib/pages/tx-details/components/TxHeader.tsx b/src/lib/pages/tx-details/components/TxHeader.tsx index 43bc0d371..a5590c30e 100644 --- a/src/lib/pages/tx-details/components/TxHeader.tsx +++ b/src/lib/pages/tx-details/components/TxHeader.tsx @@ -20,7 +20,7 @@ const DotSeparator = () => ( export const TxHeader = ({ txData, ...flexProps }: TxHeaderProps) => { const isMobile = useMobile(); const evm = useEvmConfig({ shouldRedirect: false }); - const openLcdTab = useOpenTxTab("lcd"); + const openRestTab = useOpenTxTab("rest"); return ( @@ -69,7 +69,7 @@ export const TxHeader = ({ txData, ...flexProps }: TxHeaderProps) => { rightIcon={} onClick={() => { trackUseViewJSON("tx_page_transaction_hash"); - openLcdTab(txData.txhash); + openRestTab(txData.txhash); }} > View in JSON diff --git a/src/lib/pages/upload/upload.tsx b/src/lib/pages/upload/upload.tsx index 000ad1bda..2ea7dc879 100644 --- a/src/lib/pages/upload/upload.tsx +++ b/src/lib/pages/upload/upload.tsx @@ -14,7 +14,7 @@ import { Stepper } from "lib/components/stepper"; import { UploadSection } from "lib/components/upload"; import { UserDocsLink } from "lib/components/UserDocsLink"; import { useUploadCode } from "lib/hooks"; -import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; +import { useUploadAccessParamsRest } from "lib/services/wasm/code"; export const Upload = ({ onComplete, @@ -24,7 +24,7 @@ export const Upload = ({ const router = useRouter(); const { address } = useCurrentChain(); const navigate = useInternalNavigate(); - const { data, isLoading } = useUploadAccessParamsLcd(); + const { data, isLoading } = useUploadAccessParamsRest(); const { proceed, formData, diff --git a/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyFull.tsx b/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyFull.tsx index 5f831827d..d48c94401 100644 --- a/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyFull.tsx +++ b/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyFull.tsx @@ -12,7 +12,7 @@ import { ErrorFetching, InvalidState } from "lib/components/state"; import { UserDocsLink } from "lib/components/UserDocsLink"; import { useAssetInfos } from "lib/services/assetService"; import { useMovePoolInfos } from "lib/services/move/poolService"; -import { useStakingParamsLcd } from "lib/services/staking"; +import { useStakingParamsRest } from "lib/services/staking"; import { useValidatorData } from "lib/services/validator"; import type { ValidatorDetailsQueryParams } from "../../types"; import { TabIndex } from "../../types"; @@ -37,7 +37,7 @@ export const ValidatorDetailsBodyFull = ({ withPrices: true, }); const { data: stakingParams, isFetching: isStakingParamsLoading } = - useStakingParamsLcd(!isInitia); + useStakingParamsRest(!isInitia); const { data, isLoading } = useValidatorData(validatorAddress); const handleTabChange = useCallback( diff --git a/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyLite.tsx b/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyLite.tsx index e18922791..2b48fb87b 100644 --- a/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyLite.tsx +++ b/src/lib/pages/validator-details/components/validator-details-body/ValidatorDetailsBodyLite.tsx @@ -7,13 +7,13 @@ import PageHeaderContainer from "lib/components/PageHeaderContainer"; import { CelatoneSeo } from "lib/components/Seo"; import { ErrorFetching, InvalidState } from "lib/components/state"; import { UserDocsLink } from "lib/components/UserDocsLink"; -import { indexValidatorsLcd } from "lib/pages/validators/utils"; +import { indexValidatorsRest } from "lib/pages/validators/utils"; import { useAssetInfos } from "lib/services/assetService"; import { - useDelegationsByAddressLcd, - useStakingParamsLcd, + useDelegationsByAddressRest, + useStakingParamsRest, } from "lib/services/staking"; -import { useValidatorsLcd } from "lib/services/validator"; +import { useValidatorsRest } from "lib/services/validator"; import { big } from "lib/types"; import { valoperToAddr } from "lib/utils"; import type { ValidatorDetailsQueryParams } from "../../types"; @@ -24,8 +24,8 @@ export const ValidatorDetailsBodyLite = ({ validatorAddress, }: Pick) => { const isInitia = useInitia(); - const { data, isLoading } = useValidatorsLcd(); - const indexedData = useMemo(() => indexValidatorsLcd(data), [data]); + const { data, isLoading } = useValidatorsRest(); + const indexedData = useMemo(() => indexValidatorsRest(data), [data]); const totalVotingPower = indexedData?.active.reduce( (prev, validator) => prev.add(validator.votingPower), @@ -49,9 +49,9 @@ export const ValidatorDetailsBodyLite = ({ withPrices: true, }); const { data: stakingParams, isFetching: isStakingParamsLoading } = - useStakingParamsLcd(!isInitia); + useStakingParamsRest(!isInitia); const { data: delegations, isLoading: isDelegationsLoading } = - useDelegationsByAddressLcd(valoperToAddr(validatorAddress)); + useDelegationsByAddressRest(valoperToAddr(validatorAddress)); if ( isLoading || diff --git a/src/lib/pages/validators/components/ValidatorsBodyLite.tsx b/src/lib/pages/validators/components/ValidatorsBodyLite.tsx index e265bf84c..9df2cd208 100644 --- a/src/lib/pages/validators/components/ValidatorsBodyLite.tsx +++ b/src/lib/pages/validators/components/ValidatorsBodyLite.tsx @@ -1,12 +1,12 @@ import { useEffect, useMemo } from "react"; import type { ValidatorsResponse } from "lib/services/types"; -import { useValidatorsLcd } from "lib/services/validator"; +import { useValidatorsRest } from "lib/services/validator"; import type { Option } from "lib/types"; import { ValidatorsTable } from "./validators-table"; import type { ValidatorCounts, ValidatorOrder } from "../types"; -import { compareValidator, indexValidatorsLcd } from "../utils"; +import { compareValidator, indexValidatorsRest } from "../utils"; interface ValidatorsBodyLiteProps { isActive: boolean; @@ -29,8 +29,8 @@ export const ValidatorsBodyLite = ({ search, scrollComponentId, }: ValidatorsBodyLiteProps) => { - const { data, isFetching: isLoading } = useValidatorsLcd(); - const indexedData = useMemo(() => indexValidatorsLcd(data), [data]); + const { data, isFetching: isLoading } = useValidatorsRest(); + const indexedData = useMemo(() => indexValidatorsRest(data), [data]); const filteredData: Option = useMemo(() => { if (!indexedData) return undefined; diff --git a/src/lib/pages/validators/components/validators-table/index.tsx b/src/lib/pages/validators/components/validators-table/index.tsx index ba68d2458..fcc0ed02d 100644 --- a/src/lib/pages/validators/components/validators-table/index.tsx +++ b/src/lib/pages/validators/components/validators-table/index.tsx @@ -7,7 +7,7 @@ import { Loading } from "lib/components/Loading"; import { EmptyState, ErrorFetching } from "lib/components/state"; import { MobileTableContainer } from "lib/components/table"; import { useAssetInfos } from "lib/services/assetService"; -import { useStakingParamsLcd } from "lib/services/staking"; +import { useStakingParamsRest } from "lib/services/staking"; import type { ValidatorsResponse } from "lib/services/types"; import type { Option } from "lib/types"; import { getStakingAssetInfo } from "lib/utils"; @@ -48,7 +48,7 @@ export const ValidatorsTable = ({ const { data: assetInfos } = useAssetInfos({ withPrices: false }); const { data: stakingParams, isFetching: isStakingParamsLoading } = - useStakingParamsLcd(!isInitia); + useStakingParamsRest(!isInitia); if (isLoading || isStakingParamsLoading) return ; if (!data) return ; diff --git a/src/lib/pages/validators/utils.ts b/src/lib/pages/validators/utils.ts index 117fd6472..b4c9331d2 100644 --- a/src/lib/pages/validators/utils.ts +++ b/src/lib/pages/validators/utils.ts @@ -28,7 +28,7 @@ export const compareValidator = return (isLower ? -1 : 1) * (isDesc ? -1 : 1); }; -export const indexValidatorsLcd = (data: Option) => { +export const indexValidatorsRest = (data: Option) => { if (!data) return undefined; const active = data diff --git a/src/lib/providers/cosmos-kit/index.tsx b/src/lib/providers/cosmos-kit/index.tsx index 58a7243e2..25339a5e6 100644 --- a/src/lib/providers/cosmos-kit/index.tsx +++ b/src/lib/providers/cosmos-kit/index.tsx @@ -24,7 +24,7 @@ export const CosmosKitProvider = ({ ...endpoints, [config.registryChainName]: { rpc: [config.rpc], - rest: [config.lcd], + rest: [config.rest], }, }), {} diff --git a/src/lib/providers/initia-widget.tsx b/src/lib/providers/initia-widget.tsx index dd5ca77bf..76b237a52 100644 --- a/src/lib/providers/initia-widget.tsx +++ b/src/lib/providers/initia-widget.tsx @@ -14,7 +14,7 @@ export const InitiaWidgetProvider = ({ children }: { children: ReactNode }) => { chainConfig.network_type === "local" ? { apis: { - rest: [{ address: chainConfig.lcd }], + rest: [{ address: chainConfig.rest }], rpc: [{ address: chainConfig.rpc }], "json-rpc": chainConfig.features.evm.enabled ? [{ address: chainConfig.features.evm.jsonRpc }] diff --git a/src/lib/services/account/index.ts b/src/lib/services/account/index.ts index 22e4f1828..d72d6ee1d 100644 --- a/src/lib/services/account/index.ts +++ b/src/lib/services/account/index.ts @@ -14,12 +14,12 @@ import type { AccountType, BechAddr, Option } from "lib/types"; import { getAccountData, getAccountTableCounts, getAccountType } from "./api"; import { - getAccountBech32Lcd, - getAccountDataLcd, - getAccountTypeLcd, -} from "./lcd"; + getAccountBech32Rest, + getAccountDataRest, + getAccountTypeRest, +} from "./rest"; import type { - AccountBech32LcdResponse, + AccountBech32RestResponse, AccountData, AccountTableCounts, } from "../types"; @@ -30,16 +30,16 @@ export const useAccountData = ( const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; + const endpoint = isFullTier ? apiEndpoint : restEndpoint; return useQuery( [CELATONE_QUERY_KEYS.ACCOUNT_DATA, endpoint, address], async () => isFullTier ? getAccountData(endpoint, address) - : getAccountDataLcd(endpoint, address), + : getAccountDataRest(endpoint, address), { enabled: !!address, retry: 1, refetchOnWindowFocus: false } ); }; @@ -75,22 +75,22 @@ export const useAccountType = ( const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const queryFn = useCallback(async () => { if (!address) throw new Error( - "Fetching account type: failed to retrieve address. (useAccountTypeLcd)" + "Fetching account type: failed to retrieve address. (useAccountTypeRest)" ); if (isFullTier) return getAccountType(apiEndpoint, address); - return getAccountTypeLcd(lcdEndpoint, address); - }, [lcdEndpoint, address, apiEndpoint, isFullTier]); + return getAccountTypeRest(restEndpoint, address); + }, [restEndpoint, address, apiEndpoint, isFullTier]); return useQuery( - [CELATONE_QUERY_KEYS.ACCOUNT_TYPE, apiEndpoint, lcdEndpoint, address], + [CELATONE_QUERY_KEYS.ACCOUNT_TYPE, apiEndpoint, restEndpoint, address], queryFn, { ...options, @@ -102,10 +102,10 @@ export const useAccountType = ( export const useAccountBech32 = ( endpoint: string -): UseQueryResult => +): UseQueryResult => useQuery( - [CELATONE_QUERY_KEYS.ACCOUNT_BECH_32_LCD, endpoint], - async () => getAccountBech32Lcd(endpoint), + [CELATONE_QUERY_KEYS.ACCOUNT_BECH_32_REST, endpoint], + async () => getAccountBech32Rest(endpoint), { retry: 1, refetchOnWindowFocus: false, diff --git a/src/lib/services/account/lcd.ts b/src/lib/services/account/rest.ts similarity index 55% rename from src/lib/services/account/lcd.ts rename to src/lib/services/account/rest.ts index bd1d8937c..23d47a551 100644 --- a/src/lib/services/account/lcd.ts +++ b/src/lib/services/account/rest.ts @@ -4,15 +4,15 @@ import axios from "axios"; import { AccountType } from "lib/types"; import type { BechAddr } from "lib/types"; import { parseWithError } from "lib/utils"; -import { getIcnsNamesByAddressLcd } from "../name/lcd"; -import { zAccountBech32LcdResponse, zAccountTypeLcd } from "../types"; +import { getIcnsNamesByAddressRest } from "../name/rest"; +import { zAccountBech32RestResponse, zAccountTypeRest } from "../types"; import type { AccountData } from "../types"; -export const getAccountDataLcd = async ( +export const getAccountDataRest = async ( endpoint: string, address: BechAddr ): Promise => { - const icns = await getIcnsNamesByAddressLcd(endpoint, address); + const icns = await getIcnsNamesByAddressRest(endpoint, address); // TODO: Implement this function return { @@ -22,24 +22,24 @@ export const getAccountDataLcd = async ( }; }; -export const getAccountTypeLcd = async ( +export const getAccountTypeRest = async ( endpoint: string, address: BechAddr ) => { - const [accountTypeLcd, isContract] = await Promise.all([ + const [accountTypeRest, isContract] = await Promise.all([ axios .get(`${endpoint}/cosmos/auth/v1beta1/accounts/${encodeURI(address)}`) - .then(({ data }) => parseWithError(zAccountTypeLcd, data)), + .then(({ data }) => parseWithError(zAccountTypeRest, data)), axios .get(`${endpoint}/cosmwasm/wasm/v1/contract/${encodeURI(address)}`) .then(() => true) .catch(() => false), ]); - return isContract ? AccountType.ContractAccount : accountTypeLcd; + return isContract ? AccountType.ContractAccount : accountTypeRest; }; -export const getAccountBech32Lcd = async (endpoint: string) => +export const getAccountBech32Rest = async (endpoint: string) => axios .get(`${endpoint}/cosmos/auth/v1beta1/bech32`) - .then(({ data }) => parseWithError(zAccountBech32LcdResponse, data)); + .then(({ data }) => parseWithError(zAccountBech32RestResponse, data)); diff --git a/src/lib/services/bank/index.ts b/src/lib/services/bank/index.ts index 18b8b8754..523c55dca 100644 --- a/src/lib/services/bank/index.ts +++ b/src/lib/services/bank/index.ts @@ -18,7 +18,7 @@ import { } from "lib/utils"; import { getBalances } from "./api"; -import { getBalancesLcd } from "./lcd"; +import { getBalancesRest } from "./rest"; import { useAssetInfos } from "../assetService"; import { useMovePoolInfos } from "../move/poolService"; import type { BalanceInfos } from "../types"; @@ -28,11 +28,11 @@ export const useBalances = ( enabled = true ): UseQueryResult => { const { - chainConfig: { chain, lcd: lcdEndpoint }, + chainConfig: { chain, rest: restEndpoint }, } = useCelatoneApp(); const isSei = chain === "sei"; const apiEndpoint = useBaseApiRoute("accounts"); - const endpoint = isSei ? apiEndpoint : lcdEndpoint; + const endpoint = isSei ? apiEndpoint : restEndpoint; return useQuery( [CELATONE_QUERY_KEYS.BALANCES, endpoint, address, isSei], @@ -40,7 +40,7 @@ export const useBalances = ( if (!address) throw new Error("address is undefined (useBalances)"); return isSei ? getBalances(endpoint, address) - : getBalancesLcd(endpoint, address); + : getBalancesRest(endpoint, address); }, { retry: 1, refetchOnWindowFocus: false, enabled } ); diff --git a/src/lib/services/bank/lcd.ts b/src/lib/services/bank/rest.ts similarity index 80% rename from src/lib/services/bank/lcd.ts rename to src/lib/services/bank/rest.ts index 4c4ef41eb..a800666c4 100644 --- a/src/lib/services/bank/lcd.ts +++ b/src/lib/services/bank/rest.ts @@ -2,9 +2,9 @@ import axios from "axios"; import type { BechAddr, Coin, Nullable } from "lib/types"; import { parseWithError } from "lib/utils"; -import { zBalancesReponseLcd } from "../types"; +import { zBalancesReponseRest } from "../types"; -export const getBalancesLcd = async ( +export const getBalancesRest = async ( endpoint: string, address: BechAddr ): Promise => { @@ -18,7 +18,7 @@ export const getBalancesLcd = async ( "pagination.limit": "500", }, }) - .then(({ data }) => parseWithError(zBalancesReponseLcd, data)); + .then(({ data }) => parseWithError(zBalancesReponseRest, data)); result.push(...res.balances); if (res.pagination?.nextKey) await fetchFn(res.pagination.nextKey); }; diff --git a/src/lib/services/block/index.ts b/src/lib/services/block/index.ts index 02ade3a0e..32fc3db87 100644 --- a/src/lib/services/block/index.ts +++ b/src/lib/services/block/index.ts @@ -17,7 +17,7 @@ import { import { getBlockData, getBlocks } from "./api"; import { getBlockDataJsonRpc } from "./jsonRpc"; -import { getBlockDataLcd, getLatestBlockLcd } from "./lcd"; +import { getBlockDataRest, getLatestBlockRest } from "./rest"; import { getBlockDataSequencer, getBlocksSequencer, @@ -51,9 +51,9 @@ export const useBlockData = (height: number, enabled = true) => { ); }; -export const useBlockDataLcd = (height: number, enabled = true) => { +export const useBlockDataRest = (height: number, enabled = true) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); @@ -62,10 +62,10 @@ export const useBlockDataLcd = (height: number, enabled = true) => { proposerConsensusAddress: ConsensusAddr; transactions: Transaction[]; }>( - [CELATONE_QUERY_KEYS.BLOCK_DATA_LCD, lcdEndpoint, height], + [CELATONE_QUERY_KEYS.BLOCK_DATA_REST, restEndpoint, height], async () => { const { rawProposerConsensusAddress, transactions, ...rest } = - await getBlockDataLcd(lcdEndpoint, height); + await getBlockDataRest(restEndpoint, height); return { ...rest, proposerConsensusAddress: convertRawConsensusAddrToConsensusAddr( @@ -89,14 +89,14 @@ export const useBlockDataLcd = (height: number, enabled = true) => { ); }; -export const useLatestBlockLcd = () => { +export const useLatestBlockRest = () => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.BLOCK_LATEST_HEIGHT_LCD, lcdEndpoint], - async () => getLatestBlockLcd(lcdEndpoint), + [CELATONE_QUERY_KEYS.BLOCK_LATEST_HEIGHT_REST, restEndpoint], + async () => getLatestBlockRest(restEndpoint), { retry: false, refetchOnWindowFocus: false, @@ -107,12 +107,12 @@ export const useLatestBlockLcd = () => { export const useBlocksSequencer = (limit = 10) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { data, ...rest } = useInfiniteQuery( - [CELATONE_QUERY_KEYS.BLOCKS_SEQUENCER, lcdEndpoint, limit], - async ({ pageParam }) => getBlocksSequencer(lcdEndpoint, pageParam, limit), + [CELATONE_QUERY_KEYS.BLOCKS_SEQUENCER, restEndpoint, limit], + async ({ pageParam }) => getBlocksSequencer(restEndpoint, pageParam, limit), { getNextPageParam: (lastPage) => lastPage.pagination.nextKey ?? undefined, refetchOnWindowFocus: false, @@ -127,12 +127,12 @@ export const useBlocksSequencer = (limit = 10) => { export const useBlockTimeAverageSequencer = () => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.BLOCK_TIME_AVERAGE_SEQUENCER, lcdEndpoint], - async () => getBlockTimeAverageSequencer(lcdEndpoint), + [CELATONE_QUERY_KEYS.BLOCK_TIME_AVERAGE_SEQUENCER, restEndpoint], + async () => getBlockTimeAverageSequencer(restEndpoint), { retry: false, refetchOnWindowFocus: false, @@ -142,12 +142,12 @@ export const useBlockTimeAverageSequencer = () => { export const useBlockDataSequencer = (height: number) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.BLOCK_DATA_SEQUENCER, lcdEndpoint, height], - async () => getBlockDataSequencer(lcdEndpoint, height), + [CELATONE_QUERY_KEYS.BLOCK_DATA_SEQUENCER, restEndpoint, height], + async () => getBlockDataSequencer(restEndpoint, height), { retry: false, refetchOnWindowFocus: false, diff --git a/src/lib/services/block/lcd.ts b/src/lib/services/block/lcd.ts deleted file mode 100644 index 3b57fc861..000000000 --- a/src/lib/services/block/lcd.ts +++ /dev/null @@ -1,16 +0,0 @@ -import axios from "axios"; - -import { parseWithError } from "lib/utils"; -import { zBlockDataResponseLcd, zBlockLcd } from "../types"; - -export const getLatestBlockLcd = async (endpoint: string) => - axios - .get(`${endpoint}/cosmos/base/tendermint/v1beta1/blocks/latest`) - .then(({ data }) => parseWithError(zBlockLcd, data).block.header.height); - -export const getBlockDataLcd = async (endpoint: string, height: number) => - axios - .get( - `${endpoint}/cosmos/tx/v1beta1/txs/block/${encodeURIComponent(height)}` - ) - .then(({ data }) => parseWithError(zBlockDataResponseLcd, data)); diff --git a/src/lib/services/block/rest.ts b/src/lib/services/block/rest.ts new file mode 100644 index 000000000..c92b70242 --- /dev/null +++ b/src/lib/services/block/rest.ts @@ -0,0 +1,16 @@ +import axios from "axios"; + +import { parseWithError } from "lib/utils"; +import { zBlockDataResponseRest, zBlockRest } from "../types"; + +export const getLatestBlockRest = async (endpoint: string) => + axios + .get(`${endpoint}/cosmos/base/tendermint/v1beta1/blocks/latest`) + .then(({ data }) => parseWithError(zBlockRest, data).block.header.height); + +export const getBlockDataRest = async (endpoint: string, height: number) => + axios + .get( + `${endpoint}/cosmos/tx/v1beta1/txs/block/${encodeURIComponent(height)}` + ) + .then(({ data }) => parseWithError(zBlockDataResponseRest, data)); diff --git a/src/lib/services/distribution/index.ts b/src/lib/services/distribution/index.ts index e5afd7b20..024e63fbc 100644 --- a/src/lib/services/distribution/index.ts +++ b/src/lib/services/distribution/index.ts @@ -9,26 +9,26 @@ import { import type { BechAddr, Option, ValidatorAddr } from "lib/types"; import { - getCommissionsByValidatorAddressLcd, - getDelegationRewardsByAddressLcd, -} from "./lcd"; + getCommissionsByValidatorAddressRest, + getDelegationRewardsByAddressRest, +} from "./rest"; -export const useDelegationRewardsByAddressLcd = ( +export const useDelegationRewardsByAddressRest = ( address: BechAddr, enabled: boolean ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const gov = useGovConfig({ shouldRedirect: false }); return useQuery( [ - CELATONE_QUERY_KEYS.DELEGATION_REWARDS_BY_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.DELEGATION_REWARDS_BY_ADDRESS_REST, + restEndpoint, address, ], - () => getDelegationRewardsByAddressLcd(lcdEndpoint, address), + () => getDelegationRewardsByAddressRest(restEndpoint, address), { enabled: enabled && gov.enabled, refetchOnWindowFocus: false, @@ -36,24 +36,24 @@ export const useDelegationRewardsByAddressLcd = ( ); }; -export const useCommissionsByValidatorAddressLcd = ( +export const useCommissionsByValidatorAddressRest = ( valAddr: Option, enabled: boolean ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const gov = useGovConfig({ shouldRedirect: false }); return useQuery( [ - CELATONE_QUERY_KEYS.COMMISSIONS_BY_VALIDATOR_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.COMMISSIONS_BY_VALIDATOR_ADDRESS_REST, + restEndpoint, valAddr, ], () => { if (isUndefined(valAddr)) return { commission: [] }; - return getCommissionsByValidatorAddressLcd(lcdEndpoint, valAddr); + return getCommissionsByValidatorAddressRest(restEndpoint, valAddr); }, { enabled: enabled && gov.enabled, diff --git a/src/lib/services/distribution/lcd.ts b/src/lib/services/distribution/rest.ts similarity index 68% rename from src/lib/services/distribution/lcd.ts rename to src/lib/services/distribution/rest.ts index 947462e80..7a1751aa0 100644 --- a/src/lib/services/distribution/lcd.ts +++ b/src/lib/services/distribution/rest.ts @@ -1,13 +1,13 @@ import axios from "axios"; import { - zCommissionsResponseLcd, - zDelegationRewardsResponseLcd, + zCommissionsResponseRest, + zDelegationRewardsResponseRest, } from "lib/services/types"; import type { BechAddr, ValidatorAddr } from "lib/types"; import { parseWithError } from "lib/utils"; -export const getDelegationRewardsByAddressLcd = ( +export const getDelegationRewardsByAddressRest = ( endpoint: string, address: BechAddr ) => @@ -15,9 +15,9 @@ export const getDelegationRewardsByAddressLcd = ( .get( `${endpoint}/cosmos/distribution/v1beta1/delegators/${encodeURI(address)}/rewards` ) - .then(({ data }) => parseWithError(zDelegationRewardsResponseLcd, data)); + .then(({ data }) => parseWithError(zDelegationRewardsResponseRest, data)); -export const getCommissionsByValidatorAddressLcd = ( +export const getCommissionsByValidatorAddressRest = ( endpoint: string, valAddr: ValidatorAddr ) => @@ -26,5 +26,5 @@ export const getCommissionsByValidatorAddressLcd = ( `${endpoint}/cosmos/distribution/v1beta1/validators/${encodeURI(valAddr)}/commission` ) .then( - ({ data }) => parseWithError(zCommissionsResponseLcd, data).commission + ({ data }) => parseWithError(zCommissionsResponseRest, data).commission ); diff --git a/src/lib/services/evm/index.ts b/src/lib/services/evm/index.ts index 7374a8d33..46ee07f43 100644 --- a/src/lib/services/evm/index.ts +++ b/src/lib/services/evm/index.ts @@ -17,21 +17,21 @@ import { getEvmCodesByAddress, getEvmContractInfoSequencer, getEvmParams, -} from "./lcd"; +} from "./rest"; export const useEvmParams = () => { const { chainConfig: { - lcd: lcdEndpoint, + rest: restEndpoint, features: { evm }, }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.EVM_PARAMS_LCD, lcdEndpoint], + [CELATONE_QUERY_KEYS.EVM_PARAMS_REST, restEndpoint], async () => { if (!evm.enabled) throw new Error("EVM is not enabled (useEvmParams)"); - return getEvmParams(lcdEndpoint); + return getEvmParams(restEndpoint); }, { enabled: evm.enabled, @@ -45,12 +45,12 @@ export const useEvmParams = () => { export const useEvmCodesByAddress = (address: HexAddr20, enabled = true) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.EVM_CODES_BY_ADDRESS_LCD, lcdEndpoint, address], - async () => getEvmCodesByAddress(lcdEndpoint, address), + [CELATONE_QUERY_KEYS.EVM_CODES_BY_ADDRESS_REST, restEndpoint, address], + async () => getEvmCodesByAddress(restEndpoint, address), { retry: 1, refetchOnWindowFocus: false, @@ -61,18 +61,19 @@ export const useEvmCodesByAddress = (address: HexAddr20, enabled = true) => { export const useEvmContractInfoSequencer = (address: HexAddr20) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.EVM_CONTRACT_INFO_SEQUENCER, - lcdEndpoint, + restEndpoint, bech32Prefix, address, ], - async () => getEvmContractInfoSequencer(lcdEndpoint, bech32Prefix, address), + async () => + getEvmContractInfoSequencer(restEndpoint, bech32Prefix, address), { retry: 1, refetchOnWindowFocus: false, diff --git a/src/lib/services/evm/lcd.ts b/src/lib/services/evm/rest.ts similarity index 93% rename from src/lib/services/evm/lcd.ts rename to src/lib/services/evm/rest.ts index 7e349b064..d0b12252d 100644 --- a/src/lib/services/evm/lcd.ts +++ b/src/lib/services/evm/rest.ts @@ -7,7 +7,7 @@ import { } from "lib/utils"; import { getTxsByAccountAddressSequencer } from "../tx/sequencer"; import { zEvmMsgCreate } from "../types"; -import { zEvmCodesByAddressResponseLcd, zEvmParams } from "../types/evm"; +import { zEvmCodesByAddressResponseRest, zEvmParams } from "../types/evm"; export const getEvmParams = (endpoint: string) => axios @@ -17,7 +17,7 @@ export const getEvmParams = (endpoint: string) => export const getEvmCodesByAddress = (endpoint: string, address: HexAddr20) => axios .get(`${endpoint}/minievm/evm/v1/codes/${encodeURI(address)}`) - .then(({ data }) => parseWithError(zEvmCodesByAddressResponseLcd, data)); + .then(({ data }) => parseWithError(zEvmCodesByAddressResponseRest, data)); export const getEvmContractInfoSequencer = async ( endpoint: string, diff --git a/src/lib/services/move/module/index.ts b/src/lib/services/move/module/index.ts index 3b59cf121..e96d51731 100644 --- a/src/lib/services/move/module/index.ts +++ b/src/lib/services/move/module/index.ts @@ -47,9 +47,9 @@ import { getModuleTableCounts, getModuleTxs, } from "./api"; -import { getModuleByAddressLcd, getModulesByAddressLcd } from "./lcd"; +import { getModuleByAddressRest, getModulesByAddressRest } from "./rest"; -export const useModuleByAddressLcd = ({ +export const useModuleByAddressRest = ({ address, moduleName, options = {}, @@ -59,14 +59,15 @@ export const useModuleByAddressLcd = ({ options?: Omit, "queryKey">; }) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - const queryFn = () => getModuleByAddressLcd(lcdEndpoint, address, moduleName); + const queryFn = () => + getModuleByAddressRest(restEndpoint, address, moduleName); return useQuery( [ - CELATONE_QUERY_KEYS.MODULE_BY_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.MODULE_BY_ADDRESS_REST, + restEndpoint, address, moduleName, ], @@ -87,15 +88,15 @@ export const useModulesByAddress = ({ onError?: (err: AxiosError) => void; }) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.MODULES_BY_ADDRESS, lcdEndpoint, address], + [CELATONE_QUERY_KEYS.MODULES_BY_ADDRESS, restEndpoint, address], async () => { if (!address) throw new Error("address is undefined (useModulesByAddress)"); - return getModulesByAddressLcd(lcdEndpoint, address); + return getModulesByAddressRest(restEndpoint, address); }, { enabled, @@ -123,14 +124,14 @@ export const useFunctionView = ({ onError?: (err: AxiosError) => void; }): UseQueryResult => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const queryFn: QueryFunction = () => - getFunctionView(lcdEndpoint, moduleAddress, moduleName, fn, abiData); + getFunctionView(restEndpoint, moduleAddress, moduleName, fn, abiData); return useQuery( [ CELATONE_QUERY_KEYS.FUNCTION_VIEW, - lcdEndpoint, + restEndpoint, moduleAddress, moduleName, fn.name, @@ -155,7 +156,7 @@ export const useDecodeModule = ({ options?: Omit, "queryKey">; }) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const move = useMoveConfig({ shouldRedirect: false }); @@ -164,8 +165,8 @@ export const useDecodeModule = ({ const abi = await decodeModule(base64EncodedFile); const modulePath = `${truncate(abi.address)}::${abi.name}`; - const currentPolicy = await getModuleByAddressLcd( - lcdEndpoint, + const currentPolicy = await getModuleByAddressRest( + restEndpoint, zHexAddr.parse(abi.address), abi.name ) @@ -177,7 +178,7 @@ export const useDecodeModule = ({ return useQuery( [ CELATONE_QUERY_KEYS.MODULE_DECODE, - lcdEndpoint, + restEndpoint, move.enabled, base64EncodedFile, ], @@ -194,12 +195,12 @@ export const useDecodeScript = ({ options?: Omit, "queryKey">; }): UseQueryResult => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const queryFn = async (): Promise => { const fn = await decodeScript( - `${lcdEndpoint}/initia/move/v1/script/abi`, + `${restEndpoint}/initia/move/v1/script/abi`, base64EncodedFile ); return { @@ -212,7 +213,7 @@ export const useDecodeScript = ({ }; return useQuery( - [CELATONE_QUERY_KEYS.SCRIPT_DECODE, lcdEndpoint, base64EncodedFile], + [CELATONE_QUERY_KEYS.SCRIPT_DECODE, restEndpoint, base64EncodedFile], queryFn, options ); diff --git a/src/lib/services/move/module/lcd.ts b/src/lib/services/move/module/rest.ts similarity index 77% rename from src/lib/services/move/module/lcd.ts rename to src/lib/services/move/module/rest.ts index e6822978e..973548008 100644 --- a/src/lib/services/move/module/lcd.ts +++ b/src/lib/services/move/module/rest.ts @@ -2,14 +2,14 @@ import axios from "axios"; import type { AccountModulesResponse } from "lib/services/types"; import { - zModuleResponseLcd, - zModulesResponseLcd, - zMoveViewJsonResponseLcd, + zModuleResponseRest, + zModulesResponseRest, + zMoveViewJsonResponseRest, } from "lib/services/types"; import type { Addr, HexAddr, IndexedModule, Nullable } from "lib/types"; import { parseWithError } from "lib/utils"; -export const getModuleByAddressLcd = async ( +export const getModuleByAddressRest = async ( endpoint: string, address: Addr, moduleName: string @@ -18,9 +18,9 @@ export const getModuleByAddressLcd = async ( .get( `${endpoint}/initia/move/v1/accounts/${encodeURI(address)}/modules/${encodeURI(moduleName)}` ) - .then(({ data }) => parseWithError(zModuleResponseLcd, data).module); + .then(({ data }) => parseWithError(zModuleResponseRest, data).module); -export const getModulesByAddressLcd = async ( +export const getModulesByAddressRest = async ( endpoint: string, address: Addr ): Promise => { @@ -36,7 +36,7 @@ export const getModulesByAddressLcd = async ( }, } ) - .then(({ data }) => parseWithError(zModulesResponseLcd, data)); + .then(({ data }) => parseWithError(zModulesResponseRest, data)); result.push(...res.modules); if (res.pagination.nextKey) await fetchFn(res.pagination.nextKey); }; @@ -49,7 +49,7 @@ export const getModulesByAddressLcd = async ( }; }; -export const getMoveViewJsonLcd = async ( +export const getMoveViewJsonRest = async ( endpoint: string, vmAddress: HexAddr, moduleName: string, @@ -65,4 +65,4 @@ export const getMoveViewJsonLcd = async ( type_args: typeArgs, args, }) - .then(({ data }) => parseWithError(zMoveViewJsonResponseLcd, data)); + .then(({ data }) => parseWithError(zMoveViewJsonResponseRest, data)); diff --git a/src/lib/services/move/resource/index.ts b/src/lib/services/move/resource/index.ts index 26ad3a753..9cca4850d 100644 --- a/src/lib/services/move/resource/index.ts +++ b/src/lib/services/move/resource/index.ts @@ -10,7 +10,7 @@ import type { Addr, ResourceGroup, ResourceGroupByAccount } from "lib/types"; import { zHexAddr } from "lib/types"; import { truncate } from "lib/utils"; -import { getAccountResourcesLcd } from "./lcd"; +import { getAccountResourcesRest } from "./rest"; export interface ResourcesByAddressReturn { groupedByOwner: ResourceGroupByAccount[]; @@ -18,16 +18,16 @@ export interface ResourcesByAddressReturn { totalCount: number; } -export const useResourcesByAddressLcd = ( +export const useResourcesByAddressRest = ( address: Addr ): UseQueryResult => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { enabled } = useMoveConfig({ shouldRedirect: false }); const queryFn: QueryFunction = () => - getAccountResourcesLcd(lcdEndpoint, address).then((resources) => { + getAccountResourcesRest(restEndpoint, address).then((resources) => { const groupedByOwner = resources.items.reduce< Record >((acc, resource) => { @@ -83,7 +83,7 @@ export const useResourcesByAddressLcd = ( }; }); return useQuery( - [CELATONE_QUERY_KEYS.RESOURCES_BY_ADDRESS, lcdEndpoint, address], + [CELATONE_QUERY_KEYS.RESOURCES_BY_ADDRESS, restEndpoint, address], queryFn, { enabled, refetchOnWindowFocus: false, retry: 1 } ); diff --git a/src/lib/services/move/resource/lcd.ts b/src/lib/services/move/resource/rest.ts similarity index 82% rename from src/lib/services/move/resource/lcd.ts rename to src/lib/services/move/resource/rest.ts index cadc62380..0d23395e1 100644 --- a/src/lib/services/move/resource/lcd.ts +++ b/src/lib/services/move/resource/rest.ts @@ -1,6 +1,6 @@ import axios from "axios"; -import { zResourcesResponseLcd } from "lib/services/types"; +import { zResourcesResponseRest } from "lib/services/types"; import type { ResourceResponse, ResourceResponseItem, @@ -8,7 +8,7 @@ import type { import type { Addr, Nullable } from "lib/types"; import { parseWithError } from "lib/utils"; -export const getAccountResourcesLcd = async ( +export const getAccountResourcesRest = async ( endpoint: string, address: Addr ): Promise => { @@ -24,7 +24,7 @@ export const getAccountResourcesLcd = async ( }, } ) - .then(({ data }) => parseWithError(zResourcesResponseLcd, data)); + .then(({ data }) => parseWithError(zResourcesResponseRest, data)); result.push(...res.resources); if (res.pagination.nextKey) await fetchFn(res.pagination.nextKey); }; diff --git a/src/lib/services/name/index.ts b/src/lib/services/name/index.ts index ab12efff7..9601f2dd9 100644 --- a/src/lib/services/name/index.ts +++ b/src/lib/services/name/index.ts @@ -8,20 +8,20 @@ import { } from "lib/app-provider"; import type { BechAddr, BechAddr32, Option } from "lib/types"; -import { getAddressByIcnsNameLcd, getIcnsNamesByAddressLcd } from "./lcd"; -import { getContractLcd } from "../wasm/contract/lcd"; +import { getAddressByIcnsNameRest, getIcnsNamesByAddressRest } from "./rest"; +import { getContractRest } from "../wasm/contract/rest"; -export const useIcnsNamesByAddressLcd = ( +export const useIcnsNamesByAddressRest = ( address: Option, enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const queryFn = async () => { if (!address) throw new Error("address is undefined"); - const icnsNames = await getIcnsNamesByAddressLcd(lcdEndpoint, address); + const icnsNames = await getIcnsNamesByAddressRest(restEndpoint, address); const primaryIndex = icnsNames.names.indexOf(icnsNames.primaryName); if (primaryIndex > -1) { @@ -33,7 +33,7 @@ export const useIcnsNamesByAddressLcd = ( }; return useQuery( - [CELATONE_QUERY_KEYS.ICNS_NAMES_BY_ADDRESS_LCD, lcdEndpoint, address], + [CELATONE_QUERY_KEYS.ICNS_NAMES_BY_ADDRESS_REST, restEndpoint, address], queryFn, { refetchOnWindowFocus: false, @@ -43,24 +43,24 @@ export const useIcnsNamesByAddressLcd = ( ); }; -export const useAddressByIcnsNameLcd = (name: string, enabled = true) => { +export const useAddressByIcnsNameRest = (name: string, enabled = true) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const getAddressType = useGetAddressType(); const { bech32Prefix } = useCurrentChain(); const queryFn = async () => { // Strip bech32 prefix to allow searching with .prefix (e.g. example.osmo) const [stripPrefixName] = name.split(`.${bech32Prefix}`); - const { address: icnsAddress } = await getAddressByIcnsNameLcd( - lcdEndpoint, + const { address: icnsAddress } = await getAddressByIcnsNameRest( + restEndpoint, stripPrefixName, bech32Prefix ); let addressType = getAddressType(icnsAddress); if (addressType === "contract_address") { - const contractData = await getContractLcd( - lcdEndpoint, + const contractData = await getContractRest( + restEndpoint, icnsAddress as BechAddr32 ); if (!contractData) addressType = "user_address"; @@ -73,8 +73,8 @@ export const useAddressByIcnsNameLcd = (name: string, enabled = true) => { return useQuery({ queryKey: [ - CELATONE_QUERY_KEYS.ADDRESS_BY_ICNS_NAME_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.ADDRESS_BY_ICNS_NAME_REST, + restEndpoint, name, bech32Prefix, ], diff --git a/src/lib/services/name/lcd.ts b/src/lib/services/name/rest.ts similarity index 91% rename from src/lib/services/name/lcd.ts rename to src/lib/services/name/rest.ts index df5960eec..74e2e0ed1 100644 --- a/src/lib/services/name/lcd.ts +++ b/src/lib/services/name/rest.ts @@ -7,7 +7,7 @@ import { encode, parseWithError } from "lib/utils"; const icnsResolverAddress = "osmo1xk0s8xgktn9x5vwcgtjdxqzadg88fgn33p8u9cnpdxwemvxscvast52cdd"; -export const getIcnsNamesByAddressLcd = async ( +export const getIcnsNamesByAddressRest = async ( endpoint: string, address: BechAddr ) => { @@ -26,7 +26,7 @@ export const getIcnsNamesByAddressLcd = async ( .then(({ data }) => parseWithError(zIcnsNamesByAddress, data)); }; -export const getAddressByIcnsNameLcd = async ( +export const getAddressByIcnsNameRest = async ( endpoint: string, name: string, bech32Prefix: string diff --git a/src/lib/services/nft-collection/index.ts b/src/lib/services/nft-collection/index.ts index 4f572fa04..3be4a8e6e 100644 --- a/src/lib/services/nft-collection/index.ts +++ b/src/lib/services/nft-collection/index.ts @@ -61,14 +61,14 @@ export const useNftCollectionByCollectionAddress = ( const { tier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("nft_collections"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_BY_COLLECTION_ADDRESS, apiEndpoint, - lcdEndpoint, + restEndpoint, tier, collectionAddress, ], @@ -80,7 +80,7 @@ export const useNftCollectionByCollectionAddress = ( getNftCollectionByCollectionAddress(apiEndpoint, collectionAddress), querySequencer: () => getNftCollectionByCollectionAddressSequencer( - lcdEndpoint, + restEndpoint, collectionAddress ), }), @@ -97,14 +97,14 @@ export const useNftCollectionCreator = (collectionAddress: HexAddr32) => { const { tier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("nft_collections"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_CREATOR, apiEndpoint, - lcdEndpoint, + restEndpoint, tier, bech32Prefix, collectionAddress, @@ -120,7 +120,7 @@ export const useNftCollectionCreator = (collectionAddress: HexAddr32) => { ), querySequencer: () => getNftCollectionCreatorSequencer( - lcdEndpoint, + restEndpoint, bech32Prefix, collectionAddress ), @@ -170,14 +170,14 @@ export const useNftCollectionActivitiesSequencer = ( collectionAddress: HexAddr32 ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { data, ...rest } = useInfiniteQuery( - [CELATONE_QUERY_KEYS.NFT_COLLECTION_ACTIVITIES_SEQUENCER, lcdEndpoint], + [CELATONE_QUERY_KEYS.NFT_COLLECTION_ACTIVITIES_SEQUENCER, restEndpoint], async ({ pageParam }) => getNftCollectionActivitiesSequencer( - lcdEndpoint, + restEndpoint, pageParam, collectionAddress ), @@ -230,7 +230,7 @@ export const useNftCollectionMutateEvents = ( export const useNftCollectionsByAccountAddress = (accountAddress: HexAddr) => { const apiEndpoint = useBaseApiRoute("nft_collections"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { tier } = useTierConfig(); @@ -238,7 +238,7 @@ export const useNftCollectionsByAccountAddress = (accountAddress: HexAddr) => { [ CELATONE_QUERY_KEYS.NFT_COLLECTIONS_BY_ACCOUNT, apiEndpoint, - lcdEndpoint, + restEndpoint, tier, accountAddress, ], @@ -250,7 +250,7 @@ export const useNftCollectionsByAccountAddress = (accountAddress: HexAddr) => { getNftCollectionsByAccountAddress(apiEndpoint, accountAddress), querySequencer: () => getNftCollectionsByAccountAddressSequencer( - lcdEndpoint, + restEndpoint, accountAddress ), }), diff --git a/src/lib/services/nft-collection/lcd.ts b/src/lib/services/nft-collection/rest.ts similarity index 86% rename from src/lib/services/nft-collection/lcd.ts rename to src/lib/services/nft-collection/rest.ts index e0d35dfaf..2af4707c7 100644 --- a/src/lib/services/nft-collection/lcd.ts +++ b/src/lib/services/nft-collection/rest.ts @@ -4,15 +4,15 @@ import { z } from "zod"; import { zHexAddr } from "lib/types"; import type { HexAddr, HexAddr32 } from "lib/types"; import { parseWithError } from "lib/utils"; -import { getMoveViewJsonLcd } from "../move/module/lcd"; +import { getMoveViewJsonRest } from "../move/module/rest"; import type { CollectionByCollectionAddressResponse } from "../types"; -export const getCollectionByCollectionAddressLcd = async ( +export const getCollectionByCollectionAddressRest = async ( endpoint: string, collectionAddress: HexAddr32 ) => Promise.all([ - getMoveViewJsonLcd( + getMoveViewJsonRest( endpoint, "0x1" as HexAddr, "collection", @@ -20,7 +20,7 @@ export const getCollectionByCollectionAddressLcd = async ( ["0x1::collection::Collection"], [`"${collectionAddress}"`] ).then((name) => parseWithError(z.string(), name)), - getMoveViewJsonLcd( + getMoveViewJsonRest( endpoint, "0x1" as HexAddr, "collection", @@ -28,7 +28,7 @@ export const getCollectionByCollectionAddressLcd = async ( ["0x1::collection::Collection"], [`"${collectionAddress}"`] ).then((name) => parseWithError(z.string(), name)), - getMoveViewJsonLcd( + getMoveViewJsonRest( endpoint, "0x1" as HexAddr, "collection", @@ -36,7 +36,7 @@ export const getCollectionByCollectionAddressLcd = async ( ["0x1::collection::Collection"], [`"${collectionAddress}"`] ).then((name) => parseWithError(z.string(), name)), - getMoveViewJsonLcd( + getMoveViewJsonRest( endpoint, "0x1" as HexAddr, "collection", diff --git a/src/lib/services/nft-collection/sequencer.ts b/src/lib/services/nft-collection/sequencer.ts index 71e06d640..dd3468321 100644 --- a/src/lib/services/nft-collection/sequencer.ts +++ b/src/lib/services/nft-collection/sequencer.ts @@ -6,7 +6,8 @@ import { convertAccountPubkeyToAccountAddress, parseWithError, } from "lib/utils"; -import { getCollectionByCollectionAddressLcd } from "./lcd"; + +import { getCollectionByCollectionAddressRest } from "./rest"; import { getTxsByAccountAddressSequencer } from "../tx/sequencer"; import type { Activity, CollectionCreatorResponse } from "../types"; import { @@ -27,7 +28,7 @@ export const getNftCollectionByCollectionAddressSequencer = async ( ) // Fallback to lite version if the collection is not found .catch(() => - getCollectionByCollectionAddressLcd(endpoint, collectionAddress) + getCollectionByCollectionAddressRest(endpoint, collectionAddress) ); export const getNftCollectionsByAccountAddressSequencer = async ( diff --git a/src/lib/services/nft/index.ts b/src/lib/services/nft/index.ts index ace21ef59..1e9647363 100644 --- a/src/lib/services/nft/index.ts +++ b/src/lib/services/nft/index.ts @@ -20,7 +20,7 @@ import { getNftsByCollectionAddress, getNftTxs, } from "./api"; -import { getNftByNftAddressLcd } from "./lcd"; +import { getNftByNftAddressRest } from "./rest"; import { getNftMintInfoSequencer, getNftsByAccountSequencer, @@ -47,7 +47,7 @@ export const useNfts = ( const { tier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("nfts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( @@ -59,7 +59,7 @@ export const useNfts = ( search, tier, apiEndpoint, - lcdEndpoint, + restEndpoint, ], async () => handleQueryByTier({ @@ -74,7 +74,7 @@ export const useNfts = ( offset ), querySequencer: () => - getNftsSequencer(lcdEndpoint, collectionAddress).then((nfts) => { + getNftsSequencer(restEndpoint, collectionAddress).then((nfts) => { const filteredData = nfts.filter( (val) => val.tokenId.toLowerCase().includes(search.toLowerCase()) || @@ -104,7 +104,7 @@ export const useNftByNftAddress = ( const { tier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("nfts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( @@ -114,7 +114,7 @@ export const useNftByNftAddress = ( nftAddress, tier, apiEndpoint, - lcdEndpoint, + restEndpoint, ], async () => handleQueryByTier({ @@ -122,7 +122,7 @@ export const useNftByNftAddress = ( threshold: "sequencer", queryFull: () => getNftByNftAddress(apiEndpoint, collectionAddress, nftAddress), - querySequencer: () => getNftByNftAddressLcd(lcdEndpoint, nftAddress), + querySequencer: () => getNftByNftAddressRest(restEndpoint, nftAddress), }), { enabled, @@ -132,17 +132,17 @@ export const useNftByNftAddress = ( ); }; -export const useNftByNftAddressLcd = ( +export const useNftByNftAddressRest = ( nftAddress: HexAddr32, enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.NFT_BY_NFT_ADDRESS_LCD, nftAddress, lcdEndpoint], - async () => getNftByNftAddressLcd(lcdEndpoint, nftAddress), + [CELATONE_QUERY_KEYS.NFT_BY_NFT_ADDRESS_REST, nftAddress, restEndpoint], + async () => getNftByNftAddressRest(restEndpoint, nftAddress), { enabled, retry: 1, @@ -156,14 +156,14 @@ export const useNftMintInfo = (nftAddress: HexAddr32) => { const { tier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("nfts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_TOKEN_MINT_INFO, apiEndpoint, - lcdEndpoint, + restEndpoint, tier, nftAddress, bech32Prefix, @@ -174,7 +174,7 @@ export const useNftMintInfo = (nftAddress: HexAddr32) => { threshold: "sequencer", queryFull: () => getNftMintInfo(apiEndpoint, nftAddress), querySequencer: () => - getNftMintInfoSequencer(lcdEndpoint, bech32Prefix, nftAddress), + getNftMintInfoSequencer(restEndpoint, bech32Prefix, nftAddress), }), { retry: 1, @@ -219,13 +219,13 @@ export const useNftTransactionsSequencer = ( enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { data, ...rest } = useInfiniteQuery( - [CELATONE_QUERY_KEYS.NFT_TRANSACTIONS_SEQUENCER, lcdEndpoint], + [CELATONE_QUERY_KEYS.NFT_TRANSACTIONS_SEQUENCER, restEndpoint], async ({ pageParam }) => - getNftTransactionsSequencer(lcdEndpoint, pageParam, nftAddress), + getNftTransactionsSequencer(restEndpoint, pageParam, nftAddress), { getNextPageParam: (lastPage) => lastPage.pagination.nextKey ?? undefined, refetchOnWindowFocus: false, @@ -318,19 +318,23 @@ export const useNftsByAccountByCollectionSequencer = ( enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ CELATONE_QUERY_KEYS.NFTS_BY_ACCOUNT_BY_COLLECTION_SEQUENCER, - lcdEndpoint, + restEndpoint, accountAddress, collectionAddress, search, ], async () => - getNftsByAccountSequencer(lcdEndpoint, accountAddress, collectionAddress), + getNftsByAccountSequencer( + restEndpoint, + accountAddress, + collectionAddress + ), { retry: 1, refetchOnWindowFocus: false, diff --git a/src/lib/services/nft/lcd.ts b/src/lib/services/nft/rest.ts similarity index 63% rename from src/lib/services/nft/lcd.ts rename to src/lib/services/nft/rest.ts index dce7750d3..9ba721cff 100644 --- a/src/lib/services/nft/lcd.ts +++ b/src/lib/services/nft/rest.ts @@ -1,15 +1,15 @@ import { zHexAddr } from "lib/types"; import type { HexAddr, HexAddr32 } from "lib/types"; import { parseWithError } from "lib/utils"; -import { getMoveViewJsonLcd } from "../move/module/lcd"; +import { getMoveViewJsonRest } from "../move/module/rest"; import type { Nft } from "../types"; -import { zNftInfoLcd } from "../types"; +import { zNftInfoRest } from "../types"; -export const getNftHolderLcd = async ( +export const getNftHolderRest = async ( endpoint: string, nftAddress: HexAddr32 ) => - getMoveViewJsonLcd( + getMoveViewJsonRest( endpoint, "0x1" as HexAddr, "object", @@ -18,23 +18,23 @@ export const getNftHolderLcd = async ( [`"${nftAddress}"`] ).then((data) => parseWithError(zHexAddr, data)); -export const getNftInfoLcd = async (endpoint: string, nftAddress: HexAddr32) => - getMoveViewJsonLcd( +export const getNftInfoRest = async (endpoint: string, nftAddress: HexAddr32) => + getMoveViewJsonRest( endpoint, "0x1" as HexAddr, "nft", "nft_info", [], [`"${nftAddress}"`] - ).then((data) => parseWithError(zNftInfoLcd, data)); + ).then((data) => parseWithError(zNftInfoRest, data)); -export const getNftByNftAddressLcd = async ( +export const getNftByNftAddressRest = async ( endpoint: string, nftAddress: HexAddr32 ) => Promise.all([ - getNftHolderLcd(endpoint, nftAddress), - getNftInfoLcd(endpoint, nftAddress), + getNftHolderRest(endpoint, nftAddress), + getNftInfoRest(endpoint, nftAddress), ]).then(([holder, info]) => ({ uri: info.uri, tokenId: info.tokenId, diff --git a/src/lib/services/proposal/index.ts b/src/lib/services/proposal/index.ts index 87269c753..dd21f2830 100644 --- a/src/lib/services/proposal/index.ts +++ b/src/lib/services/proposal/index.ts @@ -34,33 +34,33 @@ import { getRelatedProposalsByContractAddress, } from "./api"; import { - getProposalDataLcd, - getProposalDepositsLcd, - getProposalParamsLcd, - getProposalsLcd, - getProposalVotesInfoLcd, -} from "./lcd"; + getProposalDataRest, + getProposalDepositsRest, + getProposalParamsRest, + getProposalsRest, + getProposalVotesInfoRest, +} from "./rest"; import type { ProposalAnswerCountsResponse, ProposalDataResponse, - ProposalDataResponseLcd, + ProposalDataResponseRest, ProposalsResponse, - ProposalsResponseLcd, + ProposalsResponseRest, ProposalValidatorVotesResponse, ProposalVotesResponse, RelatedProposalsResponse, -} from "../types/proposal"; +} from "../types"; export const useProposalParams = () => { const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("proposals"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const [endpoint, queryFn] = isFullTier ? [apiEndpoint, getProposalParams] - : [lcdEndpoint, getProposalParamsLcd]; + : [restEndpoint, getProposalParamsRest]; return useQuery>( [CELATONE_QUERY_KEYS.PROPOSAL_PARAMS, endpoint], @@ -114,16 +114,16 @@ export const useProposals = ( ); }; -export const useProposalsLcd = ( +export const useProposalsRest = ( status?: Omit ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - const { data, ...rest } = useInfiniteQuery( - [CELATONE_QUERY_KEYS.PROPOSALS_LCD, lcdEndpoint, status], - ({ pageParam }) => getProposalsLcd(lcdEndpoint, pageParam, status), + const { data, ...rest } = useInfiniteQuery( + [CELATONE_QUERY_KEYS.PROPOSALS_REST, restEndpoint, status], + ({ pageParam }) => getProposalsRest(restEndpoint, pageParam, status), { getNextPageParam: (lastPage) => lastPage.pagination.nextKey ?? undefined, refetchOnWindowFocus: false, @@ -195,14 +195,14 @@ export const useProposalData = (id: number, enabled = true) => { ); }; -export const useProposalDataLcd = (id: number, enabled = true) => { +export const useProposalDataRest = (id: number, enabled = true) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - return useQuery( - [CELATONE_QUERY_KEYS.PROPOSAL_DATA_LCD, lcdEndpoint, id], - async () => getProposalDataLcd(lcdEndpoint, id), + return useQuery( + [CELATONE_QUERY_KEYS.PROPOSAL_DATA_REST, restEndpoint, id], + async () => getProposalDataRest(restEndpoint, id), { retry: 1, refetchOnWindowFocus: false, @@ -211,14 +211,14 @@ export const useProposalDataLcd = (id: number, enabled = true) => { ); }; -export const useProposalDepositsLcd = (id: number, enabled = true) => { +export const useProposalDepositsRest = (id: number, enabled = true) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery[]>( - [CELATONE_QUERY_KEYS.PROPOSAL_DEPOSITS_LCD, lcdEndpoint, id], - async () => getProposalDepositsLcd(lcdEndpoint, id), + [CELATONE_QUERY_KEYS.PROPOSAL_DEPOSITS_REST, restEndpoint, id], + async () => getProposalDepositsRest(restEndpoint, id), { retry: 1, refetchOnWindowFocus: false, @@ -231,12 +231,12 @@ export const useProposalVotesInfo = (id: number, enabled: boolean) => { const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("proposals"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const [endpoint, queryFn] = isFullTier ? [apiEndpoint, getProposalVotesInfo] - : [lcdEndpoint, getProposalVotesInfoLcd]; + : [restEndpoint, getProposalVotesInfoRest]; return useQuery( [CELATONE_QUERY_KEYS.PROPOSAL_VOTES_INFO, endpoint, id], diff --git a/src/lib/services/proposal/lcd.ts b/src/lib/services/proposal/rest.ts similarity index 65% rename from src/lib/services/proposal/lcd.ts rename to src/lib/services/proposal/rest.ts index d355f979b..aae7dc93f 100644 --- a/src/lib/services/proposal/lcd.ts +++ b/src/lib/services/proposal/rest.ts @@ -1,15 +1,15 @@ import axios from "axios"; import type { - ProposalDataResponseLcd, - ProposalsResponseLcd, + ProposalDataResponseRest, + ProposalsResponseRest, } from "lib/services/types"; import { - zProposalDataResponseLcd, - zProposalDepositsResponseLcd, - zProposalParamsResponseLcd, - zProposalsResponseLcd, - zProposalVotesInfoResponseLcd, + zProposalDataResponseRest, + zProposalDepositsResponseRest, + zProposalParamsResponseRest, + zProposalsResponseRest, + zProposalVotesInfoResponseRest, } from "lib/services/types"; import type { Coin, @@ -21,18 +21,18 @@ import type { } from "lib/types"; import { parseWithError } from "lib/utils"; -export const getProposalParamsLcd = (lcdEndpoint: string) => +export const getProposalParamsRest = (restEndpoint: string) => axios - .get(`${lcdEndpoint}/cosmos/gov/v1/params/deposit`) + .get(`${restEndpoint}/cosmos/gov/v1/params/deposit`) .then( - ({ data }) => parseWithError(zProposalParamsResponseLcd, data).params + ({ data }) => parseWithError(zProposalParamsResponseRest, data).params ); -export const getProposalsLcd = async ( +export const getProposalsRest = async ( endpoint: string, paginationKey: Option, status?: Omit -): Promise => +): Promise => axios .get(`${endpoint}/cosmos/gov/v1/proposals`, { params: { @@ -44,19 +44,19 @@ export const getProposalsLcd = async ( }), }, }) - .then(({ data }) => parseWithError(zProposalsResponseLcd, data)); + .then(({ data }) => parseWithError(zProposalsResponseRest, data)); -export const getProposalDataLcd = async ( +export const getProposalDataRest = async ( endpoint: string, id: number -): Promise => +): Promise => axios .get(`${endpoint}/cosmos/gov/v1/proposals/${encodeURIComponent(id)}`) .then(({ data }) => - parseWithError(zProposalDataResponseLcd, data.proposal) + parseWithError(zProposalDataResponseRest, data.proposal) ); -export const getProposalDepositsLcd = async (endpoint: string, id: number) => { +export const getProposalDepositsRest = async (endpoint: string, id: number) => { const result: ProposalDeposit[] = []; const fetchFn = async (paginationKey: Nullable) => { @@ -70,7 +70,7 @@ export const getProposalDepositsLcd = async (endpoint: string, id: number) => { }, } ) - .then(({ data }) => parseWithError(zProposalDepositsResponseLcd, data)); + .then(({ data }) => parseWithError(zProposalDepositsResponseRest, data)); result.push(...res.deposits); if (res.pagination.nextKey) await fetchFn(res.pagination.nextKey); }; @@ -80,7 +80,7 @@ export const getProposalDepositsLcd = async (endpoint: string, id: number) => { return result; }; -export const getProposalVotesInfoLcd = async ( +export const getProposalVotesInfoRest = async ( endpoint: string, id: number ): Promise => @@ -90,5 +90,8 @@ export const getProposalVotesInfoLcd = async ( ), axios.get(`${endpoint}/cosmos/staking/v1beta1/pool`), ]).then(([tallyRes, poolRes]) => - parseWithError(zProposalVotesInfoResponseLcd, [tallyRes.data, poolRes.data]) + parseWithError(zProposalVotesInfoResponseRest, [ + tallyRes.data, + poolRes.data, + ]) ); diff --git a/src/lib/services/searchService.ts b/src/lib/services/searchService.ts index 402b1efdc..8134d7d3a 100644 --- a/src/lib/services/searchService.ts +++ b/src/lib/services/searchService.ts @@ -23,21 +23,21 @@ import { toChecksumAddress, } from "lib/utils"; -import { useBlockData, useBlockDataLcd } from "./block"; +import { useBlockData, useBlockDataRest } from "./block"; import { useEvmCodesByAddress } from "./evm"; -import { useModuleByAddressLcd } from "./move/module"; -import { useAddressByIcnsNameLcd, useIcnsNamesByAddressLcd } from "./name"; -import { useNftByNftAddressLcd } from "./nft"; +import { useModuleByAddressRest } from "./move/module"; +import { useAddressByIcnsNameRest, useIcnsNamesByAddressRest } from "./name"; +import { useNftByNftAddressRest } from "./nft"; import { useNftCollectionByCollectionAddress } from "./nft-collection"; import { usePoolData } from "./pools"; -import { useProposalData, useProposalDataLcd } from "./proposal"; +import { useProposalData, useProposalDataRest } from "./proposal"; import { useEvmTxDataJsonRpc, useTxData } from "./tx"; import { useAddressByInitiaUsername, useInitiaUsernameByAddress, } from "./username"; -import { useValidatorData, useValidatorDataLcd } from "./validator"; -import { useCodeLcd } from "./wasm/code"; +import { useValidatorData, useValidatorDataRest } from "./validator"; +import { useCodeRest } from "./wasm/code"; import { useContractData } from "./wasm/contract"; export type SearchResultType = @@ -131,14 +131,17 @@ export const useSearchHandler = ( // ICNS const { data: icnsAddrByKeyword, isFetching: icnsAddrByKeywordFetching } = - useAddressByIcnsNameLcd(debouncedKeyword, isWasm); + useAddressByIcnsNameRest(debouncedKeyword, isWasm); const { data: icnsNamesByIcnsAddr, isFetching: icnsNamesByIcnsAddrFetching } = - useIcnsNamesByAddressLcd( + useIcnsNamesByAddressRest( icnsAddrByKeyword?.address as BechAddr, !isInitia && icnsAddrByKeyword !== undefined ); const { data: icnsNamesByKeyword, isFetching: icnsNamesByKeywordFetching } = - useIcnsNamesByAddressLcd(debouncedKeyword as BechAddr, !isInitia && isAddr); + useIcnsNamesByAddressRest( + debouncedKeyword as BechAddr, + !isInitia && isAddr + ); // Initia Username (IU) const { data: iuAddrByKeyword, isFetching: iuAddrByKeywordFetching } = @@ -150,7 +153,7 @@ export const useSearchHandler = ( // NFT /// ///////////////////////////////////////////////////// - const { data: nftData, isFetching: nftFetching } = useNftByNftAddressLcd( + const { data: nftData, isFetching: nftFetching } = useNftByNftAddressRest( zHexAddr32.parse(debouncedKeyword), isNft && isHexModuleAddress(debouncedKeyword) && !isLiteTier ); @@ -179,7 +182,7 @@ export const useSearchHandler = ( ); const { data: moduleData, isFetching: moduleFetching } = - useModuleByAddressLcd({ + useModuleByAddressRest({ address: addr, moduleName: moduleName ?? "", options: { @@ -195,7 +198,7 @@ export const useSearchHandler = ( // Wasm /// ///////////////////////////////////////////////////// - const { data: codeData, isFetching: codeFetching } = useCodeLcd( + const { data: codeData, isFetching: codeFetching } = useCodeRest( Number(debouncedKeyword), { enabled: isWasm && isId(debouncedKeyword), @@ -240,13 +243,13 @@ export const useSearchHandler = ( Number(debouncedKeyword), isPosDecimal(debouncedKeyword) && isFullTier ); - const blockLcd = useBlockDataLcd( + const blockRest = useBlockDataRest( Number(debouncedKeyword), isPosDecimal(debouncedKeyword) && !isFullTier ); const { data: blockData, isFetching: blockFetching } = isFullTier ? blockApi - : blockLcd; + : blockRest; /// ///////////////////////////////////////////////////// // Proposal @@ -257,20 +260,20 @@ export const useSearchHandler = ( Number(debouncedKeyword), isGov && isId(debouncedKeyword) && isFullTier ); - const { data: proposalLcdData, isFetching: proposalLcdIsFetching } = - useProposalDataLcd( + const { data: proposalRestData, isFetching: proposalRestIsFetching } = + useProposalDataRest( Number(debouncedKeyword), isGov && isId(debouncedKeyword) && !isFullTier ); const [proposalData, proposalFetching] = isFullTier ? [proposalApiData, proposalApiIsFetching] : [ - proposalLcdData + proposalRestData ? { - info: proposalLcdData, + info: proposalRestData, } : undefined, - proposalLcdIsFetching, + proposalRestIsFetching, ]; /// ///////////////////////////////////////////////////// @@ -281,13 +284,13 @@ export const useSearchHandler = ( zValidatorAddr.parse(debouncedKeyword), isGov && validateValidatorAddress(debouncedKeyword) === null && isFullTier ); - const validatorLcd = useValidatorDataLcd( + const validatorRest = useValidatorDataRest( zValidatorAddr.parse(debouncedKeyword), isGov && validateValidatorAddress(debouncedKeyword) === null && !isFullTier ); const { data: validatorData, isFetching: validatorFetching } = isFullTier ? validatorApi - : validatorLcd; + : validatorRest; /// ///////////////////////////////////////////////////// // Osmosis Pool diff --git a/src/lib/services/staking/index.ts b/src/lib/services/staking/index.ts index a1deb324c..319c22c02 100644 --- a/src/lib/services/staking/index.ts +++ b/src/lib/services/staking/index.ts @@ -10,21 +10,21 @@ import type { BechAddr } from "lib/types"; import { getDelegationData } from "./api"; import { - getDelegationsByAddressLcd, - getRedelegationsByAddressLcd, - getStakingParamsLcd, - getUnbondingsByAddressLcd, -} from "./lcd"; + getDelegationsByAddressRest, + getRedelegationsByAddressRest, + getStakingParamsRest, + getUnbondingsByAddressRest, +} from "./rest"; -export const useStakingParamsLcd = (enabled: boolean) => { +export const useStakingParamsRest = (enabled: boolean) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const gov = useGovConfig({ shouldRedirect: false }); return useQuery( - [CELATONE_QUERY_KEYS.STAKING_PARAMS_LCD, lcdEndpoint], - () => getStakingParamsLcd(lcdEndpoint), + [CELATONE_QUERY_KEYS.STAKING_PARAMS_REST, restEndpoint], + () => getStakingParamsRest(restEndpoint), { enabled: enabled && gov.enabled, refetchOnWindowFocus: false, @@ -32,18 +32,18 @@ export const useStakingParamsLcd = (enabled: boolean) => { ); }; -export const useDelegationsByAddressLcd = ( +export const useDelegationsByAddressRest = ( address: BechAddr, enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const gov = useGovConfig({ shouldRedirect: false }); return useQuery( - [CELATONE_QUERY_KEYS.DELEGATIONS_BY_ADDRESS_LCD, lcdEndpoint, address], - () => getDelegationsByAddressLcd(lcdEndpoint, address), + [CELATONE_QUERY_KEYS.DELEGATIONS_BY_ADDRESS_REST, restEndpoint, address], + () => getDelegationsByAddressRest(restEndpoint, address), { enabled: enabled && gov.enabled, refetchOnWindowFocus: false, @@ -51,18 +51,18 @@ export const useDelegationsByAddressLcd = ( ); }; -export const useUnbondingsByAddressLcd = ( +export const useUnbondingsByAddressRest = ( address: BechAddr, enabled: boolean ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const gov = useGovConfig({ shouldRedirect: false }); return useQuery( - [CELATONE_QUERY_KEYS.UNBONDINGS_BY_ADDRESS_LCD, lcdEndpoint, address], - () => getUnbondingsByAddressLcd(lcdEndpoint, address), + [CELATONE_QUERY_KEYS.UNBONDINGS_BY_ADDRESS_REST, restEndpoint, address], + () => getUnbondingsByAddressRest(restEndpoint, address), { enabled: enabled && gov.enabled, refetchOnWindowFocus: false, @@ -70,18 +70,18 @@ export const useUnbondingsByAddressLcd = ( ); }; -export const useRedelegationsByAddressLcd = ( +export const useRedelegationsByAddressRest = ( address: BechAddr, enabled: boolean ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const gov = useGovConfig({ shouldRedirect: false }); return useQuery( - [CELATONE_QUERY_KEYS.REDELEGATIONS_BY_ADDRESS_LCD, lcdEndpoint, address], - () => getRedelegationsByAddressLcd(lcdEndpoint, address), + [CELATONE_QUERY_KEYS.REDELEGATIONS_BY_ADDRESS_REST, restEndpoint, address], + () => getRedelegationsByAddressRest(restEndpoint, address), { enabled: enabled && gov.enabled, refetchOnWindowFocus: false, diff --git a/src/lib/services/staking/lcd.ts b/src/lib/services/staking/rest.ts similarity index 65% rename from src/lib/services/staking/lcd.ts rename to src/lib/services/staking/rest.ts index cb5b4b5e3..50e51f5a1 100644 --- a/src/lib/services/staking/lcd.ts +++ b/src/lib/services/staking/rest.ts @@ -1,37 +1,39 @@ import axios from "axios"; import { - zAnnualProvisionsResponseLcd, - zDelegationsResponseLcd, - zDistributionParamsResponseLcd, - zEpochProvisionsResponseLcd, - zMintParamsResponseLcd, - zRedelegationsResponseLcd, - zStakingParamsResponseLcd, - zUnbondingsResponseLcd, + zAnnualProvisionsResponseRest, + zDelegationsResponseRest, + zDistributionParamsResponseRest, + zEpochProvisionsResponseRest, + zMintParamsResponseRest, + zRedelegationsResponseRest, + zStakingParamsResponseRest, + zUnbondingsResponseRest, } from "lib/services/types"; import { big } from "lib/types"; import type { BechAddr } from "lib/types"; import { parseWithError } from "lib/utils"; -export const getStakingParamsLcd = (endpoint: string) => +export const getStakingParamsRest = (endpoint: string) => axios .get(`${endpoint}/cosmos/staking/v1beta1/params`) - .then(({ data }) => parseWithError(zStakingParamsResponseLcd, data).params); + .then( + ({ data }) => parseWithError(zStakingParamsResponseRest, data).params + ); -export const getDelegationsByAddressLcd = ( +export const getDelegationsByAddressRest = ( endpoint: string, address: BechAddr ) => axios .get(`${endpoint}/cosmos/staking/v1beta1/delegations/${encodeURI(address)}`) .then(({ data }) => - parseWithError(zDelegationsResponseLcd, data).delegationResponses.sort( + parseWithError(zDelegationsResponseRest, data).delegationResponses.sort( (a, b) => big(b.balance.amount).cmp(a.balance.amount) ) ); -export const getUnbondingsByAddressLcd = ( +export const getUnbondingsByAddressRest = ( endpoint: string, address: BechAddr ) => @@ -40,7 +42,7 @@ export const getUnbondingsByAddressLcd = ( `${endpoint}/cosmos/staking/v1beta1/delegators/${encodeURI(address)}/unbonding_delegations` ) .then(({ data }) => - parseWithError(zUnbondingsResponseLcd, data) + parseWithError(zUnbondingsResponseRest, data) .unbondingResponses.flatMap((unbonding) => unbonding.entries.map((entry) => ({ delegatorAddress: unbonding.delegatorAddress, @@ -51,7 +53,7 @@ export const getUnbondingsByAddressLcd = ( .sort((a, b) => a.completionTime.getTime() - b.completionTime.getTime()) ); -export const getRedelegationsByAddressLcd = ( +export const getRedelegationsByAddressRest = ( endpoint: string, address: BechAddr ) => @@ -60,7 +62,7 @@ export const getRedelegationsByAddressLcd = ( `${endpoint}/cosmos/staking/v1beta1/delegators/${encodeURI(address)}/redelegations` ) .then(({ data }) => - parseWithError(zRedelegationsResponseLcd, data) + parseWithError(zRedelegationsResponseRest, data) .redelegationResponses.flatMap((redelegation) => redelegation.entries.map((entry) => ({ ...redelegation.redelegation, @@ -71,12 +73,12 @@ export const getRedelegationsByAddressLcd = ( .sort((a, b) => a.completionTime.getTime() - b.completionTime.getTime()) ); -export const getDistributionParamsLcd = (endpoint: string) => +export const getDistributionParamsRest = (endpoint: string) => axios .get(`${endpoint}/cosmos/distribution/v1beta1/params`) - .then(({ data }) => parseWithError(zDistributionParamsResponseLcd, data)); + .then(({ data }) => parseWithError(zDistributionParamsResponseRest, data)); -export const getAnnualProvisionsLcd = (endpoint: string, chain: string) => { +export const getAnnualProvisionsRest = (endpoint: string, chain: string) => { if (chain === "sei") return { annualProvisions: big(0), @@ -84,22 +86,22 @@ export const getAnnualProvisionsLcd = (endpoint: string, chain: string) => { return axios .get(`${endpoint}/cosmos/mint/v1beta1/annual_provisions`) - .then(({ data }) => parseWithError(zAnnualProvisionsResponseLcd, data)); + .then(({ data }) => parseWithError(zAnnualProvisionsResponseRest, data)); }; -export const getMintParamsLcd = (endpoint: string, chain: string) => +export const getMintParamsRest = (endpoint: string, chain: string) => axios .get( `${endpoint}/${chain === "osmosis" ? chain : "cosmos"}/mint/v1beta1/params` ) - .then(({ data }) => parseWithError(zMintParamsResponseLcd, data)); + .then(({ data }) => parseWithError(zMintParamsResponseRest, data)); -export const getEpochProvisionsLcd = (endpoint: string, chain: string) => { +export const getEpochProvisionsRest = (endpoint: string, chain: string) => { if (chain !== "osmosis") { throw new Error("Unsupported chain"); } return axios .get(`${endpoint}/osmosis/mint/v1beta1/epoch_provisions`) - .then(({ data }) => parseWithError(zEpochProvisionsResponseLcd, data)); + .then(({ data }) => parseWithError(zEpochProvisionsResponseRest, data)); }; diff --git a/src/lib/services/tx/api.ts b/src/lib/services/tx/api.ts index bb4dc5fe5..16854c478 100644 --- a/src/lib/services/tx/api.ts +++ b/src/lib/services/tx/api.ts @@ -5,7 +5,7 @@ import { camelToSnake, parseWithError } from "lib/utils"; import { zAccountTxsResponse, zBlockTxsResponse, - zTxByHashResponseLcd, + zTxByHashResponseRest, zTxsByPoolIdResponse, zTxsByPoolIdTxsCountResponse, zTxsCountResponse, @@ -15,7 +15,7 @@ import { export const getTxData = async (txsApiRoute: string, txHash: string) => axios .get(`${txsApiRoute}/${encodeURI(txHash.toUpperCase())}`) - .then(({ data }) => parseWithError(zTxByHashResponseLcd, data)); + .then(({ data }) => parseWithError(zTxByHashResponseRest, data)); export const getTxs = async ( endpoint: string, diff --git a/src/lib/services/tx/index.ts b/src/lib/services/tx/index.ts index f57e265fc..b6511b732 100644 --- a/src/lib/services/tx/index.ts +++ b/src/lib/services/tx/index.ts @@ -51,11 +51,11 @@ import { getTxsDataJsonRpc, } from "./jsonRpc"; import { - getTxDataLcd, - getTxsByAccountAddressLcd, - getTxsByContractAddressLcd, - getTxsByHashLcd, -} from "./lcd"; + getTxDataRest, + getTxsByAccountAddressRest, + getTxsByContractAddressRest, + getTxsByHashRest, +} from "./rest"; import { getTxsByAccountAddressSequencer, getTxsByBlockHeightSequencer, @@ -76,12 +76,12 @@ export const useTxData = ( ): UseQueryResult => { const { currentChainId, - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("txs"); - const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; + const endpoint = isFullTier ? apiEndpoint : restEndpoint; const queryFn = useCallback( async (hash: Option) => { @@ -89,7 +89,7 @@ export const useTxData = ( const txData = isFullTier ? await getTxData(endpoint, hash) - : await getTxDataLcd(endpoint, hash); + : await getTxDataRest(endpoint, hash); const { txResponse } = txData; @@ -321,20 +321,20 @@ export const useTxsCountByAddress = ( ); }; -export const useTxsByContractAddressLcd = ( +export const useTxsByContractAddressRest = ( address: BechAddr32, limit: number, offset: number, options: UseQueryOptions = {} ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); const queryfn = useCallback( () => - getTxsByContractAddressLcd(lcdEndpoint, address, limit, offset).then( + getTxsByContractAddressRest(restEndpoint, address, limit, offset).then( (txs) => ({ items: txs.items.map((tx) => ({ ...tx, @@ -346,13 +346,13 @@ export const useTxsByContractAddressLcd = ( total: txs.total, }) ), - [address, lcdEndpoint, limit, offset, bech32Prefix] + [address, restEndpoint, limit, offset, bech32Prefix] ); return useQuery( [ - CELATONE_QUERY_KEYS.TXS_BY_CONTRACT_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.TXS_BY_CONTRACT_ADDRESS_REST, + restEndpoint, address, limit, offset, @@ -362,7 +362,7 @@ export const useTxsByContractAddressLcd = ( ); }; -export const useTxsByAddressLcd = ( +export const useTxsByAddressRest = ( address: Option, search: Option, limit: number, @@ -370,7 +370,7 @@ export const useTxsByAddressLcd = ( options: UseQueryOptions = {} ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); @@ -378,10 +378,10 @@ export const useTxsByAddressLcd = ( const queryfn = useCallback(async () => { const txs = await (async () => { if (search && isTxHash(search)) { - const txsByHash = await getTxsByHashLcd(lcdEndpoint, search); + const txsByHash = await getTxsByHashRest(restEndpoint, search); if (txsByHash.total === 0) - throw new Error("transaction not found (getTxsByHashLcd)"); + throw new Error("transaction not found (getTxsByHashRest)"); const tx = txsByHash.items[0]; const sender = convertAccountPubkeyToAccountAddress( @@ -391,15 +391,15 @@ export const useTxsByAddressLcd = ( if (address === sender) return txsByHash; - throw new Error("address is not equal to sender (getTxsByHashLcd)"); + throw new Error("address is not equal to sender (getTxsByHashRest)"); } if (search && !isTxHash(search)) - throw new Error("search is not a tx hash (useTxsByAddressLcd)"); + throw new Error("search is not a tx hash (useTxsByAddressRest)"); if (!address) - throw new Error("address is undefined (useTxsByAddressLcd)"); - return getTxsByAccountAddressLcd(lcdEndpoint, address, limit, offset); + throw new Error("address is undefined (useTxsByAddressRest)"); + return getTxsByAccountAddressRest(restEndpoint, address, limit, offset); })(); return { @@ -412,12 +412,12 @@ export const useTxsByAddressLcd = ( })), total: txs.total, }; - }, [address, lcdEndpoint, limit, offset, bech32Prefix, search]); + }, [address, restEndpoint, limit, offset, bech32Prefix, search]); return useQuery( [ - CELATONE_QUERY_KEYS.TXS_BY_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.TXS_BY_ADDRESS_REST, + restEndpoint, address, search, limit, @@ -430,19 +430,19 @@ export const useTxsByAddressLcd = ( export const useTxsSequencer = (limit = 10) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); const queryfn = useCallback( async (pageParam: Option) => { - return getTxsSequencer(lcdEndpoint, pageParam, limit); + return getTxsSequencer(restEndpoint, pageParam, limit); }, - [lcdEndpoint, limit] + [restEndpoint, limit] ); const { data, ...rest } = useInfiniteQuery( - [CELATONE_QUERY_KEYS.TXS_SEQUENCER, lcdEndpoint, limit], + [CELATONE_QUERY_KEYS.TXS_SEQUENCER, restEndpoint, limit], ({ pageParam }) => queryfn(pageParam), { getNextPageParam: (lastPage) => lastPage.pagination.nextKey ?? undefined, @@ -470,12 +470,12 @@ export const useTxsSequencer = (limit = 10) => { export const useTxsCountSequencer = () => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.TXS_COUNT_SEQUENCER, lcdEndpoint], - async () => getTxsCountSequencer(lcdEndpoint), + [CELATONE_QUERY_KEYS.TXS_COUNT_SEQUENCER, restEndpoint], + async () => getTxsCountSequencer(restEndpoint), { retry: 1, refetchOnWindowFocus: false } ); }; @@ -504,7 +504,7 @@ export const useTxsByAddressSequencer = ( limit = 10 ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); @@ -513,7 +513,7 @@ export const useTxsByAddressSequencer = ( async (pageParam: Option) => { return (async () => { if (search && isTxHash(search)) { - const txsByHash = await getTxsByHashSequencer(lcdEndpoint, search); + const txsByHash = await getTxsByHashSequencer(restEndpoint, search); if (txsByHash.pagination.total === 0) throw new Error("transaction not found (getTxsByHashSequencer)"); @@ -544,20 +544,20 @@ export const useTxsByAddressSequencer = ( throw new Error("address is undefined (useTxsByAddressSequncer)"); return getTxsByAccountAddressSequencer({ - endpoint: lcdEndpoint, + endpoint: restEndpoint, address, paginationKey: pageParam, limit, }); })(); }, - [address, lcdEndpoint, bech32Prefix, search, limit] + [address, restEndpoint, bech32Prefix, search, limit] ); const { data, ...rest } = useInfiniteQuery( [ CELATONE_QUERY_KEYS.TXS_BY_ADDRESS_SEQUENCER, - lcdEndpoint, + restEndpoint, address, search, limit, @@ -591,20 +591,20 @@ export const useTxsByAddressPaginationSequencer = ( enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ CELATONE_QUERY_KEYS.TXS_BY_ADDRESS_PAGINATION_SEQUENCER, - lcdEndpoint, + restEndpoint, address, paginationKey, limit, ], () => getTxsByAccountAddressSequencer({ - endpoint: lcdEndpoint, + endpoint: restEndpoint, address, paginationKey, limit, @@ -620,19 +620,19 @@ export const useTxsByAddressPaginationSequencer = ( export const useTxsByBlockHeightSequencer = (height: number) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.TXS_BY_BLOCK_HEIGHT_SEQUENCER, - lcdEndpoint, + restEndpoint, height, bech32Prefix, ], async () => { - const txs = await getTxsByBlockHeightSequencer(lcdEndpoint, height); + const txs = await getTxsByBlockHeightSequencer(restEndpoint, height); return txs.map((tx) => ({ ...tx, diff --git a/src/lib/services/tx/lcd.ts b/src/lib/services/tx/rest.ts similarity index 66% rename from src/lib/services/tx/lcd.ts rename to src/lib/services/tx/rest.ts index d60432956..fbe0fb165 100644 --- a/src/lib/services/tx/lcd.ts +++ b/src/lib/services/tx/rest.ts @@ -3,22 +3,22 @@ import axios from "axios"; import type { BechAddr20, BechAddr32 } from "lib/types"; import { parseWithError } from "lib/utils"; import { - zTxByHashResponseLcd, - zTxsByAddressResponseLcd, - zTxsByHashResponseLcd, + zTxByHashResponseRest, + zTxsByAddressResponseRest, + zTxsByHashResponseRest, } from "../types"; -export const getTxDataLcd = async (endpoint: string, txHash: string) => +export const getTxDataRest = async (endpoint: string, txHash: string) => axios .get(`${endpoint}/cosmos/tx/v1beta1/txs/${encodeURI(txHash)}`) - .then(({ data }) => parseWithError(zTxByHashResponseLcd, data)); + .then(({ data }) => parseWithError(zTxByHashResponseRest, data)); -export const getTxsByHashLcd = async (endpoint: string, txHash: string) => +export const getTxsByHashRest = async (endpoint: string, txHash: string) => axios .get(`${endpoint}/cosmos/tx/v1beta1/txs/${encodeURI(txHash)}`) - .then(({ data }) => parseWithError(zTxsByHashResponseLcd, data)); + .then(({ data }) => parseWithError(zTxsByHashResponseRest, data)); -export const getTxsByContractAddressLcd = async ( +export const getTxsByContractAddressRest = async ( endpoint: string, contractAddress: BechAddr32, limit: number, @@ -43,15 +43,15 @@ export const getTxsByContractAddressLcd = async ( }), ]).then(([queryParam, eventsParam]) => { if (queryParam.status === "fulfilled") - return parseWithError(zTxsByAddressResponseLcd, queryParam.value.data); + return parseWithError(zTxsByAddressResponseRest, queryParam.value.data); if (eventsParam.status === "fulfilled") - return parseWithError(zTxsByAddressResponseLcd, eventsParam.value.data); + return parseWithError(zTxsByAddressResponseRest, eventsParam.value.data); - throw new Error("No data found (getTxsByContractAddressLcd)"); + throw new Error("No data found (getTxsByContractAddressRest)"); }); -export const getTxsByAccountAddressLcd = async ( +export const getTxsByAccountAddressRest = async ( endpoint: string, address: BechAddr20, limit: number, @@ -76,10 +76,10 @@ export const getTxsByAccountAddressLcd = async ( }), ]).then(([queryParam, eventsParam]) => { if (queryParam.status === "fulfilled") - return parseWithError(zTxsByAddressResponseLcd, queryParam.value.data); + return parseWithError(zTxsByAddressResponseRest, queryParam.value.data); if (eventsParam.status === "fulfilled") - return parseWithError(zTxsByAddressResponseLcd, eventsParam.value.data); + return parseWithError(zTxsByAddressResponseRest, eventsParam.value.data); - throw new Error("No data found (getTxsByAccountAddressLcd)"); + throw new Error("No data found (getTxsByAccountAddressRest)"); }); diff --git a/src/lib/services/types/account.ts b/src/lib/services/types/account.ts index fca2988cd..c690ddda2 100644 --- a/src/lib/services/types/account.ts +++ b/src/lib/services/types/account.ts @@ -2,7 +2,7 @@ import { z } from "zod"; import { AccountType, - AccountTypeLcd, + AccountTypeRest, zProjectInfo, zPublicAccountInfo, } from "lib/types"; @@ -35,10 +35,10 @@ export const zAccountTableCounts = z export type AccountTableCounts = z.infer; -export const zAccountTypeLcd = z +export const zAccountTypeRest = z .object({ account: z.object({ - "@type": z.nativeEnum(AccountTypeLcd), + "@type": z.nativeEnum(AccountTypeRest), }), }) .transform((data) => data.account["@type"]); @@ -49,12 +49,12 @@ export const zAccountTypeResponse = z }) .transform((val) => val.type); -export const zAccountBech32LcdResponse = z +export const zAccountBech32RestResponse = z .object({ bech32_prefix: z.string(), }) .transform(snakeToCamel); -export type AccountBech32LcdResponse = z.infer< - typeof zAccountBech32LcdResponse +export type AccountBech32RestResponse = z.infer< + typeof zAccountBech32RestResponse >; diff --git a/src/lib/services/types/bank.ts b/src/lib/services/types/bank.ts index 925961417..f9b175341 100644 --- a/src/lib/services/types/bank.ts +++ b/src/lib/services/types/bank.ts @@ -5,7 +5,7 @@ import type { Option, TokenWithValue, USD } from "lib/types"; export const zBalancesResponse = z.array(zCoin); -export const zBalancesReponseLcd = z.object({ +export const zBalancesReponseRest = z.object({ balances: zBalancesResponse, pagination: zPagination.nullable(), }); diff --git a/src/lib/services/types/block.ts b/src/lib/services/types/block.ts index 0d7d29f42..54899be8b 100644 --- a/src/lib/services/types/block.ts +++ b/src/lib/services/types/block.ts @@ -82,8 +82,8 @@ export const zBlockDataResponse = z gasLimit: val.gas_limit, })); -// ---------------- LCD ---------------- -export const zBlockLcd = z.object({ +// ---------------- REST ---------------- +export const zBlockRest = z.object({ block: z.object({ header: z.object({ chain_id: z.string(), @@ -100,7 +100,7 @@ export const zBlockLcd = z.object({ }), }); -export const zBlockDataResponseLcd = zBlockLcd +export const zBlockDataResponseRest = zBlockRest .extend({ txs: z.array(zTx), pagination: zPagination, diff --git a/src/lib/services/types/distribution.ts b/src/lib/services/types/distribution.ts index c903a72ca..e3ee0dbcc 100644 --- a/src/lib/services/types/distribution.ts +++ b/src/lib/services/types/distribution.ts @@ -3,7 +3,7 @@ import { z } from "zod"; import { zCoin, zValidatorAddr } from "lib/types"; import { snakeToCamel } from "lib/utils"; -export const zDelegationRewardsResponseLcd = z +export const zDelegationRewardsResponseRest = z .object({ rewards: z.array( z.object({ @@ -15,7 +15,7 @@ export const zDelegationRewardsResponseLcd = z }) .transform(snakeToCamel); -export const zCommissionsResponseLcd = z.object({ +export const zCommissionsResponseRest = z.object({ commission: z.object({ commission: z.array(zCoin), }), diff --git a/src/lib/services/types/evm/codes.ts b/src/lib/services/types/evm/codes.ts index 500b4eadc..efaf103e4 100644 --- a/src/lib/services/types/evm/codes.ts +++ b/src/lib/services/types/evm/codes.ts @@ -2,9 +2,9 @@ import { z } from "zod"; import { is0x } from "lib/utils"; -export const zEvmCodesByAddressResponseLcd = z.object({ +export const zEvmCodesByAddressResponseRest = z.object({ code: z.string().transform((val) => (is0x(val) ? null : val)), }); -export type EvmCodesByAddressResponseLcd = z.infer< - typeof zEvmCodesByAddressResponseLcd +export type EvmCodesByAddressResponseRest = z.infer< + typeof zEvmCodesByAddressResponseRest >; diff --git a/src/lib/services/types/move/module.ts b/src/lib/services/types/move/module.ts index a647aace4..124d38c57 100644 --- a/src/lib/services/types/move/module.ts +++ b/src/lib/services/types/move/module.ts @@ -24,7 +24,7 @@ import { import { zProposal, zProposalsResponseItem } from "../proposal"; import { zTxsResponseItem } from "../tx"; -const zBaseModuleLcd = z.object({ +const zBaseModuleRest = z.object({ address: zHexAddr, module_name: z.string(), abi: z.string(), @@ -32,23 +32,23 @@ const zBaseModuleLcd = z.object({ upgrade_policy: z.nativeEnum(UpgradePolicy), }); -const zIndexedModuleLcd = zBaseModuleLcd.transform((val) => ({ +const zIndexedModuleRest = zBaseModuleRest.transform((val) => ({ ...snakeToCamel(val), ...indexModuleAbi(val.abi), digest: sha256Hex(Buffer.from(val.raw_bytes, "utf-8")), })); -export const zModuleResponseLcd = z.object({ - module: zIndexedModuleLcd, +export const zModuleResponseRest = z.object({ + module: zIndexedModuleRest, }); -export const zModulesResponseLcd = z.object({ - modules: z.array(zIndexedModuleLcd), +export const zModulesResponseRest = z.object({ + modules: z.array(zIndexedModuleRest), pagination: zPagination, }); export const zAccountModulesResponse = z.object({ - items: z.array(zIndexedModuleLcd), + items: z.array(zIndexedModuleRest), total: z.number().nonnegative(), }); export type AccountModulesResponse = z.infer; @@ -146,7 +146,7 @@ export interface ModuleInitialPublishInfo { initProposalTitle: Option; } -export const zMoveViewJsonResponseLcd = z +export const zMoveViewJsonResponseRest = z .object({ data: z.string(), }) diff --git a/src/lib/services/types/move/resource.ts b/src/lib/services/types/move/resource.ts index 976e4cf53..09cd9a554 100644 --- a/src/lib/services/types/move/resource.ts +++ b/src/lib/services/types/move/resource.ts @@ -13,7 +13,7 @@ const zResourcesResponseItem = z .transform(snakeToCamel); export type ResourceResponseItem = z.infer; -export const zResourcesResponseLcd = z.object({ +export const zResourcesResponseRest = z.object({ resources: z.array(zResourcesResponseItem), pagination: zPagination, }); diff --git a/src/lib/services/types/nft.ts b/src/lib/services/types/nft.ts index 638c41650..e4ddfd6dc 100644 --- a/src/lib/services/types/nft.ts +++ b/src/lib/services/types/nft.ts @@ -141,7 +141,7 @@ export const zNftsByAccountResponseSequencer = z pagination: val.pagination, })); -export const zNftInfoLcd = z +export const zNftInfoRest = z .object({ collection: zHexAddr32, description: z.string(), diff --git a/src/lib/services/types/proposal.ts b/src/lib/services/types/proposal.ts index 82d8890dd..d6dadaf58 100644 --- a/src/lib/services/types/proposal.ts +++ b/src/lib/services/types/proposal.ts @@ -46,7 +46,7 @@ export const zProposalParamsResponse = z }) .transform>(snakeToCamel); -export const zProposalParamsResponseLcd = z.object({ +export const zProposalParamsResponseRest = z.object({ params: zProposalParamsResponse, }); @@ -144,7 +144,7 @@ export const zProposalVotesInfoResponse = z totalVotingPower: val.current_total_voting_power, })); -export const zProposalVotesInfoResponseLcd = z +export const zProposalVotesInfoResponseRest = z .tuple([ z.object({ tally: z.object({ @@ -220,7 +220,7 @@ export type ProposalAnswerCountsResponse = z.infer< typeof zProposalAnswerCountsResponse >; -export const zProposalDataResponseLcd = z +export const zProposalDataResponseRest = z .object({ id: z.coerce.number(), messages: z.array(zMessageResponse).nullable(), @@ -268,15 +268,17 @@ export const zProposalDataResponseLcd = z resolvedTimestamp: null, votingTime: val.voting_start_time, })); -export type ProposalDataResponseLcd = z.infer; +export type ProposalDataResponseRest = z.infer< + typeof zProposalDataResponseRest +>; -export const zProposalsResponseLcd = z.object({ - proposals: z.array(zProposalDataResponseLcd), +export const zProposalsResponseRest = z.object({ + proposals: z.array(zProposalDataResponseRest), pagination: zPagination, }); -export type ProposalsResponseLcd = z.infer; +export type ProposalsResponseRest = z.infer; -export const zProposalDepositsResponseLcd = z.object({ +export const zProposalDepositsResponseRest = z.object({ deposits: z.array( z .object({ diff --git a/src/lib/services/types/staking.ts b/src/lib/services/types/staking.ts index 601f9a74c..1b9535d1e 100644 --- a/src/lib/services/types/staking.ts +++ b/src/lib/services/types/staking.ts @@ -11,7 +11,7 @@ import { } from "lib/types"; import { formatSeconds, snakeToCamel } from "lib/utils"; -export const zStakingParamsResponseLcd = z +export const zStakingParamsResponseRest = z .object({ params: z.object({ unbonding_time: z.string().transform((val) => formatSeconds(val)), // e.g. "1209600s" @@ -24,7 +24,7 @@ export const zStakingParamsResponseLcd = z }) .transform(snakeToCamel); -export const zDistributionParamsResponseLcd = z +export const zDistributionParamsResponseRest = z .object({ params: z.object({ community_tax: zBig, @@ -35,13 +35,13 @@ export const zDistributionParamsResponseLcd = z }) .transform(snakeToCamel); -export const zAnnualProvisionsResponseLcd = z +export const zAnnualProvisionsResponseRest = z .object({ annual_provisions: zBig, }) .transform(snakeToCamel); -export const zMintParamsResponseLcd = z +export const zMintParamsResponseRest = z .object({ params: z.object({ mint_denom: z.string(), @@ -66,13 +66,13 @@ export const zMintParamsResponseLcd = z }) .transform(snakeToCamel); -export const zEpochProvisionsResponseLcd = z +export const zEpochProvisionsResponseRest = z .object({ epoch_provisions: zBig, }) .transform(snakeToCamel); -export const zDelegationsResponseLcd = z +export const zDelegationsResponseRest = z .object({ delegation_responses: z.array( z.object({ @@ -87,7 +87,7 @@ export const zDelegationsResponseLcd = z }) .transform(snakeToCamel); -export const zUnbondingsResponseLcd = z +export const zUnbondingsResponseRest = z .object({ unbonding_responses: z.array( z.object({ @@ -106,7 +106,7 @@ export const zUnbondingsResponseLcd = z }) .transform(snakeToCamel); -export const zRedelegationsResponseLcd = z +export const zRedelegationsResponseRest = z .object({ redelegation_responses: z.array( z.object({ diff --git a/src/lib/services/types/tx.ts b/src/lib/services/types/tx.ts index 0d0ef91d6..17365c3e4 100644 --- a/src/lib/services/types/tx.ts +++ b/src/lib/services/types/tx.ts @@ -167,7 +167,7 @@ export interface TxData extends TxResponse { isTxFailed: boolean; } -export const zTxsResponseItemFromLcd = +export const zTxsResponseItemFromRest = zTxResponse.transform((val) => { const txBody = val.tx.body; @@ -210,20 +210,22 @@ export const zTxsResponseItemFromLcd = }; }); -export const zTxsByAddressResponseLcd = z +export const zTxsByAddressResponseRest = z .object({ - tx_responses: z.array(zTxsResponseItemFromLcd), + tx_responses: z.array(zTxsResponseItemFromRest), total: z.coerce.number(), }) .transform((val) => ({ items: val.tx_responses, total: val.total, })); -export type TxsByAddressResponseLcd = z.infer; +export type TxsByAddressResponseRest = z.infer< + typeof zTxsByAddressResponseRest +>; export const zTxsResponseSequencer = z .object({ - txs: z.array(zTxsResponseItemFromLcd), + txs: z.array(zTxsResponseItemFromRest), pagination: zPagination, }) .transform((val) => ({ @@ -231,9 +233,9 @@ export const zTxsResponseSequencer = z pagination: val.pagination, })); -export const zTxsByHashResponseLcd = z +export const zTxsByHashResponseRest = z .object({ - tx_response: zTxsResponseItemFromLcd, + tx_response: zTxsResponseItemFromRest, }) .transform((val) => ({ items: [val.tx_response], @@ -242,7 +244,7 @@ export const zTxsByHashResponseLcd = z export const zTxsByHashResponseSequencer = z .object({ - tx: zTxsResponseItemFromLcd, + tx: zTxsResponseItemFromRest, }) .transform((val) => ({ items: [val.tx], @@ -255,7 +257,7 @@ export type TxsByHashResponseSequencer = z.infer< typeof zTxsByHashResponseSequencer >; -export const zTxByHashResponseLcd = z +export const zTxByHashResponseRest = z .object({ tx_response: zTxResponse, }) @@ -387,7 +389,7 @@ export const zTxsCountResponse = z .transform((val) => val.count); export const zBlockTxsResponseSequencer = z.object({ - txs: z.array(zTxsResponseItemFromLcd), + txs: z.array(zTxsResponseItemFromRest), pagination: zPagination, }); diff --git a/src/lib/services/types/validator.ts b/src/lib/services/types/validator.ts index 078dcf04d..e6c89e21b 100644 --- a/src/lib/services/types/validator.ts +++ b/src/lib/services/types/validator.ts @@ -18,7 +18,7 @@ import { } from "lib/types"; import { parseTxHash, snakeToCamel, valoperToAddr } from "lib/utils"; -const zValidatorInfoLcd = z +const zValidatorInfoRest = z .object({ operator_address: zValidatorAddr, consensus_pubkey: zConsensusPubkey, @@ -67,14 +67,14 @@ const zValidatorInfoLcd = z website: val.description.website, consensusPubkey: val.consensus_pubkey, })); -export type ValidatorInfoLcd = z.infer; +export type ValidatorInfoRest = z.infer; -export const zValidatorResponseLcd = z.object({ - validator: zValidatorInfoLcd, +export const zValidatorResponseRest = z.object({ + validator: zValidatorInfoRest, }); -export const zValidatorsResponseLcd = z.object({ - validators: z.array(zValidatorInfoLcd), +export const zValidatorsResponseRest = z.object({ + validators: z.array(zValidatorInfoRest), pagination: zPagination, }); diff --git a/src/lib/services/types/wasm/code.ts b/src/lib/services/types/wasm/code.ts index 2109176e4..85acf720b 100644 --- a/src/lib/services/types/wasm/code.ts +++ b/src/lib/services/types/wasm/code.ts @@ -22,7 +22,7 @@ const zUploadAccessParams = z })); export type UploadAccessParams = z.infer; -export const zUploadAccessParamsLcd = z +export const zUploadAccessParamsRest = z .object({ params: z.object({ code_upload_access: zUploadAccessParams, @@ -30,7 +30,7 @@ export const zUploadAccessParamsLcd = z }) .transform((val) => val.params.code_upload_access); -export const zUploadAccessParamsSubspaceLcd = z +export const zUploadAccessParamsSubspaceRest = z .object({ params: z.object({ subspace: z.literal("wasm"), @@ -61,7 +61,7 @@ export const zCodesResponse = z.object({ }); export type CodesResponse = z.infer; -const zCodesResponseItemLcd = z +const zCodesResponseItemRest = z .object({ code_id: z.coerce.number(), creator: zBechAddr, @@ -80,8 +80,8 @@ const zCodesResponseItemLcd = z permissionAddresses: val.instantiate_permission.addresses, })); -export const zCodesResponseLcd = z.object({ - code_infos: z.array(zCodesResponseItemLcd), +export const zCodesResponseRest = z.object({ + code_infos: z.array(zCodesResponseItemRest), pagination: zPagination, }); @@ -124,7 +124,7 @@ export const zCodeData = z .transform(snakeToCamel); export type CodeData = z.infer; -export const zCodeInfoResponseLcd = z +export const zCodeInfoResponseRest = z .object({ code_info: z.object({ code_id: z.coerce.number(), diff --git a/src/lib/services/types/wasm/contract.ts b/src/lib/services/types/wasm/contract.ts index c39efb7c4..05c7b74b5 100644 --- a/src/lib/services/types/wasm/contract.ts +++ b/src/lib/services/types/wasm/contract.ts @@ -18,7 +18,7 @@ const zContractCreated = z.object({ tx_index: z.coerce.number(), }); -const zContractRest = z.object({ +const zContractRestApi = z.object({ address: zBechAddr32, contract_info: z.object({ code_id: z.string(), @@ -30,7 +30,7 @@ const zContractRest = z.object({ extension: z.string().nullable(), }), }); -export type ContractRest = z.infer; +export type ContractRestApi = z.infer; const zContractsResponseItem = z .object({ @@ -62,7 +62,7 @@ export const zContractsResponse = z.object({ export type ContractsResponse = z.infer; -const zContractsResponseItemLcd = zBechAddr32.transform( +const zContractsResponseItemRest = zBechAddr32.transform( (val) => ({ contractAddress: val, label: "", @@ -75,10 +75,10 @@ const zContractsResponseItemLcd = zBechAddr32.transform( }) ); -export const zContractsResponseLcd = z +export const zContractsResponseRest = z .object({ - contracts: z.array(zContractsResponseItemLcd).default([]), // by code id case - contract_addresses: z.array(zContractsResponseItemLcd).optional(), + contracts: z.array(zContractsResponseItemRest).default([]), // by code id case + contract_addresses: z.array(zContractsResponseItemRest).optional(), pagination: zPagination, }) .transform((val) => ({ @@ -109,7 +109,7 @@ export type Contract = z.infer; export const zContractData = z .object({ contract: zContract, - contract_rest: zContractRest.nullable(), + contract_rest: zContractRestApi.nullable(), project_info: zProjectInfo.nullable(), public_info: zPublicContractInfo.nullable(), }) @@ -119,31 +119,33 @@ export const zContractData = z })); export type ContractData = z.infer; -export const zContractLcd = zContractRest.transform((val) => ({ - contract: { - address: val.address, - admin: val.contract_info.admin.length - ? zBechAddr.parse(val.contract_info.admin) - : null, - codeId: Number(val.contract_info.code_id), - codeHash: "", - createdHeight: val.contract_info.created - ? Number(val.contract_info.created.block_height) - : null, - createdTimestamp: null, - cw2Contract: null, - cw2Version: null, - initMsg: "", - initProposalId: null, - initProposalTitle: null, - initTxHash: null, - instantiator: val.contract_info.creator, - label: val.contract_info.label, - }, - contractRest: val, - projectInfo: null, - publicInfo: null, -})); +export const zContractRest = zContractRestApi.transform( + (val) => ({ + contract: { + address: val.address, + admin: val.contract_info.admin.length + ? zBechAddr.parse(val.contract_info.admin) + : null, + codeId: Number(val.contract_info.code_id), + codeHash: "", + createdHeight: val.contract_info.created + ? Number(val.contract_info.created.block_height) + : null, + createdTimestamp: null, + cw2Contract: null, + cw2Version: null, + initMsg: "", + initProposalId: null, + initProposalTitle: null, + initTxHash: null, + instantiator: val.contract_info.creator, + label: val.contract_info.label, + }, + contractRest: val, + projectInfo: null, + publicInfo: null, + }) +); export const zContractTableCounts = z .object({ @@ -183,7 +185,7 @@ export const zContractQueryMsgs = z val.query.map<[string, string]>((msg) => [msg, `{"${msg}": {}}`]) ); -export const zMigrationHistoriesResponseItemLcd = z +export const zMigrationHistoriesResponseItemRest = z .object({ operation: zRemarkOperation, code_id: z.coerce.number().positive(), @@ -205,25 +207,25 @@ export const zMigrationHistoriesResponseItemLcd = z cw2Version: null, msg: JSON.stringify(val.msg), })); -export type MigrationHistoriesResponseItemLcd = z.infer< - typeof zMigrationHistoriesResponseItemLcd +export type MigrationHistoriesResponseItemRest = z.infer< + typeof zMigrationHistoriesResponseItemRest >; -export const zMigrationHistoriesResponseLcd = z.object({ - entries: z.array(zMigrationHistoriesResponseItemLcd), +export const zMigrationHistoriesResponseRest = z.object({ + entries: z.array(zMigrationHistoriesResponseItemRest), pagination: zPagination, }); -export type MigrationHistoriesResponseLcd = z.infer< - typeof zMigrationHistoriesResponseLcd +export type MigrationHistoriesResponseRest = z.infer< + typeof zMigrationHistoriesResponseRest >; -export const zInstantiatedContractsLcd = z +export const zInstantiatedContractsRest = z .object({ contract_addresses: zBechAddr32.array(), }) .transform(snakeToCamel); -export const zContractCw2InfoLcd = z +export const zContractCw2InfoRest = z .object({ data: z.string().nullable(), }) @@ -237,7 +239,7 @@ export const zContractCw2InfoLcd = z .nullable() ); -export type ContractCw2InfoLcd = z.infer; +export type ContractCw2InfoRest = z.infer; const zAllAdminContractsResponseItem = z .object({ diff --git a/src/lib/services/username/index.ts b/src/lib/services/username/index.ts index b89f816dc..b053cbb2b 100644 --- a/src/lib/services/username/index.ts +++ b/src/lib/services/username/index.ts @@ -8,7 +8,7 @@ import { import { useFormatAddresses } from "lib/hooks/useFormatAddresses"; import type { Addr, Nullish } from "lib/types"; -import { getAddressByInitiaUsername, getInitiaUsernameByAddress } from "./lcd"; +import { getAddressByInitiaUsername, getInitiaUsernameByAddress } from "./rest"; export const useInitiaUsernameByAddress = ( address: Nullish, diff --git a/src/lib/services/username/lcd.ts b/src/lib/services/username/rest.ts similarity index 77% rename from src/lib/services/username/lcd.ts rename to src/lib/services/username/rest.ts index 17f80adaf..a3b9fe978 100644 --- a/src/lib/services/username/lcd.ts +++ b/src/lib/services/username/rest.ts @@ -1,15 +1,15 @@ import type { HexAddr, HexAddr32 } from "lib/types"; import { zHexAddr } from "lib/types"; import { parseWithError } from "lib/utils"; -import { getMoveViewJsonLcd } from "../move/module/lcd"; +import { getMoveViewJsonRest } from "../move/module/rest"; -const INITIATION_2_LCD = "https://rest.initiation-2.initia.xyz"; +const INITIATION_2_REST = "https://rest.initiation-2.initia.xyz"; const USERNAME_MODULE_ADDRESS = "0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a" as HexAddr32; export const getInitiaUsernameByAddress = async (address: HexAddr) => - getMoveViewJsonLcd( - INITIATION_2_LCD, + getMoveViewJsonRest( + INITIATION_2_REST, USERNAME_MODULE_ADDRESS, "usernames", "get_name_from_address", @@ -18,8 +18,8 @@ export const getInitiaUsernameByAddress = async (address: HexAddr) => ).then((data) => (data ? `${data}.init` : null)); export const getAddressByInitiaUsername = async (username: string) => - getMoveViewJsonLcd( - INITIATION_2_LCD, + getMoveViewJsonRest( + INITIATION_2_REST, USERNAME_MODULE_ADDRESS, "usernames", "get_address_from_name", diff --git a/src/lib/services/validator/index.ts b/src/lib/services/validator/index.ts index b862a281b..13ea44566 100644 --- a/src/lib/services/validator/index.ts +++ b/src/lib/services/validator/index.ts @@ -32,13 +32,13 @@ import { getValidatorVotedProposals, getValidatorVotedProposalsAnswerCounts, } from "./api"; -import { - getValidatorDataLcd, - getValidatorDelegatorsLcd, - getValidatorsLcd, - getValidatorStakingProvisionsLcd, -} from "./lcd"; import { resolveValIdentity } from "./misc"; +import { + getValidatorDataRest, + getValidatorDelegatorsRest, + getValidatorsRest, + getValidatorStakingProvisionsRest, +} from "./rest"; import type { BlocksResponse, StakingProvisionsResponse, @@ -82,16 +82,16 @@ export const useValidators = ( ); }; -export const useValidatorsLcd = (enabled = true) => { +export const useValidatorsRest = (enabled = true) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); return useQuery( - [CELATONE_QUERY_KEYS.VALIDATORS_LCD, lcdEndpoint], + [CELATONE_QUERY_KEYS.VALIDATORS_REST, restEndpoint], async () => { - const res = await getValidatorsLcd(lcdEndpoint); + const res = await getValidatorsRest(restEndpoint); return res.map((val) => ({ ...val, consensusAddress: convertConsensusPubkeyToConsensusAddr( @@ -125,19 +125,19 @@ export const useValidatorData = ( ); }; -export const useValidatorDataLcd = ( +export const useValidatorDataRest = ( validatorAddr: ValidatorAddr, enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const { bech32Prefix } = useCurrentChain(); return useQuery( - [CELATONE_QUERY_KEYS.VALIDATOR_DATA_LCD, lcdEndpoint, validatorAddr], + [CELATONE_QUERY_KEYS.VALIDATOR_DATA_REST, restEndpoint, validatorAddr], async () => { - const res = await getValidatorDataLcd(lcdEndpoint, validatorAddr); + const res = await getValidatorDataRest(restEndpoint, validatorAddr); return { ...res, consensusAddress: convertConsensusPubkeyToConsensusAddr( @@ -158,9 +158,9 @@ export const useValidatorStakingProvisions = (enabled: boolean) => { const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("validators"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; + const endpoint = isFullTier ? apiEndpoint : restEndpoint; const { chainConfig: { chain }, @@ -171,7 +171,7 @@ export const useValidatorStakingProvisions = (enabled: boolean) => { async () => isFullTier ? getValidatorStakingProvisions(endpoint) - : getValidatorStakingProvisionsLcd(endpoint, chain), + : getValidatorStakingProvisionsRest(endpoint, chain), { enabled, retry: 1, @@ -182,16 +182,16 @@ export const useValidatorStakingProvisions = (enabled: boolean) => { export const useValidatorDelegators = (validatorAddress: ValidatorAddr) => { const isInitia = useInitia(); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); const queryFn = async () => - getValidatorDelegatorsLcd(lcdEndpoint, validatorAddress, isInitia); + getValidatorDelegatorsRest(restEndpoint, validatorAddress, isInitia); return useQuery( [ CELATONE_QUERY_KEYS.VALIDATOR_DELEGATORS, - lcdEndpoint, + restEndpoint, validatorAddress, isInitia, ], diff --git a/src/lib/services/validator/lcd.ts b/src/lib/services/validator/rest.ts similarity index 76% rename from src/lib/services/validator/lcd.ts rename to src/lib/services/validator/rest.ts index 74a063969..f9b323b8c 100644 --- a/src/lib/services/validator/lcd.ts +++ b/src/lib/services/validator/rest.ts @@ -2,32 +2,32 @@ import axios from "axios"; import type { ValidatorDelegatorsResponse, - ValidatorInfoLcd, + ValidatorInfoRest, } from "lib/services/types"; import { zValidatorDelegatorsResponse, - zValidatorResponseLcd, - zValidatorsResponseLcd, + zValidatorResponseRest, + zValidatorsResponseRest, } from "lib/services/types"; import { big } from "lib/types"; import type { Nullable, ValidatorAddr } from "lib/types"; import { parseWithError } from "lib/utils"; import { - getAnnualProvisionsLcd, - getDistributionParamsLcd, - getEpochProvisionsLcd, - getMintParamsLcd, -} from "../staking/lcd"; + getAnnualProvisionsRest, + getDistributionParamsRest, + getEpochProvisionsRest, + getMintParamsRest, +} from "../staking/rest"; -export const getValidatorsLcd = async (endpoint: string) => { - const result: ValidatorInfoLcd[] = []; +export const getValidatorsRest = async (endpoint: string) => { + const result: ValidatorInfoRest[] = []; const fetchFn = async (paginationKey: Nullable) => { const res = await axios .get(`${endpoint}/cosmos/staking/v1beta1/validators`, { params: { "pagination.key": paginationKey, "pagination.limit": "1000" }, }) - .then(({ data }) => parseWithError(zValidatorsResponseLcd, data)); + .then(({ data }) => parseWithError(zValidatorsResponseRest, data)); result.push(...res.validators); if (res.pagination.nextKey) await fetchFn(res.pagination.nextKey); }; @@ -37,7 +37,7 @@ export const getValidatorsLcd = async (endpoint: string) => { return result; }; -export const getValidatorDataLcd = ( +export const getValidatorDataRest = ( endpoint: string, validatorAddr: ValidatorAddr ) => @@ -45,16 +45,16 @@ export const getValidatorDataLcd = ( .get( `${endpoint}/cosmos/staking/v1beta1/validators/${encodeURI(validatorAddr)}` ) - .then(({ data }) => parseWithError(zValidatorResponseLcd, data).validator); + .then(({ data }) => parseWithError(zValidatorResponseRest, data).validator); -export const getValidatorStakingProvisionsLcd = async ( +export const getValidatorStakingProvisionsRest = async ( endpoint: string, chain: string ) => { if (chain === "osmosis") { const [mintParams, epochProvisions] = await Promise.all([ - getMintParamsLcd(endpoint, chain), - getEpochProvisionsLcd(endpoint, chain), + getMintParamsRest(endpoint, chain), + getEpochProvisionsRest(endpoint, chain), ]); const stakingProportion = @@ -80,8 +80,8 @@ export const getValidatorStakingProvisionsLcd = async ( } const [distParams, annualProvisions] = await Promise.all([ - getDistributionParamsLcd(endpoint), - getAnnualProvisionsLcd(endpoint, chain), + getDistributionParamsRest(endpoint), + getAnnualProvisionsRest(endpoint, chain), ]); const stakingProvisions = annualProvisions.annualProvisions.mul( @@ -91,7 +91,7 @@ export const getValidatorStakingProvisionsLcd = async ( return { stakingProvisions }; }; -export const getValidatorDelegatorsLcd = async ( +export const getValidatorDelegatorsRest = async ( endpoint: string, validatorAddress: ValidatorAddr, isInitia: boolean diff --git a/src/lib/services/wasm/code/index.ts b/src/lib/services/wasm/code/index.ts index 3167166d5..5b4265ba5 100644 --- a/src/lib/services/wasm/code/index.ts +++ b/src/lib/services/wasm/code/index.ts @@ -17,16 +17,16 @@ import { getCodes, getCodesByAddress, } from "./api"; -import { getCodeLcd, getCodesLcd, getUploadAccessParamsLcd } from "./lcd"; +import { getCodeRest, getCodesRest, getUploadAccessParamsRest } from "./rest"; -export const useUploadAccessParamsLcd = () => { +export const useUploadAccessParamsRest = () => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.UPLOAD_ACCESS_PARAMS_LCD, lcdEndpoint], - () => getUploadAccessParamsLcd(lcdEndpoint), + [CELATONE_QUERY_KEYS.UPLOAD_ACCESS_PARAMS_REST, restEndpoint], + () => getUploadAccessParamsRest(restEndpoint), { keepPreviousData: true, refetchOnWindowFocus: false, retry: false } ); }; @@ -47,14 +47,14 @@ export const useCodes = ( ); }; -export const useCodesLcd = () => { +export const useCodesRest = () => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useInfiniteQuery( - [CELATONE_QUERY_KEYS.CODES_LCD, lcdEndpoint], - ({ pageParam }) => getCodesLcd(lcdEndpoint, pageParam), + [CELATONE_QUERY_KEYS.CODES_REST, restEndpoint], + ({ pageParam }) => getCodesRest(restEndpoint, pageParam), { getNextPageParam: (lastPage) => lastPage.pagination.nextKey ?? undefined, refetchOnWindowFocus: false, @@ -77,17 +77,17 @@ export const useCodeData = (codeId: number, enabled = true) => { ); }; -export const useCodeLcd = ( +export const useCodeRest = ( codeId: number, options?: Omit, "queryKey"> ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.CODE_DATA_LCD, lcdEndpoint, codeId], - async () => getCodeLcd(lcdEndpoint, codeId), + [CELATONE_QUERY_KEYS.CODE_DATA_REST, restEndpoint, codeId], + async () => getCodeRest(restEndpoint, codeId), { retry: 1, refetchOnWindowFocus: false, @@ -138,4 +138,4 @@ export const useCodeList = (codeIds: number[]) => { ); }; -export * from "./lcd"; +export * from "./rest"; diff --git a/src/lib/services/wasm/code/lcd.ts b/src/lib/services/wasm/code/rest.ts similarity index 52% rename from src/lib/services/wasm/code/lcd.ts rename to src/lib/services/wasm/code/rest.ts index acf45e724..69b7deafe 100644 --- a/src/lib/services/wasm/code/lcd.ts +++ b/src/lib/services/wasm/code/rest.ts @@ -2,28 +2,28 @@ import axios from "axios"; import type { UploadAccessParams } from "lib/services/types"; import { - zCodeInfoResponseLcd, - zCodesResponseLcd, - zUploadAccessParamsLcd, - zUploadAccessParamsSubspaceLcd, + zCodeInfoResponseRest, + zCodesResponseRest, + zUploadAccessParamsRest, + zUploadAccessParamsSubspaceRest, } from "lib/services/types"; import type { Option } from "lib/types"; import { parseWithError } from "lib/utils"; -export const getUploadAccessParamsLcd = async ( - lcdEndpoint: string +export const getUploadAccessParamsRest = async ( + restEndpoint: string ): Promise => { - const res = await axios.get(`${lcdEndpoint}/cosmwasm/wasm/v1/codes/params`); - const validated = zUploadAccessParamsLcd.safeParse(res.data); + const res = await axios.get(`${restEndpoint}/cosmwasm/wasm/v1/codes/params`); + const validated = zUploadAccessParamsRest.safeParse(res.data); if (res.status === 200 && validated.success) return validated.data; - const res2 = await axios.get(`${lcdEndpoint}/wasm/v1beta1/params`); - const validated2 = zUploadAccessParamsSubspaceLcd.safeParse(res2.data); + const res2 = await axios.get(`${restEndpoint}/wasm/v1beta1/params`); + const validated2 = zUploadAccessParamsSubspaceRest.safeParse(res2.data); if (res2.status === 200 && validated2.success) return validated2.data; throw new Error("Failed to fetch upload access params"); }; -export const getCodesLcd = async ( +export const getCodesRest = async ( endpoint: string, paginationKey: Option ) => @@ -35,9 +35,9 @@ export const getCodesLcd = async ( "pagination.key": paginationKey, }, }) - .then(({ data }) => parseWithError(zCodesResponseLcd, data)); + .then(({ data }) => parseWithError(zCodesResponseRest, data)); -export const getCodeLcd = async (endpoint: string, codeId: number) => +export const getCodeRest = async (endpoint: string, codeId: number) => axios .get(`${endpoint}/cosmwasm/wasm/v1/code/${encodeURIComponent(codeId)}`) - .then(({ data }) => parseWithError(zCodeInfoResponseLcd, data)); + .then(({ data }) => parseWithError(zCodeInfoResponseRest, data)); diff --git a/src/lib/services/wasm/contract/index.ts b/src/lib/services/wasm/contract/index.ts index 96b1097bf..535604b98 100644 --- a/src/lib/services/wasm/contract/index.ts +++ b/src/lib/services/wasm/contract/index.ts @@ -35,14 +35,14 @@ import { getMigrationHistoriesByContractAddress, } from "./api"; import { - getContractCw2InfoLcd, - getContractLcd, - getContractQueryLcd, - getContractQueryMsgsLcd, - getContractsByCodeIdLcd, - getInstantiatedContractsByAddressLcd, - getMigrationHistoriesByContractAddressLcd, -} from "./lcd"; + getContractCw2InfoRest, + getContractQueryMsgsRest, + getContractQueryRest, + getContractRest, + getContractsByCodeIdRest, + getInstantiatedContractsByAddressRest, + getMigrationHistoriesByContractAddressRest, +} from "./rest"; export const useContracts = ( limit: number, @@ -92,22 +92,22 @@ export const useMigrationHistoriesByContractAddress = ( ); }; -export const useMigrationHistoriesByContractAddressLcd = ( +export const useMigrationHistoriesByContractAddressRest = ( contractAddress: BechAddr32, enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ - CELATONE_QUERY_KEYS.CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_REST, + restEndpoint, contractAddress, ], async () => - getMigrationHistoriesByContractAddressLcd(lcdEndpoint, contractAddress), + getMigrationHistoriesByContractAddressRest(restEndpoint, contractAddress), { retry: 1, keepPreviousData: true, @@ -208,9 +208,9 @@ export const useContractData = ( const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("contracts"); const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); - const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; + const endpoint = isFullTier ? apiEndpoint : restEndpoint; const { enabled: isGov } = useGovConfig({ shouldRedirect: false }); return useQuery( @@ -218,7 +218,7 @@ export const useContractData = ( async () => isFullTier ? getContractData(endpoint, contractAddress, isGov) - : getContractLcd(endpoint, contractAddress), + : getContractRest(endpoint, contractAddress), { retry: 1, refetchOnWindowFocus: false, ...options } ); }; @@ -242,14 +242,14 @@ export const useContractTableCounts = ( ); }; -export const useContractQueryMsgsLcd = (contractAddress: BechAddr32) => { +export const useContractQueryMsgsRest = (contractAddress: BechAddr32) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.CONTRACT_QUERY_MSGS, lcdEndpoint, contractAddress], - async () => getContractQueryMsgsLcd(lcdEndpoint, contractAddress), + [CELATONE_QUERY_KEYS.CONTRACT_QUERY_MSGS, restEndpoint, contractAddress], + async () => getContractQueryMsgsRest(restEndpoint, contractAddress), { enabled: !!contractAddress, retry: false, @@ -278,14 +278,15 @@ export const useContractsByCodeId = ( ); }; -export const useContractsByCodeIdLcd = (codeId: number) => { +export const useContractsByCodeIdRest = (codeId: number) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useInfiniteQuery( - [CELATONE_QUERY_KEYS.CONTRACTS_BY_CODE_ID_LCD, lcdEndpoint, codeId], - ({ pageParam }) => getContractsByCodeIdLcd(lcdEndpoint, codeId, pageParam), + [CELATONE_QUERY_KEYS.CONTRACTS_BY_CODE_ID_REST, restEndpoint, codeId], + ({ pageParam }) => + getContractsByCodeIdRest(restEndpoint, codeId, pageParam), { getNextPageParam: (lastPage) => lastPage.pagination.nextKey ?? undefined, refetchOnWindowFocus: false, @@ -293,18 +294,23 @@ export const useContractsByCodeIdLcd = (codeId: number) => { ); }; -export const useContractQueryLcd = ( +export const useContractQueryRest = ( contractAddress: BechAddr32, msg: string, options: UseQueryOptions ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.CONTRACT_QUERY_LCD, lcdEndpoint, contractAddress, msg], - async () => getContractQueryLcd(lcdEndpoint, contractAddress, msg), + [ + CELATONE_QUERY_KEYS.CONTRACT_QUERY_REST, + restEndpoint, + contractAddress, + msg, + ], + async () => getContractQueryRest(restEndpoint, contractAddress, msg), { retry: 1, refetchOnWindowFocus: false, @@ -313,42 +319,42 @@ export const useContractQueryLcd = ( ); }; -export const useInstantiatedContractsByAddressLcd = ( +export const useInstantiatedContractsByAddressRest = ( address: Option, enabled = false ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( [ - CELATONE_QUERY_KEYS.INSTANTIATED_CONTRACTS_BY_ADDRESS_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.INSTANTIATED_CONTRACTS_BY_ADDRESS_REST, + restEndpoint, address, ], async () => { if (!address) throw new Error( - "address not found (getInstantiatedContractsByAddressLcd)" + "address not found (getInstantiatedContractsByAddressRest)" ); - return getInstantiatedContractsByAddressLcd(lcdEndpoint, address); + return getInstantiatedContractsByAddressRest(restEndpoint, address); }, { enabled: Boolean(address) && enabled, refetchOnWindowFocus: false } ); }; -export const useContractCw2InfoLcd = ( +export const useContractCw2InfoRest = ( contractAddress: BechAddr32, enabled = true ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useQuery( - [CELATONE_QUERY_KEYS.CONTRACT_CW2_INFO_LCD, lcdEndpoint, contractAddress], - async () => getContractCw2InfoLcd(lcdEndpoint, contractAddress), + [CELATONE_QUERY_KEYS.CONTRACT_CW2_INFO_REST, restEndpoint, contractAddress], + async () => getContractCw2InfoRest(restEndpoint, contractAddress), { retry: 1, refetchOnWindowFocus: false, enabled } ); }; diff --git a/src/lib/services/wasm/contract/lcd.ts b/src/lib/services/wasm/contract/rest.ts similarity index 75% rename from src/lib/services/wasm/contract/lcd.ts rename to src/lib/services/wasm/contract/rest.ts index 56faf3ec5..e14edb94e 100644 --- a/src/lib/services/wasm/contract/lcd.ts +++ b/src/lib/services/wasm/contract/rest.ts @@ -1,17 +1,17 @@ import axios from "axios"; import type { - ContractCw2InfoLcd, - MigrationHistoriesResponseItemLcd, - MigrationHistoriesResponseLcd, + ContractCw2InfoRest, + MigrationHistoriesResponseItemRest, + MigrationHistoriesResponseRest, } from "lib/services/types"; import { - zContractCw2InfoLcd, - zContractLcd, + zContractCw2InfoRest, zContractQueryMsgs, - zContractsResponseLcd, - zInstantiatedContractsLcd, - zMigrationHistoriesResponseLcd, + zContractRest, + zContractsResponseRest, + zInstantiatedContractsRest, + zMigrationHistoriesResponseRest, } from "lib/services/types"; import type { ContractLocalInfo } from "lib/stores/contract"; import type { @@ -23,7 +23,7 @@ import type { } from "lib/types"; import { encode, libEncode, parseWithError } from "lib/utils"; -export const getContractQueryLcd = ( +export const getContractQueryRest = ( endpoint: string, contractAddress: BechAddr32, msg: string @@ -34,12 +34,15 @@ export const getContractQueryLcd = ( ) .then(({ data }) => data); -export const getContractLcd = (endpoint: string, contractAddress: BechAddr32) => +export const getContractRest = ( + endpoint: string, + contractAddress: BechAddr32 +) => axios( `${endpoint}/cosmwasm/wasm/v1/contract/${encodeURI(contractAddress)}` - ).then(({ data }) => parseWithError(zContractLcd, data)); + ).then(({ data }) => parseWithError(zContractRest, data)); -export const getContractsByCodeIdLcd = ( +export const getContractsByCodeIdRest = ( endpoint: string, codeId: number, paginationKey: Option @@ -55,9 +58,9 @@ export const getContractsByCodeIdLcd = ( }, } ) - .then(({ data }) => parseWithError(zContractsResponseLcd, data)); + .then(({ data }) => parseWithError(zContractsResponseRest, data)); -export const getContractQueryMsgsLcd = async ( +export const getContractQueryMsgsRest = async ( endpoint: string, contractAddress: BechAddr32 ) => { @@ -92,11 +95,11 @@ export const getContractQueryMsgsLcd = async ( return parseWithError(zContractQueryMsgs, data); }; -export const getMigrationHistoriesByContractAddressLcd = async ( +export const getMigrationHistoriesByContractAddressRest = async ( endpoint: string, contractAddress: BechAddr32 -): Promise => { - const entries: MigrationHistoriesResponseItemLcd[] = []; +): Promise => { + const entries: MigrationHistoriesResponseItemRest[] = []; const fetchFn = async (paginationKey: Nullable) => { const res = await axios @@ -109,7 +112,9 @@ export const getMigrationHistoriesByContractAddressLcd = async ( }, } ) - .then(({ data }) => parseWithError(zMigrationHistoriesResponseLcd, data)); + .then(({ data }) => + parseWithError(zMigrationHistoriesResponseRest, data) + ); entries.push(...res.entries); @@ -127,7 +132,7 @@ export const getMigrationHistoriesByContractAddressLcd = async ( }; }; -export const getInstantiatedContractsByAddressLcd = ( +export const getInstantiatedContractsByAddressRest = ( endpoint: string, address: BechAddr ) => @@ -142,7 +147,7 @@ export const getInstantiatedContractsByAddressLcd = ( ) .then(({ data }) => { const { contractAddresses } = parseWithError( - zInstantiatedContractsLcd, + zInstantiatedContractsRest, data ); @@ -153,12 +158,12 @@ export const getInstantiatedContractsByAddressLcd = ( })); }); -export const getContractCw2InfoLcd = async ( +export const getContractCw2InfoRest = async ( endpoint: string, contractAddress: BechAddr32 -): Promise => +): Promise => axios .get( `${endpoint}/cosmwasm/wasm/v1/contract/${encodeURI(contractAddress)}/raw/Y29udHJhY3RfaW5mbw%3D%3D` ) - .then(({ data }) => parseWithError(zContractCw2InfoLcd, data)); + .then(({ data }) => parseWithError(zContractCw2InfoRest, data)); diff --git a/src/lib/services/wasm/contractState/index.ts b/src/lib/services/wasm/contractState/index.ts index 46a52e098..55c33f62c 100644 --- a/src/lib/services/wasm/contractState/index.ts +++ b/src/lib/services/wasm/contractState/index.ts @@ -3,26 +3,26 @@ import { useInfiniteQuery } from "@tanstack/react-query"; import { CELATONE_QUERY_KEYS, useCelatoneApp } from "lib/app-provider"; import type { BechAddr32 } from "lib/types"; -import { getContractStatesLcd } from "./lcd"; +import { getContractStatesRest } from "./rest"; -export const useContractStatesLcd = ( +export const useContractStatesRest = ( contractAddress: BechAddr32, numStatesToLoad: number ) => { const { - chainConfig: { lcd: lcdEndpoint }, + chainConfig: { rest: restEndpoint }, } = useCelatoneApp(); return useInfiniteQuery( [ - CELATONE_QUERY_KEYS.CONTRACT_STATES_LCD, - lcdEndpoint, + CELATONE_QUERY_KEYS.CONTRACT_STATES_REST, + restEndpoint, contractAddress, numStatesToLoad, ], ({ pageParam }) => - getContractStatesLcd( - lcdEndpoint, + getContractStatesRest( + restEndpoint, contractAddress, numStatesToLoad, pageParam diff --git a/src/lib/services/wasm/contractState/lcd.ts b/src/lib/services/wasm/contractState/rest.ts similarity index 95% rename from src/lib/services/wasm/contractState/lcd.ts rename to src/lib/services/wasm/contractState/rest.ts index cd84093a4..bbe49c444 100644 --- a/src/lib/services/wasm/contractState/lcd.ts +++ b/src/lib/services/wasm/contractState/rest.ts @@ -9,7 +9,7 @@ import { parseWithError, } from "lib/utils"; -export const getContractStatesLcd = async ( +export const getContractStatesRest = async ( endpoint: string, contractAddress: BechAddr32, limit: number, diff --git a/src/lib/stores/chain-config.test.ts b/src/lib/stores/chain-config.test.ts index 90370d140..2f31e99d0 100644 --- a/src/lib/stores/chain-config.test.ts +++ b/src/lib/stores/chain-config.test.ts @@ -9,7 +9,7 @@ const MOCK_CONFIG: ChainConfig = { registryChainName: "testonly", prettyName: "Test Only", rpc: "https://rpc.testonly.com", - lcd: "https://rpc.testonly.com", + rest: "https://rpc.testonly.com", wallets: ["keplr", "initia", "compass", "station"], features: { wasm: { enabled: false }, diff --git a/src/lib/types/account.ts b/src/lib/types/account.ts index 0880e3931..130ddaae4 100644 --- a/src/lib/types/account.ts +++ b/src/lib/types/account.ts @@ -15,7 +15,7 @@ export enum AccountType { BaseVestingAccount = "BaseVestingAccount", } -export enum AccountTypeLcd { +export enum AccountTypeRest { BaseAccount = "/cosmos.auth.v1beta1.BaseAccount", ModuleAccount = "/cosmos.auth.v1beta1.ModuleAccount", } diff --git a/src/lib/types/chainConfig.ts b/src/lib/types/chainConfig.ts index 54fe4f316..5555c2076 100644 --- a/src/lib/types/chainConfig.ts +++ b/src/lib/types/chainConfig.ts @@ -199,7 +199,7 @@ export const zChainConfig = z registryChainName: z.string().trim(), prettyName: z.string().trim(), rpc: zHttpsUrl, - lcd: zHttpsUrl, + rest: zHttpsUrl, mesa: zHttpsUrl.optional(), wallets: z.array( z.union([