Skip to content

Commit

Permalink
Merge pull request #224 from tabaktoni/feat/starknet-types
Browse files Browse the repository at this point in the history
feat: integrate starknet types
  • Loading branch information
dhruvkelawala authored Apr 3, 2024
2 parents 5e8b2e5 + 3f6ef54 commit 17e57ed
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 389 deletions.
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 { Permission, type StarknetWindowObject } from "starknet-types"

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

0 comments on commit 17e57ed

Please sign in to comment.