How to use @ethersproject/web - 10 common examples

To help you get started, we’ve selected a few @ethersproject/web 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 / providers / lib.esm / json-rpc-provider.js View on Github external
send(method, params) {
        let request = {
            method: method,
            params: params,
            id: (this._nextId++),
            jsonrpc: "2.0"
        };
        this.emit("debug", {
            action: "request",
            request: deepCopy(request),
            provider: this
        });
        return fetchJson(this.connection, JSON.stringify(request), getResult).then((result) => {
            this.emit("debug", {
                action: "response",
                request: request,
                response: result,
                provider: this
            });
            return result;
        });
    }
    perform(method, params) {
github ethers-io / ethers.js / packages / providers / lib / etherscan-provider.js View on Github external
return this.resolveName(addressOrName).then(function (address) {
            url += "/api?module=account&action=txlist&address=" + address;
            url += "&startblock=" + startBlock;
            url += "&endblock=" + endBlock;
            url += "&sort=asc" + apiKey;
            _this.emit("debug", {
                action: "request",
                request: url,
                provider: _this
            });
            return web_1.fetchJson(url, null, getResult).then(function (result) {
                _this.emit("debug", {
                    action: "response",
                    request: url,
                    response: properties_1.deepCopy(result),
                    provider: _this
                });
                var output = [];
                result.forEach(function (tx) {
                    ["contractAddress", "to"].forEach(function (key) {
                        if (tx[key] == "") {
                            delete tx[key];
                        }
                    });
                    if (tx.creates == null && tx.contractAddress != null) {
                        tx.creates = tx.contractAddress;
                    }
github ethers-io / ethers.js / packages / providers / lib.esm / etherscan-provider.js View on Github external
const get = (url, procFunc) => __awaiter(this, void 0, void 0, function* () {
                this.emit("debug", {
                    action: "request",
                    request: url,
                    provider: this
                });
                const result = yield fetchJson(url, null, procFunc || getJsonResult);
                this.emit("debug", {
                    action: "response",
                    request: url,
                    response: deepCopy(result),
                    provider: this
                });
                return result;
            });
            switch (method) {
github ethers-io / ethers.js / packages / providers / lib.esm / etherscan-provider.js View on Github external
return this.resolveName(addressOrName).then((address) => {
            url += "/api?module=account&action=txlist&address=" + address;
            url += "&startblock=" + startBlock;
            url += "&endblock=" + endBlock;
            url += "&sort=asc" + apiKey;
            this.emit("debug", {
                action: "request",
                request: url,
                provider: this
            });
            return fetchJson(url, null, getResult).then((result) => {
                this.emit("debug", {
                    action: "response",
                    request: url,
                    response: deepCopy(result),
                    provider: this
                });
                let output = [];
                result.forEach((tx) => {
                    ["contractAddress", "to"].forEach(function (key) {
                        if (tx[key] == "") {
                            delete tx[key];
                        }
                    });
                    if (tx.creates == null && tx.contractAddress != null) {
                        tx.creates = tx.contractAddress;
                    }
github ethers-io / ethers.js / packages / providers / lib / json-rpc-provider.js View on Github external
JsonRpcProvider.prototype.send = function (method, params) {
        var _this = this;
        var request = {
            method: method,
            params: params,
            id: (this._nextId++),
            jsonrpc: "2.0"
        };
        this.emit("debug", {
            action: "request",
            request: properties_1.deepCopy(request),
            provider: this
        });
        return web_1.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) {
            _this.emit("debug", {
                action: "response",
                request: request,
                response: result,
                provider: _this
            });
            return result;
        });
    };
    JsonRpcProvider.prototype.perform = function (method, params) {
github ethers-io / ethers.js / packages / providers / lib / etherscan-provider.js View on Github external
return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        this.emit("debug", {
                                            action: "request",
                                            request: url,
                                            provider: this
                                        });
                                        return [4 /*yield*/, web_1.fetchJson(url, null, procFunc || getJsonResult)];
                                    case 1:
                                        result = _a.sent();
                                        this.emit("debug", {
                                            action: "response",
                                            request: url,
                                            response: properties_1.deepCopy(result),
                                            provider: this
                                        });
                                        return [2 /*return*/, result];
                                }
                            });
                        }); };
github ethers-io / ethers.js / packages / experimental / retry-provider.js View on Github external
RetryProvider.prototype.perform = function (method, params) {
        var _this = this;
        return web_1.poll(function () {
            return _this.provider.perform(method, params).then(function (result) {
                return result;
            }, function (error) {
                return undefined;
            });
        }, this.options);
    };
    return RetryProvider;
github ethers-io / ethers.js / packages / experimental / src.ts / retry-provider.ts View on Github external
perform(method: string, params: any): Promise {
        return poll(() => {
            return this.provider.perform(method, params).then((result) => {
                return result
            }, (error) => {
                return undefined
            });
        }, this.options);
    }
}
github ethers-io / ethers.js / packages / providers / lib / json-rpc-provider.js View on Github external
return this.sendUncheckedTransaction(transaction).then(function (hash) {
            return web_1.poll(function () {
                return _this.provider.getTransaction(hash).then(function (tx) {
                    if (tx === null) {
                        return undefined;
                    }
                    return _this.provider._wrapTransaction(tx, hash);
                });
            }, { onceBlock: _this.provider }).catch(function (error) {
                error.transactionHash = hash;
                throw error;
            });
        });
    };
github ethers-io / ethers.js / packages / providers / lib.esm / json-rpc-provider.js View on Github external
return this.sendUncheckedTransaction(transaction).then((hash) => {
            return poll(() => {
                return this.provider.getTransaction(hash).then((tx) => {
                    if (tx === null) {
                        return undefined;
                    }
                    return this.provider._wrapTransaction(tx, hash);
                });
            }, { onceBlock: this.provider }).catch((error) => {
                error.transactionHash = hash;
                throw error;
            });
        });
    }

@ethersproject/web

Utility fucntions for managing web requests for ethers.

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis

Popular @ethersproject/web functions