emblem-vault-sdk 2.3.5 → 3.0.0-experimental

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.traces/blockchain-provider-abstraction-plan.md +302 -0
  2. package/.traces/notes.md +43 -0
  3. package/.traces/readme-verification-trace.md +988 -0
  4. package/.traces/test-migration-status.md +227 -0
  5. package/.traces/tests-consolidated-trace.md +667 -0
  6. package/dist/abi/abi.json +53 -0
  7. package/dist/bundle.js +21604 -17422
  8. package/dist/clients/emblemVaultSolanaWalletClient.d.ts +74 -0
  9. package/dist/clients/emblemVaultSolanaWalletClient.js +149 -0
  10. package/dist/clients/emblemVaultSolanaWalletClient.js.map +1 -0
  11. package/dist/clients/emblemVaultWalletClient.d.ts +52 -0
  12. package/dist/clients/emblemVaultWalletClient.js +110 -0
  13. package/dist/clients/emblemVaultWalletClient.js.map +1 -0
  14. package/dist/derive.js +7 -0
  15. package/dist/derive.js.map +1 -0
  16. package/dist/index.js +321 -117
  17. package/dist/index.js.map +1 -0
  18. package/dist/providers/ProviderManager.d.ts +57 -0
  19. package/dist/providers/ProviderManager.js +283 -0
  20. package/dist/providers/ProviderManager.js.map +1 -0
  21. package/dist/providers.d.ts +101 -0
  22. package/dist/providers.js +96 -0
  23. package/dist/providers.js.map +1 -0
  24. package/dist/types.js +1 -0
  25. package/dist/types.js.map +1 -0
  26. package/dist/utils.js +61 -58
  27. package/dist/utils.js.map +1 -0
  28. package/docs/bundle.js +21604 -17422
  29. package/docs/index.html +150 -13
  30. package/docs/local.html +385 -0
  31. package/docs/steps.html +420 -53
  32. package/package.json +22 -13
  33. package/readme.md +795 -21
  34. package/src/abi/abi.json +54 -1
  35. package/src/clients/emblemVaultSolanaWalletClient.ts +257 -0
  36. package/src/clients/emblemVaultWalletClient.ts +159 -0
  37. package/src/derive.ts +5 -5
  38. package/src/index.ts +322 -106
  39. package/src/providers/ProviderManager.ts +254 -0
  40. package/src/providers.ts +163 -0
  41. package/src/types.ts +50 -0
  42. package/src/utils.ts +63 -62
  43. package/test/.mocharc.js +8 -0
  44. package/test/README.md +212 -0
  45. package/test/fixtures/ethscriptions/balance-with-native-first.json +24 -0
  46. package/test/fixtures/ethscriptions/balance-with-native.json +23 -0
  47. package/test/fixtures/ethscriptions/balance.json +18 -0
  48. package/test/helpers/sdkLoader.js +88 -0
  49. package/test/helpers/setup.js +55 -0
  50. package/test/integration/ApiOperations.spec.js +102 -0
  51. package/test/integration/VaultAI.spec.js +57 -0
  52. package/test/integration/VaultCreation.spec.js +95 -0
  53. package/test/mocks.js +127 -0
  54. package/test/tsconfig.json +25 -0
  55. package/test/unit/AllowedBells.spec.js +53 -0
  56. package/test/unit/AllowedBitcoinDeGods.spec.js +53 -0
  57. package/test/unit/AllowedBitcoinOrdinals.spec.js +46 -0
  58. package/test/unit/AllowedCounterparty.spec.js +66 -0
  59. package/test/unit/AllowedCursedOrdinals.spec.js +68 -0
  60. package/test/unit/AllowedEmbells.spec.js +11 -0
  61. package/test/unit/AllowedEmbels.spec.js +11 -0
  62. package/test/unit/AllowedEmblemOpen.spec.js +20 -0
  63. package/test/unit/AllowedEthscriptions.spec.js +53 -0
  64. package/test/unit/AllowedHardcodedNfts.spec.js +77 -0
  65. package/test/unit/AllowedNamecoin.spec.js +33 -0
  66. package/test/unit/AllowedOrdi.spec.js +46 -0
  67. package/test/unit/AllowedOxbt.spec.js +46 -0
  68. package/test/unit/AllowedProjectCollection.spec.js +51 -0
  69. package/test/unit/AllowedProtocolCollection.spec.js +44 -0
  70. package/test/unit/AllowedStamps.spec.js +78 -0
  71. package/test/unit/DarkfarmsMetadata.spec.js +10 -0
  72. package/test/unit/EmblemVaultSdk.spec.js +188 -0
  73. package/test/unit/Providers.spec.js +290 -0
  74. package/test/unit/ResourceMonitor.spec.js +111 -0
  75. package/test/unit/SDKMemoryLeaks.spec.js +176 -0
  76. package/test/unit/Signing.spec.js +321 -0
  77. package/test/unit/VaultAI.spec.js +140 -0
  78. package/test/unit/clients/EmblemVaultSolanaWalletClient.spec.js +296 -0
  79. package/test/unit/clients/EmblemVaultWalletClient.spec.js +246 -0
  80. package/test/utils/ResourceMonitor.js +169 -0
  81. package/test/windsurf-rules.md +68 -0
  82. package/tsconfig.json +7 -3
  83. package/types/derive.d.ts +0 -5
  84. package/types/index.d.ts +152 -33
  85. package/types/types.d.ts +43 -0
  86. package/types/utils.d.ts +7 -1
  87. package/dist/abi/quote.js +0 -29
  88. package/dist/abi/quote.json +0 -26
  89. package/jest.config.js +0 -6
  90. package/tests/AllowedBells.test.ts +0 -53
  91. package/tests/AllowedBitcoinDeGods.test.ts +0 -53
  92. package/tests/AllowedBitcoinOrdinals.test.ts +0 -46
  93. package/tests/AllowedCounterparty.test.ts +0 -45
  94. package/tests/AllowedCursedOrdinals.test.ts +0 -68
  95. package/tests/AllowedEmbells.test.ts +0 -12
  96. package/tests/AllowedEmbels.test.ts +0 -16
  97. package/tests/AllowedEmblemOpen.test.ts +0 -20
  98. package/tests/AllowedEthscriptions.test.ts +0 -39
  99. package/tests/AllowedHardcodedNfts.test.ts +0 -78
  100. package/tests/AllowedNamecoin.test.ts +0 -33
  101. package/tests/AllowedOrdi.test.ts +0 -47
  102. package/tests/AllowedOxbt.test.ts +0 -47
  103. package/tests/AllowedProjectlCollection.test.ts +0 -51
  104. package/tests/AllowedProtocolCollection.test.ts +0 -44
  105. package/tests/AllowedStamps.test.ts +0 -73
  106. package/tests/DarkfarmsMetadata.test.ts +0 -10
  107. package/tests/EmblemVaultSdk.test.ts +0 -124
  108. package/tests/fixtures/embels/balance.json +0 -10
  109. package/tests/fixtures/ethscriptions/balance-with-native-first.json +0 -69
  110. package/tests/fixtures/ethscriptions/balance-with-native.json +0 -37
  111. package/tests/fixtures/ethscriptions/balance.json +0 -64
  112. /package/{tests → test}/fixtures/bells/balance-with-non-bell-first.json +0 -0
  113. /package/{tests → test}/fixtures/bells/balance-with-non-bell.json +0 -0
  114. /package/{tests → test}/fixtures/bells/balance.json +0 -0
  115. /package/{tests → test}/fixtures/bitcoin-degods/balance-with-non-degods-first.json +0 -0
  116. /package/{tests → test}/fixtures/bitcoin-degods/balance-with-non-degods.json +0 -0
  117. /package/{tests → test}/fixtures/bitcoin-degods/balance.json +0 -0
  118. /package/{tests → test}/fixtures/bitcoin-ordinals/balance-with-native-first.json +0 -0
  119. /package/{tests → test}/fixtures/bitcoin-ordinals/balance-with-only-native.json +0 -0
  120. /package/{tests → test}/fixtures/bitcoin-ordinals/balance.json +0 -0
  121. /package/{tests → test}/fixtures/counterparty/balance-with-multiple.json +0 -0
  122. /package/{tests → test}/fixtures/counterparty/balance.json +0 -0
  123. /package/{tests → test}/fixtures/cursed-ordinals/balance-with-native-first.json +0 -0
  124. /package/{tests → test}/fixtures/cursed-ordinals/balance-with-native.json +0 -0
  125. /package/{tests → test}/fixtures/cursed-ordinals/balance.json +0 -0
  126. /package/{tests → test}/fixtures/dogeparty/balance-with-non-dogeparty-first.json +0 -0
  127. /package/{tests → test}/fixtures/dogeparty/balance-with-non-dogeparty.json +0 -0
  128. /package/{tests → test}/fixtures/dogeparty/balance.json +0 -0
  129. /package/{tests → test}/fixtures/emblem-open/balance.json +0 -0
  130. /package/{tests → test}/fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json +0 -0
  131. /package/{tests → test}/fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json +0 -0
  132. /package/{tests → test}/fixtures/hardcoded-nfts/balance.json +0 -0
  133. /package/{tests → test}/fixtures/megapunks/balance-with-non-megapunk-first.json +0 -0
  134. /package/{tests → test}/fixtures/megapunks/balance-with-non-megapunk.json +0 -0
  135. /package/{tests → test}/fixtures/megapunks/balance.json +0 -0
  136. /package/{tests → test}/fixtures/namecoin/balance-with-native-first.json +0 -0
  137. /package/{tests → test}/fixtures/namecoin/balance-with-native.json +0 -0
  138. /package/{tests → test}/fixtures/namecoin/balance.json +0 -0
  139. /package/{tests → test}/fixtures/ordi/balance-with-native-first.json +0 -0
  140. /package/{tests → test}/fixtures/ordi/balance-with-native.json +0 -0
  141. /package/{tests → test}/fixtures/ordi/balance.json +0 -0
  142. /package/{tests → test}/fixtures/oxbt/balance-with-native-first.json +0 -0
  143. /package/{tests → test}/fixtures/oxbt/balance-with-native.json +0 -0
  144. /package/{tests → test}/fixtures/oxbt/balance.json +0 -0
  145. /package/{tests → test}/fixtures/stamps/balance-with-non-stamps-first.json +0 -0
  146. /package/{tests → test}/fixtures/stamps/balance-with-non-stamps.json +0 -0
  147. /package/{tests → test}/fixtures/stamps/balance.json +0 -0
