@sats-connect/core 0.8.1-c2412c4 → 0.8.1-d85ba2a
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 +343 -9
- package/dist/index.d.ts +343 -9
- package/dist/index.js +390 -261
- package/dist/index.mjs +374 -260
- 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,53 +191,8 @@ function getSupportedWallets() {
|
|
|
194
191
|
return wallets;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
// src/request/
|
|
198
|
-
|
|
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
|
-
};
|
|
194
|
+
// src/request/index.ts
|
|
195
|
+
import * as v35 from "valibot";
|
|
244
196
|
|
|
245
197
|
// src/request/types/btcMethods.ts
|
|
246
198
|
import * as v6 from "valibot";
|
|
@@ -459,11 +411,6 @@ var addNetworkResultSchema = v5.object({
|
|
|
459
411
|
});
|
|
460
412
|
|
|
461
413
|
// src/request/types/btcMethods.ts
|
|
462
|
-
var ProviderPlatform = /* @__PURE__ */ ((ProviderPlatform2) => {
|
|
463
|
-
ProviderPlatform2["Web"] = "web";
|
|
464
|
-
ProviderPlatform2["Mobile"] = "mobile";
|
|
465
|
-
return ProviderPlatform2;
|
|
466
|
-
})(ProviderPlatform || {});
|
|
467
414
|
var getInfoMethodName = "getInfo";
|
|
468
415
|
var getInfoParamsSchema = v6.nullish(v6.null());
|
|
469
416
|
var getInfoResultSchema = v6.object({
|
|
@@ -471,10 +418,6 @@ var getInfoResultSchema = v6.object({
|
|
|
471
418
|
* Version of the wallet.
|
|
472
419
|
*/
|
|
473
420
|
version: v6.string(),
|
|
474
|
-
/**
|
|
475
|
-
* The platform the wallet is running on (web or mobile).
|
|
476
|
-
*/
|
|
477
|
-
platform: v6.optional(v6.enum(ProviderPlatform)),
|
|
478
421
|
/**
|
|
479
422
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
480
423
|
*/
|
|
@@ -862,10 +805,10 @@ var runesTransferRequestMessageSchema = v11.object({
|
|
|
862
805
|
}).entries
|
|
863
806
|
});
|
|
864
807
|
|
|
865
|
-
// src/request/types/sparkMethods/
|
|
808
|
+
// src/request/types/sparkMethods/flashnetMethods/getJwt.ts
|
|
866
809
|
import * as v12 from "valibot";
|
|
867
|
-
var
|
|
868
|
-
var
|
|
810
|
+
var sparkFlashnetGetJwtMethodName = "spark_flashnet_getJwt";
|
|
811
|
+
var sparkFlashnetGetJwtParamsSchema = v12.nullish(
|
|
869
812
|
v12.object({
|
|
870
813
|
/**
|
|
871
814
|
* A message to be displayed to the user in the request prompt.
|
|
@@ -873,135 +816,315 @@ var sparkGetAddressesParamsSchema = v12.nullish(
|
|
|
873
816
|
message: v12.optional(v12.string())
|
|
874
817
|
})
|
|
875
818
|
);
|
|
876
|
-
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/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({
|
|
877
1000
|
/**
|
|
878
1001
|
* The addresses generated for the given purposes.
|
|
879
1002
|
*/
|
|
880
|
-
addresses:
|
|
1003
|
+
addresses: v22.array(addressSchema),
|
|
881
1004
|
network: getNetworkResultSchema
|
|
882
1005
|
});
|
|
883
|
-
var sparkGetAddressesRequestMessageSchema =
|
|
1006
|
+
var sparkGetAddressesRequestMessageSchema = v22.object({
|
|
884
1007
|
...rpcRequestMessageSchema.entries,
|
|
885
|
-
...
|
|
886
|
-
method:
|
|
1008
|
+
...v22.object({
|
|
1009
|
+
method: v22.literal(sparkGetAddressesMethodName),
|
|
887
1010
|
params: sparkGetAddressesParamsSchema,
|
|
888
|
-
id:
|
|
1011
|
+
id: v22.string()
|
|
889
1012
|
}).entries
|
|
890
1013
|
});
|
|
891
1014
|
|
|
892
1015
|
// src/request/types/sparkMethods/getBalance.ts
|
|
893
|
-
import * as
|
|
1016
|
+
import * as v23 from "valibot";
|
|
894
1017
|
var sparkGetBalanceMethodName = "spark_getBalance";
|
|
895
|
-
var sparkGetBalanceParamsSchema =
|
|
896
|
-
var sparkGetBalanceResultSchema =
|
|
1018
|
+
var sparkGetBalanceParamsSchema = v23.nullish(v23.null());
|
|
1019
|
+
var sparkGetBalanceResultSchema = v23.object({
|
|
897
1020
|
/**
|
|
898
1021
|
* The Spark Bitcoin address balance in sats in string form.
|
|
899
1022
|
*/
|
|
900
|
-
balance:
|
|
901
|
-
tokenBalances:
|
|
902
|
-
|
|
1023
|
+
balance: v23.string(),
|
|
1024
|
+
tokenBalances: v23.array(
|
|
1025
|
+
v23.object({
|
|
903
1026
|
/* The address balance of the token in string form as it can overflow a js number */
|
|
904
|
-
balance:
|
|
905
|
-
tokenMetadata:
|
|
906
|
-
tokenIdentifier:
|
|
907
|
-
tokenName:
|
|
908
|
-
tokenTicker:
|
|
909
|
-
decimals:
|
|
910
|
-
maxSupply:
|
|
1027
|
+
balance: v23.string(),
|
|
1028
|
+
tokenMetadata: v23.object({
|
|
1029
|
+
tokenIdentifier: v23.string(),
|
|
1030
|
+
tokenName: v23.string(),
|
|
1031
|
+
tokenTicker: v23.string(),
|
|
1032
|
+
decimals: v23.number(),
|
|
1033
|
+
maxSupply: v23.string()
|
|
911
1034
|
})
|
|
912
1035
|
})
|
|
913
1036
|
)
|
|
914
1037
|
});
|
|
915
|
-
var sparkGetBalanceRequestMessageSchema =
|
|
1038
|
+
var sparkGetBalanceRequestMessageSchema = v23.object({
|
|
916
1039
|
...rpcRequestMessageSchema.entries,
|
|
917
|
-
...
|
|
918
|
-
method:
|
|
1040
|
+
...v23.object({
|
|
1041
|
+
method: v23.literal(sparkGetBalanceMethodName),
|
|
919
1042
|
params: sparkGetBalanceParamsSchema,
|
|
920
|
-
id:
|
|
1043
|
+
id: v23.string()
|
|
921
1044
|
}).entries
|
|
922
1045
|
});
|
|
923
1046
|
|
|
924
1047
|
// src/request/types/sparkMethods/transfer.ts
|
|
925
|
-
import * as
|
|
1048
|
+
import * as v24 from "valibot";
|
|
926
1049
|
var sparkTransferMethodName = "spark_transfer";
|
|
927
|
-
var sparkTransferParamsSchema =
|
|
1050
|
+
var sparkTransferParamsSchema = v24.object({
|
|
928
1051
|
/**
|
|
929
1052
|
* Amount of SATS to transfer as a string or number.
|
|
930
1053
|
*/
|
|
931
|
-
amountSats:
|
|
1054
|
+
amountSats: v24.union([v24.number(), v24.string()]),
|
|
932
1055
|
/**
|
|
933
1056
|
* The recipient's spark address.
|
|
934
1057
|
*/
|
|
935
|
-
receiverSparkAddress:
|
|
1058
|
+
receiverSparkAddress: v24.string()
|
|
936
1059
|
});
|
|
937
|
-
var sparkTransferResultSchema =
|
|
1060
|
+
var sparkTransferResultSchema = v24.object({
|
|
938
1061
|
/**
|
|
939
1062
|
* The ID of the transaction.
|
|
940
1063
|
*/
|
|
941
|
-
id:
|
|
1064
|
+
id: v24.string()
|
|
942
1065
|
});
|
|
943
|
-
var sparkTransferRequestMessageSchema =
|
|
1066
|
+
var sparkTransferRequestMessageSchema = v24.object({
|
|
944
1067
|
...rpcRequestMessageSchema.entries,
|
|
945
|
-
...
|
|
946
|
-
method:
|
|
1068
|
+
...v24.object({
|
|
1069
|
+
method: v24.literal(sparkTransferMethodName),
|
|
947
1070
|
params: sparkTransferParamsSchema,
|
|
948
|
-
id:
|
|
1071
|
+
id: v24.string()
|
|
949
1072
|
}).entries
|
|
950
1073
|
});
|
|
951
1074
|
|
|
952
1075
|
// src/request/types/sparkMethods/transferToken.ts
|
|
953
|
-
import * as
|
|
1076
|
+
import * as v25 from "valibot";
|
|
954
1077
|
var sparkTransferTokenMethodName = "spark_transferToken";
|
|
955
|
-
var sparkTransferTokenParamsSchema =
|
|
1078
|
+
var sparkTransferTokenParamsSchema = v25.object({
|
|
956
1079
|
/**
|
|
957
1080
|
* Amount of units of the token to transfer as a string or number.
|
|
958
1081
|
*/
|
|
959
|
-
tokenAmount:
|
|
1082
|
+
tokenAmount: v25.union([v25.number(), v25.string()]),
|
|
960
1083
|
/**
|
|
961
1084
|
* The Bech32m token identifier.
|
|
962
1085
|
*/
|
|
963
|
-
tokenIdentifier:
|
|
1086
|
+
tokenIdentifier: v25.string(),
|
|
964
1087
|
/**
|
|
965
1088
|
* The recipient's spark address.
|
|
966
1089
|
*/
|
|
967
|
-
receiverSparkAddress:
|
|
1090
|
+
receiverSparkAddress: v25.string()
|
|
968
1091
|
});
|
|
969
|
-
var sparkTransferTokenResultSchema =
|
|
1092
|
+
var sparkTransferTokenResultSchema = v25.object({
|
|
970
1093
|
/**
|
|
971
1094
|
* The ID of the transaction.
|
|
972
1095
|
*/
|
|
973
|
-
id:
|
|
1096
|
+
id: v25.string()
|
|
974
1097
|
});
|
|
975
|
-
var sparkTransferTokenRequestMessageSchema =
|
|
1098
|
+
var sparkTransferTokenRequestMessageSchema = v25.object({
|
|
976
1099
|
...rpcRequestMessageSchema.entries,
|
|
977
|
-
...
|
|
978
|
-
method:
|
|
1100
|
+
...v25.object({
|
|
1101
|
+
method: v25.literal(sparkTransferTokenMethodName),
|
|
979
1102
|
params: sparkTransferTokenParamsSchema,
|
|
980
|
-
id:
|
|
1103
|
+
id: v25.string()
|
|
981
1104
|
}).entries
|
|
982
1105
|
});
|
|
983
1106
|
|
|
984
1107
|
// src/request/types/stxMethods/callContract.ts
|
|
985
|
-
import * as
|
|
1108
|
+
import * as v26 from "valibot";
|
|
986
1109
|
var stxCallContractMethodName = "stx_callContract";
|
|
987
|
-
var stxCallContractParamsSchema =
|
|
1110
|
+
var stxCallContractParamsSchema = v26.object({
|
|
988
1111
|
/**
|
|
989
1112
|
* The contract principal.
|
|
990
1113
|
*
|
|
991
1114
|
* E.g. `"SPKE...GD5C.my-contract"`
|
|
992
1115
|
*/
|
|
993
|
-
contract:
|
|
1116
|
+
contract: v26.string(),
|
|
994
1117
|
/**
|
|
995
1118
|
* The name of the function to call.
|
|
996
1119
|
*
|
|
997
1120
|
* Note: spec changes ongoing,
|
|
998
1121
|
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
999
1122
|
*/
|
|
1000
|
-
functionName:
|
|
1123
|
+
functionName: v26.string(),
|
|
1001
1124
|
/**
|
|
1002
1125
|
* @deprecated in favor of `functionArgs` for @stacks/connect compatibility
|
|
1003
1126
|
*/
|
|
1004
|
-
arguments:
|
|
1127
|
+
arguments: v26.optional(v26.array(v26.string())),
|
|
1005
1128
|
/**
|
|
1006
1129
|
* The function's arguments. The arguments are expected to be hex-encoded
|
|
1007
1130
|
* strings of Clarity values.
|
|
@@ -1016,274 +1139,274 @@ var stxCallContractParamsSchema = v16.object({
|
|
|
1016
1139
|
* const hexArgs = functionArgs.map(cvToHex);
|
|
1017
1140
|
* ```
|
|
1018
1141
|
*/
|
|
1019
|
-
functionArgs:
|
|
1142
|
+
functionArgs: v26.optional(v26.array(v26.string())),
|
|
1020
1143
|
/**
|
|
1021
1144
|
* The post conditions to apply to the contract call.
|
|
1022
1145
|
*/
|
|
1023
|
-
postConditions:
|
|
1146
|
+
postConditions: v26.optional(v26.array(v26.string())),
|
|
1024
1147
|
/**
|
|
1025
1148
|
* The mode to apply to the post conditions.
|
|
1026
1149
|
*/
|
|
1027
|
-
postConditionMode:
|
|
1150
|
+
postConditionMode: v26.optional(v26.union([v26.literal("allow"), v26.literal("deny")]))
|
|
1028
1151
|
});
|
|
1029
|
-
var stxCallContractResultSchema =
|
|
1152
|
+
var stxCallContractResultSchema = v26.object({
|
|
1030
1153
|
/**
|
|
1031
1154
|
* The ID of the transaction.
|
|
1032
1155
|
*/
|
|
1033
|
-
txid:
|
|
1156
|
+
txid: v26.string(),
|
|
1034
1157
|
/**
|
|
1035
1158
|
* A Stacks transaction as a hex-encoded string.
|
|
1036
1159
|
*/
|
|
1037
|
-
transaction:
|
|
1160
|
+
transaction: v26.string()
|
|
1038
1161
|
});
|
|
1039
|
-
var stxCallContractRequestMessageSchema =
|
|
1162
|
+
var stxCallContractRequestMessageSchema = v26.object({
|
|
1040
1163
|
...rpcRequestMessageSchema.entries,
|
|
1041
|
-
...
|
|
1042
|
-
method:
|
|
1164
|
+
...v26.object({
|
|
1165
|
+
method: v26.literal(stxCallContractMethodName),
|
|
1043
1166
|
params: stxCallContractParamsSchema,
|
|
1044
|
-
id:
|
|
1167
|
+
id: v26.string()
|
|
1045
1168
|
}).entries
|
|
1046
1169
|
});
|
|
1047
1170
|
|
|
1048
1171
|
// src/request/types/stxMethods/deployContract.ts
|
|
1049
|
-
import * as
|
|
1172
|
+
import * as v27 from "valibot";
|
|
1050
1173
|
var stxDeployContractMethodName = "stx_deployContract";
|
|
1051
|
-
var stxDeployContractParamsSchema =
|
|
1174
|
+
var stxDeployContractParamsSchema = v27.object({
|
|
1052
1175
|
/**
|
|
1053
1176
|
* Name of the contract.
|
|
1054
1177
|
*/
|
|
1055
|
-
name:
|
|
1178
|
+
name: v27.string(),
|
|
1056
1179
|
/**
|
|
1057
1180
|
* The source code of the Clarity contract.
|
|
1058
1181
|
*/
|
|
1059
|
-
clarityCode:
|
|
1182
|
+
clarityCode: v27.string(),
|
|
1060
1183
|
/**
|
|
1061
1184
|
* The version of the Clarity contract.
|
|
1062
1185
|
*/
|
|
1063
|
-
clarityVersion:
|
|
1186
|
+
clarityVersion: v27.optional(v27.number()),
|
|
1064
1187
|
/**
|
|
1065
1188
|
* The post conditions to apply to the contract call.
|
|
1066
1189
|
*/
|
|
1067
|
-
postConditions:
|
|
1190
|
+
postConditions: v27.optional(v27.array(v27.string())),
|
|
1068
1191
|
/**
|
|
1069
1192
|
* The mode to apply to the post conditions.
|
|
1070
1193
|
*/
|
|
1071
|
-
postConditionMode:
|
|
1194
|
+
postConditionMode: v27.optional(v27.union([v27.literal("allow"), v27.literal("deny")]))
|
|
1072
1195
|
});
|
|
1073
|
-
var stxDeployContractResultSchema =
|
|
1196
|
+
var stxDeployContractResultSchema = v27.object({
|
|
1074
1197
|
/**
|
|
1075
1198
|
* The ID of the transaction.
|
|
1076
1199
|
*/
|
|
1077
|
-
txid:
|
|
1200
|
+
txid: v27.string(),
|
|
1078
1201
|
/**
|
|
1079
1202
|
* A Stacks transaction as a hex-encoded string.
|
|
1080
1203
|
*/
|
|
1081
|
-
transaction:
|
|
1204
|
+
transaction: v27.string()
|
|
1082
1205
|
});
|
|
1083
|
-
var stxDeployContractRequestMessageSchema =
|
|
1206
|
+
var stxDeployContractRequestMessageSchema = v27.object({
|
|
1084
1207
|
...rpcRequestMessageSchema.entries,
|
|
1085
|
-
...
|
|
1086
|
-
method:
|
|
1208
|
+
...v27.object({
|
|
1209
|
+
method: v27.literal(stxDeployContractMethodName),
|
|
1087
1210
|
params: stxDeployContractParamsSchema,
|
|
1088
|
-
id:
|
|
1211
|
+
id: v27.string()
|
|
1089
1212
|
}).entries
|
|
1090
1213
|
});
|
|
1091
1214
|
|
|
1092
1215
|
// src/request/types/stxMethods/getAccounts.ts
|
|
1093
|
-
import * as
|
|
1216
|
+
import * as v28 from "valibot";
|
|
1094
1217
|
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
1095
|
-
var stxGetAccountsParamsSchema =
|
|
1096
|
-
var stxGetAccountsResultSchema =
|
|
1218
|
+
var stxGetAccountsParamsSchema = v28.nullish(v28.null());
|
|
1219
|
+
var stxGetAccountsResultSchema = v28.object({
|
|
1097
1220
|
/**
|
|
1098
1221
|
* The addresses generated for the given purposes.
|
|
1099
1222
|
*/
|
|
1100
|
-
addresses:
|
|
1101
|
-
|
|
1102
|
-
address:
|
|
1103
|
-
publicKey:
|
|
1104
|
-
gaiaHubUrl:
|
|
1105
|
-
gaiaAppKey:
|
|
1223
|
+
addresses: v28.array(
|
|
1224
|
+
v28.object({
|
|
1225
|
+
address: v28.string(),
|
|
1226
|
+
publicKey: v28.string(),
|
|
1227
|
+
gaiaHubUrl: v28.string(),
|
|
1228
|
+
gaiaAppKey: v28.string()
|
|
1106
1229
|
})
|
|
1107
1230
|
),
|
|
1108
1231
|
network: getNetworkResultSchema
|
|
1109
1232
|
});
|
|
1110
|
-
var stxGetAccountsRequestMessageSchema =
|
|
1233
|
+
var stxGetAccountsRequestMessageSchema = v28.object({
|
|
1111
1234
|
...rpcRequestMessageSchema.entries,
|
|
1112
|
-
...
|
|
1113
|
-
method:
|
|
1235
|
+
...v28.object({
|
|
1236
|
+
method: v28.literal(stxGetAccountsMethodName),
|
|
1114
1237
|
params: stxGetAccountsParamsSchema,
|
|
1115
|
-
id:
|
|
1238
|
+
id: v28.string()
|
|
1116
1239
|
}).entries
|
|
1117
1240
|
});
|
|
1118
1241
|
|
|
1119
1242
|
// src/request/types/stxMethods/getAddresses.ts
|
|
1120
|
-
import * as
|
|
1243
|
+
import * as v29 from "valibot";
|
|
1121
1244
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
1122
|
-
var stxGetAddressesParamsSchema =
|
|
1123
|
-
|
|
1245
|
+
var stxGetAddressesParamsSchema = v29.nullish(
|
|
1246
|
+
v29.object({
|
|
1124
1247
|
/**
|
|
1125
1248
|
* A message to be displayed to the user in the request prompt.
|
|
1126
1249
|
*/
|
|
1127
|
-
message:
|
|
1250
|
+
message: v29.optional(v29.string())
|
|
1128
1251
|
})
|
|
1129
1252
|
);
|
|
1130
|
-
var stxGetAddressesResultSchema =
|
|
1253
|
+
var stxGetAddressesResultSchema = v29.object({
|
|
1131
1254
|
/**
|
|
1132
1255
|
* The addresses generated for the given purposes.
|
|
1133
1256
|
*/
|
|
1134
|
-
addresses:
|
|
1257
|
+
addresses: v29.array(addressSchema),
|
|
1135
1258
|
network: getNetworkResultSchema
|
|
1136
1259
|
});
|
|
1137
|
-
var stxGetAddressesRequestMessageSchema =
|
|
1260
|
+
var stxGetAddressesRequestMessageSchema = v29.object({
|
|
1138
1261
|
...rpcRequestMessageSchema.entries,
|
|
1139
|
-
...
|
|
1140
|
-
method:
|
|
1262
|
+
...v29.object({
|
|
1263
|
+
method: v29.literal(stxGetAddressesMethodName),
|
|
1141
1264
|
params: stxGetAddressesParamsSchema,
|
|
1142
|
-
id:
|
|
1265
|
+
id: v29.string()
|
|
1143
1266
|
}).entries
|
|
1144
1267
|
});
|
|
1145
1268
|
|
|
1146
1269
|
// src/request/types/stxMethods/signMessage.ts
|
|
1147
|
-
import * as
|
|
1270
|
+
import * as v30 from "valibot";
|
|
1148
1271
|
var stxSignMessageMethodName = "stx_signMessage";
|
|
1149
|
-
var stxSignMessageParamsSchema =
|
|
1272
|
+
var stxSignMessageParamsSchema = v30.object({
|
|
1150
1273
|
/**
|
|
1151
1274
|
* The message to sign.
|
|
1152
1275
|
*/
|
|
1153
|
-
message:
|
|
1276
|
+
message: v30.string()
|
|
1154
1277
|
});
|
|
1155
|
-
var stxSignMessageResultSchema =
|
|
1278
|
+
var stxSignMessageResultSchema = v30.object({
|
|
1156
1279
|
/**
|
|
1157
1280
|
* The signature of the message.
|
|
1158
1281
|
*/
|
|
1159
|
-
signature:
|
|
1282
|
+
signature: v30.string(),
|
|
1160
1283
|
/**
|
|
1161
1284
|
* The public key used to sign the message.
|
|
1162
1285
|
*/
|
|
1163
|
-
publicKey:
|
|
1286
|
+
publicKey: v30.string()
|
|
1164
1287
|
});
|
|
1165
|
-
var stxSignMessageRequestMessageSchema =
|
|
1288
|
+
var stxSignMessageRequestMessageSchema = v30.object({
|
|
1166
1289
|
...rpcRequestMessageSchema.entries,
|
|
1167
|
-
...
|
|
1168
|
-
method:
|
|
1290
|
+
...v30.object({
|
|
1291
|
+
method: v30.literal(stxSignMessageMethodName),
|
|
1169
1292
|
params: stxSignMessageParamsSchema,
|
|
1170
|
-
id:
|
|
1293
|
+
id: v30.string()
|
|
1171
1294
|
}).entries
|
|
1172
1295
|
});
|
|
1173
1296
|
|
|
1174
1297
|
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
1175
|
-
import * as
|
|
1298
|
+
import * as v31 from "valibot";
|
|
1176
1299
|
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
1177
|
-
var stxSignStructuredMessageParamsSchema =
|
|
1300
|
+
var stxSignStructuredMessageParamsSchema = v31.object({
|
|
1178
1301
|
/**
|
|
1179
1302
|
* The domain to be signed.
|
|
1180
1303
|
*/
|
|
1181
|
-
domain:
|
|
1304
|
+
domain: v31.string(),
|
|
1182
1305
|
/**
|
|
1183
1306
|
* Message payload to be signed.
|
|
1184
1307
|
*/
|
|
1185
|
-
message:
|
|
1308
|
+
message: v31.string(),
|
|
1186
1309
|
/**
|
|
1187
1310
|
* The public key to sign the message with.
|
|
1188
1311
|
*/
|
|
1189
|
-
publicKey:
|
|
1312
|
+
publicKey: v31.optional(v31.string())
|
|
1190
1313
|
});
|
|
1191
|
-
var stxSignStructuredMessageResultSchema =
|
|
1314
|
+
var stxSignStructuredMessageResultSchema = v31.object({
|
|
1192
1315
|
/**
|
|
1193
1316
|
* Signature of the message.
|
|
1194
1317
|
*/
|
|
1195
|
-
signature:
|
|
1318
|
+
signature: v31.string(),
|
|
1196
1319
|
/**
|
|
1197
1320
|
* Public key as hex-encoded string.
|
|
1198
1321
|
*/
|
|
1199
|
-
publicKey:
|
|
1322
|
+
publicKey: v31.string()
|
|
1200
1323
|
});
|
|
1201
|
-
var stxSignStructuredMessageRequestMessageSchema =
|
|
1324
|
+
var stxSignStructuredMessageRequestMessageSchema = v31.object({
|
|
1202
1325
|
...rpcRequestMessageSchema.entries,
|
|
1203
|
-
...
|
|
1204
|
-
method:
|
|
1326
|
+
...v31.object({
|
|
1327
|
+
method: v31.literal(stxSignStructuredMessageMethodName),
|
|
1205
1328
|
params: stxSignStructuredMessageParamsSchema,
|
|
1206
|
-
id:
|
|
1329
|
+
id: v31.string()
|
|
1207
1330
|
}).entries
|
|
1208
1331
|
});
|
|
1209
1332
|
|
|
1210
1333
|
// src/request/types/stxMethods/signTransaction.ts
|
|
1211
|
-
import * as
|
|
1334
|
+
import * as v32 from "valibot";
|
|
1212
1335
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
1213
|
-
var stxSignTransactionParamsSchema =
|
|
1336
|
+
var stxSignTransactionParamsSchema = v32.object({
|
|
1214
1337
|
/**
|
|
1215
1338
|
* The transaction to sign as a hex-encoded string.
|
|
1216
1339
|
*/
|
|
1217
|
-
transaction:
|
|
1340
|
+
transaction: v32.string(),
|
|
1218
1341
|
/**
|
|
1219
1342
|
* The public key to sign the transaction with. The wallet may use any key
|
|
1220
1343
|
* when not provided.
|
|
1221
1344
|
*/
|
|
1222
|
-
pubkey:
|
|
1345
|
+
pubkey: v32.optional(v32.string()),
|
|
1223
1346
|
/**
|
|
1224
1347
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
1225
1348
|
*/
|
|
1226
|
-
broadcast:
|
|
1349
|
+
broadcast: v32.optional(v32.boolean())
|
|
1227
1350
|
});
|
|
1228
|
-
var stxSignTransactionResultSchema =
|
|
1351
|
+
var stxSignTransactionResultSchema = v32.object({
|
|
1229
1352
|
/**
|
|
1230
1353
|
* The signed transaction as a hex-encoded string.
|
|
1231
1354
|
*/
|
|
1232
|
-
transaction:
|
|
1355
|
+
transaction: v32.string()
|
|
1233
1356
|
});
|
|
1234
|
-
var stxSignTransactionRequestMessageSchema =
|
|
1357
|
+
var stxSignTransactionRequestMessageSchema = v32.object({
|
|
1235
1358
|
...rpcRequestMessageSchema.entries,
|
|
1236
|
-
...
|
|
1237
|
-
method:
|
|
1359
|
+
...v32.object({
|
|
1360
|
+
method: v32.literal(stxSignTransactionMethodName),
|
|
1238
1361
|
params: stxSignTransactionParamsSchema,
|
|
1239
|
-
id:
|
|
1362
|
+
id: v32.string()
|
|
1240
1363
|
}).entries
|
|
1241
1364
|
});
|
|
1242
1365
|
|
|
1243
1366
|
// src/request/types/stxMethods/signTransactions.ts
|
|
1244
|
-
import * as
|
|
1367
|
+
import * as v33 from "valibot";
|
|
1245
1368
|
var stxSignTransactionsMethodName = "stx_signTransactions";
|
|
1246
|
-
var stxSignTransactionsParamsSchema =
|
|
1369
|
+
var stxSignTransactionsParamsSchema = v33.object({
|
|
1247
1370
|
/**
|
|
1248
1371
|
* The transactions to sign as hex-encoded strings.
|
|
1249
1372
|
*/
|
|
1250
|
-
transactions:
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1373
|
+
transactions: v33.pipe(
|
|
1374
|
+
v33.array(
|
|
1375
|
+
v33.pipe(
|
|
1376
|
+
v33.string(),
|
|
1377
|
+
v33.check((hex) => {
|
|
1255
1378
|
return true;
|
|
1256
1379
|
}, "Invalid hex-encoded Stacks transaction.")
|
|
1257
1380
|
)
|
|
1258
1381
|
),
|
|
1259
|
-
|
|
1382
|
+
v33.minLength(1)
|
|
1260
1383
|
),
|
|
1261
1384
|
/**
|
|
1262
1385
|
* Whether the signed transactions should be broadcast after signing. Defaults
|
|
1263
1386
|
* to `true`.
|
|
1264
1387
|
*/
|
|
1265
|
-
broadcast:
|
|
1388
|
+
broadcast: v33.optional(v33.boolean())
|
|
1266
1389
|
});
|
|
1267
|
-
var stxSignTransactionsResultSchema =
|
|
1390
|
+
var stxSignTransactionsResultSchema = v33.object({
|
|
1268
1391
|
/**
|
|
1269
1392
|
* The signed transactions as hex-encoded strings, in the same order as in the
|
|
1270
1393
|
* sign request.
|
|
1271
1394
|
*/
|
|
1272
|
-
transactions:
|
|
1395
|
+
transactions: v33.array(v33.string())
|
|
1273
1396
|
});
|
|
1274
|
-
var stxSignTransactionsRequestMessageSchema =
|
|
1397
|
+
var stxSignTransactionsRequestMessageSchema = v33.object({
|
|
1275
1398
|
...rpcRequestMessageSchema.entries,
|
|
1276
|
-
...
|
|
1277
|
-
method:
|
|
1399
|
+
...v33.object({
|
|
1400
|
+
method: v33.literal(stxSignTransactionsMethodName),
|
|
1278
1401
|
params: stxSignTransactionsParamsSchema,
|
|
1279
|
-
id:
|
|
1402
|
+
id: v33.string()
|
|
1280
1403
|
}).entries
|
|
1281
1404
|
});
|
|
1282
1405
|
|
|
1283
1406
|
// src/request/types/stxMethods/transferStx.ts
|
|
1284
|
-
import * as
|
|
1407
|
+
import * as v34 from "valibot";
|
|
1285
1408
|
var stxTransferStxMethodName = "stx_transferStx";
|
|
1286
|
-
var stxTransferStxParamsSchema =
|
|
1409
|
+
var stxTransferStxParamsSchema = v34.object({
|
|
1287
1410
|
/**
|
|
1288
1411
|
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
1289
1412
|
* parseable by `BigInt` is acceptable.
|
|
@@ -1296,23 +1419,23 @@ var stxTransferStxParamsSchema = v24.object({
|
|
|
1296
1419
|
* const amount3 = '1234';
|
|
1297
1420
|
* ```
|
|
1298
1421
|
*/
|
|
1299
|
-
amount:
|
|
1422
|
+
amount: v34.union([v34.number(), v34.string()]),
|
|
1300
1423
|
/**
|
|
1301
1424
|
* The recipient's principal.
|
|
1302
1425
|
*/
|
|
1303
|
-
recipient:
|
|
1426
|
+
recipient: v34.string(),
|
|
1304
1427
|
/**
|
|
1305
1428
|
* A string representing the memo.
|
|
1306
1429
|
*/
|
|
1307
|
-
memo:
|
|
1430
|
+
memo: v34.optional(v34.string()),
|
|
1308
1431
|
/**
|
|
1309
1432
|
* Version of parameter format.
|
|
1310
1433
|
*/
|
|
1311
|
-
version:
|
|
1434
|
+
version: v34.optional(v34.string()),
|
|
1312
1435
|
/**
|
|
1313
1436
|
* The mode of the post conditions.
|
|
1314
1437
|
*/
|
|
1315
|
-
postConditionMode:
|
|
1438
|
+
postConditionMode: v34.optional(v34.number()),
|
|
1316
1439
|
/**
|
|
1317
1440
|
* A hex-encoded string representing the post conditions.
|
|
1318
1441
|
*
|
|
@@ -1325,43 +1448,52 @@ var stxTransferStxParamsSchema = v24.object({
|
|
|
1325
1448
|
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
1326
1449
|
* ```
|
|
1327
1450
|
*/
|
|
1328
|
-
postConditions:
|
|
1451
|
+
postConditions: v34.optional(v34.array(v34.string())),
|
|
1329
1452
|
/**
|
|
1330
1453
|
* The public key to sign the transaction with. The wallet may use any key
|
|
1331
1454
|
* when not provided.
|
|
1332
1455
|
*/
|
|
1333
|
-
pubkey:
|
|
1456
|
+
pubkey: v34.optional(v34.string())
|
|
1334
1457
|
});
|
|
1335
|
-
var stxTransferStxResultSchema =
|
|
1458
|
+
var stxTransferStxResultSchema = v34.object({
|
|
1336
1459
|
/**
|
|
1337
1460
|
* The ID of the transaction.
|
|
1338
1461
|
*/
|
|
1339
|
-
txid:
|
|
1462
|
+
txid: v34.string(),
|
|
1340
1463
|
/**
|
|
1341
1464
|
* A Stacks transaction as a hex-encoded string.
|
|
1342
1465
|
*/
|
|
1343
|
-
transaction:
|
|
1466
|
+
transaction: v34.string()
|
|
1344
1467
|
});
|
|
1345
|
-
var stxTransferStxRequestMessageSchema =
|
|
1468
|
+
var stxTransferStxRequestMessageSchema = v34.object({
|
|
1346
1469
|
...rpcRequestMessageSchema.entries,
|
|
1347
|
-
...
|
|
1348
|
-
method:
|
|
1470
|
+
...v34.object({
|
|
1471
|
+
method: v34.literal(stxTransferStxMethodName),
|
|
1349
1472
|
params: stxTransferStxParamsSchema,
|
|
1350
|
-
id:
|
|
1473
|
+
id: v34.string()
|
|
1351
1474
|
}).entries
|
|
1352
1475
|
});
|
|
1353
1476
|
|
|
1354
1477
|
// src/request/index.ts
|
|
1355
|
-
var
|
|
1356
|
-
|
|
1478
|
+
var request = async (method, params, providerId) => {
|
|
1479
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
1480
|
+
if (providerId) {
|
|
1481
|
+
provider = await getProviderById(providerId);
|
|
1482
|
+
}
|
|
1483
|
+
if (!provider) {
|
|
1484
|
+
throw new Error("no wallet provider was found");
|
|
1485
|
+
}
|
|
1486
|
+
if (!method) {
|
|
1487
|
+
throw new Error("A wallet method is required");
|
|
1488
|
+
}
|
|
1357
1489
|
const response = await provider.request(method, params);
|
|
1358
|
-
if (
|
|
1490
|
+
if (v35.is(rpcErrorResponseMessageSchema, response)) {
|
|
1359
1491
|
return {
|
|
1360
1492
|
status: "error",
|
|
1361
1493
|
error: response.error
|
|
1362
1494
|
};
|
|
1363
1495
|
}
|
|
1364
|
-
if (
|
|
1496
|
+
if (v35.is(rpcSuccessResponseMessageSchema, response)) {
|
|
1365
1497
|
return {
|
|
1366
1498
|
status: "success",
|
|
1367
1499
|
result: response.result
|
|
@@ -1376,39 +1508,6 @@ var requestInternal = async (provider, method, params) => {
|
|
|
1376
1508
|
}
|
|
1377
1509
|
};
|
|
1378
1510
|
};
|
|
1379
|
-
var request = async (method, params, providerId) => {
|
|
1380
|
-
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
1381
|
-
if (providerId) {
|
|
1382
|
-
provider = await getProviderById(providerId);
|
|
1383
|
-
}
|
|
1384
|
-
if (!provider) {
|
|
1385
|
-
throw new Error("no wallet provider was found");
|
|
1386
|
-
}
|
|
1387
|
-
if (!method) {
|
|
1388
|
-
throw new Error("A wallet method is required");
|
|
1389
|
-
}
|
|
1390
|
-
if (!cache.providerInfo) {
|
|
1391
|
-
const infoResult = await requestInternal(provider, "getInfo", null);
|
|
1392
|
-
if (infoResult.status === "success") {
|
|
1393
|
-
cache.providerInfo = infoResult.result;
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
if (cache.providerInfo) {
|
|
1397
|
-
if (method === "getInfo") {
|
|
1398
|
-
return {
|
|
1399
|
-
status: "success",
|
|
1400
|
-
result: cache.providerInfo
|
|
1401
|
-
};
|
|
1402
|
-
}
|
|
1403
|
-
const sanitized = sanitizeRequest(method, params, cache.providerInfo);
|
|
1404
|
-
if (sanitized.overrideResponse) {
|
|
1405
|
-
return sanitized.overrideResponse;
|
|
1406
|
-
}
|
|
1407
|
-
method = sanitized.method;
|
|
1408
|
-
params = sanitized.params;
|
|
1409
|
-
}
|
|
1410
|
-
return requestInternal(provider, method, params);
|
|
1411
|
-
};
|
|
1412
1511
|
var addListener = (...rawArgs) => {
|
|
1413
1512
|
const [listenerInfo, providerId] = (() => {
|
|
1414
1513
|
if (rawArgs.length === 1) {
|
|
@@ -2413,7 +2512,6 @@ export {
|
|
|
2413
2512
|
DefaultAdaptersInfo,
|
|
2414
2513
|
MessageSigningProtocols,
|
|
2415
2514
|
PermissionRequestParams,
|
|
2416
|
-
ProviderPlatform,
|
|
2417
2515
|
RpcErrorCode,
|
|
2418
2516
|
RpcIdSchema,
|
|
2419
2517
|
SatsConnectAdapter,
|
|
@@ -2549,6 +2647,22 @@ export {
|
|
|
2549
2647
|
signPsbtRequestMessageSchema,
|
|
2550
2648
|
signPsbtResultSchema,
|
|
2551
2649
|
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,
|
|
2552
2666
|
sparkGetAddressesMethodName,
|
|
2553
2667
|
sparkGetAddressesParamsSchema,
|
|
2554
2668
|
sparkGetAddressesRequestMessageSchema,
|