Xianny f0d7d10fe7
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
2019-11-14 11:22:29 -05:00

57 lines
2.0 KiB
TypeScript

import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types';
import { DeploymentManager } from '../deployment_manager';
import { Actor, Constructor } from './base';
export interface TakerInterface {
fillOrderAsync: (
order: SignedOrder,
fillAmount: BigNumber,
txData?: Partial<TxData>,
) => Promise<TransactionReceiptWithDecodedLogs>;
}
/**
* This mixin encapsulates functionaltiy associated with takers within the 0x ecosystem.
* As of writing, the only extra functionality provided is a utility wrapper around `fillOrder`,
*/
export function TakerMixin<TBase extends Constructor>(Base: TBase): TBase & Constructor<TakerInterface> {
return class extends Base {
public readonly actor: Actor;
/**
* The mixin pattern requires that this constructor uses `...args: any[]`, but this class
* really expects a single `ActorConfig` parameter (assuming `Actor` is used as the base
* class).
*/
constructor(...args: any[]) {
// tslint:disable-next-line:no-inferred-empty-object-type
super(...args);
this.actor = (this as any) as Actor;
}
/**
* Fills an order by the given `fillAmount`. Defaults to paying the protocol fee in ETH.
*/
public async fillOrderAsync(
order: SignedOrder,
fillAmount: BigNumber,
txData: Partial<TxData> = {},
): Promise<TransactionReceiptWithDecodedLogs> {
return this.actor.deployment.exchange
.fillOrder(order, fillAmount, order.signature)
.awaitTransactionSuccessAsync({
from: this.actor.address,
gasPrice: DeploymentManager.gasPrice,
value: DeploymentManager.protocolFee,
...txData,
});
}
};
}
export class Taker extends TakerMixin(Actor) {}