web3-eth-contract
Advanced tools
Comparing version 4.4.1-dev.e29deea.0 to 4.4.1-dev.ebbbf1e.0
@@ -16,4 +16,4 @@ import { Web3Context, Web3EventEmitter, Web3PromiEvent } from 'web3-core'; | ||
}; | ||
export declare type ContractMethodSend = Web3PromiEvent<FormatType<TransactionReceipt, typeof DEFAULT_RETURN_FORMAT>, SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>>; | ||
export declare type ContractDeploySend<Abi extends ContractAbi> = Web3PromiEvent<Contract<Abi>, SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>>; | ||
export declare type ContractMethodSend = Web3PromiEvent<FormatType<TransactionReceipt, DataFormat>, SendTransactionEvents<DataFormat>>; | ||
export declare type ContractDeploySend<Abi extends ContractAbi> = Web3PromiEvent<Contract<Abi>, SendTransactionEvents<DataFormat>>; | ||
/** | ||
@@ -20,0 +20,0 @@ * @hidden |
@@ -260,3 +260,4 @@ "use strict"; | ||
let provider; | ||
if (typeof addressOrOptionsOrContext === 'object' && 'provider' in addressOrOptionsOrContext) { | ||
if (typeof addressOrOptionsOrContext === 'object' && | ||
'provider' in addressOrOptionsOrContext) { | ||
provider = addressOrOptionsOrContext.provider; | ||
@@ -268,3 +269,4 @@ } | ||
} | ||
else if (typeof contextOrReturnFormat === 'object' && 'provider' in contextOrReturnFormat) { | ||
else if (typeof contextOrReturnFormat === 'object' && | ||
'provider' in contextOrReturnFormat) { | ||
provider = contextOrReturnFormat.provider; | ||
@@ -302,3 +304,3 @@ } | ||
? optionsOrContextOrReturnFormat | ||
: returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3_types_1.DEFAULT_RETURN_FORMAT; | ||
: returnFormat !== null && returnFormat !== void 0 ? returnFormat : this.defaultReturnFormat; | ||
const address = typeof addressOrOptionsOrContext === 'string' ? addressOrOptionsOrContext : undefined; | ||
@@ -308,2 +310,5 @@ this.config.contractDataInputFill = | ||
this._parseAndSetJsonInterface(jsonInterface, returnDataFormat); | ||
if (this.defaultReturnFormat !== returnDataFormat) { | ||
this.defaultReturnFormat = returnDataFormat; | ||
} | ||
if (!(0, web3_validator_1.isNullish)(address)) { | ||
@@ -545,3 +550,3 @@ this._parseAndSetAddress(address, returnDataFormat); | ||
}, | ||
estimateGas: (options, returnFormat = web3_types_1.DEFAULT_RETURN_FORMAT) => __awaiter(this, void 0, void 0, function* () { | ||
estimateGas: (options, returnFormat = this.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () { | ||
const modifiedOptions = Object.assign({}, options); | ||
@@ -556,3 +561,3 @@ return this._contractMethodEstimateGas({ | ||
}), | ||
encodeABI: () => (0, encoding_js_1.encodeMethodABI)(abi, args, (0, web3_utils_1.format)({ format: 'bytes' }, deployData, web3_types_1.DEFAULT_RETURN_FORMAT)), | ||
encodeABI: () => (0, encoding_js_1.encodeMethodABI)(abi, args, (0, web3_utils_1.format)({ format: 'bytes' }, deployData, this.defaultReturnFormat)), | ||
decodeData: (data) => (Object.assign(Object.assign({}, (0, encoding_js_1.decodeMethodParams)(abi, data.replace(deployData, ''), false)), { __method__: abi.type })), | ||
@@ -577,3 +582,3 @@ }; | ||
? param2 | ||
: param3 !== null && param3 !== void 0 ? param3 : web3_types_1.DEFAULT_RETURN_FORMAT; | ||
: param3 !== null && param3 !== void 0 ? param3 : this.defaultReturnFormat; | ||
const abi = eventName === 'allEvents' || eventName === web3_eth_1.ALL_EVENTS | ||
@@ -601,3 +606,4 @@ ? web3_eth_1.ALL_EVENTS_ABI | ||
if (Array.isArray(filter[key])) { | ||
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() === String(v).toUpperCase()); | ||
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() === | ||
String(v).toUpperCase()); | ||
} | ||
@@ -610,3 +616,4 @@ const inputAbi = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.filter(input => input.name === key)[0]; | ||
} | ||
return String(log.returnValues[key]).toUpperCase() === String(filter[key]).toUpperCase(); | ||
return (String(log.returnValues[key]).toUpperCase() === | ||
String(filter[key]).toUpperCase()); | ||
}); | ||
@@ -618,3 +625,3 @@ }); | ||
} | ||
_parseAndSetAddress(value, returnFormat = web3_types_1.DEFAULT_RETURN_FORMAT) { | ||
_parseAndSetAddress(value, returnFormat = this.defaultReturnFormat) { | ||
this._address = value | ||
@@ -633,3 +640,3 @@ ? (0, web3_utils_1.toChecksumAddress)((0, web3_utils_1.format)({ format: 'address' }, value, returnFormat)) | ||
} | ||
_parseAndSetJsonInterface(abis, returnFormat = web3_types_1.DEFAULT_RETURN_FORMAT) { | ||
_parseAndSetJsonInterface(abis, returnFormat = this.defaultReturnFormat) { | ||
var _a, _b, _c, _d, _e; | ||
@@ -665,3 +672,4 @@ this._functions = {}; | ||
// We don't know a particular type of the Abi method so can't type check | ||
this._methods[abi.name] = contractMethod; | ||
this._methods[abi.name] = | ||
contractMethod; | ||
// We don't know a particular type of the Abi method so can't type check | ||
@@ -752,5 +760,8 @@ this._methods[methodName] = | ||
arguments: abiParams, | ||
call: (options, block) => __awaiter(this, void 0, void 0, function* () { return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block); }), | ||
call: (options, block) => __awaiter(this, void 0, void 0, function* () { | ||
return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block); | ||
}), | ||
send: (options) => this._contractMethodSend(methodAbi, abiParams, internalErrorsAbis, options), | ||
estimateGas: (options, returnFormat = web3_types_1.DEFAULT_RETURN_FORMAT) => __awaiter(this, void 0, void 0, function* () { | ||
estimateGas: (options, returnFormat = this | ||
.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () { | ||
return this._contractMethodEstimateGas({ | ||
@@ -785,3 +796,3 @@ abi: methodAbi, | ||
try { | ||
const result = yield (0, web3_eth_1.call)(this, tx, block, web3_types_1.DEFAULT_RETURN_FORMAT); | ||
const result = yield (0, web3_eth_1.call)(this, tx, block, this.defaultReturnFormat); | ||
return (0, encoding_js_1.decodeMethodReturn)(abi, result); | ||
@@ -808,3 +819,3 @@ } | ||
try { | ||
return (0, web3_eth_1.createAccessList)(this, tx, block, web3_types_1.DEFAULT_RETURN_FORMAT); | ||
return (0, web3_eth_1.createAccessList)(this, tx, block, this.defaultReturnFormat); | ||
} | ||
@@ -830,3 +841,3 @@ catch (error) { | ||
}); | ||
const transactionToSend = (0, web3_eth_1.sendTransaction)(this, tx, web3_types_1.DEFAULT_RETURN_FORMAT, { | ||
const transactionToSend = (0, web3_eth_1.sendTransaction)(this, tx, this.defaultReturnFormat, { | ||
// TODO Should make this configurable by the user | ||
@@ -852,6 +863,6 @@ checkRevertBeforeSending: false, | ||
params, | ||
options: Object.assign(Object.assign({}, options), { dataInputFill: this.config.contractDataInputFill }), | ||
options: Object.assign(Object.assign({}, options), { dataInputFill: this.contractDataInputFill }), | ||
contractOptions: modifiedContractOptions, | ||
}); | ||
return (0, web3_eth_1.sendTransaction)(this, tx, web3_types_1.DEFAULT_RETURN_FORMAT, { | ||
return (0, web3_eth_1.sendTransaction)(this, tx, this.defaultReturnFormat, { | ||
transactionResolver: receipt => { | ||
@@ -879,7 +890,7 @@ if (receipt.status === BigInt(0)) { | ||
}); | ||
return (0, web3_eth_1.estimateGas)(this, tx, web3_types_1.BlockTags.LATEST, returnFormat); | ||
return (0, web3_eth_1.estimateGas)(this, tx, web3_types_1.BlockTags.LATEST, returnFormat !== null && returnFormat !== void 0 ? returnFormat : this.defaultReturnFormat); | ||
}); | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
_createContractEvent(abi, returnFormat = web3_types_1.DEFAULT_RETURN_FORMAT) { | ||
_createContractEvent(abi, returnFormat = this.defaultReturnFormat) { | ||
return (...params) => { | ||
@@ -886,0 +897,0 @@ var _a; |
@@ -257,3 +257,4 @@ /* | ||
let provider; | ||
if (typeof addressOrOptionsOrContext === 'object' && 'provider' in addressOrOptionsOrContext) { | ||
if (typeof addressOrOptionsOrContext === 'object' && | ||
'provider' in addressOrOptionsOrContext) { | ||
provider = addressOrOptionsOrContext.provider; | ||
@@ -265,3 +266,4 @@ } | ||
} | ||
else if (typeof contextOrReturnFormat === 'object' && 'provider' in contextOrReturnFormat) { | ||
else if (typeof contextOrReturnFormat === 'object' && | ||
'provider' in contextOrReturnFormat) { | ||
provider = contextOrReturnFormat.provider; | ||
@@ -299,3 +301,3 @@ } | ||
? optionsOrContextOrReturnFormat | ||
: returnFormat !== null && returnFormat !== void 0 ? returnFormat : DEFAULT_RETURN_FORMAT; | ||
: returnFormat !== null && returnFormat !== void 0 ? returnFormat : this.defaultReturnFormat; | ||
const address = typeof addressOrOptionsOrContext === 'string' ? addressOrOptionsOrContext : undefined; | ||
@@ -305,2 +307,5 @@ this.config.contractDataInputFill = | ||
this._parseAndSetJsonInterface(jsonInterface, returnDataFormat); | ||
if (this.defaultReturnFormat !== returnDataFormat) { | ||
this.defaultReturnFormat = returnDataFormat; | ||
} | ||
if (!isNullish(address)) { | ||
@@ -542,3 +547,3 @@ this._parseAndSetAddress(address, returnDataFormat); | ||
}, | ||
estimateGas: (options, returnFormat = DEFAULT_RETURN_FORMAT) => __awaiter(this, void 0, void 0, function* () { | ||
estimateGas: (options, returnFormat = this.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () { | ||
const modifiedOptions = Object.assign({}, options); | ||
@@ -553,3 +558,3 @@ return this._contractMethodEstimateGas({ | ||
}), | ||
encodeABI: () => encodeMethodABI(abi, args, format({ format: 'bytes' }, deployData, DEFAULT_RETURN_FORMAT)), | ||
encodeABI: () => encodeMethodABI(abi, args, format({ format: 'bytes' }, deployData, this.defaultReturnFormat)), | ||
decodeData: (data) => (Object.assign(Object.assign({}, decodeMethodParams(abi, data.replace(deployData, ''), false)), { __method__: abi.type })), | ||
@@ -574,3 +579,3 @@ }; | ||
? param2 | ||
: param3 !== null && param3 !== void 0 ? param3 : DEFAULT_RETURN_FORMAT; | ||
: param3 !== null && param3 !== void 0 ? param3 : this.defaultReturnFormat; | ||
const abi = eventName === 'allEvents' || eventName === ALL_EVENTS | ||
@@ -598,3 +603,4 @@ ? ALL_EVENTS_ABI | ||
if (Array.isArray(filter[key])) { | ||
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() === String(v).toUpperCase()); | ||
return filter[key].some((v) => String(log.returnValues[key]).toUpperCase() === | ||
String(v).toUpperCase()); | ||
} | ||
@@ -607,3 +613,4 @@ const inputAbi = (_a = abi.inputs) === null || _a === void 0 ? void 0 : _a.filter(input => input.name === key)[0]; | ||
} | ||
return String(log.returnValues[key]).toUpperCase() === String(filter[key]).toUpperCase(); | ||
return (String(log.returnValues[key]).toUpperCase() === | ||
String(filter[key]).toUpperCase()); | ||
}); | ||
@@ -615,3 +622,3 @@ }); | ||
} | ||
_parseAndSetAddress(value, returnFormat = DEFAULT_RETURN_FORMAT) { | ||
_parseAndSetAddress(value, returnFormat = this.defaultReturnFormat) { | ||
this._address = value | ||
@@ -630,3 +637,3 @@ ? toChecksumAddress(format({ format: 'address' }, value, returnFormat)) | ||
} | ||
_parseAndSetJsonInterface(abis, returnFormat = DEFAULT_RETURN_FORMAT) { | ||
_parseAndSetJsonInterface(abis, returnFormat = this.defaultReturnFormat) { | ||
var _a, _b, _c, _d, _e; | ||
@@ -662,3 +669,4 @@ this._functions = {}; | ||
// We don't know a particular type of the Abi method so can't type check | ||
this._methods[abi.name] = contractMethod; | ||
this._methods[abi.name] = | ||
contractMethod; | ||
// We don't know a particular type of the Abi method so can't type check | ||
@@ -749,5 +757,8 @@ this._methods[methodName] = | ||
arguments: abiParams, | ||
call: (options, block) => __awaiter(this, void 0, void 0, function* () { return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block); }), | ||
call: (options, block) => __awaiter(this, void 0, void 0, function* () { | ||
return this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block); | ||
}), | ||
send: (options) => this._contractMethodSend(methodAbi, abiParams, internalErrorsAbis, options), | ||
estimateGas: (options, returnFormat = DEFAULT_RETURN_FORMAT) => __awaiter(this, void 0, void 0, function* () { | ||
estimateGas: (options, returnFormat = this | ||
.defaultReturnFormat) => __awaiter(this, void 0, void 0, function* () { | ||
return this._contractMethodEstimateGas({ | ||
@@ -782,3 +793,3 @@ abi: methodAbi, | ||
try { | ||
const result = yield call(this, tx, block, DEFAULT_RETURN_FORMAT); | ||
const result = yield call(this, tx, block, this.defaultReturnFormat); | ||
return decodeMethodReturn(abi, result); | ||
@@ -805,3 +816,3 @@ } | ||
try { | ||
return createAccessList(this, tx, block, DEFAULT_RETURN_FORMAT); | ||
return createAccessList(this, tx, block, this.defaultReturnFormat); | ||
} | ||
@@ -827,3 +838,3 @@ catch (error) { | ||
}); | ||
const transactionToSend = sendTransaction(this, tx, DEFAULT_RETURN_FORMAT, { | ||
const transactionToSend = sendTransaction(this, tx, this.defaultReturnFormat, { | ||
// TODO Should make this configurable by the user | ||
@@ -849,6 +860,6 @@ checkRevertBeforeSending: false, | ||
params, | ||
options: Object.assign(Object.assign({}, options), { dataInputFill: this.config.contractDataInputFill }), | ||
options: Object.assign(Object.assign({}, options), { dataInputFill: this.contractDataInputFill }), | ||
contractOptions: modifiedContractOptions, | ||
}); | ||
return sendTransaction(this, tx, DEFAULT_RETURN_FORMAT, { | ||
return sendTransaction(this, tx, this.defaultReturnFormat, { | ||
transactionResolver: receipt => { | ||
@@ -876,7 +887,7 @@ if (receipt.status === BigInt(0)) { | ||
}); | ||
return estimateGas(this, tx, BlockTags.LATEST, returnFormat); | ||
return estimateGas(this, tx, BlockTags.LATEST, returnFormat !== null && returnFormat !== void 0 ? returnFormat : this.defaultReturnFormat); | ||
}); | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
_createContractEvent(abi, returnFormat = DEFAULT_RETURN_FORMAT) { | ||
_createContractEvent(abi, returnFormat = this.defaultReturnFormat) { | ||
return (...params) => { | ||
@@ -883,0 +894,0 @@ var _a; |
@@ -16,4 +16,4 @@ import { Web3Context, Web3EventEmitter, Web3PromiEvent } from 'web3-core'; | ||
}; | ||
export declare type ContractMethodSend = Web3PromiEvent<FormatType<TransactionReceipt, typeof DEFAULT_RETURN_FORMAT>, SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>>; | ||
export declare type ContractDeploySend<Abi extends ContractAbi> = Web3PromiEvent<Contract<Abi>, SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT>>; | ||
export declare type ContractMethodSend = Web3PromiEvent<FormatType<TransactionReceipt, DataFormat>, SendTransactionEvents<DataFormat>>; | ||
export declare type ContractDeploySend<Abi extends ContractAbi> = Web3PromiEvent<Contract<Abi>, SendTransactionEvents<DataFormat>>; | ||
/** | ||
@@ -20,0 +20,0 @@ * @hidden |
{ | ||
"name": "web3-eth-contract", | ||
"version": "4.4.1-dev.e29deea.0+e29deea", | ||
"version": "4.4.1-dev.ebbbf1e.0+ebbbf1e", | ||
"description": "Web3 module to interact with Ethereum smart contracts.", | ||
@@ -48,9 +48,9 @@ "main": "./lib/commonjs/index.js", | ||
"dependencies": { | ||
"web3-core": "4.3.3-dev.e29deea.0+e29deea", | ||
"web3-errors": "1.1.5-dev.e29deea.0+e29deea", | ||
"web3-eth": "4.6.1-dev.e29deea.0+e29deea", | ||
"web3-eth-abi": "4.2.2-dev.e29deea.0+e29deea", | ||
"web3-types": "1.6.1-dev.e29deea.0+e29deea", | ||
"web3-utils": "4.2.4-dev.e29deea.0+e29deea", | ||
"web3-validator": "2.0.6-dev.e29deea.0+e29deea" | ||
"web3-core": "4.3.3-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-errors": "1.1.5-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-eth": "4.6.1-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-eth-abi": "4.2.2-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-types": "1.6.1-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-utils": "4.2.4-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-validator": "2.0.6-dev.ebbbf1e.0+ebbbf1e" | ||
}, | ||
@@ -72,6 +72,6 @@ "devDependencies": { | ||
"typescript": "^4.7.4", | ||
"web3-eth-accounts": "4.1.3-dev.e29deea.0+e29deea", | ||
"web3-providers-ws": "4.0.8-dev.e29deea.0+e29deea" | ||
"web3-eth-accounts": "4.1.3-dev.ebbbf1e.0+ebbbf1e", | ||
"web3-providers-ws": "4.0.8-dev.ebbbf1e.0+ebbbf1e" | ||
}, | ||
"gitHead": "e29deeac2bb9705d70c839cd825bc34a93cde1b6" | ||
"gitHead": "ebbbf1e8bb2562708f89de431fc630ea7d665624" | ||
} |
@@ -166,4 +166,4 @@ /* | ||
export type ContractMethodSend = Web3PromiEvent< | ||
FormatType<TransactionReceipt, typeof DEFAULT_RETURN_FORMAT>, | ||
SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT> | ||
FormatType<TransactionReceipt, DataFormat>, | ||
SendTransactionEvents<DataFormat> | ||
>; | ||
@@ -173,3 +173,3 @@ export type ContractDeploySend<Abi extends ContractAbi> = Web3PromiEvent< | ||
Contract<Abi>, | ||
SendTransactionEvents<typeof DEFAULT_RETURN_FORMAT> | ||
SendTransactionEvents<DataFormat> | ||
>; | ||
@@ -339,9 +339,9 @@ | ||
* It's particularly useful for debugging and understanding the interactions with and between smart contracts. | ||
* | ||
* | ||
* #### Parameters | ||
* | ||
* | ||
* - `data` **HexString**: The string of ABI-encoded data that needs to be decoded. This should include the method signature and the encoded parameters. | ||
* | ||
* | ||
* #### Returns | ||
* | ||
* | ||
* - **Object**: This object combines both the decoded parameters and the method name in a readable format. Specifically, the returned object contains: | ||
@@ -351,9 +351,9 @@ * - `__method__` **String**: The name of the contract method, reconstructed from the ABI. | ||
* - Additional properties representing each parameter by name, as well as their position and values. | ||
* | ||
* | ||
* #### Example | ||
* | ||
* | ||
* Given an ABI-encoded string from a transaction, you can decode this data to identify the method called and the parameters passed. | ||
* Here's a simplified example: | ||
* | ||
* | ||
* | ||
* | ||
* ```typescript | ||
@@ -375,7 +375,7 @@ * const GreeterAbi = [ | ||
* const contract = new Contract(GreeterAbi); // Initialize with your contract's ABI | ||
* | ||
* | ||
* // The ABI-encoded data string for "setGreeting('Hello World')" | ||
* const encodedData = | ||
* '0xa41368620000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b48656c6c6f20576f726c64000000000000000000000000000000000000000000'; | ||
* | ||
* | ||
* try { | ||
@@ -396,3 +396,3 @@ * const decoded = contract.decodeMethodData(encodedData); | ||
* ``` | ||
* | ||
* | ||
@@ -522,3 +522,7 @@ * ### createAccessList | ||
jsonInterface: Abi, | ||
addressOrOptionsOrContext?: Address | ContractInitOptions | Web3ContractContext | Web3Context, | ||
addressOrOptionsOrContext?: | ||
| Address | ||
| ContractInitOptions | ||
| Web3ContractContext | ||
| Web3Context, | ||
optionsOrContextOrReturnFormat?: | ||
@@ -549,3 +553,6 @@ | ContractInitOptions | ||
let provider; | ||
if (typeof addressOrOptionsOrContext === 'object' && 'provider' in addressOrOptionsOrContext) { | ||
if ( | ||
typeof addressOrOptionsOrContext === 'object' && | ||
'provider' in addressOrOptionsOrContext | ||
) { | ||
provider = addressOrOptionsOrContext.provider; | ||
@@ -557,3 +564,6 @@ } else if ( | ||
provider = optionsOrContextOrReturnFormat.provider; | ||
} else if (typeof contextOrReturnFormat === 'object' && 'provider' in contextOrReturnFormat) { | ||
} else if ( | ||
typeof contextOrReturnFormat === 'object' && | ||
'provider' in contextOrReturnFormat | ||
) { | ||
provider = contextOrReturnFormat.provider; | ||
@@ -595,3 +605,3 @@ } else { | ||
? optionsOrContextOrReturnFormat | ||
: returnFormat ?? DEFAULT_RETURN_FORMAT; | ||
: returnFormat ?? this.defaultReturnFormat; | ||
const address = | ||
@@ -603,2 +613,6 @@ typeof addressOrOptionsOrContext === 'string' ? addressOrOptionsOrContext : undefined; | ||
if (this.defaultReturnFormat !== returnDataFormat) { | ||
this.defaultReturnFormat = returnDataFormat; | ||
} | ||
if (!isNullish(address)) { | ||
@@ -886,3 +900,3 @@ this._parseAndSetAddress(address, returnDataFormat); | ||
options?: PayableCallOptions, | ||
returnFormat: ReturnFormat = DEFAULT_RETURN_FORMAT as ReturnFormat, | ||
returnFormat: ReturnFormat = this.defaultReturnFormat as ReturnFormat, | ||
) => { | ||
@@ -902,3 +916,7 @@ const modifiedOptions = { ...options }; | ||
args as unknown[], | ||
format({ format: 'bytes' }, deployData as Bytes, DEFAULT_RETURN_FORMAT), | ||
format( | ||
{ format: 'bytes' }, | ||
deployData as Bytes, | ||
this.defaultReturnFormat as typeof DEFAULT_RETURN_FORMAT, | ||
), | ||
), | ||
@@ -995,3 +1013,3 @@ decodeData: (data: HexString) => ({ | ||
? param2 | ||
: param3 ?? DEFAULT_RETURN_FORMAT; | ||
: param3 ?? this.defaultReturnFormat; | ||
@@ -1035,3 +1053,4 @@ const abi = | ||
(v: Numbers) => | ||
String(log.returnValues[key]).toUpperCase() === String(v).toUpperCase(), | ||
String(log.returnValues[key]).toUpperCase() === | ||
String(v).toUpperCase(), | ||
); | ||
@@ -1046,3 +1065,6 @@ } | ||
return String(log.returnValues[key]).toUpperCase() === String(filter[key]).toUpperCase(); | ||
return ( | ||
String(log.returnValues[key]).toUpperCase() === | ||
String(filter[key]).toUpperCase() | ||
); | ||
}); | ||
@@ -1055,3 +1077,6 @@ }); | ||
private _parseAndSetAddress(value?: Address, returnFormat: DataFormat = DEFAULT_RETURN_FORMAT) { | ||
private _parseAndSetAddress( | ||
value?: Address, | ||
returnFormat: DataFormat = this.defaultReturnFormat, | ||
) { | ||
this._address = value | ||
@@ -1079,3 +1104,3 @@ ? toChecksumAddress(format({ format: 'address' }, value, returnFormat)) | ||
abis: ContractAbi, | ||
returnFormat: DataFormat = DEFAULT_RETURN_FORMAT, | ||
returnFormat: DataFormat = this.defaultReturnFormat, | ||
) { | ||
@@ -1089,3 +1114,5 @@ this._functions = {}; | ||
const functionsAbi = abis.filter(abi => abi.type !== 'error'); | ||
const errorsAbi = abis.filter(abi => isAbiErrorFragment(abi)) as unknown as AbiErrorFragment[]; | ||
const errorsAbi = abis.filter(abi => | ||
isAbiErrorFragment(abi), | ||
) as unknown as AbiErrorFragment[]; | ||
@@ -1106,3 +1133,5 @@ for (const a of functionsAbi) { | ||
abi.constant = | ||
abi.stateMutability === 'view' ?? abi.stateMutability === 'pure' ?? abi.constant; | ||
abi.stateMutability === 'view' ?? | ||
abi.stateMutability === 'pure' ?? | ||
abi.constant; | ||
@@ -1115,6 +1144,6 @@ abi.payable = abi.stateMutability === 'payable' ?? abi.payable; | ||
const abiFragment = this._overloadedMethodAbis.get(abi.name) ?? []; | ||
const contractMethod = this._createContractMethod<typeof abiFragment, AbiErrorFragment>( | ||
abiFragment, | ||
errorsAbi, | ||
); | ||
const contractMethod = this._createContractMethod< | ||
typeof abiFragment, | ||
AbiErrorFragment | ||
>(abiFragment, errorsAbi); | ||
@@ -1132,3 +1161,4 @@ const exactContractMethod = this._createContractMethod< | ||
// We don't know a particular type of the Abi method so can't type check | ||
this._methods[abi.name as keyof ContractMethodsInterface<Abi>] = contractMethod as never; | ||
this._methods[abi.name as keyof ContractMethodsInterface<Abi>] = | ||
contractMethod as never; | ||
@@ -1209,3 +1239,6 @@ // We don't know a particular type of the Abi method so can't type check | ||
abiParams = this._getAbiParams(_abi, params); | ||
validator.validate(_abi.inputs as unknown as ValidationSchemaInput, abiParams); | ||
validator.validate( | ||
_abi.inputs as unknown as ValidationSchemaInput, | ||
abiParams, | ||
); | ||
applicableMethodAbi.push(_abi); | ||
@@ -1226,5 +1259,5 @@ } catch (e) { | ||
m => | ||
`${(m as { methodNameWithInputs: string }).methodNameWithInputs} (signature: ${ | ||
(m as { signature: string }).signature | ||
})`, | ||
`${ | ||
(m as { methodNameWithInputs: string }).methodNameWithInputs | ||
} (signature: ${(m as { signature: string }).signature})`, | ||
), | ||
@@ -1251,3 +1284,10 @@ )} \n\tThe first one will be used: ${ | ||
block?: BlockNumberOrTag, | ||
) => this._contractMethodCall(methodAbi, abiParams, internalErrorsAbis, options, block), | ||
) => | ||
this._contractMethodCall( | ||
methodAbi, | ||
abiParams, | ||
internalErrorsAbis, | ||
options, | ||
block, | ||
), | ||
@@ -1259,3 +1299,4 @@ send: (options?: PayableTxOptions | NonPayableTxOptions): ContractMethodSend => | ||
options?: PayableCallOptions | NonPayableCallOptions, | ||
returnFormat: ReturnFormat = DEFAULT_RETURN_FORMAT as ReturnFormat, | ||
returnFormat: ReturnFormat = this | ||
.defaultReturnFormat as unknown as ReturnFormat, | ||
) => | ||
@@ -1318,3 +1359,8 @@ this._contractMethodEstimateGas({ | ||
try { | ||
const result = await call(this, tx, block, DEFAULT_RETURN_FORMAT); | ||
const result = await call( | ||
this, | ||
tx, | ||
block, | ||
this.defaultReturnFormat as typeof DEFAULT_RETURN_FORMAT, | ||
); | ||
return decodeMethodReturn(abi, result); | ||
@@ -1350,3 +1396,3 @@ } catch (error: unknown) { | ||
try { | ||
return createAccessList(this, tx, block, DEFAULT_RETURN_FORMAT); | ||
return createAccessList(this, tx, block, this.defaultReturnFormat); | ||
} catch (error: unknown) { | ||
@@ -1381,3 +1427,3 @@ if (error instanceof ContractExecutionError) { | ||
const transactionToSend = sendTransaction(this, tx, DEFAULT_RETURN_FORMAT, { | ||
const transactionToSend = sendTransaction(this, tx, this.defaultReturnFormat, { | ||
// TODO Should make this configurable by the user | ||
@@ -1412,6 +1458,6 @@ checkRevertBeforeSending: false, | ||
params, | ||
options: { ...options, dataInputFill: this.config.contractDataInputFill }, | ||
options: { ...options, dataInputFill: this.contractDataInputFill }, | ||
contractOptions: modifiedContractOptions, | ||
}); | ||
return sendTransaction(this, tx, DEFAULT_RETURN_FORMAT, { | ||
return sendTransaction(this, tx, this.defaultReturnFormat, { | ||
transactionResolver: receipt => { | ||
@@ -1456,3 +1502,3 @@ if (receipt.status === BigInt(0)) { | ||
}); | ||
return estimateGas(this, tx, BlockTags.LATEST, returnFormat); | ||
return estimateGas(this, tx, BlockTags.LATEST, returnFormat ?? this.defaultReturnFormat); | ||
} | ||
@@ -1463,6 +1509,10 @@ | ||
abi: AbiEventFragment & { signature: HexString }, | ||
returnFormat: DataFormat = DEFAULT_RETURN_FORMAT, | ||
returnFormat: DataFormat = this.defaultReturnFormat, | ||
): ContractBoundEvent { | ||
return (...params: unknown[]) => { | ||
const { topics, fromBlock } = encodeEventABI(this.options, abi, params[0] as EventParameters); | ||
const { topics, fromBlock } = encodeEventABI( | ||
this.options, | ||
abi, | ||
params[0] as EventParameters, | ||
); | ||
const sub = new LogsSubscription( | ||
@@ -1477,3 +1527,6 @@ { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
subscriptionManager: this.subscriptionManager as Web3SubscriptionManager<unknown, any>, | ||
subscriptionManager: this.subscriptionManager as Web3SubscriptionManager< | ||
unknown, | ||
any | ||
>, | ||
returnFormat, | ||
@@ -1491,3 +1544,6 @@ }, | ||
.catch((error: Error) => { | ||
sub.emit('error', new SubscriptionError('Failed to get past events.', error)); | ||
sub.emit( | ||
'error', | ||
new SubscriptionError('Failed to get past events.', error), | ||
); | ||
}); | ||
@@ -1494,0 +1550,0 @@ } |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
399259
7365