Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLiteplo committed Dec 11, 2024
1 parent 49903a0 commit 06c5c26
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 80 deletions.
61 changes: 11 additions & 50 deletions examples/oft-aptos/aptos.layerzero.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ const aptosContract: OmniPointHardhat = {
contractName: 'oft',
}

const ethereumSandboxContract: OmniPointHardhat = {
eid: EndpointId.ETHEREUM_V2_SANDBOX,
contractName: 'MyOFT',
}

const bscSandboxContract: OmniPointHardhat = {
eid: EndpointId.BSC_V2_SANDBOX,
contractName: 'MyOFT',
}

const aptosSandboxContract: OmniPointHardhat = {
eid: EndpointId.APTOS_V2_SANDBOX,
contractName: 'oft',
}

const config: OAppOmniGraphHardhat = {
contracts: [
{
Expand All @@ -45,14 +30,6 @@ const config: OAppOmniGraphHardhat = {
contract: bscContract,
config: bscConfig.accountConfig,
},
{
contract: ethereumSandboxContract,
config: ethConfig.accountConfig,
},
{
contract: bscSandboxContract,
config: bscConfig.accountConfig,
},
{
contract: aptosContract,
config: {
Expand All @@ -70,21 +47,15 @@ const config: OAppOmniGraphHardhat = {
{
msgType: 1,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 1000, // gas limit in wei for EndpointV2.lzReceive
gas: 80000, // gas limit in wei for EndpointV2.lzReceive
value: 0, // msg.value in wei for EndpointV2.lzReceive
},
{
msgType: 2,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 1000, // gas limit in wei for EndpointV2.lzCompose
gas: 80000, // gas limit in wei for EndpointV2.lzCompose
value: 0, // msg.value in wei for EndpointV2.lzCompose
},
// {
// msgType: 1,
// optionType: ExecutorOptionType.NATIVE_DROP,
// amount: 0, // amount of native gas token in wei to drop to receiver address
// receiver: '0x0000000000000000000000000000000000000000',
// },
],
sendLibrary: '0xbe533727aebe97132ec0a606d99e0ce137dbdf06286eb07d9e0f7154df1f3f10',
receiveLibraryConfig: {
Expand All @@ -96,7 +67,7 @@ const config: OAppOmniGraphHardhat = {
// Optional Receive Library Timeout for when the Old Receive Library Address will no longer be valid on Aptos
receiveLibraryTimeoutConfig: {
lib: '0xbe533727aebe97132ec0a606d99e0ce137dbdf06286eb07d9e0f7154df1f3f10',
expiry: BigInt(696969669),
expiry: BigInt(1000),
},
sendConfig: {
executorConfig: {
Expand All @@ -106,31 +77,31 @@ const config: OAppOmniGraphHardhat = {
},
ulnConfig: {
// The number of block confirmations to wait on Aptos before emitting the message from the source chain.
confirmations: BigInt(300),
confirmations: BigInt(0),
// The address of the DVNs you will pay to verify a sent message on the source chain.
// The destination tx will wait until ALL `requiredDVNs` verify the message.
requiredDVNs: ['0xd6f420483a90c7db5ce2ec12e8acfc2bfb7b93829c9e6a3b0760bca330be64dd'],
requiredDVNs: [],
// The address of the DVNs you will pay to verify a sent message on the source chain.
// The destination tx will wait until the configured threshold of `optionalDVNs` verify a message.
optionalDVNs: ['0xd6f420483a90c7db5ce2ec12e8acfc2bfb7b93829c9e6a3b0760bca330be64dd'],
optionalDVNs: [],
// The number of `optionalDVNs` that need to successfully verify the message for it to be considered Verified.
optionalDVNThreshold: 1,
optionalDVNThreshold: 0,
},
},
// Optional Receive Configuration
// @dev Controls how the `from` chain receives messages from the `to` chain.
receiveConfig: {
ulnConfig: {
// The number of block confirmations to expect from the `to` chain.
confirmations: BigInt(300),
confirmations: BigInt(0),
// The address of the DVNs your `receiveConfig` expects to receive verifications from on the `from` chain.
// The `from` chain's OApp will wait until the configured threshold of `requiredDVNs` verify the message.
requiredDVNs: ['0x0'],
requiredDVNs: [],
// The address of the `optionalDVNs` you expect to receive verifications from on the `from` chain.
// The destination tx will wait until the configured threshold of `optionalDVNs` verify the message.
optionalDVNs: ['0xd6f420483a90c7db5ce2ec12e8acfc2bfb7b93829c9e6a3b0760bca330be64dd'],
optionalDVNs: [],
// The number of `optionalDVNs` that need to successfully verify the message for it to be considered Verified.
optionalDVNThreshold: 1,
optionalDVNThreshold: 0,
},
},
},
Expand All @@ -145,16 +116,6 @@ const config: OAppOmniGraphHardhat = {
to: aptosContract,
config: ethConfig.oappConfig,
},
{
from: bscSandboxContract,
to: aptosSandboxContract,
config: bscConfig.oappConfig,
},
{
from: ethereumSandboxContract,
to: aptosSandboxContract,
config: ethConfig.oappConfig,
},
],
}

Expand Down
22 changes: 6 additions & 16 deletions examples/oft-aptos/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,19 @@ const config: HardhatUserConfig = {
},
'bsc-testnet': {
eid: EndpointId.BSC_V2_TESTNET,
url: process.env.RPC_URL_BSC_TESTNET || 'http://127.0.0.1:8502',
url: process.env.RPC_URL_BSC_TESTNET || 'https://data-seed-prebsc-1-s1.binance.org:8545/',
accounts,
},
'avalanche-testnet': {
eid: EndpointId.AVALANCHE_V2_TESTNET,
url: process.env.RPC_URL_FUJI || 'https://rpc.ankr.com/avalanche_fuji',
accounts,
},
'aptos-testnet': {
eid: EndpointId.APTOS_V2_TESTNET,
url: process.env.RPC_URL_APTOS_TESTNET || 'http://127.0.0.1:8080',
accounts,
},
'sandbox-eth': {
eid: EndpointId.ETHEREUM_V2_SANDBOX,
url: process.env.RPC_URL_ETH_SANDBOX || 'http://127.0.0.1:8501',
accounts,
},
'sandbox-bsc': {
eid: EndpointId.BSC_V2_SANDBOX,
url: process.env.RPC_URL_BSC_SANDBOX || 'http://127.0.0.1:8502',
accounts,
},
'sandbox-aptos': {
eid: EndpointId.APTOS_V2_SANDBOX,
url: process.env.RPC_URL_APTOS_SANDBOX || 'http://127.0.0.1:8080',
accounts,
},
},
namedAccounts: {
deployer: {
Expand Down
21 changes: 14 additions & 7 deletions examples/oft-aptos/sdk/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ export class Endpoint {
}

async getSendLibrary(oftAddress: string, dstEid: number): Promise<[string, boolean]> {
const result = await this.aptos.view({
payload: {
function: `${this.endpoint_address}::endpoint::get_effective_send_library`,
functionArguments: [oftAddress, dstEid],
},
})
return [result[0] as string, result[1] as boolean]
try {
const result = await this.aptos.view({
payload: {
function: `${this.endpoint_address}::endpoint::get_effective_send_library`,
functionArguments: [oftAddress, dstEid],
},
})
return [result[0] as string, result[1] as boolean]
} catch (error) {
const toNetwork = getNetworkForChainId(dstEid)
throw new Error(
`Failed to get send library. Network: ${toNetwork.chainName}-${toNetwork.env} might not be supported.`
)
}
}

async getReceiveLibrary(oftAddress: string, dstEid: number): Promise<[string, boolean]> {
Expand Down
18 changes: 11 additions & 7 deletions examples/oft-aptos/tasks/move/sendFromAptos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getAptosOftAddress, sendAllTxs } from './utils/utils'
import { getLzNetworkStage, parseYaml } from './utils/aptosNetworkParser'
import { EndpointId } from '@layerzerolabs/lz-definitions-v3'
import { hexAddrToAptosBytesAddr } from '../../sdk/utils'
import { Options } from '@layerzerolabs/lz-v2-utilities-v3'

async function main() {
const { account_address, private_key, network } = await parseYaml()
Expand All @@ -17,23 +18,26 @@ async function main() {

const oft = new OFT(aptos, aptosOftAddress, account_address, private_key)

const amount_ld = 1
const amount_ld = 200000
const min_amount_ld = 1
const toAddress = '0x462c2AE39B6B0bdB950Deb2BC82082308cF8cB10'
const toAddressBytes = hexAddrToAptosBytesAddr(toAddress)
const options = Options.newOptions().addExecutorLzReceiveOption(BigInt(200000))

console.log(`Attempting to send ${amount_ld} units`)
console.log(`Using OFT address: ${aptosOftAddress}`)
console.log(`Using OFT at address: ${aptosOftAddress}`)
console.log(`From account: ${account_address}`)
console.log(`To account: ${toAddress}`)

const dst_eid = EndpointId.BSC_V2_TESTNET
const to = hexAddrToAptosBytesAddr('0x0000000000000000000000003e96158286f348145819244000776202ae5e0283')
const extra_options = new Uint8Array([])
const extra_options = options.toBytes()
const compose_message = new Uint8Array([])
const oft_cmd = new Uint8Array([])
const dst_eid = EndpointId.BSC_V2_TESTNET

const [nativeFee, zroFee] = await oft.quoteSend(
account_address,
dst_eid,
to,
toAddressBytes,
amount_ld,
min_amount_ld,
extra_options,
Expand All @@ -48,7 +52,7 @@ async function main() {

const sendPayload = oft.sendPayload(
dst_eid,
to,
toAddressBytes,
amount_ld,
min_amount_ld,
extra_options,
Expand Down

0 comments on commit 06c5c26

Please sign in to comment.