-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathlayerzero.config.ts
More file actions
59 lines (51 loc) · 2.36 KB
/
Copy pathlayerzero.config.ts
File metadata and controls
59 lines (51 loc) · 2.36 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
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
import { TwoWayConfig, generateConnectionsConfig } from '@layerzerolabs/metadata-tools'
import { OAppEnforcedOption, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
import { getSolanaOAppAddress } from './tasks/solana'
const arbitrumContract: OmniPointHardhat = {
eid: EndpointId.ARBSEP_V2_TESTNET,
contractName: 'MyOApp',
}
const solanaContract: OmniPointHardhat = {
eid: EndpointId.SOLANA_V2_TESTNET,
address: getSolanaOAppAddress(EndpointId.SOLANA_V2_TESTNET), // NOTE: replace with the oapp account address
}
// 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 OApp._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: 100_000,
},
]
const SOLANA_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
{
msgType: 1,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 100_000,
},
]
// To connect all the above chains to each other, we need the following pathways:
// Arbitrum <-> Solana
// With the config generator, pathways declared are automatically bidirectional
// i.e. if you declare Arbitrum,Solana there's no need to declare Solana,Arbitrum
const pathways: TwoWayConfig[] = [
[
arbitrumContract, // Arbitrum contract
solanaContract, // Solana contract
[['LayerZero Labs'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
[20, 32], // [Arbitrum to Solana outbound confirmations, Solana to Arbitrum outbound confirmations]
[SOLANA_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Arbitrum to Solana enforcedOptions, Solana to Arbitrum enforcedOptions
],
]
export default async function () {
// Generate the connections config based on the pathways
const connections = await generateConnectionsConfig(pathways)
return {
contracts: [{ contract: arbitrumContract }, { contract: solanaContract }],
connections,
}
}