@xandeum/web3.js 1.3.0 → 1.3.1

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.
Files changed (117) hide show
  1. package/README.md +9 -6
  2. package/archbee.yaml +55 -0
  3. package/dist/armageddon.js +9 -1
  4. package/dist/assignCoowner.d.ts +12 -0
  5. package/dist/assignCoowner.js +89 -0
  6. package/dist/bigbang.d.ts +2 -1
  7. package/dist/bigbang.js +17 -3
  8. package/dist/const.d.ts +1 -0
  9. package/dist/const.js +2 -1
  10. package/dist/copyPath.js +9 -1
  11. package/dist/createDirectory.js +9 -1
  12. package/dist/createFile.js +9 -1
  13. package/dist/exists.js +7 -5
  14. package/dist/find.d.ts +22 -0
  15. package/dist/find.js +88 -0
  16. package/dist/getMetadata.js +7 -5
  17. package/dist/getXandeumResult.d.ts +15 -0
  18. package/dist/getXandeumResult.js +115 -0
  19. package/dist/helpers.d.ts +56 -0
  20. package/dist/helpers.js +80 -0
  21. package/dist/index.d.ts +5 -0
  22. package/dist/index.js +7 -1
  23. package/dist/listDirectoryEntery.js +7 -5
  24. package/dist/move.d.ts +14 -0
  25. package/dist/move.js +96 -0
  26. package/dist/pdaHelpers.d.ts +57 -0
  27. package/dist/pdaHelpers.js +83 -0
  28. package/dist/peek.js +9 -1
  29. package/dist/poke.js +9 -1
  30. package/dist/removeDirectory.js +9 -1
  31. package/dist/removeFile.js +9 -1
  32. package/dist/renamePath.js +9 -1
  33. package/dist/webSocket.d.ts +1 -1
  34. package/dist/webSocket.js +16 -3
  35. package/docs/html/assets/highlight.css +92 -0
  36. package/docs/html/assets/navigation.js +1 -0
  37. package/docs/html/assets/search.js +1 -0
  38. package/docs/{functions → html/functions}/armageddon.html +3 -3
  39. package/docs/html/functions/assignCoowner.html +8 -0
  40. package/docs/html/functions/bigbang.html +5 -0
  41. package/docs/{functions → html/functions}/copyPath.html +2 -8
  42. package/docs/{functions → html/functions}/createDirectory.html +2 -8
  43. package/docs/{functions → html/functions}/createFile.html +2 -9
  44. package/docs/{functions → html/functions}/exists.html +4 -4
  45. package/docs/html/functions/find.html +10 -0
  46. package/docs/html/functions/getMetadata.html +10 -0
  47. package/docs/html/functions/getXandeumResult.html +9 -0
  48. package/docs/{functions → html/functions}/listDirectoryEntry.html +4 -4
  49. package/docs/html/functions/move.html +9 -0
  50. package/docs/{functions → html/functions}/peek.html +2 -10
  51. package/docs/{functions → html/functions}/poke.html +2 -10
  52. package/docs/{functions → html/functions}/removeDirectory.html +2 -8
  53. package/docs/{functions → html/functions}/removeFile.html +2 -8
  54. package/docs/{functions → html/functions}/renamePath.html +3 -9
  55. package/docs/{functions → html/functions}/subscribeResult.html +4 -4
  56. package/docs/html/functions/unsubscribeResult.html +6 -0
  57. package/docs/{hierarchy.html → html/hierarchy.html} +1 -1
  58. package/docs/html/index.html +62 -0
  59. package/docs/html/modules.html +1 -0
  60. package/docs/markdown/README.md +10 -7
  61. package/docs/markdown/functions/armageddon.md +2 -2
  62. package/docs/markdown/functions/assignCoowner.md +46 -0
  63. package/docs/markdown/functions/bigbang.md +9 -3
  64. package/docs/markdown/functions/copyPath.md +2 -2
  65. package/docs/markdown/functions/createDirectory.md +2 -2
  66. package/docs/markdown/functions/createFile.md +2 -2
  67. package/docs/markdown/functions/exists.md +2 -2
  68. package/docs/markdown/functions/find.md +44 -0
  69. package/docs/markdown/functions/getMetadata.md +2 -2
  70. package/docs/markdown/functions/getXandeumResult.md +38 -0
  71. package/docs/markdown/functions/listDirectoryEntry.md +2 -2
  72. package/docs/markdown/functions/move.md +55 -0
  73. package/docs/markdown/functions/peek.md +2 -2
  74. package/docs/markdown/functions/poke.md +2 -2
  75. package/docs/markdown/functions/removeDirectory.md +2 -2
  76. package/docs/markdown/functions/removeFile.md +2 -2
  77. package/docs/markdown/functions/renamePath.md +2 -2
  78. package/docs/markdown/functions/subscribeResult.md +2 -2
  79. package/docs/markdown/functions/unsubscribeResult.md +2 -2
  80. package/docs/markdown/globals.md +6 -2
  81. package/package.json +3 -3
  82. package/src/armageddon.ts +8 -0
  83. package/src/assignCoowner.ts +49 -0
  84. package/src/bigbang.ts +13 -2
  85. package/src/const.ts +3 -1
  86. package/src/copyPath.ts +8 -1
  87. package/src/createDirectory.ts +8 -1
  88. package/src/createFile.ts +8 -2
  89. package/src/exists.ts +2 -1
  90. package/src/find.ts +53 -0
  91. package/src/getMetadata.ts +2 -1
  92. package/src/getXandeumResult.ts +67 -0
  93. package/src/helpers.ts +85 -0
  94. package/src/index.ts +5 -1
  95. package/src/listDirectoryEntery.ts +2 -1
  96. package/src/move.ts +62 -0
  97. package/src/peek.ts +8 -1
  98. package/src/poke.ts +8 -1
  99. package/src/removeDirectory.ts +8 -2
  100. package/src/removeFile.ts +8 -2
  101. package/src/renamePath.ts +8 -2
  102. package/src/webSocket.ts +18 -5
  103. package/typedoc.json +3 -4
  104. package/docs/assets/highlight.css +0 -22
  105. package/docs/assets/navigation.js +0 -1
  106. package/docs/assets/search.js +0 -1
  107. package/docs/functions/bigbang.html +0 -4
  108. package/docs/functions/getMetadata.html +0 -10
  109. package/docs/functions/unsubscribeResult.html +0 -6
  110. package/docs/index.html +0 -2
  111. package/docs/modules.html +0 -1
  112. /package/docs/{.nojekyll → html/.nojekyll} +0 -0
  113. /package/docs/{assets → html/assets}/hierarchy.js +0 -0
  114. /package/docs/{assets → html/assets}/icons.js +0 -0
  115. /package/docs/{assets → html/assets}/icons.svg +0 -0
  116. /package/docs/{assets → html/assets}/main.js +0 -0
  117. /package/docs/{assets → html/assets}/style.css +0 -0
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **createFile**(`fsid`, `path`, `name`, `wallet`): `Promise`\<`Transaction`\>
10
10
 
