Class BundleAbstract

Bundle is an alternate executor that collects collects messages to broadcast as a single transaction in order to execute them simultaneously. For that, it uses the API of its parent Agent. You can use it in scripts with: await agent.bundle().wrap(async bundle=>{ client.as(bundle).exec(...) })

Hierarchy

Implements

Constructors

  • Parameters

    • agent: Agent

      The agent that will execute the batched transaction.

    • Optional callback: ((bundle) => unknown)

      Evaluating this defines the contents of the bundle.

        • (bundle): unknown
        • Evaluating this defines the contents of the bundle.

          Parameters

          Returns unknown

    Returns Bundle

Properties

Bundle: (new (agent) => Bundle) = ...

The Bundle subclass to use.

Type declaration

    • new (agent): Bundle
    • Bundle class to use when creating a bundle inside a bundle.

      Parameters

      Returns Bundle

      Default

      self
      
agent: Agent

The agent that will execute the batched transaction.

callback?: ((bundle) => unknown)

Type declaration

    • (bundle): unknown
    • Evaluating this defines the contents of the bundle.

      Parameters

      Returns unknown

depth: number = 0

Nested bundles are flattened, this counts the depth.

id: number = 0

Next message id.

msgs: any[] = []

Messages in this bundle, unencrypted.

Accessors

  • get address(): undefined | string
  • The address from which transactions are signed and sent.

    Returns undefined | string

  • get balance(): Promise<string>
  • Disallowed in bundle - do it beforehand or afterwards.

    Returns Promise<string>

  • get defaultDenom(): string
  • The default denomination in which the agent operates.

    Returns string

  • get getClient(): (<C>($C, address?, codeHash?, ...args) => C)
  • Returns (<C>($C, address?, codeHash?, ...args) => C)

      • <C>($C, address?, codeHash?, ...args): C
      • Get a client instance for talking to a specific smart contract as this executor.

        Type Parameters

        Parameters

        • $C: ClientClass<C>
        • Optional address: string
        • Optional codeHash: string
        • Rest ...args: unknown[]

        Returns C

  • get getUploader(): (<U>($U, options?) => U)
  • Returns (<U>($U, options?) => U)

      • <U>($U, options?): U
      • Get an uploader instance which performs code uploads and optionally caches them.

        Type Parameters

        Parameters

        Returns U

  • get height(): Promise<number>
  • Disallowed in bundle - do it beforehand or afterwards.

    Returns Promise<number>

  • get nextBlock(): Promise<number>
  • Disallowed in bundle - do it beforehand or afterwards.

    Returns Promise<number>

  • get ready(): Promise<this>
  • Complete the asynchronous initialization of this Agent.

    Returns Promise<this>

Methods

  • This doesnt change over time so it's allowed when building bundles.

    Parameters

    • address: string
    • Optional codeHash: string

    Returns Promise<string>

  • Disallowed in bundle - do it beforehand or afterwards.

    Parameters

    • denom: string

    Returns Promise<string>

  • This doesnt change over time so it's allowed when building bundles.

    Parameters

    • address: string

    Returns Promise<string>

  • This doesnt change over time so it's allowed when building bundles.

    Parameters

    • address: string | number

    Returns Promise<string>

  • This doesnt change over time so it's allowed when building bundles.

    Parameters

    • address: string

    Returns Promise<string>

  • Add an init message to the bundle.

    Type Parameters

    Parameters

    Returns Promise<{
        address: string;
        chainId: string;
        codeHash: string;
        initBy: undefined | string;
        label: string;
    }>

    the unmodified input.

    Example

    await agent.instantiate(template.define({ label, initMsg })
    
  • Add multiple init messages to the bundle.

    Type Parameters

    Parameters

    • inputs: C

    Returns Promise<C>

    the unmodified inputs.

    Example

    await agent.bundle().wrap(async bundle=>{
    await bundle.instantiateMany(template.instances({
    One: { label, initMsg },
    Two: { label, initMsg },
    }))
    await agent.instantiateMany({
    One: template1.instance({ label, initMsg }),
    Two: template2.instance({ label, initMsg }),
    })
    })
  • Queries are disallowed in the middle of a bundle because even though the bundle API is structured as multiple function calls, the bundle is ultimately submitted as a single transaction and it doesn't make sense to query state in the middle of that.

    Type Parameters

    • U

    Parameters

    Returns Promise<never>

  • Either submit or save the bundle.

    Parameters

    • opts: string | ExecOpts = ""
    • save: boolean = false

    Returns Promise<any>

  • Save a bundle for manual broadcast.

    Parameters

    • Optional name: string

    Returns Promise<unknown>

  • Disallowed in bundle - do it beforehand or afterwards.

    Parameters

    Returns Promise<unknown>

  • Disallowed in bundle - do it beforehand or afterwards.

    Parameters

    Returns Promise<unknown>

  • Broadcast a bundle to the chain.

    Parameters

    • Optional memo: string

    Returns Promise<unknown>

  • Uploads are disallowed in the middle of a bundle because it's easy to go over the max request size, and difficult to know what that is in advance.

    Parameters

    • data: Uint8Array
    • Optional meta: Partial<Uploadable>

    Returns Promise<never>

  • Uploads are disallowed in the middle of a bundle because it's easy to go over the max request size, and difficult to know what that is in advance.

    Parameters

    Returns Promise<never>

Generated using TypeDoc