How to use the @0x/contract-wrappers.ContractWrappers function in @0x/contract-wrappers

To help you get started, we’ve selected a few @0x/contract-wrappers 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-starter-project / src / scenarios / create_staking_pool.ts View on Github external
export async function scenarioAsync(): Promise {
    await runMigrationsOnceIfRequiredAsync();
    let txHash;
    PrintUtils.printScenario('Create Staking Pool');
    // account information, balances, general contract logs
    const web3Wrapper = new Web3Wrapper(providerEngine);
    const [maker, otherMaker] = await web3Wrapper.getAvailableAddressesAsync();
    const contractWrappers = new ContractWrappers(providerEngine, { chainId: NETWORK_CONFIGS.chainId });
    const zrxTokenAddress = contractWrappers.contractAddresses.zrxToken;
    const printUtils = new PrintUtils(web3Wrapper, contractWrappers, { maker }, { ZRX: zrxTokenAddress });

    // Staking Proxy is a delegate contract. We initialize a Staking Contract (ABI) pointing to the delegate proxy
    // at stakingProxyContractAddress
    const stakingContract = new StakingContract(contractWrappers.contractAddresses.stakingProxy, providerEngine, {
        from: maker,
    });

    // A small share is kept for the operator, note 1,000,000 represents all rebates
    // going to the operator
    const operatorSharePpm = new BigNumber(900000); // 90 %
    const stakingPoolReceipt = await stakingContract
        .createStakingPool(operatorSharePpm, true)
        .awaitTransactionSuccessAsync({
            from: maker,
github 0xProject / 0x-monorepo / packages / pipeline / src / data_sources / contract-wrappers / exchange_events.ts View on Github external
constructor(provider: Web3ProviderEngine, networkId: number) {
        const contractWrappers = new ContractWrappers(provider, { networkId });
        this._exchangeWrapper = contractWrappers.exchange;
    }
github 0xProject / 0x-monorepo / packages / website / ts / blockchain.ts View on Github external
this.networkId = networkId;
        const injectedProviderIfExists = await this._getInjectedProviderIfExistsAsync();
        const [provider, ledgerSubproviderIfExists] = await Blockchain._getProviderAsync(
            injectedProviderIfExists,
            networkId,
            shouldUserLedgerProvider,
        );
        this._web3Wrapper = new Web3Wrapper(provider);
        this.networkId = await this._web3Wrapper.getNetworkIdAsync();
        if (!_.isUndefined(this._contractWrappers)) {
            this._contractWrappers.unsubscribeAll();
        }
        const contractWrappersConfig = {
            networkId,
        };
        this._contractWrappers = new ContractWrappers(provider, contractWrappersConfig);
        if (!_.isUndefined(this._blockchainWatcher)) {
            this._blockchainWatcher.destroy();
        }
        this._blockchainWatcher = new BlockchainWatcher(this._dispatcher, this._web3Wrapper, shouldPollUserAddress);
        if (shouldUserLedgerProvider && !_.isUndefined(ledgerSubproviderIfExists)) {
            delete this._userAddressIfExists;
            this._ledgerSubprovider = ledgerSubproviderIfExists;
            this._dispatcher.updateUserAddress(undefined);
            this._dispatcher.updateProviderType(ProviderType.Ledger);
        } else {
            delete this._ledgerSubprovider;
            const userAddresses = await this._web3Wrapper.getAvailableAddressesAsync();
            this._userAddressIfExists = userAddresses[0];
            this._dispatcher.updateUserAddress(this._userAddressIfExists);
            if (!_.isUndefined(injectedProviderIfExists)) {
                this._dispatcher.updateProviderType(ProviderType.Injected);
github 0xProject / 0x-monorepo / packages / website / ts / pages / governance / connect_form.tsx View on Github external
const [provider, ledgerSubproviderIfExists] = await this._getProviderAsync(
            injectedProviderIfExists,
            networkId,
            shouldUserLedgerProvider,
        );
        this._web3Wrapper = new Web3Wrapper(provider);
        this._providerEngine = provider;
        this.networkId = await this._web3Wrapper.getNetworkIdAsync();
        this._providerName = this._getNameGivenProvider(provider);
        if (this._contractWrappers !== undefined) {
            this._contractWrappers.unsubscribeAll();
        }
        const contractWrappersConfig = {
            networkId,
        };
        this._contractWrappers = new ContractWrappers(provider, contractWrappersConfig);
        if (shouldUserLedgerProvider && ledgerSubproviderIfExists !== undefined) {
            delete this._userAddressIfExists;
            this._ledgerSubprovider = ledgerSubproviderIfExists;
        } else {
            delete this._ledgerSubprovider;
            const userAddresses = await this._web3Wrapper.getAvailableAddressesAsync();
            this._userAddressIfExists = userAddresses[0];
        }
    }
    private async _getUserAddressesAsync(): Promise {
github 0xProject / 0x-monorepo / packages / asset-buyer / src / quote_consumers / exchange_swap_quote_consumer.ts View on Github external
constructor(supportedProvider: SupportedProvider, options: Partial = {}) {
        const { networkId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
        assert.isNumber('networkId', networkId);

        const provider = providerUtils.standardizeOrThrow(supportedProvider);
        this.provider = provider;
        this.networkId = networkId;
        this._contractWrappers = new ContractWrappers(this.provider, {
            networkId,
        });
    }
github 0xProject / 0x-coordinator-server / ts / src / handlers.ts View on Github external
_.each(chainIdToProvider, (provider: Web3ProviderEngine, chainIdStr: string) => {
            const chainId = _.parseInt(chainIdStr);
            const contractAddresses = configs.CHAIN_ID_TO_CONTRACT_ADDRESSES
                ? configs.CHAIN_ID_TO_CONTRACT_ADDRESSES[chainId]
                : undefined;
            const contractWrappers = new ContractWrappers(provider, {
                chainId,
                contractAddresses,
            });
            this._chainIdToContractWrappers[chainId] = contractWrappers;
        });
    }