@streamflow/common 6.1.2 → 6.2.1
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/solana/utils.d.ts +3 -3
- package/dist/solana/utils.js +29 -23
- package/package.json +2 -2
package/dist/solana/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mint } from "@solana/spl-token";
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
-
import { BlockhashWithExpiryBlockHeight, Commitment, Connection, Keypair, PublicKey, Transaction, TransactionInstruction, SignatureStatus, VersionedTransaction, Context } from "@solana/web3.js";
|
|
3
|
+
import { BlockhashWithExpiryBlockHeight, Commitment, Connection, Keypair, PublicKey, Transaction, TransactionInstruction, SignatureStatus, VersionedTransaction, Context, RpcResponseAndContext, SimulatedTransactionResponse } from "@solana/web3.js";
|
|
4
4
|
import { Account, AtaParams, ConfirmationParams, ITransactionSolanaExt } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
@@ -78,7 +78,7 @@ export declare function executeTransaction(connection: Connection, tx: Transacti
|
|
|
78
78
|
* @param commitment - optional commitment that will be used for simulation and confirmation
|
|
79
79
|
*/
|
|
80
80
|
export declare function sendAndConfirmTransaction(connection: Connection, tx: Transaction | VersionedTransaction, { hash, context, commitment }: ConfirmationParams): Promise<string>;
|
|
81
|
-
export declare function simulateTransaction(connection: Connection, tx: Transaction | VersionedTransaction): Promise<
|
|
81
|
+
export declare function simulateTransaction(connection: Connection, tx: Transaction | VersionedTransaction): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
|
|
82
82
|
/**
|
|
83
83
|
* Confirms and validates transaction success once
|
|
84
84
|
* @param connection - Solana client connection
|
|
@@ -152,5 +152,5 @@ export declare function prepareBaseInstructions(connection: Connection, { comput
|
|
|
152
152
|
*/
|
|
153
153
|
export declare function getMintAndProgram(connection: Connection, address: PublicKey, commitment?: Commitment): Promise<{
|
|
154
154
|
mint: Mint;
|
|
155
|
-
|
|
155
|
+
tokenProgramId: PublicKey;
|
|
156
156
|
}>;
|
package/dist/solana/utils.js
CHANGED
|
@@ -327,7 +327,7 @@ function sendAndConfirmTransaction(connection, tx, _a) {
|
|
|
327
327
|
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
328
328
|
function simulateTransaction(connection, tx) {
|
|
329
329
|
return __awaiter(this, void 0, void 0, function () {
|
|
330
|
-
var
|
|
330
|
+
var res, i, errMessage;
|
|
331
331
|
return __generator(this, function (_a) {
|
|
332
332
|
switch (_a.label) {
|
|
333
333
|
case 0:
|
|
@@ -335,7 +335,6 @@ function simulateTransaction(connection, tx) {
|
|
|
335
335
|
_a.label = 1;
|
|
336
336
|
case 1:
|
|
337
337
|
if (!(i < SIMULATE_TRIES)) return [3 /*break*/, 7];
|
|
338
|
-
res = void 0;
|
|
339
338
|
if (!isTransactionVersioned(tx)) return [3 /*break*/, 3];
|
|
340
339
|
return [4 /*yield*/, connection.simulateTransaction(tx)];
|
|
341
340
|
case 2:
|
|
@@ -351,12 +350,13 @@ function simulateTransaction(connection, tx) {
|
|
|
351
350
|
if (!errMessage.includes("BlockhashNotFound") || i === SIMULATE_TRIES - 1) {
|
|
352
351
|
throw new web3_js_1.SendTransactionError("failed to simulate transaction: " + errMessage, res.value.logs || undefined);
|
|
353
352
|
}
|
|
353
|
+
return [3 /*break*/, 6];
|
|
354
354
|
}
|
|
355
|
-
return [
|
|
355
|
+
return [2 /*return*/, res];
|
|
356
356
|
case 6:
|
|
357
357
|
i++;
|
|
358
358
|
return [3 /*break*/, 1];
|
|
359
|
-
case 7:
|
|
359
|
+
case 7: throw new web3_js_1.SendTransactionError("failed to simulate transaction");
|
|
360
360
|
}
|
|
361
361
|
});
|
|
362
362
|
});
|
|
@@ -464,7 +464,7 @@ function enrichAtaParams(connection, paramsBatch) {
|
|
|
464
464
|
return __generator(this, function (_a) {
|
|
465
465
|
programIdByMint = {};
|
|
466
466
|
return [2 /*return*/, Promise.all(paramsBatch.map(function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
467
|
-
var mintStr,
|
|
467
|
+
var mintStr, tokenProgramId;
|
|
468
468
|
return __generator(this, function (_a) {
|
|
469
469
|
switch (_a.label) {
|
|
470
470
|
case 0:
|
|
@@ -475,8 +475,8 @@ function enrichAtaParams(connection, paramsBatch) {
|
|
|
475
475
|
if (!!(mintStr in programIdByMint)) return [3 /*break*/, 2];
|
|
476
476
|
return [4 /*yield*/, getMintAndProgram(connection, params.mint)];
|
|
477
477
|
case 1:
|
|
478
|
-
|
|
479
|
-
programIdByMint[mintStr] =
|
|
478
|
+
tokenProgramId = (_a.sent()).tokenProgramId;
|
|
479
|
+
programIdByMint[mintStr] = tokenProgramId;
|
|
480
480
|
_a.label = 2;
|
|
481
481
|
case 2:
|
|
482
482
|
params.programId = programIdByMint[mintStr];
|
|
@@ -581,36 +581,42 @@ function checkOrCreateAtaBatch(connection, owners, mint, invoker, programId) {
|
|
|
581
581
|
switch (_d.label) {
|
|
582
582
|
case 0:
|
|
583
583
|
ixs = [];
|
|
584
|
-
|
|
585
|
-
|
|
584
|
+
if (!!programId) return [3 /*break*/, 2];
|
|
585
|
+
return [4 /*yield*/, getMintAndProgram(connection, mint)];
|
|
586
586
|
case 1:
|
|
587
|
-
_d.
|
|
588
|
-
owners_1 = __values(owners), owners_1_1 = owners_1.next();
|
|
587
|
+
programId = (_d.sent()).tokenProgramId;
|
|
589
588
|
_d.label = 2;
|
|
590
589
|
case 2:
|
|
591
|
-
|
|
590
|
+
atas = [];
|
|
591
|
+
_d.label = 3;
|
|
592
|
+
case 3:
|
|
593
|
+
_d.trys.push([3, 8, 9, 10]);
|
|
594
|
+
owners_1 = __values(owners), owners_1_1 = owners_1.next();
|
|
595
|
+
_d.label = 4;
|
|
596
|
+
case 4:
|
|
597
|
+
if (!!owners_1_1.done) return [3 /*break*/, 7];
|
|
592
598
|
owner = owners_1_1.value;
|
|
593
599
|
_b = (_a = atas).push;
|
|
594
600
|
return [4 /*yield*/, ata(mint, owner, programId)];
|
|
595
|
-
case
|
|
601
|
+
case 5:
|
|
596
602
|
_b.apply(_a, [_d.sent()]);
|
|
597
|
-
_d.label =
|
|
598
|
-
case 4:
|
|
599
|
-
owners_1_1 = owners_1.next();
|
|
600
|
-
return [3 /*break*/, 2];
|
|
601
|
-
case 5: return [3 /*break*/, 8];
|
|
603
|
+
_d.label = 6;
|
|
602
604
|
case 6:
|
|
605
|
+
owners_1_1 = owners_1.next();
|
|
606
|
+
return [3 /*break*/, 4];
|
|
607
|
+
case 7: return [3 /*break*/, 10];
|
|
608
|
+
case 8:
|
|
603
609
|
e_3_1 = _d.sent();
|
|
604
610
|
e_3 = { error: e_3_1 };
|
|
605
|
-
return [3 /*break*/,
|
|
606
|
-
case
|
|
611
|
+
return [3 /*break*/, 10];
|
|
612
|
+
case 9:
|
|
607
613
|
try {
|
|
608
614
|
if (owners_1_1 && !owners_1_1.done && (_c = owners_1.return)) _c.call(owners_1);
|
|
609
615
|
}
|
|
610
616
|
finally { if (e_3) throw e_3.error; }
|
|
611
617
|
return [7 /*endfinally*/];
|
|
612
|
-
case
|
|
613
|
-
case
|
|
618
|
+
case 10: return [4 /*yield*/, connection.getMultipleAccountsInfo(atas)];
|
|
619
|
+
case 11:
|
|
614
620
|
response = _d.sent();
|
|
615
621
|
for (i = 0; i < response.length; i++) {
|
|
616
622
|
if (!response[i]) {
|
|
@@ -663,7 +669,7 @@ function getMintAndProgram(connection, address, commitment) {
|
|
|
663
669
|
}
|
|
664
670
|
return [2 /*return*/, {
|
|
665
671
|
mint: (0, spl_token_1.unpackMint)(address, accountInfo, programId),
|
|
666
|
-
|
|
672
|
+
tokenProgramId: programId,
|
|
667
673
|
}];
|
|
668
674
|
}
|
|
669
675
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/common",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Common utilities and types used by streamflow packages.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lint-config": "eslint --print-config",
|
|
24
24
|
"prepublishOnly": "npm run lint && npm run build"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "bd8cb2daf52fbc3c618c1c7f27d300e98f15d264",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@streamflow/eslint-config": "6.0.0",
|
|
29
29
|
"@types/bn.js": "5.1.1",
|