@leather.io/models 0.10.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/.eslintrc.yml +4 -0
- package/.turbo/turbo-build.log +17 -0
- package/CHANGELOG.md +263 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +323 -0
- package/dist/index.js +284 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
- package/src/crypto-assets/bitcoin/inscription.model.ts +158 -0
- package/src/crypto-assets/crypto-asset-balance.model.ts +59 -0
- package/src/crypto-assets/crypto-asset-info.model.ts +68 -0
- package/src/currencies.model.ts +7 -0
- package/src/decoded-auth-request.ts +14 -0
- package/src/fees/bitcoin-fees.model.ts +19 -0
- package/src/fees/fees.model.ts +23 -0
- package/src/fees/stacks-fees.model.ts +6 -0
- package/src/index.ts +15 -0
- package/src/market.model.ts +26 -0
- package/src/money.model.ts +11 -0
- package/src/network.model.ts +169 -0
- package/src/transactions/bitcoin-transaction.model.ts +66 -0
- package/src/transactions/stacks-transaction.model.ts +17 -0
- package/src/types.ts +15 -0
- package/src/types.utils.ts +13 -0
- package/src/utxo.model.ts +11 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// src/crypto-assets/crypto-asset-balance.model.ts
|
|
2
|
+
function createCryptoAssetBalance(balance) {
|
|
3
|
+
return { availableBalance: balance };
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/network.model.ts
|
|
7
|
+
var HIRO_API_BASE_URL_MAINNET = "https://api.hiro.so";
|
|
8
|
+
var HIRO_API_BASE_URL_TESTNET = "https://api.testnet.hiro.so";
|
|
9
|
+
var HIRO_INSCRIPTIONS_API_URL = "https://api.hiro.so/ordinals/v1/inscriptions";
|
|
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";
|
|
13
|
+
var BITCOIN_API_BASE_URL_SIGNET = "https://mempool.space/signet/api";
|
|
14
|
+
var BESTINSLOT_API_BASE_URL_MAINNET = "https://leatherapi.bestinslot.xyz/v3";
|
|
15
|
+
var BESTINSLOT_API_BASE_URL_TESTNET = "https://leatherapi_testnet.bestinslot.xyz/v3";
|
|
16
|
+
var STX20_API_BASE_URL_MAINNET = "https://api.stx20.com/api/v1";
|
|
17
|
+
var ChainID = /* @__PURE__ */ ((ChainID2) => {
|
|
18
|
+
ChainID2[ChainID2["Testnet"] = 2147483648] = "Testnet";
|
|
19
|
+
ChainID2[ChainID2["Mainnet"] = 1] = "Mainnet";
|
|
20
|
+
return ChainID2;
|
|
21
|
+
})(ChainID || {});
|
|
22
|
+
var WalletDefaultNetworkConfigurationIds = /* @__PURE__ */ ((WalletDefaultNetworkConfigurationIds2) => {
|
|
23
|
+
WalletDefaultNetworkConfigurationIds2["mainnet"] = "mainnet";
|
|
24
|
+
WalletDefaultNetworkConfigurationIds2["testnet"] = "testnet";
|
|
25
|
+
WalletDefaultNetworkConfigurationIds2["signet"] = "signet";
|
|
26
|
+
WalletDefaultNetworkConfigurationIds2["sbtcDevenv"] = "sbtcDevenv";
|
|
27
|
+
WalletDefaultNetworkConfigurationIds2["devnet"] = "devnet";
|
|
28
|
+
return WalletDefaultNetworkConfigurationIds2;
|
|
29
|
+
})(WalletDefaultNetworkConfigurationIds || {});
|
|
30
|
+
var networkMainnet = {
|
|
31
|
+
id: "mainnet" /* mainnet */,
|
|
32
|
+
name: "Mainnet",
|
|
33
|
+
chain: {
|
|
34
|
+
stacks: {
|
|
35
|
+
blockchain: "stacks",
|
|
36
|
+
chainId: 1 /* Mainnet */,
|
|
37
|
+
url: HIRO_API_BASE_URL_MAINNET
|
|
38
|
+
},
|
|
39
|
+
bitcoin: {
|
|
40
|
+
blockchain: "bitcoin",
|
|
41
|
+
bitcoinNetwork: "mainnet",
|
|
42
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_MAINNET
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var networkTestnet = {
|
|
47
|
+
id: "testnet" /* testnet */,
|
|
48
|
+
name: "Testnet",
|
|
49
|
+
chain: {
|
|
50
|
+
stacks: {
|
|
51
|
+
blockchain: "stacks",
|
|
52
|
+
chainId: 2147483648 /* Testnet */,
|
|
53
|
+
url: HIRO_API_BASE_URL_TESTNET
|
|
54
|
+
},
|
|
55
|
+
bitcoin: {
|
|
56
|
+
blockchain: "bitcoin",
|
|
57
|
+
bitcoinNetwork: "testnet",
|
|
58
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_TESTNET
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var networkSignet = {
|
|
63
|
+
id: "signet" /* signet */,
|
|
64
|
+
name: "Signet",
|
|
65
|
+
chain: {
|
|
66
|
+
stacks: {
|
|
67
|
+
blockchain: "stacks",
|
|
68
|
+
chainId: 2147483648 /* Testnet */,
|
|
69
|
+
url: HIRO_API_BASE_URL_TESTNET
|
|
70
|
+
},
|
|
71
|
+
bitcoin: {
|
|
72
|
+
blockchain: "bitcoin",
|
|
73
|
+
bitcoinNetwork: "signet",
|
|
74
|
+
bitcoinUrl: BITCOIN_API_BASE_URL_SIGNET
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var networkSbtcDevenv = {
|
|
79
|
+
id: "sbtcDevenv" /* sbtcDevenv */,
|
|
80
|
+
name: "sBTC Devenv",
|
|
81
|
+
chain: {
|
|
82
|
+
stacks: {
|
|
83
|
+
blockchain: "stacks",
|
|
84
|
+
chainId: 2147483648 /* Testnet */,
|
|
85
|
+
url: "http://localhost:3999"
|
|
86
|
+
},
|
|
87
|
+
bitcoin: {
|
|
88
|
+
blockchain: "bitcoin",
|
|
89
|
+
bitcoinNetwork: "regtest",
|
|
90
|
+
bitcoinUrl: "http://localhost:8999/api"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var networkDevnet = {
|
|
95
|
+
id: "devnet" /* devnet */,
|
|
96
|
+
name: "Devnet",
|
|
97
|
+
chain: {
|
|
98
|
+
stacks: {
|
|
99
|
+
blockchain: "stacks",
|
|
100
|
+
chainId: 2147483648 /* Testnet */,
|
|
101
|
+
url: "http://localhost:3999"
|
|
102
|
+
},
|
|
103
|
+
bitcoin: {
|
|
104
|
+
blockchain: "bitcoin",
|
|
105
|
+
bitcoinNetwork: "regtest",
|
|
106
|
+
bitcoinUrl: "http://localhost:18443"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var defaultCurrentNetwork = networkMainnet;
|
|
111
|
+
var defaultNetworksKeyedById = {
|
|
112
|
+
["mainnet" /* mainnet */]: networkMainnet,
|
|
113
|
+
["testnet" /* testnet */]: networkTestnet,
|
|
114
|
+
["signet" /* signet */]: networkSignet,
|
|
115
|
+
["sbtcDevenv" /* sbtcDevenv */]: networkSbtcDevenv,
|
|
116
|
+
["devnet" /* devnet */]: networkDevnet
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/crypto-assets/bitcoin/inscription.model.ts
|
|
120
|
+
function whenInscriptionMimeType(mimeType, branches) {
|
|
121
|
+
if (mimeType.startsWith("audio/") && branches.audio) {
|
|
122
|
+
return branches.audio();
|
|
123
|
+
}
|
|
124
|
+
if (mimeType.startsWith("text/html") && branches.html) {
|
|
125
|
+
return branches.html();
|
|
126
|
+
}
|
|
127
|
+
if (mimeType.startsWith("image/svg") && branches.svg) {
|
|
128
|
+
return branches.svg();
|
|
129
|
+
}
|
|
130
|
+
if (mimeType.startsWith("image/") && branches.image) {
|
|
131
|
+
return branches.image();
|
|
132
|
+
}
|
|
133
|
+
if (mimeType.startsWith("text") && branches.text) {
|
|
134
|
+
return branches.text();
|
|
135
|
+
}
|
|
136
|
+
if (mimeType.startsWith("video/") && branches.video) {
|
|
137
|
+
return branches.video();
|
|
138
|
+
}
|
|
139
|
+
if (mimeType.startsWith("model/gltf") && branches.gltf) {
|
|
140
|
+
return branches.gltf();
|
|
141
|
+
}
|
|
142
|
+
if (branches.other) return branches.other();
|
|
143
|
+
throw new Error("Unhandled inscription type");
|
|
144
|
+
}
|
|
145
|
+
function createInscription(inscription) {
|
|
146
|
+
const contentSrc = `${HIRO_INSCRIPTIONS_API_URL}/${inscription.id}/content`;
|
|
147
|
+
const iframeSrc = `https://ordinals.com/preview/${inscription.id}`;
|
|
148
|
+
const preview = `https://ordinals.hiro.so/inscription/${inscription.id}`;
|
|
149
|
+
const title = `Inscription ${inscription.number}`;
|
|
150
|
+
const sharedInfo = {
|
|
151
|
+
id: inscription.id,
|
|
152
|
+
number: inscription.number,
|
|
153
|
+
output: inscription.output,
|
|
154
|
+
txid: inscription.txid,
|
|
155
|
+
offset: inscription.offset,
|
|
156
|
+
address: inscription.address,
|
|
157
|
+
genesisBlockHash: inscription.genesisBlockHash,
|
|
158
|
+
genesisTimestamp: inscription.genesisTimestamp,
|
|
159
|
+
genesisBlockHeight: inscription.genesisBlockHeight,
|
|
160
|
+
value: inscription.value,
|
|
161
|
+
preview,
|
|
162
|
+
title
|
|
163
|
+
};
|
|
164
|
+
return whenInscriptionMimeType(inscription.contentType, {
|
|
165
|
+
audio: () => ({
|
|
166
|
+
...sharedInfo,
|
|
167
|
+
mimeType: "audio",
|
|
168
|
+
name: "inscription",
|
|
169
|
+
src: iframeSrc
|
|
170
|
+
}),
|
|
171
|
+
gltf: () => ({
|
|
172
|
+
...sharedInfo,
|
|
173
|
+
mimeType: "gltf",
|
|
174
|
+
name: "inscription",
|
|
175
|
+
src: iframeSrc
|
|
176
|
+
}),
|
|
177
|
+
html: () => ({
|
|
178
|
+
...sharedInfo,
|
|
179
|
+
mimeType: "html",
|
|
180
|
+
name: "inscription",
|
|
181
|
+
src: iframeSrc
|
|
182
|
+
}),
|
|
183
|
+
image: () => ({
|
|
184
|
+
...sharedInfo,
|
|
185
|
+
mimeType: "image",
|
|
186
|
+
name: "inscription",
|
|
187
|
+
src: contentSrc
|
|
188
|
+
}),
|
|
189
|
+
svg: () => ({
|
|
190
|
+
...sharedInfo,
|
|
191
|
+
mimeType: "svg",
|
|
192
|
+
name: "inscription",
|
|
193
|
+
src: iframeSrc
|
|
194
|
+
}),
|
|
195
|
+
text: () => ({
|
|
196
|
+
...sharedInfo,
|
|
197
|
+
mimeType: "text",
|
|
198
|
+
name: "inscription",
|
|
199
|
+
src: contentSrc
|
|
200
|
+
}),
|
|
201
|
+
video: () => ({
|
|
202
|
+
...sharedInfo,
|
|
203
|
+
mimeType: "video",
|
|
204
|
+
name: "inscription",
|
|
205
|
+
src: iframeSrc
|
|
206
|
+
}),
|
|
207
|
+
other: () => ({
|
|
208
|
+
...sharedInfo,
|
|
209
|
+
mimeType: "other",
|
|
210
|
+
name: "inscription",
|
|
211
|
+
src: ""
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/fees/bitcoin-fees.model.ts
|
|
217
|
+
var btcTxTimeMap = {
|
|
218
|
+
fastestFee: "~10 \u2013 20min",
|
|
219
|
+
halfHourFee: "~30 min",
|
|
220
|
+
hourFee: "~1 hour+"
|
|
221
|
+
};
|
|
222
|
+
var BtcFeeType = /* @__PURE__ */ ((BtcFeeType2) => {
|
|
223
|
+
BtcFeeType2["High"] = "High";
|
|
224
|
+
BtcFeeType2["Standard"] = "Standard";
|
|
225
|
+
BtcFeeType2["Low"] = "Low";
|
|
226
|
+
return BtcFeeType2;
|
|
227
|
+
})(BtcFeeType || {});
|
|
228
|
+
|
|
229
|
+
// src/fees/fees.model.ts
|
|
230
|
+
var FeeTypes = /* @__PURE__ */ ((FeeTypes2) => {
|
|
231
|
+
FeeTypes2[FeeTypes2["Low"] = 0] = "Low";
|
|
232
|
+
FeeTypes2[FeeTypes2["Middle"] = 1] = "Middle";
|
|
233
|
+
FeeTypes2[FeeTypes2["High"] = 2] = "High";
|
|
234
|
+
FeeTypes2[FeeTypes2["Custom"] = 3] = "Custom";
|
|
235
|
+
FeeTypes2[FeeTypes2["Unknown"] = 4] = "Unknown";
|
|
236
|
+
return FeeTypes2;
|
|
237
|
+
})(FeeTypes || {});
|
|
238
|
+
var FeeCalculationTypes = /* @__PURE__ */ ((FeeCalculationTypes2) => {
|
|
239
|
+
FeeCalculationTypes2["Api"] = "api";
|
|
240
|
+
FeeCalculationTypes2["Default"] = "default";
|
|
241
|
+
FeeCalculationTypes2["DefaultSimulated"] = "default-simulated";
|
|
242
|
+
FeeCalculationTypes2["FeesCapped"] = "fees-capped";
|
|
243
|
+
return FeeCalculationTypes2;
|
|
244
|
+
})(FeeCalculationTypes || {});
|
|
245
|
+
|
|
246
|
+
// src/market.model.ts
|
|
247
|
+
function createMarketPair(base, quote) {
|
|
248
|
+
return Object.freeze({ base, quote });
|
|
249
|
+
}
|
|
250
|
+
function formatMarketPair({ base, quote }) {
|
|
251
|
+
return `${base}/${quote}`;
|
|
252
|
+
}
|
|
253
|
+
function createMarketData(pair, price) {
|
|
254
|
+
if (pair.quote !== price.symbol)
|
|
255
|
+
throw new Error("Cannot create market data when price does not match quote");
|
|
256
|
+
return Object.freeze({ pair, price });
|
|
257
|
+
}
|
|
258
|
+
export {
|
|
259
|
+
BESTINSLOT_API_BASE_URL_MAINNET,
|
|
260
|
+
BESTINSLOT_API_BASE_URL_TESTNET,
|
|
261
|
+
BITCOIN_API_BASE_URL_MAINNET,
|
|
262
|
+
BITCOIN_API_BASE_URL_SIGNET,
|
|
263
|
+
BITCOIN_API_BASE_URL_TESTNET,
|
|
264
|
+
BtcFeeType,
|
|
265
|
+
ChainID,
|
|
266
|
+
FeeCalculationTypes,
|
|
267
|
+
FeeTypes,
|
|
268
|
+
HIRO_API_BASE_URL_MAINNET,
|
|
269
|
+
HIRO_API_BASE_URL_NAKAMOTO_TESTNET,
|
|
270
|
+
HIRO_API_BASE_URL_TESTNET,
|
|
271
|
+
HIRO_INSCRIPTIONS_API_URL,
|
|
272
|
+
STX20_API_BASE_URL_MAINNET,
|
|
273
|
+
WalletDefaultNetworkConfigurationIds,
|
|
274
|
+
btcTxTimeMap,
|
|
275
|
+
createCryptoAssetBalance,
|
|
276
|
+
createInscription,
|
|
277
|
+
createMarketData,
|
|
278
|
+
createMarketPair,
|
|
279
|
+
defaultCurrentNetwork,
|
|
280
|
+
defaultNetworksKeyedById,
|
|
281
|
+
formatMarketPair,
|
|
282
|
+
whenInscriptionMimeType
|
|
283
|
+
};
|
|
284
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACd;AAAA,EACF;AACF;AAEA,IAAM,g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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;","names":["ChainID","WalletDefaultNetworkConfigurationIds","BtcFeeType","FeeTypes","FeeCalculationTypes"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leather.io/models",
|
|
3
|
+
"author": "Leather.io contact@leather.io",
|
|
4
|
+
"description": "Leather models and types",
|
|
5
|
+
"version": "0.10.0",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/leather-io/mono/tree/dev/packages/models",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git@github.com:leather-io/mono.git",
|
|
11
|
+
"directory": "packages/models"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"bugs": "https://github.com/leather-io/mono/issues",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@stacks/stacks-blockchain-api-types": "7.8.2",
|
|
20
|
+
"bignumber.js": "9.1.2"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"eslint": "8.53.0",
|
|
24
|
+
"prettier": "3.3.0",
|
|
25
|
+
"tsup": "8.1.0",
|
|
26
|
+
"typescript": "5.4.5",
|
|
27
|
+
"@leather.io/eslint-config": "0.6.0",
|
|
28
|
+
"@leather.io/prettier-config": "0.5.0",
|
|
29
|
+
"@leather.io/tsconfig-config": "0.5.0"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"leather",
|
|
33
|
+
"leather wallet",
|
|
34
|
+
"models"
|
|
35
|
+
],
|
|
36
|
+
"prettier": "@leather.io/prettier-config",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"build:watch": "tsup --watch",
|
|
43
|
+
"format": "prettier . --write --ignore-path ../../.prettierignore",
|
|
44
|
+
"format:check": "prettier . --check --ignore-path ../../.prettierignore",
|
|
45
|
+
"lint": "eslint . --ignore-path ../../.eslintignore",
|
|
46
|
+
"lint:fix": "eslint . --fix --ignore-path ../../.eslintignore",
|
|
47
|
+
"typecheck": "tsc --noEmit -p ./tsconfig.json"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { HIRO_INSCRIPTIONS_API_URL } from '../../network.model';
|
|
2
|
+
import { InscriptionCryptoAssetInfo } from '../crypto-asset-info.model';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Inscriptions contain arbitrary data. When retrieving an inscription, it should be
|
|
6
|
+
* classified into one of the types below, indicating that the app can handle it
|
|
7
|
+
* appropriately and securely. Inscriptions of types not ready to be handled by the
|
|
8
|
+
* app should be classified as "other".
|
|
9
|
+
*/
|
|
10
|
+
const inscriptionMimeTypes = [
|
|
11
|
+
'audio',
|
|
12
|
+
'gltf',
|
|
13
|
+
'html',
|
|
14
|
+
'image',
|
|
15
|
+
'svg',
|
|
16
|
+
'text',
|
|
17
|
+
'video',
|
|
18
|
+
'other',
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
21
|
+
export type InscriptionMimeType = (typeof inscriptionMimeTypes)[number];
|
|
22
|
+
|
|
23
|
+
export function whenInscriptionMimeType<T>(
|
|
24
|
+
mimeType: string,
|
|
25
|
+
branches: { [k in InscriptionMimeType]?: () => T }
|
|
26
|
+
) {
|
|
27
|
+
if (mimeType.startsWith('audio/') && branches.audio) {
|
|
28
|
+
return branches.audio();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (mimeType.startsWith('text/html') && branches.html) {
|
|
32
|
+
return branches.html();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (mimeType.startsWith('image/svg') && branches.svg) {
|
|
36
|
+
return branches.svg();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (mimeType.startsWith('image/') && branches.image) {
|
|
40
|
+
return branches.image();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (mimeType.startsWith('text') && branches.text) {
|
|
44
|
+
return branches.text();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (mimeType.startsWith('video/') && branches.video) {
|
|
48
|
+
return branches.video();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (mimeType.startsWith('model/gltf') && branches.gltf) {
|
|
52
|
+
return branches.gltf();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (branches.other) return branches.other();
|
|
56
|
+
|
|
57
|
+
throw new Error('Unhandled inscription type');
|
|
58
|
+
}
|
|
59
|
+
export interface Inscription extends InscriptionCryptoAssetInfo {
|
|
60
|
+
preview: string;
|
|
61
|
+
src: string;
|
|
62
|
+
title: string;
|
|
63
|
+
output: string;
|
|
64
|
+
txid: string;
|
|
65
|
+
offset: string;
|
|
66
|
+
address: string;
|
|
67
|
+
genesisBlockHash: string;
|
|
68
|
+
genesisTimestamp: number;
|
|
69
|
+
genesisBlockHeight: number;
|
|
70
|
+
value: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface RawInscription {
|
|
74
|
+
id: string;
|
|
75
|
+
number: number;
|
|
76
|
+
output: string;
|
|
77
|
+
contentType: string;
|
|
78
|
+
txid: string;
|
|
79
|
+
offset: string;
|
|
80
|
+
address: string;
|
|
81
|
+
genesisBlockHash: string;
|
|
82
|
+
genesisTimestamp: number;
|
|
83
|
+
genesisBlockHeight: number;
|
|
84
|
+
value: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function createInscription(inscription: RawInscription): Inscription {
|
|
88
|
+
const contentSrc = `${HIRO_INSCRIPTIONS_API_URL}/${inscription.id}/content`;
|
|
89
|
+
const iframeSrc = `https://ordinals.com/preview/${inscription.id}`;
|
|
90
|
+
const preview = `https://ordinals.hiro.so/inscription/${inscription.id}`;
|
|
91
|
+
const title = `Inscription ${inscription.number}`;
|
|
92
|
+
|
|
93
|
+
const sharedInfo = {
|
|
94
|
+
id: inscription.id,
|
|
95
|
+
number: inscription.number,
|
|
96
|
+
output: inscription.output,
|
|
97
|
+
txid: inscription.txid,
|
|
98
|
+
offset: inscription.offset,
|
|
99
|
+
address: inscription.address,
|
|
100
|
+
genesisBlockHash: inscription.genesisBlockHash,
|
|
101
|
+
genesisTimestamp: inscription.genesisTimestamp,
|
|
102
|
+
genesisBlockHeight: inscription.genesisBlockHeight,
|
|
103
|
+
value: inscription.value,
|
|
104
|
+
preview,
|
|
105
|
+
title,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return whenInscriptionMimeType<Inscription>(inscription.contentType, {
|
|
109
|
+
audio: () => ({
|
|
110
|
+
...sharedInfo,
|
|
111
|
+
mimeType: 'audio',
|
|
112
|
+
name: 'inscription',
|
|
113
|
+
src: iframeSrc,
|
|
114
|
+
}),
|
|
115
|
+
gltf: () => ({
|
|
116
|
+
...sharedInfo,
|
|
117
|
+
mimeType: 'gltf',
|
|
118
|
+
name: 'inscription',
|
|
119
|
+
src: iframeSrc,
|
|
120
|
+
}),
|
|
121
|
+
html: () => ({
|
|
122
|
+
...sharedInfo,
|
|
123
|
+
mimeType: 'html',
|
|
124
|
+
name: 'inscription',
|
|
125
|
+
src: iframeSrc,
|
|
126
|
+
}),
|
|
127
|
+
image: () => ({
|
|
128
|
+
...sharedInfo,
|
|
129
|
+
mimeType: 'image',
|
|
130
|
+
name: 'inscription',
|
|
131
|
+
src: contentSrc,
|
|
132
|
+
}),
|
|
133
|
+
svg: () => ({
|
|
134
|
+
...sharedInfo,
|
|
135
|
+
mimeType: 'svg',
|
|
136
|
+
name: 'inscription',
|
|
137
|
+
src: iframeSrc,
|
|
138
|
+
}),
|
|
139
|
+
text: () => ({
|
|
140
|
+
...sharedInfo,
|
|
141
|
+
mimeType: 'text',
|
|
142
|
+
name: 'inscription',
|
|
143
|
+
src: contentSrc,
|
|
144
|
+
}),
|
|
145
|
+
video: () => ({
|
|
146
|
+
...sharedInfo,
|
|
147
|
+
mimeType: 'video',
|
|
148
|
+
name: 'inscription',
|
|
149
|
+
src: iframeSrc,
|
|
150
|
+
}),
|
|
151
|
+
other: () => ({
|
|
152
|
+
...sharedInfo,
|
|
153
|
+
mimeType: 'other',
|
|
154
|
+
name: 'inscription',
|
|
155
|
+
src: '',
|
|
156
|
+
}),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Money } from '../money.model';
|
|
2
|
+
|
|
3
|
+
export interface BaseCryptoAssetBalance {
|
|
4
|
+
/**
|
|
5
|
+
* totalBalance after filtering out outboundBalance, protectedBalance, and uneconomicalBalance
|
|
6
|
+
*/
|
|
7
|
+
readonly availableBalance: Money;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface BtcCryptoAssetBalance extends BaseCryptoAssetBalance {
|
|
11
|
+
/**
|
|
12
|
+
* Balance of UTXOs with collectibles
|
|
13
|
+
*/
|
|
14
|
+
readonly protectedBalance: Money;
|
|
15
|
+
/**
|
|
16
|
+
* Balance across UTXOs with need for larger fee than principal by UTXO given standard rate
|
|
17
|
+
*/
|
|
18
|
+
readonly uneconomicalBalance: Money;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface StxCryptoAssetBalance extends BaseCryptoAssetBalance {
|
|
22
|
+
/**
|
|
23
|
+
* availableBalance minus lockedBalance
|
|
24
|
+
*/
|
|
25
|
+
readonly availableUnlockedBalance: Money;
|
|
26
|
+
/**
|
|
27
|
+
* Balance of pending receipt into account given pending transactions
|
|
28
|
+
*/
|
|
29
|
+
readonly inboundBalance: Money;
|
|
30
|
+
/**
|
|
31
|
+
* totalBalance minus total amount locked by contracts
|
|
32
|
+
*/
|
|
33
|
+
readonly lockedBalance: Money;
|
|
34
|
+
/**
|
|
35
|
+
* Balance of pending delivery from account given pending transactions
|
|
36
|
+
*/
|
|
37
|
+
readonly outboundBalance: Money;
|
|
38
|
+
/**
|
|
39
|
+
* totalBalance plus inboundBalance minus outboundBalance
|
|
40
|
+
*/
|
|
41
|
+
readonly pendingBalance: Money;
|
|
42
|
+
/**
|
|
43
|
+
* Balance as confirmed on chain
|
|
44
|
+
*/
|
|
45
|
+
readonly totalBalance: Money;
|
|
46
|
+
/**
|
|
47
|
+
* totalBalance minus lockedBalance
|
|
48
|
+
*/
|
|
49
|
+
readonly unlockedBalance: Money;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type CryptoAssetBalance =
|
|
53
|
+
| BaseCryptoAssetBalance
|
|
54
|
+
| BtcCryptoAssetBalance
|
|
55
|
+
| StxCryptoAssetBalance;
|
|
56
|
+
|
|
57
|
+
export function createCryptoAssetBalance(balance: Money): BaseCryptoAssetBalance {
|
|
58
|
+
return { availableBalance: balance };
|
|
59
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { InscriptionMimeType } from './bitcoin/inscription.model';
|
|
2
|
+
|
|
3
|
+
export interface BaseCryptoAssetInfo {
|
|
4
|
+
readonly decimals: number;
|
|
5
|
+
readonly hasMemo: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface BtcCryptoAssetInfo extends BaseCryptoAssetInfo {
|
|
9
|
+
readonly name: 'bitcoin';
|
|
10
|
+
readonly symbol: 'BTC';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface StxCryptoAssetInfo extends BaseCryptoAssetInfo {
|
|
14
|
+
readonly name: 'stacks';
|
|
15
|
+
readonly symbol: 'STX';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Bitcoin
|
|
19
|
+
export interface Brc20CryptoAssetInfo extends BaseCryptoAssetInfo {
|
|
20
|
+
readonly name: 'brc-20';
|
|
21
|
+
readonly symbol: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface InscriptionCryptoAssetInfo {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly mimeType: InscriptionMimeType;
|
|
27
|
+
readonly name: 'inscription';
|
|
28
|
+
readonly number: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RuneCryptoAssetInfo extends BaseCryptoAssetInfo {
|
|
32
|
+
readonly name: 'rune';
|
|
33
|
+
readonly spacedRuneName: string;
|
|
34
|
+
readonly runeName: string;
|
|
35
|
+
readonly symbol: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface StampCryptoAssetInfo {
|
|
39
|
+
readonly name: 'stamp';
|
|
40
|
+
readonly stamp: number;
|
|
41
|
+
readonly stampUrl: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Src20CryptoAssetInfo extends BaseCryptoAssetInfo {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly name: 'src-20';
|
|
47
|
+
readonly symbol: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Stacks
|
|
51
|
+
export interface Sip9CryptoAssetInfo {
|
|
52
|
+
readonly contractId: string;
|
|
53
|
+
readonly imageCanonicalUri: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface Sip10CryptoAssetInfo extends BaseCryptoAssetInfo {
|
|
58
|
+
readonly canTransfer: boolean;
|
|
59
|
+
readonly contractId: string;
|
|
60
|
+
readonly imageCanonicalUri: string;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly symbol: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface Stx20CryptoAssetInfo {
|
|
66
|
+
readonly name: 'stx-20';
|
|
67
|
+
readonly symbol: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface DecodedAuthRequest {
|
|
2
|
+
public_keys: string;
|
|
3
|
+
domain_name: string;
|
|
4
|
+
manifest_uri: string;
|
|
5
|
+
redirect_uri: string;
|
|
6
|
+
scopes: string[];
|
|
7
|
+
sendToSignIn: boolean;
|
|
8
|
+
appDetails?: {
|
|
9
|
+
name: string;
|
|
10
|
+
icon: string;
|
|
11
|
+
};
|
|
12
|
+
client?: string;
|
|
13
|
+
connectVersion?: string;
|
|
14
|
+
}
|