How to use @0x/contracts-asset-proxy - 10 common examples

To help you get started, we’ve selected a few @0x/contracts-asset-proxy 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
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(
        artifacts.ERC20BridgeProxy,
        provider,
        txDefaults,
        {},
    );
    await exchange.registerAssetProxy(erc20BridgeProxy.address).awaitTransactionSuccessAsync(txDefaults);
    await erc20BridgeProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
    await erc20BridgeProxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
    await multiAssetProxy.registerAssetProxy(erc20BridgeProxy.address).awaitTransactionSuccessAsync(txDefaults);

    const zrxProxy = erc20Proxy.address;
    const zrxVault = await ZrxVaultContract.deployFrom0xArtifactAsync(
        artifacts.ZrxVault,
        provider,
        txDefaults,
        {},
github 0xProject / 0x-monorepo / packages / migrations / src / migration.ts View on Github external
);
    }

    // ERC721
    // tslint:disable-next-line:no-unused-variable
    const cryptoKittieToken = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
        artifacts.DummyERC721Token,
        provider,
        txDefaults,
        artifacts,
        erc721TokenInfo[0].name,
        erc721TokenInfo[0].symbol,
    );

    // 1155 Asset Proxy
    const erc1155Proxy = await ERC1155ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC1155Proxy,
        provider,
        txDefaults,
        artifacts,
    );

    const staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync(
        artifacts.StaticCallProxy,
        provider,
        txDefaults,
        artifacts,
    );

    const multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
        artifacts.MultiAssetProxy,
        provider,
github 0xProject / 0x-monorepo / packages / migrations / src / migration.ts View on Github external
export async function runMigrationsAsync(
    supportedProvider: SupportedProvider,
    txDefaults: TxData,
): Promise {
    const provider = providerUtils.standardizeOrThrow(supportedProvider);
    const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider));

    // Proxies
    const erc20Proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC20Proxy,
        provider,
        txDefaults,
        artifacts,
    );
    const erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC721Proxy,
        provider,
        txDefaults,
        artifacts,
    );

    // ZRX
    const zrxToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
        artifacts.DummyERC20Token,
        provider,
github 0xProject / 0x-monorepo / packages / migrations / src / migration.ts View on Github external
export async function runMigrationsAsync(
    supportedProvider: SupportedProvider,
    txDefaults: TxData,
): Promise {
    const provider = providerUtils.standardizeOrThrow(supportedProvider);
    const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider));

    // Proxies
    const erc20Proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC20Proxy,
        provider,
        txDefaults,
        artifacts,
    );
    const erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC721Proxy,
        provider,
        txDefaults,
        artifacts,
    );

    // ZRX
    const zrxToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
        artifacts.DummyERC20Token,
        provider,
        txDefaults,
        artifacts,
        '0x Protocol Token',
        'ZRX',
        new BigNumber(18),
        new BigNumber(1000000000000000000000000000),
github 0xProject / 0x-monorepo / packages / migrations / src / migration.ts View on Github external
// 1155 Asset Proxy
    const erc1155Proxy = await ERC1155ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC1155Proxy,
        provider,
        txDefaults,
        artifacts,
    );

    const staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync(
        artifacts.StaticCallProxy,
        provider,
        txDefaults,
        artifacts,
    );

    const multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
        artifacts.MultiAssetProxy,
        provider,
        txDefaults,
        artifacts,
    );

    await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
    await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
    await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
    await multiAssetProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);

    // MultiAssetProxy
    await erc20Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
    await erc721Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
    await erc1155Proxy.addAuthorizedAddress(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
    await multiAssetProxy.registerAssetProxy(erc20Proxy.address).awaitTransactionSuccessAsync(txDefaults);
github 0xProject / 0x-monorepo / packages / migrations / src / migration.ts View on Github external
provider,
        txDefaults,
        artifacts,
        erc721TokenInfo[0].name,
        erc721TokenInfo[0].symbol,
    );

    // 1155 Asset Proxy
    const erc1155Proxy = await ERC1155ProxyContract.deployFrom0xArtifactAsync(
        artifacts.ERC1155Proxy,
        provider,
        txDefaults,
        artifacts,
    );

    const staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync(
        artifacts.StaticCallProxy,
        provider,
        txDefaults,
        artifacts,
    );

    const multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
        artifacts.MultiAssetProxy,
        provider,
        txDefaults,
        artifacts,
    );

    await erc20Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
    await erc721Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
    await erc1155Proxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
