@shapeshiftoss/caip 5.0.1 → 5.1.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.
@@ -72,16 +72,20 @@ const fromAssetId = (assetId) => {
72
72
  var _a;
73
73
  if (!(0, typeGuards_1.isAssetId)(assetId))
74
74
  throw new Error(`fromAssetId: invalid AssetId: ${assetId}`);
75
- const matches = (_a = utils_1.parseAssetIdRegExp.exec(assetId)) !== null && _a !== void 0 ? _a : [];
75
+ const matches = (_a = utils_1.parseAssetIdRegExp.exec(assetId)) === null || _a === void 0 ? void 0 : _a.groups;
76
+ if (!matches)
77
+ throw new Error(`fromAssetId: could not parse AssetId: ${assetId}`);
76
78
  // These should never throw because isAssetId() would have already caught it, but they help with type inference
77
- (0, typeGuards_1.assertIsChainNamespace)(matches[1]);
78
- (0, typeGuards_1.assertIsChainReference)(matches[2]);
79
- (0, typeGuards_1.assertIsAssetNamespace)(matches[3]);
80
- const chainNamespace = matches[1];
81
- const chainReference = matches[2];
82
- const assetNamespace = matches[3];
79
+ (0, typeGuards_1.assertIsChainNamespace)(matches.chainNamespace);
80
+ (0, typeGuards_1.assertIsChainReference)(matches.chainReference);
81
+ (0, typeGuards_1.assertIsAssetNamespace)(matches.assetNamespace);
82
+ const chainNamespace = matches.chainNamespace;
83
+ const chainReference = matches.chainReference;
84
+ const assetNamespace = matches.assetNamespace;
83
85
  const shouldLowercaseAssetReference = assetNamespace && ['erc20', 'erc721'].includes(assetNamespace);
84
- const assetReference = shouldLowercaseAssetReference ? (0, toLower_1.default)(matches[4]) : matches[4];
86
+ const assetReference = shouldLowercaseAssetReference
87
+ ? (0, toLower_1.default)(matches.assetReference)
88
+ : matches.assetReference;
85
89
  (0, typeGuards_1.assertIsChainReference)(chainReference);
86
90
  (0, typeGuards_1.assertIsChainNamespace)(chainNamespace);
87
91
  const chainId = (0, chainId_1.toChainId)({ chainNamespace, chainReference });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/caip",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "description": "CAIP Implementation",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  "type-check": "tsc --project ./tsconfig.build.json --noEmit"
32
32
  },
33
33
  "peerDependencies": {
34
- "@shapeshiftoss/types": "3.1.3"
34
+ "@shapeshiftoss/types": "4.3.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@shapeshiftoss/types": "3.1.3",
37
+ "@shapeshiftoss/types": "4.3.1",
38
38
  "@yfi/sdk": "^1.0.30",
39
39
  "axios": "^0.26.1",
40
40
  "ts-node": "^10.7.0"