@xandeum/web3.js 1.3.6 → 1.3.8

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/src/peek.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Transaction, TransactionInstruction, PublicKey, SystemProgram } from '@solana/web3.js'
1
+ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
- import { programId } from './const'
3
+ import { programId, TOKEN_PROGRAM_ID } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
- import { getFeeDistributorPda } from './helpers'
5
+ import { getFeeDistributorPda, getAssociatedTokenAddressWithProgramIds, buildInstructionData } from './helpers'
6
6
 
7
7
  /**
8
8
  * Constructs a Solana transaction to perform a "peek" operation on a file within a file system.
@@ -38,16 +38,11 @@ export async function peek (
38
38
  rest
39
39
  ])
40
40
 
41
- // wrap_storage_tx: [0u8, inner_data.len() as u32 LE, inner_data]
42
- const innerLen = Buffer.alloc(4)
43
- innerLen.writeUInt32LE(innerData.length)
44
-
45
- const instructionData = Buffer.concat([
46
- Buffer.from([0]),
47
- innerLen,
48
- innerData
49
- ])
41
+ const instructionData = buildInstructionData(innerData)
50
42
  let feeDistributorPda = getFeeDistributorPda()
43
+ const payerAta = getAssociatedTokenAddressWithProgramIds(wallet)
44
+ const feeAta = getAssociatedTokenAddressWithProgramIds(feeDistributorPda.pda)
45
+
51
46
  const instruction = new TransactionInstruction({
52
47
  keys: [
53
48
  {
@@ -61,7 +56,17 @@ export async function peek (
61
56
  isWritable: true
62
57
  },
63
58
  {
64
- pubkey: SystemProgram.programId,
59
+ pubkey: payerAta.ata,
60
+ isSigner: false,
61
+ isWritable: true
62
+ },
63
+ {
64
+ pubkey: feeAta.ata,
65
+ isSigner: false,
66
+ isWritable: true
67
+ },
68
+ {
69
+ pubkey: TOKEN_PROGRAM_ID,
65
70
  isSigner: false,
66
71
  isWritable: false
67
72
  }
package/src/poke.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { Transaction, TransactionInstruction, PublicKey, SystemProgram } from '@solana/web3.js'
1
+ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
- import { programId } from './const'
3
+ import { programId, TOKEN_PROGRAM_ID } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
- import { getFeeDistributorPda } from './helpers'
5
+ import { getFeeDistributorPda, getAssociatedTokenAddressWithProgramIds, buildInstructionData } from './helpers'
6
6
 
7
7
  /**
8
- * Constructs a Solana transaction to perform a poke\operation, which writes data
8
+ * Constructs a Solana transaction to perform a poke operation, which writes data
9
9
  * to a file at the specified path and byte position.
10
10
  *
11
11
  * @param fsid - A stringified integer representing the file system ID where the file resides.
@@ -40,16 +40,11 @@ export async function poke (
40
40
  pathBuffer
41
41
  ])
42
42
 
43
- // wrap_storage_tx: [0u8, inner_data.len() as u32 LE, inner_data]
44
- const innerLen = Buffer.alloc(4)
45
- innerLen.writeUInt32LE(innerData.length)
46
-
47
- const instructionData = Buffer.concat([
48
- Buffer.from([0]),
49
- innerLen,
50
- innerData
51
- ])
43
+ const instructionData = buildInstructionData(innerData)
52
44
  let feeDistributorPda = getFeeDistributorPda()
45
+ const payerAta = getAssociatedTokenAddressWithProgramIds(wallet)
46
+ const feeAta = getAssociatedTokenAddressWithProgramIds(feeDistributorPda.pda)
47
+
53
48
  const instruction = new TransactionInstruction({
54
49
  keys: [
55
50
  {
@@ -68,7 +63,17 @@ export async function poke (
68
63
  isWritable: true
69
64
  },
70
65
  {
71
- pubkey: SystemProgram.programId,
66
+ pubkey: payerAta.ata,
67
+ isSigner: false,
68
+ isWritable: true
69
+ },
70
+ {
71
+ pubkey: feeAta.ata,
72
+ isSigner: false,
73
+ isWritable: true
74
+ },
75
+ {
76
+ pubkey: TOKEN_PROGRAM_ID,
72
77
  isSigner: false,
73
78
  isWritable: false
74
79
  }
@@ -1,8 +1,9 @@
1
- import { Transaction, TransactionInstruction, PublicKey, SystemProgram } from '@solana/web3.js'
1
+ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
- import { programId } from './const'
3
+ import { programId, TOKEN_PROGRAM_ID } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
- import { getFeeDistributorPda } from './helpers'
5
+ import { getFeeDistributorPda, getAssociatedTokenAddressWithProgramIds, buildInstructionData } from './helpers'
6
+
6
7
  /**
7
8
  * Constructs a Solana transaction to perform a "remove directory" operation
8
9
  * in a file system, identified by a file system ID (`fsid`).
@@ -27,16 +28,11 @@ export async function removeDirectory (
27
28
  Buffer.from(`${path}`, 'utf-8')
28
29
  ])
29
30
 
30
- // wrap_storage_tx: [0u8, inner_data.len() as u32 LE, inner_data]
31
- const innerLen = Buffer.alloc(4)
32
- innerLen.writeUInt32LE(innerData.length)
33
-
34
- const instructionData = Buffer.concat([
35
- Buffer.from([0]),
36
- innerLen,
37
- innerData
38
- ])
31
+ const instructionData = buildInstructionData(innerData)
39
32
  let feeDistributorPda = getFeeDistributorPda()
33
+ const payerAta = getAssociatedTokenAddressWithProgramIds(wallet)
34
+ const feeAta = getAssociatedTokenAddressWithProgramIds(feeDistributorPda.pda)
35
+
40
36
  const instruction = new TransactionInstruction({
41
37
  keys: [
42
38
  {
@@ -50,7 +46,17 @@ export async function removeDirectory (
50
46
  isWritable: true
51
47
  },
52
48
  {
53
- pubkey: SystemProgram.programId,
49
+ pubkey: payerAta.ata,
50
+ isSigner: false,
51
+ isWritable: true
52
+ },
53
+ {
54
+ pubkey: feeAta.ata,
55
+ isSigner: false,
56
+ isWritable: true
57
+ },
58
+ {
59
+ pubkey: TOKEN_PROGRAM_ID,
54
60
  isSigner: false,
55
61
  isWritable: false
56
62
  }
package/src/removeFile.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Transaction, TransactionInstruction, PublicKey, SystemProgram } from '@solana/web3.js'
1
+ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
- import { programId } from './const'
3
+ import { programId, TOKEN_PROGRAM_ID } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
- import { getFeeDistributorPda } from './helpers'
5
+ import { getFeeDistributorPda, getAssociatedTokenAddressWithProgramIds, buildInstructionData } from './helpers'
6
+
6
7
  /**
7
8
  * Constructs a Solana transaction to remove a file from a file system,
8
9
  * identified by a file system ID (`fsid`) and a UTF-8 encoded file path.
@@ -28,16 +29,11 @@ export async function removeFile (
28
29
  Buffer.from(`${path}`, 'utf-8')
29
30
  ])
30
31
 
31
- // wrap_storage_tx: [0u8, inner_data.len() as u32 LE, inner_data]
32
- const innerLen = Buffer.alloc(4)
33
- innerLen.writeUInt32LE(innerData.length)
34
-
35
- const instructionData = Buffer.concat([
36
- Buffer.from([0]),
37
- innerLen,
38
- innerData
39
- ])
32
+ const instructionData = buildInstructionData(innerData)
40
33
  let feeDistributorPda = getFeeDistributorPda()
34
+ const payerAta = getAssociatedTokenAddressWithProgramIds(wallet)
35
+ const feeAta = getAssociatedTokenAddressWithProgramIds(feeDistributorPda.pda)
36
+
41
37
  const instruction = new TransactionInstruction({
42
38
  keys: [
43
39
  {
@@ -51,7 +47,17 @@ export async function removeFile (
51
47
  isWritable: true
52
48
  },
53
49
  {
54
- pubkey: SystemProgram.programId,
50
+ pubkey: payerAta.ata,
51
+ isSigner: false,
52
+ isWritable: true
53
+ },
54
+ {
55
+ pubkey: feeAta.ata,
56
+ isSigner: false,
57
+ isWritable: true
58
+ },
59
+ {
60
+ pubkey: TOKEN_PROGRAM_ID,
55
61
  isSigner: false,
56
62
  isWritable: false
57
63
  }
package/src/renamePath.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Transaction, TransactionInstruction, PublicKey, SystemProgram } from '@solana/web3.js'
1
+ import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'
2
2
  import BN from 'bn.js'
3
- import { programId } from './const'
3
+ import { programId, TOKEN_PROGRAM_ID } from './const'
4
4
  import { sanitizePath } from './sanitizePath'
5
- import { getFeeDistributorPda } from './helpers'
5
+ import { getFeeDistributorPda, getAssociatedTokenAddressWithProgramIds, buildInstructionData } from './helpers'
6
+
6
7
  /**
7
8
  * Constructs a Solana transaction to rename (or move) a file or directory
8
9
  * within a file system, based on a provided file system ID (`fsid`).
@@ -34,16 +35,11 @@ export async function renamePath (
34
35
  rest
35
36
  ])
36
37
 
37
- // wrap_storage_tx: [0u8, inner_data.len() as u32 LE, inner_data]
38
- const innerLen = Buffer.alloc(4)
39
- innerLen.writeUInt32LE(innerData.length)
40
-
41
- const instructionData = Buffer.concat([
42
- Buffer.from([0]),
43
- innerLen,
44
- innerData
45
- ])
38
+ const instructionData = buildInstructionData(innerData)
46
39
  let feeDistributorPda = getFeeDistributorPda()
40
+ const payerAta = getAssociatedTokenAddressWithProgramIds(wallet)
41
+ const feeAta = getAssociatedTokenAddressWithProgramIds(feeDistributorPda.pda)
42
+
47
43
  const instruction = new TransactionInstruction({
48
44
  keys: [
49
45
  {
@@ -57,7 +53,17 @@ export async function renamePath (
57
53
  isWritable: true
58
54
  },
59
55
  {
60
- pubkey: SystemProgram.programId,
56
+ pubkey: payerAta.ata,
57
+ isSigner: false,
58
+ isWritable: true
59
+ },
60
+ {
61
+ pubkey: feeAta.ata,
62
+ isSigner: false,
63
+ isWritable: true
64
+ },
65
+ {
66
+ pubkey: TOKEN_PROGRAM_ID,
61
67
  isSigner: false,
62
68
  isWritable: false
63
69
  }