Skip to content

Commit

Permalink
feat(BREAKING): v5 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala authored and avimak committed Jun 20, 2023
1 parent 6777a83 commit abe5bf9
Show file tree
Hide file tree
Showing 7 changed files with 897 additions and 814 deletions.
2 changes: 1 addition & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface GetStarknetResult {
enable: (
wallet: StarknetWindowObject,
options?: {
starknetVersion?: "v3" | "v4"
starknetVersion?: "v4" | "v5"
},
) => Promise<ConnectedStarknetWindowObject>
// Disconnects from a wallet
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
"devDependencies": {
"c8": "^7.12.0",
"happy-dom": "^6.0.4",
"starknet": "^4.9.0",
"starknet": "^5.12.0",
"starknet4": "npm:starknet@4.22.0",
"typescript": "^4.6.4",
"vite": "^3.0.0",
"vite-plugin-dts": "^1.4.0",
"vitest": "^0.19.1"
},
"peerDependencies": {
"starknet": "^4.9.0"
"starknet": "^5.0.0"
},
"peerDependenciesMeta": {
"starknet": {
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/StarknetWindowObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { AccountInterface, ProviderInterface } from "starknet"
import type {
AccountInterface as AccountInterfaceV4,
ProviderInterface as ProviderInterfaceV4,
} from "starknet4"

export type AccountChangeEventHandler = (accounts: string[]) => void

Expand Down Expand Up @@ -86,16 +90,16 @@ export interface IStarknetWindowObject {
event: E["type"],
handleEvent: E["handler"],
) => void
account?: AccountInterface
provider?: ProviderInterface
account?: AccountInterface | AccountInterfaceV4
provider?: ProviderInterface | ProviderInterfaceV4
selectedAddress?: string
chainId?: string
}

export interface ConnectedStarknetWindowObject extends IStarknetWindowObject {
isConnected: true
account: AccountInterface
provider: ProviderInterface
account: AccountInterface | AccountInterfaceV4
provider: ProviderInterface | ProviderInterfaceV4
selectedAddress: string
chainId: string
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function getStarknet(
return firstPreAuthorizedWallet
},
enable: async (wallet, options) => {
await wallet.enable(options ?? { starknetVersion: "v4" })
await wallet.enable(options ?? { starknetVersion: "v5" })
if (!wallet.isConnected) {
throw new Error("Failed to connect to wallet")
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface GetStarknetResult {
enable: (
wallet: StarknetWindowObject,
options?: {
starknetVersion?: "v3" | "v4"
starknetVersion?: "v4" | "v5"
},
) => Promise<ConnectedStarknetWindowObject>
// Disconnects from a wallet
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const enableWithVersion = async (wallet: StarknetWindowObject | null) => {
if (!wallet) {
return null
}
return sn.enable(wallet, { starknetVersion: "v4" }).catch(() => null)
return sn.enable(wallet, { starknetVersion: "v5" }).catch(() => null)
}

export const connect = async ({
Expand Down
Loading

0 comments on commit abe5bf9

Please sign in to comment.