Skip to content

Commit

Permalink
fix: change env vars naming for api & verification urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters committed Sep 28, 2023
1 parent 5095b1b commit 7434bbf
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 47 deletions.
8 changes: 4 additions & 4 deletions packages/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import type { EnvironmentConfig } from ".";
const config: EnvironmentConfig = {
networks: [
{
apiURLv2: "http://localhost:3020",
apiUrl: "https://zksync2-testnet-explorer.zksync.dev",
apiUrl: "http://localhost:3020",
verificationApiUrl: "https://zksync2-testnet-explorer.zksync.dev",
hostnames: ["localhost"],
icon: "/images/icons/zksync-arrows.svg",
l1ExplorerUrl: "https://goerli.etherscan.io",
Expand All @@ -55,8 +55,8 @@ const config: EnvironmentConfig = {
},
// next network has been just added
{
apiURLv2: "http://localhost:3030",
apiUrl: "https://zksync2-testnet-explorer.zksync.dev",
apiUrl: "http://localhost:3030",
verificationApiUrl: "https://zksync2-testnet-explorer.zksync.dev",
hostnames: ["localhost"],
icon: "/images/icons/zksync-arrows.svg",
l1ExplorerUrl: "https://goerli.etherscan.io",
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/composables/useAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default (context = useContext()) => {

const getContractVerificationInfo = async (address: string): Promise<ContractVerificationInfo | null> => {
try {
return await $fetch(`${context.currentNetwork.value.apiUrl}/contract_verification/info/${address}`);
return await $fetch(`${context.currentNetwork.value.verificationApiUrl}/contract_verification/info/${address}`);
} catch (e) {
if (!(e instanceof FetchError) || e.response?.status !== 404) {
throw e;
Expand Down Expand Up @@ -165,7 +165,7 @@ export default (context = useContext()) => {

try {
const response: Api.Response.Account | Api.Response.Contract = await $fetch(
`${context.currentNetwork.value.apiURLv2}/address/${address}`
`${context.currentNetwork.value.apiUrl}/address/${address}`
);
if (response.type === "account") {
item.value = response;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default (context = useContext()) => {
isRequestFailed.value = false;

try {
const batch = await $fetch(`${context.currentNetwork.value.apiURLv2}/batches/${id}`);
const batch = await $fetch(`${context.currentNetwork.value.apiUrl}/batches/${id}`);
if (batch.proveTxHash) {
const proof = await getBatchNewProof(id);
batch.isProvenByNewProver = !!proof;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useBatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export type BatchListItem = Api.Response.BatchListItem;

export default (context = useContext()) => {
return useFetchCollection<Api.Response.BatchListItem>(
new URL(`/batches?toDate=${new Date().toISOString()}`, context.currentNetwork.value.apiURLv2)
new URL(`/batches?toDate=${new Date().toISOString()}`, context.currentNetwork.value.apiUrl)
);
};
2 changes: 1 addition & 1 deletion packages/app/src/composables/useBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default (context = useContext()) => {
isRequestFailed.value = false;

try {
const data = await $fetch(`${context.currentNetwork.value.apiURLv2}/blocks/${id}`);
const data = await $fetch(`${context.currentNetwork.value.apiUrl}/blocks/${id}`);
if (data.l1BatchNumber && data.proveTxHash) {
const proof = await getBatchNewProof(data.l1BatchNumber);
data.isProvenByNewProver = !!proof;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import type { BlockListItem } from "@/composables/useBlock";

export default (context = useContext()) => {
return useFetchCollection<BlockListItem>(
new URL(`/blocks?toDate=${new Date().toISOString()}`, context.currentNetwork.value.apiURLv2)
new URL(`/blocks?toDate=${new Date().toISOString()}`, context.currentNetwork.value.apiUrl)
);
};
2 changes: 1 addition & 1 deletion packages/app/src/composables/useContractABI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { checksumAddress } from "@/utils/formatters";

const retrieveAddressInfo = useMemoize(
async (address: Address, context: Context = useContext()) => {
return await $fetch(`${context.currentNetwork.value.apiUrl}/contract_verification/info/${address}`);
return await $fetch(`${context.currentNetwork.value.verificationApiUrl}/contract_verification/info/${address}`);
},
{
getKey(address: Address, context: Context = useContext()) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useContractEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default (context = useContext()) => {
isRequestFailed.value = false;

try {
const url = new URL(`/address/${params.contractAddress}/logs`, context.currentNetwork.value.apiURLv2);
const url = new URL(`/address/${params.contractAddress}/logs`, context.currentNetwork.value.apiUrl);
if (params.toDate && +new Date(params.toDate) > 0) {
url.searchParams.set("toDate", params.toDate.toISOString());
}
Expand Down
8 changes: 5 additions & 3 deletions packages/app/src/composables/useContractVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default (context = useContext()) => {
const response: {
status: ContractVerificationStatus;
error?: string;
} = await $fetch(`${context.currentNetwork.value.apiUrl}/contract_verification/${id}`);
} = await $fetch(`${context.currentNetwork.value.verificationApiUrl}/contract_verification/${id}`);
if (response.error) {
throw new ContractVerificationError(response.error, response);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ export default (context = useContext()) => {
].includes(data.codeFormat);

const { sourceCode, zkCompilerVersion, compilerVersion, ...payload } = data;
const response = await $fetch(`${context.currentNetwork.value.apiUrl}/contract_verification`, {
const response = await $fetch(`${context.currentNetwork.value.verificationApiUrl}/contract_verification`, {
method: "POST",
body: {
...payload,
Expand Down Expand Up @@ -135,7 +135,9 @@ export default (context = useContext()) => {
compilerVersions.value[compiler].isRequestPending = true;
compilerVersions.value[compiler].isRequestFailed = false;
try {
const result = await $fetch(`${context.currentNetwork.value.apiUrl}/contract_verification/${compiler}_versions`);
const result = await $fetch(
`${context.currentNetwork.value.verificationApiUrl}/contract_verification/${compiler}_versions`
);
compilerVersions.value[compiler].versions = result.sort((a: string, b: string) => {
return b.localeCompare(a, undefined, { numeric: true, sensitivity: "base" });
});
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useNetworkStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface NetworkStats {
}

export default (context = useContext()) => {
return useFetch<NetworkStats>(() => new URL(`${context.currentNetwork.value.apiURLv2}/stats`));
return useFetch<NetworkStats>(() => new URL(`${context.currentNetwork.value.apiUrl}/stats`));
};
4 changes: 2 additions & 2 deletions packages/app/src/composables/useRuntimeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NetworkConfig } from "@/configs";

export const DEFAULT_NETWORK: NetworkConfig = {
apiURLv2: "https://block-explorer-api.testnets.zksync.dev",
apiUrl: "https://zksync2-testnet-explorer.zksync.dev",
apiUrl: "https://block-explorer-api.testnets.zksync.dev",
verificationApiUrl: "https://zksync2-testnet-explorer.zksync.dev",
bridgeUrl: "https://goerli.bridge.zksync.io",
hostnames: ["https://goerli.explorer.zksync.io"],
icon: "/images/icons/zksync-arrows.svg",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default (context = useContext()) => {
if (!item.isValid) {
continue;
}
await $fetch(`${context.currentNetwork.value.apiURLv2}/${item.apiRoute}/${param}`);
await $fetch(`${context.currentNetwork.value.apiUrl}/${item.apiRoute}/${param}`);

await router.push({ name: item.routeName, params: item.routeParam });
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const retrieveToken = useMemoize(
if (tokenAddress === ETH_TOKEN.l2Address) {
return Promise.resolve(ETH_TOKEN);
}
return $fetch(`${context.currentNetwork.value.apiURLv2}/tokens/${tokenAddress}`);
return $fetch(`${context.currentNetwork.value.apiUrl}/tokens/${tokenAddress}`);
},
{
getKey(tokenAddress: Hash, context: Context = useContext()) {
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/composables/useTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ export default (context = useContext()) => {

try {
const [txResponse, txTransfers, txLogs] = await Promise.all([
$fetch<Api.Response.Transaction>(`${context.currentNetwork.value.apiURLv2}/transactions/${hash}`),
$fetch<Api.Response.Transaction>(`${context.currentNetwork.value.apiUrl}/transactions/${hash}`),
all<Api.Response.Transfer>(
new URL(`${context.currentNetwork.value.apiURLv2}/transactions/${hash}/transfers?limit=100`)
new URL(`${context.currentNetwork.value.apiUrl}/transactions/${hash}/transfers?limit=100`)
),
all<Api.Response.Log>(new URL(`${context.currentNetwork.value.apiURLv2}/transactions/${hash}/logs?limit=100`)),
all<Api.Response.Log>(new URL(`${context.currentNetwork.value.apiUrl}/transactions/${hash}/logs?limit=100`)),
]);
transaction.value = mapTransaction(txResponse, txTransfers, txLogs);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/composables/useTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export default (searchParams: ComputedRef<TransactionSearchParams>, context = us
.filter(([, value]) => !!value || value === 0)
.map(([key, value]) => [key, value.toString()])
);
return new URL(`/transactions?${new URLSearchParams(requestParams)}`, context.currentNetwork.value.apiURLv2);
return new URL(`/transactions?${new URLSearchParams(requestParams)}`, context.currentNetwork.value.apiUrl);
});
};
2 changes: 1 addition & 1 deletion packages/app/src/composables/useTransfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default (address: ComputedRef<string>, context = useContext()) => {
() =>
new URL(
`/address/${address.value}/transfers?toDate=${new Date().toISOString()}`,
context.currentNetwork.value.apiURLv2
context.currentNetwork.value.apiUrl
),
(transfer: Api.Response.Transfer): Transfer => ({
...transfer,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/configs/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type NetworkConfig = {
name: string;
icon: string;
verificationApiUrl: string;
apiUrl: string;
apiURLv2: string;
newProverUrl: string;
rpcUrl: string;
bridgeUrl?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/configs/local.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { EnvironmentConfig } from ".";
const config: EnvironmentConfig = {
networks: [
{
apiURLv2: "http://localhost:3020",
apiUrl: "https://zksync2-testnet-explorer.zksync.dev",
apiUrl: "http://localhost:3020",
verificationApiUrl: "https://zksync2-testnet-explorer.zksync.dev",
hostnames: ["localhost"],
icon: "/images/icons/zksync-arrows.svg",
l1ExplorerUrl: "https://goerli.etherscan.io",
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/configs/production.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { EnvironmentConfig } from ".";
const config: EnvironmentConfig = {
networks: [
{
apiURLv2: "https://block-explorer-api.testnets.zksync.dev",
apiUrl: "https://zksync2-testnet-explorer.zksync.dev",
apiUrl: "https://block-explorer-api.testnets.zksync.dev",
verificationApiUrl: "https://zksync2-testnet-explorer.zksync.dev",
bridgeUrl: "https://goerli.bridge.zksync.io",
hostnames: ["https://goerli.explorer.zksync.io"],
icon: "/images/icons/zksync-arrows.svg",
Expand All @@ -19,8 +19,8 @@ const config: EnvironmentConfig = {
rpcUrl: "https://testnet.era.zksync.dev",
},
{
apiURLv2: "https://block-explorer-api.mainnet.zksync.io",
apiUrl: "https://zksync2-mainnet-explorer.zksync.io",
apiUrl: "https://block-explorer-api.mainnet.zksync.io",
verificationApiUrl: "https://zksync2-mainnet-explorer.zksync.io",
bridgeUrl: "https://bridge.zksync.io",
hostnames: ["https://explorer.zksync.io"],
icon: "/images/icons/zksync-arrows.svg",
Expand Down
12 changes: 6 additions & 6 deletions packages/app/src/configs/staging.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { EnvironmentConfig } from ".";
const config: EnvironmentConfig = {
networks: [
{
apiURLv2: "https://block-explorer-api.testnets.zksync.dev",
apiUrl: "https://zksync2-testnet-explorer.zksync.dev",
apiUrl: "https://block-explorer-api.testnets.zksync.dev",
verificationApiUrl: "https://zksync2-testnet-explorer.zksync.dev",
bridgeUrl: "https://staging.goerli.bridge.zksync.dev",
hostnames: ["https://goerli.staging-scan-v2.zksync.dev"],
icon: "/images/icons/zksync-arrows.svg",
Expand All @@ -19,8 +19,8 @@ const config: EnvironmentConfig = {
rpcUrl: "https://testnet.era.zksync.dev",
},
{
apiURLv2: "https://block-explorer-api.stage.zksync.dev",
apiUrl: "https://z2-dev-api-explorer.zksync.dev",
apiUrl: "https://block-explorer-api.stage.zksync.dev",
verificationApiUrl: "https://z2-dev-api-explorer.zksync.dev",
hostnames: ["https://goerli-beta.staging-scan-v2.zksync.dev"],
icon: "/images/icons/zksync-arrows.svg",
l1ExplorerUrl: "https://goerli.etherscan.io",
Expand All @@ -34,8 +34,8 @@ const config: EnvironmentConfig = {
rpcUrl: "https://z2-dev-api.zksync.dev",
},
{
apiURLv2: "https://block-explorer-api.mainnet.zksync.io",
apiUrl: "https://zksync2-mainnet-explorer.zksync.io",
apiUrl: "https://block-explorer-api.mainnet.zksync.io",
verificationApiUrl: "https://zksync2-mainnet-explorer.zksync.io",
bridgeUrl: "https://staging.bridge.zksync.dev",
hostnames: ["https://staging-scan-v2.zksync.dev"],
icon: "/images/icons/zksync-arrows.svg",
Expand Down
6 changes: 3 additions & 3 deletions packages/app/tests/composables/useAddress.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const mockGetStorageAt = vi.fn().mockResolvedValue("0x00000000000000000000000000
vi.mock("@/composables/useContext", () => {
return {
default: () => ({
currentNetwork: computed(() => ({ apiUrl: "http://api.url", apiURLv2: "http://api2.url" })),
currentNetwork: computed(() => ({ verificationApiUrl: "http://verification.url", apiUrl: "http://api2.url" })),
getL2Provider: vi.fn().mockReturnValue({
getStorageAt: (slot: string) => mockGetStorageAt(slot),
}),
Expand Down Expand Up @@ -95,10 +95,10 @@ describe("useAddresses", () => {
const { item, getByAddress } = useAddress();
await getByAddress("0xc31f9d4cbf557b6cf0ad2af66d44c358f7fa7a1c");
expect($fetch).toBeCalledWith(
"http://api.url/contract_verification/info/0xc31f9d4cbf557b6cf0ad2af66d44c358f7fa7a1c"
"http://verification.url/contract_verification/info/0xc31f9d4cbf557b6cf0ad2af66d44c358f7fa7a1c"
);
expect($fetch).toBeCalledWith(
"http://api.url/contract_verification/info/0xc31f9d4cbf557b6cf0ad2af66d44c358f7fa7a10"
"http://verification.url/contract_verification/info/0xc31f9d4cbf557b6cf0ad2af66d44c358f7fa7a10"
);
expect(item.value).toEqual({
address: "0xc31f9d4cbf557b6cf0ad2af66d44c358f7fa7a1c",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/tests/composables/useTransaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ describe("useTransaction:", () => {
currentNetwork: {
value: {
newProverUrl: "http://prover.url",
apiURLv2: "http://api.url",
apiUrl: "http://api.url",
},
},
getL2Provider: vi.fn().mockReturnValue(provider),
Expand Down
2 changes: 1 addition & 1 deletion packages/app/tests/e2e/src/pages/base.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class BasePage {
//Debug on @id367

if (slug_element === "from-address" || slug_element === "to-address") {
return await this.getNetworkLayer(slug_element, "byTestID"); //changed in uexp-3170-transactions
return await this.getNetworkLayer(slug_element, "byTestID");
} else if (
//hint: for these types we should hardcoded L1 layer
//Debug on @id241
Expand Down
8 changes: 4 additions & 4 deletions packages/app/tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import type { Provider } from "zksync-web3";

export const GOERLI_NETWORK: NetworkConfig = {
name: "goerli",
apiUrl: "",
apiURLv2: "https://block-explorer-api.testnets.zksync.dev",
verificationApiUrl: "",
apiUrl: "https://block-explorer-api.testnets.zksync.dev",
icon: "",
l2ChainId: 280,
rpcUrl: "",
Expand All @@ -37,8 +37,8 @@ export const GOERLI_NETWORK: NetworkConfig = {
};
export const GOERLI_BETA_NETWORK: NetworkConfig = {
name: "goerli-beta",
apiUrl: "",
apiURLv2: "https://block-explorer-api.mock.zksync.dev",
verificationApiUrl: "",
apiUrl: "https://block-explorer-api.mock.zksync.dev",
icon: "",
l2ChainId: 270,
rpcUrl: "",
Expand Down

0 comments on commit 7434bbf

Please sign in to comment.