@leather.io/models 0.15.0 → 0.17.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.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +14 -0
- package/dist/index.d.ts +11 -7
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/settings.model.ts +15 -0
- package/src/types.ts +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @leather.io/models@0.
|
|
2
|
+
> @leather.io/models@0.17.0 build /home/runner/work/mono/mono/packages/models
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
CLI Building entry: src/index.ts
|
|
@@ -8,9 +8,9 @@ CLI tsup v8.1.0
|
|
|
8
8
|
CLI Using tsup config: /home/runner/work/mono/mono/packages/models/tsup.config.ts
|
|
9
9
|
CLI Target: es2022
|
|
10
10
|
ESM Build start
|
|
11
|
-
ESM dist/index.js 9.
|
|
12
|
-
ESM dist/index.js.map 18.
|
|
13
|
-
ESM ⚡️ Build success in
|
|
11
|
+
ESM dist/index.js 9.25 KB
|
|
12
|
+
ESM dist/index.js.map 18.75 KB
|
|
13
|
+
ESM ⚡️ Build success in 31ms
|
|
14
14
|
DTS Build start
|
|
15
|
-
DTS ⚡️ Build success in
|
|
16
|
-
DTS dist/index.d.ts
|
|
15
|
+
DTS ⚡️ Build success in 1656ms
|
|
16
|
+
DTS dist/index.d.ts 16.16 KB
|
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,20 @@
|
|
|
24
24
|
* devDependencies
|
|
25
25
|
* @leather.io/eslint-config bumped to 0.7.0
|
|
26
26
|
|
|
27
|
+
## [0.17.0](https://github.com/leather-io/mono/compare/@leather.io/models-v0.16.0...@leather.io/models-v0.17.0) (2024-09-27)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* settings notifications, closes leather-io/issues[#195](https://github.com/leather-io/mono/issues/195) ([498a1db](https://github.com/leather-io/mono/commit/498a1dbfeb48bf65e2c415b5acb96c91b1f5675c))
|
|
33
|
+
|
|
34
|
+
## [0.16.0](https://github.com/leather-io/mono/compare/@leather.io/models-v0.15.0...@leather.io/models-v0.16.0) (2024-09-24)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* settings security, closes leather-io/issues[#304](https://github.com/leather-io/mono/issues/304) ([936fa26](https://github.com/leather-io/mono/commit/936fa2674ad1ae4342ec7aa70290005867816b6b))
|
|
40
|
+
|
|
27
41
|
## [0.15.0](https://github.com/leather-io/mono/compare/@leather.io/models-v0.14.0...@leather.io/models-v0.15.0) (2024-09-20)
|
|
28
42
|
|
|
29
43
|
|
package/dist/index.d.ts
CHANGED
|
@@ -187,12 +187,6 @@ declare enum BtcFeeType {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
type Blockchain = LiteralUnion<'bitcoin' | 'stacks', string>;
|
|
190
|
-
type AccountDisplayPreference = 'ns' | 'tr' | 'bns' | 'stacks';
|
|
191
|
-
interface AccountDisplayPreferenceInfo {
|
|
192
|
-
type: AccountDisplayPreference;
|
|
193
|
-
blockchain: Blockchain;
|
|
194
|
-
name: string;
|
|
195
|
-
}
|
|
196
190
|
|
|
197
191
|
interface StacksFeeEstimate {
|
|
198
192
|
fee: Money;
|
|
@@ -374,6 +368,16 @@ type NetworkConfiguration = z.infer<typeof networkConfigurationSchema>;
|
|
|
374
368
|
declare const defaultCurrentNetwork: NetworkConfiguration;
|
|
375
369
|
declare const defaultNetworksKeyedById: Record<WalletDefaultNetworkConfigurationIds, NetworkConfiguration>;
|
|
376
370
|
|
|
371
|
+
type AccountDisplayPreference = 'native-segwit' | 'taproot' | 'bns' | 'stacks';
|
|
372
|
+
interface AccountDisplayPreferenceInfo {
|
|
373
|
+
type: AccountDisplayPreference;
|
|
374
|
+
blockchain: Blockchain;
|
|
375
|
+
name: string;
|
|
376
|
+
}
|
|
377
|
+
type AnalyticsPreference = 'consent-given' | 'rejects-tracking';
|
|
378
|
+
declare const emailAddressSchema: z.ZodString;
|
|
379
|
+
type EmailAddress = z.infer<typeof emailAddressSchema>;
|
|
380
|
+
|
|
377
381
|
interface BitcoinTransactionIssuance {
|
|
378
382
|
asset_id: string;
|
|
379
383
|
is_reissuance: boolean;
|
|
@@ -461,4 +465,4 @@ interface UtxoItem {
|
|
|
461
465
|
value: number;
|
|
462
466
|
}
|
|
463
467
|
|
|
464
|
-
export { type AccountDisplayPreference, type AccountDisplayPreferenceInfo, 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 BitcoinUnit, type BitcoinUnitInfo, type BitcoinUnitSymbol, type Blockchain, type Brc20CryptoAssetInfo, type BtcCryptoAssetBalance, type BtcCryptoAssetInfo, BtcFeeType, ChainID, type CryptoAssetBalance, type CryptoCurrency, type Currency, type DefaultNetworkConfigurations, type Entries, FeeCalculationTypes, FeeTypes, type Fees, type FiatCurrency, type FtTransfer, HIRO_API_BASE_URL_MAINNET, HIRO_API_BASE_URL_MAINNET_EXTENDED, HIRO_API_BASE_URL_NAKAMOTO_TESTNET, HIRO_API_BASE_URL_TESTNET, HIRO_API_BASE_URL_TESTNET_EXTENDED, 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 };
|
|
468
|
+
export { type AccountDisplayPreference, type AccountDisplayPreferenceInfo, type AllowAdditionalProperties, type AnalyticsPreference, 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 BitcoinUnit, type BitcoinUnitInfo, type BitcoinUnitSymbol, type Blockchain, type Brc20CryptoAssetInfo, type BtcCryptoAssetBalance, type BtcCryptoAssetInfo, BtcFeeType, ChainID, type CryptoAssetBalance, type CryptoCurrency, type Currency, type DefaultNetworkConfigurations, type EmailAddress, type Entries, FeeCalculationTypes, FeeTypes, type Fees, type FiatCurrency, type FtTransfer, HIRO_API_BASE_URL_MAINNET, HIRO_API_BASE_URL_MAINNET_EXTENDED, HIRO_API_BASE_URL_NAKAMOTO_TESTNET, HIRO_API_BASE_URL_TESTNET, HIRO_API_BASE_URL_TESTNET_EXTENDED, 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, emailAddressSchema, formatMarketPair, networkConfigurationSchema, networkModes, testnetModes, whenInscriptionMimeType };
|
package/dist/index.js
CHANGED
|
@@ -280,6 +280,10 @@ var networkConfigurationSchema = z.object({
|
|
|
280
280
|
})
|
|
281
281
|
})
|
|
282
282
|
});
|
|
283
|
+
|
|
284
|
+
// src/settings.model.ts
|
|
285
|
+
import { z as z2 } from "zod";
|
|
286
|
+
var emailAddressSchema = z2.string().email({ message: "Invalid email address" });
|
|
283
287
|
export {
|
|
284
288
|
BESTINSLOT_API_BASE_URL_MAINNET,
|
|
285
289
|
BESTINSLOT_API_BASE_URL_TESTNET,
|
|
@@ -306,6 +310,7 @@ export {
|
|
|
306
310
|
createMarketPair,
|
|
307
311
|
defaultCurrentNetwork,
|
|
308
312
|
defaultNetworksKeyedById,
|
|
313
|
+
emailAddressSchema,
|
|
309
314
|
formatMarketPair,
|
|
310
315
|
networkConfigurationSchema,
|
|
311
316
|
networkModes,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 { Blockchain } 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 HIRO_API_BASE_URL_MAINNET_EXTENDED = 'https://api.hiro.so/extended/v1';\nexport const HIRO_API_BASE_URL_TESTNET_EXTENDED = 'https://api.testnet.hiro.so/extended';\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: Blockchain;\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 { Blockchain } 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: Blockchain;\n estimates: StacksFeeEstimate[];\n calculation: FeeCalculationTypes;\n}\n","import type { CryptoCurrency, FiatCurrency } from './currencies.model';\nimport type { Money } from './money.model';\n\ninterface MarketPair {\n readonly base: CryptoCurrency;\n readonly quote: FiatCurrency;\n}\n\nexport function createMarketPair(base: CryptoCurrency, quote: FiatCurrency): 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;AACr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BAAiB,MAAkB,OAA0B;AAC3E,MAAI,KAAK,UAAU,MAAM;AACvB,UAAM,IAAI,MAAM,2DAA2D;AAC7E,SAAO,OAAO,OAAO,EAAE,MAAM,MAAM,CAAC;AACtC;;;ACzBA,SAAS,SAAS;AAIX,IAAM,4BAA4B,EAAE,KAAK,CAAC,GAAG,cAAc,GAAG,YAAY,CAAC;AAE3E,IAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM,EAAE,OAAO;AAAA,EACf,IAAI,EAAE,OAAO;AAAA,EACb,OAAO,EAAE,OAAO;AAAA,IACd,SAAS,EAAE,OAAO;AAAA,MAChB,YAAY,EAAE,QAAQ,SAAS;AAAA,MAC/B,YAAY,EAAE,OAAO;AAAA,MACrB,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACD,QAAQ,EAAE,OAAO;AAAA,MACf,YAAY,EAAE,QAAQ,QAAQ;AAAA,MAC9B,KAAK,EAAE,OAAO;AAAA,MACd,SAAS,EAAE,OAAO;AAAA,MAClB,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,IACrC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","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","../src/settings.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 { z } from 'zod';\n\nimport { Blockchain } 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 HIRO_API_BASE_URL_MAINNET_EXTENDED = 'https://api.hiro.so/extended/v1';\nexport const HIRO_API_BASE_URL_TESTNET_EXTENDED = 'https://api.testnet.hiro.so/extended';\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: Blockchain;\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 { Blockchain } 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: Blockchain;\n estimates: StacksFeeEstimate[];\n calculation: FeeCalculationTypes;\n}\n","import type { CryptoCurrency, FiatCurrency } from './currencies.model';\nimport type { Money } from './money.model';\n\ninterface MarketPair {\n readonly base: CryptoCurrency;\n readonly quote: FiatCurrency;\n}\n\nexport function createMarketPair(base: CryptoCurrency, quote: FiatCurrency): 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","import { z } from 'zod';\n\nimport { Blockchain } from './types';\n\nexport type AccountDisplayPreference = 'native-segwit' | 'taproot' | 'bns' | 'stacks';\nexport interface AccountDisplayPreferenceInfo {\n type: AccountDisplayPreference;\n blockchain: Blockchain;\n name: string;\n}\n\nexport type AnalyticsPreference = 'consent-given' | 'rejects-tracking';\n\nexport const emailAddressSchema = z.string().email({ message: 'Invalid email address' });\nexport type EmailAddress = z.infer<typeof emailAddressSchema>;\n"],"mappings":";AAw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,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;;;ACzBA,SAAS,SAAS;AAIX,IAAM,4BAA4B,EAAE,KAAK,CAAC,GAAG,cAAc,GAAG,YAAY,CAAC;AAE3E,IAAM,6BAA6B,EAAE,OAAO;AAAA,EACjD,MAAM,EAAE,OAAO;AAAA,EACf,IAAI,EAAE,OAAO;AAAA,EACb,OAAO,EAAE,OAAO;AAAA,IACd,SAAS,EAAE,OAAO;AAAA,MAChB,YAAY,EAAE,QAAQ,SAAS;AAAA,MAC/B,YAAY,EAAE,OAAO;AAAA,MACrB,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACD,QAAQ,EAAE,OAAO;AAAA,MACf,YAAY,EAAE,QAAQ,QAAQ;AAAA,MAC9B,KAAK,EAAE,OAAO;AAAA,MACd,SAAS,EAAE,OAAO;AAAA,MAClB,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,IACrC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;;;ACtBD,SAAS,KAAAC,UAAS;AAaX,IAAM,qBAAqBA,GAAE,OAAO,EAAE,MAAM,EAAE,SAAS,wBAAwB,CAAC;","names":["ChainID","WalletDefaultNetworkConfigurationIds","BtcFeeType","FeeTypes","FeeCalculationTypes","z"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@leather.io/models",
|
|
3
3
|
"author": "Leather.io contact@leather.io",
|
|
4
4
|
"description": "Leather models and types",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.17.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/leather-io/mono/tree/dev/packages/models",
|
|
8
8
|
"repository": {
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './types.utils';
|
|
|
12
12
|
export * from './money.model';
|
|
13
13
|
export * from './network/network.model';
|
|
14
14
|
export * from './network/network.schema';
|
|
15
|
+
export * from './settings.model';
|
|
15
16
|
export * from './transactions/bitcoin-transaction.model';
|
|
16
17
|
export * from './transactions/stacks-transaction.model';
|
|
17
18
|
export * from './utxo.model';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { Blockchain } from './types';
|
|
4
|
+
|
|
5
|
+
export type AccountDisplayPreference = 'native-segwit' | 'taproot' | 'bns' | 'stacks';
|
|
6
|
+
export interface AccountDisplayPreferenceInfo {
|
|
7
|
+
type: AccountDisplayPreference;
|
|
8
|
+
blockchain: Blockchain;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type AnalyticsPreference = 'consent-given' | 'rejects-tracking';
|
|
13
|
+
|
|
14
|
+
export const emailAddressSchema = z.string().email({ message: 'Invalid email address' });
|
|
15
|
+
export type EmailAddress = z.infer<typeof emailAddressSchema>;
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
import { LiteralUnion } from './types.utils';
|
|
2
2
|
|
|
3
3
|
export type Blockchain = LiteralUnion<'bitcoin' | 'stacks', string>;
|
|
4
|
-
|
|
5
|
-
export type AccountDisplayPreference = 'ns' | 'tr' | 'bns' | 'stacks';
|
|
6
|
-
export interface AccountDisplayPreferenceInfo {
|
|
7
|
-
type: AccountDisplayPreference;
|
|
8
|
-
blockchain: Blockchain;
|
|
9
|
-
name: string;
|
|
10
|
-
}
|