Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • NomadContext
    • BridgeContext

Index

Constructors

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

Properties

_blacklist: Set<number>
bridges: Map<string, BridgeContracts>
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
  • Returns NomadLocator

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

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

Methods

  • blacklist(): Set<number>
  • Returns Set<number>

  • checkHome(nameOrDomain: string | number): Promise<void>
  • Parameters

    • nameOrDomain: string | number

    Returns Promise<void>

  • checkHomes(networks: (string | number)[]): Promise<void>
  • Parameters

    • networks: (string | number)[]

    Returns 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
  • Get the {@link CoreContracts} for a given domain (or undefined)

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns undefined | CoreContracts

    a {@link CoreContracts} object (or undefined)

  • 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)

  • governorCore(): Promise<CoreContracts>
  • 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

  • mustGetCore(nameOrDomain: string | number): CoreContracts
  • Get the {@link CoreContracts} for a given domain (or throw an error)

    throws

    if no {@link CoreContracts} object exists on that domain.

    Parameters

    • nameOrDomain: string | number

      A domain name or number.

    Returns CoreContracts

    a {@link CoreContracts} object

  • 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

  • resolveCanonicalIdentifier(nameOrDomain: string | number, representation: string): Promise<TokenIdentifier>
  • Resolve the canonical domain and identifier for a representation on some domain.

    throws

    If the token is unknown to the bridge router on its domain.

    Parameters

    • nameOrDomain: string | number

      The domain hosting the representation

    • representation: string

      The address of the representation on that domain

    Returns Promise<TokenIdentifier>

    The domain and ID for the canonical token

  • resolveCanonicalToken(nameOrDomain: string | number, representation: string): Promise<BridgeToken>
  • Resolve an interface for the canonical token corresponding to a representation on some domain.

    throws

    If the token is unknown to the bridge router on its domain.

    Parameters

    • nameOrDomain: string | number

      The domain hosting the representation

    • representation: string

      The address of the representation on that domain

    Returns Promise<BridgeToken>

    An interface for that token

  • 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

  • resolveRepresentation(nameOrDomain: string | number, token: TokenIdentifier): Promise<undefined | BridgeToken>
  • Resolve the local representation of a token on some domain. E.g. find the deployed Celo address of Ethereum's Sushi Token.

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

    Parameters

    • nameOrDomain: string | number

      the target domain, which hosts the representation

    • token: TokenIdentifier

      The token to locate on that domain

    Returns Promise<undefined | BridgeToken>

    An interface for that token (if it has been deployed on that domain)

  • Resolve the local representation of a token on ALL known domain. E.g. find ALL deployed addresses of Ethereum's Sushi Token, on all registered domains.

    WARNING: do not hold references to these contracts, as they will not be reconnected in the event the chain connection changes.

    Parameters

    Returns Promise<ResolvedTokenInfo>

    A ResolvedTokenInfo object with representation addresses

  • send(from: string | number, to: string | number, token: TokenIdentifier, amount: BigNumberish, recipient: string, enableFast?: boolean, overrides?: Overrides): Promise<TransferMessage>
  • Send tokens from one domain to another. Approves the bridge if necessary.

    throws

    On missing signers, missing tokens, tx issues, etc.

    Parameters

    • from: string | number

      The domain to send from

    • to: string | number

      The domain to send to

    • token: TokenIdentifier

      The canonical token to send (details from originating chain)

    • amount: BigNumberish

      The amount (in smallest unit) to send

    • recipient: string

      The identifier to send to on the to domain

    • enableFast: boolean = false

      TRUE to enable fast liquidity; FALSE to require no fast liquidity

    • overrides: Overrides = {}

      Any tx overrides (e.g. gas price)

    Returns Promise<TransferMessage>

    a TransferMessage object representing the in-flight transfer

  • sendNative(from: string | number, to: string | number, amount: BigNumberish, recipient: string, enableFast?: boolean, overrides?: PayableOverrides): Promise<TransferMessage>
  • Send a chain's native asset from one chain to another using the EthHelper contract.

    throws

    On missing signers, tx issues, etc.

    Parameters

    • from: string | number

      The domain to send from

    • to: string | number

      The domain to send to

    • amount: BigNumberish

      The amount (in smallest unit) to send

    • recipient: string

      The identifier to send to on the to domain

    • enableFast: boolean = false

      TRUE to enable fast liquidity; FALSE to require no fast liquidity

    • overrides: PayableOverrides = {}

      Any tx overrides (e.g. gas price)

    Returns Promise<TransferMessage>

    a TransferMessage object representing the in-flight transfer

  • 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