@triadxyz/triad-protocol 2.1.2-beta → 2.1.3-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19,7 +19,6 @@ const poseidon_1 = require("./utils/pda/poseidon");
19
19
  const stake_1 = __importDefault(require("./stake"));
20
20
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
21
21
  const constants_1 = require("./utils/constants");
22
- const sendMethod_1 = __importDefault(require("./utils/sendMethod"));
23
22
  const pda_1 = require("./utils/pda");
24
23
  class TriadProtocolClient {
25
24
  constructor(connection, wallet) {
@@ -68,13 +67,20 @@ class TriadProtocolClient {
68
67
  * @param options - RPC options
69
68
  */
70
69
  withdrawPoseidon({ poseidonAsset, nft }, options) {
71
- return (0, sendMethod_1.default)(this.program.methods.withdrawPoseidon().accounts({
72
- signer: this.provider.wallet.publicKey,
73
- nft: (0, poseidon_1.getPoseidonPDA)(this.program.programId, nft),
74
- poseidonAsset,
75
- poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
76
- corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
77
- }), options);
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const ixs = [];
72
+ ixs.push(yield this.program.methods
73
+ .withdrawPoseidon()
74
+ .accounts({
75
+ signer: this.provider.wallet.publicKey,
76
+ nft: (0, poseidon_1.getPoseidonPDA)(this.program.programId, nft),
77
+ poseidonAsset,
78
+ poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
79
+ corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
80
+ })
81
+ .instruction());
82
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
83
+ });
78
84
  }
79
85
  /**
80
86
  * Collect Royalty
@@ -83,10 +89,17 @@ class TriadProtocolClient {
83
89
  * @param options - RPC options
84
90
  */
85
91
  collectRoyalty(collection, options) {
86
- return (0, sendMethod_1.default)(this.program.methods.collectRoyalty().accounts({
87
- signer: this.provider.wallet.publicKey,
88
- collection: (0, poseidon_1.getCollectionPDA)(this.program.programId, collection)
89
- }), options);
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const ixs = [];
94
+ ixs.push(yield this.program.methods
95
+ .collectRoyalty()
96
+ .accounts({
97
+ signer: this.provider.wallet.publicKey,
98
+ collection: (0, poseidon_1.getCollectionPDA)(this.program.programId, collection)
99
+ })
100
+ .instruction());
101
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
102
+ });
90
103
  }
91
104
  /**
92
105
  * Add Trader Poseidon
@@ -96,12 +109,19 @@ class TriadProtocolClient {
96
109
  * @param options - RPC options
97
110
  */
98
111
  addTraderPoseidon({ user, poseidonAsset }, options) {
99
- return (0, sendMethod_1.default)(this.program.methods.addTraderPoseidon().accounts({
100
- poseidonAsset,
101
- userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
102
- corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
103
- poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
104
- }), options);
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const ixs = [];
114
+ ixs.push(yield this.program.methods
115
+ .addTraderPoseidon()
116
+ .accounts({
117
+ poseidonAsset,
118
+ userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
119
+ corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
120
+ poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
121
+ })
122
+ .instruction());
123
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
124
+ });
105
125
  }
106
126
  /**
107
127
  * Remove Trader Poseidon
@@ -110,12 +130,19 @@ class TriadProtocolClient {
110
130
  * @param options - RPC options
111
131
  */
112
132
  removeTraderPoseidon({ user, poseidonAsset }, options) {
113
- return (0, sendMethod_1.default)(this.program.methods.removeTraderPoseidon().accounts({
114
- userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
115
- poseidonAsset,
116
- corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
117
- poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
118
- }), options);
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const ixs = [];
135
+ ixs.push(yield this.program.methods
136
+ .removeTraderPoseidon()
137
+ .accounts({
138
+ userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
139
+ poseidonAsset,
140
+ corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
141
+ poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
142
+ })
143
+ .instruction());
144
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
145
+ });
119
146
  }
