-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on implementing a wrapper around EVM connectors through Kakarot
- Loading branch information
Showing
23 changed files
with
857 additions
and
12 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@starknet-react-core-62cd0e5a-40e2-4894-8619-9b25fa4b57b1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "add chainId hint in connector's `connect`", | ||
"packageName": "@starknet-react/core", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@starknet-react-kakarot-4afaa398-6b8f-442a-90fb-3d80b5cb73d1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "feat: add EVM wallets through kakarot connectors", | ||
"packageName": "@starknet-react/kakarot", | ||
"email": "[email protected]", | ||
"dependentChangeType": "none" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/create-starknet-f3996a65-d78b-4381-b65f-3e3cfdba2c30.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "add kakarotConnectors to starknet-provider", | ||
"packageName": "create-starknet", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @starknet-react/kakarot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# `@starknet-react/kakarot` | ||
|
||
Support of EVM wallets through Kakarot. | ||
|
||
## Installation | ||
|
||
``` | ||
npm install @starknet-react/kakarot | ||
# or | ||
yarn add @starknet-react/kakarot | ||
``` | ||
|
||
## Usage | ||
|
||
Simply import the kakarotConnectors. | ||
|
||
```ts | ||
import { kakarotConnectors } from "@starknet-react/kakarot" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "@starknet-react/kakarot", | ||
"version": "3.0.2", | ||
"license": "MIT", | ||
"repository": "apibara/starknet-react", | ||
"homepage": "https://www.starknet-react.com/", | ||
"keywords": ["starknet", "ethereum", "l2", "kakarot"], | ||
"type": "module", | ||
"main": "./src/index.ts", | ||
"exports": "./src/index.ts", | ||
"publishConfig": { | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"files": ["dist", "src", "README.md"] | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"clean": "rimraf dist", | ||
"lint": "biome check src", | ||
"lint:fix": "pnpm lint --write", | ||
"format:check": "biome format .", | ||
"format": "biome format . --write" | ||
}, | ||
"devDependencies": { | ||
"@starknet-react/typescript-config": "workspace:*", | ||
"rimraf": "^4.1.2", | ||
"tsup": "^8.0.2" | ||
}, | ||
"dependencies": { | ||
"@starknet-io/types-js": "^0.7.7", | ||
"@starknet-react/chains": "^3.0.2", | ||
"@starknet-react/core": "workspace:^", | ||
"mipd": "^0.0.7", | ||
"starknet": "^6.11.0", | ||
"viem": "^2.21.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
type Chain as StarknetChain, | ||
mainnet, | ||
sepolia, | ||
} from "@starknet-react/chains"; | ||
import { type Chain as KakarotChain, defineChain } from "viem"; | ||
|
||
type ChainConfig = { | ||
kakarotChain: KakarotChain; | ||
starknetChain: StarknetChain; | ||
kakarotDeployment: string; | ||
}; | ||
|
||
export const CHAIN_CONFIGS: Record<number, ChainConfig> = { | ||
[Number(sepolia.id)]: { | ||
kakarotChain: /*#__PURE__*/ defineChain({ | ||
id: 920637907288165, | ||
name: "Kakarot Sepolia", | ||
nativeCurrency: { | ||
name: "Ether", | ||
symbol: "ETH", | ||
decimals: 18, | ||
}, | ||
rpcUrls: { | ||
default: { | ||
http: ["https://sepolia-rpc.kakarot.org"], | ||
}, | ||
}, | ||
blockExplorers: { | ||
default: { | ||
name: "Kakarot Scan", | ||
url: "https://sepolia.kakarotscan.org", | ||
}, | ||
}, | ||
testnet: true, | ||
}), | ||
starknetChain: sepolia, | ||
kakarotDeployment: | ||
"0x1d2e513630d8120666fc6e7d52ad0c01479fd99c183baac79fff9135f46e359", | ||
}, | ||
}; | ||
|
||
export const kakarotSepolia = CHAIN_CONFIGS[Number(sepolia.id)].kakarotChain; | ||
export const DEFAULT_CHAIN = CHAIN_CONFIGS[Number(sepolia.id)]; | ||
|
||
export const KAKAROT_DEPLOYMENTS: Record<number, string> = Object.fromEntries( | ||
Object.values(CHAIN_CONFIGS).map((config) => [ | ||
Number(config.starknetChain.id), | ||
config.kakarotDeployment, | ||
]), | ||
); | ||
|
||
export const getCorrespondingStarknetChain = ( | ||
chainId: number, | ||
): StarknetChain | undefined => { | ||
return Object.values(CHAIN_CONFIGS).find( | ||
(config) => config.kakarotChain.id === chainId, | ||
)?.starknetChain; | ||
}; | ||
|
||
export const getCorrespondingKakarotChain = ( | ||
starknetChainId: number, | ||
): KakarotChain | undefined => { | ||
return Object.values(CHAIN_CONFIGS).find( | ||
(config) => Number(config.starknetChain.id) === starknetChainId, | ||
)?.kakarotChain; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { ChainProviderFactory } from "@starknet-react/core"; | ||
import { createStore } from "mipd"; | ||
import type { RpcProvider } from "starknet"; | ||
import { KakarotConnector } from "./kakarot"; | ||
|
||
export function kakarotConnectors( | ||
starknetRpcProvider: ChainProviderFactory<RpcProvider>, | ||
): KakarotConnector[] { | ||
// Set up a MIPD Store, and request Providers. | ||
const store = createStore(); | ||
|
||
const allProviders = store.getProviders(); | ||
return allProviders.map((provider) => { | ||
return new KakarotConnector(provider, starknetRpcProvider); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { kakarotSepolia } from "./chains"; | ||
export { kakarotConnectors } from "./connectors"; |
Oops, something went wrong.