diff --git a/packages/app/src/api/db.ts b/packages/app/src/api/db.ts index fb661293..ba5432bc 100644 --- a/packages/app/src/api/db.ts +++ b/packages/app/src/api/db.ts @@ -1,40 +1,12 @@ import { type GetNeighboursResponse, - type Mint, - type MintResponse, - type MongoResponse, type NeighbourEntry, type RawGetNeighboursResponse, type RawNeighbourEntry, - type Transfer, - type TransferResponse, } from "./types"; import { PublicKey } from "@solana/web3.js"; -import mintStub from "./stubs/mints.json"; -import sendingStub from "./stubs/sendings.json"; -import receiptStub from "./stubs/receipts.json"; -const STUB_DB = false; -const STUBS = { - mints: mintStub, - sender: sendingStub, - recipient: receiptStub, -}; const GET_NEIGHBOURS_URL = process.env.REACT_APP_GET_NEIGHBOURS_URL ?? ""; -const MONGODB_API_URL = process.env.REACT_APP_MONGODB_API_URL ?? ""; -const MONGODB_READ_TOKEN = process.env.REACT_APP_MONGODB_READ_TOKEN ?? ""; -const buildTransferRecord = (transfer: TransferResponse): Transfer => ({ - timestamp: new Date(transfer.timestamp), - sender: new PublicKey(transfer.sender), - recipient: new PublicKey(transfer.recipient), - amount: transfer.amount, -}); -const buildMintRecord = (mint: MintResponse): Mint => ({ - timestamp: new Date(mint.timestamp), - recipient: new PublicKey(mint.recipient), - sender: mint.sender !== undefined ? new PublicKey(mint.sender) : undefined, - amount: mint.amount, -}); const fromRawNeighbourEntry = ( rawEntry: RawNeighbourEntry @@ -65,44 +37,3 @@ export const getNeighbours = async ( ), }, })); - -const getDBData = async ( - collection: "mints" | "transfers", - types: Array<"recipient" | "sender">, - address: PublicKey -): Promise> => { - if (STUB_DB) { - return ( - collection === "mints" - ? STUBS.mints - : types.flatMap((type) => STUBS[type]) - ) as MongoResponse; - } - return fetch(`${MONGODB_API_URL}/action/find`, { - method: "POST", - headers: { - "api-key": MONGODB_READ_TOKEN, - "Content-Type": "application/json", - }, - body: JSON.stringify({ - dataSource: "Cluster0", - database: "gsol-tracker", - collection, - filter: { - $or: types.map((type) => ({ - [type]: address.toString(), - })), - }, - }), - }).then(async (resp) => resp.json()); -}; -export const getAccountMints = async (address: PublicKey): Promise => - getDBData("mints", ["sender", "recipient"], address) - .then((resp) => resp.documents) - .then((mints) => mints.map(buildMintRecord)); -export const getAccountTransfers = async ( - address: PublicKey -): Promise => - getDBData("transfers", ["sender", "recipient"], address) - .then((resp) => resp.documents) - .then((transfers) => transfers.map(buildTransferRecord)); diff --git a/packages/app/src/api/stubs/mints.json b/packages/app/src/api/stubs/mints.json deleted file mode 100644 index 20932ee9..00000000 --- a/packages/app/src/api/stubs/mints.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "documents": [ - { - "_id": "63e66de71dbb9cdd9990de87", - "timestamp": "2023-02-10T16:16:29Z", - "recipient": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "amount": 0.1 - }, - { - "_id": "63ede8f1bba5fd96f0b0af08", - "timestamp": "2023-02-16T08:27:15Z", - "recipient": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "amount": 0.1 - }, - { - "_id": "63edf2c1d33a17eb81455a36", - "timestamp": "2023-02-16T09:09:14Z", - "recipient": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "amount": 0.1 - } - ] -} \ No newline at end of file diff --git a/packages/app/src/api/stubs/receipts.json b/packages/app/src/api/stubs/receipts.json deleted file mode 100644 index dc9cf9be..00000000 --- a/packages/app/src/api/stubs/receipts.json +++ /dev/null @@ -1,3 +0,0 @@ -{"documents":[ - -]} \ No newline at end of file diff --git a/packages/app/src/api/stubs/sendings.json b/packages/app/src/api/stubs/sendings.json deleted file mode 100644 index 39c77e26..00000000 --- a/packages/app/src/api/stubs/sendings.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "documents": [ - { - "_id": "63e67a7e1dbb9cdd999e4275", - "timestamp": "2023-02-10T17:10:17Z", - "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "recipient": "D5MZtJLPLgpCLx7ou2dzv1j7twBCeStJsgAmpDw9411j", - "amount": 0.5 - }, - { - "_id": "63eaa6a28fc6aa0c56c5c1a7", - "timestamp": "2023-02-13T21:07:38Z", - "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "recipient": "C2LW78oU2sKRdxNPyoFWp7us5bECwC2CaV2US1v54xVe", - "amount": 0.01 - }, - { - "_id": "63ef8c0bd44f6f713adc3d51", - "timestamp": "2023-02-17T14:15:30Z", - "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "recipient": "DxPGdzQsAuX6nvYELP7LWZiaUuoLxXNtm3nqVHMPTsiL", - "amount": 0.3 - }, - { - "_id": "63ef8c0cace82aca35ab536d", - "timestamp": "2023-02-17T14:15:33Z", - "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "recipient": "DxPGdzQsAuX6nvYELP7LWZiaUuoLxXNtm3nqVHMPTsiL", - "amount": 0.3 - }, - { - "_id": "63f5f205da344915c24ff2e1", - "timestamp": "2023-02-22T10:44:11Z", - "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "recipient": "BpTA5p4EXEACi4H375TfLjEhT3kQiBoqtiDSj24saygv", - "amount": 0.5 - }, - { - "_id": "63f88510d44f6f713aefc00e", - "timestamp": "2023-02-24T09:36:07Z", - "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv", - "recipient": "Fi3Z4wbmhKVcmnpT89CzhnMuZ7y6Xek8iHJ95YbfM76R", - "amount": 0.2 - } - ] -} \ No newline at end of file diff --git a/packages/app/src/api/types.ts b/packages/app/src/api/types.ts index 5a4f3d46..e626c913 100644 --- a/packages/app/src/api/types.ts +++ b/packages/app/src/api/types.ts @@ -1,19 +1,5 @@ import { type PublicKey } from "@solana/web3.js"; -export interface MintResponse { - timestamp: string; - sender?: string; // the wallet that pays for the mint (assume = the recipient if missing) - recipient: string; - amount: number; -} - -export interface TransferResponse { - timestamp: string; - sender: string; - recipient: string; - amount: number; -} - export interface BalanceDetails { address: PublicKey; balance: number; @@ -60,24 +46,6 @@ export interface GetNeighboursResponse { lastTransfer: Date; } -export interface MongoResponse { - documents: T[]; -} - -export interface Mint { - timestamp: Date; - sender?: PublicKey; // the wallet that pays for the mint (assume = the recipient if missing) - recipient: PublicKey; // the wallet that receives the minted gSOL - amount: number; -} - -export interface Transfer { - timestamp: Date; - sender: PublicKey; - recipient: PublicKey; - amount: number; -} - export type ParentRelationship = "PARENT_IS_SENDER" | "PARENT_IS_RECIPIENT"; export interface TreeNode { diff --git a/packages/client/doc/classes/SunriseStakeClient.html b/packages/client/doc/classes/SunriseStakeClient.html index 58ec710b..a29a0ace 100644 --- a/packages/client/doc/classes/SunriseStakeClient.html +++ b/packages/client/doc/classes/SunriseStakeClient.html @@ -20,7 +20,7 @@

Hierarchy

  • SunriseStakeClient
+
  • Defined in index.ts:94
  • @@ -109,89 +109,89 @@
    env: options: Options = {}

    Returns SunriseStakeClient

    +
  • Defined in index.ts:119
  • Properties

    blazeState: undefined | BlazeState
    +
  • Defined in index.ts:112
  • bsolTokenAccount: undefined | PublicKey
    +
  • Defined in index.ts:110
  • bsolTokenAccountAuthority: undefined | PublicKey
    +
  • Defined in index.ts:109
  • config: undefined | SunriseStakeConfig
    +
  • Defined in index.ts:96
  • +
  • Defined in index.ts:117
  • liqPoolTokenAccount: undefined | PublicKey
    +
  • Defined in index.ts:114
  • lockClient: undefined | LockClient
    +
  • Defined in index.ts:115
  • marinade: undefined | Marinade
    +
  • Defined in index.ts:99
  • marinadeState: undefined | MarinadeState
    +
  • Defined in index.ts:100
  • msolTokenAccount: undefined | PublicKey
    +
  • Defined in index.ts:107
  • msolTokenAccountAuthority: undefined | PublicKey
    +
  • Defined in index.ts:106
  • options: Options = {}
    +
  • Defined in index.ts:122
  • program: Program<SunriseStake>
    +
  • Defined in index.ts:95
  • provider: AnchorProvider
    +
  • Defined in index.ts:120
  • staker: PublicKey
    +
  • Defined in index.ts:103
  • stakerGSolTokenAccount: undefined | PublicKey
    +
  • Defined in index.ts:104
  • Methods

    @@ -204,7 +204,7 @@
    +
  • Defined in index.ts:1602
    • @@ -217,7 +217,7 @@

      Parameters

      __namedParameters: Omit<Details, "extractableYield">

    Returns BN

    +
  • Defined in index.ts:1479
  • +
  • Defined in index.ts:1081
  • +
  • Defined in index.ts:842
    • @@ -269,7 +269,7 @@
      bsolAmount: stakePoolInfo: StakePool

    Returns [number, BN]

    +
  • Defined in index.ts:1383
    • @@ -284,7 +284,7 @@
      msolAmount: marinadeState: MarinadeState

    Returns BN

    +
  • Defined in index.ts:1360
    • @@ -304,7 +304,7 @@
      authority: Returns TransactionInstruction
    +
  • Defined in index.ts:289
  • +
  • Defined in index.ts:330
    • @@ -347,7 +347,7 @@
      stakeAccountAddress: Returns Promise<string>
    +
  • Defined in index.ts:432
  • +
  • Defined in index.ts:386
  • +
  • Defined in index.ts:1183
  • +
  • Defined in index.ts:1069
  • +
  • Defined in index.ts:1011
  • +
  • Defined in index.ts:815
  • +
  • Defined in index.ts:992
    • @@ -453,7 +453,7 @@
      withRefresh: Returns Promise<LockAccountSummary>
    +
  • Defined in index.ts:1806
    • @@ -470,7 +470,7 @@
      gsolMint: options: Options = {}

    Returns Promise<{
        accounts: any;
        parameters: any;
    }>

    +
  • Defined in index.ts:1395
    • @@ -478,7 +478,7 @@
    +
  • Defined in index.ts:143
  • +
  • Defined in index.ts:939
    • @@ -507,7 +507,7 @@
      lamports: Returns Promise<Transaction[]>
    +
  • Defined in index.ts:1700
    • @@ -520,7 +520,7 @@

      Parameters

      Rest ...args: any[]

    Returns void

    +
  • Defined in index.ts:132
    • @@ -542,7 +542,7 @@
      Optional Returns Promise<Transaction>
    +
  • Defined in index.ts:308
    • @@ -561,7 +561,7 @@
      lamports: Returns Promise<[Transaction, Keypair[]]>
    +
  • Defined in index.ts:775
  • +
  • Defined in index.ts:509
  • +
  • Defined in index.ts:139
  • +
  • Defined in index.ts:713
    • @@ -620,7 +620,7 @@
      Optional Returns Promise<string>
    +
  • Defined in index.ts:240
    • @@ -648,7 +648,7 @@
      withRefresh: Returns Promise<string[]>
    +
  • Defined in index.ts:261
  • Returns Promise<TicketAccount>

    +
  • Defined in index.ts:792
  • +
  • Defined in index.ts:682
  • +
  • Defined in index.ts:1782
    • @@ -708,7 +708,7 @@
      lamports: Returns Promise<Transaction>
    +
  • Defined in index.ts:474
    • @@ -734,7 +734,7 @@
      Optional Returns Promise<void>
    +
  • Defined in index.ts:1566
  • +
  • Defined in index.ts:611
  • +
  • Defined in index.ts:1739
    • @@ -777,7 +777,7 @@
      amount: Returns Promise<string>
    +
  • Defined in index.ts:882
    • @@ -797,7 +797,7 @@
      amount: Returns Promise<string>
    +
  • Defined in index.ts:909
  • +
  • Defined in index.ts:1843
  • +
  • Defined in index.ts:1522
  • +
  • Defined in util.ts:153
  • +
  • Defined in decodeStakePool.ts:90
  • +
  • Defined in util.ts:39
  • +
  • Defined in types/Details.ts:64
  • marinadeFinanceProgramId: string
    +
  • Defined in types/Details.ts:55
  • marinadeStateAddress: string
    +
  • Defined in types/Details.ts:56
  • mpDetails: {
        msolPrice: number;
        msolValue: BN;
        stakeDelta: number;
    }
    @@ -143,17 +143,17 @@
    msolValue
    stakeDelta: number
    +
  • Defined in types/Details.ts:59
  • staker: string
    +
  • Defined in types/Details.ts:42
  • stakerGSolTokenAccount: string
    +
  • Defined in types/Details.ts:46
  • sunriseStakeConfig: {
        gsolMint: string;
        msolTokenAccount?: string;
        msolTokenAccountAuthority?: string;
        programId: string;
        stateAddress: string;
        treasury: string;
    }
    @@ -173,7 +173,7 @@
    stateAddress
    treasury: string
    +
  • Defined in types/Details.ts:47
  • +
  • Defined in constants.ts:27
  • +
  • Defined in types/sunrise_stake.ts:1
  • +
  • Defined in types/TicketAccount.ts:10
  • +
  • Defined in constants.ts:108
  • +
  • Defined in constants.ts:107
  • +
  • Defined in constants.ts:116
  • +
  • Defined in constants.ts:34
  • +
  • Defined in types/sunrise_stake.ts:2625
  • +
  • Defined in constants.ts:15
  • +
  • Defined in constants.ts:110
  • +
  • Defined in constants.ts:6
  • +
  • Defined in constants.ts:114
  • +
  • Defined in constants.ts:112
  • +
  • Defined in constants.ts:9
  • +
  • Defined in constants.ts:11
  • +
  • Defined in util.ts:232