@sats-connect/core 0.8.1-91ac91b → 0.8.1-a6a42ae

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.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ // src/request/index.ts
2
+ import * as v25 from "valibot";
3
+
1
4
  // src/provider/types.ts
2
5
  import * as v4 from "valibot";
3
6
 
@@ -191,8 +194,45 @@ function getSupportedWallets() {
191
194
  return wallets;
192
195
  }
193
196
 
194
- // src/request/index.ts
195
- import * as v29 from "valibot";
197
+ // src/request/sanitizeRequest.ts
198
+ var sanitizeRequest = (method, params, providerVersion) => {
199
+ if (providerVersion < 1) {
200
+ const v1Sanitized = sanitizeV1Request(method, params);
201
+ method = v1Sanitized.method;
202
+ params = v1Sanitized.params;
203
+ }
204
+ return { method, params };
205
+ };
206
+ var sanitizeV1Request = (method, params) => {
207
+ const filterPurposes = (purposes) => purposes?.filter(
208
+ (purpose) => purpose !== "spark" /* Spark */ && purpose !== "starknet" /* Starknet */
209
+ );
210
+ if (method === "wallet_connect") {
211
+ const typedParams = params;
212
+ if (!typedParams) {
213
+ return { method, params };
214
+ }
215
+ const { addresses, ...rest } = typedParams;
216
+ const overrideParams = {
217
+ ...rest,
218
+ addresses: filterPurposes(addresses)
219
+ };
220
+ return { method, params: overrideParams };
221
+ }
222
+ if (method === "getAccounts") {
223
+ const typedParams = params;
224
+ const { purposes, ...rest } = typedParams;
225
+ const overrideParams = { ...rest, purposes: filterPurposes(purposes) };
226
+ return { method, params: overrideParams };
227
+ }
228
+ if (method === "getAddresses") {
229
+ const typedParams = params;
230
+ const { purposes, ...rest } = typedParams;
231
+ const overrideParams = { ...rest, purposes: filterPurposes(purposes) };
232
+ return { method, params: overrideParams };
233
+ }
234
+ return { method, params };
235
+ };
196
236
 
197
237
  // src/request/types/btcMethods.ts
198
238
  import * as v6 from "valibot";
@@ -805,10 +845,10 @@ var runesTransferRequestMessageSchema = v11.object({
805
845
  }).entries
806
846
  });
807
847
 
808
- // src/request/types/sparkMethods/flashnetMethods/getJwt.ts
848
+ // src/request/types/sparkMethods/getAddresses.ts
809
849
  import * as v12 from "valibot";
