PageSourceSearch

https://magic.af/FundSolWalletWithExternalSolanaWallet-D6BbKHlH-HBU6KC3S.js

js magic.af collected 2026-10-07 17:51:33 UTC 33,316 bytes, 585 lines download raw bytes

1import {
2  b,
3  d,
4  f as f3,
5  m as m2,
6  p as p2,
7  u as u2
8} from "./chunk-H3ZXOTIG.js";
9import {
10  r as r3
11} from "./chunk-N53W7GUD.js";
12import {
13  C,
14  e as e2,
15  s as s3
16} from "./chunk-75HDCK52.js";
17import {
18  e
19} from "./chunk-HZQPUPEF.js";
20import {
21  c as c3
22} from "./chunk-4XFVO5G5.js";
23import "./chunk-AS4G2Y34.js";
24import {
25  i as i3
26} from "./chunk-2HETXWDZ.js";
27import {
28  e as e3,
29  n as n3,
30  s as s4,
31  t as t5
32} from "./chunk-VHUZOACI.js";
33import {
34  t as t3
35} from "./chunk-B6F55UZV.js";
36import {
37  o as o2
38} from "./chunk-4LXQ4QCE.js";
39import "./chunk-S262GGZ2.js";
40import {
41  t as t4
42} from "./chunk-WJTHUMIQ.js";
43import {
44  c as c2,
45  n as n2,
46  s as s2,
47  t as t2
48} from "./chunk-COQ5KDFA.js";
49import {
50  AccountRole,
51  address,
52  appendTransactionMessageInstruction,
53  compileTransaction,
54  createTransactionMessage,
55  findAssociatedTokenPda,
56  getBase58Decoder,
57  getCreateAssociatedTokenIdempotentInstruction,
58  getStructEncoder,
59  getTransactionDecoder,
60  getTransactionEncoder,
61  getTransferInstruction,
62  getU32Encoder,
63  getU64Encoder,
64  i as i2,
65  isTransactionSigner,
66  pipe,
67  setTransactionMessageFeePayerSigner,
68  setTransactionMessageLifetimeUsingBlockhash,
69  transformEncoder,
70  upgradeRoleToSigner
71} from "./chunk-XDBGXYUT.js";
72import "./chunk-OVN5HUR5.js";
73import {
74  CheckCircleIcon_default
75} from "./chunk-GZCXEBG2.js";
76import "./chunk-VCO6RSVL.js";
77import {
78  A,
79  se
80} from "./chunk-QZLHOL7H.js";
81import "./chunk-OTHATL7L.js";
82import {
83  t
84} from "./chunk-U5IFGDYD.js";
85import {
86  g
87} from "./chunk-F2OYRDGK.js";
88import {
89  m,
90  u
91} from "./chunk-UL52HBKA.js";
92import {
93  G,
94  _,
95  a as a2,
96  c,
97  f3 as f2,
98  i2 as i,
99  l,
100  o,
101  p3 as p,
102  r2,
103  require_lib,
104  s2 as s
105} from "./chunk-I4QQ47H5.js";
106import "./chunk-256YLKEK.js";
107import {
108  a4 as a,
109  eventemitter3_default,
110  f,
111  le,
112  n3 as n,
113  r7 as r,
114  y
115} from "./chunk-JY4L4TVN.js";
116import {
117  require_jsx_runtime,
118  require_react
119} from "./chunk-MUQC47WX.js";
120import {
121  base58
122} from "./chunk-5JRGJGLK.js";
123import "./chunk-RHWM2WTS.js";
124import "./chunk-M4LWCW24.js";
125import "./chunk-KBR6YQG7.js";
126import "./chunk-OZF4C3W7.js";
127import "./chunk-Z3WEDMX4.js";
128import "./chunk-M6NCLRUY.js";
129import "./chunk-XYPPA4CO.js";
130import "./chunk-BFKH7XNT.js";
131import {
132  __toESM
133} from "./chunk-FOQIPI7F.js";
134
vendor: 207 bytes, lines 135-138
135// node_modules/@privy-io/react-auth/dist/esm/FundSolWalletWithExternalSolanaWallet-D6BbKHlH.mjs
136var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
137var import_react2 = __toESM(require_react(), 1);
138
vendor: 18,614 bytes, lines 139-427
139// node_modules/@privy-io/react-auth/dist/esm/useWallets-BGXT-Nxj.mjs
140var import_react = __toESM(require_react(), 1);
141var M = ["solana:mainnet", "solana:devnet", "solana:testnet"];
142function P(n4) {
143  return getBase58Decoder().decode(n4);
144}
145function F(e5, n4) {
146  if (!Object.prototype.hasOwnProperty.call(e5, n4)) throw TypeError("attempted to use private field on non-instance");
147  return e5;
148}
149var C2 = 0;
150var U = "__private_" + C2++ + "__implementation";
151function D(e5, n4) {
152  if (!Object.prototype.hasOwnProperty.call(e5, n4)) throw TypeError("attempted to use private field on non-instance");
153  return e5;
154}
155var N = 0;
156function B(e5) {
157  return "__private_" + N++ + "_" + e5;
158}
159var x = /* @__PURE__ */ B("_address");
160var R = /* @__PURE__ */ B("_publicKey");
161var L = /* @__PURE__ */ B("_chains");
162var V = /* @__PURE__ */ B("_features");
163var Q = /* @__PURE__ */ B("_label");
164var G2 = /* @__PURE__ */ B("_icon");
165var K = class _K {
166  get address() {
167    return D(this, x)[x];
168  }
169  get publicKey() {
170    return D(this, R)[R].slice();
171  }
172  get chains() {
173    return D(this, L)[L].slice();
174  }
175  get features() {
176    return D(this, V)[V].slice();
177  }
178  get label() {
179    return D(this, Q)[Q];
180  }
181  get icon() {
182    return D(this, G2)[G2];
183  }
184  constructor({ address: e5, publicKey: n4, label: t7, icon: a4 }) {
185    Object.defineProperty(this, x, { writable: true, value: void 0 }), Object.defineProperty(this, R, { writable: true, value: void 0 }), Object.defineProperty(this, L, { writable: true, value: void 0 }), Object.defineProperty(this, V, { writable: true, value: void 0 }), Object.defineProperty(this, Q, { writable: true, value: void 0 }), Object.defineProperty(this, G2, { writable: true, value: void 0 }), D(this, x)[x] = e5, D(this, R)[R] = n4, D(this, L)[L] = M, D(this, Q)[Q] = t7, D(this, G2)[G2] = a4, D(this, V)[V] = ["solana:signAndSendTransaction", "solana:signTransaction", "solana:signMessage"], new.target === _K && Object.freeze(this);
186  }
187};
188function k(e5, n4) {
189  if (!Object.prototype.hasOwnProperty.call(e5, n4)) throw TypeError("attempted to use private field on non-instance");
190  return e5;
191}
192var J = 0;
193function Y(e5) {
194  return "__private_" + J++ + "_" + e5;
195}
196var H = /* @__PURE__ */ Y("_listeners");
197var Z = /* @__PURE__ */ Y("_version");
198var z = /* @__PURE__ */ Y("_name");
199var q = /* @__PURE__ */ Y("_icon");
200var X = /* @__PURE__ */ Y("_injection");
201var $ = /* @__PURE__ */ Y("_isPrivyWallet");
202var ee = /* @__PURE__ */ Y("_accounts");
203var ne = /* @__PURE__ */ Y("_on");
204var te = /* @__PURE__ */ Y("_emit");
205var ae = /* @__PURE__ */ Y("_off");
206var se2 = /* @__PURE__ */ Y("_connected");
207var ie = /* @__PURE__ */ Y("_connect");
208var re = /* @__PURE__ */ Y("_disconnect");
209var oe = /* @__PURE__ */ Y("_signMessage");
210var ce = /* @__PURE__ */ Y("_signAndSendTransaction");
211var le2 = /* @__PURE__ */ Y("_signTransaction");
212function de(e5, ...n4) {
213  k(this, H)[H][e5]?.forEach((e6) => e6.apply(null, n4));
214}
215function ue(e5, n4) {
216  k(this, H)[H][e5] = k(this, H)[H][e5]?.filter((e6) => n4 !== e6);
217}
218function ge(e5, s6, i5) {
219  let r6 = structuredClone(getTransactionDecoder().decode(e5)), o4 = address(s6);
220  return o4 in r6.signatures && (r6.signatures[o4] = i5), new Uint8Array(getTransactionEncoder().encode(r6));
221}
222function he() {
223  let { isHeadlessSigning: e5, walletProxy: n4, initializeWalletProxy: t7, recoverEmbeddedWallet: a4, openModal: s6, privy: i5, client: r6 } = l(), { user: c4 } = se(), { setModalData: d2 } = g(), { signWithUserSigner: h } = i2();
224  return { signMessage: ({ message: l2, address: p3, options: f4 }) => new Promise(async (y2, A2) => {
225    let m3 = _(c4, p3);
226    if ("privy" !== m3?.walletClientType) return void A2(new r2("Wallet is not a Privy wallet", void 0, i.EMBEDDED_WALLET_NOT_FOUND));
227    let { entropyId: v, entropyIdVerifier: O } = f2(c4, m3), S = s(m3), E = m2(l2).toString("base64");
228    if (E.length < 1) return void A2(new r2("Message must be a non-empty string", void 0, i.INVALID_MESSAGE));
229    let I = async () => {
230      let e6;
231      if (!c4) throw Error("User must be authenticated before signing with a Privy wallet");
232      let s7 = await r6.getAccessToken();
233      if (!s7) throw Error("User must be authenticated to use their embedded wallet.");
234      let l3 = n4 ?? await t7(15e3);
235      if (!l3) throw Error("Failed to initialize embedded wallet proxy.");
236      if (!await a4({ address: m3.address })) throw Error("Unable to connect to wallet");
237      if (S) {
238        let n5 = await a(i5, h, { chain_type: "solana", method: "signMessage", params: { message: E, encoding: "base64" }, wallet_id: m3.id });
239        if (!n5.data || !("signature" in n5.data)) throw Error("Failed to sign message");
240        e6 = n5.data.signature;
241      } else {
242        let { response: n5 } = await l3.rpc({ accessToken: s7, entropyId: v, entropyIdVerifier: O, chainType: "solana", hdWalletIndex: m3.walletIndex ?? 0, requesterAppId: f4?.uiOptions?.requesterAppId, request: { method: "signMessage", params: { message: E } } });
243        e6 = n5.data.signature;
244      }
245      return e6;
246    };
247    if (e5({ showWalletUIs: f4?.uiOptions?.showWalletUIs })) try {
248      let e6 = await I(), n5 = new Uint8Array(m2(e6, "base64"));
249      y2({ signature: n5 });
250    } catch (e6) {
251      A2(e6);
252    }
253    else d2({ signMessage: { method: "solana_signMessage", data: E, confirmAndSign: I, onSuccess: (e6) => {
254      y2({ signature: new Uint8Array(m2(e6, "base64")) });
255    }, onFailure: (e6) => {
256      A2(e6);
257    }, uiOptions: f4?.uiOptions ?? {} }, connectWallet: { recoveryMethod: m3.recoveryMethod, connectingWalletAddress: m3.address, entropyId: v, entropyIdVerifier: O, isUnifiedWallet: S, onCompleteNavigateTo: "SignRequestScreen", onFailure: (e6) => {
258      A2(new r2("Failed to connect to wallet", e6, i.UNKNOWN_CONNECT_WALLET_ERROR));
259    } } }), s6("EmbeddedWalletConnectingScreen");
260  }) };
261}
262function pe() {
263  let { isHeadlessSigning: e5, openModal: n4, privy: t7 } = l(), { setModalData: a4 } = g(), { signMessage: s6 } = he(), { signWithUserSigner: i5 } = i2(), { user: r6 } = se();
264  return { signTransaction: async ({ transaction: c4, options: l2, chain: d2 = "solana:mainnet", address: h }) => {
265    let p3 = _(r6, h);
266    if ("privy" !== p3?.walletClientType) throw new r2("Wallet is not a Privy wallet", void 0, i.EMBEDDED_WALLET_NOT_FOUND);
267    let f4 = s(p3);
268    async function y2(e6) {
269      if (f4) {
270        let n6 = await a(t7, i5, { chain_type: "solana", method: "signTransaction", params: { transaction: y.base64.fromBytes(e6), encoding: "base64" }, wallet_id: p3.id });
271        if (n6.data && "signed_transaction" in n6.data && null != n6.data.signed_transaction) return { signedTransaction: new Uint8Array(y.base64.toBytes(n6.data.signed_transaction)) };
272        throw Error("Failed to sign transaction");
273      }
274      let { signature: n5 } = await s6({ message: u2(e6), address: h, options: { ...l2, uiOptions: { ...l2?.uiOptions, showWalletUIs: false } } });
275      return { signedTransaction: ge(e6, h, n5) };
276    }
277    return e5({ showWalletUIs: l2?.uiOptions?.showWalletUIs }) ? y2(c4) : new Promise(async (e6, t8) => {
278      let { entropyId: s7, entropyIdVerifier: i6 } = f2(r6, p3);
279      function o4(e7) {
280        return (n5) => {
281          t8(n5 instanceof r2 ? n5 : new r2("Failed to connect to wallet", n5, e7));
282        };
283      }
284      let u3 = { account: p3, transaction: c4, chain: d2, signOnly: true, uiOptions: l2?.uiOptions || {}, onConfirm: y2, onSuccess: e6, onFailure: o4(i.TRANSACTION_FAILURE) };
285      a4({ connectWallet: { recoveryMethod: p3.recoveryMethod, connectingWalletAddress: p3.address, entropyId: s7, entropyIdVerifier: i6, isUnifiedWallet: f4, onCompleteNavigateTo: "StandardSignAndSendTransactionScreen", onFailure: o4(i.UNKNOWN_CONNECT_WALLET_ERROR) }, standardSignAndSendTransaction: u3 }), n4("EmbeddedWalletConnectingScreen");
286    });
287  } };
288}
289var fe = new class extends eventemitter3_default {
290  setImplementation(e5) {
291    F(this, U)[U] = e5;
292  }
293  async signMessage(e5) {
294    return F(this, U)[U].signMessage(e5);
295  }
296  async signAndSendTransaction(e5) {
297    return F(this, U)[U].signAndSendTransaction(e5);
298  }
299  async signTransaction(e5) {
300    return F(this, U)[U].signTransaction(e5);
301  }
302  constructor(e5) {
303    super(), Object.defineProperty(this, U, { writable: true, value: void 0 }), F(this, U)[U] = e5;
304  }
305}({ signTransaction: a2("signTransaction was not injected"), signAndSendTransaction: a2("signAndSendTransaction was not injected"), signMessage: a2("signMessage was not injected") });
306var we = new class {
307  get version() {
308    return k(this, Z)[Z];
309  }
310  get name() {
311    return k(this, z)[z];
312  }
313  get icon() {
314    return k(this, q)[q];
315  }
316  get chains() {
317    return M.slice();
318  }
319  get features() {
320    return { "standard:connect": { version: "1.0.0", connect: k(this, ie)[ie] }, "standard:disconnect": { version: "1.0.0", disconnect: k(this, re)[re] }, "standard:events": { version: "1.0.0", on: k(this, ne)[ne] }, "solana:signAndSendTransaction": { version: "1.0.0", supportedTransactionVersions: ["legacy", 0], signAndSendTransaction: k(this, ce)[ce] }, "solana:signTransaction": { version: "1.0.0", supportedTransactionVersions: ["legacy", 0], signTransaction: k(this, le2)[le2] }, "solana:signMessage": { version: "1.0.0", signMessage: k(this, oe)[oe] }, "privy:": { privy: { signMessage: k(this, X)[X].signMessage, signTransaction: k(this, X)[X].signTransaction, signAndSendTransaction: k(this, X)[X].signAndSendTransaction } } };
321  }
322  get accounts() {
323    return k(this, ee)[ee].slice();
324  }
325  get isPrivyWallet() {
326    return k(this, $)[$];
327  }
328  constructor({ name: e5, icon: n4, version: t7, injection: a4, wallets: s6 }) {
329    Object.defineProperty(this, te, { value: de }), Object.defineProperty(this, ae, { value: ue }), Object.defineProperty(this, H, { writable: true, value: void 0 }), Object.defineProperty(this, Z, { writable: true, value: void 0 }), Object.defineProperty(this, z, { writable: true, value: void 0 }), Object.defineProperty(this, q, { writable: true, value: void 0 }), Object.defineProperty(this, X, { writable: true, value: void 0 }), Object.defineProperty(this, $, { writable: true, value: void 0 }), Object.defineProperty(this, ee, { writable: true, value: void 0 }), Object.defineProperty(this, ne, { writable: true, value: void 0 }), Object.defineProperty(this, se2, { writable: true, value: void 0 }), Object.defineProperty(this, ie, { writable: true, value: void 0 }), Object.defineProperty(this, re, { writable: true, value: void 0 }), Object.defineProperty(this, oe, { writable: true, value: void 0 }), Object.defineProperty(this, ce, { writable: true, value: void 0 }), Object.defineProperty(this, le2, { writable: true, value: void 0 }), k(this, H)[H] = {}, k(this, ne)[ne] = (e6, n5) => (k(this, H)[H][e6]?.push(n5) || (k(this, H)[H][e6] = [n5]), () => k(this, ae)[ae](e6, n5)), k(this, se2)[se2] = (e6) => {
330      null != e6 && (k(this, ee)[ee] = e6.map(({ address: e7 }) => new K({ address: e7, publicKey: base58.decode(e7) }))), k(this, te)[te]("change", { accounts: this.accounts });
331    }, k(this, ie)[ie] = async () => (k(this, te)[te]("change", { accounts: this.accounts }), { accounts: this.accounts }), k(this, re)[re] = async () => {
332      k(this, te)[te]("change", { accounts: this.accounts });
333    }, k(this, oe)[oe] = async (...e6) => {
334      let n5 = [];
335      for (let { account: t8, ...a5 } of e6) {
336        let { signature: e7 } = await k(this, X)[X].signMessage({ ...a5, address: t8.address });
337        n5.push({ signedMessage: a5.message, signature: e7 });
338      }
339      return n5;
340    }, k(this, ce)[ce] = async (...e6) => {
341      let n5 = [];
342      for (let t8 of e6) {
343        let { signature: e7 } = await k(this, X)[X].signAndSendTransaction({ ...t8, transaction: t8.transaction, address: t8.account.address, chain: t8.chain || "solana:mainnet", options: t8.options });
344        n5.push({ signature: e7 });
345      }
346      return n5;
347    }, k(this, le2)[le2] = async (...e6) => {
348      let n5 = [];
349      for (let { transaction: t8, account: a5, options: s7, chain: i5 } of e6) {
350        let { signedTransaction: e7 } = await k(this, X)[X].signTransaction({ transaction: t8, address: a5.address, chain: i5 || "solana:mainnet", options: s7 });
351        n5.push({ signedTransaction: e7 });
352      }
353      return n5;
354    }, k(this, z)[z] = e5, k(this, q)[q] = n4, k(this, Z)[Z] = t7, k(this, X)[X] = a4, k(this, ee)[ee] = [], k(this, $)[$] = true, a4.on("accountChanged", k(this, se2)[se2], this), k(this, se2)[se2](s6);
355  }
356}({ name: "Privy", version: "1.0.0", icon: "data:image/png;base64,AAABAAEAFBQAAAAAIABlAQAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAUAAAAFAgGAAAAjYkdDQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAQVJREFUeJxiYMANZIC4E4ivAPFPIP4FxDeAuB+IlfDowwBMQFwJxF+B+D8O/AOI66Bq8QJGIF6ExyB0vAqImfEZmEeCYTDcgMswPiB+T4aB34FYApuBsWQYBsP52AycToGBK7EZuJECAw9jM3AVBQbuwWZgIwUGTsZmoDkFBnpiMxAEjpJh2FV8iVsbiD+TYBgoDVrgMgwGnID4HRGGgTKBGyHDYEAaiBdCSxh0g/5AU4Q8sYYhAzEgjoGmABBOgFo2eACowFABYn0oVgViAVINkQTiZUD8DIj/ATF6GILEXgLxCiCWIsZAbiAuBeKtQHwHiEHJ6C8UfwHie0C8E4jLoWpRAAAAAP//rcbhsQAAAAZJREFUAwBYFs3VKJ0cuQAAAABJRU5ErkJggg==", wallets: [], injection: fe });
357function ye() {
358  let { ready: e5 } = p(), { user: n4 } = se(), { signMessage: t7 } = he(), { signTransaction: a4 } = pe(), { signAndSendTransaction: r6 } = function() {
359    let e6 = le(), { isHeadlessSigning: n5, openModal: t8, privy: a5 } = l(), { setModalData: s6 } = g(), { signTransaction: i5 } = pe(), r7 = b(), { user: c5 } = se(), { signWithUserSigner: d3 } = i2();
360    return { signAndSendTransaction: async ({ transaction: l2, address: h, chain: p3 = "solana:mainnet", options: f4 }) => {
361      let y2 = _(c5, h);
362      if ("privy" !== y2?.walletClientType) throw new r2("Wallet is not a Privy wallet", void 0, i.EMBEDDED_WALLET_NOT_FOUND);
363      let A2 = s(y2);
364      async function v(e7) {
365        if (f4?.sponsor) return await (async (e8) => {
366          if (!A2) throw new r2("Sponsoring transactions is only supported for wallets on the TEE stack", i.INVALID_DATA);
367          let n7 = await a(a5, d3, { chain_type: "solana", method: "signAndSendTransaction", sponsor: true, params: { transaction: m2(e8).toString("base64"), encoding: "base64" }, caip2: `solana:${(await r7(p3).rpc.getGenesisHash().send()).substring(0, 32)}`, wallet_id: y2.id });
368          if (n7.data && "hash" in n7.data) return { signature: base58.decode(n7.data.hash) };
369          throw Error("Failed to sign and send transaction");
370        })(e7);
371        let { signedTransaction: n6 } = await i5({ transaction: e7, address: h, chain: p3, options: { ...f4, uiOptions: { ...f4?.uiOptions, showWalletUIs: false } } }), { signature: t9 } = await r7(p3).sendAndConfirmTransaction(n6);
372        return { signature: t9 };
373      }
374      return n5({ showWalletUIs: f4?.uiOptions?.showWalletUIs }) ? v(l2) : new Promise(async (n6, a6) => {
375        let i6, r8, { entropyId: o4, entropyIdVerifier: d4 } = f2(c5, y2);
376        function u3(e7) {
377          return (n7) => {
378            a6(n7 instanceof r2 ? n7 : new r2("Failed to connect to wallet", n7, e7));
379          };
380        }
381        let g2 = { account: y2, transaction: l2, chain: p3, signOnly: false, uiOptions: f4?.uiOptions || {}, onConfirm: v, onSuccess: n6, onFailure: u3(i.TRANSACTION_FAILURE), isSponsored: !!f4?.sponsor }, m3 = { recoveryMethod: y2.recoveryMethod, connectingWalletAddress: y2.address, entropyId: o4, entropyIdVerifier: d4, isUnifiedWallet: A2, onCompleteNavigateTo: "StandardSignAndSendTransactionScreen", onFailure: u3(i.UNKNOWN_CONNECT_WALLET_ERROR) };
382        e6.fundingConfig && (i6 = A({ address: h, appConfig: e6, methodScreen: "FundingMethodSelectionScreen", fundWalletConfig: { ...f4, asset: "native-currency", chain: p3 }, externalSolanaFundingScreen: "FundSolWalletWithExternalSolanaWallet" }), r8 = { amount: e6.fundingConfig.defaultRecommendedAmount, asset: "SOL", chain: p3, destinationAddress: h, afterSuccessScreen: "StandardSignAndSendTransactionScreen", sourceWalletData: void 0 }), s6({ connectWallet: m3, standardSignAndSendTransaction: g2, funding: i6, solanaFundingData: r8 }), t8("EmbeddedWalletConnectingScreen");
383      });
384    } };
385  }(), c4 = (0, import_react.useMemo)(() => {
386    let e6 = [...c(n4).sort((e7, n5) => (e7.walletIndex ?? 0) - (n5.walletIndex ?? 0))], t8 = o(n4);
387    return t8.length ? [...e6, ...t8] : e6;
388  }, [n4]), d2 = (0, import_react.useMemo)(() => ({ signMessage: async ({ message: e6, address: n5, options: a5 }) => await t7({ message: e6, address: n5, options: a5 }), signTransaction: async ({ transaction: e6, address: n5, chain: t8, options: s6 }) => await a4({ transaction: e6, address: n5, chain: t8, options: s6 }), async signAndSendTransaction({ transaction: e6, address: n5, chain: t8, options: a5 }) {
389    let { signature: s6 } = await r6({ transaction: e6, address: n5, chain: t8, options: a5 });
390    return { signature: s6 };
391  } }), [t7, a4, r6]);
392  return (0, import_react.useEffect)(() => {
393    fe?.setImplementation(d2);
394  }, [d2]), (0, import_react.useEffect)(() => {
395    var n5;
396    !e5 || (n5 = we.accounts).length === c4.length && n5.every((e6, n6) => e6.address === c4[n6]?.address) || fe?.emit("accountChanged", c4);
397  }, [e5, c4]), { ready: e5, wallet: we };
398}
399function Ae() {
400  let { client: e5 } = l(), { ready: n4, wallet: t7 } = ye(), [a4, s6] = (0, import_react.useState)([]), [o4, c4] = (0, import_react.useState)([]);
401  return (0, import_react.useEffect)(() => {
402    let e6 = [t7, ...a4.filter((e7) => "solana" === e7.chainType && !!e7.wallet.features).map((e7) => e7.wallet)];
403    c4(e6);
404    let n5 = a4.flatMap((n6) => {
405      let t8 = () => c4([...e6]);
406      return n6.on("walletsUpdated", t8), { connector: n6, off: t8 };
407    }), s7 = e6.map((n6) => n6.features["standard:events"]?.on("change", () => {
408      c4([...e6]);
409    }));
410    return () => {
411      s7.forEach((e7) => e7?.()), n5.forEach(({ connector: e7, off: n6 }) => e7.off("walletsUpdated", n6));
412    };
413  }, [a4]), (0, import_react.useEffect)(() => {
414    s6(e5.connectors?.walletConnectors.filter((e6) => "solana" === e6.chainType) ?? []);
415    let n5 = () => {
416      s6(e5.connectors?.walletConnectors.filter((e6) => "solana" === e6.chainType) ?? []);
417    };
418    return e5.connectors?.on("connectorInitialized", n5), () => {
419      e5.connectors?.off("connectorInitialized", n5);
420    };
421  }, [n4, e5.connectors]), { ready: n4, wallets: o4 };
422}
423function me() {
424  let { ready: e5, wallets: n4 } = Ae();
425  return { ready: e5, wallets: (0, import_react.useMemo)(() => n4.flatMap((e6) => e6.accounts.map((n5) => new r({ wallet: e6, account: n5 }))), [n4]) };
426}
427
vendor: 2,911 bytes, lines 428-501
428// node_modules/@solana-program/system/dist/src/index.mjs
429var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
430if (false) {
431  systemErrorMessages = {
432    [SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
433    [SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
434    [SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
435    [SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
436    [SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
437    [SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
438    [SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
439    [SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
440    [SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
441  };
442}
443function expectAddress(value) {
444  if (!value) {
445    throw new Error("Expected a Address.");
446  }
447  if (typeof value === "object" && "address" in value) {
448    return value.address;
449  }
450  if (Array.isArray(value)) {
451    return value[0];
452  }
453  return value;
454}
455function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
456  return (account) => {
457    if (!account.value) {
458      return;
459    }
460    const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
461    return Object.freeze({
462      address: expectAddress(account.value),
463      role: isTransactionSigner2(account.value) ? upgradeRoleToSigner(writableRole) : writableRole,
464      ...isTransactionSigner2(account.value) ? { signer: account.value } : {}
465    });
466  };
467}
468function isTransactionSigner2(value) {
469  return !!value && typeof value === "object" && "address" in value && isTransactionSigner(value);
470}
471var TRANSFER_SOL_DISCRIMINATOR = 2;
472function getTransferSolInstructionDataEncoder() {
473  return transformEncoder(
474    getStructEncoder([
475      ["discriminator", getU32Encoder()],
476      ["amount", getU64Encoder()]
477    ]),
478    (value) => ({ ...value, discriminator: TRANSFER_SOL_DISCRIMINATOR })
479  );
480}
481function getTransferSolInstruction(input, config) {
482  const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
483  const originalAccounts = {
484    source: { value: input.source ?? null, isWritable: true },
485    destination: { value: input.destination ?? null, isWritable: true }
486  };
487  const accounts = originalAccounts;
488  const args = { ...input };
489  const getAccountMeta = getAccountMetaFactory();
490  return Object.freeze({
491    accounts: [
492      getAccountMeta(accounts.source),
493      getAccountMeta(accounts.destination)
494    ],
495    data: getTransferSolInstructionDataEncoder().encode(
496      args
497    ),
498    programAddress
499  });
500}
501
vendor: 9,281 bytes, lines 502-585
502// node_modules/@privy-io/react-auth/dist/esm/FundSolWalletWithExternalSolanaWallet-D6BbKHlH.mjs
503var import_react_device_detect = __toESM(require_lib(), 1);
504function K2({ rows: a4 }) {
505  return (0, import_jsx_runtime.jsx)(t5, { children: a4.filter((t7) => !!t7).map((a5, n4) => null != a5.value || a5.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(s4, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(e3, { children: a5.label }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(n3, { $isLoading: a5.isLoading, children: a5.value })] }, n4) : null) });
506}
507function Z2(t7) {
508  return BigInt(Math.floor(1e9 * parseFloat(t7)));
509}
510function tt(t7) {
511  return +et.format(parseFloat(t7.toString()) / 1e9);
512}
513var et = Intl.NumberFormat(void 0, { maximumFractionDigits: 8 });
514async function at({ tx: t7, solanaClient: e5, amount: a4, asset: n4, tokenPrice: o4 }) {
515  if (!t7) return null;
516  if ("SOL" === n4 && o4) {
517    let n5 = Z2(a4), r6 = C(n5, o4), i5 = await f3({ solanaClient: e5, tx: t7 });
518    return { amountInUsd: r6, feeInUsd: o4 ? C(i5, o4) : void 0, totalInUsd: C(n5 + i5, o4) };
519  }
520  if ("USDC" === n4 && o4) {
521    let n5 = "$" + a4, r6 = await f3({ solanaClient: e5, tx: t7 }), i5 = function(t8, e6) {
522      let a5 = parseFloat(t8.toString()) / s3 * e6;
523      return a5 < 0.01 ? 0 : a5;
524    }(r6, o4);
525    return { amountInUsd: n5, feeInUsd: C(r6, o4), totalInUsd: "$" + (parseFloat(a4) + i5).toFixed(2) };
526  }
527  if ("SOL" === n4) {
528    let n5 = Z2(a4), o5 = await f3({ solanaClient: e5, tx: t7 });
529    return { amountInSol: a4 + " SOL", feeInSol: tt(o5) + " SOL", totalInSol: tt(n5 + o5) + " SOL" };
530  }
531  return { amountInUsdc: a4 + " USDC", feeInSol: tt(await f3({ solanaClient: e5, tx: t7 })) + " SOL" };
532}
533var nt = { component: function() {
534  let v = le(), { closePrivyModal: j, createAnalyticsEvent: w } = l(), { data: I, setModalData: V2, navigate: z2 } = g(), { wallets: tt2 } = me(), [et2, nt2] = (0, import_react2.useState)("preparing"), [ot, rt] = (0, import_react2.useState)(), [it, st] = (0, import_react2.useState)(), [lt, mt] = (0, import_react2.useState)();
535  if (!I?.solanaFundingData) throw Error("Funding config is missing");
536  if (!I.solanaFundingData.sourceWalletData) throw Error("Funding config is missing source wallet data");
537  let { amount: ct, asset: dt, chain: ut, sourceWalletData: pt, destinationAddress: ft, afterSuccessScreen: gt } = I.solanaFundingData, ht = tt2.find((t7) => t7.address === pt.address && G(pt.walletClientType) === G(t7.standardWallet.name)), vt = b()(ut), { tokenPrice: jt, isTokenPriceLoading: wt } = c3("solana");
538  return (0, import_react2.useEffect)(() => {
539    if ("preparing" !== et2 || wt || !ht) return;
540    let t7 = "SOL" === dt ? Z2(ct) : function(t8) {
541      return BigInt(Math.floor(1e6 * parseFloat(t8)));
542    }(ct);
543    st({ amount: ("SOL" === dt && jt ? C(t7, jt) : ct) ?? ct }), ("SOL" === dt ? async function({ solanaClient: t8, source: e5, destination: a4, amountInLamports: n4 }) {
544      let { value: o4 } = await t8.rpc.getLatestBlockhash().send(), r6 = { address: e5 }, i5 = pipe(createTransactionMessage({ version: 0 }), (t9) => setTransactionMessageFeePayerSigner(r6, t9), (t9) => setTransactionMessageLifetimeUsingBlockhash(o4, t9), (t9) => appendTransactionMessageInstruction(getTransferSolInstruction({ amount: n4, source: r6, destination: a4 }), t9), (t9) => compileTransaction(t9));
545      return new Uint8Array(getTransactionEncoder().encode(i5));
546    }({ solanaClient: vt, source: ht.address, destination: ft, amountInLamports: t7 }) : async function({ solanaClient: t8, source: e5, destination: a4, amountInBaseUnits: n4 }) {
547      let o4 = r3(t8.chain), { value: r6 } = await t8.rpc.getLatestBlockhash().send(), i5 = { address: e5 }, [s6] = await findAssociatedTokenPda({ mint: o4, owner: e5, tokenProgram: e2 }), [l2] = await findAssociatedTokenPda({ mint: o4, owner: a4, tokenProgram: e2 }), [m3, c4] = await Promise.all([t8.rpc.getAccountInfo(s6, { commitment: "confirmed", encoding: "jsonParsed" }).send().catch(() => null), t8.rpc.getAccountInfo(l2, { commitment: "confirmed", encoding: "jsonParsed" }).send().catch(() => null)]);
548      if (!m3?.value) throw Error(`Source token account does not exist for address: ${e5}`);
549      let d2 = getCreateAssociatedTokenIdempotentInstruction({ payer: i5, ata: l2, owner: a4, mint: o4 }), u3 = pipe(createTransactionMessage({ version: 0 }), (t9) => setTransactionMessageFeePayerSigner(i5, t9), (t9) => setTransactionMessageLifetimeUsingBlockhash(r6, t9), (t9) => c4?.value ? t9 : appendTransactionMessageInstruction(d2, t9), (t9) => appendTransactionMessageInstruction(getTransferInstruction({ source: s6, destination: l2, authority: i5, amount: n4 }), t9), (t9) => compileTransaction(t9));
550      return new Uint8Array(getTransactionEncoder().encode(u3));
551    }({ solanaClient: vt, source: ht.address, destination: ft, amountInBaseUnits: t7 })).then(rt).catch((t8) => {
552      nt2("error"), mt(t8);
553    });
554  }, [et2, ct, dt, ut, ht, ft, wt, jt]), (0, import_react2.useEffect)(() => {
555    "preparing" === et2 && ot && at({ tx: ot, solanaClient: vt, amount: ct, asset: dt, tokenPrice: jt }).then((t7) => {
556      nt2("loaded"), st({ amount: t7?.amountInUsd ?? t7?.amountInUsdc ?? t7?.amountInSol ?? ct, fee: t7?.feeInUsd ?? t7?.feeInSol, total: t7?.totalInUsd ?? t7?.totalInSol });
557    }).catch((t7) => {
558      nt2("error"), mt(t7);
559    });
560  }, [ot, ct, dt, et2, jt]), (0, import_react2.useEffect)(() => {
561    "error" === et2 && lt && (V2({ errorModalData: { error: lt, previousScreen: "FundSolWalletWithExternalSolanaWallet" }, solanaFundingData: I.solanaFundingData }), z2("ErrorScreen", false));
562  }, [et2, z2]), (0, import_react2.useEffect)(() => {
563    if ("success" !== et2) return;
564    let t7 = setTimeout(gt ? () => z2(gt) : j, f);
565    return () => clearTimeout(t7);
566  }, [et2]), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, "success" === et2 ? { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(t3, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(c2, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(n2, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckCircleIcon_default, { color: "var(--privy-color-success)", width: "64px", height: "64px" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(o2, { title: "Success!", description: `You\u2019ve successfully added ${ct} ${dt} to your ${v.name} wallet. It may take a minute before the funds are available to use.` })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(s2, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(u, {})] } : "preparing" === et2 || "loaded" === et2 || "sending" === et2 ? { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(t3, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(t2, { style: { marginTop: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(i3, { icon: ht?.standardWallet.icon, name: ht?.standardWallet.name }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(o2, { style: { marginTop: "8px", marginBottom: "12px" }, title: "sending" === et2 && ht ? `Confirming with ${ht.standardWallet.name}` : "Confirm transaction" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(K2, { rows: [{ label: "Source", value: n(pt.address) }, { label: "Destination", value: n(ft) }, { label: "Network", value: e(ut) }, { label: "Amount", value: it?.amount, isLoading: "preparing" === et2 }, { label: "Estimated fee", value: it?.fee, isLoading: "preparing" === et2 }, { label: "Total", value: it?.total, isLoading: "preparing" === et2 }] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(m, { style: { marginTop: "1rem" }, loading: "preparing" === et2 || "sending" === et2, onClick: function() {
567    "loaded" === et2 && ot && ht && (nt2("sending"), async function({ transaction: t7, chain: e5, sourceWallet: a4, solanaClient: n4 }) {
568      let { hasFunds: o4 } = await p2({ solanaClient: n4, tx: t7 });
569      if (!o4) throw new r2(`Wallet ${n(a4.address)} does not have enough funds.`, void 0, i.INSUFFICIENT_BALANCE);
570      let r6 = P((await a4.signAndSendTransaction({ transaction: t7, chain: e5 }).catch((t8) => {
571        throw new r2("Transaction was rejected by the user", t8, i.TRANSACTION_FAILURE);
572      })).signature);
573      return await d({ rpcSubscriptions: n4.rpcSubscriptions, signature: r6, timeout: 2e4 }), r6;
574    }({ solanaClient: vt, transaction: ot, chain: ut, sourceWallet: ht }).then((t7) => {
575      nt2("success"), w({ eventName: t4, payload: { provider: "external", status: "success", txHash: t7, address: ht.address, value: ct, chainType: "solana", clusterName: ut, token: dt, destinationAddress: ft, destinationValue: ct, destinationChainType: "solana", destinationClusterName: ut, destinationToken: dt } });
576    }).catch((t7) => {
577      nt2("error"), mt(t7);
578    }));
579  }, children: "Confirm" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(u, {})] } : { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(t3, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(t, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { marginTop: "1rem" } }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(u, {})] });
580} };
581export {
582  nt as FundSolWalletWithExternalSolanaWallet,
583  nt as default
584};
585//# sourceMappingURL=FundSolWalletWithExternalSolanaWallet-D6BbKHlH-HBU6KC3S.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.