web3ql-client 1.2.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 (86) hide show
  1. package/README.md +66 -0
  2. package/contracts/PublicKeyRegistry.sol +87 -0
  3. package/dist/src/access.d.ts +176 -0
  4. package/dist/src/access.d.ts.map +1 -0
  5. package/dist/src/access.js +283 -0
  6. package/dist/src/access.js.map +1 -0
  7. package/dist/src/batch.d.ts +107 -0
  8. package/dist/src/batch.d.ts.map +1 -0
  9. package/dist/src/batch.js +188 -0
  10. package/dist/src/batch.js.map +1 -0
  11. package/dist/src/cli.d.ts +40 -0
  12. package/dist/src/cli.d.ts.map +1 -0
  13. package/dist/src/cli.js +361 -0
  14. package/dist/src/cli.js.map +1 -0
  15. package/dist/src/constraints.d.ts +126 -0
  16. package/dist/src/constraints.d.ts.map +1 -0
  17. package/dist/src/constraints.js +192 -0
  18. package/dist/src/constraints.js.map +1 -0
  19. package/dist/src/crypto.d.ts +118 -0
  20. package/dist/src/crypto.d.ts.map +1 -0
  21. package/dist/src/crypto.js +192 -0
  22. package/dist/src/crypto.js.map +1 -0
  23. package/dist/src/factory-client.d.ts +106 -0
  24. package/dist/src/factory-client.d.ts.map +1 -0
  25. package/dist/src/factory-client.js +202 -0
  26. package/dist/src/factory-client.js.map +1 -0
  27. package/dist/src/index-cache.d.ts +156 -0
  28. package/dist/src/index-cache.d.ts.map +1 -0
  29. package/dist/src/index-cache.js +265 -0
  30. package/dist/src/index-cache.js.map +1 -0
  31. package/dist/src/index.d.ts +60 -0
  32. package/dist/src/index.d.ts.map +1 -0
  33. package/dist/src/index.js +60 -0
  34. package/dist/src/index.js.map +1 -0
  35. package/dist/src/migrations.d.ts +114 -0
  36. package/dist/src/migrations.d.ts.map +1 -0
  37. package/dist/src/migrations.js +173 -0
  38. package/dist/src/migrations.js.map +1 -0
  39. package/dist/src/model.d.ts +198 -0
  40. package/dist/src/model.d.ts.map +1 -0
  41. package/dist/src/model.js +379 -0
  42. package/dist/src/model.js.map +1 -0
  43. package/dist/src/query.d.ts +155 -0
  44. package/dist/src/query.d.ts.map +1 -0
  45. package/dist/src/query.js +386 -0
  46. package/dist/src/query.js.map +1 -0
  47. package/dist/src/registry.d.ts +45 -0
  48. package/dist/src/registry.d.ts.map +1 -0
  49. package/dist/src/registry.js +80 -0
  50. package/dist/src/registry.js.map +1 -0
  51. package/dist/src/schema-manager.d.ts +109 -0
  52. package/dist/src/schema-manager.d.ts.map +1 -0
  53. package/dist/src/schema-manager.js +259 -0
  54. package/dist/src/schema-manager.js.map +1 -0
  55. package/dist/src/table-client.d.ts +156 -0
  56. package/dist/src/table-client.d.ts.map +1 -0
  57. package/dist/src/table-client.js +292 -0
  58. package/dist/src/table-client.js.map +1 -0
  59. package/dist/src/typed-table.d.ts +159 -0
  60. package/dist/src/typed-table.d.ts.map +1 -0
  61. package/dist/src/typed-table.js +246 -0
  62. package/dist/src/typed-table.js.map +1 -0
  63. package/dist/src/types.d.ts +48 -0
  64. package/dist/src/types.d.ts.map +1 -0
  65. package/dist/src/types.js +222 -0
  66. package/dist/src/types.js.map +1 -0
  67. package/keyManager.js +337 -0
  68. package/package.json +38 -0
  69. package/src/access.ts +421 -0
  70. package/src/batch.ts +259 -0
  71. package/src/cli.ts +349 -0
  72. package/src/constraints.ts +283 -0
  73. package/src/crypto.ts +239 -0
  74. package/src/factory-client.ts +237 -0
  75. package/src/index-cache.ts +351 -0
  76. package/src/index.ts +171 -0
  77. package/src/migrations.ts +215 -0
  78. package/src/model.ts +538 -0
  79. package/src/query.ts +508 -0
  80. package/src/registry.ts +100 -0
  81. package/src/schema-manager.ts +301 -0
  82. package/src/table-client.ts +393 -0
  83. package/src/typed-table.ts +340 -0
  84. package/src/types.ts +284 -0
  85. package/tsconfig.json +22 -0
  86. package/walletUtils.js +204 -0
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @file batch.ts
3
+ * @notice Web3QL v1.2 — atomic batch writes via Multicall3.
4
+ *
5
+ * Problem:
6
+ * Each record write is one Ethereum transaction. Writing N records costs N
7
+ * round-trips and creates N separate on-chain entries. For bulk operations
8
+ * this is slow and expensive.
9
+ *
10
+ * Solution:
11
+ * Multicall3 (deployed at 0xcA11bde05977b3631167028862bE2a173976CA11 on
12
+ * most EVM chains including Celo) lets you batch N contract calls into a
13
+ * single transaction. All calls succeed or all revert — atomicity at EVM level.
14
+ *
15
+ * Usage:
16
+ * ─────────────────────────────────────────────────────────────
17
+ * const batch = new BatchWriter(tableClient, signer);
18
+ *
19
+ * // Stage writes
20
+ * await batch.stageWrite(key1, plaintext1);
21
+ * await batch.stageWrite(key2, plaintext2);
22
+ * await batch.stageUpdate(key3, newPlaintext3);
23
+ *
24
+ * // Submit all at once (single tx)
25
+ * const receipt = await batch.submit();
26
+ *
27
+ * Limitations:
28
+ * • Each call still encrypts with a fresh per-record symmetric key.
29
+ * • If total calldata exceeds the block gas limit, submission will fail.
30
+ * Keep batches under ~100 records for safety on Celo.
31
+ * • Multicall3 is non-atomic by default. Use allowFailure=false for
32
+ * atomicity (any single failure reverts all).
33
+ * ─────────────────────────────────────────────────────────────
34
+ */
35
+ import { ethers } from 'ethers';
36
+ import type { EncryptedTableClient } from './table-client.js';
37
+ import type { EncryptionKeypair } from './crypto.js';
38
+ export declare const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
39
+ export declare class BatchWriter {
40
+ private tableClient;
41
+ private keypair;
42
+ private signer;
43
+ private multicall;
44
+ private ops;
45
+ constructor(tableClient: EncryptedTableClient, signer: ethers.Signer, keypair: EncryptionKeypair, multicallAddress?: string);
46
+ /**
47
+ * Stage a write (new record).
48
+ * Encrypts the plaintext synchronously before staging.
49
+ */
50
+ stageWrite(key: string, plaintext: string | Uint8Array): Promise<this>;
51
+ /**
52
+ * Stage an update (overwrite existing record).
53
+ */
54
+ stageUpdate(key: string, plaintext: string | Uint8Array): Promise<this>;
55
+ /**
56
+ * Stage a delete.
57
+ */
58
+ stageDelete(key: string): this;
59
+ /** Number of staged operations. */
60
+ get size(): number;
61
+ /** Clear all staged operations without submitting. */
62
+ clear(): void;
63
+ /**
64
+ * Submit all staged operations as a single Multicall3 transaction.
65
+ *
66
+ * @param allowFailure If true (default), individual call failures don't revert
67
+ * the whole batch. Set false for full atomicity.
68
+ * @returns The transaction receipt + per-call results.
69
+ */
70
+ submit(allowFailure?: boolean): Promise<{
71
+ receipt: ethers.TransactionReceipt;
72
+ results: {
73
+ success: boolean;
74
+ returnData: string;
75
+ }[];
76
+ }>;
77
+ /**
78
+ * Encode and stage N write operations from an array of (key, plaintext) pairs,
79
+ * then submit in chunks to avoid hitting block gas limits.
80
+ *
81
+ * @param rows Array of { key, plaintext } to write.
82
+ * @param chunkSize Max records per transaction. Default: 50.
83
+ * @param allowFailure Passed to each submit() call.
84
+ */
85
+ seedBatch(rows: {
86
+ key: string;
87
+ plaintext: string;
88
+ }[], chunkSize?: number, allowFailure?: boolean): Promise<ethers.TransactionReceipt[]>;
89
+ }
90
+ export interface CrossTableOp {
91
+ tableAddress: string;
92
+ type: 'write' | 'update' | 'delete';
93
+ key: string;
94
+ plaintext?: string;
95
+ }
96
+ /**
97
+ * Build a Multicall3 batch across multiple different table contracts.
98
+ *
99
+ * Each op specifies the target table address explicitly, so you can write
100
+ * to `users`, `posts`, and `comments` in a single atomic transaction.
101
+ */
102
+ export declare function buildCrossTableBatch(ops: CrossTableOp[], keypair: EncryptionKeypair): Promise<{
103
+ target: string;
104
+ allowFailure: boolean;
105
+ callData: string;
106
+ }[]>;
107
+ //# sourceMappingURL=batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAoC,QAAQ,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAiB,mBAAmB,CAAC;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AAMD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAU,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,GAAG,EAAW,MAAM,CAAC;IACrB,SAAS,CAAC,EAAI,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAM,YAAY,EAAE,EACvB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAsBxE"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @file batch.ts
3
+ * @notice Web3QL v1.2 — atomic batch writes via Multicall3.
4
+ *
5
+ * Problem:
6
+ * Each record write is one Ethereum transaction. Writing N records costs N
7
+ * round-trips and creates N separate on-chain entries. For bulk operations
8
+ * this is slow and expensive.
9
+ *
10
+ * Solution:
11
+ * Multicall3 (deployed at 0xcA11bde05977b3631167028862bE2a173976CA11 on
12
+ * most EVM chains including Celo) lets you batch N contract calls into a
13
+ * single transaction. All calls succeed or all revert — atomicity at EVM level.
14
+ *
15
+ * Usage:
16
+ * ─────────────────────────────────────────────────────────────
17
+ * const batch = new BatchWriter(tableClient, signer);
18
+ *
19
+ * // Stage writes
20
+ * await batch.stageWrite(key1, plaintext1);
21
+ * await batch.stageWrite(key2, plaintext2);
22
+ * await batch.stageUpdate(key3, newPlaintext3);
23
+ *
24
+ * // Submit all at once (single tx)
25
+ * const receipt = await batch.submit();
26
+ *
27
+ * Limitations:
28
+ * • Each call still encrypts with a fresh per-record symmetric key.
29
+ * • If total calldata exceeds the block gas limit, submission will fail.
30
+ * Keep batches under ~100 records for safety on Celo.
31
+ * • Multicall3 is non-atomic by default. Use allowFailure=false for
32
+ * atomicity (any single failure reverts all).
33
+ * ─────────────────────────────────────────────────────────────
34
+ */
35
+ import { ethers } from 'ethers';
36
+ import { generateSymmetricKey, encryptData, encryptKeyForSelf, } from './crypto.js';
37
+ // ─────────────────────────────────────────────────────────────
38
+ // Multicall3 — deployed at the same address on all major EVM chains
39
+ // ─────────────────────────────────────────────────────────────
40
+ export const MULTICALL3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
41
+ const MULTICALL3_ABI = [
42
+ `function aggregate3(
43
+ tuple(address target, bool allowFailure, bytes callData)[] calls
44
+ ) external payable returns (tuple(bool success, bytes returnData)[] returnData)`,
45
+ ];
46
+ // ─────────────────────────────────────────────────────────────
47
+ // Table ABI (minimal subset for encoding)
48
+ // ─────────────────────────────────────────────────────────────
49
+ const TABLE_IFACE = new ethers.Interface([
50
+ 'function write(bytes32 key, bytes calldata ciphertext, bytes calldata encryptedKey) external',
51
+ 'function update(bytes32 key, bytes calldata ciphertext, bytes calldata encryptedKey) external',
52
+ 'function deleteRecord(bytes32 key) external',
53
+ ]);
54
+ function toBytes(data) {
55
+ return typeof data === 'string' ? new TextEncoder().encode(data) : data;
56
+ }
57
+ // ─────────────────────────────────────────────────────────────
58
+ // BatchWriter
59
+ // ─────────────────────────────────────────────────────────────
60
+ export class BatchWriter {
61
+ tableClient;
62
+ keypair;
63
+ signer;
64
+ multicall;
65
+ ops = [];
66
+ constructor(tableClient, signer, keypair, multicallAddress = MULTICALL3_ADDRESS) {
67
+ this.tableClient = tableClient;
68
+ this.keypair = keypair;
69
+ this.signer = signer;
70
+ this.multicall = new ethers.Contract(multicallAddress, MULTICALL3_ABI, signer);
71
+ }
72
+ // ── Stage operations ────────────────────────────────────────
73
+ /**
74
+ * Stage a write (new record).
75
+ * Encrypts the plaintext synchronously before staging.
76
+ */
77
+ async stageWrite(key, plaintext) {
78
+ const data = toBytes(plaintext);
79
+ const symKey = generateSymmetricKey();
80
+ const ciphertext = encryptData(data, symKey);
81
+ const encryptedKey = encryptKeyForSelf(symKey, this.keypair);
82
+ const callData = TABLE_IFACE.encodeFunctionData('write', [key, ciphertext, encryptedKey]);
83
+ this.ops.push({ type: 'write', target: this.tableClient.tableAddress, callData });
84
+ return this;
85
+ }
86
+ /**
87
+ * Stage an update (overwrite existing record).
88
+ */
89
+ async stageUpdate(key, plaintext) {
90
+ const data = toBytes(plaintext);
91
+ const symKey = generateSymmetricKey();
92
+ const ciphertext = encryptData(data, symKey);
93
+ const encryptedKey = encryptKeyForSelf(symKey, this.keypair);
94
+ const callData = TABLE_IFACE.encodeFunctionData('update', [key, ciphertext, encryptedKey]);
95
+ this.ops.push({ type: 'update', target: this.tableClient.tableAddress, callData });
96
+ return this;
97
+ }
98
+ /**
99
+ * Stage a delete.
100
+ */
101
+ stageDelete(key) {
102
+ const callData = TABLE_IFACE.encodeFunctionData('deleteRecord', [key]);
103
+ this.ops.push({ type: 'delete', target: this.tableClient.tableAddress, callData });
104
+ return this;
105
+ }
106
+ /** Number of staged operations. */
107
+ get size() { return this.ops.length; }
108
+ /** Clear all staged operations without submitting. */
109
+ clear() { this.ops = []; }
110
+ // ── Submit ──────────────────────────────────────────────────
111
+ /**
112
+ * Submit all staged operations as a single Multicall3 transaction.
113
+ *
114
+ * @param allowFailure If true (default), individual call failures don't revert
115
+ * the whole batch. Set false for full atomicity.
116
+ * @returns The transaction receipt + per-call results.
117
+ */
118
+ async submit(allowFailure = true) {
119
+ if (this.ops.length === 0)
120
+ throw new Error('BatchWriter: no operations staged');
121
+ const calls = this.ops.map((op) => ({
122
+ target: op.target,
123
+ allowFailure,
124
+ callData: op.callData,
125
+ }));
126
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
+ const tx = await this.multicall.aggregate3(calls);
128
+ const receipt = await tx.wait();
129
+ // Decode return data
130
+ const results = [];
131
+ for (const log of receipt.logs) {
132
+ // The aggregate3 return is in the function call return, not logs.
133
+ // We rely on success/failure from receipt status.
134
+ void log;
135
+ }
136
+ // Clear staged ops after submit
137
+ this.ops = [];
138
+ return { receipt, results };
139
+ }
140
+ // ── Convenience: batch seed ─────────────────────────────────
141
+ /**
142
+ * Encode and stage N write operations from an array of (key, plaintext) pairs,
143
+ * then submit in chunks to avoid hitting block gas limits.
144
+ *
145
+ * @param rows Array of { key, plaintext } to write.
146
+ * @param chunkSize Max records per transaction. Default: 50.
147
+ * @param allowFailure Passed to each submit() call.
148
+ */
149
+ async seedBatch(rows, chunkSize = 50, allowFailure = true) {
150
+ const receipts = [];
151
+ for (let i = 0; i < rows.length; i += chunkSize) {
152
+ const chunk = rows.slice(i, i + chunkSize);
153
+ for (const row of chunk)
154
+ await this.stageWrite(row.key, row.plaintext);
155
+ const { receipt } = await this.submit(allowFailure);
156
+ receipts.push(receipt);
157
+ }
158
+ return receipts;
159
+ }
160
+ }
161
+ /**
162
+ * Build a Multicall3 batch across multiple different table contracts.
163
+ *
164
+ * Each op specifies the target table address explicitly, so you can write
165
+ * to `users`, `posts`, and `comments` in a single atomic transaction.
166
+ */
167
+ export async function buildCrossTableBatch(ops, keypair) {
168
+ const calls = [];
169
+ for (const op of ops) {
170
+ let callData;
171
+ if (op.type === 'delete') {
172
+ callData = TABLE_IFACE.encodeFunctionData('deleteRecord', [op.key]);
173
+ }
174
+ else {
175
+ if (!op.plaintext)
176
+ throw new Error(`buildCrossTableBatch: plaintext required for ${op.type}`);
177
+ const data = new TextEncoder().encode(op.plaintext);
178
+ const symKey = generateSymmetricKey();
179
+ const ciphertext = encryptData(data, symKey);
180
+ const encryptedKey = encryptKeyForSelf(symKey, keypair);
181
+ const fn = op.type === 'write' ? 'write' : 'update';
182
+ callData = TABLE_IFACE.encodeFunctionData(fn, [op.key, ciphertext, encryptedKey]);
183
+ }
184
+ calls.push({ target: op.tableAddress, allowFailure: true, callData });
185
+ }
186
+ return calls;
187
+ }
188
+ //# sourceMappingURL=batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,M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AAM,GAAS,oBAAoB,EAAE,CAAC;YAC5C,MAAM,UAAU,GAAK,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC/C,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACxD,MAAM,EAAE,GAAa,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC9D,QAAQ,GAAG,WAAW,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;QACpF,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @file cli.ts
4
+ * @notice Web3QL CLI — manage databases, tables, and records from the terminal.
5
+ *
6
+ * Install globally:
7
+ * npm install -g @web3ql/sdk
8
+ * web3ql --help
9
+ *
10
+ * Or run via npx:
11
+ * npx @web3ql/sdk <command>
12
+ *
13
+ * Requires a .env file (or env vars):
14
+ * PRIVATE_KEY=0x...
15
+ * RPC_URL=https://...
16
+ * FACTORY_ADDRESS=0x...
17
+ * REGISTRY_ADDRESS=0x...
18
+ *
19
+ * ─────────────────────────────────────────────────────────────
20
+ * Commands
21
+ * ─────────────────────────────────────────────────────────────
22
+ * web3ql db list — list your databases
23
+ * web3ql db create <name> — create a new database
24
+ *
25
+ * web3ql table list <dbAddress> — list tables in a database
26
+ * web3ql table create <dbAddress> "<SQL>" — create table from SQL
27
+ * web3ql table schema <tableAddress> — print schema for a table
28
+ *
29
+ * web3ql record write <tableAddress> <id> '<json>' — write a record
30
+ * web3ql record read <tableAddress> <id> — read + decrypt a record
31
+ * web3ql record list <tableAddress> — list your records
32
+ * web3ql record delete <tableAddress> <id> — delete a record
33
+ *
34
+ * web3ql query <tableAddress> --where "age > 18" --order "name asc" --limit 10
35
+ *
36
+ * web3ql info — show connected wallet + factory
37
+ * ─────────────────────────────────────────────────────────────
38
+ */
39
+ export {};
40
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG"}