@sats-connect/core 0.0.11-760c033 → 0.0.11-e6aad2f
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 +141 -61
- package/dist/index.mjs +166 -59
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
1
3
|
interface GetCapabilitiesPayload extends RequestPayload {
|
|
2
4
|
}
|
|
3
5
|
type GetCapabilitiesResponse = Capability[];
|
|
@@ -157,6 +159,13 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
157
159
|
payload: Payload;
|
|
158
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
159
161
|
}
|
|
162
|
+
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
163
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
164
|
+
readonly method: v.StringSchema<undefined>;
|
|
165
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>], undefined>, never>;
|
|
166
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
167
|
+
}, undefined>;
|
|
168
|
+
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
160
169
|
type RpcId = string | null;
|
|
161
170
|
interface RpcBase {
|
|
162
171
|
jsonrpc: '2.0';
|
|
@@ -243,12 +252,13 @@ declare enum AddressType {
|
|
|
243
252
|
p2tr = "p2tr",
|
|
244
253
|
stacks = "stacks"
|
|
245
254
|
}
|
|
246
|
-
|
|
247
|
-
address:
|
|
248
|
-
publicKey:
|
|
249
|
-
purpose
|
|
250
|
-
addressType
|
|
251
|
-
}
|
|
255
|
+
declare const addressSchema: v.ObjectSchema<{
|
|
256
|
+
readonly address: v.StringSchema<undefined>;
|
|
257
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
258
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
259
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
260
|
+
}, undefined>;
|
|
261
|
+
type Address$1 = v.InferOutput<typeof addressSchema>;
|
|
252
262
|
interface GetAddressResponse {
|
|
253
263
|
addresses: Address$1[];
|
|
254
264
|
}
|
|
@@ -256,59 +266,110 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
256
266
|
|
|
257
267
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
258
268
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
269
|
+
declare const getInfoMethodName = "getInfo";
|
|
270
|
+
declare const getInfoParamsSchema: v.NullSchema<undefined>;
|
|
271
|
+
declare const getInfoResultSchema: v.ObjectSchema<{
|
|
272
|
+
/**
|
|
273
|
+
* Version of the wallet.
|
|
274
|
+
*/
|
|
275
|
+
readonly version: v.StringSchema<undefined>;
|
|
276
|
+
/**
|
|
277
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
278
|
+
*/
|
|
279
|
+
readonly methods: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, never>;
|
|
280
|
+
/**
|
|
281
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
282
|
+
*/
|
|
283
|
+
readonly supports: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
284
|
+
}, undefined>;
|
|
285
|
+
declare const getInfoSchema: v.ObjectSchema<{
|
|
286
|
+
readonly method: v.LiteralSchema<"getInfo", undefined>;
|
|
287
|
+
readonly params: v.NullSchema<undefined>;
|
|
288
|
+
readonly id: v.StringSchema<undefined>;
|
|
289
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
290
|
+
}, undefined>;
|
|
291
|
+
type GetInfo = MethodParamsAndResult<v.InferOutput<typeof getInfoParamsSchema>, v.InferOutput<typeof getInfoResultSchema>>;
|
|
292
|
+
declare const getAddressesMethodName = "getAddresses";
|
|
293
|
+
declare const getAddressesParamsSchema: v.ObjectSchema<{
|
|
294
|
+
/**
|
|
295
|
+
* The purposes for which to generate addresses. See
|
|
296
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
297
|
+
*/
|
|
298
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
299
|
+
/**
|
|
300
|
+
* A message to be displayed to the user in the request prompt.
|
|
301
|
+
*/
|
|
302
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
303
|
+
}, undefined>;
|
|
304
|
+
declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
305
|
+
/**
|
|
306
|
+
* The addresses generated for the given purposes.
|
|
307
|
+
*/
|
|
308
|
+
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
309
|
+
readonly address: v.StringSchema<undefined>;
|
|
310
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
311
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
312
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
313
|
+
}, undefined>, undefined>;
|
|
314
|
+
}, undefined>;
|
|
315
|
+
declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
316
|
+
readonly method: v.LiteralSchema<"getAddresses", undefined>;
|
|
317
|
+
readonly params: v.ObjectSchema<{
|
|
318
|
+
/**
|
|
319
|
+
* The purposes for which to generate addresses. See
|
|
320
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
321
|
+
*/
|
|
322
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
323
|
+
/**
|
|
324
|
+
* A message to be displayed to the user in the request prompt.
|
|
325
|
+
*/
|
|
326
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
327
|
+
}, undefined>;
|
|
328
|
+
readonly id: v.StringSchema<undefined>;
|
|
329
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
330
|
+
}, undefined>;
|
|
331
|
+
type GetAddresses = MethodParamsAndResult<v.InferOutput<typeof getAddressesParamsSchema>, v.InferOutput<typeof getAddressesResultSchema>>;
|
|
332
|
+
declare const signMessageMethodName = "signMessage";
|
|
333
|
+
declare const signMessageParamsSchema: v.ObjectSchema<{
|
|
288
334
|
/**
|
|
289
335
|
* The address used for signing.
|
|
290
336
|
**/
|
|
291
|
-
address:
|
|
337
|
+
readonly address: v.StringSchema<undefined>;
|
|
292
338
|
/**
|
|
293
339
|
* The message to sign.
|
|
294
340
|
**/
|
|
295
|
-
message:
|
|
296
|
-
}
|
|
297
|
-
|
|
341
|
+
readonly message: v.StringSchema<undefined>;
|
|
342
|
+
}, undefined>;
|
|
343
|
+
declare const signMessageResultSchema: v.ObjectSchema<{
|
|
298
344
|
/**
|
|
299
345
|
* The signature of the message.
|
|
300
346
|
*/
|
|
301
|
-
signature:
|
|
347
|
+
readonly signature: v.StringSchema<undefined>;
|
|
302
348
|
/**
|
|
303
349
|
* hash of the message.
|
|
304
350
|
*/
|
|
305
|
-
messageHash:
|
|
351
|
+
readonly messageHash: v.StringSchema<undefined>;
|
|
306
352
|
/**
|
|
307
353
|
* The address used for signing.
|
|
308
354
|
*/
|
|
309
|
-
address:
|
|
310
|
-
}
|
|
311
|
-
|
|
355
|
+
readonly address: v.StringSchema<undefined>;
|
|
356
|
+
}, undefined>;
|
|
357
|
+
declare const signMessageRequestMessageSchema: v.ObjectSchema<{
|
|
358
|
+
readonly method: v.LiteralSchema<"signMessage", undefined>;
|
|
359
|
+
readonly params: v.ObjectSchema<{
|
|
360
|
+
/**
|
|
361
|
+
* The address used for signing.
|
|
362
|
+
**/
|
|
363
|
+
readonly address: v.StringSchema<undefined>;
|
|
364
|
+
/**
|
|
365
|
+
* The message to sign.
|
|
366
|
+
**/
|
|
367
|
+
readonly message: v.StringSchema<undefined>;
|
|
368
|
+
}, undefined>;
|
|
369
|
+
readonly id: v.StringSchema<undefined>;
|
|
370
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
371
|
+
}, undefined>;
|
|
372
|
+
type SignMessage = MethodParamsAndResult<v.InferOutput<typeof signMessageParamsSchema>, v.InferOutput<typeof signMessageResultSchema>>;
|
|
312
373
|
type Recipient$1 = {
|
|
313
374
|
/**
|
|
314
375
|
* The recipient's address.
|
|
@@ -365,22 +426,41 @@ type SignPsbtResult = {
|
|
|
365
426
|
txid?: string;
|
|
366
427
|
};
|
|
367
428
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
*
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
429
|
+
declare const getAccountsMethodName = "getAccounts";
|
|
430
|
+
declare const getAccountsParamsSchema: v.ObjectSchema<{
|
|
431
|
+
/**
|
|
432
|
+
* The purposes for which to generate addresses. See
|
|
433
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
434
|
+
*/
|
|
435
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
436
|
+
/**
|
|
437
|
+
* A message to be displayed to the user in the request prompt.
|
|
438
|
+
*/
|
|
439
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
440
|
+
}, undefined>;
|
|
441
|
+
declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
442
|
+
readonly address: v.StringSchema<undefined>;
|
|
443
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
444
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
445
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
446
|
+
}, undefined>, undefined>;
|
|
447
|
+
declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
448
|
+
readonly method: v.LiteralSchema<"getAccounts", undefined>;
|
|
449
|
+
readonly params: v.ObjectSchema<{
|
|
450
|
+
/**
|
|
451
|
+
* The purposes for which to generate addresses. See
|
|
452
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
453
|
+
*/
|
|
454
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
455
|
+
/**
|
|
456
|
+
* A message to be displayed to the user in the request prompt.
|
|
457
|
+
*/
|
|
458
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
459
|
+
}, undefined>;
|
|
460
|
+
readonly id: v.StringSchema<undefined>;
|
|
461
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
462
|
+
}, undefined>;
|
|
463
|
+
type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
|
|
384
464
|
|
|
385
465
|
type CreateMintOrderRequest = {
|
|
386
466
|
runeName: string;
|
|
@@ -744,4 +824,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
|
|
|
744
824
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
745
825
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
746
826
|
|
|
747
|
-
export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type
|
|
827
|
+
export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccounts, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, rpcRequestMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
3
4
|
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
4
5
|
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
5
6
|
BitcoinNetworkType2["Signet"] = "Signet";
|
|
6
7
|
return BitcoinNetworkType2;
|
|
7
8
|
})(BitcoinNetworkType || {});
|
|
9
|
+
var rpcRequestMessageSchema = v.object({
|
|
10
|
+
jsonrpc: v.literal("2.0"),
|
|
11
|
+
method: v.string(),
|
|
12
|
+
params: v.optional(v.union([v.array(v.unknown()), v.looseObject({})])),
|
|
13
|
+
id: v.optional(v.union([v.string(), v.number(), v.null()]))
|
|
14
|
+
});
|
|
8
15
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
9
16
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
10
17
|
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
@@ -169,16 +176,6 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
|
|
|
169
176
|
var SatsConnectAdapter = class {
|
|
170
177
|
async mintRunes(params) {
|
|
171
178
|
try {
|
|
172
|
-
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
173
|
-
if (walletInfo && walletInfo.status === "success") {
|
|
174
|
-
const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
|
|
175
|
-
if (isMintSupported) {
|
|
176
|
-
const response = await this.requestInternal("runes_mint", params);
|
|
177
|
-
if (response) {
|
|
178
|
-
return response;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
179
|
const mintRequest = {
|
|
183
180
|
destinationAddress: params.destinationAddress,
|
|
184
181
|
feeRate: params.feeRate,
|
|
@@ -248,16 +245,6 @@ var SatsConnectAdapter = class {
|
|
|
248
245
|
appServiceFeeAddress: params.appServiceFeeAddress
|
|
249
246
|
};
|
|
250
247
|
try {
|
|
251
|
-
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
252
|
-
if (walletInfo && walletInfo.status === "success") {
|
|
253
|
-
const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
|
|
254
|
-
if (isEtchSupported) {
|
|
255
|
-
const response = await this.requestInternal("runes_etch", params);
|
|
256
|
-
if (response) {
|
|
257
|
-
return response;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
248
|
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
262
249
|
if (!orderResponse.data) {
|
|
263
250
|
return {
|
|
@@ -512,6 +499,147 @@ function getSupportedWallets() {
|
|
|
512
499
|
return wallets;
|
|
513
500
|
}
|
|
514
501
|
|
|
502
|
+
// src/addresses/index.ts
|
|
503
|
+
import { createUnsecuredToken } from "jsontokens";
|
|
504
|
+
|
|
505
|
+
// src/addresses/types.ts
|
|
506
|
+
import * as v2 from "valibot";
|
|
507
|
+
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
508
|
+
AddressPurpose2["Ordinals"] = "ordinals";
|
|
509
|
+
AddressPurpose2["Payment"] = "payment";
|
|
510
|
+
AddressPurpose2["Stacks"] = "stacks";
|
|
511
|
+
return AddressPurpose2;
|
|
512
|
+
})(AddressPurpose || {});
|
|
513
|
+
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
514
|
+
AddressType3["p2pkh"] = "p2pkh";
|
|
515
|
+
AddressType3["p2sh"] = "p2sh";
|
|
516
|
+
AddressType3["p2wpkh"] = "p2wpkh";
|
|
517
|
+
AddressType3["p2wsh"] = "p2wsh";
|
|
518
|
+
AddressType3["p2tr"] = "p2tr";
|
|
519
|
+
AddressType3["stacks"] = "stacks";
|
|
520
|
+
return AddressType3;
|
|
521
|
+
})(AddressType || {});
|
|
522
|
+
var addressSchema = v2.object({
|
|
523
|
+
address: v2.string(),
|
|
524
|
+
publicKey: v2.string(),
|
|
525
|
+
purpose: v2.enum(AddressPurpose),
|
|
526
|
+
addressType: v2.enum(AddressType)
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// src/addresses/index.ts
|
|
530
|
+
var getAddress = async (options) => {
|
|
531
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
532
|
+
const { purposes } = options.payload;
|
|
533
|
+
if (!purposes) {
|
|
534
|
+
throw new Error("Address purposes are required");
|
|
535
|
+
}
|
|
536
|
+
try {
|
|
537
|
+
const request2 = createUnsecuredToken(options.payload);
|
|
538
|
+
const response = await provider.connect(request2);
|
|
539
|
+
options.onFinish?.(response);
|
|
540
|
+
} catch (error) {
|
|
541
|
+
console.error("[Connect] Error during address request", error);
|
|
542
|
+
options.onCancel?.();
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
// src/request/types/btcMethods.ts
|
|
547
|
+
import * as v3 from "valibot";
|
|
548
|
+
var getInfoMethodName = "getInfo";
|
|
549
|
+
var getInfoParamsSchema = v3.null();
|
|
550
|
+
var getInfoResultSchema = v3.object({
|
|
551
|
+
/**
|
|
552
|
+
* Version of the wallet.
|
|
553
|
+
*/
|
|
554
|
+
version: v3.string(),
|
|
555
|
+
/**
|
|
556
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
557
|
+
*/
|
|
558
|
+
methods: v3.optional(v3.array(v3.string())),
|
|
559
|
+
/**
|
|
560
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
561
|
+
*/
|
|
562
|
+
supports: v3.array(v3.string())
|
|
563
|
+
});
|
|
564
|
+
var getInfoSchema = v3.object({
|
|
565
|
+
...rpcRequestMessageSchema.entries,
|
|
566
|
+
...v3.object({
|
|
567
|
+
method: v3.literal(getInfoMethodName),
|
|
568
|
+
params: getInfoParamsSchema,
|
|
569
|
+
id: v3.string()
|
|
570
|
+
}).entries
|
|
571
|
+
});
|
|
572
|
+
var getAddressesMethodName = "getAddresses";
|
|
573
|
+
var getAddressesParamsSchema = v3.object({
|
|
574
|
+
/**
|
|
575
|
+
* The purposes for which to generate addresses. See
|
|
576
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
577
|
+
*/
|
|
578
|
+
purposes: v3.array(v3.enum(AddressPurpose)),
|
|
579
|
+
/**
|
|
580
|
+
* A message to be displayed to the user in the request prompt.
|
|
581
|
+
*/
|
|
582
|
+
message: v3.optional(v3.string())
|
|
583
|
+
});
|
|
584
|
+
var getAddressesResultSchema = v3.object({
|
|
585
|
+
/**
|
|
586
|
+
* The addresses generated for the given purposes.
|
|
587
|
+
*/
|
|
588
|
+
addresses: v3.array(addressSchema)
|
|
589
|
+
});
|
|
590
|
+
var getAddressesRequestMessageSchema = v3.object({
|
|
591
|
+
...rpcRequestMessageSchema.entries,
|
|
592
|
+
...v3.object({
|
|
593
|
+
method: v3.literal(getAddressesMethodName),
|
|
594
|
+
params: getAddressesParamsSchema,
|
|
595
|
+
id: v3.string()
|
|
596
|
+
}).entries
|
|
597
|
+
});
|
|
598
|
+
var signMessageMethodName = "signMessage";
|
|
599
|
+
var signMessageParamsSchema = v3.object({
|
|
600
|
+
/**
|
|
601
|
+
* The address used for signing.
|
|
602
|
+
**/
|
|
603
|
+
address: v3.string(),
|
|
604
|
+
/**
|
|
605
|
+
* The message to sign.
|
|
606
|
+
**/
|
|
607
|
+
message: v3.string()
|
|
608
|
+
});
|
|
609
|
+
var signMessageResultSchema = v3.object({
|
|
610
|
+
/**
|
|
611
|
+
* The signature of the message.
|
|
612
|
+
*/
|
|
613
|
+
signature: v3.string(),
|
|
614
|
+
/**
|
|
615
|
+
* hash of the message.
|
|
616
|
+
*/
|
|
617
|
+
messageHash: v3.string(),
|
|
618
|
+
/**
|
|
619
|
+
* The address used for signing.
|
|
620
|
+
*/
|
|
621
|
+
address: v3.string()
|
|
622
|
+
});
|
|
623
|
+
var signMessageRequestMessageSchema = v3.object({
|
|
624
|
+
...rpcRequestMessageSchema.entries,
|
|
625
|
+
...v3.object({
|
|
626
|
+
method: v3.literal(signMessageMethodName),
|
|
627
|
+
params: signMessageParamsSchema,
|
|
628
|
+
id: v3.string()
|
|
629
|
+
}).entries
|
|
630
|
+
});
|
|
631
|
+
var getAccountsMethodName = "getAccounts";
|
|
632
|
+
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
633
|
+
var getAccountsResultSchema = v3.array(addressSchema);
|
|
634
|
+
var getAccountsRequestMessageSchema = v3.object({
|
|
635
|
+
...rpcRequestMessageSchema.entries,
|
|
636
|
+
...v3.object({
|
|
637
|
+
method: v3.literal(getAccountsMethodName),
|
|
638
|
+
params: getAccountsParamsSchema,
|
|
639
|
+
id: v3.string()
|
|
640
|
+
}).entries
|
|
641
|
+
});
|
|
642
|
+
|
|
515
643
|
// src/request/index.ts
|
|
516
644
|
var request = async (method, params, providerId) => {
|
|
517
645
|
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
@@ -551,45 +679,6 @@ var XverseAdapter = class extends SatsConnectAdapter {
|
|
|
551
679
|
// src/adapters/unisat.ts
|
|
552
680
|
import { Buffer } from "buffer";
|
|
553
681
|
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
554
|
-
|
|
555
|
-
// src/addresses/index.ts
|
|
556
|
-
import { createUnsecuredToken } from "jsontokens";
|
|
557
|
-
|
|
558
|
-
// src/addresses/types.ts
|
|
559
|
-
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
560
|
-
AddressPurpose2["Ordinals"] = "ordinals";
|
|
561
|
-
AddressPurpose2["Payment"] = "payment";
|
|
562
|
-
AddressPurpose2["Stacks"] = "stacks";
|
|
563
|
-
return AddressPurpose2;
|
|
564
|
-
})(AddressPurpose || {});
|
|
565
|
-
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
566
|
-
AddressType3["p2pkh"] = "p2pkh";
|
|
567
|
-
AddressType3["p2sh"] = "p2sh";
|
|
568
|
-
AddressType3["p2wpkh"] = "p2wpkh";
|
|
569
|
-
AddressType3["p2wsh"] = "p2wsh";
|
|
570
|
-
AddressType3["p2tr"] = "p2tr";
|
|
571
|
-
AddressType3["stacks"] = "stacks";
|
|
572
|
-
return AddressType3;
|
|
573
|
-
})(AddressType || {});
|
|
574
|
-
|
|
575
|
-
// src/addresses/index.ts
|
|
576
|
-
var getAddress = async (options) => {
|
|
577
|
-
const provider = await getProviderOrThrow(options.getProvider);
|
|
578
|
-
const { purposes } = options.payload;
|
|
579
|
-
if (!purposes) {
|
|
580
|
-
throw new Error("Address purposes are required");
|
|
581
|
-
}
|
|
582
|
-
try {
|
|
583
|
-
const request2 = createUnsecuredToken(options.payload);
|
|
584
|
-
const response = await provider.connect(request2);
|
|
585
|
-
options.onFinish?.(response);
|
|
586
|
-
} catch (error) {
|
|
587
|
-
console.error("[Connect] Error during address request", error);
|
|
588
|
-
options.onCancel?.();
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
// src/adapters/unisat.ts
|
|
593
682
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
594
683
|
let result = [];
|
|
595
684
|
for (let address in signInputs) {
|
|
@@ -994,12 +1083,25 @@ export {
|
|
|
994
1083
|
DefaultAdaptersInfo,
|
|
995
1084
|
RpcErrorCode,
|
|
996
1085
|
SatsConnectAdapter,
|
|
1086
|
+
addressSchema,
|
|
997
1087
|
createInscription,
|
|
998
1088
|
createRepeatInscriptions,
|
|
999
1089
|
defaultAdapters,
|
|
1090
|
+
getAccountsMethodName,
|
|
1091
|
+
getAccountsParamsSchema,
|
|
1092
|
+
getAccountsRequestMessageSchema,
|
|
1093
|
+
getAccountsResultSchema,
|
|
1000
1094
|
getAddress,
|
|
1095
|
+
getAddressesMethodName,
|
|
1096
|
+
getAddressesParamsSchema,
|
|
1097
|
+
getAddressesRequestMessageSchema,
|
|
1098
|
+
getAddressesResultSchema,
|
|
1001
1099
|
getCapabilities,
|
|
1002
1100
|
getDefaultProvider,
|
|
1101
|
+
getInfoMethodName,
|
|
1102
|
+
getInfoParamsSchema,
|
|
1103
|
+
getInfoResultSchema,
|
|
1104
|
+
getInfoSchema,
|
|
1003
1105
|
getProviderById,
|
|
1004
1106
|
getProviderOrThrow,
|
|
1005
1107
|
getProviders,
|
|
@@ -1007,9 +1109,14 @@ export {
|
|
|
1007
1109
|
isProviderInstalled,
|
|
1008
1110
|
removeDefaultProvider,
|
|
1009
1111
|
request,
|
|
1112
|
+
rpcRequestMessageSchema,
|
|
1010
1113
|
sendBtcTransaction,
|
|
1011
1114
|
setDefaultProvider,
|
|
1012
1115
|
signMessage,
|
|
1116
|
+
signMessageMethodName,
|
|
1117
|
+
signMessageParamsSchema,
|
|
1118
|
+
signMessageRequestMessageSchema,
|
|
1119
|
+
signMessageResultSchema,
|
|
1013
1120
|
signMultipleTransactions,
|
|
1014
1121
|
signTransaction
|
|
1015
1122
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.11-
|
|
3
|
+
"version": "0.0.11-e6aad2f",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"jsontokens": "4.0.1",
|
|
31
31
|
"lodash.omit": "4.5.0"
|
|
32
32
|
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"valibot": "0.33.2"
|
|
35
|
+
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@types/jest": "^29.2.6",
|
|
35
38
|
"@types/lodash.omit": "4.5.9",
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
"ts-jest": "^29.0.5",
|
|
43
46
|
"ts-loader": "^9.4.1",
|
|
44
47
|
"tsup": "^8.0.2",
|
|
45
|
-
"typescript": "
|
|
48
|
+
"typescript": "5.4.5",
|
|
46
49
|
"util": "^0.12.4",
|
|
47
50
|
"vm-browserify": "^1.1.2",
|
|
48
51
|
"webpack": "^5.74.0",
|