-
Notifications
You must be signed in to change notification settings - Fork 16
Ft/debug utils #113
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
f1lander
wants to merge
10
commits into
main
Choose a base branch
from
ft/debug-utils
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
Ft/debug utils #113
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c710ff7
Merge branch 'main' into feature/fet-2110-tech-create-aa-env-in-devnet
f1lander 53875ea
fix: price oracle deployment
TateB 645f7f2
Merge branch 'fix/price-oracle-deployment' into feature/fet-2110-tech…
f1lander 14ba8fe
adds debug utils scripts
f1lander 0abc299
adds debug-utils scripts
f1lander 963d9b9
adds ascii banner with gradient ens blue
f1lander 0662571
changes new ports for l2 on aa kit deploy script
f1lander 4111924
suggest revert back tot he original port sequence
mdtanrikulu ea0a8c3
bump bun version in docker env
mdtanrikulu 69f6348
disable simulation contracts
mdtanrikulu 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
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 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
Binary file not shown.
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
Submodule ens-contracts
updated
163 files
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,68 @@ | ||
# Scripts Documentation | ||
|
||
Quick reference for the available scripts in this project. | ||
|
||
## 📋 List Registered Names | ||
|
||
**Script:** `listRegisteredNames.ts` | ||
**Command:** `bun run list-names` | ||
**Purpose:** Lists all registered domain names in a table format | ||
**Shows:** Name, Owner, Duration, Total Cost (USD) | ||
**Use case:** Check which names are registered and who owns them | ||
|
||
## 🪙 Mint Mock Tokens | ||
|
||
**Script:** `mintTokensDirect.ts` | ||
**Command:** `bun run mint-tokens <WALLET_ADDRESS>` | ||
**Purpose:** Mints 1000 MockUSDC and 1000 MockDAI to a specified address | ||
**Use case:** Give test tokens to addresses for testing name registration | ||
|
||
## 👀 Watch Name Registrations | ||
|
||
**Script:** `watchNameRegistrations.ts` | ||
**Command:** `bun run watch-names` | ||
**Purpose:** Real-time monitoring of new name registrations | ||
**Shows:** New registrations as they happen with owner and cost details | ||
**Use case:** Monitor registration activity during development/testing | ||
|
||
## 🌐 CORS Proxy | ||
|
||
**Script:** `corsProxy.ts` | ||
**Command:** `bun run cors-proxy` | ||
**Purpose:** Adds CORS headers to Alto bundler responses for frontend access | ||
**Port:** 4339 (proxies to Alto L2 on 4338) | ||
**Use case:** Enable frontend to communicate with AA infrastructure | ||
|
||
## 🚀 Development Environment | ||
|
||
**Script:** `runDevnet.ts` | ||
**Command:** `bun run devnet` | ||
**Purpose:** Sets up the complete development environment with AA Kit | ||
**Shows:** Contract addresses, endpoints, test accounts | ||
**Use case:** Initialize the local development setup | ||
|
||
## 📝 Usage Examples | ||
|
||
```bash | ||
# List all registered names | ||
bun run list-names | ||
|
||
# Mint tokens to an address | ||
bun run mint-tokens 0x1234... | ||
|
||
# Watch for new registrations | ||
bun run watch-names | ||
|
||
# Start CORS proxy | ||
bun run cors-proxy | ||
|
||
# Setup devnet | ||
bun run devnet | ||
``` | ||
|
||
## 🔧 Prerequisites | ||
|
||
- Running local blockchain (Anvil/Hardhat) | ||
- AA Kit infrastructure (Alto bundlers, mock paymasters) | ||
- Contracts deployed | ||
- Bun package manager |
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,46 @@ | ||
import express from 'express'; | ||
import { createProxyMiddleware } from 'http-proxy-middleware'; | ||
import cors from 'cors'; | ||
|
||
const app = express(); | ||
const PORT = 4339; | ||
|
||
app.use(cors({ | ||
origin: ['http://localhost:3002'], | ||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], | ||
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'], | ||
credentials: true | ||
})); | ||
|
||
app.get('/health', (req, res) => { | ||
res.json({ status: 'ok', service: 'cors-proxy', timestamp: new Date().toISOString() }); | ||
}); | ||
|
||
app.use('/', createProxyMiddleware({ | ||
target: 'http://localhost:4338', | ||
changeOrigin: true, | ||
pathRewrite: { | ||
'^/': '/' | ||
}, | ||
onProxyRes: (proxyRes, req, res) => { | ||
proxyRes.headers['Access-Control-Allow-Origin'] = '*'; | ||
proxyRes.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'; | ||
proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization, X-Requested-With'; | ||
proxyRes.headers['Access-Control-Allow-Credentials'] = 'true'; | ||
}, | ||
onError: (err, req, res) => { | ||
console.error('Proxy error:', err); | ||
res.status(500).json({ error: 'Proxy error', message: err.message }); | ||
} | ||
})); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`CORS Proxy running on http://localhost:${PORT}`); | ||
console.log(`Proxying requests to Alto L2 at http://localhost:4338`); | ||
console.log(`CORS enabled for frontend at http://localhost:3002`); | ||
}); | ||
|
||
process.on('SIGINT', () => { | ||
console.log('\nShutting down CORS Proxy...'); | ||
process.exit(0); | ||
}); |
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,87 @@ | ||
import { createPublicClient, http, parseAbiItem, decodeEventLog } from 'viem'; | ||
import { localhost } from 'viem/chains'; | ||
|
||
const RPC_URL = 'http://localhost:8546'; | ||
const ETH_REGISTRAR_ADDRESS = '0xa513e6e4b8f2a923d98304ec87f64353c4d5c853'; | ||
|
||
const client = createPublicClient({ | ||
chain: localhost, | ||
transport: http(RPC_URL), | ||
}); | ||
|
||
const nameRegisteredEvent = parseAbiItem( | ||
'event NameRegistered(string name, address owner, address subregistry, address resolver, uint64 duration, uint256 tokenId, uint256 baseCost, uint256 premium)' | ||
); | ||
|
||
function shortenAddress(address: string): string { | ||
return `${address.slice(0, 6)}...${address.slice(-4)}`; | ||
} | ||
|
||
async function listRegisteredNames() { | ||
console.log('Fetching all registered names...\n'); | ||
|
||
try { | ||
const logs = await client.getLogs({ | ||
address: ETH_REGISTRAR_ADDRESS as `0x${string}`, | ||
event: nameRegisteredEvent, | ||
fromBlock: 0n, | ||
toBlock: 'latest', | ||
}); | ||
|
||
console.log(`Found ${logs.length} registered names\n`); | ||
|
||
if (logs.length === 0) { | ||
console.log('No names found'); | ||
return; | ||
} | ||
|
||
const namesData = logs.map((log, index) => { | ||
try { | ||
const decoded = decodeEventLog({ | ||
abi: [nameRegisteredEvent], | ||
data: log.data, | ||
topics: log.topics, | ||
}); | ||
|
||
const { name, owner, duration, baseCost, premium } = decoded.args; | ||
const totalCost = Number(baseCost) + Number(premium); | ||
const durationInDays = Math.floor(Number(duration) / 86400); | ||
|
||
return { | ||
'#': index + 1, | ||
'Name': name, | ||
'Owner': shortenAddress(owner), | ||
'Duration (days)': durationInDays, | ||
'Total Cost (USD)': (totalCost / 1e8).toFixed(2), | ||
}; | ||
} catch (error) { | ||
return { | ||
'#': index + 1, | ||
'Name': 'Error decoding', | ||
'Owner': 'Error', | ||
'Duration (days)': 'Error', | ||
'Total Cost (USD)': 'Error', | ||
}; | ||
} | ||
}); | ||
|
||
console.table(namesData); | ||
|
||
console.log('\nSummary:'); | ||
console.log('==========='); | ||
|
||
const uniqueOwners = new Set(namesData.map(item => item.Owner).filter(owner => owner !== 'Error')); | ||
const totalCost = namesData | ||
.filter(item => item['Total Cost (USD)'] !== 'Error') | ||
.reduce((sum, item) => sum + parseFloat(item['Total Cost (USD)']), 0); | ||
|
||
console.log(`Total Names: ${namesData.length}`); | ||
console.log(`Unique Owners: ${uniqueOwners.size}`); | ||
console.log(`Total Value: $${totalCost.toFixed(2)} USD`); | ||
|
||
} catch (error) { | ||
console.error('Error fetching names:', error); | ||
} | ||
} | ||
|
||
listRegisteredNames().catch(console.error); |
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,126 @@ | ||
#!/usr/bin/env bun | ||
import { createPublicClient, createWalletClient, http, parseEther, parseUnits } from 'viem'; | ||
import { privateKeyToAccount } from 'viem/accounts'; | ||
|
||
const MOCK_USDC_ADDRESS = '0xe7f1725e7734ce288f8367e1bb143e90bb3f0512'; | ||
const MOCK_DAI_ADDRESS = '0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0'; | ||
|
||
const MOCK_ERC20_ABI = [ | ||
{ | ||
inputs: [ | ||
{ name: 'to', type: 'address' }, | ||
{ name: 'amount', type: 'uint256' } | ||
], | ||
name: 'mint', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function' | ||
}, | ||
{ | ||
inputs: [{ name: 'account', type: 'address' }], | ||
name: 'balanceOf', | ||
outputs: [{ name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function' | ||
} | ||
]; | ||
|
||
async function main() { | ||
const targetWallet = process.argv[2]; | ||
|
||
if (!targetWallet) { | ||
console.error('Usage: bun run script/mintTokensDirect.ts <WALLET_ADDRESS>'); | ||
console.error('Example: bun run script/mintTokensDirect.ts 0x1234...'); | ||
process.exit(1); | ||
} | ||
|
||
console.log(`Minting mock tokens to: ${targetWallet}`); | ||
console.log(`MockUSDC: ${MOCK_USDC_ADDRESS}`); | ||
console.log(`MockDAI: ${MOCK_DAI_ADDRESS}`); | ||
|
||
const l2Client = createPublicClient({ | ||
chain: { | ||
id: 31338, | ||
name: 'L2 Local', | ||
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, | ||
rpcUrls: { | ||
default: { http: ['http://127.0.0.1:8546'] }, | ||
public: { http: ['http://127.0.0.1:8546'] }, | ||
}, | ||
}, | ||
transport: http('http://127.0.0.1:8546'), | ||
}); | ||
|
||
const deployerAccount = privateKeyToAccount('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'); | ||
|
||
const walletClient = createWalletClient({ | ||
account: deployerAccount, | ||
chain: { | ||
id: 31338, | ||
name: 'L2 Local', | ||
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, | ||
rpcUrls: { | ||
default: { http: ['http://127.0.0.1:8546'] }, | ||
public: { http: ['http://127.0.0.1:8546'] }, | ||
}, | ||
}, | ||
transport: http('http://127.0.0.1:8546'), | ||
}); | ||
|
||
try { | ||
const usdcAmount = parseUnits('1000', 6); | ||
console.log(`Minting 1000 USDC...`); | ||
|
||
const usdcMintTx = await walletClient.writeContract({ | ||
address: MOCK_USDC_ADDRESS, | ||
abi: MOCK_ERC20_ABI, | ||
functionName: 'mint', | ||
args: [targetWallet, usdcAmount], | ||
}); | ||
|
||
console.log(`USDC minted! Transaction: ${usdcMintTx}`); | ||
|
||
const daiAmount = parseEther('1000'); | ||
console.log(`Minting 1000 DAI...`); | ||
|
||
const daiMintTx = await walletClient.writeContract({ | ||
address: MOCK_DAI_ADDRESS, | ||
abi: MOCK_ERC20_ABI, | ||
functionName: 'mint', | ||
args: [targetWallet, daiAmount], | ||
}); | ||
|
||
console.log(`DAI minted! Transaction: ${daiMintTx}`); | ||
|
||
console.log('Waiting for transactions to be mined...'); | ||
await new Promise(resolve => setTimeout(resolve, 2000)); | ||
|
||
const usdcBalance = await l2Client.readContract({ | ||
address: MOCK_USDC_ADDRESS, | ||
abi: MOCK_ERC20_ABI, | ||
functionName: 'balanceOf', | ||
args: [targetWallet], | ||
}); | ||
|
||
const daiBalance = await l2Client.readContract({ | ||
address: MOCK_DAI_ADDRESS, | ||
abi: MOCK_ERC20_ABI, | ||
functionName: 'balanceOf', | ||
args: [targetWallet], | ||
}); | ||
|
||
console.log('\nToken minting complete!'); | ||
console.log(`${targetWallet} now has:`); | ||
console.log(` - USDC: ${Number(usdcBalance) / 1e6} USDC`); | ||
console.log(` - DAI: ${Number(daiBalance) / 1e18} DAI`); | ||
console.log('\nYou can now use these tokens to register names from your frontend!'); | ||
console.log(` - Each name registration costs $10 (in either USDC or DAI)`); | ||
console.log(` - Make sure to approve the ETHRegistrar contract to spend your tokens`); | ||
|
||
} catch (error) { | ||
console.error('Error minting tokens:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main().catch(console.error); |
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.
I put this port because this changes on devnet.