@riaskov/iohtee-abi-wrapper 2.0.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,92 +0,0 @@
1
- import {
2
- AbiEvent,
3
- TransactionReceipt,
4
- parseEventLogs,
5
- ParseEventLogsReturnType,
6
- } from "viem"
7
- import { BaseContract, TxOptions, CtorParams, isCtorAccountParamPure } from "@riaskov/iohtee-abi-wrapper"
8
- export { isCtorAccountParamPure, CtorParams, TxOptions }
9
-
10
- export interface {{contractName}}Event {
11
- eventName: string
12
- args: any
13
- address: `0x${string}`
14
- blockHash: `0x${string}`
15
- blockNumber: bigint
16
- data: `0x${string}`
17
- logIndex: number
18
- removed: boolean
19
- topics: [] | [`0x${string}`, ...`0x${string}`[]]
20
- transactionHash: `0x${string}`
21
- transactionIndex: number
22
- }
23
-
24
- {{#each events}}
25
- {{> event_types contractName=../contractName}}
26
- {{/each}}
27
-
28
- export enum {{contractName}}EventName {
29
- {{#each events}}
30
- {{> event_enum contractName=../contractName}}
31
- {{/each}}
32
- }
33
-
34
- const abi = JSON.parse(`{{abi}}`)
35
-
36
- export class {{contractName}}Contract extends BaseContract {
37
- /// GETTERS
38
- {{#each getters}}
39
- {{> getter contractName=../contractName}}
40
-
41
- {{/each}}
42
-
43
- /// SETTERS
44
- {{#each functions}}
45
- {{> function contractName=../contractName}}
46
-
47
- {{/each}}
48
-
49
- /// EVENTS
50
- {{#each events}}
51
- {{> event_utils contractName=../contractName}}
52
-
53
- {{/each}}
54
-
55
- static parseLogs(receipt: TransactionReceipt): ParseEventLogsReturnType {
56
- const logs = parseEventLogs({
57
- abi: abi as any,
58
- logs: receipt.logs,
59
- })
60
- return logs as any
61
- }
62
-
63
- static hasEvent(receipt: TransactionReceipt, eventName: {{contractName}}EventName): boolean {
64
- return parseEventLogs({ abi: abi, logs: receipt.logs }).some((log: any) => log.eventName === eventName)
65
- }
66
-
67
- static extractEventFromReceipt<T>(receipt: TransactionReceipt, eventName: {{contractName}}EventName): T {
68
- return parseEventLogs({ abi: abi, logs: receipt.logs }).find((log: any) => log.eventName === eventName) as T
69
- }
70
-
71
- static parseEvents(receipt: TransactionReceipt): {{contractName}}Event[] {
72
- return parseEventLogs({ abi: abi, logs: receipt.logs }).map((log: any) => {
73
- return {
74
- eventName: log.eventName,
75
- args: log.args,
76
- address: log.address,
77
- blockHash: log.blockHash,
78
- blockNumber: log.blockNumber,
79
- data: log.data,
80
- logIndex: log.logIndex,
81
- removed: log.removed,
82
- topics: log.topics,
83
- transactionHash: log.transactionHash,
84
- transactionIndex: log.transactionIndex,
85
- }
86
- })
87
- }
88
-
89
- constructor(deployedContractAddress: `0x${string}`, params: CtorParams) {
90
- super(deployedContractAddress, params, abi)
91
- }
92
- }