Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ jobs:
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: examples/next
- name: Run Playwright tests
run: npx playwright test
working-directory: examples/next
env:
BASE_URL: ${{ github.event.client_payload.url }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
path: examples/next/playwright-report/
retention-days: 30
10 changes: 6 additions & 4 deletions packages/controller/src/wallets/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getAddress } from "ethers";
import { ArgentWallet } from "./argent";
import { MetaMaskWallet } from "./metamask";
import { PhantomWallet } from "./phantom";
Expand Down Expand Up @@ -134,11 +135,12 @@ export class WalletBridge {
let wallet: WalletAdapter | undefined;
if (typeof identifier === "string") {
// this is an address
const checkSummedAddress = getAddress(identifier);

wallet = this.walletAdapters.values().find((adapter) => {
const ident = identifier.toLowerCase();
return (
adapter.getConnectedAccounts().includes(ident) ||
adapter.type === ident
adapter.getConnectedAccounts().includes(checkSummedAddress) ||
adapter.type === checkSummedAddress
);
});
} else {
Expand All @@ -149,7 +151,7 @@ export class WalletBridge {
wallet = this.walletAdapters
.values()
.find((adapter) =>
adapter.getConnectedAccounts().includes(identifier.toLowerCase()),
adapter.getConnectedAccounts().includes(getAddress(identifier)),
);
}

Expand Down
1 change: 0 additions & 1 deletion packages/controller/src/wallets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export * from "./bridge";
export * from "./metamask";
export * from "./phantom";
export * from "./rabby";
export * from "./turnkey";
export * from "./types";
export * from "./wallet-connect";
27 changes: 18 additions & 9 deletions packages/controller/src/wallets/metamask/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MetaMaskSDK } from "@metamask/sdk";
import { getAddress } from "ethers/address";
import { createStore } from "mipd";
import {
ExternalPlatform,
Expand Down Expand Up @@ -31,14 +32,20 @@ export class MetaMaskWallet implements WalletAdapter {
})
.then((accounts: any) => {
if (accounts && accounts.length > 0) {
this.account = accounts[0];
this.connectedAccounts = accounts;
this.account = getAddress(accounts[0]);
this.connectedAccounts = accounts.map((account: string) =>
getAddress(account),
);
}
});
this.MMSDK.getProvider()?.on("accountsChanged", (accounts: any) => {
if (Array.isArray(accounts)) {
this.account = accounts?.[0];
this.connectedAccounts = accounts;
if (accounts.length > 0) {
this.account = getAddress(accounts?.[0]);
}
this.connectedAccounts = accounts.map((account: string) =>
getAddress(account),
);
}
});
});
Expand Down Expand Up @@ -69,8 +76,8 @@ export class MetaMaskWallet implements WalletAdapter {
}

async connect(address?: string): Promise<ExternalWalletResponse<any>> {
if (address && this.connectedAccounts.includes(address)) {
this.account = address;
if (address && this.connectedAccounts.includes(getAddress(address))) {
this.account = getAddress(address);
}

if (this.account) {
Expand All @@ -84,8 +91,10 @@ export class MetaMaskWallet implements WalletAdapter {

const accounts = await this.MMSDK.connect();
if (accounts && accounts.length > 0) {
this.account = accounts[0];
this.connectedAccounts = accounts;
this.account = getAddress(accounts[0]);
this.connectedAccounts = accounts.map((account: string) =>
getAddress(account),
);
return { success: true, wallet: this.type, account: this.account };
}

Expand Down Expand Up @@ -141,7 +150,7 @@ export class MetaMaskWallet implements WalletAdapter {

const result = await this.MMSDK.getProvider()?.request({
method: "personal_sign",
params: [this.account!, message],
params: [this.account, message],
});

return { success: true, wallet: this.type, result };
Expand Down
11 changes: 5 additions & 6 deletions packages/controller/src/wallets/rabby/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getAddress } from "ethers/address";
import { createStore, EIP6963ProviderDetail } from "mipd";
import {
ExternalPlatform,
Expand Down Expand Up @@ -31,10 +32,8 @@ export class RabbyWallet implements WalletAdapter {
this.provider?.provider?.on("accountsChanged", (accounts: string[]) => {
if (accounts) {
// rabby doesn't allow multiple accounts to be connected at the same time
this.connectedAccounts = accounts.map((account) =>
account.toLowerCase(),
);
this.account = accounts?.[0]?.toLowerCase();
this.connectedAccounts = accounts.map((account) => getAddress(account));
this.account = getAddress(accounts?.[0]);
}
});
}
Expand All @@ -58,8 +57,8 @@ export class RabbyWallet implements WalletAdapter {
}

async connect(address?: string): Promise<ExternalWalletResponse<any>> {
if (address && this.connectedAccounts.includes(address.toLowerCase())) {
this.account = address.toLowerCase();
if (address && this.connectedAccounts.includes(getAddress(address))) {
this.account = getAddress(address);
}

if (this.account) {
Expand Down
195 changes: 0 additions & 195 deletions packages/controller/src/wallets/turnkey/index.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/controller/src/wallets/wallet-connect/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Provider from "@walletconnect/ethereum-provider";
import { getAddress } from "ethers/address";
import {
ExternalPlatform,
ExternalWallet,
Expand All @@ -17,7 +18,7 @@ export class WalletConnectWallet implements WalletAdapter {
private provider: Provider,
address?: string,
) {
this.account = address?.toLowerCase();
this.account = address ? getAddress(address) : undefined;
}

getConnectedAccounts(): string[] {
Expand Down
3 changes: 2 additions & 1 deletion packages/keychain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@auth0/auth0-react": "^2.3.0",
"@auth0/auth0-spa-js": "^2.1.3",
"@cartridge/controller-wasm": "catalog:",
"@cartridge/controller": "workspace:*",
"@cartridge/penpal": "catalog:",
Expand All @@ -32,7 +33,7 @@
"@starknet-io/types-js": "catalog:",
"@stripe/react-stripe-js": "^2.8.1",
"@stripe/stripe-js": "^4.8.0",
"@turnkey/sdk-browser": "^4.0.0",
"@turnkey/sdk-browser": "^4.1.0",
"@turnkey/sdk-react": "^4.2.1",
"@walletconnect/ethereum-provider": "^2.20.0",
"base64url": "catalog:",
Expand Down
Loading
Loading