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