Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
txDefaults,
artifacts,
);
// Coordinator
const coordinator = await CoordinatorContract.deployFrom0xArtifactAsync(
artifacts.Coordinator,
provider,
txDefaults,
artifacts,
exchange.address,
chainId,
);
// Dev Utils
const devUtils = await DevUtilsContract.deployFrom0xArtifactAsync(
artifacts.DevUtils,
provider,
txDefaults,
artifacts,
exchange.address,
);
// tslint:disable-next-line:no-unused-variable
const erc1155DummyToken = await ERC1155MintableContract.deployFrom0xArtifactAsync(
artifacts.ERC1155Mintable,
provider,
txDefaults,
artifacts,
);
const erc20BridgeProxy = await ERC20BridgeProxyContract.deployFrom0xArtifactAsync(
},
{
destination: deployedAddresses.multiAssetProxy,
data: exchange.registerAssetProxy(erc20BridgeProxy.address).getABIEncodedTransactionData(),
},
];
const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])');
const batchTransactionData = batchTransactionEncoder.encode([
functionCalls.map(item => item.data),
functionCalls.map(item => item.destination),
functionCalls.map(() => constants.ZERO_AMOUNT),
]);
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
await DevUtilsContract.deployFrom0xArtifactAsync(
devUtilsArtifacts.DevUtils,
provider,
txDefaults,
devUtilsArtifacts,
exchange.address,
);
await CoordinatorContract.deployFrom0xArtifactAsync(
coordinatorArtifacts.Coordinator,
provider,
txDefaults,
coordinatorArtifacts,
exchange.address,
chainId,
);
{
destination: deployedAddresses.multiAssetProxy,
data: exchange.registerAssetProxy(erc20BridgeProxy.address).getABIEncodedTransactionData(),
},
];
const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])');
const batchTransactionData = batchTransactionEncoder.encode([
functionCalls.map(item => item.data),
functionCalls.map(item => item.destination),
functionCalls.map(() => constants.ZERO_AMOUNT),
]);
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
await DevUtilsContract.deployFrom0xArtifactAsync(
devUtilsArtifacts.DevUtils,
provider,
txDefaults,
devUtilsArtifacts,
exchange.address,
);
await CoordinatorContract.deployFrom0xArtifactAsync(
coordinatorArtifacts.Coordinator,
provider,
txDefaults,
coordinatorArtifacts,
exchange.address,
chainId,
);
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
import { APIOrder, SignedOrder } from '@0x/connect';
import { DevUtilsContract } from '@0x/contracts-dev-utils';
import { BigNumber } from '@0x/utils';
const devUtilsContract = new DevUtilsContract('0x0000000000000000000000000000000000000000', {
isEIP1193: true,
} as any);
export const utils = {
async getOrderHashAsync(order: APIOrder | SignedOrder): Promise {
if ((order as APIOrder).metaData) {
const apiOrder = order as APIOrder;
const orderHash =
(apiOrder.metaData as any).orderHash ||
(await devUtilsContract
.getOrderHash(apiOrder.order, new BigNumber(apiOrder.order.chainId), apiOrder.order.exchangeAddress)
.callAsync());
return orderHash;
} else {
const signedOrder = order as SignedOrder;
const orderHash = await devUtilsContract
constructor(provider: ZeroExProvider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._dummyTokenContracts = [];
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
this._devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider);
}
public async deployDummyTokensAsync(
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._web3Wrapper = new Web3Wrapper(provider);
this._provider = provider;
const allArtifacts = _.merge(artifacts, erc1155Artifacts);
this._logDecoder = new LogDecoder(this._web3Wrapper, allArtifacts);
this._dummyTokenWrappers = [];
this._assetProxyInterface = new IAssetProxyContract(constants.NULL_ADDRESS, provider);
this._devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider);
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
this._fungibleTokenIds = [];
this._nonFungibleTokenIds = [];
this._nfts = [];
}
/**
takerAssetAmount: BigNumber,
takerAssetData: string,
exchangeAddress: string,
createOrderOpts?: CreateOrderOpts,
): Promise {
const order = orderFactory.createOrder(
makerAddress,
makerAssetAmount,
makerAssetData,
takerAssetAmount,
takerAssetData,
exchangeAddress,
await providerUtils.getChainIdAsync(supportedProvider),
createOrderOpts,
);
const orderHash = await new DevUtilsContract('0x0000000000000000000000000000000000000000', {
isEIP1193: true,
} as any)
.getOrderHash(order, new BigNumber(order.chainId), order.exchangeAddress)
.callAsync();
const signature = await signatureUtils.ecSignHashAsync(supportedProvider, orderHash, makerAddress);
const signedOrder: SignedOrder = _.assign(order, { signature });
return signedOrder;
},
};