Skip to content

Commit

Permalink
Remove interfaces directory
Browse files Browse the repository at this point in the history
  • Loading branch information
moreal committed Dec 18, 2023
1 parent 46c5d51 commit af0f8fb
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 54 deletions.
15 changes: 13 additions & 2 deletions src/actions/mint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { Address } from "@planetarium/account";
import { RecordView, Value } from "@planetarium/bencodex";
import { encodeCurrency } from "@planetarium/tx";
import { IFungibleAssetValues, IFungibleItems } from "../interfaces/minter";
import { FungibleAssetValue, encodeCurrency } from "@planetarium/tx";
import { FungibleItemId } from "../types/fungible-item-id";

export interface IFungibleAssetValues {
recipient: string;
amount: FungibleAssetValue;
}

export interface IFungibleItems {
recipient: string;
fungibleItemId: FungibleItemId;
count: number;
}

function encodeMintSpec(value: IFungibleAssetValues | IFungibleItems): Value {
if ((value as IFungibleAssetValues).amount !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/events/assets-transferred.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from "@planetarium/account";
import { IHeadlessGraphQLClient } from "../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../headless-graphql-client";
import { AssetTransferredEvent } from "../types/asset-transferred-event";
import { TransactionLocation } from "../types/transaction-location";

Expand Down
2 changes: 1 addition & 1 deletion src/events/garage-unload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from "@planetarium/account";
import { IHeadlessGraphQLClient } from "../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../headless-graphql-client";
import { GarageUnloadEvent } from "../types/garage-unload-event";

export type ValidatedGarageUnloadEvent = Omit<GarageUnloadEvent, "memo"> & {
Expand Down
21 changes: 20 additions & 1 deletion src/headless-graphql-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,33 @@ import {
GetTransactionResultDocument,
StageTransactionDocument,
} from "./generated/graphql";
import { IHeadlessGraphQLClient } from "./interfaces/headless-graphql-client";
import { AssetTransferredEvent } from "./types/asset-transferred-event";
import { BlockHash } from "./types/block-hash";
import { GarageUnloadEvent } from "./types/garage-unload-event";
import { Planet } from "./types/registry";
import { TransactionResult } from "./types/transaction-result";
import { TxId } from "./types/txid";

export interface IHeadlessGraphQLClient {
getPlanetID(): string;
getBlockIndex(blockHash: BlockHash): Promise<number>;
getTipIndex(): Promise<number>;
getBlockHash(index: number): Promise<BlockHash>;
getGarageUnloadEvents(
blockIndex: number,
agentAddress: Address,
avatarAddress: Address,
): Promise<GarageUnloadEvent[]>;
getAssetTransferredEvents(
blockIndex: number,
recipient: Address,
): Promise<AssetTransferredEvent[]>;
getNextTxNonce(address: string): Promise<number>;
getGenesisHash(): Promise<string>;
stageTransaction(payload: string): Promise<string>;
getTransactionResult(txId: TxId): Promise<TransactionResult>;
}

export class HeadlessGraphQLClient implements IHeadlessGraphQLClient {
private readonly _client: Client;
private readonly _planet: Planet;
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "dotenv/config";
import { getAccountFromEnv } from "./accounts";
import { getEnv, getRequiredEnv } from "./env";
import { HeadlessGraphQLClient } from "./headless-graphql-client";
import { IHeadlessGraphQLClient } from "./interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "./headless-graphql-client";
import { PreloadHandler } from "./preload-handler";
import { SlackBot } from "./slack/bot";
import { SlackChannel } from "./slack/channel";
Expand Down
26 changes: 0 additions & 26 deletions src/interfaces/headless-graphql-client.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/interfaces/minter.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/sync/downstream/events/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { FungibleAssetValue, signTx } from "@planetarium/tx";
import { ResponseType } from "@prisma/client";
import { encodeBurnAssetAction } from "../../../actions/burn";
import { encodeTransferAssetAction } from "../../../actions/transfer";
import { encodeMintAssetsAction } from "../../../actions/mint";
import { SUPER_FUTURE_DATETIME, additionalGasTxProperties } from "../../../tx";
import { encodeMintAssetsAction } from "../../../actions/mint";
import { AssetTransferredEvent } from "../../../types/asset-transferred-event";
import { SignedTx } from "../../../types/signed-tx";
import { BridgeResponse } from "../../types";
Expand Down
2 changes: 1 addition & 1 deletion src/sync/downstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ResponseType,
} from "@prisma/client";
import { getAssetTransferredEvents } from "../../events/assets-transferred";
import { IHeadlessGraphQLClient } from "../../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../../headless-graphql-client";
import { SlackBot } from "../../slack/bot";
import {
BridgeEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/sync/stage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Account } from "@planetarium/account";
import { PrismaClient } from "@prisma/client";
import { IHeadlessGraphQLClient } from "../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../headless-graphql-client";

export async function stageTransactionFromDB(
account: Account,
Expand Down
2 changes: 1 addition & 1 deletion src/sync/txresult.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaClient, TxResult } from "@prisma/client";
import { IHeadlessGraphQLClient } from "../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../headless-graphql-client";

const LIMIT = 10;

Expand Down
6 changes: 3 additions & 3 deletions src/sync/upstream/events/garage.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Account, Address } from "@planetarium/account";
import { signTx } from "@planetarium/tx";
import { ResponseType } from "@prisma/client";
import { ValidatedGarageUnloadEvent } from "../../../events/garage-unload";
import {
IFungibleAssetValues,
IFungibleItems,
} from "../../../interfaces/minter";
import { encodeMintAssetsAction } from "../../../actions/mint";
encodeMintAssetsAction,
} from "../../../actions/mint";
import { ValidatedGarageUnloadEvent } from "../../../events/garage-unload";
import { SUPER_FUTURE_DATETIME, additionalGasTxProperties } from "../../../tx";
import { BridgeResponse } from "../../types";

Expand Down
2 changes: 1 addition & 1 deletion src/sync/upstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ValidatedGarageUnloadEvent,
getGarageUnloadEvents,
} from "../../events/garage-unload";
import { IHeadlessGraphQLClient } from "../../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../../headless-graphql-client";
import { SlackBot } from "../../slack/bot";
import { BridgeErrorEvent } from "../../slack/messages/bridge-error-event";
import { BridgeEvent } from "../../slack/messages/bridge-event";
Expand Down
2 changes: 1 addition & 1 deletion src/sync/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Account } from "@planetarium/account";
import { ResponseType } from "@prisma/client";
import { IHeadlessGraphQLClient } from "../interfaces/headless-graphql-client";
import { IHeadlessGraphQLClient } from "../headless-graphql-client";
import { BridgeEventActionType } from "../slack/messages/bridge-event";
import { PrismaTransactionClient } from "./types";

Expand Down

0 comments on commit af0f8fb

Please sign in to comment.