diff --git a/types/web3/eth/abi.d.ts b/types/web3/eth/abi.d.ts index b103c9e4ce..dcf644e93a 100644 --- a/types/web3/eth/abi.d.ts +++ b/types/web3/eth/abi.d.ts @@ -1,6 +1,7 @@ export interface ABIDefinition { constant?: boolean; payable?: boolean; + stateMutability?: "pure" | "view" | "nonpayable" | "payable"; anonymous?: boolean; inputs?: Array<{ name: string; type: ABIDataTypes; indexed?: boolean }>; name?: string; diff --git a/types/web3/test/abi-tests.ts b/types/web3/test/abi-tests.ts new file mode 100644 index 0000000000..357c59f3c3 --- /dev/null +++ b/types/web3/test/abi-tests.ts @@ -0,0 +1,89 @@ +import { ABIDefinition } from "web3/eth/abi.d"; + +export const OLD_ABI_STANDARD: ABIDefinition[] = [ + { + constant: true, + payable: false, + inputs: [ + { + name: "paramAddress", + type: "address" + } + ], + name: "function1", + outputs: [], + type: "function" + }, { + constant: true, + payable: false, + inputs: [], + name: "removeOwner", + outputs: [ + { + name: "paramAddress", + type: "address" + } + ], + type: "function" + }, { + constant: false, + payable: false, + inputs: [], + name: "removeOwner", + outputs: [], + type: "function" + }, { + constant: false, + payable: true, + inputs: [], + name: "removeOwner", + outputs: [], + type: "function" + }, +]; + +export const NEW_ABI_STANDARD: ABIDefinition[] = [ + { + constant: true, + payable: false, + stateMutability: "view", + inputs: [ + { + name: "paramAddress", + type: "address" + } + ], + name: "function1", + outputs: [], + type: "function" + }, { + constant: true, + payable: false, + stateMutability: "pure", + inputs: [], + name: "removeOwner", + outputs: [ + { + name: "paramAddress", + type: "address" + } + ], + type: "function" + }, { + constant: false, + payable: false, + stateMutability: "nonpayable", + inputs: [], + name: "removeOwner", + outputs: [], + type: "function" + }, { + constant: false, + payable: true, + stateMutability: "payable", + inputs: [], + name: "removeOwner", + outputs: [], + type: "function" + }, +]; diff --git a/types/web3/tsconfig.json b/types/web3/tsconfig.json index 42b54fc8c5..45fb60fda4 100644 --- a/types/web3/tsconfig.json +++ b/types/web3/tsconfig.json @@ -23,6 +23,7 @@ "eth/accounts.d.ts", "eth/contract.d.ts", "eth/index.d.ts", - "eth/types.d.ts" + "eth/types.d.ts", + "test/abi-tests.ts" ] } diff --git a/types/web3/web3-tests.ts b/types/web3/web3-tests.ts index 170a8b22c3..746e199418 100644 --- a/types/web3/web3-tests.ts +++ b/types/web3/web3-tests.ts @@ -2,6 +2,7 @@ import Web3 = require("web3"); import BigNumber = require("bn.js"); import { TransactionReceipt } from "web3/types"; import PromiEvent from "web3/promiEvent"; +import { NEW_ABI_STANDARD, OLD_ABI_STANDARD } from "web3/test/abi-tests"; const contractAddress = "0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe"; @@ -125,6 +126,8 @@ web3.eth.personal.unlockAccount( // // web3.eth.abi // -------------------------------------------------------------------------- +const myContractOldAbi = new web3.eth.Contract(OLD_ABI_STANDARD); +const myContractNewAbi = new web3.eth.Contract(NEW_ABI_STANDARD); // // web3.bzz