@sats-connect/core 0.4.0-ff58e17 → 0.4.1-06b81c7
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 +589 -554
- package/dist/index.d.ts +589 -554
- package/dist/index.js +717 -312
- package/dist/index.mjs +669 -301
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -27,8 +27,7 @@ async function getProviderOrThrow(getProvider) {
|
|
|
27
27
|
return provider;
|
|
28
28
|
}
|
|
29
29
|
function getProviders() {
|
|
30
|
-
if (!window.btc_providers)
|
|
31
|
-
window.btc_providers = [];
|
|
30
|
+
if (!window.btc_providers) window.btc_providers = [];
|
|
32
31
|
return window.btc_providers;
|
|
33
32
|
}
|
|
34
33
|
function getProviderById(providerId) {
|
|
@@ -47,10 +46,7 @@ function removeDefaultProvider() {
|
|
|
47
46
|
localStorage.removeItem("sats-connect_defaultProvider");
|
|
48
47
|
}
|
|
49
48
|
function getSupportedWallets() {
|
|
50
|
-
const
|
|
51
|
-
const { xverse, ...defaultProviders } = DefaultAdaptersInfo;
|
|
52
|
-
const allProviders = [...ambientProviders, ...Object.values(defaultProviders)];
|
|
53
|
-
const wallets = allProviders.map((provider) => {
|
|
49
|
+
const wallets = Object.values(DefaultAdaptersInfo).map((provider) => {
|
|
54
50
|
{
|
|
55
51
|
return {
|
|
56
52
|
...provider,
|
|
@@ -63,11 +59,11 @@ function getSupportedWallets() {
|
|
|
63
59
|
|
|
64
60
|
// src/types.ts
|
|
65
61
|
import * as v2 from "valibot";
|
|
66
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return
|
|
62
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
63
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
64
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
65
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
66
|
+
return BitcoinNetworkType2;
|
|
71
67
|
})(BitcoinNetworkType || {});
|
|
72
68
|
var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
|
|
73
69
|
var rpcRequestMessageSchema = v2.object({
|
|
@@ -84,7 +80,7 @@ var rpcRequestMessageSchema = v2.object({
|
|
|
84
80
|
v2.null()
|
|
85
81
|
])
|
|
86
82
|
),
|
|
87
|
-
id: RpcIdSchema
|
|
83
|
+
id: v2.unwrap(RpcIdSchema)
|
|
88
84
|
});
|
|
89
85
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
90
86
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -113,16 +109,127 @@ var rpcResponseMessageSchema = v2.union([
|
|
|
113
109
|
]);
|
|
114
110
|
|
|
115
111
|
// src/request/index.ts
|
|
116
|
-
import * as
|
|
112
|
+
import * as v21 from "valibot";
|
|
113
|
+
|
|
114
|
+
// src/request/types/stxMethods/callContract.ts
|
|
115
|
+
import * as v3 from "valibot";
|
|
116
|
+
var stxCallContractMethodName = "stx_callContract";
|
|
117
|
+
var stxCallContractParamsSchema = v3.object({
|
|
118
|
+
/**
|
|
119
|
+
* The contract principal.
|
|
120
|
+
*
|
|
121
|
+
* E.g. `"SPKE...GD5C.my-contract"`
|
|
122
|
+
*/
|
|
123
|
+
contract: v3.string(),
|
|
124
|
+
/**
|
|
125
|
+
* The name of the function to call.
|
|
126
|
+
*
|
|
127
|
+
* Note: spec changes ongoing,
|
|
128
|
+
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
129
|
+
*/
|
|
130
|
+
functionName: v3.string(),
|
|
131
|
+
/**
|
|
132
|
+
* The function's arguments. The arguments are expected to be hex-encoded
|
|
133
|
+
* strings of Clarity values.
|
|
134
|
+
*
|
|
135
|
+
* To convert Clarity values to their hex representation, the `cvToString`
|
|
136
|
+
* helper from the `@stacks/transactions` package may be helpful.
|
|
137
|
+
*
|
|
138
|
+
* ```js
|
|
139
|
+
* import { cvToString } from '@stacks/transactions';
|
|
140
|
+
*
|
|
141
|
+
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
142
|
+
* const hexArgs = functionArgs.map(cvToString);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
arguments: v3.optional(v3.array(v3.string()))
|
|
146
|
+
});
|
|
147
|
+
var stxCallContractResultSchema = v3.object({
|
|
148
|
+
/**
|
|
149
|
+
* The ID of the transaction.
|
|
150
|
+
*/
|
|
151
|
+
txid: v3.string(),
|
|
152
|
+
/**
|
|
153
|
+
* A Stacks transaction as a hex-encoded string.
|
|
154
|
+
*/
|
|
155
|
+
transaction: v3.string()
|
|
156
|
+
});
|
|
157
|
+
var stxCallContractRequestMessageSchema = v3.object({
|
|
158
|
+
...rpcRequestMessageSchema.entries,
|
|
159
|
+
...v3.object({
|
|
160
|
+
method: v3.literal(stxCallContractMethodName),
|
|
161
|
+
params: stxCallContractParamsSchema,
|
|
162
|
+
id: v3.string()
|
|
163
|
+
}).entries
|
|
164
|
+
});
|
|
117
165
|
|
|
118
|
-
// src/request/types/stxMethods.ts
|
|
166
|
+
// src/request/types/stxMethods/deployContract.ts
|
|
119
167
|
import * as v4 from "valibot";
|
|
168
|
+
var stxDeployContractMethodName = "stx_deployContract";
|
|
169
|
+
var stxDeployContractParamsSchema = v4.object({
|
|
170
|
+
/**
|
|
171
|
+
* Name of the contract.
|
|
172
|
+
*/
|
|
173
|
+
name: v4.string(),
|
|
174
|
+
/**
|
|
175
|
+
* The source code of the Clarity contract.
|
|
176
|
+
*/
|
|
177
|
+
clarityCode: v4.string(),
|
|
178
|
+
/**
|
|
179
|
+
* The version of the Clarity contract.
|
|
180
|
+
*/
|
|
181
|
+
clarityVersion: v4.optional(v4.string())
|
|
182
|
+
});
|
|
183
|
+
var stxDeployContractResultSchema = v4.object({
|
|
184
|
+
/**
|
|
185
|
+
* The ID of the transaction.
|
|
186
|
+
*/
|
|
187
|
+
txid: v4.string(),
|
|
188
|
+
/**
|
|
189
|
+
* A Stacks transaction as a hex-encoded string.
|
|
190
|
+
*/
|
|
191
|
+
transaction: v4.string()
|
|
192
|
+
});
|
|
193
|
+
var stxDeployContractRequestMessageSchema = v4.object({
|
|
194
|
+
...rpcRequestMessageSchema.entries,
|
|
195
|
+
...v4.object({
|
|
196
|
+
method: v4.literal(stxDeployContractMethodName),
|
|
197
|
+
params: stxDeployContractParamsSchema,
|
|
198
|
+
id: v4.string()
|
|
199
|
+
}).entries
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// src/request/types/stxMethods/getAccounts.ts
|
|
203
|
+
import * as v5 from "valibot";
|
|
204
|
+
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
205
|
+
var stxGetAccountsParamsSchema = v5.nullish(v5.null());
|
|
206
|
+
var stxGetAccountsResultSchema = v5.object({
|
|
207
|
+
/**
|
|
208
|
+
* The addresses generated for the given purposes.
|
|
209
|
+
*/
|
|
210
|
+
addresses: v5.array(
|
|
211
|
+
v5.object({
|
|
212
|
+
address: v5.string(),
|
|
213
|
+
publicKey: v5.string(),
|
|
214
|
+
gaiaHubUrl: v5.string(),
|
|
215
|
+
gaiaAppKey: v5.string()
|
|
216
|
+
})
|
|
217
|
+
)
|
|
218
|
+
});
|
|
219
|
+
var stxGetAccountsRequestMessageSchema = v5.object({
|
|
220
|
+
...rpcRequestMessageSchema.entries,
|
|
221
|
+
...v5.object({
|
|
222
|
+
method: v5.literal(stxGetAccountsMethodName),
|
|
223
|
+
params: stxGetAccountsParamsSchema,
|
|
224
|
+
id: v5.string()
|
|
225
|
+
}).entries
|
|
226
|
+
});
|
|
120
227
|
|
|
121
228
|
// src/addresses/index.ts
|
|
122
229
|
import { createUnsecuredToken } from "jsontokens";
|
|
123
230
|
|
|
124
231
|
// src/addresses/types.ts
|
|
125
|
-
import * as
|
|
232
|
+
import * as v6 from "valibot";
|
|
126
233
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
127
234
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
128
235
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -138,11 +245,11 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
138
245
|
AddressType3["stacks"] = "stacks";
|
|
139
246
|
return AddressType3;
|
|
140
247
|
})(AddressType || {});
|
|
141
|
-
var addressSchema =
|
|
142
|
-
address:
|
|
143
|
-
publicKey:
|
|
144
|
-
purpose:
|
|
145
|
-
addressType:
|
|
248
|
+
var addressSchema = v6.object({
|
|
249
|
+
address: v6.string(),
|
|
250
|
+
publicKey: v6.string(),
|
|
251
|
+
purpose: v6.enum(AddressPurpose),
|
|
252
|
+
addressType: v6.enum(AddressType)
|
|
146
253
|
});
|
|
147
254
|
|
|
148
255
|
// src/addresses/index.ts
|
|
@@ -162,167 +269,301 @@ var getAddress = async (options) => {
|
|
|
162
269
|
}
|
|
163
270
|
};
|
|
164
271
|
|
|
165
|
-
// src/request/types/stxMethods.ts
|
|
166
|
-
|
|
167
|
-
var
|
|
272
|
+
// src/request/types/stxMethods/getAddresses.ts
|
|
273
|
+
import * as v7 from "valibot";
|
|
274
|
+
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
275
|
+
var stxGetAddressesParamsSchema = v7.nullish(
|
|
276
|
+
v7.object({
|
|
277
|
+
/**
|
|
278
|
+
* A message to be displayed to the user in the request prompt.
|
|
279
|
+
*/
|
|
280
|
+
message: v7.optional(v7.string())
|
|
281
|
+
})
|
|
282
|
+
);
|
|
283
|
+
var stxGetAddressesResultSchema = v7.object({
|
|
168
284
|
/**
|
|
169
|
-
* The
|
|
170
|
-
|
|
171
|
-
|
|
285
|
+
* The addresses generated for the given purposes.
|
|
286
|
+
*/
|
|
287
|
+
addresses: v7.array(addressSchema)
|
|
288
|
+
});
|
|
289
|
+
var stxGetAddressesRequestMessageSchema = v7.object({
|
|
290
|
+
...rpcRequestMessageSchema.entries,
|
|
291
|
+
...v7.object({
|
|
292
|
+
method: v7.literal(stxGetAddressesMethodName),
|
|
293
|
+
params: stxGetAddressesParamsSchema,
|
|
294
|
+
id: v7.string()
|
|
295
|
+
}).entries
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// src/request/types/stxMethods/signMessage.ts
|
|
299
|
+
import * as v8 from "valibot";
|
|
300
|
+
var stxSignMessageMethodName = "stx_signMessage";
|
|
301
|
+
var stxSignMessageParamsSchema = v8.object({
|
|
302
|
+
/**
|
|
303
|
+
* The message to sign.
|
|
172
304
|
*/
|
|
173
|
-
|
|
305
|
+
message: v8.string(),
|
|
174
306
|
/**
|
|
175
|
-
* The
|
|
176
|
-
*
|
|
177
|
-
* Note: spec changes ongoing,
|
|
178
|
-
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
307
|
+
* The public key to sign the message with.
|
|
179
308
|
*/
|
|
180
|
-
|
|
309
|
+
publicKey: v8.string(),
|
|
181
310
|
/**
|
|
182
|
-
* The
|
|
183
|
-
* strings of Clarity values.
|
|
184
|
-
*
|
|
185
|
-
* To convert Clarity values to their hex representation, the `cvToString`
|
|
186
|
-
* helper from the `@stacks/transactions` package may be helpful.
|
|
187
|
-
*
|
|
188
|
-
* ```js
|
|
189
|
-
* import { cvToString } from '@stacks/transactions';
|
|
190
|
-
*
|
|
191
|
-
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
192
|
-
* const hexArgs = functionArgs.map(cvToString);
|
|
193
|
-
* ```
|
|
311
|
+
* The format version of the parameter.
|
|
194
312
|
*/
|
|
195
|
-
|
|
313
|
+
parameterFormatVersion: v8.optional(v8.number())
|
|
196
314
|
});
|
|
197
|
-
var
|
|
315
|
+
var stxSignMessageResultSchema = v8.object({
|
|
198
316
|
/**
|
|
199
|
-
* The
|
|
317
|
+
* The signature of the message.
|
|
200
318
|
*/
|
|
201
|
-
|
|
319
|
+
signature: v8.string(),
|
|
202
320
|
/**
|
|
203
|
-
*
|
|
321
|
+
* The public key used to sign the message.
|
|
204
322
|
*/
|
|
205
|
-
|
|
323
|
+
publicKey: v8.string()
|
|
206
324
|
});
|
|
207
|
-
var
|
|
325
|
+
var stxSignMessageRequestMessageSchema = v8.object({
|
|
208
326
|
...rpcRequestMessageSchema.entries,
|
|
209
|
-
...
|
|
210
|
-
method:
|
|
211
|
-
params:
|
|
212
|
-
id:
|
|
327
|
+
...v8.object({
|
|
328
|
+
method: v8.literal(stxSignMessageMethodName),
|
|
329
|
+
params: stxSignMessageParamsSchema,
|
|
330
|
+
id: v8.string()
|
|
213
331
|
}).entries
|
|
214
332
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
*/
|
|
221
|
-
message: v4.optional(v4.string())
|
|
222
|
-
})
|
|
223
|
-
);
|
|
224
|
-
var stxGetAddressesResultSchema = v4.object({
|
|
333
|
+
|
|
334
|
+
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
335
|
+
import * as v9 from "valibot";
|
|
336
|
+
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
337
|
+
var stxSignStructuredMessageParamsSchema = v9.object({
|
|
225
338
|
/**
|
|
226
|
-
* The
|
|
339
|
+
* The domain to be signed.
|
|
340
|
+
*/
|
|
341
|
+
domain: v9.string(),
|
|
342
|
+
/**
|
|
343
|
+
* Message payload to be signed.
|
|
344
|
+
*/
|
|
345
|
+
message: v9.string(),
|
|
346
|
+
/**
|
|
347
|
+
* The format version of the parameter.
|
|
227
348
|
*/
|
|
228
|
-
|
|
349
|
+
parameterFormatVersion: v9.optional(v9.number()),
|
|
350
|
+
/**
|
|
351
|
+
* The public key to sign the message with.
|
|
352
|
+
*/
|
|
353
|
+
publicKey: v9.optional(v9.string())
|
|
354
|
+
});
|
|
355
|
+
var stxSignStructuredMessageResultSchema = v9.object({
|
|
356
|
+
/**
|
|
357
|
+
* Signature of the message.
|
|
358
|
+
*/
|
|
359
|
+
signature: v9.string(),
|
|
360
|
+
/**
|
|
361
|
+
* Public key as hex-encoded string.
|
|
362
|
+
*/
|
|
363
|
+
publicKey: v9.string()
|
|
229
364
|
});
|
|
230
|
-
var
|
|
365
|
+
var stxSignStructuredMessageRequestMessageSchema = v9.object({
|
|
231
366
|
...rpcRequestMessageSchema.entries,
|
|
232
|
-
...
|
|
233
|
-
method:
|
|
234
|
-
params:
|
|
235
|
-
id:
|
|
367
|
+
...v9.object({
|
|
368
|
+
method: v9.literal(stxSignStructuredMessageMethodName),
|
|
369
|
+
params: stxSignStructuredMessageParamsSchema,
|
|
370
|
+
id: v9.string()
|
|
236
371
|
}).entries
|
|
237
372
|
});
|
|
373
|
+
|
|
374
|
+
// src/request/types/stxMethods/signTransaction.ts
|
|
375
|
+
import * as v10 from "valibot";
|
|
238
376
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
239
|
-
var stxSignTransactionParamsSchema =
|
|
377
|
+
var stxSignTransactionParamsSchema = v10.object({
|
|
240
378
|
/**
|
|
241
379
|
* The transaction to sign as a hex-encoded string.
|
|
242
380
|
*/
|
|
243
|
-
transaction:
|
|
381
|
+
transaction: v10.string(),
|
|
244
382
|
/**
|
|
245
383
|
* The public key to sign the transaction with. The wallet may use any key
|
|
246
384
|
* when not provided.
|
|
247
385
|
*/
|
|
248
|
-
pubkey:
|
|
386
|
+
pubkey: v10.optional(v10.string()),
|
|
249
387
|
/**
|
|
250
388
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
251
389
|
*/
|
|
252
|
-
broadcast:
|
|
390
|
+
broadcast: v10.optional(v10.boolean())
|
|
253
391
|
});
|
|
254
|
-
var stxSignTransactionResultSchema =
|
|
392
|
+
var stxSignTransactionResultSchema = v10.object({
|
|
255
393
|
/**
|
|
256
394
|
* The signed transaction as a hex-encoded string.
|
|
257
395
|
*/
|
|
258
|
-
transaction:
|
|
396
|
+
transaction: v10.string()
|
|
259
397
|
});
|
|
260
|
-
var stxSignTransactionRequestMessageSchema =
|
|
398
|
+
var stxSignTransactionRequestMessageSchema = v10.object({
|
|
261
399
|
...rpcRequestMessageSchema.entries,
|
|
262
|
-
...
|
|
263
|
-
method:
|
|
400
|
+
...v10.object({
|
|
401
|
+
method: v10.literal(stxSignTransactionMethodName),
|
|
264
402
|
params: stxSignTransactionParamsSchema,
|
|
265
|
-
id:
|
|
403
|
+
id: v10.string()
|
|
404
|
+
}).entries
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// src/request/types/stxMethods/signTransactions.ts
|
|
408
|
+
import * as v11 from "valibot";
|
|
409
|
+
var stxSignTransactionsMethodName = "stx_signTransactions";
|
|
410
|
+
var stxSignTransactionsParamsSchema = v11.object({
|
|
411
|
+
/**
|
|
412
|
+
* The transactions to sign as hex-encoded strings.
|
|
413
|
+
*/
|
|
414
|
+
transactions: v11.array(
|
|
415
|
+
v11.object({
|
|
416
|
+
transactionHex: v11.string(),
|
|
417
|
+
/**
|
|
418
|
+
* Whether the transaction should be broadcast after signing. Defaults to `false`.
|
|
419
|
+
*/
|
|
420
|
+
broadcast: v11.optional(v11.boolean())
|
|
421
|
+
})
|
|
422
|
+
)
|
|
423
|
+
});
|
|
424
|
+
var stxSignTransactionsResultSchema = v11.object({
|
|
425
|
+
/**
|
|
426
|
+
* The signed transactions as hex-encoded strings. In the same order as the sign request.
|
|
427
|
+
*/
|
|
428
|
+
transactions: v11.array(v11.string())
|
|
429
|
+
});
|
|
430
|
+
var stxSignTransactionsRequestMessageSchema = v11.object({
|
|
431
|
+
...rpcRequestMessageSchema.entries,
|
|
432
|
+
...v11.object({
|
|
433
|
+
method: v11.literal(stxSignTransactionsMethodName),
|
|
434
|
+
params: stxSignTransactionsParamsSchema,
|
|
435
|
+
id: v11.string()
|
|
436
|
+
}).entries
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
// src/request/types/stxMethods/transferStx.ts
|
|
440
|
+
import * as v12 from "valibot";
|
|
441
|
+
var stxTransferStxMethodName = "stx_transferStx";
|
|
442
|
+
var stxTransferStxParamsSchema = v12.object({
|
|
443
|
+
/**
|
|
444
|
+
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
445
|
+
* parseable by `BigInt` is acceptable.
|
|
446
|
+
*
|
|
447
|
+
* Example,
|
|
448
|
+
*
|
|
449
|
+
* ```js
|
|
450
|
+
* const amount1 = 1234;
|
|
451
|
+
* const amount2 = 1234n;
|
|
452
|
+
* const amount3 = '1234';
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
amount: v12.union([v12.number(), v12.string()]),
|
|
456
|
+
/**
|
|
457
|
+
* The recipeint's principal.
|
|
458
|
+
*/
|
|
459
|
+
recipient: v12.string(),
|
|
460
|
+
/**
|
|
461
|
+
* A string representing the memo.
|
|
462
|
+
*/
|
|
463
|
+
memo: v12.optional(v12.string()),
|
|
464
|
+
/**
|
|
465
|
+
* Version of parameter format.
|
|
466
|
+
*/
|
|
467
|
+
version: v12.optional(v12.string()),
|
|
468
|
+
/**
|
|
469
|
+
* The mode of the post conditions.
|
|
470
|
+
*/
|
|
471
|
+
postConditionMode: v12.optional(v12.number()),
|
|
472
|
+
/**
|
|
473
|
+
* A hex-encoded string representing the post conditions.
|
|
474
|
+
*
|
|
475
|
+
* A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
|
|
476
|
+
*
|
|
477
|
+
* ```js
|
|
478
|
+
* import { serializePostCondition } from '@stacks/transactions';
|
|
479
|
+
*
|
|
480
|
+
* const postCondition = somePostCondition;
|
|
481
|
+
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
postConditions: v12.optional(v12.array(v12.string())),
|
|
485
|
+
/**
|
|
486
|
+
* The public key to sign the transaction with. The wallet may use any key
|
|
487
|
+
* when not provided.
|
|
488
|
+
*/
|
|
489
|
+
pubkey: v12.optional(v12.string())
|
|
490
|
+
});
|
|
491
|
+
var stxTransferStxResultSchema = v12.object({
|
|
492
|
+
/**
|
|
493
|
+
* The ID of the transaction.
|
|
494
|
+
*/
|
|
495
|
+
txid: v12.string(),
|
|
496
|
+
/**
|
|
497
|
+
* A Stacks transaction as a hex-encoded string.
|
|
498
|
+
*/
|
|
499
|
+
transaction: v12.string()
|
|
500
|
+
});
|
|
501
|
+
var stxTransferStxRequestMessageSchema = v12.object({
|
|
502
|
+
...rpcRequestMessageSchema.entries,
|
|
503
|
+
...v12.object({
|
|
504
|
+
method: v12.literal(stxTransferStxMethodName),
|
|
505
|
+
params: stxTransferStxParamsSchema,
|
|
506
|
+
id: v12.string()
|
|
266
507
|
}).entries
|
|
267
508
|
});
|
|
268
509
|
|
|
269
510
|
// src/request/types/btcMethods.ts
|
|
270
|
-
import * as
|
|
511
|
+
import * as v14 from "valibot";
|
|
271
512
|
|
|
272
513
|
// src/request/types/common.ts
|
|
273
|
-
import * as
|
|
514
|
+
import * as v13 from "valibot";
|
|
274
515
|
var walletTypes = ["software", "ledger"];
|
|
275
|
-
var walletTypeSchema =
|
|
516
|
+
var walletTypeSchema = v13.picklist(walletTypes);
|
|
276
517
|
|
|
277
518
|
// src/request/types/btcMethods.ts
|
|
278
519
|
var getInfoMethodName = "getInfo";
|
|
279
|
-
var getInfoParamsSchema =
|
|
280
|
-
var getInfoResultSchema =
|
|
520
|
+
var getInfoParamsSchema = v14.nullish(v14.null());
|
|
521
|
+
var getInfoResultSchema = v14.object({
|
|
281
522
|
/**
|
|
282
523
|
* Version of the wallet.
|
|
283
524
|
*/
|
|
284
|
-
version:
|
|
525
|
+
version: v14.string(),
|
|
285
526
|
/**
|
|
286
527
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
287
528
|
*/
|
|
288
|
-
methods:
|
|
529
|
+
methods: v14.optional(v14.array(v14.string())),
|
|
289
530
|
/**
|
|
290
531
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
291
532
|
*/
|
|
292
|
-
supports:
|
|
533
|
+
supports: v14.array(v14.string())
|
|
293
534
|
});
|
|
294
|
-
var getInfoRequestMessageSchema =
|
|
535
|
+
var getInfoRequestMessageSchema = v14.object({
|
|
295
536
|
...rpcRequestMessageSchema.entries,
|
|
296
|
-
...
|
|
297
|
-
method:
|
|
537
|
+
...v14.object({
|
|
538
|
+
method: v14.literal(getInfoMethodName),
|
|
298
539
|
params: getInfoParamsSchema,
|
|
299
|
-
id:
|
|
540
|
+
id: v14.string()
|
|
300
541
|
}).entries
|
|
301
542
|
});
|
|
302
543
|
var getAddressesMethodName = "getAddresses";
|
|
303
|
-
var getAddressesParamsSchema =
|
|
544
|
+
var getAddressesParamsSchema = v14.object({
|
|
304
545
|
/**
|
|
305
546
|
* The purposes for which to generate addresses. See
|
|
306
547
|
* {@linkcode AddressPurpose} for available purposes.
|
|
307
548
|
*/
|
|
308
|
-
purposes:
|
|
549
|
+
purposes: v14.array(v14.enum(AddressPurpose)),
|
|
309
550
|
/**
|
|
310
551
|
* A message to be displayed to the user in the request prompt.
|
|
311
552
|
*/
|
|
312
|
-
message:
|
|
553
|
+
message: v14.optional(v14.string())
|
|
313
554
|
});
|
|
314
|
-
var getAddressesResultSchema =
|
|
555
|
+
var getAddressesResultSchema = v14.object({
|
|
315
556
|
/**
|
|
316
557
|
* The addresses generated for the given purposes.
|
|
317
558
|
*/
|
|
318
|
-
addresses:
|
|
559
|
+
addresses: v14.array(addressSchema)
|
|
319
560
|
});
|
|
320
|
-
var getAddressesRequestMessageSchema =
|
|
561
|
+
var getAddressesRequestMessageSchema = v14.object({
|
|
321
562
|
...rpcRequestMessageSchema.entries,
|
|
322
|
-
...
|
|
323
|
-
method:
|
|
563
|
+
...v14.object({
|
|
564
|
+
method: v14.literal(getAddressesMethodName),
|
|
324
565
|
params: getAddressesParamsSchema,
|
|
325
|
-
id:
|
|
566
|
+
id: v14.string()
|
|
326
567
|
}).entries
|
|
327
568
|
});
|
|
328
569
|
var signMessageMethodName = "signMessage";
|
|
@@ -331,364 +572,456 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
|
|
|
331
572
|
MessageSigningProtocols2["BIP322"] = "BIP322";
|
|
332
573
|
return MessageSigningProtocols2;
|
|
333
574
|
})(MessageSigningProtocols || {});
|
|
334
|
-
var signMessageParamsSchema =
|
|
575
|
+
var signMessageParamsSchema = v14.object({
|
|
335
576
|
/**
|
|
336
577
|
* The address used for signing.
|
|
337
578
|
**/
|
|
338
|
-
address:
|
|
579
|
+
address: v14.string(),
|
|
339
580
|
/**
|
|
340
581
|
* The message to sign.
|
|
341
582
|
**/
|
|
342
|
-
message:
|
|
583
|
+
message: v14.string(),
|
|
343
584
|
/**
|
|
344
585
|
* The protocol to use for signing the message.
|
|
345
586
|
*/
|
|
346
|
-
protocol:
|
|
587
|
+
protocol: v14.optional(v14.enum(MessageSigningProtocols))
|
|
347
588
|
});
|
|
348
|
-
var signMessageResultSchema =
|
|
589
|
+
var signMessageResultSchema = v14.object({
|
|
349
590
|
/**
|
|
350
591
|
* The signature of the message.
|
|
351
592
|
*/
|
|
352
|
-
signature:
|
|
593
|
+
signature: v14.string(),
|
|
353
594
|
/**
|
|
354
595
|
* hash of the message.
|
|
355
596
|
*/
|
|
356
|
-
messageHash:
|
|
597
|
+
messageHash: v14.string(),
|
|
357
598
|
/**
|
|
358
599
|
* The address used for signing.
|
|
359
600
|
*/
|
|
360
|
-
address:
|
|
601
|
+
address: v14.string(),
|
|
361
602
|
/**
|
|
362
603
|
* The protocol to use for signing the message.
|
|
363
604
|
*/
|
|
364
|
-
protocol:
|
|
605
|
+
protocol: v14.enum(MessageSigningProtocols)
|
|
365
606
|
});
|
|
366
|
-
var signMessageRequestMessageSchema =
|
|
607
|
+
var signMessageRequestMessageSchema = v14.object({
|
|
367
608
|
...rpcRequestMessageSchema.entries,
|
|
368
|
-
...
|
|
369
|
-
method:
|
|
609
|
+
...v14.object({
|
|
610
|
+
method: v14.literal(signMessageMethodName),
|
|
370
611
|
params: signMessageParamsSchema,
|
|
371
|
-
id:
|
|
612
|
+
id: v14.string()
|
|
372
613
|
}).entries
|
|
373
614
|
});
|
|
374
615
|
var sendTransferMethodName = "sendTransfer";
|
|
375
|
-
var sendTransferParamsSchema =
|
|
616
|
+
var sendTransferParamsSchema = v14.object({
|
|
376
617
|
/**
|
|
377
618
|
* Array of recipients to send to.
|
|
378
619
|
* The amount to send to each recipient is in satoshis.
|
|
379
620
|
*/
|
|
380
|
-
recipients:
|
|
381
|
-
|
|
382
|
-
address:
|
|
383
|
-
amount:
|
|
621
|
+
recipients: v14.array(
|
|
622
|
+
v14.object({
|
|
623
|
+
address: v14.string(),
|
|
624
|
+
amount: v14.number()
|
|
384
625
|
})
|
|
385
626
|
)
|
|
386
627
|
});
|
|
387
|
-
var sendTransferResultSchema =
|
|
628
|
+
var sendTransferResultSchema = v14.object({
|
|
388
629
|
/**
|
|
389
630
|
* The transaction id as a hex-encoded string.
|
|
390
631
|
*/
|
|
391
|
-
txid:
|
|
632
|
+
txid: v14.string()
|
|
392
633
|
});
|
|
393
|
-
var sendTransferRequestMessageSchema =
|
|
634
|
+
var sendTransferRequestMessageSchema = v14.object({
|
|
394
635
|
...rpcRequestMessageSchema.entries,
|
|
395
|
-
...
|
|
396
|
-
method:
|
|
636
|
+
...v14.object({
|
|
637
|
+
method: v14.literal(sendTransferMethodName),
|
|
397
638
|
params: sendTransferParamsSchema,
|
|
398
|
-
id:
|
|
639
|
+
id: v14.string()
|
|
399
640
|
}).entries
|
|
400
641
|
});
|
|
401
642
|
var signPsbtMethodName = "signPsbt";
|
|
402
|
-
var signPsbtParamsSchema =
|
|
643
|
+
var signPsbtParamsSchema = v14.object({
|
|
403
644
|
/**
|
|
404
645
|
* The base64 encoded PSBT to sign.
|
|
405
646
|
*/
|
|
406
|
-
psbt:
|
|
647
|
+
psbt: v14.string(),
|
|
407
648
|
/**
|
|
408
649
|
* The inputs to sign.
|
|
409
650
|
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
410
651
|
*/
|
|
411
|
-
signInputs:
|
|
412
|
-
allowedSignHash: v6.optional(v6.number()),
|
|
652
|
+
signInputs: v14.record(v14.string(), v14.array(v14.number())),
|
|
413
653
|
/**
|
|
414
654
|
* Whether to broadcast the transaction after signing.
|
|
415
655
|
**/
|
|
416
|
-
broadcast:
|
|
656
|
+
broadcast: v14.optional(v14.boolean())
|
|
417
657
|
});
|
|
418
|
-
var signPsbtResultSchema =
|
|
658
|
+
var signPsbtResultSchema = v14.object({
|
|
419
659
|
/**
|
|
420
660
|
* The base64 encoded PSBT after signing.
|
|
421
661
|
*/
|
|
422
|
-
psbt:
|
|
662
|
+
psbt: v14.string(),
|
|
423
663
|
/**
|
|
424
664
|
* The transaction id as a hex-encoded string.
|
|
425
665
|
* This is only returned if the transaction was broadcast.
|
|
426
666
|
**/
|
|
427
|
-
txid:
|
|
667
|
+
txid: v14.optional(v14.string())
|
|
428
668
|
});
|
|
429
|
-
var signPsbtRequestMessageSchema =
|
|
669
|
+
var signPsbtRequestMessageSchema = v14.object({
|
|
430
670
|
...rpcRequestMessageSchema.entries,
|
|
431
|
-
...
|
|
432
|
-
method:
|
|
671
|
+
...v14.object({
|
|
672
|
+
method: v14.literal(signPsbtMethodName),
|
|
433
673
|
params: signPsbtParamsSchema,
|
|
434
|
-
id:
|
|
674
|
+
id: v14.string()
|
|
435
675
|
}).entries
|
|
436
676
|
});
|
|
437
677
|
var getAccountsMethodName = "getAccounts";
|
|
438
|
-
var getAccountsParamsSchema =
|
|
678
|
+
var getAccountsParamsSchema = v14.object({
|
|
439
679
|
/**
|
|
440
680
|
* The purposes for which to generate addresses. See
|
|
441
681
|
* {@linkcode AddressPurpose} for available purposes.
|
|
442
682
|
*/
|
|
443
|
-
purposes:
|
|
683
|
+
purposes: v14.array(v14.enum(AddressPurpose)),
|
|
444
684
|
/**
|
|
445
685
|
* A message to be displayed to the user in the request prompt.
|
|
446
686
|
*/
|
|
447
|
-
message:
|
|
687
|
+
message: v14.optional(v14.string())
|
|
448
688
|
});
|
|
449
|
-
var getAccountsResultSchema =
|
|
450
|
-
|
|
689
|
+
var getAccountsResultSchema = v14.array(
|
|
690
|
+
v14.object({
|
|
451
691
|
...addressSchema.entries,
|
|
452
|
-
...
|
|
692
|
+
...v14.object({
|
|
453
693
|
walletType: walletTypeSchema
|
|
454
694
|
}).entries
|
|
455
695
|
})
|
|
456
696
|
);
|
|
457
|
-
var getAccountsRequestMessageSchema =
|
|
697
|
+
var getAccountsRequestMessageSchema = v14.object({
|
|
458
698
|
...rpcRequestMessageSchema.entries,
|
|
459
|
-
...
|
|
460
|
-
method:
|
|
699
|
+
...v14.object({
|
|
700
|
+
method: v14.literal(getAccountsMethodName),
|
|
461
701
|
params: getAccountsParamsSchema,
|
|
462
|
-
id:
|
|
702
|
+
id: v14.string()
|
|
463
703
|
}).entries
|
|
464
704
|
});
|
|
465
705
|
var getBalanceMethodName = "getBalance";
|
|
466
|
-
var getBalanceParamsSchema =
|
|
467
|
-
var getBalanceResultSchema =
|
|
706
|
+
var getBalanceParamsSchema = v14.nullish(v14.null());
|
|
707
|
+
var getBalanceResultSchema = v14.object({
|
|
468
708
|
/**
|
|
469
709
|
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
470
710
|
* messages not supporting bigint
|
|
471
711
|
* (https://issues.chromium.org/issues/40116184).
|
|
472
712
|
*/
|
|
473
|
-
confirmed:
|
|
713
|
+
confirmed: v14.string(),
|
|
474
714
|
/**
|
|
475
715
|
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
476
716
|
* messages not supporting bigint
|
|
477
717
|
* (https://issues.chromium.org/issues/40116184).
|
|
478
718
|
*/
|
|
479
|
-
unconfirmed:
|
|
719
|
+
unconfirmed: v14.string(),
|
|
480
720
|
/**
|
|
481
721
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
482
722
|
* sats. Using a string due to chrome messages not supporting bigint
|
|
483
723
|
* (https://issues.chromium.org/issues/40116184).
|
|
484
724
|
*/
|
|
485
|
-
total:
|
|
725
|
+
total: v14.string()
|
|
486
726
|
});
|
|
487
|
-
var getBalanceRequestMessageSchema =
|
|
727
|
+
var getBalanceRequestMessageSchema = v14.object({
|
|
488
728
|
...rpcRequestMessageSchema.entries,
|
|
489
|
-
...
|
|
490
|
-
method:
|
|
491
|
-
id:
|
|
729
|
+
...v14.object({
|
|
730
|
+
method: v14.literal(getBalanceMethodName),
|
|
731
|
+
id: v14.string()
|
|
492
732
|
}).entries
|
|
493
733
|
});
|
|
494
734
|
|
|
495
735
|
// src/request/types/walletMethods.ts
|
|
496
|
-
import * as
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
736
|
+
import * as v15 from "valibot";
|
|
737
|
+
var accountActionsSchema = v15.object({
|
|
738
|
+
read: v15.optional(v15.boolean())
|
|
739
|
+
});
|
|
740
|
+
var walletActionsSchema = v15.object({});
|
|
741
|
+
var accountPermissionSchema = v15.object({
|
|
742
|
+
type: v15.literal("account"),
|
|
743
|
+
resourceId: v15.string(),
|
|
744
|
+
clientId: v15.string(),
|
|
745
|
+
actions: accountActionsSchema
|
|
746
|
+
});
|
|
747
|
+
var walletPermissionSchema = v15.object({
|
|
748
|
+
type: v15.literal("wallet"),
|
|
749
|
+
resourceId: v15.string(),
|
|
750
|
+
clientId: v15.string(),
|
|
751
|
+
actions: walletActionsSchema
|
|
752
|
+
});
|
|
753
|
+
var PermissionRequestParams = v15.variant("type", [
|
|
754
|
+
v15.object({
|
|
755
|
+
...v15.omit(accountPermissionSchema, ["clientId"]).entries
|
|
502
756
|
}),
|
|
503
|
-
|
|
504
|
-
...
|
|
505
|
-
actions: v7.partial(permissions.resources.wallet.walletActionsSchema)
|
|
757
|
+
v15.object({
|
|
758
|
+
...v15.omit(walletPermissionSchema, ["clientId"]).entries
|
|
506
759
|
})
|
|
507
760
|
]);
|
|
761
|
+
var permission = v15.variant("type", [accountPermissionSchema, walletPermissionSchema]);
|
|
508
762
|
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
509
|
-
var requestPermissionsParamsSchema =
|
|
510
|
-
var requestPermissionsResultSchema =
|
|
511
|
-
var requestPermissionsRequestMessageSchema =
|
|
763
|
+
var requestPermissionsParamsSchema = v15.nullish(v15.array(PermissionRequestParams));
|
|
764
|
+
var requestPermissionsResultSchema = v15.literal(true);
|
|
765
|
+
var requestPermissionsRequestMessageSchema = v15.object({
|
|
512
766
|
...rpcRequestMessageSchema.entries,
|
|
513
|
-
...
|
|
514
|
-
method:
|
|
767
|
+
...v15.object({
|
|
768
|
+
method: v15.literal(requestPermissionsMethodName),
|
|
515
769
|
params: requestPermissionsParamsSchema,
|
|
516
|
-
id:
|
|
770
|
+
id: v15.string()
|
|
517
771
|
}).entries
|
|
518
772
|
});
|
|
519
773
|
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
520
|
-
var renouncePermissionsParamsSchema =
|
|
521
|
-
var renouncePermissionsResultSchema =
|
|
522
|
-
var renouncePermissionsRequestMessageSchema =
|
|
774
|
+
var renouncePermissionsParamsSchema = v15.nullish(v15.null());
|
|
775
|
+
var renouncePermissionsResultSchema = v15.nullish(v15.null());
|
|
776
|
+
var renouncePermissionsRequestMessageSchema = v15.object({
|
|
523
777
|
...rpcRequestMessageSchema.entries,
|
|
524
|
-
...
|
|
525
|
-
method:
|
|
778
|
+
...v15.object({
|
|
779
|
+
method: v15.literal(renouncePermissionsMethodName),
|
|
526
780
|
params: renouncePermissionsParamsSchema,
|
|
527
|
-
id:
|
|
781
|
+
id: v15.string()
|
|
528
782
|
}).entries
|
|
529
783
|
});
|
|
530
784
|
var disconnectMethodName = "wallet_disconnect";
|
|
531
|
-
var disconnectParamsSchema =
|
|
532
|
-
var disconnectResultSchema =
|
|
533
|
-
var disconnectRequestMessageSchema =
|
|
785
|
+
var disconnectParamsSchema = v15.nullish(v15.null());
|
|
786
|
+
var disconnectResultSchema = v15.nullish(v15.null());
|
|
787
|
+
var disconnectRequestMessageSchema = v15.object({
|
|
534
788
|
...rpcRequestMessageSchema.entries,
|
|
535
|
-
...
|
|
536
|
-
method:
|
|
789
|
+
...v15.object({
|
|
790
|
+
method: v15.literal(disconnectMethodName),
|
|
537
791
|
params: disconnectParamsSchema,
|
|
538
|
-
id:
|
|
792
|
+
id: v15.string()
|
|
539
793
|
}).entries
|
|
540
794
|
});
|
|
541
795
|
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
542
|
-
var getWalletTypeParamsSchema =
|
|
796
|
+
var getWalletTypeParamsSchema = v15.nullish(v15.null());
|
|
543
797
|
var getWalletTypeResultSchema = walletTypeSchema;
|
|
544
|
-
var getWalletTypeRequestMessageSchema =
|
|
798
|
+
var getWalletTypeRequestMessageSchema = v15.object({
|
|
545
799
|
...rpcRequestMessageSchema.entries,
|
|
546
|
-
...
|
|
547
|
-
method:
|
|
800
|
+
...v15.object({
|
|
801
|
+
method: v15.literal(getWalletTypeMethodName),
|
|
548
802
|
params: getWalletTypeParamsSchema,
|
|
549
|
-
id:
|
|
803
|
+
id: v15.string()
|
|
550
804
|
}).entries
|
|
551
805
|
});
|
|
552
806
|
var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
553
|
-
var getCurrentPermissionsParamsSchema =
|
|
554
|
-
var getCurrentPermissionsResultSchema =
|
|
555
|
-
var getCurrentPermissionsRequestMessageSchema =
|
|
807
|
+
var getCurrentPermissionsParamsSchema = v15.nullish(v15.null());
|
|
808
|
+
var getCurrentPermissionsResultSchema = v15.array(permission);
|
|
809
|
+
var getCurrentPermissionsRequestMessageSchema = v15.object({
|
|
556
810
|
...rpcRequestMessageSchema.entries,
|
|
557
|
-
...
|
|
558
|
-
method:
|
|
811
|
+
...v15.object({
|
|
812
|
+
method: v15.literal(getCurrentPermissionsMethodName),
|
|
559
813
|
params: getCurrentPermissionsParamsSchema,
|
|
560
|
-
id:
|
|
814
|
+
id: v15.string()
|
|
561
815
|
}).entries
|
|
562
816
|
});
|
|
563
817
|
var getAccountMethodName = "wallet_getAccount";
|
|
564
|
-
var getAccountParamsSchema =
|
|
565
|
-
var getAccountResultSchema =
|
|
566
|
-
id:
|
|
567
|
-
addresses:
|
|
818
|
+
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
819
|
+
var getAccountResultSchema = v15.object({
|
|
820
|
+
id: v15.string(),
|
|
821
|
+
addresses: v15.array(addressSchema),
|
|
568
822
|
walletType: walletTypeSchema
|
|
569
823
|
});
|
|
570
|
-
var getAccountRequestMessageSchema =
|
|
824
|
+
var getAccountRequestMessageSchema = v15.object({
|
|
571
825
|
...rpcRequestMessageSchema.entries,
|
|
572
|
-
...
|
|
573
|
-
method:
|
|
826
|
+
...v15.object({
|
|
827
|
+
method: v15.literal(getAccountMethodName),
|
|
574
828
|
params: getAccountParamsSchema,
|
|
575
|
-
id:
|
|
829
|
+
id: v15.string()
|
|
576
830
|
}).entries
|
|
577
831
|
});
|
|
578
832
|
var connectMethodName = "wallet_connect";
|
|
579
|
-
var connectParamsSchema =
|
|
580
|
-
|
|
581
|
-
permissions:
|
|
833
|
+
var connectParamsSchema = v15.nullish(
|
|
834
|
+
v15.object({
|
|
835
|
+
permissions: v15.optional(v15.array(PermissionRequestParams)),
|
|
836
|
+
addresses: v15.optional(v15.array(v15.enum(AddressPurpose))),
|
|
837
|
+
message: v15.optional(
|
|
838
|
+
v15.pipe(v15.string(), v15.maxLength(80, "The message must not exceed 80 characters."))
|
|
839
|
+
)
|
|
582
840
|
})
|
|
583
841
|
);
|
|
584
842
|
var connectResultSchema = getAccountResultSchema;
|
|
585
|
-
var connectRequestMessageSchema =
|
|
843
|
+
var connectRequestMessageSchema = v15.object({
|
|
586
844
|
...rpcRequestMessageSchema.entries,
|
|
587
|
-
...
|
|
588
|
-
method:
|
|
845
|
+
...v15.object({
|
|
846
|
+
method: v15.literal(connectMethodName),
|
|
589
847
|
params: connectParamsSchema,
|
|
590
|
-
id:
|
|
848
|
+
id: v15.string()
|
|
591
849
|
}).entries
|
|
592
850
|
});
|
|
593
851
|
|
|
594
|
-
// src/request/types/runesMethods.ts
|
|
595
|
-
import * as
|
|
596
|
-
var
|
|
597
|
-
var
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
852
|
+
// src/request/types/runesMethods/etch.ts
|
|
853
|
+
import * as v16 from "valibot";
|
|
854
|
+
var runesEtchMethodName = "runes_etch";
|
|
855
|
+
var etchTermsSchema = v16.object({
|
|
856
|
+
amount: v16.string(),
|
|
857
|
+
cap: v16.string(),
|
|
858
|
+
heightStart: v16.optional(v16.string()),
|
|
859
|
+
heightEnd: v16.optional(v16.string()),
|
|
860
|
+
offsetStart: v16.optional(v16.string()),
|
|
861
|
+
offsetEnd: v16.optional(v16.string())
|
|
862
|
+
});
|
|
863
|
+
var inscriptionDetailsSchema = v16.object({
|
|
864
|
+
contentType: v16.string(),
|
|
865
|
+
contentBase64: v16.string()
|
|
866
|
+
});
|
|
867
|
+
var runesEtchParamsSchema = v16.object({
|
|
868
|
+
runeName: v16.string(),
|
|
869
|
+
divisibility: v16.optional(v16.number()),
|
|
870
|
+
symbol: v16.optional(v16.string()),
|
|
871
|
+
premine: v16.optional(v16.string()),
|
|
872
|
+
isMintable: v16.boolean(),
|
|
873
|
+
delegateInscriptionId: v16.optional(v16.string()),
|
|
874
|
+
destinationAddress: v16.string(),
|
|
875
|
+
refundAddress: v16.string(),
|
|
876
|
+
feeRate: v16.number(),
|
|
877
|
+
appServiceFee: v16.optional(v16.number()),
|
|
878
|
+
appServiceFeeAddress: v16.optional(v16.string()),
|
|
879
|
+
terms: v16.optional(etchTermsSchema),
|
|
880
|
+
inscriptionDetails: v16.optional(inscriptionDetailsSchema),
|
|
881
|
+
network: v16.optional(v16.enum(BitcoinNetworkType))
|
|
882
|
+
});
|
|
883
|
+
var runesEtchResultSchema = v16.object({
|
|
884
|
+
orderId: v16.string(),
|
|
885
|
+
fundTransactionId: v16.string(),
|
|
886
|
+
fundingAddress: v16.string()
|
|
887
|
+
});
|
|
888
|
+
var runesEtchRequestMessageSchema = v16.object({
|
|
889
|
+
...rpcRequestMessageSchema.entries,
|
|
890
|
+
...v16.object({
|
|
891
|
+
method: v16.literal(runesEtchMethodName),
|
|
892
|
+
params: runesEtchParamsSchema,
|
|
893
|
+
id: v16.string()
|
|
894
|
+
}).entries
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
// src/request/types/runesMethods/getBalance.ts
|
|
898
|
+
import * as v17 from "valibot";
|
|
899
|
+
var runesGetBalanceMethodName = "runes_getBalance";
|
|
900
|
+
var runesGetBalanceParamsSchema = v17.nullish(v17.null());
|
|
901
|
+
var runesGetBalanceResultSchema = v17.object({
|
|
902
|
+
balances: v17.array(
|
|
903
|
+
v17.object({
|
|
904
|
+
runeName: v17.string(),
|
|
905
|
+
amount: v17.string(),
|
|
906
|
+
divisibility: v17.number(),
|
|
907
|
+
symbol: v17.string(),
|
|
908
|
+
inscriptionId: v17.nullish(v17.string())
|
|
606
909
|
})
|
|
607
910
|
)
|
|
608
911
|
});
|
|
609
|
-
var
|
|
912
|
+
var runesGetBalanceRequestMessageSchema = v17.object({
|
|
610
913
|
...rpcRequestMessageSchema.entries,
|
|
611
|
-
...
|
|
612
|
-
method:
|
|
613
|
-
params:
|
|
614
|
-
id:
|
|
914
|
+
...v17.object({
|
|
915
|
+
method: v17.literal(runesGetBalanceMethodName),
|
|
916
|
+
params: runesGetBalanceParamsSchema,
|
|
917
|
+
id: v17.string()
|
|
918
|
+
}).entries
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
// src/request/types/runesMethods/mint.ts
|
|
922
|
+
import * as v18 from "valibot";
|
|
923
|
+
var runesMintMethodName = "runes_mint";
|
|
924
|
+
var runesMintParamsSchema = v18.object({
|
|
925
|
+
appServiceFee: v18.optional(v18.number()),
|
|
926
|
+
appServiceFeeAddress: v18.optional(v18.string()),
|
|
927
|
+
destinationAddress: v18.string(),
|
|
928
|
+
feeRate: v18.number(),
|
|
929
|
+
refundAddress: v18.string(),
|
|
930
|
+
repeats: v18.number(),
|
|
931
|
+
runeName: v18.string(),
|
|
932
|
+
network: v18.optional(v18.enum(BitcoinNetworkType))
|
|
933
|
+
});
|
|
934
|
+
var runesMintResultSchema = v18.object({
|
|
935
|
+
orderId: v18.string(),
|
|
936
|
+
fundTransactionId: v18.string(),
|
|
937
|
+
fundingAddress: v18.string()
|
|
938
|
+
});
|
|
939
|
+
var runesMintRequestMessageSchema = v18.object({
|
|
940
|
+
...rpcRequestMessageSchema.entries,
|
|
941
|
+
...v18.object({
|
|
942
|
+
method: v18.literal(runesMintMethodName),
|
|
943
|
+
params: runesMintParamsSchema,
|
|
944
|
+
id: v18.string()
|
|
615
945
|
}).entries
|
|
616
946
|
});
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
947
|
+
|
|
948
|
+
// src/request/types/runesMethods/transfer.ts
|
|
949
|
+
import * as v19 from "valibot";
|
|
950
|
+
var runesTransferMethodName = "runes_transfer";
|
|
951
|
+
var runesTransferParamsSchema = v19.object({
|
|
952
|
+
recipients: v19.array(
|
|
953
|
+
v19.object({
|
|
954
|
+
runeName: v19.string(),
|
|
955
|
+
amount: v19.string(),
|
|
956
|
+
address: v19.string()
|
|
624
957
|
})
|
|
625
958
|
)
|
|
626
959
|
});
|
|
627
|
-
var
|
|
960
|
+
var runesTransferResultSchema = v19.object({
|
|
961
|
+
txid: v19.string()
|
|
962
|
+
});
|
|
963
|
+
var runesTransferRequestMessageSchema = v19.object({
|
|
628
964
|
...rpcRequestMessageSchema.entries,
|
|
629
|
-
...
|
|
630
|
-
method:
|
|
631
|
-
params:
|
|
632
|
-
id:
|
|
965
|
+
...v19.object({
|
|
966
|
+
method: v19.literal(runesTransferMethodName),
|
|
967
|
+
params: runesTransferParamsSchema,
|
|
968
|
+
id: v19.string()
|
|
633
969
|
}).entries
|
|
634
970
|
});
|
|
635
|
-
var TransferRunesResultSchema = v8.object({
|
|
636
|
-
txid: v8.string()
|
|
637
|
-
});
|
|
638
971
|
|
|
639
972
|
// src/request/types/ordinalsMethods.ts
|
|
640
|
-
import * as
|
|
973
|
+
import * as v20 from "valibot";
|
|
641
974
|
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
642
|
-
var getInscriptionsParamsSchema =
|
|
643
|
-
offset:
|
|
644
|
-
limit:
|
|
645
|
-
});
|
|
646
|
-
var getInscriptionsResultSchema =
|
|
647
|
-
total:
|
|
648
|
-
limit:
|
|
649
|
-
offset:
|
|
650
|
-
inscriptions:
|
|
651
|
-
|
|
652
|
-
inscriptionId:
|
|
653
|
-
inscriptionNumber:
|
|
654
|
-
address:
|
|
655
|
-
collectionName:
|
|
656
|
-
postage:
|
|
657
|
-
contentLength:
|
|
658
|
-
contentType:
|
|
659
|
-
timestamp:
|
|
660
|
-
offset:
|
|
661
|
-
genesisTransaction:
|
|
662
|
-
output:
|
|
975
|
+
var getInscriptionsParamsSchema = v20.object({
|
|
976
|
+
offset: v20.number(),
|
|
977
|
+
limit: v20.number()
|
|
978
|
+
});
|
|
979
|
+
var getInscriptionsResultSchema = v20.object({
|
|
980
|
+
total: v20.number(),
|
|
981
|
+
limit: v20.number(),
|
|
982
|
+
offset: v20.number(),
|
|
983
|
+
inscriptions: v20.array(
|
|
984
|
+
v20.object({
|
|
985
|
+
inscriptionId: v20.string(),
|
|
986
|
+
inscriptionNumber: v20.string(),
|
|
987
|
+
address: v20.string(),
|
|
988
|
+
collectionName: v20.optional(v20.string()),
|
|
989
|
+
postage: v20.string(),
|
|
990
|
+
contentLength: v20.string(),
|
|
991
|
+
contentType: v20.string(),
|
|
992
|
+
timestamp: v20.number(),
|
|
993
|
+
offset: v20.number(),
|
|
994
|
+
genesisTransaction: v20.string(),
|
|
995
|
+
output: v20.string()
|
|
663
996
|
})
|
|
664
997
|
)
|
|
665
998
|
});
|
|
666
|
-
var
|
|
999
|
+
var getInscriptionsRequestMessageSchema = v20.object({
|
|
667
1000
|
...rpcRequestMessageSchema.entries,
|
|
668
|
-
...
|
|
669
|
-
method:
|
|
1001
|
+
...v20.object({
|
|
1002
|
+
method: v20.literal(getInscriptionsMethodName),
|
|
670
1003
|
params: getInscriptionsParamsSchema,
|
|
671
|
-
id:
|
|
1004
|
+
id: v20.string()
|
|
672
1005
|
}).entries
|
|
673
1006
|
});
|
|
674
1007
|
var sendInscriptionsMethodName = "ord_sendInscriptions";
|
|
675
|
-
var sendInscriptionsParamsSchema =
|
|
676
|
-
transfers:
|
|
677
|
-
|
|
678
|
-
address:
|
|
679
|
-
inscriptionId:
|
|
1008
|
+
var sendInscriptionsParamsSchema = v20.object({
|
|
1009
|
+
transfers: v20.array(
|
|
1010
|
+
v20.object({
|
|
1011
|
+
address: v20.string(),
|
|
1012
|
+
inscriptionId: v20.string()
|
|
680
1013
|
})
|
|
681
1014
|
)
|
|
682
1015
|
});
|
|
683
|
-
var sendInscriptionsResultSchema =
|
|
684
|
-
txid:
|
|
1016
|
+
var sendInscriptionsResultSchema = v20.object({
|
|
1017
|
+
txid: v20.string()
|
|
685
1018
|
});
|
|
686
|
-
var
|
|
1019
|
+
var sendInscriptionsRequestMessageSchema = v20.object({
|
|
687
1020
|
...rpcRequestMessageSchema.entries,
|
|
688
|
-
...
|
|
689
|
-
method:
|
|
1021
|
+
...v20.object({
|
|
1022
|
+
method: v20.literal(sendInscriptionsMethodName),
|
|
690
1023
|
params: sendInscriptionsParamsSchema,
|
|
691
|
-
id:
|
|
1024
|
+
id: v20.string()
|
|
692
1025
|
}).entries
|
|
693
1026
|
});
|
|
694
1027
|
|
|
@@ -705,13 +1038,13 @@ var request = async (method, params, providerId) => {
|
|
|
705
1038
|
throw new Error("A wallet method is required");
|
|
706
1039
|
}
|
|
707
1040
|
const response = await provider.request(method, params);
|
|
708
|
-
if (
|
|
1041
|
+
if (v21.is(rpcErrorResponseMessageSchema, response)) {
|
|
709
1042
|
return {
|
|
710
1043
|
status: "error",
|
|
711
1044
|
error: response.error
|
|
712
1045
|
};
|
|
713
1046
|
}
|
|
714
|
-
if (
|
|
1047
|
+
if (v21.is(rpcSuccessResponseMessageSchema, response)) {
|
|
715
1048
|
return {
|
|
716
1049
|
status: "success",
|
|
717
1050
|
result: response.result
|
|
@@ -1308,15 +1641,14 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1308
1641
|
autoFinalized: broadcast,
|
|
1309
1642
|
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
1310
1643
|
});
|
|
1644
|
+
const signedPsbtBase64 = Buffer.from(signedPsbt, "hex").toString("base64");
|
|
1645
|
+
let txid;
|
|
1311
1646
|
if (broadcast) {
|
|
1312
|
-
|
|
1313
|
-
return {
|
|
1314
|
-
psbt: signedPsbt,
|
|
1315
|
-
txid
|
|
1316
|
-
};
|
|
1647
|
+
txid = await window.unisat.pushPsbt(signedPsbt);
|
|
1317
1648
|
}
|
|
1318
1649
|
return {
|
|
1319
|
-
psbt:
|
|
1650
|
+
psbt: signedPsbtBase64,
|
|
1651
|
+
txid
|
|
1320
1652
|
};
|
|
1321
1653
|
}
|
|
1322
1654
|
requestInternal = async (method, params) => {
|
|
@@ -1467,8 +1799,7 @@ var extractOrValidateCapabilities = (provider, reportedCapabilities) => {
|
|
|
1467
1799
|
addListener: validateCapability("addListener")
|
|
1468
1800
|
};
|
|
1469
1801
|
return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
|
|
1470
|
-
if (value)
|
|
1471
|
-
return [...acc, capability];
|
|
1802
|
+
if (value) return [...acc, capability];
|
|
1472
1803
|
return acc;
|
|
1473
1804
|
}, []);
|
|
1474
1805
|
};
|
|
@@ -1659,12 +1990,14 @@ export {
|
|
|
1659
1990
|
BitcoinNetworkType,
|
|
1660
1991
|
DefaultAdaptersInfo,
|
|
1661
1992
|
MessageSigningProtocols,
|
|
1993
|
+
PermissionRequestParams,
|
|
1662
1994
|
RpcErrorCode,
|
|
1663
1995
|
RpcIdSchema,
|
|
1664
1996
|
SatsConnectAdapter,
|
|
1665
|
-
|
|
1997
|
+
accountActionsSchema,
|
|
1666
1998
|
accountChangeEventName,
|
|
1667
1999
|
accountChangeSchema,
|
|
2000
|
+
accountPermissionSchema,
|
|
1668
2001
|
addListener,
|
|
1669
2002
|
addressSchema,
|
|
1670
2003
|
connectMethodName,
|
|
@@ -1709,15 +2042,11 @@ export {
|
|
|
1709
2042
|
getInfoResultSchema,
|
|
1710
2043
|
getInscriptionsMethodName,
|
|
1711
2044
|
getInscriptionsParamsSchema,
|
|
2045
|
+
getInscriptionsRequestMessageSchema,
|
|
1712
2046
|
getInscriptionsResultSchema,
|
|
1713
|
-
getInscriptionsSchema,
|
|
1714
2047
|
getProviderById,
|
|
1715
2048
|
getProviderOrThrow,
|
|
1716
2049
|
getProviders,
|
|
1717
|
-
getRunesBalanceMethodName,
|
|
1718
|
-
getRunesBalanceParamsSchema,
|
|
1719
|
-
getRunesBalanceRequestMessageSchema,
|
|
1720
|
-
getRunesBalanceResultSchema,
|
|
1721
2050
|
getSupportedWallets,
|
|
1722
2051
|
getWalletTypeMethodName,
|
|
1723
2052
|
getWalletTypeParamsSchema,
|
|
@@ -1726,7 +2055,7 @@ export {
|
|
|
1726
2055
|
isProviderInstalled,
|
|
1727
2056
|
networkChangeEventName,
|
|
1728
2057
|
networkChangeSchema,
|
|
1729
|
-
|
|
2058
|
+
permission,
|
|
1730
2059
|
removeDefaultProvider,
|
|
1731
2060
|
renouncePermissionsMethodName,
|
|
1732
2061
|
renouncePermissionsParamsSchema,
|
|
@@ -1741,11 +2070,27 @@ export {
|
|
|
1741
2070
|
rpcRequestMessageSchema,
|
|
1742
2071
|
rpcResponseMessageSchema,
|
|
1743
2072
|
rpcSuccessResponseMessageSchema,
|
|
2073
|
+
runesEtchMethodName,
|
|
2074
|
+
runesEtchParamsSchema,
|
|
2075
|
+
runesEtchRequestMessageSchema,
|
|
2076
|
+
runesEtchResultSchema,
|
|
2077
|
+
runesGetBalanceMethodName,
|
|
2078
|
+
runesGetBalanceParamsSchema,
|
|
2079
|
+
runesGetBalanceRequestMessageSchema,
|
|
2080
|
+
runesGetBalanceResultSchema,
|
|
2081
|
+
runesMintMethodName,
|
|
2082
|
+
runesMintParamsSchema,
|
|
2083
|
+
runesMintRequestMessageSchema,
|
|
2084
|
+
runesMintResultSchema,
|
|
2085
|
+
runesTransferMethodName,
|
|
2086
|
+
runesTransferParamsSchema,
|
|
2087
|
+
runesTransferRequestMessageSchema,
|
|
2088
|
+
runesTransferResultSchema,
|
|
1744
2089
|
sendBtcTransaction,
|
|
1745
2090
|
sendInscriptionsMethodName,
|
|
1746
2091
|
sendInscriptionsParamsSchema,
|
|
2092
|
+
sendInscriptionsRequestMessageSchema,
|
|
1747
2093
|
sendInscriptionsResultSchema,
|
|
1748
|
-
sendInscriptionsSchema,
|
|
1749
2094
|
sendTransferMethodName,
|
|
1750
2095
|
sendTransferParamsSchema,
|
|
1751
2096
|
sendTransferRequestMessageSchema,
|
|
@@ -1766,18 +2111,41 @@ export {
|
|
|
1766
2111
|
stxCallContractParamsSchema,
|
|
1767
2112
|
stxCallContractRequestMessageSchema,
|
|
1768
2113
|
stxCallContractResultSchema,
|
|
2114
|
+
stxDeployContractMethodName,
|
|
2115
|
+
stxDeployContractParamsSchema,
|
|
2116
|
+
stxDeployContractRequestMessageSchema,
|
|
2117
|
+
stxDeployContractResultSchema,
|
|
2118
|
+
stxGetAccountsMethodName,
|
|
2119
|
+
stxGetAccountsParamsSchema,
|
|
2120
|
+
stxGetAccountsRequestMessageSchema,
|
|
2121
|
+
stxGetAccountsResultSchema,
|
|
1769
2122
|
stxGetAddressesMethodName,
|
|
1770
2123
|
stxGetAddressesParamsSchema,
|
|
1771
2124
|
stxGetAddressesRequestMessageSchema,
|
|
1772
2125
|
stxGetAddressesResultSchema,
|
|
2126
|
+
stxSignMessageMethodName,
|
|
2127
|
+
stxSignMessageParamsSchema,
|
|
2128
|
+
stxSignMessageRequestMessageSchema,
|
|
2129
|
+
stxSignMessageResultSchema,
|
|
2130
|
+
stxSignStructuredMessageMethodName,
|
|
2131
|
+
stxSignStructuredMessageParamsSchema,
|
|
2132
|
+
stxSignStructuredMessageRequestMessageSchema,
|
|
2133
|
+
stxSignStructuredMessageResultSchema,
|
|
1773
2134
|
stxSignTransactionMethodName,
|
|
1774
2135
|
stxSignTransactionParamsSchema,
|
|
1775
2136
|
stxSignTransactionRequestMessageSchema,
|
|
1776
2137
|
stxSignTransactionResultSchema,
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
2138
|
+
stxSignTransactionsMethodName,
|
|
2139
|
+
stxSignTransactionsParamsSchema,
|
|
2140
|
+
stxSignTransactionsRequestMessageSchema,
|
|
2141
|
+
stxSignTransactionsResultSchema,
|
|
2142
|
+
stxTransferStxMethodName,
|
|
2143
|
+
stxTransferStxParamsSchema,
|
|
2144
|
+
stxTransferStxRequestMessageSchema,
|
|
2145
|
+
stxTransferStxResultSchema,
|
|
2146
|
+
walletActionsSchema,
|
|
1780
2147
|
walletEventSchema,
|
|
2148
|
+
walletPermissionSchema,
|
|
1781
2149
|
walletTypeSchema,
|
|
1782
2150
|
walletTypes
|
|
1783
2151
|
};
|