@@ -2,7 +2,12 @@ import { AbiFunction, Address, Hex, Secp256k1, Value } from 'ox'
22import { getTransactionCount } from 'viem/actions'
33import { describe , expect , test } from 'vitest'
44import { chain , client , fundAddress } from '../../test/tempo/config.js'
5- import { KeyAuthorization , MultisigConfig , SignatureEnvelope } from './index.js'
5+ import {
6+ KeyAuthorization ,
7+ MultisigConfig ,
8+ SignatureEnvelope ,
9+ TransactionRequest ,
10+ } from './index.js'
611import * as Transaction from './Transaction.js'
712import * as TransactionReceipt from './TransactionReceipt.js'
813import * as TxEnvelopeTempo from './TxEnvelopeTempo.js'
@@ -135,6 +140,51 @@ describe('behavior: multisig (TIP-1061)', () => {
135140 } )
136141 }
137142
143+ test ( 'behavior: fills a multisig simulation' , async ( ) => {
144+ const { account, initialConfig, ownerKeys } = setup ( {
145+ count : 2 ,
146+ threshold : 2 ,
147+ } )
148+ await fundAddress ( client , { address : account } )
149+
150+ const request = TransactionRequest . toRpc ( {
151+ calls : [ { to : '0x0000000000000000000000000000000000000000' } ] ,
152+ from : account ,
153+ multisigSimulation : {
154+ account,
155+ approvals : ownerKeys . map ( ( owner ) => ( {
156+ keyType : 'secp256k1' ,
157+ owner : owner . address ,
158+ type : 'primitive' ,
159+ } ) ) ,
160+ config : initialConfig ,
161+ } ,
162+ } )
163+ expect ( request . multisigSimulation ?. config ) . toBeTypeOf ( 'string' )
164+
165+ const response = await client . request ( {
166+ method : 'eth_fillTransaction' ,
167+ params : [ request as never ] ,
168+ } )
169+ const transaction = TransactionRequest . fromRpc (
170+ response . tx as TransactionRequest . Rpc ,
171+ )
172+
173+ expect ( Hex . validate ( response . raw ) ) . toBe ( true )
174+ expect ( transaction . calls ) . toHaveLength ( 1 )
175+ expect ( transaction . calls ?. [ 0 ] ?. to ) . toBe (
176+ '0x0000000000000000000000000000000000000000' ,
177+ )
178+ expect ( transaction . chainId ) . toBe ( chainId )
179+ expect ( transaction . feeToken ) . toBeNull ( )
180+ expect ( transaction . gas ) . toBeGreaterThan ( 0n )
181+ expect ( transaction . maxFeePerGas ) . toBeTypeOf ( 'bigint' )
182+ expect ( transaction . maxPriorityFeePerGas ) . toBeTypeOf ( 'bigint' )
183+ expect ( transaction . nonce ?? 0n ) . toBe ( 0n )
184+ expect ( transaction . nonceKey ?? 0n ) . toBe ( 0n )
185+ expect ( transaction . type ) . toBe ( 'tempo' )
186+ } )
187+
138188 test ( 'examples: bootstrap, initialized, and configuration rotation' , async ( ) => {
139189 const { account, initialConfig, ownerKeys } = setup ( {
140190 count : 3 ,
0 commit comments