Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3fdf1cb
added deploy logs
mirooon Jan 22, 2026
d88f594
added viction
mirooon Jan 23, 2026
9908e5a
updated whitelist
mirooon Jan 23, 2026
385ae19
update
mirooon Jan 27, 2026
9a930ba
updated avalanche and viction
mirooon Jan 27, 2026
35a9349
added deployments
mirooon Jan 27, 2026
711d45e
added deploy logs for celo and fraxtal
mirooon Jan 27, 2026
853d65d
merged with smar-123 branch
mirooon Jan 27, 2026
ace70af
added verify proposal
mirooon Jan 27, 2026
2864640
merge main
mirooon Jan 27, 2026
0043b1e
added new whitelist
mirooon Jan 27, 2026
ecf2c22
added check script
mirooon Jan 27, 2026
619ed62
updates
mirooon Jan 28, 2026
131736a
added sophon logs
mirooon Jan 28, 2026
893c7f1
updated -Execute with Deployer
mirooon Jan 28, 2026
1c27264
updated script
mirooon Jan 28, 2026
85b6204
updates
mirooon Jan 28, 2026
37bd201
added megaeth logs
mirooon Jan 28, 2026
87dde1f
Merge branch 'deploy-gaszipperiphery-megaeth' into deploy-gaszipperip…
mirooon Jan 28, 2026
ff9bf4f
updated whitelist
mirooon Jan 28, 2026
bb488d1
fix confirm-safe-tx
mirooon Jan 28, 2026
1829c2e
Merge branch 'main' into deploy-gaszipperiphery
mirooon Jan 28, 2026
0bd3a69
Merge branch 'deploy-gaszipperiphery' of github.com:lifinance/contrac…
mirooon Jan 28, 2026
e5dceb1
added diamond deploy logs
mirooon Jan 28, 2026
5ccaeb6
updates
mirooon Jan 28, 2026
d6e01a0
Merge branch 'SMAR-123-Fix-automatic-contract-verification' into depl…
mirooon Jan 28, 2026
1df9c32
updates
mirooon Jan 28, 2026
2f694af
updates
mirooon Jan 28, 2026
ac2b8ab
updates
mirooon Jan 28, 2026
e8f2fc8
Merge branch 'main' into deploy-gaszipperiphery
mirooon Feb 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
"wrappedNativeAddress": "0xacc15dc74880c9944775448304b263d191c6077f",
"status": "active",
"type": "mainnet",
"rpcUrl": "https://moonbeam.public.blastapi.io",
"rpcUrl": "https://moonbeam-rpc.publicnode.com",
"verificationType": "etherscan",
"explorerUrl": "https://moonscan.io",
"explorerApiUrl": "https://api-moonbeam.moonscan.io/api",
Expand Down
3 changes: 0 additions & 3 deletions deployments/abstract.staging.json

This file was deleted.

2 changes: 1 addition & 1 deletion deployments/megaeth.diamond.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"FeeCollector": "0xF061930bc5154b72Bf90bA22840a6bEf20F4c83F",
"FeeForwarder": "0xB401ccdA43C36935e6059C02103E9541FbA3337E",
"GasZipPeriphery": "0xa8800ABdD6771dA7aAab2d09a5b97F4B8b19B58a",
"LidoWrapper": "",
"LiFiDEXAggregator": "0x85E609B97AC5776AcDBa5fAabBcca64eB7a79185",
"LidoWrapper": "",
"Patcher": "",
"Permit2Proxy": "0x700f1874314A4dF3bb9A10f7B5eA187A39d8dE74",
"ReceiverAcrossV3": "",
Expand Down
42 changes: 21 additions & 21 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,64 +110,64 @@ localanvil = "${ETH_NODE_URI_LOCALANVIL}"

