@sats-connect/core 0.16.0-2dd02aa → 0.16.0-4c59967
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/index.cjs +1383 -0
- package/dist/index.d.cts +4173 -0
- package/dist/index.d.mts +3663 -2292
- package/dist/index.mjs +1230 -2980
- package/package.json +9 -9
- package/dist/index.d.ts +0 -2802
- package/dist/index.js +0 -3339
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1383 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let valibot = require("valibot");
|
|
29
|
+
valibot = __toESM(valibot);
|
|
30
|
+
let jsontokens = require("jsontokens");
|
|
31
|
+
let axios = require("axios");
|
|
32
|
+
axios = __toESM(axios);
|
|
33
|
+
let bitcoin_address_validation = require("bitcoin-address-validation");
|
|
34
|
+
let buffer = require("buffer");
|
|
35
|
+
|
|
36
|
+
//#region src/request/types/common.ts
|
|
37
|
+
const walletTypes = [
|
|
38
|
+
"software",
|
|
39
|
+
"ledger",
|
|
40
|
+
"keystone"
|
|
41
|
+
];
|
|
42
|
+
const walletTypeSchema = valibot.picklist(walletTypes);
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/addresses/types.ts
|
|
46
|
+
let AddressPurpose = /* @__PURE__ */ function(AddressPurpose$1) {
|
|
47
|
+
AddressPurpose$1["Ordinals"] = "ordinals";
|
|
48
|
+
AddressPurpose$1["Payment"] = "payment";
|
|
49
|
+
AddressPurpose$1["Stacks"] = "stacks";
|
|
50
|
+
AddressPurpose$1["Starknet"] = "starknet";
|
|
51
|
+
AddressPurpose$1["Spark"] = "spark";
|
|
52
|
+
return AddressPurpose$1;
|
|
53
|
+
}({});
|
|
54
|
+
let AddressType = /* @__PURE__ */ function(AddressType$2) {
|
|
55
|
+
AddressType$2["p2pkh"] = "p2pkh";
|
|
56
|
+
AddressType$2["p2sh"] = "p2sh";
|
|
57
|
+
AddressType$2["p2wpkh"] = "p2wpkh";
|
|
58
|
+
AddressType$2["p2wsh"] = "p2wsh";
|
|
59
|
+
AddressType$2["p2tr"] = "p2tr";
|
|
60
|
+
AddressType$2["stacks"] = "stacks";
|
|
61
|
+
AddressType$2["starknet"] = "starknet";
|
|
62
|
+
AddressType$2["spark"] = "spark";
|
|
63
|
+
return AddressType$2;
|
|
64
|
+
}({});
|
|
65
|
+
const addressSchema = valibot.object({
|
|
66
|
+
address: valibot.string(),
|
|
67
|
+
publicKey: valibot.string(),
|
|
68
|
+
purpose: valibot.enum(AddressPurpose),
|
|
69
|
+
addressType: valibot.enum(AddressType),
|
|
70
|
+
walletType: walletTypeSchema
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/addresses/index.ts
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use `request()` instead
|
|
77
|
+
*/
|
|
78
|
+
const getAddress = async (options) => {
|
|
79
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
80
|
+
const { purposes } = options.payload;
|
|
81
|
+
if (!purposes) throw new Error("Address purposes are required");
|
|
82
|
+
try {
|
|
83
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
84
|
+
const response = await provider.connect(request$1);
|
|
85
|
+
options.onFinish?.(response);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("[Connect] Error during address request", error);
|
|
88
|
+
options.onCancel?.();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/types.ts
|
|
94
|
+
let BitcoinNetworkType = /* @__PURE__ */ function(BitcoinNetworkType$1) {
|
|
95
|
+
BitcoinNetworkType$1["Mainnet"] = "Mainnet";
|
|
96
|
+
BitcoinNetworkType$1["Testnet"] = "Testnet";
|
|
97
|
+
BitcoinNetworkType$1["Testnet4"] = "Testnet4";
|
|
98
|
+
BitcoinNetworkType$1["Signet"] = "Signet";
|
|
99
|
+
BitcoinNetworkType$1["Regtest"] = "Regtest";
|
|
100
|
+
return BitcoinNetworkType$1;
|
|
101
|
+
}({});
|
|
102
|
+
let StacksNetworkType = /* @__PURE__ */ function(StacksNetworkType$1) {
|
|
103
|
+
StacksNetworkType$1["Mainnet"] = "mainnet";
|
|
104
|
+
StacksNetworkType$1["Testnet"] = "testnet";
|
|
105
|
+
return StacksNetworkType$1;
|
|
106
|
+
}({});
|
|
107
|
+
let StarknetNetworkType = /* @__PURE__ */ function(StarknetNetworkType$1) {
|
|
108
|
+
StarknetNetworkType$1["Mainnet"] = "mainnet";
|
|
109
|
+
StarknetNetworkType$1["Sepolia"] = "sepolia";
|
|
110
|
+
return StarknetNetworkType$1;
|
|
111
|
+
}({});
|
|
112
|
+
let SparkNetworkType = /* @__PURE__ */ function(SparkNetworkType$1) {
|
|
113
|
+
SparkNetworkType$1["Mainnet"] = "mainnet";
|
|
114
|
+
SparkNetworkType$1["Regtest"] = "regtest";
|
|
115
|
+
return SparkNetworkType$1;
|
|
116
|
+
}({});
|
|
117
|
+
const RpcIdSchema = valibot.optional(valibot.union([
|
|
118
|
+
valibot.string(),
|
|
119
|
+
valibot.number(),
|
|
120
|
+
valibot.null()
|
|
121
|
+
]));
|
|
122
|
+
const rpcRequestMessageSchema = valibot.object({
|
|
123
|
+
jsonrpc: valibot.literal("2.0"),
|
|
124
|
+
method: valibot.string(),
|
|
125
|
+
params: valibot.optional(valibot.union([
|
|
126
|
+
valibot.array(valibot.unknown()),
|
|
127
|
+
valibot.looseObject({}),
|
|
128
|
+
valibot.null()
|
|
129
|
+
])),
|
|
130
|
+
id: valibot.unwrap(RpcIdSchema)
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* @enum {number} RpcErrorCode
|
|
134
|
+
* @description JSON-RPC error codes
|
|
135
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
136
|
+
*/
|
|
137
|
+
let RpcErrorCode = /* @__PURE__ */ function(RpcErrorCode$1) {
|
|
138
|
+
/**
|
|
139
|
+
* Parse error Invalid JSON
|
|
140
|
+
**/
|
|
141
|
+
RpcErrorCode$1[RpcErrorCode$1["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
142
|
+
/**
|
|
143
|
+
* The JSON sent is not a valid Request object.
|
|
144
|
+
**/
|
|
145
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
146
|
+
/**
|
|
147
|
+
* The method does not exist/is not available.
|
|
148
|
+
**/
|
|
149
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
150
|
+
/**
|
|
151
|
+
* Invalid method parameter(s).
|
|
152
|
+
*/
|
|
153
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
154
|
+
/**
|
|
155
|
+
* Internal JSON-RPC error.
|
|
156
|
+
* This is a generic error, used when the server encounters an error in performing the request.
|
|
157
|
+
**/
|
|
158
|
+
RpcErrorCode$1[RpcErrorCode$1["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
159
|
+
/**
|
|
160
|
+
* user rejected/canceled the request
|
|
161
|
+
*/
|
|
162
|
+
RpcErrorCode$1[RpcErrorCode$1["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
163
|
+
/**
|
|
164
|
+
* method is not supported for the address provided
|
|
165
|
+
*/
|
|
166
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
167
|
+
/**
|
|
168
|
+
* The client does not have permission to access the requested resource.
|
|
169
|
+
*/
|
|
170
|
+
RpcErrorCode$1[RpcErrorCode$1["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
171
|
+
return RpcErrorCode$1;
|
|
172
|
+
}({});
|
|
173
|
+
const rpcSuccessResponseMessageSchema = valibot.object({
|
|
174
|
+
jsonrpc: valibot.literal("2.0"),
|
|
175
|
+
result: valibot.nonOptional(valibot.unknown()),
|
|
176
|
+
id: RpcIdSchema
|
|
177
|
+
});
|
|
178
|
+
const rpcErrorResponseMessageSchema = valibot.object({
|
|
179
|
+
jsonrpc: valibot.literal("2.0"),
|
|
180
|
+
error: valibot.nonOptional(valibot.unknown()),
|
|
181
|
+
id: RpcIdSchema
|
|
182
|
+
});
|
|
183
|
+
const rpcResponseMessageSchema = valibot.union([rpcSuccessResponseMessageSchema, rpcErrorResponseMessageSchema]);
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/request/types/walletMethods/utils.ts
|
|
187
|
+
const commonNetworkConfigurationSchema = valibot.object({
|
|
188
|
+
id: valibot.string(),
|
|
189
|
+
name: valibot.string(),
|
|
190
|
+
mode: valibot.picklist([]),
|
|
191
|
+
blockExplorerUrl: valibot.optional(valibot.union([valibot.pipe(valibot.literal(""), valibot.transform(() => void 0)), valibot.pipe(valibot.string(), valibot.url())]))
|
|
192
|
+
});
|
|
193
|
+
const bitcoinChainModeSchema = valibot.enum({
|
|
194
|
+
mainnet: "mainnet",
|
|
195
|
+
testnet: "testnet",
|
|
196
|
+
testnet4: "testnet4",
|
|
197
|
+
signet: "signet",
|
|
198
|
+
regtest: "regtest"
|
|
199
|
+
});
|
|
200
|
+
const bitcoinNetworkConfigurationSchema = valibot.object({
|
|
201
|
+
chain: valibot.literal("bitcoin"),
|
|
202
|
+
...commonNetworkConfigurationSchema.entries,
|
|
203
|
+
mode: valibot.pipe(valibot.string(), bitcoinChainModeSchema),
|
|
204
|
+
xverseApiUrl: valibot.pipe(valibot.string(), valibot.url()),
|
|
205
|
+
electrsApiUrl: valibot.pipe(valibot.string(), valibot.url())
|
|
206
|
+
});
|
|
207
|
+
const sparkChainMode = {
|
|
208
|
+
mainnet: "mainnet",
|
|
209
|
+
regtest: "regtest"
|
|
210
|
+
};
|
|
211
|
+
const sparkChainModeSchema = valibot.enum(sparkChainMode);
|
|
212
|
+
const sparkNetworkConfigurationSchema = valibot.object({
|
|
213
|
+
chain: valibot.literal("spark"),
|
|
214
|
+
...commonNetworkConfigurationSchema.entries,
|
|
215
|
+
mode: valibot.pipe(valibot.string(), sparkChainModeSchema),
|
|
216
|
+
electrsApiUrl: valibot.pipe(valibot.string(), valibot.url())
|
|
217
|
+
});
|
|
218
|
+
const stacksChainMode = {
|
|
219
|
+
mainnet: "mainnet",
|
|
220
|
+
testnet: "testnet",
|
|
221
|
+
devnet: "devnet",
|
|
222
|
+
mocknet: "mocknet"
|
|
223
|
+
};
|
|
224
|
+
const stacksChainModeSchema = valibot.enum(stacksChainMode);
|
|
225
|
+
const stacksNetworkConfigurationSchema = valibot.object({
|
|
226
|
+
chain: valibot.literal("stacks"),
|
|
227
|
+
...commonNetworkConfigurationSchema.entries,
|
|
228
|
+
mode: valibot.pipe(valibot.string(), stacksChainModeSchema),
|
|
229
|
+
stacksApiUrl: valibot.pipe(valibot.string(), valibot.url()),
|
|
230
|
+
xverseApiUrl: valibot.pipe(valibot.string(), valibot.url())
|
|
231
|
+
});
|
|
232
|
+
const starknetChainMode = {
|
|
233
|
+
mainnet: "mainnet",
|
|
234
|
+
sepolia: "sepolia"
|
|
235
|
+
};
|
|
236
|
+
const starknetChainModeSchema = valibot.enum(starknetChainMode);
|
|
237
|
+
const starknetNetworkConfigurationSchema = valibot.object({
|
|
238
|
+
chain: valibot.literal("starknet"),
|
|
239
|
+
...commonNetworkConfigurationSchema.entries,
|
|
240
|
+
mode: valibot.pipe(valibot.string(), starknetChainModeSchema),
|
|
241
|
+
rpcApiUrl: valibot.pipe(valibot.string(), valibot.url()),
|
|
242
|
+
xverseApiUrl: valibot.pipe(valibot.string(), valibot.url())
|
|
243
|
+
});
|
|
244
|
+
const networkConfigurationSchema = valibot.variant("chain", [
|
|
245
|
+
bitcoinNetworkConfigurationSchema,
|
|
246
|
+
sparkNetworkConfigurationSchema,
|
|
247
|
+
stacksNetworkConfigurationSchema,
|
|
248
|
+
starknetNetworkConfigurationSchema
|
|
249
|
+
]);
|
|
250
|
+
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/provider/types.ts
|
|
253
|
+
const accountChangeEventName = "accountChange";
|
|
254
|
+
const accountChangeSchema = valibot.object({
|
|
255
|
+
type: valibot.literal(accountChangeEventName),
|
|
256
|
+
addresses: valibot.optional(valibot.array(addressSchema))
|
|
257
|
+
});
|
|
258
|
+
const networkChangeEventName = "networkChange";
|
|
259
|
+
const networkChangeSchema = valibot.object({
|
|
260
|
+
type: valibot.literal(networkChangeEventName),
|
|
261
|
+
bitcoin: valibot.object({ name: valibot.enum(BitcoinNetworkType) }),
|
|
262
|
+
stacks: valibot.object({ name: valibot.string() }),
|
|
263
|
+
addresses: valibot.optional(valibot.array(addressSchema))
|
|
264
|
+
});
|
|
265
|
+
const networkChangeEventNameV2 = "networkChangeV2";
|
|
266
|
+
const networkChangeV2Schema = valibot.object({
|
|
267
|
+
type: valibot.literal(networkChangeEventName),
|
|
268
|
+
networks: valibot.object({
|
|
269
|
+
bitcoin: bitcoinNetworkConfigurationSchema,
|
|
270
|
+
spark: sparkNetworkConfigurationSchema,
|
|
271
|
+
stacks: stacksNetworkConfigurationSchema,
|
|
272
|
+
starknet: starknetNetworkConfigurationSchema
|
|
273
|
+
}),
|
|
274
|
+
addresses: valibot.optional(valibot.array(addressSchema))
|
|
275
|
+
});
|
|
276
|
+
const disconnectEventName = "disconnect";
|
|
277
|
+
const disconnectSchema = valibot.object({ type: valibot.literal(disconnectEventName) });
|
|
278
|
+
const walletEventSchema = valibot.variant("type", [
|
|
279
|
+
accountChangeSchema,
|
|
280
|
+
networkChangeSchema,
|
|
281
|
+
disconnectSchema
|
|
282
|
+
]);
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/provider/index.ts
|
|
286
|
+
async function getProviderOrThrow(getProvider) {
|
|
287
|
+
const provider = await getProvider?.() || window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
288
|
+
if (!provider) throw new Error("No Bitcoin wallet installed");
|
|
289
|
+
return provider;
|
|
290
|
+
}
|
|
291
|
+
function getProviders() {
|
|
292
|
+
if (!window.btc_providers) window.btc_providers = [];
|
|
293
|
+
return window.btc_providers;
|
|
294
|
+
}
|
|
295
|
+
function getProviderById(providerId) {
|
|
296
|
+
return providerId?.split(".").reduce((acc, part) => acc?.[part], window);
|
|
297
|
+
}
|
|
298
|
+
function isProviderInstalled(providerId) {
|
|
299
|
+
return !!getProviderById(providerId);
|
|
300
|
+
}
|
|
301
|
+
function setDefaultProvider(providerId) {
|
|
302
|
+
localStorage.setItem("sats-connect_defaultProvider", providerId);
|
|
303
|
+
}
|
|
304
|
+
function getDefaultProvider() {
|
|
305
|
+
return localStorage.getItem("sats-connect_defaultProvider");
|
|
306
|
+
}
|
|
307
|
+
function removeDefaultProvider() {
|
|
308
|
+
localStorage.removeItem("sats-connect_defaultProvider");
|
|
309
|
+
}
|
|
310
|
+
function getSupportedWallets() {
|
|
311
|
+
return Object.values(DefaultAdaptersInfo).map((provider) => {
|
|
312
|
+
return {
|
|
313
|
+
...provider,
|
|
314
|
+
isInstalled: isProviderInstalled(provider.id)
|
|
315
|
+
};
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/request/sanitizeRequest.ts
|
|
321
|
+
const sanitizeRequest = (method, params, providerInfo) => {
|
|
322
|
+
try {
|
|
323
|
+
const [major, minor, patch] = providerInfo.version.split(".").map((part) => parseInt(part, 10));
|
|
324
|
+
const platform = providerInfo.platform;
|
|
325
|
+
if (!platform || platform === ProviderPlatform.Web && major <= 1 && minor <= 4 || platform === ProviderPlatform.Mobile && major <= 1 && minor <= 54) {
|
|
326
|
+
const v1Sanitized = sanitizeAddressPurposeRequest(method, params);
|
|
327
|
+
method = v1Sanitized.method;
|
|
328
|
+
params = v1Sanitized.params;
|
|
329
|
+
}
|
|
330
|
+
} catch {}
|
|
331
|
+
return {
|
|
332
|
+
method,
|
|
333
|
+
params
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
const sanitizeAddressPurposeRequest = (method, params) => {
|
|
337
|
+
const filterPurposes = (purposes) => purposes?.filter((purpose) => purpose !== AddressPurpose.Spark && purpose !== AddressPurpose.Starknet);
|
|
338
|
+
if (method === "wallet_connect") {
|
|
339
|
+
const typedParams = params;
|
|
340
|
+
if (!typedParams) return {
|
|
341
|
+
method,
|
|
342
|
+
params
|
|
343
|
+
};
|
|
344
|
+
const { addresses, ...rest } = typedParams;
|
|
345
|
+
return {
|
|
346
|
+
method,
|
|
347
|
+
params: {
|
|
348
|
+
...rest,
|
|
349
|
+
addresses: filterPurposes(addresses)
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
if (method === "getAccounts") {
|
|
354
|
+
const { purposes, ...rest } = params;
|
|
355
|
+
return {
|
|
356
|
+
method,
|
|
357
|
+
params: {
|
|
358
|
+
...rest,
|
|
359
|
+
purposes: filterPurposes(purposes)
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
if (method === "getAddresses") {
|
|
364
|
+
const { purposes, ...rest } = params;
|
|
365
|
+
return {
|
|
366
|
+
method,
|
|
367
|
+
params: {
|
|
368
|
+
...rest,
|
|
369
|
+
purposes: filterPurposes(purposes)
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
method,
|
|
375
|
+
params
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/request/rpc.ts
|
|
381
|
+
const rpcIdSchema = valibot.union([
|
|
382
|
+
valibot.string(),
|
|
383
|
+
valibot.number(),
|
|
384
|
+
valibot.null()
|
|
385
|
+
]);
|
|
386
|
+
const rpcRequestSchema = valibot.object({
|
|
387
|
+
jsonrpc: valibot.literal("2.0"),
|
|
388
|
+
method: valibot.string(),
|
|
389
|
+
params: valibot.optional(valibot.union([
|
|
390
|
+
valibot.array(valibot.unknown()),
|
|
391
|
+
valibot.looseObject({}),
|
|
392
|
+
valibot.null()
|
|
393
|
+
])),
|
|
394
|
+
id: valibot.optional(rpcIdSchema)
|
|
395
|
+
});
|
|
396
|
+
const rpcSuccessResponseSchema = valibot.object({
|
|
397
|
+
jsonrpc: valibot.literal("2.0"),
|
|
398
|
+
result: valibot.unknown(),
|
|
399
|
+
id: rpcIdSchema
|
|
400
|
+
});
|
|
401
|
+
const warningSchema = valibot.variant("code", [valibot.object({
|
|
402
|
+
code: valibot.literal("DEPRECATION_NOTICE"),
|
|
403
|
+
message: valibot.string(),
|
|
404
|
+
sunsetDate: valibot.pipe(valibot.string(), valibot.isoDate())
|
|
405
|
+
})]);
|
|
406
|
+
/**
|
|
407
|
+
* Extends the standard JSON RPC 2.0 with an additional field as a means of
|
|
408
|
+
* providing clients with extra data, such as deprecation warnings, without
|
|
409
|
+
* altering the main payloads.
|
|
410
|
+
*
|
|
411
|
+
* A JSON-RPC response must either be a result (success) or an error (failure).
|
|
412
|
+
* To provide additional data, conventions must be layered atop these two types.
|
|
413
|
+
* Having an additional property is the least disruptive approach, and is
|
|
414
|
+
* acceptable when clients are known to be able to handle such a structure,
|
|
415
|
+
* which they can since they're all part of Sats Connect.
|
|
416
|
+
*/
|
|
417
|
+
const rpcSuccessWithExtensionsResponseSchema = valibot.object({
|
|
418
|
+
...rpcSuccessResponseSchema.entries,
|
|
419
|
+
extensions: valibot.optional(valibot.object({ warnings: valibot.array(warningSchema) }))
|
|
420
|
+
});
|
|
421
|
+
const rpcErrorObject = valibot.object({
|
|
422
|
+
code: valibot.number(),
|
|
423
|
+
message: valibot.string(),
|
|
424
|
+
data: valibot.optional(valibot.unknown())
|
|
425
|
+
});
|
|
426
|
+
const rpcErrorResponseSchema = valibot.object({
|
|
427
|
+
jsonrpc: valibot.literal("2.0"),
|
|
428
|
+
error: rpcErrorObject,
|
|
429
|
+
id: rpcIdSchema
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/request/createSuccessResponseSchema.ts
|
|
434
|
+
function createSuccessResponseSchema({ method, resultSchema }) {
|
|
435
|
+
return valibot.object({
|
|
436
|
+
...rpcSuccessWithExtensionsResponseSchema.entries,
|
|
437
|
+
id: valibot.string(),
|
|
438
|
+
result: resultSchema,
|
|
439
|
+
"~sats-connect-method": valibot.literal(method)
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/request/methods.ts
|
|
445
|
+
const bitcoinMethods = {
|
|
446
|
+
getAccounts: "getAccounts",
|
|
447
|
+
bitcoin_getAccountsV2: "bitcoin_getAccountsV2",
|
|
448
|
+
getAddresses: "getAddresses",
|
|
449
|
+
bitcoin_getAddressesV2: "bitcoin_getAddressesV2",
|
|
450
|
+
getBalance: "getBalance",
|
|
451
|
+
bitcoin_getBalanceV2: "bitcoin_getBalanceV2",
|
|
452
|
+
getInfo: "getInfo",
|
|
453
|
+
bitcoin_getInfoV2: "bitcoin_getInfoV2",
|
|
454
|
+
sendTransfer: "sendTransfer",
|
|
455
|
+
bitcoin_sendTransferV2: "bitcoin_sendTransferV2",
|
|
456
|
+
signMessage: "signMessage",
|
|
457
|
+
bitcoin_signMessageV2: "bitcoin_signMessageV2",
|
|
458
|
+
signMultipleMessages: "signMultipleMessages",
|
|
459
|
+
bitcoin_signMultipleMessagesV2: "bitcoin_signMultipleMessagesV2",
|
|
460
|
+
signPsbt: "signPsbt",
|
|
461
|
+
bitcoin_signPsbtV2: "bitcoin_signPsbtV2"
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/request/rpc/methodSchemas/bitcoin/getInfo/response.ts
|
|
466
|
+
let ProviderPlatform = /* @__PURE__ */ function(ProviderPlatform$1) {
|
|
467
|
+
ProviderPlatform$1["Web"] = "web";
|
|
468
|
+
ProviderPlatform$1["Mobile"] = "mobile";
|
|
469
|
+
return ProviderPlatform$1;
|
|
470
|
+
}({});
|
|
471
|
+
const bitcoinGetInfoSuccessResponseSchema = createSuccessResponseSchema({
|
|
472
|
+
resultSchema: valibot.object({
|
|
473
|
+
version: valibot.string(),
|
|
474
|
+
platform: valibot.optional(valibot.enum(ProviderPlatform)),
|
|
475
|
+
methods: valibot.optional(valibot.array(valibot.string())),
|
|
476
|
+
supports: valibot.array(valibot.string())
|
|
477
|
+
}),
|
|
478
|
+
method: bitcoinMethods.getInfo
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/request/createRequestSchema.ts
|
|
483
|
+
function createRequestSchema({ paramsSchema, method }) {
|
|
484
|
+
return valibot.object({
|
|
485
|
+
...rpcRequestSchema.entries,
|
|
486
|
+
id: valibot.string(),
|
|
487
|
+
method: valibot.literal(method),
|
|
488
|
+
params: paramsSchema
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/request/rpc/methodSchemas/bitcoin/signMessage/request.ts
|
|
494
|
+
let MessageSigningProtocols = /* @__PURE__ */ function(MessageSigningProtocols$1) {
|
|
495
|
+
MessageSigningProtocols$1["ECDSA"] = "ECDSA";
|
|
496
|
+
MessageSigningProtocols$1["BIP322"] = "BIP322";
|
|
497
|
+
return MessageSigningProtocols$1;
|
|
498
|
+
}({});
|
|
499
|
+
const bitcoinSignMessageRequestSchema = createRequestSchema({
|
|
500
|
+
paramsSchema: valibot.object({
|
|
501
|
+
address: valibot.string(),
|
|
502
|
+
message: valibot.string(),
|
|
503
|
+
protocol: valibot.optional(valibot.enum(MessageSigningProtocols))
|
|
504
|
+
}),
|
|
505
|
+
method: bitcoinMethods.signMessage
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/request/index.ts
|
|
510
|
+
const cache = {};
|
|
511
|
+
const requestInternal = async (provider, method, params) => {
|
|
512
|
+
const response = await provider.request(method, params);
|
|
513
|
+
if (valibot.is(rpcErrorResponseMessageSchema, response)) return {
|
|
514
|
+
status: "error",
|
|
515
|
+
error: response.error
|
|
516
|
+
};
|
|
517
|
+
if (valibot.is(rpcSuccessResponseMessageSchema, response)) return {
|
|
518
|
+
status: "success",
|
|
519
|
+
result: response.result
|
|
520
|
+
};
|
|
521
|
+
return {
|
|
522
|
+
status: "error",
|
|
523
|
+
error: {
|
|
524
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
525
|
+
message: "Received unknown response from provider.",
|
|
526
|
+
data: response
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
const request = async (method, params, providerId) => {
|
|
531
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
532
|
+
if (providerId) provider = await getProviderById(providerId);
|
|
533
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
534
|
+
if (!method) throw new Error("A wallet method is required");
|
|
535
|
+
if (!cache.providerInfo) {
|
|
536
|
+
const infoResult = await requestInternal(provider, "getInfo", null);
|
|
537
|
+
if (infoResult.status === "success") cache.providerInfo = infoResult.result;
|
|
538
|
+
}
|
|
539
|
+
if (cache.providerInfo) {
|
|
540
|
+
if (method === "getInfo") return {
|
|
541
|
+
status: "success",
|
|
542
|
+
result: cache.providerInfo
|
|
543
|
+
};
|
|
544
|
+
const sanitized = sanitizeRequest(method, params, cache.providerInfo);
|
|
545
|
+
if (sanitized.overrideResponse) return sanitized.overrideResponse;
|
|
546
|
+
method = sanitized.method;
|
|
547
|
+
params = sanitized.params;
|
|
548
|
+
}
|
|
549
|
+
return requestInternal(provider, method, params);
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* Adds an event listener.
|
|
553
|
+
*
|
|
554
|
+
* Currently expects 2 arguments, although is also capable of handling legacy
|
|
555
|
+
* calls with 3 arguments consisting of:
|
|
556
|
+
*
|
|
557
|
+
* - event name (string)
|
|
558
|
+
* - callback (function)
|
|
559
|
+
* - provider ID (optional string)
|
|
560
|
+
*/
|
|
561
|
+
const addListener = (...rawArgs) => {
|
|
562
|
+
const [listenerInfo, providerId] = (() => {
|
|
563
|
+
if (rawArgs.length === 1) return [rawArgs[0], void 0];
|
|
564
|
+
if (rawArgs.length === 2) if (typeof rawArgs[1] === "function") return [{
|
|
565
|
+
eventName: rawArgs[0],
|
|
566
|
+
cb: rawArgs[1]
|
|
567
|
+
}, void 0];
|
|
568
|
+
else return rawArgs;
|
|
569
|
+
if (rawArgs.length === 3) return [{
|
|
570
|
+
eventName: rawArgs[0],
|
|
571
|
+
cb: rawArgs[1]
|
|
572
|
+
}, rawArgs[2]];
|
|
573
|
+
throw new Error("Unexpected number of arguments. Expecting 2 (or 3 for legacy requests).", { cause: rawArgs });
|
|
574
|
+
})();
|
|
575
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
576
|
+
if (providerId) provider = getProviderById(providerId);
|
|
577
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
578
|
+
if (!provider.addListener) {
|
|
579
|
+
console.error(`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`);
|
|
580
|
+
return () => {};
|
|
581
|
+
}
|
|
582
|
+
return provider.addListener(listenerInfo);
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region src/runes/api.ts
|
|
587
|
+
const urlNetworkSuffix = {
|
|
588
|
+
[BitcoinNetworkType.Mainnet]: "",
|
|
589
|
+
[BitcoinNetworkType.Testnet]: "-testnet",
|
|
590
|
+
[BitcoinNetworkType.Testnet4]: "-testnet4",
|
|
591
|
+
[BitcoinNetworkType.Signet]: "-signet"
|
|
592
|
+
};
|
|
593
|
+
const ORDINALS_API_BASE_URL = (network = BitcoinNetworkType.Mainnet) => {
|
|
594
|
+
if (network === BitcoinNetworkType.Regtest) throw new Error(`Ordinals API does not support ${network} network`);
|
|
595
|
+
return `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
|
596
|
+
};
|
|
597
|
+
var RunesApi = class {
|
|
598
|
+
client;
|
|
599
|
+
constructor(network) {
|
|
600
|
+
this.client = axios.default.create({ baseURL: ORDINALS_API_BASE_URL(network) });
|
|
601
|
+
}
|
|
602
|
+
parseError = (error) => {
|
|
603
|
+
return {
|
|
604
|
+
code: error.response?.status,
|
|
605
|
+
message: JSON.stringify(error.response?.data)
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
estimateMintCost = async (mintParams) => {
|
|
609
|
+
try {
|
|
610
|
+
return { data: (await this.client.post("/runes/mint/estimate", { ...mintParams })).data };
|
|
611
|
+
} catch (error) {
|
|
612
|
+
const err = error;
|
|
613
|
+
return { error: this.parseError(err) };
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
estimateEtchCost = async (etchParams) => {
|
|
617
|
+
try {
|
|
618
|
+
return { data: (await this.client.post("/runes/etch/estimate", { ...etchParams })).data };
|
|
619
|
+
} catch (error) {
|
|
620
|
+
const err = error;
|
|
621
|
+
return { error: this.parseError(err) };
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
createMintOrder = async (mintOrderParams) => {
|
|
625
|
+
try {
|
|
626
|
+
return { data: (await this.client.post("/runes/mint/orders", { ...mintOrderParams })).data };
|
|
627
|
+
} catch (error) {
|
|
628
|
+
const err = error;
|
|
629
|
+
return { error: this.parseError(err) };
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
createEtchOrder = async (etchOrderParams) => {
|
|
633
|
+
try {
|
|
634
|
+
return { data: (await this.client.post("/runes/etch/orders", { ...etchOrderParams })).data };
|
|
635
|
+
} catch (error) {
|
|
636
|
+
const err = error;
|
|
637
|
+
return { error: this.parseError(err) };
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
executeMint = async (orderId, fundTransactionId) => {
|
|
641
|
+
try {
|
|
642
|
+
return { data: (await this.client.post(`/runes/mint/orders/${orderId}/execute`, { fundTransactionId })).data };
|
|
643
|
+
} catch (error) {
|
|
644
|
+
const err = error;
|
|
645
|
+
return { error: this.parseError(err) };
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
executeEtch = async (orderId, fundTransactionId) => {
|
|
649
|
+
try {
|
|
650
|
+
return { data: (await this.client.post(`/runes/etch/orders/${orderId}/execute`, { fundTransactionId })).data };
|
|
651
|
+
} catch (error) {
|
|
652
|
+
const err = error;
|
|
653
|
+
return { error: this.parseError(err) };
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
getOrder = async (orderId) => {
|
|
657
|
+
try {
|
|
658
|
+
return { data: (await this.client.get(`/orders/${orderId}`)).data };
|
|
659
|
+
} catch (error) {
|
|
660
|
+
const err = error;
|
|
661
|
+
return { error: this.parseError(err) };
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
rbfOrder = async (rbfRequest) => {
|
|
665
|
+
const { orderId, newFeeRate } = rbfRequest;
|
|
666
|
+
try {
|
|
667
|
+
return { data: (await this.client.post(`/orders/${orderId}/rbf-estimate`, { newFeeRate })).data };
|
|
668
|
+
} catch (error) {
|
|
669
|
+
const err = error;
|
|
670
|
+
return { error: this.parseError(err) };
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
const clients = {};
|
|
675
|
+
const getRunesApiClient = (network = BitcoinNetworkType.Mainnet) => {
|
|
676
|
+
if (!clients[network]) clients[network] = new RunesApi(network);
|
|
677
|
+
return clients[network];
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/adapters/satsConnectAdapter.ts
|
|
682
|
+
var SatsConnectAdapter = class {
|
|
683
|
+
async mintRunes(params) {
|
|
684
|
+
try {
|
|
685
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
686
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
687
|
+
if (walletInfo.result.methods?.includes("runes_mint")) {
|
|
688
|
+
const response = await this.requestInternal("runes_mint", params);
|
|
689
|
+
if (response) {
|
|
690
|
+
if (response.status === "success") return response;
|
|
691
|
+
if (response.status === "error" && response.error.code !== RpcErrorCode.METHOD_NOT_FOUND) return response;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
const mintRequest = {
|
|
696
|
+
destinationAddress: params.destinationAddress,
|
|
697
|
+
feeRate: params.feeRate,
|
|
698
|
+
refundAddress: params.refundAddress,
|
|
699
|
+
repeats: params.repeats,
|
|
700
|
+
runeName: params.runeName,
|
|
701
|
+
appServiceFee: params.appServiceFee,
|
|
702
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
703
|
+
};
|
|
704
|
+
const orderResponse = await new RunesApi(params.network).createMintOrder(mintRequest);
|
|
705
|
+
if (!orderResponse.data) return {
|
|
706
|
+
status: "error",
|
|
707
|
+
error: {
|
|
708
|
+
code: orderResponse.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
709
|
+
message: orderResponse.error.message
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
713
|
+
address: orderResponse.data.fundAddress,
|
|
714
|
+
amount: orderResponse.data.fundAmount
|
|
715
|
+
}] });
|
|
716
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
717
|
+
await new RunesApi(params.network).executeMint(orderResponse.data.orderId, paymentResponse.result.txid);
|
|
718
|
+
return {
|
|
719
|
+
status: "success",
|
|
720
|
+
result: {
|
|
721
|
+
orderId: orderResponse.data.orderId,
|
|
722
|
+
fundTransactionId: paymentResponse.result.txid,
|
|
723
|
+
fundingAddress: orderResponse.data.fundAddress
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
} catch (error) {
|
|
727
|
+
return {
|
|
728
|
+
status: "error",
|
|
729
|
+
error: {
|
|
730
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
731
|
+
message: error.message
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
async etchRunes(params) {
|
|
737
|
+
const etchRequest = {
|
|
738
|
+
destinationAddress: params.destinationAddress,
|
|
739
|
+
refundAddress: params.refundAddress,
|
|
740
|
+
feeRate: params.feeRate,
|
|
741
|
+
runeName: params.runeName,
|
|
742
|
+
divisibility: params.divisibility,
|
|
743
|
+
symbol: params.symbol,
|
|
744
|
+
premine: params.premine,
|
|
745
|
+
isMintable: params.isMintable,
|
|
746
|
+
terms: params.terms,
|
|
747
|
+
inscriptionDetails: params.inscriptionDetails,
|
|
748
|
+
delegateInscriptionId: params.delegateInscriptionId,
|
|
749
|
+
appServiceFee: params.appServiceFee,
|
|
750
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
751
|
+
};
|
|
752
|
+
try {
|
|
753
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
754
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
755
|
+
if (walletInfo.result.methods?.includes("runes_etch")) {
|
|
756
|
+
const response = await this.requestInternal("runes_etch", params);
|
|
757
|
+
if (response) {
|
|
758
|
+
if (response.status === "success") return response;
|
|
759
|
+
if (response.status === "error" && response.error.code !== RpcErrorCode.METHOD_NOT_FOUND) return response;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
764
|
+
if (!orderResponse.data) return {
|
|
765
|
+
status: "error",
|
|
766
|
+
error: {
|
|
767
|
+
code: orderResponse.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
768
|
+
message: orderResponse.error.message
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
772
|
+
address: orderResponse.data.fundAddress,
|
|
773
|
+
amount: orderResponse.data.fundAmount
|
|
774
|
+
}] });
|
|
775
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
776
|
+
await new RunesApi(params.network).executeEtch(orderResponse.data.orderId, paymentResponse.result.txid);
|
|
777
|
+
return {
|
|
778
|
+
status: "success",
|
|
779
|
+
result: {
|
|
780
|
+
orderId: orderResponse.data.orderId,
|
|
781
|
+
fundTransactionId: paymentResponse.result.txid,
|
|
782
|
+
fundingAddress: orderResponse.data.fundAddress
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
} catch (error) {
|
|
786
|
+
return {
|
|
787
|
+
status: "error",
|
|
788
|
+
error: {
|
|
789
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
790
|
+
message: error.message
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async estimateMint(params) {
|
|
796
|
+
const estimateMintRequest = {
|
|
797
|
+
destinationAddress: params.destinationAddress,
|
|
798
|
+
feeRate: params.feeRate,
|
|
799
|
+
repeats: params.repeats,
|
|
800
|
+
runeName: params.runeName,
|
|
801
|
+
appServiceFee: params.appServiceFee,
|
|
802
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
803
|
+
};
|
|
804
|
+
const response = await getRunesApiClient(params.network).estimateMintCost(estimateMintRequest);
|
|
805
|
+
if (response.data) return {
|
|
806
|
+
status: "success",
|
|
807
|
+
result: response.data
|
|
808
|
+
};
|
|
809
|
+
return {
|
|
810
|
+
status: "error",
|
|
811
|
+
error: {
|
|
812
|
+
code: response.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
813
|
+
message: response.error.message
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
async estimateEtch(params) {
|
|
818
|
+
const estimateEtchRequest = {
|
|
819
|
+
destinationAddress: params.destinationAddress,
|
|
820
|
+
feeRate: params.feeRate,
|
|
821
|
+
runeName: params.runeName,
|
|
822
|
+
divisibility: params.divisibility,
|
|
823
|
+
symbol: params.symbol,
|
|
824
|
+
premine: params.premine,
|
|
825
|
+
isMintable: params.isMintable,
|
|
826
|
+
terms: params.terms,
|
|
827
|
+
inscriptionDetails: params.inscriptionDetails,
|
|
828
|
+
delegateInscriptionId: params.delegateInscriptionId,
|
|
829
|
+
appServiceFee: params.appServiceFee,
|
|
830
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
831
|
+
};
|
|
832
|
+
const response = await getRunesApiClient(params.network).estimateEtchCost(estimateEtchRequest);
|
|
833
|
+
if (response.data) return {
|
|
834
|
+
status: "success",
|
|
835
|
+
result: response.data
|
|
836
|
+
};
|
|
837
|
+
return {
|
|
838
|
+
status: "error",
|
|
839
|
+
error: {
|
|
840
|
+
code: response.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
841
|
+
message: response.error.message
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
async getOrder(params) {
|
|
846
|
+
const response = await getRunesApiClient(params.network).getOrder(params.id);
|
|
847
|
+
if (response.data) return {
|
|
848
|
+
status: "success",
|
|
849
|
+
result: response.data
|
|
850
|
+
};
|
|
851
|
+
return {
|
|
852
|
+
status: "error",
|
|
853
|
+
error: {
|
|
854
|
+
code: response.error.code === 400 || response.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
855
|
+
message: response.error.message
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
async estimateRbfOrder(params) {
|
|
860
|
+
const rbfOrderRequest = {
|
|
861
|
+
newFeeRate: params.newFeeRate,
|
|
862
|
+
orderId: params.orderId
|
|
863
|
+
};
|
|
864
|
+
const response = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
|
|
865
|
+
if (response.data) return {
|
|
866
|
+
status: "success",
|
|
867
|
+
result: {
|
|
868
|
+
fundingAddress: response.data.fundingAddress,
|
|
869
|
+
rbfCost: response.data.rbfCost
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
return {
|
|
873
|
+
status: "error",
|
|
874
|
+
error: {
|
|
875
|
+
code: response.error.code === 400 || response.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
876
|
+
message: response.error.message
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
async rbfOrder(params) {
|
|
881
|
+
try {
|
|
882
|
+
const rbfOrderRequest = {
|
|
883
|
+
newFeeRate: params.newFeeRate,
|
|
884
|
+
orderId: params.orderId
|
|
885
|
+
};
|
|
886
|
+
const orderResponse = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
|
|
887
|
+
if (!orderResponse.data) return {
|
|
888
|
+
status: "error",
|
|
889
|
+
error: {
|
|
890
|
+
code: orderResponse.error.code === 400 || orderResponse.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
891
|
+
message: orderResponse.error.message
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
895
|
+
address: orderResponse.data.fundingAddress,
|
|
896
|
+
amount: orderResponse.data.rbfCost
|
|
897
|
+
}] });
|
|
898
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
899
|
+
return {
|
|
900
|
+
status: "success",
|
|
901
|
+
result: {
|
|
902
|
+
fundingAddress: orderResponse.data.fundingAddress,
|
|
903
|
+
orderId: rbfOrderRequest.orderId,
|
|
904
|
+
fundRBFTransactionId: paymentResponse.result.txid
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
} catch (error) {
|
|
908
|
+
return {
|
|
909
|
+
status: "error",
|
|
910
|
+
error: {
|
|
911
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
912
|
+
message: error.message
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
async request(method, params) {
|
|
918
|
+
switch (method) {
|
|
919
|
+
case "runes_mint": return this.mintRunes(params);
|
|
920
|
+
case "runes_etch": return this.etchRunes(params);
|
|
921
|
+
case "runes_estimateMint": return this.estimateMint(params);
|
|
922
|
+
case "runes_estimateEtch": return this.estimateEtch(params);
|
|
923
|
+
case "runes_getOrder": return this.getOrder(params);
|
|
924
|
+
case "runes_estimateRbfOrder": return this.estimateRbfOrder(params);
|
|
925
|
+
case "runes_rbfOrder": return this.rbfOrder(params);
|
|
926
|
+
default: return this.requestInternal(method, params);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region src/adapters/xverse.ts
|
|
933
|
+
var XverseAdapter = class extends SatsConnectAdapter {
|
|
934
|
+
id = DefaultAdaptersInfo.xverse.id;
|
|
935
|
+
requestInternal = async (method, params) => {
|
|
936
|
+
return request(method, params, this.id);
|
|
937
|
+
};
|
|
938
|
+
addListener = (listenerInfo) => {
|
|
939
|
+
return addListener(listenerInfo, this.id);
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
//#endregion
|
|
944
|
+
//#region src/adapters/unisat.ts
|
|
945
|
+
function convertSignInputsToInputType(signInputs) {
|
|
946
|
+
let result = [];
|
|
947
|
+
if (!signInputs) return result;
|
|
948
|
+
for (let address in signInputs) {
|
|
949
|
+
let indexes = signInputs[address];
|
|
950
|
+
for (let index of indexes) result.push({
|
|
951
|
+
index,
|
|
952
|
+
address
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
return result;
|
|
956
|
+
}
|
|
957
|
+
var UnisatAdapter = class extends SatsConnectAdapter {
|
|
958
|
+
id = DefaultAdaptersInfo.unisat.id;
|
|
959
|
+
async getAccounts(params) {
|
|
960
|
+
const { purposes } = params;
|
|
961
|
+
if (purposes.includes(AddressPurpose.Stacks) || purposes.includes(AddressPurpose.Starknet) || purposes.includes(AddressPurpose.Spark)) throw new Error("Only bitcoin addresses are supported");
|
|
962
|
+
const accounts = await window.unisat.requestAccounts();
|
|
963
|
+
const publicKey = await window.unisat.getPublicKey();
|
|
964
|
+
const address = accounts[0];
|
|
965
|
+
const addressType = (0, bitcoin_address_validation.getAddressInfo)(accounts[0]).type;
|
|
966
|
+
const pk = addressType === bitcoin_address_validation.AddressType.p2tr ? publicKey.slice(2) : publicKey;
|
|
967
|
+
const paymentAddress = {
|
|
968
|
+
address,
|
|
969
|
+
publicKey: pk,
|
|
970
|
+
addressType,
|
|
971
|
+
purpose: AddressPurpose.Payment,
|
|
972
|
+
walletType: "software"
|
|
973
|
+
};
|
|
974
|
+
const ordinalsAddress = {
|
|
975
|
+
address,
|
|
976
|
+
publicKey: pk,
|
|
977
|
+
addressType,
|
|
978
|
+
purpose: AddressPurpose.Ordinals,
|
|
979
|
+
walletType: "software"
|
|
980
|
+
};
|
|
981
|
+
const response = [];
|
|
982
|
+
if (purposes.includes(AddressPurpose.Payment)) response.push({
|
|
983
|
+
...paymentAddress,
|
|
984
|
+
walletType: "software"
|
|
985
|
+
});
|
|
986
|
+
if (purposes.includes(AddressPurpose.Ordinals)) response.push({
|
|
987
|
+
...ordinalsAddress,
|
|
988
|
+
walletType: "software"
|
|
989
|
+
});
|
|
990
|
+
return response;
|
|
991
|
+
}
|
|
992
|
+
async signMessage(params) {
|
|
993
|
+
const { message, address } = params;
|
|
994
|
+
const addressType = (0, bitcoin_address_validation.getAddressInfo)(address).type;
|
|
995
|
+
if ([bitcoin_address_validation.AddressType.p2wpkh, bitcoin_address_validation.AddressType.p2tr].includes(addressType)) return {
|
|
996
|
+
address,
|
|
997
|
+
messageHash: "",
|
|
998
|
+
signature: await window.unisat.signMessage(message, "bip322-simple"),
|
|
999
|
+
protocol: MessageSigningProtocols.BIP322
|
|
1000
|
+
};
|
|
1001
|
+
return {
|
|
1002
|
+
address,
|
|
1003
|
+
messageHash: "",
|
|
1004
|
+
signature: await window.unisat.signMessage(message, "ecdsa"),
|
|
1005
|
+
protocol: MessageSigningProtocols.ECDSA
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
async sendTransfer(params) {
|
|
1009
|
+
const { recipients } = params;
|
|
1010
|
+
if (recipients.length > 1) throw new Error("Only one recipient is supported by this wallet provider");
|
|
1011
|
+
return { txid: await window.unisat.sendBitcoin(recipients[0].address, recipients[0].amount) };
|
|
1012
|
+
}
|
|
1013
|
+
async signPsbt(params) {
|
|
1014
|
+
const { psbt, signInputs, broadcast } = params;
|
|
1015
|
+
const psbtHex = buffer.Buffer.from(psbt, "base64").toString("hex");
|
|
1016
|
+
const signedPsbt = await window.unisat.signPsbt(psbtHex, {
|
|
1017
|
+
autoFinalized: broadcast,
|
|
1018
|
+
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
1019
|
+
});
|
|
1020
|
+
const signedPsbtBase64 = buffer.Buffer.from(signedPsbt, "hex").toString("base64");
|
|
1021
|
+
let txid;
|
|
1022
|
+
if (broadcast) txid = await window.unisat.pushPsbt(signedPsbt);
|
|
1023
|
+
return {
|
|
1024
|
+
psbt: signedPsbtBase64,
|
|
1025
|
+
txid
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
requestInternal = async (method, params) => {
|
|
1029
|
+
try {
|
|
1030
|
+
switch (method) {
|
|
1031
|
+
case "getAccounts": return {
|
|
1032
|
+
status: "success",
|
|
1033
|
+
result: await this.getAccounts(params)
|
|
1034
|
+
};
|
|
1035
|
+
case "sendTransfer": return {
|
|
1036
|
+
status: "success",
|
|
1037
|
+
result: await this.sendTransfer(params)
|
|
1038
|
+
};
|
|
1039
|
+
case "signMessage": return {
|
|
1040
|
+
status: "success",
|
|
1041
|
+
result: await this.signMessage(params)
|
|
1042
|
+
};
|
|
1043
|
+
case "signPsbt": return {
|
|
1044
|
+
status: "success",
|
|
1045
|
+
result: await this.signPsbt(params)
|
|
1046
|
+
};
|
|
1047
|
+
default: {
|
|
1048
|
+
const error = {
|
|
1049
|
+
code: RpcErrorCode.METHOD_NOT_SUPPORTED,
|
|
1050
|
+
message: "Method not supported by the selected wallet"
|
|
1051
|
+
};
|
|
1052
|
+
console.error("Error calling the method", error);
|
|
1053
|
+
return {
|
|
1054
|
+
status: "error",
|
|
1055
|
+
error
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
} catch (error) {
|
|
1060
|
+
console.error("Error calling the method", error);
|
|
1061
|
+
return {
|
|
1062
|
+
status: "error",
|
|
1063
|
+
error: {
|
|
1064
|
+
code: error.code === 4001 ? RpcErrorCode.USER_REJECTION : RpcErrorCode.INTERNAL_ERROR,
|
|
1065
|
+
message: error.message ? error.message : "Wallet method call error",
|
|
1066
|
+
data: error
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
addListener = ({ eventName, cb }) => {
|
|
1072
|
+
switch (eventName) {
|
|
1073
|
+
case "accountChange": {
|
|
1074
|
+
const handler = () => {
|
|
1075
|
+
cb({ type: "accountChange" });
|
|
1076
|
+
};
|
|
1077
|
+
window.unisat.on("accountsChanged", handler);
|
|
1078
|
+
return () => {
|
|
1079
|
+
window.unisat.removeListener("accountsChanged", handler);
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
case "networkChange": {
|
|
1083
|
+
const handler = () => {
|
|
1084
|
+
cb({ type: "networkChange" });
|
|
1085
|
+
};
|
|
1086
|
+
window.unisat.on("networkChanged", handler);
|
|
1087
|
+
return () => {
|
|
1088
|
+
window.unisat.removeListener("networkChanged", handler);
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
default:
|
|
1092
|
+
console.error("Event not supported by the selected wallet");
|
|
1093
|
+
return () => {};
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region src/adapters/fordefi.ts
|
|
1100
|
+
var FordefiAdapter = class extends SatsConnectAdapter {
|
|
1101
|
+
id = DefaultAdaptersInfo.fordefi.id;
|
|
1102
|
+
requestInternal = async (method, params) => {
|
|
1103
|
+
const provider = getProviderById(this.id);
|
|
1104
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1105
|
+
if (!method) throw new Error("A wallet method is required");
|
|
1106
|
+
return await provider.request(method, params);
|
|
1107
|
+
};
|
|
1108
|
+
addListener = ({ eventName, cb }) => {
|
|
1109
|
+
const provider = getProviderById(this.id);
|
|
1110
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1111
|
+
if (!provider.addListener) {
|
|
1112
|
+
console.error(`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`);
|
|
1113
|
+
return () => {};
|
|
1114
|
+
}
|
|
1115
|
+
return provider.addListener(eventName, cb);
|
|
1116
|
+
};
|
|
1117
|
+
};
|
|
1118
|
+
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region src/adapters/BaseAdapter.ts
|
|
1121
|
+
var BaseAdapter = class extends SatsConnectAdapter {
|
|
1122
|
+
id = "";
|
|
1123
|
+
constructor(providerId) {
|
|
1124
|
+
super();
|
|
1125
|
+
this.id = providerId;
|
|
1126
|
+
}
|
|
1127
|
+
requestInternal = async (method, params) => {
|
|
1128
|
+
return request(method, params, this.id);
|
|
1129
|
+
};
|
|
1130
|
+
addListener = (..._args) => {
|
|
1131
|
+
throw new Error("Method not supported for `BaseAdapter`.");
|
|
1132
|
+
};
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
//#endregion
|
|
1136
|
+
//#region src/adapters/index.ts
|
|
1137
|
+
const DefaultAdaptersInfo = {
|
|
1138
|
+
fordefi: {
|
|
1139
|
+
id: "FordefiProviders.UtxoProvider",
|
|
1140
|
+
name: "Fordefi",
|
|
1141
|
+
webUrl: "https://www.fordefi.com/",
|
|
1142
|
+
chromeWebStoreUrl: "https://chromewebstore.google.com/detail/fordefi/hcmehenccjdmfbojapcbcofkgdpbnlle",
|
|
1143
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzEzNDk0XzY2MjU0KSI+CjxwYXRoIGQ9Ik0xMC44NzY5IDE1LjYzNzhIMS41VjE4LjM5OUMxLjUgMTkuODAxMyAyLjYzNDQ3IDIwLjkzOCA0LjAzMzkyIDIwLjkzOEg4LjI0OTkyTDEwLjg3NjkgMTUuNjM3OFoiIGZpbGw9IiM3OTk0RkYiLz4KPHBhdGggZD0iTTEuNSA5Ljc3NTUxSDE5LjA1MTZMMTcuMDEzOSAxMy44NzExSDEuNVY5Ljc3NTUxWiIgZmlsbD0iIzQ4NkRGRiIvPgo8cGF0aCBkPSJNNy42NTk5NiAzSDEuNTI0NDFWOC4wMDcwNEgyMi40NjEyVjNIMTYuMzI1NlY2LjczOTQ0SDE1LjA2MDZWM0g4LjkyNTAyVjYuNzM5NDRINy42NTk5NlYzWiIgZmlsbD0iIzVDRDFGQSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEzNDk0XzY2MjU0Ij4KPHJlY3Qgd2lkdGg9IjIxIiBoZWlnaHQ9IjE4IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMS41IDMpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
1144
|
+
},
|
|
1145
|
+
xverse: {
|
|
1146
|
+
id: "XverseProviders.BitcoinProvider",
|
|
1147
|
+
name: "Xverse",
|
|
1148
|
+
webUrl: "https://www.xverse.app/",
|
|
1149
|
+
googlePlayStoreUrl: "https://play.google.com/store/apps/details?id=com.secretkeylabs.xverse",
|
|
1150
|
+
iOSAppStoreUrl: "https://apps.apple.com/app/xverse-bitcoin-web3-wallet/id1552272513",
|
|
1151
|
+
chromeWebStoreUrl: "https://chromewebstore.google.com/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg",
|
|
1152
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgdmlld0JveD0iMCAwIDEwMiAxMDIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGlkPSJJY29uX0FydCAoRWRpdCBNZSkiPgo8cmVjdCB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgZmlsbD0i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BzdG9wLWNvbG9yPSIjRjRGQjUyIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxyYWRpYWxHcmFkaWVudCBpZD0icGFpbnQyX3JhZGlhbF8xMDA1MF80MTcxIiBjeD0iMCIgY3k9IjAiIHI9IjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDg1LjAwOTkgNjEuODM5Mikgc2NhbGUoMTEuMTMpIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0Y0Qjg1MiIvPgo8c3RvcCBvZmZzZXQ9IjAuMzMiIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIwLjY0IiBzdG9wLWNvbG9yPSIjNzczOTBEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzIxMUMxRCIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEwMDUwXzQxNzEiPgo8cmVjdCB3aWR0aD0iMTE1Ljc3IiBoZWlnaHQ9IjE0Ny43IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMzIgMTYpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
const defaultAdapters = {
|
|
1162
|
+
[DefaultAdaptersInfo.fordefi.id]: FordefiAdapter,
|
|
1163
|
+
[DefaultAdaptersInfo.xverse.id]: XverseAdapter,
|
|
1164
|
+
[DefaultAdaptersInfo.unisat.id]: UnisatAdapter
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
//#endregion
|
|
1168
|
+
//#region src/capabilities/index.ts
|
|
1169
|
+
const extractOrValidateCapabilities = (provider, reportedCapabilities) => {
|
|
1170
|
+
const validateCapability = (capability) => {
|
|
1171
|
+
if (!provider[capability]) return false;
|
|
1172
|
+
if (reportedCapabilities && !reportedCapabilities.has(capability)) return false;
|
|
1173
|
+
return true;
|
|
1174
|
+
};
|
|
1175
|
+
const capabilityMap = {
|
|
1176
|
+
request: validateCapability("request"),
|
|
1177
|
+
connect: validateCapability("connect"),
|
|
1178
|
+
signMessage: validateCapability("signMessage"),
|
|
1179
|
+
signTransaction: validateCapability("signTransaction"),
|
|
1180
|
+
sendBtcTransaction: validateCapability("sendBtcTransaction"),
|
|
1181
|
+
createInscription: validateCapability("createInscription"),
|
|
1182
|
+
createRepeatInscriptions: validateCapability("createRepeatInscriptions"),
|
|
1183
|
+
signMultipleTransactions: validateCapability("signMultipleTransactions"),
|
|
1184
|
+
addListener: validateCapability("addListener")
|
|
1185
|
+
};
|
|
1186
|
+
return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
|
|
1187
|
+
if (value) return [...acc, capability];
|
|
1188
|
+
return acc;
|
|
1189
|
+
}, []);
|
|
1190
|
+
};
|
|
1191
|
+
const getCapabilities = async (options) => {
|
|
1192
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1193
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1194
|
+
if (provider.getCapabilities) try {
|
|
1195
|
+
const response = await provider.getCapabilities(request$1);
|
|
1196
|
+
options.onFinish?.(extractOrValidateCapabilities(provider, new Set(response)));
|
|
1197
|
+
} catch (error) {
|
|
1198
|
+
console.error("[Connect] Error during capabilities request", error);
|
|
1199
|
+
}
|
|
1200
|
+
try {
|
|
1201
|
+
const inferredCapabilities = extractOrValidateCapabilities(provider);
|
|
1202
|
+
options.onFinish?.(inferredCapabilities);
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
console.error("[Connect] Error during capabilities request", error);
|
|
1205
|
+
options.onCancel?.();
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/inscriptions/utils.ts
|
|
1211
|
+
const MAX_CONTENT_LENGTH_MAINNET = 4e5;
|
|
1212
|
+
const MAX_CONTENT_LENGTH_TESTNET = 6e4;
|
|
1213
|
+
const validateInscriptionPayload = (payload) => {
|
|
1214
|
+
const { contentType, content, payloadType, network, appFeeAddress, appFee } = payload;
|
|
1215
|
+
if (!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(contentType)) throw new Error("Invalid content type detected");
|
|
1216
|
+
if (!content || content.length === 0) throw new Error("Empty content not allowed");
|
|
1217
|
+
if (!payloadType || payloadType !== "BASE_64" && payloadType !== "PLAIN_TEXT") throw new Error("Empty invalid payloadType specified");
|
|
1218
|
+
if (content.length > (network.type === "Mainnet" ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)) throw new Error("Content too large");
|
|
1219
|
+
if ((appFeeAddress?.length ?? 0) > 0 && (appFee ?? 0) <= 0) throw new Error("Invalid combination of app fee address and fee provided");
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
//#endregion
|
|
1223
|
+
//#region src/inscriptions/createInscription.ts
|
|
1224
|
+
const createInscription = async (options) => {
|
|
1225
|
+
const { getProvider } = options;
|
|
1226
|
+
const provider = await getProviderOrThrow(getProvider);
|
|
1227
|
+
validateInscriptionPayload(options.payload);
|
|
1228
|
+
try {
|
|
1229
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1230
|
+
const response = await provider.createInscription(request$1);
|
|
1231
|
+
options.onFinish?.(response);
|
|
1232
|
+
} catch (error) {
|
|
1233
|
+
console.error("[Connect] Error during create inscription", error);
|
|
1234
|
+
options.onCancel?.();
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
//#endregion
|
|
1239
|
+
//#region src/inscriptions/createRepeatInscriptions.ts
|
|
1240
|
+
const createRepeatInscriptions = async (options) => {
|
|
1241
|
+
const { getProvider } = options;
|
|
1242
|
+
const provider = await getProviderOrThrow(getProvider);
|
|
1243
|
+
validateInscriptionPayload(options.payload);
|
|
1244
|
+
try {
|
|
1245
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1246
|
+
const response = await provider.createRepeatInscriptions(request$1);
|
|
1247
|
+
options.onFinish?.(response);
|
|
1248
|
+
} catch (error) {
|
|
1249
|
+
console.error("[Connect] Error during create repeat inscriptions", error);
|
|
1250
|
+
options.onCancel?.();
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
//#endregion
|
|
1255
|
+
//#region src/messages/index.ts
|
|
1256
|
+
const signMessage = async (options) => {
|
|
1257
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1258
|
+
const { address, message } = options.payload;
|
|
1259
|
+
if (!address) throw new Error("An address is required to sign a message");
|
|
1260
|
+
if (!message) throw new Error("A message to be signed is required");
|
|
1261
|
+
try {
|
|
1262
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1263
|
+
const response = await provider.signMessage(request$1);
|
|
1264
|
+
options.onFinish?.(response);
|
|
1265
|
+
} catch (error) {
|
|
1266
|
+
console.error("[Connect] Error during sign message request", error);
|
|
1267
|
+
options.onCancel?.();
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1271
|
+
//#endregion
|
|
1272
|
+
//#region src/transactions/sendBtcTransaction.ts
|
|
1273
|
+
const serializer = (recipient) => {
|
|
1274
|
+
return recipient.map((value) => {
|
|
1275
|
+
const { address, amountSats } = value;
|
|
1276
|
+
return {
|
|
1277
|
+
address,
|
|
1278
|
+
amountSats: amountSats.toString()
|
|
1279
|
+
};
|
|
1280
|
+
});
|
|
1281
|
+
};
|
|
1282
|
+
const sendBtcTransaction = async (options) => {
|
|
1283
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1284
|
+
const { recipients, senderAddress, network, message } = options.payload;
|
|
1285
|
+
if (!recipients || recipients.length === 0) throw new Error("At least one recipient is required");
|
|
1286
|
+
if (recipients.some((item) => typeof item.address !== "string" || typeof item.amountSats !== "bigint")) throw new Error("Incorrect recipient format");
|
|
1287
|
+
if (!senderAddress) throw new Error("The sender address is required");
|
|
1288
|
+
try {
|
|
1289
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)({
|
|
1290
|
+
network,
|
|
1291
|
+
senderAddress,
|
|
1292
|
+
message,
|
|
1293
|
+
recipients: serializer(recipients)
|
|
1294
|
+
});
|
|
1295
|
+
const response = await provider.sendBtcTransaction(request$1);
|
|
1296
|
+
options.onFinish?.(response);
|
|
1297
|
+
} catch (error) {
|
|
1298
|
+
console.error("[Connect] Error during send BTC transaction request", error);
|
|
1299
|
+
options.onCancel?.();
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
//#endregion
|
|
1304
|
+
//#region src/transactions/signTransaction.ts
|
|
1305
|
+
const signTransaction = async (options) => {
|
|
1306
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1307
|
+
const { psbtBase64, inputsToSign } = options.payload;
|
|
1308
|
+
if (!psbtBase64) throw new Error("A value for psbtBase64 representing the tx hash is required");
|
|
1309
|
+
if (!inputsToSign) throw new Error("An array specifying the inputs to be signed by the wallet is required");
|
|
1310
|
+
try {
|
|
1311
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1312
|
+
const response = await provider.signTransaction(request$1);
|
|
1313
|
+
options.onFinish?.(response);
|
|
1314
|
+
} catch (error) {
|
|
1315
|
+
console.error("[Connect] Error during sign transaction request", error);
|
|
1316
|
+
options.onCancel?.();
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region src/transactions/signMultipleTransactions.ts
|
|
1322
|
+
const signMultipleTransactions = async (options) => {
|
|
1323
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1324
|
+
const { psbts } = options.payload;
|
|
1325
|
+
if (!psbts || !psbts.length) throw new Error("psbts array is required");
|
|
1326
|
+
if (psbts.length > 100) throw new Error("psbts array must contain less than 100 psbts");
|
|
1327
|
+
try {
|
|
1328
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1329
|
+
const response = await provider.signMultipleTransactions(request$1);
|
|
1330
|
+
options.onFinish?.(response);
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
console.error("[Connect] Error during sign Multiple transactions request", error);
|
|
1333
|
+
options.onCancel?.();
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
//#endregion
|
|
1338
|
+
exports.AddressPurpose = AddressPurpose;
|
|
1339
|
+
exports.AddressType = AddressType;
|
|
1340
|
+
exports.BaseAdapter = BaseAdapter;
|
|
1341
|
+
exports.BitcoinNetworkType = BitcoinNetworkType;
|
|
1342
|
+
exports.DefaultAdaptersInfo = DefaultAdaptersInfo;
|
|
1343
|
+
exports.MessageSigningProtocols = MessageSigningProtocols;
|
|
1344
|
+
exports.ProviderPlatform = ProviderPlatform;
|
|
1345
|
+
exports.RpcErrorCode = RpcErrorCode;
|
|
1346
|
+
exports.RpcIdSchema = RpcIdSchema;
|
|
1347
|
+
exports.SatsConnectAdapter = SatsConnectAdapter;
|
|
1348
|
+
exports.SparkNetworkType = SparkNetworkType;
|
|
1349
|
+
exports.StacksNetworkType = StacksNetworkType;
|
|
1350
|
+
exports.StarknetNetworkType = StarknetNetworkType;
|
|
1351
|
+
exports.accountChangeEventName = accountChangeEventName;
|
|
1352
|
+
exports.accountChangeSchema = accountChangeSchema;
|
|
1353
|
+
exports.addListener = addListener;
|
|
1354
|
+
exports.addressSchema = addressSchema;
|
|
1355
|
+
exports.createInscription = createInscription;
|
|
1356
|
+
exports.createRepeatInscriptions = createRepeatInscriptions;
|
|
1357
|
+
exports.defaultAdapters = defaultAdapters;
|
|
1358
|
+
exports.disconnectEventName = disconnectEventName;
|
|
1359
|
+
exports.disconnectSchema = disconnectSchema;
|
|
1360
|
+
exports.getAddress = getAddress;
|
|
1361
|
+
exports.getCapabilities = getCapabilities;
|
|
1362
|
+
exports.getDefaultProvider = getDefaultProvider;
|
|
1363
|
+
exports.getProviderById = getProviderById;
|
|
1364
|
+
exports.getProviderOrThrow = getProviderOrThrow;
|
|
1365
|
+
exports.getProviders = getProviders;
|
|
1366
|
+
exports.getSupportedWallets = getSupportedWallets;
|
|
1367
|
+
exports.isProviderInstalled = isProviderInstalled;
|
|
1368
|
+
exports.networkChangeEventName = networkChangeEventName;
|
|
1369
|
+
exports.networkChangeEventNameV2 = networkChangeEventNameV2;
|
|
1370
|
+
exports.networkChangeSchema = networkChangeSchema;
|
|
1371
|
+
exports.networkChangeV2Schema = networkChangeV2Schema;
|
|
1372
|
+
exports.removeDefaultProvider = removeDefaultProvider;
|
|
1373
|
+
exports.request = request;
|
|
1374
|
+
exports.rpcErrorResponseMessageSchema = rpcErrorResponseMessageSchema;
|
|
1375
|
+
exports.rpcRequestMessageSchema = rpcRequestMessageSchema;
|
|
1376
|
+
exports.rpcResponseMessageSchema = rpcResponseMessageSchema;
|
|
1377
|
+
exports.rpcSuccessResponseMessageSchema = rpcSuccessResponseMessageSchema;
|
|
1378
|
+
exports.sendBtcTransaction = sendBtcTransaction;
|
|
1379
|
+
exports.setDefaultProvider = setDefaultProvider;
|
|
1380
|
+
exports.signMessage = signMessage;
|
|
1381
|
+
exports.signMultipleTransactions = signMultipleTransactions;
|
|
1382
|
+
exports.signTransaction = signTransaction;
|
|
1383
|
+
exports.walletEventSchema = walletEventSchema;
|