File tree Expand file tree Collapse file tree 7 files changed +49
-6
lines changed
Expand file tree Collapse file tree 7 files changed +49
-6
lines changed Original file line number Diff line number Diff line change 88Simple WalletConnect Web3Modal v2 integration package for Vue3 apps.
99
1010### Versions
11- | package version | web3modal |
12- | -----------------| -------------------|
13- | [ 2.x.x] ( https://github.com/kolirt/vue-web3-auth/tree/v2 ) | [ v2] ( https://github.com/WalletConnect/web3modal/tree/V2 ) |
1411
12+ | package version | web3modal |
13+ | -------------------------------------------------------- | -------------------------------------------------------- |
14+ | [ 2.x.x] ( https://github.com/kolirt/vue-web3-auth/tree/v2 ) | [ v2] ( https://github.com/WalletConnect/web3modal/tree/V2 ) |
1515
1616### Table of Contents
1717
@@ -39,6 +39,7 @@ Simple WalletConnect Web3Modal v2 integration package for Vue3 apps.
3939 - [ EstimateWriteContractGas] ( #estimatewritecontractgas )
4040 - [ ParseEvents] ( #parseevents )
4141 - [ WatchContractEvent] ( #watchcontractevent )
42+ - [ WatchAsset] ( #watchasset )
4243 - [ Composable] ( #composable )
4344 - [ UseFetchBalance] ( #usefetchbalance )
4445- [ Demo] ( #demo )
@@ -420,6 +421,18 @@ const unwatch = watchContractEvent(
420421)
421422` ` `
422423
424+ ### WatchAsset
425+
426+ ` ` ` js
427+ import { watchAsset } from ' @kolirt/vue-web3-auth'
428+
429+ const unwatch = watchAsset ({
430+ address: ' 0x6b175474e89094c44da98b954eedeac495271d0f' ,
431+ decimals: 18 ,
432+ symbol: ' DAI'
433+ })
434+ ` ` `
435+
423436## Composable
424437
425438### UseFetchBalance
Original file line number Diff line number Diff line change 1+ import { getWalletClient } from '@wagmi/core'
2+
3+ import { chain } from '../chain'
4+ import type { WatchAsset } from '../types'
5+
6+ export async function watchAsset ( options : WatchAsset ) {
7+ const walletClient = await getWalletClient ( { chainId : options . chainId || chain . value . id } )
8+
9+ if ( walletClient ) {
10+ return await walletClient . watchAsset ( {
11+ type : 'ERC20' ,
12+ options : {
13+ address : options . address ,
14+ symbol : options . symbol ,
15+ decimals : options . decimals ,
16+ image : options . image
17+ }
18+ } )
19+ }
20+
21+ return false
22+ }
Original file line number Diff line number Diff line change 11import { watchContractEvent as masterWatchContractEvent } from '@wagmi/core'
2- import { decodeEventLog } from 'viem'
32import type { TransactionReceipt } from 'viem/src/types/transaction'
3+ import { decodeEventLog } from 'viem/utils'
44
55import { chain } from '../chain'
66import type { DecodedEvent , ParseEvents , WatchContractEvent } from '../types'
Original file line number Diff line number Diff line change 1+ export { watchAsset } from './asset'
2+
13export { fetchBalance , useFetchBalance } from './balance'
24
35export { fetchBlockNumber } from './block'
Original file line number Diff line number Diff line change 11import { multicall as masterMulticall } from '@wagmi/core'
2- import { type ContractFunctionConfig , type MulticallParameters } from 'viem'
2+ import { type MulticallParameters } from 'viem/actions'
3+ import { type ContractFunctionConfig } from 'viem/src/types/contract'
34
45import type { MulticallArgs } from '../types'
56
Original file line number Diff line number Diff line change 11import type { Chain , Unit } from '@wagmi/core'
22import type { ThemeCtrlState } from '@web3modal/core'
33import type { EthereumClient } from '@web3modal/ethereum'
4+ import type { WatchAssetParams } from 'viem/src/types/eip1193'
45
56type BlockTag = 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
67
@@ -131,6 +132,10 @@ export type FetchBalance = {
131132 token ?: `0x${string } `
132133}
133134
135+ export type WatchAsset = {
136+ chainId ?: number
137+ } & WatchAssetParams [ 'options' ]
138+
134139export type FetchBalanceOptions = {
135140 disableAutoFetch ?: boolean
136141 autoReloadTime ?: number
Original file line number Diff line number Diff line change 11{
22 "name" : " @kolirt/vue-web3-auth" ,
3- "version" : " 2.0 .1" ,
3+ "version" : " 2.1 .1" ,
44 "description" : " Web3 authentication for Vue3 apps based on WalletConnect Web3Modal v2" ,
55 "author" : " kolirt" ,
66 "license" : " MIT" ,
You can’t perform that action at this time.
0 commit comments