@dngbuilds/zapkit-core 0.0.1

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 ADDED
@@ -0,0 +1,23 @@
1
+ # vite-plus-starter
2
+
3
+ A starter for creating a Vite Plus project.
4
+
5
+ ## Development
6
+
7
+ - Install dependencies:
8
+
9
+ ```bash
10
+ vp install
11
+ ```
12
+
13
+ - Run the unit tests:
14
+
15
+ ```bash
16
+ vp test
17
+ ```
18
+
19
+ - Build the library:
20
+
21
+ ```bash
22
+ vp pack
23
+ ```
@@ -0,0 +1,66 @@
1
+ import * as starkzap from "starkzap";
2
+ import { Address, Amount, BridgeToken, Call, CartridgeWalletInterface, ChainId, ConnectCartridgeBaseOptions, ConnectWalletOptions, EnsureReadyOptions, ExecuteOptions, ExternalChain, OnboardOptions, OnboardResult, OnboardStrategy, Pool, RpcProvider, SDKConfig, StarkSigner, Token, Tx, TxBuilder, Wallet, accountPresets, fromAddress, getPresets } from "starkzap";
3
+ import { CartridgeWallet } from "starkzap/cartridge";
4
+
5
+ //#region src/index.d.ts
6
+ type ConnectCartridgeOptions = NonNullable<Extract<OnboardOptions, {
7
+ strategy: "cartridge";
8
+ }>["cartridge"]> & ConnectCartridgeBaseOptions;
9
+ interface ZapKitConfig extends SDKConfig {}
10
+ declare class ZapKit {
11
+ private sdk;
12
+ private currentWallet;
13
+ private _cartridgeWallet;
14
+ constructor(config: ZapKitConfig);
15
+ /** ==================== ONBOARD & WALLET ==================== */
16
+ onboard(params: OnboardOptions): Promise<OnboardResult<starkzap.WalletInterface>>;
17
+ connectWallet(options: ConnectWalletOptions): Promise<Wallet>;
18
+ getWallet(): Wallet | CartridgeWallet | null;
19
+ disconnect(): Promise<void>;
20
+ ensureReady(options?: EnsureReadyOptions): Promise<void>;
21
+ /** ==================== STAKING ==================== */
22
+ stakingTokens(): Promise<Token[]>;
23
+ getStakerPools(staker: Address): Promise<Pool[]>;
24
+ stake(params: {
25
+ poolAddress: Address;
26
+ amount: Amount;
27
+ options?: ExecuteOptions;
28
+ }): Promise<Tx>;
29
+ claimRewards(poolAddress: Address, options?: ExecuteOptions): Promise<Tx>;
30
+ /** ==================== BRIDGING ==================== */
31
+ getBridgingTokens(chain?: ExternalChain): Promise<BridgeToken[]>;
32
+ /** ==================== CARTRIDGE ==================== */
33
+ /**
34
+ * Connect using Cartridge Controller (social login / passkeys).
35
+ * Requires `@cartridge/controller` to be installed as an app dependency.
36
+ *
37
+ * @example
38
+ * const wallet = await kit.connectCartridge({ policies: [...] });
39
+ */
40
+ connectCartridge(options?: ConnectCartridgeOptions): Promise<CartridgeWalletInterface>;
41
+ /** ==================== PROVIDER & CONTRACT ==================== */
42
+ getProvider(): RpcProvider;
43
+ callContract(call: Call): ReturnType<RpcProvider["callContract"]>;
44
+ /** ==================== UTILITIES ==================== */
45
+ get utils(): {
46
+ Amount: typeof Amount;
47
+ fromAddress: typeof fromAddress;
48
+ getPresets: typeof getPresets;
49
+ accountPresets: {
50
+ readonly devnet: starkzap.AccountClassConfig;
51
+ readonly openzeppelin: starkzap.AccountClassConfig;
52
+ readonly argent: starkzap.AccountClassConfig;
53
+ readonly braavos: starkzap.AccountClassConfig;
54
+ readonly argentXV050: starkzap.AccountClassConfig;
55
+ };
56
+ OnboardStrategy: {
57
+ readonly Signer: "signer";
58
+ readonly Privy: "privy";
59
+ readonly Cartridge: "cartridge";
60
+ };
61
+ StarkSigner: typeof StarkSigner;
62
+ };
63
+ getBalance(token: Token): Promise<Amount>;
64
+ }
65
+ //#endregion
66
+ export { type Address, Amount, BridgeToken, type Call, type CartridgeWalletInterface, ChainId, type ConnectCartridgeBaseOptions, ConnectCartridgeOptions, type ConnectWalletOptions, type EnsureReadyOptions, type ExecuteOptions, ExternalChain, type OnboardOptions, type OnboardResult, OnboardStrategy, type Pool, type RpcProvider, type SDKConfig, StarkSigner, type Token, Tx, TxBuilder, type Wallet, ZapKit, ZapKit as default, ZapKitConfig, accountPresets, fromAddress, getPresets };
package/dist/index.mjs ADDED
@@ -0,0 +1,109 @@
1
+ import { Amount, BridgeToken, ChainId, ExternalChain, OnboardStrategy, StarkSigner, StarkZap, Tx, TxBuilder, accountPresets, fromAddress, getPresets } from "starkzap";
2
+ //#region src/index.ts
3
+ var ZapKit = class {
4
+ sdk;
5
+ currentWallet = null;
6
+ _cartridgeWallet = null;
7
+ constructor(config) {
8
+ this.sdk = new StarkZap(config);
9
+ const network = config.network ?? "sepolia";
10
+ console.log(`🚀 ZapKit initialized on ${String(network)}`);
11
+ }
12
+ /** ==================== ONBOARD & WALLET ==================== */
13
+ async onboard(params) {
14
+ if (params.strategy === "cartridge" && this._cartridgeWallet) {
15
+ this.currentWallet = this._cartridgeWallet;
16
+ return {
17
+ wallet: this.currentWallet,
18
+ strategy: params.strategy,
19
+ deployed: await this.currentWallet.isDeployed()
20
+ };
21
+ }
22
+ const result = await this.sdk.onboard(params);
23
+ this.currentWallet = result.wallet;
24
+ if (params.strategy === "cartridge") this._cartridgeWallet = this.currentWallet;
25
+ return result;
26
+ }
27
+ async connectWallet(options) {
28
+ const wallet = await this.sdk.connectWallet(options);
29
+ this.currentWallet = wallet;
30
+ return wallet;
31
+ }
32
+ getWallet() {
33
+ return this.currentWallet;
34
+ }
35
+ async disconnect() {
36
+ if (this.currentWallet) {
37
+ if (this._cartridgeWallet === this.currentWallet) {
38
+ this.currentWallet = null;
39
+ return;
40
+ }
41
+ try {
42
+ await this.currentWallet.disconnect();
43
+ } catch {}
44
+ this.currentWallet = null;
45
+ }
46
+ }
47
+ async ensureReady(options) {
48
+ if (!this.currentWallet) throw new Error("Wallet not connected. Call onboard() or connectWallet() first.");
49
+ await this.currentWallet.ensureReady(options);
50
+ }
51
+ /** ==================== STAKING ==================== */
52
+ async stakingTokens() {
53
+ return this.sdk.stakingTokens();
54
+ }
55
+ async getStakerPools(staker) {
56
+ return this.sdk.getStakerPools(staker);
57
+ }
58
+ async stake(params) {
59
+ if (!this.currentWallet) throw new Error("Wallet not connected.");
60
+ const tx = await this.currentWallet.enterPool(params.poolAddress, params.amount, params.options);
61
+ await tx.wait();
62
+ return tx;
63
+ }
64
+ async claimRewards(poolAddress, options) {
65
+ if (!this.currentWallet) throw new Error("Wallet not connected.");
66
+ return this.currentWallet.claimPoolRewards(poolAddress, options);
67
+ }
68
+ /** ==================== BRIDGING ==================== */
69
+ async getBridgingTokens(chain) {
70
+ return this.sdk.getBridgingTokens(chain);
71
+ }
72
+ /** ==================== CARTRIDGE ==================== */
73
+ /**
74
+ * Connect using Cartridge Controller (social login / passkeys).
75
+ * Requires `@cartridge/controller` to be installed as an app dependency.
76
+ *
77
+ * @example
78
+ * const wallet = await kit.connectCartridge({ policies: [...] });
79
+ */
80
+ async connectCartridge(options) {
81
+ const wallet = await this.sdk.connectCartridge(options);
82
+ this.currentWallet = wallet;
83
+ return wallet;
84
+ }
85
+ /** ==================== PROVIDER & CONTRACT ==================== */
86
+ getProvider() {
87
+ return this.sdk.getProvider();
88
+ }
89
+ callContract(call) {
90
+ return this.sdk.callContract(call);
91
+ }
92
+ /** ==================== UTILITIES ==================== */
93
+ get utils() {
94
+ return {
95
+ Amount,
96
+ fromAddress,
97
+ getPresets,
98
+ accountPresets,
99
+ OnboardStrategy,
100
+ StarkSigner
101
+ };
102
+ }
103
+ async getBalance(token) {
104
+ if (!this.currentWallet) throw new Error("Wallet not connected.");
105
+ return this.currentWallet.balanceOf(token);
106
+ }
107
+ };
108
+ //#endregion
109
+ export { Amount, BridgeToken, ChainId, ExternalChain, OnboardStrategy, StarkSigner, Tx, TxBuilder, ZapKit, ZapKit as default, accountPresets, fromAddress, getPresets };
@@ -0,0 +1,35 @@
1
+ //#region src/vite.d.ts
2
+ /**
3
+ * Vite plugin for ZapKit — resolves optional starkzap peer dependencies to
4
+ * virtual no-op shims so your app bundles without errors even when those
5
+ * packages aren't installed.
6
+ *
7
+ * Uses Vite virtual modules instead of filesystem shims so the plugin works
8
+ * correctly when the config file is bundled (import.meta.url is rewritten
9
+ * to a temp path during config bundling).
10
+ *
11
+ * Optional starkzap dependencies covered:
12
+ * @avnu/avnu-sdk — AVNU swap / DCA routing
13
+ * @fatsolutions/tongo-sdk — TON bridge (confidential transactions)
14
+ * @hyperlane-xyz/sdk — Hyperlane bridge (type-only, no runtime shim needed)
15
+ * @solana/web3.js — Solana bridge (dynamically imported by starkzap)
16
+ *
17
+ * NOT shimmed (bundled as real deps in @zapkit/core):
18
+ * @cartridge/controller — included automatically, OnboardStrategy.Cartridge works out of the box
19
+ *
20
+ * @example
21
+ * // vite.config.ts
22
+ * import { defineConfig } from "vite";
23
+ * import { zapkitPlugin } from "@zapkit/core/vite";
24
+ *
25
+ * export default defineConfig({
26
+ * plugins: [zapkitPlugin()],
27
+ * });
28
+ */
29
+ declare function zapkitPlugin(): {
30
+ name: string;
31
+ resolveId(id: string): string | undefined;
32
+ load(id: string): string | undefined;
33
+ };
34
+ //#endregion
35
+ export { zapkitPlugin };
package/dist/vite.mjs ADDED
@@ -0,0 +1,69 @@
1
+ //#region src/vite.ts
2
+ /**
3
+ * Vite plugin for ZapKit — resolves optional starkzap peer dependencies to
4
+ * virtual no-op shims so your app bundles without errors even when those
5
+ * packages aren't installed.
6
+ *
7
+ * Uses Vite virtual modules instead of filesystem shims so the plugin works
8
+ * correctly when the config file is bundled (import.meta.url is rewritten
9
+ * to a temp path during config bundling).
10
+ *
11
+ * Optional starkzap dependencies covered:
12
+ * @avnu/avnu-sdk — AVNU swap / DCA routing
13
+ * @fatsolutions/tongo-sdk — TON bridge (confidential transactions)
14
+ * @hyperlane-xyz/sdk — Hyperlane bridge (type-only, no runtime shim needed)
15
+ * @solana/web3.js — Solana bridge (dynamically imported by starkzap)
16
+ *
17
+ * NOT shimmed (bundled as real deps in @zapkit/core):
18
+ * @cartridge/controller — included automatically, OnboardStrategy.Cartridge works out of the box
19
+ *
20
+ * @example
21
+ * // vite.config.ts
22
+ * import { defineConfig } from "vite";
23
+ * import { zapkitPlugin } from "@zapkit/core/vite";
24
+ *
25
+ * export default defineConfig({
26
+ * plugins: [zapkitPlugin()],
27
+ * });
28
+ */
29
+ const VIRTUAL_PREFIX = "\0zapkit-shim:";
30
+ /** Shim source code keyed by package name */
31
+ const SHIMS = {
32
+ "@fatsolutions/tongo-sdk": `
33
+ export class Account {
34
+ constructor() {
35
+ throw new Error("[zapkit] @fatsolutions/tongo-sdk is not available. Install it to use TON bridge features.");
36
+ }
37
+ }
38
+ export default {};
39
+ `,
40
+ "@hyperlane-xyz/sdk": `export default {};`,
41
+ "@solana/web3.js": `export default {};`,
42
+ "@avnu/avnu-sdk": `
43
+ const notInstalled = (name) => () => {
44
+ throw new Error(\`[zapkit] @avnu/avnu-sdk "\${name}" is not available. Install @avnu/avnu-sdk to use swap/DCA features.\`);
45
+ };
46
+ export const getQuotes = notInstalled("getQuotes");
47
+ export const quoteToCalls = notInstalled("quoteToCalls");
48
+ export const cancelDcaToCalls = notInstalled("cancelDcaToCalls");
49
+ export const createDcaToCalls = notInstalled("createDcaToCalls");
50
+ export const getDcaOrders = notInstalled("getDcaOrders");
51
+ export const DcaOrderStatus = {};
52
+ export const BASE_URL = "https://starknet.api.avnu.fi";
53
+ export const SEPOLIA_BASE_URL = "https://sepolia.api.avnu.fi";
54
+ export default {};
55
+ `
56
+ };
57
+ function zapkitPlugin() {
58
+ return {
59
+ name: "zapkit",
60
+ resolveId(id) {
61
+ if (id in SHIMS) return VIRTUAL_PREFIX + id;
62
+ },
63
+ load(id) {
64
+ if (id.startsWith(VIRTUAL_PREFIX)) return SHIMS[id.slice(13)];
65
+ }
66
+ };
67
+ }
68
+ //#endregion
69
+ export { zapkitPlugin };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@dngbuilds/zapkit-core",
3
+ "version": "0.0.1",
4
+ "description": "Zapkit core package.",
5
+ "homepage": "",
6
+ "bugs": {
7
+ "url": ""
8
+ },
9
+ "license": "MIT",
10
+ "author": "DngBuilds <dng.builds@gmail.com>",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/author/library.git"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "type": "module",
19
+ "types": "./src/index.ts",
20
+ "exports": {
21
+ ".": "./dist/index.mjs",
22
+ "./vite": "./dist/vite.mjs",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "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"
41
+ },
42
+ "dependencies": {
43
+ "@cartridge/controller": "^0.13.9",
44
+ "react": "catalog:",
45
+ "starkzap": "latest"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^25.5.0",
49
+ "@typescript/native-preview": "7.0.0-dev.20260316.1",
50
+ "bumpp": "^11.0.1",
51
+ "typescript": "^5.9.3",
52
+ "vite-plus": "^0.1.11",
53
+ "vitest": "catalog:"
54
+ }
55
+ }