Skip to content

Commit

Permalink
Merge pull request #38 from numbersprotocol/fix-transaction-not-found
Browse files Browse the repository at this point in the history
fix(run.ts): commit transaction not included
  • Loading branch information
bafu authored Jan 11, 2024
2 parents d064718 + 7143152 commit bf1200a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/nit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export async function pull(assetCid: string, blockchainInfo) {
// }
//}

export async function commit(assetCid: string, commitData: string, blockchainInfo) {
export async function commit(assetCid: string, commitData: string, blockchainInfo, confirms: number = 1) {
const commitString = addActionNameInCommit(commitData);
let r;
if (blockchainInfo.gasPrice != null) {
Expand All @@ -324,7 +324,9 @@ export async function commit(assetCid: string, commitData: string, blockchainInf
} else {
r = await blockchainInfo.contract.commit(assetCid, commitString, { gasLimit: blockchainInfo.gasLimit });
}
return r;

// Wait for the transaction to be mined
return await r.wait(confirms);
}

export async function log(assetCid: string, blockchainInfo, fromIndex: number, toIndex: number = null) {
Expand Down
10 changes: 7 additions & 3 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,14 @@ async function main() {
} else {
commitEventIndexCid = nit.assetCidMock;
}
const commitResult = await nit.commit(commitEventIndexCid, JSON.stringify(commitData), blockchain);

console.log(`Commit Tx: ${commitResult.hash}`);
console.log(`Commit Explorer: ${blockchain.explorerBaseUrl}/${commitResult.hash}`);
try {
const transactionReceipt = await nit.commit(commitEventIndexCid, JSON.stringify(commitData), blockchain);
console.log(`Commit Tx: ${transactionReceipt.transactionHash}`);
console.log(`Commit Explorer: ${blockchain.explorerBaseUrl}/${transactionReceipt.transactionHash}`);
} catch (error) {
console.error(`Transaction error: ${error}`);
}

// Reset stage
await setWorkingAssetCid("");
Expand Down

0 comments on commit bf1200a

Please sign in to comment.