Skip to content

Commit

Permalink
Merge branch 'main' into chore/csp-dogfooding
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrem authored Jul 9, 2024
2 parents e387491 + fcfc26d commit 8011f77
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ui_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
name: 'Playwright Tests'
runs-on:
group: ubuntu-runners
timeout-minutes: 15
timeout-minutes: 20
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions apps/laboratory/src/pages/library/wagmi-all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { WagmiModalInfo } from '../../components/Wagmi/WagmiModalInfo'
const queryClient = new QueryClient()

const wagmiConfig = getWagmiConfig('email')

const modal = createWeb3Modal({
wagmiConfig,
projectId: ConstantsUtil.ProjectId,
Expand Down
9 changes: 4 additions & 5 deletions apps/laboratory/tests/shared/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ const braveOptions: UseOptions = {
}
}

const EMAIL_BASED_PLATFORM_REGEX =
/(?:email\.spec\.ts|smart-account\.spec\.ts|siwe-email\.spec\.ts|siwe-sa\.spec\.ts|social\.spec\.ts).*$/u
const WAGMI_EMAIL_BASED_REGEX = /(?:smart-account\.spec\.ts|siwe-sa\.spec\.ts|social\.spec\.ts).*$/u

const SOLANA_UNIMPLEMENTED_TESTS_REGEX =
/^(?!.*(?:email\.spec\.ts|siwe\.spec\.ts|canary\.spec\.ts|smart-account\.spec\.ts|social\.spec\.ts|siwe-sa\.spec\.ts|siwe-email\.spec\.ts)).*$/u
Expand All @@ -52,14 +51,14 @@ const customProjectProperties: CustomProjectProperties = {
testIgnore: /(?:social\.spec\.ts).*$/u
},
'Desktop Brave/wagmi': {
testIgnore: EMAIL_BASED_PLATFORM_REGEX,
testIgnore: WAGMI_EMAIL_BASED_REGEX,
useOptions: braveOptions
},
'Desktop Chrome/wagmi': {
testIgnore: EMAIL_BASED_PLATFORM_REGEX
testIgnore: WAGMI_EMAIL_BASED_REGEX
},
'Desktop Firefox/wagmi': {
testIgnore: EMAIL_BASED_PLATFORM_REGEX
testIgnore: WAGMI_EMAIL_BASED_REGEX
},
// Exclude social.spec.ts, email.spec.ts, siwe.spec.ts, and canary.spec.ts from solana, not yet implemented
'Desktop Chrome/solana': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class ModalWalletValidator extends ModalValidator {
).toContainText(type)
}

async expectChangedAddressAfterSwitchingAccountType(previousAddress: string) {
await expect(this.page.getByTestId('w3m-address')).not.toHaveText(previousAddress)
}

override async expectSwitchedNetwork(network: string) {
const switchNetworkButton = this.page.getByTestId('account-switch-network-button')
await expect(switchNetworkButton).toBeVisible()
Expand Down
6 changes: 5 additions & 1 deletion apps/laboratory/tests/smart-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,20 @@ testModalSmartAccount(
}
)

testModalSmartAccount(
testModalSmartAccount.skip(
'it should properly sign with a 6492 signature',
async ({ modalPage, modalValidator }) => {
const walletModalPage = modalPage as ModalWalletPage
const walletModalValidator = modalValidator as ModalWalletValidator

const eoaAddress = await walletModalPage.getAddress()

await walletModalPage.openAccount()
await walletModalPage.openProfileView()
await walletModalPage.openSettings()
await walletModalPage.togglePreferredAccountType()
await walletModalValidator.expectChangePreferredAccountToShow(EOA)
await walletModalValidator.expectChangedAddressAfterSwitchingAccountType(eoaAddress)
await walletModalPage.closeModal()

await walletModalPage.sign()
Expand All @@ -88,6 +91,7 @@ testModalSmartAccount(
const signature = await walletModalPage.getSignature()
const address = await walletModalPage.getAddress()
const chainId = await walletModalPage.getChainId()

await walletModalValidator.expectValidSignature(signature, address, chainId)
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class W3mAccountSettingsView extends LitElement {
ModalController.close()
}
}),
AccountController.subscribeKey(
'preferredAccountType',
val => (this.preferredAccountType = val)
),
NetworkController.subscribeKey('caipNetwork', val => {
if (val?.id) {
this.network = val
Expand Down
6 changes: 6 additions & 0 deletions packages/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,12 @@ export class Web3Modal extends Web3ModalScaffold {
return
}
this.setPreferredAccountType(type as W3mFrameTypes.AccountType, this.chain)
this.syncAccount({
address: address as `0x${string}`,
isConnected: true,
chainId: NetworkUtil.caipNetworkIdToNumber(this.getCaipNetwork()?.id),
connector
})
})
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/wallet/src/W3mFrameProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ export class W3mFrameProvider {
})

return new Promise<W3mFrameTypes.Responses['FrameGetUserResponse']>((resolve, reject) => {
this.connectResolver = { resolve, reject }
if (!this.connectResolver) {
this.connectResolver = { resolve, reject }
}
})
}

Expand Down Expand Up @@ -523,12 +525,14 @@ export class W3mFrameProvider {
this.setLastUsedChainId(event.payload.chainId)

this.connectResolver?.resolve(event.payload)
this.connectResolver = undefined
}

private onConnectError(
event: Extract<W3mFrameTypes.FrameEvent, { type: '@w3m-frame/GET_USER_ERROR' }>
) {
this.connectResolver?.reject(event.payload.message)
this.connectResolver = undefined
}

private onConnectSocialSuccess(
Expand Down

0 comments on commit 8011f77

Please sign in to comment.