add this code to previously code you sent

async function untilTransaction(wallet: any, prevs: Transaction[]) {
return new Promise((resolve, reject) => {
let timer = setTimeout(() => {
reject(new Error('timeout'));
}, 10000);
let check = () => {
client.getTransactions(wallet.address, {limit: 11}).then((transactions: Transaction[]) => {
let news = transactions.filter(t => !prevs.find(pt => pt.prevTransactionHash == t.prevTransactionHash));
if (news.length > 0) {
clearTimeout(timer);
let tx = news[news.length - 1];
if (tx.description.type == 'generic' && tx.description.aborted) {
reject(new Error(`aborted`));
}
resolve(tx);
} else {
setTimeout(check, 200);
}
});
};
check();
});
}
and:
let prevs = await client.getTransactions(my_wallet.address, {limit: 10});
await wallet_contract.sendTransfer({
seqno,
secretKey,
messages: [
internal({
to: callingContract,
value: deployAmount,
bounce: true,
body: packed,
init: {
code: init.code,
data: init.data,
},
}),
],
});
let tx = await untilTransaction(my_wallet, prevs);
console.log(tx);

not tested yet

EDIT:
you have to add more checker to be sure you are tracking correct transaction

Jan 16, 2024, 1:34 PM

© 2024 Draquery.com All rights reserved.