emblem-vault-sdk 1.9.14 → 1.9.15

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 (62) hide show
  1. package/dist/bundle.js +15 -14
  2. package/dist/index.js +1 -1
  3. package/dist/utils.js +14 -13
  4. package/docs/bundle.js +15 -14
  5. package/package.json +1 -1
  6. package/src/utils.ts +16 -12
  7. package/tests/AllowedBells.test.ts +53 -0
  8. package/tests/AllowedBitcoinDeGods.test.ts +53 -0
  9. package/tests/AllowedBitcoinOrdinals.test.ts +46 -0
  10. package/tests/AllowedCounterparty.test.ts +45 -0
  11. package/tests/AllowedCursedOrdinals.test.ts +68 -0
  12. package/tests/AllowedEmbells.test.ts +12 -0
  13. package/tests/AllowedEmbels.test.ts +16 -0
  14. package/tests/AllowedEmblemOpen.test.ts +20 -0
  15. package/tests/AllowedEthscriptions.test.ts +39 -0
  16. package/tests/AllowedHardcodedNfts.test.ts +78 -0
  17. package/tests/AllowedNamecoin.test.ts +33 -0
  18. package/tests/AllowedOrdi.test.ts +47 -0
  19. package/tests/AllowedOxbt.test.ts +47 -0
  20. package/tests/AllowedProjectlCollection.test.ts +51 -0
  21. package/tests/AllowedProtocolCollection.test.ts +44 -0
  22. package/tests/AllowedStamps.test.ts +73 -0
  23. package/tests/fixtures/bells/balance-with-non-bell-first.json +14 -0
  24. package/tests/fixtures/bells/balance-with-non-bell.json +14 -0
  25. package/tests/fixtures/bells/balance.json +9 -0
  26. package/tests/fixtures/bitcoin-degods/balance-with-non-degods-first.json +57 -0
  27. package/tests/fixtures/bitcoin-degods/balance-with-non-degods.json +57 -0
  28. package/tests/fixtures/bitcoin-degods/balance.json +52 -0
  29. package/tests/fixtures/bitcoin-ordinals/balance-with-native-first.json +17 -0
  30. package/tests/fixtures/bitcoin-ordinals/balance-with-only-native.json +12 -0
  31. package/tests/fixtures/bitcoin-ordinals/balance.json +42 -0
  32. package/tests/fixtures/counterparty/balance-with-multiple.json +47 -0
  33. package/tests/fixtures/counterparty/balance.json +42 -0
  34. package/tests/fixtures/cursed-ordinals/balance-with-native-first.json +15 -0
  35. package/tests/fixtures/cursed-ordinals/balance-with-native.json +15 -0
  36. package/tests/fixtures/cursed-ordinals/balance.json +11 -0
  37. package/tests/fixtures/dogeparty/balance-with-non-dogeparty-first.json +16 -0
  38. package/tests/fixtures/dogeparty/balance-with-non-dogeparty.json +16 -0
  39. package/tests/fixtures/dogeparty/balance.json +11 -0
  40. package/tests/fixtures/embels/balance.json +10 -0
  41. package/tests/fixtures/emblem-open/balance.json +244 -0
  42. package/tests/fixtures/ethscriptions/balance-with-native-first.json +69 -0
  43. package/tests/fixtures/ethscriptions/balance-with-native.json +37 -0
  44. package/tests/fixtures/ethscriptions/balance.json +64 -0
  45. package/tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json +20 -0
  46. package/tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json +20 -0
  47. package/tests/fixtures/hardcoded-nfts/balance.json +15 -0
  48. package/tests/fixtures/megapunks/balance-with-non-megapunk-first.json +48 -0
  49. package/tests/fixtures/megapunks/balance-with-non-megapunk.json +48 -0
  50. package/tests/fixtures/megapunks/balance.json +43 -0
  51. package/tests/fixtures/namecoin/balance-with-native-first.json +109 -0
  52. package/tests/fixtures/namecoin/balance-with-native.json +109 -0
  53. package/tests/fixtures/namecoin/balance.json +103 -0
  54. package/tests/fixtures/ordi/balance-with-native-first.json +13 -0
  55. package/tests/fixtures/ordi/balance-with-native.json +13 -0
  56. package/tests/fixtures/ordi/balance.json +8 -0
  57. package/tests/fixtures/oxbt/balance-with-native-first.json +13 -0
  58. package/tests/fixtures/oxbt/balance-with-native.json +13 -0
  59. package/tests/fixtures/oxbt/balance.json +8 -0
  60. package/tests/fixtures/stamps/balance-with-non-stamps-first.json +23 -0
  61. package/tests/fixtures/stamps/balance-with-non-stamps.json +23 -0
  62. package/tests/fixtures/stamps/balance.json +18 -0
