@inkd/sdk 0.9.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.
Files changed (106) hide show
  1. package/README.md +288 -0
  2. package/dist/InkdClient.d.ts +89 -0
  3. package/dist/InkdClient.d.ts.map +1 -0
  4. package/dist/InkdClient.js +398 -0
  5. package/dist/InkdClient.js.map +1 -0
  6. package/dist/ProjectRegistry.d.ts +655 -0
  7. package/dist/ProjectRegistry.d.ts.map +1 -0
  8. package/dist/ProjectRegistry.js +708 -0
  9. package/dist/ProjectRegistry.js.map +1 -0
  10. package/dist/__tests__/InkdClient.advanced.test.d.ts +10 -0
  11. package/dist/__tests__/InkdClient.advanced.test.d.ts.map +1 -0
  12. package/dist/__tests__/InkdClient.advanced.test.js +588 -0
  13. package/dist/__tests__/InkdClient.advanced.test.js.map +1 -0
  14. package/dist/__tests__/InkdClient.connectArweave.test.d.ts +10 -0
  15. package/dist/__tests__/InkdClient.connectArweave.test.d.ts.map +1 -0
  16. package/dist/__tests__/InkdClient.connectArweave.test.js +132 -0
  17. package/dist/__tests__/InkdClient.connectArweave.test.js.map +1 -0
  18. package/dist/__tests__/InkdClient.test.d.ts +2 -0
  19. package/dist/__tests__/InkdClient.test.d.ts.map +1 -0
  20. package/dist/__tests__/InkdClient.test.js +259 -0
  21. package/dist/__tests__/InkdClient.test.js.map +1 -0
  22. package/dist/__tests__/ProjectRegistry.test.d.ts +8 -0
  23. package/dist/__tests__/ProjectRegistry.test.d.ts.map +1 -0
  24. package/dist/__tests__/ProjectRegistry.test.js +689 -0
  25. package/dist/__tests__/ProjectRegistry.test.js.map +1 -0
  26. package/dist/__tests__/arweave.test.d.ts +9 -0
  27. package/dist/__tests__/arweave.test.d.ts.map +1 -0
  28. package/dist/__tests__/arweave.test.js +353 -0
  29. package/dist/__tests__/arweave.test.js.map +1 -0
  30. package/dist/__tests__/encryption.test.d.ts +2 -0
  31. package/dist/__tests__/encryption.test.d.ts.map +1 -0
  32. package/dist/__tests__/encryption.test.js +154 -0
  33. package/dist/__tests__/encryption.test.js.map +1 -0
  34. package/dist/__tests__/errors.test.d.ts +2 -0
  35. package/dist/__tests__/errors.test.d.ts.map +1 -0
  36. package/dist/__tests__/errors.test.js +136 -0
  37. package/dist/__tests__/errors.test.js.map +1 -0
  38. package/dist/__tests__/events.test.d.ts +10 -0
  39. package/dist/__tests__/events.test.d.ts.map +1 -0
  40. package/dist/__tests__/events.test.js +380 -0
  41. package/dist/__tests__/events.test.js.map +1 -0
  42. package/dist/__tests__/index.InkdClient.test.d.ts +8 -0
  43. package/dist/__tests__/index.InkdClient.test.d.ts.map +1 -0
  44. package/dist/__tests__/index.InkdClient.test.js +422 -0
  45. package/dist/__tests__/index.InkdClient.test.js.map +1 -0
  46. package/dist/__tests__/multicall.test.d.ts +9 -0
  47. package/dist/__tests__/multicall.test.d.ts.map +1 -0
  48. package/dist/__tests__/multicall.test.js +362 -0
  49. package/dist/__tests__/multicall.test.js.map +1 -0
  50. package/dist/__tests__/types.test.d.ts +2 -0
  51. package/dist/__tests__/types.test.d.ts.map +1 -0
  52. package/dist/__tests__/types.test.js +35 -0
  53. package/dist/__tests__/types.test.js.map +1 -0
  54. package/dist/abi.d.ts +2632 -0
  55. package/dist/abi.d.ts.map +1 -0
  56. package/dist/abi.js +3423 -0
  57. package/dist/abi.js.map +1 -0
  58. package/dist/arweave.d.ts +45 -0
  59. package/dist/arweave.d.ts.map +1 -0
  60. package/dist/arweave.js +154 -0
  61. package/dist/arweave.js.map +1 -0
  62. package/dist/encryption.d.ts +52 -0
  63. package/dist/encryption.d.ts.map +1 -0
  64. package/dist/encryption.js +80 -0
  65. package/dist/encryption.js.map +1 -0
  66. package/dist/errors.d.ts +63 -0
  67. package/dist/errors.d.ts.map +1 -0
  68. package/dist/errors.js +124 -0
  69. package/dist/errors.js.map +1 -0
  70. package/dist/events.d.ts +136 -0
  71. package/dist/events.d.ts.map +1 -0
  72. package/dist/events.js +131 -0
  73. package/dist/events.js.map +1 -0
  74. package/dist/hooks/index.d.ts +5 -0
  75. package/dist/hooks/index.d.ts.map +1 -0
  76. package/dist/hooks/index.js +12 -0
  77. package/dist/hooks/index.js.map +1 -0
  78. package/dist/hooks/useInkd.d.ts +24 -0
  79. package/dist/hooks/useInkd.d.ts.map +1 -0
  80. package/dist/hooks/useInkd.js +109 -0
  81. package/dist/hooks/useInkd.js.map +1 -0
  82. package/dist/hooks/useInkdHolder.d.ts +16 -0
  83. package/dist/hooks/useInkdHolder.d.ts.map +1 -0
  84. package/dist/hooks/useInkdHolder.js +45 -0
  85. package/dist/hooks/useInkdHolder.js.map +1 -0
  86. package/dist/hooks/useInscriptions.d.ts +17 -0
  87. package/dist/hooks/useInscriptions.d.ts.map +1 -0
  88. package/dist/hooks/useInscriptions.js +46 -0
  89. package/dist/hooks/useInscriptions.js.map +1 -0
  90. package/dist/hooks/useToken.d.ts +16 -0
  91. package/dist/hooks/useToken.d.ts.map +1 -0
  92. package/dist/hooks/useToken.js +45 -0
  93. package/dist/hooks/useToken.js.map +1 -0
  94. package/dist/index.d.ts +54 -0
  95. package/dist/index.d.ts.map +1 -0
  96. package/dist/index.js +290 -0
  97. package/dist/index.js.map +1 -0
  98. package/dist/multicall.d.ts +134 -0
  99. package/dist/multicall.d.ts.map +1 -0
  100. package/dist/multicall.js +182 -0
  101. package/dist/multicall.js.map +1 -0
  102. package/dist/types.d.ts +187 -0
  103. package/dist/types.d.ts.map +1 -0
  104. package/dist/types.js +32 -0
  105. package/dist/types.js.map +1 -0
  106. package/package.json +78 -0
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ /**
3
+ * @file multicall.ts
4
+ * @description Multicall3-powered batch reads for InkdRegistry.
5
+ * Fetches multiple projects or versions in a single RPC round-trip,
6
+ * dramatically reducing latency when listing/paginating projects.
7
+ *
8
+ * Uses viem's built-in `multicall` helper, which targets Multicall3
9
+ * (0xcA11bde05977b3631167028862bE2a173976CA11 — deployed on Base and Base Sepolia).
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { batchGetProjects, batchGetFees } from "@inkd/sdk";
14
+ * import { createPublicClient, http } from "viem";
15
+ * import { baseSepolia } from "viem/chains";
16
+ *
17
+ * const publicClient = createPublicClient({ chain: baseSepolia, transport: http() });
18
+ *
19
+ * // Fetch 5 projects in one RPC call
20
+ * const projects = await batchGetProjects(publicClient, "0xRegistry...", [1n, 2n, 3n, 4n, 5n]);
21
+ *
22
+ * // Fetch both fees in one RPC call
23
+ * const fees = await batchGetFees(publicClient, "0xRegistry...");
24
+ * console.log("Version fee:", fees.versionFee);
25
+ * console.log("Transfer fee:", fees.transferFee);
26
+ * ```
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.batchGetProjects = batchGetProjects;
30
+ exports.batchGetVersions = batchGetVersions;
31
+ exports.batchGetFees = batchGetFees;
32
+ exports.batchGetProjectsWithVersions = batchGetProjectsWithVersions;
33
+ const ProjectRegistry_js_1 = require("./ProjectRegistry.js");
34
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
35
+ /**
36
+ * Coerce a raw multicall result into a typed BatchResult<T>.
37
+ * Handles both viem's `{ result, status }` shape and raw revert cases.
38
+ */
39
+ function coerceResult(raw) {
40
+ if (raw.status === "failure" || raw.status === undefined && raw.result === undefined) {
41
+ return {
42
+ data: null,
43
+ success: false,
44
+ error: raw.error instanceof Error ? raw.error.message : String(raw.error ?? "unknown"),
45
+ };
46
+ }
47
+ return {
48
+ data: raw.result,
49
+ success: true,
50
+ };
51
+ }
52
+ // ─── Public API ───────────────────────────────────────────────────────────────
53
+ /**
54
+ * Fetch multiple projects by their on-chain IDs in a **single RPC call**.
55
+ *
56
+ * Projects that don't exist (reverted getProject call) will have
57
+ * `success: false` and `data: null` in the returned array.
58
+ *
59
+ * @param publicClient A connected viem PublicClient (Base or Base Sepolia).
60
+ * @param registryAddress Address of the deployed InkdRegistry contract.
61
+ * @param projectIds Array of project IDs to fetch (bigint).
62
+ * @returns Promise resolving to a `BatchResult<ProjectData>[]` in the same order.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const results = await batchGetProjects(client, registry, [1n, 2n, 3n]);
67
+ * for (const r of results) {
68
+ * if (r.success && r.data) console.log(r.data.name);
69
+ * }
70
+ * ```
71
+ */
72
+ async function batchGetProjects(publicClient, registryAddress, projectIds) {
73
+ if (projectIds.length === 0)
74
+ return [];
75
+ const contracts = projectIds.map((id) => ({
76
+ address: registryAddress,
77
+ abi: ProjectRegistry_js_1.INKD_REGISTRY_ABI,
78
+ functionName: "getProject",
79
+ args: [id],
80
+ }));
81
+ const results = await publicClient.multicall({
82
+ contracts,
83
+ allowFailure: true,
84
+ });
85
+ return results.map((raw) => coerceResult(raw));
86
+ }
87
+ /**
88
+ * Fetch the latest versions for multiple projects in a **single RPC call**.
89
+ *
90
+ * Each element in the returned array corresponds to the project ID at the
91
+ * same index. Failed calls return `{ success: false, data: null }`.
92
+ *
93
+ * @param publicClient A connected viem PublicClient.
94
+ * @param registryAddress Address of the deployed InkdRegistry contract.
95
+ * @param projectIds Array of project IDs whose versions to fetch.
96
+ * @returns Promise resolving to `BatchResult<VersionData[]>[]` in the same order.
97
+ */
98
+ async function batchGetVersions(publicClient, registryAddress, projectIds) {
99
+ if (projectIds.length === 0)
100
+ return [];
101
+ const contracts = projectIds.map((id) => ({
102
+ address: registryAddress,
103
+ abi: ProjectRegistry_js_1.INKD_REGISTRY_ABI,
104
+ functionName: "getVersions",
105
+ args: [id],
106
+ }));
107
+ const results = await publicClient.multicall({
108
+ contracts,
109
+ allowFailure: true,
110
+ });
111
+ return results.map((raw) => coerceResult(raw));
112
+ }
113
+ /**
114
+ * Fetch versionFee, transferFee, and TOKEN_LOCK_AMOUNT in a **single RPC call**.
115
+ *
116
+ * Useful before any write operation (create project, push version, transfer)
117
+ * to confirm the required fee without extra round-trips.
118
+ *
119
+ * @param publicClient A connected viem PublicClient.
120
+ * @param registryAddress Address of the deployed InkdRegistry contract.
121
+ * @returns `RegistryFees` with all three fee values.
122
+ * @throws If any of the three calls reverts (should never happen on a valid registry).
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const { versionFee, transferFee, tokenLockAmount } = await batchGetFees(client, registry);
127
+ * ```
128
+ */
129
+ async function batchGetFees(publicClient, registryAddress) {
130
+ const contracts = [
131
+ {
132
+ address: registryAddress,
133
+ abi: ProjectRegistry_js_1.INKD_REGISTRY_ABI,
134
+ functionName: "versionFee",
135
+ args: [],
136
+ },
137
+ {
138
+ address: registryAddress,
139
+ abi: ProjectRegistry_js_1.INKD_REGISTRY_ABI,
140
+ functionName: "transferFee",
141
+ args: [],
142
+ },
143
+ {
144
+ address: registryAddress,
145
+ abi: ProjectRegistry_js_1.INKD_REGISTRY_ABI,
146
+ functionName: "TOKEN_LOCK_AMOUNT",
147
+ args: [],
148
+ },
149
+ ];
150
+ const results = await publicClient.multicall({
151
+ contracts,
152
+ allowFailure: false,
153
+ });
154
+ return {
155
+ versionFee: (results[0].result ?? 0n),
156
+ transferFee: (results[1].result ?? 0n),
157
+ tokenLockAmount: (results[2].result ?? 0n),
158
+ };
159
+ }
160
+ /**
161
+ * Fetch projects AND their versions for multiple IDs in **two RPC calls** (projects batch, then versions batch).
162
+ *
163
+ * This is more efficient than fetching each project + versions individually (2N+N calls → 2 calls).
164
+ *
165
+ * @param publicClient A connected viem PublicClient.
166
+ * @param registryAddress Address of the deployed InkdRegistry contract.
167
+ * @param projectIds Array of project IDs to hydrate.
168
+ * @returns Array of `{ project, versions }` objects in the same order as input IDs.
169
+ */
170
+ async function batchGetProjectsWithVersions(publicClient, registryAddress, projectIds) {
171
+ if (projectIds.length === 0)
172
+ return [];
173
+ const [projects, versions] = await Promise.all([
174
+ batchGetProjects(publicClient, registryAddress, projectIds),
175
+ batchGetVersions(publicClient, registryAddress, projectIds),
176
+ ]);
177
+ return projectIds.map((_, i) => ({
178
+ project: projects[i],
179
+ versions: versions[i],
180
+ }));
181
+ }
182
+ //# sourceMappingURL=multicall.js.map
@@ -0,0 +1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AE,KAAK;KACpB,CAAC,CAAC;IAEH,OAAO;QACL,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAW;QAC/C,WAAW,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAW;QAChD,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAW;KACrD,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,4BAA4B,CAChD,YAA0B,EAC1B,eAAwB,EACxB,UAAoB;IAEpB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEvC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC7C,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,CAAC;QAC3D,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,CAAC;KAC5D,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/B,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QACpB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;KACtB,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description Core TypeScript types for the Inkd Protocol SDK.
4
+ */
5
+ export type Address = `0x${string}`;
6
+ /** Common content type values for inscriptions. */
7
+ export declare enum ContentType {
8
+ JSON = "application/json",
9
+ PlainText = "text/plain",
10
+ Markdown = "text/markdown",
11
+ HTML = "text/html",
12
+ CSS = "text/css",
13
+ JavaScript = "application/javascript",
14
+ TypeScript = "application/typescript",
15
+ PNG = "image/png",
16
+ JPEG = "image/jpeg",
17
+ SVG = "image/svg+xml",
18
+ GIF = "image/gif",
19
+ WebP = "image/webp",
20
+ PDF = "application/pdf",
21
+ Binary = "application/octet-stream",
22
+ YAML = "application/yaml",
23
+ XML = "application/xml",
24
+ CSV = "text/csv",
25
+ WASM = "application/wasm"
26
+ }
27
+ /** InkdToken data as stored on-chain. */
28
+ export interface InkdTokenData {
29
+ /** Unique on-chain token identifier. */
30
+ tokenId: bigint;
31
+ /** Current owner address. */
32
+ owner: Address;
33
+ /** Timestamp when the token was minted. */
34
+ mintedAt: bigint;
35
+ /** Number of active inscriptions on this token. */
36
+ inscriptionCount: number;
37
+ /** Token metadata URI (on-chain SVG). */
38
+ tokenURI: string;
39
+ }
40
+ /** A single inscription stored on an InkdToken. */
41
+ export interface Inscription {
42
+ /** Arweave transaction ID. */
43
+ arweaveHash: string;
44
+ /** MIME type of the data. */
45
+ contentType: string;
46
+ /** File size in bytes. */
47
+ size: bigint;
48
+ /** Human-readable name. */
49
+ name: string;
50
+ /** Timestamp of creation. */
51
+ createdAt: bigint;
52
+ /** Whether the inscription has been soft-deleted. */
53
+ isRemoved: boolean;
54
+ /** Current version number. */
55
+ version: bigint;
56
+ }
57
+ /** Access grant for temporary read access. */
58
+ export interface AccessGrant {
59
+ /** Wallet with access. */
60
+ grantee: Address;
61
+ /** Expiry timestamp. */
62
+ expiresAt: bigint;
63
+ /** When access was granted. */
64
+ grantedAt: bigint;
65
+ }
66
+ /** Marketplace listing data. */
67
+ export interface SaleData {
68
+ /** Token ID being sold. */
69
+ tokenId: bigint;
70
+ /** Seller address. */
71
+ seller: Address;
72
+ /** Price in wei. */
73
+ price: bigint;
74
+ /** When the listing was created. */
75
+ listedAt: bigint;
76
+ /** Whether the listing is active. */
77
+ active: boolean;
78
+ }
79
+ /** Registry registration data. */
80
+ export interface TokenRegistration {
81
+ /** Token ID. */
82
+ tokenId: bigint;
83
+ /** Owner address. */
84
+ owner: Address;
85
+ /** Whether the token is publicly discoverable. */
86
+ isPublic: boolean;
87
+ /** Registration timestamp. */
88
+ registeredAt: bigint;
89
+ }
90
+ /** Protocol-wide statistics. */
91
+ export interface ProtocolStats {
92
+ /** Total registered tokens. */
93
+ totalTokens: bigint;
94
+ /** Total tracked inscriptions. */
95
+ totalInscriptions: bigint;
96
+ /** Total sales volume in wei. */
97
+ totalVolume: bigint;
98
+ /** Total completed sales. */
99
+ totalSales: bigint;
100
+ }
101
+ /** Configuration for the InkdClient. */
102
+ export interface InkdClientConfig {
103
+ /** InkdToken proxy contract address. */
104
+ tokenAddress: Address;
105
+ /** InkdVault proxy contract address. */
106
+ vaultAddress: Address;
107
+ /** InkdRegistry proxy contract address. */
108
+ registryAddress: Address;
109
+ /** Chain ID (8453 = Base Mainnet, 84532 = Base Sepolia). */
110
+ chainId: 8453 | 84532;
111
+ }
112
+ /** Options for inscribing data. */
113
+ export interface InscribeOptions {
114
+ /** Content type of the file. */
115
+ contentType?: string;
116
+ /** Human-readable name. */
117
+ name?: string;
118
+ /** Arweave upload tags. */
119
+ tags?: Record<string, string>;
120
+ /** ETH value to send (for protocol fee). */
121
+ value?: bigint;
122
+ }
123
+ /** Options for minting tokens. */
124
+ export interface MintOptions {
125
+ /** Number of tokens to mint (for batch mint). */
126
+ quantity?: number;
127
+ }
128
+ /** Result of a successful on-chain transaction. */
129
+ export interface TransactionResult {
130
+ /** Transaction hash. */
131
+ hash: Address;
132
+ /** Token ID (if applicable). */
133
+ tokenId?: bigint;
134
+ }
135
+ /** Result of a batch mint transaction. */
136
+ export interface BatchTransactionResult {
137
+ /** Transaction hash. */
138
+ hash: Address;
139
+ /** Array of minted token IDs. */
140
+ tokenIds: bigint[];
141
+ }
142
+ /** Result of an inscription operation. */
143
+ export interface InscribeResult {
144
+ /** Transaction hash. */
145
+ hash: Address;
146
+ /** Inscription index on the token. */
147
+ inscriptionIndex: bigint;
148
+ /** Arweave upload result. */
149
+ upload: UploadResult;
150
+ }
151
+ /** Result of an Arweave upload. */
152
+ export interface UploadResult {
153
+ /** Arweave transaction hash. */
154
+ hash: string;
155
+ /** Full Arweave gateway URL. */
156
+ url: string;
157
+ /** Size of uploaded data in bytes. */
158
+ size: number;
159
+ }
160
+ /** Encryption configuration for Lit Protocol integration. */
161
+ export interface EncryptionConfig {
162
+ /** Lit Protocol network to use. */
163
+ network: "datil" | "datil-dev" | "datil-test";
164
+ /** Chain for access control conditions. */
165
+ chain: string;
166
+ }
167
+ /** Result of encrypting data via Lit Protocol. */
168
+ export interface EncryptedData {
169
+ /** Encrypted data blob. */
170
+ ciphertext: Uint8Array;
171
+ /** Encrypted symmetric key. */
172
+ encryptedSymmetricKey: string;
173
+ /** Access control conditions for decryption. */
174
+ accessControlConditions: unknown[];
175
+ }
176
+ /** Cost estimate for an inscription operation. */
177
+ export interface InscribeCostEstimate {
178
+ /** Estimated gas cost in wei. */
179
+ gas: bigint;
180
+ /** Arweave storage cost in wei. */
181
+ arweave: bigint;
182
+ /** Protocol fee in wei. */
183
+ protocolFee: bigint;
184
+ /** Total estimated cost in wei. */
185
+ total: bigint;
186
+ }
187
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AAIpC,mDAAmD;AAEnD,oBAAY,WAAW;IACrB,IAAI,qBAAqB;IACzB,SAAS,eAAe;IACxB,QAAQ,kBAAkB;IAC1B,IAAI,cAAc;IAClB,GAAG,aAAa;IAChB,UAAU,2BAA2B;IACrC,UAAU,2BAA2B;IACrC,GAAG,cAAc;IACjB,IAAI,eAAe;IACnB,GAAG,kBAAkB;IACrB,GAAG,cAAc;IACjB,IAAI,eAAe;IACnB,GAAG,oBAAoB;IACvB,MAAM,6BAA6B;IACnC,IAAI,qBAAqB;IACzB,GAAG,oBAAoB;IACvB,GAAG,aAAa;IAChB,IAAI,qBAAqB;CAC1B;AAID,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,wC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O,CAAC;IACd,sCAAsC;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,MAAM,EAAE,YAAY,CAAC;CACtB;AAID,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAID,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,YAAY,CAAC;IAC9C,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,+BAA+B;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,uBAAuB,EAAE,OAAO,EAAE,CAAC;CACpC;AAED,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf"}
package/dist/types.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * @file types.ts
4
+ * @description Core TypeScript types for the Inkd Protocol SDK.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ContentType = void 0;
8
+ // ─── Content Types ────────────────────────────────────────────────────────────
9
+ /** Common content type values for inscriptions. */
10
+ // eslint-disable-next-line no-unused-vars
11
+ var ContentType;
12
+ (function (ContentType) {
13
+ ContentType["JSON"] = "application/json";
14
+ ContentType["PlainText"] = "text/plain";
15
+ ContentType["Markdown"] = "text/markdown";
16
+ ContentType["HTML"] = "text/html";
17
+ ContentType["CSS"] = "text/css";
18
+ ContentType["JavaScript"] = "application/javascript";
19
+ ContentType["TypeScript"] = "application/typescript";
20
+ ContentType["PNG"] = "image/png";
21
+ ContentType["JPEG"] = "image/jpeg";
22
+ ContentType["SVG"] = "image/svg+xml";
23
+ ContentType["GIF"] = "image/gif";
24
+ ContentType["WebP"] = "image/webp";
25
+ ContentType["PDF"] = "application/pdf";
26
+ ContentType["Binary"] = "application/octet-stream";
27
+ ContentType["YAML"] = "application/yaml";
28
+ ContentType["XML"] = "application/xml";
29
+ ContentType["CSV"] = "text/csv";
30
+ ContentType["WASM"] = "application/wasm";
31
+ })(ContentType || (exports.ContentType = ContentType = {}));
32
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,iFAAiF;AAEjF,mDAAmD;AACnD,0CAA0C;AAC1C,IAAY,WAmBX;AAnBD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,uCAAwB,CAAA;IACxB,yCAA0B,CAAA;IAC1B,iCAAkB,CAAA;IAClB,+BAAgB,CAAA;IAChB,oDAAqC,CAAA;IACrC,oDAAqC,CAAA;IACrC,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,kDAAmC,CAAA;IACnC,wCAAyB,CAAA;IACzB,sCAAuB,CAAA;IACvB,+BAAgB,CAAA;IAChB,wCAAyB,CAAA;AAC3B,CAAC,EAnBW,WAAW,2BAAX,WAAW,QAmBtB"}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@inkd/sdk",
3
+ "version": "0.9.0",
4
+ "description": "TypeScript SDK for Inkd Protocol \u2014 permanent on-chain file ownership on Base",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./hooks": {
15
+ "import": "./dist/hooks/index.mjs",
16
+ "require": "./dist/hooks/index.js",
17
+ "types": "./dist/hooks/index.d.ts"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "dev": "tsc --watch",
28
+ "test": "vitest run",
29
+ "test:watch": "vitest",
30
+ "test:coverage": "vitest run --coverage",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint src --ext .ts --max-warnings 0",
33
+ "prepublishOnly": "npm run typecheck && npm run test && npm run build"
34
+ },
35
+ "keywords": [
36
+ "inkd",
37
+ "protocol",
38
+ "base",
39
+ "blockchain",
40
+ "arweave",
41
+ "sdk",
42
+ "web3",
43
+ "ai-agents",
44
+ "nft",
45
+ "erc721",
46
+ "inscription",
47
+ "permanent-storage"
48
+ ],
49
+ "author": "Inkd Protocol <dev@inkdprotocol.xyz>",
50
+ "license": "MIT",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "https://github.com/inkdprotocol/inkd-protocol.git",
54
+ "directory": "sdk"
55
+ },
56
+ "homepage": "https://inkdprotocol.xyz",
57
+ "bugs": {
58
+ "url": "https://github.com/inkdprotocol/inkd-protocol/issues"
59
+ },
60
+ "peerDependencies": {
61
+ "viem": ">=2.0.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "react": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "devDependencies": {
69
+ "@types/react": "^19.2.14",
70
+ "@vitest/coverage-v8": "^1.6.1",
71
+ "typescript": "^5.0.0",
72
+ "viem": "^2.0.0",
73
+ "vitest": "^1.6.1"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public"
77
+ }
78
+ }