@hinkal/common 0.2.24 → 0.2.26
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 +270 -63
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +4 -4
- package/data-structures/Hinkal/Hinkal.mjs +17 -8
- package/data-structures/Hinkal/IHinkal.d.ts +4 -4
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.d.ts +2 -2
- package/data-structures/Hinkal/hinkalDeposit.mjs +67 -65
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +46 -45
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +48 -47
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +86 -85
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +30 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,11 +5,17 @@ Hinkal is a privacy middleware and smart-contract SDK for public blockchains tha
|
|
|
5
5
|
The SDK allows wallets, dApps, and payment platforms to integrate protocol-level privacy on Ethereum, Solana, Polygon, Base, Arbitrum, and Optimis. It hides transaction history, wallet relationships, and asset flows on-chain while preserving public-chain finality and compliance.
|
|
6
6
|
|
|
7
7
|
With Hinkal SDK, developers can:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
• Enable private sends between public wallets
|
|
9
|
+
• Perform confidential payouts and settlements
|
|
10
|
+
• Route transactions through Hinkal’s privacy contracts without exposing sender, recipient, or amounts
|
|
11
|
+
• Maintain non-custodial control with optional compliance visibility via viewing keys
|
|
12
12
|
|
|
13
|
+
## Compatibility
|
|
14
|
+
|
|
15
|
+
| Environment | Supported | Notes |
|
|
16
|
+
| ----------- | --------- | -------------------------- |
|
|
17
|
+
| Node.js | ✅ | v18+ |
|
|
18
|
+
| Browser | ✅ | React, Next.js, vanilla JS |
|
|
13
19
|
|
|
14
20
|
## Installation
|
|
15
21
|
|
|
@@ -25,18 +31,24 @@ Or, yarn:
|
|
|
25
31
|
yarn add @hinkal/common
|
|
26
32
|
```
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Initialization
|
|
37
|
+
|
|
38
|
+
To begin using Hinkal in your application, you'll need to initialize the SDK with your preferred Web3 connection library. Hinkal supports multiple popular libraries out of the box, allowing seamless integration with your existing wallet connection setup.
|
|
29
39
|
|
|
30
|
-
|
|
40
|
+
Initializing the SDK creates a `Hinkal` object that encapsulates:
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
- The user's shielded balances
|
|
43
|
+
- Actions the user can perform, such as shielding (depositing), transfers, and swapping
|
|
44
|
+
- Cryptographic keys for privacy-preserving operations
|
|
33
45
|
|
|
34
46
|
**ethers.js:**
|
|
35
47
|
|
|
36
48
|
```typescript
|
|
37
49
|
import { prepareEthersHinkal } from '@hinkal/common/providers/prepareEthersHinkal';
|
|
38
50
|
// signer: ethers.Signer
|
|
39
|
-
const hinkal = await prepareEthersHinkal(signer);
|
|
51
|
+
const hinkal = await prepareEthersHinkal(signer, hinkalConfig);
|
|
40
52
|
```
|
|
41
53
|
|
|
42
54
|
**wagmi:**
|
|
@@ -44,128 +56,323 @@ const hinkal = await prepareEthersHinkal(signer);
|
|
|
44
56
|
```typescript
|
|
45
57
|
import { prepareWagmiHinkal } from '@hinkal/common/providers/prepareWagmiHinkal';
|
|
46
58
|
// connector: wagmi.Connector
|
|
47
|
-
//
|
|
48
|
-
const hinkal = await prepareWagmiHinkal(connector,
|
|
59
|
+
// wagmiConfig: wagmi.Config
|
|
60
|
+
const hinkal = await prepareWagmiHinkal(connector, wagmiConfig, hinkalConfig);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The `hinkalConfig` is defined as follows:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
type HinkalConfig = {
|
|
67
|
+
/** Disables caching in browser localStorage, storing data only in memory. Front-end only. Defaults to false. */
|
|
68
|
+
disableCaching?: boolean;
|
|
69
|
+
|
|
70
|
+
/** If true, allows caching in a file locally. Node.js only. Defaults to false. */
|
|
71
|
+
useFileCache?: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Path to the cache file used for storing temporary data. Node.js only.
|
|
75
|
+
* It should be a valid file path string. Defaults to hinkalCache.json in the current working directory.
|
|
76
|
+
*/
|
|
77
|
+
cacheFilePath?: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Indicator controlling wether the proof should be constructed remotely in secure enclave. Defaults to true.
|
|
81
|
+
*/
|
|
82
|
+
generateProofRemotely?: boolean;
|
|
83
|
+
};
|
|
49
84
|
```
|
|
50
85
|
|
|
51
|
-
|
|
86
|
+
### Shielded balance
|
|
52
87
|
|
|
53
|
-
|
|
88
|
+
Shielded balances are encrypted token holdings stored within the Hinkal protocol. Unlike regular blockchain balances that are publicly visible, shielded balances are hidden from external observers, providing privacy for your assets. After initializing the Hinkal object, you can access and calculate your shielded balances:
|
|
54
89
|
|
|
55
90
|
```typescript
|
|
56
|
-
const balances = await hinkal.getBalances();
|
|
91
|
+
const balances: Promise<Map<string, TokenBalance>> = await hinkal.getBalances();
|
|
57
92
|
```
|
|
58
93
|
|
|
59
|
-
|
|
94
|
+
This returns a map from token address to balance for all tokens held by the user, including ERC20 and ERC721 tokens.
|
|
95
|
+
|
|
96
|
+
### Shielding: depositing funds to the shielded balance
|
|
97
|
+
|
|
98
|
+
Shielding is the process of moving your tokens from a public blockchain address into a private, encrypted balance. Once shielded, your tokens are no longer visible on-chain to external observers. This provides privacy for your holdings and subsequent transactions.
|
|
60
99
|
|
|
61
100
|
A user can deposit funds to their shielded address using:
|
|
62
101
|
|
|
63
102
|
```typescript
|
|
64
|
-
function deposit(
|
|
103
|
+
function deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], preEstimateGas?: boolean): Promise<ethers.providers.TransactionResponse>;
|
|
65
104
|
```
|
|
66
105
|
|
|
67
|
-
where
|
|
106
|
+
where:
|
|
68
107
|
|
|
69
|
-
|
|
108
|
+
- `erc20Tokens` is an array of tokens to deposit
|
|
109
|
+
- `amountChanges` represents the corresponding token amounts for the deposit
|
|
110
|
+
- `preEstimateGas` If true (default), the gas needed for the operation will be estimated before executing the deposit. This can help avoid failed transactions due to "out of gas" error.
|
|
70
111
|
|
|
71
|
-
|
|
112
|
+
The `ERC20Token` type is defined as follows:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
type ERC20Token = {
|
|
116
|
+
chainId: number;
|
|
117
|
+
erc20TokenAddress: string;
|
|
118
|
+
name: string;
|
|
119
|
+
symbol: string;
|
|
120
|
+
decimals: number;
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Private Send to Public Address: withdrawing funds from the shielded balance
|
|
125
|
+
|
|
126
|
+
Private Send to Public Address allows you to send tokens from your private, shielded balance directly to any public blockchain address. The sender's identity is not exposed during this transaction. The recipient receives the funds at their public address, where the tokens become visible on-chain. This is useful when you need to interact with public DeFi protocols, send funds to exchanges, or transfer to any public wallet while maintaining privacy for your shielded balance.
|
|
127
|
+
|
|
128
|
+
A user can withdraw funds from their shielded address to a public address using:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
function withdraw(
|
|
132
|
+
erc20Tokens: ERC20Token[],
|
|
133
|
+
deltaAmounts: bigint[],
|
|
134
|
+
recipientAddress: string,
|
|
135
|
+
isRelayerOff: boolean,
|
|
136
|
+
): Promise<string>;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
where:
|
|
140
|
+
|
|
141
|
+
- `recipientAddress` is the public address that will receive the withdrawn funds
|
|
142
|
+
- `isRelayerOff` determines whether to use a relayer for the transaction (when `false`, a relayer handles gas fees; when `true`, the user pays gas directly)
|
|
143
|
+
- `string` type represents the transaction response from the relayer service.
|
|
144
|
+
|
|
145
|
+
### Private Send to Private Address: transfering funds from shielded balance
|
|
146
|
+
|
|
147
|
+
Private Send to Private Address enables fully confidential transfers between shielded balances. Both the sender and recipient remain anonymous, and the transaction amount is hidden from external observers. This is the most private way to transfer tokens, as neither party's identity nor the transaction details are exposed on-chain.
|
|
148
|
+
|
|
149
|
+
A user can transfer tokens from their shielded balance to another shielded address using:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
function transfer(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], privateRecipientAddress: string): Promise<string>;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
where:
|
|
156
|
+
|
|
157
|
+
- `privateRecipientAddress` is the recipient's private address, formatted as a comma-separated string with five components:
|
|
158
|
+
- `randomization` - a random value for privacy
|
|
159
|
+
- `stealthAddress` - the recipient's stealth address (hex format starting with `0x`)
|
|
160
|
+
- `encryptionKey` - the recipient's encryption key (hex format starting with `0x`, 66 characters)
|
|
161
|
+
- `H0` - the first hash component of elliptic curve point for stealth address derivation
|
|
162
|
+
- `H1` - the second hash component of elliptic curve point for stealth address derivation
|
|
163
|
+
|
|
164
|
+
### Private Send from Public to Public addresses
|
|
165
|
+
|
|
166
|
+
Private Send from Public to Public addresses enables you to transfer tokens between two public addresses while using Hinkal's privacy infrastructure. The tokens are first shielded from the sender's public address, then unshielded to the recipient's public address either immediately or after some interval. This ensures there is no traceable connection between the sender and recipient on-chain, providing transaction privacy even when both parties use public addresses.
|
|
167
|
+
|
|
168
|
+
A user can perform a private transfer between public addresses using:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
function depositAndWithdraw(
|
|
172
|
+
erc20Token: ERC20Token,
|
|
173
|
+
recipientAmounts: bigint[],
|
|
174
|
+
recipientAddresses: string[],
|
|
175
|
+
txCompletionTime?: number,
|
|
176
|
+
preEstimateGas?: boolean
|
|
177
|
+
): Promise<string>;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
where:
|
|
181
|
+
|
|
182
|
+
- `erc20Token` is the token to transfer (only single token transfers are supported for this method)
|
|
183
|
+
- `recipientAmounts` is an array of amounts to send to each recipient (in the token's smallest unit)
|
|
184
|
+
- `recipientAddresses` is an array of public addresses that will receive the funds
|
|
185
|
+
- `txCompletionTime` (optional) specifies a delay in milliseconds before the withdrawal completes
|
|
186
|
+
- `preEstimateGas` If true (default), the gas needed for the operation will be estimated before executing the deposit. This can help avoid failed transactions due to "out of gas" error.
|
|
187
|
+
|
|
188
|
+
### Swapping tokens from the shielded balance
|
|
189
|
+
|
|
190
|
+
Swapping allows you to exchange tokens directly from your shielded balance without revealing your identity. The swap is executed through integrated DEX protocols (Uniswap, 1Inch, Odos) while keeping your transaction private. Your tokens are withdrawn from your shielded balance, swapped through the specified protocol, and the resulting tokens are deposited back into your shielded balance—all in a single private transaction.
|
|
191
|
+
|
|
192
|
+
A user can swap tokens directly from their shielded balance using:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
function swap(
|
|
196
|
+
erc20Tokens: ERC20Token[],
|
|
197
|
+
deltaAmounts: bigint[],
|
|
198
|
+
externalActionId: ExternalActionId,
|
|
199
|
+
swapData: string,
|
|
200
|
+
): Promise<string>;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
where:
|
|
204
|
+
|
|
205
|
+
- `externalActionId` identifies the external swap protocol to use. Possible values include:
|
|
206
|
+
- `ExternalActionId.Uniswap` - for Uniswap swaps
|
|
207
|
+
- `ExternalActionId.OneInch` - for 1Inch swaps
|
|
208
|
+
- `ExternalActionId.Odos` - for Odos swaps
|
|
209
|
+
- `swapData` contains the encoded swap parameters specific to the chosen protocol
|
|
210
|
+
|
|
211
|
+
**Getting swap calldata:**
|
|
212
|
+
|
|
213
|
+
To obtain the swap calldata using the Hinkal SDK, you can use the built-in swap data generation utilities.
|
|
214
|
+
|
|
215
|
+
To get swap data for 1Inch, you can use the `getOneInchPrice` function. This function fetches a quote from the 1Inch aggregator and returns both the expected output amount and the encoded swap data that can be passed to the `swap` function:
|
|
216
|
+
|
|
217
|
+
**1Inch:**
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
function getOneInchPrice(
|
|
221
|
+
chainId: number,
|
|
222
|
+
inSwapToken: ERC20Token,
|
|
223
|
+
outSwapToken: ERC20Token,
|
|
224
|
+
inSwapAmount: string,
|
|
225
|
+
slippagePercentage?: number,
|
|
226
|
+
): Promise<{
|
|
227
|
+
outSwapAmountValue: bigint;
|
|
228
|
+
oneInchDataValue: string;
|
|
229
|
+
}>;
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Similar functions are available for other supported swap protocols:
|
|
233
|
+
|
|
234
|
+
- **Uniswap:** `getUniswapPrice`
|
|
235
|
+
- **Odos:** `getOdosPrice`
|
|
236
|
+
- **LiFi:** `getLifiPrice`
|
|
237
|
+
|
|
238
|
+
### Interacting with smart contracts privately
|
|
239
|
+
|
|
240
|
+
The SDK lets you interact with any smart contract on the blockchain while keeping your identity private. When you initiate a private wallet action, your funds are first unshielded from your Hinkal shielded balance to an intermediary called an Emporium contract. The Emporium then executes your desired actions on-chain (such as swaps, staking, or other DeFi interactions) without exposing who initiated them. After the operations complete, the resulting tokens are automatically shielded back into your Hinkal shielded balance. This means you can use DeFi protocols, NFT marketplaces, or any other smart contract while maintaining full anonymity.
|
|
72
241
|
|
|
73
242
|
```typescript
|
|
74
243
|
function actionPrivateWallet(
|
|
75
|
-
|
|
76
|
-
|
|
244
|
+
chainId: number,
|
|
245
|
+
erc20Tokens: ERC20Token[],
|
|
246
|
+
deltaAmounts: bigint[],
|
|
77
247
|
onChainCreation: boolean[],
|
|
78
248
|
ops: string[],
|
|
79
|
-
): Promise<
|
|
249
|
+
): Promise<string>;
|
|
80
250
|
```
|
|
81
251
|
|
|
82
|
-
|
|
252
|
+
Parameters:
|
|
83
253
|
|
|
84
|
-
|
|
254
|
+
- `chainId` - the blockchain network identifier
|
|
255
|
+
- `onChainCreation` - array of booleans indicating the direction of token changes: `true` for positive changes (tokens received), `false` for negative changes (tokens spent)
|
|
256
|
+
- `ops` - array of encoded user operations to execute (see User operations below)
|
|
257
|
+
|
|
258
|
+
User operations (`ops`) are encoded instructions that tell the Emporium contract what actions to perform. Each operation specifies a target contract, the function to call, and any necessary parameters. For example, to stake ETH with Lido, you would create an operation that calls Lido's `submit` function with the appropriate value.
|
|
259
|
+
|
|
260
|
+
To generate user operations, a user will need the `emporiumOp` function.
|
|
85
261
|
|
|
86
|
-
To generate user operations (`ops`) you will need the `emporiumOp` function.
|
|
87
262
|
```typescript
|
|
88
|
-
|
|
263
|
+
function emporiumOp(
|
|
264
|
+
contract: ethers.Contract | string;
|
|
265
|
+
func?: string;
|
|
266
|
+
args?: any[];
|
|
267
|
+
callDataString?: string;
|
|
268
|
+
invokeWallet?: boolean;
|
|
269
|
+
value?: bigint;
|
|
270
|
+
): Promise<string>;
|
|
89
271
|
```
|
|
90
272
|
|
|
91
273
|
The function accepts the following arguments:
|
|
92
|
-
1. `endpoint` *(required)* - target address or contract instance (with address). The contract instance will be used to properly encode the call function, if any, in the custom operation.
|
|
93
|
-
2. `func` *(optional)* - the name of the function to be called on the target address.
|
|
94
|
-
3. `args` *(optional)* - arguments of the function to be called on the target address.
|
|
95
|
-
4. `invokeWallet` *(optional)* - bool flag that determines the type of transaction. There are two types: stateful and stateless interaction. The default is false (stateless).
|
|
96
|
-
5. `value` *(optional)* - the amount of native currency to transfer to the target address.
|
|
97
274
|
|
|
98
|
-
|
|
275
|
+
1. `contract` _(required)_ - target address or contract instance (with address). The contract instance will be used to properly encode the call function, if any, in the custom operation.
|
|
276
|
+
2. `func` _(optional)_ - the name of the function to be called on the target address.
|
|
277
|
+
3. `args` _(optional)_ - arguments of the function to be called on the target address.
|
|
278
|
+
4. `callDataString` _(optional)_ - pre-encoded calldata string. If provided, `func` and `args` should not be used.
|
|
279
|
+
5. `invokeWallet` _(optional)_ - boolean flag that determines the type of interaction (see the stateless/stateful interactions below).
|
|
280
|
+
6. `value` _(optional)_ - the value field to the user operation call.
|
|
281
|
+
|
|
282
|
+
When the Emporium contract executes a user operation, it receives the data in this format:
|
|
99
283
|
|
|
100
|
-
To execute on a smart contract, the user operation will be received in the following format:
|
|
101
284
|
```solidity
|
|
102
285
|
(address endpoint, bool invokeWallet, uint256 value, bytes data)
|
|
103
286
|
```
|
|
104
287
|
|
|
105
|
-
This
|
|
288
|
+
This enables the Emporium contract to execute generic calls using user operations:
|
|
289
|
+
|
|
106
290
|
```solidity
|
|
107
291
|
(bool success, bytes memory err) = endpoint.call{value: value}(data);
|
|
108
292
|
```
|
|
109
293
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
The best way to demonstrate how this works is with an example.
|
|
294
|
+
User operations can be categorized into two types based on whether the target protocol needs to track the caller account's history:
|
|
113
295
|
|
|
114
|
-
**Stateless
|
|
296
|
+
**Stateless interactions** are operations where the resulting token amount changes depend only on the calldata provided. Two different accounts executing the same calldata should receive the same result, regardless of their transaction history. Examples include token swaps, liquidity provision, and simple staking operations.
|
|
115
297
|
|
|
116
|
-
|
|
298
|
+
For example, consider exchanging USDC for ETH using a DEX. To perform a swap, the DEX does not need to know historical data about the caller (e.g., when and what swaps have been performed from his account in the past). It only needs to know how much token to swap and the exchange rate.
|
|
117
299
|
|
|
118
300
|
```typescript
|
|
119
301
|
const operations = [
|
|
120
|
-
emporiumOp(usdcContractInstance, 'approve', [swapRouterAddress, amountIn]),
|
|
121
|
-
emporiumOp(swapRouterContractInstance, 'exactInputSingle', [swapSingleParams]),
|
|
122
|
-
emporiumOp(wethContractInstance, 'withdraw', [amountOut]),
|
|
302
|
+
emporiumOp({ contract: usdcContractInstance, func: 'approve', args: [swapRouterAddress, amountIn] }),
|
|
303
|
+
emporiumOp({ contract: swapRouterContractInstance, func: 'exactInputSingle', args: [swapSingleParams] }),
|
|
304
|
+
emporiumOp({ contract: wethContractInstance, func: 'withdraw', args: [amountOut] }),
|
|
123
305
|
];
|
|
124
306
|
```
|
|
125
307
|
|
|
126
|
-
|
|
308
|
+
In this example:
|
|
127
309
|
|
|
128
|
-
|
|
310
|
+
- First operation approves the swap router to spend USDC tokens
|
|
311
|
+
- Second operation executes the swap from USDC to WETH
|
|
312
|
+
- Third operation unwraps WETH to ETH
|
|
129
313
|
|
|
130
|
-
**Stateful
|
|
314
|
+
**Stateful interactions** are operations where the target protocol needs to track the account's history for future calculations, such as staking rewards, voting power, or checkpoints. In these cases, set `invokeWallet: true` to ensure the operation is executed from a persistent wallet address that the protocol can track.
|
|
131
315
|
|
|
132
|
-
|
|
316
|
+
Consider a scenario where you have already staked Curve LP tokens and want to claim your rewards. The gauge contract needs to track your staking history to calculate accumulated rewards, so it must recognize the same wallet address across multiple interactions.
|
|
133
317
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```solidity
|
|
318
|
+
```typescript
|
|
137
319
|
const operations = [
|
|
138
|
-
emporiumOp(lpTokenInstance, 'approve', [gaugeAddressInstance, amount]
|
|
139
|
-
emporiumOp(
|
|
320
|
+
emporiumOp({ contract: lpTokenInstance, func: 'approve', args: [gaugeAddressInstance, amount], invokeWallet: true }),
|
|
321
|
+
emporiumOp({
|
|
322
|
+
contract: gaugeAddressInstance,
|
|
323
|
+
func: 'deposit',
|
|
324
|
+
args: [amount, invokeWalletAddress],
|
|
325
|
+
invokeWallet: true,
|
|
326
|
+
}),
|
|
140
327
|
];
|
|
141
328
|
```
|
|
142
329
|
|
|
143
|
-
|
|
330
|
+
In this example:
|
|
331
|
+
|
|
332
|
+
- First operation approves the gauge contract to spend LP tokens, executed from the persistent wallet
|
|
333
|
+
- Second operation deposits LP tokens into the gauge, with the wallet address as the recipient for reward tracking
|
|
144
334
|
|
|
145
|
-
|
|
335
|
+
## Access Tokens
|
|
146
336
|
|
|
147
|
-
|
|
337
|
+
Access tokens are required credentials that allow users to interact with Hinkal's privacy smart contracts. Think of them as a "passport" that proves you've completed the necessary compliance verification.
|
|
148
338
|
|
|
149
|
-
|
|
339
|
+
Before you can deposit funds, make transfers, or perform any private transactions through Hinkal, you must have a valid access token associated with your wallet. This is a one-time requirement—once you have an access token, you can use Hinkal's features without needing to verify again.
|
|
340
|
+
|
|
341
|
+
To check whether a user already has an access token on a specific chain, use the `checkAccessToken` function:
|
|
150
342
|
|
|
151
343
|
```typescript
|
|
152
344
|
function checkAccessToken(): Promise<boolean>;
|
|
153
345
|
```
|
|
154
346
|
|
|
155
|
-
If the user does not have an access token, they
|
|
347
|
+
If the user does not have an access token, they need to complete a compliance verification through one of Hinkal's supported compliance providers. This is a one-time process that verifies the user meets regulatory requirements before they can use the privacy features.
|
|
348
|
+
|
|
349
|
+
To get a list of all available compliance providers that can be used for verification:
|
|
156
350
|
|
|
157
351
|
```typescript
|
|
158
352
|
function getSupportedPassportLinks(): string[];
|
|
159
353
|
```
|
|
160
354
|
|
|
161
|
-
After passing the compliance check, the user
|
|
355
|
+
After passing the compliance check with one of the supported providers, the access token will be automatically minted during the user's first transaction with Hinkal. This token is stored on-chain and grants the user permission to interact with Hinkal's privacy contracts.
|
|
162
356
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
357
|
+
## Supported Chains
|
|
358
|
+
|
|
359
|
+
Hinkal SDK is available on the following blockchain networks:
|
|
360
|
+
|
|
361
|
+
| Chain | Chain ID | Status |
|
|
362
|
+
| -------- | -------- | -------------- |
|
|
363
|
+
| Ethereum | 1 | ✅ Live |
|
|
364
|
+
| Polygon | 137 | ✅ Live |
|
|
365
|
+
| Base | 8453 | ✅ Live |
|
|
366
|
+
| Arbitrum | 42161 | ✅ Live |
|
|
367
|
+
| Optimism | 10 | ✅ Live |
|
|
368
|
+
| Solana | - | 🚧 In Progress |
|
|
369
|
+
|
|
370
|
+
Each chain supports the full suite of Hinkal privacy features including shielding, transfers, and confidential interactions with DeFi protocols.
|
|
371
|
+
|
|
372
|
+
## References
|
|
373
|
+
|
|
374
|
+
Wallet: [Hinkal Wallet](https://chromewebstore.google.com/detail/hinkal-wallet/khfjgapjfcdoffmklchibpepboholpbe)
|
|
167
375
|
|
|
168
|
-
|
|
376
|
+
Application: [Private Send](https://send.hinkal.io)
|
|
169
377
|
|
|
170
|
-
|
|
171
|
-
Docs: [Hinkal Documentation](https://hinkal-team.gitbook.io/hinkal)
|
|
378
|
+
Docs: [Hinkal Documentation](https://hinkal-team.gitbook.io/hinkal)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),A=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),B=require("./hinkalDepositAndWithdraw.cjs"),w=require("./hinkalSolanaDeposit.cjs"),K=require("./hinkalSwap.cjs"),U=require("./hinkalWithdraw.cjs"),L=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ne=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ae=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ye=require("./hinkalDepostAndBridge.cjs");class Se{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new A.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new A.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new A.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,n=!1,a,s=!1){return W.getShieldedBalance(this,e,t,r,i,n,this.generateProofRemotely,a,s)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,n,a=!1){const s=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,l=await this.getBalances(s,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,n,a),p=!h.isSolanaLike(s)&&!a?await this.getApprovedBalances(i,n):new Map,d=_.isExtension?await ie.privateTokensDB.getPrivateTokens(s,o):ne.getErc20TokensForChain(s),u=[];return d.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=l.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t,r){return(await this.getTotalBalance(e,t,r,!1,!1,!0)).filter(n=>n.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(s,a),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(s,a),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(BigInt(e)!==this.merkleTreeHinkal.getRootHash()||BigInt(t)!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:n,hinkalAddress:a,originalDeployer:s}=h.networkRegistry[r].contractData;if(!n||!a||!s)throw new Error("missing solana data");const o=this.getSolanaProgram(n),c=new g.PublicKey(s);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t){return I.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return I.hinkalDepositForOther(this,e,t,r)}async depositAndWithdraw(e,t,r,i,n,a){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,n,a):B.hinkalDepositAndWithdraw(this,e,t,r,i,n,a)}async depositAndBridge(e,t,r,i,n){return ye.hinkalDepositAndBridge(this,e,t,r,i,n)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return w.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return w.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return w.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,n,a,s=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,n,s):he.hinkalTransfer(this,e,t,r,i,n,a,s)}async withdraw(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,n,a,o):U.hinkalWithdraw(this,e,t,r,i,n,a,s,o)}async withdrawStuckUtxos(e,t){return L.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,n,a,s,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,n,a,o):K.hinkalSwap(this,e,t,r,i,n,a,s,o,c)}async swapSolana(e,t,r,i,n,a=!1){const s=JSON.parse(r),o=BigInt(s.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=s.data;return ge.hinkalSolanaSwap(this,e,t,o,c,l,i,n,a)}async actionReceive(e,t,r,i,n,a,s=!1){if(!n)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],n,void 0,s):te.hinkalActionReceive(this,e,t,r,i,n,a,s)}async actionFundApproveAndTransact(e,t,r,i,n,a,s,o,c=!1,l,p,d){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,n,a,s,o,c,l,p,d)}async actionPrivateWallet(e,t,r,i,n,a,s,o,c,l=!1,p,d,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,n,a,s,o,c,l,p,d,u,k)}async approve(e,t,r,i,n,a=!1){return Y.hinkalApprove(this,e,t,r,i,n,a)}async hinkalInsideTransact(e,t,r,i,n,a,s,o,c,l=!1){return Z.hinkalInsideTransact(this,e,t,r,i,n,a,s,o,c,l)}async proxySwap(e,t,r,i,n,a,s,o,c=!1,l,p,d=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,a,s,o,d):oe.hinkalProxySwap(this,e,t,r,i,n,a,s,o,c,l,p,d)}async proxyToPrivate(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,n,a,r,s,o)}async proxySend(e,t,r,i,n,a,s,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ae.createTransaferEmporiumOpsBatch(this,e.map(d=>d.erc20TokenAddress),t,i),l=e.map((d,u)=>({token:d,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,l,r,n,a,void 0,void 0,void 0,s,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=Se;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),A=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),B=require("./hinkalDepositAndWithdraw.cjs"),w=require("./hinkalSolanaDeposit.cjs"),K=require("./hinkalSwap.cjs"),U=require("./hinkalWithdraw.cjs"),L=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ne=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ae=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ye=require("./hinkalDepostAndBridge.cjs");class Se{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new A.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new A.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new A.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,n=!1,a,s=!1){return W.getShieldedBalance(this,e,t,r,i,n,this.generateProofRemotely,a,s)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,n,a=!1){const s=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,l=await this.getBalances(s,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,n,a),p=!h.isSolanaLike(s)&&!a?await this.getApprovedBalances(i,n):new Map,d=_.isExtension?await ie.privateTokensDB.getPrivateTokens(s,o):ne.getErc20TokensForChain(s),u=[];return d.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=l.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t,r){return(await this.getTotalBalance(e,t,r,!1,!1,!0)).filter(n=>n.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(s,a),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(s,a),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(BigInt(e)!==this.merkleTreeHinkal.getRootHash()||BigInt(t)!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:n,hinkalAddress:a,originalDeployer:s}=h.networkRegistry[r].contractData;if(!n||!a||!s)throw new Error("missing solana data");const o=this.getSolanaProgram(n),c=new g.PublicKey(s);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t,r=!0){return I.hinkalDeposit(this,e,t,r)}async depositForOther(e,t,r,i=!0){return I.hinkalDepositForOther(this,e,t,r,i)}async depositAndWithdraw(e,t,r,i,n,a,s=!0){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,n,a):B.hinkalDepositAndWithdraw(this,e,t,r,i,n,a,s)}async depositAndBridge(e,t,r,i,n,a=!0){return ye.hinkalDepositAndBridge(this,e,t,r,i,n,a)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return w.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return w.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return w.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,n,a,s=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,n,s):he.hinkalTransfer(this,e,t,r,i,n,a,s)}async withdraw(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,n,a,o):U.hinkalWithdraw(this,e,t,r,i,n,a,s,o)}async withdrawStuckUtxos(e,t){return L.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,n,a,s,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,n,a,o):K.hinkalSwap(this,e,t,r,i,n,a,s,o,c)}async swapSolana(e,t,r,i,n,a=!1){const s=JSON.parse(r),o=BigInt(s.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=s.data;return ge.hinkalSolanaSwap(this,e,t,o,c,l,i,n,a)}async actionReceive(e,t,r,i,n,a,s=!1){if(!n)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],n,void 0,s):te.hinkalActionReceive(this,e,t,r,i,n,a,s)}async actionFundApproveAndTransact(e,t,r,i,n,a,s,o,c=!1,l,p,d){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,n,a,s,o,c,l,p,d)}async actionPrivateWallet(e,t,r,i,n,a,s,o,c,l=!1,p,d,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,n,a,s,o,c,l,p,d,u,k)}async approve(e,t,r,i,n,a=!1){return Y.hinkalApprove(this,e,t,r,i,n,a)}async hinkalInsideTransact(e,t,r,i,n,a,s,o,c,l=!1){return Z.hinkalInsideTransact(this,e,t,r,i,n,a,s,o,c,l)}async proxySwap(e,t,r,i,n,a,s,o,c=!1,l,p,d=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,a,s,o,d):oe.hinkalProxySwap(this,e,t,r,i,n,a,s,o,c,l,p,d)}async proxyToPrivate(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,n,a,r,s,o)}async proxySend(e,t,r,i,n,a,s,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ae.createTransaferEmporiumOpsBatch(this,e.map(d=>d.erc20TokenAddress),t,i),l=e.map((d,u)=>({token:d,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,l,r,n,a,void 0,void 0,void 0,s,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=Se;
|
|
@@ -92,10 +92,10 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
92
92
|
getMyApprovalAmountForInteraction(interactionAddress: string, tokenAddress: string): bigint;
|
|
93
93
|
checkExistingApprovalFromHinkal(erc20Address: string, interactionAddress: string): Promise<bigint>;
|
|
94
94
|
getBufferEntry(approveTo: string, tokenAddress: string, inHinkalAddress: bigint): Promise<bigint>;
|
|
95
|
-
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[]): Promise<ethers.ContractTransaction>;
|
|
96
|
-
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientInfo: string): Promise<ethers.ContractTransaction>;
|
|
97
|
-
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string): Promise<string>;
|
|
98
|
-
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string): Promise<string>;
|
|
95
|
+
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], preEstimateGas?: boolean): Promise<ethers.ContractTransaction>;
|
|
96
|
+
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientInfo: string, preEstimateGas?: boolean): Promise<ethers.ContractTransaction>;
|
|
97
|
+
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, preEstimateGas?: boolean): Promise<string>;
|
|
98
|
+
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, preEstimateGas?: boolean): Promise<string>;
|
|
99
99
|
prooflessDeposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructures?: StealthAddressStructure[]): Promise<ethers.ContractTransaction>;
|
|
100
100
|
getSolanaProgram(idl: Idl): Program;
|
|
101
101
|
getSolanaPublicKey(): PublicKey;
|
|
@@ -365,13 +365,13 @@ class cr {
|
|
|
365
365
|
async getBufferEntry(e, t, r) {
|
|
366
366
|
return se(this, e, t, r);
|
|
367
367
|
}
|
|
368
|
-
async deposit(e, t) {
|
|
369
|
-
return b(this, e, t);
|
|
368
|
+
async deposit(e, t, r = !0) {
|
|
369
|
+
return b(this, e, t, r);
|
|
370
370
|
}
|
|
371
|
-
async depositForOther(e, t, r) {
|
|
372
|
-
return W(this, e, t, r);
|
|
371
|
+
async depositForOther(e, t, r, i = !0) {
|
|
372
|
+
return W(this, e, t, r, i);
|
|
373
373
|
}
|
|
374
|
-
async depositAndWithdraw(e, t, r, i, a, n) {
|
|
374
|
+
async depositAndWithdraw(e, t, r, i, a, n, o = !0) {
|
|
375
375
|
return p(this.getCurrentChainId()) ? Se(
|
|
376
376
|
this,
|
|
377
377
|
e.erc20TokenAddress,
|
|
@@ -387,11 +387,20 @@ class cr {
|
|
|
387
387
|
r,
|
|
388
388
|
i,
|
|
389
389
|
a,
|
|
390
|
-
n
|
|
390
|
+
n,
|
|
391
|
+
o
|
|
391
392
|
);
|
|
392
393
|
}
|
|
393
|
-
async depositAndBridge(e, t, r, i, a) {
|
|
394
|
-
return Fe(
|
|
394
|
+
async depositAndBridge(e, t, r, i, a, n = !0) {
|
|
395
|
+
return Fe(
|
|
396
|
+
this,
|
|
397
|
+
e,
|
|
398
|
+
t,
|
|
399
|
+
r,
|
|
400
|
+
i,
|
|
401
|
+
a,
|
|
402
|
+
n
|
|
403
|
+
);
|
|
395
404
|
}
|
|
396
405
|
async prooflessDeposit(e, t, r) {
|
|
397
406
|
return ve(this, e, t, r);
|
|
@@ -61,10 +61,10 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
61
61
|
getMyApprovalAmountForInteraction(interactionAddress: string, tokenAddress: string): bigint;
|
|
62
62
|
checkExistingApprovalFromHinkal(erc20Address: string, interactionAddress: string): Promise<bigint>;
|
|
63
63
|
getBufferEntry(approveTo: string, tokenAddress: string, inHinkalAddress: bigint): Promise<bigint>;
|
|
64
|
-
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[]): Promise<ethers.ContractTransaction>;
|
|
65
|
-
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recepinetInfo: string): Promise<ethers.ContractTransaction>;
|
|
66
|
-
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string): Promise<string>;
|
|
67
|
-
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string): Promise<string>;
|
|
64
|
+
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], preEstimateGas?: boolean): Promise<ethers.ContractTransaction>;
|
|
65
|
+
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recepinetInfo: string, preEstimateGas?: boolean): Promise<ethers.ContractTransaction>;
|
|
66
|
+
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, preEstimateGas?: boolean): Promise<string>;
|
|
67
|
+
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, preEstimateGas?: boolean): Promise<string>;
|
|
68
68
|
prooflessDeposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructures?: StealthAddressStructure[]): Promise<ethers.ContractTransaction>;
|
|
69
69
|
getSolanaProgram(idl: Idl): Program;
|
|
70
70
|
getSolanaPublicKey(): PublicKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../constants/protocol.constants.cjs"),h=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),q=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),F=require("../../functions/web3/events/getShieldedBalance.cjs"),I=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),P=require("../utxo/Utxo.cjs"),R=require("../../error-handling/error-codes.constants.cjs");require("../../types/circom-data.types.cjs");const M=require("../../types/ethereum-network.types.cjs"),S=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const _=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),z=require("../../functions/utils/addresses.cjs"),H=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),O=require("../../functions/utils/time.utils.cjs"),U=require("../../API/admin-calls.cjs"),K=require("../../functions/pre-transaction/constructAdminData.cjs"),E=async(t,s,e)=>{const{patchAccessTokenMerkleTree:n,kycRequired:o,hasAccessToken:r}=await H.shouldPatchAccessTokenMerkleTree(t,s,e),c=void 0,A=await t.getEthereumAddress(),l=await _.getSignatureDataForTransact(t.getCurrentChainId(),A,t.userKeys,o,r),i={externalActionId:0n,externalAddress:await t.getEthereumAddress(),externalActionMetadata:"0x00"};return{signatureData:l,externalActionData:i,contractTransaction:c,contractToApprove:c,patchAccessTokenMerkleTree:n}},b=async(t,s,e,n=!0)=>{const o=s.map(a=>a.erc20TokenAddress),{externalActionData:r,contractTransaction:c,contractToApprove:A,patchAccessTokenMerkleTree:l,signatureData:i}=await E(t,o,e),p=[...await F.addPaddingToUtxos(t,o,e)],T=`swapperM${e.length.toString()}x${p[0].length}x1`,d=[],m=O.getCurrentTimeInSeconds().toString();for(let a=0;a<o.length;a+=1){const{outputUtxos:C}=h.outputUtxoProcessing(t.userKeys,p[a],e[a],m);d.push(C)}const{zkCallData:x,circomData:g,dimData:y}=await q.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,p,d,t.userKeys,T,r.externalActionId,r.externalAddress,r.externalActionMetadata,t.generateProofRemotely,w.zeroAddress,t.getCurrentChainId(),void 0,void 0,void 0,l,void 0,void 0,void 0,t.getContractWithFetcher(M.ContractType.HinkalHelperContract),i),D=await I.transactCallDirect(t,e,s,x,g,y,A,c,n),v=K.constructAdminData(S.AdminTransactionType.Onboarding,t.getCurrentChainId(),o,e,await t.getEthereumAddress());return U.emitTxPublicData(t.getCurrentChainId(),v),D},N=async(t,s,e,n,o=!0)=>{const r=s.map(u=>u.erc20TokenAddress),[c,A,l]=n.split(",");if(!z.isValidPrivateAddress(n))throw Error(R.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const i=r.map(u=>[new P.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()}),new P.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()})]),p=`swapperM${e.length.toString()}x${i[0].length}x1`,T=r.map((u,f)=>[new P.Utxo({amount:e[f],erc20TokenAddress:u,randomization:BigInt(c),stealthAddress:A,encryptionKey:l})]),{externalActionData:d,contractTransaction:m,contractToApprove:x,patchAccessTokenMerkleTree:g}=await E(t,r,e),{zkCallData:y,circomData:D,dimData:v}=await q.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,i,T,t.userKeys,p,d.externalActionId,d.externalAddress,d.externalActionMetadata,t.generateProofRemotely,w.zeroAddress,t.getCurrentChainId(),void 0,void 0,void 0,g,void 0,void 0,void 0,t.getContractWithFetcher(M.ContractType.HinkalHelperContract)),a=await I.transactCallDirect(t,e,s,y,D,v,x,m,o),C=K.constructAdminData(S.AdminTransactionType.PaymentLink,t.getCurrentChainId(),r,e,await t.getEthereumAddress());return U.emitTxPublicData(t.getCurrentChainId(),C),a};exports.hinkalDeposit=b;exports.hinkalDepositForOther=N;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
2
|
import { ERC20Token } from '../../types';
|
|
3
|
-
export declare const hinkalDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[]) => Promise<any>;
|
|
4
|
-
export declare const hinkalDepositForOther: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], recipinetInfo: string) => Promise<any>;
|
|
3
|
+
export declare const hinkalDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], preEstimateGas?: boolean) => Promise<any>;
|
|
4
|
+
export declare const hinkalDepositForOther: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], recipinetInfo: string, preEstimateGas?: boolean) => Promise<any>;
|