Skip to content

Commit

Permalink
fix dep cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
heliuchuan committed Nov 2, 2024
1 parent b3c0e0e commit 052b6f2
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/account/AbstractKeylessAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import EventEmitter from "eventemitter3";
import { jwtDecode } from "jwt-decode";
import { EphemeralCertificateVariant, HexInput, KeylessError, KeylessErrorType, SigningScheme } from "../types";
import { EphemeralCertificateVariant, HexInput, SigningScheme } from "../types";
import { AccountAddress } from "../core/accountAddress";
import {
AnyPublicKey,
Expand All @@ -28,6 +28,7 @@ import { base64UrlDecode } from "../utils/helpers";
import { FederatedKeylessPublicKey } from "../core/crypto/federatedKeyless";
import { Account } from "./Account";
import { AptosConfig } from "../api/aptosConfig";
import { KeylessError, KeylessErrorType } from "../errors";

/**
* An interface which defines if an Account utilizes Keyless signing.
Expand Down
12 changes: 2 additions & 10 deletions src/client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@

import { AptosConfig } from "../api/aptosConfig";
import { VERSION } from "../version";
import {
AnyNumber,
AptosApiError,
AptosRequest,
AptosResponse,
Client,
ClientRequest,
ClientResponse,
MimeType,
} from "../types";
import { AnyNumber, AptosRequest, AptosResponse, Client, ClientRequest, ClientResponse, MimeType } from "../types";
import { AptosApiType } from "../utils";
import { AptosApiError } from "../errors";

/**
* Sends a request using the specified options and returns the response.
Expand Down
3 changes: 1 addition & 2 deletions src/core/crypto/keyless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
ZkpVariant,
LedgerVersionArg,
MoveResource,
KeylessErrorType,
KeylessError,
} from "../../types";
import { EphemeralPublicKey, EphemeralSignature } from "./ephemeral";
import { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from "./poseidon";
Expand All @@ -35,6 +33,7 @@ import { getAptosFullNode } from "../../client";
import { memoizeAsync } from "../../utils/memoize";
import { AccountAddress, AccountAddressInput } from "../accountAddress";
import { getErrorMessage } from "../../utils";
import { KeylessError, KeylessErrorType } from "../../errors";

export const EPK_HORIZON_SECS = 10000000;
export const MAX_AUD_VAL_BYTES = 120;
Expand Down
23 changes: 1 addition & 22 deletions src/types/error.ts → src/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AptosApiType } from "../utils/const";
import { getErrorMessage } from "../utils/helpers";
import { AptosRequest } from "./types";
import { AptosRequest, AptosResponse } from "../types";

export enum KeylessErrorCategory {
API_ERROR,
Expand Down Expand Up @@ -289,27 +289,6 @@ export class KeylessError extends Error {
}
}

/**
* The API response type
*
* @param status - the response status. i.e. 200
* @param statusText - the response message
* @param data the response data
* @param url the url the request was made to
* @param headers the response headers
* @param config (optional) - the request object
* @param request (optional) - the request object
*/
export interface AptosResponse<Req, Res> {
status: number;
statusText: string;
data: Res;
url: string;
headers: any;
config?: any;
request?: Req;
}

/**
* Options for handling errors in the Aptos API.
*/
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from "./api";
export * from "./bcs";
export * from "./client";
export * from "./core";
export * from "./errors";
export * from "./transactions";
export * from "./transactions/management";
export * from "./types";
Expand Down
2 changes: 1 addition & 1 deletion src/internal/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { AptosConfig } from "../api/aptosConfig";
import { getAptosFullNode, paginateWithCursor } from "../client";
import {
AccountData,
AptosApiError,
GetAccountCoinsDataResponse,
GetAccountCollectionsWithOwnedTokenResponse,
GetAccountOwnedTokensFromCollectionResponse,
Expand Down Expand Up @@ -56,6 +55,7 @@ import { Secp256k1PrivateKey, AuthenticationKey, Ed25519PrivateKey, createObject
import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
import { getTableItem } from "./table";
import { APTOS_COIN } from "../utils";
import { AptosApiError } from "../errors";

/**
* Retrieves account information for a specified account address.
Expand Down
3 changes: 2 additions & 1 deletion src/internal/keyless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
ZkProof,
getKeylessConfig,
} from "../core";
import { HexInput, KeylessError, KeylessErrorType, ZkpVariant } from "../types";
import { HexInput, ZkpVariant } from "../types";
import { Account, EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
import { PepperFetchRequest, PepperFetchResponse, ProverRequest, ProverResponse } from "../types/keyless";
import { lookupOriginalAccountAddress } from "./account";
Expand All @@ -30,6 +30,7 @@ import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount";
import { MoveVector } from "../bcs";
import { generateTransaction } from "./transactionSubmission";
import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions";
import { KeylessError, KeylessErrorType } from "../errors";

/**
* Retrieves a pepper value based on the provided configuration and authentication details.
Expand Down
2 changes: 1 addition & 1 deletion src/internal/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import { AptosConfig } from "../api/aptosConfig";
import { getAptosFullNode, paginateWithCursor } from "../client";
import { AptosApiError } from "../errors";
import {
AptosApiError,
TransactionResponseType,
type AnyNumber,
type GasEstimation,
Expand Down
1 change: 0 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./indexer";
export * from "./error";
export * from "./types";
21 changes: 21 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,27 @@ export type AptosRequest = {
overrides?: ClientConfig & FullNodeConfig & IndexerConfig & FaucetConfig;
};

/**
* The API response type
*
* @param status - the response status. i.e. 200
* @param statusText - the response message
* @param data the response data
* @param url the url the request was made to
* @param headers the response headers
* @param config (optional) - the request object
* @param request (optional) - the request object
*/
export interface AptosResponse<Req, Res> {
status: number;
statusText: string;
data: Res;
url: string;
headers: any;
config?: any;
request?: Req;
}

/**
* The ledger version of transactions, defaulting to the latest version if not specified.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/client/aptosRequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Account,
AptosApiError,
AptosApiType,
aptosRequest,
generateSignedTransaction,
Expand All @@ -9,6 +8,7 @@ import {
NetworkToNodeAPI,
U64,
} from "../../../src";
import { AptosApiError } from "../../../src/errors";
import { VERSION } from "../../../src/version";
import { longTestTimeout } from "../../unit/helper";
import { getAptosClient } from "../helper";
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AptosApiError } from "../../src";
import { AptosApiError } from "../../src/errors";
import { AptosApiType } from "../../src/utils/const.js";

describe(AptosApiError.name, () => {
Expand Down

0 comments on commit 052b6f2

Please sign in to comment.