Skip to content

Commit 0b1431a

Browse files
authored
feat: add identity and reputation registries to app registry dapp (#4559)
### Description Exports typings for identity and reputation registry. The motivation being to add bot review, only the reputation facet is exposed in dapp. ### Changes - update build-contract-types.sh to generate typings for IIdentityRegistry and IReputationRegistry - create IIdentityRegistryShim and IReputationRegistryShim following existing shim patterns - add identity and reputation properties to AppRegistryDapp class - initialize both registries in constructor using appRegistry diamond address - all registries point to same AppRegistry diamond, exposing different facets ### Checklist - [x] Tests added where required - [x] Documentation updated where applicable - [x] Changes adhere to the repository's contribution guidelines
1 parent e739693 commit 0b1431a

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

packages/generated/scripts/build-contract-types.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TYPINGS_DIR="./dev/typings"
1111
# Run forge build in contracts directory (needs foundry.toml)
1212
(cd "$CONTRACTS_DIR" && forge build)
1313

14-
CONTRACT_INTERFACES="(IDiamond|IDiamondCut|IArchitect|Architect|ILegacyArchitect|MockLegacyArchitect|IProxyManager|IPausable|IEntitlementsManager|EntitlementsManager|IChannel|Channels|IRoles|Roles|IMulticall|IRuleEntitlement|IRuleEntitlementV2|IWalletLink|WalletLink|INodeRegistry|NodeRegistry|IOperatorRegistry|OperatorRegistry|IStreamRegistry|StreamRegistry|OwnableFacet|TokenPausableFacet|UserEntitlement|SpaceOwner|MockERC721A|MembershipFacet|IMembershipMetadata|Member|IBanning|IPricingModules|ICrossChainEntitlement|MockEntitlementGated|PrepayFacet|IERC721AQueryable|IEntitlementDataQueryable|PlatformRequirementsFacet|IERC721A|INodeOperator|ISpaceDelegation|IEntitlementChecker|IERC5267|ICreateSpace|IDropFacet|DropFacet|ITownsPoints|ITipping|IReview|ITreasury|ISwapRouter|ISwapFacet|IAppRegistry|IAppAccount|ISimpleApp|ITownsApp|Towns|RewardsDistributionV2|MainnetDelegation|GuardianFacet|SubscriptionModuleFacet|IAppInstaller|IAppFactory)"
14+
CONTRACT_INTERFACES="(IDiamond|IDiamondCut|IArchitect|Architect|ILegacyArchitect|MockLegacyArchitect|IProxyManager|IPausable|IEntitlementsManager|EntitlementsManager|IChannel|Channels|IRoles|Roles|IMulticall|IRuleEntitlement|IRuleEntitlementV2|IWalletLink|WalletLink|INodeRegistry|NodeRegistry|IOperatorRegistry|OperatorRegistry|IStreamRegistry|StreamRegistry|OwnableFacet|TokenPausableFacet|UserEntitlement|SpaceOwner|MockERC721A|MembershipFacet|IMembershipMetadata|Member|IBanning|IPricingModules|ICrossChainEntitlement|MockEntitlementGated|PrepayFacet|IERC721AQueryable|IEntitlementDataQueryable|PlatformRequirementsFacet|IERC721A|INodeOperator|ISpaceDelegation|IEntitlementChecker|IERC5267|ICreateSpace|IDropFacet|DropFacet|ITownsPoints|ITipping|IReview|ITreasury|ISwapRouter|ISwapFacet|IAppRegistry|IAppAccount|ISimpleApp|ITownsApp|Towns|RewardsDistributionV2|MainnetDelegation|GuardianFacet|SubscriptionModuleFacet|IAppInstaller|IAppFactory|IIdentityRegistry|IReputationRegistry)"
1515

1616
# Clean typings to avoid stale factories/interfaces lingering between runs
1717
rm -rf "$TYPINGS_DIR"
@@ -20,7 +20,7 @@ yarn typechain --target=ethers-v5 "$CONTRACTS_DIR/out/**/?${CONTRACT_INTERFACES}
2020
# Clean abis to avoid stale abi files lingering between runs
2121
rm -rf "$ABI_DIR"
2222
mkdir -p "$ABI_DIR"
23-
cp -a $CONTRACTS_DIR/out/{Diamond,DiamondCutFacet,Architect,MockLegacyArchitect,ProxyManager,IPausable,EntitlementsManager,Channels,Roles,IMulticall,OwnableFacet,WalletLink,MockWalletLink,NodeRegistry,OperatorRegistry,StreamRegistry,TokenPausableFacet,IRuleEntitlement,UserEntitlement,SpaceOwner,MockERC721A,MembershipFacet,IMembershipMetadata,Member,MockRiverRegistry,IBanning,IPricingModules,ICrossChainEntitlement,MockCrossChainEntitlement,MockEntitlementGated,PrepayFacet,IERC721AQueryable,IEntitlementDataQueryable,PlatformRequirementsFacet,IERC721A,INodeOperator,ISpaceDelegation,IEntitlementChecker,IEntitlementGated,IERC5267,ICreateSpace,DropFacet,ITownsPoints,ITipping,IReview,ITreasury,ISwapRouter,ISwapFacet,IAppRegistry,IAppAccount,ISimpleApp,ITownsApp,Towns,RewardsDistributionV2,MainnetDelegation,GuardianFacet,SubscriptionModuleFacet,IAppInstaller,IAppFactory}.sol/*.abi.json "$ABI_DIR"
23+
cp -a $CONTRACTS_DIR/out/{Diamond,DiamondCutFacet,Architect,MockLegacyArchitect,ProxyManager,IPausable,EntitlementsManager,Channels,Roles,IMulticall,OwnableFacet,WalletLink,MockWalletLink,NodeRegistry,OperatorRegistry,StreamRegistry,TokenPausableFacet,IRuleEntitlement,UserEntitlement,SpaceOwner,MockERC721A,MembershipFacet,IMembershipMetadata,Member,MockRiverRegistry,IBanning,IPricingModules,ICrossChainEntitlement,MockCrossChainEntitlement,MockEntitlementGated,PrepayFacet,IERC721AQueryable,IEntitlementDataQueryable,PlatformRequirementsFacet,IERC721A,INodeOperator,ISpaceDelegation,IEntitlementChecker,IEntitlementGated,IERC5267,ICreateSpace,DropFacet,ITownsPoints,ITipping,IReview,ITreasury,ISwapRouter,ISwapFacet,IAppRegistry,IAppAccount,ISimpleApp,ITownsApp,Towns,RewardsDistributionV2,MainnetDelegation,GuardianFacet,SubscriptionModuleFacet,IAppInstaller,IAppFactory,IIdentityRegistry,IReputationRegistry}.sol/*.abi.json "$ABI_DIR"
2424

2525
# Copy the json abis to TS files for type inference
2626
for file in $ABI_DIR/*.abi.json; do

packages/web3/src/app-registry/AppRegistryDapp.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Address } from 'viem'
44
import { IAppRegistryShim } from './IAppRegistryShim'
55
import { IAppInstallerShim } from './IAppInstallerShim'
66
import { IAppFactoryShim } from './IAppFactoryShim'
7+
import { IReputationRegistryShim } from './IReputationRegistryShim'
78
import { SimpleAppShim } from './SimpleAppShim'
89
import type {
910
AppRegisteredEventObject,
@@ -27,6 +28,7 @@ export class AppRegistryDapp {
2728
public readonly registry: IAppRegistryShim
2829
public readonly installer: IAppInstallerShim
2930
public readonly factory: IAppFactoryShim
31+
public readonly reputation: IReputationRegistryShim
3032
private readonly provider: ethers.providers.Provider
3133

3234
constructor(config: BaseChainConfig, provider: ethers.providers.Provider) {
@@ -36,6 +38,7 @@ export class AppRegistryDapp {
3638
this.registry = new IAppRegistryShim(config.addresses.appRegistry, provider)
3739
this.installer = new IAppInstallerShim(config.addresses.appRegistry, provider)
3840
this.factory = new IAppFactoryShim(config.addresses.appRegistry, provider)
41+
this.reputation = new IReputationRegistryShim(config.addresses.appRegistry, provider)
3942
this.provider = provider
4043
}
4144

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ethers } from 'ethers'
2+
import { BaseContractShim } from '../BaseContractShim'
3+
import { IIdentityRegistry__factory } from '@towns-protocol/generated/dev/typings/factories/IIdentityRegistry__factory'
4+
5+
const { abi, connect } = IIdentityRegistry__factory
6+
7+
export class IIdentityRegistryShim extends BaseContractShim<typeof connect> {
8+
constructor(address: string, provider: ethers.providers.Provider) {
9+
super(address, provider, connect, abi)
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ethers } from 'ethers'
2+
import { BaseContractShim } from '../BaseContractShim'
3+
import { IReputationRegistry__factory } from '@towns-protocol/generated/dev/typings/factories/IReputationRegistry__factory'
4+
5+
const { abi, connect } = IReputationRegistry__factory
6+
7+
export class IReputationRegistryShim extends BaseContractShim<typeof connect> {
8+
constructor(address: string, provider: ethers.providers.Provider) {
9+
super(address, provider, connect, abi)
10+
}
11+
}

0 commit comments

Comments
 (0)