@leather.io/models 0.10.1 → 0.11.0

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,5 +1,5 @@
1
1
 
2
- > @leather.io/models@0.10.1 build /home/runner/work/mono/mono/packages/models
2
+ > @leather.io/models@0.11.0 build /home/runner/work/mono/mono/packages/models
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,9 +9,9 @@
9
9
  CLI Target: es2022
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- ESM dist/index.js 8.12 KB
13
- ESM dist/index.js.map 16.65 KB
14
- ESM ⚡️ Build success in 30ms
12
+ ESM dist/index.js 8.87 KB
13
+ ESM dist/index.js.map 17.93 KB
14
+ ESM ⚡️ Build success in 34ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 2261ms
17
- DTS dist/index.d.ts 11.19 KB
16
+ DTS ⚡️ Build success in 2465ms
17
+ DTS dist/index.d.ts 15.29 KB
package/CHANGELOG.md CHANGED
@@ -12,6 +12,20 @@
12
12
  * devDependencies
13
13
  * @leather.io/eslint-config bumped to 0.6.1
14
14
 
15
+ ### Dependencies
16
+
17
+ * The following workspace dependencies were updated
18
+ * devDependencies
19
+ * @leather.io/tsconfig-config bumped to 0.5.1
20
+
21
+ ## [0.11.0](https://github.com/leather-io/mono/compare/@leather.io/models-v0.10.2...@leather.io/models-v0.11.0) (2024-07-31)
22
+
23
+
24
+ ### Features
25
+
26
+ * add network config schema ([bc6030e](https://github.com/leather-io/mono/commit/bc6030e19d1873436b89943283246dfb4ad3470a))
27
+ * implement mempool api, closes leather-io/issues[#215](https://github.com/leather-io/mono/issues/215) ([51b462b](https://github.com/leather-io/mono/commit/51b462b1c7e374e94d0b0af4a72a37645904951f))
28
+
15
29
  ## [0.10.0](https://github.com/leather-io/mono/compare/@leather.io/models-v0.9.0...@leather.io/models-v0.10.0) (2024-06-21)
16
30
 
17
31
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
+ import { z } from 'zod';
2
3
  import { MempoolTransaction, Transaction } from '@stacks/stacks-blockchain-api-types';
3
4
 
4
5
  type ValueOf<T> = T[keyof T];
@@ -23,24 +24,60 @@ interface Money {
23
24
  }
24
25
 
25
26
  interface BaseCryptoAssetBalance {
27
+ /**
28
+ * totalBalance after filtering out outboundBalance, protectedBalance, and uneconomicalBalance
29
+ */
26
30
  readonly availableBalance: Money;
27
31
  }
28
32
  interface BtcCryptoAssetBalance extends BaseCryptoAssetBalance {
33
+ /**
34
+ * Balance of UTXOs with collectibles
35
+ */
29
36
  readonly protectedBalance: Money;
37
+ /**
38
+ * Balance across UTXOs with need for larger fee than principal by UTXO given standard rate
39
+ */
30
40
  readonly uneconomicalBalance: Money;
31
41
  }
32
42
  interface StxCryptoAssetBalance extends BaseCryptoAssetBalance {
43
+ /**
44
+ * availableBalance minus lockedBalance
45
+ */
33
46
  readonly availableUnlockedBalance: Money;
47
+ /**
48
+ * Balance of pending receipt into account given pending transactions
49
+ */
34
50
  readonly inboundBalance: Money;
51
+ /**
52
+ * totalBalance minus total amount locked by contracts
53
+ */
35
54
  readonly lockedBalance: Money;
55
+ /**
56
+ * Balance of pending delivery from account given pending transactions
57
+ */
36
58
  readonly outboundBalance: Money;
59
+ /**
60
+ * totalBalance plus inboundBalance minus outboundBalance
61
+ */
37
62
  readonly pendingBalance: Money;
63
+ /**
64
+ * Balance as confirmed on chain
65
+ */
38
66
  readonly totalBalance: Money;
67
+ /**
68
+ * totalBalance minus lockedBalance
69
+ */
39
70
  readonly unlockedBalance: Money;
40
71
  }
41
72
  type CryptoAssetBalance = BaseCryptoAssetBalance | BtcCryptoAssetBalance | StxCryptoAssetBalance;
42
73
  declare function createCryptoAssetBalance(balance: Money): BaseCryptoAssetBalance;
43
74
 
75
+ /**
76
+ * Inscriptions contain arbitrary data. When retrieving an inscription, it should be
77
+ * classified into one of the types below, indicating that the app can handle it
78
+ * appropriately and securely. Inscriptions of types not ready to be handled by the
79
+ * app should be classified as "other".
80
+ */
44
81
  declare const inscriptionMimeTypes: readonly ["audio", "gltf", "html", "image", "svg", "text", "video", "other"];
45
82
  type InscriptionMimeType = (typeof inscriptionMimeTypes)[number];
46
83
  declare function whenInscriptionMimeType<T>(mimeType: string, branches: {
@@ -180,12 +217,105 @@ interface MarketData {
180
217
  }
181
218
  declare function createMarketData(pair: MarketPair, price: Money): MarketData;
182
219
 
220
+ declare const bitcoinNetworkModesSchema: z.ZodEnum<["mainnet", "testnet", "testnet", "regtest", "signet"]>;
221
+ declare const networkConfigurationSchema: z.ZodObject<{
222
+ name: z.ZodString;
223
+ id: z.ZodString;
224
+ chain: z.ZodObject<{
225
+ bitcoin: z.ZodObject<{
226
+ blockchain: z.ZodLiteral<"bitcoin">;
227
+ bitcoinUrl: z.ZodString;
228
+ bitcoinNetwork: z.ZodEnum<["mainnet", "testnet", "testnet", "regtest", "signet"]>;
229
+ }, "strip", z.ZodTypeAny, {
230
+ blockchain: "bitcoin";
231
+ bitcoinUrl: string;
232
+ bitcoinNetwork: "mainnet" | "testnet" | "regtest" | "signet";
233
+ }, {
234
+ blockchain: "bitcoin";
235
+ bitcoinUrl: string;
236
+ bitcoinNetwork: "mainnet" | "testnet" | "regtest" | "signet";
237
+ }>;
238
+ stacks: z.ZodObject<{
239
+ blockchain: z.ZodLiteral<"stacks">;
240
+ url: z.ZodString;
241
+ chainId: z.ZodNumber;
242
+ subnetChainId: z.ZodOptional<z.ZodNumber>;
243
+ }, "strip", z.ZodTypeAny, {
244
+ blockchain: "stacks";
245
+ url: string;
246
+ chainId: number;
247
+ subnetChainId?: number | undefined;
248
+ }, {
249
+ blockchain: "stacks";
250
+ url: string;
251
+ chainId: number;
252
+ subnetChainId?: number | undefined;
253
+ }>;
254
+ }, "strip", z.ZodTypeAny, {
255
+ bitcoin: {
256
+ blockchain: "bitcoin";
257
+ bitcoinUrl: string;
258
+ bitcoinNetwork: "mainnet" | "testnet" | "regtest" | "signet";
259
+ };
260
+ stacks: {
261
+ blockchain: "stacks";
262
+ url: string;
263
+ chainId: number;
264
+ subnetChainId?: number | undefined;
265
+ };
266
+ }, {
267
+ bitcoin: {
268
+ blockchain: "bitcoin";
269
+ bitcoinUrl: string;
270
+ bitcoinNetwork: "mainnet" | "testnet" | "regtest" | "signet";
271
+ };
272
+ stacks: {
273
+ blockchain: "stacks";
274
+ url: string;
275
+ chainId: number;
276
+ subnetChainId?: number | undefined;
277
+ };
278
+ }>;
279
+ }, "strip", z.ZodTypeAny, {
280
+ name: string;
281
+ id: string;
282
+ chain: {
283
+ bitcoin: {
284
+ blockchain: "bitcoin";
285
+ bitcoinUrl: string;
286
+ bitcoinNetwork: "mainnet" | "testnet" | "regtest" | "signet";
287
+ };
288
+ stacks: {
289
+ blockchain: "stacks";
290
+ url: string;
291
+ chainId: number;
292
+ subnetChainId?: number | undefined;
293
+ };
294
+ };
295
+ }, {
296
+ name: string;
297
+ id: string;
298
+ chain: {
299
+ bitcoin: {
300
+ blockchain: "bitcoin";
301
+ bitcoinUrl: string;
302
+ bitcoinNetwork: "mainnet" | "testnet" | "regtest" | "signet";
303
+ };
304
+ stacks: {
305
+ blockchain: "stacks";
306
+ url: string;
307
+ chainId: number;
308
+ subnetChainId?: number | undefined;
309
+ };
310
+ };
311
+ }>;
312
+
183
313
  declare const HIRO_API_BASE_URL_MAINNET = "https://api.hiro.so";
184
314
  declare const HIRO_API_BASE_URL_TESTNET = "https://api.testnet.hiro.so";
185
315
  declare const HIRO_INSCRIPTIONS_API_URL = "https://api.hiro.so/ordinals/v1/inscriptions";
186
316
  declare const HIRO_API_BASE_URL_NAKAMOTO_TESTNET = "https://api.nakamoto.testnet.hiro.so";
187
- declare const BITCOIN_API_BASE_URL_MAINNET = "https://blockstream.info/api";
188
- declare const BITCOIN_API_BASE_URL_TESTNET = "https://blockstream.info/testnet/api";
317
+ declare const BITCOIN_API_BASE_URL_MAINNET = "https://leather.mempool.space/api";
318
+ declare const BITCOIN_API_BASE_URL_TESTNET = "https://leather.mempool.space/testnet/api";
189
319
  declare const BITCOIN_API_BASE_URL_SIGNET = "https://mempool.space/signet/api";
190
320
  declare const BESTINSLOT_API_BASE_URL_MAINNET = "https://leatherapi.bestinslot.xyz/v3";
191
321
  declare const BESTINSLOT_API_BASE_URL_TESTNET = "https://leatherapi_testnet.bestinslot.xyz/v3";
@@ -205,8 +335,9 @@ type DefaultNetworkConfigurations = keyof typeof WalletDefaultNetworkConfigurati
205
335
  declare const supportedBlockchains: readonly ["stacks", "bitcoin"];
206
336
  type SupportedBlockchains = (typeof supportedBlockchains)[number];
207
337
  declare const networkModes: readonly ["mainnet", "testnet"];
338
+ declare const testnetModes: readonly ["testnet", "regtest", "signet"];
208
339
  type NetworkModes = (typeof networkModes)[number];
209
- type BitcoinTestnetModes = 'testnet' | 'regtest' | 'signet';
340
+ type BitcoinTestnetModes = (typeof testnetModes)[number];
210
341
  type BitcoinNetworkModes = NetworkModes | BitcoinTestnetModes;
211
342
  interface BaseChainConfig {
212
343
  blockchain: Blockchains;
@@ -219,17 +350,12 @@ interface BitcoinChainConfig extends BaseChainConfig {
219
350
  interface StacksChainConfig extends BaseChainConfig {
220
351
  blockchain: 'stacks';
221
352
  url: string;
353
+ /** The chainId of the network (or parent network if this is a subnet) */
222
354
  chainId: ChainID;
355
+ /** An additional chainId for subnets. Indicated a subnet if defined and is mainly used for signing. */
223
356
  subnetChainId?: ChainID;
224
357
  }
225
- interface NetworkConfiguration {
226
- name: string;
227
- id: DefaultNetworkConfigurations;
228
- chain: {
229
- bitcoin: BitcoinChainConfig;
230
- stacks: StacksChainConfig;
231
- };
232
- }
358
+ type NetworkConfiguration = z.infer<typeof networkConfigurationSchema>;
233
359
  declare const defaultCurrentNetwork: NetworkConfiguration;
234
360
  declare const defaultNetworksKeyedById: Record<WalletDefaultNetworkConfigurationIds, NetworkConfiguration>;
235
361
 
@@ -320,4 +446,4 @@ interface UtxoItem {
320
446
  value: number;
321
447
  }
322
448
 
323
- export { type AllowAdditionalProperties, type AverageBitcoinFeeRates, BESTINSLOT_API_BASE_URL_MAINNET, BESTINSLOT_API_BASE_URL_TESTNET, BITCOIN_API_BASE_URL_MAINNET, BITCOIN_API_BASE_URL_SIGNET, BITCOIN_API_BASE_URL_TESTNET, type BaseCryptoAssetBalance, type BaseCryptoAssetInfo, type BitcoinChainConfig, type BitcoinNetworkModes, type BitcoinTransactionVectorInput, type BitcoinTransactionVectorOutput, type BitcoinTx, type Blockchains, type Brc20CryptoAssetInfo, type BtcCryptoAssetBalance, type BtcCryptoAssetInfo, BtcFeeType, ChainID, type CryptoAssetBalance, type CryptoAssetType, type CryptoCurrencies, type Currencies, type DefaultNetworkConfigurations, type Entries, FeeCalculationTypes, FeeTypes, type Fees, type FiatCurrencies, type FtTransfer, HIRO_API_BASE_URL_MAINNET, HIRO_API_BASE_URL_NAKAMOTO_TESTNET, HIRO_API_BASE_URL_TESTNET, HIRO_INSCRIPTIONS_API_URL, type Inscription, type InscriptionCryptoAssetInfo, type InscriptionMimeType, type LiteralUnion, type MarketData, type Money, type NetworkConfiguration, type NetworkModes, type NumType, type RuneCryptoAssetInfo, STX20_API_BASE_URL_MAINNET, type Sip10CryptoAssetInfo, type Sip9CryptoAssetInfo, type Src20CryptoAssetInfo, type StacksChainConfig, type StacksFeeEstimate, type StacksTx, type StacksTxStatus, type StampCryptoAssetInfo, type Stx20CryptoAssetInfo, type StxCryptoAssetBalance, type StxCryptoAssetInfo, type StxTransfer, type SupportedBlockchains, type UtxoItem, type ValueOf, WalletDefaultNetworkConfigurationIds, btcTxTimeMap, createCryptoAssetBalance, createInscription, createMarketData, createMarketPair, defaultCurrentNetwork, defaultNetworksKeyedById, formatMarketPair, whenInscriptionMimeType };
449
+ export { type AllowAdditionalProperties, type AverageBitcoinFeeRates, BESTINSLOT_API_BASE_URL_MAINNET, BESTINSLOT_API_BASE_URL_TESTNET, BITCOIN_API_BASE_URL_MAINNET, BITCOIN_API_BASE_URL_SIGNET, BITCOIN_API_BASE_URL_TESTNET, type BaseCryptoAssetBalance, type BaseCryptoAssetInfo, type BitcoinChainConfig, type BitcoinNetworkModes, type BitcoinTransactionVectorInput, type BitcoinTransactionVectorOutput, type BitcoinTx, type Blockchains, type Brc20CryptoAssetInfo, type BtcCryptoAssetBalance, type BtcCryptoAssetInfo, BtcFeeType, ChainID, type CryptoAssetBalance, type CryptoAssetType, type CryptoCurrencies, type Currencies, type DefaultNetworkConfigurations, type Entries, FeeCalculationTypes, FeeTypes, type Fees, type FiatCurrencies, type FtTransfer, HIRO_API_BASE_URL_MAINNET, HIRO_API_BASE_URL_NAKAMOTO_TESTNET, HIRO_API_BASE_URL_TESTNET, HIRO_INSCRIPTIONS_API_URL, type Inscription, type InscriptionCryptoAssetInfo, type InscriptionMimeType, type LiteralUnion, type MarketData, type Money, type NetworkConfiguration, type NetworkModes, type NumType, type RuneCryptoAssetInfo, STX20_API_BASE_URL_MAINNET, type Sip10CryptoAssetInfo, type Sip9CryptoAssetInfo, type Src20CryptoAssetInfo, type StacksChainConfig, type StacksFeeEstimate, type StacksTx, type StacksTxStatus, type StampCryptoAssetInfo, type Stx20CryptoAssetInfo, type StxCryptoAssetBalance, type StxCryptoAssetInfo, type StxTransfer, type SupportedBlockchains, type UtxoItem, type ValueOf, WalletDefaultNetworkConfigurationIds, bitcoinNetworkModesSchema, btcTxTimeMap, createCryptoAssetBalance, createInscription, createMarketData, createMarketPair, defaultCurrentNetwork, defaultNetworksKeyedById, formatMarketPair, networkConfigurationSchema, networkModes, testnetModes, whenInscriptionMimeType };
package/dist/index.js CHANGED
@@ -3,13 +3,13 @@ function createCryptoAssetBalance(balance) {
3
3
  return { availableBalance: balance };
4
4
  }
5
5
 
6
- // src/network.model.ts
6
+ // src/network/network.model.ts
7
7
  var HIRO_API_BASE_URL_MAINNET = "https://api.hiro.so";
8
8
  var HIRO_API_BASE_URL_TESTNET = "https://api.testnet.hiro.so";
9
9
  var HIRO_INSCRIPTIONS_API_URL = "https://api.hiro.so/ordinals/v1/inscriptions";
10
10
  var HIRO_API_BASE_URL_NAKAMOTO_TESTNET = "https://api.nakamoto.testnet.hiro.so";
11
- var BITCOIN_API_BASE_URL_MAINNET = "https://blockstream.info/api";
12
- var BITCOIN_API_BASE_URL_TESTNET = "https://blockstream.info/testnet/api";
11
+ var BITCOIN_API_BASE_URL_MAINNET = "https://leather.mempool.space/api";
12
+ var BITCOIN_API_BASE_URL_TESTNET = "https://leather.mempool.space/testnet/api";
13
13
  var BITCOIN_API_BASE_URL_SIGNET = "https://mempool.space/signet/api";
14
14
  var BESTINSLOT_API_BASE_URL_MAINNET = "https://leatherapi.bestinslot.xyz/v3";
15
15
  var BESTINSLOT_API_BASE_URL_TESTNET = "https://leatherapi_testnet.bestinslot.xyz/v3";
@@ -27,6 +27,8 @@ var WalletDefaultNetworkConfigurationIds = /* @__PURE__ */ ((WalletDefaultNetwor
27
27
  WalletDefaultNetworkConfigurationIds2["devnet"] = "devnet";
28
28
  return WalletDefaultNetworkConfigurationIds2;
29
29
  })(WalletDefaultNetworkConfigurationIds || {});
30
+ var networkModes = ["mainnet", "testnet"];
31
+ var testnetModes = ["testnet", "regtest", "signet"];
30
32
  var networkMainnet = {
31
33
  id: "mainnet" /* mainnet */,
32
34
  name: "Mainnet",
@@ -255,6 +257,27 @@ function createMarketData(pair, price) {
255
257
  throw new Error("Cannot create market data when price does not match quote");
256
258
  return Object.freeze({ pair, price });
257
259
  }
260
+
261
+ // src/network/network.schema.ts
262
+ import { z } from "zod";
263
+ var bitcoinNetworkModesSchema = z.enum([...networkModes, ...testnetModes]);
264
+ var networkConfigurationSchema = z.object({
265
+ name: z.string(),
266
+ id: z.string(),
267
+ chain: z.object({
268
+ bitcoin: z.object({
269
+ blockchain: z.literal("bitcoin"),
270
+ bitcoinUrl: z.string(),
271
+ bitcoinNetwork: bitcoinNetworkModesSchema
272
+ }),
273
+ stacks: z.object({
274
+ blockchain: z.literal("stacks"),
275
+ url: z.string(),
276
+ chainId: z.number(),
277
+ subnetChainId: z.number().optional()
278
+ })
279
+ })
280
+ });
258
281
  export {
259
282
  BESTINSLOT_API_BASE_URL_MAINNET,
260
283
  BESTINSLOT_API_BASE_URL_TESTNET,
@@ -271,6 +294,7 @@ export {
271
294
  HIRO_INSCRIPTIONS_API_URL,
272
295
  STX20_API_BASE_URL_MAINNET,
273
296
  WalletDefaultNetworkConfigurationIds,
297
+ bitcoinNetworkModesSchema,
274
298
  btcTxTimeMap,
275
299
  createCryptoAssetBalance,
276
300
  createInscription,
@@ -279,6 +303,9 @@ export {
279
303
  defaultCurrentNetwork,
280
304
  defaultNetworksKeyedById,
281
305
  formatMarketPair,
306
+ networkConfigurationSchema,
307
+ networkModes,
308
+ testnetModes,
282
309
  whenInscriptionMimeType
283
310
  };
284
311
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/crypto-assets/crypto-asset-balance.model.ts","../src/network.model.ts","../src/crypto-assets/bitcoin/inscription.model.ts","../src/fees/bitcoin-fees.model.ts","../src/fees/fees.model.ts","../src/market.model.ts"],"sourcesContent":["import { Money } from '../money.model';\n\nexport interface BaseCryptoAssetBalance {\n /**\n * totalBalance after filtering out outboundBalance, protectedBalance, and uneconomicalBalance\n */\n readonly availableBalance: Money;\n}\n\nexport interface BtcCryptoAssetBalance extends BaseCryptoAssetBalance {\n /**\n * Balance of UTXOs with collectibles\n */\n readonly protectedBalance: Money;\n /**\n * Balance across UTXOs with need for larger fee than principal by UTXO given standard rate\n */\n readonly uneconomicalBalance: Money;\n}\n\nexport interface StxCryptoAssetBalance extends BaseCryptoAssetBalance {\n /**\n * availableBalance minus lockedBalance\n */\n readonly availableUnlockedBalance: Money;\n /**\n * Balance of pending receipt into account given pending transactions\n */\n readonly inboundBalance: Money;\n /**\n * totalBalance minus total amount locked by contracts\n */\n readonly lockedBalance: Money;\n /**\n * Balance of pending delivery from account given pending transactions\n */\n readonly outboundBalance: Money;\n /**\n * totalBalance plus inboundBalance minus outboundBalance\n */\n readonly pendingBalance: Money;\n /**\n * Balance as confirmed on chain\n */\n readonly totalBalance: Money;\n /**\n * totalBalance minus lockedBalance\n */\n readonly unlockedBalance: Money;\n}\n\nexport type CryptoAssetBalance =\n | BaseCryptoAssetBalance\n | BtcCryptoAssetBalance\n | StxCryptoAssetBalance;\n\nexport function createCryptoAssetBalance(balance: Money): BaseCryptoAssetBalance {\n return { availableBalance: balance };\n}\n","import { Blockchains } from './types';\n\nexport const HIRO_API_BASE_URL_MAINNET = 'https://api.hiro.so';\nexport const HIRO_API_BASE_URL_TESTNET = 'https://api.testnet.hiro.so';\nexport const HIRO_INSCRIPTIONS_API_URL = 'https://api.hiro.so/ordinals/v1/inscriptions';\nexport const HIRO_API_BASE_URL_NAKAMOTO_TESTNET = 'https://api.nakamoto.testnet.hiro.so';\n\nexport const BITCOIN_API_BASE_URL_MAINNET = 'https://blockstream.info/api';\nexport const BITCOIN_API_BASE_URL_TESTNET = 'https://blockstream.info/testnet/api';\nexport const BITCOIN_API_BASE_URL_SIGNET = 'https://mempool.space/signet/api';\n\nexport const BESTINSLOT_API_BASE_URL_MAINNET = 'https://leatherapi.bestinslot.xyz/v3';\nexport const BESTINSLOT_API_BASE_URL_TESTNET = 'https://leatherapi_testnet.bestinslot.xyz/v3';\n\nexport const STX20_API_BASE_URL_MAINNET = 'https://api.stx20.com/api/v1';\n\n// Copied from @stacks/transactions to avoid dependencies\nexport enum ChainID {\n Testnet = 2147483648,\n Mainnet = 1,\n}\n\nexport enum WalletDefaultNetworkConfigurationIds {\n mainnet = 'mainnet',\n testnet = 'testnet',\n signet = 'signet',\n sbtcDevenv = 'sbtcDevenv',\n devnet = 'devnet',\n}\n\nexport type DefaultNetworkConfigurations = keyof typeof WalletDefaultNetworkConfigurationIds;\n\nconst supportedBlockchains = ['stacks', 'bitcoin'] as const;\n\nexport type SupportedBlockchains = (typeof supportedBlockchains)[number];\n\nconst networkModes = ['mainnet', 'testnet'] as const;\n\nexport type NetworkModes = (typeof networkModes)[number];\n\ntype BitcoinTestnetModes = 'testnet' | 'regtest' | 'signet';\n\nexport type BitcoinNetworkModes = NetworkModes | BitcoinTestnetModes;\n\ninterface BaseChainConfig {\n blockchain: Blockchains;\n}\n\nexport interface BitcoinChainConfig extends BaseChainConfig {\n blockchain: 'bitcoin';\n bitcoinUrl: string;\n bitcoinNetwork: BitcoinNetworkModes;\n}\n\nexport interface StacksChainConfig extends BaseChainConfig {\n blockchain: 'stacks';\n url: string;\n /** The chainId of the network (or parent network if this is a subnet) */\n chainId: ChainID;\n /** An additional chainId for subnets. Indicated a subnet if defined and is mainly used for signing. */\n subnetChainId?: ChainID;\n}\n\nexport interface NetworkConfiguration {\n name: string;\n id: DefaultNetworkConfigurations;\n chain: {\n bitcoin: BitcoinChainConfig;\n stacks: StacksChainConfig;\n };\n}\n\nconst networkMainnet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.mainnet,\n name: 'Mainnet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Mainnet,\n url: HIRO_API_BASE_URL_MAINNET,\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'mainnet',\n bitcoinUrl: BITCOIN_API_BASE_URL_MAINNET,\n },\n },\n};\n\nconst networkTestnet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.testnet,\n name: 'Testnet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: HIRO_API_BASE_URL_TESTNET,\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'testnet',\n bitcoinUrl: BITCOIN_API_BASE_URL_TESTNET,\n },\n },\n};\n\nconst networkSignet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.signet,\n name: 'Signet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: HIRO_API_BASE_URL_TESTNET,\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'signet',\n bitcoinUrl: BITCOIN_API_BASE_URL_SIGNET,\n },\n },\n};\n\nconst networkSbtcDevenv: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.sbtcDevenv,\n name: 'sBTC Devenv',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: 'http://localhost:3999',\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'regtest',\n bitcoinUrl: 'http://localhost:8999/api',\n },\n },\n};\n\nconst networkDevnet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.devnet,\n name: 'Devnet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: 'http://localhost:3999',\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'regtest',\n bitcoinUrl: 'http://localhost:18443',\n },\n },\n};\n\nexport const defaultCurrentNetwork: NetworkConfiguration = networkMainnet;\n\nexport const defaultNetworksKeyedById: Record<\n WalletDefaultNetworkConfigurationIds,\n NetworkConfiguration\n> = {\n [WalletDefaultNetworkConfigurationIds.mainnet]: networkMainnet,\n [WalletDefaultNetworkConfigurationIds.testnet]: networkTestnet,\n [WalletDefaultNetworkConfigurationIds.signet]: networkSignet,\n [WalletDefaultNetworkConfigurationIds.sbtcDevenv]: networkSbtcDevenv,\n [WalletDefaultNetworkConfigurationIds.devnet]: networkDevnet,\n};\n","import { HIRO_INSCRIPTIONS_API_URL } from '../../network.model';\nimport { InscriptionCryptoAssetInfo } from '../crypto-asset-info.model';\n\n/**\n * Inscriptions contain arbitrary data. When retrieving an inscription, it should be\n * classified into one of the types below, indicating that the app can handle it\n * appropriately and securely. Inscriptions of types not ready to be handled by the\n * app should be classified as \"other\".\n */\nconst inscriptionMimeTypes = [\n 'audio',\n 'gltf',\n 'html',\n 'image',\n 'svg',\n 'text',\n 'video',\n 'other',\n] as const;\n\nexport type InscriptionMimeType = (typeof inscriptionMimeTypes)[number];\n\nexport function whenInscriptionMimeType<T>(\n mimeType: string,\n branches: { [k in InscriptionMimeType]?: () => T }\n) {\n if (mimeType.startsWith('audio/') && branches.audio) {\n return branches.audio();\n }\n\n if (mimeType.startsWith('text/html') && branches.html) {\n return branches.html();\n }\n\n if (mimeType.startsWith('image/svg') && branches.svg) {\n return branches.svg();\n }\n\n if (mimeType.startsWith('image/') && branches.image) {\n return branches.image();\n }\n\n if (mimeType.startsWith('text') && branches.text) {\n return branches.text();\n }\n\n if (mimeType.startsWith('video/') && branches.video) {\n return branches.video();\n }\n\n if (mimeType.startsWith('model/gltf') && branches.gltf) {\n return branches.gltf();\n }\n\n if (branches.other) return branches.other();\n\n throw new Error('Unhandled inscription type');\n}\nexport interface Inscription extends InscriptionCryptoAssetInfo {\n preview: string;\n src: string;\n title: string;\n output: string;\n txid: string;\n offset: string;\n address: string;\n genesisBlockHash: string;\n genesisTimestamp: number;\n genesisBlockHeight: number;\n value: string;\n}\n\ninterface RawInscription {\n id: string;\n number: number;\n output: string;\n contentType: string;\n txid: string;\n offset: string;\n address: string;\n genesisBlockHash: string;\n genesisTimestamp: number;\n genesisBlockHeight: number;\n value: string;\n}\n\nexport function createInscription(inscription: RawInscription): Inscription {\n const contentSrc = `${HIRO_INSCRIPTIONS_API_URL}/${inscription.id}/content`;\n const iframeSrc = `https://ordinals.com/preview/${inscription.id}`;\n const preview = `https://ordinals.hiro.so/inscription/${inscription.id}`;\n const title = `Inscription ${inscription.number}`;\n\n const sharedInfo = {\n id: inscription.id,\n number: inscription.number,\n output: inscription.output,\n txid: inscription.txid,\n offset: inscription.offset,\n address: inscription.address,\n genesisBlockHash: inscription.genesisBlockHash,\n genesisTimestamp: inscription.genesisTimestamp,\n genesisBlockHeight: inscription.genesisBlockHeight,\n value: inscription.value,\n preview,\n title,\n };\n\n return whenInscriptionMimeType<Inscription>(inscription.contentType, {\n audio: () => ({\n ...sharedInfo,\n mimeType: 'audio',\n name: 'inscription',\n src: iframeSrc,\n }),\n gltf: () => ({\n ...sharedInfo,\n mimeType: 'gltf',\n name: 'inscription',\n src: iframeSrc,\n }),\n html: () => ({\n ...sharedInfo,\n mimeType: 'html',\n name: 'inscription',\n src: iframeSrc,\n }),\n image: () => ({\n ...sharedInfo,\n mimeType: 'image',\n name: 'inscription',\n src: contentSrc,\n }),\n svg: () => ({\n ...sharedInfo,\n mimeType: 'svg',\n name: 'inscription',\n src: iframeSrc,\n }),\n text: () => ({\n ...sharedInfo,\n mimeType: 'text',\n name: 'inscription',\n src: contentSrc,\n }),\n video: () => ({\n ...sharedInfo,\n mimeType: 'video',\n name: 'inscription',\n src: iframeSrc,\n }),\n other: () => ({\n ...sharedInfo,\n mimeType: 'other',\n name: 'inscription',\n src: '',\n }),\n });\n}\n","import type BigNumber from 'bignumber.js';\n\nexport interface AverageBitcoinFeeRates {\n fastestFee: BigNumber;\n halfHourFee: BigNumber;\n hourFee: BigNumber;\n}\n\nexport const btcTxTimeMap: Record<keyof AverageBitcoinFeeRates, string> = {\n fastestFee: '~10 – 20min',\n halfHourFee: '~30 min',\n hourFee: '~1 hour+',\n};\n\nexport enum BtcFeeType {\n High = 'High',\n Standard = 'Standard',\n Low = 'Low',\n}\n","import { Blockchains } from '../types';\nimport { StacksFeeEstimate } from './stacks-fees.model';\n\nexport enum FeeTypes {\n Low,\n Middle,\n High,\n Custom,\n Unknown,\n}\n\nexport enum FeeCalculationTypes {\n Api = 'api',\n Default = 'default',\n DefaultSimulated = 'default-simulated',\n FeesCapped = 'fees-capped',\n}\n\nexport interface Fees {\n blockchain: Blockchains;\n estimates: StacksFeeEstimate[];\n calculation: FeeCalculationTypes;\n}\n","import type { CryptoCurrencies, FiatCurrencies } from './currencies.model';\nimport type { Money } from './money.model';\n\ninterface MarketPair {\n readonly base: CryptoCurrencies;\n readonly quote: FiatCurrencies;\n}\n\nexport function createMarketPair(base: CryptoCurrencies, quote: FiatCurrencies): MarketPair {\n return Object.freeze({ base, quote });\n}\n\nexport function formatMarketPair({ base, quote }: MarketPair) {\n return `${base}/${quote}`;\n}\n\nexport interface MarketData {\n readonly pair: MarketPair;\n readonly price: Money;\n}\n\nexport function createMarketData(pair: MarketPair, price: Money): MarketData {\n if (pair.quote !== price.symbol)\n throw new Error('Cannot create market data when price does not match quote');\n return Object.freeze({ pair, price });\n}\n"],"mappings":";AAwDO,SAAS,yBAAyB,SAAwC;AAC/E,SAAO,EAAE,kBAAkB,QAAQ;AACrC;;;ACxDO,IAAM,4BAA4B;AAClC,IAAM,4BAA4B;AAClC,IAAM,4BAA4B;AAClC,IAAM,qCAAqC;AAE3C,IAAM,+BAA+B;AACrC,IAAM,+BAA+B;AACrC,IAAM,8BAA8B;AAEpC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AAExC,IAAM,6BAA6B;AAGnC,IAAK,UAAL,kBAAKA,aAAL;AACL,EAAAA,kBAAA,aAAU,cAAV;AACA,EAAAA,kBAAA,aAAU,KAAV;AAFU,SAAAA;AAAA,GAAA;AAKL,IAAK,uCAAL,kBAAKC,0CAAL;AACL,EAAAA,sCAAA,aAAU;AACV,EAAAA,sCAAA,aAAU;AACV,EAAAA,sCAAA,YAAS;AACT,EAAAA,sCAAA,gBAAa;AACb,EAAAA,sCAAA,YAAS;AALC,SAAAA;AAAA,GAAA;AAkDZ,IAAM,iBAAuC;AAAA,EAC3C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,KAAK;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACd;AAAA,EACF;AACF;AAEA,IAAM,iBAAuC;AAAA,EAC3C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,KAAK;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP,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AAO,OAAO,OAAO,EAAE,MAAM,MAAM,CAAC;AACtC;AAEO,SAAS,iBAAiB,EAAE,MAAM,MAAM,GAAe;AAC5D,SAAO,GAAG,IAAI,IAAI,KAAK;AACzB;AAOO,SAAS,iBAAiB,MAAkB,OAA0B;AAC3E,MAAI,KAAK,UAAU,MAAM;AACvB,UAAM,IAAI,MAAM,2DAA2D;AAC7E,SAAO,OAAO,OAAO,EAAE,MAAM,MAAM,CAAC;AACtC;","names":["ChainID","WalletDefaultNetworkConfigurationIds","BtcFeeType","FeeTypes","FeeCalculationTypes"]}
1
+ {"version":3,"sources":["../src/crypto-assets/crypto-asset-balance.model.ts","../src/network/network.model.ts","../src/crypto-assets/bitcoin/inscription.model.ts","../src/fees/bitcoin-fees.model.ts","../src/fees/fees.model.ts","../src/market.model.ts","../src/network/network.schema.ts"],"sourcesContent":["import { Money } from '../money.model';\n\nexport interface BaseCryptoAssetBalance {\n /**\n * totalBalance after filtering out outboundBalance, protectedBalance, and uneconomicalBalance\n */\n readonly availableBalance: Money;\n}\n\nexport interface BtcCryptoAssetBalance extends BaseCryptoAssetBalance {\n /**\n * Balance of UTXOs with collectibles\n */\n readonly protectedBalance: Money;\n /**\n * Balance across UTXOs with need for larger fee than principal by UTXO given standard rate\n */\n readonly uneconomicalBalance: Money;\n}\n\nexport interface StxCryptoAssetBalance extends BaseCryptoAssetBalance {\n /**\n * availableBalance minus lockedBalance\n */\n readonly availableUnlockedBalance: Money;\n /**\n * Balance of pending receipt into account given pending transactions\n */\n readonly inboundBalance: Money;\n /**\n * totalBalance minus total amount locked by contracts\n */\n readonly lockedBalance: Money;\n /**\n * Balance of pending delivery from account given pending transactions\n */\n readonly outboundBalance: Money;\n /**\n * totalBalance plus inboundBalance minus outboundBalance\n */\n readonly pendingBalance: Money;\n /**\n * Balance as confirmed on chain\n */\n readonly totalBalance: Money;\n /**\n * totalBalance minus lockedBalance\n */\n readonly unlockedBalance: Money;\n}\n\nexport type CryptoAssetBalance =\n | BaseCryptoAssetBalance\n | BtcCryptoAssetBalance\n | StxCryptoAssetBalance;\n\nexport function createCryptoAssetBalance(balance: Money): BaseCryptoAssetBalance {\n return { availableBalance: balance };\n}\n","import { z } from 'zod';\n\nimport { Blockchains } from '../types';\nimport { networkConfigurationSchema } from './network.schema';\n\nexport const HIRO_API_BASE_URL_MAINNET = 'https://api.hiro.so';\nexport const HIRO_API_BASE_URL_TESTNET = 'https://api.testnet.hiro.so';\nexport const HIRO_INSCRIPTIONS_API_URL = 'https://api.hiro.so/ordinals/v1/inscriptions';\nexport const HIRO_API_BASE_URL_NAKAMOTO_TESTNET = 'https://api.nakamoto.testnet.hiro.so';\n\nexport const BITCOIN_API_BASE_URL_MAINNET = 'https://leather.mempool.space/api';\nexport const BITCOIN_API_BASE_URL_TESTNET = 'https://leather.mempool.space/testnet/api';\nexport const BITCOIN_API_BASE_URL_SIGNET = 'https://mempool.space/signet/api';\n\nexport const BESTINSLOT_API_BASE_URL_MAINNET = 'https://leatherapi.bestinslot.xyz/v3';\nexport const BESTINSLOT_API_BASE_URL_TESTNET = 'https://leatherapi_testnet.bestinslot.xyz/v3';\n\nexport const STX20_API_BASE_URL_MAINNET = 'https://api.stx20.com/api/v1';\n\n// Copied from @stacks/transactions to avoid dependencies\nexport enum ChainID {\n Testnet = 2147483648,\n Mainnet = 1,\n}\n\nexport enum WalletDefaultNetworkConfigurationIds {\n mainnet = 'mainnet',\n testnet = 'testnet',\n signet = 'signet',\n sbtcDevenv = 'sbtcDevenv',\n devnet = 'devnet',\n}\n\nexport type DefaultNetworkConfigurations = keyof typeof WalletDefaultNetworkConfigurationIds;\n\nconst supportedBlockchains = ['stacks', 'bitcoin'] as const;\n\nexport type SupportedBlockchains = (typeof supportedBlockchains)[number];\n\nexport const networkModes = ['mainnet', 'testnet'] as const;\nexport const testnetModes = ['testnet', 'regtest', 'signet'] as const;\n\nexport type NetworkModes = (typeof networkModes)[number];\ntype BitcoinTestnetModes = (typeof testnetModes)[number];\n\nexport type BitcoinNetworkModes = NetworkModes | BitcoinTestnetModes;\n\ninterface BaseChainConfig {\n blockchain: Blockchains;\n}\n\nexport interface BitcoinChainConfig extends BaseChainConfig {\n blockchain: 'bitcoin';\n bitcoinUrl: string;\n bitcoinNetwork: BitcoinNetworkModes;\n}\n\nexport interface StacksChainConfig extends BaseChainConfig {\n blockchain: 'stacks';\n url: string;\n /** The chainId of the network (or parent network if this is a subnet) */\n chainId: ChainID;\n /** An additional chainId for subnets. Indicated a subnet if defined and is mainly used for signing. */\n subnetChainId?: ChainID;\n}\n\nexport type NetworkConfiguration = z.infer<typeof networkConfigurationSchema>;\n\nconst networkMainnet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.mainnet,\n name: 'Mainnet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Mainnet,\n url: HIRO_API_BASE_URL_MAINNET,\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'mainnet',\n bitcoinUrl: BITCOIN_API_BASE_URL_MAINNET,\n },\n },\n};\n\nconst networkTestnet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.testnet,\n name: 'Testnet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: HIRO_API_BASE_URL_TESTNET,\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'testnet',\n bitcoinUrl: BITCOIN_API_BASE_URL_TESTNET,\n },\n },\n};\n\nconst networkSignet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.signet,\n name: 'Signet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: HIRO_API_BASE_URL_TESTNET,\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'signet',\n bitcoinUrl: BITCOIN_API_BASE_URL_SIGNET,\n },\n },\n};\n\nconst networkSbtcDevenv: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.sbtcDevenv,\n name: 'sBTC Devenv',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: 'http://localhost:3999',\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'regtest',\n bitcoinUrl: 'http://localhost:8999/api',\n },\n },\n};\n\nconst networkDevnet: NetworkConfiguration = {\n id: WalletDefaultNetworkConfigurationIds.devnet,\n name: 'Devnet',\n chain: {\n stacks: {\n blockchain: 'stacks',\n chainId: ChainID.Testnet,\n url: 'http://localhost:3999',\n },\n bitcoin: {\n blockchain: 'bitcoin',\n bitcoinNetwork: 'regtest',\n bitcoinUrl: 'http://localhost:18443',\n },\n },\n};\n\nexport const defaultCurrentNetwork: NetworkConfiguration = networkMainnet;\n\nexport const defaultNetworksKeyedById: Record<\n WalletDefaultNetworkConfigurationIds,\n NetworkConfiguration\n> = {\n [WalletDefaultNetworkConfigurationIds.mainnet]: networkMainnet,\n [WalletDefaultNetworkConfigurationIds.testnet]: networkTestnet,\n [WalletDefaultNetworkConfigurationIds.signet]: networkSignet,\n [WalletDefaultNetworkConfigurationIds.sbtcDevenv]: networkSbtcDevenv,\n [WalletDefaultNetworkConfigurationIds.devnet]: networkDevnet,\n};\n","import { HIRO_INSCRIPTIONS_API_URL } from '../../network/network.model';\nimport { InscriptionCryptoAssetInfo } from '../crypto-asset-info.model';\n\n/**\n * Inscriptions contain arbitrary data. When retrieving an inscription, it should be\n * classified into one of the types below, indicating that the app can handle it\n * appropriately and securely. Inscriptions of types not ready to be handled by the\n * app should be classified as \"other\".\n */\nconst inscriptionMimeTypes = [\n 'audio',\n 'gltf',\n 'html',\n 'image',\n 'svg',\n 'text',\n 'video',\n 'other',\n] as const;\n\nexport type InscriptionMimeType = (typeof inscriptionMimeTypes)[number];\n\nexport function whenInscriptionMimeType<T>(\n mimeType: string,\n branches: { [k in InscriptionMimeType]?: () => T }\n) {\n if (mimeType.startsWith('audio/') && branches.audio) {\n return branches.audio();\n }\n\n if (mimeType.startsWith('text/html') && branches.html) {\n return branches.html();\n }\n\n if (mimeType.startsWith('image/svg') && branches.svg) {\n return branches.svg();\n }\n\n if (mimeType.startsWith('image/') && branches.image) {\n return branches.image();\n }\n\n if (mimeType.startsWith('text') && branches.text) {\n return branches.text();\n }\n\n if (mimeType.startsWith('video/') && branches.video) {\n return branches.video();\n }\n\n if (mimeType.startsWith('model/gltf') && branches.gltf) {\n return branches.gltf();\n }\n\n if (branches.other) return branches.other();\n\n throw new Error('Unhandled inscription type');\n}\nexport interface Inscription extends InscriptionCryptoAssetInfo {\n preview: string;\n src: string;\n title: string;\n output: string;\n txid: string;\n offset: string;\n address: string;\n genesisBlockHash: string;\n genesisTimestamp: number;\n genesisBlockHeight: number;\n value: string;\n}\n\ninterface RawInscription {\n id: string;\n number: number;\n output: string;\n contentType: string;\n txid: string;\n offset: string;\n address: string;\n genesisBlockHash: string;\n genesisTimestamp: number;\n genesisBlockHeight: number;\n value: string;\n}\n\nexport function createInscription(inscription: RawInscription): Inscription {\n const contentSrc = `${HIRO_INSCRIPTIONS_API_URL}/${inscription.id}/content`;\n const iframeSrc = `https://ordinals.com/preview/${inscription.id}`;\n const preview = `https://ordinals.hiro.so/inscription/${inscription.id}`;\n const title = `Inscription ${inscription.number}`;\n\n const sharedInfo = {\n id: inscription.id,\n number: inscription.number,\n output: inscription.output,\n txid: inscription.txid,\n offset: inscription.offset,\n address: inscription.address,\n genesisBlockHash: inscription.genesisBlockHash,\n genesisTimestamp: inscription.genesisTimestamp,\n genesisBlockHeight: inscription.genesisBlockHeight,\n value: inscription.value,\n preview,\n title,\n };\n\n return whenInscriptionMimeType<Inscription>(inscription.contentType, {\n audio: () => ({\n ...sharedInfo,\n mimeType: 'audio',\n name: 'inscription',\n src: iframeSrc,\n }),\n gltf: () => ({\n ...sharedInfo,\n mimeType: 'gltf',\n name: 'inscription',\n src: iframeSrc,\n }),\n html: () => ({\n ...sharedInfo,\n mimeType: 'html',\n name: 'inscription',\n src: iframeSrc,\n }),\n image: () => ({\n ...sharedInfo,\n mimeType: 'image',\n name: 'inscription',\n src: contentSrc,\n }),\n svg: () => ({\n ...sharedInfo,\n mimeType: 'svg',\n name: 'inscription',\n src: iframeSrc,\n }),\n text: () => ({\n ...sharedInfo,\n mimeType: 'text',\n name: 'inscription',\n src: contentSrc,\n }),\n video: () => ({\n ...sharedInfo,\n mimeType: 'video',\n name: 'inscription',\n src: iframeSrc,\n }),\n other: () => ({\n ...sharedInfo,\n mimeType: 'other',\n name: 'inscription',\n src: '',\n }),\n });\n}\n","import type BigNumber from 'bignumber.js';\n\nexport interface AverageBitcoinFeeRates {\n fastestFee: BigNumber;\n halfHourFee: BigNumber;\n hourFee: BigNumber;\n}\n\nexport const btcTxTimeMap: Record<keyof AverageBitcoinFeeRates, string> = {\n fastestFee: '~10 – 20min',\n halfHourFee: '~30 min',\n hourFee: '~1 hour+',\n};\n\nexport enum BtcFeeType {\n High = 'High',\n Standard = 'Standard',\n Low = 'Low',\n}\n","import { Blockchains } from '../types';\nimport { StacksFeeEstimate } from './stacks-fees.model';\n\nexport enum FeeTypes {\n Low,\n Middle,\n High,\n Custom,\n Unknown,\n}\n\nexport enum FeeCalculationTypes {\n Api = 'api',\n Default = 'default',\n DefaultSimulated = 'default-simulated',\n FeesCapped = 'fees-capped',\n}\n\nexport interface Fees {\n blockchain: Blockchains;\n estimates: StacksFeeEstimate[];\n calculation: FeeCalculationTypes;\n}\n","import type { CryptoCurrencies, FiatCurrencies } from './currencies.model';\nimport type { Money } from './money.model';\n\ninterface MarketPair {\n readonly base: CryptoCurrencies;\n readonly quote: FiatCurrencies;\n}\n\nexport function createMarketPair(base: CryptoCurrencies, quote: FiatCurrencies): MarketPair {\n return Object.freeze({ base, quote });\n}\n\nexport function formatMarketPair({ base, quote }: MarketPair) {\n return `${base}/${quote}`;\n}\n\nexport interface MarketData {\n readonly pair: MarketPair;\n readonly price: Money;\n}\n\nexport function createMarketData(pair: MarketPair, price: Money): MarketData {\n if (pair.quote !== price.symbol)\n throw new Error('Cannot create market data when price does not match quote');\n return Object.freeze({ pair, price });\n}\n","import { z } from 'zod';\n\nimport { networkModes, testnetModes } from './network.model';\n\nexport const bitcoinNetworkModesSchema = z.enum([...networkModes, ...testnetModes]);\n\nexport const networkConfigurationSchema = z.object({\n name: z.string(),\n id: z.string(),\n chain: z.object({\n bitcoin: z.object({\n blockchain: z.literal('bitcoin'),\n bitcoinUrl: z.string(),\n bitcoinNetwork: bitcoinNetworkModesSchema,\n }),\n stacks: z.object({\n blockchain: z.literal('stacks'),\n url: z.string(),\n chainId: z.number(),\n subnetChainId: z.number().optional(),\n }),\n }),\n});\n"],"mappings":";AAwDO,SAAS,yBAAyB,SAAwC;AAC/E,SAAO,EAAE,kBAAkB,QAAQ;AACrC;;;ACrDO,IAAM,4BAA4B;AAClC,IAAM,4BAA4B;AAClC,IAAM,4BAA4B;AAClC,IAAM,qCAAqC;AAE3C,IAAM,+BAA+B;AACrC,IAAM,+BAA+B;AACrC,IAAM,8BAA8B;AAEpC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AAExC,IAAM,6BAA6B;AAGnC,IAAK,UAAL,kBAAKA,aAAL;AACL,EAAAA,kBAAA,aAAU,cAAV;AACA,EAAAA,kBAAA,aAAU,KAAV;AAFU,SAAAA;AAAA,GAAA;AAKL,IAAK,uCAAL,kBAAKC,0CAAL;AACL,EAAAA,sCAAA,aAAU;AACV,EAAAA,sCAAA,aAAU;AACV,EAAAA,sCAAA,YAAS;AACT,EAAAA,sCAAA,gBAAa;AACb,EAAAA,sCAAA,YAAS;AALC,SAAAA;AAAA,GAAA;AAcL,IAAM,eAAe,CAAC,WAAW,SAAS;AAC1C,IAAM,eAAe,CAAC,WAAW,WAAW,QAAQ;AA4B3D,IAAM,iBAAuC;AAAA,EAC3C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,KAAK;AAAA,IACP;AAAA,IACA,S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": "@leather.io/models",
3
3
  "author": "Leather.io contact@leather.io",
4
4
  "description": "Leather models and types",
5
- "version": "0.10.1",
5
+ "version": "0.11.0",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/leather-io/mono/tree/dev/packages/models",
8
8
  "repository": {
@@ -17,7 +17,8 @@
17
17
  "bugs": "https://github.com/leather-io/mono/issues",
18
18
  "dependencies": {
19
19
  "@stacks/stacks-blockchain-api-types": "7.8.2",
20
- "bignumber.js": "9.1.2"
20
+ "bignumber.js": "9.1.2",
21
+ "zod": "3.23.6"
21
22
  },
22
23
  "devDependencies": {
23
24
  "eslint": "8.53.0",
@@ -25,8 +26,8 @@
25
26
  "tsup": "8.1.0",
26
27
  "typescript": "5.4.5",
27
28
  "@leather.io/prettier-config": "0.5.0",
28
- "@leather.io/eslint-config": "0.6.1",
29
- "@leather.io/tsconfig-config": "0.5.0"
29
+ "@leather.io/tsconfig-config": "0.5.1",
30
+ "@leather.io/eslint-config": "0.6.1"
30
31
  },
31
32
  "keywords": [
32
33
  "leather",
@@ -1,4 +1,4 @@
1
- import { HIRO_INSCRIPTIONS_API_URL } from '../../network.model';
1
+ import { HIRO_INSCRIPTIONS_API_URL } from '../../network/network.model';
2
2
  import { InscriptionCryptoAssetInfo } from '../crypto-asset-info.model';
3
3
 
4
4
  /**
package/src/index.ts CHANGED
@@ -9,7 +9,8 @@ export * from './market.model';
9
9
  export * from './types';
10
10
  export * from './types.utils';
11
11
  export * from './money.model';
12
- export * from './network.model';
12
+ export * from './network/network.model';
13
+ export * from './network/network.schema';
13
14
  export * from './transactions/bitcoin-transaction.model';
14
15
  export * from './transactions/stacks-transaction.model';
15
16
  export * from './utxo.model';
@@ -1,12 +1,15 @@
1
- import { Blockchains } from './types';
1
+ import { z } from 'zod';
2
+
3
+ import { Blockchains } from '../types';
4
+ import { networkConfigurationSchema } from './network.schema';
2
5
 
3
6
  export const HIRO_API_BASE_URL_MAINNET = 'https://api.hiro.so';
4
7
  export const HIRO_API_BASE_URL_TESTNET = 'https://api.testnet.hiro.so';
5
8
  export const HIRO_INSCRIPTIONS_API_URL = 'https://api.hiro.so/ordinals/v1/inscriptions';
6
9
  export const HIRO_API_BASE_URL_NAKAMOTO_TESTNET = 'https://api.nakamoto.testnet.hiro.so';
7
10
 
8
- export const BITCOIN_API_BASE_URL_MAINNET = 'https://blockstream.info/api';
9
- export const BITCOIN_API_BASE_URL_TESTNET = 'https://blockstream.info/testnet/api';
11
+ export const BITCOIN_API_BASE_URL_MAINNET = 'https://leather.mempool.space/api';
12
+ export const BITCOIN_API_BASE_URL_TESTNET = 'https://leather.mempool.space/testnet/api';
10
13
  export const BITCOIN_API_BASE_URL_SIGNET = 'https://mempool.space/signet/api';
11
14
 
12
15
  export const BESTINSLOT_API_BASE_URL_MAINNET = 'https://leatherapi.bestinslot.xyz/v3';
@@ -34,11 +37,11 @@ const supportedBlockchains = ['stacks', 'bitcoin'] as const;
34
37
 
35
38
  export type SupportedBlockchains = (typeof supportedBlockchains)[number];
36
39
 
37
- const networkModes = ['mainnet', 'testnet'] as const;
40
+ export const networkModes = ['mainnet', 'testnet'] as const;
41
+ export const testnetModes = ['testnet', 'regtest', 'signet'] as const;
38
42
 
39
43
  export type NetworkModes = (typeof networkModes)[number];
40
-
41
- type BitcoinTestnetModes = 'testnet' | 'regtest' | 'signet';
44
+ type BitcoinTestnetModes = (typeof testnetModes)[number];
42
45
 
43
46
  export type BitcoinNetworkModes = NetworkModes | BitcoinTestnetModes;
44
47
 
@@ -61,14 +64,7 @@ export interface StacksChainConfig extends BaseChainConfig {
61
64
  subnetChainId?: ChainID;
62
65
  }
63
66
 
64
- export interface NetworkConfiguration {
65
- name: string;
66
- id: DefaultNetworkConfigurations;
67
- chain: {
68
- bitcoin: BitcoinChainConfig;
69
- stacks: StacksChainConfig;
70
- };
71
- }
67
+ export type NetworkConfiguration = z.infer<typeof networkConfigurationSchema>;
72
68
 
73
69
  const networkMainnet: NetworkConfiguration = {
74
70
  id: WalletDefaultNetworkConfigurationIds.mainnet,
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+
3
+ import { networkModes, testnetModes } from './network.model';
4
+
5
+ export const bitcoinNetworkModesSchema = z.enum([...networkModes, ...testnetModes]);
6
+
7
+ export const networkConfigurationSchema = z.object({
8
+ name: z.string(),
9
+ id: z.string(),
10
+ chain: z.object({
11
+ bitcoin: z.object({
12
+ blockchain: z.literal('bitcoin'),
13
+ bitcoinUrl: z.string(),
14
+ bitcoinNetwork: bitcoinNetworkModesSchema,
15
+ }),
16
+ stacks: z.object({
17
+ blockchain: z.literal('stacks'),
18
+ url: z.string(),
19
+ chainId: z.number(),
20
+ subnetChainId: z.number().optional(),
21
+ }),
22
+ }),
23
+ });