How to use the @0x/web3-wrapper.marshaller.unmarshalTxData 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 / packages / subproviders / src / subproviders / metamask_subprovider.ts View on Github external
} catch (err) {
                    end(err);
                }
                return;
            case 'eth_accounts':
                try {
                    const accounts = await this._web3Wrapper.getAvailableAddressesAsync();
                    end(null, accounts);
                } catch (err) {
                    end(err);
                }
                return;
            case 'eth_sendTransaction':
                const [txParams] = payload.params;
                try {
                    const txData = marshaller.unmarshalTxData(txParams);
                    const txHash = await this._web3Wrapper.sendTransactionAsync(txData);
                    end(null, txHash);
                } catch (err) {
                    end(err);
                }
                return;
            case 'eth_sign':
                [address, message] = payload.params;
                try {
                    // Metamask incorrectly implements eth_sign and does not prefix the message as per the spec
                    // Source: https://github.com/MetaMask/metamask-extension/commit/a9d36860bec424dcee8db043d3e7da6a5ff5672e
                    const msgBuff = ethUtil.toBuffer(message);
                    const prefixedMsgBuff = ethUtil.hashPersonalMessage(msgBuff);
                    const prefixedMsgHex = ethUtil.bufferToHex(prefixedMsgBuff);
                    const signature = await this._web3Wrapper.signMessageAsync(address, prefixedMsgHex);
                    signature ? end(null, signature) : end(new Error('Error performing eth_sign'), null);
github 0xProject / 0x-monorepo / packages / subproviders / src / subproviders / signer.ts View on Github external
} catch (err) {
                    end(err);
                }
                return;
            case 'eth_accounts':
                try {
                    const accounts = await this._web3Wrapper.getAvailableAddressesAsync();
                    end(null, accounts);
                } catch (err) {
                    end(err);
                }
                return;
            case 'eth_sendTransaction':
                const [txParams] = payload.params;
                try {
                    const txData = marshaller.unmarshalTxData(txParams);
                    const txHash = await this._web3Wrapper.sendTransactionAsync(txData);
                    end(null, txHash);
                } catch (err) {
                    end(err);
                }
                return;
            case 'eth_sign':
                [address, message] = payload.params;
                try {
                    const signature = await this._web3Wrapper.signMessageAsync(address, message);
                    end(null, signature);
                } catch (err) {
                    end(err);
                }
                return;
            case 'eth_signTypedData':