@iqlabs-official/git-sdk 0.1.12 → 0.1.15

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.
@@ -1,6 +1,7 @@
1
1
  import { SessionSpeedOption, SignerInput } from '@iqlabs-official/solana-sdk/utils';
2
2
  export { DEFAULT_SESSION_SPEED, SESSION_SPEED_PROFILES, SignerInput, resolveSessionSpeed } from '@iqlabs-official/solana-sdk/utils';
3
- import { Connection, PublicKey } from '@solana/web3.js';
3
+ import { Connection } from '@solana/web3.js';
4
+ import { Signer } from 'ethers';
4
5
 
5
6
  /** Metadata row stored in `git_repos_v2_<owner>`. */
6
7
  interface Repository {
@@ -30,6 +31,30 @@ interface RegistryEntry {
30
31
  description: string;
31
32
  timestamp: number;
32
33
  }
34
+ /** Deploy marker row stored in the `iqpages-root/deployed` gallery table. */
35
+ interface PagesDeployment {
36
+ id: string;
37
+ owner: string;
38
+ repo: string;
39
+ deployedAt: number;
40
+ }
41
+ /** `iqpages.json` — the deploy manifest a repo commits at its root. */
42
+ interface PagesConfig {
43
+ name: string;
44
+ version: string;
45
+ description: string;
46
+ entry: string;
47
+ }
48
+ /** `iqprofile.json` — optional profile/routing metadata for a deployed site. */
49
+ interface PagesProfile {
50
+ displayName: string;
51
+ description: string;
52
+ icon?: string;
53
+ routes?: {
54
+ profile?: string;
55
+ myPage?: string;
56
+ };
57
+ }
33
58
 
34
59
  /** DbRoot id for every iq-git table. Bootstrap and every caller share this. */
35
60
  declare const IQGIT_ROOT_ID = "iq-git-v1";
@@ -47,17 +72,49 @@ declare function repoListHint(owner: string): string;
47
72
  * output: "git_commits:<owner>:<repo>"
48
73
  */
49
74
  declare function commitTableHint(owner: string, repo: string): string;
50
-
75
+ /** DbRoot id for the iq-pages deployment gallery. */
76
+ declare const IQPAGES_ROOT_ID = "iqpages-root";
77
+ /** Single open-writers table that holds every deploy marker row. */
78
+ declare const IQPAGES_DEPLOYED_HINT = "deployed";
79
+ /** One-time deploy fee on Solana, in lamports (0.2 SOL). */
80
+ declare const PAGES_FEE_LAMPORTS = 200000000;
81
+ /** One-time deploy fee on EVM, in wei (0.01 ETH — value-matched to 0.2 SOL). */
82
+ declare const PAGES_FEE_WEI = 10000000000000000n;
83
+ /** Receiver of the Solana deploy fee. Same hard receiver the contract uses. */
84
+ declare const PAGES_FEE_RECIPIENT = "EWNSTD8tikwqHMcRNuuNbZrnYJUiJdKq9UXLXSEU4wZ1";
85
+ /** Receiver of the EVM deploy fee — the same address the ethereum-sdk's
86
+ * on-chain `feeReceiver()` resolves to across sepolia / monad / monadTestnet
87
+ * (verified identical on all three). Pages fee is an app-layer transfer
88
+ * outside the contract, so we send it to the protocol's fee wallet directly. */
89
+ declare const PAGES_FEE_RECIPIENT_EVM = "0xE94fA75aB69C18635A35556E9313e8D2aE009459";
90
+ /** Config / profile filenames a repo must commit to be deployable. */
91
+ declare const IQPAGES_CONFIG_FILENAME = "iqpages.json";
92
+ declare const IQPAGES_PROFILE_FILENAME = "iqprofile.json";
51
93
  /**
52
- * Speed forwarded to `iqlabs.writer.codeIn`. Either a preset name
53
- * (`"light" | "medium" | "heavy" | "extreme"`) or a raw override object —
54
- * `{ maxRps?, maxConcurrency?, maxConcurrencyUpload? }` — when you want to
55
- * dial RPS / concurrency directly without picking a preset.
56
- *
57
- * Re-exported here so consumers don't have to import both SDKs to pick a
58
- * value. See solana-sdk's `SessionSpeedOption` for the full type.
94
+ * Deploy-marker row id.
95
+ * input: owner wallet address, repo name
96
+ * output: "<owner>:<repo>"
59
97
  */
98
+ declare function pagesDeployId(owner: string, repo: string): string;
99
+
100
+ /** Re-exported solana-sdk speed dial — preset name or raw RPS/concurrency
101
+ * override. EVM ignores it (no client-side chunk pacing on that path). */
60
102
  type SessionSpeed = SessionSpeedOption;
103
+ /**
104
+ * Opaque handle to a table. Solana resolves a hint to a `PublicKey` PDA; EVM
105
+ * resolves it to `{ dbRootId, tableName }`. Callers above L1 treat it as a
106
+ * black box and only ever hand it back to `readRowsByRef`.
107
+ */
108
+ type TableRef = unknown;
109
+ /**
110
+ * A signer accepted by the active chain. The Solana adapter narrows to
111
+ * `SignerInput` (Keypair / wallet adapter); the EVM adapter narrows to an
112
+ * ethers `Signer`. Kept as a union here so one `ChainOps` interface can be
113
+ * satisfied by both — Phase 2 threads this through the client surface.
114
+ */
115
+ type GitSigner = SignerInput | Signer;
116
+ /** EVM sub-networks the eth adapter understands (mirrors ethereum-sdk). */
117
+ type EthNetwork = "sepolia" | "monad" | "monadTestnet";
61
118
 
62
119
  /** Information surfaced to the `onWrite` callback for every successful row
63
120
  * write the SDK performs. Consumers wire this to their gateway notify so
@@ -72,19 +129,37 @@ interface WriteEvent {
72
129
  /** The row object that was written (already JSON.stringify-able). */
73
130
  row: object;
74
131
  }
