Socket
Socket
Sign inDemoInstall

ethers

Package Overview
Dependencies
Maintainers
1
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethers - npm Package Compare versions

Comparing version 6.1.0 to 6.2.0

18

CHANGELOG.md

@@ -6,2 +6,20 @@ Change Log

ethers/v6.2.0 (2023-03-20 15:53)
--------------------------------
- Added extra details in the error info field for RPC errors ([30ffa78](https://github.com/ethers-io/ethers.js/commit/30ffa78d1441fa033677fa09237fc135a314f373)).
- Remove Ankr as a deafult for now as the provided API key is failing ([6e01e54](https://github.com/ethers-io/ethers.js/commit/6e01e5448f4a3e2d30288d4c8447db295c3a2e7a)).
- Fixed deferred filters after unsafe-eval changes ([#3749](https://github.com/ethers-io/ethers.js/issues/3749), [#3763](https://github.com/ethers-io/ethers.js/issues/3763); [2e3802a](https://github.com/ethers-io/ethers.js/commit/2e3802a83b8ad2f5a6269d79fbd1c83c9f2d1047)).
- tests: updated ENS normalization tests to latest standard ([0a9e4cd](https://github.com/ethers-io/ethers.js/commit/0a9e4cd67dd0187445930cdb9d75d548590af9b2)).
- Remove use of Function sub-class to address unsafe-eval issues ([#3749](https://github.com/ethers-io/ethers.js/issues/3749), [#3763](https://github.com/ethers-io/ethers.js/issues/3763); [7d3af51](https://github.com/ethers-io/ethers.js/commit/7d3af512c75b4c24027ec2daef1e9f4c1064194a)).
- tests: added contract integration tests and llocal Geth ([5318b93](https://github.com/ethers-io/ethers.js/commit/5318b939fdfe8f58cdea4bdff7923f18afbea3a2)).
- Added verifyTypedData utility (reported on Farcaster) ([f06a445](https://github.com/ethers-io/ethers.js/commit/f06a445247f3b294f9fc805cc8fe0752accb8edc)).
- Removed stray logging in IpcProvider ([#3908](https://github.com/ethers-io/ethers.js/issues/3908), [#3909](https://github.com/ethers-io/ethers.js/issues/3909); [e11d4c1](https://github.com/ethers-io/ethers.js/commit/e11d4c1c20cc5b6fd5803cf9636c4f5bc082dab7)).
- Fixed legacy serialization for implicit chainId transactions ([#3898](https://github.com/ethers-io/ethers.js/issues/3898), [#3899](https://github.com/ethers-io/ethers.js/issues/3899); [fcf6c8f](https://github.com/ethers-io/ethers.js/commit/fcf6c8fcee95ec412aaafba8ec84d5049b077a4e)).
- Fix Webpack issue (reported on discord) ([3ad4273](https://github.com/ethers-io/ethers.js/commit/3ad4273b8b714bff344ccbfb1eb71ed8a8b7cfa4)).
- Fix some bundlers which cannot handle recursive pkg.exports ([#3848](https://github.com/ethers-io/ethers.js/issues/3848); [6315e78](https://github.com/ethers-io/ethers.js/commit/6315e78ea32147653b72ca06f6800f3e2df6ffbf)).
- Fixed typo in signature.s error ([#3891](https://github.com/ethers-io/ethers.js/issues/3891); [47ef3eb](https://github.com/ethers-io/ethers.js/commit/47ef3ebde37bfa0c015c258c3d8a6800d751e147)).
- Fixed stray unreachable code ([#3890](https://github.com/ethers-io/ethers.js/issues/3890); [c220fe2](https://github.com/ethers-io/ethers.js/commit/c220fe2ea747ccc80cd3c4020e0278e3daf3c4fc)).
- Move all wrapping to proper _wrap functions ([#3818](https://github.com/ethers-io/ethers.js/issues/3818); [02a0aad](https://github.com/ethers-io/ethers.js/commit/02a0aad61212c35e8d2723a8ae589989b97dae3e)).
ethers/v6.1.0 (2023-03-07 02:10)

@@ -8,0 +26,0 @@ --------------------------------

2

lib.commonjs/_version.js

@@ -8,3 +8,3 @@ "use strict";

*/
exports.version = "6.1.0";
exports.version = "6.2.0";
//# sourceMappingURL=_version.js.map

@@ -60,3 +60,2 @@ "use strict";

}));
return t;
}));

@@ -63,0 +62,0 @@ }

@@ -7,4 +7,4 @@ import { Interface } from "../abi/index.js";

import type { EventEmitterable, Listener } from "../utils/index.js";
import type { BlockTag, ContractRunner, TransactionRequest } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction } from "./types.js";
import type { BlockTag, ContractRunner } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction, WrappedFallback } from "./types.js";
/**

@@ -18,10 +18,2 @@ * @_ignore:

export declare function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray<ParamType>, args: Array<any>): Promise<Array<any>>;
declare class WrappedFallback {
readonly _contract: BaseContract;
constructor(contract: BaseContract);
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}
declare const internal: unique symbol;

@@ -28,0 +20,0 @@ export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {

@@ -61,5 +61,2 @@ "use strict";

//export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = ContractTransactionResponse> {
function _WrappedMethodBase() {
return Function;
}
function getRunner(value, feature) {

@@ -116,35 +113,101 @@ if (value == null) {

exports.resolveArgs = resolveArgs;
function buildWrappedFallback(contract) {
const populateTransaction = async function (overrides) {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(overrides, ["data"]));
tx.to = await contract.getAddress();
const iface = contract.interface;
// Only allow payable contracts to set non-zero value
const payable = iface.receive || (iface.fallback && iface.fallback.payable);
(0, index_js_3.assertArgument)(payable || (tx.value || BN_0) === BN_0, "cannot send value to non-payable contract", "overrides.value", tx.value);
// Only allow fallback contracts to set non-empty data
(0, index_js_3.assertArgument)(iface.fallback || (tx.data || "0x") === "0x", "cannot send data to receive-only contract", "overrides.data", tx.data);
return tx;
};
const staticCall = async function (overrides) {
const runner = getRunner(contract.runner, "call");
(0, index_js_3.assert)(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await populateTransaction(overrides);
try {
return await runner.call(tx);
}
catch (error) {
if ((0, index_js_3.isCallException)(error) && error.data) {
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
};
const send = async function (overrides) {
const runner = contract.runner;
(0, index_js_3.assert)(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await populateTransaction(overrides));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new wrappers_js_1.ContractTransactionResponse(contract.interface, provider, tx);
};
const estimateGas = async function (overrides) {
const runner = getRunner(contract.runner, "estimateGas");
(0, index_js_3.assert)(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await populateTransaction(overrides));
};
const method = async (overrides) => {
return await send(overrides);
};
(0, index_js_3.defineProperties)(method, {
_contract: contract,
estimateGas,
populateTransaction,
send, staticCall
});
return method;
}
/*
class WrappedFallback {
_contract;
constructor(contract) {
(0, index_js_3.defineProperties)(this, { _contract: contract });
constructor (contract: BaseContract) {
defineProperties<WrappedFallback>(this, { _contract: contract });
const proxy = new Proxy(this, {
// Perform send when called
apply: async (target, thisArg, args) => {
apply: async (target, thisArg, args: Array<any>) => {
return await target.send(...args);
},
});
return proxy;
}
async populateTransaction(overrides) {
async populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction> {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(overrides, ["data"]));
const tx: ContractTransaction = <any>(await copyOverrides<"data">(overrides, [ "data" ]));
tx.to = await this._contract.getAddress();
const iface = this._contract.interface;
// Only allow payable contracts to set non-zero value
const payable = iface.receive || (iface.fallback && iface.fallback.payable);
(0, index_js_3.assertArgument)(payable || (tx.value || BN_0) === BN_0, "cannot send value to non-payable contract", "overrides.value", tx.value);
assertArgument(payable || (tx.value || BN_0) === BN_0,
"cannot send value to non-payable contract", "overrides.value", tx.value);
// Only allow fallback contracts to set non-empty data
(0, index_js_3.assertArgument)(iface.fallback || (tx.data || "0x") === "0x", "cannot send data to receive-only contract", "overrides.data", tx.data);
assertArgument(iface.fallback || (tx.data || "0x") === "0x",
"cannot send data to receive-only contract", "overrides.data", tx.data);
return tx;
}
async staticCall(overrides) {
async staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string> {
const runner = getRunner(this._contract.runner, "call");
(0, index_js_3.assert)(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
assert(canCall(runner), "contract runner does not support calling",
"UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(overrides);
try {
return await runner.call(tx);
}
catch (error) {
if ((0, index_js_3.isCallException)(error) && error.data) {
} catch (error: any) {
if (isCallException(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);

@@ -155,5 +218,8 @@ }

}
async send(overrides) {
async send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse> {
const runner = this._contract.runner;
(0, index_js_3.assert)(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
assert(canSend(runner), "contract runner does not support sending transactions",
"UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(overrides));

@@ -163,35 +229,17 @@ const provider = getProvider(this._contract.runner);

// meaningful error
return new wrappers_js_1.ContractTransactionResponse(this._contract.interface, provider, tx);
return new ContractTransactionResponse(this._contract.interface, <Provider>provider, tx);
}
async estimateGas(overrides) {
async estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint> {
const runner = getRunner(this._contract.runner, "estimateGas");
(0, index_js_3.assert)(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
assert(canEstimate(runner), "contract runner does not support gas estimation",
"UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(overrides));
}
}
class WrappedMethod extends _WrappedMethodBase() {
name = ""; // Investigate!
_contract;
_key;
constructor(contract, key) {
super();
(0, index_js_3.defineProperties)(this, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key
});
const proxy = new Proxy(this, {
// Perform the default operation for this fragment type
apply: async (target, thisArg, args) => {
const fragment = target.getFragment(...args);
if (fragment.constant) {
return await target.staticCall(...args);
}
return await target.send(...args);
},
});
return proxy;
}
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
get fragment() {
const fragment = this._contract.interface.getFunction(this._key);
*/
function buildWrappedMethod(contract, key) {
const getFragment = function (...args) {
const fragment = contract.interface.getFunction(key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {

@@ -201,12 +249,5 @@ operation: "fragment"

return fragment;
}
getFragment(...args) {
const fragment = this._contract.interface.getFunction(this._key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
async populateTransaction(...args) {
const fragment = this.getFragment(...args);
};
const populateTransaction = async function (...args) {
const fragment = getFragment(...args);
// If an overrides was passed in, copy it and normalize the values

@@ -220,10 +261,10 @@ let overrides = {};

}
const resolvedArgs = await resolveArgs(this._contract.runner, fragment.inputs, args);
const resolvedArgs = await resolveArgs(contract.runner, fragment.inputs, args);
return Object.assign({}, overrides, await (0, index_js_3.resolveProperties)({
to: this._contract.getAddress(),
data: this._contract.interface.encodeFunctionData(fragment, resolvedArgs)
to: contract.getAddress(),
data: contract.interface.encodeFunctionData(fragment, resolvedArgs)
}));
}
async staticCall(...args) {
const result = await this.staticCallResult(...args);
};
const staticCall = async function (...args) {
const result = await staticCallResult(...args);
if (result.length === 1) {

@@ -233,21 +274,21 @@ return result[0];

return result;
}
async send(...args) {
const runner = this._contract.runner;
};
const send = async function (...args) {
const runner = contract.runner;
(0, index_js_3.assert)(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(...args));
const provider = getProvider(this._contract.runner);
const tx = await runner.sendTransaction(await populateTransaction(...args));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new wrappers_js_1.ContractTransactionResponse(this._contract.interface, provider, tx);
}
async estimateGas(...args) {
const runner = getRunner(this._contract.runner, "estimateGas");
return new wrappers_js_1.ContractTransactionResponse(contract.interface, provider, tx);
};
const estimateGas = async function (...args) {
const runner = getRunner(contract.runner, "estimateGas");
(0, index_js_3.assert)(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(...args));
}
async staticCallResult(...args) {
const runner = getRunner(this._contract.runner, "call");
return await runner.estimateGas(await populateTransaction(...args));
};
const staticCallResult = async function (...args) {
const runner = getRunner(contract.runner, "call");
(0, index_js_3.assert)(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(...args);
const tx = await populateTransaction(...args);
let result = "0x";

@@ -259,33 +300,41 @@ try {

if ((0, index_js_3.isCallException)(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
const fragment = this.getFragment(...args);
return this._contract.interface.decodeFunctionResult(fragment, result);
}
const fragment = getFragment(...args);
return contract.interface.decodeFunctionResult(fragment, result);
};
const method = async (...args) => {
const fragment = getFragment(...args);
if (fragment.constant) {
return await staticCall(...args);
}
return await send(...args);
};
(0, index_js_3.defineProperties)(method, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key,
getFragment,
estimateGas,
populateTransaction,
send, staticCall, staticCallResult,
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getFunction(key);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return method;
}
function _WrappedEventBase() {
return Function;
}
class WrappedEvent extends _WrappedEventBase() {
name = ""; // @TODO: investigate
_contract;
_key;
constructor(contract, key) {
super();
(0, index_js_3.defineProperties)(this, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key
});
return new Proxy(this, {
// Perform the default operation for this fragment type
apply: (target, thisArg, args) => {
return new PreparedTopicFilter(contract, target.getFragment(...args), args);
},
});
}
// Only works on non-ambiguous keys
get fragment() {
const fragment = this._contract.interface.getEvent(this._key);
function buildWrappedEvent(contract, key) {
const getFragment = function (...args) {
const fragment = contract.interface.getEvent(key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {

@@ -295,12 +344,25 @@ operation: "fragment"

return fragment;
}
getFragment(...args) {
const fragment = this._contract.interface.getEvent(this._key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
};
const method = function (...args) {
return new PreparedTopicFilter(contract, getFragment(...args), args);
};
(0, index_js_3.defineProperties)(method, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key,
getFragment
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getEvent(key);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return method;
}
;
// The combination of TypeScrype, Private Fields and Proxies makes

@@ -565,3 +627,3 @@ // the world go boom; so we hide variables with some trickery keeping

(0, index_js_3.defineProperties)(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)) : null)
fallback: ((iface.receive || iface.fallback) ? (buildWrappedFallback(this)) : null)
});

@@ -634,3 +696,4 @@ // Return a Proxy that will respond to functions

}
return (new WrappedMethod(this, key));
const func = buildWrappedMethod(this, key);
return func;
}

@@ -641,3 +704,3 @@ getEvent(key) {

}
return (new WrappedEvent(this, key));
return buildWrappedEvent(this, key);
}

@@ -644,0 +707,0 @@ async queryTransaction(hash) {

@@ -9,2 +9,2 @@ /**

export { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./wrappers.js";
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides } from "./types.js";
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, WrappedFallback } from "./types.js";

@@ -49,1 +49,8 @@ import type { EventFragment, FunctionFragment, Result, Typed } from "../abi/index.js";

}
export interface WrappedFallback {
(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}

@@ -22,12 +22,12 @@ "use strict";

class ContractTransactionReceipt extends provider_js_1.TransactionReceipt {
#interface;
#iface;
constructor(iface, provider, tx) {
super(tx, provider);
this.#interface = iface;
this.#iface = iface;
}
get logs() {
return super.logs.map((log) => {
const fragment = log.topics.length ? this.#interface.getEvent(log.topics[0]) : null;
const fragment = log.topics.length ? this.#iface.getEvent(log.topics[0]) : null;
if (fragment) {
return new EventLog(log, this.#interface, fragment);
return new EventLog(log, this.#iface, fragment);
}

@@ -42,6 +42,6 @@ else {

class ContractTransactionResponse extends provider_js_1.TransactionResponse {
#interface;
#iface;
constructor(iface, provider, tx) {
super(tx, provider);
this.#interface = iface;
this.#iface = iface;
}

@@ -53,3 +53,3 @@ async wait(confirms) {

}
return new ContractTransactionReceipt(this.#interface, this.provider, receipt);
return new ContractTransactionReceipt(this.#iface, this.provider, receipt);
}

@@ -56,0 +56,0 @@ }

@@ -44,3 +44,3 @@ "use strict";

set s(_value) {
(0, index_js_2.assertArgument)((0, index_js_2.dataLength)(_value) === 32, "invalid r", "value", _value);
(0, index_js_2.assertArgument)((0, index_js_2.dataLength)(_value) === 32, "invalid s", "value", _value);
const value = (0, index_js_2.hexlify)(_value);

@@ -47,0 +47,0 @@ (0, index_js_2.assertArgument)(parseInt(value.substring(0, 3)) < 8, "non-canonical s", "value", value);

@@ -181,6 +181,4 @@ "use strict";

const pubKey = secp256k1.recoverPublicKey((0, index_js_1.getBytesCopy)(digest), der, sig.yParity);
if (pubKey != null) {
return (0, index_js_1.hexlify)(pubKey);
}
(0, index_js_1.assertArgument)(false, "invalid signautre for digest", "signature", signature);
(0, index_js_1.assertArgument)(pubKey != null, "invalid signautre for digest", "signature", signature);
return (0, index_js_1.hexlify)(pubKey);
}

@@ -187,0 +185,0 @@ /**

@@ -7,3 +7,3 @@ export { version } from "./_version.js";

export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync, lock, Signature, SigningKey } from "./crypto/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder } from "./hash/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder, verifyTypedData } from "./hash/index.js";
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, InfuraWebSocketProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network, EnsPlugin, EtherscanPlugin, FeeDataNetworkPlugin, GasCostPlugin, NetworkPlugin, SocketBlockSubscriber, SocketEventSubscriber, SocketPendingSubscriber, SocketSubscriber, UnmanagedSubscriber, copyRequest, showThrottleMessage } from "./providers/index.js";

@@ -16,3 +16,3 @@ export { accessListify, computeAddress, recoverAddress, Transaction } from "./transaction/index.js";

export type { Addressable, AddressLike, NameResolver } from "./address/index.js";
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, BaseContractMethod, ContractDeployTransaction, PostfixOverrides } from "./contract/index.js";
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, BaseContractMethod, ContractDeployTransaction, PostfixOverrides, WrappedFallback } from "./contract/index.js";
export type { ProgressCallback, SignatureLike } from "./crypto/index.js";

@@ -19,0 +19,0 @@ export type { TypedDataDomain, TypedDataField } from "./hash/index.js";

@@ -6,5 +6,5 @@ "use strict";

exports.sha256 = exports.ripemd160 = exports.keccak256 = exports.randomBytes = exports.computeHmac = exports.EventLog = exports.ContractUnknownEventPayload = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.ContractEventPayload = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.MessagePrefix = exports.EtherSymbol = exports.ZeroHash = exports.N = exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.ZeroAddress = exports.resolveAddress = exports.isAddress = exports.isAddressable = exports.getCreate2Address = exports.getCreateAddress = exports.getIcapAddress = exports.getAddress = exports.Typed = exports.TransactionDescription = exports.Result = exports.LogDescription = exports.Interface = exports.Indexed = exports.ErrorDescription = exports.checkResultErrors = exports.StructFragment = exports.ParamType = exports.NamedFragment = exports.FunctionFragment = exports.FallbackFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.AbiCoder = exports.encodeBytes32String = exports.decodeBytes32String = exports.version = void 0;
exports.GasCostPlugin = exports.FeeDataNetworkPlugin = exports.EtherscanPlugin = exports.EnsPlugin = exports.Network = exports.EnsResolver = exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.QuickNodeProvider = exports.PocketProvider = exports.InfuraWebSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.BrowserProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.AbstractProvider = exports.VoidSigner = exports.NonceManager = exports.AbstractSigner = exports.TransactionResponse = exports.TransactionReceipt = exports.Log = exports.FeeData = exports.Block = exports.getDefaultProvider = exports.TypedDataEncoder = exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = exports.verifyMessage = exports.hashMessage = exports.dnsEncode = exports.namehash = exports.isValidName = exports.ensNormalize = exports.id = exports.SigningKey = exports.Signature = exports.lock = exports.scryptSync = exports.scrypt = exports.pbkdf2 = exports.sha512 = void 0;
exports.toQuantity = exports.toNumber = exports.toBeHex = exports.toBigInt = exports.toBeArray = exports.getUint = exports.getNumber = exports.getBigInt = exports.FixedNumber = exports.FetchCancelSignal = exports.FetchResponse = exports.FetchRequest = exports.EventPayload = exports.isError = exports.isCallException = exports.makeError = exports.assertPrivate = exports.assertNormalize = exports.assertArgumentCount = exports.assertArgument = exports.assert = exports.resolveProperties = exports.defineProperties = exports.zeroPadValue = exports.zeroPadBytes = exports.stripZerosLeft = exports.isBytesLike = exports.isHexString = exports.hexlify = exports.getBytesCopy = exports.getBytes = exports.dataSlice = exports.dataLength = exports.concat = exports.encodeBase64 = exports.decodeBase64 = exports.encodeBase58 = exports.decodeBase58 = exports.Transaction = exports.recoverAddress = exports.computeAddress = exports.accessListify = exports.showThrottleMessage = exports.copyRequest = exports.UnmanagedSubscriber = exports.SocketSubscriber = exports.SocketPendingSubscriber = exports.SocketEventSubscriber = exports.SocketBlockSubscriber = exports.NetworkPlugin = void 0;
exports.wordlists = exports.WordlistOwlA = exports.WordlistOwl = exports.LangEn = exports.Wordlist = exports.encryptKeystoreJsonSync = exports.encryptKeystoreJson = exports.decryptKeystoreJson = exports.decryptKeystoreJsonSync = exports.decryptCrowdsaleJson = exports.isKeystoreJson = exports.isCrowdsaleJson = exports.getAccountPath = exports.defaultPath = exports.Wallet = exports.HDNodeVoidWallet = exports.HDNodeWallet = exports.BaseWallet = exports.Mnemonic = exports.uuidV4 = exports.encodeRlp = exports.decodeRlp = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.mask = exports.toTwos = exports.fromTwos = void 0;
exports.FeeDataNetworkPlugin = exports.EtherscanPlugin = exports.EnsPlugin = exports.Network = exports.EnsResolver = exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.QuickNodeProvider = exports.PocketProvider = exports.InfuraWebSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.BrowserProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.AbstractProvider = exports.VoidSigner = exports.NonceManager = exports.AbstractSigner = exports.TransactionResponse = exports.TransactionReceipt = exports.Log = exports.FeeData = exports.Block = exports.getDefaultProvider = exports.verifyTypedData = exports.TypedDataEncoder = exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = exports.verifyMessage = exports.hashMessage = exports.dnsEncode = exports.namehash = exports.isValidName = exports.ensNormalize = exports.id = exports.SigningKey = exports.Signature = exports.lock = exports.scryptSync = exports.scrypt = exports.pbkdf2 = exports.sha512 = void 0;
exports.toNumber = exports.toBeHex = exports.toBigInt = exports.toBeArray = exports.getUint = exports.getNumber = exports.getBigInt = exports.FixedNumber = exports.FetchCancelSignal = exports.FetchResponse = exports.FetchRequest = exports.EventPayload = exports.isError = exports.isCallException = exports.makeError = exports.assertPrivate = exports.assertNormalize = exports.assertArgumentCount = exports.assertArgument = exports.assert = exports.resolveProperties = exports.defineProperties = exports.zeroPadValue = exports.zeroPadBytes = exports.stripZerosLeft = exports.isBytesLike = exports.isHexString = exports.hexlify = exports.getBytesCopy = exports.getBytes = exports.dataSlice = exports.dataLength = exports.concat = exports.encodeBase64 = exports.decodeBase64 = exports.encodeBase58 = exports.decodeBase58 = exports.Transaction = exports.recoverAddress = exports.computeAddress = exports.accessListify = exports.showThrottleMessage = exports.copyRequest = exports.UnmanagedSubscriber = exports.SocketSubscriber = exports.SocketPendingSubscriber = exports.SocketEventSubscriber = exports.SocketBlockSubscriber = exports.NetworkPlugin = exports.GasCostPlugin = void 0;
exports.wordlists = exports.WordlistOwlA = exports.WordlistOwl = exports.LangEn = exports.Wordlist = exports.encryptKeystoreJsonSync = exports.encryptKeystoreJson = exports.decryptKeystoreJson = exports.decryptKeystoreJsonSync = exports.decryptCrowdsaleJson = exports.isKeystoreJson = exports.isCrowdsaleJson = exports.getAccountPath = exports.defaultPath = exports.Wallet = exports.HDNodeVoidWallet = exports.HDNodeWallet = exports.BaseWallet = exports.Mnemonic = exports.uuidV4 = exports.encodeRlp = exports.decodeRlp = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.mask = exports.toTwos = exports.fromTwos = exports.toQuantity = void 0;
var _version_js_1 = require("./_version.js");

@@ -85,2 +85,3 @@ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version_js_1.version; } });

Object.defineProperty(exports, "TypedDataEncoder", { enumerable: true, get: function () { return index_js_6.TypedDataEncoder; } });
Object.defineProperty(exports, "verifyTypedData", { enumerable: true, get: function () { return index_js_6.verifyTypedData; } });
var index_js_7 = require("./providers/index.js");

@@ -87,0 +88,0 @@ Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return index_js_7.getDefaultProvider; } });

@@ -10,3 +10,3 @@ /**

export { solidityPacked, solidityPackedKeccak256, solidityPackedSha256 } from "./solidity.js";
export { TypedDataEncoder } from "./typed-data.js";
export { TypedDataEncoder, verifyTypedData } from "./typed-data.js";
export type { TypedDataDomain, TypedDataField } from "./typed-data.js";

@@ -8,3 +8,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedDataEncoder = exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = exports.verifyMessage = exports.hashMessage = exports.dnsEncode = exports.namehash = exports.isValidName = exports.ensNormalize = exports.id = void 0;
exports.verifyTypedData = exports.TypedDataEncoder = exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = exports.verifyMessage = exports.hashMessage = exports.dnsEncode = exports.namehash = exports.isValidName = exports.ensNormalize = exports.id = void 0;
var id_js_1 = require("./id.js");

@@ -26,2 +26,3 @@ Object.defineProperty(exports, "id", { enumerable: true, get: function () { return id_js_1.id; } });

Object.defineProperty(exports, "TypedDataEncoder", { enumerable: true, get: function () { return typed_data_js_1.TypedDataEncoder; } });
Object.defineProperty(exports, "verifyTypedData", { enumerable: true, get: function () { return typed_data_js_1.verifyTypedData; } });
//# sourceMappingURL=index.js.map

@@ -0,1 +1,2 @@

import type { SignatureLike } from "../crypto/index.js";
import type { BigNumberish, BytesLike } from "../utils/index.js";

@@ -38,1 +39,5 @@ export interface TypedDataDomain {

}
/**
* Compute the address used to sign the typed data for the %%signature%%.
*/
export declare function verifyTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, signature: SignatureLike): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedDataEncoder = void 0;
exports.verifyTypedData = exports.TypedDataEncoder = void 0;
//import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer";
const index_js_1 = require("../address/index.js");
const index_js_2 = require("../crypto/index.js");
const index_js_3 = require("../utils/index.js");
const index_js_3 = require("../transaction/index.js");
const index_js_4 = require("../utils/index.js");
const id_js_1 = require("./id.js");

@@ -18,11 +19,11 @@ const padding = new Uint8Array(32);

function hexPadRight(value) {
const bytes = (0, index_js_3.getBytes)(value);
const bytes = (0, index_js_4.getBytes)(value);
const padOffset = bytes.length % 32;
if (padOffset) {
return (0, index_js_3.concat)([bytes, padding.slice(padOffset)]);
return (0, index_js_4.concat)([bytes, padding.slice(padOffset)]);
}
return (0, index_js_3.hexlify)(bytes);
return (0, index_js_4.hexlify)(bytes);
}
const hexTrue = (0, index_js_3.toBeHex)(BN_1, 32);
const hexFalse = (0, index_js_3.toBeHex)(BN_0, 32);
const hexTrue = (0, index_js_4.toBeHex)(BN_1, 32);
const hexFalse = (0, index_js_4.toBeHex)(BN_0, 32);
const domainFieldTypes = {

@@ -40,3 +41,3 @@ name: "string",

return function (value) {
(0, index_js_3.assertArgument)(typeof (value) === "string", `invalid domain value for ${JSON.stringify(key)}`, `domain.${key}`, value);
(0, index_js_4.assertArgument)(typeof (value) === "string", `invalid domain value for ${JSON.stringify(key)}`, `domain.${key}`, value);
return value;

@@ -49,3 +50,3 @@ };

chainId: function (value) {
return (0, index_js_3.getBigInt)(value, "domain.chainId");
return (0, index_js_4.getBigInt)(value, "domain.chainId");
},

@@ -57,8 +58,8 @@ verifyingContract: function (value) {

catch (error) { }
(0, index_js_3.assertArgument)(false, `invalid domain value "verifyingContract"`, "domain.verifyingContract", value);
(0, index_js_4.assertArgument)(false, `invalid domain value "verifyingContract"`, "domain.verifyingContract", value);
},
salt: function (value) {
const bytes = (0, index_js_3.getBytes)(value, "domain.salt");
(0, index_js_3.assertArgument)(bytes.length === 32, `invalid domain value "salt"`, "domain.salt", value);
return (0, index_js_3.hexlify)(bytes);
const bytes = (0, index_js_4.getBytes)(value, "domain.salt");
(0, index_js_4.assertArgument)(bytes.length === 32, `invalid domain value "salt"`, "domain.salt", value);
return (0, index_js_4.hexlify)(bytes);
}

@@ -73,9 +74,9 @@ };

const width = parseInt(match[2] || "256");
(0, index_js_3.assertArgument)(width % 8 === 0 && width !== 0 && width <= 256 && (match[2] == null || match[2] === String(width)), "invalid numeric width", "type", type);
const boundsUpper = (0, index_js_3.mask)(BN_MAX_UINT256, signed ? (width - 1) : width);
(0, index_js_4.assertArgument)(width % 8 === 0 && width !== 0 && width <= 256 && (match[2] == null || match[2] === String(width)), "invalid numeric width", "type", type);
const boundsUpper = (0, index_js_4.mask)(BN_MAX_UINT256, signed ? (width - 1) : width);
const boundsLower = signed ? ((boundsUpper + BN_1) * BN__1) : BN_0;
return function (_value) {
const value = (0, index_js_3.getBigInt)(_value, "value");
(0, index_js_3.assertArgument)(value >= boundsLower && value <= boundsUpper, `value out-of-bounds for ${type}`, "value", value);
return (0, index_js_3.toBeHex)((0, index_js_3.toTwos)(value, 256), 32);
const value = (0, index_js_4.getBigInt)(_value, "value");
(0, index_js_4.assertArgument)(value >= boundsLower && value <= boundsUpper, `value out-of-bounds for ${type}`, "value", value);
return (0, index_js_4.toBeHex)((0, index_js_4.toTwos)(value, 256), 32);
};

@@ -89,6 +90,6 @@ }

const width = parseInt(match[1]);
(0, index_js_3.assertArgument)(width !== 0 && width <= 32 && match[1] === String(width), "invalid bytes width", "type", type);
(0, index_js_4.assertArgument)(width !== 0 && width <= 32 && match[1] === String(width), "invalid bytes width", "type", type);
return function (value) {
const bytes = (0, index_js_3.getBytes)(value);
(0, index_js_3.assertArgument)(bytes.length === width, `invalid length for ${type}`, "value", value);
const bytes = (0, index_js_4.getBytes)(value);
(0, index_js_4.assertArgument)(bytes.length === width, `invalid length for ${type}`, "value", value);
return hexPadRight(value);

@@ -100,3 +101,3 @@ };

case "address": return function (value) {
return (0, index_js_3.zeroPadValue)((0, index_js_1.getAddress)(value), 32);
return (0, index_js_4.zeroPadValue)((0, index_js_1.getAddress)(value), 32);
};

@@ -145,7 +146,7 @@ case "bool": return function (value) {

// Check each field has a unique name
(0, index_js_3.assertArgument)(!uniqueNames.has(field.name), `duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", types);
(0, index_js_4.assertArgument)(!uniqueNames.has(field.name), `duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", types);
uniqueNames.add(field.name);
// Get the base type (drop any array specifiers)
const baseType = (field.type.match(/^([^\x5b]*)(\x5b|$)/))[1] || null;
(0, index_js_3.assertArgument)(baseType !== name, `circular type reference to ${JSON.stringify(baseType)}`, "types", types);
(0, index_js_4.assertArgument)(baseType !== name, `circular type reference to ${JSON.stringify(baseType)}`, "types", types);
// Is this a base encoding type?

@@ -156,3 +157,3 @@ const encoder = getBaseEncoder(baseType);

}
(0, index_js_3.assertArgument)(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, "types", types);
(0, index_js_4.assertArgument)(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, "types", types);
// Add linkage

@@ -165,8 +166,8 @@ parents.get(baseType).push(name);

const primaryTypes = Array.from(parents.keys()).filter((n) => (parents.get(n).length === 0));
(0, index_js_3.assertArgument)(primaryTypes.length !== 0, "missing primary type", "types", types);
(0, index_js_3.assertArgument)(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", types);
(0, index_js_3.defineProperties)(this, { primaryType: primaryTypes[0] });
(0, index_js_4.assertArgument)(primaryTypes.length !== 0, "missing primary type", "types", types);
(0, index_js_4.assertArgument)(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", types);
(0, index_js_4.defineProperties)(this, { primaryType: primaryTypes[0] });
// Check for circular type references
function checkCircular(type, found) {
(0, index_js_3.assertArgument)(!found.has(type), `circular type reference to ${JSON.stringify(type)}`, "types", types);
(0, index_js_4.assertArgument)(!found.has(type), `circular type reference to ${JSON.stringify(type)}`, "types", types);
found.add(type);

@@ -216,3 +217,3 @@ for (const child of links.get(type)) {

return (value) => {
(0, index_js_3.assertArgument)(!match[3] || parseInt(match[3]) === value.length, `array length mismatch; expected length ${parseInt(match[3])}`, "value", value);
(0, index_js_4.assertArgument)(!match[3] || parseInt(match[3]) === value.length, `array length mismatch; expected length ${parseInt(match[3])}`, "value", value);
let result = value.map(subEncoder);

@@ -222,3 +223,3 @@ if (this.#fullTypes.has(subtype)) {

}
return (0, index_js_2.keccak256)((0, index_js_3.concat)(result));
return (0, index_js_2.keccak256)((0, index_js_4.concat)(result));
};

@@ -239,10 +240,10 @@ }

values.unshift(encodedType);
return (0, index_js_3.concat)(values);
return (0, index_js_4.concat)(values);
};
}
(0, index_js_3.assertArgument)(false, `unknown type: ${type}`, "type", type);
(0, index_js_4.assertArgument)(false, `unknown type: ${type}`, "type", type);
}
encodeType(name) {
const result = this.#fullTypes.get(name);
(0, index_js_3.assertArgument)(result, `unknown type: ${JSON.stringify(name)}`, "name", name);
(0, index_js_4.assertArgument)(result, `unknown type: ${JSON.stringify(name)}`, "name", name);
return result;

@@ -273,3 +274,3 @@ }

if (match) {
(0, index_js_3.assertArgument)(!match[3] || parseInt(match[3]) === value.length, `array length mismatch; expected length ${parseInt(match[3])}`, "value", value);
(0, index_js_4.assertArgument)(!match[3] || parseInt(match[3]) === value.length, `array length mismatch; expected length ${parseInt(match[3])}`, "value", value);
return value.map((v) => this._visit(match[1], v, callback));

@@ -285,3 +286,3 @@ }

}
(0, index_js_3.assertArgument)(false, `unknown type: ${type}`, "type", type);
(0, index_js_4.assertArgument)(false, `unknown type: ${type}`, "type", type);
}

@@ -307,3 +308,3 @@ visit(value, callback) {

const type = domainFieldTypes[name];
(0, index_js_3.assertArgument)(type, `invalid typed-data domain key: ${JSON.stringify(name)}`, "domain", domain);
(0, index_js_4.assertArgument)(type, `invalid typed-data domain key: ${JSON.stringify(name)}`, "domain", domain);
domainFields.push({ name, type });

@@ -317,3 +318,3 @@ }

static encode(domain, types, value) {
return (0, index_js_3.concat)([
return (0, index_js_4.concat)([
"0x1901",

@@ -340,3 +341,3 @@ TypedDataEncoder.hashDomain(domain),

// Do we need to look up the domain's verifyingContract?
if (domain.verifyingContract && !(0, index_js_3.isHexString)(domain.verifyingContract, 20)) {
if (domain.verifyingContract && !(0, index_js_4.isHexString)(domain.verifyingContract, 20)) {
ensCache[domain.verifyingContract] = "0x";

@@ -348,3 +349,3 @@ }

encoder.visit(value, (type, value) => {
if (type === "address" && !(0, index_js_3.isHexString)(value, 20)) {
if (type === "address" && !(0, index_js_4.isHexString)(value, 20)) {
ensCache[value] = "0x";

@@ -387,3 +388,3 @@ }

const typesWithDomain = Object.assign({}, types);
(0, index_js_3.assertArgument)(typesWithDomain.EIP712Domain == null, "types must not contain EIP712Domain type", "types.EIP712Domain", types);
(0, index_js_4.assertArgument)(typesWithDomain.EIP712Domain == null, "types must not contain EIP712Domain type", "types.EIP712Domain", types);
typesWithDomain.EIP712Domain = domainTypes;

@@ -399,7 +400,7 @@ // Validate the data structures and types

if (type.match(/^bytes(\d*)/)) {
return (0, index_js_3.hexlify)((0, index_js_3.getBytes)(value));
return (0, index_js_4.hexlify)((0, index_js_4.getBytes)(value));
}
// uint or int
if (type.match(/^u?int/)) {
return (0, index_js_3.getBigInt)(value).toString();
return (0, index_js_4.getBigInt)(value).toString();
}

@@ -412,6 +413,6 @@ switch (type) {

case "string":
(0, index_js_3.assertArgument)(typeof (value) === "string", "invalid string", "value", value);
(0, index_js_4.assertArgument)(typeof (value) === "string", "invalid string", "value", value);
return value;
}
(0, index_js_3.assertArgument)(false, "unsupported type", "type", type);
(0, index_js_4.assertArgument)(false, "unsupported type", "type", type);
})

@@ -422,2 +423,9 @@ };

exports.TypedDataEncoder = TypedDataEncoder;
/**
* Compute the address used to sign the typed data for the %%signature%%.
*/
function verifyTypedData(domain, types, value, signature) {
return (0, index_js_3.recoverAddress)(TypedDataEncoder.hash(domain, types, value), signature);
}
exports.verifyTypedData = verifyTypedData;
//# sourceMappingURL=typed-data.js.map

@@ -269,3 +269,3 @@ "use strict";

_wrapTransactionResponse(tx, network) {
return new provider_js_1.TransactionResponse(tx, this);
return new provider_js_1.TransactionResponse((0, format_js_1.formatTransactionResponse)(tx), this);
}

@@ -648,3 +648,3 @@ _detectNetwork() {

}
return this._wrapBlock((0, format_js_1.formatBlock)(params), network);
return this._wrapBlock(params, network);
}

@@ -659,3 +659,3 @@ async getTransaction(hash) {

}
return this._wrapTransactionResponse((0, format_js_1.formatTransactionResponse)(params), network);
return this._wrapTransactionResponse(params, network);
}

@@ -679,3 +679,3 @@ async getTransactionReceipt(hash) {

}
return this._wrapTransactionReceipt((0, format_js_1.formatTransactionReceipt)(params), network);
return this._wrapTransactionReceipt(params, network);
}

@@ -702,3 +702,3 @@ async getTransactionResult(hash) {

});
return params.map((p) => this._wrapLog((0, format_js_1.formatLog)(p), network));
return params.map((p) => this._wrapLog(p, network));
}

@@ -705,0 +705,0 @@ // ENS

@@ -38,3 +38,3 @@ "use strict";

}
if (options.ankr !== "-") {
if (options.ankr !== "-" && options.ankr != null) {
try {

@@ -41,0 +41,0 @@ providers.push(new provider_ankr_js_1.AnkrProvider(network, options.ankr));

@@ -64,3 +64,3 @@ /**

/**
* The name this resovler was resolved against.
* The name this resolver was resolved against.
*/

@@ -79,3 +79,3 @@ name: string;

/**
* Resovles to the EIP-643 text record for %%key%%, or ``null``
* Resolves to the EIP-643 text record for %%key%%, or ``null``
* if unconfigured.

@@ -82,0 +82,0 @@ */

@@ -82,3 +82,3 @@ "use strict";

/**
* The name this resovler was resolved against.
* The name this resolver was resolved against.
*/

@@ -212,3 +212,3 @@ name;

/**
* Resovles to the EIP-643 text record for %%key%%, or ``null``
* Resolves to the EIP-643 text record for %%key%%, or ``null``
* if unconfigured.

@@ -215,0 +215,0 @@ */

@@ -57,3 +57,2 @@ "use strict";

async _write(message) {
console.log(">>>", message);
this.socket.write(message);

@@ -60,0 +59,0 @@ }

@@ -247,3 +247,3 @@ "use strict";

if (resp == null) {
return reject(new Error("@TODO: no result"));
return reject((0, index_js_5.makeError)("no response from server", "BAD_DATA", { value: result, info: { payload } }));
}

@@ -579,2 +579,3 @@ // The response is an error

transaction: (payload.params[0]),
info: { payload, error }
});

@@ -616,11 +617,11 @@ }

if (message.match(/nonce/i) && message.match(/too low/i)) {
return (0, index_js_5.makeError)("nonce has already been used", "NONCE_EXPIRED", { transaction });
return (0, index_js_5.makeError)("nonce has already been used", "NONCE_EXPIRED", { transaction, info: { error } });
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) {
return (0, index_js_5.makeError)("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction });
return (0, index_js_5.makeError)("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction, info: { error } });
}
if (message.match(/only replay-protected/i)) {
return (0, index_js_5.makeError)("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {
operation: method, info: { transaction }
operation: method, info: { transaction, info: { error } }
});

@@ -627,0 +628,0 @@ }

@@ -86,2 +86,9 @@ import type { AddressLike, NameResolver } from "../address/index.js";

export declare function copyRequest(req: TransactionRequest): PreparedTransactionRequest;
/**
* An Interface to indicate a [[Block]] has been included in the
* blockchain. This asserts a Type Guard that necessary properties
* are non-null.
*
* Before a block is included, it is a //pending// block.
*/
export interface MinedBlock extends Block {

@@ -270,26 +277,158 @@ readonly number: number;

#private;
/**
* The provider this is connected to, which will influence how its
* methods will resolve its async inspection methods.
*/
readonly provider: Provider;
/**
* The block number of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
readonly blockNumber: null | number;
/**
* The blockHash of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
readonly blockHash: null | string;
/**
* The index within the block that this transaction resides at.
*/
readonly index: number;
/**
* The transaction hash.
*/
readonly hash: string;
/**
* The [[link-eip-2718]] transaction envelope type. This is
* ``0`` for legacy transactions types.
*/
readonly type: number;
/**
* The receiver of this transaction.
*
* If ``null``, then the transaction is an initcode transaction.
* This means the result of executing the [[data]] will be deployed
* as a new contract on chain (assuming it does not revert) and the
* address may be computed using [[getCreateAddress]].
*/
readonly to: null | string;
/**
* The sender of this transaction. It is implicitly computed
* from the transaction pre-image hash (as the digest) and the
* [[signature]] using ecrecover.
*/
readonly from: string;
/**
* The nonce, which is used to prevent replay attacks and offer
* a method to ensure transactions from a given sender are explicitly
* ordered.
*
* When sending a transaction, this must be equal to the number of
* transactions ever sent by [[from]].
*/
readonly nonce: number;
/**
* The maximum units of gas this transaction can consume. If execution
* exceeds this, the entries transaction is reverted and the sender
* is charged for the full amount, despite not state changes being made.
*/
readonly gasLimit: bigint;
/**
* The gas price can have various values, depending on the network.
*
* In modern networks, for transactions that are included this is
* the //effective gas price// (the fee per gas that was actually
* charged), while for transactions that have not been included yet
* is the [[maxFeePerGas]].
*
* For legacy transactions, or transactions on legacy networks, this
* is the fee that will be charged per unit of gas the transaction
* consumes.
*/
readonly gasPrice: bigint;
/**
* The maximum priority fee (per unit of gas) to allow a
* validator to charge the sender. This is inclusive of the
* [[maxFeeFeePerGas]].
*/
readonly maxPriorityFeePerGas: null | bigint;
/**
* The maximum fee (per unit of gas) to allow this transaction
* to charge the sender.
*/
readonly maxFeePerGas: null | bigint;
/**
* The data.
*/
readonly data: string;
/**
* The value, in wei. Use [[formatEther]] to format this value
* as ether.
*/
readonly value: bigint;
/**
* The chain ID.
*/
readonly chainId: bigint;
/**
* The signature.
*/
readonly signature: Signature;
/**
* The [[link-eip-2930]] access list for transaction types that
* support it, otherwise ``null``.
*/
readonly accessList: null | AccessList;
/**
* Create a new TransactionResponse with %%tx%% parameters
* connected to %%provider%%.
*/
constructor(tx: TransactionResponseParams, provider: Provider);
/**
* Returns a JSON representation of this transaction.
*/
toJSON(): any;
/**
* Resolves to the Block that this transaction was included in.
*
* This will return null if the transaction has not been included yet.
*/
getBlock(): Promise<null | Block>;
/**
* Resolves to this transaction being re-requested from the
* provider. This can be used if you have an unmined transaction
* and wish to get an up-to-date populated instance.
*/
getTransaction(): Promise<null | TransactionResponse>;
/**
* Resolves once this transaction has been mined and has
* %%confirms%% blocks including it (default: ``1``) with an
* optional %%timeout%%.
*
* This can resolve to ``null`` only if %%confirms%% is ``0``
* and the transaction has not been mined, otherwise this will
* wait until enough confirmations have completed.
*/
wait(_confirms?: number, _timeout?: number): Promise<null | TransactionReceipt>;
/**
* Returns ``true`` if this transaction has been included.
*
* This is effective only as of the time the TransactionResponse
* was instantiated. To get up-to-date information, use
* [[getTransaction]].
*
* This provides a Type Guard that this transaction will have
* non-null property values for properties that are null for
* unmined transactions.
*/
isMined(): this is MinedTransactionResponse;
/**
* Returns true if the transaction is a legacy (i.e. ``type == 0``)
* transaction.
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLegacy(): this is (TransactionResponse & {

@@ -300,2 +439,9 @@ accessList: null;

});
/**
* Returns true if the transaction is a Berlin (i.e. ``type == 1``)
* transaction. See [[link-eip-2070]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isBerlin(): this is (TransactionResponse & {

@@ -306,2 +452,9 @@ accessList: AccessList;

});
/**
* Returns true if the transaction is a London (i.e. ``type == 2``)
* transaction. See [[link-eip-1559]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLondon(): this is (TransactionResponse & {

@@ -312,3 +465,11 @@ accessList: AccessList;

});
/**
* Returns a filter which can be used to listen for orphan events
* that evict this transaction.
*/
removedEvent(): OrphanFilter;
/**
* Returns a filter which can be used to listen for orphan events
* that re-order this event against %%other%%.
*/
reorderedEvent(other?: TransactionResponse): OrphanFilter;

@@ -326,2 +487,9 @@ /**

}
/**
* An Orphan Filter allows detecting when an orphan block has
* resulted in dropping a block or transaction or has resulted
* in transactions changing order.
*
* Not currently fully supported.
*/
export type OrphanFilter = {

@@ -367,2 +535,11 @@ orphan: "drop-block";

};
/**
* A **TopicFilter** provides a struture to define bloom-filter
* queries.
*
* Each field that is ``null`` matches **any** value, a field that is
* a ``string`` must match exactly that value and and ``array`` is
* effectively an ``OR``-ed set, where any one of those values must
* match.
*/
export type TopicFilter = Array<null | string | Array<string>>;

@@ -369,0 +546,0 @@ export interface EventFilter {

@@ -546,21 +546,113 @@ "use strict";

class TransactionResponse {
/**
* The provider this is connected to, which will influence how its
* methods will resolve its async inspection methods.
*/
provider;
/**
* The block number of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
blockNumber;
/**
* The blockHash of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
blockHash;
/**
* The index within the block that this transaction resides at.
*/
index;
/**
* The transaction hash.
*/
hash;
/**
* The [[link-eip-2718]] transaction envelope type. This is
* ``0`` for legacy transactions types.
*/
type;
/**
* The receiver of this transaction.
*
* If ``null``, then the transaction is an initcode transaction.
* This means the result of executing the [[data]] will be deployed
* as a new contract on chain (assuming it does not revert) and the
* address may be computed using [[getCreateAddress]].
*/
to;
/**
* The sender of this transaction. It is implicitly computed
* from the transaction pre-image hash (as the digest) and the
* [[signature]] using ecrecover.
*/
from;
/**
* The nonce, which is used to prevent replay attacks and offer
* a method to ensure transactions from a given sender are explicitly
* ordered.
*
* When sending a transaction, this must be equal to the number of
* transactions ever sent by [[from]].
*/
nonce;
/**
* The maximum units of gas this transaction can consume. If execution
* exceeds this, the entries transaction is reverted and the sender
* is charged for the full amount, despite not state changes being made.
*/
gasLimit;
/**
* The gas price can have various values, depending on the network.
*
* In modern networks, for transactions that are included this is
* the //effective gas price// (the fee per gas that was actually
* charged), while for transactions that have not been included yet
* is the [[maxFeePerGas]].
*
* For legacy transactions, or transactions on legacy networks, this
* is the fee that will be charged per unit of gas the transaction
* consumes.
*/
gasPrice;
/**
* The maximum priority fee (per unit of gas) to allow a
* validator to charge the sender. This is inclusive of the
* [[maxFeeFeePerGas]].
*/
maxPriorityFeePerGas;
/**
* The maximum fee (per unit of gas) to allow this transaction
* to charge the sender.
*/
maxFeePerGas;
/**
* The data.
*/
data;
/**
* The value, in wei. Use [[formatEther]] to format this value
* as ether.
*/
value;
/**
* The chain ID.
*/
chainId;
/**
* The signature.
*/
signature;
/**
* The [[link-eip-2930]] access list for transaction types that
* support it, otherwise ``null``.
*/
accessList;
#startBlock;
/**
* Create a new TransactionResponse with %%tx%% parameters
* connected to %%provider%%.
*/
constructor(tx, provider) {

@@ -587,2 +679,5 @@ this.provider = provider;

}
/**
* Returns a JSON representation of this transaction.
*/
toJSON() {

@@ -604,2 +699,7 @@ const { blockNumber, blockHash, index, hash, type, to, from, nonce, data, signature, accessList } = this;

}
/**
* Resolves to the Block that this transaction was included in.
*
* This will return null if the transaction has not been included yet.
*/
async getBlock() {

@@ -622,5 +722,19 @@ let blockNumber = this.blockNumber;

}
/**
* Resolves to this transaction being re-requested from the
* provider. This can be used if you have an unmined transaction
* and wish to get an up-to-date populated instance.
*/
async getTransaction() {
return this.provider.getTransaction(this.hash);
}
/**
* Resolves once this transaction has been mined and has
* %%confirms%% blocks including it (default: ``1``) with an
* optional %%timeout%%.
*
* This can resolve to ``null`` only if %%confirms%% is ``0``
* and the transaction has not been mined, otherwise this will
* wait until enough confirmations have completed.
*/
async wait(_confirms, _timeout) {

@@ -780,14 +894,50 @@ const confirms = (_confirms == null) ? 1 : _confirms;

}
/**
* Returns ``true`` if this transaction has been included.
*
* This is effective only as of the time the TransactionResponse
* was instantiated. To get up-to-date information, use
* [[getTransaction]].
*
* This provides a Type Guard that this transaction will have
* non-null property values for properties that are null for
* unmined transactions.
*/
isMined() {
return (this.blockHash != null);
}
/**
* Returns true if the transaction is a legacy (i.e. ``type == 0``)
* transaction.
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLegacy() {
return (this.type === 0);
}
/**
* Returns true if the transaction is a Berlin (i.e. ``type == 1``)
* transaction. See [[link-eip-2070]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isBerlin() {
return (this.type === 1);
}
/**
* Returns true if the transaction is a London (i.e. ``type == 2``)
* transaction. See [[link-eip-1559]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLondon() {
return (this.type === 2);
}
/**
* Returns a filter which can be used to listen for orphan events
* that evict this transaction.
*/
removedEvent() {

@@ -797,2 +947,6 @@ (0, index_js_1.assert)(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });

}
/**
* Returns a filter which can be used to listen for orphan events
* that re-order this event against %%other%%.
*/
reorderedEvent(other) {

@@ -799,0 +953,0 @@ (0, index_js_1.assert)(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });

@@ -104,3 +104,3 @@ "use strict";

let chainId = BN_0;
if (tx.chainId != null) {
if (tx.chainId != BN_0) {
// A chainId was provided; if non-zero we'll use EIP-155

@@ -112,5 +112,5 @@ chainId = (0, index_js_3.getBigInt)(tx.chainId, "tx.chainId");

}
else if (sig) {
// No chainId provided, but the signature is signing with EIP-155; derive chainId
const legacy = sig.legacyChainId;
else if (tx.signature) {
// No explicit chainId, but EIP-155 have a derived implicit chainId
const legacy = tx.signature.legacyChainId;
if (legacy != null) {

@@ -130,3 +130,6 @@ chainId = legacy;

}
// We pushed a chainId and null r, s on for hashing only; remove those
// @TODO: We should probably check that tx.signature, chainId, and sig
// match but that logic could break existing code, so schedule
// this for the next major bump.
// Compute the EIP-155 v
let v = BigInt(27 + sig.yParity);

@@ -139,2 +142,3 @@ if (chainId !== BN_0) {

}
// Add the signature
fields.push((0, index_js_3.toBeArray)(v));

@@ -141,0 +145,0 @@ fields.push((0, index_js_3.toBeArray)(sig.r));

@@ -181,3 +181,3 @@ export type GetUrlResponse = {

* Once created, each property may be set before issuing a
* ``.send()`` to make teh request.
* ``.send()`` to make the request.
*/

@@ -184,0 +184,0 @@ constructor(url: string);

@@ -358,3 +358,3 @@ "use strict";

* Once created, each property may be set before issuing a
* ``.send()`` to make teh request.
* ``.send()`` to make the request.
*/

@@ -361,0 +361,0 @@ constructor(url) {

@@ -5,3 +5,3 @@ /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */

*/
export const version = "6.1.0";
export const version = "6.2.0";
//# sourceMappingURL=_version.js.map

@@ -57,3 +57,2 @@ /**

}));
return t;
}));

@@ -60,0 +59,0 @@ }

@@ -58,5 +58,2 @@ import { Interface, Typed } from "../abi/index.js";

//export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = ContractTransactionResponse> {
function _WrappedMethodBase() {
return Function;
}
function getRunner(value, feature) {

@@ -111,34 +108,100 @@ if (value == null) {

}
function buildWrappedFallback(contract) {
const populateTransaction = async function (overrides) {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(overrides, ["data"]));
tx.to = await contract.getAddress();
const iface = contract.interface;
// Only allow payable contracts to set non-zero value
const payable = iface.receive || (iface.fallback && iface.fallback.payable);
assertArgument(payable || (tx.value || BN_0) === BN_0, "cannot send value to non-payable contract", "overrides.value", tx.value);
// Only allow fallback contracts to set non-empty data
assertArgument(iface.fallback || (tx.data || "0x") === "0x", "cannot send data to receive-only contract", "overrides.data", tx.data);
return tx;
};
const staticCall = async function (overrides) {
const runner = getRunner(contract.runner, "call");
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await populateTransaction(overrides);
try {
return await runner.call(tx);
}
catch (error) {
if (isCallException(error) && error.data) {
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
};
const send = async function (overrides) {
const runner = contract.runner;
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await populateTransaction(overrides));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new ContractTransactionResponse(contract.interface, provider, tx);
};
const estimateGas = async function (overrides) {
const runner = getRunner(contract.runner, "estimateGas");
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await populateTransaction(overrides));
};
const method = async (overrides) => {
return await send(overrides);
};
defineProperties(method, {
_contract: contract,
estimateGas,
populateTransaction,
send, staticCall
});
return method;
}
/*
class WrappedFallback {
_contract;
constructor(contract) {
defineProperties(this, { _contract: contract });
constructor (contract: BaseContract) {
defineProperties<WrappedFallback>(this, { _contract: contract });
const proxy = new Proxy(this, {
// Perform send when called
apply: async (target, thisArg, args) => {
apply: async (target, thisArg, args: Array<any>) => {
return await target.send(...args);
},
});
return proxy;
}
async populateTransaction(overrides) {
async populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction> {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(overrides, ["data"]));
const tx: ContractTransaction = <any>(await copyOverrides<"data">(overrides, [ "data" ]));
tx.to = await this._contract.getAddress();
const iface = this._contract.interface;
// Only allow payable contracts to set non-zero value
const payable = iface.receive || (iface.fallback && iface.fallback.payable);
assertArgument(payable || (tx.value || BN_0) === BN_0, "cannot send value to non-payable contract", "overrides.value", tx.value);
assertArgument(payable || (tx.value || BN_0) === BN_0,
"cannot send value to non-payable contract", "overrides.value", tx.value);
// Only allow fallback contracts to set non-empty data
assertArgument(iface.fallback || (tx.data || "0x") === "0x", "cannot send data to receive-only contract", "overrides.data", tx.data);
assertArgument(iface.fallback || (tx.data || "0x") === "0x",
"cannot send data to receive-only contract", "overrides.data", tx.data);
return tx;
}
async staticCall(overrides) {
async staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string> {
const runner = getRunner(this._contract.runner, "call");
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
assert(canCall(runner), "contract runner does not support calling",
"UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(overrides);
try {
return await runner.call(tx);
}
catch (error) {
} catch (error: any) {
if (isCallException(error) && error.data) {

@@ -150,5 +213,8 @@ throw this._contract.interface.makeError(error.data, tx);

}
async send(overrides) {
async send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse> {
const runner = this._contract.runner;
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
assert(canSend(runner), "contract runner does not support sending transactions",
"UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(overrides));

@@ -158,35 +224,17 @@ const provider = getProvider(this._contract.runner);

// meaningful error
return new ContractTransactionResponse(this._contract.interface, provider, tx);
return new ContractTransactionResponse(this._contract.interface, <Provider>provider, tx);
}
async estimateGas(overrides) {
async estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint> {
const runner = getRunner(this._contract.runner, "estimateGas");
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
assert(canEstimate(runner), "contract runner does not support gas estimation",
"UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(overrides));
}
}
class WrappedMethod extends _WrappedMethodBase() {
name = ""; // Investigate!
_contract;
_key;
constructor(contract, key) {
super();
defineProperties(this, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key
});
const proxy = new Proxy(this, {
// Perform the default operation for this fragment type
apply: async (target, thisArg, args) => {
const fragment = target.getFragment(...args);
if (fragment.constant) {
return await target.staticCall(...args);
}
return await target.send(...args);
},
});
return proxy;
}
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
get fragment() {
const fragment = this._contract.interface.getFunction(this._key);
*/
function buildWrappedMethod(contract, key) {
const getFragment = function (...args) {
const fragment = contract.interface.getFunction(key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {

@@ -196,12 +244,5 @@ operation: "fragment"

return fragment;
}
getFragment(...args) {
const fragment = this._contract.interface.getFunction(this._key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
async populateTransaction(...args) {
const fragment = this.getFragment(...args);
};
const populateTransaction = async function (...args) {
const fragment = getFragment(...args);
// If an overrides was passed in, copy it and normalize the values

@@ -215,10 +256,10 @@ let overrides = {};

}
const resolvedArgs = await resolveArgs(this._contract.runner, fragment.inputs, args);
const resolvedArgs = await resolveArgs(contract.runner, fragment.inputs, args);
return Object.assign({}, overrides, await resolveProperties({
to: this._contract.getAddress(),
data: this._contract.interface.encodeFunctionData(fragment, resolvedArgs)
to: contract.getAddress(),
data: contract.interface.encodeFunctionData(fragment, resolvedArgs)
}));
}
async staticCall(...args) {
const result = await this.staticCallResult(...args);
};
const staticCall = async function (...args) {
const result = await staticCallResult(...args);
if (result.length === 1) {

@@ -228,21 +269,21 @@ return result[0];

return result;
}
async send(...args) {
const runner = this._contract.runner;
};
const send = async function (...args) {
const runner = contract.runner;
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(...args));
const provider = getProvider(this._contract.runner);
const tx = await runner.sendTransaction(await populateTransaction(...args));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new ContractTransactionResponse(this._contract.interface, provider, tx);
}
async estimateGas(...args) {
const runner = getRunner(this._contract.runner, "estimateGas");
return new ContractTransactionResponse(contract.interface, provider, tx);
};
const estimateGas = async function (...args) {
const runner = getRunner(contract.runner, "estimateGas");
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(...args));
}
async staticCallResult(...args) {
const runner = getRunner(this._contract.runner, "call");
return await runner.estimateGas(await populateTransaction(...args));
};
const staticCallResult = async function (...args) {
const runner = getRunner(contract.runner, "call");
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(...args);
const tx = await populateTransaction(...args);
let result = "0x";

@@ -254,33 +295,41 @@ try {

if (isCallException(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
const fragment = this.getFragment(...args);
return this._contract.interface.decodeFunctionResult(fragment, result);
}
const fragment = getFragment(...args);
return contract.interface.decodeFunctionResult(fragment, result);
};
const method = async (...args) => {
const fragment = getFragment(...args);
if (fragment.constant) {
return await staticCall(...args);
}
return await send(...args);
};
defineProperties(method, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key,
getFragment,
estimateGas,
populateTransaction,
send, staticCall, staticCallResult,
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getFunction(key);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return method;
}
function _WrappedEventBase() {
return Function;
}
class WrappedEvent extends _WrappedEventBase() {
name = ""; // @TODO: investigate
_contract;
_key;
constructor(contract, key) {
super();
defineProperties(this, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key
});
return new Proxy(this, {
// Perform the default operation for this fragment type
apply: (target, thisArg, args) => {
return new PreparedTopicFilter(contract, target.getFragment(...args), args);
},
});
}
// Only works on non-ambiguous keys
get fragment() {
const fragment = this._contract.interface.getEvent(this._key);
function buildWrappedEvent(contract, key) {
const getFragment = function (...args) {
const fragment = contract.interface.getEvent(key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {

@@ -290,12 +339,25 @@ operation: "fragment"

return fragment;
}
getFragment(...args) {
const fragment = this._contract.interface.getEvent(this._key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
};
const method = function (...args) {
return new PreparedTopicFilter(contract, getFragment(...args), args);
};
defineProperties(method, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key,
getFragment
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getEvent(key);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return method;
}
;
// The combination of TypeScrype, Private Fields and Proxies makes

@@ -560,3 +622,3 @@ // the world go boom; so we hide variables with some trickery keeping

defineProperties(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)) : null)
fallback: ((iface.receive || iface.fallback) ? (buildWrappedFallback(this)) : null)
});

@@ -629,3 +691,4 @@ // Return a Proxy that will respond to functions

}
return (new WrappedMethod(this, key));
const func = buildWrappedMethod(this, key);
return func;
}

@@ -636,3 +699,3 @@ getEvent(key) {

}
return (new WrappedEvent(this, key));
return buildWrappedEvent(this, key);
}

@@ -639,0 +702,0 @@ async queryTransaction(hash) {

@@ -18,12 +18,12 @@ // import from provider.ts instead of index.ts to prevent circular dep

export class ContractTransactionReceipt extends TransactionReceipt {
#interface;
#iface;
constructor(iface, provider, tx) {
super(tx, provider);
this.#interface = iface;
this.#iface = iface;
}
get logs() {
return super.logs.map((log) => {
const fragment = log.topics.length ? this.#interface.getEvent(log.topics[0]) : null;
const fragment = log.topics.length ? this.#iface.getEvent(log.topics[0]) : null;
if (fragment) {
return new EventLog(log, this.#interface, fragment);
return new EventLog(log, this.#iface, fragment);
}

@@ -37,6 +37,6 @@ else {

export class ContractTransactionResponse extends TransactionResponse {
#interface;
#iface;
constructor(iface, provider, tx) {
super(tx, provider);
this.#interface = iface;
this.#iface = iface;
}

@@ -48,3 +48,3 @@ async wait(confirms) {

}
return new ContractTransactionReceipt(this.#interface, this.provider, receipt);
return new ContractTransactionReceipt(this.#iface, this.provider, receipt);
}

@@ -51,0 +51,0 @@ }

@@ -41,3 +41,3 @@ import { ZeroHash } from "../constants/index.js";

set s(_value) {
assertArgument(dataLength(_value) === 32, "invalid r", "value", _value);
assertArgument(dataLength(_value) === 32, "invalid s", "value", _value);
const value = hexlify(_value);

@@ -44,0 +44,0 @@ assertArgument(parseInt(value.substring(0, 3)) < 8, "non-canonical s", "value", value);

@@ -155,6 +155,4 @@ /**

const pubKey = secp256k1.recoverPublicKey(getBytesCopy(digest), der, sig.yParity);
if (pubKey != null) {
return hexlify(pubKey);
}
assertArgument(false, "invalid signautre for digest", "signature", signature);
assertArgument(pubKey != null, "invalid signautre for digest", "signature", signature);
return hexlify(pubKey);
}

@@ -161,0 +159,0 @@ /**

@@ -9,3 +9,3 @@ /////////////////////////////

export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync, lock, Signature, SigningKey } from "./crypto/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder } from "./hash/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder, verifyTypedData } from "./hash/index.js";
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, InfuraWebSocketProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network, EnsPlugin, EtherscanPlugin, FeeDataNetworkPlugin, GasCostPlugin, NetworkPlugin, SocketBlockSubscriber, SocketEventSubscriber, SocketPendingSubscriber, SocketSubscriber, UnmanagedSubscriber, copyRequest, showThrottleMessage } from "./providers/index.js";

@@ -12,0 +12,0 @@ export { accessListify, computeAddress, recoverAddress, Transaction } from "./transaction/index.js";

@@ -10,3 +10,3 @@ /**

export { solidityPacked, solidityPackedKeccak256, solidityPackedSha256 } from "./solidity.js";
export { TypedDataEncoder } from "./typed-data.js";
export { TypedDataEncoder, verifyTypedData } from "./typed-data.js";
//# sourceMappingURL=index.js.map
//import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer";
import { getAddress } from "../address/index.js";
import { keccak256 } from "../crypto/index.js";
import { recoverAddress } from "../transaction/index.js";
import { concat, defineProperties, getBigInt, getBytes, hexlify, isHexString, mask, toBeHex, toTwos, zeroPadValue, assertArgument } from "../utils/index.js";

@@ -396,2 +397,8 @@ import { id } from "./id.js";

}
/**
* Compute the address used to sign the typed data for the %%signature%%.
*/
export function verifyTypedData(domain, types, value, signature) {
return recoverAddress(TypedDataEncoder.hash(domain, types, value), signature);
}
//# sourceMappingURL=typed-data.js.map

@@ -265,3 +265,3 @@ /**

_wrapTransactionResponse(tx, network) {
return new TransactionResponse(tx, this);
return new TransactionResponse(formatTransactionResponse(tx), this);
}

@@ -644,3 +644,3 @@ _detectNetwork() {

}
return this._wrapBlock(formatBlock(params), network);
return this._wrapBlock(params, network);
}

@@ -655,3 +655,3 @@ async getTransaction(hash) {

}
return this._wrapTransactionResponse(formatTransactionResponse(params), network);
return this._wrapTransactionResponse(params, network);
}

@@ -675,3 +675,3 @@ async getTransactionReceipt(hash) {

}
return this._wrapTransactionReceipt(formatTransactionReceipt(params), network);
return this._wrapTransactionReceipt(params, network);
}

@@ -698,3 +698,3 @@ async getTransactionResult(hash) {

});
return params.map((p) => this._wrapLog(formatLog(p), network));
return params.map((p) => this._wrapLog(p, network));
}

@@ -701,0 +701,0 @@ // ENS

@@ -35,3 +35,3 @@ import { assert } from "../utils/index.js";

}
if (options.ankr !== "-") {
if (options.ankr !== "-" && options.ankr != null) {
try {

@@ -38,0 +38,0 @@ providers.push(new AnkrProvider(network, options.ankr));

@@ -77,3 +77,3 @@ /**

/**
* The name this resovler was resolved against.
* The name this resolver was resolved against.
*/

@@ -207,3 +207,3 @@ name;

/**
* Resovles to the EIP-643 text record for %%key%%, or ``null``
* Resolves to the EIP-643 text record for %%key%%, or ``null``
* if unconfigured.

@@ -210,0 +210,0 @@ */

@@ -54,3 +54,2 @@ import { connect } from "net";

async _write(message) {
console.log(">>>", message);
this.socket.write(message);

@@ -57,0 +56,0 @@ }

@@ -243,3 +243,3 @@ /**

if (resp == null) {
return reject(new Error("@TODO: no result"));
return reject(makeError("no response from server", "BAD_DATA", { value: result, info: { payload } }));
}

@@ -575,2 +575,3 @@ // The response is an error

transaction: (payload.params[0]),
info: { payload, error }
});

@@ -612,11 +613,11 @@ }

if (message.match(/nonce/i) && message.match(/too low/i)) {
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction });
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction, info: { error } });
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) {
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction });
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction, info: { error } });
}
if (message.match(/only replay-protected/i)) {
return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {
operation: method, info: { transaction }
operation: method, info: { transaction, info: { error } }
});

@@ -623,0 +624,0 @@ }

@@ -538,21 +538,113 @@ //import { resolveAddress } from "@ethersproject/address";

export class TransactionResponse {
/**
* The provider this is connected to, which will influence how its
* methods will resolve its async inspection methods.
*/
provider;
/**
* The block number of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
blockNumber;
/**
* The blockHash of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
blockHash;
/**
* The index within the block that this transaction resides at.
*/
index;
/**
* The transaction hash.
*/
hash;
/**
* The [[link-eip-2718]] transaction envelope type. This is
* ``0`` for legacy transactions types.
*/
type;
/**
* The receiver of this transaction.
*
* If ``null``, then the transaction is an initcode transaction.
* This means the result of executing the [[data]] will be deployed
* as a new contract on chain (assuming it does not revert) and the
* address may be computed using [[getCreateAddress]].
*/
to;
/**
* The sender of this transaction. It is implicitly computed
* from the transaction pre-image hash (as the digest) and the
* [[signature]] using ecrecover.
*/
from;
/**
* The nonce, which is used to prevent replay attacks and offer
* a method to ensure transactions from a given sender are explicitly
* ordered.
*
* When sending a transaction, this must be equal to the number of
* transactions ever sent by [[from]].
*/
nonce;
/**
* The maximum units of gas this transaction can consume. If execution
* exceeds this, the entries transaction is reverted and the sender
* is charged for the full amount, despite not state changes being made.
*/
gasLimit;
/**
* The gas price can have various values, depending on the network.
*
* In modern networks, for transactions that are included this is
* the //effective gas price// (the fee per gas that was actually
* charged), while for transactions that have not been included yet
* is the [[maxFeePerGas]].
*
* For legacy transactions, or transactions on legacy networks, this
* is the fee that will be charged per unit of gas the transaction
* consumes.
*/
gasPrice;
/**
* The maximum priority fee (per unit of gas) to allow a
* validator to charge the sender. This is inclusive of the
* [[maxFeeFeePerGas]].
*/
maxPriorityFeePerGas;
/**
* The maximum fee (per unit of gas) to allow this transaction
* to charge the sender.
*/
maxFeePerGas;
/**
* The data.
*/
data;
/**
* The value, in wei. Use [[formatEther]] to format this value
* as ether.
*/
value;
/**
* The chain ID.
*/
chainId;
/**
* The signature.
*/
signature;
/**
* The [[link-eip-2930]] access list for transaction types that
* support it, otherwise ``null``.
*/
accessList;
#startBlock;
/**
* Create a new TransactionResponse with %%tx%% parameters
* connected to %%provider%%.
*/
constructor(tx, provider) {

@@ -579,2 +671,5 @@ this.provider = provider;

}
/**
* Returns a JSON representation of this transaction.
*/
toJSON() {

@@ -596,2 +691,7 @@ const { blockNumber, blockHash, index, hash, type, to, from, nonce, data, signature, accessList } = this;

}
/**
* Resolves to the Block that this transaction was included in.
*
* This will return null if the transaction has not been included yet.
*/
async getBlock() {

@@ -614,5 +714,19 @@ let blockNumber = this.blockNumber;

}
/**
* Resolves to this transaction being re-requested from the
* provider. This can be used if you have an unmined transaction
* and wish to get an up-to-date populated instance.
*/
async getTransaction() {
return this.provider.getTransaction(this.hash);
}
/**
* Resolves once this transaction has been mined and has
* %%confirms%% blocks including it (default: ``1``) with an
* optional %%timeout%%.
*
* This can resolve to ``null`` only if %%confirms%% is ``0``
* and the transaction has not been mined, otherwise this will
* wait until enough confirmations have completed.
*/
async wait(_confirms, _timeout) {

@@ -772,14 +886,50 @@ const confirms = (_confirms == null) ? 1 : _confirms;

}
/**
* Returns ``true`` if this transaction has been included.
*
* This is effective only as of the time the TransactionResponse
* was instantiated. To get up-to-date information, use
* [[getTransaction]].
*
* This provides a Type Guard that this transaction will have
* non-null property values for properties that are null for
* unmined transactions.
*/
isMined() {
return (this.blockHash != null);
}
/**
* Returns true if the transaction is a legacy (i.e. ``type == 0``)
* transaction.
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLegacy() {
return (this.type === 0);
}
/**
* Returns true if the transaction is a Berlin (i.e. ``type == 1``)
* transaction. See [[link-eip-2070]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isBerlin() {
return (this.type === 1);
}
/**
* Returns true if the transaction is a London (i.e. ``type == 2``)
* transaction. See [[link-eip-1559]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLondon() {
return (this.type === 2);
}
/**
* Returns a filter which can be used to listen for orphan events
* that evict this transaction.
*/
removedEvent() {

@@ -789,2 +939,6 @@ assert(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });

}
/**
* Returns a filter which can be used to listen for orphan events
* that re-order this event against %%other%%.
*/
reorderedEvent(other) {

@@ -791,0 +945,0 @@ assert(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });

@@ -101,3 +101,3 @@ import { getAddress } from "../address/index.js";

let chainId = BN_0;
if (tx.chainId != null) {
if (tx.chainId != BN_0) {
// A chainId was provided; if non-zero we'll use EIP-155

@@ -109,5 +109,5 @@ chainId = getBigInt(tx.chainId, "tx.chainId");

}
else if (sig) {
// No chainId provided, but the signature is signing with EIP-155; derive chainId
const legacy = sig.legacyChainId;
else if (tx.signature) {
// No explicit chainId, but EIP-155 have a derived implicit chainId
const legacy = tx.signature.legacyChainId;
if (legacy != null) {

@@ -127,3 +127,6 @@ chainId = legacy;

}
// We pushed a chainId and null r, s on for hashing only; remove those
// @TODO: We should probably check that tx.signature, chainId, and sig
// match but that logic could break existing code, so schedule
// this for the next major bump.
// Compute the EIP-155 v
let v = BigInt(27 + sig.yParity);

@@ -136,2 +139,3 @@ if (chainId !== BN_0) {

}
// Add the signature
fields.push(toBeArray(v));

@@ -138,0 +142,0 @@ fields.push(toBeArray(sig.r));

@@ -354,3 +354,3 @@ /**

* Once created, each property may be set before issuing a
* ``.send()`` to make teh request.
* ``.send()`` to make the request.
*/

@@ -357,0 +357,0 @@ constructor(url) {

@@ -9,7 +9,6 @@ {

"./lib.esm/utils/geturl.js": "./lib.esm/utils/geturl-browser.js",
"./lib.esm/wordlists/wordlists.js": "./lib.esm/wordlists/wordlists-browser.js",
"@adraffy/ens-normalize": "@adraffy/ens-normalize/xnf"
"./lib.esm/wordlists/wordlists.js": "./lib.esm/wordlists/wordlists-browser.js"
},
"dependencies": {
"@adraffy/ens-normalize": "1.8.9",
"@adraffy/ens-normalize": "1.9.0",
"@noble/hashes": "1.1.2",

@@ -109,3 +108,3 @@ "@noble/secp256k1": "1.7.1",

],
"gitHead": "5f2678fb059d643638b9cc1dc59cbfc61ce7a7b8",
"gitHead": "30ffa78d1441fa033677fa09237fc135a314f373",
"homepage": "https://ethers.org",

@@ -150,3 +149,3 @@ "keywords": [

"types": "./types/index.d.ts",
"version": "6.1.0"
"version": "6.2.0"
}

@@ -6,2 +6,2 @@ /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */

*/
export const version: string = "6.1.0";
export const version: string = "6.2.0";

@@ -198,3 +198,2 @@ /**

}));
return t;
}));

@@ -201,0 +200,0 @@ }

@@ -25,6 +25,6 @@ import { Interface, Typed } from "../abi/index.js";

import type {
BaseContractMethod,
ContractEventName,
ContractInterface,
ContractMethodArgs,
BaseContractMethod,
ContractMethod,

@@ -34,3 +34,4 @@ ContractEventArgs,

ContractTransaction,
DeferredTopicFilter
DeferredTopicFilter,
WrappedFallback
} from "./types.js";

@@ -115,6 +116,2 @@

function _WrappedMethodBase(): new () => Function & BaseContractMethod {
return Function as any;
}
function getRunner<T extends ContractRunner>(value: any, feature: keyof ContractRunner): null | T {

@@ -171,4 +168,78 @@ if (value == null) { return null; }

function buildWrappedFallback(contract: BaseContract): WrappedFallback {
const populateTransaction = async function(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction> {
// If an overrides was passed in, copy it and normalize the values
const tx: ContractTransaction = <any>(await copyOverrides<"data">(overrides, [ "data" ]));
tx.to = await contract.getAddress();
const iface = contract.interface;
// Only allow payable contracts to set non-zero value
const payable = iface.receive || (iface.fallback && iface.fallback.payable);
assertArgument(payable || (tx.value || BN_0) === BN_0,
"cannot send value to non-payable contract", "overrides.value", tx.value);
// Only allow fallback contracts to set non-empty data
assertArgument(iface.fallback || (tx.data || "0x") === "0x",
"cannot send data to receive-only contract", "overrides.data", tx.data);
return tx;
}
const staticCall = async function(overrides?: Omit<TransactionRequest, "to">): Promise<string> {
const runner = getRunner(contract.runner, "call");
assert(canCall(runner), "contract runner does not support calling",
"UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await populateTransaction(overrides);
try {
return await runner.call(tx);
} catch (error: any) {
if (isCallException(error) && error.data) {
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
}
const send = async function(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse> {
const runner = contract.runner;
assert(canSend(runner), "contract runner does not support sending transactions",
"UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await populateTransaction(overrides));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new ContractTransactionResponse(contract.interface, <Provider>provider, tx);
}
const estimateGas = async function(overrides?: Omit<TransactionRequest, "to">): Promise<bigint> {
const runner = getRunner(contract.runner, "estimateGas");
assert(canEstimate(runner), "contract runner does not support gas estimation",
"UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await populateTransaction(overrides));
}
const method = async (overrides?: Omit<TransactionRequest, "to">) => {
return await send(overrides);
};
defineProperties<any>(method, {
_contract: contract,
estimateGas,
populateTransaction,
send, staticCall
});
return <WrappedFallback>method;
}
/*
class WrappedFallback {
readonly _contract!: BaseContract;

@@ -245,33 +316,8 @@ constructor (contract: BaseContract) {

}
*/
class WrappedMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = ContractTransactionResponse>
extends _WrappedMethodBase() implements BaseContractMethod<A, R, D> {
function buildWrappedMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = ContractTransactionResponse>(contract: BaseContract, key: string): BaseContractMethod<A, R, D> {
readonly name: string = ""; // Investigate!
readonly _contract!: BaseContract;
readonly _key!: string;
constructor (contract: BaseContract, key: string) {
super();
defineProperties<WrappedMethod>(this, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key
});
const proxy = new Proxy(this, {
// Perform the default operation for this fragment type
apply: async (target, thisArg, args: ContractMethodArgs<A>) => {
const fragment = target.getFragment(...args);
if (fragment.constant) { return await target.staticCall(...args); }
return await target.send(...args);
},
});
return proxy;
}
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
get fragment(): FunctionFragment {
const fragment = this._contract.interface.getFunction(this._key);
const getFragment = function(...args: ContractMethodArgs<A>): FunctionFragment {
const fragment = contract.interface.getFunction(key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {

@@ -283,13 +329,5 @@ operation: "fragment"

getFragment(...args: ContractMethodArgs<A>): FunctionFragment {
const fragment = this._contract.interface.getFunction(this._key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
const populateTransaction = async function(...args: ContractMethodArgs<A>): Promise<ContractTransaction> {
const fragment = getFragment(...args);
async populateTransaction(...args: ContractMethodArgs<A>): Promise<ContractTransaction> {
const fragment = this.getFragment(...args);
// If an overrides was passed in, copy it and normalize the values

@@ -305,12 +343,12 @@ let overrides: Omit<ContractTransaction, "data" | "to"> = { };

const resolvedArgs = await resolveArgs(this._contract.runner, fragment.inputs, args);
const resolvedArgs = await resolveArgs(contract.runner, fragment.inputs, args);
return Object.assign({ }, overrides, await resolveProperties({
to: this._contract.getAddress(),
data: this._contract.interface.encodeFunctionData(fragment, resolvedArgs)
to: contract.getAddress(),
data: contract.interface.encodeFunctionData(fragment, resolvedArgs)
}));
}
async staticCall(...args: ContractMethodArgs<A>): Promise<R> {
const result = await this.staticCallResult(...args);
const staticCall = async function(...args: ContractMethodArgs<A>): Promise<R> {
const result = await staticCallResult(...args);
if (result.length === 1) { return result[0]; }

@@ -320,28 +358,28 @@ return <R><unknown>result;

async send(...args: ContractMethodArgs<A>): Promise<ContractTransactionResponse> {
const runner = this._contract.runner;
const send = async function(...args: ContractMethodArgs<A>): Promise<ContractTransactionResponse> {
const runner = contract.runner;
assert(canSend(runner), "contract runner does not support sending transactions",
"UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(...args));
const provider = getProvider(this._contract.runner);
const tx = await runner.sendTransaction(await populateTransaction(...args));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new ContractTransactionResponse(this._contract.interface, <Provider>provider, tx);
return new ContractTransactionResponse(contract.interface, <Provider>provider, tx);
}
async estimateGas(...args: ContractMethodArgs<A>): Promise<bigint> {
const runner = getRunner(this._contract.runner, "estimateGas");
const estimateGas = async function(...args: ContractMethodArgs<A>): Promise<bigint> {
const runner = getRunner(contract.runner, "estimateGas");
assert(canEstimate(runner), "contract runner does not support gas estimation",
"UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(...args));
return await runner.estimateGas(await populateTransaction(...args));
}
async staticCallResult(...args: ContractMethodArgs<A>): Promise<Result> {
const runner = getRunner(this._contract.runner, "call");
const staticCallResult = async function(...args: ContractMethodArgs<A>): Promise<Result> {
const runner = getRunner(contract.runner, "call");
assert(canCall(runner), "contract runner does not support calling",
"UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(...args);
const tx = await populateTransaction(...args);

@@ -353,3 +391,3 @@ let result = "0x";

if (isCallException(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
throw contract.interface.makeError(error.data, tx);
}

@@ -359,37 +397,44 @@ throw error;

const fragment = this.getFragment(...args);
return this._contract.interface.decodeFunctionResult(fragment, result);
}
}
const fragment = getFragment(...args);
return contract.interface.decodeFunctionResult(fragment, result);
};
function _WrappedEventBase(): new () => Function & ContractEvent {
return Function as any;
}
const method = async (...args: ContractMethodArgs<A>) => {
const fragment = getFragment(...args);
if (fragment.constant) { return await staticCall(...args); }
return await send(...args);
};
class WrappedEvent<A extends Array<any> = Array<any>> extends _WrappedEventBase() implements ContractEvent<A> {
readonly name: string = ""; // @TODO: investigate
defineProperties<any>(method, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key,
readonly _contract!: BaseContract;
readonly _key!: string;
getFragment,
constructor (contract: BaseContract, key: string) {
super();
estimateGas,
populateTransaction,
send, staticCall, staticCallResult,
});
defineProperties<WrappedEvent>(this, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getFunction(key);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return new Proxy(this, {
// Perform the default operation for this fragment type
apply: (target, thisArg, args: ContractEventArgs<A>) => {
return new PreparedTopicFilter(contract, target.getFragment(...args), args);
},
});
}
return <BaseContractMethod<A, R, D>>method;
}
// Only works on non-ambiguous keys
get fragment(): EventFragment {
const fragment = this._contract.interface.getEvent(this._key);
function buildWrappedEvent<A extends Array<any> = Array<any>>(contract: BaseContract, key: string): ContractEvent<A> {
const getFragment = function(...args: ContractEventArgs<A>): EventFragment {
const fragment = contract.interface.getEvent(key, args);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {

@@ -402,13 +447,31 @@ operation: "fragment"

getFragment(...args: ContractEventArgs<A>): EventFragment {
const fragment = this._contract.interface.getEvent(this._key, args);
const method = function(...args: ContractMethodArgs<A>): PreparedTopicFilter {
return new PreparedTopicFilter(contract, getFragment(...args), args);
};
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
defineProperties<any>(method, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key,
return fragment;
}
};
getFragment
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getEvent(key);
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return <ContractEvent<A>><unknown>method;
}
type Sub = {

@@ -704,3 +767,3 @@ tag: string;

defineProperties<BaseContract>(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)): null)
fallback: ((iface.receive || iface.fallback) ? (buildWrappedFallback(this)): null)
});

@@ -779,3 +842,4 @@

if (typeof(key) !== "string") { key = key.format(); }
return <T><unknown>(new WrappedMethod(this, key));
const func = buildWrappedMethod(this, key);
return <T>func;
}

@@ -785,3 +849,3 @@

if (typeof(key) !== "string") { key = key.format(); }
return <ContractEvent><unknown>(new WrappedEvent(this, key));
return buildWrappedEvent(this, key);
}

@@ -788,0 +852,0 @@

@@ -26,3 +26,4 @@ /**

ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction,
DeferredTopicFilter, Overrides
DeferredTopicFilter, Overrides,
WrappedFallback
} from "./types.js";

@@ -87,1 +87,10 @@ import type {

};
export interface WrappedFallback {
(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}

@@ -34,7 +34,7 @@ // import from provider.ts instead of index.ts to prevent circular dep

export class ContractTransactionReceipt extends TransactionReceipt {
readonly #interface: Interface;
readonly #iface: Interface;
constructor(iface: Interface, provider: Provider, tx: TransactionReceipt) {
super(tx, provider);
this.#interface = iface;
this.#iface = iface;
}

@@ -44,5 +44,5 @@

return super.logs.map((log) => {
const fragment = log.topics.length ? this.#interface.getEvent(log.topics[0]): null;
const fragment = log.topics.length ? this.#iface.getEvent(log.topics[0]): null;
if (fragment) {
return new EventLog(log, this.#interface, fragment)
return new EventLog(log, this.#iface, fragment)
} else {

@@ -57,7 +57,7 @@ return log;

export class ContractTransactionResponse extends TransactionResponse {
readonly #interface: Interface;
readonly #iface: Interface;
constructor(iface: Interface, provider: Provider, tx: TransactionResponse) {
super(tx, provider);
this.#interface = iface;
this.#iface = iface;
}

@@ -68,3 +68,3 @@

if (receipt == null) { return null; }
return new ContractTransactionReceipt(this.#interface, this.provider, receipt);
return new ContractTransactionReceipt(this.#iface, this.provider, receipt);
}

@@ -71,0 +71,0 @@ }

@@ -85,3 +85,3 @@

set s(_value: BytesLike) {
assertArgument(dataLength(_value) === 32, "invalid r", "value", _value);
assertArgument(dataLength(_value) === 32, "invalid s", "value", _value);
const value = hexlify(_value);

@@ -88,0 +88,0 @@ assertArgument(parseInt(value.substring(0, 3)) < 8, "non-canonical s", "value", value);

@@ -184,5 +184,5 @@ /**

const pubKey = secp256k1.recoverPublicKey(getBytesCopy(digest), der, sig.yParity);
if (pubKey != null) { return hexlify(pubKey); }
assertArgument(pubKey != null, "invalid signautre for digest", "signature", signature);
assertArgument(false, "invalid signautre for digest", "signature", signature);
return hexlify(pubKey);
}

@@ -189,0 +189,0 @@

@@ -54,3 +54,4 @@

solidityPacked, solidityPackedKeccak256, solidityPackedSha256,
TypedDataEncoder
TypedDataEncoder,
verifyTypedData
} from "./hash/index.js";

@@ -153,3 +154,4 @@

DeferredTopicFilter, Overrides,
BaseContractMethod, ContractDeployTransaction, PostfixOverrides
BaseContractMethod, ContractDeployTransaction, PostfixOverrides,
WrappedFallback
} from "./contract/index.js";

@@ -156,0 +158,0 @@

@@ -13,4 +13,4 @@ /**

} from "./solidity.js";
export { TypedDataEncoder } from "./typed-data.js";
export { TypedDataEncoder, verifyTypedData } from "./typed-data.js";
export type { TypedDataDomain, TypedDataField } from "./typed-data.js";
//import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer";
import { getAddress } from "../address/index.js";
import { keccak256 } from "../crypto/index.js";
import { recoverAddress } from "../transaction/index.js";
import {

@@ -11,2 +12,3 @@ concat, defineProperties, getBigInt, getBytes, hexlify, isHexString, mask, toBeHex, toTwos, zeroPadValue,

import type { SignatureLike } from "../crypto/index.js";
import type { BigNumberish, BytesLike } from "../utils/index.js";

@@ -491,1 +493,7 @@

/**
* Compute the address used to sign the typed data for the %%signature%%.
*/
export function verifyTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, signature: SignatureLike): string {
return recoverAddress(TypedDataEncoder.hash(domain, types, value), signature);
}

@@ -495,3 +495,3 @@ /**

_wrapTransactionResponse(tx: TransactionResponseParams, network: Network): TransactionResponse {
return new TransactionResponse(tx, this);
return new TransactionResponse(formatTransactionResponse(tx), this);
}

@@ -901,3 +901,3 @@

return this._wrapBlock(formatBlock(params), network);
return this._wrapBlock(params, network);
}

@@ -912,3 +912,3 @@

return this._wrapTransactionResponse(formatTransactionResponse(params), network);
return this._wrapTransactionResponse(params, network);
}

@@ -931,3 +931,3 @@

return this._wrapTransactionReceipt(formatTransactionReceipt(params), network);
return this._wrapTransactionReceipt(params, network);
}

@@ -954,3 +954,3 @@

return params.map((p) => this._wrapLog(formatLog(p), network));
return params.map((p) => this._wrapLog(p, network));
}

@@ -957,0 +957,0 @@

@@ -44,3 +44,3 @@

if (options.ankr !== "-") {
if (options.ankr !== "-" && options.ankr != null) {
try {

@@ -47,0 +47,0 @@ providers.push(new AnkrProvider(network, options.ankr));

@@ -132,3 +132,3 @@ /**

/**
* The name this resovler was resolved against.
* The name this resolver was resolved against.
*/

@@ -271,3 +271,3 @@ name!: string;

/**
* Resovles to the EIP-643 text record for %%key%%, or ``null``
* Resolves to the EIP-643 text record for %%key%%, or ``null``
* if unconfigured.

@@ -274,0 +274,0 @@ */

@@ -67,5 +67,4 @@

async _write(message: string): Promise<void> {
console.log(">>>", message);
this.socket.write(message);
}
}

@@ -418,3 +418,3 @@ /**

if (resp == null) {
return reject(new Error("@TODO: no result"));
return reject(makeError("no response from server", "BAD_DATA", { value: result, info: { payload } }));
}

@@ -801,2 +801,3 @@

transaction: ((<any>payload).params[0]),
info: { payload, error }
});

@@ -851,3 +852,3 @@ }

if (message.match(/nonce/i) && message.match(/too low/i)) {
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction });
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction, info: { error } });
}

@@ -857,3 +858,3 @@

if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) {
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction });
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction, info: { error } });
}

@@ -863,3 +864,3 @@

return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {
operation: method, info: { transaction }
operation: method, info: { transaction, info: { error } }
});

@@ -866,0 +867,0 @@ }

@@ -201,2 +201,9 @@ //import { resolveAddress } from "@ethersproject/address";

/**
* An Interface to indicate a [[Block]] has been included in the
* blockchain. This asserts a Type Guard that necessary properties
* are non-null.
*
* Before a block is included, it is a //pending// block.
*/
export interface MinedBlock extends Block {

@@ -721,31 +728,124 @@ readonly number: number;

export class TransactionResponse implements TransactionLike<string>, TransactionResponseParams {
/**
* The provider this is connected to, which will influence how its
* methods will resolve its async inspection methods.
*/
readonly provider: Provider;
/**
* The block number of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
readonly blockNumber: null | number;
/**
* The blockHash of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
readonly blockHash: null | string;
/**
* The index within the block that this transaction resides at.
*/
readonly index!: number;
/**
* The transaction hash.
*/
readonly hash!: string;
/**
* The [[link-eip-2718]] transaction envelope type. This is
* ``0`` for legacy transactions types.
*/
readonly type!: number;
/**
* The receiver of this transaction.
*
* If ``null``, then the transaction is an initcode transaction.
* This means the result of executing the [[data]] will be deployed
* as a new contract on chain (assuming it does not revert) and the
* address may be computed using [[getCreateAddress]].
*/
readonly to!: null | string;
/**
* The sender of this transaction. It is implicitly computed
* from the transaction pre-image hash (as the digest) and the
* [[signature]] using ecrecover.
*/
readonly from!: string;
/**
* The nonce, which is used to prevent replay attacks and offer
* a method to ensure transactions from a given sender are explicitly
* ordered.
*
* When sending a transaction, this must be equal to the number of
* transactions ever sent by [[from]].
*/
readonly nonce!: number;
/**
* The maximum units of gas this transaction can consume. If execution
* exceeds this, the entries transaction is reverted and the sender
* is charged for the full amount, despite not state changes being made.
*/
readonly gasLimit!: bigint;
/**
* The gas price can have various values, depending on the network.
*
* In modern networks, for transactions that are included this is
* the //effective gas price// (the fee per gas that was actually
* charged), while for transactions that have not been included yet
* is the [[maxFeePerGas]].
*
* For legacy transactions, or transactions on legacy networks, this
* is the fee that will be charged per unit of gas the transaction
* consumes.
*/
readonly gasPrice!: bigint;
/**
* The maximum priority fee (per unit of gas) to allow a
* validator to charge the sender. This is inclusive of the
* [[maxFeeFeePerGas]].
*/
readonly maxPriorityFeePerGas!: null | bigint;
/**
* The maximum fee (per unit of gas) to allow this transaction
* to charge the sender.
*/
readonly maxFeePerGas!: null | bigint;
/**
* The data.
*/
readonly data!: string;
/**
* The value, in wei. Use [[formatEther]] to format this value
* as ether.
*/
readonly value!: bigint;
/**
* The chain ID.
*/
readonly chainId!: bigint;
/**
* The signature.
*/
readonly signature!: Signature;
/**
* The [[link-eip-2930]] access list for transaction types that
* support it, otherwise ``null``.
*/
readonly accessList!: null | AccessList;

@@ -755,2 +855,6 @@

/**
* Create a new TransactionResponse with %%tx%% parameters
* connected to %%provider%%.
*/
constructor(tx: TransactionResponseParams, provider: Provider) {

@@ -787,2 +891,5 @@ this.provider = provider;

/**
* Returns a JSON representation of this transaction.
*/
toJSON(): any {

@@ -809,2 +916,7 @@ const {

/**
* Resolves to the Block that this transaction was included in.
*
* This will return null if the transaction has not been included yet.
*/
async getBlock(): Promise<null | Block> {

@@ -822,2 +934,7 @@ let blockNumber = this.blockNumber;

/**
* Resolves to this transaction being re-requested from the
* provider. This can be used if you have an unmined transaction
* and wish to get an up-to-date populated instance.
*/
async getTransaction(): Promise<null | TransactionResponse> {

@@ -827,2 +944,11 @@ return this.provider.getTransaction(this.hash);

/**
* Resolves once this transaction has been mined and has
* %%confirms%% blocks including it (default: ``1``) with an
* optional %%timeout%%.
*
* This can resolve to ``null`` only if %%confirms%% is ``0``
* and the transaction has not been mined, otherwise this will
* wait until enough confirmations have completed.
*/
async wait(_confirms?: number, _timeout?: number): Promise<null | TransactionReceipt> {

@@ -983,2 +1109,13 @@ const confirms = (_confirms == null) ? 1: _confirms;

/**
* Returns ``true`` if this transaction has been included.
*
* This is effective only as of the time the TransactionResponse
* was instantiated. To get up-to-date information, use
* [[getTransaction]].
*
* This provides a Type Guard that this transaction will have
* non-null property values for properties that are null for
* unmined transactions.
*/
isMined(): this is MinedTransactionResponse {

@@ -988,2 +1125,9 @@ return (this.blockHash != null);

/**
* Returns true if the transaction is a legacy (i.e. ``type == 0``)
* transaction.
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLegacy(): this is (TransactionResponse & { accessList: null, maxFeePerGas: null, maxPriorityFeePerGas: null }) {

@@ -993,2 +1137,9 @@ return (this.type === 0)

/**
* Returns true if the transaction is a Berlin (i.e. ``type == 1``)
* transaction. See [[link-eip-2070]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isBerlin(): this is (TransactionResponse & { accessList: AccessList, maxFeePerGas: null, maxPriorityFeePerGas: null }) {

@@ -998,2 +1149,9 @@ return (this.type === 1);

/**
* Returns true if the transaction is a London (i.e. ``type == 2``)
* transaction. See [[link-eip-1559]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLondon(): this is (TransactionResponse & { accessList: AccessList, maxFeePerGas: bigint, maxPriorityFeePerGas: bigint }){

@@ -1003,2 +1161,6 @@ return (this.type === 2);

/**
* Returns a filter which can be used to listen for orphan events
* that evict this transaction.
*/
removedEvent(): OrphanFilter {

@@ -1010,2 +1172,6 @@ assert(this.isMined(), "unmined transaction canot be orphaned",

/**
* Returns a filter which can be used to listen for orphan events
* that re-order this event against %%other%%.
*/
reorderedEvent(other?: TransactionResponse): OrphanFilter {

@@ -1042,2 +1208,9 @@ assert(this.isMined(), "unmined transaction canot be orphaned",

/**
* An Orphan Filter allows detecting when an orphan block has
* resulted in dropping a block or transaction or has resulted
* in transactions changing order.
*
* Not currently fully supported.
*/
export type OrphanFilter = {

@@ -1095,2 +1268,11 @@ orphan: "drop-block",

/**
* A **TopicFilter** provides a struture to define bloom-filter
* queries.
*
* Each field that is ``null`` matches **any** value, a field that is
* a ``string`` must match exactly that value and and ``array`` is
* effectively an ``OR``-ed set, where any one of those values must
* match.
*/
export type TopicFilter = Array<null | string | Array<string>>;

@@ -1097,0 +1279,0 @@

@@ -194,3 +194,3 @@

let chainId = BN_0;
if (tx.chainId != null) {
if (tx.chainId != BN_0) {
// A chainId was provided; if non-zero we'll use EIP-155

@@ -204,5 +204,5 @@ chainId = getBigInt(tx.chainId, "tx.chainId");

} else if (sig) {
// No chainId provided, but the signature is signing with EIP-155; derive chainId
const legacy = sig.legacyChainId;
} else if (tx.signature) {
// No explicit chainId, but EIP-155 have a derived implicit chainId
const legacy = tx.signature.legacyChainId;
if (legacy != null) { chainId = legacy; }

@@ -223,3 +223,7 @@ }

// We pushed a chainId and null r, s on for hashing only; remove those
// @TODO: We should probably check that tx.signature, chainId, and sig
// match but that logic could break existing code, so schedule
// this for the next major bump.
// Compute the EIP-155 v
let v = BigInt(27 + sig.yParity);

@@ -232,2 +236,3 @@ if (chainId !== BN_0) {

// Add the signature
fields.push(toBeArray(v));

@@ -234,0 +239,0 @@ fields.push(toBeArray(sig.r));

@@ -415,3 +415,3 @@ /**

* Once created, each property may be set before issuing a
* ``.send()`` to make teh request.
* ``.send()`` to make the request.
*/

@@ -418,0 +418,0 @@ constructor(url: string) {

@@ -7,4 +7,4 @@ import { Interface } from "../abi/index.js";

import type { EventEmitterable, Listener } from "../utils/index.js";
import type { BlockTag, ContractRunner, TransactionRequest } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction } from "./types.js";
import type { BlockTag, ContractRunner } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction, WrappedFallback } from "./types.js";
/**

@@ -18,10 +18,2 @@ * @_ignore:

export declare function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray<ParamType>, args: Array<any>): Promise<Array<any>>;
declare class WrappedFallback {
readonly _contract: BaseContract;
constructor(contract: BaseContract);
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}
declare const internal: unique symbol;

@@ -28,0 +20,0 @@ export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {

@@ -9,3 +9,3 @@ /**

export { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./wrappers.js";
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides } from "./types.js";
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, WrappedFallback } from "./types.js";
//# sourceMappingURL=index.d.ts.map

@@ -49,2 +49,9 @@ import type { EventFragment, FunctionFragment, Result, Typed } from "../abi/index.js";

}
export interface WrappedFallback {
(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}
//# sourceMappingURL=types.d.ts.map

@@ -7,3 +7,3 @@ export { version } from "./_version.js";

export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync, lock, Signature, SigningKey } from "./crypto/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder } from "./hash/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder, verifyTypedData } from "./hash/index.js";
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, InfuraWebSocketProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network, EnsPlugin, EtherscanPlugin, FeeDataNetworkPlugin, GasCostPlugin, NetworkPlugin, SocketBlockSubscriber, SocketEventSubscriber, SocketPendingSubscriber, SocketSubscriber, UnmanagedSubscriber, copyRequest, showThrottleMessage } from "./providers/index.js";

@@ -16,3 +16,3 @@ export { accessListify, computeAddress, recoverAddress, Transaction } from "./transaction/index.js";

export type { Addressable, AddressLike, NameResolver } from "./address/index.js";
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, BaseContractMethod, ContractDeployTransaction, PostfixOverrides } from "./contract/index.js";
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, BaseContractMethod, ContractDeployTransaction, PostfixOverrides, WrappedFallback } from "./contract/index.js";
export type { ProgressCallback, SignatureLike } from "./crypto/index.js";

@@ -19,0 +19,0 @@ export type { TypedDataDomain, TypedDataField } from "./hash/index.js";

@@ -10,4 +10,4 @@ /**

export { solidityPacked, solidityPackedKeccak256, solidityPackedSha256 } from "./solidity.js";
export { TypedDataEncoder } from "./typed-data.js";
export { TypedDataEncoder, verifyTypedData } from "./typed-data.js";
export type { TypedDataDomain, TypedDataField } from "./typed-data.js";
//# sourceMappingURL=index.d.ts.map

@@ -0,1 +1,2 @@

import type { SignatureLike } from "../crypto/index.js";
import type { BigNumberish, BytesLike } from "../utils/index.js";

@@ -38,2 +39,6 @@ export interface TypedDataDomain {

}
/**
* Compute the address used to sign the typed data for the %%signature%%.
*/
export declare function verifyTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, signature: SignatureLike): string;
//# sourceMappingURL=typed-data.d.ts.map

@@ -64,3 +64,3 @@ /**

/**
* The name this resovler was resolved against.
* The name this resolver was resolved against.
*/

@@ -79,3 +79,3 @@ name: string;

/**
* Resovles to the EIP-643 text record for %%key%%, or ``null``
* Resolves to the EIP-643 text record for %%key%%, or ``null``
* if unconfigured.

@@ -82,0 +82,0 @@ */

@@ -86,2 +86,9 @@ import type { AddressLike, NameResolver } from "../address/index.js";

export declare function copyRequest(req: TransactionRequest): PreparedTransactionRequest;
/**
* An Interface to indicate a [[Block]] has been included in the
* blockchain. This asserts a Type Guard that necessary properties
* are non-null.
*
* Before a block is included, it is a //pending// block.
*/
export interface MinedBlock extends Block {

@@ -270,26 +277,158 @@ readonly number: number;

#private;
/**
* The provider this is connected to, which will influence how its
* methods will resolve its async inspection methods.
*/
readonly provider: Provider;
/**
* The block number of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
readonly blockNumber: null | number;
/**
* The blockHash of the block that this transaction was included in.
*
* This is ``null`` for pending transactions.
*/
readonly blockHash: null | string;
/**
* The index within the block that this transaction resides at.
*/
readonly index: number;
/**
* The transaction hash.
*/
readonly hash: string;
/**
* The [[link-eip-2718]] transaction envelope type. This is
* ``0`` for legacy transactions types.
*/
readonly type: number;
/**
* The receiver of this transaction.
*
* If ``null``, then the transaction is an initcode transaction.
* This means the result of executing the [[data]] will be deployed
* as a new contract on chain (assuming it does not revert) and the
* address may be computed using [[getCreateAddress]].
*/
readonly to: null | string;
/**
* The sender of this transaction. It is implicitly computed
* from the transaction pre-image hash (as the digest) and the
* [[signature]] using ecrecover.
*/
readonly from: string;
/**
* The nonce, which is used to prevent replay attacks and offer
* a method to ensure transactions from a given sender are explicitly
* ordered.
*
* When sending a transaction, this must be equal to the number of
* transactions ever sent by [[from]].
*/
readonly nonce: number;
/**
* The maximum units of gas this transaction can consume. If execution
* exceeds this, the entries transaction is reverted and the sender
* is charged for the full amount, despite not state changes being made.
*/
readonly gasLimit: bigint;
/**
* The gas price can have various values, depending on the network.
*
* In modern networks, for transactions that are included this is
* the //effective gas price// (the fee per gas that was actually
* charged), while for transactions that have not been included yet
* is the [[maxFeePerGas]].
*
* For legacy transactions, or transactions on legacy networks, this
* is the fee that will be charged per unit of gas the transaction
* consumes.
*/
readonly gasPrice: bigint;
/**
* The maximum priority fee (per unit of gas) to allow a
* validator to charge the sender. This is inclusive of the
* [[maxFeeFeePerGas]].
*/
readonly maxPriorityFeePerGas: null | bigint;
/**
* The maximum fee (per unit of gas) to allow this transaction
* to charge the sender.
*/
readonly maxFeePerGas: null | bigint;
/**
* The data.
*/
readonly data: string;
/**
* The value, in wei. Use [[formatEther]] to format this value
* as ether.
*/
readonly value: bigint;
/**
* The chain ID.
*/
readonly chainId: bigint;
/**
* The signature.
*/
readonly signature: Signature;
/**
* The [[link-eip-2930]] access list for transaction types that
* support it, otherwise ``null``.
*/
readonly accessList: null | AccessList;
/**
* Create a new TransactionResponse with %%tx%% parameters
* connected to %%provider%%.
*/
constructor(tx: TransactionResponseParams, provider: Provider);
/**
* Returns a JSON representation of this transaction.
*/
toJSON(): any;
/**
* Resolves to the Block that this transaction was included in.
*
* This will return null if the transaction has not been included yet.
*/
getBlock(): Promise<null | Block>;
/**
* Resolves to this transaction being re-requested from the
* provider. This can be used if you have an unmined transaction
* and wish to get an up-to-date populated instance.
*/
getTransaction(): Promise<null | TransactionResponse>;
/**
* Resolves once this transaction has been mined and has
* %%confirms%% blocks including it (default: ``1``) with an
* optional %%timeout%%.
*
* This can resolve to ``null`` only if %%confirms%% is ``0``
* and the transaction has not been mined, otherwise this will
* wait until enough confirmations have completed.
*/
wait(_confirms?: number, _timeout?: number): Promise<null | TransactionReceipt>;
/**
* Returns ``true`` if this transaction has been included.
*
* This is effective only as of the time the TransactionResponse
* was instantiated. To get up-to-date information, use
* [[getTransaction]].
*
* This provides a Type Guard that this transaction will have
* non-null property values for properties that are null for
* unmined transactions.
*/
isMined(): this is MinedTransactionResponse;
/**
* Returns true if the transaction is a legacy (i.e. ``type == 0``)
* transaction.
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLegacy(): this is (TransactionResponse & {

@@ -300,2 +439,9 @@ accessList: null;

});
/**
* Returns true if the transaction is a Berlin (i.e. ``type == 1``)
* transaction. See [[link-eip-2070]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isBerlin(): this is (TransactionResponse & {

@@ -306,2 +452,9 @@ accessList: AccessList;

});
/**
* Returns true if the transaction is a London (i.e. ``type == 2``)
* transaction. See [[link-eip-1559]].
*
* This provides a Type Guard that this transaction will have
* the ``null``-ness for hardfork-specific properties set correctly.
*/
isLondon(): this is (TransactionResponse & {

@@ -312,3 +465,11 @@ accessList: AccessList;

});
/**
* Returns a filter which can be used to listen for orphan events
* that evict this transaction.
*/
removedEvent(): OrphanFilter;
/**
* Returns a filter which can be used to listen for orphan events
* that re-order this event against %%other%%.
*/
reorderedEvent(other?: TransactionResponse): OrphanFilter;

@@ -326,2 +487,9 @@ /**

}
/**
* An Orphan Filter allows detecting when an orphan block has
* resulted in dropping a block or transaction or has resulted
* in transactions changing order.
*
* Not currently fully supported.
*/
export type OrphanFilter = {

@@ -367,2 +535,11 @@ orphan: "drop-block";

};
/**
* A **TopicFilter** provides a struture to define bloom-filter
* queries.
*
* Each field that is ``null`` matches **any** value, a field that is
* a ``string`` must match exactly that value and and ``array`` is
* effectively an ``OR``-ed set, where any one of those values must
* match.
*/
export type TopicFilter = Array<null | string | Array<string>>;

@@ -369,0 +546,0 @@ export interface EventFilter {

@@ -181,3 +181,3 @@ export type GetUrlResponse = {

* Once created, each property may be set before issuing a
* ``.send()`` to make teh request.
* ``.send()`` to make the request.
*/

@@ -184,0 +184,0 @@ constructor(url: string);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc