Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmanaa committed Dec 11, 2024
1 parent 24aad6a commit bd8004f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ export const ChainUpdateBuilderWrapper = ({ chain }: ChainUpdateBuilderWrapperPr
const remoteNetwork = chain === "source" ? state.destinationNetwork : state.sourceNetwork
const remoteContracts = chain === "source" ? state.destinationContracts : state.sourceContracts

// Get contract addresses
// Get contract addresses and pool type
const poolAddress = chain === "source" ? state.sourceContracts.tokenPool : state.destinationContracts.tokenPool
const poolType = chain === "source" ? state.sourceContracts.poolType : state.destinationContracts.poolType

if (process.env.NODE_ENV === "development") {
console.log(`[ConfigTrack] ${chain}-update-builder:`, {
currentNetwork: currentNetwork?.name,
remoteNetwork: remoteNetwork?.name,
poolAddress,
poolType,
remoteContracts,
timestamp: new Date().toISOString(),
})
Expand Down Expand Up @@ -209,10 +211,10 @@ export const ChainUpdateBuilderWrapper = ({ chain }: ChainUpdateBuilderWrapperPr
{isDataReady ? (
<ol className={styles.instructions}>
<li>
In the "Deploy & Run Transactions" tab, select your token pool (<strong>BurnMintTokenPool</strong> or{" "}
<strong>LockReleaseTokenPool</strong>) at:
In the "Deploy & Run Transactions" tab, select your token pool (
<strong>{poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}</strong>) at:
<div className={styles.contractInfo}>
<strong>Contract:</strong> TokenPool
<strong>Contract:</strong> {poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}
<ReactCopyText text={poolAddress || ""} code />
</div>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useState, useEffect } from "react"
import { useStore } from "@nanostores/react"
import { laneStore } from "@stores/lanes"
import { ContractAddress } from "./ContractAddress"
Expand All @@ -11,6 +11,7 @@ import { NetworkAddress } from "./NetworkAddress"
import { ContractVerificationStep } from "./ContractVerificationStep"
import type { LaneState, DeployedContracts } from "@stores/lanes"
import styles from "./DeployPoolStep.module.css"
import { utils } from "ethers"

interface DeployPoolStepProps {
chain: "source" | "destination"
Expand All @@ -33,6 +34,42 @@ export const DeployPoolStep = ({ chain }: DeployPoolStepProps) => {
const [poolType, setPoolType] = useState<"lock" | "burn">("burn")
const state = useStore(laneStore) as ExtendedLaneState

// Add effect to store pool type when valid address is provided
useEffect(() => {
const currentContracts = chain === "source" ? state.sourceContracts : state.destinationContracts

// Only update pool type when we have a valid address
if (currentContracts.tokenPool && utils.isAddress(currentContracts.tokenPool)) {
const current = laneStore.get()

// Debug log before update
console.log(`[PoolType Update] ${chain}:`, {
address: currentContracts.tokenPool,
currentPoolType: currentContracts.poolType,
newPoolType: poolType,
timestamp: new Date().toISOString(),
})

if (chain === "source") {
laneStore.set({
...current,
sourceContracts: {
...current.sourceContracts,
poolType,
},
})
} else {
laneStore.set({
...current,
destinationContracts: {
...current.destinationContracts,
poolType,
},
})
}
}
}, [chain, poolType, state.sourceContracts.tokenPool, state.destinationContracts.tokenPool])

// Debug store values
console.log("DeployPoolStep Store:", {
chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const PoolConfigVerification = ({ chain }: { chain: ChainType }) => {
const remoteContracts = chain === "source" ? state.destinationContracts : state.sourceContracts
const poolAddress = chain === "source" ? state.sourceContracts.tokenPool : state.destinationContracts.tokenPool
const rateLimits = chain === "source" ? state.sourceRateLimits : state.destinationRateLimits
const poolType = chain === "source" ? state.sourceContracts.poolType : state.destinationContracts.poolType

const stepId = chain === "source" ? "sourceConfig" : "destinationConfig"
const subStepId = chain === "source" ? "source-verification" : "dest-verification"
Expand All @@ -67,10 +68,10 @@ export const PoolConfigVerification = ({ chain }: { chain: ChainType }) => {
>
<ol className={styles.instructions}>
<li>
In the "Deploy & Run Transactions" tab, select your token pool (<strong>BurnMintTokenPool</strong> or{" "}
<strong>LockReleaseTokenPool</strong>) at:
In the "Deploy & Run Transactions" tab, select your token pool (
<strong>{poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}</strong>) at:
<div className={styles.contractInfo}>
<strong>Contract:</strong> TokenPool
<strong>Contract:</strong> {poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}
<ReactCopyText text={poolAddress || ""} code />
</div>
</li>
Expand Down
1 change: 1 addition & 0 deletions src/stores/lanes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type DeployedContracts = {
tokenPools?: string[]
registered?: boolean
configured?: boolean
poolType?: "lock" | "burn"
}

export interface TokenBucketState {
Expand Down

0 comments on commit bd8004f

Please sign in to comment.