[etherscan]
mainnet = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=1", chain = "1" }
abstract = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://abscan.org/contract_verification", chain = "2741", verifier = "zksync" }
abstract = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=2741", chain = "2741" }
apechain = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=33139", chain = "33139" }
arbitrum = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=42161", chain = "42161" }
avalanche = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=43114", chain = "43114" }
base = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=8453", chain = "8453" }
berachain = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=80094", chain = "80094" }
blast = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=81457", chain = "81457" }
bob = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.gobob.xyz/api", verifier = "blockscout", chain = "60808" }
bob = { key = "${BLOCKSCOUT_API_KEY}", url = "https://explorer.gobob.xyz/api", verifier = "blockscout", chain = "60808" }
boba = { key = "${BOBA_ETHERSCAN_API_KEY}", url = "https://api.routescan.io/v2/network/mainnet/evm/288/etherscan/api", chain = "288" }
botanix = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://api.routescan.io/v2/network/mainnet/evm/3637/etherscan", chain = "3637" }
botanix = { key = "${VERIFY_CONTRACT_API_KEY}", url = "https://api.routescan.io/v2/network/mainnet/evm/3637/etherscan", chain = "3637" }
bsc = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=56", chain = "56" }
celo = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=42220", chain = "42220" }
corn = { key = "${CORN_ETHERSCAN_API_KEY}", url = "https://api.routescan.io/v2/network/mainnet/evm/21000000/etherscan", chain = "21000000" }
cronos = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://cronos.org/explorer/api", verifier = "blockscout", chain = "25" }
cronos = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=25", chain = "25" }
flare = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://api.routescan.io/v2/network/mainnet/evm/14/etherscan", chain = "14" }
flow = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://evm.flowscan.io/api", chain = "747" , verifier = "blockscout"}
flow = { key = "${BLOCKSCOUT_API_KEY}", url = "https://evm.flowscan.io/api", chain = "747" , verifier = "blockscout"}
fraxtal = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=252", chain = "252" }
fuse = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.fuse.io/api?", chain = "122" , verifier = "blockscout"}
fuse = { key = "${BLOCKSCOUT_API_KEY}", url = "https://explorer.fuse.io/api?", chain = "122" , verifier = "blockscout"}
gnosis = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=100", chain = "100" }
gravity = { key = "${GRAVITY_ETHERSCAN_API_KEY}", url = "https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/GRAVITY", chain = "1625", verifier = "oklink" }
hemi = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.hemi.xyz/api", chain = "43111", verifier = "blockscout" }
hemi = { key = "${BLOCKSCOUT_API_KEY}", url = "https://explorer.hemi.xyz/api", chain = "43111", verifier = "blockscout" }
hyperevm = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=999", chain = "999" }
etherlink = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.etherlink.com/api", chain = "42793", verifier = "blockscout" }
ink = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.inkonchain.com/api", verifier = "blockscout", chain = "57073"}
jovay = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.jovay.io/api", chain = "5734951"}
immutablezkevm = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.immutable.com/api", chain = "13371", verifier = "blockscout" }
kaia = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/kaia", chain = "8217", verifier = "oklink" }
katana = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=747474", chain = "747474" }
lens = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://api-explorer-verify.lens.matterhosted.dev/contract_verification", chain = "232", verifier = "zksync" }
lens = { key = "${LENS_ETHERSCAN_API_KEY}", url = "https://api-explorer-verify.lens.matterhosted.dev/contract_verification", chain = "232", verifier = "zksync" }
linea = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=59144", chain = "59144" }
lisk = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://blockscout.lisk.com/api", chain = "1135", verifier = "blockscout" }
lisk = { key = "${BLOCKSCOUT_API_KEY}", url = "https://blockscout.lisk.com/api", chain = "1135", verifier = "blockscout" }
mantle = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=5000", chain = "5000" }
megaeth = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://megaeth.blockscout.com/api", chain = "4326", verifier = "blockscout" }
metis = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan", chain = "1088" }
megaeth = { key = "${BLOCKSCOUT_API_KEY}", url = "https://megaeth.blockscout.com/api", chain = "4326", verifier = "blockscout" }
metis = { key = "${VERIFY_CONTRACT_API_KEY}", url = "https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan", chain = "1088" }
mode = { key = "${MODE_ETHERSCAN_API_KEY}", url = "https://api.routescan.io/v2/network/mainnet/evm/34443/etherscan", chain = "34443" }
monad = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=143", verifier = "custom", chain = "143" }
moonbeam = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=1284", chain = "1284" }
nibiru = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://api.routescan.io/v2/network/mainnet/evm/6900/etherscan", chain = "6900" }
optimism = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=10", chain = "10" }
opbnb = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=204", chain = "204" }
plasma = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://api.routescan.io/v2/network/mainnet/evm/9745/etherscan", chain = "9745" }
plume = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer-plume-mainnet-1.t.conduit.xyz/api", verifier = "blockscout", chain = "98866" }
plasma = { key = "${VERIFY_CONTRACT_API_KEY}", url = "https://api.routescan.io/v2/network/mainnet/evm/9745/etherscan", chain = "9745" }
plume = { key = "${BLOCKSCOUT_API_KEY}", url = "https://explorer-plume-mainnet-1.t.conduit.xyz/api", verifier = "blockscout", chain = "98866" }
polygon = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=137", chain = "137" }
ronin= { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://sourcify.roninchain.com/server", chain = "2020", verifier = "sourcify" }
rootstock= { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://rootstock.blockscout.com/api", chain = "30", verifier = "blockscout" }
ronin= { key = "${SOURCIFY_API_KEY}", url = "https://sourcify.roninchain.com/server", chain = "2020", verifier = "sourcify" }
rootstock= { key = "${BLOCKSCOUT_API_KEY}", url = "https://rootstock.blockscout.com/api", chain = "30", verifier = "blockscout" }
scroll = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=534352", chain = "534352" }
sei = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=1329", chain = "1329" }
soneium = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://soneium.blockscout.com/api", verifier = "blockscout", chain = "1868" }
soneium = { key = "${BLOCKSCOUT_API_KEY}", url = "https://soneium.blockscout.com/api", verifier = "blockscout", chain = "1868" }
sonic = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=146", chain = "146" }
sophon = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer.sophon.xyz/contract_verification", chain = "50104", verifier = "zksync" }
sophon = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=50104", chain = "50104" }
stable = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=988", chain = "988"}
superposition = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://explorer-superposition-1v9rjalnat.t.conduit.xyz/api/", chain = "55244", verifier = "blockscout" }
superposition = { key = "${BLOCKSCOUT_API_KEY}", url = "https://explorer-superposition-1v9rjalnat.t.conduit.xyz/api/", chain = "55244", verifier = "blockscout" }
swellchain = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=1923", chain = "1923" }
taiko = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=167000", chain = "167000" }
unichain = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://unichain.blockscout.com/api?", chain = "130" , verifier = "blockscout" }
vana = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://vanascan.io/api", chain = "1480", verifier = "blockscout" }
unichain = { key = "${BLOCKSCOUT_API_KEY}", url = "https://unichain.blockscout.com/api?", chain = "130" , verifier = "blockscout" }
vana = { key = "${BLOCKSCOUT_API_KEY}", url = "https://vanascan.io/api", chain = "1480", verifier = "blockscout" }
Comment on lines +120 to +168
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find and display .env.example
echo "=== Looking for .env.example ==="
fd -t f '.env.example' 

# If found, show the full contents to verify
echo ""
echo "=== Contents of .env.example ==="
fd -t f '.env.example' -exec cat {} \;

Repository: lifinance/contracts

Length of output: 347


🏁 Script executed:

#!/bin/bash
# Read .env.example directly
echo "=== Contents of .env.example ==="
cat .env.example

echo ""
echo "=== Checking for new API key variables ==="
for var in BLOCKSCOUT_API_KEY VERIFY_CONTRACT_API_KEY LENS_ETHERSCAN_API_KEY SOURCIFY_API_KEY BOBA_ETHERSCAN_API_KEY GRAVITY_ETHERSCAN_API_KEY CORN_ETHERSCAN_API_KEY MODE_ETHERSCAN_API_KEY; do
  if grep -q "$var" .env.example; then
    echo "$var found"
  else
    echo "$var missing"
  fi
done

Repository: lifinance/contracts

Length of output: 2364


Update .env.example with the new API key environment variables.

Five new environment variables are introduced but missing from .env.example:

  • BLOCKSCOUT_API_KEY (used by 12+ chains)
  • VERIFY_CONTRACT_API_KEY (used by botanix, metis, plasma)
  • LENS_ETHERSCAN_API_KEY (used by lens)
  • SOURCIFY_API_KEY (used by ronin)
  • CORN_ETHERSCAN_API_KEY (used by corn)

Add these to the "Mainnet Explorer API Keys" section per the coding guideline: "Update .env.example when adding new environment variables."

🤖 Prompt for AI Agents
In `@foundry.toml` around lines 120 - 168, The PR adds new environment variables
referenced in foundry.toml (see keys used by bob/unichain/flow/etc. referencing
BLOCKSCOUT_API_KEY, botanix/metis/plasma referencing VERIFY_CONTRACT_API_KEY,
lens referencing LENS_ETHERSCAN_API_KEY, ronin referencing SOURCIFY_API_KEY, and
corn referencing CORN_ETHERSCAN_API_KEY) but .env.example wasn't updated; add
these five vars to the "Mainnet Explorer API Keys" section of .env.example with
brief placeholder values and comments matching existing style so developers know
to supply real API keys.

viction = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://www.vicscan.xyz/api/contract/foundry/verify", chain = "88" }
worldchain = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=480", chain = "480" }
xdc = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=50", chain = "50" }
xlayer = { key = "${OKLINK_ETHERSCAN_API_KEY}", url = "https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/xlayer", chain = "196", verifier = "oklink" }
zksync = { key = "${NO_ETHERSCAN_API_KEY_REQUIRED}", url = "https://zksync2-mainnet-explorer.zksync.io/contract_verification", chain = "324", verifier = "zksync" }
zksync = { key = "${MAINNET_ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/v2/api?chainid=324", chain = "324" }
22 changes: 16 additions & 6 deletions script/deploy/facets/DeployGardenFacet.s.sol
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

import {DeployScriptBase} from "./utils/DeployScriptBase.sol";
import {stdJson} from "forge-std/Script.sol";
import {GardenFacet} from "lifi/Facets/GardenFacet.sol";
import { DeployScriptBase } from "./utils/DeployScriptBase.sol";
import { stdJson } from "forge-std/Script.sol";
import { GardenFacet } from "lifi/Facets/GardenFacet.sol";

contract DeployScript is DeployScriptBase {
using stdJson for string;

constructor() DeployScriptBase("GardenFacet") {}

function run() public returns (GardenFacet deployed, bytes memory constructorArgs) {
function run()
public
returns (GardenFacet deployed, bytes memory constructorArgs)
{
constructorArgs = getConstructorArgs();

deployed = GardenFacet(deploy(bytes.concat(type(GardenFacet).creationCode, constructorArgs)));
deployed = GardenFacet(
deploy(
bytes.concat(type(GardenFacet).creationCode, constructorArgs)
)
);
}

function getConstructorArgs() internal override returns (bytes memory) {
string memory path = string.concat(root, "/config/garden.json");

// Read the htlcRegistry address from config
address htlcRegistry = _getConfigContractAddress(path, string.concat(".htlcRegistry.", network));
address htlcRegistry = _getConfigContractAddress(
path,
string.concat(".htlcRegistry.", network)
);

return abi.encode(htlcRegistry);
}
Expand Down
180 changes: 180 additions & 0 deletions script/deploy/safe/query-safe-proposals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/usr/bin/env bun

/**
* Query Safe Proposals
*
* This script provides query operations for Safe transaction proposals stored in MongoDB.
* It supports checking if proposals exist in the database with pending status.
*/

import { defineCommand, runMain } from 'citty'
import { consola } from 'consola'
import type { WithId } from 'mongodb'

import { getSafeMongoCollection, type ISafeTxDocument } from './safe-utils'

/**
* Checks if a pending proposal exists for a given network, environment, and contract
* Looks for proposals created in the last 5 minutes
* @param environment - Reserved for future use (not currently used in query)
*/
async function checkProposalExists(
network: string,
_environment: string,
contract: string
): Promise<WithId<ISafeTxDocument> | null> {
const { client, pendingTransactions } = await getSafeMongoCollection()

try {
// Calculate timestamp for 5 minutes ago
const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000)

// Query for pending proposals on this network created in the last 5 minutes
const proposals = await pendingTransactions
.find({
network: network.toLowerCase(),
status: 'pending',
timestamp: { $gte: fiveMinutesAgo },
})
.sort({ timestamp: -1 })
.limit(10)
.toArray()

if (proposals.length === 0) {
return null
}

// For better matching, try to verify the proposal matches the contract
// Check if any proposal's calldata matches what we expect
for (const proposal of proposals) {
const calldata = proposal.safeTx?.data?.data

if (!calldata) continue

// For periphery contracts: check if calldata contains registerPeripheryContract with contract name
if (contract && !contract.includes('Facet')) {
// registerPeripheryContract(string,address) selector is 0x...
// We can check if the contract name appears in the calldata (encoded as string)
// This is a simple heuristic - the contract name should be in the calldata
const contractNameLower = contract.toLowerCase()
// The calldata will have the contract name encoded, so we check if it's present
// This is approximate but should work for most cases
if (calldata.toLowerCase().includes(contractNameLower.slice(0, 8))) {
return proposal
}
}

// For facets: diamond cut proposals are harder to match exactly
// If we have multiple proposals, return the most recent one
// The caller can verify further if needed
if (contract && contract.includes('Facet')) {
// Diamond cut proposals have a specific structure
// For now, return the most recent pending proposal
return proposal
}
}

// If no exact match but we have proposals, return the most recent one
// This handles the case where timing is close but contract matching is uncertain
return proposals[0] ?? null
} finally {
await client.close()
}
}

// Define check command
const checkCommand = defineCommand({
meta: {
name: 'check',
description:
'Check if a pending proposal exists for a contract on a network',
},
args: {
network: {
type: 'string',
description: 'Network name',
required: true,
},
environment: {
type: 'string',
description: 'Environment (staging or production)',
required: true,
},
contract: {
type: 'string',
description: 'Contract name',
required: true,
},
},
async run({ args }) {
// Validate environment
if (args.environment !== 'staging' && args.environment !== 'production') {
consola.error('Environment must be either "staging" or "production"')
process.exit(1)
}

try {
const proposal = await checkProposalExists(
args.network,
args.environment,
args.contract
)

if (proposal) {
// Output JSON for bash script to parse
console.log(
JSON.stringify({
found: true,
safeTxHash: proposal.safeTxHash,
timestamp: proposal.timestamp,
network: proposal.network,
status: proposal.status,
})
)
process.exit(0)
} else {
// Output JSON indicating not found
console.log(
JSON.stringify({
found: false,
network: args.network,
contract: args.contract,
})
)
process.exit(1)
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error)
consola.error('Failed to check proposal:', errorMessage)

// Output error as JSON for bash script
console.log(
JSON.stringify({
found: false,
error: errorMessage,
network: args.network,
contract: args.contract,
})
)
process.exit(1)
}
},
})

// Define main command
const main = defineCommand({
meta: {
name: 'query-safe-proposals',
description: 'Query Safe transaction proposals from MongoDB',
version: '1.0.0',
},
subCommands: {
check: checkCommand,
},
})

// Run the CLI
runMain(main)

export { checkProposalExists }
Loading
Loading