@oracle-agent/oracle 0.35.34 → 0.35.35
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.
- package/README.md +10 -8
- package/artifacts/specialist-packs/oracle-full-crypto.json +11 -0
- package/dist/agent-sessions.mjs +1 -1
- package/dist/assets/profiles/canton-agent/SOUL.md +44 -0
- package/dist/assets/profiles/canton-agent/profile.json +30 -0
- package/dist/assets/profiles/oracle/SOUL.md +1 -0
- package/dist/assets/skills/oracle-canton/SKILL.md +49 -0
- package/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/bin/desk-server.mjs +35 -35
- package/dist/bin/oracle-data-mcp.mjs +17 -17
- package/dist/bin/oracle-gateway.mjs +14 -14
- package/dist/bin/oracle-launch-radar-shadow.mjs +4 -4
- package/dist/bin/oracle-mev-arb-shadow.mjs +4 -4
- package/dist/bin/oracle-mev-shadow.mjs +4 -4
- package/dist/bin/oracle-public-server.mjs +4 -4
- package/dist/bin/oracle-route.mjs +8 -8
- package/dist/bin/oracle-scan.mjs +10 -10
- package/dist/cli/commands/agent-session.mjs +3 -3
- package/dist/cli/commands/chain.mjs +1 -1
- package/dist/cli/commands/chat.mjs +205 -204
- package/dist/cli/commands/doctor.mjs +5 -5
- package/dist/cli/commands/eval.mjs +112 -111
- package/dist/cli/commands/farm.mjs +22 -22
- package/dist/cli/commands/model.mjs +209 -208
- package/dist/cli/commands/plugins.mjs +42 -39
- package/dist/cli/commands/quickstart.mjs +6 -6
- package/dist/cli/commands/sign.mjs +12 -12
- package/dist/cli/commands/signer.mjs +25 -23
- package/dist/cli/commands/snipe.mjs +6 -6
- package/dist/cli/commands/swap.mjs +12 -12
- package/dist/cli/commands/venues.mjs +2 -2
- package/dist/data/desk-data.mjs +33 -33
- package/dist/data/providers/farming.mjs +2 -2
- package/dist/data/providers/lp-destination-discovery.mjs +4 -4
- package/dist/index.mjs +50 -49
- package/dist/launch-radar/index.mjs +4 -4
- package/dist/local-signer/anvil-attestation-worker.mjs +1 -1
- package/dist/local-signer/index.mjs +3 -3
- package/dist/local-signer/runtime.mjs +22 -20
- package/dist/router/index.mjs +3 -3
- package/dist/router/prepare-bridge.mjs +1 -1
- package/dist/scanner/index.mjs +4 -4
- package/dist/task.mjs +2 -2
- package/dist/teams/index.mjs +3 -1
- package/dist/tui/standalone-client.mjs +75 -74
- package/package.json +2 -2
- package/public/eval-report.json +6 -6
- package/public/oracle-splash/index.html +4 -4
- package/server.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Lt from"node:fs";import{JsonRpcProvider as Pt}from"ethers";import{Interface as te,keccak256 as _t}from"ethers";import{Transaction as Ll}from"@scure/btc-signer";import{ed25519 as Bl}from"@noble/curves/ed25519.js";import{base58 as di}from"@scure/base";import{Interface as fe}from"ethers";import{Interface as je,MaxUint256 as mr,isAddress as wr,keccak256 as hr,toUtf8Bytes as gr}from"ethers";import{Interface as De,isAddress as Gt}from"ethers";import{isAddress as zt}from"ethers";var Qt=new De(["function approve(address spender,uint256 amount) returns (bool)"]);import{Interface as Fe,isAddress as rr}from"ethers";var sr=new Fe(["function approve(address spender,uint256 amount) returns (bool)"]),ar=Object.freeze({42161:"0x1c3fa76e6e1088bce750f23a5bfcffa1efef6a41",43114:"0x8f550e53dfe96c055d5bdb267c21f268fcaf63b2"});var Ar=new je(["function approve(address spender,uint256 amount) returns (bool)"]);var kr=300*1e3,Ir=(()=>{let e=Number(process.env.ORACLE_PREPARE_HARD_MAX_AGE_MS);return Number.isFinite(e)&&e>0?e:1800*1e3})();import{Address as _r,NETWORK as $r,OutScript as Rr,RawTx as Lr,SigHash as Pr,TEST_NETWORK as Br,Transaction as Dr}from"@scure/btc-signer";import{createHash as qe}from"node:crypto";import{base58 as Mr}from"@scure/base";import{getCompiledTransactionMessageDecoder as zr}from"@solana/transaction-messages";var ae=e=>qe("sha256").update(`global:${e}`).digest().subarray(0,8).toString("hex"),Wr=new Map([[ae("route"),{name:"route",prefixBytes:0}],[ae("shared_accounts_route"),{name:"shared_accounts_route",prefixBytes:1}]]);var Zr=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,Qr=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,en=AbortSignal.prototype.throwIfAborted,tn=EventTarget.prototype.addEventListener,rn=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var nn=64*1024,on=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});var bn=Object.freeze({"perp-order":"order","hip3-order":"order","hip4-order":"order","perp-bracket":"order","perp-cancel":"cancel","perp-leverage":"leverage","perp-isolated-margin":"margin","builder-fee-approval":"approveBuilder","hype-stake-deposit":"stake","hype-stake-withdraw":"unstake","hype-delegate":"delegate","hype-undelegate":"delegate"}),En=Object.freeze({"perp-order":"order","hip3-order":"order","hip4-order":"order","perp-bracket":"order","perp-cancel":"cancel","perp-leverage":"updateLeverage","perp-isolated-margin":"updateIsolatedMargin","builder-fee-approval":"approveBuilderFee","hype-stake-deposit":"cDeposit","hype-stake-withdraw":"cWithdraw","hype-delegate":"tokenDelegate","hype-undelegate":"tokenDelegate"});var An="0x"+"00".repeat(32);var He=Object.freeze([["salt","uint256"],["maker","address"],["signer","address"],["tokenId","uint256"],["makerAmount","uint256"],["takerAmount","uint256"],["side","uint8"],["signatureType","uint8"],["timestamp","uint256"],["metadata","bytes32"],["builder","bytes32"]]),Tn=Object.freeze(He.map(e=>e[0]));import{TypedDataEncoder as io,getAddress as so}from"ethers";import{TypedDataEncoder as Rn,getAddress as Ln,isAddress as Pn}from"ethers";var We=Object.freeze({1:"0x111111125421cA6dc452d289314280a0f8842A65",8453:"0x111111125421cA6dc452d289314280a0f8842A65",42161:"0x111111125421cA6dc452d289314280a0f8842A65",10:"0x111111125421cA6dc452d289314280a0f8842A65",137:"0x111111125421cA6dc452d289314280a0f8842A65",56:"0x111111125421cA6dc452d289314280a0f8842A65"}),Ue=Object.freeze({Order:[{name:"salt",type:"uint256"},{name:"maker",type:"address"},{name:"receiver",type:"address"},{name:"makerAsset",type:"address"},{name:"takerAsset",type:"address"},{name:"makingAmount",type:"uint256"},{name:"takingAmount",type:"uint256"},{name:"makerTraits",type:"uint256"}]});import{TypedDataEncoder as Vn,getAddress as Jn,isAddress as Kn}from"ethers";var Fn=Object.freeze({READ:"read",PREPARE:"prepare",EXECUTE:"execute",AUTONOMOUS:"autonomous"});var Ve=Object.freeze({1:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41",100:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41",42161:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41",8453:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41"}),to=Object.freeze({1:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",100:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",42161:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",8453:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110"});var Je=Object.freeze({Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}),ro=Object.freeze({OrderCancellations:[{name:"orderUids",type:"bytes[]"}]});var lo=Object.freeze(["https://limit-orders.1inch.io","https://api.1inch.dev/orderbook"]);var Qe=new Set(["evm","evm-swap","evm-bridge","evm-nft","evm-order","btc","sol","hl","poly","lighter"]);var Oo=Object.freeze({swap:5,bridge:5,perps:0,nft:0,mint:0,transfer:0,approve:0,delegate:0,identity:0,order:0,cancel:0,leverage:0,margin:0,approveBuilder:0,stake:0,unstake:0});var et=Object.freeze({"0x04e45aaf":{provider:"uniswap-v3",action:"swap",layout:"router02-exact-input-single"},"0x414bf389":{provider:"uniswap-v3",action:"swap",layout:"swap-router-exact-input-single"},"0xc04b8d59":{provider:"uniswap-v3",action:"swap",layout:"exact-input-deadline"},"0xb858183f":{provider:"uniswap-v3",action:"swap",layout:"exact-input"},"0x5ae401dc":{provider:"uniswap-v3",action:"swap",layout:"multicall-deadline"},"0xa026383e":{provider:"aerodrome",action:"swap",layout:"aerodrome-exact-input-single"},"0x7b939232":{provider:"across-v3",action:"bridge",layout:"across-deposit-v3"}}),To=Object.freeze({"0x161ac21f":{provider:"opensea-nft",action:"mint",layout:"seadrop-mint-public"},"0xc2f6663a":{provider:"opensea-nft",action:"mint",layout:"seadrop-mint-allowlist"}}),No=new fe(["function buySpecificNFT(uint256 tokenId,uint256 maxCost) payable","function sellNFT(uint256 tokenId,uint256 minPayout) payable"]),Co=new fe(["function mintAllowList(address nftContract,address feeRecipient,address minterIfNotPayer,uint256 quantity,(uint80 mintPrice,uint48 maxTotalMintableByWallet,uint48 startTime,uint48 endTime,uint48 dropStageIndex,uint32 maxTokenSupplyForStage,uint16 feeBps,bool restrictFeeRecipients) mintParams,bytes32[] proof) payable"]),_o=Object.freeze({"0xa0712d68":{provider:"nft-mint",action:"mint",layout:"mint-quantity"},"0x1249c58b":{provider:"nft-mint",action:"mint",layout:"mint-no-args"},"0x2db11544":{provider:"nft-mint",action:"mint",layout:"mint-quantity"},"0xefef39a1":{provider:"nft-mint",action:"mint",layout:"mint-quantity"},"0xa6f2ae3a":{provider:"nft-mint",action:"mint",layout:"mint-no-args"}});var tt=Object.freeze([...Qe]),$o=Object.freeze({...et});import{ed25519 as Ko}from"@noble/curves/ed25519.js";import{base58 as Yo}from"@scure/base";import{RawTx as Zo,SigHash as Qo,Transaction as ei}from"@scure/btc-signer";import{Transaction as ri,keccak256 as ni,verifyTypedData as oi}from"ethers";import{encode as Po}from"@msgpack/msgpack";import{keccak256 as Do,verifyTypedData as Fo}from"ethers";var jo=Object.freeze({name:"Exchange",version:"1",chainId:1337,verifyingContract:"0x0000000000000000000000000000000000000000"}),qo=Object.freeze({Agent:[{name:"source",type:"string"},{name:"connectionId",type:"bytes32"}]});import{wordlists as Ti}from"ethers";import{wordlists as vi}from"ethers";var me=64*1024;var Ci=32*1024;var st=["schemaVersion","buildVersion","recordType","execution","custody"],Ri=[...st,"recordHash"];var Li=Object.freeze({signed:new Set(["workflow.signed","legacy.signed"]),submitted:new Set(["workflow.submitted","legacy.broadcast"]),finalized:new Set(["workflow.finalized"]),reorged:new Set(["workflow.reorged"]),orphaned:new Set(["workflow.orphaned"]),compensating:new Set(["workflow.compensating"]),compensated:new Set(["workflow.compensated"])});var at=Object.freeze(["draft","checked","approval","signed","submitted","finalized","reorged","orphaned","compensating","compensated","failed","cancelled"]),Ae=Object.freeze(["workflow.drafted","workflow.checked","workflow.approval_requested","workflow.approval_granted","workflow.signed","workflow.submitted","workflow.finalized","workflow.reorged","workflow.orphaned","workflow.compensating","workflow.compensated","workflow.failed","workflow.cancelled","workflow.annotated"]),ji=new Set(Ae);var pt=64*1024*1024;var Vi=Object.freeze(["chainId","agentAddress","accountAddress","actions","targets","maxValueWei","maxGasWei","maxSlippageBps","expiresAt","nonce","revocationKey"]),Ji=Object.freeze(["read","simulate"]);var Ki=1440*60;var ns=Object.freeze(["privkey","wif","xprv","seed"]);var os=Object.freeze([{rule:"raw-32-byte-hex-key",re:/^0x[0-9a-fA-F]{64}$/},{rule:"raw-32-byte-hex-bare",re:/^[0-9a-fA-F]{64}$/},{rule:"extended-private-key",re:/\b(?:xprv|tprv|yprv|zprv)[1-9A-HJ-NP-Za-km-z]{107}\b/},{rule:"bitcoin-wif",re:/\b[59KLc][1-9A-HJ-NP-Za-km-z]{50,51}\b/},{rule:"bip39-mnemonic",re:/\b(?:[a-z]{3,8}\s+){11,23}[a-z]{3,8}\b/},{rule:"bearer-token",re:/bearer\s+[A-Za-z0-9._~+/=-]+/i},{rule:"pem-private-key",re:/-----BEGIN[A-Z ]*PRIVATE KEY-----/},{rule:"keystore-path",re:/keystore/i},{rule:"signer-url",re:/https?:\/\/\S*sign/i},{rule:"authorization-header",re:/authorization\s*:/i}]),is=Object.freeze(["grantid","id","hash","sha256","sha256hex","checksum","txhash","transactionhash","blockhash","digest","userophash","commithash","prevhash","intenthash","canonicalhash","payloadhash","requestid"]);var Y=Object.freeze(["intent","quote_comparison","simulation","prepared","approval","signed","broadcast","settlement","balance_delta","position"]),ls=Object.freeze(Object.fromEntries(Y.map((e,t)=>[e,Object.freeze(t+1<Y.length?[Y[t+1]]:[])])));var mt=Object.freeze({intent:"draft",quote_comparison:"draft",simulation:"draft",prepared:"checked",approval:"approval",signed:"signed",broadcast:"submitted",settlement:"finalized",balance_delta:"compensated",position:"compensated"});var ht=Object.freeze(["owner","operator","agent","viewer"]),gt=Object.freeze(["tenant","config","policy","grant","workflow","trade","receipt","audit","telemetry","context","lifecycle"]),yt=Object.freeze({read:"read",create:"create",update:"update",delete:"delete",manage:"manage",prepare:"prepare",cancel:"cancel",export:"export",approve:"approve"}),Js=Object.freeze(["owner"]),Ks=Object.freeze({ALLOW_ROLE_PERMISSION:"allow.role_permission",DENY_MISSING_CONTEXT:"deny.missing_context",DENY_INVALID_CONTEXT:"deny.invalid_context",DENY_INVALID_REQUEST:"deny.invalid_request",DENY_UNKNOWN_RESOURCE:"deny.unknown_resource",DENY_UNKNOWN_ACTION:"deny.unknown_action",DENY_UNBOUND_OBJECT:"deny.unbound_object",DENY_TENANT_MISMATCH:"deny.tenant_mismatch",DENY_RESOURCE_MISMATCH:"deny.resource_mismatch",DENY_ROLE_PERMISSION:"deny.role_permission",DENY_POLICY_NOT_APPROVER:"deny.policy_not_approver"}),Gs=new Set(ht),Ys=new Set(gt),Xs=new Set(Object.values(yt));var bt=Object.freeze({owner:Object.freeze(["tenant:read","tenant:manage","config:read","config:manage","policy:read","policy:manage","grant:read","grant:create","grant:update","grant:delete","grant:manage","workflow:read","workflow:create","workflow:update","workflow:delete","workflow:cancel","workflow:approve","trade:read","trade:prepare","receipt:read","receipt:export","audit:read","audit:export","telemetry:read","telemetry:create","telemetry:export","context:read","context:create","context:update","context:delete","context:manage","context:export","lifecycle:read","lifecycle:create","lifecycle:update","lifecycle:delete","lifecycle:manage","lifecycle:approve","lifecycle:export"]),operator:Object.freeze(["tenant:read","config:read","policy:read","grant:read","workflow:read","workflow:create","workflow:update","workflow:cancel","trade:read","trade:prepare","receipt:read","audit:read","telemetry:read","telemetry:create","context:read","context:create","context:update","context:delete","lifecycle:read","lifecycle:create","lifecycle:update","lifecycle:manage"]),agent:Object.freeze(["tenant:read","config:read","policy:read","grant:read","workflow:read","workflow:create","workflow:update","trade:read","trade:prepare","receipt:read","telemetry:create","context:read","context:create","context:update","lifecycle:read"]),viewer:Object.freeze(["tenant:read","config:read","grant:read","workflow:read","trade:read","receipt:read","audit:read","telemetry:read","context:read","lifecycle:read"])}),Zs=Object.freeze(Object.fromEntries(Object.entries(bt).map(([e,t])=>[e,Object.freeze([...t])])));var Et=Object.freeze(["succeeded","denied","invalid","failed","cancelled","timed_out","unavailable","skipped"]),xt=Object.freeze(["workflow","task","intent","plan","run","event","eval"]),St=Object.freeze(["taskId","intentId","planId","runId","eventId"]);var ra=Object.freeze({maxAttributes:24,maxKeyLength:48,maxStringLength:256,maxArrayLength:8}),na=new Set(Et),oa=new Set(xt),ia=new Set(St);var sa=Object.freeze(["authorization","bearer","cookie","credential","password","passphrase","secret","token","privatekey","privkey","seed","mnemonic","keystore","signature","prompt","systemmessage","usermessage","assistantmessage","rawtransaction","signedtransaction","serializedtransaction","transactionbytes","calldata","callbytes","inputdata"]);var aa=Object.freeze({taskId:"x-oracle-task-id",intentId:"x-oracle-intent-id",planId:"x-oracle-plan-id",runId:"x-oracle-run-id",eventId:"x-oracle-event-id"});var pa=Object.freeze({"workflow.cancelled":"cancelled","workflow.failed":"failed"});var ba=32*1024*1024;var xa=Object.freeze({N:1<<17,r:8,p:1}),Sa=256*1024*1024,Aa=16*1024;var ka=Object.freeze({1:{name:"ethereum",mode:"mempool-private",endpoints:["https://rpc.flashbots.net/fast","https://rpc.mevblocker.io"]},8453:{name:"base",mode:"sequencer",endpoints:["https://mainnet-sequencer.base.org"]},10:{name:"optimism",mode:"sequencer",endpoints:["https://mainnet-sequencer.optimism.io"]},42161:{name:"arbitrum",mode:"sequencer",endpoints:["https://arb1-sequencer.arbitrum.io/rpc"]},56:{name:"bsc",mode:"mempool-private",endpoints:["https://rpc.48.club","https://bsc.rpc.blxrbdn.com"]},137:{name:"polygon",mode:"mempool-private",endpoints:["https://polygon-bor-rpc.publicnode.com"]},43114:{name:"avalanche",mode:"public-only",endpoints:[]},999:{name:"hyperevm",mode:"public-only",endpoints:[]}});import{homedir as X}from"node:os";import{join as Z}from"node:path";var ve=process.env.ORACLE_PUBLIC_DESKTOP==="1",At=ve?process.env.ORACLE_CONFIG_DIR||Z(X(),".config","oracle"):Z(X(),".config","oracle"),Na=ve?At:Z(X(),".config","mad-desk");var La="0".repeat(64),Pa=Object.freeze({PREPARE:"exec.prepare",SIGN:"exec.sign",BROADCAST:"exec.broadcast",POLICY_REJECT:"policy.reject",AUTH_GRANT:"auth.grant",AUTH_OK:"auth.verify.ok",AUTH_FAIL:"auth.verify.fail"});var Ba=Promise.resolve();import{readFileSync as Ja,readdirSync as Ka,existsSync as vt}from"node:fs";import{dirname as kt,join as x}from"node:path";import{fileURLToPath as It}from"node:url";var S=kt(It(import.meta.url));function Ot(){let e=[x(S,"descriptors"),x(S,"clear-sign","descriptors"),x(S,"..","clear-sign","descriptors"),x(S,"..","..","clear-sign","descriptors"),x(S,"..","..","..","clear-sign","descriptors")];for(let t of e)if(vt(t))return t;return e[0]}var Za=Ot();var Qa=(1n<<256n)-1n;import{Wallet as cc}from"ethers";import{base58 as uc}from"@scure/base";import{ed25519 as fc}from"@noble/curves/ed25519.js";import{NETWORK as mc,TEST_NETWORK as wc,WIF as hc,p2wpkh as gc}from"@scure/btc-signer";import{pubECDSA as bc}from"@scure/btc-signer/utils.js";var Sc=Object.freeze(["spot-limit-create","spot-limit-cancel","spot-order-status"]),Ac=Object.freeze(["binance","bybit","okx","coinbase"]),vc=Object.freeze({binance:"https://api.binance.com",bybit:"https://api.bybit.com",okx:"https://openapi.okx.com",coinbase:"https://api.exchange.coinbase.com"}),kc=Object.freeze({binance:"/api/v3",bybit:"/v5/order",okx:"/api/v5/trade",coinbase:"/orders"}),Ic=Object.freeze(["version","surface","kind","venue","credentialRef","symbol","base","quote","side","baseSize","limitPrice","maxQuoteNotional","timeInForce","clientOrderId","expiresAtMs","venueOrderId","nonce","grantId","artifactHash"]),Oc=Object.freeze(["market-create","withdraw","transfer","subaccount","leverage","futures","margin","convert","api-key"]),Tc=Object.freeze(["url","host","path","method","headers","signature","apiKey","apiSecret","passphrase","privateKey","redirect","proxy"]),Nc=Object.freeze(["ccxt","binance-api-node","node-binance-api","coinbase-advanced-node","@okx-dex/okx-dex-sdk","bybit-api"]),Cc=Object.freeze({perOrderQuote:"sealed-owner-policy",dailyGrossQuote:"sealed-owner-policy",scope:Object.freeze(["per-order","UTC-day","account","venue","quote"]),envelopeFieldIsNotCeiling:!0}),_c=Object.freeze({binanceRecvWindowMs:5e3,bybitWindowMs:5e3,maxLocalSkewMs:2e3}),$c=Object.freeze({perSecond:1,perMinute:30,bind:"tighter"});var Ct=Object.freeze({binance:Object.freeze({create:["POST","/api/v3/order"],cancel:["DELETE","/api/v3/order"],status:["GET","/api/v3/order"]}),bybit:Object.freeze({create:["POST","/v5/order/create"],cancel:["POST","/v5/order/cancel"],status:["GET","/v5/order/realtime"]}),okx:Object.freeze({create:["POST","/api/v5/trade/order"],cancel:["POST","/api/v5/trade/cancel-order"],status:["GET","/api/v5/trade/order"]}),coinbase:Object.freeze({create:["POST","/orders"],cancel:["DELETE","/orders/{order_id}"],status:["GET","/orders/{order_id}"]})}),Ie=Object.freeze({binance:"https://api.binance.com",bybit:"https://api.bybit.com",okx:"https://openapi.okx.com",coinbase:"https://api.exchange.coinbase.com"});var Hc=256*1024;var l=new te(["function collection() view returns (address)","function token() view returns (address)","function robinhoodSwapFeeWei() view returns (uint256)","function quoteSpecificBuy(uint256 tokenId) view returns (uint256 totalCost,uint256 baseCost,uint256 fee,uint256 protocolFee,bool available)","function quoteSellNFT() view returns (uint256 netPayout,uint256 grossPayout,uint256 fee,uint256 protocolFee)","function inventory(uint256 tokenId) view returns (bool)","function buySpecificNFT(uint256 tokenId,uint256 maxCost) payable","function sellNFT(uint256 tokenId,uint256 minPayout) payable"]),Oe=new te(["function decimals() view returns (uint8)","function allowance(address owner,address spender) view returns (uint256)"]),ee=new te(["function ownerOf(uint256 tokenId) view returns (address)","function getApproved(uint256 tokenId) view returns (address)","function isApprovedForAll(address owner,address operator) view returns (bool)"]);function c(e,t){let r=String(e||"").toLowerCase();if(!/^0x[0-9a-f]{40}$/.test(r))throw new Error(`signer: invalid ${t}`);return r}function Te(e,t){return Object.entries(e||{}).find(([r])=>r.toLowerCase()===t)?.[1]}function $t(e,t){let r=e?.anvilQuote;if(!r||typeof r!="object"||Array.isArray(r))throw new Error("signer: exact prepared Anvil quote is required");if(!e?.artifact?.anvilQuote||JSON.stringify(e.artifact.anvilQuote)!==JSON.stringify(r))throw new Error("signer: exact prepared Anvil quote artifact mismatch");return Object.freeze(t==="buy"?{totalCostRaw:BigInt(r.totalCostRaw).toString(),baseCostRaw:BigInt(r.baseCostRaw).toString(),feeRaw:BigInt(r.feeRaw).toString(),protocolFeeRaw:BigInt(r.protocolFeeRaw).toString(),available:r.available===!0}:{netPayoutRaw:BigInt(r.netPayoutRaw).toString(),grossPayoutRaw:BigInt(r.grossPayoutRaw).toString(),feeRaw:BigInt(r.feeRaw).toString(),protocolFeeRaw:BigInt(r.protocolFeeRaw).toString()})}function Rt(e,t,r){if(e.preconditions?.exactQuoteConfirmed!==!0)throw new Error("signer: exact prepared Anvil quote confirmation required");let s=e.artifact,p=t==="buy"?[r.totalCostRaw,e.maxPaymentTokenAmountRaw,s?.maxPaymentTokenAmountRaw,e.exactQuoteTotalCostRaw,s?.exactQuoteTotalCostRaw,e.preconditions?.confirmedTotalCostRaw]:[r.netPayoutRaw,e.minPayoutRaw,s?.minPayoutRaw,e.exactQuoteNetPayoutRaw,s?.exactQuoteNetPayoutRaw,e.preconditions?.confirmedNetPayoutRaw],n;try{n=BigInt(p[0]);for(let g of p.slice(1))if(BigInt(g)!==n)throw new Error("mismatch")}catch{throw new Error(`signer: exact Anvil ${t} settlement limit mismatch`)}let d=s?.transactions;if(!Array.isArray(d)||d.length!==1)throw new Error("signer: exact Anvil action transaction required");let h=t==="buy"?"buySpecificNFT":"sellNFT",f;try{if(f=l.decodeFunctionData(h,d[0].data),l.encodeFunctionData(h,[f[0],f[1]]).toLowerCase()!==String(d[0].data).toLowerCase())throw new Error("non-canonical")}catch{throw new Error(`signer: exact Anvil ${t} calldata required`)}if(BigInt(f[0])!==BigInt(e.tokenId)||BigInt(f[1])!==n)throw new Error(`signer: exact Anvil ${t} calldata limit mismatch`);return n}async function u(e,t,r,s,p,n=[]){let d=await e.send("eth_call",[{to:t,data:r.encodeFunctionData(s,n)},p]);return r.decodeFunctionResult(s,d)[0]}async function Ne(e,t,r,{nowMs:s=Date.now(),signerAddress:p}={}){if(t?.surface!=="evm-nft"||String(t?.provider).toLowerCase()!=="anvil-nft")return null;if(!e||typeof e.send!="function")throw new Error("signer: trusted RPC cannot attest Anvil market");let n=c(t.destination,"Anvil market"),d=c(t.contract,"Anvil collection"),h=c(t.paymentToken,"Anvil payment token"),f=BigInt(t.nativeSwapFeeWei),g=Number(t.paymentTokenDecimals),y=c(p,"Anvil signer identity"),Ce=c(t.owner,"Anvil envelope owner");if(y!==Ce)throw new Error("signer: Anvil signer identity mismatch");let m=BigInt(t.tokenId);if(m<0n)throw new Error("signer: invalid Anvil tokenId");let w=String(t.nftAction||"").toLowerCase();if(w!=="buy"&&w!=="sell")throw new Error("signer: unsupported Anvil NFT action");let _=$t(t,w),$=Rt(t,w,_),A=t.anvilAttestation;if(!A||typeof A!="object"||Number(A.snapshotExpiresAtMs)<=Number(s))throw new Error("signer: fresh provider Anvil attestation required");let R=String(Te(r.anvilRuntimeCodeHashes,n)||"").toLowerCase();if(!/^0x[0-9a-f]{64}$/.test(R)||R!==String(A.runtimeCodeHash||"").toLowerCase())throw new Error("signer: Anvil runtime is not reviewed by policy");let re=Te(r.nftPaymentTokenCaps,h);if(!re||Number(re.decimals)!==g)throw new Error("signer: Anvil payment token decimals are not reviewed by policy");let ne=String(await e.send("eth_chainId",[])).toLowerCase();if(!/^0x(?:0|[1-9a-f][0-9a-f]*)$/.test(ne)||BigInt(ne)!==4663n)throw new Error("signer: trusted RPC Anvil chain mismatch");let v=String(await e.send("eth_blockNumber",[])).toLowerCase();if(!/^0x(?:0|[1-9a-f][0-9a-f]*)$/.test(v))throw new Error("signer: trusted RPC returned an invalid Anvil block number");let _e=BigInt(v),oe=await e.send("eth_getBlockByNumber",[v,!1]),L=String(oe?.hash||"").toLowerCase();if(String(oe?.number||"").toLowerCase()!==v||!/^0x[0-9a-f]{64}$/.test(L))throw new Error("signer: trusted RPC returned an invalid Anvil block attestation");let i=Object.freeze({blockHash:L,requireCanonical:!0}),P=String(await e.send("eth_getCode",[n,i])).toLowerCase();if(!/^0x[0-9a-f]+$/.test(P)||P==="0x")throw new Error("signer: Anvil market runtime is empty");let ie=_t(P).toLowerCase();if(ie!==R)throw new Error("signer: Anvil market runtime mismatch with reviewed policy");let[$e,Re,Le]=await Promise.all([u(e,n,l,"collection",i),u(e,n,l,"token",i),u(e,n,l,"robinhoodSwapFeeWei",i)]),b=c($e,"live Anvil collection"),k=c(Re,"live Anvil payment token"),se=BigInt(Le).toString();if(b!==d)throw new Error("signer: live Anvil collection mismatch");if(k!==h)throw new Error("signer: live Anvil payment token mismatch");if(se!==f.toString())throw new Error("signer: live Anvil native swap fee mismatch");let B=Number(await u(e,k,Oe,"decimals",i));if(!Number.isSafeInteger(B)||B!==g)throw new Error("signer: live Anvil payment token decimals mismatch");let D=c(await u(e,b,ee,"ownerOf",i,[m]),"live Anvil token owner"),F=null,I=null,O=null,T=null,o;if(w==="buy"){let[j,q,M]=await Promise.all([u(e,n,l,"inventory",i,[m]),u(e,k,Oe,"allowance",i,[y,n]),e.send("eth_call",[{to:n,data:l.encodeFunctionData("quoteSpecificBuy",[m])},i])]);F=!!j,I=BigInt(q).toString();let a=l.decodeFunctionResult("quoteSpecificBuy",M);if(o=Object.freeze({totalCostRaw:BigInt(a[0]).toString(),baseCostRaw:BigInt(a[1]).toString(),feeRaw:BigInt(a[2]).toString(),protocolFeeRaw:BigInt(a[3]).toString(),available:!!a[4]}),JSON.stringify(o)!==JSON.stringify(_))throw new Error("signer: exact Anvil buy quote changed after preparation");if(D!==n)throw new Error("signer: exact Anvil token owner is not the market");if(!F)throw new Error("signer: exact Anvil token is not in market inventory");if(BigInt(I)!==BigInt(t.preconditions?.allowanceRaw))throw new Error("signer: live Anvil ERC20 allowance changed after preparation");if(BigInt(I)<$)throw new Error("signer: live Anvil ERC20 allowance is insufficient");if(!o.available)throw new Error("signer: exact Anvil buy quote is unavailable");if(BigInt(o.totalCostRaw)!==$)throw new Error("signer: live Anvil buy quote does not equal exact payment limit");if(BigInt(o.totalCostRaw)!==BigInt(o.baseCostRaw)+BigInt(o.feeRaw)+BigInt(o.protocolFeeRaw))throw new Error("signer: exact Anvil buy quote fee arithmetic mismatch")}else{let[j,q,M]=await Promise.all([u(e,b,ee,"getApproved",i,[m]),u(e,b,ee,"isApprovedForAll",i,[y,n]),e.send("eth_call",[{to:n,data:l.encodeFunctionData("quoteSellNFT")},i])]);O=c(j,"live Anvil token approval"),T=!!q;let a=l.decodeFunctionResult("quoteSellNFT",M);if(o=Object.freeze({netPayoutRaw:BigInt(a[0]).toString(),grossPayoutRaw:BigInt(a[1]).toString(),feeRaw:BigInt(a[2]).toString(),protocolFeeRaw:BigInt(a[3]).toString()}),JSON.stringify(o)!==JSON.stringify(_))throw new Error("signer: exact Anvil sell quote changed after preparation");if(D!==y)throw new Error("signer: exact Anvil token owner does not match signer");if(O!==n&&!T)throw new Error("signer: live Anvil NFT approval is insufficient");if(O!==c(t.preconditions?.approvedAddress,"prepared Anvil token approval")||T!==!!t.preconditions?.approvedForAll)throw new Error("signer: live Anvil NFT approval changed after preparation");if(BigInt(o.netPayoutRaw)!==$)throw new Error("signer: live Anvil sell quote does not equal exact payout limit");if(BigInt(o.netPayoutRaw)+BigInt(o.feeRaw)+BigInt(o.protocolFeeRaw)!==BigInt(o.grossPayoutRaw))throw new Error("signer: exact Anvil sell quote fee arithmetic mismatch")}return Object.freeze({source:"local-signer-trusted-rpc",chainId:4663,market:n,collection:b,paymentToken:k,paymentTokenDecimals:B,nativeSwapFeeWei:se,signerAddress:y,nftAction:w,tokenId:m.toString(),tokenOwner:D,inventoryMember:F,allowanceRaw:I,approvedAddress:O,approvedForAll:T,quote:o,blockNumber:_e.toString(),blockHash:L,runtimeCodeHash:ie,verifiedAtMs:Number(s)})}try{let e=JSON.parse(Lt.readFileSync(0,"utf8")),t=new Pt(e.rpcUrl,Number(e.chainId)),r=await Ne(t,e.envelope,e.policy,{nowMs:Number(e.nowMs),signerAddress:e.signerAddress});process.stdout.write(JSON.stringify(r))}catch(e){process.stderr.write(`Anvil attestation failed: ${String(e?.message||e)}
|
|
1
|
+
import Bt from"node:fs";import{JsonRpcProvider as Dt}from"ethers";import{Interface as re,keccak256 as Lt}from"ethers";import{Transaction as Xu}from"@scure/btc-signer";import{ed25519 as Qu}from"@noble/curves/ed25519.js";import{base58 as pi}from"@scure/base";import{Interface as pe}from"ethers";import{Interface as je,MaxUint256 as hr,isAddress as gr,keccak256 as yr,toUtf8Bytes as br}from"ethers";import{Interface as De,isAddress as Xt}from"ethers";import{isAddress as Ut}from"ethers";var tr=new De(["function approve(address spender,uint256 amount) returns (bool)"]);import{Interface as Fe,isAddress as or}from"ethers";var cr=new Fe(["function approve(address spender,uint256 amount) returns (bool)"]),ur=Object.freeze({42161:"0x1c3fa76e6e1088bce750f23a5bfcffa1efef6a41",43114:"0x8f550e53dfe96c055d5bdb267c21f268fcaf63b2"});var Ir=new je(["function approve(address spender,uint256 amount) returns (bool)"]);var Or=300*1e3,Tr=(()=>{let e=Number(process.env.ORACLE_PREPARE_HARD_MAX_AGE_MS);return Number.isFinite(e)&&e>0?e:1800*1e3})();import{Address as Lr,NETWORK as $r,OutScript as Pr,RawTx as Br,SigHash as Dr,TEST_NETWORK as Fr,Transaction as jr}from"@scure/btc-signer";import{createHash as qe}from"node:crypto";import{base58 as zr}from"@scure/base";import{getCompiledTransactionMessageDecoder as Ur}from"@solana/transaction-messages";var ce=e=>qe("sha256").update(`global:${e}`).digest().subarray(0,8).toString("hex"),Vr=new Map([[ce("route"),{name:"route",prefixBytes:0}],[ce("shared_accounts_route"),{name:"shared_accounts_route",prefixBytes:1}]]);var en=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,tn=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,rn=AbortSignal.prototype.throwIfAborted,nn=EventTarget.prototype.addEventListener,on=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var sn=64*1024,an=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});var xn=Object.freeze({"perp-order":"order","hip3-order":"order","hip4-order":"order","perp-bracket":"order","perp-cancel":"cancel","perp-leverage":"leverage","perp-isolated-margin":"margin","builder-fee-approval":"approveBuilder","hype-stake-deposit":"stake","hype-stake-withdraw":"unstake","hype-delegate":"delegate","hype-undelegate":"delegate"}),Sn=Object.freeze({"perp-order":"order","hip3-order":"order","hip4-order":"order","perp-bracket":"order","perp-cancel":"cancel","perp-leverage":"updateLeverage","perp-isolated-margin":"updateIsolatedMargin","builder-fee-approval":"approveBuilderFee","hype-stake-deposit":"cDeposit","hype-stake-withdraw":"cWithdraw","hype-delegate":"tokenDelegate","hype-undelegate":"tokenDelegate"});var In="0x"+"00".repeat(32);var He=Object.freeze([["salt","uint256"],["maker","address"],["signer","address"],["tokenId","uint256"],["makerAmount","uint256"],["takerAmount","uint256"],["side","uint8"],["signatureType","uint8"],["timestamp","uint256"],["metadata","bytes32"],["builder","bytes32"]]),Cn=Object.freeze(He.map(e=>e[0]));import{TypedDataEncoder as ao,getAddress as co}from"ethers";import{TypedDataEncoder as Pn,getAddress as Bn,isAddress as Dn}from"ethers";var We=Object.freeze({1:"0x111111125421cA6dc452d289314280a0f8842A65",8453:"0x111111125421cA6dc452d289314280a0f8842A65",42161:"0x111111125421cA6dc452d289314280a0f8842A65",10:"0x111111125421cA6dc452d289314280a0f8842A65",137:"0x111111125421cA6dc452d289314280a0f8842A65",56:"0x111111125421cA6dc452d289314280a0f8842A65"}),Ue=Object.freeze({Order:[{name:"salt",type:"uint256"},{name:"maker",type:"address"},{name:"receiver",type:"address"},{name:"makerAsset",type:"address"},{name:"takerAsset",type:"address"},{name:"makingAmount",type:"uint256"},{name:"takingAmount",type:"uint256"},{name:"makerTraits",type:"uint256"}]});import{TypedDataEncoder as Kn,getAddress as Gn,isAddress as Yn}from"ethers";var qn=Object.freeze({READ:"read",PREPARE:"prepare",EXECUTE:"execute",AUTONOMOUS:"autonomous"});var Ve=Object.freeze({1:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41",100:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41",42161:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41",8453:"0x9008D19f58AAbD9eD0D60971565AA8510560ab41"}),no=Object.freeze({1:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",100:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",42161:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",8453:"0xC92E8bdf79f0507f65a392b0ab4667716BFE0110"});var Je=Object.freeze({Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}),oo=Object.freeze({OrderCancellations:[{name:"orderUids",type:"bytes[]"}]});var fo=Object.freeze(["https://limit-orders.1inch.io","https://api.1inch.dev/orderbook"]);var Qe=new Set(["evm","evm-swap","evm-bridge","evm-nft","evm-order","btc","sol","hl","poly","lighter"]);var No=Object.freeze({swap:5,bridge:5,perps:0,nft:0,mint:0,transfer:0,approve:0,delegate:0,identity:0,order:0,cancel:0,leverage:0,margin:0,approveBuilder:0,stake:0,unstake:0});var et=Object.freeze({"0x04e45aaf":{provider:"uniswap-v3",action:"swap",layout:"router02-exact-input-single"},"0x414bf389":{provider:"uniswap-v3",action:"swap",layout:"swap-router-exact-input-single"},"0xc04b8d59":{provider:"uniswap-v3",action:"swap",layout:"exact-input-deadline"},"0xb858183f":{provider:"uniswap-v3",action:"swap",layout:"exact-input"},"0x5ae401dc":{provider:"uniswap-v3",action:"swap",layout:"multicall-deadline"},"0xa026383e":{provider:"aerodrome",action:"swap",layout:"aerodrome-exact-input-single"},"0x7b939232":{provider:"across-v3",action:"bridge",layout:"across-deposit-v3"}}),Co=Object.freeze({"0x161ac21f":{provider:"opensea-nft",action:"mint",layout:"seadrop-mint-public"},"0xc2f6663a":{provider:"opensea-nft",action:"mint",layout:"seadrop-mint-allowlist"}}),_o=new pe(["function buySpecificNFT(uint256 tokenId,uint256 maxCost) payable","function sellNFT(uint256 tokenId,uint256 minPayout) payable"]),Ro=new pe(["function mintAllowList(address nftContract,address feeRecipient,address minterIfNotPayer,uint256 quantity,(uint80 mintPrice,uint48 maxTotalMintableByWallet,uint48 startTime,uint48 endTime,uint48 dropStageIndex,uint32 maxTokenSupplyForStage,uint16 feeBps,bool restrictFeeRecipients) mintParams,bytes32[] proof) payable"]),Lo=Object.freeze({"0xa0712d68":{provider:"nft-mint",action:"mint",layout:"mint-quantity"},"0x1249c58b":{provider:"nft-mint",action:"mint",layout:"mint-no-args"},"0x2db11544":{provider:"nft-mint",action:"mint",layout:"mint-quantity"},"0xefef39a1":{provider:"nft-mint",action:"mint",layout:"mint-quantity"},"0xa6f2ae3a":{provider:"nft-mint",action:"mint",layout:"mint-no-args"}});var tt=Object.freeze([...Qe]),$o=Object.freeze({...et});import{ed25519 as Yo}from"@noble/curves/ed25519.js";import{base58 as Zo}from"@scure/base";import{RawTx as ei,SigHash as ti,Transaction as ri}from"@scure/btc-signer";import{Transaction as oi,keccak256 as ii,verifyTypedData as si}from"ethers";import{encode as Do}from"@msgpack/msgpack";import{keccak256 as jo,verifyTypedData as qo}from"ethers";var Mo=Object.freeze({name:"Exchange",version:"1",chainId:1337,verifyingContract:"0x0000000000000000000000000000000000000000"}),Ho=Object.freeze({Agent:[{name:"source",type:"string"},{name:"connectionId",type:"bytes32"}]});import{closeSync as Ni,constants as it,fchmodSync as Ci,fsyncSync as _i,lstatSync as Ri,mkdirSync as Li,openSync as $i,readFileSync as Pi,renameSync as Bi,rmSync as Di,writeFileSync as Fi}from"node:fs";import{wordlists as ki}from"ethers";var Mi=it.O_NOFOLLOW??0;import{wordlists as Wi}from"ethers";var me=64*1024;var Vi=32*1024;var ct=["schemaVersion","buildVersion","recordType","execution","custody"],Gi=[...ct,"recordHash"];var Yi=Object.freeze({signed:new Set(["workflow.signed","legacy.signed"]),submitted:new Set(["workflow.submitted","legacy.broadcast"]),finalized:new Set(["workflow.finalized"]),reorged:new Set(["workflow.reorged"]),orphaned:new Set(["workflow.orphaned"]),compensating:new Set(["workflow.compensating"]),compensated:new Set(["workflow.compensated"])});var ut=Object.freeze(["draft","checked","approval","signed","submitted","finalized","reorged","orphaned","compensating","compensated","failed","cancelled"]),Ae=Object.freeze(["workflow.drafted","workflow.checked","workflow.approval_requested","workflow.approval_granted","workflow.signed","workflow.submitted","workflow.finalized","workflow.reorged","workflow.orphaned","workflow.compensating","workflow.compensated","workflow.failed","workflow.cancelled","workflow.annotated"]),ts=new Set(Ae);var wt=64*1024*1024;var cs=Object.freeze(["chainId","agentAddress","accountAddress","actions","targets","maxValueWei","maxGasWei","maxSlippageBps","expiresAt","nonce","revocationKey"]),us=Object.freeze(["read","simulate"]);var ls=1440*60;var bs=Object.freeze(["privkey","wif","xprv","seed"]);var Es=Object.freeze([{rule:"raw-32-byte-hex-key",re:/^0x[0-9a-fA-F]{64}$/},{rule:"raw-32-byte-hex-bare",re:/^[0-9a-fA-F]{64}$/},{rule:"extended-private-key",re:/\b(?:xprv|tprv|yprv|zprv)[1-9A-HJ-NP-Za-km-z]{107}\b/},{rule:"bitcoin-wif",re:/\b[59KLc][1-9A-HJ-NP-Za-km-z]{50,51}\b/},{rule:"bip39-mnemonic",re:/\b(?:[a-z]{3,8}\s+){11,23}[a-z]{3,8}\b/},{rule:"bearer-token",re:/bearer\s+[A-Za-z0-9._~+/=-]+/i},{rule:"pem-private-key",re:/-----BEGIN[A-Z ]*PRIVATE KEY-----/},{rule:"keystore-path",re:/keystore/i},{rule:"signer-url",re:/https?:\/\/\S*sign/i},{rule:"authorization-header",re:/authorization\s*:/i}]),xs=Object.freeze(["grantid","id","hash","sha256","sha256hex","checksum","txhash","transactionhash","blockhash","digest","userophash","commithash","prevhash","intenthash","canonicalhash","payloadhash","requestid"]);var X=Object.freeze(["intent","quote_comparison","simulation","prepared","approval","signed","broadcast","settlement","balance_delta","position"]),Is=Object.freeze(Object.fromEntries(X.map((e,t)=>[e,Object.freeze(t+1<X.length?[X[t+1]]:[])])));var ht=Object.freeze({intent:"draft",quote_comparison:"draft",simulation:"draft",prepared:"checked",approval:"approval",signed:"signed",broadcast:"submitted",settlement:"finalized",balance_delta:"compensated",position:"compensated"});var yt=Object.freeze(["owner","operator","agent","viewer"]),bt=Object.freeze(["tenant","config","policy","grant","workflow","trade","receipt","audit","telemetry","context","lifecycle"]),Et=Object.freeze({read:"read",create:"create",update:"update",delete:"delete",manage:"manage",prepare:"prepare",cancel:"cancel",export:"export",approve:"approve"}),ua=Object.freeze(["owner"]),la=Object.freeze({ALLOW_ROLE_PERMISSION:"allow.role_permission",DENY_MISSING_CONTEXT:"deny.missing_context",DENY_INVALID_CONTEXT:"deny.invalid_context",DENY_INVALID_REQUEST:"deny.invalid_request",DENY_UNKNOWN_RESOURCE:"deny.unknown_resource",DENY_UNKNOWN_ACTION:"deny.unknown_action",DENY_UNBOUND_OBJECT:"deny.unbound_object",DENY_TENANT_MISMATCH:"deny.tenant_mismatch",DENY_RESOURCE_MISMATCH:"deny.resource_mismatch",DENY_ROLE_PERMISSION:"deny.role_permission",DENY_POLICY_NOT_APPROVER:"deny.policy_not_approver"}),da=new Set(yt),fa=new Set(bt),pa=new Set(Object.values(Et));var xt=Object.freeze({owner:Object.freeze(["tenant:read","tenant:manage","config:read","config:manage","policy:read","policy:manage","grant:read","grant:create","grant:update","grant:delete","grant:manage","workflow:read","workflow:create","workflow:update","workflow:delete","workflow:cancel","workflow:approve","trade:read","trade:prepare","receipt:read","receipt:export","audit:read","audit:export","telemetry:read","telemetry:create","telemetry:export","context:read","context:create","context:update","context:delete","context:manage","context:export","lifecycle:read","lifecycle:create","lifecycle:update","lifecycle:delete","lifecycle:manage","lifecycle:approve","lifecycle:export"]),operator:Object.freeze(["tenant:read","config:read","policy:read","grant:read","workflow:read","workflow:create","workflow:update","workflow:cancel","trade:read","trade:prepare","receipt:read","audit:read","telemetry:read","telemetry:create","context:read","context:create","context:update","context:delete","lifecycle:read","lifecycle:create","lifecycle:update","lifecycle:manage"]),agent:Object.freeze(["tenant:read","config:read","policy:read","grant:read","workflow:read","workflow:create","workflow:update","trade:read","trade:prepare","receipt:read","telemetry:create","context:read","context:create","context:update","lifecycle:read"]),viewer:Object.freeze(["tenant:read","config:read","grant:read","workflow:read","trade:read","receipt:read","audit:read","telemetry:read","context:read","lifecycle:read"])}),ma=Object.freeze(Object.fromEntries(Object.entries(xt).map(([e,t])=>[e,Object.freeze([...t])])));var St=Object.freeze(["succeeded","denied","invalid","failed","cancelled","timed_out","unavailable","skipped"]),At=Object.freeze(["workflow","task","intent","plan","run","event","eval"]),vt=Object.freeze(["taskId","intentId","planId","runId","eventId"]);var ya=Object.freeze({maxAttributes:24,maxKeyLength:48,maxStringLength:256,maxArrayLength:8}),ba=new Set(St),Ea=new Set(At),xa=new Set(vt);var Sa=Object.freeze(["authorization","bearer","cookie","credential","password","passphrase","secret","token","privatekey","privkey","seed","mnemonic","keystore","signature","prompt","systemmessage","usermessage","assistantmessage","rawtransaction","signedtransaction","serializedtransaction","transactionbytes","calldata","callbytes","inputdata"]);var Aa=Object.freeze({taskId:"x-oracle-task-id",intentId:"x-oracle-intent-id",planId:"x-oracle-plan-id",runId:"x-oracle-run-id",eventId:"x-oracle-event-id"});var Na=Object.freeze({"workflow.cancelled":"cancelled","workflow.failed":"failed"});var Pa=32*1024*1024;var Da=Object.freeze({N:1<<17,r:8,p:1}),Fa=256*1024*1024,ja=16*1024;var Ma=Object.freeze({1:{name:"ethereum",mode:"mempool-private",endpoints:["https://rpc.flashbots.net/fast","https://rpc.mevblocker.io"]},8453:{name:"base",mode:"sequencer",endpoints:["https://mainnet-sequencer.base.org"]},10:{name:"optimism",mode:"sequencer",endpoints:["https://mainnet-sequencer.optimism.io"]},42161:{name:"arbitrum",mode:"sequencer",endpoints:["https://arb1-sequencer.arbitrum.io/rpc"]},56:{name:"bsc",mode:"mempool-private",endpoints:["https://rpc.48.club","https://bsc.rpc.blxrbdn.com"]},137:{name:"polygon",mode:"mempool-private",endpoints:["https://polygon-bor-rpc.publicnode.com"]},43114:{name:"avalanche",mode:"public-only",endpoints:[]},999:{name:"hyperevm",mode:"public-only",endpoints:[]}});import{homedir as Z}from"node:os";import{join as Q}from"node:path";var ve=process.env.ORACLE_PUBLIC_DESKTOP==="1",It=ve?process.env.ORACLE_CONFIG_DIR||Q(Z(),".config","oracle"):Q(Z(),".config","oracle"),Ua=ve?It:Q(Z(),".config","mad-desk");var Ya="0".repeat(64),Xa=Object.freeze({PREPARE:"exec.prepare",SIGN:"exec.sign",BROADCAST:"exec.broadcast",POLICY_REJECT:"policy.reject",AUTH_GRANT:"auth.grant",AUTH_OK:"auth.verify.ok",AUTH_FAIL:"auth.verify.fail"});var Za=Promise.resolve();import{readFileSync as uc,readdirSync as lc,existsSync as kt}from"node:fs";import{dirname as Ot,join as x}from"node:path";import{fileURLToPath as Tt}from"node:url";var S=Ot(Tt(import.meta.url));function Nt(){let e=[x(S,"descriptors"),x(S,"clear-sign","descriptors"),x(S,"..","clear-sign","descriptors"),x(S,"..","..","clear-sign","descriptors"),x(S,"..","..","..","clear-sign","descriptors")];for(let t of e)if(kt(t))return t;return e[0]}var mc=Nt();var wc=(1n<<256n)-1n;import{Wallet as vc}from"ethers";import{base58 as kc}from"@scure/base";import{ed25519 as Tc}from"@noble/curves/ed25519.js";import{NETWORK as Cc,TEST_NETWORK as _c,WIF as Rc,p2wpkh as Lc}from"@scure/btc-signer";import{pubECDSA as Pc}from"@scure/btc-signer/utils.js";var Fc=Object.freeze(["spot-limit-create","spot-limit-cancel","spot-order-status"]),jc=Object.freeze(["binance","bybit","okx","coinbase"]),qc=Object.freeze({binance:"https://api.binance.com",bybit:"https://api.bybit.com",okx:"https://openapi.okx.com",coinbase:"https://api.exchange.coinbase.com"}),Mc=Object.freeze({binance:"/api/v3",bybit:"/v5/order",okx:"/api/v5/trade",coinbase:"/orders"}),Hc=Object.freeze(["version","surface","kind","venue","credentialRef","symbol","base","quote","side","baseSize","limitPrice","maxQuoteNotional","timeInForce","clientOrderId","expiresAtMs","venueOrderId","nonce","grantId","artifactHash"]),zc=Object.freeze(["market-create","withdraw","transfer","subaccount","leverage","futures","margin","convert","api-key"]),Wc=Object.freeze(["url","host","path","method","headers","signature","apiKey","apiSecret","passphrase","privateKey","redirect","proxy"]),Uc=Object.freeze(["ccxt","binance-api-node","node-binance-api","coinbase-advanced-node","@okx-dex/okx-dex-sdk","bybit-api"]),Vc=Object.freeze({perOrderQuote:"sealed-owner-policy",dailyGrossQuote:"sealed-owner-policy",scope:Object.freeze(["per-order","UTC-day","account","venue","quote"]),envelopeFieldIsNotCeiling:!0}),Jc=Object.freeze({binanceRecvWindowMs:5e3,bybitWindowMs:5e3,maxLocalSkewMs:2e3}),Kc=Object.freeze({perSecond:1,perMinute:30,bind:"tighter"});var Rt=Object.freeze({binance:Object.freeze({create:["POST","/api/v3/order"],cancel:["DELETE","/api/v3/order"],status:["GET","/api/v3/order"]}),bybit:Object.freeze({create:["POST","/v5/order/create"],cancel:["POST","/v5/order/cancel"],status:["GET","/v5/order/realtime"]}),okx:Object.freeze({create:["POST","/api/v5/trade/order"],cancel:["POST","/api/v5/trade/cancel-order"],status:["GET","/api/v5/trade/order"]}),coinbase:Object.freeze({create:["POST","/orders"],cancel:["DELETE","/orders/{order_id}"],status:["GET","/orders/{order_id}"]})}),ke=Object.freeze({binance:"https://api.binance.com",bybit:"https://api.bybit.com",okx:"https://openapi.okx.com",coinbase:"https://api.exchange.coinbase.com"});var ou=256*1024;var u=new re(["function collection() view returns (address)","function token() view returns (address)","function robinhoodSwapFeeWei() view returns (uint256)","function quoteSpecificBuy(uint256 tokenId) view returns (uint256 totalCost,uint256 baseCost,uint256 fee,uint256 protocolFee,bool available)","function quoteSellNFT() view returns (uint256 netPayout,uint256 grossPayout,uint256 fee,uint256 protocolFee)","function inventory(uint256 tokenId) view returns (bool)","function buySpecificNFT(uint256 tokenId,uint256 maxCost) payable","function sellNFT(uint256 tokenId,uint256 minPayout) payable"]),Oe=new re(["function decimals() view returns (uint8)","function allowance(address owner,address spender) view returns (uint256)"]),te=new re(["function ownerOf(uint256 tokenId) view returns (address)","function getApproved(uint256 tokenId) view returns (address)","function isApprovedForAll(address owner,address operator) view returns (bool)"]);function c(e,t){let r=String(e||"").toLowerCase();if(!/^0x[0-9a-f]{40}$/.test(r))throw new Error(`signer: invalid ${t}`);return r}function Te(e,t){return Object.entries(e||{}).find(([r])=>r.toLowerCase()===t)?.[1]}function $t(e,t){let r=e?.anvilQuote;if(!r||typeof r!="object"||Array.isArray(r))throw new Error("signer: exact prepared Anvil quote is required");if(!e?.artifact?.anvilQuote||JSON.stringify(e.artifact.anvilQuote)!==JSON.stringify(r))throw new Error("signer: exact prepared Anvil quote artifact mismatch");return Object.freeze(t==="buy"?{totalCostRaw:BigInt(r.totalCostRaw).toString(),baseCostRaw:BigInt(r.baseCostRaw).toString(),feeRaw:BigInt(r.feeRaw).toString(),protocolFeeRaw:BigInt(r.protocolFeeRaw).toString(),available:r.available===!0}:{netPayoutRaw:BigInt(r.netPayoutRaw).toString(),grossPayoutRaw:BigInt(r.grossPayoutRaw).toString(),feeRaw:BigInt(r.feeRaw).toString(),protocolFeeRaw:BigInt(r.protocolFeeRaw).toString()})}function Pt(e,t,r){if(e.preconditions?.exactQuoteConfirmed!==!0)throw new Error("signer: exact prepared Anvil quote confirmation required");let s=e.artifact,p=t==="buy"?[r.totalCostRaw,e.maxPaymentTokenAmountRaw,s?.maxPaymentTokenAmountRaw,e.exactQuoteTotalCostRaw,s?.exactQuoteTotalCostRaw,e.preconditions?.confirmedTotalCostRaw]:[r.netPayoutRaw,e.minPayoutRaw,s?.minPayoutRaw,e.exactQuoteNetPayoutRaw,s?.exactQuoteNetPayoutRaw,e.preconditions?.confirmedNetPayoutRaw],n;try{n=BigInt(p[0]);for(let g of p.slice(1))if(BigInt(g)!==n)throw new Error("mismatch")}catch{throw new Error(`signer: exact Anvil ${t} settlement limit mismatch`)}let d=s?.transactions;if(!Array.isArray(d)||d.length!==1)throw new Error("signer: exact Anvil action transaction required");let h=t==="buy"?"buySpecificNFT":"sellNFT",f;try{if(f=u.decodeFunctionData(h,d[0].data),u.encodeFunctionData(h,[f[0],f[1]]).toLowerCase()!==String(d[0].data).toLowerCase())throw new Error("non-canonical")}catch{throw new Error(`signer: exact Anvil ${t} calldata required`)}if(BigInt(f[0])!==BigInt(e.tokenId)||BigInt(f[1])!==n)throw new Error(`signer: exact Anvil ${t} calldata limit mismatch`);return n}async function l(e,t,r,s,p,n=[]){let d=await e.send("eth_call",[{to:t,data:r.encodeFunctionData(s,n)},p]);return r.decodeFunctionResult(s,d)[0]}async function Ne(e,t,r,{nowMs:s=Date.now(),signerAddress:p}={}){if(t?.surface!=="evm-nft"||String(t?.provider).toLowerCase()!=="anvil-nft")return null;if(!e||typeof e.send!="function")throw new Error("signer: trusted RPC cannot attest Anvil market");let n=c(t.destination,"Anvil market"),d=c(t.contract,"Anvil collection"),h=c(t.paymentToken,"Anvil payment token"),f=BigInt(t.nativeSwapFeeWei),g=Number(t.paymentTokenDecimals),y=c(p,"Anvil signer identity"),Ce=c(t.owner,"Anvil envelope owner");if(y!==Ce)throw new Error("signer: Anvil signer identity mismatch");let m=BigInt(t.tokenId);if(m<0n)throw new Error("signer: invalid Anvil tokenId");let w=String(t.nftAction||"").toLowerCase();if(w!=="buy"&&w!=="sell")throw new Error("signer: unsupported Anvil NFT action");let _=$t(t,w),R=Pt(t,w,_),A=t.anvilAttestation;if(!A||typeof A!="object"||Number(A.snapshotExpiresAtMs)<=Number(s))throw new Error("signer: fresh provider Anvil attestation required");let L=String(Te(r.anvilRuntimeCodeHashes,n)||"").toLowerCase();if(!/^0x[0-9a-f]{64}$/.test(L)||L!==String(A.runtimeCodeHash||"").toLowerCase())throw new Error("signer: Anvil runtime is not reviewed by policy");let ne=Te(r.nftPaymentTokenCaps,h);if(!ne||Number(ne.decimals)!==g)throw new Error("signer: Anvil payment token decimals are not reviewed by policy");let oe=String(await e.send("eth_chainId",[])).toLowerCase();if(!/^0x(?:0|[1-9a-f][0-9a-f]*)$/.test(oe)||BigInt(oe)!==4663n)throw new Error("signer: trusted RPC Anvil chain mismatch");let v=String(await e.send("eth_blockNumber",[])).toLowerCase();if(!/^0x(?:0|[1-9a-f][0-9a-f]*)$/.test(v))throw new Error("signer: trusted RPC returned an invalid Anvil block number");let _e=BigInt(v),ie=await e.send("eth_getBlockByNumber",[v,!1]),$=String(ie?.hash||"").toLowerCase();if(String(ie?.number||"").toLowerCase()!==v||!/^0x[0-9a-f]{64}$/.test($))throw new Error("signer: trusted RPC returned an invalid Anvil block attestation");let i=Object.freeze({blockHash:$,requireCanonical:!0}),P=String(await e.send("eth_getCode",[n,i])).toLowerCase();if(!/^0x[0-9a-f]+$/.test(P)||P==="0x")throw new Error("signer: Anvil market runtime is empty");let se=Lt(P).toLowerCase();if(se!==L)throw new Error("signer: Anvil market runtime mismatch with reviewed policy");let[Re,Le,$e]=await Promise.all([l(e,n,u,"collection",i),l(e,n,u,"token",i),l(e,n,u,"robinhoodSwapFeeWei",i)]),b=c(Re,"live Anvil collection"),I=c(Le,"live Anvil payment token"),ae=BigInt($e).toString();if(b!==d)throw new Error("signer: live Anvil collection mismatch");if(I!==h)throw new Error("signer: live Anvil payment token mismatch");if(ae!==f.toString())throw new Error("signer: live Anvil native swap fee mismatch");let B=Number(await l(e,I,Oe,"decimals",i));if(!Number.isSafeInteger(B)||B!==g)throw new Error("signer: live Anvil payment token decimals mismatch");let D=c(await l(e,b,te,"ownerOf",i,[m]),"live Anvil token owner"),F=null,k=null,O=null,T=null,o;if(w==="buy"){let[j,q,M]=await Promise.all([l(e,n,u,"inventory",i,[m]),l(e,I,Oe,"allowance",i,[y,n]),e.send("eth_call",[{to:n,data:u.encodeFunctionData("quoteSpecificBuy",[m])},i])]);F=!!j,k=BigInt(q).toString();let a=u.decodeFunctionResult("quoteSpecificBuy",M);if(o=Object.freeze({totalCostRaw:BigInt(a[0]).toString(),baseCostRaw:BigInt(a[1]).toString(),feeRaw:BigInt(a[2]).toString(),protocolFeeRaw:BigInt(a[3]).toString(),available:!!a[4]}),JSON.stringify(o)!==JSON.stringify(_))throw new Error("signer: exact Anvil buy quote changed after preparation");if(D!==n)throw new Error("signer: exact Anvil token owner is not the market");if(!F)throw new Error("signer: exact Anvil token is not in market inventory");if(BigInt(k)!==BigInt(t.preconditions?.allowanceRaw))throw new Error("signer: live Anvil ERC20 allowance changed after preparation");if(BigInt(k)<R)throw new Error("signer: live Anvil ERC20 allowance is insufficient");if(!o.available)throw new Error("signer: exact Anvil buy quote is unavailable");if(BigInt(o.totalCostRaw)!==R)throw new Error("signer: live Anvil buy quote does not equal exact payment limit");if(BigInt(o.totalCostRaw)!==BigInt(o.baseCostRaw)+BigInt(o.feeRaw)+BigInt(o.protocolFeeRaw))throw new Error("signer: exact Anvil buy quote fee arithmetic mismatch")}else{let[j,q,M]=await Promise.all([l(e,b,te,"getApproved",i,[m]),l(e,b,te,"isApprovedForAll",i,[y,n]),e.send("eth_call",[{to:n,data:u.encodeFunctionData("quoteSellNFT")},i])]);O=c(j,"live Anvil token approval"),T=!!q;let a=u.decodeFunctionResult("quoteSellNFT",M);if(o=Object.freeze({netPayoutRaw:BigInt(a[0]).toString(),grossPayoutRaw:BigInt(a[1]).toString(),feeRaw:BigInt(a[2]).toString(),protocolFeeRaw:BigInt(a[3]).toString()}),JSON.stringify(o)!==JSON.stringify(_))throw new Error("signer: exact Anvil sell quote changed after preparation");if(D!==y)throw new Error("signer: exact Anvil token owner does not match signer");if(O!==n&&!T)throw new Error("signer: live Anvil NFT approval is insufficient");if(O!==c(t.preconditions?.approvedAddress,"prepared Anvil token approval")||T!==!!t.preconditions?.approvedForAll)throw new Error("signer: live Anvil NFT approval changed after preparation");if(BigInt(o.netPayoutRaw)!==R)throw new Error("signer: live Anvil sell quote does not equal exact payout limit");if(BigInt(o.netPayoutRaw)+BigInt(o.feeRaw)+BigInt(o.protocolFeeRaw)!==BigInt(o.grossPayoutRaw))throw new Error("signer: exact Anvil sell quote fee arithmetic mismatch")}return Object.freeze({source:"local-signer-trusted-rpc",chainId:4663,market:n,collection:b,paymentToken:I,paymentTokenDecimals:B,nativeSwapFeeWei:ae,signerAddress:y,nftAction:w,tokenId:m.toString(),tokenOwner:D,inventoryMember:F,allowanceRaw:k,approvedAddress:O,approvedForAll:T,quote:o,blockNumber:_e.toString(),blockHash:$,runtimeCodeHash:se,verifiedAtMs:Number(s)})}try{let e=JSON.parse(Bt.readFileSync(0,"utf8")),t=new Dt(e.rpcUrl,Number(e.chainId)),r=await Ne(t,e.envelope,e.policy,{nowMs:Number(e.nowMs),signerAddress:e.signerAddress});process.stdout.write(JSON.stringify(r))}catch(e){process.stderr.write(`Anvil attestation failed: ${String(e?.message||e)}
|
|
2
2
|
`),process.exitCode=1}
|