Skip to content

Commit

Permalink
consolidate move struct and resource type (#120)
Browse files Browse the repository at this point in the history
* consolidate move struct and resource type

* update name to MoveStructType

* update comment
  • Loading branch information
0xmigo authored Oct 26, 2023
1 parent 6bced7c commit ad8aa16
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
LedgerVersion,
MoveModuleBytecode,
MoveResource,
MoveResourceType,
MoveStructType,
OrderBy,
PaginationArgs,
TokenStandard,
Expand Down Expand Up @@ -175,7 +175,7 @@ export class Account {
*/
async getAccountResource<T extends {} = any>(args: {
accountAddress: HexInput;
resourceType: MoveResourceType;
resourceType: MoveStructType;
options?: LedgerVersion;
}): Promise<T> {
return getResource<T>({ aptosConfig: this.config, ...args });
Expand Down
4 changes: 2 additions & 2 deletions src/api/coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AptosConfig } from "./aptosConfig";
import { Account } from "../core";
import { transferCoinTransaction } from "../internal/coin";
import { SingleSignerTransaction, GenerateTransactionOptions } from "../transactions/types";
import { AnyNumber, HexInput, MoveResourceType } from "../types";
import { AnyNumber, HexInput, MoveStructType } from "../types";

/**
* A class to handle all `Coin` operations
Expand All @@ -31,7 +31,7 @@ export class Coin {
sender: Account;
recipient: HexInput;
amount: AnyNumber;
coinType?: MoveResourceType;
coinType?: MoveStructType;
options?: GenerateTransactionOptions;
}): Promise<SingleSignerTransaction> {
return transferCoinTransaction({ aptosConfig: this.config, ...args });
Expand Down
4 changes: 2 additions & 2 deletions src/api/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { AptosConfig } from "./aptosConfig";
import { getAccountEventsByCreationNumber, getAccountEventsByEventType, getEvents } from "../internal/event";
import { AnyNumber, GetEventsResponse, HexInput, MoveResourceType, OrderBy, PaginationArgs } from "../types";
import { AnyNumber, GetEventsResponse, HexInput, MoveStructType, OrderBy, PaginationArgs } from "../types";
import { EventsBoolExp } from "../types/generated/types";

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ export class Event {
*/
async getAccountEventsByEventType(args: {
accountAddress: HexInput;
eventType: MoveResourceType;
eventType: MoveStructType;
options?: {
pagination?: PaginationArgs;
orderBy?: OrderBy<GetEventsResponse[0]>;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
LedgerVersion,
MoveModuleBytecode,
MoveResource,
MoveResourceType,
MoveStructType,
OrderBy,
PaginationArgs,
SigningScheme,
Expand Down Expand Up @@ -164,7 +164,7 @@ export async function getResources(args: {
export async function getResource<T extends {}>(args: {
aptosConfig: AptosConfig;
accountAddress: HexInput;
resourceType: MoveResourceType;
resourceType: MoveStructType;
options?: LedgerVersion;
}): Promise<T> {
const { aptosConfig, accountAddress, resourceType, options } = args;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AptosConfig } from "../api/aptosConfig";
import { U64 } from "../bcs/serializable/movePrimitives";
import { Account, AccountAddress } from "../core";
import { GenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
import { HexInput, AnyNumber, MoveResourceType } from "../types";
import { HexInput, AnyNumber, MoveStructType } from "../types";
import { APTOS_COIN } from "../utils/const";
import { generateTransaction } from "./transactionSubmission";
import { parseTypeTag } from "../transactions/typeTag/parser";
Expand All @@ -12,7 +12,7 @@ export async function transferCoinTransaction(args: {
sender: Account;
recipient: HexInput;
amount: AnyNumber;
coinType?: MoveResourceType;
coinType?: MoveStructType;
options?: GenerateTransactionOptions;
}): Promise<SingleSignerTransaction> {
const { aptosConfig, sender, recipient, amount, coinType, options } = args;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { AptosConfig } from "../api/aptosConfig";
import { AccountAddress } from "../core";
import { AnyNumber, GetEventsResponse, HexInput, PaginationArgs, MoveResourceType, OrderBy } from "../types";
import { AnyNumber, GetEventsResponse, HexInput, PaginationArgs, MoveStructType, OrderBy } from "../types";
import { GetEventsQuery } from "../types/generated/operations";
import { GetEvents } from "../types/generated/queries";
import { EventsBoolExp } from "../types/generated/types";
Expand All @@ -35,7 +35,7 @@ export async function getAccountEventsByCreationNumber(args: {
export async function getAccountEventsByEventType(args: {
aptosConfig: AptosConfig;
accountAddress: HexInput;
eventType: MoveResourceType;
eventType: MoveStructType;
options?: {
pagination?: PaginationArgs;
orderBy?: OrderBy<GetEventsResponse[0]>;
Expand Down
17 changes: 8 additions & 9 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export type GasEstimation = {
};

export type MoveResource = {
type: MoveResourceType;
type: MoveStructType;
data: {};
};

Expand Down Expand Up @@ -518,7 +518,7 @@ export type TransactionPayloadResponse = EntryFunctionPayloadResponse | ScriptPa

export type EntryFunctionPayloadResponse = {
type: string;
function: MoveResourceType;
function: MoveStructType;
/**
* Type arguments of the function
*/
Expand Down Expand Up @@ -679,12 +679,11 @@ export type MoveUint128Type = string;
export type MoveUint256Type = string;
export type MoveAddressType = string;
export type MoveObjectType = string;
export type MoveStructType = `${string}::${string}::${string}`;
export type MoveOptionType = MoveType | null | undefined;
/**
* String representation of a on-chain Move struct type.
* This is the format for a fully qualified struct, resource, or entry function in Move.
*/
export type MoveResourceType = `${string}::${string}::${string}`;
export type MoveStructType = `${string}::${string}::${string}`;

export type MoveType =
| boolean
Expand Down Expand Up @@ -893,7 +892,7 @@ export type Block = {
*/
export type ViewRequestData = {
function: MoveStructType;
typeArguments?: Array<MoveResourceType>;
typeArguments?: Array<MoveStructType>;
functionArguments?: Array<MoveValue>;
};

Expand All @@ -902,14 +901,14 @@ export type ViewRequestData = {
/**
* View request for the Move view function API
*
* `type MoveResourceType = ${string}::${string}::${string}`;
* `type MoveStructType = ${string}::${string}::${string}`;
*/
export type ViewRequest = {
function: MoveResourceType;
function: MoveStructType;
/**
* Type arguments of the function
*/
type_arguments: Array<MoveResourceType>;
type_arguments: Array<MoveStructType>;
/**
* Arguments of the function
*/
Expand Down

0 comments on commit ad8aa16

Please sign in to comment.