Skip to content

Commit 97ef1d8

Browse files
committed
feat: make mina_signTransaction backward compatible
1 parent 8a4943d commit 97ef1d8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

apps/extension/src/background/handlers/web-provider.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import {
1616
// StorePrivateCredentialRequestParamsSchema,
1717
SwitchChainRequestParamsSchema,
1818
} from "@mina-js/providers"
19+
import {
20+
type TransactionOrZkAppCommandProperties,
21+
toNodeApiFormat,
22+
} from "@mina-js/utils"
1923
import { createMinaProvider } from "@palladco/web-provider"
2024
import { serializeError } from "serialize-error"
2125
import { z } from "zod"
@@ -176,7 +180,24 @@ export const minaSignTransaction: Handler = async ({ data }) => {
176180
const provider = await createMinaProvider()
177181
const payload = SignTransactionRequestParamsSchema.parse({
178182
method: "mina_signTransaction",
179-
params: data.params,
183+
params: data.params.map(
184+
(
185+
txData:
186+
| TransactionOrZkAppCommandProperties
187+
| {
188+
command: Parameters<typeof toNodeApiFormat>[0]
189+
},
190+
) => {
191+
// backward compatibility with the old feePayer input schema
192+
if ("command" in txData && "feePayer" in txData.command.feePayer) {
193+
return {
194+
...txData,
195+
command: toNodeApiFormat(txData.command),
196+
}
197+
}
198+
return txData
199+
},
200+
),
180201
context: data.context,
181202
})
182203
return await provider.request(payload)

0 commit comments

Comments
 (0)