@@ -8,6 +8,10 @@ import dayjs from "dayjs"
8
8
import Client from "mina-signer"
9
9
10
10
import type { SignedTransaction } from "@mina-js/utils"
11
+ import type {
12
+ SignableData ,
13
+ ZkappCommand ,
14
+ } from "mina-signer/dist/node/mina-signer/src/types"
11
15
import type { IVaultService } from "./types"
12
16
13
17
export enum AuthorizationState {
@@ -74,9 +78,27 @@ export const createVaultService = (): IVaultService => {
74
78
const accounts = await getAccounts ( )
75
79
const publicKey = accounts ?. [ 0 ]
76
80
if ( ! publicKey ) throw new Error ( "Wallet is not initialized." )
77
- const validTransaction = signer . verifyTransaction ( sendable . input as never )
78
- if ( ! validTransaction ) throw new Error ( "Invalid transaction." )
79
81
const type = getTxType ( sendable . input as never )
82
+ const signedData : SignableData | ZkappCommand = sendable . input as any
83
+ const verifyTransactionParams =
84
+ typeof signedData === "object"
85
+ ? "feePayer" in signedData
86
+ ? {
87
+ signature : signedData . zkappCommand . feePayer . authorization ,
88
+ publicKey : signedData . zkappCommand . feePayer . body . publicKey ,
89
+ data : signedData ,
90
+ }
91
+ : {
92
+ signature : ( sendable as any ) . signature ,
93
+ publicKey : signedData . from ,
94
+ data : signedData ,
95
+ }
96
+ : undefined
97
+ if (
98
+ ! verifyTransactionParams ||
99
+ ! signer . verifyTransaction ( verifyTransactionParams )
100
+ )
101
+ throw new Error ( "Invalid transaction." )
80
102
const payload =
81
103
type === "zkapp"
82
104
? { input : sendable . input }
0 commit comments