@sats-connect/core 0.5.7 → 0.5.8-693f6a6
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.d.mts +110 -59
- package/dist/index.d.ts +110 -59
- package/dist/index.js +414 -388
- package/dist/index.mjs +410 -388
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,77 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/types.ts
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
4
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
5
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
6
|
+
BitcoinNetworkType2["Testnet4"] = "Testnet4";
|
|
7
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
8
|
+
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
9
|
+
return BitcoinNetworkType2;
|
|
10
|
+
})(BitcoinNetworkType || {});
|
|
11
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
12
|
+
var rpcRequestMessageSchema = v.object({
|
|
13
|
+
jsonrpc: v.literal("2.0"),
|
|
14
|
+
method: v.string(),
|
|
15
|
+
params: v.optional(
|
|
16
|
+
v.union([
|
|
17
|
+
v.array(v.unknown()),
|
|
18
|
+
v.looseObject({}),
|
|
19
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
20
|
+
// to be either an array or an object when provided. Changing this now would
|
|
21
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
22
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
23
|
+
v.null()
|
|
24
|
+
])
|
|
25
|
+
),
|
|
26
|
+
id: v.unwrap(RpcIdSchema)
|
|
27
|
+
});
|
|
28
|
+
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
29
|
+
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
30
|
+
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
31
|
+
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
32
|
+
RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
33
|
+
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
35
|
+
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
36
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
37
|
+
return RpcErrorCode2;
|
|
38
|
+
})(RpcErrorCode || {});
|
|
39
|
+
var rpcSuccessResponseMessageSchema = v.object({
|
|
40
|
+
jsonrpc: v.literal("2.0"),
|
|
41
|
+
result: v.nonOptional(v.unknown()),
|
|
42
|
+
id: RpcIdSchema
|
|
43
|
+
});
|
|
44
|
+
var rpcErrorResponseMessageSchema = v.object({
|
|
45
|
+
jsonrpc: v.literal("2.0"),
|
|
46
|
+
error: v.nonOptional(v.unknown()),
|
|
47
|
+
id: RpcIdSchema
|
|
48
|
+
});
|
|
49
|
+
var rpcResponseMessageSchema = v.union([
|
|
50
|
+
rpcSuccessResponseMessageSchema,
|
|
51
|
+
rpcErrorResponseMessageSchema
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
// src/provider/types.ts
|
|
55
|
+
import * as v2 from "valibot";
|
|
3
56
|
var accountChangeEventName = "accountChange";
|
|
4
|
-
var accountChangeSchema =
|
|
5
|
-
type:
|
|
57
|
+
var accountChangeSchema = v2.object({
|
|
58
|
+
type: v2.literal(accountChangeEventName)
|
|
6
59
|
});
|
|
7
60
|
var networkChangeEventName = "networkChange";
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
name: v.picklist(networkType)
|
|
61
|
+
var networkChangeSchema = v2.object({
|
|
62
|
+
type: v2.literal(networkChangeEventName),
|
|
63
|
+
bitcoin: v2.object({
|
|
64
|
+
name: v2.enum(BitcoinNetworkType)
|
|
13
65
|
}),
|
|
14
|
-
stacks:
|
|
15
|
-
name:
|
|
66
|
+
stacks: v2.object({
|
|
67
|
+
name: v2.string()
|
|
16
68
|
})
|
|
17
69
|
});
|
|
18
70
|
var disconnectEventName = "disconnect";
|
|
19
|
-
var disconnectSchema =
|
|
20
|
-
type:
|
|
71
|
+
var disconnectSchema = v2.object({
|
|
72
|
+
type: v2.literal(disconnectEventName)
|
|
21
73
|
});
|
|
22
|
-
var walletEventSchema =
|
|
74
|
+
var walletEventSchema = v2.variant("type", [
|
|
23
75
|
accountChangeSchema,
|
|
24
76
|
networkChangeSchema,
|
|
25
77
|
disconnectSchema
|
|
@@ -64,59 +116,6 @@ function getSupportedWallets() {
|
|
|
64
116
|
return wallets;
|
|
65
117
|
}
|
|
66
118
|
|
|
67
|
-
// src/types.ts
|
|
68
|
-
import * as v2 from "valibot";
|
|
69
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
70
|
-
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
71
|
-
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
72
|
-
BitcoinNetworkType2["Testnet4"] = "Testnet4";
|
|
73
|
-
BitcoinNetworkType2["Signet"] = "Signet";
|
|
74
|
-
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
75
|
-
return BitcoinNetworkType2;
|
|
76
|
-
})(BitcoinNetworkType || {});
|
|
77
|
-
var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
|
|
78
|
-
var rpcRequestMessageSchema = v2.object({
|
|
79
|
-
jsonrpc: v2.literal("2.0"),
|
|
80
|
-
method: v2.string(),
|
|
81
|
-
params: v2.optional(
|
|
82
|
-
v2.union([
|
|
83
|
-
v2.array(v2.unknown()),
|
|
84
|
-
v2.looseObject({}),
|
|
85
|
-
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
86
|
-
// to be either an array or an object when provided. Changing this now would
|
|
87
|
-
// be a breaking change, so accepting null values for now. Tracking in
|
|
88
|
-
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
89
|
-
v2.null()
|
|
90
|
-
])
|
|
91
|
-
),
|
|
92
|
-
id: v2.unwrap(RpcIdSchema)
|
|
93
|
-
});
|
|
94
|
-
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
95
|
-
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
96
|
-
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
97
|
-
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
98
|
-
RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
99
|
-
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
100
|
-
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
101
|
-
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
102
|
-
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
103
|
-
return RpcErrorCode2;
|
|
104
|
-
})(RpcErrorCode || {});
|
|
105
|
-
var rpcSuccessResponseMessageSchema = v2.object({
|
|
106
|
-
jsonrpc: v2.literal("2.0"),
|
|
107
|
-
result: v2.nonOptional(v2.unknown()),
|
|
108
|
-
id: RpcIdSchema
|
|
109
|
-
});
|
|
110
|
-
var rpcErrorResponseMessageSchema = v2.object({
|
|
111
|
-
jsonrpc: v2.literal("2.0"),
|
|
112
|
-
error: v2.nonOptional(v2.unknown()),
|
|
113
|
-
id: RpcIdSchema
|
|
114
|
-
});
|
|
115
|
-
var rpcResponseMessageSchema = v2.union([
|
|
116
|
-
rpcSuccessResponseMessageSchema,
|
|
117
|
-
rpcErrorResponseMessageSchema
|
|
118
|
-
]);
|
|
119
|
-
|
|
120
119
|
// src/request/index.ts
|
|
121
120
|
import * as v21 from "valibot";
|
|
122
121
|
|
|
@@ -209,30 +208,15 @@ var stxDeployContractRequestMessageSchema = v4.object({
|
|
|
209
208
|
});
|
|
210
209
|
|
|
211
210
|
// src/request/types/stxMethods/getAccounts.ts
|
|
211
|
+
import * as v8 from "valibot";
|
|
212
|
+
|
|
213
|
+
// src/request/types/walletMethods.ts
|
|
214
|
+
import * as v7 from "valibot";
|
|
215
|
+
|
|
216
|
+
// src/request/types/common.ts
|
|
212
217
|
import * as v5 from "valibot";
|
|
213
|
-
var
|
|
214
|
-
var
|
|
215
|
-
var stxGetAccountsResultSchema = v5.object({
|
|
216
|
-
/**
|
|
217
|
-
* The addresses generated for the given purposes.
|
|
218
|
-
*/
|
|
219
|
-
addresses: v5.array(
|
|
220
|
-
v5.object({
|
|
221
|
-
address: v5.string(),
|
|
222
|
-
publicKey: v5.string(),
|
|
223
|
-
gaiaHubUrl: v5.string(),
|
|
224
|
-
gaiaAppKey: v5.string()
|
|
225
|
-
})
|
|
226
|
-
)
|
|
227
|
-
});
|
|
228
|
-
var stxGetAccountsRequestMessageSchema = v5.object({
|
|
229
|
-
...rpcRequestMessageSchema.entries,
|
|
230
|
-
...v5.object({
|
|
231
|
-
method: v5.literal(stxGetAccountsMethodName),
|
|
232
|
-
params: stxGetAccountsParamsSchema,
|
|
233
|
-
id: v5.string()
|
|
234
|
-
}).entries
|
|
235
|
-
});
|
|
218
|
+
var walletTypes = ["software", "ledger", "keystone"];
|
|
219
|
+
var walletTypeSchema = v5.picklist(walletTypes);
|
|
236
220
|
|
|
237
221
|
// src/addresses/index.ts
|
|
238
222
|
import { createUnsecuredToken } from "jsontokens";
|
|
@@ -279,185 +263,367 @@ var getAddress = async (options) => {
|
|
|
279
263
|
}
|
|
280
264
|
};
|
|
281
265
|
|
|
266
|
+
// src/request/types/walletMethods.ts
|
|
267
|
+
var accountActionsSchema = v7.object({
|
|
268
|
+
read: v7.optional(v7.boolean())
|
|
269
|
+
});
|
|
270
|
+
var walletActionsSchema = v7.object({
|
|
271
|
+
readNetwork: v7.optional(v7.boolean())
|
|
272
|
+
});
|
|
273
|
+
var accountPermissionSchema = v7.object({
|
|
274
|
+
type: v7.literal("account"),
|
|
275
|
+
resourceId: v7.string(),
|
|
276
|
+
clientId: v7.string(),
|
|
277
|
+
actions: accountActionsSchema
|
|
278
|
+
});
|
|
279
|
+
var walletPermissionSchema = v7.object({
|
|
280
|
+
type: v7.literal("wallet"),
|
|
281
|
+
resourceId: v7.string(),
|
|
282
|
+
clientId: v7.string(),
|
|
283
|
+
actions: walletActionsSchema
|
|
284
|
+
});
|
|
285
|
+
var PermissionRequestParams = v7.variant("type", [
|
|
286
|
+
v7.object({
|
|
287
|
+
...v7.omit(accountPermissionSchema, ["clientId"]).entries
|
|
288
|
+
}),
|
|
289
|
+
v7.object({
|
|
290
|
+
...v7.omit(walletPermissionSchema, ["clientId"]).entries
|
|
291
|
+
})
|
|
292
|
+
]);
|
|
293
|
+
var permission = v7.variant("type", [accountPermissionSchema, walletPermissionSchema]);
|
|
294
|
+
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
295
|
+
var requestPermissionsParamsSchema = v7.nullish(v7.array(PermissionRequestParams));
|
|
296
|
+
var requestPermissionsResultSchema = v7.literal(true);
|
|
297
|
+
var requestPermissionsRequestMessageSchema = v7.object({
|
|
298
|
+
...rpcRequestMessageSchema.entries,
|
|
299
|
+
...v7.object({
|
|
300
|
+
method: v7.literal(requestPermissionsMethodName),
|
|
301
|
+
params: requestPermissionsParamsSchema,
|
|
302
|
+
id: v7.string()
|
|
303
|
+
}).entries
|
|
304
|
+
});
|
|
305
|
+
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
306
|
+
var renouncePermissionsParamsSchema = v7.nullish(v7.null());
|
|
307
|
+
var renouncePermissionsResultSchema = v7.nullish(v7.null());
|
|
308
|
+
var renouncePermissionsRequestMessageSchema = v7.object({
|
|
309
|
+
...rpcRequestMessageSchema.entries,
|
|
310
|
+
...v7.object({
|
|
311
|
+
method: v7.literal(renouncePermissionsMethodName),
|
|
312
|
+
params: renouncePermissionsParamsSchema,
|
|
313
|
+
id: v7.string()
|
|
314
|
+
}).entries
|
|
315
|
+
});
|
|
316
|
+
var disconnectMethodName = "wallet_disconnect";
|
|
317
|
+
var disconnectParamsSchema = v7.nullish(v7.null());
|
|
318
|
+
var disconnectResultSchema = v7.nullish(v7.null());
|
|
319
|
+
var disconnectRequestMessageSchema = v7.object({
|
|
320
|
+
...rpcRequestMessageSchema.entries,
|
|
321
|
+
...v7.object({
|
|
322
|
+
method: v7.literal(disconnectMethodName),
|
|
323
|
+
params: disconnectParamsSchema,
|
|
324
|
+
id: v7.string()
|
|
325
|
+
}).entries
|
|
326
|
+
});
|
|
327
|
+
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
328
|
+
var getWalletTypeParamsSchema = v7.nullish(v7.null());
|
|
329
|
+
var getWalletTypeResultSchema = walletTypeSchema;
|
|
330
|
+
var getWalletTypeRequestMessageSchema = v7.object({
|
|
331
|
+
...rpcRequestMessageSchema.entries,
|
|
332
|
+
...v7.object({
|
|
333
|
+
method: v7.literal(getWalletTypeMethodName),
|
|
334
|
+
params: getWalletTypeParamsSchema,
|
|
335
|
+
id: v7.string()
|
|
336
|
+
}).entries
|
|
337
|
+
});
|
|
338
|
+
var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
339
|
+
var getCurrentPermissionsParamsSchema = v7.nullish(v7.null());
|
|
340
|
+
var getCurrentPermissionsResultSchema = v7.array(permission);
|
|
341
|
+
var getCurrentPermissionsRequestMessageSchema = v7.object({
|
|
342
|
+
...rpcRequestMessageSchema.entries,
|
|
343
|
+
...v7.object({
|
|
344
|
+
method: v7.literal(getCurrentPermissionsMethodName),
|
|
345
|
+
params: getCurrentPermissionsParamsSchema,
|
|
346
|
+
id: v7.string()
|
|
347
|
+
}).entries
|
|
348
|
+
});
|
|
349
|
+
var getNetworkMethodName = "wallet_getNetwork";
|
|
350
|
+
var getNetworkParamsSchema = v7.nullish(v7.null());
|
|
351
|
+
var getNetworkResultSchema = v7.object({
|
|
352
|
+
bitcoin: v7.object({
|
|
353
|
+
name: v7.enum(BitcoinNetworkType)
|
|
354
|
+
}),
|
|
355
|
+
stacks: v7.object({
|
|
356
|
+
name: v7.string()
|
|
357
|
+
})
|
|
358
|
+
});
|
|
359
|
+
var getNetworkRequestMessageSchema = v7.object({
|
|
360
|
+
...rpcRequestMessageSchema.entries,
|
|
361
|
+
...v7.object({
|
|
362
|
+
method: v7.literal(getNetworkMethodName),
|
|
363
|
+
params: getNetworkParamsSchema,
|
|
364
|
+
id: v7.string()
|
|
365
|
+
}).entries
|
|
366
|
+
});
|
|
367
|
+
var changeNetworkMethodName = "wallet_changeNetwork";
|
|
368
|
+
var changeNetworkParamsSchema = v7.object({
|
|
369
|
+
name: v7.enum(BitcoinNetworkType)
|
|
370
|
+
});
|
|
371
|
+
var changeNetworkResultSchema = v7.nullish(v7.null());
|
|
372
|
+
var changeNetworkRequestMessageSchema = v7.object({
|
|
373
|
+
...rpcRequestMessageSchema.entries,
|
|
374
|
+
...v7.object({
|
|
375
|
+
method: v7.literal(changeNetworkMethodName),
|
|
376
|
+
params: changeNetworkParamsSchema,
|
|
377
|
+
id: v7.string()
|
|
378
|
+
}).entries
|
|
379
|
+
});
|
|
380
|
+
var getAccountMethodName = "wallet_getAccount";
|
|
381
|
+
var getAccountParamsSchema = v7.nullish(v7.null());
|
|
382
|
+
var getAccountResultSchema = v7.object({
|
|
383
|
+
id: v7.string(),
|
|
384
|
+
addresses: v7.array(addressSchema),
|
|
385
|
+
walletType: walletTypeSchema,
|
|
386
|
+
network: getNetworkResultSchema
|
|
387
|
+
});
|
|
388
|
+
var getAccountRequestMessageSchema = v7.object({
|
|
389
|
+
...rpcRequestMessageSchema.entries,
|
|
390
|
+
...v7.object({
|
|
391
|
+
method: v7.literal(getAccountMethodName),
|
|
392
|
+
params: getAccountParamsSchema,
|
|
393
|
+
id: v7.string()
|
|
394
|
+
}).entries
|
|
395
|
+
});
|
|
396
|
+
var connectMethodName = "wallet_connect";
|
|
397
|
+
var connectParamsSchema = v7.nullish(
|
|
398
|
+
v7.object({
|
|
399
|
+
permissions: v7.optional(v7.array(PermissionRequestParams)),
|
|
400
|
+
addresses: v7.optional(v7.array(v7.enum(AddressPurpose))),
|
|
401
|
+
message: v7.optional(
|
|
402
|
+
v7.pipe(v7.string(), v7.maxLength(80, "The message must not exceed 80 characters."))
|
|
403
|
+
)
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
var connectResultSchema = v7.object({
|
|
407
|
+
id: v7.string(),
|
|
408
|
+
addresses: v7.array(addressSchema),
|
|
409
|
+
walletType: walletTypeSchema,
|
|
410
|
+
network: getNetworkResultSchema
|
|
411
|
+
});
|
|
412
|
+
var connectRequestMessageSchema = v7.object({
|
|
413
|
+
...rpcRequestMessageSchema.entries,
|
|
414
|
+
...v7.object({
|
|
415
|
+
method: v7.literal(connectMethodName),
|
|
416
|
+
params: connectParamsSchema,
|
|
417
|
+
id: v7.string()
|
|
418
|
+
}).entries
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// src/request/types/stxMethods/getAccounts.ts
|
|
422
|
+
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
423
|
+
var stxGetAccountsParamsSchema = v8.nullish(v8.null());
|
|
424
|
+
var stxGetAccountsResultSchema = v8.object({
|
|
425
|
+
/**
|
|
426
|
+
* The addresses generated for the given purposes.
|
|
427
|
+
*/
|
|
428
|
+
addresses: v8.array(
|
|
429
|
+
v8.object({
|
|
430
|
+
address: v8.string(),
|
|
431
|
+
publicKey: v8.string(),
|
|
432
|
+
gaiaHubUrl: v8.string(),
|
|
433
|
+
gaiaAppKey: v8.string()
|
|
434
|
+
})
|
|
435
|
+
),
|
|
436
|
+
network: getNetworkResultSchema
|
|
437
|
+
});
|
|
438
|
+
var stxGetAccountsRequestMessageSchema = v8.object({
|
|
439
|
+
...rpcRequestMessageSchema.entries,
|
|
440
|
+
...v8.object({
|
|
441
|
+
method: v8.literal(stxGetAccountsMethodName),
|
|
442
|
+
params: stxGetAccountsParamsSchema,
|
|
443
|
+
id: v8.string()
|
|
444
|
+
}).entries
|
|
445
|
+
});
|
|
446
|
+
|
|
282
447
|
// src/request/types/stxMethods/getAddresses.ts
|
|
283
|
-
import * as
|
|
448
|
+
import * as v9 from "valibot";
|
|
284
449
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
285
|
-
var stxGetAddressesParamsSchema =
|
|
286
|
-
|
|
450
|
+
var stxGetAddressesParamsSchema = v9.nullish(
|
|
451
|
+
v9.object({
|
|
287
452
|
/**
|
|
288
453
|
* A message to be displayed to the user in the request prompt.
|
|
289
454
|
*/
|
|
290
|
-
message:
|
|
455
|
+
message: v9.optional(v9.string())
|
|
291
456
|
})
|
|
292
457
|
);
|
|
293
|
-
var stxGetAddressesResultSchema =
|
|
458
|
+
var stxGetAddressesResultSchema = v9.object({
|
|
294
459
|
/**
|
|
295
460
|
* The addresses generated for the given purposes.
|
|
296
461
|
*/
|
|
297
|
-
addresses:
|
|
462
|
+
addresses: v9.array(addressSchema),
|
|
463
|
+
network: getNetworkResultSchema
|
|
298
464
|
});
|
|
299
|
-
var stxGetAddressesRequestMessageSchema =
|
|
465
|
+
var stxGetAddressesRequestMessageSchema = v9.object({
|
|
300
466
|
...rpcRequestMessageSchema.entries,
|
|
301
|
-
...
|
|
302
|
-
method:
|
|
467
|
+
...v9.object({
|
|
468
|
+
method: v9.literal(stxGetAddressesMethodName),
|
|
303
469
|
params: stxGetAddressesParamsSchema,
|
|
304
|
-
id:
|
|
470
|
+
id: v9.string()
|
|
305
471
|
}).entries
|
|
306
472
|
});
|
|
307
473
|
|
|
308
474
|
// src/request/types/stxMethods/signMessage.ts
|
|
309
|
-
import * as
|
|
475
|
+
import * as v10 from "valibot";
|
|
310
476
|
var stxSignMessageMethodName = "stx_signMessage";
|
|
311
|
-
var stxSignMessageParamsSchema =
|
|
477
|
+
var stxSignMessageParamsSchema = v10.object({
|
|
312
478
|
/**
|
|
313
479
|
* The message to sign.
|
|
314
480
|
*/
|
|
315
|
-
message:
|
|
481
|
+
message: v10.string(),
|
|
316
482
|
/**
|
|
317
483
|
* The public key to sign the message with.
|
|
318
484
|
*/
|
|
319
|
-
publicKey:
|
|
485
|
+
publicKey: v10.string(),
|
|
320
486
|
/**
|
|
321
487
|
* The format version of the parameter.
|
|
322
488
|
*/
|
|
323
|
-
parameterFormatVersion:
|
|
489
|
+
parameterFormatVersion: v10.optional(v10.number())
|
|
324
490
|
});
|
|
325
|
-
var stxSignMessageResultSchema =
|
|
491
|
+
var stxSignMessageResultSchema = v10.object({
|
|
326
492
|
/**
|
|
327
493
|
* The signature of the message.
|
|
328
494
|
*/
|
|
329
|
-
signature:
|
|
495
|
+
signature: v10.string(),
|
|
330
496
|
/**
|
|
331
497
|
* The public key used to sign the message.
|
|
332
498
|
*/
|
|
333
|
-
publicKey:
|
|
499
|
+
publicKey: v10.string()
|
|
334
500
|
});
|
|
335
|
-
var stxSignMessageRequestMessageSchema =
|
|
501
|
+
var stxSignMessageRequestMessageSchema = v10.object({
|
|
336
502
|
...rpcRequestMessageSchema.entries,
|
|
337
|
-
...
|
|
338
|
-
method:
|
|
503
|
+
...v10.object({
|
|
504
|
+
method: v10.literal(stxSignMessageMethodName),
|
|
339
505
|
params: stxSignMessageParamsSchema,
|
|
340
|
-
id:
|
|
506
|
+
id: v10.string()
|
|
341
507
|
}).entries
|
|
342
508
|
});
|
|
343
509
|
|
|
344
510
|
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
345
|
-
import * as
|
|
511
|
+
import * as v11 from "valibot";
|
|
346
512
|
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
347
|
-
var stxSignStructuredMessageParamsSchema =
|
|
513
|
+
var stxSignStructuredMessageParamsSchema = v11.object({
|
|
348
514
|
/**
|
|
349
515
|
* The domain to be signed.
|
|
350
516
|
*/
|
|
351
|
-
domain:
|
|
517
|
+
domain: v11.string(),
|
|
352
518
|
/**
|
|
353
519
|
* Message payload to be signed.
|
|
354
520
|
*/
|
|
355
|
-
message:
|
|
521
|
+
message: v11.string(),
|
|
356
522
|
/**
|
|
357
523
|
* The format version of the parameter.
|
|
358
524
|
*/
|
|
359
|
-
parameterFormatVersion:
|
|
525
|
+
parameterFormatVersion: v11.optional(v11.number()),
|
|
360
526
|
/**
|
|
361
527
|
* The public key to sign the message with.
|
|
362
528
|
*/
|
|
363
|
-
publicKey:
|
|
529
|
+
publicKey: v11.optional(v11.string())
|
|
364
530
|
});
|
|
365
|
-
var stxSignStructuredMessageResultSchema =
|
|
531
|
+
var stxSignStructuredMessageResultSchema = v11.object({
|
|
366
532
|
/**
|
|
367
533
|
* Signature of the message.
|
|
368
534
|
*/
|
|
369
|
-
signature:
|
|
535
|
+
signature: v11.string(),
|
|
370
536
|
/**
|
|
371
537
|
* Public key as hex-encoded string.
|
|
372
538
|
*/
|
|
373
|
-
publicKey:
|
|
539
|
+
publicKey: v11.string()
|
|
374
540
|
});
|
|
375
|
-
var stxSignStructuredMessageRequestMessageSchema =
|
|
541
|
+
var stxSignStructuredMessageRequestMessageSchema = v11.object({
|
|
376
542
|
...rpcRequestMessageSchema.entries,
|
|
377
|
-
...
|
|
378
|
-
method:
|
|
543
|
+
...v11.object({
|
|
544
|
+
method: v11.literal(stxSignStructuredMessageMethodName),
|
|
379
545
|
params: stxSignStructuredMessageParamsSchema,
|
|
380
|
-
id:
|
|
546
|
+
id: v11.string()
|
|
381
547
|
}).entries
|
|
382
548
|
});
|
|
383
549
|
|
|
384
550
|
// src/request/types/stxMethods/signTransaction.ts
|
|
385
|
-
import * as
|
|
551
|
+
import * as v12 from "valibot";
|
|
386
552
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
387
|
-
var stxSignTransactionParamsSchema =
|
|
553
|
+
var stxSignTransactionParamsSchema = v12.object({
|
|
388
554
|
/**
|
|
389
555
|
* The transaction to sign as a hex-encoded string.
|
|
390
556
|
*/
|
|
391
|
-
transaction:
|
|
557
|
+
transaction: v12.string(),
|
|
392
558
|
/**
|
|
393
559
|
* The public key to sign the transaction with. The wallet may use any key
|
|
394
560
|
* when not provided.
|
|
395
561
|
*/
|
|
396
|
-
pubkey:
|
|
562
|
+
pubkey: v12.optional(v12.string()),
|
|
397
563
|
/**
|
|
398
564
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
399
565
|
*/
|
|
400
|
-
broadcast:
|
|
566
|
+
broadcast: v12.optional(v12.boolean())
|
|
401
567
|
});
|
|
402
|
-
var stxSignTransactionResultSchema =
|
|
568
|
+
var stxSignTransactionResultSchema = v12.object({
|
|
403
569
|
/**
|
|
404
570
|
* The signed transaction as a hex-encoded string.
|
|
405
571
|
*/
|
|
406
|
-
transaction:
|
|
572
|
+
transaction: v12.string()
|
|
407
573
|
});
|
|
408
|
-
var stxSignTransactionRequestMessageSchema =
|
|
574
|
+
var stxSignTransactionRequestMessageSchema = v12.object({
|
|
409
575
|
...rpcRequestMessageSchema.entries,
|
|
410
|
-
...
|
|
411
|
-
method:
|
|
576
|
+
...v12.object({
|
|
577
|
+
method: v12.literal(stxSignTransactionMethodName),
|
|
412
578
|
params: stxSignTransactionParamsSchema,
|
|
413
|
-
id:
|
|
579
|
+
id: v12.string()
|
|
414
580
|
}).entries
|
|
415
581
|
});
|
|
416
582
|
|
|
417
583
|
// src/request/types/stxMethods/signTransactions.ts
|
|
418
|
-
import * as
|
|
584
|
+
import * as v13 from "valibot";
|
|
419
585
|
var stxSignTransactionsMethodName = "stx_signTransactions";
|
|
420
|
-
var stxSignTransactionsParamsSchema =
|
|
586
|
+
var stxSignTransactionsParamsSchema = v13.object({
|
|
421
587
|
/**
|
|
422
588
|
* The transactions to sign as hex-encoded strings.
|
|
423
589
|
*/
|
|
424
|
-
transactions:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
590
|
+
transactions: v13.pipe(
|
|
591
|
+
v13.array(
|
|
592
|
+
v13.pipe(
|
|
593
|
+
v13.string(),
|
|
594
|
+
v13.check((hex) => {
|
|
429
595
|
return true;
|
|
430
596
|
}, "Invalid hex-encoded Stacks transaction.")
|
|
431
597
|
)
|
|
432
598
|
),
|
|
433
|
-
|
|
599
|
+
v13.minLength(1)
|
|
434
600
|
),
|
|
435
601
|
/**
|
|
436
602
|
* Whether the signed transactions should be broadcast after signing. Defaults
|
|
437
603
|
* to `true`.
|
|
438
604
|
*/
|
|
439
|
-
broadcast:
|
|
605
|
+
broadcast: v13.optional(v13.boolean())
|
|
440
606
|
});
|
|
441
|
-
var stxSignTransactionsResultSchema =
|
|
607
|
+
var stxSignTransactionsResultSchema = v13.object({
|
|
442
608
|
/**
|
|
443
609
|
* The signed transactions as hex-encoded strings, in the same order as in the
|
|
444
610
|
* sign request.
|
|
445
611
|
*/
|
|
446
|
-
transactions:
|
|
612
|
+
transactions: v13.array(v13.string())
|
|
447
613
|
});
|
|
448
|
-
var stxSignTransactionsRequestMessageSchema =
|
|
614
|
+
var stxSignTransactionsRequestMessageSchema = v13.object({
|
|
449
615
|
...rpcRequestMessageSchema.entries,
|
|
450
|
-
...
|
|
451
|
-
method:
|
|
616
|
+
...v13.object({
|
|
617
|
+
method: v13.literal(stxSignTransactionsMethodName),
|
|
452
618
|
params: stxSignTransactionsParamsSchema,
|
|
453
|
-
id:
|
|
619
|
+
id: v13.string()
|
|
454
620
|
}).entries
|
|
455
621
|
});
|
|
456
622
|
|
|
457
623
|
// src/request/types/stxMethods/transferStx.ts
|
|
458
|
-
import * as
|
|
624
|
+
import * as v14 from "valibot";
|
|
459
625
|
var stxTransferStxMethodName = "stx_transferStx";
|
|
460
|
-
var stxTransferStxParamsSchema =
|
|
626
|
+
var stxTransferStxParamsSchema = v14.object({
|
|
461
627
|
/**
|
|
462
628
|
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
463
629
|
* parseable by `BigInt` is acceptable.
|
|
@@ -470,23 +636,23 @@ var stxTransferStxParamsSchema = v12.object({
|
|
|
470
636
|
* const amount3 = '1234';
|
|
471
637
|
* ```
|
|
472
638
|
*/
|
|
473
|
-
amount:
|
|
639
|
+
amount: v14.union([v14.number(), v14.string()]),
|
|
474
640
|
/**
|
|
475
641
|
* The recipeint's principal.
|
|
476
642
|
*/
|
|
477
|
-
recipient:
|
|
643
|
+
recipient: v14.string(),
|
|
478
644
|
/**
|
|
479
645
|
* A string representing the memo.
|
|
480
646
|
*/
|
|
481
|
-
memo:
|
|
647
|
+
memo: v14.optional(v14.string()),
|
|
482
648
|
/**
|
|
483
649
|
* Version of parameter format.
|
|
484
650
|
*/
|
|
485
|
-
version:
|
|
651
|
+
version: v14.optional(v14.string()),
|
|
486
652
|
/**
|
|
487
653
|
* The mode of the post conditions.
|
|
488
654
|
*/
|
|
489
|
-
postConditionMode:
|
|
655
|
+
postConditionMode: v14.optional(v14.number()),
|
|
490
656
|
/**
|
|
491
657
|
* A hex-encoded string representing the post conditions.
|
|
492
658
|
*
|
|
@@ -499,89 +665,83 @@ var stxTransferStxParamsSchema = v12.object({
|
|
|
499
665
|
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
500
666
|
* ```
|
|
501
667
|
*/
|
|
502
|
-
postConditions:
|
|
668
|
+
postConditions: v14.optional(v14.array(v14.string())),
|
|
503
669
|
/**
|
|
504
670
|
* The public key to sign the transaction with. The wallet may use any key
|
|
505
671
|
* when not provided.
|
|
506
672
|
*/
|
|
507
|
-
pubkey:
|
|
673
|
+
pubkey: v14.optional(v14.string())
|
|
508
674
|
});
|
|
509
|
-
var stxTransferStxResultSchema =
|
|
675
|
+
var stxTransferStxResultSchema = v14.object({
|
|
510
676
|
/**
|
|
511
677
|
* The ID of the transaction.
|
|
512
678
|
*/
|
|
513
|
-
txid:
|
|
679
|
+
txid: v14.string(),
|
|
514
680
|
/**
|
|
515
681
|
* A Stacks transaction as a hex-encoded string.
|
|
516
682
|
*/
|
|
517
|
-
transaction:
|
|
683
|
+
transaction: v14.string()
|
|
518
684
|
});
|
|
519
|
-
var stxTransferStxRequestMessageSchema =
|
|
685
|
+
var stxTransferStxRequestMessageSchema = v14.object({
|
|
520
686
|
...rpcRequestMessageSchema.entries,
|
|
521
|
-
...
|
|
522
|
-
method:
|
|
687
|
+
...v14.object({
|
|
688
|
+
method: v14.literal(stxTransferStxMethodName),
|
|
523
689
|
params: stxTransferStxParamsSchema,
|
|
524
|
-
id:
|
|
690
|
+
id: v14.string()
|
|
525
691
|
}).entries
|
|
526
692
|
});
|
|
527
693
|
|
|
528
694
|
// src/request/types/btcMethods.ts
|
|
529
|
-
import * as
|
|
530
|
-
|
|
531
|
-
// src/request/types/common.ts
|
|
532
|
-
import * as v13 from "valibot";
|
|
533
|
-
var walletTypes = ["software", "ledger", "keystone"];
|
|
534
|
-
var walletTypeSchema = v13.picklist(walletTypes);
|
|
535
|
-
|
|
536
|
-
// src/request/types/btcMethods.ts
|
|
695
|
+
import * as v15 from "valibot";
|
|
537
696
|
var getInfoMethodName = "getInfo";
|
|
538
|
-
var getInfoParamsSchema =
|
|
539
|
-
var getInfoResultSchema =
|
|
697
|
+
var getInfoParamsSchema = v15.nullish(v15.null());
|
|
698
|
+
var getInfoResultSchema = v15.object({
|
|
540
699
|
/**
|
|
541
700
|
* Version of the wallet.
|
|
542
701
|
*/
|
|
543
|
-
version:
|
|
702
|
+
version: v15.string(),
|
|
544
703
|
/**
|
|
545
704
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
546
705
|
*/
|
|
547
|
-
methods:
|
|
706
|
+
methods: v15.optional(v15.array(v15.string())),
|
|
548
707
|
/**
|
|
549
708
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
550
709
|
*/
|
|
551
|
-
supports:
|
|
710
|
+
supports: v15.array(v15.string())
|
|
552
711
|
});
|
|
553
|
-
var getInfoRequestMessageSchema =
|
|
712
|
+
var getInfoRequestMessageSchema = v15.object({
|
|
554
713
|
...rpcRequestMessageSchema.entries,
|
|
555
|
-
...
|
|
556
|
-
method:
|
|
714
|
+
...v15.object({
|
|
715
|
+
method: v15.literal(getInfoMethodName),
|
|
557
716
|
params: getInfoParamsSchema,
|
|
558
|
-
id:
|
|
717
|
+
id: v15.string()
|
|
559
718
|
}).entries
|
|
560
719
|
});
|
|
561
720
|
var getAddressesMethodName = "getAddresses";
|
|
562
|
-
var getAddressesParamsSchema =
|
|
721
|
+
var getAddressesParamsSchema = v15.object({
|
|
563
722
|
/**
|
|
564
723
|
* The purposes for which to generate addresses. See
|
|
565
724
|
* {@linkcode AddressPurpose} for available purposes.
|
|
566
725
|
*/
|
|
567
|
-
purposes:
|
|
726
|
+
purposes: v15.array(v15.enum(AddressPurpose)),
|
|
568
727
|
/**
|
|
569
728
|
* A message to be displayed to the user in the request prompt.
|
|
570
729
|
*/
|
|
571
|
-
message:
|
|
730
|
+
message: v15.optional(v15.string())
|
|
572
731
|
});
|
|
573
|
-
var getAddressesResultSchema =
|
|
732
|
+
var getAddressesResultSchema = v15.object({
|
|
574
733
|
/**
|
|
575
734
|
* The addresses generated for the given purposes.
|
|
576
735
|
*/
|
|
577
|
-
addresses:
|
|
736
|
+
addresses: v15.array(addressSchema),
|
|
737
|
+
network: getNetworkResultSchema
|
|
578
738
|
});
|
|
579
|
-
var getAddressesRequestMessageSchema =
|
|
739
|
+
var getAddressesRequestMessageSchema = v15.object({
|
|
580
740
|
...rpcRequestMessageSchema.entries,
|
|
581
|
-
...
|
|
582
|
-
method:
|
|
741
|
+
...v15.object({
|
|
742
|
+
method: v15.literal(getAddressesMethodName),
|
|
583
743
|
params: getAddressesParamsSchema,
|
|
584
|
-
id:
|
|
744
|
+
id: v15.string()
|
|
585
745
|
}).entries
|
|
586
746
|
});
|
|
587
747
|
var signMessageMethodName = "signMessage";
|
|
@@ -590,305 +750,162 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
|
|
|
590
750
|
MessageSigningProtocols2["BIP322"] = "BIP322";
|
|
591
751
|
return MessageSigningProtocols2;
|
|
592
752
|
})(MessageSigningProtocols || {});
|
|
593
|
-
var signMessageParamsSchema =
|
|
753
|
+
var signMessageParamsSchema = v15.object({
|
|
594
754
|
/**
|
|
595
755
|
* The address used for signing.
|
|
596
756
|
**/
|
|
597
|
-
address:
|
|
757
|
+
address: v15.string(),
|
|
598
758
|
/**
|
|
599
759
|
* The message to sign.
|
|
600
760
|
**/
|
|
601
|
-
message:
|
|
761
|
+
message: v15.string(),
|
|
602
762
|
/**
|
|
603
763
|
* The protocol to use for signing the message.
|
|
604
764
|
*/
|
|
605
|
-
protocol:
|
|
765
|
+
protocol: v15.optional(v15.enum(MessageSigningProtocols))
|
|
606
766
|
});
|
|
607
|
-
var signMessageResultSchema =
|
|
767
|
+
var signMessageResultSchema = v15.object({
|
|
608
768
|
/**
|
|
609
769
|
* The signature of the message.
|
|
610
770
|
*/
|
|
611
|
-
signature:
|
|
771
|
+
signature: v15.string(),
|
|
612
772
|
/**
|
|
613
773
|
* hash of the message.
|
|
614
774
|
*/
|
|
615
|
-
messageHash:
|
|
775
|
+
messageHash: v15.string(),
|
|
616
776
|
/**
|
|
617
777
|
* The address used for signing.
|
|
618
778
|
*/
|
|
619
|
-
address:
|
|
779
|
+
address: v15.string(),
|
|
620
780
|
/**
|
|
621
781
|
* The protocol to use for signing the message.
|
|
622
782
|
*/
|
|
623
|
-
protocol:
|
|
783
|
+
protocol: v15.enum(MessageSigningProtocols)
|
|
624
784
|
});
|
|
625
|
-
var signMessageRequestMessageSchema =
|
|
785
|
+
var signMessageRequestMessageSchema = v15.object({
|
|
626
786
|
...rpcRequestMessageSchema.entries,
|
|
627
|
-
...
|
|
628
|
-
method:
|
|
787
|
+
...v15.object({
|
|
788
|
+
method: v15.literal(signMessageMethodName),
|
|
629
789
|
params: signMessageParamsSchema,
|
|
630
|
-
id:
|
|
790
|
+
id: v15.string()
|
|
631
791
|
}).entries
|
|
632
792
|
});
|
|
633
793
|
var sendTransferMethodName = "sendTransfer";
|
|
634
|
-
var sendTransferParamsSchema =
|
|
794
|
+
var sendTransferParamsSchema = v15.object({
|
|
635
795
|
/**
|
|
636
796
|
* Array of recipients to send to.
|
|
637
797
|
* The amount to send to each recipient is in satoshis.
|
|
638
798
|
*/
|
|
639
|
-
recipients:
|
|
640
|
-
|
|
641
|
-
address:
|
|
642
|
-
amount:
|
|
799
|
+
recipients: v15.array(
|
|
800
|
+
v15.object({
|
|
801
|
+
address: v15.string(),
|
|
802
|
+
amount: v15.number()
|
|
643
803
|
})
|
|
644
804
|
)
|
|
645
805
|
});
|
|
646
|
-
var sendTransferResultSchema =
|
|
806
|
+
var sendTransferResultSchema = v15.object({
|
|
647
807
|
/**
|
|
648
808
|
* The transaction id as a hex-encoded string.
|
|
649
809
|
*/
|
|
650
|
-
txid:
|
|
810
|
+
txid: v15.string()
|
|
651
811
|
});
|
|
652
|
-
var sendTransferRequestMessageSchema =
|
|
812
|
+
var sendTransferRequestMessageSchema = v15.object({
|
|
653
813
|
...rpcRequestMessageSchema.entries,
|
|
654
|
-
...
|
|
655
|
-
method:
|
|
814
|
+
...v15.object({
|
|
815
|
+
method: v15.literal(sendTransferMethodName),
|
|
656
816
|
params: sendTransferParamsSchema,
|
|
657
|
-
id:
|
|
817
|
+
id: v15.string()
|
|
658
818
|
}).entries
|
|
659
819
|
});
|
|
660
820
|
var signPsbtMethodName = "signPsbt";
|
|
661
|
-
var signPsbtParamsSchema =
|
|
821
|
+
var signPsbtParamsSchema = v15.object({
|
|
662
822
|
/**
|
|
663
823
|
* The base64 encoded PSBT to sign.
|
|
664
824
|
*/
|
|
665
|
-
psbt:
|
|
825
|
+
psbt: v15.string(),
|
|
666
826
|
/**
|
|
667
827
|
* The inputs to sign.
|
|
668
828
|
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
669
829
|
*/
|
|
670
|
-
signInputs:
|
|
830
|
+
signInputs: v15.record(v15.string(), v15.array(v15.number())),
|
|
671
831
|
/**
|
|
672
832
|
* Whether to broadcast the transaction after signing.
|
|
673
833
|
**/
|
|
674
|
-
broadcast:
|
|
834
|
+
broadcast: v15.optional(v15.boolean())
|
|
675
835
|
});
|
|
676
|
-
var signPsbtResultSchema =
|
|
836
|
+
var signPsbtResultSchema = v15.object({
|
|
677
837
|
/**
|
|
678
838
|
* The base64 encoded PSBT after signing.
|
|
679
839
|
*/
|
|
680
|
-
psbt:
|
|
840
|
+
psbt: v15.string(),
|
|
681
841
|
/**
|
|
682
842
|
* The transaction id as a hex-encoded string.
|
|
683
843
|
* This is only returned if the transaction was broadcast.
|
|
684
844
|
**/
|
|
685
|
-
txid:
|
|
845
|
+
txid: v15.optional(v15.string())
|
|
686
846
|
});
|
|
687
|
-
var signPsbtRequestMessageSchema =
|
|
847
|
+
var signPsbtRequestMessageSchema = v15.object({
|
|
688
848
|
...rpcRequestMessageSchema.entries,
|
|
689
|
-
...
|
|
690
|
-
method:
|
|
849
|
+
...v15.object({
|
|
850
|
+
method: v15.literal(signPsbtMethodName),
|
|
691
851
|
params: signPsbtParamsSchema,
|
|
692
|
-
id:
|
|
852
|
+
id: v15.string()
|
|
693
853
|
}).entries
|
|
694
854
|
});
|
|
695
855
|
var getAccountsMethodName = "getAccounts";
|
|
696
|
-
var getAccountsParamsSchema =
|
|
856
|
+
var getAccountsParamsSchema = v15.object({
|
|
697
857
|
/**
|
|
698
858
|
* The purposes for which to generate addresses. See
|
|
699
859
|
* {@linkcode AddressPurpose} for available purposes.
|
|
700
860
|
*/
|
|
701
|
-
purposes:
|
|
861
|
+
purposes: v15.array(v15.enum(AddressPurpose)),
|
|
702
862
|
/**
|
|
703
863
|
* A message to be displayed to the user in the request prompt.
|
|
704
864
|
*/
|
|
705
|
-
message:
|
|
865
|
+
message: v15.optional(v15.string())
|
|
706
866
|
});
|
|
707
|
-
var getAccountsResultSchema =
|
|
708
|
-
|
|
867
|
+
var getAccountsResultSchema = v15.array(
|
|
868
|
+
v15.object({
|
|
709
869
|
...addressSchema.entries,
|
|
710
|
-
...
|
|
870
|
+
...v15.object({
|
|
711
871
|
walletType: walletTypeSchema
|
|
712
872
|
}).entries
|
|
713
873
|
})
|
|
714
874
|
);
|
|
715
|
-
var getAccountsRequestMessageSchema =
|
|
875
|
+
var getAccountsRequestMessageSchema = v15.object({
|
|
716
876
|
...rpcRequestMessageSchema.entries,
|
|
717
|
-
...
|
|
718
|
-
method:
|
|
877
|
+
...v15.object({
|
|
878
|
+
method: v15.literal(getAccountsMethodName),
|
|
719
879
|
params: getAccountsParamsSchema,
|
|
720
|
-
id:
|
|
880
|
+
id: v15.string()
|
|
721
881
|
}).entries
|
|
722
882
|
});
|
|
723
883
|
var getBalanceMethodName = "getBalance";
|
|
724
|
-
var getBalanceParamsSchema =
|
|
725
|
-
var getBalanceResultSchema =
|
|
884
|
+
var getBalanceParamsSchema = v15.nullish(v15.null());
|
|
885
|
+
var getBalanceResultSchema = v15.object({
|
|
726
886
|
/**
|
|
727
887
|
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
728
888
|
* messages not supporting bigint
|
|
729
889
|
* (https://issues.chromium.org/issues/40116184).
|
|
730
890
|
*/
|
|
731
|
-
confirmed:
|
|
891
|
+
confirmed: v15.string(),
|
|
732
892
|
/**
|
|
733
893
|
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
734
894
|
* messages not supporting bigint
|
|
735
895
|
* (https://issues.chromium.org/issues/40116184).
|
|
736
896
|
*/
|
|
737
|
-
unconfirmed:
|
|
897
|
+
unconfirmed: v15.string(),
|
|
738
898
|
/**
|
|
739
899
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
740
900
|
* sats. Using a string due to chrome messages not supporting bigint
|
|
741
901
|
* (https://issues.chromium.org/issues/40116184).
|
|
742
902
|
*/
|
|
743
|
-
total:
|
|
744
|
-
});
|
|
745
|
-
var getBalanceRequestMessageSchema = v14.object({
|
|
746
|
-
...rpcRequestMessageSchema.entries,
|
|
747
|
-
...v14.object({
|
|
748
|
-
method: v14.literal(getBalanceMethodName),
|
|
749
|
-
id: v14.string()
|
|
750
|
-
}).entries
|
|
751
|
-
});
|
|
752
|
-
|
|
753
|
-
// src/request/types/walletMethods.ts
|
|
754
|
-
import * as v15 from "valibot";
|
|
755
|
-
var accountActionsSchema = v15.object({
|
|
756
|
-
read: v15.optional(v15.boolean())
|
|
757
|
-
});
|
|
758
|
-
var walletActionsSchema = v15.object({
|
|
759
|
-
readNetwork: v15.optional(v15.boolean())
|
|
760
|
-
});
|
|
761
|
-
var accountPermissionSchema = v15.object({
|
|
762
|
-
type: v15.literal("account"),
|
|
763
|
-
resourceId: v15.string(),
|
|
764
|
-
clientId: v15.string(),
|
|
765
|
-
actions: accountActionsSchema
|
|
766
|
-
});
|
|
767
|
-
var walletPermissionSchema = v15.object({
|
|
768
|
-
type: v15.literal("wallet"),
|
|
769
|
-
resourceId: v15.string(),
|
|
770
|
-
clientId: v15.string(),
|
|
771
|
-
actions: walletActionsSchema
|
|
772
|
-
});
|
|
773
|
-
var PermissionRequestParams = v15.variant("type", [
|
|
774
|
-
v15.object({
|
|
775
|
-
...v15.omit(accountPermissionSchema, ["clientId"]).entries
|
|
776
|
-
}),
|
|
777
|
-
v15.object({
|
|
778
|
-
...v15.omit(walletPermissionSchema, ["clientId"]).entries
|
|
779
|
-
})
|
|
780
|
-
]);
|
|
781
|
-
var permission = v15.variant("type", [accountPermissionSchema, walletPermissionSchema]);
|
|
782
|
-
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
783
|
-
var requestPermissionsParamsSchema = v15.nullish(v15.array(PermissionRequestParams));
|
|
784
|
-
var requestPermissionsResultSchema = v15.literal(true);
|
|
785
|
-
var requestPermissionsRequestMessageSchema = v15.object({
|
|
786
|
-
...rpcRequestMessageSchema.entries,
|
|
787
|
-
...v15.object({
|
|
788
|
-
method: v15.literal(requestPermissionsMethodName),
|
|
789
|
-
params: requestPermissionsParamsSchema,
|
|
790
|
-
id: v15.string()
|
|
791
|
-
}).entries
|
|
792
|
-
});
|
|
793
|
-
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
794
|
-
var renouncePermissionsParamsSchema = v15.nullish(v15.null());
|
|
795
|
-
var renouncePermissionsResultSchema = v15.nullish(v15.null());
|
|
796
|
-
var renouncePermissionsRequestMessageSchema = v15.object({
|
|
797
|
-
...rpcRequestMessageSchema.entries,
|
|
798
|
-
...v15.object({
|
|
799
|
-
method: v15.literal(renouncePermissionsMethodName),
|
|
800
|
-
params: renouncePermissionsParamsSchema,
|
|
801
|
-
id: v15.string()
|
|
802
|
-
}).entries
|
|
803
|
-
});
|
|
804
|
-
var disconnectMethodName = "wallet_disconnect";
|
|
805
|
-
var disconnectParamsSchema = v15.nullish(v15.null());
|
|
806
|
-
var disconnectResultSchema = v15.nullish(v15.null());
|
|
807
|
-
var disconnectRequestMessageSchema = v15.object({
|
|
808
|
-
...rpcRequestMessageSchema.entries,
|
|
809
|
-
...v15.object({
|
|
810
|
-
method: v15.literal(disconnectMethodName),
|
|
811
|
-
params: disconnectParamsSchema,
|
|
812
|
-
id: v15.string()
|
|
813
|
-
}).entries
|
|
814
|
-
});
|
|
815
|
-
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
816
|
-
var getWalletTypeParamsSchema = v15.nullish(v15.null());
|
|
817
|
-
var getWalletTypeResultSchema = walletTypeSchema;
|
|
818
|
-
var getWalletTypeRequestMessageSchema = v15.object({
|
|
819
|
-
...rpcRequestMessageSchema.entries,
|
|
820
|
-
...v15.object({
|
|
821
|
-
method: v15.literal(getWalletTypeMethodName),
|
|
822
|
-
params: getWalletTypeParamsSchema,
|
|
823
|
-
id: v15.string()
|
|
824
|
-
}).entries
|
|
825
|
-
});
|
|
826
|
-
var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
827
|
-
var getCurrentPermissionsParamsSchema = v15.nullish(v15.null());
|
|
828
|
-
var getCurrentPermissionsResultSchema = v15.array(permission);
|
|
829
|
-
var getCurrentPermissionsRequestMessageSchema = v15.object({
|
|
830
|
-
...rpcRequestMessageSchema.entries,
|
|
831
|
-
...v15.object({
|
|
832
|
-
method: v15.literal(getCurrentPermissionsMethodName),
|
|
833
|
-
params: getCurrentPermissionsParamsSchema,
|
|
834
|
-
id: v15.string()
|
|
835
|
-
}).entries
|
|
836
|
-
});
|
|
837
|
-
var getAccountMethodName = "wallet_getAccount";
|
|
838
|
-
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
839
|
-
var getAccountResultSchema = v15.object({
|
|
840
|
-
id: v15.string(),
|
|
841
|
-
addresses: v15.array(addressSchema),
|
|
842
|
-
walletType: walletTypeSchema
|
|
843
|
-
});
|
|
844
|
-
var getAccountRequestMessageSchema = v15.object({
|
|
845
|
-
...rpcRequestMessageSchema.entries,
|
|
846
|
-
...v15.object({
|
|
847
|
-
method: v15.literal(getAccountMethodName),
|
|
848
|
-
params: getAccountParamsSchema,
|
|
849
|
-
id: v15.string()
|
|
850
|
-
}).entries
|
|
851
|
-
});
|
|
852
|
-
var getNetworkMethodName = "wallet_getNetwork";
|
|
853
|
-
var getNetworkParamsSchema = v15.nullish(v15.null());
|
|
854
|
-
var networkType2 = ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"];
|
|
855
|
-
var getNetworkResultSchema = v15.object({
|
|
856
|
-
bitcoin: v15.object({
|
|
857
|
-
name: v15.picklist(networkType2)
|
|
858
|
-
}),
|
|
859
|
-
stacks: v15.object({
|
|
860
|
-
name: v15.string()
|
|
861
|
-
})
|
|
862
|
-
});
|
|
863
|
-
var getNetworkRequestMessageSchema = v15.object({
|
|
864
|
-
...rpcRequestMessageSchema.entries,
|
|
865
|
-
...v15.object({
|
|
866
|
-
method: v15.literal(getNetworkMethodName),
|
|
867
|
-
params: getNetworkParamsSchema,
|
|
868
|
-
id: v15.string()
|
|
869
|
-
}).entries
|
|
903
|
+
total: v15.string()
|
|
870
904
|
});
|
|
871
|
-
var
|
|
872
|
-
var connectParamsSchema = v15.nullish(
|
|
873
|
-
v15.object({
|
|
874
|
-
permissions: v15.optional(v15.array(PermissionRequestParams)),
|
|
875
|
-
addresses: v15.optional(v15.array(v15.enum(AddressPurpose))),
|
|
876
|
-
message: v15.optional(
|
|
877
|
-
v15.pipe(v15.string(), v15.maxLength(80, "The message must not exceed 80 characters."))
|
|
878
|
-
)
|
|
879
|
-
})
|
|
880
|
-
);
|
|
881
|
-
var connectResultSchema = v15.object({
|
|
882
|
-
id: v15.string(),
|
|
883
|
-
addresses: v15.array(addressSchema),
|
|
884
|
-
walletType: walletTypeSchema,
|
|
885
|
-
network: getNetworkResultSchema
|
|
886
|
-
});
|
|
887
|
-
var connectRequestMessageSchema = v15.object({
|
|
905
|
+
var getBalanceRequestMessageSchema = v15.object({
|
|
888
906
|
...rpcRequestMessageSchema.entries,
|
|
889
907
|
...v15.object({
|
|
890
|
-
method: v15.literal(
|
|
891
|
-
params: connectParamsSchema,
|
|
908
|
+
method: v15.literal(getBalanceMethodName),
|
|
892
909
|
id: v15.string()
|
|
893
910
|
}).entries
|
|
894
911
|
});
|
|
@@ -949,7 +966,8 @@ var runesGetBalanceResultSchema = v17.object({
|
|
|
949
966
|
amount: v17.string(),
|
|
950
967
|
divisibility: v17.number(),
|
|
951
968
|
symbol: v17.string(),
|
|
952
|
-
inscriptionId: v17.nullish(v17.string())
|
|
969
|
+
inscriptionId: v17.nullish(v17.string()),
|
|
970
|
+
spendableBalance: v17.string()
|
|
953
971
|
})
|
|
954
972
|
)
|
|
955
973
|
});
|
|
@@ -2092,6 +2110,10 @@ export {
|
|
|
2092
2110
|
accountPermissionSchema,
|
|
2093
2111
|
addListener,
|
|
2094
2112
|
addressSchema,
|
|
2113
|
+
changeNetworkMethodName,
|
|
2114
|
+
changeNetworkParamsSchema,
|
|
2115
|
+
changeNetworkRequestMessageSchema,
|
|
2116
|
+
changeNetworkResultSchema,
|
|
2095
2117
|
connectMethodName,
|
|
2096
2118
|
connectParamsSchema,
|
|
2097
2119
|
connectRequestMessageSchema,
|