emblem-vault-sdk 2.3.6 → 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.
- package/.traces/blockchain-provider-abstraction-plan.md +302 -0
- package/.traces/notes.md +43 -0
- package/.traces/readme-verification-trace.md +988 -0
- package/.traces/test-migration-status.md +227 -0
- package/.traces/tests-consolidated-trace.md +667 -0
- package/dist/abi/abi.json +53 -0
- package/dist/bundle.js +21602 -17419
- package/dist/clients/emblemVaultSolanaWalletClient.d.ts +74 -0
- package/dist/clients/emblemVaultSolanaWalletClient.js +149 -0
- package/dist/clients/emblemVaultSolanaWalletClient.js.map +1 -0
- package/dist/clients/emblemVaultWalletClient.d.ts +52 -0
- package/dist/clients/emblemVaultWalletClient.js +110 -0
- package/dist/clients/emblemVaultWalletClient.js.map +1 -0
- package/dist/derive.js +7 -0
- package/dist/derive.js.map +1 -0
- package/dist/index.js +319 -114
- package/dist/index.js.map +1 -0
- package/dist/providers/ProviderManager.d.ts +57 -0
- package/dist/providers/ProviderManager.js +283 -0
- package/dist/providers/ProviderManager.js.map +1 -0
- package/dist/providers.d.ts +101 -0
- package/dist/providers.js +96 -0
- package/dist/providers.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.js +61 -58
- package/dist/utils.js.map +1 -0
- package/docs/bundle.js +21602 -17419
- package/docs/index.html +150 -13
- package/docs/local.html +385 -0
- package/docs/steps.html +420 -53
- package/package.json +22 -13
- package/readme.md +795 -21
- package/src/abi/abi.json +54 -1
- package/src/clients/emblemVaultSolanaWalletClient.ts +257 -0
- package/src/clients/emblemVaultWalletClient.ts +159 -0
- package/src/derive.ts +5 -5
- package/src/index.ts +320 -102
- package/src/providers/ProviderManager.ts +254 -0
- package/src/providers.ts +163 -0
- package/src/types.ts +50 -0
- package/src/utils.ts +63 -62
- package/test/.mocharc.js +8 -0
- package/test/README.md +212 -0
- package/test/fixtures/ethscriptions/balance-with-native-first.json +24 -0
- package/test/fixtures/ethscriptions/balance-with-native.json +23 -0
- package/test/fixtures/ethscriptions/balance.json +18 -0
- package/test/helpers/sdkLoader.js +88 -0
- package/test/helpers/setup.js +55 -0
- package/test/integration/ApiOperations.spec.js +102 -0
- package/test/integration/VaultAI.spec.js +57 -0
- package/test/integration/VaultCreation.spec.js +95 -0
- package/test/mocks.js +127 -0
- package/test/tsconfig.json +25 -0
- package/test/unit/AllowedBells.spec.js +53 -0
- package/test/unit/AllowedBitcoinDeGods.spec.js +53 -0
- package/test/unit/AllowedBitcoinOrdinals.spec.js +46 -0
- package/test/unit/AllowedCounterparty.spec.js +66 -0
- package/test/unit/AllowedCursedOrdinals.spec.js +68 -0
- package/test/unit/AllowedEmbells.spec.js +11 -0
- package/test/unit/AllowedEmbels.spec.js +11 -0
- package/test/unit/AllowedEmblemOpen.spec.js +20 -0
- package/test/unit/AllowedEthscriptions.spec.js +53 -0
- package/test/unit/AllowedHardcodedNfts.spec.js +77 -0
- package/test/unit/AllowedNamecoin.spec.js +33 -0
- package/test/unit/AllowedOrdi.spec.js +46 -0
- package/test/unit/AllowedOxbt.spec.js +46 -0
- package/test/unit/AllowedProjectCollection.spec.js +51 -0
- package/test/unit/AllowedProtocolCollection.spec.js +44 -0
- package/test/unit/AllowedStamps.spec.js +78 -0
- package/test/unit/DarkfarmsMetadata.spec.js +10 -0
- package/test/unit/EmblemVaultSdk.spec.js +188 -0
- package/test/unit/Providers.spec.js +290 -0
- package/test/unit/ResourceMonitor.spec.js +111 -0
- package/test/unit/SDKMemoryLeaks.spec.js +176 -0
- package/test/unit/Signing.spec.js +321 -0
- package/test/unit/VaultAI.spec.js +140 -0
- package/test/unit/clients/EmblemVaultSolanaWalletClient.spec.js +296 -0
- package/test/unit/clients/EmblemVaultWalletClient.spec.js +246 -0
- package/test/utils/ResourceMonitor.js +169 -0
- package/test/windsurf-rules.md +68 -0
- package/tsconfig.json +7 -3
- package/types/derive.d.ts +0 -5
- package/types/index.d.ts +152 -32
- package/types/types.d.ts +43 -0
- package/types/utils.d.ts +7 -1
- package/dist/abi/quote.js +0 -29
- package/dist/abi/quote.json +0 -26
- package/jest.config.js +0 -6
- package/tests/AllowedBells.test.ts +0 -53
- package/tests/AllowedBitcoinDeGods.test.ts +0 -53
- package/tests/AllowedBitcoinOrdinals.test.ts +0 -46
- package/tests/AllowedCounterparty.test.ts +0 -45
- package/tests/AllowedCursedOrdinals.test.ts +0 -68
- package/tests/AllowedEmbells.test.ts +0 -12
- package/tests/AllowedEmbels.test.ts +0 -16
- package/tests/AllowedEmblemOpen.test.ts +0 -20
- package/tests/AllowedEthscriptions.test.ts +0 -39
- package/tests/AllowedHardcodedNfts.test.ts +0 -78
- package/tests/AllowedNamecoin.test.ts +0 -33
- package/tests/AllowedOrdi.test.ts +0 -47
- package/tests/AllowedOxbt.test.ts +0 -47
- package/tests/AllowedProjectlCollection.test.ts +0 -51
- package/tests/AllowedProtocolCollection.test.ts +0 -44
- package/tests/AllowedStamps.test.ts +0 -73
- package/tests/DarkfarmsMetadata.test.ts +0 -10
- package/tests/EmblemVaultSdk.test.ts +0 -124
- package/tests/fixtures/embels/balance.json +0 -10
- package/tests/fixtures/ethscriptions/balance-with-native-first.json +0 -69
- package/tests/fixtures/ethscriptions/balance-with-native.json +0 -37
- package/tests/fixtures/ethscriptions/balance.json +0 -64
- /package/{tests → test}/fixtures/bells/balance-with-non-bell-first.json +0 -0
- /package/{tests → test}/fixtures/bells/balance-with-non-bell.json +0 -0
- /package/{tests → test}/fixtures/bells/balance.json +0 -0
- /package/{tests → test}/fixtures/bitcoin-degods/balance-with-non-degods-first.json +0 -0
- /package/{tests → test}/fixtures/bitcoin-degods/balance-with-non-degods.json +0 -0
- /package/{tests → test}/fixtures/bitcoin-degods/balance.json +0 -0
- /package/{tests → test}/fixtures/bitcoin-ordinals/balance-with-native-first.json +0 -0
- /package/{tests → test}/fixtures/bitcoin-ordinals/balance-with-only-native.json +0 -0
- /package/{tests → test}/fixtures/bitcoin-ordinals/balance.json +0 -0
- /package/{tests → test}/fixtures/counterparty/balance-with-multiple.json +0 -0
- /package/{tests → test}/fixtures/counterparty/balance.json +0 -0
- /package/{tests → test}/fixtures/cursed-ordinals/balance-with-native-first.json +0 -0
- /package/{tests → test}/fixtures/cursed-ordinals/balance-with-native.json +0 -0
- /package/{tests → test}/fixtures/cursed-ordinals/balance.json +0 -0
- /package/{tests → test}/fixtures/dogeparty/balance-with-non-dogeparty-first.json +0 -0
- /package/{tests → test}/fixtures/dogeparty/balance-with-non-dogeparty.json +0 -0
- /package/{tests → test}/fixtures/dogeparty/balance.json +0 -0
- /package/{tests → test}/fixtures/emblem-open/balance.json +0 -0
- /package/{tests → test}/fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json +0 -0
- /package/{tests → test}/fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json +0 -0
- /package/{tests → test}/fixtures/hardcoded-nfts/balance.json +0 -0
- /package/{tests → test}/fixtures/megapunks/balance-with-non-megapunk-first.json +0 -0
- /package/{tests → test}/fixtures/megapunks/balance-with-non-megapunk.json +0 -0
- /package/{tests → test}/fixtures/megapunks/balance.json +0 -0
- /package/{tests → test}/fixtures/namecoin/balance-with-native-first.json +0 -0
- /package/{tests → test}/fixtures/namecoin/balance-with-native.json +0 -0
- /package/{tests → test}/fixtures/namecoin/balance.json +0 -0
- /package/{tests → test}/fixtures/ordi/balance-with-native-first.json +0 -0
- /package/{tests → test}/fixtures/ordi/balance-with-native.json +0 -0
- /package/{tests → test}/fixtures/ordi/balance.json +0 -0
- /package/{tests → test}/fixtures/oxbt/balance-with-native-first.json +0 -0
- /package/{tests → test}/fixtures/oxbt/balance-with-native.json +0 -0
- /package/{tests → test}/fixtures/oxbt/balance.json +0 -0
- /package/{tests → test}/fixtures/stamps/balance-with-non-stamps-first.json +0 -0
- /package/{tests → test}/fixtures/stamps/balance-with-non-stamps.json +0 -0
- /package/{tests → test}/fixtures/stamps/balance.json +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Emblem Vault SDK Test Migration Status
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document captures the current state of the Emblem Vault SDK test migration from Jest to Mocha/Chai, including our progress, implementation patterns, and remaining work.
|
|
6
|
+
|
|
7
|
+
## Migration Journey
|
|
8
|
+
|
|
9
|
+
### Initial State
|
|
10
|
+
|
|
11
|
+
The Emblem Vault SDK originally used Jest for testing with the following characteristics:
|
|
12
|
+
- Tests were located in the `/tests` directory
|
|
13
|
+
- 18 test suites covering various collection types
|
|
14
|
+
- Mixture of unit tests and integration tests in a single directory
|
|
15
|
+
- No clear separation between test types
|
|
16
|
+
- Limited memory leak detection capabilities
|
|
17
|
+
- Test fixtures scattered across multiple directories
|
|
18
|
+
|
|
19
|
+
### Current State
|
|
20
|
+
|
|
21
|
+
We have successfully migrated to a Mocha/Chai testing framework with:
|
|
22
|
+
- Restructured test directory at `/test` (vs. original `/tests`)
|
|
23
|
+
- Clear separation between unit and integration tests
|
|
24
|
+
- Dedicated directories for fixtures, helpers, and utilities
|
|
25
|
+
- Improved memory leak detection with ResourceMonitor
|
|
26
|
+
- Override function pattern for better testability
|
|
27
|
+
- Maintained backward compatibility with legacy Jest tests
|
|
28
|
+
|
|
29
|
+
## Key Implementation Patterns
|
|
30
|
+
|
|
31
|
+
### 1. Override Function Pattern
|
|
32
|
+
|
|
33
|
+
The SDK now implements a consistent override function pattern across API methods:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
async methodName(param: string, callback: any = null, overrideFunc: Function | null = null) {
|
|
37
|
+
// Allow callback for progress tracking
|
|
38
|
+
if (callback) { callback('operation in progress') }
|
|
39
|
+
|
|
40
|
+
// Override pattern
|
|
41
|
+
const result = overrideFunc
|
|
42
|
+
? await overrideFunc(this.apiKey, { param })
|
|
43
|
+
: await fetchData(`${this.baseUrl}/endpoint`, this.apiKey);
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This pattern enables:
|
|
50
|
+
- **Testing**: Makes unit testing easier by allowing mock data injection
|
|
51
|
+
- **Flexibility**: Enables alternative implementations for different environments
|
|
52
|
+
- **Extensibility**: Consumers can provide custom data sources or caching mechanisms
|
|
53
|
+
|
|
54
|
+
### 2. Test Organization
|
|
55
|
+
|
|
56
|
+
Tests are now organized following these principles:
|
|
57
|
+
- Initialize SDK once per describe block
|
|
58
|
+
- Group related tests together
|
|
59
|
+
- Skip tests conditionally when using demo keys
|
|
60
|
+
- Use proper timeout settings for API calls
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
describe('Feature Group', () => {
|
|
64
|
+
let sdk;
|
|
65
|
+
|
|
66
|
+
before(() => {
|
|
67
|
+
sdk = new EmblemVaultSDK(API_KEY);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should test specific functionality', async () => {
|
|
71
|
+
// Test-specific mock data
|
|
72
|
+
const mockData = [...];
|
|
73
|
+
|
|
74
|
+
// Test implementation
|
|
75
|
+
const result = await sdk.someMethod();
|
|
76
|
+
expect(result).to.have.property('expectedProperty');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 3. Memory Leak Detection
|
|
82
|
+
|
|
83
|
+
We've implemented a robust ResourceMonitor utility that:
|
|
84
|
+
- Takes memory snapshots before and after operations
|
|
85
|
+
- Calculates memory differences
|
|
86
|
+
- Checks against configurable thresholds
|
|
87
|
+
- Generates detailed reports
|
|
88
|
+
- Supports garbage collection when available
|
|
89
|
+
|
|
90
|
+
### 4. Module Import Handling
|
|
91
|
+
|
|
92
|
+
We've addressed TypeScript and CommonJS/ESM integration issues:
|
|
93
|
+
- Compile TypeScript code before testing
|
|
94
|
+
- Use proper import patterns for compiled modules
|
|
95
|
+
- Handle named exports correctly
|
|
96
|
+
- Use source maps for debugging
|
|
97
|
+
|
|
98
|
+
## Migration Progress
|
|
99
|
+
|
|
100
|
+
### Completed Migrations
|
|
101
|
+
|
|
102
|
+
1. **Core SDK Tests**:
|
|
103
|
+
- EmblemVaultSdk.spec.js - Core SDK functionality
|
|
104
|
+
- ResourceMonitor.spec.js - Memory leak detection utility
|
|
105
|
+
- SDKMemoryLeaks.spec.js - Comprehensive memory leak tests
|
|
106
|
+
- Providers.spec.js - Provider abstraction tests
|
|
107
|
+
|
|
108
|
+
2. **Collection Tests** (All Completed):
|
|
109
|
+
- AllowedBells.spec.js
|
|
110
|
+
- AllowedBitcoinDeGods.spec.js
|
|
111
|
+
- AllowedBitcoinOrdinals.spec.js
|
|
112
|
+
- AllowedCounterparty.spec.js
|
|
113
|
+
- AllowedCursedOrdinals.spec.js
|
|
114
|
+
- AllowedEmbells.spec.js
|
|
115
|
+
- AllowedEmbels.spec.js
|
|
116
|
+
- AllowedEmblemOpen.spec.js
|
|
117
|
+
- AllowedEthscriptions.spec.js
|
|
118
|
+
- AllowedHardcodedNfts.spec.js
|
|
119
|
+
- AllowedNamecoin.spec.js
|
|
120
|
+
- AllowedOrdi.spec.js
|
|
121
|
+
- AllowedOxbt.spec.js
|
|
122
|
+
- AllowedProtocolCollection.spec.js
|
|
123
|
+
- AllowedStamps.spec.js
|
|
124
|
+
|
|
125
|
+
3. **Metadata Tests**:
|
|
126
|
+
- DarkfarmsMetadata.spec.js
|
|
127
|
+
|
|
128
|
+
4. **Integration Tests**:
|
|
129
|
+
- ApiOperations.spec.js - Read-only API operations
|
|
130
|
+
- VaultCreation.spec.js - Vault creation operations
|
|
131
|
+
- VaultAI.spec.js - AI-related functionality
|
|
132
|
+
|
|
133
|
+
5. **Infrastructure**:
|
|
134
|
+
- Test directory structure
|
|
135
|
+
- Mocha configuration
|
|
136
|
+
- Test helpers and utilities
|
|
137
|
+
- Fixture management
|
|
138
|
+
|
|
139
|
+
### New Test Areas
|
|
140
|
+
|
|
141
|
+
1. **Provider Abstraction Tests**:
|
|
142
|
+
- Providers.spec.js - Tests for the blockchain provider abstraction
|
|
143
|
+
- Tests for provider registration, detection, and usage
|
|
144
|
+
- Tests for Web3ProviderAdapter and Solana provider integration
|
|
145
|
+
|
|
146
|
+
2. **AI Integration Tests**:
|
|
147
|
+
- VaultAI.spec.js - Tests for AI-powered vault information retrieval
|
|
148
|
+
- Tests for API key handling and URL configuration
|
|
149
|
+
- Tests for response processing and error handling
|
|
150
|
+
|
|
151
|
+
### Remaining Work
|
|
152
|
+
|
|
153
|
+
1. **Signing Tests**:
|
|
154
|
+
- Tests for the new `performMintHelper` method (currently a stub)
|
|
155
|
+
- Tests for transaction signing with different provider types
|
|
156
|
+
- Tests for message signing with different provider types
|
|
157
|
+
|
|
158
|
+
2. **Documentation**:
|
|
159
|
+
- Update SDK documentation to reflect the new testing approach
|
|
160
|
+
- Add examples of using the override function pattern
|
|
161
|
+
- Create migration guides for contributors
|
|
162
|
+
|
|
163
|
+
## Migration Strategy
|
|
164
|
+
|
|
165
|
+
For each remaining test area, we follow this migration process:
|
|
166
|
+
|
|
167
|
+
1. **Analysis**: Review the existing code to understand its purpose and structure
|
|
168
|
+
2. **Fixture Migration**: Move fixtures to the appropriate directory in `/test/fixtures`
|
|
169
|
+
3. **Test Conversion**: Convert assertions to Chai assertions
|
|
170
|
+
4. **Override Implementation**: Update tests to use the override function pattern
|
|
171
|
+
5. **Validation**: Ensure tests pass with both real API calls and mock data
|
|
172
|
+
6. **Documentation**: Update the README.md to reflect the migration status
|
|
173
|
+
|
|
174
|
+
## Challenges and Solutions
|
|
175
|
+
|
|
176
|
+
### 1. Module Import Issues
|
|
177
|
+
|
|
178
|
+
**Challenge**: TypeScript modules with named exports caused import issues in CommonJS tests.
|
|
179
|
+
|
|
180
|
+
**Solution**:
|
|
181
|
+
- Compile TypeScript to JavaScript before testing
|
|
182
|
+
- Use proper destructuring for named exports
|
|
183
|
+
- Maintain consistent import patterns
|
|
184
|
+
|
|
185
|
+
### 2. Memory Leak Detection
|
|
186
|
+
|
|
187
|
+
**Challenge**: Detecting memory leaks reliably across different environments.
|
|
188
|
+
|
|
189
|
+
**Solution**:
|
|
190
|
+
- Created ResourceMonitor utility with configurable thresholds
|
|
191
|
+
- Implemented proper garbage collection triggers
|
|
192
|
+
- Added detailed memory usage reporting
|
|
193
|
+
|
|
194
|
+
### 3. API Key Management
|
|
195
|
+
|
|
196
|
+
**Challenge**: Securely using API keys in tests without exposing them.
|
|
197
|
+
|
|
198
|
+
**Solution**:
|
|
199
|
+
- Use environment variables for API keys
|
|
200
|
+
- Skip tests when using demo keys
|
|
201
|
+
- Add conditional test execution based on API key availability
|
|
202
|
+
|
|
203
|
+
### 4. Provider Abstraction Testing
|
|
204
|
+
|
|
205
|
+
**Challenge**: Testing provider abstraction without actual blockchain providers.
|
|
206
|
+
|
|
207
|
+
**Solution**:
|
|
208
|
+
- Created detailed mock providers for Ethereum, Solana, and Bitcoin
|
|
209
|
+
- Implemented sinon stubs for provider methods
|
|
210
|
+
- Used the adapter pattern to test provider conversions
|
|
211
|
+
|
|
212
|
+
## Next Steps
|
|
213
|
+
|
|
214
|
+
1. **Signing Implementation**:
|
|
215
|
+
- Implement the `performMintHelper` method to replace `performMintChain`
|
|
216
|
+
- Add tests for signing operations with different provider types
|
|
217
|
+
- Ensure backward compatibility with existing code
|
|
218
|
+
|
|
219
|
+
2. **Continuous Integration**:
|
|
220
|
+
- Update CI configuration to run Mocha tests
|
|
221
|
+
- Add coverage reporting for all tests
|
|
222
|
+
- Implement parallel test execution for faster feedback
|
|
223
|
+
|
|
224
|
+
3. **Documentation**:
|
|
225
|
+
- Update SDK documentation to reflect the new provider abstraction
|
|
226
|
+
- Add examples of using different provider types
|
|
227
|
+
- Create migration guides for users of the SDK
|