From bd8004f388cdb34643344ce6ec9925752180431a Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Wed, 11 Dec 2024 20:37:36 +0100 Subject: [PATCH] update --- .../ChainUpdateBuilderWrapper.tsx | 10 +++-- .../DeployPoolStep.tsx | 39 ++++++++++++++++++- .../PoolConfigVerification.tsx | 7 ++-- src/stores/lanes/index.ts | 1 + 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/components/CCIP/TutorialBlockchainSelector/ChainUpdateBuilderWrapper.tsx b/src/components/CCIP/TutorialBlockchainSelector/ChainUpdateBuilderWrapper.tsx index be6b849195a..b1d0ce78b83 100644 --- a/src/components/CCIP/TutorialBlockchainSelector/ChainUpdateBuilderWrapper.tsx +++ b/src/components/CCIP/TutorialBlockchainSelector/ChainUpdateBuilderWrapper.tsx @@ -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(), }) @@ -209,10 +211,10 @@ export const ChainUpdateBuilderWrapper = ({ chain }: ChainUpdateBuilderWrapperPr {isDataReady ? (
  1. - In the "Deploy & Run Transactions" tab, select your token pool (BurnMintTokenPool or{" "} - LockReleaseTokenPool) at: + In the "Deploy & Run Transactions" tab, select your token pool ( + {poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}) at:
    - Contract: TokenPool + Contract: {poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}
  2. diff --git a/src/components/CCIP/TutorialBlockchainSelector/DeployPoolStep.tsx b/src/components/CCIP/TutorialBlockchainSelector/DeployPoolStep.tsx index cd663064e69..321d61fed11 100644 --- a/src/components/CCIP/TutorialBlockchainSelector/DeployPoolStep.tsx +++ b/src/components/CCIP/TutorialBlockchainSelector/DeployPoolStep.tsx @@ -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" @@ -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" @@ -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, diff --git a/src/components/CCIP/TutorialBlockchainSelector/PoolConfigVerification.tsx b/src/components/CCIP/TutorialBlockchainSelector/PoolConfigVerification.tsx index 5960d71e867..632dafb63d0 100644 --- a/src/components/CCIP/TutorialBlockchainSelector/PoolConfigVerification.tsx +++ b/src/components/CCIP/TutorialBlockchainSelector/PoolConfigVerification.tsx @@ -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" @@ -67,10 +68,10 @@ export const PoolConfigVerification = ({ chain }: { chain: ChainType }) => { >
    1. - In the "Deploy & Run Transactions" tab, select your token pool (BurnMintTokenPool or{" "} - LockReleaseTokenPool) at: + In the "Deploy & Run Transactions" tab, select your token pool ( + {poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}) at:
      - Contract: TokenPool + Contract: {poolType === "burn" ? "BurnMintTokenPool" : "LockReleaseTokenPool"}
    2. diff --git a/src/stores/lanes/index.ts b/src/stores/lanes/index.ts index 9b35d3be872..687be9d865a 100644 --- a/src/stores/lanes/index.ts +++ b/src/stores/lanes/index.ts @@ -9,6 +9,7 @@ export type DeployedContracts = { tokenPools?: string[] registered?: boolean configured?: boolean + poolType?: "lock" | "burn" } export interface TokenBucketState {