Skip to content

Commit

Permalink
add ability to query for all contracts owned by an address
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 13, 2024
1 parent 18fb3ff commit 0f4cc1e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/formulas/formulas/wallet/contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { WalletFormula } from '@/types'

/**
* Get all contracts with the cw-ownable owner set to this address.
*/
export const ownedBy: WalletFormula<
string[],
{
/**
* Optionally filter by code ID key.
*/
key?: string
}
> = {
compute: async ({
walletAddress,
args: { key },
getTransformationMatches,
getCodeIdsForKeys,
}) =>
(
await getTransformationMatches(
undefined,
'owner',
walletAddress,
key ? getCodeIdsForKeys(key) : undefined
)
)?.map(({ contractAddress }) => contractAddress) ?? [],
}
1 change: 1 addition & 0 deletions src/formulas/formulas/wallet/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * as bank from './bank'
export * as contract from './contract'
export * as daos from './daos'
export * as nft from './nft'
export * as polytone from './polytone'
Expand Down

0 comments on commit 0f4cc1e

Please sign in to comment.