120
147
  }
121
148
  exports.default = TriadProtocolClient;
package/dist/stake.js CHANGED
@@ -17,7 +17,6 @@ const helpers_1 = require("./utils/helpers");
17
17
  const stake_1 = require("./utils/pda/stake");
18
18
  const constants_1 = require("./utils/constants");
19
19
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
20
- const sendMethod_1 = __importDefault(require("./utils/sendMethod"));
21
20
  class Stake {
22
21
  constructor(program) {
23
22
  this.program = program;
@@ -80,15 +79,20 @@ class Stake {
80
79
  *
81
80
  */
82
81
  stakeToken({ name, wallet, amount }, options) {
83
- return (0, sendMethod_1.default)(this.program.methods
84
- .stakeToken({
85
- name,
86
- amount: new anchor_1.BN(amount * Math.pow(10, 6))
87
- })
88
- .accounts({
89
- signer: wallet,
90
- mint: constants_1.TRD_MINT
91
- }), options);
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const ixs = [];
84
+ ixs.push(yield this.program.methods
85
+ .stakeToken({
86
+ name,
87
+ amount: new anchor_1.BN(amount * Math.pow(10, 6))
88
+ })
89
+ .accounts({
90
+ signer: wallet,
91
+ mint: constants_1.TRD_MINT
92
+ })
93
+ .instruction());
94
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
95
+ });
92
96
  }
93
97
  /**
94
98
  * Update Stake Vault
@@ -99,15 +103,20 @@ class Stake {
99
103
  *
100
104
  */
101
105
  updateStakeVault({ amount, isLocked }, options) {
102
- return (0, sendMethod_1.default)(this.program.methods
103
- .updateStakeVault({
104
- amount,
105
- isLocked
106
- })
107
- .accounts({
108
- signer: this.program.provider.publicKey,
109
- mint: constants_1.TRD_MINT
110
- }), options);
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const ixs = [];
108
+ ixs.push(yield this.program.methods
109
+ .updateStakeVault({
110
+ amount,
111
+ isLocked
112
+ })
113
+ .accounts({
114
+ signer: this.program.provider.publicKey,
115
+ mint: constants_1.TRD_MINT
116
+ })
117
+ .instruction());
118
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
119
+ });
111
120
  }
112
121
  /**
113
122
  * Request Withdraw
@@ -142,12 +151,19 @@ class Stake {
142
151
  *
143
152
  */
144
153
  withdrawStake({ wallet, name, mint }, options) {
145
- return (0, sendMethod_1.default)(this.program.methods.withdrawStake().accounts({
146
- signer: wallet,
147
- stake: (0, stake_1.getStakePDA)(this.program.programId, wallet, name),
148
- admin: constants_1.TRIAD_ADMIN,
149
- mint: mint
150
- }), options);
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ const ixs = [];
156
+ ixs.push(yield this.program.methods
157
+ .withdrawStake()
158
+ .accounts({
159
+ signer: wallet,
160
+ stake: (0, stake_1.getStakePDA)(this.program.programId, wallet, name),
161
+ admin: constants_1.TRIAD_ADMIN,
162
+ mint: mint
163
+ })
164
+ .instruction());
165
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
166
+ });
151
167
  }
152
168
  /**
153
169
  * Claim Stake Rewards
package/dist/trade.js CHANGED
@@ -19,7 +19,6 @@ const constants_1 = require("./utils/constants");
19
19
  const helpers_1 = require("./utils/helpers");
20
20
  const pda_1 = require("./utils/pda");
21
21
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
22
- const sendMethod_1 = __importDefault(require("./utils/sendMethod"));
23
22
  const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
24
23
  const pda_2 = require("./utils/pda");
25
24
  class Trade {
@@ -118,25 +117,30 @@ class Trade {
118
117
  *
119
118
  */