package/dist/bundle.js CHANGED
@@ -709476,7 +709476,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
709476
709476
  const bignumber_1 = require("@ethersproject/bignumber");
709477
709477
  const utils_1 = require("./utils");
709478
709478
  const derive_1 = require("./derive");
709479
- const SDK_VERSION = '1.9.14';
709479
+ const SDK_VERSION = '1.9.15';
709480
709480
  class EmblemVaultSDK {
709481
709481
  constructor(apiKey, baseUrl) {
709482
709482
  this.apiKey = apiKey;
@@ -710104,7 +710104,7 @@ function projectsFromMetadataJson() {
710104
710104
  for (var key in exports.NFT_DATA) {
710105
710105
  const projectName = exports.NFT_DATA[key]["projectName"];
710106
710106
  if (!projects.includes(projectName)) {
710107
- projects.push();
710107
+ projects.push(projectName);
710108
710108
  }
710109
710109
  }
710110
710110
  return projects;
@@ -710319,21 +710319,23 @@ function generateTemplate(record) {
710319
710319
  *
710320
710320
  * @param {Array} data - data is a list of balance Value objects
710321
710321
  * (see Value's interface definition in emblemvault.io-v3)
710322
+ * @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
710323
+ * It should be further embellished with tokenId and serialNumber properties.
710322
710324
  * @param {function} - msgCallback should be a function that takes a string message
710323
710325
  */
710324
710326
  allowed: (data, _this, msgCallback = null) => {
710325
710327
  var _a;
710326
- if ((!data || data.length == 0) && recordName != "Embels") {
710328
+ if (recordName == "Embels") {
710329
+ return true;
710330
+ }
710331
+ if ((!data || data.length == 0)) {
710327
710332
  return false;
710328
710333
  }
710329
710334
  let allowed = false;
710330
710335
  let firstAsset = data[0];
710331
710336
  let assetName = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.name) ? firstAsset.name : "";
710332
710337
  let message = null;
710333
- if (recordName == "Embels") {
710334
- allowed = true;
710335
- }
710336
- else if (recordName == "Cursed Ordinal") {
710338
+ if (recordName == "Cursed Ordinal") {
710337
710339
  if (data && data.length > 0) {
710338
710340
  let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
710339
710341
  let pieces = assetName.split(' ');
@@ -710391,7 +710393,9 @@ function generateTemplate(record) {
710391
710393
  allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
710392
710394
  }
710393
710395
  else if (PROJECTS_DATA.includes(recordName)) { // XCP
710394
- allowed = !!exports.NFT_DATA[assetName] && exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase();
710396
+ allowed = !!exports.NFT_DATA[assetName] &&
710397
+ exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
710398
+ firstAsset.project == _this.name && firstAsset.balance == 1;
710395
710399
  }
710396
710400
  else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
710397
710401
  allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
@@ -710404,15 +710408,12 @@ function generateTemplate(record) {
710404
710408
  if (!allowedChain) {
710405
710409
  message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
710406
710410
  }
710407
- const allowedAProject = firstAsset.project == recordName;
710408
- if (!allowedAProject) {
710411
+ const allowedProject = firstAsset.project == recordName;
710412
+ if (!allowedProject) {
710409
710413
  message = (message ? `${message} ` : '') +
710410
710414
  `Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
710411
710415
  }
710412
- allowed = allowedChain && allowedAProject;
710413
- }
710414
- else { // XCP
710415
- allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
710416
+ allowed = allowedChain && allowedProject;
710416
710417
  }
710417
710418
  if (message && msgCallback) {
710418
710419
  msgCallback(message);
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
35
  const bignumber_1 = require("@ethersproject/bignumber");
36
36
  const utils_1 = require("./utils");
37
37
  const derive_1 = require("./derive");
38
- const SDK_VERSION = '1.9.14';
38
+ const SDK_VERSION = '1.9.15';
39
39
  class EmblemVaultSDK {
40
40
  constructor(apiKey, baseUrl) {
41
41
  this.apiKey = apiKey;
package/dist/utils.js CHANGED
@@ -29,7 +29,7 @@ function projectsFromMetadataJson() {
29
29
  for (var key in exports.NFT_DATA) {
30
30
  const projectName = exports.NFT_DATA[key]["projectName"];
31
31
  if (!projects.includes(projectName)) {
32
- projects.push();
32
+ projects.push(projectName);
33
33
  }
34
34
  }
35
35
  return projects;
@@ -244,21 +244,23 @@ function generateTemplate(record) {
244
244
  *
245
245
  * @param {Array} data - data is a list of balance Value objects
246
246
  * (see Value's interface definition in emblemvault.io-v3)
247
+ * @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
248
+ * It should be further embellished with tokenId and serialNumber properties.
247
249
  * @param {function} - msgCallback should be a function that takes a string message
248
250
  */
249
251
  allowed: (data, _this, msgCallback = null) => {
250
252
  var _a;
251
- if ((!data || data.length == 0) && recordName != "Embels") {
253
+ if (recordName == "Embels") {
254
+ return true;
255
+ }
256
+ if ((!data || data.length == 0)) {
252
257
  return false;
253
258
  }
254
259
  let allowed = false;
255
260
  let firstAsset = data[0];
256
261
  let assetName = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.name) ? firstAsset.name : "";
257
262
  let message = null;
258
- if (recordName == "Embels") {
259
- allowed = true;
260
- }
261
- else if (recordName == "Cursed Ordinal") {
263
+ if (recordName == "Cursed Ordinal") {
262
264
  if (data && data.length > 0) {
263
265
  let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
264
266
  let pieces = assetName.split(' ');
@@ -316,7 +318,9 @@ function generateTemplate(record) {
316
318
  allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
317
319
  }
318
320
  else if (PROJECTS_DATA.includes(recordName)) { // XCP
319
- allowed = !!exports.NFT_DATA[assetName] && exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase();
321
+ allowed = !!exports.NFT_DATA[assetName] &&
322
+ exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
323
+ firstAsset.project == _this.name && firstAsset.balance == 1;
320
324
  }
321
325
  else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
322
326
  allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
@@ -329,15 +333,12 @@ function generateTemplate(record) {
329
333
  if (!allowedChain) {
330
334
  message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
331
335
  }
332
- const allowedAProject = firstAsset.project == recordName;
333
- if (!allowedAProject) {
336
+ const allowedProject = firstAsset.project == recordName;
337
+ if (!allowedProject) {
334
338
  message = (message ? `${message} ` : '') +
335
339
  `Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
336
340
  }
337
- allowed = allowedChain && allowedAProject;
338
- }
339
- else { // XCP
340
- allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
341
+ allowed = allowedChain && allowedProject;
341
342
  }
342
343
  if (message && msgCallback) {
343
344
  msgCallback(message);
package/docs/bundle.js CHANGED
@@ -709476,7 +709476,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
709476
709476
  const bignumber_1 = require("@ethersproject/bignumber");
709477
709477
  const utils_1 = require("./utils");
709478
709478
  const derive_1 = require("./derive");
709479
- const SDK_VERSION = '1.9.14';
709479
+ const SDK_VERSION = '1.9.15';
709480
709480
  class EmblemVaultSDK {
709481
709481
  constructor(apiKey, baseUrl) {
709482
709482
  this.apiKey = apiKey;
@@ -710104,7 +710104,7 @@ function projectsFromMetadataJson() {
710104
710104
  for (var key in exports.NFT_DATA) {
710105
710105
  const projectName = exports.NFT_DATA[key]["projectName"];
710106
710106
  if (!projects.includes(projectName)) {
710107
- projects.push();
710107
+ projects.push(projectName);
710108
710108
  }
710109
710109
  }
710110
710110
  return projects;
@@ -710319,21 +710319,23 @@ function generateTemplate(record) {
710319
710319
  *
710320
710320
  * @param {Array} data - data is a list of balance Value objects
710321
710321
  * (see Value's interface definition in emblemvault.io-v3)
710322
+ * @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
710323
+ * It should be further embellished with tokenId and serialNumber properties.
710322
710324
  * @param {function} - msgCallback should be a function that takes a string message
710323
710325
  */
710324
710326
  allowed: (data, _this, msgCallback = null) => {
710325
710327
  var _a;
710326
- if ((!data || data.length == 0) && recordName != "Embels") {
710328
+ if (recordName == "Embels") {
710329
+ return true;
710330
+ }
710331
+ if ((!data || data.length == 0)) {
710327
710332
  return false;
710328
710333
  }
710329
710334
  let allowed = false;
710330
710335
  let firstAsset = data[0];
710331
710336
  let assetName = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.name) ? firstAsset.name : "";
710332
710337
  let message = null;
710333
- if (recordName == "Embels") {
710334
- allowed = true;
710335
- }
710336
- else if (recordName == "Cursed Ordinal") {
710338
+ if (recordName == "Cursed Ordinal") {
710337
710339
  if (data && data.length > 0) {
710338
710340
  let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
710339
710341
  let pieces = assetName.split(' ');
@@ -710391,7 +710393,9 @@ function generateTemplate(record) {
710391
710393
  allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
710392
710394
  }
710393
710395
  else if (PROJECTS_DATA.includes(recordName)) { // XCP
710394
- allowed = !!exports.NFT_DATA[assetName] && exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase();
710396
+ allowed = !!exports.NFT_DATA[assetName] &&
710397
+ exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
710398
+ firstAsset.project == _this.name && firstAsset.balance == 1;
710395
710399
  }
710396
710400
  else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
710397
710401
  allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
@@ -710404,15 +710408,12 @@ function generateTemplate(record) {
710404
710408
  if (!allowedChain) {
710405
710409
  message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
710406
710410
  }
710407
- const allowedAProject = firstAsset.project == recordName;
710408
- if (!allowedAProject) {
710411
+ const allowedProject = firstAsset.project == recordName;
710412
+ if (!allowedProject) {
710409
710413
  message = (message ? `${message} ` : '') +
710410
710414
  `Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
710411
710415
  }
710412
- allowed = allowedChain && allowedAProject;
710413
- }
710414
- else { // XCP
710415
- allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
710416
+ allowed = allowedChain && allowedProject;
710416
710417
  }
710417
710418
  if (message && msgCallback) {
710418
710419
  msgCallback(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emblem-vault-sdk",
3
- "version": "1.9.14",
3
+ "version": "1.9.15",
4
4
  "description": "Emblem Vault Software Development Kit",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/utils.ts CHANGED
@@ -17,7 +17,7 @@ function projectsFromMetadataJson() {
17
17
  for (var key in NFT_DATA) {
18
18
  const projectName = NFT_DATA[key]["projectName"]
19
19
  if (!projects.includes(projectName)) {
20
- projects.push()
20
+ projects.push(projectName)
21
21
  }
22
22
  }
23
23
  return projects
@@ -230,10 +230,16 @@ export function generateTemplate(record: any) {
230
230
  *
231
231
  * @param {Array} data - data is a list of balance Value objects
232
232
  * (see Value's interface definition in emblemvault.io-v3)
233
+ * @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
234
+ * It should be further embellished with tokenId and serialNumber properties.
233
235
  * @param {function} - msgCallback should be a function that takes a string message
234
236
  */
235
237
  allowed: (data: any[], _this: any, msgCallback: any = null) => {
236
- if ((!data || data.length == 0)&& recordName != "Embels") {
238
+ if (recordName == "Embels"){
239
+ return true
240
+ }
241
+
242
+ if ((!data || data.length == 0) ) {
237
243
  return false
238
244
  }
239
245
 
@@ -241,10 +247,8 @@ export function generateTemplate(record: any) {
241
247
  let firstAsset = data[0]
242
248
  let assetName = firstAsset?.name ? firstAsset.name : ""
243
249
  let message = null
244
- if (recordName == "Embels"){
245
- allowed = true
246
- }
247
- else if (recordName == "Cursed Ordinal") {
250
+
251
+ if (recordName == "Cursed Ordinal") {
248
252
  if (data && data.length > 0) {
249
253
  let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc"
250
254
  let pieces = assetName.split(' ')
@@ -291,7 +295,9 @@ export function generateTemplate(record: any) {
291
295
  } else if (recordName == "Bitcoin DeGods") {
292
296
  allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods"
293
297
  } else if (PROJECTS_DATA.includes(recordName)) { // XCP
294
- allowed = !!NFT_DATA[assetName] && NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase();
298
+ allowed = !!NFT_DATA[assetName] &&
299
+ NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
300
+ firstAsset.project == _this.name && firstAsset.balance == 1;
295
301
  } else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
296
302
  allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase()
297
303
  if(!allowed){
@@ -302,14 +308,12 @@ export function generateTemplate(record: any) {
302
308
  if(!allowedChain) {
303
309
  message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`
304
310
  }
305
- const allowedAProject = firstAsset.project == recordName
306
- if(!allowedAProject){
311
+ const allowedProject = firstAsset.project == recordName
312
+ if(!allowedProject){
307
313
  message = (message ? `${message} ` : '') +
308
314
  `Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`
309
315
  }
310
- allowed = allowedChain && allowedAProject
311
- } else { // XCP
312
- allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
316
+ allowed = allowedChain && allowedProject
313
317
  }
314
318
 
315
319
  if (message && msgCallback) {
@@ -0,0 +1,53 @@
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
+ )
@@ -0,0 +1,53 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+ const fs = require('fs');
4
+
5
+ describe('Allowed Function for Bitcoin DeGods', () => {
6
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
7
+
8
+ it('Does not allow empty balance', async () => {
9
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
10
+ expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
11
+ expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
12
+ })
13
+
14
+ it('Requires coin to be ordinalsbtc', async () => {
15
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
16
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
17
+ balanceValues[0].coin = 'invalid value'
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
19
+ })
20
+
21
+ it('Requires balance to be 1', async () => {
22
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
23
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
24
+ balanceValues[0].balance = 2
25
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
26
+ })
27
+
28
+ it('Requires project to be DeGods', async () => {
29
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
30
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
31
+ balanceValues[0].project = 'invalid project'
32
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
33
+ })
34
+
35
+ it('Does not allow non-ordinalsbtc as first coin', async () => {
36
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
37
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance-with-non-degods-first.json"))
38
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
39
+ })
40
+
41
+ it('Allows non-ordinalsbtc if not first coin', async () => {
42
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
43
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance-with-non-degods.json"))
44
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
45
+ })
46
+
47
+ it('Allows valid balances', async () => {
48
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
49
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
50
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
51
+ })
52
+ }
53
+ )
@@ -0,0 +1,46 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+ const fs = require('fs');
4
+
5
+ describe('Allowed Function for BitcoinOrdinals', () => {
6
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
7
+
8
+ it('Does not allow empty balance', async () => {
9
+ const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
10
+ expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
11
+ expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
12
+ })
13
+
14
+ it('Allows native balance as first value', async () => {
15
+ const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
16
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance-with-native-first.json"))
17
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
18
+ })
19
+
20
+ it('Does not allow only native balances', async () => {
21
+ const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
22
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance-with-only-native.json"))
23
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
24
+ })
25
+
26
+ it('Requires first non-native balance to be a bitcoin ordinal', async () => {
27
+ const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
28
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance-with-native-first.json"))
29
+ balanceValues[1].coin = 'invalid coin'
30
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
31
+ })
32
+
33
+ it('Does not allow incorrect coin', async () => {
34
+ const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
35
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance.json"))
36
+ balanceValues[0].coin = "invalid coin"
37
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
38
+ })
39
+
40
+ it('Allows valid balances', async () => {
41
+ const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
42
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance.json"))
43
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
44
+ })
45
+ }
46
+ )
@@ -0,0 +1,45 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+ const fs = require('fs');
4
+
5
+ describe('Allowed Function for Counterparty', () => {
6
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
7
+
8
+ it('Does not allow empty balance', async () => {
9
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
10
+ expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
11
+ expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
12
+ })
13
+
14
+ it('Does not allow more than one asset', async () => {
15
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
16
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance-with-multiple.json"))
17
+ balanceValues[0].coin = 'invalid coin'
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
19
+ })
20
+
21
+ it('Does not allow non-native coin', async () => {
22
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
23
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance.json"))
24
+ balanceValues[0].coin = 'invalid coin'
25
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
26
+ })
27
+
28
+ it('Allows any native coin', async () => {
29
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
30
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance.json"))
31
+ for (var nativeAsset of curatedContract.nativeAssets) {
32
+ balanceValues[0].coin = nativeAsset
33
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
34
+ }
35
+ })
36
+
37
+ it('Allows valid balance', async () => {
38
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
39
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance.json"))
40
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
41
+ })
42
+
43
+
44
+ }
45
+ )
@@ -0,0 +1,68 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+ const fs = require('fs');
4
+
5
+ describe('Allowed Function for Cursed Ordinals', () => {
6
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
7
+
8
+ it('Does not allow empty balance', async () => {
9
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
10
+ expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
11
+ expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
12
+ })
13
+
14
+ it('Does not allow application/json content type', async () => {
15
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
16
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
17
+ balanceValues[0].content_type = 'application/json'
18
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
19
+ })
20
+
21
+ it('Does not allow incorrect coin', async () => {
22
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
23
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
24
+ balanceValues[0].coin = "invalid coin"
25
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
26
+ })
27
+
28
+ it('Does not allow incorrect names', async () => {
29
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
30
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
31
+ balanceValues[0].name = "Invalid Name"
32
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
33
+
34
+ balanceValues[0].name = "Cursed Ordinal"
35
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
36
+
37
+ balanceValues[0].name = "Cursed Ordinal InvalidNumber"
38
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
39
+
40
+ balanceValues[0].name = "Cursed Ordinal 53888"
41
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
42
+
43
+ balanceValues[0].name = "Invalid Project -53888"
44
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
45
+
46
+ balanceValues[0].name = "Cursed Ordinal -53888"
47
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
48
+ })
49
+
50
+ it('Requires first balance value to be a cursed ordinal', async () => {
51
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
52
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance-with-native-first.json"))
53
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
54
+ })
55
+
56
+ it('Allows non-cursed ordinal balances if not first', async () => {
57
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
58
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance-with-native.json"))
59
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
60
+ })
61
+
62
+ it('Allows valid coin and name', async () => {
63
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Cursed Ordinal')
64
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance.json"))
65
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
66
+ })
67
+ }
68
+ )
@@ -0,0 +1,12 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+
4
+ describe('Allowed Function for Embels',() => {
5
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
6
+
7
+ it('Always allowed', async () => {
8
+ const curatedContract:any = await sdk.fetchCuratedContractByName('Embels')
9
+ expect(curatedContract.allowed()).toBeTruthy()
10
+ })
11
+ }
12
+ )
@@ -0,0 +1,16 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+ const fs = require('fs');
4
+
5
+ describe('Allowed Function for Embels', () => {
6
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
7
+
8
+ it('Always returns true', async () => {
9
+ const curatedContract: any = await sdk.fetchCuratedContractByName('Embels')
10
+ expect(curatedContract.allowed(null, curatedContract)).toBeTruthy()
11
+ expect(curatedContract.allowed([], curatedContract)).toBeTruthy()
12
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/embels/balance.json"))
13
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
14
+ })
15
+ }
16
+ )
@@ -0,0 +1,20 @@
1
+ import EmblemVaultSDK from '../src/';
2
+
3
+ const fs = require('fs');
4
+
5
+ describe('Allowed Function for EmblemOpen', () => {
6
+ const sdk = new EmblemVaultSDK('DEMO_KEY');
7
+
8
+ it('Does not allow empty balance', async () => {
9
+ const curatedContract: any = await sdk.fetchCuratedContractByName('EmblemOpen')
10
+ expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
11
+ expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
12
+ })
13
+
14
+ it('Allows any asset', async () => {
15
+ const curatedContract: any = await sdk.fetchCuratedContractByName('EmblemOpen')
16
+ const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/emblem-open/balance.json"))
17
+ expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
18
+ })
19
+ }
20
+ )