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

Config updates never change account, so the genesis config is the correct input even for post-update transactions.

Imports

Named
import { SignatureEnvelope } from 'ox/tempo'

Examples

import { Secp256k1 } from 'ox'
import { MultisigConfig, SignatureEnvelope, TxEnvelopeTempo } from 'ox/tempo'
 
const genesisConfig = MultisigConfig.from({
  threshold: 2,
  owners: [
    { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
    { owner: '0x2222222222222222222222222222222222222222', weight: 1 },
  ],
})
 
const tx = TxEnvelopeTempo.from({ chainId: 1, calls: [] })
const payload = TxEnvelopeTempo.getSignPayload(tx)
 
const privateKeys = [Secp256k1.randomPrivateKey(), Secp256k1.randomPrivateKey()]
const digest = MultisigConfig.getSignPayload({ payload, genesisConfig })
const signatures = privateKeys.map((privateKey) =>
  SignatureEnvelope.from(Secp256k1.sign({ payload: digest, privateKey })),
)
 
const ordered = SignatureEnvelope.sortMultisigApprovals({ 
  genesisConfig, 
  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.genesisConfig

  • Type: { salt?: 0x${string}; threshold: number; owners: readonly Owner[]; }

The initial multisig config (the bootstrap config that derived the permanent account). Used to derive the account automatically.

value.payload

  • Type: 0x${string} | Uint8Array

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

value.signatures

  • Type: readonly SignatureEnvelope[]

The owner approvals to order.

Return Type

The owner approvals ordered ascending by recovered owner address.

readonly SignatureEnvelope[]