Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use portofolio UI for all wallets #3859

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/appkit/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ export class AppKit {
return AccountController.subscribeKey('connectedWalletInfo', callback)
}

public subscribeShouldUpdateToAddress(callback: (newState?: string) => void) {
AccountController.subscribeKey('shouldUpdateToAddress', callback)
}

public subscribeCaipNetworkChange(callback: (newState?: CaipNetwork) => void) {
ChainController.subscribeKey('activeCaipNetwork', callback)
}
Expand Down Expand Up @@ -857,6 +853,14 @@ export class AppKit {
if (options.excludeWalletIds) {
ApiController.initializeExcludedWalletRdns({ ids: options.excludeWalletIds })
}

AccountController.subscribeKey('shouldUpdateToAddress', address => {
const chainNamespace = ChainController.state.activeChain as ChainNamespace
const chainId = this.getChainId()
if (address && chainNamespace && chainId) {
this.syncAccount({ address, chainNamespace, chainId })
}
})
}

private getDefaultMetaData() {
Expand Down
3 changes: 1 addition & 2 deletions packages/appkit/tests/client/public-methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,9 @@
const subscribe = vi.spyOn(AccountController, 'subscribeKey')
const callback = vi.fn()

const appKit = new AppKit(mockOptions)
appKit.subscribeShouldUpdateToAddress(callback)
new AppKit(mockOptions)

expect(subscribe).toHaveBeenCalledWith('shouldUpdateToAddress', callback)

Check failure on line 206 in packages/appkit/tests/client/public-methods.test.ts

View workflow job for this annotation

GitHub Actions / test

tests/client/public-methods.test.ts > Base Public methods > should subscribe to address updates

AssertionError: expected "subscribeKey" to be called with arguments: [ 'shouldUpdateToAddress', …(1) ] Received: 1st subscribeKey call: Array [ "shouldUpdateToAddress", - [Function spy], + [Function anonymous], ] Number of calls: 1 ❯ tests/client/public-methods.test.ts:206:23
})

it('should subscribe to CAIP network changes', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/scaffold-ui/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ export * from '../src/partials/w3m-onramp-providers-footer/index.js'
export * from '../src/partials/w3m-snackbar/index.js'
export * from '../src/partials/w3m-alertbar/index.js'
export * from '../src/partials/w3m-email-login-widget/index.js'
export * from '../src/partials/w3m-account-default-widget/index.js'
export * from '../src/partials/w3m-account-wallet-features-widget/index.js'
export * from '../src/partials/w3m-account-activity-widget/index.js'
export * from '../src/partials/w3m-account-nfts-widget/index.js'
export * from '../src/partials/w3m-account-tokens-widget/index.js'
Expand Down
Loading
Loading