How to use the abi-decoder.decodeLogs function in abi-decoder

To help you get started, we’ve selected a few abi-decoder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mosaicdao / mosaic-contracts / test / test_lib / event_decoder.js View on Github external
}
          continue;
        }

        if (!contractAbi) {
          // ABI not found for contract.
          return;
        }

        relevantLogs.push(log);
        abiDecoder.addABI(contractAbi);
      }

      if (relevantLogs.length > 0) {
        decodedEvents = decodedEvents.concat(
          abiDecoder.decodeLogs(relevantLogs)
        );
      }

    }

    return this.getFormattedEvents(decodedEvents);
  }
};
github ostdotcom / ost-price-oracle / test / lib / event_decoder.js View on Github external
logger.error('**** No contract found for contract address: ' + txReceipt.logs[i].address + ' at log index(' + i + ') in TxHash: ' + txReceipt.transactionHash + '');
          continue;
        }

        // ABI not found
        if (!contractAbi) {
          logger.error("ABI not found for contract: "+contractAddr);
          return;
        }

        relevantLogs.push(txReceipt.logs[i]);
        abiDecoder.addABI(contractAbi);
      }

      if(relevantLogs.length > 0) {
        decodedEvents = abiDecoder.decodeLogs(relevantLogs);
      }

    }

    return this.getFormattedEvents(decodedEvents);
  }
github SpankChain / chainsaw / output / chainsaw.js View on Github external
logs.push(logsInTheBlock.map(log => {
        log = log.filter(a => this.contractAddresses.indexOf(a.address) >= 0);
        let decodedLogs = abiDecoder.decodeLogs(log);
        // Formating decoded logs to add extra data needed.
        decodedLogs = decodedLogs.map((dLog, i) => {
          return this.constructLogs(dLog, i, log, logsInTheBlock);
        });
        return decodedLogs;
      }).filter(a => a.length > 0));
    }
github dharmaprotocol / dharma.js / __test__ / integration / token_api.spec.ts View on Github external
test("should emit log indicating transfer success", async () => {
                    const receipt = await web3Utils.getTransactionReceiptAsync(txHash);
                    const [transferLog] = compact(ABIDecoder.decodeLogs(receipt.logs));

                    expect(transferLog.name).toBe("Transfer");
                });
github dharmaprotocol / dharma.js / __test__ / integration / order_api.spec.ts View on Github external
test("emits log indicating successful fill", async () => {
                const txHash = await orderApi.fillAsync(debtOrder);
                const receipt = await web3Wrapper.getTransactionReceiptAsync(txHash);

                const [debtOrderFilledLog] = _.compact(ABIDecoder.decodeLogs(receipt.logs));

                expect(debtOrderFilledLog.name).toBe("LogDebtOrderFilled");
            });
        });
github OpenST / openst.js / test / integration / WalletOperations.js View on Github external
0,
      0,
      0,
      0,
      config.NULL_ADDRESS,
      config.NULL_ADDRESS,
      ownerSignature.signature,
      txOptions
    );

    const txReceipt = await auxiliaryWeb3.eth.getTransactionReceipt(result.transactionHash);

    abiDecoder.addABI(abiBinProvider.getABI('GnosisSafe'));
    abiDecoder.addABI(abiBinProvider.getABI('TokenHolder'));

    const decodedResult = abiDecoder.decodeLogs(txReceipt.logs);

    const sessionsLoggedOutEvent = JSON.parse(JSON.stringify(decodedResult));

    assert.strictEqual(sessionsLoggedOutEvent[0].name, 'SessionsLoggedOut', 'Incorrect event emitted');
    assert.strictEqual(sessionsLoggedOutEvent[0].events[0].value, '2', 'Incorrect sessionwindow value');
  });
github hellobloom / share-kit / src / txUtils.ts View on Github external
export const getDecodedTxEventLogs = async (provider: string, txHash: string): Promise => {
  const httpProvider = new HttpProvider(provider)
  const ethClient = new Eth(httpProvider)
  const txReceipt = await ethClient.getTransactionReceipt(txHash)
  if (!txReceipt) {
    throw Error(`Unable to retrieve transaction receipt for hash: '${txHash}'`)
  }
  return abiDecoder.decodeLogs(txReceipt.logs) as TDecodedLog[]
}
github theoephraim / ethdevtools / src / devtools / assets / utils.js View on Github external
eth_getTransactionReceipt: (args, results, _, contracts) => {
    let params = results;
    if (results.length && results[0] && results[0].logs) {
      const decodedLogs = abiDecoder.decodeLogs(results[0].logs);
      params[0].logsDecoded = decodedLogs;
    }
    params = results.length ? results[0] : null;
    return {
      params,
    };
  },
  eth_gasPrice: (args, results) => {
github dharmaprotocol / dharma.js / src / adapters / erc721_collateralized_simple_interest / loan_adapter.ts View on Github external
.get((err, result) => {
                    if (err) {
                        reject(err);
                    }

                    ABIDecoder.addABI(collateralizer.abi);

                    const decodedResults = ABIDecoder.decodeLogs(result);

                    ABIDecoder.removeABI(collateralizer.abi);

                    const collateralReturnedEvent = _.find(decodedResults, (log: any) => {
                        const foundEvent = _.find(log.events, (event: any) => {
                            return event.name === "agreementID" && event.value === agreementId;
                        });

                        return log.name === eventName && foundEvent;
                    });

                    resolve(!_.isUndefined(collateralReturnedEvent));
                });
        });

abi-decoder

Nodejs and Javascript library for decoding data params and events from ethereum transactions"

GPL-3.0
Latest version published 4 years ago

Package Health Score

47 / 100
Full package analysis