PageSourceSearch

https://www.dibaapp.com/assets/ExternalTransferPage-DvhBPALk.js

js dibaapp.com collected 2026-10-04 06:55:29 UTC 19,150 bytes, 1 lines download raw bytes

1import{u as Se,E as ke,k as se,r,Q as Ae,J as _e,v as De,j as e,L as ae,y as Ee,c as Te,p as Ie,z as Pe,g as Re,B as $e,T as Be}from"./index-D6UrFXqh.js";import{d as re,A as ne,X as Le}from"./AppShell-DKhCxBd5.js";import{R as Ue}from"./receipt-text-CGAt5bvL.js";import{A as Me}from"./arrow-left-DJrC1F0y.js";import{W as Fe}from"./appContent-Bmmk0ks2.js";import{A as le}from"./Logo-VUZnl8oB.js";import{A as B}from"./alert-triangle-BvkLpSCp.js";import{L as qe}from"./lock-keyhole-BMrtgtHr.js";import{C as ze}from"./check-circle-2-BBTiHial.js";import{C as Oe}from"./clock-3-BjHL3Gay.js";import"./shield-check-Nz0OL0hG.js";import"./createLucideIcon-DBOTLUhc.js";import"./sparkles-DMSCgezF.js";import"./help-circle-DfpDRC0m.js";import"./file-text-DXawlq-x.js";const We=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/,Ye=/^0x[a-fA-F0-9]{40}$/,ie=/^\d+(?:\.\d{1,8})?$/,oe=()=>`external-transfer-${typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}`,h=(n,u)=>{const l=Number(n);return`${new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:8}).format(Number.isFinite(l)?l:0)} ${u.toUpperCase()}`},p=n=>n?n.split("_").filter(Boolean).map(u=>`${u.charAt(0).toUpperCase()}${u.slice(1).toLowerCase()}`).join(" "):"Submitted",Je=n=>new Intl.DateTimeFormat("en-US",{day:"2-digit",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(n?new Date(n):new Date),L=n=>{const u=n.trim();return u.length<=12?u:`${u.slice(0,6)}…${u.slice(-4)}`},Ve=n=>["completed","payment_processed","successful","success"].includes((n==null?void 0:n.toLowerCase())??""),Ge=n=>["failed","canceled","cancelled","rejected","returned"].includes((n==null?void 0:n.toLowerCase())??""),dt=()=>{var H,K,Q,X,Z,ee;const n=Se(),[u]=ke(),l=se(),C=((H=u.get("currency"))==null?void 0:H.trim().toLowerCase())??"",P=((K=u.get("chain"))==null?void 0:K.trim().toLowerCase())??"",[D,N]=r.useState("details"),[m,U]=r.useState(""),[i,M]=r.useState(""),[o,F]=r.useState(C),[g,q]=r.useState(C),[y,ce]=r.useState(""),[S,z]=r.useState(""),[k,E]=r.useState(""),[de,me]=r.useState(oe),[b,xe]=r.useState(()=>l!=null&&l.access?Ae(l.access):null),[ue,O]=r.useState(!!(l!=null&&l.access&&!b)),[W,Y]=r.useState(""),[R,J]=r.useState(!1),[T,c]=r.useState(""),[s,fe]=r.useState(null),j=r.useMemo(()=>((b==null?void 0:b.wallets)??[]).filter(t=>t.balances.length>0).map(t=>t.chain),[b]),f=r.useMemo(()=>re(b,m),[m,b]),I=r.useMemo(()=>re(b,i),[i,b]),w=r.useMemo(()=>Array.from(new Set(((f==null?void 0:f.balances)??[]).filter(t=>t.chain===m).map(t=>t.currency))),[m,f]),A=r.useMemo(()=>Array.from(new Set(((I==null?void 0:I.balances)??[]).filter(t=>t.chain===i).map(t=>t.currency))),[i,I]),V=r.useMemo(()=>{const t=Object.fromEntries(w.map(a=>[a,0]));for(const a of(f==null?void 0:f.balances)??[]){const x=a.currency.toLowerCase(),v=Number(a.balance);a.chain.toLowerCase()===m&&Number.isFinite(v)&&(t[x]=v)}return t},[m,w,f]),pe=!!(b&&f&&o),he=Number(y),$=V[o]??0,be=!!(pe&&ie.test(y.trim())&&he>$);r.useEffect(()=>{const t=se();if(!t){n("/login",{replace:!0});return}if(t.user.is_pin_set===!1){n("/dashboard/set-pin",{replace:!0,state:{action:"your external wallet transfer",from:"/dashboard/send/external"}});return}typeof t.user.is_pin_set!="boolean"&&_e(t).then(a=>{(a==null?void 0:a.user.is_pin_set)===!1&&n("/dashboard/set-pin",{replace:!0,state:{action:"your external wallet transfer",from:"/dashboard/send/external"}})})},[n,l==null?void 0:l.access,l==null?void 0:l.user.is_pin_set]),r.useEffect(()=>{if(!(l!=null&&l.access)){O(!1);return}let t=!0;return De(l.access).then(a=>{t&&(xe(a),Y(""))}).catch(()=>{t&&Y("We could not verify your balance. The transfer service will validate it before submitting.")}).finally(()=>{t&&O(!1)}),()=>{t=!1}},[l==null?void 0:l.access]),r.useEffect(()=>{j.includes(m)||U(j.includes(P)?P:j[0]??""),j.includes(i)||M(j[0]??"")},[j,i,P,m]),r.useEffect(()=>{if(!w.includes(o)){const t=w.includes(C)?C:w[0]??"";F(t)}},[C,w,o]),r.useEffect(()=>{if(!A.includes(g)){const t=A.includes(o)?o:A[0]??"";q(t)}},[A,g,o]);const ge=t=>i==="solana"?We.test(t):i==="ethereum"||i==="base"?Ye.test(t):t.length>=10,G=()=>{const t=y.trim(),a=S.trim();if(!ie.test(t)||Number(t)<=0)return"Enter a valid amount using no more than 8 decimal places.";if(be)return`Insufficient ${o.toUpperCase()} balance. You have ${h($,o)} available.`;if(!m||!w.includes(o))return"Select a supported source network and asset.";if(!i||!A.includes(g))return"Select a supported destination network and asset.";if(!ge(a))return`Enter a valid ${p(i)} wallet address.`;const x=f==null?void 0:f.address.trim();return x&&a===x?"Enter a destination wallet address different from your Diba wallet.":""},ye=()=>{const t=G();if(t){c(t);return}me(oe()),c(""),N("review")},je=async()=>{const t=G();if(t){c(t),N("details");return}if(k.length!==4){c("Enter your 4-digit PIN.");return}J(!0),c("");try{const a=await Ee(Te.externalTransfer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pin:k,amount:y.trim(),client_request_id:de,source:{currency:o,chain:m},destination:{currency:g,payment_rail:i,to_address:S.trim()}})}),x=await Ie(a);if(!a.ok){const v=Pe(x,a.status);if(v){c(v.message);return}c(Re(x,a.status,{fallback:"We could not submit this external wallet transfer.",serverError:"The external transfer service is having trouble right now. Please try again shortly.",fieldOrder:["pin","amount","client_request_id","source","destination","to_address","non_field_errors"],fieldLabels:{pin:"PIN",amount:"Amount",client_request_id:"Request ID",source:"Source",destination:"Destination",to_address:"Wallet address"}})),E("");return}$e(),Be(),fe(x??{}),E(""),N("result")}catch{c("Network or server error. Please try again with the same request."),E("")}finally{J(!1)}};if(D==="result"){const t=s==null?void 0:s.state,a=Ve(t),x=Ge(t),v=a?ze:x?B:Oe,we=a?"bg-emerald-500 text-white":x?"bg-red-500 text-white":"bg-amber-500 text-white",Ne=a?"text-emerald-600":x?"text-red-600":"text-amber-600",ve=((Q=s==null?void 0:s.destination)==null?void 0:Q.to_address)||S,_=((X=s==null?void 0:s.source)==null?void 0:X.currency)||o,d=s==null?void 0:s.receipt;return e.jsx(ne,{children:e.jsxs("div",{className:"mx-auto max-w-xl rounded-2xl bg-white p-5 shadow-lg shadow-slate-200/80 sm:p-7",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:`mx-auto inline-flex h-16 w-16 items-center justify-center rounded-full ${we}`,children:e.jsx(v,{className:"h-8 w-8"})}),e.jsx("h1",{className:`mt-5 text-2xl font-bold ${Ne}`,children:a?"Transfer completed":x?"Transfer failed":"Transfer submitted"}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-slate-500",children:a?"Your transfer has been processed.":x?"The external transfer could not be completed.":"Your transfer is being reviewed. Its final status will appear in transaction history."}),e.jsx("p",{className:"mt-4 text-3xl font-black text-slate-950",children:h((s==null?void 0:s.amount)||y,_)})]}),e.jsxs("section",{className:"mt-6 overflow-hidden rounded-2xl border border-primary/10",children:[e.jsx("div",{className:"bg-primary/10 px-4 py-3 text-center",children:e.jsx("h2",{className:"text-sm font-bold text-slate-800",children:"Transfer Details"})}),e.jsx("div",{className:"space-y-3 px-4 py-4 text-sm",children:[["Status",p(t)],["Destination wallet",L(ve)],["Source network",p(m)],["Destination network",p(((Z=s==null?void 0:s.destination)==null?void 0:Z.payment_rail)||i)],["Source asset",_.toUpperCase()],["Destination asset",(((ee=s==null?void 0:s.destination)==null?void 0:ee.currency)||g).toUpperCase()],...(d==null?void 0:d.gas_fee)!==void 0?[["Gas fee",h(d.gas_fee,_)]]:[],...(d==null?void 0:d.exch
1ange_fee)!==void 0?[["Exchange fee",h(d.exchange_fee,_)]]:[],...(d==null?void 0:d.developer_fee)!==void 0?[["Developer fee",h(d.developer_fee,_)]]:[],...(d==null?void 0:d.final_amount)!==void 0?[["Final amount",h(d.final_amount,_)]]:[],["Time",Je(s==null?void 0:s.created_at)],["Transfer ID",(s==null?void 0:s.id)||"Pending reference"]].map(([te,Ce])=>e.jsxs("div",{className:"grid grid-cols-[minmax(110px,0.8fr)_minmax(0,1.2fr)] items-start gap-3",children:[e.jsx("span",{className:"text-slate-500",children:te}),e.jsx("span",{className:"break-all text-right font-bold text-slate-800",children:Ce})]},te))})]}),e.jsxs("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:[e.jsxs(ae,{to:"/dashboard/history",className:"inline-flex items-center justify-center gap-2 rounded-xl bg-primary px-4 py-3 text-sm font-bold text-white transition hover:bg-primary-dark",children:[e.jsx(Ue,{className:"h-4 w-4"}),"Transaction history"]}),e.jsx("button",{type:"button",onClick:()=>n("/dashboard/send"),className:"inline-flex items-center justify-center rounded-xl border border-slate-200 px-4 py-3 text-sm font-bold text-slate-600 transition hover:bg-slate-50",children:"Done"})]})]})})}return e.jsx(ne,{children:e.jsxs("div",{className:"mx-auto max-w-4xl space-y-5",children:[e.jsxs(ae,{to:"/dashboard/send",className:"inline-flex items-center gap-2 text-sm font-semibold text-slate-500 transition hover:text-primary",children:[e.jsx(Me,{className:"h-4 w-4"}),"Send Money"]}),e.jsx("section",{className:"rounded-2xl bg-primary p-5 text-white shadow-lg shadow-primary/20 sm:p-6",children:e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:"External transfer"}),e.jsx("h1",{className:"mt-2 text-3xl font-bold",children:"Send to an external wallet"}),e.jsx("p",{className:"mt-3 max-w-xl text-sm font-medium leading-relaxed text-white/75",children:"Send supported stablecoins across available networks to a wallet outside Diba."})]}),e.jsx("span",{className:"hidden h-20 w-20 shrink-0 items-center justify-center rounded-2xl bg-white/15 sm:inline-flex",children:e.jsx(Fe,{className:"h-10 w-10"})})]})}),T&&D!=="pin"&&e.jsx("p",{className:"rounded-xl border border-red-100 bg-red-50 px-4 py-3 text-sm font-semibold text-red-600",children:T}),D==="details"&&e.jsxs("section",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.2fr)_minmax(260px,0.8fr)]",children:[e.jsxs("div",{className:"rounded-2xl bg-white p-5 shadow-lg shadow-slate-200/80 sm:p-6",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Source network"}),e.jsx("select",{value:m,onChange:t=>{U(t.target.value),c("")},className:"mt-2 h-12 w-full rounded-xl border border-slate-200 bg-white px-4 text-sm font-semibold text-slate-800 outline-none focus:border-primary focus:ring-4 focus:ring-primary/10",children:j.map(t=>e.jsx("option",{value:t,children:p(t)},t))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Source asset"}),e.jsx("select",{value:o,onChange:t=>{F(t.target.value),c("")},className:"mt-2 h-12 w-full rounded-xl border border-slate-200 bg-white px-4 text-sm font-semibold text-slate-800 outline-none focus:border-primary focus:ring-4 focus:ring-primary/10",children:w.map(t=>e.jsxs("option",{value:t,children:[t.toUpperCase()," | ",h(V[t]??0,t)," available"]},t))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Destination network"}),e.jsx("select",{value:i,onChange:t=>{M(t.target.value),z(""),c("")},className:"mt-2 h-12 w-full rounded-xl border border-slate-200 bg-white px-4 text-sm font-semibold text-slate-800 outline-none focus:border-primary focus:ring-4 focus:ring-primary/10",children:j.map(t=>e.jsx("option",{value:t,children:p(t)},t))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Destination asset"}),e.jsx("select",{value:g,onChange:t=>{q(t.target.value),c("")},className:"mt-2 h-12 w-full rounded-xl border border-slate-200 bg-white px-4 text-sm font-semibold text-slate-800 outline-none focus:border-primary focus:ring-4 focus:ring-primary/10",children:A.map(t=>e.jsx("option",{value:t,children:t.toUpperCase()},t))})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Destination wallet address"}),e.jsx("input",{type:"text",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,value:S,onChange:t=>{z(t.target.value.trim()),c("")},placeholder:`Enter a ${p(i)} wallet address`,className:"mt-2 h-12 w-full rounded-xl border border-slate-200 px-4 font-mono text-sm text-slate-800 outline-none focus:border-primary focus:ring-4 focus:ring-primary/10"}),e.jsx("span",{className:"mt-2 block text-xs font-semibold text-slate-400",children:"Confirm that the destination address supports the selected network and asset."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Amount"}),e.jsx("input",{type:"number",inputMode:"decimal",min:"0",step:"0.00000001",value:y,onChange:t=>{ce(t.target.value),c("")},placeholder:"0.00",className:"mt-2 h-12 w-full rounded-xl border border-slate-200 px-4 text-sm font-semibold text-slate-800 outline-none focus:border-primary focus:ring-4 focus:ring-primary/10"}),e.jsx("span",{className:"mt-2 block text-xs font-semibold text-slate-400",children:ue?"Loading balance...":`${h($,o)} available`})]}),W&&e.jsx("p",{className:"rounded-xl border border-amber-100 bg-amber-50 px-4 py-3 text-sm font-semibold text-amber-700",children:W})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsxs("button",{type:"button",onClick:ye,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-primary px-5 py-3 text-sm font-bold text-white transition hover:bg-primary-dark",children:["Review transfer",e.jsx(le,{className:"h-4 w-4"})]})})]}),e.jsxs("aside",{className:"rounded-2xl bg-white p-5 shadow-lg shadow-slate-200/80",children:[e.jsx("p",{className:"text-xs font-bold uppercase text-slate-400",children:"Before you send"}),e.jsxs("div",{className:"mt-4 flex gap-3 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800",children:[e.jsx(B,{className:"mt-0.5 h-5 w-5 shrink-0"}
1),e.jsx("p",{className:"leading-relaxed",children:"External wallet transfers cannot usually be reversed. Confirm the network, asset, and address carefully."})]}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"font-semibold text-slate-500",children:"Network"}),e.jsxs("span",{className:"font-bold text-slate-800",children:[p(m)," to ",p(i)]})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"font-semibold text-slate-500",children:"Asset"}),e.jsxs("span",{className:"font-bold text-slate-800",children:[o.toUpperCase()," ? ",g.toUpperCase()]})]})]})]})]}),D==="review"&&e.jsxs("section",{className:"mx-auto max-w-xl rounded-2xl bg-white p-5 shadow-lg shadow-slate-200/80 sm:p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-slate-950",children:"Review external transfer"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:"Confirm every detail before continuing to your PIN."}),e.jsx("div",{className:"mt-6 space-y-4 rounded-2xl bg-slate-50 p-4 text-sm",children:[["You send",h(y,o)],["Recipient receives",h(y,g)],["Source network",p(m)],["Destination network",p(i)],["Destination wallet",L(S)]].map(([t,a])=>e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("span",{className:"font-semibold text-slate-500",children:t}),e.jsx("span",{className:"max-w-[65%] break-all text-right font-bold text-slate-900",children:a})]},t))}),e.jsxs("div",{className:"mt-5 flex gap-3 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800",children:[e.jsx(B,{className:"mt-0.5 h-5 w-5 shrink-0"}),e.jsxs("p",{children:["Make sure this wallet supports ",g.toUpperCase()," on ",p(i),". Sending to the wrong network or address may permanently lose the funds."]})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row",children:[e.jsx("button",{type:"button",onClick:()=>N("details"),className:"inline-flex flex-1 items-center justify-center rounded-xl border border-slate-200 px-4 py-3 text-sm font-bold text-slate-600 transition hover:bg-slate-50",children:"Edit details"}),e.jsxs("button",{type:"button",onClick:()=>{c(""),N("pin")},className:"inline-flex flex-1 items-center justify-center gap-2 rounded-xl bg-primary px-4 py-3 text-sm font-bold text-white transition hover:bg-primary-dark",children:["Continue to PIN",e.jsx(le,{className:"h-4 w-4"})]})]})]}),D==="pin"&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-slate-950/40 px-4 py-6 backdrop-blur-[2px] sm:items-center",children:e.jsxs("div",{className:"w-full max-w-sm rounded-2xl bg-white p-5 text-center shadow-2xl shadow-slate-950/20",children:[e.jsx("button",{type:"button",onClick:()=>N("review"),className:"ml-auto flex h-8 w-8 items-center justify-center rounded-full border border-slate-200 text-slate-500 transition hover:text-slate-800","aria-label":"Back to transfer review",children:e.jsx(Le,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-auto mt-1 inline-flex h-14 w-14 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(qe,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-4 text-lg font-bold text-slate-950",children:"Enter Transaction PIN"}),e.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-slate-500",children:["Authorize ",h(y,o)," to ",L(S),"."]}),e.jsxs("label",{className:"mt-5 block",children:[e.jsx("span",{className:"sr-only",children:"Transaction PIN"}),e.jsx("input",{type:"password",inputMode:"numeric",autoComplete:"one-time-code",value:k,onChange:t=>{E(t.target.value.replace(/\D/g,"").slice(0,4)),c("")},className:"sr-only",autoFocus:!0}),e.jsx("span",{className:"flex justify-center gap-3","aria-hidden":"true",children:[0,1,2,3].map(t=>e.jsx("span",{className:`flex h-12 w-12 items-center justify-center rounded-xl border text-lg font-bold ${k[t]?"border-primary bg-primary/10 text-primary":"border-slate-200 bg-slate-50 text-slate-300"}`,children:k[t]?"•":""},t))})]}),T&&e.jsx("p",{className:"mt-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm font-semibold text-red-600",children:T}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row",children:[e.jsx("button",{type:"button",onClick:()=>N("review"),disabled:R,className:"inline-flex flex-1 items-center justify-center rounded-xl border border-slate-200 px-4 py-3 text-sm font-bold text-slate-600 transition hover:bg-slate-50 disabled:opacity-60",children:"Back"}),e.jsx("button",{type:"button",onClick:je,disabled:R||k.length!==4,className:"inline-flex flex-1 items-center justify-center rounded-xl bg-primary px-4 py-3 text-sm font-bold text-white transition hover:bg-primary-dark disabled:cursor-not-allowed disabled:opacity-60",children:R?"Submitting...":"Confirm transfer"})]})]})})]})})};export{dt as default};

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.