Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate starknet types #224

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"dev": "vite build --watch",
"test": "vitest"
},
"dependencies": {
"starknet-types": "^0.0.4"
},
"devDependencies": {
"c8": "^7.12.0",
"happy-dom": "^6.0.4",
Expand Down
24 changes: 0 additions & 24 deletions packages/core/src/StarknetWindowObject.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/core/src/__test__/wallet.mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { StarknetWindowObject } from "../StarknetWindowObject"
import wallets from "../discovery"
import { Permission } from "../rpcMessage"
import type { Permission, StarknetWindowObject } from "starknet-types"

tabaktoni marked this conversation as resolved.
Show resolved Hide resolved
type WalletMock = Pick<StarknetWindowObject, "id" | "name" | "icon" | "request">

Expand Down
21 changes: 11 additions & 10 deletions packages/core/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { type StarknetWindowObject } from "./StarknetWindowObject"
import discovery, { type WalletProvider } from "./discovery"
import { LocalStorageWrapper } from "./localStorageStore"
import { Permission } from "./rpcMessage"
import type { GetStarknetOptions, GetStarknetResult } from "./types"
import { pipe } from "./utils"
import { filterBy, filterByAuthorized } from "./wallet/filter"
import { isWalletObj } from "./wallet/isWalletObject"
import { scanObjectForWallets } from "./wallet/scan"
import { sortBy } from "./wallet/sort"

export type { StarknetWindowObject } from "./StarknetWindowObject"
import { Permission, type StarknetWindowObject } from "starknet-types"

export type {
StarknetWindowObject,
AddDeclareTransactionParameters,
AddDeclareTransactionResult,
AddDeployAccountTransactionParameters,
Expand All @@ -29,16 +27,13 @@ export type {
IsParamsOptional,
RpcTypeToMessageMap,
RequestFnCall,
} from "./rpcMessage"

export type {
WalletEvents,
AccountChangeEventHandler,
NetworkChangeEventHandler,
WalletEventHandlers,
} from "./walletEvents"
WalletEvents,
} from "starknet-types"

export { StarknetChainId, Permission } from "./rpcMessage"
export { StarknetChainId, Permission } from "starknet-types"

export { scanObjectForWallets } from "./wallet/scan"
export { isWalletObj } from "./wallet/isWalletObject"
Expand All @@ -59,6 +54,12 @@ const defaultOptions: GetStarknetOptions = {
storageFactoryImplementation: (name: string) => new LocalStorageWrapper(name),
}

declare global {
interface Window {
[key: `starknet_${string}`]: StarknetWindowObject | undefined
}
}

export function getStarknet(
options: Partial<GetStarknetOptions> = {},
): GetStarknetResult {
Expand Down
Loading
Loading