@sats-connect/core 0.9.0 → 0.10.0-833738d
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 +2357 -0
- package/dist/index.d.cts +3915 -0
- package/dist/index.d.ts +3036 -1682
- package/dist/index.js +1962 -2938
- package/package.json +9 -8
- package/dist/index.d.mts +0 -2561
- package/dist/index.mjs +0 -2821
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2357 @@
|
|
|
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") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let valibot = require("valibot");
|
|
25
|
+
valibot = __toESM(valibot);
|
|
26
|
+
let jsontokens = require("jsontokens");
|
|
27
|
+
jsontokens = __toESM(jsontokens);
|
|
28
|
+
let axios = require("axios");
|
|
29
|
+
axios = __toESM(axios);
|
|
30
|
+
let bitcoin_address_validation = require("bitcoin-address-validation");
|
|
31
|
+
bitcoin_address_validation = __toESM(bitcoin_address_validation);
|
|
32
|
+
let buffer = require("buffer");
|
|
33
|
+
buffer = __toESM(buffer);
|
|
34
|
+
|
|
35
|
+
//#region src/request/types/common.ts
|
|
36
|
+
const walletTypes = [
|
|
37
|
+
"software",
|
|
38
|
+
"ledger",
|
|
39
|
+
"keystone"
|
|
40
|
+
];
|
|
41
|
+
const walletTypeSchema = valibot.picklist(walletTypes);
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/addresses/types.ts
|
|
45
|
+
let AddressPurpose = /* @__PURE__ */ function(AddressPurpose$1) {
|
|
46
|
+
AddressPurpose$1["Ordinals"] = "ordinals";
|
|
47
|
+
AddressPurpose$1["Payment"] = "payment";
|
|
48
|
+
AddressPurpose$1["Stacks"] = "stacks";
|
|
49
|
+
AddressPurpose$1["Starknet"] = "starknet";
|
|
50
|
+
AddressPurpose$1["Spark"] = "spark";
|
|
51
|
+
return AddressPurpose$1;
|
|
52
|
+
}({});
|
|
53
|
+
let AddressType = /* @__PURE__ */ function(AddressType$2) {
|
|
54
|
+
AddressType$2["p2pkh"] = "p2pkh";
|
|
55
|
+
AddressType$2["p2sh"] = "p2sh";
|
|
56
|
+
AddressType$2["p2wpkh"] = "p2wpkh";
|
|
57
|
+
AddressType$2["p2wsh"] = "p2wsh";
|
|
58
|
+
AddressType$2["p2tr"] = "p2tr";
|
|
59
|
+
AddressType$2["stacks"] = "stacks";
|
|
60
|
+
AddressType$2["starknet"] = "starknet";
|
|
61
|
+
AddressType$2["spark"] = "spark";
|
|
62
|
+
return AddressType$2;
|
|
63
|
+
}({});
|
|
64
|
+
const addressSchema = valibot.object({
|
|
65
|
+
address: valibot.string(),
|
|
66
|
+
publicKey: valibot.string(),
|
|
67
|
+
purpose: valibot.enum(AddressPurpose),
|
|
68
|
+
addressType: valibot.enum(AddressType),
|
|
69
|
+
walletType: walletTypeSchema
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/addresses/index.ts
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Use `request()` instead
|
|
76
|
+
*/
|
|
77
|
+
const getAddress = async (options) => {
|
|
78
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
79
|
+
const { purposes } = options.payload;
|
|
80
|
+
if (!purposes) throw new Error("Address purposes are required");
|
|
81
|
+
try {
|
|
82
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
83
|
+
const response = await provider.connect(request$1);
|
|
84
|
+
options.onFinish?.(response);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error("[Connect] Error during address request", error);
|
|
87
|
+
options.onCancel?.();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/request/types/walletMethods/utils.ts
|
|
93
|
+
const commonNetworkSchema = valibot.object({
|
|
94
|
+
id: valibot.string(),
|
|
95
|
+
name: valibot.string(),
|
|
96
|
+
mode: valibot.picklist([]),
|
|
97
|
+
blockExplorerUrl: valibot.optional(valibot.pipe(valibot.string(), valibot.url()))
|
|
98
|
+
});
|
|
99
|
+
const bitcoinChainModeSchema = valibot.picklist([
|
|
100
|
+
"mainnet",
|
|
101
|
+
"testnet",
|
|
102
|
+
"testnet4",
|
|
103
|
+
"signet",
|
|
104
|
+
"regtest"
|
|
105
|
+
]);
|
|
106
|
+
const bitcoinNetworkSchema = valibot.object({
|
|
107
|
+
chain: valibot.literal("bitcoin"),
|
|
108
|
+
...commonNetworkSchema.entries,
|
|
109
|
+
mode: bitcoinChainModeSchema,
|
|
110
|
+
xverseApiUrl: valibot.string(),
|
|
111
|
+
electrsApiUrl: valibot.string()
|
|
112
|
+
});
|
|
113
|
+
const sparkChainModeSchema = valibot.picklist(["mainnet", "regtest"]);
|
|
114
|
+
const sparkNetworkSchema = valibot.object({
|
|
115
|
+
chain: valibot.literal("spark"),
|
|
116
|
+
...commonNetworkSchema.entries,
|
|
117
|
+
mode: sparkChainModeSchema,
|
|
118
|
+
electrsApiUrl: valibot.string()
|
|
119
|
+
});
|
|
120
|
+
const stacksChainModeSchema = valibot.picklist([
|
|
121
|
+
"mainnet",
|
|
122
|
+
"testnet",
|
|
123
|
+
"devnet",
|
|
124
|
+
"mocknet"
|
|
125
|
+
]);
|
|
126
|
+
const stacksNetworkSchema = valibot.object({
|
|
127
|
+
chain: valibot.literal("stacks"),
|
|
128
|
+
...commonNetworkSchema.entries,
|
|
129
|
+
mode: stacksChainModeSchema,
|
|
130
|
+
stacksApiUrl: valibot.string(),
|
|
131
|
+
xverseApiUrl: valibot.string()
|
|
132
|
+
});
|
|
133
|
+
const starknetChainModeSchema = valibot.picklist(["mainnet", "sepolia"]);
|
|
134
|
+
const starknetNetworkSchema = valibot.object({
|
|
135
|
+
chain: valibot.literal("starknet"),
|
|
136
|
+
...commonNetworkSchema.entries,
|
|
137
|
+
mode: starknetChainModeSchema,
|
|
138
|
+
rpcApiUrl: valibot.string(),
|
|
139
|
+
xverseApiUrl: valibot.string()
|
|
140
|
+
});
|
|
141
|
+
const networkSchema = valibot.variant("chain", [
|
|
142
|
+
bitcoinNetworkSchema,
|
|
143
|
+
sparkNetworkSchema,
|
|
144
|
+
stacksNetworkSchema,
|
|
145
|
+
starknetNetworkSchema
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/provider/types.ts
|
|
150
|
+
const accountChangeEventName = "accountChange";
|
|
151
|
+
const accountChangeSchema = valibot.object({
|
|
152
|
+
type: valibot.literal(accountChangeEventName),
|
|
153
|
+
addresses: valibot.optional(valibot.array(addressSchema))
|
|
154
|
+
});
|
|
155
|
+
const networkChangeEventName = "networkChange";
|
|
156
|
+
const networkChangeSchema = valibot.object({
|
|
157
|
+
type: valibot.literal(networkChangeEventName),
|
|
158
|
+
networks: valibot.object({
|
|
159
|
+
bitcoin: bitcoinNetworkSchema,
|
|
160
|
+
spark: sparkNetworkSchema,
|
|
161
|
+
stacks: stacksNetworkSchema,
|
|
162
|
+
starknet: starknetNetworkSchema
|
|
163
|
+
}),
|
|
164
|
+
addresses: valibot.optional(valibot.array(addressSchema))
|
|
165
|
+
});
|
|
166
|
+
const disconnectEventName = "disconnect";
|
|
167
|
+
const disconnectSchema = valibot.object({ type: valibot.literal(disconnectEventName) });
|
|
168
|
+
const walletEventSchema = valibot.variant("type", [
|
|
169
|
+
accountChangeSchema,
|
|
170
|
+
networkChangeSchema,
|
|
171
|
+
disconnectSchema
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/provider/index.ts
|
|
176
|
+
async function getProviderOrThrow(getProvider) {
|
|
177
|
+
const provider = await getProvider?.() || window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
178
|
+
if (!provider) throw new Error("No Bitcoin wallet installed");
|
|
179
|
+
return provider;
|
|
180
|
+
}
|
|
181
|
+
function getProviders() {
|
|
182
|
+
if (!window.btc_providers) window.btc_providers = [];
|
|
183
|
+
return window.btc_providers;
|
|
184
|
+
}
|
|
185
|
+
function getProviderById(providerId) {
|
|
186
|
+
return providerId?.split(".").reduce((acc, part) => acc?.[part], window);
|
|
187
|
+
}
|
|
188
|
+
function isProviderInstalled(providerId) {
|
|
189
|
+
return !!getProviderById(providerId);
|
|
190
|
+
}
|
|
191
|
+
function setDefaultProvider(providerId) {
|
|
192
|
+
localStorage.setItem("sats-connect_defaultProvider", providerId);
|
|
193
|
+
}
|
|
194
|
+
function getDefaultProvider() {
|
|
195
|
+
return localStorage.getItem("sats-connect_defaultProvider");
|
|
196
|
+
}
|
|
197
|
+
function removeDefaultProvider() {
|
|
198
|
+
localStorage.removeItem("sats-connect_defaultProvider");
|
|
199
|
+
}
|
|
200
|
+
function getSupportedWallets() {
|
|
201
|
+
return Object.values(DefaultAdaptersInfo).map((provider) => {
|
|
202
|
+
return {
|
|
203
|
+
...provider,
|
|
204
|
+
isInstalled: isProviderInstalled(provider.id)
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/types.ts
|
|
211
|
+
let BitcoinNetworkType = /* @__PURE__ */ function(BitcoinNetworkType$1) {
|
|
212
|
+
BitcoinNetworkType$1["Mainnet"] = "Mainnet";
|
|
213
|
+
BitcoinNetworkType$1["Testnet"] = "Testnet";
|
|
214
|
+
BitcoinNetworkType$1["Testnet4"] = "Testnet4";
|
|
215
|
+
BitcoinNetworkType$1["Signet"] = "Signet";
|
|
216
|
+
BitcoinNetworkType$1["Regtest"] = "Regtest";
|
|
217
|
+
return BitcoinNetworkType$1;
|
|
218
|
+
}({});
|
|
219
|
+
let StacksNetworkType = /* @__PURE__ */ function(StacksNetworkType$1) {
|
|
220
|
+
StacksNetworkType$1["Mainnet"] = "mainnet";
|
|
221
|
+
StacksNetworkType$1["Testnet"] = "testnet";
|
|
222
|
+
return StacksNetworkType$1;
|
|
223
|
+
}({});
|
|
224
|
+
let StarknetNetworkType = /* @__PURE__ */ function(StarknetNetworkType$1) {
|
|
225
|
+
StarknetNetworkType$1["Mainnet"] = "mainnet";
|
|
226
|
+
StarknetNetworkType$1["Sepolia"] = "sepolia";
|
|
227
|
+
return StarknetNetworkType$1;
|
|
228
|
+
}({});
|
|
229
|
+
let SparkNetworkType = /* @__PURE__ */ function(SparkNetworkType$1) {
|
|
230
|
+
SparkNetworkType$1["Mainnet"] = "mainnet";
|
|
231
|
+
SparkNetworkType$1["Regtest"] = "regtest";
|
|
232
|
+
return SparkNetworkType$1;
|
|
233
|
+
}({});
|
|
234
|
+
const RpcIdSchema = valibot.optional(valibot.union([
|
|
235
|
+
valibot.string(),
|
|
236
|
+
valibot.number(),
|
|
237
|
+
valibot.null()
|
|
238
|
+
]));
|
|
239
|
+
const rpcRequestMessageSchema = valibot.object({
|
|
240
|
+
jsonrpc: valibot.literal("2.0"),
|
|
241
|
+
method: valibot.string(),
|
|
242
|
+
params: valibot.optional(valibot.union([
|
|
243
|
+
valibot.array(valibot.unknown()),
|
|
244
|
+
valibot.looseObject({}),
|
|
245
|
+
valibot.null()
|
|
246
|
+
])),
|
|
247
|
+
id: valibot.unwrap(RpcIdSchema)
|
|
248
|
+
});
|
|
249
|
+
/**
|
|
250
|
+
* @enum {number} RpcErrorCode
|
|
251
|
+
* @description JSON-RPC error codes
|
|
252
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
253
|
+
*/
|
|
254
|
+
let RpcErrorCode = /* @__PURE__ */ function(RpcErrorCode$1) {
|
|
255
|
+
/**
|
|
256
|
+
* Parse error Invalid JSON
|
|
257
|
+
**/
|
|
258
|
+
RpcErrorCode$1[RpcErrorCode$1["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
259
|
+
/**
|
|
260
|
+
* The JSON sent is not a valid Request object.
|
|
261
|
+
**/
|
|
262
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
263
|
+
/**
|
|
264
|
+
* The method does not exist/is not available.
|
|
265
|
+
**/
|
|
266
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
267
|
+
/**
|
|
268
|
+
* Invalid method parameter(s).
|
|
269
|
+
*/
|
|
270
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
271
|
+
/**
|
|
272
|
+
* Internal JSON-RPC error.
|
|
273
|
+
* This is a generic error, used when the server encounters an error in performing the request.
|
|
274
|
+
**/
|
|
275
|
+
RpcErrorCode$1[RpcErrorCode$1["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
276
|
+
/**
|
|
277
|
+
* user rejected/canceled the request
|
|
278
|
+
*/
|
|
279
|
+
RpcErrorCode$1[RpcErrorCode$1["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
280
|
+
/**
|
|
281
|
+
* method is not supported for the address provided
|
|
282
|
+
*/
|
|
283
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
284
|
+
/**
|
|
285
|
+
* The client does not have permission to access the requested resource.
|
|
286
|
+
*/
|
|
287
|
+
RpcErrorCode$1[RpcErrorCode$1["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
288
|
+
return RpcErrorCode$1;
|
|
289
|
+
}({});
|
|
290
|
+
const rpcSuccessResponseMessageSchema = valibot.object({
|
|
291
|
+
jsonrpc: valibot.literal("2.0"),
|
|
292
|
+
result: valibot.nonOptional(valibot.unknown()),
|
|
293
|
+
id: RpcIdSchema
|
|
294
|
+
});
|
|
295
|
+
const rpcErrorResponseMessageSchema = valibot.object({
|
|
296
|
+
jsonrpc: valibot.literal("2.0"),
|
|
297
|
+
error: valibot.nonOptional(valibot.unknown()),
|
|
298
|
+
id: RpcIdSchema
|
|
299
|
+
});
|
|
300
|
+
const rpcResponseMessageSchema = valibot.union([rpcSuccessResponseMessageSchema, rpcErrorResponseMessageSchema]);
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/request/sanitizeRequest.ts
|
|
304
|
+
const sanitizeRequest = (method, params, providerInfo) => {
|
|
305
|
+
try {
|
|
306
|
+
const [major, minor, patch] = providerInfo.version.split(".").map((part) => parseInt(part, 10));
|
|
307
|
+
const platform = providerInfo.platform;
|
|
308
|
+
if (!platform || platform === ProviderPlatform.Web && major <= 1 && minor <= 4 || platform === ProviderPlatform.Mobile && major <= 1 && minor <= 54) {
|
|
309
|
+
const v1Sanitized = sanitizeAddressPurposeRequest(method, params);
|
|
310
|
+
method = v1Sanitized.method;
|
|
311
|
+
params = v1Sanitized.params;
|
|
312
|
+
}
|
|
313
|
+
} catch {}
|
|
314
|
+
return {
|
|
315
|
+
method,
|
|
316
|
+
params
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
const sanitizeAddressPurposeRequest = (method, params) => {
|
|
320
|
+
const filterPurposes = (purposes) => purposes?.filter((purpose) => purpose !== AddressPurpose.Spark && purpose !== AddressPurpose.Starknet);
|
|
321
|
+
if (method === "wallet_connect") {
|
|
322
|
+
const typedParams = params;
|
|
323
|
+
if (!typedParams) return {
|
|
324
|
+
method,
|
|
325
|
+
params
|
|
326
|
+
};
|
|
327
|
+
const { addresses,...rest } = typedParams;
|
|
328
|
+
return {
|
|
329
|
+
method,
|
|
330
|
+
params: {
|
|
331
|
+
...rest,
|
|
332
|
+
addresses: filterPurposes(addresses)
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (method === "getAccounts") {
|
|
337
|
+
const { purposes,...rest } = params;
|
|
338
|
+
return {
|
|
339
|
+
method,
|
|
340
|
+
params: {
|
|
341
|
+
...rest,
|
|
342
|
+
purposes: filterPurposes(purposes)
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (method === "getAddresses") {
|
|
347
|
+
const { purposes,...rest } = params;
|
|
348
|
+
return {
|
|
349
|
+
method,
|
|
350
|
+
params: {
|
|
351
|
+
...rest,
|
|
352
|
+
purposes: filterPurposes(purposes)
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
method,
|
|
358
|
+
params
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/request/types/btcMethods.ts
|
|
364
|
+
let ProviderPlatform = /* @__PURE__ */ function(ProviderPlatform$1) {
|
|
365
|
+
ProviderPlatform$1["Web"] = "web";
|
|
366
|
+
ProviderPlatform$1["Mobile"] = "mobile";
|
|
367
|
+
return ProviderPlatform$1;
|
|
368
|
+
}({});
|
|
369
|
+
const getInfoMethodName = "getInfo";
|
|
370
|
+
const getInfoParamsSchema = valibot.nullish(valibot.null());
|
|
371
|
+
const getInfoResultSchema = valibot.object({
|
|
372
|
+
version: valibot.string(),
|
|
373
|
+
platform: valibot.optional(valibot.enum(ProviderPlatform)),
|
|
374
|
+
methods: valibot.optional(valibot.array(valibot.string())),
|
|
375
|
+
supports: valibot.array(valibot.string())
|
|
376
|
+
});
|
|
377
|
+
const getInfoRequestMessageSchema = valibot.object({
|
|
378
|
+
...rpcRequestMessageSchema.entries,
|
|
379
|
+
...valibot.object({
|
|
380
|
+
method: valibot.literal(getInfoMethodName),
|
|
381
|
+
params: getInfoParamsSchema,
|
|
382
|
+
id: valibot.string()
|
|
383
|
+
}).entries
|
|
384
|
+
});
|
|
385
|
+
const getAddressesMethodName = "getAddresses";
|
|
386
|
+
const getAddressesParamsSchema = valibot.object({
|
|
387
|
+
purposes: valibot.array(valibot.enum(AddressPurpose)),
|
|
388
|
+
message: valibot.optional(valibot.string())
|
|
389
|
+
});
|
|
390
|
+
const getAddressesResultSchema = valibot.object({
|
|
391
|
+
addresses: valibot.array(addressSchema),
|
|
392
|
+
network: bitcoinNetworkSchema
|
|
393
|
+
});
|
|
394
|
+
const getAddressesRequestMessageSchema = valibot.object({
|
|
395
|
+
...rpcRequestMessageSchema.entries,
|
|
396
|
+
...valibot.object({
|
|
397
|
+
method: valibot.literal(getAddressesMethodName),
|
|
398
|
+
params: getAddressesParamsSchema,
|
|
399
|
+
id: valibot.string()
|
|
400
|
+
}).entries
|
|
401
|
+
});
|
|
402
|
+
const signMessageMethodName = "signMessage";
|
|
403
|
+
let MessageSigningProtocols = /* @__PURE__ */ function(MessageSigningProtocols$1) {
|
|
404
|
+
MessageSigningProtocols$1["ECDSA"] = "ECDSA";
|
|
405
|
+
MessageSigningProtocols$1["BIP322"] = "BIP322";
|
|
406
|
+
return MessageSigningProtocols$1;
|
|
407
|
+
}({});
|
|
408
|
+
const signMessageParamsSchema = valibot.object({
|
|
409
|
+
address: valibot.string(),
|
|
410
|
+
message: valibot.string(),
|
|
411
|
+
protocol: valibot.optional(valibot.enum(MessageSigningProtocols))
|
|
412
|
+
});
|
|
413
|
+
const signMessageResultSchema = valibot.object({
|
|
414
|
+
signature: valibot.string(),
|
|
415
|
+
messageHash: valibot.string(),
|
|
416
|
+
address: valibot.string(),
|
|
417
|
+
protocol: valibot.enum(MessageSigningProtocols)
|
|
418
|
+
});
|
|
419
|
+
const signMessageRequestMessageSchema = valibot.object({
|
|
420
|
+
...rpcRequestMessageSchema.entries,
|
|
421
|
+
...valibot.object({
|
|
422
|
+
method: valibot.literal(signMessageMethodName),
|
|
423
|
+
params: signMessageParamsSchema,
|
|
424
|
+
id: valibot.string()
|
|
425
|
+
}).entries
|
|
426
|
+
});
|
|
427
|
+
const sendTransferMethodName = "sendTransfer";
|
|
428
|
+
const sendTransferParamsSchema = valibot.object({ recipients: valibot.array(valibot.object({
|
|
429
|
+
address: valibot.string(),
|
|
430
|
+
amount: valibot.number()
|
|
431
|
+
})) });
|
|
432
|
+
const sendTransferResultSchema = valibot.object({ txid: valibot.string() });
|
|
433
|
+
const sendTransferRequestMessageSchema = valibot.object({
|
|
434
|
+
...rpcRequestMessageSchema.entries,
|
|
435
|
+
...valibot.object({
|
|
436
|
+
method: valibot.literal(sendTransferMethodName),
|
|
437
|
+
params: sendTransferParamsSchema,
|
|
438
|
+
id: valibot.string()
|
|
439
|
+
}).entries
|
|
440
|
+
});
|
|
441
|
+
const signPsbtMethodName = "signPsbt";
|
|
442
|
+
const signPsbtParamsSchema = valibot.object({
|
|
443
|
+
psbt: valibot.string(),
|
|
444
|
+
signInputs: valibot.optional(valibot.record(valibot.string(), valibot.array(valibot.number()))),
|
|
445
|
+
broadcast: valibot.optional(valibot.boolean())
|
|
446
|
+
});
|
|
447
|
+
const signPsbtResultSchema = valibot.object({
|
|
448
|
+
psbt: valibot.string(),
|
|
449
|
+
txid: valibot.optional(valibot.string())
|
|
450
|
+
});
|
|
451
|
+
const signPsbtRequestMessageSchema = valibot.object({
|
|
452
|
+
...rpcRequestMessageSchema.entries,
|
|
453
|
+
...valibot.object({
|
|
454
|
+
method: valibot.literal(signPsbtMethodName),
|
|
455
|
+
params: signPsbtParamsSchema,
|
|
456
|
+
id: valibot.string()
|
|
457
|
+
}).entries
|
|
458
|
+
});
|
|
459
|
+
const getAccountsMethodName = "getAccounts";
|
|
460
|
+
const getAccountsParamsSchema = valibot.object({
|
|
461
|
+
purposes: valibot.array(valibot.enum(AddressPurpose)),
|
|
462
|
+
message: valibot.optional(valibot.string())
|
|
463
|
+
});
|
|
464
|
+
const getAccountsResultSchema = valibot.array(valibot.object({
|
|
465
|
+
...addressSchema.entries,
|
|
466
|
+
...valibot.object({ walletType: walletTypeSchema }).entries
|
|
467
|
+
}));
|
|
468
|
+
const getAccountsRequestMessageSchema = valibot.object({
|
|
469
|
+
...rpcRequestMessageSchema.entries,
|
|
470
|
+
...valibot.object({
|
|
471
|
+
method: valibot.literal(getAccountsMethodName),
|
|
472
|
+
params: getAccountsParamsSchema,
|
|
473
|
+
id: valibot.string()
|
|
474
|
+
}).entries
|
|
475
|
+
});
|
|
476
|
+
const getBalanceMethodName = "getBalance";
|
|
477
|
+
const getBalanceParamsSchema = valibot.nullish(valibot.null());
|
|
478
|
+
const getBalanceResultSchema = valibot.object({
|
|
479
|
+
confirmed: valibot.string(),
|
|
480
|
+
unconfirmed: valibot.string(),
|
|
481
|
+
total: valibot.string()
|
|
482
|
+
});
|
|
483
|
+
const getBalanceRequestMessageSchema = valibot.object({
|
|
484
|
+
...rpcRequestMessageSchema.entries,
|
|
485
|
+
...valibot.object({
|
|
486
|
+
method: valibot.literal(getBalanceMethodName),
|
|
487
|
+
id: valibot.string()
|
|
488
|
+
}).entries
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/request/types/ordinalsMethods.ts
|
|
493
|
+
const getInscriptionsMethodName = "ord_getInscriptions";
|
|
494
|
+
const getInscriptionsParamsSchema = valibot.object({
|
|
495
|
+
offset: valibot.number(),
|
|
496
|
+
limit: valibot.number()
|
|
497
|
+
});
|
|
498
|
+
const getInscriptionsResultSchema = valibot.object({
|
|
499
|
+
total: valibot.number(),
|
|
500
|
+
limit: valibot.number(),
|
|
501
|
+
offset: valibot.number(),
|
|
502
|
+
inscriptions: valibot.array(valibot.object({
|
|
503
|
+
inscriptionId: valibot.string(),
|
|
504
|
+
inscriptionNumber: valibot.string(),
|
|
505
|
+
address: valibot.string(),
|
|
506
|
+
collectionName: valibot.optional(valibot.string()),
|
|
507
|
+
postage: valibot.string(),
|
|
508
|
+
contentLength: valibot.string(),
|
|
509
|
+
contentType: valibot.string(),
|
|
510
|
+
timestamp: valibot.number(),
|
|
511
|
+
offset: valibot.number(),
|
|
512
|
+
genesisTransaction: valibot.string(),
|
|
513
|
+
output: valibot.string()
|
|
514
|
+
}))
|
|
515
|
+
});
|
|
516
|
+
const getInscriptionsRequestMessageSchema = valibot.object({
|
|
517
|
+
...rpcRequestMessageSchema.entries,
|
|
518
|
+
...valibot.object({
|
|
519
|
+
method: valibot.literal(getInscriptionsMethodName),
|
|
520
|
+
params: getInscriptionsParamsSchema,
|
|
521
|
+
id: valibot.string()
|
|
522
|
+
}).entries
|
|
523
|
+
});
|
|
524
|
+
const sendInscriptionsMethodName = "ord_sendInscriptions";
|
|
525
|
+
const sendInscriptionsParamsSchema = valibot.object({ transfers: valibot.array(valibot.object({
|
|
526
|
+
address: valibot.string(),
|
|
527
|
+
inscriptionId: valibot.string()
|
|
528
|
+
})) });
|
|
529
|
+
const sendInscriptionsResultSchema = valibot.object({ txid: valibot.string() });
|
|
530
|
+
const sendInscriptionsRequestMessageSchema = valibot.object({
|
|
531
|
+
...rpcRequestMessageSchema.entries,
|
|
532
|
+
...valibot.object({
|
|
533
|
+
method: valibot.literal(sendInscriptionsMethodName),
|
|
534
|
+
params: sendInscriptionsParamsSchema,
|
|
535
|
+
id: valibot.string()
|
|
536
|
+
}).entries
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/request/types/runesMethods/etch.ts
|
|
541
|
+
const runesEtchMethodName = "runes_etch";
|
|
542
|
+
const etchTermsSchema = valibot.object({
|
|
543
|
+
amount: valibot.string(),
|
|
544
|
+
cap: valibot.string(),
|
|
545
|
+
heightStart: valibot.optional(valibot.string()),
|
|
546
|
+
heightEnd: valibot.optional(valibot.string()),
|
|
547
|
+
offsetStart: valibot.optional(valibot.string()),
|
|
548
|
+
offsetEnd: valibot.optional(valibot.string())
|
|
549
|
+
});
|
|
550
|
+
const inscriptionDetailsSchema = valibot.object({
|
|
551
|
+
contentType: valibot.string(),
|
|
552
|
+
contentBase64: valibot.string()
|
|
553
|
+
});
|
|
554
|
+
const runesEtchParamsSchema = valibot.object({
|
|
555
|
+
runeName: valibot.string(),
|
|
556
|
+
divisibility: valibot.optional(valibot.number()),
|
|
557
|
+
symbol: valibot.optional(valibot.string()),
|
|
558
|
+
premine: valibot.optional(valibot.string()),
|
|
559
|
+
isMintable: valibot.boolean(),
|
|
560
|
+
delegateInscriptionId: valibot.optional(valibot.string()),
|
|
561
|
+
destinationAddress: valibot.string(),
|
|
562
|
+
refundAddress: valibot.string(),
|
|
563
|
+
feeRate: valibot.number(),
|
|
564
|
+
appServiceFee: valibot.optional(valibot.number()),
|
|
565
|
+
appServiceFeeAddress: valibot.optional(valibot.string()),
|
|
566
|
+
terms: valibot.optional(etchTermsSchema),
|
|
567
|
+
inscriptionDetails: valibot.optional(inscriptionDetailsSchema),
|
|
568
|
+
network: valibot.optional(valibot.enum(BitcoinNetworkType))
|
|
569
|
+
});
|
|
570
|
+
const runesEtchResultSchema = valibot.object({
|
|
571
|
+
orderId: valibot.string(),
|
|
572
|
+
fundTransactionId: valibot.string(),
|
|
573
|
+
fundingAddress: valibot.string()
|
|
574
|
+
});
|
|
575
|
+
const runesEtchRequestMessageSchema = valibot.object({
|
|
576
|
+
...rpcRequestMessageSchema.entries,
|
|
577
|
+
...valibot.object({
|
|
578
|
+
method: valibot.literal(runesEtchMethodName),
|
|
579
|
+
params: runesEtchParamsSchema,
|
|
580
|
+
id: valibot.string()
|
|
581
|
+
}).entries
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region src/request/types/runesMethods/getBalance.ts
|
|
586
|
+
const runesGetBalanceMethodName = "runes_getBalance";
|
|
587
|
+
const runesGetBalanceParamsSchema = valibot.nullish(valibot.null());
|
|
588
|
+
const runesGetBalanceResultSchema = valibot.object({ balances: valibot.array(valibot.object({
|
|
589
|
+
runeName: valibot.string(),
|
|
590
|
+
amount: valibot.string(),
|
|
591
|
+
divisibility: valibot.number(),
|
|
592
|
+
symbol: valibot.string(),
|
|
593
|
+
inscriptionId: valibot.nullish(valibot.string()),
|
|
594
|
+
spendableBalance: valibot.string()
|
|
595
|
+
})) });
|
|
596
|
+
const runesGetBalanceRequestMessageSchema = valibot.object({
|
|
597
|
+
...rpcRequestMessageSchema.entries,
|
|
598
|
+
...valibot.object({
|
|
599
|
+
method: valibot.literal(runesGetBalanceMethodName),
|
|
600
|
+
params: runesGetBalanceParamsSchema,
|
|
601
|
+
id: valibot.string()
|
|
602
|
+
}).entries
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/request/types/runesMethods/mint.ts
|
|
607
|
+
const runesMintMethodName = "runes_mint";
|
|
608
|
+
const runesMintParamsSchema = valibot.object({
|
|
609
|
+
appServiceFee: valibot.optional(valibot.number()),
|
|
610
|
+
appServiceFeeAddress: valibot.optional(valibot.string()),
|
|
611
|
+
destinationAddress: valibot.string(),
|
|
612
|
+
feeRate: valibot.number(),
|
|
613
|
+
refundAddress: valibot.string(),
|
|
614
|
+
repeats: valibot.number(),
|
|
615
|
+
runeName: valibot.string(),
|
|
616
|
+
network: valibot.optional(valibot.enum(BitcoinNetworkType))
|
|
617
|
+
});
|
|
618
|
+
const runesMintResultSchema = valibot.object({
|
|
619
|
+
orderId: valibot.string(),
|
|
620
|
+
fundTransactionId: valibot.string(),
|
|
621
|
+
fundingAddress: valibot.string()
|
|
622
|
+
});
|
|
623
|
+
const runesMintRequestMessageSchema = valibot.object({
|
|
624
|
+
...rpcRequestMessageSchema.entries,
|
|
625
|
+
...valibot.object({
|
|
626
|
+
method: valibot.literal(runesMintMethodName),
|
|
627
|
+
params: runesMintParamsSchema,
|
|
628
|
+
id: valibot.string()
|
|
629
|
+
}).entries
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/request/types/runesMethods/transfer.ts
|
|
634
|
+
const runesTransferMethodName = "runes_transfer";
|
|
635
|
+
const runesTransferParamsSchema = valibot.object({ recipients: valibot.array(valibot.object({
|
|
636
|
+
runeName: valibot.string(),
|
|
637
|
+
amount: valibot.string(),
|
|
638
|
+
address: valibot.string()
|
|
639
|
+
})) });
|
|
640
|
+
const runesTransferResultSchema = valibot.object({ txid: valibot.string() });
|
|
641
|
+
const runesTransferRequestMessageSchema = valibot.object({
|
|
642
|
+
...rpcRequestMessageSchema.entries,
|
|
643
|
+
...valibot.object({
|
|
644
|
+
method: valibot.literal(runesTransferMethodName),
|
|
645
|
+
params: runesTransferParamsSchema,
|
|
646
|
+
id: valibot.string()
|
|
647
|
+
}).entries
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/request/types/sparkMethods/flashnetMethods/getJwt.ts
|
|
652
|
+
const sparkFlashnetGetJwtMethodName = "spark_flashnet_getJwt";
|
|
653
|
+
const sparkFlashnetGetJwtParamsSchema = valibot.null();
|
|
654
|
+
const sparkFlashnetGetJwtResultSchema = valibot.object({ jwt: valibot.string() });
|
|
655
|
+
const sparkFlashnetGetJwtRequestMessageSchema = valibot.object({
|
|
656
|
+
...rpcRequestMessageSchema.entries,
|
|
657
|
+
...valibot.object({
|
|
658
|
+
method: valibot.literal(sparkFlashnetGetJwtMethodName),
|
|
659
|
+
params: sparkFlashnetGetJwtParamsSchema,
|
|
660
|
+
id: valibot.string()
|
|
661
|
+
}).entries
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
//#endregion
|
|
665
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/addLiquidity.ts
|
|
666
|
+
const sparkFlashnetAddLiquidityIntentSchema = valibot.object({
|
|
667
|
+
type: valibot.literal("addLiquidity"),
|
|
668
|
+
data: valibot.object({
|
|
669
|
+
userPublicKey: valibot.string(),
|
|
670
|
+
poolId: valibot.string(),
|
|
671
|
+
assetAAmount: valibot.string(),
|
|
672
|
+
assetBAmount: valibot.string(),
|
|
673
|
+
assetAMinAmountIn: valibot.string(),
|
|
674
|
+
assetBMinAmountIn: valibot.string(),
|
|
675
|
+
assetATransferId: valibot.string(),
|
|
676
|
+
assetBTransferId: valibot.string(),
|
|
677
|
+
nonce: valibot.string()
|
|
678
|
+
})
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/clawback.ts
|
|
683
|
+
const sparkFlashnetClawbackIntentSchema = valibot.object({
|
|
684
|
+
type: valibot.literal("clawback"),
|
|
685
|
+
data: valibot.object({
|
|
686
|
+
senderPublicKey: valibot.string(),
|
|
687
|
+
sparkTransferId: valibot.string(),
|
|
688
|
+
lpIdentityPublicKey: valibot.string(),
|
|
689
|
+
nonce: valibot.string()
|
|
690
|
+
})
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/confirmInitialDeposit.ts
|
|
695
|
+
const sparkFlashnetConfirmInitialDepositIntentSchema = valibot.object({
|
|
696
|
+
type: valibot.literal("confirmInitialDeposit"),
|
|
697
|
+
data: valibot.object({
|
|
698
|
+
poolId: valibot.string(),
|
|
699
|
+
assetASparkTransferId: valibot.string(),
|
|
700
|
+
poolOwnerPublicKey: valibot.string(),
|
|
701
|
+
nonce: valibot.string()
|
|
702
|
+
})
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/createConstantProductPool.ts
|
|
707
|
+
const sparkFlashnetCreateConstantProductPoolIntentSchema = valibot.object({
|
|
708
|
+
type: valibot.literal("createConstantProductPool"),
|
|
709
|
+
data: valibot.object({
|
|
710
|
+
poolOwnerPublicKey: valibot.string(),
|
|
711
|
+
assetAAddress: valibot.string(),
|
|
712
|
+
assetBAddress: valibot.string(),
|
|
713
|
+
lpFeeRateBps: valibot.union([valibot.number(), valibot.string()]),
|
|
714
|
+
totalHostFeeRateBps: valibot.union([valibot.number(), valibot.string()]),
|
|
715
|
+
nonce: valibot.string()
|
|
716
|
+
})
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/createSingleSidedPool.ts
|
|
721
|
+
const sparkFlashnetCreateSingleSidedPoolIntentSchema = valibot.object({
|
|
722
|
+
type: valibot.literal("createSingleSidedPool"),
|
|
723
|
+
data: valibot.object({
|
|
724
|
+
assetAAddress: valibot.string(),
|
|
725
|
+
assetBAddress: valibot.string(),
|
|
726
|
+
assetAInitialReserve: valibot.string(),
|
|
727
|
+
virtualReserveA: valibot.union([valibot.number(), valibot.string()]),
|
|
728
|
+
virtualReserveB: valibot.union([valibot.number(), valibot.string()]),
|
|
729
|
+
threshold: valibot.union([valibot.number(), valibot.string()]),
|
|
730
|
+
lpFeeRateBps: valibot.union([valibot.number(), valibot.string()]),
|
|
731
|
+
totalHostFeeRateBps: valibot.union([valibot.number(), valibot.string()]),
|
|
732
|
+
poolOwnerPublicKey: valibot.string(),
|
|
733
|
+
nonce: valibot.string()
|
|
734
|
+
})
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/removeLiquidity.ts
|
|
739
|
+
const sparkFlashnetRemoveLiquidityIntentSchema = valibot.object({
|
|
740
|
+
type: valibot.literal("removeLiquidity"),
|
|
741
|
+
data: valibot.object({
|
|
742
|
+
userPublicKey: valibot.string(),
|
|
743
|
+
poolId: valibot.string(),
|
|
744
|
+
lpTokensToRemove: valibot.string(),
|
|
745
|
+
nonce: valibot.string()
|
|
746
|
+
})
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/routeSwap.ts
|
|
751
|
+
const sparkFlashnetRouteSwapIntentSchema = valibot.object({
|
|
752
|
+
type: valibot.literal("executeRouteSwap"),
|
|
753
|
+
data: valibot.object({
|
|
754
|
+
userPublicKey: valibot.string(),
|
|
755
|
+
initialSparkTransferId: valibot.string(),
|
|
756
|
+
hops: valibot.array(valibot.object({
|
|
757
|
+
poolId: valibot.string(),
|
|
758
|
+
inputAssetAddress: valibot.string(),
|
|
759
|
+
outputAssetAddress: valibot.string(),
|
|
760
|
+
hopIntegratorFeeRateBps: valibot.optional(valibot.union([valibot.number(), valibot.string()]))
|
|
761
|
+
})),
|
|
762
|
+
inputAmount: valibot.string(),
|
|
763
|
+
maxRouteSlippageBps: valibot.union([valibot.number(), valibot.string()]),
|
|
764
|
+
minAmountOut: valibot.string(),
|
|
765
|
+
defaultIntegratorFeeRateBps: valibot.optional(valibot.union([valibot.number(), valibot.string()])),
|
|
766
|
+
nonce: valibot.string()
|
|
767
|
+
})
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/request/types/sparkMethods/flashnetMethods/intents/swap.ts
|
|
772
|
+
const sparkFlashnetSwapIntentSchema = valibot.object({
|
|
773
|
+
type: valibot.literal("executeSwap"),
|
|
774
|
+
data: valibot.object({
|
|
775
|
+
userPublicKey: valibot.string(),
|
|
776
|
+
poolId: valibot.string(),
|
|
777
|
+
transferId: valibot.string(),
|
|
778
|
+
assetInAddress: valibot.string(),
|
|
779
|
+
assetOutAddress: valibot.string(),
|
|
780
|
+
amountIn: valibot.string(),
|
|
781
|
+
maxSlippageBps: valibot.union([valibot.number(), valibot.string()]),
|
|
782
|
+
minAmountOut: valibot.string(),
|
|
783
|
+
totalIntegratorFeeRateBps: valibot.optional(valibot.union([valibot.number(), valibot.string()])),
|
|
784
|
+
nonce: valibot.string()
|
|
785
|
+
})
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region src/request/types/sparkMethods/flashnetMethods/signIntent.ts
|
|
790
|
+
const sparkFlashnetSignIntentMethodName = "spark_flashnet_signIntent";
|
|
791
|
+
const sparkFlashnetSignIntentParamsSchema = valibot.union([
|
|
792
|
+
sparkFlashnetSwapIntentSchema,
|
|
793
|
+
sparkFlashnetRouteSwapIntentSchema,
|
|
794
|
+
sparkFlashnetAddLiquidityIntentSchema,
|
|
795
|
+
sparkFlashnetClawbackIntentSchema,
|
|
796
|
+
sparkFlashnetConfirmInitialDepositIntentSchema,
|
|
797
|
+
sparkFlashnetCreateConstantProductPoolIntentSchema,
|
|
798
|
+
sparkFlashnetCreateSingleSidedPoolIntentSchema,
|
|
799
|
+
sparkFlashnetRemoveLiquidityIntentSchema
|
|
800
|
+
]);
|
|
801
|
+
const sparkFlashnetSignIntentResultSchema = valibot.object({ signature: valibot.string() });
|
|
802
|
+
const sparkFlashnetSignIntentRequestMessageSchema = valibot.object({
|
|
803
|
+
...rpcRequestMessageSchema.entries,
|
|
804
|
+
...valibot.object({
|
|
805
|
+
method: valibot.literal(sparkFlashnetSignIntentMethodName),
|
|
806
|
+
params: sparkFlashnetSignIntentParamsSchema,
|
|
807
|
+
id: valibot.string()
|
|
808
|
+
}).entries
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/request/types/sparkMethods/flashnetMethods/signStructuredMessage.ts
|
|
813
|
+
const sparkFlashnetSignStructuredMessageMethodName = "spark_flashnet_signStructuredMessage";
|
|
814
|
+
const sparkFlashnetSignStructuredMessageParamsSchema = valibot.object({ message: valibot.string() });
|
|
815
|
+
const sparkFlashnetSignStructuredMessageResultSchema = valibot.object({
|
|
816
|
+
message: valibot.string(),
|
|
817
|
+
signature: valibot.string()
|
|
818
|
+
});
|
|
819
|
+
const sparkFlashnetSignStructuredMessageRequestMessageSchema = valibot.object({
|
|
820
|
+
...rpcRequestMessageSchema.entries,
|
|
821
|
+
...valibot.object({
|
|
822
|
+
method: valibot.literal(sparkFlashnetSignStructuredMessageMethodName),
|
|
823
|
+
params: sparkFlashnetSignStructuredMessageParamsSchema,
|
|
824
|
+
id: valibot.string()
|
|
825
|
+
}).entries
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/request/types/sparkMethods/getAddresses.ts
|
|
830
|
+
const sparkGetAddressesMethodName = "spark_getAddresses";
|
|
831
|
+
const sparkGetAddressesParamsSchema = valibot.nullish(valibot.object({ message: valibot.optional(valibot.string()) }));
|
|
832
|
+
const sparkGetAddressesResultSchema = valibot.object({
|
|
833
|
+
addresses: valibot.array(addressSchema),
|
|
834
|
+
network: sparkNetworkSchema
|
|
835
|
+
});
|
|
836
|
+
const sparkGetAddressesRequestMessageSchema = valibot.object({
|
|
837
|
+
...rpcRequestMessageSchema.entries,
|
|
838
|
+
...valibot.object({
|
|
839
|
+
method: valibot.literal(sparkGetAddressesMethodName),
|
|
840
|
+
params: sparkGetAddressesParamsSchema,
|
|
841
|
+
id: valibot.string()
|
|
842
|
+
}).entries
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/request/types/sparkMethods/getBalance.ts
|
|
847
|
+
const sparkGetBalanceMethodName = "spark_getBalance";
|
|
848
|
+
const sparkGetBalanceParamsSchema = valibot.nullish(valibot.null());
|
|
849
|
+
const sparkGetBalanceResultSchema = valibot.object({
|
|
850
|
+
balance: valibot.string(),
|
|
851
|
+
tokenBalances: valibot.array(valibot.object({
|
|
852
|
+
balance: valibot.string(),
|
|
853
|
+
tokenMetadata: valibot.object({
|
|
854
|
+
tokenIdentifier: valibot.string(),
|
|
855
|
+
tokenName: valibot.string(),
|
|
856
|
+
tokenTicker: valibot.string(),
|
|
857
|
+
decimals: valibot.number(),
|
|
858
|
+
maxSupply: valibot.string()
|
|
859
|
+
})
|
|
860
|
+
}))
|
|
861
|
+
});
|
|
862
|
+
const sparkGetBalanceRequestMessageSchema = valibot.object({
|
|
863
|
+
...rpcRequestMessageSchema.entries,
|
|
864
|
+
...valibot.object({
|
|
865
|
+
method: valibot.literal(sparkGetBalanceMethodName),
|
|
866
|
+
params: sparkGetBalanceParamsSchema,
|
|
867
|
+
id: valibot.string()
|
|
868
|
+
}).entries
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/request/types/sparkMethods/signMessage.ts
|
|
873
|
+
const sparkSignMessageMethodName = "spark_signMessage";
|
|
874
|
+
const sparkSignMessageParamsSchema = valibot.object({ message: valibot.string() });
|
|
875
|
+
const sparkSignMessageResultSchema = valibot.object({ signature: valibot.string() });
|
|
876
|
+
const sparkSignMessageRequestMessageSchema = valibot.object({
|
|
877
|
+
...rpcRequestMessageSchema.entries,
|
|
878
|
+
...valibot.object({
|
|
879
|
+
method: valibot.literal(sparkSignMessageMethodName),
|
|
880
|
+
params: sparkSignMessageParamsSchema,
|
|
881
|
+
id: valibot.string()
|
|
882
|
+
}).entries
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region src/request/types/sparkMethods/transfer.ts
|
|
887
|
+
const sparkTransferMethodName = "spark_transfer";
|
|
888
|
+
const sparkTransferParamsSchema = valibot.object({
|
|
889
|
+
amountSats: valibot.union([valibot.number(), valibot.string()]),
|
|
890
|
+
receiverSparkAddress: valibot.string()
|
|
891
|
+
});
|
|
892
|
+
const sparkTransferResultSchema = valibot.object({ id: valibot.string() });
|
|
893
|
+
const sparkTransferRequestMessageSchema = valibot.object({
|
|
894
|
+
...rpcRequestMessageSchema.entries,
|
|
895
|
+
...valibot.object({
|
|
896
|
+
method: valibot.literal(sparkTransferMethodName),
|
|
897
|
+
params: sparkTransferParamsSchema,
|
|
898
|
+
id: valibot.string()
|
|
899
|
+
}).entries
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
//#endregion
|
|
903
|
+
//#region src/request/types/sparkMethods/transferToken.ts
|
|
904
|
+
const sparkTransferTokenMethodName = "spark_transferToken";
|
|
905
|
+
const sparkTransferTokenParamsSchema = valibot.object({
|
|
906
|
+
tokenAmount: valibot.union([valibot.number(), valibot.string()]),
|
|
907
|
+
tokenIdentifier: valibot.string(),
|
|
908
|
+
receiverSparkAddress: valibot.string()
|
|
909
|
+
});
|
|
910
|
+
const sparkTransferTokenResultSchema = valibot.object({ id: valibot.string() });
|
|
911
|
+
const sparkTransferTokenRequestMessageSchema = valibot.object({
|
|
912
|
+
...rpcRequestMessageSchema.entries,
|
|
913
|
+
...valibot.object({
|
|
914
|
+
method: valibot.literal(sparkTransferTokenMethodName),
|
|
915
|
+
params: sparkTransferTokenParamsSchema,
|
|
916
|
+
id: valibot.string()
|
|
917
|
+
}).entries
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/request/types/stxMethods/callContract.ts
|
|
922
|
+
const stxCallContractMethodName = "stx_callContract";
|
|
923
|
+
const stxCallContractParamsSchema = valibot.object({
|
|
924
|
+
contract: valibot.string(),
|
|
925
|
+
functionName: valibot.string(),
|
|
926
|
+
arguments: valibot.optional(valibot.array(valibot.string())),
|
|
927
|
+
functionArgs: valibot.optional(valibot.array(valibot.string())),
|
|
928
|
+
postConditions: valibot.optional(valibot.array(valibot.string())),
|
|
929
|
+
postConditionMode: valibot.optional(valibot.union([valibot.literal("allow"), valibot.literal("deny")]))
|
|
930
|
+
});
|
|
931
|
+
const stxCallContractResultSchema = valibot.object({
|
|
932
|
+
txid: valibot.string(),
|
|
933
|
+
transaction: valibot.string()
|
|
934
|
+
});
|
|
935
|
+
const stxCallContractRequestMessageSchema = valibot.object({
|
|
936
|
+
...rpcRequestMessageSchema.entries,
|
|
937
|
+
...valibot.object({
|
|
938
|
+
method: valibot.literal(stxCallContractMethodName),
|
|
939
|
+
params: stxCallContractParamsSchema,
|
|
940
|
+
id: valibot.string()
|
|
941
|
+
}).entries
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region src/request/types/stxMethods/deployContract.ts
|
|
946
|
+
const stxDeployContractMethodName = "stx_deployContract";
|
|
947
|
+
const stxDeployContractParamsSchema = valibot.object({
|
|
948
|
+
name: valibot.string(),
|
|
949
|
+
clarityCode: valibot.string(),
|
|
950
|
+
clarityVersion: valibot.optional(valibot.number()),
|
|
951
|
+
postConditions: valibot.optional(valibot.array(valibot.string())),
|
|
952
|
+
postConditionMode: valibot.optional(valibot.union([valibot.literal("allow"), valibot.literal("deny")]))
|
|
953
|
+
});
|
|
954
|
+
const stxDeployContractResultSchema = valibot.object({
|
|
955
|
+
txid: valibot.string(),
|
|
956
|
+
transaction: valibot.string()
|
|
957
|
+
});
|
|
958
|
+
const stxDeployContractRequestMessageSchema = valibot.object({
|
|
959
|
+
...rpcRequestMessageSchema.entries,
|
|
960
|
+
...valibot.object({
|
|
961
|
+
method: valibot.literal(stxDeployContractMethodName),
|
|
962
|
+
params: stxDeployContractParamsSchema,
|
|
963
|
+
id: valibot.string()
|
|
964
|
+
}).entries
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/request/types/stxMethods/getAccounts.ts
|
|
969
|
+
const stxGetAccountsMethodName = "stx_getAccounts";
|
|
970
|
+
const stxGetAccountsParamsSchema = valibot.nullish(valibot.null());
|
|
971
|
+
const stxGetAccountsResultSchema = valibot.object({
|
|
972
|
+
addresses: valibot.array(valibot.object({
|
|
973
|
+
address: valibot.string(),
|
|
974
|
+
publicKey: valibot.string(),
|
|
975
|
+
gaiaHubUrl: valibot.string(),
|
|
976
|
+
gaiaAppKey: valibot.string()
|
|
977
|
+
})),
|
|
978
|
+
network: stacksNetworkSchema
|
|
979
|
+
});
|
|
980
|
+
const stxGetAccountsRequestMessageSchema = valibot.object({
|
|
981
|
+
...rpcRequestMessageSchema.entries,
|
|
982
|
+
...valibot.object({
|
|
983
|
+
method: valibot.literal(stxGetAccountsMethodName),
|
|
984
|
+
params: stxGetAccountsParamsSchema,
|
|
985
|
+
id: valibot.string()
|
|
986
|
+
}).entries
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/request/types/stxMethods/getAddresses.ts
|
|
991
|
+
const stxGetAddressesMethodName = "stx_getAddresses";
|
|
992
|
+
const stxGetAddressesParamsSchema = valibot.nullish(valibot.object({ message: valibot.optional(valibot.string()) }));
|
|
993
|
+
const stxGetAddressesResultSchema = valibot.object({
|
|
994
|
+
addresses: valibot.array(addressSchema),
|
|
995
|
+
network: stacksNetworkSchema
|
|
996
|
+
});
|
|
997
|
+
const stxGetAddressesRequestMessageSchema = valibot.object({
|
|
998
|
+
...rpcRequestMessageSchema.entries,
|
|
999
|
+
...valibot.object({
|
|
1000
|
+
method: valibot.literal(stxGetAddressesMethodName),
|
|
1001
|
+
params: stxGetAddressesParamsSchema,
|
|
1002
|
+
id: valibot.string()
|
|
1003
|
+
}).entries
|
|
1004
|
+
});
|
|
1005
|
+
|
|
1006
|
+
//#endregion
|
|
1007
|
+
//#region src/request/types/stxMethods/signMessage.ts
|
|
1008
|
+
const stxSignMessageMethodName = "stx_signMessage";
|
|
1009
|
+
const stxSignMessageParamsSchema = valibot.object({ message: valibot.string() });
|
|
1010
|
+
const stxSignMessageResultSchema = valibot.object({
|
|
1011
|
+
signature: valibot.string(),
|
|
1012
|
+
publicKey: valibot.string()
|
|
1013
|
+
});
|
|
1014
|
+
const stxSignMessageRequestMessageSchema = valibot.object({
|
|
1015
|
+
...rpcRequestMessageSchema.entries,
|
|
1016
|
+
...valibot.object({
|
|
1017
|
+
method: valibot.literal(stxSignMessageMethodName),
|
|
1018
|
+
params: stxSignMessageParamsSchema,
|
|
1019
|
+
id: valibot.string()
|
|
1020
|
+
}).entries
|
|
1021
|
+
});
|
|
1022
|
+
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/request/types/stxMethods/signStructuredMessage.ts
|
|
1025
|
+
const stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
1026
|
+
const stxSignStructuredMessageParamsSchema = valibot.object({
|
|
1027
|
+
domain: valibot.string(),
|
|
1028
|
+
message: valibot.string(),
|
|
1029
|
+
publicKey: valibot.optional(valibot.string())
|
|
1030
|
+
});
|
|
1031
|
+
const stxSignStructuredMessageResultSchema = valibot.object({
|
|
1032
|
+
signature: valibot.string(),
|
|
1033
|
+
publicKey: valibot.string()
|
|
1034
|
+
});
|
|
1035
|
+
const stxSignStructuredMessageRequestMessageSchema = valibot.object({
|
|
1036
|
+
...rpcRequestMessageSchema.entries,
|
|
1037
|
+
...valibot.object({
|
|
1038
|
+
method: valibot.literal(stxSignStructuredMessageMethodName),
|
|
1039
|
+
params: stxSignStructuredMessageParamsSchema,
|
|
1040
|
+
id: valibot.string()
|
|
1041
|
+
}).entries
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/request/types/stxMethods/signTransaction.ts
|
|
1046
|
+
const stxSignTransactionMethodName = "stx_signTransaction";
|
|
1047
|
+
const stxSignTransactionParamsSchema = valibot.object({
|
|
1048
|
+
transaction: valibot.string(),
|
|
1049
|
+
pubkey: valibot.optional(valibot.string()),
|
|
1050
|
+
broadcast: valibot.optional(valibot.boolean())
|
|
1051
|
+
});
|
|
1052
|
+
const stxSignTransactionResultSchema = valibot.object({ transaction: valibot.string() });
|
|
1053
|
+
const stxSignTransactionRequestMessageSchema = valibot.object({
|
|
1054
|
+
...rpcRequestMessageSchema.entries,
|
|
1055
|
+
...valibot.object({
|
|
1056
|
+
method: valibot.literal(stxSignTransactionMethodName),
|
|
1057
|
+
params: stxSignTransactionParamsSchema,
|
|
1058
|
+
id: valibot.string()
|
|
1059
|
+
}).entries
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1062
|
+
//#endregion
|
|
1063
|
+
//#region src/request/types/stxMethods/signTransactions.ts
|
|
1064
|
+
const stxSignTransactionsMethodName = "stx_signTransactions";
|
|
1065
|
+
const stxSignTransactionsParamsSchema = valibot.object({
|
|
1066
|
+
transactions: valibot.pipe(valibot.array(valibot.pipe(valibot.string(), valibot.check((hex) => {
|
|
1067
|
+
return true;
|
|
1068
|
+
}, "Invalid hex-encoded Stacks transaction."))), valibot.minLength(1)),
|
|
1069
|
+
broadcast: valibot.optional(valibot.boolean())
|
|
1070
|
+
});
|
|
1071
|
+
const stxSignTransactionsResultSchema = valibot.object({ transactions: valibot.array(valibot.string()) });
|
|
1072
|
+
const stxSignTransactionsRequestMessageSchema = valibot.object({
|
|
1073
|
+
...rpcRequestMessageSchema.entries,
|
|
1074
|
+
...valibot.object({
|
|
1075
|
+
method: valibot.literal(stxSignTransactionsMethodName),
|
|
1076
|
+
params: stxSignTransactionsParamsSchema,
|
|
1077
|
+
id: valibot.string()
|
|
1078
|
+
}).entries
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region src/request/types/stxMethods/transferStx.ts
|
|
1083
|
+
const stxTransferStxMethodName = "stx_transferStx";
|
|
1084
|
+
const stxTransferStxParamsSchema = valibot.object({
|
|
1085
|
+
amount: valibot.union([valibot.number(), valibot.string()]),
|
|
1086
|
+
recipient: valibot.string(),
|
|
1087
|
+
memo: valibot.optional(valibot.string()),
|
|
1088
|
+
version: valibot.optional(valibot.string()),
|
|
1089
|
+
postConditionMode: valibot.optional(valibot.number()),
|
|
1090
|
+
postConditions: valibot.optional(valibot.array(valibot.string())),
|
|
1091
|
+
pubkey: valibot.optional(valibot.string())
|
|
1092
|
+
});
|
|
1093
|
+
const stxTransferStxResultSchema = valibot.object({
|
|
1094
|
+
txid: valibot.string(),
|
|
1095
|
+
transaction: valibot.string()
|
|
1096
|
+
});
|
|
1097
|
+
const stxTransferStxRequestMessageSchema = valibot.object({
|
|
1098
|
+
...rpcRequestMessageSchema.entries,
|
|
1099
|
+
...valibot.object({
|
|
1100
|
+
method: valibot.literal(stxTransferStxMethodName),
|
|
1101
|
+
params: stxTransferStxParamsSchema,
|
|
1102
|
+
id: valibot.string()
|
|
1103
|
+
}).entries
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/request/types/walletMethods.ts
|
|
1108
|
+
const accountActionsSchema = valibot.object({ read: valibot.optional(valibot.boolean()) });
|
|
1109
|
+
const walletActionsSchema = valibot.object({ readNetwork: valibot.optional(valibot.boolean()) });
|
|
1110
|
+
const accountPermissionSchema = valibot.object({
|
|
1111
|
+
type: valibot.literal("account"),
|
|
1112
|
+
resourceId: valibot.string(),
|
|
1113
|
+
clientId: valibot.string(),
|
|
1114
|
+
actions: accountActionsSchema
|
|
1115
|
+
});
|
|
1116
|
+
const walletPermissionSchema = valibot.object({
|
|
1117
|
+
type: valibot.literal("wallet"),
|
|
1118
|
+
resourceId: valibot.string(),
|
|
1119
|
+
clientId: valibot.string(),
|
|
1120
|
+
actions: walletActionsSchema
|
|
1121
|
+
});
|
|
1122
|
+
/**
|
|
1123
|
+
* Permissions with the clientId field omitted and optional actions. Used for
|
|
1124
|
+
* permission requests, since the wallet performs authentication based on the
|
|
1125
|
+
* client's tab origin and should not rely on the client authenticating
|
|
1126
|
+
* themselves.
|
|
1127
|
+
*/
|
|
1128
|
+
const PermissionRequestParams = valibot.variant("type", [valibot.object({ ...valibot.omit(accountPermissionSchema, ["clientId"]).entries }), valibot.object({ ...valibot.omit(walletPermissionSchema, ["clientId"]).entries })]);
|
|
1129
|
+
const permission = valibot.variant("type", [accountPermissionSchema, walletPermissionSchema]);
|
|
1130
|
+
const requestPermissionsMethodName = "wallet_requestPermissions";
|
|
1131
|
+
const requestPermissionsParamsSchema = valibot.nullish(valibot.array(PermissionRequestParams));
|
|
1132
|
+
const requestPermissionsResultSchema = valibot.literal(true);
|
|
1133
|
+
const requestPermissionsRequestMessageSchema = valibot.object({
|
|
1134
|
+
...rpcRequestMessageSchema.entries,
|
|
1135
|
+
...valibot.object({
|
|
1136
|
+
method: valibot.literal(requestPermissionsMethodName),
|
|
1137
|
+
params: requestPermissionsParamsSchema,
|
|
1138
|
+
id: valibot.string()
|
|
1139
|
+
}).entries
|
|
1140
|
+
});
|
|
1141
|
+
const renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
1142
|
+
const renouncePermissionsParamsSchema = valibot.nullish(valibot.null());
|
|
1143
|
+
const renouncePermissionsResultSchema = valibot.nullish(valibot.null());
|
|
1144
|
+
const renouncePermissionsRequestMessageSchema = valibot.object({
|
|
1145
|
+
...rpcRequestMessageSchema.entries,
|
|
1146
|
+
...valibot.object({
|
|
1147
|
+
method: valibot.literal(renouncePermissionsMethodName),
|
|
1148
|
+
params: renouncePermissionsParamsSchema,
|
|
1149
|
+
id: valibot.string()
|
|
1150
|
+
}).entries
|
|
1151
|
+
});
|
|
1152
|
+
const disconnectMethodName = "wallet_disconnect";
|
|
1153
|
+
const disconnectParamsSchema = valibot.nullish(valibot.null());
|
|
1154
|
+
const disconnectResultSchema = valibot.nullish(valibot.null());
|
|
1155
|
+
const disconnectRequestMessageSchema = valibot.object({
|
|
1156
|
+
...rpcRequestMessageSchema.entries,
|
|
1157
|
+
...valibot.object({
|
|
1158
|
+
method: valibot.literal(disconnectMethodName),
|
|
1159
|
+
params: disconnectParamsSchema,
|
|
1160
|
+
id: valibot.string()
|
|
1161
|
+
}).entries
|
|
1162
|
+
});
|
|
1163
|
+
const getWalletTypeMethodName = "wallet_getWalletType";
|
|
1164
|
+
const getWalletTypeParamsSchema = valibot.nullish(valibot.null());
|
|
1165
|
+
const getWalletTypeResultSchema = walletTypeSchema;
|
|
1166
|
+
const getWalletTypeRequestMessageSchema = valibot.object({
|
|
1167
|
+
...rpcRequestMessageSchema.entries,
|
|
1168
|
+
...valibot.object({
|
|
1169
|
+
method: valibot.literal(getWalletTypeMethodName),
|
|
1170
|
+
params: getWalletTypeParamsSchema,
|
|
1171
|
+
id: valibot.string()
|
|
1172
|
+
}).entries
|
|
1173
|
+
});
|
|
1174
|
+
const getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
1175
|
+
const getCurrentPermissionsParamsSchema = valibot.nullish(valibot.null());
|
|
1176
|
+
const getCurrentPermissionsResultSchema = valibot.array(permission);
|
|
1177
|
+
const getCurrentPermissionsRequestMessageSchema = valibot.object({
|
|
1178
|
+
...rpcRequestMessageSchema.entries,
|
|
1179
|
+
...valibot.object({
|
|
1180
|
+
method: valibot.literal(getCurrentPermissionsMethodName),
|
|
1181
|
+
params: getCurrentPermissionsParamsSchema,
|
|
1182
|
+
id: valibot.string()
|
|
1183
|
+
}).entries
|
|
1184
|
+
});
|
|
1185
|
+
const getNetworksMethodName = "wallet_getNetworks";
|
|
1186
|
+
const getNetworksParamsSchema = valibot.nullish(valibot.null());
|
|
1187
|
+
const getNetworksResultSchema = valibot.object({
|
|
1188
|
+
active: valibot.object({
|
|
1189
|
+
bitcoin: bitcoinNetworkSchema,
|
|
1190
|
+
stacks: stacksNetworkSchema,
|
|
1191
|
+
spark: sparkNetworkSchema,
|
|
1192
|
+
starknet: starknetNetworkSchema
|
|
1193
|
+
}),
|
|
1194
|
+
builtin: valibot.object({
|
|
1195
|
+
bitcoin: valibot.array(bitcoinNetworkSchema),
|
|
1196
|
+
stacks: valibot.array(stacksNetworkSchema),
|
|
1197
|
+
spark: valibot.array(sparkNetworkSchema),
|
|
1198
|
+
starknet: valibot.array(starknetNetworkSchema)
|
|
1199
|
+
}),
|
|
1200
|
+
custom: valibot.object({
|
|
1201
|
+
bitcoin: valibot.array(bitcoinNetworkSchema),
|
|
1202
|
+
stacks: valibot.array(stacksNetworkSchema),
|
|
1203
|
+
spark: valibot.array(sparkNetworkSchema),
|
|
1204
|
+
starknet: valibot.array(starknetNetworkSchema)
|
|
1205
|
+
})
|
|
1206
|
+
});
|
|
1207
|
+
const getNetworksRequestMessageSchema = valibot.object({
|
|
1208
|
+
...rpcRequestMessageSchema.entries,
|
|
1209
|
+
...valibot.object({
|
|
1210
|
+
method: valibot.literal(getNetworksMethodName),
|
|
1211
|
+
params: getNetworksParamsSchema,
|
|
1212
|
+
id: valibot.string()
|
|
1213
|
+
}).entries
|
|
1214
|
+
});
|
|
1215
|
+
const changeNetworkMethodName = "wallet_changeNetwork";
|
|
1216
|
+
const changeNetworkParamsSchema = valibot.object({ name: valibot.enum(BitcoinNetworkType) });
|
|
1217
|
+
const changeNetworkResultSchema = valibot.nullish(valibot.null());
|
|
1218
|
+
const changeNetworkRequestMessageSchema = valibot.object({
|
|
1219
|
+
...rpcRequestMessageSchema.entries,
|
|
1220
|
+
...valibot.object({
|
|
1221
|
+
method: valibot.literal(changeNetworkMethodName),
|
|
1222
|
+
params: changeNetworkParamsSchema,
|
|
1223
|
+
id: valibot.string()
|
|
1224
|
+
}).entries
|
|
1225
|
+
});
|
|
1226
|
+
const changeNetworkByIdMethodName = "wallet_changeNetworkById";
|
|
1227
|
+
const changeNetworkByIdParamsSchema = valibot.object({ id: valibot.string() });
|
|
1228
|
+
const changeNetworkByIdResultSchema = valibot.nullish(valibot.null());
|
|
1229
|
+
const changeNetworkByIdRequestMessageSchema = valibot.object({
|
|
1230
|
+
...rpcRequestMessageSchema.entries,
|
|
1231
|
+
...valibot.object({
|
|
1232
|
+
method: valibot.literal(changeNetworkByIdMethodName),
|
|
1233
|
+
params: changeNetworkByIdParamsSchema,
|
|
1234
|
+
id: valibot.string()
|
|
1235
|
+
}).entries
|
|
1236
|
+
});
|
|
1237
|
+
const getAccountMethodName = "wallet_getAccount";
|
|
1238
|
+
const getAccountParamsSchema = valibot.nullish(valibot.null());
|
|
1239
|
+
const getAccountResultSchema = valibot.object({
|
|
1240
|
+
id: valibot.string(),
|
|
1241
|
+
addresses: valibot.array(addressSchema),
|
|
1242
|
+
walletType: walletTypeSchema,
|
|
1243
|
+
networks: getNetworksResultSchema
|
|
1244
|
+
});
|
|
1245
|
+
const getAccountRequestMessageSchema = valibot.object({
|
|
1246
|
+
...rpcRequestMessageSchema.entries,
|
|
1247
|
+
...valibot.object({
|
|
1248
|
+
method: valibot.literal(getAccountMethodName),
|
|
1249
|
+
params: getAccountParamsSchema,
|
|
1250
|
+
id: valibot.string()
|
|
1251
|
+
}).entries
|
|
1252
|
+
});
|
|
1253
|
+
const connectMethodName = "wallet_connect";
|
|
1254
|
+
const connectParamsSchema = valibot.nullish(valibot.object({
|
|
1255
|
+
permissions: valibot.optional(valibot.array(PermissionRequestParams)),
|
|
1256
|
+
addresses: valibot.optional(valibot.array(valibot.enum(AddressPurpose))),
|
|
1257
|
+
message: valibot.optional(valibot.pipe(valibot.string(), valibot.maxLength(80, "The message must not exceed 80 characters."))),
|
|
1258
|
+
networkId: valibot.optional(valibot.string())
|
|
1259
|
+
}));
|
|
1260
|
+
const connectResultSchema = valibot.object({
|
|
1261
|
+
id: valibot.string(),
|
|
1262
|
+
addresses: valibot.array(addressSchema),
|
|
1263
|
+
walletType: walletTypeSchema,
|
|
1264
|
+
networks: getNetworksResultSchema
|
|
1265
|
+
});
|
|
1266
|
+
const connectRequestMessageSchema = valibot.object({
|
|
1267
|
+
...rpcRequestMessageSchema.entries,
|
|
1268
|
+
...valibot.object({
|
|
1269
|
+
method: valibot.literal(connectMethodName),
|
|
1270
|
+
params: connectParamsSchema,
|
|
1271
|
+
id: valibot.string()
|
|
1272
|
+
}).entries
|
|
1273
|
+
});
|
|
1274
|
+
const addNetworkMethodName = "wallet_addNetwork";
|
|
1275
|
+
const bitcoinNetworkDefinitionSchema = valibot.omit(bitcoinNetworkSchema, ["id"]);
|
|
1276
|
+
const sparkNetworkDefinitionSchema = valibot.omit(sparkNetworkSchema, ["id"]);
|
|
1277
|
+
const stacksNetworkDefinitionSchema = valibot.omit(stacksNetworkSchema, ["id"]);
|
|
1278
|
+
const starknetNetworkDefinitionSchema = valibot.omit(starknetNetworkSchema, ["id"]);
|
|
1279
|
+
const newNetworkDefinitionSchema = valibot.variant("chain", [
|
|
1280
|
+
bitcoinNetworkDefinitionSchema,
|
|
1281
|
+
sparkNetworkDefinitionSchema,
|
|
1282
|
+
stacksNetworkDefinitionSchema,
|
|
1283
|
+
starknetNetworkDefinitionSchema
|
|
1284
|
+
]);
|
|
1285
|
+
const addNetworkParamsSchema = valibot.object({
|
|
1286
|
+
network: newNetworkDefinitionSchema,
|
|
1287
|
+
isActive: valibot.optional(valibot.boolean())
|
|
1288
|
+
});
|
|
1289
|
+
const addNetworkRequestMessageSchema = valibot.object({
|
|
1290
|
+
...rpcRequestMessageSchema.entries,
|
|
1291
|
+
...valibot.object({
|
|
1292
|
+
method: valibot.literal(addNetworkMethodName),
|
|
1293
|
+
params: addNetworkParamsSchema,
|
|
1294
|
+
id: valibot.string()
|
|
1295
|
+
}).entries
|
|
1296
|
+
});
|
|
1297
|
+
const addNetworkResultSchema = valibot.object({ id: valibot.string() });
|
|
1298
|
+
|
|
1299
|
+
//#endregion
|
|
1300
|
+
//#region src/request/index.ts
|
|
1301
|
+
const cache = {};
|
|
1302
|
+
const requestInternal = async (provider, method, params) => {
|
|
1303
|
+
const response = await provider.request(method, params);
|
|
1304
|
+
if (valibot.is(rpcErrorResponseMessageSchema, response)) return {
|
|
1305
|
+
status: "error",
|
|
1306
|
+
error: response.error
|
|
1307
|
+
};
|
|
1308
|
+
if (valibot.is(rpcSuccessResponseMessageSchema, response)) return {
|
|
1309
|
+
status: "success",
|
|
1310
|
+
result: response.result
|
|
1311
|
+
};
|
|
1312
|
+
return {
|
|
1313
|
+
status: "error",
|
|
1314
|
+
error: {
|
|
1315
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
1316
|
+
message: "Received unknown response from provider.",
|
|
1317
|
+
data: response
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
};
|
|
1321
|
+
const request = async (method, params, providerId) => {
|
|
1322
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
1323
|
+
if (providerId) provider = await getProviderById(providerId);
|
|
1324
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1325
|
+
if (!method) throw new Error("A wallet method is required");
|
|
1326
|
+
if (!cache.providerInfo) {
|
|
1327
|
+
const infoResult = await requestInternal(provider, "getInfo", null);
|
|
1328
|
+
if (infoResult.status === "success") cache.providerInfo = infoResult.result;
|
|
1329
|
+
}
|
|
1330
|
+
if (cache.providerInfo) {
|
|
1331
|
+
if (method === "getInfo") return {
|
|
1332
|
+
status: "success",
|
|
1333
|
+
result: cache.providerInfo
|
|
1334
|
+
};
|
|
1335
|
+
const sanitized = sanitizeRequest(method, params, cache.providerInfo);
|
|
1336
|
+
if (sanitized.overrideResponse) return sanitized.overrideResponse;
|
|
1337
|
+
method = sanitized.method;
|
|
1338
|
+
params = sanitized.params;
|
|
1339
|
+
}
|
|
1340
|
+
return requestInternal(provider, method, params);
|
|
1341
|
+
};
|
|
1342
|
+
/**
|
|
1343
|
+
* Adds an event listener.
|
|
1344
|
+
*
|
|
1345
|
+
* Currently expects 2 arguments, although is also capable of handling legacy
|
|
1346
|
+
* calls with 3 arguments consisting of:
|
|
1347
|
+
*
|
|
1348
|
+
* - event name (string)
|
|
1349
|
+
* - callback (function)
|
|
1350
|
+
* - provider ID (optional string)
|
|
1351
|
+
*/
|
|
1352
|
+
const addListener = (...rawArgs) => {
|
|
1353
|
+
const [listenerInfo, providerId] = (() => {
|
|
1354
|
+
if (rawArgs.length === 1) return [rawArgs[0], void 0];
|
|
1355
|
+
if (rawArgs.length === 2) if (typeof rawArgs[1] === "function") return [{
|
|
1356
|
+
eventName: rawArgs[0],
|
|
1357
|
+
cb: rawArgs[1]
|
|
1358
|
+
}, void 0];
|
|
1359
|
+
else return rawArgs;
|
|
1360
|
+
if (rawArgs.length === 3) return [{
|
|
1361
|
+
eventName: rawArgs[0],
|
|
1362
|
+
cb: rawArgs[1]
|
|
1363
|
+
}, rawArgs[2]];
|
|
1364
|
+
throw new Error("Unexpected number of arguments. Expecting 2 (or 3 for legacy requests).", { cause: rawArgs });
|
|
1365
|
+
})();
|
|
1366
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
1367
|
+
if (providerId) provider = getProviderById(providerId);
|
|
1368
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1369
|
+
if (!provider.addListener) {
|
|
1370
|
+
console.error(`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`);
|
|
1371
|
+
return () => {};
|
|
1372
|
+
}
|
|
1373
|
+
return provider.addListener(listenerInfo);
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
//#endregion
|
|
1377
|
+
//#region src/runes/api.ts
|
|
1378
|
+
const urlNetworkSuffix = {
|
|
1379
|
+
[BitcoinNetworkType.Mainnet]: "",
|
|
1380
|
+
[BitcoinNetworkType.Testnet]: "-testnet",
|
|
1381
|
+
[BitcoinNetworkType.Testnet4]: "-testnet4",
|
|
1382
|
+
[BitcoinNetworkType.Signet]: "-signet"
|
|
1383
|
+
};
|
|
1384
|
+
const ORDINALS_API_BASE_URL = (network = BitcoinNetworkType.Mainnet) => {
|
|
1385
|
+
if (network === BitcoinNetworkType.Regtest) throw new Error(`Ordinals API does not support ${network} network`);
|
|
1386
|
+
return `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
|
1387
|
+
};
|
|
1388
|
+
var RunesApi = class {
|
|
1389
|
+
client;
|
|
1390
|
+
constructor(network) {
|
|
1391
|
+
this.client = axios.default.create({ baseURL: ORDINALS_API_BASE_URL(network) });
|
|
1392
|
+
}
|
|
1393
|
+
parseError = (error) => {
|
|
1394
|
+
return {
|
|
1395
|
+
code: error.response?.status,
|
|
1396
|
+
message: JSON.stringify(error.response?.data)
|
|
1397
|
+
};
|
|
1398
|
+
};
|
|
1399
|
+
estimateMintCost = async (mintParams) => {
|
|
1400
|
+
try {
|
|
1401
|
+
return { data: (await this.client.post("/runes/mint/estimate", { ...mintParams })).data };
|
|
1402
|
+
} catch (error) {
|
|
1403
|
+
const err = error;
|
|
1404
|
+
return { error: this.parseError(err) };
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
estimateEtchCost = async (etchParams) => {
|
|
1408
|
+
try {
|
|
1409
|
+
return { data: (await this.client.post("/runes/etch/estimate", { ...etchParams })).data };
|
|
1410
|
+
} catch (error) {
|
|
1411
|
+
const err = error;
|
|
1412
|
+
return { error: this.parseError(err) };
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
createMintOrder = async (mintOrderParams) => {
|
|
1416
|
+
try {
|
|
1417
|
+
return { data: (await this.client.post("/runes/mint/orders", { ...mintOrderParams })).data };
|
|
1418
|
+
} catch (error) {
|
|
1419
|
+
const err = error;
|
|
1420
|
+
return { error: this.parseError(err) };
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
createEtchOrder = async (etchOrderParams) => {
|
|
1424
|
+
try {
|
|
1425
|
+
return { data: (await this.client.post("/runes/etch/orders", { ...etchOrderParams })).data };
|
|
1426
|
+
} catch (error) {
|
|
1427
|
+
const err = error;
|
|
1428
|
+
return { error: this.parseError(err) };
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
executeMint = async (orderId, fundTransactionId) => {
|
|
1432
|
+
try {
|
|
1433
|
+
return { data: (await this.client.post(`/runes/mint/orders/${orderId}/execute`, { fundTransactionId })).data };
|
|
1434
|
+
} catch (error) {
|
|
1435
|
+
const err = error;
|
|
1436
|
+
return { error: this.parseError(err) };
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
executeEtch = async (orderId, fundTransactionId) => {
|
|
1440
|
+
try {
|
|
1441
|
+
return { data: (await this.client.post(`/runes/etch/orders/${orderId}/execute`, { fundTransactionId })).data };
|
|
1442
|
+
} catch (error) {
|
|
1443
|
+
const err = error;
|
|
1444
|
+
return { error: this.parseError(err) };
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1447
|
+
getOrder = async (orderId) => {
|
|
1448
|
+
try {
|
|
1449
|
+
return { data: (await this.client.get(`/orders/${orderId}`)).data };
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
const err = error;
|
|
1452
|
+
return { error: this.parseError(err) };
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
rbfOrder = async (rbfRequest) => {
|
|
1456
|
+
const { orderId, newFeeRate } = rbfRequest;
|
|
1457
|
+
try {
|
|
1458
|
+
return { data: (await this.client.post(`/orders/${orderId}/rbf-estimate`, { newFeeRate })).data };
|
|
1459
|
+
} catch (error) {
|
|
1460
|
+
const err = error;
|
|
1461
|
+
return { error: this.parseError(err) };
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
};
|
|
1465
|
+
const clients = {};
|
|
1466
|
+
const getRunesApiClient = (network = BitcoinNetworkType.Mainnet) => {
|
|
1467
|
+
if (!clients[network]) clients[network] = new RunesApi(network);
|
|
1468
|
+
return clients[network];
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
//#endregion
|
|
1472
|
+
//#region src/adapters/satsConnectAdapter.ts
|
|
1473
|
+
var SatsConnectAdapter = class {
|
|
1474
|
+
async mintRunes(params) {
|
|
1475
|
+
try {
|
|
1476
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
1477
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
1478
|
+
if (walletInfo.result.methods?.includes("runes_mint")) {
|
|
1479
|
+
const response = await this.requestInternal("runes_mint", params);
|
|
1480
|
+
if (response) {
|
|
1481
|
+
if (response.status === "success") return response;
|
|
1482
|
+
if (response.status === "error" && response.error.code !== RpcErrorCode.METHOD_NOT_FOUND) return response;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
const mintRequest = {
|
|
1487
|
+
destinationAddress: params.destinationAddress,
|
|
1488
|
+
feeRate: params.feeRate,
|
|
1489
|
+
refundAddress: params.refundAddress,
|
|
1490
|
+
repeats: params.repeats,
|
|
1491
|
+
runeName: params.runeName,
|
|
1492
|
+
appServiceFee: params.appServiceFee,
|
|
1493
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
1494
|
+
};
|
|
1495
|
+
const orderResponse = await new RunesApi(params.network).createMintOrder(mintRequest);
|
|
1496
|
+
if (!orderResponse.data) return {
|
|
1497
|
+
status: "error",
|
|
1498
|
+
error: {
|
|
1499
|
+
code: orderResponse.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1500
|
+
message: orderResponse.error.message
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
1504
|
+
address: orderResponse.data.fundAddress,
|
|
1505
|
+
amount: orderResponse.data.fundAmount
|
|
1506
|
+
}] });
|
|
1507
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
1508
|
+
await new RunesApi(params.network).executeMint(orderResponse.data.orderId, paymentResponse.result.txid);
|
|
1509
|
+
return {
|
|
1510
|
+
status: "success",
|
|
1511
|
+
result: {
|
|
1512
|
+
orderId: orderResponse.data.orderId,
|
|
1513
|
+
fundTransactionId: paymentResponse.result.txid,
|
|
1514
|
+
fundingAddress: orderResponse.data.fundAddress
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
} catch (error) {
|
|
1518
|
+
return {
|
|
1519
|
+
status: "error",
|
|
1520
|
+
error: {
|
|
1521
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
1522
|
+
message: error.message
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
async etchRunes(params) {
|
|
1528
|
+
const etchRequest = {
|
|
1529
|
+
destinationAddress: params.destinationAddress,
|
|
1530
|
+
refundAddress: params.refundAddress,
|
|
1531
|
+
feeRate: params.feeRate,
|
|
1532
|
+
runeName: params.runeName,
|
|
1533
|
+
divisibility: params.divisibility,
|
|
1534
|
+
symbol: params.symbol,
|
|
1535
|
+
premine: params.premine,
|
|
1536
|
+
isMintable: params.isMintable,
|
|
1537
|
+
terms: params.terms,
|
|
1538
|
+
inscriptionDetails: params.inscriptionDetails,
|
|
1539
|
+
delegateInscriptionId: params.delegateInscriptionId,
|
|
1540
|
+
appServiceFee: params.appServiceFee,
|
|
1541
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
1542
|
+
};
|
|
1543
|
+
try {
|
|
1544
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
1545
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
1546
|
+
if (walletInfo.result.methods?.includes("runes_etch")) {
|
|
1547
|
+
const response = await this.requestInternal("runes_etch", params);
|
|
1548
|
+
if (response) {
|
|
1549
|
+
if (response.status === "success") return response;
|
|
1550
|
+
if (response.status === "error" && response.error.code !== RpcErrorCode.METHOD_NOT_FOUND) return response;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
1555
|
+
if (!orderResponse.data) return {
|
|
1556
|
+
status: "error",
|
|
1557
|
+
error: {
|
|
1558
|
+
code: orderResponse.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1559
|
+
message: orderResponse.error.message
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
1563
|
+
address: orderResponse.data.fundAddress,
|
|
1564
|
+
amount: orderResponse.data.fundAmount
|
|
1565
|
+
}] });
|
|
1566
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
1567
|
+
await new RunesApi(params.network).executeEtch(orderResponse.data.orderId, paymentResponse.result.txid);
|
|
1568
|
+
return {
|
|
1569
|
+
status: "success",
|
|
1570
|
+
result: {
|
|
1571
|
+
orderId: orderResponse.data.orderId,
|
|
1572
|
+
fundTransactionId: paymentResponse.result.txid,
|
|
1573
|
+
fundingAddress: orderResponse.data.fundAddress
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
} catch (error) {
|
|
1577
|
+
return {
|
|
1578
|
+
status: "error",
|
|
1579
|
+
error: {
|
|
1580
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
1581
|
+
message: error.message
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
async estimateMint(params) {
|
|
1587
|
+
const estimateMintRequest = {
|
|
1588
|
+
destinationAddress: params.destinationAddress,
|
|
1589
|
+
feeRate: params.feeRate,
|
|
1590
|
+
repeats: params.repeats,
|
|
1591
|
+
runeName: params.runeName,
|
|
1592
|
+
appServiceFee: params.appServiceFee,
|
|
1593
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
1594
|
+
};
|
|
1595
|
+
const response = await getRunesApiClient(params.network).estimateMintCost(estimateMintRequest);
|
|
1596
|
+
if (response.data) return {
|
|
1597
|
+
status: "success",
|
|
1598
|
+
result: response.data
|
|
1599
|
+
};
|
|
1600
|
+
return {
|
|
1601
|
+
status: "error",
|
|
1602
|
+
error: {
|
|
1603
|
+
code: response.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1604
|
+
message: response.error.message
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
async estimateEtch(params) {
|
|
1609
|
+
const estimateEtchRequest = {
|
|
1610
|
+
destinationAddress: params.destinationAddress,
|
|
1611
|
+
feeRate: params.feeRate,
|
|
1612
|
+
runeName: params.runeName,
|
|
1613
|
+
divisibility: params.divisibility,
|
|
1614
|
+
symbol: params.symbol,
|
|
1615
|
+
premine: params.premine,
|
|
1616
|
+
isMintable: params.isMintable,
|
|
1617
|
+
terms: params.terms,
|
|
1618
|
+
inscriptionDetails: params.inscriptionDetails,
|
|
1619
|
+
delegateInscriptionId: params.delegateInscriptionId,
|
|
1620
|
+
appServiceFee: params.appServiceFee,
|
|
1621
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
1622
|
+
};
|
|
1623
|
+
const response = await getRunesApiClient(params.network).estimateEtchCost(estimateEtchRequest);
|
|
1624
|
+
if (response.data) return {
|
|
1625
|
+
status: "success",
|
|
1626
|
+
result: response.data
|
|
1627
|
+
};
|
|
1628
|
+
return {
|
|
1629
|
+
status: "error",
|
|
1630
|
+
error: {
|
|
1631
|
+
code: response.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1632
|
+
message: response.error.message
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
async getOrder(params) {
|
|
1637
|
+
const response = await getRunesApiClient(params.network).getOrder(params.id);
|
|
1638
|
+
if (response.data) return {
|
|
1639
|
+
status: "success",
|
|
1640
|
+
result: response.data
|
|
1641
|
+
};
|
|
1642
|
+
return {
|
|
1643
|
+
status: "error",
|
|
1644
|
+
error: {
|
|
1645
|
+
code: response.error.code === 400 || response.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1646
|
+
message: response.error.message
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
async estimateRbfOrder(params) {
|
|
1651
|
+
const rbfOrderRequest = {
|
|
1652
|
+
newFeeRate: params.newFeeRate,
|
|
1653
|
+
orderId: params.orderId
|
|
1654
|
+
};
|
|
1655
|
+
const response = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
|
|
1656
|
+
if (response.data) return {
|
|
1657
|
+
status: "success",
|
|
1658
|
+
result: {
|
|
1659
|
+
fundingAddress: response.data.fundingAddress,
|
|
1660
|
+
rbfCost: response.data.rbfCost
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
return {
|
|
1664
|
+
status: "error",
|
|
1665
|
+
error: {
|
|
1666
|
+
code: response.error.code === 400 || response.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1667
|
+
message: response.error.message
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
async rbfOrder(params) {
|
|
1672
|
+
try {
|
|
1673
|
+
const rbfOrderRequest = {
|
|
1674
|
+
newFeeRate: params.newFeeRate,
|
|
1675
|
+
orderId: params.orderId
|
|
1676
|
+
};
|
|
1677
|
+
const orderResponse = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
|
|
1678
|
+
if (!orderResponse.data) return {
|
|
1679
|
+
status: "error",
|
|
1680
|
+
error: {
|
|
1681
|
+
code: orderResponse.error.code === 400 || orderResponse.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
1682
|
+
message: orderResponse.error.message
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
1686
|
+
address: orderResponse.data.fundingAddress,
|
|
1687
|
+
amount: orderResponse.data.rbfCost
|
|
1688
|
+
}] });
|
|
1689
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
1690
|
+
return {
|
|
1691
|
+
status: "success",
|
|
1692
|
+
result: {
|
|
1693
|
+
fundingAddress: orderResponse.data.fundingAddress,
|
|
1694
|
+
orderId: rbfOrderRequest.orderId,
|
|
1695
|
+
fundRBFTransactionId: paymentResponse.result.txid
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
} catch (error) {
|
|
1699
|
+
return {
|
|
1700
|
+
status: "error",
|
|
1701
|
+
error: {
|
|
1702
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
1703
|
+
message: error.message
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
async request(method, params) {
|
|
1709
|
+
switch (method) {
|
|
1710
|
+
case "runes_mint": return this.mintRunes(params);
|
|
1711
|
+
case "runes_etch": return this.etchRunes(params);
|
|
1712
|
+
case "runes_estimateMint": return this.estimateMint(params);
|
|
1713
|
+
case "runes_estimateEtch": return this.estimateEtch(params);
|
|
1714
|
+
case "runes_getOrder": return this.getOrder(params);
|
|
1715
|
+
case "runes_estimateRbfOrder": return this.estimateRbfOrder(params);
|
|
1716
|
+
case "runes_rbfOrder": return this.rbfOrder(params);
|
|
1717
|
+
default: return this.requestInternal(method, params);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
//#endregion
|
|
1723
|
+
//#region src/adapters/xverse.ts
|
|
1724
|
+
var XverseAdapter = class extends SatsConnectAdapter {
|
|
1725
|
+
id = DefaultAdaptersInfo.xverse.id;
|
|
1726
|
+
requestInternal = async (method, params) => {
|
|
1727
|
+
return request(method, params, this.id);
|
|
1728
|
+
};
|
|
1729
|
+
addListener = (listenerInfo) => {
|
|
1730
|
+
return addListener(listenerInfo, this.id);
|
|
1731
|
+
};
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
//#endregion
|
|
1735
|
+
//#region src/adapters/unisat.ts
|
|
1736
|
+
function convertSignInputsToInputType(signInputs) {
|
|
1737
|
+
let result = [];
|
|
1738
|
+
if (!signInputs) return result;
|
|
1739
|
+
for (let address in signInputs) {
|
|
1740
|
+
let indexes = signInputs[address];
|
|
1741
|
+
for (let index of indexes) result.push({
|
|
1742
|
+
index,
|
|
1743
|
+
address
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
return result;
|
|
1747
|
+
}
|
|
1748
|
+
var UnisatAdapter = class extends SatsConnectAdapter {
|
|
1749
|
+
id = DefaultAdaptersInfo.unisat.id;
|
|
1750
|
+
async getAccounts(params) {
|
|
1751
|
+
const { purposes } = params;
|
|
1752
|
+
if (purposes.includes(AddressPurpose.Stacks) || purposes.includes(AddressPurpose.Starknet) || purposes.includes(AddressPurpose.Spark)) throw new Error("Only bitcoin addresses are supported");
|
|
1753
|
+
const accounts = await window.unisat.requestAccounts();
|
|
1754
|
+
const publicKey = await window.unisat.getPublicKey();
|
|
1755
|
+
const address = accounts[0];
|
|
1756
|
+
const addressType = (0, bitcoin_address_validation.getAddressInfo)(accounts[0]).type;
|
|
1757
|
+
const pk = addressType === bitcoin_address_validation.AddressType.p2tr ? publicKey.slice(2) : publicKey;
|
|
1758
|
+
const paymentAddress = {
|
|
1759
|
+
address,
|
|
1760
|
+
publicKey: pk,
|
|
1761
|
+
addressType,
|
|
1762
|
+
purpose: AddressPurpose.Payment,
|
|
1763
|
+
walletType: "software"
|
|
1764
|
+
};
|
|
1765
|
+
const ordinalsAddress = {
|
|
1766
|
+
address,
|
|
1767
|
+
publicKey: pk,
|
|
1768
|
+
addressType,
|
|
1769
|
+
purpose: AddressPurpose.Ordinals,
|
|
1770
|
+
walletType: "software"
|
|
1771
|
+
};
|
|
1772
|
+
const response = [];
|
|
1773
|
+
if (purposes.includes(AddressPurpose.Payment)) response.push({
|
|
1774
|
+
...paymentAddress,
|
|
1775
|
+
walletType: "software"
|
|
1776
|
+
});
|
|
1777
|
+
if (purposes.includes(AddressPurpose.Ordinals)) response.push({
|
|
1778
|
+
...ordinalsAddress,
|
|
1779
|
+
walletType: "software"
|
|
1780
|
+
});
|
|
1781
|
+
return response;
|
|
1782
|
+
}
|
|
1783
|
+
async signMessage(params) {
|
|
1784
|
+
const { message, address } = params;
|
|
1785
|
+
const addressType = (0, bitcoin_address_validation.getAddressInfo)(address).type;
|
|
1786
|
+
if ([bitcoin_address_validation.AddressType.p2wpkh, bitcoin_address_validation.AddressType.p2tr].includes(addressType)) return {
|
|
1787
|
+
address,
|
|
1788
|
+
messageHash: "",
|
|
1789
|
+
signature: await window.unisat.signMessage(message, "bip322-simple"),
|
|
1790
|
+
protocol: MessageSigningProtocols.BIP322
|
|
1791
|
+
};
|
|
1792
|
+
return {
|
|
1793
|
+
address,
|
|
1794
|
+
messageHash: "",
|
|
1795
|
+
signature: await window.unisat.signMessage(message, "ecdsa"),
|
|
1796
|
+
protocol: MessageSigningProtocols.ECDSA
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
async sendTransfer(params) {
|
|
1800
|
+
const { recipients } = params;
|
|
1801
|
+
if (recipients.length > 1) throw new Error("Only one recipient is supported by this wallet provider");
|
|
1802
|
+
return { txid: await window.unisat.sendBitcoin(recipients[0].address, recipients[0].amount) };
|
|
1803
|
+
}
|
|
1804
|
+
async signPsbt(params) {
|
|
1805
|
+
const { psbt, signInputs, broadcast } = params;
|
|
1806
|
+
const psbtHex = buffer.Buffer.from(psbt, "base64").toString("hex");
|
|
1807
|
+
const signedPsbt = await window.unisat.signPsbt(psbtHex, {
|
|
1808
|
+
autoFinalized: broadcast,
|
|
1809
|
+
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
1810
|
+
});
|
|
1811
|
+
const signedPsbtBase64 = buffer.Buffer.from(signedPsbt, "hex").toString("base64");
|
|
1812
|
+
let txid;
|
|
1813
|
+
if (broadcast) txid = await window.unisat.pushPsbt(signedPsbt);
|
|
1814
|
+
return {
|
|
1815
|
+
psbt: signedPsbtBase64,
|
|
1816
|
+
txid
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
requestInternal = async (method, params) => {
|
|
1820
|
+
try {
|
|
1821
|
+
switch (method) {
|
|
1822
|
+
case "getAccounts": return {
|
|
1823
|
+
status: "success",
|
|
1824
|
+
result: await this.getAccounts(params)
|
|
1825
|
+
};
|
|
1826
|
+
case "sendTransfer": return {
|
|
1827
|
+
status: "success",
|
|
1828
|
+
result: await this.sendTransfer(params)
|
|
1829
|
+
};
|
|
1830
|
+
case "signMessage": return {
|
|
1831
|
+
status: "success",
|
|
1832
|
+
result: await this.signMessage(params)
|
|
1833
|
+
};
|
|
1834
|
+
case "signPsbt": return {
|
|
1835
|
+
status: "success",
|
|
1836
|
+
result: await this.signPsbt(params)
|
|
1837
|
+
};
|
|
1838
|
+
default: {
|
|
1839
|
+
const error = {
|
|
1840
|
+
code: RpcErrorCode.METHOD_NOT_SUPPORTED,
|
|
1841
|
+
message: "Method not supported by the selected wallet"
|
|
1842
|
+
};
|
|
1843
|
+
console.error("Error calling the method", error);
|
|
1844
|
+
return {
|
|
1845
|
+
status: "error",
|
|
1846
|
+
error
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
} catch (error) {
|
|
1851
|
+
console.error("Error calling the method", error);
|
|
1852
|
+
return {
|
|
1853
|
+
status: "error",
|
|
1854
|
+
error: {
|
|
1855
|
+
code: error.code === 4001 ? RpcErrorCode.USER_REJECTION : RpcErrorCode.INTERNAL_ERROR,
|
|
1856
|
+
message: error.message ? error.message : "Wallet method call error",
|
|
1857
|
+
data: error
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
addListener = ({ eventName, cb }) => {
|
|
1863
|
+
switch (eventName) {
|
|
1864
|
+
case "accountChange": {
|
|
1865
|
+
const handler = () => {
|
|
1866
|
+
cb({ type: "accountChange" });
|
|
1867
|
+
};
|
|
1868
|
+
window.unisat.on("accountsChanged", handler);
|
|
1869
|
+
return () => {
|
|
1870
|
+
window.unisat.removeListener("accountsChanged", handler);
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
case "networkChange": {
|
|
1874
|
+
const handler = () => {
|
|
1875
|
+
cb({ type: "networkChange" });
|
|
1876
|
+
};
|
|
1877
|
+
window.unisat.on("networkChanged", handler);
|
|
1878
|
+
return () => {
|
|
1879
|
+
window.unisat.removeListener("networkChanged", handler);
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
default:
|
|
1883
|
+
console.error("Event not supported by the selected wallet");
|
|
1884
|
+
return () => {};
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
};
|
|
1888
|
+
|
|
1889
|
+
//#endregion
|
|
1890
|
+
//#region src/adapters/fordefi.ts
|
|
1891
|
+
var FordefiAdapter = class extends SatsConnectAdapter {
|
|
1892
|
+
id = DefaultAdaptersInfo.fordefi.id;
|
|
1893
|
+
requestInternal = async (method, params) => {
|
|
1894
|
+
const provider = getProviderById(this.id);
|
|
1895
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1896
|
+
if (!method) throw new Error("A wallet method is required");
|
|
1897
|
+
return await provider.request(method, params);
|
|
1898
|
+
};
|
|
1899
|
+
addListener = ({ eventName, cb }) => {
|
|
1900
|
+
const provider = getProviderById(this.id);
|
|
1901
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1902
|
+
if (!provider.addListener) {
|
|
1903
|
+
console.error(`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`);
|
|
1904
|
+
return () => {};
|
|
1905
|
+
}
|
|
1906
|
+
return provider.addListener(eventName, cb);
|
|
1907
|
+
};
|
|
1908
|
+
};
|
|
1909
|
+
|
|
1910
|
+
//#endregion
|
|
1911
|
+
//#region src/adapters/BaseAdapter.ts
|
|
1912
|
+
var BaseAdapter = class extends SatsConnectAdapter {
|
|
1913
|
+
id = "";
|
|
1914
|
+
constructor(providerId) {
|
|
1915
|
+
super();
|
|
1916
|
+
this.id = providerId;
|
|
1917
|
+
}
|
|
1918
|
+
requestInternal = async (method, params) => {
|
|
1919
|
+
return request(method, params, this.id);
|
|
1920
|
+
};
|
|
1921
|
+
addListener = (..._args) => {
|
|
1922
|
+
throw new Error("Method not supported for `BaseAdapter`.");
|
|
1923
|
+
};
|
|
1924
|
+
};
|
|
1925
|
+
|
|
1926
|
+
//#endregion
|
|
1927
|
+
//#region src/adapters/index.ts
|
|
1928
|
+
const DefaultAdaptersInfo = {
|
|
1929
|
+
fordefi: {
|
|
1930
|
+
id: "FordefiProviders.UtxoProvider",
|
|
1931
|
+
name: "Fordefi",
|
|
1932
|
+
webUrl: "https://www.fordefi.com/",
|
|
1933
|
+
chromeWebStoreUrl: "https://chromewebstore.google.com/detail/fordefi/hcmehenccjdmfbojapcbcofkgdpbnlle",
|
|
1934
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzEzNDk0XzY2MjU0KSI+CjxwYXRoIGQ9Ik0xMC44NzY5IDE1LjYzNzhIMS41VjE4LjM5OUMxLjUgMTkuODAxMyAyLjYzNDQ3IDIwLjkzOCA0LjAzMzkyIDIwLjkzOEg4LjI0OTkyTDEwLjg3NjkgMTUuNjM3OFoiIGZpbGw9IiM3OTk0RkYiLz4KPHBhdGggZD0iTTEuNSA5Ljc3NTUxSDE5LjA1MTZMMTcuMDEzOSAxMy44NzExSDEuNVY5Ljc3NTUxWiIgZmlsbD0iIzQ4NkRGRiIvPgo8cGF0aCBkPSJNNy42NTk5NiAzSDEuNTI0NDFWOC4wMDcwNEgyMi40NjEyVjNIMTYuMzI1NlY2LjczOTQ0SDE1LjA2MDZWM0g4LjkyNTAyVjYuNzM5NDRINy42NTk5NlYzWiIgZmlsbD0iIzVDRDFGQSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEzNDk0XzY2MjU0Ij4KPHJlY3Qgd2lkdGg9IjIxIiBoZWlnaHQ9IjE4IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMS41IDMpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
1935
|
+
},
|
|
1936
|
+
xverse: {
|
|
1937
|
+
id: "XverseProviders.BitcoinProvider",
|
|
1938
|
+
name: "Xverse",
|
|
1939
|
+
webUrl: "https://www.xverse.app/",
|
|
1940
|
+
googlePlayStoreUrl: "https://play.google.com/store/apps/details?id=com.secretkeylabs.xverse",
|
|
1941
|
+
iOSAppStoreUrl: "https://apps.apple.com/app/xverse-bitcoin-web3-wallet/id1552272513",
|
|
1942
|
+
chromeWebStoreUrl: "https://chromewebstore.google.com/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg",
|
|
1943
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgdmlld0JveD0iMCAwIDEwMiAxMDIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGlkPSJJY29uX0FydCAoRWRpdCBNZSkiPgo8cmVjdCB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgZmlsbD0iIzE4MTgxOCIvPgo8ZyBpZD0iTG9nby9FbWJsZW0iIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMF8xMjIzKSI+CjxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik03NC42NTQyIDczLjg4ODNWNjUuMjMxMkM3NC42NTQyIDY0Ljg4OCA3NC41MTc3IDY0LjU2MDYgNzQuMjc0NSA2NC4zMTc0TDM3LjQzOTcgMjcuNDgyNUMzNy4xOTY1IDI3LjIzOTIgMzYuODY5MSAyNy4xMDI4IDM2LjUyNTggMjcuMTAyOEgyNy44NjlDMjcuNDQxNiAyNy4xMDI4IDI3LjA5MzggMjcuNDUwNiAyNy4wOTM4IDI3Ljg3OFYzNS45MjExQzI3LjA5MzggMzYuMjY0NCAyNy4yMzAyIDM2LjU5MTcgMjcuNDczNCAzNi44MzVMNDAuNjk1MiA1MC4wNTY3QzQwLjk5NzUgNTAuMzU5MSA0MC45OTc1IDUwLjg1MDEgNDAuNjk1MiA1MS4xNTI0TDI3LjMyMTEgNjQuNTI2NUMyNy4xNzU2IDY0LjY3MiAyNy4wOTM4IDY0Ljg2OTggMjcuMDkzOCA2NS4wNzQ0VjczLjg4ODNDMjcuMDkzOCA3NC4zMTUzIDI3LjQ0MTYgNzQuNjYzNSAyNy44NjkgNzQuNjYzNUg0Mi4zMzQyQzQyLjc2MTYgNzQuNjYzNSA0My4xMDk0IDc0LjMxNTMgNDMuMTA5NCA3My44ODgzVjY4LjY5NThDNDMuMTA5NCA2OC40OTEyIDQzLjE5MTIgNjguMjkzNSA0My4zMzY4IDY4LjE0NzlMNTAuNTExNCA2MC45NzMzQzUwLjgxMzggNjAuNjcwOSA1MS4zMDQ4IDYwLjY3MDkgNTEuNjA3MiA2MC45NzMzTDY0LjkxOTggNzQuMjg2MUM2NS4xNjMxIDc0LjUyOTMgNjUuNDkwNCA3NC42NjU4IDY1LjgzMzcgNzQuNjY1OEg3My44NzY3Qzc0LjMwNDIgNzQuNjY1OCA3NC42NTE5IDc0LjMxNzYgNzQuNjUxOSA3My44OTA2TDc0LjY1NDIgNzMuODg4M1oiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGlkPSJWZWN0b3JfMiIgZD0iTTU1LjM1OCAzOC41NjcySDYyLjYwMzFDNjMuMDMyOCAzOC41NjcyIDYzLjM4MjkgMzguOTE3MyA2My4zODI5IDM5LjM0NjlWNDYuNTkyMUM2My4zODI5IDQ3LjI4NzcgNjQuMjI0IDQ3LjYzNTUgNjQuNzE1MSA0Ny4xNDIyTDc0LjY1NDEgMzcuMTg3M0M3NC43OTk0IDM3LjA0MTggNzQuODgxNiAzNi44NDQgNzQuODgxNiAzNi42MzcxVjI3LjkxODlDNzQuODgxNiAyNy40ODkyIDc0LjUzMzQgMjcuMTM5MSA3NC4xMDE3IDI3LjEzOTFMNjUuMjUzOCAyNy4xMjc3QzY1LjA0NyAyNy4xMjc3IDY0Ljg0OTIgMjcuMjA5NiA2NC43MDE0IDI3LjM1NTFMNTQuODA1NiAzNy4yMzVDNTQuMzE0NSAzNy43MjYgNTQuNjYyMyAzOC41NjcyIDU1LjM1NTcgMzguNTY3Mkg1NS4zNThaIiBmaWxsPSIjRUU3QTMwIi8+CjwvZz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF8yMF8xMjIzIj4KPHJlY3Qgd2lkdGg9IjQ3LjgxMjUiIGhlaWdodD0iNDcuODEyNSIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDI3LjA5MzggMjcuMDkzOCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K"
|
|
1944
|
+
},
|
|
1945
|
+
unisat: {
|
|
1946
|
+
id: "unisat",
|
|
1947
|
+
name: "Unisat",
|
|
1948
|
+
webUrl: "https://unisat.io/",
|
|
1949
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDE4MCAxODAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxODAiIGhlaWdodD0iMTgwIiBmaWxsPSJibGFjayIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMTAwNTBfNDE3MSkiPgo8cGF0aCBkPSJNMTEzLjY2IDI5LjI4OTdMMTQzLjk3IDU5LjMwOTdDMTQ2LjU1IDYxLjg1OTcgMTQ3LjgyIDY0LjQzOTcgMTQ3Ljc4IDY3LjAzOTdDMTQ3Ljc0IDY5LjYzOTcgMTQ2LjYzIDcyLjAwOTcgMTQ0LjQ2IDc0LjE1OTdDMTQyLjE5IDc2LjQwOTcgMTM5Ljc0IDc3LjU0OTcgMTM3LjEyIDc3LjU5OTdDMTM0LjUgNzcuNjM5NyAxMzEuOSA3Ni4zNzk3IDEyOS4zMiA3My44Mjk3TDk4LjMxOTkgNDMuMTI5N0M5NC43OTk5IDM5LjYzOTcgOTEuMzk5OSAzNy4xNjk3IDg4LjEyOTkgMzUuNzE5N0M4NC44NTk5IDM0LjI2OTcgODEuNDE5OSAzNC4wMzk3IDc3LjgxOTkgMzUuMDM5N0M3NC4yMDk5IDM2LjAyOTcgNzAuMzM5OSAzOC41Nzk3IDY2LjE4OTkgNDIuNjc5N0M2MC40Njk5IDQ4LjM0OTcgNTcuNzM5OSA1My42Njk3IDU4LjAxOTkgNTguNjM5N0M1OC4yOTk5IDYzLjYwOTcgNjEuMTM5OSA2OC43Njk3IDY2LjUyOTkgNzQuMDk5N0w5Ny43Nzk5IDEwNS4wNkMxMDAuMzkgMTA3LjY0IDEwMS42NyAxMTAuMjIgMTAxLjYzIDExMi43OEMxMDEuNTkgMTE1LjM1IDEwMC40NyAxMTcuNzIgOTguMjU5OSAxMTkuOTFDOTYuMDU5OSAxMjIuMDkgOTMuNjI5OSAxMjMuMjMgOTAuOTg5OSAxMjMuMzJDODguMzQ5OSAxMjMuNDEgODUuNzE5OSAxMjIuMTYgODMuMTE5OSAxMTkuNThMNTIuODA5OSA4OS41NTk3QzQ3Ljg3OTkgODQuNjc5NyA0NC4zMTk5IDgwLjA1OTcgNDIuMTI5OSA3NS42OTk3QzM5LjkzOTkgNzEuMzM5NyAzOS4xMTk5IDY2LjQwOTcgMzkuNjg5OSA2MC45MDk3QzQwLjE5OTkgNTYuMTk5NyA0MS43MDk5IDUxLjYzOTcgNDQuMjI5OSA0Ny4yMTk3QzQ2LjczOTkgNDIuNzk5NyA1MC4zMzk5IDM4LjI3OTcgNTUuMDA5OSAzMy42NDk3QzYwLjU2OTkgMjguMTM5NyA2NS44Nzk5IDIzLjkxOTcgNzAuOTM5OSAyMC45Nzk3Qzc1Ljk4OTkgMTguMDM5NyA4MC44Nzk5IDE2LjQwOTcgODUuNTk5OSAxNi4wNjk3QzkwLjMyOTkgMTUuNzI5NyA5NC45ODk5IDE2LjY2OTcgOTkuNTk5OSAxOC44ODk3QzEwNC4yMSAyMS4xMDk3IDEwOC44OSAyNC41Njk3IDExMy42NSAyOS4yODk3SDExMy42NloiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8xMDA1MF80MTcxKSIvPgo8cGF0aCBkPSJNNjYuMTA5OSAxNTAuNDJMMzUuODA5OSAxMjAuNEMzMy4yMjk5IDExNy44NCAzMS45NTk5IDExNS4yNyAzMS45OTk5IDExMi42N0MzMi4wMzk5IDExMC4wNyAzMy4xNDk5IDEwNy43IDM1LjMxOTkgMTA1LjU1QzM3LjU4OTkgMTAzLjMgNDAuMDM5OSAxMDIuMTYgNDIuNjU5OSAxMDIuMTFDNDUuMjc5OSAxMDIuMDcgNDcuODc5OSAxMDMuMzIgNTAuNDU5OSAxMDUuODhMODEuNDQ5OSAxMzYuNThDODQuOTc5OSAxNDAuMDcgODguMzY5OSAxNDIuNTQgOTEuNjM5OSAxNDMuOTlDOTQuOTA5OSAxNDUuNDQgOTguMzQ5OSAxNDUuNjYgMTAxLjk2IDE0NC42N0MxMDUuNTcgMTQzLjY4IDEwOS40NCAxNDEuMTMgMTEzLjU5IDEzNy4wMkMxMTkuMzEgMTMxLjM1IDEyMi4wNCAxMjYuMDMgMTIxLjc2IDEyMS4wNkMxMjEuNDggMTE2LjA5IDExOC42NCAxMTAuOTMgMTEzLjI1IDEwNS41OUw5Ni41OTk5IDg5LjI0MDFDOTMuOTg5OSA4Ni42NjAxIDkyLjcwOTkgODQuMDgwMSA5Mi43NDk5IDgxLjUyMDFDOTIuNzg5OSA3OC45NTAxIDkzLjkwOTkgNzYuNTgwMSA5Ni4xMTk5IDc0LjM5MDFDOTguMzE5OSA3Mi4yMTAxIDEwMC43NSA3MS4wNzAxIDEwMy4zOSA3MC45ODAxQzEwNi4wMyA3MC44OTAxIDEwOC42NiA3Mi4xNDAxIDExMS4yNiA3NC43MjAxTDEyNi45NiA5MC4xMzAxQzEzMS44OSA5NS4wMTAxIDEzNS40NSA5OS42MzAxIDEzNy42NCAxMDMuOTlDMTM5LjgzIDEwOC4zNSAxNDAuNjUgMTEzLjI4IDE0MC4wOCAxMTguNzhDMTM5LjU3IDEyMy40OSAxMzguMDYgMTI4LjA1IDEzNS41NCAxMzIuNDdDMTMzLjAzIDEzNi44OSAxMjkuNDMgMTQxLjQxIDEyNC43NiAxNDYuMDRDMTE5LjIgMTUxLjU1IDExMy44OSAxNTUuNzcgMTA4LjgzIDE1OC43MUMxMDMuNzcgMTYxLjY1IDk4Ljg3OTkgMTYzLjI5IDk0LjE0OTkgMTYzLjYzQzg5LjQxOTkgMTYzLjk3IDg0Ljc1OTkgMTYzLjAzIDgwLjE0OTkgMTYwLjgxQzc1LjUzOTkgMTU4LjU5IDcwLjg1OTkgMTU1LjEzIDY2LjA5OTkgMTUwLjQxTDY2LjEwOTkgMTUwLjQyWiIgZmlsbD0idXJsKCNwYWludDFfbGluZWFyXzEwMDUwXzQxNzEpIi8+CjxwYXRoIGQ9Ik04NS4wMDk5IDcyLjk1OTJDOTEuMTU2OCA3Mi45NTkyIDk2LjEzOTkgNjcuOTc2MSA5Ni4xMzk5IDYxLjgyOTJDOTYuMTM5OSA1NS42ODIzIDkxLjE1NjggNTAuNjk5MiA4NS4wMDk5IDUwLjY5OTJDNzguODYzIDUwLjY5OTIgNzMuODc5OSA1NS42ODIzIDczLjg3OTkgNjEuODI5MkM3My44Nzk5IDY3Ljk3NjEgNzguODYzIDcyLjk1OTIgODUuMDA5OSA3Mi45NTkyWiIgZmlsbD0idXJsKCNwYWludDJfcmFkaWFsXzEwMDUwXzQxNzEpIi8+CjwvZz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8xMDA1MF80MTcxIiB4MT0iMTM4Ljk4NSIgeTE9IjQ2Ljc3OTUiIHgyPSI0NS4wNTI5IiB5Mj0iODguNTIzMyIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMjAxQzFCIi8+CjxzdG9wIG9mZnNldD0iMC4zNiIgc3RvcC1jb2xvcj0iIzc3MzkwRCIvPgo8c3RvcCBvZmZzZXQ9IjAuNjciIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRjRCODUyIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQxX2xpbmVhcl8xMDA1MF80MTcxIiB4MT0iNDMuMzgxMiIgeTE9IjEzNC4xNjciIHgyPSIxNTIuMjMxIiB5Mj0iMTAxLjc3MSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMUYxRDFDIi8+CjxzdG9wIG9mZnNldD0iMC4zNyIgc3RvcC1jb2xvcj0iIzc3MzkwRCIvPgo8c3RvcCBvZmZzZXQ9IjAuNjciIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRjRGQjUyIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxyYWRpYWxHcmFkaWVudCBpZD0icGFpbnQyX3JhZGlhbF8xMDA1MF80MTcxIiBjeD0iMCIgY3k9IjAiIHI9IjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDg1LjAwOTkgNjEuODM5Mikgc2NhbGUoMTEuMTMpIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0Y0Qjg1MiIvPgo8c3RvcCBvZmZzZXQ9IjAuMzMiIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIwLjY0IiBzdG9wLWNvbG9yPSIjNzczOTBEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzIxMUMxRCIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEwMDUwXzQxNzEiPgo8cmVjdCB3aWR0aD0iMTE1Ljc3IiBoZWlnaHQ9IjE0Ny43IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMzIgMTYpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
const defaultAdapters = {
|
|
1953
|
+
[DefaultAdaptersInfo.fordefi.id]: FordefiAdapter,
|
|
1954
|
+
[DefaultAdaptersInfo.xverse.id]: XverseAdapter,
|
|
1955
|
+
[DefaultAdaptersInfo.unisat.id]: UnisatAdapter
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
//#endregion
|
|
1959
|
+
//#region src/capabilities/index.ts
|
|
1960
|
+
const extractOrValidateCapabilities = (provider, reportedCapabilities) => {
|
|
1961
|
+
const validateCapability = (capability) => {
|
|
1962
|
+
if (!provider[capability]) return false;
|
|
1963
|
+
if (reportedCapabilities && !reportedCapabilities.has(capability)) return false;
|
|
1964
|
+
return true;
|
|
1965
|
+
};
|
|
1966
|
+
const capabilityMap = {
|
|
1967
|
+
request: validateCapability("request"),
|
|
1968
|
+
connect: validateCapability("connect"),
|
|
1969
|
+
signMessage: validateCapability("signMessage"),
|
|
1970
|
+
signTransaction: validateCapability("signTransaction"),
|
|
1971
|
+
sendBtcTransaction: validateCapability("sendBtcTransaction"),
|
|
1972
|
+
createInscription: validateCapability("createInscription"),
|
|
1973
|
+
createRepeatInscriptions: validateCapability("createRepeatInscriptions"),
|
|
1974
|
+
signMultipleTransactions: validateCapability("signMultipleTransactions"),
|
|
1975
|
+
addListener: validateCapability("addListener")
|
|
1976
|
+
};
|
|
1977
|
+
return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
|
|
1978
|
+
if (value) return [...acc, capability];
|
|
1979
|
+
return acc;
|
|
1980
|
+
}, []);
|
|
1981
|
+
};
|
|
1982
|
+
const getCapabilities = async (options) => {
|
|
1983
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1984
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
1985
|
+
if (provider.getCapabilities) try {
|
|
1986
|
+
const response = await provider.getCapabilities(request$1);
|
|
1987
|
+
options.onFinish?.(extractOrValidateCapabilities(provider, new Set(response)));
|
|
1988
|
+
} catch (error) {
|
|
1989
|
+
console.error("[Connect] Error during capabilities request", error);
|
|
1990
|
+
}
|
|
1991
|
+
try {
|
|
1992
|
+
const inferredCapabilities = extractOrValidateCapabilities(provider);
|
|
1993
|
+
options.onFinish?.(inferredCapabilities);
|
|
1994
|
+
} catch (error) {
|
|
1995
|
+
console.error("[Connect] Error during capabilities request", error);
|
|
1996
|
+
options.onCancel?.();
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
//#endregion
|
|
2001
|
+
//#region src/inscriptions/utils.ts
|
|
2002
|
+
const MAX_CONTENT_LENGTH_MAINNET = 4e5;
|
|
2003
|
+
const MAX_CONTENT_LENGTH_TESTNET = 6e4;
|
|
2004
|
+
const validateInscriptionPayload = (payload) => {
|
|
2005
|
+
const { contentType, content, payloadType, network, appFeeAddress, appFee } = payload;
|
|
2006
|
+
if (!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(contentType)) throw new Error("Invalid content type detected");
|
|
2007
|
+
if (!content || content.length === 0) throw new Error("Empty content not allowed");
|
|
2008
|
+
if (!payloadType || payloadType !== "BASE_64" && payloadType !== "PLAIN_TEXT") throw new Error("Empty invalid payloadType specified");
|
|
2009
|
+
if (content.length > (network.type === "Mainnet" ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)) throw new Error("Content too large");
|
|
2010
|
+
if ((appFeeAddress?.length ?? 0) > 0 && (appFee ?? 0) <= 0) throw new Error("Invalid combination of app fee address and fee provided");
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
//#endregion
|
|
2014
|
+
//#region src/inscriptions/createInscription.ts
|
|
2015
|
+
const createInscription = async (options) => {
|
|
2016
|
+
const { getProvider } = options;
|
|
2017
|
+
const provider = await getProviderOrThrow(getProvider);
|
|
2018
|
+
validateInscriptionPayload(options.payload);
|
|
2019
|
+
try {
|
|
2020
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
2021
|
+
const response = await provider.createInscription(request$1);
|
|
2022
|
+
options.onFinish?.(response);
|
|
2023
|
+
} catch (error) {
|
|
2024
|
+
console.error("[Connect] Error during create inscription", error);
|
|
2025
|
+
options.onCancel?.();
|
|
2026
|
+
}
|
|
2027
|
+
};
|
|
2028
|
+
|
|
2029
|
+
//#endregion
|
|
2030
|
+
//#region src/inscriptions/createRepeatInscriptions.ts
|
|
2031
|
+
const createRepeatInscriptions = async (options) => {
|
|
2032
|
+
const { getProvider } = options;
|
|
2033
|
+
const provider = await getProviderOrThrow(getProvider);
|
|
2034
|
+
validateInscriptionPayload(options.payload);
|
|
2035
|
+
try {
|
|
2036
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
2037
|
+
const response = await provider.createRepeatInscriptions(request$1);
|
|
2038
|
+
options.onFinish?.(response);
|
|
2039
|
+
} catch (error) {
|
|
2040
|
+
console.error("[Connect] Error during create repeat inscriptions", error);
|
|
2041
|
+
options.onCancel?.();
|
|
2042
|
+
}
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
//#endregion
|
|
2046
|
+
//#region src/messages/index.ts
|
|
2047
|
+
const signMessage = async (options) => {
|
|
2048
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
2049
|
+
const { address, message } = options.payload;
|
|
2050
|
+
if (!address) throw new Error("An address is required to sign a message");
|
|
2051
|
+
if (!message) throw new Error("A message to be signed is required");
|
|
2052
|
+
try {
|
|
2053
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
2054
|
+
const response = await provider.signMessage(request$1);
|
|
2055
|
+
options.onFinish?.(response);
|
|
2056
|
+
} catch (error) {
|
|
2057
|
+
console.error("[Connect] Error during sign message request", error);
|
|
2058
|
+
options.onCancel?.();
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2062
|
+
//#endregion
|
|
2063
|
+
//#region src/transactions/sendBtcTransaction.ts
|
|
2064
|
+
const serializer = (recipient) => {
|
|
2065
|
+
return recipient.map((value) => {
|
|
2066
|
+
const { address, amountSats } = value;
|
|
2067
|
+
return {
|
|
2068
|
+
address,
|
|
2069
|
+
amountSats: amountSats.toString()
|
|
2070
|
+
};
|
|
2071
|
+
});
|
|
2072
|
+
};
|
|
2073
|
+
const sendBtcTransaction = async (options) => {
|
|
2074
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
2075
|
+
const { recipients, senderAddress, network, message } = options.payload;
|
|
2076
|
+
if (!recipients || recipients.length === 0) throw new Error("At least one recipient is required");
|
|
2077
|
+
if (recipients.some((item) => typeof item.address !== "string" || typeof item.amountSats !== "bigint")) throw new Error("Incorrect recipient format");
|
|
2078
|
+
if (!senderAddress) throw new Error("The sender address is required");
|
|
2079
|
+
try {
|
|
2080
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)({
|
|
2081
|
+
network,
|
|
2082
|
+
senderAddress,
|
|
2083
|
+
message,
|
|
2084
|
+
recipients: serializer(recipients)
|
|
2085
|
+
});
|
|
2086
|
+
const response = await provider.sendBtcTransaction(request$1);
|
|
2087
|
+
options.onFinish?.(response);
|
|
2088
|
+
} catch (error) {
|
|
2089
|
+
console.error("[Connect] Error during send BTC transaction request", error);
|
|
2090
|
+
options.onCancel?.();
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
//#endregion
|
|
2095
|
+
//#region src/transactions/signTransaction.ts
|
|
2096
|
+
const signTransaction = async (options) => {
|
|
2097
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
2098
|
+
const { psbtBase64, inputsToSign } = options.payload;
|
|
2099
|
+
if (!psbtBase64) throw new Error("A value for psbtBase64 representing the tx hash is required");
|
|
2100
|
+
if (!inputsToSign) throw new Error("An array specifying the inputs to be signed by the wallet is required");
|
|
2101
|
+
try {
|
|
2102
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
2103
|
+
const response = await provider.signTransaction(request$1);
|
|
2104
|
+
options.onFinish?.(response);
|
|
2105
|
+
} catch (error) {
|
|
2106
|
+
console.error("[Connect] Error during sign transaction request", error);
|
|
2107
|
+
options.onCancel?.();
|
|
2108
|
+
}
|
|
2109
|
+
};
|
|
2110
|
+
|
|
2111
|
+
//#endregion
|
|
2112
|
+
//#region src/transactions/signMultipleTransactions.ts
|
|
2113
|
+
const signMultipleTransactions = async (options) => {
|
|
2114
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
2115
|
+
const { psbts } = options.payload;
|
|
2116
|
+
if (!psbts || !psbts.length) throw new Error("psbts array is required");
|
|
2117
|
+
if (psbts.length > 100) throw new Error("psbts array must contain less than 100 psbts");
|
|
2118
|
+
try {
|
|
2119
|
+
const request$1 = (0, jsontokens.createUnsecuredToken)(options.payload);
|
|
2120
|
+
const response = await provider.signMultipleTransactions(request$1);
|
|
2121
|
+
options.onFinish?.(response);
|
|
2122
|
+
} catch (error) {
|
|
2123
|
+
console.error("[Connect] Error during sign Multiple transactions request", error);
|
|
2124
|
+
options.onCancel?.();
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
|
|
2128
|
+
//#endregion
|
|
2129
|
+
exports.AddressPurpose = AddressPurpose;
|
|
2130
|
+
exports.AddressType = AddressType;
|
|
2131
|
+
exports.BaseAdapter = BaseAdapter;
|
|
2132
|
+
exports.BitcoinNetworkType = BitcoinNetworkType;
|
|
2133
|
+
exports.DefaultAdaptersInfo = DefaultAdaptersInfo;
|
|
2134
|
+
exports.MessageSigningProtocols = MessageSigningProtocols;
|
|
2135
|
+
exports.PermissionRequestParams = PermissionRequestParams;
|
|
2136
|
+
exports.ProviderPlatform = ProviderPlatform;
|
|
2137
|
+
exports.RpcErrorCode = RpcErrorCode;
|
|
2138
|
+
exports.RpcIdSchema = RpcIdSchema;
|
|
2139
|
+
exports.SatsConnectAdapter = SatsConnectAdapter;
|
|
2140
|
+
exports.SparkNetworkType = SparkNetworkType;
|
|
2141
|
+
exports.StacksNetworkType = StacksNetworkType;
|
|
2142
|
+
exports.StarknetNetworkType = StarknetNetworkType;
|
|
2143
|
+
exports.accountActionsSchema = accountActionsSchema;
|
|
2144
|
+
exports.accountChangeEventName = accountChangeEventName;
|
|
2145
|
+
exports.accountChangeSchema = accountChangeSchema;
|
|
2146
|
+
exports.accountPermissionSchema = accountPermissionSchema;
|
|
2147
|
+
exports.addListener = addListener;
|
|
2148
|
+
exports.addNetworkMethodName = addNetworkMethodName;
|
|
2149
|
+
exports.addNetworkParamsSchema = addNetworkParamsSchema;
|
|
2150
|
+
exports.addNetworkRequestMessageSchema = addNetworkRequestMessageSchema;
|
|
2151
|
+
exports.addNetworkResultSchema = addNetworkResultSchema;
|
|
2152
|
+
exports.addressSchema = addressSchema;
|
|
2153
|
+
exports.bitcoinNetworkDefinitionSchema = bitcoinNetworkDefinitionSchema;
|
|
2154
|
+
exports.changeNetworkByIdMethodName = changeNetworkByIdMethodName;
|
|
2155
|
+
exports.changeNetworkByIdParamsSchema = changeNetworkByIdParamsSchema;
|
|
2156
|
+
exports.changeNetworkByIdRequestMessageSchema = changeNetworkByIdRequestMessageSchema;
|
|
2157
|
+
exports.changeNetworkByIdResultSchema = changeNetworkByIdResultSchema;
|
|
2158
|
+
exports.changeNetworkMethodName = changeNetworkMethodName;
|
|
2159
|
+
exports.changeNetworkParamsSchema = changeNetworkParamsSchema;
|
|
2160
|
+
exports.changeNetworkRequestMessageSchema = changeNetworkRequestMessageSchema;
|
|
2161
|
+
exports.changeNetworkResultSchema = changeNetworkResultSchema;
|
|
2162
|
+
exports.connectMethodName = connectMethodName;
|
|
2163
|
+
exports.connectParamsSchema = connectParamsSchema;
|
|
2164
|
+
exports.connectRequestMessageSchema = connectRequestMessageSchema;
|
|
2165
|
+
exports.connectResultSchema = connectResultSchema;
|
|
2166
|
+
exports.createInscription = createInscription;
|
|
2167
|
+
exports.createRepeatInscriptions = createRepeatInscriptions;
|
|
2168
|
+
exports.defaultAdapters = defaultAdapters;
|
|
2169
|
+
exports.disconnectEventName = disconnectEventName;
|
|
2170
|
+
exports.disconnectMethodName = disconnectMethodName;
|
|
2171
|
+
exports.disconnectParamsSchema = disconnectParamsSchema;
|
|
2172
|
+
exports.disconnectRequestMessageSchema = disconnectRequestMessageSchema;
|
|
2173
|
+
exports.disconnectResultSchema = disconnectResultSchema;
|
|
2174
|
+
exports.disconnectSchema = disconnectSchema;
|
|
2175
|
+
exports.getAccountMethodName = getAccountMethodName;
|
|
2176
|
+
exports.getAccountParamsSchema = getAccountParamsSchema;
|
|
2177
|
+
exports.getAccountRequestMessageSchema = getAccountRequestMessageSchema;
|
|
2178
|
+
exports.getAccountResultSchema = getAccountResultSchema;
|
|
2179
|
+
exports.getAccountsMethodName = getAccountsMethodName;
|
|
2180
|
+
exports.getAccountsParamsSchema = getAccountsParamsSchema;
|
|
2181
|
+
exports.getAccountsRequestMessageSchema = getAccountsRequestMessageSchema;
|
|
2182
|
+
exports.getAccountsResultSchema = getAccountsResultSchema;
|
|
2183
|
+
exports.getAddress = getAddress;
|
|
2184
|
+
exports.getAddressesMethodName = getAddressesMethodName;
|
|
2185
|
+
exports.getAddressesParamsSchema = getAddressesParamsSchema;
|
|
2186
|
+
exports.getAddressesRequestMessageSchema = getAddressesRequestMessageSchema;
|
|
2187
|
+
exports.getAddressesResultSchema = getAddressesResultSchema;
|
|
2188
|
+
exports.getBalanceMethodName = getBalanceMethodName;
|
|
2189
|
+
exports.getBalanceParamsSchema = getBalanceParamsSchema;
|
|
2190
|
+
exports.getBalanceRequestMessageSchema = getBalanceRequestMessageSchema;
|
|
2191
|
+
exports.getBalanceResultSchema = getBalanceResultSchema;
|
|
2192
|
+
exports.getCapabilities = getCapabilities;
|
|
2193
|
+
exports.getCurrentPermissionsMethodName = getCurrentPermissionsMethodName;
|
|
2194
|
+
exports.getCurrentPermissionsParamsSchema = getCurrentPermissionsParamsSchema;
|
|
2195
|
+
exports.getCurrentPermissionsRequestMessageSchema = getCurrentPermissionsRequestMessageSchema;
|
|
2196
|
+
exports.getCurrentPermissionsResultSchema = getCurrentPermissionsResultSchema;
|
|
2197
|
+
exports.getDefaultProvider = getDefaultProvider;
|
|
2198
|
+
exports.getInfoMethodName = getInfoMethodName;
|
|
2199
|
+
exports.getInfoParamsSchema = getInfoParamsSchema;
|
|
2200
|
+
exports.getInfoRequestMessageSchema = getInfoRequestMessageSchema;
|
|
2201
|
+
exports.getInfoResultSchema = getInfoResultSchema;
|
|
2202
|
+
exports.getInscriptionsMethodName = getInscriptionsMethodName;
|
|
2203
|
+
exports.getInscriptionsParamsSchema = getInscriptionsParamsSchema;
|
|
2204
|
+
exports.getInscriptionsRequestMessageSchema = getInscriptionsRequestMessageSchema;
|
|
2205
|
+
exports.getInscriptionsResultSchema = getInscriptionsResultSchema;
|
|
2206
|
+
exports.getNetworksMethodName = getNetworksMethodName;
|
|
2207
|
+
exports.getNetworksParamsSchema = getNetworksParamsSchema;
|
|
2208
|
+
exports.getNetworksRequestMessageSchema = getNetworksRequestMessageSchema;
|
|
2209
|
+
exports.getNetworksResultSchema = getNetworksResultSchema;
|
|
2210
|
+
exports.getProviderById = getProviderById;
|
|
2211
|
+
exports.getProviderOrThrow = getProviderOrThrow;
|
|
2212
|
+
exports.getProviders = getProviders;
|
|
2213
|
+
exports.getSupportedWallets = getSupportedWallets;
|
|
2214
|
+
exports.getWalletTypeMethodName = getWalletTypeMethodName;
|
|
2215
|
+
exports.getWalletTypeParamsSchema = getWalletTypeParamsSchema;
|
|
2216
|
+
exports.getWalletTypeRequestMessageSchema = getWalletTypeRequestMessageSchema;
|
|
2217
|
+
exports.getWalletTypeResultSchema = getWalletTypeResultSchema;
|
|
2218
|
+
exports.isProviderInstalled = isProviderInstalled;
|
|
2219
|
+
exports.networkChangeEventName = networkChangeEventName;
|
|
2220
|
+
exports.networkChangeSchema = networkChangeSchema;
|
|
2221
|
+
exports.newNetworkDefinitionSchema = newNetworkDefinitionSchema;
|
|
2222
|
+
exports.permission = permission;
|
|
2223
|
+
exports.removeDefaultProvider = removeDefaultProvider;
|
|
2224
|
+
exports.renouncePermissionsMethodName = renouncePermissionsMethodName;
|
|
2225
|
+
exports.renouncePermissionsParamsSchema = renouncePermissionsParamsSchema;
|
|
2226
|
+
exports.renouncePermissionsRequestMessageSchema = renouncePermissionsRequestMessageSchema;
|
|
2227
|
+
exports.renouncePermissionsResultSchema = renouncePermissionsResultSchema;
|
|
2228
|
+
exports.request = request;
|
|
2229
|
+
exports.requestPermissionsMethodName = requestPermissionsMethodName;
|
|
2230
|
+
exports.requestPermissionsParamsSchema = requestPermissionsParamsSchema;
|
|
2231
|
+
exports.requestPermissionsRequestMessageSchema = requestPermissionsRequestMessageSchema;
|
|
2232
|
+
exports.requestPermissionsResultSchema = requestPermissionsResultSchema;
|
|
2233
|
+
exports.rpcErrorResponseMessageSchema = rpcErrorResponseMessageSchema;
|
|
2234
|
+
exports.rpcRequestMessageSchema = rpcRequestMessageSchema;
|
|
2235
|
+
exports.rpcResponseMessageSchema = rpcResponseMessageSchema;
|
|
2236
|
+
exports.rpcSuccessResponseMessageSchema = rpcSuccessResponseMessageSchema;
|
|
2237
|
+
exports.runesEtchMethodName = runesEtchMethodName;
|
|
2238
|
+
exports.runesEtchParamsSchema = runesEtchParamsSchema;
|
|
2239
|
+
exports.runesEtchRequestMessageSchema = runesEtchRequestMessageSchema;
|
|
2240
|
+
exports.runesEtchResultSchema = runesEtchResultSchema;
|
|
2241
|
+
exports.runesGetBalanceMethodName = runesGetBalanceMethodName;
|
|
2242
|
+
exports.runesGetBalanceParamsSchema = runesGetBalanceParamsSchema;
|
|
2243
|
+
exports.runesGetBalanceRequestMessageSchema = runesGetBalanceRequestMessageSchema;
|
|
2244
|
+
exports.runesGetBalanceResultSchema = runesGetBalanceResultSchema;
|
|
2245
|
+
exports.runesMintMethodName = runesMintMethodName;
|
|
2246
|
+
exports.runesMintParamsSchema = runesMintParamsSchema;
|
|
2247
|
+
exports.runesMintRequestMessageSchema = runesMintRequestMessageSchema;
|
|
2248
|
+
exports.runesMintResultSchema = runesMintResultSchema;
|
|
2249
|
+
exports.runesTransferMethodName = runesTransferMethodName;
|
|
2250
|
+
exports.runesTransferParamsSchema = runesTransferParamsSchema;
|
|
2251
|
+
exports.runesTransferRequestMessageSchema = runesTransferRequestMessageSchema;
|
|
2252
|
+
exports.runesTransferResultSchema = runesTransferResultSchema;
|
|
2253
|
+
exports.sendBtcTransaction = sendBtcTransaction;
|
|
2254
|
+
exports.sendInscriptionsMethodName = sendInscriptionsMethodName;
|
|
2255
|
+
exports.sendInscriptionsParamsSchema = sendInscriptionsParamsSchema;
|
|
2256
|
+
exports.sendInscriptionsRequestMessageSchema = sendInscriptionsRequestMessageSchema;
|
|
2257
|
+
exports.sendInscriptionsResultSchema = sendInscriptionsResultSchema;
|
|
2258
|
+
exports.sendTransferMethodName = sendTransferMethodName;
|
|
2259
|
+
exports.sendTransferParamsSchema = sendTransferParamsSchema;
|
|
2260
|
+
exports.sendTransferRequestMessageSchema = sendTransferRequestMessageSchema;
|
|
2261
|
+
exports.sendTransferResultSchema = sendTransferResultSchema;
|
|
2262
|
+
exports.setDefaultProvider = setDefaultProvider;
|
|
2263
|
+
exports.signMessage = signMessage;
|
|
2264
|
+
exports.signMessageMethodName = signMessageMethodName;
|
|
2265
|
+
exports.signMessageParamsSchema = signMessageParamsSchema;
|
|
2266
|
+
exports.signMessageRequestMessageSchema = signMessageRequestMessageSchema;
|
|
2267
|
+
exports.signMessageResultSchema = signMessageResultSchema;
|
|
2268
|
+
exports.signMultipleTransactions = signMultipleTransactions;
|
|
2269
|
+
exports.signPsbtMethodName = signPsbtMethodName;
|
|
2270
|
+
exports.signPsbtParamsSchema = signPsbtParamsSchema;
|
|
2271
|
+
exports.signPsbtRequestMessageSchema = signPsbtRequestMessageSchema;
|
|
2272
|
+
exports.signPsbtResultSchema = signPsbtResultSchema;
|
|
2273
|
+
exports.signTransaction = signTransaction;
|
|
2274
|
+
exports.sparkFlashnetAddLiquidityIntentSchema = sparkFlashnetAddLiquidityIntentSchema;
|
|
2275
|
+
exports.sparkFlashnetClawbackIntentSchema = sparkFlashnetClawbackIntentSchema;
|
|
2276
|
+
exports.sparkFlashnetConfirmInitialDepositIntentSchema = sparkFlashnetConfirmInitialDepositIntentSchema;
|
|
2277
|
+
exports.sparkFlashnetCreateConstantProductPoolIntentSchema = sparkFlashnetCreateConstantProductPoolIntentSchema;
|
|
2278
|
+
exports.sparkFlashnetCreateSingleSidedPoolIntentSchema = sparkFlashnetCreateSingleSidedPoolIntentSchema;
|
|
2279
|
+
exports.sparkFlashnetGetJwtMethodName = sparkFlashnetGetJwtMethodName;
|
|
2280
|
+
exports.sparkFlashnetGetJwtParamsSchema = sparkFlashnetGetJwtParamsSchema;
|
|
2281
|
+
exports.sparkFlashnetGetJwtRequestMessageSchema = sparkFlashnetGetJwtRequestMessageSchema;
|
|
2282
|
+
exports.sparkFlashnetGetJwtResultSchema = sparkFlashnetGetJwtResultSchema;
|
|
2283
|
+
exports.sparkFlashnetRemoveLiquidityIntentSchema = sparkFlashnetRemoveLiquidityIntentSchema;
|
|
2284
|
+
exports.sparkFlashnetRouteSwapIntentSchema = sparkFlashnetRouteSwapIntentSchema;
|
|
2285
|
+
exports.sparkFlashnetSignIntentMethodName = sparkFlashnetSignIntentMethodName;
|
|
2286
|
+
exports.sparkFlashnetSignIntentParamsSchema = sparkFlashnetSignIntentParamsSchema;
|
|
2287
|
+
exports.sparkFlashnetSignIntentRequestMessageSchema = sparkFlashnetSignIntentRequestMessageSchema;
|
|
2288
|
+
exports.sparkFlashnetSignIntentResultSchema = sparkFlashnetSignIntentResultSchema;
|
|
2289
|
+
exports.sparkFlashnetSignStructuredMessageMethodName = sparkFlashnetSignStructuredMessageMethodName;
|
|
2290
|
+
exports.sparkFlashnetSignStructuredMessageParamsSchema = sparkFlashnetSignStructuredMessageParamsSchema;
|
|
2291
|
+
exports.sparkFlashnetSignStructuredMessageRequestMessageSchema = sparkFlashnetSignStructuredMessageRequestMessageSchema;
|
|
2292
|
+
exports.sparkFlashnetSignStructuredMessageResultSchema = sparkFlashnetSignStructuredMessageResultSchema;
|
|
2293
|
+
exports.sparkFlashnetSwapIntentSchema = sparkFlashnetSwapIntentSchema;
|
|
2294
|
+
exports.sparkGetAddressesMethodName = sparkGetAddressesMethodName;
|
|
2295
|
+
exports.sparkGetAddressesParamsSchema = sparkGetAddressesParamsSchema;
|
|
2296
|
+
exports.sparkGetAddressesRequestMessageSchema = sparkGetAddressesRequestMessageSchema;
|
|
2297
|
+
exports.sparkGetAddressesResultSchema = sparkGetAddressesResultSchema;
|
|
2298
|
+
exports.sparkGetBalanceMethodName = sparkGetBalanceMethodName;
|
|
2299
|
+
exports.sparkGetBalanceParamsSchema = sparkGetBalanceParamsSchema;
|
|
2300
|
+
exports.sparkGetBalanceRequestMessageSchema = sparkGetBalanceRequestMessageSchema;
|
|
2301
|
+
exports.sparkGetBalanceResultSchema = sparkGetBalanceResultSchema;
|
|
2302
|
+
exports.sparkNetworkDefinitionSchema = sparkNetworkDefinitionSchema;
|
|
2303
|
+
exports.sparkSignMessageMethodName = sparkSignMessageMethodName;
|
|
2304
|
+
exports.sparkSignMessageParamsSchema = sparkSignMessageParamsSchema;
|
|
2305
|
+
exports.sparkSignMessageRequestMessageSchema = sparkSignMessageRequestMessageSchema;
|
|
2306
|
+
exports.sparkSignMessageResultSchema = sparkSignMessageResultSchema;
|
|
2307
|
+
exports.sparkTransferMethodName = sparkTransferMethodName;
|
|
2308
|
+
exports.sparkTransferParamsSchema = sparkTransferParamsSchema;
|
|
2309
|
+
exports.sparkTransferRequestMessageSchema = sparkTransferRequestMessageSchema;
|
|
2310
|
+
exports.sparkTransferResultSchema = sparkTransferResultSchema;
|
|
2311
|
+
exports.sparkTransferTokenMethodName = sparkTransferTokenMethodName;
|
|
2312
|
+
exports.sparkTransferTokenParamsSchema = sparkTransferTokenParamsSchema;
|
|
2313
|
+
exports.sparkTransferTokenRequestMessageSchema = sparkTransferTokenRequestMessageSchema;
|
|
2314
|
+
exports.sparkTransferTokenResultSchema = sparkTransferTokenResultSchema;
|
|
2315
|
+
exports.stacksNetworkDefinitionSchema = stacksNetworkDefinitionSchema;
|
|
2316
|
+
exports.starknetNetworkDefinitionSchema = starknetNetworkDefinitionSchema;
|
|
2317
|
+
exports.stxCallContractMethodName = stxCallContractMethodName;
|
|
2318
|
+
exports.stxCallContractParamsSchema = stxCallContractParamsSchema;
|
|
2319
|
+
exports.stxCallContractRequestMessageSchema = stxCallContractRequestMessageSchema;
|
|
2320
|
+
exports.stxCallContractResultSchema = stxCallContractResultSchema;
|
|
2321
|
+
exports.stxDeployContractMethodName = stxDeployContractMethodName;
|
|
2322
|
+
exports.stxDeployContractParamsSchema = stxDeployContractParamsSchema;
|
|
2323
|
+
exports.stxDeployContractRequestMessageSchema = stxDeployContractRequestMessageSchema;
|
|
2324
|
+
exports.stxDeployContractResultSchema = stxDeployContractResultSchema;
|
|
2325
|
+
exports.stxGetAccountsMethodName = stxGetAccountsMethodName;
|
|
2326
|
+
exports.stxGetAccountsParamsSchema = stxGetAccountsParamsSchema;
|
|
2327
|
+
exports.stxGetAccountsRequestMessageSchema = stxGetAccountsRequestMessageSchema;
|
|
2328
|
+
exports.stxGetAccountsResultSchema = stxGetAccountsResultSchema;
|
|
2329
|
+
exports.stxGetAddressesMethodName = stxGetAddressesMethodName;
|
|
2330
|
+
exports.stxGetAddressesParamsSchema = stxGetAddressesParamsSchema;
|
|
2331
|
+
exports.stxGetAddressesRequestMessageSchema = stxGetAddressesRequestMessageSchema;
|
|
2332
|
+
exports.stxGetAddressesResultSchema = stxGetAddressesResultSchema;
|
|
2333
|
+
exports.stxSignMessageMethodName = stxSignMessageMethodName;
|
|
2334
|
+
exports.stxSignMessageParamsSchema = stxSignMessageParamsSchema;
|
|
2335
|
+
exports.stxSignMessageRequestMessageSchema = stxSignMessageRequestMessageSchema;
|
|
2336
|
+
exports.stxSignMessageResultSchema = stxSignMessageResultSchema;
|
|
2337
|
+
exports.stxSignStructuredMessageMethodName = stxSignStructuredMessageMethodName;
|
|
2338
|
+
exports.stxSignStructuredMessageParamsSchema = stxSignStructuredMessageParamsSchema;
|
|
2339
|
+
exports.stxSignStructuredMessageRequestMessageSchema = stxSignStructuredMessageRequestMessageSchema;
|
|
2340
|
+
exports.stxSignStructuredMessageResultSchema = stxSignStructuredMessageResultSchema;
|
|
2341
|
+
exports.stxSignTransactionMethodName = stxSignTransactionMethodName;
|
|
2342
|
+
exports.stxSignTransactionParamsSchema = stxSignTransactionParamsSchema;
|
|
2343
|
+
exports.stxSignTransactionRequestMessageSchema = stxSignTransactionRequestMessageSchema;
|
|
2344
|
+
exports.stxSignTransactionResultSchema = stxSignTransactionResultSchema;
|
|
2345
|
+
exports.stxSignTransactionsMethodName = stxSignTransactionsMethodName;
|
|
2346
|
+
exports.stxSignTransactionsParamsSchema = stxSignTransactionsParamsSchema;
|
|
2347
|
+
exports.stxSignTransactionsRequestMessageSchema = stxSignTransactionsRequestMessageSchema;
|
|
2348
|
+
exports.stxSignTransactionsResultSchema = stxSignTransactionsResultSchema;
|
|
2349
|
+
exports.stxTransferStxMethodName = stxTransferStxMethodName;
|
|
2350
|
+
exports.stxTransferStxParamsSchema = stxTransferStxParamsSchema;
|
|
2351
|
+
exports.stxTransferStxRequestMessageSchema = stxTransferStxRequestMessageSchema;
|
|
2352
|
+
exports.stxTransferStxResultSchema = stxTransferStxResultSchema;
|
|
2353
|
+
exports.walletActionsSchema = walletActionsSchema;
|
|
2354
|
+
exports.walletEventSchema = walletEventSchema;
|
|
2355
|
+
exports.walletPermissionSchema = walletPermissionSchema;
|
|
2356
|
+
exports.walletTypeSchema = walletTypeSchema;
|
|
2357
|
+
exports.walletTypes = walletTypes;
|