@sats-connect/core 0.3.0-ab35817 → 0.3.0-f1e4d08
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 +4 -17
- package/dist/index.mjs +44 -33
- package/package.json +2 -4
package/dist/index.d.mts
CHANGED
|
@@ -319,6 +319,9 @@ interface GetAddressResponse {
|
|
|
319
319
|
}
|
|
320
320
|
type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
321
321
|
|
|
322
|
+
/**
|
|
323
|
+
* @deprecated Use `request()` instead
|
|
324
|
+
*/
|
|
322
325
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
323
326
|
|
|
324
327
|
declare const getInfoMethodName = "getInfo";
|
|
@@ -486,11 +489,6 @@ type SignPsbtParams = {
|
|
|
486
489
|
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
487
490
|
*/
|
|
488
491
|
signInputs: Record<string, number[]>;
|
|
489
|
-
/**
|
|
490
|
-
* the sigHash type to use for signing.
|
|
491
|
-
* will default to the sighash type of the input if not provided.
|
|
492
|
-
**/
|
|
493
|
-
allowedSignHash?: number;
|
|
494
492
|
/**
|
|
495
493
|
* Whether to broadcast the transaction after signing.
|
|
496
494
|
**/
|
|
@@ -1076,16 +1074,6 @@ declare const getWalletTypeRequestMessageSchema: v.ObjectSchema<{
|
|
|
1076
1074
|
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
1077
1075
|
}, undefined>;
|
|
1078
1076
|
type GetWalletType = MethodParamsAndResult<v.InferOutput<typeof getWalletTypeParamsSchema>, v.InferOutput<typeof getWalletTypeResultSchema>>;
|
|
1079
|
-
declare const getPermissionsMethodName = "wallet_getPermissions";
|
|
1080
|
-
declare const getPermissionsParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
1081
|
-
declare const getPermissionsResultSchema: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
1082
|
-
declare const getPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
1083
|
-
readonly method: v.LiteralSchema<"wallet_getPermissions", undefined>;
|
|
1084
|
-
readonly id: v.StringSchema<undefined>;
|
|
1085
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
1086
|
-
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
1087
|
-
}, undefined>;
|
|
1088
|
-
type GetPermissions = MethodParamsAndResult<v.InferOutput<typeof getPermissionsParamsSchema>, v.InferOutput<typeof getPermissionsResultSchema>>;
|
|
1089
1077
|
|
|
1090
1078
|
declare const walletTypes: readonly ["software", "ledger"];
|
|
1091
1079
|
declare const walletTypeSchema: v.PicklistSchema<readonly ["software", "ledger"], undefined>;
|
|
@@ -1133,7 +1121,6 @@ interface WalletRequests {
|
|
|
1133
1121
|
wallet_requestPermissions: RequestPermissions;
|
|
1134
1122
|
wallet_renouncePermissions: RenouncePermissions;
|
|
1135
1123
|
wallet_getWalletType: GetWalletType;
|
|
1136
|
-
wallet_getPermissions: GetPermissions;
|
|
1137
1124
|
}
|
|
1138
1125
|
type Requests = BtcRequests & StxRequests & RunesRequests & WalletRequests & OrdinalsRequests;
|
|
1139
1126
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
@@ -1166,4 +1153,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
|
|
|
1166
1153
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
1167
1154
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
1168
1155
|
|
|
1169
|
-
export { type AccountChangeEvent, type AddListener, type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type DisconnectEvent, type EstimateRbfOrder, type EstimateRunesEtch, type EstimateRunesEtchParams, type EstimateRunesEtchResult, type EstimateRunesMint, type EstimateRunesMintParams, type EstimateRunesMintResult, type EtchRunes, type EtchRunesParams, type EtchRunesResult, type GetAccounts, type GetAccountsParams, type GetAccountsRequestMessage, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesRequestMessage, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInfoParams, type GetInfoRequestMessage, type GetInfoResult, type GetInscriptions, type GetOrder, type
|
|
1156
|
+
export { type AccountChangeEvent, type AddListener, type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type DisconnectEvent, type EstimateRbfOrder, type EstimateRunesEtch, type EstimateRunesEtchParams, type EstimateRunesEtchResult, type EstimateRunesMint, type EstimateRunesMintParams, type EstimateRunesMintResult, type EtchRunes, type EtchRunesParams, type EtchRunesResult, type GetAccounts, type GetAccountsParams, type GetAccountsRequestMessage, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesRequestMessage, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInfoParams, type GetInfoRequestMessage, type GetInfoResult, type GetInscriptions, type GetOrder, type GetRunesBalance, type GetRunesBalanceParams, type GetRunesBalanceRequestMessage, type GetRunesBalanceResult, type GetWalletType, type InputToSign, MessageSigningProtocols, type MethodParamsAndResult, type MintRunes, type MintRunesParams, type MintRunesResult, type NetworkChangeEvent, type OrdinalsRequestMethod, type OrdinalsRequests, type Params, type Provider, type PsbtPayload, type RbfOrder, type Recipient$2 as Recipient, type RenouncePermissions, type RequestOptions, type RequestPayload, type RequestPermissions, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcErrorResponseMessage, type RpcId, RpcIdSchema, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResponseMessage, type RpcResult, type RpcSuccessResponse, type RpcSuccessResponseMessage, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendInscriptions, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, type SignMessagePayload, type SignMessageRequestMessage, type SignMessageResponse, type SignMessageResult, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionPayload, type SignTransactionResponse, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAccountsResult, type StxGetAddresses, type StxGetAddressesParams, type StxGetAddressesRequestMessage, type StxGetAddressesResult, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxSignTransactionParams, type StxSignTransactionRequestMessage, type StxSignTransactionResult, type StxTransferStx, type SupportedWallet, type TransferRunes, type TransferRunesParams, type TransferRunesRequest, type TransferRunesResult, TransferRunesResultSchema, type TransferStxParams, type TransferStxResult, type WalletEvent, type WalletRequests, type WalletType, accountChangeEventName, accountChangeSchema, addListener, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, disconnectEventName, disconnectSchema, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoRequestMessageSchema, getInfoResultSchema, getInscriptionsMethodName, getInscriptionsParamsSchema, getInscriptionsResultSchema, getInscriptionsSchema, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, getWalletTypeMethodName, getWalletTypeParamsSchema, getWalletTypeRequestMessageSchema, getWalletTypeResultSchema, isProviderInstalled, networkChangeEventName, networkChangeSchema, removeDefaultProvider, renouncePermissionsMethodName, renouncePermissionsParamsSchema, renouncePermissionsRequestMessageSchema, renouncePermissionsResultSchema, request, requestPermissionsMethodName, requestPermissionsParamsSchema, requestPermissionsRequestMessageSchema, requestPermissionsResultSchema, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, sendInscriptionsMethodName, sendInscriptionsParamsSchema, sendInscriptionsResultSchema, sendInscriptionsSchema, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction, stxGetAddressesMethodName, stxGetAddressesParamsSchema, stxGetAddressesRequestMessageSchema, stxGetAddressesResultSchema, stxSignTransactionMethodName, stxSignTransactionParamsSchema, stxSignTransactionRequestMessageSchema, stxSignTransactionResultSchema, transferRunesMethodName, transferRunesParamsSchema, transferRunesRequestSchema, walletEventSchema, walletTypeSchema, walletTypes };
|
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 {
|
|
@@ -120,6 +115,9 @@ var rpcResponseMessageSchema = v2.union([
|
|
|
120
115
|
// src/request/index.ts
|
|
121
116
|
import * as v10 from "valibot";
|
|
122
117
|
|
|
118
|
+
// src/request/types/stxMethods.ts
|
|
119
|
+
import * as v4 from "valibot";
|
|
120
|
+
|
|
123
121
|
// src/addresses/index.ts
|
|
124
122
|
import { createUnsecuredToken } from "jsontokens";
|
|
125
123
|
|
|
@@ -165,7 +163,6 @@ var getAddress = async (options) => {
|
|
|
165
163
|
};
|
|
166
164
|
|
|
167
165
|
// src/request/types/stxMethods.ts
|
|
168
|
-
import * as v4 from "valibot";
|
|
169
166
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
170
167
|
var stxGetAddressesParamsSchema = v4.nullish(
|
|
171
168
|
v4.object({
|
|
@@ -417,16 +414,6 @@ var getWalletTypeRequestMessageSchema = v7.object({
|
|
|
417
414
|
id: v7.string()
|
|
418
415
|
}).entries
|
|
419
416
|
});
|
|
420
|
-
var getPermissionsMethodName = "wallet_getPermissions";
|
|
421
|
-
var getPermissionsParamsSchema = v7.nullish(v7.null());
|
|
422
|
-
var getPermissionsResultSchema = v7.array(v7.string());
|
|
423
|
-
var getPermissionsRequestMessageSchema = v7.object({
|
|
424
|
-
...rpcRequestMessageSchema.entries,
|
|
425
|
-
...v7.object({
|
|
426
|
-
method: v7.literal(getPermissionsMethodName),
|
|
427
|
-
id: v7.string()
|
|
428
|
-
}).entries
|
|
429
|
-
});
|
|
430
417
|
|
|
431
418
|
// src/request/types/runesMethods.ts
|
|
432
419
|
import * as v8 from "valibot";
|
|
@@ -1059,17 +1046,16 @@ var XverseAdapter = class extends SatsConnectAdapter {
|
|
|
1059
1046
|
};
|
|
1060
1047
|
|
|
1061
1048
|
// src/adapters/unisat.ts
|
|
1062
|
-
import { Buffer } from "buffer";
|
|
1063
1049
|
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
1064
|
-
|
|
1050
|
+
import { Buffer } from "buffer";
|
|
1051
|
+
function convertSignInputsToInputType(signInputs) {
|
|
1065
1052
|
let result = [];
|
|
1066
1053
|
for (let address in signInputs) {
|
|
1067
1054
|
let indexes = signInputs[address];
|
|
1068
1055
|
for (let index of indexes) {
|
|
1069
1056
|
result.push({
|
|
1070
1057
|
index,
|
|
1071
|
-
address
|
|
1072
|
-
sighashTypes: allowedSignHash ? [allowedSignHash] : void 0
|
|
1058
|
+
address
|
|
1073
1059
|
});
|
|
1074
1060
|
}
|
|
1075
1061
|
}
|
|
@@ -1101,10 +1087,10 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1101
1087
|
};
|
|
1102
1088
|
const response = [];
|
|
1103
1089
|
if (purposes.includes("payment" /* Payment */)) {
|
|
1104
|
-
response.push(paymentAddress);
|
|
1090
|
+
response.push({ ...paymentAddress, walletType: "software" });
|
|
1105
1091
|
}
|
|
1106
1092
|
if (purposes.includes("ordinals" /* Ordinals */)) {
|
|
1107
|
-
response.push(ordinalsAddress);
|
|
1093
|
+
response.push({ ...ordinalsAddress, walletType: "software" });
|
|
1108
1094
|
}
|
|
1109
1095
|
return response;
|
|
1110
1096
|
}
|
|
@@ -1117,14 +1103,16 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1117
1103
|
return {
|
|
1118
1104
|
address,
|
|
1119
1105
|
messageHash: "",
|
|
1120
|
-
signature: response2
|
|
1106
|
+
signature: response2,
|
|
1107
|
+
protocol: "BIP322" /* BIP322 */
|
|
1121
1108
|
};
|
|
1122
1109
|
}
|
|
1123
1110
|
const response = await window.unisat.signMessage(message, "ecdsa");
|
|
1124
1111
|
return {
|
|
1125
1112
|
address,
|
|
1126
1113
|
messageHash: "",
|
|
1127
|
-
signature: response
|
|
1114
|
+
signature: response,
|
|
1115
|
+
protocol: "ECDSA" /* ECDSA */
|
|
1128
1116
|
};
|
|
1129
1117
|
}
|
|
1130
1118
|
async sendTransfer(params) {
|
|
@@ -1138,11 +1126,11 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1138
1126
|
};
|
|
1139
1127
|
}
|
|
1140
1128
|
async signPsbt(params) {
|
|
1141
|
-
const { psbt, signInputs,
|
|
1129
|
+
const { psbt, signInputs, broadcast } = params;
|
|
1142
1130
|
const psbtHex = Buffer.from(psbt, "base64").toString("hex");
|
|
1143
1131
|
const signedPsbt = await window.unisat.signPsbt(psbtHex, {
|
|
1144
1132
|
autoFinalized: broadcast,
|
|
1145
|
-
toSignInputs: convertSignInputsToInputType(signInputs
|
|
1133
|
+
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
1146
1134
|
});
|
|
1147
1135
|
if (broadcast) {
|
|
1148
1136
|
const txid = await window.unisat.pushPsbt(psbtHex);
|
|
@@ -1212,6 +1200,33 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1212
1200
|
};
|
|
1213
1201
|
}
|
|
1214
1202
|
};
|
|
1203
|
+
addListener = (eventName, cb) => {
|
|
1204
|
+
switch (eventName) {
|
|
1205
|
+
case "accountChange": {
|
|
1206
|
+
const handler = () => {
|
|
1207
|
+
cb({ type: "accountChange" });
|
|
1208
|
+
};
|
|
1209
|
+
window.unisat.on("accountsChanged", handler);
|
|
1210
|
+
return () => {
|
|
1211
|
+
window.unisat.removeListener("accountsChanged", handler);
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
case "networkChange": {
|
|
1215
|
+
const handler = () => {
|
|
1216
|
+
cb({ type: "networkChange" });
|
|
1217
|
+
};
|
|
1218
|
+
window.unisat.on("networkChanged", handler);
|
|
1219
|
+
return () => {
|
|
1220
|
+
window.unisat.removeListener("networkChanged", handler);
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
default: {
|
|
1224
|
+
console.error("Event not supported by the selected wallet");
|
|
1225
|
+
return () => {
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1215
1230
|
};
|
|
1216
1231
|
|
|
1217
1232
|
// src/adapters/BaseAdapter.ts
|
|
@@ -1504,10 +1519,6 @@ export {
|
|
|
1504
1519
|
getInscriptionsParamsSchema,
|
|
1505
1520
|
getInscriptionsResultSchema,
|
|
1506
1521
|
getInscriptionsSchema,
|
|
1507
|
-
getPermissionsMethodName,
|
|
1508
|
-
getPermissionsParamsSchema,
|
|
1509
|
-
getPermissionsRequestMessageSchema,
|
|
1510
|
-
getPermissionsResultSchema,
|
|
1511
1522
|
getProviderById,
|
|
1512
1523
|
getProviderOrThrow,
|
|
1513
1524
|
getProviders,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.3.0-
|
|
3
|
+
"version": "0.3.0-f1e4d08",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "jest",
|
|
12
|
-
"build-debug": "webpack --mode development",
|
|
12
|
+
"build-debug": "npm run clean && webpack --mode development",
|
|
13
13
|
"build": "npm run clean && tsup src/index.ts --format esm --dts",
|
|
14
14
|
"build:watch": "npm run clean && tsup src/index.ts --format esm --dts --watch",
|
|
15
15
|
"clean": "rimraf dist",
|
|
@@ -29,12 +29,10 @@
|
|
|
29
29
|
"bitcoin-address-validation": "2.2.3",
|
|
30
30
|
"buffer": "6.0.3",
|
|
31
31
|
"jsontokens": "4.0.1",
|
|
32
|
-
"lodash.omit": "4.5.0",
|
|
33
32
|
"valibot": "0.33.2"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@types/jest": "^29.2.6",
|
|
37
|
-
"@types/lodash.omit": "4.5.9",
|
|
38
36
|
"husky": "^8.0.3",
|
|
39
37
|
"lint-staged": "^13.2.3",
|
|
40
38
|
"prettier": "3.3.3",
|