Skip to content

Commit

Permalink
Merge pull request #5235 from swaponline/phpx_chain
Browse files Browse the repository at this point in the history
Add phpX blockchain
  • Loading branch information
shendel authored Feb 7, 2024
2 parents 0bcfe5f + a1ec1fd commit 3bea301
Show file tree
Hide file tree
Showing 50 changed files with 221 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/common/erc20Like/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,10 @@ export default {
defaultParams: DEFAULT_CURRENCY_PARAMETERS.evmLikeToken,
web3: new Web3(providers.fkw_provider),
}),
phpx20: new erc20LikeHelper({
standard: 'phpx20',
currency: 'phpx',
defaultParams: DEFAULT_CURRENCY_PARAMETERS.evmLikeToken,
web3: new Web3(providers.phpx_provider),
}),
}
3 changes: 3 additions & 0 deletions src/common/helpers/constants/ADDRESSES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const WrapperCurrency = {
421611: '',
1666700000: '',
1313161556: '',

52767: '0x87a6417F03E106A05698F18829bB3a40CBC54f61', // PHPx Mainnet Wrapped

}

export default {
Expand Down
1 change: 1 addition & 0 deletions src/common/helpers/constants/COINS_WITH_DYNAMIC_FEE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export default [
'ghost',
'next',
'fkw',
'phpx',
]
12 changes: 12 additions & 0 deletions src/common/helpers/constants/DEFAULT_CURRENCY_PARAMETERS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ export default {
fast: 2000,
},
},
phpx: {
limit: {
send: 21 * 1e3,
contractInteract: 200 * 1e3,
swap: 70 * 1e3,
},
price: {
slow: 100,
normal: 1000,
fast: 2000,
},
},
evmLike: {
limit: {
send: 21 * 1e3,
Expand Down
1 change: 1 addition & 0 deletions src/common/helpers/constants/MIN_AMOUNT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
phi_v1: 0.001,
phi: 0.001,
fkw: 0.001,
phpx: 0.001,
ame: 0.001,
btc: 0.00015,
ghost: 0.00015,
Expand Down
1 change: 1 addition & 0 deletions src/common/helpers/constants/MIN_AMOUNT_OFFER.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
aureth: 0.0006,
xdai: 0.0006,
ftm: 0.0006,
phpx: 0.0006,
avax: 0.0006,
movr: 0.0006,
one: 0.0006,
Expand Down
5 changes: 5 additions & 0 deletions src/common/helpers/ethLikeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,9 @@ export default {
defaultParams: DEFAULT_CURRENCY_PARAMETERS.fkw,
web3: new Web3(config.web3.fkw_provider),
}),
phpx: new ethLikeHelper({
currency: 'PHPX',
defaultParams: DEFAULT_CURRENCY_PARAMETERS.phpx,
web3: new Web3(config.web3.phpx_provider),
}),
}
14 changes: 14 additions & 0 deletions src/core/swap.app/constants/COINS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const COIN_TYPE = Object.freeze({
PHI_V1_TOKEN: 'PHI_V1_TOKEN',
PHI_TOKEN: 'PHI_TOKEN',
FKW_TOKEN: 'FKW_TOKEN',
PHPX_TOKEN: 'PHPX_TOKEN',
})

