@rhinestone/deposit-modal 0.3.0-alpha.1 → 0.3.0-alpha.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.
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  DepositModalInner
3
- } from "./chunk-SLLI7SB6.mjs";
3
+ } from "./chunk-QLTTDVFU.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
7
7
  } from "./chunk-5YXAQB6A.mjs";
8
- import "./chunk-FY76DWPD.mjs";
8
+ import "./chunk-TFXIQ7YH.mjs";
9
9
  import "./chunk-VA3ANS7D.mjs";
10
10
 
11
11
  // src/DepositModalReown.tsx
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkC6JK3IO6cjs = require('./chunk-C6JK3IO6.cjs');
3
+ var _chunkIATY2C5Rcjs = require('./chunk-IATY2C5R.cjs');
4
4
 
5
5
 
6
6
 
7
7
  var _chunkYQFH2WSWcjs = require('./chunk-YQFH2WSW.cjs');
8
- require('./chunk-DCAANLEP.cjs');
8
+ require('./chunk-V6NJIPSS.cjs');
9
9
  require('./chunk-IVTXEYB2.cjs');
10
10
 
11
11
  // src/DepositModalReown.tsx
@@ -32,7 +32,7 @@ function DepositModalWithReown(props) {
32
32
  reown.disconnect();
33
33
  }, [reown.disconnect]);
34
34
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
35
- _chunkC6JK3IO6cjs.DepositModalInner,
35
+ _chunkIATY2C5Rcjs.DepositModalInner,
36
36
  {
37
37
  ...props,
38
38
  reownWallet: reownWithSolana,
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkK7MNFNR7cjs = require('./chunk-K7MNFNR7.cjs');
3
+ var _chunkUEYFJM5Ycjs = require('./chunk-UEYFJM5Y.cjs');
4
4
 
5
5
 
6
6
 
7
7
  var _chunkYQFH2WSWcjs = require('./chunk-YQFH2WSW.cjs');
8
- require('./chunk-DCAANLEP.cjs');
8
+ require('./chunk-V6NJIPSS.cjs');
9
9
  require('./chunk-IVTXEYB2.cjs');
10
10
 
11
11
  // src/WithdrawModalReown.tsx
@@ -20,7 +20,7 @@ function WithdrawModalWithReown(props) {
20
20
  reown.disconnect();
21
21
  }, [reown.disconnect]);
22
22
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
23
- _chunkK7MNFNR7cjs.WithdrawModalInner,
23
+ _chunkUEYFJM5Ycjs.WithdrawModalInner,
24
24
  {
25
25
  ...props,
26
26
  reownWallet: reown,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  WithdrawModalInner
3
- } from "./chunk-D5YCALVX.mjs";
3
+ } from "./chunk-GE3TMZEL.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
7
7
  } from "./chunk-5YXAQB6A.mjs";
8
- import "./chunk-FY76DWPD.mjs";
8
+ import "./chunk-TFXIQ7YH.mjs";
9
9
  import "./chunk-VA3ANS7D.mjs";
10
10
 
11
11
  // src/WithdrawModalReown.tsx
@@ -14,12 +14,15 @@ import {
14
14
  WalletIcon,
15
15
  accountFromPrivateKey,
16
16
  applyTheme,
17
+ buildSafeTransaction,
17
18
  buildSessionDetails,
18
19
  createDepositService,
19
20
  createSessionOwnerKey,
20
21
  currencyFormatter,
21
22
  debugError,
22
23
  debugLog,
24
+ executeSafeErc20Transfer,
25
+ executeSafeEthTransfer,
23
26
  formatUserError,
24
27
  getAssetId,
25
28
  getPublicClient,
@@ -28,7 +31,7 @@ import {
28
31
  saveSessionOwnerToStorage,
29
32
  toEvmCaip2,
30
33
  useLatestRef
31
- } from "./chunk-FY76DWPD.mjs";
34
+ } from "./chunk-TFXIQ7YH.mjs";
32
35
  import {
33
36
  DEFAULT_BACKEND_URL,
34
37
  DEFAULT_SIGNER_ADDRESS,
@@ -765,293 +768,8 @@ function WithdrawReviewStep({
765
768
  }
766
769
  WithdrawReviewStep.displayName = "WithdrawReviewStep";
767
770
 
768
- // src/core/safe.ts
769
- import {
770
- concat,
771
- encodeFunctionData,
772
- erc20Abi as erc20Abi2,
773
- hashTypedData,
774
- pad,
775
- parseEventLogs,
776
- toHex,
777
- zeroAddress
778
- } from "viem";
779
- var SAFE_ABI = [
780
- {
781
- type: "function",
782
- name: "isOwner",
783
- stateMutability: "view",
784
- inputs: [{ name: "owner", type: "address" }],
785
- outputs: [{ name: "", type: "bool" }]
786
- },
787
- {
788
- type: "function",
789
- name: "nonce",
790
- stateMutability: "view",
791
- inputs: [],
792
- outputs: [{ type: "uint256" }]
793
- },
794
- {
795
- type: "function",
796
- name: "execTransaction",
797
- stateMutability: "payable",
798
- inputs: [
799
- { name: "to", type: "address" },
800
- { name: "value", type: "uint256" },
801
- { name: "data", type: "bytes" },
802
- { name: "operation", type: "uint8" },
803
- { name: "safeTxGas", type: "uint256" },
804
- { name: "baseGas", type: "uint256" },
805
- { name: "gasPrice", type: "uint256" },
806
- { name: "gasToken", type: "address" },
807
- { name: "refundReceiver", type: "address" },
808
- { name: "signatures", type: "bytes" }
809
- ],
810
- outputs: [{ name: "success", type: "bool" }]
811
- },
812
- {
813
- type: "event",
814
- name: "ExecutionSuccess",
815
- inputs: [
816
- { name: "txHash", type: "bytes32", indexed: true },
817
- { name: "payment", type: "uint256", indexed: false }
818
- ],
819
- anonymous: false
820
- },
821
- {
822
- type: "event",
823
- name: "ExecutionFailure",
824
- inputs: [
825
- { name: "txHash", type: "bytes32", indexed: true },
826
- { name: "payment", type: "uint256", indexed: false }
827
- ],
828
- anonymous: false
829
- }
830
- ];
831
- async function executeSafeEthTransfer(params) {
832
- const {
833
- walletClient,
834
- publicClient,
835
- safeAddress,
836
- recipient,
837
- amount,
838
- chainId
839
- } = params;
840
- const account = walletClient.account;
841
- const chain = walletClient.chain;
842
- if (!account || !chain) {
843
- throw new Error("Wallet not connected");
844
- }
845
- if (chain.id !== chainId) {
846
- throw new Error(`Switch to ${getChainName(chainId)} to sign`);
847
- }
848
- const isOwner = await publicClient.readContract({
849
- address: safeAddress,
850
- abi: SAFE_ABI,
851
- functionName: "isOwner",
852
- args: [account.address]
853
- });
854
- if (!isOwner) {
855
- throw new Error("Connected wallet is not a Safe owner");
856
- }
857
- const safeTx = {
858
- to: recipient,
859
- value: amount,
860
- data: "0x",
861
- operation: 0,
862
- safeTxGas: 0n,
863
- baseGas: 0n,
864
- gasPrice: 0n,
865
- gasToken: zeroAddress,
866
- refundReceiver: zeroAddress
867
- };
868
- const signature = concat([
869
- pad(account.address, { size: 32 }),
870
- pad(toHex(0), { size: 32 }),
871
- toHex(1, { size: 1 })
872
- ]);
873
- const txHash = await walletClient.writeContract({
874
- account,
875
- chain,
876
- address: safeAddress,
877
- abi: SAFE_ABI,
878
- functionName: "execTransaction",
879
- args: [
880
- safeTx.to,
881
- safeTx.value,
882
- safeTx.data,
883
- safeTx.operation,
884
- safeTx.safeTxGas,
885
- safeTx.baseGas,
886
- safeTx.gasPrice,
887
- safeTx.gasToken,
888
- safeTx.refundReceiver,
889
- signature
890
- ]
891
- });
892
- const receipt = await publicClient.waitForTransactionReceipt({
893
- hash: txHash
894
- });
895
- const safeLogs = receipt.logs.filter(
896
- (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
897
- );
898
- const parsed = parseEventLogs({
899
- abi: SAFE_ABI,
900
- logs: safeLogs,
901
- strict: false
902
- });
903
- const failed = parsed.find((log) => log.eventName === "ExecutionFailure");
904
- if (failed) {
905
- throw new Error("Safe transaction failed");
906
- }
907
- const succeeded = parsed.find((log) => log.eventName === "ExecutionSuccess");
908
- if (!succeeded) {
909
- throw new Error("Safe transaction status unavailable");
910
- }
911
- return { txHash };
912
- }
913
- async function executeSafeErc20Transfer(params) {
914
- const {
915
- walletClient,
916
- publicClient,
917
- safeAddress,
918
- tokenAddress,
919
- recipient,
920
- amount,
921
- chainId
922
- } = params;
923
- const account = walletClient.account;
924
- const chain = walletClient.chain;
925
- if (!account || !chain) {
926
- throw new Error("Wallet not connected");
927
- }
928
- if (chain.id !== chainId) {
929
- throw new Error(`Switch to ${getChainName(chainId)} to sign`);
930
- }
931
- const isOwner = await publicClient.readContract({
932
- address: safeAddress,
933
- abi: SAFE_ABI,
934
- functionName: "isOwner",
935
- args: [account.address]
936
- });
937
- if (!isOwner) {
938
- throw new Error("Connected wallet is not a Safe owner");
939
- }
940
- const data = encodeFunctionData({
941
- abi: erc20Abi2,
942
- functionName: "transfer",
943
- args: [recipient, amount]
944
- });
945
- const safeTx = {
946
- to: tokenAddress,
947
- value: 0n,
948
- data,
949
- operation: 0,
950
- safeTxGas: 0n,
951
- baseGas: 0n,
952
- gasPrice: 0n,
953
- gasToken: zeroAddress,
954
- refundReceiver: zeroAddress
955
- };
956
- const signature = concat([
957
- pad(account.address, { size: 32 }),
958
- pad(toHex(0), { size: 32 }),
959
- toHex(1, { size: 1 })
960
- ]);
961
- const txHash = await walletClient.writeContract({
962
- account,
963
- chain,
964
- address: safeAddress,
965
- abi: SAFE_ABI,
966
- functionName: "execTransaction",
967
- args: [
968
- safeTx.to,
969
- safeTx.value,
970
- safeTx.data,
971
- safeTx.operation,
972
- safeTx.safeTxGas,
973
- safeTx.baseGas,
974
- safeTx.gasPrice,
975
- safeTx.gasToken,
976
- safeTx.refundReceiver,
977
- signature
978
- ]
979
- });
980
- const receipt = await publicClient.waitForTransactionReceipt({
981
- hash: txHash
982
- });
983
- const safeLogs = receipt.logs.filter(
984
- (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
985
- );
986
- const parsed = parseEventLogs({
987
- abi: SAFE_ABI,
988
- logs: safeLogs,
989
- strict: false
990
- });
991
- const failed = parsed.find((log) => log.eventName === "ExecutionFailure");
992
- if (failed) {
993
- throw new Error("Safe transaction failed");
994
- }
995
- const succeeded = parsed.find((log) => log.eventName === "ExecutionSuccess");
996
- if (!succeeded) {
997
- throw new Error("Safe transaction status unavailable");
998
- }
999
- return { txHash };
1000
- }
1001
- var SAFE_TX_TYPES = {
1002
- SafeTx: [
1003
- { name: "to", type: "address" },
1004
- { name: "value", type: "uint256" },
1005
- { name: "data", type: "bytes" },
1006
- { name: "operation", type: "uint8" },
1007
- { name: "safeTxGas", type: "uint256" },
1008
- { name: "baseGas", type: "uint256" },
1009
- { name: "gasPrice", type: "uint256" },
1010
- { name: "gasToken", type: "address" },
1011
- { name: "refundReceiver", type: "address" },
1012
- { name: "nonce", type: "uint256" }
1013
- ]
1014
- };
1015
- async function buildSafeTransaction(params) {
1016
- const { publicClient, safeAddress, to, value, data, chainId } = params;
1017
- const nonce = await publicClient.readContract({
1018
- address: safeAddress,
1019
- abi: SAFE_ABI,
1020
- functionName: "nonce"
1021
- });
1022
- const message = {
1023
- to,
1024
- value,
1025
- data,
1026
- operation: 0,
1027
- safeTxGas: 0n,
1028
- baseGas: 0n,
1029
- gasPrice: 0n,
1030
- gasToken: zeroAddress,
1031
- refundReceiver: zeroAddress,
1032
- nonce
1033
- };
1034
- const safeTxHash = hashTypedData({
1035
- domain: { chainId, verifyingContract: safeAddress },
1036
- types: SAFE_TX_TYPES,
1037
- primaryType: "SafeTx",
1038
- message
1039
- });
1040
- return {
1041
- chainId,
1042
- safeAddress,
1043
- safeTxHash,
1044
- typedData: {
1045
- domain: { chainId, verifyingContract: safeAddress },
1046
- types: SAFE_TX_TYPES,
1047
- primaryType: "SafeTx",
1048
- message
1049
- }
1050
- };
1051
- }
1052
-
1053
771
  // src/WithdrawFlow.tsx
1054
- import { encodeFunctionData as encodeFunctionData2, erc20Abi as erc20Abi3, parseUnits as parseUnits2 } from "viem";
772
+ import { encodeFunctionData, erc20Abi as erc20Abi2, parseUnits as parseUnits2 } from "viem";
1055
773
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1056
774
  var ADDR_REGEX = /^0x[a-fA-F0-9]{40}$/;
1057
775
  var REGISTRATION_DEBOUNCE_MS = 600;
@@ -1475,8 +1193,8 @@ function WithdrawFlow({
1475
1193
  const transferData = isSourceNative ? { to: transferTarget, value: amountUnits, data: "0x" } : {
1476
1194
  to: sourceToken,
1477
1195
  value: 0n,
1478
- data: encodeFunctionData2({
1479
- abi: erc20Abi3,
1196
+ data: encodeFunctionData({
1197
+ abi: erc20Abi2,
1480
1198
  functionName: "transfer",
1481
1199
  args: [transferTarget, amountUnits]
1482
1200
  })
@@ -1670,10 +1388,18 @@ function WithdrawFlow({
1670
1388
  return selected?.kind === "external" ? selected.icon ?? reownWallet?.icon : void 0;
1671
1389
  }, [walletOptions, ownerAddress, reownWallet?.icon]);
1672
1390
  if (showConnectStep) {
1391
+ const withdrawRows = walletOptions.map((option) => ({
1392
+ id: option.id,
1393
+ kind: option.kind,
1394
+ label: option.label,
1395
+ icon: option.icon,
1396
+ address: option.address ?? option.solanaAddress ?? option.id,
1397
+ state: "ready"
1398
+ }));
1673
1399
  return /* @__PURE__ */ jsx3("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx3(
1674
1400
  ConnectStep,
1675
1401
  {
1676
- walletOptions,
1402
+ walletRows: withdrawRows,
1677
1403
  onConfirmWallet: (walletId) => {
1678
1404
  setSelectedWalletId(walletId);
1679
1405
  setIsConnectSelectionConfirmed(true);
@@ -1767,7 +1493,7 @@ function deriveStepView(step, _registration) {
1767
1493
  // src/WithdrawModal.tsx
1768
1494
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1769
1495
  var ReownWithdrawInner = lazy(
1770
- () => import("./WithdrawModalReown-SQQQV6KQ.mjs").then((m) => ({
1496
+ () => import("./WithdrawModalReown-UO7XCJ7K.mjs").then((m) => ({
1771
1497
  default: m.WithdrawModalReown
1772
1498
  }))
1773
1499
  );