75
- interface GitClientConfig {
76
- connection: Connection;
77
- signer: SignerInput;
132
+ /** Fields common to every chain's client config. */
133
+ interface BaseClientConfig {
78
134
  /** Fires after each successful row write inside the SDK. Fire-and-forget
79
135
  * callback for gateway notifies; throwing here will surface to the caller. */
80
136
  onWrite?: (event: WriteEvent) => void;
81
- /** Default solana-sdk session speed for blob / tree uploads (`"light"` is
82
- * the per-operation default and works well on Helius free-tier RPCs).
83
- * Override per call with `commit({ speed })`. See `SESSION_SPEED_PROFILES`. */
137
+ /** Default session speed for blob / tree uploads (`"light"` is the per-op
138
+ * default; Helius-friendly). EVM ignores it. Override per call with
139
+ * `commit({ speed })`. See `SESSION_SPEED_PROFILES`. */
84
140
  speed?: SessionSpeed;
85
141
  }
142
+ /** Solana client: a web3.js `Connection` + a Solana signer. `chain` is
143
+ * optional and defaults to `'solana'` so existing callers keep working. */
144
+ interface SolanaClientConfig extends BaseClientConfig {
145
+ chain?: "solana";
146
+ connection: Connection;
147
+ signer: SignerInput;
148
+ }
149
+ /** EVM client: an ethers `Signer` (carries its provider) + the target EVM
150
+ * network. No `Connection`. */
151
+ interface EthClientConfig extends BaseClientConfig {
152
+ chain: "eth";
153
+ signer: Signer;
154
+ network: EthNetwork;
155
+ /** Optional RPC override; defaults to the network's public endpoint. */
156
+ rpcUrl?: string;
157
+ }
158
+ type GitClientConfig = SolanaClientConfig | EthClientConfig;
86
159
  declare class GitClient {
87
160
  private readonly cfg;
161
+ /** The configured signer, as the chain-neutral union the layers consume. */
162
+ private readonly signer;
88
163
  constructor(cfg: GitClientConfig);
89
164
  /**
90
165
  * Create a new repo. Wraps repo.createRepo + pre-creating the commit table
@@ -134,13 +209,13 @@ declare class GitClient {
134
209
  }
135
210
 
136
211
  /** List all repos owned by `owner`. */
137
- declare function readOwnerRepos(_connection: Connection, owner: string): Promise<Repository[]>;
212
+ declare function readOwnerRepos(owner: string): Promise<Repository[]>;
138
213
  /**
139
214
  * One page of the public-gallery registry. Callers should still check
140
215
  * `row.owner` shape before trusting it in UI; we do not filter at the SDK
141
216
  * boundary.
142
217
  */
143
- declare function readRegistryPage(_connection: Connection, options?: {
218
+ declare function readRegistryPage(options?: {
144
219
  limit?: number;
145
220
  before?: string;
146
221
  }): Promise<RegistryEntry[]>;
@@ -149,7 +224,7 @@ declare function readRegistryPage(_connection: Connection, options?: {
149
224
  * network from an admin key; subsequent calls short-circuit because the
150
225
  * account already exists.
151
226
  */
152
- declare function bootstrapRegistry(connection: Connection, signer: SignerInput): Promise<string | null>;
227
+ declare function bootstrapRegistry(signer: GitSigner): Promise<string | null>;
153
228
 
154
229
  /**
155
230
  * Append one commit row. Callers (workflow-level code) are responsible for
@@ -159,15 +234,15 @@ declare function bootstrapRegistry(connection: Connection, signer: SignerInput):
159
234
  * iq-gateway already caching this table prepends the new commit without
160
235
  * waiting for RPC sig indexing.
161
236
  */
162
- declare function writeCommit(connection: Connection, signer: SignerInput, repo: string, commit: Commit): Promise<string>;
163
- /** The commit-table PDA for a repo. The one place owner/repo collapses to a
164
- * PDA — every read keys off the PDA, so callers that have a PDA already (a
165
- * .sol record, a dbroot match) skip this and pass it straight in. */
166
- declare function commitTablePda(owner: string, repo: string): PublicKey;
167
- /** Latest commit. Single-row, O(1) RPC path. */
168
- declare function readLatestCommit(pda: PublicKey): Promise<Commit | null>;
237
+ declare function writeCommit(signer: GitSigner, repo: string, commit: Commit): Promise<string>;
238
+ /** The commit-table reference for a repo. The one place owner/repo collapses
239
+ * to a chain handle — every read keys off it, so callers that already have a
240
+ * ref (a .sol record, a dbroot match) skip this and pass it straight in. */
241
+ declare function commitTableRef(owner: string, repo: string): TableRef;
242
+ /** Latest commit. Single-row, O(1) read path. */
243
+ declare function readLatestCommit(ref: TableRef): Promise<Commit | null>;
169
244
  /** Full commit history, newest first. */
170
- declare function readCommitHistory(pda: PublicKey, options?: {
245
+ declare function readCommitHistory(ref: TableRef, options?: {
171
246
  limit?: number;
172
247
  before?: string;
173
248
  }): Promise<Commit[]>;
@@ -178,14 +253,14 @@ declare function readCommitHistory(pda: PublicKey, options?: {
178
253
  * input: connection, signer, relativePath, base64 content, reuse map, optional onProgress
179
254
  * output: { txId, hash } — either reused or freshly uploaded
180
255
  */
181
- declare function uploadBlob(connection: Connection, signer: SignerInput, relativePath: string, base64Content: string, reuse: FileTree, onProgress?: (percent: number) => void, speed?: SessionSpeed): Promise<{
256
+ declare function uploadBlob(signer: GitSigner, relativePath: string, base64Content: string, reuse: FileTree, onProgress?: (percent: number) => void, speed?: SessionSpeed): Promise<{
182
257
  txId: string;
183
258
  hash: string;
184
259
  }>;
185
260
  /**
186
261
  * Serialize a FileTree and upload it as one `tree.json` blob.
187
262
  */
188
- declare function uploadTree(connection: Connection, signer: SignerInput, tree: FileTree, speed?: SessionSpeed): Promise<string>;
263
+ declare function uploadTree(signer: GitSigner, tree: FileTree, speed?: SessionSpeed): Promise<string>;
189
264
  /**
190
265
  * Fetch and parse a `tree.json` blob by its tx signature.
191
266
  */
@@ -196,12 +271,55 @@ declare function loadTree(treeTxId: string): Promise<FileTree>;
196
271
  */
197
272
  declare function loadBlob(txId: string): Promise<string>;
198
273
 
274
+ /** Ref to the single `iqpages-root/deployed` gallery table. Pages owns the
275
+ * (root, hint) identity; the active adapter resolves it (Solana PDA / EVM
276
+ * coordinates) — chain-neutral. */
277
+ declare function pagesTableRef(): TableRef;
278
+ /** Every deploy marker in the gallery. Gateway-first, RPC fallback (handled by
279
+ * the adapter). */
280
+ declare function listPagesDeployments(): Promise<PagesDeployment[]>;
281
+ /** True if `<owner>/<repo>` already has a deploy marker. */
282
+ declare function isPagesDeployed(owner: string, repo: string): Promise<boolean>;
283
+ /** `iqpages.json` from the repo's latest commit, or null if not committed. */
284
+ declare function readPagesConfig(owner: string, repo: string): Promise<PagesConfig | null>;
285
+ /** `iqprofile.json` from the repo's latest commit, or null if not committed. */
286
+ declare function readPagesProfile(owner: string, repo: string): Promise<PagesProfile | null>;
287
+ /**
288
+ * Register `<owner>/<repo>` in the gallery and charge the one-time fee.
289
+ *
290
+ * Pre-flight (in order): not already deployed → `iqpages.json` is committed.
291
+ * Then it ensures the gallery exists, writes the marker row, and transfers the
292
+ * fee in a separate tx (the contract can't do both atomically).
293
+ *
294
+ * Returns the marker-row tx id plus the resolved config so callers can print
295
+ * the live site URL without a second read.
296
+ */
297
+ declare function deployPages(signer: GitSigner, repo: string): Promise<{
298
+ sig: string;
299
+ config: PagesConfig;
300
+ }>;
301
+
199
302
  /** Pin the gateway URL list explicitly. Highest precedence. Pass `[]` to
200
303
  * disable gateway dispatch entirely (RPC-only mode). */
201
304
  declare function setGatewayUrls(urls: string[]): void;
202
- /** Pin the network label when the RPC URL doesn't reveal it (private nodes,
203
- * proxies, etc.). Has no effect when setGatewayUrls() is also set. */
204
- declare function setNetwork(network: "mainnet" | "devnet"): void;
205
305
  declare function getGatewayUrls(): string[];
206
306
 
207
- export { type Commit, type FileTree, GitClient, type GitClientConfig, IQGIT_ROOT_ID, REGISTRY_HINT, type RegistryEntry, type Repository, type SessionSpeed, type WriteEvent, bootstrapRegistry, commitTableHint, commitTablePda, getGatewayUrls, loadBlob, loadTree, readCommitHistory, readLatestCommit, readOwnerRepos, readRegistryPage, repoListHint, setGatewayUrls, setNetwork, uploadBlob, uploadTree, writeCommit };
307
+ type SolanaNetwork = "devnet" | "mainnet";
308
+ /** Every token `setNetwork` accepts. `'eth'` ⇒ sepolia (EVM default). */
309
+ type NetworkToken = SolanaNetwork | "eth" | EthNetwork;
310
+ /**
311
+ * Switch the active chain + network from a single token.
312
+ *
313
+ * setNetwork('mainnet') // Solana mainnet
314
+ * setNetwork('devnet') // Solana devnet
315
+ * setNetwork('eth') // EVM, sepolia (default)
316
+ * setNetwork('monad', { rpcUrl }) // EVM, monad, custom RPC
317
+ *
318
+ * `rpcUrl` only applies to EVM tokens (the EVM adapter holds the provider);
319
+ * Solana reads resolve their RPC from the gateway / `setRpcUrl`.
320
+ */
321
+ declare function setNetwork(token: NetworkToken, options?: {
322
+ rpcUrl?: string;
323
+ }): void;
324
+
325
+ export { type Commit, type EthClientConfig, type EthNetwork, type FileTree, GitClient, type GitClientConfig, type GitSigner, IQGIT_ROOT_ID, IQPAGES_CONFIG_FILENAME, IQPAGES_DEPLOYED_HINT, IQPAGES_PROFILE_FILENAME, IQPAGES_ROOT_ID, type NetworkToken, PAGES_FEE_LAMPORTS, PAGES_FEE_RECIPIENT, PAGES_FEE_RECIPIENT_EVM, PAGES_FEE_WEI, type PagesConfig, type PagesDeployment, type PagesProfile, REGISTRY_HINT, type RegistryEntry, type Repository, type SessionSpeed, type SolanaClientConfig, type SolanaNetwork, type TableRef, type WriteEvent, bootstrapRegistry, commitTableHint, commitTableRef, deployPages, getGatewayUrls, isPagesDeployed, listPagesDeployments, loadBlob, loadTree, pagesDeployId, pagesTableRef, readCommitHistory, readLatestCommit, readOwnerRepos, readPagesConfig, readPagesProfile, readRegistryPage, repoListHint, setGatewayUrls, setNetwork, uploadBlob, uploadTree, writeCommit };