Skip to content

Commit ffcba9b

Browse files
committed
feat(protocol-contracts): add bnb configs
1 parent 96f3154 commit ffcba9b

6 files changed

Lines changed: 47 additions & 7 deletions

File tree

protocol-contracts/token/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ PRIVATE_KEY=
33
# mainnet
44
MAINNET_RPC_URL=
55
RPC_URL_ZAMA_GATEWAY_MAINNET=
6+
RPC_URL_BNB_MAINNET=
67
# testnet
78
SEPOLIA_RPC_URL=
89
RPC_URL_ZAMA_GATEWAY_TESTNET=
10+
RPC_URL_BNB_TESTNET=
911
# API for contract verification
1012
ETHERSCAN_API=TA5XXXXXXXXXXXXXXXXXXXXXXXXXXXGX9
1113
BLOCKSCOUT_API=https://explorer-xxxx-xxxxxxx.conduit.xyz/api # don't forget the /api suffix at the end

protocol-contracts/token/hardhat.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ const config: HardhatUserConfig = {
9191
url: process.env.RPC_URL_ZAMA_GATEWAY_TESTNET || '',
9292
accounts,
9393
},
94+
'bnb-mainnet': {
95+
eid: EndpointId.BSC_V2_MAINNET,
96+
url: process.env.RPC_URL_BNB_MAINNET || '',
97+
accounts,
98+
},
99+
'bnb-testnet': {
100+
eid: EndpointId.BSC_V2_TESTNET,
101+
url: process.env.RPC_URL_BNB_TESTNET || '',
102+
accounts,
103+
},
94104
hardhat: {
95105
// Need this for testing because TestHelperOz5.sol is exceeding the compiled contract size limit
96106
allowUnlimitedContractSize: true,

protocol-contracts/token/layerzero.config.mainnet.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ const zamaMainnetContract: OmniPointHardhat = {
1515
contractName: 'ZamaOFT',
1616
}
1717

18-
// To connect all the above chains to each other, we need the following pathways:
18+
const bnbContract: OmniPointHardhat = {
19+
eid: EndpointId.BSC_V2_MAINNET,
20+
contractName: 'ZamaOFT',
21+
}
22+
23+
// We need the following pathways:
1924
// ZamaGatewayMainnet <-> Ethereum
25+
// BNB <-> Ethereum
2026

2127
// For this example's simplicity, we will use the same enforced options values for sending to all chains
2228
// For production, you should ensure `gas` is set to the correct value through profiling the gas usage of calling OFT._lzReceive(...) on the destination chain
@@ -41,13 +47,21 @@ const pathways: TwoWayConfig[] = [
4147
[15, 20], // [A to B confirmations, B to A confirmations]
4248
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
4349
],
50+
[
51+
ethereumContract, // Chain A contract
52+
bnbContract, // Chain B contract
53+
// TODO: Add custom ZAMA DVN in next line?
54+
[['LayerZero Labs'], [['Nethermind', 'Luganodes', 'P2P'], 2]], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
55+
[15, 20], // [A to B confirmations, B to A confirmations]
56+
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
57+
],
4458
]
4559

4660
export default async function () {
4761
// Generate the connections config based on the pathways
4862
const connections = await generateConnectionsConfig(pathways)
4963
return {
50-
contracts: [{ contract: zamaMainnetContract }, { contract: ethereumContract }],
64+
contracts: [{ contract: zamaMainnetContract }, { contract: ethereumContract }, { contract: bnbContract }],
5165
connections,
5266
}
5367
}

protocol-contracts/token/layerzero.config.testnet.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ const zamaTestnetContract: OmniPointHardhat = {
1515
contractName: 'ZamaOFT',
1616
}
1717

18-
// To connect all the above chains to each other, we need the following pathways:
18+
const bnbTestnetContract: OmniPointHardhat = {
19+
eid: EndpointId.BSC_V2_TESTNET,
20+
contractName: 'ZamaOFT',
21+
}
22+
23+
// We need the following pathways:
1924
// ZamaGatewayTestnet <-> Sepolia
25+
// BNBTestnet <-> Sepolia
2026

