@loyal-labs/private-transactions 0.2.7 → 0.2.9

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.
Files changed (32) hide show
  1. package/README.md +69 -35
  2. package/dist/index.d.ts +122 -14
  3. package/dist/index.js +2918 -20273
  4. package/dist/src/LoyalPrivateTransactionsClient.d.ts +40 -13
  5. package/dist/src/actions/shieldTokens.d.ts +69 -0
  6. package/dist/src/actions/undelegateDeposit.d.ts +25 -0
  7. package/dist/src/actions/unshieldTokens.d.ts +62 -0
  8. package/dist/src/checks/enshureChecks.d.ts +5 -0
  9. package/dist/src/constants.d.ts +17 -2
  10. package/dist/src/enumerate-deposits.d.ts +23 -0
  11. package/dist/src/fee-estimate.d.ts +25 -0
  12. package/dist/src/idl/telegram_private_transfer.d.ts +182 -121
  13. package/dist/src/instructions/closeDeposit.d.ts +4 -0
  14. package/dist/src/instructions/closePermission.d.ts +2 -0
  15. package/dist/src/instructions/closeUsernameDeposit.d.ts +4 -0
  16. package/dist/src/instructions/createPermission.d.ts +4 -0
  17. package/dist/src/instructions/delegateDeposit.d.ts +4 -0
  18. package/dist/src/instructions/initializeDeposit.d.ts +4 -0
  19. package/dist/src/instructions/initializeUsernameDeposit.d.ts +4 -0
  20. package/dist/src/instructions/modifyBalance.d.ts +4 -0
  21. package/dist/src/instructions/undelegateDeposit.d.ts +4 -0
  22. package/dist/src/instructions/undelegatePermission.d.ts +2 -0
  23. package/dist/src/kamino.d.ts +44 -0
  24. package/dist/src/pda.d.ts +1 -1
  25. package/dist/src/rent-estimate.d.ts +46 -0
  26. package/dist/src/transaction-debug.d.ts +40 -0
  27. package/dist/src/types.d.ts +224 -3
  28. package/dist/src/utils.d.ts +8 -0
  29. package/dist/src/webcrypto.d.ts +2 -0
  30. package/dist/src/wsol.d.ts +14 -0
  31. package/package.json +6 -6
  32. package/dist/src/idl.d.ts +0 -1751
@@ -1,4 +1,4 @@
1
- import type { PublicKey, Transaction, VersionedTransaction, Keypair, Commitment } from "@solana/web3.js";
1
+ import type { PublicKey, Transaction, VersionedTransaction, Keypair, Commitment, TransactionInstruction } from "@solana/web3.js";
2
2
  import type { AnchorProvider } from "@coral-xyz/anchor";
3
3
  /**
4
4
  * Minimal wallet interface matching @solana/wallet-adapter-base
@@ -16,6 +16,162 @@ export interface WalletLike {
16
16
  * - AnchorProvider: Existing Anchor projects
17
17
  */
18
18
  export type WalletSigner = WalletLike | Keypair | AnchorProvider;
