Skip to content

Commit

Permalink
Update deserializer and serializer, added tests for Deploy and Transa…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
alexmyshchyshyn committed Nov 13, 2024
1 parent bf02217 commit d8a2e00
Show file tree
Hide file tree
Showing 53 changed files with 2,290 additions and 388 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/publish-casper-client-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ jobs:
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
- name: Set release tag
run: |
if [ ${{ github.event.release.target_commitish }} == 'feat-5.0.0' ]; then
echo "release_tag=condor" >> $GITHUB_ENV
else
echo "release_tag=latest" >> $GITHUB_ENV
fi
run: echo "release_tag=condor" >> $GITHUB_ENV
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5b949b50c3461bbcd5a540b150c368278160234a #v3.4.0
with:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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-rc1",
"version": "5.0.0-rc2",
"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
144 changes: 132 additions & 12 deletions src/rpc/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export class RpcRequest {
@jsonMember({ constructor: String })
version: string;

@jsonMember(() => ({ constructor: IDValue, isRequired: false }))
@jsonMember(() => ({
constructor: IDValue,
isRequired: false,
deserializer: (json: string) => IDValue.fromJSON(json),
serializer: (value: IDValue) => value.toJSON()
}))
id?: IDValue;

@jsonMember({ constructor: String })
Expand Down Expand Up @@ -199,10 +204,32 @@ export class ParamGetStateEntity {

@jsonObject
export class AccountIdentifier {
@jsonMember(() => ({ constructor: AccountHash, isRequired: false }))
@jsonMember(() => ({
constructor: AccountHash,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return AccountHash.fromJSON(json);
},
serializer: (value: AccountHash) => {
if (!value) return;
return value.toJSON();
}
}))
accountHash?: AccountHash;

@jsonMember(() => ({ constructor: PublicKey, isRequired: false }))
@jsonMember(() => ({
constructor: PublicKey,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return PublicKey.fromJSON(json);
},
serializer: (value: PublicKey) => {
if (!value) return;
return value.toJSON();
}
}))
publicKey?: PublicKey;

constructor(accountHash?: AccountHash, publicKey?: PublicKey) {
Expand All @@ -213,13 +240,46 @@ export class AccountIdentifier {

@jsonObject
export class EntityIdentifier {
@jsonMember(() => ({ constructor: AccountHash, isRequired: false }))
@jsonMember(() => ({
constructor: AccountHash,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return AccountHash.fromJSON(json);
},
serializer: (value: AccountHash) => {
if (!value) return;
return value.toJSON();
}
}))
accountHash?: AccountHash;

@jsonMember(() => ({ constructor: PublicKey, isRequired: false }))
@jsonMember(() => ({
constructor: PublicKey,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return PublicKey.fromJSON(json);
},
serializer: (value: PublicKey) => {
if (!value) return;
return value.toJSON();
}
}))
publicKey?: PublicKey;

@jsonMember(() => ({ constructor: EntityAddr, isRequired: false }))
@jsonMember(() => ({
constructor: EntityAddr,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return EntityAddr.fromJSON(json);
},
serializer: (value: EntityAddr) => {
if (!value) return;
return value.toJSON();
}
}))
entityAddr?: EntityAddr;

constructor(
Expand Down Expand Up @@ -428,16 +488,60 @@ export class SpeculativeExecParams {

@jsonObject
export class PurseIdentifier {
@jsonMember(() => ({ constructor: PublicKey, isRequired: false }))
@jsonMember(() => ({
constructor: PublicKey,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return PublicKey.fromJSON(json);
},
serializer: (value: PublicKey) => {
if (!value) return;
return value.toJSON();
}
}))
mainPurseUnderPublicKey?: PublicKey;

@jsonMember(() => ({ constructor: AccountHash, isRequired: false }))
@jsonMember(() => ({
constructor: AccountHash,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return AccountHash.fromJSON(json);
},
serializer: (value: AccountHash) => {
if (!value) return;
return value.toJSON();
}
}))
mainPurseUnderAccountHash?: AccountHash;

@jsonMember(() => ({ constructor: EntityAddr, isRequired: false }))
@jsonMember(() => ({
constructor: EntityAddr,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return EntityAddr.fromJSON(json);
},
serializer: (value: EntityAddr) => {
if (!value) return;
return value.toJSON();
}
}))
mainPurseUnderEntityAddr?: EntityAddr;

@jsonMember(() => ({ constructor: URef, isRequired: false }))
@jsonMember(() => ({
constructor: URef,
isRequired: false,
deserializer: (json: string) => {
if (!json) return;
return URef.fromJSON(json);
},
serializer: (value: URef) => {
if (!value) return;
return value.toJSON();
}
}))
purseUref?: URef;

constructor(
Expand Down Expand Up @@ -505,10 +609,26 @@ export class QueryBalanceDetailsRequest {

@jsonObject
export class InfoGetRewardRequest {
@jsonMember(() => ({ constructor: PublicKey, isRequired: false }))
@jsonMember(() => ({
constructor: PublicKey,
isRequired: false,
deserializer: (json: string) => PublicKey.fromJSON(json),
serializer: (value: PublicKey) => value.toJSON()
}))
validator: PublicKey;

@jsonMember({ isRequired: false, constructor: PublicKey })
@jsonMember({
isRequired: false,
constructor: PublicKey,
deserializer: (json: string) => {
if (!json) return;
return PublicKey.fromJSON(json);
},
serializer: (value: PublicKey) => {
if (!value) return;
return value.toJSON();
}
})
delegator?: PublicKey;

@jsonMember({ isRequired: false, constructor: EraIdentifier })
Expand Down
Loading

0 comments on commit d8a2e00

Please sign in to comment.