How to use the @0x/web3-wrapper.NodeType.Geth function in @0x/web3-wrapper

To help you get started, we’ve selected a few @0x/web3-wrapper 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 / contracts / test-utils / src / assertions.ts View on Github external
// HACK(albrow): This dummy `catch` should not be necessary, but if you
    // remove it, there is an uncaught exception and the Node process will
    // forcibly exit. It's possible this is a false positive in
    // make-promises-safe.
    p.catch(e => {
        _.noop(e);
    });

    if (nodeType === undefined) {
        nodeType = await web3Wrapper.getNodeTypeAsync();
    }
    switch (nodeType) {
        case NodeType.Ganache:
            const rejectionMessageRegex = new RegExp(`^VM Exception while processing transaction: revert ${reason}$`);
            return expect(p).to.be.rejectedWith(rejectionMessageRegex);
        case NodeType.Geth:
            logUtils.warn(
                'WARNING: Geth does not support revert reasons for sendTransaction. This test will pass if the transaction fails for any reason.',
            );
            return expectTransactionFailedWithoutReasonAsync(p);
        default:
            throw new Error(`Unknown node type: ${nodeType}`);
    }
}
github 0xProject / 0x-monorepo / packages / dev-utils / src / blockchain_lifecycle.ts View on Github external
public async startAsync(): Promise {
        const nodeType = await this._getNodeTypeAsync();
        switch (nodeType) {
            case NodeType.Ganache:
                const snapshotId = await this._web3Wrapper.takeSnapshotAsync();
                this._snapshotIdsStack.push(snapshotId);
                break;
            case NodeType.Geth:
                let blockNumber = await this._web3Wrapper.getBlockNumberAsync();
                if (blockNumber < MINIMUM_BLOCKS) {
                    // If the minimum block number is not met, force Geth to
                    // mine some blocks by sending some dummy transactions.
                    await this._mineMinimumBlocksAsync();
                    blockNumber = await this._web3Wrapper.getBlockNumberAsync();
                }
                this._snapshotIdsStack.push(blockNumber);
                // HACK(albrow) It's possible that we applied a time offset but
                // the transaction we mined to put that time offset into the
                // blockchain was reverted. As a workaround, we mine a new dummy
                // block so that the latest block timestamp accounts for any
                // possible time offsets.
                await this._mineDummyBlockAsync();
                break;
            default:
github 0xProject / 0x-monorepo / contracts / test-utils / src / assertions.ts View on Github external
async function _getGanacheOrGethErrorAsync(ganacheError: string, gethError: string): Promise {
    if (nodeType === undefined) {
        nodeType = await web3Wrapper.getNodeTypeAsync();
    }
    switch (nodeType) {
        case NodeType.Ganache:
            return ganacheError;
        case NodeType.Geth:
            return gethError;
        default:
            throw new Error(`Unknown node type: ${nodeType}`);
    }
}