Skip to content

Commit

Permalink
Add stx_signTransactions
Browse files Browse the repository at this point in the history
  • Loading branch information
aryzing committed Nov 20, 2024
1 parent b6fc100 commit 2da5e2d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/request/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/request/types/stxMethods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export * from './getAddresses';
export * from './signMessage';
export * from './signStructuredMessage';
export * from './signTransaction';
export * from './signTransactions';
export * from './transferStx';
42 changes: 42 additions & 0 deletions src/request/types/stxMethods/signTransactions.ts
Original file line number Diff line number Diff line change
@@ -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<typeof stxSignTransactionsParamsSchema>;
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<typeof stxSignTransactionsResultSchema>;
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
>;

0 comments on commit 2da5e2d

Please sign in to comment.