orbis1-sdk-rn 0.0.1
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/LICENSE +20 -0
- package/Orbis1Sdk.podspec +24 -0
- package/README.md +269 -0
- package/android/build.gradle +78 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/orbis1sdk/AppConstants.kt +25 -0
- package/android/src/main/java/com/orbis1sdk/Orbis1SdkModule.kt +15 -0
- package/android/src/main/java/com/orbis1sdk/Orbis1SdkPackage.kt +33 -0
- package/android/src/main/java/com/orbis1sdk/RgbModule.kt +2100 -0
- package/android/src/main/java/com/orbis1sdk/RgbPackage.kt +33 -0
- package/android/src/main/java/com/orbis1sdk/WalletStore.kt +49 -0
- package/ios/AppConstants.swift +57 -0
- package/ios/Orbis1Sdk.h +5 -0
- package/ios/Orbis1Sdk.mm +1765 -0
- package/ios/Rgb.h +5 -0
- package/ios/Rgb.mm +1761 -0
- package/ios/Rgb.swift +2094 -0
- package/ios/RgbLib.swift +7871 -0
- package/ios/WalletStore.swift +61 -0
- package/lib/module/Orbis1SDK.js +116 -0
- package/lib/module/Orbis1SDK.js.map +1 -0
- package/lib/module/core/Interfaces.js +65 -0
- package/lib/module/core/Interfaces.js.map +1 -0
- package/lib/module/core/NativeRgb.js +5 -0
- package/lib/module/core/NativeRgb.js.map +1 -0
- package/lib/module/core/RgbError.js +65 -0
- package/lib/module/core/RgbError.js.map +1 -0
- package/lib/module/core/Wallet.js +854 -0
- package/lib/module/core/Wallet.js.map +1 -0
- package/lib/module/errors/FeatureNotEnabledError.js +19 -0
- package/lib/module/errors/FeatureNotEnabledError.js.map +1 -0
- package/lib/module/features/watch-tower/WatchTowerModule.js +94 -0
- package/lib/module/features/watch-tower/WatchTowerModule.js.map +1 -0
- package/lib/module/features/watch-tower/index.js +11 -0
- package/lib/module/features/watch-tower/index.js.map +1 -0
- package/lib/module/features/watch-tower/types/WatchTowerConfig.js +10 -0
- package/lib/module/features/watch-tower/types/WatchTowerConfig.js.map +1 -0
- package/lib/module/features/watch-tower/types/index.js +4 -0
- package/lib/module/features/watch-tower/types/index.js.map +1 -0
- package/lib/module/index.js +58 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/Feature.js +16 -0
- package/lib/module/types/Feature.js.map +1 -0
- package/lib/module/types/IFeatureModule.js +35 -0
- package/lib/module/types/IFeatureModule.js.map +1 -0
- package/lib/module/types/Orbis1CreateConfig.js +29 -0
- package/lib/module/types/Orbis1CreateConfig.js.map +1 -0
- package/lib/module/utils/FeatureRegistry.js +49 -0
- package/lib/module/utils/FeatureRegistry.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Orbis1SDK.d.ts +57 -0
- package/lib/typescript/src/Orbis1SDK.d.ts.map +1 -0
- package/lib/typescript/src/core/Interfaces.d.ts +422 -0
- package/lib/typescript/src/core/Interfaces.d.ts.map +1 -0
- package/lib/typescript/src/core/NativeRgb.d.ts +287 -0
- package/lib/typescript/src/core/NativeRgb.d.ts.map +1 -0
- package/lib/typescript/src/core/RgbError.d.ts +28 -0
- package/lib/typescript/src/core/RgbError.d.ts.map +1 -0
- package/lib/typescript/src/core/Wallet.d.ts +656 -0
- package/lib/typescript/src/core/Wallet.d.ts.map +1 -0
- package/lib/typescript/src/errors/FeatureNotEnabledError.d.ts +11 -0
- package/lib/typescript/src/errors/FeatureNotEnabledError.d.ts.map +1 -0
- package/lib/typescript/src/features/watch-tower/WatchTowerModule.d.ts +38 -0
- package/lib/typescript/src/features/watch-tower/WatchTowerModule.d.ts.map +1 -0
- package/lib/typescript/src/features/watch-tower/index.d.ts +9 -0
- package/lib/typescript/src/features/watch-tower/index.d.ts.map +1 -0
- package/lib/typescript/src/features/watch-tower/types/WatchTowerConfig.d.ts +13 -0
- package/lib/typescript/src/features/watch-tower/types/WatchTowerConfig.d.ts.map +1 -0
- package/lib/typescript/src/features/watch-tower/types/index.d.ts +3 -0
- package/lib/typescript/src/features/watch-tower/types/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +46 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types/Feature.d.ts +10 -0
- package/lib/typescript/src/types/Feature.d.ts.map +1 -0
- package/lib/typescript/src/types/IFeatureModule.d.ts +74 -0
- package/lib/typescript/src/types/IFeatureModule.d.ts.map +1 -0
- package/lib/typescript/src/types/Orbis1CreateConfig.d.ts +26 -0
- package/lib/typescript/src/types/Orbis1CreateConfig.d.ts.map +1 -0
- package/lib/typescript/src/utils/FeatureRegistry.d.ts +19 -0
- package/lib/typescript/src/utils/FeatureRegistry.d.ts.map +1 -0
- package/package.json +190 -0
- package/scripts/download-rgb-lib-ios.js +102 -0
- package/src/Orbis1SDK.ts +132 -0
- package/src/core/Interfaces.ts +412 -0
- package/src/core/NativeRgb.ts +491 -0
- package/src/core/RgbError.ts +84 -0
- package/src/core/Wallet.ts +1127 -0
- package/src/errors/FeatureNotEnabledError.ts +22 -0
- package/src/features/watch-tower/WatchTowerModule.ts +115 -0
- package/src/features/watch-tower/index.ts +9 -0
- package/src/features/watch-tower/types/WatchTowerConfig.ts +15 -0
- package/src/features/watch-tower/types/index.ts +2 -0
- package/src/index.tsx +75 -0
- package/src/types/Feature.ts +13 -0
- package/src/types/IFeatureModule.ts +99 -0
- package/src/types/Orbis1CreateConfig.ts +43 -0
- package/src/utils/FeatureRegistry.ts +61 -0
package/src/Orbis1SDK.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orbis1 SDK – main entry point. Create with Orbis1SDK.create(), then use sdk.watchTower().
|
|
3
|
+
*
|
|
4
|
+
* @module Orbis1SDK
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { IFeatureModule } from './types/IFeatureModule';
|
|
8
|
+
import { Feature } from './types/Feature';
|
|
9
|
+
import type {
|
|
10
|
+
Orbis1CreateConfig,
|
|
11
|
+
Orbis1SDKConfig,
|
|
12
|
+
} from './types/Orbis1CreateConfig';
|
|
13
|
+
import { normalizeCreateConfig } from './types/Orbis1CreateConfig';
|
|
14
|
+
import { FeatureRegistry } from './utils/FeatureRegistry';
|
|
15
|
+
import { WatchTowerModule } from './features/watch-tower';
|
|
16
|
+
|
|
17
|
+
export class Orbis1SDK {
|
|
18
|
+
private config: Orbis1SDKConfig;
|
|
19
|
+
private featureRegistry: FeatureRegistry;
|
|
20
|
+
private initialized = false;
|
|
21
|
+
|
|
22
|
+
constructor(config: Orbis1SDKConfig) {
|
|
23
|
+
if (!config.apiKey || typeof config.apiKey !== 'string') {
|
|
24
|
+
throw new Error('Orbis1SDK requires a non-empty apiKey');
|
|
25
|
+
}
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.featureRegistry = new FeatureRegistry();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create and initialize an Orbis1SDK instance.
|
|
32
|
+
*
|
|
33
|
+
* @param config - apiKey and list of features to enable (e.g. features: ['watchtower'])
|
|
34
|
+
* @returns Initialized SDK instance
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const sdk = await Orbis1SDK.create({
|
|
38
|
+
* apiKey: 'your-api-key',
|
|
39
|
+
* features: ['watchtower']
|
|
40
|
+
* });
|
|
41
|
+
* const watchtower = sdk.watchTower();
|
|
42
|
+
* await watchtower.setFcmToken('your-fcm-token');
|
|
43
|
+
* const result = await watchtower.addToWatchTower('rgb:invoice...');
|
|
44
|
+
*/
|
|
45
|
+
static async create(config: Orbis1CreateConfig): Promise<Orbis1SDK> {
|
|
46
|
+
const normalized = normalizeCreateConfig(config);
|
|
47
|
+
const sdk = new Orbis1SDK(normalized);
|
|
48
|
+
await sdk.initialize();
|
|
49
|
+
return sdk;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the SDK and all enabled features. Called automatically by create().
|
|
54
|
+
*/
|
|
55
|
+
async initialize(): Promise<void> {
|
|
56
|
+
if (this.initialized) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const { features } = this.config;
|
|
61
|
+
|
|
62
|
+
if (features?.watchTower?.enabled) {
|
|
63
|
+
const apiKey = features.watchTower.apiKey ?? this.config.apiKey;
|
|
64
|
+
if (!apiKey) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
'Watch Tower requires apiKey (set apiKey or features.watchTower.apiKey)'
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const watchTowerModule = new WatchTowerModule({
|
|
70
|
+
name: 'watchTower',
|
|
71
|
+
enabled: true,
|
|
72
|
+
apiKey,
|
|
73
|
+
});
|
|
74
|
+
this.featureRegistry.register(Feature.WATCH_TOWER, watchTowerModule);
|
|
75
|
+
await watchTowerModule.initialize(undefined);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.featureRegistry.markInitialized();
|
|
79
|
+
this.initialized = true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Cleanup and release resources.
|
|
84
|
+
*/
|
|
85
|
+
async cleanup(): Promise<void> {
|
|
86
|
+
if (!this.initialized) return;
|
|
87
|
+
const modules = this.featureRegistry.getAllModules();
|
|
88
|
+
await Promise.all(modules.map((m) => m.cleanup()));
|
|
89
|
+
this.initialized = false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private ensureInitialized(): void {
|
|
93
|
+
if (!this.initialized) {
|
|
94
|
+
throw new Error('SDK is not initialized. Use Orbis1SDK.create() first.');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get a feature module by enum. Throws if feature is not enabled.
|
|
100
|
+
*/
|
|
101
|
+
getFeature<T extends IFeatureModule = IFeatureModule>(feature: Feature): T {
|
|
102
|
+
this.ensureInitialized();
|
|
103
|
+
return this.featureRegistry.get<T>(feature, true)!;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Access Watch Tower feature (add invoice to watchtower, set FCM token).
|
|
108
|
+
*
|
|
109
|
+
* @throws {FeatureNotEnabledError} If Watch Tower was not enabled in create({ features: ['watchtower'] })
|
|
110
|
+
*/
|
|
111
|
+
watchTower(): WatchTowerModule {
|
|
112
|
+
return this.getFeature<WatchTowerModule>(Feature.WATCH_TOWER);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
hasFeature(feature: Feature): boolean {
|
|
116
|
+
return this.featureRegistry.has(feature);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
isInitialized(): boolean {
|
|
120
|
+
return this.initialized;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
getStatus(): {
|
|
124
|
+
initialized: boolean;
|
|
125
|
+
features: Record<string, ReturnType<IFeatureModule['getStatus']>>;
|
|
126
|
+
} {
|
|
127
|
+
return {
|
|
128
|
+
initialized: this.initialized,
|
|
129
|
+
features: this.featureRegistry.getStatus(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
export type BitcoinNetwork =
|
|
2
|
+
| 'MAINNET'
|
|
3
|
+
| 'TESTNET'
|
|
4
|
+
| 'TESTNET4'
|
|
5
|
+
| 'REGTEST'
|
|
6
|
+
| 'SIGNET';
|
|
7
|
+
|
|
8
|
+
export const BitcoinNetwork = {
|
|
9
|
+
MAINNET: 'MAINNET' as const,
|
|
10
|
+
TESTNET: 'TESTNET' as const,
|
|
11
|
+
TESTNET4: 'TESTNET4' as const,
|
|
12
|
+
REGTEST: 'REGTEST' as const,
|
|
13
|
+
SIGNET: 'SIGNET' as const,
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export type Keys = {
|
|
17
|
+
mnemonic: string;
|
|
18
|
+
xpub: string;
|
|
19
|
+
accountXpubVanilla: string;
|
|
20
|
+
accountXpubColored: string;
|
|
21
|
+
masterFingerprint: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type Balance = {
|
|
25
|
+
settled: number;
|
|
26
|
+
future: number;
|
|
27
|
+
spendable: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type BtcBalance = {
|
|
31
|
+
vanilla: Balance;
|
|
32
|
+
colored: Balance;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type AssetSchema = 'NIA' | 'UDA' | 'CFA' | 'IFA';
|
|
36
|
+
|
|
37
|
+
export const AssetSchema = {
|
|
38
|
+
NIA: 'NIA' as const,
|
|
39
|
+
UDA: 'UDA' as const,
|
|
40
|
+
CFA: 'CFA' as const,
|
|
41
|
+
IFA: 'IFA' as const,
|
|
42
|
+
} as const;
|
|
43
|
+
|
|
44
|
+
export type AssignmentType =
|
|
45
|
+
| 'FUNGIBLE'
|
|
46
|
+
| 'NON_FUNGIBLE'
|
|
47
|
+
| 'INFLATION_RIGHT'
|
|
48
|
+
| 'REPLACE_RIGHT'
|
|
49
|
+
| 'ANY';
|
|
50
|
+
|
|
51
|
+
export type Assignment = {
|
|
52
|
+
type: AssignmentType;
|
|
53
|
+
amount?: number;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type Outpoint = {
|
|
57
|
+
txid: string;
|
|
58
|
+
vout: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type Utxo = {
|
|
62
|
+
outpoint: Outpoint;
|
|
63
|
+
btcAmount: number;
|
|
64
|
+
colorable: boolean;
|
|
65
|
+
exists: boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type RgbAllocation = {
|
|
69
|
+
assetId?: string;
|
|
70
|
+
assignment: Assignment;
|
|
71
|
+
settled: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type RefreshTransferStatus =
|
|
75
|
+
| 'WAITING_COUNTERPARTY'
|
|
76
|
+
| 'WAITING_CONFIRMATIONS';
|
|
77
|
+
|
|
78
|
+
export type RefreshFilter = {
|
|
79
|
+
status: RefreshTransferStatus;
|
|
80
|
+
incoming: boolean;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type WitnessData = {
|
|
84
|
+
amountSat: number;
|
|
85
|
+
blinding?: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type Recipient = {
|
|
89
|
+
recipientId: string;
|
|
90
|
+
witnessData?: WitnessData;
|
|
91
|
+
assignment: Assignment;
|
|
92
|
+
transportEndpoints: string[];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type Media = {
|
|
96
|
+
filePath: string;
|
|
97
|
+
mime: string;
|
|
98
|
+
digest: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type AssetCfa = {
|
|
102
|
+
assetId: string;
|
|
103
|
+
name: string;
|
|
104
|
+
details?: string;
|
|
105
|
+
precision: number;
|
|
106
|
+
issuedSupply: number;
|
|
107
|
+
timestamp: number;
|
|
108
|
+
addedAt: number;
|
|
109
|
+
balance: Balance;
|
|
110
|
+
media?: Media;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type AssetIfa = {
|
|
114
|
+
assetId: string;
|
|
115
|
+
ticker: string;
|
|
116
|
+
name: string;
|
|
117
|
+
details?: string;
|
|
118
|
+
precision: number;
|
|
119
|
+
initialSupply: number;
|
|
120
|
+
maxSupply: number;
|
|
121
|
+
knownCirculatingSupply: number;
|
|
122
|
+
timestamp: number;
|
|
123
|
+
addedAt: number;
|
|
124
|
+
balance: Balance;
|
|
125
|
+
media?: Media;
|
|
126
|
+
rejectListUrl?: string;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type AssetNia = {
|
|
130
|
+
assetId: string;
|
|
131
|
+
ticker: string;
|
|
132
|
+
name: string;
|
|
133
|
+
details?: string;
|
|
134
|
+
precision: number;
|
|
135
|
+
issuedSupply: number;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
addedAt: number;
|
|
138
|
+
balance: Balance;
|
|
139
|
+
media?: Media;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export type AssetUda = {
|
|
143
|
+
assetId: string;
|
|
144
|
+
ticker: string;
|
|
145
|
+
name: string;
|
|
146
|
+
details?: string;
|
|
147
|
+
precision: number;
|
|
148
|
+
timestamp: number;
|
|
149
|
+
addedAt: number;
|
|
150
|
+
balance: Balance;
|
|
151
|
+
token?: {
|
|
152
|
+
index: number;
|
|
153
|
+
ticker?: string;
|
|
154
|
+
name?: string;
|
|
155
|
+
details?: string;
|
|
156
|
+
embeddedMedia: boolean;
|
|
157
|
+
media?: Media;
|
|
158
|
+
attachments: Array<{
|
|
159
|
+
key: number;
|
|
160
|
+
filePath: string;
|
|
161
|
+
mime: string;
|
|
162
|
+
digest: string;
|
|
163
|
+
}>;
|
|
164
|
+
reserves: boolean;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export type Assets = {
|
|
169
|
+
nia: AssetNia[];
|
|
170
|
+
uda: AssetUda[];
|
|
171
|
+
cfa: AssetCfa[];
|
|
172
|
+
ifa: AssetIfa[];
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type OperationResult = {
|
|
176
|
+
txid: string;
|
|
177
|
+
batchTransferIdx: number;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type ReceiveData = {
|
|
181
|
+
invoice: string;
|
|
182
|
+
recipientId: string;
|
|
183
|
+
expirationTimestamp: number | null;
|
|
184
|
+
batchTransferIdx: number;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export type InvoiceData = {
|
|
188
|
+
invoice: string;
|
|
189
|
+
recipientId: string;
|
|
190
|
+
assetSchema?: AssetSchema;
|
|
191
|
+
assetId?: string;
|
|
192
|
+
assignment: Assignment;
|
|
193
|
+
assignmentName?: string;
|
|
194
|
+
network: BitcoinNetwork;
|
|
195
|
+
expirationTimestamp: number | null;
|
|
196
|
+
transportEndpoints: string[];
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export type Transaction = {
|
|
200
|
+
transactionType: 'RGB_SEND' | 'DRAIN' | 'CREATE_UTXOS' | 'USER';
|
|
201
|
+
txid: string;
|
|
202
|
+
received: number;
|
|
203
|
+
sent: number;
|
|
204
|
+
fee: number;
|
|
205
|
+
confirmationTime?: number;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type TransferTransportEndpoint = {
|
|
209
|
+
endpoint: string;
|
|
210
|
+
used: boolean;
|
|
211
|
+
transportType: string;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export type Transfer = {
|
|
215
|
+
idx: number;
|
|
216
|
+
batchTransferIdx: number;
|
|
217
|
+
createdAt: number;
|
|
218
|
+
updatedAt: number;
|
|
219
|
+
kind: 'ISSUANCE' | 'RECEIVE_BLIND' | 'RECEIVE_WITNESS' | 'SEND' | 'INFLATION';
|
|
220
|
+
status:
|
|
221
|
+
| 'WAITING_COUNTERPARTY'
|
|
222
|
+
| 'WAITING_CONFIRMATIONS'
|
|
223
|
+
| 'SETTLED'
|
|
224
|
+
| 'FAILED';
|
|
225
|
+
txid?: string;
|
|
226
|
+
recipientId?: string;
|
|
227
|
+
requestedAssignment?: Assignment;
|
|
228
|
+
assignments: Assignment[];
|
|
229
|
+
receiveUtxo?: Outpoint;
|
|
230
|
+
changeUtxo?: Outpoint;
|
|
231
|
+
expiration?: number;
|
|
232
|
+
transportEndpoints: TransferTransportEndpoint[];
|
|
233
|
+
invoiceString?: string;
|
|
234
|
+
consignmentPath?: string;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export type Unspent = {
|
|
238
|
+
utxo: Utxo;
|
|
239
|
+
rgbAllocations: RgbAllocation[];
|
|
240
|
+
pendingBlinded: number;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export type RefreshedTransfer = {
|
|
244
|
+
updatedStatus?:
|
|
245
|
+
| 'WAITING_COUNTERPARTY'
|
|
246
|
+
| 'WAITING_CONFIRMATIONS'
|
|
247
|
+
| 'SETTLED'
|
|
248
|
+
| 'FAILED';
|
|
249
|
+
failure?: string;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export type WalletData = {
|
|
253
|
+
dataDir: string;
|
|
254
|
+
bitcoinNetwork: string;
|
|
255
|
+
databaseType: string;
|
|
256
|
+
maxAllocationsPerUtxo: number;
|
|
257
|
+
accountXpubVanilla: string;
|
|
258
|
+
accountXpubColored: string;
|
|
259
|
+
mnemonic?: string;
|
|
260
|
+
masterFingerprint: string;
|
|
261
|
+
vanillaKeychain?: number;
|
|
262
|
+
supportedSchemas: string[];
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export type AssetMetadata = {
|
|
266
|
+
assetId: string;
|
|
267
|
+
name: string;
|
|
268
|
+
ticker?: string;
|
|
269
|
+
details?: string;
|
|
270
|
+
precision?: number;
|
|
271
|
+
issuedSupply?: number;
|
|
272
|
+
timestamp?: number;
|
|
273
|
+
amounts?: number[];
|
|
274
|
+
assetNia?: AssetNia;
|
|
275
|
+
assetUda?: AssetUda;
|
|
276
|
+
assetCfa?: AssetCfa;
|
|
277
|
+
assetIfa?: AssetIfa;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Error types that can be returned by RGB library methods.
|
|
282
|
+
* These correspond to the RgbLibError
|
|
283
|
+
* Errors with associated values are represented as objects with the error name and associated data.
|
|
284
|
+
*/
|
|
285
|
+
export type RgbLibErrors =
|
|
286
|
+
| 'AllocationsAlreadyAvailable'
|
|
287
|
+
| { type: 'AssetNotFound'; assetId: string }
|
|
288
|
+
| { type: 'BatchTransferNotFound'; idx: number }
|
|
289
|
+
| 'BitcoinNetworkMismatch'
|
|
290
|
+
| 'CannotChangeOnline'
|
|
291
|
+
| 'CannotDeleteBatchTransfer'
|
|
292
|
+
| 'CannotEstimateFees'
|
|
293
|
+
| 'CannotFailBatchTransfer'
|
|
294
|
+
| 'CannotFinalizePsbt'
|
|
295
|
+
| 'CannotUseIfaOnMainnet'
|
|
296
|
+
| { type: 'EmptyFile'; filePath: string }
|
|
297
|
+
| { type: 'FailedBdkSync'; details: string }
|
|
298
|
+
| { type: 'FailedBroadcast'; details: string }
|
|
299
|
+
| { type: 'FailedIssuance'; details: string }
|
|
300
|
+
| { type: 'FileAlreadyExists'; path: string }
|
|
301
|
+
| 'FingerprintMismatch'
|
|
302
|
+
| { type: 'Io'; details: string }
|
|
303
|
+
| { type: 'Inconsistency'; details: string }
|
|
304
|
+
| { type: 'Indexer'; details: string }
|
|
305
|
+
| 'InexistentDataDir'
|
|
306
|
+
| 'InsufficientAllocationSlots'
|
|
307
|
+
| { type: 'InsufficientAssignments'; assetId: string; available: unknown }
|
|
308
|
+
| { type: 'InsufficientBitcoins'; needed: number; available: number }
|
|
309
|
+
| { type: 'Internal'; details: string }
|
|
310
|
+
| { type: 'InvalidAddress'; details: string }
|
|
311
|
+
| 'InvalidAmountZero'
|
|
312
|
+
| { type: 'InvalidAssetId'; assetId: string }
|
|
313
|
+
| 'InvalidAssignment'
|
|
314
|
+
| { type: 'InvalidAttachments'; details: string }
|
|
315
|
+
| 'InvalidBitcoinKeys'
|
|
316
|
+
| { type: 'InvalidBitcoinNetwork'; network: string }
|
|
317
|
+
| { type: 'InvalidColoringInfo'; details: string }
|
|
318
|
+
| 'InvalidConsignment'
|
|
319
|
+
| { type: 'InvalidDetails'; details: string }
|
|
320
|
+
| { type: 'InvalidElectrum'; details: string }
|
|
321
|
+
| 'InvalidEstimationBlocks'
|
|
322
|
+
| { type: 'InvalidFeeRate'; details: string }
|
|
323
|
+
| { type: 'InvalidFilePath'; filePath: string }
|
|
324
|
+
| 'InvalidFingerprint'
|
|
325
|
+
| { type: 'InvalidIndexer'; details: string }
|
|
326
|
+
| { type: 'InvalidInvoice'; details: string }
|
|
327
|
+
| { type: 'InvalidMnemonic'; details: string }
|
|
328
|
+
| { type: 'InvalidName'; details: string }
|
|
329
|
+
| { type: 'InvalidPrecision'; details: string }
|
|
330
|
+
| { type: 'InvalidProxyProtocol'; version: string }
|
|
331
|
+
| { type: 'InvalidPsbt'; details: string }
|
|
332
|
+
| { type: 'InvalidPubkey'; details: string }
|
|
333
|
+
| { type: 'InvalidRecipientData'; details: string }
|
|
334
|
+
| 'InvalidRecipientId'
|
|
335
|
+
| 'InvalidRecipientNetwork'
|
|
336
|
+
| { type: 'InvalidRejectListUrl'; details: string }
|
|
337
|
+
| { type: 'InvalidTicker'; details: string }
|
|
338
|
+
| { type: 'InvalidTransportEndpoint'; details: string }
|
|
339
|
+
| { type: 'InvalidTransportEndpoints'; details: string }
|
|
340
|
+
| 'InvalidTxid'
|
|
341
|
+
| 'InvalidVanillaKeychain'
|
|
342
|
+
| { type: 'MaxFeeExceeded'; txid: string }
|
|
343
|
+
| { type: 'MinFeeNotMet'; txid: string }
|
|
344
|
+
| { type: 'Network'; details: string }
|
|
345
|
+
| 'NoConsignment'
|
|
346
|
+
| 'NoInflationAmounts'
|
|
347
|
+
| 'NoIssuanceAmounts'
|
|
348
|
+
| 'NoSupportedSchemas'
|
|
349
|
+
| 'NoValidTransportEndpoint'
|
|
350
|
+
| 'Offline'
|
|
351
|
+
| 'OnlineNeeded'
|
|
352
|
+
| 'OutputBelowDustLimit'
|
|
353
|
+
| { type: 'Proxy'; details: string }
|
|
354
|
+
| 'RecipientIdAlreadyUsed'
|
|
355
|
+
| 'RecipientIdDuplicated'
|
|
356
|
+
| { type: 'RejectListService'; details: string }
|
|
357
|
+
| { type: 'RestClientBuild'; details: string }
|
|
358
|
+
| 'TooHighInflationAmounts'
|
|
359
|
+
| 'TooHighIssuanceAmounts'
|
|
360
|
+
| { type: 'UnknownRgbSchema'; schemaId: string }
|
|
361
|
+
| { type: 'UnknownTransfer'; txid: string }
|
|
362
|
+
| { type: 'UnsupportedBackupVersion'; version: string }
|
|
363
|
+
| { type: 'UnsupportedInflation'; assetSchema: string }
|
|
364
|
+
| { type: 'UnsupportedLayer1'; layer1: string }
|
|
365
|
+
| { type: 'UnsupportedSchema'; assetSchema: string }
|
|
366
|
+
| 'UnsupportedTransportType'
|
|
367
|
+
| { type: 'WalletDirAlreadyExists'; path: string }
|
|
368
|
+
| 'WatchOnly'
|
|
369
|
+
| 'WrongPassword';
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Constants for all RGB library errors.
|
|
373
|
+
* Use these for error code comparison and type safety.
|
|
374
|
+
*/
|
|
375
|
+
export const RgbLibErrors = {
|
|
376
|
+
AllocationsAlreadyAvailable: 'AllocationsAlreadyAvailable' as const,
|
|
377
|
+
BitcoinNetworkMismatch: 'BitcoinNetworkMismatch' as const,
|
|
378
|
+
CannotChangeOnline: 'CannotChangeOnline' as const,
|
|
379
|
+
CannotDeleteBatchTransfer: 'CannotDeleteBatchTransfer' as const,
|
|
380
|
+
CannotEstimateFees: 'CannotEstimateFees' as const,
|
|
381
|
+
CannotFailBatchTransfer: 'CannotFailBatchTransfer' as const,
|
|
382
|
+
CannotFinalizePsbt: 'CannotFinalizePsbt' as const,
|
|
383
|
+
CannotUseIfaOnMainnet: 'CannotUseIfaOnMainnet' as const,
|
|
384
|
+
FingerprintMismatch: 'FingerprintMismatch' as const,
|
|
385
|
+
InexistentDataDir: 'InexistentDataDir' as const,
|
|
386
|
+
InsufficientAllocationSlots: 'InsufficientAllocationSlots' as const,
|
|
387
|
+
InvalidAmountZero: 'InvalidAmountZero' as const,
|
|
388
|
+
InvalidAssignment: 'InvalidAssignment' as const,
|
|
389
|
+
InvalidBitcoinKeys: 'InvalidBitcoinKeys' as const,
|
|
390
|
+
InvalidConsignment: 'InvalidConsignment' as const,
|
|
391
|
+
InvalidEstimationBlocks: 'InvalidEstimationBlocks' as const,
|
|
392
|
+
InvalidFingerprint: 'InvalidFingerprint' as const,
|
|
393
|
+
InvalidRecipientId: 'InvalidRecipientId' as const,
|
|
394
|
+
InvalidRecipientNetwork: 'InvalidRecipientNetwork' as const,
|
|
395
|
+
InvalidTxid: 'InvalidTxid' as const,
|
|
396
|
+
InvalidVanillaKeychain: 'InvalidVanillaKeychain' as const,
|
|
397
|
+
NoConsignment: 'NoConsignment' as const,
|
|
398
|
+
NoInflationAmounts: 'NoInflationAmounts' as const,
|
|
399
|
+
NoIssuanceAmounts: 'NoIssuanceAmounts' as const,
|
|
400
|
+
NoSupportedSchemas: 'NoSupportedSchemas' as const,
|
|
401
|
+
NoValidTransportEndpoint: 'NoValidTransportEndpoint' as const,
|
|
402
|
+
Offline: 'Offline' as const,
|
|
403
|
+
OnlineNeeded: 'OnlineNeeded' as const,
|
|
404
|
+
OutputBelowDustLimit: 'OutputBelowDustLimit' as const,
|
|
405
|
+
RecipientIdAlreadyUsed: 'RecipientIdAlreadyUsed' as const,
|
|
406
|
+
RecipientIdDuplicated: 'RecipientIdDuplicated' as const,
|
|
407
|
+
TooHighInflationAmounts: 'TooHighInflationAmounts' as const,
|
|
408
|
+
TooHighIssuanceAmounts: 'TooHighIssuanceAmounts' as const,
|
|
409
|
+
UnsupportedTransportType: 'UnsupportedTransportType' as const,
|
|
410
|
+
WatchOnly: 'WatchOnly' as const,
|
|
411
|
+
WrongPassword: 'WrongPassword' as const,
|
|
412
|
+
} as const;
|