diff --git a/packages/core/src/__test__/main.test.ts b/packages/core/src/__test__/main.test.ts index 50d3830..8dd0500 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, + OKXMock, UnknownWalletAMock, UnknownWalletBMock, makePreAuthorized, @@ -31,11 +32,13 @@ describe("getAvailableWallets()", () => { }, starknet: ArgentXMock, "starknet-braavos": BraavosMock, + starknet_okxwallet: OKXMock, }) const availableWallets = await sn.getAvailableWallets() - expect(availableWallets.length).toBe(2) + expect(availableWallets.length).toBe(3) expect(availableWallets).toContainEqual(ArgentXMock) expect(availableWallets).toContainEqual(BraavosMock) + expect(availableWallets).toContainEqual(OKXMock) }) it("should return one injected wallet", async () => { const sn = getWallet({ @@ -110,16 +113,19 @@ describe("getPreAuthorizedWallets()", () => { const sn = getWallet({ "starknet-argent": makePreAuthorized(true)(ArgentXMock), "starknet-braavos": makePreAuthorized(true)(BraavosMock), + starknet_okxwallet: makePreAuthorized(true)(OKXMock), }) const preauthorizedWallets = await sn.getPreAuthorizedWallets() - expect(preauthorizedWallets.length).toBe(2) + expect(preauthorizedWallets.length).toBe(3) 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) }) 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), }) const preauthorizedWallets = await sn.getPreAuthorizedWallets() expect(preauthorizedWallets.length).toBe(1) @@ -131,8 +137,9 @@ describe("getDiscoveryWallets()", () => { it("should return all discovery wallets", async () => { const sn = getWallet({}) const discoveryWallets = await sn.getDiscoveryWallets() - expect(discoveryWallets.length).toBe(2) + expect(discoveryWallets.length).toBe(3) 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) }) }) diff --git a/packages/core/src/__test__/storage.test.ts b/packages/core/src/__test__/storage.test.ts index def4c4b..ee9f8a7 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, + OKXMock, UnknownWalletAMock, UnknownWalletBMock, makeConnected, @@ -48,6 +49,7 @@ describe("getLastConnectedWallet()", () => { { "starknet-argentX": makePreAuthorized(false)(ArgentXMock), "starknet-braavos": makePreAuthorized(false)(BraavosMock), + starknet_okxwallet: makePreAuthorized(false)(OKXMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -61,6 +63,7 @@ describe("getLastConnectedWallet()", () => { { "starknet-argentX": makePreAuthorized(false)(ArgentXMock), "starknet-braavos": makePreAuthorized(true)(BraavosMock), + starknet_okxwallet: makePreAuthorized(false)(OKXMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -74,6 +77,7 @@ describe("getLastConnectedWallet()", () => { { "starknet-argentX": makePreAuthorized(true)(ArgentXMock), "starknet-braavos": makePreAuthorized(true)(BraavosMock), + starknet_okxwallet: makePreAuthorized(true)(OKXMock), }, mockStorageFunction({ "gsw-last": "braavos" }), ) @@ -84,6 +88,7 @@ describe("getLastConnectedWallet()", () => { const sn = getWallet({ "starknet-argentX": makeConnected(true)(ArgentXMock), "starknet-braavos": makeConnected(true)(BraavosMock), + starknet_okxwallet: makeConnected(true)(OKXMock), }) const lastConnectedWallet = await sn.getLastConnectedWallet() expect(lastConnectedWallet).toBe(null) @@ -108,6 +113,7 @@ describe("getLastConnectedWallet()", () => { { "starknet-argentX": makePreAuthorized(true)(ArgentXMock), "starknet-braavos": makePreAuthorized(true)(BraavosMock), + starknet_okxwallet: makePreAuthorized(true)(OKXMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -125,6 +131,7 @@ describe("getLastConnectedWallet()", () => { { "starknet-argentX": makePreAuthorized(true)(ArgentXMock), "starknet-braavos": makePreAuthorized(true)(BraavosMock), + starknet_okxwallet: makePreAuthorized(true)(OKXMock), }, mockStorageFunction({ "gsw-last": "braavos", diff --git a/packages/core/src/__test__/wallet.mock.ts b/packages/core/src/__test__/wallet.mock.ts index 5f2a14c..a8ea8e9 100644 --- a/packages/core/src/__test__/wallet.mock.ts +++ b/packages/core/src/__test__/wallet.mock.ts @@ -29,6 +29,11 @@ export const BraavosMock: WalletMock = { isPreauthorized: async () => false, } +export const OKXMock: WalletMock = { + ...wallets.find((w) => w.id === "okxwallet")!, + 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 b97e02e..e623843 100644 --- a/packages/core/src/discovery.ts +++ b/packages/core/src/discovery.ts @@ -6,6 +6,7 @@ export type WalletProvider = { | { chrome?: `https://chrome.google.com/webstore/detail/${string}` } | { firefox?: `https://addons.mozilla.org/en-US/firefox/addon/${string}` } | { edge?: `https://microsoftedge.microsoft.com/addons/detail/${string}` } + | { safari?: `https://apps.apple.com/us/app/${string}` } } const wallets: WalletProvider[] = [ @@ -17,7 +18,7 @@ const wallets: WalletProvider[] = [ chrome: "https://chrome.google.com/webstore/detail/argent-x-starknet-wallet/dlcobpjiigpikoobohmabehhmhfoodbb", firefox: "https://addons.mozilla.org/en-US/firefox/addon/argent-x", - edge: "https://microsoftedge.microsoft.com/addons/detail/argent-x/ajcicjlkibolbeaaagejfhnofogocgcj" + edge: "https://microsoftedge.microsoft.com/addons/detail/argent-x/ajcicjlkibolbeaaagejfhnofogocgcj", }, }, { @@ -31,6 +32,18 @@ const wallets: WalletProvider[] = [ edge: "https://microsoftedge.microsoft.com/addons/detail/braavos-wallet/hkkpjehhcnhgefhbdcgfkeegglpjchdc", }, }, + { + id: "okxwallet", + name: "OKX Wallet", + icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJDSURBVHgB7Zq9jtpAEMfHlhEgQLiioXEkoAGECwoKxMcTRHmC5E3IoyRPkPAEkI7unJYmTgEFTYwA8a3NTKScLnCHN6c9r1e3P2llWQy7M/s1Gv1twCP0ej37dDq9x+Zut1t3t9vZjDEHIiSRSPg4ZpDL5fxkMvn1cDh8m0wmfugfO53OoFQq/crn8wxfY9EymQyrVCqMfHvScZx1p9ls3pFxXBy/bKlUipGPrVbLuQqAfsCliq3zl0H84zwtjQrOw4Mt1W63P5LvBm2d+Xz+YzqdgkqUy+WgWCy+Mc/nc282m4FqLBYL+3g8fjDxenq72WxANZbLJeA13zDX67UDioL5ybXwafMYu64Ltn3bdDweQ5R97fd7GyhBQMipx4POeEDHIu2LfDdBIGGz+hJ9CQ1ABjoA2egAZPM6AgiCAEQhsi/C4jHyPA/6/f5NG3Ks2+3CYDC4aTccDrn6ojG54MnEvG00GoVmWLIRNZ7wTCwDHYBsdACy0QHIhiuRETxlICWpMMhGZHmqS8qH6JLyGegAZKMDkI0uKf8X4SWlaZo+Pp1bRrwlJU8ZKLIvUjKh0WiQ3sRUbNVq9c5Ebew7KEo2m/1p4jJ4qAmDaqDQBzj5XyiAT4VCQezJigAU+IDU+z8vJFnGWeC+bKQV/5VZ71FV6L7PA3gg3tXrdQ+DgLhC+75Wq3no69P3MC0NFQpx2lL04Ql9gHK1bRDjsSBIvScBnDTk1WrlGIZBorIDEYJj+rhdgnQ67VmWRe0zlplXl81vcyEt0rSoYDUAAAAASUVORK5CYII=", + downloads: { + chrome: + "https://chrome.google.com/webstore/detail/mcohilncbfahbmgdjkbpemcciiolgcge", + firefox: "https://addons.mozilla.org/en-US/firefox/addon/okexwallet", + edge: "https://microsoftedge.microsoft.com/addons/detail/%E6%AC%A7%E6%98%93-web3-%E9%92%B1%E5%8C%85/pbpjkcldjiffchgbbndmhojiacbgflha", + safari: "https://apps.apple.com/us/app/okx-wallet/id6463797825", + }, + }, ] export default wallets diff --git a/packages/ui/src/main.ts b/packages/ui/src/main.ts index 8b236a0..34eec3e 100644 --- a/packages/ui/src/main.ts +++ b/packages/ui/src/main.ts @@ -8,7 +8,7 @@ import sn, { export type { StarknetWindowObject, DisconnectOptions } from "get-starknet-core" -type StoreVersion = "chrome" | "firefox" | "edge" +type StoreVersion = "chrome" | "firefox" | "edge" | "safari" const ssrSafeWindow = typeof window !== "undefined" ? window : null @@ -28,6 +28,8 @@ function getStoreVersionFromBrowser(): StoreVersion | null { case "opera": // opera is chromium based case "vivaldi": // vivaldi is chromium based return "chrome" + case "safari": + return "safari" default: return null }