From fe400225fa80e66d3797ed1623524f998ff96aa3 Mon Sep 17 00:00:00 2001 From: Oleksandr Myshchyshyn Date: Mon, 25 Nov 2024 13:29:48 +0200 Subject: [PATCH] Prepare 5.0.0-rc4 for publishing --- CHANGELOG.md | 17 +++++++++++++ README.md | 2 +- ...guide-v2-v3.md => migration-guide-v2-v5.md | 4 ++-- package.json | 2 +- src/types/Deploy.ts | 24 +++++++++++++++++-- 5 files changed, 43 insertions(+), 6 deletions(-) rename migration-guide-v2-v3.md => migration-guide-v2-v5.md (94%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e64af68..1c9ea43f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Removed --> +## [5.0.0-rc4] - 2024-11-25 + +### Added + +- `makeCsprTransferDeploy` and `makeAuctionManagerDeploy` utils +- **README.md**: Introduced a comprehensive README file, including detailed information about the SDK, setup instructions, and usage examples. +- **Migration Guide**: Added a basic migration guide to assist developers in transitioning to the new SDK version with updated types and RPC. +- `getDeploySizeInBytes` static method for Deploy + +### Removed + +- DeployParams class due to deprecation, renamed `fromHeaderAndItems` function to the `makeDeploy` due to consistency with previous methods names + +### Changed + +- Made `id` optional in TransferDeployItem.newTransfer + ## [5.0.0-rc3] - 2024-11-19 ### Added diff --git a/README.md b/README.md index 18f2c293..6958f9ef 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ npm install casper-js-sdk --save ## Migration guides -### [v2 to v3](./migration-guide-v2-v3.md) +### [v2 to v5](./migration-guide-v2-v5.md) ## Usage examples diff --git a/migration-guide-v2-v3.md b/migration-guide-v2-v5.md similarity index 94% rename from migration-guide-v2-v3.md rename to migration-guide-v2-v5.md index d06854b8..c85036b7 100644 --- a/migration-guide-v2-v3.md +++ b/migration-guide-v2-v5.md @@ -1,6 +1,6 @@ -# V2 to V3 Migration Guide +# V2 to V5 Migration Guide -`Casper JS SDK V3` makes many **breaking changes** to the SDK behavior, effectively rewriting it from scratch. +`Casper JS SDK V5` makes many **breaking changes** to the SDK behavior, effectively rewriting it from scratch. The purpose of these changes is to improve and simplify the SDK, as well as to bring the Casper JS SDK to the same look and behavior as the Casper SDK in other languages. diff --git a/package.json b/package.json index 179675c2..5ca162a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "casper-js-sdk", - "version": "5.0.0-rc3", + "version": "5.0.0-rc4", "license": "Apache 2.0", "description": "SDK to interact with the Casper blockchain", "homepage": "https://github.com/casper-ecosystem/casper-js-sdk#README.md", diff --git a/src/types/Deploy.ts b/src/types/Deploy.ts index 3cda771f..d12a99ec 100644 --- a/src/types/Deploy.ts +++ b/src/types/Deploy.ts @@ -2,9 +2,8 @@ import { jsonArrayMember, jsonMember, jsonObject, TypedJSON } from 'typedjson'; import { concat } from '@ethersproject/bytes'; import { Hash } from './key'; -import { PrivateKey } from './keypair/PrivateKey'; import { HexBytes } from './HexBytes'; -import { PublicKey } from './keypair'; +import { PublicKey, PrivateKey } from './keypair'; import { Duration, Timestamp } from './Time'; import { Approval, @@ -491,6 +490,27 @@ export class Deploy { } return false; } + + /** + * Gets the byte-size of a deploy + * @param deploy The `Deploy` for which to calculate the size + * @returns The size of the `Deploy` in its serialized representation + */ + public static getDeploySizeInBytes = (deploy: Deploy): number => { + const hashSize = deploy.hash.toBytes().length; + const bodySize = concat([deploy.payment.bytes(), deploy.session.bytes()]) + .length; + const headerSize = deploy.header.toBytes().length; + const approvalsSize = deploy.approvals + .map(approval => { + return ( + (approval.signature.bytes.length + approval.signer.bytes().length) / 2 + ); + }) + .reduce((a, b) => a + b, 0); + + return hashSize + headerSize + bodySize + approvalsSize; + }; } /**