@ckb-ccc/xverse 1.0.33 → 1.1.1

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/advanced.d.mts +2 -0
  3. package/dist/advanced.mjs +1 -0
  4. package/dist/advancedBarrel-C-ThB6-A.d.mts +481 -0
  5. package/dist/advancedBarrel-C-ThB6-A.d.mts.map +1 -0
  6. package/dist/advancedBarrel-DIYsVxWE.mjs +2 -0
  7. package/dist/advancedBarrel-DIYsVxWE.mjs.map +1 -0
  8. package/dist/advancedBarrel.d.mts +2 -0
  9. package/dist/advancedBarrel.mjs +1 -0
  10. package/dist/barrel.d.mts +101 -0
  11. package/dist/barrel.d.mts.map +1 -0
  12. package/dist/barrel.mjs +2 -0
  13. package/dist/barrel.mjs.map +1 -0
  14. package/dist/index.d.mts +2 -0
  15. package/dist/index.mjs +1 -0
  16. package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
  17. package/dist.commonjs/advanced.d.ts +2 -2
  18. package/dist.commonjs/advanced.js +1 -37
  19. package/dist.commonjs/advancedBarrel-BCHIO_V8.d.ts +483 -0
  20. package/dist.commonjs/advancedBarrel-BCHIO_V8.d.ts.map +1 -0
  21. package/dist.commonjs/advancedBarrel-DA4O2d7u.js +2 -0
  22. package/dist.commonjs/advancedBarrel-DA4O2d7u.js.map +1 -0
  23. package/dist.commonjs/advancedBarrel.d.ts +2 -2
  24. package/dist.commonjs/advancedBarrel.js +1 -17
  25. package/dist.commonjs/barrel.d.ts +100 -2
  26. package/dist.commonjs/barrel.d.ts.map +1 -1
  27. package/dist.commonjs/barrel.js +2 -18
  28. package/dist.commonjs/barrel.js.map +1 -0
  29. package/dist.commonjs/index.d.ts +2 -2
  30. package/dist.commonjs/index.js +1 -37
  31. package/package.json +28 -31
  32. package/src/sat-connect-core/types.advanced.ts +6 -4
  33. package/src/signer.ts +2 -1
  34. package/tsdown.config.mts +43 -0
  35. package/dist/advanced.d.ts +0 -2
  36. package/dist/advanced.d.ts.map +0 -1
  37. package/dist/advanced.js +0 -1
  38. package/dist/advancedBarrel.d.ts +0 -2
  39. package/dist/advancedBarrel.d.ts.map +0 -1
  40. package/dist/advancedBarrel.js +0 -1
  41. package/dist/barrel.d.ts +0 -3
  42. package/dist/barrel.d.ts.map +0 -1
  43. package/dist/barrel.js +0 -2
  44. package/dist/index.d.ts +0 -2
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/index.js +0 -1
  47. package/dist/sat-connect-core/advanced.d.ts +0 -5
  48. package/dist/sat-connect-core/advanced.d.ts.map +0 -1
  49. package/dist/sat-connect-core/advanced.js +0 -4
  50. package/dist/sat-connect-core/btcMethods.advanced.d.ts +0 -280
  51. package/dist/sat-connect-core/btcMethods.advanced.d.ts.map +0 -1
  52. package/dist/sat-connect-core/btcMethods.advanced.js +0 -179
  53. package/dist/sat-connect-core/provider.advanced.d.ts +0 -48
  54. package/dist/sat-connect-core/provider.advanced.d.ts.map +0 -1
  55. package/dist/sat-connect-core/provider.advanced.js +0 -21
  56. package/dist/sat-connect-core/requests.advanced.d.ts +0 -21
  57. package/dist/sat-connect-core/requests.advanced.d.ts.map +0 -1
  58. package/dist/sat-connect-core/requests.advanced.js +0 -1
  59. package/dist/sat-connect-core/types.advanced.d.ts +0 -124
  60. package/dist/sat-connect-core/types.advanced.d.ts.map +0 -1
  61. package/dist/sat-connect-core/types.advanced.js +0 -80
  62. package/dist/sat-connect-core/walletMethods.advanced.d.ts +0 -36
  63. package/dist/sat-connect-core/walletMethods.advanced.d.ts.map +0 -1
  64. package/dist/sat-connect-core/walletMethods.advanced.js +0 -37
  65. package/dist/signer.d.ts +0 -81
  66. package/dist/signer.d.ts.map +0 -1
  67. package/dist/signer.js +0 -225
  68. package/dist/signersFactory.d.ts +0 -13
  69. package/dist/signersFactory.d.ts.map +0 -1
  70. package/dist/signersFactory.js +0 -33
  71. package/dist.commonjs/advanced.d.ts.map +0 -1
  72. package/dist.commonjs/advancedBarrel.d.ts.map +0 -1
  73. package/dist.commonjs/index.d.ts.map +0 -1
  74. package/dist.commonjs/sat-connect-core/advanced.d.ts +0 -5
  75. package/dist.commonjs/sat-connect-core/advanced.d.ts.map +0 -1
  76. package/dist.commonjs/sat-connect-core/advanced.js +0 -20
  77. package/dist.commonjs/sat-connect-core/btcMethods.advanced.d.ts +0 -280
  78. package/dist.commonjs/sat-connect-core/btcMethods.advanced.d.ts.map +0 -1
  79. package/dist.commonjs/sat-connect-core/btcMethods.advanced.js +0 -215
  80. package/dist.commonjs/sat-connect-core/provider.advanced.d.ts +0 -48
  81. package/dist.commonjs/sat-connect-core/provider.advanced.d.ts.map +0 -1
  82. package/dist.commonjs/sat-connect-core/provider.advanced.js +0 -57
  83. package/dist.commonjs/sat-connect-core/requests.advanced.d.ts +0 -21
  84. package/dist.commonjs/sat-connect-core/requests.advanced.d.ts.map +0 -1
  85. package/dist.commonjs/sat-connect-core/requests.advanced.js +0 -2
  86. package/dist.commonjs/sat-connect-core/types.advanced.d.ts +0 -124
  87. package/dist.commonjs/sat-connect-core/types.advanced.d.ts.map +0 -1
  88. package/dist.commonjs/sat-connect-core/types.advanced.js +0 -116
  89. package/dist.commonjs/sat-connect-core/walletMethods.advanced.d.ts +0 -36
  90. package/dist.commonjs/sat-connect-core/walletMethods.advanced.d.ts.map +0 -1
  91. package/dist.commonjs/sat-connect-core/walletMethods.advanced.js +0 -73
  92. package/dist.commonjs/signer.d.ts +0 -81
  93. package/dist.commonjs/signer.d.ts.map +0 -1
  94. package/dist.commonjs/signer.js +0 -262
  95. package/dist.commonjs/signersFactory.d.ts +0 -13
  96. package/dist.commonjs/signersFactory.d.ts.map +0 -1
  97. package/dist.commonjs/signersFactory.js +0 -36
@@ -1,124 +0,0 @@
1
- import * as v from "valibot";
2
- import type { BtcProvider } from "./provider.advanced.js";
3
- import type { Requests, Return } from "./requests.advanced.js";
4
- export declare enum BitcoinNetworkType {
5
- Mainnet = "Mainnet",
6
- Testnet = "Testnet",
7
- Signet = "Signet"
8
- }
9
- export interface BitcoinNetwork {
10
- type: BitcoinNetworkType;
11
- address?: string;
12
- }
13
- export interface RequestPayload {
14
- network: BitcoinNetwork;
15
- }
16
- export interface RequestOptions<Payload extends RequestPayload, Response> {
17
- onFinish: (response: Response) => void;
18
- onCancel: () => void;
19
- payload: Payload;
20
- getProvider?: () => Promise<BtcProvider | undefined>;
21
- }
22
- export declare const RpcIdSchema: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, undefined>;
23
- export type RpcId = v.InferOutput<typeof RpcIdSchema>;
24
- export declare const rpcRequestMessageSchema: v.ObjectSchema<{
25
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
26
- readonly method: v.StringSchema<undefined>;
27
- readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, undefined>;
28
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, undefined>;
29
- }, undefined>;
30
- export type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
31
- export interface RpcBase {
32
- jsonrpc: "2.0";
33
- id: RpcId;
34
- }
35
- export interface RpcRequest<T extends string, U> extends RpcBase {
36
- method: T;
37
- params: U;
38
- }
39
- export interface MethodParamsAndResult<TParams, TResult> {
40
- params: TParams;
41
- result: TResult;
42
- }
43
- /**
44
- * @enum {number} RpcErrorCode
45
- * @description JSON-RPC error codes
46
- * @see https://www.jsonrpc.org/specification#error_object
47
- */
48
- export declare enum RpcErrorCode {
49
- /**
50
- * Parse error Invalid JSON
51
- **/
52
- PARSE_ERROR = -32700,
53
- /**
54
- * The JSON sent is not a valid Request object.
55
- **/
56
- INVALID_REQUEST = -32600,
57
- /**
58
- * The method does not exist/is not available.
59
- **/
60
- METHOD_NOT_FOUND = -32601,
61
- /**
62
- * Invalid method parameter(s).
63
- */
64
- INVALID_PARAMS = -32602,
65
- /**
66
- * Internal JSON-RPC error.
67
- * This is a generic error, used when the server encounters an error in performing the request.
68
- **/
69
- INTERNAL_ERROR = -32603,
70
- /**
71
- * user rejected/canceled the request
72
- */
73
- USER_REJECTION = -32000,
74
- /**
75
- * method is not supported for the address provided
76
- */
77
- METHOD_NOT_SUPPORTED = -32001,
78
- /**
79
- * The client does not have permission to access the requested resource.
80
- */
81
- ACCESS_DENIED = -32002
82
- }
83
- export declare const rpcSuccessResponseMessageSchema: v.ObjectSchema<{
84
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
85
- readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
86
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, undefined>;
87
- }, undefined>;
88
- export type RpcSuccessResponseMessage = v.InferOutput<typeof rpcSuccessResponseMessageSchema>;
89
- export declare const rpcErrorResponseMessageSchema: v.ObjectSchema<{
90
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
91
- readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
92
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, undefined>;
93
- }, undefined>;
94
- export type RpcErrorResponseMessage = v.InferOutput<typeof rpcErrorResponseMessageSchema>;
95
- export declare const rpcResponseMessageSchema: v.UnionSchema<[v.ObjectSchema<{
96
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
97
- readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
98
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, undefined>;
99
- }, undefined>, v.ObjectSchema<{
100
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
101
- readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
102
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, undefined>;
103
- }, undefined>], undefined>;
104
- export type RpcResponseMessage = v.InferOutput<typeof rpcResponseMessageSchema>;
105
- export interface RpcError {
106
- code: number | RpcErrorCode;
107
- message: string;
108
- data?: any;
109
- }
110
- export interface RpcErrorResponse<TError extends RpcError = RpcError> extends RpcBase {
111
- error: TError;
112
- }
113
- export interface RpcSuccessResponse<Method extends keyof Requests> extends RpcBase {
114
- result: Return<Method>;
115
- }
116
- export type RpcResponse<Method extends keyof Requests> = RpcSuccessResponse<Method> | RpcErrorResponse;
117
- export type RpcResult<Method extends keyof Requests> = {
118
- result: RpcSuccessResponse<Method>["result"];
119
- status: "success";
120
- } | {
121
- error: RpcErrorResponse["error"];
122
- status: "error";
123
- };
124
- //# sourceMappingURL=types.advanced.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.advanced.d.ts","sourceRoot":"","sources":["../../src/sat-connect-core/types.advanced.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE/D,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,cAAc,EAAE,QAAQ;IACtE,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,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B,GAAG,CAAC,CAAC,WAAW,CACjD,OAAO,6BAA6B,CACrC,CAAC;AACF,eAAO,MAAM,wBAAwB;;;;;;;;0BAGnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,QAAQ,GAAG,QAAQ,CAClE,SAAQ,OAAO;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS,MAAM,QAAQ,CAC/D,SAAQ,OAAO;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,MAAM,QAAQ,IACjD,kBAAkB,CAAC,MAAM,CAAC,GAC1B,gBAAgB,CAAC;AAErB,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,QAAQ,IAC/C;IACE,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,EAAE,SAAS,CAAC;CACnB,GACD;IACE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -1,80 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- // From https://github.com/secretkeylabs/sats-connect-core/
3
- import * as v from "valibot";
4
- export var BitcoinNetworkType;
5
- (function (BitcoinNetworkType) {
6
- BitcoinNetworkType["Mainnet"] = "Mainnet";
7
- BitcoinNetworkType["Testnet"] = "Testnet";
8
- BitcoinNetworkType["Signet"] = "Signet";
9
- })(BitcoinNetworkType || (BitcoinNetworkType = {}));
10
- // RPC Request and Response types
11
- export const RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
12
- export const rpcRequestMessageSchema = v.object({
13
- jsonrpc: v.literal("2.0"),
14
- method: v.string(),
15
- params: v.optional(v.union([
16
- v.array(v.unknown()),
17
- v.looseObject({}),
18
- // Note: This is to support current incorrect usage of RPC 2.0. Params need
19
- // to be either an array or an object when provided. Changing this now would
20
- // be a breaking change, so accepting null values for now. Tracking in
21
- // https://linear.app/xverseapp/issue/ENG-4538.
22
- v.null(),
23
- ])),
24
- id: RpcIdSchema,
25
- });
26
- /**
27
- * @enum {number} RpcErrorCode
28
- * @description JSON-RPC error codes
29
- * @see https://www.jsonrpc.org/specification#error_object
30
- */
31
- export var RpcErrorCode;
32
- (function (RpcErrorCode) {
33
- /**
34
- * Parse error Invalid JSON
35
- **/
36
- RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
37
- /**
38
- * The JSON sent is not a valid Request object.
39
- **/
40
- RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
41
- /**
42
- * The method does not exist/is not available.
43
- **/
44
- RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
45
- /**
46
- * Invalid method parameter(s).
47
- */
48
- RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
49
- /**
50
- * Internal JSON-RPC error.
51
- * This is a generic error, used when the server encounters an error in performing the request.
52
- **/
53
- RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
54
- /**
55
- * user rejected/canceled the request
56
- */
57
- RpcErrorCode[RpcErrorCode["USER_REJECTION"] = -32000] = "USER_REJECTION";
58
- /**
59
- * method is not supported for the address provided
60
- */
61
- RpcErrorCode[RpcErrorCode["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
62
- /**
63
- * The client does not have permission to access the requested resource.
64
- */
65
- RpcErrorCode[RpcErrorCode["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
66
- })(RpcErrorCode || (RpcErrorCode = {}));
67
- export const rpcSuccessResponseMessageSchema = v.object({
68
- jsonrpc: v.literal("2.0"),
69
- result: v.nonOptional(v.unknown()),
70
- id: RpcIdSchema,
71
- });
72
- export const rpcErrorResponseMessageSchema = v.object({
73
- jsonrpc: v.literal("2.0"),
74
- error: v.nonOptional(v.unknown()),
75
- id: RpcIdSchema,
76
- });
77
- export const rpcResponseMessageSchema = v.union([
78
- rpcSuccessResponseMessageSchema,
79
- rpcErrorResponseMessageSchema,
80
- ]);
@@ -1,36 +0,0 @@
1
- import * as v from "valibot";
2
- import { MethodParamsAndResult } from "./types.advanced.js";
3
- export declare const walletTypes: readonly ["software", "ledger"];
4
- export declare const walletTypeSchema: v.PicklistSchema<readonly ["software", "ledger"], undefined>;
5
- export type WalletType = v.InferOutput<typeof walletTypeSchema>;
6
- export declare const requestPermissionsMethodName = "wallet_requestPermissions";
7
- export declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
8
- export declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
9
- export declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
10
- readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
11
- readonly params: v.UndefinedSchema<undefined>;
12
- readonly id: v.StringSchema<undefined>;
13
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
14
- }, undefined>;
15
- export type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
16
- export declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
17
- export declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
18
- export declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
19
- export declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
20
- readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
21
- readonly params: v.UndefinedSchema<undefined>;
22
- readonly id: v.StringSchema<undefined>;
23
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
24
- }, undefined>;
25
- export type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
26
- export declare const getWalletTypeMethodName = "wallet_getWalletType";
27
- export declare const getWalletTypeParamsSchema: v.NullishSchema<v.NullSchema<undefined>, undefined>;
28
- export declare const getWalletTypeResultSchema: v.PicklistSchema<readonly ["software", "ledger"], undefined>;
29
- export declare const getWalletTypeRequestMessageSchema: v.ObjectSchema<{
30
- readonly method: v.LiteralSchema<"wallet_getWalletType", undefined>;
31
- readonly id: v.StringSchema<undefined>;
32
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
33
- readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, undefined>;
34
- }, undefined>;
35
- export type GetWalletType = MethodParamsAndResult<v.InferOutput<typeof getWalletTypeParamsSchema>, v.InferOutput<typeof getWalletTypeResultSchema>>;
36
- //# sourceMappingURL=walletMethods.advanced.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"walletMethods.advanced.d.ts","sourceRoot":"","sources":["../../src/sat-connect-core/walletMethods.advanced.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EACL,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,WAAW,iCAAkC,CAAC;AAC3D,eAAO,MAAM,gBAAgB,8DAA0B,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AACxE,eAAO,MAAM,8BAA8B,8BAAgB,CAAC;AAC5D,eAAO,MAAM,8BAA8B,kCAAkB,CAAC;AAC9D,eAAO,MAAM,sCAAsC;;;;;aAOjD,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CACpD,CAAC,CAAC,WAAW,CAAC,OAAO,8BAA8B,CAAC,EACpD,CAAC,CAAC,WAAW,CAAC,OAAO,8BAA8B,CAAC,CACrD,CAAC;AAEF,eAAO,MAAM,6BAA6B,+BAA+B,CAAC;AAC1E,eAAO,MAAM,+BAA+B,8BAAgB,CAAC;AAC7D,eAAO,MAAM,+BAA+B,kCAAkB,CAAC;AAC/D,eAAO,MAAM,uCAAuC;;;;;aAOlD,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CACrD,CAAC,CAAC,WAAW,CAAC,OAAO,+BAA+B,CAAC,EACrD,CAAC,CAAC,WAAW,CAAC,OAAO,+BAA+B,CAAC,CACtD,CAAC;AAEF,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAC9D,eAAO,MAAM,yBAAyB,qDAAsB,CAAC;AAC7D,eAAO,MAAM,yBAAyB,8DAAmB,CAAC;AAC1D,eAAO,MAAM,iCAAiC;;;;;aAM5C,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAC/C,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,EAC/C,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAChD,CAAC"}
@@ -1,37 +0,0 @@
1
- // From https://github.com/secretkeylabs/sats-connect-core/
2
- import * as v from "valibot";
3
- import { rpcRequestMessageSchema, } from "./types.advanced.js";
4
- export const walletTypes = ["software", "ledger"];
5
- export const walletTypeSchema = v.picklist(walletTypes);
6
- export const requestPermissionsMethodName = "wallet_requestPermissions";
7
- export const requestPermissionsParamsSchema = v.undefined();
8
- export const requestPermissionsResultSchema = v.literal(true);
9
- export const requestPermissionsRequestMessageSchema = v.object({
10
- ...rpcRequestMessageSchema.entries,
11
- ...v.object({
12
- method: v.literal(requestPermissionsMethodName),
13
- params: requestPermissionsParamsSchema,
14
- id: v.string(),
15
- }).entries,
16
- });
17
- export const renouncePermissionsMethodName = "wallet_renouncePermissions";
18
- export const renouncePermissionsParamsSchema = v.undefined();
19
- export const renouncePermissionsResultSchema = v.literal(true);
20
- export const renouncePermissionsRequestMessageSchema = v.object({
21
- ...rpcRequestMessageSchema.entries,
22
- ...v.object({
23
- method: v.literal(renouncePermissionsMethodName),
24
- params: renouncePermissionsParamsSchema,
25
- id: v.string(),
26
- }).entries,
27
- });
28
- export const getWalletTypeMethodName = "wallet_getWalletType";
29
- export const getWalletTypeParamsSchema = v.nullish(v.null());
30
- export const getWalletTypeResultSchema = walletTypeSchema;
31
- export const getWalletTypeRequestMessageSchema = v.object({
32
- ...rpcRequestMessageSchema.entries,
33
- ...v.object({
34
- method: v.literal(getWalletTypeMethodName),
35
- id: v.string(),
36
- }).entries,
37
- });
package/dist/signer.d.ts DELETED
@@ -1,81 +0,0 @@
1
- import { ccc } from "@ckb-ccc/core";
2
- import { Address, BtcProvider } from "./advancedBarrel.js";
3
- /**
4
- * Class representing a Bitcoin signer that extends SignerBtc
5
- * @public
6
- */
7
- export declare class Signer extends ccc.SignerBtc {
8
- readonly provider: BtcProvider;
9
- private readonly preferredNetworks;
10
- private addressCache;
11
- /**
12
- * Creates an instance of Signer.
13
- * @param client - The client instance.
14
- * @param provider - The provider instance.
15
- */
16
- constructor(client: ccc.Client, provider: BtcProvider, preferredNetworks?: ccc.NetworkPreference[]);
17
- assertAddress(): Promise<Address>;
18
- /**
19
- * Gets the Bitcoin account address.
20
- * @returns A promise that resolves to the Bitcoin account address.
21
- */
22
- getBtcAccount(): Promise<string>;
23
- /**
24
- * Gets the Bitcoin public key.
25
- * @returns A promise that resolves to the Bitcoin public key.
26
- */
27
- getBtcPublicKey(): Promise<ccc.Hex>;
28
- /**
29
- * Connects to the provider by requesting accounts.
30
- * @returns A promise that resolves when the connection is established.
31
- */
32
- connect(): Promise<void>;
33
- disconnect(): Promise<void>;
34
- onReplaced(listener: () => void): () => void;
35
- /**
36
- * Checks if the signer is connected.
37
- * @returns A promise that resolves to true if connected, false otherwise.
38
- */
39
- isConnected(): Promise<boolean>;
40
- /**
41
- * Signs a raw message with the Bitcoin account.
42
- * @param message - The message to sign.
43
- * @returns A promise that resolves to the signed message.
44
- */
45
- signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
46
- /**
47
- * Build default inputsToSign for all unsigned inputs
48
- */
49
- private buildDefaultinputsToSign;
50
- private prepareSignPsbtParams;
51
- /**
52
- * Signs a PSBT using Xverse wallet.
53
- *
54
- * @param psbtHex - The hex string of PSBT to sign.
55
- * @param options - Options for signing the PSBT
56
- * @returns A promise that resolves to the signed PSBT as a Hex string
57
- *
58
- * @remarks
59
- * Xverse accepts:
60
- * - psbt: A string representing the PSBT to sign, encoded in base64
61
- * - signInputs: A Record<string, number[]> where:
62
- * - keys are the addresses to use for signing
63
- * - values are the indexes of the inputs to sign with each address
64
- *
65
- * Xverse returns:
66
- * - psbt: The base64 encoded signed PSBT
67
- *
68
- * @see https://docs.xverse.app/sats-connect/bitcoin-methods/signpsbt
69
- */
70
- signPsbt(psbtHex: ccc.HexLike, options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
71
- /**
72
- * Broadcasts a PSBT to the Bitcoin network.
73
- *
74
- * @remarks
75
- * Xverse does not support broadcasting a signed PSBT directly.
76
- * It only supports "Sign and Broadcast" as a single atomic operation via `signAndBroadcastPsbt`.
77
- */
78
- broadcastPsbt(_psbtHex: ccc.HexLike, _options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
79
- signAndBroadcastPsbt(psbtHex: ccc.HexLike, options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
80
- }
81
- //# sourceMappingURL=signer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EA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AG,CAAC,GAAG,CAAC;IAMb,oBAAoB,CACxB,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,OAAO,CAAC,EAAE,GAAG,CAAC,mBAAmB,GAChC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAqBpB"}
package/dist/signer.js DELETED
@@ -1,225 +0,0 @@
1
- import { ccc } from "@ckb-ccc/core";
2
- import { Psbt } from "bitcoinjs-lib";
3
- import * as v from "valibot";
4
- import { AddressPurpose, MessageSigningProtocols, RpcErrorCode, rpcErrorResponseMessageSchema, rpcSuccessResponseMessageSchema, } from "./advancedBarrel.js";
5
- async function checkResponse(response) {
6
- const res = await response;
7
- if (v.is(rpcErrorResponseMessageSchema, res)) {
8
- // eslint-disable-next-line @typescript-eslint/only-throw-error
9
- throw res.error;
10
- }
11
- if (v.is(rpcSuccessResponseMessageSchema, res)) {
12
- return res.result;
13
- }
14
- // eslint-disable-next-line @typescript-eslint/only-throw-error
15
- throw {
16
- code: RpcErrorCode.INTERNAL_ERROR,
17
- message: "Received unknown response from provider.",
18
- data: res,
19
- };
20
- }
21
- /**
22
- * Class representing a Bitcoin signer that extends SignerBtc
23
- * @public
24
- */
25
- export class Signer extends ccc.SignerBtc {
26
- /**
27
- * Creates an instance of Signer.
28
- * @param client - The client instance.
29
- * @param provider - The provider instance.
30
- */
31
- constructor(client, provider, preferredNetworks = [
32
- {
33
- addressPrefix: "ckb",
34
- signerType: ccc.SignerType.BTC,
35
- network: "btc",
36
- },
37
- {
38
- addressPrefix: "ckt",
39
- signerType: ccc.SignerType.BTC,
40
- network: "btcTestnet",
41
- },
42
- ]) {
43
- super(client);
44
- this.provider = provider;
45
- this.preferredNetworks = preferredNetworks;
46
- }
47
- async assertAddress() {
48
- this.addressCache =
49
- this.addressCache ??
50
- (async () => {
51
- if (!(await this.isConnected())) {
52
- return;
53
- }
54
- return (await checkResponse(this.provider.request("getAddresses", {
55
- purposes: [AddressPurpose.Payment],
56
- }))).addresses[0];
57
- })();
58
- const address = await this.addressCache;
59
- if (address) {
60
- return address;
61
- }
62
- throw Error("Not connected");
63
- }
64
- /**
65
- * Gets the Bitcoin account address.
66
- * @returns A promise that resolves to the Bitcoin account address.
67
- */
68
- async getBtcAccount() {
69
- return (await this.assertAddress()).address;
70
- }
71
- /**
72
- * Gets the Bitcoin public key.
73
- * @returns A promise that resolves to the Bitcoin public key.
74
- */
75
- async getBtcPublicKey() {
76
- return ccc.hexFrom((await this.assertAddress()).publicKey);
77
- }
78
- /**
79
- * Connects to the provider by requesting accounts.
80
- * @returns A promise that resolves when the connection is established.
81
- */
82
- async connect() {
83
- if (await this.isConnected()) {
84
- return;
85
- }
86
- await checkResponse(this.provider.request("wallet_requestPermissions", undefined));
87
- }
88
- async disconnect() {
89
- this.addressCache = undefined;
90
- }
91
- onReplaced(listener) {
92
- const stop = [];
93
- const replacer = () => {
94
- listener();
95
- stop[0]?.();
96
- };
97
- stop.push(this.provider.addListener("accountChange", replacer), this.provider.addListener("networkChange", replacer));
98
- return stop[0];
99
- }
100
- /**
101
- * Checks if the signer is connected.
102
- * @returns A promise that resolves to true if connected, false otherwise.
103
- */
104
- async isConnected() {
105
- try {
106
- await checkResponse(this.provider.request("getBalance", undefined));
107
- return true;
108
- }
109
- catch (_error) {
110
- return false;
111
- }
112
- }
113
- /**
114
- * Signs a raw message with the Bitcoin account.
115
- * @param message - The message to sign.
116
- * @returns A promise that resolves to the signed message.
117
- */
118
- async signMessageRaw(message) {
119
- const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
120
- return (await checkResponse(this.provider.request("signMessage", {
121
- message: challenge,
122
- address: (await this.assertAddress()).address,
123
- protocol: MessageSigningProtocols.ECDSA,
124
- }))).signature;
125
- }
126
- /**
127
- * Build default inputsToSign for all unsigned inputs
128
- */
129
- buildDefaultinputsToSign(psbtHex, address) {
130
- const inputsToSign = [];
131
- try {
132
- // Collect all unsigned inputs
133
- const psbt = Psbt.fromHex(psbtHex.slice(2));
134
- psbt.data.inputs.forEach((input, index) => {
135
- const isSigned = input.finalScriptSig ||
136
- input.finalScriptWitness ||
137
- input.tapKeySig ||
138
- (input.partialSig && input.partialSig.length > 0) ||
139
- (input.tapScriptSig && input.tapScriptSig.length > 0);
140
- if (!isSigned) {
141
- inputsToSign.push({ index, address });
142
- }
143
- });
144
- // If no unsigned inputs found, the PSBT is already fully signed
145
- // Let the wallet handle this case (likely a no-op or error)
146
- }
147
- catch (error) {
148
- const errorMessage = error instanceof Error ? error.message : String(error);
149
- throw new Error(`Failed to parse PSBT hex. Please provide inputsToSign explicitly in options. Original error: ${errorMessage}`);
150
- }
151
- return inputsToSign;
152
- }
153
- async prepareSignPsbtParams(psbtHex, options) {
154
- let inputsToSign = options?.inputsToSign;
155
- if (!inputsToSign || !inputsToSign.length) {
156
- const address = await this.getBtcAccount();
157
- inputsToSign = this.buildDefaultinputsToSign(psbtHex, address);
158
- }
159
- const psbtBase64 = ccc.bytesTo(psbtHex, "base64");
160
- const signInputs = inputsToSign.reduce((acc, input) => {
161
- if (!input.address) {
162
- throw new Error("Xverse only supports signing with address. Please provide 'address' in inputsToSign.");
163
- }
164
- if (acc[input.address]) {
165
- acc[input.address].push(input.index);
166
- }
167
- else {
168
- acc[input.address] = [input.index];
169
- }
170
- return acc;
171
- }, {});
172
- return { psbtBase64, signInputs };
173
- }
174
- /**
175
- * Signs a PSBT using Xverse wallet.
176
- *
177
- * @param psbtHex - The hex string of PSBT to sign.
178
- * @param options - Options for signing the PSBT
179
- * @returns A promise that resolves to the signed PSBT as a Hex string
180
- *
181
- * @remarks
182
- * Xverse accepts:
183
- * - psbt: A string representing the PSBT to sign, encoded in base64
184
- * - signInputs: A Record<string, number[]> where:
185
- * - keys are the addresses to use for signing
186
- * - values are the indexes of the inputs to sign with each address
187
- *
188
- * Xverse returns:
189
- * - psbt: The base64 encoded signed PSBT
190
- *
191
- * @see https://docs.xverse.app/sats-connect/bitcoin-methods/signpsbt
192
- */
193
- async signPsbt(psbtHex, options) {
194
- const { psbtBase64, signInputs } = await this.prepareSignPsbtParams(ccc.hexFrom(psbtHex), options);
195
- const signedPsbtBase64 = (await checkResponse(this.provider.request("signPsbt", {
196
- psbt: psbtBase64,
197
- signInputs,
198
- broadcast: false,
199
- }))).psbt;
200
- return ccc.hexFrom(ccc.bytesFrom(signedPsbtBase64, "base64"));
201
- }
202
- /**
203
- * Broadcasts a PSBT to the Bitcoin network.
204
- *
205
- * @remarks
206
- * Xverse does not support broadcasting a signed PSBT directly.
207
- * It only supports "Sign and Broadcast" as a single atomic operation via `signAndBroadcastPsbt`.
208
- */
209
- async broadcastPsbt(_psbtHex, _options) {
210
- throw new Error("Xverse does not support broadcasting signed PSBTs directly. Use signAndBroadcastPsbt instead.");
211
- }
212
- async signAndBroadcastPsbt(psbtHex, options) {
213
- // ccc.hexFrom adds 0x prefix, but BTC expects non-0x
214
- const { psbtBase64, signInputs } = await this.prepareSignPsbtParams(ccc.hexFrom(psbtHex), options);
215
- const result = await checkResponse(this.provider.request("signPsbt", {
216
- psbt: psbtBase64,
217
- signInputs,
218
- broadcast: true,
219
- }));
220
- if (!result.txid) {
221
- throw new Error("Failed to broadcast PSBT");
222
- }
223
- return ccc.hexFrom(result.txid);
224
- }
225
- }
@@ -1,13 +0,0 @@
1
- import { ccc } from "@ckb-ccc/core";
2
- /**
3
- * Retrieves the Xverse signer if available.
4
- * @public
5
- *
6
- * @param client - The client instance.
7
- * @returns All Xverse Signer instances
8
- */
9
- export declare function getXverseSigners(client: ccc.Client, preferredNetworks?: ccc.NetworkPreference[]): {
10
- wallet: ccc.Wallet;
11
- signerInfo: ccc.SignerInfo;
12
- }[];
13
- //# sourceMappingURL=signersFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAapC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAC1C;IAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAA;CAAE,EAAE,CA+BtD"}
@@ -1,33 +0,0 @@
1
- import { Signer } from "./signer.js";
2
- function getProviderById(providerId) {
3
- return providerId
4
- ?.split(".")
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return
6
- .reduce((acc, part) => acc?.[part], window);
7
- }
8
- /**
9
- * Retrieves the Xverse signer if available.
10
- * @public
11
- *
12
- * @param client - The client instance.
13
- * @returns All Xverse Signer instances
14
- */
15
- export function getXverseSigners(client, preferredNetworks) {
16
- const windowRef = window;
17
- const signers = (() => {
18
- if (windowRef.btc_providers) {
19
- return windowRef.btc_providers.map((provider) => ({
20
- wallet: {
21
- name: provider.name,
22
- icon: provider.icon,
23
- },
24
- signerInfo: {
25
- name: "BTC",
26
- signer: new Signer(client, getProviderById(provider.id), preferredNetworks),
27
- },
28
- }));
29
- }
30
- return [];
31
- })();
32
- return signers;
33
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}