@dngbuilds/zapkit-core 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -11
- package/package.json +28 -25
package/README.md
CHANGED
|
@@ -1,23 +1,152 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>⚡ @dngbuilds/zapkit-core</h1>
|
|
3
|
+
<p><strong>The Starknet wallet SDK — connect, transact, and bridge in a few lines of code.</strong></p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://www.npmjs.com/package/@dngbuilds/zapkit-core"><img src="https://img.shields.io/npm/v/@dngbuilds/zapkit-core?color=blue&label=npm" alt="npm version" /></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@dngbuilds/zapkit-core"><img src="https://img.shields.io/npm/dm/@dngbuilds/zapkit-core?color=green" alt="npm downloads" /></a>
|
|
8
|
+
<a href="https://github.com/DngBuilds/zapkit/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license" /></a>
|
|
9
|
+
</p>
|
|
10
|
+
</div>
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
---
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
`@dngbuilds/zapkit-core` wraps the [StarkZap](https://github.com/starkzap) SDK into a single `ZapKit` class that handles wallet connections (Cartridge Controller, StarkSigner, Privy), staking, bridging, and low-level contract calls on Starknet.
|
|
17
|
+
|
|
18
|
+
> **Using React?** Check out [`@dngbuilds/zapkit-react`](https://www.npmjs.com/package/@dngbuilds/zapkit-react) — it provides a context provider and hooks that build on top of this core package.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
8
21
|
|
|
9
22
|
```bash
|
|
10
|
-
|
|
23
|
+
npm install @dngbuilds/zapkit-core
|
|
11
24
|
```
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
## Quick Start
|
|
14
27
|
|
|
15
|
-
```
|
|
16
|
-
|
|
28
|
+
```ts
|
|
29
|
+
import ZapKit, { OnboardStrategy } from "@dngbuilds/zapkit-core";
|
|
30
|
+
|
|
31
|
+
const kit = new ZapKit({ network: "mainnet" });
|
|
32
|
+
|
|
33
|
+
// Connect with Cartridge Controller (social login / passkeys)
|
|
34
|
+
const result = await kit.onboard({ strategy: OnboardStrategy.Cartridge });
|
|
35
|
+
console.log("Connected:", result.wallet.address);
|
|
36
|
+
|
|
37
|
+
// Get token balance
|
|
38
|
+
const balance = await kit.getBalance({ symbol: "ETH", address: "0x049d…" });
|
|
39
|
+
console.log("ETH balance:", balance.toString());
|
|
17
40
|
```
|
|
18
41
|
|
|
19
|
-
|
|
42
|
+
## Wallet Strategies
|
|
20
43
|
|
|
21
|
-
|
|
22
|
-
|
|
44
|
+
ZapKit supports three onboarding strategies:
|
|
45
|
+
|
|
46
|
+
### Cartridge Controller
|
|
47
|
+
|
|
48
|
+
Social login and passkeys via [Cartridge](https://cartridge.gg). No extra dependencies needed.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
await kit.onboard({ strategy: OnboardStrategy.Cartridge });
|
|
23
52
|
```
|
|
53
|
+
|
|
54
|
+
### StarkSigner (Private Key)
|
|
55
|
+
|
|
56
|
+
Direct private-key signing for scripts, bots, or testing.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { StarkSigner } from "@dngbuilds/zapkit-core";
|
|
60
|
+
|
|
61
|
+
await kit.onboard({
|
|
62
|
+
strategy: OnboardStrategy.Signer,
|
|
63
|
+
signer: new StarkSigner("0xYOUR_PRIVATE_KEY"),
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Privy
|
|
68
|
+
|
|
69
|
+
Third-party auth (email, social, etc.) via [Privy](https://privy.io). Requires the Privy SDK in your app.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
await kit.onboard({
|
|
73
|
+
strategy: OnboardStrategy.Privy,
|
|
74
|
+
privy: { walletConnector: privyWalletConnector },
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## API Reference
|
|
79
|
+
|
|
80
|
+
### `new ZapKit(config)`
|
|
81
|
+
|
|
82
|
+
Creates a new ZapKit instance.
|
|
83
|
+
|
|
84
|
+
| Option | Type | Description |
|
|
85
|
+
| --------- | -------- | ---------------------------- |
|
|
86
|
+
| `network` | `string` | `"mainnet"` or `"sepolia"` |
|
|
87
|
+
| _...rest_ | | Passed through to StarkZap |
|
|
88
|
+
|
|
89
|
+
### Wallet Methods
|
|
90
|
+
|
|
91
|
+
| Method | Returns | Description |
|
|
92
|
+
| -------------------------------- | ------------------- | ---------------------------------------- |
|
|
93
|
+
| `onboard(options)` | `OnboardResult` | Connect using a given strategy |
|
|
94
|
+
| `connectWallet(options)` | `Wallet` | Low-level wallet connect |
|
|
95
|
+
| `connectCartridge(options?)` | `CartridgeWallet` | Direct Cartridge Controller connect |
|
|
96
|
+
| `getWallet()` | `Wallet \| null` | Current wallet instance |
|
|
97
|
+
| `disconnect()` | `void` | Disconnect the active wallet |
|
|
98
|
+
| `ensureReady(options?)` | `void` | Wait until the wallet is fully ready |
|
|
99
|
+
|
|
100
|
+
### DeFi Methods
|
|
101
|
+
|
|
102
|
+
| Method | Returns | Description |
|
|
103
|
+
| -------------------------------- | ------------------- | ---------------------------------------- |
|
|
104
|
+
| `stakingTokens()` | `Token[]` | List available staking tokens |
|
|
105
|
+
| `getStakerPools(address)` | `Pool[]` | Pools a staker is in |
|
|
106
|
+
| `stake({ poolAddress, amount })` | `Tx` | Stake tokens in a pool |
|
|
107
|
+
| `claimRewards(poolAddress)` | `Tx` | Claim staking rewards |
|
|
108
|
+
| `getBridgingTokens(chain?)` | `BridgeToken[]` | Available bridging tokens |
|
|
109
|
+
| `getBalance(token)` | `Amount` | Token balance of connected wallet |
|
|
110
|
+
|
|
111
|
+
### Utilities
|
|
112
|
+
|
|
113
|
+
| Method / Property | Description |
|
|
114
|
+
| -------------------------- | ------------------------------------ |
|
|
115
|
+
| `getProvider()` | Returns the underlying RPC provider |
|
|
116
|
+
| `callContract(call)` | Execute a read-only contract call |
|
|
117
|
+
| `utils.Amount` | Token amount helpers |
|
|
118
|
+
| `utils.fromAddress(addr)` | Parse an address string |
|
|
119
|
+
| `utils.getPresets()` | Account preset configurations |
|
|
120
|
+
|
|
121
|
+
### Vite Plugin
|
|
122
|
+
|
|
123
|
+
ZapKit provides a Vite plugin that resolves optional peer dependencies (starkzap modules) to no-op shims, preventing missing-module errors during builds.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
// vite.config.ts
|
|
127
|
+
import { defineConfig } from "vite";
|
|
128
|
+
import { zapkitPlugin } from "@dngbuilds/zapkit-core/vite";
|
|
129
|
+
|
|
130
|
+
export default defineConfig({
|
|
131
|
+
plugins: [zapkitPlugin()],
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Exports
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
// Value exports
|
|
139
|
+
export { OnboardStrategy, StarkSigner, Amount, fromAddress };
|
|
140
|
+
export { getPresets, accountPresets, Tx, TxBuilder };
|
|
141
|
+
export { ChainId, ExternalChain, BridgeToken };
|
|
142
|
+
|
|
143
|
+
// Type exports
|
|
144
|
+
export type { SDKConfig, Wallet, Token, Address, Pool };
|
|
145
|
+
export type { OnboardOptions, OnboardResult, ConnectWalletOptions };
|
|
146
|
+
export type { CartridgeWalletInterface, ConnectCartridgeOptions };
|
|
147
|
+
export type { EnsureReadyOptions, ExecuteOptions, RpcProvider, Call };
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
[MIT](https://github.com/DngBuilds/zapkit/blob/master/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dngbuilds/zapkit-core",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"homepage": "",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Starknet wallet SDK — connect, transact, and bridge in a few lines of code.",
|
|
5
|
+
"homepage": "https://zapkit.vercel.app",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": ""
|
|
7
|
+
"url": "https://github.com/DngBuilds/zapkit/issues"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"author": "DngBuilds <dng.builds@gmail.com>",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/
|
|
13
|
+
"url": "git+https://github.com/DngBuilds/zapkit.git",
|
|
14
|
+
"directory": "packages/core"
|
|
14
15
|
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"starknet",
|
|
18
|
+
"wallet",
|
|
19
|
+
"web3",
|
|
20
|
+
"defi",
|
|
21
|
+
"zapkit",
|
|
22
|
+
"cartridge",
|
|
23
|
+
"starkzap"
|
|
24
|
+
],
|
|
15
25
|
"files": [
|
|
16
26
|
"dist"
|
|
17
27
|
],
|
|
18
28
|
"type": "module",
|
|
19
|
-
"types": "./
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
20
30
|
"exports": {
|
|
21
31
|
".": "./dist/index.mjs",
|
|
22
32
|
"./vite": "./dist/vite.mjs",
|
|
23
33
|
"./package.json": "./package.json"
|
|
24
34
|
},
|
|
25
35
|
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
27
|
-
"exports": {
|
|
28
|
-
".": "./dist/index.mjs",
|
|
29
|
-
"./vite": "./dist/vite.mjs",
|
|
30
|
-
"./package.json": "./package.json"
|
|
31
|
-
},
|
|
32
|
-
"main": "./dist/index.mjs",
|
|
33
|
-
"types": "./dist/index.d.mts"
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "vp pack",
|
|
37
|
-
"dev": "vp pack --watch",
|
|
38
|
-
"test": "vp test",
|
|
39
|
-
"check": "vp check",
|
|
40
|
-
"prepublishOnly": "vp run build"
|
|
36
|
+
"access": "public"
|
|
41
37
|
},
|
|
42
38
|
"dependencies": {
|
|
43
39
|
"@cartridge/controller": "^0.13.9",
|
|
44
|
-
"react": "
|
|
40
|
+
"react": "^19.2.4",
|
|
45
41
|
"starkzap": "latest"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
@@ -50,6 +46,13 @@
|
|
|
50
46
|
"bumpp": "^11.0.1",
|
|
51
47
|
"typescript": "^5.9.3",
|
|
52
48
|
"vite-plus": "^0.1.11",
|
|
53
|
-
"vitest": "
|
|
54
|
-
}
|
|
55
|
-
|
|
49
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@^0.1.14"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "vp pack",
|
|
53
|
+
"dev": "vp pack --watch",
|
|
54
|
+
"test": "vp test",
|
|
55
|
+
"check": "vp check"
|
|
56
|
+
},
|
|
57
|
+
"main": "./dist/index.mjs"
|
|
58
|
+
}
|