19
+ export type InstructionCheck = {
20
+ address: PublicKey;
21
+ delegated: boolean;
22
+ passNotExist: boolean;
23
+ label: string;
24
+ };
25
+ export type CheckedTransactionInstruction = {
26
+ ix: TransactionInstruction;
27
+ ensure: InstructionCheck[];
28
+ };
29
+ export type ShieldFlowKind = "shield" | "unshield";
30
+ export type FeeEstimateCluster = "base" | "ephemeral";
31
+ export interface BuildShieldFlowTransactionPlanParams {
32
+ kind: ShieldFlowKind;
33
+ user: PublicKey;
34
+ tokenMint: PublicKey;
35
+ amount: number | bigint;
36
+ payer?: PublicKey;
37
+ validator?: PublicKey;
38
+ sessionToken?: PublicKey | null;
39
+ magicProgram?: PublicKey;
40
+ magicContext?: PublicKey;
41
+ }
42
+ export type BuildShieldTokensTransactionPlanParams = Omit<BuildShieldFlowTransactionPlanParams, "kind">;
43
+ export type BuildUnshieldTokensTransactionPlanParams = Omit<BuildShieldFlowTransactionPlanParams, "kind">;
44
+ export interface EstimateShieldFlowFeeParams {
45
+ plan: ShieldFlowPlan;
46
+ commitment?: Commitment;
47
+ }
48
+ export interface EstimateShieldTokensFeeParams extends EstimateShieldFlowFeeParams {
49
+ }
50
+ export interface EstimateUnshieldTokensFeeParams extends EstimateShieldFlowFeeParams {
51
+ }
52
+ export interface ExecuteShieldFlowTransactionPlanParams {
53
+ plan: ShieldFlowPlan;
54
+ rpcOptions?: RpcOptions;
55
+ }
56
+ export interface ExecuteShieldTokensTransactionPlanParams extends ExecuteShieldFlowTransactionPlanParams {
57
+ }
58
+ export interface ExecuteUnshieldTokensTransactionPlanParams extends ExecuteShieldFlowTransactionPlanParams {
59
+ }
60
+ export interface ShieldTokensClientParams {
61
+ user: PublicKey;
62
+ tokenMint: PublicKey;
63
+ amount: number | bigint;
64
+ payer?: PublicKey;
65
+ validator?: PublicKey;
66
+ sessionToken?: PublicKey | null;
67
+ magicProgram?: PublicKey;
68
+ magicContext?: PublicKey;
69
+ rpcOptions?: RpcOptions;
70
+ }
71
+ export interface UnshieldTokensClientParams {
72
+ user: PublicKey;
73
+ tokenMint: PublicKey;
74
+ amount: number | bigint;
75
+ payer?: PublicKey;
76
+ validator?: PublicKey;
77
+ sessionToken?: PublicKey | null;
78
+ magicProgram?: PublicKey;
79
+ magicContext?: PublicKey;
80
+ rpcOptions?: RpcOptions;
81
+ }
82
+ export interface InstructionCostEstimate {
83
+ transactionIndex: number;
84
+ instructionIndex: number;
85
+ label: string;
86
+ programId: PublicKey;
87
+ /**
88
+ * Net rent impact for this instruction.
89
+ * Positive values are newly locked rent; negative values are reclaimed rent.
90
+ */
91
+ rentLamports: number;
92
+ /**
93
+ * Net native-SOL value movement caused by token semantics, excluding fees and rent.
94
+ * Positive values debit the payer/user, negative values credit them.
95
+ */
96
+ nativeLamports: number;
97
+ }
98
+ export interface ShieldFlowInstructionPlan {
99
+ label: string;
100
+ ix: TransactionInstruction;
101
+ /**
102
+ * Net rent impact for this instruction.
103
+ * Positive values are newly locked rent; negative values are reclaimed rent.
104
+ */
105
+ rentLamports?: number;
106
+ /**
107
+ * Net native-SOL value movement caused by token semantics, excluding fees and rent.
108
+ * Positive values debit the payer/user, negative values credit them.
109
+ */
110
+ nativeLamports?: number;
111
+ }
112
+ export interface ShieldFlowOwnerChangeWait {
113
+ address: PublicKey;
114
+ owner: PublicKey;
115
+ bestEffort?: boolean;
116
+ }
117
+ export interface ShieldFlowTransactionPlan {
118
+ label: string;
119
+ cluster: FeeEstimateCluster;
120
+ instructions: ShieldFlowInstructionPlan[];
121
+ checks?: InstructionCheck[];
122
+ postSendOwnerChange?: ShieldFlowOwnerChangeWait;
123
+ }
124
+ export interface ShieldFlowPlan {
125
+ kind: ShieldFlowKind;
126
+ user: PublicKey;
127
+ payer: PublicKey;
128
+ tokenMint: PublicKey;
129
+ amount: bigint;
130
+ transactions: ShieldFlowTransactionPlan[];
131
+ }
132
+ export interface ShieldFlowTransactionFeeEstimate {
133
+ index: number;
134
+ label: string;
135
+ cluster: FeeEstimateCluster;
136
+ feePayer: PublicKey;
137
+ blockhash: string;
138
+ lastValidBlockHeight: number;
139
+ instructionCount: number;
140
+ feeLamports: number;
141
+ rentLamports: number;
142
+ nativeLamports: number;
143
+ totalLamports: number;
144
+ instructions: InstructionCostEstimate[];
145
+ }
146
+ export interface ShieldFlowFeeEstimate {
147
+ kind: ShieldFlowKind;
148
+ user: PublicKey;
149
+ payer: PublicKey;
150
+ tokenMint: PublicKey;
151
+ amount: bigint;
152
+ totalFeeLamports: number;
153
+ totalRentLamports: number;
154
+ totalNativeLamports: number;
155
+ feeAndRentLamports: number;
156
+ totalLamports: number;
157
+ transactions: ShieldFlowTransactionFeeEstimate[];
158
+ instructions: InstructionCostEstimate[];
159
+ note: string;
160
+ }
161
+ export interface ShieldFlowTransactionExecutionResult {
162
+ index: number;
163
+ label: string;
164
+ cluster: FeeEstimateCluster;
165
+ signature: string;
166
+ }
167
+ export interface ShieldFlowExecutionResult {
168
+ kind: ShieldFlowKind;
169
+ user: PublicKey;
170
+ payer: PublicKey;
171
+ tokenMint: PublicKey;
172
+ amount: bigint;
173
+ signatures: ShieldFlowTransactionExecutionResult[];
174
+ }
19
175
  /**
20
176
  * RPC options for transactions
21
177
  */
