@fogo/sessions-sdk 0.1.8 → 0.1.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.
package/esm/index.js CHANGED
@@ -3,17 +3,18 @@ import { DomainRegistryIdl, IntentTransferIdl, IntentTransferProgram, SessionMan
3
3
  import { findMetadataPda, safeFetchMetadata, } from "@metaplex-foundation/mpl-token-metadata";
4
4
  import { publicKey as metaplexPublicKey } from "@metaplex-foundation/umi";
5
5
  import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
6
- import { sha256 } from "@noble/hashes/sha2";
6
+ import { sha256 } from "@noble/hashes/sha2.js";
7
7
  import { fromLegacyPublicKey } from "@solana/compat";
8
8
  import { generateKeyPair, getAddressFromPublicKey, getProgramDerivedAddress, } from "@solana/kit";
9
9
  import { getAssociatedTokenAddressSync, getMint } from "@solana/spl-token";
10
10
  import { ComputeBudgetProgram, Ed25519Program, Keypair, PublicKey, } from "@solana/web3.js";
11
- import { routes, Wormhole, wormhole } from "@wormhole-foundation/sdk";
11
+ import { Wormhole, wormhole } from "@wormhole-foundation/sdk";
12
12
  import solanaSdk from "@wormhole-foundation/sdk/solana";
13
13
  import { contracts } from "@wormhole-foundation/sdk-base";
14
+ import * as routes from "@wormhole-foundation/sdk-connect/routes";
14
15
  import { nttExecutorRoute } from "@wormhole-foundation/sdk-route-ntt";
15
16
  import { utils } from "@wormhole-foundation/sdk-solana-core";
16
- import { NTT } from "@wormhole-foundation/sdk-solana-ntt";
17
+ import { NTT, register as registerNtt, } from "@wormhole-foundation/sdk-solana-ntt";
17
18
  import BN from "bn.js";
18
19
  import bs58 from "bs58";
19
20
  import { z } from "zod";
@@ -23,6 +24,7 @@ import { importKey, signMessageWithKey, verifyMessageWithKey, } from "./crypto.j
23
24
  import { createSessionUnwrapInstruction, createSessionWrapInstructions, createSystemProgramSessionWrapInstruction, } from "./instructions.js";
24
25
  import { USDC_DECIMALS, USDC_MINT } from "./mints.js";
25
26
  import { Network } from "./network.js";
27
+ registerNtt();
26
28
  export { createSessionConnection, TransactionResultType, } from "./connection.js";
27
29
  export { createSessionContext, } from "./context.js";
28
30
  export { createPaymasterFeeInstruction, createSessionUnwrapInstruction, createSessionWrapInstructions, createSystemProgramSessionWrapInstruction, } from "./instructions.js";
@@ -67,9 +69,9 @@ export const establishSession = async (options) => {
67
69
  };
68
70
  const sendSessionEstablishTransaction = async (options, sessionKey, instructions, sessionEstablishmentLookupTable) => {
69
71
  const result = await options.context.sendTransaction(sessionKey, instructions, options.walletPublicKey, {
70
- variation: "Session Establishment",
71
72
  addressLookupTable: sessionEstablishmentLookupTable ??
72
73
  SESSION_ESTABLISHMENT_LOOKUP_TABLE_ADDRESS[options.context.network],
74
+ variation: "Session Establishment",
73
75
  });
74
76
  switch (result.type) {
75
77
  case TransactionResultType.Success: {
@@ -92,8 +94,8 @@ export const revokeSession = async (options) => {
92
94
  const instruction = await new SessionManagerProgram(new AnchorProvider(options.context.connection, {}, {})).methods
93
95
  .revokeSession()
94
96
  .accounts({
95
- sponsor: options.session.sessionInfo.sponsor,
96
97
  session: options.session.sessionPublicKey,
98
+ sponsor: options.session.sessionInfo.sponsor,
97
99
  })
98
100
  .instruction();
99
101
  return options.context.sendTransaction(options.session.sessionKey, [instruction], options.session.walletPublicKey, {
@@ -143,17 +145,17 @@ const createSession = async (context, walletPublicKey, sessionKey) => {
143
145
  !authorizedProgramsMatchDomainRegistry(sessionInfo.authorizedPrograms, domainRegistryAuthorizedPrograms)
144
146
  ? undefined
145
147
  : {
146
- sessionPublicKey,
147
- walletPublicKey,
148
- sessionKey,
149
- payer: context.payer,
150
- getSystemProgramSessionWrapInstruction: (amount) => createSystemProgramSessionWrapInstruction(sessionPublicKey, walletPublicKey, amount),
151
- getSessionWrapInstructions: (amount) => createSessionWrapInstructions(sessionPublicKey, walletPublicKey, amount),
152
148
  getSessionUnwrapInstructions: () => [
153
149
  createSessionUnwrapInstruction(sessionPublicKey, walletPublicKey),
154
150
  ],
151
+ getSessionWrapInstructions: (amount) => createSessionWrapInstructions(sessionPublicKey, walletPublicKey, amount),
152
+ getSystemProgramSessionWrapInstruction: (amount) => createSystemProgramSessionWrapInstruction(sessionPublicKey, walletPublicKey, amount),
153
+ payer: context.payer,
155
154
  sendTransaction: (instructions, extraConfig) => context.sendTransaction(sessionKey, instructions, walletPublicKey, extraConfig),
156
155
  sessionInfo,
156
+ sessionKey,
157
+ sessionPublicKey,
158
+ walletPublicKey,
157
159
  };
158
160
  };
159
161
  const authorizedTokensSchema = z.union([
@@ -165,9 +167,9 @@ const authorizedTokensSchema = z.union([
165
167
  z.object({ All: z.object({}) }),
166
168
  ]);
167
169
  const revokedSessionInfoSchema = z.object({
168
- user: z.instanceof(PublicKey),
169
- expiration: z.instanceof(BN),
170
170
  authorized_tokens_with_mints: authorizedTokensSchema,
171
+ expiration: z.instanceof(BN),
172
+ user: z.instanceof(PublicKey),
171
173
  });
172
174
  const activeSessionInfoSchema = z.object({
173
175
  authorized_programs: z.union([
@@ -199,6 +201,7 @@ const activeSessionInfoSchema = z.object({
199
201
  });
200
202
  const sessionInfoSchema = z
201
203
  .object({
204
+ major: z.number(),
202
205
  session_info: z.union([
203
206
  z.object({
204
207
  V1: z.object({
@@ -292,8 +295,8 @@ const sessionInfoSchema = z
292
295
  z.object({
293
296
  Active: z.object({
294
297
  "0": z.object({
295
- domain_hash: z.array(z.number()).length(32),
296
298
  active_session_info: activeSessionInfoSchema,
299
+ domain_hash: z.array(z.number()).length(32),
297
300
  }),
298
301
  }),
299
302
  }),
@@ -301,7 +304,6 @@ const sessionInfoSchema = z
301
304
  }),
302
305
  }),
303
306
  ]),
304
- major: z.number(),
305
307
  sponsor: z.instanceof(PublicKey),
306
308
  })
307
309
  .transform(({ session_info, major, sponsor }) => {
@@ -340,8 +342,8 @@ const sessionInfoSchema = z
340
342
  extra: activeSessionInfo.extra[0],
341
343
  major: major,
342
344
  minor: minor,
343
- user: activeSessionInfo.user,
344
345
  sponsor,
346
+ user: activeSessionInfo.user,
345
347
  };
346
348
  });
347
349
  export var AuthorizedProgramsType;
@@ -352,8 +354,8 @@ export var AuthorizedProgramsType;
352
354
  const AuthorizedPrograms = {
353
355
  All: () => ({ type: AuthorizedProgramsType.All }),
354
356
  Specific: (programs) => ({
355
- type: AuthorizedProgramsType.Specific,
356
357
  programs,
358
+ type: AuthorizedProgramsType.Specific,
357
359
  }),
358
360
  };
359
361
  export var AuthorizedTokens;
@@ -367,13 +369,13 @@ var SymbolOrMintType;
367
369
  SymbolOrMintType[SymbolOrMintType["Mint"] = 1] = "Mint";
368
370
  })(SymbolOrMintType || (SymbolOrMintType = {}));
369
371
  const SymbolOrMint = {
370
- Symbol: (symbol) => ({
371
- type: SymbolOrMintType.Symbol,
372
- symbol,
373
- }),
374
372
  Mint: (mint) => ({
375
- type: SymbolOrMintType.Mint,
376
373
  mint,
374
+ type: SymbolOrMintType.Mint,
375
+ }),
376
+ Symbol: (symbol) => ({
377
+ symbol,
378
+ type: SymbolOrMintType.Symbol,
377
379
  }),
378
380
  };
379
381
  const getTokenInfo = (context, limits) => {
@@ -386,17 +388,19 @@ const getTokenInfo = (context, limits) => {
386
388
  safeFetchMetadata(umi, metadataAddress),
387
389
  ]);
388
390
  return {
391
+ amount,
392
+ decimals: mintInfo.decimals,
393
+ metadataAddress: new PublicKey(metadataAddress),
394
+ mint,
389
395
  symbolOrMint: metadata?.symbol
390
396
  ? SymbolOrMint.Symbol(metadata.symbol)
391
397
  : SymbolOrMint.Mint(mint),
392
- metadataAddress: new PublicKey(metadataAddress),
393
- amount,
394
- mint,
395
- decimals: mintInfo.decimals,
396
398
  };
397
399
  }));
398
400
  };
399
- const buildStartSessionIntentInstruction = async (options, sessionKey, tokens) => buildIntentInstruction(options, MESSAGE_HEADER, {
401
+ const buildStartSessionIntentInstruction = async (options, sessionKey, tokens) => buildIntentInstruction(options, MESSAGE_HEADER,
402
+ // biome-ignore assist/source/useSortedKeys: The sort order is important here
403
+ {
400
404
  version: `${CURRENT_MAJOR}.${CURRENT_MINOR}`,
401
405
  chain_id: options.context.chainId,
402
406
  domain: options.context.domain,
@@ -408,9 +412,9 @@ const buildIntentInstruction = async (options, header, body, extra) => {
408
412
  const message = new TextEncoder().encode([header, serializeKV(body), extra && serializeExtra(extra)].join("\n"));
409
413
  const { signature, signedMessage } = await options.signMessage(message);
410
414
  return Ed25519Program.createInstructionWithPublicKey({
415
+ message: signedMessage,
411
416
  publicKey: options.walletPublicKey.toBytes(),
412
417
  signature,
413
- message: signedMessage,
414
418
  });
415
419
  };
416
420
  const serializeExtra = (extra) => {
@@ -454,7 +458,7 @@ const amountToString = (amount, decimals) => {
454
458
  ].join("");
455
459
  };
456
460
  export const getDomainRecordAddress = (domain) => {
457
- const hash = sha256(domain);
461
+ const hash = sha256(new TextEncoder().encode(domain));
458
462
  return PublicKey.findProgramAddressSync([Buffer.from("domain-record"), hash], new PublicKey(DomainRegistryIdl.address))[0];
459
463
  };
460
464
  const BRIDGING_ADDRESS_LOOKUP_TABLE = {
@@ -471,30 +475,30 @@ const buildStartSessionInstruction = async (options, sessionKey, tokens) => {
471
475
  const instruction = new SessionManagerProgram(new AnchorProvider(options.context.connection, {}, {})).methods
472
476
  .startSession()
473
477
  .accounts({
474
- sponsor: options.context.payer,
475
- session: await getAddressFromPublicKey(sessionKey.publicKey),
476
478
  domainRegistry: getDomainRecordAddress(options.context.domain),
479
+ session: await getAddressFromPublicKey(sessionKey.publicKey),
480
+ sponsor: options.context.payer,
477
481
  });
478
482
  return tokens === undefined
479
483
  ? instruction.instruction()
480
484
  : instruction
481
485
  .remainingAccounts(tokens.flatMap(({ symbolOrMint, mint, metadataAddress }) => [
482
486
  {
483
- pubkey: getAssociatedTokenAddressSync(mint, options.walletPublicKey),
484
- isWritable: true,
485
487
  isSigner: false,
488
+ isWritable: true,
489
+ pubkey: getAssociatedTokenAddressSync(mint, options.walletPublicKey),
486
490
  },
487
491
  {
488
- pubkey: mint,
489
- isWritable: false,
490
492
  isSigner: false,
493
+ isWritable: false,
494
+ pubkey: mint,
491
495
  },
492
496
  ...(symbolOrMint.type === SymbolOrMintType.Symbol
493
497
  ? [
494
498
  {
495
- pubkey: metadataAddress,
496
- isWritable: false,
497
499
  isSigner: false,
500
+ isWritable: false,
501
+ pubkey: metadataAddress,
498
502
  },
499
503
  ]
500
504
  : []),
@@ -507,15 +511,15 @@ export var SessionResultType;
507
511
  SessionResultType[SessionResultType["Failed"] = 1] = "Failed";
508
512
  })(SessionResultType || (SessionResultType = {}));
509
513
  const EstablishSessionResult = {
510
- Success: (signature, session) => ({
511
- type: SessionResultType.Success,
512
- signature,
513
- session,
514
- }),
515
514
  Failed: (signature, error) => ({
515
+ error,
516
+ signature,
516
517
  type: SessionResultType.Failed,
518
+ }),
519
+ Success: (signature, session) => ({
520
+ session,
517
521
  signature,
518
- error,
522
+ type: SessionResultType.Success,
519
523
  }),
520
524
  };
521
525
  export const getTransferFee = async (context) => {
@@ -540,16 +544,16 @@ const getFee = async (context) => {
540
544
  const [feeConfigPda] = PublicKey.findProgramAddressSync([Buffer.from("fee_config"), usdcMint.toBytes()], program.programId);
541
545
  const feeConfig = await program.account.feeConfig.fetch(feeConfigPda);
542
546
  return {
547
+ decimals: USDC_DECIMALS,
548
+ fee: {
549
+ bridgeTransfer: BigInt(feeConfig.bridgeTransferFee.toString()),
550
+ intrachainTransfer: BigInt(feeConfig.intrachainTransferFee.toString()),
551
+ },
543
552
  metadata: findMetadataPda(umi, {
544
553
  mint: metaplexPublicKey(usdcMintAddress),
545
554
  })[0],
546
555
  mint: usdcMint,
547
556
  symbolOrMint: "USDC.s",
548
- decimals: USDC_DECIMALS,
549
- fee: {
550
- intrachainTransfer: BigInt(feeConfig.intrachainTransferFee.toString()),
551
- bridgeTransfer: BigInt(feeConfig.bridgeTransferFee.toString()),
552
- },
553
557
  };
554
558
  };
555
559
  const TRANSFER_MESSAGE_HEADER = `Fogo Transfer:
@@ -572,17 +576,17 @@ export const sendTransfer = async (options) => {
572
576
  feeMetadata: options.feeConfig.metadata,
573
577
  feeMint: options.feeConfig.mint,
574
578
  feeSource: getAssociatedTokenAddressSync(options.feeConfig.mint, options.walletPublicKey),
575
- mint: options.mint,
576
- source: sourceAta,
577
- sponsor: options.context.internalPayer,
578
579
  metadata:
579
580
  // eslint-disable-next-line unicorn/no-null
580
581
  symbol === undefined ? null : new PublicKey(metadataAddress),
582
+ mint: options.mint,
583
+ source: sourceAta,
584
+ sponsor: options.context.internalPayer,
581
585
  })
582
586
  .instruction(),
583
587
  ], options.walletPublicKey, {
584
- variation: "Intent Transfer",
585
588
  paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
589
+ variation: "Intent Transfer",
586
590
  });
587
591
  };
588
592
  const buildTransferIntentInstruction = async (program, options, symbol, feeToken, feeAmount) => {
@@ -590,7 +594,9 @@ const buildTransferIntentInstruction = async (program, options, symbol, feeToken
590
594
  getNonce(program, options.walletPublicKey, NonceType.Transfer),
591
595
  getMint(options.context.connection, options.mint),
592
596
  ]);
593
- return buildIntentInstruction(options, TRANSFER_MESSAGE_HEADER, {
597
+ return buildIntentInstruction(options, TRANSFER_MESSAGE_HEADER,
598
+ // biome-ignore assist/source/useSortedKeys: The sort order is important here
599
+ {
594
600
  version: `${CURRENT_INTENT_TRANSFER_MAJOR}.${CURRENT_INTENT_TRANSFER_MINOR}`,
595
601
  chain_id: options.context.chainId,
596
602
  token: symbol ?? options.mint.toBase58(),
@@ -608,24 +614,26 @@ export const sendNativeTransfer = async (options) => {
608
614
  await program.methods
609
615
  .sendNative()
610
616
  .accounts({
617
+ destination: options.recipient,
618
+ feeDestination: IntentTransferIdl.address,
611
619
  feeMetadata: options.feeConfig.metadata,
612
620
  feeMint: options.feeConfig.mint,
613
621
  feeSource: getAssociatedTokenAddressSync(options.feeConfig.mint, options.walletPublicKey),
614
- feeDestination: IntentTransferIdl.address,
615
622
  source: options.walletPublicKey,
616
- destination: options.recipient,
617
623
  sponsor: options.context.internalPayer,
618
624
  })
619
625
  .instruction(),
620
626
  ], options.walletPublicKey, {
621
- variation: "Intent Transfer",
622
627
  paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
628
+ variation: "Intent Transfer",
623
629
  });
624
630
  };
625
631
  const FOGO_DECIMALS = 9;
626
632
  const buildNativeTransferIntentInstruction = async (program, options, feeToken, feeAmount) => {
627
633
  const nonce = await getNonce(program, options.walletPublicKey, NonceType.Transfer);
628
- return buildIntentInstruction(options, TRANSFER_MESSAGE_HEADER, {
634
+ return buildIntentInstruction(options, TRANSFER_MESSAGE_HEADER,
635
+ // biome-ignore assist/source/useSortedKeys: The sort order is important here
636
+ {
629
637
  version: `${CURRENT_INTENT_TRANSFER_MAJOR}.${CURRENT_INTENT_TRANSFER_MINOR}`,
630
638
  chain_id: options.context.chainId,
631
639
  token: "FOGO",
@@ -663,17 +671,17 @@ export const bridgeOut = async (options) => {
663
671
  signedQuoteBytes: [...quote.signedQuote],
664
672
  })
665
673
  .accounts({
666
- sponsor: options.context.internalPayer,
667
- mint: options.fromToken.mint,
674
+ feeMetadata: options.feeConfig.metadata,
675
+ feeMint: options.feeConfig.mint,
676
+ feeSource: getAssociatedTokenAddressSync(options.feeConfig.mint, options.walletPublicKey),
668
677
  metadata: metadata?.symbol === undefined
669
678
  ? // eslint-disable-next-line unicorn/no-null
670
679
  null
671
680
  : new PublicKey(metadataAddress),
672
- source: getAssociatedTokenAddressSync(options.fromToken.mint, options.walletPublicKey),
681
+ mint: options.fromToken.mint,
673
682
  ntt: nttPdas,
674
- feeMetadata: options.feeConfig.metadata,
675
- feeMint: options.feeConfig.mint,
676
- feeSource: getAssociatedTokenAddressSync(options.feeConfig.mint, options.walletPublicKey),
683
+ source: getAssociatedTokenAddressSync(options.fromToken.mint, options.walletPublicKey),
684
+ sponsor: options.context.internalPayer,
677
685
  })
678
686
  .instruction(),
679
687
  ]);
@@ -681,10 +689,10 @@ export const bridgeOut = async (options) => {
681
689
  ComputeBudgetProgram.setComputeUnitLimit({ units: BRIDGE_OUT_CUS }),
682
690
  ...instructions,
683
691
  ], options.walletPublicKey, {
684
- variation: "Intent NTT Bridge",
685
- paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
686
- extraSigners: [outboxItem],
687
692
  addressLookupTable: BRIDGING_ADDRESS_LOOKUP_TABLE[options.context.network]?.[options.fromToken.mint.toBase58()],
693
+ extraSigners: [outboxItem],
694
+ paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
695
+ variation: "Intent NTT Bridge",
688
696
  });
689
697
  };
690
698
  const getDestinationAtaExists = async (context, token, wallet) => {
@@ -726,16 +734,18 @@ const getNttPdas = async (options, wh, program, outboxItemPublicKey, quotePayeeA
726
734
  nttTokenAuthority: pdas.tokenAuthority(),
727
735
  payeeNttWithExecutor: quotePayeeAddress,
728
736
  transceiver: registeredTransceiverPda,
729
- wormholeProgram: coreBridgeContract,
730
737
  wormholeBridge: wormholePdas.wormholeBridge,
731
738
  wormholeFeeCollector: wormholePdas.wormholeFeeCollector,
732
739
  wormholeMessage: transceiverPdas.wormholeMessageAccount(outboxItemPublicKey),
740
+ wormholeProgram: coreBridgeContract,
733
741
  wormholeSequence: wormholePdas.wormholeSequence,
734
742
  };
735
743
  };
736
744
  const buildBridgeOutIntent = async (program, options, decimals, symbol, feeToken, feeAmount) => {
737
745
  const nonce = await getNonce(program, options.walletPublicKey, NonceType.Bridge);
738
- return buildIntentInstruction(options, BRIDGE_OUT_MESSAGE_HEADER, {
746
+ return buildIntentInstruction(options, BRIDGE_OUT_MESSAGE_HEADER,
747
+ // biome-ignore assist/source/useSortedKeys: The sort order is important here
748
+ {
739
749
  version: `${CURRENT_BRIDGE_OUT_MAJOR}.${CURRENT_BRIDGE_OUT_MINOR}`,
740
750
  from_chain_id: options.context.chainId,
741
751
  to_chain_id: "solana",
@@ -813,9 +823,9 @@ const buildWormholeTransfer = async (options, connection) => {
813
823
  });
814
824
  const route = new Route(wh);
815
825
  const transferRequest = await routes.RouteTransferRequest.create(wh, {
826
+ destination: Wormhole.tokenId(options.toToken.chain, options.toToken.mint.toBase58()),
816
827
  recipient: Wormhole.chainAddress(options.toToken.chain, options.walletPublicKey.toBase58()),
817
828
  source: Wormhole.tokenId(options.fromToken.chain, options.fromToken.mint.toBase58()),
818
- destination: Wormhole.tokenId(options.toToken.chain, options.toToken.mint.toBase58()),
819
829
  });
820
830
  const validated = await route.validate(transferRequest, {
821
831
  amount: amountToString(options.amount, decimals),
@@ -823,11 +833,11 @@ const buildWormholeTransfer = async (options, connection) => {
823
833
  });
824
834
  if (validated.valid) {
825
835
  return {
826
- wh,
836
+ decimals,
827
837
  route,
828
- transferRequest,
829
838
  transferParams: validated.params,
830
- decimals,
839
+ transferRequest,
840
+ wh,
831
841
  };
832
842
  }
833
843
  else {
@@ -1,6 +1,6 @@
1
1
  import { AnchorProvider } from "@coral-xyz/anchor";
2
2
  import { TollboothIdl, TollboothProgram } from "@fogo/sessions-idls";
3
- import { sha256 } from "@noble/hashes/sha2";
3
+ import { sha256 } from "@noble/hashes/sha2.js";
4
4
  import { createAssociatedTokenAccountIdempotentInstruction, createCloseAccountInstruction, createSyncNativeInstruction, getAssociatedTokenAddressSync, NATIVE_MINT, } from "@solana/spl-token";
5
5
  import { PublicKey, SystemProgram, TransactionInstruction, } from "@solana/web3.js";
6
6
  const SESSION_WRAP_DISCRIMINATOR = 4_000_000;
@@ -17,17 +17,17 @@ export function createSystemProgramSessionWrapInstruction(sessionKey, walletPubl
17
17
  view.setUint32(0, SESSION_WRAP_DISCRIMINATOR, true);
18
18
  view.setBigUint64(4, amount, true);
19
19
  return new TransactionInstruction({
20
- programId: SystemProgram.programId,
20
+ data: Buffer.from(data),
21
21
  keys: [
22
- { pubkey: walletPublicKey, isSigner: false, isWritable: true },
22
+ { isSigner: false, isWritable: true, pubkey: walletPublicKey },
23
23
  {
24
- pubkey: getNativeMintAssociatedTokenAddressSync(walletPublicKey),
25
24
  isSigner: false,
26
25
  isWritable: true,
26
+ pubkey: getNativeMintAssociatedTokenAddressSync(walletPublicKey),
27
27
  },
28
- { pubkey: sessionKey, isSigner: true, isWritable: false },
28
+ { isSigner: true, isWritable: false, pubkey: sessionKey },
29
29
  ],
30
- data: Buffer.from(data),
30
+ programId: SystemProgram.programId,
31
31
  });
32
32
  }
33
33
  /**
@@ -53,7 +53,7 @@ export function createSessionUnwrapInstruction(sessionKey, walletPublicKey) {
53
53
  return createCloseAccountInstruction(getNativeMintAssociatedTokenAddressSync(walletPublicKey), walletPublicKey, sessionKey);
54
54
  }
55
55
  const getDomainTollRecipientAddress = (domain) => {
56
- const hash = sha256(domain);
56
+ const hash = sha256(new TextEncoder().encode(domain));
57
57
  return PublicKey.findProgramAddressSync([Buffer.from("toll_recipient"), Buffer.from([0]), hash], new PublicKey(TollboothIdl.address))[0];
58
58
  };
59
59
  /**
@@ -66,10 +66,10 @@ export const createPaymasterFeeInstruction = ({ sessionKey, walletPublicKey, dom
66
66
  return new TollboothProgram(new AnchorProvider({}, {})).methods
67
67
  .payToll(feeAmount, 0)
68
68
  .accounts({
69
- session: sessionKey,
70
- source: getAssociatedTokenAddressSync(feeMint, walletPublicKey),
71
69
  destination: getAssociatedTokenAddressSync(feeMint, recipient, true),
72
70
  mint: feeMint,
71
+ session: sessionKey,
72
+ source: getAssociatedTokenAddressSync(feeMint, walletPublicKey),
73
73
  })
74
74
  .instruction();
75
75
  };
package/package.json CHANGED
@@ -1,54 +1,55 @@
1
1
  {
2
- "name": "@fogo/sessions-sdk",
3
- "version": "0.1.8",
4
- "description": "A set of utilities for integrating with Fogo sessions",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/fogo-foundation/fogo-sessions",
8
- "directory": "packages/sessions-sdk-ts"
2
+ "dependencies": {
3
+ "@coral-xyz/anchor": "^0.32.1",
4
+ "@metaplex-foundation/mpl-token-metadata": "^3.4.0",
5
+ "@metaplex-foundation/umi": "^1.5.1",
6
+ "@metaplex-foundation/umi-bundle-defaults": "^1.5.1",
7
+ "@noble/hashes": "^2.2.0",
8
+ "@solana/compat": "^6.8.0",
9
+ "@solana/kit": "^6.8.0",
10
+ "@solana/spl-token": "^0.4.14",
11
+ "@solana/web3.js": "^1.98.4",
12
+ "@wormhole-foundation/sdk": "^4.17.0",
13
+ "@wormhole-foundation/sdk-base": "^4.17.0",
14
+ "@wormhole-foundation/sdk-connect": "^4.17.0",
15
+ "@wormhole-foundation/sdk-route-ntt": "^4.0.17",
16
+ "@wormhole-foundation/sdk-solana-core": "^4.17.0",
17
+ "@wormhole-foundation/sdk-solana-ntt": "^4.0.17",
18
+ "bn.js": "^5.2.3",
19
+ "bs58": "^6.0.0",
20
+ "zod": "4.3.6",
21
+ "@fogo/sessions-idls": "^0.1.4"
9
22
  },
10
- "keywords": [
11
- "fogo",
12
- "sessions",
13
- "crypto",
14
- "wallet"
15
- ],
16
- "type": "module",
17
- "main": "./cjs/index.js",
18
- "types": "./cjs/index.d.ts",
23
+ "description": "A set of utilities for integrating with Fogo sessions",
19
24
  "engines": {
20
25
  "node": ">=22"
21
26
  },
22
27
  "exports": {
23
28
  ".": {
24
29
  "import": {
25
- "types": "./esm/index.d.ts",
26
- "default": "./esm/index.js"
30
+ "default": "./esm/index.js",
31
+ "types": "./esm/index.d.ts"
27
32
  },
28
33
  "require": {
29
- "types": "./cjs/index.d.ts",
30
- "default": "./cjs/index.js"
34
+ "default": "./cjs/index.js",
35
+ "types": "./cjs/index.d.ts"
31
36
  }
32
37
  }
33
38
  },
34
- "dependencies": {
35
- "@coral-xyz/anchor": "^0.31.1",
36
- "@metaplex-foundation/mpl-token-metadata": "^3.4.0",
37
- "@metaplex-foundation/umi": "^1.2.0",
38
- "@metaplex-foundation/umi-bundle-defaults": "^1.2.0",
39
- "@noble/hashes": "^1.8.0",
40
- "@solana/compat": "^4.0.0",
41
- "@solana/kit": "^4.0.0",
42
- "@solana/spl-token": "^0.4.13",
43
- "@solana/web3.js": "^1.92.3",
44
- "@wormhole-foundation/sdk": "^3.10.0",
45
- "@wormhole-foundation/sdk-base": "^3.11.0",
46
- "@wormhole-foundation/sdk-route-ntt": "^4.0.1",
47
- "@wormhole-foundation/sdk-solana-core": "^3.10.0",
48
- "@wormhole-foundation/sdk-solana-ntt": "^4.0.1",
49
- "bn.js": "^5.1.2",
50
- "bs58": "^6.0.0",
51
- "zod": "3.25.67",
52
- "@fogo/sessions-idls": "^0.1.2"
53
- }
39
+ "keywords": [
40
+ "fogo",
41
+ "sessions",
42
+ "crypto",
43
+ "wallet"
44
+ ],
45
+ "main": "./cjs/index.js",
46
+ "name": "@fogo/sessions-sdk",
47
+ "repository": {
48
+ "directory": "packages/sessions-sdk-ts",
49
+ "type": "git",
50
+ "url": "https://github.com/fogo-foundation/fogo-sessions"
51
+ },
52
+ "type": "module",
53
+ "types": "./cjs/index.d.ts",
54
+ "version": "0.1.9"
54
55
  }