@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/LICENSE
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
37
|
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
38
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
39
|
+
|
|
40
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
41
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
42
|
+
|
|
43
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
44
|
+
|
|
45
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
46
|
+
|
|
47
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
48
|
+
|
|
49
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
50
|
+
|
|
51
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# @xandeum/web3.js
|
|
2
|
+
|
|
3
|
+
> Solana transaction builder for interacting with a file system on the Xandeum network.
|
|
4
|
+
|
|
5
|
+
This package provides a JavaScript/TypeScript interface to construct Solana transactions for creating, modifying, and managing file systems on-chain using the Xandeum program.
|
|
6
|
+
|
|
7
|
+
## ✨ Features
|
|
8
|
+
|
|
9
|
+
- Create and delete file systems (`bigbang`, `armageddon`)
|
|
10
|
+
- Manage files and directories (`create`, `rename`, `remove`, `copy`)
|
|
11
|
+
- Read and write file contents with byte-level control (`peek`, `poke`)
|
|
12
|
+
- Secure path validation and serialization
|
|
13
|
+
- Compatible with `@solana/web3.js`
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @xandeum/web3.js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
yarn add @xandeum/web3.js
|
|
25
|
+
```
|
|
26
|
+
🚀 Usage
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
import {
|
|
30
|
+
bigbang,
|
|
31
|
+
armageddon,
|
|
32
|
+
createFile,
|
|
33
|
+
poke,
|
|
34
|
+
peek,
|
|
35
|
+
copyPath
|
|
36
|
+
} from '@xandeum/web3.js'
|
|
37
|
+
|
|
38
|
+
import {
|
|
39
|
+
Connection,
|
|
40
|
+
sendAndConfirmTransaction,
|
|
41
|
+
Keypair,
|
|
42
|
+
PublicKey
|
|
43
|
+
} from '@solana/web3.js'
|
|
44
|
+
|
|
45
|
+
const connection = new Connection('https://apis.devnet.xandeum.com)
|
|
46
|
+
const signer = Keypair.generate()
|
|
47
|
+
const wallet = signer.publicKey
|
|
48
|
+
|
|
49
|
+
async function main() {
|
|
50
|
+
// Create a new file system
|
|
51
|
+
const tx1 = await bigbang(wallet)
|
|
52
|
+
await sendAndConfirmTransaction(connection, tx1, [signer])
|
|
53
|
+
|
|
54
|
+
// Create a file
|
|
55
|
+
const tx2 = await createFile('1', '/','hello.txt', wallet)
|
|
56
|
+
await sendAndConfirmTransaction(connection, tx2, [signer])
|
|
57
|
+
|
|
58
|
+
const dataAccount = new PublicKey("FBM4G63KPUneqyLwQy6zVu81AsMqmkQjsdxNGBKq3dkv");
|
|
59
|
+
|
|
60
|
+
// Write data
|
|
61
|
+
const tx3 = await poke('1', '/hello.txt', 0, Buffer.from('Hello Xandeum!'), wallet)
|
|
62
|
+
await sendAndConfirmTransaction(connection, tx3, [signer])
|
|
63
|
+
|
|
64
|
+
// Read data
|
|
65
|
+
const tx4 = await peek('1', '/hello.txt', 0, 14, wallet)
|
|
66
|
+
await sendAndConfirmTransaction(connection, tx4, [signer])
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 🧩 API Overview
|
|
71
|
+
|
|
72
|
+
bigbang(wallet: PublicKey): Promise<Transaction>
|
|
73
|
+
Creates a new file system account.
|
|
74
|
+
|
|
75
|
+
armageddon(fsid: string, wallet: PublicKey): Promise<Transaction>
|
|
76
|
+
Deletes a file system by ID.
|
|
77
|
+
|
|
78
|
+
createFile(fsid: string, path: string, wallet: PublicKey): Promise<Transaction>
|
|
79
|
+
Creates a new file at the given path.
|
|
80
|
+
|
|
81
|
+
poke(fsid: string, path: string, offset: number, data: Buffer, wallet: PublicKey): Promise<Transaction>
|
|
82
|
+
Writes bytes to a file starting at a specific offset.
|
|
83
|
+
|
|
84
|
+
peek(fsid: string, path: string, offset: number, length: number, wallet: PublicKey): Promise<Transaction>
|
|
85
|
+
Reads bytes from a file.
|
|
86
|
+
|
|
87
|
+
copyPath(fsid: string, srcPath: string, destPath: string, wallet: PublicKey): Promise<Transaction>
|
|
88
|
+
Copies a file or directory from one path to another.
|
|
89
|
+
|
|
90
|
+
Other available functions <br />
|
|
91
|
+
renamePath <br />
|
|
92
|
+
removeFile <br />
|
|
93
|
+
removeDirectory <br />
|
|
94
|
+
createDirectory <br />
|
|
95
|
+
exists <br />
|
|
96
|
+
listDirectoryEntry <br />
|
|
97
|
+
getMetadata <br />
|
|
98
|
+
|
|
99
|
+
All functions that accept a file or directory path will validate inputs using sanitizePath to prevent invalid characters.
|
|
100
|
+
|
|
101
|
+
## 🌐 WebSocket Subscription
|
|
102
|
+
|
|
103
|
+
subscribeResult(connection: Connection,tx: string, onResult: (result: ResultValue) => void, onError?: (err: any) => void, onClose?: () => void): void
|
|
104
|
+
Subscribes to results from a transaction via WebSocket. Used for listening events triggered by the transaction.
|
|
105
|
+
|
|
106
|
+
#### Parameters:
|
|
107
|
+
|
|
108
|
+
connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
|
|
109
|
+
tx — Transaction signature to subscribe to
|
|
110
|
+
onResult(result) — Called when a valid result is received
|
|
111
|
+
onError(err) — Optional callback for connection errors
|
|
112
|
+
onClose() — Optional callback for connection closure
|
|
113
|
+
Example:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
subscribeResult(
|
|
117
|
+
connection,
|
|
118
|
+
'transactionSignatureHere',
|
|
119
|
+
result => {
|
|
120
|
+
console.log('Result:', result)
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Example
|
|
126
|
+
```
|
|
127
|
+
import {
|
|
128
|
+
bigbang,
|
|
129
|
+
createFile,
|
|
130
|
+
poke,
|
|
131
|
+
peek,
|
|
132
|
+
subscribeResult
|
|
133
|
+
} from '@xandeum/web3.js'
|
|
134
|
+
|
|
135
|
+
import {
|
|
136
|
+
Connection,
|
|
137
|
+
sendAndConfirmTransaction,
|
|
138
|
+
Keypair
|
|
139
|
+
} from '@solana/web3.js'
|
|
140
|
+
|
|
141
|
+
const connection = new Connection('https://api.mainnet-beta.solana.com')
|
|
142
|
+
const signer = Keypair.generate()
|
|
143
|
+
const wallet = signer.publicKey
|
|
144
|
+
|
|
145
|
+
async function main() {
|
|
146
|
+
const tx = await createFile('1', '/hello.txt', wallet)
|
|
147
|
+
const txSignature = await sendAndConfirmTransaction(connection, tx, [signer])
|
|
148
|
+
|
|
149
|
+
subscribeResult(
|
|
150
|
+
connection,
|
|
151
|
+
txSignature,
|
|
152
|
+
result => {
|
|
153
|
+
console.log('Received result:', result)
|
|
154
|
+
},
|
|
155
|
+
err => console.error('WebSocket error:', err),
|
|
156
|
+
() => console.log('WebSocket closed')
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Apache-2.0 © Xandeum
|
|
162
|
+
|
|
163
|
+
👤 Author
|
|
164
|
+
|
|
165
|
+
Built by Xandeum to provide decentralized, programmable file systems on Solana via the Xandeum protocol.
|
|
166
|
+
|
|
167
|
+
|
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
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a Solana transaction that triggers the "armageddon" instruction
|
|
4
|
+
* on the specified file system (fsid).
|
|
5
|
+
*
|
|
6
|
+
* @param fsid - A stringified integer representing the file system ID to be used in the instruction.
|
|
7
|
+
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
8
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the armageddon instruction.
|
|
9
|
+
*/
|
|
10
|
+
export declare function armageddon(fsid: string, wallet: PublicKey): Promise<Transaction>;
|
|
@@ -0,0 +1,77 @@
|
|
|
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.armageddon = armageddon;
|
|
43
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
44
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
45
|
+
var const_js_1 = require("./const.js");
|
|
46
|
+
/**
|
|
47
|
+
* Constructs a Solana transaction that triggers the "armageddon" instruction
|
|
48
|
+
* on the specified file system (fsid).
|
|
49
|
+
*
|
|
50
|
+
* @param fsid - A stringified integer representing the file system ID to be used in the instruction.
|
|
51
|
+
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
52
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the armageddon instruction.
|
|
53
|
+
*/
|
|
54
|
+
function armageddon(fsid, wallet) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var instructionData, instruction, tx;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
instructionData = Buffer.concat([
|
|
59
|
+
Buffer.from(Int8Array.from([1]).buffer),
|
|
60
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8)))
|
|
61
|
+
]);
|
|
62
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
63
|
+
keys: [
|
|
64
|
+
{
|
|
65
|
+
pubkey: wallet,
|
|
66
|
+
isSigner: true,
|
|
67
|
+
isWritable: true
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
programId: new web3_js_1.PublicKey(const_js_1.programId),
|
|
71
|
+
data: instructionData
|
|
72
|
+
});
|
|
73
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
74
|
+
return [2 /*return*/, tx];
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -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,81 @@
|
|
|
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
|
+
/**
|
|
47
|
+
* Constructs a Solana transaction to assign a co-owner to a file or directory
|
|
48
|
+
* identified by a file system ID (`fsid`).
|
|
49
|
+
*
|
|
50
|
+
* @param fsid - A stringified integer representing the file system ID where the co-owner is to be assigned.
|
|
51
|
+
* @param path - The path within the file system.
|
|
52
|
+
* @param coowner - The public key of the co-owner to be assigned.
|
|
53
|
+
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
54
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the assignCoowner instruction.
|
|
55
|
+
*/
|
|
56
|
+
function assignCoowner(fsid, path, coowner, wallet) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var rest, instructionData, instruction, tx;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
rest = Buffer.from("".concat(path, "\0").concat(coowner.toString()), 'utf-8');
|
|
61
|
+
instructionData = Buffer.concat([
|
|
62
|
+
Buffer.from(Int8Array.from([14]).buffer),
|
|
63
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(fsid).toArray('le', 8))),
|
|
64
|
+
rest
|
|
65
|
+
]);
|
|
66
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
67
|
+
keys: [
|
|
68
|
+
{
|
|
69
|
+
pubkey: wallet,
|
|
70
|
+
isSigner: true,
|
|
71
|
+
isWritable: true
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
75
|
+
data: instructionData
|
|
76
|
+
});
|
|
77
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
78
|
+
return [2 /*return*/, tx];
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a Solana transaction that triggers the "bigbang" instruction and create new file system.
|
|
4
|
+
*
|
|
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.
|
|
7
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
|
|
8
|
+
*/
|
|
9
|
+
export declare function bigbang(replica_count: string, wallet: PublicKey): Promise<Transaction>;
|
package/dist/bigbang.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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.bigbang = bigbang;
|
|
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
|
+
/**
|
|
47
|
+
* Constructs a Solana transaction that triggers the "bigbang" instruction and create new file system.
|
|
48
|
+
*
|
|
49
|
+
* @param wallet - The public key of the wallet that will sign and authorize the transaction.
|
|
50
|
+
* @param replica_count - A stringified integer representing the number of replicas for the new file system.
|
|
51
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
|
|
52
|
+
*/
|
|
53
|
+
function bigbang(replica_count, wallet) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
+
var instructionData, instruction, tx;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
instructionData = Buffer.concat([
|
|
58
|
+
Buffer.from(Int8Array.from([0]).buffer),
|
|
59
|
+
Buffer.from(Uint8Array.of.apply(Uint8Array, new bn_js_1.default(replica_count).toArray('le', 8)))
|
|
60
|
+
]);
|
|
61
|
+
instruction = new web3_js_1.TransactionInstruction({
|
|
62
|
+
keys: [
|
|
63
|
+
{
|
|
64
|
+
pubkey: wallet,
|
|
65
|
+
isSigner: true,
|
|
66
|
+
isWritable: true
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
programId: new web3_js_1.PublicKey(const_1.programId),
|
|
70
|
+
data: instructionData
|
|
71
|
+
});
|
|
72
|
+
tx = new web3_js_1.Transaction().add(instruction);
|
|
73
|
+
return [2 /*return*/, tx];
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
package/dist/const.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const programId = "xSHLJPXU8QW3A9kGiRoL94bksJ7ZZPY4dUwJPAT8CVK";
|
package/dist/const.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a Solana transaction to copy a file or directory from one path to another.
|
|
4
|
+
*
|
|
5
|
+
* @param fsid - The unique numeric identifier representing the target file system.
|
|
6
|
+
* @param srcPath - The source path to copy from (e.g., `/documents/report.txt`).
|
|
7
|
+
* @param destPath - The destination path to copy to (e.g., `/archive/report.txt`).
|
|
8
|
+
* @param wallet - The wallet public key used to sign and authorize the transaction.
|
|
9
|
+
* @returns A Promise that resolves to a Solana `Transaction` object containing the copyPath instruction.
|
|
10
|
+
* @throws Will throw an error if `srcPath` or `destPath` contains invalid characters.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export declare function copyPath(fsid: string, srcPath: string, destPath: string, wallet: PublicKey): Promise<Transaction>;
|