120
119
  createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }, options) {
121
- if (question.length > 80) {
122
- throw new Error('Question must be less than 80 characters');
123
- }
124
- return (0, sendMethod_1.default)(this.program.methods
125
- .createMarket({
126
- marketId: new bn_js_1.default(marketId),
127
- question: (0, helpers_1.encodeString)(question, 80),
128
- marketStart: new bn_js_1.default(startTime),
129
- marketEnd: new bn_js_1.default(endTime),
130
- feeBps,
131
- payoutFee
132
- })
133
- .accounts({
134
- signer: this.program.provider.publicKey,
135
- mint,
136
- tokenProgram: (0, helpers_1.getTokenProgram)(mint),
137
- customer,
138
- pool: null
139
- }), options);
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ if (question.length > 80) {
122
+ throw new Error('Question must be less than 80 characters');
123
+ }
124
+ const ixs = [];
125
+ ixs.push(yield this.program.methods
126
+ .createMarket({
127
+ marketId: new bn_js_1.default(marketId),
128
+ question: (0, helpers_1.encodeString)(question, 80),
129
+ marketStart: new bn_js_1.default(startTime),
130
+ marketEnd: new bn_js_1.default(endTime),
131
+ feeBps,
132
+ payoutFee
133
+ })
134
+ .accounts({
135
+ signer: this.program.provider.publicKey,
136
+ mint,
137
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint),
138
+ customer,
139
+ pool: null
140
+ })
141
+ .instruction());
142
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
143
+ });
140
144
  }
141
145
  /**
142
146
  * Create Pool
@@ -231,17 +235,22 @@ class Trade {
231
235
  */
232
236
  closeOrder({ marketId, orderId, userNonce }, options) {
233
237
  return __awaiter(this, void 0, void 0, function* () {
238
+ const ixs = [];
234
239
  let userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
235
240
  if (userNonce !== 0) {
236
241
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonce);
237
242
  userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
238
243
  }
239
- return (0, sendMethod_1.default)(this.program.methods.closeOrder(new bn_js_1.default(orderId)).accounts({
244
+ ixs.push(yield this.program.methods
245
+ .closeOrder(new bn_js_1.default(orderId))
246
+ .accounts({
240
247
  signer: this.program.provider.publicKey,
241
248
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
242
249
  mint: constants_1.TRD_MINT,
243
250
  userTrade: userTradePDA
244
- }), options);
251
+ })
252
+ .instruction());
253
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
245
254
  });
246
255
  }
247
256
  /**
@@ -253,16 +262,21 @@ class Trade {
253
262
  *
254
263
  */
255
264
  resolveMarket({ marketId, winningDirection }, options) {
256
- return (0, sendMethod_1.default)(this.program.methods
257
- .updateMarket({
258
- winningDirection,
259
- allowPayout: null,
260
- marketEnd: null
261
- })
262
- .accounts({
263
- signer: this.program.provider.publicKey,
264
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
265
- }), options);
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ const ixs = [];
267
+ ixs.push(yield this.program.methods
268
+ .updateMarket({
269
+ winningDirection,
270
+ allowPayout: null,
271
+ marketEnd: null
272
+ })
273
+ .accounts({
274
+ signer: this.program.provider.publicKey,
275
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
276
+ })
277
+ .instruction());
278
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
279
+ });
266
280
  }
267
281
  /**
268
282
  * Collect Remaining Liquidity
@@ -273,13 +287,18 @@ class Trade {
273
287
  */
274
288
  collectRemainingLiquidity(marketId, options) {
275
289
  return __awaiter(this, void 0, void 0, function* () {
290
+ const ixs = [];
276
291
  const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
277
292
  const market = yield this.getMarketByAddress(marketPDA);
278
- return (0, sendMethod_1.default)(this.program.methods.collectRemainingLiquidity().accounts({
293
+ ixs.push(yield this.program.methods
294
+ .collectRemainingLiquidity()
295
+ .accounts({
279
296
  signer: this.program.provider.publicKey,
280
297
  market: marketPDA,
281
298
  mint: market.mint
282
- }), options);
299
+ })
300
+ .instruction());
301
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
283
302
  });
284
303
  }
