@layerzerolabs/lz-v2-stellar-sdk 0.2.13 → 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 +1 -0
- package/.turbo/turbo-test.log +1009 -0
- package/dist/generated/bml.d.ts +104 -37
- package/dist/generated/bml.js +83 -42
- package/dist/generated/counter.d.ts +334 -175
- package/dist/generated/counter.js +109 -63
- package/dist/generated/dvn.d.ts +1985 -0
- package/dist/generated/dvn.js +326 -0
- package/dist/generated/dvn_fee_lib.d.ts +690 -0
- package/dist/generated/dvn_fee_lib.js +163 -0
- package/dist/generated/endpoint.d.ts +155 -46
- package/dist/generated/endpoint.js +93 -50
- package/dist/generated/executor.d.ts +1841 -0
- package/dist/generated/executor.js +312 -0
- package/dist/generated/executor_fee_lib.d.ts +1083 -0
- package/dist/generated/executor_fee_lib.js +255 -0
- package/dist/generated/executor_helper.d.ts +981 -0
- package/dist/generated/executor_helper.js +236 -0
- package/dist/generated/oft_std.d.ts +1722 -0
- package/dist/generated/oft_std.js +316 -0
- package/dist/generated/price_feed.d.ts +1077 -0
- package/dist/generated/price_feed.js +210 -0
- package/dist/generated/sml.d.ts +171 -56
- package/dist/generated/sml.js +111 -62
- package/dist/generated/treasury.d.ts +896 -0
- package/dist/generated/treasury.js +219 -0
- package/dist/generated/uln302.d.ts +175 -75
- package/dist/generated/uln302.js +126 -82
- package/dist/generated/upgrader.d.ts +70 -0
- package/dist/generated/upgrader.js +19 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +14 -0
- package/dist/wasm/blocked-message-lib.d.ts +1 -0
- package/dist/wasm/blocked-message-lib.js +2 -0
- package/dist/wasm/counter.d.ts +1 -0
- package/dist/wasm/counter.js +2 -0
- package/dist/wasm/dvn-fee-lib.d.ts +1 -0
- package/dist/wasm/dvn-fee-lib.js +2 -0
- package/dist/wasm/dvn.d.ts +1 -0
- package/dist/wasm/dvn.js +2 -0
- package/dist/wasm/endpoint-v2.d.ts +1 -0
- package/dist/wasm/endpoint-v2.js +2 -0
- package/dist/wasm/executor-fee-lib.d.ts +1 -0
- package/dist/wasm/executor-fee-lib.js +2 -0
- package/dist/wasm/executor-helper.d.ts +1 -0
- package/dist/wasm/executor-helper.js +2 -0
- package/dist/wasm/executor.d.ts +1 -0
- package/dist/wasm/executor.js +2 -0
- package/dist/wasm/layerzero-views.d.ts +1 -0
- package/dist/wasm/layerzero-views.js +2 -0
- package/dist/wasm/oft-std.d.ts +1 -0
- package/dist/wasm/oft-std.js +2 -0
- package/dist/wasm/price-feed.d.ts +1 -0
- package/dist/wasm/price-feed.js +2 -0
- package/dist/wasm/simple-message-lib.d.ts +1 -0
- package/dist/wasm/simple-message-lib.js +2 -0
- package/dist/wasm/treasury.d.ts +1 -0
- package/dist/wasm/treasury.js +2 -0
- package/dist/wasm/uln302.d.ts +1 -0
- package/dist/wasm/uln302.js +2 -0
- package/dist/wasm/upgrader.d.ts +1 -0
- package/dist/wasm/upgrader.js +2 -0
- package/dist/wasm.d.ts +15 -0
- package/dist/wasm.js +15 -0
- package/package.json +12 -9
- package/src/generated/bml.ts +117 -66
- package/src/generated/counter.ts +338 -191
- package/src/generated/dvn.ts +2036 -0
- package/src/generated/dvn_fee_lib.ts +693 -0
- package/src/generated/endpoint.ts +177 -80
- package/src/generated/executor.ts +228 -127
- package/src/generated/executor_fee_lib.ts +1072 -0
- package/src/generated/executor_helper.ts +163 -57
- package/src/generated/oft_std.ts +800 -246
- package/src/generated/price_feed.ts +1108 -0
- package/src/generated/sml.ts +194 -91
- package/src/generated/treasury.ts +943 -0
- package/src/generated/uln302.ts +211 -113
- package/src/generated/upgrader.ts +102 -0
- package/src/index.ts +17 -0
- package/src/wasm/blocked-message-lib.ts +2 -0
- package/src/wasm/counter.ts +2 -0
- package/src/wasm/dvn-fee-lib.ts +2 -0
- package/src/wasm/dvn.ts +2 -0
- package/src/wasm/endpoint-v2.ts +2 -0
- package/src/wasm/executor-fee-lib.ts +2 -0
- package/src/wasm/executor-helper.ts +2 -0
- package/src/wasm/executor.ts +2 -0
- package/src/wasm/layerzero-views.ts +2 -0
- package/src/wasm/oft-std.ts +2 -0
- package/src/wasm/price-feed.ts +2 -0
- package/src/wasm/simple-message-lib.ts +2 -0
- package/src/wasm/treasury.ts +2 -0
- package/src/wasm/uln302.ts +2 -0
- package/src/wasm/upgrader.ts +2 -0
- package/src/wasm.ts +15 -0
- package/test/counter-sml.test.ts +376 -0
- package/test/counter-uln.test.ts +493 -0
- package/test/{oft.test.ts → oft-sml.test.ts} +187 -323
- package/test/suites/constants.ts +22 -2
- package/test/suites/dummyContractClient.ts +169 -0
- package/test/suites/globalSetup.ts +450 -0
- package/test/suites/localnet.ts +23 -6
- package/test/upgrader.test.ts +300 -0
- package/test/utils.ts +558 -85
- package/vitest.config.ts +21 -0
- package/test/index.test.ts +0 -376
package/test/suites/constants.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Asset, Keypair, Networks } from '@stellar/stellar-sdk';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { Secp256k1KeyPair } from '../utils';
|
|
4
|
+
|
|
5
|
+
const CORE_URL = 'http://localhost:8086';
|
|
4
6
|
export const FRIENDBOT_URL = `${CORE_URL}/friendbot`;
|
|
5
7
|
export const RPC_URL = `${CORE_URL}/rpc`;
|
|
6
8
|
export const NETWORK_PASSPHRASE = Networks.STANDALONE;
|
|
@@ -10,8 +12,26 @@ export const DEFAULT_DEPLOYER = Keypair.fromSecret(
|
|
|
10
12
|
export const ZRO_DISTRIBUTOR = Keypair.fromSecret(
|
|
11
13
|
'SB6QAFXFRR2MXYHW4RRZ23JDGKHDCYCT5YTQEGG3WNT5VKZADJQFVNWG',
|
|
12
14
|
);
|
|
13
|
-
|
|
15
|
+
// Use deterministic keypair for EXECUTOR_ADMIN to ensure consistency between globalSetup and test files
|
|
16
|
+
// (globalSetup runs in a separate process, so Keypair.random() would generate different keys)
|
|
17
|
+
export const EXECUTOR_ADMIN = Keypair.fromSecret(
|
|
18
|
+
'SACWJCNRT2AYRPBWW7IBRNI765EMZSWPXXAAHYN57UFQNOXMGET7HM5K',
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// DVN secp256k1 signer for multisig (deterministic key for testing)
|
|
22
|
+
// Private key is keccak256("dvn_test_signer") truncated to 32 bytes
|
|
23
|
+
export const DVN_SIGNER = new Secp256k1KeyPair(
|
|
24
|
+
'0x8d3f8d5d8f1c7e2a5b4c3d6e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a',
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// DVN configuration
|
|
28
|
+
export const DVN_VID = 1;
|
|
29
|
+
|
|
30
|
+
export const EID = 30400;
|
|
14
31
|
export const NATIVE_TOKEN_ADDRESS = Asset.native().contractId(NETWORK_PASSPHRASE);
|
|
15
32
|
export const ZRO_ASSET = new Asset('ZRO', DEFAULT_DEPLOYER.publicKey());
|
|
16
33
|
export const ZRO_TOKEN_ADDRESS = ZRO_ASSET.contractId(NETWORK_PASSPHRASE);
|
|
17
34
|
export const MSG_TYPE_VANILLA = 1;
|
|
35
|
+
export const MSG_TYPE_COMPOSED = 2;
|
|
36
|
+
export const MSG_TYPE_ABA = 3;
|
|
37
|
+
export const MSG_TYPE_COMPOSED_ABA = 4;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Option, u32 } from '@stellar/stellar-sdk/contract';
|
|
2
|
+
import {
|
|
3
|
+
AssembledTransaction,
|
|
4
|
+
Client as ContractClient,
|
|
5
|
+
ClientOptions as ContractClientOptions,
|
|
6
|
+
MethodOptions,
|
|
7
|
+
Spec as ContractSpec,
|
|
8
|
+
} from '@stellar/stellar-sdk/contract';
|
|
9
|
+
import { Buffer } from 'buffer';
|
|
10
|
+
export * from '@stellar/stellar-sdk';
|
|
11
|
+
export * as contract from '@stellar/stellar-sdk/contract';
|
|
12
|
+
export * as rpc from '@stellar/stellar-sdk/rpc';
|
|
13
|
+
|
|
14
|
+
if (typeof window !== 'undefined') {
|
|
15
|
+
//@ts-ignore Buffer exists
|
|
16
|
+
window.Buffer = window.Buffer || Buffer;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const BufferReaderError = {
|
|
20
|
+
1000: { message: 'InvalidLength' },
|
|
21
|
+
1001: { message: 'InvalidAddressPayload' },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const BufferWriterError = {
|
|
25
|
+
1100: { message: 'InvalidAddressPayload' },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const TtlError = {
|
|
29
|
+
1200: { message: 'InvalidTtlConfig' },
|
|
30
|
+
1201: { message: 'TtlConfigFrozen' },
|
|
31
|
+
1202: { message: 'TtlConfigAlreadyFrozen' },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const OwnableError = {
|
|
35
|
+
1300: { message: 'OwnerAlreadySet' },
|
|
36
|
+
1301: { message: 'OwnerNotSet' },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const BytesExtError = {
|
|
40
|
+
1400: { message: 'LengthMismatch' },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const UpgradeableError = {
|
|
44
|
+
1500: { message: 'MigrationNotAllowed' },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type DefaultOwnableStorage = { tag: 'Owner'; values: void };
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A pair of TTL values: threshold (when to trigger extension) and extend_to (target TTL).
|
|
51
|
+
*/
|
|
52
|
+
export interface TtlConfig {
|
|
53
|
+
/**
|
|
54
|
+
* Target TTL after extension (in ledgers).
|
|
55
|
+
*/
|
|
56
|
+
extend_to: u32;
|
|
57
|
+
/**
|
|
58
|
+
* TTL threshold that triggers extension (in ledgers).
|
|
59
|
+
*/
|
|
60
|
+
threshold: u32;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type TtlConfigStorage =
|
|
64
|
+
| { tag: 'Frozen'; values: void }
|
|
65
|
+
| { tag: 'Instance'; values: void }
|
|
66
|
+
| { tag: 'Persistent'; values: void };
|
|
67
|
+
|
|
68
|
+
export type UpgradeableStorage = { tag: 'Migrating'; values: void };
|
|
69
|
+
|
|
70
|
+
export interface Client {
|
|
71
|
+
/**
|
|
72
|
+
* Construct and simulate a owner transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
73
|
+
*/
|
|
74
|
+
owner: (options?: MethodOptions) => Promise<AssembledTransaction<Option<string>>>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Construct and simulate a transfer_ownership transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
78
|
+
*/
|
|
79
|
+
transfer_ownership: (
|
|
80
|
+
{ new_owner }: { new_owner: string },
|
|
81
|
+
options?: MethodOptions,
|
|
82
|
+
) => Promise<AssembledTransaction<null>>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Construct and simulate a renounce_ownership transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
86
|
+
*/
|
|
87
|
+
renounce_ownership: (options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
91
|
+
*/
|
|
92
|
+
upgrade: (
|
|
93
|
+
{ new_wasm_hash }: { new_wasm_hash: Buffer },
|
|
94
|
+
options?: MethodOptions,
|
|
95
|
+
) => Promise<AssembledTransaction<null>>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Construct and simulate a migrate transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
99
|
+
*/
|
|
100
|
+
migrate: (
|
|
101
|
+
{ migration_data }: { migration_data: MigrationData },
|
|
102
|
+
options?: MethodOptions,
|
|
103
|
+
) => Promise<AssembledTransaction<null>>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Construct and simulate a counter transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
107
|
+
*/
|
|
108
|
+
counter: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Construct and simulate a counter2 transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
112
|
+
*/
|
|
113
|
+
counter2: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>;
|
|
114
|
+
}
|
|
115
|
+
export class Client extends ContractClient {
|
|
116
|
+
static async deploy<T = Client>(
|
|
117
|
+
/** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
|
|
118
|
+
options: MethodOptions &
|
|
119
|
+
Omit<ContractClientOptions, 'contractId'> & {
|
|
120
|
+
/** The hash of the Wasm blob, which must already be installed on-chain. */
|
|
121
|
+
wasmHash: Buffer | string;
|
|
122
|
+
/** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
|
|
123
|
+
salt?: Buffer | Uint8Array;
|
|
124
|
+
/** The format used to decode `wasmHash`, if it's provided as a string. */
|
|
125
|
+
format?: 'hex' | 'base64';
|
|
126
|
+
},
|
|
127
|
+
): Promise<AssembledTransaction<T>> {
|
|
128
|
+
return ContractClient.deploy(null, options);
|
|
129
|
+
}
|
|
130
|
+
constructor(public readonly options: ContractClientOptions) {
|
|
131
|
+
super(
|
|
132
|
+
new ContractSpec([
|
|
133
|
+
'AAAAAAAAAAAAAAAFb3duZXIAA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ZW5zaW9uIChpbiBsZWRnZXJzKS4AAAAACXRocmVzaG9sZAAAAAAAAAQ=',
|
|
150
|
+
'AAAAAgAAAAAAAAAAAAAAEFR0bENvbmZpZ1N0b3JhZ2UAAAADAAAAAAAAAAAAAAAGRnJvemVuAAAAAAAAAAAAAAAAAAhJbnN0YW5jZQAAAAAAAAAAAAAAClBlcnNpc3RlbnQAAA==',
|
|
151
|
+
'AAAABQAAACdFdmVudCBlbWl0dGVkIHdoZW4gVFRMIGNvbmZpZ3MgYXJlIHNldC4AAAAAAAAAAA1UdGxDb25maWdzU2V0AAAAAAAAAQAAAA1UdGxDb25maWdzU2V0AAAAAAAAAgAAAAAAAAAIaW5zdGFuY2UAAAPoAAAH0AAAAAlUdGxDb25maWcAAAAAAAAAAAAAAAAAAApwZXJzaXN0ZW50AAAAAAPoAAAH0AAAAAlUdGxDb25maWcAAAAAAAAAAAAAAg==',
|
|
152
|
+
'AAAABQAAACpFdmVudCBlbWl0dGVkIHdoZW4gVFRMIGNvbmZpZ3MgYXJlIGZyb3plbi4AAAAAAAAAAAAQVHRsQ29uZmlnc0Zyb3plbgAAAAEAAAAQVHRsQ29uZmlnc0Zyb3plbgAAAAAAAAAC',
|
|
153
|
+
'AAAAAgAAAAAAAAAAAAAAElVwZ3JhZGVhYmxlU3RvcmFnZQAAAAAAAQAAAAAAAAAAAAAACU1pZ3JhdGluZwAAAA==',
|
|
154
|
+
]),
|
|
155
|
+
options,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
public readonly fromJSON = {
|
|
159
|
+
owner: this.txFromJSON<Option<string>>,
|
|
160
|
+
transfer_ownership: this.txFromJSON<null>,
|
|
161
|
+
renounce_ownership: this.txFromJSON<null>,
|
|
162
|
+
upgrade: this.txFromJSON<null>,
|
|
163
|
+
migrate: this.txFromJSON<null>,
|
|
164
|
+
counter: this.txFromJSON<u32>,
|
|
165
|
+
counter2: this.txFromJSON<u32>,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type MigrationData = void;
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import type { GlobalSetupContext } from 'vitest/node';
|
|
3
|
+
|
|
4
|
+
import { getFullyQualifiedRepoRootPath } from '@layerzerolabs/common-node-utils';
|
|
5
|
+
|
|
6
|
+
import { Client as DvnClient } from '../../src/generated/dvn';
|
|
7
|
+
import { Client as DvnFeeLibClient } from '../../src/generated/dvn_fee_lib';
|
|
8
|
+
import { Client as EndpointClient } from '../../src/generated/endpoint';
|
|
9
|
+
import { Client as ExecutorClient } from '../../src/generated/executor';
|
|
10
|
+
import { Client as ExecutorFeeLibClient } from '../../src/generated/executor_fee_lib';
|
|
11
|
+
import { Client as ExecutorHelperClient } from '../../src/generated/executor_helper';
|
|
12
|
+
import { Client as PriceFeedClient } from '../../src/generated/price_feed';
|
|
13
|
+
import { Client as SMLClient } from '../../src/generated/sml';
|
|
14
|
+
import { Client as TreasuryClient } from '../../src/generated/treasury';
|
|
15
|
+
import { Client as Uln302Client } from '../../src/generated/uln302';
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_DEPLOYER,
|
|
18
|
+
DVN_SIGNER,
|
|
19
|
+
DVN_VID,
|
|
20
|
+
EID,
|
|
21
|
+
EXECUTOR_ADMIN,
|
|
22
|
+
NATIVE_TOKEN_ADDRESS,
|
|
23
|
+
ZRO_TOKEN_ADDRESS,
|
|
24
|
+
} from './constants';
|
|
25
|
+
import { deployContract } from './deploy';
|
|
26
|
+
import { startStellarLocalnet, stopStellarLocalnet } from './localnet';
|
|
27
|
+
|
|
28
|
+
export interface ProtocolAddresses {
|
|
29
|
+
endpointV2: string;
|
|
30
|
+
uln302: string;
|
|
31
|
+
sml: string;
|
|
32
|
+
treasury: string;
|
|
33
|
+
executor: string;
|
|
34
|
+
executorHelper: string;
|
|
35
|
+
executorFeeLib: string;
|
|
36
|
+
priceFeed: string;
|
|
37
|
+
dvnFeeLib: string;
|
|
38
|
+
dvn: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ProtocolClients {
|
|
42
|
+
endpointClient: EndpointClient;
|
|
43
|
+
uln302Client: Uln302Client;
|
|
44
|
+
smlClient: SMLClient;
|
|
45
|
+
treasuryClient: TreasuryClient;
|
|
46
|
+
executorClient: ExecutorClient;
|
|
47
|
+
executorHelperClient: ExecutorHelperClient;
|
|
48
|
+
executorFeeLibClient: ExecutorFeeLibClient;
|
|
49
|
+
priceFeedClient: PriceFeedClient;
|
|
50
|
+
dvnFeeLibClient: DvnFeeLibClient;
|
|
51
|
+
dvnClient: DvnClient;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Declare the injection key type for vitest
|
|
55
|
+
declare module 'vitest' {
|
|
56
|
+
export interface ProvidedContext {
|
|
57
|
+
protocolAddresses: ProtocolAddresses;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Deploy all protocol contracts and wire them together
|
|
63
|
+
* Returns the deployed contract addresses
|
|
64
|
+
*/
|
|
65
|
+
async function deployProtocolContracts(): Promise<{
|
|
66
|
+
addresses: ProtocolAddresses;
|
|
67
|
+
clients: ProtocolClients;
|
|
68
|
+
}> {
|
|
69
|
+
const repoRoot = await getFullyQualifiedRepoRootPath();
|
|
70
|
+
const wasmDir = path.join(
|
|
71
|
+
repoRoot,
|
|
72
|
+
'contracts',
|
|
73
|
+
'protocol',
|
|
74
|
+
'stellar',
|
|
75
|
+
'target',
|
|
76
|
+
'wasm32v1-none',
|
|
77
|
+
'release',
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const addresses: ProtocolAddresses = {
|
|
81
|
+
endpointV2: '',
|
|
82
|
+
uln302: '',
|
|
83
|
+
sml: '',
|
|
84
|
+
treasury: '',
|
|
85
|
+
executor: '',
|
|
86
|
+
executorHelper: '',
|
|
87
|
+
executorFeeLib: '',
|
|
88
|
+
priceFeed: '',
|
|
89
|
+
dvnFeeLib: '',
|
|
90
|
+
dvn: '',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// 1. Deploy Endpoint
|
|
94
|
+
console.log('🚀 Deploying Endpoint...');
|
|
95
|
+
const endpointClient = await deployContract<EndpointClient>(
|
|
96
|
+
EndpointClient,
|
|
97
|
+
path.join(wasmDir, 'endpoint_v2.wasm'),
|
|
98
|
+
{
|
|
99
|
+
eid: EID,
|
|
100
|
+
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
101
|
+
native_token: NATIVE_TOKEN_ADDRESS,
|
|
102
|
+
},
|
|
103
|
+
DEFAULT_DEPLOYER,
|
|
104
|
+
);
|
|
105
|
+
addresses.endpointV2 = endpointClient.options.contractId;
|
|
106
|
+
console.log('✅ Endpoint deployed:', addresses.endpointV2);
|
|
107
|
+
|
|
108
|
+
// 2. Deploy Treasury
|
|
109
|
+
console.log('🚀 Deploying Treasury...');
|
|
110
|
+
const treasuryClient = await deployContract<TreasuryClient>(
|
|
111
|
+
TreasuryClient,
|
|
112
|
+
path.join(wasmDir, 'treasury.wasm'),
|
|
113
|
+
{ owner: DEFAULT_DEPLOYER.publicKey() },
|
|
114
|
+
DEFAULT_DEPLOYER,
|
|
115
|
+
);
|
|
116
|
+
addresses.treasury = treasuryClient.options.contractId;
|
|
117
|
+
console.log('✅ Treasury deployed:', addresses.treasury);
|
|
118
|
+
|
|
119
|
+
// 3. Deploy ULN302
|
|
120
|
+
console.log('🚀 Deploying ULN302...');
|
|
121
|
+
const uln302Client = await deployContract<Uln302Client>(
|
|
122
|
+
Uln302Client,
|
|
123
|
+
path.join(wasmDir, 'uln302.wasm'),
|
|
124
|
+
{
|
|
125
|
+
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
126
|
+
endpoint: addresses.endpointV2,
|
|
127
|
+
treasury: addresses.treasury,
|
|
128
|
+
},
|
|
129
|
+
DEFAULT_DEPLOYER,
|
|
130
|
+
);
|
|
131
|
+
addresses.uln302 = uln302Client.options.contractId;
|
|
132
|
+
console.log('✅ ULN302 deployed:', addresses.uln302);
|
|
133
|
+
|
|
134
|
+
// 4. Deploy SML (SimpleMessageLib)
|
|
135
|
+
console.log('🚀 Deploying SimpleMessageLib...');
|
|
136
|
+
const smlClient = await deployContract<SMLClient>(
|
|
137
|
+
SMLClient,
|
|
138
|
+
path.join(wasmDir, 'simple_message_lib.wasm'),
|
|
139
|
+
{
|
|
140
|
+
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
141
|
+
endpoint: addresses.endpointV2,
|
|
142
|
+
fee_recipient: DEFAULT_DEPLOYER.publicKey(),
|
|
143
|
+
},
|
|
144
|
+
DEFAULT_DEPLOYER,
|
|
145
|
+
);
|
|
146
|
+
addresses.sml = smlClient.options.contractId;
|
|
147
|
+
console.log('✅ SimpleMessageLib deployed:', addresses.sml);
|
|
148
|
+
|
|
149
|
+
// 5. Deploy Price Feed
|
|
150
|
+
console.log('🚀 Deploying Price Feed...');
|
|
151
|
+
const priceFeedClient = await deployContract<PriceFeedClient>(
|
|
152
|
+
PriceFeedClient,
|
|
153
|
+
path.join(wasmDir, 'price_feed.wasm'),
|
|
154
|
+
{
|
|
155
|
+
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
156
|
+
price_updater: DEFAULT_DEPLOYER.publicKey(),
|
|
157
|
+
},
|
|
158
|
+
DEFAULT_DEPLOYER,
|
|
159
|
+
);
|
|
160
|
+
addresses.priceFeed = priceFeedClient.options.contractId;
|
|
161
|
+
console.log('✅ Price Feed deployed:', addresses.priceFeed);
|
|
162
|
+
|
|
163
|
+
// 6. Deploy Executor Fee Lib
|
|
164
|
+
console.log('🚀 Deploying Executor Fee Lib...');
|
|
165
|
+
const executorFeeLibClient = await deployContract<ExecutorFeeLibClient>(
|
|
166
|
+
ExecutorFeeLibClient,
|
|
167
|
+
path.join(wasmDir, 'executor_fee_lib.wasm'),
|
|
168
|
+
{ owner: DEFAULT_DEPLOYER.publicKey() },
|
|
169
|
+
DEFAULT_DEPLOYER,
|
|
170
|
+
);
|
|
171
|
+
addresses.executorFeeLib = executorFeeLibClient.options.contractId;
|
|
172
|
+
console.log('✅ Executor Fee Lib deployed:', addresses.executorFeeLib);
|
|
173
|
+
|
|
174
|
+
// 7. Deploy DVN Fee Lib
|
|
175
|
+
console.log('🚀 Deploying DVN Fee Lib...');
|
|
176
|
+
const dvnFeeLibClient = await deployContract<DvnFeeLibClient>(
|
|
177
|
+
DvnFeeLibClient,
|
|
178
|
+
path.join(wasmDir, 'dvn_fee_lib.wasm'),
|
|
179
|
+
{ owner: DEFAULT_DEPLOYER.publicKey() },
|
|
180
|
+
DEFAULT_DEPLOYER,
|
|
181
|
+
);
|
|
182
|
+
addresses.dvnFeeLib = dvnFeeLibClient.options.contractId;
|
|
183
|
+
console.log('✅ DVN Fee Lib deployed:', addresses.dvnFeeLib);
|
|
184
|
+
|
|
185
|
+
// 8. Deploy DVN
|
|
186
|
+
console.log('🚀 Deploying DVN...');
|
|
187
|
+
const dvnClient = await deployContract<DvnClient>(
|
|
188
|
+
DvnClient,
|
|
189
|
+
path.join(wasmDir, 'dvn.wasm'),
|
|
190
|
+
{
|
|
191
|
+
vid: DVN_VID,
|
|
192
|
+
signers: [DVN_SIGNER.ethAddress],
|
|
193
|
+
threshold: 1,
|
|
194
|
+
admins: [DEFAULT_DEPLOYER.publicKey()],
|
|
195
|
+
supported_msglibs: [addresses.uln302],
|
|
196
|
+
price_feed: addresses.priceFeed,
|
|
197
|
+
default_multiplier_bps: 10000,
|
|
198
|
+
worker_fee_lib: addresses.dvnFeeLib,
|
|
199
|
+
deposit_address: DEFAULT_DEPLOYER.publicKey(),
|
|
200
|
+
},
|
|
201
|
+
DEFAULT_DEPLOYER,
|
|
202
|
+
);
|
|
203
|
+
addresses.dvn = dvnClient.options.contractId;
|
|
204
|
+
console.log('✅ DVN deployed:', addresses.dvn);
|
|
205
|
+
|
|
206
|
+
// 9. Deploy Executor Helper
|
|
207
|
+
console.log('🚀 Deploying Executor Helper...');
|
|
208
|
+
const executorHelperClient = await deployContract<ExecutorHelperClient>(
|
|
209
|
+
ExecutorHelperClient,
|
|
210
|
+
path.join(wasmDir, 'executor_helper.wasm'),
|
|
211
|
+
undefined,
|
|
212
|
+
DEFAULT_DEPLOYER,
|
|
213
|
+
);
|
|
214
|
+
addresses.executorHelper = executorHelperClient.options.contractId;
|
|
215
|
+
console.log('✅ Executor Helper deployed:', addresses.executorHelper);
|
|
216
|
+
|
|
217
|
+
// 10. Deploy Executor (supports both ULN302 and SML)
|
|
218
|
+
console.log('🚀 Deploying Executor...');
|
|
219
|
+
const whitelist = [
|
|
220
|
+
[addresses.executorHelper, 'native_drop_and_execute'],
|
|
221
|
+
[addresses.executorHelper, 'execute'],
|
|
222
|
+
[addresses.executorHelper, 'compose'],
|
|
223
|
+
];
|
|
224
|
+
const executorClient = await deployContract<ExecutorClient>(
|
|
225
|
+
ExecutorClient,
|
|
226
|
+
path.join(wasmDir, 'executor.wasm'),
|
|
227
|
+
{
|
|
228
|
+
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
229
|
+
endpoint: addresses.endpointV2,
|
|
230
|
+
whitelist,
|
|
231
|
+
admins: [EXECUTOR_ADMIN.publicKey(), DEFAULT_DEPLOYER.publicKey()],
|
|
232
|
+
message_libs: [addresses.uln302, addresses.sml],
|
|
233
|
+
price_feed: addresses.priceFeed,
|
|
234
|
+
default_multiplier_bps: 10000,
|
|
235
|
+
worker_fee_lib: addresses.executorFeeLib,
|
|
236
|
+
deposit_address: DEFAULT_DEPLOYER.publicKey(),
|
|
237
|
+
},
|
|
238
|
+
DEFAULT_DEPLOYER,
|
|
239
|
+
);
|
|
240
|
+
addresses.executor = executorClient.options.contractId;
|
|
241
|
+
console.log('✅ Executor deployed:', addresses.executor);
|
|
242
|
+
|
|
243
|
+
const clients: ProtocolClients = {
|
|
244
|
+
endpointClient,
|
|
245
|
+
uln302Client,
|
|
246
|
+
smlClient,
|
|
247
|
+
treasuryClient,
|
|
248
|
+
executorClient,
|
|
249
|
+
executorHelperClient,
|
|
250
|
+
executorFeeLibClient,
|
|
251
|
+
priceFeedClient,
|
|
252
|
+
dvnFeeLibClient,
|
|
253
|
+
dvnClient,
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
return { addresses, clients };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Wire protocol contracts (register libraries, set defaults, configure workers)
|
|
261
|
+
*/
|
|
262
|
+
async function wireProtocolContracts(
|
|
263
|
+
addresses: ProtocolAddresses,
|
|
264
|
+
clients: ProtocolClients,
|
|
265
|
+
): Promise<void> {
|
|
266
|
+
const { endpointClient, uln302Client, priceFeedClient, executorClient, dvnClient } = clients;
|
|
267
|
+
|
|
268
|
+
console.log('🔗 Wiring protocol contracts...');
|
|
269
|
+
|
|
270
|
+
// Register libraries
|
|
271
|
+
await (await endpointClient.register_library({ new_lib: addresses.uln302 })).signAndSend();
|
|
272
|
+
await (await endpointClient.register_library({ new_lib: addresses.sml })).signAndSend();
|
|
273
|
+
console.log('✅ Libraries registered (ULN302 + SML)');
|
|
274
|
+
|
|
275
|
+
// Set ZRO token
|
|
276
|
+
await (await endpointClient.set_zro({ zro: ZRO_TOKEN_ADDRESS })).signAndSend();
|
|
277
|
+
console.log('✅ ZRO token set');
|
|
278
|
+
|
|
279
|
+
// Configure ULN302 executor config FIRST (so is_supported_eid returns true)
|
|
280
|
+
await (
|
|
281
|
+
await uln302Client.set_default_executor_configs({
|
|
282
|
+
params: [
|
|
283
|
+
{
|
|
284
|
+
dst_eid: EID,
|
|
285
|
+
config: { executor: addresses.executor, max_message_size: 10000 },
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
})
|
|
289
|
+
).signAndSend();
|
|
290
|
+
console.log('✅ ULN302 executor config set');
|
|
291
|
+
|
|
292
|
+
// Configure ULN302 send/receive configs
|
|
293
|
+
await (
|
|
294
|
+
await uln302Client.set_default_send_uln_configs({
|
|
295
|
+
params: [
|
|
296
|
+
{
|
|
297
|
+
eid: EID,
|
|
298
|
+
config: {
|
|
299
|
+
confirmations: 1n,
|
|
300
|
+
required_dvns: [addresses.dvn],
|
|
301
|
+
optional_dvns: [],
|
|
302
|
+
optional_dvn_threshold: 0,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
})
|
|
307
|
+
).signAndSend();
|
|
308
|
+
|
|
309
|
+
await (
|
|
310
|
+
await uln302Client.set_default_receive_uln_configs({
|
|
311
|
+
params: [
|
|
312
|
+
{
|
|
313
|
+
eid: EID,
|
|
314
|
+
config: {
|
|
315
|
+
confirmations: 1n,
|
|
316
|
+
required_dvns: [addresses.dvn],
|
|
317
|
+
optional_dvns: [],
|
|
318
|
+
optional_dvn_threshold: 0,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
})
|
|
323
|
+
).signAndSend();
|
|
324
|
+
console.log('✅ ULN302 send/receive configs set');
|
|
325
|
+
|
|
326
|
+
// NOW set default send/receive libraries to ULN302 (after configs are set)
|
|
327
|
+
await (
|
|
328
|
+
await endpointClient.set_default_send_library({ dst_eid: EID, new_lib: addresses.uln302 })
|
|
329
|
+
).signAndSend();
|
|
330
|
+
await (
|
|
331
|
+
await endpointClient.set_default_receive_library({
|
|
332
|
+
src_eid: EID,
|
|
333
|
+
new_lib: addresses.uln302,
|
|
334
|
+
grace_period: 0n,
|
|
335
|
+
})
|
|
336
|
+
).signAndSend();
|
|
337
|
+
console.log('✅ Default libraries set to ULN302');
|
|
338
|
+
|
|
339
|
+
// Configure Price Feed
|
|
340
|
+
await (
|
|
341
|
+
await priceFeedClient.set_price_ratio_denominator({ denominator: 100000000000000000000n })
|
|
342
|
+
).signAndSend();
|
|
343
|
+
await (
|
|
344
|
+
await priceFeedClient.set_native_token_price_usd({
|
|
345
|
+
price_updater: DEFAULT_DEPLOYER.publicKey(),
|
|
346
|
+
native_token_price_usd: 1000000000000000000n,
|
|
347
|
+
})
|
|
348
|
+
).signAndSend();
|
|
349
|
+
|
|
350
|
+
const NORMALIZED_EID = EID % 30000;
|
|
351
|
+
await (
|
|
352
|
+
await priceFeedClient.set_price({
|
|
353
|
+
price_updater: DEFAULT_DEPLOYER.publicKey(),
|
|
354
|
+
prices: [
|
|
355
|
+
{
|
|
356
|
+
eid: NORMALIZED_EID,
|
|
357
|
+
price: {
|
|
358
|
+
gas_per_byte: 1,
|
|
359
|
+
gas_price_in_unit: 1n,
|
|
360
|
+
price_ratio: 100000000000000000000n,
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
})
|
|
365
|
+
).signAndSend();
|
|
366
|
+
console.log('✅ Price Feed configured');
|
|
367
|
+
|
|
368
|
+
// Configure Executor
|
|
369
|
+
await (
|
|
370
|
+
await executorClient.set_dst_config({
|
|
371
|
+
admin: DEFAULT_DEPLOYER.publicKey(),
|
|
372
|
+
params: [
|
|
373
|
+
{
|
|
374
|
+
dst_eid: EID,
|
|
375
|
+
dst_config: {
|
|
376
|
+
floor_margin_usd: 0n,
|
|
377
|
+
lz_compose_base_gas: 50000n,
|
|
378
|
+
lz_receive_base_gas: 100000n,
|
|
379
|
+
multiplier_bps: 10000,
|
|
380
|
+
native_cap: 1000000000000n,
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
})
|
|
385
|
+
).signAndSend();
|
|
386
|
+
console.log('✅ Executor configured');
|
|
387
|
+
|
|
388
|
+
// Configure DVN
|
|
389
|
+
await (
|
|
390
|
+
await dvnClient.set_dst_config({
|
|
391
|
+
admin: DEFAULT_DEPLOYER.publicKey(),
|
|
392
|
+
params: [
|
|
393
|
+
{
|
|
394
|
+
dst_eid: EID,
|
|
395
|
+
config: {
|
|
396
|
+
floor_margin_usd: 0n,
|
|
397
|
+
gas: 100000n,
|
|
398
|
+
multiplier_bps: 10000,
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
})
|
|
403
|
+
).signAndSend();
|
|
404
|
+
console.log('✅ DVN configured');
|
|
405
|
+
|
|
406
|
+
console.log('🎉 Protocol wiring complete!');
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Vitest Global Setup - runs ONCE before all test files
|
|
411
|
+
* Uses vitest's provide() to share data in memory with test files
|
|
412
|
+
*/
|
|
413
|
+
export default async function globalSetup({
|
|
414
|
+
provide,
|
|
415
|
+
}: GlobalSetupContext): Promise<() => Promise<void>> {
|
|
416
|
+
console.log('\n========================================');
|
|
417
|
+
console.log('🌐 GLOBAL SETUP: Starting Stellar Localnet');
|
|
418
|
+
console.log('========================================\n');
|
|
419
|
+
|
|
420
|
+
await startStellarLocalnet();
|
|
421
|
+
|
|
422
|
+
console.log('\n========================================');
|
|
423
|
+
console.log('📦 GLOBAL SETUP: Deploying Protocol Contracts');
|
|
424
|
+
console.log('========================================\n');
|
|
425
|
+
|
|
426
|
+
const { addresses, clients } = await deployProtocolContracts();
|
|
427
|
+
|
|
428
|
+
console.log('\n========================================');
|
|
429
|
+
console.log('🔗 GLOBAL SETUP: Wiring Protocol Contracts');
|
|
430
|
+
console.log('========================================\n');
|
|
431
|
+
|
|
432
|
+
await wireProtocolContracts(addresses, clients);
|
|
433
|
+
|
|
434
|
+
// Provide addresses in memory for test files to access via inject()
|
|
435
|
+
provide('protocolAddresses', addresses);
|
|
436
|
+
console.log('\n✅ Protocol addresses provided to tests (in-memory)');
|
|
437
|
+
|
|
438
|
+
console.log('\n========================================');
|
|
439
|
+
console.log('✅ GLOBAL SETUP COMPLETE');
|
|
440
|
+
console.log('========================================\n');
|
|
441
|
+
|
|
442
|
+
// Return teardown function
|
|
443
|
+
return async () => {
|
|
444
|
+
console.log('\n========================================');
|
|
445
|
+
console.log('🛑 GLOBAL TEARDOWN: Stopping Stellar Localnet');
|
|
446
|
+
console.log('========================================\n');
|
|
447
|
+
|
|
448
|
+
await stopStellarLocalnet();
|
|
449
|
+
};
|
|
450
|
+
}
|