-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to query for all contracts owned by an address
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ?? [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters