export async function queryLogsForEvent( txHash: string, eventName: string, ): Promise<ABIDecoder.DecodedLog | undefined> { const receipt = await web3.eth.getTransactionReceipt(txHash); return _.find(ABIDecoder.decodeLogs(receipt.logs), { name: eventName }); }
before(async () => { await principalToken.setBalance.sendTransactionAsync(PAYER, Units.ether(1.1), { from: CONTRACT_OWNER, }); await principalToken.approve.sendTransactionAsync( tokenTransferProxy.address, Units.ether(1.1), { from: PAYER }, ); payerBalanceBefore = await principalToken.balanceOf.callAsync(PAYER); beneficiaryBalanceBefore = await principalToken.balanceOf.callAsync( BENEFICIARY_1, ); const txHash = await router.repay.sendTransactionAsync( agreementId, Units.ether(1.1), principalToken.address, { from: PAYER }, ); receipt = await web3.eth.getTransactionReceipt(txHash); [repaymentLog] = _.compact(ABIDecoder.decodeLogs(receipt.logs)); });
export async function submitMultiSigTransaction( multiSig: DharmaMultiSigWalletContract, contract: BaseContract, methodName: string, args: any[], txData: TxData, ): Promise<BigNumber> { ABIDecoder.addABI(multiSig.abi); const encodedTransaction = await contract.web3ContractInstance[methodName].getData.apply( null, args, ); const txHash = await multiSig.submitTransaction.sendTransactionAsync( contract.address, // Ether value - 0. new BigNumber(0), encodedTransaction, txData, ); // Get the transaction ID from the logs. const receipt = await web3.eth.getTransactionReceipt(txHash); const submission = ABIDecoder.decodeLogs(receipt.logs)[0] as DecodedLog< MultiSigSubmissionEventArgs >; const transactionId = submission.events[0].value; ABIDecoder.removeABI(multiSig.abi); return transactionId; }
protected async getLogs( txHash: string, event: string, ): Promise<ABIDecoder.DecodedLog | undefined> { const receipt = await web3.eth.getTransactionReceipt(txHash); return _.find(ABIDecoder.decodeLogs(receipt.logs), { name: event }); }
before(async () => { const txHash = await debtToken.transfer.sendTransactionAsync( TOKEN_OWNER_2, DEBT_ENTRY_1.getTokenId(), { from: TOKEN_OWNER_2 }, ); const res = await web3.eth.getTransactionReceipt(txHash); [transferLog] = ABIDecoder.decodeLogs(res.logs); });
it("should emit a log saying the debt is edited", () => { const [logReturned] = ABIDecoder.decodeLogs(res.logs); const logExpected = LogModifyEntryBeneficiary( registry.address, entry.getIssuanceHash(), entry.getBeneficiary(), BENEFICIARY_2, ); expect(logReturned).to.deep.equal(logExpected); });
it("should emit approval log", () => { const [approvalLog] = ABIDecoder.decodeLogs(res.logs); const logExpected = LogApproval( debtToken.address, TOKEN_OWNER_1, NULL_ADDRESS, DEBT_ENTRY_2.getTokenId(), ); expect(approvalLog).to.deep.equal(logExpected); });
it("should emit transfer log event", () => { const [insertRegistryLog, transferLog] = ABIDecoder.decodeLogs(res.logs); const logExpected = LogTransfer( debtToken.address, NULL_ADDRESS, DEBT_ENTRY_2.getBeneficiary(), DEBT_ENTRY_2.getTokenId(), ); expect(transferLog).to.deep.equal(logExpected); });
it("should not emit log indicating success", async () => { const txHash = await termsContract.registerTermStart.sendTransactionAsync( ARBITRARY_AGREEMENT_ID, DEBTOR, { from: MOCK_DEBT_KERNEL_ADDRESS, }, ); const receipt = await web3.eth.getTransactionReceipt(txHash); expect(_.compact(ABIDecoder.decodeLogs(receipt.logs))).to.be.empty; });
it("should emit log that collateral has been secured", async () => { const receipt = await web3.eth.getTransactionReceipt(txHash); const [collateralLockedLog] = compact(ABIDecoder.decodeLogs(receipt.logs)); expect(collateralLockedLog).to.deep.equal( CollateralLocked( collateralizer.address, scenario.agreementId, mockCollateralToken.address, scenario.expectedCollateralAmount, ), ); });