@nosana/kit 1.0.8 → 1.0.9

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.
@@ -17,7 +17,29 @@ export class SolanaService {
17
17
  const addressEncoder = getAddressEncoder();
18
18
  const [pda] = await getProgramDerivedAddress({
19
19
  programAddress: programId,
20
- seeds: seeds.map((seed) => (typeof seed !== 'string' ? addressEncoder.encode(seed) : seed)),
20
+ seeds: seeds.map((seed) => {
21
+ // Address is a branded string type, so typeof will return 'string'
22
+ // We need to encode Address types to bytes for PDA seeds
23
+ // Try to encode if it looks like an address (base58, 32-44 chars), otherwise pass as-is
24
+ if (typeof seed === 'string') {
25
+ // Check if it's likely an address (base58 encoded addresses are 32-44 chars)
26
+ // Short strings like 'ClaimStatus' should be passed as-is
27
+ if (seed.length >= 32 && seed.length <= 44) {
28
+ try {
29
+ // Try to encode as Address - if it's a valid address, this will work
30
+ return addressEncoder.encode(seed);
31
+ }
32
+ catch {
33
+ // If encoding fails, it's not a valid address, pass as-is (e.g., 'ClaimStatus')
34
+ return seed;
35
+ }
36
+ }
37
+ // Short strings pass as-is
38
+ return seed;
39
+ }
40
+ // Non-string types should be encoded
41
+ return addressEncoder.encode(seed);
42
+ }),
21
43
  });
22
44
  return pda;
23
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosana/kit",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Nosana KIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",