@collabland/chain
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -18,2 +18,8 @@ import { AssetName, AssetTypeParams } from './caip'; | ||
/** | ||
* Check if the token spec is for native token | ||
* @param tokenSpec - Token spec | ||
* @returns | ||
*/ | ||
isNative(tokenSpec: string): boolean; | ||
/** | ||
* Check if the token spec is for NFT | ||
@@ -20,0 +26,0 @@ * @param tokenSpec - Token spec |
@@ -34,2 +34,10 @@ "use strict"; | ||
} | ||
/** | ||
* Check if the token spec is for native token | ||
* @param tokenSpec - Token spec | ||
* @returns | ||
*/ | ||
isNative(tokenSpec) { | ||
return tokenSpec === types_1.NATIVE_TOKEN.namespace; | ||
} | ||
getBalance(account) { | ||
@@ -57,4 +65,3 @@ throw new common_1.HttpErrors.NotImplemented('Method not implemented.'); | ||
}); | ||
if (req.reference === types_1.NATIVE_TOKEN.reference && | ||
req.namespace === types_1.NATIVE_TOKEN.namespace) { | ||
if (this.isNative(req.namespace)) { | ||
const nativeBalance = await this.getBalance(account); | ||
@@ -64,3 +71,4 @@ asset = { balance: nativeBalance, asset: assetUri }; | ||
} | ||
else if (await this.isFT(req.namespace)) { | ||
else if (req.namespace.toLowerCase() === 'ft' || | ||
(await this.isFT(req.namespace))) { | ||
const ftBalance = await this.getFTBalance(account, assetName); | ||
@@ -70,3 +78,4 @@ asset = { balance: ftBalance, asset: assetUri }; | ||
} | ||
else if (await this.isNFT(req.namespace)) { | ||
else if (req.namespace.toLowerCase() === 'nft' || | ||
(await this.isNFT(req.namespace))) { | ||
const metadata = (_b = req.metadata) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.metadata; | ||
@@ -73,0 +82,0 @@ const nftOptions = { |
@@ -8,3 +8,4 @@ "use strict"; | ||
exports.CAIP = void 0; | ||
const namespace = '[-a-z0-9]{3,8}'; | ||
// REVIEW(rfeng): It deviates from CAIP as we allow uppercase letters | ||
const namespace = '[-a-zA-Z0-9]{3,8}'; | ||
const chainIdReference = '[-a-zA-Z0-9]{1,32}'; | ||
@@ -11,0 +12,0 @@ // See https://github.com/ChainAgnostic/CAIPs/issues/63 |
@@ -5,2 +5,3 @@ export * from './base-connector'; | ||
export * from './chain-resource'; | ||
export * from './crypto'; | ||
export * from './types'; |
@@ -12,3 +12,4 @@ "use strict"; | ||
(0, tslib_1.__exportStar)(require("./chain-resource"), exports); | ||
(0, tslib_1.__exportStar)(require("./crypto"), exports); | ||
(0, tslib_1.__exportStar)(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@collabland/chain", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "CollabLand Ethereum Integration", | ||
@@ -34,3 +34,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@collabland/common": "^0.21.0", | ||
"@collabland/common": "^0.21.1", | ||
"tslib": "^2.0.0" | ||
@@ -48,3 +48,3 @@ }, | ||
"author": "Abridged, Inc.", | ||
"gitHead": "9b590f2b1a394afe6ae5966cfc54002750c4af9b" | ||
"gitHead": "2442aa2522c9230d8437b32c143ed082f627d5a6" | ||
} |
@@ -72,2 +72,11 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved. | ||
/** | ||
* Check if the token spec is for native token | ||
* @param tokenSpec - Token spec | ||
* @returns | ||
*/ | ||
isNative(tokenSpec: string) { | ||
return tokenSpec === NATIVE_TOKEN.namespace; | ||
} | ||
/** | ||
* Check if the token spec is for NFT | ||
@@ -132,14 +141,17 @@ * @param tokenSpec - Token spec | ||
}); | ||
if ( | ||
req.reference === NATIVE_TOKEN.reference && | ||
req.namespace === NATIVE_TOKEN.namespace | ||
) { | ||
if (this.isNative(req.namespace)) { | ||
const nativeBalance = await this.getBalance(account); | ||
asset = {balance: nativeBalance, asset: assetUri}; | ||
return asset; | ||
} else if (await this.isFT(req.namespace)) { | ||
} else if ( | ||
req.namespace.toLowerCase() === 'ft' || | ||
(await this.isFT(req.namespace)) | ||
) { | ||
const ftBalance = await this.getFTBalance(account, assetName); | ||
asset = {balance: ftBalance, asset: assetUri}; | ||
return asset; | ||
} else if (await this.isNFT(req.namespace)) { | ||
} else if ( | ||
req.namespace.toLowerCase() === 'nft' || | ||
(await this.isNFT(req.namespace)) | ||
) { | ||
const metadata = req.metadata ?? options?.metadata; | ||
@@ -146,0 +158,0 @@ const nftOptions: NFTAssetOptions = { |
@@ -8,3 +8,4 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved. | ||
const namespace = '[-a-z0-9]{3,8}'; | ||
// REVIEW(rfeng): It deviates from CAIP as we allow uppercase letters | ||
const namespace = '[-a-zA-Z0-9]{3,8}'; | ||
const chainIdReference = '[-a-zA-Z0-9]{1,32}'; | ||
@@ -11,0 +12,0 @@ |
@@ -10,2 +10,3 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved. | ||
export * from './chain-resource'; | ||
export * from './crypto'; | ||
export * from './types'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
112921
63
2921
1
Updated@collabland/common@^0.21.1