285
304
  /**
@@ -325,16 +344,21 @@ class Trade {
325
344
  *
326
345
  */
327
346
  allowMarketToPayout(marketId, options) {
328
- return (0, sendMethod_1.default)(this.program.methods
329
- .updateMarket({
330
- winningDirection: null,
331
- allowPayout: true,
332
- marketEnd: null
333
- })
334
- .accounts({
335
- signer: this.program.provider.publicKey,
336
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
337
- }), options);
347
+ return __awaiter(this, void 0, void 0, function* () {
348
+ const ixs = [];
349
+ ixs.push(yield this.program.methods
350
+ .updateMarket({
351
+ winningDirection: null,
352
+ allowPayout: true,
353
+ marketEnd: null
354
+ })
355
+ .accounts({
356
+ signer: this.program.provider.publicKey,
357
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
358
+ })
359
+ .instruction());
360
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
361
+ });
338
362
  }
339
363
  /**
340
364
  * Create Sub User Trade
@@ -345,11 +369,16 @@ class Trade {
345
369
  */
346
370
  createSubUserTrade(user, options) {
347
371
  return __awaiter(this, void 0, void 0, function* () {
372
+ const ixs = [];
348
373
  const userTrade = yield this.getUserTrade(user);
349
374
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, user, userTrade.nonce + 1);
350
- return (0, sendMethod_1.default)(this.program.methods.createSubUserTrade(subUserTradePDA).accounts({
375
+ ixs.push(yield this.program.methods
376
+ .createSubUserTrade(subUserTradePDA)
377
+ .accounts({
351
378
  signer: this.program.provider.publicKey
352
- }), options);
379
+ })
380
+ .instruction());
381
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
353
382
  });
354
383
  }
355
384
  /**
@@ -361,16 +390,21 @@ class Trade {
361
390
  *
362
391
  */
363
392
  updateMarket(marketId, marketEnd, options) {
364
- return (0, sendMethod_1.default)(this.program.methods
365
- .updateMarket({
366
- marketEnd: new bn_js_1.default(marketEnd),
367
- winningDirection: null,
368
- allowPayout: null
369
- })
370
- .accounts({
371
- signer: this.program.provider.publicKey,
372
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
373
- }), options);
393
+ return __awaiter(this, void 0, void 0, function* () {
394
+ const ixs = [];
395
+ ixs.push(yield this.program.methods
396
+ .updateMarket({
397
+ marketEnd: new bn_js_1.default(marketEnd),
398
+ winningDirection: null,
399
+ allowPayout: null
400
+ })
401
+ .accounts({
402
+ signer: this.program.provider.publicKey,
403
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
404
+ })
405
+ .instruction());
406
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
407
+ });
374
408
  }
375
409
  /**
376
410
  * Create Customer
@@ -382,11 +416,16 @@ class Trade {
382
416
  *
383
417
  */
384
418
  createCustomer({ id, name, authority, feeRecipient }, options) {
385
- return (0, sendMethod_1.default)(this.program.methods
386
- .createCustomer({ id, name, authority, feeRecipient })
387
- .accounts({
388
- signer: this.program.provider.publicKey
389
- }), options);
419
+ return __awaiter(this, void 0, void 0, function* () {
420
+ const ixs = [];
421
+ ixs.push(yield this.program.methods
422
+ .createCustomer({ id, name, authority, feeRecipient })
423
+ .accounts({
424
+ signer: this.program.provider.publicKey
425
+ })
426
+ .instruction());
427
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
428
+ });
390
429
  }
391
430
  /**
392
431
  * Get User Trade Nonce With Slots
@@ -549,18 +588,23 @@ class Trade {
549
588
  */
