Skip to content

Commit

Permalink
fix: matching ipfs metadata string
Browse files Browse the repository at this point in the history
  • Loading branch information
filo87 committed Nov 12, 2024
1 parent 723e708 commit c1619eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/helpers/ipfsFetch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IPFS_NODE } from '../config'

export const cid = new RegExp(
'(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})$'
'(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})$',
'g'
)

export async function readIpfs<T extends Record<string, unknown>>(ipfsId: string): Promise<T> {
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/services/poolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ export class PoolService extends Pool {
return metadata.pool?.poolFees ?? []
}

public async getIpfsPoolFeeMetadata(): Promise<PoolIpfsMetadata['pool']['poolFees']> {
public async getIpfsPoolFeeMetadata(): Promise<Required<PoolIpfsMetadata['pool']>['poolFees']> {
if (!this.metadata) return logger.warn('No IPFS metadata')
const matchedMetadata = this.metadata.match(cid)
if (!matchedMetadata || matchedMetadata.length !== 1) throw new Error('Unable to read metadata')
const metadata = await readIpfs<PoolIpfsMetadata>(matchedMetadata[0])
return metadata.pool.poolFees
return metadata.pool.poolFees ?? []
}

public async getIpfsPoolFeeName(poolFeeId: string): Promise<string> {
Expand Down

0 comments on commit c1619eb

Please sign in to comment.