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