diff --git a/packages/core/src/__test__/main.test.ts b/packages/core/src/__test__/main.test.ts index 64e7a61..b38dfdb 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("getAuthorizedWallets()", () => { "starknet-braavos": makeAuthorized(true)(BraavosMock), starknet_okxwallet: makeAuthorized(true)(OKXMock), starknet_keplr: makeAuthorized(true)(KeplrMock), + starknet_fordefi: makeAuthorized(true)(FordefiMock), }) const preauthorizedWallets = await sn.getAuthorizedWallets() - 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 authorized wallet", async () => { const sn = getWallet({ @@ -132,6 +137,7 @@ describe("getAuthorizedWallets()", () => { "starknet-braavos": makeAuthorized(false)(BraavosMock), starknet_okxwallet: makeAuthorized(false)(OKXMock), starknet_keplr: makeAuthorized(false)(KeplrMock), + starknet_fordefi: makeAuthorized(false)(FordefiMock), }) const authorizedWallets = await sn.getAuthorizedWallets() expect(authorizedWallets.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 d7c1e51..f4db405 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": makeAuthorized(false)(BraavosMock), starknet_okxwallet: makeAuthorized(false)(OKXMock), starknet_keplr: makeAuthorized(false)(KeplrMock), + starknet_fordefi: makeAuthorized(false)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -67,6 +69,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makeAuthorized(true)(BraavosMock), starknet_okxwallet: makeAuthorized(false)(OKXMock), starknet_keplr: makeAuthorized(false)(KeplrMock), + starknet_fordefi: makeAuthorized(false)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -82,6 +85,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makeAuthorized(true)(BraavosMock), starknet_okxwallet: makeAuthorized(true)(OKXMock), starknet_keplr: makeAuthorized(true)(KeplrMock), + starknet_fordefi: makeAuthorized(true)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos" }), ) @@ -94,6 +98,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makeConnected(true)(BraavosMock), starknet_okxwallet: makeConnected(true)(OKXMock), starknet_keplr: makeAuthorized(true)(KeplrMock), + starknet_fordefi: makeAuthorized(true)(FordefiMock), }) const lastConnectedWallet = await sn.getLastConnectedWallet() expect(lastConnectedWallet).toBe(null) @@ -120,6 +125,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makeAuthorized(true)(BraavosMock), starknet_okxwallet: makeAuthorized(true)(OKXMock), starknet_keplr: makeAuthorized(true)(KeplrMock), + starknet_fordefi: makeAuthorized(true)(FordefiMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -139,6 +145,7 @@ describe("getLastConnectedWallet()", () => { "starknet-braavos": makeAuthorized(true)(BraavosMock), starknet_okxwallet: makeAuthorized(true)(OKXMock), starknet_keplr: makeAuthorized(true)(KeplrMock), + starknet_fordefi: makeAuthorized(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 eb881a7..cf9701d 100644 --- a/packages/core/src/__test__/wallet.mock.ts +++ b/packages/core/src/__test__/wallet.mock.ts @@ -80,6 +80,21 @@ export const KeplrMock: StarknetWindowObject = { off: () => {}, } +export const FordefiMock: StarknetWindowObject = { + ...wallets.find((w) => w.id === "fordefi")!, + version: "0.0.0", + request: async (request) => { + switch (request.type) { + case "wallet_getPermissions": + return [] + default: + return undefined as any + } + }, + on: () => {}, + off: () => {}, +} + export function makeAuthorized(authorized: boolean) { return (wallet: StarknetWindowObject) => ({ diff --git a/packages/core/src/discovery.ts b/packages/core/src/discovery.ts index b43273b..bbe671e 100644 --- a/packages/core/src/discovery.ts +++ b/packages/core/src/discovery.ts @@ -93,6 +93,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