@leather.io/rpc 2.21.0 → 2.21.2
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.cjs +572 -704
- package/dist/index.d.cts +2364 -2342
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +2364 -2342
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +495 -599
- package/dist/index.js.map +1 -1
- package/package.json +15 -9
- package/dist/index.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,782 +1,650 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
Bip322MessageTypesSchema: () => Bip322MessageTypesSchema,
|
|
24
|
-
RpcErrorCode: () => RpcErrorCode,
|
|
25
|
-
addressResponseBodySchema: () => addressResponseBodySchema,
|
|
26
|
-
addressSchema: () => addressSchema,
|
|
27
|
-
baseStacksTransactionConfigSchema: () => baseStacksTransactionConfigSchema,
|
|
28
|
-
bitcoinPaymentTypesSchema: () => bitcoinPaymentTypesSchema,
|
|
29
|
-
btcAddressBaseSchema: () => btcAddressBaseSchema,
|
|
30
|
-
btcAddressSchema: () => btcAddressSchema,
|
|
31
|
-
clarityValueSchema: () => clarityValueSchema,
|
|
32
|
-
createRequestEncoder: () => createRequestEncoder,
|
|
33
|
-
createRpcErrorBodySchema: () => createRpcErrorBodySchema,
|
|
34
|
-
createRpcErrorResponse: () => createRpcErrorResponse,
|
|
35
|
-
createRpcErrorResponseSchema: () => createRpcErrorResponseSchema,
|
|
36
|
-
createRpcRequestSchema: () => createRpcRequestSchema,
|
|
37
|
-
createRpcResponseSchema: () => createRpcResponseSchema,
|
|
38
|
-
createRpcSuccessResponse: () => createRpcSuccessResponse,
|
|
39
|
-
createRpcSuccessResponseSchema: () => createRpcSuccessResponseSchema,
|
|
40
|
-
cvAddressSchema: () => cvAddressSchema,
|
|
41
|
-
cvAsciiSchema: () => cvAsciiSchema,
|
|
42
|
-
cvBufferSchema: () => cvBufferSchema,
|
|
43
|
-
cvContractSchema: () => cvContractSchema,
|
|
44
|
-
cvErrSchema: () => cvErrSchema,
|
|
45
|
-
cvFalseSchema: () => cvFalseSchema,
|
|
46
|
-
cvIntSchema: () => cvIntSchema,
|
|
47
|
-
cvListSchema: () => cvListSchema,
|
|
48
|
-
cvNoneSchema: () => cvNoneSchema,
|
|
49
|
-
cvOkSchema: () => cvOkSchema,
|
|
50
|
-
cvSomeSchema: () => cvSomeSchema,
|
|
51
|
-
cvTrueSchema: () => cvTrueSchema,
|
|
52
|
-
cvTupleSchema: () => cvTupleSchema,
|
|
53
|
-
cvUintSchema: () => cvUintSchema,
|
|
54
|
-
cvUtf8Schema: () => cvUtf8Schema,
|
|
55
|
-
decodeBase64Json: () => decodeBase64Json,
|
|
56
|
-
defaultErrorSchema: () => defaultErrorSchema,
|
|
57
|
-
defineRpcEndpoint: () => defineRpcEndpoint,
|
|
58
|
-
encodeBase64Json: () => encodeBase64Json,
|
|
59
|
-
endpoints: () => endpoints,
|
|
60
|
-
getAddresses: () => getAddresses,
|
|
61
|
-
getInfo: () => getInfo,
|
|
62
|
-
open: () => open,
|
|
63
|
-
openSwap: () => openSwap,
|
|
64
|
-
parseEndpointRequest: () => parseEndpointRequest,
|
|
65
|
-
rpcBasePropsSchema: () => rpcBasePropsSchema,
|
|
66
|
-
rpcParameterSchema: () => rpcParameterSchema,
|
|
67
|
-
rpcSendTransferLegacyParamSchema: () => rpcSendTransferLegacyParamSchema,
|
|
68
|
-
rpcSendTransferNewParamsSchema: () => rpcSendTransferNewParamsSchema,
|
|
69
|
-
rpcSendTransferParamsSchema: () => rpcSendTransferParamsSchema,
|
|
70
|
-
sendTransfer: () => sendTransfer,
|
|
71
|
-
signMessage: () => signMessage,
|
|
72
|
-
signMessageRequestParamsSchema: () => signMessageRequestParamsSchema,
|
|
73
|
-
signPsbt: () => signPsbt,
|
|
74
|
-
signatureHash: () => signatureHash,
|
|
75
|
-
stacksTransactionDetailsSchema: () => stacksTransactionDetailsSchema,
|
|
76
|
-
stxAddressItemSchema: () => stxAddressItemSchema,
|
|
77
|
-
stxAddressSchema: () => stxAddressSchema,
|
|
78
|
-
stxCallContract: () => stxCallContract,
|
|
79
|
-
stxDeployContract: () => stxDeployContract,
|
|
80
|
-
stxDeployContractResponseBodySchema: () => stxDeployContractResponseBodySchema,
|
|
81
|
-
stxGetAddresses: () => stxGetAddresses,
|
|
82
|
-
stxGetAddressesResponseBodySchema: () => stxGetAddressesResponseBodySchema,
|
|
83
|
-
stxSignMessage: () => stxSignMessage,
|
|
84
|
-
stxSignMessageRequestBaseSchema: () => stxSignMessageRequestBaseSchema,
|
|
85
|
-
stxSignMessageRequestStructuredSchema: () => stxSignMessageRequestStructuredSchema,
|
|
86
|
-
stxSignMessageRequestUtf8Schema: () => stxSignMessageRequestUtf8Schema,
|
|
87
|
-
stxSignMessageTypeSchema: () => stxSignMessageTypeSchema,
|
|
88
|
-
stxSignStructuredMessage: () => stxSignStructuredMessage,
|
|
89
|
-
stxSignTransaction: () => stxSignTransaction,
|
|
90
|
-
stxSignTransactionRequestLeatherRpcParamsSchema: () => stxSignTransactionRequestLeatherRpcParamsSchema,
|
|
91
|
-
stxSignTransactionRequestSip30ParamsSchema: () => stxSignTransactionRequestSip30ParamsSchema,
|
|
92
|
-
stxTransferSip10Ft: () => stxTransferSip10Ft,
|
|
93
|
-
stxTransferSip9Nft: () => stxTransferSip9Nft,
|
|
94
|
-
stxTransferStx: () => stxTransferStx,
|
|
95
|
-
stxUpdateProfile: () => stxUpdateProfile,
|
|
96
|
-
stxUpdateProfileRequestParamsSchema: () => stxUpdateProfileRequestParamsSchema,
|
|
97
|
-
stxUpdateProfileResponseBodySchema: () => stxUpdateProfileResponseBodySchema,
|
|
98
|
-
supportedMethodSchema: () => supportedMethodSchema,
|
|
99
|
-
supportedMethods: () => supportedMethods,
|
|
100
|
-
testIsNumberOrArrayOfNumbers: () => testIsNumberOrArrayOfNumbers
|
|
101
|
-
});
|
|
102
|
-
module.exports = __toCommonJS(index_exports);
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
let __leather_io_utils = require("@leather.io/utils");
|
|
3
|
+
let __leather_io_stacks = require("@leather.io/stacks");
|
|
103
4
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var rpcParameterSchema = import_zod.z.union([
|
|
112
|
-
rpcParameterByPositionSchema,
|
|
113
|
-
rpcParameterByNameSchema,
|
|
114
|
-
import_zod.z.undefined()
|
|
5
|
+
//#region src/rpc/schemas.ts
|
|
6
|
+
const rpcParameterByPositionSchema = zod.z.string().array();
|
|
7
|
+
const rpcParameterByNameSchema = zod.z.record(zod.z.string(), zod.z.unknown());
|
|
8
|
+
const rpcParameterSchema = zod.z.union([
|
|
9
|
+
rpcParameterByPositionSchema,
|
|
10
|
+
rpcParameterByNameSchema,
|
|
11
|
+
zod.z.undefined()
|
|
115
12
|
]);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
13
|
+
const rpcBasePropsSchema = zod.z.object({
|
|
14
|
+
jsonrpc: zod.z.literal("2.0"),
|
|
15
|
+
id: zod.z.string()
|
|
119
16
|
});
|
|
120
17
|
function createRpcRequestSchema(method, paramsSchema) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
18
|
+
if (!paramsSchema) return rpcBasePropsSchema.extend({ method: zod.z.literal(method) });
|
|
19
|
+
return rpcBasePropsSchema.extend({
|
|
20
|
+
method: zod.z.literal(method),
|
|
21
|
+
params: paramsSchema
|
|
22
|
+
});
|
|
126
23
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
24
|
+
let RpcErrorCode = /* @__PURE__ */ function(RpcErrorCode$1) {
|
|
25
|
+
RpcErrorCode$1[RpcErrorCode$1["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
26
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
27
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
28
|
+
RpcErrorCode$1[RpcErrorCode$1["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
29
|
+
RpcErrorCode$1[RpcErrorCode$1["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
30
|
+
RpcErrorCode$1[RpcErrorCode$1["SERVER_ERROR"] = -32e3] = "SERVER_ERROR";
|
|
31
|
+
RpcErrorCode$1[RpcErrorCode$1["USER_REJECTION"] = 4001] = "USER_REJECTION";
|
|
32
|
+
RpcErrorCode$1[RpcErrorCode$1["METHOD_NOT_SUPPORTED"] = 4002] = "METHOD_NOT_SUPPORTED";
|
|
33
|
+
RpcErrorCode$1[RpcErrorCode$1["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
|
|
34
|
+
RpcErrorCode$1[RpcErrorCode$1["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
|
|
35
|
+
return RpcErrorCode$1;
|
|
36
|
+
}({});
|
|
37
|
+
const rpcErrorCodeSchema = zod.z.enum(RpcErrorCode);
|
|
141
38
|
function createRpcErrorBodySchema(errorDataSchema) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
39
|
+
return zod.z.object({
|
|
40
|
+
code: zod.z.union([zod.z.number(), rpcErrorCodeSchema]),
|
|
41
|
+
message: zod.z.string(),
|
|
42
|
+
data: errorDataSchema.optional()
|
|
43
|
+
});
|
|
147
44
|
}
|
|
148
45
|
function createRpcErrorResponseSchema(errorSchema) {
|
|
149
|
-
|
|
46
|
+
return rpcBasePropsSchema.extend({ error: errorSchema });
|
|
150
47
|
}
|
|
151
|
-
|
|
48
|
+
const defaultErrorSchema = createRpcErrorBodySchema(zod.z.any());
|
|
152
49
|
function createRpcSuccessResponseSchema(resultSchema) {
|
|
153
|
-
|
|
50
|
+
return rpcBasePropsSchema.extend({ result: resultSchema });
|
|
154
51
|
}
|
|
155
52
|
function createRpcResponseSchema(resultSchema, errorSchema) {
|
|
156
|
-
|
|
157
|
-
createRpcSuccessResponseSchema(resultSchema),
|
|
158
|
-
createRpcErrorResponseSchema(errorSchema)
|
|
159
|
-
]);
|
|
53
|
+
return zod.z.union([createRpcSuccessResponseSchema(resultSchema), createRpcErrorResponseSchema(errorSchema)]);
|
|
160
54
|
}
|
|
161
55
|
function defineRpcEndpoint(props) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
response: createRpcResponseSchema(props.result, error)
|
|
179
|
-
};
|
|
56
|
+
const error = props.error ?? defaultErrorSchema;
|
|
57
|
+
if ("params" in props) return {
|
|
58
|
+
method: props.method,
|
|
59
|
+
params: props.params,
|
|
60
|
+
result: props.result,
|
|
61
|
+
error,
|
|
62
|
+
request: createRpcRequestSchema(props.method, props.params),
|
|
63
|
+
response: createRpcResponseSchema(props.result, error)
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
method: props.method,
|
|
67
|
+
result: props.result,
|
|
68
|
+
error,
|
|
69
|
+
request: createRpcRequestSchema(props.method),
|
|
70
|
+
response: createRpcResponseSchema(props.result, error)
|
|
71
|
+
};
|
|
180
72
|
}
|
|
181
73
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
params: rpcSendTransferParamsSchema,
|
|
205
|
-
result: import_zod2.z.object({
|
|
206
|
-
txid: import_zod2.z.string()
|
|
207
|
-
})
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/methods/bitcoin/send-transfer.ts
|
|
76
|
+
const rpcSendTransferLegacyParamSchema = zod.z.object({
|
|
77
|
+
account: zod.z.number().optional(),
|
|
78
|
+
address: zod.z.string(),
|
|
79
|
+
amount: zod.z.coerce.string(),
|
|
80
|
+
network: zod.z.string()
|
|
81
|
+
});
|
|
82
|
+
const transferRecipientParamSchema = zod.z.object({
|
|
83
|
+
address: zod.z.string(),
|
|
84
|
+
amount: zod.z.coerce.string()
|
|
85
|
+
});
|
|
86
|
+
const rpcSendTransferNewParamsSchema = zod.z.object({
|
|
87
|
+
account: zod.z.number().optional(),
|
|
88
|
+
recipients: zod.z.array(transferRecipientParamSchema),
|
|
89
|
+
network: zod.z.string()
|
|
90
|
+
});
|
|
91
|
+
const rpcSendTransferParamsSchema = zod.z.union([rpcSendTransferLegacyParamSchema, rpcSendTransferNewParamsSchema]);
|
|
92
|
+
const sendTransfer = defineRpcEndpoint({
|
|
93
|
+
method: "sendTransfer",
|
|
94
|
+
params: rpcSendTransferParamsSchema,
|
|
95
|
+
result: zod.z.object({ txid: zod.z.string() })
|
|
208
96
|
});
|
|
209
97
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/methods/bitcoin/sign-message.ts
|
|
100
|
+
const Bip322MessageTypesSchema = zod.z.enum(["legacy", "bip322"]);
|
|
101
|
+
const supportedPaymentTypesSchema = zod.z.enum(["p2tr", "p2wpkh"]);
|
|
102
|
+
const signMessageRequestParamsSchema = zod.z.looseObject({
|
|
103
|
+
type: Bip322MessageTypesSchema.optional(),
|
|
104
|
+
account: zod.z.number().optional(),
|
|
105
|
+
message: zod.z.string(),
|
|
106
|
+
paymentType: supportedPaymentTypesSchema,
|
|
107
|
+
network: zod.z.string().optional()
|
|
108
|
+
});
|
|
109
|
+
const signMessage = defineRpcEndpoint({
|
|
110
|
+
method: "signMessage",
|
|
111
|
+
params: signMessageRequestParamsSchema,
|
|
112
|
+
result: zod.z.object({
|
|
113
|
+
signature: zod.z.string(),
|
|
114
|
+
address: zod.z.string(),
|
|
115
|
+
message: zod.z.string()
|
|
116
|
+
})
|
|
229
117
|
});
|
|
230
118
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
// src/rpc/helpers.ts
|
|
235
|
-
var import_utils = require("@leather.io/utils");
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/rpc/helpers.ts
|
|
236
121
|
function testIsNumberOrArrayOfNumbers(value) {
|
|
237
|
-
|
|
238
|
-
|
|
122
|
+
if ((0, __leather_io_utils.isUndefined)(value)) return true;
|
|
123
|
+
return (0, __leather_io_utils.isNumberOrNumberList)(value);
|
|
239
124
|
}
|
|
240
125
|
function encodeBase64Json(payload) {
|
|
241
|
-
|
|
242
|
-
|
|
126
|
+
const jsonString = JSON.stringify(payload);
|
|
127
|
+
return btoa(jsonString);
|
|
243
128
|
}
|
|
244
129
|
function decodeBase64Json(encodedPayload) {
|
|
245
|
-
|
|
246
|
-
|
|
130
|
+
const jsonString = atob(encodedPayload);
|
|
131
|
+
return JSON.parse(jsonString);
|
|
247
132
|
}
|
|
248
133
|
function createRequestEncoder(schema) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
134
|
+
function encode(request) {
|
|
135
|
+
return encodeBase64Json(schema.parse(request));
|
|
136
|
+
}
|
|
137
|
+
function decode(encodedRequest) {
|
|
138
|
+
const parsedJson = decodeBase64Json(encodedRequest);
|
|
139
|
+
return schema.parse(parsedJson);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
encode,
|
|
143
|
+
decode
|
|
144
|
+
};
|
|
257
145
|
}
|
|
258
146
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/methods/bitcoin/sign-psbt.ts
|
|
149
|
+
/**
|
|
150
|
+
* DEFAULT -- all inputs, all outputs
|
|
151
|
+
* ALL -- all inputs, all outputs
|
|
152
|
+
* NONE -- all inputs, no outputs
|
|
153
|
+
* SINGLE -- all inputs, one output of the same index
|
|
154
|
+
* ALL + ANYONE -- one input, all outputs
|
|
155
|
+
* NONE + ANYONE -- one input, no outputs
|
|
156
|
+
* SINGLE -- one inputs, one output of the same index
|
|
157
|
+
*/
|
|
158
|
+
const signatureHash = {
|
|
159
|
+
DEFAULT: 0,
|
|
160
|
+
ALL: 1,
|
|
161
|
+
NONE: 2,
|
|
162
|
+
SINGLE: 3,
|
|
163
|
+
ALL_ANYONECANPAY: 129,
|
|
164
|
+
NONE_ANYONECANPAY: 130,
|
|
165
|
+
SINGLE_ANYONECANPAY: 131
|
|
268
166
|
};
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
167
|
+
const signPsbtRequestParamsSchema = zod.z.object({
|
|
168
|
+
account: zod.z.number().optional(),
|
|
169
|
+
allowedSighash: zod.z.array(zod.z.any()).optional(),
|
|
170
|
+
broadcast: zod.z.boolean().optional(),
|
|
171
|
+
hex: zod.z.string(),
|
|
172
|
+
network: zod.z.string().optional(),
|
|
173
|
+
signAtIndex: zod.z.union([zod.z.number(), zod.z.array(zod.z.number())]).optional().refine(testIsNumberOrArrayOfNumbers)
|
|
174
|
+
});
|
|
175
|
+
const signPsbtResponseBodySchema = zod.z.object({
|
|
176
|
+
hex: zod.z.string(),
|
|
177
|
+
txid: zod.z.string().optional()
|
|
178
|
+
});
|
|
179
|
+
const signPsbt = defineRpcEndpoint({
|
|
180
|
+
method: "signPsbt",
|
|
181
|
+
params: signPsbtRequestParamsSchema,
|
|
182
|
+
result: signPsbtResponseBodySchema
|
|
285
183
|
});
|
|
286
184
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
derivationPath: import_zod5.z.string(),
|
|
296
|
-
descriptor: import_zod5.z.string()
|
|
297
|
-
});
|
|
298
|
-
var nativeSegwitAddressSchema = btcAddressBaseSchema.extend({
|
|
299
|
-
type: import_zod5.z.literal("p2wpkh")
|
|
300
|
-
});
|
|
301
|
-
var taprootAddressSchema = btcAddressBaseSchema.extend({
|
|
302
|
-
type: import_zod5.z.literal("p2tr"),
|
|
303
|
-
tweakedPublicKey: import_zod5.z.string()
|
|
304
|
-
});
|
|
305
|
-
var btcAddressSchema = import_zod5.z.discriminatedUnion("type", [
|
|
306
|
-
nativeSegwitAddressSchema,
|
|
307
|
-
taprootAddressSchema
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/methods/get-addresses.ts
|
|
187
|
+
const bitcoinPaymentTypesSchema = zod.z.enum([
|
|
188
|
+
"p2pkh",
|
|
189
|
+
"p2sh",
|
|
190
|
+
"p2wpkh-p2sh",
|
|
191
|
+
"p2wpkh",
|
|
192
|
+
"p2tr"
|
|
308
193
|
]);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
194
|
+
const btcAddressBaseSchema = zod.z.object({
|
|
195
|
+
symbol: zod.z.literal("BTC"),
|
|
196
|
+
type: bitcoinPaymentTypesSchema,
|
|
197
|
+
address: zod.z.string(),
|
|
198
|
+
publicKey: zod.z.string(),
|
|
199
|
+
derivationPath: zod.z.string(),
|
|
200
|
+
descriptor: zod.z.string()
|
|
201
|
+
});
|
|
202
|
+
const nativeSegwitAddressSchema = btcAddressBaseSchema.extend({ type: zod.z.literal("p2wpkh") });
|
|
203
|
+
const taprootAddressSchema = btcAddressBaseSchema.extend({
|
|
204
|
+
type: zod.z.literal("p2tr"),
|
|
205
|
+
tweakedPublicKey: zod.z.string()
|
|
206
|
+
});
|
|
207
|
+
const btcAddressSchema = zod.z.discriminatedUnion("type", [nativeSegwitAddressSchema, taprootAddressSchema]);
|
|
208
|
+
const stxAddressSchema = zod.z.object({
|
|
209
|
+
symbol: zod.z.literal("STX"),
|
|
210
|
+
address: zod.z.string(),
|
|
211
|
+
publicKey: zod.z.string()
|
|
212
|
+
});
|
|
213
|
+
const addressSchema = zod.z.union([btcAddressSchema, stxAddressSchema]);
|
|
214
|
+
const addressResponseBodySchema = zod.z.object({ addresses: zod.z.array(addressSchema) });
|
|
215
|
+
const getAddresses = defineRpcEndpoint({
|
|
216
|
+
method: "getAddresses",
|
|
217
|
+
params: zod.z.object({ network: zod.z.string().optional() }).optional(),
|
|
218
|
+
result: addressResponseBodySchema
|
|
320
219
|
});
|
|
321
220
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/methods/get-info.ts
|
|
223
|
+
const getInfoResponseBodySchema = zod.z.object({
|
|
224
|
+
version: zod.z.string(),
|
|
225
|
+
supportedMethods: zod.z.array(zod.z.string()).optional(),
|
|
226
|
+
platform: zod.z.union([zod.z.literal("mobile"), zod.z.literal("extension")])
|
|
328
227
|
});
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
228
|
+
const getInfo = defineRpcEndpoint({
|
|
229
|
+
method: "getInfo",
|
|
230
|
+
result: getInfoResponseBodySchema
|
|
332
231
|
});
|
|
333
232
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/methods/open.ts
|
|
235
|
+
const open = defineRpcEndpoint({
|
|
236
|
+
method: "open",
|
|
237
|
+
params: zod.z.object({ mode: zod.z.enum(["fullpage", "popup"]) }).default({ mode: "popup" }),
|
|
238
|
+
result: zod.z.object({ success: zod.z.literal(true) })
|
|
340
239
|
});
|
|
341
240
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
params: openSwapRequestParamsSchema,
|
|
354
|
-
result: openSwapResponseBodySchema
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/methods/open-swap.ts
|
|
243
|
+
const openSwapRequestParamsSchema = zod.z.object({
|
|
244
|
+
base: zod.z.string(),
|
|
245
|
+
quote: zod.z.string()
|
|
246
|
+
});
|
|
247
|
+
const openSwapResponseBodySchema = zod.z.object({ message: zod.z.string() });
|
|
248
|
+
const openSwap = defineRpcEndpoint({
|
|
249
|
+
method: "openSwap",
|
|
250
|
+
params: openSwapRequestParamsSchema,
|
|
251
|
+
result: openSwapResponseBodySchema
|
|
355
252
|
});
|
|
356
253
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
// add pc later when imported from stacks.js
|
|
379
|
-
postConditions: import_zod9.z.array(import_zod9.z.string()).optional(),
|
|
380
|
-
postConditionMode: import_zod9.z.union([import_zod9.z.literal("allow"), import_zod9.z.literal("deny")]).optional(),
|
|
381
|
-
sponsored: import_zod9.z.boolean().optional()
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/methods/stacks/_stacks-helpers.ts
|
|
256
|
+
const stacksTransactionDetailsSchema = zod.z.object({
|
|
257
|
+
txid: zod.z.string(),
|
|
258
|
+
transaction: zod.z.string()
|
|
259
|
+
});
|
|
260
|
+
const baseStacksTransactionConfigSchema = zod.z.object({
|
|
261
|
+
address: zod.z.string().optional(),
|
|
262
|
+
network: zod.z.union([
|
|
263
|
+
zod.z.literal("mainnet"),
|
|
264
|
+
zod.z.literal("testnet"),
|
|
265
|
+
zod.z.literal("regtest"),
|
|
266
|
+
zod.z.literal("devnet"),
|
|
267
|
+
zod.z.literal("mocknet"),
|
|
268
|
+
zod.z.string()
|
|
269
|
+
]).optional(),
|
|
270
|
+
fee: zod.z.coerce.number().optional(),
|
|
271
|
+
nonce: zod.z.coerce.number().optional(),
|
|
272
|
+
postConditions: zod.z.array(zod.z.string()).optional(),
|
|
273
|
+
postConditionMode: zod.z.union([zod.z.literal("allow"), zod.z.literal("deny")]).optional(),
|
|
274
|
+
sponsored: zod.z.boolean().optional()
|
|
382
275
|
});
|
|
383
276
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
),
|
|
395
|
-
result: stacksTransactionDetailsSchema
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/methods/stacks/stx-call-contract.ts
|
|
279
|
+
const stxCallContract = defineRpcEndpoint({
|
|
280
|
+
method: "stx_callContract",
|
|
281
|
+
params: zod.z.intersection(zod.z.object({
|
|
282
|
+
contract: zod.z.string(),
|
|
283
|
+
functionName: zod.z.string(),
|
|
284
|
+
functionArgs: zod.z.array(zod.z.string()).optional()
|
|
285
|
+
}), baseStacksTransactionConfigSchema),
|
|
286
|
+
result: stacksTransactionDetailsSchema
|
|
396
287
|
});
|
|
397
288
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}),
|
|
410
|
-
baseStacksTransactionConfigSchema
|
|
411
|
-
),
|
|
412
|
-
result: stxDeployContractResponseBodySchema
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/methods/stacks/stx-deploy-contract.ts
|
|
291
|
+
const stxDeployContractResponseBodySchema = stacksTransactionDetailsSchema;
|
|
292
|
+
const stxDeployContract = defineRpcEndpoint({
|
|
293
|
+
method: "stx_deployContract",
|
|
294
|
+
params: zod.z.intersection(zod.z.object({
|
|
295
|
+
name: zod.z.string(),
|
|
296
|
+
clarityCode: __leather_io_stacks.clarityContractSchema,
|
|
297
|
+
clarityVersion: zod.z.coerce.number().optional()
|
|
298
|
+
}), baseStacksTransactionConfigSchema),
|
|
299
|
+
result: stxDeployContractResponseBodySchema
|
|
413
300
|
});
|
|
414
301
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/methods/stacks/stx-get-addresses.ts
|
|
304
|
+
const stxAddressItemSchema = zod.z.object({
|
|
305
|
+
address: zod.z.string(),
|
|
306
|
+
publicKey: zod.z.string(),
|
|
307
|
+
derivationPath: zod.z.string()
|
|
308
|
+
});
|
|
309
|
+
const stxGetAddressesResponseBodySchema = zod.z.array(stxAddressItemSchema);
|
|
310
|
+
const stxGetAddresses = defineRpcEndpoint({
|
|
311
|
+
method: "stx_getAddresses",
|
|
312
|
+
params: zod.z.object({ network: zod.z.string().optional() }).optional(),
|
|
313
|
+
result: stxGetAddressesResponseBodySchema
|
|
427
314
|
});
|
|
428
315
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
)
|
|
442
|
-
})
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/methods/stacks/stx-get-networks.ts
|
|
318
|
+
const stxGetNetworks = defineRpcEndpoint({
|
|
319
|
+
method: "stx_getNetworks",
|
|
320
|
+
result: zod.z.object({
|
|
321
|
+
active: zod.z.string(),
|
|
322
|
+
networks: zod.z.array(zod.z.object({
|
|
323
|
+
id: zod.z.string(),
|
|
324
|
+
chainId: zod.z.string(),
|
|
325
|
+
transactionVersion: zod.z.string()
|
|
326
|
+
}))
|
|
327
|
+
})
|
|
443
328
|
});
|
|
444
329
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
)
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/methods/stacks/stx-sign-message.ts
|
|
332
|
+
const stxSignMessageTypeSchema = zod.z.enum(["utf8", "structured"]);
|
|
333
|
+
const stxSignMessageRequestBaseSchema = zod.z.object({
|
|
334
|
+
messageType: stxSignMessageTypeSchema.optional().default("utf8"),
|
|
335
|
+
network: zod.z.optional(zod.z.enum([
|
|
336
|
+
"mainnet",
|
|
337
|
+
"testnet",
|
|
338
|
+
"devnet",
|
|
339
|
+
"mocknet"
|
|
340
|
+
]))
|
|
341
|
+
});
|
|
342
|
+
const stxSignMessageRequestUtf8Schema = stxSignMessageRequestBaseSchema.and(zod.z.object({
|
|
343
|
+
messageType: zod.z.literal("utf8").default("utf8"),
|
|
344
|
+
message: zod.z.string()
|
|
345
|
+
}));
|
|
346
|
+
const stxSignMessageRequestStructuredSchema = stxSignMessageRequestBaseSchema.and(zod.z.object({
|
|
347
|
+
messageType: zod.z.literal("structured"),
|
|
348
|
+
domain: zod.z.string(),
|
|
349
|
+
message: zod.z.string()
|
|
350
|
+
}));
|
|
351
|
+
const stxSignMessage = defineRpcEndpoint({
|
|
352
|
+
method: "stx_signMessage",
|
|
353
|
+
params: zod.z.union([stxSignMessageRequestUtf8Schema, stxSignMessageRequestStructuredSchema]),
|
|
354
|
+
result: zod.z.object({
|
|
355
|
+
signature: zod.z.string(),
|
|
356
|
+
publicKey: zod.z.string()
|
|
357
|
+
})
|
|
472
358
|
});
|
|
473
359
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/methods/stacks/stx-sign-structured-message.ts
|
|
362
|
+
const stxSignStructuredMessage = defineRpcEndpoint({
|
|
363
|
+
method: "stx_signStructuredMessage",
|
|
364
|
+
params: zod.z.object({
|
|
365
|
+
domain: zod.z.string(),
|
|
366
|
+
message: zod.z.string()
|
|
367
|
+
}),
|
|
368
|
+
result: zod.z.object({
|
|
369
|
+
signature: zod.z.string(),
|
|
370
|
+
publicKey: zod.z.string()
|
|
371
|
+
})
|
|
486
372
|
});
|
|
487
373
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
transaction: import_zod16.z.string(),
|
|
509
|
-
txHex: import_zod16.z.string()
|
|
510
|
-
})
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/methods/stacks/stx-sign-transaction.ts
|
|
376
|
+
const stxSignTransactionRequestLeatherRpcParamsSchema = zod.z.object({
|
|
377
|
+
txHex: zod.z.string(),
|
|
378
|
+
stxAddress: zod.z.string().optional(),
|
|
379
|
+
attachment: zod.z.string().optional(),
|
|
380
|
+
accountIndex: zod.z.string().optional(),
|
|
381
|
+
network: zod.z.string().optional()
|
|
382
|
+
});
|
|
383
|
+
const stxSignTransactionRequestSip30ParamsSchema = zod.z.object({
|
|
384
|
+
transaction: zod.z.string(),
|
|
385
|
+
network: zod.z.string().optional()
|
|
386
|
+
});
|
|
387
|
+
const stxSignTransaction = defineRpcEndpoint({
|
|
388
|
+
method: "stx_signTransaction",
|
|
389
|
+
params: zod.z.union([stxSignTransactionRequestLeatherRpcParamsSchema, stxSignTransactionRequestSip30ParamsSchema]),
|
|
390
|
+
result: zod.z.object({
|
|
391
|
+
transaction: zod.z.string(),
|
|
392
|
+
txHex: zod.z.string()
|
|
393
|
+
})
|
|
511
394
|
});
|
|
512
395
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
baseStacksTransactionConfigSchema
|
|
524
|
-
),
|
|
525
|
-
result: stacksTransactionDetailsSchema
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/methods/stacks/stx-transfer-sip9-nft.ts
|
|
398
|
+
const stxTransferSip9Nft = defineRpcEndpoint({
|
|
399
|
+
method: "stx_transferSip9Nft",
|
|
400
|
+
params: zod.z.intersection(zod.z.looseObject({
|
|
401
|
+
recipient: zod.z.string(),
|
|
402
|
+
asset: zod.z.string(),
|
|
403
|
+
assetId: zod.z.string()
|
|
404
|
+
}), baseStacksTransactionConfigSchema),
|
|
405
|
+
result: stacksTransactionDetailsSchema
|
|
526
406
|
});
|
|
527
407
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
baseStacksTransactionConfigSchema
|
|
539
|
-
),
|
|
540
|
-
result: stacksTransactionDetailsSchema
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/methods/stacks/stx-transfer-sip10-ft.ts
|
|
410
|
+
const stxTransferSip10Ft = defineRpcEndpoint({
|
|
411
|
+
method: "stx_transferSip10Ft",
|
|
412
|
+
params: zod.z.intersection(zod.z.looseObject({
|
|
413
|
+
recipient: zod.z.string(),
|
|
414
|
+
asset: zod.z.string(),
|
|
415
|
+
amount: zod.z.coerce.number()
|
|
416
|
+
}), baseStacksTransactionConfigSchema),
|
|
417
|
+
result: stacksTransactionDetailsSchema
|
|
541
418
|
});
|
|
542
419
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}),
|
|
554
|
-
baseStacksTransactionConfigSchema
|
|
555
|
-
),
|
|
556
|
-
result: stacksTransactionDetailsSchema
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/methods/stacks/stx-transfer-stx.ts
|
|
422
|
+
const stxTransferStx = defineRpcEndpoint({
|
|
423
|
+
method: "stx_transferStx",
|
|
424
|
+
params: zod.z.intersection(zod.z.object({
|
|
425
|
+
recipient: __leather_io_stacks.principalSchema,
|
|
426
|
+
amount: zod.z.coerce.number().int("Amount must be an integer describing µSTX"),
|
|
427
|
+
memo: __leather_io_stacks.stacksMemoSchema.optional()
|
|
428
|
+
}), baseStacksTransactionConfigSchema),
|
|
429
|
+
result: stacksTransactionDetailsSchema
|
|
557
430
|
});
|
|
558
431
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
method: "stx_updateProfile",
|
|
568
|
-
params: stxUpdateProfileRequestParamsSchema,
|
|
569
|
-
result: stxUpdateProfileResponseBodySchema
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/methods/stacks/stx-update-profile.ts
|
|
434
|
+
const stxUpdateProfileRequestParamsSchema = zod.z.object({ person: zod.z.looseObject({}) });
|
|
435
|
+
const stxUpdateProfileResponseBodySchema = stacksTransactionDetailsSchema;
|
|
436
|
+
const stxUpdateProfile = defineRpcEndpoint({
|
|
437
|
+
method: "stx_updateProfile",
|
|
438
|
+
params: stxUpdateProfileRequestParamsSchema,
|
|
439
|
+
result: stxUpdateProfileResponseBodySchema
|
|
570
440
|
});
|
|
571
441
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/methods/supported-methods.ts
|
|
444
|
+
const supportedMethodSchema = zod.z.object({
|
|
445
|
+
name: zod.z.string(),
|
|
446
|
+
docsUrl: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())])
|
|
447
|
+
});
|
|
448
|
+
const supportedMethods = defineRpcEndpoint({
|
|
449
|
+
method: "supportedMethods",
|
|
450
|
+
result: zod.z.object({
|
|
451
|
+
documentation: zod.z.string(),
|
|
452
|
+
methods: zod.z.array(supportedMethodSchema)
|
|
453
|
+
})
|
|
584
454
|
});
|
|
585
455
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
});
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
type: import_zod22.z.literal("utf8"),
|
|
622
|
-
value: import_zod22.z.string()
|
|
623
|
-
});
|
|
624
|
-
var cvOkSchema = import_zod22.z.object({
|
|
625
|
-
type: import_zod22.z.literal("ok"),
|
|
626
|
-
value: import_zod22.z.lazy(() => clarityValueSchema)
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/methods/stacks/_clarity-values.ts
|
|
458
|
+
const cvIntSchema = zod.z.object({
|
|
459
|
+
type: zod.z.literal("int"),
|
|
460
|
+
value: zod.z.coerce.string()
|
|
461
|
+
});
|
|
462
|
+
const cvUintSchema = zod.z.object({
|
|
463
|
+
type: zod.z.literal("uint"),
|
|
464
|
+
value: zod.z.coerce.string()
|
|
465
|
+
});
|
|
466
|
+
const cvBufferSchema = zod.z.object({
|
|
467
|
+
type: zod.z.literal("buffer"),
|
|
468
|
+
value: zod.z.string()
|
|
469
|
+
});
|
|
470
|
+
const cvTrueSchema = zod.z.object({ type: zod.z.literal("true") });
|
|
471
|
+
const cvFalseSchema = zod.z.object({ type: zod.z.literal("false") });
|
|
472
|
+
const cvAddressSchema = zod.z.object({
|
|
473
|
+
type: zod.z.literal("address"),
|
|
474
|
+
value: zod.z.string()
|
|
475
|
+
});
|
|
476
|
+
const cvContractSchema = zod.z.object({
|
|
477
|
+
type: zod.z.literal("contract"),
|
|
478
|
+
value: zod.z.string().refine((value) => value.includes("."), { message: "Stacks contract principals are denoted with a dot" })
|
|
479
|
+
});
|
|
480
|
+
const cvAsciiSchema = zod.z.object({
|
|
481
|
+
type: zod.z.literal("ascii"),
|
|
482
|
+
value: zod.z.string()
|
|
483
|
+
});
|
|
484
|
+
const cvUtf8Schema = zod.z.object({
|
|
485
|
+
type: zod.z.literal("utf8"),
|
|
486
|
+
value: zod.z.string()
|
|
487
|
+
});
|
|
488
|
+
const cvOkSchema = zod.z.object({
|
|
489
|
+
type: zod.z.literal("ok"),
|
|
490
|
+
value: zod.z.lazy(() => clarityValueSchema)
|
|
627
491
|
}).transform((value) => value);
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
cvSomeSchema,
|
|
662
|
-
cvListSchema,
|
|
663
|
-
cvTupleSchema,
|
|
664
|
-
cvAsciiSchema,
|
|
665
|
-
cvUtf8Schema
|
|
492
|
+
const cvErrSchema = zod.z.object({
|
|
493
|
+
type: zod.z.literal("err"),
|
|
494
|
+
value: zod.z.lazy(() => clarityValueSchema)
|
|
495
|
+
});
|
|
496
|
+
const cvNoneSchema = zod.z.object({ type: zod.z.literal("none") });
|
|
497
|
+
const cvSomeSchema = zod.z.object({
|
|
498
|
+
type: zod.z.literal("some"),
|
|
499
|
+
value: zod.z.lazy(() => clarityValueSchema)
|
|
500
|
+
});
|
|
501
|
+
const cvListSchema = zod.z.object({
|
|
502
|
+
type: zod.z.literal("list"),
|
|
503
|
+
value: zod.z.array(zod.z.lazy(() => clarityValueSchema))
|
|
504
|
+
});
|
|
505
|
+
const cvTupleSchema = zod.z.object({
|
|
506
|
+
type: zod.z.literal("tuple"),
|
|
507
|
+
value: zod.z.record(zod.z.string(), zod.z.lazy(() => clarityValueSchema))
|
|
508
|
+
});
|
|
509
|
+
const clarityValueSchema = zod.z.union([
|
|
510
|
+
cvIntSchema,
|
|
511
|
+
cvUintSchema,
|
|
512
|
+
cvBufferSchema,
|
|
513
|
+
cvTrueSchema,
|
|
514
|
+
cvFalseSchema,
|
|
515
|
+
cvAddressSchema,
|
|
516
|
+
cvContractSchema,
|
|
517
|
+
cvOkSchema,
|
|
518
|
+
cvErrSchema,
|
|
519
|
+
cvNoneSchema,
|
|
520
|
+
cvSomeSchema,
|
|
521
|
+
cvListSchema,
|
|
522
|
+
cvTupleSchema,
|
|
523
|
+
cvAsciiSchema,
|
|
524
|
+
cvUtf8Schema
|
|
666
525
|
]);
|
|
667
526
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region src/index.ts
|
|
529
|
+
const endpoints = {
|
|
530
|
+
getAddresses,
|
|
531
|
+
getInfo,
|
|
532
|
+
open,
|
|
533
|
+
openSwap,
|
|
534
|
+
sendTransfer,
|
|
535
|
+
signMessage,
|
|
536
|
+
signPsbt,
|
|
537
|
+
stxCallContract,
|
|
538
|
+
stxDeployContract,
|
|
539
|
+
stxGetAddresses,
|
|
540
|
+
stxGetNetworks,
|
|
541
|
+
stxSignMessage,
|
|
542
|
+
stxSignStructuredMessage,
|
|
543
|
+
stxSignTransaction,
|
|
544
|
+
stxTransferSip10Ft,
|
|
545
|
+
stxTransferSip9Nft,
|
|
546
|
+
stxTransferStx,
|
|
547
|
+
stxUpdateProfile,
|
|
548
|
+
supportedMethods
|
|
689
549
|
};
|
|
550
|
+
/**
|
|
551
|
+
* Helper to create a successful RPC response object
|
|
552
|
+
*/
|
|
690
553
|
function createRpcSuccessResponse(_method, response) {
|
|
691
|
-
|
|
554
|
+
return {
|
|
555
|
+
jsonrpc: "2.0",
|
|
556
|
+
...response
|
|
557
|
+
};
|
|
692
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Helper to create an error RPC response object
|
|
561
|
+
*/
|
|
693
562
|
function createRpcErrorResponse(_method, error) {
|
|
694
|
-
|
|
563
|
+
return {
|
|
564
|
+
jsonrpc: "2.0",
|
|
565
|
+
...error
|
|
566
|
+
};
|
|
695
567
|
}
|
|
696
568
|
function parseEndpointRequest(data) {
|
|
697
|
-
|
|
698
|
-
const endpoint = endpointRequests.find((req) => req.safeParse(data).success);
|
|
699
|
-
return endpoint?.safeParse(data).data;
|
|
569
|
+
return Object.values(endpoints).map((endpoint) => endpoint.request).find((req) => req.safeParse(data).success)?.safeParse(data).data;
|
|
700
570
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
});
|
|
782
|
-
//# sourceMappingURL=index.cjs.map
|
|
571
|
+
|
|
572
|
+
//#endregion
|
|
573
|
+
exports.Bip322MessageTypesSchema = Bip322MessageTypesSchema;
|
|
574
|
+
exports.RpcErrorCode = RpcErrorCode;
|
|
575
|
+
exports.addressResponseBodySchema = addressResponseBodySchema;
|
|
576
|
+
exports.addressSchema = addressSchema;
|
|
577
|
+
exports.baseStacksTransactionConfigSchema = baseStacksTransactionConfigSchema;
|
|
578
|
+
exports.bitcoinPaymentTypesSchema = bitcoinPaymentTypesSchema;
|
|
579
|
+
exports.btcAddressBaseSchema = btcAddressBaseSchema;
|
|
580
|
+
exports.btcAddressSchema = btcAddressSchema;
|
|
581
|
+
exports.clarityValueSchema = clarityValueSchema;
|
|
582
|
+
exports.createRequestEncoder = createRequestEncoder;
|
|
583
|
+
exports.createRpcErrorBodySchema = createRpcErrorBodySchema;
|
|
584
|
+
exports.createRpcErrorResponse = createRpcErrorResponse;
|
|
585
|
+
exports.createRpcErrorResponseSchema = createRpcErrorResponseSchema;
|
|
586
|
+
exports.createRpcRequestSchema = createRpcRequestSchema;
|
|
587
|
+
exports.createRpcResponseSchema = createRpcResponseSchema;
|
|
588
|
+
exports.createRpcSuccessResponse = createRpcSuccessResponse;
|
|
589
|
+
exports.createRpcSuccessResponseSchema = createRpcSuccessResponseSchema;
|
|
590
|
+
exports.cvAddressSchema = cvAddressSchema;
|
|
591
|
+
exports.cvAsciiSchema = cvAsciiSchema;
|
|
592
|
+
exports.cvBufferSchema = cvBufferSchema;
|
|
593
|
+
exports.cvContractSchema = cvContractSchema;
|
|
594
|
+
exports.cvErrSchema = cvErrSchema;
|
|
595
|
+
exports.cvFalseSchema = cvFalseSchema;
|
|
596
|
+
exports.cvIntSchema = cvIntSchema;
|
|
597
|
+
exports.cvListSchema = cvListSchema;
|
|
598
|
+
exports.cvNoneSchema = cvNoneSchema;
|
|
599
|
+
exports.cvOkSchema = cvOkSchema;
|
|
600
|
+
exports.cvSomeSchema = cvSomeSchema;
|
|
601
|
+
exports.cvTrueSchema = cvTrueSchema;
|
|
602
|
+
exports.cvTupleSchema = cvTupleSchema;
|
|
603
|
+
exports.cvUintSchema = cvUintSchema;
|
|
604
|
+
exports.cvUtf8Schema = cvUtf8Schema;
|
|
605
|
+
exports.decodeBase64Json = decodeBase64Json;
|
|
606
|
+
exports.defaultErrorSchema = defaultErrorSchema;
|
|
607
|
+
exports.defineRpcEndpoint = defineRpcEndpoint;
|
|
608
|
+
exports.encodeBase64Json = encodeBase64Json;
|
|
609
|
+
exports.endpoints = endpoints;
|
|
610
|
+
exports.getAddresses = getAddresses;
|
|
611
|
+
exports.getInfo = getInfo;
|
|
612
|
+
exports.open = open;
|
|
613
|
+
exports.openSwap = openSwap;
|
|
614
|
+
exports.parseEndpointRequest = parseEndpointRequest;
|
|
615
|
+
exports.rpcBasePropsSchema = rpcBasePropsSchema;
|
|
616
|
+
exports.rpcParameterSchema = rpcParameterSchema;
|
|
617
|
+
exports.rpcSendTransferLegacyParamSchema = rpcSendTransferLegacyParamSchema;
|
|
618
|
+
exports.rpcSendTransferNewParamsSchema = rpcSendTransferNewParamsSchema;
|
|
619
|
+
exports.rpcSendTransferParamsSchema = rpcSendTransferParamsSchema;
|
|
620
|
+
exports.sendTransfer = sendTransfer;
|
|
621
|
+
exports.signMessage = signMessage;
|
|
622
|
+
exports.signMessageRequestParamsSchema = signMessageRequestParamsSchema;
|
|
623
|
+
exports.signPsbt = signPsbt;
|
|
624
|
+
exports.signatureHash = signatureHash;
|
|
625
|
+
exports.stacksTransactionDetailsSchema = stacksTransactionDetailsSchema;
|
|
626
|
+
exports.stxAddressItemSchema = stxAddressItemSchema;
|
|
627
|
+
exports.stxAddressSchema = stxAddressSchema;
|
|
628
|
+
exports.stxCallContract = stxCallContract;
|
|
629
|
+
exports.stxDeployContract = stxDeployContract;
|
|
630
|
+
exports.stxDeployContractResponseBodySchema = stxDeployContractResponseBodySchema;
|
|
631
|
+
exports.stxGetAddresses = stxGetAddresses;
|
|
632
|
+
exports.stxGetAddressesResponseBodySchema = stxGetAddressesResponseBodySchema;
|
|
633
|
+
exports.stxSignMessage = stxSignMessage;
|
|
634
|
+
exports.stxSignMessageRequestBaseSchema = stxSignMessageRequestBaseSchema;
|
|
635
|
+
exports.stxSignMessageRequestStructuredSchema = stxSignMessageRequestStructuredSchema;
|
|
636
|
+
exports.stxSignMessageRequestUtf8Schema = stxSignMessageRequestUtf8Schema;
|
|
637
|
+
exports.stxSignMessageTypeSchema = stxSignMessageTypeSchema;
|
|
638
|
+
exports.stxSignStructuredMessage = stxSignStructuredMessage;
|
|
639
|
+
exports.stxSignTransaction = stxSignTransaction;
|
|
640
|
+
exports.stxSignTransactionRequestLeatherRpcParamsSchema = stxSignTransactionRequestLeatherRpcParamsSchema;
|
|
641
|
+
exports.stxSignTransactionRequestSip30ParamsSchema = stxSignTransactionRequestSip30ParamsSchema;
|
|
642
|
+
exports.stxTransferSip10Ft = stxTransferSip10Ft;
|
|
643
|
+
exports.stxTransferSip9Nft = stxTransferSip9Nft;
|
|
644
|
+
exports.stxTransferStx = stxTransferStx;
|
|
645
|
+
exports.stxUpdateProfile = stxUpdateProfile;
|
|
646
|
+
exports.stxUpdateProfileRequestParamsSchema = stxUpdateProfileRequestParamsSchema;
|
|
647
|
+
exports.stxUpdateProfileResponseBodySchema = stxUpdateProfileResponseBodySchema;
|
|
648
|
+
exports.supportedMethodSchema = supportedMethodSchema;
|
|
649
|
+
exports.supportedMethods = supportedMethods;
|
|
650
|
+
exports.testIsNumberOrArrayOfNumbers = testIsNumberOrArrayOfNumbers;
|