Skip to content

Commit

Permalink
Add optional broadcast param
Browse files Browse the repository at this point in the history
  • Loading branch information
aryzing authored Jul 11, 2024
1 parent 81d5375 commit 997aa7e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sats-connect/core",
"version": "0.0.15",
"version": "0.1.0",
"main": "dist/index.mjs",
"module": "dist/index.mjs",
"types": "dist/index.d.mts",
Expand Down
42 changes: 37 additions & 5 deletions src/request/types/stxMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,42 @@ export type StxGetAddresses = MethodParamsAndResult<
v.InferOutput<typeof stxGetAddressesResultSchema>
>;

// Types for `stx_signTransaction` request
export type SignTransactionParams = Transaction & Partial<Pubkey>;
export type SignTransactionResult = Transaction;
export const stxSignTransactionMethodName = 'stx_signTransaction';
export const stxSignTransactionParamsSchema = v.object({
/**
* The transaction to sign as a hex-encoded string.
*/
transaction: v.string(),
/**
* The public key to sign the transaction with. The wallet may use any key
* when not provided.
*/
pubkey: v.optional(v.string()),
/**
* Whether to broadcast the transaction after signing. Defaults to `true`.
*/
broadcast: v.optional(v.boolean()),
});
export type StxSignTransactionParams = v.InferOutput<typeof stxSignTransactionParamsSchema>;
export const stxSignTransactionResultSchema = v.object({
/**
* The signed transaction as a hex-encoded string.
*/
transaction: v.string(),
});
export type StxSignTransactionResult = v.InferOutput<typeof stxSignTransactionResultSchema>;
export const stxSignTransactionRequestMessageSchema = v.object({
...rpcRequestMessageSchema.entries,
...v.object({
method: v.literal(stxSignTransactionMethodName),
params: stxSignTransactionParamsSchema,
id: v.string(),
}).entries,
});
export type StxSignTransactionRequestMessage = v.InferOutput<
typeof stxSignTransactionRequestMessageSchema
>;
export type StxSignTransaction = MethodParamsAndResult<
SignTransactionParams,
SignTransactionResult
StxSignTransactionParams,
StxSignTransactionResult
>;

0 comments on commit 997aa7e

Please sign in to comment.