@thru/token-program 0.2.1 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thru/token-program",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -13,8 +13,8 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@thru/helpers": "0.2.1",
17
- "@thru/thru-sdk": "0.2.1"
16
+ "@thru/helpers": "0.2.3",
17
+ "@thru/thru-sdk": "0.2.3"
18
18
  },
19
19
  "devDependencies": {
20
20
  "tsup": "^8.5.0",
package/src/derivation.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { deriveAddress, deriveProgramAddress, Pubkey } from '@thru/thru-sdk';
1
+ import { Pubkey } from '@thru/thru-sdk';
2
+ import type { Thru } from '@thru/thru-sdk/client';
2
3
  import { PUBKEY_LENGTH } from './constants';
3
4
 
4
5
  const TOKEN_ACCOUNT_DEFAULT_SEED = new Uint8Array(PUBKEY_LENGTH);
5
6
 
6
7
  export function deriveMintAddress(
8
+ thru: Thru,
7
9
  mintAuthorityAddress: string,
8
10
  seed: string,
9
11
  tokenProgramAddress: string
@@ -12,9 +14,9 @@ export function deriveMintAddress(
12
14
  const seedBytes = hexToBytes(seed);
13
15
  if (seedBytes.length !== 32) throw new Error('Seed must be 32 bytes (64 hex characters)');
14
16
 
15
- const { bytes: derivedSeed } = deriveAddress([mintAuthorityBytes, seedBytes]);
17
+ const { bytes: derivedSeed } = thru.helpers.deriveAddress([mintAuthorityBytes, seedBytes]);
16
18
 
17
- const result = deriveProgramAddress({
19
+ const result = thru.helpers.deriveProgramAddress({
18
20
  programAddress: tokenProgramAddress,
19
21
  seed: derivedSeed,
20
22
  ephemeral: false,
@@ -28,6 +30,7 @@ export function deriveMintAddress(
28
30
  }
29
31
 
30
32
  export function deriveTokenAccountAddress(
33
+ thru: Thru,
31
34
  ownerAddress: string,
32
35
  mintAddress: string,
33
36
  tokenProgramAddress: string,
@@ -38,9 +41,9 @@ export function deriveTokenAccountAddress(
38
41
  const ownerBytes = Pubkey.from(ownerAddress).toBytes();
39
42
  const mintBytes = Pubkey.from(mintAddress).toBytes();
40
43
 
41
- const { bytes: derivedSeed } = deriveAddress([ownerBytes, mintBytes, seed]);
44
+ const { bytes: derivedSeed } = thru.helpers.deriveAddress([ownerBytes, mintBytes, seed]);
42
45
 
43
- const result = deriveProgramAddress({
46
+ const result = thru.helpers.deriveProgramAddress({
44
47
  programAddress: tokenProgramAddress,
45
48
  seed: derivedSeed,
46
49
  ephemeral: false,
@@ -54,11 +57,12 @@ export function deriveTokenAccountAddress(
54
57
  }
55
58
 
56
59
  export function deriveWalletSeed(
60
+ thru: Thru,
57
61
  walletAddress: string,
58
62
  extraSeeds: Uint8Array[] = []
59
63
  ): Uint8Array {
60
64
  const walletBytes = Pubkey.from(walletAddress).toBytes();
61
- return deriveAddress([walletBytes, ...extraSeeds]).bytes;
65
+ return thru.helpers.deriveAddress([walletBytes, ...extraSeeds]).bytes;
62
66
  }
63
67
 
64
68
  function hexToBytes(hex: string): Uint8Array {