@gvnrdao/dh-lit-actions 0.0.320 → 0.0.321
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/dist/a_dev_address-probe-signer.meta.json +1 -1
- package/dist/a_dev_address-probe.meta.json +1 -1
- package/dist/a_dev_always-signer.meta.json +1 -1
- package/dist/a_dev_authorization-dummy-b.meta.json +1 -1
- package/dist/a_dev_authorization-dummy.meta.json +1 -1
- package/dist/a_dev_ethers-version-probe.meta.json +1 -1
- package/dist/a_dev_process-payment-sign-only.meta.json +1 -1
- package/dist/agent-module-executor.action.js +1 -1
- package/dist/agent-module-executor.hash +1 -1
- package/dist/agent-module-executor.meta.json +5 -5
- package/dist/btc-address-balance.meta.json +1 -1
- package/dist/btc-transaction-signer.meta.json +1 -1
- package/dist/btc-utxo-invalidator.meta.json +1 -1
- package/dist/btc-withdrawal.action.js +1 -1
- package/dist/btc-withdrawal.hash +1 -1
- package/dist/btc-withdrawal.meta.json +5 -5
- package/dist/encrypt-parameter.meta.json +1 -1
- package/dist/extend-position-validator.meta.json +1 -1
- package/dist/liquidation-validator.meta.json +1 -1
- package/dist/loan-vault-btc-balance.meta.json +1 -1
- package/dist/pkp-validator.meta.json +1 -1
- package/dist/price-oracle.meta.json +1 -1
- package/dist/process-payment-validator.meta.json +1 -1
- package/dist/stale-spend-recovery-validator.meta.json +1 -1
- package/dist/ucd-mint-validator.meta.json +1 -1
- package/package.json +4 -2
- package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts.map +1 -1
- package/pkg-dist/pkg-src/index.js +18 -24
- package/pkg-dist/pkg-src/index.js.map +2 -2
- package/pkg-dist/src/constants/chunks/deployment-addresses.d.ts +7 -0
- package/pkg-dist/src/constants/chunks/deployment-addresses.d.ts.map +1 -1
- package/pkg-dist/src/modules/business-rules-math.module.d.ts +30 -0
- package/pkg-dist/src/modules/business-rules-math.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/pinned-addresses.d.ts +39 -1
- package/pkg-dist/src/modules/pinned-addresses.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var _LIT_ACTION_=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i={};((t,r)=>{for(var n in r)e(t,n,{get:r[n],enumerable:!0})})(i,{main:()=>main});var o=1,a=["function agentOf(address user) view returns (tuple(address agent, uint64 validUntil, uint8 status, uint64 registeredAt, uint64 revokedAt))","function canMint(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)","function canRepay(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canRenew(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canWithdraw(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)"],s=["NONE","PAUSED","NO_GRANT","SCOPE_DISABLED","NO_AGENT","AGENT_REVOKED","AGENT_EXPIRED","NOT_BORROWER","POSITION_TERMINAL"],u=e=>{const t=Number(e);return Number.isInteger(t)&&t>=0&&t<s.length?s[t]:`UNKNOWN(${String(e)})`};var d={1:{AgentDelegationRegistry:"0x54853b7E91ce2Be34ce65655D80c4447e67187Fa"},11155111:{AgentModuleFactory:"0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5",AgentDelegationRegistry:"0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025"}};var c=(e=>(e.SEPOLIA="sepolia",e.ETHEREUM="ethereum",e.HARDHAT="hardhat",e))(c||{}),l={sepolia:"regtest",ethereum:"mainnet",hardhat:"regtest"},h={ethereum:1,sepolia:11155111,hardhat:1337};var g={hardhat:{chain:"hardhat",chainId:h.hardhat,bitcoinNetwork:l.hardhat,allowArbitraryBitcoinProvider:!0,allowArbitraryEvmRpc:!0,pinContractAddresses:!1,allowDevSinglePriceProvider:!0,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},sepolia:{chain:"sepolia",chainId:h.sepolia,bitcoinNetwork:l.sepolia,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},ethereum:{chain:"ethereum",chainId:h.ethereum,bitcoinNetwork:l.ethereum,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:6,minBitcoinSpendConfirmations:6,minConsensusProviders:2}};function f(e){const t=function(e){const t=e.toLowerCase().trim();if("sepolia"===t)return"sepolia";if("ethereum"===t||"mainnet"===t)return"ethereum";if("hardhat"===t)return"hardhat";throw new Error(`Unsupported EVM chain: "${e}". Supported chains: ${Object.values(c).join(", ")}`)}(e),r=g[t];if(!r)throw new Error(`No chain policy registered for "${e}"`);return r}var p=["AgentModuleFactory","AgentDelegationRegistry"];function m(e,t){if(!e.pinContractAddresses){const e={};for(const r of p){const n=t?.[r];"string"==typeof n&&n.length>0&&(e[r]=n)}return e}const r=(n=e.chainId,d[n]??{});var n;const i={};for(const n of p){const o=r[n];if(!o)continue;const a=t?.[n];if("string"==typeof a&&a.length>0&&a.toLowerCase()!==o.toLowerCase())throw new Error(`Caller-supplied "${n}" (${a}) contradicts the pinned ${e.chain} address (${o}); refusing to evaluate the Safe-agent authorization arm`);i[n]=o}return i}var w=["function execute(address target, bytes calldata data)"],y=["function safe() view returns (address)","function agent() view returns (address)","function isWhitelisted(address target, bytes4 selector) view returns (bool)"],b=["function isFromFactory(address) view returns (bool)"],v={mint:"mint-ucd",repay:"make-payment",renew:"extend-position",withdraw:"withdraw-btc"},I={mint:[{signature:"mintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes)",positionIdPath:"flat"}],repay:[{signature:"approve(address,uint256)",positionIdPath:null},{signature:"makePayment(bytes32,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],renew:[{signature:"extendPosition(bytes32,uint256,uint256,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],withdraw:[{signature:"withdrawBTC((bytes32,bytes32,bytes32,bytes32,bytes32,string,uint256,uint256,uint256,uint256,string,uint32),bytes,bytes)",positionIdPath:"tuple"}]};var A,x=(e,t)=>"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase();function E(e,t){if("string"!=typeof e||!/^0x[0-9a-fA-F]{40}$/.test(e))throw new Error(`[agent-module-executor] ${t} must be a 0x address, got ${JSON.stringify(e)}`);return e}async function main(e){const t=e?.mode;if("authorize"!==t&&"execute"!==t)throw new Error(`[agent-module-executor] mode must be "authorize" or "execute", got ${JSON.stringify(t)}`);const r=E(e?.safe,"safe"),n=E(e?.module,"module"),i=E(e?.pkpId,"pkpId");if("string"!=typeof e?.positionId||!/^0x[0-9a-fA-F]{64}$/.test(e.positionId))throw new Error("[agent-module-executor] positionId must be a bytes32 hex string");if("string"!=typeof e?.chain||0===e.chain.length)throw new Error('[agent-module-executor] chain is required (e.g. "sepolia")');const s=f(e.chain);if("number"!=typeof e?.chainId||!Number.isInteger(e.chainId))throw new Error("[agent-module-executor] chainId must be an integer");if(e.chainId!==s.chainId)throw new Error(`[agent-module-executor] chainId ${e.chainId} does not match the policy chainId ${s.chainId} derived from chain=${e.chain} \u2014 refusing`);if("string"!=typeof e?.rpcUrl||!e.rpcUrl.startsWith("http"))throw new Error("[agent-module-executor] rpcUrl is required (server-supplied)");const d=m(s,e?.contractAddresses),c=E(d.AgentDelegationRegistry,"AgentDelegationRegistry (pinned; unavailable on this chain)"),l=E(d.AgentModuleFactory,"AgentModuleFactory (pinned; unavailable on this chain)"),h=new ethers.providers.JsonRpcProvider(e.rpcUrl),g=new ethers.Contract(l,b,h);if(!0!==await g.isFromFactory(n))throw new Error(`[agent-module-executor] module ${n} was not deployed by the canonical AgentModuleFactory ${l} \u2014 refusing to act through an unprovenanced module`);const p=new ethers.Contract(n,y,h),[A,P]=await Promise.all([p.safe(),p.agent()]);if(!x(A,r))throw new Error(`[agent-module-executor] module ${n} is bound to Safe ${A}, not ${r}`);const $=await async function(e){const{provider:t,registryAddress:r,safe:n,positionId:i,op:s,candidateAgent:d}=e,c=new ethers.Contract(r,a,t),l=await c.agentOf(n),h=l.agent??l[0],g=Number(l.status??l[2]),f=Number(l.validUntil??l[1]);if(g!==o)throw new Error(`[agent-authorization] Safe ${n} has no Active agent registration (status=${g}) \u2014 refusing`);if(h.toLowerCase()!==d.toLowerCase())throw new Error(`[agent-authorization] Safe ${n}'s registered agent is ${h}, but ${d} was supplied \u2014 refusing to sign with a key that is merely group-co-member`);if(!Number.isFinite(f)||0===f)throw new Error(`[agent-authorization] agent record for ${n} has no validUntil`);const p="mint"===s?"canMint":"repay"===s?"canRepay":"renew"===s?"canRenew":"withdraw"===s?"canWithdraw":null;if(!p)throw new Error(`[agent-authorization] unknown op ${String(s)}`);const m=await c[p](i,h),w=m.ok??m[0],y=m.reason??m[1];if(!0!==w)throw new Error(`[agent-authorization] registry refused ${s} for position ${i} (agent ${h}): ${u(y)}`);const b=m.effectiveFloorBps??m[2];return{agent:h,validUntil:f,effectiveFloorBps:void 0!==b?Number(b):void 0}}({provider:h,registryAddress:c,safe:r,positionId:e.positionId,op:e.op,candidateAgent:i});if(!x(P,i))throw new Error(`[agent-module-executor] module agent is ${P} but pkpId ${i} was supplied \u2014 refusing to sign with a key the module does not recognise`);if("execute"===t&&"withdraw"===e.op)throw new Error(`[agent-module-executor] execute mode for op=withdraw is not yet supported: the collateral floor (effectiveFloorBps=${$.effectiveFloorBps}) has no enforcement point in this chain yet \u2014 refusing rather than sign an unbounded, broadcastable withdrawal transaction`);const C=await Lit.Actions.getPrivateKey({pkpId:i}),N="string"==typeof C?C.startsWith("0x")?C:`0x${C}`:String(C),D=new ethers.Wallet(N);if(!x(D.address,i))throw new Error(`[agent-module-executor] getPrivateKey returned a key for ${D.address}, not ${i}`);const F={success:!0,mode:t,module:n,agent:$.agent,op:e.op};if("authorize"===t){if("number"!=typeof e.timestamp||!Number.isInteger(e.timestamp))throw new Error("[agent-module-executor] timestamp is required for mode=authorize (quantum-aligned)");const t=function(e,t){if("renew"===e.op){if("number"!=typeof e.selectedTerm)throw new Error("[agent-module-executor] selectedTerm is required for op=renew");return ethers.utils.solidityKeccak256(["bytes32","uint256","uint256","uint256","bytes32"],[e.positionId,e.timestamp,e.chainId,e.selectedTerm,t])}if("string"!=typeof e.amount||0===e.amount.length)throw new Error(`[agent-module-executor] amount is required for op=${e.op}`);if("withdraw"===e.op){if("string"!=typeof e.destinationAddress||0===e.destinationAddress.length)throw new Error("[agent-module-executor] destinationAddress is required for op=withdraw");return ethers.utils.solidityKeccak256(["bytes32","uint256","uint256","uint256","string","bytes32"],[e.positionId,e.timestamp,e.chainId,e.amount,e.destinationAddress,t])}return ethers.utils.solidityKeccak256(["bytes32","uint256","uint256","uint256","bytes32"],[e.positionId,e.timestamp,e.chainId,e.amount,t])}(e,ethers.utils.keccak256(ethers.utils.toUtf8Bytes(v[e.op]))),r=await D.signMessage(ethers.utils.arrayify(t));return{...F,authorization:{timestamp:e.timestamp,signature:r,signer:D.address}}}const O=E(e?.target,"target");if("string"!=typeof e?.innerData||!/^0x[0-9a-fA-F]{8,}$/.test(e.innerData))throw new Error("[agent-module-executor] innerData must be 0x-hex with a 4-byte selector for mode=execute");const B=e?.tx;if(!B||"number"!=typeof B.nonce||!Number.isInteger(B.nonce)||"string"!=typeof B.gasLimit||"string"!=typeof B.maxFeePerGas||"string"!=typeof B.maxPriorityFeePerGas)throw new Error("[agent-module-executor] tx.{nonce,gasLimit,maxFeePerGas,maxPriorityFeePerGas} are required for mode=execute and must be caller-supplied (multi-node determinism)");const T=e.innerData.slice(0,10);if(!0!==await p.isWhitelisted(O,T))throw new Error(`[agent-module-executor] (${O}, ${T}) is not on module ${n}'s whitelist \u2014 refusing`);const _=(I[e.op]??[]).find((e=>{return(t=e.signature,ethers.utils.id(t).slice(0,10)).toLowerCase()===T.toLowerCase();var t}));if(!_)throw new Error(`[agent-module-executor] op=${e.op} does not authorize selector ${T}. createPosition, setPositionDelegate, and approve-outside-a-repay-grant have no corresponding AgentDelegationRegistry scope and are never reachable through this action (setPositionDelegate specifically: vigil concern C-43) \u2014 refusing to sign`);if(null!==_.positionIdPath){const t=_.signature.slice(0,_.signature.indexOf("(")),r=new ethers.utils.Interface([`function ${_.signature}`]).decodeFunctionData(t,e.innerData),n="tuple"===_.positionIdPath?r[0][0]:r[0];if(!x(n,e.positionId))throw new Error(`[agent-module-executor] innerData targets position ${n}, but the scope grant checked in step 3 was for ${e.positionId} \u2014 refusing to sign a call against a different position than the one authorized`)}const k=new ethers.utils.Interface(w).encodeFunctionData("execute",[O,e.innerData]),L=await D.signTransaction({to:n,data:k,value:0,chainId:e.chainId,nonce:B.nonce,gasLimit:ethers.BigNumber.from(B.gasLimit),maxFeePerGas:ethers.BigNumber.from(B.maxFeePerGas),maxPriorityFeePerGas:ethers.BigNumber.from(B.maxPriorityFeePerGas),type:2});return{...F,signedTransaction:L}}return A=i,((i,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let u of r(o))n.call(i,u)||u===a||e(i,u,{get:()=>o[u],enumerable:!(s=t(o,u))||s.enumerable});return i})(e({},"__esModule",{value:!0}),A)})();if("object"==typeof _LIT_ACTION_)if("function"==typeof _LIT_ACTION_.main)var main=_LIT_ACTION_.main;else"function"==typeof _LIT_ACTION_.go&&_LIT_ACTION_.go();
|
|
1
|
+
var _LIT_ACTION_=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i={};((t,r)=>{for(var n in r)e(t,n,{get:r[n],enumerable:!0})})(i,{main:()=>main});var o=1,a=["function agentOf(address user) view returns (tuple(address agent, uint64 validUntil, uint8 status, uint64 registeredAt, uint64 revokedAt))","function canMint(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)","function canRepay(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canRenew(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canWithdraw(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)"],s=["NONE","PAUSED","NO_GRANT","SCOPE_DISABLED","NO_AGENT","AGENT_REVOKED","AGENT_EXPIRED","NOT_BORROWER","POSITION_TERMINAL"],u=e=>{const t=Number(e);return Number.isInteger(t)&&t>=0&&t<s.length?s[t]:`UNKNOWN(${String(e)})`};var d={1:{AgentDelegationRegistry:"0x54853b7E91ce2Be34ce65655D80c4447e67187Fa",BitcoinWithdrawalAddressRegistry:"0xf667f77FDba7458345f227eB6Bfe4148243E7270"},11155111:{AgentModuleFactory:"0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5",AgentDelegationRegistry:"0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",BitcoinWithdrawalAddressRegistry:"0x6376D392097F0A81e51BD83960A97EA20eaf1dbe"}};var c=(e=>(e.SEPOLIA="sepolia",e.ETHEREUM="ethereum",e.HARDHAT="hardhat",e))(c||{}),l={sepolia:"regtest",ethereum:"mainnet",hardhat:"regtest"},g={ethereum:1,sepolia:11155111,hardhat:1337};var h={hardhat:{chain:"hardhat",chainId:g.hardhat,bitcoinNetwork:l.hardhat,allowArbitraryBitcoinProvider:!0,allowArbitraryEvmRpc:!0,pinContractAddresses:!1,allowDevSinglePriceProvider:!0,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},sepolia:{chain:"sepolia",chainId:g.sepolia,bitcoinNetwork:l.sepolia,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},ethereum:{chain:"ethereum",chainId:g.ethereum,bitcoinNetwork:l.ethereum,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:6,minBitcoinSpendConfirmations:6,minConsensusProviders:2}};function f(e){const t=function(e){const t=e.toLowerCase().trim();if("sepolia"===t)return"sepolia";if("ethereum"===t||"mainnet"===t)return"ethereum";if("hardhat"===t)return"hardhat";throw new Error(`Unsupported EVM chain: "${e}". Supported chains: ${Object.values(c).join(", ")}`)}(e),r=h[t];if(!r)throw new Error(`No chain policy registered for "${e}"`);return r}var p=["AgentModuleFactory","AgentDelegationRegistry","BitcoinWithdrawalAddressRegistry"];function m(e,t){if(!e.pinContractAddresses){const e={};for(const r of p){const n=t?.[r];"string"==typeof n&&n.length>0&&(e[r]=n)}return e}const r=(n=e.chainId,d[n]??{});var n;const i={};for(const n of p){const o=r[n];if(!o)continue;const a=t?.[n];if("string"==typeof a&&a.length>0&&a.toLowerCase()!==o.toLowerCase())throw new Error(`Caller-supplied "${n}" (${a}) contradicts the pinned ${e.chain} address (${o}); refusing to evaluate the Safe-agent authorization arm`);i[n]=o}return i}var w=["function execute(address target, bytes calldata data)"],y=["function safe() view returns (address)","function agent() view returns (address)","function isWhitelisted(address target, bytes4 selector) view returns (bool)"],b=["function isFromFactory(address) view returns (bool)"],v={mint:"mint-ucd",repay:"make-payment",renew:"extend-position",withdraw:"withdraw-btc"},I={mint:[{signature:"mintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes)",positionIdPath:"flat"}],repay:[{signature:"approve(address,uint256)",positionIdPath:null},{signature:"makePayment(bytes32,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],renew:[{signature:"extendPosition(bytes32,uint256,uint256,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],withdraw:[{signature:"withdrawBTC((bytes32,bytes32,bytes32,bytes32,bytes32,string,uint256,uint256,uint256,uint256,string,uint32),bytes,bytes)",positionIdPath:"tuple"}]};var A,E=(e,t)=>"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase();function x(e,t){if("string"!=typeof e||!/^0x[0-9a-fA-F]{40}$/.test(e))throw new Error(`[agent-module-executor] ${t} must be a 0x address, got ${JSON.stringify(e)}`);return e}async function main(e){const t=e?.mode;if("authorize"!==t&&"execute"!==t)throw new Error(`[agent-module-executor] mode must be "authorize" or "execute", got ${JSON.stringify(t)}`);const r=x(e?.safe,"safe"),n=x(e?.module,"module"),i=x(e?.pkpId,"pkpId");if("string"!=typeof e?.positionId||!/^0x[0-9a-fA-F]{64}$/.test(e.positionId))throw new Error("[agent-module-executor] positionId must be a bytes32 hex string");if("string"!=typeof e?.chain||0===e.chain.length)throw new Error('[agent-module-executor] chain is required (e.g. "sepolia")');const s=f(e.chain);if("number"!=typeof e?.chainId||!Number.isInteger(e.chainId))throw new Error("[agent-module-executor] chainId must be an integer");if(e.chainId!==s.chainId)throw new Error(`[agent-module-executor] chainId ${e.chainId} does not match the policy chainId ${s.chainId} derived from chain=${e.chain} \u2014 refusing`);if("string"!=typeof e?.rpcUrl||!e.rpcUrl.startsWith("http"))throw new Error("[agent-module-executor] rpcUrl is required (server-supplied)");const d=m(s,e?.contractAddresses),c=x(d.AgentDelegationRegistry,"AgentDelegationRegistry (pinned; unavailable on this chain)"),l=x(d.AgentModuleFactory,"AgentModuleFactory (pinned; unavailable on this chain)"),g=new ethers.providers.JsonRpcProvider(e.rpcUrl),h=new ethers.Contract(l,b,g);if(!0!==await h.isFromFactory(n))throw new Error(`[agent-module-executor] module ${n} was not deployed by the canonical AgentModuleFactory ${l} \u2014 refusing to act through an unprovenanced module`);const p=new ethers.Contract(n,y,g),[A,P]=await Promise.all([p.safe(),p.agent()]);if(!E(A,r))throw new Error(`[agent-module-executor] module ${n} is bound to Safe ${A}, not ${r}`);const $=await async function(e){const{provider:t,registryAddress:r,safe:n,positionId:i,op:s,candidateAgent:d}=e,c=new ethers.Contract(r,a,t),l=await c.agentOf(n),g=l.agent??l[0],h=Number(l.status??l[2]),f=Number(l.validUntil??l[1]);if(h!==o)throw new Error(`[agent-authorization] Safe ${n} has no Active agent registration (status=${h}) \u2014 refusing`);if(g.toLowerCase()!==d.toLowerCase())throw new Error(`[agent-authorization] Safe ${n}'s registered agent is ${g}, but ${d} was supplied \u2014 refusing to sign with a key that is merely group-co-member`);if(!Number.isFinite(f)||0===f)throw new Error(`[agent-authorization] agent record for ${n} has no validUntil`);const p="mint"===s?"canMint":"repay"===s?"canRepay":"renew"===s?"canRenew":"withdraw"===s?"canWithdraw":null;if(!p)throw new Error(`[agent-authorization] unknown op ${String(s)}`);const m=await c[p](i,g),w=m.ok??m[0],y=m.reason??m[1];if(!0!==w)throw new Error(`[agent-authorization] registry refused ${s} for position ${i} (agent ${g}): ${u(y)}`);const b=m.effectiveFloorBps??m[2];return{agent:g,validUntil:f,effectiveFloorBps:void 0!==b?Number(b):void 0}}({provider:g,registryAddress:c,safe:r,positionId:e.positionId,op:e.op,candidateAgent:i});if(!E(P,i))throw new Error(`[agent-module-executor] module agent is ${P} but pkpId ${i} was supplied \u2014 refusing to sign with a key the module does not recognise`);const C=await Lit.Actions.getPrivateKey({pkpId:i}),N="string"==typeof C?C.startsWith("0x")?C:`0x${C}`:String(C),D=new ethers.Wallet(N);if(!E(D.address,i))throw new Error(`[agent-module-executor] getPrivateKey returned a key for ${D.address}, not ${i}`);const B={success:!0,mode:t,module:n,agent:$.agent,op:e.op};if("authorize"===t){if("number"!=typeof e.timestamp||!Number.isInteger(e.timestamp))throw new Error("[agent-module-executor] timestamp is required for mode=authorize (quantum-aligned)");const t=function(e,t){if("renew"===e.op){if("number"!=typeof e.selectedTerm)throw new Error("[agent-module-executor] selectedTerm is required for op=renew");return ethers.utils.solidityKeccak256(["bytes32","uint256","uint256","uint256","bytes32"],[e.positionId,e.timestamp,e.chainId,e.selectedTerm,t])}if("string"!=typeof e.amount||0===e.amount.length)throw new Error(`[agent-module-executor] amount is required for op=${e.op}`);if("withdraw"===e.op){if("string"!=typeof e.destinationAddress||0===e.destinationAddress.length)throw new Error("[agent-module-executor] destinationAddress is required for op=withdraw");return ethers.utils.solidityKeccak256(["bytes32","uint256","uint256","uint256","string","bytes32"],[e.positionId,e.timestamp,e.chainId,e.amount,e.destinationAddress,t])}return ethers.utils.solidityKeccak256(["bytes32","uint256","uint256","uint256","bytes32"],[e.positionId,e.timestamp,e.chainId,e.amount,t])}(e,ethers.utils.keccak256(ethers.utils.toUtf8Bytes(v[e.op]))),r=await D.signMessage(ethers.utils.arrayify(t));return{...B,authorization:{timestamp:e.timestamp,signature:r,signer:D.address}}}const F=x(e?.target,"target");if("string"!=typeof e?.innerData||!/^0x[0-9a-fA-F]{8,}$/.test(e.innerData))throw new Error("[agent-module-executor] innerData must be 0x-hex with a 4-byte selector for mode=execute");const O=e?.tx;if(!O||"number"!=typeof O.nonce||!Number.isInteger(O.nonce)||"string"!=typeof O.gasLimit||"string"!=typeof O.maxFeePerGas||"string"!=typeof O.maxPriorityFeePerGas)throw new Error("[agent-module-executor] tx.{nonce,gasLimit,maxFeePerGas,maxPriorityFeePerGas} are required for mode=execute and must be caller-supplied (multi-node determinism)");const T=e.innerData.slice(0,10);if(!0!==await p.isWhitelisted(F,T))throw new Error(`[agent-module-executor] (${F}, ${T}) is not on module ${n}'s whitelist \u2014 refusing`);const _=(I[e.op]??[]).find((e=>{return(t=e.signature,ethers.utils.id(t).slice(0,10)).toLowerCase()===T.toLowerCase();var t}));if(!_)throw new Error(`[agent-module-executor] op=${e.op} does not authorize selector ${T}. createPosition, setPositionDelegate, and approve-outside-a-repay-grant have no corresponding AgentDelegationRegistry scope and are never reachable through this action (setPositionDelegate specifically: vigil concern C-43) \u2014 refusing to sign`);if(null!==_.positionIdPath){const t=_.signature.slice(0,_.signature.indexOf("(")),r=new ethers.utils.Interface([`function ${_.signature}`]).decodeFunctionData(t,e.innerData),n="tuple"===_.positionIdPath?r[0][0]:r[0];if(!E(n,e.positionId))throw new Error(`[agent-module-executor] innerData targets position ${n}, but the scope grant checked in step 3 was for ${e.positionId} \u2014 refusing to sign a call against a different position than the one authorized`)}const R=new ethers.utils.Interface(w).encodeFunctionData("execute",[F,e.innerData]),k=await D.signTransaction({to:n,data:R,value:0,chainId:e.chainId,nonce:O.nonce,gasLimit:ethers.BigNumber.from(O.gasLimit),maxFeePerGas:ethers.BigNumber.from(O.maxFeePerGas),maxPriorityFeePerGas:ethers.BigNumber.from(O.maxPriorityFeePerGas),type:2});return{...B,signedTransaction:k}}return A=i,((i,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let u of r(o))n.call(i,u)||u===a||e(i,u,{get:()=>o[u],enumerable:!(s=t(o,u))||s.enumerable});return i})(e({},"__esModule",{value:!0}),A)})();if("object"==typeof _LIT_ACTION_)if("function"==typeof _LIT_ACTION_.main)var main=_LIT_ACTION_.main;else"function"==typeof _LIT_ACTION_.go&&_LIT_ACTION_.go();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"actionName": "agent-module-executor",
|
|
3
|
-
"originalSize":
|
|
4
|
-
"minifiedSize":
|
|
5
|
-
"compressionRatio": 0.
|
|
6
|
-
"hash": "
|
|
7
|
-
"buildTime":
|
|
3
|
+
"originalSize": 19761,
|
|
4
|
+
"minifiedSize": 11655,
|
|
5
|
+
"compressionRatio": 0.41020191285866103,
|
|
6
|
+
"hash": "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec",
|
|
7
|
+
"buildTime": 1787171880624,
|
|
8
8
|
"version": "0.1.0"
|
|
9
9
|
}
|