diff --git a/packages/massa-web3/src/experimental/basicElements/operationManager.ts b/packages/massa-web3/src/experimental/basicElements/operationManager.ts index 7c3873ed..1e988ff0 100644 --- a/packages/massa-web3/src/experimental/basicElements/operationManager.ts +++ b/packages/massa-web3/src/experimental/basicElements/operationManager.ts @@ -5,9 +5,7 @@ import { BlockchainClient } from '../client' import { Signature } from './signature' import varint from 'varint' import { FIRST } from '../utils' - -// TODO: replace with a U64 helper -const U64_SIZE_BYTES = 8 +import { U64 } from './serializers' const PERIOD_TO_LIVE_DEFAULT = 10 const PERIOD_TO_LIVE_MAX = 100 @@ -103,7 +101,6 @@ export class OperationManager { * @returns A byte array representing the serialized operation. */ static serialize(operation: OperationDetails): Uint8Array { - // TODO: check that unsigned.encode is equivalent to varint.encode const components = [ unsigned.encode(operation.fee), varint.encode(operation.expirePeriod), @@ -227,7 +224,7 @@ export class OperationManager { key: PublicKey ): Uint8Array { // u64ToBytes is little endian - const networkId = new Uint8Array(U64_SIZE_BYTES) + const networkId = new Uint8Array(U64.SIZE_BYTE) const view = new DataView(networkId.buffer) view.setBigUint64(FIRST, chainId, false) diff --git a/packages/massa-web3/src/experimental/basicElements/storage.ts b/packages/massa-web3/src/experimental/basicElements/storage.ts index f9c4e24e..2abb44f5 100644 --- a/packages/massa-web3/src/experimental/basicElements/storage.ts +++ b/packages/massa-web3/src/experimental/basicElements/storage.ts @@ -1,10 +1,8 @@ import { toNanoMas } from '../utils' +import { U32 } from './serializers' const BYTE_COST_MASSA = 0.0001 -// TODO: replace with a U32 helper -const U32_SIZE_BYTES = 4 - // TODO: replace by the underlying logic of the storage cost const ACCOUNT_SIZE_BYTES = 10 @@ -48,5 +46,5 @@ export function smartContract(numberOfBytes: number): bigint { * @returns The cost in the smallest unit of the Massa currency. */ export function newEntry(): bigint { - return bytes(U32_SIZE_BYTES) + return bytes(U32.SIZE_BYTE) }