How to use the @ethersproject/properties.resolveProperties function in @ethersproject/properties

To help you get started, we’ve selected a few @ethersproject/properties 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 ethers-io / ethers.js / packages / abstract-signer / lib.esm / index.js View on Github external
call(transaction, blockTag) {
        this._checkProvider("call");
        return resolveProperties(this.checkTransaction(transaction)).then((tx) => {
            return this.provider.call(tx);
        });
    }
    // Populates all fields in a transaction, signs it and sends it to the network
github ethers-io / ethers.js / packages / contracts / lib.esm / index.js View on Github external
if (method.constant || options.callStatic) {
                // Call (constant functions) always cost 0 ether
                if (options.estimate) {
                    return Promise.resolve(Zero);
                }
                if (!contract.provider && !contract.signer) {
                    logger.throwError("call (constant functions) require a provider or signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" });
                }
                // Check overrides make sense
                ["gasLimit", "gasPrice", "value"].forEach(function (key) {
                    if (tx[key] != null) {
                        throw new Error("call cannot override " + key);
                    }
                });
                if (options.transaction) {
                    return resolveProperties(tx);
                }
                return (contract.signer || contract.provider).call(tx, blockTag).then((value) => {
                    try {
                        let result = contract.interface.decodeFunctionResult(method, value);
                        if (method.outputs.length === 1) {
                            result = result[0];
                        }
                        return result;
                    }
                    catch (error) {
                        if (error.code === Logger.errors.CALL_EXCEPTION) {
                            error.address = contract.address;
                            error.args = params;
                            error.transaction = tx;
                        }
                        throw error;
github ethers-io / ethers.js / packages / providers / lib.esm / json-rpc-provider.js View on Github external
let fromAddress = this.getAddress().then((address) => {
            if (address) {
                address = address.toLowerCase();
            }
            return address;
        });
        // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user
        // wishes to use this, it is easy to specify explicitly, otherwise
        // we look it up for them.
        if (transaction.gasLimit == null) {
            let estimate = shallowCopy(transaction);
            estimate.from = fromAddress;
            transaction.gasLimit = this.provider.estimateGas(estimate);
        }
        return Promise.all([
            resolveProperties(transaction),
            fromAddress
        ]).then((results) => {
            let tx = results[0];
            let hexTx = this.provider.constructor.hexlifyTransaction(tx);
            hexTx.from = results[1];
            return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => {
                return hash;
            }, (error) => {
                if (error.responseText) {
                    // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??)
                    if (error.responseText.indexOf("insufficient funds") >= 0) {
                        logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {
                            transaction: tx
                        });
                    }
                    if (error.responseText.indexOf("nonce too low") >= 0) {
github ethers-io / ethers.js / packages / abstract-signer / lib.esm / index.js View on Github external
estimateGas(transaction) {
        this._checkProvider("estimateGas");
        return resolveProperties(this.checkTransaction(transaction)).then((tx) => {
            return this.provider.estimateGas(tx);
        });
    }
    // Populates "from" if unspecified, and calls with the transation
github ethers-io / ethers.js / packages / providers / lib / base-provider.js View on Github external
result.address = this._getAddress(filter.address);
                        }
                        ["blockHash", "topics"].forEach(function (key) {
                            if (filter[key] == null) {
                                return;
                            }
                            result[key] = filter[key];
                        });
                        ["fromBlock", "toBlock"].forEach(function (key) {
                            if (filter[key] == null) {
                                return;
                            }
                            result[key] = _this._getBlockTag(filter[key]);
                        });
                        _b = (_a = this.formatter).filter;
                        return [4 /*yield*/, properties_1.resolveProperties(filter)];
                    case 3: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
                }
            });
        });
github ethers-io / ethers.js / packages / abstract-signer / lib.esm / index.js View on Github external
logger.throwArgumentError("from address mismatch", "transaction", transaction);
                    }
                    return results[0];
                });
            }
            if (tx.gasLimit == null) {
                tx.gasLimit = this.estimateGas(tx).catch((error) => {
                    logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
                        tx: tx
                    });
                });
            }
            if (tx.chainId == null) {
                tx.chainId = this.getChainId();
            }
            return yield resolveProperties(tx);
        });
    }
github ethers-io / ethers.js / packages / wallet / src.ts / index.ts View on Github external
signTransaction(transaction: TransactionRequest): Promise {
        return resolveProperties(transaction).then((tx) => {
            if (tx.from != null) {
                if (getAddress(tx.from) !== this.address) {
                    throw new Error("transaction from address mismatch");
                }
                delete tx.from;
            }

            const signature = this._signingKey().signDigest(keccak256(serialize(tx)));
            return serialize(tx, signature);
        });
    }
github ethers-io / ethers.js / packages / wallet / lib.esm / index.js View on Github external
signTransaction(transaction) {
        return resolveProperties(transaction).then((tx) => {
            if (tx.from != null) {
                if (getAddress(tx.from) !== this.address) {
                    throw new Error("transaction from address mismatch");
                }
                delete tx.from;
            }
            const signature = this._signingKey().signDigest(keccak256(serialize(tx)));
            return serialize(tx, signature);
        });
    }
    signMessage(message) {
github ethers-io / ethers.js / packages / providers / lib.esm / base-provider.js View on Github external
}
                tx[key] = Promise.resolve(values[key]).then((v) => (v ? this._getAddress(v) : null));
            });
            ["gasLimit", "gasPrice", "value"].forEach((key) => {
                if (values[key] == null) {
                    return;
                }
                tx[key] = Promise.resolve(values[key]).then((v) => (v ? BigNumber.from(v) : null));
            });
            ["data"].forEach((key) => {
                if (values[key] == null) {
                    return;
                }
                tx[key] = Promise.resolve(values[key]).then((v) => (v ? hexlify(v) : null));
            });
            return this.formatter.transactionRequest(yield resolveProperties(tx));
        });
    }