@layerzerolabs/lz-solana-sdk-v2 2.3.20 → 2.3.22

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/dist/index.mjs CHANGED
@@ -1,24 +1,23 @@
1
1
  import * as web35 from '@solana/web3.js';
2
2
  import { PublicKey, TransactionInstruction, AddressLookupTableProgram, VersionedTransaction, TransactionMessage, Keypair, NONCE_ACCOUNT_LENGTH, Transaction, SystemProgram, NonceAccount, ComputeBudgetProgram } from '@solana/web3.js';
3
- import BN6 from 'bn.js';
3
+ import BN2 from 'bn.js';
4
4
  import * as beet201 from '@metaplex-foundation/beet';
5
5
  import { uniformFixedSizeArray, u8, FixableBeetArgsStruct, u32, u64, bytes, u16, BeetArgsStruct, bool, array } from '@metaplex-foundation/beet';
6
6
  import * as beetSolana97 from '@metaplex-foundation/beet-solana';
7
7
  import * as splToken from '@solana/spl-token';
8
- import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
9
- import { ethers } from 'ethers';
10
- import invariant2 from 'tiny-invariant';
8
+ import { getMintLen, createInitializeMintInstruction, TOKEN_PROGRAM_ID } from '@solana/spl-token';
9
+ import { arrayify, hexlify, hexZeroPad } from '@ethersproject/bytes';
10
+ import { keccak256 } from '@ethersproject/keccak256';
11
+ import invariant3 from 'tiny-invariant';
11
12
  import { getAddress } from '@ethersproject/address';
12
- import { arrayify, hexZeroPad, hexlify as hexlify$1 } from '@ethersproject/bytes';
13
13
  import '@ethersproject/abi';
14
14
  import { BigNumber } from '@ethersproject/bignumber';
15
15
  import '@ethersproject/solidity';
16
- import { keccak256 } from '@ethersproject/keccak256';
17
16
  import { signWithECDSA } from '@layerzerolabs/lz-corekit-solana';
18
17
  import { Environment, EndpointId } from '@layerzerolabs/lz-definitions';
19
18
  import crypto from 'crypto';
19
+ import { sha256 } from '@ethersproject/sha2';
20
20
  import base58 from 'bs58';
21
- import { hexlify } from 'ethers/lib/utils';
22
21
 
23
22
  var __defProp = Object.defineProperty;
