Skip to content

Commit

Permalink
feat: add fordefi wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbellmas committed Nov 27, 2024
1 parent 5a1c0c5 commit 8fe23ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/core/src/__test__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { mockStorageFunction } from "./storage.mock"
import {
ArgentXMock,
BraavosMock,
FordefiMock,
KeplrMock,
OKXMock,
UnknownWalletAMock,
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -118,20 +121,23 @@ 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({
"starknet-argent": makePreAuthorized(true)(ArgentXMock),
"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)
Expand All @@ -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)
})
})
7 changes: 7 additions & 0 deletions packages/core/src/__test__/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { mockStorageFunction } from "./storage.mock"
import {
ArgentXMock,
BraavosMock,
FordefiMock,
KeplrMock,
OKXMock,
UnknownWalletAMock,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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" }),
)
Expand All @@ -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)
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/__test__/wallet.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8fe23ee

Please sign in to comment.