Skip to content

Commit f61d14c

Browse files
committed
feat(connect): update mina_sendTransaction in the test zkapp for payment transactions
1 parent e109dab commit f61d14c

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

apps/docs/src/components/test-zkapp.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import {
88
} from "./sample-data";
99
import bs58 from 'bs58';
1010

11+
enum TransactionType {
12+
PAYMENT = "payment",
13+
DELEGATION = "delegation",
14+
ZKAPP = "zkapp"
15+
}
16+
1117
function bytesToHex(bytes: Uint8Array): string {
1218
return Array.from(bytes)
1319
.map((byte) => byte.toString(16).padStart(2, '0'))
@@ -61,6 +67,7 @@ export const TestZkApp = () => {
6167
const [presentationRequest, setPresentationRequest] = useState(
6268
JSON.stringify(samplePresentationRequestHttpsFromExampleUpdated, null, 2),
6369
);
70+
const [transactionType, setTransactionType] = useState(TransactionType.PAYMENT)
6471
const [transactionBody, setTransactionBody] = useObjectState({
6572
to: "B62qnVUL6A53E4ZaGd3qbTr6RCtEZYTu3kTijVrrquNpPo4d3MuJ3nb",
6673
amount: "3000000000",
@@ -213,6 +220,7 @@ export const TestZkApp = () => {
213220
setResults(() => ({
214221
mina_signTransaction: JSON.stringify(result, undefined, "\t"),
215222
}));
223+
setTransactionType(TransactionType.PAYMENT);
216224
};
217225
const signZkAppCommand = async () => {
218226
if (!provider) return;
@@ -247,22 +255,24 @@ export const TestZkApp = () => {
247255
setResults(() => ({
248256
mina_signTransaction: JSON.stringify(result, undefined, "\t"),
249257
}));
258+
setTransactionType(TransactionType.ZKAPP);
250259
};
251260
const sendTransaction = async () => {
252261
if (!provider) return;
253262
if (!results.mina_signTransaction) return;
254263
const signedTransaction = JSON.parse(results.mina_signTransaction)
255-
const { result } = await provider.request({
256-
method: "mina_sendTransaction",
257-
params: [{
258-
...signedTransaction,
259-
signature: typeof signedTransaction.signature === "string" ?
260-
convertSignature(signedTransaction.signature) : signedTransaction.signature
261-
}],
262-
});
263-
setResults(() => ({
264-
mina_sendTransaction: JSON.stringify(result, undefined, "\t"),
265-
}));
264+
if (transactionType === TransactionType.PAYMENT) {
265+
const { result } = await provider.request({
266+
method: "mina_sendTransaction",
267+
params: [{
268+
input: signedTransaction.data,
269+
signature: signedTransaction.signature
270+
}, "payment"],
271+
});
272+
setResults(() => ({
273+
mina_sendTransaction: JSON.stringify(result, undefined, "\t"),
274+
}));
275+
}
266276
};
267277
const switchChain = async (networkId: string) => {
268278
if (!provider) return;

0 commit comments

Comments
 (0)