@sats-connect/core 0.6.4 → 0.6.5-e7f85ed
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 +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +76 -73
- package/dist/index.mjs +76 -73
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -150,6 +150,13 @@ declare const networkChangeSchema: v.ObjectSchema<{
|
|
|
150
150
|
readonly stacks: v.ObjectSchema<{
|
|
151
151
|
readonly name: v.StringSchema<undefined>;
|
|
152
152
|
}, undefined>;
|
|
153
|
+
readonly addresses: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
154
|
+
readonly address: v.StringSchema<undefined>;
|
|
155
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
156
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
157
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
158
|
+
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
159
|
+
}, undefined>, undefined>, never>;
|
|
153
160
|
}, undefined>;
|
|
154
161
|
type NetworkChangeEvent = v.InferOutput<typeof networkChangeSchema>;
|
|
155
162
|
declare const disconnectEventName = "disconnect";
|
|
@@ -174,6 +181,13 @@ declare const walletEventSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
|
174
181
|
readonly stacks: v.ObjectSchema<{
|
|
175
182
|
readonly name: v.StringSchema<undefined>;
|
|
176
183
|
}, undefined>;
|
|
184
|
+
readonly addresses: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
185
|
+
readonly address: v.StringSchema<undefined>;
|
|
186
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
187
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
188
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
189
|
+
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
190
|
+
}, undefined>, undefined>, never>;
|
|
177
191
|
}, undefined>, v.ObjectSchema<{
|
|
178
192
|
readonly type: v.LiteralSchema<"disconnect", undefined>;
|
|
179
193
|
}, undefined>], undefined>;
|
|
@@ -399,7 +413,9 @@ declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
|
399
413
|
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
400
414
|
readonly address: v.StringSchema<undefined>;
|
|
401
415
|
readonly publicKey: v.StringSchema<undefined>;
|
|
402
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
416
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>; /**
|
|
417
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
418
|
+
*/
|
|
403
419
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
404
420
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
405
421
|
}, undefined>, undefined>;
|
|
@@ -595,7 +611,9 @@ declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
595
611
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
596
612
|
readonly address: v.StringSchema<undefined>;
|
|
597
613
|
readonly publicKey: v.StringSchema<undefined>;
|
|
598
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
614
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>; /**
|
|
615
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
616
|
+
*/
|
|
599
617
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
600
618
|
}, undefined>, undefined>;
|
|
601
619
|
type GetAccountsResult = v.InferOutput<typeof getAccountsResultSchema>;
|
package/dist/index.d.ts
CHANGED
|
@@ -150,6 +150,13 @@ declare const networkChangeSchema: v.ObjectSchema<{
|
|
|
150
150
|
readonly stacks: v.ObjectSchema<{
|
|
151
151
|
readonly name: v.StringSchema<undefined>;
|
|
152
152
|
}, undefined>;
|
|
153
|
+
readonly addresses: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
154
|
+
readonly address: v.StringSchema<undefined>;
|
|
155
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
156
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
157
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
158
|
+
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
159
|
+
}, undefined>, undefined>, never>;
|
|
153
160
|
}, undefined>;
|
|
154
161
|
type NetworkChangeEvent = v.InferOutput<typeof networkChangeSchema>;
|
|
155
162
|
declare const disconnectEventName = "disconnect";
|
|
@@ -174,6 +181,13 @@ declare const walletEventSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
|
174
181
|
readonly stacks: v.ObjectSchema<{
|
|
175
182
|
readonly name: v.StringSchema<undefined>;
|
|
176
183
|
}, undefined>;
|
|
184
|
+
readonly addresses: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
185
|
+
readonly address: v.StringSchema<undefined>;
|
|
186
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
187
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
188
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
189
|
+
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
190
|
+
}, undefined>, undefined>, never>;
|
|
177
191
|
}, undefined>, v.ObjectSchema<{
|
|
178
192
|
readonly type: v.LiteralSchema<"disconnect", undefined>;
|
|
179
193
|
}, undefined>], undefined>;
|
|
@@ -399,7 +413,9 @@ declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
|
399
413
|
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
400
414
|
readonly address: v.StringSchema<undefined>;
|
|
401
415
|
readonly publicKey: v.StringSchema<undefined>;
|
|
402
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
416
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>; /**
|
|
417
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
418
|
+
*/
|
|
403
419
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
404
420
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
405
421
|
}, undefined>, undefined>;
|
|
@@ -595,7 +611,9 @@ declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
595
611
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
596
612
|
readonly address: v.StringSchema<undefined>;
|
|
597
613
|
readonly publicKey: v.StringSchema<undefined>;
|
|
598
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
614
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>; /**
|
|
615
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
616
|
+
*/
|
|
599
617
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
600
618
|
}, undefined>, undefined>;
|
|
601
619
|
type GetAccountsResult = v.InferOutput<typeof getAccountsResultSchema>;
|
package/dist/index.js
CHANGED
|
@@ -205,11 +205,21 @@ __export(src_exports, {
|
|
|
205
205
|
});
|
|
206
206
|
module.exports = __toCommonJS(src_exports);
|
|
207
207
|
|
|
208
|
+
// src/provider/types.ts
|
|
209
|
+
var v4 = __toESM(require("valibot"));
|
|
210
|
+
|
|
208
211
|
// src/addresses/index.ts
|
|
209
212
|
var import_jsontokens = require("jsontokens");
|
|
210
213
|
|
|
211
214
|
// src/addresses/types.ts
|
|
215
|
+
var v2 = __toESM(require("valibot"));
|
|
216
|
+
|
|
217
|
+
// src/request/types/common.ts
|
|
212
218
|
var v = __toESM(require("valibot"));
|
|
219
|
+
var walletTypes = ["software", "ledger", "keystone"];
|
|
220
|
+
var walletTypeSchema = v.picklist(walletTypes);
|
|
221
|
+
|
|
222
|
+
// src/addresses/types.ts
|
|
213
223
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
214
224
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
215
225
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -225,11 +235,11 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
225
235
|
AddressType3["stacks"] = "stacks";
|
|
226
236
|
return AddressType3;
|
|
227
237
|
})(AddressType || {});
|
|
228
|
-
var addressSchema =
|
|
229
|
-
address:
|
|
230
|
-
publicKey:
|
|
231
|
-
purpose:
|
|
232
|
-
addressType:
|
|
238
|
+
var addressSchema = v2.object({
|
|
239
|
+
address: v2.string(),
|
|
240
|
+
publicKey: v2.string(),
|
|
241
|
+
purpose: v2.enum(AddressPurpose),
|
|
242
|
+
addressType: v2.enum(AddressType),
|
|
233
243
|
walletType: walletTypeSchema
|
|
234
244
|
});
|
|
235
245
|
|
|
@@ -251,7 +261,7 @@ var getAddress = async (options) => {
|
|
|
251
261
|
};
|
|
252
262
|
|
|
253
263
|
// src/types.ts
|
|
254
|
-
var
|
|
264
|
+
var v3 = __toESM(require("valibot"));
|
|
255
265
|
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
256
266
|
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
257
267
|
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
@@ -260,22 +270,22 @@ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
|
260
270
|
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
261
271
|
return BitcoinNetworkType2;
|
|
262
272
|
})(BitcoinNetworkType || {});
|
|
263
|
-
var RpcIdSchema =
|
|
264
|
-
var rpcRequestMessageSchema =
|
|
265
|
-
jsonrpc:
|
|
266
|
-
method:
|
|
267
|
-
params:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
273
|
+
var RpcIdSchema = v3.optional(v3.union([v3.string(), v3.number(), v3.null()]));
|
|
274
|
+
var rpcRequestMessageSchema = v3.object({
|
|
275
|
+
jsonrpc: v3.literal("2.0"),
|
|
276
|
+
method: v3.string(),
|
|
277
|
+
params: v3.optional(
|
|
278
|
+
v3.union([
|
|
279
|
+
v3.array(v3.unknown()),
|
|
280
|
+
v3.looseObject({}),
|
|
271
281
|
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
272
282
|
// to be either an array or an object when provided. Changing this now would
|
|
273
283
|
// be a breaking change, so accepting null values for now. Tracking in
|
|
274
284
|
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
275
|
-
|
|
285
|
+
v3.null()
|
|
276
286
|
])
|
|
277
287
|
),
|
|
278
|
-
id:
|
|
288
|
+
id: v3.unwrap(RpcIdSchema)
|
|
279
289
|
});
|
|
280
290
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
281
291
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -288,43 +298,43 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
288
298
|
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
289
299
|
return RpcErrorCode2;
|
|
290
300
|
})(RpcErrorCode || {});
|
|
291
|
-
var rpcSuccessResponseMessageSchema =
|
|
292
|
-
jsonrpc:
|
|
293
|
-
result:
|
|
301
|
+
var rpcSuccessResponseMessageSchema = v3.object({
|
|
302
|
+
jsonrpc: v3.literal("2.0"),
|
|
303
|
+
result: v3.nonOptional(v3.unknown()),
|
|
294
304
|
id: RpcIdSchema
|
|
295
305
|
});
|
|
296
|
-
var rpcErrorResponseMessageSchema =
|
|
297
|
-
jsonrpc:
|
|
298
|
-
error:
|
|
306
|
+
var rpcErrorResponseMessageSchema = v3.object({
|
|
307
|
+
jsonrpc: v3.literal("2.0"),
|
|
308
|
+
error: v3.nonOptional(v3.unknown()),
|
|
299
309
|
id: RpcIdSchema
|
|
300
310
|
});
|
|
301
|
-
var rpcResponseMessageSchema =
|
|
311
|
+
var rpcResponseMessageSchema = v3.union([
|
|
302
312
|
rpcSuccessResponseMessageSchema,
|
|
303
313
|
rpcErrorResponseMessageSchema
|
|
304
314
|
]);
|
|
305
315
|
|
|
306
316
|
// src/provider/types.ts
|
|
307
|
-
var v3 = __toESM(require("valibot"));
|
|
308
317
|
var accountChangeEventName = "accountChange";
|
|
309
|
-
var accountChangeSchema =
|
|
310
|
-
type:
|
|
311
|
-
addresses:
|
|
318
|
+
var accountChangeSchema = v4.object({
|
|
319
|
+
type: v4.literal(accountChangeEventName),
|
|
320
|
+
addresses: v4.optional(v4.array(addressSchema))
|
|
312
321
|
});
|
|
313
322
|
var networkChangeEventName = "networkChange";
|
|
314
|
-
var networkChangeSchema =
|
|
315
|
-
type:
|
|
316
|
-
bitcoin:
|
|
317
|
-
name:
|
|
323
|
+
var networkChangeSchema = v4.object({
|
|
324
|
+
type: v4.literal(networkChangeEventName),
|
|
325
|
+
bitcoin: v4.object({
|
|
326
|
+
name: v4.enum(BitcoinNetworkType)
|
|
318
327
|
}),
|
|
319
|
-
stacks:
|
|
320
|
-
name:
|
|
321
|
-
})
|
|
328
|
+
stacks: v4.object({
|
|
329
|
+
name: v4.string()
|
|
330
|
+
}),
|
|
331
|
+
addresses: v4.optional(v4.array(addressSchema))
|
|
322
332
|
});
|
|
323
333
|
var disconnectEventName = "disconnect";
|
|
324
|
-
var disconnectSchema =
|
|
325
|
-
type:
|
|
334
|
+
var disconnectSchema = v4.object({
|
|
335
|
+
type: v4.literal(disconnectEventName)
|
|
326
336
|
});
|
|
327
|
-
var walletEventSchema =
|
|
337
|
+
var walletEventSchema = v4.variant("type", [
|
|
328
338
|
accountChangeSchema,
|
|
329
339
|
networkChangeSchema,
|
|
330
340
|
disconnectSchema
|
|
@@ -373,26 +383,26 @@ function getSupportedWallets() {
|
|
|
373
383
|
var v21 = __toESM(require("valibot"));
|
|
374
384
|
|
|
375
385
|
// src/request/types/stxMethods/callContract.ts
|
|
376
|
-
var
|
|
386
|
+
var v5 = __toESM(require("valibot"));
|
|
377
387
|
var stxCallContractMethodName = "stx_callContract";
|
|
378
|
-
var stxCallContractParamsSchema =
|
|
388
|
+
var stxCallContractParamsSchema = v5.object({
|
|
379
389
|
/**
|
|
380
390
|
* The contract principal.
|
|
381
391
|
*
|
|
382
392
|
* E.g. `"SPKE...GD5C.my-contract"`
|
|
383
393
|
*/
|
|
384
|
-
contract:
|
|
394
|
+
contract: v5.string(),
|
|
385
395
|
/**
|
|
386
396
|
* The name of the function to call.
|
|
387
397
|
*
|
|
388
398
|
* Note: spec changes ongoing,
|
|
389
399
|
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
390
400
|
*/
|
|
391
|
-
functionName:
|
|
401
|
+
functionName: v5.string(),
|
|
392
402
|
/**
|
|
393
403
|
* @deprecated in favor of `functionArgs` for @stacks/connect compatibility
|
|
394
404
|
*/
|
|
395
|
-
arguments:
|
|
405
|
+
arguments: v5.optional(v5.array(v5.string())),
|
|
396
406
|
/**
|
|
397
407
|
* The function's arguments. The arguments are expected to be hex-encoded
|
|
398
408
|
* strings of Clarity values.
|
|
@@ -407,76 +417,76 @@ var stxCallContractParamsSchema = v4.object({
|
|
|
407
417
|
* const hexArgs = functionArgs.map(cvToHex);
|
|
408
418
|
* ```
|
|
409
419
|
*/
|
|
410
|
-
functionArgs:
|
|
420
|
+
functionArgs: v5.optional(v5.array(v5.string())),
|
|
411
421
|
/**
|
|
412
422
|
* The post conditions to apply to the contract call.
|
|
413
423
|
*/
|
|
414
|
-
postConditions:
|
|
424
|
+
postConditions: v5.optional(v5.array(v5.string())),
|
|
415
425
|
/**
|
|
416
426
|
* The mode to apply to the post conditions.
|
|
417
427
|
*/
|
|
418
|
-
postConditionMode:
|
|
428
|
+
postConditionMode: v5.optional(v5.union([v5.literal("allow"), v5.literal("deny")]))
|
|
419
429
|
});
|
|
420
|
-
var stxCallContractResultSchema =
|
|
430
|
+
var stxCallContractResultSchema = v5.object({
|
|
421
431
|
/**
|
|
422
432
|
* The ID of the transaction.
|
|
423
433
|
*/
|
|
424
|
-
txid:
|
|
434
|
+
txid: v5.string(),
|
|
425
435
|
/**
|
|
426
436
|
* A Stacks transaction as a hex-encoded string.
|
|
427
437
|
*/
|
|
428
|
-
transaction:
|
|
438
|
+
transaction: v5.string()
|
|
429
439
|
});
|
|
430
|
-
var stxCallContractRequestMessageSchema =
|
|
440
|
+
var stxCallContractRequestMessageSchema = v5.object({
|
|
431
441
|
...rpcRequestMessageSchema.entries,
|
|
432
|
-
...
|
|
433
|
-
method:
|
|
442
|
+
...v5.object({
|
|
443
|
+
method: v5.literal(stxCallContractMethodName),
|
|
434
444
|
params: stxCallContractParamsSchema,
|
|
435
|
-
id:
|
|
445
|
+
id: v5.string()
|
|
436
446
|
}).entries
|
|
437
447
|
});
|
|
438
448
|
|
|
439
449
|
// src/request/types/stxMethods/deployContract.ts
|
|
440
|
-
var
|
|
450
|
+
var v6 = __toESM(require("valibot"));
|
|
441
451
|
var stxDeployContractMethodName = "stx_deployContract";
|
|
442
|
-
var stxDeployContractParamsSchema =
|
|
452
|
+
var stxDeployContractParamsSchema = v6.object({
|
|
443
453
|
/**
|
|
444
454
|
* Name of the contract.
|
|
445
455
|
*/
|
|
446
|
-
name:
|
|
456
|
+
name: v6.string(),
|
|
447
457
|
/**
|
|
448
458
|
* The source code of the Clarity contract.
|
|
449
459
|
*/
|
|
450
|
-
clarityCode:
|
|
460
|
+
clarityCode: v6.string(),
|
|
451
461
|
/**
|
|
452
462
|
* The version of the Clarity contract.
|
|
453
463
|
*/
|
|
454
|
-
clarityVersion:
|
|
464
|
+
clarityVersion: v6.optional(v6.string()),
|
|
455
465
|
/**
|
|
456
466
|
* The post conditions to apply to the contract call.
|
|
457
467
|
*/
|
|
458
|
-
postConditions:
|
|
468
|
+
postConditions: v6.optional(v6.array(v6.string())),
|
|
459
469
|
/**
|
|
460
470
|
* The mode to apply to the post conditions.
|
|
461
471
|
*/
|
|
462
|
-
postConditionMode:
|
|
472
|
+
postConditionMode: v6.optional(v6.union([v6.literal("allow"), v6.literal("deny")]))
|
|
463
473
|
});
|
|
464
|
-
var stxDeployContractResultSchema =
|
|
474
|
+
var stxDeployContractResultSchema = v6.object({
|
|
465
475
|
/**
|
|
466
476
|
* The ID of the transaction.
|
|
467
477
|
*/
|
|
468
|
-
txid:
|
|
478
|
+
txid: v6.string(),
|
|
469
479
|
/**
|
|
470
480
|
* A Stacks transaction as a hex-encoded string.
|
|
471
481
|
*/
|
|
472
|
-
transaction:
|
|
482
|
+
transaction: v6.string()
|
|
473
483
|
});
|
|
474
|
-
var stxDeployContractRequestMessageSchema =
|
|
484
|
+
var stxDeployContractRequestMessageSchema = v6.object({
|
|
475
485
|
...rpcRequestMessageSchema.entries,
|
|
476
|
-
...
|
|
477
|
-
method:
|
|
486
|
+
...v6.object({
|
|
487
|
+
method: v6.literal(stxDeployContractMethodName),
|
|
478
488
|
params: stxDeployContractParamsSchema,
|
|
479
|
-
id:
|
|
489
|
+
id: v6.string()
|
|
480
490
|
}).entries
|
|
481
491
|
});
|
|
482
492
|
|
|
@@ -485,13 +495,6 @@ var v8 = __toESM(require("valibot"));
|
|
|
485
495
|
|
|
486
496
|
// src/request/types/walletMethods.ts
|
|
487
497
|
var v7 = __toESM(require("valibot"));
|
|
488
|
-
|
|
489
|
-
// src/request/types/common.ts
|
|
490
|
-
var v6 = __toESM(require("valibot"));
|
|
491
|
-
var walletTypes = ["software", "ledger", "keystone"];
|
|
492
|
-
var walletTypeSchema = v6.picklist(walletTypes);
|
|
493
|
-
|
|
494
|
-
// src/request/types/walletMethods.ts
|
|
495
498
|
var accountActionsSchema = v7.object({
|
|
496
499
|
read: v7.optional(v7.boolean())
|
|
497
500
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
// src/provider/types.ts
|
|
2
|
+
import * as v4 from "valibot";
|
|
3
|
+
|
|
1
4
|
// src/addresses/index.ts
|
|
2
5
|
import { createUnsecuredToken } from "jsontokens";
|
|
3
6
|
|
|
4
7
|
// src/addresses/types.ts
|
|
8
|
+
import * as v2 from "valibot";
|
|
9
|
+
|
|
10
|
+
// src/request/types/common.ts
|
|
5
11
|
import * as v from "valibot";
|
|
12
|
+
var walletTypes = ["software", "ledger", "keystone"];
|
|
13
|
+
var walletTypeSchema = v.picklist(walletTypes);
|
|
14
|
+
|
|
15
|
+
// src/addresses/types.ts
|
|
6
16
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
7
17
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
8
18
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -18,11 +28,11 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
18
28
|
AddressType3["stacks"] = "stacks";
|
|
19
29
|
return AddressType3;
|
|
20
30
|
})(AddressType || {});
|
|
21
|
-
var addressSchema =
|
|
22
|
-
address:
|
|
23
|
-
publicKey:
|
|
24
|
-
purpose:
|
|
25
|
-
addressType:
|
|
31
|
+
var addressSchema = v2.object({
|
|
32
|
+
address: v2.string(),
|
|
33
|
+
publicKey: v2.string(),
|
|
34
|
+
purpose: v2.enum(AddressPurpose),
|
|
35
|
+
addressType: v2.enum(AddressType),
|
|
26
36
|
walletType: walletTypeSchema
|
|
27
37
|
});
|
|
28
38
|
|
|
@@ -44,7 +54,7 @@ var getAddress = async (options) => {
|
|
|
44
54
|
};
|
|
45
55
|
|
|
46
56
|
// src/types.ts
|
|
47
|
-
import * as
|
|
57
|
+
import * as v3 from "valibot";
|
|
48
58
|
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
49
59
|
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
50
60
|
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
@@ -53,22 +63,22 @@ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
|
53
63
|
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
54
64
|
return BitcoinNetworkType2;
|
|
55
65
|
})(BitcoinNetworkType || {});
|
|
56
|
-
var RpcIdSchema =
|
|
57
|
-
var rpcRequestMessageSchema =
|
|
58
|
-
jsonrpc:
|
|
59
|
-
method:
|
|
60
|
-
params:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
var RpcIdSchema = v3.optional(v3.union([v3.string(), v3.number(), v3.null()]));
|
|
67
|
+
var rpcRequestMessageSchema = v3.object({
|
|
68
|
+
jsonrpc: v3.literal("2.0"),
|
|
69
|
+
method: v3.string(),
|
|
70
|
+
params: v3.optional(
|
|
71
|
+
v3.union([
|
|
72
|
+
v3.array(v3.unknown()),
|
|
73
|
+
v3.looseObject({}),
|
|
64
74
|
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
65
75
|
// to be either an array or an object when provided. Changing this now would
|
|
66
76
|
// be a breaking change, so accepting null values for now. Tracking in
|
|
67
77
|
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
68
|
-
|
|
78
|
+
v3.null()
|
|
69
79
|
])
|
|
70
80
|
),
|
|
71
|
-
id:
|
|
81
|
+
id: v3.unwrap(RpcIdSchema)
|
|
72
82
|
});
|
|
73
83
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
74
84
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -81,43 +91,43 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
81
91
|
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
82
92
|
return RpcErrorCode2;
|
|
83
93
|
})(RpcErrorCode || {});
|
|
84
|
-
var rpcSuccessResponseMessageSchema =
|
|
85
|
-
jsonrpc:
|
|
86
|
-
result:
|
|
94
|
+
var rpcSuccessResponseMessageSchema = v3.object({
|
|
95
|
+
jsonrpc: v3.literal("2.0"),
|
|
96
|
+
result: v3.nonOptional(v3.unknown()),
|
|
87
97
|
id: RpcIdSchema
|
|
88
98
|
});
|
|
89
|
-
var rpcErrorResponseMessageSchema =
|
|
90
|
-
jsonrpc:
|
|
91
|
-
error:
|
|
99
|
+
var rpcErrorResponseMessageSchema = v3.object({
|
|
100
|
+
jsonrpc: v3.literal("2.0"),
|
|
101
|
+
error: v3.nonOptional(v3.unknown()),
|
|
92
102
|
id: RpcIdSchema
|
|
93
103
|
});
|
|
94
|
-
var rpcResponseMessageSchema =
|
|
104
|
+
var rpcResponseMessageSchema = v3.union([
|
|
95
105
|
rpcSuccessResponseMessageSchema,
|
|
96
106
|
rpcErrorResponseMessageSchema
|
|
97
107
|
]);
|
|
98
108
|
|
|
99
109
|
// src/provider/types.ts
|
|
100
|
-
import * as v3 from "valibot";
|
|
101
110
|
var accountChangeEventName = "accountChange";
|
|
102
|
-
var accountChangeSchema =
|
|
103
|
-
type:
|
|
104
|
-
addresses:
|
|
111
|
+
var accountChangeSchema = v4.object({
|
|
112
|
+
type: v4.literal(accountChangeEventName),
|
|
113
|
+
addresses: v4.optional(v4.array(addressSchema))
|
|
105
114
|
});
|
|
106
115
|
var networkChangeEventName = "networkChange";
|
|
107
|
-
var networkChangeSchema =
|
|
108
|
-
type:
|
|
109
|
-
bitcoin:
|
|
110
|
-
name:
|
|
116
|
+
var networkChangeSchema = v4.object({
|
|
117
|
+
type: v4.literal(networkChangeEventName),
|
|
118
|
+
bitcoin: v4.object({
|
|
119
|
+
name: v4.enum(BitcoinNetworkType)
|
|
111
120
|
}),
|
|
112
|
-
stacks:
|
|
113
|
-
name:
|
|
114
|
-
})
|
|
121
|
+
stacks: v4.object({
|
|
122
|
+
name: v4.string()
|
|
123
|
+
}),
|
|
124
|
+
addresses: v4.optional(v4.array(addressSchema))
|
|
115
125
|
});
|
|
116
126
|
var disconnectEventName = "disconnect";
|
|
117
|
-
var disconnectSchema =
|
|
118
|
-
type:
|
|
127
|
+
var disconnectSchema = v4.object({
|
|
128
|
+
type: v4.literal(disconnectEventName)
|
|
119
129
|
});
|
|
120
|
-
var walletEventSchema =
|
|
130
|
+
var walletEventSchema = v4.variant("type", [
|
|
121
131
|
accountChangeSchema,
|
|
122
132
|
networkChangeSchema,
|
|
123
133
|
disconnectSchema
|
|
@@ -166,26 +176,26 @@ function getSupportedWallets() {
|
|
|
166
176
|
import * as v21 from "valibot";
|
|
167
177
|
|
|
168
178
|
// src/request/types/stxMethods/callContract.ts
|
|
169
|
-
import * as
|
|
179
|
+
import * as v5 from "valibot";
|
|
170
180
|
var stxCallContractMethodName = "stx_callContract";
|
|
171
|
-
var stxCallContractParamsSchema =
|
|
181
|
+
var stxCallContractParamsSchema = v5.object({
|
|
172
182
|
/**
|
|
173
183
|
* The contract principal.
|
|
174
184
|
*
|
|
175
185
|
* E.g. `"SPKE...GD5C.my-contract"`
|
|
176
186
|
*/
|
|
177
|
-
contract:
|
|
187
|
+
contract: v5.string(),
|
|
178
188
|
/**
|
|
179
189
|
* The name of the function to call.
|
|
180
190
|
*
|
|
181
191
|
* Note: spec changes ongoing,
|
|
182
192
|
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
183
193
|
*/
|
|
184
|
-
functionName:
|
|
194
|
+
functionName: v5.string(),
|
|
185
195
|
/**
|
|
186
196
|
* @deprecated in favor of `functionArgs` for @stacks/connect compatibility
|
|
187
197
|
*/
|
|
188
|
-
arguments:
|
|
198
|
+
arguments: v5.optional(v5.array(v5.string())),
|
|
189
199
|
/**
|
|
190
200
|
* The function's arguments. The arguments are expected to be hex-encoded
|
|
191
201
|
* strings of Clarity values.
|
|
@@ -200,76 +210,76 @@ var stxCallContractParamsSchema = v4.object({
|
|
|
200
210
|
* const hexArgs = functionArgs.map(cvToHex);
|
|
201
211
|
* ```
|
|
202
212
|
*/
|
|
203
|
-
functionArgs:
|
|
213
|
+
functionArgs: v5.optional(v5.array(v5.string())),
|
|
204
214
|
/**
|
|
205
215
|
* The post conditions to apply to the contract call.
|
|
206
216
|
*/
|
|
207
|
-
postConditions:
|
|
217
|
+
postConditions: v5.optional(v5.array(v5.string())),
|
|
208
218
|
/**
|
|
209
219
|
* The mode to apply to the post conditions.
|
|
210
220
|
*/
|
|
211
|
-
postConditionMode:
|
|
221
|
+
postConditionMode: v5.optional(v5.union([v5.literal("allow"), v5.literal("deny")]))
|
|
212
222
|
});
|
|
213
|
-
var stxCallContractResultSchema =
|
|
223
|
+
var stxCallContractResultSchema = v5.object({
|
|
214
224
|
/**
|
|
215
225
|
* The ID of the transaction.
|
|
216
226
|
*/
|
|
217
|
-
txid:
|
|
227
|
+
txid: v5.string(),
|
|
218
228
|
/**
|
|
219
229
|
* A Stacks transaction as a hex-encoded string.
|
|
220
230
|
*/
|
|
221
|
-
transaction:
|
|
231
|
+
transaction: v5.string()
|
|
222
232
|
});
|
|
223
|
-
var stxCallContractRequestMessageSchema =
|
|
233
|
+
var stxCallContractRequestMessageSchema = v5.object({
|
|
224
234
|
...rpcRequestMessageSchema.entries,
|
|
225
|
-
...
|
|
226
|
-
method:
|
|
235
|
+
...v5.object({
|
|
236
|
+
method: v5.literal(stxCallContractMethodName),
|
|
227
237
|
params: stxCallContractParamsSchema,
|
|
228
|
-
id:
|
|
238
|
+
id: v5.string()
|
|
229
239
|
}).entries
|
|
230
240
|
});
|
|
231
241
|
|
|
232
242
|
// src/request/types/stxMethods/deployContract.ts
|
|
233
|
-
import * as
|
|
243
|
+
import * as v6 from "valibot";
|
|
234
244
|
var stxDeployContractMethodName = "stx_deployContract";
|
|
235
|
-
var stxDeployContractParamsSchema =
|
|
245
|
+
var stxDeployContractParamsSchema = v6.object({
|
|
236
246
|
/**
|
|
237
247
|
* Name of the contract.
|
|
238
248
|
*/
|
|
239
|
-
name:
|
|
249
|
+
name: v6.string(),
|
|
240
250
|
/**
|
|
241
251
|
* The source code of the Clarity contract.
|
|
242
252
|
*/
|
|
243
|
-
clarityCode:
|
|
253
|
+
clarityCode: v6.string(),
|
|
244
254
|
/**
|
|
245
255
|
* The version of the Clarity contract.
|
|
246
256
|
*/
|
|
247
|
-
clarityVersion:
|
|
257
|
+
clarityVersion: v6.optional(v6.string()),
|
|
248
258
|
/**
|
|
249
259
|
* The post conditions to apply to the contract call.
|
|
250
260
|
*/
|
|
251
|
-
postConditions:
|
|
261
|
+
postConditions: v6.optional(v6.array(v6.string())),
|
|
252
262
|
/**
|
|
253
263
|
* The mode to apply to the post conditions.
|
|
254
264
|
*/
|
|
255
|
-
postConditionMode:
|
|
265
|
+
postConditionMode: v6.optional(v6.union([v6.literal("allow"), v6.literal("deny")]))
|
|
256
266
|
});
|
|
257
|
-
var stxDeployContractResultSchema =
|
|
267
|
+
var stxDeployContractResultSchema = v6.object({
|
|
258
268
|
/**
|
|
259
269
|
* The ID of the transaction.
|
|
260
270
|
*/
|
|
261
|
-
txid:
|
|
271
|
+
txid: v6.string(),
|
|
262
272
|
/**
|
|
263
273
|
* A Stacks transaction as a hex-encoded string.
|
|
264
274
|
*/
|
|
265
|
-
transaction:
|
|
275
|
+
transaction: v6.string()
|
|
266
276
|
});
|
|
267
|
-
var stxDeployContractRequestMessageSchema =
|
|
277
|
+
var stxDeployContractRequestMessageSchema = v6.object({
|
|
268
278
|
...rpcRequestMessageSchema.entries,
|
|
269
|
-
...
|
|
270
|
-
method:
|
|
279
|
+
...v6.object({
|
|
280
|
+
method: v6.literal(stxDeployContractMethodName),
|
|
271
281
|
params: stxDeployContractParamsSchema,
|
|
272
|
-
id:
|
|
282
|
+
id: v6.string()
|
|
273
283
|
}).entries
|
|
274
284
|
});
|
|
275
285
|
|
|
@@ -278,13 +288,6 @@ import * as v8 from "valibot";
|
|
|
278
288
|
|
|
279
289
|
// src/request/types/walletMethods.ts
|
|
280
290
|
import * as v7 from "valibot";
|
|
281
|
-
|
|
282
|
-
// src/request/types/common.ts
|
|
283
|
-
import * as v6 from "valibot";
|
|
284
|
-
var walletTypes = ["software", "ledger", "keystone"];
|
|
285
|
-
var walletTypeSchema = v6.picklist(walletTypes);
|
|
286
|
-
|
|
287
|
-
// src/request/types/walletMethods.ts
|
|
288
291
|
var accountActionsSchema = v7.object({
|
|
289
292
|
read: v7.optional(v7.boolean())
|
|
290
293
|
});
|