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.
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 +21602 -17419
  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 +319 -114
  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 +21602 -17419
  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 +320 -102
  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 -32
  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,46 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ describe('Allowed Function for $ORDI', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('$ORDI');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires specific balance', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('$ORDI');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ordi/balance.json")));
18
+ balanceValues[0].balance = curatedContract.balanceQty - 1;
19
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
20
+ balanceValues[0].balance = curatedContract.balanceQty + 1;
21
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
22
+ });
23
+
24
+ it('Requires specific name', async () => {
25
+ const curatedContract = await sdk.fetchCuratedContractByName('$ORDI');
26
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ordi/balance.json")));
27
+ balanceValues[0].name = `${curatedContract.balanceQty}`;
28
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
29
+ balanceValues[0].name = '$ORDI';
30
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
31
+ balanceValues[0].name = `${curatedContract.balanceQty} $ORDI`;
32
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
33
+ });
34
+
35
+ it('Allows non-ordi balance if not first', async () => {
36
+ const curatedContract = await sdk.fetchCuratedContractByName('$ORDI');
37
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ordi/balance-with-native.json")));
38
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
39
+ });
40
+
41
+ it('Does not allow non-ordi balance as first value', async () => {
42
+ const curatedContract = await sdk.fetchCuratedContractByName('$ORDI');
43
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ordi/balance-with-native-first.json")));
44
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
45
+ });
46
+ });
@@ -0,0 +1,46 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ describe('Allowed Function for $OXBT', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('$OXBT');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires specific balance', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('$OXBT');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/oxbt/balance.json")));
18
+ balanceValues[0].balance = curatedContract.balanceQty - 1;
19
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
20
+ balanceValues[0].balance = curatedContract.balanceQty + 1;
21
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
22
+ });
23
+
24
+ it('Requires specific name', async () => {
25
+ const curatedContract = await sdk.fetchCuratedContractByName('$OXBT');
26
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/oxbt/balance.json")));
27
+ balanceValues[0].name = `${curatedContract.balanceQty}`;
28
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
29
+ balanceValues[0].name = '$ORDI';
30
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
31
+ balanceValues[0].name = `${curatedContract.balanceQty} $OXBT`;
32
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
33
+ });
34
+
35
+ it('Allows non-oxbt balance if not first', async () => {
36
+ const curatedContract = await sdk.fetchCuratedContractByName('$OXBT');
37
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/oxbt/balance-with-native.json")));
38
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
39
+ });
40
+
41
+ it('Does not allow non-oxbt balance as first value', async () => {
42
+ const curatedContract = await sdk.fetchCuratedContractByName('$OXBT');
43
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/oxbt/balance-with-native-first.json")));
44
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
45
+ });
46
+ });
@@ -0,0 +1,51 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ describe('Allowed Function for project collections', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('MegaPunks');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires first asset to have coin matching collectionChain (case insensitive)', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('MegaPunks');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/megapunks/balance.json")));
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
19
+ balanceValues[0].coin = balanceValues[0].coin.toUpperCase();
20
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
21
+ balanceValues[0].coin = balanceValues[0].coin.toLowerCase();
22
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
23
+ balanceValues[0].coin = 'invalid coin';
24
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
25
+ });
26
+
27
+ it('Requires project to match collection name', async () => {
28
+ const curatedContract = await sdk.fetchCuratedContractByName('MegaPunks');
29
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/megapunks/balance.json")));
30
+ balanceValues[0].project = 'invalid project';
31
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
32
+ });
33
+
34
+ it('Does not allow non collection assets if first', async () => {
35
+ const curatedContract = await sdk.fetchCuratedContractByName('MegaPunks');
36
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/megapunks/balance-with-non-megapunk-first.json")));
37
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
38
+ });
39
+
40
+ it('Allows non collection assets if not first', async () => {
41
+ const curatedContract = await sdk.fetchCuratedContractByName('MegaPunks');
42
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/megapunks/balance-with-non-megapunk.json")));
43
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
44
+ });
45
+
46
+ it('Allows valid balances', async () => {
47
+ const curatedContract = await sdk.fetchCuratedContractByName('MegaPunks');
48
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/megapunks/balance.json")));
49
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
50
+ });
51
+ });
@@ -0,0 +1,44 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ describe('Allowed Function for protocol collections', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('Dogeparty');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires first asset to have coin matching collectionChain (case insensitive)', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('Dogeparty');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/dogeparty/balance.json")));
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
19
+ balanceValues[0].coin = balanceValues[0].coin.toUpperCase();
20
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
21
+ balanceValues[0].coin = balanceValues[0].coin.toLowerCase();
22
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
23
+ balanceValues[0].coin = 'invalid coin';
24
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
25
+ });
26
+
27
+ it('Does not allow non collection asset if first', async () => {
28
+ const curatedContract = await sdk.fetchCuratedContractByName('Dogeparty');
29
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/dogeparty/balance-with-non-dogeparty-first.json")));
30
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
31
+ });
32
+
33
+ it('Allows non collection assets if not first', async () => {
34
+ const curatedContract = await sdk.fetchCuratedContractByName('Dogeparty');
35
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/dogeparty/balance-with-non-dogeparty.json")));
36
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
37
+ });
38
+
39
+ it('Allows valid balances', async () => {
40
+ const curatedContract = await sdk.fetchCuratedContractByName('Dogeparty');
41
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/dogeparty/balance.json")));
42
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
43
+ });
44
+ });
@@ -0,0 +1,78 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ describe('Allowed Function for Stamps', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires asset name to include `stamps`', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance.json")));
18
+ balanceValues[0].name = 'invalid asset name';
19
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
20
+ });
21
+
22
+ it('Requires project name', async () => {
23
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
24
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance.json")));
25
+ const originalProject = balanceValues[0].project;
26
+ // balanceValues[0].project = null;
27
+ delete balanceValues[0].project;
28
+ const result = curatedContract.allowed(balanceValues, curatedContract);
29
+ expect(result).to.be.false; // Check for any falsy value (false, null, undefined, 0, "")
30
+ // Restore the original project for future tests
31
+ balanceValues[0].project = originalProject;
32
+ });
33
+
34
+ it('Requires project name to be Stamps or Stampunks', async () => {
35
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
36
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance.json")));
37
+ balanceValues[0].project = 'invalid project';
38
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
39
+ });
40
+
41
+ it('Allows case insensitive project name', async () => {
42
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
43
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance.json")));
44
+ balanceValues[0].project = 'STAMPS';
45
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
46
+ balanceValues[0].project = 'STAMPUNKS';
47
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
48
+ });
49
+
50
+ it('Requires coin to be a native asset', async () => {
51
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
52
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance.json")));
53
+ balanceValues[0].coin = 'invalid coin';
54
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
55
+ for (var nativeAsset of curatedContract.nativeAssets) {
56
+ balanceValues[0].coin = nativeAsset;
57
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
58
+ }
59
+ });
60
+
61
+ it('Requires first asset to be a stamp', async () => {
62
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
63
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance-with-non-stamps-first.json")));
64
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
65
+ });
66
+
67
+ it('Allows non-stamps assets if not first', async () => {
68
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
69
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance-with-non-stamps.json")));
70
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
71
+ });
72
+
73
+ it('Allows valid balances', async () => {
74
+ const curatedContract = await sdk.fetchCuratedContractByName('Stamps');
75
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/stamps/balance.json")));
76
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
77
+ });
78
+ });
@@ -0,0 +1,10 @@
1
+ const { NFT_DATA } = require('../../dist/utils.js');
2
+ const { expect } = require('chai');
3
+
4
+ describe('Hardcoded Metadata for Darkfarms', function() {
5
+ it('NFT_DATA includes Darkfarms', async () => {
6
+ const token = NFT_DATA["BANKINISSAFE"];
7
+ expect(token).to.exist;
8
+ expect(token.projectName).to.equal("Darkfarms");
9
+ });
10
+ });
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Emblem Vault SDK Unit Tests
3
+ * Core functionality tests for the SDK
4
+ */
5
+
6
+ const { EmblemVaultSDK } = require('../../dist/index');
7
+ const { expect } = require('chai');
8
+
9
+ // Test constants
10
+ const API_KEY = 'DEMO_KEY';
11
+ const TEST_ADDRESS = '0x0000000000000000000000000000000000000000';
12
+
13
+ // We'll get the actual templates from the SDK rather than hardcoding them
14
+ let mocks = {};
15
+
16
+ /**
17
+ * Unit tests for the EmblemVaultSDK
18
+ *
19
+ * Note: Tests that require live API calls have been moved to the integration test suite:
20
+ * - test/integration/ApiOperations.spec.js
21
+ * - test/integration/VaultCreation.spec.js
22
+ */
23
+ describe('EmblemVaultSDK', () => {
24
+ describe('Non Writing Operations', () => {
25
+ let sdk = new EmblemVaultSDK(API_KEY);
26
+
27
+ // before(() => {
28
+ // sdk = new EmblemVaultSDK(API_KEY);
29
+ // });
30
+
31
+ it('should create a valid SDK instance with an API key', () => {
32
+ expect(sdk).to.be.instanceOf(EmblemVaultSDK);
33
+ });
34
+
35
+ it('should throw an error when no API key is provided', () => {
36
+ expect(() => {
37
+ new EmblemVaultSDK('');
38
+ }).to.throw('API key is required');
39
+ });
40
+
41
+ it('should get all asset metadata', () => {
42
+ const metadata = sdk.getAllAssetMetadata();
43
+ expect(metadata).to.be.an('array');
44
+ expect(metadata.length).to.be.greaterThan(0);
45
+ // Check that the metadata has the expected structure
46
+ expect(metadata[0]).to.have.property('projectName');
47
+ });
48
+
49
+ it('should get all asset metadata using an override function', () => {
50
+ // Create a mock override function that returns predefined data
51
+ const mockData = [
52
+ { projectName: 'Project1', description: 'Description 1' },
53
+ { projectName: 'Project2', description: 'Description 2' },
54
+ { projectName: 'Project3', description: 'Description 3' }
55
+ ];
56
+
57
+ const overrideFunc = () => mockData;
58
+
59
+ // Call getAllAssetMetadata with the override function
60
+ const metadata = sdk.getAllAssetMetadata(overrideFunc);
61
+
62
+ expect(metadata).to.be.an('array');
63
+ expect(metadata).to.deep.equal(mockData);
64
+ expect(metadata[0].projectName).to.equal('Project1');
65
+ expect(metadata[1].projectName).to.equal('Project2');
66
+ expect(metadata[2].projectName).to.equal('Project3');
67
+ });
68
+
69
+ it('should get asset metadata for a project', async () => {
70
+ // Create a mock override function that returns predefined data
71
+ // This is necessary because the real API might return unexpected data format
72
+ const mockData = {
73
+ "EVTESTCOMMON": {
74
+ "image": "https://emblem.finance/EVTESTCOMMON.gif",
75
+ "projectName": "Emblem Test"
76
+ },
77
+ "EVTESTEPIC": {
78
+ "image": "https://emblem.finance/EVTESTEPIC.gif",
79
+ "projectName": "Emblem Test"
80
+ },
81
+ "EVTESTLEGEND": {
82
+ "image": "https://emblem.finance/EVTESTLEGEND.jpg",
83
+ "projectName": "Emblem Test"
84
+ }
85
+ };
86
+
87
+ const overrideFunc = () => mockData
88
+
89
+ const metadata = await sdk.getAssetMetadata('Emblem Test', false, overrideFunc);
90
+ expect(metadata).to.be.an('array');
91
+ expect(metadata.length).to.equal(3);
92
+ expect(metadata[0].projectName).to.equal('Emblem Test');
93
+ });
94
+
95
+ it('should get asset metadata with case-insensitive matching by default', async () => {
96
+ // Create a mock override function that returns predefined data
97
+ const mockData = {
98
+ "EVTESTLEGEND": {
99
+ "image": "https://emblem.finance/EVTESTLEGEND.jpg",
100
+ "projectName": "CaseSensitive"
101
+ }
102
+ };
103
+
104
+ const overrideFunc = () => mockData;
105
+
106
+ // Call with different case but strict=false (default)
107
+ const metadata = await sdk.getAssetMetadata('casesensitive', false, overrideFunc);
108
+
109
+ expect(metadata).to.be.an('array');
110
+ expect(metadata).to.have.lengthOf(1);
111
+ expect(metadata[0].projectName).to.equal('CaseSensitive');
112
+ });
113
+
114
+ it('should respect strict matching when specified', async () => {
115
+ // Create a mock override function that returns predefined data
116
+ const mockData = [
117
+ { projectName: 'CaseSensitive', description: 'This tests case sensitivity' }
118
+ ];
119
+
120
+ const overrideFunc = async () => mockData;
121
+
122
+ // Call with different case and strict=true
123
+ const metadata = await sdk.getAssetMetadata('casesensitive', true, overrideFunc);
124
+
125
+ expect(metadata).to.be.an('array');
126
+ expect(metadata).to.have.lengthOf(0); // Should find nothing with strict matching
127
+ });
128
+
129
+ it('should get curated contracts', async () => {
130
+ const contracts = await sdk.fetchCuratedContracts();
131
+ expect(contracts).to.be.an('array');
132
+ expect(contracts.length).to.be.greaterThan(0);
133
+
134
+ // Store contract templates for later tests
135
+ const emblemOpenContract = contracts.find(contract => contract.name === "EmblemOpen");
136
+ const bitcoinOrdinalsContract = contracts.find(contract => contract.name === "BitcoinOrdinals");
137
+
138
+ if (emblemOpenContract) {
139
+ mocks.emblemopen_create_template = emblemOpenContract.generateCreateTemplate(emblemOpenContract);
140
+ }
141
+
142
+ if (bitcoinOrdinalsContract) {
143
+ mocks.empty_create_template = bitcoinOrdinalsContract.generateCreateTemplate(bitcoinOrdinalsContract);
144
+ }
145
+ });
146
+
147
+ it('should make template with functions', async () => {
148
+ const contracts = await sdk.fetchCuratedContracts();
149
+ expect(contracts[0]["generateVaultBody"]).to.be.a('function');
150
+ });
151
+
152
+ it('should generate create template correctly for emblem open', async () => {
153
+ const contracts = await sdk.fetchCuratedContracts();
154
+ let contract = contracts.find(contract => contract.name === "EmblemOpen");
155
+ const template = contract?.generateCreateTemplate(contract);
156
+
157
+ // Verify the template has the expected structure
158
+ expect(template).to.be.an('object');
159
+ expect(template).to.have.property('targetAsset');
160
+ expect(template.targetAsset).to.have.property('name');
161
+ });
162
+
163
+ it('should generate create template correctly for empty', async () => {
164
+ const contracts = await sdk.fetchCuratedContracts();
165
+ let contract = contracts.find(contract => contract.name === "BitcoinOrdinals");
166
+ const template = contract?.generateCreateTemplate(contract);
167
+
168
+ // Verify the template has the expected structure
169
+ expect(template).to.be.an('object');
170
+ expect(template).to.have.property('targetAsset');
171
+ });
172
+
173
+ it('should fetch metadata', async () => {
174
+ const metadata = await sdk.fetchMetadata("1337");
175
+ expect(metadata).to.be.an('object');
176
+ expect(metadata.name).to.equal("Patrick's Birthday Vault");
177
+ });
178
+
179
+ it('should fetch vaults of type', async () => {
180
+ const vaults = await sdk.fetchVaultsOfType("created", TEST_ADDRESS);
181
+ expect(vaults).to.be.an('array');
182
+ // todo: test for a non-zero value address
183
+ expect(vaults.length).to.be.at.least(0);
184
+ });
185
+ });
186
+
187
+ // Note: Vault Creation tests have been moved to integration tests
188
+ });