Skip to content

Commit

Permalink
update stellar utils
Browse files Browse the repository at this point in the history
  • Loading branch information
shan57blocks committed Jan 9, 2025
1 parent 0eca8cf commit c46ae8e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
12 changes: 12 additions & 0 deletions packages/huma-shared/src/services/CampaignService.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/huma-shared/src/stellar/index.ts
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 2 additions & 0 deletions packages/huma-shared/src/stellar/metadata/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './mainnet'
export * from './testnet'
1 change: 1 addition & 0 deletions packages/huma-shared/src/stellar/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './metadata'
1 change: 1 addition & 0 deletions packages/huma-shared/src/stellar/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './poolUtils'
23 changes: 23 additions & 0 deletions packages/huma-shared/src/stellar/utils/poolUtils.ts
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Campaign } from '@huma-finance/shared'
import { StellarCampaign } from '@huma-finance/shared'

export type StellarPoolState = {
poolAddress: string
Expand Down Expand Up @@ -36,5 +36,5 @@ export type StellarPoolState = {
protocolIncomeWithdrawn: string
poolOwnerIncomeWithdrawn: string
}
campaign?: Campaign
campaign?: StellarCampaign
}

0 comments on commit c46ae8e

Please sign in to comment.