@xandeum/web3.js 0.4.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.
- package/LICENSE +51 -0
- package/README.md +167 -0
- package/archbee.yaml +55 -0
- package/dist/armageddon.d.ts +10 -0
- package/dist/armageddon.js +77 -0
- package/dist/assignCoowner.d.ts +12 -0
- package/dist/assignCoowner.js +81 -0
- package/dist/bigbang.d.ts +9 -0
- package/dist/bigbang.js +76 -0
- package/dist/const.d.ts +1 -0
- package/dist/const.js +4 -0
- package/dist/copyPath.d.ts +13 -0
- package/dist/copyPath.js +86 -0
- package/dist/createDirectory.d.ts +12 -0
- package/dist/createDirectory.js +84 -0
- package/dist/createFile.d.ts +13 -0
- package/dist/createFile.js +85 -0
- package/dist/exists.d.ts +20 -0
- package/dist/exists.js +86 -0
- package/dist/find.d.ts +22 -0
- package/dist/find.js +88 -0
- package/dist/getInfo.d.ts +12 -0
- package/dist/getInfo.js +77 -0
- package/dist/getMetadata.d.ts +23 -0
- package/dist/getMetadata.js +89 -0
- package/dist/getXandeumResult.d.ts +15 -0
- package/dist/getXandeumResult.js +95 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +37 -0
- package/dist/listDirectoryEntery.d.ts +21 -0
- package/dist/listDirectoryEntery.js +87 -0
- package/dist/move.d.ts +14 -0
- package/dist/move.js +88 -0
- package/dist/peek.d.ts +15 -0
- package/dist/peek.js +88 -0
- package/dist/poke.d.ts +14 -0
- package/dist/poke.js +93 -0
- package/dist/removeDirectory.d.ts +12 -0
- package/dist/removeDirectory.js +82 -0
- package/dist/removeFile.d.ts +12 -0
- package/dist/removeFile.js +82 -0
- package/dist/renamePath.d.ts +13 -0
- package/dist/renamePath.js +85 -0
- package/dist/sanitizePath.d.ts +14 -0
- package/dist/sanitizePath.js +60 -0
- package/dist/webSocket.d.ts +47 -0
- package/dist/webSocket.js +103 -0
- package/docs/html/.nojekyll +1 -0
- package/docs/html/assets/hierarchy.js +1 -0
- package/docs/html/assets/highlight.css +92 -0
- package/docs/html/assets/icons.js +18 -0
- package/docs/html/assets/icons.svg +1 -0
- package/docs/html/assets/main.js +60 -0
- package/docs/html/assets/navigation.js +1 -0
- package/docs/html/assets/search.js +1 -0
- package/docs/html/assets/style.css +1640 -0
- package/docs/html/functions/armageddon.html +6 -0
- package/docs/html/functions/bigbang.html +5 -0
- package/docs/html/functions/copyPath.html +8 -0
- package/docs/html/functions/createDirectory.html +8 -0
- package/docs/html/functions/createFile.html +9 -0
- package/docs/html/functions/exists.html +8 -0
- package/docs/html/functions/getMetadata.html +10 -0
- package/docs/html/functions/getXandeumResult.html +9 -0
- package/docs/html/functions/listDirectoryEntry.html +9 -0
- package/docs/html/functions/move.html +9 -0
- package/docs/html/functions/peek.html +10 -0
- package/docs/html/functions/poke.html +10 -0
- package/docs/html/functions/removeDirectory.html +8 -0
- package/docs/html/functions/removeFile.html +8 -0
- package/docs/html/functions/renamePath.html +9 -0
- package/docs/html/functions/subscribeResult.html +17 -0
- package/docs/html/functions/unsubscribeResult.html +6 -0
- package/docs/html/hierarchy.html +1 -0
- package/docs/html/index.html +62 -0
- package/docs/html/modules.html +1 -0
- package/docs/markdown/.nojekyll +0 -0
- package/docs/markdown/README.md +169 -0
- package/docs/markdown/functions/armageddon.md +34 -0
- package/docs/markdown/functions/bigbang.md +27 -0
- package/docs/markdown/functions/copyPath.md +49 -0
- package/docs/markdown/functions/createDirectory.md +49 -0
- package/docs/markdown/functions/createFile.md +50 -0
- package/docs/markdown/functions/exists.md +37 -0
- package/docs/markdown/functions/getMetadata.md +39 -0
- package/docs/markdown/functions/getXandeumResult.md +38 -0
- package/docs/markdown/functions/listDirectoryEntry.md +38 -0
- package/docs/markdown/functions/move.md +55 -0
- package/docs/markdown/functions/peek.md +57 -0
- package/docs/markdown/functions/poke.md +56 -0
- package/docs/markdown/functions/removeDirectory.md +44 -0
- package/docs/markdown/functions/removeFile.md +44 -0
- package/docs/markdown/functions/renamePath.md +50 -0
- package/docs/markdown/functions/subscribeResult.md +60 -0
- package/docs/markdown/functions/unsubscribeResult.md +34 -0
- package/docs/markdown/globals.md +25 -0
- package/docs/markdown/summary.md +44 -0
- package/package.json +26 -0
- package/src/armageddon.ts +36 -0
- package/src/bigbang.ts +32 -0
- package/src/const.ts +1 -0
- package/src/copyPath.ts +51 -0
- package/src/createDirectory.ts +47 -0
- package/src/createFile.ts +47 -0
- package/src/exists.ts +47 -0
- package/src/getMetadata.ts +50 -0
- package/src/getXandeumResult.ts +48 -0
- package/src/index.ts +16 -0
- package/src/listDirectoryEntery.ts +51 -0
- package/src/move.ts +55 -0
- package/src/peek.ts +52 -0
- package/src/poke.ts +59 -0
- package/src/removeDirectory.ts +43 -0
- package/src/removeFile.ts +44 -0
- package/src/renamePath.ts +50 -0
- package/src/sanitizePath.ts +69 -0
- package/src/webSocket.ts +131 -0
- package/tsconfig.json +14 -0
- package/typedoc.json +26 -0
package/dist/copyPath.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.copyPath = copyPath;
|
|
43
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
|
+
var const_1 = require("./const");
|
|
46
|
+
var sanitizePath_1 = require("./sanitizePath");
|
|
47
|
+
/**
|
|
48
|
+
* Constructs a Solana transaction to copy a file or directory from one path to another.
|
|
49
|
+
*
|
|
50
|
+
* @param fsid - The unique numeric identifier representing the target file system.
|
|
51
|
+
* @param srcPath - The source path to copy from (e.g., `/documents/report.txt`).
|
|
52
|
+
* @param destPath - The destination path to copy to (e.g., `/archive/report.txt`).
|
|
53
|
+
* @param wallet - The wallet public key used to sign and authorize the transaction.
|
|
54
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the copyPath instruction.
|
|
55
|
+
* @throws Will throw an error if `srcPath` or `destPath` contains invalid characters.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
function copyPath(fsid, srcPath, destPath, wallet) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var rest, instructionData, instruction, tx;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
// Validate path: only letters, numbers, and /
|
|
63
|
+
(0, sanitizePath_1.sanitizePath)(srcPath);
|
|
64
|
+
(0, sanitizePath_1.sanitizePath)(destPath);
|
|
65
|
+
rest = Buffer.from("".concat(srcPath, "\0").concat(destPath), 'utf-8');
|
|
66
|
+
instructionData = Buffer.concat([
|
|
67
|
+
Buffer.from(Int8Array.from([9]).buffer),
|
|
68
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
69
|
+
rest
|
|
70
|
+
]);
|
|
71
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
72
|
+
keys: [
|
|
73
|
+
{
|
|
74
|
+
pubkey: wallet,
|
|
75
|
+
isSigner: true,
|
|
76
|
+
isWritable: true
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
80
|
+
data: instructionData
|
|
81
|
+
});
|
|
82
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
83
|
+
return [2 /*return*/, tx];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a Solana transaction to create a new directory within a file system.
|
|
4
|
+
*
|
|
5
|
+
* @param fsid - A numeric filesystem identifier used to scope the directory creation.
|
|
6
|
+
* @param path - The parent path where the directory should be created (e.g., `/documents`).
|
|
7
|
+
* @param name - The name of the new directory (e.g., `reports`).
|
|
8
|
+
* @param wallet - The signer’s public key that authorizes the transaction.
|
|
9
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the createDirectory instruction.
|
|
10
|
+
* @throws Will throw an error if `path` or `name` contains invalid characters.@throws Will throw if the combined path is invalid (non-alphanumeric or unsupported characters).
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDirectory(fsid: string, path: string, name: string, wallet: PublicKey): Promise<Transaction>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.createDirectory = createDirectory;
|
|
43
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
|
+
var const_1 = require("./const");
|
|
46
|
+
var sanitizePath_1 = require("./sanitizePath");
|
|
47
|
+
/**
|
|
48
|
+
* Constructs a Solana transaction to create a new directory within a file system.
|
|
49
|
+
*
|
|
50
|
+
* @param fsid - A numeric filesystem identifier used to scope the directory creation.
|
|
51
|
+
* @param path - The parent path where the directory should be created (e.g., `/documents`).
|
|
52
|
+
* @param name - The name of the new directory (e.g., `reports`).
|
|
53
|
+
* @param wallet - The signer’s public key that authorizes the transaction.
|
|
54
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the createDirectory instruction.
|
|
55
|
+
* @throws Will throw an error if `path` or `name` contains invalid characters.@throws Will throw if the combined path is invalid (non-alphanumeric or unsupported characters).
|
|
56
|
+
*/
|
|
57
|
+
function createDirectory(fsid, path, name, wallet) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var combinedPath, rest, instructionData, instruction, tx;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
combinedPath = path.endsWith('/') ? "".concat(path).concat(name) : "".concat(path, "/").concat(name);
|
|
62
|
+
(0, sanitizePath_1.sanitizePath)(combinedPath);
|
|
63
|
+
rest = Buffer.from("".concat(path, "\0").concat(name), 'utf-8');
|
|
64
|
+
instructionData = Buffer.concat([
|
|
65
|
+
Buffer.from(Int8Array.from([6]).buffer),
|
|
66
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
67
|
+
rest
|
|
68
|
+
]);
|
|
69
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
70
|
+
keys: [
|
|
71
|
+
{
|
|
72
|
+
pubkey: wallet,
|
|
73
|
+
isSigner: true,
|
|
74
|
+
isWritable: true
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
78
|
+
data: instructionData
|
|
79
|
+
});
|
|
80
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
81
|
+
return [2 /*return*/, tx];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a Solana transaction to create a new file
|
|
4
|
+
* within a file system, identified by a file system ID (`fsid`).
|
|
5
|
+
*
|
|
6
|
+
* @param fsid - A stringified integer representing the file system ID where the file is to be created.
|
|
7
|
+
* @param path - The absolute or relative path within the file system where the file should be created.
|
|
8
|
+
* @param name - The name of the new file or directory to be created.
|
|
9
|
+
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
10
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the createFile instruction.
|
|
11
|
+
* @throws Will throw an error if `path` or `name` contains invalid characters.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFile(fsid: string, path: string, name: string, wallet: PublicKey): Promise<Transaction>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.createFile = createFile;
|
|
43
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
|
+
var const_1 = require("./const");
|
|
46
|
+
var sanitizePath_1 = require("./sanitizePath");
|
|
47
|
+
/**
|
|
48
|
+
* Constructs a Solana transaction to create a new file
|
|
49
|
+
* within a file system, identified by a file system ID (`fsid`).
|
|
50
|
+
*
|
|
51
|
+
* @param fsid - A stringified integer representing the file system ID where the file is to be created.
|
|
52
|
+
* @param path - The absolute or relative path within the file system where the file should be created.
|
|
53
|
+
* @param name - The name of the new file or directory to be created.
|
|
54
|
+
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
55
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the createFile instruction.
|
|
56
|
+
* @throws Will throw an error if `path` or `name` contains invalid characters.
|
|
57
|
+
*/
|
|
58
|
+
function createFile(fsid, path, name, wallet) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var combinedPath, rest, instructionData, instruction, tx;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
combinedPath = path.endsWith('/') ? "".concat(path).concat(name) : "".concat(path, "/").concat(name);
|
|
63
|
+
(0, sanitizePath_1.sanitizePath)(combinedPath);
|
|
64
|
+
rest = Buffer.from("".concat(path, "\0").concat(name), 'utf-8');
|
|
65
|
+
instructionData = Buffer.concat([
|
|
66
|
+
Buffer.from(Int8Array.from([2]).buffer),
|
|
67
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
68
|
+
rest
|
|
69
|
+
]);
|
|
70
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
71
|
+
keys: [
|
|
72
|
+
{
|
|
73
|
+
pubkey: wallet,
|
|
74
|
+
isSigner: true,
|
|
75
|
+
isWritable: true
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
79
|
+
data: instructionData
|
|
80
|
+
});
|
|
81
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
82
|
+
return [2 /*return*/, tx];
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
package/dist/exists.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
export interface RpcRequest {
|
|
3
|
+
jsonrpc: string;
|
|
4
|
+
id: number;
|
|
5
|
+
method: string;
|
|
6
|
+
params: any[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sends a JSON-RPC request to the Xandeum RPC endpoint to check if a file or directory exists.
|
|
10
|
+
*
|
|
11
|
+
* This function calls the custom RPC method `isExist`, which should be implemented
|
|
12
|
+
* by the backend to validate the existence of metadata (files/directories) at a given path.
|
|
13
|
+
* @param connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
|
|
14
|
+
* @param path - The filesystem path to check (e.g., `/documents/myfile.txt`).
|
|
15
|
+
*
|
|
16
|
+
* @returns A `Promise<any>` resolving to the RPC response JSON, typically including a `result` field
|
|
17
|
+
* indicating existence (e.g., `true` or `false`), or `null` if not found.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export declare function exists(connection: Connection, path: string): Promise<any>;
|
package/dist/exists.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.exists = exists;
|
|
40
|
+
/**
|
|
41
|
+
* Sends a JSON-RPC request to the Xandeum RPC endpoint to check if a file or directory exists.
|
|
42
|
+
*
|
|
43
|
+
* This function calls the custom RPC method `isExist`, which should be implemented
|
|
44
|
+
* by the backend to validate the existence of metadata (files/directories) at a given path.
|
|
45
|
+
* @param connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
|
|
46
|
+
* @param path - The filesystem path to check (e.g., `/documents/myfile.txt`).
|
|
47
|
+
*
|
|
48
|
+
* @returns A `Promise<any>` resolving to the RPC response JSON, typically including a `result` field
|
|
49
|
+
* indicating existence (e.g., `true` or `false`), or `null` if not found.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
function exists(connection, path) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var url, requestBody, response, errorText, data;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
url = connection.rpcEndpoint;
|
|
59
|
+
requestBody = {
|
|
60
|
+
jsonrpc: '2.0',
|
|
61
|
+
id: 1,
|
|
62
|
+
method: 'isExist',
|
|
63
|
+
params: [path]
|
|
64
|
+
};
|
|
65
|
+
return [4 /*yield*/, fetch(url, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/json'
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(requestBody)
|
|
71
|
+
})];
|
|
72
|
+
case 1:
|
|
73
|
+
response = _a.sent();
|
|
74
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
75
|
+
return [4 /*yield*/, response.text()];
|
|
76
|
+
case 2:
|
|
77
|
+
errorText = _a.sent();
|
|
78
|
+
return [2 /*return*/, Error("error! status: ".concat(response.status, ", message: ").concat(errorText))];
|
|
79
|
+
case 3: return [4 /*yield*/, response.json()];
|
|
80
|
+
case 4:
|
|
81
|
+
data = _a.sent();
|
|
82
|
+
return [2 /*return*/, data];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
package/dist/find.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
export interface RpcRequest {
|
|
3
|
+
jsonrpc: string;
|
|
4
|
+
id: number;
|
|
5
|
+
method: string;
|
|
6
|
+
params: any[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sends a JSON-RPC request to the Xandeum RPC endpoint to search for a file or directory
|
|
10
|
+
* within a specified path.
|
|
11
|
+
*
|
|
12
|
+
* This function calls the custom RPC method `find`, which is return an array of
|
|
13
|
+
* directory entry metadata — names, types etc.
|
|
14
|
+
*
|
|
15
|
+
* @param connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
|
|
16
|
+
* @param path - The filesystem path where the search will be performed (e.g., `/documents`).
|
|
17
|
+
* @param query - The query to search for (e.g., `'myfile.txt'`).
|
|
18
|
+
*
|
|
19
|
+
* @returns A `Promise<any>` resolving to the parsed JSON response from the RPC server,
|
|
20
|
+
* typically including a `result` array containing directory entry objects.
|
|
21
|
+
*/
|
|
22
|
+
export declare function listDirectoryEntry(connection: Connection, path: string, query: string): Promise<any>;
|
package/dist/find.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.listDirectoryEntry = listDirectoryEntry;
|
|
40
|
+
/**
|
|
41
|
+
* Sends a JSON-RPC request to the Xandeum RPC endpoint to search for a file or directory
|
|
42
|
+
* within a specified path.
|
|
43
|
+
*
|
|
44
|
+
* This function calls the custom RPC method `find`, which is return an array of
|
|
45
|
+
* directory entry metadata — names, types etc.
|
|
46
|
+
*
|
|
47
|
+
* @param connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
|
|
48
|
+
* @param path - The filesystem path where the search will be performed (e.g., `/documents`).
|
|
49
|
+
* @param query - The query to search for (e.g., `'myfile.txt'`).
|
|
50
|
+
*
|
|
51
|
+
* @returns A `Promise<any>` resolving to the parsed JSON response from the RPC server,
|
|
52
|
+
* typically including a `result` array containing directory entry objects.
|
|
53
|
+
*/
|
|
54
|
+
function listDirectoryEntry(connection, path, query) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var url, requestBody, response, errorText, data;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
url = connection.rpcEndpoint;
|
|
61
|
+
requestBody = {
|
|
62
|
+
jsonrpc: '2.0',
|
|
63
|
+
id: 1,
|
|
64
|
+
method: 'find',
|
|
65
|
+
params: [path, query]
|
|
66
|
+
};
|
|
67
|
+
return [4 /*yield*/, fetch(url, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
'Content-Type': 'application/json'
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify(requestBody)
|
|
73
|
+
})];
|
|
74
|
+
case 1:
|
|
75
|
+
response = _a.sent();
|
|
76
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
77
|
+
return [4 /*yield*/, response.text()];
|
|
78
|
+
case 2:
|
|
79
|
+
errorText = _a.sent();
|
|
80
|
+
return [2 /*return*/, Error("error! status: ".concat(response.status, ", message: ").concat(errorText))];
|
|
81
|
+
case 3: return [4 /*yield*/, response.json()];
|
|
82
|
+
case 4:
|
|
83
|
+
data = _a.sent();
|
|
84
|
+
return [2 /*return*/, data];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface RpcRequest {
|
|
2
|
+
jsonrpc: string;
|
|
3
|
+
id: number;
|
|
4
|
+
method: string;
|
|
5
|
+
params: any[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Calls Solana RPC method `getMetadata` for the file and direcories with the given path. (parent_path, depth,type)
|
|
9
|
+
* @param path The metadata path (e.g., account or key)
|
|
10
|
+
* @param url The Xandeum RPC URL
|
|
11
|
+
*/
|
|
12
|
+
export declare function getInfo(path: string, url: string): Promise<any>;
|
package/dist/getInfo.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// const url = 'https://api.devnet.solana.com';
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
14
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.getInfo = getInfo;
|
|
41
|
+
/**
|
|
42
|
+
* Calls Solana RPC method `getMetadata` for the file and direcories with the given path. (parent_path, depth,type)
|
|
43
|
+
* @param path The metadata path (e.g., account or key)
|
|
44
|
+
* @param url The Xandeum RPC URL
|
|
45
|
+
*/
|
|
46
|
+
function getInfo(path, url) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var requestBody, response, data;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
requestBody = {
|
|
53
|
+
jsonrpc: '2.0',
|
|
54
|
+
id: 1,
|
|
55
|
+
method: 'getInfo',
|
|
56
|
+
params: [path],
|
|
57
|
+
};
|
|
58
|
+
return [4 /*yield*/, fetch(url, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
},
|
|
63
|
+
body: JSON.stringify(requestBody),
|
|
64
|
+
})];
|
|
65
|
+
case 1:
|
|
66
|
+
response = _a.sent();
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
throw new Error("HTTP error! Status: ".concat(response.status));
|
|
69
|
+
}
|
|
70
|
+
return [4 /*yield*/, response.json()];
|
|
71
|
+
case 2:
|
|
72
|
+
data = _a.sent();
|
|
73
|
+
return [2 /*return*/, data];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
export interface RpcRequest {
|
|
3
|
+
jsonrpc: string;
|
|
4
|
+
id: number;
|
|
5
|
+
method: string;
|
|
6
|
+
params: any[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sends a JSON-RPC request to the Xandeum RPC endpoint to retrieve metadata
|
|
10
|
+
* about a file or directory at the given path.
|
|
11
|
+
*
|
|
12
|
+
* This function calls the custom RPC method `getMetadata`, which is implemented
|
|
13
|
+
* by the backend to return metadata such as type (file or directory), size,
|
|
14
|
+
* timestamps etc.
|
|
15
|
+
*
|
|
16
|
+
* @param connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
|
|
17
|
+
* @param path - The filesystem path to query metadata for (e.g., `/documents/myfile.txt`).
|
|
18
|
+
*
|
|
19
|
+
* @returns A `Promise<any>` resolving to the parsed JSON response from the RPC server,
|
|
20
|
+
* typically containing a `result` object with metadata fields.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare function getMetadata(connection: Connection, path: string): Promise<any>;
|