[@types/web3] ⬆️ Solidity compilers defines stateMutability for ABIDefinition

This commit is contained in:
Thibault 2018-12-03 08:49:55 +00:00
parent c34029e6e0
commit a359aa88dd
No known key found for this signature in database
GPG Key ID: 4637DAC223508054
4 changed files with 95 additions and 1 deletions

View File

@ -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;

View File

@ -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"
},
];

View File

@ -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"
]
}

View File

@ -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