@layerzerolabs/lz-solana-sdk-v2 2.3.10 → 2.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.cjs +133 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +51 -14
- package/dist/index.d.ts +51 -14
- package/dist/index.mjs +112 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @layerzerolabs/lz-solana-sdk-v2
|
|
2
2
|
|
|
3
|
+
## 2.3.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2761d43: minor update & fix some bugs
|
|
8
|
+
- Updated dependencies [2761d43]
|
|
9
|
+
- @layerzerolabs/lz-corekit-solana@2.3.12
|
|
10
|
+
- @layerzerolabs/lz-definitions@2.3.12
|
|
11
|
+
- @layerzerolabs/lz-utilities@2.3.12
|
|
12
|
+
- @layerzerolabs/lz-v2-utilities@2.3.12
|
|
13
|
+
|
|
14
|
+
## 2.3.11
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- a7ee3c1: mainnet endpoints, cyber, iota
|
|
19
|
+
- Updated dependencies [a7ee3c1]
|
|
20
|
+
- @layerzerolabs/lz-corekit-solana@2.3.11
|
|
21
|
+
- @layerzerolabs/lz-definitions@2.3.11
|
|
22
|
+
- @layerzerolabs/lz-utilities@2.3.11
|
|
23
|
+
- @layerzerolabs/lz-v2-utilities@2.3.11
|
|
24
|
+
|
|
3
25
|
## 2.3.10
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var web370 = require('@solana/web3.js');
|
|
4
|
-
var
|
|
4
|
+
var BN3 = require('bn.js');
|
|
5
5
|
var anchor = require('@coral-xyz/anchor');
|
|
6
6
|
var beet158 = require('@metaplex-foundation/beet');
|
|
7
7
|
var beetSolana66 = require('@metaplex-foundation/beet-solana');
|
|
@@ -39,6 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
var web370__namespace = /*#__PURE__*/_interopNamespace(web370);
|
|
42
|
+
var BN3__default = /*#__PURE__*/_interopDefault(BN3);
|
|
42
43
|
var beet158__namespace = /*#__PURE__*/_interopNamespace(beet158);
|
|
43
44
|
var beetSolana66__namespace = /*#__PURE__*/_interopNamespace(beetSolana66);
|
|
44
45
|
var invariant__default = /*#__PURE__*/_interopDefault(invariant);
|
|
@@ -195,7 +196,7 @@ var EndpointPDADeriver = class {
|
|
|
195
196
|
[
|
|
196
197
|
Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
|
|
197
198
|
// U32 to Uint8Array([0,0,0,0])
|
|
198
|
-
new
|
|
199
|
+
new BN3.BN(dstEndpointId).toArrayLike(Buffer, "be", 4)
|
|
199
200
|
],
|
|
200
201
|
this.program
|
|
201
202
|
);
|
|
@@ -206,7 +207,7 @@ var EndpointPDADeriver = class {
|
|
|
206
207
|
Buffer.from(SEND_LIBRARY_CONFIG_SEED, "utf8"),
|
|
207
208
|
sender.toBytes(),
|
|
208
209
|
// U32 to Uint8Array([0,0,0,0])
|
|
209
|
-
new
|
|
210
|
+
new BN3.BN(dstEndpointId).toArrayLike(Buffer, "be", 4)
|
|
210
211
|
],
|
|
211
212
|
this.program
|
|
212
213
|
);
|
|
@@ -225,7 +226,7 @@ var EndpointPDADeriver = class {
|
|
|
225
226
|
[
|
|
226
227
|
Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
|
|
227
228
|
// U32 to Uint8Array([0,0,0,0])
|
|
228
|
-
new
|
|
229
|
+
new BN3.BN(srcEndpointId).toArrayLike(Buffer, "be", 4)
|
|
229
230
|
],
|
|
230
231
|
this.program
|
|
231
232
|
);
|
|
@@ -236,7 +237,7 @@ var EndpointPDADeriver = class {
|
|
|
236
237
|
Buffer.from(RECEIVE_LIBRARY_CONFIG_SEED, "utf8"),
|
|
237
238
|
receiver.toBytes(),
|
|
238
239
|
// U32 to Uint8Array([0,0,0,0])
|
|
239
|
-
new
|
|
240
|
+
new BN3.BN(srcEndpointId).toArrayLike(Buffer, "be", 4)
|
|
240
241
|
],
|
|
241
242
|
this.program
|
|
242
243
|
);
|
|
@@ -264,7 +265,7 @@ var EndpointPDADeriver = class {
|
|
|
264
265
|
Buffer.from(NONCE_SEED, "utf8"),
|
|
265
266
|
localOapp.toBytes(),
|
|
266
267
|
// U32 to Uint8Array([0,0,0,0])
|
|
267
|
-
new
|
|
268
|
+
new BN3.BN(remoteChainId).toArrayLike(Buffer, "be", 4),
|
|
268
269
|
remoteOapp
|
|
269
270
|
],
|
|
270
271
|
this.program
|
|
@@ -275,7 +276,7 @@ var EndpointPDADeriver = class {
|
|
|
275
276
|
[
|
|
276
277
|
Buffer.from(PENDING_NONCE_SEED, "utf8"),
|
|
277
278
|
localOapp.toBytes(),
|
|
278
|
-
new
|
|
279
|
+
new BN3.BN(remoteChainId).toArrayLike(Buffer, "be", 4),
|
|
279
280
|
remoteOapp
|
|
280
281
|
],
|
|
281
282
|
this.program
|
|
@@ -300,9 +301,9 @@ var EndpointPDADeriver = class {
|
|
|
300
301
|
[
|
|
301
302
|
Buffer.from(PAYLOAD_HASH_SEED, "utf8"),
|
|
302
303
|
receiver.toBytes(),
|
|
303
|
-
new
|
|
304
|
+
new BN3.BN(srcEid).toArrayLike(Buffer, "be", 4),
|
|
304
305
|
sender,
|
|
305
|
-
new
|
|
306
|
+
new BN3.BN(nonce).toArrayLike(Buffer, "be", 8)
|
|
306
307
|
],
|
|
307
308
|
this.program
|
|
308
309
|
);
|
|
@@ -314,7 +315,7 @@ var EndpointPDADeriver = class {
|
|
|
314
315
|
from.toBytes(),
|
|
315
316
|
to.toBytes(),
|
|
316
317
|
guid,
|
|
317
|
-
new
|
|
318
|
+
new BN3.BN(index).toArrayLike(Buffer, "be", 2),
|
|
318
319
|
messageHash
|
|
319
320
|
],
|
|
320
321
|
this.program
|
|
@@ -330,13 +331,13 @@ var MessageLibPDADeriver = class {
|
|
|
330
331
|
}
|
|
331
332
|
sendConfig(eid, oapp) {
|
|
332
333
|
return web370.PublicKey.findProgramAddressSync(
|
|
333
|
-
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new
|
|
334
|
+
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN3.BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
|
|
334
335
|
this.program
|
|
335
336
|
);
|
|
336
337
|
}
|
|
337
338
|
receiveConfig(eid, oapp) {
|
|
338
339
|
return web370.PublicKey.findProgramAddressSync(
|
|
339
|
-
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new
|
|
340
|
+
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN3.BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
|
|
340
341
|
this.program
|
|
341
342
|
);
|
|
342
343
|
}
|
|
@@ -347,25 +348,25 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
|
|
|
347
348
|
}
|
|
348
349
|
config(eid) {
|
|
349
350
|
return web370.PublicKey.findProgramAddressSync(
|
|
350
|
-
[Buffer.from(ULN_CONFIG_SEED, "utf8"), new
|
|
351
|
+
[Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN3.BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
351
352
|
this.program
|
|
352
353
|
);
|
|
353
354
|
}
|
|
354
355
|
defaultSendConfig(eid) {
|
|
355
356
|
return web370.PublicKey.findProgramAddressSync(
|
|
356
|
-
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new
|
|
357
|
+
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN3.BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
357
358
|
this.program
|
|
358
359
|
);
|
|
359
360
|
}
|
|
360
361
|
defaultReceiveConfig(eid) {
|
|
361
362
|
return web370.PublicKey.findProgramAddressSync(
|
|
362
|
-
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new
|
|
363
|
+
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN3.BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
363
364
|
this.program
|
|
364
365
|
);
|
|
365
366
|
}
|
|
366
367
|
options(eit) {
|
|
367
368
|
return web370.PublicKey.findProgramAddressSync(
|
|
368
|
-
[Buffer.from(OPTIONS_SEED, "utf8"), new
|
|
369
|
+
[Buffer.from(OPTIONS_SEED, "utf8"), new BN3.BN(eit).toArrayLike(Buffer, "be", 4)],
|
|
369
370
|
this.program
|
|
370
371
|
);
|
|
371
372
|
}
|
|
@@ -385,7 +386,7 @@ var OAppBasePDADeriver = class {
|
|
|
385
386
|
}
|
|
386
387
|
remote(dstChainId) {
|
|
387
388
|
return web370.PublicKey.findProgramAddressSync(
|
|
388
|
-
[Buffer.from(REMOTE_SEED), new
|
|
389
|
+
[Buffer.from(REMOTE_SEED), new BN3.BN(dstChainId).toArrayLike(Buffer, "be", 4)],
|
|
389
390
|
this.program
|
|
390
391
|
);
|
|
391
392
|
}
|
|
@@ -406,7 +407,7 @@ var OmniCounterPDADeriver = class extends OAppBasePDADeriver {
|
|
|
406
407
|
}
|
|
407
408
|
remote(dstChainId) {
|
|
408
409
|
return web370.PublicKey.findProgramAddressSync(
|
|
409
|
-
[Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new
|
|
410
|
+
[Buffer.from(REMOTE_SEED), this.count()[0].toBytes(), new BN3.BN(dstChainId).toArrayLike(Buffer, "be", 4)],
|
|
410
411
|
this.program
|
|
411
412
|
);
|
|
412
413
|
}
|
|
@@ -470,13 +471,13 @@ var OftPDADeriver = class {
|
|
|
470
471
|
}
|
|
471
472
|
enforcedOptions(oftConfig, eid) {
|
|
472
473
|
return web370.PublicKey.findProgramAddressSync(
|
|
473
|
-
[Buffer.from(ENFORCED_OPTIONS_SEED, "utf8"), oftConfig.toBytes(), new
|
|
474
|
+
[Buffer.from(ENFORCED_OPTIONS_SEED, "utf8"), oftConfig.toBytes(), new BN3.BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
474
475
|
this.program
|
|
475
476
|
);
|
|
476
477
|
}
|
|
477
478
|
peer(oftConfig, eid) {
|
|
478
479
|
return web370.PublicKey.findProgramAddressSync(
|
|
479
|
-
[Buffer.from(PEER_SEED, "utf8"), oftConfig.toBytes(), new
|
|
480
|
+
[Buffer.from(PEER_SEED, "utf8"), oftConfig.toBytes(), new BN3.BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
480
481
|
this.program
|
|
481
482
|
);
|
|
482
483
|
}
|
|
@@ -6091,7 +6092,7 @@ var Endpoint = class {
|
|
|
6091
6092
|
const [sendLibraryConfig] = this.endpointDeriver.sendLibraryConfig(oappIDPDA2, dstEid);
|
|
6092
6093
|
const [sendLibraryInfo] = this.endpointDeriver.messageLibraryInfo(newSendLib);
|
|
6093
6094
|
const [oappRegistry] = this.endpointDeriver.oappRegistry(oappIDPDA2);
|
|
6094
|
-
|
|
6095
|
+
const ix = createSetSendLibraryInstruction(
|
|
6095
6096
|
{
|
|
6096
6097
|
signer: oappAdmin,
|
|
6097
6098
|
sendLibraryConfig,
|
|
@@ -6109,6 +6110,7 @@ var Endpoint = class {
|
|
|
6109
6110
|
},
|
|
6110
6111
|
this.program
|
|
6111
6112
|
);
|
|
6113
|
+
return Promise.resolve(ix);
|
|
6112
6114
|
}
|
|
6113
6115
|
async initReceiveLibrary(connection, delegate, receiver, srcEid, commitmentOrConfig) {
|
|
6114
6116
|
const [oappRegistry] = this.endpointDeriver.oappRegistry(receiver);
|
|
@@ -6137,7 +6139,7 @@ var Endpoint = class {
|
|
|
6137
6139
|
const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(oappIDPDA2, srcEid);
|
|
6138
6140
|
const [receiveLibraryInfo] = this.endpointDeriver.messageLibraryInfo(newReceiveLib);
|
|
6139
6141
|
const [oappRegistry] = this.endpointDeriver.oappRegistry(oappIDPDA2);
|
|
6140
|
-
|
|
6142
|
+
const ix = createSetReceiveLibraryInstruction(
|
|
6141
6143
|
{
|
|
6142
6144
|
signer: oappAdmin,
|
|
6143
6145
|
receiveLibraryConfig,
|
|
@@ -6156,18 +6158,21 @@ var Endpoint = class {
|
|
|
6156
6158
|
},
|
|
6157
6159
|
this.program
|
|
6158
6160
|
);
|
|
6161
|
+
return Promise.resolve(ix);
|
|
6159
6162
|
}
|
|
6160
6163
|
async setOappConfig(connection, oappDelegate, oappID, msgLibProgram, eid, config, commitment = "confirmed") {
|
|
6161
6164
|
const [msgLib] = new MessageLibPDADeriver(msgLibProgram).messageLib();
|
|
6162
6165
|
const [msgLibInfo] = this.endpointDeriver.messageLibraryInfo(msgLib);
|
|
6163
6166
|
const msgLibVersion = await this.getMessageLibVersion(connection, oappDelegate, msgLibProgram, commitment);
|
|
6164
6167
|
let msgLibClient;
|
|
6165
|
-
if (msgLibVersion?.major.toString() === "0" && msgLibVersion
|
|
6168
|
+
if (msgLibVersion?.major.toString() === "0" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
|
|
6166
6169
|
msgLibClient = new simple_message_lib_exports.SimpleMessageLib(msgLibProgram);
|
|
6167
|
-
} else if (msgLibVersion?.major.toString() === "3" && msgLibVersion
|
|
6170
|
+
} else if (msgLibVersion?.major.toString() === "3" && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
|
|
6168
6171
|
msgLibClient = new uln_exports.Uln(msgLibProgram);
|
|
6169
6172
|
} else {
|
|
6170
|
-
throw new Error(
|
|
6173
|
+
throw new Error(
|
|
6174
|
+
`unsupported message lib version ${msgLibVersion?.major.toString()}.${msgLibVersion?.minor.toString()}`
|
|
6175
|
+
);
|
|
6171
6176
|
}
|
|
6172
6177
|
const [oappRegistry] = this.endpointDeriver.oappRegistry(oappID);
|
|
6173
6178
|
const ix = createSetConfigInstruction(
|
|
@@ -6231,17 +6236,15 @@ var Endpoint = class {
|
|
|
6231
6236
|
},
|
|
6232
6237
|
this.program
|
|
6233
6238
|
);
|
|
6234
|
-
return
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
);
|
|
6244
|
-
});
|
|
6239
|
+
return Promise.resolve(
|
|
6240
|
+
[
|
|
6241
|
+
{
|
|
6242
|
+
pubkey: this.program,
|
|
6243
|
+
isSigner: false,
|
|
6244
|
+
isWritable: false
|
|
6245
|
+
}
|
|
6246
|
+
].concat(accounts)
|
|
6247
|
+
);
|
|
6245
6248
|
}
|
|
6246
6249
|
/***
|
|
6247
6250
|
* Get the account meta of the send instruction for CPI(Cross-Program Invocation )
|
|
@@ -6296,7 +6299,7 @@ var Endpoint = class {
|
|
|
6296
6299
|
[Buffer.from(OAPP_SEED, "utf-8"), receiver.toBuffer()],
|
|
6297
6300
|
this.program
|
|
6298
6301
|
);
|
|
6299
|
-
|
|
6302
|
+
const ix = createSkipInstruction(
|
|
6300
6303
|
{
|
|
6301
6304
|
signer: payer,
|
|
6302
6305
|
oappRegistry: oAppRegistry,
|
|
@@ -6312,11 +6315,12 @@ var Endpoint = class {
|
|
|
6312
6315
|
receiver,
|
|
6313
6316
|
srcEid,
|
|
6314
6317
|
sender: Array.from(sender.toBytes()),
|
|
6315
|
-
nonce
|
|
6318
|
+
nonce: new BN3__default.default(nonce)
|
|
6316
6319
|
}
|
|
6317
6320
|
},
|
|
6318
6321
|
this.program
|
|
6319
6322
|
);
|
|
6323
|
+
return Promise.resolve(ix);
|
|
6320
6324
|
}
|
|
6321
6325
|
async initVerify(connection, payer, sender, receiver, srcEid, nonce, commitmentOrConfig) {
|
|
6322
6326
|
const [nonceAccount] = this.endpointDeriver.nonce(receiver, srcEid, lzV2Utilities.addressToBytes32(sender.toBase58()));
|
|
@@ -6336,7 +6340,7 @@ var Endpoint = class {
|
|
|
6336
6340
|
srcEid,
|
|
6337
6341
|
sender: Array.from(sender.toBytes()),
|
|
6338
6342
|
receiver,
|
|
6339
|
-
nonce
|
|
6343
|
+
nonce: new BN3__default.default(nonce)
|
|
6340
6344
|
}
|
|
6341
6345
|
},
|
|
6342
6346
|
this.program
|
|
@@ -6351,7 +6355,7 @@ var Endpoint = class {
|
|
|
6351
6355
|
const [receiveLibraryConfig] = this.endpointDeriver.receiveLibraryConfig(receiver, srcEid);
|
|
6352
6356
|
const [nonce] = this.endpointDeriver.nonce(receiver, srcEid, sender);
|
|
6353
6357
|
const [pendingNonce] = this.endpointDeriver.pendingNonce(receiver, srcEid, sender);
|
|
6354
|
-
const
|
|
6358
|
+
const accounts = createVerifyInstructionAccounts(
|
|
6355
6359
|
{
|
|
6356
6360
|
receiveLibrary,
|
|
6357
6361
|
receiveLibraryConfig,
|
|
@@ -6362,14 +6366,47 @@ var Endpoint = class {
|
|
|
6362
6366
|
program: this.program,
|
|
6363
6367
|
eventAuthority: this.eventAuthorityPDA
|
|
6364
6368
|
},
|
|
6365
|
-
|
|
6369
|
+
this.program
|
|
6370
|
+
);
|
|
6371
|
+
accounts.forEach((key) => {
|
|
6372
|
+
key.isSigner = false;
|
|
6373
|
+
});
|
|
6374
|
+
const program = {
|
|
6375
|
+
pubkey: this.program,
|
|
6376
|
+
isSigner: false,
|
|
6377
|
+
isWritable: false
|
|
6378
|
+
};
|
|
6379
|
+
return [program, ...accounts];
|
|
6380
|
+
}
|
|
6381
|
+
/***
|
|
6382
|
+
* setConfig is only supported by ULN
|
|
6383
|
+
*/
|
|
6384
|
+
getSetConfigIXAccountMetaForCPI(connection, msgLibProgram, oappID, eid, commitmentOrConfig = "confirmed") {
|
|
6385
|
+
const msgLib = msgLibProgram;
|
|
6386
|
+
const [msgLibInfo] = this.endpointDeriver.messageLibraryInfo(msgLib);
|
|
6387
|
+
const ix = createSetConfigInstruction(
|
|
6388
|
+
{
|
|
6389
|
+
signer: oappID,
|
|
6390
|
+
messageLibInfo: msgLibInfo,
|
|
6391
|
+
messageLib: msgLib,
|
|
6392
|
+
messageLibProgram: msgLibProgram,
|
|
6393
|
+
// anchorRemainingAccounts: await uln.getSetConfigIXAccountMetaForCPI( // FIXME: FIXME: uncomment this line later
|
|
6394
|
+
// connection,
|
|
6395
|
+
// this.program,
|
|
6396
|
+
// oappID,
|
|
6397
|
+
// eid,
|
|
6398
|
+
// commitmentOrConfig
|
|
6399
|
+
// ),
|
|
6400
|
+
oappRegistry: msgLib
|
|
6401
|
+
// FIXME: oappRegistry is wrong
|
|
6402
|
+
},
|
|
6403
|
+
// Fake params. Just to get the ix.keys
|
|
6366
6404
|
{
|
|
6367
6405
|
params: {
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
payloadHash: Array.from(lzV2Utilities.addressToBytes32(packet.sender()))
|
|
6406
|
+
eid,
|
|
6407
|
+
configType: 1,
|
|
6408
|
+
config: Uint8Array.from([]),
|
|
6409
|
+
oapp: oappID
|
|
6373
6410
|
}
|
|
6374
6411
|
}
|
|
6375
6412
|
);
|
|
@@ -6379,8 +6416,8 @@ var Endpoint = class {
|
|
|
6379
6416
|
return [
|
|
6380
6417
|
{
|
|
6381
6418
|
pubkey: this.program,
|
|
6382
|
-
|
|
6383
|
-
|
|
6419
|
+
isWritable: false,
|
|
6420
|
+
isSigner: false
|
|
6384
6421
|
}
|
|
6385
6422
|
].concat(ix.keys);
|
|
6386
6423
|
}
|
|
@@ -6723,7 +6760,7 @@ var Endpoint = class {
|
|
|
6723
6760
|
const slot = await connection.getSlot();
|
|
6724
6761
|
const timestamp = await connection.getBlockTime(slot);
|
|
6725
6762
|
invariant__default.default(timestamp, "timestamp should not be null");
|
|
6726
|
-
const isValid = timeout2.expiry > timestamp;
|
|
6763
|
+
const isValid = parseInt(timeout2.expiry.toString()) > timestamp;
|
|
6727
6764
|
return {
|
|
6728
6765
|
programId: defaultInfo.messageLib,
|
|
6729
6766
|
msgLib: defaultInfo.messageLib,
|
|
@@ -6746,7 +6783,7 @@ var Endpoint = class {
|
|
|
6746
6783
|
const slot = await connection.getSlot();
|
|
6747
6784
|
const timestamp = await connection.getBlockTime(slot);
|
|
6748
6785
|
invariant__default.default(timestamp, "timestamp should not be null");
|
|
6749
|
-
const isValid = timeout.expiry > timestamp;
|
|
6786
|
+
const isValid = parseInt(timeout.expiry.toString()) > timestamp;
|
|
6750
6787
|
return {
|
|
6751
6788
|
programId: messageLibInfo.owner,
|
|
6752
6789
|
msgLib: info.messageLib,
|
|
@@ -6788,6 +6825,14 @@ var Endpoint = class {
|
|
|
6788
6825
|
return null;
|
|
6789
6826
|
}
|
|
6790
6827
|
}
|
|
6828
|
+
async getPendingInboundNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
|
|
6829
|
+
const [nonce] = this.endpointDeriver.pendingNonce(oappIDPDA2, remoteEid, remoteOappAddr);
|
|
6830
|
+
try {
|
|
6831
|
+
return await PendingInboundNonce.fromAccountAddress(connection, nonce, commitmentOrConfig);
|
|
6832
|
+
} catch (e) {
|
|
6833
|
+
return null;
|
|
6834
|
+
}
|
|
6835
|
+
}
|
|
6791
6836
|
async getMessageLibVersion(connection, payer, messageLibProgram, commitment = "confirmed") {
|
|
6792
6837
|
const ix = simple_message_lib_exports.instructions.createVersionInstruction(messageLibProgram);
|
|
6793
6838
|
const simulateResp = await simulateTransaction(connection, [ix], messageLibProgram, payer, commitment);
|
|
@@ -10884,7 +10929,7 @@ var DVN = class {
|
|
|
10884
10929
|
_getExpiration() {
|
|
10885
10930
|
return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
|
|
10886
10931
|
}
|
|
10887
|
-
|
|
10932
|
+
setMsgLibs(connection, payer, msgLibs, sign) {
|
|
10888
10933
|
const expiration = this._getExpiration();
|
|
10889
10934
|
return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
|
|
10890
10935
|
}
|
|
@@ -15802,7 +15847,7 @@ var Uln = class {
|
|
|
15802
15847
|
/**
|
|
15803
15848
|
* before calling this function, you should call initUln to initialize the uln
|
|
15804
15849
|
*/
|
|
15805
|
-
async setTreasury(admin, treasury
|
|
15850
|
+
async setTreasury(admin, treasury) {
|
|
15806
15851
|
const [setting] = this.deriver.setting();
|
|
15807
15852
|
const ix = createSetTreasuryInstruction(
|
|
15808
15853
|
{
|
|
@@ -16014,20 +16059,53 @@ var Uln = class {
|
|
|
16014
16059
|
params: {
|
|
16015
16060
|
packetHeader: Array.from(Uint8Array.from(Buffer.from(packet.header().slice(2), "hex"))),
|
|
16016
16061
|
payloadHash: Array.from(payloadHashBytes),
|
|
16017
|
-
confirmations: typeof confirmations === "string" ? new
|
|
16062
|
+
confirmations: typeof confirmations === "string" ? new BN3.BN(confirmations) : confirmations
|
|
16018
16063
|
}
|
|
16019
16064
|
},
|
|
16020
16065
|
this.program
|
|
16021
16066
|
);
|
|
16022
16067
|
}
|
|
16023
|
-
async
|
|
16068
|
+
async isDvnVerified(connection, endpointProgram, dvn, packetBytes, commitmentOrConfig = "confirmed") {
|
|
16024
16069
|
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|
|
16025
16070
|
const headerHash = packet.headerHash();
|
|
16026
16071
|
const headerHashBytes = Uint8Array.from(Buffer.from(headerHash.slice(2), "hex"));
|
|
16027
16072
|
const payloadHash = packet.payloadHash();
|
|
16028
16073
|
const payloadHashBytes = Uint8Array.from(Buffer.from(payloadHash.slice(2), "hex"));
|
|
16029
16074
|
const [confirmationsPDA] = this.deriver.confirmations(headerHashBytes, payloadHashBytes, dvn);
|
|
16030
|
-
|
|
16075
|
+
const endpoint = new endpoint_exports.Endpoint(endpointProgram);
|
|
16076
|
+
const receiver = new web370.PublicKey(utils.arrayify(packet.receiver()));
|
|
16077
|
+
const sender = utils.arrayify(packet.sender());
|
|
16078
|
+
const nonce = await endpoint.getNonce(connection, receiver, packet.srcEid(), sender, commitmentOrConfig);
|
|
16079
|
+
const pendingNonce = await endpoint.getPendingInboundNonce(
|
|
16080
|
+
connection,
|
|
16081
|
+
receiver,
|
|
16082
|
+
packet.srcEid(),
|
|
16083
|
+
sender,
|
|
16084
|
+
commitmentOrConfig
|
|
16085
|
+
);
|
|
16086
|
+
if (!nonce || !pendingNonce) {
|
|
16087
|
+
return false;
|
|
16088
|
+
}
|
|
16089
|
+
if (parseInt(nonce.inboundNonce.toString()) >= parseInt(packet.nonce())) {
|
|
16090
|
+
return true;
|
|
16091
|
+
}
|
|
16092
|
+
if (pendingNonce.nonces.find((n) => n.toString() === packet.nonce()) !== void 0) {
|
|
16093
|
+
return true;
|
|
16094
|
+
}
|
|
16095
|
+
try {
|
|
16096
|
+
const confirmation = await Confirmations.fromAccountAddress(
|
|
16097
|
+
connection,
|
|
16098
|
+
confirmationsPDA,
|
|
16099
|
+
commitmentOrConfig
|
|
16100
|
+
);
|
|
16101
|
+
if (confirmation.value === null) {
|
|
16102
|
+
return false;
|
|
16103
|
+
} else {
|
|
16104
|
+
return true;
|
|
16105
|
+
}
|
|
16106
|
+
} catch (e) {
|
|
16107
|
+
return false;
|
|
16108
|
+
}
|
|
16031
16109
|
}
|
|
16032
16110
|
async commitVerification(connection, endpointProgram, packetBytes) {
|
|
16033
16111
|
const packet = lzV2Utilities.PacketV1Codec.fromBytes(packetBytes);
|