2022-12-04 01:01:29 +03:00
|
|
|
// import from provider.ts instead of index.ts to prevent circular dep
|
|
|
|
// from EtherscanProvider
|
|
|
|
import { Log, TransactionReceipt, TransactionResponse } from "../providers/provider.js";
|
2022-09-05 23:57:11 +03:00
|
|
|
import { defineProperties, EventPayload } from "../utils/index.js";
|
|
|
|
export class EventLog extends Log {
|
|
|
|
interface;
|
|
|
|
fragment;
|
|
|
|
args;
|
|
|
|
constructor(log, iface, fragment) {
|
|
|
|
super(log, log.provider);
|
|
|
|
const args = iface.decodeEventLog(fragment, log.data, log.topics);
|
|
|
|
defineProperties(this, { args, fragment, interface: iface });
|
|
|
|
}
|
|
|
|
get eventName() { return this.fragment.name; }
|
|
|
|
get eventSignature() { return this.fragment.format(); }
|
|
|
|
}
|
|
|
|
export class ContractTransactionReceipt extends 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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export class ContractTransactionResponse extends 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
|
|
|
}
|
|
|
|
}
|
2022-11-09 10:57:02 +03:00
|
|
|
export class ContractUnknownEventPayload extends 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-11-09 10:57:02 +03:00
|
|
|
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
|
|
|
export 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);
|
|
|
|
defineProperties(this, { args, fragment });
|
|
|
|
}
|
|
|
|
get eventName() {
|
|
|
|
return this.fragment.name;
|
|
|
|
}
|
|
|
|
get eventSignature() {
|
|
|
|
return this.fragment.format();
|
|
|
|
}
|
|
|
|
}
|
2022-09-05 23:57:11 +03:00
|
|
|
//# sourceMappingURL=wrappers.js.map
|