@layerzerolabs/ton-sdk-tools 3.0.28 → 3.0.29
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +3 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -297,7 +297,7 @@ function parseDeclareLines(input, fieldMap) {
|
|
|
297
297
|
function parseFieldNames(strInput) {
|
|
298
298
|
const fieldMap = {};
|
|
299
299
|
const inverseFieldMap = {};
|
|
300
|
-
const regex = /^const\s+int\s+(?:[A-Za-z]+::)?[A-Za-z]\w+::(
|
|
300
|
+
const regex = /^const\s+int\s+(?:[A-Za-z]+::)?[A-Za-z]\w+::([A-Za-z0-9]+)\s*=\s*(\d+);/gm;
|
|
301
301
|
let match;
|
|
302
302
|
while ((match = regex.exec(strInput)) !== null) {
|
|
303
303
|
const [, fieldName, fieldIndexStr] = match;
|
|
@@ -3197,21 +3197,15 @@ import UlnManagerArtifact from '@layerzerolabs/layerzero-v2-ton/build/UlnManager
|
|
|
3197
3197
|
import { Profile, addressToBigInt, cellFromArtifact } from '@layerzerolabs/ton-sdk-tools'
|
|
3198
3198
|
|
|
3199
3199
|
import {
|
|
3200
|
-
ActionTypes,
|
|
3201
3200
|
OAppFixture,
|
|
3202
3201
|
OAppFlowGas,
|
|
3203
|
-
OutOfOrder,
|
|
3204
|
-
PacketInFlight,
|
|
3205
3202
|
ProtocolFixture,
|
|
3206
3203
|
SIGNATURE_BYTE_LENGTH,
|
|
3207
3204
|
addMsgLibToController,
|
|
3208
|
-
assertCommittableView,
|
|
3209
|
-
assertVerifiedView,
|
|
3210
3205
|
createLzPacketFromPacketEncoded,
|
|
3211
3206
|
createVerifierDictSet,
|
|
3212
3207
|
emptyObject,
|
|
3213
3208
|
generateRandomVerifierSet,
|
|
3214
|
-
lzReceiveAndExpect,
|
|
3215
3209
|
protocolSetupGas,
|
|
3216
3210
|
publicKeyToHash,
|
|
3217
3211
|
requireDefined,
|
|
@@ -3221,9 +3215,7 @@ import {
|
|
|
3221
3215
|
setDefaultEndpointConfig,
|
|
3222
3216
|
wireChannels,
|
|
3223
3217
|
} from './auto-utils-common'
|
|
3224
|
-
import { ExpectedCounts, assertInboundCount, assertOutboundCount, incrementCounterAndExpectULN } from './utils'
|
|
3225
3218
|
import {
|
|
3226
|
-
ERRORS,
|
|
3227
3219
|
ExtendedContract,
|
|
3228
3220
|
LzDict,
|
|
3229
3221
|
LzEventHandler,
|
|
@@ -3234,8 +3226,6 @@ import {
|
|
|
3234
3226
|
} from '../../src'
|
|
3235
3227
|
|
|
3236
3228
|
const ULN_MANAGER_DEFAULT_VERSION = BigInt(1)
|
|
3237
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3238
|
-
const ULN_MANAGER_CUSTOM_VERSION = BigInt(2)
|
|
3239
3229
|
|
|
3240
3230
|
export const TRUE = BigInt(-1)
|
|
3241
3231
|
export const FALSE = BigInt(0)
|
|
@@ -3321,211 +3311,6 @@ export function serializeDvns(dvnList: bigint[]): Cell {
|
|
|
3321
3311
|
return linkedList.endCell()
|
|
3322
3312
|
}
|
|
3323
3313
|
|
|
3324
|
-
// ================================Out of order helper functions================================
|
|
3325
|
-
|
|
3326
|
-
export async function generateFromPacketsInFlight(
|
|
3327
|
-
outOfOrder: OutOfOrder,
|
|
3328
|
-
fixtures: Map<bigint, OAppFixtureULN>,
|
|
3329
|
-
expectedCounts: Map<bigint, ExpectedCounts>,
|
|
3330
|
-
packetsInFlight: Map<bigint, PacketInFlight[]>,
|
|
3331
|
-
multiSigOwner1: SandboxContract<TreasuryContract>,
|
|
3332
|
-
eventHandler: LzEventHandler,
|
|
3333
|
-
profile?: Profile
|
|
3334
|
-
): Promise<PacketInFlight[]> {
|
|
3335
|
-
let fromPacketsInFlight: PacketInFlight[] | undefined = []
|
|
3336
|
-
|
|
3337
|
-
for (const action of outOfOrder.actions) {
|
|
3338
|
-
const fromEidBigInt = BigInt(action.fromEid)
|
|
3339
|
-
const fromFixture = fixtures.get(fromEidBigInt)
|
|
3340
|
-
const fromExpectedCounts = expectedCounts.get(fromEidBigInt)
|
|
3341
|
-
fromPacketsInFlight = packetsInFlight.get(fromEidBigInt)
|
|
3342
|
-
|
|
3343
|
-
if (!fromFixture || !fromExpectedCounts || !fromPacketsInFlight) {
|
|
3344
|
-
throw new Error('Fixture, ExpectedCount, or PacketsInFlight not found')
|
|
3345
|
-
}
|
|
3346
|
-
|
|
3347
|
-
const mdPacketSent = await incrementCounterAndExpectULN(
|
|
3348
|
-
{
|
|
3349
|
-
dstEid: action.toEid,
|
|
3350
|
-
actionType: ActionTypes[action.actionType],
|
|
3351
|
-
extraOptions: beginCell().endCell(),
|
|
3352
|
-
nativeFee: toNano('0.000006240'),
|
|
3353
|
-
zroFee: toNano('0'),
|
|
3354
|
-
},
|
|
3355
|
-
multiSigOwner1,
|
|
3356
|
-
eventHandler,
|
|
3357
|
-
fromFixture.msglibConnection,
|
|
3358
|
-
fromFixture,
|
|
3359
|
-
profile ?? undefined
|
|
3360
|
-
)
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
await assertOutboundCount(fromFixture.oApp, action.toEid, ++fromExpectedCounts.outbound)
|
|
3364
|
-
|
|
3365
|
-
fromPacketsInFlight.push({
|
|
3366
|
-
fromEid: action.fromEid,
|
|
3367
|
-
toEid: action.toEid,
|
|
3368
|
-
mdPacketSent,
|
|
3369
|
-
})
|
|
3370
|
-
}
|
|
3371
|
-
return fromPacketsInFlight
|
|
3372
|
-
}
|
|
3373
|
-
|
|
3374
|
-
export async function getRandomLzPacket(
|
|
3375
|
-
allStorages: SandboxContract<TonContractWrapper>,
|
|
3376
|
-
fromPacketsInFlight: PacketInFlight[],
|
|
3377
|
-
fixtures: Map<bigint, OAppFixtureULN>,
|
|
3378
|
-
expectedCounts: Map<bigint, ExpectedCounts>,
|
|
3379
|
-
pooos: Map<bigint, number[]>
|
|
3380
|
-
): Promise<{
|
|
3381
|
-
randomPacketIndex: number
|
|
3382
|
-
randomPacketInFlight: PacketInFlight
|
|
3383
|
-
toFixture: OAppFixtureULN
|
|
3384
|
-
toExpectedCounts: ExpectedCounts
|
|
3385
|
-
lzPacket: Cell
|
|
3386
|
-
toPooo: number[]
|
|
3387
|
-
}> {
|
|
3388
|
-
if (fromPacketsInFlight.length === 0) {
|
|
3389
|
-
throw new Error('No packets in flight available')
|
|
3390
|
-
}
|
|
3391
|
-
|
|
3392
|
-
const randomPacketIndex = Math.floor(Math.random() * fromPacketsInFlight.length)
|
|
3393
|
-
const randomPacketInFlight = fromPacketsInFlight[randomPacketIndex]
|
|
3394
|
-
|
|
3395
|
-
const toEidBigInt = BigInt(randomPacketInFlight.toEid)
|
|
3396
|
-
const toFixture = fixtures.get(toEidBigInt)
|
|
3397
|
-
const toExpectedCounts = expectedCounts.get(toEidBigInt)
|
|
3398
|
-
const toPooo = pooos.get(toEidBigInt)
|
|
3399
|
-
|
|
3400
|
-
if (!toFixture || !toExpectedCounts || !toPooo) {
|
|
3401
|
-
throw new Error('Fixture, ExpectedCount, or POOO not found')
|
|
3402
|
-
}
|
|
3403
|
-
|
|
3404
|
-
const lzPacket = await createLzPacketFromPacketEncoded(randomPacketInFlight.mdPacketSent.packetEncoded, allStorages)
|
|
3405
|
-
|
|
3406
|
-
return {
|
|
3407
|
-
randomPacketIndex,
|
|
3408
|
-
randomPacketInFlight,
|
|
3409
|
-
toFixture,
|
|
3410
|
-
toExpectedCounts,
|
|
3411
|
-
lzPacket,
|
|
3412
|
-
toPooo,
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
|
|
3416
|
-
export async function handleVerify(
|
|
3417
|
-
toFixture: OAppFixtureULN,
|
|
3418
|
-
randomPacketInFlight: PacketInFlight,
|
|
3419
|
-
lzPacket: Cell,
|
|
3420
|
-
allStorages: SandboxContract<TonContractWrapper>,
|
|
3421
|
-
eventHandler: LzEventHandler
|
|
3422
|
-
): Promise<void> {
|
|
3423
|
-
let isVerified = true
|
|
3424
|
-
for (const dvnFixture of toFixture.receiveDvnFixturesCustom) {
|
|
3425
|
-
const isVerifiedView = await assertVerifiedView(
|
|
3426
|
-
toFixture.msglibConnection,
|
|
3427
|
-
addressToBigInt(dvnFixture.proxy.address),
|
|
3428
|
-
randomPacketInFlight.mdPacketSent.nonce,
|
|
3429
|
-
BigInt('0x' + lzPacket.hash().toString('hex')),
|
|
3430
|
-
BigInt(1) // requiredConfirmations
|
|
3431
|
-
)
|
|
3432
|
-
|
|
3433
|
-
if (isVerifiedView == FALSE) {
|
|
3434
|
-
isVerified = false
|
|
3435
|
-
}
|
|
3436
|
-
}
|
|
3437
|
-
|
|
3438
|
-
if (!isVerified) {
|
|
3439
|
-
await ulnVerifyAndExpect(
|
|
3440
|
-
allStorages,
|
|
3441
|
-
randomPacketInFlight.mdPacketSent,
|
|
3442
|
-
toFixture,
|
|
3443
|
-
toFixture.receiveDvnFixturesCustom,
|
|
3444
|
-
toFixture.msglibManager,
|
|
3445
|
-
toFixture.msglibConnection,
|
|
3446
|
-
eventHandler
|
|
3447
|
-
)
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
|
|
3451
|
-
export async function handleCommit(
|
|
3452
|
-
toFixture: OAppFixtureULN,
|
|
3453
|
-
randomPacketInFlight: PacketInFlight,
|
|
3454
|
-
lzPacketWithGuid: Cell,
|
|
3455
|
-
multiSigOwner1: SandboxContract<TreasuryContract>,
|
|
3456
|
-
eventHandler: LzEventHandler
|
|
3457
|
-
): Promise<void> {
|
|
3458
|
-
const status = await assertCommittableView(
|
|
3459
|
-
toFixture.msglibConnection,
|
|
3460
|
-
randomPacketInFlight.mdPacketSent.nonce,
|
|
3461
|
-
lzPacketWithGuid,
|
|
3462
|
-
toFixture.defaultUlnReceiveConfig
|
|
3463
|
-
)
|
|
3464
|
-
|
|
3465
|
-
if (status == UlnConnectionVerificationStatusCommittable) {
|
|
3466
|
-
await commitVerificationAndExpect(lzPacketWithGuid, multiSigOwner1, eventHandler, toFixture)
|
|
3467
|
-
}
|
|
3468
|
-
}
|
|
3469
|
-
|
|
3470
|
-
export async function handleLzReceive(
|
|
3471
|
-
isExecutable: boolean,
|
|
3472
|
-
nonces: bigint[],
|
|
3473
|
-
toFixture: OAppFixtureULN,
|
|
3474
|
-
randomPacketInFlight: PacketInFlight,
|
|
3475
|
-
multiSigOwner1: SandboxContract<TreasuryContract>,
|
|
3476
|
-
allStorages: SandboxContract<TonContractWrapper>,
|
|
3477
|
-
lzReceivePrepareValue: bigint,
|
|
3478
|
-
eventHandler: LzEventHandler,
|
|
3479
|
-
toExpectedCounts: ExpectedCounts,
|
|
3480
|
-
randomPacketIndex: number | undefined,
|
|
3481
|
-
fromPacketsInFlight: PacketInFlight[] | undefined,
|
|
3482
|
-
totalPacketsDelivered?: number,
|
|
3483
|
-
opcode = OPCODES.Channel_OP_LZ_RECEIVE_PREPARE,
|
|
3484
|
-
profile?: Profile
|
|
3485
|
-
): Promise<number | undefined> {
|
|
3486
|
-
if (isExecutable) {
|
|
3487
|
-
for (const nonce of nonces) {
|
|
3488
|
-
await lzReceiveAndExpect({
|
|
3489
|
-
lzReceivePrepareMd: await allStorages.getNewMdLzReceivePrepare({
|
|
3490
|
-
nonce,
|
|
3491
|
-
nanotons: lzReceivePrepareValue,
|
|
3492
|
-
}),
|
|
3493
|
-
oAppFixture: toFixture,
|
|
3494
|
-
deployer: multiSigOwner1,
|
|
3495
|
-
eventHandler,
|
|
3496
|
-
profile,
|
|
3497
|
-
})
|
|
3498
|
-
await assertInboundCount(toFixture.oApp, randomPacketInFlight.fromEid, ++toExpectedCounts.inbound)
|
|
3499
|
-
if (totalPacketsDelivered !== undefined) totalPacketsDelivered++
|
|
3500
|
-
}
|
|
3501
|
-
if (fromPacketsInFlight && randomPacketIndex !== undefined) {
|
|
3502
|
-
fromPacketsInFlight.splice(randomPacketIndex, 1)
|
|
3503
|
-
}
|
|
3504
|
-
} else {
|
|
3505
|
-
await sendInternalMessageAndExpect({
|
|
3506
|
-
value: toNano('1'),
|
|
3507
|
-
sender: multiSigOwner1.getSender(),
|
|
3508
|
-
contract: toFixture.channel,
|
|
3509
|
-
opCode: opcode,
|
|
3510
|
-
md: await allStorages.getNewMdLzReceivePrepare({
|
|
3511
|
-
nonce: randomPacketInFlight.mdPacketSent.nonce,
|
|
3512
|
-
nanotons: lzReceivePrepareValue,
|
|
3513
|
-
}),
|
|
3514
|
-
expectedTransactions: [
|
|
3515
|
-
{
|
|
3516
|
-
from: multiSigOwner1.address,
|
|
3517
|
-
to: toFixture.channel.address,
|
|
3518
|
-
op: Number(opcode),
|
|
3519
|
-
exitCode: Number(ERRORS.Channel_ERROR_notExecutable),
|
|
3520
|
-
success: false,
|
|
3521
|
-
},
|
|
3522
|
-
],
|
|
3523
|
-
})
|
|
3524
|
-
await assertInboundCount(toFixture.oApp, randomPacketInFlight.fromEid, toExpectedCounts.inbound)
|
|
3525
|
-
}
|
|
3526
|
-
return totalPacketsDelivered
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3529
3314
|
// ==============================ULN INTEGRATION FUNCTIONS==============================
|
|
3530
3315
|
|
|
3531
3316
|
export async function commitVerificationAndExpect(
|
|
@@ -4647,7 +4432,7 @@ export async function wireFixtureWithUln(
|
|
|
4647
4432
|
md: await allStorages.getNewLzConfig({
|
|
4648
4433
|
path: srcFixture.path,
|
|
4649
4434
|
forwardingAddress: addressToBigInt(srcFixture.msglibManager.address),
|
|
4650
|
-
opCode: OPCODES.MsglibManager_OP_SET_OAPP_MSGLIB_SEND_CONFIG,
|
|
4435
|
+
opCode: OPCODES.MsglibManager_OP_SET_OAPP_MSGLIB_SEND_CONFIG as bigint,
|
|
4651
4436
|
config: ulnSendConfig,
|
|
4652
4437
|
}),
|
|
4653
4438
|
balanceRefill: toNano('1'),
|
|
@@ -4698,7 +4483,7 @@ export async function wireFixtureWithUln(
|
|
|
4698
4483
|
md: await allStorages.getNewLzConfig({
|
|
4699
4484
|
path: srcFixture.path,
|
|
4700
4485
|
forwardingAddress: addressToBigInt(srcFixture.msglibManager.address),
|
|
4701
|
-
opCode: OPCODES.MsglibManager_OP_SET_OAPP_MSGLIB_RECEIVE_CONFIG,
|
|
4486
|
+
opCode: OPCODES.MsglibManager_OP_SET_OAPP_MSGLIB_RECEIVE_CONFIG as bigint,
|
|
4702
4487
|
config: ulnReceiveConfig,
|
|
4703
4488
|
}),
|
|
4704
4489
|
balanceRefill: toNano('1'),
|