Skip to content

Commit

Permalink
chore(api): merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyun Joong Kim authored and Hyun Joong Kim committed Aug 29, 2024
2 parents 6012d45 + fc40ba3 commit 7dbab1c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 22 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18.17.1-alpine AS base-stage

WORKDIR /usr/src/app
COPY package*.json ./

FROM base-stage AS build-stage
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
RUN npm cache clean --force && npm install
COPY . .
RUN npm run generate

FROM base-stage AS production-stage
COPY --from=build-stage /usr/src/app/.output/public ./dist
RUN npm i -g http-server

ARG PORT=3000
ENV PORT=${PORT}

WORKDIR /usr/src/app/dist

CMD http-server -p $PORT -c-1 --proxy="http://127.0.0.1:$PORT/index.html?"
19 changes: 13 additions & 6 deletions composables/transaction/useAllowance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,19 @@ export default (
});

setAllowanceStatus.value = "sending";
const receipt = await getPublicClient().waitForTransactionReceipt({
hash: setAllowanceTransactionHash.value!,
onReplaced: (replacement) => {
setAllowanceTransactionHash.value = replacement.transaction.hash;
},
});
const receipt = await retry(
() =>
getPublicClient().waitForTransactionReceipt({
hash: setAllowanceTransactionHash.value!,
onReplaced: (replacement) => {
setAllowanceTransactionHash.value = replacement.transaction.hash;
},
}),
{
retries: 3,
delay: 5_000,
}
);
await requestAllowance();

setAllowanceStatus.value = "done";
Expand Down
1 change: 1 addition & 0 deletions composables/usePortalRuntimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export const usePortalRuntimeConfig = () => {
}
: undefined,
},
hyperchainsConfig: runtimeConfig?.hyperchainsConfig,
};
};
14 changes: 8 additions & 6 deletions composables/zksync/useWithdrawalFinalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ export default (transactionInfo: ComputedRef<TransactionInfo>) => {
});

status.value = "sending";
const receipt = await onboardStore.getPublicClient().waitForTransactionReceipt({
hash: transactionHash.value!,
onReplaced: (replacement) => {
transactionHash.value = replacement.transaction.hash;
},
});
const receipt = await retry(() =>
onboardStore.getPublicClient().waitForTransactionReceipt({
hash: transactionHash.value!,
onReplaced: (replacement) => {
transactionHash.value = replacement.transaction.hash;
},
})
);

trackEvent("withdrawal-finalized", {
token: transactionInfo.value!.token.symbol,
Expand Down
2 changes: 1 addition & 1 deletion data/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const publicChains: ZkSyncNetwork[] = [
];

const getHyperchains = (): ZkSyncNetwork[] => {
const hyperchains = Hyperchains as Config;
const hyperchains = portalRuntimeConfig.hyperchainsConfig || (Hyperchains as Config);
return hyperchains.map((e) => {
const network: ZkSyncNetwork = {
...e.network,
Expand Down
8 changes: 5 additions & 3 deletions store/zksync/transactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ export const useZkSyncTransactionStatusStore = defineStore("zkSyncTransactionSta

const getDepositL2TransactionHash = async (l1TransactionHash: string) => {
const publicClient = onboardStore.getPublicClient();
const transaction = await publicClient.waitForTransactionReceipt({
hash: l1TransactionHash as Hash,
});
const transaction = await retry(() =>
publicClient.waitForTransactionReceipt({
hash: l1TransactionHash as Hash,
})
);
for (const log of transaction.logs) {
try {
const { args, eventName } = decodeEventLog({
Expand Down
11 changes: 7 additions & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { type Config as HyperchainsConfig } from "@/scripts/hyperchains/common";

export type Hash = `0x${string}`;

export type TokenPrice = number | undefined;
Expand Down Expand Up @@ -132,7 +134,7 @@ declare global {
track: (eventName: string, params?: unknown) => void;
initialized: boolean;
};
'##runtimeConfig'?: {
"##runtimeConfig"?: {
nodeType?: string;
walletConnectProjectId?: string;
ankrToken?: string;
Expand All @@ -141,8 +143,9 @@ declare global {
rudder?: {
key: string;
dataplaneUrl: string;
}
}
}
};
};
hyperchainsConfig?: HyperchainsConfig;
};
}
}
9 changes: 7 additions & 2 deletions utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@ export const silentRouterChange = (location: string, mode: "push" | "replace" =

interface RetryOptions {
retries?: number;
delay?: number;
}
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
retries: 2,
delay: 0,
};
export async function retry<T>(func: () => Promise<T>, options: RetryOptions = {}): Promise<T> {
const { retries } = Object.assign({}, DEFAULT_RETRY_OPTIONS, options);
const { retries, delay } = Object.assign({}, DEFAULT_RETRY_OPTIONS, options);
try {
return await func();
} catch (error) {
if (retries && retries > 0) {
return retry(func, { retries: retries - 1 });
if (delay) {
await new Promise((resolve) => setTimeout(resolve, delay));
}
return retry(func, { retries: retries - 1, delay });
} else {
throw error;
}
Expand Down

0 comments on commit 7dbab1c

Please sign in to comment.