@xandeum/web3.js 1.3.6 → 1.3.7
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/dist/armageddon.js +19 -13
- package/dist/assignCoowner.js +17 -11
- package/dist/bigbang.d.ts +3 -3
- package/dist/bigbang.js +25 -27
- package/dist/const.d.ts +5 -1
- package/dist/const.js +6 -2
- package/dist/copyPath.js +17 -11
- package/dist/createDirectory.d.ts +1 -1
- package/dist/createDirectory.js +18 -12
- package/dist/createFile.js +17 -11
- package/dist/helpers.d.ts +26 -0
- package/dist/helpers.js +44 -0
- package/dist/move.js +15 -9
- package/dist/peek.js +15 -9
- package/dist/poke.d.ts +1 -1
- package/dist/poke.js +16 -10
- package/dist/removeDirectory.js +15 -9
- package/dist/removeFile.js +15 -9
- package/dist/renamePath.js +15 -9
- package/package.json +1 -1
- package/src/armageddon.ts +17 -13
- package/src/assignCoowner.ts +19 -14
- package/src/bigbang.ts +29 -30
- package/src/const.ts +6 -1
- package/src/copyPath.ts +18 -13
- package/src/createDirectory.ts +19 -14
- package/src/createFile.ts +19 -13
- package/src/helpers.ts +48 -1
- package/src/move.ts +18 -13
- package/src/peek.ts +18 -13
- package/src/poke.ts +19 -14
- package/src/removeDirectory.ts +19 -13
- package/src/removeFile.ts +19 -13
- package/src/renamePath.ts +19 -13
package/dist/armageddon.js
CHANGED
|
@@ -42,8 +42,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.armageddon = armageddon;
|
|
43
43
|
var web3_js_1 = require("@solana/web3.js");
|
|
44
44
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var const_1 = require("./const");
|
|
46
|
+
var helpers_1 = require("./helpers");
|
|
47
47
|
/**
|
|
48
48
|
* Constructs a Solana transaction that triggers the "armageddon" instruction
|
|
49
49
|
* on the specified file system (fsid).
|
|
@@ -54,20 +54,16 @@ var helpers_js_1 = require("./helpers.js");
|
|
|
54
54
|
*/
|
|
55
55
|
function armageddon(fsid, wallet) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var innerData,
|
|
57
|
+
var innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
58
58
|
return __generator(this, function (_a) {
|
|
59
59
|
innerData = Buffer.concat([
|
|
60
60
|
Buffer.from([1]),
|
|
61
61
|
Buffer.from(new bn_js_1.default(fsid).toArray('le', 8))
|
|
62
62
|
]);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
innerLen,
|
|
68
|
-
innerData
|
|
69
|
-
]);
|
|
70
|
-
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
63
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
64
|
+
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
65
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
66
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
71
67
|
instruction = new web3_js_1.TransactionInstruction({
|
|
72
68
|
keys: [
|
|
73
69
|
{
|
|
@@ -81,12 +77,22 @@ function armageddon(fsid, wallet) {
|
|
|
81
77
|
isWritable: true
|
|
82
78
|
},
|
|
83
79
|
{
|
|
84
|
-
pubkey:
|
|
80
|
+
pubkey: payerAta.ata,
|
|
81
|
+
isSigner: false,
|
|
82
|
+
isWritable: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
pubkey: feeAta.ata,
|
|
86
|
+
isSigner: false,
|
|
87
|
+
isWritable: true
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
85
91
|
isSigner: false,
|
|
86
92
|
isWritable: false
|
|
87
93
|
}
|
|
88
94
|
],
|
|
89
|
-
programId: new web3_js_1.PublicKey(
|
|
95
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
90
96
|
data: instructionData
|
|
91
97
|
});
|
|
92
98
|
tx = new web3_js_1.Transaction().add(instruction);
|
package/dist/assignCoowner.js
CHANGED
|
@@ -43,7 +43,7 @@ exports.assignCoowner = assignCoowner;
|
|
|
43
43
|
var web3_js_1 = require("@solana/web3.js");
|
|
44
44
|
var const_1 = require("./const");
|
|
45
45
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
46
|
-
var
|
|
46
|
+
var helpers_1 = require("./helpers");
|
|
47
47
|
/**
|
|
48
48
|
* Constructs a Solana transaction to assign a co-owner to a file or directory
|
|
49
49
|
* identified by a file system ID (`fsid`).
|
|
@@ -56,7 +56,7 @@ var helpers_js_1 = require("./helpers.js");
|
|
|
56
56
|
*/
|
|
57
57
|
function assignCoowner(fsid, path, coowner, wallet) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var rest, innerData,
|
|
59
|
+
var rest, innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
60
60
|
return __generator(this, function (_a) {
|
|
61
61
|
rest = Buffer.from("".concat(path, "\0").concat(coowner.toString()), 'utf-8');
|
|
62
62
|
innerData = Buffer.concat([
|
|
@@ -64,14 +64,10 @@ function assignCoowner(fsid, path, coowner, wallet) {
|
|
|
64
64
|
Buffer.from(new bn_js_1.default(fsid).toArray('le', 8)),
|
|
65
65
|
rest
|
|
66
66
|
]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
innerLen,
|
|
72
|
-
innerData
|
|
73
|
-
]);
|
|
74
|
-
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
67
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
68
|
+
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
69
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
70
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
75
71
|
instruction = new web3_js_1.TransactionInstruction({
|
|
76
72
|
keys: [
|
|
77
73
|
{
|
|
@@ -85,7 +81,17 @@ function assignCoowner(fsid, path, coowner, wallet) {
|
|
|
85
81
|
isWritable: true
|
|
86
82
|
},
|
|
87
83
|
{
|
|
88
|
-
pubkey:
|
|
84
|
+
pubkey: payerAta.ata,
|
|
85
|
+
isSigner: false,
|
|
86
|
+
isWritable: true
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
pubkey: feeAta.ata,
|
|
90
|
+
isSigner: false,
|
|
91
|
+
isWritable: true
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
89
95
|
isSigner: false,
|
|
90
96
|
isWritable: false
|
|
91
97
|
}
|
package/dist/bigbang.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
2
|
/**
|
|
3
|
-
* Constructs a Solana transaction that triggers the "bigbang" instruction and
|
|
3
|
+
* Constructs a Solana transaction that triggers the "bigbang" instruction and creates a new file system.
|
|
4
4
|
*
|
|
5
|
+
* @param replicaCount - The number of replicas for the new file system. Must be 2 or greater. The total number of copies will be replicaCount + 1 (one original plus the replicas).
|
|
5
6
|
* @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).
|
|
7
7
|
* @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
|
|
8
8
|
*/
|
|
9
|
-
export declare function bigbang(
|
|
9
|
+
export declare function bigbang(replicaCount: number, wallet: PublicKey): Promise<Transaction>;
|
package/dist/bigbang.js
CHANGED
|
@@ -35,61 +35,59 @@ 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
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
exports.bigbang = bigbang;
|
|
43
40
|
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
-
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
41
|
var const_1 = require("./const");
|
|
46
42
|
var helpers_1 = require("./helpers");
|
|
47
43
|
/**
|
|
48
|
-
* Constructs a Solana transaction that triggers the "bigbang" instruction and
|
|
44
|
+
* Constructs a Solana transaction that triggers the "bigbang" instruction and creates a new file system.
|
|
49
45
|
*
|
|
46
|
+
* @param replicaCount - The number of replicas for the new file system. Must be 2 or greater. The total number of copies will be replicaCount + 1 (one original plus the replicas).
|
|
50
47
|
* @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).
|
|
52
48
|
* @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
|
|
53
49
|
*/
|
|
54
|
-
function bigbang(
|
|
50
|
+
function bigbang(replicaCount, wallet) {
|
|
55
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var
|
|
52
|
+
var feeDistributorPda, payerAta, feeAta, innerData, instructionData, instruction;
|
|
57
53
|
return __generator(this, function (_a) {
|
|
58
|
-
innerData = Buffer.concat([
|
|
59
|
-
Buffer.from([0]),
|
|
60
|
-
Buffer.from(new bn_js_1.default(replica_count).toArray('le', 8))
|
|
61
|
-
]);
|
|
62
|
-
innerLen = Buffer.alloc(4);
|
|
63
|
-
innerLen.writeUInt32LE(innerData.length);
|
|
64
|
-
instructionData = Buffer.concat([
|
|
65
|
-
Buffer.from([0]),
|
|
66
|
-
innerLen,
|
|
67
|
-
innerData
|
|
68
|
-
]);
|
|
69
54
|
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
55
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
56
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
57
|
+
innerData = Buffer.concat([Buffer.from([0]), (0, helpers_1.u64ToLeBytes)(replicaCount)]);
|
|
58
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
70
59
|
instruction = new web3_js_1.TransactionInstruction({
|
|
71
60
|
keys: [
|
|
72
61
|
{
|
|
73
62
|
pubkey: wallet,
|
|
74
63
|
isSigner: true,
|
|
75
|
-
isWritable: true
|
|
64
|
+
isWritable: true,
|
|
76
65
|
},
|
|
77
66
|
{
|
|
78
67
|
pubkey: feeDistributorPda.pda,
|
|
79
68
|
isSigner: false,
|
|
80
|
-
isWritable: true
|
|
69
|
+
isWritable: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
pubkey: payerAta.ata,
|
|
73
|
+
isSigner: false,
|
|
74
|
+
isWritable: true,
|
|
81
75
|
},
|
|
82
76
|
{
|
|
83
|
-
pubkey:
|
|
77
|
+
pubkey: feeAta.ata,
|
|
84
78
|
isSigner: false,
|
|
85
|
-
isWritable:
|
|
86
|
-
}
|
|
79
|
+
isWritable: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
83
|
+
isSigner: false,
|
|
84
|
+
isWritable: false,
|
|
85
|
+
},
|
|
87
86
|
],
|
|
88
87
|
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
89
|
-
data: instructionData
|
|
88
|
+
data: instructionData,
|
|
90
89
|
});
|
|
91
|
-
|
|
92
|
-
return [2 /*return*/, tx];
|
|
90
|
+
return [2 /*return*/, new web3_js_1.Transaction().add(instruction)];
|
|
93
91
|
});
|
|
94
92
|
});
|
|
95
93
|
}
|
package/dist/const.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
export declare const programId = "GH4eE2Wuzd2cFHQgXDp4avGLA3cEiNwEBVhkGkP8Vrs3";
|
|
3
|
+
export declare const TOKEN_PROGRAM_ID: PublicKey;
|
|
4
|
+
export declare const ATA_PROGRAM_ID: PublicKey;
|
|
5
|
+
export declare const TOKEN_MINT_ADDRESS: PublicKey;
|
package/dist/const.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.programId = void 0;
|
|
4
|
-
|
|
3
|
+
exports.TOKEN_MINT_ADDRESS = exports.ATA_PROGRAM_ID = exports.TOKEN_PROGRAM_ID = exports.programId = void 0;
|
|
4
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
exports.programId = "GH4eE2Wuzd2cFHQgXDp4avGLA3cEiNwEBVhkGkP8Vrs3";
|
|
6
|
+
exports.TOKEN_PROGRAM_ID = new web3_js_1.PublicKey("651cCwrKdzgNUBo3sUBGCahtsxzfC7yTaNounG3q3iDF");
|
|
7
|
+
exports.ATA_PROGRAM_ID = new web3_js_1.PublicKey("7aRtRTerxiPxr6fpUBfs2j2ehRANmpSLRWgNPyYitaxi");
|
|
8
|
+
exports.TOKEN_MINT_ADDRESS = new web3_js_1.PublicKey("BPbgHqagPnds7Rs5j7NvL8DjsJAZz1XSCQFW1mU2wigR");
|
package/dist/copyPath.js
CHANGED
|
@@ -44,7 +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
|
|
47
|
+
var helpers_1 = require("./helpers");
|
|
48
48
|
/**
|
|
49
49
|
* Constructs a Solana transaction to copy a file or directory from one path to another.
|
|
50
50
|
*
|
|
@@ -58,7 +58,7 @@ var helpers_js_1 = require("./helpers.js");
|
|
|
58
58
|
*/
|
|
59
59
|
function copyPath(fsid, srcPath, destPath, wallet) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var rest, innerData,
|
|
61
|
+
var rest, innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
62
62
|
return __generator(this, function (_a) {
|
|
63
63
|
// Validate path: only letters, numbers, and /
|
|
64
64
|
(0, sanitizePath_1.sanitizePath)(srcPath);
|
|
@@ -69,14 +69,10 @@ function copyPath(fsid, srcPath, destPath, wallet) {
|
|
|
69
69
|
Buffer.from(new bn_js_1.default(fsid).toArray('le', 8)),
|
|
70
70
|
rest
|
|
71
71
|
]);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
innerLen,
|
|
77
|
-
innerData
|
|
78
|
-
]);
|
|
79
|
-
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
72
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
73
|
+
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
74
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
75
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
80
76
|
instruction = new web3_js_1.TransactionInstruction({
|
|
81
77
|
keys: [
|
|
82
78
|
{
|
|
@@ -90,7 +86,17 @@ function copyPath(fsid, srcPath, destPath, wallet) {
|
|
|
90
86
|
isWritable: true
|
|
91
87
|
},
|
|
92
88
|
{
|
|
93
|
-
pubkey:
|
|
89
|
+
pubkey: payerAta.ata,
|
|
90
|
+
isSigner: false,
|
|
91
|
+
isWritable: true
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pubkey: feeAta.ata,
|
|
95
|
+
isSigner: false,
|
|
96
|
+
isWritable: true
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
94
100
|
isSigner: false,
|
|
95
101
|
isWritable: false
|
|
96
102
|
}
|
|
@@ -5,7 +5,7 @@ import { Transaction, PublicKey } from '@solana/web3.js';
|
|
|
5
5
|
* @param fsid - A numeric filesystem identifier used to scope the directory creation.
|
|
6
6
|
* @param path - The parent path where the directory should be created (e.g., `/documents`).
|
|
7
7
|
* @param name - The name of the new directory (e.g., `reports`).
|
|
8
|
-
* @param wallet - The signer
|
|
8
|
+
* @param wallet - The signer's public key that authorizes the transaction.
|
|
9
9
|
* @returns A Promise that resolves to a Solana `Transaction` object containing the createDirectory instruction.
|
|
10
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
11
|
*/
|
package/dist/createDirectory.js
CHANGED
|
@@ -44,20 +44,20 @@ 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
|
|
47
|
+
var helpers_1 = require("./helpers");
|
|
48
48
|
/**
|
|
49
49
|
* Constructs a Solana transaction to create a new directory within a file system.
|
|
50
50
|
*
|
|
51
51
|
* @param fsid - A numeric filesystem identifier used to scope the directory creation.
|
|
52
52
|
* @param path - The parent path where the directory should be created (e.g., `/documents`).
|
|
53
53
|
* @param name - The name of the new directory (e.g., `reports`).
|
|
54
|
-
* @param wallet - The signer
|
|
54
|
+
* @param wallet - The signer's public key that authorizes the transaction.
|
|
55
55
|
* @returns A Promise that resolves to a Solana `Transaction` object containing the createDirectory instruction.
|
|
56
56
|
* @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).
|
|
57
57
|
*/
|
|
58
58
|
function createDirectory(fsid, path, name, wallet) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
var combinedPath, rest, innerData,
|
|
60
|
+
var combinedPath, rest, innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
61
61
|
return __generator(this, function (_a) {
|
|
62
62
|
combinedPath = path.endsWith('/') ? "".concat(path).concat(name) : "".concat(path, "/").concat(name);
|
|
63
63
|
(0, sanitizePath_1.sanitizePath)(combinedPath);
|
|
@@ -67,14 +67,10 @@ function createDirectory(fsid, path, name, wallet) {
|
|
|
67
67
|
Buffer.from(new bn_js_1.default(fsid).toArray('le', 8)),
|
|
68
68
|
rest
|
|
69
69
|
]);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
innerLen,
|
|
75
|
-
innerData
|
|
76
|
-
]);
|
|
77
|
-
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
70
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
71
|
+
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
72
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
73
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
78
74
|
instruction = new web3_js_1.TransactionInstruction({
|
|
79
75
|
keys: [
|
|
80
76
|
{
|
|
@@ -88,7 +84,17 @@ function createDirectory(fsid, path, name, wallet) {
|
|
|
88
84
|
isWritable: true
|
|
89
85
|
},
|
|
90
86
|
{
|
|
91
|
-
pubkey:
|
|
87
|
+
pubkey: payerAta.ata,
|
|
88
|
+
isSigner: false,
|
|
89
|
+
isWritable: true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
pubkey: feeAta.ata,
|
|
93
|
+
isSigner: false,
|
|
94
|
+
isWritable: true
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
92
98
|
isSigner: false,
|
|
93
99
|
isWritable: false
|
|
94
100
|
}
|
package/dist/createFile.js
CHANGED
|
@@ -44,7 +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
|
|
47
|
+
var helpers_1 = require("./helpers");
|
|
48
48
|
/**
|
|
49
49
|
* Constructs a Solana transaction to create a new file
|
|
50
50
|
* within a file system, identified by a file system ID (`fsid`).
|
|
@@ -58,7 +58,7 @@ var helpers_js_1 = require("./helpers.js");
|
|
|
58
58
|
*/
|
|
59
59
|
function createFile(fsid, path, name, wallet) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var combinedPath, rest, innerData,
|
|
61
|
+
var combinedPath, rest, innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
62
62
|
return __generator(this, function (_a) {
|
|
63
63
|
combinedPath = path.endsWith('/') ? "".concat(path).concat(name) : "".concat(path, "/").concat(name);
|
|
64
64
|
(0, sanitizePath_1.sanitizePath)(combinedPath);
|
|
@@ -68,14 +68,10 @@ function createFile(fsid, path, name, wallet) {
|
|
|
68
68
|
Buffer.from(new bn_js_1.default(fsid).toArray('le', 8)),
|
|
69
69
|
rest
|
|
70
70
|
]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
innerLen,
|
|
76
|
-
innerData
|
|
77
|
-
]);
|
|
78
|
-
feeDistributorPda = (0, helpers_js_1.getFeeDistributorPda)();
|
|
71
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
72
|
+
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
73
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
74
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
79
75
|
instruction = new web3_js_1.TransactionInstruction({
|
|
80
76
|
keys: [
|
|
81
77
|
{
|
|
@@ -89,7 +85,17 @@ function createFile(fsid, path, name, wallet) {
|
|
|
89
85
|
isWritable: true
|
|
90
86
|
},
|
|
91
87
|
{
|
|
92
|
-
pubkey:
|
|
88
|
+
pubkey: payerAta.ata,
|
|
89
|
+
isSigner: false,
|
|
90
|
+
isWritable: true
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
pubkey: feeAta.ata,
|
|
94
|
+
isSigner: false,
|
|
95
|
+
isWritable: true
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
93
99
|
isSigner: false,
|
|
94
100
|
isWritable: false
|
|
95
101
|
}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -50,6 +50,32 @@ export declare function getCurrentYuga(): number;
|
|
|
50
50
|
* console.log('Bump seed:', bump)
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
+
/**
|
|
54
|
+
* Derives the Associated Token Address (ATA) for a given wallet using custom program IDs.
|
|
55
|
+
*
|
|
56
|
+
* @param walletAddress - The public key of the wallet
|
|
57
|
+
* @returns An object containing the ATA public key and bump seed
|
|
58
|
+
*/
|
|
59
|
+
export declare function getAssociatedTokenAddressWithProgramIds(walletAddress: PublicKey): {
|
|
60
|
+
ata: PublicKey;
|
|
61
|
+
bump: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Converts a u64 value to little-endian bytes.
|
|
65
|
+
*
|
|
66
|
+
* @param value - The value to convert (number)
|
|
67
|
+
* @returns A Buffer containing the 8-byte little-endian representation
|
|
68
|
+
*/
|
|
69
|
+
export declare function u64ToLeBytes(value: number): Buffer;
|
|
70
|
+
/**
|
|
71
|
+
* Builds the instruction data buffer for a given inner data payload.
|
|
72
|
+
* Allocates a fixed 33-byte buffer, sets the first byte to 0,
|
|
73
|
+
* and copies the inner data starting at offset 1.
|
|
74
|
+
*
|
|
75
|
+
* @param innerData - The inner data buffer to embed in the instruction
|
|
76
|
+
* @returns A 33-byte Buffer containing the instruction data
|
|
77
|
+
*/
|
|
78
|
+
export declare function buildInstructionData(innerData: Buffer): Buffer;
|
|
53
79
|
export declare function getFeeDistributorPda(): {
|
|
54
80
|
pda: PublicKey;
|
|
55
81
|
bump: number;
|
package/dist/helpers.js
CHANGED
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.YUGA_START_TIMESTAMP = exports.YUGA_DURATION_SECONDS = exports.PULSES_PER_YUGA = exports.PULSE_DURATION_SECONDS = exports.FEE_DISTRIBUTOR_SEED = void 0;
|
|
7
7
|
exports.getYugaFromTimestamp = getYugaFromTimestamp;
|
|
8
8
|
exports.getCurrentYuga = getCurrentYuga;
|
|
9
|
+
exports.getAssociatedTokenAddressWithProgramIds = getAssociatedTokenAddressWithProgramIds;
|
|
10
|
+
exports.u64ToLeBytes = u64ToLeBytes;
|
|
11
|
+
exports.buildInstructionData = buildInstructionData;
|
|
9
12
|
exports.getFeeDistributorPda = getFeeDistributorPda;
|
|
10
13
|
var web3_js_1 = require("@solana/web3.js");
|
|
11
14
|
var const_1 = require("./const");
|
|
@@ -69,6 +72,47 @@ function getCurrentYuga() {
|
|
|
69
72
|
* console.log('Bump seed:', bump)
|
|
70
73
|
* ```
|
|
71
74
|
*/
|
|
75
|
+
/**
|
|
76
|
+
* Derives the Associated Token Address (ATA) for a given wallet using custom program IDs.
|
|
77
|
+
*
|
|
78
|
+
* @param walletAddress - The public key of the wallet
|
|
79
|
+
* @returns An object containing the ATA public key and bump seed
|
|
80
|
+
*/
|
|
81
|
+
function getAssociatedTokenAddressWithProgramIds(walletAddress) {
|
|
82
|
+
var _a = web3_js_1.PublicKey.findProgramAddressSync([
|
|
83
|
+
walletAddress.toBuffer(),
|
|
84
|
+
const_1.TOKEN_PROGRAM_ID.toBuffer(),
|
|
85
|
+
const_1.TOKEN_MINT_ADDRESS.toBuffer(),
|
|
86
|
+
], const_1.ATA_PROGRAM_ID), ata = _a[0], bump = _a[1];
|
|
87
|
+
return { ata: ata, bump: bump };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts a u64 value to little-endian bytes.
|
|
91
|
+
*
|
|
92
|
+
* @param value - The value to convert (number)
|
|
93
|
+
* @returns A Buffer containing the 8-byte little-endian representation
|
|
94
|
+
*/
|
|
95
|
+
function u64ToLeBytes(value) {
|
|
96
|
+
var bn = new bn_js_1.default(value);
|
|
97
|
+
if (bn.isNeg() || bn.byteLength() > 8) {
|
|
98
|
+
throw new Error("u64 out of range: ".concat(value));
|
|
99
|
+
}
|
|
100
|
+
return Buffer.from(bn.toArray('le', 8));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Builds the instruction data buffer for a given inner data payload.
|
|
104
|
+
* Allocates a fixed 33-byte buffer, sets the first byte to 0,
|
|
105
|
+
* and copies the inner data starting at offset 1.
|
|
106
|
+
*
|
|
107
|
+
* @param innerData - The inner data buffer to embed in the instruction
|
|
108
|
+
* @returns A 33-byte Buffer containing the instruction data
|
|
109
|
+
*/
|
|
110
|
+
function buildInstructionData(innerData) {
|
|
111
|
+
var instructionData = Buffer.alloc(33, 0);
|
|
112
|
+
instructionData[0] = 0;
|
|
113
|
+
innerData.copy(instructionData, 1);
|
|
114
|
+
return instructionData;
|
|
115
|
+
}
|
|
72
116
|
function getFeeDistributorPda() {
|
|
73
117
|
var yuga = getCurrentYuga();
|
|
74
118
|
var yugaBuffer = Buffer.from(new bn_js_1.default(yuga).toArray('le', 8));
|
package/dist/move.js
CHANGED
|
@@ -59,7 +59,7 @@ var helpers_1 = require("./helpers");
|
|
|
59
59
|
*/
|
|
60
60
|
function move(fsid, srcPath, destPath, name, wallet) {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var rest, innerData,
|
|
62
|
+
var rest, innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
63
63
|
return __generator(this, function (_a) {
|
|
64
64
|
// Validate path: only letters, numbers, and /
|
|
65
65
|
(0, sanitizePath_1.sanitizePath)(srcPath);
|
|
@@ -71,14 +71,10 @@ function move(fsid, srcPath, destPath, name, wallet) {
|
|
|
71
71
|
Buffer.from(new bn_js_1.default(fsid).toArray('le', 8)),
|
|
72
72
|
rest
|
|
73
73
|
]);
|
|
74
|
-
|
|
75
|
-
innerLen.writeUInt32LE(innerData.length);
|
|
76
|
-
instructionData = Buffer.concat([
|
|
77
|
-
Buffer.from([0]),
|
|
78
|
-
innerLen,
|
|
79
|
-
innerData
|
|
80
|
-
]);
|
|
74
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
81
75
|
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
76
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
77
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
82
78
|
instruction = new web3_js_1.TransactionInstruction({
|
|
83
79
|
keys: [
|
|
84
80
|
{
|
|
@@ -92,7 +88,17 @@ function move(fsid, srcPath, destPath, name, wallet) {
|
|
|
92
88
|
isWritable: true
|
|
93
89
|
},
|
|
94
90
|
{
|
|
95
|
-
pubkey:
|
|
91
|
+
pubkey: payerAta.ata,
|
|
92
|
+
isSigner: false,
|
|
93
|
+
isWritable: true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
pubkey: feeAta.ata,
|
|
97
|
+
isSigner: false,
|
|
98
|
+
isWritable: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
96
102
|
isSigner: false,
|
|
97
103
|
isWritable: false
|
|
98
104
|
}
|
package/dist/peek.js
CHANGED
|
@@ -60,7 +60,7 @@ var helpers_1 = require("./helpers");
|
|
|
60
60
|
*/
|
|
61
61
|
function peek(fsid, path, startPosition, endPosition, wallet) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var rest, innerData,
|
|
63
|
+
var rest, innerData, instructionData, feeDistributorPda, payerAta, feeAta, instruction, tx;
|
|
64
64
|
return __generator(this, function (_a) {
|
|
65
65
|
(0, sanitizePath_1.sanitizePath)(path);
|
|
66
66
|
rest = Buffer.from("".concat(path), 'utf-8');
|
|
@@ -71,14 +71,10 @@ function peek(fsid, path, startPosition, endPosition, wallet) {
|
|
|
71
71
|
Buffer.from(new bn_js_1.default(endPosition).toArray('le', 8)),
|
|
72
72
|
rest
|
|
73
73
|
]);
|
|
74
|
-
|
|
75
|
-
innerLen.writeUInt32LE(innerData.length);
|
|
76
|
-
instructionData = Buffer.concat([
|
|
77
|
-
Buffer.from([0]),
|
|
78
|
-
innerLen,
|
|
79
|
-
innerData
|
|
80
|
-
]);
|
|
74
|
+
instructionData = (0, helpers_1.buildInstructionData)(innerData);
|
|
81
75
|
feeDistributorPda = (0, helpers_1.getFeeDistributorPda)();
|
|
76
|
+
payerAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(wallet);
|
|
77
|
+
feeAta = (0, helpers_1.getAssociatedTokenAddressWithProgramIds)(feeDistributorPda.pda);
|
|
82
78
|
instruction = new web3_js_1.TransactionInstruction({
|
|
83
79
|
keys: [
|
|
84
80
|
{
|
|
@@ -92,7 +88,17 @@ function peek(fsid, path, startPosition, endPosition, wallet) {
|
|
|
92
88
|
isWritable: true
|
|
93
89
|
},
|
|
94
90
|
{
|
|
95
|
-
pubkey:
|
|
91
|
+
pubkey: payerAta.ata,
|
|
92
|
+
isSigner: false,
|
|
93
|
+
isWritable: true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
pubkey: feeAta.ata,
|
|
97
|
+
isSigner: false,
|
|
98
|
+
isWritable: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
pubkey: const_1.TOKEN_PROGRAM_ID,
|
|
96
102
|
isSigner: false,
|
|
97
103
|
isWritable: false
|
|
98
104
|
}
|
package/dist/poke.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
2
|
/**
|
|
3
|
-
* Constructs a Solana transaction to perform a poke
|
|
3
|
+
* Constructs a Solana transaction to perform a poke operation, which writes data
|
|
4
4
|
* to a file at the specified path and byte position.
|
|
5
5
|
*
|
|
6
6
|
* @param fsid - A stringified integer representing the file system ID where the file resides.
|