Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions examples/oft-adapter-initia/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ shell-scripts

transactions/*
!transactions/.gitkeep
deployments
8 changes: 5 additions & 3 deletions examples/oft-adapter-initia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ https://docs.initia.xyz/build-on-initia/initiad
After installation, generate a new key and add it to the keyring:

```bash
initiad keys add <your-key-name> --key-type secp256k1 --coin-type 118 --keyring-backend test
initiad keys add <your-key-name> --keyring-backend test
```

For more information on key management please reference the Initiad docs: https://docs.initia.xyz/build-on-initia/initiad#managing-keys
Expand Down Expand Up @@ -92,7 +92,7 @@ pnpm run lz:sdk:move:build --oapp-config move.layerzero.config.ts --oapp-type of
To build and deploy the contracts, run the following command:

```bash
pnpm run lz:sdk:move:deploy --oapp-config move.layerzero.config.ts --address-name oft --move-deploy-script deploy-move/OFTInitParams.ts --oapp-type oft
pnpm run lz:sdk:move:deploy --oapp-config move.layerzero.config.ts --address-name oft --move-deploy-script deploy-move/OFTAdapterInitParams.ts --oapp-type oft
```

## EVM Deployment
Expand All @@ -110,6 +110,7 @@ First modify deploy-move/OFTAdapterInitParams.ts and replace the oftMetadata wit
```ts
const oftMetadata = {
move_vm_fa_address: "<your fungible asset address>",
localDecimals: 6,
};
```

Expand Down Expand Up @@ -275,12 +276,13 @@ pnpm run lz:sdk:move:mint-to-move-oft --oapp-config move.layerzero.config.ts --a

```bash
pnpm run lz:sdk:move:send-from-move-oft \
--oapp-config move.layerzero.config.ts \
--amount-ld <your-amount-ld> \
--min-amount-ld <your-min-amount-ld> \
--src-address <your-source-account-address> \
--to-address <your-destination-account-address> \
--gas-limit <your-gas-limit> \
--dst-eid <your-dst-eid>\
--dst-eid <your-dst-eid>
```

## Send from EVM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { OFTAdapterFaInitParams } from '@layerzerolabs/oft-move'

const oftMetadata: OFTAdapterFaInitParams = {
move_vm_fa_address: '',
localDecimals: 6,
}

export default oftMetadata
1 change: 1 addition & 0 deletions examples/oft-adapter-initia/deploy/MyEVMOFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const deploy: DeployFunction = async (hre) => {
],
log: true,
skipIfAlreadyDeployed: false,
gasLimit: 3_000_000,
})

console.log(`Deployed contract: ${contractName}, network: ${hre.network.name}, address: ${address}`)
Expand Down
11 changes: 3 additions & 8 deletions examples/oft-adapter-initia/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,9 @@ const config: HardhatUserConfig = {
],
},
networks: {
'arbitrum-sepolia': {
eid: EndpointId.ARBSEP_V2_TESTNET,
url: process.env.RPC_URL_ARBITRUM_SEPOLIA || 'https://arbitrum-sepolia.gateway.tenderly.co',
accounts,
},
'sepolia-testnet': {
eid: EndpointId.SEPOLIA_V2_TESTNET,
url: process.env.RPC_URL_SEPOLIA || 'https://sepolia.infura.io/v3/',
'bsc-testnet': {
eid: EndpointId.BSC_V2_TESTNET,
url: process.env.RPC_URL_BSC_TESTNET || 'https://data-seed-prebsc-1-s1.binance.org:8545',
accounts,
},
hardhat: {
Expand Down
8 changes: 4 additions & 4 deletions examples/oft-adapter-initia/move.layerzero.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum MsgType {
}

const bscContract: OmniPointHardhat = {
eid: EndpointId.ARBSEP_V2_TESTNET,
eid: EndpointId.BSC_V2_TESTNET,
contractName: 'MyOFT',
}

Expand Down Expand Up @@ -90,7 +90,7 @@ const config: OAppOmniGraphHardhat = {
receiveConfig: {
ulnConfig: {
// The number of block confirmations to expect from the `to` chain.
confirmations: BigInt(5),
confirmations: BigInt(10),
// 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: ['0x3f12330ba9e26a604e2149b4b67c0710d32fcbc3de0bea76dd43dbb6b747bc8c'],
Expand Down Expand Up @@ -136,14 +136,14 @@ const config: OAppOmniGraphHardhat = {
executor: '0x31894b190a8bAbd9A067Ce59fde0BfCFD2B18470',
},
ulnConfig: {
confirmations: BigInt(5),
confirmations: BigInt(10),
requiredDVNs: ['0x0eE552262f7B562eFcED6DD4A7e2878AB897d405'],
optionalDVNThreshold: 0,
},
},
receiveConfig: {
ulnConfig: {
confirmations: BigInt(10),
confirmations: BigInt(2),
requiredDVNs: ['0x0eE552262f7B562eFcED6DD4A7e2878AB897d405'],
optionalDVNThreshold: 0,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ module oft::oft_adapter_fa {
public entry fun initialize(
account: &signer,
token_metadata_address: address,
shared_decimals: u8
shared_decimals: u8,
local_decimals: Option<u8>
) acquires OftImpl {
// Only the admin can initialize the OFT
assert_admin(address_of(account));
Expand All @@ -289,8 +290,14 @@ module oft::oft_adapter_fa {
let metadata = address_to_object<Metadata>(token_metadata_address);
store_mut().metadata = option::some(metadata);

// compute the local decimals
let local_decimals = if (option::is_some(&local_decimals)) {
*option::borrow(&local_decimals)
} else {
fungible_asset::decimals(metadata)
};

// Initialize the OFT Core
let local_decimals = fungible_asset::decimals(metadata);
oft_core::initialize(local_decimals, shared_decimals);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module oft::oft_adapter_fa_tests {
// Some of the tests expect that that shared decimals is 6. If this is changed, the tests will need to be
// updated (specifically the values need to be adjusted for dust)
6,
option::none(),
);

mint_ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module oft::oapp_receive_using_oft_adapter_fa_tests {
use std::account::create_signer_for_test;
use std::event::was_event_emitted;
use std::fungible_asset::{Self, MintRef};
use std::option;
use std::primary_fungible_store;
use std::string::utf8;

Expand Down Expand Up @@ -38,7 +39,7 @@ module oft::oapp_receive_using_oft_adapter_fa_tests {

// Generates a fungible asset with 8 decimals
let (fa, _, mint_ref) = create_fa(b"My Test Token");
oft_adapter_fa::initialize(oft_admin, fa, 6);
oft_adapter_fa::initialize(oft_admin, fa, 6, option::none());

oapp_core::set_peer(oft_admin, SRC_EID, from_bytes32(from_address(@1234)));
oapp_core::set_peer(oft_admin, DST_EID, from_bytes32(from_address(@4321)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module oft::oft_using_oft_adapter_fa_tests {

// Generates a fungible asset with 8 decimals
let (fa, _, mint_ref) = create_fa(b"My Test Token");
oft_adapter_fa::initialize(oft_admin, fa, 6);
oft_adapter_fa::initialize(oft_admin, fa, 6, option::none());

let remote_oapp = from_address(@2000);
set_peer(oft_admin, DST_EID, from_bytes32(remote_oapp));
Expand Down
1 change: 1 addition & 0 deletions examples/oft-initia/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ shell-scripts

transactions/*
!transactions/.gitkeep
deployments
5 changes: 3 additions & 2 deletions examples/oft-initia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ https://docs.initia.xyz/build-on-initia/initiad
After installation, generate a new key and add it to the keyring:

```bash
initiad keys add <your-key-name> --key-type secp256k1 --coin-type 118 --keyring-backend test
initiad keys add <your-key-name> --keyring-backend test
```

For more information on key management please reference the Initiad docs: https://docs.initia.xyz/build-on-initia/initiad#managing-keys
Expand Down Expand Up @@ -293,12 +293,13 @@ pnpm run lz:sdk:move:mint-to-move-oft --oapp-config move.layerzero.config.ts --a

```bash
pnpm run lz:sdk:move:send-from-move-oft \
--oapp-config move.layerzero.config.ts \
--amount-ld <your-amount-ld> \
--min-amount-ld <your-min-amount-ld> \
--src-address <your-source-account-address> \
--to-address <your-destination-account-address> \
--gas-limit <your-gas-limit> \
--dst-eid <your-dst-eid>\
--dst-eid <your-dst-eid>
```

## Send from EVM
Expand Down
11 changes: 3 additions & 8 deletions examples/oft-initia/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,9 @@ const config: HardhatUserConfig = {
],
},
networks: {
'arbitrum-sepolia': {
eid: EndpointId.ARBSEP_V2_TESTNET,
url: process.env.RPC_URL_ARB_SEPOLIA || 'https://arbitrum-sepolia.gateway.tenderly.co',
accounts,
},
'base-sepolia': {
eid: EndpointId.BASESEP_V2_TESTNET,
url: process.env.RPC_URL_BASE_SEPOLIA || 'https://base-sepolia.gateway.tenderly.co',
'bsc-testnet': {
eid: EndpointId.BSC_V2_TESTNET,
url: process.env.RPC_URL_BSC_TESTNET || 'https://data-seed-prebsc-1-s1.binance.org:8545',
accounts,
},
hardhat: {
Expand Down
16 changes: 8 additions & 8 deletions examples/oft-initia/move.layerzero.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum MsgType {
}

const bscContract: OmniPointHardhat = {
eid: EndpointId.ARBSEP_V2_TESTNET,
eid: EndpointId.BSC_V2_TESTNET,
contractName: 'MyOFT',
}

Expand Down Expand Up @@ -74,7 +74,7 @@ const config: OAppOmniGraphHardhat = {
},
ulnConfig: {
// The number of block confirmations to wait on Initia before emitting the message from the source chain.
confirmations: BigInt(1_000_000),
confirmations: BigInt(10),
// 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: ['0x3f12330ba9e26a604e2149b4b67c0710d32fcbc3de0bea76dd43dbb6b747bc8c'],
Expand All @@ -90,7 +90,7 @@ const config: OAppOmniGraphHardhat = {
receiveConfig: {
ulnConfig: {
// The number of block confirmations to expect from the `to` chain.
confirmations: BigInt(5),
confirmations: BigInt(10),
// 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: ['0x3f12330ba9e26a604e2149b4b67c0710d32fcbc3de0bea76dd43dbb6b747bc8c'],
Expand All @@ -111,13 +111,13 @@ const config: OAppOmniGraphHardhat = {
{
msgType: MsgType.SEND,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 300_000, // gas limit in wei for EndpointV2.lzReceive
gas: 5_000, // gas limit in wei for EndpointV2.lzReceive
value: 0, // msg.value in wei for EndpointV2.lzReceive
},
{
msgType: MsgType.SEND_AND_CALL,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 300_000, // gas limit in wei for EndpointV2.lzCompose
gas: 5_000, // gas limit in wei for EndpointV2.lzCompose
value: 0, // msg.value in wei for EndpointV2.lzCompose
},
],
Expand All @@ -132,18 +132,18 @@ const config: OAppOmniGraphHardhat = {
// },
sendConfig: {
executorConfig: {
maxMessageSize: 100_000,
maxMessageSize: 10_000,
executor: '0x31894b190a8bAbd9A067Ce59fde0BfCFD2B18470',
},
ulnConfig: {
confirmations: BigInt(5),
confirmations: BigInt(10),
requiredDVNs: ['0x0eE552262f7B562eFcED6DD4A7e2878AB897d405'],
optionalDVNThreshold: 0,
},
},
receiveConfig: {
ulnConfig: {
confirmations: BigInt(1_000_000),
confirmations: BigInt(2),
requiredDVNs: ['0x0eE552262f7B562eFcED6DD4A7e2878AB897d405'],
optionalDVNThreshold: 0,
},
Expand Down
1 change: 0 additions & 1 deletion examples/oft-initia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"hardhat-deploy": "^0.12.1"
},
"dependencies": {
"@initia/initia.js": "^0.2.28",
"@types/glob": "^8.1.0",
"glob": "^11.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-move/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"devDependencies": {
"@aptos-labs/ts-sdk": "^1.33.1",
"@initia/initia.js": "^0.2.28",
"@initia/initia.js": "^1.0.0",
"@jest/globals": "^29.7.0",
"@layerzerolabs/devtools-extensible-cli": "^0.0.7",
"@layerzerolabs/io-devtools": "^0.3.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools-move/sdk/IOFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export interface IOFT {

initializeAdapterFAPayload(
tokenMetadataAddress: string,
sharedDecimals: number
sharedDecimals: number,
localDecimals?: number
): TypedInputGenerateTransactionPayloadData

createSetRateLimitTx(
Expand Down
7 changes: 4 additions & 3 deletions packages/devtools-move/sdk/aptosOFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ export class aptosOFT implements IOFT {

initializeAdapterFAPayload(
tokenMetadataAddress: string,
sharedDecimals: number
sharedDecimals: number,
localDecimals?: number
): TypedInputGenerateTransactionPayloadData {
return {
function: `${this.oft_address}::oft_adapter_fa::initialize`,
functionArguments: [tokenMetadataAddress, sharedDecimals],
types: ['address', 'u8'],
functionArguments: [tokenMetadataAddress, sharedDecimals, localDecimals || 0],
types: ['address', 'u8', 'u8'],
}
}

Expand Down
13 changes: 9 additions & 4 deletions packages/devtools-move/sdk/initiaOFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,24 @@ export class InitiaOFT implements IOFT {

initializeAdapterFAPayload(
tokenMetadataAddress: string,
sharedDecimals: number
sharedDecimals: number,
localDecimals?: number
): TypedInputGenerateTransactionPayloadData {
const msg = new MsgExecute(
this.accountAddress,
this.oft_address,
'oft_adapter_fa',
'initialize',
[],
[bcs.address().serialize(tokenMetadataAddress).toBase64(), bcs.u8().serialize(sharedDecimals).toBase64()]
[
bcs.address().serialize(tokenMetadataAddress).toBase64(),
bcs.u8().serialize(sharedDecimals).toBase64(),
bcs.option(bcs.u8()).serialize(localDecimals).toBase64(),
]
)
return Object.assign(msg, {
types: ['address', 'u8'],
multiSigArgs: [tokenMetadataAddress, sharedDecimals],
types: ['address', 'u8', 'u8'],
multiSigArgs: [tokenMetadataAddress, sharedDecimals, localDecimals || 0],
})
}

Expand Down
7 changes: 4 additions & 3 deletions packages/devtools-move/sdk/oft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ export class OFT {

initializeAdapterFAPayload(
tokenMetadataAddress: string,
sharedDecimals: number
sharedDecimals: number,
localDecimals?: number
): TypedInputGenerateTransactionPayloadData {
return {
function: `${this.oft_address}::oft_adapter_fa::initialize`,
functionArguments: [tokenMetadataAddress, sharedDecimals],
types: ['address', 'u8'],
functionArguments: [tokenMetadataAddress, sharedDecimals, localDecimals || 0],
types: ['address', 'u8', 'u8'],
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/devtools-move/tasks/move/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spawn } from 'child_process'
import fs from 'fs'
import path from 'path'
import { DeployTaskContext } from '../../sdk/baseTaskHelper'
import { getAptosCLICommand, checkInitiaCLIVersion } from './utils/config'
import { getAptosCLICommand } from './utils/config'

let stdErr = ''

Expand Down Expand Up @@ -70,7 +70,6 @@ async function getCLICmd(chain: string, stage: string) {
if (chain === 'aptos' || chain === 'movement') {
return await getAptosCLICommand(chain, stage)
} else if (chain === 'initia') {
await checkInitiaCLIVersion()
return 'initiad'
} else {
throw new Error(`Chain ${chain}-${stage} not supported for build.`)
Expand Down
Loading