@aptos-labs/wallet-adapter-core 4.23.1 → 4.25.0

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/src/WalletCore.ts CHANGED
@@ -174,7 +174,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
174
174
  plugins: ReadonlyArray<Wallet>,
175
175
  optInWallets: ReadonlyArray<AvailableWallets>,
176
176
  dappConfig?: DappConfig,
177
- disableTelemetry?: boolean
177
+ disableTelemetry?: boolean,
178
178
  ) {
179
179
  super();
180
180
 
@@ -207,7 +207,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
207
207
  // new standard version installed. Pontem uses "Pontem" wallet name for previous versions and
208
208
  // "Pontem Wallet" with new version
209
209
  const existingStandardPontemWallet = this._standard_wallets.find(
210
- (wallet) => wallet.name == "Pontem Wallet"
210
+ (wallet) => wallet.name == "Pontem Wallet",
211
211
  );
212
212
  if (wallet.name === "Pontem" && existingStandardPontemWallet) {
213
213
  return;
@@ -219,7 +219,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
219
219
  * include the plugin wallet (i.e npm package)
220
220
  */
221
221
  const existingWalletIndex = this._standard_wallets.findIndex(
222
- (standardWallet) => standardWallet.name == wallet.name
222
+ (standardWallet) => standardWallet.name == wallet.name,
223
223
  );
224
224
  if (existingWalletIndex !== -1) return;
225
225
 
@@ -274,7 +274,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
274
274
  aptosStandardSupportedWalletList.map((supportedWallet) => {
275
275
  // Check if we already have this wallet as an installed plugin
276
276
  const existingPluginWalletIndex = this.wallets.findIndex(
277
- (wallet) => wallet.name === supportedWallet.name
277
+ (wallet) => wallet.name === supportedWallet.name,
278
278
  );
279
279
 
280
280
  // If the plugin wallet is installed, dont append and dont show it on the selector modal
@@ -285,7 +285,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
285
285
  // new standard version installed. Pontem uses "Pontem" wallet name for previous versions and
286
286
  // "Pontem Wallet" with new version
287
287
  const existingStandardPontemWallet = this.wallets.find(
288
- (wallet) => wallet.name == "Pontem"
288
+ (wallet) => wallet.name == "Pontem",
289
289
  );
290
290
  if (
291
291
  supportedWallet.name === "Pontem Wallet" &&
@@ -296,7 +296,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
296
296
 
297
297
  // Check if we already have this wallet as a AIP-62 wallet standard
298
298
  const existingStandardWallet = this._standard_wallets.find(
299
- (wallet) => wallet.name == supportedWallet.name
299
+ (wallet) => wallet.name == supportedWallet.name,
300
300
  );
301
301
 
302
302
  // If AIP-62 wallet detected but it is excluded by the dapp, dont add it to the wallets array
@@ -334,7 +334,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
334
334
  // Twallet SDK fires a register event so the adapter assumes it is an extension wallet
335
335
  // so filter out t wallet, remove it when twallet fixes it
336
336
  const wallets = extensionwWallets.filter(
337
- (wallet) => wallet.name !== "Dev T wallet" && wallet.name !== "T wallet"
337
+ (wallet) => wallet.name !== "Dev T wallet" && wallet.name !== "T wallet",
338
338
  );
339
339
 
340
340
  wallets.map((wallet: AptosStandardWallet) => {
@@ -392,7 +392,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
392
392
  * @param standardWallet An AIP-62 standard compatible wallet
393
393
  */
394
394
  private standardizeStandardWalletToPluginWalletType = (
395
- standardWallet: AptosStandardWallet
395
+ standardWallet: AptosStandardWallet,
396
396
  ) => {
397
397
  let standardWalletConvertedToWallet: Wallet = {
398
398
  name: standardWallet.name as WalletName,
@@ -425,7 +425,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
425
425
 
426
426
  // Remove optional duplications in the _all_wallets array
427
427
  this._all_wallets = this._all_wallets.filter(
428
- (item) => item.name !== standardWalletConvertedToWallet.name
428
+ (item) => item.name !== standardWalletConvertedToWallet.name,
429
429
  );
430
430
  this._all_wallets.push(standardWalletConvertedToWallet);
431
431
 
@@ -467,7 +467,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
467
467
  * @param account An account
468
468
  */
469
469
  private ensureAccountExists(
470
- account: AccountInfo | null
470
+ account: AccountInfo | null,
471
471
  ): asserts account is AccountInfo {
472
472
  if (!account) {
473
473
  throw new WalletAccountError("Account is not set").name;
@@ -553,7 +553,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
553
553
  | AccountInfo
554
554
  | StandardAccountInfo
555
555
  | UserResponse<StandardAccountInfo>
556
- | null
556
+ | null,
557
557
  ): void {
558
558
  if (account === null) {
559
559
  this._account = null;
@@ -722,7 +722,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
722
722
  const allDetectedWallets = this._all_wallets as Array<Wallet>;
723
723
 
724
724
  const selectedWallet = allDetectedWallets.find(
725
- (wallet: Wallet) => wallet.name === walletName
725
+ (wallet: Wallet) => wallet.name === walletName,
726
726
  );
727
727
  if (!selectedWallet) return;
728
728
 
@@ -731,7 +731,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
731
731
  // if the selected wallet is already connected, we don't need to connect again
732
732
  if (this._wallet?.name === walletName)
733
733
  throw new WalletConnectionError(
734
- `${walletName} wallet is already connected`
734
+ `${walletName} wallet is already connected`,
735
735
  ).message;
736
736
  }
737
737
 
@@ -741,11 +741,24 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
741
741
  isRedirectable() &&
742
742
  selectedWallet.readyState !== WalletReadyState.Installed
743
743
  ) {
744
- // use wallet deep link
745
- if (selectedWallet.isAIP62Standard && selectedWallet.openInMobileApp) {
746
- selectedWallet.openInMobileApp();
747
- return;
744
+ // If wallet is AIP-62 compatible
745
+ if (selectedWallet.isAIP62Standard) {
746
+ // If wallet has a openInMobileApp method, use it
747
+ if (selectedWallet.openInMobileApp) {
748
+ selectedWallet.openInMobileApp();
749
+ return;
750
+ }
751
+ // If wallet has a deeplinkProvider property, i.e wallet is on the internal registry, use it
752
+ const uninstalledWallet =
753
+ selectedWallet as AptosStandardSupportedWallet;
754
+ if (uninstalledWallet.deeplinkProvider) {
755
+ const url = encodeURIComponent(window.location.href);
756
+ const location = uninstalledWallet.deeplinkProvider.concat(url);
757
+ window.location.href = location;
758
+ return;
759
+ }
748
760
  }
761
+ // Wallet is on the old standard, check if it has a deeplinkProvider method property
749
762
  if (selectedWallet.deeplinkProvider) {
750
763
  const url = encodeURIComponent(window.location.href);
751
764
  const location = selectedWallet.deeplinkProvider({ url });
@@ -830,7 +843,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
830
843
  * @returns The pending transaction hash (V1 output) | PendingTransactionResponse (V2 output)
831
844
  */
832
845
  async signAndSubmitTransaction(
833
- transactionInput: InputTransactionData
846
+ transactionInput: InputTransactionData,
834
847
  ): Promise<
835
848
  { hash: Types.HexEncodedBytes; output?: any } | PendingTransactionResponse
836
849
  > {
@@ -872,7 +885,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
872
885
  aptos,
873
886
  this._account,
874
887
  this._wallet,
875
- this._standard_wallets
888
+ this._standard_wallets,
876
889
  );
877
890
  return { hash, output };
878
891
  } else {
@@ -883,7 +896,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
883
896
  this._network,
884
897
  this._wallet,
885
898
  transactionInput,
886
- this._dappConfig
899
+ this._dappConfig,
887
900
  );
888
901
  return { hash, output };
889
902
  }
@@ -924,7 +937,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
924
937
  async signTransaction(
925
938
  transactionOrPayload: AnyRawTransaction | Types.TransactionPayload,
926
939
  asFeePayer?: boolean,
927
- options?: InputGenerateTransactionOptions
940
+ options?: InputGenerateTransactionOptions,
928
941
  ): Promise<AccountAuthenticator> {
929
942
  try {
930
943
  this.ensureWalletExists(this._wallet);
@@ -941,7 +954,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
941
954
  return await this.walletStandardCore.signTransaction(
942
955
  transactionOrPayload,
943
956
  this._wallet,
944
- asFeePayer
957
+ asFeePayer,
945
958
  );
946
959
  } else if (this._wallet.isSignTransactionV1_1) {
947
960
  // This wallet is AIP-62 compliant and supports transaction inputs
@@ -966,7 +979,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
966
979
  ? { address: AccountAddress.from(optionsV1.sender) }
967
980
  : undefined,
968
981
  },
969
- this._wallet
982
+ this._wallet,
970
983
  );
971
984
  return authenticator;
972
985
  } else {
@@ -975,7 +988,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
975
988
  const sender = this._account.address;
976
989
  const payload = await generateTransactionPayloadFromV1Input(
977
990
  aptosConfig,
978
- transactionOrPayload
991
+ transactionOrPayload,
979
992
  );
980
993
  const optionsV1 = options as CompatibleTransactionOptions;
981
994
  const optionsV2 = {
@@ -996,7 +1009,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
996
1009
  return await this.walletStandardCore.signTransaction(
997
1010
  new SimpleTransaction(rawTransaction),
998
1011
  this._wallet,
999
- false
1012
+ false,
1000
1013
  );
1001
1014
  }
1002
1015
  }
@@ -1007,7 +1020,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1007
1020
  if ("rawTransaction" in transactionOrPayload) {
1008
1021
  const accountAuthenticator = (await this._wallet.signTransaction(
1009
1022
  transactionOrPayload,
1010
- asFeePayer
1023
+ asFeePayer,
1011
1024
  )) as AccountAuthenticator;
1012
1025
 
1013
1026
  return accountAuthenticator;
@@ -1022,7 +1035,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1022
1035
  gas_unit_price: options?.gasUnitPrice
1023
1036
  ? BigInt(options?.gasUnitPrice)
1024
1037
  : undefined,
1025
- }
1038
+ },
1026
1039
  );
1027
1040
 
1028
1041
  if (!response) {
@@ -1041,7 +1054,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1041
1054
 
1042
1055
  const accountAuthenticator = new AccountAuthenticatorEd25519(
1043
1056
  new Ed25519PublicKey(publicKey),
1044
- new Ed25519Signature(signature)
1057
+ new Ed25519Signature(signature),
1045
1058
  );
1046
1059
  return accountAuthenticator;
1047
1060
  }
@@ -1049,7 +1062,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1049
1062
 
1050
1063
  // If we are here it means this wallet does not support signTransaction
1051
1064
  throw new WalletNotSupportedMethod(
1052
- `Sign Transaction is not supported by ${this.wallet?.name}`
1065
+ `Sign Transaction is not supported by ${this.wallet?.name}`,
1053
1066
  ).message;
1054
1067
  } catch (error: any) {
1055
1068
  const errMsg = generalizedErrorMessage(error);
@@ -1086,7 +1099,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1086
1099
  * @returns PendingTransactionResponse
1087
1100
  */
1088
1101
  async submitTransaction(
1089
- transaction: InputSubmitTransactionData
1102
+ transaction: InputSubmitTransactionData,
1090
1103
  ): Promise<PendingTransactionResponse> {
1091
1104
  try {
1092
1105
  this.ensureWalletExists(this._wallet);
@@ -1139,7 +1152,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1139
1152
  await this.setAnsName();
1140
1153
  this.recordEvent("account_change");
1141
1154
  this.emit("accountChange", this._account);
1142
- }
1155
+ },
1143
1156
  );
1144
1157
  } catch (error: any) {
1145
1158
  const errMsg = generalizedErrorMessage(error);
@@ -1160,7 +1173,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1160
1173
  this.setNetwork(data);
1161
1174
  await this.setAnsName();
1162
1175
  this.emit("networkChange", this._network);
1163
- }
1176
+ },
1164
1177
  );
1165
1178
  } catch (error: any) {
1166
1179
  const errMsg = generalizedErrorMessage(error);
@@ -1198,7 +1211,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1198
1211
  return response.args;
1199
1212
  }
1200
1213
  throw new WalletChangeNetworkError(
1201
- `${this._wallet.name} does not support changing network request`
1214
+ `${this._wallet.name} does not support changing network request`,
1202
1215
  ).message;
1203
1216
  } catch (error: any) {
1204
1217
  const errMsg = generalizedErrorMessage(error);
@@ -1220,14 +1233,14 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
1220
1233
  if (this._wallet.isAIP62Standard) {
1221
1234
  return this.walletStandardCore.signMessageAndVerify(
1222
1235
  message,
1223
- this._wallet
1236
+ this._wallet,
1224
1237
  );
1225
1238
  }
1226
1239
 
1227
1240
  return await this.walletCoreV1.signMessageAndVerify(
1228
1241
  message,
1229
1242
  this._wallet,
1230
- this._account
1243
+ this._account,
1231
1244
  );
1232
1245
  } catch (error: any) {
1233
1246
  const errMsg = generalizedErrorMessage(error);
package/src/ga/index.ts CHANGED
@@ -21,7 +21,7 @@ export class GA4 {
21
21
 
22
22
  myScript.setAttribute(
23
23
  "src",
24
- `https://www.googletagmanager.com/gtag/js?id=${gaID}`
24
+ `https://www.googletagmanager.com/gtag/js?id=${gaID}`,
25
25
  );
26
26
 
27
27
  const that = this;
@@ -19,17 +19,17 @@ import { WalletSignAndSubmitMessageError } from "../error";
19
19
 
20
20
  export function isMobile(): boolean {
21
21
  return /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i.test(
22
- navigator.userAgent
22
+ navigator.userAgent,
23
23
  );
24
24
  }
25
25
 
26
26
  export function isInAppBrowser(): boolean {
27
27
  const isIphone = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(
28
- navigator.userAgent
28
+ navigator.userAgent,
29
29
  );
30
30
 
31
31
  const isAndroid = /(Android).*Version\/[\d.]+.*Chrome\/[^\s]+ Mobile/i.test(
32
- navigator.userAgent
32
+ navigator.userAgent,
33
33
  );
34
34
 
35
35
  return isIphone || isAndroid;
@@ -55,14 +55,14 @@ export function generalizedErrorMessage(error: any): string {
55
55
  // Serializable, so if each argument is of an instance of a class
56
56
  // the extends Serializable - we know these are BCS arguments
57
57
  export const areBCSArguments = (
58
- args: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>
58
+ args: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>,
59
59
  ): boolean => {
60
60
  // `every` returns true if the array is empty, so
61
61
  // first check the array length
62
62
  if (args.length === 0) return false;
63
63
  return args.every(
64
64
  (arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes) =>
65
- arg instanceof Serializable
65
+ arg instanceof Serializable,
66
66
  );
67
67
  };
68
68
 
@@ -75,7 +75,7 @@ export const areBCSArguments = (
75
75
  */
76
76
  export const getAptosConfig = (
77
77
  networkInfo: NetworkInfo | StandardNetworkInfo | null,
78
- dappConfig: DappConfig | undefined
78
+ dappConfig: DappConfig | undefined,
79
79
  ): AptosConfig => {
80
80
  if (!networkInfo) {
81
81
  throw new Error("Undefined network");
@@ -97,10 +97,10 @@ export const getAptosConfig = (
97
97
  });
98
98
  }
99
99
 
100
- return new AptosConfig({
101
- network: Network.CUSTOM,
102
- fullnode: networkInfo.url,
103
- });
100
+ // Custom networks are not supported, please ensure that the wallet is returning the appropriate network Mainnet, Testnet, Devnet, Local
101
+ throw new Error(
102
+ "Invalid network, custom network not supported with Aptos wallet adapter to prevent user from using an unexpected network.",
103
+ );
104
104
  };
105
105
 
106
106
  /**
@@ -110,7 +110,7 @@ export const getAptosConfig = (
110
110
  * @returns boolean
111
111
  */
112
112
  export const isAptosNetwork = (
113
- networkInfo: NetworkInfo | StandardNetworkInfo | null
113
+ networkInfo: NetworkInfo | StandardNetworkInfo | null,
114
114
  ): boolean => {
115
115
  if (!networkInfo) {
116
116
  throw new Error("Undefined network");
@@ -140,7 +140,7 @@ export const fetchDevnetChainId = async (): Promise<number> => {
140
140
  * as a string, this function converts the string to Uint8Array.
141
141
  */
142
142
  export const handlePublishPackageTransaction = (
143
- transactionInput: InputTransactionData
143
+ transactionInput: InputTransactionData,
144
144
  ) => {
145
145
  // convert the first argument, metadataBytes, to uint8array if is a string
146
146
  let metadataBytes = transactionInput.data.functionArguments[0];
@@ -159,7 +159,7 @@ export const handlePublishPackageTransaction = (
159
159
  });
160
160
  } else {
161
161
  throw new WalletSignAndSubmitMessageError(
162
- "The bytecode argument must be an array."
162
+ "The bytecode argument must be an array.",
163
163
  ).message;
164
164
  }
165
165
 
@@ -28,7 +28,7 @@ export function scopePollingDetectionStrategy(detect: () => boolean): void {
28
28
  once: true,
29
29
  });
30
30
  disposers.push(() =>
31
- document.removeEventListener("DOMContentLoaded", detectAndDispose)
31
+ document.removeEventListener("DOMContentLoaded", detectAndDispose),
32
32
  );
33
33
  }
34
34
 
@@ -11,7 +11,9 @@ import { isRedirectable } from "./helpers";
11
11
  */
12
12
  export function partitionWallets(
13
13
  wallets: ReadonlyArray<AnyAptosWallet>,
14
- partitionFunction: (wallet: AnyAptosWallet) => boolean = isInstalledOrLoadable
14
+ partitionFunction: (
15
+ wallet: AnyAptosWallet,
16
+ ) => boolean = isInstalledOrLoadable,
15
17
  ) {
16
18
  const defaultWallets: Array<AnyAptosWallet> = [];
17
19
  const moreWallets: Array<AnyAptosWallet> = [];
@@ -51,7 +53,7 @@ export function truncateAddress(address: string | undefined) {
51
53
 
52
54
  /** Returns `true` if the provided wallet is an Aptos Connect wallet. */
53
55
  export function isAptosConnectWallet(
54
- wallet: WalletInfo | AnyAptosWallet | AptosStandardWallet
56
+ wallet: WalletInfo | AnyAptosWallet | AptosStandardWallet,
55
57
  ) {
56
58
  if (!wallet.url) return false;
57
59
  return wallet.url.startsWith(APTOS_CONNECT_BASE_URL);
@@ -64,7 +66,7 @@ export function isAptosConnectWallet(
64
66
  export function getAptosConnectWallets(wallets: ReadonlyArray<AnyAptosWallet>) {
65
67
  const { defaultWallets, moreWallets } = partitionWallets(
66
68
  wallets,
67
- isAptosConnectWallet
69
+ isAptosConnectWallet,
68
70
  );
69
71
  return { aptosConnectWallets: defaultWallets, otherWallets: moreWallets };
70
72
  }
@@ -93,7 +95,7 @@ export interface WalletSortingOptions {
93
95
  */
94
96
  export function groupAndSortWallets(
95
97
  wallets: ReadonlyArray<AnyAptosWallet>,
96
- options?: WalletSortingOptions
98
+ options?: WalletSortingOptions,
97
99
  ) {
98
100
  const { aptosConnectWallets, otherWallets } = getAptosConnectWallets(wallets);
99
101
  const { defaultWallets, moreWallets } = partitionWallets(otherWallets);
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const WALLET_ADAPTER_CORE_VERSION = "4.23.1";
1
+ export const WALLET_ADAPTER_CORE_VERSION = "4.25.0";