@@ -48,11 +204,34 @@ export interface DepositData {
48
204
  amount: bigint;
49
205
  address: PublicKey;
50
206
  }
207
+ export interface KaminoReserveSnapshot {
208
+ reserve: PublicKey;
209
+ tokenMint: PublicKey;
210
+ liquidityDecimals: number;
211
+ collateralSupplyRaw: bigint;
212
+ totalLiquiditySupplyScaled: bigint;
213
+ collateralExchangeRateSf: bigint;
214
+ }
215
+ export interface KaminoTrackedBalanceCostBasis {
216
+ trackedShareAmountRaw: bigint;
217
+ trackedLiquidityAmountRaw: bigint;
218
+ }
219
+ export interface KaminoPositionYieldInfo {
220
+ reserve: PublicKey;
221
+ tokenMint: PublicKey;
222
+ liquidityDecimals: number;
223
+ shareAmountRaw: bigint;
224
+ currentLiquidityAmountRaw: bigint;
225
+ trackedShareAmountRaw: bigint | null;
226
+ trackedLiquidityAmountRaw: bigint | null;
227
+ currentTrackedLiquidityCostBasisRaw: bigint | null;
228
+ earnedLiquidityAmountRaw: bigint | null;
229
+ }
51
230
  /**
52
231
  * Data structure for a username-based deposit account
53
232
  */
