Skip to content

Commit

Permalink
index hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 10, 2024
1 parent f05d935 commit 7303100
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/formulas/formulas/contract/external/cw4Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ export const admin = makeSimpleContractFormula<string | null>({
// Null if no admin exists.
fallback: null,
})

export const hooks = makeSimpleContractFormula<string[], { hooks: string[] }>({
transformation: 'hooks',
fallbackKeys: ['cw4-hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
10 changes: 10 additions & 0 deletions src/formulas/formulas/contract/staking/cw20Stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,13 @@ export const topStakers: ContractFormula<
}))
},
}

export const getHooks = makeSimpleContractFormula<
string[],
{ hooks: string[] }
>({
transformation: 'hooks',
fallbackKeys: ['hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
7 changes: 7 additions & 0 deletions src/formulas/formulas/contract/voting/daoVotingCw721Staked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,10 @@ export const ownersOfStakedNfts: ContractFormula<Record<string, string>> = {
)
},
}

export const hooks = makeSimpleContractFormula<string[], { hooks: string[] }>({
transformation: 'hooks',
fallbackKeys: ['hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
10 changes: 10 additions & 0 deletions src/formulas/formulas/contract/voting/daoVotingNativeStaked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,13 @@ export const topStakers: ContractFormula<Staker[]> = {
return stakers
},
}

export const getHooks = makeSimpleContractFormula<
string[],
{ hooks: string[] }
>({
transformation: 'hooks',
fallbackKeys: ['hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
6 changes: 6 additions & 0 deletions src/formulas/formulas/contract/voting/daoVotingOnftStaked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,9 @@ export const ownersOfStakedNfts: ContractFormula<Record<string, string>> = {
)
},
}
export const hooks = makeSimpleContractFormula<string[], { hooks: string[] }>({
transformation: 'hooks',
fallbackKeys: ['hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,10 @@ export const allVotersWithVotingPower: ContractFormula<
return voters
},
}

export const hooks = makeSimpleContractFormula<string[], { hooks: string[] }>({
transformation: 'hooks',
fallbackKeys: ['hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
10 changes: 10 additions & 0 deletions src/formulas/formulas/contract/voting/daoVotingTokenStaked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,13 @@ export const topStakers: ContractFormula<Staker[]> = {
return stakers
},
}

export const getHooks = makeSimpleContractFormula<
string[],
{ hooks: string[] }
>({
transformation: 'hooks',
fallbackKeys: ['hooks'],
fallback: { hooks: [] },
transform: (hooks) => ({ hooks }),
})
4 changes: 3 additions & 1 deletion src/transformers/transformers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ const owner: Transformer = {
getValue: (event) => event.valueJson.owner,
}

export default [info, ownership, owner]
const hooks: Transformer = makeTransformer([], 'hooks')

export default [info, ownership, owner, hooks]
5 changes: 3 additions & 2 deletions src/transformers/transformers/external/cw4Group.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { makeTransformerForMap } from '../../utils'
import { makeTransformer, makeTransformerForMap } from '../../utils'

const CODE_IDS_KEYS = ['cw4-group']

const member = makeTransformerForMap(CODE_IDS_KEYS, 'member', 'members')
const hooks = makeTransformer(CODE_IDS_KEYS, 'hooks', 'cw4-hooks')

export default [member]
export default [member, hooks]

0 comments on commit 7303100

Please sign in to comment.