// Update broadcaster (time-delay workflow): pass new address and current broadcaster to replace
async function updateBroadcaster(newBroadcaster: Address, currentBroadcaster: Address) {
try {
const result = await secureOwnable.updateBroadcasterRequest(
newBroadcaster,
currentBroadcaster,
{ from: account.address }
)
console.log('Broadcaster update requested:', result.hash)
const receipt = await publicClient.waitForTransactionReceipt({ hash: result.hash })
if (receipt.status === 'success') console.log('β
Broadcaster update successful')
} catch (error) {
console.error('Broadcaster update failed:', error instanceof Error ? error.message : error)
}
}
// Update recovery: requires signed meta-transaction (owner signs, broadcaster submits)
async function updateRecovery(signedMetaTx: MetaTransaction) {
try {
const result = await secureOwnable.updateRecoveryRequestAndApprove(
signedMetaTx,
{ from: broadcasterAddress }
)
console.log('Recovery update completed:', result.hash)
} catch (error) {
console.error('Recovery update failed:', error instanceof Error ? error.message : error)
}
}
// Update time lock period: requires signed meta-transaction
async function updateTimeLock(signedMetaTx: MetaTransaction) {
try {
const result = await secureOwnable.updateTimeLockRequestAndApprove(
signedMetaTx,
{ from: broadcasterAddress }
)
console.log('Time lock update completed:', result.hash)
const updatedPeriod = await secureOwnable.getTimeLockPeriodSec()
console.log('New time lock period:', updatedPeriod, 'seconds')
} catch (error) {
console.error('Time lock update failed:', error instanceof Error ? error.message : error)
}
}
## π **RuntimeRBAC Examples**
### **Role Management**
```typescript
// Get role information
async function getRoleInfo(roleHash: string) {
try {
const role = await runtimeRBAC.getRole(roleHash)
console.log('Role information:', {
name: role.roleName,
hash: role.roleHashReturn,
maxWallets: role.maxWallets,
walletCount: role.walletCount,
isProtected: role.isProtected
})
return role
} catch (error) {
console.error('Failed to get role info:', error.message)
}
}
// Check role membership
async function checkRoleMembership(roleHash: string, account: Address) {
try {
const hasRole = await runtimeRBAC.hasRole(roleHash, account)
console.log(`Account ${account} has role ${roleHash}:`, hasRole)
return hasRole
} catch (error) {
console.error('Failed to check role membership:', error.message)
}
}
// Get authorized wallets in a role
async function getAuthorizedWallets(roleHash: string) {
try {
const wallets = await runtimeRBAC.getAuthorizedWallets(roleHash)
console.log(`Authorized wallets in role ${roleHash}:`, wallets)
return wallets
} catch (error) {
console.error('Failed to get authorized wallets in role:', error.message)
}
}
// Get roles for a wallet
async function getWalletRoles(wallet: Address) {
try {
const roles = await runtimeRBAC.getWalletRoles(wallet)
console.log(`Roles for wallet ${wallet}:`, roles)
return roles
} catch (error) {
console.error('Failed to get wallet roles:', error.message)
}
}
// Get supported roles
async function getSupportedRoles() {
try {
const roles = await runtimeRBAC.getSupportedRoles()
console.log('Supported roles:', roles)
return roles
} catch (error) {
console.error('Failed to get supported roles:', error.message)
}
}
// Usage
await getRoleInfo('0x...') // role hash
await checkRoleMembership('0x...', '0x...') // role hash, account
await getAuthorizedWallets('0x...') // role hash
await getWalletRoles('0x...') // wallet address
await getSupportedRoles()