54
233
  export interface UsernameDepositData {
55
- username: string;
234
+ usernameHash: number[];
56
235
  tokenMint: PublicKey;
57
236
  amount: bigint;
58
237
  address: PublicKey;
@@ -72,6 +251,23 @@ export interface InitializeUsernameDepositParams {
72
251
  payer: PublicKey;
73
252
  rpcOptions?: RpcOptions;
74
253
  }
254
+ export interface CloseDepositParams {
255
+ user: PublicKey;
256
+ tokenMint: PublicKey;
257
+ rpcOptions?: RpcOptions;
258
+ }
259
+ export interface CloseUsernameDepositParams {
260
+ username: string;
261
+ tokenMint: PublicKey;
262
+ authority: PublicKey;
263
+ session: PublicKey;
264
+ rpcOptions?: RpcOptions;
265
+ }
266
+ export interface ClosePermissionParams {
267
+ user: PublicKey;
268
+ tokenMint: PublicKey;
269
+ rpcOptions?: RpcOptions;
270
+ }
75
271
  /**
76
272
  * Parameters for modifying a deposit balance
77
273
  */
@@ -81,8 +277,8 @@ export interface ModifyBalanceParams {
81
277
  amount: number | bigint;
82
278
  increase: boolean;
83
279
  payer: PublicKey;
84
- userTokenAccount: PublicKey;
85
280
  rpcOptions?: RpcOptions;
281
+ passNotExist?: boolean;
86
282
  }
87
283
  /**
88
284
  * Result of a balance modification
@@ -91,6 +287,24 @@ export interface ModifyBalanceResult {
91
287
  signature: string;
92
288
  deposit: DepositData;
93
289
  }
290
+ export interface GetKaminoShieldedBalanceQuoteParams {
291
+ tokenMint: PublicKey;
292
+ collateralSharesAmountRaw: number | bigint;
293
+ principalLiquidityAmountRaw?: number | bigint | null;
294
+ shieldCollateralExchangeRateSf?: number | bigint | null;
295
+ }
296
+ export interface GetKaminoCollateralSharesForLiquidityAmountParams {
297
+ tokenMint: PublicKey;
298
+ liquidityAmountRaw: number | bigint;
299
+ }
300
+ export interface KaminoShieldedBalanceQuote {
301
+ snapshot: KaminoReserveSnapshot;
302
+ collateralSharesAmountRaw: bigint;
303
+ redeemableLiquidityAmountRaw: bigint;
304
+ principalLiquidityAmountRaw: bigint | null;
305
+ earnedLiquidityAmountRaw: bigint | null;
306
+ shieldCollateralExchangeRateSf: bigint | null;
307
+ }
94
308
  export interface ClaimUsernameDepositToDepositParams {
95
309
  username: string;
96
310
  tokenMint: PublicKey;
@@ -107,6 +321,7 @@ export interface CreatePermissionParams {
107
321
  tokenMint: PublicKey;
108
322
  payer: PublicKey;
109
323
  rpcOptions?: RpcOptions;
324
+ passNotExist?: boolean;
110
325
  }
111
326
  /**
112
327
  * Parameters for creating a permission for a username deposit
@@ -128,6 +343,7 @@ export interface DelegateDepositParams {
128
343
  payer: PublicKey;
129
344
  validator: PublicKey;
130
345
  rpcOptions?: RpcOptions;
346
+ passNotExist?: boolean;
131
347
  }
132
348
  /**
133
349
  * Parameters for delegating a username deposit to an ephemeral rollup
@@ -163,6 +379,11 @@ export interface UndelegateUsernameDepositParams {
163
379
  magicContext: PublicKey;
164
380
  rpcOptions?: RpcOptions;
165
381
  }
382
+ export interface UndelegatePermissionParams {
383
+ user: PublicKey;
384
+ tokenMint: PublicKey;
385
+ rpcOptions?: RpcOptions;
386
+ }
166
387
  /**
167
388
  * Parameters for transferring between user deposits
168
389
  */
@@ -0,0 +1,8 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ export declare function prettyStringify(obj: unknown): string;
3
+ export declare function waitForAccountOwnerChange(connection: Connection, account: PublicKey, expectedOwner: PublicKey, timeoutMs?: number, intervalMs?: number): {
4
+ wait: () => Promise<void>;
5
+ cancel: () => Promise<void>;
6
+ };
7
+ export declare function sha256hash(data: string): Promise<number[]>;
8
+ export declare function validateUsername(username: string): void;
@@ -0,0 +1,2 @@
1
+ import type { Keypair } from "@solana/web3.js";
2
+ export declare function createKeypairMessageSigner(keypair: Keypair): (message: Uint8Array) => Promise<Uint8Array>;
@@ -0,0 +1,14 @@
1
+ import { type PublicKey, type TransactionInstruction } from "@solana/web3.js";
2
+ export declare function wrapSolToWsolIx({ user, payer, lamports, }: {
3
+ user: PublicKey;
4
+ payer: PublicKey;
5
+ lamports: bigint;
6
+ }): TransactionInstruction[];
7
+ export declare function createWsolAta({ user, payer, }: {
8
+ user: PublicKey;
9
+ payer: PublicKey;
10
+ }): TransactionInstruction;
11
+ export declare function closeWsolAta({ user, destination, }: {
12
+ user: PublicKey;
13
+ destination: PublicKey;
14
+ }): TransactionInstruction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loyal-labs/private-transactions",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "SDK for Telegram-based private Solana deposits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,7 @@
38
38
  "license": "MIT",
39
39
  "repository": {
40
40
  "type": "git",
41
- "url": "https://github.com/loyal/loyal-app.git",
41
+ "url": "https://github.com/loyal-labs/loyal-app.git",
42
42
  "directory": "sdk/private-transactions"
43
43
  },
44
44
  "bugs": {
@@ -47,17 +47,17 @@
47
47
  "homepage": "https://github.com/loyal/loyal-app/tree/main/sdk/private-transactions#readme",
48
48
  "peerDependencies": {
49
49
  "@coral-xyz/anchor": "^0.32.0",
50
- "@magicblock-labs/ephemeral-rollups-sdk": "^0.8.5",
50
+ "@magicblock-labs/ephemeral-rollups-sdk": "^0.11.1",
51
51
  "@solana/spl-token": "^0.4.14",
52
52
  "@solana/web3.js": "^1.95.0"
53
53
  },
54
- "dependencies": {
55
- "tweetnacl": "^1.0.3"
56
- },
57
54
  "devDependencies": {
58
55
  "@coral-xyz/anchor": "^0.32.1",
59
56
  "@solana/web3.js": "^1.95.0",
60
57
  "@types/bun": "latest",
61
58
  "typescript": "^5"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
62
  }
63
63
  }