Skip to content
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

Ccip/rel1.2 #1689

Merged
merged 31 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
846cc24
ccip v1.2.0 testnet
aelmanaa Dec 4, 2023
2bead25
ccip v1.2.0 testnet
aelmanaa Dec 4, 2023
cd9d99e
add caution note
aelmanaa Dec 4, 2023
9ffa97d
ccip v1.2.0 testnet
aelmanaa Dec 6, 2023
acd921d
remove strict sequencing
aelmanaa Dec 8, 2023
54a9480
getting-started
aelmanaa Dec 8, 2023
9675ef8
send-tokens tutorial
aelmanaa Dec 8, 2023
49202c8
programmable tokens tutorials
aelmanaa Dec 8, 2023
447182f
defensive example
aelmanaa Dec 8, 2023
cb6f77e
transfer tokens betweek eoas
aelmanaa Dec 8, 2023
b658682
arbitrary data example
aelmanaa Dec 8, 2023
db7ab90
ccip v1.2.0 testnet
aelmanaa Dec 8, 2023
2584c9e
ccip v1.2.0 testnet
aelmanaa Dec 8, 2023
1082a79
ccip v1.2.0 testnet
aelmanaa Dec 8, 2023
b622e94
ccip v1.2.0 testnet
aelmanaa Dec 8, 2023
a2f2e8a
Merge branch 'main' into ccip/rel1.2
aelmanaa Dec 8, 2023
9f59c05
update notice
aelmanaa Dec 9, 2023
00110d6
update release notes
aelmanaa Dec 9, 2023
d2d39f7
update release notes
aelmanaa Dec 9, 2023
add5381
update service limits page
aelmanaa Dec 9, 2023
0c88b45
update service limits page
aelmanaa Dec 9, 2023
cc02984
Merge branch 'main' into ccip/rel1.2
aelmanaa Dec 9, 2023
908b732
release notes
aelmanaa Dec 9, 2023
03f01a0
release notes
aelmanaa Dec 9, 2023
6313e07
release notes
aelmanaa Dec 9, 2023
8df9141
service limits
aelmanaa Dec 9, 2023
865eb0e
update
aelmanaa Dec 9, 2023
3eecdf1
Update src/content/ccip/release-notes.mdx
aelmanaa Dec 9, 2023
ef1adf7
Update src/content/ccip/release-notes.mdx
aelmanaa Dec 9, 2023
a5505ff
update
aelmanaa Dec 9, 2023
22b04cd
update
aelmanaa Dec 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@astrojs/sitemap": "^3.0.3",
"@chainlink/components": "^0.4.5",
"@chainlink/contracts": "^0.8.0",
"@chainlink/contracts-ccip": "^0.7.6",
"@chainlink/contracts-ccip": "^1.2.1",
"@chainlink/design-system": "^0.1.50",
"@chainlink/solana-sdk": "^0.2.2",
"@metamask/detect-provider": "^2.0.0",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/ccip/tutorials/ccip-explorer-tx-details.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/ccip/tutorials/deploy-receiver-mumbai.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/ccip/tutorials/deploy-sender-sepolia.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/ccip/tutorials/deployed-receiver-mumbai.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/ccip/tutorials/deployed-sender-sepolia.jpg
Binary file modified public/images/ccip/tutorials/mumbai-getmessagedetails.jpg
Binary file modified public/images/ccip/tutorials/mumbai-token-messagedetails.jpg
Binary file modified public/images/ccip/tutorials/mumbai-tokensreceived.jpg
Binary file modified public/images/ccip/tutorials/sepolia-sendmessage.jpg
6 changes: 3 additions & 3 deletions public/samples/CCIP/Messenger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/
import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {CCIPReceiver} from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/token/ERC20/IERC20.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/IERC20.sol";