github 0xProject / 0x-monorepo / packages / migrations / src / testnet_migrations.ts View on Github external
exchangeArtifacts.Exchange,
        provider,
        txDefaults,
        exchangeArtifacts,
        chainId,
    );

    const stakingProxy = await StakingProxyContract.deployFrom0xArtifactAsync(
        stakingArtifacts.StakingProxy,
        provider,
        txDefaults,
        stakingArtifacts,
        stakingLogic.address,
    );

    const erc20BridgeProxy = await ERC20BridgeProxyContract.deployFrom0xArtifactAsync(
        assetProxyArtifacts.ERC20BridgeProxy,
        provider,
        txDefaults,
        assetProxyArtifacts,
    );

    await UniswapBridgeContract.deployFrom0xArtifactAsync(
        assetProxyArtifacts.UniswapBridge,
        provider,
        txDefaults,
        assetProxyArtifacts,
    );

    await Eth2DaiBridgeContract.deployFrom0xArtifactAsync(
        assetProxyArtifacts.Eth2DaiBridge,
        provider,
github 0xProject / 0x-monorepo / packages / migrations / src / test_contract_configs.ts View on Github external
async function testContractConfigsAsync(provider: SupportedProvider): Promise {
    const web3Wrapper = new Web3Wrapper(provider);
    const chainId = await web3Wrapper.getChainIdAsync();
    const addresses = getContractAddressesForChainOrThrow(chainId);
    const configs = getConfigsByChainId(chainId);

    function warnIfMismatch(actual: any, expected: any, message: string): void {
        if (actual !== expected) {
            logUtils.warn(`${message}: actual: ${actual}, expected: ${expected}, chainId: ${chainId}`);
        }
    }

    const exchange = new ExchangeContract(addresses.exchange, provider);
    const exchangeV2 = new ExchangeContract(addresses.exchangeV2, provider);
    const erc20Proxy = new ERC20ProxyContract(addresses.erc20Proxy, provider);
    const erc721Proxy = new ERC721ProxyContract(addresses.erc721Proxy, provider);
    const erc1155Proxy = new ERC1155ProxyContract(addresses.erc1155Proxy, provider);
    const multiAssetProxy = new MultiAssetProxyContract(addresses.multiAssetProxy, provider);
    const erc20BridgeProxy = new ERC20ProxyContract(addresses.erc20BridgeProxy, provider);
    const governor = new ZeroExGovernorContract(addresses.zeroExGovernor, provider);
    const stakingProxy = new StakingProxyContract(addresses.stakingProxy, provider);
    const stakingContract = new StakingContract(addresses.stakingProxy, provider);
    const zrxVault = new ZrxVaultContract(addresses.zrxVault, provider);

    async function verifyExchangeV2ConfigsAsync(): Promise {
        const exchangeOwner = await exchangeV2.owner().callAsync();
        warnIfMismatch(exchangeOwner, governor.address, 'Unexpected ExchangeV2 owner');

        const registeredERC20Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC20).callAsync();
        warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in ExchangeV2');
github 0xProject / 0x-monorepo / packages / migrations / src / test_contract_configs.ts View on Github external
const addresses = getContractAddressesForChainOrThrow(chainId);
    const configs = getConfigsByChainId(chainId);

    function warnIfMismatch(actual: any, expected: any, message: string): void {
        if (actual !== expected) {
            logUtils.warn(`${message}: actual: ${actual}, expected: ${expected}, chainId: ${chainId}`);
        }
    }

    const exchange = new ExchangeContract(addresses.exchange, provider);
    const exchangeV2 = new ExchangeContract(addresses.exchangeV2, provider);
    const erc20Proxy = new ERC20ProxyContract(addresses.erc20Proxy, provider);
    const erc721Proxy = new ERC721ProxyContract(addresses.erc721Proxy, provider);
    const erc1155Proxy = new ERC1155ProxyContract(addresses.erc1155Proxy, provider);
    const multiAssetProxy = new MultiAssetProxyContract(addresses.multiAssetProxy, provider);
    const erc20BridgeProxy = new ERC20ProxyContract(addresses.erc20BridgeProxy, provider);
    const governor = new ZeroExGovernorContract(addresses.zeroExGovernor, provider);
    const stakingProxy = new StakingProxyContract(addresses.stakingProxy, provider);
    const stakingContract = new StakingContract(addresses.stakingProxy, provider);
    const zrxVault = new ZrxVaultContract(addresses.zrxVault, provider);

    async function verifyExchangeV2ConfigsAsync(): Promise {
        const exchangeOwner = await exchangeV2.owner().callAsync();
        warnIfMismatch(exchangeOwner, governor.address, 'Unexpected ExchangeV2 owner');

        const registeredERC20Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC20).callAsync();
        warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in ExchangeV2');

        const registeredERC721Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC721).callAsync();
        warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in ExchangeV2');

        const registeredERC1155Proxy = await exchangeV2.getAssetProxy(AssetProxyId.ERC1155).callAsync();
github 0xProject / 0x-monorepo / packages / migrations / src / testnet_migrations.ts View on Github external
const erc20BridgeProxy = await ERC20BridgeProxyContract.deployFrom0xArtifactAsync(
        assetProxyArtifacts.ERC20BridgeProxy,
        provider,
        txDefaults,
        assetProxyArtifacts,
    );

    await UniswapBridgeContract.deployFrom0xArtifactAsync(
        assetProxyArtifacts.UniswapBridge,
        provider,
        txDefaults,
        assetProxyArtifacts,
    );

    await Eth2DaiBridgeContract.deployFrom0xArtifactAsync(
        assetProxyArtifacts.Eth2DaiBridge,
        provider,
        txDefaults,
        assetProxyArtifacts,
    );

    const authorizableInterface = new IAuthorizableContract(constants.NULL_ADDRESS, provider, txDefaults);
    const ownableInterface = new IOwnableContract(constants.NULL_ADDRESS, provider, txDefaults);

    const customTimeLocks = getTimelockRegistrationsByChainId(chainId.toNumber());

    const governor = await ZeroExGovernorContract.deployFrom0xArtifactAsync(
        multisigArtifacts.ZeroExGovernor,
        provider,
        txDefaults,
        multisigArtifacts,