當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript web3Factory.create方法代碼示例

本文整理匯總了TypeScript中@0xproject/dev-utils.web3Factory.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript web3Factory.create方法的具體用法?TypeScript web3Factory.create怎麽用?TypeScript web3Factory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@0xproject/dev-utils.web3Factory的用法示例。


在下文中一共展示了web3Factory.create方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('Assertion library', () => {
    const web3 = web3Factory.create();
    const config = {
        networkId: constants.TESTRPC_NETWORK_ID,
    };
    const zeroEx = new ZeroEx(web3.currentProvider, config);
    describe('#isSenderAddressHexAsync', () => {
        it('throws when address is invalid', async () => {
            const address = '0xdeadbeef';
            const varName = 'address';
            return expect(
                assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper),
            ).to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
        });
        it('throws when address is unavailable', async () => {
            const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42';
            const varName = 'address';
            return expect(
                assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper),
            ).to.be.rejectedWith(
                `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
            );
        });
        it("doesn't throw if address is available", async () => {
            const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0];
            const varName = 'address';
            return expect(
                assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper),
            ).to.become(undefined);
        });
    });
});
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:32,代碼來源:assert_test.ts

示例2: before

import { web3Factory } from '@0xproject/dev-utils';
import * as chai from 'chai';

import { ZeroEx } from '../src';

import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';

chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();

describe('TokenTransferProxyWrapper', () => {
    let zeroEx: ZeroEx;
    const config = {
        networkId: constants.TESTRPC_NETWORK_ID,
    };
    before(async () => {
        zeroEx = new ZeroEx(web3.currentProvider, config);
    });
    describe('#isAuthorizedAsync', () => {
        it('should return false if the address is not authorized', async () => {
            const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(ZeroEx.NULL_ADDRESS);
            expect(isAuthorized).to.be.false();
        });
    });
    describe('#getAuthorizedAddressesAsync', () => {
        it('should return the list of authorized addresses', async () => {
            const authorizedAddresses = await zeroEx.proxy.getAuthorizedAddressesAsync();
            for (const authorizedAddress of authorizedAddresses) {
                const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(authorizedAddress);
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:31,代碼來源:token_transfer_proxy_wrapper_test.ts

示例3: before

 before(async () => {
     const hasAddresses = false;
     const web3WithoutAccounts = web3Factory.create({ hasAddresses });
     zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
 });
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:5,代碼來源:token_wrapper_test.ts

示例4:

import { web3Factory } from '@0xproject/dev-utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';

const web3ProviderConfig = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(web3ProviderConfig);
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:6,代碼來源:web3_wrapper.ts

示例5: before

 before(async () => {
     web3 = web3Factory.create();
     const pollingIntervalMs = 10;
     web3Wrapper = new Web3Wrapper(web3.currentProvider);
     eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs);
 });
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:6,代碼來源:event_watcher_test.ts


注:本文中的@0xproject/dev-utils.web3Factory.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。