Skip to content

Commit bc2ddaf

Browse files
committed
updated parseEvents
1 parent 50eb86c commit bc2ddaf

File tree

7 files changed

+55
-44
lines changed

7 files changed

+55
-44
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ Simple WalletConnect v2 integration package for Vue3 apps.
2929
- [FetchToken](#fetchtoken)
3030
- [ReadContract](#readcontract)
3131
- [WriteContract](#writecontract)
32+
- [EstimateWriteContractGas](#estimatewritecontractgas)
3233
- [ParseEvents](#parseevents)
3334
- [WatchContractEvent](#watchcontractevent)
34-
- [EstimateWriteContractGas](#estimatewritecontractgas)
3535
- [Composable](#composable)
3636
- [UseFetchBalance](#usefetchbalance)
3737
- [Demo](#demo)
@@ -361,6 +361,20 @@ await writeContract({
361361
})
362362
```
363363
364+
### EstimateWriteContractGas
365+
366+
```ts
367+
import {erc20ABI, estimateWriteContractGas} from '@kolirt/vue-web3-auth'
368+
369+
const gas = await estimateWriteContractGas({
370+
abi: erc20ABI,
371+
address: '0x55d398326f99059fF775485246999027B3197955',
372+
functionName: 'approve',
373+
args: ['0x685B1ded8013785d6623CC18D214320b6Bb64759', 100]
374+
}).catch(e => {
375+
})
376+
```
377+
364378
### ParseEvents
365379
366380
```js
@@ -401,20 +415,6 @@ const unwatch = watchContractEvent({
401415
})
402416
```
403417
404-
### EstimateWriteContractGas
405-
406-
```ts
407-
import {erc20ABI, estimateWriteContractGas} from '@kolirt/vue-web3-auth'
408-
409-
const gas = await estimateWriteContractGas({
410-
abi: erc20ABI,
411-
address: '0x55d398326f99059fF775485246999027B3197955',
412-
functionName: 'approve',
413-
args: ['0x685B1ded8013785d6623CC18D214320b6Bb64759', 100]
414-
}).catch(e => {
415-
})
416-
```
417-
418418
## Composable
419419
420420
### UseFetchBalance

dist/vue-web3-auth.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export declare function connect(chain?: Chain): Promise<void>;
3737

3838
export declare function createWeb3Auth(options: Options): Plugin_2;
3939

40+
declare type DecodedEvent = {
41+
eventName: string;
42+
args: [] | {};
43+
};
44+
4045
export declare function disconnect(): Promise<void>;
4146

4247
export declare const erc20ABI: ({
@@ -234,10 +239,7 @@ declare type ParseEvents = {
234239
abi: any;
235240
};
236241

237-
export declare function parseEvents(data: ParseEvents, transactionReceipt: TransactionReceipt): ({
238-
eventName: string;
239-
args: readonly [] | {};
240-
} | undefined)[];
242+
export declare function parseEvents(data: ParseEvents, transactionReceipt: TransactionReceipt): DecodedEvent[];
241243

242244
declare type ReadContract = {
243245
chainId?: number;

dist/vue-web3-auth.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fe from "@wagmi/core/chains";
22
import { reactive as f, toRaw as R, watch as $, watchEffect as S, ref as k, computed as _ } from "vue";
3-
import { configureChains as j, createConfig as D, watchNetwork as H, watchAccount as V, disconnect as W, fetchBalance as L, fetchBlockNumber as z, readContract as q, writeContract as J, getPublicClient as x, waitForTransaction as F, watchContractEvent as K, fetchFeeData as Q, signMessage as X, multicall as Y, fetchToken as Z, fetchTransaction as O, sendTransaction as B } from "@wagmi/core";
3+
import { configureChains as j, createConfig as D, watchNetwork as H, watchAccount as V, disconnect as W, fetchBalance as L, fetchBlockNumber as z, readContract as q, writeContract as J, getPublicClient as x, waitForTransaction as E, watchContractEvent as K, fetchFeeData as Q, signMessage as X, multicall as Y, fetchToken as Z, fetchTransaction as O, sendTransaction as B } from "@wagmi/core";
44
import { Web3Modal as ee } from "@web3modal/html";
55
import ne from "js-event-bus";
66
import { w3mProvider as te, w3mConnectors as ae, EthereumClient as ie } from "@web3modal/ethereum";
@@ -87,7 +87,7 @@ function d(...e) {
8787
}
8888
var o = /* @__PURE__ */ ((e) => (e.Connected = "connected", e.Disconnected = "disconnect", e.ChainSwitched = "chain_switched", e.UnknownChain = "unknown_chain", e.ModalStateChanged = "modal_state_changed", e))(o || {});
8989
let P;
90-
const E = f({
90+
const F = f({
9191
client: null
9292
});
9393
function b(e) {
@@ -124,7 +124,7 @@ function v() {
124124
p.bufferAccount = l.address ? l : null;
125125
}), $([() => p.bufferAccount, () => u.bufferChain], me);
126126
const T = new ie(s, e);
127-
E.client = T, he(T);
127+
F.client = T, he(T);
128128
}
129129
const p = f({
130130
bufferAccount: null,
@@ -185,11 +185,11 @@ const u = f({
185185
function xe() {
186186
return a.chains;
187187
}
188-
async function Fe(e) {
188+
async function Ee(e) {
189189
var n;
190-
r.value || v(), await ((n = E.client) == null ? void 0 : n.switchNetwork({ chainId: e.id }));
190+
r.value || v(), await ((n = F.client) == null ? void 0 : n.switchNetwork({ chainId: e.id }));
191191
}
192-
async function Ee() {
192+
async function Fe() {
193193
var e;
194194
r.value || v(), await ((e = r.value) == null ? void 0 : e.openModal({
195195
route: "SelectNetwork"
@@ -282,7 +282,7 @@ async function Ge(e) {
282282
value: e.value
283283
});
284284
function t() {
285-
return F({
285+
return E({
286286
chainId: e.chainId || c.value.id,
287287
hash: n,
288288
confirmations: e.confirmations || 1
@@ -309,17 +309,17 @@ async function Re(e) {
309309
});
310310
}
311311
function Se(e, n) {
312-
return n.logs.map((t) => {
312+
const t = [];
313+
return n.logs.forEach((i) => {
313314
try {
314-
return se({
315+
t.push(se({
315316
abi: e.abi,
316-
topics: t.topics,
317-
data: t.data
318-
});
317+
topics: i.topics,
318+
data: i.data
319+
}));
319320
} catch {
320-
return;
321321
}
322-
}).filter((t) => t);
322+
}), t;
323323
}
324324
function _e(e, n) {
325325
return K({
@@ -391,7 +391,7 @@ async function ze(e) {
391391
nonce: e.nonce,
392392
value: e.value
393393
});
394-
return F({
394+
return E({
395395
chainId: e.chainId || c.value.id,
396396
hash: n,
397397
confirmations: e.confirmations || 1
@@ -764,11 +764,11 @@ export {
764764
Je as multicallABI,
765765
Se as parseEvents,
766766
Ne as readContract,
767-
Ee as selectChain,
767+
Fe as selectChain,
768768
ze as sendTransaction,
769769
ye as shortAddressFilter,
770770
De as signMessage,
771-
Fe as switchChain,
771+
Ee as switchChain,
772772
Ue as useFetchBalance,
773773
_e as watchContractEvent,
774774
Ge as writeContract

0 commit comments

Comments
 (0)