@layerzerolabs/lz-solana-sdk-v2 3.0.15 → 3.0.16
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 +13 -0
- package/README.md +132 -0
- package/deployments/solana-mainnet/dvn-paxos.json +9 -0
- package/deployments/solana-testnet/dvn-paxos.json +9 -0
- package/dist/index.cjs +1315 -246
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1940 -62
- package/dist/index.d.ts +1940 -62
- package/dist/index.mjs +1283 -214
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -15
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import * as web314 from '@solana/web3.js';
|
|
2
2
|
import { PublicKey, TransactionInstruction, AddressLookupTableProgram, VersionedTransaction, TransactionMessage, Keypair, NONCE_ACCOUNT_LENGTH, Transaction, SystemProgram, NonceAccount } from '@solana/web3.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import base58 from 'bs58';
|
|
9
|
-
import '@ethersproject/abi';
|
|
10
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
11
|
-
import '@ethersproject/solidity';
|
|
4
|
+
import invariant3 from 'tiny-invariant';
|
|
5
|
+
import { keccak_256, sha2_256 } from '@layerzerolabs/lz-foundation';
|
|
6
|
+
import { arrayify } from '@layerzerolabs/lz-utilities';
|
|
7
|
+
import { addressToBytes32, PacketV1Codec } from '@layerzerolabs/lz-v2-utilities';
|
|
12
8
|
import * as beet159 from '@metaplex-foundation/beet';
|
|
13
9
|
import { uniformFixedSizeArray, u8, FixableBeetArgsStruct, u32, u64, bytes, u16, BeetArgsStruct, bool, array } from '@metaplex-foundation/beet';
|
|
14
10
|
import * as beetSolana85 from '@metaplex-foundation/beet-solana';
|
|
15
11
|
import * as splToken from '@solana/spl-token';
|
|
16
12
|
import { Environment, EndpointId } from '@layerzerolabs/lz-definitions';
|
|
17
13
|
import crypto from 'crypto';
|
|
18
|
-
import
|
|
14
|
+
import base58 from 'bs58';
|
|
19
15
|
|
|
20
16
|
var __defProp = Object.defineProperty;
|
|
21
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
17
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
23
18
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
24
19
|
}) : x)(function(x) {
|
|
@@ -30,10 +25,6 @@ var __export = (target, all) => {
|
|
|
30
25
|
for (var name in all)
|
|
31
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
32
27
|
};
|
|
33
|
-
var __publicField = (obj, key, value) => {
|
|
34
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
|
-
return value;
|
|
36
|
-
};
|
|
37
28
|
var ENDPOINT_SEED = "Endpoint";
|
|
38
29
|
var MESSAGE_LIB_SEED = "MessageLib";
|
|
39
30
|
var SEND_LIBRARY_CONFIG_SEED = "SendLibraryConfig";
|
|
@@ -62,12 +53,28 @@ var PEER_SEED = "Peer";
|
|
|
62
53
|
var MINT_SEED = "Mint";
|
|
63
54
|
var ENFORCED_OPTIONS_SEED = "EnforcedOptions";
|
|
64
55
|
var EndpointPDADeriver = class {
|
|
56
|
+
/**
|
|
57
|
+
* Creates an instance of the EndpointPDADeriver class.
|
|
58
|
+
*
|
|
59
|
+
* @param {PublicKey} program - The program public key.
|
|
60
|
+
*/
|
|
65
61
|
constructor(program) {
|
|
66
62
|
this.program = program;
|
|
67
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Derives the setting address.
|
|
66
|
+
*
|
|
67
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
68
|
+
*/
|
|
68
69
|
setting() {
|
|
69
70
|
return PublicKey.findProgramAddressSync([Buffer.from(ENDPOINT_SEED, "utf8")], this.program);
|
|
70
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Derives the default send library configuration address.
|
|
74
|
+
*
|
|
75
|
+
* @param {number} dstEndpointId - The destination endpoint ID.
|
|
76
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
77
|
+
*/
|
|
71
78
|
defaultSendLibraryConfig(dstEndpointId) {
|
|
72
79
|
return PublicKey.findProgramAddressSync(
|
|
73
80
|
[
|
|
@@ -78,6 +85,13 @@ var EndpointPDADeriver = class {
|
|
|
78
85
|
this.program
|
|
79
86
|
);
|
|
80
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Derives the send library configuration address.
|
|
90
|
+
*
|
|
91
|
+
* @param {PublicKey} sender - The sender public key.
|
|
92
|
+
* @param {number} dstEndpointId - The destination endpoint ID.
|
|
93
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
94
|
+
*/
|
|
81
95
|
sendLibraryConfig(sender, dstEndpointId) {
|
|
82
96
|
return PublicKey.findProgramAddressSync(
|
|
83
97
|
[
|
|
@@ -90,7 +104,10 @@ var EndpointPDADeriver = class {
|
|
|
90
104
|
);
|
|
91
105
|
}
|
|
92
106
|
/**
|
|
93
|
-
*
|
|
107
|
+
* Derives the message library information address.
|
|
108
|
+
*
|
|
109
|
+
* @param {PublicKey} messageLibrary - The message library public key, PDA(derive by message lib program)
|
|
110
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
94
111
|
*/
|
|
95
112
|
messageLibraryInfo(messageLibrary) {
|
|
96
113
|
return PublicKey.findProgramAddressSync(
|
|
@@ -98,6 +115,12 @@ var EndpointPDADeriver = class {
|
|
|
98
115
|
this.program
|
|
99
116
|
);
|
|
100
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Derives the default receive library configuration address.
|
|
120
|
+
*
|
|
121
|
+
* @param {number} srcEndpointId - The source endpoint ID.
|
|
122
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
123
|
+
*/
|
|
101
124
|
defaultReceiveLibraryConfig(srcEndpointId) {
|
|
102
125
|
return PublicKey.findProgramAddressSync(
|
|
103
126
|
[
|
|
@@ -108,6 +131,13 @@ var EndpointPDADeriver = class {
|
|
|
108
131
|
this.program
|
|
109
132
|
);
|
|
110
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Derives the receive library configuration address.
|
|
136
|
+
*
|
|
137
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
138
|
+
* @param {number} srcEndpointId - The source endpoint ID.
|
|
139
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
140
|
+
*/
|
|
111
141
|
receiveLibraryConfig(receiver, srcEndpointId) {
|
|
112
142
|
return PublicKey.findProgramAddressSync(
|
|
113
143
|
[
|
|
@@ -132,9 +162,12 @@ var EndpointPDADeriver = class {
|
|
|
132
162
|
);
|
|
133
163
|
}
|
|
134
164
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @param
|
|
165
|
+
* Derives the nonce address.
|
|
166
|
+
*
|
|
167
|
+
* @param {PublicKey} localOapp - The local OApp public key.
|
|
168
|
+
* @param {number} remoteChainId - The remote chain ID.
|
|
169
|
+
* @param {Uint8Array} remoteOapp - The remote OApp address.
|
|
170
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
138
171
|
*/
|
|
139
172
|
nonce(localOapp, remoteChainId, remoteOapp) {
|
|
140
173
|
return PublicKey.findProgramAddressSync(
|
|
@@ -148,6 +181,14 @@ var EndpointPDADeriver = class {
|
|
|
148
181
|
this.program
|
|
149
182
|
);
|
|
150
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Derives the pending nonce address.
|
|
186
|
+
*
|
|
187
|
+
* @param {PublicKey} localOapp - The local OApp public key.
|
|
188
|
+
* @param {number} remoteChainId - The remote chain ID.
|
|
189
|
+
* @param {Uint8Array} remoteOapp - The remote OApp address.
|
|
190
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
191
|
+
*/
|
|
151
192
|
pendingNonce(localOapp, remoteChainId, remoteOapp) {
|
|
152
193
|
return PublicKey.findProgramAddressSync(
|
|
153
194
|
[
|
|
@@ -159,19 +200,23 @@ var EndpointPDADeriver = class {
|
|
|
159
200
|
this.program
|
|
160
201
|
);
|
|
161
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Derives the OApp registry address.
|
|
205
|
+
*
|
|
206
|
+
* @param {PublicKey} localOapp - The local OApp public key.
|
|
207
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
208
|
+
*/
|
|
162
209
|
oappRegistry(localOapp) {
|
|
163
210
|
return PublicKey.findProgramAddressSync([Buffer.from(OAPP_SEED, "utf8"), localOapp.toBytes()], this.program);
|
|
164
211
|
}
|
|
165
|
-
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* @param
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
171
|
-
* @
|
|
172
|
-
* @
|
|
173
|
-
* @nonce u64 to Uint8Array([0,0,0,0,0,0,0,0])
|
|
174
|
-
* @payloadHash [u8; 32]
|
|
212
|
+
/**
|
|
213
|
+
* Derives the payload hash address.
|
|
214
|
+
*
|
|
215
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
216
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
217
|
+
* @param {Uint8Array} sender - The sender address.
|
|
218
|
+
* @param {number} nonce - The nonce.
|
|
219
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
175
220
|
*/
|
|
176
221
|
payloadHash(receiver, srcEid, sender, nonce) {
|
|
177
222
|
return PublicKey.findProgramAddressSync(
|
|
@@ -185,6 +230,16 @@ var EndpointPDADeriver = class {
|
|
|
185
230
|
this.program
|
|
186
231
|
);
|
|
187
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Derives the composed message address.
|
|
235
|
+
*
|
|
236
|
+
* @param {PublicKey} from - The sender public key.
|
|
237
|
+
* @param {Uint8Array} guid - The GUID.
|
|
238
|
+
* @param {number} index - The index.
|
|
239
|
+
* @param {PublicKey} to - The receiver public key.
|
|
240
|
+
* @param {Uint8Array} messageHash - The message hash.
|
|
241
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
242
|
+
*/
|
|
188
243
|
composedMessage(from, guid, index, to, messageHash) {
|
|
189
244
|
return PublicKey.findProgramAddressSync(
|
|
190
245
|
[
|
|
@@ -200,18 +255,42 @@ var EndpointPDADeriver = class {
|
|
|
200
255
|
}
|
|
201
256
|
};
|
|
202
257
|
var MessageLibPDADeriver = class {
|
|
258
|
+
/**
|
|
259
|
+
* Creates an instance of the MessageLibPDADeriver class.
|
|
260
|
+
*
|
|
261
|
+
* @param {PublicKey} program - The program public key.
|
|
262
|
+
*/
|
|
203
263
|
constructor(program) {
|
|
204
264
|
this.program = program;
|
|
205
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Derives the message library address.
|
|
268
|
+
*
|
|
269
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
270
|
+
*/
|
|
206
271
|
messageLib() {
|
|
207
272
|
return PublicKey.findProgramAddressSync([Buffer.from(MESSAGE_LIB_SEED, "utf8")], this.program);
|
|
208
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Derives the send configuration address.
|
|
276
|
+
*
|
|
277
|
+
* @param {number} eid - The endpoint ID.
|
|
278
|
+
* @param {PublicKey} oapp - The OApp public key.
|
|
279
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
280
|
+
*/
|
|
209
281
|
sendConfig(eid, oapp) {
|
|
210
282
|
return PublicKey.findProgramAddressSync(
|
|
211
283
|
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
|
|
212
284
|
this.program
|
|
213
285
|
);
|
|
214
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Derives the receive configuration address.
|
|
289
|
+
*
|
|
290
|
+
* @param {number} eid - The endpoint ID.
|
|
291
|
+
* @param {PublicKey} oapp - The OApp public key.
|
|
292
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
293
|
+
*/
|
|
215
294
|
receiveConfig(eid, oapp) {
|
|
216
295
|
return PublicKey.findProgramAddressSync(
|
|
217
296
|
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4), oapp.toBuffer()],
|
|
@@ -220,36 +299,79 @@ var MessageLibPDADeriver = class {
|
|
|
220
299
|
}
|
|
221
300
|
};
|
|
222
301
|
var UlnPDADeriver = class extends MessageLibPDADeriver {
|
|
302
|
+
/**
|
|
303
|
+
* Derives the setting address.
|
|
304
|
+
*
|
|
305
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
306
|
+
*/
|
|
223
307
|
setting() {
|
|
224
308
|
return PublicKey.findProgramAddressSync([Buffer.from(ULN_SEED, "utf8")], this.program);
|
|
225
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Derives the configuration address.
|
|
312
|
+
*
|
|
313
|
+
* @param {number} eid - The endpoint ID.
|
|
314
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
315
|
+
*/
|
|
226
316
|
config(eid) {
|
|
227
317
|
return PublicKey.findProgramAddressSync(
|
|
228
318
|
[Buffer.from(ULN_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
229
319
|
this.program
|
|
230
320
|
);
|
|
231
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Derives the default send configuration address.
|
|
324
|
+
*
|
|
325
|
+
* @param {number} eid - The endpoint ID.
|
|
326
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
327
|
+
*/
|
|
232
328
|
defaultSendConfig(eid) {
|
|
233
329
|
return PublicKey.findProgramAddressSync(
|
|
234
330
|
[Buffer.from(SEND_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
235
331
|
this.program
|
|
236
332
|
);
|
|
237
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Derives the default receive configuration address.
|
|
336
|
+
*
|
|
337
|
+
* @param {number} eid - The endpoint ID.
|
|
338
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
339
|
+
*/
|
|
238
340
|
defaultReceiveConfig(eid) {
|
|
239
341
|
return PublicKey.findProgramAddressSync(
|
|
240
342
|
[Buffer.from(RECEIVE_CONFIG_SEED, "utf8"), new BN(eid).toArrayLike(Buffer, "be", 4)],
|
|
241
343
|
this.program
|
|
242
344
|
);
|
|
243
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Derives the options address.
|
|
348
|
+
*
|
|
349
|
+
* @param {number} eit - The endpoint ID.
|
|
350
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
351
|
+
*/
|
|
244
352
|
options(eit) {
|
|
245
353
|
return PublicKey.findProgramAddressSync(
|
|
246
354
|
[Buffer.from(OPTIONS_SEED, "utf8"), new BN(eit).toArrayLike(Buffer, "be", 4)],
|
|
247
355
|
this.program
|
|
248
356
|
);
|
|
249
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Derives the worker configuration address.
|
|
360
|
+
*
|
|
361
|
+
* @param {PublicKey} worker - The worker public key.
|
|
362
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
363
|
+
*/
|
|
250
364
|
workerConfig(worker) {
|
|
251
365
|
return PublicKey.findProgramAddressSync([Buffer.from(WORKER_SEED, "utf8"), worker.toBuffer()], this.program);
|
|
252
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Derives the confirmations address.
|
|
369
|
+
*
|
|
370
|
+
* @param {Uint8Array} headerHash - The header hash.
|
|
371
|
+
* @param {Uint8Array} payloadHash - The payload hash.
|
|
372
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
373
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
374
|
+
*/
|
|
253
375
|
confirmations(headerHash, payloadHash, dvn) {
|
|
254
376
|
return PublicKey.findProgramAddressSync(
|
|
255
377
|
[Buffer.from(CONFIRMATIONS_SEED, "utf8"), headerHash, payloadHash, dvn.toBytes()],
|
|
@@ -258,18 +380,39 @@ var UlnPDADeriver = class extends MessageLibPDADeriver {
|
|
|
258
380
|
}
|
|
259
381
|
};
|
|
260
382
|
var OAppBasePDADeriver = class {
|
|
383
|
+
/**
|
|
384
|
+
* Creates an instance of the OAppBasePDADeriver class.
|
|
385
|
+
*
|
|
386
|
+
* @param {PublicKey} program - The program public key.
|
|
387
|
+
*/
|
|
261
388
|
constructor(program) {
|
|
262
389
|
this.program = program;
|
|
263
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Derives the remote address.
|
|
393
|
+
*
|
|
394
|
+
* @param {number} dstChainId - The destination chain ID.
|
|
395
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
396
|
+
*/
|
|
264
397
|
remote(dstChainId) {
|
|
265
398
|
return PublicKey.findProgramAddressSync(
|
|
266
399
|
[Buffer.from(REMOTE_SEED), new BN(dstChainId).toArrayLike(Buffer, "be", 4)],
|
|
267
400
|
this.program
|
|
268
401
|
);
|
|
269
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Derives the LzReceive types accounts address.
|
|
405
|
+
*
|
|
406
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
407
|
+
*/
|
|
270
408
|
lzReceiveTypesAccounts() {
|
|
271
409
|
return PublicKey.findProgramAddressSync([Buffer.from(LZ_RECEIVE_TYPES_SEED, "utf8")], this.program);
|
|
272
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Derives the LzCompose types accounts address.
|
|
413
|
+
*
|
|
414
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
415
|
+
*/
|
|
273
416
|
lzComposeTypesAccounts() {
|
|
274
417
|
return PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], this.program);
|
|
275
418
|
}
|
|
@@ -278,36 +421,82 @@ var DVNDeriver = class {
|
|
|
278
421
|
constructor(program) {
|
|
279
422
|
this.program = program;
|
|
280
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Derives the authority address.
|
|
426
|
+
*
|
|
427
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
428
|
+
*/
|
|
281
429
|
authority() {
|
|
282
430
|
return PublicKey.findProgramAddressSync([Buffer.from("dvn", "utf8")], this.program);
|
|
283
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Derives the configuration address.
|
|
434
|
+
*
|
|
435
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
436
|
+
*/
|
|
284
437
|
config() {
|
|
285
438
|
return PublicKey.findProgramAddressSync([Buffer.from(DVN_CONFIG_SEED, "utf8")], this.program);
|
|
286
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Derives the execute hash address.
|
|
442
|
+
*
|
|
443
|
+
* @param {Buffer} digestHash - The digest hash.
|
|
444
|
+
* @returns {[PublicKey, number]} The derived address and bump seed.
|
|
445
|
+
*/
|
|
287
446
|
executeHash(digestHash) {
|
|
288
447
|
return PublicKey.findProgramAddressSync([Buffer.from("ExecuteHash", "utf8"), digestHash], this.program);
|
|
289
448
|
}
|
|
290
449
|
};
|
|
291
450
|
var EventPDADeriver = class {
|
|
451
|
+
/**
|
|
452
|
+
* Creates an instance of the EventPDADeriver class.
|
|
453
|
+
*
|
|
454
|
+
* @param {PublicKey} program - The program public key.
|
|
455
|
+
*/
|
|
292
456
|
constructor(program) {
|
|
293
457
|
this.program = program;
|
|
294
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Derives the event authority PDA.
|
|
461
|
+
*
|
|
462
|
+
* @returns {[PublicKey, number]} The event authority PDA and bump seed.
|
|
463
|
+
*/
|
|
295
464
|
eventAuthority() {
|
|
296
465
|
return PublicKey.findProgramAddressSync([Buffer.from(EVENT_SEED, "utf8")], this.program);
|
|
297
466
|
}
|
|
298
467
|
};
|
|
299
468
|
var ExecutorPDADeriver = class {
|
|
469
|
+
/**
|
|
470
|
+
* Creates an instance of the ExecutorPDADeriver class.
|
|
471
|
+
*
|
|
472
|
+
* @param {PublicKey} program - The program public key.
|
|
473
|
+
*/
|
|
300
474
|
constructor(program) {
|
|
301
475
|
this.program = program;
|
|
302
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Derives the executor configuration PDA.
|
|
479
|
+
*
|
|
480
|
+
* @returns {[PublicKey, number]} The executor configuration PDA and bump seed.
|
|
481
|
+
*/
|
|
303
482
|
config() {
|
|
304
483
|
return PublicKey.findProgramAddressSync([Buffer.from(EXECUTOR_CONFIG_SEED, "utf8")], this.program);
|
|
305
484
|
}
|
|
306
485
|
};
|
|
307
486
|
var PriceFeedPDADeriver = class {
|
|
487
|
+
/**
|
|
488
|
+
* Creates an instance of the PriceFeedPDADeriver class.
|
|
489
|
+
*
|
|
490
|
+
* @param {PublicKey} program - The program public key.
|
|
491
|
+
*/
|
|
308
492
|
constructor(program) {
|
|
309
493
|
this.program = program;
|
|
310
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* Derives the price feed PDA.
|
|
497
|
+
*
|
|
498
|
+
* @returns {[PublicKey, number]} The price feed PDA and bump seed.
|
|
499
|
+
*/
|
|
311
500
|
priceFeed() {
|
|
312
501
|
return PublicKey.findProgramAddressSync([Buffer.from(PRICE_FEED_SEED, "utf8")], this.program);
|
|
313
502
|
}
|
|
@@ -326,138 +515,6 @@ __export(endpoint_exports, {
|
|
|
326
515
|
instructions: () => instructions_exports,
|
|
327
516
|
types: () => types_exports
|
|
328
517
|
});
|
|
329
|
-
function hexZeroPadTo32(addr) {
|
|
330
|
-
return hexZeroPad(addr, 32);
|
|
331
|
-
}
|
|
332
|
-
function bytes32ToEthAddress(bytes322) {
|
|
333
|
-
if (bytes322 instanceof Uint8Array) {
|
|
334
|
-
bytes322 = hexlify(bytes322);
|
|
335
|
-
}
|
|
336
|
-
return getAddress(bytes322.slice(-40));
|
|
337
|
-
}
|
|
338
|
-
function trim0x(str) {
|
|
339
|
-
return str.replace(/^0x/, "");
|
|
340
|
-
}
|
|
341
|
-
function addressToBytes32(address) {
|
|
342
|
-
if (isSolanaAddress(address)) {
|
|
343
|
-
return base58.decode(address);
|
|
344
|
-
} else if (address.startsWith("0x") && address.length <= 66) {
|
|
345
|
-
return arrayify(hexZeroPadTo32(address));
|
|
346
|
-
}
|
|
347
|
-
throw new Error("Invalid address");
|
|
348
|
-
}
|
|
349
|
-
var solanaAddressRegex = /^([1-9A-HJ-NP-Za-km-z]{32,44})$/;
|
|
350
|
-
function isSolanaAddress(address) {
|
|
351
|
-
return solanaAddressRegex.test(address);
|
|
352
|
-
}
|
|
353
|
-
BigNumber.from("0xffffffffffffffffffffffffffffffff");
|
|
354
|
-
var PACKET_VERSION_OFFSET = 0;
|
|
355
|
-
var NONCE_OFFSET = 1;
|
|
356
|
-
var SRC_CHAIN_OFFSET = 9;
|
|
357
|
-
var SRC_ADDRESS_OFFSET = 13;
|
|
358
|
-
var DST_CHAIN_OFFSET = 45;
|
|
359
|
-
var DST_ADDRESS_OFFSET = 49;
|
|
360
|
-
var GUID_OFFSET = 81;
|
|
361
|
-
var MESSAGE_OFFSET = 113;
|
|
362
|
-
var PacketV1Codec = class _PacketV1Codec {
|
|
363
|
-
constructor(payloadEncoded) {
|
|
364
|
-
__publicField(this, "buffer");
|
|
365
|
-
this.buffer = Buffer.from(trim0x(payloadEncoded), "hex");
|
|
366
|
-
}
|
|
367
|
-
static from(payloadEncoded) {
|
|
368
|
-
return new _PacketV1Codec(payloadEncoded);
|
|
369
|
-
}
|
|
370
|
-
static fromBytes(payload) {
|
|
371
|
-
return new _PacketV1Codec("0x" + Buffer.from(payload).toString("hex"));
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* encode packet to hex string
|
|
375
|
-
*/
|
|
376
|
-
static encode(packet) {
|
|
377
|
-
const buff = this.encodeBytes(packet);
|
|
378
|
-
return "0x" + Buffer.from(buff).toString("hex");
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* encode packet to Uint8Array
|
|
382
|
-
* @param packet
|
|
383
|
-
*/
|
|
384
|
-
static encodeBytes(packet) {
|
|
385
|
-
const message = trim0x(packet.message);
|
|
386
|
-
const buffer = Buffer.alloc(MESSAGE_OFFSET + message.length / 2);
|
|
387
|
-
buffer.writeUInt8(packet.version, PACKET_VERSION_OFFSET);
|
|
388
|
-
buffer.writeBigUInt64BE(BigInt(packet.nonce), NONCE_OFFSET);
|
|
389
|
-
buffer.writeUInt32BE(packet.srcEid, SRC_CHAIN_OFFSET);
|
|
390
|
-
buffer.write(Buffer.from(addressToBytes32(packet.sender)).toString("hex"), SRC_ADDRESS_OFFSET, 32, "hex");
|
|
391
|
-
buffer.writeUInt32BE(packet.dstEid, DST_CHAIN_OFFSET);
|
|
392
|
-
buffer.write(Buffer.from(addressToBytes32(packet.receiver)).toString("hex"), DST_ADDRESS_OFFSET, 32, "hex");
|
|
393
|
-
buffer.write(trim0x(packet.guid), GUID_OFFSET, 32, "hex");
|
|
394
|
-
buffer.write(message, MESSAGE_OFFSET, message.length / 2, "hex");
|
|
395
|
-
return new Uint8Array(buffer);
|
|
396
|
-
}
|
|
397
|
-
version() {
|
|
398
|
-
return this.buffer.readUInt8(PACKET_VERSION_OFFSET);
|
|
399
|
-
}
|
|
400
|
-
nonce() {
|
|
401
|
-
return this.buffer.readBigUint64BE(NONCE_OFFSET).toString();
|
|
402
|
-
}
|
|
403
|
-
srcEid() {
|
|
404
|
-
return this.buffer.readUint32BE(SRC_CHAIN_OFFSET);
|
|
405
|
-
}
|
|
406
|
-
sender() {
|
|
407
|
-
return "0x" + this.buffer.slice(SRC_ADDRESS_OFFSET, DST_CHAIN_OFFSET).toString("hex");
|
|
408
|
-
}
|
|
409
|
-
senderAddressB20() {
|
|
410
|
-
return bytes32ToEthAddress(this.sender());
|
|
411
|
-
}
|
|
412
|
-
dstEid() {
|
|
413
|
-
return this.buffer.readUint32BE(DST_CHAIN_OFFSET);
|
|
414
|
-
}
|
|
415
|
-
receiver() {
|
|
416
|
-
return "0x" + this.buffer.slice(DST_ADDRESS_OFFSET, GUID_OFFSET).toString("hex");
|
|
417
|
-
}
|
|
418
|
-
receiverAddressB20() {
|
|
419
|
-
return bytes32ToEthAddress(this.receiver());
|
|
420
|
-
}
|
|
421
|
-
guid() {
|
|
422
|
-
return "0x" + this.buffer.slice(GUID_OFFSET, MESSAGE_OFFSET).toString("hex");
|
|
423
|
-
}
|
|
424
|
-
message() {
|
|
425
|
-
return "0x" + this.buffer.slice(MESSAGE_OFFSET).toString("hex");
|
|
426
|
-
}
|
|
427
|
-
payloadHash() {
|
|
428
|
-
return keccak256(this.payload());
|
|
429
|
-
}
|
|
430
|
-
payload() {
|
|
431
|
-
return "0x" + this.buffer.slice(GUID_OFFSET).toString("hex");
|
|
432
|
-
}
|
|
433
|
-
header() {
|
|
434
|
-
return "0x" + this.buffer.slice(0, GUID_OFFSET).toString("hex");
|
|
435
|
-
}
|
|
436
|
-
headerHash() {
|
|
437
|
-
return keccak256(this.header());
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* deserialize packet from hex string
|
|
441
|
-
* @deprecated use toPacket instead
|
|
442
|
-
*/
|
|
443
|
-
decode() {
|
|
444
|
-
return this.toPacket();
|
|
445
|
-
}
|
|
446
|
-
toPacket() {
|
|
447
|
-
return {
|
|
448
|
-
version: this.version(),
|
|
449
|
-
nonce: this.nonce(),
|
|
450
|
-
srcEid: this.srcEid(),
|
|
451
|
-
sender: this.sender(),
|
|
452
|
-
dstEid: this.dstEid(),
|
|
453
|
-
receiver: this.receiver(),
|
|
454
|
-
guid: this.guid(),
|
|
455
|
-
message: this.message(),
|
|
456
|
-
// derived
|
|
457
|
-
payload: this.payload()
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
518
|
|
|
462
519
|
// src/generated/endpoint/accounts/index.ts
|
|
463
520
|
var accounts_exports = {};
|
|
@@ -5836,6 +5893,11 @@ var sendLibrarySetEventBeet = new beet159.BeetArgsStruct(
|
|
|
5836
5893
|
var EventEmitDiscriminator = "e445a52e51cb9a1d";
|
|
5837
5894
|
var DefaultMessageLib = PublicKey.default;
|
|
5838
5895
|
var Endpoint = class {
|
|
5896
|
+
/**
|
|
5897
|
+
* Creates an instance of the Endpoint class.
|
|
5898
|
+
*
|
|
5899
|
+
* @param {PublicKey} program - The program public key.
|
|
5900
|
+
*/
|
|
5839
5901
|
constructor(program) {
|
|
5840
5902
|
this.program = program;
|
|
5841
5903
|
this.deriver = new EndpointPDADeriver(program);
|
|
@@ -5843,7 +5905,12 @@ var Endpoint = class {
|
|
|
5843
5905
|
this.eventAuthorityPDA = eventAuthorityPDA;
|
|
5844
5906
|
}
|
|
5845
5907
|
/**
|
|
5846
|
-
*
|
|
5908
|
+
* Initializes the endpoint settings, including eid and admin, and registers the blocked message library.
|
|
5909
|
+
*
|
|
5910
|
+
* @param {number} endpointId - The endpoint ID.
|
|
5911
|
+
* @param {PublicKey} payer - The payer public key.
|
|
5912
|
+
* @param {PublicKey} admin - The admin public key.
|
|
5913
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
5847
5914
|
*/
|
|
5848
5915
|
initEndpoint(endpointId, payer, admin) {
|
|
5849
5916
|
const [settingPDA] = this.deriver.setting();
|
|
@@ -5862,8 +5929,14 @@ var Endpoint = class {
|
|
|
5862
5929
|
);
|
|
5863
5930
|
}
|
|
5864
5931
|
// async initOrUpdateConfig(connection:Connection,)
|
|
5865
|
-
|
|
5932
|
+
/**
|
|
5933
|
+
* Registers a library.
|
|
5866
5934
|
* call this function after endpoint initialized. Only admin can call this function.
|
|
5935
|
+
*
|
|
5936
|
+
* @param {PublicKey} admin - The admin public key.
|
|
5937
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
5938
|
+
* @param {types.MessageLibType} [libType=types.MessageLibType.SendAndReceive] - The library type.
|
|
5939
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
5867
5940
|
*/
|
|
5868
5941
|
registerLibrary(admin, messageLibProgram, libType = 2 /* SendAndReceive */) {
|
|
5869
5942
|
const [msgLibPda] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
@@ -5886,6 +5959,16 @@ var Endpoint = class {
|
|
|
5886
5959
|
this.program
|
|
5887
5960
|
);
|
|
5888
5961
|
}
|
|
5962
|
+
/**
|
|
5963
|
+
* Sets the default send library.
|
|
5964
|
+
*
|
|
5965
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
5966
|
+
* @param {PublicKey} admin - The admin public key.
|
|
5967
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
5968
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
5969
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
5970
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
5971
|
+
*/
|
|
5889
5972
|
async setDefaultSendLibrary(connection, admin, messageLibProgram, dstEid, commitmentOrConfig) {
|
|
5890
5973
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
5891
5974
|
const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -5938,6 +6021,16 @@ var Endpoint = class {
|
|
|
5938
6021
|
);
|
|
5939
6022
|
}
|
|
5940
6023
|
}
|
|
6024
|
+
/**
|
|
6025
|
+
* Sets the default receive library.
|
|
6026
|
+
*
|
|
6027
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6028
|
+
* @param {PublicKey} admin - The admin public key.
|
|
6029
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
6030
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6031
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6032
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6033
|
+
*/
|
|
5941
6034
|
async setDefaultReceiveLibrary(connection, admin, messageLibProgram, srcEid, commitmentOrConfig) {
|
|
5942
6035
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
5943
6036
|
const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
|
|
@@ -5992,6 +6085,16 @@ var Endpoint = class {
|
|
|
5992
6085
|
);
|
|
5993
6086
|
}
|
|
5994
6087
|
}
|
|
6088
|
+
/**
|
|
6089
|
+
* Initializes the OApp configuration.
|
|
6090
|
+
*
|
|
6091
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6092
|
+
* @param {MessageLibInterface} msgLibSDK - The message library SDK.
|
|
6093
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6094
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
6095
|
+
* @param {number} eid - The endpoint ID.
|
|
6096
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6097
|
+
*/
|
|
5995
6098
|
initOAppConfig(delegate, msgLibSDK, payer, oappID, eid) {
|
|
5996
6099
|
const [msgLib] = new MessageLibPDADeriver(msgLibSDK.program).messageLib();
|
|
5997
6100
|
const [oappRegistry] = this.deriver.oappRegistry(oappID);
|
|
@@ -6014,6 +6117,15 @@ var Endpoint = class {
|
|
|
6014
6117
|
this.program
|
|
6015
6118
|
);
|
|
6016
6119
|
}
|
|
6120
|
+
/**
|
|
6121
|
+
* Initializes the OApp nonce.
|
|
6122
|
+
*
|
|
6123
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6124
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6125
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
6126
|
+
* @param {Uint8Array} remoteOappAddr - The remote OApp address.
|
|
6127
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6128
|
+
*/
|
|
6017
6129
|
initOAppNonce(delegate, dstEid, oappIDPDA2, remoteOappAddr) {
|
|
6018
6130
|
const [nonce] = this.deriver.nonce(oappIDPDA2, dstEid, remoteOappAddr);
|
|
6019
6131
|
const [pendingNonce] = this.deriver.pendingNonce(oappIDPDA2, dstEid, remoteOappAddr);
|
|
@@ -6035,6 +6147,14 @@ var Endpoint = class {
|
|
|
6035
6147
|
this.program
|
|
6036
6148
|
);
|
|
6037
6149
|
}
|
|
6150
|
+
/**
|
|
6151
|
+
* Initializes the send library.
|
|
6152
|
+
*
|
|
6153
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6154
|
+
* @param {PublicKey} sender - The sender public key.
|
|
6155
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6156
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6157
|
+
*/
|
|
6038
6158
|
initSendLibrary(delegate, sender, dstEid) {
|
|
6039
6159
|
const [oappRegistry] = this.deriver.oappRegistry(sender);
|
|
6040
6160
|
const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid);
|
|
@@ -6053,6 +6173,15 @@ var Endpoint = class {
|
|
|
6053
6173
|
this.program
|
|
6054
6174
|
);
|
|
6055
6175
|
}
|
|
6176
|
+
/**
|
|
6177
|
+
* Sets the send library.
|
|
6178
|
+
*
|
|
6179
|
+
* @param {PublicKey} oappAdmin - The OApp admin public key.
|
|
6180
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
6181
|
+
* @param {PublicKey} newSendLibProgram - The new send library program public key.
|
|
6182
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6183
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6184
|
+
*/
|
|
6056
6185
|
setSendLibrary(oappAdmin, oappIDPDA2, newSendLibProgram, dstEid) {
|
|
6057
6186
|
const [newSendLib] = new MessageLibPDADeriver(newSendLibProgram).messageLib();
|
|
6058
6187
|
const [sendLibraryConfig] = this.deriver.sendLibraryConfig(oappIDPDA2, dstEid);
|
|
@@ -6078,6 +6207,14 @@ var Endpoint = class {
|
|
|
6078
6207
|
);
|
|
6079
6208
|
return ix;
|
|
6080
6209
|
}
|
|
6210
|
+
/**
|
|
6211
|
+
* Initializes the receive library.
|
|
6212
|
+
*
|
|
6213
|
+
* @param {PublicKey} delegate - The delegate public key.
|
|
6214
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6215
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6216
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6217
|
+
*/
|
|
6081
6218
|
initReceiveLibrary(delegate, receiver, srcEid) {
|
|
6082
6219
|
const [oappRegistry] = this.deriver.oappRegistry(receiver);
|
|
6083
6220
|
const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid);
|
|
@@ -6096,6 +6233,16 @@ var Endpoint = class {
|
|
|
6096
6233
|
this.program
|
|
6097
6234
|
);
|
|
6098
6235
|
}
|
|
6236
|
+
/**
|
|
6237
|
+
* Sets the receive library.
|
|
6238
|
+
*
|
|
6239
|
+
* @param {PublicKey} oappAdmin - The OApp admin public key.
|
|
6240
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
6241
|
+
* @param {PublicKey} newReceiveLibProgram - The new receive library program public key.
|
|
6242
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6243
|
+
* @param {bigint | number} [gracePeriod] - The grace period.
|
|
6244
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
6245
|
+
*/
|
|
6099
6246
|
setReceiveLibrary(oappAdmin, oappIDPDA2, newReceiveLibProgram, srcEid, gracePeriod) {
|
|
6100
6247
|
const [newReceiveLib] = new MessageLibPDADeriver(newReceiveLibProgram).messageLib();
|
|
6101
6248
|
const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(oappIDPDA2, srcEid);
|
|
@@ -6122,6 +6269,21 @@ var Endpoint = class {
|
|
|
6122
6269
|
);
|
|
6123
6270
|
return ix;
|
|
6124
6271
|
}
|
|
6272
|
+
/**
|
|
6273
|
+
* Sets the OApp configuration.
|
|
6274
|
+
*
|
|
6275
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6276
|
+
* @param {PublicKey} oappDelegate - The OApp delegate public key.
|
|
6277
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
6278
|
+
* @param {PublicKey} msgLibProgram - The message library program public key.
|
|
6279
|
+
* @param {number} eid - The endpoint ID.
|
|
6280
|
+
* @param {object} config - The configuration object.
|
|
6281
|
+
* @param {SetConfigType} config.configType - The configuration type.
|
|
6282
|
+
* @param {UlnProgram.types.ExecutorConfig | UlnProgram.types.UlnConfig} config.value - The configuration value.
|
|
6283
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
6284
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
6285
|
+
* @throws {Error} If the message library version is unsupported.
|
|
6286
|
+
*/
|
|
6125
6287
|
async setOappConfig(connection, oappDelegate, oappID, msgLibProgram, eid, config, commitment = "confirmed") {
|
|
6126
6288
|
const [msgLib] = new MessageLibPDADeriver(msgLibProgram).messageLib();
|
|
6127
6289
|
const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib);
|
|
@@ -6159,7 +6321,9 @@ var Endpoint = class {
|
|
|
6159
6321
|
return ix;
|
|
6160
6322
|
}
|
|
6161
6323
|
/// send a simulated transaction to the endpoint to get the fee for sending a message
|
|
6162
|
-
|
|
6324
|
+
/**
|
|
6325
|
+
*
|
|
6326
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
6163
6327
|
*
|
|
6164
6328
|
* caculate the fee for sending a message with ULN:
|
|
6165
6329
|
* 1. executorFee: feeForGas + feeForOptionType
|
|
@@ -6170,6 +6334,13 @@ var Endpoint = class {
|
|
|
6170
6334
|
*
|
|
6171
6335
|
* The priceRatioDenominator is 10^20
|
|
6172
6336
|
* totalFee = executorFee + oracleFee * numOracles(requiredOracles + optionalOracles)
|
|
6337
|
+
*
|
|
6338
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6339
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6340
|
+
* @param {PacketPath} path - The packet path.
|
|
6341
|
+
* @param {MessageLibInterface} msgLibProgram - The message library program.
|
|
6342
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
6343
|
+
* @throws {Error} If the default send library is not initialized or the message library is blocked.
|
|
6173
6344
|
*/
|
|
6174
6345
|
async getQuoteIXAccountMetaForCPI(connection, payer, path, msgLibProgram) {
|
|
6175
6346
|
const { sender: sender_, dstEid, receiver: receiver_ } = path;
|
|
@@ -6208,8 +6379,16 @@ var Endpoint = class {
|
|
|
6208
6379
|
].concat(accounts)
|
|
6209
6380
|
);
|
|
6210
6381
|
}
|
|
6211
|
-
|
|
6212
|
-
*
|
|
6382
|
+
/**
|
|
6383
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
|
|
6384
|
+
*
|
|
6385
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6386
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6387
|
+
* @param {PacketPath} path - The packet path.
|
|
6388
|
+
* @param {MessageLibInterface} msgLibProgram - The message library program.
|
|
6389
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6390
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
6391
|
+
* @throws {Error} If the default send library is not initialized or the message library is blocked.
|
|
6213
6392
|
*/
|
|
6214
6393
|
async getSendIXAccountMetaForCPI(connection, payer, path, msgLibProgram, commitmentOrConfig) {
|
|
6215
6394
|
const { sender: sender_, dstEid, receiver: receiver_ } = path;
|
|
@@ -6253,6 +6432,16 @@ var Endpoint = class {
|
|
|
6253
6432
|
}
|
|
6254
6433
|
].concat(accounts);
|
|
6255
6434
|
}
|
|
6435
|
+
/**
|
|
6436
|
+
* Skips a message.
|
|
6437
|
+
*
|
|
6438
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6439
|
+
* @param {PublicKey} sender - The sender public key.
|
|
6440
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6441
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6442
|
+
* @param {string} nonce - The nonce.
|
|
6443
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6444
|
+
*/
|
|
6256
6445
|
async skip(payer, sender, receiver, srcEid, nonce) {
|
|
6257
6446
|
const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
|
|
6258
6447
|
const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
|
|
@@ -6284,6 +6473,18 @@ var Endpoint = class {
|
|
|
6284
6473
|
);
|
|
6285
6474
|
return Promise.resolve(ix);
|
|
6286
6475
|
}
|
|
6476
|
+
/**
|
|
6477
|
+
* Initializes the verification process.
|
|
6478
|
+
*
|
|
6479
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6480
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6481
|
+
* @param {PublicKey} sender - The sender public key.
|
|
6482
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6483
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6484
|
+
* @param {string} nonce - The nonce.
|
|
6485
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6486
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
6487
|
+
*/
|
|
6287
6488
|
async initVerify(connection, payer, sender, receiver, srcEid, nonce, commitmentOrConfig) {
|
|
6288
6489
|
const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()));
|
|
6289
6490
|
const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce));
|
|
@@ -6308,6 +6509,13 @@ var Endpoint = class {
|
|
|
6308
6509
|
this.program
|
|
6309
6510
|
);
|
|
6310
6511
|
}
|
|
6512
|
+
/**
|
|
6513
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the verify instruction.
|
|
6514
|
+
*
|
|
6515
|
+
* @param {PacketV1Codec} packet - The packet.
|
|
6516
|
+
* @param {PublicKey} receiveLibrary - The receive library public key.
|
|
6517
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
6518
|
+
*/
|
|
6311
6519
|
getVerifyIXAccountMetaForCPI(packet, receiveLibrary) {
|
|
6312
6520
|
const receiver = new PublicKey(Buffer.from(packet.receiver().slice(2), "hex"));
|
|
6313
6521
|
const srcEid = packet.srcEid();
|
|
@@ -6503,6 +6711,13 @@ var Endpoint = class {
|
|
|
6503
6711
|
// } as AccountMeta,
|
|
6504
6712
|
// ].concat(ix.keys)
|
|
6505
6713
|
// }
|
|
6714
|
+
/**
|
|
6715
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the register OApp instruction.
|
|
6716
|
+
*
|
|
6717
|
+
* @param {PublicKey} payer - The payer public key.
|
|
6718
|
+
* @param {PublicKey} oapp - The OApp public key.
|
|
6719
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
6720
|
+
*/
|
|
6506
6721
|
getRegisterOappIxAccountMetaForCPI(payer, oapp) {
|
|
6507
6722
|
const [oappRegistry] = this.deriver.oappRegistry(oapp);
|
|
6508
6723
|
const eventAuthority = this.eventAuthorityPDA;
|
|
@@ -6527,6 +6742,15 @@ var Endpoint = class {
|
|
|
6527
6742
|
}
|
|
6528
6743
|
].concat(keys);
|
|
6529
6744
|
}
|
|
6745
|
+
/**
|
|
6746
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the skip instruction.
|
|
6747
|
+
*
|
|
6748
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
6749
|
+
* @param {Uint8Array} sender - The sender address.
|
|
6750
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6751
|
+
* @param {number} nonce - The nonce.
|
|
6752
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
6753
|
+
*/
|
|
6530
6754
|
getSkipIxAccountMetaForCPI(receiver, sender, srcEid, nonce) {
|
|
6531
6755
|
const [noncePDA] = this.deriver.nonce(receiver, srcEid, sender);
|
|
6532
6756
|
const [pendingNonce] = this.deriver.pendingNonce(receiver, srcEid, sender);
|
|
@@ -6556,6 +6780,15 @@ var Endpoint = class {
|
|
|
6556
6780
|
}
|
|
6557
6781
|
].concat(keys);
|
|
6558
6782
|
}
|
|
6783
|
+
/**
|
|
6784
|
+
* Checks if the given message library program is the default send library.
|
|
6785
|
+
*
|
|
6786
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6787
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
6788
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6789
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6790
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default send library, false otherwise.
|
|
6791
|
+
*/
|
|
6559
6792
|
async isDefaultSendLibrary(connection, messageLibProgram, dstEid, commitmentOrConfig) {
|
|
6560
6793
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
6561
6794
|
const info = await this.getDefaultSendLibrary(connection, dstEid, commitmentOrConfig);
|
|
@@ -6564,6 +6797,15 @@ var Endpoint = class {
|
|
|
6564
6797
|
}
|
|
6565
6798
|
return false;
|
|
6566
6799
|
}
|
|
6800
|
+
/**
|
|
6801
|
+
* Checks if the given message library program is the default receive library.
|
|
6802
|
+
*
|
|
6803
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6804
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
6805
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6806
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6807
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default receive library, false otherwise.
|
|
6808
|
+
*/
|
|
6567
6809
|
async isDefaultReceiveLibrary(connection, messageLibProgram, srcEid, commitmentOrConfig) {
|
|
6568
6810
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
6569
6811
|
const info = await this.getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig);
|
|
@@ -6573,6 +6815,13 @@ var Endpoint = class {
|
|
|
6573
6815
|
return false;
|
|
6574
6816
|
}
|
|
6575
6817
|
// all of below functions are retrieving accounts state
|
|
6818
|
+
/**
|
|
6819
|
+
* Gets the endpoint settings.
|
|
6820
|
+
*
|
|
6821
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6822
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6823
|
+
* @returns {Promise<EndpointSettings | null>} A promise that resolves to the endpoint settings or null if not found.
|
|
6824
|
+
*/
|
|
6576
6825
|
async getSetting(connection, commitmentOrConfig) {
|
|
6577
6826
|
const [setting] = this.deriver.setting();
|
|
6578
6827
|
try {
|
|
@@ -6582,8 +6831,12 @@ var Endpoint = class {
|
|
|
6582
6831
|
}
|
|
6583
6832
|
}
|
|
6584
6833
|
/**
|
|
6834
|
+
* Gets the message library information.
|
|
6585
6835
|
*
|
|
6586
|
-
* @param
|
|
6836
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6837
|
+
* @param {PublicKey} messageLibProgram - The message library program public key, It is a PDA of the message library program
|
|
6838
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6839
|
+
* @returns {Promise<MessageLibInfo | null>} A promise that resolves to the message library information or null if not found.
|
|
6587
6840
|
*/
|
|
6588
6841
|
async getMessageLibInfo(connection, messageLibProgram, commitmentOrConfig) {
|
|
6589
6842
|
const [msgLib] = new MessageLibPDADeriver(messageLibProgram).messageLib();
|
|
@@ -6594,6 +6847,14 @@ var Endpoint = class {
|
|
|
6594
6847
|
return null;
|
|
6595
6848
|
}
|
|
6596
6849
|
}
|
|
6850
|
+
/**
|
|
6851
|
+
* Gets the default receive library.
|
|
6852
|
+
*
|
|
6853
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6854
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6855
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6856
|
+
* @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default receive library or null if not found.
|
|
6857
|
+
*/
|
|
6597
6858
|
async getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig) {
|
|
6598
6859
|
const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid);
|
|
6599
6860
|
try {
|
|
@@ -6616,6 +6877,14 @@ var Endpoint = class {
|
|
|
6616
6877
|
return null;
|
|
6617
6878
|
}
|
|
6618
6879
|
}
|
|
6880
|
+
/**
|
|
6881
|
+
* Gets the default send library.
|
|
6882
|
+
*
|
|
6883
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6884
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6885
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6886
|
+
* @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default send library or null if not found.
|
|
6887
|
+
*/
|
|
6619
6888
|
async getDefaultSendLibrary(connection, dstEid, commitmentOrConfig) {
|
|
6620
6889
|
const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid);
|
|
6621
6890
|
try {
|
|
@@ -6639,8 +6908,13 @@ var Endpoint = class {
|
|
|
6639
6908
|
}
|
|
6640
6909
|
}
|
|
6641
6910
|
/**
|
|
6642
|
-
*
|
|
6643
|
-
*
|
|
6911
|
+
* Gets the configured send library for the app.
|
|
6912
|
+
*
|
|
6913
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6914
|
+
* @param {PublicKey} oappPda - The OApp PDA.
|
|
6915
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
6916
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
6917
|
+
* @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean } | null>} A promise that resolves to the configured send library or null if not found.
|
|
6644
6918
|
*/
|
|
6645
6919
|
async getSendLibrary(connection, oappPda, dstEid, commitmentOrConfig = "confirmed") {
|
|
6646
6920
|
const [sendLibConfig] = this.deriver.sendLibraryConfig(oappPda, dstEid);
|
|
@@ -6673,7 +6947,13 @@ var Endpoint = class {
|
|
|
6673
6947
|
}
|
|
6674
6948
|
}
|
|
6675
6949
|
/**
|
|
6676
|
-
*
|
|
6950
|
+
* Gets the configured receive library for the app.
|
|
6951
|
+
*
|
|
6952
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
6953
|
+
* @param {PublicKey} oappPda - The OApp PDA.
|
|
6954
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
6955
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
6956
|
+
* @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean; timeout: { msgLib: PublicKey; expiry: bigint } | null } | null>} A promise that resolves to the configured receive library or null if not found.
|
|
6677
6957
|
*/
|
|
6678
6958
|
async getReceiveLibrary(connection, oappPda, srcEid, commitmentOrConfig) {
|
|
6679
6959
|
const [receiveLibConfig] = this.deriver.receiveLibraryConfig(oappPda, srcEid);
|
|
@@ -6709,7 +6989,7 @@ var Endpoint = class {
|
|
|
6709
6989
|
};
|
|
6710
6990
|
}
|
|
6711
6991
|
const messageLibInfo = await connection.getAccountInfo(info.messageLib, commitmentOrConfig);
|
|
6712
|
-
|
|
6992
|
+
invariant3(messageLibInfo, "messageLibInfo should not be null");
|
|
6713
6993
|
const { timeout } = info;
|
|
6714
6994
|
if (timeout) {
|
|
6715
6995
|
return {
|
|
@@ -6722,6 +7002,18 @@ var Endpoint = class {
|
|
|
6722
7002
|
return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null };
|
|
6723
7003
|
}
|
|
6724
7004
|
// rename to a more generic name
|
|
7005
|
+
/**
|
|
7006
|
+
* Gets the inbound payload hash.
|
|
7007
|
+
*
|
|
7008
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7009
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
7010
|
+
* @param {number} srcEid - The source endpoint ID.
|
|
7011
|
+
* @param {Uint8Array} sender - The sender address.
|
|
7012
|
+
* @param {number} nonce - The nonce.
|
|
7013
|
+
* @param {Uint8Array} _payloadHash - The payload hash.
|
|
7014
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7015
|
+
* @returns {Promise<PayloadHash | null>} A promise that resolves to the payload hash or null if not found.
|
|
7016
|
+
*/
|
|
6725
7017
|
async getInboundPayloadHash(connection, receiver, srcEid, sender, nonce, _payloadHash, commitmentOrConfig) {
|
|
6726
7018
|
const [payloadHashPDA] = this.deriver.payloadHash(receiver, srcEid, sender, nonce);
|
|
6727
7019
|
const accountInfo = await connection.getAccountInfo(payloadHashPDA, commitmentOrConfig);
|
|
@@ -6730,8 +7022,17 @@ var Endpoint = class {
|
|
|
6730
7022
|
}
|
|
6731
7023
|
return PayloadHash.fromAccountInfo(accountInfo, 0)[0];
|
|
6732
7024
|
}
|
|
7025
|
+
/**
|
|
7026
|
+
* Gets the composed message state.
|
|
7027
|
+
*
|
|
7028
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7029
|
+
* @param {PublicKey} from - The sender public key.
|
|
7030
|
+
* @param {types.SendComposeParams} params - The send compose parameters.
|
|
7031
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7032
|
+
* @returns {Promise<ComposeMessageState | null>} A promise that resolves to the composed message state or null if not found.
|
|
7033
|
+
*/
|
|
6733
7034
|
async getComposedMessageState(connection, from, params, commitmentOrConfig) {
|
|
6734
|
-
const message =
|
|
7035
|
+
const message = keccak_256(params.message);
|
|
6735
7036
|
const [composedMessagePDA] = this.deriver.composedMessage(
|
|
6736
7037
|
from,
|
|
6737
7038
|
Uint8Array.from(params.guid),
|
|
@@ -6745,6 +7046,16 @@ var Endpoint = class {
|
|
|
6745
7046
|
}
|
|
6746
7047
|
return ComposeMessageState.fromAccountInfo(accountInfo, 0)[0];
|
|
6747
7048
|
}
|
|
7049
|
+
/**
|
|
7050
|
+
* Gets the nonce.
|
|
7051
|
+
*
|
|
7052
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7053
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
7054
|
+
* @param {number} remoteEid - The remote endpoint ID.
|
|
7055
|
+
* @param {Uint8Array} remoteOappAddr - The remote OApp address.
|
|
7056
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7057
|
+
* @returns {Promise<accounts.Nonce | null>} A promise that resolves to the nonce or null if not found.
|
|
7058
|
+
*/
|
|
6748
7059
|
async getNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
|
|
6749
7060
|
const [nonce] = this.deriver.nonce(oappIDPDA2, remoteEid, remoteOappAddr);
|
|
6750
7061
|
try {
|
|
@@ -6753,6 +7064,16 @@ var Endpoint = class {
|
|
|
6753
7064
|
return null;
|
|
6754
7065
|
}
|
|
6755
7066
|
}
|
|
7067
|
+
/**
|
|
7068
|
+
* Gets the pending inbound nonce.
|
|
7069
|
+
*
|
|
7070
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7071
|
+
* @param {PublicKey} oappIDPDA - The OApp ID PDA.
|
|
7072
|
+
* @param {number} remoteEid - The remote endpoint ID.
|
|
7073
|
+
* @param {Uint8Array} remoteOappAddr - The remote OApp address.
|
|
7074
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
7075
|
+
* @returns {Promise<accounts.PendingInboundNonce | null>} A promise that resolves to the pending inbound nonce or null if not found.
|
|
7076
|
+
*/
|
|
6756
7077
|
async getPendingInboundNonce(connection, oappIDPDA2, remoteEid, remoteOappAddr, commitmentOrConfig) {
|
|
6757
7078
|
const [nonce] = this.deriver.pendingNonce(oappIDPDA2, remoteEid, remoteOappAddr);
|
|
6758
7079
|
try {
|
|
@@ -6761,12 +7082,30 @@ var Endpoint = class {
|
|
|
6761
7082
|
return null;
|
|
6762
7083
|
}
|
|
6763
7084
|
}
|
|
7085
|
+
/**
|
|
7086
|
+
* Gets the message library version.
|
|
7087
|
+
*
|
|
7088
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7089
|
+
* @param {PublicKey} payer - The payer public key.
|
|
7090
|
+
* @param {PublicKey} messageLibProgram - The message library program public key.
|
|
7091
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
7092
|
+
* @returns {Promise<Version | null>} A promise that resolves to the version or null if not found.
|
|
7093
|
+
*/
|
|
6764
7094
|
async getMessageLibVersion(connection, payer, messageLibProgram, commitment = "confirmed") {
|
|
6765
7095
|
const ix = simple_message_lib_exports.instructions.createVersionInstruction(messageLibProgram);
|
|
6766
7096
|
const simulateResp = await simulateTransaction(connection, [ix], messageLibProgram, payer, commitment);
|
|
6767
7097
|
const version = simple_message_lib_exports.types.versionBeet.read(simulateResp, 0);
|
|
6768
7098
|
return version;
|
|
6769
7099
|
}
|
|
7100
|
+
/**
|
|
7101
|
+
* Transfers the admin role to a new admin.
|
|
7102
|
+
*
|
|
7103
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
7104
|
+
* @param {PublicKey} admin - The current admin public key.
|
|
7105
|
+
* @param {PublicKey} newAdmin - The new admin public key.
|
|
7106
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
7107
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
7108
|
+
*/
|
|
6770
7109
|
async transferAdmin(connection, admin, newAdmin, commitment = "confirmed") {
|
|
6771
7110
|
const [settingPDA] = this.deriver.setting();
|
|
6772
7111
|
const endpointSettings = await EndpointSettings.fromAccountAddress(connection, settingPDA, commitment);
|
|
@@ -8713,10 +9052,27 @@ var PROGRAM_ID2 = new PublicKey(PROGRAM_ADDRESS2);
|
|
|
8713
9052
|
|
|
8714
9053
|
// src/simple-message-lib.ts
|
|
8715
9054
|
var SimpleMessageLib = class {
|
|
9055
|
+
/**
|
|
9056
|
+
* Creates an instance of the SimpleMessageLib class.
|
|
9057
|
+
*
|
|
9058
|
+
* @param {PublicKey} program - The program public key.
|
|
9059
|
+
*/
|
|
8716
9060
|
constructor(program) {
|
|
8717
9061
|
this.program = program;
|
|
8718
9062
|
this.deriver = new MessageLibPDADeriver(program);
|
|
8719
9063
|
}
|
|
9064
|
+
/**
|
|
9065
|
+
* Initializes the SimpleMessageLib.
|
|
9066
|
+
*
|
|
9067
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
9068
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9069
|
+
* @param {PublicKey} admin - The admin public key.
|
|
9070
|
+
* @param {number} eid - The endpoint ID.
|
|
9071
|
+
* @param {number} nativeFee - The native fee.
|
|
9072
|
+
* @param {number} [lzTokenFee=0] - The LayerZero token fee.
|
|
9073
|
+
*
|
|
9074
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
9075
|
+
*/
|
|
8720
9076
|
initSimpleMessageLib(endpointProgram, payer, admin, eid, nativeFee, lzTokenFee = 0) {
|
|
8721
9077
|
const [messageLibPda] = this.deriver.messageLib();
|
|
8722
9078
|
const [endpointAuth] = new EndpointPDADeriver(endpointProgram).messageLibraryInfo(messageLibPda);
|
|
@@ -8738,6 +9094,14 @@ var SimpleMessageLib = class {
|
|
|
8738
9094
|
this.program
|
|
8739
9095
|
);
|
|
8740
9096
|
}
|
|
9097
|
+
/**
|
|
9098
|
+
* Sets the whitelist caller.
|
|
9099
|
+
*
|
|
9100
|
+
* @param {PublicKey} admin - The admin public key.
|
|
9101
|
+
* @param {PublicKey} newCaller - The new caller public key.
|
|
9102
|
+
*
|
|
9103
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
9104
|
+
*/
|
|
8741
9105
|
setWhitelistCaller(admin, newCaller) {
|
|
8742
9106
|
const [messageLibPDA] = this.deriver.messageLib();
|
|
8743
9107
|
return createSetWlCallerInstruction(
|
|
@@ -8753,6 +9117,15 @@ var SimpleMessageLib = class {
|
|
|
8753
9117
|
this.program
|
|
8754
9118
|
);
|
|
8755
9119
|
}
|
|
9120
|
+
/**
|
|
9121
|
+
* Checks if a caller is whitelisted.
|
|
9122
|
+
*
|
|
9123
|
+
* @param {Connection} connection - The connection object.
|
|
9124
|
+
* @param {PublicKey} caller - The caller public key.
|
|
9125
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
9126
|
+
*
|
|
9127
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the caller is whitelisted, false otherwise.
|
|
9128
|
+
*/
|
|
8756
9129
|
async isWhiteListed(connection, caller, commitmentOrConfig) {
|
|
8757
9130
|
try {
|
|
8758
9131
|
const exceptedCaller = await this.getWhiteListCaller(connection, commitmentOrConfig);
|
|
@@ -8761,6 +9134,14 @@ var SimpleMessageLib = class {
|
|
|
8761
9134
|
return false;
|
|
8762
9135
|
}
|
|
8763
9136
|
}
|
|
9137
|
+
/**
|
|
9138
|
+
* Gets the whitelisted caller.
|
|
9139
|
+
*
|
|
9140
|
+
* @param {Connection} connection - The connection object.
|
|
9141
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
9142
|
+
*
|
|
9143
|
+
* @returns {Promise<PublicKey>} A promise that resolves to the whitelisted caller public key.
|
|
9144
|
+
*/
|
|
8764
9145
|
async getWhiteListCaller(connection, commitmentOrConfig) {
|
|
8765
9146
|
const [messageLibPDA] = this.deriver.messageLib();
|
|
8766
9147
|
const messageLibInfo = await MessageLib.fromAccountAddress(
|
|
@@ -8770,6 +9151,16 @@ var SimpleMessageLib = class {
|
|
|
8770
9151
|
);
|
|
8771
9152
|
return messageLibInfo.wlCaller;
|
|
8772
9153
|
}
|
|
9154
|
+
/**
|
|
9155
|
+
* Validates a packet.
|
|
9156
|
+
*
|
|
9157
|
+
* @param {Connection} _connection - The connection object.
|
|
9158
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
9159
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9160
|
+
* @param {Uint8Array} encodedPacket - The encoded packet.
|
|
9161
|
+
*
|
|
9162
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
9163
|
+
*/
|
|
8773
9164
|
validatePacket(_connection, endpointProgram, payer, encodedPacket) {
|
|
8774
9165
|
const packet = PacketV1Codec.fromBytes(encodedPacket);
|
|
8775
9166
|
const [receiveLibrary] = this.deriver.messageLib();
|
|
@@ -8786,8 +9177,14 @@ var SimpleMessageLib = class {
|
|
|
8786
9177
|
this.program
|
|
8787
9178
|
);
|
|
8788
9179
|
}
|
|
8789
|
-
|
|
8790
|
-
*
|
|
9180
|
+
/**
|
|
9181
|
+
* Gets the account meta of the send instruction for CPI (Cross-Program Invocation).
|
|
9182
|
+
*
|
|
9183
|
+
* @param {Connection} _connection - The connection object.
|
|
9184
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9185
|
+
* @param {PacketPath} _path - The packet path.
|
|
9186
|
+
*
|
|
9187
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
|
|
8791
9188
|
*/
|
|
8792
9189
|
async getSendIXAccountMetaForCPI(_connection, payer, _path) {
|
|
8793
9190
|
const [msgLib] = this.deriver.messageLib();
|
|
@@ -8807,6 +9204,16 @@ var SimpleMessageLib = class {
|
|
|
8807
9204
|
});
|
|
8808
9205
|
return Promise.resolve(cpiAccounts.slice(1));
|
|
8809
9206
|
}
|
|
9207
|
+
/**
|
|
9208
|
+
* Gets the account meta of the quote instruction for CPI (Cross-Program Invocation).
|
|
9209
|
+
*
|
|
9210
|
+
* @param {Connection} _connection - The connection object.
|
|
9211
|
+
* @param {PublicKey} _payer - The payer public key.
|
|
9212
|
+
* @param {PacketPath} _path - The packet path.
|
|
9213
|
+
* @param {Commitment} [commitment] - The commitment.
|
|
9214
|
+
*
|
|
9215
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
|
|
9216
|
+
*/
|
|
8810
9217
|
async getQuoteIXAccountMetaForCPI(_connection, _payer, _path, _commitment) {
|
|
8811
9218
|
const [msgLib] = this.deriver.messageLib();
|
|
8812
9219
|
const keys = createQuoteInstructionAccounts2(
|
|
@@ -8819,8 +9226,14 @@ var SimpleMessageLib = class {
|
|
|
8819
9226
|
);
|
|
8820
9227
|
return Promise.resolve(keys.slice(1));
|
|
8821
9228
|
}
|
|
8822
|
-
|
|
8823
|
-
*
|
|
9229
|
+
/**
|
|
9230
|
+
* Gets the account meta of the init config instruction for CPI (Cross-Program Invocation).
|
|
9231
|
+
*
|
|
9232
|
+
* @param {PublicKey} payer - The payer public key.
|
|
9233
|
+
* @param {PublicKey} oappID - The oapp ID public key.
|
|
9234
|
+
* @param {number} eid - The endpoint ID.
|
|
9235
|
+
*
|
|
9236
|
+
* @returns {AccountMeta[]} An array of account meta.
|
|
8824
9237
|
*/
|
|
8825
9238
|
getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
|
|
8826
9239
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
@@ -8844,6 +9257,15 @@ var SimpleMessageLib = class {
|
|
|
8844
9257
|
});
|
|
8845
9258
|
return keys.slice(1);
|
|
8846
9259
|
}
|
|
9260
|
+
/**
|
|
9261
|
+
* Gets the account meta of the set config instruction for CPI (Cross-Program Invocation).
|
|
9262
|
+
*
|
|
9263
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
9264
|
+
* @param {PublicKey} oappID - The oapp ID public key.
|
|
9265
|
+
* @param {number} eid - The endpoint ID.
|
|
9266
|
+
*
|
|
9267
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account meta.
|
|
9268
|
+
*/
|
|
8847
9269
|
async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
|
|
8848
9270
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
8849
9271
|
const [receiveConfig] = this.deriver.receiveConfig(eid, oappID);
|
|
@@ -10721,9 +11143,21 @@ var SolanaSignerExt = class _SolanaSignerExt {
|
|
|
10721
11143
|
constructor(signers) {
|
|
10722
11144
|
this.signers = signers;
|
|
10723
11145
|
}
|
|
11146
|
+
/**
|
|
11147
|
+
* Creates an instance of the SolanaSignerExt class.
|
|
11148
|
+
*
|
|
11149
|
+
* @param {HashSigner[]} signers - The signers.
|
|
11150
|
+
* @returns {SolanaSignerExt} The SolanaSignerExt instance.
|
|
11151
|
+
*/
|
|
10724
11152
|
static from(signers) {
|
|
10725
11153
|
return new _SolanaSignerExt(signers);
|
|
10726
11154
|
}
|
|
11155
|
+
/**
|
|
11156
|
+
* Signs a message.
|
|
11157
|
+
*
|
|
11158
|
+
* @param {Buffer} message - The message to sign.
|
|
11159
|
+
* @returns {Promise<{ signature: Uint8Array; recoveryId: number }[]>} A promise that resolves to an array of signature objects.
|
|
11160
|
+
*/
|
|
10727
11161
|
async sign(message) {
|
|
10728
11162
|
return Promise.all(
|
|
10729
11163
|
this.signers.map(async (s) => {
|
|
@@ -10734,12 +11168,27 @@ var SolanaSignerExt = class _SolanaSignerExt {
|
|
|
10734
11168
|
}
|
|
10735
11169
|
};
|
|
10736
11170
|
var DVN = class {
|
|
11171
|
+
/**
|
|
11172
|
+
* Creates an instance of the DVN class.
|
|
11173
|
+
*
|
|
11174
|
+
* @param {PublicKey} programId - The program ID.
|
|
11175
|
+
* @param {EndpointId} [endpointId=EndpointId.SOLANA_V2_SANDBOX] - The endpoint ID.
|
|
11176
|
+
*/
|
|
10737
11177
|
constructor(programId, endpointId = EndpointId.SOLANA_V2_SANDBOX) {
|
|
10738
11178
|
this.programId = programId;
|
|
10739
11179
|
this.dvnDeriver = new DVNDeriver(programId);
|
|
10740
11180
|
this.vid = endpointId % 3e4;
|
|
10741
11181
|
this.eventAuthority = new EventPDADeriver(programId).eventAuthority()[0];
|
|
10742
11182
|
}
|
|
11183
|
+
/**
|
|
11184
|
+
* Initializes the DVN.
|
|
11185
|
+
*
|
|
11186
|
+
* @param {Connection} connection - The connection.
|
|
11187
|
+
* @param {PublicKey} payer - The payer.
|
|
11188
|
+
* @param {InitDvnParams} params - The initialization parameters.
|
|
11189
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
11190
|
+
* @throws {Error} If the DVN is already initialized.
|
|
11191
|
+
*/
|
|
10743
11192
|
async initDVN(connection, payer, params) {
|
|
10744
11193
|
const [config] = this.dvnDeriver.config();
|
|
10745
11194
|
const info = await connection.getAccountInfo(config);
|
|
@@ -10757,6 +11206,14 @@ var DVN = class {
|
|
|
10757
11206
|
this.programId
|
|
10758
11207
|
);
|
|
10759
11208
|
}
|
|
11209
|
+
/**
|
|
11210
|
+
* Gets the digest for a transaction.
|
|
11211
|
+
*
|
|
11212
|
+
* @param {number} vid - The validator ID.
|
|
11213
|
+
* @param {TransactionInstruction} instruction - The transaction instruction.
|
|
11214
|
+
* @param {number} expiration - The expiration time.
|
|
11215
|
+
* @returns {types.ExecuteTransactionDigest} The transaction digest.
|
|
11216
|
+
*/
|
|
10760
11217
|
getDigest(vid, instruction, expiration) {
|
|
10761
11218
|
return {
|
|
10762
11219
|
vid,
|
|
@@ -10772,15 +11229,39 @@ var DVN = class {
|
|
|
10772
11229
|
expiration
|
|
10773
11230
|
};
|
|
10774
11231
|
}
|
|
11232
|
+
/**
|
|
11233
|
+
* Gets the execute hash for a given hash bytes.
|
|
11234
|
+
*
|
|
11235
|
+
* @param {Buffer} hashBytes - The hash bytes.
|
|
11236
|
+
* @returns {PublicKey} The execute hash.
|
|
11237
|
+
*/
|
|
10775
11238
|
getExecuteHash(hashBytes) {
|
|
10776
11239
|
const [executeHash] = this.dvnDeriver.executeHash(hashBytes);
|
|
10777
11240
|
return executeHash;
|
|
10778
11241
|
}
|
|
11242
|
+
/**
|
|
11243
|
+
* Gets the hash bytes for a given digest.
|
|
11244
|
+
*
|
|
11245
|
+
* @param {types.ExecuteTransactionDigest} digest - The transaction digest.
|
|
11246
|
+
* @returns {Buffer} The hash bytes.
|
|
11247
|
+
*/
|
|
10779
11248
|
getHashBytes(digest) {
|
|
10780
11249
|
const [digestBytes] = executeTransactionDigestBeet.serialize(digest);
|
|
10781
|
-
const hash =
|
|
10782
|
-
return Buffer.from(hash
|
|
11250
|
+
const hash = keccak_256(digestBytes);
|
|
11251
|
+
return Buffer.from(hash);
|
|
10783
11252
|
}
|
|
11253
|
+
/**
|
|
11254
|
+
* Invokes a transaction.
|
|
11255
|
+
*
|
|
11256
|
+
* @param {Connection} connection - The connection.
|
|
11257
|
+
* @param {number} vid - The validator ID.
|
|
11258
|
+
* @param {PublicKey} payer - The payer.
|
|
11259
|
+
* @param {TransactionInstruction} instruction - The transaction instruction.
|
|
11260
|
+
* @param {number} expiration - The expiration time.
|
|
11261
|
+
* @param {SignFunc} sign - The sign function.
|
|
11262
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
11263
|
+
* @throws {Error} If the DVN is not initialized.
|
|
11264
|
+
*/
|
|
10784
11265
|
async invoke(connection, vid, payer, instruction, expiration, sign) {
|
|
10785
11266
|
const configState = await this.getConfigState(connection, "confirmed");
|
|
10786
11267
|
if (!configState) {
|
|
@@ -10822,6 +11303,12 @@ var DVN = class {
|
|
|
10822
11303
|
this.programId
|
|
10823
11304
|
);
|
|
10824
11305
|
}
|
|
11306
|
+
/**
|
|
11307
|
+
* Creates a transaction instruction to set the quorum.
|
|
11308
|
+
*
|
|
11309
|
+
* @param {number} quorum - The quorum.
|
|
11310
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11311
|
+
*/
|
|
10825
11312
|
createSetQuorumInstruction(quorum) {
|
|
10826
11313
|
const params = {
|
|
10827
11314
|
fields: [quorum],
|
|
@@ -10836,6 +11323,12 @@ var DVN = class {
|
|
|
10836
11323
|
data: buffer
|
|
10837
11324
|
});
|
|
10838
11325
|
}
|
|
11326
|
+
/**
|
|
11327
|
+
* Creates a transaction instruction to set the admins.
|
|
11328
|
+
*
|
|
11329
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
11330
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11331
|
+
*/
|
|
10839
11332
|
createSetAdminsInstruction(admins) {
|
|
10840
11333
|
const params = {
|
|
10841
11334
|
fields: [admins],
|
|
@@ -10850,6 +11343,12 @@ var DVN = class {
|
|
|
10850
11343
|
data: buffer
|
|
10851
11344
|
});
|
|
10852
11345
|
}
|
|
11346
|
+
/**
|
|
11347
|
+
* Creates a transaction instruction to set the signers.
|
|
11348
|
+
*
|
|
11349
|
+
* @param {Uint8Array[]} signers - The signer public keys.
|
|
11350
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11351
|
+
*/
|
|
10853
11352
|
createSetSignersInstruction(signers) {
|
|
10854
11353
|
const params = {
|
|
10855
11354
|
fields: [signers.map((s) => Array.from(s))],
|
|
@@ -10864,6 +11363,12 @@ var DVN = class {
|
|
|
10864
11363
|
data: buffer
|
|
10865
11364
|
});
|
|
10866
11365
|
}
|
|
11366
|
+
/**
|
|
11367
|
+
* Creates a transaction instruction to set the allowlist.
|
|
11368
|
+
*
|
|
11369
|
+
* @param {PublicKey[]} allowlist - The allowlist public keys.
|
|
11370
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11371
|
+
*/
|
|
10867
11372
|
createSetAllowlistInstruction(allowlist) {
|
|
10868
11373
|
const params = {
|
|
10869
11374
|
fields: [allowlist],
|
|
@@ -10878,6 +11383,12 @@ var DVN = class {
|
|
|
10878
11383
|
data: buffer
|
|
10879
11384
|
});
|
|
10880
11385
|
}
|
|
11386
|
+
/**
|
|
11387
|
+
* Creates a transaction instruction to set the denylist.
|
|
11388
|
+
*
|
|
11389
|
+
* @param {PublicKey[]} denylist - The denylist public keys.
|
|
11390
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11391
|
+
*/
|
|
10881
11392
|
createSetDenylistInstruction(denylist) {
|
|
10882
11393
|
const params = {
|
|
10883
11394
|
fields: [denylist],
|
|
@@ -10892,6 +11403,12 @@ var DVN = class {
|
|
|
10892
11403
|
data: buffer
|
|
10893
11404
|
});
|
|
10894
11405
|
}
|
|
11406
|
+
/**
|
|
11407
|
+
* Creates a transaction instruction to set the pause state.
|
|
11408
|
+
*
|
|
11409
|
+
* @param {boolean} pause - The pause state.
|
|
11410
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11411
|
+
*/
|
|
10895
11412
|
createSetPauseInstruction(pause) {
|
|
10896
11413
|
const params = {
|
|
10897
11414
|
fields: [pause],
|
|
@@ -10906,6 +11423,13 @@ var DVN = class {
|
|
|
10906
11423
|
data: buffer
|
|
10907
11424
|
});
|
|
10908
11425
|
}
|
|
11426
|
+
/**
|
|
11427
|
+
* Creates a transaction instruction to set the default multiplier basis points.
|
|
11428
|
+
*
|
|
11429
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11430
|
+
* @param {number} defaultMultiplierBps - The default multiplier basis points.
|
|
11431
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11432
|
+
*/
|
|
10909
11433
|
createSetDefaultMultiplierBpsInstruction(admin, defaultMultiplierBps) {
|
|
10910
11434
|
const [configAccount] = this.dvnDeriver.config();
|
|
10911
11435
|
return createSetConfigInstruction3(
|
|
@@ -10926,6 +11450,13 @@ var DVN = class {
|
|
|
10926
11450
|
this.programId
|
|
10927
11451
|
);
|
|
10928
11452
|
}
|
|
11453
|
+
/**
|
|
11454
|
+
* Creates a transaction instruction to change the admins.
|
|
11455
|
+
*
|
|
11456
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11457
|
+
* @param {PublicKey[]} admins - The new admin public keys.
|
|
11458
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11459
|
+
*/
|
|
10929
11460
|
createChangeAdminsInstruction(admin, admins) {
|
|
10930
11461
|
const [configAccount] = this.dvnDeriver.config();
|
|
10931
11462
|
return createSetConfigInstruction3(
|
|
@@ -10946,6 +11477,13 @@ var DVN = class {
|
|
|
10946
11477
|
this.programId
|
|
10947
11478
|
);
|
|
10948
11479
|
}
|
|
11480
|
+
/**
|
|
11481
|
+
* Creates a transaction instruction to set the destination configurations.
|
|
11482
|
+
*
|
|
11483
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11484
|
+
* @param {types.DstConfig[]} dstConfigs - The destination configurations.
|
|
11485
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11486
|
+
*/
|
|
10949
11487
|
createSetDstConfigInstruction(admin, dstConfigs) {
|
|
10950
11488
|
const [configAccount] = this.dvnDeriver.config();
|
|
10951
11489
|
return createSetConfigInstruction3(
|
|
@@ -10966,6 +11504,13 @@ var DVN = class {
|
|
|
10966
11504
|
this.programId
|
|
10967
11505
|
);
|
|
10968
11506
|
}
|
|
11507
|
+
/**
|
|
11508
|
+
* Creates a transaction instruction to remove the destination configurations.
|
|
11509
|
+
*
|
|
11510
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11511
|
+
* @param {number[]} removeEids - The endpoint IDs to remove.
|
|
11512
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11513
|
+
*/
|
|
10969
11514
|
createRemoveDstConfigInstruction(admin, removeEids) {
|
|
10970
11515
|
const [configAccount] = this.dvnDeriver.config();
|
|
10971
11516
|
return createSetConfigInstruction3(
|
|
@@ -10986,6 +11531,12 @@ var DVN = class {
|
|
|
10986
11531
|
this.programId
|
|
10987
11532
|
);
|
|
10988
11533
|
}
|
|
11534
|
+
/**
|
|
11535
|
+
* Creates a transaction instruction to set the message libraries.
|
|
11536
|
+
*
|
|
11537
|
+
* @param {PublicKey[]} msglibPrograms - The message library public keys.
|
|
11538
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11539
|
+
*/
|
|
10989
11540
|
createSetMsgLibsInstruction(msglibPrograms) {
|
|
10990
11541
|
const params = {
|
|
10991
11542
|
fields: [msglibPrograms],
|
|
@@ -11000,13 +11551,34 @@ var DVN = class {
|
|
|
11000
11551
|
data: buffer
|
|
11001
11552
|
});
|
|
11002
11553
|
}
|
|
11554
|
+
/**
|
|
11555
|
+
* Gets the expiration time.
|
|
11556
|
+
*
|
|
11557
|
+
* @returns {number} The expiration time.
|
|
11558
|
+
*/
|
|
11003
11559
|
_getExpiration() {
|
|
11004
11560
|
return (/* @__PURE__ */ new Date()).getTime() / 1e3 + 120;
|
|
11005
11561
|
}
|
|
11562
|
+
/**
|
|
11563
|
+
* Sets the message libraries.
|
|
11564
|
+
*
|
|
11565
|
+
* @param {Connection} connection - The connection.
|
|
11566
|
+
* @param {PublicKey} payer - The payer.
|
|
11567
|
+
* @param {PublicKey[]} msgLibs - The message library public keys.
|
|
11568
|
+
* @param {SignFunc} sign - The sign function.
|
|
11569
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
11570
|
+
*/
|
|
11006
11571
|
async setMsgLibs(connection, payer, msgLibs, sign) {
|
|
11007
11572
|
const expiration = this._getExpiration();
|
|
11008
11573
|
return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign);
|
|
11009
11574
|
}
|
|
11575
|
+
/**
|
|
11576
|
+
* Creates a transaction instruction to set the price feed.
|
|
11577
|
+
*
|
|
11578
|
+
* @param {PublicKey} admin - The admin public key.
|
|
11579
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
11580
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
11581
|
+
*/
|
|
11010
11582
|
createSetPriceFeedInstruction(admin, priceFeedProgram) {
|
|
11011
11583
|
const [configAccount] = this.dvnDeriver.config();
|
|
11012
11584
|
const [priceFeedPda] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
|
|
@@ -11028,6 +11600,14 @@ var DVN = class {
|
|
|
11028
11600
|
this.programId
|
|
11029
11601
|
);
|
|
11030
11602
|
}
|
|
11603
|
+
/**
|
|
11604
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
11605
|
+
*
|
|
11606
|
+
* @param {PublicKey} priceFeedConfig - The price feed configuration public key.
|
|
11607
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
11608
|
+
* @param {boolean} payment - Indicates if payment is required.
|
|
11609
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
11610
|
+
*/
|
|
11031
11611
|
getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
|
|
11032
11612
|
const [config] = this.dvnDeriver.config();
|
|
11033
11613
|
const keys = createQuoteDvnInstructionAccounts(
|
|
@@ -11049,6 +11629,13 @@ var DVN = class {
|
|
|
11049
11629
|
}
|
|
11050
11630
|
].concat(keys);
|
|
11051
11631
|
}
|
|
11632
|
+
/**
|
|
11633
|
+
* Gets the configuration state.
|
|
11634
|
+
*
|
|
11635
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
11636
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
11637
|
+
* @returns {Promise<accounts.DvnConfig | null>} A promise that resolves to the configuration state or null if not found.
|
|
11638
|
+
*/
|
|
11052
11639
|
async getConfigState(connection, commitment = "confirmed") {
|
|
11053
11640
|
const [config] = this.dvnDeriver.config();
|
|
11054
11641
|
try {
|
|
@@ -12620,8 +13207,8 @@ var treasurySetEventBeet = new beet159.FixableBeetArgsStruct(
|
|
|
12620
13207
|
function getEventDiscriminator(event) {
|
|
12621
13208
|
const hash = crypto.createHash("sha256");
|
|
12622
13209
|
hash.update(`event:${event}`);
|
|
12623
|
-
const
|
|
12624
|
-
return
|
|
13210
|
+
const sha256 = hash.digest("hex");
|
|
13211
|
+
return sha256.slice(0, 16);
|
|
12625
13212
|
}
|
|
12626
13213
|
async function extractSentPacketEventByTxHash(connection, program, signature, commitment, unsafeParseErr = false) {
|
|
12627
13214
|
const events = await extractEventFromTransactionSignature(
|
|
@@ -12851,7 +13438,7 @@ async function buildVersionedTransaction(connection, payerKey, instructions, com
|
|
|
12851
13438
|
);
|
|
12852
13439
|
}
|
|
12853
13440
|
function instructionDiscriminator(method) {
|
|
12854
|
-
return Buffer.from(
|
|
13441
|
+
return Buffer.from(sha2_256(Buffer.from(`global:${method}`))).subarray(0, 8);
|
|
12855
13442
|
}
|
|
12856
13443
|
async function simulateTransaction(connection, instructions, programId, payer, commitment = "confirmed", blockhash, lookupTableAddress) {
|
|
12857
13444
|
const tx = await buildVersionedTransaction(
|
|
@@ -13292,11 +13879,28 @@ var PROGRAM_ID4 = new PublicKey(PROGRAM_ADDRESS4);
|
|
|
13292
13879
|
|
|
13293
13880
|
// src/executor.ts
|
|
13294
13881
|
var Executor = class {
|
|
13882
|
+
/**
|
|
13883
|
+
* Creates an instance of the Executor class.
|
|
13884
|
+
*
|
|
13885
|
+
* @param {PublicKey} program - The program public key.
|
|
13886
|
+
*/
|
|
13295
13887
|
constructor(program) {
|
|
13296
13888
|
this.program = program;
|
|
13297
13889
|
this.deriver = new ExecutorPDADeriver(this.program);
|
|
13298
13890
|
}
|
|
13299
13891
|
// owner methods
|
|
13892
|
+
/**
|
|
13893
|
+
* Initializes the executor.
|
|
13894
|
+
*
|
|
13895
|
+
* @param {PublicKey} payer - The payer public key.
|
|
13896
|
+
* @param {PublicKey} owner - The owner public key.
|
|
13897
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
13898
|
+
* @param {PublicKey[]} executors - The executor public keys.
|
|
13899
|
+
* @param {PublicKey[]} msglibs - The message library public keys.
|
|
13900
|
+
* @param {PublicKey} priceFeed - The price feed public key.
|
|
13901
|
+
*
|
|
13902
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13903
|
+
*/
|
|
13300
13904
|
initExecutor(payer, owner, admins, executors, msglibs, priceFeed) {
|
|
13301
13905
|
const [configAccount] = this.deriver.config();
|
|
13302
13906
|
return createInitExecutorInstruction(
|
|
@@ -13316,6 +13920,14 @@ var Executor = class {
|
|
|
13316
13920
|
this.program
|
|
13317
13921
|
);
|
|
13318
13922
|
}
|
|
13923
|
+
/**
|
|
13924
|
+
* Sets the owner.
|
|
13925
|
+
*
|
|
13926
|
+
* @param {PublicKey} owner - The current owner public key.
|
|
13927
|
+
* @param {PublicKey} newOwner - The new owner public key.
|
|
13928
|
+
*
|
|
13929
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13930
|
+
*/
|
|
13319
13931
|
setOwner(owner, newOwner) {
|
|
13320
13932
|
const [configAccount] = this.deriver.config();
|
|
13321
13933
|
return createOwnerSetConfigInstruction(
|
|
@@ -13332,6 +13944,14 @@ var Executor = class {
|
|
|
13332
13944
|
this.program
|
|
13333
13945
|
);
|
|
13334
13946
|
}
|
|
13947
|
+
/**
|
|
13948
|
+
* Sets the admins.
|
|
13949
|
+
*
|
|
13950
|
+
* @param {PublicKey} owner - The owner public key.
|
|
13951
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
13952
|
+
*
|
|
13953
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13954
|
+
*/
|
|
13335
13955
|
setAdmins(owner, admins) {
|
|
13336
13956
|
const [configAccount] = this.deriver.config();
|
|
13337
13957
|
return createOwnerSetConfigInstruction(
|
|
@@ -13348,6 +13968,14 @@ var Executor = class {
|
|
|
13348
13968
|
this.program
|
|
13349
13969
|
);
|
|
13350
13970
|
}
|
|
13971
|
+
/**
|
|
13972
|
+
* Sets the allow list.
|
|
13973
|
+
*
|
|
13974
|
+
* @param {PublicKey} owner - The owner public key.
|
|
13975
|
+
* @param {PublicKey[]} allowlist - The allow list public keys.
|
|
13976
|
+
*
|
|
13977
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
13978
|
+
*/
|
|
13351
13979
|
setAllowList(owner, allowlist) {
|
|
13352
13980
|
const [configAccount] = this.deriver.config();
|
|
13353
13981
|
return createOwnerSetConfigInstruction(
|
|
@@ -13364,6 +13992,14 @@ var Executor = class {
|
|
|
13364
13992
|
this.program
|
|
13365
13993
|
);
|
|
13366
13994
|
}
|
|
13995
|
+
/**
|
|
13996
|
+
* Sets the deny list.
|
|
13997
|
+
*
|
|
13998
|
+
* @param {PublicKey} owner - The owner public key.
|
|
13999
|
+
* @param {PublicKey[]} denylist - The deny list public keys.
|
|
14000
|
+
*
|
|
14001
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14002
|
+
*/
|
|
13367
14003
|
setDenyList(owner, denylist) {
|
|
13368
14004
|
const [configAccount] = this.deriver.config();
|
|
13369
14005
|
return createOwnerSetConfigInstruction(
|
|
@@ -13380,6 +14016,14 @@ var Executor = class {
|
|
|
13380
14016
|
this.program
|
|
13381
14017
|
);
|
|
13382
14018
|
}
|
|
14019
|
+
/**
|
|
14020
|
+
* Sets the paused state.
|
|
14021
|
+
*
|
|
14022
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14023
|
+
* @param {boolean} paused - The paused state.
|
|
14024
|
+
*
|
|
14025
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14026
|
+
*/
|
|
13383
14027
|
setPaused(owner, paused) {
|
|
13384
14028
|
const [configAccount] = this.deriver.config();
|
|
13385
14029
|
return createOwnerSetConfigInstruction(
|
|
@@ -13396,6 +14040,14 @@ var Executor = class {
|
|
|
13396
14040
|
this.program
|
|
13397
14041
|
);
|
|
13398
14042
|
}
|
|
14043
|
+
/**
|
|
14044
|
+
* Sets the executors.
|
|
14045
|
+
*
|
|
14046
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14047
|
+
* @param {PublicKey[]} executors - The executor public keys.
|
|
14048
|
+
*
|
|
14049
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14050
|
+
*/
|
|
13399
14051
|
setExecutors(owner, executors) {
|
|
13400
14052
|
const [configAccount] = this.deriver.config();
|
|
13401
14053
|
return createOwnerSetConfigInstruction(
|
|
@@ -13412,6 +14064,14 @@ var Executor = class {
|
|
|
13412
14064
|
this.program
|
|
13413
14065
|
);
|
|
13414
14066
|
}
|
|
14067
|
+
/**
|
|
14068
|
+
* Sets the message libraries by programs.
|
|
14069
|
+
*
|
|
14070
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14071
|
+
* @param {PublicKey[]} msglibPrograms - The message library program public keys.
|
|
14072
|
+
*
|
|
14073
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14074
|
+
*/
|
|
13415
14075
|
setMsglibByPrograms(owner, msglibPrograms) {
|
|
13416
14076
|
this.deriver.config();
|
|
13417
14077
|
const msglibPdas = msglibPrograms.map((program) => {
|
|
@@ -13419,6 +14079,14 @@ var Executor = class {
|
|
|
13419
14079
|
});
|
|
13420
14080
|
return this.setMsglibByPDAs(owner, msglibPdas);
|
|
13421
14081
|
}
|
|
14082
|
+
/**
|
|
14083
|
+
* Sets the message libraries by PDAs.
|
|
14084
|
+
*
|
|
14085
|
+
* @param {PublicKey} owner - The owner public key.
|
|
14086
|
+
* @param {PublicKey[]} msglibPDAs - The message library PDA public keys.
|
|
14087
|
+
*
|
|
14088
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14089
|
+
*/
|
|
13422
14090
|
setMsglibByPDAs(owner, msglibPDAs) {
|
|
13423
14091
|
const [configAccount] = this.deriver.config();
|
|
13424
14092
|
return createOwnerSetConfigInstruction(
|
|
@@ -13436,6 +14104,14 @@ var Executor = class {
|
|
|
13436
14104
|
);
|
|
13437
14105
|
}
|
|
13438
14106
|
// admin methods
|
|
14107
|
+
/**
|
|
14108
|
+
* Sets the default multiplier BPS.
|
|
14109
|
+
*
|
|
14110
|
+
* @param {PublicKey} admin - The admin public key.
|
|
14111
|
+
* @param {number} defaultMultiplierBps - The default multiplier BPS.
|
|
14112
|
+
*
|
|
14113
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14114
|
+
*/
|
|
13439
14115
|
setDefaultMultiplierBps(admin, defaultMultiplierBps) {
|
|
13440
14116
|
const [configAccount] = this.deriver.config();
|
|
13441
14117
|
return createAdminSetConfigInstruction(
|
|
@@ -13452,6 +14128,14 @@ var Executor = class {
|
|
|
13452
14128
|
this.program
|
|
13453
14129
|
);
|
|
13454
14130
|
}
|
|
14131
|
+
/**
|
|
14132
|
+
* Sets the destination configurations.
|
|
14133
|
+
*
|
|
14134
|
+
* @param {PublicKey} admin - The admin public key.
|
|
14135
|
+
* @param {types.DstConfig[]} dstConfigs - The destination configurations.
|
|
14136
|
+
*
|
|
14137
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14138
|
+
*/
|
|
13455
14139
|
setDstConfig(admin, dstConfigs) {
|
|
13456
14140
|
const [configAccount] = this.deriver.config();
|
|
13457
14141
|
return createAdminSetConfigInstruction(
|
|
@@ -13468,6 +14152,14 @@ var Executor = class {
|
|
|
13468
14152
|
this.program
|
|
13469
14153
|
);
|
|
13470
14154
|
}
|
|
14155
|
+
/**
|
|
14156
|
+
* Sets the price feed.
|
|
14157
|
+
*
|
|
14158
|
+
* @param {PublicKey} admin - The admin public key.
|
|
14159
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
14160
|
+
*
|
|
14161
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
14162
|
+
*/
|
|
13471
14163
|
setPriceFeed(admin, priceFeedProgram) {
|
|
13472
14164
|
const [configAccount] = this.deriver.config();
|
|
13473
14165
|
const [priceFeed] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed();
|
|
@@ -13485,6 +14177,14 @@ var Executor = class {
|
|
|
13485
14177
|
this.program
|
|
13486
14178
|
);
|
|
13487
14179
|
}
|
|
14180
|
+
/**
|
|
14181
|
+
* Gets the executor configuration.
|
|
14182
|
+
*
|
|
14183
|
+
* @param {Connection} connection - The connection.
|
|
14184
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or configuration.
|
|
14185
|
+
*
|
|
14186
|
+
* @returns {Promise<accounts.ExecutorConfig | null>} A promise that resolves to the executor configuration or null.
|
|
14187
|
+
*/
|
|
13488
14188
|
async getExecutorConfig(connection, commitmentOrConfig) {
|
|
13489
14189
|
const [configAccount] = this.deriver.config();
|
|
13490
14190
|
try {
|
|
@@ -13498,6 +14198,15 @@ var Executor = class {
|
|
|
13498
14198
|
return null;
|
|
13499
14199
|
}
|
|
13500
14200
|
}
|
|
14201
|
+
/**
|
|
14202
|
+
* Gets the quote instruction account meta for CPI.
|
|
14203
|
+
*
|
|
14204
|
+
* @param {PublicKey} priceFeedConfig - The price feed configuration public key.
|
|
14205
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
14206
|
+
* @param {boolean} payment - Whether payment is required.
|
|
14207
|
+
*
|
|
14208
|
+
* @returns {AccountMeta[]} The account meta array.
|
|
14209
|
+
*/
|
|
13501
14210
|
getQuoteIXAccountMetaForCPI(priceFeedConfig, priceFeedProgram, payment) {
|
|
13502
14211
|
const [config] = this.deriver.config();
|
|
13503
14212
|
const ixAccounts = createQuoteExecutorInstructionAccounts(
|
|
@@ -13519,6 +14228,20 @@ var Executor = class {
|
|
|
13519
14228
|
}
|
|
13520
14229
|
].concat(ixAccounts);
|
|
13521
14230
|
}
|
|
14231
|
+
/**
|
|
14232
|
+
* Executes a transaction.
|
|
14233
|
+
*
|
|
14234
|
+
* @param {Connection} connection - The connection.
|
|
14235
|
+
* @param {PublicKey} executor - The executor public key.
|
|
14236
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
14237
|
+
* @param {Packet} packet - The packet.
|
|
14238
|
+
* @param {Uint8Array} extraData - The extra data.
|
|
14239
|
+
* @param {BN} [value] - The value.
|
|
14240
|
+
* @param {number} [computeUnits] - The compute units.
|
|
14241
|
+
* @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
|
|
14242
|
+
*
|
|
14243
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
14244
|
+
*/
|
|
13522
14245
|
async execute(connection, executor, endpointProgram, packet, extraData, value = new BN(0), computeUnits = 2e5, commitmentOrConfig) {
|
|
13523
14246
|
const [config] = this.deriver.config();
|
|
13524
14247
|
const endpointEventDeriver = new EventPDADeriver(endpointProgram);
|
|
@@ -13578,6 +14301,20 @@ var Executor = class {
|
|
|
13578
14301
|
this.program
|
|
13579
14302
|
);
|
|
13580
14303
|
}
|
|
14304
|
+
/**
|
|
14305
|
+
* Composes a transaction.
|
|
14306
|
+
*
|
|
14307
|
+
* @param {Connection} connection - The connection.
|
|
14308
|
+
* @param {PublicKey} executor - The executor public key.
|
|
14309
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
14310
|
+
* @param {ComposeSentEvent} event - The compose sent event.
|
|
14311
|
+
* @param {Uint8Array} extraData - The extra data.
|
|
14312
|
+
* @param {BN} [value] - The value.
|
|
14313
|
+
* @param {number} [computeUnits] - The compute units.
|
|
14314
|
+
* @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
|
|
14315
|
+
*
|
|
14316
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
14317
|
+
*/
|
|
13581
14318
|
async compose(connection, executor, endpointProgram, event, extraData, value = new BN(0), computeUnits = 4e5, commitmentOrConfig) {
|
|
13582
14319
|
const [config] = this.deriver.config();
|
|
13583
14320
|
const endpointEventDeriver = new EventPDADeriver(endpointProgram);
|
|
@@ -16440,12 +17177,26 @@ var PROGRAM_ID5 = new PublicKey(PROGRAM_ADDRESS5);
|
|
|
16440
17177
|
|
|
16441
17178
|
// src/uln.ts
|
|
16442
17179
|
var Uln = class {
|
|
17180
|
+
/**
|
|
17181
|
+
* Creates an instance of the Uln class.
|
|
17182
|
+
*
|
|
17183
|
+
* @param {PublicKey} program - The program public key.
|
|
17184
|
+
*/
|
|
16443
17185
|
constructor(program) {
|
|
16444
17186
|
this.program = program;
|
|
16445
17187
|
this.deriver = new UlnPDADeriver(program);
|
|
16446
17188
|
const [eventAuthorityPDA] = new EventPDADeriver(program).eventAuthority();
|
|
16447
17189
|
this.eventAuthorityPDA = eventAuthorityPDA;
|
|
16448
17190
|
}
|
|
17191
|
+
/**
|
|
17192
|
+
* Initializes the ULN.
|
|
17193
|
+
*
|
|
17194
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17195
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17196
|
+
* @param {PublicKey} admin - The admin public key.
|
|
17197
|
+
* @param {number} eid - The endpoint ID.
|
|
17198
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
17199
|
+
*/
|
|
16449
17200
|
initUln(endpointProgram, payer, admin, eid) {
|
|
16450
17201
|
const [setting] = this.deriver.setting();
|
|
16451
17202
|
const [msgLib] = this.deriver.messageLib();
|
|
@@ -16467,7 +17218,17 @@ var Uln = class {
|
|
|
16467
17218
|
);
|
|
16468
17219
|
}
|
|
16469
17220
|
/**
|
|
17221
|
+
* Initializes or updates the default configuration.
|
|
16470
17222
|
* before calling this function, you should call initUln to initialize the uln
|
|
17223
|
+
*
|
|
17224
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17225
|
+
* @param {PublicKey} admin - The admin public key.
|
|
17226
|
+
* @param {number} eid - The endpoint ID.
|
|
17227
|
+
* @param {types.UlnConfig} sendUlnConfig - The send ULN configuration.
|
|
17228
|
+
* @param {types.UlnConfig} receiveUlnConfig - The receive ULN configuration.
|
|
17229
|
+
* @param {types.ExecutorConfig} executorConfig - The executor configuration.
|
|
17230
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17231
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
16471
17232
|
*/
|
|
16472
17233
|
async initOrUpdateDefaultConfig(connection, admin, eid, sendUlnConfig, receiveUlnConfig, executorConfig, commitmentOrConfig) {
|
|
16473
17234
|
const [setting] = this.deriver.setting();
|
|
@@ -16518,7 +17279,18 @@ var Uln = class {
|
|
|
16518
17279
|
}
|
|
16519
17280
|
// msg_lib -> msg_lib_program ->
|
|
16520
17281
|
/**
|
|
17282
|
+
* Sets the treasury.
|
|
16521
17283
|
* before calling this function, you should call initUln to initialize the uln
|
|
17284
|
+
*
|
|
17285
|
+
* @param {PublicKey} admin - The admin public key.
|
|
17286
|
+
* @param {object} treasury - The treasury object.
|
|
17287
|
+
* @param {PublicKey} treasury.admin - The treasury admin public key.
|
|
17288
|
+
* @param {PublicKey} treasury.nativeReceiver - The native receiver public key.
|
|
17289
|
+
* @param {number} treasury.nativeFeeBps - The native fee basis points.
|
|
17290
|
+
* @param {object} treasury.lzToken - The LZ token object.
|
|
17291
|
+
* @param {PublicKey} treasury.lzToken.receiver - The LZ token receiver public key.
|
|
17292
|
+
* @param {number} treasury.lzToken.fee - The LZ token fee.
|
|
17293
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
16522
17294
|
*/
|
|
16523
17295
|
async setTreasury(admin, treasury) {
|
|
16524
17296
|
const [setting] = this.deriver.setting();
|
|
@@ -16538,6 +17310,16 @@ var Uln = class {
|
|
|
16538
17310
|
);
|
|
16539
17311
|
return Promise.resolve(ix);
|
|
16540
17312
|
}
|
|
17313
|
+
/**
|
|
17314
|
+
* Transfers the admin role to a new admin.
|
|
17315
|
+
*
|
|
17316
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17317
|
+
* @param {PublicKey} admin - The current admin public key.
|
|
17318
|
+
* @param {PublicKey} newAdmin - The new admin public key.
|
|
17319
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17320
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
17321
|
+
* @throws {Error} If the ULN is not initialized.
|
|
17322
|
+
*/
|
|
16541
17323
|
async transferAdmin(connection, admin, newAdmin, commitmentOrConfig) {
|
|
16542
17324
|
const [setting] = this.deriver.setting();
|
|
16543
17325
|
const info = await connection.getAccountInfo(setting, commitmentOrConfig);
|
|
@@ -16560,15 +17342,13 @@ var Uln = class {
|
|
|
16560
17342
|
);
|
|
16561
17343
|
}
|
|
16562
17344
|
/**
|
|
17345
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
16563
17346
|
*
|
|
16564
|
-
* @param connection
|
|
16565
|
-
*
|
|
16566
|
-
* @param
|
|
16567
|
-
* @param
|
|
16568
|
-
* @
|
|
16569
|
-
* @param payInLzToken
|
|
16570
|
-
* @param commitment
|
|
16571
|
-
* @returns
|
|
17347
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17348
|
+
* @param {PublicKey} _payer - The payer public key.
|
|
17349
|
+
* @param {PacketPath} path - The packet path.
|
|
17350
|
+
* @param {Commitment} [commitment] - The commitment level.
|
|
17351
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
16572
17352
|
*/
|
|
16573
17353
|
async getQuoteIXAccountMetaForCPI(connection, _payer, path, commitment) {
|
|
16574
17354
|
const { sender: sender_, dstEid } = path;
|
|
@@ -16590,8 +17370,14 @@ var Uln = class {
|
|
|
16590
17370
|
);
|
|
16591
17371
|
return accounts.slice(1);
|
|
16592
17372
|
}
|
|
16593
|
-
|
|
16594
|
-
*
|
|
17373
|
+
/**
|
|
17374
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
|
|
17375
|
+
*
|
|
17376
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17377
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17378
|
+
* @param {PacketPath} path - The packet path.
|
|
17379
|
+
* @param {Commitment} [commitment='confirmed'] - The commitment level.
|
|
17380
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
16595
17381
|
*/
|
|
16596
17382
|
async getSendIXAccountMetaForCPI(connection, payer, path, commitment = "confirmed") {
|
|
16597
17383
|
const { sender: sender_, dstEid } = path;
|
|
@@ -16629,6 +17415,16 @@ var Uln = class {
|
|
|
16629
17415
|
return accounts.slice(1);
|
|
16630
17416
|
}
|
|
16631
17417
|
// 3 RPC requests
|
|
17418
|
+
/**
|
|
17419
|
+
* Gets the remaining accounts for the send instruction.
|
|
17420
|
+
*
|
|
17421
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17422
|
+
* @param {PublicKey} sender - The sender public key.
|
|
17423
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
17424
|
+
* @param {boolean} payment - Indicates if payment is required.
|
|
17425
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
17426
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
17427
|
+
*/
|
|
16632
17428
|
async getSendIxRemainingAccounts(connection, sender, dstEid, payment, commitment = "confirmed") {
|
|
16633
17429
|
const { executor, dvns } = await this.getWorkers(connection, sender, dstEid, commitment);
|
|
16634
17430
|
const priceFeeds = new Array();
|
|
@@ -16639,7 +17435,7 @@ var Uln = class {
|
|
|
16639
17435
|
});
|
|
16640
17436
|
const priceFeedInfos = await connection.getMultipleAccountsInfo(priceFeeds, commitment);
|
|
16641
17437
|
const priceFeedDict = priceFeedInfos.reduce((acc, info, i) => {
|
|
16642
|
-
|
|
17438
|
+
invariant3(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
|
|
16643
17439
|
acc.set(priceFeeds[i].toBase58(), info.owner);
|
|
16644
17440
|
return acc;
|
|
16645
17441
|
}, /* @__PURE__ */ new Map());
|
|
@@ -16659,9 +17455,15 @@ var Uln = class {
|
|
|
16659
17455
|
});
|
|
16660
17456
|
return executorAccounts.concat(dvnAccounts.flat());
|
|
16661
17457
|
}
|
|
16662
|
-
|
|
16663
|
-
*
|
|
17458
|
+
/**
|
|
17459
|
+
* Gets all workers (executor and DVN).
|
|
16664
17460
|
* 2 RPC requests
|
|
17461
|
+
*
|
|
17462
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17463
|
+
* @param {PublicKey} sender - The sender public key.
|
|
17464
|
+
* @param {number} eid - The endpoint ID.
|
|
17465
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
17466
|
+
* @returns {Promise<{ executor: { config: ExecutorAccounts.ExecutorConfig; owner: PublicKey }; dvns: { config: DvnAccounts.DvnConfig; owner: PublicKey }[] }>} A promise that resolves to an object containing the executor and DVN configurations.
|
|
16665
17467
|
*/
|
|
16666
17468
|
async getWorkers(connection, sender, eid, commitment = "confirmed") {
|
|
16667
17469
|
const [defaultSendConfig] = this.deriver.defaultSendConfig(eid);
|
|
@@ -16670,7 +17472,7 @@ var Uln = class {
|
|
|
16670
17472
|
[defaultSendConfig, sendConfig],
|
|
16671
17473
|
commitment
|
|
16672
17474
|
);
|
|
16673
|
-
|
|
17475
|
+
invariant3(defaultSendConfigBuf, "defaultSendConfig not initialized");
|
|
16674
17476
|
const [defaultSendConfigState] = SendConfig.fromAccountInfo(defaultSendConfigBuf);
|
|
16675
17477
|
let {
|
|
16676
17478
|
executor,
|
|
@@ -16695,14 +17497,14 @@ var Uln = class {
|
|
|
16695
17497
|
[executor.executor, ...dvns],
|
|
16696
17498
|
commitment
|
|
16697
17499
|
);
|
|
16698
|
-
|
|
17500
|
+
invariant3(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
|
|
16699
17501
|
return {
|
|
16700
17502
|
executor: {
|
|
16701
17503
|
config: accounts_exports4.ExecutorConfig.fromAccountInfo(executorBuf)[0],
|
|
16702
17504
|
owner: executorBuf.owner
|
|
16703
17505
|
},
|
|
16704
17506
|
dvns: dvnBuf.map((dvn, i) => {
|
|
16705
|
-
|
|
17507
|
+
invariant3(dvn, `dvn:${dvns[i].toBase58()} not initialized`);
|
|
16706
17508
|
return {
|
|
16707
17509
|
config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
|
|
16708
17510
|
owner: dvn.owner
|
|
@@ -16710,6 +17512,16 @@ var Uln = class {
|
|
|
16710
17512
|
})
|
|
16711
17513
|
};
|
|
16712
17514
|
}
|
|
17515
|
+
/**
|
|
17516
|
+
* Initializes the verification process.
|
|
17517
|
+
*
|
|
17518
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17519
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17520
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17521
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17522
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17523
|
+
* @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
|
|
17524
|
+
*/
|
|
16713
17525
|
async initVerify(connection, payer, dvn, packetBytes, commitmentOrConfig) {
|
|
16714
17526
|
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
16715
17527
|
const headerHash = packet.headerHash();
|
|
@@ -16736,6 +17548,14 @@ var Uln = class {
|
|
|
16736
17548
|
this.program
|
|
16737
17549
|
);
|
|
16738
17550
|
}
|
|
17551
|
+
/**
|
|
17552
|
+
* Verifies the packet.
|
|
17553
|
+
*
|
|
17554
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17555
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17556
|
+
* @param {number | string} confirmations - The number of confirmations.
|
|
17557
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
17558
|
+
*/
|
|
16739
17559
|
verify(dvn, packetBytes, confirmations) {
|
|
16740
17560
|
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
16741
17561
|
const headerHash = packet.headerHash();
|
|
@@ -16760,6 +17580,14 @@ var Uln = class {
|
|
|
16760
17580
|
this.program
|
|
16761
17581
|
);
|
|
16762
17582
|
}
|
|
17583
|
+
/**
|
|
17584
|
+
* Closes the verification process.
|
|
17585
|
+
*
|
|
17586
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17587
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
17588
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17589
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
17590
|
+
*/
|
|
16763
17591
|
closeVerify(dvn, receiver, packetBytes) {
|
|
16764
17592
|
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
16765
17593
|
const headerHash = packet.headerHash();
|
|
@@ -16782,6 +17610,16 @@ var Uln = class {
|
|
|
16782
17610
|
this.program
|
|
16783
17611
|
);
|
|
16784
17612
|
}
|
|
17613
|
+
/**
|
|
17614
|
+
* Checks if the DVN is verified.
|
|
17615
|
+
*
|
|
17616
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17617
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17618
|
+
* @param {PublicKey} dvn - The DVN public key.
|
|
17619
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17620
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
17621
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the DVN is verified, false otherwise.
|
|
17622
|
+
*/
|
|
16785
17623
|
async isDvnVerified(connection, endpointProgram, dvn, packetBytes, commitmentOrConfig = "confirmed") {
|
|
16786
17624
|
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
16787
17625
|
const headerHash = packet.headerHash();
|
|
@@ -16824,6 +17662,14 @@ var Uln = class {
|
|
|
16824
17662
|
return false;
|
|
16825
17663
|
}
|
|
16826
17664
|
}
|
|
17665
|
+
/**
|
|
17666
|
+
* Commits the verification process.
|
|
17667
|
+
*
|
|
17668
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17669
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17670
|
+
* @param {Uint8Array} packetBytes - The packet bytes.
|
|
17671
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
17672
|
+
*/
|
|
16827
17673
|
async commitVerification(connection, endpointProgram, packetBytes) {
|
|
16828
17674
|
const packet = PacketV1Codec.fromBytes(packetBytes);
|
|
16829
17675
|
const payloadHash = packet.payloadHash();
|
|
@@ -16863,8 +17709,13 @@ var Uln = class {
|
|
|
16863
17709
|
this.program
|
|
16864
17710
|
);
|
|
16865
17711
|
}
|
|
16866
|
-
|
|
16867
|
-
*
|
|
17712
|
+
/**
|
|
17713
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the init config instruction.
|
|
17714
|
+
*
|
|
17715
|
+
* @param {PublicKey} payer - The payer public key.
|
|
17716
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
17717
|
+
* @param {number} eid - The endpoint ID.
|
|
17718
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
16868
17719
|
*/
|
|
16869
17720
|
getInitConfigIXAccountMetaForCPI(payer, oappID, eid) {
|
|
16870
17721
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
@@ -16888,6 +17739,14 @@ var Uln = class {
|
|
|
16888
17739
|
});
|
|
16889
17740
|
return accounts.slice(1);
|
|
16890
17741
|
}
|
|
17742
|
+
/**
|
|
17743
|
+
* Constructs the set config data.
|
|
17744
|
+
*
|
|
17745
|
+
* @param {SetConfigType} configType - The configuration type.
|
|
17746
|
+
* @param {types.ExecutorConfig | types.UlnConfig} configData - The configuration data.
|
|
17747
|
+
* @returns {Uint8Array} The constructed set config data.
|
|
17748
|
+
* @throws {Error} If the configuration type is invalid.
|
|
17749
|
+
*/
|
|
16891
17750
|
static constructSetConfigData(configType, configData) {
|
|
16892
17751
|
switch (configType) {
|
|
16893
17752
|
case 1 /* EXECUTOR */: {
|
|
@@ -16904,8 +17763,12 @@ var Uln = class {
|
|
|
16904
17763
|
}
|
|
16905
17764
|
}
|
|
16906
17765
|
/**
|
|
16907
|
-
*
|
|
17766
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the set config instruction.
|
|
16908
17767
|
*
|
|
17768
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
17769
|
+
* @param {PublicKey} oappID - The OApp ID public key.
|
|
17770
|
+
* @param {number} eid - The endpoint ID.
|
|
17771
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
16909
17772
|
*/
|
|
16910
17773
|
async getSetConfigIXAccountMetaForCPI(endpointProgram, oappID, eid) {
|
|
16911
17774
|
const [sendConfig] = this.deriver.sendConfig(eid, oappID);
|
|
@@ -16932,6 +17795,13 @@ var Uln = class {
|
|
|
16932
17795
|
}
|
|
16933
17796
|
//
|
|
16934
17797
|
// all of below functions are retrieving accounts state
|
|
17798
|
+
/**
|
|
17799
|
+
* Gets the ULN settings.
|
|
17800
|
+
*
|
|
17801
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17802
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17803
|
+
* @returns {Promise<accounts.UlnSettings | null>} A promise that resolves to the ULN settings or null if not found.
|
|
17804
|
+
*/
|
|
16935
17805
|
async getSetting(connection, commitmentOrConfig) {
|
|
16936
17806
|
const [setting] = this.deriver.setting();
|
|
16937
17807
|
try {
|
|
@@ -16940,6 +17810,14 @@ var Uln = class {
|
|
|
16940
17810
|
return null;
|
|
16941
17811
|
}
|
|
16942
17812
|
}
|
|
17813
|
+
/**
|
|
17814
|
+
* Gets the default send configuration state.
|
|
17815
|
+
*
|
|
17816
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17817
|
+
* @param {number} eid - The endpoint ID.
|
|
17818
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17819
|
+
* @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the default send configuration state or null if not found.
|
|
17820
|
+
*/
|
|
16943
17821
|
async getDefaultSendConfigState(connection, eid, commitmentOrConfig) {
|
|
16944
17822
|
const [config] = this.deriver.defaultSendConfig(eid);
|
|
16945
17823
|
try {
|
|
@@ -16948,6 +17826,15 @@ var Uln = class {
|
|
|
16948
17826
|
return null;
|
|
16949
17827
|
}
|
|
16950
17828
|
}
|
|
17829
|
+
/**
|
|
17830
|
+
* Gets the send configuration state.
|
|
17831
|
+
*
|
|
17832
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17833
|
+
* @param {PublicKey} sender - The sender public key.
|
|
17834
|
+
* @param {number} eid - The endpoint ID.
|
|
17835
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17836
|
+
* @returns {Promise<accounts.SendConfig | null>} A promise that resolves to the send configuration state or null if not found.
|
|
17837
|
+
*/
|
|
16951
17838
|
async getSendConfigState(connection, sender, eid, commitmentOrConfig) {
|
|
16952
17839
|
const [config] = this.deriver.sendConfig(eid, sender);
|
|
16953
17840
|
try {
|
|
@@ -16956,6 +17843,14 @@ var Uln = class {
|
|
|
16956
17843
|
return null;
|
|
16957
17844
|
}
|
|
16958
17845
|
}
|
|
17846
|
+
/**
|
|
17847
|
+
* Gets the default receive configuration state.
|
|
17848
|
+
*
|
|
17849
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17850
|
+
* @param {number} eid - The endpoint ID.
|
|
17851
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17852
|
+
* @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the default receive configuration state or null if not found.
|
|
17853
|
+
*/
|
|
16959
17854
|
async getDefaultReceiveConfigState(connection, eid, commitmentOrConfig) {
|
|
16960
17855
|
const [config] = this.deriver.defaultReceiveConfig(eid);
|
|
16961
17856
|
try {
|
|
@@ -16964,6 +17859,15 @@ var Uln = class {
|
|
|
16964
17859
|
return null;
|
|
16965
17860
|
}
|
|
16966
17861
|
}
|
|
17862
|
+
/**
|
|
17863
|
+
* Gets the receive configuration state.
|
|
17864
|
+
*
|
|
17865
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17866
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
17867
|
+
* @param {number} eid - The endpoint ID.
|
|
17868
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
|
|
17869
|
+
* @returns {Promise<accounts.ReceiveConfig | null>} A promise that resolves to the receive configuration state or null if not found.
|
|
17870
|
+
*/
|
|
16967
17871
|
async getReceiveConfigState(connection, receiver, eid, commitmentOrConfig) {
|
|
16968
17872
|
const [config] = this.deriver.receiveConfig(eid, receiver);
|
|
16969
17873
|
try {
|
|
@@ -16972,6 +17876,16 @@ var Uln = class {
|
|
|
16972
17876
|
return null;
|
|
16973
17877
|
}
|
|
16974
17878
|
}
|
|
17879
|
+
/**
|
|
17880
|
+
* Gets the final receive configuration state.
|
|
17881
|
+
*
|
|
17882
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
17883
|
+
* @param {PublicKey} receiver - The receiver public key.
|
|
17884
|
+
* @param {number} eid - The endpoint ID.
|
|
17885
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
17886
|
+
* @returns {Promise<accounts.ReceiveConfig>} A promise that resolves to the final receive configuration state.
|
|
17887
|
+
* @throws {Error} If no DVN is found.
|
|
17888
|
+
*/
|
|
16975
17889
|
async getFinalReceiveConfigState(connection, receiver, eid, commitmentOrConfig = "confirmed") {
|
|
16976
17890
|
const NIL_CONFIRMATIONS = "18446744073709551615";
|
|
16977
17891
|
const NIL_DVN_COUNT = "255";
|
|
@@ -17803,10 +18717,26 @@ var PROGRAM_ID6 = new PublicKey(PROGRAM_ADDRESS6);
|
|
|
17803
18717
|
|
|
17804
18718
|
// src/pricefeed.ts
|
|
17805
18719
|
var PriceFeed2 = class {
|
|
18720
|
+
/**
|
|
18721
|
+
* Creates an instance of the PriceFeed class.
|
|
18722
|
+
*
|
|
18723
|
+
* @param {PublicKey} program - The public key of the program.
|
|
18724
|
+
*/
|
|
17806
18725
|
constructor(program) {
|
|
17807
18726
|
this.program = program;
|
|
17808
18727
|
this.deriver = new PriceFeedPDADeriver(this.program);
|
|
17809
18728
|
}
|
|
18729
|
+
/**
|
|
18730
|
+
* Initializes the price feed.
|
|
18731
|
+
*
|
|
18732
|
+
* @param {Connection} connection - The Solana connection object.
|
|
18733
|
+
* @param {PublicKey} payer - The public key of the payer.
|
|
18734
|
+
* @param {PublicKey} admin - The public key of the admin.
|
|
18735
|
+
* @param {PublicKey[]} updaters - The list of public keys of the updaters.
|
|
18736
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
|
|
18737
|
+
*
|
|
18738
|
+
* @returns {Promise<TransactionInstruction>} The transaction instruction.
|
|
18739
|
+
*/
|
|
17810
18740
|
async initPriceFeed(connection, payer, admin, updaters, commitmentOrConfig) {
|
|
17811
18741
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17812
18742
|
const info = await connection.getAccountInfo(priceFeed, commitmentOrConfig);
|
|
@@ -17827,6 +18757,16 @@ var PriceFeed2 = class {
|
|
|
17827
18757
|
this.program
|
|
17828
18758
|
);
|
|
17829
18759
|
}
|
|
18760
|
+
/**
|
|
18761
|
+
* Sets the price feed.
|
|
18762
|
+
*
|
|
18763
|
+
* @param {PublicKey} admin - The public key of the admin.
|
|
18764
|
+
* @param {PublicKey[]} updaters - The list of public keys of the updaters.
|
|
18765
|
+
* @param {bignum} priceRatioDenominator - The price ratio denominator.
|
|
18766
|
+
* @param {number} arbitrumCompressionPercent - The Arbitrum compression percentage.
|
|
18767
|
+
*
|
|
18768
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18769
|
+
*/
|
|
17830
18770
|
setPriceFeed(admin, updaters, priceRatioDenominator, arbitrumCompressionPercent) {
|
|
17831
18771
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17832
18772
|
return createSetPriceFeedInstruction(
|
|
@@ -17844,6 +18784,18 @@ var PriceFeed2 = class {
|
|
|
17844
18784
|
this.program
|
|
17845
18785
|
);
|
|
17846
18786
|
}
|
|
18787
|
+
/**
|
|
18788
|
+
* Sets the price.
|
|
18789
|
+
*
|
|
18790
|
+
* @param {PublicKey} updater - The public key of the updater.
|
|
18791
|
+
* @param {number} dstEid - The destination EID.
|
|
18792
|
+
* @param {bignum} priceRatio - The price ratio.
|
|
18793
|
+
* @param {bignum} gasPriceInUnit - The gas price in unit.
|
|
18794
|
+
* @param {number} gasPerByte - The gas per byte.
|
|
18795
|
+
* @param {types.ModelType | null} modelType - The model type.
|
|
18796
|
+
*
|
|
18797
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18798
|
+
*/
|
|
17847
18799
|
setPrice(updater, dstEid, priceRatio, gasPriceInUnit, gasPerByte, modelType) {
|
|
17848
18800
|
const EID_MODULUS = 3e4;
|
|
17849
18801
|
dstEid = dstEid % EID_MODULUS;
|
|
@@ -17867,6 +18819,14 @@ var PriceFeed2 = class {
|
|
|
17867
18819
|
this.program
|
|
17868
18820
|
);
|
|
17869
18821
|
}
|
|
18822
|
+
/**
|
|
18823
|
+
* Sets the SOL price.
|
|
18824
|
+
*
|
|
18825
|
+
* @param {PublicKey} updater - The public key of the updater.
|
|
18826
|
+
* @param {bignum | null} nativeTokenPriceUsd - The native token price in USD.
|
|
18827
|
+
*
|
|
18828
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18829
|
+
*/
|
|
17870
18830
|
setSolPrice(updater, nativeTokenPriceUsd) {
|
|
17871
18831
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17872
18832
|
return createSetSolPriceInstruction(
|
|
@@ -17882,6 +18842,14 @@ var PriceFeed2 = class {
|
|
|
17882
18842
|
this.program
|
|
17883
18843
|
);
|
|
17884
18844
|
}
|
|
18845
|
+
/**
|
|
18846
|
+
* Transfers the admin role.
|
|
18847
|
+
*
|
|
18848
|
+
* @param {PublicKey} admin - The public key of the current admin.
|
|
18849
|
+
* @param {PublicKey} newAdmin - The public key of the new admin.
|
|
18850
|
+
*
|
|
18851
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
18852
|
+
*/
|
|
17885
18853
|
transferAdmin(admin, newAdmin) {
|
|
17886
18854
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17887
18855
|
return createTransferAdminInstruction4(
|
|
@@ -17897,6 +18865,14 @@ var PriceFeed2 = class {
|
|
|
17897
18865
|
this.program
|
|
17898
18866
|
);
|
|
17899
18867
|
}
|
|
18868
|
+
/**
|
|
18869
|
+
* Retrieves the price feed account.
|
|
18870
|
+
*
|
|
18871
|
+
* @param {Connection} connection - The Solana connection object.
|
|
18872
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - Optional commitment or configuration.
|
|
18873
|
+
*
|
|
18874
|
+
* @returns {Promise<accounts.PriceFeed | null>} The price feed account or null if not found.
|
|
18875
|
+
*/
|
|
17900
18876
|
async getPriceFeed(connection, commitmentOrConfig) {
|
|
17901
18877
|
const [priceFeed] = this.deriver.priceFeed();
|
|
17902
18878
|
try {
|
|
@@ -17929,19 +18905,52 @@ function deriveLzComposeTypesAccountsPDA(program, oappId) {
|
|
|
17929
18905
|
return PublicKey.findProgramAddressSync([Buffer.from(LZ_COMPOSE_TYPES_SEED, "utf8")], program);
|
|
17930
18906
|
}
|
|
17931
18907
|
var BaseOApp = class {
|
|
18908
|
+
/**
|
|
18909
|
+
* Creates an instance of the BaseOApp class.
|
|
18910
|
+
*
|
|
18911
|
+
* @param {PublicKey} program - The program public key.
|
|
18912
|
+
*/
|
|
17932
18913
|
constructor(program) {
|
|
17933
18914
|
this.program = program;
|
|
17934
18915
|
this.oappBaseDeriver = new OAppBasePDADeriver(program);
|
|
17935
18916
|
}
|
|
18917
|
+
/**
|
|
18918
|
+
* Queries the ID PDA info.
|
|
18919
|
+
*
|
|
18920
|
+
* @param {Connection} connection - The connection.
|
|
18921
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
18922
|
+
* @returns {Promise<AccountInfo<Buffer> | null>} The account info.
|
|
18923
|
+
*/
|
|
17936
18924
|
async queryIDPDAInfo(connection, commitmentOrConfig) {
|
|
17937
18925
|
return this.queryPDAInfo(connection, this.idPDA()[0], commitmentOrConfig);
|
|
17938
18926
|
}
|
|
18927
|
+
/**
|
|
18928
|
+
* Queries the PDA info.
|
|
18929
|
+
*
|
|
18930
|
+
* @param {Connection} connection - The connection.
|
|
18931
|
+
* @param {PublicKey} pda - The PDA public key.
|
|
18932
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
18933
|
+
* @returns {Promise<AccountInfo<Buffer> | null>} The account info.
|
|
18934
|
+
*/
|
|
17939
18935
|
async queryPDAInfo(connection, pda, commitmentOrConfig) {
|
|
17940
18936
|
return connection.getAccountInfo(pda, commitmentOrConfig);
|
|
17941
18937
|
}
|
|
18938
|
+
/**
|
|
18939
|
+
* Gets the ID PDA.
|
|
18940
|
+
*
|
|
18941
|
+
* @returns {[PublicKey, number]} The ID PDA and bump.
|
|
18942
|
+
*/
|
|
17942
18943
|
idPDA() {
|
|
17943
18944
|
return oappIDPDA(this.program);
|
|
17944
18945
|
}
|
|
18946
|
+
/**
|
|
18947
|
+
* Gets the remote.
|
|
18948
|
+
*
|
|
18949
|
+
* @param {Connection} connection - The connection.
|
|
18950
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
18951
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or config.
|
|
18952
|
+
* @returns {Promise<Uint8Array | null>} The remote data.
|
|
18953
|
+
*/
|
|
17945
18954
|
async getRemote(connection, dstEid, commitmentOrConfig) {
|
|
17946
18955
|
const [remotePDA] = this.oappBaseDeriver.remote(dstEid);
|
|
17947
18956
|
const info = await this.queryPDAInfo(connection, remotePDA, commitmentOrConfig);
|
|
@@ -18043,6 +19052,13 @@ function createVersionInstructionAccounts3(programId) {
|
|
|
18043
19052
|
var PROGRAM_ADDRESS7 = "2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB";
|
|
18044
19053
|
var PROGRAM_ID7 = new PublicKey(PROGRAM_ADDRESS7);
|
|
18045
19054
|
var SendHelper = class {
|
|
19055
|
+
/**
|
|
19056
|
+
* Creates an instance of the SendHelper class.
|
|
19057
|
+
*
|
|
19058
|
+
* @param {PublicKey} [endpointProgram=EndpointProgram.PROGRAM_ID] - The endpoint program public key.
|
|
19059
|
+
* @param {PublicKey} [ulnProgram=UlnProgram.PROGRAM_ID] - The ULN program public key.
|
|
19060
|
+
* @param {PublicKey} [simpleMsgLibProgram=SimpleMessageLibProgram.PROGRAM_ID] - The simple message library program public key.
|
|
19061
|
+
*/
|
|
18046
19062
|
constructor(endpointProgram = endpoint_exports.PROGRAM_ID, ulnProgram = uln_exports.PROGRAM_ID, simpleMsgLibProgram = simple_message_lib_exports.PROGRAM_ID) {
|
|
18047
19063
|
this.endpointProgram = endpointProgram;
|
|
18048
19064
|
this.ulnProgram = ulnProgram;
|
|
@@ -18052,6 +19068,14 @@ var SendHelper = class {
|
|
|
18052
19068
|
this.uln = new uln_exports.Uln(ulnProgram);
|
|
18053
19069
|
this.simpleMsgLib = new simple_message_lib_exports.SimpleMessageLib(simpleMsgLibProgram);
|
|
18054
19070
|
}
|
|
19071
|
+
/**
|
|
19072
|
+
* Fetches multiple account information.
|
|
19073
|
+
*
|
|
19074
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19075
|
+
* @param {PublicKey[]} keys - The public keys of the accounts.
|
|
19076
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
|
|
19077
|
+
* @returns {Promise<(AccountInfo<Buffer> | null)[]>} A promise that resolves to an array of account information.
|
|
19078
|
+
*/
|
|
18055
19079
|
async getMultipleAccountsInfo(connection, keys, commitment) {
|
|
18056
19080
|
const missingKeys = keys.filter((key) => !this.accounts.has(key.toBase58()));
|
|
18057
19081
|
if (missingKeys.length > 0) {
|
|
@@ -18062,6 +19086,17 @@ var SendHelper = class {
|
|
|
18062
19086
|
}
|
|
18063
19087
|
return keys.map((key) => this.accounts.get(key.toBase58()));
|
|
18064
19088
|
}
|
|
19089
|
+
/**
|
|
19090
|
+
* Gets the account metadata for the quote instruction.
|
|
19091
|
+
*
|
|
19092
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19093
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19094
|
+
* @param {PublicKey} sender - The sender public key.
|
|
19095
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
19096
|
+
* @param {string} receiver - The receiver address.
|
|
19097
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
19098
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
19099
|
+
*/
|
|
18065
19100
|
async getQuoteAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
|
|
18066
19101
|
const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
|
|
18067
19102
|
const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -18081,7 +19116,7 @@ var SendHelper = class {
|
|
|
18081
19116
|
[sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
|
|
18082
19117
|
commitmentOrConfig
|
|
18083
19118
|
);
|
|
18084
|
-
|
|
19119
|
+
invariant3(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
|
|
18085
19120
|
const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
|
|
18086
19121
|
const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
|
|
18087
19122
|
defaultSendLibConfigBuf,
|
|
@@ -18120,14 +19155,16 @@ var SendHelper = class {
|
|
|
18120
19155
|
);
|
|
18121
19156
|
}
|
|
18122
19157
|
/**
|
|
18123
|
-
*
|
|
18124
|
-
*
|
|
18125
|
-
* @param
|
|
18126
|
-
* @param
|
|
18127
|
-
* @param
|
|
18128
|
-
* @param
|
|
18129
|
-
*
|
|
18130
|
-
*
|
|
19158
|
+
* Gets the account metadata for the send instruction.
|
|
19159
|
+
*
|
|
19160
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19161
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19162
|
+
* @param {PublicKey} sender - The sender public key.
|
|
19163
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
19164
|
+
* @param {string} receiver - The receiver address.
|
|
19165
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
|
|
19166
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
19167
|
+
*/
|
|
18131
19168
|
async getSendAccounts(connection, payer, sender, dstEid, receiver, commitmentOrConfig = "confirmed") {
|
|
18132
19169
|
const [sendLibConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
|
|
18133
19170
|
const [defaultSendLibConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -18147,7 +19184,7 @@ var SendHelper = class {
|
|
|
18147
19184
|
[sendLibConfig, defaultSendLibConfig, simpleMsgLib, uln, ulnDefaultSendConfig, ulnSendConfig],
|
|
18148
19185
|
commitmentOrConfig
|
|
18149
19186
|
);
|
|
18150
|
-
|
|
19187
|
+
invariant3(defaultSendLibConfigBuf && sendLibConfigBuf, "endpoint send library not initialized");
|
|
18151
19188
|
const [sendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0);
|
|
18152
19189
|
const [defaultSendLibConfigInfo] = endpoint_exports.accounts.SendLibraryConfig.fromAccountInfo(
|
|
18153
19190
|
defaultSendLibConfigBuf,
|
|
@@ -18185,6 +19222,17 @@ var SendHelper = class {
|
|
|
18185
19222
|
)
|
|
18186
19223
|
);
|
|
18187
19224
|
}
|
|
19225
|
+
/**
|
|
19226
|
+
* Gets the account metadata for the endpoint.
|
|
19227
|
+
*
|
|
19228
|
+
* @param {PublicKey} msgLibProgram - The message library program public key.
|
|
19229
|
+
* @param {PublicKey} msgLib - The message library public key.
|
|
19230
|
+
* @param {PublicKey} sender - The sender public key.
|
|
19231
|
+
* @param {number} dstEid - The destination endpoint ID.
|
|
19232
|
+
* @param {string} receiver - The receiver address.
|
|
19233
|
+
* @param {QuoteOrSend} quoteOrSend - The quote or send action.
|
|
19234
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
19235
|
+
*/
|
|
18188
19236
|
getEndpointAccounts(msgLibProgram, msgLib, sender, dstEid, receiver, quoteOrSend) {
|
|
18189
19237
|
const [sendLibraryConfig] = this.endpoint.deriver.sendLibraryConfig(sender, dstEid);
|
|
18190
19238
|
const [defaultSendLibraryConfig] = this.endpoint.deriver.defaultSendLibraryConfig(dstEid);
|
|
@@ -18231,6 +19279,13 @@ var SendHelper = class {
|
|
|
18231
19279
|
}
|
|
18232
19280
|
].concat(accounts);
|
|
18233
19281
|
}
|
|
19282
|
+
/**
|
|
19283
|
+
* Gets the account metadata for the simple message library.
|
|
19284
|
+
*
|
|
19285
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19286
|
+
* @param {QuoteOrSend} quoteOrSend - The quote or send action.
|
|
19287
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
19288
|
+
*/
|
|
18234
19289
|
getSimpleMsgLibAccounts(payer, quoteOrSend) {
|
|
18235
19290
|
const [msgLib] = this.simpleMsgLib.deriver.messageLib();
|
|
18236
19291
|
let accounts;
|
|
@@ -18261,9 +19316,20 @@ var SendHelper = class {
|
|
|
18261
19316
|
});
|
|
18262
19317
|
return accounts.slice(1);
|
|
18263
19318
|
}
|
|
18264
|
-
|
|
19319
|
+
/**
|
|
19320
|
+
* Gets the account metadata for the ULN.
|
|
19321
|
+
*
|
|
19322
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
19323
|
+
* @param {PublicKey} payer - The payer public key.
|
|
19324
|
+
* @param {KeyedAccountInfo} ulnInfo - The ULN account information.
|
|
19325
|
+
* @param {KeyedAccountInfo} ulnDefaultSendConfigInfo - The ULN default send configuration account information.
|
|
19326
|
+
* @param {KeyedAccountInfo} ulnSendConfigInfo - The ULN send configuration account information.
|
|
19327
|
+
* @param {QuoteOrSend} quoteOrSend - The quote or send action.
|
|
19328
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment] - The commitment level or account info configuration.
|
|
19329
|
+
* @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
|
|
19330
|
+
*/
|
|
18265
19331
|
async getUlnAccounts(connection, payer, ulnInfo, ulnDefaultSendConfigInfo, ulnSendConfigInfo, quoteOrSend, commitment) {
|
|
18266
|
-
|
|
19332
|
+
invariant3(ulnInfo.accountInfo && ulnDefaultSendConfigInfo.accountInfo, "uln send library not initialized");
|
|
18267
19333
|
const [ulnState] = uln_exports.accounts.UlnSettings.fromAccountInfo(ulnInfo.accountInfo, 0);
|
|
18268
19334
|
const [defaultSendConfigState] = uln_exports.accounts.SendConfig.fromAccountInfo(
|
|
18269
19335
|
ulnDefaultSendConfigInfo.accountInfo,
|
|
@@ -18293,7 +19359,7 @@ var SendHelper = class {
|
|
|
18293
19359
|
[executor.executor, ...dvnsKey],
|
|
18294
19360
|
commitment
|
|
18295
19361
|
);
|
|
18296
|
-
|
|
19362
|
+
invariant3(executorBuf, `executor:${executor.executor.toBase58()} not initialized`);
|
|
18297
19363
|
let executorAccounts, dvnAccounts;
|
|
18298
19364
|
{
|
|
18299
19365
|
const executor2 = {
|
|
@@ -18301,7 +19367,7 @@ var SendHelper = class {
|
|
|
18301
19367
|
owner: executorBuf.owner
|
|
18302
19368
|
};
|
|
18303
19369
|
const dvns = dvnBuf.map((dvn, i) => {
|
|
18304
|
-
|
|
19370
|
+
invariant3(dvn, `dvn:${dvnsKey[i].toBase58()} not initialized`);
|
|
18305
19371
|
return {
|
|
18306
19372
|
config: accounts_exports3.DvnConfig.fromAccountInfo(dvn)[0],
|
|
18307
19373
|
owner: dvn.owner
|
|
@@ -18313,7 +19379,7 @@ var SendHelper = class {
|
|
|
18313
19379
|
});
|
|
18314
19380
|
const priceFeedInfos = await this.getMultipleAccountsInfo(connection, priceFeeds, commitment);
|
|
18315
19381
|
priceFeedInfos.forEach((info, i) => {
|
|
18316
|
-
|
|
19382
|
+
invariant3(info, `priceFeed:${priceFeeds[i].toBase58()} not initialized`);
|
|
18317
19383
|
});
|
|
18318
19384
|
executorAccounts = new Executor(executor2.owner).getQuoteIXAccountMetaForCPI(
|
|
18319
19385
|
executor2.config.priceFeed,
|
|
@@ -19911,6 +20977,9 @@ var types = [
|
|
|
19911
20977
|
|
|
19912
20978
|
// src/index.ts
|
|
19913
20979
|
var IdlTypes = {
|
|
20980
|
+
/**
|
|
20981
|
+
* The endpoint types.
|
|
20982
|
+
*/
|
|
19914
20983
|
endpoint: types
|
|
19915
20984
|
};
|
|
19916
20985
|
var SetConfigType2 = /* @__PURE__ */ ((SetConfigType3) => {
|