24
23
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -88,7 +87,7 @@ var MaxExecutorOptionTypeLength = 10;
88
87
  function oappIDPDA(program, seed = COUNT_SEED, id) {
89
88
  if (id != void 0) {
90
89
  return PublicKey.findProgramAddressSync(
91
- [Buffer.from(seed, "utf8"), new BN6(id).toArrayLike(Buffer, "be", 1)],
90
+ [Buffer.from(seed, "utf8"), new BN2(id).toArrayLike(Buffer, "be", 1)],
92
91
  program
93
92
  );
94
93
  } else {
@@ -132,121 +131,22 @@ var BaseOApp = class {
132
131
  }
133
132
  };
134
133
 
135
- // src/generated/oft/index.ts
136
- var oft_exports = {};
137
- __export(oft_exports, {
134
+ // src/generated/oft/accounts/index.ts
135
+ var accounts_exports = {};
136
+ __export(accounts_exports, {
138
137
  EnforcedOptions: () => EnforcedOptions,
139
- InvalidDecimalsError: () => InvalidDecimalsError,
140
- InvalidEndpointProgramError: () => InvalidEndpointProgramError,
141
- InvalidOptionsError: () => InvalidOptionsError,
142
- InvalidSenderError: () => InvalidSenderError,
143
- InvalidTokenDestError: () => InvalidTokenDestError,
144
- InvalidTokenEscrowError: () => InvalidTokenEscrowError,
145
- InvalidTokenMintError: () => InvalidTokenMintError,
146
138
  LzReceiveTypesAccounts: () => LzReceiveTypesAccounts,
147
139
  OftConfig: () => OftConfig,
148
- PROGRAM_ADDRESS: () => PROGRAM_ADDRESS,
149
- PROGRAM_ID: () => PROGRAM_ID,
150
140
  Peer: () => Peer,
151
- RateLimitExceededError: () => RateLimitExceededError,
152
- SlippageExceededError: () => SlippageExceededError,
153
- UnauthorizedError: () => UnauthorizedError,
154
141
  accountProviders: () => accountProviders,
155
- createInitAdapterOftInstruction: () => createInitAdapterOftInstruction,
156
- createInitAdapterOftInstructionAccounts: () => createInitAdapterOftInstructionAccounts,
157
- createInitOftInstruction: () => createInitOftInstruction,
158
- createInitOftInstructionAccounts: () => createInitOftInstructionAccounts,
159
- createLzReceiveInstruction: () => createLzReceiveInstruction,
160
- createLzReceiveInstructionAccounts: () => createLzReceiveInstructionAccounts,
161
- createLzReceiveTypesInstruction: () => createLzReceiveTypesInstruction,
162
- createLzReceiveTypesInstructionAccounts: () => createLzReceiveTypesInstructionAccounts,
163
- createMintToInstruction: () => createMintToInstruction,
164
- createMintToInstructionAccounts: () => createMintToInstructionAccounts,
165
- createQuoteInstruction: () => createQuoteInstruction,
166
- createQuoteInstructionAccounts: () => createQuoteInstructionAccounts,
167
- createQuoteOftInstruction: () => createQuoteOftInstruction,
168
- createQuoteOftInstructionAccounts: () => createQuoteOftInstructionAccounts,
169
- createSendInstruction: () => createSendInstruction,
170
- createSendInstructionAccounts: () => createSendInstructionAccounts,
171
- createSetDelegateInstruction: () => createSetDelegateInstruction,
172
- createSetDelegateInstructionAccounts: () => createSetDelegateInstructionAccounts,
173
- createSetEnforcedOptionsInstruction: () => createSetEnforcedOptionsInstruction,
174
- createSetEnforcedOptionsInstructionAccounts: () => createSetEnforcedOptionsInstructionAccounts,
175
- createSetMintAuthorityInstruction: () => createSetMintAuthorityInstruction,
176
- createSetMintAuthorityInstructionAccounts: () => createSetMintAuthorityInstructionAccounts,
177
- createSetPeerInstruction: () => createSetPeerInstruction,
178
- createSetPeerInstructionAccounts: () => createSetPeerInstructionAccounts,
179
- createSetRateLimitInstruction: () => createSetRateLimitInstruction,
180
- createSetRateLimitInstructionAccounts: () => createSetRateLimitInstructionAccounts,
181
- createTransferAdminInstruction: () => createTransferAdminInstruction,
182
- createTransferAdminInstructionAccounts: () => createTransferAdminInstructionAccounts,
183
- createVersionInstruction: () => createVersionInstruction,
184
- createVersionInstructionAccounts: () => createVersionInstructionAccounts,
185
142
  enforcedOptionsBeet: () => enforcedOptionsBeet,
186
143
  enforcedOptionsDiscriminator: () => enforcedOptionsDiscriminator,
187
- errorFromCode: () => errorFromCode,
188
- errorFromName: () => errorFromName,
189
- initAdapterOftInstructionDiscriminator: () => initAdapterOftInstructionDiscriminator,
190
- initAdapterOftParamsBeet: () => initAdapterOftParamsBeet,
191
- initAdapterOftStruct: () => initAdapterOftStruct,
192
- initOftInstructionDiscriminator: () => initOftInstructionDiscriminator,
193
- initOftParamsBeet: () => initOftParamsBeet,
194
- initOftStruct: () => initOftStruct,
195
- isOftConfigExtAdapter: () => isOftConfigExtAdapter,
196
- isOftConfigExtNative: () => isOftConfigExtNative,
197
- lzAccountBeet: () => lzAccountBeet,
198
- lzReceiveInstructionDiscriminator: () => lzReceiveInstructionDiscriminator,
199
- lzReceiveParamsBeet: () => lzReceiveParamsBeet,
200
- lzReceiveStruct: () => lzReceiveStruct,
201
144
  lzReceiveTypesAccountsBeet: () => lzReceiveTypesAccountsBeet,
202
145
  lzReceiveTypesAccountsDiscriminator: () => lzReceiveTypesAccountsDiscriminator,
203
- lzReceiveTypesInstructionDiscriminator: () => lzReceiveTypesInstructionDiscriminator,
204
- lzReceiveTypesStruct: () => lzReceiveTypesStruct,
205
- messagingFeeBeet: () => messagingFeeBeet,
206
- messagingReceiptBeet: () => messagingReceiptBeet,
207
- mintToInstructionDiscriminator: () => mintToInstructionDiscriminator,
208
- mintToParamsBeet: () => mintToParamsBeet,
209
- mintToStruct: () => mintToStruct,
210
- oFTFeeDetailBeet: () => oFTFeeDetailBeet,
211
- oFTLimitsBeet: () => oFTLimitsBeet,
212
- oFTReceiptBeet: () => oFTReceiptBeet,
213
146
  oftConfigBeet: () => oftConfigBeet,
214
147
  oftConfigDiscriminator: () => oftConfigDiscriminator,
215
- oftConfigExtBeet: () => oftConfigExtBeet,
216
148
  peerBeet: () => peerBeet,
217
- peerDiscriminator: () => peerDiscriminator,
218
- quoteInstructionDiscriminator: () => quoteInstructionDiscriminator,
219
- quoteOftInstructionDiscriminator: () => quoteOftInstructionDiscriminator,
220
- quoteOftParamsBeet: () => quoteOftParamsBeet,
221
- quoteOftResultBeet: () => quoteOftResultBeet,
222
- quoteOftStruct: () => quoteOftStruct,
223
- quoteParamsBeet: () => quoteParamsBeet,
224
- quoteStruct: () => quoteStruct,
225
- rateLimiterBeet: () => rateLimiterBeet,
226
- sendInstructionDiscriminator: () => sendInstructionDiscriminator,
227
- sendParamsBeet: () => sendParamsBeet,
228
- sendStruct: () => sendStruct,
229
- setDelegateInstructionDiscriminator: () => setDelegateInstructionDiscriminator,
230
- setDelegateParamsBeet: () => setDelegateParamsBeet,
231
- setDelegateStruct: () => setDelegateStruct,
232
- setEnforcedOptionsInstructionDiscriminator: () => setEnforcedOptionsInstructionDiscriminator,
233
- setEnforcedOptionsParamsBeet: () => setEnforcedOptionsParamsBeet,
234
- setEnforcedOptionsStruct: () => setEnforcedOptionsStruct,
235
- setMintAuthorityInstructionDiscriminator: () => setMintAuthorityInstructionDiscriminator,
236
- setMintAuthorityParamsBeet: () => setMintAuthorityParamsBeet,
237
- setMintAuthorityStruct: () => setMintAuthorityStruct,
238
- setPeerInstructionDiscriminator: () => setPeerInstructionDiscriminator,
239
- setPeerParamsBeet: () => setPeerParamsBeet,
240
- setPeerStruct: () => setPeerStruct,
241
- setRateLimitInstructionDiscriminator: () => setRateLimitInstructionDiscriminator,
242
- setRateLimitParamsBeet: () => setRateLimitParamsBeet,
243
- setRateLimitStruct: () => setRateLimitStruct,
244
- transferAdminInstructionDiscriminator: () => transferAdminInstructionDiscriminator,
245
- transferAdminParamsBeet: () => transferAdminParamsBeet,
246
- transferAdminStruct: () => transferAdminStruct,
247
- versionBeet: () => versionBeet,
248
- versionInstructionDiscriminator: () => versionInstructionDiscriminator,
249
- versionStruct: () => versionStruct
149
+ peerDiscriminator: () => peerDiscriminator
250
150
  });
251
151
  var enforcedOptionsDiscriminator = [114, 221, 43, 174, 5, 37, 8, 20];
252
152
  var EnforcedOptions = class _EnforcedOptions {
@@ -927,14 +827,71 @@ createErrorFromNameLookup.set(
927
827
  "RateLimitExceeded",
928
828
  () => new RateLimitExceededError()
929
829
  );
930
- function errorFromCode(code) {
931
- const createError = createErrorFromCodeLookup.get(code);
932
- return createError != null ? createError() : null;
933
- }
934
- function errorFromName(name) {
935
- const createError = createErrorFromNameLookup.get(name);
936
- return createError != null ? createError() : null;
937
- }
830
+
831
+ // src/generated/oft/instructions/index.ts
832
+ var instructions_exports = {};
833
+ __export(instructions_exports, {
834
+ createInitAdapterOftInstruction: () => createInitAdapterOftInstruction,
835
+ createInitAdapterOftInstructionAccounts: () => createInitAdapterOftInstructionAccounts,
836
+ createInitOftInstruction: () => createInitOftInstruction,
837
+ createInitOftInstructionAccounts: () => createInitOftInstructionAccounts,
838
+ createLzReceiveInstruction: () => createLzReceiveInstruction,
839
+ createLzReceiveInstructionAccounts: () => createLzReceiveInstructionAccounts,
840
+ createLzReceiveTypesInstruction: () => createLzReceiveTypesInstruction,
841
+ createLzReceiveTypesInstructionAccounts: () => createLzReceiveTypesInstructionAccounts,
842
+ createMintToInstruction: () => createMintToInstruction,
843
+ createMintToInstructionAccounts: () => createMintToInstructionAccounts,
844
+ createQuoteInstruction: () => createQuoteInstruction,
845
+ createQuoteInstructionAccounts: () => createQuoteInstructionAccounts,
846
+ createQuoteOftInstruction: () => createQuoteOftInstruction,
847
+ createQuoteOftInstructionAccounts: () => createQuoteOftInstructionAccounts,
848
+ createSendInstruction: () => createSendInstruction,
849
+ createSendInstructionAccounts: () => createSendInstructionAccounts,
850
+ createSetDelegateInstruction: () => createSetDelegateInstruction,
851
+ createSetDelegateInstructionAccounts: () => createSetDelegateInstructionAccounts,
852
+ createSetEnforcedOptionsInstruction: () => createSetEnforcedOptionsInstruction,
853
+ createSetEnforcedOptionsInstructionAccounts: () => createSetEnforcedOptionsInstructionAccounts,
854
+ createSetMintAuthorityInstruction: () => createSetMintAuthorityInstruction,
855
+ createSetMintAuthorityInstructionAccounts: () => createSetMintAuthorityInstructionAccounts,
856
+ createSetPeerInstruction: () => createSetPeerInstruction,
857
+ createSetPeerInstructionAccounts: () => createSetPeerInstructionAccounts,
858
+ createSetRateLimitInstruction: () => createSetRateLimitInstruction,
859
+ createSetRateLimitInstructionAccounts: () => createSetRateLimitInstructionAccounts,
860
+ createTransferAdminInstruction: () => createTransferAdminInstruction,
861
+ createTransferAdminInstructionAccounts: () => createTransferAdminInstructionAccounts,
862
+ createVersionInstruction: () => createVersionInstruction,
863
+ createVersionInstructionAccounts: () => createVersionInstructionAccounts,
864
+ initAdapterOftInstructionDiscriminator: () => initAdapterOftInstructionDiscriminator,
865
+ initAdapterOftStruct: () => initAdapterOftStruct,
866
+ initOftInstructionDiscriminator: () => initOftInstructionDiscriminator,
867
+ initOftStruct: () => initOftStruct,
868
+ lzReceiveInstructionDiscriminator: () => lzReceiveInstructionDiscriminator,
869
+ lzReceiveStruct: () => lzReceiveStruct,
870
+ lzReceiveTypesInstructionDiscriminator: () => lzReceiveTypesInstructionDiscriminator,
871
+ lzReceiveTypesStruct: () => lzReceiveTypesStruct,
872
+ mintToInstructionDiscriminator: () => mintToInstructionDiscriminator,
873
+ mintToStruct: () => mintToStruct,
874
+ quoteInstructionDiscriminator: () => quoteInstructionDiscriminator,
875
+ quoteOftInstructionDiscriminator: () => quoteOftInstructionDiscriminator,
876
+ quoteOftStruct: () => quoteOftStruct,
877
+ quoteStruct: () => quoteStruct,
878
+ sendInstructionDiscriminator: () => sendInstructionDiscriminator,
879
+ sendStruct: () => sendStruct,
880
+ setDelegateInstructionDiscriminator: () => setDelegateInstructionDiscriminator,
881
+ setDelegateStruct: () => setDelegateStruct,
882
+ setEnforcedOptionsInstructionDiscriminator: () => setEnforcedOptionsInstructionDiscriminator,
883
+ setEnforcedOptionsStruct: () => setEnforcedOptionsStruct,
884
+ setMintAuthorityInstructionDiscriminator: () => setMintAuthorityInstructionDiscriminator,
885
+ setMintAuthorityStruct: () => setMintAuthorityStruct,
886
+ setPeerInstructionDiscriminator: () => setPeerInstructionDiscriminator,
887
+ setPeerStruct: () => setPeerStruct,
888
+ setRateLimitInstructionDiscriminator: () => setRateLimitInstructionDiscriminator,
889
+ setRateLimitStruct: () => setRateLimitStruct,
890
+ transferAdminInstructionDiscriminator: () => transferAdminInstructionDiscriminator,
891
+ transferAdminStruct: () => transferAdminStruct,
892
+ versionInstructionDiscriminator: () => versionInstructionDiscriminator,
893
+ versionStruct: () => versionStruct
894
+ });
938
895
  var initAdapterOftParamsBeet = new beet201.FixableBeetArgsStruct(
939
896
  [
940
897
  ["admin", beetSolana97.publicKey],
@@ -2391,6 +2348,36 @@ function createVersionInstructionAccounts(programId = new web35.PublicKey("HRPXL
2391
2348
  const keys = [];
2392
2349
  return keys;
2393
2350
  }
2351
+
2352
+ // src/generated/oft/types/index.ts
2353
+ var types_exports = {};
2354
+ __export(types_exports, {
2355
+ initAdapterOftParamsBeet: () => initAdapterOftParamsBeet,
2356
+ initOftParamsBeet: () => initOftParamsBeet,
2357
+ isOftConfigExtAdapter: () => isOftConfigExtAdapter,
2358
+ isOftConfigExtNative: () => isOftConfigExtNative,
2359
+ lzAccountBeet: () => lzAccountBeet,
2360
+ lzReceiveParamsBeet: () => lzReceiveParamsBeet,
2361
+ messagingFeeBeet: () => messagingFeeBeet,
2362
+ messagingReceiptBeet: () => messagingReceiptBeet,
2363
+ mintToParamsBeet: () => mintToParamsBeet,
2364
+ oFTFeeDetailBeet: () => oFTFeeDetailBeet,
2365
+ oFTLimitsBeet: () => oFTLimitsBeet,
2366
+ oFTReceiptBeet: () => oFTReceiptBeet,
2367
+ oftConfigExtBeet: () => oftConfigExtBeet,
2368
+ quoteOftParamsBeet: () => quoteOftParamsBeet,
2369
+ quoteOftResultBeet: () => quoteOftResultBeet,
2370
+ quoteParamsBeet: () => quoteParamsBeet,
2371
+ rateLimiterBeet: () => rateLimiterBeet,
2372
+ sendParamsBeet: () => sendParamsBeet,
2373
+ setDelegateParamsBeet: () => setDelegateParamsBeet,
2374
+ setEnforcedOptionsParamsBeet: () => setEnforcedOptionsParamsBeet,
2375
+ setMintAuthorityParamsBeet: () => setMintAuthorityParamsBeet,
2376
+ setPeerParamsBeet: () => setPeerParamsBeet,
2377
+ setRateLimitParamsBeet: () => setRateLimitParamsBeet,
2378
+ transferAdminParamsBeet: () => transferAdminParamsBeet,
2379
+ versionBeet: () => versionBeet
2380
+ });
2394
2381
  var lzAccountBeet = new beet201.BeetArgsStruct(
2395
2382
  [
2396
2383
  ["pubkey", beetSolana97.publicKey],
@@ -2496,7 +2483,7 @@ var EndpointPDADeriver = class {
2496
2483
  [
2497
2484
  Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
2498
2485
  // U32 to Uint8Array([0,0,0,0])
2499
- new BN6(dstEndpointId).toArrayLike(Buffer, "be", 4)
2486
+ new BN2(dstEndpointId).toArrayLike(Buffer, "be", 4)
2500
2487
  ],
2501
2488
  this.program
2502
2489
  );
@@ -2507,7 +2494,7 @@ var EndpointPDADeriver = class {
2507
2494
  Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
2508
2495
  sender.toBytes(),
2509
2496
  // U32 to Uint8Array([0,0,0,0])
2510
- new BN6(dstEndpointId).toArrayLike(Buffer, "be", 4)
2497
+ new BN2(dstEndpointId).toArrayLike(Buffer, "be", 4)
2511
2498
  ],
2512
2499
  this.program
2513
2500
  );
@@ -2526,7 +2513,7 @@ var EndpointPDADeriver = class {
2526
2513
  [
2527
2514
  Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
2528
2515
  // U32 to Uint8Array([0,0,0,0])
2529
- new BN6(srcEndpointId).toArrayLike(Buffer, "be", 4)
2516
+ new BN2(srcEndpointId).toArrayLike(Buffer, "be", 4)
2530
2517
  ],
2531
2518
  this.program
2532
2519
  );
@@ -2537,7 +2524,7 @@ var EndpointPDADeriver = class {
2537
2524
  Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
2538
2525
  receiver.toBytes(),
2539
2526
  // U32 to Uint8Array([0,0,0,0])
2540
- new BN6(srcEndpointId).toArrayLike(Buffer, "be", 4)
2527
+ new BN2(srcEndpointId).toArrayLike(Buffer, "be", 4)
2541
2528
  ],
2542
2529
  this.program
2543
2530
  );
@@ -2565,7 +2552,7 @@ var EndpointPDADeriver = class {
2565
2552
  Buffer.from(NONCE_SEED, "utf8"),
2566
2553
  localOapp.toBytes(),
2567
2554
  // U32 to Uint8Array([0,0,0,0])
2568
- new BN6(remoteChainId).toArrayLike(Buffer, "be", 4),
2555
+ new BN2(remoteChainId).toArrayLike(Buffer, "be", 4),
2569
2556
  remoteOapp
2570
2557
  ],
2571
2558
  this.program
@@ -2576,7 +2563,7 @@ var EndpointPDADeriver = class {
2576
2563
  [
2577
2564
  Buffer.from(PENDING_NONCE_SEED, "utf8"),
2578
2565
  localOapp.toBytes(),
2579
- new BN6(remoteChainId).toArrayLike(Buffer, "be", 4),
2566
+ new BN2(remoteChainId).toArrayLike(Buffer, "be", 4),
2580
2567
  remoteOapp
2581
2568
  ],
2582
2569
  this.program
@@ -2601,9 +2588,9 @@ var EndpointPDADeriver = class {
2601
2588
  [
2602
2589
  Buffer.from(PAYLOAD_HASH_SEED, "utf8"),
2603
2590
  receiver.toBytes(),
2604
- new BN6(srcEid).toArrayLike(Buffer, "be", 4),
2591
+ new BN2(srcEid).toArrayLike(Buffer, "be", 4),
2605
2592
  sender,
2606
- new BN6(nonce).toArrayLike(Buffer, "be", 8)
2593
+ new BN2(nonce).toArrayLike(Buffer, "be", 8)
2607
2594
  ],
2608
2595
  this.program
2609
2596
  );
@@ -2615,7 +2602,7 @@ var EndpointPDADeriver = class {
2615
2602
  from.toBytes(),
2616
2603
  to.toBytes(),
2617
2604
  guid,
2618
- new BN6(index).toArrayLike(Buffer, "be", 2),
2605
+ new BN2(index).toArrayLike(Buffer, "be", 2),
2619
2606
  messageHash
2620
2607
  ],
2621
2608
  this.program
@@ -2631,13 +2618,13 @@ var MessageLibPDADeriver = class {
2631
2618
  }
2632
2619
  sendConfig(eid, oapp) {
2633
2620
  return PublicKey.findProgramAddressSync(
2634
- [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN6(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
2621
+ [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
2635
2622
  this.program
2636
2623
  );
2637
2624
  }
2638
2625
  receiveConfig(eid, oapp) {
2639
2626
  return PublicKey.findProgramAddressSync(
2640
- [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN6(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
2627
+ [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
2641
2628
  this.program
2642
2629
  );
2643
2630
  }
@@ -2648,25 +2635,25 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
2648
2635
  }
2649
2636
  config(eid) {
2650
2637
  return PublicKey.findProgramAddressSync(
2651
- [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN6(eid).toArrayLike(Buffer, "be", 4)],
2638
+ [Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4)],
2652
2639
  this.program
2653
2640
  );
2654
2641
  }
2655
2642
  defaultSendConfig(eid) {
2656
2643
  return PublicKey.findProgramAddressSync(
2657
- [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN6(eid).toArrayLike(Buffer, "be", 4)],
2644
+ [Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4)],
2658
2645
  this.program
2659
2646
  );
2660
2647
  }
2661
2648
  defaultReceiveConfig(eid) {
2662
2649
  return PublicKey.findProgramAddressSync(
2663
- [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN6(eid).toArrayLike(Buffer, "be", 4)],
2650
+ [Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN2(eid).toArrayLike(Buffer, "be", 4)],
2664
2651
  this.program
2665
2652
  );
2666
2653
  }
2667
2654
  options(eit) {
2668
2655
  return PublicKey.findProgramAddressSync(
2669
- [Buffer.from(OPTIONS_SEED, "utf8"), new BN6(eit).toArrayLike(Buffer, "be", 4)],
2656
+ [Buffer.from(OPTIONS_SEED, "utf8"), new BN2(eit).toArrayLike(Buffer, "be", 4)],
2670
2657
  this.program
2671
2658
  );
2672
2659
  }
@@ -2686,7 +2673,7 @@ var OAppBasePDADeriver = class {
2686
2673
  }
2687
2674
  remote(dstChainId) {
2688
2675
  return PublicKey.findProgramAddressSync(
2689
- [Buffer.from(REMOTE_SEED), new BN6(dstChainId).toArrayLike(Buffer, "be", 4)],
2676
+ [Buffer.from(REMOTE_SEED), new BN2(dstChainId).toArrayLike(Buffer, "be", 4)],
2690
2677
  this.program
2691
2678
  );
2692
2679
  }
@@ -2707,7 +2694,7 @@ var OmniCounterPDADeriver = class extends OAppBasePDADeriver {
2707
2694
  }
2708
2695
  remote(dstChainId) {
2709
2696
  return PublicKey.findProgramAddressSync(
2710
- [Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new BN6(dstChainId).toArrayLike(Buffer, "be", 4)],
2697
+ [Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new BN2(dstChainId).toArrayLike(Buffer, "be", 4)],
2711
2698
  this.program
2712
2699
  );
2713
2700
  }
@@ -2771,19 +2758,25 @@ var OftPDADeriver = class {
2771
2758
  }
2772
2759
  enforcedOptions(oftConfig, eid) {
2773
2760
  return PublicKey.findProgramAddressSync(
2774
- [Buffer.from(ENFORCED_OPTIONS_SEED, "utf8"), oftConfig.toBytes(), new BN6(eid).toArrayLike(Buffer, "be", 4)],
2761
+ [Buffer.from(ENFORCED_OPTIONS_SEED, "utf8"), oftConfig.toBytes(), new BN2(eid).toArrayLike(Buffer, "be", 4)],
2775
2762
  this.program
2776
2763
  );
2777
2764
  }
2778
2765
  peer(oftConfig, eid) {
2779
2766
  return PublicKey.findProgramAddressSync(
2780
- [Buffer.from(PEER_SEED, "utf8"), oftConfig.toBytes(), new BN6(eid).toArrayLike(Buffer, "be", 4)],
2767
+ [Buffer.from(PEER_SEED, "utf8"), oftConfig.toBytes(), new BN2(eid).toArrayLike(Buffer, "be", 4)],
2781
2768
  this.program
2782
2769
  );
2783
2770
  }
2784
2771
  oftConfig(mintOrEscrow) {
2785
2772
  return PublicKey.findProgramAddressSync([Buffer.from(OFT_SEED, "utf8"), mintOrEscrow.toBuffer()], this.program);
2786
2773
  }
2774
+ lzReceiveTypesAccounts(oftConfig) {
2775
+ return PublicKey.findProgramAddressSync(
2776
+ [Buffer.from(LZ_RECEIVE_TYPES_SEED, "utf-8"), oftConfig.toBuffer()],
2777
+ this.program
2778
+ );
2779
+ }
2787
2780
  };
2788
2781
 
2789
2782
  // src/endpoint.ts
@@ -2793,18 +2786,18 @@ __export(endpoint_exports, {
2793
2786
  Endpoint: () => Endpoint,
2794
2787
  EventEmitDiscriminator: () => EventEmitDiscriminator,
2795
2788
  PROGRAM_ID: () => PROGRAM_ID2,
2796
- accounts: () => accounts_exports,
2789
+ accounts: () => accounts_exports2,
2797
2790
  errors: () => errors_exports,
2798
2791
  events: () => events_exports,
2799
- instructions: () => instructions_exports,
2800
- types: () => types_exports
2792
+ instructions: () => instructions_exports2,
2793
+ types: () => types_exports2
2801
2794
  });
2802
2795
  function hexZeroPadTo32(addr) {
2803
2796
  return hexZeroPad(addr, 32);
2804
2797
  }
2805
2798
  function bytes32ToEthAddress(bytes322) {
2806
2799
  if (bytes322 instanceof Uint8Array) {
2807
- bytes322 = hexlify$1(bytes322);
2800
+ bytes322 = hexlify(bytes322);
2808
2801
  }
2809
2802
  return getAddress(bytes322.slice(-40));
2810
2803
  }
@@ -2931,10 +2924,27 @@ var PacketV1Codec = class _PacketV1Codec {
2931
2924
  };
2932
2925
  }
2933
2926
  };
2927
+ var PacketSerializer = class {
2928
+ static serialize(packet) {
2929
+ return PacketV1Codec.encode(packet);
2930
+ }
2931
+ static serializeBytes(packet) {
2932
+ return PacketV1Codec.encodeBytes(packet);
2933
+ }
2934
+ static deserialize(bytesLike) {
2935
+ let codec;
2936
+ if (bytesLike instanceof Uint8Array) {
2937
+ codec = PacketV1Codec.fromBytes(bytesLike);
2938
+ } else {
2939
+ codec = PacketV1Codec.from(bytesLike);
2940
+ }
2941
+ return codec.toPacket();
2942
+ }
2943
+ };
2934
2944
 
2935
2945
  // src/generated/endpoint/accounts/index.ts
2936
- var accounts_exports = {};
2937
- __export(accounts_exports, {
2946
+ var accounts_exports2 = {};
2947
+ __export(accounts_exports2, {
2938
2948
  ComposeMessageState: () => ComposeMessageState,
2939
2949
  EndpointSettings: () => EndpointSettings,
2940
2950
  MessageLibInfo: () => MessageLibInfo,
@@ -4092,8 +4102,8 @@ __export(errors_exports, {
4092
4102
  SameValueError: () => SameValueError,
4093
4103
  UnauthorizedError: () => UnauthorizedError2,
4094
4104
  WritableAccountNotAllowedError: () => WritableAccountNotAllowedError,
4095
- errorFromCode: () => errorFromCode2,
4096
- errorFromName: () => errorFromName2
4105
+ errorFromCode: () => errorFromCode,
4106
+ errorFromName: () => errorFromName
4097
4107
  });
4098
4108
  var createErrorFromCodeLookup2 = /* @__PURE__ */ new Map();
4099
4109
  var createErrorFromNameLookup2 = /* @__PURE__ */ new Map();
@@ -4349,18 +4359,18 @@ createErrorFromNameLookup2.set(
4349
4359
  "WritableAccountNotAllowed",
4350
4360
  () => new WritableAccountNotAllowedError()
4351
4361
  );
4352
- function errorFromCode2(code) {
4362
+ function errorFromCode(code) {
4353
4363
  const createError = createErrorFromCodeLookup2.get(code);
4354
4364
  return createError != null ? createError() : null;
4355
4365
  }
4356
- function errorFromName2(name) {
4366
+ function errorFromName(name) {
4357
4367
  const createError = createErrorFromNameLookup2.get(name);
4358
4368
  return createError != null ? createError() : null;
4359
4369
  }
4360
4370
 
4361
4371
  // src/generated/endpoint/instructions/index.ts
4362
- var instructions_exports = {};
4363
- __export(instructions_exports, {
4372
+ var instructions_exports2 = {};
4373
+ __export(instructions_exports2, {
4364
4374
  burnInstructionDiscriminator: () => burnInstructionDiscriminator,
4365
4375
  burnStruct: () => burnStruct,
4366
4376
  clearComposeInstructionDiscriminator: () => clearComposeInstructionDiscriminator,
@@ -8034,8 +8044,8 @@ function createWithdrawRentInstructionAccounts(accounts, programId = new web35.P
8034
8044
  }
8035
8045
 
8036
8046
  // src/generated/endpoint/types/index.ts
8037
- var types_exports = {};
8038
- __export(types_exports, {
8047
+ var types_exports2 = {};
8048
+ __export(types_exports2, {
8039
8049
  MessageLibType: () => MessageLibType,
8040
8050
  burnParamsBeet: () => burnParamsBeet,
8041
8051
  clearComposeParamsBeet: () => clearComposeParamsBeet,
@@ -8498,12 +8508,16 @@ var Endpoint = class {
8498
8508
  }
8499
8509
  async initOAppNonce(connection, delegate, dstEid, oappIDPDA2, remoteOappAddr) {
8500
8510
  const [nonce] = this.endpointDeriver.nonce(oappIDPDA2, dstEid, remoteOappAddr);
8501
- const [pendingNonce] = this.endpointDeriver.pendingNonce(oappIDPDA2, dstEid, remoteOappAddr);
8502
- const [oappRegistry] = this.endpointDeriver.oappRegistry(oappIDPDA2);
8503
8511
  const info = await connection.getAccountInfo(nonce);
8504
8512
  if (info) {
8505
8513
  return null;
8506
8514
  }
8515
+ return this.initOAppNonceWithoutChecks(delegate, dstEid, oappIDPDA2, remoteOappAddr);
8516
+ }
8517
+ initOAppNonceWithoutChecks(delegate, dstEid, oappIDPDA2, remoteOappAddr) {
8518
+ const [nonce] = this.endpointDeriver.nonce(oappIDPDA2, dstEid, remoteOappAddr);
8519
+ const [pendingNonce] = this.endpointDeriver.pendingNonce(oappIDPDA2, dstEid, remoteOappAddr);
8520
+ const [oappRegistry] = this.endpointDeriver.oappRegistry(oappIDPDA2);
8507
8521
  return createInitNonceInstruction(
8508
8522
  {
8509
8523
  nonce,
@@ -8522,12 +8536,16 @@ var Endpoint = class {
8522
8536
  );
8523
8537
  }
8524
8538
  async initSendLibrary(connection, delegate, sender, dstEid, commitmentOrConfig) {
8525
- const [oappRegistry] = this.endpointDeriver.oappRegistry(sender);
8526
8539
  const [sendLibraryConfig] = this.endpointDeriver.sendLibraryConfig(sender, dstEid);
8527
8540
  const info = await connection.getAccountInfo(sendLibraryConfig, commitmentOrConfig);
8528
8541
  if (info) {
8529
8542
  return null;
8530
8543
  }
8544
+ return this.initSendLibraryWithoutChecks(delegate, sender, dstEid);
8545
+ }
8546
+ initSendLibraryWithoutChecks(delegate, sender, dstEid) {
8547
+ const [oappRegistry] = this.endpointDeriver.oappRegistry(sender);
8548
+ const [sendLibraryConfig] = this.endpointDeriver.sendLibraryConfig(sender, dstEid);
8531
8549
  return createInitSendLibraryInstruction(
8532
8550
  {
8533
8551
  delegate,
@@ -8543,7 +8561,7 @@ var Endpoint = class {
8543
8561
  this.program
8544
8562
  );
8545
8563
  }
8546
- async setSendLibrary(_connection, oappAdmin, oappIDPDA2, newSendLibProgram, dstEid) {
8564
+ async setSendLibrary(oappAdmin, oappIDPDA2, newSendLibProgram, dstEid) {
8547
8565
  const [newSendLib] = new MessageLibPDADeriver(newSendLibProgram).messageLib();
8548
8566
  const [sendLibraryConfig] = this.endpointDeriver.sendLibraryConfig(oappIDPDA2, dstEid);
8549
8567
  const [sendLibraryInfo] = this.endpointDeriver.messageLibraryInfo(newSendLib);
@@ -8569,12 +8587,16 @@ var Endpoint = class {
8569
8587
  return Promise.resolve(ix);
8570
8588
  }
8571
8589
  async initReceiveLibrary(connection, delegate, receiver, srcEid, commitmentOrConfig) {
8572
- const [oappRegistry] = this.endpointDeriver.oappRegistry(receiver);
8573
8590
  const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(receiver, srcEid);
8574
8591
  const info = await connection.getAccountInfo(receiveLibraryConfig, commitmentOrConfig);
8575
8592
  if (info) {
8576
8593
  return null;
8577
8594
  }
8595
+ return this.initReceiveLibraryWithoutChecks(delegate, receiver, srcEid);
8596
+ }
8597
+ initReceiveLibraryWithoutChecks(delegate, receiver, srcEid) {
8598
+ const [oappRegistry] = this.endpointDeriver.oappRegistry(receiver);
8599
+ const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(receiver, srcEid);
8578
8600
  return createInitReceiveLibraryInstruction(
8579
8601
  {
8580
8602
  delegate,
@@ -8590,7 +8612,7 @@ var Endpoint = class {
8590
8612
  this.program
8591
8613
  );
8592
8614
  }
8593
- async setReceiveLibrary(_connection, oappAdmin, oappIDPDA2, newReceiveLibProgram, srcEid, gracePeriod) {
8615
+ async setReceiveLibrary(oappAdmin, oappIDPDA2, newReceiveLibProgram, srcEid, gracePeriod) {
8594
8616
  const [newReceiveLib] = new MessageLibPDADeriver(newReceiveLibProgram).messageLib();
8595
8617
  const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(oappIDPDA2, srcEid);
8596
8618
  const [receiveLibraryInfo] = this.endpointDeriver.messageLibraryInfo(newReceiveLib);
@@ -8644,7 +8666,7 @@ var Endpoint = class {
8644
8666
  params: {
8645
8667
  eid,
8646
8668
  configType: config.configType,
8647
- config: uln_exports.Uln.constructSetConfigData(config.configType, config.value),
8669
+ config: msgLibProgram.toBase58() === simple_message_lib_exports.PROGRAM_ID.toBase58() ? new Uint8Array(10) : uln_exports.Uln.constructSetConfigData(config.configType, config.value),
8648
8670
  oapp: oappID
8649
8671
  }
8650
8672
  },
@@ -8667,7 +8689,7 @@ var Endpoint = class {
8667
8689
  */
8668
8690
  async getQuoteIXAccountMetaForCPI(connection, payer, path, msgLibProgram) {
8669
8691
  const { sender: sender_, dstEid, receiver: receiver_ } = path;
8670
- const sender = new PublicKey(ethers.utils.arrayify(sender_));
8692
+ const sender = new PublicKey(arrayify(sender_));
8671
8693
  const receiver = addressToBytes32(receiver_);
8672
8694
  const sendLibInfo = await this.getSendLibrary(connection, sender, dstEid);
8673
8695
  if (!sendLibInfo?.programId) {
@@ -8707,7 +8729,7 @@ var Endpoint = class {
8707
8729
  */
8708
8730
  async getSendIXAccountMetaForCPI(connection, payer, path, msgLibProgram, commitmentOrConfig) {
8709
8731
  const { sender: sender_, dstEid, receiver: receiver_ } = path;
8710
- const sender = new PublicKey(ethers.utils.arrayify(sender_));
8732
+ const sender = new PublicKey(arrayify(sender_));
8711
8733
  const receiver = addressToBytes32(receiver_);
8712
8734
  const info = await this.getSendLibrary(connection, sender, dstEid, commitmentOrConfig);
8713
8735
  if (!info?.programId) {
@@ -8771,7 +8793,7 @@ var Endpoint = class {
8771
8793
  receiver,
8772
8794
  srcEid,
8773
8795
  sender: Array.from(sender.toBytes()),
8774
- nonce: new BN6(nonce)
8796
+ nonce: new BN2(nonce)
8775
8797
  }
8776
8798
  },
8777
8799
  this.program
@@ -8796,7 +8818,7 @@ var Endpoint = class {
8796
8818
  srcEid,
8797
8819
  sender: Array.from(sender.toBytes()),
8798
8820
  receiver,
8799
- nonce: new BN6(nonce)
8821
+ nonce: new BN2(nonce)
8800
8822
  }
8801
8823
  },
8802
8824
  this.program
@@ -9040,15 +9062,39 @@ var Endpoint = class {
9040
9062
  // } as AccountMeta,
9041
9063
  // ].concat(ix.keys)
9042
9064
  // }
9065
+ getRegisterOappIxAccountMetaForCPI(payer, oapp) {
9066
+ const [oappRegistry] = this.endpointDeriver.oappRegistry(oapp);
9067
+ const eventAuthority = this.eventAuthorityPDA;
9068
+ const keys = createRegisterOappInstructionAccounts(
9069
+ {
9070
+ payer,
9071
+ oapp,
9072
+ oappRegistry,
9073
+ eventAuthority,
9074
+ program: this.program
9075
+ },
9076
+ this.program
9077
+ );
9078
+ keys.forEach((key) => {
9079
+ key.isSigner = false;
9080
+ });
9081
+ return [
9082
+ {
9083
+ pubkey: this.program,
9084
+ isSigner: false,
9085
+ isWritable: false
9086
+ }
9087
+ ].concat(keys);
9088
+ }
9043
9089
  getSkipIxAccountMetaForCPI(receiver, sender, srcEid, nonce) {
9044
9090
  const [noncePDA] = this.endpointDeriver.nonce(receiver, srcEid, sender);
9045
9091
  const [pendingNonce] = this.endpointDeriver.pendingNonce(receiver, srcEid, sender);
9046
9092
  const [payloadHash] = this.endpointDeriver.payloadHash(receiver, srcEid, sender, nonce);
9047
- const ix = createSkipInstruction(
9093
+ const [oappRegistry] = this.endpointDeriver.oappRegistry(receiver);
9094
+ const keys = createSkipInstructionAccounts(
9048
9095
  {
9049
9096
  signer: receiver,
9050
- oappRegistry: receiver,
9051
- // FIXME: oappRegistry is wrong
9097
+ oappRegistry,
9052
9098
  nonce: noncePDA,
9053
9099
  pendingInboundNonce: pendingNonce,
9054
9100
  payloadHash,
@@ -9056,16 +9102,9 @@ var Endpoint = class {
9056
9102
  program: this.program,
9057
9103
  eventAuthority: this.eventAuthorityPDA
9058
9104
  },
9059
- {
9060
- params: {
9061
- srcEid,
9062
- sender: Array.from(sender),
9063
- receiver,
9064
- nonce
9065
- }
9066
- }
9105
+ this.program
9067
9106
  );
9068
- ix.keys.forEach((key) => {
9107
+ keys.forEach((key) => {
9069
9108
  key.isSigner = false;
9070
9109
  });
9071
9110
  return [
@@ -9074,7 +9113,7 @@ var Endpoint = class {
9074
9113
  isSigner: false,
9075
9114
  isWritable: false
9076
9115
  }
9077
- ].concat(ix.keys);
9116
+ ].concat(keys);
9078
9117
  }
9079
9118
  async isDefaultSendLibrary(connection, messageLibProgram, dstEid, commitmentOrConfig) {
9080
9119
  const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
@@ -9215,7 +9254,7 @@ var Endpoint = class {
9215
9254
  if (timeout2) {
9216
9255
  const slot = await connection.getSlot();
9217
9256
  const timestamp = await connection.getBlockTime(slot);
9218
- invariant2(timestamp, "timestamp should not be null");
9257
+ invariant3(timestamp, "timestamp should not be null");
9219
9258
  const isValid = parseInt(timeout2.expiry.toString()) > timestamp;
9220
9259
  return {
9221
9260
  programId: defaultInfo.messageLib,
@@ -9233,12 +9272,12 @@ var Endpoint = class {
9233
9272
  };
9234
9273
  }
9235
9274
  const messageLibInfo = await connection.getAccountInfo(info.messageLib, commitmentOrConfig);
9236
- invariant2(messageLibInfo, "messageLibInfo should not be null");
9275
+ invariant3(messageLibInfo, "messageLibInfo should not be null");
9237
9276
  const { timeout } = info;
9238
9277
  if (timeout) {
9239
9278
  const slot = await connection.getSlot();
9240
9279
  const timestamp = await connection.getBlockTime(slot);
9241
- invariant2(timestamp, "timestamp should not be null");
9280
+ invariant3(timestamp, "timestamp should not be null");
9242
9281
  const isValid = parseInt(timeout.expiry.toString()) > timestamp;
9243
9282
  return {
9244
9283
  programId: messageLibInfo.owner,
@@ -9259,7 +9298,7 @@ var Endpoint = class {
9259
9298
  return PayloadHash.fromAccountInfo(accountInfo, 0)[0];
9260
9299
  }
9261
9300
  async getComposedMessageState(connection, from, params, commitmentOrConfig) {
9262
- const message = ethers.utils.arrayify(ethers.utils.keccak256(params.message));
9301
+ const message = arrayify(keccak256(params.message));
9263
9302
  const [composedMessagePDA] = this.endpointDeriver.composedMessage(
9264
9303
  from,
9265
9304
  Uint8Array.from(params.guid),
@@ -9323,15 +9362,15 @@ var simple_message_lib_exports = {};
9323
9362
  __export(simple_message_lib_exports, {
9324
9363
  PROGRAM_ID: () => PROGRAM_ID3,
9325
9364
  SimpleMessageLib: () => SimpleMessageLib,
9326
- accounts: () => accounts_exports2,
9365
+ accounts: () => accounts_exports3,
9327
9366
  errors: () => errors_exports2,
9328
- instructions: () => instructions_exports2,
9329
- types: () => types_exports2
9367
+ instructions: () => instructions_exports3,
9368
+ types: () => types_exports3
9330
9369
  });
9331
9370
 
9332
9371
  // src/generated/simple_messagelib/accounts/index.ts
9333
- var accounts_exports2 = {};
9334
- __export(accounts_exports2, {
9372
+ var accounts_exports3 = {};
9373
+ __export(accounts_exports3, {
9335
9374
  MessageLib: () => MessageLib,
9336
9375
  ReceiveConfigStore: () => ReceiveConfigStore,
9337
9376
  SendConfigStore: () => SendConfigStore,
@@ -9749,8 +9788,8 @@ __export(errors_exports2, {
9749
9788
  OnlyRevertError: () => OnlyRevertError,
9750
9789
  OnlyWhitelistedCallerError: () => OnlyWhitelistedCallerError,
9751
9790
  SendReentrancyError: () => SendReentrancyError,
9752
- errorFromCode: () => errorFromCode3,
9753
- errorFromName: () => errorFromName3
9791
+ errorFromCode: () => errorFromCode2,
9792
+ errorFromName: () => errorFromName2
9754
9793
  });
9755
9794
  var createErrorFromCodeLookup3 = /* @__PURE__ */ new Map();
9756
9795
  var createErrorFromNameLookup3 = /* @__PURE__ */ new Map();
@@ -9865,18 +9904,18 @@ var OnlyRevertError = class _OnlyRevertError extends Error {
9865
9904
  };
9866
9905
  createErrorFromCodeLookup3.set(6007, () => new OnlyRevertError());
9867
9906
  createErrorFromNameLookup3.set("OnlyRevert", () => new OnlyRevertError());
9868
- function errorFromCode3(code) {
9907
+ function errorFromCode2(code) {
9869
9908
  const createError = createErrorFromCodeLookup3.get(code);
9870
9909
  return createError != null ? createError() : null;
9871
9910
  }
9872
- function errorFromName3(name) {
9911
+ function errorFromName2(name) {
9873
9912
  const createError = createErrorFromNameLookup3.get(name);
9874
9913
  return createError != null ? createError() : null;
9875
9914
  }
9876
9915
 
9877
9916
  // src/generated/simple_messagelib/instructions/index.ts
9878
- var instructions_exports2 = {};
9879
- __export(instructions_exports2, {
9917
+ var instructions_exports3 = {};
9918
+ __export(instructions_exports3, {
9880
9919
  createInitConfigInstruction: () => createInitConfigInstruction2,
9881
9920
  createInitConfigInstructionAccounts: () => createInitConfigInstructionAccounts2,
9882
9921
  createInitDefaultConfigInstruction: () => createInitDefaultConfigInstruction,
@@ -11201,8 +11240,8 @@ function createWithdrawFeesInstructionAccounts(accounts, programId = new web35.P
11201
11240
  }
11202
11241
 
11203
11242
  // src/generated/simple_messagelib/types/index.ts
11204
- var types_exports2 = {};
11205
- __export(types_exports2, {
11243
+ var types_exports3 = {};
11244
+ __export(types_exports3, {
11206
11245
  initConfigParamsBeet: () => initConfigParamsBeet2,
11207
11246
  initDefaultConfigParamsBeet: () => initDefaultConfigParamsBeet,
11208
11247
  initMessageLibParamsBeet: () => initMessageLibParamsBeet,
@@ -11322,36 +11361,21 @@ var SimpleMessageLib = class {
11322
11361
  */
11323
11362
  async getSendIXAccountMetaForCPI(_connection, payer, _path) {
11324
11363
  const [msgLib] = this.deriver.messageLib();
11325
- const ix = createSendInstruction3(
11364
+ const cpiAccounts = createSendInstructionAccounts3(
11326
11365
  {
11327
11366
  endpoint: PublicKey.default,
11328
11367
  // useless
11329
11368
  messageLib: msgLib,
11330
11369
  payer
11331
11370
  },
11332
- /// Fake value. params is useless.
11333
- {
11334
- params: {
11335
- packet: {
11336
- nonce: 0,
11337
- srcEid: 0,
11338
- sender: PublicKey.default,
11339
- dstEid: 0,
11340
- receiver: Array.from(PublicKey.default.toBytes()),
11341
- message: Uint8Array.from(Buffer.from("test")),
11342
- guid: Array.from(PublicKey.default.toBytes())
11343
- },
11344
- options: Uint8Array.from(Buffer.from("test")),
11345
- nativeFee: 0
11346
- }
11347
- }
11371
+ this.program
11348
11372
  );
11349
- ix.keys.forEach((key) => {
11373
+ cpiAccounts.forEach((key) => {
11350
11374
  if (!payer.equals(key.pubkey)) {
11351
11375
  key.isSigner = false;
11352
11376
  }
11353
11377
  });
11354
- return Promise.resolve(ix.keys.slice(1));
11378
+ return Promise.resolve(cpiAccounts.slice(1));
11355
11379
  }
11356
11380
  async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
11357
11381
  const [msgLib] = this.deriver.messageLib();
@@ -11387,7 +11411,7 @@ var SimpleMessageLib = class {
11387
11411
  const [sendConfig] = this.deriver.sendConfig(eid, oappID);
11388
11412
  const [receiveConfig] = this.deriver.receiveConfig(eid, oappID);
11389
11413
  const [messageLib] = this.deriver.messageLib();
11390
- const ix = createInitConfigInstruction2(
11414
+ const keys = createInitConfigInstructionAccounts2(
11391
11415
  {
11392
11416
  endpoint: PublicKey.default,
11393
11417
  // useless
@@ -11396,23 +11420,30 @@ var SimpleMessageLib = class {
11396
11420
  sendConfig,
11397
11421
  receiveConfig
11398
11422
  },
11399
- // Fake params, just to get the ix.keys
11400
- {
11401
- params: {
11402
- eid,
11403
- oapp: oappID
11404
- }
11405
- }
11423
+ this.program
11406
11424
  );
11407
- ix.keys.forEach((key) => {
11425
+ keys.forEach((key) => {
11408
11426
  if (!payer.equals(key.pubkey)) {
11409
11427
  key.isSigner = false;
11410
11428
  }
11411
11429
  });
11412
- return Promise.resolve(ix.keys.slice(1));
11430
+ return Promise.resolve(keys.slice(1));
11413
11431
  }
11414
- async getSetConfigIXAccountMetaForCPI(_endpointProgram, _oappID, _eid) {
11415
- return Promise.reject(new Error("Method not implemented."));
11432
+ async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
11433
+ const [sendConfig] = this.deriver.sendConfig(eid, oappID);
11434
+ const [receiveConfig] = this.deriver.receiveConfig(eid, oappID);
11435
+ const [msgLib] = this.deriver.messageLib();
11436
+ const accounts = createSetConfigInstructionAccounts2(
11437
+ {
11438
+ endpoint: PublicKey.default,
11439
+ // useless
11440
+ sendConfig,
11441
+ receiveConfig,
11442
+ messageLib: msgLib
11443
+ },
11444
+ this.program
11445
+ );
11446
+ return Promise.resolve(accounts.slice(1));
11416
11447
  }
11417
11448
  };
11418
11449
 
@@ -11460,7 +11491,7 @@ __export(uln_exports, {
11460
11491
  VerifyingError: () => VerifyingError,
11461
11492
  ZeroMessageSizeError: () => ZeroMessageSizeError,
11462
11493
  accountProviders: () => accountProviders6,
11463
- accounts: () => accounts_exports5,
11494
+ accounts: () => accounts_exports6,
11464
11495
  commitVerificationInstructionDiscriminator: () => commitVerificationInstructionDiscriminator,
11465
11496
  commitVerificationParamsBeet: () => commitVerificationParamsBeet,
11466
11497
  commitVerificationStruct: () => commitVerificationStruct,
@@ -11497,8 +11528,8 @@ __export(uln_exports, {
11497
11528
  createVersionInstructionAccounts: () => createVersionInstructionAccounts3,
11498
11529
  createWithdrawRentInstruction: () => createWithdrawRentInstruction2,
11499
11530
  createWithdrawRentInstructionAccounts: () => createWithdrawRentInstructionAccounts2,
11500
- errorFromCode: () => errorFromCode6,
11501
- errorFromName: () => errorFromName6,
11531
+ errorFromCode: () => errorFromCode5,
11532
+ errorFromName: () => errorFromName5,
11502
11533
  errors: () => errors_exports4,
11503
11534
  events: () => events_exports4,
11504
11535
  executorConfigBeet: () => executorConfigBeet2,
@@ -11514,7 +11545,7 @@ __export(uln_exports, {
11514
11545
  initVerifyInstructionDiscriminator: () => initVerifyInstructionDiscriminator2,
11515
11546
  initVerifyParamsBeet: () => initVerifyParamsBeet2,
11516
11547
  initVerifyStruct: () => initVerifyStruct2,
11517
- instructions: () => instructions_exports5,
11548
+ instructions: () => instructions_exports6,
11518
11549
  isConfigExecutor: () => isConfigExecutor,
11519
11550
  isConfigReceiveUln: () => isConfigReceiveUln,
11520
11551
  isConfigSendUln: () => isConfigSendUln,
@@ -11548,7 +11579,7 @@ __export(uln_exports, {
11548
11579
  transferAdminStruct: () => transferAdminStruct4,
11549
11580
  treasuryBeet: () => treasuryBeet,
11550
11581
  treasuryFeeBeet: () => treasuryFeeBeet,
11551
- types: () => types_exports5,
11582
+ types: () => types_exports6,
11552
11583
  ulnConfigBeet: () => ulnConfigBeet2,
11553
11584
  ulnSettingsBeet: () => ulnSettingsBeet,
11554
11585
  ulnSettingsDiscriminator: () => ulnSettingsDiscriminator,
@@ -11570,11 +11601,11 @@ __export(dvn_exports2, {
11570
11601
  DVN: () => DVN,
11571
11602
  PROGRAM_ID: () => PROGRAM_ID4,
11572
11603
  SolanaSignerExt: () => SolanaSignerExt,
11573
- accounts: () => accounts_exports3,
11604
+ accounts: () => accounts_exports4,
11574
11605
  errors: () => errors_exports3,
11575
11606
  events: () => events_exports2,
11576
- instructions: () => instructions_exports3,
11577
- types: () => types_exports3
11607
+ instructions: () => instructions_exports4,
11608
+ types: () => types_exports4
11578
11609
  });
11579
11610
 
11580
11611
  // src/generated/dvn/index.ts
@@ -11626,8 +11657,8 @@ __export(dvn_exports, {
11626
11657
  dstConfigBeet: () => dstConfigBeet,
11627
11658
  dvnConfigBeet: () => dvnConfigBeet,
11628
11659
  dvnConfigDiscriminator: () => dvnConfigDiscriminator,
11629
- errorFromCode: () => errorFromCode4,
11630
- errorFromName: () => errorFromName4,
11660
+ errorFromCode: () => errorFromCode3,
11661
+ errorFromName: () => errorFromName3,
11631
11662
  executeHashBeet: () => executeHashBeet,
11632
11663
  executeHashDiscriminator: () => executeHashDiscriminator,
11633
11664
  executeTransactionDigestBeet: () => executeTransactionDigestBeet,
@@ -11671,8 +11702,8 @@ __export(dvn_exports, {
11671
11702
  });
11672
11703
 
11673
11704
  // src/generated/dvn/accounts/index.ts
11674
- var accounts_exports3 = {};
11675
- __export(accounts_exports3, {
11705
+ var accounts_exports4 = {};
11706
+ __export(accounts_exports4, {
11676
11707
  DvnConfig: () => DvnConfig,
11677
11708
  ExecuteHash: () => ExecuteHash,
11678
11709
  ReceiveConfig: () => ReceiveConfig,
@@ -12122,8 +12153,8 @@ __export(errors_exports3, {
12122
12153
  TooManyOptionTypesError: () => TooManyOptionTypesError,
12123
12154
  UnexpiredExecuteHashError: () => UnexpiredExecuteHashError,
12124
12155
  UniqueOwnersError: () => UniqueOwnersError,
12125
- errorFromCode: () => errorFromCode4,
12126
- errorFromName: () => errorFromName4
12156
+ errorFromCode: () => errorFromCode3,
12157
+ errorFromName: () => errorFromName3
12127
12158
  });
12128
12159
  var createErrorFromCodeLookup4 = /* @__PURE__ */ new Map();
12129
12160
  var createErrorFromNameLookup4 = /* @__PURE__ */ new Map();
@@ -12355,18 +12386,18 @@ createErrorFromNameLookup4.set(
12355
12386
  "EidNotSupported",
12356
12387
  () => new EidNotSupportedError()
12357
12388
  );
12358
- function errorFromCode4(code) {
12389
+ function errorFromCode3(code) {
12359
12390
  const createError = createErrorFromCodeLookup4.get(code);
12360
12391
  return createError != null ? createError() : null;
12361
12392
  }
12362
- function errorFromName4(name) {
12393
+ function errorFromName3(name) {
12363
12394
  const createError = createErrorFromNameLookup4.get(name);
12364
12395
  return createError != null ? createError() : null;
12365
12396
  }
12366
12397
 
12367
12398
  // src/generated/dvn/instructions/index.ts
12368
- var instructions_exports3 = {};
12369
- __export(instructions_exports3, {
12399
+ var instructions_exports4 = {};
12400
+ __export(instructions_exports4, {
12370
12401
  closeExecuteInstructionDiscriminator: () => closeExecuteInstructionDiscriminator,
12371
12402
  closeExecuteStruct: () => closeExecuteStruct,
12372
12403
  createCloseExecuteInstruction: () => createCloseExecuteInstruction,
@@ -13121,8 +13152,8 @@ function createWithdrawFeeInstructionAccounts(accounts, programId = new web35.Pu
13121
13152
  }
13122
13153
 
13123
13154
  // src/generated/dvn/types/index.ts
13124
- var types_exports3 = {};
13125
- __export(types_exports3, {
13155
+ var types_exports4 = {};
13156
+ __export(types_exports4, {
13126
13157
  VerificationState: () => VerificationState,
13127
13158
  aclBeet: () => aclBeet,
13128
13159
  adminConfigBeet: () => adminConfigBeet,
@@ -13312,7 +13343,7 @@ var DVN = class {
13312
13343
  }
13313
13344
  getHashBytes(digest) {
13314
13345
  const [digestBytes] = executeTransactionDigestBeet.serialize(digest);
13315
- const hash = ethers.utils.keccak256(digestBytes);
13346
+ const hash = keccak256(digestBytes);
13316
13347
  return Buffer.from(hash.slice(2), "hex");
13317
13348
  }
13318
13349
  async invoke(connection, vid, payer, instruction, expiration, sign) {
@@ -13622,7 +13653,7 @@ __export(executor_exports, {
13622
13653
  ZeroLzComposeGasProvidedError: () => ZeroLzComposeGasProvidedError,
13623
13654
  ZeroLzReceiveGasProvidedError: () => ZeroLzReceiveGasProvidedError,
13624
13655
  accountProviders: () => accountProviders5,
13625
- accounts: () => accounts_exports4,
13656
+ accounts: () => accounts_exports5,
13626
13657
  aclBeet: () => aclBeet2,
13627
13658
  adminSetConfigInstructionDiscriminator: () => adminSetConfigInstructionDiscriminator,
13628
13659
  adminSetConfigParamsBeet: () => adminSetConfigParamsBeet,
@@ -13647,8 +13678,8 @@ __export(executor_exports, {
13647
13678
  createQuoteExecutorInstruction: () => createQuoteExecutorInstruction,
13648
13679
  createQuoteExecutorInstructionAccounts: () => createQuoteExecutorInstructionAccounts,
13649
13680
  dstConfigBeet: () => dstConfigBeet2,
13650
- errorFromCode: () => errorFromCode5,
13651
- errorFromName: () => errorFromName5,
13681
+ errorFromCode: () => errorFromCode4,
13682
+ errorFromName: () => errorFromName4,
13652
13683
  events: () => events_exports3,
13653
13684
  executableInstructionDiscriminator: () => executableInstructionDiscriminator,
13654
13685
  executableParamsBeet: () => executableParamsBeet,
@@ -13662,7 +13693,7 @@ __export(executor_exports, {
13662
13693
  initExecutorInstructionDiscriminator: () => initExecutorInstructionDiscriminator,
13663
13694
  initExecutorParamsBeet: () => initExecutorParamsBeet,
13664
13695
  initExecutorStruct: () => initExecutorStruct,
13665
- instructions: () => instructions_exports4,
13696
+ instructions: () => instructions_exports5,
13666
13697
  isAdminSetConfigParamsDefaultMultiplierBps: () => isAdminSetConfigParamsDefaultMultiplierBps,
13667
13698
  isAdminSetConfigParamsDstConfigs: () => isAdminSetConfigParamsDstConfigs,
13668
13699
  isAdminSetConfigParamsPriceFeed: () => isAdminSetConfigParamsPriceFeed,
@@ -13688,12 +13719,12 @@ __export(executor_exports, {
13688
13719
  quoteExecutorInstructionDiscriminator: () => quoteExecutorInstructionDiscriminator,
13689
13720
  quoteExecutorParamsBeet: () => quoteExecutorParamsBeet,
13690
13721
  quoteExecutorStruct: () => quoteExecutorStruct,
13691
- types: () => types_exports4
13722
+ types: () => types_exports5
13692
13723
  });
13693
13724
 
13694
13725
  // src/generated/executor/accounts/index.ts
13695
- var accounts_exports4 = {};
13696
- __export(accounts_exports4, {
13726
+ var accounts_exports5 = {};
13727
+ __export(accounts_exports5, {
13697
13728
  ExecutorConfig: () => ExecutorConfig,
13698
13729
  Nonce: () => Nonce2,
13699
13730
  accountProviders: () => accountProviders5,
@@ -14032,8 +14063,8 @@ var nativeDropAppliedEventBeet = new beet201.FixableBeetArgsStruct(
14032
14063
  );
14033
14064
 
14034
14065
  // src/generated/executor/instructions/index.ts
14035
- var instructions_exports4 = {};
14036
- __export(instructions_exports4, {
14066
+ var instructions_exports5 = {};
14067
+ __export(instructions_exports5, {
14037
14068
  adminSetConfigInstructionDiscriminator: () => adminSetConfigInstructionDiscriminator,
14038
14069
  adminSetConfigStruct: () => adminSetConfigStruct,
14039
14070
  composeInstructionDiscriminator: () => composeInstructionDiscriminator,
@@ -14919,8 +14950,8 @@ function createQuoteExecutorInstructionAccounts(accounts, programId = new web35.
14919
14950
  }
14920
14951
 
14921
14952
  // src/generated/executor/types/index.ts
14922
- var types_exports4 = {};
14923
- __export(types_exports4, {
14953
+ var types_exports5 = {};
14954
+ __export(types_exports5, {
14924
14955
  ExecutionState: () => ExecutionState,
14925
14956
  aclBeet: () => aclBeet2,
14926
14957
  adminSetConfigParamsBeet: () => adminSetConfigParamsBeet,
@@ -15109,8 +15140,8 @@ var treasurySetEventBeet = new beet201.FixableBeetArgsStruct(
15109
15140
  function getEventDiscriminator(event) {
15110
15141
  const hash = crypto.createHash("sha256");
15111
15142
  hash.update(`event:${event}`);
15112
- const sha256 = hash.digest("hex");
15113
- return sha256.slice(0, 16);
15143
+ const sha2562 = hash.digest("hex");
15144
+ return sha2562.slice(0, 16);
15114
15145
  }
15115
15146
  async function extractSentPacketEventByTxHash(connection, program, signature, commitment) {
15116
15147
  const events = await extractEventFromTransactionSignature(
@@ -15318,7 +15349,7 @@ async function isAccountInitialized(connection, account, commitmentOrConfig) {
15318
15349
  async function buildMessageV0(connection, payerKey, instructions, commitmentOrConfig = "confirmed", blockhash) {
15319
15350
  return new TransactionMessage({
15320
15351
  payerKey,
15321
- recentBlockhash: blockhash ?? (await connection.getLatestBlockhash()).blockhash,
15352
+ recentBlockhash: blockhash ?? (await connection.getLatestBlockhash(commitmentOrConfig)).blockhash,
15322
15353
  instructions
15323
15354
  }).compileToV0Message();
15324
15355
  }
@@ -15331,7 +15362,7 @@ async function buildVersionedTransaction(connection, payerKey, instructions, com
15331
15362
  );
15332
15363
  }
15333
15364
  function instructionDiscriminator(method) {
15334
- return Buffer.from(ethers.utils.sha256(Buffer.from(`global:${method}`)).substring(2), "hex").subarray(0, 8);
15365
+ return Buffer.from(sha256(Buffer.from(`global:${method}`)).substring(2), "hex").subarray(0, 8);
15335
15366
  }
15336
15367
  async function simulateTransaction(connection, instructions, programId, payer, commitment = "confirmed", blockhash, lookupTableAddress) {
15337
15368
  const tx = await buildVersionedTransaction(
@@ -15356,11 +15387,11 @@ async function simulateTransaction(connection, instructions, programId, payer, c
15356
15387
  async function lzReceive(connection, payer, packet, callerParams = Uint8Array.from([0, 0]), commitmentOrConfig) {
15357
15388
  const { message: message_, sender, srcEid, guid, receiver: receiver_ } = packet;
15358
15389
  const receiver = new PublicKey(addressToBytes32(receiver_));
15359
- const message = ethers.utils.arrayify(message_);
15390
+ const message = arrayify(message_);
15360
15391
  const params = {
15361
15392
  srcEid,
15362
- sender: Array.from(ethers.utils.arrayify(sender)),
15363
- guid: Array.from(ethers.utils.arrayify(guid)),
15393
+ sender: Array.from(arrayify(sender)),
15394
+ guid: Array.from(arrayify(guid)),
15364
15395
  message,
15365
15396
  callerParams,
15366
15397
  nonce: parseInt(packet.nonce)
@@ -15745,11 +15776,11 @@ createErrorFromNameLookup5.set(
15745
15776
  "ExecutorIsAdmin",
15746
15777
  () => new ExecutorIsAdminError()
15747
15778
  );
15748
- function errorFromCode5(code) {
15779
+ function errorFromCode4(code) {
15749
15780
  const createError = createErrorFromCodeLookup5.get(code);
15750
15781
  return createError != null ? createError() : null;
15751
15782
  }
15752
- function errorFromName5(name) {
15783
+ function errorFromName4(name) {
15753
15784
  const createError = createErrorFromNameLookup5.get(name);
15754
15785
  return createError != null ? createError() : null;
15755
15786
  }
@@ -15994,7 +16025,7 @@ var Executor = class {
15994
16025
  }
15995
16026
  ].concat(ixAccounts);
15996
16027
  }
15997
- async execute(connection, executor, endpointProgram, packet, extraData, value = new BN6(0), computeUnits = 2e5, commitmentOrConfig) {
16028
+ async execute(connection, executor, endpointProgram, packet, extraData, value = new BN2(0), computeUnits = 2e5, commitmentOrConfig) {
15998
16029
  const [config] = this.deriver.config();
15999
16030
  const endpointEventDeriver = new EventPDADeriver(endpointProgram);
16000
16031
  const executorEventDeriver = new EventPDADeriver(this.program);
@@ -16002,7 +16033,7 @@ var Executor = class {
16002
16033
  const receiver = new PublicKey(addressToBytes32(receiver_));
16003
16034
  const receiverInfo = await connection.getParsedAccountInfo(receiver, commitmentOrConfig);
16004
16035
  const receiverProgram = new PublicKey(receiverInfo.value.owner);
16005
- const message = ethers.utils.arrayify(message_);
16036
+ const message = arrayify(message_);
16006
16037
  const accounts = await getLzReceiveAccounts(
16007
16038
  connection,
16008
16039
  executor,
@@ -16010,8 +16041,8 @@ var Executor = class {
16010
16041
  receiverProgram,
16011
16042
  {
16012
16043
  srcEid,
16013
- sender: Array.from(ethers.utils.arrayify(sender)),
16014
- guid: Array.from(ethers.utils.arrayify(guid)),
16044
+ sender: Array.from(arrayify(sender)),
16045
+ guid: Array.from(arrayify(guid)),
16015
16046
  message,
16016
16047
  callerParams: extraData,
16017
16048
  nonce: parseInt(packet.nonce)
@@ -16040,9 +16071,9 @@ var Executor = class {
16040
16071
  receiver,
16041
16072
  lzReceive: {
16042
16073
  srcEid,
16043
- sender: Array.from(ethers.utils.arrayify(sender)),
16074
+ sender: Array.from(arrayify(sender)),
16044
16075
  nonce: parseInt(nonce),
16045
- guid: Array.from(ethers.utils.arrayify(guid)),
16076
+ guid: Array.from(arrayify(guid)),
16046
16077
  message,
16047
16078
  extraData
16048
16079
  },
@@ -16053,7 +16084,7 @@ var Executor = class {
16053
16084
  this.program
16054
16085
  );
16055
16086
  }
16056
- async compose(connection, executor, endpointProgram, event, extraData, value = new BN6(0), computeUnits = 4e5, commitmentOrConfig) {
16087
+ async compose(connection, executor, endpointProgram, event, extraData, value = new BN2(0), computeUnits = 4e5, commitmentOrConfig) {
16057
16088
  const [config] = this.deriver.config();
16058
16089
  const endpointEventDeriver = new EventPDADeriver(endpointProgram);
16059
16090
  const executorEventDeriver = new EventPDADeriver(this.program);
@@ -16112,8 +16143,8 @@ var Executor = class {
16112
16143
  };
16113
16144
 
16114
16145
  // src/generated/uln/accounts/index.ts
16115
- var accounts_exports5 = {};
16116
- __export(accounts_exports5, {
16146
+ var accounts_exports6 = {};
16147
+ __export(accounts_exports6, {
16117
16148
  Confirmations: () => Confirmations,
16118
16149
  ReceiveConfig: () => ReceiveConfig2,
16119
16150
  SendConfig: () => SendConfig,
@@ -16639,8 +16670,8 @@ __export(errors_exports4, {
16639
16670
  UnsortedError: () => UnsortedError,
16640
16671
  VerifyingError: () => VerifyingError,
16641
16672
  ZeroMessageSizeError: () => ZeroMessageSizeError,
16642
- errorFromCode: () => errorFromCode6,
16643
- errorFromName: () => errorFromName6
16673
+ errorFromCode: () => errorFromCode5,
16674
+ errorFromName: () => errorFromName5
16644
16675
  });
16645
16676
  var createErrorFromCodeLookup6 = /* @__PURE__ */ new Map();
16646
16677
  var createErrorFromNameLookup6 = /* @__PURE__ */ new Map();
@@ -17109,18 +17140,18 @@ var InvalidPayerError = class _InvalidPayerError extends Error {
17109
17140
  };
17110
17141
  createErrorFromCodeLookup6.set(6032, () => new InvalidPayerError());
17111
17142
  createErrorFromNameLookup6.set("InvalidPayer", () => new InvalidPayerError());
17112
- function errorFromCode6(code) {
17143
+ function errorFromCode5(code) {
17113
17144
  const createError = createErrorFromCodeLookup6.get(code);
17114
17145
  return createError != null ? createError() : null;
17115
17146
  }
17116
- function errorFromName6(name) {
17147
+ function errorFromName5(name) {
17117
17148
  const createError = createErrorFromNameLookup6.get(name);
17118
17149
  return createError != null ? createError() : null;
17119
17150
  }
17120
17151
 
17121
17152
  // src/generated/uln/instructions/index.ts
17122
- var instructions_exports5 = {};
17123
- __export(instructions_exports5, {
17153
+ var instructions_exports6 = {};
17154
+ __export(instructions_exports6, {
17124
17155
  commitVerificationInstructionDiscriminator: () => commitVerificationInstructionDiscriminator,
17125
17156
  commitVerificationStruct: () => commitVerificationStruct,
17126
17157
  createCommitVerificationInstruction: () => createCommitVerificationInstruction,
@@ -18775,8 +18806,8 @@ function createWithdrawRentInstructionAccounts2(accounts, programId = new web35.
18775
18806
  }
18776
18807
 
18777
18808
  // src/generated/uln/types/index.ts
18778
- var types_exports5 = {};
18779
- __export(types_exports5, {
18809
+ var types_exports6 = {};
18810
+ __export(types_exports6, {
18780
18811
  commitVerificationParamsBeet: () => commitVerificationParamsBeet,
18781
18812
  configBeet: () => configBeet,
18782
18813
  executorConfigBeet: () => executorConfigBeet2,
@@ -18960,7 +18991,7 @@ var Uln = class {
18960
18991
  */
18961
18992
  async getQuoteIXAccountMetaForCPI(connection, _payer, path, commitment) {
18962
18993
  const { sender: sender_, dstEid } = path;
18963
- const sender = new PublicKey(ethers.utils.arrayify(sender_));
18994
+ const sender = new PublicKey(arrayify(sender_));
18964
18995
  const { executorProgram, dvnPrograms } = await this.getWorkerPrograms(connection, sender, dstEid, commitment);
18965
18996
  const [defaultSendConfig] = this.deriver.defaultSendConfig(dstEid);
18966
18997
  const [sendConfig] = this.deriver.sendConfig(dstEid, sender);
@@ -18991,7 +19022,7 @@ var Uln = class {
18991
19022
  */
18992
19023
  async getSendIXAccountMetaForCPI(connection, payer, path, commitment = "confirmed") {
18993
19024
  const { sender: sender_, dstEid } = path;
18994
- const sender = new PublicKey(ethers.utils.arrayify(sender_));
19025
+ const sender = new PublicKey(arrayify(sender_));
18995
19026
  const { executorProgram, dvnPrograms } = await this.getWorkerPrograms(connection, sender, dstEid, commitment);
18996
19027
  const [sendConfig] = this.deriver.sendConfig(dstEid, sender);
18997
19028
  const [defaultSendConfig] = this.deriver.defaultSendConfig(dstEid);
@@ -19123,7 +19154,7 @@ var Uln = class {
19123
19154
  params: {
19124
19155
  packetHeader: Array.from(Uint8Array.from(Buffer.from(packet.header().slice(2), "hex"))),
19125
19156
  payloadHash: Array.from(payloadHashBytes),
19126
- confirmations: typeof confirmations === "string" ? new BN6(confirmations) : confirmations
19157
+ confirmations: typeof confirmations === "string" ? new BN2(confirmations) : confirmations
19127
19158
  }
19128
19159
  },
19129
19160
  this.program
@@ -19137,8 +19168,8 @@ var Uln = class {
19137
19168
  const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
19138
19169
  const [confirmationsPDA] = this.deriver.confirmations(headerHashBytes, payloadHashBytes, dvn);
19139
19170
  const endpoint = new endpoint_exports.Endpoint(endpointProgram);
19140
- const receiver = new PublicKey(ethers.utils.arrayify(packet.receiver()));
19141
- const sender = ethers.utils.arrayify(packet.sender());
19171
+ const receiver = new PublicKey(arrayify(packet.receiver()));
19172
+ const sender = arrayify(packet.sender());
19142
19173
  const nonce = await endpoint.getNonce(connection, receiver, packet.srcEid(), sender, commitmentOrConfig);
19143
19174
  const pendingNonce = await endpoint.getPendingInboundNonce(
19144
19175
  connection,
@@ -19175,7 +19206,7 @@ var Uln = class {
19175
19206
  const packet = PacketV1Codec.fromBytes(packetBytes);
19176
19207
  const payloadHash = packet.payloadHash();
19177
19208
  const srcEid = packet.srcEid();
19178
- const receiver = new PublicKey(ethers.utils.arrayify(packet.receiver()));
19209
+ const receiver = new PublicKey(arrayify(packet.receiver()));
19179
19210
  const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
19180
19211
  const [defaultReceiveConfig] = this.deriver.defaultReceiveConfig(srcEid);
19181
19212
  const [receiveConfig] = this.deriver.receiveConfig(srcEid, receiver);
@@ -19209,7 +19240,7 @@ var Uln = class {
19209
19240
  },
19210
19241
  {
19211
19242
  params: {
19212
- packetHeader: Array.from(ethers.utils.arrayify(packet.header())),
19243
+ packetHeader: Array.from(arrayify(packet.header())),
19213
19244
  payloadHash: Array.from(payloadHashBytes)
19214
19245
  }
19215
19246
  },
@@ -19326,14 +19357,14 @@ var pricefeed_exports = {};
19326
19357
  __export(pricefeed_exports, {
19327
19358
  PROGRAM_ID: () => PROGRAM_ID7,
19328
19359
  PriceFeed: () => PriceFeed2,
19329
- accounts: () => accounts_exports6,
19330
- instructions: () => instructions_exports6,
19331
- types: () => types_exports6
19360
+ accounts: () => accounts_exports7,
19361
+ instructions: () => instructions_exports7,
19362
+ types: () => types_exports7
19332
19363
  });
19333
19364
 
19334
19365
  // src/generated/pricefeed/accounts/index.ts
19335
- var accounts_exports6 = {};
19336
- __export(accounts_exports6, {
19366
+ var accounts_exports7 = {};
19367
+ __export(accounts_exports7, {
19337
19368
  PriceFeed: () => PriceFeed,
19338
19369
  accountProviders: () => accountProviders7,
19339
19370
  priceFeedBeet: () => priceFeedBeet,
@@ -19533,8 +19564,8 @@ var priceFeedBeet = new beet201.FixableBeetStruct(
19533
19564
  var accountProviders7 = { PriceFeed };
19534
19565
 
19535
19566
  // src/generated/pricefeed/instructions/index.ts
19536
- var instructions_exports6 = {};
19537
- __export(instructions_exports6, {
19567
+ var instructions_exports7 = {};
19568
+ __export(instructions_exports7, {
19538
19569
  createGetFeeInstruction: () => createGetFeeInstruction,
19539
19570
  createGetFeeInstructionAccounts: () => createGetFeeInstructionAccounts,
19540
19571
  createInitPriceFeedInstruction: () => createInitPriceFeedInstruction,
@@ -20019,8 +20050,8 @@ function createTransferAdminInstructionAccounts5(accounts, programId = new web35
20019
20050
  }
20020
20051
 
20021
20052
  // src/generated/pricefeed/types/index.ts
20022
- var types_exports6 = {};
20023
- __export(types_exports6, {
20053
+ var types_exports7 = {};
20054
+ __export(types_exports7, {
20024
20055
  getFeeParamsBeet: () => getFeeParamsBeet,
20025
20056
  initPriceFeedParamsBeet: () => initPriceFeedParamsBeet,
20026
20057
  isModelTypeArbitrum: () => isModelTypeArbitrum,
@@ -20194,11 +20225,9 @@ var PriceFeed2 = class {
20194
20225
  }
20195
20226
  };
20196
20227
 
20197
- // src/OftTools.ts
20198
- var OftTools_exports = {};
20199
- __export(OftTools_exports, {
20200
- ConfigType: () => ConfigType,
20201
- OFT_SEED: () => OFT_SEED2,
20228
+ // src/oft-tools.ts
20229
+ var oft_tools_exports = {};
20230
+ __export(oft_tools_exports, {
20202
20231
  SOLANA_EID: () => SOLANA_EID,
20203
20232
  createInitAdapterOftIx: () => createInitAdapterOftIx,
20204
20233
  createInitConfigIx: () => createInitConfigIx,
@@ -20221,211 +20250,443 @@ __export(OftTools_exports, {
20221
20250
  getEndpointConfig: () => getEndpointConfig,
20222
20251
  getEnforcedOptions: () => getEnforcedOptions,
20223
20252
  getPeerAddress: () => getPeerAddress,
20224
- isAccountInitialized: () => isAccountInitialized2,
20225
20253
  quoteOft: () => quoteOft,
20226
20254
  quoteWithUln: () => quoteWithUln,
20227
20255
  sendWithUln: () => sendWithUln
20228
20256
  });
20229
- var SOLANA_EID = 1;
20230
- var OFT_SEED2 = "Oft";
20231
- var NONCE_SEED2 = "Nonce";
20232
- var PENDING_NONCE_SEED2 = "PendingNonce";
20233
- var ENDPOINT_SEED2 = "Endpoint";
20234
- var SEND_CONFIG_SEED2 = "SendConfig";
20235
- var RECEIVE_CONFIG_SEED2 = "ReceiveConfig";
20236
- var OAPP_SEED2 = "OApp";
20237
- var EVENT_SEED2 = "__event_authority";
20238
- var LZ_RECEIVE_TYPES_SEED2 = "LzReceiveTypes";
20239
- var PEER_SEED2 = "Peer";
20240
- var ENFORCED_OPTIONS_SEED2 = "EnforcedOptions";
20241
- var SEND_LIBRARY_CONFIG_SEED2 = "SendLibraryConfig";
20242
- var RECEIVE_LIBRARY_CONFIG_SEED2 = "ReceiveLibraryConfig";
20243
- var MESSAGE_LIB_SEED2 = "MessageLib";
20244
- var ULN_SEED2 = MESSAGE_LIB_SEED2;
20245
- var ConfigType = /* @__PURE__ */ ((ConfigType2) => {
20246
- ConfigType2[ConfigType2["Executor"] = 1] = "Executor";
20247
- ConfigType2[ConfigType2["SendUln"] = 2] = "SendUln";
20248
- ConfigType2[ConfigType2["ReceiveUln"] = 3] = "ReceiveUln";
20249
- return ConfigType2;
20250
- })(ConfigType || {});
20251
- async function isAccountInitialized2(connection, account, commitmentOrConfig = "confirmed") {
20252
- return connection.getAccountInfo(account, commitmentOrConfig).then((res) => {
20253
- return res !== null;
20254
- });
20255
- }
20256
- async function createNonceTx(connection, nonceAccount, nonceAuthority, instructions, commitmentOrConfig = "confirmed") {
20257
- const nonceAccountInfo = await connection.getNonce(nonceAccount, commitmentOrConfig);
20258
- if (nonceAccountInfo === null) {
20259
- throw new Error("Invalid nonce account");
20257
+
20258
+ // src/oft.ts
20259
+ var oft_exports = {};
20260
+ __export(oft_exports, {
20261
+ OFT_DECIMALS: () => OFT_DECIMALS,
20262
+ OFT_DEFAULT_PROGRAM_ID: () => PROGRAM_ID,
20263
+ Oft: () => Oft,
20264
+ accounts: () => accounts_exports,
20265
+ instructions: () => instructions_exports,
20266
+ types: () => types_exports
20267
+ });
20268
+ var OFT_DECIMALS = 6;
20269
+ var Oft = class {
20270
+ constructor(program, endpointProgram, _tokenProgram, mintKp, escrowKp) {
20271
+ this.program = program;
20272
+ this.endpointProgram = endpointProgram;
20273
+ this.deriver = new OftPDADeriver(this.program);
20274
+ this.endpoint = new endpoint_exports.Endpoint(endpointProgram);
20275
+ const [eventAuthorityPDA] = new EventPDADeriver(this.program).eventAuthority();
20276
+ this.eventAuthorityPDA = eventAuthorityPDA;
20277
+ this.mintKp = mintKp;
20278
+ this.escrowKp = escrowKp;
20279
+ this.isAdapter = escrowKp !== void 0;
20280
+ this.tokenProgram = _tokenProgram;
20260
20281
  }
20261
- const { nonce } = nonceAccountInfo;
20262
- const nonceAdvanceIx = SystemProgram.nonceAdvance({
20263
- noncePubkey: nonceAccount,
20264
- authorizedPubkey: nonceAuthority
20265
- });
20266
- return new Transaction({
20267
- recentBlockhash: nonce,
20268
- nonceInfo: {
20269
- nonce,
20270
- nonceInstruction: nonceAdvanceIx
20271
- }
20272
- }).add(...instructions);
20273
- }
20274
- async function createInitAdapterOftIx(payer, admin, mint, lzDelegate, escrow, sharedDecimals = 6, tokenProgram = TOKEN_PROGRAM_ID) {
20275
- const [oftConfig] = PublicKey.findProgramAddressSync(
20276
- [Buffer.from(OFT_SEED2, "utf-8"), escrow.toBuffer()],
20277
- PROGRAM_ID
20278
- );
20279
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20280
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20281
- PROGRAM_ID2
20282
- );
20283
- const [endpointEventAuthority] = PublicKey.findProgramAddressSync(
20284
- [Buffer.from(EVENT_SEED2, "utf-8")],
20285
- PROGRAM_ID2
20286
- );
20287
- const [lzReceiveTypes] = PublicKey.findProgramAddressSync(
20288
- [Buffer.from(LZ_RECEIVE_TYPES_SEED2, "utf-8"), oftConfig.toBuffer()],
20289
- PROGRAM_ID
20290
- );
20291
- const registerOappIx = createRegisterOappInstruction(
20292
- {
20293
- payer,
20294
- oapp: oftConfig,
20295
- oappRegistry: oAppRegistry,
20296
- eventAuthority: endpointEventAuthority,
20297
- program: PROGRAM_ID
20298
- },
20299
- {
20300
- params: {
20301
- delegate: lzDelegate
20302
- }
20282
+ getOftConfig() {
20283
+ if (this.isAdapter) {
20284
+ return this.deriver.oftConfig(this.escrowKp)[0];
20303
20285
  }
20304
- );
20305
- for (const acc of registerOappIx.keys) {
20306
- acc.isSigner = false;
20286
+ return this.deriver.oftConfig(this.mintKp)[0];
20307
20287
  }
20308
- return createInitAdapterOftInstruction(
20309
- {
20310
- payer,
20311
- oftConfig,
20312
- tokenMint: mint,
20313
- tokenEscrow: escrow,
20314
- lzReceiveTypesAccounts: lzReceiveTypes,
20315
- tokenProgram,
20316
- anchorRemainingAccounts: [
20317
- {
20318
- pubkey: PROGRAM_ID2,
20319
- isSigner: false,
20320
- isWritable: false
20321
- }
20322
- ].concat(
20323
- ...registerOappIx.keys,
20324
- {
20325
- pubkey: endpointEventAuthority,
20326
- isSigner: false,
20327
- isWritable: false
20328
- },
20329
- {
20330
- pubkey: PROGRAM_ID2,
20331
- isSigner: false,
20332
- isWritable: false
20288
+ async getVersion() {
20289
+ return Promise.resolve([createVersionInstruction(this.program)]);
20290
+ }
20291
+ async setDelegate(admin, delegate) {
20292
+ const endpointEventAuthority = this.endpoint.eventAuthorityPDA;
20293
+ const oftConfig = this.getOftConfig();
20294
+ const [oAppRegistry] = this.endpoint.endpointDeriver.oappRegistry(oftConfig);
20295
+ const endpointSetDelegateKeys = endpoint_exports.instructions.createSetDelegateInstructionAccounts(
20296
+ {
20297
+ oapp: oftConfig,
20298
+ oappRegistry: oAppRegistry,
20299
+ eventAuthority: endpointEventAuthority,
20300
+ program: this.endpointProgram
20301
+ },
20302
+ this.endpointProgram
20303
+ );
20304
+ for (const acc of endpointSetDelegateKeys) {
20305
+ acc.isSigner = false;
20306
+ }
20307
+ const ix = createSetDelegateInstruction(
20308
+ {
20309
+ admin,
20310
+ oftConfig: this.getOftConfig(),
20311
+ anchorRemainingAccounts: [
20312
+ {
20313
+ pubkey: this.endpointProgram,
20314
+ isSigner: false,
20315
+ isWritable: false
20316
+ },
20317
+ ...endpointSetDelegateKeys
20318
+ ]
20319
+ },
20320
+ {
20321
+ params: {
20322
+ delegate
20333
20323
  }
20324
+ },
20325
+ this.program
20326
+ );
20327
+ return Promise.resolve(ix);
20328
+ }
20329
+ async initOft(connection, payer, admin) {
20330
+ const oftConfig = this.getOftConfig();
20331
+ const endpointEventAuthority = this.endpoint.eventAuthorityPDA;
20332
+ const [oAppRegistry] = this.endpoint.endpointDeriver.oappRegistry(oftConfig);
20333
+ const [lzReceiveTypes] = PublicKey.findProgramAddressSync(
20334
+ [Buffer.from(LZ_RECEIVE_TYPES_SEED, "utf-8"), oftConfig.toBuffer()],
20335
+ this.program
20336
+ );
20337
+ const registerOappIxKeys = endpoint_exports.instructions.createRegisterOappInstructionAccounts(
20338
+ {
20339
+ payer: admin,
20340
+ oapp: oftConfig,
20341
+ oappRegistry: oAppRegistry,
20342
+ eventAuthority: endpointEventAuthority,
20343
+ program: this.program
20344
+ },
20345
+ this.program
20346
+ );
20347
+ for (const acc of registerOappIxKeys) {
20348
+ acc.isSigner = false;
20349
+ }
20350
+ const ret = [
20351
+ SystemProgram.createAccount({
20352
+ fromPubkey: admin,
20353
+ newAccountPubkey: this.mintKp,
20354
+ space: getMintLen([]),
20355
+ lamports: await connection.getMinimumBalanceForRentExemption(getMintLen([])),
20356
+ programId: this.tokenProgram
20357
+ }),
20358
+ createInitializeMintInstruction(
20359
+ this.mintKp,
20360
+ OFT_DECIMALS,
20361
+ this.isAdapter ? admin : oftConfig,
20362
+ null,
20363
+ this.tokenProgram
20334
20364
  )
20335
- },
20336
- {
20337
- params: {
20338
- admin,
20339
- sharedDecimals,
20340
- endpointProgram: PROGRAM_ID2
20365
+ ];
20366
+ if (this.isAdapter) {
20367
+ return ret.concat(
20368
+ createInitAdapterOftInstruction(
20369
+ {
20370
+ payer,
20371
+ oftConfig,
20372
+ tokenMint: this.mintKp,
20373
+ tokenEscrow: this.escrowKp,
20374
+ lzReceiveTypesAccounts: lzReceiveTypes,
20375
+ tokenProgram: this.tokenProgram,
20376
+ anchorRemainingAccounts: [
20377
+ {
20378
+ pubkey: this.endpointProgram,
20379
+ isSigner: false,
20380
+ isWritable: false
20381
+ }
20382
+ ].concat(
20383
+ ...registerOappIxKeys,
20384
+ {
20385
+ pubkey: endpointEventAuthority,
20386
+ isSigner: false,
20387
+ isWritable: false
20388
+ },
20389
+ {
20390
+ pubkey: this.endpointProgram,
20391
+ isSigner: false,
20392
+ isWritable: false
20393
+ }
20394
+ )
20395
+ },
20396
+ {
20397
+ params: {
20398
+ admin,
20399
+ sharedDecimals: OFT_DECIMALS,
20400
+ endpointProgram: this.endpointProgram
20401
+ }
20402
+ }
20403
+ )
20404
+ );
20405
+ } else {
20406
+ return ret.concat(
20407
+ createInitOftInstruction(
20408
+ {
20409
+ payer,
20410
+ oftConfig,
20411
+ tokenMint: this.mintKp,
20412
+ lzReceiveTypesAccounts: lzReceiveTypes,
20413
+ tokenProgram: this.tokenProgram,
20414
+ anchorRemainingAccounts: [
20415
+ {
20416
+ pubkey: this.endpointProgram,
20417
+ isSigner: false,
20418
+ isWritable: false
20419
+ }
20420
+ ].concat(
20421
+ ...registerOappIxKeys,
20422
+ {
20423
+ pubkey: endpointEventAuthority,
20424
+ isSigner: false,
20425
+ isWritable: false
20426
+ },
20427
+ {
20428
+ pubkey: this.endpointProgram,
20429
+ isSigner: false,
20430
+ isWritable: false
20431
+ }
20432
+ )
20433
+ },
20434
+ {
20435
+ params: {
20436
+ admin,
20437
+ sharedDecimals: OFT_DECIMALS,
20438
+ endpointProgram: this.endpointProgram,
20439
+ mintAuthority: admin
20440
+ }
20441
+ },
20442
+ this.program
20443
+ )
20444
+ );
20445
+ }
20446
+ }
20447
+ getAddressB32() {
20448
+ const [oftConfig] = this.deriver.oftConfig(this.isAdapter ? this.escrowKp : this.mintKp);
20449
+ const ret = new Uint8Array(32);
20450
+ ret.fill(0).set(oftConfig.toBytes());
20451
+ return ret;
20452
+ }
20453
+ async mint_to(signer, to, amount) {
20454
+ const ix = createMintToInstruction(
20455
+ {
20456
+ minter: signer,
20457
+ oftConfig: this.getOftConfig(),
20458
+ tokenDest: to,
20459
+ tokenMint: this.mintKp,
20460
+ tokenProgram: this.tokenProgram
20461
+ },
20462
+ {
20463
+ params: {
20464
+ amount: new BN2(amount.toString())
20465
+ }
20341
20466
  }
20467
+ );
20468
+ return Promise.resolve(ix);
20469
+ }
20470
+ async setPeer(_peer, admin, dstEid) {
20471
+ const [oftConfig] = this.deriver.oftConfig(this.isAdapter ? this.escrowKp : this.mintKp);
20472
+ const [peer] = this.deriver.peer(oftConfig, dstEid);
20473
+ const ix = createSetPeerInstruction(
20474
+ {
20475
+ admin,
20476
+ peer,
20477
+ oftConfig
20478
+ },
20479
+ {
20480
+ params: {
20481
+ dstEid,
20482
+ peer: new Array(32 - _peer.length).fill(0).concat(_peer)
20483
+ }
20484
+ },
20485
+ this.program
20486
+ );
20487
+ return Promise.resolve(ix);
20488
+ }
20489
+ async setEnforcedOptions(admin, send, sendAndCall, dstEid) {
20490
+ const oftConfig = this.getOftConfig();
20491
+ const [enforcedOptions] = this.deriver.enforcedOptions(oftConfig, dstEid);
20492
+ const ix = createSetEnforcedOptionsInstruction(
20493
+ {
20494
+ admin,
20495
+ enforcedOptions,
20496
+ oftConfig
20497
+ },
20498
+ {
20499
+ params: {
20500
+ dstEid,
20501
+ send,
20502
+ sendAndCall
20503
+ }
20504
+ },
20505
+ this.program
20506
+ );
20507
+ return Promise.resolve(ix);
20508
+ }
20509
+ async send(connection, payer, tokenSource, to, dstEid, amountLd, minAmountLd, fee, options = new Uint8Array(), composeMsg = null, commitmentOrConfig = "confirmed") {
20510
+ const oftConfig = this.getOftConfig();
20511
+ const [peer] = this.deriver.peer(oftConfig, dstEid);
20512
+ const [enforcedOptions] = this.deriver.enforcedOptions(oftConfig, dstEid);
20513
+ const peerinfo = await connection.getAccountInfo(peer);
20514
+ const peerAddress = peerinfo.data.subarray(8, 32 + 8);
20515
+ const msgLibProgram = await this.getSendLibraryProgram(connection, payer, dstEid);
20516
+ const [endpointSettings] = this.endpoint.endpointDeriver.setting();
20517
+ const receiverInfo = await Peer.fromAccountAddress(connection, peer, commitmentOrConfig);
20518
+ const packetPath = {
20519
+ srcEid: 0,
20520
+ dstEid,
20521
+ sender: hexlify(oftConfig.toBytes()),
20522
+ receiver: hexlify(receiverInfo.address)
20523
+ };
20524
+ invariant3(await isAccountInitialized(connection, endpointSettings), "endpointSettings account not initialized");
20525
+ invariant3(await isAccountInitialized(connection, peer), "peer account not initialized");
20526
+ invariant3(await isAccountInitialized(connection, enforcedOptions), "enforcedOptions account not initialized");
20527
+ invariant3(await isAccountInitialized(connection, payer), "payer account not initialized");
20528
+ invariant3(
20529
+ await isAccountInitialized(
20530
+ connection,
20531
+ this.endpoint.endpointDeriver.nonce(oftConfig, dstEid, peerAddress)[0]
20532
+ ),
20533
+ "nonce account not initialized"
20534
+ );
20535
+ return createSendInstruction(
20536
+ {
20537
+ signer: payer,
20538
+ peer,
20539
+ enforcedOptions,
20540
+ oftConfig,
20541
+ tokenSource,
20542
+ tokenEscrow: this.escrowKp,
20543
+ tokenMint: this.mintKp,
20544
+ tokenProgram: this.tokenProgram,
20545
+ eventAuthority: this.eventAuthorityPDA,
20546
+ program: this.program,
20547
+ // Get remaining accounts from msgLib(simple_msgLib or uln)
20548
+ anchorRemainingAccounts: await this.endpoint.getSendIXAccountMetaForCPI(
20549
+ connection,
20550
+ payer,
20551
+ packetPath,
20552
+ msgLibProgram,
20553
+ commitmentOrConfig
20554
+ )
20555
+ },
20556
+ {
20557
+ params: {
20558
+ dstEid,
20559
+ to,
20560
+ amountLd: new BN2(amountLd.toString()),
20561
+ minAmountLd: new BN2(minAmountLd.toString()),
20562
+ options,
20563
+ composeMsg,
20564
+ nativeFee: fee.nativeFee,
20565
+ lzTokenFee: fee.lzTokenFee
20566
+ }
20567
+ },
20568
+ this.program
20569
+ );
20570
+ }
20571
+ async setRateLimit(signer, dstEid, capacity, refillPerSecond, enabled) {
20572
+ const [peerPda] = this.deriver.peer(this.getOftConfig(), dstEid);
20573
+ const ix = createSetRateLimitInstruction(
20574
+ {
20575
+ admin: signer,
20576
+ peer: peerPda,
20577
+ oftConfig: this.getOftConfig()
20578
+ },
20579
+ {
20580
+ params: {
20581
+ dstEid,
20582
+ capacity: new BN2(capacity.toString()),
20583
+ refillPerSecond: new BN2(refillPerSecond.toString()),
20584
+ enabled
20585
+ }
20586
+ },
20587
+ this.program
20588
+ );
20589
+ return Promise.resolve(ix);
20590
+ }
20591
+ async lzReceive(connection, payer, packet) {
20592
+ const deserializedPacket = PacketSerializer.deserialize(packet);
20593
+ return lzReceive(connection, payer, deserializedPacket);
20594
+ }
20595
+ async getSendLibraryProgram(connection, payer, dstEid) {
20596
+ const oftConfig = this.getOftConfig();
20597
+ const sendLibInfo = await this.endpoint.getSendLibrary(connection, oftConfig, dstEid);
20598
+ if (!sendLibInfo?.programId) {
20599
+ throw new Error("Send library not initialized or blocked message library");
20342
20600
  }
20343
- );
20344
- }
20345
- async function createInitNativeOftIx(payer, admin, mint, oftMintAuthority, lzDelegate, sharedDecimals = 6, tokenProgram = TOKEN_PROGRAM_ID) {
20346
- const [oftConfig] = PublicKey.findProgramAddressSync(
20347
- [Buffer.from(OFT_SEED2, "utf-8"), mint.toBuffer()],
20348
- PROGRAM_ID
20349
- );
20350
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20351
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20352
- PROGRAM_ID2
20353
- );
20354
- const [endpointEventAuthority] = PublicKey.findProgramAddressSync(
20355
- [Buffer.from(EVENT_SEED2, "utf-8")],
20356
- PROGRAM_ID2
20357
- );
20358
- const [lzReceiveTypes] = PublicKey.findProgramAddressSync(
20359
- [Buffer.from(LZ_RECEIVE_TYPES_SEED2, "utf-8"), oftConfig.toBuffer()],
20360
- PROGRAM_ID
20361
- );
20362
- const registerOappIx = createRegisterOappInstruction(
20601
+ const { programId: msgLibProgram } = sendLibInfo;
20602
+ const msgLibVersion = await this.endpoint.getMessageLibVersion(connection, payer, msgLibProgram);
20603
+ if (msgLibVersion?.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
20604
+ return new simple_message_lib_exports.SimpleMessageLib(msgLibProgram);
20605
+ } else if (msgLibVersion?.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
20606
+ return new uln_exports.Uln(msgLibProgram);
20607
+ }
20608
+ throw new Error(`Unsupported message library version: ${JSON.stringify(msgLibVersion, null, 2)}`);
20609
+ }
20610
+ };
20611
+
20612
+ // src/oft-tools.ts
20613
+ var SOLANA_EID = 1;
20614
+ async function createInitAdapterOftIx(payer, admin, mint, escrow, sharedDecimals = 6, tokenProgram = TOKEN_PROGRAM_ID, oftProgramId = PROGRAM_ID, endpointProgram = PROGRAM_ID2) {
20615
+ const deriver = new OftPDADeriver(oftProgramId);
20616
+ const endpoint = new Endpoint(endpointProgram);
20617
+ const [oftConfig] = deriver.oftConfig(escrow);
20618
+ const [lzReceiveTypes] = deriver.lzReceiveTypesAccounts(oftConfig);
20619
+ return instructions_exports.createInitAdapterOftInstruction(
20363
20620
  {
20364
20621
  payer,
20365
- oapp: oftConfig,
20366
- oappRegistry: oAppRegistry,
20367
- eventAuthority: endpointEventAuthority,
20368
- program: PROGRAM_ID
20622
+ oftConfig,
20623
+ tokenMint: mint,
20624
+ tokenEscrow: escrow,
20625
+ lzReceiveTypesAccounts: lzReceiveTypes,
20626
+ tokenProgram,
20627
+ anchorRemainingAccounts: endpoint.getRegisterOappIxAccountMetaForCPI(payer, oftConfig)
20369
20628
  },
20370
20629
  {
20371
20630
  params: {
20372
- delegate: lzDelegate
20631
+ admin,
20632
+ sharedDecimals,
20633
+ endpointProgram
20373
20634
  }
20374
20635
  }
20375
20636
  );
20376
- for (const acc of registerOappIx.keys) {
20377
- acc.isSigner = false;
20637
+ }
20638
+ async function createNonceTx(connection, nonceAccount, nonceAuthority, instructions, commitmentOrConfig = "confirmed") {
20639
+ const nonceAccountInfo = await connection.getNonce(nonceAccount, commitmentOrConfig);
20640
+ if (nonceAccountInfo === null) {
20641
+ throw new Error("Invalid nonce account");
20378
20642
  }
20379
- return createInitOftInstruction(
20643
+ const { nonce } = nonceAccountInfo;
20644
+ const nonceAdvanceIx = SystemProgram.nonceAdvance({
20645
+ noncePubkey: nonceAccount,
20646
+ authorizedPubkey: nonceAuthority
20647
+ });
20648
+ return new Transaction({
20649
+ recentBlockhash: nonce,
20650
+ nonceInfo: {
20651
+ nonce,
20652
+ nonceInstruction: nonceAdvanceIx
20653
+ }
20654
+ }).add(...instructions);
20655
+ }
20656
+ async function createInitNativeOftIx(payer, admin, mint, oftMintAuthority, sharedDecimals = 6, tokenProgram = TOKEN_PROGRAM_ID, oftProgramId = PROGRAM_ID, endpointProgram = PROGRAM_ID2) {
20657
+ const deriver = new OftPDADeriver(oftProgramId);
20658
+ const endpoint = new Endpoint(endpointProgram);
20659
+ const [oftConfig] = deriver.oftConfig(mint);
20660
+ const [lzReceiveTypes] = deriver.lzReceiveTypesAccounts(oftConfig);
20661
+ return instructions_exports.createInitOftInstruction(
20380
20662
  {
20381
20663
  payer,
20382
20664
  oftConfig,
20383
20665
  tokenMint: mint,
20384
20666
  lzReceiveTypesAccounts: lzReceiveTypes,
20385
20667
  tokenProgram,
20386
- anchorRemainingAccounts: [
20387
- {
20388
- pubkey: PROGRAM_ID2,
20389
- isSigner: false,
20390
- isWritable: false
20391
- }
20392
- ].concat(
20393
- ...registerOappIx.keys,
20394
- {
20395
- pubkey: endpointEventAuthority,
20396
- isSigner: false,
20397
- isWritable: false
20398
- },
20399
- {
20400
- pubkey: PROGRAM_ID2,
20401
- isSigner: false,
20402
- isWritable: false
20403
- }
20404
- )
20668
+ anchorRemainingAccounts: endpoint.getRegisterOappIxAccountMetaForCPI(payer, oftConfig)
20405
20669
  },
20406
20670
  {
20407
20671
  params: {
20408
20672
  admin,
20409
20673
  sharedDecimals,
20410
- endpointProgram: PROGRAM_ID2,
20411
- mintAuthority: oftMintAuthority
20674
+ mintAuthority: oftMintAuthority,
20675
+ endpointProgram
20412
20676
  }
20413
20677
  },
20414
- PROGRAM_ID
20678
+ oftProgramId
20415
20679
  );
20416
20680
  }
20417
- async function createSetPeerIx(admin, oftConfig, dstEid, peer) {
20681
+ async function createSetPeerIx(admin, oftConfig, dstEid, peer, oftProgramId = PROGRAM_ID) {
20418
20682
  if (peer.length !== 32) {
20419
20683
  throw new Error("Peer must be 32 bytes (left-padded with zeroes)");
20420
20684
  }
20421
20685
  if (dstEid % 3e4 == 0) {
20422
20686
  throw new Error("Invalid dstEid");
20423
20687
  }
20424
- const [peerPda] = PublicKey.findProgramAddressSync(
20425
- [Buffer.from(PEER_SEED2, "utf-8"), oftConfig.toBuffer(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20426
- PROGRAM_ID
20427
- );
20428
- return createSetPeerInstruction(
20688
+ const [peerPda] = new OftPDADeriver(oftProgramId).peer(oftConfig, dstEid);
20689
+ return instructions_exports.createSetPeerInstruction(
20429
20690
  {
20430
20691
  admin,
20431
20692
  peer: peerPda,
@@ -20437,45 +20698,36 @@ async function createSetPeerIx(admin, oftConfig, dstEid, peer) {
20437
20698
  peer
20438
20699
  }
20439
20700
  },
20440
- PROGRAM_ID
20701
+ oftProgramId
20441
20702
  );
20442
20703
  }
20443
- async function createSetDelegateIx(admin, oftConfig, delegate) {
20444
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20445
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20446
- PROGRAM_ID2
20447
- );
20448
- const [endpointEventAuthority] = PublicKey.findProgramAddressSync(
20449
- [Buffer.from(EVENT_SEED2, "utf-8")],
20450
- PROGRAM_ID2
20451
- );
20452
- const endpointSetDelegateIx = createSetDelegateInstruction2(
20704
+ async function createSetDelegateIx(admin, oftConfig, delegate, oftProgramId = PROGRAM_ID, endpointProgram = PROGRAM_ID2) {
20705
+ const endpoint = new Endpoint(endpointProgram);
20706
+ const [oAppRegistry] = endpoint.endpointDeriver.oappRegistry(oftConfig);
20707
+ const endpointEventAuthority = endpoint.eventAuthorityPDA;
20708
+ const keys = instructions_exports2.createSetDelegateInstructionAccounts(
20453
20709
  {
20454
20710
  oapp: oftConfig,
20455
20711
  oappRegistry: oAppRegistry,
20456
20712
  eventAuthority: endpointEventAuthority,
20457
- program: PROGRAM_ID2
20713
+ program: endpointProgram
20458
20714
  },
20459
- {
20460
- params: {
20461
- delegate
20462
- }
20463
- }
20715
+ endpointProgram
20464
20716
  );
20465
- for (const acc of endpointSetDelegateIx.keys) {
20717
+ for (const acc of keys) {
20466
20718
  acc.isSigner = false;
20467
20719
  }
20468
- return createSetDelegateInstruction(
20720
+ return instructions_exports.createSetDelegateInstruction(
20469
20721
  {
20470
20722
  admin,
20471
20723
  oftConfig,
20472
20724
  anchorRemainingAccounts: [
20473
20725
  {
20474
- pubkey: PROGRAM_ID2,
20726
+ pubkey: endpointProgram,
20475
20727
  isSigner: false,
20476
20728
  isWritable: false
20477
20729
  },
20478
- ...endpointSetDelegateIx.keys
20730
+ ...keys
20479
20731
  ]
20480
20732
  },
20481
20733
  {
@@ -20483,151 +20735,34 @@ async function createSetDelegateIx(admin, oftConfig, delegate) {
20483
20735
  delegate
20484
20736
  }
20485
20737
  },
20486
- PROGRAM_ID
20487
- );
20488
- }
20489
- async function createInitSendLibraryIx(signer, oftConfig, dstEid) {
20490
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20491
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20492
- PROGRAM_ID2
20493
- );
20494
- const [sendLibraryConfig] = PublicKey.findProgramAddressSync(
20495
- [
20496
- Buffer.from(SEND_LIBRARY_CONFIG_SEED2, "utf-8"),
20497
- oftConfig.toBuffer(),
20498
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
20499
- ],
20500
- PROGRAM_ID2
20501
- );
20502
- return createInitSendLibraryInstruction(
20503
- {
20504
- delegate: signer,
20505
- oappRegistry: oAppRegistry,
20506
- sendLibraryConfig
20507
- },
20508
- {
20509
- params: {
20510
- sender: oftConfig,
20511
- eid: dstEid
20512
- }
20513
- },
20514
- PROGRAM_ID2
20515
- );
20516
- }
20517
- async function createInitReceiveLibraryIx(signer, oftConfig, remoteEid) {
20518
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20519
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20520
- PROGRAM_ID2
20521
- );
20522
- const [receiveLibraryConfig] = PublicKey.findProgramAddressSync(
20523
- [
20524
- Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED2, "utf-8"),
20525
- oftConfig.toBuffer(),
20526
- new BN6(remoteEid).toArrayLike(Buffer, "be", 4)
20527
- ],
20528
- PROGRAM_ID2
20529
- );
20530
- return createInitReceiveLibraryInstruction(
20531
- {
20532
- delegate: signer,
20533
- oappRegistry: oAppRegistry,
20534
- receiveLibraryConfig
20535
- },
20536
- {
20537
- params: {
20538
- receiver: oftConfig,
20539
- eid: remoteEid
20540
- }
20541
- },
20542
- PROGRAM_ID2
20738
+ oftProgramId
20543
20739
  );
20544
20740
  }
20545
- async function createSetSendLibraryIx(signer, oftConfig, sendLibraryProgram, dstEid) {
20546
- const [newSendLib] = PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED2, "utf8")], sendLibraryProgram);
20547
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20548
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20549
- PROGRAM_ID2
20550
- );
20551
- const [sendLibraryConfig] = PublicKey.findProgramAddressSync(
20552
- [
20553
- Buffer.from(SEND_LIBRARY_CONFIG_SEED2, "utf-8"),
20554
- oftConfig.toBuffer(),
20555
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
20556
- ],
20557
- PROGRAM_ID2
20558
- );
20559
- const [sendLibraryInfo] = PublicKey.findProgramAddressSync(
20560
- [Buffer.from(MESSAGE_LIB_SEED2, "utf-8"), newSendLib.toBuffer()],
20561
- PROGRAM_ID2
20562
- );
20563
- const [eventAuthority] = PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED2, "utf-8")], PROGRAM_ID2);
20564
- return createSetSendLibraryInstruction(
20565
- {
20566
- signer,
20567
- oappRegistry: oAppRegistry,
20568
- sendLibraryConfig,
20569
- messageLibInfo: sendLibraryInfo,
20570
- eventAuthority,
20571
- program: PROGRAM_ID2
20572
- },
20573
- {
20574
- params: {
20575
- sender: oftConfig,
20576
- eid: dstEid,
20577
- newLib: newSendLib
20578
- }
20579
- },
20580
- PROGRAM_ID2
20741
+ async function createInitSendLibraryIx(signer, oftConfig, dstEid, endpointProgram = PROGRAM_ID2) {
20742
+ const endpoint = new Endpoint(endpointProgram);
20743
+ return endpoint.initSendLibraryWithoutChecks(signer, oftConfig, dstEid);
20744
+ }
20745
+ async function createInitReceiveLibraryIx(signer, oftConfig, remoteEid, endpointProgram = PROGRAM_ID2) {
20746
+ const endpoint = new Endpoint(endpointProgram);
20747
+ return endpoint.initReceiveLibraryWithoutChecks(signer, oftConfig, remoteEid);
20748
+ }
20749
+ async function createSetSendLibraryIx(signer, oftConfig, sendLibraryProgram, dstEid, endpointProgram = PROGRAM_ID2) {
20750
+ const endpoint = new Endpoint(endpointProgram);
20751
+ return endpoint.setSendLibrary(signer, oftConfig, sendLibraryProgram, dstEid);
20752
+ }
20753
+ async function createSetReceiveLibraryIx(signer, oftConfig, receiveLibraryProgram, dstEid, gracePeriod, endpointProgram = PROGRAM_ID2) {
20754
+ const endpoint = new Endpoint(endpointProgram);
20755
+ return endpoint.setReceiveLibrary(
20756
+ signer,
20757
+ oftConfig,
20758
+ receiveLibraryProgram,
20759
+ dstEid,
20760
+ parseInt(gracePeriod.toString())
20581
20761
  );
20582
20762
  }
20583
- async function createSetReceiveLibraryIx(signer, oftConfig, receiveLibraryProgram, dstEid, gracePeriod) {
20584
- const [newReceiveLib] = PublicKey.findProgramAddressSync(
20585
- [Buffer.from(MESSAGE_LIB_SEED2, "utf8")],
20586
- receiveLibraryProgram
20587
- );
20588
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20589
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBuffer()],
20590
- PROGRAM_ID2
20591
- );
20592
- const [receiveLibraryConfig] = PublicKey.findProgramAddressSync(
20593
- [
20594
- Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED2, "utf-8"),
20595
- oftConfig.toBuffer(),
20596
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
20597
- ],
20598
- PROGRAM_ID2
20599
- );
20600
- const [receiveLibraryInfo] = PublicKey.findProgramAddressSync(
20601
- [Buffer.from(MESSAGE_LIB_SEED2, "utf-8"), newReceiveLib.toBuffer()],
20602
- PROGRAM_ID2
20603
- );
20604
- const [eventAuthority] = PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED2, "utf-8")], PROGRAM_ID2);
20605
- return createSetReceiveLibraryInstruction(
20606
- {
20607
- signer,
20608
- oappRegistry: oAppRegistry,
20609
- receiveLibraryConfig,
20610
- messageLibInfo: receiveLibraryInfo,
20611
- eventAuthority,
20612
- program: PROGRAM_ID2
20613
- },
20614
- {
20615
- params: {
20616
- receiver: oftConfig,
20617
- eid: dstEid,
20618
- newLib: newReceiveLib,
20619
- gracePeriod: new BN6(gracePeriod.toString())
20620
- }
20621
- },
20622
- PROGRAM_ID2
20623
- );
20624
- }
20625
- async function createMintToIx(signer, tokenMint, tokenDest, amount, tokenProgram = TOKEN_PROGRAM_ID) {
20626
- const [oftConfig] = PublicKey.findProgramAddressSync(
20627
- [Buffer.from(OFT_SEED2, "utf-8"), tokenMint.toBytes()],
20628
- PROGRAM_ID
20629
- );
20630
- return createMintToInstruction(
20763
+ async function createMintToIx(signer, tokenMint, tokenDest, amount, tokenProgram = TOKEN_PROGRAM_ID, oftProgramId = PROGRAM_ID) {
20764
+ const [oftConfig] = new OftPDADeriver(oftProgramId).oftConfig(tokenMint);
20765
+ return instructions_exports.createMintToInstruction(
20631
20766
  {
20632
20767
  minter: signer,
20633
20768
  oftConfig,
@@ -20637,18 +20772,15 @@ async function createMintToIx(signer, tokenMint, tokenDest, amount, tokenProgram
20637
20772
  },
20638
20773
  {
20639
20774
  params: {
20640
- amount: new BN6(amount.toString())
20775
+ amount: new BN2(amount.toString())
20641
20776
  }
20642
20777
  },
20643
- PROGRAM_ID
20778
+ oftProgramId
20644
20779
  );
20645
20780
  }
20646
- async function createSetRateLimitIx(signer, oftConfig, dstEid, capacity, refillPerSecond, enabled) {
20647
- const [peer] = PublicKey.findProgramAddressSync(
20648
- [Buffer.from(PEER_SEED2, "utf-8"), oftConfig.toBytes(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20649
- PROGRAM_ID
20650
- );
20651
- return createSetRateLimitInstruction(
20781
+ async function createSetRateLimitIx(signer, oftConfig, dstEid, capacity, refillPerSecond, enabled, oftProgramId = PROGRAM_ID) {
20782
+ const [peer] = new OftPDADeriver(oftProgramId).peer(oftConfig, dstEid);
20783
+ return instructions_exports.createSetRateLimitInstruction(
20652
20784
  {
20653
20785
  admin: signer,
20654
20786
  peer,
@@ -20657,160 +20789,31 @@ async function createSetRateLimitIx(signer, oftConfig, dstEid, capacity, refillP
20657
20789
  {
20658
20790
  params: {
20659
20791
  dstEid,
20660
- capacity: new BN6(capacity.toString()),
20661
- refillPerSecond: new BN6(refillPerSecond.toString()),
20792
+ capacity: new BN2(capacity.toString()),
20793
+ refillPerSecond: new BN2(refillPerSecond.toString()),
20662
20794
  enabled
20663
20795
  }
20664
20796
  },
20665
- PROGRAM_ID
20797
+ oftProgramId
20666
20798
  );
20667
20799
  }
20668
- async function createInitConfigIx(signer, oftConfig, messageLibProgram, dstEid) {
20669
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20670
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBytes()],
20671
- PROGRAM_ID2
20672
- );
20673
- const [messageLib] = PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED2, "utf-8")], messageLibProgram);
20674
- const [messageLibInfo] = PublicKey.findProgramAddressSync(
20675
- [Buffer.from(MESSAGE_LIB_SEED2, "utf-8"), messageLib.toBytes()],
20676
- PROGRAM_ID2
20677
- );
20678
- const [endpointSettings] = PublicKey.findProgramAddressSync(
20679
- [Buffer.from(ENDPOINT_SEED2, "utf-8")],
20680
- PROGRAM_ID2
20681
- );
20682
- const [sendConfig] = PublicKey.findProgramAddressSync(
20683
- [Buffer.from(SEND_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4), oftConfig.toBytes()],
20684
- messageLibProgram
20685
- );
20686
- const [receiveConfig] = PublicKey.findProgramAddressSync(
20687
- [Buffer.from(RECEIVE_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4), oftConfig.toBytes()],
20688
- messageLibProgram
20689
- );
20690
- const initConfigMessageLibIx = createInitConfigInstruction3(
20691
- {
20692
- endpoint: endpointSettings,
20693
- payer: signer,
20694
- uln: messageLib,
20695
- sendConfig,
20696
- receiveConfig
20697
- },
20698
- {
20699
- params: {
20700
- oapp: oftConfig,
20701
- eid: dstEid
20702
- }
20703
- }
20704
- );
20705
- for (const acc of initConfigMessageLibIx.keys) {
20706
- if (!signer.equals(acc.pubkey)) {
20707
- acc.isSigner = false;
20708
- }
20800
+ async function createInitConfigIx(signer, oftConfig, dstEid, msgLibProgram = PROGRAM_ID6, endpointProgram = PROGRAM_ID2) {
20801
+ const endpoint = new Endpoint(endpointProgram);
20802
+ let msgLib;
20803
+ if (msgLibProgram.toBase58() === simple_message_lib_exports.PROGRAM_ID.toBase58()) {
20804
+ msgLib = new simple_message_lib_exports.SimpleMessageLib(msgLibProgram);
20805
+ } else {
20806
+ msgLib = new Uln(msgLibProgram);
20709
20807
  }
20710
- return createInitConfigInstruction(
20711
- {
20712
- delegate: signer,
20713
- oappRegistry: oAppRegistry,
20714
- messageLibInfo,
20715
- messageLib,
20716
- messageLibProgram,
20717
- anchorRemainingAccounts: initConfigMessageLibIx.keys.slice(1)
20718
- },
20719
- {
20720
- params: {
20721
- oapp: oftConfig,
20722
- eid: dstEid
20723
- }
20724
- }
20725
- );
20808
+ return endpoint.initOappConfig(signer, msgLib, signer, oftConfig, dstEid);
20726
20809
  }
20727
- async function createSetConfigIx(signer, oftConfig, dstEid, configType, config, messageLibProgram = PROGRAM_ID6) {
20728
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20729
- [Buffer.from(OAPP_SEED2, "utf-8"), oftConfig.toBytes()],
20730
- PROGRAM_ID2
20731
- );
20732
- const [messageLib] = PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED2, "utf-8")], messageLibProgram);
20733
- const [messageLibInfo] = PublicKey.findProgramAddressSync(
20734
- [Buffer.from(MESSAGE_LIB_SEED2, "utf-8"), messageLib.toBytes()],
20735
- PROGRAM_ID2
20736
- );
20737
- const [endpointSettings] = PublicKey.findProgramAddressSync(
20738
- [Buffer.from(ENDPOINT_SEED2, "utf-8")],
20739
- PROGRAM_ID2
20740
- );
20741
- const [defaultSendConfig] = PublicKey.findProgramAddressSync(
20742
- [Buffer.from(SEND_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20743
- messageLibProgram
20744
- );
20745
- const [sendConfig] = PublicKey.findProgramAddressSync(
20746
- [Buffer.from(SEND_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4), oftConfig.toBytes()],
20747
- messageLibProgram
20748
- );
20749
- const [defaultReceiveConfig] = PublicKey.findProgramAddressSync(
20750
- [Buffer.from(RECEIVE_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20751
- messageLibProgram
20752
- );
20753
- const [receiveConfig] = PublicKey.findProgramAddressSync(
20754
- [Buffer.from(RECEIVE_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4), oftConfig.toBytes()],
20755
- messageLibProgram
20756
- );
20757
- const [messageLibEventAuthority] = PublicKey.findProgramAddressSync(
20758
- [Buffer.from(EVENT_SEED2, "utf-8")],
20759
- messageLibProgram
20760
- );
20761
- const [ulnSettings] = PublicKey.findProgramAddressSync([Buffer.from(ULN_SEED2, "utf-8")], messageLibProgram);
20762
- const messageLibSetConfigIx = createSetConfigInstruction4(
20763
- {
20764
- endpoint: endpointSettings,
20765
- uln: ulnSettings,
20766
- sendConfig,
20767
- receiveConfig,
20768
- defaultSendConfig,
20769
- defaultReceiveConfig,
20770
- eventAuthority: messageLibEventAuthority,
20771
- program: messageLibProgram
20772
- },
20773
- {
20774
- params: {
20775
- oapp: oftConfig,
20776
- eid: dstEid,
20777
- configType,
20778
- config
20779
- }
20780
- },
20781
- messageLibProgram
20782
- );
20783
- for (const acc of messageLibSetConfigIx.keys) {
20784
- if (!signer.equals(acc.pubkey)) {
20785
- acc.isSigner = false;
20786
- }
20787
- }
20788
- return createSetConfigInstruction(
20789
- {
20790
- signer,
20791
- oappRegistry: oAppRegistry,
20792
- messageLibInfo,
20793
- messageLib,
20794
- messageLibProgram,
20795
- anchorRemainingAccounts: messageLibSetConfigIx.keys.slice(1)
20796
- },
20797
- {
20798
- params: {
20799
- oapp: oftConfig,
20800
- eid: dstEid,
20801
- configType,
20802
- config
20803
- }
20804
- },
20805
- PROGRAM_ID2
20806
- );
20810
+ async function createSetConfigIx(connection, signer, oftConfig, dstEid, configType, config, msgLibProgram = PROGRAM_ID6, endpointProgram = PROGRAM_ID2) {
20811
+ const endpoint = new Endpoint(endpointProgram);
20812
+ return endpoint.setOappConfig(connection, signer, oftConfig, msgLibProgram, dstEid, { configType, value: config });
20807
20813
  }
20808
- async function createSetEnforcedOptionsIx(admin, oftConfig, dstEid, sendOptions, sendAndCallOptions) {
20809
- const [enforcedOptions] = PublicKey.findProgramAddressSync(
20810
- [Buffer.from(ENFORCED_OPTIONS_SEED2, "utf-8"), oftConfig.toBytes(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20811
- PROGRAM_ID
20812
- );
20813
- return createSetEnforcedOptionsInstruction(
20814
+ async function createSetEnforcedOptionsIx(admin, oftConfig, dstEid, sendOptions, sendAndCallOptions, oftProgramId = PROGRAM_ID) {
20815
+ const [enforcedOptions] = new OftPDADeriver(oftProgramId).enforcedOptions(oftConfig, dstEid);
20816
+ return instructions_exports.createSetEnforcedOptionsInstruction(
20814
20817
  {
20815
20818
  admin,
20816
20819
  enforcedOptions,
@@ -20823,11 +20826,11 @@ async function createSetEnforcedOptionsIx(admin, oftConfig, dstEid, sendOptions,
20823
20826
  sendAndCall: sendAndCallOptions
20824
20827
  }
20825
20828
  },
20826
- PROGRAM_ID
20829
+ oftProgramId
20827
20830
  );
20828
20831
  }
20829
- async function createTransferAdminIx(signer, oftConfig, newAdmin) {
20830
- return createTransferAdminInstruction(
20832
+ async function createTransferAdminIx(signer, oftConfig, newAdmin, oftProgramId = PROGRAM_ID) {
20833
+ return instructions_exports.createTransferAdminInstruction(
20831
20834
  {
20832
20835
  admin: signer,
20833
20836
  oftConfig
@@ -20837,115 +20840,36 @@ async function createTransferAdminIx(signer, oftConfig, newAdmin) {
20837
20840
  admin: newAdmin
20838
20841
  }
20839
20842
  },
20840
- PROGRAM_ID
20843
+ oftProgramId
20841
20844
  );
20842
20845
  }
20843
- async function sendWithUln(connection, payer, tokenMint, tokenSource, dstEid, amountLd, minAmountLd, options, to, nativeFee, tokenEscrow = void 0, lzTokenFee = 0n, tokenProgram = TOKEN_PROGRAM_ID, composeMsg = null) {
20844
- const [oftInstance] = PublicKey.findProgramAddressSync(
20845
- [Buffer.from(OFT_SEED2, "utf-8"), tokenEscrow ? tokenEscrow.toBuffer() : tokenMint.toBuffer()],
20846
- PROGRAM_ID
20847
- );
20848
- const [peer] = PublicKey.findProgramAddressSync(
20849
- [Buffer.from(PEER_SEED2, "utf-8"), oftInstance.toBuffer(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20850
- PROGRAM_ID
20851
- );
20852
- const [oftEventAuthority] = PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED2, "utf-8")], PROGRAM_ID);
20853
- const peerInfo = await Peer.fromAccountAddress(connection, peer);
20854
- const peerAddress = peerInfo.address;
20855
- const [enforcedOptions] = PublicKey.findProgramAddressSync(
20856
- [
20857
- Buffer.from(ENFORCED_OPTIONS_SEED2, "utf-8"),
20858
- oftInstance.toBuffer(),
20859
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
20860
- ],
20861
- PROGRAM_ID
20862
- );
20863
- const messageLib = new Uln(PROGRAM_ID6);
20864
- const endpoint = new Endpoint(PROGRAM_ID2);
20865
- const remainingAccounts = await endpoint.getSendIXAccountMetaForCPI(
20846
+ async function sendWithUln(connection, payer, tokenMint, tokenSource, dstEid, amountLd, minAmountLd, options, to, nativeFee, tokenEscrow = void 0, lzTokenFee = 0n, tokenProgram = TOKEN_PROGRAM_ID, composeMsg = null, oftProgramId = PROGRAM_ID, endpointProgram = PROGRAM_ID2) {
20847
+ const oft = new Oft(oftProgramId, endpointProgram, tokenProgram, tokenMint, tokenEscrow);
20848
+ return oft.send(
20866
20849
  connection,
20867
20850
  payer,
20851
+ tokenSource,
20852
+ to,
20853
+ dstEid,
20854
+ amountLd,
20855
+ minAmountLd,
20868
20856
  {
20869
- srcEid: SOLANA_EID,
20870
- sender: ethers.utils.hexlify(oftInstance.toBytes()),
20871
- dstEid,
20872
- receiver: ethers.utils.hexlify(peerAddress)
20873
- },
20874
- messageLib
20875
- );
20876
- return createSendInstruction(
20877
- {
20878
- signer: payer,
20879
- peer,
20880
- enforcedOptions,
20881
- oftConfig: oftInstance,
20882
- tokenSource,
20883
- tokenEscrow,
20884
- tokenMint,
20885
- tokenProgram,
20886
- eventAuthority: oftEventAuthority,
20887
- program: PROGRAM_ID,
20888
- anchorRemainingAccounts: remainingAccounts
20857
+ nativeFee: new BN2(nativeFee.toString()),
20858
+ lzTokenFee: new BN2(lzTokenFee.toString())
20889
20859
  },
20890
- {
20891
- params: {
20892
- dstEid,
20893
- to,
20894
- amountLd: new BN6(amountLd.toString()),
20895
- minAmountLd: new BN6(minAmountLd.toString()),
20896
- options,
20897
- composeMsg,
20898
- nativeFee: new BN6(nativeFee.toString()),
20899
- lzTokenFee: new BN6(lzTokenFee.toString())
20900
- }
20901
- }
20860
+ options,
20861
+ composeMsg
20902
20862
  );
20903
20863
  }
20904
- async function createInitNonceIx(delegate, dstEid, oftInstance, remoteOappAddr) {
20905
- const [nonce] = PublicKey.findProgramAddressSync(
20906
- [Buffer.from(NONCE_SEED2), oftInstance.toBuffer(), new BN6(dstEid).toArrayLike(Buffer, "be", 4), remoteOappAddr],
20907
- PROGRAM_ID2
20908
- );
20909
- const [pendingNonce] = PublicKey.findProgramAddressSync(
20910
- [
20911
- Buffer.from(PENDING_NONCE_SEED2),
20912
- oftInstance.toBuffer(),
20913
- new BN6(dstEid).toArrayLike(Buffer, "be", 4),
20914
- remoteOappAddr
20915
- ],
20916
- PROGRAM_ID2
20917
- );
20918
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
20919
- [Buffer.from(OAPP_SEED2, "utf-8"), oftInstance.toBuffer()],
20920
- PROGRAM_ID2
20921
- );
20922
- return createInitNonceInstruction(
20923
- {
20924
- nonce,
20925
- pendingInboundNonce: pendingNonce,
20926
- oappRegistry: oAppRegistry,
20927
- delegate
20928
- },
20929
- {
20930
- params: {
20931
- localOapp: oftInstance,
20932
- remoteOapp: Array.from(remoteOappAddr),
20933
- remoteEid: dstEid
20934
- }
20935
- },
20936
- PROGRAM_ID2
20937
- );
20864
+ async function createInitNonceIx(delegate, dstEid, oftInstance, remoteOappAddr, endpointProgram = PROGRAM_ID2) {
20865
+ const endpoint = new Endpoint(endpointProgram);
20866
+ return endpoint.initOAppNonceWithoutChecks(delegate, dstEid, oftInstance, remoteOappAddr);
20938
20867
  }
20939
- async function quoteOft(connection, payer, tokenMint, dstEid, amountLd, minAmountLd, options, to, tokenEscrow = void 0, payInLzToken = false, composeMsg = null) {
20940
- const [oftInstance] = PublicKey.findProgramAddressSync(
20941
- [Buffer.from(OFT_SEED2, "utf-8"), tokenMint.toBuffer()],
20942
- PROGRAM_ID
20943
- );
20944
- const [peer] = PublicKey.findProgramAddressSync(
20945
- [Buffer.from(PEER_SEED2, "utf-8"), oftInstance.toBuffer(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20946
- PROGRAM_ID
20947
- );
20948
- const ix = createQuoteOftInstruction(
20868
+ async function quoteOft(connection, payer, tokenMint, dstEid, amountLd, minAmountLd, options, to, tokenEscrow = void 0, payInLzToken = false, composeMsg = null, tokenProgram = TOKEN_PROGRAM_ID, oftProgramId = PROGRAM_ID, endpointProgram = PROGRAM_ID2) {
20869
+ const oft = new Oft(oftProgramId, endpointProgram, tokenProgram, tokenMint, tokenEscrow);
20870
+ const oftInstance = oft.getOftConfig();
20871
+ const [peer] = oft.deriver.peer(oftInstance, dstEid);
20872
+ const ix = instructions_exports.createQuoteOftInstruction(
20949
20873
  {
20950
20874
  oftConfig: oftInstance,
20951
20875
  peer,
@@ -20955,8 +20879,8 @@ async function quoteOft(connection, payer, tokenMint, dstEid, amountLd, minAmoun
20955
20879
  params: {
20956
20880
  dstEid,
20957
20881
  to,
20958
- amountLd: new BN6(amountLd.toString()),
20959
- minAmountLd: new BN6(minAmountLd.toString()),
20882
+ amountLd: new BN2(amountLd.toString()),
20883
+ minAmountLd: new BN2(minAmountLd.toString()),
20960
20884
  options,
20961
20885
  payInLzToken,
20962
20886
  composeMsg
@@ -20964,57 +20888,30 @@ async function quoteOft(connection, payer, tokenMint, dstEid, amountLd, minAmoun
20964
20888
  }
20965
20889
  );
20966
20890
  const returnedValues = await simulateTransaction(connection, [ix], ix.programId, payer, "confirmed");
20967
- const oftLimits = oFTLimitsBeet.read(returnedValues, 0);
20968
- const [oftFeeDetail] = oFTFeeDetailBeet.deserialize(returnedValues, 20);
20969
- const oftReceipt = oFTReceiptBeet.read(returnedValues, returnedValues.length - oFTLimitsBeet.byteSize);
20970
- return {
20971
- oftLimits: {
20972
- minAmountLd: oftLimits.minAmountLd.toString(),
20973
- maxAmountLd: oftLimits.maxAmountLd.toString()
20974
- },
20975
- oftFeeDetail: {
20976
- feeAmountLd: oftFeeDetail.feeAmountLd.toString(),
20977
- description: oftFeeDetail.description
20978
- },
20979
- oftReceipt: {
20980
- amountSentLd: oftReceipt.amountSentLd.toString(),
20981
- amountReceivedLd: oftReceipt.amountReceivedLd.toString()
20982
- }
20983
- };
20984
- }
20985
- async function quoteWithUln(connection, payer, tokenMint, dstEid, amountLd, minAmountLd, options, to, tokenEscrow = void 0, payInLzToken = false, composeMsg = null) {
20986
- const [oftInstance] = tokenEscrow === void 0 ? PublicKey.findProgramAddressSync([Buffer.from(OFT_SEED2, "utf-8"), tokenMint.toBuffer()], PROGRAM_ID) : PublicKey.findProgramAddressSync([Buffer.from(OFT_SEED2, "utf-8"), tokenEscrow.toBuffer()], PROGRAM_ID);
20987
- const [peer] = PublicKey.findProgramAddressSync(
20988
- [Buffer.from(PEER_SEED2, "utf-8"), oftInstance.toBytes(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
20989
- PROGRAM_ID
20990
- );
20991
- const peerinfo = await connection.getAccountInfo(peer);
20992
- if (peerinfo === null) {
20993
- throw new Error("Peer not found");
20994
- }
20995
- const peerAddress = peerinfo.data.subarray(8, 32 + 8);
20996
- const [enforcedOptions] = PublicKey.findProgramAddressSync(
20997
- [
20998
- Buffer.from(ENFORCED_OPTIONS_SEED2, "utf-8"),
20999
- oftInstance.toBuffer(),
21000
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
21001
- ],
21002
- PROGRAM_ID
21003
- );
21004
- const messageLib = new Uln(PROGRAM_ID6);
21005
- const endpoint = new Endpoint(PROGRAM_ID2);
20891
+ const [result] = types_exports.quoteOftResultBeet.deserialize(returnedValues, 0);
20892
+ return result;
20893
+ }
20894
+ async function quoteWithUln(connection, payer, tokenMint, dstEid, amountLd, minAmountLd, options, to, tokenEscrow = void 0, payInLzToken = false, composeMsg = null, tokenProgram = TOKEN_PROGRAM_ID, oftProgramId = PROGRAM_ID, msgLibProgram = PROGRAM_ID6, endpointProgram = PROGRAM_ID2) {
20895
+ const oft = new Oft(oftProgramId, endpointProgram, tokenProgram, tokenMint, tokenEscrow);
20896
+ const oftInstance = oft.getOftConfig();
20897
+ const [enforcedOptions] = oft.deriver.enforcedOptions(oftInstance, dstEid);
20898
+ const [peer] = oft.deriver.peer(oftInstance, dstEid);
20899
+ const peerInfo = await accounts_exports.Peer.fromAccountAddress(connection, peer);
20900
+ const peerAddress = peerInfo.address;
20901
+ const messageLib = new Uln(msgLibProgram);
20902
+ const endpoint = new Endpoint(endpointProgram);
21006
20903
  const remainingAccounts = await endpoint.getQuoteIXAccountMetaForCPI(
21007
20904
  connection,
21008
20905
  payer,
21009
20906
  {
21010
20907
  srcEid: SOLANA_EID,
21011
- sender: ethers.utils.hexlify(oftInstance.toBytes()),
20908
+ sender: hexlify(oftInstance.toBytes()),
21012
20909
  dstEid,
21013
- receiver: ethers.utils.hexlify(peerAddress)
20910
+ receiver: hexlify(peerAddress)
21014
20911
  },
21015
20912
  messageLib
21016
20913
  );
21017
- const ix = createQuoteInstruction(
20914
+ const ix = instructions_exports.createQuoteInstruction(
21018
20915
  {
21019
20916
  oftConfig: oftInstance,
21020
20917
  peer,
@@ -21026,8 +20923,8 @@ async function quoteWithUln(connection, payer, tokenMint, dstEid, amountLd, minA
21026
20923
  params: {
21027
20924
  dstEid,
21028
20925
  to,
21029
- amountLd: new BN6(amountLd.toString()),
21030
- minAmountLd: new BN6(minAmountLd.toString()),
20926
+ amountLd: new BN2(amountLd.toString()),
20927
+ minAmountLd: new BN2(minAmountLd.toString()),
21031
20928
  options,
21032
20929
  payInLzToken,
21033
20930
  composeMsg
@@ -21038,11 +20935,11 @@ async function quoteWithUln(connection, payer, tokenMint, dstEid, amountLd, minA
21038
20935
  units: 1e6
21039
20936
  });
21040
20937
  const buffer = await simulateTransaction(connection, [modifyComputeUnits, ix], ix.programId, payer, "confirmed");
21041
- const fee = types_exports.messagingFeeBeet.read(buffer, 0);
20938
+ const fee = types_exports2.messagingFeeBeet.read(buffer, 0);
21042
20939
  return { nativeFee: BigInt(fee.nativeFee.toString()), lzTokenFee: BigInt(fee.lzTokenFee.toString()) };
21043
20940
  }
21044
- async function createSetMintAuthorityIx(signer, oftInstance, newAuthority) {
21045
- return createSetMintAuthorityInstruction(
20941
+ async function createSetMintAuthorityIx(signer, oftInstance, newAuthority, oftProgramId = PROGRAM_ID) {
20942
+ return instructions_exports.createSetMintAuthorityInstruction(
21046
20943
  {
21047
20944
  signer,
21048
20945
  oftConfig: oftInstance
@@ -21052,40 +20949,22 @@ async function createSetMintAuthorityIx(signer, oftInstance, newAuthority) {
21052
20949
  mintAuthority: newAuthority
21053
20950
  }
21054
20951
  },
21055
- PROGRAM_ID
20952
+ oftProgramId
21056
20953
  );
21057
20954
  }
21058
- async function getEndpointConfig(connection, oftInstance, dstEid) {
21059
- const [sendLib] = PublicKey.findProgramAddressSync(
21060
- [
21061
- Buffer.from(SEND_LIBRARY_CONFIG_SEED2, "utf-8"),
21062
- oftInstance.toBuffer(),
21063
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
21064
- ],
21065
- PROGRAM_ID2
21066
- );
21067
- const [defaultSendLib] = PublicKey.findProgramAddressSync(
21068
- [Buffer.from(SEND_LIBRARY_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
21069
- PROGRAM_ID2
21070
- );
21071
- const [receiveLib] = PublicKey.findProgramAddressSync(
21072
- [
21073
- Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED2, "utf-8"),
21074
- oftInstance.toBuffer(),
21075
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
21076
- ],
21077
- PROGRAM_ID2
21078
- );
21079
- const [defaultReceiveLib] = PublicKey.findProgramAddressSync(
21080
- [Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
21081
- PROGRAM_ID2
21082
- );
21083
- const [ulnSettings] = PublicKey.findProgramAddressSync([Buffer.from(ULN_SEED2, "utf-8")], PROGRAM_ID6);
21084
- let sendLibraryConfig = await accounts_exports.SendLibraryConfig.fromAccountAddress(connection, sendLib);
21085
- let receiveLibraryConfig = await accounts_exports.ReceiveLibraryConfig.fromAccountAddress(connection, receiveLib);
21086
- const defaultSendLibraryConfig = await accounts_exports.SendLibraryConfig.fromAccountAddress(connection, defaultSendLib);
21087
- const defaultReceiveLibraryConfig = await accounts_exports.ReceiveLibraryConfig.fromAccountAddress(connection, defaultReceiveLib);
21088
- const nil64 = new BN6("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "hex");
20955
+ async function getEndpointConfig(connection, oftInstance, dstEid, msgLibProgram = PROGRAM_ID6, endpointProgram = PROGRAM_ID2) {
20956
+ const endpointDeriver = new EndpointPDADeriver(endpointProgram);
20957
+ const ulnDeriver = new UlnPDADeriver(msgLibProgram);
20958
+ const [sendLib] = endpointDeriver.sendLibraryConfig(oftInstance, dstEid);
20959
+ const [defaultSendLib] = endpointDeriver.defaultSendLibraryConfig(dstEid);
20960
+ const [receiveLib] = endpointDeriver.receiveLibraryConfig(oftInstance, dstEid);
20961
+ const [defaultReceiveLib] = endpointDeriver.defaultReceiveLibraryConfig(dstEid);
20962
+ const [msgLib] = ulnDeriver.messageLib();
20963
+ let sendLibraryConfig = await accounts_exports2.SendLibraryConfig.fromAccountAddress(connection, sendLib);
20964
+ let receiveLibraryConfig = await accounts_exports2.ReceiveLibraryConfig.fromAccountAddress(connection, receiveLib);
20965
+ const defaultSendLibraryConfig = await accounts_exports2.SendLibraryConfig.fromAccountAddress(connection, defaultSendLib);
20966
+ const defaultReceiveLibraryConfig = await accounts_exports2.ReceiveLibraryConfig.fromAccountAddress(connection, defaultReceiveLib);
20967
+ const nil64 = new BN2("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "hex");
21089
20968
  const nil8 = 255;
21090
20969
  if (sendLibraryConfig.messageLib.equals(PublicKey.default)) {
21091
20970
  sendLibraryConfig = defaultSendLibraryConfig;
@@ -21093,25 +20972,15 @@ async function getEndpointConfig(connection, oftInstance, dstEid) {
21093
20972
  if (receiveLibraryConfig.messageLib.equals(PublicKey.default)) {
21094
20973
  receiveLibraryConfig = defaultReceiveLibraryConfig;
21095
20974
  }
21096
- if (sendLibraryConfig.messageLib.equals(ulnSettings)) {
21097
- const [ulnDefaultSendConfigPDA] = PublicKey.findProgramAddressSync(
21098
- [Buffer.from(SEND_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
21099
- PROGRAM_ID6
21100
- );
21101
- const [ulnSendConfigPDA] = PublicKey.findProgramAddressSync(
21102
- [
21103
- Buffer.from(SEND_CONFIG_SEED2, "utf-8"),
21104
- new BN6(dstEid).toArrayLike(Buffer, "be", 4),
21105
- oftInstance.toBuffer()
21106
- ],
21107
- PROGRAM_ID6
21108
- );
21109
- const ulnSendConfig = await accounts_exports5.SendConfig.fromAccountAddress(connection, ulnSendConfigPDA);
21110
- const ulnDefaultSendConfig = await accounts_exports5.SendConfig.fromAccountAddress(
20975
+ if (sendLibraryConfig.messageLib.equals(msgLib)) {
20976
+ const [ulnDefaultSendConfigPDA] = ulnDeriver.defaultSendConfig(dstEid);
20977
+ const [ulnSendConfigPDA] = ulnDeriver.sendConfig(dstEid, oftInstance);
20978
+ const ulnSendConfig = await accounts_exports6.SendConfig.fromAccountAddress(connection, ulnSendConfigPDA);
20979
+ const ulnDefaultSendConfig = await accounts_exports6.SendConfig.fromAccountAddress(
21111
20980
  connection,
21112
20981
  ulnDefaultSendConfigPDA
21113
20982
  );
21114
- if (nil64.eq(new BN6(ulnSendConfig.uln.confirmations.toString()))) {
20983
+ if (nil64.eq(new BN2(ulnSendConfig.uln.confirmations.toString()))) {
21115
20984
  ulnSendConfig.uln.confirmations = 0;
21116
20985
  } else if (ulnSendConfig.uln.confirmations == 0) {
21117
20986
  ulnSendConfig.uln.confirmations = ulnDefaultSendConfig.uln.confirmations;
@@ -21132,25 +21001,15 @@ async function getEndpointConfig(connection, oftInstance, dstEid) {
21132
21001
  }
21133
21002
  sendLibraryConfig.ulnSendConfig = ulnSendConfig;
21134
21003
  }
21135
- if (receiveLibraryConfig.messageLib.equals(ulnSettings)) {
21136
- const [ulnDefaultReceiveConfigPDA] = PublicKey.findProgramAddressSync(
21137
- [Buffer.from(SEND_CONFIG_SEED2, "utf-8"), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
21138
- PROGRAM_ID6
21139
- );
21140
- const [ulnReceiveConfigPDA] = PublicKey.findProgramAddressSync(
21141
- [
21142
- Buffer.from(SEND_CONFIG_SEED2, "utf-8"),
21143
- new BN6(dstEid).toArrayLike(Buffer, "be", 4),
21144
- oftInstance.toBuffer()
21145
- ],
21146
- PROGRAM_ID6
21147
- );
21148
- const ulnReceiveConfig = await accounts_exports5.ReceiveConfig.fromAccountAddress(connection, ulnReceiveConfigPDA);
21149
- const ulnDefaultReceiveConfig = await accounts_exports5.ReceiveConfig.fromAccountAddress(
21004
+ if (receiveLibraryConfig.messageLib.equals(msgLib)) {
21005
+ const [ulnDefaultReceiveConfigPDA] = ulnDeriver.defaultReceiveConfig(dstEid);
21006
+ const [ulnReceiveConfigPDA] = ulnDeriver.receiveConfig(dstEid, oftInstance);
21007
+ const ulnReceiveConfig = await accounts_exports6.ReceiveConfig.fromAccountAddress(connection, ulnReceiveConfigPDA);
21008
+ const ulnDefaultReceiveConfig = await accounts_exports6.ReceiveConfig.fromAccountAddress(
21150
21009
  connection,
21151
21010
  ulnDefaultReceiveConfigPDA
21152
21011
  );
21153
- if (nil64.eq(new BN6(ulnReceiveConfig.uln.confirmations.toString()))) {
21012
+ if (nil64.eq(new BN2(ulnReceiveConfig.uln.confirmations.toString()))) {
21154
21013
  ulnReceiveConfig.uln.confirmations = 0;
21155
21014
  } else if (ulnReceiveConfig.uln.confirmations == 0) {
21156
21015
  ulnReceiveConfig.uln.confirmations = ulnDefaultReceiveConfig.uln.confirmations;
@@ -21176,33 +21035,19 @@ async function getEndpointConfig(connection, oftInstance, dstEid) {
21176
21035
  receiveLibraryConfig
21177
21036
  };
21178
21037
  }
21179
- async function getPeerAddress(connection, oftInstance, dstEid) {
21180
- const [peer] = PublicKey.findProgramAddressSync(
21181
- [Buffer.from(PEER_SEED2, "utf-8"), oftInstance.toBytes(), new BN6(dstEid).toArrayLike(Buffer, "be", 4)],
21182
- PROGRAM_ID
21183
- );
21184
- const peerinfo = await connection.getAccountInfo(peer);
21185
- return hexlify(peerinfo.data.subarray(8, 32 + 8));
21038
+ async function getPeerAddress(connection, oftInstance, dstEid, oftProgramId = PROGRAM_ID) {
21039
+ const [peer] = new OftPDADeriver(oftProgramId).peer(oftInstance, dstEid);
21040
+ const peerInfo = await accounts_exports.Peer.fromAccountAddress(connection, peer);
21041
+ return hexlify(peerInfo.address);
21186
21042
  }
21187
- async function getDelegate(connection, oftInstance) {
21188
- const [oAppRegistry] = PublicKey.findProgramAddressSync(
21189
- [Buffer.from(OAPP_SEED2, "utf-8"), oftInstance.toBuffer()],
21190
- PROGRAM_ID2
21191
- );
21192
- const oAppRegistryInfo = await connection.getAccountInfo(oAppRegistry);
21193
- return new PublicKey(oAppRegistryInfo.data.subarray(8, 40));
21194
- }
21195
- async function getEnforcedOptions(connection, oftInstance, dstEid) {
21196
- const [enforcedOptions] = PublicKey.findProgramAddressSync(
21197
- [
21198
- Buffer.from(ENFORCED_OPTIONS_SEED2, "utf-8"),
21199
- oftInstance.toBuffer(),
21200
- new BN6(dstEid).toArrayLike(Buffer, "be", 4)
21201
- ],
21202
- PROGRAM_ID
21203
- );
21204
- const enforcedOptionsInfo = await connection.getAccountInfo(enforcedOptions);
21205
- return enforcedOptionsBeet.deserialize(enforcedOptionsInfo.data);
21043
+ async function getDelegate(connection, oftInstance, endpointProgram = PROGRAM_ID2) {
21044
+ const [oAppRegistry] = new EndpointPDADeriver(endpointProgram).oappRegistry(oftInstance);
21045
+ const oAppRegistryInfo = await accounts_exports2.OAppRegistry.fromAccountAddress(connection, oAppRegistry);
21046
+ return oAppRegistryInfo.delegate;
21047
+ }
21048
+ async function getEnforcedOptions(connection, oftInstance, dstEid, oftProgramId = PROGRAM_ID) {
21049
+ const [enforcedOptions] = new OftPDADeriver(oftProgramId).enforcedOptions(oftInstance, dstEid);
21050
+ return accounts_exports.EnforcedOptions.fromAccountAddress(connection, enforcedOptions);
21206
21051
  }
21207
21052
  var idlTypes = [
21208
21053
  "MessageLibQuoteParams",
@@ -22832,13 +22677,13 @@ var types = [
22832
22677
  var IdlTypes = {
22833
22678
  endpoint: types
22834
22679
  };
22835
- var SetConfigType2 = /* @__PURE__ */ ((SetConfigType3) => {
22836
- SetConfigType3[SetConfigType3["EXECUTOR"] = 1] = "EXECUTOR";
22837
- SetConfigType3[SetConfigType3["SEND_ULN"] = 2] = "SEND_ULN";
22838
- SetConfigType3[SetConfigType3["RECEIVE_ULN"] = 3] = "RECEIVE_ULN";
22839
- return SetConfigType3;
22680
+ var SetConfigType2 = /* @__PURE__ */ ((SetConfigType4) => {
22681
+ SetConfigType4[SetConfigType4["EXECUTOR"] = 1] = "EXECUTOR";
22682
+ SetConfigType4[SetConfigType4["SEND_ULN"] = 2] = "SEND_ULN";
22683
+ SetConfigType4[SetConfigType4["RECEIVE_ULN"] = 3] = "RECEIVE_ULN";
22684
+ return SetConfigType4;
22840
22685
  })(SetConfigType2 || {});
22841
22686
 
22842
- export { AddressType, BaseOApp, blocked_messagelib_exports as BlockedMessageLibProgram, COMPOSED_MESSAGE_HASH_SEED, CONFIRMATIONS_SEED, COUNT_SEED, DVNDeriver, dvn_exports2 as DVNProgram, DVN_CONFIG_SEED, dvn_exports as DvnProgram, ENDPOINT_SEED, ENFORCED_OPTIONS_SEED, EVENT_SEED, EXECUTOR_CONFIG_SEED, EndpointPDADeriver, endpoint_exports as EndpointProgram, EventPDADeriver, ExecutorOptionType, ExecutorPDADeriver, executor_exports as ExecutorProgram, FAUCET_URL, IdlTypes, LZ_COMPOSE_TYPES_SEED, LZ_RECEIVE_TYPES_SEED, LzComposeParamsBeet, LzReceiveAccountBeet, LzReceiveParamsBeet, MESSAGE_LIB_SEED, MINT_SEED, MSG_TYPE_OFFSET, MaxExecutorOptionTypeLength, MessageLibPDADeriver, MessageType, NONCE_SEED, OAPP_SEED, OAppBasePDADeriver, OFT_SEED, OPTIONS_SEED, oft_exports as Oft, OftPDADeriver, OftTools_exports as OftTools, OmniCounterPDADeriver, PAYLOAD_HASH_SEED, PEER_SEED, PENDING_NONCE_SEED, PRICE_FEED_SEED, PriceFeedPDADeriver, pricefeed_exports as PriceFeedProgram, RECEIVE_CONFIG_SEED, RECEIVE_LIBRARY_CONFIG_SEED, REMOTE_SEED, SEND_CONFIG_SEED, SEND_LIBRARY_CONFIG_SEED, SetConfigType2 as SetConfigType, simple_message_lib_exports as SimpleMessageLibProgram, ULN_CONFIG_SEED, ULN_SEED, UlnPDADeriver, uln_exports as UlnProgram, WORKER_SEED, buildMessageV0, buildVersionedTransaction, closeLookupTable, createNonceAccountTX, deactivateLookupTable, deriveLzComposeTypesAccountsPDA, deriveLzReceiveTypesAccountsPDA, extractComposeDeliveredEventByTxHash, extractComposeSentEventByTxHash, extractEventFromTransactionSignature, extractReceivedPacketEventByTxHash, extractSentPacketEventByTxHash, extractVerifiedPacketEventByTxHash, extractWorkerFeePaidEventByTxHash, generateAddressLookupTable, getBlockedMessageLibProgramId, getDVNProgramId, getEndpointProgramId, getExecutorProgramId, getLzComposeAccountMeta, getLzReceiveAccounts, getPricefeedProgramId, getProgramKeypair, getSimpleMessageLibProgramId, getULNProgramId, idlTypes, instructionDiscriminator, isAccountInitialized, lzCompose, lzReceive, messageLibs, oappIDPDA, simulateTransaction, txWithAddressLookupTable, txWithNonce };
22687
+ export { AddressType, BaseOApp, blocked_messagelib_exports as BlockedMessageLibProgram, COMPOSED_MESSAGE_HASH_SEED, CONFIRMATIONS_SEED, COUNT_SEED, DVNDeriver, dvn_exports2 as DVNProgram, DVN_CONFIG_SEED, dvn_exports as DvnProgram, ENDPOINT_SEED, ENFORCED_OPTIONS_SEED, EVENT_SEED, EXECUTOR_CONFIG_SEED, EndpointPDADeriver, endpoint_exports as EndpointProgram, EventPDADeriver, ExecutorOptionType, ExecutorPDADeriver, executor_exports as ExecutorProgram, FAUCET_URL, IdlTypes, LZ_COMPOSE_TYPES_SEED, LZ_RECEIVE_TYPES_SEED, LzComposeParamsBeet, LzReceiveAccountBeet, LzReceiveParamsBeet, MESSAGE_LIB_SEED, MINT_SEED, MSG_TYPE_OFFSET, MaxExecutorOptionTypeLength, MessageLibPDADeriver, MessageType, NONCE_SEED, OAPP_SEED, OAppBasePDADeriver, OFT_SEED, OPTIONS_SEED, OftPDADeriver, oft_exports as OftProgram, oft_tools_exports as OftTools, OmniCounterPDADeriver, PAYLOAD_HASH_SEED, PEER_SEED, PENDING_NONCE_SEED, PRICE_FEED_SEED, PriceFeedPDADeriver, pricefeed_exports as PriceFeedProgram, RECEIVE_CONFIG_SEED, RECEIVE_LIBRARY_CONFIG_SEED, REMOTE_SEED, SEND_CONFIG_SEED, SEND_LIBRARY_CONFIG_SEED, SetConfigType2 as SetConfigType, simple_message_lib_exports as SimpleMessageLibProgram, ULN_CONFIG_SEED, ULN_SEED, UlnPDADeriver, uln_exports as UlnProgram, WORKER_SEED, buildMessageV0, buildVersionedTransaction, closeLookupTable, createNonceAccountTX, deactivateLookupTable, deriveLzComposeTypesAccountsPDA, deriveLzReceiveTypesAccountsPDA, extractComposeDeliveredEventByTxHash, extractComposeSentEventByTxHash, extractEventFromTransactionSignature, extractReceivedPacketEventByTxHash, extractSentPacketEventByTxHash, extractVerifiedPacketEventByTxHash, extractWorkerFeePaidEventByTxHash, generateAddressLookupTable, getBlockedMessageLibProgramId, getDVNProgramId, getEndpointProgramId, getExecutorProgramId, getLzComposeAccountMeta, getLzReceiveAccounts, getPricefeedProgramId, getProgramKeypair, getSimpleMessageLibProgramId, getULNProgramId, idlTypes, instructionDiscriminator, isAccountInitialized, lzCompose, lzReceive, messageLibs, oappIDPDA, simulateTransaction, txWithAddressLookupTable, txWithNonce };
22843
22688
  //# sourceMappingURL=out.js.map
22844
22689
  //# sourceMappingURL=index.mjs.map