Validates a config against an observed chain commitment.
(options: {
account: `0x${string}`
commitment: Hex.Hex
config: MultisigConfig.Config
})
| 779 | |
| 780 | /** Validates a config against an observed chain commitment. */ |
| 781 | function assertConfig(options: { |
| 782 | account: `0x${string}` |
| 783 | commitment: Hex.Hex |
| 784 | config: MultisigConfig.Config |
| 785 | }) { |
| 786 | const { account, commitment, config } = options |
| 787 | if ( |
| 788 | config.version === 0n && |
| 789 | MultisigConfig.getAddress(config, { |
| 790 | factory: Addresses.nativeMultisigFactory, |
| 791 | }).toLowerCase() !== account.toLowerCase() |
| 792 | ) |
| 793 | throw new RpcResponse.InvalidParamsError({ |
| 794 | message: 'Initial multisig config does not match the multisig account.', |
| 795 | }) |
| 796 | if (config.version === 0n && Hex.toBigInt(commitment) === 0n) return |
| 797 | if ( |
| 798 | commitment.toLowerCase() !== |
| 799 | MultisigConfig.getCommitment(config).toLowerCase() |
| 800 | ) |
| 801 | throw new RpcResponse.InvalidParamsError({ |
| 802 | message: `Multisig config does not match account ${account}.`, |
| 803 | }) |
| 804 | } |
| 805 | |
| 806 | /** Reads and validates a config commitment at one block. */ |
| 807 | async function validateConfig(options: { |