Skip to content

Commit

Permalink
Rename tzktUrl to tzktApiUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
serjonya-trili committed Sep 6, 2023
1 parent ced4c35 commit 69758eb
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/types/Network.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export const MAINNET = {
export const MAINNET: Network = {
name: "mainnet",
rpcUrl: "https://prod.tcinfra.net/rpc/mainnet/",
tzktApiUrl: "https://api.mainnet.tzkt.io",
tzktExplorerUrl: "https://tzkt.io",
buyTezUrl: "https://widget.wert.io",
};

export const GHOSTNET = {
export const GHOSTNET: Network = {
name: "ghostnet",
rpcUrl: "https://ghostnet.ecadinfra.com",
tzktUrl: "https://api.ghostnet.tzkt.io",
tzktApiUrl: "https://api.ghostnet.tzkt.io",
tzktExplorerUrl: "https://ghostnet.tzkt.io",
buyTezUrl: "https://faucet.ghostnet.teztnets.xyz/",
};
Expand All @@ -19,7 +19,7 @@ export type NetworkName = string; // must be unique
export type Network = {
name: NetworkName;
rpcUrl: string;
tzktUrl: string; // TODO: rename to tzktApiUrl
tzktApiUrl: string;
tzktExplorerUrl?: string;
buyTezUrl?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/multisig/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("multisig fetch", () => {

const result = await getAllMultiSigContracts(GHOSTNET);
expect(mockedAxios.get).toBeCalledWith(
`${GHOSTNET.tzktUrl}/v1/contracts?typeHash=1963879877&codeHash=-1890025422&includeStorage=true&limit=10000`
`${GHOSTNET.tzktApiUrl}/v1/contracts?typeHash=1963879877&codeHash=-1890025422&includeStorage=true&limit=10000`
);
expect(
result.map(({ address, storage: { pending_ops, signers, threshold } }) => ({
Expand Down
4 changes: 2 additions & 2 deletions src/utils/multisig/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getAllMultiSigContracts = async (
network: Network
): Promise<RawTzktGetSameMultisigs> => {
try {
const url = `${network.tzktUrl}/v1/contracts?typeHash=${TYPE_HASH}&codeHash=${CODE_HASH}&includeStorage=true&limit=${MULTISIG_FETCH_LIMIT}`;
const url = `${network.tzktApiUrl}/v1/contracts?typeHash=${TYPE_HASH}&codeHash=${CODE_HASH}&includeStorage=true&limit=${MULTISIG_FETCH_LIMIT}`;
const { data } = await axios.get<RawTzktGetSameMultisigs>(url);

return data;
Expand All @@ -23,7 +23,7 @@ export const getPendingOperations = async (
bigMaps: number[],
network: Network
): Promise<RawTzktGetBigMapKeys> => {
const url = `${network.tzktUrl}/v1/bigmaps/keys?active=true&bigmap.in=${bigMaps.join(
const url = `${network.tzktApiUrl}/v1/bigmaps/keys?active=true&bigmap.in=${bigMaps.join(
","
)}&limit=${MULTISIG_FETCH_LIMIT}`;
const { data } = await axios.get<RawTzktGetBigMapKeys>(url);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/multisig/helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("multisig helpers", () => {
);

expect(mockedAxios.get).toBeCalledWith(
`${network.tzktUrl}/v1/bigmaps/keys?active=true&bigmap.in=0,1&limit=10000`
`${network.tzktApiUrl}/v1/bigmaps/keys?active=true&bigmap.in=0,1&limit=10000`
);

expect(result).toEqual([
Expand Down
8 changes: 4 additions & 4 deletions src/utils/tezos/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("tezos utils fetch", () => {
];
const res = await getTokenBalances(addresses, network);
expect(mockedAxios.get).toBeCalledWith(
`${network.tzktUrl}/v1/tokens/balances?account.in=${addresses.join(",")}&balance.gt=0`
`${network.tzktApiUrl}/v1/tokens/balances?account.in=${addresses.join(",")}&balance.gt=0`
);

expect(res).toEqual(response);
Expand All @@ -83,7 +83,7 @@ describe("tezos utils fetch", () => {
limit: 10,
},
{
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
}
);
});
Expand All @@ -97,7 +97,7 @@ describe("tezos utils fetch", () => {
limit: 10,
},
{
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
}
);
});
Expand All @@ -121,7 +121,7 @@ describe("tezos utils fetch", () => {
];
const res = await getAccounts(addresses, network);
expect(mockedAxios.get).toBeCalledWith(
`${network.tzktUrl}/v1/accounts?address.in=${addresses.join(",")}&select=address,balance`
`${network.tzktApiUrl}/v1/accounts?address.in=${addresses.join(",")}&select=address,balance`
);

expect(res).toEqual([
Expand Down
14 changes: 7 additions & 7 deletions src/utils/tezos/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type TzktAccount = { address: string; balance: number };

export const getAccounts = async (pkhs: string[], network: Network): Promise<TzktAccount[]> => {
const response = await axios.get<TzktAccount[]>(
`${network.tzktUrl}/v1/accounts?address.in=${pkhs.join(",")}&select=address,balance`
`${network.tzktApiUrl}/v1/accounts?address.in=${pkhs.join(",")}&select=address,balance`
);
return response.data;
};
Expand All @@ -32,7 +32,7 @@ export const getTokenBalances = async (
network: Network
): Promise<RawTokenBalance[]> => {
const response = await axios.get<RawTokenBalance[]>(
`${network.tzktUrl}/v1/tokens/balances?account.in=${pkhs.join(",")}&balance.gt=0`
`${network.tzktApiUrl}/v1/tokens/balances?account.in=${pkhs.join(",")}&balance.gt=0`
);
return response.data;
};
Expand All @@ -45,7 +45,7 @@ export const getTezTransfers = (address: string, network: Network): Promise<TezT
limit: 10,
},
{
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
}
);
};
Expand All @@ -58,7 +58,7 @@ export const getTokenTransfers = (address: string, network: Network): Promise<To
limit: 10,
},
{
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
}
);
};
Expand All @@ -74,7 +74,7 @@ export const getLastDelegation = async (
limit: 1,
},
{
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
}
).then(d => d[0]);
};
Expand All @@ -93,7 +93,7 @@ export const getTezosPriceInUSD = async (): Promise<number | null> => {

export const getLatestBlockLevel = async (network: Network): Promise<number> => {
return await blocksGetCount({
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
});
};

Expand All @@ -106,7 +106,7 @@ export const getBakers = async (network: Network): Promise<Delegate[]> => {
select: { fields: ["address,alias,stakingBalance"] },
},
{
baseUrl: network.tzktUrl,
baseUrl: network.tzktApiUrl,
}
);
};
4 changes: 2 additions & 2 deletions src/utils/tezos/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("tezos utils helpers", () => {
mockedAxios.get.mockResolvedValue(mockResponse);
const result = await addressExists(mockImplicitAddress(0).pkh, MAINNET);
expect(mockedAxios.get).toBeCalledWith(
`${MAINNET.tzktUrl}/v1/accounts/${mockImplicitAddress(0).pkh}`
`${MAINNET.tzktApiUrl}/v1/accounts/${mockImplicitAddress(0).pkh}`
);
expect(result).toEqual(true);
});
Expand All @@ -62,7 +62,7 @@ describe("tezos utils helpers", () => {
mockedAxios.get.mockResolvedValue(mockResponse);
const result = await addressExists(mockImplicitAddress(0).pkh, MAINNET);
expect(mockedAxios.get).toBeCalledWith(
`${MAINNET.tzktUrl}/v1/accounts/${mockImplicitAddress(0).pkh}`
`${MAINNET.tzktApiUrl}/v1/accounts/${mockImplicitAddress(0).pkh}`
);
expect(result).toEqual(false);
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tezos/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Network } from "../../types/Network";

export const addressExists = async (pkh: string, network: Network): Promise<boolean> => {
try {
const url = `${network.tzktUrl}/v1/accounts/${pkh}`;
const url = `${network.tzktApiUrl}/v1/accounts/${pkh}`;
const {
data: { type },
} = await axios.get<RawTzktGetAddressType>(url);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/useAssetsPolling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("useAssetsPolling", () => {
});

test("bakers", async () => {
const baseUrl = network.tzktUrl;
const baseUrl = network.tzktApiUrl;
(delegatesGet as jest.Mock).mockResolvedValue([
{ ...mockBaker(0), alias: mockBaker(0).name },
{ ...mockBaker(1), alias: mockBaker(1).name },
Expand Down

0 comments on commit 69758eb

Please sign in to comment.