Class DeployableTargetWithRBAC<Payload, ABI>

A minimal RBAC implementation that offers MANAGER and ADMIN roles, and Budgets and allowlists support this auth scheme

DeployableTargetWithRBAC

Type Parameters

  • Payload
  • ABI extends Abi

Hierarchy (view full)

Constructors

Properties

bases: Record<number, `0x${string}`> = {}

A static property representing a map of stringified chain ID's to the address of the base implementation on chain, used when cloning base contracts.

registryType: RegistryType = RegistryType.ACTION

The target's registry type.

_isBase: boolean = true

A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.

abi: ABI
_payload: undefined | Payload

The deployable payload used either for contract construction or initialization

_config: Config
_address: undefined | `0x${string}`

The internally managed address for this contract

_account?: Account

If it exists, Viem Local Account, if in a Node environment

Accessors

  • get bases(): Record<number, `0x${string}`>
  • A getter that will return the base implementation's static addresses by numerical chain ID

    Returns Record<number, `0x${string}`>

  • get address(): undefined | `0x${string}`
  • A getter returning this contract's deployed address, if it exists.

    Returns undefined | `0x${string}`

Methods

  • Set the authorized status of the given accounts The mechanism for managing authorization is left to the implementing contract

    Parameters

    • addresses: `0x${string}`[]

      The accounts to authorize or deauthorize

    • allowed: boolean[]

      The authorization status for the given accounts

    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<void>

  • Set the authorized status of the given accounts The mechanism for managing authorization is left to the implementing contract

    Parameters

    • addresses: `0x${string}`[]

      The accounts to authorize or deauthorize

    • allowed: boolean[]

      The authorization status for the given accounts

    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<{
        hash: `0x${string}`;
        result: void;
    }>

  • Grant permissions for a user on the rbac.

    Parameters

    • address: `0x${string}`
    • role: Roles
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<void>

    await rbac.grantRoles('0xfoo', Roles.MANAGER)
    
  • Grant permissions for a user on the rbac.

    Parameters

    • address: `0x${string}`
    • role: Roles
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<{
        hash: `0x${string}`;
        result: void;
    }>

    await rbac.grantRoles('0xfoo', Roles.MANAGER)
    
  • Revoke permissions for a user on the rbac.

    Parameters

    • address: `0x${string}`
    • role: Roles
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<void>

    await rbac.revokeRoles('0xfoo', Roles.MANAGER)
    
  • Revoke permissions for a user on the rbac.

    Parameters

    • address: `0x${string}`
    • role: Roles
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<{
        hash: `0x${string}`;
        result: void;
    }>

    await rbac.revokeRoles('0xfoo', Roles.MANAGER)
    
  • Grant many accounts permissions on the rbac.

    Parameters

    • addresses: `0x${string}`[]
    • roles: Roles[]
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<void>

    await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
    
  • Grant many accounts permissions on the rbac.

    Parameters

    • addresses: `0x${string}`[]
    • roles: Roles[]
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<{
        hash: `0x${string}`;
        result: void;
    }>

    await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
    
  • Revoke many accounts' permissions on the rbac.

    Parameters

    • addresses: `0x${string}`[]
    • roles: Roles[]
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<void>

    await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
    
  • Revoke many accounts' permissions on the rbac.

    Parameters

    • addresses: `0x${string}`[]
    • roles: Roles[]
    • Optionalparams: Partial<Omit<UnionCompute<UnionStrictOmit<SimulateContractParameters<Abi, string, readonly unknown[], Chain, Chain, (`0x${string}` | Account)>, "chain">> & ChainIdParameter<Config, number> & ConnectorParameter,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<{
        hash: `0x${string}`;
        result: void;
    }>

    await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
    
  • Return an array of the roles assigned to the given account.

    Parameters

    • account: `0x${string}`
    • Optionalparams: Partial<Omit<ReadContractParameters,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<Roles[]>

    (await rbac.rolesOf(0xfoo)).includes(Roles.ADMIN)
    
  • Returns whether given account has any of the provided roles bitmap.

    Parameters

    • account: `0x${string}`
    • roles: Roles
    • Optionalparams: Partial<Omit<ReadContractParameters,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<boolean>

    await rbac.hasAnyRole(0xfoo, Roles.ADMIN | Roles.MANAGER)
    
  • Returns whether given account has all of the provided roles bitmap.

    Parameters

    • account: `0x${string}`
    • roles: Roles
    • Optionalparams: Partial<Omit<ReadContractParameters,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<boolean>

    await rbac.hasAllRoles(0xfoo, Roles.ADMIN | Roles.MANAGER)
    
  • Check if the given account is authorized to use the rbac

    Parameters

    • account: `0x${string}`
    • Optionalparams: Partial<Omit<ReadContractParameters,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<boolean>

    • True if the account is authorized
  • Check if the contract supports the given interface

    Parameters

    • interfaceId: `0x${string}`

      The interface identifier

    • Optionalparams: Partial<Omit<ReadContractParameters,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<boolean>

    • True if the contract supports the interface
  • Return a cloneable's unique identifier for downstream consumers to differentiate various targets All implementations must override this function

    Parameters

    • Optionalparams: Partial<Omit<ReadContractParameters,
          | "address"
          | "abi"
          | "functionName"
          | "args">>

    Returns Promise<`0x${string}`>

  • A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]. Accepts eventName and eventNames as optional parameters to narrow the returned log types.

    Type Parameters

    • event extends string
    • const abiEvent extends {
          name: event;
      } & AbiEvent = Extract<Extract<ABI[number], {
          type: "event";
      }>, {
          name: event;
      }>

    Parameters

    Returns Promise<GetLogsReturnType<abiEvent, abiEvent[]>>

    const logs = contract.getLogs({ eventName: 'EventName' })
    const logs = contract.getLogs({ eventNames: ['EventName'] })

    @public
    @async
    @template {ContractEvent} event
    @template {ExtractAbiEvent<
    ContractAbi,
    event
    >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]
    @param {?Omit<
    GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,
    'event' | 'events'
    > & {
    eventName?: event;
    eventNames?: event[];
    }} [params]
    @returns {Promise<GetLogsReturnType<abiEvent, abiEvent
  • A typed wrapper for wagmi.watchContractEvent

    Type Parameters

    • event extends string

    Parameters

    • cb: ((log: WatchContractEventOnLogsParameter<ABI, event, true>[number]) => unknown)
        • (log): unknown
        • Parameters

          • log: WatchContractEventOnLogsParameter<ABI, event, true>[number]

          Returns unknown

    • Optionalparams: Partial<Omit<UnionCompute<WatchContractEventParameters<ABI, event, undefined, WebSocketTransport> & ChainIdParameter<Config, number> & SyncConnectedChainParameter>, "address" | "abi">> & {
          eventName?: event;
      }

    Returns (() => void)

      • (): void
      • Returns void

  • Protected

    Internal function to attach the connected account to write methods to avoid manually passing in an account each call.

    Parameters

    • Optionalaccount: Account

    Returns {
        account: Account;
    } | {
        account: undefined;
    }