Skip to content

SignatureEnvelope.sortMultisigApprovals

Orders native multisig owner approvals into the strictly-ascending recovered-owner order the Tempo node requires for the multisig signatures array (the node enforces "recovered owners must be strictly ascending").

Each approval is signed over the multisig owner approval digest (MultisigConfig.getSignPayload), so the signer of every approval is recovered against that digest and the list is sorted by the recovered owner address. Works for any owner key type (secp256k1, p256, webAuthn, keychain).

Imports

Named
import { SignatureEnvelope } from 'ox/tempo'

Examples

import { Secp256k1 } from 'ox'
import { MultisigConfig, SignatureEnvelope, TxEnvelopeTempo } from 'ox/tempo'
 
const config = MultisigConfig.from({
  threshold: 2,
  owners: [
    { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
    { owner: '0x2222222222222222222222222222222222222222', weight: 1 },
  ],
})
const configId = MultisigConfig.toId(config)
const account = MultisigConfig.getAddress({ configId })
 
const tx = TxEnvelopeTempo.from({ chainId: 1, calls: [] })
const payload = TxEnvelopeTempo.getSignPayload(tx)
const digest = MultisigConfig.getSignPayload({ payload, account, configId })
 
const privateKeys = [Secp256k1.randomPrivateKey(), Secp256k1.randomPrivateKey()]
const signatures = privateKeys.map((privateKey) =>
  SignatureEnvelope.from(Secp256k1.sign({ payload: digest, privateKey })),
)
 
const ordered = SignatureEnvelope.sortMultisigApprovals({ 
  account, 
  configId, 
  payload, 
  signatures, 
})

Definition

function sortMultisigApprovals(
  value: sortMultisigApprovals.Value,
): readonly SignatureEnvelope[]

Source: src/tempo/SignatureEnvelope.ts

Parameters

value

  • Type: sortMultisigApprovals.Value

The approval ordering parameters.

value.account

  • Type: abitype_Address

The native multisig account address.

value.configId

  • Type: 0x${string}

The permanent config ID.

value.payload

  • Type: 0x${string} | Uint8Array

The inner transaction sign payload (tx.signature_hash()).

value.signatures

  • Type: readonly SignatureEnvelope[]

The primitive owner approvals to order.

Return Type

The owner approvals ordered ascending by recovered owner address.

readonly SignatureEnvelope[]