@loyal-labs/private-transactions 0.2.8 → 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.
- package/README.md +69 -35
- package/dist/index.d.ts +66 -2
- package/dist/index.js +2349 -350
- package/dist/src/LoyalPrivateTransactionsClient.d.ts +15 -3
- package/dist/src/actions/shieldTokens.d.ts +69 -0
- package/dist/src/actions/undelegateDeposit.d.ts +25 -0
- package/dist/src/actions/unshieldTokens.d.ts +62 -0
- package/dist/src/checks/enshureChecks.d.ts +5 -0
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/enumerate-deposits.d.ts +23 -0
- package/dist/src/fee-estimate.d.ts +25 -0
- package/dist/src/idl/telegram_private_transfer.d.ts +119 -3
- package/dist/src/instructions/closeDeposit.d.ts +4 -0
- package/dist/src/instructions/closePermission.d.ts +2 -0
- package/dist/src/instructions/closeUsernameDeposit.d.ts +4 -0
- package/dist/src/instructions/createPermission.d.ts +4 -0
- package/dist/src/instructions/delegateDeposit.d.ts +4 -0
- package/dist/src/instructions/initializeDeposit.d.ts +4 -0
- package/dist/src/instructions/initializeUsernameDeposit.d.ts +4 -0
- package/dist/src/instructions/modifyBalance.d.ts +4 -0
- package/dist/src/instructions/undelegateDeposit.d.ts +4 -0
- package/dist/src/instructions/undelegatePermission.d.ts +2 -0
- package/dist/src/kamino.d.ts +1 -1
- package/dist/src/rent-estimate.d.ts +46 -0
- package/dist/src/transaction-debug.d.ts +40 -0
- package/dist/src/types.d.ts +182 -2
- package/dist/src/utils.d.ts +7 -0
- package/dist/src/wsol.d.ts +14 -0
- package/package.json +6 -3
package/dist/src/types.d.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -95,6 +251,23 @@ export interface InitializeUsernameDepositParams {
|
|
|
95
251
|
payer: PublicKey;
|
|
96
252
|
rpcOptions?: RpcOptions;
|
|
97
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
|
+
}
|
|
98
271
|
/**
|
|
99
272
|
* Parameters for modifying a deposit balance
|
|
100
273
|
*/
|
|
@@ -104,8 +277,8 @@ export interface ModifyBalanceParams {
|
|
|
104
277
|
amount: number | bigint;
|
|
105
278
|
increase: boolean;
|
|
106
279
|
payer: PublicKey;
|
|
107
|
-
userTokenAccount: PublicKey;
|
|
108
280
|
rpcOptions?: RpcOptions;
|
|
281
|
+
passNotExist?: boolean;
|
|
109
282
|
}
|
|
110
283
|
/**
|
|
111
284
|
* Result of a balance modification
|
|
@@ -148,6 +321,7 @@ export interface CreatePermissionParams {
|
|
|
148
321
|
tokenMint: PublicKey;
|
|
149
322
|
payer: PublicKey;
|
|
150
323
|
rpcOptions?: RpcOptions;
|
|
324
|
+
passNotExist?: boolean;
|
|
151
325
|
}
|
|
152
326
|
/**
|
|
153
327
|
* Parameters for creating a permission for a username deposit
|
|
@@ -169,6 +343,7 @@ export interface DelegateDepositParams {
|
|
|
169
343
|
payer: PublicKey;
|
|
170
344
|
validator: PublicKey;
|
|
171
345
|
rpcOptions?: RpcOptions;
|
|
346
|
+
passNotExist?: boolean;
|
|
172
347
|
}
|
|
173
348
|
/**
|
|
174
349
|
* Parameters for delegating a username deposit to an ephemeral rollup
|
|
@@ -204,6 +379,11 @@ export interface UndelegateUsernameDepositParams {
|
|
|
204
379
|
magicContext: PublicKey;
|
|
205
380
|
rpcOptions?: RpcOptions;
|
|
206
381
|
}
|
|
382
|
+
export interface UndelegatePermissionParams {
|
|
383
|
+
user: PublicKey;
|
|
384
|
+
tokenMint: PublicKey;
|
|
385
|
+
rpcOptions?: RpcOptions;
|
|
386
|
+
}
|
|
207
387
|
/**
|
|
208
388
|
* Parameters for transferring between user deposits
|
|
209
389
|
*/
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1 +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
|
+
};
|
|
1
7
|
export declare function sha256hash(data: string): Promise<number[]>;
|
|
8
|
+
export declare function validateUsername(username: string): void;
|
|
@@ -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.
|
|
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,7 +47,7 @@
|
|
|
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.
|
|
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
|
},
|
|
@@ -56,5 +56,8 @@
|
|
|
56
56
|
"@solana/web3.js": "^1.95.0",
|
|
57
57
|
"@types/bun": "latest",
|
|
58
58
|
"typescript": "^5"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
59
62
|
}
|
|
60
63
|
}
|