/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
Expand Down Expand Up @@ -247,8 +247,8 @@ contract Messenger is CCIPReceiver, OwnerIsCreator {
data: abi.encode(_text), // ABI-encoded string
tokenAmounts: new Client.EVMTokenAmount[](0), // Empty array aas no tokens are transferred
extraArgs: Client._argsToBytes(
// Additional arguments, setting gas limit and non-strict sequencing mode
Client.EVMExtraArgsV1({gasLimit: 200_000, strict: false})
// Additional arguments, setting gas limit
Client.EVMExtraArgsV1({gasLimit: 200_000})
),
// Set the feeToken to a feeTokenAddress, indicating specific asset will be used for fees
feeToken: _feeTokenAddress
Expand Down
10 changes: 5 additions & 5 deletions public/samples/CCIP/ProgrammableDefensiveTokenTransfers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/
import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {CCIPReceiver} from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/token/ERC20/IERC20.sol";
import {SafeERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/token/ERC20/utils/SafeERC20.sol";
import {EnumerableMap} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/utils/structs/EnumerableMap.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/utils/SafeERC20.sol";
import {EnumerableMap} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableMap.sol";

/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
Expand Down Expand Up @@ -466,8 +466,8 @@ contract ProgrammableDefensiveTokenTransfers is CCIPReceiver, OwnerIsCreator {
data: abi.encode(_text), // ABI-encoded string
tokenAmounts: tokenAmounts, // The amount and type of token being transferred
extraArgs: Client._argsToBytes(
// Additional arguments, setting gas limit and non-strict sequencing mode
Client.EVMExtraArgsV1({gasLimit: 2_000_000, strict: false})
// Additional arguments, setting gas limit
Client.EVMExtraArgsV1({gasLimit: 2_000_000})
),
// Set the feeToken to a feeTokenAddress, indicating specific asset will be used for fees
feeToken: _feeTokenAddress
Expand Down
6 changes: 3 additions & 3 deletions public/samples/CCIP/ProgrammableTokenTransfers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/
import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {CCIPReceiver} from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/token/ERC20/IERC20.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/IERC20.sol";

/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
Expand Down Expand Up @@ -328,8 +328,8 @@ contract ProgrammableTokenTransfers is CCIPReceiver, OwnerIsCreator {
data: abi.encode(_text), // ABI-encoded string
tokenAmounts: tokenAmounts, // The amount and type of token being transferred
extraArgs: Client._argsToBytes(
// Additional arguments, setting gas limit and non-strict sequencing mode
Client.EVMExtraArgsV1({gasLimit: 200_000, strict: false})
// Additional arguments, setting gas limit
Client.EVMExtraArgsV1({gasLimit: 200_000})
),
// Set the feeToken to a feeTokenAddress, indicating specific asset will be used for fees
feeToken: _feeTokenAddress
Expand Down
4 changes: 2 additions & 2 deletions public/samples/CCIP/Sender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ contract Sender is OwnerIsCreator {
data: abi.encode(text), // ABI-encoded string
tokenAmounts: new Client.EVMTokenAmount[](0), // Empty array indicating no tokens are being sent
extraArgs: Client._argsToBytes(
// Additional arguments, setting gas limit and non-strict sequencing mode
Client.EVMExtraArgsV1({gasLimit: 200_000, strict: false})
// Additional arguments, setting gas limit
Client.EVMExtraArgsV1({gasLimit: 200_000})
),
// Set the feeToken address, indicating LINK will be used for fees
feeToken: address(s_linkToken)
Expand Down
6 changes: 3 additions & 3 deletions public/samples/CCIP/TokenTransferor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol";
import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/token/ERC20/IERC20.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/IERC20.sol";

/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
Expand Down Expand Up @@ -221,8 +221,8 @@ contract TokenTransferor is OwnerIsCreator {
data: "", // No data
tokenAmounts: tokenAmounts, // The amount and type of token being transferred
extraArgs: Client._argsToBytes(
// Additional arguments, setting gas limit to 0 as we are not sending any data and non-strict sequencing mode
Client.EVMExtraArgsV1({gasLimit: 0, strict: false})
// Additional arguments, setting gas limit to 0 as we are not sending any data
Client.EVMExtraArgsV1({gasLimit: 0})
),
// Set the feeToken to a feeTokenAddress, indicating specific asset will be used for fees
feeToken: _feeTokenAddress
Expand Down
181 changes: 138 additions & 43 deletions src/config/data/ccip/data.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,161 @@
import { ChainsConfig, LanesConfig, TokensConfig, Environment } from "./types"
import { ChainsConfig, LanesConfig, TokensConfig, Environment, Version } from "./types"

// For mainnet
import chainsMainnet from "@config/data/ccip/mainnet/chains.json"
import lanesMainnet from "@config/data/ccip/mainnet/lanes.json"
import tokensMainnet from "@config/data/ccip/mainnet//tokens.json"
import chainsMainnetv100 from "@config/data/ccip/v1_0_0/mainnet/chains.json"
import lanesMainnetv100 from "@config/data/ccip/v1_0_0/mainnet/lanes.json"
import tokensMainnetv100 from "@config/data/ccip/v1_0_0/mainnet/tokens.json"

// For testnet

import chainsTestnet from "@config/data/ccip/testnet/chains.json"
import lanesTestnet from "@config/data/ccip/testnet/lanes.json"
import tokensTestnet from "@config/data/ccip/testnet/tokens.json"
import chainsTestnetv120 from "@config/data/ccip/v1_2_0/testnet/chains.json"
import lanesTestnetv120 from "@config/data/ccip/v1_2_0/testnet/lanes.json"
import tokensTestnetv120 from "@config/data/ccip/v1_2_0/testnet/tokens.json"

import chainsTestnetv100 from "@config/data/ccip/v1_0_0/testnet/chains.json"
import lanesTestnetv100 from "@config/data/ccip/v1_0_0/testnet/lanes.json"
import tokensTestnetv100 from "@config/data/ccip/v1_0_0/testnet/tokens.json"
import { SupportedChain } from "@config/types"
import { supportedChainToChainInRdd } from "@features/utils"

export const loadReferenceData = (environment: Environment) => {
let chainsReferenceData: ChainsConfig, lanesReferenceData: LanesConfig, tokensReferenceData: TokensConfig
switch (
environment // Make sure to use the parameter 'environment', not the type 'Environment'
) {
case Environment.Mainnet:
chainsReferenceData = chainsMainnet as unknown as ChainsConfig
lanesReferenceData = lanesMainnet as unknown as LanesConfig
tokensReferenceData = tokensMainnet as unknown as TokensConfig
export const loadReferenceData = ({ environment, version }: { environment: Environment; version: Version }) => {
let chainsReferenceData: ChainsConfig
let lanesReferenceData: LanesConfig
let tokensReferenceData: TokensConfig

if (environment === Environment.Mainnet && version === Version.V1_0_0) {
chainsReferenceData = chainsMainnetv100 as unknown as ChainsConfig
lanesReferenceData = lanesMainnetv100 as unknown as LanesConfig
tokensReferenceData = tokensMainnetv100 as unknown as TokensConfig
} else if (environment === Environment.Testnet && version === Version.V1_2_0) {
chainsReferenceData = chainsTestnetv120 as unknown as ChainsConfig
lanesReferenceData = lanesTestnetv120 as unknown as LanesConfig
tokensReferenceData = tokensTestnetv120 as unknown as TokensConfig
} else if (environment === Environment.Testnet && version === Version.V1_0_0) {
chainsReferenceData = chainsTestnetv100 as unknown as ChainsConfig
lanesReferenceData = lanesTestnetv100 as unknown as LanesConfig
tokensReferenceData = tokensTestnetv100 as unknown as TokensConfig
} else {
throw new Error(`Invalid environment/version combination: ${environment}/${version}`)
}

return { chainsReferenceData, lanesReferenceData, tokensReferenceData }
}

export const getAllChains = ({
mainnetVersion,
testnetVersion,
}: {
mainnetVersion: Version
testnetVersion: Version
}) => {
let chainsMainnetKeys: string[] = []
let chainsTestnetKeys: string[] = []

switch (mainnetVersion) {
case Version.V1_0_0:
chainsMainnetKeys = Object.keys(chainsMainnetv100)
break
default:
throw new Error(`Invalid mainnet version: ${mainnetVersion}`)
}

switch (testnetVersion) {
case Version.V1_0_0:
chainsTestnetKeys = Object.keys(chainsTestnetv100)
break
case Environment.Testnet:
chainsReferenceData = chainsTestnet as unknown as ChainsConfig
lanesReferenceData = lanesTestnet as unknown as LanesConfig
tokensReferenceData = tokensTestnet as unknown as TokensConfig
case Version.V1_2_0:
chainsTestnetKeys = Object.keys(chainsTestnetv120)
break
default:
throw Error(`Wrong environment ${environment}`)
throw new Error(`Invalid testnet version: ${testnetVersion}`)
}

return { chainsReferenceData, lanesReferenceData, tokensReferenceData }
return [...chainsMainnetKeys, ...chainsTestnetKeys]
}

export const allChains = [...Object.keys(chainsMainnet), ...Object.keys(chainsTestnet)]

const CCIPTokenImage =
"https://images.prismic.io/data-chain-link/86d5bc29-7511-49f5-bbd8-18a8ebc008b0_ccip-icon-white.png?auto=compress,format"

export const isBnMRdd = (chainRdd: string) => {
return tokensTestnet["CCIP-BnM"][chainRdd]
const isBnMRdd = ({ chainRdd, version }: { chainRdd: string; version: Version }) => {
let tokensTestData

switch (version) {
case Version.V1_0_0:
tokensTestData = tokensTestnetv100["CCIP-BnM"]
break
case Version.V1_2_0:
tokensTestData = tokensTestnetv120["CCIP-BnM"]
break
default:
throw new Error(`Invalid testnet version: ${version}`)
}

return tokensTestData[chainRdd]
}

export const isBnM = (chain: SupportedChain) => {
export const isBnM = ({ chain, version }: { chain: SupportedChain; version: Version }) => {
const chainRdd = supportedChainToChainInRdd(chain)
return isBnMRdd(chainRdd)
return isBnMRdd({ chainRdd, version })
}

export const isLnMRdd = (chainRdd: string) => {
export const isLnMRdd = ({ chainRdd, version }: { chainRdd: string; version: Version }) => {
let tokensTestData
const supportedChainForLock: SupportedChain = "ETHEREUM_SEPOLIA"
switch (version) {
case Version.V1_0_0:
tokensTestData = tokensTestnetv100["CCIP-LnM"]
break
case Version.V1_2_0:
tokensTestData = tokensTestnetv120["CCIP-LnM"]
break
default:
throw new Error(`Invalid testnet version: ${version}`)
}

return {
supported: tokensTestnet["CCIP-LnM"][chainRdd],
supported: tokensTestData[chainRdd],
supportedChainForLock,
} // LnM only for Sepolia
}
}

export const isLnM = (chain: SupportedChain) => {
export const isLnM = ({ chain, version }: { chain: SupportedChain; version: Version }) => {
const chainRdd = supportedChainToChainInRdd(chain)
return isLnMRdd(chainRdd)
return isLnMRdd({ chainRdd, version })
}

export const isBnMOrLnMRdd = (chainRdd: string) => {
return isBnMRdd(chainRdd) || isLnMRdd(chainRdd).supported
export const isBnMOrLnMRdd = ({ chainRdd, version }: { chainRdd: string; version: Version }) => {
return isBnMRdd({ chainRdd, version }) || isLnMRdd({ chainRdd, version }).supported
}

export const isBnMOrLnM = (chain: SupportedChain) => {
return isBnM(chain) || isLnM(chain)
export const isBnMOrLnM = ({ chain, version }: { chain: SupportedChain; version: Version }) => {
return isBnM({ chain, version }) || isLnM({ chain, version })
}

export const getBnMParams = (supportedChain: SupportedChain) => {
export const getBnMParams = ({ supportedChain, version }: { supportedChain: SupportedChain; version: Version }) => {
const supportedChainRdd = supportedChainToChainInRdd(supportedChain)
if (!(supportedChainRdd in chainsTestnet)) return undefined // No BnM for mainnets
const token = tokensTestnet["CCIP-BnM"][supportedChainRdd]

let chainsTestData
let tokensTestData
switch (version) {
case Version.V1_0_0:
chainsTestData = chainsTestnetv100
tokensTestData = tokensTestnetv100["CCIP-BnM"]
break
case Version.V1_2_0:
chainsTestData = chainsTestnetv120
tokensTestData = tokensTestnetv120["CCIP-BnM"]
break
default:
throw new Error(`Invalid testnet version: ${version}`)
}

if (!(supportedChainRdd in chainsTestData)) return undefined // No BnM for mainnets
const token = tokensTestData[supportedChainRdd]
if (!token || Object.keys(token).length === 0) {
console.warn(`No BnM found for testnet ${supportedChain}`)
return undefined
}

const {
tokenAddress: address,
symbol,
Expand All @@ -98,23 +176,40 @@ export const getBnMParams = (supportedChain: SupportedChain) => {
}
}

export const getLnMParams = (supportedChain: SupportedChain) => {
export const getLnMParams = ({ supportedChain, version }: { supportedChain: SupportedChain; version: Version }) => {
const supportedChainRdd = supportedChainToChainInRdd(supportedChain)
if (!isLnMRdd(supportedChainRdd).supported) return undefined
const token = tokensTestnet["CCIP-LnM"][supportedChainRdd]

if (!isLnMRdd({ chainRdd: supportedChainRdd, version }).supported) return undefined

let tokensTestData
switch (version) {
case Version.V1_0_0:
tokensTestData = tokensTestnetv100["CCIP-LnM"]
break
case Version.V1_2_0:
tokensTestData = tokensTestnetv120["CCIP-LnM"]
break
default:
throw new Error(`Invalid testnet version: ${version}`)
}

const token = tokensTestData[supportedChainRdd]
if (!token || Object.keys(token).length === 0) {
console.warn(`No LnM found for testnet ${supportedChain}`)
return undefined
}

const {
tokenAddress: address,
symbol,
decimals,
} = token as { tokenAddress: string; symbol: string; decimals: number }

if (!address || !symbol || !decimals) {
console.error(`Token data not correct for LnM token on ${supportedChain}`)
return undefined
}

return {
type: "ERC20",
options: {
Expand Down
5 changes: 5 additions & 0 deletions src/config/data/ccip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ export enum Environment {
Mainnet = "mainnet",
Testnet = "testnet",
}

export enum Version {
V1_0_0 = "1.0.0",
V1_2_0 = "1.2.0",
}
Loading
Loading