@sats-connect/core 0.4.0-68f1213 → 0.4.0-6eb2eb5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -27,8 +27,7 @@ async function getProviderOrThrow(getProvider) {
27
27
  return provider;
28
28
  }
29
29
  function getProviders() {
30
- if (!window.btc_providers)
31
- window.btc_providers = [];
30
+ if (!window.btc_providers) window.btc_providers = [];
32
31
  return window.btc_providers;
33
32
  }
34
33
  function getProviderById(providerId) {
@@ -47,10 +46,7 @@ function removeDefaultProvider() {
47
46
  localStorage.removeItem("sats-connect_defaultProvider");
48
47
  }
49
48
  function getSupportedWallets() {
50
- const ambientProviders = getProviders();
51
- const { xverse, ...defaultProviders } = DefaultAdaptersInfo;
52
- const allProviders = [...ambientProviders, ...Object.values(defaultProviders)];
53
- const wallets = allProviders.map((provider) => {
49
+ const wallets = Object.values(DefaultAdaptersInfo).map((provider) => {
54
50
  {
55
51
  return {
56
52
  ...provider,
@@ -63,11 +59,11 @@ function getSupportedWallets() {
63
59
 
64
60
  // src/types.ts
65
61
  import * as v2 from "valibot";
66
- var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
67
- BitcoinNetworkType3["Mainnet"] = "Mainnet";
68
- BitcoinNetworkType3["Testnet"] = "Testnet";
69
- BitcoinNetworkType3["Signet"] = "Signet";
70
- return BitcoinNetworkType3;
62
+ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
63
+ BitcoinNetworkType2["Mainnet"] = "Mainnet";
64
+ BitcoinNetworkType2["Testnet"] = "Testnet";
65
+ BitcoinNetworkType2["Signet"] = "Signet";
66
+ return BitcoinNetworkType2;
71
67
  })(BitcoinNetworkType || {});
72
68
  var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
73
69
  var rpcRequestMessageSchema = v2.object({
@@ -84,7 +80,7 @@ var rpcRequestMessageSchema = v2.object({
84
80
  v2.null()
85
81
  ])
86
82
  ),
87
- id: RpcIdSchema
83
+ id: v2.unwrap(RpcIdSchema)
88
84
  });
89
85
  var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
90
86
  RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
@@ -113,7 +109,7 @@ var rpcResponseMessageSchema = v2.union([
113
109
  ]);
114
110
 
115
111
  // src/request/index.ts
116
- import * as v17 from "valibot";
112
+ import * as v20 from "valibot";
117
113
 
118
114
  // src/request/types/stxMethods/callContract.ts
119
115
  import * as v3 from "valibot";
@@ -176,13 +172,13 @@ var stxDeployContractParamsSchema = v4.object({
176
172
  */
177
173
  name: v4.string(),
178
174
  /**
179
- * The code of the Clarity contract.
175
+ * The source code of the Clarity contract.
180
176
  */
181
- codeBody: v4.string(),
177
+ clarityCode: v4.string(),
182
178
  /**
183
179
  * The version of the Clarity contract.
184
180
  */
185
- version: v4.optional(v4.string())
181
+ clarityVersion: v4.optional(v4.string())
186
182
  });
187
183
  var stxDeployContractResultSchema = v4.object({
188
184
  /**
@@ -622,7 +618,6 @@ var signPsbtParamsSchema = v13.object({
622
618
  * The key is the address and the value is an array of indexes of the inputs to sign.
623
619
  */
624
620
  signInputs: v13.record(v13.string(), v13.array(v13.number())),
625
- allowedSignHash: v13.optional(v13.number()),
626
621
  /**
627
622
  * Whether to broadcast the transaction after signing.
628
623
  **/
@@ -707,19 +702,33 @@ var getBalanceRequestMessageSchema = v13.object({
707
702
 
708
703
  // src/request/types/walletMethods.ts
709
704
  import * as v14 from "valibot";
710
- import { permissions } from "@secretkeylabs/xverse-core";
711
- var permissionTemplate = v14.variant("type", [
705
+ var accountActionsSchema = v14.object({
706
+ read: v14.optional(v14.boolean())
707
+ });
708
+ var walletActionsSchema = v14.object({});
709
+ var accountPermissionSchema = v14.object({
710
+ type: v14.literal("account"),
711
+ resourceId: v14.string(),
712
+ clientId: v14.string(),
713
+ actions: accountActionsSchema
714
+ });
715
+ var walletPermissionSchema = v14.object({
716
+ type: v14.literal("wallet"),
717
+ resourceId: v14.string(),
718
+ clientId: v14.string(),
719
+ actions: walletActionsSchema
720
+ });
721
+ var PermissionRequestParams = v14.variant("type", [
712
722
  v14.object({
713
- ...v14.omit(permissions.resources.account.accountPermissionSchema, ["clientId", "actions"]).entries,
714
- actions: v14.partial(permissions.resources.account.accountActionsSchema)
723
+ ...v14.omit(accountPermissionSchema, ["clientId"]).entries
715
724
  }),
716
725
  v14.object({
717
- ...v14.omit(permissions.resources.wallet.walletPermissionSchema, ["clientId"]).entries,
718
- actions: v14.partial(permissions.resources.wallet.walletActionsSchema)
726
+ ...v14.omit(walletPermissionSchema, ["clientId"]).entries
719
727
  })
720
728
  ]);
729
+ var permission = v14.variant("type", [accountPermissionSchema, walletPermissionSchema]);
721
730
  var requestPermissionsMethodName = "wallet_requestPermissions";
722
- var requestPermissionsParamsSchema = v14.nullish(v14.array(permissionTemplate));
731
+ var requestPermissionsParamsSchema = v14.nullish(v14.array(PermissionRequestParams));
723
732
  var requestPermissionsResultSchema = v14.literal(true);
724
733
  var requestPermissionsRequestMessageSchema = v14.object({
725
734
  ...rpcRequestMessageSchema.entries,
@@ -764,7 +773,7 @@ var getWalletTypeRequestMessageSchema = v14.object({
764
773
  });
765
774
  var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
766
775
  var getCurrentPermissionsParamsSchema = v14.nullish(v14.null());
767
- var getCurrentPermissionsResultSchema = v14.array(permissions.store.permission);
776
+ var getCurrentPermissionsResultSchema = v14.array(permission);
768
777
  var getCurrentPermissionsRequestMessageSchema = v14.object({
769
778
  ...rpcRequestMessageSchema.entries,
770
779
  ...v14.object({
@@ -776,7 +785,7 @@ var getCurrentPermissionsRequestMessageSchema = v14.object({
776
785
  var getAccountMethodName = "wallet_getAccount";
777
786
  var getAccountParamsSchema = v14.nullish(v14.null());
778
787
  var getAccountResultSchema = v14.object({
779
- id: permissions.utils.account.accountIdSchema,
788
+ id: v14.string(),
780
789
  addresses: v14.array(addressSchema),
781
790
  walletType: walletTypeSchema
782
791
  });
@@ -791,7 +800,11 @@ var getAccountRequestMessageSchema = v14.object({
791
800
  var connectMethodName = "wallet_connect";
792
801
  var connectParamsSchema = v14.nullish(
793
802
  v14.object({
794
- permissions: v14.optional(v14.array(permissionTemplate))
803
+ permissions: v14.optional(v14.array(PermissionRequestParams)),
804
+ addresses: v14.optional(v14.array(v14.enum(AddressPurpose))),
805
+ message: v14.optional(
806
+ v14.pipe(v14.string(), v14.maxLength(80, "The message must not exceed 80 characters."))
807
+ )
795
808
  })
796
809
  );
797
810
  var connectResultSchema = getAccountResultSchema;
@@ -804,104 +817,179 @@ var connectRequestMessageSchema = v14.object({
804
817
  }).entries
805
818
  });
806
819
 
807
- // src/request/types/runesMethods.ts
820
+ // src/request/types/runesMethods/etch.ts
808
821
  import * as v15 from "valibot";
809
- var getRunesBalanceMethodName = "runes_getBalance";
810
- var getRunesBalanceParamsSchema = v15.nullish(v15.null());
811
- var getRunesBalanceResultSchema = v15.object({
812
- balances: v15.array(
813
- v15.object({
814
- runeName: v15.string(),
815
- amount: v15.string(),
816
- divisibility: v15.number(),
817
- symbol: v15.string(),
818
- inscriptionId: v15.nullish(v15.string())
819
- })
820
- )
821
- });
822
- var getRunesBalanceRequestMessageSchema = v15.object({
822
+ var runesEtchMethodName = "runes_etch";
823
+ var etchTermsSchema = v15.object({
824
+ amount: v15.string(),
825
+ cap: v15.string(),
826
+ heightStart: v15.optional(v15.string()),
827
+ heightEnd: v15.optional(v15.string()),
828
+ offsetStart: v15.optional(v15.string()),
829
+ offsetEnd: v15.optional(v15.string())
830
+ });
831
+ var inscriptionDetailsSchema = v15.object({
832
+ contentType: v15.string(),
833
+ contentBase64: v15.string()
834
+ });
835
+ var runesEtchParamsSchema = v15.object({
836
+ runeName: v15.string(),
837
+ divisibility: v15.optional(v15.number()),
838
+ symbol: v15.optional(v15.string()),
839
+ premine: v15.optional(v15.string()),
840
+ isMintable: v15.boolean(),
841
+ delegateInscriptionId: v15.optional(v15.string()),
842
+ destinationAddress: v15.string(),
843
+ refundAddress: v15.string(),
844
+ feeRate: v15.number(),
845
+ appServiceFee: v15.optional(v15.number()),
846
+ appServiceFeeAddress: v15.optional(v15.string()),
847
+ terms: v15.optional(etchTermsSchema),
848
+ inscriptionDetails: v15.optional(inscriptionDetailsSchema),
849
+ network: v15.optional(v15.enum(BitcoinNetworkType))
850
+ });
851
+ var runesEtchResultSchema = v15.object({
852
+ orderId: v15.string(),
853
+ fundTransactionId: v15.string(),
854
+ fundingAddress: v15.string()
855
+ });
856
+ var runesEtchRequestMessageSchema = v15.object({
823
857
  ...rpcRequestMessageSchema.entries,
824
858
  ...v15.object({
825
- method: v15.literal(getRunesBalanceMethodName),
826
- params: getRunesBalanceParamsSchema,
859
+ method: v15.literal(runesEtchMethodName),
860
+ params: runesEtchParamsSchema,
827
861
  id: v15.string()
828
862
  }).entries
829
863
  });
830
- var transferRunesMethodName = "runes_transfer";
831
- var transferRunesParamsSchema = v15.object({
832
- recipients: v15.array(
833
- v15.object({
834
- runeName: v15.string(),
835
- amount: v15.string(),
836
- address: v15.string()
864
+
865
+ // src/request/types/runesMethods/getBalance.ts
866
+ import * as v16 from "valibot";
867
+ var runesGetBalanceMethodName = "runes_getBalance";
868
+ var runesGetBalanceParamsSchema = v16.nullish(v16.null());
869
+ var runesGetBalanceResultSchema = v16.object({
870
+ balances: v16.array(
871
+ v16.object({
872
+ runeName: v16.string(),
873
+ amount: v16.string(),
874
+ divisibility: v16.number(),
875
+ symbol: v16.string(),
876
+ inscriptionId: v16.nullish(v16.string())
837
877
  })
838
878
  )
839
879
  });
840
- var transferRunesRequestSchema = v15.object({
880
+ var runesGetBalanceRequestMessageSchema = v16.object({
841
881
  ...rpcRequestMessageSchema.entries,
842
- ...v15.object({
843
- method: v15.literal(transferRunesMethodName),
844
- params: transferRunesParamsSchema,
845
- id: v15.string()
882
+ ...v16.object({
883
+ method: v16.literal(runesGetBalanceMethodName),
884
+ params: runesGetBalanceParamsSchema,
885
+ id: v16.string()
846
886
  }).entries
847
887
  });
848
- var TransferRunesResultSchema = v15.object({
849
- txid: v15.string()
888
+
889
+ // src/request/types/runesMethods/mint.ts
890
+ import * as v17 from "valibot";
891
+ var runesMintMethodName = "runes_mint";
892
+ var runesMintParamsSchema = v17.object({
893
+ appServiceFee: v17.optional(v17.number()),
894
+ appServiceFeeAddress: v17.optional(v17.string()),
895
+ destinationAddress: v17.string(),
896
+ feeRate: v17.number(),
897
+ refundAddress: v17.string(),
898
+ repeats: v17.number(),
899
+ runeName: v17.string(),
900
+ network: v17.optional(v17.enum(BitcoinNetworkType))
901
+ });
902
+ var runesMintResultSchema = v17.object({
903
+ orderId: v17.string(),
904
+ fundTransactionId: v17.string(),
905
+ fundingAddress: v17.string()
906
+ });
907
+ var runesMintRequestMessageSchema = v17.object({
908
+ ...rpcRequestMessageSchema.entries,
909
+ ...v17.object({
910
+ method: v17.literal(runesMintMethodName),
911
+ params: runesMintParamsSchema,
912
+ id: v17.string()
913
+ }).entries
914
+ });
915
+
916
+ // src/request/types/runesMethods/transfer.ts
917
+ import * as v18 from "valibot";
918
+ var runesTransferMethodName = "runes_transfer";
919
+ var runesTransferParamsSchema = v18.object({
920
+ recipients: v18.array(
921
+ v18.object({
922
+ runeName: v18.string(),
923
+ amount: v18.string(),
924
+ address: v18.string()
925
+ })
926
+ )
927
+ });
928
+ var runesTransferResultSchema = v18.object({
929
+ txid: v18.string()
930
+ });
931
+ var runesTransferRequestMessageSchema = v18.object({
932
+ ...rpcRequestMessageSchema.entries,
933
+ ...v18.object({
934
+ method: v18.literal(runesTransferMethodName),
935
+ params: runesTransferParamsSchema,
936
+ id: v18.string()
937
+ }).entries
850
938
  });
851
939
 
852
940
  // src/request/types/ordinalsMethods.ts
853
- import * as v16 from "valibot";
941
+ import * as v19 from "valibot";
854
942
  var getInscriptionsMethodName = "ord_getInscriptions";
855
- var getInscriptionsParamsSchema = v16.object({
856
- offset: v16.number(),
857
- limit: v16.number()
858
- });
859
- var getInscriptionsResultSchema = v16.object({
860
- total: v16.number(),
861
- limit: v16.number(),
862
- offset: v16.number(),
863
- inscriptions: v16.array(
864
- v16.object({
865
- inscriptionId: v16.string(),
866
- inscriptionNumber: v16.string(),
867
- address: v16.string(),
868
- collectionName: v16.optional(v16.string()),
869
- postage: v16.string(),
870
- contentLength: v16.string(),
871
- contentType: v16.string(),
872
- timestamp: v16.number(),
873
- offset: v16.number(),
874
- genesisTransaction: v16.string(),
875
- output: v16.string()
943
+ var getInscriptionsParamsSchema = v19.object({
944
+ offset: v19.number(),
945
+ limit: v19.number()
946
+ });
947
+ var getInscriptionsResultSchema = v19.object({
948
+ total: v19.number(),
949
+ limit: v19.number(),
950
+ offset: v19.number(),
951
+ inscriptions: v19.array(
952
+ v19.object({
953
+ inscriptionId: v19.string(),
954
+ inscriptionNumber: v19.string(),
955
+ address: v19.string(),
956
+ collectionName: v19.optional(v19.string()),
957
+ postage: v19.string(),
958
+ contentLength: v19.string(),
959
+ contentType: v19.string(),
960
+ timestamp: v19.number(),
961
+ offset: v19.number(),
962
+ genesisTransaction: v19.string(),
963
+ output: v19.string()
876
964
  })
877
965
  )
878
966
  });
879
- var getInscriptionsSchema = v16.object({
967
+ var getInscriptionsRequestMessageSchema = v19.object({
880
968
  ...rpcRequestMessageSchema.entries,
881
- ...v16.object({
882
- method: v16.literal(getInscriptionsMethodName),
969
+ ...v19.object({
970
+ method: v19.literal(getInscriptionsMethodName),
883
971
  params: getInscriptionsParamsSchema,
884
- id: v16.string()
972
+ id: v19.string()
885
973
  }).entries
886
974
  });
887
975
  var sendInscriptionsMethodName = "ord_sendInscriptions";
888
- var sendInscriptionsParamsSchema = v16.object({
889
- transfers: v16.array(
890
- v16.object({
891
- address: v16.string(),
892
- inscriptionId: v16.string()
976
+ var sendInscriptionsParamsSchema = v19.object({
977
+ transfers: v19.array(
978
+ v19.object({
979
+ address: v19.string(),
980
+ inscriptionId: v19.string()
893
981
  })
894
982
  )
895
983
  });
896
- var sendInscriptionsResultSchema = v16.object({
897
- txid: v16.string()
984
+ var sendInscriptionsResultSchema = v19.object({
985
+ txid: v19.string()
898
986
  });
899
- var sendInscriptionsSchema = v16.object({
987
+ var sendInscriptionsRequestMessageSchema = v19.object({
900
988
  ...rpcRequestMessageSchema.entries,
901
- ...v16.object({
902
- method: v16.literal(sendInscriptionsMethodName),
989
+ ...v19.object({
990
+ method: v19.literal(sendInscriptionsMethodName),
903
991
  params: sendInscriptionsParamsSchema,
904
- id: v16.string()
992
+ id: v19.string()
905
993
  }).entries
906
994
  });
907
995
 
@@ -918,13 +1006,13 @@ var request = async (method, params, providerId) => {
918
1006
  throw new Error("A wallet method is required");
919
1007
  }
920
1008
  const response = await provider.request(method, params);
921
- if (v17.is(rpcErrorResponseMessageSchema, response)) {
1009
+ if (v20.is(rpcErrorResponseMessageSchema, response)) {
922
1010
  return {
923
1011
  status: "error",
924
1012
  error: response.error
925
1013
  };
926
1014
  }
927
- if (v17.is(rpcSuccessResponseMessageSchema, response)) {
1015
+ if (v20.is(rpcSuccessResponseMessageSchema, response)) {
928
1016
  return {
929
1017
  status: "success",
930
1018
  result: response.result
@@ -1680,8 +1768,7 @@ var extractOrValidateCapabilities = (provider, reportedCapabilities) => {
1680
1768
  addListener: validateCapability("addListener")
1681
1769
  };
1682
1770
  return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
1683
- if (value)
1684
- return [...acc, capability];
1771
+ if (value) return [...acc, capability];
1685
1772
  return acc;
1686
1773
  }, []);
1687
1774
  };
@@ -1872,12 +1959,14 @@ export {
1872
1959
  BitcoinNetworkType,
1873
1960
  DefaultAdaptersInfo,
1874
1961
  MessageSigningProtocols,
1962
+ PermissionRequestParams,
1875
1963
  RpcErrorCode,
1876
1964
  RpcIdSchema,
1877
1965
  SatsConnectAdapter,
1878
- TransferRunesResultSchema,
1966
+ accountActionsSchema,
1879
1967
  accountChangeEventName,
1880
1968
  accountChangeSchema,
1969
+ accountPermissionSchema,
1881
1970
  addListener,
1882
1971
  addressSchema,
1883
1972
  connectMethodName,
@@ -1922,15 +2011,11 @@ export {
1922
2011
  getInfoResultSchema,
1923
2012
  getInscriptionsMethodName,
1924
2013
  getInscriptionsParamsSchema,
2014
+ getInscriptionsRequestMessageSchema,
1925
2015
  getInscriptionsResultSchema,
1926
- getInscriptionsSchema,
1927
2016
  getProviderById,
1928
2017
  getProviderOrThrow,
1929
2018
  getProviders,
1930
- getRunesBalanceMethodName,
1931
- getRunesBalanceParamsSchema,
1932
- getRunesBalanceRequestMessageSchema,
1933
- getRunesBalanceResultSchema,
1934
2019
  getSupportedWallets,
1935
2020
  getWalletTypeMethodName,
1936
2021
  getWalletTypeParamsSchema,
@@ -1939,7 +2024,7 @@ export {
1939
2024
  isProviderInstalled,
1940
2025
  networkChangeEventName,
1941
2026
  networkChangeSchema,
1942
- permissionTemplate,
2027
+ permission,
1943
2028
  removeDefaultProvider,
1944
2029
  renouncePermissionsMethodName,
1945
2030
  renouncePermissionsParamsSchema,
@@ -1954,11 +2039,27 @@ export {
1954
2039
  rpcRequestMessageSchema,
1955
2040
  rpcResponseMessageSchema,
1956
2041
  rpcSuccessResponseMessageSchema,
2042
+ runesEtchMethodName,
2043
+ runesEtchParamsSchema,
2044
+ runesEtchRequestMessageSchema,
2045
+ runesEtchResultSchema,
2046
+ runesGetBalanceMethodName,
2047
+ runesGetBalanceParamsSchema,
2048
+ runesGetBalanceRequestMessageSchema,
2049
+ runesGetBalanceResultSchema,
2050
+ runesMintMethodName,
2051
+ runesMintParamsSchema,
2052
+ runesMintRequestMessageSchema,
2053
+ runesMintResultSchema,
2054
+ runesTransferMethodName,
2055
+ runesTransferParamsSchema,
2056
+ runesTransferRequestMessageSchema,
2057
+ runesTransferResultSchema,
1957
2058
  sendBtcTransaction,
1958
2059
  sendInscriptionsMethodName,
1959
2060
  sendInscriptionsParamsSchema,
2061
+ sendInscriptionsRequestMessageSchema,
1960
2062
  sendInscriptionsResultSchema,
1961
- sendInscriptionsSchema,
1962
2063
  sendTransferMethodName,
1963
2064
  sendTransferParamsSchema,
1964
2065
  sendTransferRequestMessageSchema,
@@ -2007,10 +2108,9 @@ export {
2007
2108
  stxTransferStxParamsSchema,
2008
2109
  stxTransferStxRequestMessageSchema,
2009
2110
  stxTransferStxResultSchema,
2010
- transferRunesMethodName,
2011
- transferRunesParamsSchema,
2012
- transferRunesRequestSchema,
2111
+ walletActionsSchema,
2013
2112
  walletEventSchema,
2113
+ walletPermissionSchema,
2014
2114
  walletTypeSchema,
2015
2115
  walletTypes
2016
2116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.4.0-68f1213",
3
+ "version": "0.4.0-6eb2eb5",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",
@@ -26,8 +26,7 @@
26
26
  ]
27
27
  },
28
28
  "dependencies": {
29
- "@secretkeylabs/xverse-core": "24.0.0-4db3b55",
30
- "axios": "1.7.4",
29
+ "axios": "1.7.7",
31
30
  "bitcoin-address-validation": "2.2.3",
32
31
  "buffer": "6.0.3",
33
32
  "jsontokens": "4.0.1",