PageSourceSearch

https://civilizationcontrol.pages.dev/civ-control/assets/GatePermitPage-Dou_q9vQ.js

js civilizationcontrol.pages.dev collected 2026-10-03 06:38:48 UTC 16,272 bytes, 1 lines download raw bytes

1import{r as j,j as e}from"./index-ClfJ-8p4.js";import{at as k,as as A}from"./SmartObjectProvider-CCqzRETG.js";import{C as V}from"./transactionExecutionErrors-B_eK2SlT.js";import{u as W}from"./useAutoConnect-CUwSsRzj.js";import{a as M,d as Q}from"./App-8pS2_v-Y.js";import{r as K}from"./objectResolver-CcOWYrF7.js";import{u as B,h as Y,z as X,m as H,b as J,a as Z}from"./suiReader-BwlV2sHH.js";import{u as ee}from"./QueryClientProvider-Dd4YlBk5.js";import{u as te,r as D}from"./useSponsoredExecution-DJ-qupSM.js";import{d as G,e as U,u as re,s as L,j as se,f as E,g as F,a as z}from"./currency-xPWZQZ2W.js";import{C as _,G as S,S as ne}from"./constants-CeqDYj5_.js";import{s as T}from"./formatAddress-7QjVTtAb.js";import"./client-OkvARVtL.js";import"./dynamic-fields-BC8LHLFP.js";import"./derived-objects-C5ha1StP.js";import"./removable-DCceCa59.js";import"./query-DgCC6GfN.js";import"./suiRpcClient-DB6uDllx.js";const oe="stillness";function ae(){const{gateId:r}=M(),[n]=Q(),t=n.get("itemId"),i=n.get("tenant")||oe;return j.useMemo(()=>{if(r)return{gateId:r,source:"url-param",error:null};if(t)try{return{gateId:K(t,i),source:"query-context",error:null}}catch{return{gateId:void 0,source:"none",error:"Failed to resolve gate from in-game context."}}return{gateId:void 0,source:"none",error:null}},[r,t,i])}const q="0x6",ie=50;function $(r){return!r||!Number.isFinite(r)?1:Math.min(Math.max(Math.floor(r),1),ie)}function le(r){const{sourceGateId:n,destinationGateId:t,characterId:i}=r,s=$(r.quantity),c=new k;for(let d=0;d<s;d+=1)c.moveCall({target:`${_}::gate_control::request_jump_permit_free`,arguments:[c.object(S),c.object(n),c.object(t),c.object(i),c.object(q)]});return c}function ce(r){const{sourceGateId:n,destinationGateId:t,characterId:i,eveCoinId:s,tollPrice:c,mergeCoinIds:d}=r,u=$(r.quantity),a=new k;d&&d.length>0&&a.mergeCoins(a.object(s),d.map(m=>a.object(m)));const l=a.splitCoins(a.object(s),Array.from({length:u},()=>a.pure.u64(BigInt(c))));for(let m=0;m<u;m+=1)a.moveCall({target:`${_}::gate_control::request_jump_permit`,arguments:[a.object(S),a.object(n),a.object(t),a.object(i),l[m],a.object(q)]});return a}function de(r){const{sourceGateId:n,destinationGateId:t,characterId:i,coinType:s,paymentCoinId:c,altTollPrice:d,mergeCoinIds:u}=r,a=$(r.quantity),l=new k;u&&u.length>0&&l.mergeCoins(l.object(c),u.map(o=>l.object(o)));const m=l.splitCoins(l.object(c),Array.from({length:a},()=>l.pure.u64(BigInt(d))));for(let o=0;o<a;o+=1)l.moveCall({target:`${_}::gate_control::request_jump_permit_alt`,typeArguments:[s],arguments:[l.object(S),l.object(n),l.object(t),l.object(i),m[o],l.object(q)]});return l}function ue(r,n,t,i){if(!r)return{access:!0,toll:0,mode:n,hasPreset:!1};const s=n==="commercial"?r.commercialPreset:r.defensePreset;if(!s)return{access:!0,toll:0,mode:n,hasPreset:!1};const c=n==="commercial"?r.commercialCharacterEntries:r.defenseCharacterEntries;if(i&&c){const u=c.find(a=>a.characterId===i);if(u)return{access:u.access,toll:u.toll,mode:n,hasPreset:!0}}const d=s.entries.find(u=>u.tribe===t);return d?{access:d.access,toll:d.toll,mode:n,hasPreset:!0}:{access:s.defaultAccess,toll:s.defaultToll,mode:n,hasPreset:!0}}function me(r){const{walletAddress:n}=A();return B({queryKey:["gatePermit",r,n],queryFn:async()=>{const[t,i,s,c]=await Promise.all([Y(r),X(r),n?H(n):null,J(r)]),{found:d,linkedGateId:u}=i,a=u?[r,u]:[r],l=await Z(a),m=!!u&&a.every(g=>l.get(g)==="authorized"),o=(s==null?void 0:s.tribeId)??0,y=ue(t,c,o,(s==null?void 0:s.characterId)??null),x=(t==null?void 0:t.altCurrency)??null,f=x&&G(x.coinType)?x:null;return{gateFound:d,linkedGateId:u,policy:t,posture:c,effectiveToll:y.toll,accessAllowed:y.access,playerCharacterId:(s==null?void 0:s.characterId)??null,playerCharacterName:(s==null?void 0:s.characterName)??"",playerTribeId:o,extensionReady:m,hasPreset:y.hasPreset,altCurrency:f}},enabled:!!r,staleTime:3e4})}function he(){const r=te(),{walletAddress:n}=A(),t=ee(),[i,s]=j.useState("idle"),[c,d]=j.useState(null),[u,a]=j.useState(null),l=j.useCallback(async(o,y,x=1,f="eve")=>{var g;s("pending"),a(null),d(null);try{if(!o.playerCharacterId)throw new Error("No character found for this wallet.");if(!o.linkedGateId)throw new Error("Gate has no linked destination.");let b;if(o.effectiveToll>0&&f==="alt"){if(!n)throw new Error("Wallet not connected.");const p=o.altCurrency;
1if(!p)throw new Error("This gate does not accept a marketplace toll currency.");const h=((g=G(p.coinType))==null?void 0:g.symbol)??"marketplace currency",R=U(o.effectiveToll,p.rateNum,p.rateDen),O=await re(n,p.coinType),w=L(O,R*x);if(!w)throw new Error(`Insufficient ${h} balance for toll.`);b=de({sourceGateId:y,destinationGateId:o.linkedGateId,characterId:o.playerCharacterId,coinType:p.coinType,paymentCoinId:w.primaryCoinId,mergeCoinIds:w.mergeCoinIds,altTollPrice:R,quantity:x})}else if(o.effectiveToll>0){if(!n)throw new Error("Wallet not connected.");const p=await se(n),h=L(p,o.effectiveToll*x);if(!h)throw new Error("Insufficient EVE balance for toll.");b=ce({sourceGateId:y,destinationGateId:o.linkedGateId,characterId:o.playerCharacterId,eveCoinId:h.primaryCoinId,mergeCoinIds:h.mergeCoinIds,tollPrice:o.effectiveToll,quantity:x})}else b=le({sourceGateId:y,destinationGateId:o.linkedGateId,characterId:o.playerCharacterId,quantity:x});const{digest:C}=await r(b);d(C),s("success"),t.invalidateQueries({queryKey:["gatePermit"]})}catch(b){const C=b instanceof Error?b.message:String(b);a(fe(C)),s("error")}},[r,n,t]),m=j.useCallback(()=>{s("idle"),d(null),a(null)},[]);return{status:i,digest:c,error:u,execute:l,reset:m}}function fe(r){return r.includes("EAccessDenied")?"Your tribe is not permitted to pass through this gate.":r.includes("EWrongAltCurrency")||r.includes("EAltCurrencyNotSet")?"This gate's marketplace-currency toll configuration changed. Reload the page and try again.":r.includes("EAltTollOverflow")?"The configured marketplace-currency rate produces an unpayable toll. Contact the gate owner.":r.includes("EInsufficientToll")?"Insufficient funds to pay the required toll.":r.includes("ETollRequired")?"A toll is required for this route but was not provided.":r.includes("EExtensionNotAuthorized")||r.includes("assert_gate_extension_matches")||r.includes("assert_jump_permit_extension_authorization")?"This gate is not enrolled in CivilizationControl gate control. The gate owner needs to authorize gate control and publish an access policy at civilizationcontrol.com before permits can be issued.":r.includes("borrow_preset")||r.includes("dynamic_field")?"The gate owner has not published an access policy for the current posture yet. Permits cannot be issued until they do.":/gas selection|insufficient sui/i.test(r)?"Gas sponsorship is temporarily unavailable and your wallet holds no SUI to pay gas itself. Get free testnet SUI from the faucet below and retry, or try again later once sponsorship is restored.":r}const xe=[1,5,10,50];function Re(){const{gateId:r,error:n}=ae(),{isConnected:t,walletAddress:i}=A(),{connectError:s,hasClientWallet:c}=W(),{data:d,isLoading:u,error:a}=me(r),l=he();let m="init",o=null;return n?(m="error",o=n):r?s?(m="error",o=`Wallet connect failed: ${s}`):t?u?m="loading":a||!d?(m="error",o="Failed to load gate data. Verify the gate ID is correct."):m="ready":m="wallet":m="resolve",m==="error"?e.jsx(I,{children:e.jsx("p",{className:"text-destructive text-sm",children:o})}):r?t?u?e.jsx(I,{children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading gate data…"})}):d?e.jsx(pe,{gateId:r,walletAddress:i??null,gate:d,permit:l}):e.jsx(I,{children:e.jsx("p",{className:"text-destructive text-sm",children:"Failed to load gate data. Verify the gate ID is correct."})}):e.jsx(I,{children:c?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Connecting wallet…"}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Connect your wallet to see this gate's terms for your pilot and acquire transit permits."}),e.jsx(V,{})]})}):e.jsx(I,{children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No gate context found. This page expects either a gate ID in the URL or in-game query parameters (?itemId=&tenant=)."})})}function pe({gateId:r,walletAddress:n,gate:t,permit:i}){const[s,c]=j.useState(1),[d,u]=j.useState("eve");if(!t.gateFound)return e.jsxs(I,{children:[e.jsxs("div",{className:"border-b border-border/50 pb-4",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-[0.02em] text-foreground",children:"Gate Transit Permit"}),e.jsx("p",{className:"text-xs font-mono text-muted-foreground mt-1",children:T(r)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Gate Status"}),e.jsx(v,{label:"On-chain record",value:"Not found",blocked:!0})]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No gate exists on-chain at this id. This usually means the gate was recently unanchored or rebuilt (rebuilding creates a new on-chain record), or it was anchored moments ago and the chain has not caught up. Refresh in a minute. If this keeps happening on a live gate, screenshot this page including the address bar and report it."}),e.jsxs("p",{className:"text-[11px] font-mono text-muted-foreground
1/60 break-all",children:["resolved id: ",r]})]});const a=!t.playerCharacterId,l=!t.linkedGateId,m=!t.extensionReady&&!l,o=t.extensionReady&&!t.hasPreset,y=t.accessAllowed&&t.extensionReady&&t.hasPreset&&!a&&!l,x=t.effectiveToll*s,f=t.altCurrency?G(t.altCurrency.coinType):null,g=!!t.altCurrency&&!!f&&t.effectiveToll>0,b=g?U(t.effectiveToll,t.altCurrency.rateNum,t.altCurrency.rateDen):0,C=b*s,p=g&&d==="alt"?"alt":"eve";return e.jsxs(I,{children:[e.jsxs("div",{className:"border-b border-border/50 pb-4",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-[0.02em] text-foreground",children:"Gate Transit Permit"}),e.jsxs("p",{className:"text-xs font-mono text-muted-foreground mt-1",children:[T(r),t.linkedGateId&&e.jsxs("span",{children:[" → ",T(t.linkedGateId)]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(N,{children:"Pilot"}),a?e.jsxs("p",{className:"text-destructive text-sm",children:["No character found for wallet ",T(n??""),"."]}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-sm text-foreground",children:[t.playerCharacterName||T(t.playerCharacterId),e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:D(t.playerTribeId)})]}),e.jsx(ye,{characterId:t.playerCharacterId})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Gate Policy"}),m&&e.jsx(v,{label:"Gate control",value:"Not enrolled",blocked:!0}),o&&e.jsx(v,{label:"Access policy",value:"Not published",blocked:!0}),P(t)&&t.effectiveToll===0&&t.accessAllowed&&e.jsx(v,{label:"Open passage",value:"No restrictions"}),P(t)&&!t.accessAllowed&&e.jsx(v,{label:"Access",value:"Denied",blocked:!0}),P(t)&&t.effectiveToll>0&&e.jsx(v,{label:"Transit toll",value:g&&f?`${E(t.effectiveToll)} Lux or ${F(b,f)} ${f.symbol}`:`${E(t.effectiveToll)} Lux (${z(t.effectiveToll)} EVE)`}),e.jsx(v,{label:"Posture mode",value:t.posture==="defense"?"Defense":"Commercial"}),l&&e.jsx(v,{label:"Destination",value:"Not linked",blocked:!0})]}),l&&e.jsx("p",{className:"text-muted-foreground text-sm",children:"The chain shows no destination link for this gate. If it looks linked in-game, the link may not have registered on-chain yet, or the partner gate was unanchored (unanchoring deletes the on-chain gate and breaks the link). Permits need a live linked pair."}),m&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This gate is not governed by CivilizationControl yet, so transit permits cannot be issued here. If you own this gate, connect at"," ",e.jsx("span",{className:"text-foreground",children:"civilizationcontrol.com"}),", authorize gate control on both linked gates, and publish an access policy."]}),o&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Gate control is authorized, but the owner has not published an access policy for the current ",t.posture," posture. Permits cannot be issued until a policy is saved."]}),P(t)&&!t.accessAllowed&&e.jsxs("p",{className:"text-destructive text-sm",children:["Your tribe (",D(t.playerTribeId),") is not permitted under the current ",t.posture," policy."]}),m||o||l?null:i.status==="success"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-primary text-sm font-medium",children:s>1?`${s} permits acquired.`:"Permit acquired."}),e.jsxs("p",{className:"text-xs font-mono text-muted-foreground",children:["tx: ",i.digest]})]}):e.jsxs(e.Fragment,{children:[y&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{children:"Permits"}),e.jsx("div",{className:"flex gap-1.5",children:xe.map(h=>e.jsx("button",{onClick:()=>c(h),className:`rounded border px-3 py-1 text-xs font-medium transition ${s===h?"border-primary/50 bg-primary/15 text-primary":"border-border text-muted-foreground hover:text-foreground"}`,children:h},h))})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Each permit covers one jump on this route and stays valid for 14 days. Stock up to avoid re-requesting before every transit."})]}),y&&g&&f&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{children:"Pay with"}),e.jsx("div",{className:"flex gap-1.5",children:[{key:"eve",label:"Lux (EVE)"},{key:"alt",label:f.symbol}].map(h=>e.jsx("button",{onClick:()=>u(h.key),className:`rounded border px-3 py-1 text-xs font-medium transition ${p===h.key?"border-primary/50 bg-primary/15 text-primary":"border-border text-muted-foreground hover:text-foreground"}`,children:h.label},h.key))})]}
1),e.jsxs("p",{className:"text-[11px] text-muted-foreground/70",children:["This gate accepts ",f.symbol," (Tri-Ex marketplace credit) as an alternative to the EVE toll. Pay with whichever you hold."]})]}),e.jsx("button",{onClick:()=>i.execute(t,r,s,p),disabled:!y||i.status==="pending",className:"w-full rounded border border-primary/30 bg-primary/10 px-4 py-2.5 text-sm font-medium text-primary transition hover:bg-primary/20 disabled:opacity-40 disabled:cursor-not-allowed",children:i.status==="pending"?"Requesting…":t.effectiveToll>0?p==="alt"&&f?`Pay ${F(C,f)} ${f.symbol} — Acquire ${s>1?`${s} Permits`:"Permit"}`:`Pay ${E(x)} Lux (${z(x)} EVE) — Acquire ${s>1?`${s} Permits`:"Permit"}`:`Acquire ${s>1?`${s} Transit Permits`:"Transit Permit"}`}),i.error&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-destructive text-sm",children:i.error}),/faucet/i.test(i.error)&&e.jsx("a",{href:ne,target:"_blank",rel:"noreferrer",className:"inline-block rounded border border-primary/30 bg-primary/10 px-3 py-1.5 text-xs font-medium text-primary transition hover:bg-primary/20",children:"Get free testnet SUI ↗"})]})]})]})}function P(r){return r.extensionReady&&r.hasPreset}function ye({characterId:r}){const[n,t]=j.useState(!1);return e.jsx("button",{onClick:()=>{var i;(i=navigator.clipboard)==null||i.writeText(r).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)}).catch(()=>{})},title:"Copy your pilot ID — share it with a gate owner to be granted individual access",className:"shrink-0 rounded border border-border px-2 py-1 text-[10px] text-muted-foreground transition hover:text-foreground hover:bg-white/5",children:n?"Copied":"Copy pilot ID"})}function I({children:r}){return e.jsx("div",{className:"dark min-h-screen bg-background text-foreground flex items-center justify-center p-4",children:e.jsx("div",{className:"cc-panel w-full max-w-md 
1space-y-5 rounded-lg border border-border bg-[var(--surface-standard)] p-6",children:r})})}function N({children:r}){return e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-widest text-muted-foreground",children:r})}function v({label:r,value:n,blocked:t=!1}){return e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:r}),e.jsx("span",{className:t?"text-destructive":"text-foreground",children:n})]})}export{Re as GatePermitPage,pe as GatePermitView};

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.