-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayerzero.config.ts
More file actions
67 lines (60 loc) · 2.56 KB
/
layerzero.config.ts
File metadata and controls
67 lines (60 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
import { TwoWayConfig, generateConnectionsConfig } from '@layerzerolabs/metadata-tools'
import { OAppEnforcedOption } from '@layerzerolabs/toolbox-hardhat'
import type { OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
/**
* WARNING: ONLY 1 OFTAdapter should exist for a given global mesh.
* The token address for the adapter should be defined in hardhat.config. This will be used in deployment.
*
* for example:
*
* 'optimism-testnet': {
* eid: EndpointId.OPTSEP_V2_TESTNET,
* url: process.env.RPC_URL_OP_SEPOLIA || 'https://optimism-sepolia.gateway.tenderly.co',
* accounts,
* oftAdapter: {
* tokenAddress: '0x0', // Set the token address for the OFT adapter
* },
* },
*/
const baseContract: OmniPointHardhat = {
eid: EndpointId.BASESEP_V2_TESTNET,
contractName: 'MyOFTAdapter',
}
const arbitrumContract: OmniPointHardhat = {
eid: EndpointId.ARBSEP_V2_TESTNET,
contractName: 'MyOFT',
}
// To connect all the above chains to each other, we need the following pathways:
// Base <-> Arbitrum
// For this example's simplicity, we will use the same enforced options values for sending to all chains
// 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
// To learn more, read https://docs.layerzero.network/v2/concepts/applications/oapp-standard#execution-options-and-enforced-settings
const EVM_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
{
msgType: 1,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 80000,
value: 0,
},
]
// With the config generator, pathways declared are automatically bidirectional
// i.e. if you declare A,B there's no need to declare B,A
const pathways: TwoWayConfig[] = [
[
baseContract, // Chain A contract
arbitrumContract, // Chain B contract
[['LayerZero Labs'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
[1, 1], // [A to B confirmations, B to A confirmations]
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
],
]
export default async function () {
// Generate the connections config based on the pathways
const connections = await generateConnectionsConfig(pathways)
return {
contracts: [{ contract: baseContract }, { contract: arbitrumContract }],
connections,
}
}