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
21 changes: 18 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 All @@ -297,6 +299,19 @@ pnpm run lz:sdk:evm:send-evm \
--min-amount <your-min-amount>
```

Sending Native Token via NativeAdaptor

```bash
pnpm run lz:sdk:evm:send-evm \
--oapp-config move.layerzero.config.ts \
--src-eid <your-src-eid> \
--dst-eid <your-dst-eid> \
--to <your-source-account-address> \
--amount <your-amount> \
--min-amount <your-min-amount> \
--native-token true
```

## Multi-sig

Multi-sig wallet creation and transaction execution on Initia can be done using the Initia multi-sig builder: https://multisig.testnet.initia.xyz/
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
18 changes: 16 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 All @@ -315,6 +316,19 @@ pnpm run lz:sdk:evm:send-evm \
--min-amount <your-min-amount>
```

Sending Native Token via NativeAdaptor

```bash
pnpm run lz:sdk:evm:send-evm \
--oapp-config move.layerzero.config.ts \
--src-eid <your-src-eid> \
--dst-eid <your-dst-eid> \
--to <your-source-account-address> \
--amount <your-amount> \
--min-amount <your-min-amount> \
--native-token true
```

## Multi-sig

Multi-sig wallet creation and transaction execution on Initia can be done using the Initia multi-sig builder: https://multisig.testnet.initia.xyz/
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
4 changes: 2 additions & 2 deletions packages/devtools-evm/src/signer/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class GnosisOmniSignerEVM<
ethers,
signerOrProvider: signer,
}),
protected readonly apiKit = new SafeApiKit({ txServiceUrl: safeUrl, apiKey: safeConfig.safeApiKey, chainId }),
protected readonly apiKit = new SafeApiKit({ txServiceUrl: safeUrl, ethAdapter }),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SafeApiKit constructor uses deprecated/invalid API parameters

High Severity

The SafeApiKit constructor changed from using chainId and apiKey to using ethAdapter. However, the package uses @safe-global/api-kit version ~4.0.0, which requires chainId as a mandatory parameter and does not accept ethAdapter. The ethAdapter pattern was deprecated in SafeApiKit v2.x. This will cause the Gnosis Safe multisig functionality to fail at runtime when instantiating the GnosisOmniSignerEVM class.

Fix in Cursor Fix in Web

protected readonly safeSdkPromise: Safe | Promise<Safe> = Safe.create({
ethAdapter,
safeAddress: safeConfig.safeAddress!,
Expand Down Expand Up @@ -138,7 +138,7 @@ export class GnosisOmniSignerEVM<

const safeSdk = await this.safeSdkPromise
const safeAddress = await safeSdk.getAddress()
const nonce = parseInt(await this.apiKit.getNextNonce(safeAddress), 10)
const nonce = await this.apiKit.getNextNonce(safeAddress)

return safeSdk.createTransaction({
safeTransactionData: transactions.map((transaction) => this.#serializeTransaction(transaction)),
Expand Down
13 changes: 12 additions & 1 deletion packages/devtools-move/cli/operations/evm-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class EVMSendOperation implements INewOperation {
required: false,
},
},
{
name: '--native-token',
arg: {
help: 'The request is trying to send native token (true/false)',
required: false,
},
},
]

async impl(args: any): Promise<void> {
Expand All @@ -66,6 +73,7 @@ async function sendOFT(args: any): Promise<MessagingFee> {
const to = ethers.utils.hexZeroPad(args.to, 32)
const amount = args.amount
const minAmount = args.min_amount
const sendingNativeToken = args.native_token ? true : false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean CLI flag incorrectly parses string "false" as true

High Severity

The --native-token CLI argument is parsed using args.native_token ? true : false, which treats the string "false" as truthy. If a user explicitly passes --native-token false, sendingNativeToken will be true because non-empty strings are truthy in JavaScript. This causes the transaction to include the token amount in the ETH value when the user explicitly tried to disable native token sending. The correct pattern used elsewhere in the codebase is args.xxx === 'true'.

Fix in Cursor Fix in Web


const privateKey = readPrivateKey(args)
const omniContracts = await createEvmOmniContracts(args, privateKey)
Expand Down Expand Up @@ -101,8 +109,11 @@ async function sendOFT(args: any): Promise<MessagingFee> {
console.log('\t🏦 Native fee:', fee.nativeFee.toString())
console.log('\t🪙 LZ token fee:', fee.lzTokenFee.toString())

const value = sendingNativeToken ? BigInt(fee.nativeFee) + BigInt(amount) : BigInt(fee.nativeFee)
console.log('\n💸 Sending message with total value:', value)

const tx = await oft.send(sendParam, fee, refundAddress, {
value: fee.nativeFee,
value: value,
})

console.log('\n📨 Transaction sent:')
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
Loading