How to use the @ethersproject/properties.getStatic 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 / providers / lib / url-json-rpc-provider.js View on Github external
function UrlJsonRpcProvider(network, apiKey) {
        var _newTarget = this.constructor;
        var _this = this;
        logger.checkAbstract(_newTarget, UrlJsonRpcProvider);
        // Normalize the Network and API Key
        network = properties_1.getStatic((_newTarget), "getNetwork")(network);
        apiKey = properties_1.getStatic((_newTarget), "getApiKey")(apiKey);
        var connection = properties_1.getStatic((_newTarget), "getUrl")(network, apiKey);
        _this = _super.call(this, connection, network) || this;
        if (typeof (apiKey) === "string") {
            properties_1.defineReadOnly(_this, "apiKey", apiKey);
        }
        else if (apiKey != null) {
            Object.keys(apiKey).forEach(function (key) {
                properties_1.defineReadOnly(_this, key, apiKey[key]);
            });
        }
        return _this;
    }
    UrlJsonRpcProvider.prototype._startPending = function () {
github ethers-io / ethers.js / packages / providers / src.ts / url-json-rpc-provider.ts View on Github external
constructor(network?: Networkish, apiKey?: any) {
        logger.checkAbstract(new.target, UrlJsonRpcProvider);

        // Normalize the Network and API Key
        network = getStatic<(network: Networkish) => Network>(new.target, "getNetwork")(network);
        apiKey = getStatic<(apiKey: string) => string>(new.target, "getApiKey")(apiKey);

        const connection = getStatic(new.target, "getUrl")(network, apiKey);

        super(connection, network);

        if (typeof(apiKey) === "string") {
            defineReadOnly(this, "apiKey", apiKey);
        } else if (apiKey != null) {
            Object.keys(apiKey).forEach((key) => {
                defineReadOnly(this, key, apiKey[key]);
            });
        }
    }
github ethers-io / ethers.js / packages / providers / lib.esm / json-rpc-provider.js View on Github external
constructor(url, network) {
        logger.checkNew(new.target, JsonRpcProvider);
        const getNetwork = getStatic((new.target), "getNetwork");
        // One parameter, but it is a network name, so swap it with the URL
        if (typeof (url) === "string") {
            if (network === null) {
                const checkNetwork = getNetwork(url);
                network = checkNetwork;
                url = null;
            }
        }
        if (network) {
            // The network has been specified explicitly, we can use it
            super(network);
        }
        else {
            // The network is unknown, query the JSON-RPC for it
            const ready = new Promise((resolve, reject) => {
                setTimeout(() => __awaiter(this, void 0, void 0, function* () {
github ethers-io / ethers.js / packages / providers / lib / url-json-rpc-provider.js View on Github external
function UrlJsonRpcProvider(network, apiKey) {
        var _newTarget = this.constructor;
        var _this = this;
        logger.checkAbstract(_newTarget, UrlJsonRpcProvider);
        // Normalize the Network and API Key
        network = properties_1.getStatic((_newTarget), "getNetwork")(network);
        apiKey = properties_1.getStatic((_newTarget), "getApiKey")(apiKey);
        var connection = properties_1.getStatic((_newTarget), "getUrl")(network, apiKey);
        _this = _super.call(this, connection, network) || this;
        if (typeof (apiKey) === "string") {
            properties_1.defineReadOnly(_this, "apiKey", apiKey);
        }
        else if (apiKey != null) {
            Object.keys(apiKey).forEach(function (key) {
                properties_1.defineReadOnly(_this, key, apiKey[key]);
            });
        }
        return _this;
    }
    UrlJsonRpcProvider.prototype._startPending = function () {
github ethers-io / ethers.js / packages / providers / lib.esm / url-json-rpc-provider.js View on Github external
constructor(network, apiKey) {
        logger.checkAbstract(new.target, UrlJsonRpcProvider);
        // Normalize the Network and API Key
        network = getStatic((new.target), "getNetwork")(network);
        apiKey = getStatic((new.target), "getApiKey")(apiKey);
        const connection = getStatic((new.target), "getUrl")(network, apiKey);
        super(connection, network);
        if (typeof (apiKey) === "string") {
            defineReadOnly(this, "apiKey", apiKey);
        }
        else if (apiKey != null) {
            Object.keys(apiKey).forEach((key) => {
                defineReadOnly(this, key, apiKey[key]);
            });
        }
    }
    _startPending() {
github ethers-io / ethers.js / packages / abi / lib.esm / interface.js View on Github external
constructor(fragments) {
        logger.checkNew(new.target, Interface);
        let abi = [];
        if (typeof (fragments) === "string") {
            abi = JSON.parse(fragments);
        }
        else {
            abi = fragments;
        }
        defineReadOnly(this, "fragments", abi.map((fragment) => {
            return Fragment.from(fragment);
        }).filter((fragment) => (fragment != null)));
        defineReadOnly(this, "_abiCoder", getStatic((new.target), "getAbiCoder")());
        defineReadOnly(this, "functions", {});
        defineReadOnly(this, "errors", {});
        defineReadOnly(this, "events", {});
        defineReadOnly(this, "structs", {});
        // Add all fragments by their signature
        this.fragments.forEach((fragment) => {
            let bucket = null;
            switch (fragment.type) {
                case "constructor":
                    if (this.deploy) {
                        logger.warn("duplicate definition - constructor");
                        return;
                    }
                    defineReadOnly(this, "deploy", fragment);
                    return;
                case "function":
github ethers-io / ethers.js / packages / providers / src.ts / url-json-rpc-provider.ts View on Github external
constructor(network?: Networkish, apiKey?: any) {
        logger.checkAbstract(new.target, UrlJsonRpcProvider);

        // Normalize the Network and API Key
        network = getStatic<(network: Networkish) => Network>(new.target, "getNetwork")(network);
        apiKey = getStatic<(apiKey: string) => string>(new.target, "getApiKey")(apiKey);

        const connection = getStatic(new.target, "getUrl")(network, apiKey);

        super(connection, network);

        if (typeof(apiKey) === "string") {
            defineReadOnly(this, "apiKey", apiKey);
        } else if (apiKey != null) {
            Object.keys(apiKey).forEach((key) => {
                defineReadOnly(this, key, apiKey[key]);
            });
        }
    }
github ethers-io / ethers.js / packages / contracts / lib / index.js View on Github external
bytecodeHex = "!";
        }
        // Make sure it is 0x prefixed
        if (bytecodeHex.substring(0, 2) !== "0x") {
            bytecodeHex = "0x" + bytecodeHex;
        }
        // Make sure the final result is valid bytecode
        if (!bytes_1.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) {
            logger.throwArgumentError("invalid bytecode", "bytecode", bytecode);
        }
        // If we have a signer, make sure it is valid
        if (signer && !abstract_signer_1.Signer.isSigner(signer)) {
            logger.throwArgumentError("invalid signer", "signer", signer);
        }
        properties_1.defineReadOnly(this, "bytecode", bytecodeHex);
        properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface));
        properties_1.defineReadOnly(this, "signer", signer || null);
    }
    ContractFactory.prototype.getDeployTransaction = function () {
github ethers-io / ethers.js / packages / providers / lib.esm / url-json-rpc-provider.js View on Github external
constructor(network, apiKey) {
        logger.checkAbstract(new.target, UrlJsonRpcProvider);
        // Normalize the Network and API Key
        network = getStatic((new.target), "getNetwork")(network);
        apiKey = getStatic((new.target), "getApiKey")(apiKey);
        const connection = getStatic((new.target), "getUrl")(network, apiKey);
        super(connection, network);
        if (typeof (apiKey) === "string") {
            defineReadOnly(this, "apiKey", apiKey);
        }
        else if (apiKey != null) {
            Object.keys(apiKey).forEach((key) => {
                defineReadOnly(this, key, apiKey[key]);
            });
        }
    }
    _startPending() {
github ethers-io / ethers.js / packages / abi / lib / interface.js View on Github external
function Interface(fragments) {
        var _newTarget = this.constructor;
        var _this = this;
        logger.checkNew(_newTarget, Interface);
        var abi = [];
        if (typeof (fragments) === "string") {
            abi = JSON.parse(fragments);
        }
        else {
            abi = fragments;
        }
        properties_1.defineReadOnly(this, "fragments", abi.map(function (fragment) {
            return fragments_1.Fragment.from(fragment);
        }).filter(function (fragment) { return (fragment != null); }));
        properties_1.defineReadOnly(this, "_abiCoder", properties_1.getStatic((_newTarget), "getAbiCoder")());
        properties_1.defineReadOnly(this, "functions", {});
        properties_1.defineReadOnly(this, "errors", {});
        properties_1.defineReadOnly(this, "events", {});
        properties_1.defineReadOnly(this, "structs", {});
        // Add all fragments by their signature
        this.fragments.forEach(function (fragment) {
            var bucket = null;
            switch (fragment.type) {
                case "constructor":
                    if (_this.deploy) {
                        logger.warn("duplicate definition - constructor");
                        return;
                    }
                    properties_1.defineReadOnly(_this, "deploy", fragment);
                    return;
                case "function":