Skip to content

Commit

Permalink
Prepare 5.0.0-rc4 for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmyshchyshyn committed Nov 25, 2024
1 parent 85bc958 commit fe40022
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions migration-guide-v2-v3.md → migration-guide-v2-v5.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
24 changes: 22 additions & 2 deletions src/types/Deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
};
}

/**
Expand Down

0 comments on commit fe40022

Please sign in to comment.