Skip to content

Commit

Permalink
added legacy flag to nft claims
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 8, 2024
1 parent 05ae189 commit 1313d25
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/formulas/formulas/contract/voting/daoVotingCw721Staked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const dao = makeSimpleContractFormula<string>({
type NftClaim = {
token_id: string
release_at: Expiration
legacy: boolean
}

export const nftClaims: ContractFormula<NftClaim[], { address: string }> = {
Expand All @@ -66,8 +67,16 @@ export const nftClaims: ContractFormula<NftClaim[], { address: string }> = {
throw new Error('missing `address`')
}

const legacyClaims =
(await get<NftClaim[]>(contractAddress, 'nft_claims', address)) ?? []
const legacyClaims = (
(await get<Omit<NftClaim, 'legacy'>[]>(
contractAddress,
'nft_claims',
address
)) ?? []
).map((claim) => ({
...claim,
legacy: true,
}))

const claims = Object.entries(
(await getTransformationMap<string, Expiration>(
Expand All @@ -78,6 +87,7 @@ export const nftClaims: ContractFormula<NftClaim[], { address: string }> = {
([token_id, release_at]): NftClaim => ({
token_id,
release_at,
legacy: false,
})
)

Expand Down
14 changes: 12 additions & 2 deletions src/formulas/formulas/contract/voting/daoVotingOnftStaked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const dao = makeSimpleContractFormula<string>({
type NftClaim = {
token_id: string
release_at: Expiration
legacy: boolean
}

export const nftClaims: ContractFormula<NftClaim[], { address: string }> = {
Expand All @@ -76,8 +77,16 @@ export const nftClaims: ContractFormula<NftClaim[], { address: string }> = {
throw new Error('missing `address`')
}

const legacyClaims =
(await get<NftClaim[]>(contractAddress, 'nft_claims', address)) ?? []
const legacyClaims = (
(await get<Omit<NftClaim, 'legacy'>[]>(
contractAddress,
'nft_claims',
address
)) ?? []
).map((claim) => ({
...claim,
legacy: true,
}))

const claims = Object.entries(
(await getTransformationMap<string, Expiration>(
Expand All @@ -88,6 +97,7 @@ export const nftClaims: ContractFormula<NftClaim[], { address: string }> = {
([token_id, release_at]): NftClaim => ({
token_id,
release_at,
legacy: false,
})
)

Expand Down

0 comments on commit 1313d25

Please sign in to comment.