@layerzerolabs/protocol-stellar-v2 0.2.15 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +350 -309
- package/.turbo/turbo-lint.log +146 -108
- package/.turbo/turbo-test.log +1423 -1238
- package/Cargo.lock +12 -0
- package/Cargo.toml +3 -0
- package/contracts/ERROR_SPEC.md +44 -0
- package/contracts/common-macros/src/auth.rs +113 -0
- package/contracts/common-macros/src/contract_ttl.rs +84 -0
- package/contracts/common-macros/src/lib.rs +181 -30
- package/contracts/common-macros/src/lz_contract.rs +83 -0
- package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
- package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
- package/contracts/common-macros/src/tests/mod.rs +2 -2
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
- package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
- package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +3 -3
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
- package/contracts/common-macros/src/ttl_configurable.rs +19 -34
- package/contracts/common-macros/src/ttl_extendable.rs +36 -0
- package/contracts/common-macros/src/upgradeable.rs +5 -5
- package/contracts/common-macros/src/utils.rs +9 -0
- package/contracts/endpoint-v2/src/constants.rs +4 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
- package/contracts/endpoint-v2/src/errors.rs +4 -3
- package/contracts/endpoint-v2/src/events.rs +1 -1
- package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
- package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
- package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
- package/contracts/endpoint-v2/src/storage.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
- package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
- package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
- package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
- package/contracts/message-libs/treasury/src/errors.rs +2 -2
- package/contracts/message-libs/treasury/src/events.rs +1 -1
- package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
- package/contracts/message-libs/treasury/src/storage.rs +1 -1
- package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
- package/contracts/message-libs/treasury/src/treasury.rs +14 -16
- package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
- package/contracts/message-libs/uln-302/src/send_uln.rs +23 -3
- package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
- package/contracts/oapps/counter/Cargo.toml +14 -1
- package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
- package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
- package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
- package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
- package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
- package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
- package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
- package/contracts/oapps/counter/src/counter.rs +67 -43
- package/contracts/oapps/counter/src/tests/mod.rs +0 -13
- package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
- package/contracts/oapps/oapp/src/errors.rs +5 -1
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
- package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
- package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
- package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
- package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
- package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
- package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
- package/contracts/oapps/oft/integration-tests/setup.rs +25 -7
- package/contracts/oapps/oft/src/errors.rs +6 -1
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +8 -8
- package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
- package/contracts/oapps/oft/src/lib.rs +4 -2
- package/contracts/oapps/oft/src/oft.rs +24 -64
- package/contracts/oapps/oft/src/oft_impl.rs +201 -0
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -3
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -4
- package/contracts/oapps/oft/src/storage.rs +2 -0
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +36 -22
- package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +5 -3
- package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +5 -3
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +5 -3
- package/contracts/oapps/oft/src/tests/test_decimals.rs +2 -2
- package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +1 -2
- package/contracts/oapps/oft/src/tests/test_utils.rs +45 -23
- package/contracts/oapps/oft/src/types.rs +20 -0
- package/contracts/oapps/oft-std/integration-tests/setup.rs +4 -2
- package/contracts/oapps/oft-std/src/oft.rs +24 -6
- package/contracts/upgrader/src/lib.rs +4 -4
- package/contracts/utils/src/auth.rs +44 -0
- package/contracts/utils/src/errors.rs +27 -5
- package/contracts/utils/src/lib.rs +3 -0
- package/contracts/utils/src/multisig.rs +211 -0
- package/contracts/utils/src/ownable.rs +12 -10
- package/contracts/utils/src/tests/buffer_reader.rs +6 -6
- package/contracts/utils/src/tests/buffer_writer.rs +6 -6
- package/contracts/utils/src/tests/bytes_ext.rs +2 -4
- package/contracts/utils/src/tests/mod.rs +1 -0
- package/contracts/utils/src/tests/multisig.rs +731 -0
- package/contracts/utils/src/tests/option_ext.rs +2 -5
- package/contracts/utils/src/tests/ownable.rs +16 -5
- package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
- package/contracts/utils/src/tests/upgradeable.rs +4 -2
- package/contracts/utils/src/ttl_configurable.rs +23 -8
- package/contracts/utils/src/ttl_extendable.rs +27 -0
- package/contracts/utils/src/upgradeable.rs +2 -0
- package/contracts/workers/dvn/Cargo.toml +1 -1
- package/contracts/workers/dvn/src/auth.rs +7 -7
- package/contracts/workers/dvn/src/dvn.rs +10 -38
- package/contracts/workers/dvn/src/errors.rs +0 -7
- package/contracts/workers/dvn/src/events.rs +1 -14
- package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
- package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
- package/contracts/workers/dvn/src/storage.rs +3 -13
- package/contracts/workers/dvn/src/tests/auth.rs +4 -4
- package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
- package/contracts/workers/dvn/src/tests/setup.rs +5 -5
- package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
- package/contracts/workers/executor/src/auth.rs +80 -16
- package/contracts/workers/executor/src/executor.rs +5 -31
- package/contracts/workers/executor/src/storage.rs +2 -9
- package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
- package/contracts/workers/executor-helper/Cargo.toml +1 -1
- package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
- package/contracts/workers/price-feed/Cargo.toml +1 -1
- package/contracts/workers/price-feed/src/price_feed.rs +7 -10
- package/contracts/workers/worker/src/errors.rs +4 -0
- package/contracts/workers/worker/src/tests/worker.rs +7 -6
- package/contracts/workers/worker/src/worker.rs +20 -16
- package/package.json +8 -5
- package/sdk/.turbo/turbo-build.log +1 -0
- package/sdk/.turbo/turbo-test.log +1009 -0
- package/sdk/dist/generated/bml.d.ts +65 -8
- package/sdk/dist/generated/bml.js +70 -34
- package/sdk/dist/generated/counter.d.ts +167 -42
- package/sdk/dist/generated/counter.js +86 -45
- package/sdk/dist/generated/dvn.d.ts +282 -229
- package/sdk/dist/generated/dvn.js +119 -81
- package/sdk/dist/generated/dvn_fee_lib.d.ts +142 -67
- package/sdk/dist/generated/dvn_fee_lib.js +64 -24
- package/sdk/dist/generated/endpoint.d.ts +97 -22
- package/sdk/dist/generated/endpoint.js +75 -37
- package/sdk/dist/generated/executor.d.ts +117 -85
- package/sdk/dist/generated/executor.js +102 -59
- package/sdk/dist/generated/executor_fee_lib.d.ts +162 -78
- package/sdk/dist/generated/executor_fee_lib.js +104 -57
- package/sdk/dist/generated/executor_helper.d.ts +133 -21
- package/sdk/dist/generated/executor_helper.js +99 -50
- package/sdk/dist/generated/oft_std.d.ts +233 -55
- package/sdk/dist/generated/oft_std.js +99 -54
- package/sdk/dist/generated/price_feed.d.ts +142 -67
- package/sdk/dist/generated/price_feed.js +64 -24
- package/sdk/dist/generated/sml.d.ts +113 -32
- package/sdk/dist/generated/sml.js +93 -49
- package/sdk/dist/generated/treasury.d.ts +896 -0
- package/sdk/dist/generated/treasury.js +219 -0
- package/sdk/dist/generated/uln302.d.ts +113 -32
- package/sdk/dist/generated/uln302.js +93 -49
- package/sdk/dist/generated/upgrader.d.ts +2 -2
- package/sdk/dist/generated/upgrader.js +1 -1
- package/sdk/dist/index.d.ts +2 -0
- package/sdk/dist/index.js +3 -0
- package/sdk/dist/wasm/blocked-message-lib.d.ts +1 -0
- package/sdk/dist/wasm/blocked-message-lib.js +2 -0
- package/sdk/dist/wasm/counter.d.ts +1 -0
- package/sdk/dist/wasm/counter.js +2 -0
- package/sdk/dist/wasm/dvn-fee-lib.d.ts +1 -0
- package/sdk/dist/wasm/dvn-fee-lib.js +2 -0
- package/sdk/dist/wasm/dvn.d.ts +1 -0
- package/sdk/dist/wasm/dvn.js +2 -0
- package/sdk/dist/wasm/endpoint-v2.d.ts +1 -0
- package/sdk/dist/wasm/endpoint-v2.js +2 -0
- package/sdk/dist/wasm/executor-fee-lib.d.ts +1 -0
- package/sdk/dist/wasm/executor-fee-lib.js +2 -0
- package/sdk/dist/wasm/executor-helper.d.ts +1 -0
- package/sdk/dist/wasm/executor-helper.js +2 -0
- package/sdk/dist/wasm/executor.d.ts +1 -0
- package/sdk/dist/wasm/executor.js +2 -0
- package/sdk/dist/wasm/layerzero-views.d.ts +1 -0
- package/sdk/dist/wasm/layerzero-views.js +2 -0
- package/sdk/dist/wasm/oft-std.d.ts +1 -0
- package/sdk/dist/wasm/oft-std.js +2 -0
- package/sdk/dist/wasm/price-feed.d.ts +1 -0
- package/sdk/dist/wasm/price-feed.js +2 -0
- package/sdk/dist/wasm/simple-message-lib.d.ts +1 -0
- package/sdk/dist/wasm/simple-message-lib.js +2 -0
- package/sdk/dist/wasm/treasury.d.ts +1 -0
- package/sdk/dist/wasm/treasury.js +2 -0
- package/sdk/dist/wasm/uln302.d.ts +1 -0
- package/sdk/dist/wasm/uln302.js +2 -0
- package/sdk/dist/wasm/upgrader.d.ts +1 -0
- package/sdk/dist/wasm/upgrader.js +2 -0
- package/sdk/dist/wasm.d.ts +15 -0
- package/sdk/dist/wasm.js +15 -0
- package/sdk/package.json +4 -2
- package/sdk/src/index.ts +4 -0
- package/sdk/test/counter-sml.test.ts +376 -0
- package/sdk/test/counter-uln.test.ts +493 -0
- package/sdk/test/{oft.test.ts → oft-sml.test.ts} +185 -310
- package/sdk/test/suites/constants.ts +22 -2
- package/sdk/test/suites/globalSetup.ts +450 -0
- package/sdk/test/suites/localnet.ts +23 -6
- package/sdk/test/upgrader.test.ts +7 -16
- package/sdk/test/utils.ts +558 -85
- package/sdk/vitest.config.ts +21 -0
- package/tools/ts-bindings-gen/src/main.rs +1 -0
- package/turbo.json +2 -0
- package/contracts/common-macros/src/contract_impl.rs +0 -52
- package/contracts/common-macros/src/ownable.rs +0 -41
- package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
- package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
- package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
- package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
- package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
- package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
- package/contracts/oapps/oapp-macros/src/util.rs +0 -107
- package/contracts/oapps/oft/src/constants.rs +0 -5
- package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
- package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
- package/contracts/workers/dvn/src/multisig.rs +0 -157
- package/sdk/test/index.test.ts +0 -375
- /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
|
@@ -2,102 +2,56 @@ import {
|
|
|
2
2
|
Address,
|
|
3
3
|
Asset,
|
|
4
4
|
BASE_FEE,
|
|
5
|
-
Contract,
|
|
6
5
|
Keypair,
|
|
7
|
-
nativeToScVal,
|
|
8
6
|
Operation,
|
|
9
7
|
rpc,
|
|
10
|
-
scValToNative,
|
|
11
8
|
StrKey,
|
|
12
9
|
TransactionBuilder,
|
|
13
10
|
} from '@stellar/stellar-sdk';
|
|
14
11
|
import path from 'path';
|
|
15
|
-
import {
|
|
16
|
-
import { $ } from 'zx';
|
|
12
|
+
import { beforeAll, describe, expect, inject, it } from 'vitest';
|
|
17
13
|
|
|
18
14
|
import { getFullyQualifiedRepoRootPath } from '@layerzerolabs/common-node-utils';
|
|
19
15
|
import { PacketSerializer, PacketV1Codec } from '@layerzerolabs/lz-v2-utilities';
|
|
20
16
|
|
|
21
17
|
import { Client as EndpointClient } from '../src/generated/endpoint';
|
|
22
|
-
import { Client as ExecutorClient } from '../src/generated/executor';
|
|
23
18
|
import { Client as ExecutorHelperClient } from '../src/generated/executor_helper';
|
|
24
|
-
import { Client as OFTStdClient, SendParam } from '../src/generated/oft_std';
|
|
19
|
+
import { Client as OFTStdClient, OFTMode, SendParam } from '../src/generated/oft_std';
|
|
25
20
|
import { Client as SMLClient } from '../src/generated/sml';
|
|
26
21
|
import {
|
|
27
22
|
DEFAULT_DEPLOYER,
|
|
28
23
|
EID,
|
|
29
|
-
|
|
24
|
+
EXECUTOR_ADMIN,
|
|
30
25
|
NETWORK_PASSPHRASE,
|
|
31
26
|
RPC_URL,
|
|
32
|
-
ZRO_TOKEN_ADDRESS,
|
|
33
27
|
} from './suites/constants';
|
|
34
28
|
import { deployAssetSac, deployContract } from './suites/deploy';
|
|
35
|
-
import { fundAccount
|
|
29
|
+
import { fundAccount } from './suites/localnet';
|
|
36
30
|
import { PacketSentEvent, scanPacketSentEvents } from './suites/scan';
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Build the balance call
|
|
47
|
-
const balanceOp = tokenContract.call(
|
|
48
|
-
'balance',
|
|
49
|
-
nativeToScVal(Address.fromString(accountAddress), { type: 'address' }),
|
|
50
|
-
);
|
|
31
|
+
import {
|
|
32
|
+
assertTransactionSucceeded,
|
|
33
|
+
createClient,
|
|
34
|
+
getTokenBalance,
|
|
35
|
+
signAndSendWithExecutorAuth,
|
|
36
|
+
} from './utils';
|
|
37
|
+
|
|
38
|
+
// Protocol addresses (will be injected from globalSetup in beforeAll)
|
|
39
|
+
let protocolAddresses: ReturnType<typeof inject<'protocolAddresses'>>;
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
.addOperation(balanceOp)
|
|
58
|
-
.setTimeout(30)
|
|
59
|
-
.build();
|
|
60
|
-
|
|
61
|
-
const simulated = await server.simulateTransaction(tx);
|
|
62
|
-
if (rpc.Api.isSimulationError(simulated)) {
|
|
63
|
-
throw new Error(`Balance query failed: ${JSON.stringify(simulated)}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Extract result from simulation
|
|
67
|
-
const result = (simulated as rpc.Api.SimulateTransactionSuccessResponse).result;
|
|
68
|
-
if (result?.retval) {
|
|
69
|
-
return scValToNative(result.retval) as bigint;
|
|
70
|
-
}
|
|
71
|
-
return 0n;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
$.verbose = true;
|
|
75
|
-
$.stdio = ['inherit', 'pipe', process.stderr];
|
|
76
|
-
|
|
77
|
-
// Contract addresses
|
|
78
|
-
const CONTRACT_ADDRESSES = {
|
|
79
|
-
endpointV2: '',
|
|
80
|
-
sml: '',
|
|
81
|
-
executor: '',
|
|
82
|
-
executorHelper: '',
|
|
83
|
-
oftToken: '', // The SAC for OFT token
|
|
84
|
-
lockUnlockOft: '',
|
|
85
|
-
mintBurnOft: '',
|
|
86
|
-
};
|
|
41
|
+
// OFT-specific addresses
|
|
42
|
+
let oftTokenAddress = '';
|
|
43
|
+
let lockUnlockOftAddress = '';
|
|
44
|
+
let mintBurnOftAddress = '';
|
|
87
45
|
|
|
88
46
|
// Clients
|
|
89
47
|
let endpointClient: EndpointClient;
|
|
90
48
|
let smlClient: SMLClient;
|
|
91
|
-
let executorClient: ExecutorClient;
|
|
92
49
|
let executorHelperClient: ExecutorHelperClient;
|
|
93
50
|
let lockUnlockOftClient: OFTStdClient;
|
|
94
51
|
let mintBurnOftClient: OFTStdClient;
|
|
95
52
|
|
|
96
53
|
// Test accounts
|
|
97
|
-
const EXECUTOR_ADMIN = Keypair.random();
|
|
98
54
|
const TOKEN_ISSUER = Keypair.random();
|
|
99
|
-
// Use DEFAULT_DEPLOYER as SENDER (same pattern as Counter test)
|
|
100
|
-
// The deployer has proper signing setup with the contract clients
|
|
101
55
|
|
|
102
56
|
// Recipients for each direction
|
|
103
57
|
const RECIPIENT_A = Keypair.random(); // Receives tokens in Lock/Unlock -> Mint/Burn direction
|
|
@@ -114,7 +68,7 @@ const SEND_AMOUNT = 100_0000000n; // 100 tokens in local decimals (7 decimals)
|
|
|
114
68
|
|
|
115
69
|
// NOTE: run `stellar contract build` before running the test
|
|
116
70
|
|
|
117
|
-
describe('OFT E2E Testing with SAC', async () => {
|
|
71
|
+
describe('OFT E2E Testing with SAC (SML)', async () => {
|
|
118
72
|
const repoRoot = await getFullyQualifiedRepoRootPath();
|
|
119
73
|
const wasmDir = path.join(
|
|
120
74
|
repoRoot,
|
|
@@ -126,98 +80,33 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
126
80
|
'release',
|
|
127
81
|
);
|
|
128
82
|
|
|
129
|
-
const ENDPOINT_WASM_PATH = path.join(wasmDir, 'endpoint_v2.wasm');
|
|
130
|
-
const SML_WASM_PATH = path.join(wasmDir, 'simple_message_lib.wasm');
|
|
131
|
-
const EXECUTOR_WASM_PATH = path.join(wasmDir, 'executor.wasm');
|
|
132
|
-
const EXECUTOR_HELPER_WASM_PATH = path.join(wasmDir, 'executor_helper.wasm');
|
|
133
83
|
const OFT_STD_WASM_PATH = path.join(wasmDir, 'oft_std.wasm');
|
|
134
84
|
|
|
135
85
|
beforeAll(async () => {
|
|
136
|
-
|
|
86
|
+
// Inject protocol addresses from globalSetup
|
|
87
|
+
protocolAddresses = inject('protocolAddresses');
|
|
88
|
+
|
|
89
|
+
console.log('\n📋 Protocol addresses injected from globalSetup');
|
|
90
|
+
console.log(' Endpoint:', protocolAddresses.endpointV2);
|
|
91
|
+
console.log(' SML:', protocolAddresses.sml);
|
|
92
|
+
console.log(' Executor:', protocolAddresses.executor);
|
|
93
|
+
console.log(' Executor Helper:', protocolAddresses.executorHelper);
|
|
94
|
+
|
|
95
|
+
// Create clients for protocol contracts
|
|
96
|
+
endpointClient = createClient(EndpointClient, protocolAddresses.endpointV2);
|
|
97
|
+
smlClient = createClient(SMLClient, protocolAddresses.sml);
|
|
98
|
+
executorHelperClient = createClient(ExecutorHelperClient, protocolAddresses.executorHelper);
|
|
99
|
+
|
|
137
100
|
// Fund test accounts
|
|
138
|
-
await fundAccount(EXECUTOR_ADMIN.publicKey());
|
|
139
101
|
await fundAccount(TOKEN_ISSUER.publicKey());
|
|
140
102
|
await fundAccount(RECIPIENT_A.publicKey());
|
|
141
103
|
await fundAccount(RECIPIENT_B.publicKey());
|
|
142
104
|
|
|
143
105
|
// Create the OFT asset (TOKEN_ISSUER is the issuer)
|
|
144
106
|
OFT_ASSET = new Asset(OFT_TOKEN_CODE, TOKEN_ISSUER.publicKey());
|
|
145
|
-
}, 120000); // 2 minute timeout for setup
|
|
146
|
-
|
|
147
|
-
afterAll(async () => {
|
|
148
|
-
await stopStellarLocalnet();
|
|
149
107
|
});
|
|
150
108
|
|
|
151
|
-
describe('
|
|
152
|
-
it('Deploy Endpoint', async () => {
|
|
153
|
-
endpointClient = await deployContract<EndpointClient>(
|
|
154
|
-
EndpointClient,
|
|
155
|
-
ENDPOINT_WASM_PATH,
|
|
156
|
-
{
|
|
157
|
-
eid: EID,
|
|
158
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
159
|
-
native_token: NATIVE_TOKEN_ADDRESS,
|
|
160
|
-
},
|
|
161
|
-
DEFAULT_DEPLOYER,
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
CONTRACT_ADDRESSES.endpointV2 = endpointClient.options.contractId;
|
|
165
|
-
console.log('✅ Endpoint deployed:', CONTRACT_ADDRESSES.endpointV2);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('Deploy SimpleMessageLib', async () => {
|
|
169
|
-
smlClient = await deployContract<SMLClient>(
|
|
170
|
-
SMLClient,
|
|
171
|
-
SML_WASM_PATH,
|
|
172
|
-
{
|
|
173
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
174
|
-
endpoint: CONTRACT_ADDRESSES.endpointV2,
|
|
175
|
-
fee_recipient: DEFAULT_DEPLOYER.publicKey(),
|
|
176
|
-
},
|
|
177
|
-
DEFAULT_DEPLOYER,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
CONTRACT_ADDRESSES.sml = smlClient.options.contractId;
|
|
181
|
-
console.log('✅ SimpleMessageLib deployed:', CONTRACT_ADDRESSES.sml);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('Deploy Executor Helper', async () => {
|
|
185
|
-
executorHelperClient = await deployContract<ExecutorHelperClient>(
|
|
186
|
-
ExecutorHelperClient,
|
|
187
|
-
EXECUTOR_HELPER_WASM_PATH,
|
|
188
|
-
undefined,
|
|
189
|
-
DEFAULT_DEPLOYER,
|
|
190
|
-
);
|
|
191
|
-
CONTRACT_ADDRESSES.executorHelper = executorHelperClient.options.contractId;
|
|
192
|
-
console.log('✅ Executor Helper deployed:', CONTRACT_ADDRESSES.executorHelper);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('Deploy Executor', async () => {
|
|
196
|
-
const whitelist = [
|
|
197
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'native_drop_and_execute' },
|
|
198
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'execute' },
|
|
199
|
-
{ contract: CONTRACT_ADDRESSES.executorHelper, fn_name: 'compose' },
|
|
200
|
-
];
|
|
201
|
-
|
|
202
|
-
executorClient = await deployContract<ExecutorClient>(
|
|
203
|
-
ExecutorClient,
|
|
204
|
-
EXECUTOR_WASM_PATH,
|
|
205
|
-
{
|
|
206
|
-
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
207
|
-
endpoint: CONTRACT_ADDRESSES.endpointV2,
|
|
208
|
-
whitelist,
|
|
209
|
-
admins: [EXECUTOR_ADMIN.publicKey()],
|
|
210
|
-
message_libs: [CONTRACT_ADDRESSES.sml],
|
|
211
|
-
// FIXME: Add price feed
|
|
212
|
-
price_feed: CONTRACT_ADDRESSES.endpointV2,
|
|
213
|
-
default_multiplier_bps: 10000,
|
|
214
|
-
},
|
|
215
|
-
DEFAULT_DEPLOYER,
|
|
216
|
-
);
|
|
217
|
-
CONTRACT_ADDRESSES.executor = executorClient.options.contractId;
|
|
218
|
-
console.log('✅ Executor deployed:', CONTRACT_ADDRESSES.executor);
|
|
219
|
-
});
|
|
220
|
-
|
|
109
|
+
describe('Deploy OFT Contracts', () => {
|
|
221
110
|
it('Deploy OFT Token SAC', async () => {
|
|
222
111
|
const server = new rpc.Server(RPC_URL, { allowHttp: true });
|
|
223
112
|
|
|
@@ -271,8 +160,8 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
271
160
|
console.log('✅ OFT token issued to DEFAULT_DEPLOYER');
|
|
272
161
|
|
|
273
162
|
// Step 2: Deploy the SAC for the OFT token
|
|
274
|
-
|
|
275
|
-
console.log('✅ OFT Token SAC deployed:',
|
|
163
|
+
oftTokenAddress = await deployAssetSac(OFT_ASSET);
|
|
164
|
+
console.log('✅ OFT Token SAC deployed:', oftTokenAddress);
|
|
276
165
|
});
|
|
277
166
|
|
|
278
167
|
it('Deploy Lock/Unlock OFT', async () => {
|
|
@@ -280,22 +169,22 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
280
169
|
OFTStdClient,
|
|
281
170
|
OFT_STD_WASM_PATH,
|
|
282
171
|
{
|
|
283
|
-
token:
|
|
172
|
+
token: oftTokenAddress,
|
|
284
173
|
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
285
|
-
endpoint:
|
|
174
|
+
endpoint: protocolAddresses.endpointV2,
|
|
286
175
|
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
287
176
|
shared_decimals: SHARED_DECIMALS,
|
|
288
|
-
mode:
|
|
177
|
+
mode: OFTMode.LockUnlock, // Lock/Unlock mode
|
|
289
178
|
},
|
|
290
179
|
DEFAULT_DEPLOYER,
|
|
291
180
|
);
|
|
292
181
|
|
|
293
|
-
|
|
294
|
-
console.log('✅ Lock/Unlock OFT deployed:',
|
|
182
|
+
lockUnlockOftAddress = lockUnlockOftClient.options.contractId;
|
|
183
|
+
console.log('✅ Lock/Unlock OFT deployed:', lockUnlockOftAddress);
|
|
295
184
|
|
|
296
185
|
// Verify it's in lock/unlock mode
|
|
297
186
|
const { result: mode } = await lockUnlockOftClient.mode();
|
|
298
|
-
expect(mode).toEqual(
|
|
187
|
+
expect(mode).toEqual(OFTMode.LockUnlock);
|
|
299
188
|
});
|
|
300
189
|
|
|
301
190
|
it('Deploy Mint/Burn OFT', async () => {
|
|
@@ -303,91 +192,102 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
303
192
|
OFTStdClient,
|
|
304
193
|
OFT_STD_WASM_PATH,
|
|
305
194
|
{
|
|
306
|
-
token:
|
|
195
|
+
token: oftTokenAddress,
|
|
307
196
|
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
308
|
-
endpoint:
|
|
197
|
+
endpoint: protocolAddresses.endpointV2,
|
|
309
198
|
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
310
199
|
shared_decimals: SHARED_DECIMALS,
|
|
311
|
-
mode:
|
|
200
|
+
mode: OFTMode.MintBurn, // Mint/Burn mode
|
|
312
201
|
},
|
|
313
202
|
DEFAULT_DEPLOYER,
|
|
314
203
|
);
|
|
315
204
|
|
|
316
|
-
|
|
317
|
-
console.log('✅ Mint/Burn OFT deployed:',
|
|
205
|
+
mintBurnOftAddress = mintBurnOftClient.options.contractId;
|
|
206
|
+
console.log('✅ Mint/Burn OFT deployed:', mintBurnOftAddress);
|
|
318
207
|
|
|
319
208
|
// Verify it's in mint/burn mode
|
|
320
209
|
const { result: mode } = await mintBurnOftClient.mode();
|
|
321
|
-
expect(mode).toEqual(
|
|
210
|
+
expect(mode).toEqual(OFTMode.MintBurn);
|
|
322
211
|
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe('Wire OFT Contracts to use SML', () => {
|
|
215
|
+
it('Set Lock/Unlock OFT Send Library to SML', async () => {
|
|
216
|
+
const assembledTx = await endpointClient.set_send_library({
|
|
217
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
218
|
+
sender: lockUnlockOftAddress,
|
|
219
|
+
dst_eid: EID,
|
|
220
|
+
new_lib: protocolAddresses.sml,
|
|
221
|
+
});
|
|
222
|
+
await assembledTx.signAndSend();
|
|
323
223
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
console.log('
|
|
331
|
-
console.log(' Lock/Unlock OFT:', CONTRACT_ADDRESSES.lockUnlockOft);
|
|
332
|
-
console.log(' Mint/Burn OFT:', CONTRACT_ADDRESSES.mintBurnOft);
|
|
224
|
+
const { result: sendLib } = await endpointClient.get_send_library({
|
|
225
|
+
sender: lockUnlockOftAddress,
|
|
226
|
+
dst_eid: EID,
|
|
227
|
+
});
|
|
228
|
+
expect(sendLib.lib).toBe(protocolAddresses.sml);
|
|
229
|
+
expect(sendLib.is_default).toBe(false);
|
|
230
|
+
console.log('✅ Lock/Unlock OFT send library set to SML');
|
|
333
231
|
});
|
|
334
|
-
});
|
|
335
232
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
233
|
+
it('Set Lock/Unlock OFT Receive Library to SML', async () => {
|
|
234
|
+
const assembledTx = await endpointClient.set_receive_library({
|
|
235
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
236
|
+
receiver: lockUnlockOftAddress,
|
|
237
|
+
src_eid: EID,
|
|
238
|
+
new_lib: protocolAddresses.sml,
|
|
239
|
+
grace_period: 0n,
|
|
340
240
|
});
|
|
341
241
|
await assembledTx.signAndSend();
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
242
|
+
|
|
243
|
+
const { result: receiveLib } = await endpointClient.get_receive_library({
|
|
244
|
+
receiver: lockUnlockOftAddress,
|
|
245
|
+
src_eid: EID,
|
|
345
246
|
});
|
|
346
|
-
expect(
|
|
347
|
-
expect(
|
|
348
|
-
console.log('✅
|
|
247
|
+
expect(receiveLib.lib).toBe(protocolAddresses.sml);
|
|
248
|
+
expect(receiveLib.is_default).toBe(false);
|
|
249
|
+
console.log('✅ Lock/Unlock OFT receive library set to SML');
|
|
349
250
|
});
|
|
350
251
|
|
|
351
|
-
it('Set
|
|
352
|
-
const assembledTx = await endpointClient.
|
|
252
|
+
it('Set Mint/Burn OFT Send Library to SML', async () => {
|
|
253
|
+
const assembledTx = await endpointClient.set_send_library({
|
|
254
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
255
|
+
sender: mintBurnOftAddress,
|
|
353
256
|
dst_eid: EID,
|
|
354
|
-
new_lib:
|
|
257
|
+
new_lib: protocolAddresses.sml,
|
|
355
258
|
});
|
|
356
259
|
await assembledTx.signAndSend();
|
|
357
|
-
|
|
260
|
+
|
|
261
|
+
const { result: sendLib } = await endpointClient.get_send_library({
|
|
262
|
+
sender: mintBurnOftAddress,
|
|
358
263
|
dst_eid: EID,
|
|
359
264
|
});
|
|
360
|
-
expect(
|
|
361
|
-
|
|
265
|
+
expect(sendLib.lib).toBe(protocolAddresses.sml);
|
|
266
|
+
expect(sendLib.is_default).toBe(false);
|
|
267
|
+
console.log('✅ Mint/Burn OFT send library set to SML');
|
|
362
268
|
});
|
|
363
269
|
|
|
364
|
-
it('Set
|
|
365
|
-
const assembledTx = await endpointClient.
|
|
270
|
+
it('Set Mint/Burn OFT Receive Library to SML', async () => {
|
|
271
|
+
const assembledTx = await endpointClient.set_receive_library({
|
|
272
|
+
caller: DEFAULT_DEPLOYER.publicKey(),
|
|
273
|
+
receiver: mintBurnOftAddress,
|
|
366
274
|
src_eid: EID,
|
|
367
|
-
new_lib:
|
|
275
|
+
new_lib: protocolAddresses.sml,
|
|
368
276
|
grace_period: 0n,
|
|
369
277
|
});
|
|
370
278
|
await assembledTx.signAndSend();
|
|
371
|
-
const { result: defaultReceiveLib } = await endpointClient.default_receive_library({
|
|
372
|
-
src_eid: EID,
|
|
373
|
-
});
|
|
374
|
-
expect(defaultReceiveLib).toBe(CONTRACT_ADDRESSES.sml);
|
|
375
|
-
console.log('✅ Default receive library set');
|
|
376
|
-
});
|
|
377
279
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
280
|
+
const { result: receiveLib } = await endpointClient.get_receive_library({
|
|
281
|
+
receiver: mintBurnOftAddress,
|
|
282
|
+
src_eid: EID,
|
|
381
283
|
});
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
expect(newZroToken).toBe(ZRO_TOKEN_ADDRESS);
|
|
386
|
-
console.log('✅ ZRO token set:', ZRO_TOKEN_ADDRESS);
|
|
284
|
+
expect(receiveLib.lib).toBe(protocolAddresses.sml);
|
|
285
|
+
expect(receiveLib.is_default).toBe(false);
|
|
286
|
+
console.log('✅ Mint/Burn OFT receive library set to SML');
|
|
387
287
|
});
|
|
388
288
|
|
|
389
289
|
it('Set Lock/Unlock OFT Peer (to Mint/Burn OFT)', async () => {
|
|
390
|
-
const mintBurnPeerBytes = StrKey.decodeContract(
|
|
290
|
+
const mintBurnPeerBytes = StrKey.decodeContract(mintBurnOftAddress);
|
|
391
291
|
|
|
392
292
|
const assembledTx = await lockUnlockOftClient.set_peer({
|
|
393
293
|
eid: EID,
|
|
@@ -403,7 +303,7 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
403
303
|
});
|
|
404
304
|
|
|
405
305
|
it('Set Mint/Burn OFT Peer (to Lock/Unlock OFT)', async () => {
|
|
406
|
-
const lockUnlockPeerBytes = StrKey.decodeContract(
|
|
306
|
+
const lockUnlockPeerBytes = StrKey.decodeContract(lockUnlockOftAddress);
|
|
407
307
|
|
|
408
308
|
const assembledTx = await mintBurnOftClient.set_peer({
|
|
409
309
|
eid: EID,
|
|
@@ -420,26 +320,19 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
420
320
|
|
|
421
321
|
it('Set SAC Admin to Mint/Burn OFT (for minting)', async () => {
|
|
422
322
|
// The Mint/Burn OFT needs to be the admin of the SAC to mint tokens
|
|
423
|
-
// Use the SAC's set_admin function
|
|
424
323
|
const server = new rpc.Server(RPC_URL, { allowHttp: true });
|
|
425
324
|
|
|
426
|
-
// Build set_admin transaction
|
|
427
|
-
// SAC's set_admin function requires the current admin (TOKEN_ISSUER) to sign
|
|
428
325
|
const account = await server.getAccount(TOKEN_ISSUER.publicKey());
|
|
429
326
|
|
|
430
|
-
// Build the invokeContract operation for SAC's set_admin
|
|
431
327
|
const setAdminTx = new TransactionBuilder(account, {
|
|
432
328
|
fee: BASE_FEE,
|
|
433
329
|
networkPassphrase: NETWORK_PASSPHRASE,
|
|
434
330
|
})
|
|
435
331
|
.addOperation(
|
|
436
332
|
Operation.invokeContractFunction({
|
|
437
|
-
contract:
|
|
333
|
+
contract: oftTokenAddress,
|
|
438
334
|
function: 'set_admin',
|
|
439
|
-
args: [
|
|
440
|
-
// new_admin: Address
|
|
441
|
-
Address.fromString(CONTRACT_ADDRESSES.mintBurnOft).toScVal(),
|
|
442
|
-
],
|
|
335
|
+
args: [Address.fromString(mintBurnOftAddress).toScVal()],
|
|
443
336
|
}),
|
|
444
337
|
)
|
|
445
338
|
.setTimeout(30)
|
|
@@ -472,39 +365,35 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
472
365
|
let message: Buffer;
|
|
473
366
|
|
|
474
367
|
it('Verify initial balances', async () => {
|
|
475
|
-
|
|
476
|
-
const senderBalance = await getSacBalance(
|
|
477
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
368
|
+
const senderBalance = await getTokenBalance(
|
|
478
369
|
DEFAULT_DEPLOYER.publicKey(),
|
|
370
|
+
oftTokenAddress,
|
|
479
371
|
);
|
|
480
372
|
console.log('📊 Initial Balances:');
|
|
481
373
|
console.log(` - Sender (DEFAULT_DEPLOYER): ${senderBalance} (expected: 10000000000)`);
|
|
482
374
|
|
|
483
|
-
|
|
484
|
-
const recipientABalance = await getSacBalance(
|
|
485
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
375
|
+
const recipientABalance = await getTokenBalance(
|
|
486
376
|
RECIPIENT_A.publicKey(),
|
|
377
|
+
oftTokenAddress,
|
|
487
378
|
);
|
|
488
379
|
console.log(` - RECIPIENT_A: ${recipientABalance} (expected: 0)`);
|
|
489
380
|
|
|
490
|
-
expect(senderBalance).toBe(10000000000n);
|
|
381
|
+
expect(senderBalance).toBe(10000000000n);
|
|
491
382
|
expect(recipientABalance).toBe(0n);
|
|
492
383
|
});
|
|
493
384
|
|
|
494
385
|
it('Quote OFT send', async () => {
|
|
495
|
-
// Build SendParam - send to RECIPIENT_A
|
|
496
386
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_A.publicKey());
|
|
497
387
|
const sendParam: SendParam = {
|
|
498
388
|
dst_eid: EID,
|
|
499
389
|
to: Buffer.from(receiverBytes),
|
|
500
390
|
amount_ld: SEND_AMOUNT,
|
|
501
|
-
min_amount_ld: SEND_AMOUNT,
|
|
391
|
+
min_amount_ld: SEND_AMOUNT,
|
|
502
392
|
extra_options: Buffer.from([]),
|
|
503
393
|
compose_msg: Buffer.from([]),
|
|
504
394
|
oft_cmd: Buffer.from([]),
|
|
505
395
|
};
|
|
506
396
|
|
|
507
|
-
// Quote OFT
|
|
508
397
|
const { result: quoteResult } = await lockUnlockOftClient.quote_oft({
|
|
509
398
|
send_param: sendParam,
|
|
510
399
|
});
|
|
@@ -518,7 +407,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
518
407
|
});
|
|
519
408
|
|
|
520
409
|
it('Send tokens (Lock/Unlock -> Mint/Burn)', async () => {
|
|
521
|
-
// Build SendParam - send to RECIPIENT_A
|
|
522
410
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_A.publicKey());
|
|
523
411
|
const sendParam: SendParam = {
|
|
524
412
|
dst_eid: EID,
|
|
@@ -530,7 +418,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
530
418
|
oft_cmd: Buffer.from([]),
|
|
531
419
|
};
|
|
532
420
|
|
|
533
|
-
// Quote send fee (pay in ZRO like Counter test does)
|
|
534
421
|
const { result: fee } = await lockUnlockOftClient.quote_send({
|
|
535
422
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
536
423
|
send_param: sendParam,
|
|
@@ -538,7 +425,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
538
425
|
});
|
|
539
426
|
console.log('📊 Messaging Fee:', fee);
|
|
540
427
|
|
|
541
|
-
// Send tokens
|
|
542
428
|
const assembledTx = await lockUnlockOftClient.send({
|
|
543
429
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
544
430
|
send_param: sendParam,
|
|
@@ -546,22 +432,22 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
546
432
|
refund_address: DEFAULT_DEPLOYER.publicKey(),
|
|
547
433
|
});
|
|
548
434
|
|
|
549
|
-
// Sign and send
|
|
550
435
|
const sentTx = await assembledTx.signAndSend();
|
|
551
436
|
|
|
552
|
-
// Extract ledger number
|
|
553
437
|
const txResponse = sentTx.getTransactionResponse;
|
|
554
438
|
if (txResponse && 'ledger' in txResponse) {
|
|
555
439
|
sendLedger = txResponse.ledger;
|
|
556
440
|
}
|
|
557
441
|
|
|
558
|
-
|
|
442
|
+
if (txResponse) {
|
|
443
|
+
assertTransactionSucceeded(txResponse, 'OFT Send');
|
|
444
|
+
}
|
|
559
445
|
console.log('✅ Tokens sent, ledger:', sendLedger);
|
|
560
446
|
});
|
|
561
447
|
|
|
562
448
|
it('Scan PacketSent events', async () => {
|
|
563
449
|
const packetSentEvents = await scanPacketSentEvents(
|
|
564
|
-
|
|
450
|
+
protocolAddresses.endpointV2,
|
|
565
451
|
sendLedger,
|
|
566
452
|
);
|
|
567
453
|
expect(packetSentEvents.length).toBeGreaterThan(0);
|
|
@@ -586,59 +472,56 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
586
472
|
});
|
|
587
473
|
|
|
588
474
|
it('Receive tokens (mint on Mint/Burn OFT)', async () => {
|
|
589
|
-
const lockUnlockPeerBytes = StrKey.decodeContract(
|
|
475
|
+
const lockUnlockPeerBytes = StrKey.decodeContract(lockUnlockOftAddress);
|
|
590
476
|
const origin = {
|
|
591
477
|
nonce: 1n,
|
|
592
478
|
sender: Buffer.from(lockUnlockPeerBytes),
|
|
593
479
|
src_eid: EID,
|
|
594
480
|
};
|
|
595
481
|
|
|
596
|
-
const assembledTx = await executorHelperClient.execute(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
482
|
+
const assembledTx = await executorHelperClient.execute(
|
|
483
|
+
{
|
|
484
|
+
executor: protocolAddresses.executor,
|
|
485
|
+
params: {
|
|
486
|
+
extra_data: Buffer.from([]),
|
|
487
|
+
gas_limit: 0n,
|
|
488
|
+
guid,
|
|
489
|
+
message,
|
|
490
|
+
origin,
|
|
491
|
+
receiver: mintBurnOftAddress,
|
|
492
|
+
value: 0n,
|
|
493
|
+
},
|
|
494
|
+
value_payer: EXECUTOR_ADMIN.publicKey(),
|
|
606
495
|
},
|
|
607
|
-
|
|
608
|
-
|
|
496
|
+
{
|
|
497
|
+
simulate: false,
|
|
498
|
+
},
|
|
499
|
+
);
|
|
609
500
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
CONTRACT_ADDRESSES.executor,
|
|
501
|
+
const txResult = await signAndSendWithExecutorAuth(
|
|
502
|
+
protocolAddresses.executor,
|
|
613
503
|
EXECUTOR_ADMIN,
|
|
614
504
|
assembledTx,
|
|
615
505
|
NETWORK_PASSPHRASE,
|
|
616
506
|
);
|
|
617
507
|
|
|
618
|
-
|
|
619
|
-
const sentTx = await assembledTx.signAndSend();
|
|
620
|
-
assertTransactionsSucceeded(sentTx, 'LzReceive (Mint)');
|
|
508
|
+
assertTransactionSucceeded(txResult, 'LzReceive (Mint)');
|
|
621
509
|
|
|
622
510
|
console.log('✅ Tokens received and minted on Mint/Burn OFT');
|
|
623
511
|
});
|
|
624
512
|
|
|
625
513
|
it('Verify balances after forward send', async () => {
|
|
626
|
-
|
|
627
|
-
// - Sender (DEFAULT_DEPLOYER): 1000 - 100 = 900 tokens
|
|
628
|
-
// - Lock/Unlock OFT contract: holds 100 locked tokens
|
|
629
|
-
// - RECIPIENT_A: received 100 minted tokens
|
|
630
|
-
|
|
631
|
-
const senderBalance = await getSacBalance(
|
|
632
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
514
|
+
const senderBalance = await getTokenBalance(
|
|
633
515
|
DEFAULT_DEPLOYER.publicKey(),
|
|
516
|
+
oftTokenAddress,
|
|
634
517
|
);
|
|
635
|
-
const lockUnlockOftBalance = await
|
|
636
|
-
|
|
637
|
-
|
|
518
|
+
const lockUnlockOftBalance = await getTokenBalance(
|
|
519
|
+
lockUnlockOftAddress,
|
|
520
|
+
oftTokenAddress,
|
|
638
521
|
);
|
|
639
|
-
const recipientABalance = await
|
|
640
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
522
|
+
const recipientABalance = await getTokenBalance(
|
|
641
523
|
RECIPIENT_A.publicKey(),
|
|
524
|
+
oftTokenAddress,
|
|
642
525
|
);
|
|
643
526
|
|
|
644
527
|
console.log('📊 Balances after forward send:');
|
|
@@ -648,9 +531,9 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
648
531
|
);
|
|
649
532
|
console.log(` - RECIPIENT_A (minted): ${recipientABalance} (expected: 1000000000)`);
|
|
650
533
|
|
|
651
|
-
expect(senderBalance).toBe(9000000000n);
|
|
652
|
-
expect(lockUnlockOftBalance).toBe(1000000000n);
|
|
653
|
-
expect(recipientABalance).toBe(1000000000n);
|
|
534
|
+
expect(senderBalance).toBe(9000000000n);
|
|
535
|
+
expect(lockUnlockOftBalance).toBe(1000000000n);
|
|
536
|
+
expect(recipientABalance).toBe(1000000000n);
|
|
654
537
|
});
|
|
655
538
|
});
|
|
656
539
|
|
|
@@ -659,10 +542,9 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
659
542
|
let packetSentEvent: PacketSentEvent;
|
|
660
543
|
let guid: Buffer;
|
|
661
544
|
let message: Buffer;
|
|
662
|
-
const REVERSE_SEND_AMOUNT = 50_0000000n;
|
|
545
|
+
const REVERSE_SEND_AMOUNT = 50_0000000n;
|
|
663
546
|
|
|
664
547
|
it('Quote OFT send (reverse)', async () => {
|
|
665
|
-
// Send to RECIPIENT_B
|
|
666
548
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_B.publicKey());
|
|
667
549
|
const sendParam: SendParam = {
|
|
668
550
|
dst_eid: EID,
|
|
@@ -687,7 +569,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
687
569
|
});
|
|
688
570
|
|
|
689
571
|
it('Send tokens (Mint/Burn -> Lock/Unlock)', async () => {
|
|
690
|
-
// DEFAULT_DEPLOYER sends via Mint/Burn OFT to RECIPIENT_B
|
|
691
572
|
const receiverBytes = StrKey.decodeEd25519PublicKey(RECIPIENT_B.publicKey());
|
|
692
573
|
const sendParam: SendParam = {
|
|
693
574
|
dst_eid: EID,
|
|
@@ -699,7 +580,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
699
580
|
oft_cmd: Buffer.from([]),
|
|
700
581
|
};
|
|
701
582
|
|
|
702
|
-
// Quote send fee (pay in ZRO like Counter test does)
|
|
703
583
|
const { result: fee } = await mintBurnOftClient.quote_send({
|
|
704
584
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
705
585
|
send_param: sendParam,
|
|
@@ -707,7 +587,6 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
707
587
|
});
|
|
708
588
|
console.log('📊 Reverse Messaging Fee:', fee);
|
|
709
589
|
|
|
710
|
-
// Send tokens
|
|
711
590
|
const assembledTx = await mintBurnOftClient.send({
|
|
712
591
|
sender: DEFAULT_DEPLOYER.publicKey(),
|
|
713
592
|
send_param: sendParam,
|
|
@@ -715,22 +594,22 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
715
594
|
refund_address: DEFAULT_DEPLOYER.publicKey(),
|
|
716
595
|
});
|
|
717
596
|
|
|
718
|
-
// Sign and send
|
|
719
597
|
const sentTx = await assembledTx.signAndSend();
|
|
720
598
|
|
|
721
|
-
// Extract ledger number
|
|
722
599
|
const txResponse = sentTx.getTransactionResponse;
|
|
723
600
|
if (txResponse && 'ledger' in txResponse) {
|
|
724
601
|
sendLedger = txResponse.ledger;
|
|
725
602
|
}
|
|
726
603
|
|
|
727
|
-
|
|
604
|
+
if (txResponse) {
|
|
605
|
+
assertTransactionSucceeded(txResponse, 'OFT Reverse Send');
|
|
606
|
+
}
|
|
728
607
|
console.log('✅ Tokens sent (reverse), ledger:', sendLedger);
|
|
729
608
|
});
|
|
730
609
|
|
|
731
610
|
it('Scan PacketSent events (reverse)', async () => {
|
|
732
611
|
const packetSentEvents = await scanPacketSentEvents(
|
|
733
|
-
|
|
612
|
+
protocolAddresses.endpointV2,
|
|
734
613
|
sendLedger,
|
|
735
614
|
);
|
|
736
615
|
expect(packetSentEvents.length).toBeGreaterThan(0);
|
|
@@ -757,64 +636,60 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
757
636
|
});
|
|
758
637
|
|
|
759
638
|
it('Receive tokens (unlock on Lock/Unlock OFT)', async () => {
|
|
760
|
-
const mintBurnPeerBytes = StrKey.decodeContract(
|
|
639
|
+
const mintBurnPeerBytes = StrKey.decodeContract(mintBurnOftAddress);
|
|
761
640
|
const origin = {
|
|
762
641
|
nonce: 1n,
|
|
763
642
|
sender: Buffer.from(mintBurnPeerBytes),
|
|
764
643
|
src_eid: EID,
|
|
765
644
|
};
|
|
766
645
|
|
|
767
|
-
const assembledTx = await executorHelperClient.execute(
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
646
|
+
const assembledTx = await executorHelperClient.execute(
|
|
647
|
+
{
|
|
648
|
+
executor: protocolAddresses.executor,
|
|
649
|
+
params: {
|
|
650
|
+
extra_data: Buffer.from([]),
|
|
651
|
+
gas_limit: 0n,
|
|
652
|
+
guid,
|
|
653
|
+
message,
|
|
654
|
+
origin,
|
|
655
|
+
receiver: lockUnlockOftAddress,
|
|
656
|
+
value: 0n,
|
|
657
|
+
},
|
|
658
|
+
value_payer: EXECUTOR_ADMIN.publicKey(),
|
|
777
659
|
},
|
|
778
|
-
|
|
779
|
-
|
|
660
|
+
{
|
|
661
|
+
simulate: false,
|
|
662
|
+
},
|
|
663
|
+
);
|
|
780
664
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
CONTRACT_ADDRESSES.executor,
|
|
665
|
+
const txResult = await signAndSendWithExecutorAuth(
|
|
666
|
+
protocolAddresses.executor,
|
|
784
667
|
EXECUTOR_ADMIN,
|
|
785
668
|
assembledTx,
|
|
786
669
|
NETWORK_PASSPHRASE,
|
|
787
670
|
);
|
|
788
671
|
|
|
789
|
-
|
|
790
|
-
const sentTx = await assembledTx.signAndSend();
|
|
791
|
-
assertTransactionsSucceeded(sentTx, 'LzReceive (Unlock)');
|
|
672
|
+
assertTransactionSucceeded(txResult, 'LzReceive (Unlock)');
|
|
792
673
|
|
|
793
674
|
console.log('✅ Tokens received and unlocked on Lock/Unlock OFT');
|
|
794
675
|
});
|
|
795
676
|
|
|
796
677
|
it('Verify final balances', async () => {
|
|
797
|
-
|
|
798
|
-
// - DEFAULT_DEPLOYER: started with 1000, sent 100 (locked), sent 50 (burned) = 850
|
|
799
|
-
// - Lock/Unlock OFT: locked 100, unlocked 50 = 50 held
|
|
800
|
-
// - RECIPIENT_A: received 100 (minted)
|
|
801
|
-
// - RECIPIENT_B: received 50 (unlocked)
|
|
802
|
-
|
|
803
|
-
const senderBalance = await getSacBalance(
|
|
804
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
678
|
+
const senderBalance = await getTokenBalance(
|
|
805
679
|
DEFAULT_DEPLOYER.publicKey(),
|
|
680
|
+
oftTokenAddress,
|
|
806
681
|
);
|
|
807
|
-
const lockUnlockOftBalance = await
|
|
808
|
-
|
|
809
|
-
|
|
682
|
+
const lockUnlockOftBalance = await getTokenBalance(
|
|
683
|
+
lockUnlockOftAddress,
|
|
684
|
+
oftTokenAddress,
|
|
810
685
|
);
|
|
811
|
-
const recipientABalance = await
|
|
812
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
686
|
+
const recipientABalance = await getTokenBalance(
|
|
813
687
|
RECIPIENT_A.publicKey(),
|
|
688
|
+
oftTokenAddress,
|
|
814
689
|
);
|
|
815
|
-
const recipientBBalance = await
|
|
816
|
-
CONTRACT_ADDRESSES.oftToken,
|
|
690
|
+
const recipientBBalance = await getTokenBalance(
|
|
817
691
|
RECIPIENT_B.publicKey(),
|
|
692
|
+
oftTokenAddress,
|
|
818
693
|
);
|
|
819
694
|
|
|
820
695
|
console.log('\n📊 Final Balance Summary:');
|
|
@@ -825,10 +700,10 @@ describe('OFT E2E Testing with SAC', async () => {
|
|
|
825
700
|
console.log(` - RECIPIENT_A (minted): ${recipientABalance} (expected: 1000000000)`);
|
|
826
701
|
console.log(` - RECIPIENT_B (unlocked): ${recipientBBalance} (expected: 500000000)`);
|
|
827
702
|
|
|
828
|
-
expect(senderBalance).toBe(8500000000n);
|
|
829
|
-
expect(lockUnlockOftBalance).toBe(500000000n);
|
|
830
|
-
expect(recipientABalance).toBe(1000000000n);
|
|
831
|
-
expect(recipientBBalance).toBe(500000000n);
|
|
703
|
+
expect(senderBalance).toBe(8500000000n);
|
|
704
|
+
expect(lockUnlockOftBalance).toBe(500000000n);
|
|
705
|
+
expect(recipientABalance).toBe(1000000000n);
|
|
706
|
+
expect(recipientBBalance).toBe(500000000n);
|
|
832
707
|
|
|
833
708
|
console.log('✅ OFT E2E test completed successfully!');
|
|
834
709
|
});
|