diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-14 17:30:51 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-14 17:30:51 +0800 |
commit | c94d1b22754c1d1bf10f0dd2b9c13eea91e17cb6 (patch) | |
tree | 986b220cf80aab8d8e8ef6c4cef8c08be6eeab10 /packages/contracts/util | |
parent | 7d60356facce60c1d4d80c703bfc565c5c47e73b (diff) | |
parent | 58fa35641d3016ef106496c929e48febcf827dc6 (diff) | |
download | dexon-sol-tools-c94d1b22754c1d1bf10f0dd2b9c13eea91e17cb6.tar.gz dexon-sol-tools-c94d1b22754c1d1bf10f0dd2b9c13eea91e17cb6.tar.zst dexon-sol-tools-c94d1b22754c1d1bf10f0dd2b9c13eea91e17cb6.zip |
Merge branch 'development' of github.com:0xProject/0x-monorepo into development
* 'development' of github.com:0xProject/0x-monorepo:
Add missing type definitions
Diffstat (limited to 'packages/contracts/util')
-rw-r--r-- | packages/contracts/util/crypto.ts | 2 | ||||
-rw-r--r-- | packages/contracts/util/formatters.ts | 6 | ||||
-rw-r--r-- | packages/contracts/util/multi_sig_wrapper.ts | 4 | ||||
-rw-r--r-- | packages/contracts/util/signed_order_utils.ts | 13 | ||||
-rw-r--r-- | packages/contracts/util/token_registry_wrapper.ts | 8 |
5 files changed, 21 insertions, 12 deletions
diff --git a/packages/contracts/util/crypto.ts b/packages/contracts/util/crypto.ts index 810072d2f..3661b3afd 100644 --- a/packages/contracts/util/crypto.ts +++ b/packages/contracts/util/crypto.ts @@ -18,7 +18,7 @@ export const crypto = { solSHA256(args: any[]): Buffer { return crypto._solHash(args, ABI.soliditySHA256); }, - _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer) { + _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer): Buffer { const argTypes: string[] = []; _.each(args, (arg, i) => { const isNumber = _.isFinite(arg); diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts index 8e0dfb09e..3e3b67495 100644 --- a/packages/contracts/util/formatters.ts +++ b/packages/contracts/util/formatters.ts @@ -9,7 +9,7 @@ export const formatters = { signedOrders: SignedOrder[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, fillTakerTokenAmounts: BigNumber[] = [], - ) { + ): BatchFillOrders { const batchFill: BatchFillOrders = { orderAddresses: [], orderValues: [], @@ -48,7 +48,7 @@ export const formatters = { signedOrders: SignedOrder[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, fillTakerTokenAmount: BigNumber, - ) { + ): FillOrdersUpTo { const fillUpTo: FillOrdersUpTo = { orderAddresses: [], orderValues: [], @@ -80,7 +80,7 @@ export const formatters = { }); return fillUpTo; }, - createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) { + createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []): BatchCancelOrders { const batchCancel: BatchCancelOrders = { orderAddresses: [], orderValues: [], diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts index 9f6dcec52..c66106b9a 100644 --- a/packages/contracts/util/multi_sig_wrapper.ts +++ b/packages/contracts/util/multi_sig_wrapper.ts @@ -11,7 +11,7 @@ import { TransactionDataParams } from './types'; export class MultiSigWrapper { private _multiSig: MultiSigWalletContract; - public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]) { + public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]): string { const abiEntity = _.find(abi, { name }) as MethodAbi; if (_.isUndefined(abiEntity)) { throw new Error(`Did not find abi entry for name: ${name}`); @@ -33,7 +33,7 @@ export class MultiSigWrapper { from: string, dataParams: TransactionDataParams, value: BigNumber = new BigNumber(0), - ) { + ): Promise<string> { const { name, abi, args = [] } = dataParams; const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args); return this._multiSig.submitTransaction.sendTransactionAsync(destination, value, encoded, { diff --git a/packages/contracts/util/signed_order_utils.ts b/packages/contracts/util/signed_order_utils.ts index fc2f800cd..30a2814e7 100644 --- a/packages/contracts/util/signed_order_utils.ts +++ b/packages/contracts/util/signed_order_utils.ts @@ -6,6 +6,15 @@ import * as _ from 'lodash'; import { crypto } from './crypto'; +interface OrderAddressesAndValues { + orderAddresses: string[]; + orderValues: BigNumber[]; +} + +interface OrderCancel extends OrderAddressesAndValues { + cancelTakerTokenAmount: BigNumber; +} + export const signedOrderUtils = { createFill: ( signedOrder: SignedOrder, @@ -20,14 +29,14 @@ export const signedOrderUtils = { }; return fill; }, - createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber) { + createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber): OrderCancel { const cancel = { ...signedOrderUtils.getOrderAddressesAndValues(signedOrder), cancelTakerTokenAmount: cancelTakerTokenAmount || signedOrder.takerTokenAmount, }; return cancel; }, - getOrderAddressesAndValues(signedOrder: SignedOrder) { + getOrderAddressesAndValues(signedOrder: SignedOrder): OrderAddressesAndValues { return { orderAddresses: [ signedOrder.maker, diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts index d78c8a64e..bed62fa53 100644 --- a/packages/contracts/util/token_registry_wrapper.ts +++ b/packages/contracts/util/token_registry_wrapper.ts @@ -9,7 +9,7 @@ export class TokenRegWrapper { constructor(tokenRegContract: TokenRegistryContract) { this._tokenReg = tokenRegContract; } - public async addTokenAsync(token: Token, from: string) { + public async addTokenAsync(token: Token, from: string): Promise<string> { const tx = this._tokenReg.addToken.sendTransactionAsync( token.address as string, token.name, @@ -21,7 +21,7 @@ export class TokenRegWrapper { ); return tx; } - public async getTokenMetaDataAsync(tokenAddress: string) { + public async getTokenMetaDataAsync(tokenAddress: string): Promise<Token> { const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress); const token: Token = { address: data[0], @@ -33,7 +33,7 @@ export class TokenRegWrapper { }; return token; } - public async getTokenByNameAsync(tokenName: string) { + public async getTokenByNameAsync(tokenName: string): Promise<Token> { const data = await this._tokenReg.getTokenByName.callAsync(tokenName); const token: Token = { address: data[0], @@ -45,7 +45,7 @@ export class TokenRegWrapper { }; return token; } - public async getTokenBySymbolAsync(tokenSymbol: string) { + public async getTokenBySymbolAsync(tokenSymbol: string): Promise<Token> { const data = await this._tokenReg.getTokenBySymbol.callAsync(tokenSymbol); const token: Token = { address: data[0], |