Skip to content

Commit

Permalink
Merge pull request #516 from casper-ecosystem/CSDK-227
Browse files Browse the repository at this point in the history
Fixed construction of Uref and EraID for Transaction Session builder
  • Loading branch information
alexmyshchyshyn authored Feb 24, 2025
2 parents 025f451 + 7e53ebc commit 1cf0933
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/types/key/Era.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { jsonMember, jsonObject } from 'typedjson';
import { toBytesNumber } from '../ByteConverters';

/**
* Represents an Era in the system.
Expand Down Expand Up @@ -57,8 +58,6 @@ export class Era {
* @returns A Uint8Array representation of the Era value as a 32-bit unsigned integer.
*/
toBytes(): Uint8Array {
const buffer = new ArrayBuffer(4);
new DataView(buffer).setUint32(0, this.value, true);
return new Uint8Array(buffer);
return toBytesNumber(64, false)(this.value);
}
}
4 changes: 2 additions & 2 deletions src/types/key/Key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class Key {
case KeyTypeID.EraId:
return Key.concatBytes(this.era?.toBytes(), typeBytes);
case KeyTypeID.URef:
return Key.concatBytes(this.uRef?.data, typeBytes);
return Key.concatBytes(this.uRef?.bytes(), typeBytes);
case KeyTypeID.Transfer:
return Key.concatBytes(this.transfer?.toBytes(), typeBytes);
case KeyTypeID.DeployInfo:
Expand Down Expand Up @@ -408,7 +408,7 @@ export class Key {
case KeyTypeID.Hash:
return `${PrefixName.Hash}${this.hash?.toHex()}`;
case KeyTypeID.EraId:
return `${PrefixName.EraId}${this.era?.toString()}`;
return `${PrefixName.EraId}${this.era?.toJSON()}`;
case KeyTypeID.URef:
return this.uRef!.toPrefixedString();
case KeyTypeID.Transfer:
Expand Down

0 comments on commit 1cf0933

Please sign in to comment.