From d8d479bb8e6d41679085abda2a5d011d33781809 Mon Sep 17 00:00:00 2001 From: Abraham Makovetsky Date: Thu, 14 Dec 2023 15:14:57 +0200 Subject: [PATCH] chore: removed `isPreauthorized`, `selectedAddress`, `chainId`, `isConnected` --- packages/core/src/StarknetWindowObject.ts | 48 +++++------ packages/core/src/__test__/main.test.ts | 30 +++---- packages/core/src/__test__/storage.test.ts | 32 +++---- packages/core/src/__test__/wallet.mock.ts | 65 ++++++++++----- packages/core/src/main.ts | 97 +++++++++------------- packages/core/src/types.ts | 42 ++++++++++ packages/core/src/utils.ts | 9 +- packages/core/src/wallet/filter.ts | 15 +++- packages/core/src/wallet/isWalletObject.ts | 3 - packages/ui/src/main.ts | 10 +-- packages/ui/src/modal/Modal.svelte | 4 +- packages/ui/src/modal/index.ts | 20 ++--- 12 files changed, 212 insertions(+), 163 deletions(-) create mode 100644 packages/core/src/types.ts diff --git a/packages/core/src/StarknetWindowObject.ts b/packages/core/src/StarknetWindowObject.ts index 9c659a8..dd0dc7c 100644 --- a/packages/core/src/StarknetWindowObject.ts +++ b/packages/core/src/StarknetWindowObject.ts @@ -1,3 +1,12 @@ +export enum StarknetChainId { + SN_MAIN = "0x534e5f4d41494e", + SN_GOERLI = "0x534e5f474f45524c49", +} + +export enum Permission { + Accounts = "accounts", +} + type FELT = string type Call = { @@ -51,7 +60,10 @@ export interface TypedData { export type AccountChangeEventHandler = (accounts?: string[]) => void -export type NetworkChangeEventHandler = (network?: string) => void +export type NetworkChangeEventHandler = ( + chainId?: StarknetChainId, + accounts?: string[], +) => void export type WalletEvents = | { @@ -205,6 +217,11 @@ export interface SwitchStarknetChainParameters { } export type RpcMessage = + | { + type: "wallet_getPermissions" + params: never + result: Permission[] + } | { type: "wallet_requestAccounts" params?: RequestAccountsParameters @@ -225,6 +242,11 @@ export type RpcMessage = params: SwitchStarknetChainParameters result: boolean } + | { + type: "wallet_requestChainId" + params: never + result: StarknetChainId // returns the chain ID of the current network + } | { type: "starknet_addInvokeTransaction" params: AddInvokeTransactionParameters @@ -246,7 +268,7 @@ export type RpcMessage = result: string[] } -export interface IStarknetWindowObject { +export interface StarknetWindowObject { id: string name: string version: string @@ -254,7 +276,6 @@ export interface IStarknetWindowObject { request: ( call: Omit, ) => Promise - isPreauthorized: () => Promise on: ( event: E["type"], handleEvent: E["handler"], @@ -263,31 +284,10 @@ export interface IStarknetWindowObject { event: E["type"], handleEvent: E["handler"], ) => void - selectedAddress?: string - chainId?: string - isConnected: boolean -} - -export interface ConnectedStarknetWindowObject extends IStarknetWindowObject { - selectedAddress: string - chainId: string - isConnected: true } -export interface DisconnectedStarknetWindowObject - extends IStarknetWindowObject { - isConnected: false -} - -export type StarknetWindowObject = - | ConnectedStarknetWindowObject - | DisconnectedStarknetWindowObject - declare global { interface Window { - starknet?: StarknetWindowObject - starknet_braavos?: StarknetWindowObject - starknet_argentX?: StarknetWindowObject [key: `starknet_${string}`]: StarknetWindowObject | undefined } } diff --git a/packages/core/src/__test__/main.test.ts b/packages/core/src/__test__/main.test.ts index 50d3830..a98faf9 100644 --- a/packages/core/src/__test__/main.test.ts +++ b/packages/core/src/__test__/main.test.ts @@ -3,9 +3,9 @@ import { mockStorageFunction } from "./storage.mock" import { ArgentXMock, BraavosMock, + makeAuthorized, UnknownWalletAMock, UnknownWalletBMock, - makePreAuthorized, } from "./wallet.mock" import { describe, expect, it } from "vitest" @@ -105,25 +105,25 @@ describe("getAvailableWallets()", () => { }) }) -describe("getPreAuthorizedWallets()", () => { - it("should return all preauthorized wallets", async () => { +describe("getAuthorizedWallets()", () => { + it("should return all authorized wallets", async () => { const sn = getWallet({ - "starknet-argent": makePreAuthorized(true)(ArgentXMock), - "starknet-braavos": makePreAuthorized(true)(BraavosMock), + "starknet-argent": makeAuthorized(true)(ArgentXMock), + "starknet-braavos": makeAuthorized(true)(BraavosMock), }) - const preauthorizedWallets = await sn.getPreAuthorizedWallets() - expect(preauthorizedWallets.length).toBe(2) - expect(preauthorizedWallets.map((w) => w.id)).contains(ArgentXMock.id) - expect(preauthorizedWallets.map((w) => w.id)).contains(BraavosMock.id) + const authorizedWallets = await sn.getAuthorizedWallets() + expect(authorizedWallets.length).toBe(2) + expect(authorizedWallets.map((w) => w.id)).contains(ArgentXMock.id) + expect(authorizedWallets.map((w) => w.id)).contains(BraavosMock.id) }) - it("should return one preauthorized wallet", async () => { + it("should return one authorized wallet", async () => { const sn = getWallet({ - "starknet-argent": makePreAuthorized(true)(ArgentXMock), - "starknet-braavos": makePreAuthorized(false)(BraavosMock), + "starknet-argent": makeAuthorized(true)(ArgentXMock), + "starknet-braavos": makeAuthorized(false)(BraavosMock), }) - const preauthorizedWallets = await sn.getPreAuthorizedWallets() - expect(preauthorizedWallets.length).toBe(1) - expect(preauthorizedWallets.map((w) => w.id)).contains(ArgentXMock.id) + const authorizedWallets = await sn.getAuthorizedWallets() + expect(authorizedWallets.length).toBe(1) + expect(authorizedWallets.map((w) => w.id)).contains(ArgentXMock.id) }) }) diff --git a/packages/core/src/__test__/storage.test.ts b/packages/core/src/__test__/storage.test.ts index def4c4b..2d5727e 100644 --- a/packages/core/src/__test__/storage.test.ts +++ b/packages/core/src/__test__/storage.test.ts @@ -3,10 +3,10 @@ import { mockStorageFunction } from "./storage.mock" import { ArgentXMock, BraavosMock, + makeAuthorized, + makeConnected, UnknownWalletAMock, UnknownWalletBMock, - makeConnected, - makePreAuthorized, } from "./wallet.mock" import { describe, expect, it } from "vitest" @@ -24,8 +24,8 @@ function getWallet( describe("getLastConnectedWallet()", () => { it("should return null if no last wallet set", async () => { const sn = getWallet({ - "starknet-walletA": makePreAuthorized(false)(UnknownWalletAMock), - "starknet-walletB": makePreAuthorized(false)(UnknownWalletBMock), + "starknet-walletA": makeAuthorized(false)(UnknownWalletAMock), + "starknet-walletB": makeAuthorized(false)(UnknownWalletBMock), }) const lastConnectedWallet = await sn.getLastConnectedWallet() expect(lastConnectedWallet).toBe(null) @@ -33,8 +33,8 @@ describe("getLastConnectedWallet()", () => { it("should return null if the last connected wallet is not available", async () => { const sn = getWallet( { - "starknet-walletA": makePreAuthorized(false)(UnknownWalletAMock), - "starknet-walletB": makePreAuthorized(false)(UnknownWalletBMock), + "starknet-walletA": makeAuthorized(false)(UnknownWalletAMock), + "starknet-walletB": makeAuthorized(false)(UnknownWalletBMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -46,8 +46,8 @@ describe("getLastConnectedWallet()", () => { it("should not return the last connected wallet if not preauthorized", async () => { const sn = getWallet( { - "starknet-argentX": makePreAuthorized(false)(ArgentXMock), - "starknet-braavos": makePreAuthorized(false)(BraavosMock), + "starknet-argentX": makeAuthorized(false)(ArgentXMock), + "starknet-braavos": makeAuthorized(false)(BraavosMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -59,8 +59,8 @@ describe("getLastConnectedWallet()", () => { it("should return the last connected wallet if still preauthorized", async () => { const sn = getWallet( { - "starknet-argentX": makePreAuthorized(false)(ArgentXMock), - "starknet-braavos": makePreAuthorized(true)(BraavosMock), + "starknet-argentX": makeAuthorized(false)(ArgentXMock), + "starknet-braavos": makeAuthorized(true)(BraavosMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -72,8 +72,8 @@ describe("getLastConnectedWallet()", () => { it("should return the last connected wallet when last is available", async () => { const sn = getWallet( { - "starknet-argentX": makePreAuthorized(true)(ArgentXMock), - "starknet-braavos": makePreAuthorized(true)(BraavosMock), + "starknet-argentX": makeAuthorized(true)(ArgentXMock), + "starknet-braavos": makeAuthorized(true)(BraavosMock), }, mockStorageFunction({ "gsw-last": "braavos" }), ) @@ -106,8 +106,8 @@ describe("getLastConnectedWallet()", () => { it("should default disable", async () => { const sn = getWallet( { - "starknet-argentX": makePreAuthorized(true)(ArgentXMock), - "starknet-braavos": makePreAuthorized(true)(BraavosMock), + "starknet-argentX": makeAuthorized(true)(ArgentXMock), + "starknet-braavos": makeAuthorized(true)(BraavosMock), }, mockStorageFunction({ "gsw-last": "braavos", @@ -123,8 +123,8 @@ describe("getLastConnectedWallet()", () => { it("should disable with clearLastWallet", async () => { const sn = getWallet( { - "starknet-argentX": makePreAuthorized(true)(ArgentXMock), - "starknet-braavos": makePreAuthorized(true)(BraavosMock), + "starknet-argentX": makeAuthorized(true)(ArgentXMock), + "starknet-braavos": makeAuthorized(true)(BraavosMock), }, mockStorageFunction({ "gsw-last": "braavos", diff --git a/packages/core/src/__test__/wallet.mock.ts b/packages/core/src/__test__/wallet.mock.ts index ec9ac09..4a54248 100644 --- a/packages/core/src/__test__/wallet.mock.ts +++ b/packages/core/src/__test__/wallet.mock.ts @@ -1,45 +1,72 @@ -import type { StarknetWindowObject } from "../StarknetWindowObject" +import { Permission, StarknetWindowObject } from "../StarknetWindowObject" import wallets from "../discovery" -type WalletMock = Pick< - StarknetWindowObject, - "id" | "name" | "icon" | "isPreauthorized" -> +type WalletMock = Pick export const UnknownWalletAMock: WalletMock = { id: "wallet-a", name: "Wallet A", icon: "https://avatars.dicebear.com/api/initials/Wallet%20A.svg", - isPreauthorized: async () => false, + request: async () => false, } export const UnknownWalletBMock: WalletMock = { id: "wallet-b", name: "Wallet B", icon: "https://avatars.dicebear.com/api/initials/Wallet%20B.svg", - isPreauthorized: async () => false, + request: async () => false, } export const ArgentXMock: WalletMock = { ...wallets.find((w) => w.id === "argentX")!, - isPreauthorized: async () => false, + request: async (request) => { + switch (request.type) { + case "wallet_getPermissions": + return [] + default: + return undefined as any + } + }, } export const BraavosMock: WalletMock = { ...wallets.find((w) => w.id === "braavos")!, - isPreauthorized: async () => false, + request: async (request) => { + switch (request.type) { + case "wallet_getPermissions": + return [] + default: + return undefined as any + } + }, } -export function makePreAuthorized(isPreauthorized: boolean) { - return (wallet: WalletMock) => ({ - ...wallet, - isPreauthorized: async () => isPreauthorized, - }) +export function makeAuthorized(authorized: boolean) { + return (wallet: WalletMock) => + ({ + ...wallet, + request: async (request) => { + switch (request.type) { + case "wallet_getPermissions": + return authorized ? [Permission.Accounts] : [] + default: + return wallet.request(request) + } + }, + } as WalletMock) } export function makeConnected(isConnected: boolean) { - return (wallet: WalletMock) => ({ - ...makePreAuthorized(true)(wallet), - request: async () => [], - isConnected, - }) + return (wallet: WalletMock) => { + return { + ...makeAuthorized(true)(wallet), + request: async ({ type }) => { + switch (type) { + case "wallet_getPermissions": + return isConnected ? [Permission.Accounts] : [] + default: + return [] + } + }, + } as WalletMock + } } diff --git a/packages/core/src/main.ts b/packages/core/src/main.ts index 517808c..138c9a1 100644 --- a/packages/core/src/main.ts +++ b/packages/core/src/main.ts @@ -1,44 +1,42 @@ -import type { - ConnectedStarknetWindowObject, - RequestAccountsParameters, - StarknetWindowObject, -} from "./StarknetWindowObject" -import discovery, { WalletProvider } from "./discovery" -import { IStorageWrapper, LocalStorageWrapper } from "./localStorageStore" +import { Permission, type StarknetWindowObject } from "./StarknetWindowObject" +import discovery, { type WalletProvider } from "./discovery" +import { LocalStorageWrapper } from "./localStorageStore" +import type { GetStarknetOptions, GetStarknetResult } from "./types" import { pipe } from "./utils" -import { FilterList, filterBy, filterByPreAuthorized } from "./wallet/filter" +import { filterBy, filterByAuthorized } from "./wallet/filter" import { isWalletObj } from "./wallet/isWalletObject" import { scanObjectForWallets } from "./wallet/scan" -import { Sort, sortBy } from "./wallet/sort" +import { sortBy } from "./wallet/sort" export type { AccountChangeEventHandler, - AddStarknetChainParameters, - ConnectedStarknetWindowObject, - NetworkChangeEventHandler, - RpcMessage, - StarknetWindowObject, - SwitchStarknetChainParameters, - WalletEvents, - WatchAssetParameters, - DisconnectedStarknetWindowObject, - IStarknetWindowObject, - RequestAccountsParameters, AddDeclareTransactionParameters, AddDeclareTransactionResult, AddDeployAccountTransactionParameters, AddDeployAccountTransactionResult, AddInvokeTransactionParameters, AddInvokeTransactionResult, + AddStarknetChainParameters, + NetworkChangeEventHandler, + RequestAccountsParameters, + RpcMessage, + StarknetChainId, + StarknetWindowObject, + SwitchStarknetChainParameters, TypedData, + WalletEvents, + WatchAssetParameters, } from "./StarknetWindowObject" -export type { WalletProvider } from "./discovery" -export interface GetStarknetOptions { - windowObject: Record - isWalletObject: (wallet: any) => boolean - storageFactoryImplementation: (name: string) => IStorageWrapper -} +export { Permission } from "./StarknetWindowObject" + +export type { + DisconnectOptions, + GetStarknetOptions, + GetStarknetResult, + GetWalletOptions, + WalletProvider, +} from "./types" const ssrSafeWindow = typeof window !== "undefined" ? window : {} @@ -48,31 +46,6 @@ const defaultOptions: GetStarknetOptions = { storageFactoryImplementation: (name: string) => new LocalStorageWrapper(name), } -export interface GetWalletOptions { - sort?: Sort - include?: FilterList - exclude?: FilterList -} - -export interface DisconnectOptions { - clearLastWallet?: boolean -} -interface GetStarknetResult { - getAvailableWallets: ( - options?: GetWalletOptions, - ) => Promise // Returns all wallets available in the window object - getPreAuthorizedWallets: ( - options?: GetWalletOptions, - ) => Promise // Returns only preauthorized wallets available in the window object - getDiscoveryWallets: (options?: GetWalletOptions) => Promise // Returns all wallets in existence (from discovery file) - getLastConnectedWallet: () => Promise // Returns the last wallet connected when it's still connected - enable: ( - wallet: StarknetWindowObject, - options?: RequestAccountsParameters, - ) => Promise // Connects to a wallet - disconnect: (options?: DisconnectOptions) => Promise // Disconnects from a wallet -} - export function getStarknet( options: Partial = {}, ): GetStarknetResult { @@ -93,13 +66,13 @@ export function getStarknet( (_) => sortBy(_, options.sort), )(availableWallets) }, - getPreAuthorizedWallets: async (options = {}) => { + getAuthorizedWallets: async (options = {}) => { const availableWallets = scanObjectForWallets( windowObject, isWalletObject, ) return pipe( - (_) => filterByPreAuthorized(_), + (_) => filterByAuthorized(_), (_) => filterBy(_, options), (_) => sortBy(_, options.sort), )(availableWallets) @@ -116,20 +89,28 @@ export function getStarknet( const lastConnectedWallet = allWallets.find( (w) => w.id === lastConnectedWalletId, ) - const [firstPreAuthorizedWallet] = await filterByPreAuthorized( + const [firstAuthorizedWallet] = await filterByAuthorized( lastConnectedWallet ? [lastConnectedWallet] : [], ) - if (!firstPreAuthorizedWallet) { + if (!firstAuthorizedWallet) { lastConnectedStore.delete() return null } - return firstPreAuthorizedWallet + return firstAuthorizedWallet }, enable: async (wallet, options) => { - await wallet.request({ type: "wallet_requestAccounts", params: options }) - if (!wallet.isConnected) { + await wallet.request({ + type: "wallet_requestAccounts", + params: options, + }) + + // check for permissions + const permissions = (await wallet.request({ + type: "wallet_getPermissions", + })) as Permission[] + if (!permissions?.includes(Permission.Accounts)) { throw new Error("Failed to connect to wallet") } lastConnectedStore.set(wallet.id) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts new file mode 100644 index 0000000..7c4f935 --- /dev/null +++ b/packages/core/src/types.ts @@ -0,0 +1,42 @@ +import { IStorageWrapper } from "./localStorageStore" +import { Sort } from "./wallet/sort" +import { FilterList } from "./wallet/filter" +import { + RequestAccountsParameters, + StarknetWindowObject, +} from "./StarknetWindowObject" +import { WalletProvider } from "./discovery" + +export type { WalletProvider } from "./discovery" + +export interface GetStarknetOptions { + windowObject: Record + isWalletObject: (wallet: any) => boolean + storageFactoryImplementation: (name: string) => IStorageWrapper +} + +export interface GetWalletOptions { + sort?: Sort + include?: FilterList + exclude?: FilterList +} + +export interface DisconnectOptions { + clearLastWallet?: boolean +} + +export interface GetStarknetResult { + getAvailableWallets: ( + options?: GetWalletOptions, + ) => Promise // Returns all wallets available in the window object + getAuthorizedWallets: ( + options?: GetWalletOptions, + ) => Promise // Returns only preauthorized wallets available in the window object + getDiscoveryWallets: (options?: GetWalletOptions) => Promise // Returns all wallets in existence (from discovery file) + getLastConnectedWallet: () => Promise // Returns the last wallet connected when it's still connected + enable: ( + wallet: StarknetWindowObject, + options?: RequestAccountsParameters, + ) => Promise // Connects to a wallet + disconnect: (options?: DisconnectOptions) => Promise // Disconnects from a wallet +} diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index e4555dd..6f159e2 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -13,8 +13,7 @@ export const shuffle = (arr: T): T => { } type AllowPromise = Promise | T -export function pipe( - ...fns: Array<(arg: T) => AllowPromise> -): (arg: T) => Promise { - return (arg: T) => fns.reduce((acc, fn) => acc.then(fn), Promise.resolve(arg)) -} +export const pipe = + (...fns: Array<(arg: T) => AllowPromise>): ((arg: T) => Promise) => + (arg: T) => + fns.reduce>((acc, fn) => acc.then(fn), Promise.resolve(arg)) diff --git a/packages/core/src/wallet/filter.ts b/packages/core/src/wallet/filter.ts index 8111bbb..d4460d4 100644 --- a/packages/core/src/wallet/filter.ts +++ b/packages/core/src/wallet/filter.ts @@ -1,5 +1,5 @@ -import { StarknetWindowObject } from "../StarknetWindowObject" -import { WalletProvider } from "../discovery" +import { Permission, type StarknetWindowObject } from "../StarknetWindowObject" +import type { WalletProvider } from "../discovery" export type FilterList = string[] interface FilterByOptions { @@ -28,11 +28,18 @@ export function filterBy( * filters given wallets array, return only preAuthorized instances * @param wallets */ -export const filterByPreAuthorized = async ( +export const filterByAuthorized = async ( wallets: StarknetWindowObject[], ): Promise => { const preAuthResponses = await Promise.all( - wallets.map((w) => w.isPreauthorized().catch(() => false)), + wallets.map((w) => + w + .request({ type: "wallet_getPermissions" }) + .then((result) => + (result as Permission[])?.includes(Permission.Accounts), + ) + .catch(() => false), + ), ) return wallets.filter((_, i) => preAuthResponses[i]) } diff --git a/packages/core/src/wallet/isWalletObject.ts b/packages/core/src/wallet/isWalletObject.ts index 92696c8..471db3b 100644 --- a/packages/core/src/wallet/isWalletObject.ts +++ b/packages/core/src/wallet/isWalletObject.ts @@ -5,9 +5,6 @@ export const isWalletObj = (wallet: any): boolean => { [ // wallet's must have methods/members, see IStarknetWindowObject "request", - "isConnected", - "provider", - "isPreauthorized", "on", "off", "version", diff --git a/packages/ui/src/main.ts b/packages/ui/src/main.ts index 45085e2..65f130a 100644 --- a/packages/ui/src/main.ts +++ b/packages/ui/src/main.ts @@ -56,15 +56,15 @@ export const connect = async ({ modalTheme, ...restOptions }: ConnectOptions = {}): Promise => { - const preAuthorizedWallets = await sn.getPreAuthorizedWallets({ + const authorizedWallets = await sn.getAuthorizedWallets({ ...restOptions, }) const lastWallet = await sn.getLastConnectedWallet() if (modalMode === "neverAsk") { const wallet = - preAuthorizedWallets.find((w) => w.id === lastWallet?.id) ?? - preAuthorizedWallets[0] // at this point pre-authorized is already sorted + authorizedWallets.find((w) => w.id === lastWallet?.id) ?? + authorizedWallets[0] // at this point authorized is already sorted // return `wallet` even if it's null/undefined since we aren't allowed // to show any "connect" related UI @@ -78,7 +78,7 @@ export const connect = async ({ lastWallet ) { const wallet = - preAuthorizedWallets.find((w) => w.id === lastWallet?.id) ?? + authorizedWallets.find((w) => w.id === lastWallet?.id) ?? (installedWallets.length === 1 ? installedWallets[0] : undefined) if (wallet) { return enableWithVersion(wallet) @@ -97,7 +97,7 @@ export const connect = async ({ return show({ lastWallet, - preAuthorizedWallets, + authorizedWallets, installedWallets, discoveryWallets: discoveryWalletsByStoreVersion, enable: enableWithVersion, diff --git a/packages/ui/src/modal/Modal.svelte b/packages/ui/src/modal/Modal.svelte index ed18584..6cf8ad0 100644 --- a/packages/ui/src/modal/Modal.svelte +++ b/packages/ui/src/modal/Modal.svelte @@ -6,7 +6,7 @@ const ssrSafeWindow = typeof window !== "undefined" ? window : null export let lastWallet: StarknetWindowObject | null = null export let installedWallets: StarknetWindowObject[] = [] - export let preAuthorizedWallets: StarknetWindowObject[] = [] + export let authorizedWallets: StarknetWindowObject[] = [] export let discoveryWallets: WalletProviderWithStoreVersion[] = [] export let callback: ( value: StarknetWindowObject | null, @@ -50,7 +50,7 @@ const wallets = [ lastWallet, - ...preAuthorizedWallets, + ...authorizedWallets, ...installedWallets, ].filter(Boolean) diff --git a/packages/ui/src/modal/index.ts b/packages/ui/src/modal/index.ts index b61f292..05a4b2e 100644 --- a/packages/ui/src/modal/index.ts +++ b/packages/ui/src/modal/index.ts @@ -1,9 +1,5 @@ import Modal from "./Modal.svelte" -import type { - ConnectedStarknetWindowObject, - StarknetWindowObject, - WalletProvider, -} from "get-starknet-core" +import type { StarknetWindowObject, WalletProvider } from "get-starknet-core" export interface WalletProviderWithStoreVersion extends Omit { @@ -21,17 +17,17 @@ export default async function show({ discoveryWallets, installedWallets, lastWallet, - preAuthorizedWallets, + authorizedWallets, enable, modalOptions, }: { lastWallet?: StarknetWindowObject installedWallets?: StarknetWindowObject[] - preAuthorizedWallets?: StarknetWindowObject[] + authorizedWallets?: StarknetWindowObject[] discoveryWallets?: WalletProviderWithStoreVersion[] enable?: ( wallet: StarknetWindowObject | null, - ) => Promise + ) => Promise modalOptions?: { theme?: "light" | "dark" | "system" } @@ -39,15 +35,15 @@ export default async function show({ return new Promise((resolve) => { // make sure wallets are not shown twice const fixedWallets = [lastWallet].filter(Boolean) - preAuthorizedWallets = excludeWallets(preAuthorizedWallets, fixedWallets) + authorizedWallets = excludeWallets(authorizedWallets, fixedWallets) installedWallets = excludeWallets(installedWallets, [ ...fixedWallets, - ...preAuthorizedWallets, + ...authorizedWallets, ]) discoveryWallets = excludeWallets(discoveryWallets, [ ...fixedWallets, ...installedWallets, - ...preAuthorizedWallets, + ...authorizedWallets, ]) const modal = new Modal({ @@ -60,7 +56,7 @@ export default async function show({ }, lastWallet, installedWallets, - preAuthorizedWallets, + authorizedWallets, discoveryWallets, theme: modalOptions?.theme === "system" ? null : modalOptions?.theme ?? null,