Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-2501] Fix the WSOD with Aptos Connect adapter on Firefox/Safari #417

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Try to fix Aptos Connect WSOD
  • Loading branch information
xbtmatt committed Nov 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2c5fe855dd4c03cf5646686fb28cc980cb9042c3
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/.env
**/.turbo
**/.vercel
**/.env*.local
**/.env.local
**/.env.*
1 change: 1 addition & 0 deletions src/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -6,3 +6,4 @@ node_modules/
.env*.local
**/*.env*.local
.env
.vercel
Original file line number Diff line number Diff line change
@@ -182,18 +182,20 @@ export function AptosContextProvider({ children }: PropsWithChildren) {
);

const handleTransactionSubmission = useCallback(
async (
network: NetworkInfo,
trySubmit: () => Promise<{
aptos: Aptos;
functionName: EntryFunctionNames;
res: PendingTransactionResponse;
}>
) => {
async ({
network,
aptos,
functionName,
res,
}: {
network: NetworkInfo;
aptos: Aptos;
functionName: EntryFunctionNames;
res: PendingTransactionResponse;
}) => {
let response: PendingTransactionResponse | UserTransactionResponse | null = null;
let error: unknown;
try {
const { aptos, res, functionName } = await trySubmit();
response = res;
setStatus("pending");
try {
@@ -253,18 +255,16 @@ export function AptosContextProvider({ children }: PropsWithChildren) {
async (builderFn: () => Promise<EntryFunctionTransactionBuilder>) => {
if (geoblocked) return null;
if (checkNetworkAndToast(network, true)) {
const trySubmit = async () => {
const builder = await builderFn();
setStatus("prompt");
const input = builder.payloadBuilder.toInputPayload();
return adapterSignAndSubmitTxn(input).then((res) => ({
aptos: builder.aptos,
functionName: builder.payloadBuilder.functionName as EntryFunctionNames,
res,
}));
};
const builder = await builderFn();
setStatus("prompt");
const input = builder.payloadBuilder.toInputPayload();
const { aptos, functionName, res } = await adapterSignAndSubmitTxn(input).then((res) => ({
aptos: builder.aptos,
functionName: builder.payloadBuilder.functionName as EntryFunctionNames,
res,
}));

return await handleTransactionSubmission(network, trySubmit);
return await handleTransactionSubmission({ network, aptos, functionName, res });
}
return null;
},
@@ -278,20 +278,19 @@ export function AptosContextProvider({ children }: PropsWithChildren) {
async (builderFn: () => Promise<EntryFunctionTransactionBuilder>) => {
if (geoblocked) return null;
if (checkNetworkAndToast(network, true)) {
const trySubmit = async () => {
const builder = await builderFn();
setStatus("prompt");
const senderAuthenticator = await signTransaction(builder.rawTransactionInput);
return submitTransaction({
transaction: builder.rawTransactionInput,
senderAuthenticator,
}).then((res) => ({
aptos: builder.aptos,
functionName: builder.payloadBuilder.functionName as EntryFunctionNames,
res,
}));
};
return await handleTransactionSubmission(network, trySubmit);
const builder = await builderFn();
setStatus("prompt");
const senderAuthenticator = await signTransaction(builder.rawTransactionInput);
const { aptos, functionName, res } = await submitTransaction({
transaction: builder.rawTransactionInput,
senderAuthenticator,
}).then((res) => ({
aptos: builder.aptos,
functionName: builder.payloadBuilder.functionName as EntryFunctionNames,
res,
}));

return await handleTransactionSubmission({ network, aptos, functionName, res });
}
return null;
},