@snapshot-labs/snapshot.js 0.13.0 → 0.13.1

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.
@@ -3832,14 +3832,15 @@ function isEvmAddress(address$1) {
3832
3832
  return address.isAddress(address$1);
3833
3833
  }
3834
3834
  function getFormattedAddress(address$1, format) {
3835
- // Consider non-evm addresses as Starknet by default
3836
- // as there's no other way to differentiate them
3837
- const addressType = format !== null && format !== void 0 ? format : (isEvmAddress(address$1) ? 'evm' : 'starknet');
3835
+ if (typeof address$1 !== 'string' || !/^0[xX]/.test(address$1)) {
3836
+ throw new Error(`Invalid address: ${address$1}`);
3837
+ }
3838
+ const addressType = format !== null && format !== void 0 ? format : (address$1.length === 42 ? 'evm' : 'starknet');
3838
3839
  if (addressType === 'evm' && isEvmAddress(address$1))
3839
3840
  return address.getAddress(address$1);
3840
3841
  if (addressType === 'starknet' && isStarknetAddress(address$1))
3841
3842
  return starknet$1.validateAndParseAddress(address$1);
3842
- throw new Error(`Invalid address: ${address$1}`);
3843
+ throw new Error(`Invalid ${addressType} address: ${address$1}`);
3843
3844
  }
3844
3845
  function inputError(message) {
3845
3846
  return Promise.reject(new Error(message));
@@ -3822,14 +3822,15 @@ function isEvmAddress(address) {
3822
3822
  return isAddress(address);
3823
3823
  }
3824
3824
  function getFormattedAddress(address, format) {
3825
- // Consider non-evm addresses as Starknet by default
3826
- // as there's no other way to differentiate them
3827
- const addressType = format !== null && format !== void 0 ? format : (isEvmAddress(address) ? 'evm' : 'starknet');
3825
+ if (typeof address !== 'string' || !/^0[xX]/.test(address)) {
3826
+ throw new Error(`Invalid address: ${address}`);
3827
+ }
3828
+ const addressType = format !== null && format !== void 0 ? format : (address.length === 42 ? 'evm' : 'starknet');
3828
3829
  if (addressType === 'evm' && isEvmAddress(address))
3829
3830
  return getAddress(address);
3830
3831
  if (addressType === 'starknet' && isStarknetAddress(address))
3831
3832
  return validateAndParseAddress(address);
3832
- throw new Error(`Invalid address: ${address}`);
3833
+ throw new Error(`Invalid ${addressType} address: ${address}`);
3833
3834
  }
3834
3835
  function inputError(message) {
3835
3836
  return Promise.reject(new Error(message));