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

fix(run.ts): commit transaction not included #38

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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