@layerzerolabs/lz-solana-sdk-v2 3.0.135 → 3.0.137-sui.0
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 +26 -0
- package/dist/{index-CvZUDmni.d.mts → index-Cl-ICwDK.d.mts} +6 -6
- package/dist/{index-CvZUDmni.d.ts → index-Cl-ICwDK.d.ts} +6 -6
- package/dist/index.cjs +35 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +36 -27
- package/dist/index.mjs.map +1 -1
- package/dist/umi.cjs +18 -17
- package/dist/umi.cjs.map +1 -1
- package/dist/umi.d.mts +1 -1
- package/dist/umi.d.ts +1 -1
- package/dist/umi.mjs +18 -17
- package/dist/umi.mjs.map +1 -1
- package/package.json +9 -9
- package/src/solita/utility.ts +23 -12
- package/src/utility.ts +29 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/lz-solana-sdk-v2",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.137-sui.0",
|
|
4
4
|
"license": "BUSL-1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"test-uln": "TEST_SCOPES=uln anchor test --skip-build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@layerzerolabs/lz-corekit-solana": "^3.0.
|
|
43
|
-
"@layerzerolabs/lz-definitions": "^3.0.
|
|
44
|
-
"@layerzerolabs/lz-foundation": "^3.0.
|
|
45
|
-
"@layerzerolabs/lz-serdes": "^3.0.
|
|
46
|
-
"@layerzerolabs/lz-utilities": "^3.0.
|
|
47
|
-
"@layerzerolabs/lz-v2-utilities": "^3.0.
|
|
42
|
+
"@layerzerolabs/lz-corekit-solana": "^3.0.137-sui.0",
|
|
43
|
+
"@layerzerolabs/lz-definitions": "^3.0.137-sui.0",
|
|
44
|
+
"@layerzerolabs/lz-foundation": "^3.0.137-sui.0",
|
|
45
|
+
"@layerzerolabs/lz-serdes": "^3.0.137-sui.0",
|
|
46
|
+
"@layerzerolabs/lz-utilities": "^3.0.137-sui.0",
|
|
47
|
+
"@layerzerolabs/lz-v2-utilities": "^3.0.137-sui.0",
|
|
48
48
|
"@metaplex-foundation/beet": "^0.7.1",
|
|
49
49
|
"@metaplex-foundation/beet-solana": "^0.4.0",
|
|
50
50
|
"@metaplex-foundation/mpl-toolbox": "^0.9.2",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"@kinobi-so/renderers": "^0.21.3",
|
|
68
68
|
"@kinobi-so/renderers-js-umi": "^0.21.6",
|
|
69
69
|
"@layerzerolabs/layerzero-v2-solana": "^0.0.0",
|
|
70
|
-
"@layerzerolabs/tsup-config-next": "^3.0.
|
|
71
|
-
"@layerzerolabs/typescript-config-next": "^3.0.
|
|
70
|
+
"@layerzerolabs/tsup-config-next": "^3.0.137-sui.0",
|
|
71
|
+
"@layerzerolabs/typescript-config-next": "^3.0.137-sui.0",
|
|
72
72
|
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
|
|
73
73
|
"@types/bn.js": "^5.1.5",
|
|
74
74
|
"@types/chai": "^4.3.11",
|
package/src/solita/utility.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as beet from '@metaplex-foundation/beet'
|
|
2
2
|
import {
|
|
3
|
+
AddressLookupTableAccount,
|
|
3
4
|
AddressLookupTableProgram,
|
|
4
5
|
Blockhash,
|
|
5
6
|
CloseLookupTableParams,
|
|
@@ -365,7 +366,7 @@ export function closeLookupTable(
|
|
|
365
366
|
* @param {PublicKey} payer - The payer public key.
|
|
366
367
|
* @param {TransactionInstruction[]} instructions - The transaction instructions.
|
|
367
368
|
* @param {Blockhash} [recentBlockHash] - The recent block hash.
|
|
368
|
-
* @param {PublicKey} [
|
|
369
|
+
* @param {PublicKey} [_tableAddrs] - The array of address lookup table public keys.
|
|
369
370
|
* @returns {Promise<VersionedTransaction>} A promise that resolves to the versioned transaction.
|
|
370
371
|
*/
|
|
371
372
|
export async function txWithAddressLookupTable(
|
|
@@ -373,10 +374,10 @@ export async function txWithAddressLookupTable(
|
|
|
373
374
|
payer: PublicKey,
|
|
374
375
|
instructions: TransactionInstruction[],
|
|
375
376
|
recentBlockHash?: Blockhash,
|
|
376
|
-
|
|
377
|
+
_tableAddrs?: PublicKey | PublicKey[]
|
|
377
378
|
): Promise<VersionedTransaction> {
|
|
378
379
|
recentBlockHash = recentBlockHash ?? (await connection.getLatestBlockhash()).blockhash
|
|
379
|
-
if (!
|
|
380
|
+
if (!_tableAddrs) {
|
|
380
381
|
return new VersionedTransaction(
|
|
381
382
|
new TransactionMessage({
|
|
382
383
|
instructions,
|
|
@@ -385,13 +386,23 @@ export async function txWithAddressLookupTable(
|
|
|
385
386
|
}).compileToV0Message()
|
|
386
387
|
)
|
|
387
388
|
}
|
|
388
|
-
const
|
|
389
|
+
const tableAddrs = Array.isArray(_tableAddrs) ? _tableAddrs : [_tableAddrs]
|
|
390
|
+
const lookupTableAccountsResult = await connection.getMultipleAccountsInfo(tableAddrs)
|
|
391
|
+
const lookupTableAccounts = lookupTableAccountsResult
|
|
392
|
+
.map((result, index) => {
|
|
393
|
+
if (result === null) return null
|
|
394
|
+
return new AddressLookupTableAccount({
|
|
395
|
+
key: tableAddrs[index],
|
|
396
|
+
state: AddressLookupTableAccount.deserialize(result.data),
|
|
397
|
+
})
|
|
398
|
+
})
|
|
399
|
+
.filter((account): account is AddressLookupTableAccount => account !== null)
|
|
389
400
|
return new VersionedTransaction(
|
|
390
401
|
new TransactionMessage({
|
|
391
402
|
instructions,
|
|
392
403
|
payerKey: payer,
|
|
393
404
|
recentBlockhash: recentBlockHash,
|
|
394
|
-
}).compileToV0Message(
|
|
405
|
+
}).compileToV0Message(lookupTableAccounts.length > 0 ? lookupTableAccounts : undefined)
|
|
395
406
|
)
|
|
396
407
|
}
|
|
397
408
|
|
|
@@ -519,7 +530,7 @@ export async function buildMessageV0(
|
|
|
519
530
|
* @param {TransactionInstruction[]} instructions - The transaction instructions.
|
|
520
531
|
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
521
532
|
* @param {Blockhash} [blockhash] - The blockhash.
|
|
522
|
-
* @param {PublicKey} [
|
|
533
|
+
* @param {PublicKey} [lookupTableAddresses] - The array of lookup table addresses.
|
|
523
534
|
* @returns {Promise<VersionedTransaction>} A promise that resolves to the versioned transaction.
|
|
524
535
|
*/
|
|
525
536
|
export async function buildVersionedTransaction(
|
|
@@ -528,10 +539,10 @@ export async function buildVersionedTransaction(
|
|
|
528
539
|
instructions: TransactionInstruction[],
|
|
529
540
|
commitmentOrConfig: Commitment | GetAccountInfoConfig = 'confirmed',
|
|
530
541
|
blockhash?: Blockhash,
|
|
531
|
-
|
|
542
|
+
lookupTableAddresses?: PublicKey | PublicKey[]
|
|
532
543
|
): Promise<VersionedTransaction> {
|
|
533
|
-
if (
|
|
534
|
-
return txWithAddressLookupTable(connection, payerKey, instructions, blockhash,
|
|
544
|
+
if (lookupTableAddresses) {
|
|
545
|
+
return txWithAddressLookupTable(connection, payerKey, instructions, blockhash, lookupTableAddresses)
|
|
535
546
|
}
|
|
536
547
|
return new VersionedTransaction(
|
|
537
548
|
await buildMessageV0(connection, payerKey, instructions, commitmentOrConfig, blockhash)
|
|
@@ -557,7 +568,7 @@ export function instructionDiscriminator(method: string): Buffer {
|
|
|
557
568
|
* @param {PublicKey} payer - The payer public key.
|
|
558
569
|
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
559
570
|
* @param {Blockhash} [blockhash] - The blockhash.
|
|
560
|
-
* @param {PublicKey} [
|
|
571
|
+
* @param {PublicKey} [lookupTableAddresses] - The array of lookup table addresses.
|
|
561
572
|
* @returns {Promise<Buffer>} A promise that resolves to the simulation result.
|
|
562
573
|
* @throws {Error} If the simulation fails.
|
|
563
574
|
*/
|
|
@@ -568,7 +579,7 @@ export async function simulateTransaction(
|
|
|
568
579
|
payer: PublicKey,
|
|
569
580
|
commitment: Commitment = 'confirmed',
|
|
570
581
|
blockhash?: Blockhash,
|
|
571
|
-
|
|
582
|
+
lookupTableAddresses?: PublicKey | PublicKey[]
|
|
572
583
|
): Promise<Buffer> {
|
|
573
584
|
const tx = await buildVersionedTransaction(
|
|
574
585
|
connection,
|
|
@@ -576,7 +587,7 @@ export async function simulateTransaction(
|
|
|
576
587
|
instructions,
|
|
577
588
|
commitment,
|
|
578
589
|
blockhash,
|
|
579
|
-
|
|
590
|
+
lookupTableAddresses
|
|
580
591
|
)
|
|
581
592
|
const simulateResp = await connection.simulateTransaction(tx, { sigVerify: false, commitment })
|
|
582
593
|
const returnPrefix = `Program return: ${programId.toBase58()} `
|
package/src/utility.ts
CHANGED
|
@@ -360,7 +360,7 @@ export function closeLookupTable(
|
|
|
360
360
|
* @param {PublicKey} payer - The payer public key.
|
|
361
361
|
* @param {TransactionInstruction[]} instructions - The transaction instructions.
|
|
362
362
|
* @param {Blockhash} [recentBlockHash] - The recent block hash.
|
|
363
|
-
* @param {PublicKey} [
|
|
363
|
+
* @param {PublicKey} [_tableAddrs] - The array of address lookup table public keys.
|
|
364
364
|
* @returns {Promise<VersionedTransaction>} A promise that resolves to the versioned transaction.
|
|
365
365
|
*/
|
|
366
366
|
export async function txWithAddressLookupTable(
|
|
@@ -368,10 +368,10 @@ export async function txWithAddressLookupTable(
|
|
|
368
368
|
payer: web3.PublicKey,
|
|
369
369
|
instructions: web3.TransactionInstruction[],
|
|
370
370
|
recentBlockHash?: web3.Blockhash,
|
|
371
|
-
|
|
371
|
+
_tableAddrs?: web3.PublicKey | web3.PublicKey[]
|
|
372
372
|
): Promise<web3.VersionedTransaction> {
|
|
373
373
|
recentBlockHash = recentBlockHash ?? (await connection.getLatestBlockhash()).blockhash
|
|
374
|
-
if (!
|
|
374
|
+
if (!_tableAddrs) {
|
|
375
375
|
return new web3.VersionedTransaction(
|
|
376
376
|
new web3.TransactionMessage({
|
|
377
377
|
instructions,
|
|
@@ -380,13 +380,23 @@ export async function txWithAddressLookupTable(
|
|
|
380
380
|
}).compileToV0Message()
|
|
381
381
|
)
|
|
382
382
|
}
|
|
383
|
-
const
|
|
383
|
+
const tableAddrs = Array.isArray(_tableAddrs) ? _tableAddrs : [_tableAddrs]
|
|
384
|
+
const lookupTableAccountsResult = await connection.getMultipleAccountsInfo(tableAddrs)
|
|
385
|
+
const lookupTableAccounts = lookupTableAccountsResult
|
|
386
|
+
.map((result, index) => {
|
|
387
|
+
if (result === null) return null
|
|
388
|
+
return new web3.AddressLookupTableAccount({
|
|
389
|
+
key: tableAddrs[index],
|
|
390
|
+
state: web3.AddressLookupTableAccount.deserialize(result.data),
|
|
391
|
+
})
|
|
392
|
+
})
|
|
393
|
+
.filter((account): account is web3.AddressLookupTableAccount => account !== null)
|
|
384
394
|
return new web3.VersionedTransaction(
|
|
385
395
|
new web3.TransactionMessage({
|
|
386
396
|
instructions,
|
|
387
397
|
payerKey: payer,
|
|
388
398
|
recentBlockhash: recentBlockHash,
|
|
389
|
-
}).compileToV0Message(
|
|
399
|
+
}).compileToV0Message(lookupTableAccounts.length > 0 ? lookupTableAccounts : undefined)
|
|
390
400
|
)
|
|
391
401
|
}
|
|
392
402
|
|
|
@@ -514,7 +524,7 @@ export async function buildMessageV0(
|
|
|
514
524
|
* @param {TransactionInstruction[]} instructions - The transaction instructions.
|
|
515
525
|
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
516
526
|
* @param {Blockhash} [blockhash] - The blockhash.
|
|
517
|
-
* @param {PublicKey} [
|
|
527
|
+
* @param {PublicKey} [lookupTableAddresses] - The array of lookup table addresses.
|
|
518
528
|
* @returns {Promise<VersionedTransaction>} A promise that resolves to the versioned transaction.
|
|
519
529
|
*/
|
|
520
530
|
export async function buildVersionedTransaction(
|
|
@@ -523,10 +533,10 @@ export async function buildVersionedTransaction(
|
|
|
523
533
|
instructions: web3.TransactionInstruction[],
|
|
524
534
|
commitmentOrConfig: web3.Commitment | web3.GetAccountInfoConfig = 'confirmed',
|
|
525
535
|
blockhash?: web3.Blockhash,
|
|
526
|
-
|
|
536
|
+
lookupTableAddresses?: web3.PublicKey | web3.PublicKey[]
|
|
527
537
|
): Promise<web3.VersionedTransaction> {
|
|
528
|
-
if (
|
|
529
|
-
return txWithAddressLookupTable(connection, payerKey, instructions, blockhash,
|
|
538
|
+
if (lookupTableAddresses) {
|
|
539
|
+
return txWithAddressLookupTable(connection, payerKey, instructions, blockhash, lookupTableAddresses)
|
|
530
540
|
}
|
|
531
541
|
return new web3.VersionedTransaction(
|
|
532
542
|
await buildMessageV0(connection, payerKey, instructions, commitmentOrConfig, blockhash)
|
|
@@ -553,7 +563,7 @@ export function instructionDiscriminator(method: string): Buffer {
|
|
|
553
563
|
* @param {Serializer<From, To>} serializer - The serializer.
|
|
554
564
|
* @param {web3.Commitment} [commitment='confirmed'] - The commitment level.
|
|
555
565
|
* @param {web3.Blockhash} [blockhash] - The blockhash.
|
|
556
|
-
* @param {web3.PublicKey | PublicKey} [
|
|
566
|
+
* @param {web3.PublicKey | PublicKey} [_lookupTableAddresses] - The array of lookup table addresses.
|
|
557
567
|
* @returns {Promise<Buffer>} A promise that resolves to the simulation result.
|
|
558
568
|
* @throws {Error} If the simulation fails.
|
|
559
569
|
*/
|
|
@@ -565,7 +575,7 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
|
|
|
565
575
|
serializer: Serializer<From, To>,
|
|
566
576
|
commitment: web3.Commitment = 'confirmed',
|
|
567
577
|
blockhash?: web3.Blockhash,
|
|
568
|
-
|
|
578
|
+
_lookupTableAddresses?: web3.PublicKey | PublicKey | web3.PublicKey[] | PublicKey[]
|
|
569
579
|
): Promise<To> {
|
|
570
580
|
let connection: web3.Connection
|
|
571
581
|
if (typeof _connection === 'string') {
|
|
@@ -600,14 +610,13 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
|
|
|
600
610
|
payer = toWeb3JsPublicKey(_payer)
|
|
601
611
|
}
|
|
602
612
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
613
|
+
const lookupTableAddresses =
|
|
614
|
+
_lookupTableAddresses &&
|
|
615
|
+
(Array.isArray(_lookupTableAddresses)
|
|
616
|
+
? _lookupTableAddresses.map((addr) => (addr instanceof web3.PublicKey ? addr : toWeb3JsPublicKey(addr)))
|
|
617
|
+
: _lookupTableAddresses instanceof web3.PublicKey
|
|
618
|
+
? _lookupTableAddresses
|
|
619
|
+
: toWeb3JsPublicKey(_lookupTableAddresses))
|
|
611
620
|
|
|
612
621
|
const tx = await buildVersionedTransaction(
|
|
613
622
|
connection,
|
|
@@ -615,7 +624,7 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
|
|
|
615
624
|
instructions,
|
|
616
625
|
commitment,
|
|
617
626
|
blockhash,
|
|
618
|
-
|
|
627
|
+
lookupTableAddresses
|
|
619
628
|
)
|
|
620
629
|
const simulateResp = await connection.simulateTransaction(tx, { sigVerify: false, commitment })
|
|
621
630
|
const returnPrefix = `Program return: ${programId.toBase58()} `
|