-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix infinite
pendingTransactions
event and add `pendingTrans…
…actionFilter` option (#3514)
- Loading branch information
Showing
7 changed files
with
202 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
'@reown/appkit-adapter-wagmi': patch | ||
'@reown/appkit': patch | ||
'@reown/appkit-common': patch | ||
'@reown/appkit-adapter-bitcoin': patch | ||
'@reown/appkit-adapter-ethers': patch | ||
'@reown/appkit-adapter-ethers5': patch | ||
'@reown/appkit-adapter-solana': patch | ||
'@reown/appkit-utils': patch | ||
'@reown/appkit-cdn': patch | ||
'@reown/appkit-cli': patch | ||
'@reown/appkit-core': patch | ||
'@reown/appkit-experimental': patch | ||
'@reown/appkit-polyfills': patch | ||
'@reown/appkit-scaffold-ui': patch | ||
'@reown/appkit-siwe': patch | ||
'@reown/appkit-siwx': patch | ||
'@reown/appkit-ui': patch | ||
'@reown/appkit-wallet': patch | ||
'@reown/appkit-wallet-button': patch | ||
--- | ||
|
||
Fixed an issue where the `pendingTransactions` event was being emitted infinitely in wagmi adapter. | ||
|
||
Additionally another option was added to wagmi adapter called `pendingTransactionsFilter`. | ||
|
||
**Example usage** | ||
|
||
```ts | ||
const wagmiAdapter = new WagmiAdapter({ | ||
networks: [/* Your Networks */], | ||
projectId: "YOUR_PROJECT_ID", | ||
pendingTransactionsFilter: { | ||
enable: true, | ||
pollingInterval: 15_000 | ||
} | ||
}); | ||
|
||
createAppKit({ | ||
adapters: [wagmiAdapter], | ||
networks: [/* Your Networks */], | ||
projectId: "YOUR_PROJECT_ID" | ||
}); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { LimitterUtil } from '../utils/LimitterUtil' | ||
|
||
// -- Tests -------------------------------------------------------------------- | ||
describe('LimitterUtil', () => { | ||
it('should have valid default state', () => { | ||
expect(LimitterUtil.state).toEqual({ | ||
pendingTransactions: 0 | ||
}) | ||
}) | ||
|
||
it('should increase state limit', () => { | ||
LimitterUtil.increase('pendingTransactions') | ||
expect(LimitterUtil.state.pendingTransactions).toBe(1) | ||
}) | ||
|
||
it('should decrease state limit', () => { | ||
expect(LimitterUtil.state.pendingTransactions).toBe(1) | ||
LimitterUtil.decrease('pendingTransactions') | ||
expect(LimitterUtil.state.pendingTransactions).toBe(0) | ||
}) | ||
|
||
it('should reset state limit', () => { | ||
LimitterUtil.increase('pendingTransactions') | ||
expect(LimitterUtil.state.pendingTransactions).toEqual(1) | ||
LimitterUtil.reset('pendingTransactions') | ||
expect(LimitterUtil.state.pendingTransactions).toEqual(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { subscribeKey as subKey } from 'valtio/vanilla/utils' | ||
import { proxy } from 'valtio/vanilla' | ||
|
||
// -- Types --------------------------------------------- // | ||
export interface LimitteStoreUtilState { | ||
pendingTransactions: number | ||
} | ||
|
||
type StateKey = keyof LimitteStoreUtilState | ||
|
||
// -- State --------------------------------------------- // | ||
const state = proxy<LimitteStoreUtilState>({ | ||
pendingTransactions: 0 | ||
}) | ||
|
||
// -- Controller ---------------------------------------- // | ||
export const LimitterUtil = { | ||
state, | ||
|
||
subscribeKey<K extends StateKey>(key: K, callback: (value: LimitteStoreUtilState[K]) => void) { | ||
return subKey(state, key, callback) | ||
}, | ||
|
||
increase(value: StateKey) { | ||
state[value] += 1 | ||
}, | ||
|
||
decrease(value: StateKey) { | ||
state[value] -= 1 | ||
}, | ||
|
||
reset(value: StateKey) { | ||
state[value] = 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const PACKAGE_VERSION = '1.6.0' | ||
export const PACKAGE_VERSION = '1.6.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters