Skip to content

Commit

Permalink
wait for tx success
Browse files Browse the repository at this point in the history
  • Loading branch information
kevtechi committed Nov 29, 2024
1 parent ffed993 commit 2740255
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
"typescript": "^5.6.3",
"zustand": "^4.5.2"
}
}
}
19 changes: 0 additions & 19 deletions src/deeplink/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,3 @@ export const generateLegacyReceiveLink = (

return `${baseUrl}/#/?alias=${alias}&receiveParams=${compressedParams}`;
};

export const generateReceiveLink = (
baseUrl: string,
account: string,
alias: string,
amount?: string,
description?: string
): string => {
let url = `${baseUrl}/?sendto=${account}@${alias}`;
if (amount) {
url += `&amount=${amount}`;
}

if (description) {
url += `&description=${encodeURIComponent(description)}`;
}

return url;
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export * from "./ipfs";
export * from "./vouchers";
export * from "./deeplink";
export * from "./accounts";
export * from "./receive";
export * from "./transactions";
18 changes: 18 additions & 0 deletions src/receive/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const generateReceiveLink = (
baseUrl: string,
account: string,
alias: string,
amount?: string,
description?: string
): string => {
let url = `${baseUrl}/?sendto=${account}@${alias}`;
if (amount) {
url += `&amount=${amount}`;
}

if (description) {
url += `&description=${encodeURIComponent(description)}`;
}

return url;
};
21 changes: 21 additions & 0 deletions src/transactions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { CommunityConfig } from "../index.ts";

Check failure on line 1 in src/transactions/index.ts

View workflow job for this annotation

GitHub Actions / build-and-tag

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import { JsonRpcProvider } from "ethers";

export const waitForTxSuccess = async (
config: CommunityConfig,
txHash: string
): Promise<boolean> => {
try {
const rpc = new JsonRpcProvider(config.primaryRPCUrl);

const receipt = await rpc.waitForTransaction(txHash);
if (!receipt) {
throw new Error("Transaction not found");
}

return receipt.status === 1;
} catch (error) {
console.error("Error waiting for transaction:", error);
return false;
}
};

0 comments on commit 2740255

Please sign in to comment.