From 8fe23ee4280bbb706e6906670dd7a445d6fa6318 Mon Sep 17 00:00:00 2001 From: Daniel Bellmas Date: Wed, 27 Nov 2024 17:24:16 +0200 Subject: [PATCH] feat: add fordefi wallet --- packages/core/src/__test__/main.test.ts | 13 ++++++++++--- packages/core/src/__test__/storage.test.ts | 7 +++++++ packages/core/src/__test__/wallet.mock.ts | 5 +++++ packages/core/src/discovery.ts | 9 +++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/packages/core/src/__test__/main.test.ts b/packages/core/src/__test__/main.test.ts index 8daed25..f8fbfca 100644 --- a/packages/core/src/__test__/main.test.ts +++ b/packages/core/src/__test__/main.test.ts @@ -3,6 +3,7 @@ import { mockStorageFunction } from "./storage.mock" import { ArgentXMock, BraavosMock, + FordefiMock, KeplrMock, OKXMock, UnknownWalletAMock, @@ -35,13 +36,15 @@ describe("getAvailableWallets()", () => { "starknet-braavos": BraavosMock, starknet_okxwallet: OKXMock, starknet_keplr: KeplrMock, + starknet_fordefi: FordefiMock, }) const availableWallets = await sn.getAvailableWallets() - expect(availableWallets.length).toBe(4) + expect(availableWallets.length).toBe(5) expect(availableWallets).toContainEqual(ArgentXMock) expect(availableWallets).toContainEqual(BraavosMock) expect(availableWallets).toContainEqual(OKXMock) expect(availableWallets).toContainEqual(KeplrMock) + expect(availableWallets).toContainEqual(FordefiMock) }) it("should return one injected wallet", async () => { const sn = getWallet({ @@ -118,13 +121,15 @@ describe("getPreAuthorizedWallets()", () => { "starknet-braavos": makePreAuthorized(true)(BraavosMock), starknet_okxwallet: makePreAuthorized(true)(OKXMock), starknet_keplr: makePreAuthorized(true)(KeplrMock), + starknet_fordefi: makePreAuthorized(true)(FordefiMock), }) const preauthorizedWallets = await sn.getPreAuthorizedWallets() - expect(preauthorizedWallets.length).toBe(4) + expect(preauthorizedWallets.length).toBe(5) expect(preauthorizedWallets.map((w) => w.id)).contains(ArgentXMock.id) expect(preauthorizedWallets.map((w) => w.id)).contains(BraavosMock.id) expect(preauthorizedWallets.map((w) => w.id)).contains(OKXMock.id) expect(preauthorizedWallets.map((w) => w.id)).contains(KeplrMock.id) + expect(preauthorizedWallets.map((w) => w.id)).contains(FordefiMock.id) }) it("should return one preauthorized wallet", async () => { const sn = getWallet({ @@ -132,6 +137,7 @@ describe("getPreAuthorizedWallets()", () => { "starknet-braavos": makePreAuthorized(false)(BraavosMock), starknet_okxwallet: makePreAuthorized(false)(OKXMock), starknet_keplr: makePreAuthorized(false)(KeplrMock), + starknet_fordefi: makePreAuthorized(false)(FordefiMock), }) const preauthorizedWallets = await sn.getPreAuthorizedWallets() expect(preauthorizedWallets.length).toBe(1) @@ -143,10 +149,11 @@ describe("getDiscoveryWallets()", () => { it("should return all discovery wallets", async () => { const sn = getWallet({}) const discoveryWallets = await sn.getDiscoveryWallets() - expect(discoveryWallets.length).toBe(5) + expect(discoveryWallets.length).toBe(6) expect(discoveryWallets.map((w) => w.id)).contains(ArgentXMock.id) expect(discoveryWallets.map((w) => w.id)).contains(BraavosMock.id) expect(discoveryWallets.map((w) => w.id)).contains(OKXMock.id) expect(discoveryWallets.map((w) => w.id)).contains(KeplrMock.id) + expect(discoveryWallets.map((w) => w.id)).contains(FordefiMock.id) }) }) diff --git a/packages/core/src/__test__/storage.test.ts b/packages/core/src/__test__/storage.test.ts index 7c8d31a..9d287c6 100644 --- a/packages/core/src/__test__/storage.test.ts +++ b/packages/core/src/__test__/storage.test.ts @@ -3,6 +3,7 @@ import { mockStorageFunction } from "./storage.mock" import { ArgentXMock, BraavosMock, + FordefiMock, KeplrMock, OKXMock, UnknownWalletAMock, @@ -52,6 +53,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makePreAuthorized(false)(BraavosMock), starknet_okxwallet: makePreAuthorized(false)(OKXMock), starknet_keplr: makePreAuthorized(false)(KeplrMock), + starknet_fordefi: makePreAuthorized(false)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -67,6 +69,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makePreAuthorized(true)(BraavosMock), starknet_okxwallet: makePreAuthorized(false)(OKXMock), starknet_keplr: makePreAuthorized(false)(KeplrMock), + starknet_fordefi: makePreAuthorized(false)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -82,6 +85,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makePreAuthorized(true)(BraavosMock), starknet_okxwallet: makePreAuthorized(true)(OKXMock), starknet_keplr: makePreAuthorized(true)(KeplrMock), + starknet_fordefi: makePreAuthorized(true)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos" }), ) @@ -97,6 +101,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makeConnected(true)(BraavosMock), starknet_okxwallet: makeConnected(true)(OKXMock), starknet_keplr: makePreAuthorized(true)(KeplrMock), + starknet_fordefi: makePreAuthorized(true)(FordefiMock), }) const lastConnectedWallet = await sn.getLastConnectedWallet() expect(lastConnectedWallet).toBe(null) @@ -124,6 +129,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makePreAuthorized(true)(BraavosMock), starknet_okxwallet: makePreAuthorized(true)(OKXMock), starknet_keplr: makePreAuthorized(true)(KeplrMock), + starknet_fordefi: makePreAuthorized(true)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -143,6 +149,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makePreAuthorized(true)(BraavosMock), starknet_okxwallet: makePreAuthorized(true)(OKXMock), starknet_keplr: makePreAuthorized(true)(KeplrMock), + starknet_fordefi: makePreAuthorized(true)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", diff --git a/packages/core/src/__test__/wallet.mock.ts b/packages/core/src/__test__/wallet.mock.ts index 51ac669..8295294 100644 --- a/packages/core/src/__test__/wallet.mock.ts +++ b/packages/core/src/__test__/wallet.mock.ts @@ -39,6 +39,11 @@ export const KeplrMock: WalletMock = { isPreauthorized: async () => false, } +export const FordefiMock: WalletMock = { + ...wallets.find((w) => w.id === "fordefi")!, + isPreauthorized: async () => false, +} + export function makePreAuthorized(isPreauthorized: boolean) { return (wallet: WalletMock) => ({ ...wallet, diff --git a/packages/core/src/discovery.ts b/packages/core/src/discovery.ts index 21f1176..abf9257 100644 --- a/packages/core/src/discovery.ts +++ b/packages/core/src/discovery.ts @@ -92,6 +92,15 @@ const wallets: WalletProvider[] = [ edge: "https://microsoftedge.microsoft.com/addons/detail/keplr/ocodgmmffbkkeecmadcijjhkmeohinei", }, }, + { + id: "fordefi", + name: "Fordefi", + icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzEzNDk0XzY2MjU0KSI+CjxwYXRoIGQ9Ik0xMC44NzY5IDE1LjYzNzhIMS41VjE4LjM5OUMxLjUgMTkuODAxMyAyLjYzNDQ3IDIwLjkzOCA0LjAzMzkyIDIwLjkzOEg4LjI0OTkyTDEwLjg3NjkgMTUuNjM3OFoiIGZpbGw9IiM3OTk0RkYiLz4KPHBhdGggZD0iTTEuNSA5Ljc3NTUxSDE5LjA1MTZMMTcuMDEzOSAxMy44NzExSDEuNVY5Ljc3NTUxWiIgZmlsbD0iIzQ4NkRGRiIvPgo8cGF0aCBkPSJNNy42NTk5NiAzSDEuNTI0NDFWOC4wMDcwNEgyMi40NjEyVjNIMTYuMzI1NlY2LjczOTQ0SDE1LjA2MDZWM0g4LjkyNTAyVjYuNzM5NDRINy42NTk5NlYzWiIgZmlsbD0iIzVDRDFGQSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEzNDk0XzY2MjU0Ij4KPHJlY3Qgd2lkdGg9IjIxIiBoZWlnaHQ9IjE4IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMS41IDMpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==", + downloads: { + chrome: + "https://chrome.google.com/webstore/detail/fordefi/hcmehenccjdmfbojapcbcofkgdpbnlle", + }, + }, ] export default wallets