admin: update dist files

This commit is contained in:
Richard Moore 2023-01-30 22:29:09 -05:00
parent c3f8e8ac07
commit 9c744dd081
33 changed files with 883 additions and 268 deletions

280
dist/ethers.js vendored

@ -439,7 +439,7 @@ function zeroPadBytes(data, length) {
*
* @_subsection: api/utils:Math Helpers [about-maths]
*/
const BN_0$9 = BigInt(0);
const BN_0$a = BigInt(0);
const BN_1$6 = BigInt(1);
//const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
// IEEE 754 support 53-bits of mantissa
@ -453,7 +453,7 @@ const maxValue = 0x1fffffffffffff;
function fromTwos(_value, _width) {
const value = getUint(_value, "value");
const width = BigInt(getNumber(_width, "width"));
assert$1((value >> width) === BN_0$9, "overflow", "NUMERIC_FAULT", {
assert$1((value >> width) === BN_0$a, "overflow", "NUMERIC_FAULT", {
operation: "fromTwos", fault: "overflow", value: _value
});
// Top bit set; treat as a negative value
@ -473,7 +473,7 @@ function toTwos(_value, _width) {
let value = getBigInt(_value, "value");
const width = BigInt(getNumber(_width, "width"));
const limit = (BN_1$6 << (width - BN_1$6));
if (value < BN_0$9) {
if (value < BN_0$a) {
value = -value;
assert$1(value <= limit, "too low", "NUMERIC_FAULT", {
operation: "toTwos", fault: "overflow", value: _value
@ -525,7 +525,7 @@ function getBigInt(value, name) {
}
function getUint(value, name) {
const result = getBigInt(value, name);
assert$1(result >= BN_0$9, "unsigned value cannot be negative", "NUMERIC_FAULT", {
assert$1(result >= BN_0$a, "unsigned value cannot be negative", "NUMERIC_FAULT", {
fault: "overflow", operation: "getUint", value
});
return result;
@ -611,7 +611,7 @@ function toBeHex(_value, _width) {
*/
function toBeArray(_value) {
const value = getUint(_value, "value");
if (value === BN_0$9) {
if (value === BN_0$a) {
return new Uint8Array([]);
}
let hex = value.toString(16);
@ -669,7 +669,7 @@ function getAlpha(letter) {
assertArgument(result != null, `invalid base58 value`, "letter", letter);
return result;
}
const BN_0$8 = BigInt(0);
const BN_0$9 = BigInt(0);
const BN_58 = BigInt(58);
/**
* Encode %%value%% as a Base58-encoded string.
@ -687,7 +687,7 @@ function encodeBase58(_value) {
* Decode the Base58-encoded %%value%%.
*/
function decodeBase58(value) {
let result = BN_0$8;
let result = BN_0$9;
for (let i = 0; i < value.length; i++) {
result *= BN_58;
result += getAlpha(value[i]);
@ -1779,7 +1779,7 @@ function wait(delay) {
* @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
*/
const BN_N1 = BigInt(-1);
const BN_0$7 = BigInt(0);
const BN_0$8 = BigInt(0);
const BN_1$5 = BigInt(1);
const BN_5 = BigInt(5);
const _guard$5 = {};
@ -1803,7 +1803,7 @@ function checkValue(val, format, safeOp) {
assert$1(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
operation: safeOp, fault: "overflow", value: val
});
if (val > BN_0$7) {
if (val > BN_0$8) {
val = fromTwos(mask(val, width), width);
}
else {
@ -1863,7 +1863,7 @@ function getFormat(value) {
}
function toString(val, decimals) {
let negative = "";
if (val < BN_0$7) {
if (val < BN_0$8) {
negative = "-";
val *= BN_N1;
}
@ -2054,13 +2054,13 @@ class FixedNumber {
mulSignal(other) {
this.#checkFormat(other);
const value = this.#val * other.#val;
assert$1((value % this.#tens) === BN_0$7, "precision lost during signalling mul", "NUMERIC_FAULT", {
assert$1((value % this.#tens) === BN_0$8, "precision lost during signalling mul", "NUMERIC_FAULT", {
operation: "mulSignal", fault: "underflow", value: this
});
return this.#checkValue(value / this.#tens, "mulSignal");
}
#div(o, safeOp) {
assert$1(o.#val !== BN_0$7, "division by zero", "NUMERIC_FAULT", {
assert$1(o.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
operation: "div", fault: "divide-by-zero", value: this
});
this.#checkFormat(o);
@ -2084,12 +2084,12 @@ class FixedNumber {
* (precision loss) occurs.
*/
divSignal(other) {
assert$1(other.#val !== BN_0$7, "division by zero", "NUMERIC_FAULT", {
assert$1(other.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
operation: "div", fault: "divide-by-zero", value: this
});
this.#checkFormat(other);
const value = (this.#val * this.#tens);
assert$1((value % other.#val) === BN_0$7, "precision lost during signalling div", "NUMERIC_FAULT", {
assert$1((value % other.#val) === BN_0$8, "precision lost during signalling div", "NUMERIC_FAULT", {
operation: "divSignal", fault: "underflow", value: this
});
return this.#checkValue(value / other.#val, "divSignal");
@ -2148,7 +2148,7 @@ class FixedNumber {
*/
floor() {
let val = this.#val;
if (this.#val < BN_0$7) {
if (this.#val < BN_0$8) {
val -= this.#tens - BN_1$5;
}
val = (this.#val / this.#tens) * this.#tens;
@ -2162,7 +2162,7 @@ class FixedNumber {
*/
ceiling() {
let val = this.#val;
if (this.#val > BN_0$7) {
if (this.#val > BN_0$8) {
val += this.#tens - BN_1$5;
}
val = (this.#val / this.#tens) * this.#tens;
@ -2191,11 +2191,11 @@ class FixedNumber {
/**
* Returns true if %%this%% is equal to ``0``.
*/
isZero() { return (this.#val === BN_0$7); }
isZero() { return (this.#val === BN_0$8); }
/**
* Returns true if %%this%% is less than ``0``.
*/
isNegative() { return (this.#val < BN_0$7); }
isNegative() { return (this.#val < BN_0$8); }
/**
* Returns the string representation of %%this%%.
*/
@ -2234,7 +2234,7 @@ class FixedNumber {
const delta = decimals - format.decimals;
if (delta > 0) {
const tens = getTens(delta);
assert$1((value % tens) === BN_0$7, "value loses precision for format", "NUMERIC_FAULT", {
assert$1((value % tens) === BN_0$8, "value loses precision for format", "NUMERIC_FAULT", {
operation: "fromValue", fault: "underflow", value: _value
});
value /= tens;
@ -5871,7 +5871,7 @@ const MessagePrefix = "\x19Ethereum Signed Message:\n";
*/
// Constants
const BN_0$6 = BigInt(0);
const BN_0$7 = BigInt(0);
const BN_1$4 = BigInt(1);
const BN_2$3 = BigInt(2);
const BN_27$1 = BigInt(27);
@ -6022,7 +6022,7 @@ class Signature {
const bv = getBigInt(v, "v");
// The v is not an EIP-155 v, so it is the unspecified chain ID
if ((bv == BN_27$1) || (bv == BN_28$1)) {
return BN_0$6;
return BN_0$7;
}
// Bad value for an EIP-155 v
assertArgument(bv >= BN_35$1, "invalid EIP-155 v", "v", v);
@ -6068,7 +6068,7 @@ class Signature {
*/
static getNormalizedV(v) {
const bv = getBigInt(v);
if (bv === BN_0$6 || bv === BN_27$1) {
if (bv === BN_0$7 || bv === BN_27$1) {
return 27;
}
if (bv === BN_1$4 || bv === BN_28$1) {
@ -6353,7 +6353,7 @@ function lock() {
randomBytes.lock();
}
const BN_0$5 = BigInt(0);
const BN_0$6 = BigInt(0);
const BN_36 = BigInt(36);
function getChecksumAddress(address) {
// if (!isHexString(address, 20)) {
@ -6415,7 +6415,7 @@ const Base36 = (function () {
})();
function fromBase36(value) {
value = value.toLowerCase();
let result = BN_0$5;
let result = BN_0$6;
for (let i = 0; i < value.length; i++) {
result = result * BN_36 + Base36[value[i]];
}
@ -7229,7 +7229,7 @@ class NullCoder extends Coder {
}
}
const BN_0$4 = BigInt(0);
const BN_0$5 = BigInt(0);
const BN_1$3 = BigInt(1);
const BN_MAX_UINT256$1 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
/**
@ -7257,7 +7257,7 @@ class NumberCoder extends Coder {
}
value = toTwos(value, 8 * WordSize);
}
else if (value < BN_0$4 || value > mask(maxUintValue, this.size * 8)) {
else if (value < BN_0$5 || value > mask(maxUintValue, this.size * 8)) {
this._throwError("value out-of-bounds", _value);
}
return writer.writeValue(value);
@ -8455,7 +8455,7 @@ function recoverAddress(digest, signature) {
return computeAddress(SigningKey.recoverPublicKey(digest, signature));
}
const BN_0$3 = BigInt(0);
const BN_0$4 = BigInt(0);
const BN_2$2 = BigInt(2);
const BN_27 = BigInt(27);
const BN_28 = BigInt(28);
@ -8483,7 +8483,7 @@ function handleNumber(_value, param) {
}
function handleUint(_value, param) {
if (_value === "0x") {
return BN_0$3;
return BN_0$4;
}
const value = getBigInt(_value, param);
assertArgument(value <= BN_MAX_UINT, "value exceeds uint size", param, value);
@ -8509,7 +8509,7 @@ function _parseLegacy(data) {
to: handleAddress(fields[3]),
value: handleUint(fields[4], "value"),
data: hexlify(fields[5]),
chainId: BN_0$3
chainId: BN_0$4
};
// Legacy unsigned transaction
if (fields.length === 6) {
@ -8518,19 +8518,19 @@ function _parseLegacy(data) {
const v = handleUint(fields[6], "v");
const r = handleUint(fields[7], "r");
const s = handleUint(fields[8], "s");
if (r === BN_0$3 && s === BN_0$3) {
if (r === BN_0$4 && s === BN_0$4) {
// EIP-155 unsigned transaction
tx.chainId = v;
}
else {
// Compute the EIP-155 chain ID (or 0 for legacy)
let chainId = (v - BN_35) / BN_2$2;
if (chainId < BN_0$3) {
chainId = BN_0$3;
if (chainId < BN_0$4) {
chainId = BN_0$4;
}
tx.chainId = chainId;
// Signed Legacy Transaction
assertArgument(chainId !== BN_0$3 || (v === BN_27 || v === BN_28), "non-canonical legacy v", "v", fields[6]);
assertArgument(chainId !== BN_0$4 || (v === BN_27 || v === BN_28), "non-canonical legacy v", "v", fields[6]);
tx.signature = Signature.from({
r: zeroPadValue(fields[7], 32),
s: zeroPadValue(fields[8], 32),
@ -8549,7 +8549,7 @@ function _serializeLegacy(tx, sig) {
formatNumber(tx.value || 0, "value"),
(tx.data || "0x"),
];
let chainId = BN_0$3;
let chainId = BN_0$4;
if (tx.chainId != null) {
// A chainId was provided; if non-zero we'll use EIP-155
chainId = getBigInt(tx.chainId, "tx.chainId");
@ -8567,7 +8567,7 @@ function _serializeLegacy(tx, sig) {
// Requesting an unsigned transaction
if (!sig) {
// We have an EIP-155 transaction (chainId was specified and non-zero)
if (chainId !== BN_0$3) {
if (chainId !== BN_0$4) {
fields.push(toBeArray(chainId));
fields.push("0x");
fields.push("0x");
@ -8576,7 +8576,7 @@ function _serializeLegacy(tx, sig) {
}
// We pushed a chainId and null r, s on for hashing only; remove those
let v = BigInt(27 + sig.yParity);
if (chainId !== BN_0$3) {
if (chainId !== BN_0$4) {
v = Signature.getChainIdV(chainId, sig.v);
}
else if (BigInt(sig.v) !== v) {
@ -8782,7 +8782,7 @@ class Transaction {
get gasPrice() {
const value = this.#gasPrice;
if (value == null && (this.type === 0 || this.type === 1)) {
return BN_0$3;
return BN_0$4;
}
return value;
}
@ -8797,7 +8797,7 @@ class Transaction {
const value = this.#maxPriorityFeePerGas;
if (value == null) {
if (this.type === 2) {
return BN_0$3;
return BN_0$4;
}
return null;
}
@ -8814,7 +8814,7 @@ class Transaction {
const value = this.#maxFeePerGas;
if (value == null) {
if (this.type === 2) {
return BN_0$3;
return BN_0$4;
}
return null;
}
@ -9304,7 +9304,7 @@ function solidityPackedSha256(types, values) {
const padding = new Uint8Array(32);
padding.fill(0);
const BN__1 = BigInt(-1);
const BN_0$2 = BigInt(0);
const BN_0$3 = BigInt(0);
const BN_1$2 = BigInt(1);
const BN_MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
;
@ -9318,7 +9318,7 @@ function hexPadRight(value) {
return hexlify(bytes);
}
const hexTrue = toBeHex(BN_1$2, 32);
const hexFalse = toBeHex(BN_0$2, 32);
const hexFalse = toBeHex(BN_0$3, 32);
const domainFieldTypes = {
name: "string",
version: "string",
@ -9363,7 +9363,7 @@ function getBaseEncoder(type) {
const width = parseInt(match[2] || "256");
assertArgument(width % 8 === 0 && width !== 0 && width <= 256 && (match[2] == null || match[2] === String(width)), "invalid numeric width", "type", type);
const boundsUpper = mask(BN_MAX_UINT256, signed ? (width - 1) : width);
const boundsLower = signed ? ((boundsUpper + BN_1$2) * BN__1) : BN_0$2;
const boundsLower = signed ? ((boundsUpper + BN_1$2) * BN__1) : BN_0$3;
return function (_value) {
const value = getBigInt(_value, "value");
assertArgument(value >= boundsLower && value <= boundsUpper, `value out-of-bounds for ${type}`, "value", value);
@ -9704,7 +9704,7 @@ function setify(items) {
// Visibility Keywords
const _kwVisib = "constant external internal payable private public pure view";
const KwVisib = setify(_kwVisib.split(" "));
const _kwTypes = "constructor error event function struct";
const _kwTypes = "constructor error event fallback function receive struct";
const KwTypes = setify(_kwTypes.split(" "));
const _kwModifiers = "calldata memory storage payable indexed";
const KwModifiers = setify(_kwModifiers.split(" "));
@ -10019,6 +10019,7 @@ const ParamTypeInternal = "_ParamTypeInternal";
const ErrorFragmentInternal = "_ErrorInternal";
const EventFragmentInternal = "_EventInternal";
const ConstructorFragmentInternal = "_ConstructorInternal";
const FallbackFragmentInternal = "_FallbackInternal";
const FunctionFragmentInternal = "_FunctionInternal";
const StructFragmentInternal = "_StructInternal";
/**
@ -10397,34 +10398,45 @@ class Fragment {
*/
static from(obj) {
if (typeof (obj) === "string") {
// Try parsing JSON...
try {
Fragment.from(JSON.parse(obj));
}
catch (e) { }
// ...otherwise, use the human-readable lexer
return Fragment.from(lex(obj));
}
if (obj instanceof TokenString) {
const type = obj.popKeyword(KwTypes);
// Human-readable ABI (already lexed)
const type = obj.peekKeyword(KwTypes);
switch (type) {
case "constructor": return ConstructorFragment.from(obj);
case "error": return ErrorFragment.from(obj);
case "event": return EventFragment.from(obj);
case "fallback":
case "receive":
return FallbackFragment.from(obj);
case "function": return FunctionFragment.from(obj);
case "struct": return StructFragment.from(obj);
}
throw new Error(`unsupported type: ${type}`);
}
if (typeof (obj) === "object") {
else if (typeof (obj) === "object") {
// JSON ABI
switch (obj.type) {
case "constructor": return ConstructorFragment.from(obj);
case "error": return ErrorFragment.from(obj);
case "event": return EventFragment.from(obj);
case "fallback":
case "receive":
return FallbackFragment.from(obj);
case "function": return FunctionFragment.from(obj);
case "struct": return StructFragment.from(obj);
}
throw new Error(`not implemented yet: ${obj.type}`);
assert$1(false, `unsupported type: ${obj.type}`, "UNSUPPORTED_OPERATION", {
operation: "Fragment.from"
});
}
throw new Error(`unsupported type: ${obj}`);
assertArgument(false, "unsupported frgament object", "obj", obj);
}
/**
* Returns true if %%value%% is a [[ConstructorFragment]].
@ -10647,6 +10659,79 @@ class ConstructorFragment extends Fragment {
return (value && value[internal$1] === ConstructorFragmentInternal);
}
}
/**
* A Fragment which represents a method.
*/
class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
payable;
constructor(guard, inputs, payable) {
super(guard, "fallback", inputs);
Object.defineProperty(this, internal$1, { value: FallbackFragmentInternal });
defineProperties(this, { payable });
}
format(format) {
const type = ((this.inputs.length === 0) ? "receive" : "fallback");
if (format === "json") {
const stateMutability = (this.payable ? "payable" : "nonpayable");
return JSON.stringify({ type, stateMutability });
}
return `${type}()${this.payable ? " payable" : ""}`;
}
static from(obj) {
if (FallbackFragment.isFragment(obj)) {
return obj;
}
if (typeof (obj) === "string") {
return FallbackFragment.from(lex(obj));
}
else if (obj instanceof TokenString) {
const errorObj = obj.toString();
const topIsValid = obj.peekKeyword(setify(["fallback", "receive"]));
assertArgument(topIsValid, "type must be fallback or receive", "obj", errorObj);
const type = obj.popKeyword(setify(["fallback", "receive"]));
// receive()
if (type === "receive") {
const inputs = consumeParams(obj);
assertArgument(inputs.length === 0, `receive cannot have arguments`, "obj.inputs", inputs);
consumeKeywords(obj, setify(["payable"]));
consumeEoi(obj);
return new FallbackFragment(_guard$2, [], true);
}
// fallback() [payable]
// fallback(bytes) [payable] returns (bytes)
let inputs = consumeParams(obj);
if (inputs.length) {
assertArgument(inputs.length === 1 && inputs[0].type === "bytes", "invalid fallback inputs", "obj.inputs", inputs.map((i) => i.format("minimal")).join(", "));
}
else {
inputs = [ParamType.from("bytes")];
}
const mutability = consumeMutability(obj);
assertArgument(mutability === "nonpayable" || mutability === "payable", "fallback cannot be constants", "obj.stateMutability", mutability);
if (consumeKeywords(obj, setify(["returns"])).has("returns")) {
const outputs = consumeParams(obj);
assertArgument(outputs.length === 1 && outputs[0].type === "bytes", "invalid fallback outputs", "obj.outputs", outputs.map((i) => i.format("minimal")).join(", "));
}
consumeEoi(obj);
return new FallbackFragment(_guard$2, inputs, mutability === "payable");
}
if (obj.type === "receive") {
return new FallbackFragment(_guard$2, [], true);
}
if (obj.type === "fallback") {
const inputs = [ParamType.from("bytes")];
const payable = (obj.stateMutability === "payable");
return new FallbackFragment(_guard$2, inputs, payable);
}
assertArgument(false, "invalid fallback description", "obj", obj);
}
static isFragment(value) {
return (value && value[internal$1] === FallbackFragmentInternal);
}
}
/**
* A Fragment which represents a method.
*/
@ -10665,7 +10750,7 @@ class FunctionFragment extends NamedFragment {
*/
stateMutability;
/**
* If the function can be send a value during invocation.
* If the function can be sent value during invocation.
*/
payable;
/**
@ -11112,6 +11197,14 @@ class Interface {
* The Contract constructor.
*/
deploy;
/**
* The Fallback method, if any.
*/
fallback;
/**
* If receiving ether is supported.
*/
receive;
#errors;
#events;
#functions;
@ -11144,9 +11237,11 @@ class Interface {
defineProperties(this, {
fragments: Object.freeze(frags)
});
let fallback = null;
let receive = false;
this.#abiCoder = this.getAbiCoder();
// Add all fragments by their signature
this.fragments.forEach((fragment) => {
this.fragments.forEach((fragment, index) => {
let bucket;
switch (fragment.type) {
case "constructor":
@ -11157,6 +11252,16 @@ class Interface {
//checkNames(fragment, "input", fragment.inputs);
defineProperties(this, { deploy: fragment });
return;
case "fallback":
if (fragment.inputs.length === 0) {
receive = true;
}
else {
assertArgument(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment);
fallback = fragment;
receive = fallback.payable;
}
return;
case "function":
//checkNames(fragment, "input", fragment.inputs);
//checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
@ -11185,6 +11290,7 @@ class Interface {
deploy: ConstructorFragment.from("constructor()")
});
}
defineProperties(this, { fallback, receive });
}
/**
* Returns the entire Human-Readable ABI, as an array of
@ -11962,7 +12068,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
*/
//import { resolveAddress } from "@ethersproject/address";
const BN_0$1 = BigInt(0);
const BN_0$2 = BigInt(0);
// -----------------------
function getValue(value) {
if (value == null) {
@ -12696,7 +12802,7 @@ class TransactionResponse {
if (tx.data === this.data && tx.to === this.to && tx.value === this.value) {
reason = "repriced";
}
else if (tx.data === "0x" && tx.from === tx.to && tx.value === BN_0$1) {
else if (tx.data === "0x" && tx.from === tx.to && tx.value === BN_0$2) {
reason = "cancelled";
}
assert$1(false, "transaction was replaced", "TRANSACTION_REPLACED", {
@ -12908,6 +13014,7 @@ class ContractEventPayload extends ContractUnknownEventPayload {
}
}
const BN_0$1 = BigInt(0);
function canCall(value) {
return (value && typeof (value.call) === "function");
}
@ -12981,17 +13088,11 @@ function getProvider(value) {
/**
* @_ignore:
*/
async function copyOverrides(arg) {
async function copyOverrides(arg, allowed) {
// Create a shallow copy (we'll deep-ify anything needed during normalizing)
const overrides = copyRequest(Typed.dereference(arg, "overrides"));
// Some sanity checking; these are what these methods adds
//if ((<any>overrides).to) {
if (overrides.to) {
assertArgument(false, "cannot override to", "overrides.to", overrides.to);
}
else if (overrides.data) {
assertArgument(false, "cannot override data", "overrides.data", overrides.data);
}
assertArgument(overrides.to == null || (allowed || []).indexOf("to") >= 0, "cannot override to", "overrides.to", overrides.to);
assertArgument(overrides.data == null || (allowed || []).indexOf("data") >= 0, "cannot override data", "overrides.data", overrides.data);
// Resolve any from
if (overrides.from) {
overrides.from = await resolveAddress(overrides.from);
@ -13015,6 +13116,59 @@ async function resolveArgs(_runner, inputs, args) {
});
}));
}
class WrappedFallback {
_contract;
constructor(contract) {
defineProperties(this, { _contract: contract });
const proxy = new Proxy(this, {
// Perform send when called
apply: async (target, thisArg, args) => {
return await target.send(...args);
},
});
return proxy;
}
async populateTransaction(overrides) {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(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$1) === BN_0$1, "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;
}
async staticCall(overrides) {
const runner = getRunner(this._contract.runner, "call");
assert$1(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 (isCallException(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
}
throw error;
}
}
async send(overrides) {
const runner = this._contract.runner;
assert$1(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(overrides));
const provider = getProvider(this._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(overrides) {
const runner = getRunner(this._contract.runner, "estimateGas");
assert$1(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;
@ -13335,6 +13489,7 @@ class BaseContract {
runner;
filters;
[internal];
fallback;
constructor(target, abi, runner, _deployTx) {
if (runner == null) {
runner = null;
@ -13401,6 +13556,9 @@ class BaseContract {
}
});
defineProperties(this, { filters });
defineProperties(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)) : null)
});
// Return a Proxy that will respond to functions
return new Proxy(this, {
get: (target, _prop, receiver) => {

2
dist/ethers.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

@ -19,7 +19,7 @@ describe("Test Contract", function () {
"function testErrorString(bool pass, string calldata message) pure returns (uint256)",
"function testPanic(uint256 code) returns (uint256)",
"function testEvent(uint256 valueUint256, address valueAddress, string valueString, bytes valueBytes) public",
"function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)"
"function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)",
];
it("tests contract calls", async function () {
this.timeout(10000);
@ -210,73 +210,128 @@ describe("Test Typed Contract Interaction", function () {
}
}
});
/*
describe("Test Contract Calls", function() {
it("finds typed methods", async function() {
const contract = new Contract("0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72", [
"function foo(string s) view returns (uint)",
"function foo(uint8) view returns (uint)",
"function foo(uint u, bool b) view returns (uint)",
]);
const value = Typed.string("42");
await contract.foo.populateTransaction(value, Typed.overrides({ value: 100 }))
contract["foo(string)"].fragment
});
});
describe("Test Contract Interface", function() {
it("builds contract interfaces", async function() {
this.timeout(60000);
interface Erc20Interface {
// Constant Methods
balanceOf: ConstantContractMethod<[ address: string | Addressable ], bigint>;
decimals: ConstantContractMethod<[ ], bigint>;
name: ConstantContractMethod<[ ], string>;
symbol: ConstantContractMethod<[ ], string>;
// Mutation Methods
transferFrom: ContractMethod<[ address: string | Addressable,
address: string | Addressable, amount: BigNumberish ], boolean>;
// Events
filters: {
Transfer: ContractEvent<[ from: Addressable | string, to: BigNumberish ]>;
}
}
const erc20Abi = [
"function balanceOf(address owner) view returns (uint)",
"function decimals() view returns (uint)",
"function name() view returns (string)",
"function symbol() view returns (string)",
"function transferFrom(address from, address to, uint amount) returns (boolean)",
"event Transfer(address indexed from, address indexed to, uint amount)"
describe("Test Contract Fallback", function () {
const tests = [
{
name: "none",
address: "0x0ccdace3d8353fed9b87a2d63c40452923ccdae5",
abi: [],
sendNone: { error: "no fallback" },
sendData: { error: "no fallback" },
sendValue: { error: "no fallback" },
sendDataAndValue: { error: "no fallback" },
},
{
name: "non-payable fallback",
address: "0x3f10193f79a639b11ec9d2ab42a25a4a905a8870",
abi: [
"fallback()"
],
sendNone: { data: "0x" },
sendData: { data: "0x1234" },
sendValue: { error: "overrides.value" },
sendDataAndValue: { error: "overrides.value" },
},
{
name: "payable fallback",
address: "0xe2de6b97c5eb9fee8a47ca6c0fa642331e0b6330",
abi: [
"fallback() payable"
],
sendNone: { data: "0x" },
sendData: { data: "0x1234" },
sendValue: { data: "0x" },
sendDataAndValue: { data: "0x1234" },
},
{
name: "receive-only",
address: "0xf8f2afbbe37f6a4520e4db7f99495655aa31229b",
abi: [
"receive()"
],
sendNone: { data: "0x" },
sendData: { error: "overrides.data" },
sendValue: { data: "0x" },
sendDataAndValue: { error: "overrides.data" },
},
{
name: "receive and payable fallback",
address: "0x7d97ca5d9dea1cd0364f1d493252006a3c4e18a0",
abi: [
"fallback() payable",
"receive()"
],
sendNone: { data: "0x" },
sendData: { data: "0x1234" },
sendValue: { data: "0x" },
sendDataAndValue: { data: "0x1234" },
},
{
name: "receive and non-payable fallback",
address: "0x5b59d934f0d22b15e73b5d6b9ae83486b70df67e",
abi: [
"fallback() payable",
"receive()"
],
sendNone: { data: "0x" },
sendData: { data: "0x" },
sendValue: { data: "0x" },
sendDataAndValue: { error: "overrides.value" },
},
];
class Erc20Contract extends BaseContract.buildClass<Erc20Interface>(erc20Abi) { };
const provider = new providers.InfuraProvider();
// ENS
//const addr = "0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72";
// DAI
const addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
const contract = new Erc20Contract(addr, provider);
console.log("SYMBOL", await contract.symbol());
console.log("DECIMALS", await contract.decimals());
console.log(await contract.balanceOf("0x5555763613a12D8F3e73be831DFf8598089d3dCa"));
console.log(await contract.balanceOf("ricmoo.eth"));
await contract.on(contract.filters.Transfer, (from, to, value, event) => {
console.log("HELLO!", { from, to, value, event });
event.removeListener();
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
const testGroups = [
{
group: "sendNone",
tx: {}
},
{
group: "sendData",
tx: { data: "0x1234" }
},
{
group: "sendValue",
tx: { value: 123 }
},
{
group: "sendDataAndValue",
tx: { data: "0x1234", value: 123 }
},
];
for (const { group, tx } of testGroups) {
for (const test of tests) {
const { name, address, abi } = test;
const send = test[group];
const contract = new index_js_1.Contract(address, abi, provider);
it(`test contract fallback checks: ${group} - ${name}`, async function () {
const func = async function () {
if (abi.length === 0) {
throw new Error("no fallback");
}
assert_1.default.ok(contract.fallback);
return await contract.fallback.populateTransaction(tx);
};
if ("data" in send) {
await func();
//const result = await func();
//@TODO: Test for the correct populated tx
//console.log(result);
assert_1.default.ok(true);
}
else {
assert_1.default.rejects(func, function (error) {
if (error.message === send.error) {
return true;
}
if ((0, index_js_1.isError)(error, "INVALID_ARGUMENT")) {
return error.argument === send.error;
}
console.log("EE", error);
return true;
});
const logs = await contract.queryFilter("Transfer", -10);
console.log(logs, logs[0], logs[0].args.from);
}
});
}
}
});
*/
//# sourceMappingURL=test-contract.js.map

File diff suppressed because one or more lines are too long

@ -5,7 +5,7 @@
* @_subsection api/abi/abi-coder:Fragments
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.StructFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.ErrorFragment = exports.NamedFragment = exports.Fragment = exports.ParamType = void 0;
exports.StructFragment = exports.FunctionFragment = exports.FallbackFragment = exports.ConstructorFragment = exports.EventFragment = exports.ErrorFragment = exports.NamedFragment = exports.Fragment = exports.ParamType = void 0;
const index_js_1 = require("../utils/index.js");
const index_js_2 = require("../hash/index.js");
;
@ -18,7 +18,7 @@ function setify(items) {
// Visibility Keywords
const _kwVisib = "constant external internal payable private public pure view";
const KwVisib = setify(_kwVisib.split(" "));
const _kwTypes = "constructor error event function struct";
const _kwTypes = "constructor error event fallback function receive struct";
const KwTypes = setify(_kwTypes.split(" "));
const _kwModifiers = "calldata memory storage payable indexed";
const KwModifiers = setify(_kwModifiers.split(" "));
@ -333,6 +333,7 @@ const ParamTypeInternal = "_ParamTypeInternal";
const ErrorFragmentInternal = "_ErrorInternal";
const EventFragmentInternal = "_EventInternal";
const ConstructorFragmentInternal = "_ConstructorInternal";
const FallbackFragmentInternal = "_FallbackInternal";
const FunctionFragmentInternal = "_FunctionInternal";
const StructFragmentInternal = "_StructInternal";
/**
@ -712,34 +713,45 @@ class Fragment {
*/
static from(obj) {
if (typeof (obj) === "string") {
// Try parsing JSON...
try {
Fragment.from(JSON.parse(obj));
}
catch (e) { }
// ...otherwise, use the human-readable lexer
return Fragment.from(lex(obj));
}
if (obj instanceof TokenString) {
const type = obj.popKeyword(KwTypes);
// Human-readable ABI (already lexed)
const type = obj.peekKeyword(KwTypes);
switch (type) {
case "constructor": return ConstructorFragment.from(obj);
case "error": return ErrorFragment.from(obj);
case "event": return EventFragment.from(obj);
case "fallback":
case "receive":
return FallbackFragment.from(obj);
case "function": return FunctionFragment.from(obj);
case "struct": return StructFragment.from(obj);
}
throw new Error(`unsupported type: ${type}`);
}
if (typeof (obj) === "object") {
else if (typeof (obj) === "object") {
// JSON ABI
switch (obj.type) {
case "constructor": return ConstructorFragment.from(obj);
case "error": return ErrorFragment.from(obj);
case "event": return EventFragment.from(obj);
case "fallback":
case "receive":
return FallbackFragment.from(obj);
case "function": return FunctionFragment.from(obj);
case "struct": return StructFragment.from(obj);
}
throw new Error(`not implemented yet: ${obj.type}`);
(0, index_js_1.assert)(false, `unsupported type: ${obj.type}`, "UNSUPPORTED_OPERATION", {
operation: "Fragment.from"
});
}
throw new Error(`unsupported type: ${obj}`);
(0, index_js_1.assertArgument)(false, "unsupported frgament object", "obj", obj);
}
/**
* Returns true if %%value%% is a [[ConstructorFragment]].
@ -967,6 +979,80 @@ class ConstructorFragment extends Fragment {
}
}
exports.ConstructorFragment = ConstructorFragment;
/**
* A Fragment which represents a method.
*/
class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
payable;
constructor(guard, inputs, payable) {
super(guard, "fallback", inputs);
Object.defineProperty(this, internal, { value: FallbackFragmentInternal });
(0, index_js_1.defineProperties)(this, { payable });
}
format(format) {
const type = ((this.inputs.length === 0) ? "receive" : "fallback");
if (format === "json") {
const stateMutability = (this.payable ? "payable" : "nonpayable");
return JSON.stringify({ type, stateMutability });
}
return `${type}()${this.payable ? " payable" : ""}`;
}
static from(obj) {
if (FallbackFragment.isFragment(obj)) {
return obj;
}
if (typeof (obj) === "string") {
return FallbackFragment.from(lex(obj));
}
else if (obj instanceof TokenString) {
const errorObj = obj.toString();
const topIsValid = obj.peekKeyword(setify(["fallback", "receive"]));
(0, index_js_1.assertArgument)(topIsValid, "type must be fallback or receive", "obj", errorObj);
const type = obj.popKeyword(setify(["fallback", "receive"]));
// receive()
if (type === "receive") {
const inputs = consumeParams(obj);
(0, index_js_1.assertArgument)(inputs.length === 0, `receive cannot have arguments`, "obj.inputs", inputs);
consumeKeywords(obj, setify(["payable"]));
consumeEoi(obj);
return new FallbackFragment(_guard, [], true);
}
// fallback() [payable]
// fallback(bytes) [payable] returns (bytes)
let inputs = consumeParams(obj);
if (inputs.length) {
(0, index_js_1.assertArgument)(inputs.length === 1 && inputs[0].type === "bytes", "invalid fallback inputs", "obj.inputs", inputs.map((i) => i.format("minimal")).join(", "));
}
else {
inputs = [ParamType.from("bytes")];
}
const mutability = consumeMutability(obj);
(0, index_js_1.assertArgument)(mutability === "nonpayable" || mutability === "payable", "fallback cannot be constants", "obj.stateMutability", mutability);
if (consumeKeywords(obj, setify(["returns"])).has("returns")) {
const outputs = consumeParams(obj);
(0, index_js_1.assertArgument)(outputs.length === 1 && outputs[0].type === "bytes", "invalid fallback outputs", "obj.outputs", outputs.map((i) => i.format("minimal")).join(", "));
}
consumeEoi(obj);
return new FallbackFragment(_guard, inputs, mutability === "payable");
}
if (obj.type === "receive") {
return new FallbackFragment(_guard, [], true);
}
if (obj.type === "fallback") {
const inputs = [ParamType.from("bytes")];
const payable = (obj.stateMutability === "payable");
return new FallbackFragment(_guard, inputs, payable);
}
(0, index_js_1.assertArgument)(false, "invalid fallback description", "obj", obj);
}
static isFragment(value) {
return (value && value[internal] === FallbackFragmentInternal);
}
}
exports.FallbackFragment = FallbackFragment;
/**
* A Fragment which represents a method.
*/
@ -985,7 +1071,7 @@ class FunctionFragment extends NamedFragment {
*/
stateMutability;
/**
* If the function can be send a value during invocation.
* If the function can be sent value during invocation.
*/
payable;
/**

File diff suppressed because one or more lines are too long

@ -6,7 +6,7 @@
* @_navTitle: ABI
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Typed = exports.Result = exports.TransactionDescription = exports.LogDescription = exports.ErrorDescription = exports.Interface = exports.Indexed = exports.checkResultErrors = exports.StructFragment = exports.ParamType = exports.NamedFragment = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.encodeBytes32String = exports.decodeBytes32String = exports.AbiCoder = void 0;
exports.Typed = exports.Result = exports.TransactionDescription = exports.LogDescription = exports.ErrorDescription = exports.Interface = exports.Indexed = exports.checkResultErrors = exports.StructFragment = exports.ParamType = exports.NamedFragment = exports.FunctionFragment = exports.Fragment = exports.FallbackFragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.encodeBytes32String = exports.decodeBytes32String = exports.AbiCoder = void 0;
//////
var abi_coder_js_1 = require("./abi-coder.js");
Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return abi_coder_js_1.AbiCoder; } });
@ -17,6 +17,7 @@ var fragments_js_1 = require("./fragments.js");
Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return fragments_js_1.ConstructorFragment; } });
Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return fragments_js_1.ErrorFragment; } });
Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return fragments_js_1.EventFragment; } });
Object.defineProperty(exports, "FallbackFragment", { enumerable: true, get: function () { return fragments_js_1.FallbackFragment; } });
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragments_js_1.Fragment; } });
Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function () { return fragments_js_1.FunctionFragment; } });
Object.defineProperty(exports, "NamedFragment", { enumerable: true, get: function () { return fragments_js_1.NamedFragment; } });

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,MAAM;AACN,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAEjB,2CAAwE;AAA/D,iHAAA,mBAAmB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAEjD,+CAGwB;AAFpB,mHAAA,mBAAmB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAC3D,gHAAA,gBAAgB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,8GAAA,cAAc,OAAA;AAG9D,+CAMwB;AALpB,iHAAA,iBAAiB,OAAA;AACjB,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AACxD,sGAAA,MAAM,OAAA;AAGV,uCAAmC;AAA1B,iGAAA,KAAK,OAAA"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,MAAM;AACN,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAEjB,2CAAwE;AAA/D,iHAAA,mBAAmB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAEjD,+CAGwB;AAFpB,mHAAA,mBAAmB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AACnE,wGAAA,QAAQ,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,8GAAA,cAAc,OAAA;AAGxE,+CAMwB;AALpB,iHAAA,iBAAiB,OAAA;AACjB,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AACxD,sGAAA,MAAM,OAAA;AAGV,uCAAmC;AAA1B,iGAAA,KAAK,OAAA"}

@ -123,6 +123,14 @@ class Interface {
* The Contract constructor.
*/
deploy;
/**
* The Fallback method, if any.
*/
fallback;
/**
* If receiving ether is supported.
*/
receive;
#errors;
#events;
#functions;
@ -155,9 +163,11 @@ class Interface {
(0, index_js_3.defineProperties)(this, {
fragments: Object.freeze(frags)
});
let fallback = null;
let receive = false;
this.#abiCoder = this.getAbiCoder();
// Add all fragments by their signature
this.fragments.forEach((fragment) => {
this.fragments.forEach((fragment, index) => {
let bucket;
switch (fragment.type) {
case "constructor":
@ -168,6 +178,16 @@ class Interface {
//checkNames(fragment, "input", fragment.inputs);
(0, index_js_3.defineProperties)(this, { deploy: fragment });
return;
case "fallback":
if (fragment.inputs.length === 0) {
receive = true;
}
else {
(0, index_js_3.assertArgument)(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment);
fallback = fragment;
receive = fallback.payable;
}
return;
case "function":
//checkNames(fragment, "input", fragment.inputs);
//checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
@ -196,6 +216,7 @@ class Interface {
deploy: fragments_js_1.ConstructorFragment.from("constructor()")
});
}
(0, index_js_3.defineProperties)(this, { fallback, receive });
}
/**
* Returns the entire Human-Readable ABI, as an array of

File diff suppressed because one or more lines are too long

@ -8,6 +8,7 @@ const index_js_2 = require("../address/index.js");
const provider_js_1 = require("../providers/provider.js");
const index_js_3 = require("../utils/index.js");
const wrappers_js_1 = require("./wrappers.js");
const BN_0 = BigInt(0);
function canCall(value) {
return (value && typeof (value.call) === "function");
}
@ -81,17 +82,11 @@ function getProvider(value) {
/**
* @_ignore:
*/
async function copyOverrides(arg) {
async function copyOverrides(arg, allowed) {
// Create a shallow copy (we'll deep-ify anything needed during normalizing)
const overrides = (0, provider_js_1.copyRequest)(index_js_1.Typed.dereference(arg, "overrides"));
// Some sanity checking; these are what these methods adds
//if ((<any>overrides).to) {
if (overrides.to) {
(0, index_js_3.assertArgument)(false, "cannot override to", "overrides.to", overrides.to);
}
else if (overrides.data) {
(0, index_js_3.assertArgument)(false, "cannot override data", "overrides.data", overrides.data);
}
(0, index_js_3.assertArgument)(overrides.to == null || (allowed || []).indexOf("to") >= 0, "cannot override to", "overrides.to", overrides.to);
(0, index_js_3.assertArgument)(overrides.data == null || (allowed || []).indexOf("data") >= 0, "cannot override data", "overrides.data", overrides.data);
// Resolve any from
if (overrides.from) {
overrides.from = await (0, index_js_2.resolveAddress)(overrides.from);
@ -117,6 +112,59 @@ async function resolveArgs(_runner, inputs, args) {
}));
}
exports.resolveArgs = resolveArgs;
class WrappedFallback {
_contract;
constructor(contract) {
(0, index_js_3.defineProperties)(this, { _contract: contract });
const proxy = new Proxy(this, {
// Perform send when called
apply: async (target, thisArg, args) => {
return await target.send(...args);
},
});
return proxy;
}
async populateTransaction(overrides) {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(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);
// 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;
}
async staticCall(overrides) {
const runner = getRunner(this._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(overrides);
try {
return await runner.call(tx);
}
catch (error) {
if ((0, index_js_3.isCallException)(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
}
throw error;
}
}
async send(overrides) {
const runner = this._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(overrides));
const provider = getProvider(this._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(overrides) {
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" });
return await runner.estimateGas(await this.populateTransaction(overrides));
}
}
class WrappedMethod extends _WrappedMethodBase() {
name = ""; // Investigate!
_contract;
@ -437,6 +485,7 @@ class BaseContract {
runner;
filters;
[internal];
fallback;
constructor(target, abi, runner, _deployTx) {
if (runner == null) {
runner = null;
@ -503,6 +552,9 @@ class BaseContract {
}
});
(0, index_js_3.defineProperties)(this, { filters });
(0, index_js_3.defineProperties)(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)) : null)
});
// Return a Proxy that will respond to functions
return new Proxy(this, {
get: (target, _prop, receiver) => {

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
import assert from "assert";
import { getProvider, setupProviders } from "./create-provider.js";
import { Contract, EventLog, Typed, Wallet } from "../index.js";
import { Contract, EventLog, isError, Typed, Wallet } from "../index.js";
setupProviders();
describe("Test Contract", function () {
const addr = "0x99417252Aad7B065940eBdF50d665Fb8879c5958";
@ -14,7 +14,7 @@ describe("Test Contract", function () {
"function testErrorString(bool pass, string calldata message) pure returns (uint256)",
"function testPanic(uint256 code) returns (uint256)",
"function testEvent(uint256 valueUint256, address valueAddress, string valueString, bytes valueBytes) public",
"function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)"
"function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)",
];
it("tests contract calls", async function () {
this.timeout(10000);
@ -205,73 +205,128 @@ describe("Test Typed Contract Interaction", function () {
}
}
});
/*
describe("Test Contract Calls", function() {
it("finds typed methods", async function() {
const contract = new Contract("0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72", [
"function foo(string s) view returns (uint)",
"function foo(uint8) view returns (uint)",
"function foo(uint u, bool b) view returns (uint)",
]);
const value = Typed.string("42");
await contract.foo.populateTransaction(value, Typed.overrides({ value: 100 }))
contract["foo(string)"].fragment
});
});
describe("Test Contract Interface", function() {
it("builds contract interfaces", async function() {
this.timeout(60000);
interface Erc20Interface {
// Constant Methods
balanceOf: ConstantContractMethod<[ address: string | Addressable ], bigint>;
decimals: ConstantContractMethod<[ ], bigint>;
name: ConstantContractMethod<[ ], string>;
symbol: ConstantContractMethod<[ ], string>;
// Mutation Methods
transferFrom: ContractMethod<[ address: string | Addressable,
address: string | Addressable, amount: BigNumberish ], boolean>;
// Events
filters: {
Transfer: ContractEvent<[ from: Addressable | string, to: BigNumberish ]>;
}
}
const erc20Abi = [
"function balanceOf(address owner) view returns (uint)",
"function decimals() view returns (uint)",
"function name() view returns (string)",
"function symbol() view returns (string)",
"function transferFrom(address from, address to, uint amount) returns (boolean)",
"event Transfer(address indexed from, address indexed to, uint amount)"
describe("Test Contract Fallback", function () {
const tests = [
{
name: "none",
address: "0x0ccdace3d8353fed9b87a2d63c40452923ccdae5",
abi: [],
sendNone: { error: "no fallback" },
sendData: { error: "no fallback" },
sendValue: { error: "no fallback" },
sendDataAndValue: { error: "no fallback" },
},
{
name: "non-payable fallback",
address: "0x3f10193f79a639b11ec9d2ab42a25a4a905a8870",
abi: [
"fallback()"
],
sendNone: { data: "0x" },
sendData: { data: "0x1234" },
sendValue: { error: "overrides.value" },
sendDataAndValue: { error: "overrides.value" },
},
{
name: "payable fallback",
address: "0xe2de6b97c5eb9fee8a47ca6c0fa642331e0b6330",
abi: [
"fallback() payable"
],
sendNone: { data: "0x" },
sendData: { data: "0x1234" },
sendValue: { data: "0x" },
sendDataAndValue: { data: "0x1234" },
},
{
name: "receive-only",
address: "0xf8f2afbbe37f6a4520e4db7f99495655aa31229b",
abi: [
"receive()"
],
sendNone: { data: "0x" },
sendData: { error: "overrides.data" },
sendValue: { data: "0x" },
sendDataAndValue: { error: "overrides.data" },
},
{
name: "receive and payable fallback",
address: "0x7d97ca5d9dea1cd0364f1d493252006a3c4e18a0",
abi: [
"fallback() payable",
"receive()"
],
sendNone: { data: "0x" },
sendData: { data: "0x1234" },
sendValue: { data: "0x" },
sendDataAndValue: { data: "0x1234" },
},
{
name: "receive and non-payable fallback",
address: "0x5b59d934f0d22b15e73b5d6b9ae83486b70df67e",
abi: [
"fallback() payable",
"receive()"
],
sendNone: { data: "0x" },
sendData: { data: "0x" },
sendValue: { data: "0x" },
sendDataAndValue: { error: "overrides.value" },
},
];
class Erc20Contract extends BaseContract.buildClass<Erc20Interface>(erc20Abi) { };
const provider = new providers.InfuraProvider();
// ENS
//const addr = "0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72";
// DAI
const addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
const contract = new Erc20Contract(addr, provider);
console.log("SYMBOL", await contract.symbol());
console.log("DECIMALS", await contract.decimals());
console.log(await contract.balanceOf("0x5555763613a12D8F3e73be831DFf8598089d3dCa"));
console.log(await contract.balanceOf("ricmoo.eth"));
await contract.on(contract.filters.Transfer, (from, to, value, event) => {
console.log("HELLO!", { from, to, value, event });
event.removeListener();
const provider = getProvider("InfuraProvider", "goerli");
const testGroups = [
{
group: "sendNone",
tx: {}
},
{
group: "sendData",
tx: { data: "0x1234" }
},
{
group: "sendValue",
tx: { value: 123 }
},
{
group: "sendDataAndValue",
tx: { data: "0x1234", value: 123 }
},
];
for (const { group, tx } of testGroups) {
for (const test of tests) {
const { name, address, abi } = test;
const send = test[group];
const contract = new Contract(address, abi, provider);
it(`test contract fallback checks: ${group} - ${name}`, async function () {
const func = async function () {
if (abi.length === 0) {
throw new Error("no fallback");
}
assert.ok(contract.fallback);
return await contract.fallback.populateTransaction(tx);
};
if ("data" in send) {
await func();
//const result = await func();
//@TODO: Test for the correct populated tx
//console.log(result);
assert.ok(true);
}
else {
assert.rejects(func, function (error) {
if (error.message === send.error) {
return true;
}
if (isError(error, "INVALID_ARGUMENT")) {
return error.argument === send.error;
}
console.log("EE", error);
return true;
});
const logs = await contract.queryFilter("Transfer", -10);
console.log(logs, logs[0], logs[0].args.from);
}
});
}
}
});
*/
//# sourceMappingURL=test-contract.js.map

File diff suppressed because one or more lines are too long

@ -15,7 +15,7 @@ function setify(items) {
// Visibility Keywords
const _kwVisib = "constant external internal payable private public pure view";
const KwVisib = setify(_kwVisib.split(" "));
const _kwTypes = "constructor error event function struct";
const _kwTypes = "constructor error event fallback function receive struct";
const KwTypes = setify(_kwTypes.split(" "));
const _kwModifiers = "calldata memory storage payable indexed";
const KwModifiers = setify(_kwModifiers.split(" "));
@ -330,6 +330,7 @@ const ParamTypeInternal = "_ParamTypeInternal";
const ErrorFragmentInternal = "_ErrorInternal";
const EventFragmentInternal = "_EventInternal";
const ConstructorFragmentInternal = "_ConstructorInternal";
const FallbackFragmentInternal = "_FallbackInternal";
const FunctionFragmentInternal = "_FunctionInternal";
const StructFragmentInternal = "_StructInternal";
/**
@ -708,34 +709,45 @@ export class Fragment {
*/
static from(obj) {
if (typeof (obj) === "string") {
// Try parsing JSON...
try {
Fragment.from(JSON.parse(obj));
}
catch (e) { }
// ...otherwise, use the human-readable lexer
return Fragment.from(lex(obj));
}
if (obj instanceof TokenString) {
const type = obj.popKeyword(KwTypes);
// Human-readable ABI (already lexed)
const type = obj.peekKeyword(KwTypes);
switch (type) {
case "constructor": return ConstructorFragment.from(obj);
case "error": return ErrorFragment.from(obj);
case "event": return EventFragment.from(obj);
case "fallback":
case "receive":
return FallbackFragment.from(obj);
case "function": return FunctionFragment.from(obj);
case "struct": return StructFragment.from(obj);
}
throw new Error(`unsupported type: ${type}`);
}
if (typeof (obj) === "object") {
else if (typeof (obj) === "object") {
// JSON ABI
switch (obj.type) {
case "constructor": return ConstructorFragment.from(obj);
case "error": return ErrorFragment.from(obj);
case "event": return EventFragment.from(obj);
case "fallback":
case "receive":
return FallbackFragment.from(obj);
case "function": return FunctionFragment.from(obj);
case "struct": return StructFragment.from(obj);
}
throw new Error(`not implemented yet: ${obj.type}`);
assert(false, `unsupported type: ${obj.type}`, "UNSUPPORTED_OPERATION", {
operation: "Fragment.from"
});
}
throw new Error(`unsupported type: ${obj}`);
assertArgument(false, "unsupported frgament object", "obj", obj);
}
/**
* Returns true if %%value%% is a [[ConstructorFragment]].
@ -958,6 +970,79 @@ export class ConstructorFragment extends Fragment {
return (value && value[internal] === ConstructorFragmentInternal);
}
}
/**
* A Fragment which represents a method.
*/
export class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
payable;
constructor(guard, inputs, payable) {
super(guard, "fallback", inputs);
Object.defineProperty(this, internal, { value: FallbackFragmentInternal });
defineProperties(this, { payable });
}
format(format) {
const type = ((this.inputs.length === 0) ? "receive" : "fallback");
if (format === "json") {
const stateMutability = (this.payable ? "payable" : "nonpayable");
return JSON.stringify({ type, stateMutability });
}
return `${type}()${this.payable ? " payable" : ""}`;
}
static from(obj) {
if (FallbackFragment.isFragment(obj)) {
return obj;
}
if (typeof (obj) === "string") {
return FallbackFragment.from(lex(obj));
}
else if (obj instanceof TokenString) {
const errorObj = obj.toString();
const topIsValid = obj.peekKeyword(setify(["fallback", "receive"]));
assertArgument(topIsValid, "type must be fallback or receive", "obj", errorObj);
const type = obj.popKeyword(setify(["fallback", "receive"]));
// receive()
if (type === "receive") {
const inputs = consumeParams(obj);
assertArgument(inputs.length === 0, `receive cannot have arguments`, "obj.inputs", inputs);
consumeKeywords(obj, setify(["payable"]));
consumeEoi(obj);
return new FallbackFragment(_guard, [], true);
}
// fallback() [payable]
// fallback(bytes) [payable] returns (bytes)
let inputs = consumeParams(obj);
if (inputs.length) {
assertArgument(inputs.length === 1 && inputs[0].type === "bytes", "invalid fallback inputs", "obj.inputs", inputs.map((i) => i.format("minimal")).join(", "));
}
else {
inputs = [ParamType.from("bytes")];
}
const mutability = consumeMutability(obj);
assertArgument(mutability === "nonpayable" || mutability === "payable", "fallback cannot be constants", "obj.stateMutability", mutability);
if (consumeKeywords(obj, setify(["returns"])).has("returns")) {
const outputs = consumeParams(obj);
assertArgument(outputs.length === 1 && outputs[0].type === "bytes", "invalid fallback outputs", "obj.outputs", outputs.map((i) => i.format("minimal")).join(", "));
}
consumeEoi(obj);
return new FallbackFragment(_guard, inputs, mutability === "payable");
}
if (obj.type === "receive") {
return new FallbackFragment(_guard, [], true);
}
if (obj.type === "fallback") {
const inputs = [ParamType.from("bytes")];
const payable = (obj.stateMutability === "payable");
return new FallbackFragment(_guard, inputs, payable);
}
assertArgument(false, "invalid fallback description", "obj", obj);
}
static isFragment(value) {
return (value && value[internal] === FallbackFragmentInternal);
}
}
/**
* A Fragment which represents a method.
*/
@ -976,7 +1061,7 @@ export class FunctionFragment extends NamedFragment {
*/
stateMutability;
/**
* If the function can be send a value during invocation.
* If the function can be sent value during invocation.
*/
payable;
/**

File diff suppressed because one or more lines are too long

@ -7,7 +7,7 @@
//////
export { AbiCoder } from "./abi-coder.js";
export { decodeBytes32String, encodeBytes32String } from "./bytes32.js";
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { checkResultErrors, Indexed, Interface, ErrorDescription, LogDescription, TransactionDescription, Result } from "./interface.js";
export { Typed } from "./typed.js";
//# sourceMappingURL=index.js.map

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM;AACN,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACH,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAC3D,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,GAC7D,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EACxD,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM;AACN,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACH,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EACnE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,GACvE,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EACxD,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}

@ -115,6 +115,14 @@ export class Interface {
* The Contract constructor.
*/
deploy;
/**
* The Fallback method, if any.
*/
fallback;
/**
* If receiving ether is supported.
*/
receive;
#errors;
#events;
#functions;
@ -147,9 +155,11 @@ export class Interface {
defineProperties(this, {
fragments: Object.freeze(frags)
});
let fallback = null;
let receive = false;
this.#abiCoder = this.getAbiCoder();
// Add all fragments by their signature
this.fragments.forEach((fragment) => {
this.fragments.forEach((fragment, index) => {
let bucket;
switch (fragment.type) {
case "constructor":
@ -160,6 +170,16 @@ export class Interface {
//checkNames(fragment, "input", fragment.inputs);
defineProperties(this, { deploy: fragment });
return;
case "fallback":
if (fragment.inputs.length === 0) {
receive = true;
}
else {
assertArgument(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment);
fallback = fragment;
receive = fallback.payable;
}
return;
case "function":
//checkNames(fragment, "input", fragment.inputs);
//checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
@ -188,6 +208,7 @@ export class Interface {
deploy: ConstructorFragment.from("constructor()")
});
}
defineProperties(this, { fallback, receive });
}
/**
* Returns the entire Human-Readable ABI, as an array of

File diff suppressed because one or more lines are too long

@ -5,6 +5,7 @@ import { resolveAddress } from "../address/index.js";
import { copyRequest, Log } from "../providers/provider.js";
import { defineProperties, isCallException, isHexString, resolveProperties, makeError, assert, assertArgument } from "../utils/index.js";
import { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionResponse, EventLog } from "./wrappers.js";
const BN_0 = BigInt(0);
function canCall(value) {
return (value && typeof (value.call) === "function");
}
@ -78,17 +79,11 @@ function getProvider(value) {
/**
* @_ignore:
*/
export async function copyOverrides(arg) {
export async function copyOverrides(arg, allowed) {
// Create a shallow copy (we'll deep-ify anything needed during normalizing)
const overrides = copyRequest(Typed.dereference(arg, "overrides"));
// Some sanity checking; these are what these methods adds
//if ((<any>overrides).to) {
if (overrides.to) {
assertArgument(false, "cannot override to", "overrides.to", overrides.to);
}
else if (overrides.data) {
assertArgument(false, "cannot override data", "overrides.data", overrides.data);
}
assertArgument(overrides.to == null || (allowed || []).indexOf("to") >= 0, "cannot override to", "overrides.to", overrides.to);
assertArgument(overrides.data == null || (allowed || []).indexOf("data") >= 0, "cannot override data", "overrides.data", overrides.data);
// Resolve any from
if (overrides.from) {
overrides.from = await resolveAddress(overrides.from);
@ -112,6 +107,59 @@ export async function resolveArgs(_runner, inputs, args) {
});
}));
}
class WrappedFallback {
_contract;
constructor(contract) {
defineProperties(this, { _contract: contract });
const proxy = new Proxy(this, {
// Perform send when called
apply: async (target, thisArg, args) => {
return await target.send(...args);
},
});
return proxy;
}
async populateTransaction(overrides) {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(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);
// 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;
}
async staticCall(overrides) {
const runner = getRunner(this._contract.runner, "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 (isCallException(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
}
throw error;
}
}
async send(overrides) {
const runner = this._contract.runner;
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(overrides));
const provider = getProvider(this._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(overrides) {
const runner = getRunner(this._contract.runner, "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;
@ -432,6 +480,7 @@ export class BaseContract {
runner;
filters;
[internal];
fallback;
constructor(target, abi, runner, _deployTx) {
if (runner == null) {
runner = null;
@ -498,6 +547,9 @@ export class BaseContract {
}
});
defineProperties(this, { filters });
defineProperties(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)) : null)
});
// Return a Proxy that will respond to functions
return new Proxy(this, {
get: (target, _prop, receiver) => {

File diff suppressed because one or more lines are too long

15
package-lock.json generated

@ -1,15 +1,15 @@
{
"name": "ethers",
"version": "6.0.0-beta-exports.11",
"version": "6.0.0-beta-exports.14",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "ethers",
"version": "6.0.0-beta-exports.11",
"version": "6.0.0-beta-exports.14",
"license": "MIT",
"dependencies": {
"@adraffy/ens-normalize": "^1.8.8",
"@adraffy/ens-normalize": "git@github.com:ricmoo/ens-normalize.js.git",
"@noble/hashes": "1.1.2",
"@noble/secp256k1": "1.6.3",
"aes-js": "4.0.0-beta.3",
@ -33,8 +33,8 @@
},
"node_modules/@adraffy/ens-normalize": {
"version": "1.8.8",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.8.8.tgz",
"integrity": "sha512-QbJczL+zOCNUBkfjCww1DfhL+KNYgC/yCBApqT3d8b9BHg7CFw4O3bTY0BOogiMhw/vGnV2FD17bstxXWn61EA=="
"resolved": "git+ssh://git@github.com/ricmoo/ens-normalize.js.git#b8658d11c63396b605372e0d5d6d88665d5e97eb",
"license": "MIT"
},
"node_modules/@bcoe/v8-coverage": {
"version": "0.2.3",
@ -1565,9 +1565,8 @@
},
"dependencies": {
"@adraffy/ens-normalize": {
"version": "1.8.8",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.8.8.tgz",
"integrity": "sha512-QbJczL+zOCNUBkfjCww1DfhL+KNYgC/yCBApqT3d8b9BHg7CFw4O3bTY0BOogiMhw/vGnV2FD17bstxXWn61EA=="
"version": "git+ssh://git@github.com/ricmoo/ens-normalize.js.git#b8658d11c63396b605372e0d5d6d88665d5e97eb",
"from": "@adraffy/ens-normalize@git@github.com:ricmoo/ens-normalize.js.git"
},
"@bcoe/v8-coverage": {
"version": "0.2.3",

@ -96,7 +96,7 @@
"types": "./types/wordlistsindex.d.ts"
}
},
"gitHead": "f8cd9c9eafc3839849da73b1467f8b4b5133a2fe",
"gitHead": "c3f8e8ac0753cecbca64e602c73139b38fd7f58a",
"keywords": [
"ethereum",
"ethers",

@ -198,7 +198,7 @@ export declare class ParamType {
/**
* The type of a [[Fragment]].
*/
export declare type FragmentType = "constructor" | "error" | "event" | "function" | "struct";
export declare type FragmentType = "constructor" | "error" | "event" | "fallback" | "function" | "struct";
/**
* An abstract class to represent An individual fragment from a parse ABI.
*/
@ -306,6 +306,19 @@ export declare class ConstructorFragment extends Fragment {
static from(obj: any): ConstructorFragment;
static isFragment(value: any): value is ConstructorFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
constructor(guard: any, inputs: ReadonlyArray<ParamType>, payable: boolean);
format(format?: FormatType): string;
static from(obj: any): FallbackFragment;
static isFragment(value: any): value is FallbackFragment;
}
/**
* A Fragment which represents a method.
*/
@ -322,9 +335,9 @@ export declare class FunctionFragment extends NamedFragment {
* The state mutability (e.g. ``payable``, ``nonpayable``, ``view``
* or ``pure``)
*/
readonly stateMutability: string;
readonly stateMutability: "payable" | "nonpayable" | "view" | "pure";
/**
* If the function can be send a value during invocation.
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
/**
@ -334,7 +347,7 @@ export declare class FunctionFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, stateMutability: string, inputs: ReadonlyArray<ParamType>, outputs: ReadonlyArray<ParamType>, gas: null | bigint);
constructor(guard: any, name: string, stateMutability: "payable" | "nonpayable" | "view" | "pure", inputs: ReadonlyArray<ParamType>, outputs: ReadonlyArray<ParamType>, gas: null | bigint);
/**
* The Function selector.
*/

File diff suppressed because one or more lines are too long

@ -6,7 +6,7 @@
*/
export { AbiCoder } from "./abi-coder.js";
export { decodeBytes32String, encodeBytes32String } from "./bytes32.js";
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { checkResultErrors, Indexed, Interface, ErrorDescription, LogDescription, TransactionDescription, Result } from "./interface.js";
export { Typed } from "./typed.js";
export type { JsonFragment, JsonFragmentType, FormatType, FragmentType, ParamTypeWalkAsyncFunc, ParamTypeWalkFunc } from "./fragments.js";

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACH,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAC3D,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,GAC7D,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EACxD,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,YAAY,EACR,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EACtE,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,YAAY,GACf,MAAM,gBAAgB,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACH,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EACnE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,GACvE,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EACxD,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,YAAY,EACR,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EACtE,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,YAAY,GACf,MAAM,gBAAgB,CAAC"}

@ -5,7 +5,7 @@
*/
import { AbiCoder } from "./abi-coder.js";
import { checkResultErrors, Result } from "./coders/abstract-coder.js";
import { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType } from "./fragments.js";
import { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, ParamType } from "./fragments.js";
import { Typed } from "./typed.js";
import type { BigNumberish, BytesLike, CallExceptionError, CallExceptionTransaction } from "../utils/index.js";
import type { JsonFragment } from "./fragments.js";
@ -65,6 +65,14 @@ export declare class Interface {
* The Contract constructor.
*/
readonly deploy: ConstructorFragment;
/**
* The Fallback method, if any.
*/
readonly fallback: null | FallbackFragment;
/**
* If receiving ether is supported.
*/
readonly receive: boolean;
/**
* Create a new Interface for the %%fragments%%.
*/

@ -1 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src.ts/abi/interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1H,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE/G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAA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EAAE,YAAY,CAAA;KAAE,GAAG,IAAI,GAAG,sBAAsB;IAY3F,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAIxC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,GAAG,cAAc;IAa5E;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,gBAAgB;IAWpD;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS;CAe1D"}

@ -4,16 +4,24 @@ import { ContractTransactionResponse, EventLog } from "./wrappers.js";
import type { EventFragment, FunctionFragment, InterfaceAbi, ParamType } from "../abi/index.js";
import type { Addressable } from "../address/index.js";
import type { EventEmitterable, Listener } from "../utils/index.js";
import type { BlockTag, ContractRunner } from "../providers/index.js";
import type { BlockTag, ContractRunner, TransactionRequest } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction } from "./types.js";
/**
* @_ignore:
*/
export declare function copyOverrides(arg: any): Promise<Omit<ContractTransaction, "data" | "to">>;
export declare function copyOverrides<O extends string = "data" | "to">(arg: any, allowed?: Array<string>): Promise<Omit<ContractTransaction, O>>;
/**
* @_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;
export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {
readonly target: string | Addressable;
@ -21,6 +29,7 @@ export declare class BaseContract implements Addressable, EventEmitterable<Contr
readonly runner: null | ContractRunner;
readonly filters: Record<string, ContractEvent>;
readonly [internal]: any;
readonly fallback: null | WrappedFallback;
constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse);
connect(runner: null | ContractRunner): BaseContract;
getAddress(): Promise<string>;

@ -1 +1 @@
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src.ts/contract/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,iBAAiB,CAAC;AAInD,OAAO,EAAe,GAAG,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAMjF,OAAO,EAEH,2BAA2B,EAC3B,QAAQ,EACX,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAU,MAAM,iBAAiB,CAAC;AACxG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EACR,QAAQ,EAAE,cAAc,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACR,iBAAiB,EACjB,iBAAiB,EAGjB,cAAc,EAEd,aAAa,EACb,mBAAmB,EAEtB,MAAM,YAAY,CAAC;AA+FpB;;GAEG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAmB/F;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,IAAI,GAAG,cAAc,EAAE,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,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