From 3cea5d520c5912c6abd2434b6e3743399c2514f1 Mon Sep 17 00:00:00 2001 From: James Gilles Date: Thu, 31 Oct 2024 16:55:17 -0400 Subject: [PATCH] Fix names --- packages/sdk/src/address.ts | 2 +- packages/sdk/src/algebraic_type.ts | 13 ++++++------- packages/sdk/src/identity.ts | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/sdk/src/address.ts b/packages/sdk/src/address.ts index b315205..7ac54d5 100644 --- a/packages/sdk/src/address.ts +++ b/packages/sdk/src/address.ts @@ -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; } diff --git a/packages/sdk/src/algebraic_type.ts b/packages/sdk/src/algebraic_type.ts index 0457fcf..c6fb23c 100644 --- a/packages/sdk/src/algebraic_type.ts +++ b/packages/sdk/src/algebraic_type.ts @@ -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()); } } @@ -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 { @@ -383,7 +383,6 @@ 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 @@ -391,11 +390,11 @@ export class AlgebraicType { } 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 { diff --git a/packages/sdk/src/identity.ts b/packages/sdk/src/identity.ts index 13816de..9ce25dc 100644 --- a/packages/sdk/src/identity.ts +++ b/packages/sdk/src/identity.ts @@ -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; } @@ -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; }