@arcblock/forge-util
Advanced tools
Comparing version 0.33.0 to 0.33.1
@@ -62,2 +62,20 @@ // Generate by [js2dts@0.3.3](https://github.com/whxaxes/js2dts#readme) | ||
declare function isUUID(str: string): boolean; | ||
/** | ||
* Convert address to did: prepend `did:abt:` prefix | ||
* | ||
* @public | ||
* @static | ||
* @param {string} did - address string | ||
* @returns {string} | ||
*/ | ||
declare function toDid(address: any): string; | ||
/** | ||
* Convert did to address: remove `did:abt:` prefix if exists | ||
* | ||
* @public | ||
* @static | ||
* @param {string} did - address string | ||
* @returns {string} | ||
*/ | ||
declare function toAddress(did: string): string; | ||
declare const _Lib: _Lib.T100; | ||
@@ -93,4 +111,6 @@ declare namespace _Lib { | ||
isUUID: typeof isUUID; | ||
toDid: typeof toDid; | ||
toAddress: typeof toAddress; | ||
} | ||
} | ||
export = _Lib; |
@@ -20,2 +20,3 @@ /* eslint-disable no-bitwise */ | ||
const DID_PREFIX = 'did:abt:'; | ||
const zero = new BN(0); | ||
@@ -600,2 +601,26 @@ const negative1 = new BN(-1); | ||
/** | ||
* Convert did to address: remove `did:abt:` prefix if exists | ||
* | ||
* @public | ||
* @static | ||
* @param {string} did - address string | ||
* @returns {string} | ||
*/ | ||
function toAddress(did) { | ||
return did.replace(DID_PREFIX, ''); | ||
} | ||
/** | ||
* Convert address to did: prepend `did:abt:` prefix | ||
* | ||
* @public | ||
* @static | ||
* @param {string} did - address string | ||
* @returns {string} | ||
*/ | ||
function toDid(address) { | ||
return `${DID_PREFIX}${toAddress(address)}`; | ||
} | ||
module.exports = { | ||
@@ -629,2 +654,4 @@ BN, | ||
isUUID, | ||
toDid, | ||
toAddress, | ||
}; |
{ | ||
"name": "@arcblock/forge-util", | ||
"version": "0.33.0", | ||
"version": "0.33.1", | ||
"description": "utils shared across mutlipe forge js libs, works in both node.js and browser", | ||
@@ -17,3 +17,3 @@ "keywords": [ | ||
"bn.js": "4.11.6", | ||
"lodash": "^4.17.11", | ||
"lodash": "^4.17.14", | ||
"multibase": "^0.6.0", | ||
@@ -45,2 +45,3 @@ "number-to-bn": "^1.7.0", | ||
"lint:fix": "eslint --fix lib tests", | ||
"upgrade": "yarn generate-dts && yarn generate-docs && yarn format-docs", | ||
"generate-docs": "jsdoc2md lib/index.js > docs/README.md", | ||
@@ -57,3 +58,3 @@ "generate-dts": "j2d lib/index.js", | ||
}, | ||
"gitHead": "9e30e3a049b194fc6e1657156c54220217744b36" | ||
"gitHead": "398740a29b186416c777e4d35df810a167e24599" | ||
} |
@@ -9,2 +9,3 @@ ![forge-util](https://www.arcblock.io/.netlify/functions/badge/?text=forge-util) | ||
## Usage | ||
@@ -28,4 +29,5 @@ | ||
## Documentation | ||
For full documentation, checkout [README.md](./docs/README.md). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21566
692
32
Updatedlodash@^4.17.14