aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2019-02-01 06:07:09 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-02-09 08:25:30 +0800
commit171618d32b649b976f8ecffa69cff3ef30fc7c7d (patch)
tree332f955a4882ae05c34b7f20eed9f062fe7caebc /packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts
parentf7b58e7f64dc5af1e4ac8e7159717c78f0767c85 (diff)
downloaddexon-0x-contracts-171618d32b649b976f8ecffa69cff3ef30fc7c7d.tar.gz
dexon-0x-contracts-171618d32b649b976f8ecffa69cff3ef30fc7c7d.tar.zst
dexon-0x-contracts-171618d32b649b976f8ecffa69cff3ef30fc7c7d.zip
Added comments for transaction decoder
Diffstat (limited to 'packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts')
-rw-r--r--packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts31
1 files changed, 25 insertions, 6 deletions
diff --git a/packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts b/packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts
index 441424e92..4a5a5809f 100644
--- a/packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts
+++ b/packages/contract-wrappers/src/utils/zeroex_transaction_decoder.ts
@@ -8,29 +8,48 @@ import { DeployedContractInfo, DeployedContractInfoByName, TransactionData, Tran
export class ZeroExTransactionDecoder extends TransactionDecoder {
private static _instance: ZeroExTransactionDecoder;
-
+ /**
+ * Adds a set of ABI definitions, after which transaction data targeting these ABI's can be decoded.
+ * Additional properties can be included to disambiguate similar ABI's. For example, if two functions
+ * have the same signature but different parameter names, then their ABI definitions can be disambiguated
+ * by specifying a contract name.
+ * @param abiDefinitions ABI definitions for a given contract.
+ * @param contractName Name of contract that encapsulates the ABI definitions (optional).
+ * @param deploymentInfos A collection of network/address pairs where this contract is deployed (optional).
+ */
public static addABI(
- abiArray: AbiDefinition[],
+ abiDefinitions: AbiDefinition[],
contractName: string,
deploymentInfos?: DeployedContractInfo[],
): void {
const instance = ZeroExTransactionDecoder._getInstance();
- instance.addABI(abiArray, contractName, deploymentInfos);
+ instance.addABI(abiDefinitions, contractName, deploymentInfos);
}
-
+ /**
+ * Decodes transaction data for a known ABI.
+ * @param txData hex-encoded transaction data.
+ * @param txProperties Properties about the transaction used to disambiguate similar ABI's (optional).
+ * @return Decoded transaction data. Includes: function name and signature, along with the decoded arguments.
+ */
public static decode(calldata: string, txProperties?: TransactionProperties): TransactionData {
const instance = ZeroExTransactionDecoder._getInstance();
const decodedCalldata = instance.decode(calldata, txProperties);
return decodedCalldata;
}
-
+ /**
+ * Gets instance for singleton.
+ * @return singleton instance.
+ */
private static _getInstance(): ZeroExTransactionDecoder {
if (!ZeroExTransactionDecoder._instance) {
ZeroExTransactionDecoder._instance = new ZeroExTransactionDecoder();
}
return ZeroExTransactionDecoder._instance;
}
-
+ /**
+ * Adds all known contract ABI's defined by the @0x/Artifacts package, along with known 0x
+ * contract addresses.
+ */
private constructor() {
super();
// Load addresses by contract name