diff --git a/packages/huma-shared/src/services/CampaignService.ts b/packages/huma-shared/src/services/CampaignService.ts index 609112e0..e785a395 100644 --- a/packages/huma-shared/src/services/CampaignService.ts +++ b/packages/huma-shared/src/services/CampaignService.ts @@ -1,6 +1,7 @@ import { gql } from 'graphql-request' import { SolanaChainEnum, SolanaPoolInfo } from '../solana' +import { StellarPoolInfo } from '../stellar' import { ChainEnum, NETWORK_TYPE } from '../utils/chain' import { configUtil } from '../utils/config' import { COMMON_ERROR_MESSAGE } from '../utils/const' @@ -40,6 +41,10 @@ export interface SolanaCampaign extends BaseCampaign { solanaPoolInfo: SolanaPoolInfo } +export interface StellarCampaign extends BaseCampaign { + stellarPoolInfo: StellarPoolInfo +} + export type CampaignGroup = { id: string name: string @@ -54,6 +59,13 @@ export type SolanaCampaignGroup = { partners: CampaignPartner[] } +export type StellarCampaignGroup = { + id: string + name: string + campaigns: StellarCampaign[] + partners: CampaignPartner[] +} + type CampaignPoints = { campaignId: string juniorTranchePoints: number diff --git a/packages/huma-shared/src/stellar/index.ts b/packages/huma-shared/src/stellar/index.ts index 885193c2..8381a2a1 100644 --- a/packages/huma-shared/src/stellar/index.ts +++ b/packages/huma-shared/src/stellar/index.ts @@ -1,4 +1,4 @@ export * from './chain' -export * from './metadata/testnet' -export * from './metadata/mainnet' -export * from './types/metadata' +export * from './metadata' +export * from './types' +export * from './utils' diff --git a/packages/huma-shared/src/stellar/metadata/index.ts b/packages/huma-shared/src/stellar/metadata/index.ts new file mode 100644 index 00000000..e89dc4a3 --- /dev/null +++ b/packages/huma-shared/src/stellar/metadata/index.ts @@ -0,0 +1,2 @@ +export * from './mainnet' +export * from './testnet' diff --git a/packages/huma-shared/src/stellar/types/index.ts b/packages/huma-shared/src/stellar/types/index.ts new file mode 100644 index 00000000..14021640 --- /dev/null +++ b/packages/huma-shared/src/stellar/types/index.ts @@ -0,0 +1 @@ +export * from './metadata' diff --git a/packages/huma-shared/src/stellar/utils/index.ts b/packages/huma-shared/src/stellar/utils/index.ts new file mode 100644 index 00000000..888d051d --- /dev/null +++ b/packages/huma-shared/src/stellar/utils/index.ts @@ -0,0 +1 @@ +export * from './poolUtils' diff --git a/packages/huma-shared/src/stellar/utils/poolUtils.ts b/packages/huma-shared/src/stellar/utils/poolUtils.ts new file mode 100644 index 00000000..4bab4e5c --- /dev/null +++ b/packages/huma-shared/src/stellar/utils/poolUtils.ts @@ -0,0 +1,23 @@ +import { StellarChainEnum } from '../chain' +import { STELLAR_CHAIN_POOLS_INFO } from '../types' + +export function getStellarPoolInfoForPoolAddress( + chainId: StellarChainEnum, + poolAddress: string, +) { + const poolsInfo = STELLAR_CHAIN_POOLS_INFO[chainId] + if (!poolsInfo) { + return null + } + + let foundPoolInfo = null + + for (const poolInfo of Object.values(poolsInfo)) { + if (poolInfo.pool.toLowerCase() === poolAddress.toLowerCase()) { + foundPoolInfo = poolInfo + break + } + } + + return foundPoolInfo +} diff --git a/packages/huma-web-shared/src/stellar/types/stellarPoolState.ts b/packages/huma-web-shared/src/stellar/types/stellarPoolState.ts index 8ce1da0e..6a77c9ac 100644 --- a/packages/huma-web-shared/src/stellar/types/stellarPoolState.ts +++ b/packages/huma-web-shared/src/stellar/types/stellarPoolState.ts @@ -1,4 +1,4 @@ -import { Campaign } from '@huma-finance/shared' +import { StellarCampaign } from '@huma-finance/shared' export type StellarPoolState = { poolAddress: string @@ -36,5 +36,5 @@ export type StellarPoolState = { protocolIncomeWithdrawn: string poolOwnerIncomeWithdrawn: string } - campaign?: Campaign + campaign?: StellarCampaign }