@1sat/wallet-toolbox 0.0.73 → 0.0.74
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/dist/api/balance/index.d.ts +1 -11
- package/dist/api/balance/index.js +0 -30
- package/dist/api/locks/index.js +7 -23
- package/dist/index.d.ts +1 -1
- package/dist/indexers/Bsv21Indexer.js +3 -3
- package/dist/indexers/types.d.ts +5 -6
- package/dist/services/client/Bsv21Client.d.ts +38 -11
- package/dist/services/client/Bsv21Client.js +54 -10
- package/dist/services/client/OverlayClient.d.ts +0 -17
- package/dist/services/client/OverlayClient.js +0 -33
- package/dist/services/types.d.ts +28 -19
- package/package.json +1 -1
|
@@ -36,15 +36,5 @@ export type GetExchangeRateInput = Record<string, never>;
|
|
|
36
36
|
* Get current BSV/USD exchange rate.
|
|
37
37
|
*/
|
|
38
38
|
export declare const getExchangeRate: Skill<GetExchangeRateInput, number>;
|
|
39
|
-
/** Input for getChainInfo skill (no required params) */
|
|
40
|
-
export type GetChainInfoInput = Record<string, never>;
|
|
41
|
-
/** Output for getChainInfo skill */
|
|
42
|
-
export interface ChainInfo {
|
|
43
|
-
blocks: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get chain info from WhatsOnChain.
|
|
47
|
-
*/
|
|
48
|
-
export declare const getChainInfo: Skill<GetChainInfoInput, ChainInfo | null>;
|
|
49
39
|
/** All balance skills for registry */
|
|
50
|
-
export declare const balanceSkills: (Skill<GetBalanceInput, Balance> | Skill<GetPaymentUtxosInput, PaymentUtxo[]> | Skill<GetExchangeRateInput, number>
|
|
40
|
+
export declare const balanceSkills: (Skill<GetBalanceInput, Balance> | Skill<GetPaymentUtxosInput, PaymentUtxo[]> | Skill<GetExchangeRateInput, number>)[];
|
|
@@ -103,35 +103,6 @@ export const getExchangeRate = {
|
|
|
103
103
|
return fetchExchangeRate(ctx.chain, ctx.wocApiKey);
|
|
104
104
|
},
|
|
105
105
|
};
|
|
106
|
-
/**
|
|
107
|
-
* Get chain info from WhatsOnChain.
|
|
108
|
-
*/
|
|
109
|
-
export const getChainInfo = {
|
|
110
|
-
meta: {
|
|
111
|
-
name: "getChainInfo",
|
|
112
|
-
description: "Get current chain info (block height) from WhatsOnChain",
|
|
113
|
-
category: "balance",
|
|
114
|
-
inputSchema: {
|
|
115
|
-
type: "object",
|
|
116
|
-
properties: {},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
async execute(ctx) {
|
|
120
|
-
const baseUrl = ctx.chain === "main" ? WOC_MAINNET_URL : WOC_TESTNET_URL;
|
|
121
|
-
const headers = {};
|
|
122
|
-
if (ctx.wocApiKey)
|
|
123
|
-
headers["woc-api-key"] = ctx.wocApiKey;
|
|
124
|
-
try {
|
|
125
|
-
const response = await fetch(`${baseUrl}/chain/info`, { headers });
|
|
126
|
-
if (!response.ok)
|
|
127
|
-
return null;
|
|
128
|
-
return await response.json();
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
106
|
// ============================================================================
|
|
136
107
|
// Module exports
|
|
137
108
|
// ============================================================================
|
|
@@ -140,5 +111,4 @@ export const balanceSkills = [
|
|
|
140
111
|
getBalance,
|
|
141
112
|
getPaymentUtxos,
|
|
142
113
|
getExchangeRate,
|
|
143
|
-
getChainInfo,
|
|
144
114
|
];
|
package/dist/api/locks/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Skills for time-locking BSV.
|
|
5
5
|
*/
|
|
6
6
|
import { Hash, PublicKey, Script, Transaction, TransactionSignature, Utils, } from "@bsv/sdk";
|
|
7
|
-
import { LOCK_BASKET, LOCK_PREFIX, LOCK_SUFFIX, MIN_UNLOCK_SATS,
|
|
7
|
+
import { LOCK_BASKET, LOCK_PREFIX, LOCK_SUFFIX, MIN_UNLOCK_SATS, } from "../constants";
|
|
8
8
|
// ============================================================================
|
|
9
9
|
// Constants
|
|
10
10
|
// ============================================================================
|
|
@@ -21,21 +21,6 @@ function buildLockScript(address, until) {
|
|
|
21
21
|
.writeNumber(until)
|
|
22
22
|
.writeScript(Script.fromHex(LOCK_SUFFIX));
|
|
23
23
|
}
|
|
24
|
-
async function getChainInfoInternal(chain, wocApiKey) {
|
|
25
|
-
const baseUrl = chain === "main" ? WOC_MAINNET_URL : WOC_TESTNET_URL;
|
|
26
|
-
const headers = {};
|
|
27
|
-
if (wocApiKey)
|
|
28
|
-
headers["woc-api-key"] = wocApiKey;
|
|
29
|
-
try {
|
|
30
|
-
const response = await fetch(`${baseUrl}/chain/info`, { headers });
|
|
31
|
-
if (!response.ok)
|
|
32
|
-
return null;
|
|
33
|
-
return await response.json();
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
24
|
/**
|
|
40
25
|
* Get lock data summary.
|
|
41
26
|
*/
|
|
@@ -51,8 +36,9 @@ export const getLockData = {
|
|
|
51
36
|
},
|
|
52
37
|
async execute(ctx) {
|
|
53
38
|
const lockData = { totalLocked: 0, unlockable: 0, nextUnlock: 0 };
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
if (!ctx.services)
|
|
40
|
+
return lockData;
|
|
41
|
+
const currentHeight = await ctx.services.chaintracks.currentHeight();
|
|
56
42
|
const result = await ctx.wallet.listOutputs({
|
|
57
43
|
basket: LOCK_BASKET,
|
|
58
44
|
includeTags: true,
|
|
@@ -178,11 +164,9 @@ export const unlockBsv = {
|
|
|
178
164
|
},
|
|
179
165
|
async execute(ctx) {
|
|
180
166
|
try {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return { error: "could-not-get-block-height" };
|
|
185
|
-
}
|
|
167
|
+
if (!ctx.services)
|
|
168
|
+
return { error: "services-required" };
|
|
169
|
+
const currentHeight = await ctx.services.chaintracks.currentHeight();
|
|
186
170
|
const result = await ctx.wallet.listOutputs({
|
|
187
171
|
basket: LOCK_BASKET,
|
|
188
172
|
includeTags: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./api";
|
|
2
2
|
export { OneSatServices, type SyncOutput } from "./services/OneSatServices";
|
|
3
|
-
export type { IndexedOutput, OrdfsMetadata, OrdfsContentOptions, OrdfsContentResponse, OrdfsResponseHeaders, Capability, } from "./services/types";
|
|
3
|
+
export type { IndexedOutput, OrdfsMetadata, OrdfsContentOptions, OrdfsContentResponse, OrdfsResponseHeaders, Capability, TokenDetailResponse, TokenStatus, Bsv21TokenData, Bsv21OutputData, Bsv21TransactionData, } from "./services/types";
|
|
4
4
|
export * from "./services/client";
|
|
5
5
|
export { ReadOnlySigner } from "./signers/ReadOnlySigner";
|
|
6
6
|
export * from "./indexers";
|
|
@@ -56,9 +56,9 @@ export class Bsv21Indexer extends Indexer {
|
|
|
56
56
|
if (!isDeploy) {
|
|
57
57
|
try {
|
|
58
58
|
const details = await this.services.bsv21.getTokenDetails(tokenId);
|
|
59
|
-
bsv21.sym = details.sym;
|
|
60
|
-
bsv21.icon = resolveIcon(details.icon, tokenId);
|
|
61
|
-
bsv21.dec = details.dec;
|
|
59
|
+
bsv21.sym = details.token.sym;
|
|
60
|
+
bsv21.icon = resolveIcon(details.token.icon, tokenId);
|
|
61
|
+
bsv21.dec = Number(details.token.dec) || 0;
|
|
62
62
|
}
|
|
63
63
|
catch (e) {
|
|
64
64
|
// Token not found on server - could be unconfirmed or invalid
|
package/dist/indexers/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface Bsv21TokenData {
|
|
|
8
8
|
op: string;
|
|
9
9
|
amt: string;
|
|
10
10
|
sym?: string;
|
|
11
|
-
dec?:
|
|
11
|
+
dec?: string;
|
|
12
12
|
icon?: string;
|
|
13
13
|
address?: string;
|
|
14
14
|
}
|
|
@@ -16,15 +16,13 @@ export interface Bsv21TokenData {
|
|
|
16
16
|
* BSV21 output data from overlay API
|
|
17
17
|
*/
|
|
18
18
|
export interface Bsv21OutputData {
|
|
19
|
-
txid
|
|
19
|
+
txid?: string;
|
|
20
20
|
vout: number;
|
|
21
21
|
data: {
|
|
22
22
|
bsv21: Bsv21TokenData;
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
spend: string | null;
|
|
27
|
-
score: number;
|
|
24
|
+
spend?: string | null;
|
|
25
|
+
score?: number;
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
28
|
* BSV21 transaction data from overlay API
|
|
@@ -34,6 +32,7 @@ export interface Bsv21TransactionData {
|
|
|
34
32
|
inputs: Bsv21OutputData[];
|
|
35
33
|
outputs: Bsv21OutputData[];
|
|
36
34
|
beef?: string;
|
|
35
|
+
block_height?: number;
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* IndexData contains the parsed data and tags from an indexer
|
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Bsv21TransactionData, ClientOptions, IndexedOutput, TokenDetailResponse } from "../types";
|
|
2
2
|
import { BaseClient } from "./BaseClient";
|
|
3
3
|
/**
|
|
4
4
|
* Client for /1sat/bsv21/* routes.
|
|
5
5
|
* Provides BSV21 token queries.
|
|
6
6
|
*
|
|
7
7
|
* Routes:
|
|
8
|
-
* -
|
|
9
|
-
* - GET /:tokenId
|
|
10
|
-
* - GET /:tokenId/tx/:txid - Get token data
|
|
8
|
+
* - POST /lookup - Bulk lookup token details with funding status
|
|
9
|
+
* - GET /:tokenId - Get token details with funding status
|
|
10
|
+
* - GET /:tokenId/tx/:txid - Get token transaction data
|
|
11
11
|
* - GET /:tokenId/:lockType/:address/balance - Get token balance
|
|
12
12
|
* - GET /:tokenId/:lockType/:address/unspent - Get unspent token UTXOs
|
|
13
13
|
* - GET /:tokenId/:lockType/:address/history - Get token transaction history
|
|
14
|
+
* - POST /:tokenId/:lockType/balance - Multi-address token balance
|
|
15
|
+
* - POST /:tokenId/:lockType/unspent - Multi-address unspent token UTXOs
|
|
16
|
+
* - POST /:tokenId/:lockType/history - Multi-address token transaction history
|
|
14
17
|
*/
|
|
15
18
|
export declare class Bsv21Client extends BaseClient {
|
|
16
19
|
private cache;
|
|
17
20
|
constructor(baseUrl: string, options?: ClientOptions);
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
22
|
+
* Bulk lookup token details with funding status.
|
|
23
|
+
* Returns details and active status for multiple tokens in one request.
|
|
24
|
+
* @param tokenIds - Array of token IDs (max 100)
|
|
21
25
|
*/
|
|
22
|
-
|
|
26
|
+
lookupTokens(tokenIds: string[]): Promise<TokenDetailResponse[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Get token details with funding status.
|
|
29
|
+
* Results are cached since token deploy data is immutable.
|
|
30
|
+
*/
|
|
31
|
+
getTokenDetails(tokenId: string): Promise<TokenDetailResponse>;
|
|
23
32
|
/**
|
|
24
33
|
* Get token transaction data for a specific txid
|
|
25
34
|
*/
|
|
26
35
|
getTokenByTxid(tokenId: string, txid: string): Promise<Bsv21TransactionData>;
|
|
27
36
|
/**
|
|
28
37
|
* Get token balance for an address
|
|
29
|
-
* @param tokenId - Token ID (outpoint of deploy tx)
|
|
30
|
-
* @param lockType - Lock type (e.g., 'p2pkh', 'ordlock')
|
|
31
|
-
* @param address - Address to check
|
|
32
38
|
*/
|
|
33
|
-
getBalance(tokenId: string, lockType: string, address: string): Promise<
|
|
39
|
+
getBalance(tokenId: string, lockType: string, address: string): Promise<{
|
|
40
|
+
balance: number;
|
|
41
|
+
utxoCount: number;
|
|
42
|
+
}>;
|
|
34
43
|
/**
|
|
35
44
|
* Get unspent token UTXOs for an address
|
|
36
45
|
*/
|
|
@@ -39,6 +48,24 @@ export declare class Bsv21Client extends BaseClient {
|
|
|
39
48
|
* Get token transaction history for an address
|
|
40
49
|
*/
|
|
41
50
|
getHistory(tokenId: string, lockType: string, address: string): Promise<IndexedOutput[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Get token balance for multiple addresses
|
|
53
|
+
* @param addresses - Array of addresses (max 100)
|
|
54
|
+
*/
|
|
55
|
+
getBalanceMulti(tokenId: string, lockType: string, addresses: string[]): Promise<{
|
|
56
|
+
balance: number;
|
|
57
|
+
utxoCount: number;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Get unspent token UTXOs for multiple addresses
|
|
61
|
+
* @param addresses - Array of addresses (max 100)
|
|
62
|
+
*/
|
|
63
|
+
getUnspentMulti(tokenId: string, lockType: string, addresses: string[]): Promise<IndexedOutput[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get token transaction history for multiple addresses
|
|
66
|
+
* @param addresses - Array of addresses (max 100)
|
|
67
|
+
*/
|
|
68
|
+
getHistoryMulti(tokenId: string, lockType: string, addresses: string[]): Promise<IndexedOutput[]>;
|
|
42
69
|
/**
|
|
43
70
|
* Clear the token details cache
|
|
44
71
|
*/
|
|
@@ -4,12 +4,15 @@ import { BaseClient } from "./BaseClient";
|
|
|
4
4
|
* Provides BSV21 token queries.
|
|
5
5
|
*
|
|
6
6
|
* Routes:
|
|
7
|
-
* -
|
|
8
|
-
* - GET /:tokenId
|
|
9
|
-
* - GET /:tokenId/tx/:txid - Get token data
|
|
7
|
+
* - POST /lookup - Bulk lookup token details with funding status
|
|
8
|
+
* - GET /:tokenId - Get token details with funding status
|
|
9
|
+
* - GET /:tokenId/tx/:txid - Get token transaction data
|
|
10
10
|
* - GET /:tokenId/:lockType/:address/balance - Get token balance
|
|
11
11
|
* - GET /:tokenId/:lockType/:address/unspent - Get unspent token UTXOs
|
|
12
12
|
* - GET /:tokenId/:lockType/:address/history - Get token transaction history
|
|
13
|
+
* - POST /:tokenId/:lockType/balance - Multi-address token balance
|
|
14
|
+
* - POST /:tokenId/:lockType/unspent - Multi-address unspent token UTXOs
|
|
15
|
+
* - POST /:tokenId/:lockType/history - Multi-address token transaction history
|
|
13
16
|
*/
|
|
14
17
|
export class Bsv21Client extends BaseClient {
|
|
15
18
|
cache = new Map();
|
|
@@ -17,8 +20,20 @@ export class Bsv21Client extends BaseClient {
|
|
|
17
20
|
super(`${baseUrl}/1sat/bsv21`, options);
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
23
|
+
* Bulk lookup token details with funding status.
|
|
24
|
+
* Returns details and active status for multiple tokens in one request.
|
|
25
|
+
* @param tokenIds - Array of token IDs (max 100)
|
|
26
|
+
*/
|
|
27
|
+
async lookupTokens(tokenIds) {
|
|
28
|
+
return this.request("/lookup", {
|
|
29
|
+
method: "POST",
|
|
30
|
+
headers: { "Content-Type": "application/json" },
|
|
31
|
+
body: JSON.stringify(tokenIds),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get token details with funding status.
|
|
36
|
+
* Results are cached since token deploy data is immutable.
|
|
22
37
|
*/
|
|
23
38
|
async getTokenDetails(tokenId) {
|
|
24
39
|
const cached = this.cache.get(tokenId);
|
|
@@ -36,13 +51,9 @@ export class Bsv21Client extends BaseClient {
|
|
|
36
51
|
}
|
|
37
52
|
/**
|
|
38
53
|
* Get token balance for an address
|
|
39
|
-
* @param tokenId - Token ID (outpoint of deploy tx)
|
|
40
|
-
* @param lockType - Lock type (e.g., 'p2pkh', 'ordlock')
|
|
41
|
-
* @param address - Address to check
|
|
42
54
|
*/
|
|
43
55
|
async getBalance(tokenId, lockType, address) {
|
|
44
|
-
|
|
45
|
-
return BigInt(data.balance);
|
|
56
|
+
return this.request(`/${tokenId}/${lockType}/${address}/balance`);
|
|
46
57
|
}
|
|
47
58
|
/**
|
|
48
59
|
* Get unspent token UTXOs for an address
|
|
@@ -56,6 +67,39 @@ export class Bsv21Client extends BaseClient {
|
|
|
56
67
|
async getHistory(tokenId, lockType, address) {
|
|
57
68
|
return this.request(`/${tokenId}/${lockType}/${address}/history`);
|
|
58
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Get token balance for multiple addresses
|
|
72
|
+
* @param addresses - Array of addresses (max 100)
|
|
73
|
+
*/
|
|
74
|
+
async getBalanceMulti(tokenId, lockType, addresses) {
|
|
75
|
+
return this.request(`/${tokenId}/${lockType}/balance`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: { "Content-Type": "application/json" },
|
|
78
|
+
body: JSON.stringify(addresses),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get unspent token UTXOs for multiple addresses
|
|
83
|
+
* @param addresses - Array of addresses (max 100)
|
|
84
|
+
*/
|
|
85
|
+
async getUnspentMulti(tokenId, lockType, addresses) {
|
|
86
|
+
return this.request(`/${tokenId}/${lockType}/unspent`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: { "Content-Type": "application/json" },
|
|
89
|
+
body: JSON.stringify(addresses),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get token transaction history for multiple addresses
|
|
94
|
+
* @param addresses - Array of addresses (max 100)
|
|
95
|
+
*/
|
|
96
|
+
async getHistoryMulti(tokenId, lockType, addresses) {
|
|
97
|
+
return this.request(`/${tokenId}/${lockType}/history`, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: { "Content-Type": "application/json" },
|
|
100
|
+
body: JSON.stringify(addresses),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
59
103
|
/**
|
|
60
104
|
* Clear the token details cache
|
|
61
105
|
*/
|
|
@@ -11,12 +11,6 @@ export interface TopicManagerInfo {
|
|
|
11
11
|
export interface LookupServiceInfo {
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
}
|
|
14
|
-
/** BSV-21 token info extracted from topic managers */
|
|
15
|
-
export interface Bsv21TokenInfo {
|
|
16
|
-
tokenId: string;
|
|
17
|
-
symbol?: string;
|
|
18
|
-
icon?: string;
|
|
19
|
-
}
|
|
20
14
|
/**
|
|
21
15
|
* Client for overlay service routes.
|
|
22
16
|
* Handles topic manager queries and overlay lookups.
|
|
@@ -25,23 +19,12 @@ export declare class OverlayClient extends BaseClient {
|
|
|
25
19
|
constructor(baseUrl: string, options?: ClientOptions);
|
|
26
20
|
/**
|
|
27
21
|
* List all registered topic managers.
|
|
28
|
-
* BSV-21 tokens have topic managers named `tm_{tokenId}`.
|
|
29
22
|
*/
|
|
30
23
|
listTopicManagers(): Promise<Record<string, TopicManagerInfo>>;
|
|
31
24
|
/**
|
|
32
25
|
* List all registered lookup service providers.
|
|
33
26
|
*/
|
|
34
27
|
listLookupServiceProviders(): Promise<Record<string, LookupServiceInfo>>;
|
|
35
|
-
/**
|
|
36
|
-
* Get list of active BSV-21 token IDs from topic managers.
|
|
37
|
-
* Extracts tokenIds from topics matching the `tm_{tokenId}` pattern.
|
|
38
|
-
*/
|
|
39
|
-
getActiveBsv21TokenIds(): Promise<string[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Get active BSV-21 tokens with metadata from topic managers.
|
|
42
|
-
* Returns tokenId, symbol (from name), and icon for each active token.
|
|
43
|
-
*/
|
|
44
|
-
getActiveBsv21Tokens(): Promise<Bsv21TokenInfo[]>;
|
|
45
28
|
/**
|
|
46
29
|
* Submit a transaction to the overlay service for indexing.
|
|
47
30
|
* @param beef - BEEF data as Uint8Array or number[]
|
|
@@ -9,7 +9,6 @@ export class OverlayClient extends BaseClient {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* List all registered topic managers.
|
|
12
|
-
* BSV-21 tokens have topic managers named `tm_{tokenId}`.
|
|
13
12
|
*/
|
|
14
13
|
async listTopicManagers() {
|
|
15
14
|
return this.request("/1sat/overlay/listTopicManagers");
|
|
@@ -20,38 +19,6 @@ export class OverlayClient extends BaseClient {
|
|
|
20
19
|
async listLookupServiceProviders() {
|
|
21
20
|
return this.request("/1sat/overlay/listLookupServiceProviders");
|
|
22
21
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Get list of active BSV-21 token IDs from topic managers.
|
|
25
|
-
* Extracts tokenIds from topics matching the `tm_{tokenId}` pattern.
|
|
26
|
-
*/
|
|
27
|
-
async getActiveBsv21TokenIds() {
|
|
28
|
-
const topicManagers = await this.listTopicManagers();
|
|
29
|
-
const tokenIds = [];
|
|
30
|
-
for (const topic of Object.keys(topicManagers)) {
|
|
31
|
-
if (topic.startsWith("tm_")) {
|
|
32
|
-
tokenIds.push(topic.slice(3));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return tokenIds;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get active BSV-21 tokens with metadata from topic managers.
|
|
39
|
-
* Returns tokenId, symbol (from name), and icon for each active token.
|
|
40
|
-
*/
|
|
41
|
-
async getActiveBsv21Tokens() {
|
|
42
|
-
const topicManagers = await this.listTopicManagers();
|
|
43
|
-
const tokens = [];
|
|
44
|
-
for (const [topic, info] of Object.entries(topicManagers)) {
|
|
45
|
-
if (topic.startsWith("tm_")) {
|
|
46
|
-
tokens.push({
|
|
47
|
-
tokenId: topic.slice(3),
|
|
48
|
-
symbol: info.name,
|
|
49
|
-
icon: info.icon,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return tokens;
|
|
54
|
-
}
|
|
55
22
|
/**
|
|
56
23
|
* Submit a transaction to the overlay service for indexing.
|
|
57
24
|
* @param beef - BEEF data as Uint8Array or number[]
|
package/dist/services/types.d.ts
CHANGED
|
@@ -195,19 +195,6 @@ export interface OrdfsContentResponse {
|
|
|
195
195
|
data: Uint8Array;
|
|
196
196
|
headers: OrdfsResponseHeaders;
|
|
197
197
|
}
|
|
198
|
-
/**
|
|
199
|
-
* BSV21 token details (deploy data)
|
|
200
|
-
*/
|
|
201
|
-
export interface Bsv21TokenDetails {
|
|
202
|
-
id: string;
|
|
203
|
-
txid: string;
|
|
204
|
-
vout: number;
|
|
205
|
-
op: string;
|
|
206
|
-
amt: string;
|
|
207
|
-
sym?: string;
|
|
208
|
-
dec: number;
|
|
209
|
-
icon?: string;
|
|
210
|
-
}
|
|
211
198
|
/**
|
|
212
199
|
* BSV21 token data structure from overlay API
|
|
213
200
|
*/
|
|
@@ -216,23 +203,44 @@ export interface Bsv21TokenData {
|
|
|
216
203
|
op: string;
|
|
217
204
|
amt: string;
|
|
218
205
|
sym?: string;
|
|
219
|
-
dec?:
|
|
206
|
+
dec?: string;
|
|
220
207
|
icon?: string;
|
|
221
208
|
address?: string;
|
|
222
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* BSV21 token detail response from GET /bsv21/:tokenId and POST /bsv21/lookup
|
|
212
|
+
*/
|
|
213
|
+
export interface TokenDetailResponse {
|
|
214
|
+
tokenId: string;
|
|
215
|
+
token: Bsv21TokenData;
|
|
216
|
+
status: TokenStatus;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* BSV21 token funding/activity status
|
|
220
|
+
*/
|
|
221
|
+
export interface TokenStatus {
|
|
222
|
+
token_id: string;
|
|
223
|
+
is_active: boolean;
|
|
224
|
+
balance: number;
|
|
225
|
+
credits: number;
|
|
226
|
+
debits: number;
|
|
227
|
+
output_count: number;
|
|
228
|
+
fee_per_output: number;
|
|
229
|
+
fee_address: string;
|
|
230
|
+
is_whitelisted: boolean;
|
|
231
|
+
is_blacklisted: boolean;
|
|
232
|
+
}
|
|
223
233
|
/**
|
|
224
234
|
* BSV21 output data from overlay API
|
|
225
235
|
*/
|
|
226
236
|
export interface Bsv21OutputData {
|
|
227
|
-
txid
|
|
237
|
+
txid?: string;
|
|
228
238
|
vout: number;
|
|
229
239
|
data: {
|
|
230
240
|
bsv21: Bsv21TokenData;
|
|
231
241
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
spend: string | null;
|
|
235
|
-
score: number;
|
|
242
|
+
spend?: string | null;
|
|
243
|
+
score?: number;
|
|
236
244
|
}
|
|
237
245
|
/**
|
|
238
246
|
* BSV21 transaction data from overlay API
|
|
@@ -242,6 +250,7 @@ export interface Bsv21TransactionData {
|
|
|
242
250
|
inputs: Bsv21OutputData[];
|
|
243
251
|
outputs: Bsv21OutputData[];
|
|
244
252
|
beef?: string;
|
|
253
|
+
block_height?: number;
|
|
245
254
|
}
|
|
246
255
|
/**
|
|
247
256
|
* Event from SSE subscription
|