emblem-vault-sdk 2.3.6 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/derive.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
package/dist/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
45
  const bignumber_1 = require("@ethersproject/bignumber");
36
46
  const utils_1 = require("./utils");
37
47
  const derive_1 = require("./derive");
38
- const SDK_VERSION = '2.3.6';
48
+ const SDK_VERSION = '2.4.0';
39
49
  class EmblemVaultSDK {
40
50
  constructor(apiKey, baseUrl, v3Url, sigUrl) {
41
51
  this.apiKey = apiKey;
package/dist/utils.js CHANGED
@@ -324,6 +324,7 @@ function generateTemplate(record) {
324
324
  * @param {function} - msgCallback should be a function that takes a string message
325
325
  */
326
326
  allowed: (data, _this, msgCallback = null) => {
327
+ var _a;
327
328
  if (recordName == "Embels") {
328
329
  return true;
329
330
  }
@@ -336,7 +337,7 @@ function generateTemplate(record) {
336
337
  let message = null;
337
338
  if (recordName == "Filthy Fiat") {
338
339
  data = _this.filterNativeBalances({ balances: data }, _this);
339
- allowed = data[0].project == recordName;
340
+ allowed = ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.project) == recordName;
340
341
  }
341
342
  else if (recordName == "Cursed Ordinal") {
342
343
  if (data && data.length > 0) {
@@ -413,21 +414,30 @@ function generateTemplate(record) {
413
414
  let possibleBalances = [5000, 50000, 500000];
414
415
  let covalAssets = data.filter((item) => item.name == "Circuits of Value");
415
416
  let covalTotalBalance = covalAssets.reduce((acc, item) => acc + item.balance, 0);
416
- allowed = possibleBalances.includes(covalTotalBalance) || false;
417
+ const normalizedBalance = possibleBalances.reduce((closest, target) => {
418
+ // If balance is less than current target, return the previous closest
419
+ if (covalTotalBalance < target) {
420
+ return closest;
421
+ }
422
+ // If we're at or above this target, it becomes our new closest
423
+ return target;
424
+ }, 0);
425
+ allowed = normalizedBalance > 0;
426
+ // allowed = possibleBalances.includes(covalTotalBalance) || false
417
427
  message = !allowed ? `Load vault with 5000, 50000, or 500000 Circuits of Value` : message;
418
428
  }
419
429
  else if (_this.vaultCollectionType && _this.vaultCollectionType == "collection") {
420
430
  if (recordName == "Bitcoin Punks") {
421
431
  firstAsset = _this.filterNativeBalances({ balances: data }, _this)[0];
422
432
  }
423
- const allowedChain = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
433
+ const allowedChain = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.coin.toLowerCase()) == _this.collectionChain.toLowerCase();
424
434
  if (!allowedChain) {
425
- message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
435
+ message = `Found ${firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
426
436
  }
427
- const allowedProject = firstAsset.project == recordName;
437
+ const allowedProject = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.project) == recordName;
428
438
  if (!allowedProject) {
429
439
  message = (message ? `${message} ` : '') +
430
- `Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
440
+ `Found asset from ${firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.project} collection, expected asset from ${recordName} collection.`;
431
441
  }
432
442
  allowed = allowedChain && allowedProject;
433
443
  }