@sats-connect/core 0.5.6 → 0.5.7-8d89b71
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 +31 -23
- package/dist/index.d.ts +31 -23
- package/dist/index.js +84 -84
- package/dist/index.mjs +84 -84
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -103,7 +103,7 @@ declare const networkChangeEventName = "networkChange";
|
|
|
103
103
|
declare const networkChangeSchema: v.ObjectSchema<{
|
|
104
104
|
readonly type: v.LiteralSchema<"networkChange", undefined>;
|
|
105
105
|
readonly bitcoin: v.ObjectSchema<{
|
|
106
|
-
readonly name: v.
|
|
106
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
107
107
|
}, undefined>;
|
|
108
108
|
readonly stacks: v.ObjectSchema<{
|
|
109
109
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -120,7 +120,7 @@ declare const walletEventSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
|
120
120
|
}, undefined>, v.ObjectSchema<{
|
|
121
121
|
readonly type: v.LiteralSchema<"networkChange", undefined>;
|
|
122
122
|
readonly bitcoin: v.ObjectSchema<{
|
|
123
|
-
readonly name: v.
|
|
123
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
124
124
|
}, undefined>;
|
|
125
125
|
readonly stacks: v.ObjectSchema<{
|
|
126
126
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -1603,6 +1603,26 @@ declare const getCurrentPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
|
1603
1603
|
}, undefined>;
|
|
1604
1604
|
type GetCurrentPermissionsRequestMessage = v.InferOutput<typeof getCurrentPermissionsRequestMessageSchema>;
|
|
1605
1605
|
type GetCurrentPermissions = MethodParamsAndResult<GetCurrentPermissionsParams, GetCurrentPermissionsResult>;
|
|
1606
|
+
declare const getNetworkMethodName = "wallet_getNetwork";
|
|
1607
|
+
declare const getNetworkParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1608
|
+
type GetNetworkParams = v.InferOutput<typeof getNetworkParamsSchema>;
|
|
1609
|
+
declare const getNetworkResultSchema: v.ObjectSchema<{
|
|
1610
|
+
readonly bitcoin: v.ObjectSchema<{
|
|
1611
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
1612
|
+
}, undefined>;
|
|
1613
|
+
readonly stacks: v.ObjectSchema<{
|
|
1614
|
+
readonly name: v.StringSchema<undefined>;
|
|
1615
|
+
}, undefined>;
|
|
1616
|
+
}, undefined>;
|
|
1617
|
+
type GetNetworkResult = v.InferOutput<typeof getNetworkResultSchema>;
|
|
1618
|
+
declare const getNetworkRequestMessageSchema: v.ObjectSchema<{
|
|
1619
|
+
readonly method: v.LiteralSchema<"wallet_getNetwork", undefined>;
|
|
1620
|
+
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1621
|
+
readonly id: v.StringSchema<undefined>;
|
|
1622
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
1623
|
+
}, undefined>;
|
|
1624
|
+
type GetNetworkRequestMessage = v.InferOutput<typeof getNetworkRequestMessageSchema>;
|
|
1625
|
+
type GetNetwork = MethodParamsAndResult<GetNetworkParams, GetNetworkResult>;
|
|
1606
1626
|
declare const getAccountMethodName = "wallet_getAccount";
|
|
1607
1627
|
declare const getAccountParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1608
1628
|
type GetAccountParams = v.InferOutput<typeof getAccountParamsSchema>;
|
|
@@ -1616,6 +1636,14 @@ declare const getAccountResultSchema: v.ObjectSchema<{
|
|
|
1616
1636
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
1617
1637
|
}, undefined>, undefined>;
|
|
1618
1638
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
1639
|
+
readonly network: v.ObjectSchema<{
|
|
1640
|
+
readonly bitcoin: v.ObjectSchema<{
|
|
1641
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
1642
|
+
}, undefined>;
|
|
1643
|
+
readonly stacks: v.ObjectSchema<{
|
|
1644
|
+
readonly name: v.StringSchema<undefined>;
|
|
1645
|
+
}, undefined>;
|
|
1646
|
+
}, undefined>;
|
|
1619
1647
|
}, undefined>;
|
|
1620
1648
|
type GetAccountResult = v.InferOutput<typeof getAccountResultSchema>;
|
|
1621
1649
|
declare const getAccountRequestMessageSchema: v.ObjectSchema<{
|
|
@@ -1626,26 +1654,6 @@ declare const getAccountRequestMessageSchema: v.ObjectSchema<{
|
|
|
1626
1654
|
}, undefined>;
|
|
1627
1655
|
type GetAccountRequestMessage = v.InferOutput<typeof getAccountRequestMessageSchema>;
|
|
1628
1656
|
type GetAccount = MethodParamsAndResult<GetAccountParams, GetAccountResult>;
|
|
1629
|
-
declare const getNetworkMethodName = "wallet_getNetwork";
|
|
1630
|
-
declare const getNetworkParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1631
|
-
type GetNetworkParams = v.InferOutput<typeof getNetworkParamsSchema>;
|
|
1632
|
-
declare const getNetworkResultSchema: v.ObjectSchema<{
|
|
1633
|
-
readonly bitcoin: v.ObjectSchema<{
|
|
1634
|
-
readonly name: v.PicklistSchema<readonly ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"], undefined>;
|
|
1635
|
-
}, undefined>;
|
|
1636
|
-
readonly stacks: v.ObjectSchema<{
|
|
1637
|
-
readonly name: v.StringSchema<undefined>;
|
|
1638
|
-
}, undefined>;
|
|
1639
|
-
}, undefined>;
|
|
1640
|
-
type GetNetworkResult = v.InferOutput<typeof getNetworkResultSchema>;
|
|
1641
|
-
declare const getNetworkRequestMessageSchema: v.ObjectSchema<{
|
|
1642
|
-
readonly method: v.LiteralSchema<"wallet_getNetwork", undefined>;
|
|
1643
|
-
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1644
|
-
readonly id: v.StringSchema<undefined>;
|
|
1645
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
1646
|
-
}, undefined>;
|
|
1647
|
-
type GetNetworkRequestMessage = v.InferOutput<typeof getNetworkRequestMessageSchema>;
|
|
1648
|
-
type GetNetwork = MethodParamsAndResult<GetNetworkParams, GetNetworkResult>;
|
|
1649
1657
|
declare const connectMethodName = "wallet_connect";
|
|
1650
1658
|
declare const connectParamsSchema: v.NullishSchema<v.ObjectSchema<{
|
|
1651
1659
|
readonly permissions: v.OptionalSchema<v.ArraySchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -1677,7 +1685,7 @@ declare const connectResultSchema: v.ObjectSchema<{
|
|
|
1677
1685
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
1678
1686
|
readonly network: v.ObjectSchema<{
|
|
1679
1687
|
readonly bitcoin: v.ObjectSchema<{
|
|
1680
|
-
readonly name: v.
|
|
1688
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
1681
1689
|
}, undefined>;
|
|
1682
1690
|
readonly stacks: v.ObjectSchema<{
|
|
1683
1691
|
readonly name: v.StringSchema<undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ declare const networkChangeEventName = "networkChange";
|
|
|
103
103
|
declare const networkChangeSchema: v.ObjectSchema<{
|
|
104
104
|
readonly type: v.LiteralSchema<"networkChange", undefined>;
|
|
105
105
|
readonly bitcoin: v.ObjectSchema<{
|
|
106
|
-
readonly name: v.
|
|
106
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
107
107
|
}, undefined>;
|
|
108
108
|
readonly stacks: v.ObjectSchema<{
|
|
109
109
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -120,7 +120,7 @@ declare const walletEventSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
|
120
120
|
}, undefined>, v.ObjectSchema<{
|
|
121
121
|
readonly type: v.LiteralSchema<"networkChange", undefined>;
|
|
122
122
|
readonly bitcoin: v.ObjectSchema<{
|
|
123
|
-
readonly name: v.
|
|
123
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
124
124
|
}, undefined>;
|
|
125
125
|
readonly stacks: v.ObjectSchema<{
|
|
126
126
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -1603,6 +1603,26 @@ declare const getCurrentPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
|
1603
1603
|
}, undefined>;
|
|
1604
1604
|
type GetCurrentPermissionsRequestMessage = v.InferOutput<typeof getCurrentPermissionsRequestMessageSchema>;
|
|
1605
1605
|
type GetCurrentPermissions = MethodParamsAndResult<GetCurrentPermissionsParams, GetCurrentPermissionsResult>;
|
|
1606
|
+
declare const getNetworkMethodName = "wallet_getNetwork";
|
|
1607
|
+
declare const getNetworkParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1608
|
+
type GetNetworkParams = v.InferOutput<typeof getNetworkParamsSchema>;
|
|
1609
|
+
declare const getNetworkResultSchema: v.ObjectSchema<{
|
|
1610
|
+
readonly bitcoin: v.ObjectSchema<{
|
|
1611
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
1612
|
+
}, undefined>;
|
|
1613
|
+
readonly stacks: v.ObjectSchema<{
|
|
1614
|
+
readonly name: v.StringSchema<undefined>;
|
|
1615
|
+
}, undefined>;
|
|
1616
|
+
}, undefined>;
|
|
1617
|
+
type GetNetworkResult = v.InferOutput<typeof getNetworkResultSchema>;
|
|
1618
|
+
declare const getNetworkRequestMessageSchema: v.ObjectSchema<{
|
|
1619
|
+
readonly method: v.LiteralSchema<"wallet_getNetwork", undefined>;
|
|
1620
|
+
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1621
|
+
readonly id: v.StringSchema<undefined>;
|
|
1622
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
1623
|
+
}, undefined>;
|
|
1624
|
+
type GetNetworkRequestMessage = v.InferOutput<typeof getNetworkRequestMessageSchema>;
|
|
1625
|
+
type GetNetwork = MethodParamsAndResult<GetNetworkParams, GetNetworkResult>;
|
|
1606
1626
|
declare const getAccountMethodName = "wallet_getAccount";
|
|
1607
1627
|
declare const getAccountParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1608
1628
|
type GetAccountParams = v.InferOutput<typeof getAccountParamsSchema>;
|
|
@@ -1616,6 +1636,14 @@ declare const getAccountResultSchema: v.ObjectSchema<{
|
|
|
1616
1636
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
1617
1637
|
}, undefined>, undefined>;
|
|
1618
1638
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
1639
|
+
readonly network: v.ObjectSchema<{
|
|
1640
|
+
readonly bitcoin: v.ObjectSchema<{
|
|
1641
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
1642
|
+
}, undefined>;
|
|
1643
|
+
readonly stacks: v.ObjectSchema<{
|
|
1644
|
+
readonly name: v.StringSchema<undefined>;
|
|
1645
|
+
}, undefined>;
|
|
1646
|
+
}, undefined>;
|
|
1619
1647
|
}, undefined>;
|
|
1620
1648
|
type GetAccountResult = v.InferOutput<typeof getAccountResultSchema>;
|
|
1621
1649
|
declare const getAccountRequestMessageSchema: v.ObjectSchema<{
|
|
@@ -1626,26 +1654,6 @@ declare const getAccountRequestMessageSchema: v.ObjectSchema<{
|
|
|
1626
1654
|
}, undefined>;
|
|
1627
1655
|
type GetAccountRequestMessage = v.InferOutput<typeof getAccountRequestMessageSchema>;
|
|
1628
1656
|
type GetAccount = MethodParamsAndResult<GetAccountParams, GetAccountResult>;
|
|
1629
|
-
declare const getNetworkMethodName = "wallet_getNetwork";
|
|
1630
|
-
declare const getNetworkParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1631
|
-
type GetNetworkParams = v.InferOutput<typeof getNetworkParamsSchema>;
|
|
1632
|
-
declare const getNetworkResultSchema: v.ObjectSchema<{
|
|
1633
|
-
readonly bitcoin: v.ObjectSchema<{
|
|
1634
|
-
readonly name: v.PicklistSchema<readonly ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"], undefined>;
|
|
1635
|
-
}, undefined>;
|
|
1636
|
-
readonly stacks: v.ObjectSchema<{
|
|
1637
|
-
readonly name: v.StringSchema<undefined>;
|
|
1638
|
-
}, undefined>;
|
|
1639
|
-
}, undefined>;
|
|
1640
|
-
type GetNetworkResult = v.InferOutput<typeof getNetworkResultSchema>;
|
|
1641
|
-
declare const getNetworkRequestMessageSchema: v.ObjectSchema<{
|
|
1642
|
-
readonly method: v.LiteralSchema<"wallet_getNetwork", undefined>;
|
|
1643
|
-
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1644
|
-
readonly id: v.StringSchema<undefined>;
|
|
1645
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
1646
|
-
}, undefined>;
|
|
1647
|
-
type GetNetworkRequestMessage = v.InferOutput<typeof getNetworkRequestMessageSchema>;
|
|
1648
|
-
type GetNetwork = MethodParamsAndResult<GetNetworkParams, GetNetworkResult>;
|
|
1649
1657
|
declare const connectMethodName = "wallet_connect";
|
|
1650
1658
|
declare const connectParamsSchema: v.NullishSchema<v.ObjectSchema<{
|
|
1651
1659
|
readonly permissions: v.OptionalSchema<v.ArraySchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -1677,7 +1685,7 @@ declare const connectResultSchema: v.ObjectSchema<{
|
|
|
1677
1685
|
readonly walletType: v.PicklistSchema<readonly ["software", "ledger", "keystone"], undefined>;
|
|
1678
1686
|
readonly network: v.ObjectSchema<{
|
|
1679
1687
|
readonly bitcoin: v.ObjectSchema<{
|
|
1680
|
-
readonly name: v.
|
|
1688
|
+
readonly name: v.EnumSchema<typeof BitcoinNetworkType, undefined>;
|
|
1681
1689
|
}, undefined>;
|
|
1682
1690
|
readonly stacks: v.ObjectSchema<{
|
|
1683
1691
|
readonly name: v.StringSchema<undefined>;
|
package/dist/index.js
CHANGED
|
@@ -201,28 +201,80 @@ __export(src_exports, {
|
|
|
201
201
|
});
|
|
202
202
|
module.exports = __toCommonJS(src_exports);
|
|
203
203
|
|
|
204
|
-
// src/
|
|
204
|
+
// src/types.ts
|
|
205
205
|
var v = __toESM(require("valibot"));
|
|
206
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
207
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
208
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
209
|
+
BitcoinNetworkType2["Testnet4"] = "Testnet4";
|
|
210
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
211
|
+
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
212
|
+
return BitcoinNetworkType2;
|
|
213
|
+
})(BitcoinNetworkType || {});
|
|
214
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
215
|
+
var rpcRequestMessageSchema = v.object({
|
|
216
|
+
jsonrpc: v.literal("2.0"),
|
|
217
|
+
method: v.string(),
|
|
218
|
+
params: v.optional(
|
|
219
|
+
v.union([
|
|
220
|
+
v.array(v.unknown()),
|
|
221
|
+
v.looseObject({}),
|
|
222
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
223
|
+
// to be either an array or an object when provided. Changing this now would
|
|
224
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
225
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
226
|
+
v.null()
|
|
227
|
+
])
|
|
228
|
+
),
|
|
229
|
+
id: v.unwrap(RpcIdSchema)
|
|
230
|
+
});
|
|
231
|
+
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
232
|
+
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
233
|
+
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
234
|
+
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
235
|
+
RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
236
|
+
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
237
|
+
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
238
|
+
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
239
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
240
|
+
return RpcErrorCode2;
|
|
241
|
+
})(RpcErrorCode || {});
|
|
242
|
+
var rpcSuccessResponseMessageSchema = v.object({
|
|
243
|
+
jsonrpc: v.literal("2.0"),
|
|
244
|
+
result: v.nonOptional(v.unknown()),
|
|
245
|
+
id: RpcIdSchema
|
|
246
|
+
});
|
|
247
|
+
var rpcErrorResponseMessageSchema = v.object({
|
|
248
|
+
jsonrpc: v.literal("2.0"),
|
|
249
|
+
error: v.nonOptional(v.unknown()),
|
|
250
|
+
id: RpcIdSchema
|
|
251
|
+
});
|
|
252
|
+
var rpcResponseMessageSchema = v.union([
|
|
253
|
+
rpcSuccessResponseMessageSchema,
|
|
254
|
+
rpcErrorResponseMessageSchema
|
|
255
|
+
]);
|
|
256
|
+
|
|
257
|
+
// src/provider/types.ts
|
|
258
|
+
var v2 = __toESM(require("valibot"));
|
|
206
259
|
var accountChangeEventName = "accountChange";
|
|
207
|
-
var accountChangeSchema =
|
|
208
|
-
type:
|
|
260
|
+
var accountChangeSchema = v2.object({
|
|
261
|
+
type: v2.literal(accountChangeEventName)
|
|
209
262
|
});
|
|
210
263
|
var networkChangeEventName = "networkChange";
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
name: v.picklist(networkType)
|
|
264
|
+
var networkChangeSchema = v2.object({
|
|
265
|
+
type: v2.literal(networkChangeEventName),
|
|
266
|
+
bitcoin: v2.object({
|
|
267
|
+
name: v2.enum(BitcoinNetworkType)
|
|
216
268
|
}),
|
|
217
|
-
stacks:
|
|
218
|
-
name:
|
|
269
|
+
stacks: v2.object({
|
|
270
|
+
name: v2.string()
|
|
219
271
|
})
|
|
220
272
|
});
|
|
221
273
|
var disconnectEventName = "disconnect";
|
|
222
|
-
var disconnectSchema =
|
|
223
|
-
type:
|
|
274
|
+
var disconnectSchema = v2.object({
|
|
275
|
+
type: v2.literal(disconnectEventName)
|
|
224
276
|
});
|
|
225
|
-
var walletEventSchema =
|
|
277
|
+
var walletEventSchema = v2.variant("type", [
|
|
226
278
|
accountChangeSchema,
|
|
227
279
|
networkChangeSchema,
|
|
228
280
|
disconnectSchema
|
|
@@ -267,59 +319,6 @@ function getSupportedWallets() {
|
|
|
267
319
|
return wallets;
|
|
268
320
|
}
|
|
269
321
|
|
|
270
|
-
// src/types.ts
|
|
271
|
-
var v2 = __toESM(require("valibot"));
|
|
272
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
273
|
-
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
274
|
-
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
275
|
-
BitcoinNetworkType2["Testnet4"] = "Testnet4";
|
|
276
|
-
BitcoinNetworkType2["Signet"] = "Signet";
|
|
277
|
-
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
278
|
-
return BitcoinNetworkType2;
|
|
279
|
-
})(BitcoinNetworkType || {});
|
|
280
|
-
var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
|
|
281
|
-
var rpcRequestMessageSchema = v2.object({
|
|
282
|
-
jsonrpc: v2.literal("2.0"),
|
|
283
|
-
method: v2.string(),
|
|
284
|
-
params: v2.optional(
|
|
285
|
-
v2.union([
|
|
286
|
-
v2.array(v2.unknown()),
|
|
287
|
-
v2.looseObject({}),
|
|
288
|
-
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
289
|
-
// to be either an array or an object when provided. Changing this now would
|
|
290
|
-
// be a breaking change, so accepting null values for now. Tracking in
|
|
291
|
-
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
292
|
-
v2.null()
|
|
293
|
-
])
|
|
294
|
-
),
|
|
295
|
-
id: v2.unwrap(RpcIdSchema)
|
|
296
|
-
});
|
|
297
|
-
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
298
|
-
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
299
|
-
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
300
|
-
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
301
|
-
RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
302
|
-
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
303
|
-
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
304
|
-
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
305
|
-
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
306
|
-
return RpcErrorCode2;
|
|
307
|
-
})(RpcErrorCode || {});
|
|
308
|
-
var rpcSuccessResponseMessageSchema = v2.object({
|
|
309
|
-
jsonrpc: v2.literal("2.0"),
|
|
310
|
-
result: v2.nonOptional(v2.unknown()),
|
|
311
|
-
id: RpcIdSchema
|
|
312
|
-
});
|
|
313
|
-
var rpcErrorResponseMessageSchema = v2.object({
|
|
314
|
-
jsonrpc: v2.literal("2.0"),
|
|
315
|
-
error: v2.nonOptional(v2.unknown()),
|
|
316
|
-
id: RpcIdSchema
|
|
317
|
-
});
|
|
318
|
-
var rpcResponseMessageSchema = v2.union([
|
|
319
|
-
rpcSuccessResponseMessageSchema,
|
|
320
|
-
rpcErrorResponseMessageSchema
|
|
321
|
-
]);
|
|
322
|
-
|
|
323
322
|
// src/request/index.ts
|
|
324
323
|
var v21 = __toESM(require("valibot"));
|
|
325
324
|
|
|
@@ -1037,27 +1036,11 @@ var getCurrentPermissionsRequestMessageSchema = v15.object({
|
|
|
1037
1036
|
id: v15.string()
|
|
1038
1037
|
}).entries
|
|
1039
1038
|
});
|
|
1040
|
-
var getAccountMethodName = "wallet_getAccount";
|
|
1041
|
-
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
1042
|
-
var getAccountResultSchema = v15.object({
|
|
1043
|
-
id: v15.string(),
|
|
1044
|
-
addresses: v15.array(addressSchema),
|
|
1045
|
-
walletType: walletTypeSchema
|
|
1046
|
-
});
|
|
1047
|
-
var getAccountRequestMessageSchema = v15.object({
|
|
1048
|
-
...rpcRequestMessageSchema.entries,
|
|
1049
|
-
...v15.object({
|
|
1050
|
-
method: v15.literal(getAccountMethodName),
|
|
1051
|
-
params: getAccountParamsSchema,
|
|
1052
|
-
id: v15.string()
|
|
1053
|
-
}).entries
|
|
1054
|
-
});
|
|
1055
1039
|
var getNetworkMethodName = "wallet_getNetwork";
|
|
1056
1040
|
var getNetworkParamsSchema = v15.nullish(v15.null());
|
|
1057
|
-
var networkType2 = ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"];
|
|
1058
1041
|
var getNetworkResultSchema = v15.object({
|
|
1059
1042
|
bitcoin: v15.object({
|
|
1060
|
-
name: v15.
|
|
1043
|
+
name: v15.enum(BitcoinNetworkType)
|
|
1061
1044
|
}),
|
|
1062
1045
|
stacks: v15.object({
|
|
1063
1046
|
name: v15.string()
|
|
@@ -1071,6 +1054,22 @@ var getNetworkRequestMessageSchema = v15.object({
|
|
|
1071
1054
|
id: v15.string()
|
|
1072
1055
|
}).entries
|
|
1073
1056
|
});
|
|
1057
|
+
var getAccountMethodName = "wallet_getAccount";
|
|
1058
|
+
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
1059
|
+
var getAccountResultSchema = v15.object({
|
|
1060
|
+
id: v15.string(),
|
|
1061
|
+
addresses: v15.array(addressSchema),
|
|
1062
|
+
walletType: walletTypeSchema,
|
|
1063
|
+
network: getNetworkResultSchema
|
|
1064
|
+
});
|
|
1065
|
+
var getAccountRequestMessageSchema = v15.object({
|
|
1066
|
+
...rpcRequestMessageSchema.entries,
|
|
1067
|
+
...v15.object({
|
|
1068
|
+
method: v15.literal(getAccountMethodName),
|
|
1069
|
+
params: getAccountParamsSchema,
|
|
1070
|
+
id: v15.string()
|
|
1071
|
+
}).entries
|
|
1072
|
+
});
|
|
1074
1073
|
var connectMethodName = "wallet_connect";
|
|
1075
1074
|
var connectParamsSchema = v15.nullish(
|
|
1076
1075
|
v15.object({
|
|
@@ -1329,10 +1328,11 @@ var import_axios = __toESM(require("axios"));
|
|
|
1329
1328
|
var urlNetworkSuffix = {
|
|
1330
1329
|
["Mainnet" /* Mainnet */]: "",
|
|
1331
1330
|
["Testnet" /* Testnet */]: "-testnet",
|
|
1331
|
+
["Testnet4" /* Testnet4 */]: "-testnet4",
|
|
1332
1332
|
["Signet" /* Signet */]: "-signet"
|
|
1333
1333
|
};
|
|
1334
1334
|
var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => {
|
|
1335
|
-
if (network === "Regtest" /* Regtest */
|
|
1335
|
+
if (network === "Regtest" /* Regtest */) {
|
|
1336
1336
|
throw new Error(`Ordinals API does not support ${network} network`);
|
|
1337
1337
|
}
|
|
1338
1338
|
return `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,77 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/types.ts
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
4
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
5
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
6
|
+
BitcoinNetworkType2["Testnet4"] = "Testnet4";
|
|
7
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
8
|
+
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
9
|
+
return BitcoinNetworkType2;
|
|
10
|
+
})(BitcoinNetworkType || {});
|
|
11
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
12
|
+
var rpcRequestMessageSchema = v.object({
|
|
13
|
+
jsonrpc: v.literal("2.0"),
|
|
14
|
+
method: v.string(),
|
|
15
|
+
params: v.optional(
|
|
16
|
+
v.union([
|
|
17
|
+
v.array(v.unknown()),
|
|
18
|
+
v.looseObject({}),
|
|
19
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
20
|
+
// to be either an array or an object when provided. Changing this now would
|
|
21
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
22
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
23
|
+
v.null()
|
|
24
|
+
])
|
|
25
|
+
),
|
|
26
|
+
id: v.unwrap(RpcIdSchema)
|
|
27
|
+
});
|
|
28
|
+
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
29
|
+
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
30
|
+
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
31
|
+
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
32
|
+
RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
33
|
+
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
35
|
+
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
36
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
37
|
+
return RpcErrorCode2;
|
|
38
|
+
})(RpcErrorCode || {});
|
|
39
|
+
var rpcSuccessResponseMessageSchema = v.object({
|
|
40
|
+
jsonrpc: v.literal("2.0"),
|
|
41
|
+
result: v.nonOptional(v.unknown()),
|
|
42
|
+
id: RpcIdSchema
|
|
43
|
+
});
|
|
44
|
+
var rpcErrorResponseMessageSchema = v.object({
|
|
45
|
+
jsonrpc: v.literal("2.0"),
|
|
46
|
+
error: v.nonOptional(v.unknown()),
|
|
47
|
+
id: RpcIdSchema
|
|
48
|
+
});
|
|
49
|
+
var rpcResponseMessageSchema = v.union([
|
|
50
|
+
rpcSuccessResponseMessageSchema,
|
|
51
|
+
rpcErrorResponseMessageSchema
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
// src/provider/types.ts
|
|
55
|
+
import * as v2 from "valibot";
|
|
3
56
|
var accountChangeEventName = "accountChange";
|
|
4
|
-
var accountChangeSchema =
|
|
5
|
-
type:
|
|
57
|
+
var accountChangeSchema = v2.object({
|
|
58
|
+
type: v2.literal(accountChangeEventName)
|
|
6
59
|
});
|
|
7
60
|
var networkChangeEventName = "networkChange";
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
name: v.picklist(networkType)
|
|
61
|
+
var networkChangeSchema = v2.object({
|
|
62
|
+
type: v2.literal(networkChangeEventName),
|
|
63
|
+
bitcoin: v2.object({
|
|
64
|
+
name: v2.enum(BitcoinNetworkType)
|
|
13
65
|
}),
|
|
14
|
-
stacks:
|
|
15
|
-
name:
|
|
66
|
+
stacks: v2.object({
|
|
67
|
+
name: v2.string()
|
|
16
68
|
})
|
|
17
69
|
});
|
|
18
70
|
var disconnectEventName = "disconnect";
|
|
19
|
-
var disconnectSchema =
|
|
20
|
-
type:
|
|
71
|
+
var disconnectSchema = v2.object({
|
|
72
|
+
type: v2.literal(disconnectEventName)
|
|
21
73
|
});
|
|
22
|
-
var walletEventSchema =
|
|
74
|
+
var walletEventSchema = v2.variant("type", [
|
|
23
75
|
accountChangeSchema,
|
|
24
76
|
networkChangeSchema,
|
|
25
77
|
disconnectSchema
|
|
@@ -64,59 +116,6 @@ function getSupportedWallets() {
|
|
|
64
116
|
return wallets;
|
|
65
117
|
}
|
|
66
118
|
|
|
67
|
-
// src/types.ts
|
|
68
|
-
import * as v2 from "valibot";
|
|
69
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
70
|
-
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
71
|
-
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
72
|
-
BitcoinNetworkType2["Testnet4"] = "Testnet4";
|
|
73
|
-
BitcoinNetworkType2["Signet"] = "Signet";
|
|
74
|
-
BitcoinNetworkType2["Regtest"] = "Regtest";
|
|
75
|
-
return BitcoinNetworkType2;
|
|
76
|
-
})(BitcoinNetworkType || {});
|
|
77
|
-
var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
|
|
78
|
-
var rpcRequestMessageSchema = v2.object({
|
|
79
|
-
jsonrpc: v2.literal("2.0"),
|
|
80
|
-
method: v2.string(),
|
|
81
|
-
params: v2.optional(
|
|
82
|
-
v2.union([
|
|
83
|
-
v2.array(v2.unknown()),
|
|
84
|
-
v2.looseObject({}),
|
|
85
|
-
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
86
|
-
// to be either an array or an object when provided. Changing this now would
|
|
87
|
-
// be a breaking change, so accepting null values for now. Tracking in
|
|
88
|
-
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
89
|
-
v2.null()
|
|
90
|
-
])
|
|
91
|
-
),
|
|
92
|
-
id: v2.unwrap(RpcIdSchema)
|
|
93
|
-
});
|
|
94
|
-
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
95
|
-
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
96
|
-
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
97
|
-
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
98
|
-
RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
99
|
-
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
100
|
-
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
101
|
-
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
102
|
-
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
103
|
-
return RpcErrorCode2;
|
|
104
|
-
})(RpcErrorCode || {});
|
|
105
|
-
var rpcSuccessResponseMessageSchema = v2.object({
|
|
106
|
-
jsonrpc: v2.literal("2.0"),
|
|
107
|
-
result: v2.nonOptional(v2.unknown()),
|
|
108
|
-
id: RpcIdSchema
|
|
109
|
-
});
|
|
110
|
-
var rpcErrorResponseMessageSchema = v2.object({
|
|
111
|
-
jsonrpc: v2.literal("2.0"),
|
|
112
|
-
error: v2.nonOptional(v2.unknown()),
|
|
113
|
-
id: RpcIdSchema
|
|
114
|
-
});
|
|
115
|
-
var rpcResponseMessageSchema = v2.union([
|
|
116
|
-
rpcSuccessResponseMessageSchema,
|
|
117
|
-
rpcErrorResponseMessageSchema
|
|
118
|
-
]);
|
|
119
|
-
|
|
120
119
|
// src/request/index.ts
|
|
121
120
|
import * as v21 from "valibot";
|
|
122
121
|
|
|
@@ -834,27 +833,11 @@ var getCurrentPermissionsRequestMessageSchema = v15.object({
|
|
|
834
833
|
id: v15.string()
|
|
835
834
|
}).entries
|
|
836
835
|
});
|
|
837
|
-
var getAccountMethodName = "wallet_getAccount";
|
|
838
|
-
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
839
|
-
var getAccountResultSchema = v15.object({
|
|
840
|
-
id: v15.string(),
|
|
841
|
-
addresses: v15.array(addressSchema),
|
|
842
|
-
walletType: walletTypeSchema
|
|
843
|
-
});
|
|
844
|
-
var getAccountRequestMessageSchema = v15.object({
|
|
845
|
-
...rpcRequestMessageSchema.entries,
|
|
846
|
-
...v15.object({
|
|
847
|
-
method: v15.literal(getAccountMethodName),
|
|
848
|
-
params: getAccountParamsSchema,
|
|
849
|
-
id: v15.string()
|
|
850
|
-
}).entries
|
|
851
|
-
});
|
|
852
836
|
var getNetworkMethodName = "wallet_getNetwork";
|
|
853
837
|
var getNetworkParamsSchema = v15.nullish(v15.null());
|
|
854
|
-
var networkType2 = ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"];
|
|
855
838
|
var getNetworkResultSchema = v15.object({
|
|
856
839
|
bitcoin: v15.object({
|
|
857
|
-
name: v15.
|
|
840
|
+
name: v15.enum(BitcoinNetworkType)
|
|
858
841
|
}),
|
|
859
842
|
stacks: v15.object({
|
|
860
843
|
name: v15.string()
|
|
@@ -868,6 +851,22 @@ var getNetworkRequestMessageSchema = v15.object({
|
|
|
868
851
|
id: v15.string()
|
|
869
852
|
}).entries
|
|
870
853
|
});
|
|
854
|
+
var getAccountMethodName = "wallet_getAccount";
|
|
855
|
+
var getAccountParamsSchema = v15.nullish(v15.null());
|
|
856
|
+
var getAccountResultSchema = v15.object({
|
|
857
|
+
id: v15.string(),
|
|
858
|
+
addresses: v15.array(addressSchema),
|
|
859
|
+
walletType: walletTypeSchema,
|
|
860
|
+
network: getNetworkResultSchema
|
|
861
|
+
});
|
|
862
|
+
var getAccountRequestMessageSchema = v15.object({
|
|
863
|
+
...rpcRequestMessageSchema.entries,
|
|
864
|
+
...v15.object({
|
|
865
|
+
method: v15.literal(getAccountMethodName),
|
|
866
|
+
params: getAccountParamsSchema,
|
|
867
|
+
id: v15.string()
|
|
868
|
+
}).entries
|
|
869
|
+
});
|
|
871
870
|
var connectMethodName = "wallet_connect";
|
|
872
871
|
var connectParamsSchema = v15.nullish(
|
|
873
872
|
v15.object({
|
|
@@ -1126,10 +1125,11 @@ import axios from "axios";
|
|
|
1126
1125
|
var urlNetworkSuffix = {
|
|
1127
1126
|
["Mainnet" /* Mainnet */]: "",
|
|
1128
1127
|
["Testnet" /* Testnet */]: "-testnet",
|
|
1128
|
+
["Testnet4" /* Testnet4 */]: "-testnet4",
|
|
1129
1129
|
["Signet" /* Signet */]: "-signet"
|
|
1130
1130
|
};
|
|
1131
1131
|
var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => {
|
|
1132
|
-
if (network === "Regtest" /* Regtest */
|
|
1132
|
+
if (network === "Regtest" /* Regtest */) {
|
|
1133
1133
|
throw new Error(`Ordinals API does not support ${network} network`);
|
|
1134
1134
|
}
|
|
1135
1135
|
return `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|