Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NomadContext

The NomadContext manages connections to Nomad core and Bridge contracts. It inherits from the {@link MultiProvider}, and ensures that its contracts always use the latest registered providers and signers.

For convenience, we've pre-constructed contexts for mainnet and testnet deployments. These can be imported directly.

example

// Set up mainnet and then access contracts as below: let router = mainnet.mustGetBridge('celo').bridgeRouter;

Hierarchy

  • MultiProvider<config.Domain>
    • NomadContext

Index

Constructors

  • new NomadContext(environment?: string | NomadConfig): NomadContext

Properties

_blacklist: Set<number>
conf: NomadConfig
cores: Map<string, CoreContracts>
domains: Map<string, Domain>
providers: Map<string, Provider>
signers: Map<string, Signer>

Accessors

  • get domainNames(): string[]
  • Returns string[]

  • get domainNumbers(): number[]
  • Returns number[]

  • get governor(): NomadLocator
  • get missingProviders(): string[]
  • Returns string[]

  • get registeredDomains(): Readonly<T>[]
  • Returns Readonly<T>[]

Methods

  • blacklist(): Set<number>
  • checkHome(nameOrDomain: string | number): Promise<void>
  • checkHomes(networks: (string | number)[]): Promise<void>
  • clearSigners(): void
  • Clear all signers from all registered domains.

    Returns void

  • getAddress(nameOrDomain: string | number): Promise<undefined | string>
  • Resolves the address of a Signer on a domain (or undefined, if no Signer)

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns Promise<undefined | string>

    A Promise for the address of the registered signer (if any)

  • getConnection(nameOrDomain: string | number): undefined | Provider | Signer
  • Returns the most privileged connection registered to a domain. E.g. this function will attempt to return a Signer, then attempt to return the Provider (if no Signer is registered). If neither Signer nor Provider is registered for a domain, it will return undefined

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns undefined | Provider | Signer

    A Signer (if any), otherwise a Provider (if any), otherwise undefined

  • getCore(nameOrDomain: string | number): undefined | CoreContracts
  • getDomain(nameOrDomain: string | number): undefined | Domain
  • Get the registered {@link Domain} object (if any)

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns undefined | Domain

    A {@link Domain} (if the domain has been registered)

  • getProvider(nameOrDomain: string | number): undefined | Provider
  • Get the Provider associated with a doman (if any)

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns undefined | Provider

    The currently registered Provider (or none)

  • getReplicaFor(home: string | number, remote: string | number): undefined | Replica
  • Resolve the replica for the Home domain on the Remote domain (if any).

    WARNING: do not hold references to this contract, as it will not be reconnected in the event the chain connection changes.

    Parameters

    • home: string | number

      the sending domain

    • remote: string | number

      the receiving domain

    Returns undefined | Replica

    An interface for the Replica (if any)

  • getSigner(nameOrDomain: string | number): undefined | Signer
  • Return the signer registered to a domain (if any).

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns undefined | Signer

    The registered signer (or undefined)

  • Discovers the governor domain of this nomad deployment and returns the associated Core.

    Returns Promise<CoreContracts>

    The identifier of the governing domain

  • knownDomain(nameOrDomain: string | number): boolean
  • Check whether the {@link MultiProvider} is aware of a domain.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns boolean

    true if the {@link Domain} has been registered, else false.

  • mustGetConnection(nameOrDomain: string | number): Provider | Signer
  • Get the Connection associated with a doman (or error)

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns Provider | Signer

    A Signer

  • mustGetDomain(nameOrDomain: string | number): Domain
  • Get the registered {@link Domain} object (or error)

    throws

    if the domain has not been registered

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns Domain

    A {@link Domain}

  • mustGetProvider(nameOrDomain: string | number): Provider
  • Get the Provider associated with a doman (or error)

    throws

    If no provider has been registered for the specified domain

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns Provider

    A Provider

  • mustGetReplicaFor(home: string | number, remote: string | number): Replica
  • Resolve the replica for the Home domain on the Remote domain (or throws).

    WARNING: do not hold references to this contract, as it will not be reconnected in the event the chain connection changes.

    throws

    If no replica is found.

    Parameters

    • home: string | number

      the sending domain

    • remote: string | number

      the receiving domain

    Returns Replica

    An interface for the Replica

  • mustGetSigner(nameOrDomain: string | number): Signer
  • Get the Signer associated with a doman (or error)

    throws

    If no provider has been registered for the specified domain

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns Signer

    A Signer

  • reconnect(nameOrDomain: string | number): void
  • Ensure that the contracts on a given domain are connected to the currently-registered signer or provider.

    Parameters

    • nameOrDomain: string | number

    Returns void

  • registerDomain(domain: Domain): void
  • Resgister a domain with the MultiProvider. This allows the multiprovider to resolves tha domain info, and reference it by name or number.

    Parameters

    • domain: Domain

      The Domain object to register.

    Returns void

  • registerProvider(nameOrDomain: string | number, provider: Provider): void
  • Register an ethers Provider for a specified domain.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    • provider: Provider

      An ethers Provider to be used by requests to that domain.

    Returns void

  • registerRpcProvider(nameOrDomain: string | number, rpc: string): void
  • Shortcut to register a provider by its HTTP RPC URL.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    • rpc: string

      The HTTP RPC Url

    Returns void

  • registerSigner(nameOrDomain: string | number, signer: Signer): void
  • Register an ethers Signer for a specified domain.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    • signer: Signer

      An ethers Signer to be used by requests to that domain.

    Returns void

  • registerWalletSigner(nameOrDomain: string | number, privkey: string): void
  • A shortcut for registering a basic local privkey signer on a domain.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    • privkey: string

      A private key string passed to ethers.Wallet

    Returns void

  • resolveDomain(nameOrDomain: string | number): number
  • Resolve a domain name (or number) to the canonical number.

    This function is used extensively to disambiguate domains.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns number

    The canonical domain number.

  • resolveDomainName(nameOrDomain: string | number): string
  • Resolve the name of a registered {@link Domain}, from its name or number.

    Similar to resolveDomain.

    throws

    If the domain is unknown

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns string

    The name

  • unregisterSigner(nameOrDomain: string | number): void
  • Remove the registered ethers Signer from a domain. This function will attempt to preserve any Provider that was previously connected to this domain.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns void

Generated using TypeDoc