Skip to content

Commit

Permalink
Backfilling operations field and variants of 'TransformValue' type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Zajkowski committed Aug 28, 2024
1 parent 985139f commit 034cd25
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Removed
-->

## [2.15.6] - 2024-04-18

### Fixed

- Backfilled missing variants of `TransformValue` type (AddInt32|AddUInt64|AddUInt128|AddUInt256|WriteEraInfo|WriteBid|WriteWithdraw|Failure|WriteUnbonding)
- Backfilled `operations` field in `Effect` type
- Exported all types in `services/types` module so that they can be used by end users

## [2.15.5] - 2024-04-18

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "casper-js-sdk",
"version": "2.15.5",
"version": "2.15.6",
"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 Expand Up @@ -130,4 +130,4 @@
"ts-results": "npm:@casperlabs/ts-results@^3.3.4",
"typedjson": "^1.6.0-rc2"
}
}
}
82 changes: 64 additions & 18 deletions src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface GetPeersResult extends RpcResult {
}

/** Interface for information on the most recently appended block on the network */
interface LastAddedBlockInfo {
export interface LastAddedBlockInfo {
hash: string;
timestamp: string;
era_id: number;
Expand All @@ -31,12 +31,12 @@ interface LastAddedBlockInfo {
creator: string;
}

interface NextUpgrade {
export interface NextUpgrade {
activation_point: number | string;
protocol_version: string;
}

type ReactorState =
export type ReactorState =
| 'Initialize'
| 'CatchUp'
| 'Upgrading'
Expand All @@ -45,7 +45,7 @@ type ReactorState =
| 'ShutdownForUpgrade';

/** The status of syncing an individual block. */
interface BlockSyncStatus {
export interface BlockSyncStatus {
/** The block hash. */
block_hash: string;
/** The height of the block, if known. */
Expand All @@ -55,7 +55,7 @@ interface BlockSyncStatus {
}

/** The status of the block synchronizer. */
interface BlockSynchronizerStatus {
export interface BlockSynchronizerStatus {
historical: BlockSyncStatus;
forward: BlockSyncStatus;
}
Expand Down Expand Up @@ -148,8 +148,28 @@ export type AddKey = {
name: string;
};

export type ISeigniorageAllocation =
| {
Validator: {
validator_public_key: string;
amount: string;
};
}
| {
Delegator: {
delegator_public_key: string;
validator_public_key: string;
amount: string;
};
};

export interface EraInfo {
seigniorage_allocations: ISeigniorageAllocation[];
}

export type TransformValue =
| 'Identity'
| { WriteAccount: string }
| 'WriteContractWasm'
| 'WriteContract'
| 'WriteContractPackage'
Expand All @@ -158,20 +178,43 @@ export type TransformValue =
}
| { WriteDeployInfo: WriteDeployInfo }
| { WriteTransfer: WriteTransfer }
| { AddInt32: number }
| { AddUInt64: number }
| { AddUInt128: string }
| { AddUInt256: string }
| { AddUInt512: string }
| { AddKeys: AddKey[] };

interface Transform {
| { AddKeys: AddKey[] }
| { WriteEraInfo: EraInfo }
| { WriteBid: any } //TODO fill this definition
| { WriteWithdraw: any[] } //TODO fill this definition
| { Failure: string }
| { WriteUnbonding: any[] }; //TODO fill this definition

export interface Transform {
key: string;
transform: TransformValue;
}

interface Effect {
export enum OpKind {
Read = 'Read',
Write = 'Write',
Add = 'Add',
NoOp = 'NoOp',
Prune = 'Prune'
}

export interface Operation {
key: string;
kind: OpKind;
}

export interface Effect {
operations: Operation[];
transforms: Transform[];
}

/** Result interface for an execution result body */
interface ExecutionResultBody {
export interface ExecutionResultBody {
cost: number;
error_message?: string | null;
transfers: string[];
Expand Down Expand Up @@ -226,7 +269,7 @@ export interface JsonSystemTransaction {
}

/** JSON deploy header interface that acts as a schema for JSON deploy headers */
interface JsonDeployHeader {
export interface JsonDeployHeader {
account: string;
timestamp: string;
ttl: number;
Expand All @@ -236,31 +279,34 @@ interface JsonDeployHeader {
chain_name: string;
}

interface JsonBasicExecutionDeployItemInternal {
export interface JsonBasicExecutionDeployItemInternal {
args: Map<string, CLValue>;
}

interface JsonModuleBytes extends JsonBasicExecutionDeployItemInternal {
export interface JsonModuleBytes extends JsonBasicExecutionDeployItemInternal {
module_bytes: string;
}

interface JsonStoredContract extends JsonBasicExecutionDeployItemInternal {
export interface JsonStoredContract
extends JsonBasicExecutionDeployItemInternal {
entry_point: string;
}

interface JsonStoredContractByHash extends JsonStoredContract {
export interface JsonStoredContractByHash extends JsonStoredContract {
hash: string;
}

interface JsonStoredContractByName extends JsonStoredContract {
export interface JsonStoredContractByName extends JsonStoredContract {
name: string;
}

interface JsonStoredVersionedContractByName extends JsonStoredContractByName {
export interface JsonStoredVersionedContractByName
extends JsonStoredContractByName {
version: number | null;
}

interface JsonStoredVersionedContractByHash extends JsonStoredContractByHash {
export interface JsonStoredVersionedContractByHash
extends JsonStoredContractByHash {
version: number | null;
}

Expand Down

0 comments on commit 034cd25

Please sign in to comment.