@@ -0,0 +1,667 @@
1
+ # Comprehensive Trace Documentation: Emblem Vault SDK Tests
2
+
3
+ This document provides a complete analysis of the Emblem Vault SDK test suite, including directory structure, test implementation, test failures, and recommendations for improvements.
4
+
5
+ ## Directory Structure
6
+ ```
7
+ /Users/shannoncode/repo/Emblem.Current/emblem-vault-sdk/tests/
8
+ ├── AllowedBells.test.ts
9
+ ├── AllowedBitcoinDeGods.test.ts
10
+ ├── AllowedBitcoinOrdinals.test.ts
11
+ ├── AllowedCounterparty.test.ts
12
+ ├── AllowedCursedOrdinals.test.ts
13
+ ├── AllowedEmbells.test.ts
14
+ ├── AllowedEmbels.test.ts
15
+ ├── AllowedEmblemOpen.test.ts
16
+ ├── AllowedEthscriptions.test.ts
17
+ ├── AllowedHardcodedNfts.test.ts
18
+ ├── AllowedNamecoin.test.ts
19
+ ├── AllowedOrdi.test.ts
20
+ ├── AllowedOxbt.test.ts
21
+ ├── AllowedProjectlCollection.test.ts
22
+ ├── AllowedProtocolCollection.test.ts
23
+ ├── AllowedStamps.test.ts
24
+ ├── DarkfarmsMetadata.test.ts
25
+ ├── EmblemVaultSdk.test.ts
26
+ └── fixtures/
27
+ ├── bells/
28
+ ├── bitcoin-degods/
29
+ ├── bitcoin-ordinals/
30
+ ├── counterparty/
31
+ ├── cursed-ordinals/
32
+ ├── dogeparty/
33
+ ├── embels/
34
+ ├── emblem-open/
35
+ ├── ethscriptions/
36
+ ├── hardcoded-nfts/
37
+ ├── megapunks/
38
+ ├── namecoin/
39
+ ├── ordi/
40
+ ├── oxbt/
41
+ └── stamps/
42
+ ```
43
+
44
+ ## Test Results Summary
45
+ - **Total Test Suites**: 18
46
+ - **Passed**: 14
47
+ - **Failed**: 4
48
+ - **Total Tests**: 94
49
+ - **Passed Tests**: 86
50
+ - **Failed Tests**: 6
51
+ - **Skipped Tests**: 2
52
+
53
+ ### Failed Tests:
54
+ 1. **AllowedCounterparty.test.ts**: Failure in "Allows any native coin" test
55
+ 2. **AllowedOrdi.test.ts**: Timeout in "Requires specific balance" test
56
+ 3. **AllowedStamps.test.ts**: Timeout in "Requires asset name to include `stamps`" test
57
+
58
+ ## SDK Core Functionality Analysis
59
+
60
+ The EmblemVaultSDK class (defined in `src/index.ts`) serves as the main entry point for interacting with the Emblem Vault ecosystem. Key components include:
61
+
62
+ ### 1. Initialization
63
+ ```typescript
64
+ constructor(private apiKey: string, baseUrl?: string, v3Url?: string, sigUrl?: string) {
65
+ console.log('EmblemVaultSDK version:', SDK_VERSION)
66
+ if (!apiKey) {
67
+ throw new Error('API key is required');
68
+ }
69
+ this.baseUrl = baseUrl || 'https://v2.emblemvault.io';
70
+ this.v3Url = v3Url || 'https://v3.emblemvault.io';
71
+ this.sigUrl = sigUrl || 'https://tor-us-signer-coval.vercel.app';
72
+ }
73
+ ```
74
+
75
+ The SDK requires an API key and optionally accepts custom URLs for different API endpoints.
76
+
77
+ ### 2. Core API Methods
78
+
79
+ The SDK provides several categories of methods:
80
+
81
+ #### Asset Metadata
82
+ - `getAssetMetadata`: Retrieves metadata for a specific project
83
+ - `getAllAssetMetadata`: Gets metadata for all assets
84
+ - `getRemoteAssetMetadata`: Fetches metadata from remote API
85
+
86
+ #### Curated Collections
87
+ - `fetchCuratedContracts`: Retrieves all curated collections
88
+ - `fetchCuratedContractByName`: Gets a specific collection by name
89
+ - `createCuratedVault`: Creates a new vault based on a template
90
+
91
+ #### Vault Operations
92
+ - `refreshOwnershipForTokenId`: Updates ownership data for a token
93
+ - `refreshOwnershipForAccount`: Updates ownership data for an account
94
+ - `fetchMetadata`: Gets metadata for a specific token
95
+ - `refreshBalance`: Updates and retrieves balance for a token
96
+ - `fetchVaultsOfType`: Gets vaults of a specific type for an address
97
+
98
+ #### Report Generation
99
+ - `generateJumpReport`: Creates a report of possible vault transitions
100
+ - `generateMintReport`: Generates a report of mintable vaults
101
+
102
+ ### 3. Validation Logic
103
+
104
+ The validation logic for different token types is implemented in the `utils.ts` file, specifically in the `generateTemplate` function. This function creates templates with validation rules for each curated collection.
105
+
106
+ ## File Analysis
107
+
108
+ <details>
109
+ <summary>EmblemVaultSdk.test.ts (line 1 of 5870)</summary>
110
+
111
+ This file contains the main tests for the EmblemVaultSDK class. It tests core functionality of the SDK.
112
+
113
+ Key observations:
114
+ - Tests the initialization of the SDK
115
+ - Tests version logging (currently shows "__SDK_VERSION__" placeholder)
116
+ - Tests core API methods like `fetchCuratedContracts`, `fetchMetadata`, and `fetchVaultsOfType`
117
+ - Contains skipped tests for vault creation functionality
118
+ - Uses mock data for testing templates
119
+
120
+ Test categories:
121
+ - **Non-Writing Tests**: Tests that don't modify data
122
+ - **Vault Creation Tests**: Tests that create vaults (currently skipped)
123
+
124
+ Current status: PASS
125
+ </details>
126
+
127
+ <details>
128
+ <summary>AllowedBitcoinDeGods.test.ts (line 1 of 2879)</summary>
129
+
130
+ Tests for the Bitcoin DeGods NFT collection validation.
131
+
132
+ Key observations:
133
+ - Tests the "allowed" function for DeGods NFTs
134
+ - Verifies that the correct balance and metadata are required
135
+ - Uses fixtures from tests/fixtures/bitcoin-degods/
136
+
137
+ Current status: PASS
138
+ </details>
139
+
140
+ <details>
141
+ <summary>AllowedBitcoinOrdinals.test.ts (line 1 of 2518)</summary>
142
+
143
+ Tests for Bitcoin Ordinals validation.
144
+
145
+ Key observations:
146
+ - Verifies that Bitcoin Ordinals are properly validated
147
+ - Checks for required metadata and balance values
148
+ - Uses fixtures from the ordinals directory
149
+
150
+ Current status: PASS
151
+ </details>
152
+
153
+ <details>
154
+ <summary>AllowedCounterparty.test.ts (line 1 of 2178)</summary>
155
+
156
+ Tests for Counterparty token validation.
157
+
158
+ Key observations:
159
+ - Tests native coin validation for Counterparty
160
+ - Currently FAILING on the "Allows any native coin" test
161
+ - Failure indicates that the validation function is returning false when it should return true
162
+
163
+ **Failure Details:**
164
+ - Test: "Allows any native coin"
165
+ - Error: `expect(received).toBeTruthy() - Received: false`
166
+ - Line: 33
167
+
168
+ **Root Cause:**
169
+ The Counterparty validation logic is commented out in the source code (utils.ts around line 326-335). The test expects the `allowed` function to return true when a native asset is provided, but since the implementation is commented out, it's likely defaulting to false.
170
+
171
+ ```typescript
172
+ // Commented out implementation in utils.ts:
173
+ // } else if (recordName == "Counterparty") {
174
+ // let facts = [
175
+ // {
176
+ // eval: record.nativeAssets.includes(data[0]?.coin),
177
+ // msg: `Vaults should only contain assets native to ${recordName}`
178
+ // },
179
+ // {eval: data.length == 1, msg: `Vaults should only contain a single item`},
180
+ // // { eval: data[0].projectName && data[0].projectName == recordName, msg: `Vaults should only contain a single item` }
181
+ // ]
182
+ // allowed = evaluateFacts(allowed, facts, msgCallback)
183
+ ```
184
+
185
+ Current status: FAIL
186
+ </details>
187
+
188
+ <details>
189
+ <summary>AllowedCursedOrdinals.test.ts (line 1 of 3677)</summary>
190
+
191
+ Tests for Cursed Ordinals NFT validation.
192
+
193
+ Key observations:
194
+ - Verifies the validation logic for Cursed Ordinals
195
+ - Checks for required metadata and balance
196
+
197
+ Current status: PASS
198
+ </details>
199
+
200
+ <details>
201
+ <summary>AllowedEmblemOpen.test.ts (line 1 of 837)</summary>
202
+
203
+ Tests for Emblem Open validation.
204
+
205
+ Key observations:
206
+ - Tests the validation logic for Emblem Open tokens
207
+ - Relatively simple test file compared to others
208
+
209
+ Current status: PASS
210
+ </details>
211
+
212
+ <details>
213
+ <summary>AllowedNamecoin.test.ts (line 1 of 1763)</summary>
214
+
215
+ Tests for Namecoin validation.
216
+
217
+ Key observations:
218
+ - Verifies the validation logic for Namecoin tokens
219
+ - Checks for required metadata and balance
220
+
221
+ Current status: PASS
222
+ </details>
223
+
224
+ <details>
225
+ <summary>AllowedOrdi.test.ts (line 1 of 2492)</summary>
226
+
227
+ Tests for $ORDI token validation.
228
+
229
+ Key observations:
230
+ - Tests the validation logic for $ORDI tokens
231
+ - Currently FAILING with a timeout in the "Requires specific balance" test
232
+ - The test is exceeding the 5000ms timeout limit
233
+
234
+ **Failure Details:**
235
+ - Test: "Requires specific balance"
236
+ - Error: "Exceeded timeout of 5000 ms for a test"
237
+ - Line: 14
238
+
239
+ **Root Cause:**
240
+ The test is timing out, which could be due to:
241
+ 1. An infinite loop or long-running operation in the validation logic
242
+ 2. A network request that's not completing
243
+ 3. A promise that's not being resolved
244
+
245
+ **Test Data:**
246
+ The test uses a fixture from `tests/fixtures/ordi/balance.json` which contains:
247
+ ```json
248
+ [
249
+ {
250
+ "coin": "ordi",
251
+ "name": "200 $ORDI",
252
+ "balance": "200",
253
+ "price": "0"
254
+ }
255
+ ]
256
+ ```
257
+
258
+ **Implementation in utils.ts:**
259
+ ```typescript
260
+ // From utils.ts around line 322:
261
+ else if (balanceQty && balanceQty > 0) { // $ORDI, $OXBT
262
+ allowed = firstAsset.balance == balanceQty && assetName == `${balanceQty} ${recordName}`
263
+ if (!allowed) {
264
+ message = `Load vault with exactly ${balanceQty} ${recordName}`
265
+ }
266
+ }
267
+ ```
268
+
269
+ Current status: FAIL
270
+ </details>
271
+
272
+ <details>
273
+ <summary>AllowedOxbt.test.ts (line 1 of 2492)</summary>
274
+
275
+ Tests for OXBT token validation.
276
+
277
+ Key observations:
278
+ - Verifies the validation logic for OXBT tokens
279
+ - Similar structure to other token validation tests
280
+
281
+ Current status: PASS
282
+ </details>
283
+
284
+ <details>
285
+ <summary>AllowedProjectlCollection.test.ts (line 1 of 2905)</summary>
286
+
287
+ Tests for Project Collection validation.
288
+
289
+ Key observations:
290
+ - Tests the validation logic for Project Collections
291
+ - Verifies that the correct metadata and balance are required
292
+
293
+ Current status: PASS
294
+ </details>
295
+
296
+ <details>
297
+ <summary>AllowedProtocolCollection.test.ts (line 1 of 2486)</summary>
298
+
299
+ Tests for Protocol Collection validation.
300
+
301
+ Key observations:
302
+ - Tests the validation logic for Protocol Collections
303
+ - Verifies that the correct metadata and balance are required
304
+
305
+ Current status: PASS
306
+ </details>
307
+
308
+ <details>
309
+ <summary>AllowedStamps.test.ts (line 1 of 3956)</summary>
310
+
311
+ Tests for Stamps validation.
312
+
313
+ Key observations:
314
+ - Tests the validation logic for Stamps
315
+ - Currently FAILING with a timeout in the "Requires asset name to include `stamps`" test
316
+ - The test is exceeding the 5000ms timeout limit
317
+
318
+ **Failure Details:**
319
+ - Test: "Requires asset name to include `stamps`"
320
+ - Error: "Exceeded timeout of 5000 ms for a test"
321
+ - Line: 14
322
+
323
+ **Root Cause:**
324
+ Similar to the $ORDI test, this test is timing out. The validation logic for Stamps in utils.ts is:
325
+
326
+ ```typescript
327
+ // From utils.ts around line 336:
328
+ else if (recordName == "Stamps") {
329
+ let allowedName = assetName.toLowerCase().includes("stamp")
330
+ allowed = allowedName &&
331
+ firstAsset.project &&
332
+ record.nativeAssets.includes(firstAsset.coin) &&
333
+ (recordName.toLowerCase() == firstAsset.project.toLowerCase() || firstAsset.project.toLowerCase() == "stampunks")
334
+ }
335
+ ```
336
+
337
+ **Test Data:**
338
+ The test uses a fixture from `tests/fixtures/stamps/balance.json` which contains:
339
+ ```json
340
+ [
341
+ {
342
+ "coin": "XCP",
343
+ "name": "Stamp #11",
344
+ "balance": 1,
345
+ "type": "nft",
346
+ "external_url": "https://xchain.io/asset/A5433937813514022010",
347
+ "image": "https://stampchain.io/stamps/88fab306902f27f2a2c5aabf8983f0ef1f4135c20c0cbf494546a611bc2692c6.png",
348
+ "project": "STAMPS",
349
+ "traits": [
350
+ {
351
+ "trait_type": "STAMPS",
352
+ "value": "STAMP #11"
353
+ }
354
+ ],
355
+ "assetName": "A5433937813514022010"
356
+ }
357
+ ]
358
+ ```
359
+
360
+ Current status: FAIL
361
+ </details>
362
+
363
+ <details>
364
+ <summary>AllowedBells.test.ts (line 1 of 2742)</summary>
365
+
366
+ Tests for Bells token validation.
367
+
368
+ Key observations:
369
+ - Tests the validation logic for Bells tokens
370
+ - Verifies that the correct metadata and balance are required
371
+
372
+ Current status: PASS
373
+ </details>
374
+
375
+ <details>
376
+ <summary>AllowedEmbells.test.ts (line 1 of 347)</summary>
377
+
378
+ Tests for Embells token validation.
379
+
380
+ Key observations:
381
+ - Very small test file (347 bytes)
382
+ - Likely a simple validation test for Embells tokens
383
+
384
+ Current status: Not explicitly shown in test results, likely PASS
385
+ </details>
386
+
387
+ <details>
388
+ <summary>AllowedEmbels.test.ts (line 1 of 668)</summary>
389
+
390
+ Tests for Embels token validation.
391
+
392
+ Key observations:
393
+ - Small test file (668 bytes)
394
+ - Tests basic validation for Embels tokens
395
+
396
+ Current status: Not explicitly shown in test results, likely PASS
397
+ </details>
398
+
399
+ <details>
400
+ <summary>AllowedEthscriptions.test.ts (line 1 of 2052)</summary>
401
+
402
+ Tests for Ethscriptions validation.
403
+
404
+ Key observations:
405
+ - Tests the validation logic for Ethscriptions
406
+ - Verifies that the correct metadata and balance are required
407
+
408
+ Current status: Not explicitly shown in test results, likely PASS
409
+ </details>
410
+
411
+ <details>
412
+ <summary>AllowedHardcodedNfts.test.ts (line 1 of 4421)</summary>
413
+
414
+ Tests for hardcoded NFT validation.
415
+
416
+ Key observations:
417
+ - Largest test file (4421 bytes)
418
+ - Tests validation logic for hardcoded NFTs
419
+ - Likely covers edge cases or special NFTs
420
+
421
+ Current status: Not explicitly shown in test results, likely PASS
422
+ </details>
423
+
424
+ <details>
425
+ <summary>DarkfarmsMetadata.test.ts (line 1 of 318)</summary>
426
+
427
+ Tests for Darkfarms metadata handling.
428
+
429
+ Key observations:
430
+ - Very small test file (318 bytes)
431
+ - Tests metadata processing for Darkfarms
432
+
433
+ Current status: PASS
434
+ </details>
435
+
436
+ ## Fixtures Analysis
437
+
438
+ The fixtures directory contains test data organized by token/NFT type. Each subdirectory typically contains:
439
+
440
+ 1. `balance.json`: Standard balance data for the token type
441
+ 2. `balance-with-native.json` or similar: Mixed data with native tokens
442
+ 3. Additional specialized test cases
443
+
444
+ Here's a breakdown of the fixtures structure:
445
+
446
+ ```
447
+ fixtures/
448
+ ├── bells/ # Bells token test data
449
+ ├── bitcoin-degods/ # Bitcoin DeGods NFTs test data
450
+ ├── bitcoin-ordinals/ # Bitcoin Ordinals test data
451
+ ├── counterparty/ # Counterparty tokens test data
452
+ ├── cursed-ordinals/ # Cursed Ordinals test data
453
+ ├── dogeparty/ # Dogeparty tokens test data
454
+ ├── embels/ # Embels token test data
455
+ ├── emblem-open/ # Emblem Open test data
456
+ ├── ethscriptions/ # Ethscriptions test data
457
+ ├── hardcoded-nfts/ # Hardcoded NFTs test data
458
+ ├── megapunks/ # Megapunks NFT test data
459
+ ├── namecoin/ # Namecoin test data
460
+ ├── ordi/ # $ORDI token test data
461
+ ├── oxbt/ # OXBT token test data
462
+ └── stamps/ # Stamps NFT test data
463
+ ```
464
+
465
+ ### Key Fixtures Examined
466
+
467
+ #### bitcoin-degods
468
+ Contains test data for Bitcoin DeGods NFTs:
469
+ - `balance.json`: Standard DeGods NFT data
470
+ - `balance-with-non-degods-first.json`: Mixed data with non-DeGods tokens first
471
+
472
+ Example from `balance-with-non-degods-first.json`:
473
+ ```json
474
+ [
475
+ {
476
+ "coin": "BTC",
477
+ "name": "BTC",
478
+ "balance": 1
479
+ },
480
+ {
481
+ "coin": "ordinalsbtc",
482
+ "name": "DeGod #4654",
483
+ "balance": 1,
484
+ "type": "nft",
485
+ "external_url": "https://ordinals.com/inscription/4e80a569505ced2e72d48e9f79832ba487a64716c9a77b7189d6b6f1b3f95694i0",
486
+ "image": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/4e80a569505ced2e72d48e9f79832ba487a64716c9a77b7189d6b6f1b3f95694i0",
487
+ "project": "DeGods",
488
+ "projectLogo": "https://bis-ord-content.fra1.cdn.digitaloceanspaces.com/ordinals/d8c2e6fca21b41817dc162445f2a0c0f5b0995c0cae12799a39571cd974c4ea2i0",
489
+ "traits": [...]
490
+ }
491
+ ]
492
+ ```
493
+
494
+ #### counterparty
495
+ Contains test data for Counterparty tokens:
496
+ - `balance.json`: Standard Counterparty NFT (Rare Pepe)
497
+ - `balance-with-multiple.json`: Multiple Counterparty tokens
498
+
499
+ #### ordi
500
+ Contains test data for $ORDI tokens:
501
+ - `balance.json`: Standard $ORDI token data
502
+ - `balance-with-native.json`: $ORDI with other native tokens
503
+ - `balance-with-native-first.json`: Native token first, then $ORDI
504
+
505
+ #### stamps
506
+ Contains test data for Stamps NFTs:
507
+ - `balance.json`: Standard Stamps NFT data
508
+
509
+ ### Common Fixture Patterns
510
+
511
+ Most token fixtures follow similar patterns:
512
+
513
+ 1. **Basic Structure**: Each fixture typically contains an array of balance objects with properties like:
514
+ - `coin`: The token/coin identifier
515
+ - `name`: Human-readable name
516
+ - `balance`: Amount held
517
+ - `type`: Token type (e.g., "nft")
518
+ - Additional metadata specific to the token type
519
+
520
+ 2. **Variation Fixtures**: Many token types include variations to test different validation scenarios:
521
+ - Multiple tokens in a single balance
522
+ - Native tokens mixed with the specific token
523
+ - Invalid configurations to test validation rules
524
+
525
+ ## Test Implementation Analysis
526
+
527
+ The test suite follows a consistent pattern across different token types:
528
+
529
+ ### 1. Main SDK Tests (`EmblemVaultSdk.test.ts`)
530
+
531
+ Tests core SDK functionality:
532
+ - SDK initialization
533
+ - API method functionality
534
+ - Template generation
535
+ - Vault creation (skipped in actual execution)
536
+
537
+ ### 2. Token-Specific Tests (`Allowed*.test.ts`)
538
+
539
+ Each token type has its own test file that follows a similar structure:
540
+
541
+ ```typescript
542
+ describe('Allowed Function for [TokenType]', () => {
543
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
544
+
545
+ it('Does not allow empty balance', async () => {
546
+ // Test empty balance validation
547
+ })
548
+
549
+ it('Requires specific [property]', async () => {
550
+ // Test specific validation rules
551
+ })
552
+
553
+ // Additional test cases...
554
+ })
555
+ ```
556
+
557
+ Common test cases across token types:
558
+ - Empty balance validation
559
+ - Specific balance requirements
560
+ - Name/metadata validation
561
+ - Multiple asset validation
562
+ - Native asset requirements
563
+
564
+ ### 3. Test Timeouts
565
+
566
+ Several tests are failing due to timeouts, particularly:
567
+ - `AllowedOrdi.test.ts`: "Requires specific balance" test
568
+ - `AllowedStamps.test.ts`: "Requires asset name to include `stamps`" test
569
+
570
+ These timeouts are likely due to:
571
+ - Async operations without proper timeout handling
572
+ - Network requests in the validation logic
573
+ - Complex validation rules that take too long to execute
574
+
575
+ ## Relationship Between Tests and Implementation
576
+
577
+ The test suite validates the SDK's functionality with a focus on the validation rules for different token types. Key relationships:
578
+
579
+ ### 1. Validation Logic Flow
580
+
581
+ ```
582
+ Test → SDK.fetchCuratedContractByName() → generateTemplate() → allowed() function
583
+ ```
584
+
585
+ The tests fetch curated contract data, which includes the validation logic generated by the `generateTemplate` function in `utils.ts`. The `allowed` function is then tested with various fixture data.
586
+
587
+ ### 2. Template Generation
588
+
589
+ The `generateTemplate` function in `utils.ts` creates templates with validation rules for each curated collection. These templates include:
590
+ - Validation logic (`allowed` function)
591
+ - UI templates
592
+ - Creation templates
593
+ - Asset templates
594
+
595
+ ### 3. Test Coverage
596
+
597
+ The test suite covers:
598
+ - Core SDK functionality
599
+ - Validation rules for each token type
600
+ - Edge cases for validation
601
+ - Template generation
602
+
603
+ However, some areas have limited coverage:
604
+ - Error handling
605
+ - Network request failures
606
+ - Edge cases in vault creation
607
+
608
+ ## Recommendations for Test Improvements
609
+
610
+ Based on the analysis, here are recommendations for improving the test suite:
611
+
612
+ ### 1. Fix Failing Tests
613
+
614
+ #### Counterparty Test
615
+ ```typescript
616
+ // Uncomment and update the Counterparty validation logic in utils.ts
617
+ else if (recordName == "Counterparty") {
618
+ let facts = [
619
+ {
620
+ eval: record.nativeAssets.includes(data[0]?.coin),
621
+ msg: `Vaults should only contain assets native to ${recordName}`
622
+ },
623
+ {eval: data.length == 1, msg: `Vaults should only contain a single item`}
624
+ ]
625
+ allowed = evaluateFacts(allowed, facts, msgCallback)
626
+ }
627
+ ```
628
+
629
+ #### Timeout Issues
630
+ ```typescript
631
+ // Add to the top of test files with timeout issues
632
+ jest.setTimeout(15000); // Increase timeout to 15 seconds
633
+
634
+ // Or add timeout to individual tests
635
+ it('Requires specific balance', async () => {
636
+ // Test code
637
+ }, 15000); // 15 second timeout
638
+ ```
639
+
640
+ ### 2. Improve Test Structure
641
+
642
+ - Add setup and teardown functions to reduce code duplication
643
+ - Create shared test utilities for common operations
644
+ - Group related tests more effectively
645
+
646
+ ### 3. Enhance Test Coverage
647
+
648
+ - Add tests for error handling
649
+ - Test network request failures
650
+ - Add more edge cases for validation
651
+ - Test with real-world data
652
+
653
+ ### 4. Performance Improvements
654
+
655
+ - Mock network requests in tests
656
+ - Add caching for repeated operations
657
+ - Optimize validation logic
658
+
659
+ ## Conclusion
660
+
661
+ The Emblem Vault SDK test suite provides comprehensive validation of the SDK's functionality, particularly the token validation rules. The main issues are:
662
+
663
+ 1. Commented-out validation logic for Counterparty tokens
664
+ 2. Timeout issues in the $ORDI and Stamps tests
665
+ 3. Limited test coverage for error handling and edge cases
666
+
667
+ Addressing these issues will improve the reliability and effectiveness of the test suite.