@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,277 @@
1
+ import { type LockingScript, type Script, type ScriptTemplate, type UnlockingScript } from '@bsv/sdk';
2
+ import Inscription from '../inscription/inscription.js';
3
+ /**
4
+ * BSV-20 token operation types
5
+ */
6
+ export type BSV20Operation = 'deploy' | 'mint' | 'transfer' | 'burn';
7
+ /**
8
+ * Token data structure for JSON payload
9
+ */
10
+ export interface TokenData {
11
+ /** Protocol identifier (always "bsv-20") */
12
+ p: 'bsv-20';
13
+ /** Token operation */
14
+ op: string;
15
+ /** Amount as string to handle large numbers */
16
+ amt: string;
17
+ }
18
+ /**
19
+ * BSV-20 token data structure for JSON payload
20
+ */
21
+ export interface BSV20TokenData extends TokenData {
22
+ /** Token operation */
23
+ op: BSV20Operation;
24
+ /** Token ticker/symbol (for deploy, mint, transfer, burn) */
25
+ tick?: string;
26
+ /** Decimals (for deploy only, max 18) */
27
+ dec?: number;
28
+ /** Maximum supply (for deploy only) */
29
+ max?: string;
30
+ /** Limit per mint operation (for deploy only) */
31
+ lim?: string;
32
+ /** Token deployment ID (for transfer/burn operations) */
33
+ id?: string;
34
+ }
35
+ /**
36
+ * Token creation options
37
+ */
38
+ export interface TokenOptions {
39
+ /** Optional parent inscription reference (36-byte outpoint) */
40
+ parent?: Uint8Array;
41
+ /** Optional script prefix to prepend before inscription (e.g., P2PKH locking script) */
42
+ scriptPrefix?: Script | LockingScript;
43
+ /** Optional script suffix to append after inscription (e.g., OP_RETURN data) */
44
+ scriptSuffix?: Script | LockingScript;
45
+ }
46
+ /**
47
+ * Token inscription base interface (compatible with js-1sat-ord)
48
+ */
49
+ export interface TokenInscription {
50
+ /** Protocol identifier (always "bsv-20") */
51
+ p: 'bsv-20';
52
+ /** Token operation */
53
+ op: string;
54
+ /** Amount as string to handle large numbers */
55
+ amt: string;
56
+ }
57
+ /**
58
+ * BSV-20 token inscription interface (compatible with js-1sat-ord)
59
+ */
60
+ export interface BSV20Inscription extends TokenInscription {
61
+ /** Token operation */
62
+ op: 'deploy' | 'mint' | 'transfer' | 'burn';
63
+ /** Token ticker/symbol (for deploy, mint, transfer, burn) */
64
+ tick: string;
65
+ /** Decimals (for deploy only, max 18) */
66
+ dec?: number;
67
+ /** Maximum supply (for deploy only) */
68
+ max?: string;
69
+ /** Limit per mint operation (for deploy only) */
70
+ lim?: string;
71
+ }
72
+ /**
73
+ * BSV-20 token creation options
74
+ */
75
+ export interface BSV20Options extends TokenOptions {
76
+ }
77
+ /**
78
+ * BSV-20 class implementing ScriptTemplate for basic fungible tokens.
79
+ *
80
+ * BSV-20 is the foundational token standard for BSV blockchain, providing
81
+ * simple and efficient fungible tokens with ticker-based identification.
82
+ * It serves as the base layer for the token economy on BSV.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * // Deploy a new token
87
+ * const deploy = BSV20.deploy("MYTOKEN", BigInt("21000000"), 8, BigInt("1000000"));
88
+ * const deployScript = deploy.lock();
89
+ *
90
+ * // Mint tokens
91
+ * const mint = BSV20.mint("MYTOKEN", BigInt("1000000"));
92
+ * const mintScript = mint.lock();
93
+ *
94
+ * // Transfer tokens
95
+ * const transfer = BSV20.transfer("MYTOKEN", BigInt("500"));
96
+ * const transferScript = transfer.lock();
97
+ *
98
+ * // Parse token from script
99
+ * const parsed = BSV20.decode(someScript);
100
+ * if (parsed) {
101
+ * console.log(`Ticker: ${parsed.getTicker()}`);
102
+ * console.log(`Amount: ${parsed.getAmount()}`);
103
+ * console.log(`Operation: ${parsed.tokenData.op}`);
104
+ * }
105
+ * ```
106
+ */
107
+ export default class BSV20 implements ScriptTemplate {
108
+ /** BSV-20 token data */
109
+ readonly tokenData: BSV20TokenData;
110
+ /** Underlying inscription containing the token data */
111
+ readonly inscription: Inscription;
112
+ /**
113
+ * Creates a new BSV20 instance
114
+ *
115
+ * @param tokenData - The token data structure
116
+ * @param inscription - The inscription containing the token data
117
+ */
118
+ constructor(tokenData: BSV20TokenData, inscription: Inscription);
119
+ /**
120
+ * Creates a deploy operation for a new BSV-20 token
121
+ *
122
+ * @param ticker - Token ticker/symbol (1-32 characters)
123
+ * @param maxSupply - Maximum total supply
124
+ * @param decimals - Number of decimal places (0-18, default 0)
125
+ * @param limitPerMint - Optional limit per mint operation
126
+ * @param options - Optional inscription parameters
127
+ * @returns A new BSV20 instance
128
+ */
129
+ static deploy(ticker: string, maxSupply: bigint, decimals?: number, limitPerMint?: bigint, options?: BSV20Options): BSV20;
130
+ /**
131
+ * Creates a mint operation for an existing BSV-20 token
132
+ *
133
+ * @param ticker - Token ticker to mint
134
+ * @param amount - Amount to mint
135
+ * @param options - Optional inscription parameters
136
+ * @returns A new BSV20 instance
137
+ */
138
+ static mint(ticker: string, amount: bigint, options?: BSV20Options): BSV20;
139
+ /**
140
+ * Creates a transfer operation for moving BSV-20 tokens
141
+ *
142
+ * @param ticker - Token ticker to transfer
143
+ * @param amount - Amount to transfer
144
+ * @param options - Optional inscription parameters
145
+ * @returns A new BSV20 instance
146
+ */
147
+ static transfer(ticker: string, amount: bigint, options?: BSV20Options): BSV20;
148
+ /**
149
+ * Creates a burn operation for permanently destroying BSV-20 tokens
150
+ *
151
+ * @param ticker - Token ticker to burn
152
+ * @param amount - Amount to burn
153
+ * @param options - Optional inscription parameters
154
+ * @returns A new BSV20 instance
155
+ */
156
+ static burn(ticker: string, amount: bigint, options?: BSV20Options): BSV20;
157
+ /**
158
+ * Decodes a BSV-20 token from a script
159
+ *
160
+ * @param script - The script containing BSV-20 token data
161
+ * @returns Decoded BSV-20 token or null if not found/invalid
162
+ */
163
+ static decode(script: Script): BSV20 | null;
164
+ /**
165
+ * Creates a locking script containing the BSV-20 token inscription
166
+ *
167
+ * @param lockingScript - Optional locking script to append as suffix
168
+ * @returns A locking script containing the token data
169
+ */
170
+ lock(lockingScript?: LockingScript): LockingScript;
171
+ /**
172
+ * BSV-20 tokens cannot be unlocked directly as they are data containers
173
+ *
174
+ * @throws Error indicating unlock is not supported
175
+ */
176
+ unlock(): {
177
+ sign: () => Promise<UnlockingScript>;
178
+ estimateLength: () => Promise<number>;
179
+ };
180
+ /**
181
+ * Gets the token amount as BigInt
182
+ *
183
+ * @returns Token amount
184
+ */
185
+ getAmount(): bigint;
186
+ /**
187
+ * Gets the token amount as BigInt (concise method)
188
+ *
189
+ * @returns Token amount
190
+ */
191
+ amount(): bigint;
192
+ /**
193
+ * Gets the token ticker/symbol
194
+ *
195
+ * @returns Token ticker
196
+ */
197
+ getTicker(): string | undefined;
198
+ /**
199
+ * Gets the token ticker/symbol (concise method)
200
+ *
201
+ * @returns Token ticker
202
+ */
203
+ ticker(): string | undefined;
204
+ /**
205
+ * Gets the number of decimal places (for deploy operations)
206
+ *
207
+ * @returns Number of decimals, defaults to 0
208
+ */
209
+ getDecimals(): number;
210
+ /**
211
+ * Gets the maximum supply (for deploy operations)
212
+ *
213
+ * @returns Maximum supply as BigInt or undefined
214
+ */
215
+ getMaxSupply(): bigint | undefined;
216
+ /**
217
+ * Gets the limit per mint operation (for deploy operations)
218
+ *
219
+ * @returns Limit per mint as BigInt or undefined
220
+ */
221
+ getLimitPerMint(): bigint | undefined;
222
+ /**
223
+ * Gets the token operation type
224
+ *
225
+ * @returns The operation (deploy, mint, transfer, or burn)
226
+ */
227
+ getOperation(): BSV20Operation;
228
+ /**
229
+ * Gets the token operation type (concise method)
230
+ *
231
+ * @returns The operation (deploy, mint, transfer, or burn)
232
+ */
233
+ operation(): BSV20Operation;
234
+ /**
235
+ * Checks if this is a deploy operation
236
+ *
237
+ * @returns true for deploy operations
238
+ */
239
+ isDeploy(): boolean;
240
+ /**
241
+ * Checks if this is a mint operation
242
+ *
243
+ * @returns true for mint operations
244
+ */
245
+ isMint(): boolean;
246
+ /**
247
+ * Checks if this is a transfer operation
248
+ *
249
+ * @returns true for transfer operations
250
+ */
251
+ isTransfer(): boolean;
252
+ /**
253
+ * Checks if this is a burn operation
254
+ *
255
+ * @returns true for burn operations
256
+ */
257
+ isBurn(): boolean;
258
+ /**
259
+ * Gets the underlying inscription
260
+ *
261
+ * @returns The inscription containing the token data
262
+ */
263
+ getInscription(): Inscription;
264
+ /**
265
+ * Gets the token data as formatted JSON string
266
+ *
267
+ * @returns JSON representation of token data
268
+ */
269
+ toJSON(): string;
270
+ /**
271
+ * Validates the token data structure
272
+ *
273
+ * @returns true if token data is valid
274
+ */
275
+ validate(): boolean;
276
+ }
277
+ //# sourceMappingURL=bsv20.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bsv20.d.ts","sourceRoot":"","sources":["../../src/bsv20/bsv20.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,eAAe,EAEpB,MAAM,UAAU,CAAA;AACjB,OAAO,WAAW,MAAM,+BAA+B,CAAA;AAEvD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;AAEpE;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,4CAA4C;IAC5C,CAAC,EAAE,QAAQ,CAAA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