diff --git a/src/request/types/index.ts b/src/request/types/index.ts index 0bcb1d4..874755d 100644 --- a/src/request/types/index.ts +++ b/src/request/types/index.ts @@ -13,6 +13,7 @@ export interface StxRequests { stx_signStructuredMessage: StxMethods.StxSignStructuredMessage; stx_signTransaction: StxMethods.StxSignTransaction; stx_transferStx: StxMethods.StxTransferStx; + stx_signTransactions: StxMethods.StxSignTransactions; } export type StxRequestMethod = keyof StxRequests; diff --git a/src/request/types/stxMethods/index.ts b/src/request/types/stxMethods/index.ts index 9f45984..021f92e 100644 --- a/src/request/types/stxMethods/index.ts +++ b/src/request/types/stxMethods/index.ts @@ -5,4 +5,5 @@ export * from './getAddresses'; export * from './signMessage'; export * from './signStructuredMessage'; export * from './signTransaction'; +export * from './signTransactions'; export * from './transferStx'; diff --git a/src/request/types/stxMethods/signTransactions.ts b/src/request/types/stxMethods/signTransactions.ts new file mode 100644 index 0000000..48828ce --- /dev/null +++ b/src/request/types/stxMethods/signTransactions.ts @@ -0,0 +1,42 @@ +import { MethodParamsAndResult, rpcRequestMessageSchema } from '../../../types'; +import * as v from 'valibot'; + +export const stxSignTransactionsMethodName = 'stx_signTransactions'; +export const stxSignTransactionsParamsSchema = v.object({ + /** + * The transactions to sign as hex-encoded strings. + */ + transactions: v.array( + v.object({ + transactionHex: v.string(), + + /** + * Whether the transaction should be broadcast after signing. Defaults to `false`. + */ + broadcast: v.optional(v.boolean()), + }) + ), +}); +export type StxSignTransactionsParams = v.InferOutput; +export const stxSignTransactionsResultSchema = v.object({ + /** + * The signed transactions as hex-encoded strings. In the same order as the sign request. + */ + transactions: v.array(v.string()), +}); +export type StxSignTransactionsResult = v.InferOutput; +export const stxSignTransactionsRequestMessageSchema = v.object({ + ...rpcRequestMessageSchema.entries, + ...v.object({ + method: v.literal(stxSignTransactionsMethodName), + params: stxSignTransactionsParamsSchema, + id: v.string(), + }).entries, +}); +export type StxSignTransactionsRequestMessage = v.InferOutput< + typeof stxSignTransactionsRequestMessageSchema +>; +export type StxSignTransactions = MethodParamsAndResult< + StxSignTransactionsParams, + StxSignTransactionsResult +>;