How to use @0x/contracts-dev-utils - 7 common examples

To help you get started, we’ve selected a few @0x/contracts-dev-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / migrations / src / migration.ts View on Github external
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(
github 0xProject / 0x-monorepo / packages / migrations / src / testnet_migrations.ts View on Github external
},
        {
            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,
    );
github 0xProject / 0x-monorepo / packages / migrations / src / testnet_migrations.ts View on Github external
{
            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(
github 0xProject / 0x-monorepo / packages / orderbook / src / utils.ts View on Github external
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
github 0xProject / 0x-monorepo / contracts / asset-proxy / src / erc20_wrapper.ts View on Github external
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(
github 0xProject / 0x-monorepo / contracts / asset-proxy / src / erc1155_proxy_wrapper.ts View on Github external
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 = [];
    }
    /**
github 0xProject / 0x-monorepo / packages / order-utils / src / order_factory.ts View on Github external
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;
    },
};

@0x/contracts-dev-utils

0x protocol specific utility contracts

Apache-2.0
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis

Similar packages