@sats-connect/core 0.0.2-7d8cb11 → 0.0.3
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/README.md +0 -1
- package/dist/index.d.mts +609 -0
- package/dist/index.mjs +596 -0
- package/package.json +6 -3
- package/dist/adapters/BaseAdapter.d.ts +0 -9
- package/dist/adapters/BaseAdapter.js +0 -17
- package/dist/adapters/BaseAdapter.js.map +0 -1
- package/dist/adapters/index.d.ts +0 -6
- package/dist/adapters/index.js +0 -43
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/satsConnectAdapter.d.ts +0 -7
- package/dist/adapters/satsConnectAdapter.js +0 -7
- package/dist/adapters/satsConnectAdapter.js.map +0 -1
- package/dist/adapters/unisat.d.ts +0 -38
- package/dist/adapters/unisat.js +0 -160
- package/dist/adapters/unisat.js.map +0 -1
- package/dist/adapters/xverse.d.ts +0 -8
- package/dist/adapters/xverse.js +0 -14
- package/dist/adapters/xverse.js.map +0 -1
- package/dist/addresses/index.d.ts +0 -3
- package/dist/addresses/index.js +0 -38
- package/dist/addresses/index.js.map +0 -1
- package/dist/addresses/types.d.ts +0 -28
- package/dist/addresses/types.js +0 -19
- package/dist/addresses/types.js.map +0 -1
- package/dist/capabilities/index.d.ts +0 -3
- package/dist/capabilities/index.js +0 -70
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/types.d.ts +0 -6
- package/dist/capabilities/types.js +0 -3
- package/dist/capabilities/types.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -27
- package/dist/index.js.map +0 -1
- package/dist/inscriptions/createInscription.d.ts +0 -2
- package/dist/inscriptions/createInscription.js +0 -22
- package/dist/inscriptions/createInscription.js.map +0 -1
- package/dist/inscriptions/createRepeatInscriptions.d.ts +0 -2
- package/dist/inscriptions/createRepeatInscriptions.js +0 -22
- package/dist/inscriptions/createRepeatInscriptions.js.map +0 -1
- package/dist/inscriptions/index.d.ts +0 -3
- package/dist/inscriptions/index.js +0 -20
- package/dist/inscriptions/index.js.map +0 -1
- package/dist/inscriptions/types.d.ts +0 -21
- package/dist/inscriptions/types.js +0 -3
- package/dist/inscriptions/types.js.map +0 -1
- package/dist/inscriptions/utils.d.ts +0 -2
- package/dist/inscriptions/utils.js +0 -26
- package/dist/inscriptions/utils.js.map +0 -1
- package/dist/messages/index.d.ts +0 -3
- package/dist/messages/index.js +0 -41
- package/dist/messages/index.js.map +0 -1
- package/dist/messages/types.d.ts +0 -7
- package/dist/messages/types.js +0 -3
- package/dist/messages/types.js.map +0 -1
- package/dist/provider/index.d.ts +0 -10
- package/dist/provider/index.js +0 -74
- package/dist/provider/index.js.map +0 -1
- package/dist/provider/types.d.ts +0 -46
- package/dist/provider/types.js +0 -3
- package/dist/provider/types.js.map +0 -1
- package/dist/request/index.d.ts +0 -4
- package/dist/request/index.js +0 -47
- package/dist/request/index.js.map +0 -1
- package/dist/request/types/btcMethods.d.ts +0 -127
- package/dist/request/types/btcMethods.js +0 -6
- package/dist/request/types/btcMethods.js.map +0 -1
- package/dist/request/types/index.d.ts +0 -27
- package/dist/request/types/index.js +0 -19
- package/dist/request/types/index.js.map +0 -1
- package/dist/request/types/stxMethods.d.ts +0 -181
- package/dist/request/types/stxMethods.js +0 -3
- package/dist/request/types/stxMethods.js.map +0 -1
- package/dist/transactions/index.d.ts +0 -4
- package/dist/transactions/index.js +0 -21
- package/dist/transactions/index.js.map +0 -1
- package/dist/transactions/sendBtcTransaction.d.ts +0 -2
- package/dist/transactions/sendBtcTransaction.js +0 -45
- package/dist/transactions/sendBtcTransaction.js.map +0 -1
- package/dist/transactions/signMultipleTransactions.d.ts +0 -2
- package/dist/transactions/signMultipleTransactions.js +0 -26
- package/dist/transactions/signMultipleTransactions.js.map +0 -1
- package/dist/transactions/signTransaction.d.ts +0 -2
- package/dist/transactions/signTransaction.js +0 -26
- package/dist/transactions/signTransaction.js.map +0 -1
- package/dist/transactions/types.d.ts +0 -46
- package/dist/transactions/types.js +0 -3
- package/dist/transactions/types.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -87
- package/dist/types.js +0 -46
- package/dist/types.js.map +0 -1
- package/dist/ui/index.d.ts +0 -5
- package/dist/ui/index.js +0 -27
- package/dist/ui/index.js.map +0 -1
package/README.md
CHANGED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
interface GetCapabilitiesPayload extends RequestPayload {
|
|
2
|
+
}
|
|
3
|
+
type GetCapabilitiesResponse = Capability[];
|
|
4
|
+
type GetCapabilitiesOptions = RequestOptions<GetCapabilitiesPayload, GetCapabilitiesResponse>;
|
|
5
|
+
|
|
6
|
+
declare const getCapabilities: (options: GetCapabilitiesOptions) => Promise<void>;
|
|
7
|
+
|
|
8
|
+
interface CreateInscriptionPayload extends RequestPayload {
|
|
9
|
+
contentType: string;
|
|
10
|
+
content: string;
|
|
11
|
+
payloadType: 'PLAIN_TEXT' | 'BASE_64';
|
|
12
|
+
appFee?: number;
|
|
13
|
+
appFeeAddress?: string;
|
|
14
|
+
suggestedMinerFeeRate?: number;
|
|
15
|
+
token?: string;
|
|
16
|
+
}
|
|
17
|
+
interface CreateRepeatInscriptionsPayload extends CreateInscriptionPayload {
|
|
18
|
+
repeat: number;
|
|
19
|
+
}
|
|
20
|
+
type CreateInscriptionResponse = {
|
|
21
|
+
txId: string;
|
|
22
|
+
};
|
|
23
|
+
type CreateRepeatInscriptionsResponse = {
|
|
24
|
+
txId: string;
|
|
25
|
+
};
|
|
26
|
+
type CreateInscriptionOptions = RequestOptions<CreateInscriptionPayload, CreateInscriptionResponse>;
|
|
27
|
+
type CreateRepeatInscriptionsOptions = RequestOptions<CreateRepeatInscriptionsPayload, CreateRepeatInscriptionsResponse>;
|
|
28
|
+
|
|
29
|
+
declare const createInscription: (options: CreateInscriptionOptions) => Promise<void>;
|
|
30
|
+
|
|
31
|
+
declare const createRepeatInscriptions: (options: CreateRepeatInscriptionsOptions) => Promise<void>;
|
|
32
|
+
|
|
33
|
+
interface SignMessagePayload extends RequestPayload {
|
|
34
|
+
address: string;
|
|
35
|
+
message: string;
|
|
36
|
+
}
|
|
37
|
+
type SignMessageResponse = string;
|
|
38
|
+
type SignMessageOptions = RequestOptions<SignMessagePayload, SignMessageResponse>;
|
|
39
|
+
|
|
40
|
+
declare const signMessage: (options: SignMessageOptions) => Promise<void>;
|
|
41
|
+
|
|
42
|
+
interface Recipient$2 {
|
|
43
|
+
address: string;
|
|
44
|
+
amountSats: bigint;
|
|
45
|
+
}
|
|
46
|
+
type SerializedRecipient = Omit<Recipient$2, 'amountSats'> & {
|
|
47
|
+
amountSats: string;
|
|
48
|
+
};
|
|
49
|
+
interface SendBtcTransactionPayload extends RequestPayload {
|
|
50
|
+
recipients: Recipient$2[];
|
|
51
|
+
senderAddress: string;
|
|
52
|
+
message?: string;
|
|
53
|
+
}
|
|
54
|
+
type SerializedSendBtcTransactionPayload = Omit<SendBtcTransactionPayload, 'recipients'> & {
|
|
55
|
+
recipients: SerializedRecipient[];
|
|
56
|
+
};
|
|
57
|
+
type SendBtcTransactionResponse = string;
|
|
58
|
+
type SendBtcTransactionOptions = RequestOptions<SendBtcTransactionPayload, SendBtcTransactionResponse>;
|
|
59
|
+
interface InputToSign {
|
|
60
|
+
address: string;
|
|
61
|
+
signingIndexes: number[];
|
|
62
|
+
sigHash?: number;
|
|
63
|
+
}
|
|
64
|
+
type PsbtPayload = {
|
|
65
|
+
psbtBase64: string;
|
|
66
|
+
inputsToSign: InputToSign[];
|
|
67
|
+
broadcast?: boolean;
|
|
68
|
+
};
|
|
69
|
+
type SignMultiplePsbtPayload = {
|
|
70
|
+
psbtBase64: string;
|
|
71
|
+
inputsToSign: InputToSign[];
|
|
72
|
+
};
|
|
73
|
+
interface SignTransactionPayload extends RequestPayload, PsbtPayload {
|
|
74
|
+
message: string;
|
|
75
|
+
}
|
|
76
|
+
interface SignTransactionResponse {
|
|
77
|
+
psbtBase64: string;
|
|
78
|
+
txId?: string;
|
|
79
|
+
}
|
|
80
|
+
type SignTransactionOptions = RequestOptions<SignTransactionPayload, SignTransactionResponse>;
|
|
81
|
+
interface SignMultipleTransactionsPayload extends RequestPayload {
|
|
82
|
+
message: string;
|
|
83
|
+
psbts: SignMultiplePsbtPayload[];
|
|
84
|
+
}
|
|
85
|
+
type SignMultipleTransactionsResponse = SignTransactionResponse[];
|
|
86
|
+
type SignMultipleTransactionOptions = RequestOptions<SignMultipleTransactionsPayload, SignMultipleTransactionsResponse>;
|
|
87
|
+
|
|
88
|
+
declare const sendBtcTransaction: (options: SendBtcTransactionOptions) => Promise<void>;
|
|
89
|
+
|
|
90
|
+
declare const signTransaction: (options: SignTransactionOptions) => Promise<void>;
|
|
91
|
+
|
|
92
|
+
declare const signMultipleTransactions: (options: SignMultipleTransactionOptions) => Promise<void>;
|
|
93
|
+
|
|
94
|
+
interface BaseBitcoinProvider {
|
|
95
|
+
request: <Method extends keyof Requests>(method: Method, options: Params<Method>, providerId?: string) => Promise<RpcResponse<Method>>;
|
|
96
|
+
connect: (request: string) => Promise<GetAddressResponse>;
|
|
97
|
+
signMessage: (request: string) => Promise<SignMessageResponse>;
|
|
98
|
+
signTransaction: (request: string) => Promise<SignTransactionResponse>;
|
|
99
|
+
sendBtcTransaction: (request: string) => Promise<SendBtcTransactionResponse>;
|
|
100
|
+
createInscription: (request: string) => Promise<CreateInscriptionResponse>;
|
|
101
|
+
createRepeatInscriptions: (request: string) => Promise<CreateRepeatInscriptionsResponse>;
|
|
102
|
+
signMultipleTransactions: (request: string) => Promise<SignMultipleTransactionsResponse>;
|
|
103
|
+
}
|
|
104
|
+
type Capability = keyof BaseBitcoinProvider;
|
|
105
|
+
interface BitcoinProvider extends BaseBitcoinProvider {
|
|
106
|
+
getCapabilities?: (request: string) => Promise<GetCapabilitiesResponse>;
|
|
107
|
+
}
|
|
108
|
+
interface Provider {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
icon: string;
|
|
112
|
+
webUrl?: string;
|
|
113
|
+
chromeWebStoreUrl?: string;
|
|
114
|
+
mozillaAddOnsUrl?: string;
|
|
115
|
+
googlePlayStoreUrl?: string;
|
|
116
|
+
iOSAppStoreUrl?: string;
|
|
117
|
+
methods?: (StxRequestMethod | BtcRequestMethod)[];
|
|
118
|
+
}
|
|
119
|
+
interface SupportedWallet extends Provider {
|
|
120
|
+
isInstalled: boolean;
|
|
121
|
+
}
|
|
122
|
+
declare global {
|
|
123
|
+
interface XverseProviders {
|
|
124
|
+
BitcoinProvider?: BitcoinProvider;
|
|
125
|
+
}
|
|
126
|
+
interface Window {
|
|
127
|
+
BitcoinProvider?: BitcoinProvider;
|
|
128
|
+
XverseProviders?: XverseProviders;
|
|
129
|
+
btc_providers?: Provider[];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare function getProviderOrThrow(getProvider?: () => Promise<BitcoinProvider | undefined>): Promise<BitcoinProvider>;
|
|
134
|
+
declare function getProviders(): Provider[];
|
|
135
|
+
declare function getProviderById(providerId: string): any;
|
|
136
|
+
declare function isProviderInstalled(providerId: string): boolean;
|
|
137
|
+
declare function setDefaultProvider(providerId: string): void;
|
|
138
|
+
declare function getDefaultProvider(): string | null;
|
|
139
|
+
declare function removeDefaultProvider(): void;
|
|
140
|
+
declare function getSupportedWallets(): SupportedWallet[];
|
|
141
|
+
|
|
142
|
+
declare enum BitcoinNetworkType {
|
|
143
|
+
Mainnet = "Mainnet",
|
|
144
|
+
Testnet = "Testnet"
|
|
145
|
+
}
|
|
146
|
+
interface BitcoinNetwork {
|
|
147
|
+
type: BitcoinNetworkType;
|
|
148
|
+
address?: string;
|
|
149
|
+
}
|
|
150
|
+
interface RequestPayload {
|
|
151
|
+
network: BitcoinNetwork;
|
|
152
|
+
}
|
|
153
|
+
interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
154
|
+
onFinish: (response: Response) => void;
|
|
155
|
+
onCancel: () => void;
|
|
156
|
+
payload: Payload;
|
|
157
|
+
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
158
|
+
}
|
|
159
|
+
type RpcId = string | null;
|
|
160
|
+
interface RpcBase {
|
|
161
|
+
jsonrpc: '2.0';
|
|
162
|
+
id: RpcId;
|
|
163
|
+
}
|
|
164
|
+
interface RpcRequest<T extends string, U> extends RpcBase {
|
|
165
|
+
method: T;
|
|
166
|
+
params: U;
|
|
167
|
+
}
|
|
168
|
+
interface MethodParamsAndResult<TParams, TResult> {
|
|
169
|
+
params: TParams;
|
|
170
|
+
result: TResult;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* @enum {number} RpcErrorCode
|
|
174
|
+
* @description JSON-RPC error codes
|
|
175
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
176
|
+
*/
|
|
177
|
+
declare enum RpcErrorCode {
|
|
178
|
+
/**
|
|
179
|
+
* Parse error Invalid JSON
|
|
180
|
+
**/
|
|
181
|
+
PARSE_ERROR = -32700,
|
|
182
|
+
/**
|
|
183
|
+
* The JSON sent is not a valid Request object.
|
|
184
|
+
**/
|
|
185
|
+
INVALID_REQUEST = -32600,
|
|
186
|
+
/**
|
|
187
|
+
* The method does not exist/is not available.
|
|
188
|
+
**/
|
|
189
|
+
METHOD_NOT_FOUND = -32601,
|
|
190
|
+
/**
|
|
191
|
+
* Invalid method parameter(s).
|
|
192
|
+
*/
|
|
193
|
+
INVALID_PARAMS = -32602,
|
|
194
|
+
/**
|
|
195
|
+
* Internal JSON-RPC error.
|
|
196
|
+
* This is a generic error, used when the server encounters an error in performing the request.
|
|
197
|
+
**/
|
|
198
|
+
INTERNAL_ERROR = -32603,
|
|
199
|
+
/**
|
|
200
|
+
* user rejected/canceled the request
|
|
201
|
+
*/
|
|
202
|
+
USER_REJECTION = -32000,
|
|
203
|
+
/**
|
|
204
|
+
* method is not supported for the address provided
|
|
205
|
+
*/
|
|
206
|
+
METHOD_NOT_SUPPORTED = -32001
|
|
207
|
+
}
|
|
208
|
+
interface RpcError {
|
|
209
|
+
code: number | RpcErrorCode;
|
|
210
|
+
message: string;
|
|
211
|
+
data?: any;
|
|
212
|
+
}
|
|
213
|
+
interface RpcErrorResponse<TError extends RpcError = RpcError> extends RpcBase {
|
|
214
|
+
error: TError;
|
|
215
|
+
}
|
|
216
|
+
interface RpcSuccessResponse<Method extends keyof Requests> extends RpcBase {
|
|
217
|
+
result: Return<Method>;
|
|
218
|
+
}
|
|
219
|
+
type RpcResponse<Method extends keyof Requests> = RpcSuccessResponse<Method> | RpcErrorResponse;
|
|
220
|
+
type RpcResult<Method extends keyof Requests> = {
|
|
221
|
+
result: RpcSuccessResponse<Method>['result'];
|
|
222
|
+
status: 'success';
|
|
223
|
+
} | {
|
|
224
|
+
error: RpcErrorResponse['error'];
|
|
225
|
+
status: 'error';
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
declare enum AddressPurpose {
|
|
229
|
+
Ordinals = "ordinals",
|
|
230
|
+
Payment = "payment",
|
|
231
|
+
Stacks = "stacks"
|
|
232
|
+
}
|
|
233
|
+
interface GetAddressPayload extends RequestPayload {
|
|
234
|
+
purposes: AddressPurpose[];
|
|
235
|
+
message: string;
|
|
236
|
+
}
|
|
237
|
+
declare enum AddressType {
|
|
238
|
+
p2pkh = "p2pkh",
|
|
239
|
+
p2sh = "p2sh",
|
|
240
|
+
p2wpkh = "p2wpkh",
|
|
241
|
+
p2wsh = "p2wsh",
|
|
242
|
+
p2tr = "p2tr",
|
|
243
|
+
stacks = "stacks"
|
|
244
|
+
}
|
|
245
|
+
interface Address$1 {
|
|
246
|
+
address: string;
|
|
247
|
+
publicKey: string;
|
|
248
|
+
purpose?: AddressPurpose;
|
|
249
|
+
addressType?: AddressType;
|
|
250
|
+
}
|
|
251
|
+
interface GetAddressResponse {
|
|
252
|
+
addresses: Address$1[];
|
|
253
|
+
}
|
|
254
|
+
type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
255
|
+
|
|
256
|
+
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Represents the types and interfaces related to BTC methods.
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
type GetInfoResult = {
|
|
263
|
+
version: number | string;
|
|
264
|
+
methods?: Array<string>;
|
|
265
|
+
supports?: Array<string>;
|
|
266
|
+
};
|
|
267
|
+
type GetInfo = MethodParamsAndResult<null, GetInfoResult>;
|
|
268
|
+
type GetAddressesParams$1 = {
|
|
269
|
+
/**
|
|
270
|
+
* The purposes for which to generate addresses.
|
|
271
|
+
* possible values are "payment", "ordinals", ...
|
|
272
|
+
*/
|
|
273
|
+
purposes: Array<AddressPurpose>;
|
|
274
|
+
/**
|
|
275
|
+
* a message to be displayed to the user in the request prompt.
|
|
276
|
+
*/
|
|
277
|
+
message?: string;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* The addresses generated for the given purposes.
|
|
281
|
+
*/
|
|
282
|
+
type GetAddressesResult$1 = {
|
|
283
|
+
addresses: Array<Address$1>;
|
|
284
|
+
};
|
|
285
|
+
type GetAddresses = MethodParamsAndResult<GetAddressesParams$1, GetAddressesResult$1>;
|
|
286
|
+
type SignMessageParams = {
|
|
287
|
+
/**
|
|
288
|
+
* The address used for signing.
|
|
289
|
+
**/
|
|
290
|
+
address: string;
|
|
291
|
+
/**
|
|
292
|
+
* The message to sign.
|
|
293
|
+
**/
|
|
294
|
+
message: string;
|
|
295
|
+
};
|
|
296
|
+
type SignMessageResult = {
|
|
297
|
+
/**
|
|
298
|
+
* The signature of the message.
|
|
299
|
+
*/
|
|
300
|
+
signature: string;
|
|
301
|
+
/**
|
|
302
|
+
* hash of the message.
|
|
303
|
+
*/
|
|
304
|
+
messageHash: string;
|
|
305
|
+
/**
|
|
306
|
+
* The address used for signing.
|
|
307
|
+
*/
|
|
308
|
+
address: string;
|
|
309
|
+
};
|
|
310
|
+
type SignMessage = MethodParamsAndResult<SignMessageParams, SignMessageResult>;
|
|
311
|
+
type Recipient$1 = {
|
|
312
|
+
/**
|
|
313
|
+
* The recipient's address.
|
|
314
|
+
**/
|
|
315
|
+
address: string;
|
|
316
|
+
/**
|
|
317
|
+
* The amount to send to the recipient in satoshis.
|
|
318
|
+
*/
|
|
319
|
+
amount: number;
|
|
320
|
+
};
|
|
321
|
+
type SendTransferParams = {
|
|
322
|
+
/**
|
|
323
|
+
* Array of recipients to send to.
|
|
324
|
+
* The amount to send to each recipient is in satoshis.
|
|
325
|
+
*/
|
|
326
|
+
recipients: Array<Recipient$1>;
|
|
327
|
+
};
|
|
328
|
+
type SendTransferResult = {
|
|
329
|
+
/**
|
|
330
|
+
* The transaction id as a hex-encoded string.
|
|
331
|
+
*/
|
|
332
|
+
txid: string;
|
|
333
|
+
};
|
|
334
|
+
type SendTransfer = MethodParamsAndResult<SendTransferParams, SendTransferResult>;
|
|
335
|
+
type SignPsbtParams = {
|
|
336
|
+
/**
|
|
337
|
+
* The base64 encoded PSBT to sign.
|
|
338
|
+
*/
|
|
339
|
+
psbt: string;
|
|
340
|
+
/**
|
|
341
|
+
* The inputs to sign.
|
|
342
|
+
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
343
|
+
*/
|
|
344
|
+
signInputs: Record<string, number[]>;
|
|
345
|
+
/**
|
|
346
|
+
* the sigHash type to use for signing.
|
|
347
|
+
* will default to the sighash type of the input if not provided.
|
|
348
|
+
**/
|
|
349
|
+
allowedSignHash?: number;
|
|
350
|
+
/**
|
|
351
|
+
* Whether to broadcast the transaction after signing.
|
|
352
|
+
**/
|
|
353
|
+
broadcast?: boolean;
|
|
354
|
+
};
|
|
355
|
+
type SignPsbtResult = {
|
|
356
|
+
/**
|
|
357
|
+
* The base64 encoded PSBT after signing.
|
|
358
|
+
*/
|
|
359
|
+
psbt: string;
|
|
360
|
+
/**
|
|
361
|
+
* The transaction id as a hex-encoded string.
|
|
362
|
+
* This is only returned if the transaction was broadcast.
|
|
363
|
+
**/
|
|
364
|
+
txid?: string;
|
|
365
|
+
};
|
|
366
|
+
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
367
|
+
type GetAccountsParams = {
|
|
368
|
+
/**
|
|
369
|
+
* The purposes for which to generate addresses.
|
|
370
|
+
* possible values are "payment", "ordinals", ...
|
|
371
|
+
*/
|
|
372
|
+
purposes: Array<AddressPurpose>;
|
|
373
|
+
/**
|
|
374
|
+
* a message to be displayed to the user in the request prompt.
|
|
375
|
+
*/
|
|
376
|
+
/**
|
|
377
|
+
* a message to be displayed to the user in the request prompt.
|
|
378
|
+
*/
|
|
379
|
+
message?: string;
|
|
380
|
+
};
|
|
381
|
+
type GetAccountResult = Address$1[];
|
|
382
|
+
type GetAccounts = MethodParamsAndResult<GetAccountsParams, GetAccountResult>;
|
|
383
|
+
|
|
384
|
+
interface Pubkey {
|
|
385
|
+
/**
|
|
386
|
+
* When sending a transfer STX request to a wallet, users can generally
|
|
387
|
+
* choose from which accout they want to send the STX tokens from. In
|
|
388
|
+
* cases where applications want the transfer to be made from a specific
|
|
389
|
+
* account, they can provide the `pubkey` of the address they'd like the
|
|
390
|
+
* transfer to be made from. It is up to wallet providers to handle this
|
|
391
|
+
* field as they see fit.
|
|
392
|
+
*/
|
|
393
|
+
pubkey: string;
|
|
394
|
+
}
|
|
395
|
+
interface Address {
|
|
396
|
+
/**
|
|
397
|
+
* A Crockford base-32 encoded Stacks address.
|
|
398
|
+
*/
|
|
399
|
+
address: string;
|
|
400
|
+
}
|
|
401
|
+
interface PostConditions {
|
|
402
|
+
/**
|
|
403
|
+
* A hex-encoded string representing the post conditions.
|
|
404
|
+
*
|
|
405
|
+
* A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
|
|
406
|
+
*
|
|
407
|
+
* ```js
|
|
408
|
+
* import { serializePostCondition } from '@stacks/transactions';
|
|
409
|
+
*
|
|
410
|
+
* const postCondition = somePostCondition;
|
|
411
|
+
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
postConditions: Array<string>;
|
|
415
|
+
}
|
|
416
|
+
interface PostConditionMode {
|
|
417
|
+
/**
|
|
418
|
+
* The mode of the post conditions.
|
|
419
|
+
*/
|
|
420
|
+
postConditionMode: number;
|
|
421
|
+
}
|
|
422
|
+
interface ParameterFormatVersion {
|
|
423
|
+
/**
|
|
424
|
+
* Version of parameter format.
|
|
425
|
+
*/
|
|
426
|
+
version: string;
|
|
427
|
+
}
|
|
428
|
+
interface Recipient {
|
|
429
|
+
/**
|
|
430
|
+
* The recipeint's Crockford base-32 encoded Stacks address.
|
|
431
|
+
*/
|
|
432
|
+
recipient: string;
|
|
433
|
+
}
|
|
434
|
+
interface Amount {
|
|
435
|
+
/**
|
|
436
|
+
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
437
|
+
* parseable by `BigInt` is acceptable.
|
|
438
|
+
*
|
|
439
|
+
* Example,
|
|
440
|
+
*
|
|
441
|
+
* ```js
|
|
442
|
+
* const amount1 = 1234;
|
|
443
|
+
* const amount2 = 1234n;
|
|
444
|
+
* const amount3 = '1234';
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
amount: number | string;
|
|
448
|
+
}
|
|
449
|
+
interface Memo {
|
|
450
|
+
/**
|
|
451
|
+
* A string representing the memo.
|
|
452
|
+
*/
|
|
453
|
+
memo: string;
|
|
454
|
+
}
|
|
455
|
+
interface TxId {
|
|
456
|
+
/**
|
|
457
|
+
* The ID of the transaction.
|
|
458
|
+
*/
|
|
459
|
+
txid: string;
|
|
460
|
+
}
|
|
461
|
+
interface Transaction {
|
|
462
|
+
/**
|
|
463
|
+
* A Stacks transaction as a hex-encoded string.
|
|
464
|
+
*/
|
|
465
|
+
transaction: string;
|
|
466
|
+
}
|
|
467
|
+
interface Message {
|
|
468
|
+
/**
|
|
469
|
+
* Message payload to be signed.
|
|
470
|
+
*/
|
|
471
|
+
message: string;
|
|
472
|
+
}
|
|
473
|
+
interface Signature {
|
|
474
|
+
/**
|
|
475
|
+
* Signature of the message.
|
|
476
|
+
*/
|
|
477
|
+
signature: string;
|
|
478
|
+
}
|
|
479
|
+
interface PublicKey {
|
|
480
|
+
/**
|
|
481
|
+
* Public key as hex-encoded string.
|
|
482
|
+
*/
|
|
483
|
+
publicKey: string;
|
|
484
|
+
}
|
|
485
|
+
interface Domain {
|
|
486
|
+
/**
|
|
487
|
+
* The domain to be signed.
|
|
488
|
+
*/
|
|
489
|
+
domain: string;
|
|
490
|
+
}
|
|
491
|
+
interface CallContractParams {
|
|
492
|
+
/**
|
|
493
|
+
* The contract's Crockford base-32 encoded Stacks address and name.
|
|
494
|
+
*
|
|
495
|
+
* E.g. `"SPKE...GD5C.my-contract"`
|
|
496
|
+
*/
|
|
497
|
+
contract: string;
|
|
498
|
+
/**
|
|
499
|
+
* The name of the function to call.
|
|
500
|
+
*
|
|
501
|
+
* Note: spec changes ongoing,
|
|
502
|
+
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
503
|
+
*/
|
|
504
|
+
functionName: string;
|
|
505
|
+
/**
|
|
506
|
+
* The function's arguments. The arguments are expected to be hex-encoded
|
|
507
|
+
* strings of Clarity values.
|
|
508
|
+
*
|
|
509
|
+
* To convert Clarity values to their hex representation, the `cvToString`
|
|
510
|
+
* helper from the `@stacks/transactions` package may be helpful.
|
|
511
|
+
*
|
|
512
|
+
* ```js
|
|
513
|
+
* import { cvToString } from '@stacks/transactions';
|
|
514
|
+
*
|
|
515
|
+
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
516
|
+
* const hexArgs = functionArgs.map(cvToString);
|
|
517
|
+
* ```
|
|
518
|
+
*/
|
|
519
|
+
arguments?: Array<string>;
|
|
520
|
+
}
|
|
521
|
+
type CallContractResult = TxId & Transaction;
|
|
522
|
+
type StxCallContract = MethodParamsAndResult<CallContractParams, CallContractResult>;
|
|
523
|
+
type TransferStxParams = Amount & Recipient & Partial<Memo> & Partial<ParameterFormatVersion> & Partial<PostConditionMode> & Partial<PostConditions> & Partial<Pubkey>;
|
|
524
|
+
type TransferStxResult = TxId & Transaction;
|
|
525
|
+
type StxTransferStx = MethodParamsAndResult<TransferStxParams, TransferStxResult>;
|
|
526
|
+
type SignStxMessageParams = Message & Partial<Pubkey> & Partial<ParameterFormatVersion>;
|
|
527
|
+
type SignStxMessageResult = Signature & PublicKey;
|
|
528
|
+
type StxSignStxMessage = MethodParamsAndResult<SignStxMessageParams, SignStxMessageResult>;
|
|
529
|
+
type SignStructuredMessageParams = Domain & Message & Partial<ParameterFormatVersion> & Partial<Pubkey>;
|
|
530
|
+
type SignStructuredMessageResult = Signature & PublicKey;
|
|
531
|
+
type StxSignStructuredMessage = MethodParamsAndResult<SignStructuredMessageParams, SignStructuredMessageResult>;
|
|
532
|
+
interface DeployContractParams {
|
|
533
|
+
/**
|
|
534
|
+
* Name of the contract.
|
|
535
|
+
*/
|
|
536
|
+
name: string;
|
|
537
|
+
/**
|
|
538
|
+
* The code of the Clarity contract.
|
|
539
|
+
*/
|
|
540
|
+
clarityCode: string;
|
|
541
|
+
/**
|
|
542
|
+
* The version of the Clarity contract.
|
|
543
|
+
*/
|
|
544
|
+
clarityVersion?: string;
|
|
545
|
+
}
|
|
546
|
+
type DeployContractResult = TxId & Transaction;
|
|
547
|
+
type StxDeployContract = MethodParamsAndResult<DeployContractParams, DeployContractResult>;
|
|
548
|
+
type GetAccountsResult = {
|
|
549
|
+
addresses: Array<Address & PublicKey & {
|
|
550
|
+
gaiaHubUrl: string;
|
|
551
|
+
gaiaAppKey: string;
|
|
552
|
+
}>;
|
|
553
|
+
};
|
|
554
|
+
type StxGetAccounts = MethodParamsAndResult<{}, GetAccountsResult>;
|
|
555
|
+
type GetAddressesParams = undefined | null;
|
|
556
|
+
type GetAddressesResult = {
|
|
557
|
+
addresses: Array<Address & PublicKey>;
|
|
558
|
+
};
|
|
559
|
+
type StxGetAddresses = MethodParamsAndResult<GetAddressesParams, GetAddressesResult>;
|
|
560
|
+
type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
561
|
+
type SignTransactionResult = Transaction;
|
|
562
|
+
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
563
|
+
|
|
564
|
+
interface StxRequests {
|
|
565
|
+
stx_callContract: StxCallContract;
|
|
566
|
+
stx_deployContract: StxDeployContract;
|
|
567
|
+
stx_getAccounts: StxGetAccounts;
|
|
568
|
+
stx_getAddresses: StxGetAddresses;
|
|
569
|
+
stx_signMessage: StxSignStxMessage;
|
|
570
|
+
stx_signStructuredMessage: StxSignStructuredMessage;
|
|
571
|
+
stx_signTransaction: StxSignTransaction;
|
|
572
|
+
stx_transferStx: StxTransferStx;
|
|
573
|
+
}
|
|
574
|
+
type StxRequestMethod = keyof StxRequests;
|
|
575
|
+
interface BtcRequests {
|
|
576
|
+
getInfo: GetInfo;
|
|
577
|
+
getAddresses: GetAddresses;
|
|
578
|
+
getAccounts: GetAccounts;
|
|
579
|
+
signMessage: SignMessage;
|
|
580
|
+
sendTransfer: SendTransfer;
|
|
581
|
+
signPsbt: SignPsbt;
|
|
582
|
+
}
|
|
583
|
+
type BtcRequestMethod = keyof BtcRequests;
|
|
584
|
+
type Requests = BtcRequests & StxRequests;
|
|
585
|
+
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
586
|
+
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
587
|
+
|
|
588
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
589
|
+
|
|
590
|
+
declare abstract class SatsConnectAdapter {
|
|
591
|
+
abstract readonly id: string;
|
|
592
|
+
abstract request<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method> | undefined>;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
declare class BaseAdapter extends SatsConnectAdapter {
|
|
596
|
+
id: string;
|
|
597
|
+
constructor(providerId: string);
|
|
598
|
+
request: <Method extends keyof BtcRequests | keyof StxRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method> | undefined>;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
602
|
+
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
603
|
+
|
|
604
|
+
interface Config {
|
|
605
|
+
providers: SupportedWallet[];
|
|
606
|
+
}
|
|
607
|
+
declare function createDefaultConfig(providers: SupportedWallet[]): Config;
|
|
608
|
+
|
|
609
|
+
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 Config, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccountResult, type GetAccounts, type GetAccountsParams, 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 RpcResponse, type RpcResult, type RpcSuccessResponse, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, 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, createDefaultConfig, createInscription, createRepeatInscriptions, defaultAdapters, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction };
|