2127
// For this example's simplicity, we will use the same enforced options values for sending to all chains
2228
// For production, you should ensure `gas` is set to the correct value through profiling the gas usage of calling OFT._lzReceive(...) on the destination chain
@@ -25,7 +31,7 @@ const EVM_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
2531
{
2632
msgType: 1,
2733
optionType: ExecutorOptionType.LZ_RECEIVE,
28-
gas: 50000,
34+
gas: 80000,
2935
value: 0,
3036
},
3137
]
@@ -41,13 +47,20 @@ const pathways: TwoWayConfig[] = [
4147
[15, 20], // [A to B confirmations, B to A confirmations]
4248
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
4349
],
50+
[
51+
sepoliaContract,
52+
bnbTestnetContract,
53+
[['LayerZero Labs'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
54+
[15, 20], // [A to B confirmations, B to A confirmations]
55+
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
56+
],
4457
]
4558

4659
export default async function () {
4760
// Generate the connections config based on the pathways
4861
const connections = await generateConnectionsConfig(pathways)
4962
return {
50-
contracts: [{ contract: zamaTestnetContract }, { contract: sepoliaContract }],
63+
contracts: [{ contract: zamaTestnetContract }, { contract: sepoliaContract }, { contract: bnbTestnetContract }],
5164
connections,
5265
}
5366
}

protocol-contracts/token/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"lint:js": "eslint '**/*.{js,ts,json}' && prettier --check .",
1212
"lint:sol": "solhint 'contracts/**/*.sol'",
1313
"test": "hardhat test",
14-
"verify:etherscan:arbitrum:sepolia": "dotenv -e .env -- bash -c 'npx @layerzerolabs/verify-contract verify-contract -d ./deployments -n arbitrum-testnet -u https://api.etherscan.io/v2/api?chainid=421614 -k $ETHERSCAN_API'",
14+
"verify:etherscan:bnb:mainnet": "dotenv -e .env -- bash -c 'npx @layerzerolabs/verify-contract verify-contract -d ./deployments -n bnb-mainnet -u https://api.etherscan.io/v2/api?chainid=56 -k $ETHERSCAN_API'",
15+
"verify:etherscan:bnb:testnet": "dotenv -e .env -- bash -c 'npx @layerzerolabs/verify-contract verify-contract -d ./deployments -n bnb-testnet -u https://api.etherscan.io/v2/api?chainid=97 -k $ETHERSCAN_API'",
1516
"verify:etherscan:ethereum:mainnet": "dotenv -e .env -- bash -c 'npx @layerzerolabs/verify-contract verify-contract -d ./deployments -n ethereum-mainnet -u https://api.etherscan.io/v2/api?chainid=1 -k $ETHERSCAN_API'",
1617
"verify:etherscan:ethereum:sepolia": "dotenv -e .env -- bash -c 'npx @layerzerolabs/verify-contract verify-contract -d ./deployments -n ethereum-testnet -u https://api.etherscan.io/v2/api?chainid=11155111 -k $ETHERSCAN_API'",
1718
"verify:etherscan:gateway:mainnet": "dotenv -e .env -- bash -c 'npx @layerzerolabs/verify-contract verify-contract -d ./deployments -n gateway-mainnet -u $BLOCKSCOUT_API'",

protocol-contracts/token/tasks/sendOFT.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ task('lz:oft:send', 'Sends OFT tokens cross‐chain from EVM chains')
3434
.addParam('dstEid', 'Destination endpoint ID', undefined, types.int)
3535
.addParam('amount', 'Amount to send (human readable units, e.g. "1.5")', undefined, types.string)
3636
.addParam('to', 'Recipient address (20-byte hex for EVM)', undefined, types.string)
37-
.addOptionalParam('oappConfig', 'Path to LayerZero config file', 'layerzero.config.testnet.ts', types.string)
37+
.addOptionalParam('oappConfig', 'Path to LayerZero config file', 'layerzero.config.mainnet.ts', types.string)
3838
.addOptionalParam(
3939
'minAmount',
4040
'Minimum amount to receive in case of custom slippage or fees (human readable units, e.g. "1.5")',

0 commit comments

Comments
 (0)