810
- var sparkFlashnetGetJwtMethodName = "spark_flashnet_getJwt";
811
- var sparkFlashnetGetJwtParamsSchema = v12.nullish(
850
+ var sparkGetAddressesMethodName = "spark_getAddresses";
851
+ var sparkGetAddressesParamsSchema = v12.nullish(
812
852
  v12.object({
813
853
  /**
814
854
  * A message to be displayed to the user in the request prompt.
@@ -816,227 +856,135 @@ var sparkFlashnetGetJwtParamsSchema = v12.nullish(
816
856
  message: v12.optional(v12.string())
817
857
  })
818
858
  );
819
- var sparkFlashnetGetJwtResultSchema = v12.object({
820
- /**
821
- * The JWT token for authenticated requests to the Flashnet API.
822
- */
823
- jwt: v12.string()
824
- });
825
- var sparkFlashnetGetJwtRequestMessageSchema = v12.object({
826
- ...rpcRequestMessageSchema.entries,
827
- ...v12.object({
828
- method: v12.literal(sparkFlashnetGetJwtMethodName),
829
- params: sparkFlashnetGetJwtParamsSchema,
830
- id: v12.string()
831
- }).entries
832
- });
833
-
834
- // src/request/types/sparkMethods/flashnetMethods/intents/common.ts
835
- var FlashnetIntentType = /* @__PURE__ */ ((FlashnetIntentType2) => {
836
- FlashnetIntentType2["Swap"] = "swap";
837
- FlashnetIntentType2["RouteSwap"] = "route-swap";
838
- return FlashnetIntentType2;
839
- })(FlashnetIntentType || {});
840
-
841
- // src/request/types/sparkMethods/flashnetMethods/intents/routeSwap.ts
842
- import * as v13 from "valibot";
843
- var sparkFlashnetRouteSwapIntentSchema = v13.object({
844
- intentType: v13.literal("route-swap" /* RouteSwap */),
845
- userPublicKey: v13.string(),
846
- initialSparkTransferId: v13.string(),
847
- hops: v13.array(
848
- v13.object({
849
- poolId: v13.string(),
850
- assetInAddress: v13.string(),
851
- assetOutAddress: v13.string(),
852
- hopIntegratorFeeRateBps: v13.optional(v13.number())
853
- })
854
- ),
855
- inputAmount: v13.string(),
856
- maxRouteSlippageBps: v13.number(),
857
- minAmountOut: v13.string(),
858
- defaultIntegratorFeeRateBps: v13.optional(v13.number()),
859
- nonce: v13.string()
860
- });
861
-
862
- // src/request/types/sparkMethods/flashnetMethods/intents/swap.ts
863
- import * as v14 from "valibot";
864
- var sparkFlashnetSwapIntentSchema = v14.object({
865
- intentType: v14.literal("swap" /* Swap */),
866
- userPublicKey: v14.string(),
867
- poolId: v14.string(),
868
- transferId: v14.string(),
869
- assetInAddress: v14.string(),
870
- assetOutAddress: v14.string(),
871
- amountIn: v14.string(),
872
- maxSlippageBps: v14.number(),
873
- minAmountOut: v14.string(),
874
- totalIntegratorFeeRateBps: v14.optional(v14.number()),
875
- nonce: v14.string()
876
- });
877
-
878
- // src/request/types/sparkMethods/flashnetMethods/signIntent.ts
879
- import * as v15 from "valibot";
880
- var sparkFlashnetSignIntentMethodName = "spark_flashnet_signIntent";
881
- var sparkFlashnetSignIntentParamsSchema = v15.union([
882
- sparkFlashnetSwapIntentSchema,
883
- sparkFlashnetRouteSwapIntentSchema
884
- ]);
885
- var sparkFlashnetSignIntentResultSchema = v15.object({
886
- /**
887
- * The signed intent as a hex string.
888
- */
889
- signature: v15.string()
890
- });
891
- var sparkFlashnetSignIntentRequestMessageSchema = v15.object({
892
- ...rpcRequestMessageSchema.entries,
893
- ...v15.object({
894
- method: v15.literal(sparkFlashnetSignIntentMethodName),
895
- params: sparkFlashnetSignIntentParamsSchema,
896
- id: v15.string()
897
- }).entries
898
- });
899
-
900
- // src/request/types/sparkMethods/getAddresses.ts
901
- import * as v16 from "valibot";
902
- var sparkGetAddressesMethodName = "spark_getAddresses";
903
- var sparkGetAddressesParamsSchema = v16.nullish(
904
- v16.object({
905
- /**
906
- * A message to be displayed to the user in the request prompt.
907
- */
908
- message: v16.optional(v16.string())
909
- })
910
- );
911
- var sparkGetAddressesResultSchema = v16.object({
859
+ var sparkGetAddressesResultSchema = v12.object({
912
860
  /**
913
861
  * The addresses generated for the given purposes.
914
862
  */
915
- addresses: v16.array(addressSchema),
863
+ addresses: v12.array(addressSchema),
916
864
  network: getNetworkResultSchema
917
865
  });
918
- var sparkGetAddressesRequestMessageSchema = v16.object({
866
+ var sparkGetAddressesRequestMessageSchema = v12.object({
919
867
  ...rpcRequestMessageSchema.entries,
920
- ...v16.object({
921
- method: v16.literal(sparkGetAddressesMethodName),
868
+ ...v12.object({
869
+ method: v12.literal(sparkGetAddressesMethodName),
922
870
  params: sparkGetAddressesParamsSchema,
923
- id: v16.string()
871
+ id: v12.string()
924
872
  }).entries
925
873
  });
926
874
 
927
875
  // src/request/types/sparkMethods/getBalance.ts
928
- import * as v17 from "valibot";
876
+ import * as v13 from "valibot";
929
877
  var sparkGetBalanceMethodName = "spark_getBalance";
930
- var sparkGetBalanceParamsSchema = v17.nullish(v17.null());
931
- var sparkGetBalanceResultSchema = v17.object({
878
+ var sparkGetBalanceParamsSchema = v13.nullish(v13.null());
879
+ var sparkGetBalanceResultSchema = v13.object({
932
880
  /**
933
881
  * The Spark Bitcoin address balance in sats in string form.
934
882
  */
935
- balance: v17.string(),
936
- tokenBalances: v17.array(
937
- v17.object({
883
+ balance: v13.string(),
884
+ tokenBalances: v13.array(
885
+ v13.object({
938
886
  /* The address balance of the token in string form as it can overflow a js number */
939
- balance: v17.string(),
940
- tokenMetadata: v17.object({
941
- tokenIdentifier: v17.string(),
942
- tokenName: v17.string(),
943
- tokenTicker: v17.string(),
944
- decimals: v17.number(),
945
- maxSupply: v17.string()
887
+ balance: v13.string(),
888
+ tokenMetadata: v13.object({
889
+ tokenIdentifier: v13.string(),
890
+ tokenName: v13.string(),
891
+ tokenTicker: v13.string(),
892
+ decimals: v13.number(),
893
+ maxSupply: v13.string()
946
894
  })
947
895
  })
948
896
  )
949
897
  });
950
- var sparkGetBalanceRequestMessageSchema = v17.object({
898
+ var sparkGetBalanceRequestMessageSchema = v13.object({
951
899
  ...rpcRequestMessageSchema.entries,
952
- ...v17.object({
953
- method: v17.literal(sparkGetBalanceMethodName),
900
+ ...v13.object({
901
+ method: v13.literal(sparkGetBalanceMethodName),
954
902
  params: sparkGetBalanceParamsSchema,
955
- id: v17.string()
903
+ id: v13.string()
956
904
  }).entries
957
905
  });
958
906
 
959
907
  // src/request/types/sparkMethods/transfer.ts
960
- import * as v18 from "valibot";
908
+ import * as v14 from "valibot";
961
909
  var sparkTransferMethodName = "spark_transfer";
962
- var sparkTransferParamsSchema = v18.object({
910
+ var sparkTransferParamsSchema = v14.object({
963
911
  /**
964
912
  * Amount of SATS to transfer as a string or number.
965
913
  */
966
- amountSats: v18.union([v18.number(), v18.string()]),
914
+ amountSats: v14.union([v14.number(), v14.string()]),
967
915
  /**
968
916
  * The recipient's spark address.
969
917
  */
970
- receiverSparkAddress: v18.string()
918
+ receiverSparkAddress: v14.string()
971
919
  });
972
- var sparkTransferResultSchema = v18.object({
920
+ var sparkTransferResultSchema = v14.object({
973
921
  /**
974
922
  * The ID of the transaction.
975
923
  */
976
- id: v18.string()
924
+ id: v14.string()
977
925
  });
978
- var sparkTransferRequestMessageSchema = v18.object({
926
+ var sparkTransferRequestMessageSchema = v14.object({
979
927
  ...rpcRequestMessageSchema.entries,
980
- ...v18.object({
981
- method: v18.literal(sparkTransferMethodName),
928
+ ...v14.object({
929
+ method: v14.literal(sparkTransferMethodName),
982
930
  params: sparkTransferParamsSchema,
983
- id: v18.string()
931
+ id: v14.string()
984
932
  }).entries
985
933
  });
986
934
 
987
935
  // src/request/types/sparkMethods/transferToken.ts
988
- import * as v19 from "valibot";
936
+ import * as v15 from "valibot";
989
937
  var sparkTransferTokenMethodName = "spark_transferToken";
990
- var sparkTransferTokenParamsSchema = v19.object({
938
+ var sparkTransferTokenParamsSchema = v15.object({
991
939
  /**
992
940
  * Amount of units of the token to transfer as a string or number.
993
941
  */
994
- tokenAmount: v19.union([v19.number(), v19.string()]),
942
+ tokenAmount: v15.union([v15.number(), v15.string()]),
995
943
  /**
996
944
  * The Bech32m token identifier.
997
945
  */
998
- tokenIdentifier: v19.string(),
946
+ tokenIdentifier: v15.string(),
999
947
  /**
1000
948
  * The recipient's spark address.
1001
949
  */
1002
- receiverSparkAddress: v19.string()
950
+ receiverSparkAddress: v15.string()
1003
951
  });
1004
- var sparkTransferTokenResultSchema = v19.object({
952
+ var sparkTransferTokenResultSchema = v15.object({
1005
953
  /**
1006
954
  * The ID of the transaction.
1007
955
  */
1008
- id: v19.string()
956
+ id: v15.string()
1009
957
  });
1010
- var sparkTransferTokenRequestMessageSchema = v19.object({
958
+ var sparkTransferTokenRequestMessageSchema = v15.object({
1011
959
  ...rpcRequestMessageSchema.entries,
1012
- ...v19.object({
1013
- method: v19.literal(sparkTransferTokenMethodName),
960
+ ...v15.object({
961
+ method: v15.literal(sparkTransferTokenMethodName),
1014
962
  params: sparkTransferTokenParamsSchema,
1015
- id: v19.string()
963
+ id: v15.string()
1016
964
  }).entries
1017
965
  });
1018
966
 
1019
967
  // src/request/types/stxMethods/callContract.ts
1020
- import * as v20 from "valibot";
968
+ import * as v16 from "valibot";
1021
969
  var stxCallContractMethodName = "stx_callContract";
1022
- var stxCallContractParamsSchema = v20.object({
970
+ var stxCallContractParamsSchema = v16.object({
1023
971
  /**
1024
972
  * The contract principal.
1025
973
  *
1026
974
  * E.g. `"SPKE...GD5C.my-contract"`
1027
975
  */
1028
- contract: v20.string(),
976
+ contract: v16.string(),
1029
977
  /**
1030
978
  * The name of the function to call.
1031
979
  *
1032
980
  * Note: spec changes ongoing,
1033
981
  * https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
1034
982
  */
1035
- functionName: v20.string(),
983
+ functionName: v16.string(),
1036
984
  /**
1037
985
  * @deprecated in favor of `functionArgs` for @stacks/connect compatibility
1038
986
  */
1039
- arguments: v20.optional(v20.array(v20.string())),
987
+ arguments: v16.optional(v16.array(v16.string())),
1040
988
  /**
1041
989
  * The function's arguments. The arguments are expected to be hex-encoded
1042
990
  * strings of Clarity values.
@@ -1051,274 +999,274 @@ var stxCallContractParamsSchema = v20.object({
1051
999
  * const hexArgs = functionArgs.map(cvToHex);
1052
1000
  * ```
1053
1001
  */
1054
- functionArgs: v20.optional(v20.array(v20.string())),
1002
+ functionArgs: v16.optional(v16.array(v16.string())),
1055
1003
  /**
1056
1004
  * The post conditions to apply to the contract call.
1057
1005
  */
1058
- postConditions: v20.optional(v20.array(v20.string())),
1006
+ postConditions: v16.optional(v16.array(v16.string())),
1059
1007
  /**
1060
1008
  * The mode to apply to the post conditions.
1061
1009
  */
1062
- postConditionMode: v20.optional(v20.union([v20.literal("allow"), v20.literal("deny")]))
1010
+ postConditionMode: v16.optional(v16.union([v16.literal("allow"), v16.literal("deny")]))
1063
1011
  });
1064
- var stxCallContractResultSchema = v20.object({
1012
+ var stxCallContractResultSchema = v16.object({
1065
1013
  /**
1066
1014
  * The ID of the transaction.
1067
1015
  */
1068
- txid: v20.string(),
1016
+ txid: v16.string(),
1069
1017
  /**
1070
1018
  * A Stacks transaction as a hex-encoded string.
1071
1019
  */
1072
- transaction: v20.string()
1020
+ transaction: v16.string()
1073
1021
  });
1074
- var stxCallContractRequestMessageSchema = v20.object({
1022
+ var stxCallContractRequestMessageSchema = v16.object({
1075
1023
  ...rpcRequestMessageSchema.entries,
1076
- ...v20.object({
1077
- method: v20.literal(stxCallContractMethodName),
1024
+ ...v16.object({
1025
+ method: v16.literal(stxCallContractMethodName),
1078
1026
  params: stxCallContractParamsSchema,
1079
- id: v20.string()
1027
+ id: v16.string()
1080
1028
  }).entries
1081
1029
  });
1082
1030
 
1083
1031
  // src/request/types/stxMethods/deployContract.ts
1084
- import * as v21 from "valibot";
1032
+ import * as v17 from "valibot";
1085
1033
  var stxDeployContractMethodName = "stx_deployContract";
1086
- var stxDeployContractParamsSchema = v21.object({
1034
+ var stxDeployContractParamsSchema = v17.object({
1087
1035
  /**
1088
1036
  * Name of the contract.
1089
1037
  */
1090
- name: v21.string(),
1038
+ name: v17.string(),
1091
1039
  /**
1092
1040
  * The source code of the Clarity contract.
1093
1041
  */
1094
- clarityCode: v21.string(),
1042
+ clarityCode: v17.string(),
1095
1043
  /**
1096
1044
  * The version of the Clarity contract.
1097
1045
  */
1098
- clarityVersion: v21.optional(v21.number()),
1046
+ clarityVersion: v17.optional(v17.number()),
1099
1047
  /**
1100
1048
  * The post conditions to apply to the contract call.
1101
1049
  */
1102
- postConditions: v21.optional(v21.array(v21.string())),
1050
+ postConditions: v17.optional(v17.array(v17.string())),
1103
1051
  /**
1104
1052
  * The mode to apply to the post conditions.
1105
1053
  */
1106
- postConditionMode: v21.optional(v21.union([v21.literal("allow"), v21.literal("deny")]))
1054
+ postConditionMode: v17.optional(v17.union([v17.literal("allow"), v17.literal("deny")]))
1107
1055
  });
1108
- var stxDeployContractResultSchema = v21.object({
1056
+ var stxDeployContractResultSchema = v17.object({
1109
1057
  /**
1110
1058
  * The ID of the transaction.
1111
1059
  */
1112
- txid: v21.string(),
1060
+ txid: v17.string(),
1113
1061
  /**
1114
1062
  * A Stacks transaction as a hex-encoded string.
1115
1063
  */
1116
- transaction: v21.string()
1064
+ transaction: v17.string()
1117
1065
  });
1118
- var stxDeployContractRequestMessageSchema = v21.object({
1066
+ var stxDeployContractRequestMessageSchema = v17.object({
1119
1067
  ...rpcRequestMessageSchema.entries,
1120
- ...v21.object({
1121
- method: v21.literal(stxDeployContractMethodName),
1068
+ ...v17.object({
1069
+ method: v17.literal(stxDeployContractMethodName),
1122
1070
  params: stxDeployContractParamsSchema,
1123
- id: v21.string()
1071
+ id: v17.string()
1124
1072
  }).entries
1125
1073
  });
1126
1074
 
1127
1075
  // src/request/types/stxMethods/getAccounts.ts
1128
- import * as v22 from "valibot";
1076
+ import * as v18 from "valibot";
1129
1077
  var stxGetAccountsMethodName = "stx_getAccounts";
1130
- var stxGetAccountsParamsSchema = v22.nullish(v22.null());
1131
- var stxGetAccountsResultSchema = v22.object({
1078
+ var stxGetAccountsParamsSchema = v18.nullish(v18.null());
1079
+ var stxGetAccountsResultSchema = v18.object({
1132
1080
  /**
1133
1081
  * The addresses generated for the given purposes.
1134
1082
  */
1135
- addresses: v22.array(
1136
- v22.object({
1137
- address: v22.string(),
1138
- publicKey: v22.string(),
1139
- gaiaHubUrl: v22.string(),
1140
- gaiaAppKey: v22.string()
1083
+ addresses: v18.array(
1084
+ v18.object({
1085
+ address: v18.string(),
1086
+ publicKey: v18.string(),
1087
+ gaiaHubUrl: v18.string(),
1088
+ gaiaAppKey: v18.string()
1141
1089
  })
1142
1090
  ),
1143
1091
  network: getNetworkResultSchema
1144
1092
  });
1145
- var stxGetAccountsRequestMessageSchema = v22.object({
1093
+ var stxGetAccountsRequestMessageSchema = v18.object({
1146
1094
  ...rpcRequestMessageSchema.entries,
1147
- ...v22.object({
1148
- method: v22.literal(stxGetAccountsMethodName),
1095
+ ...v18.object({
1096
+ method: v18.literal(stxGetAccountsMethodName),
1149
1097
  params: stxGetAccountsParamsSchema,
1150
- id: v22.string()
1098
+ id: v18.string()
1151
1099
  }).entries
1152
1100
  });
1153
1101
 
1154
1102
  // src/request/types/stxMethods/getAddresses.ts
1155
- import * as v23 from "valibot";
1103
+ import * as v19 from "valibot";
1156
1104
  var stxGetAddressesMethodName = "stx_getAddresses";
1157
- var stxGetAddressesParamsSchema = v23.nullish(
1158
- v23.object({
1105
+ var stxGetAddressesParamsSchema = v19.nullish(
1106
+ v19.object({
1159
1107
  /**
1160
1108
  * A message to be displayed to the user in the request prompt.
1161
1109
  */
1162
- message: v23.optional(v23.string())
1110
+ message: v19.optional(v19.string())
1163
1111
  })
1164
1112
  );
1165
- var stxGetAddressesResultSchema = v23.object({
1113
+ var stxGetAddressesResultSchema = v19.object({
1166
1114
  /**
1167
1115
  * The addresses generated for the given purposes.
1168
1116
  */
1169
- addresses: v23.array(addressSchema),
1117
+ addresses: v19.array(addressSchema),
1170
1118
  network: getNetworkResultSchema
1171
1119
  });
1172
- var stxGetAddressesRequestMessageSchema = v23.object({
1120
+ var stxGetAddressesRequestMessageSchema = v19.object({
1173
1121
  ...rpcRequestMessageSchema.entries,
1174
- ...v23.object({
1175
- method: v23.literal(stxGetAddressesMethodName),
1122
+ ...v19.object({
1123
+ method: v19.literal(stxGetAddressesMethodName),
1176
1124
  params: stxGetAddressesParamsSchema,
1177
- id: v23.string()
1125
+ id: v19.string()
1178
1126
  }).entries
1179
1127
  });
1180
1128
 
1181
1129
  // src/request/types/stxMethods/signMessage.ts
1182
- import * as v24 from "valibot";
1130
+ import * as v20 from "valibot";
1183
1131
  var stxSignMessageMethodName = "stx_signMessage";
1184
- var stxSignMessageParamsSchema = v24.object({
1132
+ var stxSignMessageParamsSchema = v20.object({
1185
1133
  /**
1186
1134
  * The message to sign.
1187
1135
  */
1188
- message: v24.string()
1136
+ message: v20.string()
1189
1137
  });
1190
- var stxSignMessageResultSchema = v24.object({
1138
+ var stxSignMessageResultSchema = v20.object({
1191
1139
  /**
1192
1140
  * The signature of the message.
1193
1141
  */
1194
- signature: v24.string(),
1142
+ signature: v20.string(),
1195
1143
  /**
1196
1144
  * The public key used to sign the message.
1197
1145
  */
1198
- publicKey: v24.string()
1146
+ publicKey: v20.string()
1199
1147
  });
1200
- var stxSignMessageRequestMessageSchema = v24.object({
1148
+ var stxSignMessageRequestMessageSchema = v20.object({
1201
1149
  ...rpcRequestMessageSchema.entries,
1202
- ...v24.object({
1203
- method: v24.literal(stxSignMessageMethodName),
1150
+ ...v20.object({
1151
+ method: v20.literal(stxSignMessageMethodName),
1204
1152
  params: stxSignMessageParamsSchema,
1205
- id: v24.string()
1153
+ id: v20.string()
1206
1154
  }).entries
1207
1155
  });
1208
1156
 
1209
1157
  // src/request/types/stxMethods/signStructuredMessage.ts
1210
- import * as v25 from "valibot";
1158
+ import * as v21 from "valibot";
1211
1159
  var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
1212
- var stxSignStructuredMessageParamsSchema = v25.object({
1160
+ var stxSignStructuredMessageParamsSchema = v21.object({
1213
1161
  /**
1214
1162
  * The domain to be signed.
1215
1163
  */
1216
- domain: v25.string(),
1164
+ domain: v21.string(),
1217
1165
  /**
1218
1166
  * Message payload to be signed.
1219
1167
  */
1220
- message: v25.string(),
1168
+ message: v21.string(),
1221
1169
  /**
1222
1170
  * The public key to sign the message with.
1223
1171
  */
1224
- publicKey: v25.optional(v25.string())
1172
+ publicKey: v21.optional(v21.string())
1225
1173
  });
1226
- var stxSignStructuredMessageResultSchema = v25.object({
1174
+ var stxSignStructuredMessageResultSchema = v21.object({
1227
1175
  /**
1228
1176
  * Signature of the message.
1229
1177
  */
1230
- signature: v25.string(),
1178
+ signature: v21.string(),
1231
1179
  /**
1232
1180
  * Public key as hex-encoded string.
1233
1181
  */
1234
- publicKey: v25.string()
1182
+ publicKey: v21.string()
1235
1183
  });
1236
- var stxSignStructuredMessageRequestMessageSchema = v25.object({
1184
+ var stxSignStructuredMessageRequestMessageSchema = v21.object({
1237
1185
  ...rpcRequestMessageSchema.entries,
1238
- ...v25.object({
1239
- method: v25.literal(stxSignStructuredMessageMethodName),
1186
+ ...v21.object({
1187
+ method: v21.literal(stxSignStructuredMessageMethodName),
1240
1188
  params: stxSignStructuredMessageParamsSchema,
1241
- id: v25.string()
1189
+ id: v21.string()
1242
1190
  }).entries
1243
1191
  });
1244
1192
 
1245
1193
  // src/request/types/stxMethods/signTransaction.ts
1246
- import * as v26 from "valibot";
1194
+ import * as v22 from "valibot";
1247
1195
  var stxSignTransactionMethodName = "stx_signTransaction";
1248
- var stxSignTransactionParamsSchema = v26.object({
1196
+ var stxSignTransactionParamsSchema = v22.object({
1249
1197
  /**
1250
1198
  * The transaction to sign as a hex-encoded string.
1251
1199
  */
1252
- transaction: v26.string(),
1200
+ transaction: v22.string(),
1253
1201
  /**
1254
1202
  * The public key to sign the transaction with. The wallet may use any key
1255
1203
  * when not provided.
1256
1204
  */
1257
- pubkey: v26.optional(v26.string()),
1205
+ pubkey: v22.optional(v22.string()),
1258
1206
  /**
1259
1207
  * Whether to broadcast the transaction after signing. Defaults to `true`.
1260
1208
  */
1261
- broadcast: v26.optional(v26.boolean())
1209
+ broadcast: v22.optional(v22.boolean())
1262
1210
  });
1263
- var stxSignTransactionResultSchema = v26.object({
1211
+ var stxSignTransactionResultSchema = v22.object({
1264
1212
  /**
1265
1213
  * The signed transaction as a hex-encoded string.
1266
1214
  */
1267
- transaction: v26.string()
1215
+ transaction: v22.string()
1268
1216
  });
1269
- var stxSignTransactionRequestMessageSchema = v26.object({
1217
+ var stxSignTransactionRequestMessageSchema = v22.object({
1270
1218
  ...rpcRequestMessageSchema.entries,
1271
- ...v26.object({
1272
- method: v26.literal(stxSignTransactionMethodName),
1219
+ ...v22.object({
1220
+ method: v22.literal(stxSignTransactionMethodName),
1273
1221
  params: stxSignTransactionParamsSchema,
1274
- id: v26.string()
1222
+ id: v22.string()
1275
1223
  }).entries
1276
1224
  });
1277
1225
 
1278
1226
  // src/request/types/stxMethods/signTransactions.ts
1279
- import * as v27 from "valibot";
1227
+ import * as v23 from "valibot";
1280
1228
  var stxSignTransactionsMethodName = "stx_signTransactions";
1281
- var stxSignTransactionsParamsSchema = v27.object({
1229
+ var stxSignTransactionsParamsSchema = v23.object({
1282
1230
  /**
1283
1231
  * The transactions to sign as hex-encoded strings.
1284
1232
  */
1285
- transactions: v27.pipe(
1286
- v27.array(
1287
- v27.pipe(
1288
- v27.string(),
1289
- v27.check((hex) => {
1233
+ transactions: v23.pipe(
1234
+ v23.array(
1235
+ v23.pipe(
1236
+ v23.string(),
1237
+ v23.check((hex) => {
1290
1238
  return true;
1291
1239
  }, "Invalid hex-encoded Stacks transaction.")
1292
1240
  )
1293
1241
  ),
1294
- v27.minLength(1)
1242
+ v23.minLength(1)
1295
1243
  ),
1296
1244
  /**
1297
1245
  * Whether the signed transactions should be broadcast after signing. Defaults
1298
1246
  * to `true`.
1299
1247
  */
1300
- broadcast: v27.optional(v27.boolean())
1248
+ broadcast: v23.optional(v23.boolean())
1301
1249
  });
1302
- var stxSignTransactionsResultSchema = v27.object({
1250
+ var stxSignTransactionsResultSchema = v23.object({
1303
1251
  /**
1304
1252
  * The signed transactions as hex-encoded strings, in the same order as in the
1305
1253
  * sign request.
1306
1254
  */
1307
- transactions: v27.array(v27.string())
1255
+ transactions: v23.array(v23.string())
1308
1256
  });
1309
- var stxSignTransactionsRequestMessageSchema = v27.object({
1257
+ var stxSignTransactionsRequestMessageSchema = v23.object({
1310
1258
  ...rpcRequestMessageSchema.entries,
1311
- ...v27.object({
1312
- method: v27.literal(stxSignTransactionsMethodName),
1259
+ ...v23.object({
1260
+ method: v23.literal(stxSignTransactionsMethodName),
1313
1261
  params: stxSignTransactionsParamsSchema,
1314
- id: v27.string()
1262
+ id: v23.string()
1315
1263
  }).entries
1316
1264
  });
1317
1265
 
1318
1266
  // src/request/types/stxMethods/transferStx.ts
1319
- import * as v28 from "valibot";
1267
+ import * as v24 from "valibot";
1320
1268
  var stxTransferStxMethodName = "stx_transferStx";
1321
- var stxTransferStxParamsSchema = v28.object({
1269
+ var stxTransferStxParamsSchema = v24.object({
1322
1270
  /**
1323
1271
  * Amount of STX tokens to transfer in microstacks as a string. Anything
1324
1272
  * parseable by `BigInt` is acceptable.
@@ -1331,23 +1279,23 @@ var stxTransferStxParamsSchema = v28.object({
1331
1279
  * const amount3 = '1234';
1332
1280
  * ```
1333
1281
  */
1334
- amount: v28.union([v28.number(), v28.string()]),
1282
+ amount: v24.union([v24.number(), v24.string()]),
1335
1283
  /**
1336
1284
  * The recipient's principal.
1337
1285
  */
1338
- recipient: v28.string(),
1286
+ recipient: v24.string(),
1339
1287
  /**
1340
1288
  * A string representing the memo.
1341
1289
  */
1342
- memo: v28.optional(v28.string()),
1290
+ memo: v24.optional(v24.string()),
1343
1291
  /**
1344
1292
  * Version of parameter format.
1345
1293
  */
1346
- version: v28.optional(v28.string()),
1294
+ version: v24.optional(v24.string()),
1347
1295
  /**
1348
1296
  * The mode of the post conditions.
1349
1297
  */
1350
- postConditionMode: v28.optional(v28.number()),
1298
+ postConditionMode: v24.optional(v24.number()),
1351
1299
  /**
1352
1300
  * A hex-encoded string representing the post conditions.
1353
1301
  *
@@ -1360,29 +1308,29 @@ var stxTransferStxParamsSchema = v28.object({
1360
1308
  * const hexPostCondition = serializePostCondition(postCondition).toString('hex');
1361
1309
  * ```
1362
1310
  */
1363
- postConditions: v28.optional(v28.array(v28.string())),
1311
+ postConditions: v24.optional(v24.array(v24.string())),
1364
1312
  /**
1365
1313
  * The public key to sign the transaction with. The wallet may use any key
1366
1314
  * when not provided.
1367
1315
  */
1368
- pubkey: v28.optional(v28.string())
1316
+ pubkey: v24.optional(v24.string())
1369
1317
  });
1370
- var stxTransferStxResultSchema = v28.object({
1318
+ var stxTransferStxResultSchema = v24.object({
1371
1319
  /**
1372
1320
  * The ID of the transaction.
1373
1321
  */
1374
- txid: v28.string(),
1322
+ txid: v24.string(),
1375
1323
  /**
1376
1324
  * A Stacks transaction as a hex-encoded string.
1377
1325
  */
1378
- transaction: v28.string()
1326
+ transaction: v24.string()
1379
1327
  });
1380
- var stxTransferStxRequestMessageSchema = v28.object({
1328
+ var stxTransferStxRequestMessageSchema = v24.object({
1381
1329
  ...rpcRequestMessageSchema.entries,
1382
- ...v28.object({
1383
- method: v28.literal(stxTransferStxMethodName),
1330
+ ...v24.object({
1331
+ method: v24.literal(stxTransferStxMethodName),
1384
1332
  params: stxTransferStxParamsSchema,
1385
- id: v28.string()
1333
+ id: v24.string()
1386
1334
  }).entries
1387
1335
  });
1388
1336
 
@@ -1398,14 +1346,23 @@ var request = async (method, params, providerId) => {
1398
1346
  if (!method) {
1399
1347
  throw new Error("A wallet method is required");
1400
1348
  }
1401
- const response = await provider.request(method, params);
1402
- if (v29.is(rpcErrorResponseMessageSchema, response)) {
1349
+ const providerVersion = provider.version ?? 0;
1350
+ const {
1351
+ method: sanitizedMethod,
1352
+ params: sanitizedParams,
1353
+ overrideResponse
1354
+ } = sanitizeRequest(method, params, providerVersion);
1355
+ if (overrideResponse) {
1356
+ return overrideResponse;
1357
+ }
1358
+ const response = await provider.request(sanitizedMethod, sanitizedParams);
1359
+ if (v25.is(rpcErrorResponseMessageSchema, response)) {
1403
1360
  return {
1404
1361
  status: "error",
1405
1362
  error: response.error
1406
1363
  };
1407
1364
  }
1408
- if (v29.is(rpcSuccessResponseMessageSchema, response)) {
1365
+ if (v25.is(rpcSuccessResponseMessageSchema, response)) {
1409
1366
  return {
1410
1367
  status: "success",
1411
1368
  result: response.result
@@ -2221,6 +2178,7 @@ var extractOrValidateCapabilities = (provider, reportedCapabilities) => {
2221
2178
  return true;
2222
2179
  };
2223
2180
  const capabilityMap = {
2181
+ version: validateCapability("version"),
2224
2182
  request: validateCapability("request"),
2225
2183
  connect: validateCapability("connect"),
2226
2184
  signMessage: validateCapability("signMessage"),
@@ -2422,7 +2380,6 @@ export {
2422
2380
  BaseAdapter,
2423
2381
  BitcoinNetworkType,
2424
2382
  DefaultAdaptersInfo,
2425
- FlashnetIntentType,
2426
2383
  MessageSigningProtocols,
2427
2384
  PermissionRequestParams,
2428
2385
  RpcErrorCode,
@@ -2560,16 +2517,6 @@ export {
2560
2517
  signPsbtRequestMessageSchema,
2561
2518
  signPsbtResultSchema,
2562
2519
  signTransaction,
2563
- sparkFlashnetGetJwtMethodName,
2564
- sparkFlashnetGetJwtParamsSchema,
2565
- sparkFlashnetGetJwtRequestMessageSchema,
2566
- sparkFlashnetGetJwtResultSchema,
2567
- sparkFlashnetRouteSwapIntentSchema,
2568
- sparkFlashnetSignIntentMethodName,
2569
- sparkFlashnetSignIntentParamsSchema,
2570
- sparkFlashnetSignIntentRequestMessageSchema,
2571
- sparkFlashnetSignIntentResultSchema,
2572
- sparkFlashnetSwapIntentSchema,
2573
2520
  sparkGetAddressesMethodName,
2574
2521
  sparkGetAddressesParamsSchema,
2575
2522
  sparkGetAddressesRequestMessageSchema,