How to use the @0x/contracts-dev-utils.DevUtilsContract function in @0x/contracts-dev-utils

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 / 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

60 / 100
Full package analysis

Similar packages