Merge pull request 'fix: deployments-local.json committed to repo (#589)' (#1049) from fix/issue-589 into master

This commit is contained in:
johba 2026-03-20 12:26:04 +01:00
commit 26957dae88
5 changed files with 39 additions and 25 deletions

3
.gitignore vendored
View file

@ -39,3 +39,6 @@ logs/
# Holdout scenarios (cloned at runtime by evaluate.sh)
.holdout-scenarios/
# Local deployment addresses (generated per-run by bootstrap scripts)
onchain/deployments-local.json

View file

@ -1,8 +0,0 @@
{
"contracts": {
"Kraiken": "0xff196f1e3a895404d073b8611252cf97388773a7",
"Stake": "0xc36e784e1dff616bdae4eac7b310f0934faf04a4",
"LiquidityManager": "0x33d10f2449ffede92b43d4fba562f132ba6a766a",
"OptimizerProxy": "0x1cf34658e7df9a46ad61486d007a8d62aec9891e"
}
}

View file

@ -178,22 +178,29 @@ fi
log "Optimizer deployed and upgraded"
# =============================================================================
# Step 4 — Read deployment addresses
# Step 4 — Read deployment addresses from broadcast JSON
#
# DeployLocal.sol writes deterministic addresses to deployments-local.json when
# run against a fresh Anvil + standard mnemonic.
# deploy-optimizer.sh runs DeployLocal.sol which writes a broadcast JSON file.
# We read contract addresses from there rather than relying on a potentially
# stale committed deployments-local.json.
# =============================================================================
DEPLOYMENTS="$ONCHAIN_DIR/deployments-local.json"
[ -f "$DEPLOYMENTS" ] || fail2 "deployments-local.json not found — did DeployLocal.sol run?"
CHAIN_ID="$(cast chain-id --rpc-url "$RPC_URL")"
BROADCAST_JSON="$ONCHAIN_DIR/broadcast/DeployLocal.sol/$CHAIN_ID/run-latest.json"
[ -f "$BROADCAST_JSON" ] || fail2 "Broadcast JSON not found at $BROADCAST_JSON — did DeployLocal.sol run?"
LM_ADDR=$(python3 -c "
import json
d = json.load(open('$DEPLOYMENTS'))
print(d['contracts']['LiquidityManager'])
" 2>/dev/null) || fail2 "Failed to read LiquidityManager from deployments-local.json"
LM_ADDR="$(python3 - "$BROADCAST_JSON" <<'PYEOF'
import json, sys
with open(sys.argv[1]) as f:
data = json.load(f)
for tx in data.get('transactions', []):
if (tx.get('contractName') or '').lower() == 'liquiditymanager':
print(tx.get('contractAddress', ''))
break
PYEOF
)" || fail2 "Failed to read LiquidityManager from broadcast JSON"
[ -n "$LM_ADDR" ] || fail2 "LiquidityManager address is empty in deployments-local.json"
[ -n "$LM_ADDR" ] || fail2 "LiquidityManager address not found in broadcast JSON"
log "LiquidityManager: $LM_ADDR"
# =============================================================================

View file

@ -7,8 +7,8 @@
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "dist",
"rootDir": "."
"rootDir": ".."
},
"include": ["./**/*.ts"],
"include": ["./**/*.ts", "../push3-transpiler/src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}

View file

@ -1,5 +1,3 @@
import deploymentsLocal from '../../onchain/deployments-local.json';
const env = import.meta.env;
const LOCAL_PONDER_PATH = '/api/graphql';
@ -16,8 +14,22 @@ interface DeploymentInfrastructure {
weth?: string;
}
const localContracts = (deploymentsLocal as { contracts?: DeploymentContracts })?.contracts ?? {};
const localInfra = (deploymentsLocal as { infrastructure?: DeploymentInfrastructure })?.infrastructure ?? {};
interface DeploymentsLocal {
contracts?: DeploymentContracts;
infrastructure?: DeploymentInfrastructure;
}
// deployments-local.json is gitignored (generated per-run by bootstrap scripts).
// Use a glob pattern (brace expansion) so Vite treats it as dynamic — returns {}
// when the file is absent (CI, production) instead of a hard import error.
const _localFiles = import.meta.glob<DeploymentsLocal>('../../onchain/deployments-local{.json}', {
eager: true,
import: 'default',
});
const deploymentsLocal: DeploymentsLocal = _localFiles['../../onchain/deployments-local.json'] ?? {};
const localContracts = deploymentsLocal.contracts ?? {};
const localInfra = deploymentsLocal.infrastructure ?? {};
const LOCAL_KRAIKEN = (env.VITE_KRAIKEN_ADDRESS ?? localContracts.Kraiken ?? '').trim();
const LOCAL_STAKE = (env.VITE_STAKE_ADDRESS ?? localContracts.Stake ?? '').trim();
const LOCAL_LM = (env.VITE_LIQUIDITY_MANAGER ?? localContracts.LiquidityManager ?? '').trim();