@mistcash/config 0.5.0 → 0.5.2

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.
@@ -0,0 +1,19 @@
1
+
2
+ 
3
+ > @mistcash/config@0.5.1 build /Users/shramee/www/crypto/mono/sdk/config
4
+ > tsup src/index.ts --format cjs,esm --dts
5
+
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.5.0
9
+ CLI Target: es2020
10
+ CJS Build start
11
+ ESM Build start
12
+ CJS dist/index.js 26.72 KB
13
+ CJS ⚡️ Build success in 47ms
14
+ ESM dist/index.mjs 25.58 KB
15
+ ESM ⚡️ Build success in 47ms
16
+ DTS Build start
17
+ DTS ⚡️ Build success in 705ms
18
+ DTS dist/index.d.ts 20.85 KB
19
+ DTS dist/index.d.mts 20.85 KB
package/dist/index.d.mts CHANGED
@@ -95,7 +95,7 @@ declare const CHAMBER_ABI: readonly [{
95
95
  readonly name: "claiming_key";
96
96
  readonly type: "core::integer::u256";
97
97
  }, {
98
- readonly name: "recipient";
98
+ readonly name: "owner";
99
99
  readonly type: "core::starknet::contract_address::ContractAddress";
100
100
  }, {
101
101
  readonly name: "asset";
@@ -113,7 +113,7 @@ declare const CHAMBER_ABI: readonly [{
113
113
  readonly name: "claiming_key";
114
114
  readonly type: "core::integer::u256";
115
115
  }, {
116
- readonly name: "recipient";
116
+ readonly name: "owner";
117
117
  readonly type: "core::starknet::contract_address::ContractAddress";
118
118
  }, {
119
119
  readonly name: "asset";
package/dist/index.d.ts CHANGED
@@ -95,7 +95,7 @@ declare const CHAMBER_ABI: readonly [{
95
95
  readonly name: "claiming_key";
96
96
  readonly type: "core::integer::u256";
97
97
  }, {
98
- readonly name: "recipient";
98
+ readonly name: "owner";
99
99
  readonly type: "core::starknet::contract_address::ContractAddress";
100
100
  }, {
101
101
  readonly name: "asset";
@@ -113,7 +113,7 @@ declare const CHAMBER_ABI: readonly [{
113
113
  readonly name: "claiming_key";
114
114
  readonly type: "core::integer::u256";
115
115
  }, {
116
- readonly name: "recipient";
116
+ readonly name: "owner";
117
117
  readonly type: "core::starknet::contract_address::ContractAddress";
118
118
  }, {
119
119
  readonly name: "asset";
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ __export(index_exports, {
29
29
  module.exports = __toCommonJS(index_exports);
30
30
 
31
31
  // src/contracts.ts
32
- var CHAMBER_ADDR_MAINNET = process.env.CHAMBER_ADDR_MAINNET || "0x03a889eb7aecedcb76b987fc981ad3b92689cf45bffec8c1c409a4b0b79c3f31";
32
+ var CHAMBER_ADDR_MAINNET = process.env.CHAMBER_ADDR_MAINNET || "0x06f8dcc500131b6be6b33f4534ec6d33df33e61083ec2b051555d52e75654444";
33
33
  var CHAMBER_ABI = [
34
34
  {
35
35
  "type": "impl",
@@ -160,7 +160,7 @@ var CHAMBER_ABI = [
160
160
  "type": "core::integer::u256"
161
161
  },
162
162
  {
163
- "name": "recipient",
163
+ "name": "owner",
164
164
  "type": "core::starknet::contract_address::ContractAddress"
165
165
  },
166
166
  {
@@ -184,7 +184,7 @@ var CHAMBER_ABI = [
184
184
  "type": "core::integer::u256"
185
185
  },
186
186
  {
187
- "name": "recipient",
187
+ "name": "owner",
188
188
  "type": "core::starknet::contract_address::ContractAddress"
189
189
  },
190
190
  {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/contracts.ts
2
- var CHAMBER_ADDR_MAINNET = process.env.CHAMBER_ADDR_MAINNET || "0x03a889eb7aecedcb76b987fc981ad3b92689cf45bffec8c1c409a4b0b79c3f31";
2
+ var CHAMBER_ADDR_MAINNET = process.env.CHAMBER_ADDR_MAINNET || "0x06f8dcc500131b6be6b33f4534ec6d33df33e61083ec2b051555d52e75654444";
3
3
  var CHAMBER_ABI = [
4
4
  {
5
5
  "type": "impl",
@@ -130,7 +130,7 @@ var CHAMBER_ABI = [
130
130
  "type": "core::integer::u256"
131
131
  },
132
132
  {
133
- "name": "recipient",
133
+ "name": "owner",
134
134
  "type": "core::starknet::contract_address::ContractAddress"
135
135
  },
136
136
  {
@@ -154,7 +154,7 @@ var CHAMBER_ABI = [
154
154
  "type": "core::integer::u256"
155
155
  },
156
156
  {
157
- "name": "recipient",
157
+ "name": "owner",
158
158
  "type": "core::starknet::contract_address::ContractAddress"
159
159
  },
160
160
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistcash/config",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  "module": "dist/index.mjs",
19
19
  "types": "dist/index.d.ts",
20
20
  "dependencies": {
21
- "starknet": "^8.9.0"
21
+ "starknet": "^9.2.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/jest": "^29.5.0",
package/readme.md CHANGED
@@ -1,25 +1,313 @@
1
1
  # @mistcash/config
2
2
 
3
- MIST SDK config
3
+ Configuration package for MIST SDK providing contract ABIs, addresses, and token definitions for the Starknet ecosystem.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
7
+ ```bash
8
+ npm install @mistcash/config
9
+ # or
8
10
  pnpm add @mistcash/config
11
+ # or
12
+ yarn add @mistcash/config
9
13
  ```
10
14
 
11
- ## Usage
15
+ ## Overview
12
16
 
13
- ```js
14
- import { CHAMBER_ABI, CHAMBER_ADDR_MAINNET, ChamberTypedContract } from '@mistcash/config';
17
+ This package exports:
18
+ - **Contract ABIs**: Chamber and ERC20 contract interfaces
19
+ - **Contract Addresses**: Mainnet addresses for MIST contracts
20
+ - **Token Definitions**: Supported tokens with metadata
21
+ - **TypeScript Types**: Fully typed contract interfaces
15
22
 
16
- // Do something with the ABIs and other config data
23
+ ## Contract ABIs & Addresses
24
+
25
+ ### Chamber Contract
26
+
27
+ The main MIST protocol contract for private transactions.
28
+
29
+ #### `CHAMBER_ADDR_MAINNET`
30
+
31
+ The Chamber contract address on Starknet mainnet.
32
+
33
+ ```typescript
34
+ import { CHAMBER_ADDR_MAINNET } from '@mistcash/config';
35
+
36
+ console.log(CHAMBER_ADDR_MAINNET);
37
+ // '0x06f8dcc500131b6be6b33f4534ec6d33df33e61083ec2b051555d52e75654444'
38
+ ```
39
+
40
+ **Type:** `0x${string}`
41
+
42
+ **Environment Variable:** Can be overridden with `CHAMBER_ADDR_MAINNET` environment variable.
43
+
44
+ ---
45
+
46
+ #### `CHAMBER_ABI`
47
+
48
+ Complete ABI for the Chamber contract including all functions and events.
49
+
50
+ ```typescript
51
+ import { CHAMBER_ABI } from '@mistcash/config';
52
+ import { Contract } from 'starknet';
53
+
54
+ const chamber = new Contract({
55
+ abi: CHAMBER_ABI,
56
+ address: CHAMBER_ADDR_MAINNET,
57
+ provider
58
+ });
59
+ ```
60
+
61
+ **Key Functions in Chamber ABI:**
62
+
63
+ - `deposit(hash: u256, asset: Asset)` - Deposit tokens into the chamber
64
+ - `withdraw_no_zk(claiming_key, owner, asset, proof)` - Withdraw without ZK proof
65
+ - `seek_and_hide_no_zk(claiming_key, owner, asset, proof, new_tx_secret, new_tx_amount)` - Transfer without ZK
66
+ - `handle_zkp(proof: Span<felt252>)` - Process ZK proof for private transactions
67
+ - `tx_array()` - Get all transaction leaves
68
+ - `merkle_root()` - Get current Merkle root
69
+ - `merkle_proof(index: u32)` - Get Merkle proof for transaction at index
70
+ - `merkle_leaves(height: u32)` - Get leaves at specific tree height
71
+ - `assets_from_secret(tx_secret: u256)` - Retrieve asset info from transaction secret
72
+ - `nullifiers_spent(nullifiers: Array<u256>)` - Check if nullifiers have been spent
73
+ - `transactions_exist(transactions: Array<u256>)` - Check if transactions exist
74
+ - `setVerifierAddress(verifier)` - Set the Groth16 verifier contract address
75
+ - `recalculate_merkle_root()` - Recalculate Merkle root from leaves
76
+
77
+ ---
78
+
79
+ #### `ChamberTypedContract`
80
+
81
+ TypeScript type for the typed Chamber contract interface.
82
+
83
+ ```typescript
84
+ import { ChamberTypedContract, CHAMBER_ABI, CHAMBER_ADDR_MAINNET } from '@mistcash/config';
85
+ import { Contract, ProviderInterface } from 'starknet';
86
+
87
+ function getChamber(provider: ProviderInterface): ChamberTypedContract {
88
+ return new Contract({
89
+ abi: CHAMBER_ABI,
90
+ address: CHAMBER_ADDR_MAINNET,
91
+ provider
92
+ }).typedv2(CHAMBER_ABI);
93
+ }
17
94
  ```
18
95
 
19
- ## Contributing
96
+ **Type:** `TypedContractV2<typeof CHAMBER_ABI>`
20
97
 
21
- Head over to https://github.com/mistcash/sdk for details.
98
+ ---
99
+
100
+ ### ERC20 Contract
101
+
102
+ Standard ERC20 token ABI for Starknet.
103
+
104
+ #### `ERC20_ABI`
105
+
106
+ Complete ERC20 ABI following OpenZeppelin standards.
107
+
108
+ ```typescript
109
+ import { ERC20_ABI } from '@mistcash/config';
110
+ import { Contract } from 'starknet';
111
+
112
+ const token = new Contract({
113
+ abi: ERC20_ABI,
114
+ address: tokenAddress,
115
+ provider
116
+ });
117
+
118
+ const balance = await token.balance_of(userAddress);
119
+ ```
120
+
121
+ **Key Functions:**
122
+
123
+ - `total_supply()` - Get total token supply
124
+ - `balance_of(account)` - Get account balance
125
+ - `allowance(owner, spender)` - Get spending allowance
126
+ - `transfer(recipient, amount)` - Transfer tokens
127
+ - `transfer_from(sender, recipient, amount)` - Transfer from approved account
128
+ - `approve(spender, amount)` - Approve spending allowance
129
+ - `name()` - Get token name
130
+ - `symbol()` - Get token symbol
131
+ - `decimals()` - Get token decimals
132
+
133
+ ---
134
+
135
+ ## Token Definitions
136
+
137
+ ### Token Interface
138
+
139
+ ```typescript
140
+ interface Token {
141
+ id: string; // Contract address (hex string)
142
+ name: string; // Token symbol (e.g., 'ETH', 'USDC')
143
+ icon?: string; // SVG icon markup
144
+ color: string; // Primary color for UI
145
+ textColor: string; // Text color for contrast
146
+ decimals?: number; // Token decimal places
147
+ }
148
+ ```
149
+
150
+ ---
151
+
152
+ ### `tokensData`
153
+
154
+ Array of supported tokens with metadata.
155
+
156
+ ```typescript
157
+ import { tokensData } from '@mistcash/config';
158
+
159
+ tokensData.forEach(token => {
160
+ console.log(`${token.name}: ${token.id}`);
161
+ });
162
+ ```
163
+
164
+ **Included Tokens Details:**
165
+
166
+ MIST supports any ERC20 token, but here are popular ones for convenience
167
+
168
+ | Name | Address | Decimals | Color |
169
+ | ---- | ------------------------------------------------------------------ | -------- | ----------- |
170
+ | ETH | 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 | 18 | #5f7edd |
171
+ | STRK | 0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d | 18 | #EC796B |
172
+ | USDC | 0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8 | 6 | #2775ca |
173
+ | USDT | 0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8 | 6 | transparent |
174
+ | DAI | 0x00da114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3 | 18 | #F4B731 |
175
+
176
+ ---
177
+
178
+ ### `tokensMap`
179
+
180
+ Map of token addresses to token objects for quick lookups.
181
+
182
+ ```typescript
183
+ import { tokensMap } from '@mistcash/config';
184
+
185
+ const tokenAddress = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
186
+ const token = tokensMap[tokenAddress];
187
+
188
+ console.log(token.name); // 'ETH'
189
+ console.log(token.decimals); // 18
190
+ console.log(token.color); // '#5f7edd'
191
+ ```
192
+
193
+ **Type:** `{ [key: string]: Token }`
194
+
195
+ ---
196
+
197
+ ## Complete Usage Example
198
+
199
+ ```typescript
200
+ import {
201
+ CHAMBER_ABI,
202
+ CHAMBER_ADDR_MAINNET,
203
+ ChamberTypedContract,
204
+ ERC20_ABI,
205
+ tokensData,
206
+ tokensMap,
207
+ Token
208
+ } from '@mistcash/config';
209
+ import { Contract, RpcProvider } from 'starknet';
210
+
211
+ // Setup provider
212
+ const provider = new RpcProvider({
213
+ nodeUrl: 'https://starknet-mainnet.public.blastapi.io'
214
+ });
215
+
216
+ // Get typed Chamber contract
217
+ const chamber: ChamberTypedContract = new Contract({
218
+ abi: CHAMBER_ABI,
219
+ address: CHAMBER_ADDR_MAINNET,
220
+ provider
221
+ }).typedv2(CHAMBER_ABI);
222
+
223
+ // Use chamber contract
224
+ const txArray = await chamber.tx_array();
225
+ const merkleRoot = await chamber.merkle_root();
226
+
227
+ // Work with tokens
228
+ const ethToken = tokensMap['0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7'];
229
+ console.log(`${ethToken.name} has ${ethToken.decimals} decimals`);
230
+
231
+ // Get ERC20 contract
232
+ const erc20 = new Contract({
233
+ abi: ERC20_ABI,
234
+ address: ethToken.id,
235
+ provider
236
+ });
237
+
238
+ const balance = await erc20.balance_of(userAddress);
239
+ ```
240
+
241
+ ## UI Integration
242
+
243
+ The token data includes SVG icons and colors for easy UI integration:
244
+
245
+ ```tsx
246
+ import { tokensData } from '@mistcash/config';
247
+
248
+ function TokenSelector() {
249
+ return (
250
+ <div>
251
+ {tokensData.map(token => (
252
+ <div
253
+ key={token.id}
254
+ style={{
255
+ backgroundColor: token.color,
256
+ color: token.textColor
257
+ }}
258
+ >
259
+ {token.icon && (
260
+ <div dangerouslySetInnerHTML={{ __html: token.icon }} />
261
+ )}
262
+ <span>{token.name}</span>
263
+ </div>
264
+ ))}
265
+ </div>
266
+ );
267
+ }
268
+ ```
269
+
270
+ ## TypeScript Support
271
+
272
+ All exports are fully typed for excellent TypeScript support:
273
+
274
+ ```typescript
275
+ import type { Token, ChamberTypedContract } from '@mistcash/config';
276
+
277
+ // Token operations are type-safe
278
+ const processToken = (token: Token) => {
279
+ const amount = BigInt(1000) * BigInt(10 ** (token.decimals || 18));
280
+ return amount;
281
+ };
282
+
283
+ // Contract calls are type-checked
284
+ const queryContract = async (contract: ChamberTypedContract) => {
285
+ const root = await contract.merkle_root(); // Returns bigint
286
+ const leaves = await contract.tx_array(); // Returns bigint[]
287
+ };
288
+ ```
289
+
290
+ ## Environment Variables
291
+
292
+ - `CHAMBER_ADDR_MAINNET`: Override the default Chamber contract address
293
+
294
+ ```bash
295
+ # .env
296
+ CHAMBER_ADDR_MAINNET=0x1234567890abcdef...
297
+ ```
298
+
299
+ ## Dependencies
300
+
301
+ - `starknet` ^9.2.1 - Starknet.js library for contract interactions
22
302
 
23
303
  ## License
24
304
 
25
305
  MIT
306
+
307
+ ## Repository
308
+
309
+ https://github.com/mistcash/sdk
310
+
311
+ ## Issues
312
+
313
+ https://github.com/mistcash/sdk/issues
package/src/contracts.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Abi, TypedContractV2 } from 'starknet';
2
2
 
3
3
  export const CHAMBER_ADDR_MAINNET = (process.env.CHAMBER_ADDR_MAINNET ||
4
- '0x03a889eb7aecedcb76b987fc981ad3b92689cf45bffec8c1c409a4b0b79c3f31') as `0x${string}`;
4
+ '0x06f8dcc500131b6be6b33f4534ec6d33df33e61083ec2b051555d52e75654444') as `0x${string}`;
5
5
 
6
6
  export const CHAMBER_ABI = [
7
7
  {
@@ -133,7 +133,7 @@ export const CHAMBER_ABI = [
133
133
  "type": "core::integer::u256"
134
134
  },
135
135
  {
136
- "name": "recipient",
136
+ "name": "owner",
137
137
  "type": "core::starknet::contract_address::ContractAddress"
138
138
  },
139
139
  {
@@ -157,7 +157,7 @@ export const CHAMBER_ABI = [
157
157
  "type": "core::integer::u256"
158
158
  },
159
159
  {
160
- "name": "recipient",
160
+ "name": "owner",
161
161
  "type": "core::starknet::contract_address::ContractAddress"
162
162
  },
163
163
  {
package/src/tokens.ts CHANGED
@@ -7,6 +7,7 @@ export interface Token {
7
7
  decimals?: number;
8
8
  }
9
9
 
10
+ // MIST supports any ERC20 token, but here are popular ones for convenience
10
11
  export const tokensData: Token[] = [
11
12
  {
12
13
  id: '0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',