@1sat/wallet-toolbox 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Tokens Module
3
3
  *
4
- * Functions for managing BSV21 tokens.
4
+ * Skills for managing BSV21 tokens.
5
5
  */
6
- import { type WalletInterface, type WalletOutput } from "@bsv/sdk";
7
- import type { OneSatServices } from "../../services/OneSatServices";
6
+ import { type WalletOutput } from "@bsv/sdk";
7
+ import type { Skill } from "../skills/types";
8
+ type PubKeyHex = string;
8
9
  export interface Bsv21Balance {
9
10
  /** Token protocol (bsv-20) */
10
11
  p: string;
@@ -32,57 +33,55 @@ export interface Bsv21Balance {
32
33
  export interface SendBsv21Request {
33
34
  /** Token ID (txid_vout format) */
34
35
  tokenId: string;
35
- /** Destination address */
36
- address: string;
37
36
  /** Amount to send (as bigint or string) */
38
37
  amount: bigint | string;
38
+ /** Recipient's identity public key (preferred) */
39
+ counterparty?: PubKeyHex;
40
+ /** Legacy: raw P2PKH address */
41
+ address?: string;
42
+ /** Paymail address */
43
+ paymail?: string;
44
+ }
45
+ export interface PurchaseBsv21Request {
46
+ /** Token ID (txid_vout format of the deploy transaction) */
47
+ tokenId: string;
48
+ /** Outpoint of listed token UTXO (OrdLock containing BSV21) */
49
+ outpoint: string;
50
+ /** Amount of tokens in the listing */
51
+ amount: bigint | string;
52
+ /** Optional marketplace fee address */
53
+ marketplaceAddress?: string;
54
+ /** Optional marketplace fee rate (0-1) */
55
+ marketplaceRate?: number;
39
56
  }
40
57
  export interface TokenOperationResponse {
41
58
  txid?: string;
42
59
  rawtx?: string;
43
60
  error?: string;
44
61
  }
62
+ /** Input for listTokens skill */
63
+ export interface ListTokensInput {
64
+ /** Max number of tokens to return */
65
+ limit?: number;
66
+ }
45
67
  /**
46
- * List BSV21 token outputs from the bsv21 basket.
47
- * Returns WalletOutput[] directly - use tags for metadata.
68
+ * List BSV21 token outputs from the wallet.
48
69
  */
49
- export declare function listTokens(cwi: WalletInterface, limit?: number): Promise<WalletOutput[]>;
70
+ export declare const listTokens: Skill<ListTokensInput, WalletOutput[]>;
71
+ /** Input for getBsv21Balances skill (no required params) */
72
+ export type GetBsv21BalancesInput = Record<string, never>;
50
73
  /**
51
74
  * Get aggregated BSV21 token balances.
52
- * Groups outputs by token ID and sums amounts.
53
75
  */
54
- export declare function getBsv21Balances(cwi: WalletInterface): Promise<Bsv21Balance[]>;
76
+ export declare const getBsv21Balances: Skill<GetBsv21BalancesInput, Bsv21Balance[]>;
55
77
  /**
56
78
  * Send BSV21 tokens to an address.
57
- *
58
- * Flow:
59
- * 1. Get token UTXOs from basket
60
- * 2. Validate each with BSV21 service
61
- * 3. Select UTXOs until we have enough tokens
62
- * 4. Build transfer inscription outputs
63
- * 5. Create and sign transaction
64
79
  */
65
- export declare function sendBsv21(cwi: WalletInterface, request: SendBsv21Request, services?: OneSatServices): Promise<TokenOperationResponse>;
66
- export interface PurchaseBsv21Request {
67
- /** Token ID (txid_vout format of the deploy transaction) */
68
- tokenId: string;
69
- /** Outpoint of listed token UTXO (OrdLock containing BSV21) */
70
- outpoint: string;
71
- /** Amount of tokens in the listing */
72
- amount: bigint | string;
73
- /** Optional marketplace fee address */
74
- marketplaceAddress?: string;
75
- /** Optional marketplace fee rate (0-1) */
76
- marketplaceRate?: number;
77
- }
80
+ export declare const sendBsv21: Skill<SendBsv21Request, TokenOperationResponse>;
78
81
  /**
79
82
  * Purchase BSV21 tokens from marketplace.
80
- *
81
- * Flow:
82
- * 1. Fetch listing BEEF to get the locking script
83
- * 2. Decode OrdLock to get price and payout
84
- * 3. Build BSV21 transfer output for buyer
85
- * 4. Build payment output for seller
86
- * 5. Build custom OrdLock purchase unlock (preimage only, no signature)
87
83
  */
88
- export declare function purchaseBsv21(cwi: WalletInterface, request: PurchaseBsv21Request, services?: OneSatServices): Promise<TokenOperationResponse>;
84
+ export declare const purchaseBsv21: Skill<PurchaseBsv21Request, TokenOperationResponse>;
85
+ /** All token skills for registry */
86
+ export declare const tokensSkills: (Skill<ListTokensInput, WalletOutput[]> | Skill<GetBsv21BalancesInput, Bsv21Balance[]> | Skill<SendBsv21Request, TokenOperationResponse> | Skill<PurchaseBsv21Request, TokenOperationResponse>)[];
87
+ export {};