@sats-connect/core 0.4.0-8f3e1e5 → 0.4.0-9147908
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 +580 -272
- package/dist/index.d.ts +1954 -0
- package/dist/index.js +2290 -0
- package/dist/index.mjs +699 -255
- package/package.json +9 -12
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/provider/index.ts
|
|
2
|
-
import omit from "lodash.omit";
|
|
3
|
-
|
|
4
1
|
// src/provider/types.ts
|
|
5
2
|
import * as v from "valibot";
|
|
6
3
|
var accountChangeEventName = "accountChange";
|
|
@@ -50,11 +47,9 @@ function removeDefaultProvider() {
|
|
|
50
47
|
localStorage.removeItem("sats-connect_defaultProvider");
|
|
51
48
|
}
|
|
52
49
|
function getSupportedWallets() {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
allProviders.push(DefaultAdaptersInfo[key]);
|
|
57
|
-
}
|
|
50
|
+
const ambientProviders = getProviders();
|
|
51
|
+
const { xverse, ...defaultProviders } = DefaultAdaptersInfo;
|
|
52
|
+
const allProviders = [...ambientProviders, ...Object.values(defaultProviders)];
|
|
58
53
|
const wallets = allProviders.map((provider) => {
|
|
59
54
|
{
|
|
60
55
|
return {
|
|
@@ -68,11 +63,11 @@ function getSupportedWallets() {
|
|
|
68
63
|
|
|
69
64
|
// src/types.ts
|
|
70
65
|
import * as v2 from "valibot";
|
|
71
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
66
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
67
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
68
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
69
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
70
|
+
return BitcoinNetworkType2;
|
|
76
71
|
})(BitcoinNetworkType || {});
|
|
77
72
|
var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
|
|
78
73
|
var rpcRequestMessageSchema = v2.object({
|
|
@@ -118,13 +113,127 @@ var rpcResponseMessageSchema = v2.union([
|
|
|
118
113
|
]);
|
|
119
114
|
|
|
120
115
|
// src/request/index.ts
|
|
121
|
-
import * as
|
|
116
|
+
import * as v20 from "valibot";
|
|
117
|
+
|
|
118
|
+
// src/request/types/stxMethods/callContract.ts
|
|
119
|
+
import * as v3 from "valibot";
|
|
120
|
+
var stxCallContractMethodName = "stx_callContract";
|
|
121
|
+
var stxCallContractParamsSchema = v3.object({
|
|
122
|
+
/**
|
|
123
|
+
* The contract principal.
|
|
124
|
+
*
|
|
125
|
+
* E.g. `"SPKE...GD5C.my-contract"`
|
|
126
|
+
*/
|
|
127
|
+
contract: v3.string(),
|
|
128
|
+
/**
|
|
129
|
+
* The name of the function to call.
|
|
130
|
+
*
|
|
131
|
+
* Note: spec changes ongoing,
|
|
132
|
+
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
133
|
+
*/
|
|
134
|
+
functionName: v3.string(),
|
|
135
|
+
/**
|
|
136
|
+
* The function's arguments. The arguments are expected to be hex-encoded
|
|
137
|
+
* strings of Clarity values.
|
|
138
|
+
*
|
|
139
|
+
* To convert Clarity values to their hex representation, the `cvToString`
|
|
140
|
+
* helper from the `@stacks/transactions` package may be helpful.
|
|
141
|
+
*
|
|
142
|
+
* ```js
|
|
143
|
+
* import { cvToString } from '@stacks/transactions';
|
|
144
|
+
*
|
|
145
|
+
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
146
|
+
* const hexArgs = functionArgs.map(cvToString);
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
arguments: v3.optional(v3.array(v3.string()))
|
|
150
|
+
});
|
|
151
|
+
var stxCallContractResultSchema = v3.object({
|
|
152
|
+
/**
|
|
153
|
+
* The ID of the transaction.
|
|
154
|
+
*/
|
|
155
|
+
txid: v3.string(),
|
|
156
|
+
/**
|
|
157
|
+
* A Stacks transaction as a hex-encoded string.
|
|
158
|
+
*/
|
|
159
|
+
transaction: v3.string()
|
|
160
|
+
});
|
|
161
|
+
var stxCallContractRequestMessageSchema = v3.object({
|
|
162
|
+
...rpcRequestMessageSchema.entries,
|
|
163
|
+
...v3.object({
|
|
164
|
+
method: v3.literal(stxCallContractMethodName),
|
|
165
|
+
params: stxCallContractParamsSchema,
|
|
166
|
+
id: v3.string()
|
|
167
|
+
}).entries
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// src/request/types/stxMethods/deployContract.ts
|
|
171
|
+
import * as v4 from "valibot";
|
|
172
|
+
var stxDeployContractMethodName = "stx_deployContract";
|
|
173
|
+
var stxDeployContractParamsSchema = v4.object({
|
|
174
|
+
/**
|
|
175
|
+
* Name of the contract.
|
|
176
|
+
*/
|
|
177
|
+
name: v4.string(),
|
|
178
|
+
/**
|
|
179
|
+
* The source code of the Clarity contract.
|
|
180
|
+
*/
|
|
181
|
+
clarityCode: v4.string(),
|
|
182
|
+
/**
|
|
183
|
+
* The version of the Clarity contract.
|
|
184
|
+
*/
|
|
185
|
+
clarityVersion: v4.optional(v4.string())
|
|
186
|
+
});
|
|
187
|
+
var stxDeployContractResultSchema = v4.object({
|
|
188
|
+
/**
|
|
189
|
+
* The ID of the transaction.
|
|
190
|
+
*/
|
|
191
|
+
txid: v4.string(),
|
|
192
|
+
/**
|
|
193
|
+
* A Stacks transaction as a hex-encoded string.
|
|
194
|
+
*/
|
|
195
|
+
transaction: v4.string()
|
|
196
|
+
});
|
|
197
|
+
var stxDeployContractRequestMessageSchema = v4.object({
|
|
198
|
+
...rpcRequestMessageSchema.entries,
|
|
199
|
+
...v4.object({
|
|
200
|
+
method: v4.literal(stxDeployContractMethodName),
|
|
201
|
+
params: stxDeployContractParamsSchema,
|
|
202
|
+
id: v4.string()
|
|
203
|
+
}).entries
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// src/request/types/stxMethods/getAccounts.ts
|
|
207
|
+
import * as v5 from "valibot";
|
|
208
|
+
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
209
|
+
var stxGetAccountsParamsSchema = v5.nullish(v5.null());
|
|
210
|
+
var stxGetAccountsResultSchema = v5.object({
|
|
211
|
+
/**
|
|
212
|
+
* The addresses generated for the given purposes.
|
|
213
|
+
*/
|
|
214
|
+
addresses: v5.array(
|
|
215
|
+
v5.object({
|
|
216
|
+
address: v5.string(),
|
|
217
|
+
publicKey: v5.string(),
|
|
218
|
+
gaiaHubUrl: v5.string(),
|
|
219
|
+
gaiaAppKey: v5.string()
|
|
220
|
+
})
|
|
221
|
+
)
|
|
222
|
+
});
|
|
223
|
+
var stxGetAccountsRequestMessageSchema = v5.object({
|
|
224
|
+
...rpcRequestMessageSchema.entries,
|
|
225
|
+
...v5.object({
|
|
226
|
+
method: v5.literal(stxGetAccountsMethodName),
|
|
227
|
+
params: stxGetAccountsParamsSchema,
|
|
228
|
+
id: v5.string()
|
|
229
|
+
}).entries
|
|
230
|
+
});
|
|
122
231
|
|
|
123
232
|
// src/addresses/index.ts
|
|
124
233
|
import { createUnsecuredToken } from "jsontokens";
|
|
125
234
|
|
|
126
235
|
// src/addresses/types.ts
|
|
127
|
-
import * as
|
|
236
|
+
import * as v6 from "valibot";
|
|
128
237
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
129
238
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
130
239
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -140,11 +249,11 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
140
249
|
AddressType3["stacks"] = "stacks";
|
|
141
250
|
return AddressType3;
|
|
142
251
|
})(AddressType || {});
|
|
143
|
-
var addressSchema =
|
|
144
|
-
address:
|
|
145
|
-
publicKey:
|
|
146
|
-
purpose:
|
|
147
|
-
addressType:
|
|
252
|
+
var addressSchema = v6.object({
|
|
253
|
+
address: v6.string(),
|
|
254
|
+
publicKey: v6.string(),
|
|
255
|
+
purpose: v6.enum(AddressPurpose),
|
|
256
|
+
addressType: v6.enum(AddressType)
|
|
148
257
|
});
|
|
149
258
|
|
|
150
259
|
// src/addresses/index.ts
|
|
@@ -164,119 +273,269 @@ var getAddress = async (options) => {
|
|
|
164
273
|
}
|
|
165
274
|
};
|
|
166
275
|
|
|
167
|
-
// src/request/types/stxMethods.ts
|
|
168
|
-
import * as
|
|
276
|
+
// src/request/types/stxMethods/getAddresses.ts
|
|
277
|
+
import * as v7 from "valibot";
|
|
169
278
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
170
|
-
var stxGetAddressesParamsSchema =
|
|
171
|
-
|
|
279
|
+
var stxGetAddressesParamsSchema = v7.nullish(
|
|
280
|
+
v7.object({
|
|
172
281
|
/**
|
|
173
282
|
* A message to be displayed to the user in the request prompt.
|
|
174
283
|
*/
|
|
175
|
-
message:
|
|
284
|
+
message: v7.optional(v7.string())
|
|
176
285
|
})
|
|
177
286
|
);
|
|
178
|
-
var stxGetAddressesResultSchema =
|
|
287
|
+
var stxGetAddressesResultSchema = v7.object({
|
|
179
288
|
/**
|
|
180
289
|
* The addresses generated for the given purposes.
|
|
181
290
|
*/
|
|
182
|
-
addresses:
|
|
291
|
+
addresses: v7.array(addressSchema)
|
|
183
292
|
});
|
|
184
|
-
var stxGetAddressesRequestMessageSchema =
|
|
293
|
+
var stxGetAddressesRequestMessageSchema = v7.object({
|
|
185
294
|
...rpcRequestMessageSchema.entries,
|
|
186
|
-
...
|
|
187
|
-
method:
|
|
295
|
+
...v7.object({
|
|
296
|
+
method: v7.literal(stxGetAddressesMethodName),
|
|
188
297
|
params: stxGetAddressesParamsSchema,
|
|
189
|
-
id:
|
|
298
|
+
id: v7.string()
|
|
299
|
+
}).entries
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// src/request/types/stxMethods/signMessage.ts
|
|
303
|
+
import * as v8 from "valibot";
|
|
304
|
+
var stxSignMessageMethodName = "stx_signMessage";
|
|
305
|
+
var stxSignMessageParamsSchema = v8.object({
|
|
306
|
+
/**
|
|
307
|
+
* The message to sign.
|
|
308
|
+
*/
|
|
309
|
+
message: v8.string(),
|
|
310
|
+
/**
|
|
311
|
+
* The public key to sign the message with.
|
|
312
|
+
*/
|
|
313
|
+
publicKey: v8.string(),
|
|
314
|
+
/**
|
|
315
|
+
* The format version of the parameter.
|
|
316
|
+
*/
|
|
317
|
+
parameterFormatVersion: v8.optional(v8.number())
|
|
318
|
+
});
|
|
319
|
+
var stxSignMessageResultSchema = v8.object({
|
|
320
|
+
/**
|
|
321
|
+
* The signature of the message.
|
|
322
|
+
*/
|
|
323
|
+
signature: v8.string(),
|
|
324
|
+
/**
|
|
325
|
+
* The public key used to sign the message.
|
|
326
|
+
*/
|
|
327
|
+
publicKey: v8.string()
|
|
328
|
+
});
|
|
329
|
+
var stxSignMessageRequestMessageSchema = v8.object({
|
|
330
|
+
...rpcRequestMessageSchema.entries,
|
|
331
|
+
...v8.object({
|
|
332
|
+
method: v8.literal(stxSignMessageMethodName),
|
|
333
|
+
params: stxSignMessageParamsSchema,
|
|
334
|
+
id: v8.string()
|
|
335
|
+
}).entries
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
339
|
+
import * as v9 from "valibot";
|
|
340
|
+
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
341
|
+
var stxSignStructuredMessageParamsSchema = v9.object({
|
|
342
|
+
/**
|
|
343
|
+
* The domain to be signed.
|
|
344
|
+
*/
|
|
345
|
+
domain: v9.string(),
|
|
346
|
+
/**
|
|
347
|
+
* Message payload to be signed.
|
|
348
|
+
*/
|
|
349
|
+
message: v9.string(),
|
|
350
|
+
/**
|
|
351
|
+
* The format version of the parameter.
|
|
352
|
+
*/
|
|
353
|
+
parameterFormatVersion: v9.optional(v9.number()),
|
|
354
|
+
/**
|
|
355
|
+
* The public key to sign the message with.
|
|
356
|
+
*/
|
|
357
|
+
publicKey: v9.optional(v9.string())
|
|
358
|
+
});
|
|
359
|
+
var stxSignStructuredMessageResultSchema = v9.object({
|
|
360
|
+
/**
|
|
361
|
+
* Signature of the message.
|
|
362
|
+
*/
|
|
363
|
+
signature: v9.string(),
|
|
364
|
+
/**
|
|
365
|
+
* Public key as hex-encoded string.
|
|
366
|
+
*/
|
|
367
|
+
publicKey: v9.string()
|
|
368
|
+
});
|
|
369
|
+
var stxSignStructuredMessageRequestMessageSchema = v9.object({
|
|
370
|
+
...rpcRequestMessageSchema.entries,
|
|
371
|
+
...v9.object({
|
|
372
|
+
method: v9.literal(stxSignStructuredMessageMethodName),
|
|
373
|
+
params: stxSignStructuredMessageParamsSchema,
|
|
374
|
+
id: v9.string()
|
|
190
375
|
}).entries
|
|
191
376
|
});
|
|
377
|
+
|
|
378
|
+
// src/request/types/stxMethods/signTransaction.ts
|
|
379
|
+
import * as v10 from "valibot";
|
|
192
380
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
193
|
-
var stxSignTransactionParamsSchema =
|
|
381
|
+
var stxSignTransactionParamsSchema = v10.object({
|
|
194
382
|
/**
|
|
195
383
|
* The transaction to sign as a hex-encoded string.
|
|
196
384
|
*/
|
|
197
|
-
transaction:
|
|
385
|
+
transaction: v10.string(),
|
|
198
386
|
/**
|
|
199
387
|
* The public key to sign the transaction with. The wallet may use any key
|
|
200
388
|
* when not provided.
|
|
201
389
|
*/
|
|
202
|
-
pubkey:
|
|
390
|
+
pubkey: v10.optional(v10.string()),
|
|
203
391
|
/**
|
|
204
392
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
205
393
|
*/
|
|
206
|
-
broadcast:
|
|
394
|
+
broadcast: v10.optional(v10.boolean())
|
|
207
395
|
});
|
|
208
|
-
var stxSignTransactionResultSchema =
|
|
396
|
+
var stxSignTransactionResultSchema = v10.object({
|
|
209
397
|
/**
|
|
210
398
|
* The signed transaction as a hex-encoded string.
|
|
211
399
|
*/
|
|
212
|
-
transaction:
|
|
400
|
+
transaction: v10.string()
|
|
213
401
|
});
|
|
214
|
-
var stxSignTransactionRequestMessageSchema =
|
|
402
|
+
var stxSignTransactionRequestMessageSchema = v10.object({
|
|
215
403
|
...rpcRequestMessageSchema.entries,
|
|
216
|
-
...
|
|
217
|
-
method:
|
|
404
|
+
...v10.object({
|
|
405
|
+
method: v10.literal(stxSignTransactionMethodName),
|
|
218
406
|
params: stxSignTransactionParamsSchema,
|
|
219
|
-
id:
|
|
407
|
+
id: v10.string()
|
|
408
|
+
}).entries
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// src/request/types/stxMethods/transferStx.ts
|
|
412
|
+
import * as v11 from "valibot";
|
|
413
|
+
var stxTransferStxMethodName = "stx_transferStx";
|
|
414
|
+
var stxTransferStxParamsSchema = v11.object({
|
|
415
|
+
/**
|
|
416
|
+
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
417
|
+
* parseable by `BigInt` is acceptable.
|
|
418
|
+
*
|
|
419
|
+
* Example,
|
|
420
|
+
*
|
|
421
|
+
* ```js
|
|
422
|
+
* const amount1 = 1234;
|
|
423
|
+
* const amount2 = 1234n;
|
|
424
|
+
* const amount3 = '1234';
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
amount: v11.union([v11.number(), v11.string()]),
|
|
428
|
+
/**
|
|
429
|
+
* The recipeint's principal.
|
|
430
|
+
*/
|
|
431
|
+
recipient: v11.string(),
|
|
432
|
+
/**
|
|
433
|
+
* A string representing the memo.
|
|
434
|
+
*/
|
|
435
|
+
memo: v11.optional(v11.string()),
|
|
436
|
+
/**
|
|
437
|
+
* Version of parameter format.
|
|
438
|
+
*/
|
|
439
|
+
version: v11.optional(v11.string()),
|
|
440
|
+
/**
|
|
441
|
+
* The mode of the post conditions.
|
|
442
|
+
*/
|
|
443
|
+
postConditionMode: v11.optional(v11.number()),
|
|
444
|
+
/**
|
|
445
|
+
* A hex-encoded string representing the post conditions.
|
|
446
|
+
*
|
|
447
|
+
* A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
|
|
448
|
+
*
|
|
449
|
+
* ```js
|
|
450
|
+
* import { serializePostCondition } from '@stacks/transactions';
|
|
451
|
+
*
|
|
452
|
+
* const postCondition = somePostCondition;
|
|
453
|
+
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
postConditions: v11.optional(v11.array(v11.string())),
|
|
457
|
+
/**
|
|
458
|
+
* The public key to sign the transaction with. The wallet may use any key
|
|
459
|
+
* when not provided.
|
|
460
|
+
*/
|
|
461
|
+
pubkey: v11.optional(v11.string())
|
|
462
|
+
});
|
|
463
|
+
var stxTransferStxResultSchema = v11.object({
|
|
464
|
+
/**
|
|
465
|
+
* The ID of the transaction.
|
|
466
|
+
*/
|
|
467
|
+
txid: v11.string(),
|
|
468
|
+
/**
|
|
469
|
+
* A Stacks transaction as a hex-encoded string.
|
|
470
|
+
*/
|
|
471
|
+
transaction: v11.string()
|
|
472
|
+
});
|
|
473
|
+
var stxTransferStxRequestMessageSchema = v11.object({
|
|
474
|
+
...rpcRequestMessageSchema.entries,
|
|
475
|
+
...v11.object({
|
|
476
|
+
method: v11.literal(stxTransferStxMethodName),
|
|
477
|
+
params: stxTransferStxParamsSchema,
|
|
478
|
+
id: v11.string()
|
|
220
479
|
}).entries
|
|
221
480
|
});
|
|
222
481
|
|
|
223
482
|
// src/request/types/btcMethods.ts
|
|
224
|
-
import * as
|
|
483
|
+
import * as v13 from "valibot";
|
|
225
484
|
|
|
226
485
|
// src/request/types/common.ts
|
|
227
|
-
import * as
|
|
486
|
+
import * as v12 from "valibot";
|
|
228
487
|
var walletTypes = ["software", "ledger"];
|
|
229
|
-
var walletTypeSchema =
|
|
488
|
+
var walletTypeSchema = v12.picklist(walletTypes);
|
|
230
489
|
|
|
231
490
|
// src/request/types/btcMethods.ts
|
|
232
491
|
var getInfoMethodName = "getInfo";
|
|
233
|
-
var getInfoParamsSchema =
|
|
234
|
-
var getInfoResultSchema =
|
|
492
|
+
var getInfoParamsSchema = v13.nullish(v13.null());
|
|
493
|
+
var getInfoResultSchema = v13.object({
|
|
235
494
|
/**
|
|
236
495
|
* Version of the wallet.
|
|
237
496
|
*/
|
|
238
|
-
version:
|
|
497
|
+
version: v13.string(),
|
|
239
498
|
/**
|
|
240
499
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
241
500
|
*/
|
|
242
|
-
methods:
|
|
501
|
+
methods: v13.optional(v13.array(v13.string())),
|
|
243
502
|
/**
|
|
244
503
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
245
504
|
*/
|
|
246
|
-
supports:
|
|
505
|
+
supports: v13.array(v13.string())
|
|
247
506
|
});
|
|
248
|
-
var getInfoRequestMessageSchema =
|
|
507
|
+
var getInfoRequestMessageSchema = v13.object({
|
|
249
508
|
...rpcRequestMessageSchema.entries,
|
|
250
|
-
...
|
|
251
|
-
method:
|
|
509
|
+
...v13.object({
|
|
510
|
+
method: v13.literal(getInfoMethodName),
|
|
252
511
|
params: getInfoParamsSchema,
|
|
253
|
-
id:
|
|
512
|
+
id: v13.string()
|
|
254
513
|
}).entries
|
|
255
514
|
});
|
|
256
515
|
var getAddressesMethodName = "getAddresses";
|
|
257
|
-
var getAddressesParamsSchema =
|
|
516
|
+
var getAddressesParamsSchema = v13.object({
|
|
258
517
|
/**
|
|
259
518
|
* The purposes for which to generate addresses. See
|
|
260
519
|
* {@linkcode AddressPurpose} for available purposes.
|
|
261
520
|
*/
|
|
262
|
-
purposes:
|
|
521
|
+
purposes: v13.array(v13.enum(AddressPurpose)),
|
|
263
522
|
/**
|
|
264
523
|
* A message to be displayed to the user in the request prompt.
|
|
265
524
|
*/
|
|
266
|
-
message:
|
|
525
|
+
message: v13.optional(v13.string())
|
|
267
526
|
});
|
|
268
|
-
var getAddressesResultSchema =
|
|
527
|
+
var getAddressesResultSchema = v13.object({
|
|
269
528
|
/**
|
|
270
529
|
* The addresses generated for the given purposes.
|
|
271
530
|
*/
|
|
272
|
-
addresses:
|
|
531
|
+
addresses: v13.array(addressSchema)
|
|
273
532
|
});
|
|
274
|
-
var getAddressesRequestMessageSchema =
|
|
533
|
+
var getAddressesRequestMessageSchema = v13.object({
|
|
275
534
|
...rpcRequestMessageSchema.entries,
|
|
276
|
-
...
|
|
277
|
-
method:
|
|
535
|
+
...v13.object({
|
|
536
|
+
method: v13.literal(getAddressesMethodName),
|
|
278
537
|
params: getAddressesParamsSchema,
|
|
279
|
-
id:
|
|
538
|
+
id: v13.string()
|
|
280
539
|
}).entries
|
|
281
540
|
});
|
|
282
541
|
var signMessageMethodName = "signMessage";
|
|
@@ -285,318 +544,439 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
|
|
|
285
544
|
MessageSigningProtocols2["BIP322"] = "BIP322";
|
|
286
545
|
return MessageSigningProtocols2;
|
|
287
546
|
})(MessageSigningProtocols || {});
|
|
288
|
-
var signMessageParamsSchema =
|
|
547
|
+
var signMessageParamsSchema = v13.object({
|
|
289
548
|
/**
|
|
290
549
|
* The address used for signing.
|
|
291
550
|
**/
|
|
292
|
-
address:
|
|
551
|
+
address: v13.string(),
|
|
293
552
|
/**
|
|
294
553
|
* The message to sign.
|
|
295
554
|
**/
|
|
296
|
-
message:
|
|
555
|
+
message: v13.string(),
|
|
297
556
|
/**
|
|
298
557
|
* The protocol to use for signing the message.
|
|
299
558
|
*/
|
|
300
|
-
protocol:
|
|
559
|
+
protocol: v13.optional(v13.enum(MessageSigningProtocols))
|
|
301
560
|
});
|
|
302
|
-
var signMessageResultSchema =
|
|
561
|
+
var signMessageResultSchema = v13.object({
|
|
303
562
|
/**
|
|
304
563
|
* The signature of the message.
|
|
305
564
|
*/
|
|
306
|
-
signature:
|
|
565
|
+
signature: v13.string(),
|
|
307
566
|
/**
|
|
308
567
|
* hash of the message.
|
|
309
568
|
*/
|
|
310
|
-
messageHash:
|
|
569
|
+
messageHash: v13.string(),
|
|
311
570
|
/**
|
|
312
571
|
* The address used for signing.
|
|
313
572
|
*/
|
|
314
|
-
address:
|
|
573
|
+
address: v13.string(),
|
|
315
574
|
/**
|
|
316
575
|
* The protocol to use for signing the message.
|
|
317
576
|
*/
|
|
318
|
-
protocol:
|
|
577
|
+
protocol: v13.enum(MessageSigningProtocols)
|
|
319
578
|
});
|
|
320
|
-
var signMessageRequestMessageSchema =
|
|
579
|
+
var signMessageRequestMessageSchema = v13.object({
|
|
321
580
|
...rpcRequestMessageSchema.entries,
|
|
322
|
-
...
|
|
323
|
-
method:
|
|
581
|
+
...v13.object({
|
|
582
|
+
method: v13.literal(signMessageMethodName),
|
|
324
583
|
params: signMessageParamsSchema,
|
|
325
|
-
id:
|
|
584
|
+
id: v13.string()
|
|
585
|
+
}).entries
|
|
586
|
+
});
|
|
587
|
+
var sendTransferMethodName = "sendTransfer";
|
|
588
|
+
var sendTransferParamsSchema = v13.object({
|
|
589
|
+
/**
|
|
590
|
+
* Array of recipients to send to.
|
|
591
|
+
* The amount to send to each recipient is in satoshis.
|
|
592
|
+
*/
|
|
593
|
+
recipients: v13.array(
|
|
594
|
+
v13.object({
|
|
595
|
+
address: v13.string(),
|
|
596
|
+
amount: v13.number()
|
|
597
|
+
})
|
|
598
|
+
)
|
|
599
|
+
});
|
|
600
|
+
var sendTransferResultSchema = v13.object({
|
|
601
|
+
/**
|
|
602
|
+
* The transaction id as a hex-encoded string.
|
|
603
|
+
*/
|
|
604
|
+
txid: v13.string()
|
|
605
|
+
});
|
|
606
|
+
var sendTransferRequestMessageSchema = v13.object({
|
|
607
|
+
...rpcRequestMessageSchema.entries,
|
|
608
|
+
...v13.object({
|
|
609
|
+
method: v13.literal(sendTransferMethodName),
|
|
610
|
+
params: sendTransferParamsSchema,
|
|
611
|
+
id: v13.string()
|
|
612
|
+
}).entries
|
|
613
|
+
});
|
|
614
|
+
var signPsbtMethodName = "signPsbt";
|
|
615
|
+
var signPsbtParamsSchema = v13.object({
|
|
616
|
+
/**
|
|
617
|
+
* The base64 encoded PSBT to sign.
|
|
618
|
+
*/
|
|
619
|
+
psbt: v13.string(),
|
|
620
|
+
/**
|
|
621
|
+
* The inputs to sign.
|
|
622
|
+
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
623
|
+
*/
|
|
624
|
+
signInputs: v13.record(v13.string(), v13.array(v13.number())),
|
|
625
|
+
allowedSignHash: v13.optional(v13.number()),
|
|
626
|
+
/**
|
|
627
|
+
* Whether to broadcast the transaction after signing.
|
|
628
|
+
**/
|
|
629
|
+
broadcast: v13.optional(v13.boolean())
|
|
630
|
+
});
|
|
631
|
+
var signPsbtResultSchema = v13.object({
|
|
632
|
+
/**
|
|
633
|
+
* The base64 encoded PSBT after signing.
|
|
634
|
+
*/
|
|
635
|
+
psbt: v13.string(),
|
|
636
|
+
/**
|
|
637
|
+
* The transaction id as a hex-encoded string.
|
|
638
|
+
* This is only returned if the transaction was broadcast.
|
|
639
|
+
**/
|
|
640
|
+
txid: v13.optional(v13.string())
|
|
641
|
+
});
|
|
642
|
+
var signPsbtRequestMessageSchema = v13.object({
|
|
643
|
+
...rpcRequestMessageSchema.entries,
|
|
644
|
+
...v13.object({
|
|
645
|
+
method: v13.literal(signPsbtMethodName),
|
|
646
|
+
params: signPsbtParamsSchema,
|
|
647
|
+
id: v13.string()
|
|
326
648
|
}).entries
|
|
327
649
|
});
|
|
328
650
|
var getAccountsMethodName = "getAccounts";
|
|
329
|
-
var getAccountsParamsSchema =
|
|
651
|
+
var getAccountsParamsSchema = v13.object({
|
|
330
652
|
/**
|
|
331
653
|
* The purposes for which to generate addresses. See
|
|
332
654
|
* {@linkcode AddressPurpose} for available purposes.
|
|
333
655
|
*/
|
|
334
|
-
purposes:
|
|
656
|
+
purposes: v13.array(v13.enum(AddressPurpose)),
|
|
335
657
|
/**
|
|
336
658
|
* A message to be displayed to the user in the request prompt.
|
|
337
659
|
*/
|
|
338
|
-
message:
|
|
660
|
+
message: v13.optional(v13.string())
|
|
339
661
|
});
|
|
340
|
-
var getAccountsResultSchema =
|
|
341
|
-
|
|
662
|
+
var getAccountsResultSchema = v13.array(
|
|
663
|
+
v13.object({
|
|
342
664
|
...addressSchema.entries,
|
|
343
|
-
...
|
|
665
|
+
...v13.object({
|
|
344
666
|
walletType: walletTypeSchema
|
|
345
667
|
}).entries
|
|
346
668
|
})
|
|
347
669
|
);
|
|
348
|
-
var getAccountsRequestMessageSchema =
|
|
670
|
+
var getAccountsRequestMessageSchema = v13.object({
|
|
349
671
|
...rpcRequestMessageSchema.entries,
|
|
350
|
-
...
|
|
351
|
-
method:
|
|
672
|
+
...v13.object({
|
|
673
|
+
method: v13.literal(getAccountsMethodName),
|
|
352
674
|
params: getAccountsParamsSchema,
|
|
353
|
-
id:
|
|
675
|
+
id: v13.string()
|
|
354
676
|
}).entries
|
|
355
677
|
});
|
|
356
678
|
var getBalanceMethodName = "getBalance";
|
|
357
|
-
var getBalanceParamsSchema =
|
|
358
|
-
var getBalanceResultSchema =
|
|
679
|
+
var getBalanceParamsSchema = v13.nullish(v13.null());
|
|
680
|
+
var getBalanceResultSchema = v13.object({
|
|
359
681
|
/**
|
|
360
682
|
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
361
683
|
* messages not supporting bigint
|
|
362
684
|
* (https://issues.chromium.org/issues/40116184).
|
|
363
685
|
*/
|
|
364
|
-
confirmed:
|
|
686
|
+
confirmed: v13.string(),
|
|
365
687
|
/**
|
|
366
688
|
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
367
689
|
* messages not supporting bigint
|
|
368
690
|
* (https://issues.chromium.org/issues/40116184).
|
|
369
691
|
*/
|
|
370
|
-
unconfirmed:
|
|
692
|
+
unconfirmed: v13.string(),
|
|
371
693
|
/**
|
|
372
694
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
373
695
|
* sats. Using a string due to chrome messages not supporting bigint
|
|
374
696
|
* (https://issues.chromium.org/issues/40116184).
|
|
375
697
|
*/
|
|
376
|
-
total:
|
|
698
|
+
total: v13.string()
|
|
377
699
|
});
|
|
378
|
-
var getBalanceRequestMessageSchema =
|
|
700
|
+
var getBalanceRequestMessageSchema = v13.object({
|
|
379
701
|
...rpcRequestMessageSchema.entries,
|
|
380
|
-
...
|
|
381
|
-
method:
|
|
382
|
-
id:
|
|
702
|
+
...v13.object({
|
|
703
|
+
method: v13.literal(getBalanceMethodName),
|
|
704
|
+
id: v13.string()
|
|
383
705
|
}).entries
|
|
384
706
|
});
|
|
385
707
|
|
|
386
708
|
// src/request/types/walletMethods.ts
|
|
387
|
-
import * as
|
|
709
|
+
import * as v14 from "valibot";
|
|
388
710
|
import { permissions } from "@secretkeylabs/xverse-core";
|
|
389
|
-
var permissionTemplate =
|
|
390
|
-
|
|
391
|
-
...
|
|
392
|
-
actions:
|
|
711
|
+
var permissionTemplate = v14.variant("type", [
|
|
712
|
+
v14.object({
|
|
713
|
+
...v14.omit(permissions.resources.account.accountPermissionSchema, ["clientId", "actions"]).entries,
|
|
714
|
+
actions: v14.partial(permissions.resources.account.accountActionsSchema)
|
|
393
715
|
}),
|
|
394
|
-
|
|
395
|
-
...
|
|
396
|
-
actions:
|
|
716
|
+
v14.object({
|
|
717
|
+
...v14.omit(permissions.resources.wallet.walletPermissionSchema, ["clientId"]).entries,
|
|
718
|
+
actions: v14.partial(permissions.resources.wallet.walletActionsSchema)
|
|
397
719
|
})
|
|
398
720
|
]);
|
|
399
721
|
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
400
|
-
var requestPermissionsParamsSchema =
|
|
401
|
-
var requestPermissionsResultSchema =
|
|
402
|
-
var requestPermissionsRequestMessageSchema =
|
|
722
|
+
var requestPermissionsParamsSchema = v14.nullish(v14.array(permissionTemplate));
|
|
723
|
+
var requestPermissionsResultSchema = v14.literal(true);
|
|
724
|
+
var requestPermissionsRequestMessageSchema = v14.object({
|
|
403
725
|
...rpcRequestMessageSchema.entries,
|
|
404
|
-
...
|
|
405
|
-
method:
|
|
726
|
+
...v14.object({
|
|
727
|
+
method: v14.literal(requestPermissionsMethodName),
|
|
406
728
|
params: requestPermissionsParamsSchema,
|
|
407
|
-
id:
|
|
729
|
+
id: v14.string()
|
|
408
730
|
}).entries
|
|
409
731
|
});
|
|
410
732
|
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
411
|
-
var renouncePermissionsParamsSchema =
|
|
412
|
-
var renouncePermissionsResultSchema =
|
|
413
|
-
var renouncePermissionsRequestMessageSchema =
|
|
733
|
+
var renouncePermissionsParamsSchema = v14.nullish(v14.null());
|
|
734
|
+
var renouncePermissionsResultSchema = v14.nullish(v14.null());
|
|
735
|
+
var renouncePermissionsRequestMessageSchema = v14.object({
|
|
414
736
|
...rpcRequestMessageSchema.entries,
|
|
415
|
-
...
|
|
416
|
-
method:
|
|
737
|
+
...v14.object({
|
|
738
|
+
method: v14.literal(renouncePermissionsMethodName),
|
|
417
739
|
params: renouncePermissionsParamsSchema,
|
|
418
|
-
id:
|
|
740
|
+
id: v14.string()
|
|
419
741
|
}).entries
|
|
420
742
|
});
|
|
421
743
|
var disconnectMethodName = "wallet_disconnect";
|
|
422
|
-
var disconnectParamsSchema =
|
|
423
|
-
var disconnectResultSchema =
|
|
424
|
-
var disconnectRequestMessageSchema =
|
|
744
|
+
var disconnectParamsSchema = v14.nullish(v14.null());
|
|
745
|
+
var disconnectResultSchema = v14.nullish(v14.null());
|
|
746
|
+
var disconnectRequestMessageSchema = v14.object({
|
|
425
747
|
...rpcRequestMessageSchema.entries,
|
|
426
|
-
...
|
|
427
|
-
method:
|
|
748
|
+
...v14.object({
|
|
749
|
+
method: v14.literal(disconnectMethodName),
|
|
428
750
|
params: disconnectParamsSchema,
|
|
429
|
-
id:
|
|
751
|
+
id: v14.string()
|
|
430
752
|
}).entries
|
|
431
753
|
});
|
|
432
754
|
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
433
|
-
var getWalletTypeParamsSchema =
|
|
755
|
+
var getWalletTypeParamsSchema = v14.nullish(v14.null());
|
|
434
756
|
var getWalletTypeResultSchema = walletTypeSchema;
|
|
435
|
-
var getWalletTypeRequestMessageSchema =
|
|
757
|
+
var getWalletTypeRequestMessageSchema = v14.object({
|
|
436
758
|
...rpcRequestMessageSchema.entries,
|
|
437
|
-
...
|
|
438
|
-
method:
|
|
759
|
+
...v14.object({
|
|
760
|
+
method: v14.literal(getWalletTypeMethodName),
|
|
439
761
|
params: getWalletTypeParamsSchema,
|
|
440
|
-
id:
|
|
762
|
+
id: v14.string()
|
|
441
763
|
}).entries
|
|
442
764
|
});
|
|
443
765
|
var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
444
|
-
var getCurrentPermissionsParamsSchema =
|
|
445
|
-
var getCurrentPermissionsResultSchema =
|
|
446
|
-
var getCurrentPermissionsRequestMessageSchema =
|
|
766
|
+
var getCurrentPermissionsParamsSchema = v14.nullish(v14.null());
|
|
767
|
+
var getCurrentPermissionsResultSchema = v14.array(permissions.store.permission);
|
|
768
|
+
var getCurrentPermissionsRequestMessageSchema = v14.object({
|
|
447
769
|
...rpcRequestMessageSchema.entries,
|
|
448
|
-
...
|
|
449
|
-
method:
|
|
770
|
+
...v14.object({
|
|
771
|
+
method: v14.literal(getCurrentPermissionsMethodName),
|
|
450
772
|
params: getCurrentPermissionsParamsSchema,
|
|
451
|
-
id:
|
|
773
|
+
id: v14.string()
|
|
452
774
|
}).entries
|
|
453
775
|
});
|
|
454
776
|
var getAccountMethodName = "wallet_getAccount";
|
|
455
|
-
var getAccountParamsSchema =
|
|
456
|
-
var getAccountResultSchema =
|
|
777
|
+
var getAccountParamsSchema = v14.nullish(v14.null());
|
|
778
|
+
var getAccountResultSchema = v14.object({
|
|
457
779
|
id: permissions.utils.account.accountIdSchema,
|
|
458
|
-
addresses:
|
|
780
|
+
addresses: v14.array(addressSchema),
|
|
459
781
|
walletType: walletTypeSchema
|
|
460
782
|
});
|
|
461
|
-
var getAccountRequestMessageSchema =
|
|
783
|
+
var getAccountRequestMessageSchema = v14.object({
|
|
462
784
|
...rpcRequestMessageSchema.entries,
|
|
463
|
-
...
|
|
464
|
-
method:
|
|
785
|
+
...v14.object({
|
|
786
|
+
method: v14.literal(getAccountMethodName),
|
|
465
787
|
params: getAccountParamsSchema,
|
|
466
|
-
id:
|
|
467
|
-
}).entries
|
|
468
|
-
});
|
|
469
|
-
var registerClientMethodName = "wallet_registerClient";
|
|
470
|
-
var registerClientParamsSchema = v7.object({
|
|
471
|
-
name: v7.optional(v7.string()),
|
|
472
|
-
description: v7.optional(v7.string())
|
|
473
|
-
});
|
|
474
|
-
var registerClientResultSchema = v7.object({
|
|
475
|
-
id: v7.string()
|
|
476
|
-
});
|
|
477
|
-
var registerClientRequestMessageSchema = v7.object({
|
|
478
|
-
...rpcRequestMessageSchema.entries,
|
|
479
|
-
...v7.object({
|
|
480
|
-
method: v7.literal(registerClientMethodName),
|
|
481
|
-
params: registerClientParamsSchema,
|
|
482
|
-
id: v7.string()
|
|
788
|
+
id: v14.string()
|
|
483
789
|
}).entries
|
|
484
790
|
});
|
|
485
791
|
var connectMethodName = "wallet_connect";
|
|
486
|
-
var connectParamsSchema =
|
|
487
|
-
|
|
488
|
-
permissions:
|
|
489
|
-
clientInfo: registerClientParamsSchema
|
|
792
|
+
var connectParamsSchema = v14.nullish(
|
|
793
|
+
v14.object({
|
|
794
|
+
permissions: v14.optional(v14.array(permissionTemplate))
|
|
490
795
|
})
|
|
491
796
|
);
|
|
492
797
|
var connectResultSchema = getAccountResultSchema;
|
|
493
|
-
var connectRequestMessageSchema =
|
|
798
|
+
var connectRequestMessageSchema = v14.object({
|
|
494
799
|
...rpcRequestMessageSchema.entries,
|
|
495
|
-
...
|
|
496
|
-
method:
|
|
800
|
+
...v14.object({
|
|
801
|
+
method: v14.literal(connectMethodName),
|
|
497
802
|
params: connectParamsSchema,
|
|
498
|
-
id:
|
|
803
|
+
id: v14.string()
|
|
499
804
|
}).entries
|
|
500
805
|
});
|
|
501
806
|
|
|
502
|
-
// src/request/types/runesMethods.ts
|
|
503
|
-
import * as
|
|
504
|
-
var
|
|
505
|
-
var
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
807
|
+
// src/request/types/runesMethods/etch.ts
|
|
808
|
+
import * as v15 from "valibot";
|
|
809
|
+
var runesEtchMethodName = "runes_etch";
|
|
810
|
+
var etchTermsSchema = v15.object({
|
|
811
|
+
amount: v15.string(),
|
|
812
|
+
cap: v15.string(),
|
|
813
|
+
heightStart: v15.optional(v15.string()),
|
|
814
|
+
heightEnd: v15.optional(v15.string()),
|
|
815
|
+
offsetStart: v15.optional(v15.string()),
|
|
816
|
+
offsetEnd: v15.optional(v15.string())
|
|
817
|
+
});
|
|
818
|
+
var inscriptionDetailsSchema = v15.object({
|
|
819
|
+
contentType: v15.string(),
|
|
820
|
+
contentBase64: v15.string()
|
|
821
|
+
});
|
|
822
|
+
var runesEtchParamsSchema = v15.object({
|
|
823
|
+
runeName: v15.string(),
|
|
824
|
+
divisibility: v15.optional(v15.number()),
|
|
825
|
+
symbol: v15.optional(v15.string()),
|
|
826
|
+
premine: v15.optional(v15.string()),
|
|
827
|
+
isMintable: v15.boolean(),
|
|
828
|
+
delegateInscriptionId: v15.optional(v15.string()),
|
|
829
|
+
destinationAddress: v15.string(),
|
|
830
|
+
refundAddress: v15.string(),
|
|
831
|
+
feeRate: v15.number(),
|
|
832
|
+
appServiceFee: v15.optional(v15.number()),
|
|
833
|
+
appServiceFeeAddress: v15.optional(v15.string()),
|
|
834
|
+
terms: v15.optional(etchTermsSchema),
|
|
835
|
+
inscriptionDetails: v15.optional(inscriptionDetailsSchema),
|
|
836
|
+
network: v15.optional(v15.enum(BitcoinNetworkType))
|
|
837
|
+
});
|
|
838
|
+
var runesEtchResultSchema = v15.object({
|
|
839
|
+
orderId: v15.string(),
|
|
840
|
+
fundTransactionId: v15.string(),
|
|
841
|
+
fundingAddress: v15.string()
|
|
842
|
+
});
|
|
843
|
+
var runesEtchRequestMessageSchema = v15.object({
|
|
844
|
+
...rpcRequestMessageSchema.entries,
|
|
845
|
+
...v15.object({
|
|
846
|
+
method: v15.literal(runesEtchMethodName),
|
|
847
|
+
params: runesEtchParamsSchema,
|
|
848
|
+
id: v15.string()
|
|
849
|
+
}).entries
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
// src/request/types/runesMethods/getBalance.ts
|
|
853
|
+
import * as v16 from "valibot";
|
|
854
|
+
var runesGetBalanceMethodName = "runes_getBalance";
|
|
855
|
+
var runesGetBalanceParamsSchema = v16.nullish(v16.null());
|
|
856
|
+
var runesGetBalanceResultSchema = v16.object({
|
|
857
|
+
balances: v16.array(
|
|
858
|
+
v16.object({
|
|
859
|
+
runeName: v16.string(),
|
|
860
|
+
amount: v16.string(),
|
|
861
|
+
divisibility: v16.number(),
|
|
862
|
+
symbol: v16.string(),
|
|
863
|
+
inscriptionId: v16.nullish(v16.string())
|
|
514
864
|
})
|
|
515
865
|
)
|
|
516
866
|
});
|
|
517
|
-
var
|
|
867
|
+
var runesGetBalanceRequestMessageSchema = v16.object({
|
|
518
868
|
...rpcRequestMessageSchema.entries,
|
|
519
|
-
...
|
|
520
|
-
method:
|
|
521
|
-
params:
|
|
522
|
-
id:
|
|
869
|
+
...v16.object({
|
|
870
|
+
method: v16.literal(runesGetBalanceMethodName),
|
|
871
|
+
params: runesGetBalanceParamsSchema,
|
|
872
|
+
id: v16.string()
|
|
523
873
|
}).entries
|
|
524
874
|
});
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
875
|
+
|
|
876
|
+
// src/request/types/runesMethods/mint.ts
|
|
877
|
+
import * as v17 from "valibot";
|
|
878
|
+
var runesMintMethodName = "runes_mint";
|
|
879
|
+
var runesMintParamsSchema = v17.object({
|
|
880
|
+
appServiceFee: v17.optional(v17.number()),
|
|
881
|
+
appServiceFeeAddress: v17.optional(v17.string()),
|
|
882
|
+
destinationAddress: v17.string(),
|
|
883
|
+
feeRate: v17.number(),
|
|
884
|
+
refundAddress: v17.string(),
|
|
885
|
+
repeats: v17.number(),
|
|
886
|
+
runeName: v17.string(),
|
|
887
|
+
network: v17.optional(v17.enum(BitcoinNetworkType))
|
|
888
|
+
});
|
|
889
|
+
var runesMintResultSchema = v17.object({
|
|
890
|
+
orderId: v17.string(),
|
|
891
|
+
fundTransactionId: v17.string(),
|
|
892
|
+
fundingAddress: v17.string()
|
|
893
|
+
});
|
|
894
|
+
var runesMintRequestMessageSchema = v17.object({
|
|
895
|
+
...rpcRequestMessageSchema.entries,
|
|
896
|
+
...v17.object({
|
|
897
|
+
method: v17.literal(runesMintMethodName),
|
|
898
|
+
params: runesMintParamsSchema,
|
|
899
|
+
id: v17.string()
|
|
900
|
+
}).entries
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
// src/request/types/runesMethods/transfer.ts
|
|
904
|
+
import * as v18 from "valibot";
|
|
905
|
+
var runesTransferMethodName = "runes_transfer";
|
|
906
|
+
var runesTransferParamsSchema = v18.object({
|
|
907
|
+
recipients: v18.array(
|
|
908
|
+
v18.object({
|
|
909
|
+
runeName: v18.string(),
|
|
910
|
+
amount: v18.string(),
|
|
911
|
+
address: v18.string()
|
|
532
912
|
})
|
|
533
913
|
)
|
|
534
914
|
});
|
|
535
|
-
var
|
|
915
|
+
var runesTransferResultSchema = v18.object({
|
|
916
|
+
txid: v18.string()
|
|
917
|
+
});
|
|
918
|
+
var runesTransferRequestSchema = v18.object({
|
|
536
919
|
...rpcRequestMessageSchema.entries,
|
|
537
|
-
...
|
|
538
|
-
method:
|
|
539
|
-
params:
|
|
540
|
-
id:
|
|
920
|
+
...v18.object({
|
|
921
|
+
method: v18.literal(runesTransferMethodName),
|
|
922
|
+
params: runesTransferParamsSchema,
|
|
923
|
+
id: v18.string()
|
|
541
924
|
}).entries
|
|
542
925
|
});
|
|
543
|
-
var TransferRunesResultSchema = v8.object({
|
|
544
|
-
txid: v8.string()
|
|
545
|
-
});
|
|
546
926
|
|
|
547
927
|
// src/request/types/ordinalsMethods.ts
|
|
548
|
-
import * as
|
|
928
|
+
import * as v19 from "valibot";
|
|
549
929
|
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
550
|
-
var getInscriptionsParamsSchema =
|
|
551
|
-
offset:
|
|
552
|
-
limit:
|
|
553
|
-
});
|
|
554
|
-
var getInscriptionsResultSchema =
|
|
555
|
-
total:
|
|
556
|
-
limit:
|
|
557
|
-
offset:
|
|
558
|
-
inscriptions:
|
|
559
|
-
|
|
560
|
-
inscriptionId:
|
|
561
|
-
inscriptionNumber:
|
|
562
|
-
address:
|
|
563
|
-
collectionName:
|
|
564
|
-
postage:
|
|
565
|
-
contentLength:
|
|
566
|
-
contentType:
|
|
567
|
-
timestamp:
|
|
568
|
-
offset:
|
|
569
|
-
genesisTransaction:
|
|
570
|
-
output:
|
|
930
|
+
var getInscriptionsParamsSchema = v19.object({
|
|
931
|
+
offset: v19.number(),
|
|
932
|
+
limit: v19.number()
|
|
933
|
+
});
|
|
934
|
+
var getInscriptionsResultSchema = v19.object({
|
|
935
|
+
total: v19.number(),
|
|
936
|
+
limit: v19.number(),
|
|
937
|
+
offset: v19.number(),
|
|
938
|
+
inscriptions: v19.array(
|
|
939
|
+
v19.object({
|
|
940
|
+
inscriptionId: v19.string(),
|
|
941
|
+
inscriptionNumber: v19.string(),
|
|
942
|
+
address: v19.string(),
|
|
943
|
+
collectionName: v19.optional(v19.string()),
|
|
944
|
+
postage: v19.string(),
|
|
945
|
+
contentLength: v19.string(),
|
|
946
|
+
contentType: v19.string(),
|
|
947
|
+
timestamp: v19.number(),
|
|
948
|
+
offset: v19.number(),
|
|
949
|
+
genesisTransaction: v19.string(),
|
|
950
|
+
output: v19.string()
|
|
571
951
|
})
|
|
572
952
|
)
|
|
573
953
|
});
|
|
574
|
-
var getInscriptionsSchema =
|
|
954
|
+
var getInscriptionsSchema = v19.object({
|
|
575
955
|
...rpcRequestMessageSchema.entries,
|
|
576
|
-
...
|
|
577
|
-
method:
|
|
956
|
+
...v19.object({
|
|
957
|
+
method: v19.literal(getInscriptionsMethodName),
|
|
578
958
|
params: getInscriptionsParamsSchema,
|
|
579
|
-
id:
|
|
959
|
+
id: v19.string()
|
|
580
960
|
}).entries
|
|
581
961
|
});
|
|
582
962
|
var sendInscriptionsMethodName = "ord_sendInscriptions";
|
|
583
|
-
var sendInscriptionsParamsSchema =
|
|
584
|
-
transfers:
|
|
585
|
-
|
|
586
|
-
address:
|
|
587
|
-
inscriptionId:
|
|
963
|
+
var sendInscriptionsParamsSchema = v19.object({
|
|
964
|
+
transfers: v19.array(
|
|
965
|
+
v19.object({
|
|
966
|
+
address: v19.string(),
|
|
967
|
+
inscriptionId: v19.string()
|
|
588
968
|
})
|
|
589
969
|
)
|
|
590
970
|
});
|
|
591
|
-
var sendInscriptionsResultSchema =
|
|
592
|
-
txid:
|
|
971
|
+
var sendInscriptionsResultSchema = v19.object({
|
|
972
|
+
txid: v19.string()
|
|
593
973
|
});
|
|
594
|
-
var sendInscriptionsSchema =
|
|
974
|
+
var sendInscriptionsSchema = v19.object({
|
|
595
975
|
...rpcRequestMessageSchema.entries,
|
|
596
|
-
...
|
|
597
|
-
method:
|
|
976
|
+
...v19.object({
|
|
977
|
+
method: v19.literal(sendInscriptionsMethodName),
|
|
598
978
|
params: sendInscriptionsParamsSchema,
|
|
599
|
-
id:
|
|
979
|
+
id: v19.string()
|
|
600
980
|
}).entries
|
|
601
981
|
});
|
|
602
982
|
|
|
@@ -613,13 +993,13 @@ var request = async (method, params, providerId) => {
|
|
|
613
993
|
throw new Error("A wallet method is required");
|
|
614
994
|
}
|
|
615
995
|
const response = await provider.request(method, params);
|
|
616
|
-
if (
|
|
996
|
+
if (v20.is(rpcErrorResponseMessageSchema, response)) {
|
|
617
997
|
return {
|
|
618
998
|
status: "error",
|
|
619
999
|
error: response.error
|
|
620
1000
|
};
|
|
621
1001
|
}
|
|
622
|
-
if (
|
|
1002
|
+
if (v20.is(rpcSuccessResponseMessageSchema, response)) {
|
|
623
1003
|
return {
|
|
624
1004
|
status: "success",
|
|
625
1005
|
result: response.result
|
|
@@ -1130,17 +1510,16 @@ var XverseAdapter = class extends SatsConnectAdapter {
|
|
|
1130
1510
|
};
|
|
1131
1511
|
|
|
1132
1512
|
// src/adapters/unisat.ts
|
|
1133
|
-
import { Buffer } from "buffer";
|
|
1134
1513
|
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
1135
|
-
|
|
1514
|
+
import { Buffer } from "buffer";
|
|
1515
|
+
function convertSignInputsToInputType(signInputs) {
|
|
1136
1516
|
let result = [];
|
|
1137
1517
|
for (let address in signInputs) {
|
|
1138
1518
|
let indexes = signInputs[address];
|
|
1139
1519
|
for (let index of indexes) {
|
|
1140
1520
|
result.push({
|
|
1141
1521
|
index,
|
|
1142
|
-
address
|
|
1143
|
-
sighashTypes: allowedSignHash ? [allowedSignHash] : void 0
|
|
1522
|
+
address
|
|
1144
1523
|
});
|
|
1145
1524
|
}
|
|
1146
1525
|
}
|
|
@@ -1172,10 +1551,10 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1172
1551
|
};
|
|
1173
1552
|
const response = [];
|
|
1174
1553
|
if (purposes.includes("payment" /* Payment */)) {
|
|
1175
|
-
response.push(paymentAddress);
|
|
1554
|
+
response.push({ ...paymentAddress, walletType: "software" });
|
|
1176
1555
|
}
|
|
1177
1556
|
if (purposes.includes("ordinals" /* Ordinals */)) {
|
|
1178
|
-
response.push(ordinalsAddress);
|
|
1557
|
+
response.push({ ...ordinalsAddress, walletType: "software" });
|
|
1179
1558
|
}
|
|
1180
1559
|
return response;
|
|
1181
1560
|
}
|
|
@@ -1188,14 +1567,16 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1188
1567
|
return {
|
|
1189
1568
|
address,
|
|
1190
1569
|
messageHash: "",
|
|
1191
|
-
signature: response2
|
|
1570
|
+
signature: response2,
|
|
1571
|
+
protocol: "BIP322" /* BIP322 */
|
|
1192
1572
|
};
|
|
1193
1573
|
}
|
|
1194
1574
|
const response = await window.unisat.signMessage(message, "ecdsa");
|
|
1195
1575
|
return {
|
|
1196
1576
|
address,
|
|
1197
1577
|
messageHash: "",
|
|
1198
|
-
signature: response
|
|
1578
|
+
signature: response,
|
|
1579
|
+
protocol: "ECDSA" /* ECDSA */
|
|
1199
1580
|
};
|
|
1200
1581
|
}
|
|
1201
1582
|
async sendTransfer(params) {
|
|
@@ -1209,11 +1590,11 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1209
1590
|
};
|
|
1210
1591
|
}
|
|
1211
1592
|
async signPsbt(params) {
|
|
1212
|
-
const { psbt, signInputs,
|
|
1593
|
+
const { psbt, signInputs, broadcast } = params;
|
|
1213
1594
|
const psbtHex = Buffer.from(psbt, "base64").toString("hex");
|
|
1214
1595
|
const signedPsbt = await window.unisat.signPsbt(psbtHex, {
|
|
1215
1596
|
autoFinalized: broadcast,
|
|
1216
|
-
toSignInputs: convertSignInputsToInputType(signInputs
|
|
1597
|
+
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
1217
1598
|
});
|
|
1218
1599
|
if (broadcast) {
|
|
1219
1600
|
const txid = await window.unisat.pushPsbt(psbtHex);
|
|
@@ -1283,6 +1664,33 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1283
1664
|
};
|
|
1284
1665
|
}
|
|
1285
1666
|
};
|
|
1667
|
+
addListener = (eventName, cb) => {
|
|
1668
|
+
switch (eventName) {
|
|
1669
|
+
case "accountChange": {
|
|
1670
|
+
const handler = () => {
|
|
1671
|
+
cb({ type: "accountChange" });
|
|
1672
|
+
};
|
|
1673
|
+
window.unisat.on("accountsChanged", handler);
|
|
1674
|
+
return () => {
|
|
1675
|
+
window.unisat.removeListener("accountsChanged", handler);
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
case "networkChange": {
|
|
1679
|
+
const handler = () => {
|
|
1680
|
+
cb({ type: "networkChange" });
|
|
1681
|
+
};
|
|
1682
|
+
window.unisat.on("networkChanged", handler);
|
|
1683
|
+
return () => {
|
|
1684
|
+
window.unisat.removeListener("networkChanged", handler);
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
default: {
|
|
1688
|
+
console.error("Event not supported by the selected wallet");
|
|
1689
|
+
return () => {
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1286
1694
|
};
|
|
1287
1695
|
|
|
1288
1696
|
// src/adapters/BaseAdapter.ts
|
|
@@ -1542,7 +1950,6 @@ export {
|
|
|
1542
1950
|
RpcErrorCode,
|
|
1543
1951
|
RpcIdSchema,
|
|
1544
1952
|
SatsConnectAdapter,
|
|
1545
|
-
TransferRunesResultSchema,
|
|
1546
1953
|
accountChangeEventName,
|
|
1547
1954
|
accountChangeSchema,
|
|
1548
1955
|
addListener,
|
|
@@ -1594,10 +2001,6 @@ export {
|
|
|
1594
2001
|
getProviderById,
|
|
1595
2002
|
getProviderOrThrow,
|
|
1596
2003
|
getProviders,
|
|
1597
|
-
getRunesBalanceMethodName,
|
|
1598
|
-
getRunesBalanceParamsSchema,
|
|
1599
|
-
getRunesBalanceRequestMessageSchema,
|
|
1600
|
-
getRunesBalanceResultSchema,
|
|
1601
2004
|
getSupportedWallets,
|
|
1602
2005
|
getWalletTypeMethodName,
|
|
1603
2006
|
getWalletTypeParamsSchema,
|
|
@@ -1607,10 +2010,6 @@ export {
|
|
|
1607
2010
|
networkChangeEventName,
|
|
1608
2011
|
networkChangeSchema,
|
|
1609
2012
|
permissionTemplate,
|
|
1610
|
-
registerClientMethodName,
|
|
1611
|
-
registerClientParamsSchema,
|
|
1612
|
-
registerClientRequestMessageSchema,
|
|
1613
|
-
registerClientResultSchema,
|
|
1614
2013
|
removeDefaultProvider,
|
|
1615
2014
|
renouncePermissionsMethodName,
|
|
1616
2015
|
renouncePermissionsParamsSchema,
|
|
@@ -1625,11 +2024,31 @@ export {
|
|
|
1625
2024
|
rpcRequestMessageSchema,
|
|
1626
2025
|
rpcResponseMessageSchema,
|
|
1627
2026
|
rpcSuccessResponseMessageSchema,
|
|
2027
|
+
runesEtchMethodName,
|
|
2028
|
+
runesEtchParamsSchema,
|
|
2029
|
+
runesEtchRequestMessageSchema,
|
|
2030
|
+
runesEtchResultSchema,
|
|
2031
|
+
runesGetBalanceMethodName,
|
|
2032
|
+
runesGetBalanceParamsSchema,
|
|
2033
|
+
runesGetBalanceRequestMessageSchema,
|
|
2034
|
+
runesGetBalanceResultSchema,
|
|
2035
|
+
runesMintMethodName,
|
|
2036
|
+
runesMintParamsSchema,
|
|
2037
|
+
runesMintRequestMessageSchema,
|
|
2038
|
+
runesMintResultSchema,
|
|
2039
|
+
runesTransferMethodName,
|
|
2040
|
+
runesTransferParamsSchema,
|
|
2041
|
+
runesTransferRequestSchema,
|
|
2042
|
+
runesTransferResultSchema,
|
|
1628
2043
|
sendBtcTransaction,
|
|
1629
2044
|
sendInscriptionsMethodName,
|
|
1630
2045
|
sendInscriptionsParamsSchema,
|
|
1631
2046
|
sendInscriptionsResultSchema,
|
|
1632
2047
|
sendInscriptionsSchema,
|
|
2048
|
+
sendTransferMethodName,
|
|
2049
|
+
sendTransferParamsSchema,
|
|
2050
|
+
sendTransferRequestMessageSchema,
|
|
2051
|
+
sendTransferResultSchema,
|
|
1633
2052
|
setDefaultProvider,
|
|
1634
2053
|
signMessage,
|
|
1635
2054
|
signMessageMethodName,
|
|
@@ -1637,18 +2056,43 @@ export {
|
|
|
1637
2056
|
signMessageRequestMessageSchema,
|
|
1638
2057
|
signMessageResultSchema,
|
|
1639
2058
|
signMultipleTransactions,
|
|
2059
|
+
signPsbtMethodName,
|
|
2060
|
+
signPsbtParamsSchema,
|
|
2061
|
+
signPsbtRequestMessageSchema,
|
|
2062
|
+
signPsbtResultSchema,
|
|
1640
2063
|
signTransaction,
|
|
2064
|
+
stxCallContractMethodName,
|
|
2065
|
+
stxCallContractParamsSchema,
|
|
2066
|
+
stxCallContractRequestMessageSchema,
|
|
2067
|
+
stxCallContractResultSchema,
|
|
2068
|
+
stxDeployContractMethodName,
|
|
2069
|
+
stxDeployContractParamsSchema,
|
|
2070
|
+
stxDeployContractRequestMessageSchema,
|
|
2071
|
+
stxDeployContractResultSchema,
|
|
2072
|
+
stxGetAccountsMethodName,
|
|
2073
|
+
stxGetAccountsParamsSchema,
|
|
2074
|
+
stxGetAccountsRequestMessageSchema,
|
|
2075
|
+
stxGetAccountsResultSchema,
|
|
1641
2076
|
stxGetAddressesMethodName,
|
|
1642
2077
|
stxGetAddressesParamsSchema,
|
|
1643
2078
|
stxGetAddressesRequestMessageSchema,
|
|
1644
2079
|
stxGetAddressesResultSchema,
|
|
2080
|
+
stxSignMessageMethodName,
|
|
2081
|
+
stxSignMessageParamsSchema,
|
|
2082
|
+
stxSignMessageRequestMessageSchema,
|
|
2083
|
+
stxSignMessageResultSchema,
|
|
2084
|
+
stxSignStructuredMessageMethodName,
|
|
2085
|
+
stxSignStructuredMessageParamsSchema,
|
|
2086
|
+
stxSignStructuredMessageRequestMessageSchema,
|
|
2087
|
+
stxSignStructuredMessageResultSchema,
|
|
1645
2088
|
stxSignTransactionMethodName,
|
|
1646
2089
|
stxSignTransactionParamsSchema,
|
|
1647
2090
|
stxSignTransactionRequestMessageSchema,
|
|
1648
2091
|
stxSignTransactionResultSchema,
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
2092
|
+
stxTransferStxMethodName,
|
|
2093
|
+
stxTransferStxParamsSchema,
|
|
2094
|
+
stxTransferStxRequestMessageSchema,
|
|
2095
|
+
stxTransferStxResultSchema,
|
|
1652
2096
|
walletEventSchema,
|
|
1653
2097
|
walletTypeSchema,
|
|
1654
2098
|
walletTypes
|