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