Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
convert quorum overload funcs to mapping (quorum-overloads)
Browse files Browse the repository at this point in the history
  • Loading branch information
CruzMolina committed Jul 10, 2019
1 parent e0d79a2 commit 5de5316
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/truffle-interface-adapter/lib/quorum-overloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import _ from "underscore";
export const QuorumDefinition = {
async initNetworkType (web3: Web3Shim) {
// duck punch some of web3's output formatters
getBlock(web3);
getTransaction(web3);
getTransactionReceipt(web3);
decodeParameters(web3);
overrides.getBlock(web3);
overrides.getTransaction(web3);
overrides.getTransactionReceipt(web3);
overrides.decodeParameters(web3);
}
}

const overrides = {
// The ts-ignores are ignoring the checks that are
// saying that web3.eth.getBlock is a function and doesn't
// have a `method` property, which it does

export function getBlock(web3: Web3Shim) {
"getBlock": (web3: Web3Shim) => {
// @ts-ignore
const _oldBlockFormatter = web3.eth.getBlock.method.outputFormatter;
// @ts-ignore
Expand Down Expand Up @@ -52,9 +52,9 @@ export function getBlock(web3: Web3Shim) {

return result;
};
};
},

export function getTransaction(web3: Web3Shim) {
"getTransaction": (web3: Web3Shim) => {
const _oldTransactionFormatter =
// @ts-ignore
web3.eth.getTransaction.method.outputFormatter;
Expand All @@ -77,9 +77,9 @@ export function getTransaction(web3: Web3Shim) {

return result;
};
};
},

export function getTransactionReceipt(web3: Web3Shim) {
"getTransactionReceipt": (web3: Web3Shim) => {
const _oldTransactionReceiptFormatter =
// @ts-ignore
web3.eth.getTransactionReceipt.method.outputFormatter;
Expand All @@ -102,12 +102,12 @@ export function getTransactionReceipt(web3: Web3Shim) {

return result;
};
};
},

// The primary difference between this decodeParameters function and web3's
// is that the 'Out of Gas?' zero/null bytes guard has been removed and any
// falsy bytes are interpreted as a zero value.
export function decodeParameters(web3: Web3Shim) {
"decodeParameters": (web3: Web3Shim) => {
const _oldDecodeParameters = web3.eth.abi.decodeParameters;

const ethersAbiCoder = new EthersAbi((type, value) => {
Expand Down Expand Up @@ -152,4 +152,5 @@ export function decodeParameters(web3: Web3Shim) {

return returnValue;
};
}
}
};

0 comments on commit 5de5316

Please sign in to comment.