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,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResourceMonitor - A utility class for monitoring memory usage in tests
|
|
3
|
+
*
|
|
4
|
+
* This class provides methods to track memory usage during test execution,
|
|
5
|
+
* helping to identify potential memory leaks in the SDK.
|
|
6
|
+
*/
|
|
7
|
+
class ResourceMonitor {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new ResourceMonitor
|
|
10
|
+
* @param {number} thresholdPercentage Percentage increase threshold for warnings (default: 10)
|
|
11
|
+
* @param {boolean} verbose Whether to log all memory measurements (default: false)
|
|
12
|
+
*/
|
|
13
|
+
constructor(thresholdPercentage = 10, verbose = false) {
|
|
14
|
+
this.snapshots = [];
|
|
15
|
+
this.thresholdPercentage = thresholdPercentage;
|
|
16
|
+
this.verbose = verbose;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get current memory usage in MB
|
|
21
|
+
* @returns {number} Current heap memory usage in MB
|
|
22
|
+
*/
|
|
23
|
+
getMemoryUsage() {
|
|
24
|
+
const memoryUsage = process.memoryUsage();
|
|
25
|
+
return Math.round(memoryUsage.heapUsed / 1024 / 1024 * 100) / 100;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Take a memory snapshot with a label
|
|
30
|
+
* @param {string} label Label for this memory snapshot
|
|
31
|
+
* @returns {number} The memory usage in MB
|
|
32
|
+
*/
|
|
33
|
+
takeSnapshot(label) {
|
|
34
|
+
const memoryUsage = this.getMemoryUsage();
|
|
35
|
+
this.snapshots.push({
|
|
36
|
+
label,
|
|
37
|
+
memoryUsage,
|
|
38
|
+
timestamp: Date.now()
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
console.log(`Memory snapshot [${label}]: ${memoryUsage} MB`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return memoryUsage;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the difference between the current memory usage and a previous snapshot
|
|
50
|
+
* @param {string} label Label of the snapshot to compare against
|
|
51
|
+
* @returns {number|null} Memory difference in MB, or null if snapshot not found
|
|
52
|
+
*/
|
|
53
|
+
getDifference(label) {
|
|
54
|
+
const snapshot = this.snapshots.find(s => s.label === label);
|
|
55
|
+
if (!snapshot) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const currentMemory = this.getMemoryUsage();
|
|
60
|
+
return Math.round((currentMemory - snapshot.memoryUsage) * 100) / 100;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get the difference between two snapshots
|
|
65
|
+
* @param {string} startLabel Label of the starting snapshot
|
|
66
|
+
* @param {string} endLabel Label of the ending snapshot
|
|
67
|
+
* @returns {number|null} Memory difference in MB, or null if either snapshot not found
|
|
68
|
+
*/
|
|
69
|
+
getDifferenceBetweenSnapshots(startLabel, endLabel) {
|
|
70
|
+
const startSnapshot = this.snapshots.find(s => s.label === startLabel);
|
|
71
|
+
const endSnapshot = this.snapshots.find(s => s.label === endLabel);
|
|
72
|
+
|
|
73
|
+
if (!startSnapshot || !endSnapshot) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return Math.round((endSnapshot.memoryUsage - startSnapshot.memoryUsage) * 100) / 100;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check if memory usage has increased beyond the threshold compared to a snapshot
|
|
82
|
+
* @param {string} label Label of the snapshot to compare against
|
|
83
|
+
* @returns {Object} Object containing whether threshold was exceeded and the percentage increase
|
|
84
|
+
*/
|
|
85
|
+
checkThreshold(label) {
|
|
86
|
+
const snapshot = this.snapshots.find(s => s.label === label);
|
|
87
|
+
if (!snapshot) {
|
|
88
|
+
return { exceeded: false, percentageIncrease: null };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const currentMemory = this.getMemoryUsage();
|
|
92
|
+
const percentageIncrease = ((currentMemory - snapshot.memoryUsage) / snapshot.memoryUsage) * 100;
|
|
93
|
+
const roundedPercentage = Math.round(percentageIncrease * 100) / 100;
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
exceeded: percentageIncrease > this.thresholdPercentage,
|
|
97
|
+
percentageIncrease: roundedPercentage
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get all snapshots
|
|
103
|
+
* @returns {Array} Array of all memory snapshots
|
|
104
|
+
*/
|
|
105
|
+
getSnapshots() {
|
|
106
|
+
return [...this.snapshots];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Reset all snapshots
|
|
111
|
+
*/
|
|
112
|
+
reset() {
|
|
113
|
+
this.snapshots = [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Force garbage collection if available
|
|
118
|
+
* @returns {boolean} True if garbage collection was triggered, false otherwise
|
|
119
|
+
*/
|
|
120
|
+
triggerGC() {
|
|
121
|
+
if (global.gc) {
|
|
122
|
+
global.gc();
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (this.verbose) {
|
|
127
|
+
console.log('Garbage collection not exposed. Run with node --expose-gc to enable.');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generate a report of memory usage
|
|
135
|
+
* @returns {string} A formatted string containing memory usage information
|
|
136
|
+
*/
|
|
137
|
+
generateReport() {
|
|
138
|
+
if (this.snapshots.length === 0) {
|
|
139
|
+
return 'No memory snapshots recorded.';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const firstSnapshot = this.snapshots[0];
|
|
143
|
+
const lastSnapshot = this.snapshots[this.snapshots.length - 1];
|
|
144
|
+
const totalDifference = lastSnapshot.memoryUsage - firstSnapshot.memoryUsage;
|
|
145
|
+
const percentageChange = ((lastSnapshot.memoryUsage - firstSnapshot.memoryUsage) / firstSnapshot.memoryUsage) * 100;
|
|
146
|
+
|
|
147
|
+
let report = '=== Memory Usage Report ===\n';
|
|
148
|
+
report += `Initial memory [${firstSnapshot.label}]: ${firstSnapshot.memoryUsage} MB\n`;
|
|
149
|
+
report += `Final memory [${lastSnapshot.label}]: ${lastSnapshot.memoryUsage} MB\n`;
|
|
150
|
+
report += `Total change: ${Math.round(totalDifference * 100) / 100} MB (${Math.round(percentageChange * 100) / 100}%)\n`;
|
|
151
|
+
|
|
152
|
+
if (this.snapshots.length > 2) {
|
|
153
|
+
report += '\nSnapshot history:\n';
|
|
154
|
+
|
|
155
|
+
for (let i = 1; i < this.snapshots.length; i++) {
|
|
156
|
+
const prev = this.snapshots[i - 1];
|
|
157
|
+
const curr = this.snapshots[i];
|
|
158
|
+
const diff = curr.memoryUsage - prev.memoryUsage;
|
|
159
|
+
const percentChange = (diff / prev.memoryUsage) * 100;
|
|
160
|
+
|
|
161
|
+
report += `${prev.label} → ${curr.label}: ${Math.round(diff * 100) / 100} MB (${Math.round(percentChange * 100) / 100}%)\n`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return report;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = { ResourceMonitor };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Emblem Vault SDK Test Migration Windsurf Rules
|
|
2
|
+
|
|
3
|
+
## Migration Principles
|
|
4
|
+
- **Backward Compatibility**: Maintain backward compatibility with existing code
|
|
5
|
+
- **Deprecation Before Removal**: Mark functions/features as deprecated before removing them
|
|
6
|
+
- **Incremental Migration**: Migrate tests one at a time to ensure stability
|
|
7
|
+
- **Dual Testing Frameworks**: Support both Jest and Mocha/Chai during transition
|
|
8
|
+
- **Consistent Test Coverage**: Ensure the same level of test coverage in the new framework
|
|
9
|
+
|
|
10
|
+
## Directory Structure
|
|
11
|
+
- `/test`: New Mocha/Chai tests location
|
|
12
|
+
- `/fixtures`: Test fixtures (JSON, mock data)
|
|
13
|
+
- `/unit`: Unit tests for individual components
|
|
14
|
+
- `/integration`: Integration tests for combined functionality
|
|
15
|
+
- `/helpers`: Test helper functions and utilities
|
|
16
|
+
- `/tests`: Legacy Jest tests (to be deprecated gradually)
|
|
17
|
+
|
|
18
|
+
## Test File Naming Conventions
|
|
19
|
+
- Unit tests: `*.spec.ts`
|
|
20
|
+
- Integration tests: `*.integration.spec.ts`
|
|
21
|
+
- Fixture files: Descriptive names matching the data they represent
|
|
22
|
+
|
|
23
|
+
## Migration Process
|
|
24
|
+
1. **Phase 1**: Set up Mocha/Chai infrastructure
|
|
25
|
+
- Create configuration files
|
|
26
|
+
- Set up test helpers
|
|
27
|
+
- Establish test patterns
|
|
28
|
+
|
|
29
|
+
2. **Phase 2**: Migrate core tests
|
|
30
|
+
- Start with foundational SDK tests
|
|
31
|
+
- Move to feature-specific tests
|
|
32
|
+
- Ensure all fixtures are properly migrated
|
|
33
|
+
|
|
34
|
+
3. **Phase 3**: Deprecation of Jest tests
|
|
35
|
+
- Update package.json to support both frameworks
|
|
36
|
+
- Add deprecation notices to Jest test files
|
|
37
|
+
- Document migration timeline
|
|
38
|
+
|
|
39
|
+
4. **Phase 4**: Complete transition
|
|
40
|
+
- Remove Jest dependencies when appropriate
|
|
41
|
+
- Update documentation
|
|
42
|
+
- Clean up legacy code
|
|
43
|
+
|
|
44
|
+
## Coding Standards
|
|
45
|
+
- Use TypeScript for all test files
|
|
46
|
+
- Follow existing code style and formatting
|
|
47
|
+
- Add comprehensive comments explaining test purpose
|
|
48
|
+
- Use descriptive test names that explain what is being tested
|
|
49
|
+
- Group related tests in describe blocks
|
|
50
|
+
|
|
51
|
+
## Test Structure Guidelines
|
|
52
|
+
- Each test file should focus on a specific component or feature
|
|
53
|
+
- Use before/beforeEach for setup and after/afterEach for cleanup
|
|
54
|
+
- Mock external dependencies when appropriate
|
|
55
|
+
- Use fixtures for consistent test data
|
|
56
|
+
- Include both positive and negative test cases
|
|
57
|
+
|
|
58
|
+
## Documentation Requirements
|
|
59
|
+
- Document any changes to the API or behavior
|
|
60
|
+
- Update README with new test instructions
|
|
61
|
+
- Add migration notes for contributors
|
|
62
|
+
- Document any known issues or limitations
|
|
63
|
+
|
|
64
|
+
## Commit Message Format
|
|
65
|
+
- `test: Migrate [test name] to Mocha/Chai`
|
|
66
|
+
- `chore: Update test configuration for Mocha/Chai`
|
|
67
|
+
- `docs: Update test documentation`
|
|
68
|
+
- `refactor: Improve test structure for [component]`
|
package/tsconfig.json
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
|
9
9
|
"resolveJsonModule": true, /* Include this to allow importing of .json files. */
|
|
10
10
|
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
11
|
-
"declarationMap": false,
|
|
12
|
-
"outDir": "./dist" /* Redirect output structure to the directory. */
|
|
11
|
+
"declarationMap": false, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
12
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
13
|
+
"rootDir": "./src", /* Specify the root directory of input files. */
|
|
14
|
+
"sourceMap": true, /* Generate source maps for debugging. */
|
|
15
|
+
"removeComments": false /* Do not remove comments in the compiled output. */
|
|
13
16
|
},
|
|
14
|
-
"
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["**/*.test.ts", "node_modules", "dist", "test"]
|
|
15
19
|
}
|
package/types/derive.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,44 +1,167 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import { Collection, CuratedCollectionsResponse, MetaData, Ownership, Vault } from './types';
|
|
3
|
-
|
|
2
|
+
import { AiVaultInfo, Balance, Collection, CuratedCollectionsResponse, MetaData, Ownership, v3LocalMintSignature, Vault } from './types';
|
|
3
|
+
import { BlockchainType } from './providers';
|
|
4
|
+
import { EmblemVaultWalletClient, EmblemVaultWalletClientConfig } from './clients/emblemVaultWalletClient';
|
|
5
|
+
import { EmblemVaultSolanaWalletClient, EmblemVaultSolanaWalletClientConfig } from './clients/emblemVaultSolanaWalletClient';
|
|
6
|
+
export declare class EmblemVaultSDK {
|
|
4
7
|
private apiKey;
|
|
5
8
|
private baseUrl;
|
|
6
9
|
private v3Url;
|
|
7
10
|
private sigUrl;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
private aiUrl;
|
|
12
|
+
private aiApiKey?;
|
|
13
|
+
private byoKey?;
|
|
14
|
+
private providerManager;
|
|
15
|
+
version: string;
|
|
16
|
+
constructor(apiKey: string, baseUrl?: string, v3Url?: string, sigUrl?: string, aiUrl?: string, aiApiKey?: string, byoKey?: string);
|
|
17
|
+
/**
|
|
18
|
+
* Register a blockchain provider for a specific blockchain type
|
|
19
|
+
* @param type The blockchain type
|
|
20
|
+
* @param provider The provider instance
|
|
21
|
+
*/
|
|
22
|
+
registerProvider(type: BlockchainType, provider: any): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get a registered provider for a specific blockchain type
|
|
25
|
+
* @param type The blockchain type
|
|
26
|
+
* @returns The provider instance or undefined if not registered
|
|
27
|
+
*/
|
|
28
|
+
getProvider(type: BlockchainType): any;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a provider is registered for a specific blockchain type
|
|
31
|
+
* @param type The blockchain type
|
|
32
|
+
* @returns True if a provider is registered for the specified type
|
|
33
|
+
*/
|
|
34
|
+
hasProvider(type: BlockchainType): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get or detect a provider for a specific blockchain type
|
|
37
|
+
* If a provider is registered, it will be returned
|
|
38
|
+
* Otherwise, it will try to detect a provider in the environment
|
|
39
|
+
* @param type The blockchain type
|
|
40
|
+
* @returns A promise that resolves to the provider instance
|
|
41
|
+
* @throws Error if no provider is available
|
|
42
|
+
*/
|
|
43
|
+
getOrDetectProvider(type: BlockchainType): Promise<any>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Wallet Client instance powered by the Emblem Vault TEE signer.
|
|
46
|
+
*
|
|
47
|
+
* @param config - Configuration specific to the wallet client, like the walletId.
|
|
48
|
+
* @returns An EmblemVaultWalletClient instance.
|
|
49
|
+
*/
|
|
50
|
+
createWalletClient(config: Omit<EmblemVaultWalletClientConfig, 'sdk'>): EmblemVaultWalletClient;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a Solana Wallet Client instance powered by the Emblem Vault TEE signer.
|
|
53
|
+
*
|
|
54
|
+
* @param config - Configuration specific to the Solana wallet client, like the walletId.
|
|
55
|
+
* @returns An EmblemVaultSolanaWalletClient instance.
|
|
56
|
+
*/
|
|
57
|
+
createSolanaWalletClient(config: Omit<EmblemVaultSolanaWalletClientConfig, 'sdk'>): EmblemVaultSolanaWalletClient;
|
|
58
|
+
/**
|
|
59
|
+
* Ethereum Convenience
|
|
60
|
+
*
|
|
61
|
+
* @param config - Configuration specific to the Solana wallet client, like the walletId.
|
|
62
|
+
* @returns An EmblemVaultSolanaWalletClient instance.
|
|
63
|
+
*/
|
|
64
|
+
getConnectedEthAccount(): Promise<string>;
|
|
65
|
+
getCuratedAssetMetadata(projectName: string, strict?: boolean, overrideFunc?: Function | null): any[];
|
|
66
|
+
getAssetMetadata(projectName: string, strict?: boolean, overrideFunc?: Function | null): any[];
|
|
67
|
+
getAllCuratedAssetMetadata(overrideFunc?: Function | null): any;
|
|
68
|
+
getAllAssetMetadata(overrideFunc?: Function | null): any;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated
|
|
71
|
+
* This method is deprecated and will be removed in a future version.
|
|
72
|
+
* Please use `getInventoryAssetMetadataProject` instead.
|
|
73
|
+
*/
|
|
74
|
+
getRemoteAssetMetadataProjectList(overrideFunc?: Function | null): Promise<any>;
|
|
75
|
+
getInventoryAssetMetadataProject(projectName?: string, overrideFunc?: Function | null): Promise<any>;
|
|
76
|
+
getInventoryAssetMetadata(asset_name: string, overrideFunc?: Function | null): Promise<any>;
|
|
77
|
+
getInventoryAssetMetadataVaultedProjectList(overrideFunc?: Function | null): Promise<any>;
|
|
78
|
+
getAllCuratedProjects(overrideFunc?: Function | null): any[];
|
|
79
|
+
fetchCuratedContracts(hideUnMintable?: boolean, overrideFunc?: Function | null): Promise<CuratedCollectionsResponse>;
|
|
80
|
+
fetchCuratedContractByName(name: string, contracts?: any, overrideFunc?: Function | null): Promise<Collection | null>;
|
|
81
|
+
createCuratedVault(template: any, callback?: any, overrideFunc?: Function | null): Promise<Vault>;
|
|
82
|
+
refreshOwnershipForTokenId(tokenId: string, callback?: any, overrideFunc?: Function | null): Promise<Ownership[]>;
|
|
83
|
+
refreshOwnershipForAccount(account: string, callback?: any, overrideFunc?: Function | null): Promise<Ownership[]>;
|
|
84
|
+
fetchMetadata(tokenId: string, callback?: any, overrideFunc?: Function | null): Promise<MetaData>;
|
|
85
|
+
refreshBalance(tokenId: string, callback?: any, overrideFunc?: Function | null): Promise<Balance[]>;
|
|
86
|
+
fetchVaultsOfType(vaultType: string, address: string, overrideFunc?: Function | null): Promise<any>;
|
|
87
|
+
generateJumpReport(address: string, hideUnMintable?: boolean, overrideFunc?: Function | null): Promise<unknown>;
|
|
88
|
+
generateMintReport(address: string, hideUnMintable?: boolean, overrideFunc?: Function | null): Promise<unknown>;
|
|
89
|
+
generateMigrateReport(address: string, hideUnMintable?: boolean, overrideFunc?: Function | null): Promise<unknown>;
|
|
27
90
|
loadWeb3(): Promise<any | undefined>;
|
|
28
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Performs a mint operation on the blockchain.
|
|
93
|
+
* @param web3 - The web3 instance to use for the transaction.
|
|
94
|
+
* @param tokenId - The ID of the token to mint.
|
|
95
|
+
* @param callback - Optional callback function to handle the transaction.
|
|
96
|
+
* @returns A promise that resolves to the mint response.
|
|
97
|
+
* @deprecated Use `performMintHelper` instead.
|
|
98
|
+
*/
|
|
99
|
+
performMintChain(web3: any, tokenId: string, callback?: any): Promise<{
|
|
29
100
|
mintResponse: any;
|
|
30
101
|
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Stub for new mint chain helper
|
|
104
|
+
* @param amount - The amount of tokens to mint.
|
|
105
|
+
* @param callback - Optional callback function to handle the transaction.
|
|
106
|
+
* @returns A promise that resolves to the mint response.
|
|
107
|
+
*/
|
|
108
|
+
performMintHelper(amount: number, callback?: any): Promise<BigNumber>;
|
|
31
109
|
performClaimChain(web3: any, tokenId: string, serialNumber: any, callback?: any): Promise<any>;
|
|
110
|
+
/**
|
|
111
|
+
* Stub for new mint signature request
|
|
112
|
+
* @param web3 - The web3 instance to use for the transaction.
|
|
113
|
+
* @param tokenId - The ID of the token to mint.
|
|
114
|
+
* @param callback - Optional callback function to handle the transaction.
|
|
115
|
+
* @returns A promise that resolves to the mint signature.
|
|
116
|
+
* @deprecated Use `requestV3LocalMintSignature` instead.
|
|
117
|
+
*/
|
|
32
118
|
requestLocalMintSignature(web3: any, tokenId: string, callback?: any): Promise<any>;
|
|
119
|
+
/**
|
|
120
|
+
* Requests a signature for a curated minting operation. (ONLY ETHEREUM FOR NOW)
|
|
121
|
+
* @param tokenId - The ID of the token to mint.
|
|
122
|
+
* @param callback - Optional callback function to handle the transaction.
|
|
123
|
+
* @param overrideFunc - Optional function to override the default behavior.
|
|
124
|
+
* @returns A promise that resolves to the mint signature.
|
|
125
|
+
*/
|
|
126
|
+
requestV3LocalMintSignature(tokenId: string, callback?: any, overrideFunc?: Function | null): Promise<v3LocalMintSignature>;
|
|
127
|
+
/**
|
|
128
|
+
* Requests a signature for a curated minting operation. (ONLY ETHEREUM FOR NOW)
|
|
129
|
+
* @param tokenId - The ID of the token to mint.
|
|
130
|
+
* @param signature - The signature for the curated minting operation.
|
|
131
|
+
* @param callback - Optional callback function to handle the transaction.
|
|
132
|
+
* @param overrideFunc - Optional function to override the default behavior.
|
|
133
|
+
* @returns A promise that resolves to the remote mint signature.
|
|
134
|
+
* @deprecated Use `requestV3RemoteMintSignature` instead.
|
|
135
|
+
*/
|
|
136
|
+
requestRemoteMintSignature(web3: any, tokenId: string, signature: string, callback?: any, overrideFunc?: Function | null): Promise<any>;
|
|
137
|
+
/**
|
|
138
|
+
* Requests a signature for a curated minting operation. (ONLY ETHEREUM FOR NOW)
|
|
139
|
+
* @param tokenId - The ID of the token to mint.
|
|
140
|
+
* @param signature - The signature for the curated minting operation.
|
|
141
|
+
* @param callback - Optional callback function to handle the transaction.
|
|
142
|
+
* @param overrideFunc - Optional function to override the default behavior.
|
|
143
|
+
* @returns A promise that resolves to the remote mint signature.
|
|
144
|
+
*/
|
|
145
|
+
requestV3RemoteMintSignature(tokenId: string, signature: string, callback?: any, overrideFunc?: Function | null): Promise<any>;
|
|
33
146
|
requestLocalClaimSignature(web3: any, tokenId: string, serialNumber: any, callback?: any): Promise<any>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
147
|
+
requestRemoteClaimToken(web3: any, tokenId: string, signature: string, callback?: any, overrideFunc?: Function | null): Promise<any>;
|
|
148
|
+
requestRemoteKey(tokenId: string, jwt: any, callback?: any, overrideFunc?: Function | null): Promise<any>;
|
|
149
|
+
decryptVaultKeys(tokenId: string, dkeys: any, callback?: any, overrideFunc?: Function | null): Promise<any>;
|
|
150
|
+
recoverSignerFromMessage(message: string, signature: string, overrideFunc?: Function | null): Promise<string>;
|
|
151
|
+
/**
|
|
152
|
+
* ** Emblem Vault AI **
|
|
153
|
+
*
|
|
154
|
+
* Be sure to allow api key requests, or api_key_hash and auth sig (wallet, socialAuth, oAuth)
|
|
155
|
+
* Here we will begin using the aiApiKey and the aiUrl to communicate with the ai vault system
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
vaultInfoFromApiKey(aiApiKey?: string, full?: boolean, overrideFunc?: Function | null): Promise<AiVaultInfo>;
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
|
161
|
+
* Please use alternative methods for price quotation.
|
|
162
|
+
*/
|
|
40
163
|
getQuote(web3: any, amount: number, callback?: any): Promise<BigNumber>;
|
|
41
|
-
performMint(web3: any,
|
|
164
|
+
performMint(web3: any, remoteMintSig: any, callback?: any): Promise<any>;
|
|
42
165
|
performBurn(web3: any, tokenId: any, callback?: any): Promise<any>;
|
|
43
166
|
contentTypeReport(url: string): Promise<unknown>;
|
|
44
167
|
legacyBalanceFromContractByAddress(web3: any, address: string): Promise<number[]>;
|
|
@@ -50,8 +173,5 @@ declare class EmblemVaultSDK {
|
|
|
50
173
|
declare global {
|
|
51
174
|
interface Window {
|
|
52
175
|
EmblemVaultSDK: any;
|
|
53
|
-
web3: any;
|
|
54
|
-
ethereum: any;
|
|
55
176
|
}
|
|
56
177
|
}
|
|
57
|
-
export default EmblemVaultSDK;
|
package/types/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockchainType } from './providers';
|
|
1
2
|
export type ContractDetails = {
|
|
2
3
|
[key: string]: string;
|
|
3
4
|
};
|
|
@@ -78,6 +79,16 @@ export interface MetaData {
|
|
|
78
79
|
ownershipInfo?: any;
|
|
79
80
|
alpha?: boolean;
|
|
80
81
|
}
|
|
82
|
+
export type Balance = {
|
|
83
|
+
coin: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
balance: number;
|
|
86
|
+
symbol?: string;
|
|
87
|
+
address: string;
|
|
88
|
+
type?: string;
|
|
89
|
+
image?: string;
|
|
90
|
+
qty?: number;
|
|
91
|
+
};
|
|
81
92
|
export type Address = {
|
|
82
93
|
path?: string;
|
|
83
94
|
address: string;
|
|
@@ -133,3 +144,35 @@ export type Ownership = {
|
|
|
133
144
|
network: string;
|
|
134
145
|
};
|
|
135
146
|
export type CuratedCollectionsResponse = Collection[];
|
|
147
|
+
export type AiVaultInfo = {
|
|
148
|
+
address: string;
|
|
149
|
+
vaultId: string;
|
|
150
|
+
};
|
|
151
|
+
export type v3LocalMintSignature = {
|
|
152
|
+
message: string;
|
|
153
|
+
signature: string;
|
|
154
|
+
};
|
|
155
|
+
export interface WalletConfig {
|
|
156
|
+
priority?: string[];
|
|
157
|
+
autoConnectWallets?: BlockchainType[];
|
|
158
|
+
}
|
|
159
|
+
declare global {
|
|
160
|
+
interface Window {
|
|
161
|
+
ethereum?: any;
|
|
162
|
+
phantom?: any;
|
|
163
|
+
solflare?: any;
|
|
164
|
+
trustWallet?: any;
|
|
165
|
+
coinbaseWalletExtension?: any;
|
|
166
|
+
bitcoin?: any;
|
|
167
|
+
HiroWalletProvider?: any;
|
|
168
|
+
solana?: any & {
|
|
169
|
+
isPhantom?: boolean;
|
|
170
|
+
isSolflare?: boolean;
|
|
171
|
+
connect?: (options?: {
|
|
172
|
+
onlyIfTrusted?: boolean;
|
|
173
|
+
}) => Promise<any>;
|
|
174
|
+
set?: (config: Record<string, any>) => void;
|
|
175
|
+
};
|
|
176
|
+
web3?: any;
|
|
177
|
+
}
|
|
178
|
+
}
|
package/types/utils.d.ts
CHANGED
|
@@ -22,7 +22,13 @@ export declare function generateTemplate(record: any): any;
|
|
|
22
22
|
export declare function templateGuard(input: {
|
|
23
23
|
[x: string]: any;
|
|
24
24
|
hasOwnProperty: (arg0: string) => any;
|
|
25
|
-
}
|
|
25
|
+
}, options?: {
|
|
26
|
+
throwError?: boolean;
|
|
27
|
+
returnErrors?: boolean;
|
|
28
|
+
}): {
|
|
29
|
+
valid: boolean;
|
|
30
|
+
errors: any[];
|
|
31
|
+
};
|
|
26
32
|
export declare function genericGuard(input: any, type: string, key: string): void;
|
|
27
33
|
export declare function getQuoteContractObject(web3: any): Promise<any>;
|
|
28
34
|
export declare function getHandlerContract(web3: any): Promise<any>;
|
package/dist/abi/quote.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.abi = void 0;
|
|
4
|
-
exports.abi = [
|
|
5
|
-
{
|
|
6
|
-
"inputs": [
|
|
7
|
-
{
|
|
8
|
-
"internalType": "address",
|
|
9
|
-
"name": "buyer",
|
|
10
|
-
"type": "address"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"internalType": "uint256",
|
|
14
|
-
"name": "_usdPrice",
|
|
15
|
-
"type": "uint256"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"name": "quoteExternalPrice",
|
|
19
|
-
"outputs": [
|
|
20
|
-
{
|
|
21
|
-
"internalType": "uint256",
|
|
22
|
-
"name": "",
|
|
23
|
-
"type": "uint256"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"stateMutability": "view",
|
|
27
|
-
"type": "function"
|
|
28
|
-
}
|
|
29
|
-
];
|
package/dist/abi/quote.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"inputs": [
|
|
4
|
-
{
|
|
5
|
-
"internalType": "address",
|
|
6
|
-
"name": "buyer",
|
|
7
|
-
"type": "address"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"internalType": "uint256",
|
|
11
|
-
"name": "_usdPrice",
|
|
12
|
-
"type": "uint256"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"name": "quoteExternalPrice",
|
|
16
|
-
"outputs": [
|
|
17
|
-
{
|
|
18
|
-
"internalType": "uint256",
|
|
19
|
-
"name": "",
|
|
20
|
-
"type": "uint256"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"stateMutability": "view",
|
|
24
|
-
"type": "function"
|
|
25
|
-
}
|
|
26
|
-
]
|
package/jest.config.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: process.env.JEST_ENV === 'browser' ? undefined : 'ts-jest',
|
|
3
|
-
testMatch: process.env.JEST_ENV === 'browser' ? ['**/browser-tests/**/*.test.ts'] : ['**/tests/**/*.test.ts'],
|
|
4
|
-
testEnvironment: process.env.JEST_ENV === 'browser' ? undefined : 'node',
|
|
5
|
-
// other configurations
|
|
6
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import EmblemVaultSDK from '../src/';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
describe('Allowed Function for Bells', () => {
|
|
6
|
-
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
-
|
|
8
|
-
it('Does not allow empty balance', async () => {
|
|
9
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
10
|
-
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
-
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('Requires balance to be greater than zero', async () => {
|
|
15
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
16
|
-
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
17
|
-
balanceValues[0].balance = 0
|
|
18
|
-
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('Requires balance to be an integer', async () => {
|
|
22
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
23
|
-
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
24
|
-
balanceValues[0].balance = 1.5
|
|
25
|
-
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('Requires name to be `Bel`', async () => {
|
|
29
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
30
|
-
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
31
|
-
balanceValues[0].name = 'invalid name'
|
|
32
|
-
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('Does not allow non-bel assets as first value', async () => {
|
|
36
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
37
|
-
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance-with-non-bell-first.json"))
|
|
38
|
-
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('Allows non-bel assets if not first', async () => {
|
|
42
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
43
|
-
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance-with-non-bell.json"))
|
|
44
|
-
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('Allows valid balances', async () => {
|
|
48
|
-
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
49
|
-
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
50
|
-
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
)
|