11
- Defined in: [createFile.ts:17](https://github.com/Xandeum/test_web3/blob/main/src/createFile.ts#L17)
11
+ Defined in: [createFile.ts:17](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/createFile.ts#L17)
12
12
 
13
13
  Constructs a Solana transaction to create a new file
14
14
  within a file system, identified by a file system ID (`fsid`).
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **exists**(`connection`, `path`): `Promise`\<`any`\>
10
10
 
11
- Defined in: [exists.ts:23](https://github.com/Xandeum/test_web3/blob/main/src/exists.ts#L23)
11
+ Defined in: [exists.ts:23](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/exists.ts#L23)
12
12
 
13
13
  Sends a JSON-RPC request to the Xandeum RPC endpoint to check if a file or directory exists.
14
14
 
@@ -0,0 +1,44 @@
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
+
3
+ ***
4
+
5
+ [Xandeum Web3 Library](../globals.md) / find
6
+
7
+ # Function: find()
8
+
9
+ > **find**(`connection`, `path`, `query`): `Promise`\<`any`\>
10
+
11
+ Defined in: [find.ts:25](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/find.ts#L25)
12
+
13
+ Sends a JSON-RPC request to the Xandeum RPC endpoint to search for a file or directory
14
+ within a specified path.
15
+
16
+ This function calls the custom RPC method `find`, which is return an array of
17
+ directory entry metadata — names, types etc.
18
+
19
+ ## Parameters
20
+
21
+ ### connection
22
+
23
+ `Connection`
24
+
25
+ The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
26
+
27
+ ### path
28
+
29
+ `string`
30
+
31
+ The filesystem path where the search will be performed (e.g., `/documents`).
32
+
33
+ ### query
34
+
35
+ `string`
36
+
37
+ The query to search for (e.g., `'myfile.txt'`).
38
+
39
+ ## Returns
40
+
41
+ `Promise`\<`any`\>
42
+
43
+ A `Promise<any>` resolving to the parsed JSON response from the RPC server,
44
+ typically including a `result` array containing directory entry objects.
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **getMetadata**(`connection`, `path`): `Promise`\<`any`\>
10
10
 
11
- Defined in: [getMetadata.ts:26](https://github.com/Xandeum/test_web3/blob/main/src/getMetadata.ts#L26)
11
+ Defined in: [getMetadata.ts:26](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/getMetadata.ts#L26)
12
12
 
13
13
  Sends a JSON-RPC request to the Xandeum RPC endpoint to retrieve metadata
14
14
  about a file or directory at the given path.
@@ -0,0 +1,38 @@
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
+
3
+ ***
4
+
5
+ [Xandeum Web3 Library](../globals.md) / getXandeumResult
6
+
7
+ # Function: getXandeumResult()
8
+
9
+ > **getXandeumResult**(`connection`, `signature`): `Promise`\<`any`\>
10
+
11
+ Defined in: [getXandeumResult.ts:21](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/getXandeumResult.ts#L21)
12
+
13
+ Sends a JSON-RPC request to the Xandeum-compatible endpoint to retrieve
14
+ the result of a transaction previously submitted with a specific signature.
15
+
16
+ This function calls the custom RPC method `getXandeumResult`, which returns
17
+ the result associated with the given transaction signature.
18
+
19
+ ## Parameters
20
+
21
+ ### connection
22
+
23
+ `Connection`
24
+
25
+ The Solana web3 connection object pointing to a Xandeum-compatible RPC endpoint.
26
+
27
+ ### signature
28
+
29
+ `string`
30
+
31
+ The transaction signature string whose result should be queried.
32
+
33
+ ## Returns
34
+
35
+ `Promise`\<`any`\>
36
+
37
+ A `Promise<any>` resolving to the parsed JSON response from the RPC server,
38
+ which includes the result of the transaction if available.
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **listDirectoryEntry**(`connection`, `path`): `Promise`\<`any`\>
10
10
 
11
- Defined in: [listDirectoryEntery.ts:24](https://github.com/Xandeum/test_web3/blob/main/src/listDirectoryEntery.ts#L24)
11
+ Defined in: [listDirectoryEntery.ts:24](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/listDirectoryEntery.ts#L24)
12
12
 
13
13
  Sends a JSON-RPC request to the Xandeum RPC endpoint to list all entries (files and subdirectories)
14
14
  within a specified path.
@@ -0,0 +1,55 @@
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
+
3
+ ***
4
+
5
+ [Xandeum Web3 Library](../globals.md) / move
6
+
7
+ # Function: move()
8
+
9
+ > **move**(`fsid`, `srcPath`, `destPath`, `name`, `wallet`): `Promise`\<`Transaction`\>
10
+
11
+ Defined in: [move.ts:19](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/move.ts#L19)
12
+
13
+ Constructs a Solana transaction to copy a file or directory from one path to another.
14
+
15
+ ## Parameters
16
+
17
+ ### fsid
18
+
19
+ `string`
20
+
21
+ The unique numeric identifier representing the target file system.
22
+
23
+ ### srcPath
24
+
25
+ `string`
26
+
27
+ The source path to copy from (e.g., `/documents`).
28
+
29
+ ### destPath
30
+
31
+ `string`
32
+
33
+ The destination path to copy to (e.g., `/archive`).
34
+
35
+ ### name
36
+
37
+ `string`
38
+
39
+ The name of the new file or directory at the destination (e.g., `report.txt`).
40
+
41
+ ### wallet
42
+
43
+ `PublicKey`
44
+
45
+ The wallet public key used to sign and authorize the transaction.
46
+
47
+ ## Returns
48
+
49
+ `Promise`\<`Transaction`\>
50
+
51
+ A Promise that resolves to a Solana `Transaction` object containing the copyPath instruction.
52
+
53
+ ## Throws
54
+
55
+ Will throw an error if `srcPath` or `destPath` contains invalid characters.
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **peek**(`fsid`, `path`, `startPosition`, `endPosition`, `wallet`): `Promise`\<`Transaction`\>
10
10
 
11
- Defined in: [peek.ts:20](https://github.com/Xandeum/test_web3/blob/main/src/peek.ts#L20)
11
+ Defined in: [peek.ts:20](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/peek.ts#L20)
12
12
 
13
13
  Constructs a Solana transaction to perform a "peek" operation on a file within a file system.
14
14
 
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **poke**(`fsid`, `path`, `position`, `wallet`, `dataKey`): `Promise`\<`Transaction`\>
10
10
 
11
- Defined in: [poke.ts:19](https://github.com/Xandeum/test_web3/blob/main/src/poke.ts#L19)
11
+ Defined in: [poke.ts:19](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/poke.ts#L19)
12
12
 
13
13
  Constructs a Solana transaction to perform a poke\operation, which writes data
14
14
  to a file at the specified path and byte position.
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **removeDirectory**(`fsid`, `path`, `wallet`): `Promise`\<`Transaction`\>
10
10
 
11
- Defined in: [removeDirectory.ts:17](https://github.com/Xandeum/test_web3/blob/main/src/removeDirectory.ts#L17)
11
+ Defined in: [removeDirectory.ts:17](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/removeDirectory.ts#L17)
12
12
 
13
13
  Constructs a Solana transaction to perform a "remove directory" operation
14
14
  in a file system, identified by a file system ID (`fsid`).
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **removeFile**(`fsid`, `path`, `wallet`): `Promise`\<`Transaction`\>
10
10
 
11
- Defined in: [removeFile.ts:17](https://github.com/Xandeum/test_web3/blob/main/src/removeFile.ts#L17)
11
+ Defined in: [removeFile.ts:17](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/removeFile.ts#L17)
12
12
 
13
13
  Constructs a Solana transaction to remove a file from a file system,
14
14
  identified by a file system ID (`fsid`) and a UTF-8 encoded file path.
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **renamePath**(`fsid`, `oldPath`, `name`, `wallet`): `Promise`\<`Transaction`\>
10
10
 
11
- Defined in: [renamePath.ts:18](https://github.com/Xandeum/test_web3/blob/main/src/renamePath.ts#L18)
11
+ Defined in: [renamePath.ts:18](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/renamePath.ts#L18)
12
12
 
13
13
  Constructs a Solana transaction to rename (or move) a file or directory
14
14
  within a file system, based on a provided file system ID (`fsid`).
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **subscribeResult**(`connection`, `tx`, `onResult`, `onError?`, `onClose?`): `void`
10
10
 
11
- Defined in: [webSocket.ts:40](https://github.com/Xandeum/test_web3/blob/main/src/webSocket.ts#L40)
11
+ Defined in: [webSocket.ts:40](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/webSocket.ts#L40)
12
12
 
13
13
  Opens a WebSocket connection and subscribes to the result of a transaction
14
14
  via the custom `xandeumResultSubscribe` method.
@@ -1,4 +1,4 @@
1
- [**Xandeum Web3 Library v1.1.0**](../README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **unsubscribeResult**(`connection`, `subscriptionId`): `void`
10
10
 
11
- Defined in: [webSocket.ts:96](https://github.com/Xandeum/test_web3/blob/main/src/webSocket.ts#L96)
11
+ Defined in: [webSocket.ts:103](https://github.com/Xandeum/xandeum-web3.js/blob/reinheim/src/webSocket.ts#L103)
12
12
 
13
13
  Sends a WebSocket JSON-RPC message to unsubscribe from a previously subscribed transaction result
14
14
  using the `xandeumResultUnsubscribed` method (note: custom method, ensure server-side implementation matches).
@@ -1,19 +1,23 @@
1
- [**Xandeum Web3 Library v1.1.0**](README.md)
1
+ [**Xandeum Web3 Library v0.8.1**](README.md)
2
2
 
3
3
  ***
4
4
 
5
- # Xandeum Web3 Library v1.1.0
5
+ # Xandeum Web3 Library v0.8.1
6
6
 
7
7
  ## Functions
8
8
 
9
9
  - [armageddon](functions/armageddon.md)
10
+ - [assignCoowner](functions/assignCoowner.md)
10
11
  - [bigbang](functions/bigbang.md)
11
12
  - [copyPath](functions/copyPath.md)
12
13
  - [createDirectory](functions/createDirectory.md)
13
14
  - [createFile](functions/createFile.md)
14
15
  - [exists](functions/exists.md)
16
+ - [find](functions/find.md)
15
17
  - [getMetadata](functions/getMetadata.md)
18
+ - [getXandeumResult](functions/getXandeumResult.md)
16
19
  - [listDirectoryEntry](functions/listDirectoryEntry.md)
20
+ - [move](functions/move.md)
17
21
  - [peek](functions/peek.md)
18
22
  - [poke](functions/poke.md)
19
23
  - [removeDirectory](functions/removeDirectory.md)
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@xandeum/web3.js",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Xandeum javascript api",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "deploy-docs": "typedoc && gh-pages -d docs"
9
+ "deploy-docs": "typedoc && gh-pages -d docs/html"
10
10
  },
11
11
  "author": "",
12
- "license": "MIT",
12
+ "license": "Apache-2.0",
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
package/src/armageddon.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
3
  import { programId } from './const.js'
4
+ import { getFeeDistributorPda } from './helpers.js'
4
5
 
5
6
  /**
6
7
  * Constructs a Solana transaction that triggers the "armageddon" instruction
@@ -15,9 +16,11 @@ export async function armageddon (
15
16
  wallet: PublicKey
16
17
  ): Promise<Transaction> {
17
18
  const instructionData = Buffer.concat([
19
+ Buffer.from(Int8Array.from([0]).buffer),
18
20
  Buffer.from(Int8Array.from([1]).buffer),
19
21
  Buffer.from(Uint8Array.of(...new BN(fsid).toArray('le', 8)))
20
22
  ])
23
+ let feeDistributorPda = getFeeDistributorPda()
21
24
 
22
25
  const instruction = new TransactionInstruction({
23
26
  keys: [
@@ -25,6 +28,11 @@ export async function armageddon (
25
28
  pubkey: wallet,
26
29
  isSigner: true,
27
30
  isWritable: true
31
+ },
32
+ {
33
+ pubkey: feeDistributorPda.pda,
34
+ isSigner: false,
35
+ isWritable: true
28
36
  }
29
37
  ],
30
38
  programId: new PublicKey(programId),
@@ -0,0 +1,49 @@
1
+ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
+ import { programId } from './const'
3
+ import BN from 'bn.js'
4
+ import { getFeeDistributorPda } from './helpers.js'
5
+
6
+ /**
7
+ * Constructs a Solana transaction to assign a co-owner to a file or directory
8
+ * identified by a file system ID (`fsid`).
9
+ *
10
+ * @param fsid - A stringified integer representing the file system ID where the co-owner is to be assigned.
11
+ * @param path - The path within the file system.
12
+ * @param coowner - The public key of the co-owner to be assigned.
13
+ * @param wallet - The public key of the wallet that will sign and authorize the transaction.
14
+ * @returns A Promise that resolves to a Solana `Transaction` object containing the assignCoowner instruction.
15
+ */
16
+ export async function assignCoowner (
17
+ fsid: string,
18
+ path: string,
19
+ coowner: PublicKey,
20
+ wallet: PublicKey
21
+ ): Promise<Transaction> {
22
+ const rest = Buffer.from(`${path}\0${coowner.toString()}`, 'utf-8')
23
+ const instructionData = Buffer.concat([
24
+ Buffer.from(Int8Array.from([0]).buffer),
25
+ Buffer.from(Int8Array.from([14]).buffer),
26
+ Buffer.from(Uint8Array.of(...new BN(fsid).toArray('le', 8))),
27
+ rest
28
+ ])
29
+ let feeDistributorPda = getFeeDistributorPda()
30
+ const instruction = new TransactionInstruction({
31
+ keys: [
32
+ {
33
+ pubkey: wallet,
34
+ isSigner: true,
35
+ isWritable: true
36
+ },
37
+ {
38
+ pubkey: feeDistributorPda.pda,
39
+ isSigner: false,
40
+ isWritable: true
41
+ }
42
+ ],
43
+ programId: new PublicKey(programId),
44
+ data: instructionData
45
+ })
46
+
47
+ const tx = new Transaction().add(instruction)
48
+ return tx
49
+ }
package/src/bigbang.ts CHANGED
@@ -1,16 +1,22 @@
1
1
  import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
+ import BN from 'bn.js'
2
3
  import { programId } from './const'
4
+ import { getFeeDistributorPda } from './helpers'
3
5
 
4
6
  /**
5
7
  * Constructs a Solana transaction that triggers the "bigbang" instruction and create new file system.
6
8
  *
7
9
  * @param wallet - The public key of the wallet that will sign and authorize the transaction.
10
+ * @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).
8
11
  * @returns A Promise that resolves to a Solana `Transaction` object containing the bigbang instruction.
9
12
  */
10
- export async function bigbang (wallet: PublicKey): Promise<Transaction> {
13
+ export async function bigbang(replica_count:string,wallet: PublicKey): Promise<Transaction> {
11
14
  const instructionData = Buffer.concat([
12
- Buffer.from(Int8Array.from([0]).buffer)
15
+ Buffer.from(Int8Array.from([0]).buffer),
16
+ Buffer.from(Int8Array.from([0]).buffer),
17
+ Buffer.from(Uint8Array.of(...new BN(replica_count).toArray('le', 8)))
13
18
  ])
19
+ let feeDistributorPda = getFeeDistributorPda()
14
20
 
15
21
  const instruction = new TransactionInstruction({
16
22
  keys: [
@@ -18,6 +24,11 @@ export async function bigbang (wallet: PublicKey): Promise<Transaction> {
18
24
  pubkey: wallet,
19
25
  isSigner: true,
20
26
  isWritable: true
27
+ },
28
+ {
29
+ pubkey: feeDistributorPda.pda,
30
+ isSigner: false,
31
+ isWritable: true
21
32
  }
22
33
  ],
23
34
  programId: new PublicKey(programId),
package/src/const.ts CHANGED
@@ -1 +1,3 @@
1
- export const programId="xSHLJPXU8QW3A9kGiRoL94bksJ7ZZPY4dUwJPAT8CVK";
1
+ export const programId="xSHLJPXU8QW3A9kGiRoL94bksJ7ZZPY4dUwJPAT8CVK";
2
+
3
+ export const stoincProgramId="EaLDF7m76kzvrpeADHVHPLfk5qpPaPxYUYqYApByLp1S";
package/src/copyPath.ts CHANGED
@@ -2,6 +2,7 @@ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
3
  import { programId } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
+ import { getFeeDistributorPda } from './helpers.js'
5
6
 
6
7
  /**
7
8
  * Constructs a Solana transaction to copy a file or directory from one path to another.
@@ -29,17 +30,23 @@ export async function copyPath (
29
30
  const rest = Buffer.from(`${srcPath}\0${destPath}`, 'utf-8')
30
31
 
31
32
  const instructionData = Buffer.concat([
33
+ Buffer.from(Int8Array.from([0]).buffer),
32
34
  Buffer.from(Int8Array.from([9]).buffer),
33
35
  Buffer.from(Uint8Array.of(...new BN(fsid).toArray('le', 8))),
34
36
  rest
35
37
  ])
36
-
38
+ let feeDistributorPda = getFeeDistributorPda()
37
39
  const instruction = new TransactionInstruction({
38
40
  keys: [
39
41
  {
40
42
  pubkey: wallet,
41
43
  isSigner: true,
42
44
  isWritable: true
45
+ },
46
+ {
47
+ pubkey: feeDistributorPda.pda,
48
+ isSigner: false,
49
+ isWritable: true
43
50
  }
44
51
  ],
45
52
  programId: new PublicKey(programId),
@@ -2,6 +2,7 @@ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
3
  import { programId } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
+ import { getFeeDistributorPda } from './helpers.js'
5
6
 
6
7
  /**
7
8
  * Constructs a Solana transaction to create a new directory within a file system.
@@ -25,17 +26,23 @@ export async function createDirectory (
25
26
  sanitizePath(combinedPath)
26
27
  const rest = Buffer.from(`${path}\0${name}`, 'utf-8')
27
28
  const instructionData = Buffer.concat([
29
+ Buffer.from(Int8Array.from([0]).buffer),
28
30
  Buffer.from(Int8Array.from([6]).buffer),
29
31
  Buffer.from(Uint8Array.of(...new BN(fsid).toArray('le', 8))),
30
32
  rest
31
33
  ])
32
-
34
+ let feeDistributorPda = getFeeDistributorPda()
33
35
  const instruction = new TransactionInstruction({
34
36
  keys: [
35
37
  {
36
38
  pubkey: wallet,
37
39
  isSigner: true,
38
40
  isWritable: true
41
+ },
42
+ {
43
+ pubkey: feeDistributorPda.pda,
44
+ isSigner: false,
45
+ isWritable: true
39
46
  }
40
47
  ],
41
48
  programId: new PublicKey(programId),
package/src/createFile.ts CHANGED
@@ -2,7 +2,7 @@ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
3
  import { programId } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
-
5
+ import { getFeeDistributorPda } from './helpers.js'
6
6
  /**
7
7
  * Constructs a Solana transaction to create a new file
8
8
  * within a file system, identified by a file system ID (`fsid`).
@@ -25,17 +25,23 @@ export async function createFile (
25
25
 
26
26
  const rest = Buffer.from(`${path}\0${name}`, 'utf-8')
27
27
  const instructionData = Buffer.concat([
28
+ Buffer.from(Int8Array.from([0]).buffer),
28
29
  Buffer.from(Int8Array.from([2]).buffer),
29
30
  Buffer.from(Uint8Array.of(...new BN(fsid).toArray('le', 8))),
30
31
  rest
31
32
  ])
32
-
33
+ let feeDistributorPda = getFeeDistributorPda()
33
34
  const instruction = new TransactionInstruction({
34
35
  keys: [
35
36
  {
36
37
  pubkey: wallet,
37
38
  isSigner: true,
38
39
  isWritable: true
40
+ },
41
+ {
42
+ pubkey: feeDistributorPda.pda,
43
+ isSigner: false,
44
+ isWritable: true
39
45
  }
40
46
  ],
41
47
  programId: new PublicKey(programId),
package/src/exists.ts CHANGED
@@ -38,7 +38,8 @@ export interface RpcRequest {
38
38
  })
39
39
 
40
40
  if (!response.ok) {
41
- throw new Error(`HTTP error! Status: ${response.status}`)
41
+ const errorText = await response.text();
42
+ return Error(`error! status: ${response.status}, message: ${errorText}`);
42
43
  }
43
44
 
44
45
  const data = await response.json()
package/src/find.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { Connection } from "@solana/web3.js"
2
+
3
+ export interface RpcRequest {
4
+ jsonrpc: string
5
+ id: number
6
+ method: string
7
+ params: any[]
8
+ }
9
+
10
+ /**
11
+ * Sends a JSON-RPC request to the Xandeum RPC endpoint to search for a file or directory
12
+ * within a specified path.
13
+ *
14
+ * This function calls the custom RPC method `find`, which is return an array of
15
+ * directory entry metadata — names, types etc.
16
+ *
17
+ * @param connection - The solana web3 connection with Xandeum-compatible JSON-RPC endpoint (e.g., `'https://api.devnet.solana.com'`).
18
+ * @param path - The filesystem path where the search will be performed (e.g., `/documents`).
19
+ * @param query - The query to search for (e.g., `'myfile.txt'`).
20
+ *
21
+ * @returns A `Promise<any>` resolving to the parsed JSON response from the RPC server,
22
+ * typically including a `result` array containing directory entry objects.
23
+ */
24
+
25
+ export async function find (
26
+ connection: Connection,
27
+ path: string,
28
+ query: string,
29
+ ): Promise<any> {
30
+ const url = connection.rpcEndpoint;
31
+ const requestBody: RpcRequest = {
32
+ jsonrpc: '2.0',
33
+ id: 1,
34
+ method: 'find',
35
+ params: [path,query]
36
+ }
37
+
38
+ const response = await fetch(url, {
39
+ method: 'POST',
40
+ headers: {
41
+ 'Content-Type': 'application/json'
42
+ },
43
+ body: JSON.stringify(requestBody)
44
+ })
45
+
46
+ if (!response.ok) {
47
+ const errorText = await response.text();
48
+ return Error(`error! status: ${response.status}, message: ${errorText}`);
49
+ }
50
+
51
+ const data = await response.json()
52
+ return data
53
+ }
@@ -41,7 +41,8 @@ export async function getMetadata (connection: Connection,path: string): Promise
41
41
  })
42
42
 
43
43
  if (!response.ok) {
44
- throw new Error(`HTTP error! Status: ${response.status}`)
44
+ const errorText = await response.text();
45
+ return Error(`error! status: ${response.status}, message: ${errorText}`);
45
46
  }
46
47
 
47
48
  const data = await response.json()