@vechain/sdk-core
Advanced tools
Comparing version 1.0.0-beta.12 to 1.0.0-beta.13
{ | ||
"name": "@vechain/sdk-core", | ||
"version": "1.0.0-beta.12", | ||
"version": "1.0.0-beta.13", | ||
"description": "Includes modules for fundamental operations like hashing and cryptography", | ||
@@ -42,4 +42,4 @@ "author": "vechain Foundation", | ||
"@types/elliptic": "^6.4.18", | ||
"@vechain/sdk-errors": "1.0.0-beta.12", | ||
"@vechain/sdk-logging": "1.0.0-beta.12", | ||
"@vechain/sdk-errors": "1.0.0-beta.13", | ||
"@vechain/sdk-logging": "1.0.0-beta.13", | ||
"bignumber.js": "^9.1.2", | ||
@@ -46,0 +46,0 @@ "blakejs": "^1.2.1", |
@@ -28,3 +28,3 @@ import { ADDRESS, assert } from '@vechain/sdk-errors'; | ||
*/ | ||
function fromPrivateKey(privateKey: Uint8Array): string { | ||
function fromPrivateKey(privateKey: Uint8Array): `0x${string}` { | ||
return fromPublicKey(secp256k1.derivePublicKey(privateKey)); | ||
@@ -57,3 +57,3 @@ } | ||
function fromPublicKey(publicKey: Uint8Array): string { | ||
function fromPublicKey(publicKey: Uint8Array): `0x${string}` { | ||
return toERC55Checksum( | ||
@@ -95,3 +95,3 @@ Hex0x.of( | ||
*/ | ||
function toERC55Checksum(address: string): string { | ||
function toERC55Checksum(address: string): `0x${string}` { | ||
assert( | ||
@@ -106,3 +106,3 @@ 'addressUtils.toERC55Checksum', | ||
const hash = Hex.of(keccak256(digits)); | ||
let result = '0x'; | ||
let result: `0x${string}` = '0x'; | ||
for (let i = 0; i < digits.length; i++) { | ||
@@ -109,0 +109,0 @@ if (parseInt(hash[i], 16) >= 8) { |
@@ -84,3 +84,3 @@ import { stringifyData } from '@vechain/sdk-errors'; | ||
*/ | ||
const VIP180_ABI = stringifyData([ | ||
const VIP180_ABI = [ | ||
{ | ||
@@ -342,5 +342,5 @@ constant: true, | ||
} | ||
]); | ||
] as const; | ||
const ERC721_ABI = stringifyData([ | ||
const ERC721_ABI = [ | ||
{ | ||
@@ -803,4 +803,4 @@ inputs: [], | ||
} | ||
]); | ||
] as const; | ||
export { PARAMS_ABI, VIP180_ABI, ERC721_ABI }; |
@@ -13,7 +13,2 @@ import * as utils from '@noble/curves/abstract/utils'; | ||
/** | ||
* Set the {@link BIG_NUMBER_PRECISION} for the fixed precision math. | ||
*/ | ||
BigNumber.set({ DECIMAL_PLACES: BIG_NUMBER_PRECISION }); | ||
/** | ||
* One VET is 10^18. | ||
@@ -194,2 +189,7 @@ * | ||
): string { | ||
const bnConfig = BigNumber.config(); | ||
BigNumber.set({ | ||
DECIMAL_PLACES: BIG_NUMBER_PRECISION, | ||
ROUNDING_MODE: BigNumber.ROUND_HALF_UP | ||
}); | ||
try { | ||
@@ -213,2 +213,4 @@ const bn = bigNumberOf(value); | ||
); | ||
} finally { | ||
BigNumber.set(bnConfig); | ||
} | ||
@@ -262,2 +264,7 @@ } | ||
): bigint { | ||
const bnConfig = BigNumber.config(); | ||
BigNumber.set({ | ||
DECIMAL_PLACES: BIG_NUMBER_PRECISION, | ||
ROUNDING_MODE: BigNumber.ROUND_HALF_UP | ||
}); | ||
try { | ||
@@ -268,4 +275,5 @@ const bn = bigNumberOf(value); | ||
const result = bn.times(multiplier); | ||
const precisionDigits = digitsOfIntegerPart(bn) + powerOfTen; | ||
return BigInt(result.toPrecision(precisionDigits)); | ||
const fractionDigits = digitsOfFractionalPart(result); | ||
const integerDigits = digitsOfIntegerPart(result); | ||
return BigInt(result.toPrecision(fractionDigits + integerDigits)); | ||
} catch (e) { | ||
@@ -279,2 +287,4 @@ throw buildError( | ||
); | ||
} finally { | ||
BigNumber.set(bnConfig); | ||
} | ||
@@ -292,3 +302,3 @@ } | ||
* @param {string} value - The value to parse as a VET amount. | ||
* hexadecimal supported previxed with `0x`. | ||
* hexadecimal supported prefixed with `0x`. | ||
* | ||
@@ -295,0 +305,0 @@ * @returns {bigint} The parsed value as a bigint. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
964385
25907
+ Added@vechain/sdk-errors@1.0.0-beta.13(transitive)
+ Added@vechain/sdk-logging@1.0.0-beta.13(transitive)
- Removed@vechain/sdk-errors@1.0.0-beta.12(transitive)
- Removed@vechain/sdk-logging@1.0.0-beta.12(transitive)