diff --git a/src/bcs/serializable/fixed-bytes.ts b/src/bcs/serializable/fixed-bytes.ts index e6a927629..870839c4f 100644 --- a/src/bcs/serializable/fixed-bytes.ts +++ b/src/bcs/serializable/fixed-bytes.ts @@ -5,10 +5,7 @@ import { Serializable, Serializer } from "../serializer"; import { Deserializer } from "../deserializer"; import { HexInput } from "../../types"; import { Hex } from "../../core"; -import { - EntryFunctionArgument, - TransactionArgument, -} from "../../transactions/instances/transactionArgument"; +import { EntryFunctionArgument, TransactionArgument } from "../../transactions/instances/transactionArgument"; /** * This class exists to represent a contiguous sequence of BCS bytes that when serialized diff --git a/src/bcs/serializable/move-primitives.ts b/src/bcs/serializable/move-primitives.ts index 5a57fd003..4a1f5aec2 100644 --- a/src/bcs/serializable/move-primitives.ts +++ b/src/bcs/serializable/move-primitives.ts @@ -11,12 +11,7 @@ import { } from "../consts"; import { AnyNumber, Uint16, Uint32, Uint8 } from "../../types"; import { Deserializer } from "../deserializer"; -import { - Serializable, - Serializer, - ensureBoolean, - validateNumberInRange, -} from "../serializer"; +import { Serializable, Serializer, ensureBoolean, validateNumberInRange } from "../serializer"; import { TransactionArgument } from "../../transactions/instances/transactionArgument"; import { ScriptTransactionArgumentBool, diff --git a/src/bcs/serializable/move-structs.ts b/src/bcs/serializable/move-structs.ts index 59093abe3..da0758803 100644 --- a/src/bcs/serializable/move-structs.ts +++ b/src/bcs/serializable/move-structs.ts @@ -6,14 +6,8 @@ import { Deserializable, Deserializer } from "../deserializer"; import { Bool, U128, U16, U256, U32, U64, U8 } from "./move-primitives"; import { AnyNumber, HexInput } from "../../types"; import { AccountAddress, Hex } from "../../core"; -import { - EntryFunctionArgument, - TransactionArgument, -} from "../../transactions/instances/transactionArgument"; -import { - ScriptTransactionArgumentAddress, - ScriptTransactionArgumentU8Vector, -} from "../../transactions/instances"; +import { EntryFunctionArgument, TransactionArgument } from "../../transactions/instances/transactionArgument"; +import { ScriptTransactionArgumentAddress, ScriptTransactionArgumentU8Vector } from "../../transactions/instances"; /** * This class is the Aptos Typescript SDK representation of a Move `vector`, @@ -58,10 +52,7 @@ import { * values: an Array of values where T is a class that implements Serializable * @returns a `MoveVector` with the values `values` */ -export class MoveVector - extends Serializable - implements TransactionArgument -{ +export class MoveVector extends Serializable implements TransactionArgument { public values: Array; constructor(values: Array) { @@ -219,10 +210,7 @@ export class MoveVector * @returns a MoveVector of the corresponding class T * * */ - static deserialize( - deserializer: Deserializer, - cls: Deserializable - ): MoveVector { + static deserialize(deserializer: Deserializer, cls: Deserializable): MoveVector { const length = deserializer.deserializeUleb128AsU32(); const values = new Array(); for (let i = 0; i < length; i += 1) { @@ -260,10 +248,7 @@ export class MoveString extends Serializable implements TransactionArgument { } } -export class MoveOption - extends Serializable - implements EntryFunctionArgument -{ +export class MoveOption extends Serializable implements EntryFunctionArgument { private vec: MoveVector; public readonly value?: T; @@ -331,9 +316,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static U8(value?: number | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new U8(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new U8(value) : undefined); } /** @@ -348,9 +331,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static U16(value?: number | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new U16(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new U16(value) : undefined); } /** @@ -365,9 +346,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static U32(value?: number | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new U32(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new U32(value) : undefined); } /** @@ -382,9 +361,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static U64(value?: AnyNumber | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new U64(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new U64(value) : undefined); } /** @@ -399,9 +376,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static U128(value?: AnyNumber | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new U128(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new U128(value) : undefined); } /** @@ -416,9 +391,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static U256(value?: AnyNumber | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new U256(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new U256(value) : undefined); } /** @@ -433,9 +406,7 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static Bool(value?: boolean | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new Bool(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new Bool(value) : undefined); } /** @@ -451,15 +422,10 @@ export class MoveOption * @returns a MoveOption with an inner value `value` */ static MoveString(value?: string | null): MoveOption { - return new MoveOption( - value !== null && value !== undefined ? new MoveString(value) : undefined - ); + return new MoveOption(value !== null && value !== undefined ? new MoveString(value) : undefined); } - static deserialize( - deserializer: Deserializer, - cls: Deserializable - ): MoveOption { + static deserialize(deserializer: Deserializer, cls: Deserializable): MoveOption { const vector = MoveVector.deserialize(deserializer, cls); return new MoveOption(vector.values[0]); } diff --git a/src/bcs/serializer.ts b/src/bcs/serializer.ts index 9fb0e250c..8937e8bb4 100644 --- a/src/bcs/serializer.ts +++ b/src/bcs/serializer.ts @@ -34,7 +34,8 @@ export abstract class Serializable { * Helper function to get a value's BCS-serialized bytes as a Hex instance. * @returns a Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array */ - bcsToHex() { //: Hex { + bcsToHex() { + //: Hex { // const bcsBytes = this.bcsToBytes(); // return Hex.fromHexInput({ hexInput: bcsBytes }); } diff --git a/src/transactions/instances/scriptTransactionArguments.ts b/src/transactions/instances/scriptTransactionArguments.ts index 4d1762e28..7eac21dfc 100644 --- a/src/transactions/instances/scriptTransactionArguments.ts +++ b/src/transactions/instances/scriptTransactionArguments.ts @@ -259,4 +259,4 @@ export class ScriptTransactionArgumentBool extends ScriptTransactionArgument imp const value = deserializer.deserializeBool(); return new ScriptTransactionArgumentBool(value); } -} \ No newline at end of file +} diff --git a/src/transactions/instances/transactionArgument.ts b/src/transactions/instances/transactionArgument.ts index 1343dad3c..59d664a3d 100644 --- a/src/transactions/instances/transactionArgument.ts +++ b/src/transactions/instances/transactionArgument.ts @@ -2,9 +2,7 @@ import { Serializer, Deserializer, Serializable } from "../../bcs"; import { HexInput } from "../../types"; import { FixedBytes } from "../../bcs/serializable/fixed-bytes"; -export interface TransactionArgument - extends EntryFunctionArgument, - ScriptFunctionArgument {} +export interface TransactionArgument extends EntryFunctionArgument, ScriptFunctionArgument {} export interface EntryFunctionArgument { /** @@ -41,10 +39,7 @@ export interface ScriptFunctionArgument { * of the argument beforehand, and use the appropriate class to deserialize the bytes within * an instance of this class. */ -export class EntryFunctionBytes - extends Serializable - implements EntryFunctionArgument -{ +export class EntryFunctionBytes extends Serializable implements EntryFunctionArgument { public readonly value: FixedBytes; private constructor(value: HexInput) { @@ -77,10 +72,7 @@ export class EntryFunctionBytes * @param length the length of the bytes to deserialize * @returns an instance of this class, which will now only be usable as an EntryFunctionArgument */ - static deserialize( - deserializer: Deserializer, - length: number - ): EntryFunctionBytes { + static deserialize(deserializer: Deserializer, length: number): EntryFunctionBytes { const fixedBytes = FixedBytes.deserialize(deserializer, length); return new EntryFunctionBytes(fixedBytes.value); } diff --git a/src/transactions/instances/transactionPayload.ts b/src/transactions/instances/transactionPayload.ts index c3d93a46a..63f723422 100644 --- a/src/transactions/instances/transactionPayload.ts +++ b/src/transactions/instances/transactionPayload.ts @@ -138,7 +138,12 @@ export class EntryFunction { * public entry fun transfer(from: &signer, to: address, amount: u64) * ``` */ - constructor(module_name: ModuleId, function_name: Identifier, type_args: Array, args: Array) { + constructor( + module_name: ModuleId, + function_name: Identifier, + type_args: Array, + args: Array, + ) { this.module_name = module_name; this.function_name = function_name; this.type_args = type_args; @@ -192,7 +197,7 @@ export class EntryFunction { * NOTE: When you deserialize an EntryFunction payload with this method, the entry function * arguments are populated into the deserialized instance as type-agnostic, raw fixed bytes * in the form of the EntryFunctionBytes class. - * + * * In order to correctly deserialize these arguments as their actual type representations, you * must know the types of the arguments beforehand and deserialize them yourself individually. * diff --git a/src/transactions/typeTag/typeTag.ts b/src/transactions/typeTag/typeTag.ts index d845e6c02..a4b5dbe62 100644 --- a/src/transactions/typeTag/typeTag.ts +++ b/src/transactions/typeTag/typeTag.ts @@ -235,12 +235,8 @@ export class StructTag extends Serializable { } } -export const stringStructTag = () => new StructTag( - AccountAddress.ONE, - new Identifier("string"), - new Identifier("String"), - [], -); +export const stringStructTag = () => + new StructTag(AccountAddress.ONE, new Identifier("string"), new Identifier("String"), []); export function optionStructTag(typeArg: TypeTag): StructTag { return new StructTag(AccountAddress.ONE, new Identifier("option"), new Identifier("Option"), [typeArg]); diff --git a/tests/unit/script_transaction_arguments.test.ts b/tests/unit/script_transaction_arguments.test.ts index 89d10af03..2f808a2dd 100644 --- a/tests/unit/script_transaction_arguments.test.ts +++ b/tests/unit/script_transaction_arguments.test.ts @@ -120,4 +120,4 @@ describe("Tests for the script transaction argument class", () => { true, ); }); -}); \ No newline at end of file +}); diff --git a/tests/unit/type_tag.test.ts b/tests/unit/type_tag.test.ts index dd9f67da0..961b441cf 100644 --- a/tests/unit/type_tag.test.ts +++ b/tests/unit/type_tag.test.ts @@ -74,7 +74,7 @@ describe("TypeTagParser", () => { const typeTagError = error as ParsingError; expect(typeTagError.message).toEqual( `The given hex string ${typeTag} is a special address not in LONG form, - it must be 0x0 to 0xf without padding zeroes.` + it must be 0x0 to 0xf without padding zeroes.`, ); }