@@ -5,12 +5,7 @@ import type { Hex } from 'ox'
55import { TxEnvelopeTempo } from 'ox/tempo'
66import { Handler } from 'tempo.ts/server'
77import { createClient , custom , encodeFunctionData , parseUnits } from 'viem'
8- import {
9- getTransactionReceipt ,
10- prepareTransactionRequest ,
11- sendCallsSync ,
12- signTransaction ,
13- } from 'viem/actions'
8+ import { getTransactionReceipt , prepareTransactionRequest , signTransaction } from 'viem/actions'
149import { Abis , Account , Actions , Addresses , Secp256k1 , Tick , Transaction } from 'viem/tempo'
1510import { beforeAll , describe , expect , test } from 'vp/test'
1611import * as Http from '~test/Http.js'
@@ -661,7 +656,6 @@ describe('tempo', () => {
661656 methods : [
662657 tempo_client ( {
663658 account : accounts [ 1 ] ,
664- mode : 'push' ,
665659 getClient : ( ) => client ,
666660 } ) ,
667661 ] ,
@@ -693,7 +687,7 @@ describe('tempo', () => {
693687 httpServer . close ( )
694688 } )
695689
696- test ( 'behavior: accepts hash when split transfers are out of order' , async ( ) => {
690+ test ( 'behavior: accepts transaction when split transfers are out of order' , async ( ) => {
697691 const httpServer = await Http . createServer ( async ( req , res ) => {
698692 const result = await Mppx_server . toNodeListener (
699693 server . charge ( {
@@ -720,35 +714,33 @@ describe('tempo', () => {
720714 const primaryAmount =
721715 BigInt ( challenge . request . amount ) - BigInt ( splits [ 0 ] ! . amount ) - BigInt ( splits [ 1 ] ! . amount )
722716
723- const calls = [
724- Actions . token . transfer . call ( {
725- amount : BigInt ( splits [ 1 ] ! . amount ) ,
726- to : splits [ 1 ] ! . recipient as Hex . Hex ,
727- token : challenge . request . currency as Hex . Hex ,
728- } ) ,
729- Actions . token . transfer . call ( {
730- amount : primaryAmount ,
731- to : challenge . request . recipient as Hex . Hex ,
732- token : challenge . request . currency as Hex . Hex ,
733- } ) ,
734- Actions . token . transfer . call ( {
735- amount : BigInt ( splits [ 0 ] ! . amount ) ,
736- to : splits [ 0 ] ! . recipient as Hex . Hex ,
737- token : challenge . request . currency as Hex . Hex ,
738- } ) ,
739- ]
740-
741- const { receipts } = await sendCallsSync ( client , {
742- account : accounts [ 1 ] ,
743- calls : calls as never ,
744- experimental_fallback : true ,
745- } )
746- const hash = receipts ?. [ 0 ] ?. transactionHash
747- if ( ! hash ) throw new Error ( 'No transaction receipt returned.' )
717+ const prepared = await prepareTransactionRequest ( client , {
718+ account : accounts [ 1 ] ! ,
719+ calls : [
720+ Actions . token . transfer . call ( {
721+ amount : BigInt ( splits [ 1 ] ! . amount ) ,
722+ to : splits [ 1 ] ! . recipient as Hex . Hex ,
723+ token : challenge . request . currency as Hex . Hex ,
724+ } ) ,
725+ Actions . token . transfer . call ( {
726+ amount : primaryAmount ,
727+ to : challenge . request . recipient as Hex . Hex ,
728+ token : challenge . request . currency as Hex . Hex ,
729+ } ) ,
730+ Actions . token . transfer . call ( {
731+ amount : BigInt ( splits [ 0 ] ! . amount ) ,
732+ to : splits [ 0 ] ! . recipient as Hex . Hex ,
733+ token : challenge . request . currency as Hex . Hex ,
734+ } ) ,
735+ ] ,
736+ nonceKey : 'expiring' ,
737+ } as never )
738+ prepared . gas = prepared . gas ! + 5_000n
739+ const signature = await signTransaction ( client , prepared as never )
748740
749741 const credential = Credential . from ( {
750742 challenge,
751- payload : { hash , type : 'hash ' as const } ,
743+ payload : { signature , type : 'transaction ' as const } ,
752744 } )
753745
754746 const authResponse = await fetch ( httpServer . url , {
0 commit comments