@sats-connect/core 0.8.1-f2a77fa → 0.8.1-fb4ce52
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 +3 -148
- package/dist/index.d.ts +3 -148
- package/dist/index.js +195 -277
- package/dist/index.mjs +195 -267
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -172,16 +172,6 @@ __export(index_exports, {
|
|
|
172
172
|
signPsbtRequestMessageSchema: () => signPsbtRequestMessageSchema,
|
|
173
173
|
signPsbtResultSchema: () => signPsbtResultSchema,
|
|
174
174
|
signTransaction: () => signTransaction,
|
|
175
|
-
sparkFlashnetGetJwtMethodName: () => sparkFlashnetGetJwtMethodName,
|
|
176
|
-
sparkFlashnetGetJwtParamsSchema: () => sparkFlashnetGetJwtParamsSchema,
|
|
177
|
-
sparkFlashnetGetJwtRequestMessageSchema: () => sparkFlashnetGetJwtRequestMessageSchema,
|
|
178
|
-
sparkFlashnetGetJwtResultSchema: () => sparkFlashnetGetJwtResultSchema,
|
|
179
|
-
sparkFlashnetRouteSwapIntentSchema: () => sparkFlashnetRouteSwapIntentSchema,
|
|
180
|
-
sparkFlashnetSignIntentMethodName: () => sparkFlashnetSignIntentMethodName,
|
|
181
|
-
sparkFlashnetSignIntentParamsSchema: () => sparkFlashnetSignIntentParamsSchema,
|
|
182
|
-
sparkFlashnetSignIntentRequestMessageSchema: () => sparkFlashnetSignIntentRequestMessageSchema,
|
|
183
|
-
sparkFlashnetSignIntentResultSchema: () => sparkFlashnetSignIntentResultSchema,
|
|
184
|
-
sparkFlashnetSwapIntentSchema: () => sparkFlashnetSwapIntentSchema,
|
|
185
175
|
sparkGetAddressesMethodName: () => sparkGetAddressesMethodName,
|
|
186
176
|
sparkGetAddressesParamsSchema: () => sparkGetAddressesParamsSchema,
|
|
187
177
|
sparkGetAddressesRequestMessageSchema: () => sparkGetAddressesRequestMessageSchema,
|
|
@@ -242,6 +232,9 @@ __export(index_exports, {
|
|
|
242
232
|
});
|
|
243
233
|
module.exports = __toCommonJS(index_exports);
|
|
244
234
|
|
|
235
|
+
// src/request/index.ts
|
|
236
|
+
var v25 = __toESM(require("valibot"));
|
|
237
|
+
|
|
245
238
|
// src/provider/types.ts
|
|
246
239
|
var v4 = __toESM(require("valibot"));
|
|
247
240
|
|
|
@@ -435,8 +428,22 @@ function getSupportedWallets() {
|
|
|
435
428
|
return wallets;
|
|
436
429
|
}
|
|
437
430
|
|
|
438
|
-
// src/request/
|
|
439
|
-
var
|
|
431
|
+
// src/request/sanitizeRequest.ts
|
|
432
|
+
var sanitizeRequest = (method, params, providerVersion) => {
|
|
433
|
+
if (method === "wallet_connect" && providerVersion < 1) {
|
|
434
|
+
const typedParams = params;
|
|
435
|
+
if (!typedParams) {
|
|
436
|
+
return { method, params };
|
|
437
|
+
}
|
|
438
|
+
const { addresses, ...rest } = typedParams;
|
|
439
|
+
const sanitizedAddresses = addresses?.filter(
|
|
440
|
+
(addr) => addr !== "spark" /* Spark */ && addr !== "starknet" /* Starknet */
|
|
441
|
+
);
|
|
442
|
+
const overrideParams = { ...rest, addresses: sanitizedAddresses };
|
|
443
|
+
return { method, params: overrideParams };
|
|
444
|
+
}
|
|
445
|
+
return { method, params };
|
|
446
|
+
};
|
|
440
447
|
|
|
441
448
|
// src/request/types/btcMethods.ts
|
|
442
449
|
var v6 = __toESM(require("valibot"));
|
|
@@ -1049,10 +1056,10 @@ var runesTransferRequestMessageSchema = v11.object({
|
|
|
1049
1056
|
}).entries
|
|
1050
1057
|
});
|
|
1051
1058
|
|
|
1052
|
-
// src/request/types/sparkMethods/
|
|
1059
|
+
// src/request/types/sparkMethods/getAddresses.ts
|
|
1053
1060
|
var v12 = __toESM(require("valibot"));
|
|
1054
|
-
var
|
|
1055
|
-
var
|
|
1061
|
+
var sparkGetAddressesMethodName = "spark_getAddresses";
|
|
1062
|
+
var sparkGetAddressesParamsSchema = v12.nullish(
|
|
1056
1063
|
v12.object({
|
|
1057
1064
|
/**
|
|
1058
1065
|
* A message to be displayed to the user in the request prompt.
|
|
@@ -1060,224 +1067,135 @@ var sparkFlashnetGetJwtParamsSchema = v12.nullish(
|
|
|
1060
1067
|
message: v12.optional(v12.string())
|
|
1061
1068
|
})
|
|
1062
1069
|
);
|
|
1063
|
-
var
|
|
1064
|
-
/**
|
|
1065
|
-
* The JWT token for authenticated requests to the Flashnet API.
|
|
1066
|
-
*/
|
|
1067
|
-
jwt: v12.string()
|
|
1068
|
-
});
|
|
1069
|
-
var sparkFlashnetGetJwtRequestMessageSchema = v12.object({
|
|
1070
|
-
...rpcRequestMessageSchema.entries,
|
|
1071
|
-
...v12.object({
|
|
1072
|
-
method: v12.literal(sparkFlashnetGetJwtMethodName),
|
|
1073
|
-
params: sparkFlashnetGetJwtParamsSchema,
|
|
1074
|
-
id: v12.string()
|
|
1075
|
-
}).entries
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/routeSwap.ts
|
|
1079
|
-
var v13 = __toESM(require("valibot"));
|
|
1080
|
-
var sparkFlashnetRouteSwapIntentSchema = v13.object({
|
|
1081
|
-
type: v13.literal("executeRouteSwap"),
|
|
1082
|
-
data: v13.object({
|
|
1083
|
-
userPublicKey: v13.string(),
|
|
1084
|
-
initialSparkTransferId: v13.string(),
|
|
1085
|
-
hops: v13.array(
|
|
1086
|
-
v13.object({
|
|
1087
|
-
poolId: v13.string(),
|
|
1088
|
-
assetInAddress: v13.string(),
|
|
1089
|
-
assetOutAddress: v13.string(),
|
|
1090
|
-
hopIntegratorFeeRateBps: v13.optional(v13.number())
|
|
1091
|
-
})
|
|
1092
|
-
),
|
|
1093
|
-
inputAmount: v13.string(),
|
|
1094
|
-
maxRouteSlippageBps: v13.number(),
|
|
1095
|
-
minAmountOut: v13.string(),
|
|
1096
|
-
defaultIntegratorFeeRateBps: v13.optional(v13.number()),
|
|
1097
|
-
nonce: v13.string()
|
|
1098
|
-
})
|
|
1099
|
-
});
|
|
1100
|
-
|
|
1101
|
-
// src/request/types/sparkMethods/flashnetMethods/intents/swap.ts
|
|
1102
|
-
var v14 = __toESM(require("valibot"));
|
|
1103
|
-
var sparkFlashnetSwapIntentSchema = v14.object({
|
|
1104
|
-
type: v14.literal("executeSwap"),
|
|
1105
|
-
data: v14.object({
|
|
1106
|
-
userPublicKey: v14.string(),
|
|
1107
|
-
poolId: v14.string(),
|
|
1108
|
-
transferId: v14.string(),
|
|
1109
|
-
assetInAddress: v14.string(),
|
|
1110
|
-
assetOutAddress: v14.string(),
|
|
1111
|
-
amountIn: v14.string(),
|
|
1112
|
-
maxSlippageBps: v14.number(),
|
|
1113
|
-
minAmountOut: v14.string(),
|
|
1114
|
-
totalIntegratorFeeRateBps: v14.optional(v14.number()),
|
|
1115
|
-
nonce: v14.string()
|
|
1116
|
-
})
|
|
1117
|
-
});
|
|
1118
|
-
|
|
1119
|
-
// src/request/types/sparkMethods/flashnetMethods/signIntent.ts
|
|
1120
|
-
var v15 = __toESM(require("valibot"));
|
|
1121
|
-
var sparkFlashnetSignIntentMethodName = "spark_flashnet_signIntent";
|
|
1122
|
-
var sparkFlashnetSignIntentParamsSchema = v15.union([
|
|
1123
|
-
sparkFlashnetSwapIntentSchema,
|
|
1124
|
-
sparkFlashnetRouteSwapIntentSchema
|
|
1125
|
-
]);
|
|
1126
|
-
var sparkFlashnetSignIntentResultSchema = v15.object({
|
|
1127
|
-
/**
|
|
1128
|
-
* The signed intent as a hex string.
|
|
1129
|
-
*/
|
|
1130
|
-
signature: v15.string()
|
|
1131
|
-
});
|
|
1132
|
-
var sparkFlashnetSignIntentRequestMessageSchema = v15.object({
|
|
1133
|
-
...rpcRequestMessageSchema.entries,
|
|
1134
|
-
...v15.object({
|
|
1135
|
-
method: v15.literal(sparkFlashnetSignIntentMethodName),
|
|
1136
|
-
params: sparkFlashnetSignIntentParamsSchema,
|
|
1137
|
-
id: v15.string()
|
|
1138
|
-
}).entries
|
|
1139
|
-
});
|
|
1140
|
-
|
|
1141
|
-
// src/request/types/sparkMethods/getAddresses.ts
|
|
1142
|
-
var v16 = __toESM(require("valibot"));
|
|
1143
|
-
var sparkGetAddressesMethodName = "spark_getAddresses";
|
|
1144
|
-
var sparkGetAddressesParamsSchema = v16.nullish(
|
|
1145
|
-
v16.object({
|
|
1146
|
-
/**
|
|
1147
|
-
* A message to be displayed to the user in the request prompt.
|
|
1148
|
-
*/
|
|
1149
|
-
message: v16.optional(v16.string())
|
|
1150
|
-
})
|
|
1151
|
-
);
|
|
1152
|
-
var sparkGetAddressesResultSchema = v16.object({
|
|
1070
|
+
var sparkGetAddressesResultSchema = v12.object({
|
|
1153
1071
|
/**
|
|
1154
1072
|
* The addresses generated for the given purposes.
|
|
1155
1073
|
*/
|
|
1156
|
-
addresses:
|
|
1074
|
+
addresses: v12.array(addressSchema),
|
|
1157
1075
|
network: getNetworkResultSchema
|
|
1158
1076
|
});
|
|
1159
|
-
var sparkGetAddressesRequestMessageSchema =
|
|
1077
|
+
var sparkGetAddressesRequestMessageSchema = v12.object({
|
|
1160
1078
|
...rpcRequestMessageSchema.entries,
|
|
1161
|
-
...
|
|
1162
|
-
method:
|
|
1079
|
+
...v12.object({
|
|
1080
|
+
method: v12.literal(sparkGetAddressesMethodName),
|
|
1163
1081
|
params: sparkGetAddressesParamsSchema,
|
|
1164
|
-
id:
|
|
1082
|
+
id: v12.string()
|
|
1165
1083
|
}).entries
|
|
1166
1084
|
});
|
|
1167
1085
|
|
|
1168
1086
|
// src/request/types/sparkMethods/getBalance.ts
|
|
1169
|
-
var
|
|
1087
|
+
var v13 = __toESM(require("valibot"));
|
|
1170
1088
|
var sparkGetBalanceMethodName = "spark_getBalance";
|
|
1171
|
-
var sparkGetBalanceParamsSchema =
|
|
1172
|
-
var sparkGetBalanceResultSchema =
|
|
1089
|
+
var sparkGetBalanceParamsSchema = v13.nullish(v13.null());
|
|
1090
|
+
var sparkGetBalanceResultSchema = v13.object({
|
|
1173
1091
|
/**
|
|
1174
1092
|
* The Spark Bitcoin address balance in sats in string form.
|
|
1175
1093
|
*/
|
|
1176
|
-
balance:
|
|
1177
|
-
tokenBalances:
|
|
1178
|
-
|
|
1094
|
+
balance: v13.string(),
|
|
1095
|
+
tokenBalances: v13.array(
|
|
1096
|
+
v13.object({
|
|
1179
1097
|
/* The address balance of the token in string form as it can overflow a js number */
|
|
1180
|
-
balance:
|
|
1181
|
-
tokenMetadata:
|
|
1182
|
-
tokenIdentifier:
|
|
1183
|
-
tokenName:
|
|
1184
|
-
tokenTicker:
|
|
1185
|
-
decimals:
|
|
1186
|
-
maxSupply:
|
|
1098
|
+
balance: v13.string(),
|
|
1099
|
+
tokenMetadata: v13.object({
|
|
1100
|
+
tokenIdentifier: v13.string(),
|
|
1101
|
+
tokenName: v13.string(),
|
|
1102
|
+
tokenTicker: v13.string(),
|
|
1103
|
+
decimals: v13.number(),
|
|
1104
|
+
maxSupply: v13.string()
|
|
1187
1105
|
})
|
|
1188
1106
|
})
|
|
1189
1107
|
)
|
|
1190
1108
|
});
|
|
1191
|
-
var sparkGetBalanceRequestMessageSchema =
|
|
1109
|
+
var sparkGetBalanceRequestMessageSchema = v13.object({
|
|
1192
1110
|
...rpcRequestMessageSchema.entries,
|
|
1193
|
-
...
|
|
1194
|
-
method:
|
|
1111
|
+
...v13.object({
|
|
1112
|
+
method: v13.literal(sparkGetBalanceMethodName),
|
|
1195
1113
|
params: sparkGetBalanceParamsSchema,
|
|
1196
|
-
id:
|
|
1114
|
+
id: v13.string()
|
|
1197
1115
|
}).entries
|
|
1198
1116
|
});
|
|
1199
1117
|
|
|
1200
1118
|
// src/request/types/sparkMethods/transfer.ts
|
|
1201
|
-
var
|
|
1119
|
+
var v14 = __toESM(require("valibot"));
|
|
1202
1120
|
var sparkTransferMethodName = "spark_transfer";
|
|
1203
|
-
var sparkTransferParamsSchema =
|
|
1121
|
+
var sparkTransferParamsSchema = v14.object({
|
|
1204
1122
|
/**
|
|
1205
1123
|
* Amount of SATS to transfer as a string or number.
|
|
1206
1124
|
*/
|
|
1207
|
-
amountSats:
|
|
1125
|
+
amountSats: v14.union([v14.number(), v14.string()]),
|
|
1208
1126
|
/**
|
|
1209
1127
|
* The recipient's spark address.
|
|
1210
1128
|
*/
|
|
1211
|
-
receiverSparkAddress:
|
|
1129
|
+
receiverSparkAddress: v14.string()
|
|
1212
1130
|
});
|
|
1213
|
-
var sparkTransferResultSchema =
|
|
1131
|
+
var sparkTransferResultSchema = v14.object({
|
|
1214
1132
|
/**
|
|
1215
1133
|
* The ID of the transaction.
|
|
1216
1134
|
*/
|
|
1217
|
-
id:
|
|
1135
|
+
id: v14.string()
|
|
1218
1136
|
});
|
|
1219
|
-
var sparkTransferRequestMessageSchema =
|
|
1137
|
+
var sparkTransferRequestMessageSchema = v14.object({
|
|
1220
1138
|
...rpcRequestMessageSchema.entries,
|
|
1221
|
-
...
|
|
1222
|
-
method:
|
|
1139
|
+
...v14.object({
|
|
1140
|
+
method: v14.literal(sparkTransferMethodName),
|
|
1223
1141
|
params: sparkTransferParamsSchema,
|
|
1224
|
-
id:
|
|
1142
|
+
id: v14.string()
|
|
1225
1143
|
}).entries
|
|
1226
1144
|
});
|
|
1227
1145
|
|
|
1228
1146
|
// src/request/types/sparkMethods/transferToken.ts
|
|
1229
|
-
var
|
|
1147
|
+
var v15 = __toESM(require("valibot"));
|
|
1230
1148
|
var sparkTransferTokenMethodName = "spark_transferToken";
|
|
1231
|
-
var sparkTransferTokenParamsSchema =
|
|
1149
|
+
var sparkTransferTokenParamsSchema = v15.object({
|
|
1232
1150
|
/**
|
|
1233
1151
|
* Amount of units of the token to transfer as a string or number.
|
|
1234
1152
|
*/
|
|
1235
|
-
tokenAmount:
|
|
1153
|
+
tokenAmount: v15.union([v15.number(), v15.string()]),
|
|
1236
1154
|
/**
|
|
1237
1155
|
* The Bech32m token identifier.
|
|
1238
1156
|
*/
|
|
1239
|
-
tokenIdentifier:
|
|
1157
|
+
tokenIdentifier: v15.string(),
|
|
1240
1158
|
/**
|
|
1241
1159
|
* The recipient's spark address.
|
|
1242
1160
|
*/
|
|
1243
|
-
receiverSparkAddress:
|
|
1161
|
+
receiverSparkAddress: v15.string()
|
|
1244
1162
|
});
|
|
1245
|
-
var sparkTransferTokenResultSchema =
|
|
1163
|
+
var sparkTransferTokenResultSchema = v15.object({
|
|
1246
1164
|
/**
|
|
1247
1165
|
* The ID of the transaction.
|
|
1248
1166
|
*/
|
|
1249
|
-
id:
|
|
1167
|
+
id: v15.string()
|
|
1250
1168
|
});
|
|
1251
|
-
var sparkTransferTokenRequestMessageSchema =
|
|
1169
|
+
var sparkTransferTokenRequestMessageSchema = v15.object({
|
|
1252
1170
|
...rpcRequestMessageSchema.entries,
|
|
1253
|
-
...
|
|
1254
|
-
method:
|
|
1171
|
+
...v15.object({
|
|
1172
|
+
method: v15.literal(sparkTransferTokenMethodName),
|
|
1255
1173
|
params: sparkTransferTokenParamsSchema,
|
|
1256
|
-
id:
|
|
1174
|
+
id: v15.string()
|
|
1257
1175
|
}).entries
|
|
1258
1176
|
});
|
|
1259
1177
|
|
|
1260
1178
|
// src/request/types/stxMethods/callContract.ts
|
|
1261
|
-
var
|
|
1179
|
+
var v16 = __toESM(require("valibot"));
|
|
1262
1180
|
var stxCallContractMethodName = "stx_callContract";
|
|
1263
|
-
var stxCallContractParamsSchema =
|
|
1181
|
+
var stxCallContractParamsSchema = v16.object({
|
|
1264
1182
|
/**
|
|
1265
1183
|
* The contract principal.
|
|
1266
1184
|
*
|
|
1267
1185
|
* E.g. `"SPKE...GD5C.my-contract"`
|
|
1268
1186
|
*/
|
|
1269
|
-
contract:
|
|
1187
|
+
contract: v16.string(),
|
|
1270
1188
|
/**
|
|
1271
1189
|
* The name of the function to call.
|
|
1272
1190
|
*
|
|
1273
1191
|
* Note: spec changes ongoing,
|
|
1274
1192
|
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
1275
1193
|
*/
|
|
1276
|
-
functionName:
|
|
1194
|
+
functionName: v16.string(),
|
|
1277
1195
|
/**
|
|
1278
1196
|
* @deprecated in favor of `functionArgs` for @stacks/connect compatibility
|
|
1279
1197
|
*/
|
|
1280
|
-
arguments:
|
|
1198
|
+
arguments: v16.optional(v16.array(v16.string())),
|
|
1281
1199
|
/**
|
|
1282
1200
|
* The function's arguments. The arguments are expected to be hex-encoded
|
|
1283
1201
|
* strings of Clarity values.
|
|
@@ -1292,274 +1210,274 @@ var stxCallContractParamsSchema = v20.object({
|
|
|
1292
1210
|
* const hexArgs = functionArgs.map(cvToHex);
|
|
1293
1211
|
* ```
|
|
1294
1212
|
*/
|
|
1295
|
-
functionArgs:
|
|
1213
|
+
functionArgs: v16.optional(v16.array(v16.string())),
|
|
1296
1214
|
/**
|
|
1297
1215
|
* The post conditions to apply to the contract call.
|
|
1298
1216
|
*/
|
|
1299
|
-
postConditions:
|
|
1217
|
+
postConditions: v16.optional(v16.array(v16.string())),
|
|
1300
1218
|
/**
|
|
1301
1219
|
* The mode to apply to the post conditions.
|
|
1302
1220
|
*/
|
|
1303
|
-
postConditionMode:
|
|
1221
|
+
postConditionMode: v16.optional(v16.union([v16.literal("allow"), v16.literal("deny")]))
|
|
1304
1222
|
});
|
|
1305
|
-
var stxCallContractResultSchema =
|
|
1223
|
+
var stxCallContractResultSchema = v16.object({
|
|
1306
1224
|
/**
|
|
1307
1225
|
* The ID of the transaction.
|
|
1308
1226
|
*/
|
|
1309
|
-
txid:
|
|
1227
|
+
txid: v16.string(),
|
|
1310
1228
|
/**
|
|
1311
1229
|
* A Stacks transaction as a hex-encoded string.
|
|
1312
1230
|
*/
|
|
1313
|
-
transaction:
|
|
1231
|
+
transaction: v16.string()
|
|
1314
1232
|
});
|
|
1315
|
-
var stxCallContractRequestMessageSchema =
|
|
1233
|
+
var stxCallContractRequestMessageSchema = v16.object({
|
|
1316
1234
|
...rpcRequestMessageSchema.entries,
|
|
1317
|
-
...
|
|
1318
|
-
method:
|
|
1235
|
+
...v16.object({
|
|
1236
|
+
method: v16.literal(stxCallContractMethodName),
|
|
1319
1237
|
params: stxCallContractParamsSchema,
|
|
1320
|
-
id:
|
|
1238
|
+
id: v16.string()
|
|
1321
1239
|
}).entries
|
|
1322
1240
|
});
|
|
1323
1241
|
|
|
1324
1242
|
// src/request/types/stxMethods/deployContract.ts
|
|
1325
|
-
var
|
|
1243
|
+
var v17 = __toESM(require("valibot"));
|
|
1326
1244
|
var stxDeployContractMethodName = "stx_deployContract";
|
|
1327
|
-
var stxDeployContractParamsSchema =
|
|
1245
|
+
var stxDeployContractParamsSchema = v17.object({
|
|
1328
1246
|
/**
|
|
1329
1247
|
* Name of the contract.
|
|
1330
1248
|
*/
|
|
1331
|
-
name:
|
|
1249
|
+
name: v17.string(),
|
|
1332
1250
|
/**
|
|
1333
1251
|
* The source code of the Clarity contract.
|
|
1334
1252
|
*/
|
|
1335
|
-
clarityCode:
|
|
1253
|
+
clarityCode: v17.string(),
|
|
1336
1254
|
/**
|
|
1337
1255
|
* The version of the Clarity contract.
|
|
1338
1256
|
*/
|
|
1339
|
-
clarityVersion:
|
|
1257
|
+
clarityVersion: v17.optional(v17.number()),
|
|
1340
1258
|
/**
|
|
1341
1259
|
* The post conditions to apply to the contract call.
|
|
1342
1260
|
*/
|
|
1343
|
-
postConditions:
|
|
1261
|
+
postConditions: v17.optional(v17.array(v17.string())),
|
|
1344
1262
|
/**
|
|
1345
1263
|
* The mode to apply to the post conditions.
|
|
1346
1264
|
*/
|
|
1347
|
-
postConditionMode:
|
|
1265
|
+
postConditionMode: v17.optional(v17.union([v17.literal("allow"), v17.literal("deny")]))
|
|
1348
1266
|
});
|
|
1349
|
-
var stxDeployContractResultSchema =
|
|
1267
|
+
var stxDeployContractResultSchema = v17.object({
|
|
1350
1268
|
/**
|
|
1351
1269
|
* The ID of the transaction.
|
|
1352
1270
|
*/
|
|
1353
|
-
txid:
|
|
1271
|
+
txid: v17.string(),
|
|
1354
1272
|
/**
|
|
1355
1273
|
* A Stacks transaction as a hex-encoded string.
|
|
1356
1274
|
*/
|
|
1357
|
-
transaction:
|
|
1275
|
+
transaction: v17.string()
|
|
1358
1276
|
});
|
|
1359
|
-
var stxDeployContractRequestMessageSchema =
|
|
1277
|
+
var stxDeployContractRequestMessageSchema = v17.object({
|
|
1360
1278
|
...rpcRequestMessageSchema.entries,
|
|
1361
|
-
...
|
|
1362
|
-
method:
|
|
1279
|
+
...v17.object({
|
|
1280
|
+
method: v17.literal(stxDeployContractMethodName),
|
|
1363
1281
|
params: stxDeployContractParamsSchema,
|
|
1364
|
-
id:
|
|
1282
|
+
id: v17.string()
|
|
1365
1283
|
}).entries
|
|
1366
1284
|
});
|
|
1367
1285
|
|
|
1368
1286
|
// src/request/types/stxMethods/getAccounts.ts
|
|
1369
|
-
var
|
|
1287
|
+
var v18 = __toESM(require("valibot"));
|
|
1370
1288
|
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
1371
|
-
var stxGetAccountsParamsSchema =
|
|
1372
|
-
var stxGetAccountsResultSchema =
|
|
1289
|
+
var stxGetAccountsParamsSchema = v18.nullish(v18.null());
|
|
1290
|
+
var stxGetAccountsResultSchema = v18.object({
|
|
1373
1291
|
/**
|
|
1374
1292
|
* The addresses generated for the given purposes.
|
|
1375
1293
|
*/
|
|
1376
|
-
addresses:
|
|
1377
|
-
|
|
1378
|
-
address:
|
|
1379
|
-
publicKey:
|
|
1380
|
-
gaiaHubUrl:
|
|
1381
|
-
gaiaAppKey:
|
|
1294
|
+
addresses: v18.array(
|
|
1295
|
+
v18.object({
|
|
1296
|
+
address: v18.string(),
|
|
1297
|
+
publicKey: v18.string(),
|
|
1298
|
+
gaiaHubUrl: v18.string(),
|
|
1299
|
+
gaiaAppKey: v18.string()
|
|
1382
1300
|
})
|
|
1383
1301
|
),
|
|
1384
1302
|
network: getNetworkResultSchema
|
|
1385
1303
|
});
|
|
1386
|
-
var stxGetAccountsRequestMessageSchema =
|
|
1304
|
+
var stxGetAccountsRequestMessageSchema = v18.object({
|
|
1387
1305
|
...rpcRequestMessageSchema.entries,
|
|
1388
|
-
...
|
|
1389
|
-
method:
|
|
1306
|
+
...v18.object({
|
|
1307
|
+
method: v18.literal(stxGetAccountsMethodName),
|
|
1390
1308
|
params: stxGetAccountsParamsSchema,
|
|
1391
|
-
id:
|
|
1309
|
+
id: v18.string()
|
|
1392
1310
|
}).entries
|
|
1393
1311
|
});
|
|
1394
1312
|
|
|
1395
1313
|
// src/request/types/stxMethods/getAddresses.ts
|
|
1396
|
-
var
|
|
1314
|
+
var v19 = __toESM(require("valibot"));
|
|
1397
1315
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
1398
|
-
var stxGetAddressesParamsSchema =
|
|
1399
|
-
|
|
1316
|
+
var stxGetAddressesParamsSchema = v19.nullish(
|
|
1317
|
+
v19.object({
|
|
1400
1318
|
/**
|
|
1401
1319
|
* A message to be displayed to the user in the request prompt.
|
|
1402
1320
|
*/
|
|
1403
|
-
message:
|
|
1321
|
+
message: v19.optional(v19.string())
|
|
1404
1322
|
})
|
|
1405
1323
|
);
|
|
1406
|
-
var stxGetAddressesResultSchema =
|
|
1324
|
+
var stxGetAddressesResultSchema = v19.object({
|
|
1407
1325
|
/**
|
|
1408
1326
|
* The addresses generated for the given purposes.
|
|
1409
1327
|
*/
|
|
1410
|
-
addresses:
|
|
1328
|
+
addresses: v19.array(addressSchema),
|
|
1411
1329
|
network: getNetworkResultSchema
|
|
1412
1330
|
});
|
|
1413
|
-
var stxGetAddressesRequestMessageSchema =
|
|
1331
|
+
var stxGetAddressesRequestMessageSchema = v19.object({
|
|
1414
1332
|
...rpcRequestMessageSchema.entries,
|
|
1415
|
-
...
|
|
1416
|
-
method:
|
|
1333
|
+
...v19.object({
|
|
1334
|
+
method: v19.literal(stxGetAddressesMethodName),
|
|
1417
1335
|
params: stxGetAddressesParamsSchema,
|
|
1418
|
-
id:
|
|
1336
|
+
id: v19.string()
|
|
1419
1337
|
}).entries
|
|
1420
1338
|
});
|
|
1421
1339
|
|
|
1422
1340
|
// src/request/types/stxMethods/signMessage.ts
|
|
1423
|
-
var
|
|
1341
|
+
var v20 = __toESM(require("valibot"));
|
|
1424
1342
|
var stxSignMessageMethodName = "stx_signMessage";
|
|
1425
|
-
var stxSignMessageParamsSchema =
|
|
1343
|
+
var stxSignMessageParamsSchema = v20.object({
|
|
1426
1344
|
/**
|
|
1427
1345
|
* The message to sign.
|
|
1428
1346
|
*/
|
|
1429
|
-
message:
|
|
1347
|
+
message: v20.string()
|
|
1430
1348
|
});
|
|
1431
|
-
var stxSignMessageResultSchema =
|
|
1349
|
+
var stxSignMessageResultSchema = v20.object({
|
|
1432
1350
|
/**
|
|
1433
1351
|
* The signature of the message.
|
|
1434
1352
|
*/
|
|
1435
|
-
signature:
|
|
1353
|
+
signature: v20.string(),
|
|
1436
1354
|
/**
|
|
1437
1355
|
* The public key used to sign the message.
|
|
1438
1356
|
*/
|
|
1439
|
-
publicKey:
|
|
1357
|
+
publicKey: v20.string()
|
|
1440
1358
|
});
|
|
1441
|
-
var stxSignMessageRequestMessageSchema =
|
|
1359
|
+
var stxSignMessageRequestMessageSchema = v20.object({
|
|
1442
1360
|
...rpcRequestMessageSchema.entries,
|
|
1443
|
-
...
|
|
1444
|
-
method:
|
|
1361
|
+
...v20.object({
|
|
1362
|
+
method: v20.literal(stxSignMessageMethodName),
|
|
1445
1363
|
params: stxSignMessageParamsSchema,
|
|
1446
|
-
id:
|
|
1364
|
+
id: v20.string()
|
|
1447
1365
|
}).entries
|
|
1448
1366
|
});
|
|
1449
1367
|
|
|
1450
1368
|
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
1451
|
-
var
|
|
1369
|
+
var v21 = __toESM(require("valibot"));
|
|
1452
1370
|
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
1453
|
-
var stxSignStructuredMessageParamsSchema =
|
|
1371
|
+
var stxSignStructuredMessageParamsSchema = v21.object({
|
|
1454
1372
|
/**
|
|
1455
1373
|
* The domain to be signed.
|
|
1456
1374
|
*/
|
|
1457
|
-
domain:
|
|
1375
|
+
domain: v21.string(),
|
|
1458
1376
|
/**
|
|
1459
1377
|
* Message payload to be signed.
|
|
1460
1378
|
*/
|
|
1461
|
-
message:
|
|
1379
|
+
message: v21.string(),
|
|
1462
1380
|
/**
|
|
1463
1381
|
* The public key to sign the message with.
|
|
1464
1382
|
*/
|
|
1465
|
-
publicKey:
|
|
1383
|
+
publicKey: v21.optional(v21.string())
|
|
1466
1384
|
});
|
|
1467
|
-
var stxSignStructuredMessageResultSchema =
|
|
1385
|
+
var stxSignStructuredMessageResultSchema = v21.object({
|
|
1468
1386
|
/**
|
|
1469
1387
|
* Signature of the message.
|
|
1470
1388
|
*/
|
|
1471
|
-
signature:
|
|
1389
|
+
signature: v21.string(),
|
|
1472
1390
|
/**
|
|
1473
1391
|
* Public key as hex-encoded string.
|
|
1474
1392
|
*/
|
|
1475
|
-
publicKey:
|
|
1393
|
+
publicKey: v21.string()
|
|
1476
1394
|
});
|
|
1477
|
-
var stxSignStructuredMessageRequestMessageSchema =
|
|
1395
|
+
var stxSignStructuredMessageRequestMessageSchema = v21.object({
|
|
1478
1396
|
...rpcRequestMessageSchema.entries,
|
|
1479
|
-
...
|
|
1480
|
-
method:
|
|
1397
|
+
...v21.object({
|
|
1398
|
+
method: v21.literal(stxSignStructuredMessageMethodName),
|
|
1481
1399
|
params: stxSignStructuredMessageParamsSchema,
|
|
1482
|
-
id:
|
|
1400
|
+
id: v21.string()
|
|
1483
1401
|
}).entries
|
|
1484
1402
|
});
|
|
1485
1403
|
|
|
1486
1404
|
// src/request/types/stxMethods/signTransaction.ts
|
|
1487
|
-
var
|
|
1405
|
+
var v22 = __toESM(require("valibot"));
|
|
1488
1406
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
1489
|
-
var stxSignTransactionParamsSchema =
|
|
1407
|
+
var stxSignTransactionParamsSchema = v22.object({
|
|
1490
1408
|
/**
|
|
1491
1409
|
* The transaction to sign as a hex-encoded string.
|
|
1492
1410
|
*/
|
|
1493
|
-
transaction:
|
|
1411
|
+
transaction: v22.string(),
|
|
1494
1412
|
/**
|
|
1495
1413
|
* The public key to sign the transaction with. The wallet may use any key
|
|
1496
1414
|
* when not provided.
|
|
1497
1415
|
*/
|
|
1498
|
-
pubkey:
|
|
1416
|
+
pubkey: v22.optional(v22.string()),
|
|
1499
1417
|
/**
|
|
1500
1418
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
1501
1419
|
*/
|
|
1502
|
-
broadcast:
|
|
1420
|
+
broadcast: v22.optional(v22.boolean())
|
|
1503
1421
|
});
|
|
1504
|
-
var stxSignTransactionResultSchema =
|
|
1422
|
+
var stxSignTransactionResultSchema = v22.object({
|
|
1505
1423
|
/**
|
|
1506
1424
|
* The signed transaction as a hex-encoded string.
|
|
1507
1425
|
*/
|
|
1508
|
-
transaction:
|
|
1426
|
+
transaction: v22.string()
|
|
1509
1427
|
});
|
|
1510
|
-
var stxSignTransactionRequestMessageSchema =
|
|
1428
|
+
var stxSignTransactionRequestMessageSchema = v22.object({
|
|
1511
1429
|
...rpcRequestMessageSchema.entries,
|
|
1512
|
-
...
|
|
1513
|
-
method:
|
|
1430
|
+
...v22.object({
|
|
1431
|
+
method: v22.literal(stxSignTransactionMethodName),
|
|
1514
1432
|
params: stxSignTransactionParamsSchema,
|
|
1515
|
-
id:
|
|
1433
|
+
id: v22.string()
|
|
1516
1434
|
}).entries
|
|
1517
1435
|
});
|
|
1518
1436
|
|
|
1519
1437
|
// src/request/types/stxMethods/signTransactions.ts
|
|
1520
|
-
var
|
|
1438
|
+
var v23 = __toESM(require("valibot"));
|
|
1521
1439
|
var stxSignTransactionsMethodName = "stx_signTransactions";
|
|
1522
|
-
var stxSignTransactionsParamsSchema =
|
|
1440
|
+
var stxSignTransactionsParamsSchema = v23.object({
|
|
1523
1441
|
/**
|
|
1524
1442
|
* The transactions to sign as hex-encoded strings.
|
|
1525
1443
|
*/
|
|
1526
|
-
transactions:
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1444
|
+
transactions: v23.pipe(
|
|
1445
|
+
v23.array(
|
|
1446
|
+
v23.pipe(
|
|
1447
|
+
v23.string(),
|
|
1448
|
+
v23.check((hex) => {
|
|
1531
1449
|
return true;
|
|
1532
1450
|
}, "Invalid hex-encoded Stacks transaction.")
|
|
1533
1451
|
)
|
|
1534
1452
|
),
|
|
1535
|
-
|
|
1453
|
+
v23.minLength(1)
|
|
1536
1454
|
),
|
|
1537
1455
|
/**
|
|
1538
1456
|
* Whether the signed transactions should be broadcast after signing. Defaults
|
|
1539
1457
|
* to `true`.
|
|
1540
1458
|
*/
|
|
1541
|
-
broadcast:
|
|
1459
|
+
broadcast: v23.optional(v23.boolean())
|
|
1542
1460
|
});
|
|
1543
|
-
var stxSignTransactionsResultSchema =
|
|
1461
|
+
var stxSignTransactionsResultSchema = v23.object({
|
|
1544
1462
|
/**
|
|
1545
1463
|
* The signed transactions as hex-encoded strings, in the same order as in the
|
|
1546
1464
|
* sign request.
|
|
1547
1465
|
*/
|
|
1548
|
-
transactions:
|
|
1466
|
+
transactions: v23.array(v23.string())
|
|
1549
1467
|
});
|
|
1550
|
-
var stxSignTransactionsRequestMessageSchema =
|
|
1468
|
+
var stxSignTransactionsRequestMessageSchema = v23.object({
|
|
1551
1469
|
...rpcRequestMessageSchema.entries,
|
|
1552
|
-
...
|
|
1553
|
-
method:
|
|
1470
|
+
...v23.object({
|
|
1471
|
+
method: v23.literal(stxSignTransactionsMethodName),
|
|
1554
1472
|
params: stxSignTransactionsParamsSchema,
|
|
1555
|
-
id:
|
|
1473
|
+
id: v23.string()
|
|
1556
1474
|
}).entries
|
|
1557
1475
|
});
|
|
1558
1476
|
|
|
1559
1477
|
// src/request/types/stxMethods/transferStx.ts
|
|
1560
|
-
var
|
|
1478
|
+
var v24 = __toESM(require("valibot"));
|
|
1561
1479
|
var stxTransferStxMethodName = "stx_transferStx";
|
|
1562
|
-
var stxTransferStxParamsSchema =
|
|
1480
|
+
var stxTransferStxParamsSchema = v24.object({
|
|
1563
1481
|
/**
|
|
1564
1482
|
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
1565
1483
|
* parseable by `BigInt` is acceptable.
|
|
@@ -1572,23 +1490,23 @@ var stxTransferStxParamsSchema = v28.object({
|
|
|
1572
1490
|
* const amount3 = '1234';
|
|
1573
1491
|
* ```
|
|
1574
1492
|
*/
|
|
1575
|
-
amount:
|
|
1493
|
+
amount: v24.union([v24.number(), v24.string()]),
|
|
1576
1494
|
/**
|
|
1577
1495
|
* The recipient's principal.
|
|
1578
1496
|
*/
|
|
1579
|
-
recipient:
|
|
1497
|
+
recipient: v24.string(),
|
|
1580
1498
|
/**
|
|
1581
1499
|
* A string representing the memo.
|
|
1582
1500
|
*/
|
|
1583
|
-
memo:
|
|
1501
|
+
memo: v24.optional(v24.string()),
|
|
1584
1502
|
/**
|
|
1585
1503
|
* Version of parameter format.
|
|
1586
1504
|
*/
|
|
1587
|
-
version:
|
|
1505
|
+
version: v24.optional(v24.string()),
|
|
1588
1506
|
/**
|
|
1589
1507
|
* The mode of the post conditions.
|
|
1590
1508
|
*/
|
|
1591
|
-
postConditionMode:
|
|
1509
|
+
postConditionMode: v24.optional(v24.number()),
|
|
1592
1510
|
/**
|
|
1593
1511
|
* A hex-encoded string representing the post conditions.
|
|
1594
1512
|
*
|
|
@@ -1601,29 +1519,29 @@ var stxTransferStxParamsSchema = v28.object({
|
|
|
1601
1519
|
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
1602
1520
|
* ```
|
|
1603
1521
|
*/
|
|
1604
|
-
postConditions:
|
|
1522
|
+
postConditions: v24.optional(v24.array(v24.string())),
|
|
1605
1523
|
/**
|
|
1606
1524
|
* The public key to sign the transaction with. The wallet may use any key
|
|
1607
1525
|
* when not provided.
|
|
1608
1526
|
*/
|
|
1609
|
-
pubkey:
|
|
1527
|
+
pubkey: v24.optional(v24.string())
|
|
1610
1528
|
});
|
|
1611
|
-
var stxTransferStxResultSchema =
|
|
1529
|
+
var stxTransferStxResultSchema = v24.object({
|
|
1612
1530
|
/**
|
|
1613
1531
|
* The ID of the transaction.
|
|
1614
1532
|
*/
|
|
1615
|
-
txid:
|
|
1533
|
+
txid: v24.string(),
|
|
1616
1534
|
/**
|
|
1617
1535
|
* A Stacks transaction as a hex-encoded string.
|
|
1618
1536
|
*/
|
|
1619
|
-
transaction:
|
|
1537
|
+
transaction: v24.string()
|
|
1620
1538
|
});
|
|
1621
|
-
var stxTransferStxRequestMessageSchema =
|
|
1539
|
+
var stxTransferStxRequestMessageSchema = v24.object({
|
|
1622
1540
|
...rpcRequestMessageSchema.entries,
|
|
1623
|
-
...
|
|
1624
|
-
method:
|
|
1541
|
+
...v24.object({
|
|
1542
|
+
method: v24.literal(stxTransferStxMethodName),
|
|
1625
1543
|
params: stxTransferStxParamsSchema,
|
|
1626
|
-
id:
|
|
1544
|
+
id: v24.string()
|
|
1627
1545
|
}).entries
|
|
1628
1546
|
});
|
|
1629
1547
|
|
|
@@ -1639,14 +1557,23 @@ var request = async (method, params, providerId) => {
|
|
|
1639
1557
|
if (!method) {
|
|
1640
1558
|
throw new Error("A wallet method is required");
|
|
1641
1559
|
}
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1560
|
+
const providerVersion = provider.version ?? 0;
|
|
1561
|
+
const {
|
|
1562
|
+
method: sanitizedMethod,
|
|
1563
|
+
params: sanitizedParams,
|
|
1564
|
+
overrideResponse
|
|
1565
|
+
} = sanitizeRequest(method, params, providerVersion);
|
|
1566
|
+
if (overrideResponse) {
|
|
1567
|
+
return overrideResponse;
|
|
1568
|
+
}
|
|
1569
|
+
const response = await provider.request(sanitizedMethod, sanitizedParams);
|
|
1570
|
+
if (v25.is(rpcErrorResponseMessageSchema, response)) {
|
|
1644
1571
|
return {
|
|
1645
1572
|
status: "error",
|
|
1646
1573
|
error: response.error
|
|
1647
1574
|
};
|
|
1648
1575
|
}
|
|
1649
|
-
if (
|
|
1576
|
+
if (v25.is(rpcSuccessResponseMessageSchema, response)) {
|
|
1650
1577
|
return {
|
|
1651
1578
|
status: "success",
|
|
1652
1579
|
result: response.result
|
|
@@ -2462,6 +2389,7 @@ var extractOrValidateCapabilities = (provider, reportedCapabilities) => {
|
|
|
2462
2389
|
return true;
|
|
2463
2390
|
};
|
|
2464
2391
|
const capabilityMap = {
|
|
2392
|
+
version: validateCapability("version"),
|
|
2465
2393
|
request: validateCapability("request"),
|
|
2466
2394
|
connect: validateCapability("connect"),
|
|
2467
2395
|
signMessage: validateCapability("signMessage"),
|
|
@@ -2801,16 +2729,6 @@ var signMultipleTransactions = async (options) => {
|
|
|
2801
2729
|
signPsbtRequestMessageSchema,
|
|
2802
2730
|
signPsbtResultSchema,
|
|
2803
2731
|
signTransaction,
|
|
2804
|
-
sparkFlashnetGetJwtMethodName,
|
|
2805
|
-
sparkFlashnetGetJwtParamsSchema,
|
|
2806
|
-
sparkFlashnetGetJwtRequestMessageSchema,
|
|
2807
|
-
sparkFlashnetGetJwtResultSchema,
|
|
2808
|
-
sparkFlashnetRouteSwapIntentSchema,
|
|
2809
|
-
sparkFlashnetSignIntentMethodName,
|
|
2810
|
-
sparkFlashnetSignIntentParamsSchema,
|
|
2811
|
-
sparkFlashnetSignIntentRequestMessageSchema,
|
|
2812
|
-
sparkFlashnetSignIntentResultSchema,
|
|
2813
|
-
sparkFlashnetSwapIntentSchema,
|
|
2814
2732
|
sparkGetAddressesMethodName,
|
|
2815
2733
|
sparkGetAddressesParamsSchema,
|
|
2816
2734
|
sparkGetAddressesRequestMessageSchema,
|