@1sat/wallet 0.0.3 → 0.0.4
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/OneSatWallet.d.ts +222 -0
- package/dist/OneSatWallet.d.ts.map +1 -0
- package/dist/OneSatWallet.js +754 -0
- package/dist/OneSatWallet.js.map +1 -0
- package/dist/address-sync/AddressManager.d.ts +86 -0
- package/dist/address-sync/AddressManager.d.ts.map +1 -0
- package/dist/address-sync/AddressManager.js +108 -0
- package/dist/address-sync/AddressManager.js.map +1 -0
- package/dist/address-sync/AddressSyncManager.d.ts +204 -0
- package/dist/address-sync/AddressSyncManager.d.ts.map +1 -0
- package/dist/address-sync/AddressSyncManager.js +525 -0
- package/dist/address-sync/AddressSyncManager.js.map +1 -0
- package/dist/address-sync/AddressSyncQueueIdb.d.ts +31 -0
- package/dist/address-sync/AddressSyncQueueIdb.d.ts.map +1 -0
- package/dist/address-sync/AddressSyncQueueIdb.js +356 -0
- package/dist/address-sync/AddressSyncQueueIdb.js.map +1 -0
- package/dist/address-sync/AddressSyncQueueSqlite.d.ts +55 -0
- package/dist/address-sync/AddressSyncQueueSqlite.d.ts.map +1 -0
- package/dist/address-sync/AddressSyncQueueSqlite.js +198 -0
- package/dist/address-sync/AddressSyncQueueSqlite.js.map +1 -0
- package/dist/address-sync/index.d.ts +8 -0
- package/dist/address-sync/index.d.ts.map +1 -0
- package/dist/address-sync/index.js +5 -0
- package/dist/address-sync/index.js.map +1 -0
- package/dist/backup/FileBackupProvider.d.ts +97 -0
- package/dist/backup/FileBackupProvider.d.ts.map +1 -0
- package/dist/backup/FileBackupProvider.js +185 -0
- package/dist/backup/FileBackupProvider.js.map +1 -0
- package/dist/backup/FileRestoreReader.d.ts +59 -0
- package/dist/backup/FileRestoreReader.d.ts.map +1 -0
- package/dist/backup/FileRestoreReader.js +89 -0
- package/dist/backup/FileRestoreReader.js.map +1 -0
- package/dist/backup/index.d.ts +6 -0
- package/dist/backup/index.d.ts.map +1 -0
- package/dist/backup/index.js +5 -0
- package/dist/backup/index.js.map +1 -0
- package/dist/backup/types.d.ts +32 -0
- package/dist/backup/types.d.ts.map +1 -0
- package/dist/backup/types.js +2 -0
- package/dist/backup/types.js.map +1 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +6 -0
- package/dist/browser.js.map +1 -0
- package/dist/cwi/chrome.d.ts +12 -0
- package/dist/cwi/chrome.d.ts.map +1 -0
- package/dist/cwi/chrome.js +44 -0
- package/dist/cwi/chrome.js.map +1 -0
- package/dist/cwi/event.d.ts +12 -0
- package/dist/cwi/event.d.ts.map +1 -0
- package/dist/cwi/event.js +39 -0
- package/dist/cwi/event.js.map +1 -0
- package/dist/cwi/factory.d.ts +15 -0
- package/dist/cwi/factory.d.ts.map +1 -0
- package/dist/cwi/factory.js +45 -0
- package/dist/cwi/factory.js.map +1 -0
- package/dist/cwi/index.d.ts +12 -0
- package/dist/cwi/index.d.ts.map +1 -0
- package/dist/cwi/index.js +12 -0
- package/dist/cwi/index.js.map +1 -0
- package/dist/cwi/types.d.ts +40 -0
- package/dist/cwi/types.d.ts.map +1 -0
- package/dist/cwi/types.js +40 -0
- package/dist/cwi/types.js.map +1 -0
- package/dist/factory/createWebWallet.d.ts +73 -0
- package/dist/factory/createWebWallet.d.ts.map +1 -0
- package/dist/factory/createWebWallet.js +251 -0
- package/dist/factory/createWebWallet.js.map +1 -0
- package/dist/factory/fullSync.d.ts +58 -0
- package/dist/factory/fullSync.d.ts.map +1 -0
- package/dist/factory/fullSync.js +92 -0
- package/dist/factory/fullSync.js.map +1 -0
- package/dist/factory/index.d.ts +5 -0
- package/dist/factory/index.d.ts.map +1 -0
- package/dist/factory/index.js +3 -0
- package/dist/factory/index.js.map +1 -0
- package/dist/index.d.ts +18 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -21
- package/dist/index.js.map +1 -1
- package/dist/indexers/Bsv21Indexer.d.ts +36 -0
- package/dist/indexers/Bsv21Indexer.d.ts.map +1 -0
- package/dist/indexers/Bsv21Indexer.js +232 -0
- package/dist/indexers/Bsv21Indexer.js.map +1 -0
- package/dist/indexers/CosignIndexer.d.ts +14 -0
- package/dist/indexers/CosignIndexer.d.ts.map +1 -0
- package/dist/indexers/CosignIndexer.js +27 -0
- package/dist/indexers/CosignIndexer.js.map +1 -0
- package/dist/indexers/FundIndexer.d.ts +20 -0
- package/dist/indexers/FundIndexer.d.ts.map +1 -0
- package/dist/indexers/FundIndexer.js +65 -0
- package/dist/indexers/FundIndexer.js.map +1 -0
- package/dist/indexers/InscriptionIndexer.d.ts +33 -0
- package/dist/indexers/InscriptionIndexer.d.ts.map +1 -0
- package/dist/indexers/InscriptionIndexer.js +116 -0
- package/dist/indexers/InscriptionIndexer.js.map +1 -0
- package/dist/indexers/LockIndexer.d.ts +11 -0
- package/dist/indexers/LockIndexer.d.ts.map +1 -0
- package/dist/indexers/LockIndexer.js +44 -0
- package/dist/indexers/LockIndexer.js.map +1 -0
- package/dist/indexers/MapIndexer.d.ts +14 -0
- package/dist/indexers/MapIndexer.d.ts.map +1 -0
- package/dist/indexers/MapIndexer.js +65 -0
- package/dist/indexers/MapIndexer.js.map +1 -0
- package/dist/indexers/OpNSIndexer.d.ts +10 -0
- package/dist/indexers/OpNSIndexer.d.ts.map +1 -0
- package/dist/indexers/OpNSIndexer.js +39 -0
- package/dist/indexers/OpNSIndexer.js.map +1 -0
- package/dist/indexers/OrdLockIndexer.d.ts +18 -0
- package/dist/indexers/OrdLockIndexer.d.ts.map +1 -0
- package/dist/indexers/OrdLockIndexer.js +65 -0
- package/dist/indexers/OrdLockIndexer.js.map +1 -0
- package/dist/indexers/OriginIndexer.d.ts +38 -0
- package/dist/indexers/OriginIndexer.d.ts.map +1 -0
- package/dist/indexers/OriginIndexer.js +241 -0
- package/dist/indexers/OriginIndexer.js.map +1 -0
- package/dist/indexers/Outpoint.d.ts +11 -0
- package/dist/indexers/Outpoint.d.ts.map +1 -0
- package/dist/indexers/Outpoint.js +62 -0
- package/dist/indexers/Outpoint.js.map +1 -0
- package/dist/indexers/SigmaIndexer.d.ts +29 -0
- package/dist/indexers/SigmaIndexer.d.ts.map +1 -0
- package/dist/indexers/SigmaIndexer.js +134 -0
- package/dist/indexers/SigmaIndexer.js.map +1 -0
- package/dist/indexers/index.d.ts +14 -0
- package/dist/indexers/index.d.ts.map +1 -0
- package/dist/indexers/index.js +14 -0
- package/dist/indexers/index.js.map +1 -0
- package/dist/indexers/parseAddress.d.ts +10 -0
- package/dist/indexers/parseAddress.d.ts.map +1 -0
- package/dist/indexers/parseAddress.js +25 -0
- package/dist/indexers/parseAddress.js.map +1 -0
- package/dist/node.d.ts +6 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +6 -0
- package/dist/node.js.map +1 -0
- package/dist/signers/ReadOnlySigner.d.ts +16 -0
- package/dist/signers/ReadOnlySigner.d.ts.map +1 -0
- package/dist/signers/ReadOnlySigner.js +48 -0
- package/dist/signers/ReadOnlySigner.js.map +1 -0
- package/package.json +21 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullSync.d.ts","sourceRoot":"","sources":["../../src/factory/fullSync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAA;AAC9F,OAAO,KAAK,EAAE,GAAG,IAAI,gBAAgB,EAAE,MAAM,oDAAoD,CAAA;AAIjG,KAAK,qBAAqB,GAAG,gBAAgB,CAAC,qBAAqB,CAAA;AAEnE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAA;AAE5E,MAAM,WAAW,eAAe;IAC/B,4BAA4B;IAC5B,OAAO,EAAE,oBAAoB,CAAA;IAC7B,qDAAqD;IACrD,aAAa,EAAE,qBAAqB,CAAA;IACpC,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,iCAAiC;IACjC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5D,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC7B,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,cAAc,CAAC,CAwGzB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full wallet synchronization with remote backup server.
|
|
3
|
+
*
|
|
4
|
+
* Performs a complete resync: push local → reset sync state → full pull from server.
|
|
5
|
+
* This is a deliberate user action (not automatic) for recovering from sync issues.
|
|
6
|
+
*/
|
|
7
|
+
import { createSyncMap } from '@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities/EntityBase.js';
|
|
8
|
+
import { EntitySyncState } from '@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities/EntitySyncState.js';
|
|
9
|
+
/**
|
|
10
|
+
* Perform a full sync with the remote backup server.
|
|
11
|
+
*
|
|
12
|
+
* Steps:
|
|
13
|
+
* 1. Push all local data to remote backup
|
|
14
|
+
* 2. Clear local syncMap / reset sync state
|
|
15
|
+
* 3. Pull ALL data from server (not incremental)
|
|
16
|
+
* 4. Rebuild complete server→client ID mappings
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const result = await fullSync({
|
|
21
|
+
* storage,
|
|
22
|
+
* remoteStorage: remoteClient,
|
|
23
|
+
* identityKey: pubKey,
|
|
24
|
+
* onProgress: (stage, msg) => console.log(`[${stage}] ${msg}`)
|
|
25
|
+
* });
|
|
26
|
+
* console.log(`Pushed: ${result.pushed.inserts}/${result.pushed.updates}`);
|
|
27
|
+
* console.log(`Pulled: ${result.pulled.inserts}/${result.pulled.updates}`);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export async function fullSync(options) {
|
|
31
|
+
const { storage, remoteStorage, identityKey, onProgress, maxRoughSize = 1000000, // 1 MB default
|
|
32
|
+
maxItems = 100, } = options;
|
|
33
|
+
// Step 1: Push ALL local data to remote (bypassing timestamp filter)
|
|
34
|
+
onProgress?.('pushing', 'Pushing local data to remote...');
|
|
35
|
+
const localSettings = storage.getSettings();
|
|
36
|
+
const remoteSettings = await remoteStorage.makeAvailable();
|
|
37
|
+
let pushInserts = 0;
|
|
38
|
+
let pushUpdates = 0;
|
|
39
|
+
let chunkCount = 0;
|
|
40
|
+
for (;;) {
|
|
41
|
+
// Get sync state from remote for proper offsets
|
|
42
|
+
const ss = await EntitySyncState.fromStorage(remoteStorage, identityKey, localSettings);
|
|
43
|
+
const args = ss.makeRequestSyncChunkArgs(identityKey, remoteSettings.storageIdentityKey, maxRoughSize, maxItems);
|
|
44
|
+
// KEY: Override since to undefined - includes ALL data regardless of timestamp
|
|
45
|
+
args.since = undefined;
|
|
46
|
+
// Get chunk from local storage
|
|
47
|
+
const chunk = await storage.runAsSync(async (sync) => sync.getSyncChunk(args));
|
|
48
|
+
// Send chunk to remote
|
|
49
|
+
const result = await remoteStorage.processSyncChunk(args, chunk);
|
|
50
|
+
pushInserts += result.inserts;
|
|
51
|
+
pushUpdates += result.updates;
|
|
52
|
+
chunkCount++;
|
|
53
|
+
onProgress?.('pushing', `Chunk ${chunkCount}: ${result.inserts} inserts, ${result.updates} updates`);
|
|
54
|
+
if (result.done)
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
onProgress?.('pushing', `Pushed ${pushInserts} inserts, ${pushUpdates} updates`);
|
|
58
|
+
// Step 2: Reset sync state to force full pull
|
|
59
|
+
onProgress?.('resetting', 'Resetting sync state...');
|
|
60
|
+
const auth = await storage.getAuth();
|
|
61
|
+
await storage.runAsStorageProvider(async (active) => {
|
|
62
|
+
const syncStates = await active.findSyncStates({
|
|
63
|
+
partial: {
|
|
64
|
+
userId: auth.userId,
|
|
65
|
+
storageIdentityKey: remoteSettings.storageIdentityKey,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (syncStates.length > 0) {
|
|
69
|
+
const syncState = syncStates[0];
|
|
70
|
+
await active.updateSyncState(syncState.syncStateId, {
|
|
71
|
+
syncMap: JSON.stringify(createSyncMap()),
|
|
72
|
+
when: undefined,
|
|
73
|
+
status: 'unknown',
|
|
74
|
+
});
|
|
75
|
+
onProgress?.('resetting', 'Sync state reset complete');
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
onProgress?.('resetting', 'No existing sync state found');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Step 3: Pull from remote (full pull due to reset state)
|
|
82
|
+
onProgress?.('pulling', 'Pulling all data from remote...');
|
|
83
|
+
const pullResult = await storage.syncFromReader(identityKey, remoteStorage);
|
|
84
|
+
onProgress?.('pulling', `Pulled ${pullResult.inserts} inserts, ${pullResult.updates} updates`);
|
|
85
|
+
// Step 4: Complete
|
|
86
|
+
onProgress?.('complete', 'Full sync complete');
|
|
87
|
+
return {
|
|
88
|
+
pushed: { inserts: pushInserts, updates: pushUpdates },
|
|
89
|
+
pulled: { inserts: pullResult.inserts, updates: pullResult.updates },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=fullSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullSync.js","sourceRoot":"","sources":["../../src/factory/fullSync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,0EAA0E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AAW,EAAE,aAAa,CAAC,CAAA;IAE3E,UAAU,EAAE,CACX,SAAS,EACT,UAAU,UAAU,CAAC,OAAO,aAAa,UAAU,CAAC,OAAO,UAAU,CACrE,CAAA;IAED,mBAAmB;IACnB,UAAU,EAAE,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAA;IAE9C,OAAO;QACN,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;QACtD,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE;KACpE,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createWebWallet } from './createWebWallet';
|
|
2
|
+
export type { WebWalletConfig, WebWalletResult } from './createWebWallet';
|
|
3
|
+
export { fullSync } from './fullSync';
|
|
4
|
+
export type { FullSyncOptions, FullSyncResult, FullSyncStage } from './fullSync';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @1sat/wallet - BRC-100 Wallet Engine for 1Sat Ordinals SDK
|
|
3
3
|
*
|
|
4
|
-
* This package provides the wallet functionality for the 1Sat SDK
|
|
5
|
-
* wrapping 1sat-wallet-toolbox with SDK-specific integrations.
|
|
4
|
+
* This package provides the wallet functionality for the 1Sat SDK.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* ```typescript
|
|
9
|
-
* import { OneSatWallet,
|
|
8
|
+
* import { OneSatWallet, OneSatServices } from '@1sat/wallet'
|
|
9
|
+
* import { WalletStorageManager, StorageIdb } from '@bsv/wallet-toolbox/mobile'
|
|
10
10
|
*
|
|
11
|
-
* // Create storage
|
|
12
|
-
* const storage = await WalletStorageManager.
|
|
11
|
+
* // Create storage (from @bsv/wallet-toolbox)
|
|
12
|
+
* const storage = await WalletStorageManager.createWalletStorageManager(
|
|
13
13
|
* new StorageIdb({ name: 'my-wallet' })
|
|
14
14
|
* )
|
|
15
15
|
*
|
|
16
|
-
* // Initialize wallet
|
|
16
|
+
* // Initialize wallet
|
|
17
17
|
* const wallet = new OneSatWallet({
|
|
18
|
-
* rootKey:
|
|
18
|
+
* rootKey: privateKey,
|
|
19
19
|
* storage,
|
|
20
20
|
* chain: 'main',
|
|
21
21
|
* owners: new Set([address1, address2])
|
|
22
22
|
* })
|
|
23
23
|
*
|
|
24
|
-
* // Or with full signing capability
|
|
25
|
-
* const signingWallet = new OneSatWallet({
|
|
26
|
-
* rootKey: privateKey,
|
|
27
|
-
* storage,
|
|
28
|
-
* chain: 'main'
|
|
29
|
-
* })
|
|
30
|
-
*
|
|
31
24
|
* // Sync and use
|
|
32
|
-
*
|
|
25
|
+
* wallet.syncAll()
|
|
33
26
|
* ```
|
|
34
27
|
*/
|
|
35
|
-
export { OneSatWallet, type
|
|
36
|
-
export { OneSatServices
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
28
|
+
export { OneSatWallet, type IngestResult, type OneSatWalletArgs, type OneSatWalletEvents, } from './OneSatWallet';
|
|
29
|
+
export { OneSatServices } from '@1sat/client';
|
|
30
|
+
export type { Bsv21OutputData, Bsv21TokenData, Bsv21TransactionData, Capability, OrdfsMetadata, SyncOutput, } from '@1sat/types';
|
|
31
|
+
export { ReadOnlySigner } from './signers/ReadOnlySigner';
|
|
32
|
+
export { ArcadeClient, BaseClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OwnerClient, OverlayClient, TxoClient, } from '@1sat/client';
|
|
33
|
+
export { Bsv21Indexer, CosignIndexer, deriveFundAddress, FundIndexer, Indexer, InscriptionIndexer, LockIndexer, Listing, MapIndexer, OpNSIndexer, OrdLockIndexer, OriginIndexer, Outpoint, parseAddress, SigmaIndexer, type Bsv21, type CosignData, type File, type IndexData, type IndexSummary, type Inscription, type Origin, type ParseContext, type ParseResult, type Sigma, type Txo, } from './indexers';
|
|
34
|
+
export { AddressManager, AddressSyncFetcher, AddressSyncManager, AddressSyncProcessor, AddressSyncQueueIdb, AddressSyncQueueSqlite, BRC29_PROTOCOL_ID, YOURS_PREFIX, type AddressDerivation, type AddressSyncEvents, type AddressSyncFetcherEvents, type AddressSyncFetcherOptions, type AddressSyncManagerOptions, type AddressSyncProcessorEvents, type AddressSyncProcessorOptions, type AddressSyncQueueInput, type AddressSyncQueueItem, type AddressSyncQueueItemStatus, type AddressSyncQueueStats, type AddressSyncQueueStorage, type AddressSyncState, } from './address-sync';
|
|
35
|
+
export { FileBackupProvider, FileRestoreReader, Zip, ZipDeflate, unzip, type BackupManifest, type BackupProgressCallback, type BackupProgressEvent, type Unzipped, } from './backup';
|
|
36
|
+
export { createWebWallet, fullSync, type FullSyncOptions, type FullSyncResult, type FullSyncStage, type WebWalletConfig, type WebWalletResult, } from './factory';
|
|
37
|
+
export { ChromeCWI, CWIEventName, EventCWI, createChromeCWI, createCWI, createEventCWI, type CWIResponseDetail, type CWITransport, } from './cwi';
|
|
40
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EACN,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACvB,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,YAAY,EACX,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,UAAU,GACV,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,GACT,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,GAAG,GACR,MAAM,YAAY,CAAA;AAGnB,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACrB,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,UAAU,EACV,KAAK,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,QAAQ,GACb,MAAM,UAAU,CAAA;AAGjB,OAAO,EACN,eAAe,EACf,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,YAAY,GACjB,MAAM,OAAO,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @1sat/wallet - BRC-100 Wallet Engine for 1Sat Ordinals SDK
|
|
3
3
|
*
|
|
4
|
-
* This package provides the wallet functionality for the 1Sat SDK
|
|
5
|
-
* wrapping 1sat-wallet-toolbox with SDK-specific integrations.
|
|
4
|
+
* This package provides the wallet functionality for the 1Sat SDK.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* ```typescript
|
|
9
|
-
* import { OneSatWallet,
|
|
8
|
+
* import { OneSatWallet, OneSatServices } from '@1sat/wallet'
|
|
9
|
+
* import { WalletStorageManager, StorageIdb } from '@bsv/wallet-toolbox/mobile'
|
|
10
10
|
*
|
|
11
|
-
* // Create storage
|
|
12
|
-
* const storage = await WalletStorageManager.
|
|
11
|
+
* // Create storage (from @bsv/wallet-toolbox)
|
|
12
|
+
* const storage = await WalletStorageManager.createWalletStorageManager(
|
|
13
13
|
* new StorageIdb({ name: 'my-wallet' })
|
|
14
14
|
* )
|
|
15
15
|
*
|
|
16
|
-
* // Initialize wallet
|
|
16
|
+
* // Initialize wallet
|
|
17
17
|
* const wallet = new OneSatWallet({
|
|
18
|
-
* rootKey:
|
|
18
|
+
* rootKey: privateKey,
|
|
19
19
|
* storage,
|
|
20
20
|
* chain: 'main',
|
|
21
21
|
* owners: new Set([address1, address2])
|
|
22
22
|
* })
|
|
23
23
|
*
|
|
24
|
-
* // Or with full signing capability
|
|
25
|
-
* const signingWallet = new OneSatWallet({
|
|
26
|
-
* rootKey: privateKey,
|
|
27
|
-
* storage,
|
|
28
|
-
* chain: 'main'
|
|
29
|
-
* })
|
|
30
|
-
*
|
|
31
24
|
* // Sync and use
|
|
32
|
-
*
|
|
25
|
+
* wallet.syncAll()
|
|
33
26
|
* ```
|
|
34
27
|
*/
|
|
35
28
|
// Core wallet exports
|
|
36
|
-
export { OneSatWallet, } from '
|
|
29
|
+
export { OneSatWallet, } from './OneSatWallet';
|
|
37
30
|
// Services
|
|
38
|
-
export { OneSatServices } from '@1sat/
|
|
31
|
+
export { OneSatServices } from '@1sat/client';
|
|
39
32
|
// Signers
|
|
40
|
-
export { ReadOnlySigner } from '
|
|
33
|
+
export { ReadOnlySigner } from './signers/ReadOnlySigner';
|
|
34
|
+
// API Clients
|
|
35
|
+
export { ArcadeClient, BaseClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OwnerClient, OverlayClient, TxoClient, } from '@1sat/client';
|
|
41
36
|
// Indexers
|
|
42
|
-
export { Bsv21Indexer, CosignIndexer, deriveFundAddress, FundIndexer, Indexer, InscriptionIndexer, LockIndexer, Listing,
|
|
43
|
-
//
|
|
44
|
-
export {
|
|
37
|
+
export { Bsv21Indexer, CosignIndexer, deriveFundAddress, FundIndexer, Indexer, InscriptionIndexer, LockIndexer, Listing, MapIndexer, OpNSIndexer, OrdLockIndexer, OriginIndexer, Outpoint, parseAddress, SigmaIndexer, } from './indexers';
|
|
38
|
+
// Address sync
|
|
39
|
+
export { AddressManager, AddressSyncFetcher, AddressSyncManager, AddressSyncProcessor, AddressSyncQueueIdb, AddressSyncQueueSqlite, BRC29_PROTOCOL_ID, YOURS_PREFIX, } from './address-sync';
|
|
40
|
+
// Backup
|
|
41
|
+
export { FileBackupProvider, FileRestoreReader, Zip, ZipDeflate, unzip, } from './backup';
|
|
42
|
+
// Factory
|
|
43
|
+
export { createWebWallet, fullSync, } from './factory';
|
|
44
|
+
// CWI (Compute With Integrity)
|
|
45
|
+
export { ChromeCWI, CWIEventName, EventCWI, createChromeCWI, createCWI, createEventCWI, } from './cwi';
|
|
46
|
+
// Note: Storage utilities (StorageIdb, WalletStorageManager, Chain) should be
|
|
47
|
+
// imported directly from '@bsv/wallet-toolbox/mobile'
|
|
45
48
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,sBAAsB;AACtB,OAAO,EACN,YAAY,GAIZ,MAAM,gBAAgB,CAAA;AAEvB,WAAW;AACX,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAU7C,UAAU;AACV,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,cAAc;AACd,OAAO,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,GACT,MAAM,cAAc,CAAA;AAErB,WAAW;AACX,OAAO,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,GAYZ,MAAM,YAAY,CAAA;AAEnB,eAAe;AACf,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,GAcZ,MAAM,gBAAgB,CAAA;AAEvB,SAAS;AACT,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,UAAU,EACV,KAAK,GAKL,MAAM,UAAU,CAAA;AAEjB,UAAU;AACV,OAAO,EACN,eAAe,EACf,QAAQ,GAMR,MAAM,WAAW,CAAA;AAElB,+BAA+B;AAC/B,OAAO,EACN,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,GAGd,MAAM,OAAO,CAAA;AAEd,8EAA8E;AAC9E,sDAAsD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type OneSatServices } from '@1sat/client';
|
|
2
|
+
import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from '@1sat/types';
|
|
3
|
+
export interface Bsv21 {
|
|
4
|
+
id: string;
|
|
5
|
+
op: string;
|
|
6
|
+
amt: bigint;
|
|
7
|
+
dec: number;
|
|
8
|
+
sym?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
status: 'valid' | 'invalid' | 'pending';
|
|
11
|
+
reason?: string;
|
|
12
|
+
fundAddress: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Bsv21Indexer identifies and validates BSV21 tokens.
|
|
16
|
+
* These are 1-sat outputs with application/bsv-20 inscription type.
|
|
17
|
+
*
|
|
18
|
+
* Data structure: Bsv21 with id, op, amt, dec, status, etc.
|
|
19
|
+
*
|
|
20
|
+
* Basket: 'bsv21'
|
|
21
|
+
* Events: id, id:status, bsv21:amt
|
|
22
|
+
*/
|
|
23
|
+
export declare class Bsv21Indexer extends Indexer {
|
|
24
|
+
owners: Set<string>;
|
|
25
|
+
network: 'mainnet' | 'testnet';
|
|
26
|
+
services: OneSatServices;
|
|
27
|
+
tag: string;
|
|
28
|
+
name: string;
|
|
29
|
+
constructor(owners: Set<string>, network: 'mainnet' | 'testnet', services: OneSatServices);
|
|
30
|
+
parse(txo: Txo): Promise<ParseResult | undefined>;
|
|
31
|
+
summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
32
|
+
serialize(bsv21: Bsv21): string;
|
|
33
|
+
deserialize(str: string): Bsv21;
|
|
34
|
+
}
|
|
35
|
+
export declare function deriveFundAddress(idOrOutpoint: string | number[]): string;
|
|
36
|
+
//# sourceMappingURL=Bsv21Indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bsv21Indexer.d.ts","sourceRoot":"","sources":["../../src/indexers/Bsv21Indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7D,OAAO,EACN,KAAK,YAAY,EACjB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,MAAM,aAAa,CAAA;AAMpB,MAAM,WAAW,KAAK;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAa,SAAQ,OAAO;IAKhC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,OAAO,EAAE,SAAS,GAAG,SAAS;IAC9B,QAAQ,EAAE,cAAc;IANhC,GAAG,SAAU;IACb,IAAI,SAAiB;gBAGb,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EACnB,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,QAAQ,EAAE,cAAc;IAK1B,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAuEjD,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA0HrE,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAO/B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;CAO/B;AAsBD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAOzE"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { HttpError } from '@1sat/client';
|
|
2
|
+
import { BSV21_FEE_XPUB } from '@1sat/types';
|
|
3
|
+
import { Indexer, } from '@1sat/types';
|
|
4
|
+
import { BSV21 } from '@bopen-io/templates';
|
|
5
|
+
import { HD, Hash, Utils } from '@bsv/sdk';
|
|
6
|
+
const hdKey = HD.fromString(BSV21_FEE_XPUB);
|
|
7
|
+
/**
|
|
8
|
+
* Bsv21Indexer identifies and validates BSV21 tokens.
|
|
9
|
+
* These are 1-sat outputs with application/bsv-20 inscription type.
|
|
10
|
+
*
|
|
11
|
+
* Data structure: Bsv21 with id, op, amt, dec, status, etc.
|
|
12
|
+
*
|
|
13
|
+
* Basket: 'bsv21'
|
|
14
|
+
* Events: id, id:status, bsv21:amt
|
|
15
|
+
*/
|
|
16
|
+
export class Bsv21Indexer extends Indexer {
|
|
17
|
+
owners;
|
|
18
|
+
network;
|
|
19
|
+
services;
|
|
20
|
+
tag = 'bsv21';
|
|
21
|
+
name = 'BSV21 Tokens';
|
|
22
|
+
constructor(owners, network, services) {
|
|
23
|
+
super(owners, network);
|
|
24
|
+
this.owners = owners;
|
|
25
|
+
this.network = network;
|
|
26
|
+
this.services = services;
|
|
27
|
+
}
|
|
28
|
+
async parse(txo) {
|
|
29
|
+
const lockingScript = txo.output.lockingScript;
|
|
30
|
+
// Use template decode
|
|
31
|
+
const decoded = BSV21.decode(lockingScript);
|
|
32
|
+
if (!decoded)
|
|
33
|
+
return;
|
|
34
|
+
const outpoint = txo.outpoint;
|
|
35
|
+
const tokenData = decoded.tokenData;
|
|
36
|
+
// Determine token ID - for deploy ops it's this outpoint, otherwise from inscription
|
|
37
|
+
const tokenId = tokenData.id || outpoint.toOrdinalString();
|
|
38
|
+
// Determine initial status:
|
|
39
|
+
// - deploy ops (deploy+mint, deploy+auth) are always valid (they create the token)
|
|
40
|
+
// - transfer/burn ops start as pending until validated in summarize()
|
|
41
|
+
const isDeploy = tokenData.op.startsWith('deploy');
|
|
42
|
+
const initialStatus = isDeploy ? 'valid' : 'pending';
|
|
43
|
+
// Create indexer data structure with basic info from inscription
|
|
44
|
+
const bsv21 = {
|
|
45
|
+
id: tokenId,
|
|
46
|
+
op: tokenData.op,
|
|
47
|
+
amt: decoded.getAmount(),
|
|
48
|
+
dec: decoded.getDecimals(),
|
|
49
|
+
sym: tokenData.sym,
|
|
50
|
+
icon: tokenData.icon,
|
|
51
|
+
status: initialStatus,
|
|
52
|
+
fundAddress: deriveFundAddress(outpoint.toBEBinary()),
|
|
53
|
+
};
|
|
54
|
+
// For non-deploy ops, fetch token metadata from server (cached)
|
|
55
|
+
// This ensures we always have sym, dec, icon for any token
|
|
56
|
+
if (!isDeploy) {
|
|
57
|
+
try {
|
|
58
|
+
const details = await this.services.bsv21.getTokenDetails(tokenId);
|
|
59
|
+
bsv21.sym = details.token.sym;
|
|
60
|
+
bsv21.icon = resolveIcon(details.token.icon, tokenId);
|
|
61
|
+
bsv21.dec = Number(details.token.dec) || 0;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
// Token not found on server - could be unconfirmed or invalid
|
|
65
|
+
// Keep local values from inscription, status remains pending
|
|
66
|
+
if (!(e instanceof HttpError && e.status === 404)) {
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// For deploy ops, resolve relative icon reference if present
|
|
73
|
+
bsv21.icon = resolveIcon(bsv21.icon, tokenId);
|
|
74
|
+
}
|
|
75
|
+
// Validate amount range
|
|
76
|
+
if (bsv21.amt <= 0n || bsv21.amt > 2n ** 64n - 1n)
|
|
77
|
+
return;
|
|
78
|
+
const tags = [];
|
|
79
|
+
if (txo.owner && this.owners.has(txo.owner)) {
|
|
80
|
+
tags.push(`id:${bsv21.id}`);
|
|
81
|
+
tags.push(`amt:${bsv21.amt.toString()}`);
|
|
82
|
+
// Add metadata tags for efficient querying
|
|
83
|
+
if (bsv21.sym)
|
|
84
|
+
tags.push(`sym:${bsv21.sym}`);
|
|
85
|
+
if (bsv21.icon)
|
|
86
|
+
tags.push(`icon:${bsv21.icon}`);
|
|
87
|
+
tags.push(`dec:${bsv21.dec}`);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
data: bsv21,
|
|
91
|
+
tags,
|
|
92
|
+
basket: 'bsv21',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async summarize(ctx) {
|
|
96
|
+
// Track token flows per token ID for validation
|
|
97
|
+
const tokenFlows = {};
|
|
98
|
+
let summaryToken;
|
|
99
|
+
let summaryBalance = 0;
|
|
100
|
+
// Process inputs from ctx.spends (already parsed)
|
|
101
|
+
for (const spend of ctx.spends) {
|
|
102
|
+
const bsv21 = spend.data.bsv21;
|
|
103
|
+
if (!bsv21)
|
|
104
|
+
continue;
|
|
105
|
+
const tokenData = bsv21.data;
|
|
106
|
+
// Initialize token tracking
|
|
107
|
+
if (!tokenFlows[tokenData.id]) {
|
|
108
|
+
tokenFlows[tokenData.id] = {
|
|
109
|
+
tokensIn: 0n,
|
|
110
|
+
tokensOut: 0n,
|
|
111
|
+
inputsPending: false,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const flow = tokenFlows[tokenData.id];
|
|
115
|
+
// Validate this input exists on the overlay
|
|
116
|
+
try {
|
|
117
|
+
await this.services.bsv21.getTokenByTxid(tokenData.id, spend.outpoint.txid);
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
if (e instanceof HttpError && e.status === 404) {
|
|
121
|
+
// Input not on overlay yet - outputs will be pending
|
|
122
|
+
flow.inputsPending = true;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Accumulate tokens in
|
|
129
|
+
flow.tokensIn += tokenData.amt;
|
|
130
|
+
if (!summaryToken)
|
|
131
|
+
summaryToken = tokenData;
|
|
132
|
+
// Track balance change for owned inputs
|
|
133
|
+
if (summaryToken &&
|
|
134
|
+
tokenData.id === summaryToken.id &&
|
|
135
|
+
spend.owner &&
|
|
136
|
+
this.owners.has(spend.owner)) {
|
|
137
|
+
summaryBalance -= Number(tokenData.amt);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Process outputs: accumulate tokensOut and validate
|
|
141
|
+
for (const txo of ctx.txos) {
|
|
142
|
+
const bsv21 = txo.data.bsv21;
|
|
143
|
+
if (!bsv21 || !['transfer', 'burn'].includes(bsv21.data.op))
|
|
144
|
+
continue;
|
|
145
|
+
const tokenData = bsv21.data;
|
|
146
|
+
const flow = tokenFlows[tokenData.id];
|
|
147
|
+
if (flow) {
|
|
148
|
+
flow.tokensOut += tokenData.amt;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// No inputs for this token - invalid (attempting to create tokens from nothing)
|
|
152
|
+
tokenData.status = 'invalid';
|
|
153
|
+
}
|
|
154
|
+
if (!summaryToken)
|
|
155
|
+
summaryToken = tokenData;
|
|
156
|
+
// Track balance change for owned outputs
|
|
157
|
+
if (summaryToken &&
|
|
158
|
+
tokenData.id === summaryToken.id &&
|
|
159
|
+
txo.owner &&
|
|
160
|
+
this.owners.has(txo.owner)) {
|
|
161
|
+
summaryBalance += Number(tokenData.amt);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Finalize validation and apply status to outputs
|
|
165
|
+
for (const txo of ctx.txos) {
|
|
166
|
+
const bsv21 = txo.data.bsv21;
|
|
167
|
+
if (!bsv21 || !['transfer', 'burn'].includes(bsv21.data.op))
|
|
168
|
+
continue;
|
|
169
|
+
const tokenData = bsv21.data;
|
|
170
|
+
if (tokenData.status === 'invalid')
|
|
171
|
+
continue; // Already marked invalid
|
|
172
|
+
const flow = tokenFlows[tokenData.id];
|
|
173
|
+
if (!flow)
|
|
174
|
+
continue;
|
|
175
|
+
// Determine final status
|
|
176
|
+
if (flow.inputsPending) {
|
|
177
|
+
tokenData.status = 'pending';
|
|
178
|
+
}
|
|
179
|
+
else if (flow.tokensIn >= flow.tokensOut) {
|
|
180
|
+
tokenData.status = 'valid';
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
tokenData.status = 'invalid';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (summaryToken?.sym) {
|
|
187
|
+
return {
|
|
188
|
+
id: summaryToken.sym,
|
|
189
|
+
amount: summaryBalance / 10 ** (summaryToken.dec || 0),
|
|
190
|
+
icon: summaryToken.icon,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
serialize(bsv21) {
|
|
195
|
+
return JSON.stringify({
|
|
196
|
+
...bsv21,
|
|
197
|
+
amt: bsv21.amt.toString(10),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
deserialize(str) {
|
|
201
|
+
const obj = JSON.parse(str);
|
|
202
|
+
return {
|
|
203
|
+
...obj,
|
|
204
|
+
amt: BigInt(obj.amt),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Resolve a relative icon reference to an absolute outpoint.
|
|
210
|
+
* If icon starts with "_", it's a relative reference to another output
|
|
211
|
+
* in the same transaction as the token deploy. We resolve it by
|
|
212
|
+
* prepending the token ID's txid.
|
|
213
|
+
*
|
|
214
|
+
* Example: tokenId = "abc123...def_0", icon = "_1" -> "abc123...def_1"
|
|
215
|
+
*/
|
|
216
|
+
function resolveIcon(icon, tokenId) {
|
|
217
|
+
if (!icon || !icon.startsWith('_'))
|
|
218
|
+
return icon;
|
|
219
|
+
// Token ID format is "txid_vout", extract the txid
|
|
220
|
+
const txid = tokenId.substring(0, 64);
|
|
221
|
+
// Icon format is "_vout", combine with txid
|
|
222
|
+
return `${txid}${icon}`;
|
|
223
|
+
}
|
|
224
|
+
export function deriveFundAddress(idOrOutpoint) {
|
|
225
|
+
const hash = Hash.sha256(idOrOutpoint);
|
|
226
|
+
const reader = new Utils.Reader(hash);
|
|
227
|
+
let path = `m/21/${reader.readUInt32BE() >> 1}`;
|
|
228
|
+
reader.pos = 24;
|
|
229
|
+
path += `/${reader.readUInt32BE() >> 1}`;
|
|
230
|
+
return hdKey.derive(path).pubKey.toAddress();
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=Bsv21Indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bsv21Indexer.js","sourceRoot":"","sources":["../../src/indexers/Bsv21Indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAEN,OAAO,GAIP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,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,EAAE,CAAA;IAC/C,MAAM,CAAC,GAAG,GAAG,EAAE,CAAA;IACf,IAAI,IAAI,IAAI,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAA;IACxC,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Indexer, type ParseResult, type Txo } from '@1sat/types';
|
|
2
|
+
export interface CosignData {
|
|
3
|
+
address: string;
|
|
4
|
+
cosigner: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class CosignIndexer extends Indexer {
|
|
7
|
+
owners: Set<string>;
|
|
8
|
+
network: 'mainnet' | 'testnet';
|
|
9
|
+
tag: string;
|
|
10
|
+
name: string;
|
|
11
|
+
constructor(owners?: Set<string>, network?: 'mainnet' | 'testnet');
|
|
12
|
+
parse(txo: Txo): Promise<ParseResult | undefined>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=CosignIndexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosignIndexer.d.ts","sourceRoot":"","sources":["../../src/indexers/CosignIndexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAA;AAGjE,MAAM,WAAW,UAAU;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,aAAc,SAAQ,OAAO;IAKjC,MAAM;IACN,OAAO,EAAE,SAAS,GAAG,SAAS;IALtC,GAAG,SAAW;IACd,IAAI,SAAW;gBAGP,MAAM,cAAoB,EAC1B,OAAO,GAAE,SAAS,GAAG,SAAqB;IAK5C,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;CAcvD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Indexer } from '@1sat/types';
|
|
2
|
+
import { Cosign } from '@bopen-io/templates';
|
|
3
|
+
export class CosignIndexer extends Indexer {
|
|
4
|
+
owners;
|
|
5
|
+
network;
|
|
6
|
+
tag = 'cosign';
|
|
7
|
+
name = 'Cosign';
|
|
8
|
+
constructor(owners = new Set(), network = 'mainnet') {
|
|
9
|
+
super(owners, network);
|
|
10
|
+
this.owners = owners;
|
|
11
|
+
this.network = network;
|
|
12
|
+
}
|
|
13
|
+
async parse(txo) {
|
|
14
|
+
const lockingScript = txo.output.lockingScript;
|
|
15
|
+
// Use template decode
|
|
16
|
+
const decoded = Cosign.decode(lockingScript, this.network === 'mainnet');
|
|
17
|
+
if (!decoded)
|
|
18
|
+
return;
|
|
19
|
+
return {
|
|
20
|
+
data: decoded,
|
|
21
|
+
tags: [],
|
|
22
|
+
owner: decoded.address,
|
|
23
|
+
protocol: 'basket insertion', // Cosign script requires cosigner signature
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=CosignIndexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosignIndexer.js","sourceRoot":"","sources":["../../src/indexers/CosignIndexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA8B,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAO5C,MAAM,OAAO,aAAc,SAAQ,OAAO;IAKjC;IACA;IALR,GAAG,GAAG,QAAQ,CAAA;IACd,IAAI,GAAG,QAAQ,CAAA;IAEf,YACQ,SAAS,IAAI,GAAG,EAAU,EAC1B,UAAiC,SAAS;QAEjD,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAHf,WAAM,GAAN,MAAM,CAAoB;QAC1B,YAAO,GAAP,OAAO,CAAmC;IAGlD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,GAAQ;QACnB,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAA;QAE9C,sBAAsB;QACtB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAA;QACxE,IAAI,CAAC,OAAO;YAAE,OAAM;QAEpB,OAAO;YACN,IAAI,EAAE,OAAqB;YAC3B,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,OAAO,CAAC,OAAO;YACtB,QAAQ,EAAE,kBAAkB,EAAE,4CAA4C;SAC1E,CAAA;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type IndexSummary, Indexer, type ParseContext, type ParseResult, type Txo } from '@1sat/types';
|
|
2
|
+
/**
|
|
3
|
+
* FundIndexer identifies P2PKH outputs to owned addresses.
|
|
4
|
+
* These are standard "funding" UTXOs that can be spent normally.
|
|
5
|
+
*
|
|
6
|
+
* Data structure: string (address)
|
|
7
|
+
*
|
|
8
|
+
* Basket: 'fund'
|
|
9
|
+
* Tags: None
|
|
10
|
+
*/
|
|
11
|
+
export declare class FundIndexer extends Indexer {
|
|
12
|
+
owners: Set<string>;
|
|
13
|
+
network: 'mainnet' | 'testnet';
|
|
14
|
+
tag: string;
|
|
15
|
+
name: string;
|
|
16
|
+
constructor(owners?: Set<string>, network?: 'mainnet' | 'testnet');
|
|
17
|
+
parse(txo: Txo): Promise<ParseResult | undefined>;
|
|
18
|
+
summarize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=FundIndexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FundIndexer.d.ts","sourceRoot":"","sources":["../../src/indexers/FundIndexer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,MAAM,aAAa,CAAA;AAGpB;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,OAAO;IAK/B,MAAM;IACN,OAAO,EAAE,SAAS,GAAG,SAAS;IALtC,GAAG,SAAS;IACZ,IAAI,SAAU;gBAGN,MAAM,cAAoB,EAC1B,OAAO,GAAE,SAAS,GAAG,SAAqB;IAK5C,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAcjD,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;CAkCrE"}
|