Skip to content

Commit 50eb86c

Browse files
committed
implement fetchTransactionReceipt, parseEvents
1 parent f476508 commit 50eb86c

File tree

9 files changed

+246
-133
lines changed

9 files changed

+246
-133
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ Simple WalletConnect v2 integration package for Vue3 apps.
2121
- [FetchGasPrice](#fetchgasprice)
2222
- [FetchBlockNumber](#fetchblocknumber)
2323
- [FetchTransaction](#fetchtransaction)
24+
- [FetchTransactionReceipt](#fetchtransactionreceipt)
2425
- [SendTransaction](#sendtransaction)
2526
- [SignMessage](#signmessage)
2627
- [Multicall](#multicall)
2728
- [FetchBalance](#fetchbalance)
2829
- [FetchToken](#fetchtoken)
2930
- [ReadContract](#readcontract)
3031
- [WriteContract](#writecontract)
32+
- [ParseEvents](#parseevents)
3133
- [WatchContractEvent](#watchcontractevent)
3234
- [EstimateWriteContractGas](#estimatewritecontractgas)
3335
- [Composable](#composable)
@@ -194,7 +196,17 @@ let data = await fetchBlockNumber()
194196
```js
195197
import {fetchTransaction} from '@kolirt/vue-web3-auth'
196198

197-
let txn = await fetchTransaction({
199+
let transaction = await fetchTransaction({
200+
hash: '0x7ed8dc64f54ae43f4d53173e95aa929c52de44ec5cea8c28246989914ed7f4fb'
201+
})
202+
```
203+
204+
### fetchTransactionReceipt
205+
206+
```js
207+
import {fetchTransactionReceipt} from '@kolirt/vue-web3-auth'
208+
209+
let transactionReceipt = await fetchTransactionReceipt({
198210
hash: '0x7ed8dc64f54ae43f4d53173e95aa929c52de44ec5cea8c28246989914ed7f4fb'
199211
})
200212
```
@@ -349,6 +361,32 @@ await writeContract({
349361
})
350362
```
351363
364+
### ParseEvents
365+
366+
```js
367+
import {erc20ABI, fetchTransactionReceipt, parseEvents} from '@kolirt/vue-web3-auth'
368+
369+
const transactionReceipt = await fetchTransactionReceipt({
370+
hash: '0x2a328737e94bb243b1ff64792ae68cd6c179797dc1de1e092c96137f0d3404c3'
371+
})
372+
373+
const events = parseEvents({abi: erc20ABI}, transactionReceipt)
374+
/**
375+
* Result in events
376+
*
377+
* [
378+
* {
379+
* args: {
380+
* owner: '0xaA916B4a4cDbEFC045fa24542673F500a11F5413',
381+
* spender: '0x023963f7e755bE4F743047183d1F49C31E84AEa4',
382+
* value: 1000000000000000000n
383+
* },
384+
* eventName: 'Approval'
385+
* }
386+
* ]
387+
*/
388+
```
389+
352390
### WatchContractEvent
353391
354392
```js

dist/vue-web3-auth.d.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import type { Plugin as Plugin_2 } from 'vue';
88
import type { Ref } from 'vue';
99
import type { ThemeCtrlState } from '@web3modal/core';
1010
import type { Transaction } from 'viem';
11-
import type { TransactionReceipt } from 'viem';
11+
import type { TransactionReceipt } from 'viem/src/types/transaction';
12+
import type { TransactionReceipt as TransactionReceipt_2 } from 'viem';
1213
import type { Unit } from '@wagmi/core';
1314
import type { WaitForTransactionResult } from '@wagmi/core';
1415

@@ -131,6 +132,13 @@ declare type FetchTransaction = {
131132

132133
export declare function fetchTransaction(data: FetchTransaction): Promise<Transaction>;
133134

135+
declare type FetchTransactionReceipt = {
136+
chainId?: number;
137+
hash: `0x${string}`;
138+
};
139+
140+
export declare function fetchTransactionReceipt(data: FetchTransactionReceipt): Promise<TransactionReceipt_2>;
141+
134142
export declare function getAvailableChains(): Chain[];
135143

136144
export declare function init(): void;
@@ -222,6 +230,15 @@ export declare type Options = {
222230
web3modalOptions?: ThemeCtrlState;
223231
};
224232

233+
declare type ParseEvents = {
234+
abi: any;
235+
};
236+
237+
export declare function parseEvents(data: ParseEvents, transactionReceipt: TransactionReceipt): ({
238+
eventName: string;
239+
args: readonly [] | {};
240+
} | undefined)[];
241+
225242
declare type ReadContract = {
226243
chainId?: number;
227244
address: `0x${string}`;
@@ -250,7 +267,7 @@ declare type SendTransaction = {
250267
confirmations?: number;
251268
};
252269

253-
export declare function sendTransaction(data: SendTransaction): Promise<TransactionReceipt>;
270+
export declare function sendTransaction(data: SendTransaction): Promise<TransactionReceipt_2>;
254271

255272
export declare function shortAddressFilter(value?: string): string;
256273

0 commit comments

Comments
 (0)