{"version":3,"file":"getHistory.cjs","sources":["../../../../src/wallet/getHistory.ts"],"sourcesContent":["import {\n  BASE_URL,\n  buildQueryString,\n  handleResponse,\n  getHeaders,\n} from \"./utils\";\nimport type { GetHistoryRequest, GetHistoryResponse } from \"./types\";\n\n/**\n * Get transaction history for a given wallet\n *\n * Retrieves a parsed transaction history using our internal parsers. Returns\n * human-readable, parsed transactions with balance changes for each transaction.\n * **Pagination is manual** - the API returns up to 100 transactions per request.\n *\n * Returns transactions in reverse chronological order (i.e., newest first).\n *\n * **Associated Token Accounts (ATAs):** The `tokenAccounts` parameter controls whether\n * transactions involving token accounts owned by the wallet are included:\n * - `balanceChanged` (recommended): Includes transactions that changed token account balances, filtering spam\n * - `none`: Only direct wallet interactions\n * - `all`: All token account transactions including spam\n *\n * **Pagination:** Use the `before` parameter with `pagination.nextCursor` to fetch the\n * next page. The response includes `pagination.hasMore` to indicate if more results are\n * available. Each request makes a single API call and costs 100 credits.\n *\n * @beta The Wallet API is currently in beta. APIs and response formats may change.\n *\n * @param apiKey - Helius API key\n * @param params - Request parameters including wallet address and pagination options\n * @returns Transaction history with balance changes and pagination metadata\n * @throws Error if HTTP error or invalid wallet address\n *\n * @example\n * ```ts\n * // Get first page of history\n * const history = await helius.wallet.getHistory({\n *   wallet: \"86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY\",\n *   limit: 50,\n *   tokenAccounts: \"balanceChanged\"\n * });\n *\n * console.log(`Found ${history.data.length} transactions`);\n * history.data.forEach(tx => {\n *   console.log(`${tx.signature}: ${tx.balanceChanges.length} balance changes`);\n * });\n *\n * // Paginate to older transactions\n * if (history.pagination.hasMore) {\n *   const olderTxs = await helius.wallet.getHistory({\n *     wallet: \"86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY\",\n *     before: history.pagination.nextCursor,\n *     limit: 50\n *   });\n * }\n * ```\n */\nexport const getHistory = async (\n  apiKey: string,\n  params: GetHistoryRequest,\n  userAgent?: string\n): Promise<GetHistoryResponse> => {\n  const { wallet, limit, before, after, type, tokenAccounts } = params;\n\n  const queryParams = {\n    \"api-key\": apiKey,\n    limit,\n    before,\n    after,\n    type,\n    tokenAccounts,\n  };\n\n  const url = `${BASE_URL}/${wallet}/history${buildQueryString(queryParams)}`;\n\n  const response = await fetch(url, {\n    method: \"GET\",\n    headers: getHeaders(false, userAgent),\n  });\n\n  return handleResponse<GetHistoryResponse>(response);\n};\n"],"names":["BASE_URL","buildQueryString","getHeaders","handleResponse"],"mappings":";;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDG;AACI,MAAM,UAAU,GAAG,OACxB,MAAc,EACd,MAAyB,EACzB,SAAkB,KACa;AAC/B,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,MAAM;AAEpE,IAAA,MAAM,WAAW,GAAG;AAClB,QAAA,SAAS,EAAE,MAAM;QACjB,KAAK;QACL,MAAM;QACN,KAAK;QACL,IAAI;QACJ,aAAa;KACd;AAED,IAAA,MAAM,GAAG,GAAG,CAAA,EAAGA,cAAQ,CAAA,CAAA,EAAI,MAAM,CAAA,QAAA,EAAWC,sBAAgB,CAAC,WAAW,CAAC,CAAA,CAAE;AAE3E,IAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,OAAO,EAAEC,gBAAU,CAAC,KAAK,EAAE,SAAS,CAAC;AACtC,KAAA,CAAC;AAEF,IAAA,OAAOC,oBAAc,CAAqB,QAAQ,CAAC;AACrD;;;;"}