forked from safe-global/safe-smart-account
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request safe-global#331 from safe-global/features
Fix Safe version feature helper
- Loading branch information
Showing
12 changed files
with
45 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './eip-3770' | ||
export * from './eip-712' | ||
export * from './safeVersions' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import semverSatisfies from 'semver/functions/satisfies' | ||
|
||
export enum SAFE_FEATURES { | ||
SAFE_TX_GAS_OPTIONAL = 'SAFE_TX_GAS_OPTIONAL', | ||
SAFE_TX_GUARDS = 'SAFE_TX_GUARDS', | ||
SAFE_FALLBACK_HANDLER = 'SAFE_FALLBACK_HANDLER', | ||
ETH_SIGN = 'ETH_SIGN' | ||
} | ||
|
||
const SAFE_FEATURES_BY_VERSION: Record<SAFE_FEATURES, string> = { | ||
[SAFE_FEATURES.SAFE_TX_GAS_OPTIONAL]: '>=1.3.0', | ||
[SAFE_FEATURES.SAFE_TX_GUARDS]: '>=1.3.0', | ||
[SAFE_FEATURES.SAFE_FALLBACK_HANDLER]: '>=1.1.1', | ||
[SAFE_FEATURES.ETH_SIGN]: '>=1.1.0' | ||
} | ||
|
||
export const hasSafeFeature = (feature: SAFE_FEATURES, version: string): boolean => { | ||
if (!(feature in SAFE_FEATURES_BY_VERSION)) { | ||
return false | ||
} | ||
|
||
return semverSatisfies(version, SAFE_FEATURES_BY_VERSION[feature]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters