-
Notifications
You must be signed in to change notification settings - Fork 1
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 #54 from valory-xyz/mohan/prohibeted-addresses-cou…
…ntries-1 feat: update functions for prohibited addresses & countries
- Loading branch information
Showing
7 changed files
with
51 additions
and
39 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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// list of tiny reusable components | ||
|
||
import React from 'react'; | ||
|
||
export const CannotConnectAddressOfacError = () => ( | ||
<> | ||
Cannot connect – address is on | ||
<a | ||
rel="noreferrer" | ||
href="https://www.treasury.gov/ofac/downloads/sdnlist.pdf" | ||
target="_blank" | ||
> | ||
OFAC SDN list | ||
</a> | ||
</> | ||
); |
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,40 +1,8 @@ | ||
import React from 'react'; | ||
import { toLower } from 'lodash'; | ||
import prohibitedAddresses from './prohibited-addresses.json'; | ||
import prohibitedCountries from './prohibited-countries.json'; | ||
import { notifyError } from '../functions'; | ||
|
||
/** | ||
* Check if the address is prohibited | ||
*/ | ||
export const isAddressProhibited = (address: string | null) => { | ||
if (!address) return false; | ||
|
||
const addresses = prohibitedAddresses.map((e) => toLower(e)); | ||
return addresses.includes(toLower(address)); | ||
}; | ||
|
||
/** | ||
* Check if the country is prohibited | ||
*/ | ||
export const isCountryProhibited = (country: string | null) => { | ||
if (!country) return false; | ||
|
||
const prohibitedCountriesCode = Object.values(prohibitedCountries); | ||
return prohibitedCountriesCode.includes(country); | ||
}; | ||
|
||
export const notifyProhibitedAddressError = () => { | ||
return notifyError( | ||
<> | ||
Cannot connect – address is on | ||
<a | ||
rel="noreferrer" | ||
href="https://www.treasury.gov/ofac/downloads/sdnlist.pdf" | ||
target="_blank" | ||
> | ||
OFAC SDN list | ||
</a> | ||
</>, | ||
); | ||
}; | ||
export { | ||
isAddressProhibited, | ||
isCountryProhibited, | ||
} from './prohibitedCountriesAndAddresses'; | ||
export { prohibitedAddresses, prohibitedCountries }; |
23 changes: 23 additions & 0 deletions
23
src/functions/prohibitedCountriesAndAddresses/prohibitedCountriesAndAddresses.ts
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 { toLower } from 'lodash'; | ||
import prohibitedAddresses from './prohibited-addresses.json'; | ||
import prohibitedCountries from './prohibited-countries.json'; | ||
|
||
/** | ||
* Check if the address is prohibited | ||
*/ | ||
export const isAddressProhibited = (address: string | null) => { | ||
if (!address) return false; | ||
|
||
const addresses = prohibitedAddresses.map((e) => toLower(e)); | ||
return addresses.includes(toLower(address)); | ||
}; | ||
|
||
/** | ||
* Check if the country is prohibited | ||
*/ | ||
export const isCountryProhibited = (country: string | null) => { | ||
if (!country) return false; | ||
|
||
const prohibitedCountriesCode = Object.values(prohibitedCountries); | ||
return prohibitedCountriesCode.includes(country); | ||
}; |