2022-09-05 23:57:11 +03:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2022-11-09 10:57:02 +03:00
|
|
|
exports.ContractEventPayload = exports.ContractUnknownEventPayload = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.EventLog = void 0;
|
2022-12-04 01:01:29 +03:00
|
|
|
// import from provider.ts instead of index.ts to prevent circular dep
|
|
|
|
// from EtherscanProvider
|
|
|
|
const provider_js_1 = require("../providers/provider.js");
|
|
|
|
const index_js_1 = require("../utils/index.js");
|
|
|
|
class EventLog extends provider_js_1.Log {
|
2022-09-05 23:57:11 +03:00
|
|
|
interface;
|
|
|
|
fragment;
|
|
|
|
args;
|
|
|
|
constructor(log, iface, fragment) {
|
|
|
|
super(log, log.provider);
|
|
|
|
const args = iface.decodeEventLog(fragment, log.data, log.topics);
|
2022-12-04 01:01:29 +03:00
|
|
|
(0, index_js_1.defineProperties)(this, { args, fragment, interface: iface });
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
get eventName() { return this.fragment.name; }
|
|
|
|
get eventSignature() { return this.fragment.format(); }
|
|
|
|
}
|
|
|
|
exports.EventLog = EventLog;
|
2022-12-04 01:01:29 +03:00
|
|
|
class ContractTransactionReceipt extends provider_js_1.TransactionReceipt {
|
2023-03-20 19:53:37 +03:00
|
|
|
#iface;
|
2022-09-05 23:57:11 +03:00
|
|
|
constructor(iface, provider, tx) {
|
|
|
|
super(tx, provider);
|
2023-03-20 19:53:37 +03:00
|
|
|
this.#iface = iface;
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
get logs() {
|
|
|
|
return super.logs.map((log) => {
|
2023-03-20 19:53:37 +03:00
|
|
|
const fragment = log.topics.length ? this.#iface.getEvent(log.topics[0]) : null;
|
2022-09-05 23:57:11 +03:00
|
|
|
if (fragment) {
|
2023-03-20 19:53:37 +03:00
|
|
|
return new EventLog(log, this.#iface, fragment);
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return log;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.ContractTransactionReceipt = ContractTransactionReceipt;
|
2022-12-04 01:01:29 +03:00
|
|
|
class ContractTransactionResponse extends provider_js_1.TransactionResponse {
|
2023-03-20 19:53:37 +03:00
|
|
|
#iface;
|
2022-09-05 23:57:11 +03:00
|
|
|
constructor(iface, provider, tx) {
|
|
|
|
super(tx, provider);
|
2023-03-20 19:53:37 +03:00
|
|
|
this.#iface = iface;
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
async wait(confirms) {
|
|
|
|
const receipt = await super.wait();
|
|
|
|
if (receipt == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2023-03-20 19:53:37 +03:00
|
|
|
return new ContractTransactionReceipt(this.#iface, this.provider, receipt);
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.ContractTransactionResponse = ContractTransactionResponse;
|
2022-12-04 01:01:29 +03:00
|
|
|
class ContractUnknownEventPayload extends index_js_1.EventPayload {
|
2022-09-05 23:57:11 +03:00
|
|
|
log;
|
2022-11-09 10:57:02 +03:00
|
|
|
constructor(contract, listener, filter, log) {
|
2022-09-05 23:57:11 +03:00
|
|
|
super(contract, listener, filter);
|
2022-12-04 01:01:29 +03:00
|
|
|
(0, index_js_1.defineProperties)(this, { log });
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
async getBlock() {
|
|
|
|
return await this.log.getBlock();
|
|
|
|
}
|
|
|
|
async getTransaction() {
|
|
|
|
return await this.log.getTransaction();
|
|
|
|
}
|
|
|
|
async getTransactionReceipt() {
|
|
|
|
return await this.log.getTransactionReceipt();
|
|
|
|
}
|
|
|
|
}
|
2022-11-09 10:57:02 +03:00
|
|
|
exports.ContractUnknownEventPayload = ContractUnknownEventPayload;
|
|
|
|
class ContractEventPayload extends ContractUnknownEventPayload {
|
|
|
|
constructor(contract, listener, filter, fragment, _log) {
|
|
|
|
super(contract, listener, filter, new EventLog(_log, contract.interface, fragment));
|
|
|
|
const args = contract.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
|
2022-12-04 01:01:29 +03:00
|
|
|
(0, index_js_1.defineProperties)(this, { args, fragment });
|
2022-11-09 10:57:02 +03:00
|
|
|
}
|
|
|
|
get eventName() {
|
|
|
|
return this.fragment.name;
|
|
|
|
}
|
|
|
|
get eventSignature() {
|
|
|
|
return this.fragment.format();
|
|
|
|
}
|
|
|
|
}
|
2022-09-05 23:57:11 +03:00
|
|
|
exports.ContractEventPayload = ContractEventPayload;
|
|
|
|
//# sourceMappingURL=wrappers.js.map
|