@arcblock/forge-wallet
Advanced tools
Comparing version 0.39.7 to 0.39.9
@@ -83,4 +83,13 @@ // Generate by [js2dts@0.3.3](https://github.com/whxaxes/js2dts#readme) | ||
/** | ||
* Check if an object is valid wallet object | ||
* | ||
* @public | ||
* @static | ||
* @param {object} wallet | ||
* @param {boolean} canSign - should the wallet support sign | ||
*/ | ||
declare function isValid(wallet: any, canSign?: boolean): boolean; | ||
/** | ||
* @public | ||
* @static | ||
* @global | ||
@@ -176,2 +185,3 @@ * @name WalletObject | ||
fromJSON: typeof fromJSON; | ||
isValid: typeof isValid; | ||
Wallet: typeof Wallet; | ||
@@ -178,0 +188,0 @@ WalletType: typeof WalletType; |
@@ -249,2 +249,43 @@ /** | ||
/** | ||
* Check if an object is valid wallet object | ||
* | ||
* @public | ||
* @static | ||
* @param {object} wallet | ||
* @param {boolean} canSign - should the wallet support sign | ||
*/ | ||
function isValid(wallet, canSign = true) { | ||
if (!wallet || typeof wallet !== 'object') { | ||
return false; | ||
} | ||
if (typeof wallet.verify !== 'function') { | ||
return false; | ||
} | ||
if (typeof wallet.toAddress !== 'function') { | ||
return false; | ||
} | ||
if (typeof wallet.toJSON !== 'function') { | ||
return false; | ||
} | ||
if (!wallet.type || !wallet.publicKey) { | ||
return false; | ||
} | ||
if (canSign) { | ||
if (!wallet.secretKey) { | ||
return false; | ||
} | ||
if (typeof wallet.sign !== 'function') { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
module.exports = { | ||
@@ -257,4 +298,5 @@ fromSecretKey, | ||
fromJSON, | ||
isValid, | ||
Wallet, | ||
WalletType, | ||
}; |
{ | ||
"name": "@arcblock/forge-wallet", | ||
"version": "0.39.7", | ||
"version": "0.39.9", | ||
"description": "Utility function to create and use an forge compatible crypto wallet", | ||
@@ -54,3 +54,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "8a9f9caec73d880ea3a8696d7257fe40413b50fd" | ||
"gitHead": "65d05ef507094a5796668be4734fb5c831e91b3c" | ||
} |
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
19019
462