@sats-connect/core 0.8.1 → 0.8.2-6e91f8a
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 +341 -1
- package/dist/index.d.ts +341 -1
- package/dist/index.js +467 -179
- package/dist/index.mjs +450 -179
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/request/index.ts
|
|
2
|
+
import * as v35 from "valibot";
|
|
3
|
+
|
|
1
4
|
// src/provider/types.ts
|
|
2
5
|
import * as v4 from "valibot";
|
|
3
6
|
|
|
@@ -191,8 +194,53 @@ function getSupportedWallets() {
|
|
|
191
194
|
return wallets;
|
|
192
195
|
}
|
|
193
196
|
|
|
194
|
-
// src/request/
|
|
195
|
-
|
|
197
|
+
// src/request/sanitizeRequest.ts
|
|
198
|
+
var sanitizeRequest = (method, params, providerInfo) => {
|
|
199
|
+
try {
|
|
200
|
+
const [major, minor, patch] = providerInfo.version.split(".").map((part) => parseInt(part, 10));
|
|
201
|
+
const platform = providerInfo.platform;
|
|
202
|
+
if (
|
|
203
|
+
// platform is missing for versions < 1.5.0 on web and < 1.55.0 on mobile
|
|
204
|
+
!platform || platform === "web" /* Web */ && major <= 1 && minor <= 4 || platform === "mobile" /* Mobile */ && major <= 1 && minor <= 54
|
|
205
|
+
) {
|
|
206
|
+
const v1Sanitized = sanitizeAddressPurposeRequest(method, params);
|
|
207
|
+
method = v1Sanitized.method;
|
|
208
|
+
params = v1Sanitized.params;
|
|
209
|
+
}
|
|
210
|
+
} catch {
|
|
211
|
+
}
|
|
212
|
+
return { method, params };
|
|
213
|
+
};
|
|
214
|
+
var sanitizeAddressPurposeRequest = (method, params) => {
|
|
215
|
+
const filterPurposes = (purposes) => purposes?.filter(
|
|
216
|
+
(purpose) => purpose !== "spark" /* Spark */ && purpose !== "starknet" /* Starknet */
|
|
217
|
+
);
|
|
218
|
+
if (method === "wallet_connect") {
|
|
219
|
+
const typedParams = params;
|
|
220
|
+
if (!typedParams) {
|
|
221
|
+
return { method, params };
|
|
222
|
+
}
|
|
223
|
+
const { addresses, ...rest } = typedParams;
|
|
224
|
+
const overrideParams = {
|
|
225
|
+
...rest,
|
|
226
|
+
addresses: filterPurposes(addresses)
|
|
227
|
+
};
|
|
228
|
+
return { method, params: overrideParams };
|
|
229
|
+
}
|
|
230
|
+
if (method === "getAccounts") {
|
|
231
|
+
const typedParams = params;
|
|
232
|
+
const { purposes, ...rest } = typedParams;
|
|
233
|
+
const overrideParams = { ...rest, purposes: filterPurposes(purposes) };
|
|
234
|
+
return { method, params: overrideParams };
|
|
235
|
+
}
|
|
236
|
+
if (method === "getAddresses") {
|
|
237
|
+
const typedParams = params;
|
|
238
|
+
const { purposes, ...rest } = typedParams;
|
|
239
|
+
const overrideParams = { ...rest, purposes: filterPurposes(purposes) };
|
|
240
|
+
return { method, params: overrideParams };
|
|
241
|
+
}
|
|
242
|
+
return { method, params };
|
|
243
|
+
};
|
|
196
244
|
|
|
197
245
|
// src/request/types/btcMethods.ts
|
|
198
246
|
import * as v6 from "valibot";
|
|
@@ -411,6 +459,11 @@ var addNetworkResultSchema = v5.object({
|
|
|
411
459
|
});
|
|
412
460
|
|
|
413
461
|
// src/request/types/btcMethods.ts
|
|
462
|
+
var ProviderPlatform = /* @__PURE__ */ ((ProviderPlatform2) => {
|
|
463
|
+
ProviderPlatform2["Web"] = "web";
|
|
464
|
+
ProviderPlatform2["Mobile"] = "mobile";
|
|
465
|
+
return ProviderPlatform2;
|
|
466
|
+
})(ProviderPlatform || {});
|
|
414
467
|
var getInfoMethodName = "getInfo";
|
|
415
468
|
var getInfoParamsSchema = v6.nullish(v6.null());
|
|
416
469
|
var getInfoResultSchema = v6.object({
|
|
@@ -418,6 +471,10 @@ var getInfoResultSchema = v6.object({
|
|
|
418
471
|
* Version of the wallet.
|
|
419
472
|
*/
|
|
420
473
|
version: v6.string(),
|
|
474
|
+
/**
|
|
475
|
+
* The platform the wallet is running on (web or mobile).
|
|
476
|
+
*/
|
|
477
|
+
platform: v6.optional(v6.enum(ProviderPlatform)),
|
|
421
478
|
/**
|
|
422
479
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
423
480
|
*/
|
|
@@ -805,146 +862,319 @@ var runesTransferRequestMessageSchema = v11.object({
|
|
|
805
862
|
}).entries
|
|
806
863
|
});
|
|
807
864
|
|
|
808
|
-
// src/request/types/sparkMethods/
|
|
865
|
+
// src/request/types/sparkMethods/flashnetMethods/getJwt.ts
|
|
809
866
|
import * as v12 from "valibot";
|
|
867
|
+
var sparkFlashnetGetJwtMethodName = "spark_flashnet_getJwt";
|
|
868
|
+
var sparkFlashnetGetJwtParamsSchema = v12.null();
|
|
869
|
+
var sparkFlashnetGetJwtResultSchema = v12.object({
|
|
870
|
+
/**
|
|
871
|
+
* The JWT token for authenticated requests to the Flashnet API.
|
|
872
|
+
*/
|
|
873
|
+
jwt: v12.string()
|
|
874
|
+
});
|
|
875
|
+
var sparkFlashnetGetJwtRequestMessageSchema = v12.object({
|
|
876
|
+
...rpcRequestMessageSchema.entries,
|
|
877
|
+
...v12.object({
|
|
878
|
+
method: v12.literal(sparkFlashnetGetJwtMethodName),
|
|
879
|
+
params: sparkFlashnetGetJwtParamsSchema,
|
|
880
|
+
id: v12.string()
|
|
881
|
+
}).entries
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/addLiquidity.ts
|
|
885
|
+
import * as v13 from "valibot";
|
|
886
|
+
var sparkFlashnetAddLiquidityIntentSchema = v13.object({
|
|
887
|
+
type: v13.literal("addLiquidity"),
|
|
888
|
+
data: v13.object({
|
|
889
|
+
userPublicKey: v13.string(),
|
|
890
|
+
poolId: v13.string(),
|
|
891
|
+
assetAAmount: v13.string(),
|
|
892
|
+
assetBAmount: v13.string(),
|
|
893
|
+
assetAMinAmountIn: v13.string(),
|
|
894
|
+
assetBMinAmountIn: v13.string(),
|
|
895
|
+
assetATransferId: v13.string(),
|
|
896
|
+
assetBTransferId: v13.string(),
|
|
897
|
+
nonce: v13.string()
|
|
898
|
+
})
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/clawback.ts
|
|
902
|
+
import * as v14 from "valibot";
|
|
903
|
+
var sparkFlashnetClawbackIntentSchema = v14.object({
|
|
904
|
+
type: v14.literal("clawback"),
|
|
905
|
+
data: v14.object({
|
|
906
|
+
senderPublicKey: v14.string(),
|
|
907
|
+
sparkTransferId: v14.string(),
|
|
908
|
+
lpIdentityPublicKey: v14.string(),
|
|
909
|
+
nonce: v14.string()
|
|
910
|
+
})
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/confirmInitialDeposit.ts
|
|
914
|
+
import * as v15 from "valibot";
|
|
915
|
+
var sparkFlashnetConfirmInitialDepositIntentSchema = v15.object({
|
|
916
|
+
type: v15.literal("confirmInitialDeposit"),
|
|
917
|
+
data: v15.object({
|
|
918
|
+
poolId: v15.string(),
|
|
919
|
+
assetASparkTransferId: v15.string(),
|
|
920
|
+
poolOwnerPublicKey: v15.string(),
|
|
921
|
+
nonce: v15.string()
|
|
922
|
+
})
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/createConstantProductPool.ts
|
|
926
|
+
import * as v16 from "valibot";
|
|
927
|
+
var sparkFlashnetCreateConstantProductPoolIntentSchema = v16.object({
|
|
928
|
+
type: v16.literal("createConstantProductPool"),
|
|
929
|
+
data: v16.object({
|
|
930
|
+
poolOwnerPublicKey: v16.string(),
|
|
931
|
+
assetAAddress: v16.string(),
|
|
932
|
+
assetBAddress: v16.string(),
|
|
933
|
+
lpFeeRateBps: v16.number(),
|
|
934
|
+
totalHostFeeRateBps: v16.number(),
|
|
935
|
+
nonce: v16.string()
|
|
936
|
+
})
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/createSingleSidedPool.ts
|
|
940
|
+
import * as v17 from "valibot";
|
|
941
|
+
var sparkFlashnetCreateSingleSidedPoolIntentSchema = v17.object({
|
|
942
|
+
type: v17.literal("createSingleSidedPool"),
|
|
943
|
+
data: v17.object({
|
|
944
|
+
assetAAddress: v17.string(),
|
|
945
|
+
assetBAddress: v17.string(),
|
|
946
|
+
assetAInitialReserve: v17.string(),
|
|
947
|
+
virtualReserveA: v17.union([v17.number(), v17.string()]),
|
|
948
|
+
virtualReserveB: v17.union([v17.number(), v17.string()]),
|
|
949
|
+
threshold: v17.union([v17.number(), v17.string()]),
|
|
950
|
+
lpFeeRateBps: v17.number(),
|
|
951
|
+
totalHostFeeRateBps: v17.number(),
|
|
952
|
+
poolOwnerPublicKey: v17.string(),
|
|
953
|
+
nonce: v17.string()
|
|
954
|
+
})
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/removeLiquidity.ts
|
|
958
|
+
import * as v18 from "valibot";
|
|
959
|
+
var sparkFlashnetRemoveLiquidityIntentSchema = v18.object({
|
|
960
|
+
type: v18.literal("removeLiquidity"),
|
|
961
|
+
data: v18.object({
|
|
962
|
+
userPublicKey: v18.string(),
|
|
963
|
+
poolId: v18.string(),
|
|
964
|
+
lpTokensToRemove: v18.string(),
|
|
965
|
+
nonce: v18.string()
|
|
966
|
+
})
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/routeSwap.ts
|
|
970
|
+
import * as v19 from "valibot";
|
|
971
|
+
var sparkFlashnetRouteSwapIntentSchema = v19.object({
|
|
972
|
+
type: v19.literal("executeRouteSwap"),
|
|
973
|
+
data: v19.object({
|
|
974
|
+
userPublicKey: v19.string(),
|
|
975
|
+
initialSparkTransferId: v19.string(),
|
|
976
|
+
hops: v19.array(
|
|
977
|
+
v19.object({
|
|
978
|
+
poolId: v19.string(),
|
|
979
|
+
inputAssetAddress: v19.string(),
|
|
980
|
+
outputAssetAddress: v19.string(),
|
|
981
|
+
hopIntegratorFeeRateBps: v19.optional(v19.number())
|
|
982
|
+
})
|
|
983
|
+
),
|
|
984
|
+
inputAmount: v19.string(),
|
|
985
|
+
maxRouteSlippageBps: v19.number(),
|
|
986
|
+
minAmountOut: v19.string(),
|
|
987
|
+
defaultIntegratorFeeRateBps: v19.optional(v19.number()),
|
|
988
|
+
nonce: v19.string()
|
|
989
|
+
})
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
// src/request/types/sparkMethods/flashnetMethods/intents/swap.ts
|
|
993
|
+
import * as v20 from "valibot";
|
|
994
|
+
var sparkFlashnetSwapIntentSchema = v20.object({
|
|
995
|
+
type: v20.literal("executeSwap"),
|
|
996
|
+
data: v20.object({
|
|
997
|
+
userPublicKey: v20.string(),
|
|
998
|
+
poolId: v20.string(),
|
|
999
|
+
transferId: v20.string(),
|
|
1000
|
+
assetInAddress: v20.string(),
|
|
1001
|
+
assetOutAddress: v20.string(),
|
|
1002
|
+
amountIn: v20.string(),
|
|
1003
|
+
maxSlippageBps: v20.number(),
|
|
1004
|
+
minAmountOut: v20.string(),
|
|
1005
|
+
totalIntegratorFeeRateBps: v20.optional(v20.number()),
|
|
1006
|
+
nonce: v20.string()
|
|
1007
|
+
})
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
// src/request/types/sparkMethods/flashnetMethods/signIntent.ts
|
|
1011
|
+
import * as v21 from "valibot";
|
|
1012
|
+
var sparkFlashnetSignIntentMethodName = "spark_flashnet_signIntent";
|
|
1013
|
+
var sparkFlashnetSignIntentParamsSchema = v21.union([
|
|
1014
|
+
sparkFlashnetSwapIntentSchema,
|
|
1015
|
+
sparkFlashnetRouteSwapIntentSchema,
|
|
1016
|
+
sparkFlashnetAddLiquidityIntentSchema,
|
|
1017
|
+
sparkFlashnetClawbackIntentSchema,
|
|
1018
|
+
sparkFlashnetConfirmInitialDepositIntentSchema,
|
|
1019
|
+
sparkFlashnetCreateConstantProductPoolIntentSchema,
|
|
1020
|
+
sparkFlashnetCreateSingleSidedPoolIntentSchema,
|
|
1021
|
+
sparkFlashnetRemoveLiquidityIntentSchema
|
|
1022
|
+
]);
|
|
1023
|
+
var sparkFlashnetSignIntentResultSchema = v21.object({
|
|
1024
|
+
/**
|
|
1025
|
+
* The signed intent as a hex string.
|
|
1026
|
+
*/
|
|
1027
|
+
signature: v21.string()
|
|
1028
|
+
});
|
|
1029
|
+
var sparkFlashnetSignIntentRequestMessageSchema = v21.object({
|
|
1030
|
+
...rpcRequestMessageSchema.entries,
|
|
1031
|
+
...v21.object({
|
|
1032
|
+
method: v21.literal(sparkFlashnetSignIntentMethodName),
|
|
1033
|
+
params: sparkFlashnetSignIntentParamsSchema,
|
|
1034
|
+
id: v21.string()
|
|
1035
|
+
}).entries
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
// src/request/types/sparkMethods/getAddresses.ts
|
|
1039
|
+
import * as v22 from "valibot";
|
|
810
1040
|
var sparkGetAddressesMethodName = "spark_getAddresses";
|
|
811
|
-
var sparkGetAddressesParamsSchema =
|
|
812
|
-
|
|
1041
|
+
var sparkGetAddressesParamsSchema = v22.nullish(
|
|
1042
|
+
v22.object({
|
|
813
1043
|
/**
|
|
814
1044
|
* A message to be displayed to the user in the request prompt.
|
|
815
1045
|
*/
|
|
816
|
-
message:
|
|
1046
|
+
message: v22.optional(v22.string())
|
|
817
1047
|
})
|
|
818
1048
|
);
|
|
819
|
-
var sparkGetAddressesResultSchema =
|
|
1049
|
+
var sparkGetAddressesResultSchema = v22.object({
|
|
820
1050
|
/**
|
|
821
1051
|
* The addresses generated for the given purposes.
|
|
822
1052
|
*/
|
|
823
|
-
addresses:
|
|
1053
|
+
addresses: v22.array(addressSchema),
|
|
824
1054
|
network: getNetworkResultSchema
|
|
825
1055
|
});
|
|
826
|
-
var sparkGetAddressesRequestMessageSchema =
|
|
1056
|
+
var sparkGetAddressesRequestMessageSchema = v22.object({
|
|
827
1057
|
...rpcRequestMessageSchema.entries,
|
|
828
|
-
...
|
|
829
|
-
method:
|
|
1058
|
+
...v22.object({
|
|
1059
|
+
method: v22.literal(sparkGetAddressesMethodName),
|
|
830
1060
|
params: sparkGetAddressesParamsSchema,
|
|
831
|
-
id:
|
|
1061
|
+
id: v22.string()
|
|
832
1062
|
}).entries
|
|
833
1063
|
});
|
|
834
1064
|
|
|
835
1065
|
// src/request/types/sparkMethods/getBalance.ts
|
|
836
|
-
import * as
|
|
1066
|
+
import * as v23 from "valibot";
|
|
837
1067
|
var sparkGetBalanceMethodName = "spark_getBalance";
|
|
838
|
-
var sparkGetBalanceParamsSchema =
|
|
839
|
-
var sparkGetBalanceResultSchema =
|
|
1068
|
+
var sparkGetBalanceParamsSchema = v23.nullish(v23.null());
|
|
1069
|
+
var sparkGetBalanceResultSchema = v23.object({
|
|
840
1070
|
/**
|
|
841
1071
|
* The Spark Bitcoin address balance in sats in string form.
|
|
842
1072
|
*/
|
|
843
|
-
balance:
|
|
844
|
-
tokenBalances:
|
|
845
|
-
|
|
1073
|
+
balance: v23.string(),
|
|
1074
|
+
tokenBalances: v23.array(
|
|
1075
|
+
v23.object({
|
|
846
1076
|
/* The address balance of the token in string form as it can overflow a js number */
|
|
847
|
-
balance:
|
|
848
|
-
tokenMetadata:
|
|
849
|
-
tokenIdentifier:
|
|
850
|
-
tokenName:
|
|
851
|
-
tokenTicker:
|
|
852
|
-
decimals:
|
|
853
|
-
maxSupply:
|
|
1077
|
+
balance: v23.string(),
|
|
1078
|
+
tokenMetadata: v23.object({
|
|
1079
|
+
tokenIdentifier: v23.string(),
|
|
1080
|
+
tokenName: v23.string(),
|
|
1081
|
+
tokenTicker: v23.string(),
|
|
1082
|
+
decimals: v23.number(),
|
|
1083
|
+
maxSupply: v23.string()
|
|
854
1084
|
})
|
|
855
1085
|
})
|
|
856
1086
|
)
|
|
857
1087
|
});
|
|
858
|
-
var sparkGetBalanceRequestMessageSchema =
|
|
1088
|
+
var sparkGetBalanceRequestMessageSchema = v23.object({
|
|
859
1089
|
...rpcRequestMessageSchema.entries,
|
|
860
|
-
...
|
|
861
|
-
method:
|
|
1090
|
+
...v23.object({
|
|
1091
|
+
method: v23.literal(sparkGetBalanceMethodName),
|
|
862
1092
|
params: sparkGetBalanceParamsSchema,
|
|
863
|
-
id:
|
|
1093
|
+
id: v23.string()
|
|
864
1094
|
}).entries
|
|
865
1095
|
});
|
|
866
1096
|
|
|
867
1097
|
// src/request/types/sparkMethods/transfer.ts
|
|
868
|
-
import * as
|
|
1098
|
+
import * as v24 from "valibot";
|
|
869
1099
|
var sparkTransferMethodName = "spark_transfer";
|
|
870
|
-
var sparkTransferParamsSchema =
|
|
1100
|
+
var sparkTransferParamsSchema = v24.object({
|
|
871
1101
|
/**
|
|
872
1102
|
* Amount of SATS to transfer as a string or number.
|
|
873
1103
|
*/
|
|
874
|
-
amountSats:
|
|
1104
|
+
amountSats: v24.union([v24.number(), v24.string()]),
|
|
875
1105
|
/**
|
|
876
1106
|
* The recipient's spark address.
|
|
877
1107
|
*/
|
|
878
|
-
receiverSparkAddress:
|
|
1108
|
+
receiverSparkAddress: v24.string()
|
|
879
1109
|
});
|
|
880
|
-
var sparkTransferResultSchema =
|
|
1110
|
+
var sparkTransferResultSchema = v24.object({
|
|
881
1111
|
/**
|
|
882
1112
|
* The ID of the transaction.
|
|
883
1113
|
*/
|
|
884
|
-
id:
|
|
1114
|
+
id: v24.string()
|
|
885
1115
|
});
|
|
886
|
-
var sparkTransferRequestMessageSchema =
|
|
1116
|
+
var sparkTransferRequestMessageSchema = v24.object({
|
|
887
1117
|
...rpcRequestMessageSchema.entries,
|
|
888
|
-
...
|
|
889
|
-
method:
|
|
1118
|
+
...v24.object({
|
|
1119
|
+
method: v24.literal(sparkTransferMethodName),
|
|
890
1120
|
params: sparkTransferParamsSchema,
|
|
891
|
-
id:
|
|
1121
|
+
id: v24.string()
|
|
892
1122
|
}).entries
|
|
893
1123
|
});
|
|
894
1124
|
|
|
895
1125
|
// src/request/types/sparkMethods/transferToken.ts
|
|
896
|
-
import * as
|
|
1126
|
+
import * as v25 from "valibot";
|
|
897
1127
|
var sparkTransferTokenMethodName = "spark_transferToken";
|
|
898
|
-
var sparkTransferTokenParamsSchema =
|
|
1128
|
+
var sparkTransferTokenParamsSchema = v25.object({
|
|
899
1129
|
/**
|
|
900
1130
|
* Amount of units of the token to transfer as a string or number.
|
|
901
1131
|
*/
|
|
902
|
-
tokenAmount:
|
|
1132
|
+
tokenAmount: v25.union([v25.number(), v25.string()]),
|
|
903
1133
|
/**
|
|
904
1134
|
* The Bech32m token identifier.
|
|
905
1135
|
*/
|
|
906
|
-
tokenIdentifier:
|
|
1136
|
+
tokenIdentifier: v25.string(),
|
|
907
1137
|
/**
|
|
908
1138
|
* The recipient's spark address.
|
|
909
1139
|
*/
|
|
910
|
-
receiverSparkAddress:
|
|
1140
|
+
receiverSparkAddress: v25.string()
|
|
911
1141
|
});
|
|
912
|
-
var sparkTransferTokenResultSchema =
|
|
1142
|
+
var sparkTransferTokenResultSchema = v25.object({
|
|
913
1143
|
/**
|
|
914
1144
|
* The ID of the transaction.
|
|
915
1145
|
*/
|
|
916
|
-
id:
|
|
1146
|
+
id: v25.string()
|
|
917
1147
|
});
|
|
918
|
-
var sparkTransferTokenRequestMessageSchema =
|
|
1148
|
+
var sparkTransferTokenRequestMessageSchema = v25.object({
|
|
919
1149
|
...rpcRequestMessageSchema.entries,
|
|
920
|
-
...
|
|
921
|
-
method:
|
|
1150
|
+
...v25.object({
|
|
1151
|
+
method: v25.literal(sparkTransferTokenMethodName),
|
|
922
1152
|
params: sparkTransferTokenParamsSchema,
|
|
923
|
-
id:
|
|
1153
|
+
id: v25.string()
|
|
924
1154
|
}).entries
|
|
925
1155
|
});
|
|
926
1156
|
|
|
927
1157
|
// src/request/types/stxMethods/callContract.ts
|
|
928
|
-
import * as
|
|
1158
|
+
import * as v26 from "valibot";
|
|
929
1159
|
var stxCallContractMethodName = "stx_callContract";
|
|
930
|
-
var stxCallContractParamsSchema =
|
|
1160
|
+
var stxCallContractParamsSchema = v26.object({
|
|
931
1161
|
/**
|
|
932
1162
|
* The contract principal.
|
|
933
1163
|
*
|
|
934
1164
|
* E.g. `"SPKE...GD5C.my-contract"`
|
|
935
1165
|
*/
|
|
936
|
-
contract:
|
|
1166
|
+
contract: v26.string(),
|
|
937
1167
|
/**
|
|
938
1168
|
* The name of the function to call.
|
|
939
1169
|
*
|
|
940
1170
|
* Note: spec changes ongoing,
|
|
941
1171
|
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
942
1172
|
*/
|
|
943
|
-
functionName:
|
|
1173
|
+
functionName: v26.string(),
|
|
944
1174
|
/**
|
|
945
1175
|
* @deprecated in favor of `functionArgs` for @stacks/connect compatibility
|
|
946
1176
|
*/
|
|
947
|
-
arguments:
|
|
1177
|
+
arguments: v26.optional(v26.array(v26.string())),
|
|
948
1178
|
/**
|
|
949
1179
|
* The function's arguments. The arguments are expected to be hex-encoded
|
|
950
1180
|
* strings of Clarity values.
|
|
@@ -959,274 +1189,274 @@ var stxCallContractParamsSchema = v16.object({
|
|
|
959
1189
|
* const hexArgs = functionArgs.map(cvToHex);
|
|
960
1190
|
* ```
|
|
961
1191
|
*/
|
|
962
|
-
functionArgs:
|
|
1192
|
+
functionArgs: v26.optional(v26.array(v26.string())),
|
|
963
1193
|
/**
|
|
964
1194
|
* The post conditions to apply to the contract call.
|
|
965
1195
|
*/
|
|
966
|
-
postConditions:
|
|
1196
|
+
postConditions: v26.optional(v26.array(v26.string())),
|
|
967
1197
|
/**
|
|
968
1198
|
* The mode to apply to the post conditions.
|
|
969
1199
|
*/
|
|
970
|
-
postConditionMode:
|
|
1200
|
+
postConditionMode: v26.optional(v26.union([v26.literal("allow"), v26.literal("deny")]))
|
|
971
1201
|
});
|
|
972
|
-
var stxCallContractResultSchema =
|
|
1202
|
+
var stxCallContractResultSchema = v26.object({
|
|
973
1203
|
/**
|
|
974
1204
|
* The ID of the transaction.
|
|
975
1205
|
*/
|
|
976
|
-
txid:
|
|
1206
|
+
txid: v26.string(),
|
|
977
1207
|
/**
|
|
978
1208
|
* A Stacks transaction as a hex-encoded string.
|
|
979
1209
|
*/
|
|
980
|
-
transaction:
|
|
1210
|
+
transaction: v26.string()
|
|
981
1211
|
});
|
|
982
|
-
var stxCallContractRequestMessageSchema =
|
|
1212
|
+
var stxCallContractRequestMessageSchema = v26.object({
|
|
983
1213
|
...rpcRequestMessageSchema.entries,
|
|
984
|
-
...
|
|
985
|
-
method:
|
|
1214
|
+
...v26.object({
|
|
1215
|
+
method: v26.literal(stxCallContractMethodName),
|
|
986
1216
|
params: stxCallContractParamsSchema,
|
|
987
|
-
id:
|
|
1217
|
+
id: v26.string()
|
|
988
1218
|
}).entries
|
|
989
1219
|
});
|
|
990
1220
|
|
|
991
1221
|
// src/request/types/stxMethods/deployContract.ts
|
|
992
|
-
import * as
|
|
1222
|
+
import * as v27 from "valibot";
|
|
993
1223
|
var stxDeployContractMethodName = "stx_deployContract";
|
|
994
|
-
var stxDeployContractParamsSchema =
|
|
1224
|
+
var stxDeployContractParamsSchema = v27.object({
|
|
995
1225
|
/**
|
|
996
1226
|
* Name of the contract.
|
|
997
1227
|
*/
|
|
998
|
-
name:
|
|
1228
|
+
name: v27.string(),
|
|
999
1229
|
/**
|
|
1000
1230
|
* The source code of the Clarity contract.
|
|
1001
1231
|
*/
|
|
1002
|
-
clarityCode:
|
|
1232
|
+
clarityCode: v27.string(),
|
|
1003
1233
|
/**
|
|
1004
1234
|
* The version of the Clarity contract.
|
|
1005
1235
|
*/
|
|
1006
|
-
clarityVersion:
|
|
1236
|
+
clarityVersion: v27.optional(v27.number()),
|
|
1007
1237
|
/**
|
|
1008
1238
|
* The post conditions to apply to the contract call.
|
|
1009
1239
|
*/
|
|
1010
|
-
postConditions:
|
|
1240
|
+
postConditions: v27.optional(v27.array(v27.string())),
|
|
1011
1241
|
/**
|
|
1012
1242
|
* The mode to apply to the post conditions.
|
|
1013
1243
|
*/
|
|
1014
|
-
postConditionMode:
|
|
1244
|
+
postConditionMode: v27.optional(v27.union([v27.literal("allow"), v27.literal("deny")]))
|
|
1015
1245
|
});
|
|
1016
|
-
var stxDeployContractResultSchema =
|
|
1246
|
+
var stxDeployContractResultSchema = v27.object({
|
|
1017
1247
|
/**
|
|
1018
1248
|
* The ID of the transaction.
|
|
1019
1249
|
*/
|
|
1020
|
-
txid:
|
|
1250
|
+
txid: v27.string(),
|
|
1021
1251
|
/**
|
|
1022
1252
|
* A Stacks transaction as a hex-encoded string.
|
|
1023
1253
|
*/
|
|
1024
|
-
transaction:
|
|
1254
|
+
transaction: v27.string()
|
|
1025
1255
|
});
|
|
1026
|
-
var stxDeployContractRequestMessageSchema =
|
|
1256
|
+
var stxDeployContractRequestMessageSchema = v27.object({
|
|
1027
1257
|
...rpcRequestMessageSchema.entries,
|
|
1028
|
-
...
|
|
1029
|
-
method:
|
|
1258
|
+
...v27.object({
|
|
1259
|
+
method: v27.literal(stxDeployContractMethodName),
|
|
1030
1260
|
params: stxDeployContractParamsSchema,
|
|
1031
|
-
id:
|
|
1261
|
+
id: v27.string()
|
|
1032
1262
|
}).entries
|
|
1033
1263
|
});
|
|
1034
1264
|
|
|
1035
1265
|
// src/request/types/stxMethods/getAccounts.ts
|
|
1036
|
-
import * as
|
|
1266
|
+
import * as v28 from "valibot";
|
|
1037
1267
|
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
1038
|
-
var stxGetAccountsParamsSchema =
|
|
1039
|
-
var stxGetAccountsResultSchema =
|
|
1268
|
+
var stxGetAccountsParamsSchema = v28.nullish(v28.null());
|
|
1269
|
+
var stxGetAccountsResultSchema = v28.object({
|
|
1040
1270
|
/**
|
|
1041
1271
|
* The addresses generated for the given purposes.
|
|
1042
1272
|
*/
|
|
1043
|
-
addresses:
|
|
1044
|
-
|
|
1045
|
-
address:
|
|
1046
|
-
publicKey:
|
|
1047
|
-
gaiaHubUrl:
|
|
1048
|
-
gaiaAppKey:
|
|
1273
|
+
addresses: v28.array(
|
|
1274
|
+
v28.object({
|
|
1275
|
+
address: v28.string(),
|
|
1276
|
+
publicKey: v28.string(),
|
|
1277
|
+
gaiaHubUrl: v28.string(),
|
|
1278
|
+
gaiaAppKey: v28.string()
|
|
1049
1279
|
})
|
|
1050
1280
|
),
|
|
1051
1281
|
network: getNetworkResultSchema
|
|
1052
1282
|
});
|
|
1053
|
-
var stxGetAccountsRequestMessageSchema =
|
|
1283
|
+
var stxGetAccountsRequestMessageSchema = v28.object({
|
|
1054
1284
|
...rpcRequestMessageSchema.entries,
|
|
1055
|
-
...
|
|
1056
|
-
method:
|
|
1285
|
+
...v28.object({
|
|
1286
|
+
method: v28.literal(stxGetAccountsMethodName),
|
|
1057
1287
|
params: stxGetAccountsParamsSchema,
|
|
1058
|
-
id:
|
|
1288
|
+
id: v28.string()
|
|
1059
1289
|
}).entries
|
|
1060
1290
|
});
|
|
1061
1291
|
|
|
1062
1292
|
// src/request/types/stxMethods/getAddresses.ts
|
|
1063
|
-
import * as
|
|
1293
|
+
import * as v29 from "valibot";
|
|
1064
1294
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
1065
|
-
var stxGetAddressesParamsSchema =
|
|
1066
|
-
|
|
1295
|
+
var stxGetAddressesParamsSchema = v29.nullish(
|
|
1296
|
+
v29.object({
|
|
1067
1297
|
/**
|
|
1068
1298
|
* A message to be displayed to the user in the request prompt.
|
|
1069
1299
|
*/
|
|
1070
|
-
message:
|
|
1300
|
+
message: v29.optional(v29.string())
|
|
1071
1301
|
})
|
|
1072
1302
|
);
|
|
1073
|
-
var stxGetAddressesResultSchema =
|
|
1303
|
+
var stxGetAddressesResultSchema = v29.object({
|
|
1074
1304
|
/**
|
|
1075
1305
|
* The addresses generated for the given purposes.
|
|
1076
1306
|
*/
|
|
1077
|
-
addresses:
|
|
1307
|
+
addresses: v29.array(addressSchema),
|
|
1078
1308
|
network: getNetworkResultSchema
|
|
1079
1309
|
});
|
|
1080
|
-
var stxGetAddressesRequestMessageSchema =
|
|
1310
|
+
var stxGetAddressesRequestMessageSchema = v29.object({
|
|
1081
1311
|
...rpcRequestMessageSchema.entries,
|
|
1082
|
-
...
|
|
1083
|
-
method:
|
|
1312
|
+
...v29.object({
|
|
1313
|
+
method: v29.literal(stxGetAddressesMethodName),
|
|
1084
1314
|
params: stxGetAddressesParamsSchema,
|
|
1085
|
-
id:
|
|
1315
|
+
id: v29.string()
|
|
1086
1316
|
}).entries
|
|
1087
1317
|
});
|
|
1088
1318
|
|
|
1089
1319
|
// src/request/types/stxMethods/signMessage.ts
|
|
1090
|
-
import * as
|
|
1320
|
+
import * as v30 from "valibot";
|
|
1091
1321
|
var stxSignMessageMethodName = "stx_signMessage";
|
|
1092
|
-
var stxSignMessageParamsSchema =
|
|
1322
|
+
var stxSignMessageParamsSchema = v30.object({
|
|
1093
1323
|
/**
|
|
1094
1324
|
* The message to sign.
|
|
1095
1325
|
*/
|
|
1096
|
-
message:
|
|
1326
|
+
message: v30.string()
|
|
1097
1327
|
});
|
|
1098
|
-
var stxSignMessageResultSchema =
|
|
1328
|
+
var stxSignMessageResultSchema = v30.object({
|
|
1099
1329
|
/**
|
|
1100
1330
|
* The signature of the message.
|
|
1101
1331
|
*/
|
|
1102
|
-
signature:
|
|
1332
|
+
signature: v30.string(),
|
|
1103
1333
|
/**
|
|
1104
1334
|
* The public key used to sign the message.
|
|
1105
1335
|
*/
|
|
1106
|
-
publicKey:
|
|
1336
|
+
publicKey: v30.string()
|
|
1107
1337
|
});
|
|
1108
|
-
var stxSignMessageRequestMessageSchema =
|
|
1338
|
+
var stxSignMessageRequestMessageSchema = v30.object({
|
|
1109
1339
|
...rpcRequestMessageSchema.entries,
|
|
1110
|
-
...
|
|
1111
|
-
method:
|
|
1340
|
+
...v30.object({
|
|
1341
|
+
method: v30.literal(stxSignMessageMethodName),
|
|
1112
1342
|
params: stxSignMessageParamsSchema,
|
|
1113
|
-
id:
|
|
1343
|
+
id: v30.string()
|
|
1114
1344
|
}).entries
|
|
1115
1345
|
});
|
|
1116
1346
|
|
|
1117
1347
|
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
1118
|
-
import * as
|
|
1348
|
+
import * as v31 from "valibot";
|
|
1119
1349
|
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
1120
|
-
var stxSignStructuredMessageParamsSchema =
|
|
1350
|
+
var stxSignStructuredMessageParamsSchema = v31.object({
|
|
1121
1351
|
/**
|
|
1122
1352
|
* The domain to be signed.
|
|
1123
1353
|
*/
|
|
1124
|
-
domain:
|
|
1354
|
+
domain: v31.string(),
|
|
1125
1355
|
/**
|
|
1126
1356
|
* Message payload to be signed.
|
|
1127
1357
|
*/
|
|
1128
|
-
message:
|
|
1358
|
+
message: v31.string(),
|
|
1129
1359
|
/**
|
|
1130
1360
|
* The public key to sign the message with.
|
|
1131
1361
|
*/
|
|
1132
|
-
publicKey:
|
|
1362
|
+
publicKey: v31.optional(v31.string())
|
|
1133
1363
|
});
|
|
1134
|
-
var stxSignStructuredMessageResultSchema =
|
|
1364
|
+
var stxSignStructuredMessageResultSchema = v31.object({
|
|
1135
1365
|
/**
|
|
1136
1366
|
* Signature of the message.
|
|
1137
1367
|
*/
|
|
1138
|
-
signature:
|
|
1368
|
+
signature: v31.string(),
|
|
1139
1369
|
/**
|
|
1140
1370
|
* Public key as hex-encoded string.
|
|
1141
1371
|
*/
|
|
1142
|
-
publicKey:
|
|
1372
|
+
publicKey: v31.string()
|
|
1143
1373
|
});
|
|
1144
|
-
var stxSignStructuredMessageRequestMessageSchema =
|
|
1374
|
+
var stxSignStructuredMessageRequestMessageSchema = v31.object({
|
|
1145
1375
|
...rpcRequestMessageSchema.entries,
|
|
1146
|
-
...
|
|
1147
|
-
method:
|
|
1376
|
+
...v31.object({
|
|
1377
|
+
method: v31.literal(stxSignStructuredMessageMethodName),
|
|
1148
1378
|
params: stxSignStructuredMessageParamsSchema,
|
|
1149
|
-
id:
|
|
1379
|
+
id: v31.string()
|
|
1150
1380
|
}).entries
|
|
1151
1381
|
});
|
|
1152
1382
|
|
|
1153
1383
|
// src/request/types/stxMethods/signTransaction.ts
|
|
1154
|
-
import * as
|
|
1384
|
+
import * as v32 from "valibot";
|
|
1155
1385
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
1156
|
-
var stxSignTransactionParamsSchema =
|
|
1386
|
+
var stxSignTransactionParamsSchema = v32.object({
|
|
1157
1387
|
/**
|
|
1158
1388
|
* The transaction to sign as a hex-encoded string.
|
|
1159
1389
|
*/
|
|
1160
|
-
transaction:
|
|
1390
|
+
transaction: v32.string(),
|
|
1161
1391
|
/**
|
|
1162
1392
|
* The public key to sign the transaction with. The wallet may use any key
|
|
1163
1393
|
* when not provided.
|
|
1164
1394
|
*/
|
|
1165
|
-
pubkey:
|
|
1395
|
+
pubkey: v32.optional(v32.string()),
|
|
1166
1396
|
/**
|
|
1167
1397
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
1168
1398
|
*/
|
|
1169
|
-
broadcast:
|
|
1399
|
+
broadcast: v32.optional(v32.boolean())
|
|
1170
1400
|
});
|
|
1171
|
-
var stxSignTransactionResultSchema =
|
|
1401
|
+
var stxSignTransactionResultSchema = v32.object({
|
|
1172
1402
|
/**
|
|
1173
1403
|
* The signed transaction as a hex-encoded string.
|
|
1174
1404
|
*/
|
|
1175
|
-
transaction:
|
|
1405
|
+
transaction: v32.string()
|
|
1176
1406
|
});
|
|
1177
|
-
var stxSignTransactionRequestMessageSchema =
|
|
1407
|
+
var stxSignTransactionRequestMessageSchema = v32.object({
|
|
1178
1408
|
...rpcRequestMessageSchema.entries,
|
|
1179
|
-
...
|
|
1180
|
-
method:
|
|
1409
|
+
...v32.object({
|
|
1410
|
+
method: v32.literal(stxSignTransactionMethodName),
|
|
1181
1411
|
params: stxSignTransactionParamsSchema,
|
|
1182
|
-
id:
|
|
1412
|
+
id: v32.string()
|
|
1183
1413
|
}).entries
|
|
1184
1414
|
});
|
|
1185
1415
|
|
|
1186
1416
|
// src/request/types/stxMethods/signTransactions.ts
|
|
1187
|
-
import * as
|
|
1417
|
+
import * as v33 from "valibot";
|
|
1188
1418
|
var stxSignTransactionsMethodName = "stx_signTransactions";
|
|
1189
|
-
var stxSignTransactionsParamsSchema =
|
|
1419
|
+
var stxSignTransactionsParamsSchema = v33.object({
|
|
1190
1420
|
/**
|
|
1191
1421
|
* The transactions to sign as hex-encoded strings.
|
|
1192
1422
|
*/
|
|
1193
|
-
transactions:
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1423
|
+
transactions: v33.pipe(
|
|
1424
|
+
v33.array(
|
|
1425
|
+
v33.pipe(
|
|
1426
|
+
v33.string(),
|
|
1427
|
+
v33.check((hex) => {
|
|
1198
1428
|
return true;
|
|
1199
1429
|
}, "Invalid hex-encoded Stacks transaction.")
|
|
1200
1430
|
)
|
|
1201
1431
|
),
|
|
1202
|
-
|
|
1432
|
+
v33.minLength(1)
|
|
1203
1433
|
),
|
|
1204
1434
|
/**
|
|
1205
1435
|
* Whether the signed transactions should be broadcast after signing. Defaults
|
|
1206
1436
|
* to `true`.
|
|
1207
1437
|
*/
|
|
1208
|
-
broadcast:
|
|
1438
|
+
broadcast: v33.optional(v33.boolean())
|
|
1209
1439
|
});
|
|
1210
|
-
var stxSignTransactionsResultSchema =
|
|
1440
|
+
var stxSignTransactionsResultSchema = v33.object({
|
|
1211
1441
|
/**
|
|
1212
1442
|
* The signed transactions as hex-encoded strings, in the same order as in the
|
|
1213
1443
|
* sign request.
|
|
1214
1444
|
*/
|
|
1215
|
-
transactions:
|
|
1445
|
+
transactions: v33.array(v33.string())
|
|
1216
1446
|
});
|
|
1217
|
-
var stxSignTransactionsRequestMessageSchema =
|
|
1447
|
+
var stxSignTransactionsRequestMessageSchema = v33.object({
|
|
1218
1448
|
...rpcRequestMessageSchema.entries,
|
|
1219
|
-
...
|
|
1220
|
-
method:
|
|
1449
|
+
...v33.object({
|
|
1450
|
+
method: v33.literal(stxSignTransactionsMethodName),
|
|
1221
1451
|
params: stxSignTransactionsParamsSchema,
|
|
1222
|
-
id:
|
|
1452
|
+
id: v33.string()
|
|
1223
1453
|
}).entries
|
|
1224
1454
|
});
|
|
1225
1455
|
|
|
1226
1456
|
// src/request/types/stxMethods/transferStx.ts
|
|
1227
|
-
import * as
|
|
1457
|
+
import * as v34 from "valibot";
|
|
1228
1458
|
var stxTransferStxMethodName = "stx_transferStx";
|
|
1229
|
-
var stxTransferStxParamsSchema =
|
|
1459
|
+
var stxTransferStxParamsSchema = v34.object({
|
|
1230
1460
|
/**
|
|
1231
1461
|
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
1232
1462
|
* parseable by `BigInt` is acceptable.
|
|
@@ -1239,23 +1469,23 @@ var stxTransferStxParamsSchema = v24.object({
|
|
|
1239
1469
|
* const amount3 = '1234';
|
|
1240
1470
|
* ```
|
|
1241
1471
|
*/
|
|
1242
|
-
amount:
|
|
1472
|
+
amount: v34.union([v34.number(), v34.string()]),
|
|
1243
1473
|
/**
|
|
1244
1474
|
* The recipient's principal.
|
|
1245
1475
|
*/
|
|
1246
|
-
recipient:
|
|
1476
|
+
recipient: v34.string(),
|
|
1247
1477
|
/**
|
|
1248
1478
|
* A string representing the memo.
|
|
1249
1479
|
*/
|
|
1250
|
-
memo:
|
|
1480
|
+
memo: v34.optional(v34.string()),
|
|
1251
1481
|
/**
|
|
1252
1482
|
* Version of parameter format.
|
|
1253
1483
|
*/
|
|
1254
|
-
version:
|
|
1484
|
+
version: v34.optional(v34.string()),
|
|
1255
1485
|
/**
|
|
1256
1486
|
* The mode of the post conditions.
|
|
1257
1487
|
*/
|
|
1258
|
-
postConditionMode:
|
|
1488
|
+
postConditionMode: v34.optional(v34.number()),
|
|
1259
1489
|
/**
|
|
1260
1490
|
* A hex-encoded string representing the post conditions.
|
|
1261
1491
|
*
|
|
@@ -1268,52 +1498,43 @@ var stxTransferStxParamsSchema = v24.object({
|
|
|
1268
1498
|
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
1269
1499
|
* ```
|
|
1270
1500
|
*/
|
|
1271
|
-
postConditions:
|
|
1501
|
+
postConditions: v34.optional(v34.array(v34.string())),
|
|
1272
1502
|
/**
|
|
1273
1503
|
* The public key to sign the transaction with. The wallet may use any key
|
|
1274
1504
|
* when not provided.
|
|
1275
1505
|
*/
|
|
1276
|
-
pubkey:
|
|
1506
|
+
pubkey: v34.optional(v34.string())
|
|
1277
1507
|
});
|
|
1278
|
-
var stxTransferStxResultSchema =
|
|
1508
|
+
var stxTransferStxResultSchema = v34.object({
|
|
1279
1509
|
/**
|
|
1280
1510
|
* The ID of the transaction.
|
|
1281
1511
|
*/
|
|
1282
|
-
txid:
|
|
1512
|
+
txid: v34.string(),
|
|
1283
1513
|
/**
|
|
1284
1514
|
* A Stacks transaction as a hex-encoded string.
|
|
1285
1515
|
*/
|
|
1286
|
-
transaction:
|
|
1516
|
+
transaction: v34.string()
|
|
1287
1517
|
});
|
|
1288
|
-
var stxTransferStxRequestMessageSchema =
|
|
1518
|
+
var stxTransferStxRequestMessageSchema = v34.object({
|
|
1289
1519
|
...rpcRequestMessageSchema.entries,
|
|
1290
|
-
...
|
|
1291
|
-
method:
|
|
1520
|
+
...v34.object({
|
|
1521
|
+
method: v34.literal(stxTransferStxMethodName),
|
|
1292
1522
|
params: stxTransferStxParamsSchema,
|
|
1293
|
-
id:
|
|
1523
|
+
id: v34.string()
|
|
1294
1524
|
}).entries
|
|
1295
1525
|
});
|
|
1296
1526
|
|
|
1297
1527
|
// src/request/index.ts
|
|
1298
|
-
var
|
|
1299
|
-
|
|
1300
|
-
if (providerId) {
|
|
1301
|
-
provider = await getProviderById(providerId);
|
|
1302
|
-
}
|
|
1303
|
-
if (!provider) {
|
|
1304
|
-
throw new Error("no wallet provider was found");
|
|
1305
|
-
}
|
|
1306
|
-
if (!method) {
|
|
1307
|
-
throw new Error("A wallet method is required");
|
|
1308
|
-
}
|
|
1528
|
+
var cache = {};
|
|
1529
|
+
var requestInternal = async (provider, method, params) => {
|
|
1309
1530
|
const response = await provider.request(method, params);
|
|
1310
|
-
if (
|
|
1531
|
+
if (v35.is(rpcErrorResponseMessageSchema, response)) {
|
|
1311
1532
|
return {
|
|
1312
1533
|
status: "error",
|
|
1313
1534
|
error: response.error
|
|
1314
1535
|
};
|
|
1315
1536
|
}
|
|
1316
|
-
if (
|
|
1537
|
+
if (v35.is(rpcSuccessResponseMessageSchema, response)) {
|
|
1317
1538
|
return {
|
|
1318
1539
|
status: "success",
|
|
1319
1540
|
result: response.result
|
|
@@ -1328,6 +1549,39 @@ var request = async (method, params, providerId) => {
|
|
|
1328
1549
|
}
|
|
1329
1550
|
};
|
|
1330
1551
|
};
|
|
1552
|
+
var request = async (method, params, providerId) => {
|
|
1553
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
1554
|
+
if (providerId) {
|
|
1555
|
+
provider = await getProviderById(providerId);
|
|
1556
|
+
}
|
|
1557
|
+
if (!provider) {
|
|
1558
|
+
throw new Error("no wallet provider was found");
|
|
1559
|
+
}
|
|
1560
|
+
if (!method) {
|
|
1561
|
+
throw new Error("A wallet method is required");
|
|
1562
|
+
}
|
|
1563
|
+
if (!cache.providerInfo) {
|
|
1564
|
+
const infoResult = await requestInternal(provider, "getInfo", null);
|
|
1565
|
+
if (infoResult.status === "success") {
|
|
1566
|
+
cache.providerInfo = infoResult.result;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
if (cache.providerInfo) {
|
|
1570
|
+
if (method === "getInfo") {
|
|
1571
|
+
return {
|
|
1572
|
+
status: "success",
|
|
1573
|
+
result: cache.providerInfo
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
const sanitized = sanitizeRequest(method, params, cache.providerInfo);
|
|
1577
|
+
if (sanitized.overrideResponse) {
|
|
1578
|
+
return sanitized.overrideResponse;
|
|
1579
|
+
}
|
|
1580
|
+
method = sanitized.method;
|
|
1581
|
+
params = sanitized.params;
|
|
1582
|
+
}
|
|
1583
|
+
return requestInternal(provider, method, params);
|
|
1584
|
+
};
|
|
1331
1585
|
var addListener = (...rawArgs) => {
|
|
1332
1586
|
const [listenerInfo, providerId] = (() => {
|
|
1333
1587
|
if (rawArgs.length === 1) {
|
|
@@ -2332,6 +2586,7 @@ export {
|
|
|
2332
2586
|
DefaultAdaptersInfo,
|
|
2333
2587
|
MessageSigningProtocols,
|
|
2334
2588
|
PermissionRequestParams,
|
|
2589
|
+
ProviderPlatform,
|
|
2335
2590
|
RpcErrorCode,
|
|
2336
2591
|
RpcIdSchema,
|
|
2337
2592
|
SatsConnectAdapter,
|
|
@@ -2467,6 +2722,22 @@ export {
|
|
|
2467
2722
|
signPsbtRequestMessageSchema,
|
|
2468
2723
|
signPsbtResultSchema,
|
|
2469
2724
|
signTransaction,
|
|
2725
|
+
sparkFlashnetAddLiquidityIntentSchema,
|
|
2726
|
+
sparkFlashnetClawbackIntentSchema,
|
|
2727
|
+
sparkFlashnetConfirmInitialDepositIntentSchema,
|
|
2728
|
+
sparkFlashnetCreateConstantProductPoolIntentSchema,
|
|
2729
|
+
sparkFlashnetCreateSingleSidedPoolIntentSchema,
|
|
2730
|
+
sparkFlashnetGetJwtMethodName,
|
|
2731
|
+
sparkFlashnetGetJwtParamsSchema,
|
|
2732
|
+
sparkFlashnetGetJwtRequestMessageSchema,
|
|
2733
|
+
sparkFlashnetGetJwtResultSchema,
|
|
2734
|
+
sparkFlashnetRemoveLiquidityIntentSchema,
|
|
2735
|
+
sparkFlashnetRouteSwapIntentSchema,
|
|
2736
|
+
sparkFlashnetSignIntentMethodName,
|
|
2737
|
+
sparkFlashnetSignIntentParamsSchema,
|
|
2738
|
+
sparkFlashnetSignIntentRequestMessageSchema,
|
|
2739
|
+
sparkFlashnetSignIntentResultSchema,
|
|
2740
|
+
sparkFlashnetSwapIntentSchema,
|
|
2470
2741
|
sparkGetAddressesMethodName,
|
|
2471
2742
|
sparkGetAddressesParamsSchema,
|
|
2472
2743
|
sparkGetAddressesRequestMessageSchema,
|