@vechain/sdk-core
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
{ | ||
"name": "@vechain/sdk-core", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"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.8", | ||
"@vechain/sdk-logging": "1.0.0-beta.8", | ||
"@vechain/sdk-errors": "1.0.0-beta.9", | ||
"@vechain/sdk-logging": "1.0.0-beta.9", | ||
"bignumber.js": "^9.1.2", | ||
@@ -46,0 +46,0 @@ "blakejs": "^1.2.1", |
@@ -1,2 +0,2 @@ | ||
import { assert, RLP as RLPError, RLP } from '@vechain/sdk-errors'; | ||
import { assert, RLP_ERRORS } from '@vechain/sdk-errors'; | ||
import { type RLPInput } from '../../encoding'; | ||
@@ -21,3 +21,3 @@ | ||
Buffer.isBuffer(bufferToCheck), | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Expected a Buffer type in ${context}.`, | ||
@@ -48,3 +48,3 @@ { | ||
Array.isArray(arrayToCheck), | ||
RLPError.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Expected an array in ${context}.`, | ||
@@ -51,0 +51,0 @@ { |
@@ -1,2 +0,2 @@ | ||
import { assert, RLP } from '@vechain/sdk-errors'; | ||
import { assert, RLP_ERRORS } from '@vechain/sdk-errors'; | ||
import { Hex0x } from '../../../utils'; | ||
@@ -20,3 +20,3 @@ | ||
buffer.length <= bytes, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Buffer in ${context} must be at most ${bytes} bytes.`, | ||
@@ -29,3 +29,3 @@ { buffer, context } | ||
buffer.length === 0 || buffer[0] !== 0, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Buffer in ${context} should not have leading zero bytes.`, | ||
@@ -32,0 +32,0 @@ { |
@@ -1,2 +0,2 @@ | ||
import { assert, RLP } from '@vechain/sdk-errors'; | ||
import { assert, RLP_ERRORS } from '@vechain/sdk-errors'; | ||
@@ -19,3 +19,3 @@ /** | ||
data.length === bytes * 2 + 2, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Hex string in ${context} must be exactly ${bytes} bytes in length.`, | ||
@@ -43,3 +43,3 @@ { data, context } | ||
buffer.length === bytes, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Buffer in ${context} must be exactly ${bytes} bytes in length.`, | ||
@@ -46,0 +46,0 @@ { buffer, context } |
import { Hex0x } from '../../../utils'; | ||
import { type RLPInput } from '../types'; | ||
import { assert, RLP } from '@vechain/sdk-errors'; | ||
import { assert, RLP_ERRORS } from '@vechain/sdk-errors'; | ||
@@ -16,3 +16,3 @@ /** | ||
typeof data === 'string', | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
'Validation error: Input must be a string.', | ||
@@ -29,3 +29,3 @@ { | ||
Hex0x.isValid(data as string), | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
"Validation error: Input must be a valid hex string with a '0x' prefix.", | ||
@@ -39,3 +39,3 @@ { data, context } | ||
(data as string).length % 2 === 0, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
'Validation error: Hex string must have an even length.', | ||
@@ -60,3 +60,3 @@ { data, context } | ||
Buffer.isBuffer(buffer), | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
'Validation error: Input must be a valid buffer.', | ||
@@ -63,0 +63,0 @@ { |
@@ -1,4 +0,4 @@ | ||
import { dataUtils, Hex0x, Hex } from '../../../utils'; | ||
import { dataUtils, Hex, Hex0x } from '../../../utils'; | ||
import { type RLPInput } from '../types'; | ||
import { assert, RLP } from '@vechain/sdk-errors'; | ||
import { assert, RLP_ERRORS } from '@vechain/sdk-errors'; | ||
@@ -19,3 +19,3 @@ /** | ||
typeof data === 'number' || typeof data === 'string', | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Input in ${context} must be a string or number.`, | ||
@@ -50,3 +50,3 @@ { data, context } | ||
Number.isSafeInteger(num) && num >= 0, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Number in ${context} must be a safe and non-negative integer.`, | ||
@@ -80,3 +80,3 @@ { | ||
isHex || isDecimal, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: String in ${context} must represent a non-negative integer in hex or decimal format.`, | ||
@@ -90,3 +90,3 @@ { str, context } | ||
!isHex || str.length > 2, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Hex string number in ${context} must be of valid length.`, | ||
@@ -118,3 +118,3 @@ { str, context } | ||
maxBytes === undefined || buf.length <= maxBytes, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Buffer in ${context} must be less than ${maxBytes} bytes.`, | ||
@@ -128,3 +128,3 @@ { maxBytes, context } | ||
buf[0] !== 0, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Buffer in ${context} must represent a canonical integer (no leading zeros).`, | ||
@@ -154,3 +154,3 @@ { buf, context } | ||
maxBytes === undefined || hex.length <= maxBytes * 2, | ||
RLP.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Validation error: Encoded number in ${context} must fit within ${maxBytes} bytes.`, | ||
@@ -157,0 +157,0 @@ { maxBytes, hex, context } |
@@ -10,8 +10,8 @@ import { RLPBase } from './rlp'; | ||
/** | ||
* The `RLP` object, encapsulating all functionalities related to Recursive Length Prefix (RLP) encoding. | ||
* The `RLP_CODER` object, encapsulating all functionalities related to Recursive Length Prefix (RLP_CODER) encoding. | ||
* | ||
* RLP contains the following classes and methods: | ||
* - `encode` - Encodes data using the Ethereumjs RLP library. | ||
* - `decode` - Decodes RLP-encoded data using the Ethereumjs RLP library. | ||
* - `Profiler` - Class handling the profiling of RLP encoded/decoded objects. | ||
* RLP_CODER contains the following classes and methods: | ||
* - `encode` - Encodes data using the Ethereumjs RLP_CODER library. | ||
* - `decode` - Decodes RLP_CODER-encoded data using the Ethereumjs RLP_CODER library. | ||
* - `Profiler` - Class handling the profiling of RLP_CODER encoded/decoded objects. | ||
* - `ScalarKind` - Abstract class for scalar types. | ||
@@ -21,5 +21,5 @@ * - `BufferKind` - Class managing buffers and ensuring type safety with encode/decode methods. | ||
*/ | ||
export const RLP = { | ||
export const RLP_CODER = { | ||
...RLPBase, | ||
...RLPProfiles | ||
}; |
@@ -5,10 +5,10 @@ import { BufferKind } from './bufferkind'; | ||
import { | ||
CompactFixedHexBlobKind, | ||
FixedHexBlobKind, | ||
HexBlobKind, | ||
FixedHexBlobKind, | ||
OptionalFixedHexBlobKind, | ||
CompactFixedHexBlobKind | ||
OptionalFixedHexBlobKind | ||
} from './hexblobkinds'; | ||
/** | ||
* RLP profile classes. | ||
* RLP_CODER profile classes. | ||
*/ | ||
@@ -15,0 +15,0 @@ export const RLPProfiles = { |
@@ -1,2 +0,2 @@ | ||
import { RLP as rlp } from '@ethereumjs/rlp'; | ||
import { RLP } from '@ethereumjs/rlp'; | ||
import { | ||
@@ -9,4 +9,4 @@ type RLPInput, | ||
} from './types'; | ||
import { RLP } from '.'; | ||
import { assert, RLP as RLPError } from '@vechain/sdk-errors'; | ||
import { RLPProfiles } from '.'; | ||
import { assert, RLP_ERRORS } from '@vechain/sdk-errors'; | ||
import { assertIsArray } from '../../assertions'; | ||
@@ -20,3 +20,3 @@ | ||
function encode(data: RLPInput): Buffer { | ||
const encodedData = rlp.encode(data); | ||
const encodedData = RLP.encode(data); | ||
return Buffer.from(encodedData); | ||
@@ -31,3 +31,3 @@ } | ||
function decode(encodedData: Buffer): RLPOutput { | ||
return rlp.decode(encodedData); | ||
return RLP.decode(encodedData); | ||
} | ||
@@ -42,3 +42,3 @@ | ||
* Creates a new Profiler instance. | ||
* @param profile - RLP profile for encoding/decoding structures. | ||
* @param profile - RLP_CODER profile for encoding/decoding structures. | ||
*/ | ||
@@ -48,3 +48,3 @@ constructor(readonly profile: RLPProfile) {} | ||
/** | ||
* Encodes an object following the provided RLP profile. | ||
* Encodes an object following the provided RLP_CODER profile. | ||
* @param data - Object to be encoded. | ||
@@ -55,7 +55,7 @@ * @returns - Encoded data as a Buffer. | ||
const packedData = _packData(data, this.profile, ''); | ||
return Buffer.from(rlp.encode(packedData)); | ||
return Buffer.from(RLP.encode(packedData)); | ||
} | ||
/** | ||
* Decodes an object following the provided RLP profile. | ||
* Decodes an object following the provided RLP_CODER profile. | ||
* @param encodedData - Data to be decoded. | ||
@@ -65,3 +65,3 @@ * @returns - Decoded data as RLPValueType. | ||
public decodeObject(encodedData: Buffer): RLPValueType { | ||
const packedData = rlp.decode(encodedData); | ||
const packedData = RLP.decode(encodedData); | ||
return _unpackData(packedData, this.profile, ''); | ||
@@ -77,3 +77,3 @@ } | ||
* @param obj - The object data to be packed. | ||
* @param profile - RLP profile for encoding structures. | ||
* @param profile - RLP_CODER profile for encoding structures. | ||
* @param context - Encoding context for error tracing. | ||
@@ -93,3 +93,3 @@ * @returns Packed data as RLPInput. | ||
// ScalarKind: direct encoding using the provided method. | ||
if (kind instanceof RLP.ScalarKind) { | ||
if (kind instanceof RLPProfiles.ScalarKind) { | ||
return kind.data(obj, context).encode(); | ||
@@ -127,3 +127,3 @@ } | ||
* @param packed - The packed data to be unpacked. | ||
* @param profile - RLP profile for decoding structures. | ||
* @param profile - RLP_CODER profile for decoding structures. | ||
* @param context - Decoding context for error tracing. | ||
@@ -144,7 +144,7 @@ * @returns Unpacked data as RLPValueType. | ||
// ScalarKind: Direct decoding using the provided method. | ||
if (kind instanceof RLP.ScalarKind) { | ||
if (kind instanceof RLPProfiles.ScalarKind) { | ||
assert( | ||
'_unpackData', | ||
Buffer.isBuffer(packed) || packed instanceof Uint8Array, | ||
RLPError.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
'Unpacking error: Expected data type is Buffer.', | ||
@@ -166,3 +166,3 @@ { context } | ||
parts.length === kind.length, | ||
RLPError.INVALID_RLP, | ||
RLP_ERRORS.INVALID_RLP, | ||
`Unpacking error: Expected ${kind.length} items, but got ${parts.length}.`, | ||
@@ -169,0 +169,0 @@ { context } |
@@ -1,2 +0,2 @@ | ||
import { RLP } from '../../encoding'; | ||
import { RLP_CODER } from '../../encoding'; | ||
@@ -46,3 +46,3 @@ /** | ||
*/ | ||
{ name: 'chainTag', kind: new RLP.NumericKind(1) }, | ||
{ name: 'chainTag', kind: new RLP_CODER.NumericKind(1) }, | ||
@@ -54,3 +54,3 @@ /** | ||
name: 'blockRef', | ||
kind: new RLP.CompactFixedHexBlobKind(8) | ||
kind: new RLP_CODER.CompactFixedHexBlobKind(8) | ||
}, | ||
@@ -61,3 +61,3 @@ | ||
*/ | ||
{ name: 'expiration', kind: new RLP.NumericKind(4) }, | ||
{ name: 'expiration', kind: new RLP_CODER.NumericKind(4) }, | ||
@@ -71,5 +71,8 @@ /** | ||
item: [ | ||
{ name: 'to', kind: new RLP.OptionalFixedHexBlobKind(20) }, | ||
{ name: 'value', kind: new RLP.NumericKind(32) }, | ||
{ name: 'data', kind: new RLP.HexBlobKind() } | ||
{ | ||
name: 'to', | ||
kind: new RLP_CODER.OptionalFixedHexBlobKind(20) | ||
}, | ||
{ name: 'value', kind: new RLP_CODER.NumericKind(32) }, | ||
{ name: 'data', kind: new RLP_CODER.HexBlobKind() } | ||
] | ||
@@ -82,3 +85,3 @@ } | ||
*/ | ||
{ name: 'gasPriceCoef', kind: new RLP.NumericKind(1) }, | ||
{ name: 'gasPriceCoef', kind: new RLP_CODER.NumericKind(1) }, | ||
@@ -88,3 +91,3 @@ /** | ||
*/ | ||
{ name: 'gas', kind: new RLP.NumericKind(8) }, | ||
{ name: 'gas', kind: new RLP_CODER.NumericKind(8) }, | ||
@@ -94,3 +97,3 @@ /** | ||
*/ | ||
{ name: 'dependsOn', kind: new RLP.OptionalFixedHexBlobKind(32) }, | ||
{ name: 'dependsOn', kind: new RLP_CODER.OptionalFixedHexBlobKind(32) }, | ||
@@ -100,3 +103,3 @@ /** | ||
*/ | ||
{ name: 'nonce', kind: new RLP.NumericKind(8) }, | ||
{ name: 'nonce', kind: new RLP_CODER.NumericKind(8) }, | ||
@@ -106,3 +109,3 @@ /** | ||
*/ | ||
{ name: 'reserved', kind: { item: new RLP.BufferKind() } } | ||
{ name: 'reserved', kind: { item: new RLP_CODER.BufferKind() } } | ||
]; | ||
@@ -116,3 +119,3 @@ | ||
name: 'reserved.features', | ||
kind: new RLP.NumericKind(4) | ||
kind: new RLP_CODER.NumericKind(4) | ||
}; | ||
@@ -126,10 +129,10 @@ | ||
name: 'signature', | ||
kind: new RLP.BufferKind() | ||
kind: new RLP_CODER.BufferKind() | ||
}; | ||
/** | ||
* RLP profiler for simple unsigned transactions | ||
* RLP_CODER profiler for simple unsigned transactions | ||
* @internal | ||
*/ | ||
const UNSIGNED_TRANSACTION_RLP = new RLP.Profiler({ | ||
const UNSIGNED_TRANSACTION_RLP = new RLP_CODER.Profiler({ | ||
name: 'tx', | ||
@@ -140,6 +143,6 @@ kind: TRANSACTION_FIELDS | ||
/** | ||
* RLP profiler for simple signed transactions | ||
* RLP_CODER profiler for simple signed transactions | ||
* @internal | ||
*/ | ||
const SIGNED_TRANSACTION_RLP = new RLP.Profiler({ | ||
const SIGNED_TRANSACTION_RLP = new RLP_CODER.Profiler({ | ||
name: 'tx', | ||
@@ -146,0 +149,0 @@ |
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
931731
25295
+ Added@vechain/sdk-errors@1.0.0-beta.9(transitive)
+ Added@vechain/sdk-logging@1.0.0-beta.9(transitive)
- Removed@vechain/sdk-errors@1.0.0-beta.8(transitive)
- Removed@vechain/sdk-logging@1.0.0-beta.8(transitive)