Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Fix: web3 transaction verification flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Prajjawalk committed Mar 14, 2023
1 parent dc2ecdb commit 25bc5a1
Show file tree
Hide file tree
Showing 29 changed files with 39,773 additions and 78,756 deletions.
22 changes: 11 additions & 11 deletions dist/web3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/web3.min.js.map

Large diffs are not rendered by default.

31,181 changes: 27,655 additions & 3,526 deletions package-lock.json

Large diffs are not rendered by default.

6,145 changes: 6 additions & 6,139 deletions packages/@theqrl/web3-bzz/package-lock.json

Large diffs are not rendered by default.

4,022 changes: 5 additions & 4,017 deletions packages/@theqrl/web3-core-helpers/package-lock.json

Large diffs are not rendered by default.

4,485 changes: 2 additions & 4,483 deletions packages/@theqrl/web3-core-method/package-lock.json

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions packages/@theqrl/web3-core-method/src/index.js
Expand Up @@ -236,11 +236,18 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
}),
new Method({
name: 'getTransactionByHash',
call: 'zond_getTransactionByHash',
call: 'zond_getTransaction',
params: 1,
inputFormatter: [null],
outputFormatter: formatters.outputTransactionFormatter
}),
new Method({
name: "getTransactionByBlockHashAndIndex",
call: "zond_getTransactionByBlockHashAndIndex",
params: 2,
inputFormatter: [null, null],
outputFormatter: formatters.outputTransactionFormatter
}),
new Subscriptions({
name: 'subscribe',
type: 'zond',
Expand Down Expand Up @@ -287,6 +294,13 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
defer.eventEmitter,
defer.reject
);
}).then(async function(rec) {
_zondCall.getTransactionByBlockHashAndIndex(rec?.blockHash, '0x'+rec?.transactionIndex.toString(16)).then((tx)=>{
if(tx?.hash == rec.transactionHash) {
rec.status = true
}
})
return rec
})
// if CONFIRMATION listener exists check for confirmations, by setting canUnsubscribe = false
.then(async function (receipt) {
Expand Down Expand Up @@ -343,7 +357,6 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
})
// CHECK for CONTRACT DEPLOYMENT
.then(async function (receipt) {

if (isContractDeployment && !promiseResolved) {

if (!receipt.contractAddress) {
Expand Down Expand Up @@ -427,7 +440,6 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {

} else {
receiptJSON = JSON.stringify(receipt, null, 2);

if (receipt.status === false || receipt.status === '0x0') {
try {
var revertMessage = null;
Expand Down Expand Up @@ -506,7 +518,6 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
// time out the transaction if not mined after 50 blocks
.catch(function () {
timeoutCount++;

// check to see if we are http polling
if (!!isPolling) {
// polling timeout is different than transactionBlockTimeout blocks since we are triggering every second
Expand Down Expand Up @@ -580,7 +591,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
// first check if we already have a confirmed transaction
_zondCall.getTransactionReceipt(result)
.then(function (receipt) {
if (receipt && receipt.blockHash) {
if (receipt && receipt.blockHash && receipt.status === true) {
if (defer.eventEmitter.listeners('confirmation').length > 0) {
// We must keep on watching for new Blocks, if a confirmation listener is present
startWatching(receipt);
Expand Down

0 comments on commit 25bc5a1

Please sign in to comment.