@layerzerolabs/lz-solana-sdk-v2 3.0.67 → 3.0.68

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/lz-solana-sdk-v2",
3
- "version": "3.0.67",
3
+ "version": "3.0.68",
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.67",
43
- "@layerzerolabs/lz-definitions": "^3.0.67",
44
- "@layerzerolabs/lz-foundation": "^3.0.67",
45
- "@layerzerolabs/lz-serdes": "^3.0.67",
46
- "@layerzerolabs/lz-utilities": "^3.0.67",
47
- "@layerzerolabs/lz-v2-utilities": "^3.0.67",
42
+ "@layerzerolabs/lz-corekit-solana": "^3.0.68",
43
+ "@layerzerolabs/lz-definitions": "^3.0.68",
44
+ "@layerzerolabs/lz-foundation": "^3.0.68",
45
+ "@layerzerolabs/lz-serdes": "^3.0.68",
46
+ "@layerzerolabs/lz-utilities": "^3.0.68",
47
+ "@layerzerolabs/lz-v2-utilities": "^3.0.68",
48
48
  "@metaplex-foundation/beet": "^0.7.1",
49
49
  "@metaplex-foundation/beet-solana": "^0.4.0",
50
50
  "@metaplex-foundation/umi": "^0.9.2",
@@ -66,8 +66,8 @@
66
66
  "@kinobi-so/renderers": "^0.21.3",
67
67
  "@kinobi-so/renderers-js-umi": "^0.21.6",
68
68
  "@layerzerolabs/layerzero-v2-solana": "^0.0.0",
69
- "@layerzerolabs/tsup-config-next": "^3.0.67",
70
- "@layerzerolabs/typescript-config-next": "^3.0.67",
69
+ "@layerzerolabs/tsup-config-next": "^3.0.68",
70
+ "@layerzerolabs/typescript-config-next": "^3.0.68",
71
71
  "@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
72
72
  "@types/bn.js": "^5.1.5",
73
73
  "@types/chai": "^4.3.11",
package/src/next_nonce.ts CHANGED
@@ -16,7 +16,7 @@ import { arrayify } from '@layerzerolabs/lz-utilities'
16
16
  import { Packet, addressToBytes32 } from '@layerzerolabs/lz-v2-utilities'
17
17
 
18
18
  import { EDDSA } from './pda'
19
- import { instructionDiscriminator, simulateWeb3JsTransaction } from './utility'
19
+ import { instructionDiscriminator, simulateWeb3JsTransaction, toWeb3Connection } from './utility'
20
20
 
21
21
  // Data.
22
22
  export interface NextNonceInstructionData {
@@ -61,14 +61,7 @@ export async function nextNonce(
61
61
  ): Promise<bigint> {
62
62
  const { sender: sender_, srcEid, receiver: receiver_ } = packet
63
63
  const receiver = new web3.PublicKey(addressToBytes32(receiver_))
64
- let connection: web3.Connection
65
- if (rpc instanceof web3.Connection) {
66
- connection = rpc
67
- } else if ('connection' in rpc && rpc.connection instanceof web3.Connection) {
68
- ;({ connection } = rpc)
69
- } else {
70
- throw new Error('Invalid connection')
71
- }
64
+ const connection = toWeb3Connection(rpc)
72
65
  const receiverInfo = await connection.getAccountInfo(receiver)
73
66
  if (receiverInfo === null) {
74
67
  throw new Error(`Receiver account not found: ${receiver.toBase58()}`)
package/src/utility.ts CHANGED
@@ -222,7 +222,7 @@ export async function extractWorkerFeePaidEventByTxHash(
222
222
  * @returns {Promise<E[] | null>} A promise that resolves to an array of events or null if not found.
223
223
  */
224
224
  export async function extractEventFromTransactionSignature<From, To extends From = From>(
225
- connection: web3.Connection | RpcInterface,
225
+ rpc: web3.Connection | RpcInterface,
226
226
  _program: PublicKey | web3.PublicKey,
227
227
  signature: web3.TransactionSignature | web3.ParsedTransactionWithMeta | null,
228
228
  serializer: Serializer<From, To>,
@@ -237,13 +237,8 @@ export async function extractEventFromTransactionSignature<From, To extends From
237
237
  }
238
238
  let tx: web3.ParsedTransactionWithMeta | null
239
239
  if (typeof signature === 'string') {
240
- if (connection instanceof web3.Connection) {
241
- tx = await connection.getParsedTransaction(signature, commitment)
242
- } else if ('connection' in connection && connection.connection instanceof web3.Connection) {
243
- tx = await connection.connection.getParsedTransaction(signature, commitment)
244
- } else {
245
- throw new Error('Invalid connection')
246
- }
240
+ const connection = toWeb3Connection(rpc)
241
+ tx = await connection.getParsedTransaction(signature, commitment)
247
242
  } else {
248
243
  tx = signature
249
244
  }
@@ -575,12 +570,8 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
575
570
  let connection: web3.Connection
576
571
  if (typeof _connection === 'string') {
577
572
  connection = new web3.Connection(_connection, commitment)
578
- } else if (_connection instanceof web3.Connection) {
579
- connection = _connection
580
- } else if ('connection' in _connection && _connection.connection instanceof web3.Connection) {
581
- ;({ connection } = _connection)
582
573
  } else {
583
- throw new Error('Invalid connection')
574
+ connection = toWeb3Connection(_connection)
584
575
  }
585
576
 
586
577
  let instructions: web3.TransactionInstruction[]
@@ -636,3 +627,13 @@ export async function simulateWeb3JsTransaction<From, To extends From = From>(
636
627
  return serializer.deserialize(resp, 0)[0]
637
628
  }
638
629
  }
630
+
631
+ export function toWeb3Connection(rpc: RpcInterface | web3.Connection): web3.Connection {
632
+ if (rpc instanceof web3.Connection) {
633
+ return rpc
634
+ } else if ('connection' in rpc && rpc.connection instanceof web3.Connection) {
635
+ return rpc.connection
636
+ } else {
637
+ throw new Error('Invalid connection')
638
+ }
639
+ }