export const TOKEN_STANDARD = Object.freeze({
Expand All @@ -29,6 +30,7 @@ export const TOKEN_STANDARD = Object.freeze({
PHI20_V1: 'PHI20_V1',
PHI20: 'PHI20',
FKW20: 'FKW20',
PHPX20: 'PHPX20',
})

export const BLOCKCHAIN = Object.freeze({
Expand All @@ -49,6 +51,7 @@ export const BLOCKCHAIN = Object.freeze({
PHI_V1: 'PHI_V1',
PHI: 'PHI',
FKW: 'FKW',
PHPX: 'PHPX',
})

export const BASE_TOKEN_CURRENCY = Object.freeze({
Expand All @@ -65,6 +68,7 @@ export const BASE_TOKEN_CURRENCY = Object.freeze({
PHI_V1: 'PHI_V1',
PHI: 'PHI',
FKW: 'FKW',
PHPX: 'PHPX',
})

export const COIN_MODEL = Object.freeze({
Expand Down Expand Up @@ -196,6 +200,15 @@ export const COIN_DATA = {
model: COIN_MODEL.AB,
precision: 18,
},
PHPX: {
ticker: 'PHPX',
name: 'PHPX',
type: COIN_TYPE.PHPX_TOKEN,
blockchain: BLOCKCHAIN.PHPX,
standard: TOKEN_STANDARD.PHPX20,
model: COIN_MODEL.AB,
precision: 18,
},
USDT: {
ticker: 'USDT',
name: 'Tether',
Expand Down Expand Up @@ -278,6 +291,7 @@ export const NATIVE = {
phi_v1: 'PHI_V1',
phi: 'PHI',
fkw: 'FKW',
phpx: 'PHPX',
ghost: 'GHOST',
next: 'NEXT',
}
Expand Down
8 changes: 8 additions & 0 deletions src/core/swap.app/util/tokenRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,12 @@ export default {
isCoinAddress: typeforce.isCoinAddress.FKW,
isPublicKey: typeforce.isPublicKey.FKW,
}),
phpx20: new TokenRegistrar({
blockchainType: BLOCKCHAIN_TYPE.PHPX,
tokenStandard: TOKEN_STANDARD.PHPX20,
coinType: COIN_TYPE.PHPX_TOKEN,
blockchainModel: COIN_DATA.PHPX.model,
isCoinAddress: typeforce.isCoinAddress.PHPX,
isPublicKey: typeforce.isPublicKey.PHPX,
}),
}
2 changes: 2 additions & 0 deletions src/core/swap.app/util/typeforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const isCoinAddress = { // TODO: move to front helpers
[constants.COINS.phi_v1]: isEvmAddress,
[constants.COINS.phi]: isEvmAddress,
[constants.COINS.fkw]: isEvmAddress,
[constants.COINS.phpx]: isEvmAddress,
[constants.COINS.btc]: (value) => typeof value === 'string' && /^[A-Za-z0-9]{26,35}$/.test(value),
[constants.COINS.ghost]: (value) => typeof value === 'string' && /^[A-Za-z0-9]{26,35}$/.test(value),
[constants.COINS.next]: (value) => typeof value === 'string' && /^[A-Za-z0-9]{26,35}$/.test(value),
Expand All @@ -59,6 +60,7 @@ const isPublicKey = {
[constants.COINS.phi_v1]: '?String',
[constants.COINS.phi]: '?String',
[constants.COINS.fkw]: '?String',
[constants.COINS.phpx]: '?String',
[constants.COINS.btc]: (value) => typeof value === 'string' && /^[A-Za-z0-9]{66}$/.test(value),
[constants.COINS.ghost]: (value) => typeof value === 'string' && /^[A-Za-z0-9]{66}$/.test(value),
[constants.COINS.next]: (value) => typeof value === 'string' && /^[A-Za-z0-9]{66}$/.test(value),
Expand Down
1 change: 1 addition & 0 deletions src/front/config/mainnet/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ export default {
noxon: 'https://noxon.wpmix.net',
phiscan: 'https://phiscan.com/api',
fkwscan: 'https://explorer.fokawa.com/api',
phpxscan: 'https://explorer.phpx.network/api',
WalletConnectProjectId: 'a23677c4af3139b4eccb52981f76ad94',
}
1 change: 1 addition & 0 deletions src/front/config/mainnet/evmNetworkVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default [
4181, // PHI v1
144, // PHI v2
40821, // FKW (Fokawa)
52767, // PHPX
]
9 changes: 9 additions & 0 deletions src/front/config/mainnet/evmNetworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,13 @@ export default {
blockExplorerUrls: [link.fkw_Explorer],
hasWalletConnect: false,
},
PHPX: {
currency: 'PHPX',
chainId: '0xCE1F',
networkVersion: 52767,
chainName: 'PHPX Network',
rpcUrls: [web3.phpx_provider],
blockExplorerUrls: [link.phpx_Explorer],
hasWalletConnect: false,
},
}
1 change: 1 addition & 0 deletions src/front/config/mainnet/hiddenCoins.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default [
'PHI_V1',
'PHI',
'FKW',
'PHPX',
'{ETH}SWAP',
'{ETH}HDP',
'{ETH}USDT',
Expand Down
2 changes: 2 additions & 0 deletions src/front/config/mainnet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import bep20 from './bep20'
import phi20_v1 from './phi20'
import phi20 from './phi20'
import fkw20 from './fkw20'
import phpx20 from './phpx20'
import api from './api'
import swapContract from './swapContract'
import feeRates from './feeRates'
Expand All @@ -34,6 +35,7 @@ export default {
phi20_v1,
phi20,
fkw20,
phpx20,
erc20matic,
erc20xdai,
erc20ftm,
Expand Down
1 change: 1 addition & 0 deletions src/front/config/mainnet/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export default {
phi_v1Explorer: 'https://explorer.phi.network',
phi_Explorer: 'https://phiscan.com',
fkw_Explorer: 'https://explorer.fokawa.com',
phpx_Explorer: 'https://explorer.phpx.network',
}
1 change: 1 addition & 0 deletions src/front/config/mainnet/phpx20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
3 changes: 3 additions & 0 deletions src/front/config/mainnet/swapContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ export default {
fkwFactory: '0xcE72A00dfe506Bff0398CBA51BE8853D8Cb5F099',
fkwRouter: '0x663A8a85FaB794f95F8C098A0806bdc1D9D33d76',

phpxFactory: '0x48d7ac38530697aDB91061B6D141C8c763edE565',
phpxRouter: '0x83048f0Bf34FEeD8CEd419455a4320A735a92e9d',

affiliateAddress: '0x873351e707257C28eC6fAB1ADbc850480f6e0633',
}
1 change: 1 addition & 0 deletions src/front/config/mainnet/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default {
phi_v1_provider: 'https://rpc1.phi.network',
phi_provider: 'https://connect.phi.network',
fkw_provider: 'https://mainnet-rpc.fokawa.com',
phpx_provider: 'https://rpc.phpx.network',
}
1 change: 1 addition & 0 deletions src/front/config/testnet/evmNetworkVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export default [
1666700000, // ONE Testnet
181, // AME testnet
1313161556, // AURETH Aurora Betanet
52767, // PHPX
]
9 changes: 9 additions & 0 deletions src/front/config/testnet/evmNetworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,13 @@ export default {
rpcUrls: [web3.fwk_provider],
blockExplorerUrls: [link.fkw_Explorer],
},
PHPX: {
currency: 'PHPX',
chainId: '0xCE1F',
networkVersion: 52767,
chainName: 'PHPX Network',
rpcUrls: [web3.phpx_provider],
blockExplorerUrls: [link.phpx_Explorer],
hasWalletConnect: false,
},
}
2 changes: 2 additions & 0 deletions src/front/config/testnet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import erc20aurora from './erc20aurora'
import phi20_v1 from './phi20'
import phi20 from './phi20_v2'
import fkw20 from './fkw20'
import phpx20 from './phpx20'
import api from './api'
import swapContract from './swapContract'
import feeRates from './feeRates'
Expand Down Expand Up @@ -42,6 +43,7 @@ export default {
phi20_v1,
phi20,
fkw20,
phpx20,
swapContract,
feeRates,
hiddenCoins,
Expand Down
1 change: 1 addition & 0 deletions src/front/config/testnet/phpx20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
1 change: 1 addition & 0 deletions src/front/config/testnet/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default {
phi_v1_provider: '',
phi_provider: '',
fkw_provider: '',
phpx_provider: 'https://rpc.phpx.network',
}
2 changes: 2 additions & 0 deletions src/front/externalConfigs/mainnet-localhost.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ window.buildOptions = {
phi_v1: true,
phi: true,
fkw: true,
phpx: true,
},
blockchainSwapEnabled: {
btc: true,
Expand All @@ -135,6 +136,7 @@ window.buildOptions = {
phi_v1: false,
phi: false,
fkw: false,
phpx: false,
},
defaultExchangePair: {
buy: '{eth}wbtc',
Expand Down
2 changes: 2 additions & 0 deletions src/front/externalConfigs/swaponline.github.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ window.buildOptions = {
phi_v1: true,
phi: true,
fkw: true,
phpx: true,
},
blockchainSwapEnabled: {
btc: true,
Expand All @@ -84,6 +85,7 @@ window.buildOptions = {
phi_v1: false,
phi: false,
fkw: false,
phpx: false,
},
defaultExchangePair: {
buy: '{eth}wbtc',
Expand Down
6 changes: 6 additions & 0 deletions src/front/shared/components/Coin/Coin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const defaultCurrencyColors = {
'phi_v1': '#1C0237',
'phi': '#1C0237',
'fkw': '#f2f9f6',
'phpx': '#000000',
'usdt': '#33a681',
'ghost': 'black',
'next': 'white',
Expand Down Expand Up @@ -57,6 +58,7 @@ const Coin = function (props: CoinProps) {
|| config?.phi20_v1[lowerName]?.icon
|| config?.phi20[lowerName]?.icon
|| config?.fkw20[lowerName]?.icon
|| config?.phpx20[lowerName]?.icon
) {
isIconConfigExist = true
}
Expand Down Expand Up @@ -121,6 +123,10 @@ const Coin = function (props: CoinProps) {
if (config?.fkw20[lowerName]?.iconBgColor) {
style.backgroundColor = config.fkw20[lowerName].iconBgColor
}

if (config?.phpx20[lowerName]?.iconBgColor) {
style.backgroundColor = config.phpx20[lowerName].iconBgColor
}

// *************************************

Expand Down
2 changes: 2 additions & 0 deletions src/front/shared/components/SaveKeys/SaveKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type SaveKeysProps = {
phi_v1Data,
phiData,
fkwData,
phpxData,
ameData,
btcData,
ghostData,
Expand All @@ -49,6 +50,7 @@ type SaveKeysProps = {
phi_v1Data,
phiData,
fkwData,
phpxData,
ameData,
ethData,
ghostData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ type WithdrawModalState = {
phi_v1Data,
phiData,
fkwData,
phpxData,
ameData,
btcData,
ghostData,
Expand All @@ -146,6 +147,7 @@ type WithdrawModalState = {
phi_v1Data,
phiData,
fkwData,
phpxData,
ameData,
btcData,
ghostData,
Expand Down
2 changes: 2 additions & 0 deletions src/front/shared/components/ui/CurrencyIcon/images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import next from './next.svg'
import phi_v1 from './phi.png'
import phi from './phi_v2.png'
import fkw from './fkw.png'
import phpx from './phpx.png'



Expand Down Expand Up @@ -73,4 +74,5 @@ export default {
phi_v1,
phi,
fkw,
phpx,
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/front/shared/helpers/constants/TOKEN_DECIMALS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const decimals = {
phi_v1: 18,
phi: 18,
fkw: 18,
phpx: 18,
ghost: 8,
next: 8,
}
Expand Down
Loading

0 comments on commit 3bea301

Please sign in to comment.