PageSourceSearch

https://www.xstable.ai/_next/static/chunks/6979.c37a30dbe2f711d3.js

js xstable.ai collected 2026-10-05 14:39:14 UTC 10,357 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6979],{49360:(e,t,a)=>{a.r(t),a.d(t,{default:()=>k});var s=a(80069),n=a(7844),r=a(17582),d=a(52644),l=a(73957),o=a(81838),c=a(69493),i=a(46945),u=a(85394),g=a(71432),x=a(75772),b=a(65470),f=a(64776),m=a(96788),h=a(69760),p=a(20801);let w="a91487f22b50836d9b62f576d6ba9dff";function v(){let{open:e}=(0,c.B)(),{isConnected:t,isConnecting:a,address:l,wallet:o,chain:u,status:x}=(0,i.w)({namespaceId:"solana"}),[b,f]=(0,p.useState)("TrustConnect Solana signMessage test"),[v,k]=(0,p.useState)(""),[N,C]=(0,p.useState)(""),[M,W]=(0,p.useState)(),[T,E]=(0,p.useState)(),[A,D]=(0,p.useState)("idle"),[O,P]=(0,p.useState)(""),[_,K]=(0,p.useState)(""),[F,V]=(0,p.useState)(""),[I,R]=(0,p.useState)(""),[q,B]=(0,p.useState)(""),[L,X]=(0,p.useState)(""),z=(0,g.Y)({mutationOptions:{onSuccess(e){k(h.A.encode(e.signature)),C(new TextDecoder().decode(e.signedMessage)),W(e.signature),E(e.signedMessage),D("idle"),P(""),K("")}}}),H=async()=>{if(!l||!M||!T){D("error"),K("Connect wallet and sign a message before verifying.");return}try{let e=h.A.decode(l),t=t=>n.ev.verify(M,t,e);if(t(T)){D("valid"),P("raw-message"),K("");return}let a=new TextEncoder().encode(h.A.encode(T)),s=t(a);D(s?"valid":"invalid"),P(s?"walletconnect-base58-message":""),K("")}catch(e){D("error"),P(""),K(e instanceof Error?e.message:"Failed to verify signature.")}},J=async()=>{V(""),R("");try{let e=(0,m.d)().get().find(e=>e.name.toLowerCase().includes("trust")&&!!e.features[r.F]);if(!e)throw Error("Trust Wallet Standard provider not found.");let t=e.features["standard:connect"],a=e.features[r.F];if(!(null==t?void 0:t.connect)||!(null==a?void 0:a.signMessage))throw Error("Trust Wallet does not expose required Wallet Standard features.");let s=(await t.connect()).accounts[0]||e.accounts[0];if(!s)throw Error("Trust Wallet did not return a Solana account.");let d=new TextEncoder().encode(b),[l]=await a.signMessage({account:s,message:d});if(!l)throw Error("Trust Wallet did not return a signature.");let o=n.ev.verify(l.signature,l.signedMessage,s.publicKey);V(["Wallet: ".concat(e.name),"Address: ".concat(s.address),"Public key (bs58): ".concat(h.A.encode(s.publicKey)),"Public key bytes: ".concat(s.publicKey.length),"Address matches public key: ".concat(s.address===h.A.encode(s.publicKey)?"true":"false"),"Signed message: ".concat(new TextDecoder().decode(l.signedMessage)),"Signed message bytes: ".concat(l.signedMessage.length),"Signature bytes: ".concat(l.signature.length),"Signature (bs58): ".concat(h.A.encode(l.signature)),"Verified: ".concat(o?"true":"false")].join("\n"))}catch(e){R(e instanceof Error?e.message:"Failed to sign with Wallet Standard.")}},Q=async()=>{B(""),X("");try{let e=(0,m.d)().get().find(e=>e.name.toLowerCase().includes("trust")&&!!e.features[d.l]);if(!e)throw Error("Trust Wallet does not expose solana:signOffchainMessage.");let t=e.features["standard:connect"],a=e.features[d.l];if(!(null==t?void 0:t.connect)||!(null==a?void 0:a.signOffchainMessage))throw Error("Trust Wallet does not expose required offchain message features.");let s=(await t.connect()).accounts[0]||e.accounts[0];if(!s)throw Error("Trust Wallet did not return a Solana account.");let[r]=await a.signOffchainMessage({account:s,message:b,messageVersion:1,requiredSigners:[s.publicKey]});if(!r)throw Error("Trust Wallet did not return an offchain signature.");let l=n.ev.verify(r.signature,r.signedOffchainMessage,s.publicKey);B(["Wallet: ".concat(e.name),"Address: ".concat(s.address),"Public key (bs58): ".concat(h.A.encode(s.publicKey)),"Signed offchain message bytes: ".concat(r.signedOffchainMessage.length),"Signature bytes: ".concat(r.signature.length),"Signature (bs58): ".concat(h.A.encode(r.signature)),"Verified: ".concat(l?"true":"false")].join("\n"))}catch(e){X(e instanceof Error?e.message:"Failed to sign offchain message.")}};return(0,s.jsx)("main",{className:"min-h-screen bg-[#f6f7f9] px-4 py-8 text-[#111827] dark:bg-[#111318] dark:text-white",children:(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-[720px] flex-col gap-5",children:[(0,s.jsxs)("header",{className:"flex flex-col gap-2",children:[(0,s.jsx)("h1",{className:"text-2xl font-600",children:"TrustConnect Solana SignMessage"}),(0,s.jsx)("p",{className:"text-sm text-[#6b7280] dark:text-[#a1a1aa]",children:"Test Trust Wallet Solana connection and signMessage on devnet."})]}),!w&&(0,s.jsx)("div",{className:"rounded-[8px] border border-[#f59e0b] bg-[#fffbeb] p-3 text-sm text-[#92400e]",children:"NEXT_PUBLIC_PROJECT_ID is not configured. WalletConnect QR connection may not work."}),(0,s.jsxs)("section",{className:"rounded-[8px] border border-[#e5e7eb] bg-white p-4 dark:border-[#2b2f38] dark:bg-[#181b22]",children:[(0,s.jsxs)("div",{className:"grid gap-3 text-sm",children:[(0,s.jsx)(y,{label:"Status",value:x}),(0,s.jsx)(y,{label:"Wallet",value:(null==o?void 0:o.name)||"-"}),(0,s.jsx)(y,{label:"Address",value:l||"-"}),(0,s.jsx)(y,{label:"Chain",value:(null==u?void 0:u.reference)?"".concat(u.reference):"-"})]}),(0,s.jsx)("button",{type:"button",className:"mt-4 h-10 rounded-[8px] bg-[#0500ff] px-4 text-sm font-600 text-white disabled:cursor-not-allowed disabled:opacity-60",disabled:a,onClick:()=>e(),children:t?"Change Wallet":a?"Connecting...":"Connect Wallet"})]}),(0,s.jsxs)("section",{className:"rounded-[8px] border border-[#e5e7eb] bg-white p-4 dark:border-[#2b2f38] dark:bg-[#181b22]",children:[(0,s.jsx)("label",{className:"text-sm font-600",htmlFor:"trust-solana-message",children:"Message"}),(0,s.jsx)("textarea",{id:"trust-solana-message",className:"mt-2 min-h-[112px] w-full resize-y rounded-[8px] border border-[#d1d5db] bg-transparent p-3 text-sm outline-none focus:border-[#0500ff] dark:border-[#3f4652]",value:b,onChange:e=>f(e.target.value)}),(0,s.jsx)("button",{type:"button",className:"mt-4 h-10 rounded-[8px] bg-[#111827] px-4 text-sm font-600 text-white disabled:cursor-not-allowed disabled:opacity-60 dark:bg-white dark:text-[#111827]",disabled:!t||!b.trim()||z.isPending,onClick:()=>{k(""),C(""),W(void 0),E(void 0),D("idle"),P(""),K(""),z.mutate({message:b})},children:z.isPending?"Signing...":"Sign Message"}),z.error&&(0,s.jsx)("pre",{className:"mt-4 overflow-auto rounded-[8px] bg-[#fef2f2] p-3 text-xs text-[#b91c1c] dark:bg-[#2a1719] dark:text-[#fca5a5]",children:z.error.message}),v&&(0,s.jsxs)("div",{className:"mt-4 grid gap-3 text-sm",children:[(0,s.jsx)(S,{label:"Signed Message",value:N}),(0,s.jsx)(S,{label:"Signature (bs58)",value:v}),(0,s.jsx)(S,{label:"Diagnostics",value:["Address: ".concat(l||"-"),"Public key bytes: ".concat(l?h.A.decode(l).length:0),"Signed message bytes: ".concat((null==T?void 0:T.length)||0),"WalletConnect message bytes: ".concat(T?new TextEncoder().encode(h.A.encode(T)).length:0),"Signature bytes: ".concat((null==M?void 0:M.length)||0)].join("\n")}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("button",{type:"button",className:"h-10 w-fit roun
1ded-[8px] border border-[#111827] px-4 text-sm font-600 disabled:cursor-not-allowed disabled:opacity-60 dark:border-white",disabled:!l||!M||!T,onClick:H,children:"Verify Signature"}),(0,s.jsx)(j,{status:A,mode:O,error:_})]})]})]}),(0,s.jsxs)("section",{className:"rounded-[8px] border border-[#e5e7eb] bg-white p-4 dark:border-[#2b2f38] dark:bg-[#181b22]",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("h2",{className:"text-base font-600",children:"Direct Wallet Standard Check"}),(0,s.jsx)("p",{className:"text-sm text-[#6b7280] dark:text-[#a1a1aa]",children:"Bypass TrustConnect and call Trust Wallet's injected Wallet Standard signMessage directly."})]}),(0,s.jsx)("button",{type:"button",className:"mt-4 h-10 rounded-[8px] border border-[#111827] px-4 text-sm font-600 disabled:cursor-not-allowed disabled:opacity-60 dark:border-white",disabled:!b.trim(),onClick:J,children:"Direct Wallet Standard Sign"}),I&&(0,s.jsx)("pre",{className:"mt-4 overflow-auto rounded-[8px] bg-[#fef2f2] p-3 text-xs text-[#b91c1c] dark:bg-[#2a1719] dark:text-[#fca5a5]",children:I}),F&&(0,s.jsx)(S,{label:"Direct Wallet Standard Result",value:F}),(0,s.jsx)("button",{type:"button",className:"mt-4 h-10 rounded-[8px] border border-[#111827] px-4 text-sm font-600 disabled:cursor-not-allowed disabled:opacity-60 dark:border-white",disabled:!b.trim(),onClick:Q,children:"Direct Offchain Message Sign"}),L&&(0,s.jsx)("pre",{className:"mt-4 overflow-auto rounded-[8px] bg-[#fef2f2] p-3 text-xs text-[#b91c1c] dark:bg-[#2a1719] dark:text-[#fca5a5]",children:L}),q&&(0,s.jsx)(S,{label:"Direct Offchain Message Result",value:q})]})]})})}function j(e){let{status:t,mode:a,error:n}=e;return"idle"===t?(0,s.jsx)("span",{className:"text-xs text-[#6b7280] dark:text-[#a1a1aa]",children:"Signature has not been verified yet."}):"valid"===t?(0,s.jsx)("span",{className:"text-xs font-600 text-[#15803d]",children:"Signature is valid for the connected address. Verified payload: ".concat("walletconnect-base58-message"===a?"WalletConnect base58 message":"raw message",".")}):"invalid"===t?(0,s.jsx)("span",{className:"text-xs font-600 text-[#b91c1c]",children:"Signature does not verify against the connected address and returned signedMessage. Checked raw message and WalletConnect base58 message payloads."}):(0,s.jsx)("span",{className:"text-xs font-600 text-[#b91c1c]",children:n})}function y(e){let{label:t,value:a}=e;return(0,s.jsxs)("div",{className:"grid gap-1 md:grid-cols-[120px_1fr]",children:[(0,s.jsx)("span",{className:"text-[#6b7280] dark:text-[#a1a1aa]",children:t}),(0,s.jsx)("span",{className:"break-all font-500",children:a})]})}function S(e){let{label:t,value:a}=e;return(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-1 text-[#6b7280] dark:text-[#a1a1aa]",children:t}),(0,s.jsx)("pre",{className:"overflow-auto rounded-[8px] bg-[#f3f4f6] p-3 text-xs dark:bg-[#101217]",children:a})]})}function k(){let e=(0,p.useMemo)(()=>new l.E,[]),t=(0,p.useMemo)(()=>(0,x.j)({chain:b.xn}),[]),a=(0,p.useMemo)(()=>(0,f.o)({projectId:w||"",metadata:{name:"XStable TrustConnect Solana Demo",url:window.location.origin,description:"TrustConnect Solana signMessage demo",icons:["https://www.xstable.ai/favicon.ico"]}}),[]);return(0,s.jsx)(u.w$,{config:{namespaces:[t],services:[a]},theme:"auto",children:(0,s.jsx)(o.Ht,{client:e,children:(0,s.jsx)(v,{})})})}}}]);

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.