diff --git a/.pnp.cjs b/.pnp.cjs index 9dda6eb..5b8c9aa 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -331,7 +331,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ [\ "axios",\ - "npm:0.27.2"\ + "npm:1.2.2"\ ],\ [\ "axobject-query",\ @@ -679,7 +679,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ [\ "follow-redirects",\ - "virtual:dbe3a48aea1dd5649e16abaf23d4ae05582d2149e16141955113766a0f84f681baf358c77ddccfc82eb23e4ccc66c6c912df62a9c01f2a83f1842bf86cc297b1#npm:1.15.2"\ + "virtual:151da260f043de3d749a8f50d94ea39c8fdee423844c248b45c294861d204ee8a26e55a007a999b1acda99c567c41f066b092a55a55bd7e6d602c6c55fba680b#npm:1.15.2"\ ],\ [\ "form-data",\ @@ -1189,6 +1189,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "prop-types",\ "npm:15.8.1"\ ],\ + [\ + "proxy-from-env",\ + "npm:1.1.0"\ + ],\ [\ "punycode",\ "npm:2.1.1"\ @@ -1595,7 +1599,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@many-things/cosmos-query", "workspace:packages/core"],\ ["@types/qs", "npm:6.9.7"],\ - ["axios", "npm:0.27.2"],\ + ["axios", "npm:1.2.2"],\ ["buffer", "npm:6.0.3"],\ ["qs", "npm:6.11.0"],\ ["typescript", "patch:typescript@npm%3A4.8.3#~builtin::version=4.8.3&hash=a1c5e5"],\ @@ -2235,9 +2239,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/node", "npm:18.7.14"],\ ["@types/react", "npm:18.0.18"],\ ["@types/react-dom", "npm:18.0.6"],\ + ["axios", "npm:1.2.2"],\ ["eslint", "npm:8.23.0"],\ ["eslint-config-next", "virtual:8c5004c4f3557c80514cda75e97d6e6db14d633f9486d0c16a5c0f31498615eb1896596c4508deff446d8f8d531e1f219a50a8db91debfd4af35e85134ab6248#npm:12.2.5"],\ ["next", "virtual:8c5004c4f3557c80514cda75e97d6e6db14d633f9486d0c16a5c0f31498615eb1896596c4508deff446d8f8d531e1f219a50a8db91debfd4af35e85134ab6248#npm:12.2.5"],\ + ["qs", "npm:6.11.0"],\ ["react", "npm:18.2.0"],\ ["react-dom", "virtual:8c5004c4f3557c80514cda75e97d6e6db14d633f9486d0c16a5c0f31498615eb1896596c4508deff446d8f8d531e1f219a50a8db91debfd4af35e85134ab6248#npm:18.2.0"],\ ["typescript", "patch:typescript@npm%3A4.8.2#~builtin::version=4.8.2&hash=a1c5e5"]\ @@ -2370,12 +2376,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["axios", [\ - ["npm:0.27.2", {\ - "packageLocation": "./.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/",\ + ["npm:1.2.2", {\ + "packageLocation": "./.yarn/cache/axios-npm-1.2.2-151da260f0-6e357491b3.zip/node_modules/axios/",\ "packageDependencies": [\ - ["axios", "npm:0.27.2"],\ - ["follow-redirects", "virtual:dbe3a48aea1dd5649e16abaf23d4ae05582d2149e16141955113766a0f84f681baf358c77ddccfc82eb23e4ccc66c6c912df62a9c01f2a83f1842bf86cc297b1#npm:1.15.2"],\ - ["form-data", "npm:4.0.0"]\ + ["axios", "npm:1.2.2"],\ + ["follow-redirects", "virtual:151da260f043de3d749a8f50d94ea39c8fdee423844c248b45c294861d204ee8a26e55a007a999b1acda99c567c41f066b092a55a55bd7e6d602c6c55fba680b#npm:1.15.2"],\ + ["form-data", "npm:4.0.0"],\ + ["proxy-from-env", "npm:1.1.0"]\ ],\ "linkType": "HARD"\ }]\ @@ -3628,10 +3635,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ "linkType": "SOFT"\ }],\ - ["virtual:dbe3a48aea1dd5649e16abaf23d4ae05582d2149e16141955113766a0f84f681baf358c77ddccfc82eb23e4ccc66c6c912df62a9c01f2a83f1842bf86cc297b1#npm:1.15.2", {\ - "packageLocation": "./.yarn/__virtual__/follow-redirects-virtual-42073a9d6a/0/cache/follow-redirects-npm-1.15.2-1ec1dd82be-faa66059b6.zip/node_modules/follow-redirects/",\ + ["virtual:151da260f043de3d749a8f50d94ea39c8fdee423844c248b45c294861d204ee8a26e55a007a999b1acda99c567c41f066b092a55a55bd7e6d602c6c55fba680b#npm:1.15.2", {\ + "packageLocation": "./.yarn/__virtual__/follow-redirects-virtual-002d16d4e1/0/cache/follow-redirects-npm-1.15.2-1ec1dd82be-faa66059b6.zip/node_modules/follow-redirects/",\ "packageDependencies": [\ - ["follow-redirects", "virtual:dbe3a48aea1dd5649e16abaf23d4ae05582d2149e16141955113766a0f84f681baf358c77ddccfc82eb23e4ccc66c6c912df62a9c01f2a83f1842bf86cc297b1#npm:1.15.2"],\ + ["follow-redirects", "virtual:151da260f043de3d749a8f50d94ea39c8fdee423844c248b45c294861d204ee8a26e55a007a999b1acda99c567c41f066b092a55a55bd7e6d602c6c55fba680b#npm:1.15.2"],\ ["@types/debug", null],\ ["debug", null]\ ],\ @@ -5097,6 +5104,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["proxy-from-env", [\ + ["npm:1.1.0", {\ + "packageLocation": "./.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip/node_modules/proxy-from-env/",\ + "packageDependencies": [\ + ["proxy-from-env", "npm:1.1.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["punycode", [\ ["npm:2.1.1", {\ "packageLocation": "./.yarn/cache/punycode-npm-2.1.1-26eb3e15cf-823bf443c6.zip/node_modules/punycode/",\ diff --git a/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip b/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip deleted file mode 100644 index 601f769..0000000 Binary files a/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip and /dev/null differ diff --git a/.yarn/cache/axios-npm-1.2.2-151da260f0-6e357491b3.zip b/.yarn/cache/axios-npm-1.2.2-151da260f0-6e357491b3.zip new file mode 100644 index 0000000..f631e89 Binary files /dev/null and b/.yarn/cache/axios-npm-1.2.2-151da260f0-6e357491b3.zip differ diff --git a/.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip b/.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip new file mode 100644 index 0000000..a58e6bf Binary files /dev/null and b/.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip differ diff --git a/examples/application/package.json b/examples/application/package.json index 465d68f..318e83c 100644 --- a/examples/application/package.json +++ b/examples/application/package.json @@ -10,7 +10,9 @@ }, "dependencies": { "@many-things/cosmos-query": "*", + "axios": "^1.2.2", "next": "12.2.5", + "qs": "^6.11.0", "react": "18.2.0", "react-dom": "18.2.0" }, diff --git a/examples/application/pages/index.tsx b/examples/application/pages/index.tsx index b0a9b82..06dbb9e 100644 --- a/examples/application/pages/index.tsx +++ b/examples/application/pages/index.tsx @@ -1,6 +1,8 @@ import type { NextPage } from "next"; import { useEffect } from "react"; import { getCosmosQuery } from "@many-things/cosmos-query"; +import axios, { ParamsSerializerOptions } from "axios"; +import { stringify } from "qs"; const lcdList = { ["cosmoshub-4"]: "https://lcd-cosmoshub.blockapsis.com", @@ -27,9 +29,18 @@ const lcdList = { }; const Home: NextPage = () => { - const { getAccounts } = getCosmosQuery(lcdList["osmosis-1"]); + const client = axios.create({ + baseURL: lcdList["osmosis-1"], + paramsSerializer: { + serialize: (params: Record) => { + return stringify(params, { allowDots: true }); + }, + }, + }); + const { getAccounts } = getCosmosQuery(client); useEffect(() => { + console.info("-----test--00------"); (async () => { const a = await getAccounts({ pagination: { diff --git a/packages/core/package.json b/packages/core/package.json index a2a97ff..99ee7f4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -34,7 +34,7 @@ "vite-plugin-dts": "^1.4.1" }, "dependencies": { - "axios": "^0.27.2", + "axios": "^1.2.2", "buffer": "^6.0.3", "qs": "^6.11.0" } diff --git a/packages/core/src/apis/cosmos/auth/index.ts b/packages/core/src/apis/cosmos/auth/index.ts index 7327746..ccfcc0d 100644 --- a/packages/core/src/apis/cosmos/auth/index.ts +++ b/packages/core/src/apis/cosmos/auth/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { AccountResponse, @@ -9,28 +9,27 @@ import type { export type { AccountResponse, AccountsResponse, AuthParamsResponse }; export const getAccounts = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/auth/v1beta1/accounts", { + await instance.get("/cosmos/auth/v1beta1/accounts", { params: { pagination }, }) ).data; }; export const getAccountByAddress = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address }: { address: string }): Promise => { - return ( - await instance(baseURL).get(`/cosmos/auth/v1beta1/accounts/${address}`) - ).data; + return (await instance.get(`/cosmos/auth/v1beta1/accounts/${address}`)) + .data; }; export const getAuthParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/auth/v1beta1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/auth/v1beta1/params")).data; }; diff --git a/packages/core/src/apis/cosmos/authz/index.ts b/packages/core/src/apis/cosmos/authz/index.ts index b426afe..674078b 100644 --- a/packages/core/src/apis/cosmos/authz/index.ts +++ b/packages/core/src/apis/cosmos/authz/index.ts @@ -1,11 +1,11 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { GrantsResponse } from "./types"; export type { GrantsResponse }; export const getGrants = - (baseURL: string) => + (instance: AxiosInstance) => async ({ granter, grantee, @@ -18,7 +18,7 @@ export const getGrants = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/authz/v1beta1/grants", { + await instance.get("/cosmos/authz/v1beta1/grants", { params: { granter, grantee, diff --git a/packages/core/src/apis/cosmos/bank/index.ts b/packages/core/src/apis/cosmos/bank/index.ts index f7fd91e..519aa0e 100644 --- a/packages/core/src/apis/cosmos/bank/index.ts +++ b/packages/core/src/apis/cosmos/bank/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { AllBalancesResponse, @@ -23,7 +23,7 @@ export type { }; export const getAllBalances = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address, pagination, @@ -32,14 +32,14 @@ export const getAllBalances = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get(`/cosmos/bank/v1beta1/balances/${address}`, { + await instance.get(`/cosmos/bank/v1beta1/balances/${address}`, { params: { pagination }, }) ).data; }; export const getBalance = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address, denom, @@ -48,14 +48,12 @@ export const getBalance = denom: string; }): Promise => { return ( - await instance(baseURL).get( - `/cosmos/bank/v1beta1/balances/${address}/${denom}` - ) + await instance.get(`/cosmos/bank/v1beta1/balances/${address}/${denom}`) ).data; }; export const getDenomOwners = - (baseURL: string) => + (instance: AxiosInstance) => async ({ denom, pagination, @@ -64,61 +62,54 @@ export const getDenomOwners = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( - `/cosmos/bank/v1beta1/denom_owners/${denom}`, - { - params: { pagination }, - } - ) + await instance.get(`/cosmos/bank/v1beta1/denom_owners/${denom}`, { + params: { pagination }, + }) ).data; }; export const getAllDenomsMetadata = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/bank/v1beta1/denoms_metadata", { + await instance.get("/cosmos/bank/v1beta1/denoms_metadata", { params: { pagination }, }) ).data; }; export const getDenomMetadata = - (baseURL: string) => + (instance: AxiosInstance) => async ({ denom }: { denom: string }): Promise => { - return ( - await instance(baseURL).get( - `/cosmos/bank/v1beta1/denoms_metadata/${denom}` - ) - ).data; + return (await instance.get(`/cosmos/bank/v1beta1/denoms_metadata/${denom}`)) + .data; }; export const getBankParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/bank/v1beta1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/bank/v1beta1/params")).data; }; export const getTotalSupply = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/bank/v1beta1/supply", { + await instance.get("/cosmos/bank/v1beta1/supply", { params: { pagination }, }) ).data; }; export const getSupply = - (baseURL: string) => + (instance: AxiosInstance) => async ({ denom }: { denom: string }): Promise => { - return (await instance(baseURL).get(`/cosmos/bank/v1beta1/supply/${denom}`)) - .data; + return (await instance.get(`/cosmos/bank/v1beta1/supply/${denom}`)).data; }; diff --git a/packages/core/src/apis/cosmos/base/index.ts b/packages/core/src/apis/cosmos/base/index.ts index 7083dc6..bbfefcb 100644 --- a/packages/core/src/apis/cosmos/base/index.ts +++ b/packages/core/src/apis/cosmos/base/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { BlockResponse, @@ -15,47 +15,47 @@ export type { }; export const getLatestBlock = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => async (): Promise => { return ( - await instance(baseURL).get( + await instance.get( "/cosmos/base/tendermint/v1beta1/blocks/latest" ) ).data; }; export const getBlockByHeight = - (baseURL: string) => + (instance: AxiosInstance) => async ({ height }: { height: number }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/base/tendermint/v1beta1/blocks/${height.toString()}` ) ).data; }; export const getNodeInfo = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => async (): Promise => { return ( - await instance(baseURL).get("/cosmos/base/tendermint/v1beta1/node_info") + await instance.get("/cosmos/base/tendermint/v1beta1/node_info") ).data; }; export const getSyncing = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => async (): Promise => { return ( - await instance(baseURL).get("/cosmos/base/tendermint/v1beta1/syncing") + await instance.get("/cosmos/base/tendermint/v1beta1/syncing") ).data; }; export const getLatestValidatorSet = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( "/cosmos/base/tendermint/v1beta1/validatorsets/latest", { params: { pagination } } ) @@ -63,7 +63,7 @@ export const getLatestValidatorSet = }; export const getValidatorSetByHeight = - (baseURL: string) => + (instance: AxiosInstance) => async ({ height, pagination, @@ -72,7 +72,7 @@ export const getValidatorSetByHeight = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/base/tendermint/v1beta1/validatorsets/${height}`, { params: { pagination } } ) diff --git a/packages/core/src/apis/cosmos/distribution/index.ts b/packages/core/src/apis/cosmos/distribution/index.ts index 80e115a..c057102 100644 --- a/packages/core/src/apis/cosmos/distribution/index.ts +++ b/packages/core/src/apis/cosmos/distribution/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { CommunityPoolResponse, @@ -25,28 +25,27 @@ export type { }; export const getCommunityPool = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/cosmos/distribution/v1beta1/community_pool") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/distribution/v1beta1/community_pool")) + .data; }; export const getDelegationTotalRewards = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, }: { delegatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/delegators/${delegatorAddress}/rewards` ) ).data; }; export const getDelegationRewards = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, validatorAddress, @@ -55,76 +54,76 @@ export const getDelegationRewards = validatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/delegators/${delegatorAddress}/rewards/${validatorAddress}` ) ).data; }; export const getDelegatorValidatorAddresses = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, }: { delegatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/delegators/${delegatorAddress}/validators` ) ).data; }; export const getDelegatorWithdrawAddress = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, }: { delegatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/delegators/${delegatorAddress}/withdraw_address` ) ).data; }; export const getDistributionParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/distribution/v1beta1/params")) - .data; + (instance: AxiosInstance) => + async (): Promise => { + return (await instance.get("/cosmos/distribution/v1beta1/params")).data; }; export const getValidatorCommission = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, }: { validatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/validators/${validatorAddress}/commission` ) ).data; }; export const getValidatorOutstandingRewards = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, }: { validatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/validators/${validatorAddress}/outstanding_rewards` ) ).data; }; export const getValidatorSlashes = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, startingHeight, @@ -137,7 +136,7 @@ export const getValidatorSlashes = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/distribution/v1beta1/validators/${validatorAddress}/slashes`, { params: { diff --git a/packages/core/src/apis/cosmos/evidence/index.ts b/packages/core/src/apis/cosmos/evidence/index.ts index df4a695..20865a8 100644 --- a/packages/core/src/apis/cosmos/evidence/index.ts +++ b/packages/core/src/apis/cosmos/evidence/index.ts @@ -1,33 +1,31 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { AllEvidenceResponse, EvidenceResponse } from "./types"; export type { AllEvidenceResponse, EvidenceResponse }; export const getAllEvidence = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/evidence/v1beta1/evidence", { + await instance.get("/cosmos/evidence/v1beta1/evidence", { params: { pagination }, }) ).data; }; export const getEvidence = - (baseURL: string) => + (instance: AxiosInstance) => async ({ evidenceHash, }: { evidenceHash: string; }): Promise => { return ( - await instance(baseURL).get( - `/cosmos/evidence/v1beta1/evidence/${evidenceHash}` - ) + await instance.get(`/cosmos/evidence/v1beta1/evidence/${evidenceHash}`) ).data; }; diff --git a/packages/core/src/apis/cosmos/feegrant/index.ts b/packages/core/src/apis/cosmos/feegrant/index.ts index fc9b3e1..642db39 100644 --- a/packages/core/src/apis/cosmos/feegrant/index.ts +++ b/packages/core/src/apis/cosmos/feegrant/index.ts @@ -1,11 +1,11 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { AllowanceResponse, AllowancesResponse } from "./types"; export type { AllowanceResponse, AllowancesResponse }; export const getAllowances = - (baseURL: string) => + (instance: AxiosInstance) => async ({ grantee, pagination, @@ -14,7 +14,7 @@ export const getAllowances = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/feegrant/v1beta1/allowances/${grantee}`, { params: { pagination }, @@ -24,7 +24,7 @@ export const getAllowances = }; export const getAllowance = - (baseURL: string) => + (instance: AxiosInstance) => async ({ granter, grantee, @@ -33,7 +33,7 @@ export const getAllowance = grantee: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/feegrant/v1beta1/allowance/${granter}/${grantee}` ) ).data; diff --git a/packages/core/src/apis/cosmos/governance/index.ts b/packages/core/src/apis/cosmos/governance/index.ts index f0750ca..ac00ac1 100644 --- a/packages/core/src/apis/cosmos/governance/index.ts +++ b/packages/core/src/apis/cosmos/governance/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams, ProposalStatus } from "../../../types"; import type { GovParamsResponse, @@ -25,19 +25,19 @@ export type { }; export const getGovParams = - (baseURL: string) => + (instance: AxiosInstance) => async ({ paramsType, }: { paramsType: GovParamsType; }): Promise => { return ( - await instance(baseURL).get(`/cosmos/gov/v1beta1/params/${paramsType}`) + await instance.get(`/cosmos/gov/v1beta1/params/${paramsType}`) ).data; }; export const getProposals = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalStatus, voter, @@ -72,7 +72,7 @@ export const getProposals = return 0; }; return ( - await instance(baseURL).get("/cosmos/gov/v1beta1/proposals", { + await instance.get("/cosmos/gov/v1beta1/proposals", { params: { proposal_status: proposalStatusNumber(), voter, @@ -84,15 +84,15 @@ export const getProposals = }; export const getProposal = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalId }: { proposalId: string }): Promise => { return ( - await instance(baseURL).get(`/cosmos/gov/v1beta1/proposals/${proposalId}`) + await instance.get(`/cosmos/gov/v1beta1/proposals/${proposalId}`) ).data; }; export const getProposalDeposits = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalId, pagination, @@ -101,7 +101,7 @@ export const getProposalDeposits = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/gov/v1beta1/proposals/${proposalId}/deposits`, { params: { pagination }, @@ -111,7 +111,7 @@ export const getProposalDeposits = }; export const getProposalDeposit = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalId, depositor, @@ -120,28 +120,28 @@ export const getProposalDeposit = depositor: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/gov/v1beta1/proposals/${proposalId}/deposits/${depositor}` ) ).data; }; export const getProposalTally = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalId, }: { proposalId: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/gov/v1beta1/proposals/${proposalId}/tally` ) ).data; }; export const getProposalVotes = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalId, pagination, @@ -150,7 +150,7 @@ export const getProposalVotes = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/gov/v1beta1/proposals/${proposalId}/votes`, { params: { pagination }, @@ -160,7 +160,7 @@ export const getProposalVotes = }; export const getProposalVote = - (baseURL: string) => + (instance: AxiosInstance) => async ({ proposalId, voter, @@ -169,7 +169,7 @@ export const getProposalVote = voter: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/gov/v1beta1/proposals/${proposalId}/votes/${voter}` ) ).data; diff --git a/packages/core/src/apis/cosmos/mint/index.ts b/packages/core/src/apis/cosmos/mint/index.ts index 3003cf6..3790532 100644 --- a/packages/core/src/apis/cosmos/mint/index.ts +++ b/packages/core/src/apis/cosmos/mint/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { AnnualProvisionsResponse, InflationResponse, @@ -12,18 +12,16 @@ export type { }; export const getAnnualProvisions = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/cosmos/mint/v1beta1/annual_provisions") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/mint/v1beta1/annual_provisions")).data; }; export const getInflation = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/mint/v1beta1/inflation")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/mint/v1beta1/inflation")).data; }; export const getMintingParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/mint/v1beta1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/mint/v1beta1/params")).data; }; diff --git a/packages/core/src/apis/cosmos/params/index.ts b/packages/core/src/apis/cosmos/params/index.ts index 72f0344..91a3521 100644 --- a/packages/core/src/apis/cosmos/params/index.ts +++ b/packages/core/src/apis/cosmos/params/index.ts @@ -1,9 +1,9 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { ParamsResponse } from "./types"; export type { ParamsResponse }; export const getParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/params/v1beta1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/params/v1beta1/params")).data; }; diff --git a/packages/core/src/apis/cosmos/slashing/index.ts b/packages/core/src/apis/cosmos/slashing/index.ts index 977a20e..bf866d5 100644 --- a/packages/core/src/apis/cosmos/slashing/index.ts +++ b/packages/core/src/apis/cosmos/slashing/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { SigningInfoResponse, @@ -9,34 +9,33 @@ import type { export type { SigningInfoResponse, SigningInfosResponse, SlashingParams }; export const getSlashingParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/slashing/v1beta1/params")) - .data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/slashing/v1beta1/params")).data; }; export const getSigningInfos = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/slashing/v1beta1/signing_infos", { + await instance.get("/cosmos/slashing/v1beta1/signing_infos", { params: { pagination }, }) ).data; }; export const getSigningInfo = - (baseURL: string) => + (instance: AxiosInstance) => async ({ consAddress, }: { consAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/slashing/v1beta1/signing_infos/${consAddress}` ) ).data; diff --git a/packages/core/src/apis/cosmos/staking/index.ts b/packages/core/src/apis/cosmos/staking/index.ts index 6215eb2..6b5f1d2 100644 --- a/packages/core/src/apis/cosmos/staking/index.ts +++ b/packages/core/src/apis/cosmos/staking/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { DelegatorDelegationsResponse, @@ -35,7 +35,7 @@ export type { }; export const getDelegatorDelegations = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, pagination, @@ -44,7 +44,7 @@ export const getDelegatorDelegations = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/delegations/${delegatorAddress}`, { params: { pagination }, @@ -54,7 +54,7 @@ export const getDelegatorDelegations = }; export const getDelegatorRedelegations = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, srcValidatorAddress, @@ -67,7 +67,7 @@ export const getDelegatorRedelegations = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/delegators/${delegatorAddress}/redelegations`, { params: { @@ -81,7 +81,7 @@ export const getDelegatorRedelegations = }; export const getDelegatorUnbondingDelegations = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, pagination, @@ -90,7 +90,7 @@ export const getDelegatorUnbondingDelegations = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/delegators/${delegatorAddress}/unbonding_delegations`, { params: { pagination }, @@ -100,7 +100,7 @@ export const getDelegatorUnbondingDelegations = }; export const getDelegatorValidators = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, pagination, @@ -109,7 +109,7 @@ export const getDelegatorValidators = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/delegators/${delegatorAddress}/validators`, { params: { pagination }, @@ -119,7 +119,7 @@ export const getDelegatorValidators = }; export const getDelegatorValidator = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, validatorAddress, @@ -128,33 +128,32 @@ export const getDelegatorValidator = validatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/delegators/${delegatorAddress}/validators/${validatorAddress}` ) ).data; }; export const getHistoricalInfo = - (baseURL: string) => + (instance: AxiosInstance) => async ({ height }: { height: string }): Promise => { return ( - await instance(baseURL).get( - `/cosmos/staking/v1beta1/historical_info/${height}` - ) + await instance.get(`/cosmos/staking/v1beta1/historical_info/${height}`) ).data; }; export const getStakingParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/staking/v1beta1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/staking/v1beta1/params")).data; }; -export const getPool = (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/staking/v1beta1/pool")).data; -}; +export const getPool = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/staking/v1beta1/pool")).data; + }; export const getValidators = - (baseURL: string) => + (instance: AxiosInstance) => async ({ status, pagination, @@ -163,7 +162,7 @@ export const getValidators = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/cosmos/staking/v1beta1/validators", { + await instance.get("/cosmos/staking/v1beta1/validators", { params: { status, pagination, @@ -173,21 +172,21 @@ export const getValidators = }; export const getValidator = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, }: { validatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/validators/${validatorAddress}` ) ).data; }; export const getValidatorDelegations = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, pagination, @@ -196,7 +195,7 @@ export const getValidatorDelegations = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/validators/${validatorAddress}/delegations`, { params: { pagination }, @@ -206,7 +205,7 @@ export const getValidatorDelegations = }; export const getValidatorDelegation = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, delegatorAddress, @@ -215,14 +214,14 @@ export const getValidatorDelegation = delegatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/validators/${validatorAddress}/delegations/${delegatorAddress}` ) ).data; }; export const getValidatorUnbondingDelegations = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, pagination, @@ -231,7 +230,7 @@ export const getValidatorUnbondingDelegations = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/validators/${validatorAddress}/unbonding_delegations`, { params: { pagination }, @@ -241,7 +240,7 @@ export const getValidatorUnbondingDelegations = }; export const getValidatorUnbondingDelegation = - (baseURL: string) => + (instance: AxiosInstance) => async ({ validatorAddress, delegatorAddress, @@ -250,7 +249,7 @@ export const getValidatorUnbondingDelegation = delegatorAddress: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/staking/v1beta1/validators/${validatorAddress}/delegations/${delegatorAddress}/unbonding_delegation` ) ).data; diff --git a/packages/core/src/apis/cosmos/tx/index.ts b/packages/core/src/apis/cosmos/tx/index.ts index ecc99b4..acb2159 100644 --- a/packages/core/src/apis/cosmos/tx/index.ts +++ b/packages/core/src/apis/cosmos/tx/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { BroadcastTx, @@ -21,14 +21,14 @@ export type { }; export const simulateTx = - (baseURL: string) => + (instance: AxiosInstance) => async ({ body }: { body: SimulateTx }): Promise => { - return (await instance(baseURL).post("/cosmos/tx/v1beta1/simulate", body)) + return (await instance.post("/cosmos/tx/v1beta1/simulate", body)) .data; }; export const getTxsEvent = - (baseURL: string) => + (instance: AxiosInstance) => async ({ events, orderBy, @@ -39,24 +39,24 @@ export const getTxsEvent = orderBy?: OrderBy; }): Promise => { return ( - await instance(baseURL).get("/cosmos/tx/v1beta1/txs", { + await instance.get("/cosmos/tx/v1beta1/txs", { params: { events, pagination, order_by: orderBy }, }) ).data; }; export const broadcastTx = - (baseURL: string) => + (instance: AxiosInstance) => async ({ body }: { body: BroadcastTx }): Promise => { return ( - await instance(baseURL).post("/cosmos/tx/v1beta1/txs", { + await instance.post("/cosmos/tx/v1beta1/txs", { body, }) ).data; }; export const getTxByHash = - (baseURL: string) => + (instance: AxiosInstance) => async ({ hash }: { hash: string }): Promise => { - return (await instance(baseURL).get(`/cosmos/tx/v1beta1/txs/${hash}`)).data; + return (await instance.get(`/cosmos/tx/v1beta1/txs/${hash}`)).data; }; diff --git a/packages/core/src/apis/cosmos/upgrade/index.ts b/packages/core/src/apis/cosmos/upgrade/index.ts index 2363874..663bbea 100644 --- a/packages/core/src/apis/cosmos/upgrade/index.ts +++ b/packages/core/src/apis/cosmos/upgrade/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { AppliedPlanResponse, CurrentPlanResponse, @@ -14,44 +14,40 @@ export type { }; export const getAppliedPlan = - (baseURL: string) => + (instance: AxiosInstance) => async ({ name }: { name: string }): Promise => { - return ( - await instance(baseURL).get( - `/cosmos/upgrade/v1beta1/applied_plan/${name}` - ) - ).data; + return (await instance.get(`/cosmos/upgrade/v1beta1/applied_plan/${name}`)) + .data; }; export const getCurrentPlan = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/cosmos/upgrade/v1beta1/current_plan")) - .data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/cosmos/upgrade/v1beta1/current_plan")).data; }; export const getModuleVersions = - (baseURL: string) => + (instance: AxiosInstance) => async ({ moduleName, }: { moduleName?: string; }): Promise => { return ( - await instance(baseURL).get("/cosmos/upgrade/v1beta1/module_versions", { + await instance.get("/cosmos/upgrade/v1beta1/module_versions", { params: { module_name: moduleName }, }) ).data; }; export const getUpgradedConsensusState = - (baseURL: string) => + (instance: AxiosInstance) => async ({ lastHeight, }: { lastHeight: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/cosmos/upgrade/v1beta1/upgraded_consensus_state/${lastHeight}` ) ).data; diff --git a/packages/core/src/apis/cosmwasm/wasm/index.ts b/packages/core/src/apis/cosmwasm/wasm/index.ts index 1cbb9bb..e88d7e2 100644 --- a/packages/core/src/apis/cosmwasm/wasm/index.ts +++ b/packages/core/src/apis/cosmwasm/wasm/index.ts @@ -1,8 +1,9 @@ -import { getUrlFromObj, getWasmDUrlFromObj, instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { ContractCodeHashResponse } from "./types"; +import { Buffer } from "buffer"; export const getQuerySmartContract = - (baseURL: string) => + (instance: AxiosInstance) => async ({ isWasmd = false, contractAddress, @@ -12,19 +13,26 @@ export const getQuerySmartContract = contractAddress: string; contractQueryInterface: object; }): Promise => { + const msg = JSON.stringify(contractQueryInterface); + const query = Buffer.from(msg).toString("base64"); + + if (isWasmd) { + return ( + await instance.get( + `/cosmwasm/wasm/v1/contract/${contractAddress}/smart/${query}` + ) + ).data; + } + return ( - await instance(baseURL).get( - isWasmd - ? getWasmDUrlFromObj(contractAddress, contractQueryInterface) - : getUrlFromObj(contractAddress, contractQueryInterface) - ) + await instance.get(`/wasm/v1/contract/${contractAddress}/smart/${query}`) ).data; }; export const getContractCodeHash = - (baseURL: string) => async (contractAddress: string) => + (instance: AxiosInstance) => async (contractAddress: string) => ( - await instance(baseURL).get( + await instance.get( `/wasm/contract/${contractAddress}/code-hash` ) ).data; diff --git a/packages/core/src/apis/evmos/claims/index.ts b/packages/core/src/apis/evmos/claims/index.ts index 2c0e3f2..ddc71c6 100644 --- a/packages/core/src/apis/evmos/claims/index.ts +++ b/packages/core/src/apis/evmos/claims/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { ClaimsParamsResponse, @@ -15,34 +15,34 @@ export type { }; export const getClaimsRecords = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/evmos/claims/v1/claims_records", { + await instance.get("/evmos/claims/v1/claims_records", { params: { pagination }, }) ).data; }; export const getClaimsRecord = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address }: { address: string }): Promise => { return ( - await instance(baseURL).get(`/evmos/claims/v1/claims_records/${address}`) + await instance.get(`/evmos/claims/v1/claims_records/${address}`) ).data; }; export const getClaimsParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/claims/v1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/claims/v1/params")).data; }; export const getTotalUnclaimed = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/claims/v1/total_unclaimed")) + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/claims/v1/total_unclaimed")) .data; }; diff --git a/packages/core/src/apis/evmos/epochs/index.ts b/packages/core/src/apis/evmos/epochs/index.ts index 9e0bb47..824147d 100644 --- a/packages/core/src/apis/evmos/epochs/index.ts +++ b/packages/core/src/apis/evmos/epochs/index.ts @@ -1,18 +1,18 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { CurrentEpochResponse, EpochsResponse } from "./types"; export type { CurrentEpochResponse, EpochsResponse }; export const getCurrentEpoch = - (baseURL: string) => + (instance: AxiosInstance) => async ({ identifier, }: { identifier?: string; }): Promise => { return ( - await instance(baseURL).get("/evmos/epochs/v1/current_epoch", { + await instance.get("/evmos/epochs/v1/current_epoch", { params: { identifier, }, @@ -21,14 +21,14 @@ export const getCurrentEpoch = }; export const getEpochs = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/evmos/epochs/v1/epochs", { + await instance.get("/evmos/epochs/v1/epochs", { params: { pagination, }, diff --git a/packages/core/src/apis/evmos/erc20/index.ts b/packages/core/src/apis/evmos/erc20/index.ts index a89db20..28eac41 100644 --- a/packages/core/src/apis/evmos/erc20/index.ts +++ b/packages/core/src/apis/evmos/erc20/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { ERC20ParamsResponse, @@ -9,21 +9,21 @@ import type { export type { ERC20ParamsResponse, TokenPairResponse, TokenPairsResponse }; export const getERC20Params = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/erc20/v1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/erc20/v1/params")).data; }; export const getTokenPairs = - (baseURL: string) => + (instance: AxiosInstance) => async ({}: { pagination?: PaginationParams; }): Promise => { - return (await instance(baseURL).get("/evmos/erc20/v1/token_pairs")).data; + return (await instance.get("/evmos/erc20/v1/token_pairs")).data; }; export const getTokenPair = - (baseURL: string) => + (instance: AxiosInstance) => async ({ token }: { token: string }): Promise => { - return (await instance(baseURL).get(`/evmos/erc20/v1/token_pairs/${token}`)) + return (await instance.get(`/evmos/erc20/v1/token_pairs/${token}`)) .data; }; diff --git a/packages/core/src/apis/evmos/incentives/index.ts b/packages/core/src/apis/evmos/incentives/index.ts index ee078cd..369bff9 100644 --- a/packages/core/src/apis/evmos/incentives/index.ts +++ b/packages/core/src/apis/evmos/incentives/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { AllocationMeterResponse, @@ -21,31 +21,29 @@ export type { }; export const getAllocationMeters = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/evmos/incentives/v1/allocation_meters", { + await instance.get("/evmos/incentives/v1/allocation_meters", { params: { pagination }, }) ).data; }; export const getAllocationMeter = - (baseURL: string) => + (instance: AxiosInstance) => async ({ denom }: { denom: string }): Promise => { return ( - await instance(baseURL).get( - `/evmos/incentives/v1/allocation_meters/${denom}` - ) + await instance.get(`/evmos/incentives/v1/allocation_meters/${denom}`) ).data; }; export const getGasMeters = - (baseURL: string) => + (instance: AxiosInstance) => async ({ contract, pagination, @@ -54,17 +52,14 @@ export const getGasMeters = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( - `/evmos/incentives/v1/gas_meters/${contract}`, - { - params: { pagination }, - } - ) + await instance.get(`/evmos/incentives/v1/gas_meters/${contract}`, { + params: { pagination }, + }) ).data; }; export const getGasMeter = - (baseURL: string) => + (instance: AxiosInstance) => async ({ contract, participant, @@ -73,35 +68,34 @@ export const getGasMeter = participant: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/evmos/incentives/v1/gas_meters/${contract}/${participant}` ) ).data; }; export const getIncentives = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/evmos/incentives/v1/incentives", { + await instance.get("/evmos/incentives/v1/incentives", { params: { pagination }, }) ).data; }; export const getIncentive = - (baseURL: string) => + (instance: AxiosInstance) => async ({ contract }: { contract: string }): Promise => { - return ( - await instance(baseURL).get(`/evmos/incentives/v1/incentives/${contract}`) - ).data; + return (await instance.get(`/evmos/incentives/v1/incentives/${contract}`)) + .data; }; export const getIncentivesParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/incentives/v1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/incentives/v1/params")).data; }; diff --git a/packages/core/src/apis/evmos/inflation/index.ts b/packages/core/src/apis/evmos/inflation/index.ts index 621fa3d..a14c479 100644 --- a/packages/core/src/apis/evmos/inflation/index.ts +++ b/packages/core/src/apis/evmos/inflation/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { CirculatingSupplyResponse, EpochMintProvisionResponse, @@ -18,37 +18,33 @@ export type { }; export const getCirculatingSupply = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/evmos/inflation/v1/circulating_supply") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/inflation/v1/circulating_supply")).data; }; export const getEpochMintProvision = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/evmos/inflation/v1/epoch_mint_provision") - ).data; + (instance: AxiosInstance) => + async (): Promise => { + return (await instance.get("/evmos/inflation/v1/epoch_mint_provision")) + .data; }; export const getInflationRate = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/inflation/v1/inflation_rate")) - .data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/inflation/v1/inflation_rate")).data; }; export const getInflationParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/inflation/v1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/inflation/v1/params")).data; }; export const getInflationPeriod = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/inflation/v1/period")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/inflation/v1/period")).data; }; export const getSkippedEpochs = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/inflation/v1/skipped_epochs")) - .data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/inflation/v1/skipped_epochs")).data; }; diff --git a/packages/core/src/apis/evmos/recovery/index.ts b/packages/core/src/apis/evmos/recovery/index.ts index e51f2a3..3e9a04b 100644 --- a/packages/core/src/apis/evmos/recovery/index.ts +++ b/packages/core/src/apis/evmos/recovery/index.ts @@ -1,9 +1,9 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { RecoveryParamsResponse } from "./types"; export type { RecoveryParamsResponse }; export const getRecoveryParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/evmos/recovery/v1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/evmos/recovery/v1/params")).data; }; diff --git a/packages/core/src/apis/evmos/vesting/index.ts b/packages/core/src/apis/evmos/vesting/index.ts index 174b686..d8a7dc9 100644 --- a/packages/core/src/apis/evmos/vesting/index.ts +++ b/packages/core/src/apis/evmos/vesting/index.ts @@ -1,16 +1,14 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { VestingBalancesResponse } from "./types"; export type { VestingBalancesResponse }; export const getVestingBalances = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address, }: { address: string; }): Promise => { - return ( - await instance(baseURL).get(`/evmos/vesting/v1/balances/${address}`) - ).data; + return (await instance.get(`/evmos/vesting/v1/balances/${address}`)).data; }; diff --git a/packages/core/src/apis/ibc/applications/index.ts b/packages/core/src/apis/ibc/applications/index.ts index 2dc1c38..18608ab 100644 --- a/packages/core/src/apis/ibc/applications/index.ts +++ b/packages/core/src/apis/ibc/applications/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { DenomTraceResponse, @@ -9,14 +9,14 @@ import type { export type { DenomTraceResponse, DenomTracesResponse, TransferParamsResponse }; export const getDenomTraces = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? "/ibc/apps/transfer/v1/denom_traces" : "/ibc/applications/transfer/v1beta1/denom_traces", @@ -28,7 +28,7 @@ export const getDenomTraces = }; export const getDenomTrace = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ hash, }: { @@ -36,7 +36,7 @@ export const getDenomTrace = isIBCGo?: boolean; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/apps/transfer/v1/denom_traces/${hash}` : `/ibc/applications/transfer/v1beta1/denom_traces/${hash}` @@ -45,10 +45,10 @@ export const getDenomTrace = }; export const getTransferParams = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async (): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? "/ibc/apps/transfer/v1/params" : "/ibc/applications/transfer/v1beta1/params" diff --git a/packages/core/src/apis/ibc/client/index.ts b/packages/core/src/apis/ibc/client/index.ts index 9fd908b..283fef3 100644 --- a/packages/core/src/apis/ibc/client/index.ts +++ b/packages/core/src/apis/ibc/client/index.ts @@ -1,13 +1,13 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { ClientParamsResponse } from "./types"; export type { ClientParamsResponse }; export const getClientParams = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async (): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? "/ibc/client/v1/params" : "/ibc/client/v1beta1/params" ) ).data; diff --git a/packages/core/src/apis/ibc/core/channel/index.ts b/packages/core/src/apis/ibc/core/channel/index.ts index 5f696ba..51b0892 100644 --- a/packages/core/src/apis/ibc/core/channel/index.ts +++ b/packages/core/src/apis/ibc/core/channel/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../../types"; import type { ChannelClientStateResponse, @@ -33,14 +33,14 @@ export type { }; export const getChannels = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? "/ibc/core/channel/v1/channels" : "/ibc/core/channel/v1beta1/channels", @@ -52,7 +52,7 @@ export const getChannels = }; export const getChannel = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -61,7 +61,7 @@ export const getChannel = portId: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}` @@ -70,7 +70,7 @@ export const getChannel = }; export const getChannelClientState = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -79,7 +79,7 @@ export const getChannelClientState = portId: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/client_state` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/client_state` @@ -88,7 +88,7 @@ export const getChannelClientState = }; export const getChannelConsensusState = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -101,7 +101,7 @@ export const getChannelConsensusState = revisionHeight: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/consensus_state/revision/${revisionNumber}/height/${revisionHeight}` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/consensus_state/revision/${revisionNumber}/height/${revisionHeight}` @@ -110,7 +110,7 @@ export const getChannelConsensusState = }; export const getNextSequenceReceive = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -119,7 +119,7 @@ export const getNextSequenceReceive = portId: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/next_sequence` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/next_sequence` @@ -128,7 +128,7 @@ export const getNextSequenceReceive = }; export const getPacketAcknowledgements = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -139,7 +139,7 @@ export const getPacketAcknowledgements = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_acknowledgements` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_acknowledgements`, @@ -151,7 +151,7 @@ export const getPacketAcknowledgements = }; export const getPacketAcknowledgement = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -162,7 +162,7 @@ export const getPacketAcknowledgement = sequence: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_acks/${sequence}` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_acks/${sequence}` @@ -171,7 +171,7 @@ export const getPacketAcknowledgement = }; export const getPacketCommitments = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -182,7 +182,7 @@ export const getPacketCommitments = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_commitments`, @@ -194,7 +194,7 @@ export const getPacketCommitments = }; export const getUnreceivedAcks = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -206,7 +206,7 @@ export const getUnreceivedAcks = }): Promise => { const packetAckSequencesString = packetAckSequences.join(","); return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${packetAckSequencesString}/unreceived_acks` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_commitments/${packetAckSequencesString}/unreceived_acks` @@ -215,7 +215,7 @@ export const getUnreceivedAcks = }; export const getUnreceivedPackets = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -227,7 +227,7 @@ export const getUnreceivedPackets = }): Promise => { const packetCommitmentSequencesString = packetCommitmentSequences.join(","); return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${packetCommitmentSequencesString}/unreceived_packets` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_commitments/${packetCommitmentSequencesString}/unreceived_packets` @@ -236,7 +236,7 @@ export const getUnreceivedPackets = }; export const getPacketCommitment = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -247,7 +247,7 @@ export const getPacketCommitment = sequence: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_commitments/${sequence}` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_commitments/${sequence}` @@ -256,7 +256,7 @@ export const getPacketCommitment = }; export const getPacketReceipt = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ channelId, portId, @@ -267,7 +267,7 @@ export const getPacketReceipt = sequence: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/channels/${channelId}/ports/${portId}/packet_receipts/${sequence}` : `/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/packet_receipts/${sequence}` @@ -276,7 +276,7 @@ export const getPacketReceipt = }; export const getConnectionChannels = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ connection, pagination, @@ -285,7 +285,7 @@ export const getConnectionChannels = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/channel/v1/connections/${connection}/channels` : `/ibc/core/channel/v1beta1/connections/${connection}/channels`, diff --git a/packages/core/src/apis/ibc/core/client/index.ts b/packages/core/src/apis/ibc/core/client/index.ts index 295b43f..ce5de9c 100644 --- a/packages/core/src/apis/ibc/core/client/index.ts +++ b/packages/core/src/apis/ibc/core/client/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../../types"; import type { ClientStateResponse, @@ -15,14 +15,14 @@ export type { }; export const getClientStates = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? "/ibc/core/client/v1/client_states" : "/ibc/core/client/v1beta1/client_states", @@ -34,10 +34,10 @@ export const getClientStates = }; export const getClientState = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ clientId }: { clientId: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/client/v1/client_states/${clientId}` : `/ibc/core/client/v1beta1/client_states/${clientId}` @@ -46,7 +46,7 @@ export const getClientState = }; export const getConsensusStates = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ clientId, pagination, @@ -55,7 +55,7 @@ export const getConsensusStates = pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/client/v1/consensus_states/${clientId}` : `/ibc/core/client/v1beta1/consensus_states/${clientId}`, @@ -67,7 +67,7 @@ export const getConsensusStates = }; export const getConsensusState = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ clientId, revisionNumber, @@ -80,7 +80,7 @@ export const getConsensusState = latestHeight?: boolean; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/client/v1/consensus_states/${clientId}/revision/${revisionNumber}/height/${revisionHeight}` : `/ibc/core/client/v1beta1/consensus_states/${clientId}/revision/${revisionNumber}/height/${revisionHeight}`, diff --git a/packages/core/src/apis/ibc/core/connection/index.ts b/packages/core/src/apis/ibc/core/connection/index.ts index 0c8b29f..2cf0232 100644 --- a/packages/core/src/apis/ibc/core/connection/index.ts +++ b/packages/core/src/apis/ibc/core/connection/index.ts @@ -1,11 +1,11 @@ -import { instance } from "../../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../../types"; export const getClientConnections = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ clientId }: { clientId: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/connection/v1/client_connections/${clientId}` : `/ibc/core/connection/v1beta1/client_connections/${clientId}` @@ -14,10 +14,10 @@ export const getClientConnections = }; export const getConnections = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ pagination }: { pagination?: PaginationParams }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? "/ibc/core/connection/v1/connections" : "/ibc/core/connection/v1beta1/connections", @@ -29,10 +29,10 @@ export const getConnections = }; export const getConnection = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ connectionId }: { connectionId: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/connection/v1/connections/${connectionId}` : `/ibc/core/connection/v1beta1/connections/${connectionId}` @@ -41,10 +41,10 @@ export const getConnection = }; export const getConnectionClientState = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ connectionId }: { connectionId: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/connection/v1/connections/${connectionId}/client_state` : `/ibc/core/connection/v1beta1/connections/${connectionId}/client_state` @@ -53,7 +53,7 @@ export const getConnectionClientState = }; export const getConnectionConsensusState = - (baseURL: string, isIBCGo = false) => + (instance: AxiosInstance, isIBCGo = false) => async ({ connectionId, revisionNumber, @@ -64,7 +64,7 @@ export const getConnectionConsensusState = revisionHeight: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( isIBCGo ? `/ibc/core/connection/v1/connections/${connectionId}/consensus_state/revision/${revisionNumber}/height/${revisionHeight}` : `/ibc/core/connection/v1beta1/connections/${connectionId}/consensus_state/revision/${revisionNumber}/height/${revisionHeight}` diff --git a/packages/core/src/apis/osmosis/claim/index.ts b/packages/core/src/apis/osmosis/claim/index.ts index c1688e9..8f05057 100644 --- a/packages/core/src/apis/osmosis/claim/index.ts +++ b/packages/core/src/apis/osmosis/claim/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { ActionParams, ClaimableForActionResponse, @@ -18,17 +18,17 @@ export type { }; export const getClaimRecord = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address }: { address: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/claim/v1beta1/claim_record/${address}` ) ).data; }; export const getClaimableForAction = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address, action, @@ -37,31 +37,31 @@ export const getClaimableForAction = action: ActionParams; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/claim/v1beta1/claimable_for_action/${address}/${action}` ) ).data; }; export const getModuleAccountBalance = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => async (): Promise => { return ( - await instance(baseURL).get( + await instance.get( "/osmosis/claim/v1beta1/module_account_balance" ) ).data; }; export const getClaimParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/osmosis/claim/v1beta1/params")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/claim/v1beta1/params")).data; }; export const getTotalClaimable = - (baseURL: string) => + (instance: AxiosInstance) => async ({ address }: { address: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/claim/v1beta1/total_claimable/${address}` ) ).data; diff --git a/packages/core/src/apis/osmosis/epochs/index.ts b/packages/core/src/apis/osmosis/epochs/index.ts index 3d2f2cf..b9e1b91 100644 --- a/packages/core/src/apis/osmosis/epochs/index.ts +++ b/packages/core/src/apis/osmosis/epochs/index.ts @@ -1,16 +1,14 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { CurrentEpochResponse, EpochsResponse } from "./types"; export type { CurrentEpochResponse, EpochsResponse }; export const getCurrentEpoch = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/osmosis/epochs/v1beta1/current_epoch") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/epochs/v1beta1/current_epoch")).data; }; export const getEpochs = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/osmosis/epochs/v1beta1/epochs")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/epochs/v1beta1/epochs")).data; }; diff --git a/packages/core/src/apis/osmosis/gamm/index.ts b/packages/core/src/apis/osmosis/gamm/index.ts index 8298065..dd30e6a 100644 --- a/packages/core/src/apis/osmosis/gamm/index.ts +++ b/packages/core/src/apis/osmosis/gamm/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { OsmosisPaginationParams } from "../../../types"; import type { NumPoolsResponse, @@ -27,45 +27,39 @@ export type { }; export const getNumPools = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/osmosis/gamm/v1beta1/num_pools")) - .data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/gamm/v1beta1/num_pools")).data; }; export const getPools = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: OsmosisPaginationParams; }): Promise => { return ( - await instance(baseURL).get("/osmosis/gamm/v1beta1/pools", { + await instance.get("/osmosis/gamm/v1beta1/pools", { params: { pagination }, }) ).data; }; export const getPool = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId }: { poolId: string }): Promise => { - return ( - await instance(baseURL).get(`/osmosis/gamm/v1beta1/pools/${poolId}`) - ).data; + return (await instance.get(`/osmosis/gamm/v1beta1/pools/${poolId}`)).data; }; export const getPoolParams = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId }: { poolId: string }): Promise => { - return ( - await instance(baseURL).get( - `/osmosis/gamm/v1beta1/pools/${poolId}/params` - ) - ).data; + return (await instance.get(`/osmosis/gamm/v1beta1/pools/${poolId}/params`)) + .data; }; export const getPoolPrice = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId, tokenInDenom, @@ -78,48 +72,38 @@ export const getPoolPrice = withSwapFee?: boolean; }): Promise => { return ( - await instance(baseURL).get( - `/osmosis/gamm/v1beta1/pools/${poolId}/prices`, - { - params: { - tokenInDenom, - tokenOutDenom, - withSwapFee, - }, - } - ) + await instance.get(`/osmosis/gamm/v1beta1/pools/${poolId}/prices`, { + params: { + tokenInDenom, + tokenOutDenom, + withSwapFee, + }, + }) ).data; }; export const getPoolTokens = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId }: { poolId: string }): Promise => { - return ( - await instance(baseURL).get( - `/osmosis/gamm/v1beta1/pools/${poolId}/tokens` - ) - ).data; + return (await instance.get(`/osmosis/gamm/v1beta1/pools/${poolId}/tokens`)) + .data; }; export const getPoolTotalShare = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId }: { poolId: string }): Promise => { return ( - await instance(baseURL).get( - `/osmosis/gamm/v1beta1/pools/${poolId}/total_share` - ) + await instance.get(`/osmosis/gamm/v1beta1/pools/${poolId}/total_share`) ).data; }; export const getTotalLiquidity = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/osmosis/gamm/v1beta1/total_liquidity") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/gamm/v1beta1/total_liquidity")).data; }; export const getSwapExactAmountIn = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId, sender, @@ -130,7 +114,7 @@ export const getSwapExactAmountIn = tokenIn?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/gamm/v1beta1/${poolId}/estimate/swap_exact_amount_in`, { params: { sender, tokenIn }, @@ -140,7 +124,7 @@ export const getSwapExactAmountIn = }; export const getSwapExactAmountOut = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId, sender, @@ -151,7 +135,7 @@ export const getSwapExactAmountOut = tokenOut?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/gamm/v1beta1/${poolId}/estimate/swap_exact_amount_out`, { params: { diff --git a/packages/core/src/apis/osmosis/incentives/index.ts b/packages/core/src/apis/osmosis/incentives/index.ts index c2d4a37..64a9919 100644 --- a/packages/core/src/apis/osmosis/incentives/index.ts +++ b/packages/core/src/apis/osmosis/incentives/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PaginationParams } from "../../../types"; import type { ActiveGaugesResponse, @@ -21,56 +21,53 @@ export type { }; export const getActiveGauges = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("osmosis/incentives/v1beta1/active_gauges", { + await instance.get("osmosis/incentives/v1beta1/active_gauges", { params: { pagination }, }) ).data; }; export const getGaugeById = - (baseURL: string) => + (instance: AxiosInstance) => async ({ id }: { id: string }): Promise => { - return ( - await instance(baseURL).get( - `/osmosis/incentives/v1beta1/gauge_by_id/${id}` - ) - ).data; + return (await instance.get(`/osmosis/incentives/v1beta1/gauge_by_id/${id}`)) + .data; }; export const getGauges = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get("/osmosis/incentives/v1beta1/gauges", { + await instance.get("/osmosis/incentives/v1beta1/gauges", { params: { pagination }, }) ).data; }; export const getModuleDistributedCoins = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => + async (): Promise => { return ( - await instance(baseURL).get( - "/osmosis/incentives/v1beta1/module_distributed_coins" - ) + await instance.get("/osmosis/incentives/v1beta1/module_distributed_coins") ).data; }; export const getModuleToDistributeCoins = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => + async (): Promise => { return ( - await instance(baseURL).get( + await instance.get( "/osmosis/incentives/v1beta1/module_to_distribute_coins" ) ).data; @@ -78,7 +75,7 @@ export const getModuleToDistributeCoins = // TODO: check lockIds param export const getRewardsEst = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, lockIds, @@ -89,28 +86,22 @@ export const getRewardsEst = endEpoch?: string; }): Promise => { return ( - await instance(baseURL).get( - `/osmosis/incentives/v1beta1/rewards_est/${owner}`, - { - params: { lock_ids: lockIds, end_epoch: endEpoch }, - } - ) + await instance.get(`/osmosis/incentives/v1beta1/rewards_est/${owner}`, { + params: { lock_ids: lockIds, end_epoch: endEpoch }, + }) ).data; }; export const getUpcomingGauges = - (baseURL: string) => + (instance: AxiosInstance) => async ({ pagination, }: { pagination?: PaginationParams; }): Promise => { return ( - await instance(baseURL).get( - "/osmosis/incentives/v1beta1/upcoming_gauges", - { - params: { pagination }, - } - ) + await instance.get("/osmosis/incentives/v1beta1/upcoming_gauges", { + params: { pagination }, + }) ).data; }; diff --git a/packages/core/src/apis/osmosis/lockup/index.ts b/packages/core/src/apis/osmosis/lockup/index.ts index 8bb3560..aec6bdc 100644 --- a/packages/core/src/apis/osmosis/lockup/index.ts +++ b/packages/core/src/apis/osmosis/lockup/index.ts @@ -1,20 +1,20 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { CoinsResponse, LockedByIdResponse, LocksResponse } from "./types"; export type { CoinsResponse, LockedByIdResponse, LocksResponse }; export const getAccountLockedCoins = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner }: { owner: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_coins/${owner}` ) ).data; }; export const getAccountLockedLongerDuration = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, duration, @@ -23,7 +23,7 @@ export const getAccountLockedLongerDuration = duration?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_longer_duration/${owner}`, { params: { duration }, @@ -33,7 +33,7 @@ export const getAccountLockedLongerDuration = }; export const getAccountLockedLongerDurationDenom = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, duration, @@ -44,7 +44,7 @@ export const getAccountLockedLongerDurationDenom = denom?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_longer_duration_denom/${owner}`, { params: { @@ -57,7 +57,7 @@ export const getAccountLockedLongerDurationDenom = }; export const getAccountLockedLongerDurationNotUnlockingOnly = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, duration, @@ -66,7 +66,7 @@ export const getAccountLockedLongerDurationNotUnlockingOnly = duration?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_longer_duration_not_unlocking_only/${owner}`, { params: { duration }, @@ -76,7 +76,7 @@ export const getAccountLockedLongerDurationNotUnlockingOnly = }; export const getAccountLockedPastTime = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, timestamp, @@ -85,7 +85,7 @@ export const getAccountLockedPastTime = timestamp?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_pasttime/${owner}`, { params: { timestamp }, @@ -95,7 +95,7 @@ export const getAccountLockedPastTime = }; export const getAccountLockedPastTimeDenom = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, timestamp, @@ -106,7 +106,7 @@ export const getAccountLockedPastTimeDenom = denom?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_pasttime_denom/${owner}`, { params: { timestamp, denom }, @@ -116,7 +116,7 @@ export const getAccountLockedPastTimeDenom = }; export const getAccountLockedPastTimeNotUnlockingOnly = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, timestamp, @@ -125,7 +125,7 @@ export const getAccountLockedPastTimeNotUnlockingOnly = timestamp?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_locked_pasttime_not_unlocking_only/${owner}`, { params: { timestamp }, @@ -135,17 +135,17 @@ export const getAccountLockedPastTimeNotUnlockingOnly = }; export const getAccountUnlockableCoins = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner }: { owner: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_unlockable_coins/${owner}` ) ).data; }; export const getAccountUnlockedBeforeTime = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner, timestamp, @@ -154,7 +154,7 @@ export const getAccountUnlockedBeforeTime = timestamp?: string; }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_unlocked_before_time/${owner}`, { params: { timestamp }, @@ -164,37 +164,30 @@ export const getAccountUnlockedBeforeTime = }; export const getAccountUnlockingCoins = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner }: { owner: string }): Promise => { return ( - await instance(baseURL).get( + await instance.get( `/osmosis/lockup/v1beta1/account_unlocking_coins/${owner}` ) ).data; }; export const getLockedById = - (baseURL: string) => + (instance: AxiosInstance) => async ({ lockId }: { lockId: string }): Promise => { return ( - await instance(baseURL).get( - `/osmosis/lockup/v1beta1/locked_by_id/${lockId}` - ) + await instance.get(`/osmosis/lockup/v1beta1/locked_by_id/${lockId}`) ).data; }; export const getModuleBalance = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/osmosis/lockup/v1beta1/module_balance") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/lockup/v1beta1/module_balance")).data; }; export const getModuleLockedAmount = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get( - "/osmosis/lockup/v1beta1/module_locked_amount" - ) - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/lockup/v1beta1/module_locked_amount")) + .data; }; diff --git a/packages/core/src/apis/osmosis/mint/index.ts b/packages/core/src/apis/osmosis/mint/index.ts index 2c437ac..3d972a6 100644 --- a/packages/core/src/apis/osmosis/mint/index.ts +++ b/packages/core/src/apis/osmosis/mint/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { EpochProvisionsResponse, OsmosisMintingParamsResponse, @@ -7,13 +7,12 @@ import type { export type { EpochProvisionsResponse, OsmosisMintingParamsResponse }; export const getEpochProvisions = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/osmosis/mint/v1beta1/epoch_provisions") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/mint/v1beta1/epoch_provisions")).data; }; export const getMintingParams = - (baseURL: string) => async (): Promise => { - return (await instance(baseURL).get("/osmosis/mint/v1beta1/params")).data; + (instance: AxiosInstance) => + async (): Promise => { + return (await instance.get("/osmosis/mint/v1beta1/params")).data; }; diff --git a/packages/core/src/apis/osmosis/pool-incentives/index.ts b/packages/core/src/apis/osmosis/pool-incentives/index.ts index 7cf4963..237c9eb 100644 --- a/packages/core/src/apis/osmosis/pool-incentives/index.ts +++ b/packages/core/src/apis/osmosis/pool-incentives/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { DistrInfoResponse, GaugeIdsResponse, @@ -16,43 +16,35 @@ export type { }; export const getDistrInfo = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/osmosis/pool-incentives/v1beta1/distr_info") - ).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/osmosis/pool-incentives/v1beta1/distr_info")) + .data; }; export const getGaugeIds = - (baseURL: string) => + (instance: AxiosInstance) => async ({ poolId }: { poolId: string }): Promise => { return ( - await instance(baseURL).get( - `/osmosis/pool-incentives/v1beta1/gauge-ids/${poolId}` - ) + await instance.get(`/osmosis/pool-incentives/v1beta1/gauge-ids/${poolId}`) ).data; }; export const getIncentivizedPools = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => async (): Promise => { return ( - await instance(baseURL).get( - "/osmosis/pool-incentives/v1beta1/incentivized_pools" - ) + await instance.get("/osmosis/pool-incentives/v1beta1/incentivized_pools") ).data; }; export const getLockableDurations = - (baseURL: string) => async (): Promise => { + (instance: AxiosInstance) => async (): Promise => { return ( - await instance(baseURL).get( - "/osmosis/pool-incentives/v1beta1/lockable_durations" - ) + await instance.get("/osmosis/pool-incentives/v1beta1/lockable_durations") ).data; }; export const getPoolIncentivesParams = - (baseURL: string) => async (): Promise => { - return ( - await instance(baseURL).get("/osmosis/pool-incentives/v1beta1/params") - ).data; + (instance: AxiosInstance) => + async (): Promise => { + return (await instance.get("/osmosis/pool-incentives/v1beta1/params")).data; }; diff --git a/packages/core/src/apis/osmosis/superfluid/index.ts b/packages/core/src/apis/osmosis/superfluid/index.ts index d696524..e001ede 100644 --- a/packages/core/src/apis/osmosis/superfluid/index.ts +++ b/packages/core/src/apis/osmosis/superfluid/index.ts @@ -1,4 +1,4 @@ -import { instance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { SuperfluidAllAssetsResponse, SuperfluidDelegationResponse, @@ -7,15 +7,14 @@ import type { export type { SuperfluidDelegationResponse }; export const getSuperfluidDelegation = - (baseURL: string) => + (instance: AxiosInstance) => async ({ owner }: { owner: string }): Promise => ( - await instance(baseURL).get( + await instance.get( `/osmosis/superfluid/v1beta1/superfluid_delegations/${owner}` ) ).data; export const getSuperfluidAllAssets = - (baseURL: string) => async (): Promise => - (await instance(baseURL).get(`/osmosis/superfluid/v1beta1/all_assets`)) - .data; + (instance: AxiosInstance) => async (): Promise => + (await instance.get(`/osmosis/superfluid/v1beta1/all_assets`)).data; diff --git a/packages/core/src/apis/osmosisHistorical/apr/index.ts b/packages/core/src/apis/osmosisHistorical/apr/index.ts index 5d1bf5f..1655d05 100644 --- a/packages/core/src/apis/osmosisHistorical/apr/index.ts +++ b/packages/core/src/apis/osmosisHistorical/apr/index.ts @@ -1,20 +1,20 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { APRResponse, StakingAPRResponse } from "./types"; export type { APRResponse, StakingAPRResponse }; -export const getStakingAPR = async (): Promise => { - return (await osmosisInstance.get("/apr/v2/staking")).data; -}; +export const getStakingAPR = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/apr/v2/staking")).data; + }; -export const getAllAPR = async (): Promise => { - return (await osmosisInstance.get("/apr/v2/all")).data; -}; +export const getAllAPR = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/apr/v2/all")).data; + }; -export const getAPR = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/apr/v2/${poolId}`)).data; -}; +export const getAPR = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/apr/v2/${poolId}`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/fees/index.ts b/packages/core/src/apis/osmosisHistorical/fees/index.ts index 6770be6..7f4b2af 100644 --- a/packages/core/src/apis/osmosisHistorical/fees/index.ts +++ b/packages/core/src/apis/osmosisHistorical/fees/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { HistoricalFeeResponse, PoolFeesResponse, @@ -7,30 +7,29 @@ import type { export type { HistoricalFeeResponse, PoolFeesResponse, TotalFeesResponse }; -export const getTotalFees = async (): Promise => { - return (await osmosisInstance.get("/fees/v1/total")).data; -}; +export const getTotalFees = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/fees/v1/total")).data; + }; -export const getPoolsFees = async (): Promise => { - return (await osmosisInstance.get("/fees/v1/pools")).data; -}; +export const getPoolsFees = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/fees/v1/pools")).data; + }; -export const getPoolFees = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/fees/v1/${poolId}`)).data; -}; +export const getPoolFees = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/fees/v1/${poolId}`)).data; + }; -export const getHistoricalFees = async (): Promise => { - return (await osmosisInstance.get("/fees/v1/total/historical")).data; -}; +export const getHistoricalFees = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/fees/v1/total/historical")).data; + }; -export const getHistoricalFee = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/fees/v1/historical/${poolId}`)).data; -}; +export const getHistoricalFee = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/fees/v1/historical/${poolId}`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/health/index.ts b/packages/core/src/apis/osmosisHistorical/health/index.ts index afa59d6..a48f6db 100644 --- a/packages/core/src/apis/osmosisHistorical/health/index.ts +++ b/packages/core/src/apis/osmosisHistorical/health/index.ts @@ -1,8 +1,9 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { HealthResponse } from "./types"; export type { HealthResponse }; -export const getHealth = async (): Promise => { - return (await osmosisInstance.get("/health/v1/check")).data; -}; +export const getHealth = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/health/v1/check")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/ibc/index.ts b/packages/core/src/apis/osmosisHistorical/ibc/index.ts index 2a8e25a..1e83eb1 100644 --- a/packages/core/src/apis/osmosisHistorical/ibc/index.ts +++ b/packages/core/src/apis/osmosisHistorical/ibc/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { AllIbcResponse, IbcDestinationResponse, @@ -17,65 +17,68 @@ export type { IbcSourceResponse, }; -export const getIbcInfo = async (): Promise => { - return (await osmosisInstance.get("/ibc/v1/info")).data; -}; +export const getIbcInfo = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/ibc/v1/info")).data; + }; -export const getAllIbc = async ({ - dex, -}: { - dex?: string; -}): Promise => { - return (await osmosisInstance.get("/ibc/v1/all", { params: { dex } })).data; -}; +export const getAllIbc = + (instance: AxiosInstance) => + async ({ dex }: { dex?: string }): Promise => { + return (await instance.get("/ibc/v1/all", { params: { dex } })).data; + }; -export const getIbcSourceDestination = async ({ - source, - destination, - minutes_trigger, -}: { - source: string; - destination: string; - minutes_trigger: number; -}): Promise => { - return ( - await osmosisInstance.get( - `/ibc/v1/source/${source}/destination${destination}`, - { +export const getIbcSourceDestination = + (instance: AxiosInstance) => + async ({ + source, + destination, + minutes_trigger, + }: { + source: string; + destination: string; + minutes_trigger: number; + }): Promise => { + return ( + await instance.get(`/ibc/v1/source/${source}/destination${destination}`, { params: { minutes_trigger }, - } - ) - ).data; -}; + }) + ).data; + }; -export const getIbcSource = async ({ - source, - minutes_trigger, -}: { - source: string; - minutes_trigger: number; -}): Promise => { - return ( - await osmosisInstance.get(`/ibc/v1/source/${source}`, { - params: { minutes_trigger }, - }) - ).data; -}; +export const getIbcSource = + (instance: AxiosInstance) => + async ({ + source, + minutes_trigger, + }: { + source: string; + minutes_trigger: number; + }): Promise => { + return ( + await instance.get(`/ibc/v1/source/${source}`, { + params: { minutes_trigger }, + }) + ).data; + }; -export const getIbcDestination = async ({ - destination, - minutes_trigger, -}: { - destination: string; - minutes_trigger: number; -}): Promise => { - return ( - await osmosisInstance.get(`/ibc/v1/destination/${destination}`, { - params: { minutes_trigger }, - }) - ).data; -}; +export const getIbcDestination = + (instance: AxiosInstance) => + async ({ + destination, + minutes_trigger, + }: { + destination: string; + minutes_trigger: number; + }): Promise => { + return ( + await instance.get(`/ibc/v1/destination/${destination}`, { + params: { minutes_trigger }, + }) + ).data; + }; -export const getIbcRaw = async (): Promise => { - return (await osmosisInstance.get("/ibc/v1/raw")).data; -}; +export const getIbcRaw = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/ibc/v1/raw")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/liquidity/index.ts b/packages/core/src/apis/osmosisHistorical/liquidity/index.ts index 92ad4ff..d9c0c9d 100644 --- a/packages/core/src/apis/osmosisHistorical/liquidity/index.ts +++ b/packages/core/src/apis/osmosisHistorical/liquidity/index.ts @@ -1,9 +1,10 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { LiquidityHistoricalChartResponse } from "./types"; export type { LiquidityHistoricalChartResponse }; export const getLiquidityHistoricalChart = + (instance: AxiosInstance) => async (): Promise => { - return (await osmosisInstance.get("/liquidity/v2/historical/chart")).data; + return (await instance.get("/liquidity/v2/historical/chart")).data; }; diff --git a/packages/core/src/apis/osmosisHistorical/overview/index.ts b/packages/core/src/apis/osmosisHistorical/overview/index.ts index fd7e4bd..d032391 100644 --- a/packages/core/src/apis/osmosisHistorical/overview/index.ts +++ b/packages/core/src/apis/osmosisHistorical/overview/index.ts @@ -1,12 +1,14 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { MessageResponse, MetricsResponse } from "./types"; export type { MessageResponse, MetricsResponse }; -export const getMetrics = async (): Promise => { - return (await osmosisInstance.get("/overview/v1/metrics")).data; -}; +export const getMetrics = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/overview/v1/metrics")).data; + }; -export const getMessage = async (): Promise => { - return (await osmosisInstance.get("/overview/v1/message")).data; -}; +export const getMessage = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/overview/v1/message")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/pairs/index.ts b/packages/core/src/apis/osmosisHistorical/pairs/index.ts index 97a96fd..aabe965 100644 --- a/packages/core/src/apis/osmosisHistorical/pairs/index.ts +++ b/packages/core/src/apis/osmosisHistorical/pairs/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { PairsHistoricalChartParams, PairsHistoricalChartResponse, @@ -11,25 +11,28 @@ export type { PairsSummaryResponse, }; -export const getPairsSummary = async (): Promise => { - return (await osmosisInstance.get("/pairs/v1/summary")).data; -}; +export const getPairsSummary = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/pairs/v1/summary")).data; + }; -export const getPairsHistoricalChart = async ({ - poolId, - assetIn, - assetOut, - assetType, - range, -}: PairsHistoricalChartParams): Promise => { - return ( - await osmosisInstance.get(`/pairs/v1/historical/${poolId}/chart`, { - params: { - asset_in: assetIn, - asset_out: assetOut, - asset_type: assetType, - range, - }, - }) - ).data; -}; +export const getPairsHistoricalChart = + (instance: AxiosInstance) => + async ({ + poolId, + assetIn, + assetOut, + assetType, + range, + }: PairsHistoricalChartParams): Promise => { + return ( + await instance.get(`/pairs/v1/historical/${poolId}/chart`, { + params: { + asset_in: assetIn, + asset_out: assetOut, + asset_type: assetType, + range, + }, + }) + ).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/pools/index.ts b/packages/core/src/apis/osmosisHistorical/pools/index.ts index 80c4e40..484f02b 100644 --- a/packages/core/src/apis/osmosisHistorical/pools/index.ts +++ b/packages/core/src/apis/osmosisHistorical/pools/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { AllPoolsResponse, PoolResponse, @@ -13,41 +13,40 @@ export type { PoolVolumeChartResponse, }; -export const getAllPools = async ({ - lowLiquidity, -}: { - lowLiquidity: boolean; -}): Promise => { - return ( - await osmosisInstance.get("/pools/v2/all", { - params: { - low_liquidity: lowLiquidity, - }, - }) - ).data; -}; +export const getAllPools = + (instance: AxiosInstance) => + async ({ + lowLiquidity, + }: { + lowLiquidity: boolean; + }): Promise => { + return ( + await instance.get("/pools/v2/all", { + params: { + low_liquidity: lowLiquidity, + }, + }) + ).data; + }; -export const getPool = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/pools/v2/${poolId}`)).data; -}; +export const getPool = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/pools/v2/${poolId}`)).data; + }; -export const getPoolLiquidityChart = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/pools/v2/liquidity/${poolId}/chart`)) - .data; -}; +export const getPoolLiquidityChart = + (instance: AxiosInstance) => + async ({ + poolId, + }: { + poolId: number; + }): Promise => { + return (await instance.get(`/pools/v2/liquidity/${poolId}/chart`)).data; + }; -export const getPoolVolumeChart = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/pools/v2/volume/${poolId}/chart`)).data; -}; +export const getPoolVolumeChart = + (instance: AxiosInstance) => + async ({ poolId }: { poolId: number }): Promise => { + return (await instance.get(`/pools/v2/volume/${poolId}/chart`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/search/index.ts b/packages/core/src/apis/osmosisHistorical/search/index.ts index 78d2075..bfe5c1e 100644 --- a/packages/core/src/apis/osmosisHistorical/search/index.ts +++ b/packages/core/src/apis/osmosisHistorical/search/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { SearchDenomResponse, SearchExponentResponse, @@ -11,44 +11,38 @@ export type { SearchSymbolResponse, }; -export const getSearchDenom = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return ( - await osmosisInstance.get("/search/v1/denom", { - params: { - symbol, - }, - }) - ).data; -}; +export const getSearchDenom = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return ( + await instance.get("/search/v1/denom", { + params: { + symbol, + }, + }) + ).data; + }; -export const getSearchSymbol = async ({ - denom, -}: { - denom: string; -}): Promise => { - return ( - await osmosisInstance.get("/search/v1/symbol", { - params: { - denom, - }, - }) - ).data; -}; +export const getSearchSymbol = + (instance: AxiosInstance) => + async ({ denom }: { denom: string }): Promise => { + return ( + await instance.get("/search/v1/symbol", { + params: { + denom, + }, + }) + ).data; + }; -export const getSearchExponent = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return ( - await osmosisInstance.get("/search/v1/exponent", { - params: { - symbol, - }, - }) - ).data; -}; +export const getSearchExponent = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return ( + await instance.get("/search/v1/exponent", { + params: { + symbol, + }, + }) + ).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/supply/index.ts b/packages/core/src/apis/osmosisHistorical/supply/index.ts index b8e83e5..1eb9af5 100644 --- a/packages/core/src/apis/osmosisHistorical/supply/index.ts +++ b/packages/core/src/apis/osmosisHistorical/supply/index.ts @@ -1,12 +1,14 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { SupplyResponse } from "./types"; export type { SupplyResponse }; -export const getSupplyOsmo = async (): Promise => { - return (await osmosisInstance.get("/supply/v1/osmo")).data; -}; +export const getSupplyOsmo = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/supply/v1/osmo")).data; + }; -export const getSupplyIon = async (): Promise => { - return (await osmosisInstance.get("/supply/v1/ion")).data; -}; +export const getSupplyIon = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/supply/v1/ion")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/tokens/index.ts b/packages/core/src/apis/osmosisHistorical/tokens/index.ts index 5a9728c..5403ef4 100644 --- a/packages/core/src/apis/osmosisHistorical/tokens/index.ts +++ b/packages/core/src/apis/osmosisHistorical/tokens/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { TokenCountResponse, TokensHistoricalChartParams, @@ -29,101 +29,109 @@ export type { TokensVolumeChartByPoolResponse, }; -export const getAllTokens = async (): Promise => { - return (await osmosisInstance.get("/tokens/v2/all")).data; -}; +export const getAllTokens = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/tokens/v2/all")).data; + }; export const getTokensMarketCap = - async (): Promise => { - return (await osmosisInstance.get("/tokens/v2/mcap")).data; + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/tokens/v2/mcap")).data; }; -export const getToken = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/${symbol}`)).data; -}; +export const getToken = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return (await instance.get(`/tokens/v2/${symbol}`)).data; + }; -export const getTokenHistoricalChart = async ({ - symbol, -}: TokensHistoricalChartParams): Promise => { - return (await osmosisInstance.get(`/tokens/v2/historical/${symbol}/chart`)) - .data; -}; +export const getTokenHistoricalChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: TokensHistoricalChartParams): Promise => { + return (await instance.get(`/tokens/v2/historical/${symbol}/chart`)).data; + }; -export const getTokenLiquidityChart = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/liquidity/${symbol}/chart`)) - .data; -}; +export const getTokenLiquidityChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: { + symbol: string; + }): Promise => { + return (await instance.get(`/tokens/v2/liquidity/${symbol}/chart`)).data; + }; -export const getTokenVolumeChart = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/volume/${symbol}/chart`)).data; -}; +export const getTokenVolumeChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: { + symbol: string; + }): Promise => { + return (await instance.get(`/tokens/v2/volume/${symbol}/chart`)).data; + }; -export const getTokenPrice = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/price/${symbol}`)).data; -}; +export const getTokenPrice = + (instance: AxiosInstance) => + async ({ symbol }: { symbol: string }): Promise => { + return (await instance.get(`/tokens/v2/price/${symbol}`)).data; + }; -export const getTokensTop = async ({ - type, -}: { - type: "gainer" | "losers"; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/top/${type}`)).data; -}; +export const getTokensTop = + (instance: AxiosInstance) => + async ({ + type, + }: { + type: "gainer" | "losers"; + }): Promise => { + return (await instance.get(`/tokens/v2/top/${type}`)).data; + }; -export const getTokensCount = async ({ - poolId, - rangeStart, - rangeStop, -}: { - poolId: string; - rangeStart: string; - rangeStop: string; -}): Promise => { - return ( - await osmosisInstance.get(`/tokens/v2/count/${poolId}`, { - params: { - range_start: rangeStart, - range_stop: rangeStop, - }, - }) - ).data; -}; +export const getTokensCount = + (instance: AxiosInstance) => + async ({ + poolId, + rangeStart, + rangeStop, + }: { + poolId: string; + rangeStart: string; + rangeStop: string; + }): Promise => { + return ( + await instance.get(`/tokens/v2/count/${poolId}`, { + params: { + range_start: rangeStart, + range_stop: rangeStop, + }, + }) + ).data; + }; export const getTokensVolumeGlobal = + (instance: AxiosInstance) => async (): Promise => { - return (await osmosisInstance.get("/tokens/v2/volume/global")).data; + return (await instance.get("/tokens/v2/volume/global")).data; }; -export const getTokensCoinVolumeChart = async ({ - symbol, -}: { - symbol: string; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/volume/coin/${symbol}/chart`)) - .data; -}; +export const getTokensCoinVolumeChart = + (instance: AxiosInstance) => + async ({ + symbol, + }: { + symbol: string; + }): Promise => { + return (await instance.get(`/tokens/v2/volume/coin/${symbol}/chart`)).data; + }; -export const getTokensVolumeChartByPool = async ({ - poolId, -}: { - poolId: number; -}): Promise => { - return (await osmosisInstance.get(`/tokens/v2/volume/${poolId}/coin/chart`)) - .data; -}; +export const getTokensVolumeChartByPool = + (instance: AxiosInstance) => + async ({ + poolId, + }: { + poolId: number; + }): Promise => { + return (await instance.get(`/tokens/v2/volume/${poolId}/coin/chart`)).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/tradingview/index.ts b/packages/core/src/apis/osmosisHistorical/tradingview/index.ts index 565c0fa..f12da33 100644 --- a/packages/core/src/apis/osmosisHistorical/tradingview/index.ts +++ b/packages/core/src/apis/osmosisHistorical/tradingview/index.ts @@ -1,36 +1,38 @@ // TODO: Add return types -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; -export const postTradingViewAuthorize = async (body: { - login: string; - password: string; - scope?: string; -}) => { - return (await osmosisInstance.post("/tradingview/v1/authorize", body)).data; -}; +export const postTradingViewAuthorize = + (instance: AxiosInstance) => + async (body: { login: string; password: string; scope?: string }) => { + return (await instance.post("/tradingview/v1/authorize", body)).data; + }; -export const getTradingViewSymbolInfo = async () => { - return (await osmosisInstance.get("/tradingview/v1/symbol_info")).data; -}; +export const getTradingViewSymbolInfo = + (instance: AxiosInstance) => async () => { + return (await instance.get("/tradingview/v1/symbol_info")).data; + }; -export const getTradingViewHistory = async ({ - symbol, - to, - from, - resolution, -}: { - symbol: string; - to: number; - from: number; - resolution: string; -}) => { - return ( - await osmosisInstance.get("/tradingview/v1/history", { - params: { symbol, to, from, resolution }, - }) - ).data; -}; +export const getTradingViewHistory = + (instance: AxiosInstance) => + async ({ + symbol, + to, + from, + resolution, + }: { + symbol: string; + to: number; + from: number; + resolution: string; + }) => { + return ( + await instance.get("/tradingview/v1/history", { + params: { symbol, to, from, resolution }, + }) + ).data; + }; -export const getTradingViewStreaming = async () => { - return (await osmosisInstance.get("/tradingview/v1/streaming")).data; -}; +export const getTradingViewStreaming = + (instance: AxiosInstance) => async () => { + return (await instance.get("/tradingview/v1/streaming")).data; + }; diff --git a/packages/core/src/apis/osmosisHistorical/volume/index.ts b/packages/core/src/apis/osmosisHistorical/volume/index.ts index f057d88..f2491e0 100644 --- a/packages/core/src/apis/osmosisHistorical/volume/index.ts +++ b/packages/core/src/apis/osmosisHistorical/volume/index.ts @@ -1,4 +1,4 @@ -import { osmosisInstance } from "../../../common"; +import { AxiosInstance } from "axios"; import type { TotalVolumeResponse, VolumeHistoricalChartResponse, @@ -7,10 +7,12 @@ import type { export type { TotalVolumeResponse, VolumeHistoricalChartResponse }; export const getVolumeHistoricalChart = + (instance: AxiosInstance) => async (): Promise => { - return (await osmosisInstance.get("/volume/v2/historical/chart")).data; + return (await instance.get("/volume/v2/historical/chart")).data; }; -export const getTotalVolume = async (): Promise => { - return (await osmosisInstance.get("/volume/v2/total")).data; -}; +export const getTotalVolume = + (instance: AxiosInstance) => async (): Promise => { + return (await instance.get("/volume/v2/total")).data; + }; diff --git a/packages/core/src/apis/staking/index.ts b/packages/core/src/apis/staking/index.ts index 9fc444e..5fc6716 100644 --- a/packages/core/src/apis/staking/index.ts +++ b/packages/core/src/apis/staking/index.ts @@ -1,8 +1,8 @@ -import { instance } from "../../common"; +import { AxiosInstance } from "axios"; import type { Delegation, DelegationsResponse } from "./types"; export const submitDelegation = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, delegation, @@ -11,7 +11,7 @@ export const submitDelegation = delegation?: Delegation; }): Promise => { return ( - await instance(baseURL).post( + await instance.post( `/staking/delegators/${delegatorAddress}/delegations`, { delegation, @@ -21,7 +21,7 @@ export const submitDelegation = }; export const submitUnbondingDelegation = - (baseURL: string) => + (instance: AxiosInstance) => async ({ delegatorAddress, delegation, @@ -30,7 +30,7 @@ export const submitUnbondingDelegation = delegation?: Delegation; }): Promise => { return ( - await instance(baseURL).post( + await instance.post( `/staking/delegators/${delegatorAddress}/unbonding_delegations`, { delegation, diff --git a/packages/core/src/common/cosmwasm.ts b/packages/core/src/common/cosmwasm.ts deleted file mode 100644 index 6fea461..0000000 --- a/packages/core/src/common/cosmwasm.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Buffer } from "buffer"; - -export const getUrlFromObj = (contractAddress: string, obj: object): string => { - const msg = JSON.stringify(obj); - const query = Buffer.from(msg).toString("base64"); - - return `/wasm/v1/contract/${contractAddress}/smart/${query}`; -}; - -export const getWasmDUrlFromObj = ( - contractAddress: string, - obj: object -): string => { - const msg = JSON.stringify(obj); - const query = Buffer.from(msg).toString("base64"); - - return `/cosmwasm/wasm/v1/contract/${contractAddress}/smart/${query}`; -}; diff --git a/packages/core/src/common/index.ts b/packages/core/src/common/index.ts index a2fea8b..b1120b9 100644 --- a/packages/core/src/common/index.ts +++ b/packages/core/src/common/index.ts @@ -1,2 +1 @@ export * from "./instance"; -export * from "./cosmwasm"; diff --git a/packages/core/src/common/instance.ts b/packages/core/src/common/instance.ts index c0eb673..dded88f 100644 --- a/packages/core/src/common/instance.ts +++ b/packages/core/src/common/instance.ts @@ -1,13 +1,13 @@ import axios from "axios"; import { stringify } from "qs"; -export const instance = (baseURL: string) => +const instance = (baseURL: string) => axios.create({ baseURL, - paramsSerializer(params) { - return stringify(params, { - allowDots: true, - }); + paramsSerializer: { + serialize: (params: Record) => { + return stringify(params, { allowDots: true }); + }, }, }); diff --git a/packages/core/src/getCosmosQuery.ts b/packages/core/src/getCosmosQuery.ts index 8e6592e..10a506d 100644 --- a/packages/core/src/getCosmosQuery.ts +++ b/packages/core/src/getCosmosQuery.ts @@ -1,9 +1,10 @@ import * as Staking from "./apis/staking"; import * as Cosmos from "./apis/cosmos"; +import { AxiosInstance } from "axios"; -export const getCosmosQuery = (baseURL: string | undefined) => { - const setBase = (callback: (url: string) => T) => { - return callback(baseURL ?? ""); +export const getCosmosQuery = (instance: AxiosInstance) => { + const setInstance = (callback: (instanceClient: AxiosInstance) => T) => { + return callback(instance); }; return { @@ -12,163 +13,163 @@ export const getCosmosQuery = (baseURL: string | undefined) => { * * POST `/staking/delegators/{delegatorAddr}/delegations` */ - submitDelegation: setBase(Staking.submitDelegation), + submitDelegation: setInstance(Staking.submitDelegation), /** * Submit an unbonding delegation * * POST `/staking/delegators/{delegatorAddr}/unbonding_delegations` */ - submitUnbondingDelegation: setBase(Staking.submitUnbondingDelegation), + submitUnbondingDelegation: setInstance(Staking.submitUnbondingDelegation), /** * GetLatestBlock returns the latest block. * * GET `/cosmos/base/tendermint/v1beta1/blocks/latest` */ - getLatestBlock: setBase(Cosmos.getLatestBlock), + getLatestBlock: setInstance(Cosmos.getLatestBlock), /** * GetBlockByHeight queries block for given height. * * GET `/cosmos/base/tendermint/v1beta1/blocks/{height}` */ - getBlockByHeight: setBase(Cosmos.getBlockByHeight), + getBlockByHeight: setInstance(Cosmos.getBlockByHeight), /** * GetNodeInfo queries the current node info. * * GET `/cosmos/base/tendermint/v1beta1/node_info` */ - getNodeInfo: setBase(Cosmos.getNodeInfo), + getNodeInfo: setInstance(Cosmos.getNodeInfo), /** * GetSyncing queries node syncing. * * `/cosmos/base/tendermint/v1beta1/syncing` */ - getSyncing: setBase(Cosmos.getSyncing), + getSyncing: setInstance(Cosmos.getSyncing), /** * GetLatestValidatorSet queries latest validator-set. * * GET `/cosmos/base/tendermint/v1beta1/validatorsets/latest` */ - getLatestValidatorSet: setBase(Cosmos.getLatestValidatorSet), + getLatestValidatorSet: setInstance(Cosmos.getLatestValidatorSet), /** * GetValidatorSetByHeight queries validator-set at a given height. * * GET `/cosmos/base/tendermint/v1beta1/validatorsets/{height}` */ - getValidatorSetByHeight: setBase(Cosmos.getValidatorSetByHeight), + getValidatorSetByHeight: setInstance(Cosmos.getValidatorSetByHeight), /** * SimulateTx simulates executing a transaction for estimating gas usage. * * POST `/cosmos/tx/v1beta1/simulate` */ - simulateTx: setBase(Cosmos.simulateTx), + simulateTx: setInstance(Cosmos.simulateTx), /** * GetTxsEvent fetches txs by event. * * GET `/cosmos/tx/v1beta1/txs` */ - getTxsEvent: setBase(Cosmos.getTxsEvent), + getTxsEvent: setInstance(Cosmos.getTxsEvent), /** * BroadcastTx broadcast transaction. * * POST `/cosmos/tx/v1beta1/txs` */ - broadcastTx: setBase(Cosmos.broadcastTx), + broadcastTx: setInstance(Cosmos.broadcastTx), /** * GetTxByHash fetches a tx by hash. * * GET `/cosmos/tx/v1beta1/txs/{hash}` */ - getTxByHash: setBase(Cosmos.getTxByHash), + getTxByHash: setInstance(Cosmos.getTxByHash), /** * Accounts returns all the existing accounts. * * GET `/cosmos/auth/v1beta1/accounts` */ - getAccounts: setBase(Cosmos.getAccounts), + getAccounts: setInstance(Cosmos.getAccounts), /** * Account returns account details based on address. * * GET `/cosmos/auth/v1beta1/accounts/{address}` */ - getAccountByAddress: setBase(Cosmos.getAccountByAddress), + getAccountByAddress: setInstance(Cosmos.getAccountByAddress), /** * Params queries all parameters. * * GET `/cosmos/auth/v1beta1/params` */ - getAuthParams: setBase(Cosmos.getAuthParams), + getAuthParams: setInstance(Cosmos.getAuthParams), /** * AllBalances queries the balance of all coins for a single account. * * GET `/cosmos/bank/v1beta1/balances/{address}` */ - getAllBalances: setBase(Cosmos.getAllBalances), + getAllBalances: setInstance(Cosmos.getAllBalances), /** * Balance queries the balance of a single coin for a single account. * * GET `/cosmos/bank/v1beta1/balances/{address}/{denom}` */ - getBalance: setBase(Cosmos.getBalance), + getBalance: setInstance(Cosmos.getBalance), /** * DenomOwners queries for all account addresses that own a particular token denomination. * * GET `/cosmos/bank/v1beta1/denom_owners/{denom}` */ - getDenomOwners: setBase(Cosmos.getDenomOwners), + getDenomOwners: setInstance(Cosmos.getDenomOwners), /** * DenomsMetadata queries the client metadata for all registered coin denominations. * * GET `/cosmos/bank/v1beta1/denoms_metadata` */ - getAllDenomsMetadata: setBase(Cosmos.getAllDenomsMetadata), + getAllDenomsMetadata: setInstance(Cosmos.getAllDenomsMetadata), /** * DenomsMetadata queries the client metadata of a given coin denomination. * * GET `/cosmos/bank/v1beta1/denoms_metadata/{denom}` */ - getDenomMetadata: setBase(Cosmos.getDenomMetadata), + getDenomMetadata: setInstance(Cosmos.getDenomMetadata), /** * Params queries the parameters of x/bank module. * * GET `/cosmos/bank/v1beta1/params` */ - getBankParams: setBase(Cosmos.getBankParams), + getBankParams: setInstance(Cosmos.getBankParams), /** * TotalSupply queries the total supply of all coins. * * GET `/cosmos/bank/v1beta1/supply` */ - getTotalSupply: setBase(Cosmos.getTotalSupply), + getTotalSupply: setInstance(Cosmos.getTotalSupply), /** * SupplyOf queries the supply of a single coin. * * GET `/cosmos/bank/v1beta1/supply/{denom}` */ - getSupply: setBase(Cosmos.getSupply), + getSupply: setInstance(Cosmos.getSupply), /** * CommunityPool queries the community pool coins. * * GET `/cosmos/distribution/v1beta1/community_pool` */ - getCommunityPool: setBase(Cosmos.getCommunityPool), + getCommunityPool: setInstance(Cosmos.getCommunityPool), /** * DelegationTotalRewards queries the total rewards accrued by a each validator. * * GET `/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards` */ - getDelegationTotalRewards: setBase(Cosmos.getDelegationTotalRewards), + getDelegationTotalRewards: setInstance(Cosmos.getDelegationTotalRewards), /** * DelegationRewards queries the total rewards accrued by a delegation. * * GET `/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/{validator_address}` */ - getDelegationRewards: setBase(Cosmos.getDelegationRewards), + getDelegationRewards: setInstance(Cosmos.getDelegationRewards), /** * DelegatorValidators queries the validators of a delegator. * * GET `/cosmos/distribution/v1beta1/delegators/{delegator_address}/validators` */ - getDelegatorValidatorAddresses: setBase( + getDelegatorValidatorAddresses: setInstance( Cosmos.getDelegatorValidatorAddresses ), /** @@ -176,25 +177,25 @@ export const getCosmosQuery = (baseURL: string | undefined) => { * * GET `/cosmos/distribution/v1beta1/delegators/{delegator_address}/withdraw_address` */ - getDelegatorWithdrawAddress: setBase(Cosmos.getDelegatorWithdrawAddress), + getDelegatorWithdrawAddress: setInstance(Cosmos.getDelegatorWithdrawAddress), /** * Params queries params of the distribution module. * * GET `/cosmos/distribution/v1beta1/params` */ - getDistributionParams: setBase(Cosmos.getDistributionParams), + getDistributionParams: setInstance(Cosmos.getDistributionParams), /** * ValidatorCommission queries accumulated commission for a validator. * * GET `/cosmos/distribution/v1beta1/validators/{validator_address}/commission` */ - getValidatorCommission: setBase(Cosmos.getValidatorCommission), + getValidatorCommission: setInstance(Cosmos.getValidatorCommission), /** * ValidatorOutstandingRewards queries rewards of a validator address. * * GET `/cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards` */ - getValidatorOutstandingRewards: setBase( + getValidatorOutstandingRewards: setInstance( Cosmos.getValidatorOutstandingRewards ), /** @@ -202,127 +203,127 @@ export const getCosmosQuery = (baseURL: string | undefined) => { * * GET `/cosmos/distribution/v1beta1/validators/{validator_address}/slashes` */ - getValidatorSlashes: setBase(Cosmos.getValidatorSlashes), + getValidatorSlashes: setInstance(Cosmos.getValidatorSlashes), /** * AllEvidence queries all evidence. * * GET `/cosmos/evidence/v1beta1/evidence` */ - getAllEvidence: setBase(Cosmos.getAllEvidence), + getAllEvidence: setInstance(Cosmos.getAllEvidence), /** * Evidence queries evidence based on evidence hash. * * GET `/cosmos/evidence/v1beta1/evidence/{evidence_hash}` */ - getEvidence: setBase(Cosmos.getEvidence), + getEvidence: setInstance(Cosmos.getEvidence), /** * Params queries all parameters of the gov module. * * GET `/cosmos/gov/v1beta1/params/{params_type}` */ - getGovParams: setBase(Cosmos.getGovParams), + getGovParams: setInstance(Cosmos.getGovParams), /** * Proposals queries all proposals based on given status. * * GET `/cosmos/gov/v1beta1/proposals` */ - getProposals: setBase(Cosmos.getProposals), + getProposals: setInstance(Cosmos.getProposals), /** * Proposal queries proposal details based on ProposalID. * * GET `/cosmos/gov/v1beta1/proposals/{proposal_id}` */ - getProposal: setBase(Cosmos.getProposal), + getProposal: setInstance(Cosmos.getProposal), /** * Deposits queries all deposits of a single proposal. * * GET `/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits` */ - getProposalDeposits: setBase(Cosmos.getProposalDeposits), + getProposalDeposits: setInstance(Cosmos.getProposalDeposits), /** * Deposit queries single deposit information based proposalID, depositAddr. * * GET `/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}` */ - getProposalDeposit: setBase(Cosmos.getProposalDeposit), + getProposalDeposit: setInstance(Cosmos.getProposalDeposit), /** * TallyResult queries the tally of a proposal vote. * * GET `/cosmos/gov/v1beta1/proposals/{proposal_id}/tally` */ - getProposalTally: setBase(Cosmos.getProposalTally), + getProposalTally: setInstance(Cosmos.getProposalTally), /** * Votes queries votes of a given proposal. * * GET `/cosmos/gov/v1beta1/proposals/{proposal_id}/votes` */ - getProposalVotes: setBase(Cosmos.getProposalVotes), + getProposalVotes: setInstance(Cosmos.getProposalVotes), /** * Vote queries voted information based on proposalID, voterAddr. * * GET `/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}` */ - getProposalVote: setBase(Cosmos.getProposalVote), + getProposalVote: setInstance(Cosmos.getProposalVote), /** * AnnualProvisions current minting annual provisions value. * * GET `/cosmos/mint/v1beta1/annual_provisions` */ - getAnnualProvisions: setBase(Cosmos.getAnnualProvisions), + getAnnualProvisions: setInstance(Cosmos.getAnnualProvisions), /** * Inflation returns the current minting inflation value. * * GET `/cosmos/mint/v1beta1/inflation` */ - getInflation: setBase(Cosmos.getInflation), + getInflation: setInstance(Cosmos.getInflation), /** * Params returns the total set of minting parameters. * * GET `/cosmos/mint/v1beta1/params` */ - getMintingParams: setBase(Cosmos.getMintingParams), + getMintingParams: setInstance(Cosmos.getMintingParams), /** * Params queries a specific parameter of a module, given its subspace and key. * * GET `/cosmos/params/v1beta1/params` */ - getParams: setBase(Cosmos.getParams), + getParams: setInstance(Cosmos.getParams), /** * Params queries the parameters of slashing module. * * GET `/cosmos/slashing/v1beta1/params` */ - getSlashingParams: setBase(Cosmos.getSlashingParams), + getSlashingParams: setInstance(Cosmos.getSlashingParams), /** * SigningInfos queries signing info of all validators * * GET `/cosmos/slashing/v1beta1/signing_infos` */ - getSigningInfos: setBase(Cosmos.getSigningInfos), + getSigningInfos: setInstance(Cosmos.getSigningInfos), /** * SigningInfo queries the signing info of given cons address * * GET `/cosmos/slashing/v1beta1/signing_infos/{cons_address}` */ - getSigningInfo: setBase(Cosmos.getSigningInfo), + getSigningInfo: setInstance(Cosmos.getSigningInfo), /** * DelegatorDelegations queries all delegations of a given delegator address. * * GET `/cosmos/staking/v1beta1/delegations/{delegator_addr}` */ - getDelegatorDelegations: setBase(Cosmos.getDelegatorDelegations), + getDelegatorDelegations: setInstance(Cosmos.getDelegatorDelegations), /** * Redelegations queries redelegations of given address. * * GET `/cosmos/staking/v1beta1/delegators/{delegator_addr}/redelegations` */ - getDelegatorRedelegations: setBase(Cosmos.getDelegatorRedelegations), + getDelegatorRedelegations: setInstance(Cosmos.getDelegatorRedelegations), /** * DelegatorUnbondingDelegations queries all unbonding delegations of a given delegator address. * * GET `/cosmos/staking/v1beta1/delegators/{delegator_addr}/unbonding_delegations` */ - getDelegatorUnbondingDelegations: setBase( + getDelegatorUnbondingDelegations: setInstance( Cosmos.getDelegatorUnbondingDelegations ), /** @@ -330,61 +331,61 @@ export const getCosmosQuery = (baseURL: string | undefined) => { * * GET `/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators` */ - getDelegatorValidators: setBase(Cosmos.getDelegatorValidators), + getDelegatorValidators: setInstance(Cosmos.getDelegatorValidators), /** * DelegatorValidator queries validator info for given delegator validator pair. * * GET `/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators/{validator_addr}` */ - getDelegatorValidator: setBase(Cosmos.getDelegatorValidator), + getDelegatorValidator: setInstance(Cosmos.getDelegatorValidator), /** * HistoricalInfo queries the historical info for given height. * * GET `/cosmos/staking/v1beta1/historical_info/{height}` */ - getHistoricalInfo: setBase(Cosmos.getHistoricalInfo), + getHistoricalInfo: setInstance(Cosmos.getHistoricalInfo), /** * Params queries the staking parameters. * * GET `/cosmos/staking/v1beta1/params` */ - getStakingParams: setBase(Cosmos.getStakingParams), + getStakingParams: setInstance(Cosmos.getStakingParams), /** * Pool queries the pool info. * * GET `/cosmos/staking/v1beta1/pool` */ - getPool: setBase(Cosmos.getPool), + getPool: setInstance(Cosmos.getPool), /** * Validators queries all validators that match the given status. * * GET `/cosmos/staking/v1beta1/validators` */ - getValidators: setBase(Cosmos.getValidators), + getValidators: setInstance(Cosmos.getValidators), /** * Validator queries validator info for given validator address. * * GET `/cosmos/staking/v1beta1/validators/{validator_addr}` */ - getValidator: setBase(Cosmos.getValidator), + getValidator: setInstance(Cosmos.getValidator), /** * ValidatorDelegations queries delegate info for given validator. * * GET `/cosmos/staking/v1beta1/validators/{validator_addr}/delegations` */ - getValidatorDelegations: setBase(Cosmos.getValidatorDelegations), + getValidatorDelegations: setInstance(Cosmos.getValidatorDelegations), /** * Delegation queries delegate info for given validator delegator pair. * * GET `/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr}` */ - getValidatorDelegation: setBase(Cosmos.getValidatorDelegation), + getValidatorDelegation: setInstance(Cosmos.getValidatorDelegation), /** * ValidatorUnbondingDelegations queries unbonding delegations of a validator. * * GET `/cosmos/staking/v1beta1/validators/{validator_addr}/unbonding_delegations` */ - getValidatorUnbondingDelegations: setBase( + getValidatorUnbondingDelegations: setInstance( Cosmos.getValidatorUnbondingDelegations ), /** @@ -392,7 +393,7 @@ export const getCosmosQuery = (baseURL: string | undefined) => { * * GET `/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr}/unbonding_delegation` */ - getValidatorUnbondingDelegation: setBase( + getValidatorUnbondingDelegation: setInstance( Cosmos.getValidatorUnbondingDelegation ), /** @@ -400,42 +401,42 @@ export const getCosmosQuery = (baseURL: string | undefined) => { * * GET `/cosmos/upgrade/v1beta1/applied_plan/{name}` */ - getAppliedPlan: setBase(Cosmos.getAppliedPlan), + getAppliedPlan: setInstance(Cosmos.getAppliedPlan), /** * CurrentPlan queries the current upgrade plan. * * GET `/cosmos/upgrade/v1beta1/current_plan` */ - getCurrentPlan: setBase(Cosmos.getCurrentPlan), + getCurrentPlan: setInstance(Cosmos.getCurrentPlan), /** * ModuleVersions queries the list of module versions from state. * * GET `/cosmos/upgrade/v1beta1/module_versions` */ - getModuleVersions: setBase(Cosmos.getModuleVersions), + getModuleVersions: setInstance(Cosmos.getModuleVersions), /** * UpgradedConsensusState queries the consensus state that will serve as a trusted kernel for the next version of this chain. It will only be stored at the last height of this chain. UpgradedConsensusState RPC not supported with legacy querier. * * GET `/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}` */ - getUpgradedConsensusState: setBase(Cosmos.getUpgradedConsensusState), + getUpgradedConsensusState: setInstance(Cosmos.getUpgradedConsensusState), /** * Returns list of `Authorization`, granted to the grantee by the granter. * * GET `/cosmos/authz/v1beta1/grants` */ - getGrants: setBase(Cosmos.getGrants), + getGrants: setInstance(Cosmos.getGrants), /** * Allowances returns all the grants for address. * * GET `/cosmos/feegrant/v1beta1/allowances/{grantee}` */ - getAllowances: setBase(Cosmos.getAllowances), + getAllowances: setInstance(Cosmos.getAllowances), /** * Allowance returns fee granted to the grantee by the granter. * * GET `/cosmos/feegrant/v1beta1/allowance/{granter}/{grantee}` */ - getAllowance: setBase(Cosmos.getAllowance), + getAllowance: setInstance(Cosmos.getAllowance), }; }; diff --git a/packages/core/src/getCosmwasmQuery.ts b/packages/core/src/getCosmwasmQuery.ts index 833afd5..ab10ee2 100644 --- a/packages/core/src/getCosmwasmQuery.ts +++ b/packages/core/src/getCosmwasmQuery.ts @@ -1,8 +1,9 @@ +import { AxiosInstance } from "axios"; import * as Wasm from "./apis/cosmwasm"; -export const getCosmwasmQuery = (baseURL: string | undefined) => { - const setBase = (callback: (url: string) => T) => { - return callback(baseURL ?? ""); +export const getCosmwasmQuery = (instance: AxiosInstance) => { + const setInstance = (callback: (instance: AxiosInstance) => T) => { + return callback(instance); }; return { @@ -12,10 +13,10 @@ export const getCosmwasmQuery = (baseURL: string | undefined) => { * * GET `contractAddress` */ - getQuerySmartContract: setBase(Wasm.getQuerySmartContract), + getQuerySmartContract: setInstance(Wasm.getQuerySmartContract), /** * GET `/wasm/contract/{contractAddress}/code-hash` */ - getContractCodeHash: setBase(Wasm.getContractCodeHash), + getContractCodeHash: setInstance(Wasm.getContractCodeHash), }; }; diff --git a/packages/core/src/getEvmosQuery.ts b/packages/core/src/getEvmosQuery.ts index 98cab1f..dd436e3 100644 --- a/packages/core/src/getEvmosQuery.ts +++ b/packages/core/src/getEvmosQuery.ts @@ -1,106 +1,107 @@ +import { AxiosInstance } from "axios"; import * as Evmos from "./apis/evmos"; -export const getEvmosQuery = (baseURL: string | undefined) => { - const setBase = (callback: (url: string) => T) => { - return callback(baseURL ?? ""); +export const getEvmosQuery = (instance: AxiosInstance) => { + const setInstance = (callback: (instance: AxiosInstance) => T) => { + return callback(instance); }; return { /** * GET `/evmos/claims/v1/claims_records` */ - getClaimsRecords: setBase(Evmos.getClaimsRecords), + getClaimsRecords: setInstance(Evmos.getClaimsRecords), /** * GET `/evmos/claims/v1/claims_records/{address}` */ - getClaimsRecord: setBase(Evmos.getClaimsRecord), + getClaimsRecord: setInstance(Evmos.getClaimsRecord), /** * GET `/evmos/claims/v1/params` */ - getClaimsParams: setBase(Evmos.getClaimsParams), + getClaimsParams: setInstance(Evmos.getClaimsParams), /** * GET `/evmos/claims/v1/total_unclaimed` */ - getTotalUnclaimed: setBase(Evmos.getTotalUnclaimed), + getTotalUnclaimed: setInstance(Evmos.getTotalUnclaimed), /** * GET `/evmos/epochs/v1/current_epoch` */ - getCurrentEpoch: setBase(Evmos.getCurrentEpoch), + getCurrentEpoch: setInstance(Evmos.getCurrentEpoch), /** * GET `/evmos/epochs/v1/epochs` */ - getEpochs: setBase(Evmos.getEpochs), + getEpochs: setInstance(Evmos.getEpochs), /** * GET `/evmos/erc20/v1/params` */ - getERC20Params: setBase(Evmos.getERC20Params), + getERC20Params: setInstance(Evmos.getERC20Params), /** * GET `/evmos/erc20/v1/token_pairs` */ - getTokenPairs: setBase(Evmos.getTokenPairs), + getTokenPairs: setInstance(Evmos.getTokenPairs), /** * GET `/evmos/erc20/v1/token_pairs/{token}` */ - getTokenPair: setBase(Evmos.getTokenPair), + getTokenPair: setInstance(Evmos.getTokenPair), /** * GET `/evmos/incentives/v1/allocation_meters` */ - getAllocationMeters: setBase(Evmos.getAllocationMeters), + getAllocationMeters: setInstance(Evmos.getAllocationMeters), /** * GET `/evmos/incentives/v1/allocation_meters/{denom}` */ - getAllocationMeter: setBase(Evmos.getAllocationMeter), + getAllocationMeter: setInstance(Evmos.getAllocationMeter), /** * GET `/evmos/incentives/v1/gas_meters/{contract}` */ - getGasMeters: setBase(Evmos.getGasMeters), + getGasMeters: setInstance(Evmos.getGasMeters), /** * GET `/evmos/incentives/v1/gas_meters/{contract}/{participant}` */ - getGasMeter: setBase(Evmos.getGasMeter), + getGasMeter: setInstance(Evmos.getGasMeter), /** * GET `/evmos/incentives/v1/incentives` */ - getIncentives: setBase(Evmos.getIncentives), + getIncentives: setInstance(Evmos.getIncentives), /** * GET `/evmos/incentives/v1/incentives/{contract}` */ - getIncentive: setBase(Evmos.getIncentive), + getIncentive: setInstance(Evmos.getIncentive), /** * GET `/evmos/incentives/v1/params` */ - getIncentivesParams: setBase(Evmos.getIncentivesParams), + getIncentivesParams: setInstance(Evmos.getIncentivesParams), /** * GET `/evmos/inflation/v1/circulating_supply` */ - getCirculatingSupply: setBase(Evmos.getCirculatingSupply), + getCirculatingSupply: setInstance(Evmos.getCirculatingSupply), /** * GET `/evmos/inflation/v1/epoch_mint_provision` */ - getEpochMintProvision: setBase(Evmos.getEpochMintProvision), + getEpochMintProvision: setInstance(Evmos.getEpochMintProvision), /** * GET `/evmos/inflation/v1/inflation_rate` */ - getInflationRate: setBase(Evmos.getInflationRate), + getInflationRate: setInstance(Evmos.getInflationRate), /** * GET `/evmos/inflation/v1/params` */ - getInflationParams: setBase(Evmos.getInflationParams), + getInflationParams: setInstance(Evmos.getInflationParams), /** * GET `/evmos/inflation/v1/period` */ - getInflationPeriod: setBase(Evmos.getInflationPeriod), + getInflationPeriod: setInstance(Evmos.getInflationPeriod), /** * GET `/evmos/inflation/v1/skipped_epochs` */ - getSkippedEpochs: setBase(Evmos.getSkippedEpochs), + getSkippedEpochs: setInstance(Evmos.getSkippedEpochs), /** * GET `/evmos/vesting/v1/balances/{address}` */ - getVestingBalances: setBase(Evmos.getVestingBalances), + getVestingBalances: setInstance(Evmos.getVestingBalances), /** * GET `/evmos/recovery/v1/params` */ - getRecoveryParams: setBase(Evmos.getRecoveryParams), + getRecoveryParams: setInstance(Evmos.getRecoveryParams), }; }; diff --git a/packages/core/src/getIBCQuery.ts b/packages/core/src/getIBCQuery.ts index 4865997..2521ba4 100644 --- a/packages/core/src/getIBCQuery.ts +++ b/packages/core/src/getIBCQuery.ts @@ -1,10 +1,12 @@ +import { AxiosInstance } from "axios"; import * as IBC from "./apis/ibc"; -export const getIBCQuery = (baseURL: string | undefined, isIBCGo?: boolean) => { - const setBase = ( - callback: (url: string, ibcFeatureFlag?: boolean) => T +export const getIBCQuery = (instance: AxiosInstance, isIBCGo?: boolean) => { + // todo ibcFeatureFlag 인자에 대해서 알아보기 + const setInstance = ( + callback: (instance: AxiosInstance, ibcFeatureFlag?: boolean) => T ) => { - return callback(baseURL ?? "", isIBCGo); + return callback(instance, isIBCGo); }; return { @@ -13,156 +15,156 @@ export const getIBCQuery = (baseURL: string | undefined, isIBCGo?: boolean) => { * * GET `/ibc/core/channel/v1beta1/channels` */ - getChannels: setBase(IBC.getChannels), + getChannels: setInstance(IBC.getChannels), /** * Channel queries an IBC Channel. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}` */ - getChannel: setBase(IBC.getChannel), + getChannel: setInstance(IBC.getChannel), /** * ChannelClientState queries for the client state for the channel associated with the provided channel identifiers. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state` */ - getChannelClientState: setBase(IBC.getChannelClientState), + getChannelClientState: setInstance(IBC.getChannelClientState), /** * ChannelConsensusState queries for the consensus state for the channel associated with the provided channel identifiers. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/revision/{revision_number}/height/{revision_height}` */ - getChannelConsensusState: setBase(IBC.getChannelConsensusState), + getChannelConsensusState: setInstance(IBC.getChannelConsensusState), /** * NextSequenceReceive returns the next receive sequence for a given channel. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence` */ - getNextSequenceReceive: setBase(IBC.getNextSequenceReceive), + getNextSequenceReceive: setInstance(IBC.getNextSequenceReceive), /** * PacketAcknowledgements returns all the packet acknowledgements associated with a channel. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements` */ - getPacketAcknowledgements: setBase(IBC.getPacketAcknowledgements), + getPacketAcknowledgements: setInstance(IBC.getPacketAcknowledgements), /** * PacketAcknowledgement queries a stored packet acknowledgement hash. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}` */ - getPacketAcknowledgement: setBase(IBC.getPacketAcknowledgement), + getPacketAcknowledgement: setInstance(IBC.getPacketAcknowledgement), /** * PacketCommitments returns all the packet commitments hashes associated with a channel. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments` */ - getPacketCommitments: setBase(IBC.getPacketCommitments), + getPacketCommitments: setInstance(IBC.getPacketCommitments), /** * UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a channel and sequences. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks` */ - getUnreceivedAcks: setBase(IBC.getUnreceivedAcks), + getUnreceivedAcks: setInstance(IBC.getUnreceivedAcks), /** * UnreceivedPackets returns all the unreceived IBC packets associated with a channel and sequences. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_commitment_sequences}/unreceived_packets` */ - getUnreceivedPackets: setBase(IBC.getUnreceivedPackets), + getUnreceivedPackets: setInstance(IBC.getUnreceivedPackets), /** * PacketCommitment queries a stored packet commitment hash. * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}` */ - getPacketCommitment: setBase(IBC.getPacketCommitment), + getPacketCommitment: setInstance(IBC.getPacketCommitment), /** * PacketReceipt queries if a given packet sequence has been received on the queried chain * * GET `/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}` */ - getPacketReceipt: setBase(IBC.getPacketReceipt), + getPacketReceipt: setInstance(IBC.getPacketReceipt), /** * ConnectionChannels queries all the channels associated with a connection end. * * GET `/ibc/core/channel/v1beta1/connections/{connection}/channels` */ - getConnectionChannels: setBase(IBC.getConnectionChannels), + getConnectionChannels: setInstance(IBC.getConnectionChannels), /** * ClientParams queries all parameters of the ibc client. * * GET `/ibc/client/v1beta1/params` */ - getClientParams: setBase(IBC.getClientParams), + getClientParams: setInstance(IBC.getClientParams), /** * ClientStates queries all the IBC light clients of a chain. * * GET `/ibc/core/client/v1beta1/client_states` */ - getClientStates: setBase(IBC.getClientStates), + getClientStates: setInstance(IBC.getClientStates), /** * ClientState queries an IBC light client. * * GET `/ibc/core/client/v1beta1/client_states/{client_id}` */ - getClientState: setBase(IBC.getClientState), + getClientState: setInstance(IBC.getClientState), /** * ConsensusStates queries all the consensus state associated with a given client. * * GET `/ibc/core/client/v1beta1/consensus_states/{client_id}` */ - getConsensusStates: setBase(IBC.getConsensusStates), + getConsensusStates: setInstance(IBC.getConsensusStates), /** * ConsensusState queries a consensus state associated with a client state at a given height. * * GET `/ibc/core/client/v1beta1/consensus_states/{client_id}/revision/{revision_number}/height/{revision_height}` */ - getConsensusState: setBase(IBC.getConsensusState), + getConsensusState: setInstance(IBC.getConsensusState), /** * ClientConnections queries the connection paths associated with a client state. * * GET `/ibc/core/connection/v1beta1/client_connections/{client_id} */ - getClientConnections: setBase(IBC.getClientConnections), + getClientConnections: setInstance(IBC.getClientConnections), /** * Connections queries all the IBC connections of a chain. * * GET `/ibc/core/connection/v1beta1/connections` */ - getConnections: setBase(IBC.getConnections), + getConnections: setInstance(IBC.getConnections), /** * Connection queries an IBC connection end. * * GET `/ibc/core/connection/v1beta1/connections/{connection_id}` */ - getConnection: setBase(IBC.getConnection), + getConnection: setInstance(IBC.getConnection), /** * ConnectionClientState queries the client state associated with the connection. * * GET `/ibc/core/connection/v1beta1/connections/{connection_id}/client_state` */ - getConnectionClientState: setBase(IBC.getConnectionClientState), + getConnectionClientState: setInstance(IBC.getConnectionClientState), /** * ConnectionConsensusState queries the consensus state associated with the connection. * * GET `/ibc/core/connection/v1beta1/connections/{connection_id}/consensus_state/revision/{revision_number}/height/{revision_height}` */ - getConnectionConsensusState: setBase(IBC.getConnectionConsensusState), + getConnectionConsensusState: setInstance(IBC.getConnectionConsensusState), /** * DenomTraces queries all denomination traces. * * GET `/ibc/applications/transfer/v1beta1/denom_traces` */ - getDenomTraces: setBase(IBC.getDenomTraces), + getDenomTraces: setInstance(IBC.getDenomTraces), /** * DenomTrace queries a denomination trace information. * * GET `/ibc/applications/transfer/v1beta1/denom_traces/{hash}` */ - getDenomTrace: setBase(IBC.getDenomTrace), + getDenomTrace: setInstance(IBC.getDenomTrace), /** * Params queries all parameters of the ibc-transfer module. * * GET `/ibc/applications/transfer/v1beta1/params` */ - getTransferParams: setBase(IBC.getTransferParams), + getTransferParams: setInstance(IBC.getTransferParams), }; }; diff --git a/packages/core/src/getOsmosisHistoricalQuery.ts b/packages/core/src/getOsmosisHistoricalQuery.ts index 7556bc8..576d374 100644 --- a/packages/core/src/getOsmosisHistoricalQuery.ts +++ b/packages/core/src/getOsmosisHistoricalQuery.ts @@ -1,194 +1,226 @@ +import { AxiosInstance } from "axios"; import * as OsmosisHistorical from "./apis/osmosisHistorical"; -export const getOsmosisHistoricalQuery = () => { +export const getOsmosisHistoricalQuery = (instance: AxiosInstance) => { + /** + * todo + * make axios call with default instance when instance is not given + */ + + const setInstance = (callback: (queryInstance: AxiosInstance) => T) => { + return callback(instance); + }; + return { /** * GET `/health/v1/check` */ - getHealth: OsmosisHistorical.getHealth, + getHealth: setInstance(OsmosisHistorical.getHealth), /** * GET `/overview/v1/metrics` */ - getMetrics: OsmosisHistorical.getMetrics, + getMetrics: setInstance(OsmosisHistorical.getMetrics), /** * GET `/overview/v1/message` */ - getMessage: OsmosisHistorical.getMessage, + getMessage: setInstance(OsmosisHistorical.getMessage), /** * GET `/ibc/v1/info` */ - getIbcInfo: OsmosisHistorical.getIbcInfo, + getIbcInfo: setInstance(OsmosisHistorical.getIbcInfo), /** * GET `/ibc/v1/all` */ - getAllIbc: OsmosisHistorical.getAllIbc, + getAllIbc: setInstance(OsmosisHistorical.getAllIbc), /** * GET `/ibc/v1/source/{source}/destination{destination}` */ - getIbcSourceDestination: OsmosisHistorical.getIbcSourceDestination, + getIbcSourceDestination: setInstance( + OsmosisHistorical.getIbcSourceDestination + ), /** * GET `/ibc/v1/source/{source}` */ - getIbcSource: OsmosisHistorical.getIbcSource, + getIbcSource: setInstance(OsmosisHistorical.getIbcSource), /** * GET `/ibc/v1/destination/{destination}` */ - getIbcDestination: OsmosisHistorical.getIbcDestination, + getIbcDestination: setInstance(OsmosisHistorical.getIbcDestination), /** * GET `/ibc/v1/raw` */ - getIbcRaw: OsmosisHistorical.getIbcRaw, + getIbcRaw: setInstance(OsmosisHistorical.getIbcRaw), /** * GET `/pairs/v1/summary` */ - getPairsSummary: OsmosisHistorical.getPairsSummary, + getPairsSummary: setInstance(OsmosisHistorical.getPairsSummary), /** * GET `/pairs/v1/historical/{pool_id}/chart` */ - getPairsHistoricalChart: OsmosisHistorical.getPairsHistoricalChart, + getPairsHistoricalChart: setInstance( + OsmosisHistorical.getPairsHistoricalChart + ), /** * GET `/pools/v2/all` */ - getAllPools: OsmosisHistorical.getAllPools, + getAllPools: setInstance(OsmosisHistorical.getAllPools), /** * GET `/pools/v2/{pool_id}` */ - getPool: OsmosisHistorical.getPool, + getPool: setInstance(OsmosisHistorical.getPool), /** * GET `/pools/v2/liquidity/{pool_id}/chart` */ - getPoolLiquidityChart: OsmosisHistorical.getPoolLiquidityChart, + getPoolLiquidityChart: setInstance(OsmosisHistorical.getPoolLiquidityChart), /** * GET `/pools/vs2/volume/{pool_id}/chart` */ - getPoolVolumeChart: OsmosisHistorical.getPoolVolumeChart, + getPoolVolumeChart: setInstance(OsmosisHistorical.getPoolVolumeChart), /** * GET `/tokens/v2/all` */ - getAllTokens: OsmosisHistorical.getAllTokens, + getAllTokens: setInstance(OsmosisHistorical.getAllTokens), /** * GET `/tokens/v2/mcap` */ - getTokensMarketCap: OsmosisHistorical.getTokensMarketCap, + getTokensMarketCap: setInstance(OsmosisHistorical.getTokensMarketCap), /** * GET `/tokens/v2/{symbol}` */ - getToken: OsmosisHistorical.getToken, + getToken: setInstance(OsmosisHistorical.getToken), /** * GET `/tokens/v2/historical/{symbol}/chart` */ - getTokenHistoricalChart: OsmosisHistorical.getTokenHistoricalChart, + getTokenHistoricalChart: setInstance( + OsmosisHistorical.getTokenHistoricalChart + ), /** * GET `/tokens/v2/liquidity/{symbol}/chart` */ - getTokenLiquidityChart: OsmosisHistorical.getTokenLiquidityChart, + getTokenLiquidityChart: setInstance( + OsmosisHistorical.getTokenLiquidityChart + ), /** * GET `/tokens/v2/volume/{symbol}/chart` */ - getTokenVolumeChart: OsmosisHistorical.getTokenVolumeChart, + getTokenVolumeChart: setInstance(OsmosisHistorical.getTokenVolumeChart), /** * GET `/tokens/v2/price/{symbol}` */ - getTokenPrice: OsmosisHistorical.getTokenPrice, + getTokenPrice: setInstance(OsmosisHistorical.getTokenPrice), /** * GET `/tokens/v2/top/{type}` */ - getTokensTop: OsmosisHistorical.getTokensTop, + getTokensTop: setInstance(OsmosisHistorical.getTokensTop), /** * GET `/tokens/v2/count/{pool_id}` */ - getTokensCount: OsmosisHistorical.getTokensCount, + getTokensCount: setInstance(OsmosisHistorical.getTokensCount), /** * GET `/tokens/v2/volume/global` */ - getTokensVolumeGlobal: OsmosisHistorical.getTokensVolumeGlobal, + getTokensVolumeGlobal: setInstance(OsmosisHistorical.getTokensVolumeGlobal), /** * GET `/tokens/v2/volume/coin/{symbol}/chart` */ - getTokensCoinVolumeChart: OsmosisHistorical.getTokensCoinVolumeChart, + getTokensCoinVolumeChart: setInstance( + OsmosisHistorical.getTokensCoinVolumeChart + ), /** * GET `/tokens/v2/volume/{pool_id}/coin/chart` */ - getTokensVolumeChartByPool: OsmosisHistorical.getTokensVolumeChartByPool, + getTokensVolumeChartByPool: setInstance( + OsmosisHistorical.getTokensVolumeChartByPool + ), /** * GET `/liquidity/v2/historical/chart` */ - getLiquidityHistoricalChart: OsmosisHistorical.getLiquidityHistoricalChart, + getLiquidityHistoricalChart: setInstance( + OsmosisHistorical.getLiquidityHistoricalChart + ), /** * GET `/volume/v2/historical/chart` */ - getVolumeHistoricalChart: OsmosisHistorical.getVolumeHistoricalChart, + getVolumeHistoricalChart: setInstance( + OsmosisHistorical.getVolumeHistoricalChart + ), /** * GET `/volume/v2/total` */ - getTotalVolume: OsmosisHistorical.getTotalVolume, + getTotalVolume: setInstance(OsmosisHistorical.getTotalVolume), /** * GET `/fees/v1/total` */ - getTotalFees: OsmosisHistorical.getTotalFees, + getTotalFees: setInstance(OsmosisHistorical.getTotalFees), /** * GET `/fees/v1/pools` */ - getPoolsFees: OsmosisHistorical.getPoolsFees, + getPoolsFees: setInstance(OsmosisHistorical.getPoolsFees), /** * GET `/fees/v1/{pool_id}` */ - getPoolFees: OsmosisHistorical.getPoolFees, + getPoolFees: setInstance(OsmosisHistorical.getPoolFees), /** * GET `/fees/v1/total/historical` */ - getHistoricalFees: OsmosisHistorical.getHistoricalFees, + getHistoricalFees: setInstance(OsmosisHistorical.getHistoricalFees), /** * GET `/fees/v1/historical/{pool_id}` */ - getHistoricalFee: OsmosisHistorical.getHistoricalFee, + getHistoricalFee: setInstance(OsmosisHistorical.getHistoricalFee), /** * GET `/search/v1/denom` */ - getSearchDenom: OsmosisHistorical.getSearchDenom, + getSearchDenom: setInstance(OsmosisHistorical.getSearchDenom), /** * GET `/search/v1/symbol` */ - getSearchSymbol: OsmosisHistorical.getSearchSymbol, + getSearchSymbol: setInstance(OsmosisHistorical.getSearchSymbol), /** * GET `/search/v1/exponent` */ - getSearchExponent: OsmosisHistorical.getSearchExponent, + getSearchExponent: setInstance(OsmosisHistorical.getSearchExponent), /** * GET `/apr/v2/staking` */ - getStakingAPR: OsmosisHistorical.getStakingAPR, + getStakingAPR: setInstance(OsmosisHistorical.getStakingAPR), /** * GET `/apr/v2/all` */ - getAllAPR: OsmosisHistorical.getAllAPR, + getAllAPR: setInstance(OsmosisHistorical.getAllAPR), /** * GET `/apr/v2/{pool_id}` */ - getAPR: OsmosisHistorical.getAPR, + getAPR: setInstance(OsmosisHistorical.getAPR), /** * GET `/supply/v1/osmo` */ - getSupplyOsmo: OsmosisHistorical.getSupplyOsmo, + getSupplyOsmo: setInstance(OsmosisHistorical.getSupplyOsmo), /** * GET `/supply/v1/ion` */ - getSupplyIon: OsmosisHistorical.getSupplyIon, + getSupplyIon: setInstance(OsmosisHistorical.getSupplyIon), /** * POST `/tradingview/v1/authorize` */ - postTradingViewAuthorize: OsmosisHistorical.postTradingViewAuthorize, + postTradingViewAuthorize: setInstance( + OsmosisHistorical.postTradingViewAuthorize + ), /** * GET `/tradingview/v1/symbol_info` */ - getTradingViewSymbolInfo: OsmosisHistorical.getTradingViewSymbolInfo, + getTradingViewSymbolInfo: setInstance( + OsmosisHistorical.getTradingViewSymbolInfo + ), /** * GET `/tradingview/v1/history` */ - getTradingViewHistory: OsmosisHistorical.getTradingViewHistory, + getTradingViewHistory: setInstance(OsmosisHistorical.getTradingViewHistory), /** * GET `/tradingview/v1/streaming` */ - getTradingViewStreaming: OsmosisHistorical.getTradingViewStreaming, + getTradingViewStreaming: setInstance( + OsmosisHistorical.getTradingViewStreaming + ), }; }; diff --git a/packages/core/src/getOsmosisQuery.ts b/packages/core/src/getOsmosisQuery.ts index ec928fa..25e0e3f 100644 --- a/packages/core/src/getOsmosisQuery.ts +++ b/packages/core/src/getOsmosisQuery.ts @@ -1,204 +1,205 @@ +import { AxiosInstance } from "axios"; import * as Osmosis from "./apis/osmosis"; -export const getOsmosisQuery = (baseURL: string | undefined) => { - const setBase = (callback: (url: string) => T) => { - return callback(baseURL ?? ""); +export const getOsmosisQuery = (instance: AxiosInstance) => { + const setInstance = (callback: (instance: AxiosInstance) => T) => { + return callback(instance); }; return { /** * GET `/osmosis/gamm/v1beta1/num_pools` */ - getNumPools: setBase(Osmosis.getNumPools), + getNumPools: setInstance(Osmosis.getNumPools), /** * GET `/osmosis/gamm/v1beta1/pools` */ - getPools: setBase(Osmosis.getPools), + getPools: setInstance(Osmosis.getPools), /** * GET /osmosis/gamm/v1beta1/pools/{poolId}`` */ - getPool: setBase(Osmosis.getPool), + getPool: setInstance(Osmosis.getPool), /** * GET `/osmosis/gamm/v1beta1/pools/{poolId}/params` */ - getPoolParams: setBase(Osmosis.getPoolParams), + getPoolParams: setInstance(Osmosis.getPoolParams), /** * GET `/osmosis/gamm/v1beta1/pools/{poolId}/prices` */ - getPoolPrice: setBase(Osmosis.getPoolPrice), + getPoolPrice: setInstance(Osmosis.getPoolPrice), /** * GET `/osmosis/gamm/v1beta1/pools/{poolId}/tokens` */ - getPoolTokens: setBase(Osmosis.getPoolTokens), + getPoolTokens: setInstance(Osmosis.getPoolTokens), /** * GET `/osmosis/gamm/v1beta1/pools/{poolId}/total_share` */ - getPoolTotalShare: setBase(Osmosis.getPoolTotalShare), + getPoolTotalShare: setInstance(Osmosis.getPoolTotalShare), /** * GET `/osmosis/gamm/v1beta1/total_liquidity` */ - getTotalLiquidity: setBase(Osmosis.getTotalLiquidity), + getTotalLiquidity: setInstance(Osmosis.getTotalLiquidity), /** * GET `/osmosis/gamm/v1beta1/{poolId}/estimate/swap_exact_amount_in` */ - getSwapExactAmountIn: setBase(Osmosis.getSwapExactAmountIn), + getSwapExactAmountIn: setInstance(Osmosis.getSwapExactAmountIn), /** * GET `/osmosis/gamm/v1beta1/{poolId}/estimate/swap_exact_amount_out` */ - getSwapExactAmountOut: setBase(Osmosis.getSwapExactAmountOut), + getSwapExactAmountOut: setInstance(Osmosis.getSwapExactAmountOut), /** * GET `/osmosis/epochs/v1beta1/current_epoch` */ - getCurrentEpoch: setBase(Osmosis.getCurrentEpoch), + getCurrentEpoch: setInstance(Osmosis.getCurrentEpoch), /** * GET `/osmosis/epochs/v1beta1/epochs` */ - getEpochs: setBase(Osmosis.getEpochs), + getEpochs: setInstance(Osmosis.getEpochs), /** * GET `/osmosis/pool-incentives/v1beta1/distr_info` */ - getDistrInfo: setBase(Osmosis.getDistrInfo), + getDistrInfo: setInstance(Osmosis.getDistrInfo), /** * GET `/osmosis/pool-incentives/v1beta1/gauge-ids/{pool_id}` */ - getGaugeIds: setBase(Osmosis.getGaugeIds), + getGaugeIds: setInstance(Osmosis.getGaugeIds), /** * GET `/osmosis/pool-incentives/v1beta1/incentivized_pools` */ - getIncentivizedPools: setBase(Osmosis.getIncentivizedPools), + getIncentivizedPools: setInstance(Osmosis.getIncentivizedPools), /** * GET `/osmosis/pool-incentives/v1beta1/lockable_durations` */ - getLockableDurations: setBase(Osmosis.getLockableDurations), + getLockableDurations: setInstance(Osmosis.getLockableDurations), /** * GET `/osmosis/pool-incentives/v1beta1/params` */ - getPoolIncentivesParams: setBase(Osmosis.getPoolIncentivesParams), + getPoolIncentivesParams: setInstance(Osmosis.getPoolIncentivesParams), /** * GET `/osmosis/lockup/v1beta1/account_locked_coins/{owner}` */ - getAccountLockedCoins: setBase(Osmosis.getAccountLockedCoins), + getAccountLockedCoins: setInstance(Osmosis.getAccountLockedCoins), /** * GET `/osmosis/lockup/v1beta1/account_locked_longer_duration/{owner}` */ - getAccountLockedLongerDuration: setBase( + getAccountLockedLongerDuration: setInstance( Osmosis.getAccountLockedLongerDuration ), /** * GET `/osmosis/lockup/v1beta1/account_locked_longer_duration_denom/{owner}` */ - getAccountLockedLongerDurationDenom: setBase( + getAccountLockedLongerDurationDenom: setInstance( Osmosis.getAccountLockedLongerDurationDenom ), /** * GET `/osmosis/lockup/v1beta1/account_locked_longer_duration_not_unlocking_only/{owner}` */ - getAccountLockedLongerDurationNotUnlockingOnly: setBase( + getAccountLockedLongerDurationNotUnlockingOnly: setInstance( Osmosis.getAccountLockedLongerDurationNotUnlockingOnly ), /** * GET `/osmosis/lockup/v1beta1/account_locked_pasttime/{owner}` */ - getAccountLockedPastTime: setBase(Osmosis.getAccountLockedPastTime), + getAccountLockedPastTime: setInstance(Osmosis.getAccountLockedPastTime), /** * GET `/osmosis/lockup/v1beta1/account_locked_pasttime_denom/{owner}` */ - getAccountLockedPastTimeDenom: setBase( + getAccountLockedPastTimeDenom: setInstance( Osmosis.getAccountLockedPastTimeDenom ), /** * GET `/osmosis/lockup/v1beta1/account_locked_pasttime_not_unlocking_only/{owner}` */ - getAccountLockedPastTimeNotUnlockingOnly: setBase( + getAccountLockedPastTimeNotUnlockingOnly: setInstance( Osmosis.getAccountLockedPastTimeNotUnlockingOnly ), /** * GET `/osmosis/lockup/v1beta1/account_unlockable_coins/{owner}` */ - getAccountUnlockableCoins: setBase(Osmosis.getAccountUnlockableCoins), + getAccountUnlockableCoins: setInstance(Osmosis.getAccountUnlockableCoins), /** * GET `/osmosis/lockup/v1beta1/account_unlocked_before_time/{owner}` */ - getAccountUnlockedBeforeTime: setBase(Osmosis.getAccountUnlockedBeforeTime), + getAccountUnlockedBeforeTime: setInstance(Osmosis.getAccountUnlockedBeforeTime), /** * GET `/osmosis/lockup/v1beta1/account_unlocking_coins/{owner}` */ - getAccountUnlockingCoins: setBase(Osmosis.getAccountUnlockingCoins), + getAccountUnlockingCoins: setInstance(Osmosis.getAccountUnlockingCoins), /** * GET `/osmosis/lockup/v1beta1/locked_by_id/{lock_id}` */ - getLockedById: setBase(Osmosis.getLockedById), + getLockedById: setInstance(Osmosis.getLockedById), /** * GET `/osmosis/lockup/v1beta1/locked_by_id/{lock_id}` */ - getModuleBalance: setBase(Osmosis.getModuleBalance), + getModuleBalance: setInstance(Osmosis.getModuleBalance), /** * GET `/osmosis/lockup/v1beta1/module_locked_amount` */ - getModuleLockedAmount: setBase(Osmosis.getModuleLockedAmount), + getModuleLockedAmount: setInstance(Osmosis.getModuleLockedAmount), /** * GET `/osmosis/incentives/v1beta1/active_gauges` */ - getActiveGauges: setBase(Osmosis.getActiveGauges), + getActiveGauges: setInstance(Osmosis.getActiveGauges), /** * GET `/osmosis/incentives/v1beta1/gauge_by_id/{id}` */ - getGaugeById: setBase(Osmosis.getGaugeById), + getGaugeById: setInstance(Osmosis.getGaugeById), /** * GET `/osmosis/incentives/v1beta1/gauges` */ - getGauges: setBase(Osmosis.getGauges), + getGauges: setInstance(Osmosis.getGauges), /** * GET `/osmosis/incentives/v1beta1/module_distributed_coins` */ - getModuleDistributedCoins: setBase(Osmosis.getModuleDistributedCoins), + getModuleDistributedCoins: setInstance(Osmosis.getModuleDistributedCoins), /** * GET `/osmosis/incentives/v1beta1/module_to_distribute_coins` */ - getModuleToDistributeCoins: setBase(Osmosis.getModuleToDistributeCoins), + getModuleToDistributeCoins: setInstance(Osmosis.getModuleToDistributeCoins), /** * GET `/osmosis/incentives/v1beta1/rewards_est/{owner}` */ - getRewardsEst: setBase(Osmosis.getRewardsEst), + getRewardsEst: setInstance(Osmosis.getRewardsEst), /** * GET `/osmosis/incentives/v1beta1/upcoming_gauges` */ - getUpcomingGauges: setBase(Osmosis.getUpcomingGauges), + getUpcomingGauges: setInstance(Osmosis.getUpcomingGauges), /** * GET `/osmosis/claim/v1beta1/claim_record/{address}` */ - getClaimRecord: setBase(Osmosis.getClaimRecord), + getClaimRecord: setInstance(Osmosis.getClaimRecord), /** * GET `/osmosis/claim/v1beta1/claimable_for_action/{address}/{action}` */ - getClaimableForAction: setBase(Osmosis.getClaimableForAction), + getClaimableForAction: setInstance(Osmosis.getClaimableForAction), /** * GET `/osmosis/claim/v1beta1/module_account_balance` */ - getModuleAccountBalance: setBase(Osmosis.getModuleAccountBalance), + getModuleAccountBalance: setInstance(Osmosis.getModuleAccountBalance), /** * GET `/osmosis/claim/v1beta1/params` */ - getClaimParams: setBase(Osmosis.getClaimParams), + getClaimParams: setInstance(Osmosis.getClaimParams), /** * GET `/osmosis/claim/v1beta1/total_claimable/{address}` */ - getTotalClaimable: setBase(Osmosis.getTotalClaimable), + getTotalClaimable: setInstance(Osmosis.getTotalClaimable), /** * GET `/osmosis/mint/v1beta1/epoch_provisions` */ - getEpochProvisions: setBase(Osmosis.getEpochProvisions), + getEpochProvisions: setInstance(Osmosis.getEpochProvisions), /** * GET `/osmosis/mint/v1beta1/params` */ - getMintingParams: setBase(Osmosis.getMintingParams), + getMintingParams: setInstance(Osmosis.getMintingParams), /** * GET `/osmosis/superfluid/v1beta1/superfluid_delegations/${owner}` */ - getSuperfluidDelegation: setBase(Osmosis.getSuperfluidDelegation), + getSuperfluidDelegation: setInstance(Osmosis.getSuperfluidDelegation), /** * GET `osmosis/superfluid/v1beta1/all_assets` */ - getSuperfluidAllAssets: setBase(Osmosis.getSuperfluidAllAssets), + getSuperfluidAllAssets: setInstance(Osmosis.getSuperfluidAllAssets), }; }; diff --git a/yarn.lock b/yarn.lock index a028e36..0c79607 100644 --- a/yarn.lock +++ b/yarn.lock @@ -92,7 +92,7 @@ __metadata: resolution: "@many-things/cosmos-query@workspace:packages/core" dependencies: "@types/qs": ^6.9.7 - axios: ^0.27.2 + axios: ^1.2.2 buffer: ^6.0.3 qs: ^6.11.0 typescript: ^4.8.2 @@ -620,9 +620,11 @@ __metadata: "@types/node": 18.7.14 "@types/react": 18.0.18 "@types/react-dom": 18.0.6 + axios: ^1.2.2 eslint: 8.23.0 eslint-config-next: 12.2.5 next: 12.2.5 + qs: ^6.11.0 react: 18.2.0 react-dom: 18.2.0 typescript: 4.8.2 @@ -737,13 +739,14 @@ __metadata: languageName: node linkType: hard -"axios@npm:^0.27.2": - version: 0.27.2 - resolution: "axios@npm:0.27.2" +"axios@npm:^1.2.2": + version: 1.2.2 + resolution: "axios@npm:1.2.2" dependencies: - follow-redirects: ^1.14.9 + follow-redirects: ^1.15.0 form-data: ^4.0.0 - checksum: 38cb7540465fe8c4102850c4368053c21683af85c5fdf0ea619f9628abbcb59415d1e22ebc8a6390d2bbc9b58a9806c874f139767389c862ec9b772235f06854 + proxy-from-env: ^1.1.0 + checksum: 6e357491b38426c5720f7328ecbafca3c643b03952c052d787570672ce7a9365717c2d64db4ce97cfbee3f830fa405101e360e14d0857ef7f96a9f4d814c4e03 languageName: node linkType: hard @@ -1749,7 +1752,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.14.9": +"follow-redirects@npm:^1.15.0": version: 1.15.2 resolution: "follow-redirects@npm:1.15.2" peerDependenciesMeta: @@ -3071,6 +3074,13 @@ __metadata: languageName: node linkType: hard +"proxy-from-env@npm:^1.1.0": + version: 1.1.0 + resolution: "proxy-from-env@npm:1.1.0" + checksum: ed7fcc2ba0a33404958e34d95d18638249a68c430e30fcb6c478497d72739ba64ce9810a24f53a7d921d0c065e5b78e3822759800698167256b04659366ca4d4 + languageName: node + linkType: hard + "punycode@npm:^2.1.0": version: 2.1.1 resolution: "punycode@npm:2.1.1"