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