-
Notifications
You must be signed in to change notification settings - Fork 92
Added helpful scripts #1596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mirooon
wants to merge
30
commits into
main
Choose a base branch
from
deploy-gaszipperiphery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added helpful scripts #1596
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
3fdf1cb
added deploy logs
mirooon d88f594
added viction
mirooon 9908e5a
updated whitelist
mirooon 385ae19
update
mirooon 9a930ba
updated avalanche and viction
mirooon 35a9349
added deployments
mirooon 711d45e
added deploy logs for celo and fraxtal
mirooon 853d65d
merged with smar-123 branch
mirooon ace70af
added verify proposal
mirooon 2864640
merge main
mirooon 0043b1e
added new whitelist
mirooon ecf2c22
added check script
mirooon 619ed62
updates
mirooon 131736a
added sophon logs
mirooon 893c7f1
updated -Execute with Deployer
mirooon 1c27264
updated script
mirooon 85b6204
updates
mirooon 37bd201
added megaeth logs
mirooon 87dde1f
Merge branch 'deploy-gaszipperiphery-megaeth' into deploy-gaszipperip…
mirooon ff9bf4f
updated whitelist
mirooon bb488d1
fix confirm-safe-tx
mirooon 1829c2e
Merge branch 'main' into deploy-gaszipperiphery
mirooon 0bd3a69
Merge branch 'deploy-gaszipperiphery' of github.com:lifinance/contrac…
mirooon e5dceb1
added diamond deploy logs
mirooon 5ccaeb6
updates
mirooon d6e01a0
Merge branch 'SMAR-123-Fix-automatic-contract-verification' into depl…
mirooon 1df9c32
updates
mirooon 2f694af
updates
mirooon ac2b8ab
updates
mirooon e8f2fc8
Merge branch 'main' into deploy-gaszipperiphery
mirooon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } 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 } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: lifinance/contracts
Length of output: 347
🏁 Script executed:
Repository: lifinance/contracts
Length of output: 2364
Update
.env.examplewith 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.examplewhen adding new environment variables."🤖 Prompt for AI Agents