550
589
  cancelBidOrder({ marketId, orderId, userNonce, mint }, options) {
551
590
  return __awaiter(this, void 0, void 0, function* () {
591
+ const ixs = [];
552
592
  let userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
553
593
  if (userNonce !== 0) {
554
594
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonce);
555
595
  userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
556
596
  }
557
- return (0, sendMethod_1.default)(this.program.methods.cancelBidOrder(new bn_js_1.default(orderId)).accounts({
597
+ ixs.push(yield this.program.methods
598
+ .cancelBidOrder(new bn_js_1.default(orderId))
599
+ .accounts({
558
600
  signer: this.program.provider.publicKey,
559
601
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
560
602
  bidUserTrade: userTradePDA,
561
603
  mint,
562
604
  tokenProgram: (0, helpers_1.getTokenProgram)(mint)
563
- }), options);
605
+ })
606
+ .instruction());
607
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
564
608
  });
565
609
  }
566
610
  /**
@@ -574,6 +618,7 @@ class Trade {
574
618
  */
575
619
  cancelAskOrder({ marketId, orderId, userNonce, userNonceBidOrder }, options) {
576
620
  return __awaiter(this, void 0, void 0, function* () {
621
+ const ixs = [];
577
622
  let askUserTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
578
623
  if (userNonce !== 0) {
579
624
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonce);
@@ -584,12 +629,16 @@ class Trade {
584
629
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonceBidOrder);
585
630
  bidUserTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
586
631
  }
587
- return (0, sendMethod_1.default)(this.program.methods.cancelAskOrder(new bn_js_1.default(orderId)).accounts({
632
+ ixs.push(yield this.program.methods
633
+ .cancelAskOrder(new bn_js_1.default(orderId))
634
+ .accounts({
588
635
  signer: this.program.provider.publicKey,
589
636
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
590
637
  askUserTrade: askUserTradePDA,
591
638
  bidUserTrade: bidUserTradePDA
592
- }), options);
639
+ })
640
+ .instruction());
641
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
593
642
  });
594
643
  }
595
644
  /**
@@ -54,11 +54,11 @@
54
54
  "signer": true
55
55
  },
56
56
  {
57
- "name": "ask_user_trade",
57
+ "name": "bid_user_trade",
58
58
  "writable": true
59
59
  },
60
60
  {
61
- "name": "bid_user_trade",
61
+ "name": "ask_user_trade",
62
62
  "writable": true
63
63
  },
64
64
  {
@@ -60,11 +60,11 @@ export type TriadProtocol = {
60
60
  signer: true;
61
61
  },
62
62
  {
63
- name: 'askUserTrade';
63
+ name: 'bidUserTrade';
64
64
  writable: true;
65
65
  },
66
66
  {
67
- name: 'bidUserTrade';
67
+ name: 'askUserTrade';
68
68
  writable: true;
69
69
  },
70
70
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.1.2-beta",
3
+ "version": "2.1.3-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,5 +0,0 @@
1
- import { RpcOptions } from '../types';
2
- import { MethodsBuilder } from '@coral-xyz/anchor/dist/cjs/program/namespace/methods';
3
- import { TriadProtocol } from '../types/triad_protocol';
4
- declare const sendMethod: (method: MethodsBuilder<TriadProtocol, any, any>, options?: RpcOptions) => Promise<string>;
5
- export default sendMethod;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const web3_js_1 = require("@solana/web3.js");
16
- const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
17
- const sendMethod = (method, options) => __awaiter(void 0, void 0, void 0, function* () {
18
- if (options === null || options === void 0 ? void 0 : options.microLamports) {
19
- method.postInstructions([
20
- web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
21
- microLamports: options.microLamports
22
- })
23
- ]);
24
- }
25
- if (!(options === null || options === void 0 ? void 0 : options.microLamports)) {
26
- const priorityFee = yield (0, getPriorityFee_1.default)();
27
- method.postInstructions([
28
- web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
29
- microLamports: priorityFee
30
- })
31
- ]);
32
- }
33
- return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
34
- });
35
- exports.default = sendMethod;