@rhinestone/deposit-modal 0.1.5 → 0.1.6

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/dist/index.cjs CHANGED
@@ -651,12 +651,29 @@ async function signEnableSessionWithOwner(rhinestoneAccount, sessionDetails, sig
651
651
  rhinestoneAccount.config.owners = originalOwners;
652
652
  }
653
653
  }
654
- async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner) {
655
- const allChains = [...SUPPORTED_CHAINS];
656
- if (!allChains.some((c) => c.id === targetChain.id)) {
657
- allChains.push(targetChain);
654
+ async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner, targetToken) {
655
+ const isTargetTestnet = Boolean(targetChain.testnet);
656
+ const chainsByNetworkType = SUPPORTED_CHAINS.filter(
657
+ (chain) => Boolean(chain.testnet) === isTargetTestnet
658
+ );
659
+ let selectedChains = [...chainsByNetworkType];
660
+ if (targetToken) {
661
+ const targetSymbol = getTokenSymbol(targetToken, targetChain.id).toUpperCase();
662
+ if (targetSymbol && targetSymbol !== "TOKEN") {
663
+ const chainsForToken = selectedChains.filter(
664
+ (chain) => getSupportedTokenSymbolsForChain(chain.id).includes(targetSymbol)
665
+ );
666
+ if (chainsForToken.length > 0) {
667
+ selectedChains = chainsForToken;
668
+ }
669
+ }
658
670
  }
659
- const sessions = allChains.map((chain) => buildSession(chain, signerAddress));
671
+ if (!selectedChains.some((c) => c.id === targetChain.id)) {
672
+ selectedChains.push(targetChain);
673
+ }
674
+ const sessions = selectedChains.map(
675
+ (chain) => buildSession(chain, signerAddress)
676
+ );
660
677
  const sessionDetails = await rhinestoneAccount.experimental_getSessionDetails(sessions);
661
678
  const enableSignature = sessionSigner ? await signEnableSessionWithOwner(
662
679
  rhinestoneAccount,
@@ -781,7 +798,8 @@ function SetupStep({
781
798
  account,
782
799
  targetChainObj,
783
800
  signerAddress,
784
- sessionOwner.account
801
+ sessionOwner.account,
802
+ targetToken
785
803
  );
786
804
  setState({ type: "registering" });
787
805
  await service.registerAccount({
@@ -4039,7 +4057,8 @@ function WithdrawFlow({
4039
4057
  account,
4040
4058
  targetChainObj,
4041
4059
  signerAddress,
4042
- sessionOwner.account
4060
+ sessionOwner.account,
4061
+ targetToken
4043
4062
  );
4044
4063
  await service.registerAccount({
4045
4064
  address: smartAccount,
package/dist/index.mjs CHANGED
@@ -610,12 +610,29 @@ async function signEnableSessionWithOwner(rhinestoneAccount, sessionDetails, sig
610
610
  rhinestoneAccount.config.owners = originalOwners;
611
611
  }
612
612
  }
613
- async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner) {
614
- const allChains = [...SUPPORTED_CHAINS];
615
- if (!allChains.some((c) => c.id === targetChain.id)) {
616
- allChains.push(targetChain);
613
+ async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner, targetToken) {
614
+ const isTargetTestnet = Boolean(targetChain.testnet);
615
+ const chainsByNetworkType = SUPPORTED_CHAINS.filter(
616
+ (chain) => Boolean(chain.testnet) === isTargetTestnet
617
+ );
618
+ let selectedChains = [...chainsByNetworkType];
619
+ if (targetToken) {
620
+ const targetSymbol = getTokenSymbol(targetToken, targetChain.id).toUpperCase();
621
+ if (targetSymbol && targetSymbol !== "TOKEN") {
622
+ const chainsForToken = selectedChains.filter(
623
+ (chain) => getSupportedTokenSymbolsForChain(chain.id).includes(targetSymbol)
624
+ );
625
+ if (chainsForToken.length > 0) {
626
+ selectedChains = chainsForToken;
627
+ }
628
+ }
617
629
  }
618
- const sessions = allChains.map((chain) => buildSession(chain, signerAddress));
630
+ if (!selectedChains.some((c) => c.id === targetChain.id)) {
631
+ selectedChains.push(targetChain);
632
+ }
633
+ const sessions = selectedChains.map(
634
+ (chain) => buildSession(chain, signerAddress)
635
+ );
619
636
  const sessionDetails = await rhinestoneAccount.experimental_getSessionDetails(sessions);
620
637
  const enableSignature = sessionSigner ? await signEnableSessionWithOwner(
621
638
  rhinestoneAccount,
@@ -743,7 +760,8 @@ function SetupStep({
743
760
  account,
744
761
  targetChainObj,
745
762
  signerAddress,
746
- sessionOwner.account
763
+ sessionOwner.account,
764
+ targetToken
747
765
  );
748
766
  setState({ type: "registering" });
749
767
  await service.registerAccount({
@@ -4009,7 +4027,8 @@ function WithdrawFlow({
4009
4027
  account,
4010
4028
  targetChainObj,
4011
4029
  signerAddress,
4012
- sessionOwner.account
4030
+ sessionOwner.account,
4031
+ targetToken
4013
4032
  );
4014
4033
  await service.registerAccount({
4015
4034
  address: smartAccount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/deposit-modal",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "React modal component for Rhinestone cross-chain deposits",
5
5
  "author": "Rhinestone <dev@rhinestone.wtf>",
6
6
  "bugs": {