@haven-fi/solauto-sdk 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +3 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +8 -3
- package/dist/clients/solautoMarginfiClient.d.ts +2 -1
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +2 -1
- package/dist/transactions/transactionsManager.d.ts +1 -0
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +15 -0
- package/package.json +2 -1
- package/src/clients/solautoClient.ts +11 -5
- package/src/clients/solautoMarginfiClient.ts +4 -1
- package/src/transactions/transactionsManager.ts +32 -2
- package/tests/transactions/solautoMarginfi.ts +1 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
import "rpc-websockets/dist/lib/client";
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
3
3
|
import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
4
|
+
import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
|
4
5
|
import { DCASettings, DCASettingsInpArgs, LendingPlatform, PositionState, ReferralState, SolautoActionArgs, SolautoPosition, SolautoRebalanceTypeArgs, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, UpdatePositionDataArgs } from "../generated";
|
5
6
|
import { JupSwapDetails } from "../utils/jupiterUtils";
|
6
7
|
import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
|
@@ -8,7 +9,8 @@ import { LivePositionUpdates } from "../utils/solauto/generalUtils";
|
|
8
9
|
export interface SolautoClientArgs {
|
9
10
|
authority?: PublicKey;
|
10
11
|
positionId: number;
|
11
|
-
signer
|
12
|
+
signer?: Signer;
|
13
|
+
wallet?: WalletAdapter;
|
12
14
|
supplyLiquidityMint?: PublicKey;
|
13
15
|
debtLiquidityMint?: PublicKey;
|
14
16
|
referralFeesDestMint?: PublicKey;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAQJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EAQvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAQnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAOpE,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAQJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAAyB,MAAM,iDAAiD,CAAC;AACvG,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EAQvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EA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AAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,6BAA6B,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAiDnE,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAYlE"}
|
@@ -5,6 +5,7 @@ require("rpc-websockets/dist/lib/client");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
6
6
|
const umi_1 = require("@metaplex-foundation/umi");
|
7
7
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
8
|
+
const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wallet-adapters");
|
8
9
|
const generated_1 = require("../generated");
|
9
10
|
const accountUtils_1 = require("../utils/accountUtils");
|
10
11
|
const generalAccounts_1 = require("../constants/generalAccounts");
|
@@ -20,9 +21,13 @@ class SolautoClient {
|
|
20
21
|
this.localTest = Boolean(localTest);
|
21
22
|
}
|
22
23
|
async initialize(args, lendingPlatform) {
|
23
|
-
this.umi = solautoConstants_1.UMI
|
24
|
-
|
25
|
-
|
24
|
+
this.umi = solautoConstants_1.UMI;
|
25
|
+
if (!args.signer && !args.wallet) {
|
26
|
+
throw new Error("Signer or wallet must be provided");
|
27
|
+
}
|
28
|
+
this.umi = solautoConstants_1.UMI.use(args.signer ? (0, umi_1.signerIdentity)(args.signer) : (0, umi_signer_wallet_adapters_1.walletAdapterIdentity)(args.wallet, true));
|
29
|
+
this.signer = this.umi.identity;
|
30
|
+
this.authority = args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.umi.identity.publicKey);
|
26
31
|
this.positionId = args.positionId;
|
27
32
|
this.selfManaged = this.positionId === 0;
|
28
33
|
this.lendingPlatform = lendingPlatform;
|
@@ -6,12 +6,13 @@ import { DCASettingsInpArgs, PositionState, SolautoActionArgs, SolautoRebalanceT
|
|
6
6
|
import { MarginfiAccount } from "../marginfi-sdk";
|
7
7
|
import { JupSwapDetails } from "../utils/jupiterUtils";
|
8
8
|
import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
|
9
|
+
import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
|
9
10
|
export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
10
11
|
marginfiAccount?: PublicKey | Signer;
|
11
12
|
marginfiAccountSeedIdx?: bigint;
|
12
13
|
marginfiGroup?: PublicKey;
|
13
14
|
}
|
14
|
-
export declare function newMarginfiSolautoManagedPositionArgs(positionId: number, signer: Signer, supplyMint: PublicKey, debtMint: PublicKey, referredByAuthority?: PublicKey): SolautoMarginfiClientArgs;
|
15
|
+
export declare function newMarginfiSolautoManagedPositionArgs(positionId: number, signer: Signer | undefined, wallet: WalletAdapter | undefined, supplyMint: PublicKey, debtMint: PublicKey, referredByAuthority?: PublicKey): SolautoMarginfiClientArgs;
|
15
16
|
export declare class SolautoMarginfiClient extends SolautoClient {
|
16
17
|
marginfiProgram: PublicKey;
|
17
18
|
marginfiAccountSeedIdx?: bigint;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,SAAS,EAEV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe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CAAC;IAE5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,0BAA0B,EAAG,qBAAqB,CAAC;IACnD,wBAAwB,EAAG,qBAAqB,CAAC;IAGjD,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAgEhD,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAQ/B,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA2C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAMhE,OAAO,CAAC,6BAA6B;IA8DrC,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA4CrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IA8ElE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAqBlE"}
|
@@ -12,10 +12,11 @@ const generalUtils_1 = require("../utils/generalUtils");
|
|
12
12
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
13
13
|
const marginfiUtils_1 = require("../utils/marginfiUtils");
|
14
14
|
const numberUtils_1 = require("../utils/numberUtils");
|
15
|
-
function newMarginfiSolautoManagedPositionArgs(positionId, signer, supplyMint, debtMint, referredByAuthority) {
|
15
|
+
function newMarginfiSolautoManagedPositionArgs(positionId, signer, wallet, supplyMint, debtMint, referredByAuthority) {
|
16
16
|
return {
|
17
17
|
positionId,
|
18
18
|
signer,
|
19
|
+
wallet,
|
19
20
|
marginfiAccountSeedIdx: positionId > 0 ? (0, generalUtils_1.generateRandomU64)() : undefined,
|
20
21
|
supplyLiquidityMint: supplyMint,
|
21
22
|
debtLiquidityMint: debtMint,
|
@@ -14,6 +14,7 @@ export declare class TransactionItem {
|
|
14
14
|
} | undefined>, name?: string | undefined);
|
15
15
|
initialize(): Promise<void>;
|
16
16
|
refetch(attemptNum: number): Promise<void>;
|
17
|
+
uniqueAccounts(): string[];
|
17
18
|
}
|
18
19
|
export declare enum TransactionStatus {
|
19
20
|
Skipped = "Skipped",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuCzD,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC;IATd,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,oBAAQ;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuCzD,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC;IATd,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,oBAAQ;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,YAAY,CAAC;IARvB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,eAAe,EAAE,EACxB,cAAc,CAAC,6CAA4C,IAAI,aAAA,EAC/D,YAAY,CAAC,qBAAS,EACtB,YAAY,CAAC,qBAAS;YAKlB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAgB9D,IAAI;CAqIX"}
|
@@ -45,6 +45,14 @@ class TransactionItem {
|
|
45
45
|
this.tx = resp?.tx;
|
46
46
|
this.lookupTableAddresses = resp?.lookupTableAddresses ?? [];
|
47
47
|
}
|
48
|
+
uniqueAccounts() {
|
49
|
+
return Array.from(new Set(this.tx.getInstructions()
|
50
|
+
.map((x) => [
|
51
|
+
x.programId.toString(),
|
52
|
+
...x.keys.map((y) => y.pubkey.toString()),
|
53
|
+
])
|
54
|
+
.flat()));
|
55
|
+
}
|
48
56
|
}
|
49
57
|
exports.TransactionItem = TransactionItem;
|
50
58
|
class TransactionSet {
|
@@ -57,6 +65,13 @@ class TransactionSet {
|
|
57
65
|
if (!item.tx) {
|
58
66
|
return true;
|
59
67
|
}
|
68
|
+
const accountLocks = Array.from(new Set([
|
69
|
+
...this.items.map((x) => x.uniqueAccounts()),
|
70
|
+
...item.uniqueAccounts(),
|
71
|
+
])).length;
|
72
|
+
if (accountLocks > 128) {
|
73
|
+
return false;
|
74
|
+
}
|
60
75
|
return (await this.getSingleTransaction())
|
61
76
|
.add(item.tx)
|
62
77
|
.setAddressLookupTables(await this.lookupTables.getLutInputs([
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@haven-fi/solauto-sdk",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"types": "dist/index.d.ts",
|
6
6
|
"description": "Typescript SDK for the Solauto program on the Solana blockchain",
|
@@ -18,6 +18,7 @@
|
|
18
18
|
"@jup-ag/api": "^6.0.24",
|
19
19
|
"@metaplex-foundation/umi": "^0.9.1",
|
20
20
|
"@metaplex-foundation/umi-bundle-defaults": "^0.9.1",
|
21
|
+
"@metaplex-foundation/umi-signer-wallet-adapters": "^0.9.1",
|
21
22
|
"@metaplex-foundation/umi-web3js-adapters": "^0.9.1",
|
22
23
|
"@solana/spl-token": "^0.4.0",
|
23
24
|
"@solana/web3.js": "^1.92.1",
|
@@ -13,6 +13,7 @@ import {
|
|
13
13
|
some,
|
14
14
|
} from "@metaplex-foundation/umi";
|
15
15
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
16
|
+
import { WalletAdapter, walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";
|
16
17
|
import {
|
17
18
|
DCASettings,
|
18
19
|
DCASettingsInpArgs,
|
@@ -65,7 +66,8 @@ import {
|
|
65
66
|
export interface SolautoClientArgs {
|
66
67
|
authority?: PublicKey;
|
67
68
|
positionId: number;
|
68
|
-
signer
|
69
|
+
signer?: Signer;
|
70
|
+
wallet?: WalletAdapter;
|
69
71
|
|
70
72
|
supplyLiquidityMint?: PublicKey;
|
71
73
|
debtLiquidityMint?: PublicKey;
|
@@ -119,10 +121,14 @@ export abstract class SolautoClient {
|
|
119
121
|
}
|
120
122
|
|
121
123
|
async initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform) {
|
122
|
-
this.umi = UMI
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
this.umi = UMI;
|
125
|
+
if (!args.signer && !args.wallet) {
|
126
|
+
throw new Error("Signer or wallet must be provided");
|
127
|
+
}
|
128
|
+
this.umi = UMI.use(args.signer ? signerIdentity(args.signer) : walletAdapterIdentity(args.wallet!, true));
|
129
|
+
|
130
|
+
this.signer = this.umi.identity;
|
131
|
+
this.authority = args.authority ?? toWeb3JsPublicKey(this.umi.identity.publicKey);
|
126
132
|
|
127
133
|
this.positionId = args.positionId;
|
128
134
|
this.selfManaged = this.positionId === 0;
|
@@ -55,6 +55,7 @@ import {
|
|
55
55
|
getMarginfiAccountPositionState,
|
56
56
|
} from "../utils/marginfiUtils";
|
57
57
|
import { bytesToI80F48 } from "../utils/numberUtils";
|
58
|
+
import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
|
58
59
|
|
59
60
|
export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
60
61
|
marginfiAccount?: PublicKey | Signer;
|
@@ -64,7 +65,8 @@ export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
|
64
65
|
|
65
66
|
export function newMarginfiSolautoManagedPositionArgs(
|
66
67
|
positionId: number,
|
67
|
-
signer: Signer,
|
68
|
+
signer: Signer | undefined,
|
69
|
+
wallet: WalletAdapter | undefined,
|
68
70
|
supplyMint: PublicKey,
|
69
71
|
debtMint: PublicKey,
|
70
72
|
referredByAuthority?: PublicKey
|
@@ -72,6 +74,7 @@ export function newMarginfiSolautoManagedPositionArgs(
|
|
72
74
|
return {
|
73
75
|
positionId,
|
74
76
|
signer,
|
77
|
+
wallet,
|
75
78
|
marginfiAccountSeedIdx: positionId > 0 ? generateRandomU64() : undefined,
|
76
79
|
supplyLiquidityMint: supplyMint,
|
77
80
|
debtLiquidityMint: debtMint,
|
@@ -65,6 +65,19 @@ export class TransactionItem {
|
|
65
65
|
this.tx = resp?.tx;
|
66
66
|
this.lookupTableAddresses = resp?.lookupTableAddresses ?? [];
|
67
67
|
}
|
68
|
+
|
69
|
+
uniqueAccounts(): string[] {
|
70
|
+
return Array.from(
|
71
|
+
new Set(
|
72
|
+
this.tx!.getInstructions()
|
73
|
+
.map((x) => [
|
74
|
+
x.programId.toString(),
|
75
|
+
...x.keys.map((y) => y.pubkey.toString()),
|
76
|
+
])
|
77
|
+
.flat()
|
78
|
+
)
|
79
|
+
);
|
80
|
+
}
|
68
81
|
}
|
69
82
|
|
70
83
|
class TransactionSet {
|
@@ -79,6 +92,16 @@ class TransactionSet {
|
|
79
92
|
return true;
|
80
93
|
}
|
81
94
|
|
95
|
+
const accountLocks = Array.from(
|
96
|
+
new Set([
|
97
|
+
...this.items.map((x) => x.uniqueAccounts()),
|
98
|
+
...item.uniqueAccounts(),
|
99
|
+
])
|
100
|
+
).length;
|
101
|
+
if (accountLocks > 128) {
|
102
|
+
return false;
|
103
|
+
}
|
104
|
+
|
82
105
|
return (await this.getSingleTransaction())
|
83
106
|
.add(item.tx)
|
84
107
|
.setAddressLookupTables(
|
@@ -249,7 +272,12 @@ export class TransactionsManager {
|
|
249
272
|
choresBefore.prepend(updateLookupTable.updateLutTx);
|
250
273
|
}
|
251
274
|
if (choresBefore.getInstructions().length > 0) {
|
252
|
-
this.items.unshift(
|
275
|
+
this.items.unshift(
|
276
|
+
new TransactionItem(
|
277
|
+
async () => ({ tx: choresBefore }),
|
278
|
+
"create account(s)"
|
279
|
+
)
|
280
|
+
);
|
253
281
|
this.client.log("Chores before: ", choresBefore.getInstructions().length);
|
254
282
|
}
|
255
283
|
if (choresAfter.getInstructions().length > 0) {
|
@@ -264,7 +292,9 @@ export class TransactionsManager {
|
|
264
292
|
}
|
265
293
|
|
266
294
|
if (this.mustBeAtomic && itemSets.length > 1) {
|
267
|
-
throw new Error(
|
295
|
+
throw new Error(
|
296
|
+
`${itemSets.length} transactions required but jito bundles are not currently supported`
|
297
|
+
);
|
268
298
|
// itemSets.forEach((set) => {
|
269
299
|
// this.updateStatus(set.name(), TransactionStatus.Processing);
|
270
300
|
// });
|