@xandeum/web3.js 1.3.0 → 1.3.2
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 +9 -6
- package/archbee.yaml +55 -0
- package/dist/armageddon.js +9 -1
- package/dist/assignCoowner.d.ts +12 -0
- package/dist/assignCoowner.js +89 -0
- package/dist/bigbang.d.ts +2 -1
- package/dist/bigbang.js +17 -3
- package/dist/const.d.ts +1 -1
- package/dist/const.js +1 -1
- package/dist/copyPath.js +9 -1
- package/dist/createDirectory.js +9 -1
- package/dist/createFile.js +9 -1
- package/dist/exists.js +7 -5
- package/dist/find.d.ts +22 -0
- package/dist/find.js +88 -0
- package/dist/getMetadata.js +7 -5
- package/dist/getXandeumResult.d.ts +15 -0
- package/dist/getXandeumResult.js +115 -0
- package/dist/helpers.d.ts +56 -0
- package/dist/helpers.js +80 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -1
- package/dist/listDirectoryEntery.js +7 -5
- package/dist/move.d.ts +14 -0
- package/dist/move.js +96 -0
- package/dist/pdaHelpers.d.ts +57 -0
- package/dist/pdaHelpers.js +83 -0
- package/dist/peek.js +9 -1
- package/dist/poke.js +9 -1
- package/dist/removeDirectory.js +9 -1
- package/dist/removeFile.js +9 -1
- package/dist/renamePath.js +9 -1
- package/dist/webSocket.d.ts +1 -1
- package/dist/webSocket.js +16 -3
- package/docs/html/assets/highlight.css +92 -0
- package/docs/html/assets/navigation.js +1 -0
- package/docs/html/assets/search.js +1 -0
- package/docs/{functions → html/functions}/armageddon.html +3 -3
- package/docs/html/functions/assignCoowner.html +8 -0
- package/docs/html/functions/bigbang.html +5 -0
- package/docs/{functions → html/functions}/copyPath.html +2 -8
- package/docs/{functions → html/functions}/createDirectory.html +2 -8
- package/docs/{functions → html/functions}/createFile.html +2 -9
- package/docs/{functions → html/functions}/exists.html +4 -4
- package/docs/html/functions/find.html +10 -0
- package/docs/html/functions/getMetadata.html +10 -0
- package/docs/html/functions/getXandeumResult.html +9 -0
- package/docs/{functions → html/functions}/listDirectoryEntry.html +4 -4
- package/docs/html/functions/move.html +9 -0
- package/docs/{functions → html/functions}/peek.html +2 -10
- package/docs/{functions → html/functions}/poke.html +2 -10
- package/docs/{functions → html/functions}/removeDirectory.html +2 -8
- package/docs/{functions → html/functions}/removeFile.html +2 -8
- package/docs/{functions → html/functions}/renamePath.html +3 -9
- package/docs/{functions → html/functions}/subscribeResult.html +4 -4
- package/docs/html/functions/unsubscribeResult.html +6 -0
- package/docs/{hierarchy.html → html/hierarchy.html} +1 -1
- package/docs/html/index.html +62 -0
- package/docs/html/modules.html +1 -0
- package/docs/markdown/README.md +10 -7
- package/docs/markdown/functions/armageddon.md +2 -2
- package/docs/markdown/functions/assignCoowner.md +46 -0
- package/docs/markdown/functions/bigbang.md +9 -3
- package/docs/markdown/functions/copyPath.md +2 -2
- package/docs/markdown/functions/createDirectory.md +2 -2
- package/docs/markdown/functions/createFile.md +2 -2
- package/docs/markdown/functions/exists.md +2 -2
- package/docs/markdown/functions/find.md +44 -0
- package/docs/markdown/functions/getMetadata.md +2 -2
- package/docs/markdown/functions/getXandeumResult.md +38 -0
- package/docs/markdown/functions/listDirectoryEntry.md +2 -2
- package/docs/markdown/functions/move.md +55 -0
- package/docs/markdown/functions/peek.md +2 -2
- package/docs/markdown/functions/poke.md +2 -2
- package/docs/markdown/functions/removeDirectory.md +2 -2
- package/docs/markdown/functions/removeFile.md +2 -2
- package/docs/markdown/functions/renamePath.md +2 -2
- package/docs/markdown/functions/subscribeResult.md +2 -2
- package/docs/markdown/functions/unsubscribeResult.md +2 -2
- package/docs/markdown/globals.md +6 -2
- package/package.json +3 -3
- package/src/armageddon.ts +8 -0
- package/src/assignCoowner.ts +49 -0
- package/src/bigbang.ts +13 -2
- package/src/const.ts +1 -1
- package/src/copyPath.ts +8 -1
- package/src/createDirectory.ts +8 -1
- package/src/createFile.ts +8 -2
- package/src/exists.ts +2 -1
- package/src/find.ts +53 -0
- package/src/getMetadata.ts +2 -1
- package/src/getXandeumResult.ts +67 -0
- package/src/helpers.ts +85 -0
- package/src/index.ts +5 -1
- package/src/listDirectoryEntery.ts +2 -1
- package/src/move.ts +62 -0
- package/src/peek.ts +8 -1
- package/src/poke.ts +8 -1
- package/src/removeDirectory.ts +8 -2
- package/src/removeFile.ts +8 -2
- package/src/renamePath.ts +8 -2
- package/src/webSocket.ts +18 -5
- package/typedoc.json +3 -4
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/functions/bigbang.html +0 -4
- package/docs/functions/getMetadata.html +0 -10
- package/docs/functions/unsubscribeResult.html +0 -6
- package/docs/index.html +0 -2
- package/docs/modules.html +0 -1
- /package/docs/{.nojekyll → html/.nojekyll} +0 -0
- /package/docs/{assets → html/assets}/hierarchy.js +0 -0
- /package/docs/{assets → html/assets}/icons.js +0 -0
- /package/docs/{assets → html/assets}/icons.svg +0 -0
- /package/docs/{assets → html/assets}/main.js +0 -0
- /package/docs/{assets → html/assets}/style.css +0 -0
package/README.md
CHANGED
|
@@ -38,7 +38,8 @@ import {
|
|
|
38
38
|
import {
|
|
39
39
|
Connection,
|
|
40
40
|
sendAndConfirmTransaction,
|
|
41
|
-
Keypair
|
|
41
|
+
Keypair,
|
|
42
|
+
PublicKey
|
|
42
43
|
} from '@solana/web3.js'
|
|
43
44
|
|
|
44
45
|
const connection = new Connection('https://apis.devnet.xandeum.com)
|
|
@@ -51,15 +52,17 @@ async function main() {
|
|
|
51
52
|
await sendAndConfirmTransaction(connection, tx1, [signer])
|
|
52
53
|
|
|
53
54
|
// Create a file
|
|
54
|
-
const tx2 = await createFile('1', '/
|
|
55
|
+
const tx2 = await createFile('1', '/','hello.txt', wallet)
|
|
55
56
|
await sendAndConfirmTransaction(connection, tx2, [signer])
|
|
56
57
|
|
|
58
|
+
const dataAccount = new PublicKey("FBM4G63KPUneqyLwQy6zVu81AsMqmkQjsdxNGBKq3dkv");
|
|
59
|
+
|
|
57
60
|
// Write data
|
|
58
|
-
const tx3 = await poke('1', '/
|
|
61
|
+
const tx3 = await poke('1', '/hello.txt', 0, Buffer.from('Hello Xandeum!'), wallet)
|
|
59
62
|
await sendAndConfirmTransaction(connection, tx3, [signer])
|
|
60
63
|
|
|
61
64
|
// Read data
|
|
62
|
-
const tx4 = await peek('1', '/
|
|
65
|
+
const tx4 = await peek('1', '/hello.txt', 0, 14, wallet)
|
|
63
66
|
await sendAndConfirmTransaction(connection, tx4, [signer])
|
|
64
67
|
}
|
|
65
68
|
```
|
|
@@ -140,7 +143,7 @@ const signer = Keypair.generate()
|
|
|
140
143
|
const wallet = signer.publicKey
|
|
141
144
|
|
|
142
145
|
async function main() {
|
|
143
|
-
const tx = await createFile('1', '/
|
|
146
|
+
const tx = await createFile('1', '/hello.txt', wallet)
|
|
144
147
|
const txSignature = await sendAndConfirmTransaction(connection, tx, [signer])
|
|
145
148
|
|
|
146
149
|
subscribeResult(
|
|
@@ -155,7 +158,7 @@ async function main() {
|
|
|
155
158
|
}
|
|
156
159
|
```
|
|
157
160
|
|
|
158
|
-
|
|
161
|
+
Apache-2.0 © Xandeum
|
|
159
162
|
|
|
160
163
|
👤 Author
|
|
161
164
|
|
package/archbee.yaml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Archbee Configuration for Xandeum Pod Documentation
|
|
2
|
+
# This file must be in the root of your repository
|
|
3
|
+
# Reference: https://www.archbee.com/docs/set-up-the-repository
|
|
4
|
+
|
|
5
|
+
# Define where the markdown docs are located
|
|
6
|
+
# This tells Archbee where to find your markdown files
|
|
7
|
+
root: docs/markdown
|
|
8
|
+
|
|
9
|
+
# Structure configuration
|
|
10
|
+
structure:
|
|
11
|
+
# summary.md defines the document tree navigation in Archbee
|
|
12
|
+
summary: summary.md
|
|
13
|
+
# Assets folder relative to docspath
|
|
14
|
+
assets: assets
|
|
15
|
+
|
|
16
|
+
# Auto-publish to production after each commit
|
|
17
|
+
publishspace: true
|
|
18
|
+
|
|
19
|
+
# Document tree options (for OpenAPI/Swagger if needed)
|
|
20
|
+
doctreeoptions:
|
|
21
|
+
openapitryit: true
|
|
22
|
+
showdownloadopenapifile: true
|
|
23
|
+
shouldcreateschemacategory: true
|
|
24
|
+
shouldcreateintro: true
|
|
25
|
+
openapilanguageexamples:
|
|
26
|
+
- value: bash
|
|
27
|
+
label: Bash
|
|
28
|
+
- value: javascript
|
|
29
|
+
label: JavaScript
|
|
30
|
+
- value: python
|
|
31
|
+
label: Python
|
|
32
|
+
|
|
33
|
+
# Custom CSS (optional - add your brand styling)
|
|
34
|
+
customcss: |
|
|
35
|
+
:root {
|
|
36
|
+
--primary-color: #your-brand-color;
|
|
37
|
+
--accent-color: #your-accent-color;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Custom JavaScript (optional)
|
|
41
|
+
customjs: ""
|
|
42
|
+
|
|
43
|
+
# Footer template (optional)
|
|
44
|
+
footertemplate: |
|
|
45
|
+
<div style="text-align: center; padding: 20px;">
|
|
46
|
+
<p>Made with ❤️ by the Xandeum Team</p>
|
|
47
|
+
<p>
|
|
48
|
+
<a href="https://github.com/xandeum" target="_blank">GitHub</a> |
|
|
49
|
+
<a href="https://twitter.com/xandeum" target="_blank">Twitter</a>
|
|
50
|
+
</p>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
# Header includes (optional - for analytics, etc.)
|
|
54
|
+
headerincludes: ""
|
|
55
|
+
|
package/dist/armageddon.js
CHANGED
|
@@ -43,6 +43,7 @@ exports.armageddon = armageddon;
|
|
|
43
43
|
var web3_js_1 = require("@solana/web3.js");
|
|
44
44
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
45
|
var const_js_1 = require("./const.js");
|
|
46
|
+
var helpers_js_1 = require("./helpers.js");
|
|
46
47
|
/**
|
|
47
48
|
* Constructs a Solana transaction that triggers the "armageddon" instruction
|
|
48
49
|
* on the specified file system (fsid).
|
|
@@ -53,18 +54,25 @@ var const_js_1 = require("./const.js");
|
|
|
53
54
|
*/
|
|
54
55
|
function armageddon(fsid, wallet) {
|
|
55
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var instructionData, instruction, tx;
|
|
57
|
+
var instructionData, feeDistributorPda, instruction, tx;
|
|
57
58
|
return __generator(this, function (_a) {
|
|
58
59
|
instructionData = Buffer.concat([
|
|
60
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
59
61
|
Buffer.from(Int8Array.from([1]).buffer),
|
|
60
62
|
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8)))
|
|
61
63
|
]);
|
|
64
|
+
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
62
65
|
instruction = new web3_js_1.TransactionInstruction({
|
|
63
66
|
keys: [
|
|
64
67
|
{
|
|
65
68
|
pubkey: wallet,
|
|
66
69
|
isSigner: true,
|
|
67
70
|
isWritable: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
pubkey: feeDistributorPda.pda,
|
|
74
|
+
isSigner: false,
|
|
75
|
+
isWritable: true
|
|
68
76
|
}
|
|
69
77
|
],
|
|
70
78
|
programId: new web3_js_1.PublicKey(const_js_1.programId),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a Solana transaction to assign a co-owner to a file or directory
|
|
4
|
+
* identified by a file system ID (`fsid`).
|
|
5
|
+
*
|
|
6
|
+
* @param fsid - A stringified integer representing the file system ID where the co-owner is to be assigned.
|
|
7
|
+
* @param path - The path within the file system.
|
|
8
|
+
* @param coowner - The public key of the co-owner to be assigned.
|
|
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 assignCoowner instruction.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assignCoowner(fsid: string, path: string, coowner: PublicKey, wallet: PublicKey): Promise<Transaction>;
|
|
@@ -0,0 +1,89 @@
|
|
|
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.assignCoowner = assignCoowner;
|
|
43
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
+
var const_1 = require("./const");
|
|
45
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
46
|
+
var helpers_js_1 = require("./helpers.js");
|
|
47
|
+
/**
|
|
48
|
+
* Constructs a Solana transaction to assign a co-owner to a file or directory
|
|
49
|
+
* identified by a file system ID (`fsid`).
|
|
50
|
+
*
|
|
51
|
+
* @param fsid - A stringified integer representing the file system ID where the co-owner is to be assigned.
|
|
52
|
+
* @param path - The path within the file system.
|
|
53
|
+
* @param coowner - The public key of the co-owner to be assigned.
|
|
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 assignCoowner instruction.
|
|
56
|
+
*/
|
|
57
|
+
function assignCoowner(fsid, path, coowner, wallet) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var rest, instructionData, feeDistributorPda, instruction, tx;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
rest = Buffer.from("".concat(path, "\0").concat(coowner.toString()), 'utf-8');
|
|
62
|
+
instructionData = Buffer.concat([
|
|
63
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
64
|
+
Buffer.from(Int8Array.from([14]).buffer),
|
|
65
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
66
|
+
rest
|
|
67
|
+
]);
|
|
68
|
+
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
69
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
70
|
+
keys: [
|
|
71
|
+
{
|
|
72
|
+
pubkey: wallet,
|
|
73
|
+
isSigner: true,
|
|
74
|
+
isWritable: true
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
pubkey: feeDistributorPda.pda,
|
|
78
|
+
isSigner: false,
|
|
79
|
+
isWritable: true
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
83
|
+
data: instructionData
|
|
84
|
+
});
|
|
85
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
86
|
+
return [2 /*return*/, tx];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
package/dist/bigbang.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Transaction, PublicKey } from '@solana/web3.js';
|
|
|
3
3
|
* Constructs a Solana transaction that triggers the "bigbang" instruction and create new file system.
|
|
4
4
|
*
|
|
5
5
|
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
6
|
+
* @param replica_count - A stringified integer representing the number of replicas for the new file system. Must be 2 or greater. The total number of copies will be replica_count + 1 (one original plus the replicas).
|
|
6
7
|
* @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
|
|
7
8
|
*/
|
|
8
|
-
export declare function bigbang(wallet: PublicKey): Promise<Transaction>;
|
|
9
|
+
export declare function bigbang(replica_count: string, wallet: PublicKey): Promise<Transaction>;
|
package/dist/bigbang.js
CHANGED
|
@@ -35,29 +35,43 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
exports.bigbang = bigbang;
|
|
40
43
|
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
41
45
|
var const_1 = require("./const");
|
|
46
|
+
var helpers_1 = require("./helpers");
|
|
42
47
|
/**
|
|
43
48
|
* Constructs a Solana transaction that triggers the "bigbang" instruction and create new file system.
|
|
44
49
|
*
|
|
45
50
|
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
51
|
+
* @param replica_count - A stringified integer representing the number of replicas for the new file system. Must be 2 or greater. The total number of copies will be replica_count + 1 (one original plus the replicas).
|
|
46
52
|
* @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
|
|
47
53
|
*/
|
|
48
|
-
function bigbang(wallet) {
|
|
54
|
+
function bigbang(replica_count, wallet) {
|
|
49
55
|
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var instructionData, instruction, tx;
|
|
56
|
+
var instructionData, feeDistributorPda, instruction, tx;
|
|
51
57
|
return __generator(this, function (_a) {
|
|
52
58
|
instructionData = Buffer.concat([
|
|
53
|
-
Buffer.from(Int8Array.from([0]).buffer)
|
|
59
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
60
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
61
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(replica_count).toArray('le', 8)))
|
|
54
62
|
]);
|
|
63
|
+
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
55
64
|
instruction = new web3_js_1.TransactionInstruction({
|
|
56
65
|
keys: [
|
|
57
66
|
{
|
|
58
67
|
pubkey: wallet,
|
|
59
68
|
isSigner: true,
|
|
60
69
|
isWritable: true
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
pubkey: feeDistributorPda.pda,
|
|
73
|
+
isSigner: false,
|
|
74
|
+
isWritable: true
|
|
61
75
|
}
|
|
62
76
|
],
|
|
63
77
|
programId: new web3_js_1.PublicKey(const_1.programId),
|
package/dist/const.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const programId = "
|
|
1
|
+
export declare const programId = "EaLDF7m76kzvrpeADHVHPLfk5qpPaPxYUYqYApByLp1S";
|
package/dist/const.js
CHANGED
package/dist/copyPath.js
CHANGED
|
@@ -44,6 +44,7 @@ var web3_js_1 = require("@solana/web3.js");
|
|
|
44
44
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
45
|
var const_1 = require("./const");
|
|
46
46
|
var sanitizePath_1 = require("./sanitizePath");
|
|
47
|
+
var helpers_js_1 = require("./helpers.js");
|
|
47
48
|
/**
|
|
48
49
|
* Constructs a Solana transaction to copy a file or directory from one path to another.
|
|
49
50
|
*
|
|
@@ -57,23 +58,30 @@ var sanitizePath_1 = require("./sanitizePath");
|
|
|
57
58
|
*/
|
|
58
59
|
function copyPath(fsid, srcPath, destPath, wallet) {
|
|
59
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
var rest, instructionData, instruction, tx;
|
|
61
|
+
var rest, instructionData, feeDistributorPda, instruction, tx;
|
|
61
62
|
return __generator(this, function (_a) {
|
|
62
63
|
// Validate path: only letters, numbers, and /
|
|
63
64
|
(0, sanitizePath_1.sanitizePath)(srcPath);
|
|
64
65
|
(0, sanitizePath_1.sanitizePath)(destPath);
|
|
65
66
|
rest = Buffer.from("".concat(srcPath, "\0").concat(destPath), 'utf-8');
|
|
66
67
|
instructionData = Buffer.concat([
|
|
68
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
67
69
|
Buffer.from(Int8Array.from([9]).buffer),
|
|
68
70
|
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
69
71
|
rest
|
|
70
72
|
]);
|
|
73
|
+
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
71
74
|
instruction = new web3_js_1.TransactionInstruction({
|
|
72
75
|
keys: [
|
|
73
76
|
{
|
|
74
77
|
pubkey: wallet,
|
|
75
78
|
isSigner: true,
|
|
76
79
|
isWritable: true
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
pubkey: feeDistributorPda.pda,
|
|
83
|
+
isSigner: false,
|
|
84
|
+
isWritable: true
|
|
77
85
|
}
|
|
78
86
|
],
|
|
79
87
|
programId: new web3_js_1.PublicKey(const_1.programId),
|
package/dist/createDirectory.js
CHANGED
|
@@ -44,6 +44,7 @@ var web3_js_1 = require("@solana/web3.js");
|
|
|
44
44
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
45
|
var const_1 = require("./const");
|
|
46
46
|
var sanitizePath_1 = require("./sanitizePath");
|
|
47
|
+
var helpers_js_1 = require("./helpers.js");
|
|
47
48
|
/**
|
|
48
49
|
* Constructs a Solana transaction to create a new directory within a file system.
|
|
49
50
|
*
|
|
@@ -56,22 +57,29 @@ var sanitizePath_1 = require("./sanitizePath");
|
|
|
56
57
|
*/
|
|
57
58
|
function createDirectory(fsid, path, name, wallet) {
|
|
58
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var combinedPath, rest, instructionData, instruction, tx;
|
|
60
|
+
var combinedPath, rest, instructionData, feeDistributorPda, instruction, tx;
|
|
60
61
|
return __generator(this, function (_a) {
|
|
61
62
|
combinedPath = path.endsWith('/') ? "".concat(path).concat(name) : "".concat(path, "/").concat(name);
|
|
62
63
|
(0, sanitizePath_1.sanitizePath)(combinedPath);
|
|
63
64
|
rest = Buffer.from("".concat(path, "\0").concat(name), 'utf-8');
|
|
64
65
|
instructionData = Buffer.concat([
|
|
66
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
65
67
|
Buffer.from(Int8Array.from([6]).buffer),
|
|
66
68
|
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
67
69
|
rest
|
|
68
70
|
]);
|
|
71
|
+
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
69
72
|
instruction = new web3_js_1.TransactionInstruction({
|
|
70
73
|
keys: [
|
|
71
74
|
{
|
|
72
75
|
pubkey: wallet,
|
|
73
76
|
isSigner: true,
|
|
74
77
|
isWritable: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
pubkey: feeDistributorPda.pda,
|
|
81
|
+
isSigner: false,
|
|
82
|
+
isWritable: true
|
|
75
83
|
}
|
|
76
84
|
],
|
|
77
85
|
programId: new web3_js_1.PublicKey(const_1.programId),
|
package/dist/createFile.js
CHANGED
|
@@ -44,6 +44,7 @@ var web3_js_1 = require("@solana/web3.js");
|
|
|
44
44
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
45
|
var const_1 = require("./const");
|
|
46
46
|
var sanitizePath_1 = require("./sanitizePath");
|
|
47
|
+
var helpers_js_1 = require("./helpers.js");
|
|
47
48
|
/**
|
|
48
49
|
* Constructs a Solana transaction to create a new file
|
|
49
50
|
* within a file system, identified by a file system ID (`fsid`).
|
|
@@ -57,22 +58,29 @@ var sanitizePath_1 = require("./sanitizePath");
|
|
|
57
58
|
*/
|
|
58
59
|
function createFile(fsid, path, name, wallet) {
|
|
59
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
var combinedPath, rest, instructionData, instruction, tx;
|
|
61
|
+
var combinedPath, rest, instructionData, feeDistributorPda, instruction, tx;
|
|
61
62
|
return __generator(this, function (_a) {
|
|
62
63
|
combinedPath = path.endsWith('/') ? "".concat(path).concat(name) : "".concat(path, "/").concat(name);
|
|
63
64
|
(0, sanitizePath_1.sanitizePath)(combinedPath);
|
|
64
65
|
rest = Buffer.from("".concat(path, "\0").concat(name), 'utf-8');
|
|
65
66
|
instructionData = Buffer.concat([
|
|
67
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
66
68
|
Buffer.from(Int8Array.from([2]).buffer),
|
|
67
69
|
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
68
70
|
rest
|
|
69
71
|
]);
|
|
72
|
+
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
70
73
|
instruction = new web3_js_1.TransactionInstruction({
|
|
71
74
|
keys: [
|
|
72
75
|
{
|
|
73
76
|
pubkey: wallet,
|
|
74
77
|
isSigner: true,
|
|
75
78
|
isWritable: true
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
pubkey: feeDistributorPda.pda,
|
|
82
|
+
isSigner: false,
|
|
83
|
+
isWritable: true
|
|
76
84
|
}
|
|
77
85
|
],
|
|
78
86
|
programId: new web3_js_1.PublicKey(const_1.programId),
|
package/dist/exists.js
CHANGED
|
@@ -51,7 +51,7 @@ exports.exists = exists;
|
|
|
51
51
|
*/
|
|
52
52
|
function exists(connection, path) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var url, requestBody, response, data;
|
|
54
|
+
var url, requestBody, response, errorText, data;
|
|
55
55
|
return __generator(this, function (_a) {
|
|
56
56
|
switch (_a.label) {
|
|
57
57
|
case 0:
|
|
@@ -71,11 +71,13 @@ function exists(connection, path) {
|
|
|
71
71
|
})];
|
|
72
72
|
case 1:
|
|
73
73
|
response = _a.sent();
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
return [4 /*yield*/, response.json()];
|
|
74
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
75
|
+
return [4 /*yield*/, response.text()];
|
|
78
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:
|
|
79
81
|
data = _a.sent();
|
|
80
82
|
return [2 /*return*/, data];
|
|
81
83
|
}
|
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 find(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.find = find;
|
|
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 find(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
|
+
}
|
package/dist/getMetadata.js
CHANGED
|
@@ -54,7 +54,7 @@ exports.getMetadata = getMetadata;
|
|
|
54
54
|
*/
|
|
55
55
|
function getMetadata(connection, path) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var url, requestBody, response, data;
|
|
57
|
+
var url, requestBody, response, errorText, data;
|
|
58
58
|
return __generator(this, function (_a) {
|
|
59
59
|
switch (_a.label) {
|
|
60
60
|
case 0:
|
|
@@ -74,11 +74,13 @@ function getMetadata(connection, path) {
|
|
|
74
74
|
})];
|
|
75
75
|
case 1:
|
|
76
76
|
response = _a.sent();
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
return [4 /*yield*/, response.json()];
|
|
77
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
78
|
+
return [4 /*yield*/, response.text()];
|
|
81
79
|
case 2:
|
|
80
|
+
errorText = _a.sent();
|
|
81
|
+
return [2 /*return*/, Error("error! status: ".concat(response.status, ", message: ").concat(errorText))];
|
|
82
|
+
case 3: return [4 /*yield*/, response.json()];
|
|
83
|
+
case 4:
|
|
82
84
|
data = _a.sent();
|
|
83
85
|
return [2 /*return*/, data];
|
|
84
86
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Sends a JSON-RPC request to the Xandeum-compatible endpoint to retrieve
|
|
4
|
+
* the result of a transaction previously submitted with a specific signature.
|
|
5
|
+
*
|
|
6
|
+
* This function calls the custom RPC method `getXandeumResult`, which returns
|
|
7
|
+
* the result associated with the given transaction signature.
|
|
8
|
+
*
|
|
9
|
+
* @param connection - The Solana web3 connection object pointing to a Xandeum-compatible RPC endpoint.
|
|
10
|
+
* @param signature - The transaction signature string whose result should be queried.
|
|
11
|
+
*
|
|
12
|
+
* @returns A `Promise<any>` resolving to the parsed JSON response from the RPC server,
|
|
13
|
+
* which includes the result of the transaction if available.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getXandeumResult(connection: Connection, signature: string): Promise<any>;
|