update abi-gen with new method interfaces (#2325)

* update abi-gen with new method interfaces

* wip: get all packages to build

* wip: get all packages to build

* Fix two contract wrapper calls

* Export necessary types part of the contract wrapper public interfaces

* Revive and fix wrapper_unit_tests

* Remove duplicate type

* Fix lib_exchange_rich_error_decoder tests

* Fix remaining test failures in contracts-* packages

* Prettier fixes

* remove transactionHelper

* lint and update changelogs

* Fix prettier

* Revert changes to reference docs

* Add back changelog already published and add revert changelog entry

* Add missing CHANGELOG entries

* Add missing comma

* Update mesh-rpc-client dep

* Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta

* Align package versions
This commit is contained in:
Xianny
2019-11-14 11:22:29 -05:00
committed by GitHub
parent 9d4d9ce978
commit f0d7d10fe7
198 changed files with 30021 additions and 38850 deletions

View File

@@ -9,6 +9,14 @@
{
"note": "Remove duplicate types `IndexedFilterValues`, `DecodedLogEvent`, `EventCallback`",
"pr": 2243
},
{
"note": "Added ContractFunctionObj type and supporting types",
"pr": 2325
},
{
"note": "Added AwaitTransactionSuccessOpts and SendTransactionOpts",
"pr": 2325
}
],
"timestamp": 1573159180

View File

@@ -29,11 +29,20 @@ import { default as VM } from 'ethereumjs-vm';
import PStateManager from 'ethereumjs-vm/dist/state/promisified';
import * as _ from 'lodash';
export { methodAbiToFunctionSignature } from './utils';
import { formatABIDataItem } from './utils';
export { SubscriptionManager } from './subscription_manager';
export * from './types';
export {
ContractEvent,
SendTransactionOpts,
AwaitTransactionSuccessOpts,
ContractFunctionObj,
ContractTxFunctionObj,
SubscriptionErrors,
} from './types';
export interface AbiEncoderByFunctionSignature {
[key: string]: AbiEncoder.Method;

View File

@@ -1,4 +1,6 @@
import { LogEntryEvent } from 'ethereum-types';
import { BlockParam, CallData, LogEntryEvent, TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types';
import { PromiseWithTransactionHash } from './index';
export type LogEvent = LogEntryEvent;
@@ -18,3 +20,36 @@ export enum SubscriptionErrors {
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
}
/**
* Used with `sendTransactionAsync`
* * shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
*/
export interface SendTransactionOpts {
shouldValidate?: boolean;
}
/**
* Used with `awaitTransactionSuccessAsync`
* * pollingIntervalMs: Determine polling intervals in milliseconds
* * timeoutMs: Determines timeout in milliseconds
*/
export interface AwaitTransactionSuccessOpts extends SendTransactionOpts {
pollingIntervalMs?: number;
timeoutMs?: number;
}
export interface ContractFunctionObj<T> {
callAsync(callData?: Partial<CallData>, defaultBlock?: BlockParam): Promise<T>;
getABIEncodedTransactionData(): string;
}
export interface ContractTxFunctionObj<T> extends ContractFunctionObj<T> {
sendTransactionAsync(txData?: Partial<TxData>, opts?: SendTransactionOpts): Promise<string>;
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts?: AwaitTransactionSuccessOpts,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
estimateGasAsync(txData?: Partial<TxData>): Promise<number>;
}

View File

@@ -1,4 +1,4 @@
import { DataItem } from 'ethereum-types';
import { DataItem, MethodAbi } from 'ethereum-types';
import * as _ from 'lodash';
// tslint:disable-next-line:completed-docs
@@ -23,3 +23,22 @@ export function formatABIDataItem(abi: DataItem, value: any, formatter: (type: s
return formatter(abi.type, value);
}
}
function dataItemsToABIString(dataItems: DataItem[]): string {
const types = dataItems.map(item => {
if (item.components) {
return `(${dataItemsToABIString(item.components)})`;
} else {
return item.type;
}
});
return `${types.join(',')}`;
}
/**
* Takes a MethodAbi and returns a function signature for ABI encoding/decoding
* @return a function signature as a string, e.g. 'functionName(uint256, bytes[])'
*/
export function methodAbiToFunctionSignature(methodAbi: MethodAbi): string {
const inputs = dataItemsToABIString(methodAbi.inputs);
return `${methodAbi.name}(${inputs})`;
}