@iqlabs-official/solana-sdk 0.1.7 → 0.1.8

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 CHANGED
@@ -408,7 +408,41 @@ myFiles.forEach(tx => {
408
408
  ```typescript
409
409
  import iqlabs from '@iqlabs-official/solana-sdk';
410
410
 
411
- iqlabs.utils.setRpcUrl('https://your-rpc.example.com');
411
+ iqlabs.setRpcUrl('https://your-rpc.example.com');
412
+ ```
413
+
414
+ ### `getRpcUrl()`
415
+
416
+ Returns the currently configured RPC URL.
417
+
418
+ | Parameter | Type | Description |
419
+ |---|---|---|
420
+ | **Returns** | `string` | The current RPC URL |
421
+
422
+ **Example:**
423
+ ```typescript
424
+ const url = iqlabs.getRpcUrl();
425
+ console.log(url); // https://api.mainnet-beta.solana.com
426
+ ```
427
+
428
+ ---
429
+
430
+ ### User Metadata
431
+
432
+ #### `updateUserMetadata()`
433
+
434
+ | **Parameters** | `connection`: Solana RPC Connection<br>`signer`: Signer<br>`dbRootId`: database ID (Uint8Array or string)<br>`meta`: metadata to store (Uint8Array or string) |
435
+ |----------|--------------------------|
436
+ | **Returns** | Transaction signature (string) |
437
+
438
+ **Example:**
439
+ ```typescript
440
+ import iqlabs from '@iqlabs-official/solana-sdk';
441
+
442
+ await iqlabs.writer.updateUserMetadata(
443
+ connection, signer, 'my-db',
444
+ JSON.stringify({ name: 'Alice', bio: 'gm' })
445
+ );
412
446
  ```
413
447
 
414
448
  ---
@@ -1,2 +1,2 @@
1
1
  export { codeIn } from "./code_in";
2
- export { writeRow, writeConnectionRow, manageRowData, requestConnection, } from "./iqdb";
2
+ export { writeRow, writeConnectionRow, manageRowData, requestConnection, updateUserMetadata, } from "./iqdb";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requestConnection = exports.manageRowData = exports.writeConnectionRow = exports.writeRow = exports.codeIn = void 0;
3
+ exports.updateUserMetadata = exports.requestConnection = exports.manageRowData = exports.writeConnectionRow = exports.writeRow = exports.codeIn = void 0;
4
4
  // writer: high-level flows only
5
5
  var code_in_1 = require("./code_in");
6
6
  Object.defineProperty(exports, "codeIn", { enumerable: true, get: function () { return code_in_1.codeIn; } });
@@ -9,3 +9,4 @@ Object.defineProperty(exports, "writeRow", { enumerable: true, get: function ()
9
9
  Object.defineProperty(exports, "writeConnectionRow", { enumerable: true, get: function () { return iqdb_1.writeConnectionRow; } });
10
10
  Object.defineProperty(exports, "manageRowData", { enumerable: true, get: function () { return iqdb_1.manageRowData; } });
11
11
  Object.defineProperty(exports, "requestConnection", { enumerable: true, get: function () { return iqdb_1.requestConnection; } });
12
+ Object.defineProperty(exports, "updateUserMetadata", { enumerable: true, get: function () { return iqdb_1.updateUserMetadata; } });
@@ -9,4 +9,5 @@ export declare function resolveSignerAta(connection: Connection, signer: Signer,
9
9
  export declare function writeRow(connection: Connection, signer: Signer, dbRootId: Uint8Array | string, tableSeed: Uint8Array | string, rowJson: string, skipConfirmation?: boolean): Promise<string>;
10
10
  export declare function writeConnectionRow(connection: Connection, signer: Signer, dbRootId: Uint8Array | string, connectionSeed: Uint8Array | string, rowJson: string): Promise<string>;
11
11
  export declare function manageRowData(connection: Connection, signer: Signer, dbRootId: Uint8Array | string, seed: Uint8Array | string, rowJson: string, tableName?: string | Uint8Array, targetTx?: string | Uint8Array): Promise<string>;
12
+ export declare function updateUserMetadata(connection: Connection, signer: Signer, dbRootId: Uint8Array | string, meta: Uint8Array | string): Promise<string>;
12
13
  export declare function requestConnection(connection: Connection, signer: Signer, dbRootId: Uint8Array | string, partyA: string, partyB: string, tableName: string | Uint8Array, columns: Array<string | Uint8Array>, idCol: string | Uint8Array, extKeys: Array<string | Uint8Array>): Promise<string>;
@@ -5,6 +5,7 @@ exports.resolveSignerAta = resolveSignerAta;
5
5
  exports.writeRow = writeRow;
6
6
  exports.writeConnectionRow = writeConnectionRow;
7
7
  exports.manageRowData = manageRowData;
8
+ exports.updateUserMetadata = updateUserMetadata;
8
9
  exports.requestConnection = requestConnection;
9
10
  const web3_js_1 = require("@solana/web3.js");
10
11
  const contract_1 = require("../../contract");
@@ -203,6 +204,24 @@ async function manageRowData(connection, signer, dbRootId, seed, rowJson, tableN
203
204
  }
204
205
  throw new Error("table/connection not found");
205
206
  }
207
+ async function updateUserMetadata(connection, signer, dbRootId, meta) {
208
+ const programId = contract_1.PROGRAM_ID;
209
+ const builder = (0, contract_1.createInstructionBuilder)(IDL, programId);
210
+ const dbRootSeed = (0, seed_1.toSeedBytes)(dbRootId);
211
+ const dbRoot = (0, contract_1.getDbRootPda)(dbRootSeed, programId);
212
+ const user = (0, contract_1.getUserPda)(signer.publicKey, programId);
213
+ const metaBytes = typeof meta === "string" ? Buffer.from(meta, "utf8") : meta;
214
+ const ix = (0, contract_1.updateUserMetadataInstruction)(builder, {
215
+ user,
216
+ db_root: dbRoot,
217
+ signer: signer.publicKey,
218
+ system_program: web3_js_1.SystemProgram.programId,
219
+ }, {
220
+ db_root_id: dbRootSeed,
221
+ meta: metaBytes,
222
+ });
223
+ return (0, writer_utils_1.sendTx)(connection, signer, ix);
224
+ }
206
225
  async function requestConnection(connection, signer, dbRootId, partyA, partyB, tableName, columns, idCol, extKeys) {
207
226
  // Validate requester
208
227
  const programId = contract_1.PROGRAM_ID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqlabs-official/solana-sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": ["dist", "idl"],