@layerzerolabs/protocol-stellar-v2 0.2.18 → 0.2.19
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 +275 -248
- package/.turbo/turbo-lint.log +52 -58
- package/.turbo/turbo-test.log +1224 -1358
- package/Cargo.lock +8 -5
- package/Cargo.toml +1 -1
- package/contracts/ERROR_SPEC.md +1 -1
- package/contracts/message-libs/uln-302/src/send_uln.rs +1 -1
- package/contracts/oapps/oapp/src/oapp_receiver.rs +1 -1
- package/contracts/oapps/oft/Cargo.toml +10 -7
- package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_oft_fee.rs +3 -4
- package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_pausable.rs +2 -3
- package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_rate_limiter.rs +1 -1
- package/contracts/oapps/oft/integration-tests/mod.rs +1 -1
- package/contracts/oapps/oft/integration-tests/setup.rs +28 -127
- package/contracts/oapps/oft/integration-tests/utils.rs +254 -21
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +5 -6
- package/contracts/oapps/oft/src/lib.rs +10 -14
- package/contracts/oapps/oft/src/oft.rs +151 -189
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +9 -11
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +32 -12
- package/contracts/oapps/oft/src/oft_types/mod.rs +13 -0
- package/contracts/oapps/{oft-std → oft-core}/Cargo.toml +6 -4
- package/contracts/oapps/{oft-std → oft-core}/integration-tests/mod.rs +1 -1
- package/contracts/oapps/{oft-std → oft-core}/integration-tests/setup.rs +126 -29
- package/contracts/oapps/{oft → oft-core}/integration-tests/test_with_sml.rs +3 -3
- package/contracts/oapps/oft-core/integration-tests/utils.rs +201 -0
- package/contracts/oapps/oft-core/src/lib.rs +18 -0
- package/contracts/oapps/oft-core/src/oft_core.rs +439 -0
- package/contracts/oapps/{oft → oft-core}/src/tests/mod.rs +0 -2
- package/contracts/oapps/{oft → oft-core}/src/tests/test_lz_receive.rs +7 -7
- package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_msg_codec.rs +4 -4
- package/contracts/oapps/{oft → oft-core}/src/tests/test_resolve_address.rs +3 -3
- package/contracts/oapps/{oft → oft-core}/src/tests/test_utils.rs +44 -25
- package/contracts/oapps/{oft → oft-core}/src/utils.rs +1 -1
- package/contracts/utils/src/errors.rs +5 -1
- package/contracts/utils/src/ownable.rs +125 -3
- package/contracts/utils/src/tests/option_ext.rs +1 -1
- package/contracts/utils/src/tests/ownable.rs +445 -7
- package/contracts/utils/src/tests/ttl_configurable.rs +2 -2
- package/package.json +4 -5
- package/sdk/.turbo/turbo-test.log +216 -206
- package/sdk/dist/generated/bml.d.ts +30 -0
- package/sdk/dist/generated/bml.js +28 -5
- package/sdk/dist/generated/counter.d.ts +122 -2
- package/sdk/dist/generated/counter.js +36 -7
- package/sdk/dist/generated/dvn.d.ts +30 -0
- package/sdk/dist/generated/dvn.js +28 -5
- package/sdk/dist/generated/dvn_fee_lib.d.ts +122 -2
- package/sdk/dist/generated/dvn_fee_lib.js +36 -7
- package/sdk/dist/generated/endpoint.d.ts +122 -2
- package/sdk/dist/generated/endpoint.js +36 -7
- package/sdk/dist/generated/executor.d.ts +122 -2
- package/sdk/dist/generated/executor.js +36 -7
- package/sdk/dist/generated/executor_fee_lib.d.ts +122 -2
- package/sdk/dist/generated/executor_fee_lib.js +36 -7
- package/sdk/dist/generated/executor_helper.d.ts +30 -0
- package/sdk/dist/generated/executor_helper.js +28 -5
- package/sdk/dist/generated/oft.d.ts +1842 -0
- package/sdk/dist/generated/oft.js +345 -0
- package/sdk/dist/generated/price_feed.d.ts +122 -2
- package/sdk/dist/generated/price_feed.js +36 -7
- package/sdk/dist/generated/sml.d.ts +122 -2
- package/sdk/dist/generated/sml.js +36 -7
- package/sdk/dist/generated/treasury.d.ts +122 -2
- package/sdk/dist/generated/treasury.js +36 -7
- package/sdk/dist/generated/uln302.d.ts +122 -2
- package/sdk/dist/generated/uln302.js +36 -7
- package/sdk/dist/generated/upgrader.d.ts +15 -0
- package/sdk/dist/generated/upgrader.js +18 -0
- package/sdk/dist/index.d.ts +1 -2
- package/sdk/dist/index.js +1 -3
- package/sdk/package.json +3 -2
- package/sdk/src/index.ts +1 -4
- package/sdk/test/oft-sml.test.ts +16 -16
- package/sdk/turbo.json +8 -0
- package/tools/ts-bindings-gen/Cargo.toml +2 -0
- package/tools/ts-bindings-gen/src/main.rs +51 -4
- package/turbo.json +0 -2
- package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +0 -23
- package/contracts/oapps/oft/src/interfaces/mod.rs +0 -3
- package/contracts/oapps/oft/src/oft_impl.rs +0 -201
- package/contracts/oapps/oft/src/tests/extensions/mod.rs +0 -11
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +0 -917
- package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +0 -751
- package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +0 -434
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +0 -1080
- package/contracts/oapps/oft-std/integration-tests/utils.rs +0 -427
- package/contracts/oapps/oft-std/src/lib.rs +0 -16
- package/contracts/oapps/oft-std/src/oft.rs +0 -174
- package/sdk/dist/generated/oft_std.d.ts +0 -1722
- package/sdk/dist/generated/oft_std.js +0 -316
- package/sdk/dist/wasm/blocked-message-lib.d.ts +0 -1
- package/sdk/dist/wasm/blocked-message-lib.js +0 -2
- package/sdk/dist/wasm/counter.d.ts +0 -1
- package/sdk/dist/wasm/counter.js +0 -2
- package/sdk/dist/wasm/dvn-fee-lib.d.ts +0 -1
- package/sdk/dist/wasm/dvn-fee-lib.js +0 -2
- package/sdk/dist/wasm/dvn.d.ts +0 -1
- package/sdk/dist/wasm/dvn.js +0 -2
- package/sdk/dist/wasm/endpoint-v2.d.ts +0 -1
- package/sdk/dist/wasm/endpoint-v2.js +0 -2
- package/sdk/dist/wasm/executor-fee-lib.d.ts +0 -1
- package/sdk/dist/wasm/executor-fee-lib.js +0 -2
- package/sdk/dist/wasm/executor-helper.d.ts +0 -1
- package/sdk/dist/wasm/executor-helper.js +0 -2
- package/sdk/dist/wasm/executor.d.ts +0 -1
- package/sdk/dist/wasm/executor.js +0 -2
- package/sdk/dist/wasm/layerzero-views.d.ts +0 -1
- package/sdk/dist/wasm/layerzero-views.js +0 -2
- package/sdk/dist/wasm/oft-std.d.ts +0 -1
- package/sdk/dist/wasm/oft-std.js +0 -2
- package/sdk/dist/wasm/price-feed.d.ts +0 -1
- package/sdk/dist/wasm/price-feed.js +0 -2
- package/sdk/dist/wasm/simple-message-lib.d.ts +0 -1
- package/sdk/dist/wasm/simple-message-lib.js +0 -2
- package/sdk/dist/wasm/treasury.d.ts +0 -1
- package/sdk/dist/wasm/treasury.js +0 -2
- package/sdk/dist/wasm/uln302.d.ts +0 -1
- package/sdk/dist/wasm/uln302.js +0 -2
- package/sdk/dist/wasm/upgrader.d.ts +0 -1
- package/sdk/dist/wasm/upgrader.js +0 -2
- package/sdk/dist/wasm.d.ts +0 -15
- package/sdk/dist/wasm.js +0 -15
- /package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/mod.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/codec/mod.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/codec/oft_compose_msg_codec.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/codec/oft_msg_codec.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/errors.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/events.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/storage.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_decimals.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_compose_msg_codec.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_version.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_oft.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_send.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_send.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_token.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/types.rs +0 -0
|
@@ -4,6 +4,21 @@ export * from '@stellar/stellar-sdk';
|
|
|
4
4
|
export * as contract from '@stellar/stellar-sdk/contract';
|
|
5
5
|
export * as rpc from '@stellar/stellar-sdk/rpc';
|
|
6
6
|
export type MigrationData = void;
|
|
7
|
+
/**
|
|
8
|
+
* Embedded WASM bytecode (base64-encoded)
|
|
9
|
+
* Size: 1597 bytes (1.56 KB)
|
|
10
|
+
*/
|
|
11
|
+
export declare const WASM_BASE64 = "AGFzbQEAAAABHAVgAX4BfmACfn4BfmADfn5+AX5gA35+fgBgAAACEwMBYgE4AAABdgFnAAEBZAFfAAIDBQQCAwQEBQMBABAGIQR/AUGAgMAAC38AQYCAwAALfwBBgIDAAAt/AEGAgMAACwc/BQZtZW1vcnkCABN1cGdyYWRlX2FuZF9taWdyYXRlAAMBXwMBCl9fZGF0YV9lbmQDAgtfX2hlYXBfYmFzZQMDCoUCBNIBAwF/AX4BfyOAgICAAEEQayIDJICAgIAAAkAgAEL/AYNCzQBSDQAgAUL/AYNCyABSDQAgARCAgICAAEKAgICAcINCgICAgIAEUg0AIAJC/wGDQssAUg0AIAMgATcDAEICIQRBASEFAkADQCAFRQ0BIAVBf2ohBSABIQQMAAsLIAMgBDcDCCAAQo7UqfPNresBIANBCGqtQiCGQgSEQoSAgIAQEIGAgIAAEISAgIAAIABCjtS58831ygEgAhCEgICAACADQRBqJICAgIAAQgIPCwALIQACQCAAIAEgAhCCgICAAEL/AYNCAlENABCGgICAAAALCwMAAAsJABCFgICAAAALCwkBAEGAgMAACwAA6wcOY29udHJhY3RzcGVjdjAAAAAAAAADWlVwZ3JhZGUgYSB0YXJnZXQgY29udHJhY3QgYW5kIH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LCBtaWdyYXRpb25fZGF0YSk7CmBgYAAAAAAAE3VwZ3JhZGVfYW5kX21pZ3JhdGUAAAAAAwAAAAAAAAAQY29udHJhY3RfYWRkcmVzcwAAABMAAAAAAAAACXdhc21faGFzaAAAAAAAA+4AAAAgAAAAAAAAAA5taWdyYXRpb25fZGF0YQAAAAAD6gAAAAAAAAAAAB4RY29udHJhY3RlbnZtZXRhdjAAAAAAAAAAFwAAAAAAbw5jb250cmFjdG1ldGF2MAAAAAAAAAAFcnN2ZXIAAAAAAAAGMS45MC4wAAAAAAAAAAAACHJzc2RrdmVyAAAALzIzLjQuMCM2NzNkNmM0ZjIzNjhkMjgyZDI1ZGEyOWJkYTU1YzIxYjhiZTY5Y2E2AA==";
|
|
12
|
+
/**
|
|
13
|
+
* Pre-computed WASM hash (SHA-256)
|
|
14
|
+
* Use this when the WASM is already uploaded on-chain
|
|
15
|
+
*/
|
|
16
|
+
export declare const WASM_HASH = "250cba854264d9d437c960e9f8ed838dbf39876947b4fb84c5a209a39b794da6";
|
|
17
|
+
/**
|
|
18
|
+
* Get the WASM bytecode as a Buffer
|
|
19
|
+
* Use this to upload the WASM to the network
|
|
20
|
+
*/
|
|
21
|
+
export declare function getWasmBuffer(): Buffer;
|
|
7
22
|
export interface Client {
|
|
8
23
|
/**
|
|
9
24
|
* Construct and simulate a upgrade_and_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.
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
import { Buffer } from "buffer";
|
|
1
2
|
import { Client as ContractClient, Spec as ContractSpec, } from '@stellar/stellar-sdk/contract';
|
|
2
3
|
export * from '@stellar/stellar-sdk';
|
|
3
4
|
export * as contract from '@stellar/stellar-sdk/contract';
|
|
4
5
|
export * as rpc from '@stellar/stellar-sdk/rpc';
|
|
6
|
+
/**
|
|
7
|
+
* Embedded WASM bytecode (base64-encoded)
|
|
8
|
+
* Size: 1597 byt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jhiZTY5Y2E2AA==";
|
|
11
|
+
/**
|
|
12
|
+
* Pre-computed WASM hash (SHA-256)
|
|
13
|
+
* Use this when the WASM is already uploaded on-chain
|
|
14
|
+
*/
|
|
15
|
+
export const WASM_HASH = "250cba854264d9d437c960e9f8ed838dbf39876947b4fb84c5a209a39b794da6";
|
|
16
|
+
/**
|
|
17
|
+
* Get the WASM bytecode as a Buffer
|
|
18
|
+
* Use this to upload the WASM to the network
|
|
19
|
+
*/
|
|
20
|
+
export function getWasmBuffer() {
|
|
21
|
+
return Buffer.from(WASM_BASE64, 'base64');
|
|
22
|
+
}
|
|
5
23
|
export class Client extends ContractClient {
|
|
6
24
|
options;
|
|
7
25
|
static async deploy(
|
package/sdk/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,4 @@ export * as executor from './generated/executor.js';
|
|
|
11
11
|
export * as executorFeeLib from './generated/executor_fee_lib.js';
|
|
12
12
|
export * as executorHelper from './generated/executor_helper.js';
|
|
13
13
|
export * as priceFeed from './generated/price_feed.js';
|
|
14
|
-
export * as
|
|
15
|
-
export * from './wasm.js';
|
|
14
|
+
export * as oft from './generated/oft.js';
|
package/sdk/dist/index.js
CHANGED
|
@@ -14,6 +14,4 @@ export * as executorFeeLib from './generated/executor_fee_lib.js';
|
|
|
14
14
|
export * as executorHelper from './generated/executor_helper.js';
|
|
15
15
|
export * as priceFeed from './generated/price_feed.js';
|
|
16
16
|
// OApp contracts
|
|
17
|
-
export * as
|
|
18
|
-
// WASM exports (auto-generated)
|
|
19
|
-
export * from './wasm.js';
|
|
17
|
+
export * as oft from './generated/oft.js';
|
package/sdk/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/lz-v2-stellar-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "TypeScript SDK for endpoint-v2 Stellar contract",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"test": "vitest --run --pass-with-no-tests --typecheck"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@layerzerolabs/protocol-stellar-v2": "workspace:*",
|
|
20
21
|
"@noble/hashes": "catalog:",
|
|
21
22
|
"@noble/secp256k1": "catalog:",
|
|
22
23
|
"@stellar/stellar-sdk": "catalog:",
|
|
@@ -25,7 +26,6 @@
|
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@layerzerolabs/common-node-utils": "workspace:*",
|
|
27
28
|
"@layerzerolabs/lz-v2-utilities": "catalog:",
|
|
28
|
-
"@layerzerolabs/protocol-stellar-v2": "workspace:*",
|
|
29
29
|
"@layerzerolabs/tsup-configuration": "workspace:*",
|
|
30
30
|
"@layerzerolabs/typescript-configuration": "workspace:*",
|
|
31
31
|
"axios": "catalog:",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"registry": "https://registry.npmjs.org/"
|
|
39
39
|
},
|
|
40
40
|
"implicitDependencies": {
|
|
41
|
+
"@layerzerolabs/protocol-stellar-v2": "workspace:*",
|
|
41
42
|
"buffer": "catalog:"
|
|
42
43
|
}
|
|
43
44
|
}
|
package/sdk/src/index.ts
CHANGED
|
@@ -16,7 +16,4 @@ export * as executorHelper from './generated/executor_helper.js';
|
|
|
16
16
|
export * as priceFeed from './generated/price_feed.js';
|
|
17
17
|
|
|
18
18
|
// OApp contracts
|
|
19
|
-
export * as
|
|
20
|
-
|
|
21
|
-
// WASM exports (auto-generated)
|
|
22
|
-
export * from './wasm.js';
|
|
19
|
+
export * as oft from './generated/oft.js';
|
package/sdk/test/oft-sml.test.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { PacketSerializer, PacketV1Codec } from '@layerzerolabs/lz-v2-utilities'
|
|
|
16
16
|
|
|
17
17
|
import { Client as EndpointClient } from '../src/generated/endpoint';
|
|
18
18
|
import { Client as ExecutorHelperClient } from '../src/generated/executor_helper';
|
|
19
|
-
import { Client as
|
|
19
|
+
import { Client as OFTClient, OftType, SendParam } from '../src/generated/oft';
|
|
20
20
|
import { Client as SMLClient } from '../src/generated/sml';
|
|
21
21
|
import {
|
|
22
22
|
DEFAULT_DEPLOYER,
|
|
@@ -47,8 +47,8 @@ let mintBurnOftAddress = '';
|
|
|
47
47
|
let endpointClient: EndpointClient;
|
|
48
48
|
let smlClient: SMLClient;
|
|
49
49
|
let executorHelperClient: ExecutorHelperClient;
|
|
50
|
-
let lockUnlockOftClient:
|
|
51
|
-
let mintBurnOftClient:
|
|
50
|
+
let lockUnlockOftClient: OFTClient;
|
|
51
|
+
let mintBurnOftClient: OFTClient;
|
|
52
52
|
|
|
53
53
|
// Test accounts
|
|
54
54
|
const TOKEN_ISSUER = Keypair.random();
|
|
@@ -80,7 +80,7 @@ describe('OFT E2E Testing with SAC (SML)', async () => {
|
|
|
80
80
|
'release',
|
|
81
81
|
);
|
|
82
82
|
|
|
83
|
-
const
|
|
83
|
+
const OFT_WASM_PATH = path.join(wasmDir, 'oft.wasm');
|
|
84
84
|
|
|
85
85
|
beforeAll(async () => {
|
|
86
86
|
// Inject protocol addresses from globalSetup
|
|
@@ -165,16 +165,16 @@ describe('OFT E2E Testing with SAC (SML)', async () => {
|
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
it('Deploy Lock/Unlock OFT', async () => {
|
|
168
|
-
lockUnlockOftClient = await deployContract<
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
lockUnlockOftClient = await deployContract<OFTClient>(
|
|
169
|
+
OFTClient,
|
|
170
|
+
OFT_WASM_PATH,
|
|
171
171
|
{
|
|
172
172
|
token: oftTokenAddress,
|
|
173
173
|
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
174
174
|
endpoint: protocolAddresses.endpointV2,
|
|
175
175
|
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
176
176
|
shared_decimals: SHARED_DECIMALS,
|
|
177
|
-
|
|
177
|
+
oft_type: OftType.LockUnlock,
|
|
178
178
|
},
|
|
179
179
|
DEFAULT_DEPLOYER,
|
|
180
180
|
);
|
|
@@ -183,21 +183,21 @@ describe('OFT E2E Testing with SAC (SML)', async () => {
|
|
|
183
183
|
console.log('✅ Lock/Unlock OFT deployed:', lockUnlockOftAddress);
|
|
184
184
|
|
|
185
185
|
// Verify it's in lock/unlock mode
|
|
186
|
-
const { result:
|
|
187
|
-
expect(
|
|
186
|
+
const { result: oftType } = await lockUnlockOftClient.oft_type();
|
|
187
|
+
expect(oftType).toEqual(OftType.LockUnlock);
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
it('Deploy Mint/Burn OFT', async () => {
|
|
191
|
-
mintBurnOftClient = await deployContract<
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
mintBurnOftClient = await deployContract<OFTClient>(
|
|
192
|
+
OFTClient,
|
|
193
|
+
OFT_WASM_PATH,
|
|
194
194
|
{
|
|
195
195
|
token: oftTokenAddress,
|
|
196
196
|
owner: DEFAULT_DEPLOYER.publicKey(),
|
|
197
197
|
endpoint: protocolAddresses.endpointV2,
|
|
198
198
|
delegate: DEFAULT_DEPLOYER.publicKey(),
|
|
199
199
|
shared_decimals: SHARED_DECIMALS,
|
|
200
|
-
|
|
200
|
+
oft_type: OftType.MintBurn, // Mint/Burn mode
|
|
201
201
|
},
|
|
202
202
|
DEFAULT_DEPLOYER,
|
|
203
203
|
);
|
|
@@ -206,8 +206,8 @@ describe('OFT E2E Testing with SAC (SML)', async () => {
|
|
|
206
206
|
console.log('✅ Mint/Burn OFT deployed:', mintBurnOftAddress);
|
|
207
207
|
|
|
208
208
|
// Verify it's in mint/burn mode
|
|
209
|
-
const { result:
|
|
210
|
-
expect(
|
|
209
|
+
const { result: oftType } = await mintBurnOftClient.oft_type();
|
|
210
|
+
expect(oftType).toEqual(OftType.MintBurn);
|
|
211
211
|
});
|
|
212
212
|
});
|
|
213
213
|
|
package/sdk/turbo.json
ADDED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
use anyhow::Result;
|
|
2
|
+
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
|
|
3
|
+
use sha2::{Digest, Sha256};
|
|
2
4
|
use soroban_spec_typescript::generate_from_file;
|
|
3
5
|
use std::{fs, path::Path};
|
|
4
6
|
|
|
@@ -37,6 +39,44 @@ export type MigrationData = void;
|
|
|
37
39
|
"#
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/// Generate embedded WASM code section
|
|
43
|
+
fn generate_wasm_embed(wasm_bytes: &[u8]) -> String {
|
|
44
|
+
// Compute SHA-256 hash (this is what Stellar uses for wasmHash)
|
|
45
|
+
let wasm_hash = Sha256::digest(wasm_bytes);
|
|
46
|
+
let wasm_hash_hex = format!("{:x}", wasm_hash);
|
|
47
|
+
|
|
48
|
+
// Base64 encode the WASM bytes
|
|
49
|
+
let wasm_base64 = BASE64.encode(wasm_bytes);
|
|
50
|
+
|
|
51
|
+
format!(
|
|
52
|
+
r#"/**
|
|
53
|
+
* Embedded WASM bytecode (base64-encoded)
|
|
54
|
+
* Size: {} bytes ({:.2} KB)
|
|
55
|
+
*/
|
|
56
|
+
export const WASM_BASE64 = "{}";
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Pre-computed WASM hash (SHA-256)
|
|
60
|
+
* Use this when the WASM is already uploaded on-chain
|
|
61
|
+
*/
|
|
62
|
+
export const WASM_HASH = "{}";
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get the WASM bytecode as a Buffer
|
|
66
|
+
* Use this to upload the WASM to the network
|
|
67
|
+
*/
|
|
68
|
+
export function getWasmBuffer(): Buffer {{
|
|
69
|
+
return Buffer.from(WASM_BASE64, 'base64');
|
|
70
|
+
}}
|
|
71
|
+
|
|
72
|
+
"#,
|
|
73
|
+
wasm_bytes.len(),
|
|
74
|
+
wasm_bytes.len() as f64 / 1024.0,
|
|
75
|
+
wasm_base64,
|
|
76
|
+
wasm_hash_hex
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
40
80
|
fn main() -> Result<()> {
|
|
41
81
|
println!("🚀 Generating TypeScript bindings for Stellar contracts...\n");
|
|
42
82
|
|
|
@@ -63,7 +103,7 @@ fn main() -> Result<()> {
|
|
|
63
103
|
("price_feed", "price_feed.ts"),
|
|
64
104
|
// OApp contracts
|
|
65
105
|
("counter", "counter.ts"),
|
|
66
|
-
("
|
|
106
|
+
("oft", "oft.ts"),
|
|
67
107
|
// Add more contracts here as needed:
|
|
68
108
|
];
|
|
69
109
|
|
|
@@ -89,6 +129,13 @@ fn main() -> Result<()> {
|
|
|
89
129
|
continue;
|
|
90
130
|
}
|
|
91
131
|
|
|
132
|
+
// Read WASM bytes for embedding
|
|
133
|
+
let wasm_bytes = fs::read(&wasm_path)?;
|
|
134
|
+
println!(" WASM size: {} bytes ({:.2} KB)", wasm_bytes.len(), wasm_bytes.len() as f64 / 1024.0);
|
|
135
|
+
|
|
136
|
+
// Generate the embedded WASM section
|
|
137
|
+
let wasm_embed = generate_wasm_embed(&wasm_bytes);
|
|
138
|
+
|
|
92
139
|
// Generate TypeScript bindings
|
|
93
140
|
println!(" Generating bindings...");
|
|
94
141
|
let wasm_path_str =
|
|
@@ -132,8 +179,8 @@ fn main() -> Result<()> {
|
|
|
132
179
|
}"#,
|
|
133
180
|
);
|
|
134
181
|
|
|
135
|
-
// Combine imports header
|
|
136
|
-
let complete_code = format!("{}{}", generate_imports_header(), ts_code);
|
|
182
|
+
// Combine imports header + embedded WASM + generated code
|
|
183
|
+
let complete_code = format!("{}{}{}", generate_imports_header(), wasm_embed, ts_code);
|
|
137
184
|
|
|
138
185
|
// Write to contract-specific TypeScript file
|
|
139
186
|
fs::write(&output_file, &complete_code)?;
|
|
@@ -145,7 +192,7 @@ fn main() -> Result<()> {
|
|
|
145
192
|
}
|
|
146
193
|
|
|
147
194
|
println!("\n✅ TypeScript binding generation complete!");
|
|
148
|
-
println!(" Generated {} contract(s)", generated_contracts.len());
|
|
195
|
+
println!(" Generated {} contract(s) with embedded WASM", generated_contracts.len());
|
|
149
196
|
|
|
150
197
|
if generated_contracts.is_empty() {
|
|
151
198
|
println!("\n💡 Tip: Build your contracts first before generating bindings:");
|
package/turbo.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
use soroban_sdk::{contractclient, Address, Env};
|
|
2
|
-
|
|
3
|
-
/// Contract interface for mint and burn token operations.
|
|
4
|
-
///
|
|
5
|
-
/// This interface abstracts the token mint/burn functionality, allowing different
|
|
6
|
-
/// token implementations (e.g., StellarAssetContract, custom tokens) to be used
|
|
7
|
-
/// with the MintBurn OFT.
|
|
8
|
-
#[contractclient(name = "MintBurnTokenClient")]
|
|
9
|
-
pub trait MintBurnToken {
|
|
10
|
-
/// Mints tokens to the specified address.
|
|
11
|
-
///
|
|
12
|
-
/// # Parameters
|
|
13
|
-
/// * `to` - The address to mint tokens to
|
|
14
|
-
/// * `amount` - The amount of tokens to mint (must be non-negative)
|
|
15
|
-
fn mint(env: Env, to: Address, amount: i128);
|
|
16
|
-
|
|
17
|
-
/// Burns tokens from the specified address.
|
|
18
|
-
///
|
|
19
|
-
/// # Parameters
|
|
20
|
-
/// * `from` - The address to burn tokens from
|
|
21
|
-
/// * `amount` - The amount of tokens to burn (must be non-negative)
|
|
22
|
-
fn burn(env: Env, from: Address, amount: i128);
|
|
23
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
//! Default OFT implementations.
|
|
2
|
-
//!
|
|
3
|
-
//! This module provides default standalone functions for common OFT operations that can be
|
|
4
|
-
//! reused by trait implementations.
|
|
5
|
-
|
|
6
|
-
use crate::{
|
|
7
|
-
codec::{oft_compose_msg_codec::OFTComposeMsg, oft_msg_codec::OFTMessage},
|
|
8
|
-
errors::OFTError,
|
|
9
|
-
events::{self, OFTSent},
|
|
10
|
-
oft::{OFTInternal, OFT},
|
|
11
|
-
storage::OFTStorage,
|
|
12
|
-
types::{self, OFTFeeDetail, OFTLimit, OFTReceipt, SendParam},
|
|
13
|
-
utils,
|
|
14
|
-
};
|
|
15
|
-
use ::utils::{option_ext::OptionExt, ownable::OwnableInitializer};
|
|
16
|
-
use endpoint_v2::{MessagingComposerClient, MessagingFee, MessagingReceipt, Origin};
|
|
17
|
-
use oapp::{oapp_core::initialize_oapp, oapp_options_type3::OAppOptionsType3};
|
|
18
|
-
use soroban_sdk::{assert_with_error, token::TokenClient, vec, Address, Bytes, BytesN, Env, Vec};
|
|
19
|
-
|
|
20
|
-
/// Initializes the OFT contract with token, endpoint, and decimal configuration.
|
|
21
|
-
/// The `shared_decimals` must be <= token's local decimals.
|
|
22
|
-
pub fn initialize_oft<T: OFT + OwnableInitializer>(
|
|
23
|
-
env: &Env,
|
|
24
|
-
owner: &Address,
|
|
25
|
-
token: &Address,
|
|
26
|
-
endpoint: &Address,
|
|
27
|
-
delegate: &Option<Address>,
|
|
28
|
-
shared_decimals: u32,
|
|
29
|
-
) {
|
|
30
|
-
// Initialize OApp (includes owner initialization)
|
|
31
|
-
initialize_oapp::<T>(env, owner, endpoint, delegate);
|
|
32
|
-
|
|
33
|
-
let local_decimals = TokenClient::new(env, token).decimals();
|
|
34
|
-
assert_with_error!(env, local_decimals >= shared_decimals, OFTError::InvalidLocalDecimals);
|
|
35
|
-
|
|
36
|
-
// Initialize OFT storage
|
|
37
|
-
OFTStorage::set_token(env, token);
|
|
38
|
-
OFTStorage::set_decimal_conversion_rate(env, &10_i128.pow(local_decimals - shared_decimals));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/// Simulates a debit operation without executing, used for quoting.
|
|
42
|
-
///
|
|
43
|
-
/// # Arguments
|
|
44
|
-
/// * `amount_ld` - The amount of tokens to send in local decimals
|
|
45
|
-
/// * `min_amount_ld` - The minimum amount to send in local decimals (slippage protection)
|
|
46
|
-
/// * `dst_eid` - The destination chain ID (unused in default implementation)
|
|
47
|
-
///
|
|
48
|
-
/// # Returns
|
|
49
|
-
/// `OFTReceipt` containing the amount sent and amount received after dust removal
|
|
50
|
-
pub fn debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, _dst_eid: u32) -> OFTReceipt {
|
|
51
|
-
let conversion_rate = OFTStorage::decimal_conversion_rate(env).unwrap_or_panic(env, OFTError::NotInitialized);
|
|
52
|
-
let amount_sent_ld = utils::remove_dust(amount_ld, conversion_rate);
|
|
53
|
-
let amount_received_ld = amount_sent_ld;
|
|
54
|
-
|
|
55
|
-
assert_with_error!(env, amount_received_ld >= min_amount_ld, OFTError::SlippageExceeded);
|
|
56
|
-
|
|
57
|
-
OFTReceipt { amount_sent_ld, amount_received_ld }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/// Builds the OFT message payload and combines enforced options for cross-chain transfer.
|
|
61
|
-
///
|
|
62
|
-
/// # Arguments
|
|
63
|
-
/// * `from` - The address initiating the transfer
|
|
64
|
-
/// * `send_param` - The send parameters including destination, recipient, and options
|
|
65
|
-
/// * `receive_amount_ld` - The amount to be received in local decimals (after dust removal)
|
|
66
|
-
///
|
|
67
|
-
/// # Returns
|
|
68
|
-
/// A tuple of (encoded message, combined options)
|
|
69
|
-
pub fn build_msg_and_options<T: OAppOptionsType3>(
|
|
70
|
-
env: &Env,
|
|
71
|
-
from: &Address,
|
|
72
|
-
send_param: &SendParam,
|
|
73
|
-
receive_amount_ld: i128,
|
|
74
|
-
) -> (Bytes, Bytes) {
|
|
75
|
-
let has_compose = !send_param.compose_msg.is_empty();
|
|
76
|
-
let conversion_rate = OFTStorage::decimal_conversion_rate(env).unwrap_or_panic(env, OFTError::NotInitialized);
|
|
77
|
-
let (msg, _) = OFTMessage {
|
|
78
|
-
send_to: send_param.to.clone(),
|
|
79
|
-
amount_sd: utils::to_sd(env, receive_amount_ld, conversion_rate),
|
|
80
|
-
compose_from: if has_compose { Some(utils::address_to_bytes32(from)) } else { None },
|
|
81
|
-
compose_msg: if has_compose { Some(send_param.compose_msg.clone()) } else { None },
|
|
82
|
-
}
|
|
83
|
-
.encode(env);
|
|
84
|
-
let msg_type = if has_compose { types::SEND_AND_CALL } else { types::SEND };
|
|
85
|
-
|
|
86
|
-
(msg, T::combine_options(env, send_param.dst_eid, msg_type, &send_param.extra_options))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/// Quotes an OFT transfer without executing.
|
|
90
|
-
///
|
|
91
|
-
/// # Arguments
|
|
92
|
-
/// * `send_param` - The send parameters to quote
|
|
93
|
-
///
|
|
94
|
-
/// # Returns
|
|
95
|
-
/// A tuple of (transfer limits, fee details, estimated receipt)
|
|
96
|
-
pub fn quote_oft<T: OFTInternal>(env: &Env, send_param: &SendParam) -> (OFTLimit, Vec<OFTFeeDetail>, OFTReceipt) {
|
|
97
|
-
let limit = OFTLimit { min_amount_ld: 0, max_amount_ld: i128::MAX }; // No limits in default implementation
|
|
98
|
-
let fee_details = vec![env]; // No fee details in default implementation
|
|
99
|
-
let oft_receipt = T::__debit_view(env, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
|
|
100
|
-
(limit, fee_details, oft_receipt)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/// Quotes the LayerZero messaging fee for a send operation.
|
|
104
|
-
///
|
|
105
|
-
/// # Arguments
|
|
106
|
-
/// * `from` - The address initiating the transfer
|
|
107
|
-
/// * `send_param` - The send parameters to quote
|
|
108
|
-
/// * `pay_in_zro` - Whether to pay the fee in ZRO token
|
|
109
|
-
///
|
|
110
|
-
/// # Returns
|
|
111
|
-
/// The messaging fee required for the transfer
|
|
112
|
-
pub fn quote_send<T: OFT>(env: &Env, from: &Address, send_param: &SendParam, pay_in_zro: bool) -> MessagingFee {
|
|
113
|
-
let OFTReceipt { amount_received_ld, .. } =
|
|
114
|
-
T::__debit_view(env, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
|
|
115
|
-
|
|
116
|
-
let (msg, options) = build_msg_and_options::<T>(env, from, send_param, amount_received_ld);
|
|
117
|
-
T::__quote(env, send_param.dst_eid, &msg, &options, pay_in_zro)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/// Executes a cross-chain token transfer via LayerZero.
|
|
121
|
-
///
|
|
122
|
-
/// Debits tokens from the `from` address, builds the message, and sends via the endpoint.
|
|
123
|
-
/// The `from` address must be authenticated.
|
|
124
|
-
///
|
|
125
|
-
/// # Arguments
|
|
126
|
-
/// * `from` - The address sending tokens (must authorize)
|
|
127
|
-
/// * `send_param` - The send parameters (destination, recipient, amount, options)
|
|
128
|
-
/// * `fee` - The messaging fee to pay
|
|
129
|
-
/// * `refund_address` - The address to refund excess fees to
|
|
130
|
-
///
|
|
131
|
-
/// # Returns
|
|
132
|
-
/// A tuple of (messaging receipt, OFT receipt with amounts)
|
|
133
|
-
pub fn send<T: OFT>(
|
|
134
|
-
env: &Env,
|
|
135
|
-
from: &Address,
|
|
136
|
-
send_param: &SendParam,
|
|
137
|
-
fee: &MessagingFee,
|
|
138
|
-
refund_address: &Address,
|
|
139
|
-
) -> (MessagingReceipt, OFTReceipt) {
|
|
140
|
-
from.require_auth();
|
|
141
|
-
|
|
142
|
-
let oft_receipt = T::__debit(env, from, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
|
|
143
|
-
|
|
144
|
-
let (msg, options) = build_msg_and_options::<T>(env, from, send_param, oft_receipt.amount_received_ld);
|
|
145
|
-
let msg_receipt = T::__lz_send(env, send_param.dst_eid, &msg, &options, from, fee, refund_address);
|
|
146
|
-
|
|
147
|
-
OFTSent {
|
|
148
|
-
guid: msg_receipt.guid.clone(),
|
|
149
|
-
dst_eid: send_param.dst_eid,
|
|
150
|
-
from: from.clone(),
|
|
151
|
-
amount_sent_ld: oft_receipt.amount_sent_ld,
|
|
152
|
-
amount_received_ld: oft_receipt.amount_received_ld,
|
|
153
|
-
}
|
|
154
|
-
.publish(env);
|
|
155
|
-
|
|
156
|
-
(msg_receipt, oft_receipt)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/// Handles incoming cross-chain OFT transfer from LayerZero endpoint.
|
|
160
|
-
///
|
|
161
|
-
/// Credits tokens to the recipient and optionally queues a compose message.
|
|
162
|
-
///
|
|
163
|
-
/// # Arguments
|
|
164
|
-
/// * `executor` - The address of the executor handling the message (unused in default implementation)
|
|
165
|
-
/// * `origin` - The origin information (source chain, sender, nonce)
|
|
166
|
-
/// * `guid` - The unique message identifier
|
|
167
|
-
/// * `message` - The encoded OFT message payload
|
|
168
|
-
/// * `extra_data` - Additional data (unused in default implementation)
|
|
169
|
-
/// * `value` - The native token value sent with the message (unused in default implementation)
|
|
170
|
-
pub fn lz_receive<T: OFTInternal>(
|
|
171
|
-
env: &Env,
|
|
172
|
-
_executor: &Address,
|
|
173
|
-
origin: &Origin,
|
|
174
|
-
guid: &BytesN<32>,
|
|
175
|
-
message: &Bytes,
|
|
176
|
-
_extra_data: &Bytes,
|
|
177
|
-
_value: i128,
|
|
178
|
-
) {
|
|
179
|
-
let oft_msg = OFTMessage::decode(message);
|
|
180
|
-
let send_to = utils::resolve_address(env, &oft_msg.send_to);
|
|
181
|
-
|
|
182
|
-
let conversion_rate = OFTStorage::decimal_conversion_rate(env).unwrap_or_panic(env, OFTError::NotInitialized);
|
|
183
|
-
let amount_received_ld =
|
|
184
|
-
T::__credit(env, &send_to, utils::to_ld(oft_msg.amount_sd, conversion_rate), origin.src_eid);
|
|
185
|
-
|
|
186
|
-
if oft_msg.is_composed() {
|
|
187
|
-
let compose_msg = OFTComposeMsg {
|
|
188
|
-
nonce: origin.nonce,
|
|
189
|
-
src_eid: origin.src_eid,
|
|
190
|
-
amount_ld: amount_received_ld,
|
|
191
|
-
compose_from: oft_msg.compose_from.unwrap(),
|
|
192
|
-
compose_msg: oft_msg.compose_msg.unwrap(),
|
|
193
|
-
}
|
|
194
|
-
.encode(env);
|
|
195
|
-
|
|
196
|
-
let endpoint_client = MessagingComposerClient::new(env, &T::endpoint(env));
|
|
197
|
-
endpoint_client.send_compose(&env.current_contract_address(), &send_to, guid, &0, &compose_msg);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
events::OFTReceived { guid: guid.clone(), src_eid: origin.src_eid, to: send_to, amount_received_ld }.publish(env);
|
|
201
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//! Extension tests module.
|
|
2
|
-
//!
|
|
3
|
-
//! This module contains tests for OFT extensions (pausable, oft_fee, rate_limiter).
|
|
4
|
-
|
|
5
|
-
pub mod setup;
|
|
6
|
-
pub mod test_oft_fee;
|
|
7
|
-
pub mod test_pausable;
|
|
8
|
-
pub mod test_rate_limiter;
|
|
9
|
-
|
|
10
|
-
// Re-export commonly used items for convenience
|
|
11
|
-
pub use setup::{ExtensiveOFT, ExtensiveOFTClient, ExtensiveOFTTestSetup};
|