Skip to content

Commit

Permalink
Fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
kazimuth committed Oct 31, 2024
1 parent b0bcd01 commit 3cea5d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/sdk/src/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { hexStringToU128, u128ToHexString, u128ToUint8Array } from './utils';
export class Address {
data: bigint;

get __address_bytes(): bigint {
get __address__(): bigint {
return this.data;
}

Expand Down
13 changes: 6 additions & 7 deletions packages/sdk/src/algebraic_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ export class ProductType {
deserialize = (reader: BinaryReader): object => {
let result: { [key: string]: any } = {};
if (this.elements.length === 1) {
if (this.elements[0].name === '__identity_bytes') {
if (this.elements[0].name === '__identity__') {
return new Identity(reader.readU256());
}

if (this.elements[0].name === '__address_bytes') {
if (this.elements[0].name === '__address__') {
return new Address(reader.readU128());
}
}
Expand Down Expand Up @@ -344,12 +344,12 @@ export class AlgebraicType {
}
static createIdentityType(): AlgebraicType {
return this.createProductType([
new ProductTypeElement('__identity_bytes', this.createU256Type()),
new ProductTypeElement('__identity__', this.createU256Type()),
]);
}
static createAddressType(): AlgebraicType {
return this.createProductType([
new ProductTypeElement('__address_bytes', this.createU128Type()),
new ProductTypeElement('__address__', this.createU128Type()),
]);
}
static createScheduleAtType(): AlgebraicType {
Expand Down Expand Up @@ -383,19 +383,18 @@ export class AlgebraicType {
return (
this.isProductType() &&
this.product.elements.length === 1 &&
// confusingly, Address and Identity's '__address_bytes' and '__identity_bytes' now store integers rather than byte arrays.
(this.product.elements[0].algebraicType.type == Type.U128 ||
this.product.elements[0].algebraicType.type == Type.U256) &&
this.product.elements[0].name === tag
);
}

isIdentity(): boolean {
return this.#isBytesNewtype('__identity_bytes');
return this.#isBytesNewtype('__identity__');
}

isAddress(): boolean {
return this.#isBytesNewtype('__address_bytes');
return this.#isBytesNewtype('__address__');
}

serialize(writer: BinaryWriter, value: any): void {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { hexStringToU256, u256ToHexString, u256ToUint8Array } from './utils';
export class Identity {
data: bigint;

get __identity_bytes(): bigint {
get __identity__(): bigint {
return this.data;
}

Expand All @@ -18,7 +18,7 @@ export class Identity {
* `data` can be a hexadecimal string or a `bigint`.
*/
constructor(data: string | bigint) {
// we get a JSON with __identity_bytes when getting a token with a JSON API
// we get a JSON with __identity__ when getting a token with a JSON API
// and an bigint when using BSATN
this.data = typeof data === 'string' ? hexStringToU256(data) : data;
}
Expand Down

0 comments on commit 3cea5d5

Please sign in to comment.