1
1
import { z } from 'zod' ;
2
2
3
- import { DefineRpcMethod , RpcRequest , RpcResponse } from '../../rpc/schemas' ;
3
+ import {
4
+ DefineRpcMethod ,
5
+ createRpcRequestSchema ,
6
+ createRpcResponseSchema ,
7
+ defaultErrorSchema ,
8
+ } from '../../rpc/schemas' ;
4
9
5
10
export const stxSignTransactionMethodName = 'stx_signTransaction' ;
6
11
@@ -24,23 +29,26 @@ export const stxSignTransactionRequestParamsSchema = z.union([
24
29
stxSignTransactionRequestLeatherRpcParamsSchema ,
25
30
stxSignTransactionRequestSip30ParamsSchema ,
26
31
] ) ;
27
-
28
32
export type StxSignTransactionRequestParams = z . infer < typeof stxSignTransactionRequestParamsSchema > ;
29
33
34
+ export const stxSignTransactionRequestSchema = createRpcRequestSchema (
35
+ stxSignTransactionMethodName ,
36
+ stxSignTransactionRequestParamsSchema
37
+ ) ;
38
+ export type StxSignTransactionRequest = z . infer < typeof stxSignTransactionRequestSchema > ;
39
+
30
40
// For backwards compatibility, we return the same data under both properties
31
- export const stxSignTransactionResponseSchema = z . object ( {
41
+ export const stxSignTransactionResponseBodySchema = z . object ( {
32
42
transaction : z . string ( ) ,
33
43
txHex : z . string ( ) ,
34
44
} ) ;
45
+ export type StxSignTransactionResponseBody = z . infer < typeof stxSignTransactionResponseBodySchema > ;
35
46
36
- export type StxSignTransactionResponseBody = z . infer < typeof stxSignTransactionResponseSchema > ;
37
-
38
- export type StxSignTransactionRequest = RpcRequest <
39
- typeof stxSignTransactionMethodName ,
40
- StxSignTransactionRequestParams
41
- > ;
42
-
43
- export type StxSignTransactionResponse = RpcResponse < StxSignTransactionResponseBody > ;
47
+ export const stxSignTransactionResponseSchema = createRpcResponseSchema (
48
+ stxSignTransactionResponseBodySchema ,
49
+ defaultErrorSchema
50
+ ) ;
51
+ export type StxSignTransactionResponse = z . infer < typeof stxSignTransactionResponseSchema > ;
44
52
45
53
export type DefineStxSignTransactionMethod = DefineRpcMethod <
46
54
StxSignTransactionRequest ,
0 commit comments