@sats-connect/core 0.16.0-2dd02aa → 0.16.0-4c59967
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1383 -0
- package/dist/index.d.cts +4173 -0
- package/dist/index.d.mts +3663 -2292
- package/dist/index.mjs +1230 -2980
- package/package.json +9 -9
- package/dist/index.d.ts +0 -2802
- package/dist/index.js +0 -3339
package/dist/index.mjs
CHANGED
|
@@ -1,3059 +1,1309 @@
|
|
|
1
|
-
// src/request/index.ts
|
|
2
|
-
import * as v48 from "valibot";
|
|
3
|
-
|
|
4
|
-
// src/provider/types.ts
|
|
5
|
-
import * as v4 from "valibot";
|
|
6
|
-
|
|
7
|
-
// src/addresses/index.ts
|
|
8
|
-
import { createUnsecuredToken } from "jsontokens";
|
|
9
|
-
|
|
10
|
-
// src/addresses/types.ts
|
|
11
|
-
import * as v2 from "valibot";
|
|
12
|
-
|
|
13
|
-
// src/request/types/common.ts
|
|
14
1
|
import * as v from "valibot";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
20
|
-
AddressPurpose2["Ordinals"] = "ordinals";
|
|
21
|
-
AddressPurpose2["Payment"] = "payment";
|
|
22
|
-
AddressPurpose2["Stacks"] = "stacks";
|
|
23
|
-
AddressPurpose2["Starknet"] = "starknet";
|
|
24
|
-
AddressPurpose2["Spark"] = "spark";
|
|
25
|
-
return AddressPurpose2;
|
|
26
|
-
})(AddressPurpose || {});
|
|
27
|
-
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
28
|
-
AddressType3["p2pkh"] = "p2pkh";
|
|
29
|
-
AddressType3["p2sh"] = "p2sh";
|
|
30
|
-
AddressType3["p2wpkh"] = "p2wpkh";
|
|
31
|
-
AddressType3["p2wsh"] = "p2wsh";
|
|
32
|
-
AddressType3["p2tr"] = "p2tr";
|
|
33
|
-
AddressType3["stacks"] = "stacks";
|
|
34
|
-
AddressType3["starknet"] = "starknet";
|
|
35
|
-
AddressType3["spark"] = "spark";
|
|
36
|
-
return AddressType3;
|
|
37
|
-
})(AddressType || {});
|
|
38
|
-
var addressSchema = v2.object({
|
|
39
|
-
address: v2.string(),
|
|
40
|
-
publicKey: v2.string(),
|
|
41
|
-
purpose: v2.enum(AddressPurpose),
|
|
42
|
-
addressType: v2.enum(AddressType),
|
|
43
|
-
walletType: walletTypeSchema
|
|
44
|
-
});
|
|
2
|
+
import { createUnsecuredToken } from "jsontokens";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { AddressType as AddressType$1, getAddressInfo } from "bitcoin-address-validation";
|
|
5
|
+
import { Buffer } from "buffer";
|
|
45
6
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
7
|
+
//#region src/request/types/common.ts
|
|
8
|
+
const walletTypes = [
|
|
9
|
+
"software",
|
|
10
|
+
"ledger",
|
|
11
|
+
"keystone"
|
|
12
|
+
];
|
|
13
|
+
const walletTypeSchema = v.picklist(walletTypes);
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/addresses/types.ts
|
|
17
|
+
let AddressPurpose = /* @__PURE__ */ function(AddressPurpose$1) {
|
|
18
|
+
AddressPurpose$1["Ordinals"] = "ordinals";
|
|
19
|
+
AddressPurpose$1["Payment"] = "payment";
|
|
20
|
+
AddressPurpose$1["Stacks"] = "stacks";
|
|
21
|
+
AddressPurpose$1["Starknet"] = "starknet";
|
|
22
|
+
AddressPurpose$1["Spark"] = "spark";
|
|
23
|
+
return AddressPurpose$1;
|
|
24
|
+
}({});
|
|
25
|
+
let AddressType = /* @__PURE__ */ function(AddressType$2) {
|
|
26
|
+
AddressType$2["p2pkh"] = "p2pkh";
|
|
27
|
+
AddressType$2["p2sh"] = "p2sh";
|
|
28
|
+
AddressType$2["p2wpkh"] = "p2wpkh";
|
|
29
|
+
AddressType$2["p2wsh"] = "p2wsh";
|
|
30
|
+
AddressType$2["p2tr"] = "p2tr";
|
|
31
|
+
AddressType$2["stacks"] = "stacks";
|
|
32
|
+
AddressType$2["starknet"] = "starknet";
|
|
33
|
+
AddressType$2["spark"] = "spark";
|
|
34
|
+
return AddressType$2;
|
|
35
|
+
}({});
|
|
36
|
+
const addressSchema = v.object({
|
|
37
|
+
address: v.string(),
|
|
38
|
+
publicKey: v.string(),
|
|
39
|
+
purpose: v.enum(AddressPurpose),
|
|
40
|
+
addressType: v.enum(AddressType),
|
|
41
|
+
walletType: walletTypeSchema
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/addresses/index.ts
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use `request()` instead
|
|
48
|
+
*/
|
|
49
|
+
const getAddress = async (options) => {
|
|
50
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
51
|
+
const { purposes } = options.payload;
|
|
52
|
+
if (!purposes) throw new Error("Address purposes are required");
|
|
53
|
+
try {
|
|
54
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
55
|
+
const response = await provider.connect(request$1);
|
|
56
|
+
options.onFinish?.(response);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error("[Connect] Error during address request", error);
|
|
59
|
+
options.onCancel?.();
|
|
60
|
+
}
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/types.ts
|
|
65
|
+
let BitcoinNetworkType = /* @__PURE__ */ function(BitcoinNetworkType$1) {
|
|
66
|
+
BitcoinNetworkType$1["Mainnet"] = "Mainnet";
|
|
67
|
+
BitcoinNetworkType$1["Testnet"] = "Testnet";
|
|
68
|
+
BitcoinNetworkType$1["Testnet4"] = "Testnet4";
|
|
69
|
+
BitcoinNetworkType$1["Signet"] = "Signet";
|
|
70
|
+
BitcoinNetworkType$1["Regtest"] = "Regtest";
|
|
71
|
+
return BitcoinNetworkType$1;
|
|
72
|
+
}({});
|
|
73
|
+
let StacksNetworkType = /* @__PURE__ */ function(StacksNetworkType$1) {
|
|
74
|
+
StacksNetworkType$1["Mainnet"] = "mainnet";
|
|
75
|
+
StacksNetworkType$1["Testnet"] = "testnet";
|
|
76
|
+
return StacksNetworkType$1;
|
|
77
|
+
}({});
|
|
78
|
+
let StarknetNetworkType = /* @__PURE__ */ function(StarknetNetworkType$1) {
|
|
79
|
+
StarknetNetworkType$1["Mainnet"] = "mainnet";
|
|
80
|
+
StarknetNetworkType$1["Sepolia"] = "sepolia";
|
|
81
|
+
return StarknetNetworkType$1;
|
|
82
|
+
}({});
|
|
83
|
+
let SparkNetworkType = /* @__PURE__ */ function(SparkNetworkType$1) {
|
|
84
|
+
SparkNetworkType$1["Mainnet"] = "mainnet";
|
|
85
|
+
SparkNetworkType$1["Regtest"] = "regtest";
|
|
86
|
+
return SparkNetworkType$1;
|
|
87
|
+
}({});
|
|
88
|
+
const RpcIdSchema = v.optional(v.union([
|
|
89
|
+
v.string(),
|
|
90
|
+
v.number(),
|
|
91
|
+
v.null()
|
|
92
|
+
]));
|
|
93
|
+
const rpcRequestMessageSchema = v.object({
|
|
94
|
+
jsonrpc: v.literal("2.0"),
|
|
95
|
+
method: v.string(),
|
|
96
|
+
params: v.optional(v.union([
|
|
97
|
+
v.array(v.unknown()),
|
|
98
|
+
v.looseObject({}),
|
|
99
|
+
v.null()
|
|
100
|
+
])),
|
|
101
|
+
id: v.unwrap(RpcIdSchema)
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* @enum {number} RpcErrorCode
|
|
105
|
+
* @description JSON-RPC error codes
|
|
106
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
107
|
+
*/
|
|
108
|
+
let RpcErrorCode = /* @__PURE__ */ function(RpcErrorCode$1) {
|
|
109
|
+
/**
|
|
110
|
+
* Parse error Invalid JSON
|
|
111
|
+
**/
|
|
112
|
+
RpcErrorCode$1[RpcErrorCode$1["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
113
|
+
/**
|
|
114
|
+
* The JSON sent is not a valid Request object.
|
|
115
|
+
**/
|
|
116
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
117
|
+
/**
|
|
118
|
+
* The method does not exist/is not available.
|
|
119
|
+
**/
|
|
120
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
121
|
+
/**
|
|
122
|
+
* Invalid method parameter(s).
|
|
123
|
+
*/
|
|
124
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
125
|
+
/**
|
|
126
|
+
* Internal JSON-RPC error.
|
|
127
|
+
* This is a generic error, used when the server encounters an error in performing the request.
|
|
128
|
+
**/
|
|
129
|
+
RpcErrorCode$1[RpcErrorCode$1["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
130
|
+
/**
|
|
131
|
+
* user rejected/canceled the request
|
|
132
|
+
*/
|
|
133
|
+
RpcErrorCode$1[RpcErrorCode$1["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
134
|
+
/**
|
|
135
|
+
* method is not supported for the address provided
|
|
136
|
+
*/
|
|
137
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
138
|
+
/**
|
|
139
|
+
* The client does not have permission to access the requested resource.
|
|
140
|
+
*/
|
|
141
|
+
RpcErrorCode$1[RpcErrorCode$1["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
142
|
+
return RpcErrorCode$1;
|
|
143
|
+
}({});
|
|
144
|
+
const rpcSuccessResponseMessageSchema = v.object({
|
|
145
|
+
jsonrpc: v.literal("2.0"),
|
|
146
|
+
result: v.nonOptional(v.unknown()),
|
|
147
|
+
id: RpcIdSchema
|
|
148
|
+
});
|
|
149
|
+
const rpcErrorResponseMessageSchema = v.object({
|
|
150
|
+
jsonrpc: v.literal("2.0"),
|
|
151
|
+
error: v.nonOptional(v.unknown()),
|
|
152
|
+
id: RpcIdSchema
|
|
153
|
+
});
|
|
154
|
+
const rpcResponseMessageSchema = v.union([rpcSuccessResponseMessageSchema, rpcErrorResponseMessageSchema]);
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/request/types/walletMethods/utils.ts
|
|
158
|
+
const commonNetworkConfigurationSchema = v.object({
|
|
159
|
+
id: v.string(),
|
|
160
|
+
name: v.string(),
|
|
161
|
+
mode: v.picklist([]),
|
|
162
|
+
blockExplorerUrl: v.optional(v.union([v.pipe(v.literal(""), v.transform(() => void 0)), v.pipe(v.string(), v.url())]))
|
|
163
|
+
});
|
|
164
|
+
const bitcoinChainModeSchema = v.enum({
|
|
165
|
+
mainnet: "mainnet",
|
|
166
|
+
testnet: "testnet",
|
|
167
|
+
testnet4: "testnet4",
|
|
168
|
+
signet: "signet",
|
|
169
|
+
regtest: "regtest"
|
|
170
|
+
});
|
|
171
|
+
const bitcoinNetworkConfigurationSchema = v.object({
|
|
172
|
+
chain: v.literal("bitcoin"),
|
|
173
|
+
...commonNetworkConfigurationSchema.entries,
|
|
174
|
+
mode: v.pipe(v.string(), bitcoinChainModeSchema),
|
|
175
|
+
xverseApiUrl: v.pipe(v.string(), v.url()),
|
|
176
|
+
electrsApiUrl: v.pipe(v.string(), v.url())
|
|
177
|
+
});
|
|
178
|
+
const sparkChainMode = {
|
|
179
|
+
mainnet: "mainnet",
|
|
180
|
+
regtest: "regtest"
|
|
181
|
+
};
|
|
182
|
+
const sparkChainModeSchema = v.enum(sparkChainMode);
|
|
183
|
+
const sparkNetworkConfigurationSchema = v.object({
|
|
184
|
+
chain: v.literal("spark"),
|
|
185
|
+
...commonNetworkConfigurationSchema.entries,
|
|
186
|
+
mode: v.pipe(v.string(), sparkChainModeSchema),
|
|
187
|
+
electrsApiUrl: v.pipe(v.string(), v.url())
|
|
188
|
+
});
|
|
189
|
+
const stacksChainMode = {
|
|
190
|
+
mainnet: "mainnet",
|
|
191
|
+
testnet: "testnet",
|
|
192
|
+
devnet: "devnet",
|
|
193
|
+
mocknet: "mocknet"
|
|
194
|
+
};
|
|
195
|
+
const stacksChainModeSchema = v.enum(stacksChainMode);
|
|
196
|
+
const stacksNetworkConfigurationSchema = v.object({
|
|
197
|
+
chain: v.literal("stacks"),
|
|
198
|
+
...commonNetworkConfigurationSchema.entries,
|
|
199
|
+
mode: v.pipe(v.string(), stacksChainModeSchema),
|
|
200
|
+
stacksApiUrl: v.pipe(v.string(), v.url()),
|
|
201
|
+
xverseApiUrl: v.pipe(v.string(), v.url())
|
|
202
|
+
});
|
|
203
|
+
const starknetChainMode = {
|
|
204
|
+
mainnet: "mainnet",
|
|
205
|
+
sepolia: "sepolia"
|
|
206
|
+
};
|
|
207
|
+
const starknetChainModeSchema = v.enum(starknetChainMode);
|
|
208
|
+
const starknetNetworkConfigurationSchema = v.object({
|
|
209
|
+
chain: v.literal("starknet"),
|
|
210
|
+
...commonNetworkConfigurationSchema.entries,
|
|
211
|
+
mode: v.pipe(v.string(), starknetChainModeSchema),
|
|
212
|
+
rpcApiUrl: v.pipe(v.string(), v.url()),
|
|
213
|
+
xverseApiUrl: v.pipe(v.string(), v.url())
|
|
214
|
+
});
|
|
215
|
+
const networkConfigurationSchema = v.variant("chain", [
|
|
216
|
+
bitcoinNetworkConfigurationSchema,
|
|
217
|
+
sparkNetworkConfigurationSchema,
|
|
218
|
+
stacksNetworkConfigurationSchema,
|
|
219
|
+
starknetNetworkConfigurationSchema
|
|
129
220
|
]);
|
|
130
221
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/provider/types.ts
|
|
224
|
+
const accountChangeEventName = "accountChange";
|
|
225
|
+
const accountChangeSchema = v.object({
|
|
226
|
+
type: v.literal(accountChangeEventName),
|
|
227
|
+
addresses: v.optional(v.array(addressSchema))
|
|
228
|
+
});
|
|
229
|
+
const networkChangeEventName = "networkChange";
|
|
230
|
+
const networkChangeSchema = v.object({
|
|
231
|
+
type: v.literal(networkChangeEventName),
|
|
232
|
+
bitcoin: v.object({ name: v.enum(BitcoinNetworkType) }),
|
|
233
|
+
stacks: v.object({ name: v.string() }),
|
|
234
|
+
addresses: v.optional(v.array(addressSchema))
|
|
235
|
+
});
|
|
236
|
+
const networkChangeEventNameV2 = "networkChangeV2";
|
|
237
|
+
const networkChangeV2Schema = v.object({
|
|
238
|
+
type: v.literal(networkChangeEventName),
|
|
239
|
+
networks: v.object({
|
|
240
|
+
bitcoin: bitcoinNetworkConfigurationSchema,
|
|
241
|
+
spark: sparkNetworkConfigurationSchema,
|
|
242
|
+
stacks: stacksNetworkConfigurationSchema,
|
|
243
|
+
starknet: starknetNetworkConfigurationSchema
|
|
244
|
+
}),
|
|
245
|
+
addresses: v.optional(v.array(addressSchema))
|
|
246
|
+
});
|
|
247
|
+
const disconnectEventName = "disconnect";
|
|
248
|
+
const disconnectSchema = v.object({ type: v.literal(disconnectEventName) });
|
|
249
|
+
const walletEventSchema = v.variant("type", [
|
|
250
|
+
accountChangeSchema,
|
|
251
|
+
networkChangeSchema,
|
|
252
|
+
disconnectSchema
|
|
156
253
|
]);
|
|
157
254
|
|
|
158
|
-
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/provider/index.ts
|
|
159
257
|
async function getProviderOrThrow(getProvider) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
return provider;
|
|
258
|
+
const provider = await getProvider?.() || window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
259
|
+
if (!provider) throw new Error("No Bitcoin wallet installed");
|
|
260
|
+
return provider;
|
|
165
261
|
}
|
|
166
262
|
function getProviders() {
|
|
167
|
-
|
|
168
|
-
|
|
263
|
+
if (!window.btc_providers) window.btc_providers = [];
|
|
264
|
+
return window.btc_providers;
|
|
169
265
|
}
|
|
170
266
|
function getProviderById(providerId) {
|
|
171
|
-
|
|
267
|
+
return providerId?.split(".").reduce((acc, part) => acc?.[part], window);
|
|
172
268
|
}
|
|
173
269
|
function isProviderInstalled(providerId) {
|
|
174
|
-
|
|
270
|
+
return !!getProviderById(providerId);
|
|
175
271
|
}
|
|
176
272
|
function setDefaultProvider(providerId) {
|
|
177
|
-
|
|
273
|
+
localStorage.setItem("sats-connect_defaultProvider", providerId);
|
|
178
274
|
}
|
|
179
275
|
function getDefaultProvider() {
|
|
180
|
-
|
|
276
|
+
return localStorage.getItem("sats-connect_defaultProvider");
|
|
181
277
|
}
|
|
182
278
|
function removeDefaultProvider() {
|
|
183
|
-
|
|
279
|
+
localStorage.removeItem("sats-connect_defaultProvider");
|
|
184
280
|
}
|
|
185
281
|
function getSupportedWallets() {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
return wallets;
|
|
282
|
+
return Object.values(DefaultAdaptersInfo).map((provider) => {
|
|
283
|
+
return {
|
|
284
|
+
...provider,
|
|
285
|
+
isInstalled: isProviderInstalled(provider.id)
|
|
286
|
+
};
|
|
287
|
+
});
|
|
195
288
|
}
|
|
196
289
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/request/sanitizeRequest.ts
|
|
292
|
+
const sanitizeRequest = (method, params, providerInfo) => {
|
|
293
|
+
try {
|
|
294
|
+
const [major, minor, patch] = providerInfo.version.split(".").map((part) => parseInt(part, 10));
|
|
295
|
+
const platform = providerInfo.platform;
|
|
296
|
+
if (!platform || platform === ProviderPlatform.Web && major <= 1 && minor <= 4 || platform === ProviderPlatform.Mobile && major <= 1 && minor <= 54) {
|
|
297
|
+
const v1Sanitized = sanitizeAddressPurposeRequest(method, params);
|
|
298
|
+
method = v1Sanitized.method;
|
|
299
|
+
params = v1Sanitized.params;
|
|
300
|
+
}
|
|
301
|
+
} catch {}
|
|
302
|
+
return {
|
|
303
|
+
method,
|
|
304
|
+
params
|
|
305
|
+
};
|
|
213
306
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
307
|
+
const sanitizeAddressPurposeRequest = (method, params) => {
|
|
308
|
+
const filterPurposes = (purposes) => purposes?.filter((purpose) => purpose !== AddressPurpose.Spark && purpose !== AddressPurpose.Starknet);
|
|
309
|
+
if (method === "wallet_connect") {
|
|
310
|
+
const typedParams = params;
|
|
311
|
+
if (!typedParams) return {
|
|
312
|
+
method,
|
|
313
|
+
params
|
|
314
|
+
};
|
|
315
|
+
const { addresses, ...rest } = typedParams;
|
|
316
|
+
return {
|
|
317
|
+
method,
|
|
318
|
+
params: {
|
|
319
|
+
...rest,
|
|
320
|
+
addresses: filterPurposes(addresses)
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (method === "getAccounts") {
|
|
325
|
+
const { purposes, ...rest } = params;
|
|
326
|
+
return {
|
|
327
|
+
method,
|
|
328
|
+
params: {
|
|
329
|
+
...rest,
|
|
330
|
+
purposes: filterPurposes(purposes)
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
if (method === "getAddresses") {
|
|
335
|
+
const { purposes, ...rest } = params;
|
|
336
|
+
return {
|
|
337
|
+
method,
|
|
338
|
+
params: {
|
|
339
|
+
...rest,
|
|
340
|
+
purposes: filterPurposes(purposes)
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
method,
|
|
346
|
+
params
|
|
347
|
+
};
|
|
243
348
|
};
|
|
244
349
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// src/request/types/btcMethods/getAccounts.ts
|
|
253
|
-
import * as v5 from "valibot";
|
|
254
|
-
var getAccountsMethodName = "getAccounts";
|
|
255
|
-
var getAccountsParamsSchema = v5.object({
|
|
256
|
-
/**
|
|
257
|
-
* The purposes for which to generate addresses. See
|
|
258
|
-
* {@linkcode AddressPurpose} for available purposes.
|
|
259
|
-
*/
|
|
260
|
-
purposes: v5.array(v5.enum(AddressPurpose)),
|
|
261
|
-
/**
|
|
262
|
-
* A message to be displayed to the user in the request prompt.
|
|
263
|
-
*/
|
|
264
|
-
message: v5.optional(v5.string())
|
|
265
|
-
});
|
|
266
|
-
var getAccountsResultSchema = v5.array(
|
|
267
|
-
v5.object({
|
|
268
|
-
...addressSchema.entries,
|
|
269
|
-
...v5.object({
|
|
270
|
-
walletType: walletTypeSchema
|
|
271
|
-
}).entries
|
|
272
|
-
})
|
|
273
|
-
);
|
|
274
|
-
var getAccountsRequestMessageSchema = v5.object({
|
|
275
|
-
...rpcRequestMessageSchema.entries,
|
|
276
|
-
...v5.object({
|
|
277
|
-
method: v5.literal(getAccountsMethodName),
|
|
278
|
-
params: getAccountsParamsSchema,
|
|
279
|
-
id: v5.string()
|
|
280
|
-
}).entries
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
// src/request/types/btcMethods/getAddresses.ts
|
|
284
|
-
import * as v7 from "valibot";
|
|
285
|
-
|
|
286
|
-
// src/request/types/walletMethods.ts
|
|
287
|
-
import * as v6 from "valibot";
|
|
288
|
-
var accountActionsSchema = v6.object({
|
|
289
|
-
read: v6.optional(v6.boolean())
|
|
290
|
-
});
|
|
291
|
-
var walletActionsSchema = v6.object({
|
|
292
|
-
readNetwork: v6.optional(v6.boolean())
|
|
293
|
-
});
|
|
294
|
-
var accountPermissionSchema = v6.object({
|
|
295
|
-
type: v6.literal("account"),
|
|
296
|
-
resourceId: v6.string(),
|
|
297
|
-
clientId: v6.string(),
|
|
298
|
-
actions: accountActionsSchema
|
|
299
|
-
});
|
|
300
|
-
var walletPermissionSchema = v6.object({
|
|
301
|
-
type: v6.literal("wallet"),
|
|
302
|
-
resourceId: v6.string(),
|
|
303
|
-
clientId: v6.string(),
|
|
304
|
-
actions: walletActionsSchema
|
|
305
|
-
});
|
|
306
|
-
var PermissionRequestParams = v6.variant("type", [
|
|
307
|
-
v6.object({
|
|
308
|
-
...v6.omit(accountPermissionSchema, ["clientId"]).entries
|
|
309
|
-
}),
|
|
310
|
-
v6.object({
|
|
311
|
-
...v6.omit(walletPermissionSchema, ["clientId"]).entries
|
|
312
|
-
})
|
|
313
|
-
]);
|
|
314
|
-
var permission = v6.variant("type", [accountPermissionSchema, walletPermissionSchema]);
|
|
315
|
-
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
316
|
-
var requestPermissionsParamsSchema = v6.nullish(v6.array(PermissionRequestParams));
|
|
317
|
-
var requestPermissionsResultSchema = v6.literal(true);
|
|
318
|
-
var requestPermissionsRequestMessageSchema = v6.object({
|
|
319
|
-
...rpcRequestMessageSchema.entries,
|
|
320
|
-
...v6.object({
|
|
321
|
-
method: v6.literal(requestPermissionsMethodName),
|
|
322
|
-
params: requestPermissionsParamsSchema,
|
|
323
|
-
id: v6.string()
|
|
324
|
-
}).entries
|
|
325
|
-
});
|
|
326
|
-
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
327
|
-
var renouncePermissionsParamsSchema = v6.nullish(v6.null());
|
|
328
|
-
var renouncePermissionsResultSchema = v6.nullish(v6.null());
|
|
329
|
-
var renouncePermissionsRequestMessageSchema = v6.object({
|
|
330
|
-
...rpcRequestMessageSchema.entries,
|
|
331
|
-
...v6.object({
|
|
332
|
-
method: v6.literal(renouncePermissionsMethodName),
|
|
333
|
-
params: renouncePermissionsParamsSchema,
|
|
334
|
-
id: v6.string()
|
|
335
|
-
}).entries
|
|
336
|
-
});
|
|
337
|
-
var disconnectMethodName = "wallet_disconnect";
|
|
338
|
-
var disconnectParamsSchema = v6.nullish(v6.null());
|
|
339
|
-
var disconnectResultSchema = v6.nullish(v6.null());
|
|
340
|
-
var disconnectRequestMessageSchema = v6.object({
|
|
341
|
-
...rpcRequestMessageSchema.entries,
|
|
342
|
-
...v6.object({
|
|
343
|
-
method: v6.literal(disconnectMethodName),
|
|
344
|
-
params: disconnectParamsSchema,
|
|
345
|
-
id: v6.string()
|
|
346
|
-
}).entries
|
|
347
|
-
});
|
|
348
|
-
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
349
|
-
var getWalletTypeParamsSchema = v6.nullish(v6.null());
|
|
350
|
-
var getWalletTypeResultSchema = walletTypeSchema;
|
|
351
|
-
var getWalletTypeRequestMessageSchema = v6.object({
|
|
352
|
-
...rpcRequestMessageSchema.entries,
|
|
353
|
-
...v6.object({
|
|
354
|
-
method: v6.literal(getWalletTypeMethodName),
|
|
355
|
-
params: getWalletTypeParamsSchema,
|
|
356
|
-
id: v6.string()
|
|
357
|
-
}).entries
|
|
358
|
-
});
|
|
359
|
-
var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
360
|
-
var getCurrentPermissionsParamsSchema = v6.nullish(v6.null());
|
|
361
|
-
var getCurrentPermissionsResultSchema = v6.array(permission);
|
|
362
|
-
var getCurrentPermissionsRequestMessageSchema = v6.object({
|
|
363
|
-
...rpcRequestMessageSchema.entries,
|
|
364
|
-
...v6.object({
|
|
365
|
-
method: v6.literal(getCurrentPermissionsMethodName),
|
|
366
|
-
params: getCurrentPermissionsParamsSchema,
|
|
367
|
-
id: v6.string()
|
|
368
|
-
}).entries
|
|
369
|
-
});
|
|
370
|
-
var getNetworkMethodName = "wallet_getNetwork";
|
|
371
|
-
var getNetworkParamsSchema = v6.nullish(v6.null());
|
|
372
|
-
var getNetworkResultSchema = v6.object({
|
|
373
|
-
bitcoin: v6.object({
|
|
374
|
-
name: v6.enum(BitcoinNetworkType)
|
|
375
|
-
}),
|
|
376
|
-
stacks: v6.object({
|
|
377
|
-
name: v6.enum(StacksNetworkType)
|
|
378
|
-
}),
|
|
379
|
-
spark: v6.object({
|
|
380
|
-
name: v6.enum(SparkNetworkType)
|
|
381
|
-
})
|
|
382
|
-
});
|
|
383
|
-
var getNetworkRequestMessageSchema = v6.object({
|
|
384
|
-
...rpcRequestMessageSchema.entries,
|
|
385
|
-
...v6.object({
|
|
386
|
-
method: v6.literal(getNetworkMethodName),
|
|
387
|
-
params: getNetworkParamsSchema,
|
|
388
|
-
id: v6.string()
|
|
389
|
-
}).entries
|
|
390
|
-
});
|
|
391
|
-
var changeNetworkMethodName = "wallet_changeNetwork";
|
|
392
|
-
var changeNetworkParamsSchema = v6.object({
|
|
393
|
-
name: v6.enum(BitcoinNetworkType)
|
|
394
|
-
});
|
|
395
|
-
var changeNetworkResultSchema = v6.nullish(v6.null());
|
|
396
|
-
var changeNetworkRequestMessageSchema = v6.object({
|
|
397
|
-
...rpcRequestMessageSchema.entries,
|
|
398
|
-
...v6.object({
|
|
399
|
-
method: v6.literal(changeNetworkMethodName),
|
|
400
|
-
params: changeNetworkParamsSchema,
|
|
401
|
-
id: v6.string()
|
|
402
|
-
}).entries
|
|
403
|
-
});
|
|
404
|
-
var changeNetworkByIdMethodName = "wallet_changeNetworkById";
|
|
405
|
-
var changeNetworkByIdParamsSchema = v6.object({
|
|
406
|
-
id: v6.string()
|
|
407
|
-
});
|
|
408
|
-
var changeNetworkByIdResultSchema = v6.nullish(v6.null());
|
|
409
|
-
var changeNetworkByIdRequestMessageSchema = v6.object({
|
|
410
|
-
...rpcRequestMessageSchema.entries,
|
|
411
|
-
...v6.object({
|
|
412
|
-
method: v6.literal(changeNetworkByIdMethodName),
|
|
413
|
-
params: changeNetworkByIdParamsSchema,
|
|
414
|
-
id: v6.string()
|
|
415
|
-
}).entries
|
|
416
|
-
});
|
|
417
|
-
var getAccountMethodName = "wallet_getAccount";
|
|
418
|
-
var getAccountParamsSchema = v6.nullish(v6.null());
|
|
419
|
-
var getAccountResultSchema = v6.object({
|
|
420
|
-
id: v6.string(),
|
|
421
|
-
addresses: v6.array(addressSchema),
|
|
422
|
-
walletType: walletTypeSchema,
|
|
423
|
-
network: getNetworkResultSchema
|
|
424
|
-
});
|
|
425
|
-
var getAccountRequestMessageSchema = v6.object({
|
|
426
|
-
...rpcRequestMessageSchema.entries,
|
|
427
|
-
...v6.object({
|
|
428
|
-
method: v6.literal(getAccountMethodName),
|
|
429
|
-
params: getAccountParamsSchema,
|
|
430
|
-
id: v6.string()
|
|
431
|
-
}).entries
|
|
432
|
-
});
|
|
433
|
-
var connectMethodName = "wallet_connect";
|
|
434
|
-
var connectParamsSchema = v6.nullish(
|
|
435
|
-
v6.object({
|
|
436
|
-
permissions: v6.optional(v6.array(PermissionRequestParams)),
|
|
437
|
-
addresses: v6.optional(v6.array(v6.enum(AddressPurpose))),
|
|
438
|
-
message: v6.optional(
|
|
439
|
-
v6.pipe(v6.string(), v6.maxLength(80, "The message must not exceed 80 characters."))
|
|
440
|
-
),
|
|
441
|
-
network: v6.optional(v6.enum(BitcoinNetworkType))
|
|
442
|
-
})
|
|
443
|
-
);
|
|
444
|
-
var connectResultSchema = v6.object({
|
|
445
|
-
id: v6.string(),
|
|
446
|
-
addresses: v6.array(addressSchema),
|
|
447
|
-
walletType: walletTypeSchema,
|
|
448
|
-
network: getNetworkResultSchema
|
|
449
|
-
});
|
|
450
|
-
var connectRequestMessageSchema = v6.object({
|
|
451
|
-
...rpcRequestMessageSchema.entries,
|
|
452
|
-
...v6.object({
|
|
453
|
-
method: v6.literal(connectMethodName),
|
|
454
|
-
params: connectParamsSchema,
|
|
455
|
-
id: v6.string()
|
|
456
|
-
}).entries
|
|
457
|
-
});
|
|
458
|
-
var addNetworkMethodName = "wallet_addNetwork";
|
|
459
|
-
var addNetworkParamsSchema = v6.variant("chain", [
|
|
460
|
-
v6.object({
|
|
461
|
-
chain: v6.literal("bitcoin"),
|
|
462
|
-
type: v6.enum(BitcoinNetworkType),
|
|
463
|
-
name: v6.string(),
|
|
464
|
-
rpcUrl: v6.string(),
|
|
465
|
-
rpcFallbackUrl: v6.optional(v6.string()),
|
|
466
|
-
indexerUrl: v6.optional(v6.string()),
|
|
467
|
-
blockExplorerUrl: v6.optional(v6.string()),
|
|
468
|
-
switch: v6.optional(v6.boolean())
|
|
469
|
-
}),
|
|
470
|
-
v6.object({
|
|
471
|
-
chain: v6.literal("stacks"),
|
|
472
|
-
name: v6.string(),
|
|
473
|
-
type: v6.enum(StacksNetworkType),
|
|
474
|
-
rpcUrl: v6.string(),
|
|
475
|
-
blockExplorerUrl: v6.optional(v6.string()),
|
|
476
|
-
switch: v6.optional(v6.boolean())
|
|
477
|
-
}),
|
|
478
|
-
v6.object({
|
|
479
|
-
chain: v6.literal("starknet"),
|
|
480
|
-
name: v6.string(),
|
|
481
|
-
type: v6.enum(StarknetNetworkType),
|
|
482
|
-
rpcUrl: v6.string(),
|
|
483
|
-
blockExplorerUrl: v6.optional(v6.string()),
|
|
484
|
-
switch: v6.optional(v6.boolean())
|
|
485
|
-
})
|
|
486
|
-
]);
|
|
487
|
-
var addNetworkRequestMessageSchema = v6.object({
|
|
488
|
-
...rpcRequestMessageSchema.entries,
|
|
489
|
-
...v6.object({
|
|
490
|
-
method: v6.literal(addNetworkMethodName),
|
|
491
|
-
params: addNetworkParamsSchema,
|
|
492
|
-
id: v6.string()
|
|
493
|
-
}).entries
|
|
494
|
-
});
|
|
495
|
-
var addNetworkResultSchema = v6.object({
|
|
496
|
-
id: v6.string()
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
// src/request/types/btcMethods/getAddresses.ts
|
|
500
|
-
var getAddressesMethodName = "getAddresses";
|
|
501
|
-
var getAddressesParamsSchema = v7.object({
|
|
502
|
-
/**
|
|
503
|
-
* The purposes for which to generate addresses. See
|
|
504
|
-
* {@linkcode AddressPurpose} for available purposes.
|
|
505
|
-
*/
|
|
506
|
-
purposes: v7.array(v7.enum(AddressPurpose)),
|
|
507
|
-
/**
|
|
508
|
-
* A message to be displayed to the user in the request prompt.
|
|
509
|
-
*/
|
|
510
|
-
message: v7.optional(v7.string())
|
|
511
|
-
});
|
|
512
|
-
var getAddressesResultSchema = v7.object({
|
|
513
|
-
/**
|
|
514
|
-
* The addresses generated for the given purposes.
|
|
515
|
-
*/
|
|
516
|
-
addresses: v7.array(addressSchema),
|
|
517
|
-
network: getNetworkResultSchema
|
|
518
|
-
});
|
|
519
|
-
var getAddressesRequestMessageSchema = v7.object({
|
|
520
|
-
...rpcRequestMessageSchema.entries,
|
|
521
|
-
...v7.object({
|
|
522
|
-
method: v7.literal(getAddressesMethodName),
|
|
523
|
-
params: getAddressesParamsSchema,
|
|
524
|
-
id: v7.string()
|
|
525
|
-
}).entries
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
// src/request/types/btcMethods/getBalance.ts
|
|
529
|
-
import * as v8 from "valibot";
|
|
530
|
-
var getBalanceMethodName = "getBalance";
|
|
531
|
-
var getBalanceParamsSchema = v8.nullish(v8.null());
|
|
532
|
-
var getBalanceResultSchema = v8.object({
|
|
533
|
-
/**
|
|
534
|
-
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
535
|
-
* messages not supporting bigint
|
|
536
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
537
|
-
*/
|
|
538
|
-
confirmed: v8.string(),
|
|
539
|
-
/**
|
|
540
|
-
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
541
|
-
* messages not supporting bigint
|
|
542
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
543
|
-
*/
|
|
544
|
-
unconfirmed: v8.string(),
|
|
545
|
-
/**
|
|
546
|
-
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
547
|
-
* sats. Using a string due to chrome messages not supporting bigint
|
|
548
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
549
|
-
*/
|
|
550
|
-
total: v8.string()
|
|
551
|
-
});
|
|
552
|
-
var getBalanceRequestMessageSchema = v8.object({
|
|
553
|
-
...rpcRequestMessageSchema.entries,
|
|
554
|
-
...v8.object({
|
|
555
|
-
method: v8.literal(getBalanceMethodName),
|
|
556
|
-
id: v8.string()
|
|
557
|
-
}).entries
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
// src/request/types/btcMethods/getInfo.ts
|
|
561
|
-
import * as v9 from "valibot";
|
|
562
|
-
var ProviderPlatform = /* @__PURE__ */ ((ProviderPlatform2) => {
|
|
563
|
-
ProviderPlatform2["Web"] = "web";
|
|
564
|
-
ProviderPlatform2["Mobile"] = "mobile";
|
|
565
|
-
return ProviderPlatform2;
|
|
566
|
-
})(ProviderPlatform || {});
|
|
567
|
-
var getInfoMethodName = "getInfo";
|
|
568
|
-
var getInfoParamsSchema = v9.nullish(v9.null());
|
|
569
|
-
var getInfoResultSchema = v9.object({
|
|
570
|
-
/**
|
|
571
|
-
* Version of the wallet.
|
|
572
|
-
*/
|
|
573
|
-
version: v9.string(),
|
|
574
|
-
/**
|
|
575
|
-
* The platform the wallet is running on (web or mobile).
|
|
576
|
-
*/
|
|
577
|
-
platform: v9.optional(v9.enum(ProviderPlatform)),
|
|
578
|
-
/**
|
|
579
|
-
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
580
|
-
*/
|
|
581
|
-
methods: v9.optional(v9.array(v9.string())),
|
|
582
|
-
/**
|
|
583
|
-
* List of WBIP standards supported by the wallet. Not currently used.
|
|
584
|
-
*/
|
|
585
|
-
supports: v9.array(v9.string())
|
|
586
|
-
});
|
|
587
|
-
var getInfoRequestMessageSchema = v9.object({
|
|
588
|
-
...rpcRequestMessageSchema.entries,
|
|
589
|
-
...v9.object({
|
|
590
|
-
method: v9.literal(getInfoMethodName),
|
|
591
|
-
params: getInfoParamsSchema,
|
|
592
|
-
id: v9.string()
|
|
593
|
-
}).entries
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
// src/request/types/btcMethods/sendTransfer.ts
|
|
597
|
-
import * as v10 from "valibot";
|
|
598
|
-
var sendTransferMethodName = "sendTransfer";
|
|
599
|
-
var sendTransferParamsSchema = v10.object({
|
|
600
|
-
/**
|
|
601
|
-
* Array of recipients to send to.
|
|
602
|
-
* The amount to send to each recipient is in satoshis.
|
|
603
|
-
*/
|
|
604
|
-
recipients: v10.array(
|
|
605
|
-
v10.object({
|
|
606
|
-
address: v10.string(),
|
|
607
|
-
amount: v10.number()
|
|
608
|
-
})
|
|
609
|
-
)
|
|
610
|
-
});
|
|
611
|
-
var sendTransferResultSchema = v10.object({
|
|
612
|
-
/**
|
|
613
|
-
* The transaction id as a hex-encoded string.
|
|
614
|
-
*/
|
|
615
|
-
txid: v10.string()
|
|
616
|
-
});
|
|
617
|
-
var sendTransferRequestMessageSchema = v10.object({
|
|
618
|
-
...rpcRequestMessageSchema.entries,
|
|
619
|
-
...v10.object({
|
|
620
|
-
method: v10.literal(sendTransferMethodName),
|
|
621
|
-
params: sendTransferParamsSchema,
|
|
622
|
-
id: v10.string()
|
|
623
|
-
}).entries
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
// src/request/types/btcMethods/signMessage.ts
|
|
627
|
-
import * as v11 from "valibot";
|
|
628
|
-
var signMessageMethodName = "signMessage";
|
|
629
|
-
var signMessageParamsSchema = v11.object({
|
|
630
|
-
/**
|
|
631
|
-
* The address used for signing.
|
|
632
|
-
**/
|
|
633
|
-
address: v11.string(),
|
|
634
|
-
/**
|
|
635
|
-
* The message to sign.
|
|
636
|
-
**/
|
|
637
|
-
message: v11.string(),
|
|
638
|
-
/**
|
|
639
|
-
* The protocol to use for signing the message.
|
|
640
|
-
*/
|
|
641
|
-
protocol: v11.optional(v11.enum(MessageSigningProtocols))
|
|
642
|
-
});
|
|
643
|
-
var signMessageResultSchema = v11.object({
|
|
644
|
-
/**
|
|
645
|
-
* The signature of the message.
|
|
646
|
-
*/
|
|
647
|
-
signature: v11.string(),
|
|
648
|
-
/**
|
|
649
|
-
* hash of the message.
|
|
650
|
-
*/
|
|
651
|
-
messageHash: v11.string(),
|
|
652
|
-
/**
|
|
653
|
-
* The address used for signing.
|
|
654
|
-
*/
|
|
655
|
-
address: v11.string(),
|
|
656
|
-
/**
|
|
657
|
-
* The protocol to use for signing the message.
|
|
658
|
-
*/
|
|
659
|
-
protocol: v11.enum(MessageSigningProtocols)
|
|
660
|
-
});
|
|
661
|
-
var signMessageRequestMessageSchema = v11.object({
|
|
662
|
-
...rpcRequestMessageSchema.entries,
|
|
663
|
-
...v11.object({
|
|
664
|
-
method: v11.literal(signMessageMethodName),
|
|
665
|
-
params: signMessageParamsSchema,
|
|
666
|
-
id: v11.string()
|
|
667
|
-
}).entries
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
// src/request/types/btcMethods/signMultipleMessages.ts
|
|
671
|
-
import * as v12 from "valibot";
|
|
672
|
-
var signMultipleMessagesMethodName = "signMultipleMessages";
|
|
673
|
-
var signMultipleMessagesParamsSchema = v12.array(
|
|
674
|
-
v12.object({
|
|
675
|
-
/**
|
|
676
|
-
* The address used for signing.
|
|
677
|
-
**/
|
|
678
|
-
address: v12.string(),
|
|
679
|
-
/**
|
|
680
|
-
* The message to sign.
|
|
681
|
-
**/
|
|
682
|
-
message: v12.string(),
|
|
683
|
-
/**
|
|
684
|
-
* The protocol to use for signing the message.
|
|
685
|
-
*/
|
|
686
|
-
protocol: v12.optional(v12.enum(MessageSigningProtocols))
|
|
687
|
-
})
|
|
688
|
-
);
|
|
689
|
-
var signMultipleMessagesResultSchema = v12.array(
|
|
690
|
-
v12.object({
|
|
691
|
-
/**
|
|
692
|
-
* The signature of the message.
|
|
693
|
-
*/
|
|
694
|
-
signature: v12.string(),
|
|
695
|
-
/**
|
|
696
|
-
* The original message which was signed.
|
|
697
|
-
*/
|
|
698
|
-
message: v12.string(),
|
|
699
|
-
/**
|
|
700
|
-
* Hash of the message.
|
|
701
|
-
*/
|
|
702
|
-
messageHash: v12.string(),
|
|
703
|
-
/**
|
|
704
|
-
* The address used for signing.
|
|
705
|
-
*/
|
|
706
|
-
address: v12.string(),
|
|
707
|
-
/**
|
|
708
|
-
* The protocol to use for signing the message.
|
|
709
|
-
*/
|
|
710
|
-
protocol: v12.enum(MessageSigningProtocols)
|
|
711
|
-
})
|
|
712
|
-
);
|
|
713
|
-
var signMultipleMessagesRequestMessageSchema = v12.object({
|
|
714
|
-
...rpcRequestMessageSchema.entries,
|
|
715
|
-
...v12.object({
|
|
716
|
-
method: v12.literal(signMultipleMessagesMethodName),
|
|
717
|
-
params: signMultipleMessagesParamsSchema,
|
|
718
|
-
id: v12.string()
|
|
719
|
-
}).entries
|
|
720
|
-
});
|
|
721
|
-
|
|
722
|
-
// src/request/types/btcMethods/signPSBT.ts
|
|
723
|
-
import * as v13 from "valibot";
|
|
724
|
-
var signPsbtMethodName = "signPsbt";
|
|
725
|
-
var signPsbtParamsSchema = v13.object({
|
|
726
|
-
/**
|
|
727
|
-
* The base64 encoded PSBT to sign.
|
|
728
|
-
*/
|
|
729
|
-
psbt: v13.string(),
|
|
730
|
-
/**
|
|
731
|
-
* The inputs to sign.
|
|
732
|
-
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
733
|
-
*/
|
|
734
|
-
signInputs: v13.optional(v13.record(v13.string(), v13.array(v13.number()))),
|
|
735
|
-
/**
|
|
736
|
-
* Whether to broadcast the transaction after signing.
|
|
737
|
-
**/
|
|
738
|
-
broadcast: v13.optional(v13.boolean())
|
|
739
|
-
});
|
|
740
|
-
var signPsbtResultSchema = v13.object({
|
|
741
|
-
/**
|
|
742
|
-
* The base64 encoded PSBT after signing.
|
|
743
|
-
*/
|
|
744
|
-
psbt: v13.string(),
|
|
745
|
-
/**
|
|
746
|
-
* The transaction id as a hex-encoded string.
|
|
747
|
-
* This is only returned if the transaction was broadcast.
|
|
748
|
-
**/
|
|
749
|
-
txid: v13.optional(v13.string())
|
|
750
|
-
});
|
|
751
|
-
var signPsbtRequestMessageSchema = v13.object({
|
|
752
|
-
...rpcRequestMessageSchema.entries,
|
|
753
|
-
...v13.object({
|
|
754
|
-
method: v13.literal(signPsbtMethodName),
|
|
755
|
-
params: signPsbtParamsSchema,
|
|
756
|
-
id: v13.string()
|
|
757
|
-
}).entries
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// src/request/types/ordinalsMethods.ts
|
|
761
|
-
import * as v14 from "valibot";
|
|
762
|
-
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
763
|
-
var getInscriptionsParamsSchema = v14.object({
|
|
764
|
-
offset: v14.number(),
|
|
765
|
-
limit: v14.number()
|
|
766
|
-
});
|
|
767
|
-
var getInscriptionsResultSchema = v14.object({
|
|
768
|
-
total: v14.number(),
|
|
769
|
-
limit: v14.number(),
|
|
770
|
-
offset: v14.number(),
|
|
771
|
-
inscriptions: v14.array(
|
|
772
|
-
v14.object({
|
|
773
|
-
inscriptionId: v14.string(),
|
|
774
|
-
inscriptionNumber: v14.string(),
|
|
775
|
-
address: v14.string(),
|
|
776
|
-
collectionName: v14.optional(v14.string()),
|
|
777
|
-
postage: v14.string(),
|
|
778
|
-
contentLength: v14.string(),
|
|
779
|
-
contentType: v14.string(),
|
|
780
|
-
timestamp: v14.number(),
|
|
781
|
-
offset: v14.number(),
|
|
782
|
-
genesisTransaction: v14.string(),
|
|
783
|
-
output: v14.string()
|
|
784
|
-
})
|
|
785
|
-
)
|
|
786
|
-
});
|
|
787
|
-
var getInscriptionsRequestMessageSchema = v14.object({
|
|
788
|
-
...rpcRequestMessageSchema.entries,
|
|
789
|
-
...v14.object({
|
|
790
|
-
method: v14.literal(getInscriptionsMethodName),
|
|
791
|
-
params: getInscriptionsParamsSchema,
|
|
792
|
-
id: v14.string()
|
|
793
|
-
}).entries
|
|
794
|
-
});
|
|
795
|
-
var sendInscriptionsMethodName = "ord_sendInscriptions";
|
|
796
|
-
var sendInscriptionsParamsSchema = v14.object({
|
|
797
|
-
transfers: v14.array(
|
|
798
|
-
v14.object({
|
|
799
|
-
address: v14.string(),
|
|
800
|
-
inscriptionId: v14.string()
|
|
801
|
-
})
|
|
802
|
-
)
|
|
803
|
-
});
|
|
804
|
-
var sendInscriptionsResultSchema = v14.object({
|
|
805
|
-
txid: v14.string()
|
|
806
|
-
});
|
|
807
|
-
var sendInscriptionsRequestMessageSchema = v14.object({
|
|
808
|
-
...rpcRequestMessageSchema.entries,
|
|
809
|
-
...v14.object({
|
|
810
|
-
method: v14.literal(sendInscriptionsMethodName),
|
|
811
|
-
params: sendInscriptionsParamsSchema,
|
|
812
|
-
id: v14.string()
|
|
813
|
-
}).entries
|
|
814
|
-
});
|
|
815
|
-
|
|
816
|
-
// src/request/types/runesMethods/etch.ts
|
|
817
|
-
import * as v15 from "valibot";
|
|
818
|
-
var runesEtchMethodName = "runes_etch";
|
|
819
|
-
var etchTermsSchema = v15.object({
|
|
820
|
-
amount: v15.string(),
|
|
821
|
-
cap: v15.string(),
|
|
822
|
-
heightStart: v15.optional(v15.string()),
|
|
823
|
-
heightEnd: v15.optional(v15.string()),
|
|
824
|
-
offsetStart: v15.optional(v15.string()),
|
|
825
|
-
offsetEnd: v15.optional(v15.string())
|
|
826
|
-
});
|
|
827
|
-
var inscriptionDetailsSchema = v15.object({
|
|
828
|
-
contentType: v15.string(),
|
|
829
|
-
contentBase64: v15.string()
|
|
830
|
-
});
|
|
831
|
-
var runesEtchParamsSchema = v15.object({
|
|
832
|
-
runeName: v15.string(),
|
|
833
|
-
divisibility: v15.optional(v15.number()),
|
|
834
|
-
symbol: v15.optional(v15.string()),
|
|
835
|
-
premine: v15.optional(v15.string()),
|
|
836
|
-
isMintable: v15.boolean(),
|
|
837
|
-
delegateInscriptionId: v15.optional(v15.string()),
|
|
838
|
-
destinationAddress: v15.string(),
|
|
839
|
-
refundAddress: v15.string(),
|
|
840
|
-
feeRate: v15.number(),
|
|
841
|
-
appServiceFee: v15.optional(v15.number()),
|
|
842
|
-
appServiceFeeAddress: v15.optional(v15.string()),
|
|
843
|
-
terms: v15.optional(etchTermsSchema),
|
|
844
|
-
inscriptionDetails: v15.optional(inscriptionDetailsSchema),
|
|
845
|
-
network: v15.optional(v15.enum(BitcoinNetworkType))
|
|
846
|
-
});
|
|
847
|
-
var runesEtchResultSchema = v15.object({
|
|
848
|
-
orderId: v15.string(),
|
|
849
|
-
fundTransactionId: v15.string(),
|
|
850
|
-
fundingAddress: v15.string()
|
|
851
|
-
});
|
|
852
|
-
var runesEtchRequestMessageSchema = v15.object({
|
|
853
|
-
...rpcRequestMessageSchema.entries,
|
|
854
|
-
...v15.object({
|
|
855
|
-
method: v15.literal(runesEtchMethodName),
|
|
856
|
-
params: runesEtchParamsSchema,
|
|
857
|
-
id: v15.string()
|
|
858
|
-
}).entries
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
// src/request/types/runesMethods/getBalance.ts
|
|
862
|
-
import * as v16 from "valibot";
|
|
863
|
-
var runesGetBalanceMethodName = "runes_getBalance";
|
|
864
|
-
var runesGetBalanceParamsSchema = v16.nullish(v16.null());
|
|
865
|
-
var runesGetBalanceResultSchema = v16.object({
|
|
866
|
-
balances: v16.array(
|
|
867
|
-
v16.object({
|
|
868
|
-
runeName: v16.string(),
|
|
869
|
-
amount: v16.string(),
|
|
870
|
-
divisibility: v16.number(),
|
|
871
|
-
symbol: v16.string(),
|
|
872
|
-
inscriptionId: v16.nullish(v16.string()),
|
|
873
|
-
spendableBalance: v16.string()
|
|
874
|
-
})
|
|
875
|
-
)
|
|
876
|
-
});
|
|
877
|
-
var runesGetBalanceRequestMessageSchema = v16.object({
|
|
878
|
-
...rpcRequestMessageSchema.entries,
|
|
879
|
-
...v16.object({
|
|
880
|
-
method: v16.literal(runesGetBalanceMethodName),
|
|
881
|
-
params: runesGetBalanceParamsSchema,
|
|
882
|
-
id: v16.string()
|
|
883
|
-
}).entries
|
|
884
|
-
});
|
|
885
|
-
|
|
886
|
-
// src/request/types/runesMethods/mint.ts
|
|
887
|
-
import * as v17 from "valibot";
|
|
888
|
-
var runesMintMethodName = "runes_mint";
|
|
889
|
-
var runesMintParamsSchema = v17.object({
|
|
890
|
-
appServiceFee: v17.optional(v17.number()),
|
|
891
|
-
appServiceFeeAddress: v17.optional(v17.string()),
|
|
892
|
-
destinationAddress: v17.string(),
|
|
893
|
-
feeRate: v17.number(),
|
|
894
|
-
refundAddress: v17.string(),
|
|
895
|
-
repeats: v17.number(),
|
|
896
|
-
runeName: v17.string(),
|
|
897
|
-
network: v17.optional(v17.enum(BitcoinNetworkType))
|
|
898
|
-
});
|
|
899
|
-
var runesMintResultSchema = v17.object({
|
|
900
|
-
orderId: v17.string(),
|
|
901
|
-
fundTransactionId: v17.string(),
|
|
902
|
-
fundingAddress: v17.string()
|
|
903
|
-
});
|
|
904
|
-
var runesMintRequestMessageSchema = v17.object({
|
|
905
|
-
...rpcRequestMessageSchema.entries,
|
|
906
|
-
...v17.object({
|
|
907
|
-
method: v17.literal(runesMintMethodName),
|
|
908
|
-
params: runesMintParamsSchema,
|
|
909
|
-
id: v17.string()
|
|
910
|
-
}).entries
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// src/request/types/runesMethods/transfer.ts
|
|
914
|
-
import * as v18 from "valibot";
|
|
915
|
-
var runesTransferMethodName = "runes_transfer";
|
|
916
|
-
var runesTransferParamsSchema = v18.object({
|
|
917
|
-
recipients: v18.array(
|
|
918
|
-
v18.object({
|
|
919
|
-
runeName: v18.string(),
|
|
920
|
-
amount: v18.string(),
|
|
921
|
-
address: v18.string()
|
|
922
|
-
})
|
|
923
|
-
)
|
|
924
|
-
});
|
|
925
|
-
var runesTransferResultSchema = v18.object({
|
|
926
|
-
txid: v18.string()
|
|
927
|
-
});
|
|
928
|
-
var runesTransferRequestMessageSchema = v18.object({
|
|
929
|
-
...rpcRequestMessageSchema.entries,
|
|
930
|
-
...v18.object({
|
|
931
|
-
method: v18.literal(runesTransferMethodName),
|
|
932
|
-
params: runesTransferParamsSchema,
|
|
933
|
-
id: v18.string()
|
|
934
|
-
}).entries
|
|
935
|
-
});
|
|
936
|
-
|
|
937
|
-
// src/request/types/sparkMethods/flashnetMethods/clawbackFunds.ts
|
|
938
|
-
import * as v19 from "valibot";
|
|
939
|
-
var sparkFlashnetClawbackFundsMethodName = "spark_flashnet_clawbackFunds";
|
|
940
|
-
var sparkFlashnetClawbackFundsParamsSchema = v19.object({
|
|
941
|
-
sparkTransferId: v19.string(),
|
|
942
|
-
lpIdentityPublicKey: v19.string()
|
|
943
|
-
});
|
|
944
|
-
var sparkFlashnetClawbackFundsResultSchema = v19.object({
|
|
945
|
-
requestId: v19.string(),
|
|
946
|
-
accepted: v19.boolean(),
|
|
947
|
-
internalRequestId: v19.optional(v19.string()),
|
|
948
|
-
sparkStatusTrackingId: v19.optional(v19.string()),
|
|
949
|
-
error: v19.optional(v19.string())
|
|
950
|
-
});
|
|
951
|
-
var sparkFlashnetClawbackFundsRequestMessageSchema = v19.object({
|
|
952
|
-
...rpcRequestMessageSchema.entries,
|
|
953
|
-
...v19.object({
|
|
954
|
-
method: v19.literal(sparkFlashnetClawbackFundsMethodName),
|
|
955
|
-
params: sparkFlashnetClawbackFundsParamsSchema,
|
|
956
|
-
id: v19.string()
|
|
957
|
-
}).entries
|
|
958
|
-
});
|
|
959
|
-
|
|
960
|
-
// src/request/types/sparkMethods/flashnetMethods/executeRouteSwap.ts
|
|
961
|
-
import * as v20 from "valibot";
|
|
962
|
-
var sparkFlashnetExecuteRouteSwapMethodName = "spark_flashnet_executeRouteSwap";
|
|
963
|
-
var sparkFlashnetExecuteRouteSwapParamsSchema = v20.object({
|
|
964
|
-
hops: v20.array(
|
|
965
|
-
v20.object({
|
|
966
|
-
poolId: v20.string(),
|
|
967
|
-
assetInAddress: v20.string(),
|
|
968
|
-
assetOutAddress: v20.string(),
|
|
969
|
-
hopIntegratorFeeRateBps: v20.optional(v20.number())
|
|
970
|
-
})
|
|
971
|
-
),
|
|
972
|
-
initialAssetAddress: v20.string(),
|
|
973
|
-
inputAmount: v20.string(),
|
|
974
|
-
maxRouteSlippageBps: v20.string(),
|
|
975
|
-
minAmountOut: v20.optional(v20.string()),
|
|
976
|
-
integratorFeeRateBps: v20.optional(v20.number()),
|
|
977
|
-
integratorPublicKey: v20.optional(v20.string())
|
|
978
|
-
});
|
|
979
|
-
var sparkFlashnetExecuteRouteSwapResultSchema = v20.object({
|
|
980
|
-
requestId: v20.string(),
|
|
981
|
-
accepted: v20.boolean(),
|
|
982
|
-
outputAmount: v20.string(),
|
|
983
|
-
executionPrice: v20.string(),
|
|
984
|
-
finalOutboundTransferId: v20.string(),
|
|
985
|
-
error: v20.optional(v20.string())
|
|
986
|
-
});
|
|
987
|
-
var sparkFlashnetExecuteRouteSwapRequestMessageSchema = v20.object({
|
|
988
|
-
...rpcRequestMessageSchema.entries,
|
|
989
|
-
...v20.object({
|
|
990
|
-
method: v20.literal(sparkFlashnetExecuteRouteSwapMethodName),
|
|
991
|
-
params: sparkFlashnetExecuteRouteSwapParamsSchema,
|
|
992
|
-
id: v20.string()
|
|
993
|
-
}).entries
|
|
994
|
-
});
|
|
995
|
-
|
|
996
|
-
// src/request/types/sparkMethods/flashnetMethods/executeSwap.ts
|
|
997
|
-
import * as v21 from "valibot";
|
|
998
|
-
var sparkFlashnetExecuteSwapMethodName = "spark_flashnet_executeSwap";
|
|
999
|
-
var sparkFlashnetExecuteSwapParamsSchema = v21.object({
|
|
1000
|
-
poolId: v21.string(),
|
|
1001
|
-
assetInAddress: v21.string(),
|
|
1002
|
-
assetOutAddress: v21.string(),
|
|
1003
|
-
amountIn: v21.string(),
|
|
1004
|
-
maxSlippageBps: v21.number(),
|
|
1005
|
-
minAmountOut: v21.optional(v21.string()),
|
|
1006
|
-
integratorFeeRateBps: v21.optional(v21.number()),
|
|
1007
|
-
integratorPublicKey: v21.optional(v21.string())
|
|
1008
|
-
});
|
|
1009
|
-
var sparkFlashnetExecuteSwapResultSchema = v21.object({
|
|
1010
|
-
requestId: v21.string(),
|
|
1011
|
-
accepted: v21.boolean(),
|
|
1012
|
-
amountOut: v21.optional(v21.string()),
|
|
1013
|
-
feeAmount: v21.optional(v21.string()),
|
|
1014
|
-
executionPrice: v21.optional(v21.string()),
|
|
1015
|
-
assetOutAddress: v21.optional(v21.string()),
|
|
1016
|
-
assetInAddress: v21.optional(v21.string()),
|
|
1017
|
-
outboundTransferId: v21.optional(v21.string()),
|
|
1018
|
-
error: v21.optional(v21.string())
|
|
1019
|
-
});
|
|
1020
|
-
var sparkFlashnetExecuteSwapRequestMessageSchema = v21.object({
|
|
1021
|
-
...rpcRequestMessageSchema.entries,
|
|
1022
|
-
...v21.object({
|
|
1023
|
-
method: v21.literal(sparkFlashnetExecuteSwapMethodName),
|
|
1024
|
-
params: sparkFlashnetExecuteSwapParamsSchema,
|
|
1025
|
-
id: v21.string()
|
|
1026
|
-
}).entries
|
|
1027
|
-
});
|
|
1028
|
-
|
|
1029
|
-
// src/request/types/sparkMethods/flashnetMethods/getClawbackEligibleTransfers.ts
|
|
1030
|
-
import * as v22 from "valibot";
|
|
1031
|
-
var sparkGetClawbackEligibleTransfersMethodName = "spark_flashnet_getClawbackEligibleTransfers";
|
|
1032
|
-
var sparkGetClawbackEligibleTransfersParamsSchema = v22.nullish(v22.null());
|
|
1033
|
-
var sparkGetClawbackEligibleTransfersResultSchema = v22.object({
|
|
1034
|
-
eligibleTransfers: v22.array(
|
|
1035
|
-
v22.object({
|
|
1036
|
-
txId: v22.string(),
|
|
1037
|
-
createdAt: v22.string(),
|
|
1038
|
-
lpIdentityPublicKey: v22.string()
|
|
1039
|
-
})
|
|
1040
|
-
)
|
|
1041
|
-
});
|
|
1042
|
-
var sparkGetClawbackEligibleTransfersRequestMessageSchema = v22.object({
|
|
1043
|
-
...rpcRequestMessageSchema.entries,
|
|
1044
|
-
...v22.object({
|
|
1045
|
-
method: v22.literal(sparkGetClawbackEligibleTransfersMethodName),
|
|
1046
|
-
params: sparkGetClawbackEligibleTransfersParamsSchema,
|
|
1047
|
-
id: v22.string()
|
|
1048
|
-
}).entries
|
|
1049
|
-
});
|
|
1050
|
-
|
|
1051
|
-
// src/request/types/sparkMethods/flashnetMethods/getJwt.ts
|
|
1052
|
-
import * as v23 from "valibot";
|
|
1053
|
-
var sparkFlashnetGetJwtMethodName = "spark_flashnet_getJwt";
|
|
1054
|
-
var sparkFlashnetGetJwtParamsSchema = v23.null();
|
|
1055
|
-
var sparkFlashnetGetJwtResultSchema = v23.object({
|
|
1056
|
-
/**
|
|
1057
|
-
* The JWT token for authenticated requests to the Flashnet API.
|
|
1058
|
-
*/
|
|
1059
|
-
jwt: v23.string()
|
|
1060
|
-
});
|
|
1061
|
-
var sparkFlashnetGetJwtRequestMessageSchema = v23.object({
|
|
1062
|
-
...rpcRequestMessageSchema.entries,
|
|
1063
|
-
...v23.object({
|
|
1064
|
-
method: v23.literal(sparkFlashnetGetJwtMethodName),
|
|
1065
|
-
params: sparkFlashnetGetJwtParamsSchema,
|
|
1066
|
-
id: v23.string()
|
|
1067
|
-
}).entries
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/addLiquidity.ts
|
|
1071
|
-
import * as v24 from "valibot";
|
|
1072
|
-
var sparkFlashnetAddLiquidityIntentSchema = v24.object({
|
|
1073
|
-
type: v24.literal("addLiquidity"),
|
|
1074
|
-
data: v24.object({
|
|
1075
|
-
userPublicKey: v24.string(),
|
|
1076
|
-
poolId: v24.string(),
|
|
1077
|
-
assetAAmount: v24.string(),
|
|
1078
|
-
assetBAmount: v24.string(),
|
|
1079
|
-
assetAMinAmountIn: v24.string(),
|
|
1080
|
-
assetBMinAmountIn: v24.string(),
|
|
1081
|
-
assetATransferId: v24.string(),
|
|
1082
|
-
assetBTransferId: v24.string(),
|
|
1083
|
-
nonce: v24.string()
|
|
1084
|
-
})
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/clawback.ts
|
|
1088
|
-
import * as v25 from "valibot";
|
|
1089
|
-
var sparkFlashnetClawbackIntentSchema = v25.object({
|
|
1090
|
-
type: v25.literal("clawback"),
|
|
1091
|
-
data: v25.object({
|
|
1092
|
-
senderPublicKey: v25.string(),
|
|
1093
|
-
sparkTransferId: v25.string(),
|
|
1094
|
-
lpIdentityPublicKey: v25.string(),
|
|
1095
|
-
nonce: v25.string()
|
|
1096
|
-
})
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/confirmInitialDeposit.ts
|
|
1100
|
-
import * as v26 from "valibot";
|
|
1101
|
-
var sparkFlashnetConfirmInitialDepositIntentSchema = v26.object({
|
|
1102
|
-
type: v26.literal("confirmInitialDeposit"),
|
|
1103
|
-
data: v26.object({
|
|
1104
|
-
poolId: v26.string(),
|
|
1105
|
-
assetASparkTransferId: v26.string(),
|
|
1106
|
-
poolOwnerPublicKey: v26.string(),
|
|
1107
|
-
nonce: v26.string()
|
|
1108
|
-
})
|
|
1109
|
-
});
|
|
1110
|
-
|
|
1111
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/createConstantProductPool.ts
|
|
1112
|
-
import * as v27 from "valibot";
|
|
1113
|
-
var sparkFlashnetCreateConstantProductPoolIntentSchema = v27.object({
|
|
1114
|
-
type: v27.literal("createConstantProductPool"),
|
|
1115
|
-
data: v27.object({
|
|
1116
|
-
poolOwnerPublicKey: v27.string(),
|
|
1117
|
-
assetAAddress: v27.string(),
|
|
1118
|
-
assetBAddress: v27.string(),
|
|
1119
|
-
lpFeeRateBps: v27.union([v27.number(), v27.string()]),
|
|
1120
|
-
totalHostFeeRateBps: v27.union([v27.number(), v27.string()]),
|
|
1121
|
-
nonce: v27.string()
|
|
1122
|
-
})
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/createSingleSidedPool.ts
|
|
1126
|
-
import * as v28 from "valibot";
|
|
1127
|
-
var sparkFlashnetCreateSingleSidedPoolIntentSchema = v28.object({
|
|
1128
|
-
type: v28.literal("createSingleSidedPool"),
|
|
1129
|
-
data: v28.object({
|
|
1130
|
-
assetAAddress: v28.string(),
|
|
1131
|
-
assetBAddress: v28.string(),
|
|
1132
|
-
assetAInitialReserve: v28.string(),
|
|
1133
|
-
virtualReserveA: v28.union([v28.number(), v28.string()]),
|
|
1134
|
-
virtualReserveB: v28.union([v28.number(), v28.string()]),
|
|
1135
|
-
threshold: v28.union([v28.number(), v28.string()]),
|
|
1136
|
-
lpFeeRateBps: v28.union([v28.number(), v28.string()]),
|
|
1137
|
-
totalHostFeeRateBps: v28.union([v28.number(), v28.string()]),
|
|
1138
|
-
poolOwnerPublicKey: v28.string(),
|
|
1139
|
-
nonce: v28.string()
|
|
1140
|
-
})
|
|
1141
|
-
});
|
|
1142
|
-
|
|
1143
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/removeLiquidity.ts
|
|
1144
|
-
import * as v29 from "valibot";
|
|
1145
|
-
var sparkFlashnetRemoveLiquidityIntentSchema = v29.object({
|
|
1146
|
-
type: v29.literal("removeLiquidity"),
|
|
1147
|
-
data: v29.object({
|
|
1148
|
-
userPublicKey: v29.string(),
|
|
1149
|
-
poolId: v29.string(),
|
|
1150
|
-
lpTokensToRemove: v29.string(),
|
|
1151
|
-
nonce: v29.string()
|
|
1152
|
-
})
|
|
1153
|
-
});
|
|
1154
|
-
|
|
1155
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/routeSwap.ts
|
|
1156
|
-
import * as v30 from "valibot";
|
|
1157
|
-
var sparkFlashnetRouteSwapIntentSchema = v30.object({
|
|
1158
|
-
type: v30.literal("executeRouteSwap"),
|
|
1159
|
-
data: v30.object({
|
|
1160
|
-
userPublicKey: v30.string(),
|
|
1161
|
-
initialSparkTransferId: v30.string(),
|
|
1162
|
-
hops: v30.array(
|
|
1163
|
-
v30.object({
|
|
1164
|
-
poolId: v30.string(),
|
|
1165
|
-
inputAssetAddress: v30.string(),
|
|
1166
|
-
outputAssetAddress: v30.string(),
|
|
1167
|
-
hopIntegratorFeeRateBps: v30.optional(v30.union([v30.number(), v30.string()]))
|
|
1168
|
-
})
|
|
1169
|
-
),
|
|
1170
|
-
inputAmount: v30.string(),
|
|
1171
|
-
maxRouteSlippageBps: v30.union([v30.number(), v30.string()]),
|
|
1172
|
-
minAmountOut: v30.string(),
|
|
1173
|
-
defaultIntegratorFeeRateBps: v30.optional(v30.union([v30.number(), v30.string()])),
|
|
1174
|
-
nonce: v30.string()
|
|
1175
|
-
})
|
|
1176
|
-
});
|
|
1177
|
-
|
|
1178
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/swap.ts
|
|
1179
|
-
import * as v31 from "valibot";
|
|
1180
|
-
var sparkFlashnetSwapIntentSchema = v31.object({
|
|
1181
|
-
type: v31.literal("executeSwap"),
|
|
1182
|
-
data: v31.object({
|
|
1183
|
-
userPublicKey: v31.string(),
|
|
1184
|
-
poolId: v31.string(),
|
|
1185
|
-
transferId: v31.string(),
|
|
1186
|
-
assetInAddress: v31.string(),
|
|
1187
|
-
assetOutAddress: v31.string(),
|
|
1188
|
-
amountIn: v31.string(),
|
|
1189
|
-
maxSlippageBps: v31.union([v31.number(), v31.string()]),
|
|
1190
|
-
minAmountOut: v31.string(),
|
|
1191
|
-
totalIntegratorFeeRateBps: v31.optional(v31.union([v31.number(), v31.string()])),
|
|
1192
|
-
nonce: v31.string()
|
|
1193
|
-
})
|
|
1194
|
-
});
|
|
1195
|
-
|
|
1196
|
-
// src/request/types/sparkMethods/flashnetMethods/signIntent.ts
|
|
1197
|
-
import * as v32 from "valibot";
|
|
1198
|
-
var sparkFlashnetSignIntentMethodName = "spark_flashnet_signIntent";
|
|
1199
|
-
var sparkFlashnetSignIntentParamsSchema = v32.union([
|
|
1200
|
-
sparkFlashnetSwapIntentSchema,
|
|
1201
|
-
sparkFlashnetRouteSwapIntentSchema,
|
|
1202
|
-
sparkFlashnetAddLiquidityIntentSchema,
|
|
1203
|
-
sparkFlashnetClawbackIntentSchema,
|
|
1204
|
-
sparkFlashnetConfirmInitialDepositIntentSchema,
|
|
1205
|
-
sparkFlashnetCreateConstantProductPoolIntentSchema,
|
|
1206
|
-
sparkFlashnetCreateSingleSidedPoolIntentSchema,
|
|
1207
|
-
sparkFlashnetRemoveLiquidityIntentSchema
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/request/rpc.ts
|
|
352
|
+
const rpcIdSchema = v.union([
|
|
353
|
+
v.string(),
|
|
354
|
+
v.number(),
|
|
355
|
+
v.null()
|
|
1208
356
|
]);
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
})
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
);
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
params: sparkGetAddressesParamsSchema,
|
|
1266
|
-
id: v34.string()
|
|
1267
|
-
}).entries
|
|
1268
|
-
});
|
|
1269
|
-
|
|
1270
|
-
// src/request/types/sparkMethods/getBalance.ts
|
|
1271
|
-
import * as v35 from "valibot";
|
|
1272
|
-
var sparkGetBalanceMethodName = "spark_getBalance";
|
|
1273
|
-
var sparkGetBalanceParamsSchema = v35.nullish(v35.null());
|
|
1274
|
-
var sparkGetBalanceResultSchema = v35.object({
|
|
1275
|
-
/**
|
|
1276
|
-
* The Spark Bitcoin address balance in sats in string form.
|
|
1277
|
-
*/
|
|
1278
|
-
balance: v35.string(),
|
|
1279
|
-
tokenBalances: v35.array(
|
|
1280
|
-
v35.object({
|
|
1281
|
-
/* The address balance of the token in string form as it can overflow a js number */
|
|
1282
|
-
balance: v35.string(),
|
|
1283
|
-
tokenMetadata: v35.object({
|
|
1284
|
-
tokenIdentifier: v35.string(),
|
|
1285
|
-
tokenName: v35.string(),
|
|
1286
|
-
tokenTicker: v35.string(),
|
|
1287
|
-
decimals: v35.number(),
|
|
1288
|
-
maxSupply: v35.string()
|
|
1289
|
-
})
|
|
1290
|
-
})
|
|
1291
|
-
)
|
|
1292
|
-
});
|
|
1293
|
-
var sparkGetBalanceRequestMessageSchema = v35.object({
|
|
1294
|
-
...rpcRequestMessageSchema.entries,
|
|
1295
|
-
...v35.object({
|
|
1296
|
-
method: v35.literal(sparkGetBalanceMethodName),
|
|
1297
|
-
params: sparkGetBalanceParamsSchema,
|
|
1298
|
-
id: v35.string()
|
|
1299
|
-
}).entries
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
// src/request/types/sparkMethods/signMessage.ts
|
|
1303
|
-
import * as v36 from "valibot";
|
|
1304
|
-
var sparkSignMessageMethodName = "spark_signMessage";
|
|
1305
|
-
var sparkSignMessageParamsSchema = v36.object({
|
|
1306
|
-
/**
|
|
1307
|
-
* The message to sign. The message should only consist of valid UTF-8 characters.
|
|
1308
|
-
*/
|
|
1309
|
-
message: v36.string()
|
|
1310
|
-
});
|
|
1311
|
-
var sparkSignMessageResultSchema = v36.object({
|
|
1312
|
-
/**
|
|
1313
|
-
* The signature, encoded in base64, of the message hash.
|
|
1314
|
-
*
|
|
1315
|
-
* Note: When signing, the message is decoded into a byte array,
|
|
1316
|
-
* and the resulting byte array is hashed with SHA256 before signing
|
|
1317
|
-
* with the private key.
|
|
1318
|
-
*/
|
|
1319
|
-
signature: v36.string()
|
|
1320
|
-
});
|
|
1321
|
-
var sparkSignMessageRequestMessageSchema = v36.object({
|
|
1322
|
-
...rpcRequestMessageSchema.entries,
|
|
1323
|
-
...v36.object({
|
|
1324
|
-
method: v36.literal(sparkSignMessageMethodName),
|
|
1325
|
-
params: sparkSignMessageParamsSchema,
|
|
1326
|
-
id: v36.string()
|
|
1327
|
-
}).entries
|
|
1328
|
-
});
|
|
1329
|
-
|
|
1330
|
-
// src/request/types/sparkMethods/transfer.ts
|
|
1331
|
-
import * as v37 from "valibot";
|
|
1332
|
-
var sparkTransferMethodName = "spark_transfer";
|
|
1333
|
-
var sparkTransferParamsSchema = v37.object({
|
|
1334
|
-
/**
|
|
1335
|
-
* Amount of SATS to transfer as a string or number.
|
|
1336
|
-
*/
|
|
1337
|
-
amountSats: v37.union([v37.number(), v37.string()]),
|
|
1338
|
-
/**
|
|
1339
|
-
* The recipient's spark address.
|
|
1340
|
-
*/
|
|
1341
|
-
receiverSparkAddress: v37.string()
|
|
1342
|
-
});
|
|
1343
|
-
var sparkTransferResultSchema = v37.object({
|
|
1344
|
-
/**
|
|
1345
|
-
* The ID of the transaction.
|
|
1346
|
-
*/
|
|
1347
|
-
id: v37.string()
|
|
1348
|
-
});
|
|
1349
|
-
var sparkTransferRequestMessageSchema = v37.object({
|
|
1350
|
-
...rpcRequestMessageSchema.entries,
|
|
1351
|
-
...v37.object({
|
|
1352
|
-
method: v37.literal(sparkTransferMethodName),
|
|
1353
|
-
params: sparkTransferParamsSchema,
|
|
1354
|
-
id: v37.string()
|
|
1355
|
-
}).entries
|
|
1356
|
-
});
|
|
1357
|
-
|
|
1358
|
-
// src/request/types/sparkMethods/transferToken.ts
|
|
1359
|
-
import * as v38 from "valibot";
|
|
1360
|
-
var sparkTransferTokenMethodName = "spark_transferToken";
|
|
1361
|
-
var sparkTransferTokenParamsSchema = v38.object({
|
|
1362
|
-
/**
|
|
1363
|
-
* Amount of units of the token to transfer as a string or number.
|
|
1364
|
-
*/
|
|
1365
|
-
tokenAmount: v38.union([v38.number(), v38.string()]),
|
|
1366
|
-
/**
|
|
1367
|
-
* The Bech32m token identifier.
|
|
1368
|
-
*/
|
|
1369
|
-
tokenIdentifier: v38.string(),
|
|
1370
|
-
/**
|
|
1371
|
-
* The recipient's spark address.
|
|
1372
|
-
*/
|
|
1373
|
-
receiverSparkAddress: v38.string()
|
|
1374
|
-
});
|
|
1375
|
-
var sparkTransferTokenResultSchema = v38.object({
|
|
1376
|
-
/**
|
|
1377
|
-
* The ID of the transaction.
|
|
1378
|
-
*/
|
|
1379
|
-
id: v38.string()
|
|
1380
|
-
});
|
|
1381
|
-
var sparkTransferTokenRequestMessageSchema = v38.object({
|
|
1382
|
-
...rpcRequestMessageSchema.entries,
|
|
1383
|
-
...v38.object({
|
|
1384
|
-
method: v38.literal(sparkTransferTokenMethodName),
|
|
1385
|
-
params: sparkTransferTokenParamsSchema,
|
|
1386
|
-
id: v38.string()
|
|
1387
|
-
}).entries
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
// src/request/types/stxMethods/callContract.ts
|
|
1391
|
-
import * as v39 from "valibot";
|
|
1392
|
-
var stxCallContractMethodName = "stx_callContract";
|
|
1393
|
-
var stxCallContractParamsSchema = v39.object({
|
|
1394
|
-
/**
|
|
1395
|
-
* The contract principal.
|
|
1396
|
-
*
|
|
1397
|
-
* E.g. `"SPKE...GD5C.my-contract"`
|
|
1398
|
-
*/
|
|
1399
|
-
contract: v39.string(),
|
|
1400
|
-
/**
|
|
1401
|
-
* The name of the function to call.
|
|
1402
|
-
*
|
|
1403
|
-
* Note: spec changes ongoing,
|
|
1404
|
-
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
1405
|
-
*/
|
|
1406
|
-
functionName: v39.string(),
|
|
1407
|
-
/**
|
|
1408
|
-
* @deprecated in favor of `functionArgs` for @stacks/connect compatibility
|
|
1409
|
-
*/
|
|
1410
|
-
arguments: v39.optional(v39.array(v39.string())),
|
|
1411
|
-
/**
|
|
1412
|
-
* The function's arguments. The arguments are expected to be hex-encoded
|
|
1413
|
-
* strings of Clarity values.
|
|
1414
|
-
*
|
|
1415
|
-
* To convert Clarity values to their hex representation, the `cvToHex`
|
|
1416
|
-
* helper from the `@stacks/transactions` package may be helpful.
|
|
1417
|
-
*
|
|
1418
|
-
* ```js
|
|
1419
|
-
* import { cvToHex } from '@stacks/transactions';
|
|
1420
|
-
*
|
|
1421
|
-
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
1422
|
-
* const hexArgs = functionArgs.map(cvToHex);
|
|
1423
|
-
* ```
|
|
1424
|
-
*/
|
|
1425
|
-
functionArgs: v39.optional(v39.array(v39.string())),
|
|
1426
|
-
/**
|
|
1427
|
-
* The post conditions to apply to the contract call.
|
|
1428
|
-
*/
|
|
1429
|
-
postConditions: v39.optional(v39.array(v39.string())),
|
|
1430
|
-
/**
|
|
1431
|
-
* The mode to apply to the post conditions.
|
|
1432
|
-
*/
|
|
1433
|
-
postConditionMode: v39.optional(v39.union([v39.literal("allow"), v39.literal("deny")]))
|
|
1434
|
-
});
|
|
1435
|
-
var stxCallContractResultSchema = v39.object({
|
|
1436
|
-
/**
|
|
1437
|
-
* The ID of the transaction.
|
|
1438
|
-
*/
|
|
1439
|
-
txid: v39.string(),
|
|
1440
|
-
/**
|
|
1441
|
-
* A Stacks transaction as a hex-encoded string.
|
|
1442
|
-
*/
|
|
1443
|
-
transaction: v39.string()
|
|
1444
|
-
});
|
|
1445
|
-
var stxCallContractRequestMessageSchema = v39.object({
|
|
1446
|
-
...rpcRequestMessageSchema.entries,
|
|
1447
|
-
...v39.object({
|
|
1448
|
-
method: v39.literal(stxCallContractMethodName),
|
|
1449
|
-
params: stxCallContractParamsSchema,
|
|
1450
|
-
id: v39.string()
|
|
1451
|
-
}).entries
|
|
1452
|
-
});
|
|
1453
|
-
|
|
1454
|
-
// src/request/types/stxMethods/deployContract.ts
|
|
1455
|
-
import * as v40 from "valibot";
|
|
1456
|
-
var stxDeployContractMethodName = "stx_deployContract";
|
|
1457
|
-
var stxDeployContractParamsSchema = v40.object({
|
|
1458
|
-
/**
|
|
1459
|
-
* Name of the contract.
|
|
1460
|
-
*/
|
|
1461
|
-
name: v40.string(),
|
|
1462
|
-
/**
|
|
1463
|
-
* The source code of the Clarity contract.
|
|
1464
|
-
*/
|
|
1465
|
-
clarityCode: v40.string(),
|
|
1466
|
-
/**
|
|
1467
|
-
* The version of the Clarity contract.
|
|
1468
|
-
*/
|
|
1469
|
-
clarityVersion: v40.optional(v40.number()),
|
|
1470
|
-
/**
|
|
1471
|
-
* The post conditions to apply to the contract call.
|
|
1472
|
-
*/
|
|
1473
|
-
postConditions: v40.optional(v40.array(v40.string())),
|
|
1474
|
-
/**
|
|
1475
|
-
* The mode to apply to the post conditions.
|
|
1476
|
-
*/
|
|
1477
|
-
postConditionMode: v40.optional(v40.union([v40.literal("allow"), v40.literal("deny")]))
|
|
1478
|
-
});
|
|
1479
|
-
var stxDeployContractResultSchema = v40.object({
|
|
1480
|
-
/**
|
|
1481
|
-
* The ID of the transaction.
|
|
1482
|
-
*/
|
|
1483
|
-
txid: v40.string(),
|
|
1484
|
-
/**
|
|
1485
|
-
* A Stacks transaction as a hex-encoded string.
|
|
1486
|
-
*/
|
|
1487
|
-
transaction: v40.string()
|
|
1488
|
-
});
|
|
1489
|
-
var stxDeployContractRequestMessageSchema = v40.object({
|
|
1490
|
-
...rpcRequestMessageSchema.entries,
|
|
1491
|
-
...v40.object({
|
|
1492
|
-
method: v40.literal(stxDeployContractMethodName),
|
|
1493
|
-
params: stxDeployContractParamsSchema,
|
|
1494
|
-
id: v40.string()
|
|
1495
|
-
}).entries
|
|
1496
|
-
});
|
|
1497
|
-
|
|
1498
|
-
// src/request/types/stxMethods/getAccounts.ts
|
|
1499
|
-
import * as v41 from "valibot";
|
|
1500
|
-
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
1501
|
-
var stxGetAccountsParamsSchema = v41.nullish(v41.null());
|
|
1502
|
-
var stxGetAccountsResultSchema = v41.object({
|
|
1503
|
-
/**
|
|
1504
|
-
* The addresses generated for the given purposes.
|
|
1505
|
-
*/
|
|
1506
|
-
addresses: v41.array(
|
|
1507
|
-
v41.object({
|
|
1508
|
-
address: v41.string(),
|
|
1509
|
-
publicKey: v41.string(),
|
|
1510
|
-
gaiaHubUrl: v41.string(),
|
|
1511
|
-
gaiaAppKey: v41.string()
|
|
1512
|
-
})
|
|
1513
|
-
),
|
|
1514
|
-
network: getNetworkResultSchema
|
|
1515
|
-
});
|
|
1516
|
-
var stxGetAccountsRequestMessageSchema = v41.object({
|
|
1517
|
-
...rpcRequestMessageSchema.entries,
|
|
1518
|
-
...v41.object({
|
|
1519
|
-
method: v41.literal(stxGetAccountsMethodName),
|
|
1520
|
-
params: stxGetAccountsParamsSchema,
|
|
1521
|
-
id: v41.string()
|
|
1522
|
-
}).entries
|
|
1523
|
-
});
|
|
1524
|
-
|
|
1525
|
-
// src/request/types/stxMethods/getAddresses.ts
|
|
1526
|
-
import * as v42 from "valibot";
|
|
1527
|
-
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
1528
|
-
var stxGetAddressesParamsSchema = v42.nullish(
|
|
1529
|
-
v42.object({
|
|
1530
|
-
/**
|
|
1531
|
-
* A message to be displayed to the user in the request prompt.
|
|
1532
|
-
*/
|
|
1533
|
-
message: v42.optional(v42.string())
|
|
1534
|
-
})
|
|
1535
|
-
);
|
|
1536
|
-
var stxGetAddressesResultSchema = v42.object({
|
|
1537
|
-
/**
|
|
1538
|
-
* The addresses generated for the given purposes.
|
|
1539
|
-
*/
|
|
1540
|
-
addresses: v42.array(addressSchema),
|
|
1541
|
-
network: getNetworkResultSchema
|
|
1542
|
-
});
|
|
1543
|
-
var stxGetAddressesRequestMessageSchema = v42.object({
|
|
1544
|
-
...rpcRequestMessageSchema.entries,
|
|
1545
|
-
...v42.object({
|
|
1546
|
-
method: v42.literal(stxGetAddressesMethodName),
|
|
1547
|
-
params: stxGetAddressesParamsSchema,
|
|
1548
|
-
id: v42.string()
|
|
1549
|
-
}).entries
|
|
1550
|
-
});
|
|
1551
|
-
|
|
1552
|
-
// src/request/types/stxMethods/signMessage.ts
|
|
1553
|
-
import * as v43 from "valibot";
|
|
1554
|
-
var stxSignMessageMethodName = "stx_signMessage";
|
|
1555
|
-
var stxSignMessageParamsSchema = v43.object({
|
|
1556
|
-
/**
|
|
1557
|
-
* The message to sign.
|
|
1558
|
-
*/
|
|
1559
|
-
message: v43.string()
|
|
1560
|
-
});
|
|
1561
|
-
var stxSignMessageResultSchema = v43.object({
|
|
1562
|
-
/**
|
|
1563
|
-
* The signature of the message.
|
|
1564
|
-
*/
|
|
1565
|
-
signature: v43.string(),
|
|
1566
|
-
/**
|
|
1567
|
-
* The public key used to sign the message.
|
|
1568
|
-
*/
|
|
1569
|
-
publicKey: v43.string()
|
|
1570
|
-
});
|
|
1571
|
-
var stxSignMessageRequestMessageSchema = v43.object({
|
|
1572
|
-
...rpcRequestMessageSchema.entries,
|
|
1573
|
-
...v43.object({
|
|
1574
|
-
method: v43.literal(stxSignMessageMethodName),
|
|
1575
|
-
params: stxSignMessageParamsSchema,
|
|
1576
|
-
id: v43.string()
|
|
1577
|
-
}).entries
|
|
1578
|
-
});
|
|
1579
|
-
|
|
1580
|
-
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
1581
|
-
import * as v44 from "valibot";
|
|
1582
|
-
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
1583
|
-
var stxSignStructuredMessageParamsSchema = v44.object({
|
|
1584
|
-
/**
|
|
1585
|
-
* The domain to be signed.
|
|
1586
|
-
*/
|
|
1587
|
-
domain: v44.string(),
|
|
1588
|
-
/**
|
|
1589
|
-
* Message payload to be signed.
|
|
1590
|
-
*/
|
|
1591
|
-
message: v44.string(),
|
|
1592
|
-
/**
|
|
1593
|
-
* The public key to sign the message with.
|
|
1594
|
-
*/
|
|
1595
|
-
publicKey: v44.optional(v44.string())
|
|
1596
|
-
});
|
|
1597
|
-
var stxSignStructuredMessageResultSchema = v44.object({
|
|
1598
|
-
/**
|
|
1599
|
-
* Signature of the message.
|
|
1600
|
-
*/
|
|
1601
|
-
signature: v44.string(),
|
|
1602
|
-
/**
|
|
1603
|
-
* Public key as hex-encoded string.
|
|
1604
|
-
*/
|
|
1605
|
-
publicKey: v44.string()
|
|
1606
|
-
});
|
|
1607
|
-
var stxSignStructuredMessageRequestMessageSchema = v44.object({
|
|
1608
|
-
...rpcRequestMessageSchema.entries,
|
|
1609
|
-
...v44.object({
|
|
1610
|
-
method: v44.literal(stxSignStructuredMessageMethodName),
|
|
1611
|
-
params: stxSignStructuredMessageParamsSchema,
|
|
1612
|
-
id: v44.string()
|
|
1613
|
-
}).entries
|
|
1614
|
-
});
|
|
1615
|
-
|
|
1616
|
-
// src/request/types/stxMethods/signTransaction.ts
|
|
1617
|
-
import * as v45 from "valibot";
|
|
1618
|
-
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
1619
|
-
var stxSignTransactionParamsSchema = v45.object({
|
|
1620
|
-
/**
|
|
1621
|
-
* The transaction to sign as a hex-encoded string.
|
|
1622
|
-
*/
|
|
1623
|
-
transaction: v45.string(),
|
|
1624
|
-
/**
|
|
1625
|
-
* The public key to sign the transaction with. The wallet may use any key
|
|
1626
|
-
* when not provided.
|
|
1627
|
-
*/
|
|
1628
|
-
pubkey: v45.optional(v45.string()),
|
|
1629
|
-
/**
|
|
1630
|
-
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
1631
|
-
*/
|
|
1632
|
-
broadcast: v45.optional(v45.boolean())
|
|
1633
|
-
});
|
|
1634
|
-
var stxSignTransactionResultSchema = v45.object({
|
|
1635
|
-
/**
|
|
1636
|
-
* The signed transaction as a hex-encoded string.
|
|
1637
|
-
*/
|
|
1638
|
-
transaction: v45.string()
|
|
1639
|
-
});
|
|
1640
|
-
var stxSignTransactionRequestMessageSchema = v45.object({
|
|
1641
|
-
...rpcRequestMessageSchema.entries,
|
|
1642
|
-
...v45.object({
|
|
1643
|
-
method: v45.literal(stxSignTransactionMethodName),
|
|
1644
|
-
params: stxSignTransactionParamsSchema,
|
|
1645
|
-
id: v45.string()
|
|
1646
|
-
}).entries
|
|
1647
|
-
});
|
|
357
|
+
const rpcRequestSchema = v.object({
|
|
358
|
+
jsonrpc: v.literal("2.0"),
|
|
359
|
+
method: v.string(),
|
|
360
|
+
params: v.optional(v.union([
|
|
361
|
+
v.array(v.unknown()),
|
|
362
|
+
v.looseObject({}),
|
|
363
|
+
v.null()
|
|
364
|
+
])),
|
|
365
|
+
id: v.optional(rpcIdSchema)
|
|
366
|
+
});
|
|
367
|
+
const rpcSuccessResponseSchema = v.object({
|
|
368
|
+
jsonrpc: v.literal("2.0"),
|
|
369
|
+
result: v.unknown(),
|
|
370
|
+
id: rpcIdSchema
|
|
371
|
+
});
|
|
372
|
+
const warningSchema = v.variant("code", [v.object({
|
|
373
|
+
code: v.literal("DEPRECATION_NOTICE"),
|
|
374
|
+
message: v.string(),
|
|
375
|
+
sunsetDate: v.pipe(v.string(), v.isoDate())
|
|
376
|
+
})]);
|
|
377
|
+
/**
|
|
378
|
+
* Extends the standard JSON RPC 2.0 with an additional field as a means of
|
|
379
|
+
* providing clients with extra data, such as deprecation warnings, without
|
|
380
|
+
* altering the main payloads.
|
|
381
|
+
*
|
|
382
|
+
* A JSON-RPC response must either be a result (success) or an error (failure).
|
|
383
|
+
* To provide additional data, conventions must be layered atop these two types.
|
|
384
|
+
* Having an additional property is the least disruptive approach, and is
|
|
385
|
+
* acceptable when clients are known to be able to handle such a structure,
|
|
386
|
+
* which they can since they're all part of Sats Connect.
|
|
387
|
+
*/
|
|
388
|
+
const rpcSuccessWithExtensionsResponseSchema = v.object({
|
|
389
|
+
...rpcSuccessResponseSchema.entries,
|
|
390
|
+
extensions: v.optional(v.object({ warnings: v.array(warningSchema) }))
|
|
391
|
+
});
|
|
392
|
+
const rpcErrorObject = v.object({
|
|
393
|
+
code: v.number(),
|
|
394
|
+
message: v.string(),
|
|
395
|
+
data: v.optional(v.unknown())
|
|
396
|
+
});
|
|
397
|
+
const rpcErrorResponseSchema = v.object({
|
|
398
|
+
jsonrpc: v.literal("2.0"),
|
|
399
|
+
error: rpcErrorObject,
|
|
400
|
+
id: rpcIdSchema
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/request/createSuccessResponseSchema.ts
|
|
405
|
+
function createSuccessResponseSchema({ method, resultSchema }) {
|
|
406
|
+
return v.object({
|
|
407
|
+
...rpcSuccessWithExtensionsResponseSchema.entries,
|
|
408
|
+
id: v.string(),
|
|
409
|
+
result: resultSchema,
|
|
410
|
+
"~sats-connect-method": v.literal(method)
|
|
411
|
+
});
|
|
412
|
+
}
|
|
1648
413
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
* to `true`.
|
|
1670
|
-
*/
|
|
1671
|
-
broadcast: v46.optional(v46.boolean())
|
|
1672
|
-
});
|
|
1673
|
-
var stxSignTransactionsResultSchema = v46.object({
|
|
1674
|
-
/**
|
|
1675
|
-
* The signed transactions as hex-encoded strings, in the same order as in the
|
|
1676
|
-
* sign request.
|
|
1677
|
-
*/
|
|
1678
|
-
transactions: v46.array(v46.string())
|
|
1679
|
-
});
|
|
1680
|
-
var stxSignTransactionsRequestMessageSchema = v46.object({
|
|
1681
|
-
...rpcRequestMessageSchema.entries,
|
|
1682
|
-
...v46.object({
|
|
1683
|
-
method: v46.literal(stxSignTransactionsMethodName),
|
|
1684
|
-
params: stxSignTransactionsParamsSchema,
|
|
1685
|
-
id: v46.string()
|
|
1686
|
-
}).entries
|
|
1687
|
-
});
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/request/methods.ts
|
|
416
|
+
const bitcoinMethods = {
|
|
417
|
+
getAccounts: "getAccounts",
|
|
418
|
+
bitcoin_getAccountsV2: "bitcoin_getAccountsV2",
|
|
419
|
+
getAddresses: "getAddresses",
|
|
420
|
+
bitcoin_getAddressesV2: "bitcoin_getAddressesV2",
|
|
421
|
+
getBalance: "getBalance",
|
|
422
|
+
bitcoin_getBalanceV2: "bitcoin_getBalanceV2",
|
|
423
|
+
getInfo: "getInfo",
|
|
424
|
+
bitcoin_getInfoV2: "bitcoin_getInfoV2",
|
|
425
|
+
sendTransfer: "sendTransfer",
|
|
426
|
+
bitcoin_sendTransferV2: "bitcoin_sendTransferV2",
|
|
427
|
+
signMessage: "signMessage",
|
|
428
|
+
bitcoin_signMessageV2: "bitcoin_signMessageV2",
|
|
429
|
+
signMultipleMessages: "signMultipleMessages",
|
|
430
|
+
bitcoin_signMultipleMessagesV2: "bitcoin_signMultipleMessagesV2",
|
|
431
|
+
signPsbt: "signPsbt",
|
|
432
|
+
bitcoin_signPsbtV2: "bitcoin_signPsbtV2"
|
|
433
|
+
};
|
|
1688
434
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
*/
|
|
1717
|
-
version: v47.optional(v47.string()),
|
|
1718
|
-
/**
|
|
1719
|
-
* The mode of the post conditions.
|
|
1720
|
-
*/
|
|
1721
|
-
postConditionMode: v47.optional(v47.number()),
|
|
1722
|
-
/**
|
|
1723
|
-
* A hex-encoded string representing the post conditions.
|
|
1724
|
-
*
|
|
1725
|
-
* A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
|
|
1726
|
-
*
|
|
1727
|
-
* ```js
|
|
1728
|
-
* import { serializePostCondition } from '@stacks/transactions';
|
|
1729
|
-
*
|
|
1730
|
-
* const postCondition = somePostCondition;
|
|
1731
|
-
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
1732
|
-
* ```
|
|
1733
|
-
*/
|
|
1734
|
-
postConditions: v47.optional(v47.array(v47.string())),
|
|
1735
|
-
/**
|
|
1736
|
-
* The public key to sign the transaction with. The wallet may use any key
|
|
1737
|
-
* when not provided.
|
|
1738
|
-
*/
|
|
1739
|
-
pubkey: v47.optional(v47.string())
|
|
1740
|
-
});
|
|
1741
|
-
var stxTransferStxResultSchema = v47.object({
|
|
1742
|
-
/**
|
|
1743
|
-
* The ID of the transaction.
|
|
1744
|
-
*/
|
|
1745
|
-
txid: v47.string(),
|
|
1746
|
-
/**
|
|
1747
|
-
* A Stacks transaction as a hex-encoded string.
|
|
1748
|
-
*/
|
|
1749
|
-
transaction: v47.string()
|
|
1750
|
-
});
|
|
1751
|
-
var stxTransferStxRequestMessageSchema = v47.object({
|
|
1752
|
-
...rpcRequestMessageSchema.entries,
|
|
1753
|
-
...v47.object({
|
|
1754
|
-
method: v47.literal(stxTransferStxMethodName),
|
|
1755
|
-
params: stxTransferStxParamsSchema,
|
|
1756
|
-
id: v47.string()
|
|
1757
|
-
}).entries
|
|
1758
|
-
});
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/request/rpc/methodSchemas/bitcoin/getInfo/response.ts
|
|
437
|
+
let ProviderPlatform = /* @__PURE__ */ function(ProviderPlatform$1) {
|
|
438
|
+
ProviderPlatform$1["Web"] = "web";
|
|
439
|
+
ProviderPlatform$1["Mobile"] = "mobile";
|
|
440
|
+
return ProviderPlatform$1;
|
|
441
|
+
}({});
|
|
442
|
+
const bitcoinGetInfoSuccessResponseSchema = createSuccessResponseSchema({
|
|
443
|
+
resultSchema: v.object({
|
|
444
|
+
version: v.string(),
|
|
445
|
+
platform: v.optional(v.enum(ProviderPlatform)),
|
|
446
|
+
methods: v.optional(v.array(v.string())),
|
|
447
|
+
supports: v.array(v.string())
|
|
448
|
+
}),
|
|
449
|
+
method: bitcoinMethods.getInfo
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/request/createRequestSchema.ts
|
|
454
|
+
function createRequestSchema({ paramsSchema, method }) {
|
|
455
|
+
return v.object({
|
|
456
|
+
...rpcRequestSchema.entries,
|
|
457
|
+
id: v.string(),
|
|
458
|
+
method: v.literal(method),
|
|
459
|
+
params: paramsSchema
|
|
460
|
+
});
|
|
461
|
+
}
|
|
1759
462
|
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/request/rpc/methodSchemas/bitcoin/signMessage/request.ts
|
|
465
|
+
let MessageSigningProtocols = /* @__PURE__ */ function(MessageSigningProtocols$1) {
|
|
466
|
+
MessageSigningProtocols$1["ECDSA"] = "ECDSA";
|
|
467
|
+
MessageSigningProtocols$1["BIP322"] = "BIP322";
|
|
468
|
+
return MessageSigningProtocols$1;
|
|
469
|
+
}({});
|
|
470
|
+
const bitcoinSignMessageRequestSchema = createRequestSchema({
|
|
471
|
+
paramsSchema: v.object({
|
|
472
|
+
address: v.string(),
|
|
473
|
+
message: v.string(),
|
|
474
|
+
protocol: v.optional(v.enum(MessageSigningProtocols))
|
|
475
|
+
}),
|
|
476
|
+
method: bitcoinMethods.signMessage
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/request/index.ts
|
|
481
|
+
const cache = {};
|
|
482
|
+
const requestInternal = async (provider, method, params) => {
|
|
483
|
+
const response = await provider.request(method, params);
|
|
484
|
+
if (v.is(rpcErrorResponseMessageSchema, response)) return {
|
|
485
|
+
status: "error",
|
|
486
|
+
error: response.error
|
|
487
|
+
};
|
|
488
|
+
if (v.is(rpcSuccessResponseMessageSchema, response)) return {
|
|
489
|
+
status: "success",
|
|
490
|
+
result: response.result
|
|
491
|
+
};
|
|
492
|
+
return {
|
|
493
|
+
status: "error",
|
|
494
|
+
error: {
|
|
495
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
496
|
+
message: "Received unknown response from provider.",
|
|
497
|
+
data: response
|
|
498
|
+
}
|
|
499
|
+
};
|
|
1784
500
|
};
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
status: "success",
|
|
1806
|
-
result: cache.providerInfo
|
|
1807
|
-
};
|
|
1808
|
-
}
|
|
1809
|
-
const sanitized = sanitizeRequest(method, params, cache.providerInfo);
|
|
1810
|
-
if (sanitized.overrideResponse) {
|
|
1811
|
-
return sanitized.overrideResponse;
|
|
1812
|
-
}
|
|
1813
|
-
method = sanitized.method;
|
|
1814
|
-
params = sanitized.params;
|
|
1815
|
-
}
|
|
1816
|
-
return requestInternal(provider, method, params);
|
|
501
|
+
const request = async (method, params, providerId) => {
|
|
502
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
503
|
+
if (providerId) provider = await getProviderById(providerId);
|
|
504
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
505
|
+
if (!method) throw new Error("A wallet method is required");
|
|
506
|
+
if (!cache.providerInfo) {
|
|
507
|
+
const infoResult = await requestInternal(provider, "getInfo", null);
|
|
508
|
+
if (infoResult.status === "success") cache.providerInfo = infoResult.result;
|
|
509
|
+
}
|
|
510
|
+
if (cache.providerInfo) {
|
|
511
|
+
if (method === "getInfo") return {
|
|
512
|
+
status: "success",
|
|
513
|
+
result: cache.providerInfo
|
|
514
|
+
};
|
|
515
|
+
const sanitized = sanitizeRequest(method, params, cache.providerInfo);
|
|
516
|
+
if (sanitized.overrideResponse) return sanitized.overrideResponse;
|
|
517
|
+
method = sanitized.method;
|
|
518
|
+
params = sanitized.params;
|
|
519
|
+
}
|
|
520
|
+
return requestInternal(provider, method, params);
|
|
1817
521
|
};
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
if (providerId) {
|
|
1851
|
-
provider = getProviderById(providerId);
|
|
1852
|
-
}
|
|
1853
|
-
if (!provider) {
|
|
1854
|
-
throw new Error("no wallet provider was found");
|
|
1855
|
-
}
|
|
1856
|
-
if (!provider.addListener) {
|
|
1857
|
-
console.error(
|
|
1858
|
-
`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`
|
|
1859
|
-
);
|
|
1860
|
-
return () => {
|
|
1861
|
-
};
|
|
1862
|
-
}
|
|
1863
|
-
return provider.addListener(listenerInfo);
|
|
522
|
+
/**
|
|
523
|
+
* Adds an event listener.
|
|
524
|
+
*
|
|
525
|
+
* Currently expects 2 arguments, although is also capable of handling legacy
|
|
526
|
+
* calls with 3 arguments consisting of:
|
|
527
|
+
*
|
|
528
|
+
* - event name (string)
|
|
529
|
+
* - callback (function)
|
|
530
|
+
* - provider ID (optional string)
|
|
531
|
+
*/
|
|
532
|
+
const addListener = (...rawArgs) => {
|
|
533
|
+
const [listenerInfo, providerId] = (() => {
|
|
534
|
+
if (rawArgs.length === 1) return [rawArgs[0], void 0];
|
|
535
|
+
if (rawArgs.length === 2) if (typeof rawArgs[1] === "function") return [{
|
|
536
|
+
eventName: rawArgs[0],
|
|
537
|
+
cb: rawArgs[1]
|
|
538
|
+
}, void 0];
|
|
539
|
+
else return rawArgs;
|
|
540
|
+
if (rawArgs.length === 3) return [{
|
|
541
|
+
eventName: rawArgs[0],
|
|
542
|
+
cb: rawArgs[1]
|
|
543
|
+
}, rawArgs[2]];
|
|
544
|
+
throw new Error("Unexpected number of arguments. Expecting 2 (or 3 for legacy requests).", { cause: rawArgs });
|
|
545
|
+
})();
|
|
546
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
547
|
+
if (providerId) provider = getProviderById(providerId);
|
|
548
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
549
|
+
if (!provider.addListener) {
|
|
550
|
+
console.error(`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`);
|
|
551
|
+
return () => {};
|
|
552
|
+
}
|
|
553
|
+
return provider.addListener(listenerInfo);
|
|
1864
554
|
};
|
|
1865
555
|
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region src/runes/api.ts
|
|
558
|
+
const urlNetworkSuffix = {
|
|
559
|
+
[BitcoinNetworkType.Mainnet]: "",
|
|
560
|
+
[BitcoinNetworkType.Testnet]: "-testnet",
|
|
561
|
+
[BitcoinNetworkType.Testnet4]: "-testnet4",
|
|
562
|
+
[BitcoinNetworkType.Signet]: "-signet"
|
|
1873
563
|
};
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
}
|
|
1878
|
-
return `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
|
564
|
+
const ORDINALS_API_BASE_URL = (network = BitcoinNetworkType.Mainnet) => {
|
|
565
|
+
if (network === BitcoinNetworkType.Regtest) throw new Error(`Ordinals API does not support ${network} network`);
|
|
566
|
+
return `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
|
1879
567
|
};
|
|
1880
568
|
var RunesApi = class {
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
fundTransactionId
|
|
1957
|
-
});
|
|
1958
|
-
return {
|
|
1959
|
-
data: response.data
|
|
1960
|
-
};
|
|
1961
|
-
} catch (error) {
|
|
1962
|
-
const err = error;
|
|
1963
|
-
return {
|
|
1964
|
-
error: this.parseError(err)
|
|
1965
|
-
};
|
|
1966
|
-
}
|
|
1967
|
-
};
|
|
1968
|
-
executeEtch = async (orderId, fundTransactionId) => {
|
|
1969
|
-
try {
|
|
1970
|
-
const response = await this.client.post(`/runes/etch/orders/${orderId}/execute`, {
|
|
1971
|
-
fundTransactionId
|
|
1972
|
-
});
|
|
1973
|
-
return {
|
|
1974
|
-
data: response.data
|
|
1975
|
-
};
|
|
1976
|
-
} catch (error) {
|
|
1977
|
-
const err = error;
|
|
1978
|
-
return {
|
|
1979
|
-
error: this.parseError(err)
|
|
1980
|
-
};
|
|
1981
|
-
}
|
|
1982
|
-
};
|
|
1983
|
-
getOrder = async (orderId) => {
|
|
1984
|
-
try {
|
|
1985
|
-
const response = await this.client.get(`/orders/${orderId}`);
|
|
1986
|
-
return {
|
|
1987
|
-
data: response.data
|
|
1988
|
-
};
|
|
1989
|
-
} catch (error) {
|
|
1990
|
-
const err = error;
|
|
1991
|
-
return {
|
|
1992
|
-
error: this.parseError(err)
|
|
1993
|
-
};
|
|
1994
|
-
}
|
|
1995
|
-
};
|
|
1996
|
-
rbfOrder = async (rbfRequest) => {
|
|
1997
|
-
const { orderId, newFeeRate } = rbfRequest;
|
|
1998
|
-
try {
|
|
1999
|
-
const response = await this.client.post(`/orders/${orderId}/rbf-estimate`, {
|
|
2000
|
-
newFeeRate
|
|
2001
|
-
});
|
|
2002
|
-
return {
|
|
2003
|
-
data: response.data
|
|
2004
|
-
};
|
|
2005
|
-
} catch (error) {
|
|
2006
|
-
const err = error;
|
|
2007
|
-
return {
|
|
2008
|
-
error: this.parseError(err)
|
|
2009
|
-
};
|
|
2010
|
-
}
|
|
2011
|
-
};
|
|
569
|
+
client;
|
|
570
|
+
constructor(network) {
|
|
571
|
+
this.client = axios.create({ baseURL: ORDINALS_API_BASE_URL(network) });
|
|
572
|
+
}
|
|
573
|
+
parseError = (error) => {
|
|
574
|
+
return {
|
|
575
|
+
code: error.response?.status,
|
|
576
|
+
message: JSON.stringify(error.response?.data)
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
estimateMintCost = async (mintParams) => {
|
|
580
|
+
try {
|
|
581
|
+
return { data: (await this.client.post("/runes/mint/estimate", { ...mintParams })).data };
|
|
582
|
+
} catch (error) {
|
|
583
|
+
const err = error;
|
|
584
|
+
return { error: this.parseError(err) };
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
estimateEtchCost = async (etchParams) => {
|
|
588
|
+
try {
|
|
589
|
+
return { data: (await this.client.post("/runes/etch/estimate", { ...etchParams })).data };
|
|
590
|
+
} catch (error) {
|
|
591
|
+
const err = error;
|
|
592
|
+
return { error: this.parseError(err) };
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
createMintOrder = async (mintOrderParams) => {
|
|
596
|
+
try {
|
|
597
|
+
return { data: (await this.client.post("/runes/mint/orders", { ...mintOrderParams })).data };
|
|
598
|
+
} catch (error) {
|
|
599
|
+
const err = error;
|
|
600
|
+
return { error: this.parseError(err) };
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
createEtchOrder = async (etchOrderParams) => {
|
|
604
|
+
try {
|
|
605
|
+
return { data: (await this.client.post("/runes/etch/orders", { ...etchOrderParams })).data };
|
|
606
|
+
} catch (error) {
|
|
607
|
+
const err = error;
|
|
608
|
+
return { error: this.parseError(err) };
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
executeMint = async (orderId, fundTransactionId) => {
|
|
612
|
+
try {
|
|
613
|
+
return { data: (await this.client.post(`/runes/mint/orders/${orderId}/execute`, { fundTransactionId })).data };
|
|
614
|
+
} catch (error) {
|
|
615
|
+
const err = error;
|
|
616
|
+
return { error: this.parseError(err) };
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
executeEtch = async (orderId, fundTransactionId) => {
|
|
620
|
+
try {
|
|
621
|
+
return { data: (await this.client.post(`/runes/etch/orders/${orderId}/execute`, { fundTransactionId })).data };
|
|
622
|
+
} catch (error) {
|
|
623
|
+
const err = error;
|
|
624
|
+
return { error: this.parseError(err) };
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
getOrder = async (orderId) => {
|
|
628
|
+
try {
|
|
629
|
+
return { data: (await this.client.get(`/orders/${orderId}`)).data };
|
|
630
|
+
} catch (error) {
|
|
631
|
+
const err = error;
|
|
632
|
+
return { error: this.parseError(err) };
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
rbfOrder = async (rbfRequest) => {
|
|
636
|
+
const { orderId, newFeeRate } = rbfRequest;
|
|
637
|
+
try {
|
|
638
|
+
return { data: (await this.client.post(`/orders/${orderId}/rbf-estimate`, { newFeeRate })).data };
|
|
639
|
+
} catch (error) {
|
|
640
|
+
const err = error;
|
|
641
|
+
return { error: this.parseError(err) };
|
|
642
|
+
}
|
|
643
|
+
};
|
|
2012
644
|
};
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}
|
|
2018
|
-
return clients[network];
|
|
645
|
+
const clients = {};
|
|
646
|
+
const getRunesApiClient = (network = BitcoinNetworkType.Mainnet) => {
|
|
647
|
+
if (!clients[network]) clients[network] = new RunesApi(network);
|
|
648
|
+
return clients[network];
|
|
2019
649
|
};
|
|
2020
650
|
|
|
2021
|
-
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region src/adapters/satsConnectAdapter.ts
|
|
2022
653
|
var SatsConnectAdapter = class {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
if (!orderResponse.data) {
|
|
2270
|
-
return {
|
|
2271
|
-
status: "error",
|
|
2272
|
-
error: {
|
|
2273
|
-
code: orderResponse.error.code === 400 || orderResponse.error.code === 404 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
|
|
2274
|
-
message: orderResponse.error.message
|
|
2275
|
-
}
|
|
2276
|
-
};
|
|
2277
|
-
}
|
|
2278
|
-
const paymentResponse = await this.requestInternal("sendTransfer", {
|
|
2279
|
-
recipients: [
|
|
2280
|
-
{
|
|
2281
|
-
address: orderResponse.data.fundingAddress,
|
|
2282
|
-
amount: orderResponse.data.rbfCost
|
|
2283
|
-
}
|
|
2284
|
-
]
|
|
2285
|
-
});
|
|
2286
|
-
if (paymentResponse.status !== "success") {
|
|
2287
|
-
return paymentResponse;
|
|
2288
|
-
}
|
|
2289
|
-
return {
|
|
2290
|
-
status: "success",
|
|
2291
|
-
result: {
|
|
2292
|
-
fundingAddress: orderResponse.data.fundingAddress,
|
|
2293
|
-
orderId: rbfOrderRequest.orderId,
|
|
2294
|
-
fundRBFTransactionId: paymentResponse.result.txid
|
|
2295
|
-
}
|
|
2296
|
-
};
|
|
2297
|
-
} catch (error) {
|
|
2298
|
-
return {
|
|
2299
|
-
status: "error",
|
|
2300
|
-
error: {
|
|
2301
|
-
code: -32603 /* INTERNAL_ERROR */,
|
|
2302
|
-
message: error.message
|
|
2303
|
-
}
|
|
2304
|
-
};
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
async request(method, params) {
|
|
2308
|
-
switch (method) {
|
|
2309
|
-
case "runes_mint":
|
|
2310
|
-
return this.mintRunes(params);
|
|
2311
|
-
case "runes_etch":
|
|
2312
|
-
return this.etchRunes(params);
|
|
2313
|
-
case "runes_estimateMint":
|
|
2314
|
-
return this.estimateMint(params);
|
|
2315
|
-
case "runes_estimateEtch":
|
|
2316
|
-
return this.estimateEtch(params);
|
|
2317
|
-
case "runes_getOrder": {
|
|
2318
|
-
return this.getOrder(params);
|
|
2319
|
-
}
|
|
2320
|
-
case "runes_estimateRbfOrder": {
|
|
2321
|
-
return this.estimateRbfOrder(params);
|
|
2322
|
-
}
|
|
2323
|
-
case "runes_rbfOrder": {
|
|
2324
|
-
return this.rbfOrder(params);
|
|
2325
|
-
}
|
|
2326
|
-
default:
|
|
2327
|
-
return this.requestInternal(method, params);
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
654
|
+
async mintRunes(params) {
|
|
655
|
+
try {
|
|
656
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
657
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
658
|
+
if (walletInfo.result.methods?.includes("runes_mint")) {
|
|
659
|
+
const response = await this.requestInternal("runes_mint", params);
|
|
660
|
+
if (response) {
|
|
661
|
+
if (response.status === "success") return response;
|
|
662
|
+
if (response.status === "error" && response.error.code !== RpcErrorCode.METHOD_NOT_FOUND) return response;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
const mintRequest = {
|
|
667
|
+
destinationAddress: params.destinationAddress,
|
|
668
|
+
feeRate: params.feeRate,
|
|
669
|
+
refundAddress: params.refundAddress,
|
|
670
|
+
repeats: params.repeats,
|
|
671
|
+
runeName: params.runeName,
|
|
672
|
+
appServiceFee: params.appServiceFee,
|
|
673
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
674
|
+
};
|
|
675
|
+
const orderResponse = await new RunesApi(params.network).createMintOrder(mintRequest);
|
|
676
|
+
if (!orderResponse.data) return {
|
|
677
|
+
status: "error",
|
|
678
|
+
error: {
|
|
679
|
+
code: orderResponse.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
680
|
+
message: orderResponse.error.message
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
684
|
+
address: orderResponse.data.fundAddress,
|
|
685
|
+
amount: orderResponse.data.fundAmount
|
|
686
|
+
}] });
|
|
687
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
688
|
+
await new RunesApi(params.network).executeMint(orderResponse.data.orderId, paymentResponse.result.txid);
|
|
689
|
+
return {
|
|
690
|
+
status: "success",
|
|
691
|
+
result: {
|
|
692
|
+
orderId: orderResponse.data.orderId,
|
|
693
|
+
fundTransactionId: paymentResponse.result.txid,
|
|
694
|
+
fundingAddress: orderResponse.data.fundAddress
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
} catch (error) {
|
|
698
|
+
return {
|
|
699
|
+
status: "error",
|
|
700
|
+
error: {
|
|
701
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
702
|
+
message: error.message
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
async etchRunes(params) {
|
|
708
|
+
const etchRequest = {
|
|
709
|
+
destinationAddress: params.destinationAddress,
|
|
710
|
+
refundAddress: params.refundAddress,
|
|
711
|
+
feeRate: params.feeRate,
|
|
712
|
+
runeName: params.runeName,
|
|
713
|
+
divisibility: params.divisibility,
|
|
714
|
+
symbol: params.symbol,
|
|
715
|
+
premine: params.premine,
|
|
716
|
+
isMintable: params.isMintable,
|
|
717
|
+
terms: params.terms,
|
|
718
|
+
inscriptionDetails: params.inscriptionDetails,
|
|
719
|
+
delegateInscriptionId: params.delegateInscriptionId,
|
|
720
|
+
appServiceFee: params.appServiceFee,
|
|
721
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
722
|
+
};
|
|
723
|
+
try {
|
|
724
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
725
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
726
|
+
if (walletInfo.result.methods?.includes("runes_etch")) {
|
|
727
|
+
const response = await this.requestInternal("runes_etch", params);
|
|
728
|
+
if (response) {
|
|
729
|
+
if (response.status === "success") return response;
|
|
730
|
+
if (response.status === "error" && response.error.code !== RpcErrorCode.METHOD_NOT_FOUND) return response;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
735
|
+
if (!orderResponse.data) return {
|
|
736
|
+
status: "error",
|
|
737
|
+
error: {
|
|
738
|
+
code: orderResponse.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
739
|
+
message: orderResponse.error.message
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
743
|
+
address: orderResponse.data.fundAddress,
|
|
744
|
+
amount: orderResponse.data.fundAmount
|
|
745
|
+
}] });
|
|
746
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
747
|
+
await new RunesApi(params.network).executeEtch(orderResponse.data.orderId, paymentResponse.result.txid);
|
|
748
|
+
return {
|
|
749
|
+
status: "success",
|
|
750
|
+
result: {
|
|
751
|
+
orderId: orderResponse.data.orderId,
|
|
752
|
+
fundTransactionId: paymentResponse.result.txid,
|
|
753
|
+
fundingAddress: orderResponse.data.fundAddress
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
} catch (error) {
|
|
757
|
+
return {
|
|
758
|
+
status: "error",
|
|
759
|
+
error: {
|
|
760
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
761
|
+
message: error.message
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
async estimateMint(params) {
|
|
767
|
+
const estimateMintRequest = {
|
|
768
|
+
destinationAddress: params.destinationAddress,
|
|
769
|
+
feeRate: params.feeRate,
|
|
770
|
+
repeats: params.repeats,
|
|
771
|
+
runeName: params.runeName,
|
|
772
|
+
appServiceFee: params.appServiceFee,
|
|
773
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
774
|
+
};
|
|
775
|
+
const response = await getRunesApiClient(params.network).estimateMintCost(estimateMintRequest);
|
|
776
|
+
if (response.data) return {
|
|
777
|
+
status: "success",
|
|
778
|
+
result: response.data
|
|
779
|
+
};
|
|
780
|
+
return {
|
|
781
|
+
status: "error",
|
|
782
|
+
error: {
|
|
783
|
+
code: response.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
784
|
+
message: response.error.message
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
async estimateEtch(params) {
|
|
789
|
+
const estimateEtchRequest = {
|
|
790
|
+
destinationAddress: params.destinationAddress,
|
|
791
|
+
feeRate: params.feeRate,
|
|
792
|
+
runeName: params.runeName,
|
|
793
|
+
divisibility: params.divisibility,
|
|
794
|
+
symbol: params.symbol,
|
|
795
|
+
premine: params.premine,
|
|
796
|
+
isMintable: params.isMintable,
|
|
797
|
+
terms: params.terms,
|
|
798
|
+
inscriptionDetails: params.inscriptionDetails,
|
|
799
|
+
delegateInscriptionId: params.delegateInscriptionId,
|
|
800
|
+
appServiceFee: params.appServiceFee,
|
|
801
|
+
appServiceFeeAddress: params.appServiceFeeAddress
|
|
802
|
+
};
|
|
803
|
+
const response = await getRunesApiClient(params.network).estimateEtchCost(estimateEtchRequest);
|
|
804
|
+
if (response.data) return {
|
|
805
|
+
status: "success",
|
|
806
|
+
result: response.data
|
|
807
|
+
};
|
|
808
|
+
return {
|
|
809
|
+
status: "error",
|
|
810
|
+
error: {
|
|
811
|
+
code: response.error.code === 400 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
812
|
+
message: response.error.message
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
async getOrder(params) {
|
|
817
|
+
const response = await getRunesApiClient(params.network).getOrder(params.id);
|
|
818
|
+
if (response.data) return {
|
|
819
|
+
status: "success",
|
|
820
|
+
result: response.data
|
|
821
|
+
};
|
|
822
|
+
return {
|
|
823
|
+
status: "error",
|
|
824
|
+
error: {
|
|
825
|
+
code: response.error.code === 400 || response.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
826
|
+
message: response.error.message
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
async estimateRbfOrder(params) {
|
|
831
|
+
const rbfOrderRequest = {
|
|
832
|
+
newFeeRate: params.newFeeRate,
|
|
833
|
+
orderId: params.orderId
|
|
834
|
+
};
|
|
835
|
+
const response = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
|
|
836
|
+
if (response.data) return {
|
|
837
|
+
status: "success",
|
|
838
|
+
result: {
|
|
839
|
+
fundingAddress: response.data.fundingAddress,
|
|
840
|
+
rbfCost: response.data.rbfCost
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
return {
|
|
844
|
+
status: "error",
|
|
845
|
+
error: {
|
|
846
|
+
code: response.error.code === 400 || response.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
847
|
+
message: response.error.message
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
async rbfOrder(params) {
|
|
852
|
+
try {
|
|
853
|
+
const rbfOrderRequest = {
|
|
854
|
+
newFeeRate: params.newFeeRate,
|
|
855
|
+
orderId: params.orderId
|
|
856
|
+
};
|
|
857
|
+
const orderResponse = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
|
|
858
|
+
if (!orderResponse.data) return {
|
|
859
|
+
status: "error",
|
|
860
|
+
error: {
|
|
861
|
+
code: orderResponse.error.code === 400 || orderResponse.error.code === 404 ? RpcErrorCode.INVALID_REQUEST : RpcErrorCode.INTERNAL_ERROR,
|
|
862
|
+
message: orderResponse.error.message
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
const paymentResponse = await this.requestInternal("sendTransfer", { recipients: [{
|
|
866
|
+
address: orderResponse.data.fundingAddress,
|
|
867
|
+
amount: orderResponse.data.rbfCost
|
|
868
|
+
}] });
|
|
869
|
+
if (paymentResponse.status !== "success") return paymentResponse;
|
|
870
|
+
return {
|
|
871
|
+
status: "success",
|
|
872
|
+
result: {
|
|
873
|
+
fundingAddress: orderResponse.data.fundingAddress,
|
|
874
|
+
orderId: rbfOrderRequest.orderId,
|
|
875
|
+
fundRBFTransactionId: paymentResponse.result.txid
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
} catch (error) {
|
|
879
|
+
return {
|
|
880
|
+
status: "error",
|
|
881
|
+
error: {
|
|
882
|
+
code: RpcErrorCode.INTERNAL_ERROR,
|
|
883
|
+
message: error.message
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
async request(method, params) {
|
|
889
|
+
switch (method) {
|
|
890
|
+
case "runes_mint": return this.mintRunes(params);
|
|
891
|
+
case "runes_etch": return this.etchRunes(params);
|
|
892
|
+
case "runes_estimateMint": return this.estimateMint(params);
|
|
893
|
+
case "runes_estimateEtch": return this.estimateEtch(params);
|
|
894
|
+
case "runes_getOrder": return this.getOrder(params);
|
|
895
|
+
case "runes_estimateRbfOrder": return this.estimateRbfOrder(params);
|
|
896
|
+
case "runes_rbfOrder": return this.rbfOrder(params);
|
|
897
|
+
default: return this.requestInternal(method, params);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
2330
900
|
};
|
|
2331
901
|
|
|
2332
|
-
|
|
902
|
+
//#endregion
|
|
903
|
+
//#region src/adapters/xverse.ts
|
|
2333
904
|
var XverseAdapter = class extends SatsConnectAdapter {
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
905
|
+
id = DefaultAdaptersInfo.xverse.id;
|
|
906
|
+
requestInternal = async (method, params) => {
|
|
907
|
+
return request(method, params, this.id);
|
|
908
|
+
};
|
|
909
|
+
addListener = (listenerInfo) => {
|
|
910
|
+
return addListener(listenerInfo, this.id);
|
|
911
|
+
};
|
|
2341
912
|
};
|
|
2342
913
|
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
import { Buffer } from "buffer";
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/adapters/unisat.ts
|
|
2346
916
|
function convertSignInputsToInputType(signInputs) {
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
});
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
return result;
|
|
917
|
+
let result = [];
|
|
918
|
+
if (!signInputs) return result;
|
|
919
|
+
for (let address in signInputs) {
|
|
920
|
+
let indexes = signInputs[address];
|
|
921
|
+
for (let index of indexes) result.push({
|
|
922
|
+
index,
|
|
923
|
+
address
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
return result;
|
|
2361
927
|
}
|
|
2362
928
|
var UnisatAdapter = class extends SatsConnectAdapter {
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
};
|
|
2502
|
-
addListener = ({ eventName, cb }) => {
|
|
2503
|
-
switch (eventName) {
|
|
2504
|
-
case "accountChange": {
|
|
2505
|
-
const handler = () => {
|
|
2506
|
-
cb({ type: "accountChange" });
|
|
2507
|
-
};
|
|
2508
|
-
window.unisat.on("accountsChanged", handler);
|
|
2509
|
-
return () => {
|
|
2510
|
-
window.unisat.removeListener("accountsChanged", handler);
|
|
2511
|
-
};
|
|
2512
|
-
}
|
|
2513
|
-
case "networkChange": {
|
|
2514
|
-
const handler = () => {
|
|
2515
|
-
cb({ type: "networkChange" });
|
|
2516
|
-
};
|
|
2517
|
-
window.unisat.on("networkChanged", handler);
|
|
2518
|
-
return () => {
|
|
2519
|
-
window.unisat.removeListener("networkChanged", handler);
|
|
2520
|
-
};
|
|
2521
|
-
}
|
|
2522
|
-
default: {
|
|
2523
|
-
console.error("Event not supported by the selected wallet");
|
|
2524
|
-
return () => {
|
|
2525
|
-
};
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
};
|
|
929
|
+
id = DefaultAdaptersInfo.unisat.id;
|
|
930
|
+
async getAccounts(params) {
|
|
931
|
+
const { purposes } = params;
|
|
932
|
+
if (purposes.includes(AddressPurpose.Stacks) || purposes.includes(AddressPurpose.Starknet) || purposes.includes(AddressPurpose.Spark)) throw new Error("Only bitcoin addresses are supported");
|
|
933
|
+
const accounts = await window.unisat.requestAccounts();
|
|
934
|
+
const publicKey = await window.unisat.getPublicKey();
|
|
935
|
+
const address = accounts[0];
|
|
936
|
+
const addressType = getAddressInfo(accounts[0]).type;
|
|
937
|
+
const pk = addressType === AddressType$1.p2tr ? publicKey.slice(2) : publicKey;
|
|
938
|
+
const paymentAddress = {
|
|
939
|
+
address,
|
|
940
|
+
publicKey: pk,
|
|
941
|
+
addressType,
|
|
942
|
+
purpose: AddressPurpose.Payment,
|
|
943
|
+
walletType: "software"
|
|
944
|
+
};
|
|
945
|
+
const ordinalsAddress = {
|
|
946
|
+
address,
|
|
947
|
+
publicKey: pk,
|
|
948
|
+
addressType,
|
|
949
|
+
purpose: AddressPurpose.Ordinals,
|
|
950
|
+
walletType: "software"
|
|
951
|
+
};
|
|
952
|
+
const response = [];
|
|
953
|
+
if (purposes.includes(AddressPurpose.Payment)) response.push({
|
|
954
|
+
...paymentAddress,
|
|
955
|
+
walletType: "software"
|
|
956
|
+
});
|
|
957
|
+
if (purposes.includes(AddressPurpose.Ordinals)) response.push({
|
|
958
|
+
...ordinalsAddress,
|
|
959
|
+
walletType: "software"
|
|
960
|
+
});
|
|
961
|
+
return response;
|
|
962
|
+
}
|
|
963
|
+
async signMessage(params) {
|
|
964
|
+
const { message, address } = params;
|
|
965
|
+
const addressType = getAddressInfo(address).type;
|
|
966
|
+
if ([AddressType$1.p2wpkh, AddressType$1.p2tr].includes(addressType)) return {
|
|
967
|
+
address,
|
|
968
|
+
messageHash: "",
|
|
969
|
+
signature: await window.unisat.signMessage(message, "bip322-simple"),
|
|
970
|
+
protocol: MessageSigningProtocols.BIP322
|
|
971
|
+
};
|
|
972
|
+
return {
|
|
973
|
+
address,
|
|
974
|
+
messageHash: "",
|
|
975
|
+
signature: await window.unisat.signMessage(message, "ecdsa"),
|
|
976
|
+
protocol: MessageSigningProtocols.ECDSA
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
async sendTransfer(params) {
|
|
980
|
+
const { recipients } = params;
|
|
981
|
+
if (recipients.length > 1) throw new Error("Only one recipient is supported by this wallet provider");
|
|
982
|
+
return { txid: await window.unisat.sendBitcoin(recipients[0].address, recipients[0].amount) };
|
|
983
|
+
}
|
|
984
|
+
async signPsbt(params) {
|
|
985
|
+
const { psbt, signInputs, broadcast } = params;
|
|
986
|
+
const psbtHex = Buffer.from(psbt, "base64").toString("hex");
|
|
987
|
+
const signedPsbt = await window.unisat.signPsbt(psbtHex, {
|
|
988
|
+
autoFinalized: broadcast,
|
|
989
|
+
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
990
|
+
});
|
|
991
|
+
const signedPsbtBase64 = Buffer.from(signedPsbt, "hex").toString("base64");
|
|
992
|
+
let txid;
|
|
993
|
+
if (broadcast) txid = await window.unisat.pushPsbt(signedPsbt);
|
|
994
|
+
return {
|
|
995
|
+
psbt: signedPsbtBase64,
|
|
996
|
+
txid
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
requestInternal = async (method, params) => {
|
|
1000
|
+
try {
|
|
1001
|
+
switch (method) {
|
|
1002
|
+
case "getAccounts": return {
|
|
1003
|
+
status: "success",
|
|
1004
|
+
result: await this.getAccounts(params)
|
|
1005
|
+
};
|
|
1006
|
+
case "sendTransfer": return {
|
|
1007
|
+
status: "success",
|
|
1008
|
+
result: await this.sendTransfer(params)
|
|
1009
|
+
};
|
|
1010
|
+
case "signMessage": return {
|
|
1011
|
+
status: "success",
|
|
1012
|
+
result: await this.signMessage(params)
|
|
1013
|
+
};
|
|
1014
|
+
case "signPsbt": return {
|
|
1015
|
+
status: "success",
|
|
1016
|
+
result: await this.signPsbt(params)
|
|
1017
|
+
};
|
|
1018
|
+
default: {
|
|
1019
|
+
const error = {
|
|
1020
|
+
code: RpcErrorCode.METHOD_NOT_SUPPORTED,
|
|
1021
|
+
message: "Method not supported by the selected wallet"
|
|
1022
|
+
};
|
|
1023
|
+
console.error("Error calling the method", error);
|
|
1024
|
+
return {
|
|
1025
|
+
status: "error",
|
|
1026
|
+
error
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
} catch (error) {
|
|
1031
|
+
console.error("Error calling the method", error);
|
|
1032
|
+
return {
|
|
1033
|
+
status: "error",
|
|
1034
|
+
error: {
|
|
1035
|
+
code: error.code === 4001 ? RpcErrorCode.USER_REJECTION : RpcErrorCode.INTERNAL_ERROR,
|
|
1036
|
+
message: error.message ? error.message : "Wallet method call error",
|
|
1037
|
+
data: error
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
addListener = ({ eventName, cb }) => {
|
|
1043
|
+
switch (eventName) {
|
|
1044
|
+
case "accountChange": {
|
|
1045
|
+
const handler = () => {
|
|
1046
|
+
cb({ type: "accountChange" });
|
|
1047
|
+
};
|
|
1048
|
+
window.unisat.on("accountsChanged", handler);
|
|
1049
|
+
return () => {
|
|
1050
|
+
window.unisat.removeListener("accountsChanged", handler);
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
case "networkChange": {
|
|
1054
|
+
const handler = () => {
|
|
1055
|
+
cb({ type: "networkChange" });
|
|
1056
|
+
};
|
|
1057
|
+
window.unisat.on("networkChanged", handler);
|
|
1058
|
+
return () => {
|
|
1059
|
+
window.unisat.removeListener("networkChanged", handler);
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
default:
|
|
1063
|
+
console.error("Event not supported by the selected wallet");
|
|
1064
|
+
return () => {};
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
2529
1067
|
};
|
|
2530
1068
|
|
|
2531
|
-
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#region src/adapters/fordefi.ts
|
|
2532
1071
|
var FordefiAdapter = class extends SatsConnectAdapter {
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
if (!provider.addListener) {
|
|
2550
|
-
console.error(
|
|
2551
|
-
`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`
|
|
2552
|
-
);
|
|
2553
|
-
return () => {
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
return provider.addListener(eventName, cb);
|
|
2557
|
-
};
|
|
1072
|
+
id = DefaultAdaptersInfo.fordefi.id;
|
|
1073
|
+
requestInternal = async (method, params) => {
|
|
1074
|
+
const provider = getProviderById(this.id);
|
|
1075
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1076
|
+
if (!method) throw new Error("A wallet method is required");
|
|
1077
|
+
return await provider.request(method, params);
|
|
1078
|
+
};
|
|
1079
|
+
addListener = ({ eventName, cb }) => {
|
|
1080
|
+
const provider = getProviderById(this.id);
|
|
1081
|
+
if (!provider) throw new Error("no wallet provider was found");
|
|
1082
|
+
if (!provider.addListener) {
|
|
1083
|
+
console.error(`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`);
|
|
1084
|
+
return () => {};
|
|
1085
|
+
}
|
|
1086
|
+
return provider.addListener(eventName, cb);
|
|
1087
|
+
};
|
|
2558
1088
|
};
|
|
2559
1089
|
|
|
2560
|
-
|
|
1090
|
+
//#endregion
|
|
1091
|
+
//#region src/adapters/BaseAdapter.ts
|
|
2561
1092
|
var BaseAdapter = class extends SatsConnectAdapter {
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
1093
|
+
id = "";
|
|
1094
|
+
constructor(providerId) {
|
|
1095
|
+
super();
|
|
1096
|
+
this.id = providerId;
|
|
1097
|
+
}
|
|
1098
|
+
requestInternal = async (method, params) => {
|
|
1099
|
+
return request(method, params, this.id);
|
|
1100
|
+
};
|
|
1101
|
+
addListener = (..._args) => {
|
|
1102
|
+
throw new Error("Method not supported for `BaseAdapter`.");
|
|
1103
|
+
};
|
|
2573
1104
|
};
|
|
2574
1105
|
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/adapters/index.ts
|
|
1108
|
+
const DefaultAdaptersInfo = {
|
|
1109
|
+
fordefi: {
|
|
1110
|
+
id: "FordefiProviders.UtxoProvider",
|
|
1111
|
+
name: "Fordefi",
|
|
1112
|
+
webUrl: "https://www.fordefi.com/",
|
|
1113
|
+
chromeWebStoreUrl: "https://chromewebstore.google.com/detail/fordefi/hcmehenccjdmfbojapcbcofkgdpbnlle",
|
|
1114
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzEzNDk0XzY2MjU0KSI+CjxwYXRoIGQ9Ik0xMC44NzY5IDE1LjYzNzhIMS41VjE4LjM5OUMxLjUgMTkuODAxMyAyLjYzNDQ3IDIwLjkzOCA0LjAzMzkyIDIwLjkzOEg4LjI0OTkyTDEwLjg3NjkgMTUuNjM3OFoiIGZpbGw9IiM3OTk0RkYiLz4KPHBhdGggZD0iTTEuNSA5Ljc3NTUxSDE5LjA1MTZMMTcuMDEzOSAxMy44NzExSDEuNVY5Ljc3NTUxWiIgZmlsbD0iIzQ4NkRGRiIvPgo8cGF0aCBkPSJNNy42NTk5NiAzSDEuNTI0NDFWOC4wMDcwNEgyMi40NjEyVjNIMTYuMzI1NlY2LjczOTQ0SDE1LjA2MDZWM0g4LjkyNTAyVjYuNzM5NDRINy42NTk5NlYzWiIgZmlsbD0iIzVDRDFGQSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEzNDk0XzY2MjU0Ij4KPHJlY3Qgd2lkdGg9IjIxIiBoZWlnaHQ9IjE4IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMS41IDMpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
1115
|
+
},
|
|
1116
|
+
xverse: {
|
|
1117
|
+
id: "XverseProviders.BitcoinProvider",
|
|
1118
|
+
name: "Xverse",
|
|
1119
|
+
webUrl: "https://www.xverse.app/",
|
|
1120
|
+
googlePlayStoreUrl: "https://play.google.com/store/apps/details?id=com.secretkeylabs.xverse",
|
|
1121
|
+
iOSAppStoreUrl: "https://apps.apple.com/app/xverse-bitcoin-web3-wallet/id1552272513",
|
|
1122
|
+
chromeWebStoreUrl: "https://chromewebstore.google.com/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg",
|
|
1123
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgdmlld0JveD0iMCAwIDEwMiAxMDIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGlkPSJJY29uX0FydCAoRWRpdCBNZSkiPgo8cmVjdCB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgZmlsbD0iIzE4MTgxOCIvPgo8ZyBpZD0iTG9nby9FbWJsZW0iIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMF8xMjIzKSI+CjxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik03NC42NTQyIDczLjg4ODNWNjUuMjMxMkM3NC42NTQyIDY0Ljg4OCA3NC41MTc3IDY0LjU2MDYgNzQuMjc0NSA2NC4zMTc0TDM3LjQzOTcgMjcuNDgyNUMzNy4xOTY1IDI3LjIzOTIgMzYuODY5MSAyNy4xMDI4IDM2LjUyNTggMjcuMTAyOEgyNy44NjlDMjcuNDQxNiAyNy4xMDI4IDI3LjA5MzggMjcuNDUwNiAyNy4wOTM4IDI3Ljg3OFYzNS45MjExQzI3LjA5MzggMzYuMjY0NCAyNy4yMzAyIDM2LjU5MTcgMjcuNDczNCAzNi44MzVMNDAuNjk1MiA1MC4wNTY3QzQwLjk5NzUgNTAuMzU5MSA0MC45OTc1IDUwLjg1MDEgNDAuNjk1MiA1MS4xNTI0TDI3LjMyMTEgNjQuNTI2NUMyNy4xNzU2IDY0LjY3MiAyNy4wOTM4IDY0Ljg2OTggMjcuMDkzOCA2NS4wNzQ0VjczLjg4ODNDMjcuMDkzOCA3NC4zMTUzIDI3LjQ0MTYgNzQuNjYzNSAyNy44NjkgNzQuNjYzNUg0Mi4zMzQyQzQyLjc2MTYgNzQuNjYzNSA0My4xMDk0IDc0LjMxNTMgNDMuMTA5NCA3My44ODgzVjY4LjY5NThDNDMuMTA5NCA2OC40OTEyIDQzLjE5MTIgNjguMjkzNSA0My4zMzY4IDY4LjE0NzlMNTAuNTExNCA2MC45NzMzQzUwLjgxMzggNjAuNjcwOSA1MS4zMDQ4IDYwLjY3MDkgNTEuNjA3MiA2MC45NzMzTDY0LjkxOTggNzQuMjg2MUM2NS4xNjMxIDc0LjUyOTMgNjUuNDkwNCA3NC42NjU4IDY1LjgzMzcgNzQuNjY1OEg3My44NzY3Qzc0LjMwNDIgNzQuNjY1OCA3NC42NTE5IDc0LjMxNzYgNzQuNjUxOSA3My44OTA2TDc0LjY1NDIgNzMuODg4M1oiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGlkPSJWZWN0b3JfMiIgZD0iTTU1LjM1OCAzOC41NjcySDYyLjYwMzFDNjMuMDMyOCAzOC41NjcyIDYzLjM4MjkgMzguOTE3MyA2My4zODI5IDM5LjM0NjlWNDYuNTkyMUM2My4zODI5IDQ3LjI4NzcgNjQuMjI0IDQ3LjYzNTUgNjQuNzE1MSA0Ny4xNDIyTDc0LjY1NDEgMzcuMTg3M0M3NC43OTk0IDM3LjA0MTggNzQuODgxNiAzNi44NDQgNzQuODgxNiAzNi42MzcxVjI3LjkxODlDNzQuODgxNiAyNy40ODkyIDc0LjUzMzQgMjcuMTM5MSA3NC4xMDE3IDI3LjEzOTFMNjUuMjUzOCAyNy4xMjc3QzY1LjA0NyAyNy4xMjc3IDY0Ljg0OTIgMjcuMjA5NiA2NC43MDE0IDI3LjM1NTFMNTQuODA1NiAzNy4yMzVDNTQuMzE0NSAzNy43MjYgNTQuNjYyMyAzOC41NjcyIDU1LjM1NTcgMzguNTY3Mkg1NS4zNThaIiBmaWxsPSIjRUU3QTMwIi8+CjwvZz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF8yMF8xMjIzIj4KPHJlY3Qgd2lkdGg9IjQ3LjgxMjUiIGhlaWdodD0iNDcuODEyNSIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDI3LjA5MzggMjcuMDkzOCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K"
|
|
1124
|
+
},
|
|
1125
|
+
unisat: {
|
|
1126
|
+
id: "unisat",
|
|
1127
|
+
name: "Unisat",
|
|
1128
|
+
webUrl: "https://unisat.io/",
|
|
1129
|
+
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDE4MCAxODAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxODAiIGhlaWdodD0iMTgwIiBmaWxsPSJibGFjayIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMTAwNTBfNDE3MSkiPgo8cGF0aCBkPSJNMTEzLjY2IDI5LjI4OTdMMTQzLjk3IDU5LjMwOTdDMTQ2LjU1IDYxLjg1OTcgMTQ3LjgyIDY0LjQzOTcgMTQ3Ljc4IDY3LjAzOTdDMTQ3Ljc0IDY5LjYzOTcgMTQ2LjYzIDcyLjAwOTcgMTQ0LjQ2IDc0LjE1OTdDMTQyLjE5IDc2LjQwOTcgMTM5Ljc0IDc3LjU0OTcgMTM3LjEyIDc3LjU5OTdDMTM0LjUgNzcuNjM5NyAxMzEuOSA3Ni4zNzk3IDEyOS4zMiA3My44Mjk3TDk4LjMxOTkgNDMuMTI5N0M5NC43OTk5IDM5LjYzOTcgOTEuMzk5OSAzNy4xNjk3IDg4LjEyOTkgMzUuNzE5N0M4NC44NTk5IDM0LjI2OTcgODEuNDE5OSAzNC4wMzk3IDc3LjgxOTkgMzUuMDM5N0M3NC4yMDk5IDM2LjAyOTcgNzAuMzM5OSAzOC41Nzk3IDY2LjE4OTkgNDIuNjc5N0M2MC40Njk5IDQ4LjM0OTcgNTcuNzM5OSA1My42Njk3IDU4LjAxOTkgNTguNjM5N0M1OC4yOTk5IDYzLjYwOTcgNjEuMTM5OSA2OC43Njk3IDY2LjUyOTkgNzQuMDk5N0w5Ny43Nzk5IDEwNS4wNkMxMDAuMzkgMTA3LjY0IDEwMS42NyAxMTAuMjIgMTAxLjYzIDExMi43OEMxMDEuNTkgMTE1LjM1IDEwMC40NyAxMTcuNzIgOTguMjU5OSAxMTkuOTFDOTYuMDU5OSAxMjIuMDkgOTMuNjI5OSAxMjMuMjMgOTAuOTg5OSAxMjMuMzJDODguMzQ5OSAxMjMuNDEgODUuNzE5OSAxMjIuMTYgODMuMTE5OSAxMTkuNThMNTIuODA5OSA4OS41NTk3QzQ3Ljg3OTkgODQuNjc5NyA0NC4zMTk5IDgwLjA1OTcgNDIuMTI5OSA3NS42OTk3QzM5LjkzOTkgNzEuMzM5NyAzOS4xMTk5IDY2LjQwOTcgMzkuNjg5OSA2MC45MDk3QzQwLjE5OTkgNTYuMTk5NyA0MS43MDk5IDUxLjYzOTcgNDQuMjI5OSA0Ny4yMTk3QzQ2LjczOTkgNDIuNzk5NyA1MC4zMzk5IDM4LjI3OTcgNTUuMDA5OSAzMy42NDk3QzYwLjU2OTkgMjguMTM5NyA2NS44Nzk5IDIzLjkxOTcgNzAuOTM5OSAyMC45Nzk3Qzc1Ljk4OTkgMTguMDM5NyA4MC44Nzk5IDE2LjQwOTcgODUuNTk5OSAxNi4wNjk3QzkwLjMyOTkgMTUuNzI5NyA5NC45ODk5IDE2LjY2OTcgOTkuNTk5OSAxOC44ODk3QzEwNC4yMSAyMS4xMDk3IDEwOC44OSAyNC41Njk3IDExMy42NSAyOS4yODk3SDExMy42NloiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8xMDA1MF80MTcxKSIvPgo8cGF0aCBkPSJNNjYuMTA5OSAxNTAuNDJMMzUuODA5OSAxMjAuNEMzMy4yMjk5IDExNy44NCAzMS45NTk5IDExNS4yNyAzMS45OTk5IDExMi42N0MzMi4wMzk5IDExMC4wNyAzMy4xNDk5IDEwNy43IDM1LjMxOTkgMTA1LjU1QzM3LjU4OTkgMTAzLjMgNDAuMDM5OSAxMDIuMTYgNDIuNjU5OSAxMDIuMTFDNDUuMjc5OSAxMDIuMDcgNDcuODc5OSAxMDMuMzIgNTAuNDU5OSAxMDUuODhMODEuNDQ5OSAxMzYuNThDODQuOTc5OSAxNDAuMDcgODguMzY5OSAxNDIuNTQgOTEuNjM5OSAxNDMuOTlDOTQuOTA5OSAxNDUuNDQgOTguMzQ5OSAxNDUuNjYgMTAxLjk2IDE0NC42N0MxMDUuNTcgMTQzLjY4IDEwOS40NCAxNDEuMTMgMTEzLjU5IDEzNy4wMkMxMTkuMzEgMTMxLjM1IDEyMi4wNCAxMjYuMDMgMTIxLjc2IDEyMS4wNkMxMjEuNDggMTE2LjA5IDExOC42NCAxMTAuOTMgMTEzLjI1IDEwNS41OUw5Ni41OTk5IDg5LjI0MDFDOTMuOTg5OSA4Ni42NjAxIDkyLjcwOTkgODQuMDgwMSA5Mi43NDk5IDgxLjUyMDFDOTIuNzg5OSA3OC45NTAxIDkzLjkwOTkgNzYuNTgwMSA5Ni4xMTk5IDc0LjM5MDFDOTguMzE5OSA3Mi4yMTAxIDEwMC43NSA3MS4wNzAxIDEwMy4zOSA3MC45ODAxQzEwNi4wMyA3MC44OTAxIDEwOC42NiA3Mi4xNDAxIDExMS4yNiA3NC43MjAxTDEyNi45NiA5MC4xMzAxQzEzMS44OSA5NS4wMTAxIDEzNS40NSA5OS42MzAxIDEzNy42NCAxMDMuOTlDMTM5LjgzIDEwOC4zNSAxNDAuNjUgMTEzLjI4IDE0MC4wOCAxMTguNzhDMTM5LjU3IDEyMy40OSAxMzguMDYgMTI4LjA1IDEzNS41NCAxMzIuNDdDMTMzLjAzIDEzNi44OSAxMjkuNDMgMTQxLjQxIDEyNC43NiAxNDYuMDRDMTE5LjIgMTUxLjU1IDExMy44OSAxNTUuNzcgMTA4LjgzIDE1OC43MUMxMDMuNzcgMTYxLjY1IDk4Ljg3OTkgMTYzLjI5IDk0LjE0OTkgMTYzLjYzQzg5LjQxOTkgMTYzLjk3IDg0Ljc1OTkgMTYzLjAzIDgwLjE0OTkgMTYwLjgxQzc1LjUzOTkgMTU4LjU5IDcwLjg1OTkgMTU1LjEzIDY2LjA5OTkgMTUwLjQxTDY2LjEwOTkgMTUwLjQyWiIgZmlsbD0idXJsKCNwYWludDFfbGluZWFyXzEwMDUwXzQxNzEpIi8+CjxwYXRoIGQ9Ik04NS4wMDk5IDcyLjk1OTJDOTEuMTU2OCA3Mi45NTkyIDk2LjEzOTkgNjcuOTc2MSA5Ni4xMzk5IDYxLjgyOTJDOTYuMTM5OSA1NS42ODIzIDkxLjE1NjggNTAuNjk5MiA4NS4wMDk5IDUwLjY5OTJDNzguODYzIDUwLjY5OTIgNzMuODc5OSA1NS42ODIzIDczLjg3OTkgNjEuODI5MkM3My44Nzk5IDY3Ljk3NjEgNzguODYzIDcyLjk1OTIgODUuMDA5OSA3Mi45NTkyWiIgZmlsbD0idXJsKCNwYWludDJfcmFkaWFsXzEwMDUwXzQxNzEpIi8+CjwvZz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8xMDA1MF80MTcxIiB4MT0iMTM4Ljk4NSIgeTE9IjQ2Ljc3OTUiIHgyPSI0NS4wNTI5IiB5Mj0iODguNTIzMyIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMjAxQzFCIi8+CjxzdG9wIG9mZnNldD0iMC4zNiIgc3RvcC1jb2xvcj0iIzc3MzkwRCIvPgo8c3RvcCBvZmZzZXQ9IjAuNjciIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRjRCODUyIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQxX2xpbmVhcl8xMDA1MF80MTcxIiB4MT0iNDMuMzgxMiIgeTE9IjEzNC4xNjciIHgyPSIxNTIuMjMxIiB5Mj0iMTAxLjc3MSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMUYxRDFDIi8+CjxzdG9wIG9mZnNldD0iMC4zNyIgc3RvcC1jb2xvcj0iIzc3MzkwRCIvPgo8c3RvcCBvZmZzZXQ9IjAuNjciIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRjRGQjUyIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxyYWRpYWxHcmFkaWVudCBpZD0icGFpbnQyX3JhZGlhbF8xMDA1MF80MTcxIiBjeD0iMCIgY3k9IjAiIHI9IjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDg1LjAwOTkgNjEuODM5Mikgc2NhbGUoMTEuMTMpIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0Y0Qjg1MiIvPgo8c3RvcCBvZmZzZXQ9IjAuMzMiIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIwLjY0IiBzdG9wLWNvbG9yPSIjNzczOTBEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzIxMUMxRCIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEwMDUwXzQxNzEiPgo8cmVjdCB3aWR0aD0iMTE1Ljc3IiBoZWlnaHQ9IjE0Ny43IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMzIgMTYpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
1130
|
+
}
|
|
2599
1131
|
};
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
1132
|
+
const defaultAdapters = {
|
|
1133
|
+
[DefaultAdaptersInfo.fordefi.id]: FordefiAdapter,
|
|
1134
|
+
[DefaultAdaptersInfo.xverse.id]: XverseAdapter,
|
|
1135
|
+
[DefaultAdaptersInfo.unisat.id]: UnisatAdapter
|
|
2604
1136
|
};
|
|
2605
1137
|
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
|
|
2630
|
-
if (value) return [...acc, capability];
|
|
2631
|
-
return acc;
|
|
2632
|
-
}, []);
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region src/capabilities/index.ts
|
|
1140
|
+
const extractOrValidateCapabilities = (provider, reportedCapabilities) => {
|
|
1141
|
+
const validateCapability = (capability) => {
|
|
1142
|
+
if (!provider[capability]) return false;
|
|
1143
|
+
if (reportedCapabilities && !reportedCapabilities.has(capability)) return false;
|
|
1144
|
+
return true;
|
|
1145
|
+
};
|
|
1146
|
+
const capabilityMap = {
|
|
1147
|
+
request: validateCapability("request"),
|
|
1148
|
+
connect: validateCapability("connect"),
|
|
1149
|
+
signMessage: validateCapability("signMessage"),
|
|
1150
|
+
signTransaction: validateCapability("signTransaction"),
|
|
1151
|
+
sendBtcTransaction: validateCapability("sendBtcTransaction"),
|
|
1152
|
+
createInscription: validateCapability("createInscription"),
|
|
1153
|
+
createRepeatInscriptions: validateCapability("createRepeatInscriptions"),
|
|
1154
|
+
signMultipleTransactions: validateCapability("signMultipleTransactions"),
|
|
1155
|
+
addListener: validateCapability("addListener")
|
|
1156
|
+
};
|
|
1157
|
+
return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
|
|
1158
|
+
if (value) return [...acc, capability];
|
|
1159
|
+
return acc;
|
|
1160
|
+
}, []);
|
|
2633
1161
|
};
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
options.onCancel?.();
|
|
2651
|
-
}
|
|
1162
|
+
const getCapabilities = async (options) => {
|
|
1163
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1164
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
1165
|
+
if (provider.getCapabilities) try {
|
|
1166
|
+
const response = await provider.getCapabilities(request$1);
|
|
1167
|
+
options.onFinish?.(extractOrValidateCapabilities(provider, new Set(response)));
|
|
1168
|
+
} catch (error) {
|
|
1169
|
+
console.error("[Connect] Error during capabilities request", error);
|
|
1170
|
+
}
|
|
1171
|
+
try {
|
|
1172
|
+
const inferredCapabilities = extractOrValidateCapabilities(provider);
|
|
1173
|
+
options.onFinish?.(inferredCapabilities);
|
|
1174
|
+
} catch (error) {
|
|
1175
|
+
console.error("[Connect] Error during capabilities request", error);
|
|
1176
|
+
options.onCancel?.();
|
|
1177
|
+
}
|
|
2652
1178
|
};
|
|
2653
1179
|
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
if (!content || content.length === 0) {
|
|
2666
|
-
throw new Error("Empty content not allowed");
|
|
2667
|
-
}
|
|
2668
|
-
if (!payloadType || payloadType !== "BASE_64" && payloadType !== "PLAIN_TEXT") {
|
|
2669
|
-
throw new Error("Empty invalid payloadType specified");
|
|
2670
|
-
}
|
|
2671
|
-
if (content.length > (network.type === "Mainnet" ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)) {
|
|
2672
|
-
throw new Error("Content too large");
|
|
2673
|
-
}
|
|
2674
|
-
if ((appFeeAddress?.length ?? 0) > 0 && (appFee ?? 0) <= 0) {
|
|
2675
|
-
throw new Error("Invalid combination of app fee address and fee provided");
|
|
2676
|
-
}
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region src/inscriptions/utils.ts
|
|
1182
|
+
const MAX_CONTENT_LENGTH_MAINNET = 4e5;
|
|
1183
|
+
const MAX_CONTENT_LENGTH_TESTNET = 6e4;
|
|
1184
|
+
const validateInscriptionPayload = (payload) => {
|
|
1185
|
+
const { contentType, content, payloadType, network, appFeeAddress, appFee } = payload;
|
|
1186
|
+
if (!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(contentType)) throw new Error("Invalid content type detected");
|
|
1187
|
+
if (!content || content.length === 0) throw new Error("Empty content not allowed");
|
|
1188
|
+
if (!payloadType || payloadType !== "BASE_64" && payloadType !== "PLAIN_TEXT") throw new Error("Empty invalid payloadType specified");
|
|
1189
|
+
if (content.length > (network.type === "Mainnet" ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)) throw new Error("Content too large");
|
|
1190
|
+
if ((appFeeAddress?.length ?? 0) > 0 && (appFee ?? 0) <= 0) throw new Error("Invalid combination of app fee address and fee provided");
|
|
2677
1191
|
};
|
|
2678
1192
|
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region src/inscriptions/createInscription.ts
|
|
1195
|
+
const createInscription = async (options) => {
|
|
1196
|
+
const { getProvider } = options;
|
|
1197
|
+
const provider = await getProviderOrThrow(getProvider);
|
|
1198
|
+
validateInscriptionPayload(options.payload);
|
|
1199
|
+
try {
|
|
1200
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
1201
|
+
const response = await provider.createInscription(request$1);
|
|
1202
|
+
options.onFinish?.(response);
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
console.error("[Connect] Error during create inscription", error);
|
|
1205
|
+
options.onCancel?.();
|
|
1206
|
+
}
|
|
2692
1207
|
};
|
|
2693
1208
|
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/inscriptions/createRepeatInscriptions.ts
|
|
1211
|
+
const createRepeatInscriptions = async (options) => {
|
|
1212
|
+
const { getProvider } = options;
|
|
1213
|
+
const provider = await getProviderOrThrow(getProvider);
|
|
1214
|
+
validateInscriptionPayload(options.payload);
|
|
1215
|
+
try {
|
|
1216
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
1217
|
+
const response = await provider.createRepeatInscriptions(request$1);
|
|
1218
|
+
options.onFinish?.(response);
|
|
1219
|
+
} catch (error) {
|
|
1220
|
+
console.error("[Connect] Error during create repeat inscriptions", error);
|
|
1221
|
+
options.onCancel?.();
|
|
1222
|
+
}
|
|
2708
1223
|
};
|
|
2709
1224
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
} catch (error) {
|
|
2726
|
-
console.error("[Connect] Error during sign message request", error);
|
|
2727
|
-
options.onCancel?.();
|
|
2728
|
-
}
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/messages/index.ts
|
|
1227
|
+
const signMessage = async (options) => {
|
|
1228
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1229
|
+
const { address, message } = options.payload;
|
|
1230
|
+
if (!address) throw new Error("An address is required to sign a message");
|
|
1231
|
+
if (!message) throw new Error("A message to be signed is required");
|
|
1232
|
+
try {
|
|
1233
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
1234
|
+
const response = await provider.signMessage(request$1);
|
|
1235
|
+
options.onFinish?.(response);
|
|
1236
|
+
} catch (error) {
|
|
1237
|
+
console.error("[Connect] Error during sign message request", error);
|
|
1238
|
+
options.onCancel?.();
|
|
1239
|
+
}
|
|
2729
1240
|
};
|
|
2730
1241
|
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region src/transactions/sendBtcTransaction.ts
|
|
1244
|
+
const serializer = (recipient) => {
|
|
1245
|
+
return recipient.map((value) => {
|
|
1246
|
+
const { address, amountSats } = value;
|
|
1247
|
+
return {
|
|
1248
|
+
address,
|
|
1249
|
+
amountSats: amountSats.toString()
|
|
1250
|
+
};
|
|
1251
|
+
});
|
|
2741
1252
|
};
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
message,
|
|
2762
|
-
recipients: serializedRecipients
|
|
2763
|
-
};
|
|
2764
|
-
const request2 = createUnsecuredToken6(serializedPayload);
|
|
2765
|
-
const response = await provider.sendBtcTransaction(request2);
|
|
2766
|
-
options.onFinish?.(response);
|
|
2767
|
-
} catch (error) {
|
|
2768
|
-
console.error("[Connect] Error during send BTC transaction request", error);
|
|
2769
|
-
options.onCancel?.();
|
|
2770
|
-
}
|
|
1253
|
+
const sendBtcTransaction = async (options) => {
|
|
1254
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1255
|
+
const { recipients, senderAddress, network, message } = options.payload;
|
|
1256
|
+
if (!recipients || recipients.length === 0) throw new Error("At least one recipient is required");
|
|
1257
|
+
if (recipients.some((item) => typeof item.address !== "string" || typeof item.amountSats !== "bigint")) throw new Error("Incorrect recipient format");
|
|
1258
|
+
if (!senderAddress) throw new Error("The sender address is required");
|
|
1259
|
+
try {
|
|
1260
|
+
const request$1 = createUnsecuredToken({
|
|
1261
|
+
network,
|
|
1262
|
+
senderAddress,
|
|
1263
|
+
message,
|
|
1264
|
+
recipients: serializer(recipients)
|
|
1265
|
+
});
|
|
1266
|
+
const response = await provider.sendBtcTransaction(request$1);
|
|
1267
|
+
options.onFinish?.(response);
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
console.error("[Connect] Error during send BTC transaction request", error);
|
|
1270
|
+
options.onCancel?.();
|
|
1271
|
+
}
|
|
2771
1272
|
};
|
|
2772
1273
|
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
} catch (error) {
|
|
2789
|
-
console.error("[Connect] Error during sign transaction request", error);
|
|
2790
|
-
options.onCancel?.();
|
|
2791
|
-
}
|
|
1274
|
+
//#endregion
|
|
1275
|
+
//#region src/transactions/signTransaction.ts
|
|
1276
|
+
const signTransaction = async (options) => {
|
|
1277
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1278
|
+
const { psbtBase64, inputsToSign } = options.payload;
|
|
1279
|
+
if (!psbtBase64) throw new Error("A value for psbtBase64 representing the tx hash is required");
|
|
1280
|
+
if (!inputsToSign) throw new Error("An array specifying the inputs to be signed by the wallet is required");
|
|
1281
|
+
try {
|
|
1282
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
1283
|
+
const response = await provider.signTransaction(request$1);
|
|
1284
|
+
options.onFinish?.(response);
|
|
1285
|
+
} catch (error) {
|
|
1286
|
+
console.error("[Connect] Error during sign transaction request", error);
|
|
1287
|
+
options.onCancel?.();
|
|
1288
|
+
}
|
|
2792
1289
|
};
|
|
2793
1290
|
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
} catch (error) {
|
|
2810
|
-
console.error("[Connect] Error during sign Multiple transactions request", error);
|
|
2811
|
-
options.onCancel?.();
|
|
2812
|
-
}
|
|
2813
|
-
};
|
|
2814
|
-
export {
|
|
2815
|
-
AddressPurpose,
|
|
2816
|
-
AddressType,
|
|
2817
|
-
BaseAdapter,
|
|
2818
|
-
BitcoinNetworkType,
|
|
2819
|
-
DefaultAdaptersInfo,
|
|
2820
|
-
MessageSigningProtocols,
|
|
2821
|
-
PermissionRequestParams,
|
|
2822
|
-
ProviderPlatform,
|
|
2823
|
-
RpcErrorCode,
|
|
2824
|
-
RpcIdSchema,
|
|
2825
|
-
SatsConnectAdapter,
|
|
2826
|
-
SparkNetworkType,
|
|
2827
|
-
StacksNetworkType,
|
|
2828
|
-
StarknetNetworkType,
|
|
2829
|
-
accountActionsSchema,
|
|
2830
|
-
accountChangeEventName,
|
|
2831
|
-
accountChangeSchema,
|
|
2832
|
-
accountPermissionSchema,
|
|
2833
|
-
addListener,
|
|
2834
|
-
addNetworkMethodName,
|
|
2835
|
-
addNetworkParamsSchema,
|
|
2836
|
-
addNetworkRequestMessageSchema,
|
|
2837
|
-
addNetworkResultSchema,
|
|
2838
|
-
addressSchema,
|
|
2839
|
-
changeNetworkByIdMethodName,
|
|
2840
|
-
changeNetworkByIdParamsSchema,
|
|
2841
|
-
changeNetworkByIdRequestMessageSchema,
|
|
2842
|
-
changeNetworkByIdResultSchema,
|
|
2843
|
-
changeNetworkMethodName,
|
|
2844
|
-
changeNetworkParamsSchema,
|
|
2845
|
-
changeNetworkRequestMessageSchema,
|
|
2846
|
-
changeNetworkResultSchema,
|
|
2847
|
-
connectMethodName,
|
|
2848
|
-
connectParamsSchema,
|
|
2849
|
-
connectRequestMessageSchema,
|
|
2850
|
-
connectResultSchema,
|
|
2851
|
-
createInscription,
|
|
2852
|
-
createRepeatInscriptions,
|
|
2853
|
-
defaultAdapters,
|
|
2854
|
-
disconnectEventName,
|
|
2855
|
-
disconnectMethodName,
|
|
2856
|
-
disconnectParamsSchema,
|
|
2857
|
-
disconnectRequestMessageSchema,
|
|
2858
|
-
disconnectResultSchema,
|
|
2859
|
-
disconnectSchema,
|
|
2860
|
-
getAccountMethodName,
|
|
2861
|
-
getAccountParamsSchema,
|
|
2862
|
-
getAccountRequestMessageSchema,
|
|
2863
|
-
getAccountResultSchema,
|
|
2864
|
-
getAccountsMethodName,
|
|
2865
|
-
getAccountsParamsSchema,
|
|
2866
|
-
getAccountsRequestMessageSchema,
|
|
2867
|
-
getAccountsResultSchema,
|
|
2868
|
-
getAddress,
|
|
2869
|
-
getAddressesMethodName,
|
|
2870
|
-
getAddressesParamsSchema,
|
|
2871
|
-
getAddressesRequestMessageSchema,
|
|
2872
|
-
getAddressesResultSchema,
|
|
2873
|
-
getBalanceMethodName,
|
|
2874
|
-
getBalanceParamsSchema,
|
|
2875
|
-
getBalanceRequestMessageSchema,
|
|
2876
|
-
getBalanceResultSchema,
|
|
2877
|
-
getCapabilities,
|
|
2878
|
-
getCurrentPermissionsMethodName,
|
|
2879
|
-
getCurrentPermissionsParamsSchema,
|
|
2880
|
-
getCurrentPermissionsRequestMessageSchema,
|
|
2881
|
-
getCurrentPermissionsResultSchema,
|
|
2882
|
-
getDefaultProvider,
|
|
2883
|
-
getInfoMethodName,
|
|
2884
|
-
getInfoParamsSchema,
|
|
2885
|
-
getInfoRequestMessageSchema,
|
|
2886
|
-
getInfoResultSchema,
|
|
2887
|
-
getInscriptionsMethodName,
|
|
2888
|
-
getInscriptionsParamsSchema,
|
|
2889
|
-
getInscriptionsRequestMessageSchema,
|
|
2890
|
-
getInscriptionsResultSchema,
|
|
2891
|
-
getNetworkMethodName,
|
|
2892
|
-
getNetworkParamsSchema,
|
|
2893
|
-
getNetworkRequestMessageSchema,
|
|
2894
|
-
getNetworkResultSchema,
|
|
2895
|
-
getProviderById,
|
|
2896
|
-
getProviderOrThrow,
|
|
2897
|
-
getProviders,
|
|
2898
|
-
getSupportedWallets,
|
|
2899
|
-
getWalletTypeMethodName,
|
|
2900
|
-
getWalletTypeParamsSchema,
|
|
2901
|
-
getWalletTypeRequestMessageSchema,
|
|
2902
|
-
getWalletTypeResultSchema,
|
|
2903
|
-
isProviderInstalled,
|
|
2904
|
-
networkChangeEventName,
|
|
2905
|
-
networkChangeSchema,
|
|
2906
|
-
permission,
|
|
2907
|
-
removeDefaultProvider,
|
|
2908
|
-
renouncePermissionsMethodName,
|
|
2909
|
-
renouncePermissionsParamsSchema,
|
|
2910
|
-
renouncePermissionsRequestMessageSchema,
|
|
2911
|
-
renouncePermissionsResultSchema,
|
|
2912
|
-
request,
|
|
2913
|
-
requestPermissionsMethodName,
|
|
2914
|
-
requestPermissionsParamsSchema,
|
|
2915
|
-
requestPermissionsRequestMessageSchema,
|
|
2916
|
-
requestPermissionsResultSchema,
|
|
2917
|
-
rpcErrorResponseMessageSchema,
|
|
2918
|
-
rpcRequestMessageSchema,
|
|
2919
|
-
rpcResponseMessageSchema,
|
|
2920
|
-
rpcSuccessResponseMessageSchema,
|
|
2921
|
-
runesEtchMethodName,
|
|
2922
|
-
runesEtchParamsSchema,
|
|
2923
|
-
runesEtchRequestMessageSchema,
|
|
2924
|
-
runesEtchResultSchema,
|
|
2925
|
-
runesGetBalanceMethodName,
|
|
2926
|
-
runesGetBalanceParamsSchema,
|
|
2927
|
-
runesGetBalanceRequestMessageSchema,
|
|
2928
|
-
runesGetBalanceResultSchema,
|
|
2929
|
-
runesMintMethodName,
|
|
2930
|
-
runesMintParamsSchema,
|
|
2931
|
-
runesMintRequestMessageSchema,
|
|
2932
|
-
runesMintResultSchema,
|
|
2933
|
-
runesTransferMethodName,
|
|
2934
|
-
runesTransferParamsSchema,
|
|
2935
|
-
runesTransferRequestMessageSchema,
|
|
2936
|
-
runesTransferResultSchema,
|
|
2937
|
-
sendBtcTransaction,
|
|
2938
|
-
sendInscriptionsMethodName,
|
|
2939
|
-
sendInscriptionsParamsSchema,
|
|
2940
|
-
sendInscriptionsRequestMessageSchema,
|
|
2941
|
-
sendInscriptionsResultSchema,
|
|
2942
|
-
sendTransferMethodName,
|
|
2943
|
-
sendTransferParamsSchema,
|
|
2944
|
-
sendTransferRequestMessageSchema,
|
|
2945
|
-
sendTransferResultSchema,
|
|
2946
|
-
setDefaultProvider,
|
|
2947
|
-
signMessage,
|
|
2948
|
-
signMessageMethodName,
|
|
2949
|
-
signMessageParamsSchema,
|
|
2950
|
-
signMessageRequestMessageSchema,
|
|
2951
|
-
signMessageResultSchema,
|
|
2952
|
-
signMultipleMessagesMethodName,
|
|
2953
|
-
signMultipleMessagesParamsSchema,
|
|
2954
|
-
signMultipleMessagesRequestMessageSchema,
|
|
2955
|
-
signMultipleMessagesResultSchema,
|
|
2956
|
-
signMultipleTransactions,
|
|
2957
|
-
signPsbtMethodName,
|
|
2958
|
-
signPsbtParamsSchema,
|
|
2959
|
-
signPsbtRequestMessageSchema,
|
|
2960
|
-
signPsbtResultSchema,
|
|
2961
|
-
signTransaction,
|
|
2962
|
-
sparkFlashnetAddLiquidityIntentSchema,
|
|
2963
|
-
sparkFlashnetClawbackFundsMethodName,
|
|
2964
|
-
sparkFlashnetClawbackFundsParamsSchema,
|
|
2965
|
-
sparkFlashnetClawbackFundsRequestMessageSchema,
|
|
2966
|
-
sparkFlashnetClawbackFundsResultSchema,
|
|
2967
|
-
sparkFlashnetClawbackIntentSchema,
|
|
2968
|
-
sparkFlashnetConfirmInitialDepositIntentSchema,
|
|
2969
|
-
sparkFlashnetCreateConstantProductPoolIntentSchema,
|
|
2970
|
-
sparkFlashnetCreateSingleSidedPoolIntentSchema,
|
|
2971
|
-
sparkFlashnetExecuteRouteSwapMethodName,
|
|
2972
|
-
sparkFlashnetExecuteRouteSwapParamsSchema,
|
|
2973
|
-
sparkFlashnetExecuteRouteSwapRequestMessageSchema,
|
|
2974
|
-
sparkFlashnetExecuteRouteSwapResultSchema,
|
|
2975
|
-
sparkFlashnetExecuteSwapMethodName,
|
|
2976
|
-
sparkFlashnetExecuteSwapParamsSchema,
|
|
2977
|
-
sparkFlashnetExecuteSwapRequestMessageSchema,
|
|
2978
|
-
sparkFlashnetExecuteSwapResultSchema,
|
|
2979
|
-
sparkFlashnetGetJwtMethodName,
|
|
2980
|
-
sparkFlashnetGetJwtParamsSchema,
|
|
2981
|
-
sparkFlashnetGetJwtRequestMessageSchema,
|
|
2982
|
-
sparkFlashnetGetJwtResultSchema,
|
|
2983
|
-
sparkFlashnetRemoveLiquidityIntentSchema,
|
|
2984
|
-
sparkFlashnetRouteSwapIntentSchema,
|
|
2985
|
-
sparkFlashnetSignIntentMethodName,
|
|
2986
|
-
sparkFlashnetSignIntentParamsSchema,
|
|
2987
|
-
sparkFlashnetSignIntentRequestMessageSchema,
|
|
2988
|
-
sparkFlashnetSignIntentResultSchema,
|
|
2989
|
-
sparkFlashnetSignStructuredMessageMethodName,
|
|
2990
|
-
sparkFlashnetSignStructuredMessageParamsSchema,
|
|
2991
|
-
sparkFlashnetSignStructuredMessageRequestMessageSchema,
|
|
2992
|
-
sparkFlashnetSignStructuredMessageResultSchema,
|
|
2993
|
-
sparkFlashnetSwapIntentSchema,
|
|
2994
|
-
sparkGetAddressesMethodName,
|
|
2995
|
-
sparkGetAddressesParamsSchema,
|
|
2996
|
-
sparkGetAddressesRequestMessageSchema,
|
|
2997
|
-
sparkGetAddressesResultSchema,
|
|
2998
|
-
sparkGetBalanceMethodName,
|
|
2999
|
-
sparkGetBalanceParamsSchema,
|
|
3000
|
-
sparkGetBalanceRequestMessageSchema,
|
|
3001
|
-
sparkGetBalanceResultSchema,
|
|
3002
|
-
sparkGetClawbackEligibleTransfersMethodName,
|
|
3003
|
-
sparkGetClawbackEligibleTransfersParamsSchema,
|
|
3004
|
-
sparkGetClawbackEligibleTransfersRequestMessageSchema,
|
|
3005
|
-
sparkGetClawbackEligibleTransfersResultSchema,
|
|
3006
|
-
sparkSignMessageMethodName,
|
|
3007
|
-
sparkSignMessageParamsSchema,
|
|
3008
|
-
sparkSignMessageRequestMessageSchema,
|
|
3009
|
-
sparkSignMessageResultSchema,
|
|
3010
|
-
sparkTransferMethodName,
|
|
3011
|
-
sparkTransferParamsSchema,
|
|
3012
|
-
sparkTransferRequestMessageSchema,
|
|
3013
|
-
sparkTransferResultSchema,
|
|
3014
|
-
sparkTransferTokenMethodName,
|
|
3015
|
-
sparkTransferTokenParamsSchema,
|
|
3016
|
-
sparkTransferTokenRequestMessageSchema,
|
|
3017
|
-
sparkTransferTokenResultSchema,
|
|
3018
|
-
stxCallContractMethodName,
|
|
3019
|
-
stxCallContractParamsSchema,
|
|
3020
|
-
stxCallContractRequestMessageSchema,
|
|
3021
|
-
stxCallContractResultSchema,
|
|
3022
|
-
stxDeployContractMethodName,
|
|
3023
|
-
stxDeployContractParamsSchema,
|
|
3024
|
-
stxDeployContractRequestMessageSchema,
|
|
3025
|
-
stxDeployContractResultSchema,
|
|
3026
|
-
stxGetAccountsMethodName,
|
|
3027
|
-
stxGetAccountsParamsSchema,
|
|
3028
|
-
stxGetAccountsRequestMessageSchema,
|
|
3029
|
-
stxGetAccountsResultSchema,
|
|
3030
|
-
stxGetAddressesMethodName,
|
|
3031
|
-
stxGetAddressesParamsSchema,
|
|
3032
|
-
stxGetAddressesRequestMessageSchema,
|
|
3033
|
-
stxGetAddressesResultSchema,
|
|
3034
|
-
stxSignMessageMethodName,
|
|
3035
|
-
stxSignMessageParamsSchema,
|
|
3036
|
-
stxSignMessageRequestMessageSchema,
|
|
3037
|
-
stxSignMessageResultSchema,
|
|
3038
|
-
stxSignStructuredMessageMethodName,
|
|
3039
|
-
stxSignStructuredMessageParamsSchema,
|
|
3040
|
-
stxSignStructuredMessageRequestMessageSchema,
|
|
3041
|
-
stxSignStructuredMessageResultSchema,
|
|
3042
|
-
stxSignTransactionMethodName,
|
|
3043
|
-
stxSignTransactionParamsSchema,
|
|
3044
|
-
stxSignTransactionRequestMessageSchema,
|
|
3045
|
-
stxSignTransactionResultSchema,
|
|
3046
|
-
stxSignTransactionsMethodName,
|
|
3047
|
-
stxSignTransactionsParamsSchema,
|
|
3048
|
-
stxSignTransactionsRequestMessageSchema,
|
|
3049
|
-
stxSignTransactionsResultSchema,
|
|
3050
|
-
stxTransferStxMethodName,
|
|
3051
|
-
stxTransferStxParamsSchema,
|
|
3052
|
-
stxTransferStxRequestMessageSchema,
|
|
3053
|
-
stxTransferStxResultSchema,
|
|
3054
|
-
walletActionsSchema,
|
|
3055
|
-
walletEventSchema,
|
|
3056
|
-
walletPermissionSchema,
|
|
3057
|
-
walletTypeSchema,
|
|
3058
|
-
walletTypes
|
|
1291
|
+
//#endregion
|
|
1292
|
+
//#region src/transactions/signMultipleTransactions.ts
|
|
1293
|
+
const signMultipleTransactions = async (options) => {
|
|
1294
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
1295
|
+
const { psbts } = options.payload;
|
|
1296
|
+
if (!psbts || !psbts.length) throw new Error("psbts array is required");
|
|
1297
|
+
if (psbts.length > 100) throw new Error("psbts array must contain less than 100 psbts");
|
|
1298
|
+
try {
|
|
1299
|
+
const request$1 = createUnsecuredToken(options.payload);
|
|
1300
|
+
const response = await provider.signMultipleTransactions(request$1);
|
|
1301
|
+
options.onFinish?.(response);
|
|
1302
|
+
} catch (error) {
|
|
1303
|
+
console.error("[Connect] Error during sign Multiple transactions request", error);
|
|
1304
|
+
options.onCancel?.();
|
|
1305
|
+
}
|
|
3059
1306
|
};
|
|
1307
|
+
|
|
1308
|
+
//#endregion
|
|
1309
|
+
export { AddressPurpose, AddressType, BaseAdapter, BitcoinNetworkType, DefaultAdaptersInfo, MessageSigningProtocols, ProviderPlatform, RpcErrorCode, RpcIdSchema, SatsConnectAdapter, SparkNetworkType, StacksNetworkType, StarknetNetworkType, accountChangeEventName, accountChangeSchema, addListener, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, disconnectEventName, disconnectSchema, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, networkChangeEventName, networkChangeEventNameV2, networkChangeSchema, networkChangeV2Schema, removeDefaultProvider, request, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction, walletEventSchema };
|