@sats-connect/core 0.5.7-919d21a → 0.5.7-dfae3ce
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 +83 -41
- package/dist/index.d.ts +83 -41
- 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,369 @@ 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.nullish(
|
|
369
|
+
v7.object({
|
|
370
|
+
name: v7.enum(BitcoinNetworkType)
|
|
371
|
+
})
|
|
372
|
+
);
|
|
373
|
+
var changeNetworkResultSchema = v7.nullish(v7.null());
|
|
374
|
+
var changeNetworkRequestMessageSchema = v7.object({
|
|
375
|
+
...rpcRequestMessageSchema.entries,
|
|
376
|
+
...v7.object({
|
|
377
|
+
method: v7.literal(changeNetworkMethodName),
|
|
378
|
+
params: changeNetworkParamsSchema,
|
|
379
|
+
id: v7.string()
|
|
380
|
+
}).entries
|
|
381
|
+
});
|
|
382
|
+
var getAccountMethodName = "wallet_getAccount";
|
|
383
|
+
var getAccountParamsSchema = v7.nullish(v7.null());
|
|
384
|
+
var getAccountResultSchema = v7.object({
|
|
385
|
+
id: v7.string(),
|
|
386
|
+
addresses: v7.array(addressSchema),
|
|
387
|
+
walletType: walletTypeSchema,
|
|
388
|
+
network: getNetworkResultSchema
|
|
389
|
+
});
|
|
390
|
+
var getAccountRequestMessageSchema = v7.object({
|
|
391
|
+
...rpcRequestMessageSchema.entries,
|
|
392
|
+
...v7.object({
|
|
393
|
+
method: v7.literal(getAccountMethodName),
|
|
394
|
+
params: getAccountParamsSchema,
|
|
395
|
+
id: v7.string()
|
|
396
|
+
}).entries
|
|
397
|
+
});
|
|
398
|
+
var connectMethodName = "wallet_connect";
|
|
399
|
+
var connectParamsSchema = v7.nullish(
|
|
400
|
+
v7.object({
|
|
401
|
+
permissions: v7.optional(v7.array(PermissionRequestParams)),
|
|
402
|
+
addresses: v7.optional(v7.array(v7.enum(AddressPurpose))),
|
|
403
|
+
message: v7.optional(
|
|
404
|
+
v7.pipe(v7.string(), v7.maxLength(80, "The message must not exceed 80 characters."))
|
|
405
|
+
)
|
|
406
|
+
})
|
|
407
|
+
);
|
|
408
|
+
var connectResultSchema = v7.object({
|
|
409
|
+
id: v7.string(),
|
|
410
|
+
addresses: v7.array(addressSchema),
|
|
411
|
+
walletType: walletTypeSchema,
|
|
412
|
+
network: getNetworkResultSchema
|
|
413
|
+
});
|
|
414
|
+
var connectRequestMessageSchema = v7.object({
|
|
415
|
+
...rpcRequestMessageSchema.entries,
|
|
416
|
+
...v7.object({
|
|
417
|
+
method: v7.literal(connectMethodName),
|
|
418
|
+
params: connectParamsSchema,
|
|
419
|
+
id: v7.string()
|
|
420
|
+
}).entries
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// src/request/types/stxMethods/getAccounts.ts
|
|
424
|
+
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
425
|
+
var stxGetAccountsParamsSchema = v8.nullish(v8.null());
|
|
426
|
+
var stxGetAccountsResultSchema = v8.object({
|
|
427
|
+
/**
|
|
428
|
+
* The addresses generated for the given purposes.
|
|
429
|
+
*/
|
|
430
|
+
addresses: v8.array(
|
|
431
|
+
v8.object({
|
|
432
|
+
address: v8.string(),
|
|
433
|
+
publicKey: v8.string(),
|
|
434
|
+
gaiaHubUrl: v8.string(),
|
|
435
|
+
gaiaAppKey: v8.string()
|
|
436
|
+
})
|
|
437
|
+
),
|
|
438
|
+
network: getNetworkResultSchema
|
|
439
|
+
});
|
|
440
|
+
var stxGetAccountsRequestMessageSchema = v8.object({
|
|
441
|
+
...rpcRequestMessageSchema.entries,
|
|
442
|
+
...v8.object({
|
|
443
|
+
method: v8.literal(stxGetAccountsMethodName),
|
|
444
|
+
params: stxGetAccountsParamsSchema,
|
|
445
|
+
id: v8.string()
|
|
446
|
+
}).entries
|
|
447
|
+
});
|
|
448
|
+
|
|
282
449
|
// src/request/types/stxMethods/getAddresses.ts
|
|
283
|
-
import * as
|
|
450
|
+
import * as v9 from "valibot";
|
|
284
451
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
285
|
-
var stxGetAddressesParamsSchema =
|
|
286
|
-
|
|
452
|
+
var stxGetAddressesParamsSchema = v9.nullish(
|
|
453
|
+
v9.object({
|
|
287
454
|
/**
|
|
288
455
|
* A message to be displayed to the user in the request prompt.
|
|
289
456
|
*/
|
|
290
|
-
message:
|
|
457
|
+
message: v9.optional(v9.string())
|
|
291
458
|
})
|
|
292
459
|
);
|
|
293
|
-
var stxGetAddressesResultSchema =
|
|
460
|
+
var stxGetAddressesResultSchema = v9.object({
|
|
294
461
|
/**
|
|
295
462
|
* The addresses generated for the given purposes.
|
|
296
463
|
*/
|
|
297
|
-
addresses:
|
|
464
|
+
addresses: v9.array(addressSchema),
|
|
465
|
+
network: getNetworkResultSchema
|
|
298
466
|
});
|
|
299
|
-
var stxGetAddressesRequestMessageSchema =
|
|
467
|
+
var stxGetAddressesRequestMessageSchema = v9.object({
|
|
300
468
|
...rpcRequestMessageSchema.entries,
|
|
301
|
-
...
|
|
302
|
-
method:
|
|
469
|
+
...v9.object({
|
|
470
|
+
method: v9.literal(stxGetAddressesMethodName),
|
|
303
471
|
params: stxGetAddressesParamsSchema,
|
|
304
|
-
id:
|
|
472
|
+
id: v9.string()
|
|
305
473
|
}).entries
|
|
306
474
|
});
|
|
307
475
|
|
|
308
476
|
// src/request/types/stxMethods/signMessage.ts
|
|
309
|
-
import * as
|
|
477
|
+
import * as v10 from "valibot";
|
|
310
478
|
var stxSignMessageMethodName = "stx_signMessage";
|
|
311
|
-
var stxSignMessageParamsSchema =
|
|
479
|
+
var stxSignMessageParamsSchema = v10.object({
|
|
312
480
|
/**
|
|
313
481
|
* The message to sign.
|
|
314
482
|
*/
|
|
315
|
-
message:
|
|
483
|
+
message: v10.string(),
|
|
316
484
|
/**
|
|
317
485
|
* The public key to sign the message with.
|
|
318
486
|
*/
|
|
319
|
-
publicKey:
|
|
487
|
+
publicKey: v10.string(),
|
|
320
488
|
/**
|
|
321
489
|
* The format version of the parameter.
|
|
322
490
|
*/
|
|
323
|
-
parameterFormatVersion:
|
|
491
|
+
parameterFormatVersion: v10.optional(v10.number())
|
|
324
492
|
});
|
|
325
|
-
var stxSignMessageResultSchema =
|
|
493
|
+
var stxSignMessageResultSchema = v10.object({
|
|
326
494
|
/**
|
|
327
495
|
* The signature of the message.
|
|
328
496
|
*/
|
|
329
|
-
signature:
|
|
497
|
+
signature: v10.string(),
|
|
330
498
|
/**
|
|
331
499
|
* The public key used to sign the message.
|
|
332
500
|
*/
|
|
333
|
-
publicKey:
|
|
501
|
+
publicKey: v10.string()
|
|
334
502
|
});
|
|
335
|
-
var stxSignMessageRequestMessageSchema =
|
|
503
|
+
var stxSignMessageRequestMessageSchema = v10.object({
|
|
336
504
|
...rpcRequestMessageSchema.entries,
|
|
337
|
-
...
|
|
338
|
-
method:
|
|
505
|
+
...v10.object({
|
|
506
|
+
method: v10.literal(stxSignMessageMethodName),
|
|
339
507
|
params: stxSignMessageParamsSchema,
|
|
340
|
-
id:
|
|
508
|
+
id: v10.string()
|
|
341
509
|
}).entries
|
|
342
510
|
});
|
|
343
511
|
|
|
344
512
|
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
345
|
-
import * as
|
|
513
|
+
import * as v11 from "valibot";
|
|
346
514
|
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
347
|
-
var stxSignStructuredMessageParamsSchema =
|
|
515
|
+
var stxSignStructuredMessageParamsSchema = v11.object({
|
|
348
516
|
/**
|
|
349
517
|
* The domain to be signed.
|
|
350
518
|
*/
|
|
351
|
-
domain:
|
|
519
|
+
domain: v11.string(),
|
|
352
520
|
/**
|
|
353
521
|
* Message payload to be signed.
|
|
354
522
|
*/
|
|
355
|
-
message:
|
|
523
|
+
message: v11.string(),
|
|
356
524
|
/**
|
|
357
525
|
* The format version of the parameter.
|
|
358
526
|
*/
|
|
359
|
-
parameterFormatVersion:
|
|
527
|
+
parameterFormatVersion: v11.optional(v11.number()),
|
|
360
528
|
/**
|
|
361
529
|
* The public key to sign the message with.
|
|
362
530
|
*/
|
|
363
|
-
publicKey:
|
|
531
|
+
publicKey: v11.optional(v11.string())
|
|
364
532
|
});
|
|
365
|
-
var stxSignStructuredMessageResultSchema =
|
|
533
|
+
var stxSignStructuredMessageResultSchema = v11.object({
|
|
366
534
|
/**
|
|
367
535
|
* Signature of the message.
|
|
368
536
|
*/
|
|
369
|
-
signature:
|
|
537
|
+
signature: v11.string(),
|
|
370
538
|
/**
|
|
371
539
|
* Public key as hex-encoded string.
|
|
372
540
|
*/
|
|
373
|
-
publicKey:
|
|
541
|
+
publicKey: v11.string()
|
|
374
542
|
});
|
|
375
|
-
var stxSignStructuredMessageRequestMessageSchema =
|
|
543
|
+
var stxSignStructuredMessageRequestMessageSchema = v11.object({
|
|
376
544
|
...rpcRequestMessageSchema.entries,
|
|
377
|
-
...
|
|
378
|
-
method:
|
|
545
|
+
...v11.object({
|
|
546
|
+
method: v11.literal(stxSignStructuredMessageMethodName),
|
|
379
547
|
params: stxSignStructuredMessageParamsSchema,
|
|
380
|
-
id:
|
|
548
|
+
id: v11.string()
|
|
381
549
|
}).entries
|
|
382
550
|
});
|
|
383
551
|
|
|
384
552
|
// src/request/types/stxMethods/signTransaction.ts
|
|
385
|
-
import * as
|
|
553
|
+
import * as v12 from "valibot";
|
|
386
554
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
387
|
-
var stxSignTransactionParamsSchema =
|
|
555
|
+
var stxSignTransactionParamsSchema = v12.object({
|
|
388
556
|
/**
|
|
389
557
|
* The transaction to sign as a hex-encoded string.
|
|
390
558
|
*/
|
|
391
|
-
transaction:
|
|
559
|
+
transaction: v12.string(),
|
|
392
560
|
/**
|
|
393
561
|
* The public key to sign the transaction with. The wallet may use any key
|
|
394
562
|
* when not provided.
|
|
395
563
|
*/
|
|
396
|
-
pubkey:
|
|
564
|
+
pubkey: v12.optional(v12.string()),
|
|
397
565
|
/**
|
|
398
566
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
399
567
|
*/
|
|
400
|
-
broadcast:
|
|
568
|
+
broadcast: v12.optional(v12.boolean())
|
|
401
569
|
});
|
|
402
|
-
var stxSignTransactionResultSchema =
|
|
570
|
+
var stxSignTransactionResultSchema = v12.object({
|
|
403
571
|
/**
|
|
404
572
|
* The signed transaction as a hex-encoded string.
|
|
405
573
|
*/
|
|
406
|
-
transaction:
|
|
574
|
+
transaction: v12.string()
|
|
407
575
|
});
|
|
408
|
-
var stxSignTransactionRequestMessageSchema =
|
|
576
|
+
var stxSignTransactionRequestMessageSchema = v12.object({
|
|
409
577
|
...rpcRequestMessageSchema.entries,
|
|
410
|
-
...
|
|
411
|
-
method:
|
|
578
|
+
...v12.object({
|
|
579
|
+
method: v12.literal(stxSignTransactionMethodName),
|
|
412
580
|
params: stxSignTransactionParamsSchema,
|
|
413
|
-
id:
|
|
581
|
+
id: v12.string()
|
|
414
582
|
}).entries
|
|
415
583
|
});
|
|
416
584
|
|
|
417
585
|
// src/request/types/stxMethods/signTransactions.ts
|
|
418
|
-
import * as
|
|
586
|
+
import * as v13 from "valibot";
|
|
419
587
|
var stxSignTransactionsMethodName = "stx_signTransactions";
|
|
420
|
-
var stxSignTransactionsParamsSchema =
|
|
588
|
+
var stxSignTransactionsParamsSchema = v13.object({
|
|
421
589
|
/**
|
|
422
590
|
* The transactions to sign as hex-encoded strings.
|
|
423
591
|
*/
|
|
424
|
-
transactions:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
592
|
+
transactions: v13.pipe(
|
|
593
|
+
v13.array(
|
|
594
|
+
v13.pipe(
|
|
595
|
+
v13.string(),
|
|
596
|
+
v13.check((hex) => {
|
|
429
597
|
return true;
|
|
430
598
|
}, "Invalid hex-encoded Stacks transaction.")
|
|
431
599
|
)
|
|
432
600
|
),
|
|
433
|
-
|
|
601
|
+
v13.minLength(1)
|
|
434
602
|
),
|
|
435
603
|
/**
|
|
436
604
|
* Whether the signed transactions should be broadcast after signing. Defaults
|
|
437
605
|
* to `true`.
|
|
438
606
|
*/
|
|
439
|
-
broadcast:
|
|
607
|
+
broadcast: v13.optional(v13.boolean())
|
|
440
608
|
});
|
|
441
|
-
var stxSignTransactionsResultSchema =
|
|
609
|
+
var stxSignTransactionsResultSchema = v13.object({
|
|
442
610
|
/**
|
|
443
611
|
* The signed transactions as hex-encoded strings, in the same order as in the
|
|
444
612
|
* sign request.
|
|
445
613
|
*/
|
|
446
|
-
transactions:
|
|
614
|
+
transactions: v13.array(v13.string())
|
|
447
615
|
});
|
|
448
|
-
var stxSignTransactionsRequestMessageSchema =
|
|
616
|
+
var stxSignTransactionsRequestMessageSchema = v13.object({
|
|
449
617
|
...rpcRequestMessageSchema.entries,
|
|
450
|
-
...
|
|
451
|
-
method:
|
|
618
|
+
...v13.object({
|
|
619
|
+
method: v13.literal(stxSignTransactionsMethodName),
|
|
452
620
|
params: stxSignTransactionsParamsSchema,
|
|
453
|
-
id:
|
|
621
|
+
id: v13.string()
|
|
454
622
|
}).entries
|
|
455
623
|
});
|
|
456
624
|
|
|
457
625
|
// src/request/types/stxMethods/transferStx.ts
|
|
458
|
-
import * as
|
|
626
|
+
import * as v14 from "valibot";
|
|
459
627
|
var stxTransferStxMethodName = "stx_transferStx";
|
|
460
|
-
var stxTransferStxParamsSchema =
|
|
628
|
+
var stxTransferStxParamsSchema = v14.object({
|
|
461
629
|
/**
|
|
462
630
|
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
463
631
|
* parseable by `BigInt` is acceptable.
|
|
@@ -470,23 +638,23 @@ var stxTransferStxParamsSchema = v12.object({
|
|
|
470
638
|
* const amount3 = '1234';
|
|
471
639
|
* ```
|
|
472
640
|
*/
|
|
473
|
-
amount:
|
|
641
|
+
amount: v14.union([v14.number(), v14.string()]),
|
|
474
642
|
/**
|
|
475
643
|
* The recipeint's principal.
|
|
476
644
|
*/
|
|
477
|
-
recipient:
|
|
645
|
+
recipient: v14.string(),
|
|
478
646
|
/**
|
|
479
647
|
* A string representing the memo.
|
|
480
648
|
*/
|
|
481
|
-
memo:
|
|
649
|
+
memo: v14.optional(v14.string()),
|
|
482
650
|
/**
|
|
483
651
|
* Version of parameter format.
|
|
484
652
|
*/
|
|
485
|
-
version:
|
|
653
|
+
version: v14.optional(v14.string()),
|
|
486
654
|
/**
|
|
487
655
|
* The mode of the post conditions.
|
|
488
656
|
*/
|
|
489
|
-
postConditionMode:
|
|
657
|
+
postConditionMode: v14.optional(v14.number()),
|
|
490
658
|
/**
|
|
491
659
|
* A hex-encoded string representing the post conditions.
|
|
492
660
|
*
|
|
@@ -499,89 +667,83 @@ var stxTransferStxParamsSchema = v12.object({
|
|
|
499
667
|
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
500
668
|
* ```
|
|
501
669
|
*/
|
|
502
|
-
postConditions:
|
|
670
|
+
postConditions: v14.optional(v14.array(v14.string())),
|
|
503
671
|
/**
|
|
504
672
|
* The public key to sign the transaction with. The wallet may use any key
|
|
505
673
|
* when not provided.
|
|
506
674
|
*/
|
|
507
|
-
pubkey:
|
|
675
|
+
pubkey: v14.optional(v14.string())
|
|
508
676
|
});
|
|
509
|
-
var stxTransferStxResultSchema =
|
|
677
|
+
var stxTransferStxResultSchema = v14.object({
|
|
510
678
|
/**
|
|
511
679
|
* The ID of the transaction.
|
|
512
680
|
*/
|
|
513
|
-
txid:
|
|
681
|
+
txid: v14.string(),
|
|
514
682
|
/**
|
|
515
683
|
* A Stacks transaction as a hex-encoded string.
|
|
516
684
|
*/
|
|
517
|
-
transaction:
|
|
685
|
+
transaction: v14.string()
|
|
518
686
|
});
|
|
519
|
-
var stxTransferStxRequestMessageSchema =
|
|
687
|
+
var stxTransferStxRequestMessageSchema = v14.object({
|
|
520
688
|
...rpcRequestMessageSchema.entries,
|
|
521
|
-
...
|
|
522
|
-
method:
|
|
689
|
+
...v14.object({
|
|
690
|
+
method: v14.literal(stxTransferStxMethodName),
|
|
523
691
|
params: stxTransferStxParamsSchema,
|
|
524
|
-
id:
|
|
692
|
+
id: v14.string()
|
|
525
693
|
}).entries
|
|
526
694
|
});
|
|
527
695
|
|
|
528
696
|
// 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
|
|
697
|
+
import * as v15 from "valibot";
|
|
537
698
|
var getInfoMethodName = "getInfo";
|
|
538
|
-
var getInfoParamsSchema =
|
|
539
|
-
var getInfoResultSchema =
|
|
699
|
+
var getInfoParamsSchema = v15.nullish(v15.null());
|
|
700
|
+
var getInfoResultSchema = v15.object({
|
|
540
701
|
/**
|
|
541
702
|
* Version of the wallet.
|
|
542
703
|
*/
|
|
543
|
-
version:
|
|
704
|
+
version: v15.string(),
|
|
544
705
|
/**
|
|
545
706
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
546
707
|
*/
|
|
547
|
-
methods:
|
|
708
|
+
methods: v15.optional(v15.array(v15.string())),
|
|
548
709
|
/**
|
|
549
710
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
550
711
|
*/
|
|
551
|
-
supports:
|
|
712
|
+
supports: v15.array(v15.string())
|
|
552
713
|
});
|
|
553
|
-
var getInfoRequestMessageSchema =
|
|
714
|
+
var getInfoRequestMessageSchema = v15.object({
|
|
554
715
|
...rpcRequestMessageSchema.entries,
|
|
555
|
-
...
|
|
556
|
-
method:
|
|
716
|
+
...v15.object({
|
|
717
|
+
method: v15.literal(getInfoMethodName),
|
|
557
718
|
params: getInfoParamsSchema,
|
|
558
|
-
id:
|
|
719
|
+
id: v15.string()
|
|
559
720
|
}).entries
|
|
560
721
|
});
|
|
561
722
|
var getAddressesMethodName = "getAddresses";
|
|
562
|
-
var getAddressesParamsSchema =
|
|
723
|
+
var getAddressesParamsSchema = v15.object({
|
|
563
724
|
/**
|
|
564
725
|
* The purposes for which to generate addresses. See
|
|
565
726
|
* {@linkcode AddressPurpose} for available purposes.
|
|
566
727
|
*/
|
|
567
|
-
purposes:
|
|
728
|
+
purposes: v15.array(v15.enum(AddressPurpose)),
|
|
568
729
|
/**
|
|
569
730
|
* A message to be displayed to the user in the request prompt.
|
|
570
731
|
*/
|
|
571
|
-
message:
|
|
732
|
+
message: v15.optional(v15.string())
|
|
572
733
|
});
|
|
573
|
-
var getAddressesResultSchema =
|
|
734
|
+
var getAddressesResultSchema = v15.object({
|
|
574
735
|
/**
|
|
575
736
|
* The addresses generated for the given purposes.
|
|
576
737
|
*/
|
|
577
|
-
addresses:
|
|
738
|
+
addresses: v15.array(addressSchema),
|
|
739
|
+
network: getNetworkResultSchema
|
|
578
740
|
});
|
|
579
|
-
var getAddressesRequestMessageSchema =
|
|
741
|
+
var getAddressesRequestMessageSchema = v15.object({
|
|
580
742
|
...rpcRequestMessageSchema.entries,
|
|
581
|
-
...
|
|
582
|
-
method:
|
|
743
|
+
...v15.object({
|
|
744
|
+
method: v15.literal(getAddressesMethodName),
|
|
583
745
|
params: getAddressesParamsSchema,
|
|
584
|
-
id:
|
|
746
|
+
id: v15.string()
|
|
585
747
|
}).entries
|
|
586
748
|
});
|
|
587
749
|
var signMessageMethodName = "signMessage";
|
|
@@ -590,306 +752,162 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
|
|
|
590
752
|
MessageSigningProtocols2["BIP322"] = "BIP322";
|
|
591
753
|
return MessageSigningProtocols2;
|
|
592
754
|
})(MessageSigningProtocols || {});
|
|
593
|
-
var signMessageParamsSchema =
|
|
755
|
+
var signMessageParamsSchema = v15.object({
|
|
594
756
|
/**
|
|
595
757
|
* The address used for signing.
|
|
596
758
|
**/
|
|
597
|
-
address:
|
|
759
|
+
address: v15.string(),
|
|
598
760
|
/**
|
|
599
761
|
* The message to sign.
|
|
600
762
|
**/
|
|
601
|
-
message:
|
|
763
|
+
message: v15.string(),
|
|
602
764
|
/**
|
|
603
765
|
* The protocol to use for signing the message.
|
|
604
766
|
*/
|
|
605
|
-
protocol:
|
|
767
|
+
protocol: v15.optional(v15.enum(MessageSigningProtocols))
|
|
606
768
|
});
|
|
607
|
-
var signMessageResultSchema =
|
|
769
|
+
var signMessageResultSchema = v15.object({
|
|
608
770
|
/**
|
|
609
771
|
* The signature of the message.
|
|
610
772
|
*/
|
|
611
|
-
signature:
|
|
773
|
+
signature: v15.string(),
|
|
612
774
|
/**
|
|
613
775
|
* hash of the message.
|
|
614
776
|
*/
|
|
615
|
-
messageHash:
|
|
777
|
+
messageHash: v15.string(),
|
|
616
778
|
/**
|
|
617
779
|
* The address used for signing.
|
|
618
780
|
*/
|
|
619
|
-
address:
|
|
781
|
+
address: v15.string(),
|
|
620
782
|
/**
|
|
621
783
|
* The protocol to use for signing the message.
|
|
622
784
|
*/
|
|
623
|
-
protocol:
|
|
785
|
+
protocol: v15.enum(MessageSigningProtocols)
|
|
624
786
|
});
|
|
625
|
-
var signMessageRequestMessageSchema =
|
|
787
|
+
var signMessageRequestMessageSchema = v15.object({
|
|
626
788
|
...rpcRequestMessageSchema.entries,
|
|
627
|
-
...
|
|
628
|
-
method:
|
|
789
|
+
...v15.object({
|
|
790
|
+
method: v15.literal(signMessageMethodName),
|
|
629
791
|
params: signMessageParamsSchema,
|
|
630
|
-
id:
|
|
792
|
+
id: v15.string()
|
|
631
793
|
}).entries
|
|
632
794
|
});
|
|
633
795
|
var sendTransferMethodName = "sendTransfer";
|
|
634
|
-
var sendTransferParamsSchema =
|
|
796
|
+
var sendTransferParamsSchema = v15.object({
|
|
635
797
|
/**
|
|
636
798
|
* Array of recipients to send to.
|
|
637
799
|
* The amount to send to each recipient is in satoshis.
|
|
638
800
|
*/
|
|
639
|
-
recipients:
|
|
640
|
-
|
|
641
|
-
address:
|
|
642
|
-
amount:
|
|
801
|
+
recipients: v15.array(
|
|
802
|
+
v15.object({
|
|
803
|
+
address: v15.string(),
|
|
804
|
+
amount: v15.number()
|
|
643
805
|
})
|
|
644
806
|
)
|
|
645
807
|
});
|
|
646
|
-
var sendTransferResultSchema =
|
|
808
|
+
var sendTransferResultSchema = v15.object({
|
|
647
809
|
/**
|
|
648
810
|
* The transaction id as a hex-encoded string.
|
|
649
811
|
*/
|
|
650
|
-
txid:
|
|
812
|
+
txid: v15.string()
|
|
651
813
|
});
|
|
652
|
-
var sendTransferRequestMessageSchema =
|
|
814
|
+
var sendTransferRequestMessageSchema = v15.object({
|
|
653
815
|
...rpcRequestMessageSchema.entries,
|
|
654
|
-
...
|
|
655
|
-
method:
|
|
816
|
+
...v15.object({
|
|
817
|
+
method: v15.literal(sendTransferMethodName),
|
|
656
818
|
params: sendTransferParamsSchema,
|
|
657
|
-
id:
|
|
819
|
+
id: v15.string()
|
|
658
820
|
}).entries
|
|
659
821
|
});
|
|
660
822
|
var signPsbtMethodName = "signPsbt";
|
|
661
|
-
var signPsbtParamsSchema =
|
|
823
|
+
var signPsbtParamsSchema = v15.object({
|
|
662
824
|
/**
|
|
663
825
|
* The base64 encoded PSBT to sign.
|
|
664
826
|
*/
|
|
665
|
-
psbt:
|
|
827
|
+
psbt: v15.string(),
|
|
666
828
|
/**
|
|
667
829
|
* The inputs to sign.
|
|
668
830
|
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
669
831
|
*/
|
|
670
|
-
signInputs:
|
|
832
|
+
signInputs: v15.record(v15.string(), v15.array(v15.number())),
|
|
671
833
|
/**
|
|
672
834
|
* Whether to broadcast the transaction after signing.
|
|
673
835
|
**/
|
|
674
|
-
broadcast:
|
|
836
|
+
broadcast: v15.optional(v15.boolean())
|
|
675
837
|
});
|
|
676
|
-
var signPsbtResultSchema =
|
|
838
|
+
var signPsbtResultSchema = v15.object({
|
|
677
839
|
/**
|
|
678
840
|
* The base64 encoded PSBT after signing.
|
|
679
841
|
*/
|
|
680
|
-
psbt:
|
|
842
|
+
psbt: v15.string(),
|
|
681
843
|
/**
|
|
682
844
|
* The transaction id as a hex-encoded string.
|
|
683
845
|
* This is only returned if the transaction was broadcast.
|
|
684
846
|
**/
|
|
685
|
-
txid:
|
|
847
|
+
txid: v15.optional(v15.string())
|
|
686
848
|
});
|
|
687
|
-
var signPsbtRequestMessageSchema =
|
|
849
|
+
var signPsbtRequestMessageSchema = v15.object({
|
|
688
850
|
...rpcRequestMessageSchema.entries,
|
|
689
|
-
...
|
|
690
|
-
method:
|
|
851
|
+
...v15.object({
|
|
852
|
+
method: v15.literal(signPsbtMethodName),
|
|
691
853
|
params: signPsbtParamsSchema,
|
|
692
|
-
id:
|
|
854
|
+
id: v15.string()
|
|
693
855
|
}).entries
|
|
694
856
|
});
|
|
695
857
|
var getAccountsMethodName = "getAccounts";
|
|
696
|
-
var getAccountsParamsSchema =
|
|
858
|
+
var getAccountsParamsSchema = v15.object({
|
|
697
859
|
/**
|
|
698
860
|
* The purposes for which to generate addresses. See
|
|
699
861
|
* {@linkcode AddressPurpose} for available purposes.
|
|
700
862
|
*/
|
|
701
|
-
purposes:
|
|
863
|
+
purposes: v15.array(v15.enum(AddressPurpose)),
|
|
702
864
|
/**
|
|
703
865
|
* A message to be displayed to the user in the request prompt.
|
|
704
866
|
*/
|
|
705
|
-
message:
|
|
867
|
+
message: v15.optional(v15.string())
|
|
706
868
|
});
|
|
707
|
-
var getAccountsResultSchema =
|
|
708
|
-
|
|
869
|
+
var getAccountsResultSchema = v15.array(
|
|
870
|
+
v15.object({
|
|
709
871
|
...addressSchema.entries,
|
|
710
|
-
...
|
|
872
|
+
...v15.object({
|
|
711
873
|
walletType: walletTypeSchema
|
|
712
874
|
}).entries
|
|
713
875
|
})
|
|
714
876
|
);
|
|
715
|
-
var getAccountsRequestMessageSchema =
|
|
877
|
+
var getAccountsRequestMessageSchema = v15.object({
|
|
716
878
|
...rpcRequestMessageSchema.entries,
|
|
717
|
-
...
|
|
718
|
-
method:
|
|
879
|
+
...v15.object({
|
|
880
|
+
method: v15.literal(getAccountsMethodName),
|
|
719
881
|
params: getAccountsParamsSchema,
|
|
720
|
-
id:
|
|
882
|
+
id: v15.string()
|
|
721
883
|
}).entries
|
|
722
884
|
});
|
|
723
885
|
var getBalanceMethodName = "getBalance";
|
|
724
|
-
var getBalanceParamsSchema =
|
|
725
|
-
var getBalanceResultSchema =
|
|
886
|
+
var getBalanceParamsSchema = v15.nullish(v15.null());
|
|
887
|
+
var getBalanceResultSchema = v15.object({
|
|
726
888
|
/**
|
|
727
889
|
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
728
890
|
* messages not supporting bigint
|
|
729
891
|
* (https://issues.chromium.org/issues/40116184).
|
|
730
892
|
*/
|
|
731
|
-
confirmed:
|
|
893
|
+
confirmed: v15.string(),
|
|
732
894
|
/**
|
|
733
895
|
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
734
896
|
* messages not supporting bigint
|
|
735
897
|
* (https://issues.chromium.org/issues/40116184).
|
|
736
898
|
*/
|
|
737
|
-
unconfirmed:
|
|
899
|
+
unconfirmed: v15.string(),
|
|
738
900
|
/**
|
|
739
901
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
740
902
|
* sats. Using a string due to chrome messages not supporting bigint
|
|
741
903
|
* (https://issues.chromium.org/issues/40116184).
|
|
742
904
|
*/
|
|
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())
|
|
905
|
+
total: v15.string()
|
|
757
906
|
});
|
|
758
|
-
var
|
|
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({
|
|
907
|
+
var getBalanceRequestMessageSchema = v15.object({
|
|
819
908
|
...rpcRequestMessageSchema.entries,
|
|
820
909
|
...v15.object({
|
|
821
|
-
method: v15.literal(
|
|
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 getNetworkMethodName = "wallet_getNetwork";
|
|
838
|
-
var getNetworkParamsSchema = v15.nullish(v15.null());
|
|
839
|
-
var networkType2 = ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"];
|
|
840
|
-
var getNetworkResultSchema = v15.object({
|
|
841
|
-
bitcoin: v15.object({
|
|
842
|
-
name: v15.picklist(networkType2)
|
|
843
|
-
}),
|
|
844
|
-
stacks: v15.object({
|
|
845
|
-
name: v15.string()
|
|
846
|
-
})
|
|
847
|
-
});
|
|
848
|
-
var getNetworkRequestMessageSchema = v15.object({
|
|
849
|
-
...rpcRequestMessageSchema.entries,
|
|
850
|
-
...v15.object({
|
|
851
|
-
method: v15.literal(getNetworkMethodName),
|
|
852
|
-
params: getNetworkParamsSchema,
|
|
853
|
-
id: v15.string()
|
|
854
|
-
}).entries
|
|
855
|
-
});
|
|
856
|
-
var getAccountMethodName = "wallet_getAccount";
|
|
857
|
-
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
858
|
-
var getAccountResultSchema = v15.object({
|
|
859
|
-
id: v15.string(),
|
|
860
|
-
addresses: v15.array(addressSchema),
|
|
861
|
-
walletType: walletTypeSchema,
|
|
862
|
-
network: getNetworkResultSchema
|
|
863
|
-
});
|
|
864
|
-
var getAccountRequestMessageSchema = v15.object({
|
|
865
|
-
...rpcRequestMessageSchema.entries,
|
|
866
|
-
...v15.object({
|
|
867
|
-
method: v15.literal(getAccountMethodName),
|
|
868
|
-
params: getAccountParamsSchema,
|
|
869
|
-
id: v15.string()
|
|
870
|
-
}).entries
|
|
871
|
-
});
|
|
872
|
-
var connectMethodName = "wallet_connect";
|
|
873
|
-
var connectParamsSchema = v15.nullish(
|
|
874
|
-
v15.object({
|
|
875
|
-
permissions: v15.optional(v15.array(PermissionRequestParams)),
|
|
876
|
-
addresses: v15.optional(v15.array(v15.enum(AddressPurpose))),
|
|
877
|
-
message: v15.optional(
|
|
878
|
-
v15.pipe(v15.string(), v15.maxLength(80, "The message must not exceed 80 characters."))
|
|
879
|
-
)
|
|
880
|
-
})
|
|
881
|
-
);
|
|
882
|
-
var connectResultSchema = v15.object({
|
|
883
|
-
id: v15.string(),
|
|
884
|
-
addresses: v15.array(addressSchema),
|
|
885
|
-
walletType: walletTypeSchema,
|
|
886
|
-
network: getNetworkResultSchema
|
|
887
|
-
});
|
|
888
|
-
var connectRequestMessageSchema = v15.object({
|
|
889
|
-
...rpcRequestMessageSchema.entries,
|
|
890
|
-
...v15.object({
|
|
891
|
-
method: v15.literal(connectMethodName),
|
|
892
|
-
params: connectParamsSchema,
|
|
910
|
+
method: v15.literal(getBalanceMethodName),
|
|
893
911
|
id: v15.string()
|
|
894
912
|
}).entries
|
|
895
913
|
});
|
|
@@ -2093,6 +2111,10 @@ export {
|
|
|
2093
2111
|
accountPermissionSchema,
|
|
2094
2112
|
addListener,
|
|
2095
2113
|
addressSchema,
|
|
2114
|
+
changeNetworkMethodName,
|
|
2115
|
+
changeNetworkParamsSchema,
|
|
2116
|
+
changeNetworkRequestMessageSchema,
|
|
2117
|
+
changeNetworkResultSchema,
|
|
2096
2118
|
connectMethodName,
|
|
2097
2119
|
connectParamsSchema,
|
|
2098
2120
|
connectRequestMessageSchema,
|