@1sat/templates 0.0.1

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.
Files changed (57) hide show
  1. package/dist/bitcom/aip.d.ts +88 -0
  2. package/dist/bitcom/aip.d.ts.map +1 -0
  3. package/dist/bitcom/aip.js +205 -0
  4. package/dist/bitcom/aip.js.map +1 -0
  5. package/dist/bitcom/b.d.ts +99 -0
  6. package/dist/bitcom/b.d.ts.map +1 -0
  7. package/dist/bitcom/b.js +206 -0
  8. package/dist/bitcom/b.js.map +1 -0
  9. package/dist/bitcom/bap.d.ts +126 -0
  10. package/dist/bitcom/bap.d.ts.map +1 -0
  11. package/dist/bitcom/bap.js +334 -0
  12. package/dist/bitcom/bap.js.map +1 -0
  13. package/dist/bitcom/bitcom.d.ts +75 -0
  14. package/dist/bitcom/bitcom.d.ts.map +1 -0
  15. package/dist/bitcom/bitcom.js +186 -0
  16. package/dist/bitcom/bitcom.js.map +1 -0
  17. package/dist/bitcom/map.d.ts +90 -0
  18. package/dist/bitcom/map.d.ts.map +1 -0
  19. package/dist/bitcom/map.js +215 -0
  20. package/dist/bitcom/map.js.map +1 -0
  21. package/dist/bitcom/sigma.d.ts +93 -0
  22. package/dist/bitcom/sigma.d.ts.map +1 -0
  23. package/dist/bitcom/sigma.js +175 -0
  24. package/dist/bitcom/sigma.js.map +1 -0
  25. package/dist/bsocial/bsocial.d.ts +152 -0
  26. package/dist/bsocial/bsocial.d.ts.map +1 -0
  27. package/dist/bsocial/bsocial.js +397 -0
  28. package/dist/bsocial/bsocial.js.map +1 -0
  29. package/dist/bsv20/bsv20.d.ts +277 -0
  30. package/dist/bsv20/bsv20.d.ts.map +1 -0
  31. package/dist/bsv20/bsv20.js +544 -0
  32. package/dist/bsv20/bsv20.js.map +1 -0
  33. package/dist/bsv21/bsv21.d.ts +231 -0
  34. package/dist/bsv21/bsv21.d.ts.map +1 -0
  35. package/dist/bsv21/bsv21.js +475 -0
  36. package/dist/bsv21/bsv21.js.map +1 -0
  37. package/dist/index.d.ts +35 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +31 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/inscription/inscription.d.ts +165 -0
  42. package/dist/inscription/inscription.d.ts.map +1 -0
  43. package/dist/inscription/inscription.js +401 -0
  44. package/dist/inscription/inscription.js.map +1 -0
  45. package/dist/lock/lock.d.ts +92 -0
  46. package/dist/lock/lock.d.ts.map +1 -0
  47. package/dist/lock/lock.js +283 -0
  48. package/dist/lock/lock.js.map +1 -0
  49. package/dist/ordlock/ordlock.d.ts +126 -0
  50. package/dist/ordlock/ordlock.d.ts.map +1 -0
  51. package/dist/ordlock/ordlock.js +316 -0
  52. package/dist/ordlock/ordlock.js.map +1 -0
  53. package/dist/signer.d.ts +39 -0
  54. package/dist/signer.d.ts.map +1 -0
  55. package/dist/signer.js +54 -0
  56. package/dist/signer.js.map +1 -0
  57. package/package.json +43 -0
