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
package/test/mocks.js ADDED
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Mock data for Emblem Vault SDK tests
3
+ */
4
+
5
+ // Empty vault creation template
6
+ const empty_create_template = {
7
+ contractName: 'Emblem Open',
8
+ name: 'Test Vault',
9
+ description: 'Test vault created by automated tests',
10
+ image: 'https://emblem.finance/stamps.png',
11
+ fromAddress: '', // Will be populated in tests
12
+ toAddress: '', // Will be populated in tests
13
+ chainId: '1', // Ethereum mainnet
14
+ targetContract: {} // Empty object to prevent null reference errors
15
+ };
16
+
17
+ // Emblem Open vault creation template with more details
18
+ const emblemopen_create_template = {
19
+ contractName: 'Emblem Open',
20
+ name: 'Test Vault with Asset',
21
+ description: 'Test vault with asset created by automated tests',
22
+ image: 'https://emblem.finance/stamps.png',
23
+ fromAddress: '', // Will be populated in tests
24
+ toAddress: '', // Will be populated in tests
25
+ chainId: '1', // Ethereum mainnet
26
+ targetContract: {}, // Empty object to prevent null reference errors
27
+ targetAsset: {
28
+ name: '', // Will be populated in tests
29
+ image: '', // Will be populated in tests
30
+ description: '' // Will be populated in tests
31
+ }
32
+ };
33
+
34
+ // Mock data for API operations tests
35
+ const ethscription_contract = {
36
+ name: 'Ethscription',
37
+ mintable: true,
38
+ description: 'Ethscriptions are digital artifacts inscribed to Ethereum',
39
+ image: 'https://emblem.finance/ethscriptions.png',
40
+ contractAddress: '0x1234567890123456789012345678901234567890'
41
+ };
42
+
43
+ const curated_contracts = [
44
+ {
45
+ name: 'Emblem Open',
46
+ mintable: true,
47
+ description: 'Open template for creating vaults',
48
+ image: 'https://emblem.finance/emblemopen.png',
49
+ contractAddress: '0x0987654321098765432109876543210987654321'
50
+ },
51
+ ethscription_contract,
52
+ {
53
+ name: 'Bitcoin Ordinals',
54
+ mintable: true,
55
+ description: 'Bitcoin Ordinals template',
56
+ image: 'https://emblem.finance/ordinals.png',
57
+ contractAddress: '0xabcdef1234567890abcdef1234567890abcdef12'
58
+ }
59
+ ];
60
+
61
+ const sample_vaults = [
62
+ {
63
+ tokenId: '12345',
64
+ name: 'Test Vault 1',
65
+ description: 'A test vault for integration tests',
66
+ image: 'https://emblem.finance/testvault1.png',
67
+ owner: '0xb0573e14D92755DE30281f7b10d0F3a5DD3e747B',
68
+ contractAddress: '0x0987654321098765432109876543210987654321',
69
+ chainId: '1'
70
+ },
71
+ {
72
+ tokenId: '67890',
73
+ name: 'Test Vault 2',
74
+ description: 'Another test vault for integration tests',
75
+ image: 'https://emblem.finance/testvault2.png',
76
+ owner: '0xb0573e14D92755DE30281f7b10d0F3a5DD3e747B',
77
+ contractAddress: '0x0987654321098765432109876543210987654321',
78
+ chainId: '1'
79
+ }
80
+ ];
81
+
82
+ const bitcoin_ordinals_metadata = [
83
+ {
84
+ projectName: 'Bitcoin Ordinals',
85
+ description: 'Bitcoin Ordinals are digital artifacts on the Bitcoin blockchain',
86
+ image: 'https://emblem.finance/ordinals.png',
87
+ assetId: 'btc-ordinals',
88
+ contractAddress: '0xabcdef1234567890abcdef1234567890abcdef12'
89
+ }
90
+ ];
91
+
92
+ const project_list = [
93
+ {
94
+ name: 'Bitcoin Ordinals',
95
+ description: 'Bitcoin Ordinals are digital artifacts on the Bitcoin blockchain',
96
+ image: 'https://emblem.finance/ordinals.png'
97
+ },
98
+ {
99
+ name: 'Ethscriptions',
100
+ description: 'Ethscriptions are digital artifacts inscribed to Ethereum',
101
+ image: 'https://emblem.finance/ethscriptions.png'
102
+ }
103
+ ];
104
+
105
+ const created_vault_response = {
106
+ data: {
107
+ tokenId: '123456789',
108
+ name: 'Test Vault',
109
+ description: 'Test vault created by automated tests',
110
+ image: 'https://emblem.finance/stamps.png',
111
+ owner: '0xb0573e14D92755DE30281f7b10d0F3a5DD3e747B',
112
+ contractAddress: '0x0987654321098765432109876543210987654321',
113
+ chainId: '1',
114
+ status: 'created'
115
+ }
116
+ };
117
+
118
+ module.exports = {
119
+ empty_create_template,
120
+ emblemopen_create_template,
121
+ ethscription_contract,
122
+ curated_contracts,
123
+ sample_vaults,
124
+ bitcoin_ordinals_metadata,
125
+ project_list,
126
+ created_vault_response
127
+ };
@@ -0,0 +1,25 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "target": "es2018",
5
+ "module": "commonjs",
6
+ "esModuleInterop": true,
7
+ "resolveJsonModule": true,
8
+ "outDir": "../dist-test",
9
+ "rootDir": "./",
10
+ "strict": false,
11
+ "declaration": false,
12
+ "sourceMap": true,
13
+ "baseUrl": "..",
14
+ "paths": {
15
+ "*": ["*"]
16
+ }
17
+ },
18
+ "include": [
19
+ "**/*.ts",
20
+ "**/*.json"
21
+ ],
22
+ "references": [
23
+ { "path": ".." }
24
+ ]
25
+ }
@@ -0,0 +1,53 @@
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 Bells', () => {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires balance to be greater than zero', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bells/balance.json")));
18
+ balanceValues[0].balance = 0;
19
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
20
+ });
21
+
22
+ it('Requires balance to be an integer', async () => {
23
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
24
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bells/balance.json")));
25
+ balanceValues[0].balance = 1.5;
26
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
27
+ });
28
+
29
+ it('Requires name to be `Bel`', async () => {
30
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
31
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bells/balance.json")));
32
+ balanceValues[0].name = 'invalid name';
33
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
34
+ });
35
+
36
+ it('Does not allow non-bel assets as first value', async () => {
37
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
38
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bells/balance-with-non-bell-first.json")));
39
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
40
+ });
41
+
42
+ it('Allows non-bel assets if not first', async () => {
43
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
44
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bells/balance-with-non-bell.json")));
45
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
46
+ });
47
+
48
+ it('Allows valid balances', async () => {
49
+ const curatedContract = await sdk.fetchCuratedContractByName('Bells');
50
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bells/balance.json")));
51
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
52
+ });
53
+ });
@@ -0,0 +1,53 @@
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 Bitcoin DeGods', () => {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires coin to be ordinalsbtc', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-degods/balance.json")));
18
+ balanceValues[0].coin = 'invalid value';
19
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
20
+ });
21
+
22
+ it('Requires balance to be 1', async () => {
23
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
24
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-degods/balance.json")));
25
+ balanceValues[0].balance = 2;
26
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
27
+ });
28
+
29
+ it('Requires project to be DeGods', async () => {
30
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
31
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-degods/balance.json")));
32
+ balanceValues[0].project = 'invalid project';
33
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
34
+ });
35
+
36
+ it('Does not allow non-ordinalsbtc as first coin', async () => {
37
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
38
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-degods/balance-with-non-degods-first.json")));
39
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
40
+ });
41
+
42
+ it('Allows non-ordinalsbtc if not first coin', async () => {
43
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
44
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-degods/balance-with-non-degods.json")));
45
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
46
+ });
47
+
48
+ it('Allows valid balances', async () => {
49
+ const curatedContract = await sdk.fetchCuratedContractByName('Bitcoin DeGods');
50
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-degods/balance.json")));
51
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
52
+ });
53
+ });
@@ -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 BitcoinOrdinals', () => {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('BitcoinOrdinals');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Allows native balance as first value', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('BitcoinOrdinals');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-ordinals/balance-with-native-first.json")));
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
19
+ });
20
+
21
+ it('Does not allow only native balances', async () => {
22
+ const curatedContract = await sdk.fetchCuratedContractByName('BitcoinOrdinals');
23
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-ordinals/balance-with-only-native.json")));
24
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
25
+ });
26
+
27
+ it('Requires first non-native balance to be a bitcoin ordinal', async () => {
28
+ const curatedContract = await sdk.fetchCuratedContractByName('BitcoinOrdinals');
29
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance-with-native-first.json")));
30
+ balanceValues[1].coin = 'invalid coin';
31
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
32
+ });
33
+
34
+ it('Does not allow incorrect coin', async () => {
35
+ const curatedContract = await sdk.fetchCuratedContractByName('BitcoinOrdinals');
36
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-ordinals/balance.json")));
37
+ balanceValues[0].coin = "invalid coin";
38
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
39
+ });
40
+
41
+ it('Allows valid balances', async () => {
42
+ const curatedContract = await sdk.fetchCuratedContractByName('BitcoinOrdinals');
43
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/bitcoin-ordinals/balance.json")));
44
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
45
+ });
46
+ });
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Counterparty Collection Tests
3
+ * Tests for the Counterparty collection's allowed function
4
+ */
5
+
6
+ const { EmblemVaultSDK } = require('../../dist/index');
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { expect } = require('chai');
10
+
11
+ // Test constants
12
+ const API_KEY = 'DEMO_KEY';
13
+
14
+ describe('Allowed Function for Counterparty', function() {
15
+ // Increase timeout for API calls
16
+ this.timeout(10000);
17
+
18
+ const sdk = new EmblemVaultSDK(API_KEY);
19
+
20
+ // Helper function to get fixture path
21
+ const getFixturePath = (filename) => {
22
+ return path.join(__dirname, '../fixtures/counterparty', filename);
23
+ };
24
+
25
+ it('Does not allow empty balance', async () => {
26
+ const curatedContract = await sdk.fetchCuratedContractByName('Counterparty');
27
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
28
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
29
+ });
30
+
31
+ it('Does not allow more than one asset', async () => {
32
+ const curatedContract = await sdk.fetchCuratedContractByName('Counterparty');
33
+ const balanceValues = JSON.parse(fs.readFileSync(getFixturePath("balance-with-multiple.json"), 'utf8'));
34
+ balanceValues[0].coin = 'invalid coin';
35
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
36
+ });
37
+
38
+ it('Does not allow non-native coin', async () => {
39
+ const curatedContract = await sdk.fetchCuratedContractByName('Counterparty');
40
+ const balanceValues = JSON.parse(fs.readFileSync(getFixturePath("balance.json"), 'utf8'));
41
+ balanceValues[0].coin = 'invalid coin';
42
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
43
+ });
44
+
45
+ it('Allows collection chain asset', async () => {
46
+ const curatedContract = await sdk.fetchCuratedContractByName('Counterparty');
47
+ const balanceValues = JSON.parse(fs.readFileSync(getFixturePath("balance.json"), 'utf8'));
48
+
49
+ // For protocol collections, only the collectionChain asset is allowed
50
+ balanceValues[0].coin = curatedContract.collectionChain;
51
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
52
+
53
+ // Test case insensitivity
54
+ balanceValues[0].coin = curatedContract.collectionChain.toUpperCase();
55
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
56
+ });
57
+
58
+ it('Allows valid balance', async () => {
59
+ const curatedContract = await sdk.fetchCuratedContractByName('Counterparty');
60
+ const balanceValues = JSON.parse(fs.readFileSync(getFixturePath("balance.json"), 'utf8'));
61
+
62
+ // Make sure the coin matches the collectionChain for protocol collections
63
+ balanceValues[0].coin = curatedContract.collectionChain;
64
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
65
+ });
66
+ });
@@ -0,0 +1,68 @@
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 Cursed Ordinals', () => {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Does not allow application/json content type', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance.json")));
18
+ balanceValues[0].content_type = 'application/json';
19
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
20
+ });
21
+
22
+ it('Does not allow incorrect coin', async () => {
23
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
24
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance.json")));
25
+ balanceValues[0].coin = "invalid coin";
26
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
27
+ });
28
+
29
+ it('Does not allow incorrect names', async () => {
30
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
31
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance.json")));
32
+ balanceValues[0].name = "Invalid Name";
33
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
34
+
35
+ balanceValues[0].name = "Cursed Ordinal";
36
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
37
+
38
+ balanceValues[0].name = "Cursed Ordinal InvalidNumber";
39
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
40
+
41
+ balanceValues[0].name = "Cursed Ordinal 53888";
42
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
43
+
44
+ balanceValues[0].name = "Invalid Project -53888";
45
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
46
+
47
+ balanceValues[0].name = "Cursed Ordinal -53888";
48
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
49
+ });
50
+
51
+ it('Requires first balance value to be a cursed ordinal', async () => {
52
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
53
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance-with-native-first.json")));
54
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
55
+ });
56
+
57
+ it('Allows non-cursed ordinal balances if not first', async () => {
58
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
59
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance-with-native.json")));
60
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
61
+ });
62
+
63
+ it('Allows valid coin and name', async () => {
64
+ const curatedContract = await sdk.fetchCuratedContractByName('Cursed Ordinal');
65
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/cursed-ordinals/balance.json")));
66
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
67
+ });
68
+ });
@@ -0,0 +1,11 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+
4
+ describe('Allowed Function for Embells', function() {
5
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
6
+
7
+ it('Always allowed', async () => {
8
+ const curatedContract = await sdk.fetchCuratedContractByName('Embels');
9
+ expect(curatedContract.allowed()).to.be.true;
10
+ });
11
+ });
@@ -0,0 +1,11 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { expect } = require('chai');
3
+
4
+ describe('Allowed Function for Embels', function() {
5
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
6
+
7
+ it('Always allowed', async () => {
8
+ const curatedContract = await sdk.fetchCuratedContractByName('Embels');
9
+ expect(curatedContract.allowed()).to.be.true;
10
+ });
11
+ });
@@ -0,0 +1,20 @@
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 EmblemOpen', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('EmblemOpen');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Allows any asset', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('EmblemOpen');
17
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/emblem-open/balance.json")));
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
19
+ });
20
+ });
@@ -0,0 +1,53 @@
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 Ethscriptions', function() {
7
+ // Set timeout for all tests in this suite
8
+ this.timeout(10000);
9
+
10
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
11
+
12
+ it('Does not allow empty balance', async () => {
13
+ const curatedContract = await sdk.fetchCuratedContractByName('Ethscription');
14
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
15
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
16
+ });
17
+
18
+ it("Requires coin to match collectionChain case-insensitively", async () => {
19
+ const curatedContract = await sdk.fetchCuratedContractByName('Ethscription');
20
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ethscriptions/balance.json")));
21
+ // For protocol collections, the coin must match the collectionChain (case insensitive)
22
+ balanceValues[0].coin = "invalid coin";
23
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
24
+
25
+ // Should pass with the correct coin matching collectionChain (case insensitive)
26
+ // Note: The fixture uses "ethscription" (singular) while the collectionChain is "Ethscriptions" (plural)
27
+ // The validation should be case-insensitive but the actual value needs to match exactly
28
+ balanceValues[0].coin = "ethscription"; // exact match to the fixture
29
+ balanceValues[0].project = "Ethscription"; // Add project property matching the contract name
30
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
31
+ });
32
+
33
+ it('Requires first balance value to be an ethscription', async () => {
34
+ const curatedContract = await sdk.fetchCuratedContractByName('Ethscription');
35
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ethscriptions/balance-with-native-first.json")));
36
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
37
+ });
38
+
39
+ it('Allows non-ethscription balances if not first', async () => {
40
+ const curatedContract = await sdk.fetchCuratedContractByName('Ethscription');
41
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ethscriptions/balance-with-native.json")));
42
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
43
+ });
44
+
45
+ it('Allows valid balances', async () => {
46
+ const curatedContract = await sdk.fetchCuratedContractByName('Ethscription');
47
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/ethscriptions/balance.json")));
48
+ // Make sure the coin matches the collectionChain for protocol collections (case insensitive)
49
+ balanceValues[0].coin = "ethscription"; // exact match to the fixture
50
+ balanceValues[0].project = "Ethscription"; // Add project property matching the contract name
51
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
52
+ });
53
+ });
@@ -0,0 +1,77 @@
1
+ const { EmblemVaultSDK } = require('../../dist/index.js');
2
+ const { NFT_DATA } = require('../../dist/utils.js');
3
+ const { expect } = require('chai');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ describe('Allowed Function for Hardcoded NFTs (XCP)', function() {
8
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
9
+
10
+ it('Does not allow empty balance', async () => {
11
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
12
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
13
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
14
+ });
15
+
16
+ it('Requires asset name to be present in hardcoded metadata', async () => {
17
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
18
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance.json")));
19
+ balanceValues[0].name = 'invalid name';
20
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
21
+ });
22
+
23
+ it('Requires projectName in hardcoded data to match curated collection name (case insensitive)', async () => {
24
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
25
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance.json")));
26
+ const hardcodedData = NFT_DATA[balanceValues[0]['name']];
27
+ const validProjectName = hardcodedData['projectName'];
28
+
29
+ NFT_DATA[balanceValues[0]['name']]['projectName'] = validProjectName.toUpperCase();
30
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
31
+
32
+ NFT_DATA[balanceValues[0]['name']]['projectName'] = 'invalid name';
33
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
34
+
35
+ NFT_DATA[balanceValues[0]['name']]['projectName'] = validProjectName;
36
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
37
+ });
38
+
39
+ it('Requires asset project to match curated collection name', async () => {
40
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
41
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance.json")));
42
+ balanceValues[0].project = 'Invalid project';
43
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
44
+ });
45
+
46
+ it('Requires first asset balance to be 1', async () => {
47
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
48
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance.json")));
49
+ balanceValues[0].balance = 2;
50
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
51
+ });
52
+
53
+ it('Allows any coin', async () => {
54
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
55
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance.json")));
56
+ balanceValues[0].coin = 'some coin';
57
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
58
+ });
59
+
60
+ it('Does not allow non hardcoded asset first', async () => {
61
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
62
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json")));
63
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.false;
64
+ });
65
+
66
+ it('Allows non hardcoded assets if not first', async () => {
67
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
68
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json")));
69
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
70
+ });
71
+
72
+ it('Allows valid balances', async () => {
73
+ const curatedContract = await sdk.fetchCuratedContractByName('Age of Chains');
74
+ const balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/hardcoded-nfts/balance.json")));
75
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
76
+ });
77
+ });
@@ -0,0 +1,33 @@
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 Namecoin', function() {
7
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
8
+
9
+ it('Does not allow empty balance', async () => {
10
+ const curatedContract = await sdk.fetchCuratedContractByName('Namecoin');
11
+ expect(curatedContract.allowed(null, curatedContract)).to.be.false;
12
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
13
+ });
14
+
15
+ it('Requires coin to be a native asset', async () => {
16
+ const curatedContract = await sdk.fetchCuratedContractByName('Namecoin');
17
+ let balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/namecoin/balance.json")));
18
+ balanceValues[0].coin = "invalid coin";
19
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
20
+ balanceValues[0].coin = null;
21
+ expect(curatedContract.allowed([], curatedContract)).to.be.false;
22
+ });
23
+
24
+ it('Allows native assets and NFTs in any order', async () => {
25
+ const curatedContract = await sdk.fetchCuratedContractByName('Namecoin');
26
+ let balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/namecoin/balance.json")));
27
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
28
+ balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/namecoin/balance-with-native.json")));
29
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
30
+ balanceValues = JSON.parse(fs.readFileSync(path.join(__dirname, "../fixtures/namecoin/balance-with-native-first.json")));
31
+ expect(curatedContract.allowed(balanceValues, curatedContract)).to.be.true;
32
+ });
33
+ });