@@ -0,0 +1,231 @@
1
+ import { type LockingScript, type Script, type ScriptTemplate, type UnlockingScript } from '@bsv/sdk';
2
+ import type { TokenInscription, TokenOptions } from '../bsv20/bsv20.js';
3
+ import Inscription from '../inscription/inscription.js';
4
+ /**
5
+ * BSV-21 token operation types
6
+ */
7
+ export type BSV21Operation = 'deploy+mint' | 'transfer' | 'burn';
8
+ /**
9
+ * BSV-21 token data structure for JSON payload
10
+ */
11
+ export interface BSV21TokenData extends TokenInscription {
12
+ /** Token operation */
13
+ op: BSV21Operation;
14
+ /** Token symbol (for deploy+mint only) */
15
+ sym?: string;
16
+ /** Decimals (for deploy+mint only, max 18) */
17
+ dec?: number;
18
+ /** Icon URL or data URI (for deploy+mint only) */
19
+ icon?: string;
20
+ /** Token ID (for transfer/burn only) */
21
+ id?: string;
22
+ }
23
+ /**
24
+ * BSV-21 token inscription interface (compatible with js-1sat-ord)
25
+ */
26
+ export interface BSV21Inscription extends TokenInscription {
27
+ /** Token operation */
28
+ op: 'deploy+mint' | 'transfer' | 'burn';
29
+ /** Token symbol (for deploy+mint only) */
30
+ sym?: string;
31
+ /** Decimals (for deploy+mint only, max 18) */
32
+ dec?: number;
33
+ /** Icon URL or data URI (for deploy+mint only) */
34
+ icon?: string;
35
+ /** Token ID (for transfer/burn only) */
36
+ id?: string;
37
+ }
38
+ /**
39
+ * BSV-21 token creation options
40
+ */
41
+ export interface BSV21Options extends TokenOptions {
42
+ }
43
+ /**
44
+ * BSV-21 class implementing ScriptTemplate for advanced token functionality.
45
+ *
46
+ * BSV-21 is an advanced token standard that builds on inscriptions to create
47
+ * sophisticated tokens with rich metadata, file attachments, and complex operations.
48
+ * Unlike BSV-20's simple JSON structure, BSV-21 leverages the full power of
49
+ * inscriptions for token data storage.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Create deploy+mint token (initial token creation)
54
+ * const token = BSV21.deployMint("MYTOKEN", 1000000n, 8, "https://example.com/icon.png");
55
+ * const lockingScript = token.lock();
56
+ *
57
+ * // Transfer tokens
58
+ * const transfer = BSV21.transfer("token_deployment_outpoint", 500n);
59
+ * const transferScript = transfer.lock();
60
+ *
61
+ * // Parse token from script
62
+ * const parsed = BSV21.decode(someScript);
63
+ * if (parsed) {
64
+ * console.log(`Symbol: ${parsed.getSymbol()}`);
65
+ * console.log(`Amount: ${parsed.getAmount()}`);
66
+ * console.log(`Operation: ${parsed.tokenData.op}`);
67
+ * }
68
+ * ```
69
+ */
70
+ export default class BSV21 implements ScriptTemplate {
71
+ /** BSV-21 token data */
72
+ readonly tokenData: BSV21TokenData;
73
+ /** Underlying inscription containing the token data */
74
+ readonly inscription: Inscription;
75
+ /**
76
+ * Creates a new BSV21 instance
77
+ *
78
+ * @param tokenData - The token data structure
79
+ * @param inscription - The inscription containing the token data
80
+ */
81
+ constructor(tokenData: BSV21TokenData, inscription: Inscription);
82
+ /**
83
+ * Creates a deploy+mint token (initial token creation with minting)
84
+ *
85
+ * @param symbol - Token symbol/ticker (e.g., "MYTOKEN")
86
+ * @param amount - Initial amount to mint
87
+ * @param decimals - Number of decimal places (0-18, default 0)
88
+ * @param icon - Optional icon URL or data URI
89
+ * @param options - Optional inscription parameters
90
+ * @returns A new BSV21 instance
91
+ */
92
+ static deployMint(symbol: string, amount: bigint, decimals?: number, icon?: string, options?: BSV21Options): BSV21;
93
+ /**
94
+ * Creates a transfer token for moving tokens between addresses
95
+ *
96
+ * @param tokenId - Token deployment transaction outpoint (txid_vout)
97
+ * @param amount - Amount to transfer
98
+ * @param options - Optional inscription parameters
99
+ * @returns A new BSV21 instance
100
+ */
101
+ static transfer(tokenId: string, amount: bigint, options?: BSV21Options): BSV21;
102
+ /**
103
+ * Creates a burn token for permanently destroying tokens
104
+ *
105
+ * @param tokenId - Token deployment transaction outpoint (txid_vout)
106
+ * @param amount - Amount to burn
107
+ * @param options - Optional inscription parameters
108
+ * @returns A new BSV21 instance
109
+ */
110
+ static burn(tokenId: string, amount: bigint, options?: BSV21Options): BSV21;
111
+ /**
112
+ * Decodes a BSV-21 token from a script
113
+ *
114
+ * @param script - The script containing BSV-21 token data
115
+ * @returns Decoded BSV-21 token or null if not found/invalid
116
+ */
117
+ static decode(script: Script): BSV21 | null;
118
+ /**
119
+ * Creates a locking script containing the BSV-21 token inscription
120
+ *
121
+ * @param lockingScript - Optional locking script to append as suffix
122
+ * @returns A locking script containing the token data
123
+ */
124
+ lock(lockingScript?: LockingScript): LockingScript;
125
+ /**
126
+ * BSV-21 tokens cannot be unlocked directly as they are data containers
127
+ *
128
+ * @throws Error indicating unlock is not supported
129
+ */
130
+ unlock(): {
131
+ sign: () => Promise<UnlockingScript>;
132
+ estimateLength: () => Promise<number>;
133
+ };
134
+ /**
135
+ * Gets the token amount as BigInt
136
+ *
137
+ * @returns Token amount
138
+ */
139
+ getAmount(): bigint;
140
+ /**
141
+ * Gets the token amount as BigInt (concise method)
142
+ *
143
+ * @returns Token amount
144
+ */
145
+ amount(): bigint;
146
+ /**
147
+ * Gets the token symbol (for deploy+mint operations)
148
+ *
149
+ * @returns Token symbol or undefined for transfer/burn operations
150
+ */
151
+ getSymbol(): string | undefined;
152
+ /**
153
+ * Gets the token symbol (concise method)
154
+ *
155
+ * @returns Token symbol or undefined for transfer/burn operations
156
+ */
157
+ symbol(): string | undefined;
158
+ /**
159
+ * Gets the number of decimal places (for deploy+mint operations)
160
+ *
161
+ * @returns Number of decimals, defaults to 0
162
+ */
163
+ getDecimals(): number;
164
+ /**
165
+ * Gets the token ID (for transfer/burn operations)
166
+ *
167
+ * @returns Token deployment outpoint or undefined for deploy+mint operations
168
+ */
169
+ getTokenId(): string | undefined;
170
+ /**
171
+ * Gets the icon URL or data URI (for deploy+mint operations)
172
+ *
173
+ * @returns Icon string or undefined
174
+ */
175
+ getIcon(): string | undefined;
176
+ /**
177
+ * Checks if this token has an icon
178
+ *
179
+ * @returns true if icon is present
180
+ */
181
+ hasIcon(): boolean;
182
+ /**
183
+ * Gets the token operation type
184
+ *
185
+ * @returns The operation (deploy+mint, transfer, or burn)
186
+ */
187
+ getOperation(): BSV21Operation;
188
+ /**
189
+ * Gets the token operation type (concise method)
190
+ *
191
+ * @returns The operation (deploy+mint, transfer, or burn)
192
+ */
193
+ operation(): BSV21Operation;
194
+ /**
195
+ * Checks if this is a deploy+mint operation
196
+ *
197
+ * @returns true for deploy+mint operations
198
+ */
199
+ isDeployMint(): boolean;
200
+ /**
201
+ * Checks if this is a transfer operation
202
+ *
203
+ * @returns true for transfer operations
204
+ */
205
+ isTransfer(): boolean;
206
+ /**
207
+ * Checks if this is a burn operation
208
+ *
209
+ * @returns true for burn operations
210
+ */
211
+ isBurn(): boolean;
212
+ /**
213
+ * Gets the underlying inscription
214
+ *
215
+ * @returns The inscription containing the token data
216
+ */
217
+ getInscription(): Inscription;
218
+ /**
219
+ * Gets the token data as formatted JSON string
220
+ *
221
+ * @returns JSON representation of token data
222
+ */
223
+ toJSON(): string;
224
+ /**
225
+ * Validates the token data structure
226
+ *
227
+ * @returns true if token data is valid
228
+ */
229
+ validate(): boolean;
230
+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