Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"@polkadot/util": "^13.5.3",
"@polkadot/util-crypto": "^13.5.3",
"@polkadot/x-global": "^13.5.3",
"@subwallet/chain-list": "0.2.127",
"@subwallet/chain-list": "0.2.128-beta.1-pr-696-ce4807a0",
"@subwallet/keyring": "0.1.14",
"@subwallet/react-ui": "5.1.2-b79",
"@subwallet/ui-keyring": "0.1.14",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@sora-substrate/type-definitions": "^1.17.7",
"@substrate/connect": "^0.8.9",
"@subwallet-monorepos/subwallet-services-sdk": "0.1.17-beta.2",
"@subwallet/chain-list": "0.2.127",
"@subwallet/chain-list": "0.2.128-beta.1-pr-696-ce4807a0",
"@subwallet/extension-base": "^1.3.79-1",
"@subwallet/extension-chains": "^1.3.79-1",
"@subwallet/extension-dapp": "^1.3.79-1",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-base/src/core/substrate/xcm-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getAvailBridgeWarning (): string {
}

function getPolygonBridgeWarning (originChainInfo: _ChainInfo): string {
if (originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM || originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
if (originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
return 'Cross-chain transfer of this token may take up to 40 minutes. Do you still want to continue?';
} else {
return 'Cross-chain transfer of this token may take up to 3 hours, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,11 @@ export function isAvailBridgeGatewayContract (contractAddress: _Address) {
return [AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
}

const POLYGONBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe';
const POLYGONBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582';

export function getPolygonBridgeContract (chain: string): string {
if (chain === 'polygonzkEvm_cardona' || chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
return POLYGONBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
} else if (chain === 'polygonZkEvm' || chain === COMMON_CHAIN_SLUGS.ETHEREUM) {
return POLYGONBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
}

throw new Error('Invalid chain');
Expand Down
14 changes: 12 additions & 2 deletions packages/extension-base/src/koni/background/handlers/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { Common } from '@ethereumjs/common';
import { LegacyTransaction } from '@ethereumjs/tx';
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
Expand Down Expand Up @@ -5753,6 +5754,10 @@ export default class KoniExtension {
}

private async getIsClaimedPolygonBridge (data: RequestIsClaimedPolygonBridge) {
if (data.chainslug !== COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
throw new Error('Polygon zkEVM Mainnet Beta has sunset. Please use Polygon official Ethereum claim flow.');
}

const evmApi = this.#koniState.getEvmApi(data.chainslug);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const isClaimed: boolean = await isClaimedPolygonBridge(data.chainslug, data.counter, data.sourceNetwork, evmApi);
Expand All @@ -5766,13 +5771,18 @@ export default class KoniExtension {

let transaction: SubmittableExtrinsic<'promise'> | TransactionConfig | null = null;

const evmApi = this.#koniState.getEvmApi(chain);
const metadata = notification.metadata as ClaimPolygonBridgeNotificationMetadata;

if (metadata.bridgeType !== 'POS' && chain !== COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
throw new Error('Polygon zkEVM Mainnet Beta has sunset. Please use Polygon official Ethereum claim flow.');
}

const evmApi = this.#koniState.getEvmApi(chain);
const feeInfo = await this.#koniState.feeService.subscribeChainFee(getId(), chain, 'evm') as EvmFeeInfo;

if (metadata.bridgeType === 'POS') {
transaction = await getClaimPosBridge(chain, notification, evmApi, feeInfo);
} else {
} else if (chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
transaction = await getClaimPolygonBridge(chain, notification, evmApi, feeInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const createPolygonBridgeExtrinsic = async ({ destinationChain,
const sourceChain = originChain.slug;

const createExtrinsic = isPolygonBridgeXcm
? (sourceChain === 'polygonzkEvm_cardona' || sourceChain === 'polygonZkEvm')
? sourceChain === 'polygonzkEvm_cardona'
? _createPolygonBridgeL2toL1Extrinsic
: _createPolygonBridgeL1toL2Extrinsic
: (sourceChain === 'polygon_amoy' || sourceChain === 'polygon')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ interface ClaimNotification {
}

export const POLYGON_PROOF_INDEXER = {
MAINNET: 'https://api-gateway.polygon.technology/api/v3/proof/mainnet/merkle-proof',
TESTNET: 'https://api-gateway.polygon.technology/api/v3/proof/testnet/merkle-proof'
};

export const POLYGON_GAS_INDEXER = {
MAINNET: 'https://gasstation.polygon.technology/zkevm',
TESTNET: 'https://gasstation.polygon.technology/zkevm/cardona'
};

Expand Down Expand Up @@ -102,8 +100,7 @@ export async function getClaimPolygonBridge (chainSlug: string, notification: _N
const polygonBridgeContract = getWeb3Contract(polygonBridgeContractAddress, evmApi, _POLYGON_BRIDGE_ABI);
const metadata = notification.metadata as ClaimPolygonBridgeNotificationMetadata;

const isTestnet = chainSlug === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA;
const proofDomain = isTestnet ? POLYGON_PROOF_INDEXER.TESTNET : POLYGON_PROOF_INDEXER.MAINNET;
const proofDomain = POLYGON_PROOF_INDEXER.TESTNET;

const proofResponse = await fetch(`${proofDomain}?networkId=${metadata.sourceNetwork ?? ''}&depositCount=${metadata.counter ?? ''}`)
.then((res) => res.json()) as ClaimNotification;
Expand Down Expand Up @@ -143,10 +140,6 @@ export function _isPolygonChainBridge (srcChain: string, destChain: string): boo
return true;
} else if (srcChain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA && destChain === 'polygonzkEvm_cardona') {
return true;
} else if (srcChain === 'polygonZkEvm' && destChain === COMMON_CHAIN_SLUGS.ETHEREUM) {
return true;
} else if (srcChain === COMMON_CHAIN_SLUGS.ETHEREUM && destChain === 'polygonZkEvm') {
return true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,8 @@ export const calculateGasFeeParams = async (web3: _EvmApi, networkKey: string, u
}

try {
if (networkKey === 'polygonzkEvm_cardona' || networkKey === 'polygonZkEvm') {
const isTestnet = networkKey === 'polygonzkEvm_cardona';
const gasDomain = isTestnet ? POLYGON_GAS_INDEXER.TESTNET : POLYGON_GAS_INDEXER.MAINNET;
const gasResponse = await fetch(`${gasDomain}`).then((res) => res.json()) as gasStation;
if (networkKey === 'polygonzkEvm_cardona') {
const gasResponse = await fetch(`${POLYGON_GAS_INDEXER.TESTNET}`).then((res) => res.json()) as gasStation;
const gasPriceInWei = gasResponse.standard * 1e9 + 200000;

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,18 @@ export function getPolygonBridgeClaimDescription (amount: string, symbol: string
}
/* Description */

function getPolygonBridgeNetworkIds (isTestnet: boolean): number[] {
return isTestnet ? [0, 1, -1] : [0, -1];
}

export async function fetchPolygonBridgeTransactions (userAddress: string, isTestnet: boolean, pageSize = 500, page = 0) {
const params = new URLSearchParams({
userAddress,
pageSize: pageSize.toString(),
page: page.toString()
});

const networkIds = [0, 1, -1];
const networkIds = getPolygonBridgeNetworkIds(isTestnet);

networkIds.forEach((networkId) => {
params.append('destinationNetworkIds', networkId.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const getPriceMap = async (priceIds: Set<string>, currency: CurrencyType
useBackupApi = true;

try {
response = await fetch(`https://api-cache.subwallet.app/api/price/get?ids=${idStr}`);
response = await fetch(`${apiCacheDomain}/api/price/get?ids=${idStr}`);
} catch (e) {}

if (response?.status !== 200) {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-koni-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@polkadot/util-crypto": "^13.5.3",
"@ramonak/react-progress-bar": "^5.0.3",
"@reduxjs/toolkit": "^1.9.1",
"@subwallet/chain-list": "0.2.127",
"@subwallet/chain-list": "0.2.128-beta.1-pr-696-ce4807a0",
"@subwallet/extension-base": "^1.3.79-1",
"@subwallet/extension-chains": "^1.3.79-1",
"@subwallet/extension-dapp": "^1.3.79-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Search from '@subwallet/extension-koni-ui/components/Search';
import { BN_ZERO, CLAIM_BRIDGE_TRANSACTION, CLAIM_REWARD_TRANSACTION, DEFAULT_CLAIM_AVAIL_BRIDGE_PARAMS, DEFAULT_CLAIM_REWARD_PARAMS, DEFAULT_UN_STAKE_PARAMS, DEFAULT_WITHDRAW_PARAMS, NOTI_MULTISIG_PENDINGTX_ID, NOTIFICATION_DETAIL_MODAL, WITHDRAW_TRANSACTION } from '@subwallet/extension-koni-ui/constants';
import { DataContext } from '@subwallet/extension-koni-ui/contexts/DataContext';
import { WalletModalContext } from '@subwallet/extension-koni-ui/contexts/WalletModalContextProvider';
import { useAlert, useDefaultNavigate, useGetChainAndExcludedTokenByCurrentAccountProxy, useSelector } from '@subwallet/extension-koni-ui/hooks';
import { useAlert, useDefaultNavigate, useGetChainAndExcludedTokenByCurrentAccountProxy, useNotification, useSelector } from '@subwallet/extension-koni-ui/hooks';
import { useLocalStorage } from '@subwallet/extension-koni-ui/hooks/common/useLocalStorage';
import { enableChain, saveNotificationSetup } from '@subwallet/extension-koni-ui/messaging';
import { fetchInappNotifications, getIsClaimNotificationStatus, markAllReadNotification, switchReadNotificationStatus } from '@subwallet/extension-koni-ui/messaging/transaction/notification';
Expand Down Expand Up @@ -79,6 +79,7 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const navigate = useNavigate();
const { goHome } = useDefaultNavigate();
const notify = useNotification();
const { token } = useTheme() as Theme;
const { alertProps, closeAlert, openAlert, updateAlertProps } = useAlert(alertModalId);
const { allowedChains, excludedTokens } = useGetChainAndExcludedTokenByCurrentAccountProxy();
Expand Down Expand Up @@ -406,13 +407,18 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
showWarningModal('claimed');
}
} catch (error) {
console.error(error);
notify({
message: (error as Error).message,
type: 'error',
duration: 8
});
}
};

handleClaimPolygonBridge().catch((err) => {
console.error('Error:', err);
});

break;
}

Expand Down Expand Up @@ -469,7 +475,7 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
});
}
};
}, [accounts, allowedChains, chainStateMap, currentAccountProxy, currentTimestampMs, earningRewards, excludedTokens, isAllAccount, isTrigger, navigate, openTransactionProcessModal, poolInfoMap, setClaimAvailBridgeStorage, setClaimRewardStorage, setNotiMultisigPendingTxStorage, setWithdrawStorage, showActiveChainModal, showWarningModal, yieldPositions]);
}, [accounts, allowedChains, chainStateMap, currentAccountProxy, currentTimestampMs, earningRewards, excludedTokens, isAllAccount, isTrigger, navigate, notify, openTransactionProcessModal, poolInfoMap, setClaimAvailBridgeStorage, setClaimRewardStorage, setNotiMultisigPendingTxStorage, setWithdrawStorage, showActiveChainModal, showWarningModal, yieldPositions]);

const renderItem = useCallback((item: NotificationInfoItem) => {
return (
Expand Down Expand Up @@ -617,19 +623,21 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
onSelect={onSelectFilterTab}
selectedItem={selectedFilterTab}
/>
{(selectedFilterTab === NotificationTab.UNREAD || selectedFilterTab === NotificationTab.ALL || selectedFilterTab === NotificationTab.MULTISIG) && <Button
className={'mark-read-btn'}
icon={(
<Icon
phosphorIcon={Checks}
weight={'fill'}
/>
)}
onClick={handleSwitchClick}
size='xs'
tooltip={t('ui.SETTINGS.screen.Setting.Notifications.markAllAsRead')}
type='ghost'
/>}
{(selectedFilterTab === NotificationTab.UNREAD || selectedFilterTab === NotificationTab.ALL || selectedFilterTab === NotificationTab.MULTISIG) && (
<Button
className={'mark-read-btn'}
icon={(
<Icon
phosphorIcon={Checks}
weight={'fill'}
/>
)}
onClick={handleSwitchClick}
size='xs'
tooltip={t('ui.SETTINGS.screen.Setting.Notifications.markAllAsRead')}
type='ghost'
/>
)}
</div>

{enableNotification
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@polkadot/util-crypto": "^13.5.3",
"@ramonak/react-progress-bar": "^5.0.3",
"@reduxjs/toolkit": "^1.9.1",
"@subwallet/chain-list": "0.2.127",
"@subwallet/chain-list": "0.2.128-beta.1-pr-696-ce4807a0",
"@subwallet/extension-base": "^1.3.79-1",
"@subwallet/extension-chains": "^1.3.79-1",
"@subwallet/extension-dapp": "^1.3.79-1",
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6576,13 +6576,13 @@ __metadata:
languageName: node
linkType: hard

"@subwallet/chain-list@npm:0.2.127":
version: 0.2.127
resolution: "@subwallet/chain-list@npm:0.2.127"
"@subwallet/chain-list@npm:0.2.128-beta.1-pr-696-ce4807a0":
version: 0.2.128-beta.1-pr-696-ce4807a0
resolution: "@subwallet/chain-list@npm:0.2.128-beta.1-pr-696-ce4807a0"
dependencies:
"@polkadot/util": ^13.5.5
ts-md5: ^1.3.1
checksum: 4b2a84af91b2c7b0fe820143e73e38a8210618dd4c2dbd870ace717a5b5e4182e5b066c4a1449b27e8cab9e603cfcdb7d5744b9aacc7dfdc1cd99cd6a4953c3f
checksum: 72f0aa3a3e781502201748920f3356c080401861b1db7335e4981ee4feb360ada9a000c7b7cb529ebe9eaf52681436575d683aadbcb1814ef469743b8bd81001
languageName: node
linkType: hard

Expand Down Expand Up @@ -6627,7 +6627,7 @@ __metadata:
"@sora-substrate/type-definitions": ^1.17.7
"@substrate/connect": ^0.8.9
"@subwallet-monorepos/subwallet-services-sdk": 0.1.17-beta.2
"@subwallet/chain-list": 0.2.127
"@subwallet/chain-list": 0.2.128-beta.1-pr-696-ce4807a0
"@subwallet/extension-base": ^1.3.79-1
"@subwallet/extension-chains": ^1.3.79-1
"@subwallet/extension-dapp": ^1.3.79-1
Expand Down Expand Up @@ -6768,7 +6768,7 @@ __metadata:
"@polkadot/util-crypto": ^13.5.3
"@ramonak/react-progress-bar": ^5.0.3
"@reduxjs/toolkit": ^1.9.1
"@subwallet/chain-list": 0.2.127
"@subwallet/chain-list": 0.2.128-beta.1-pr-696-ce4807a0
"@subwallet/extension-base": ^1.3.79-1
"@subwallet/extension-chains": ^1.3.79-1
"@subwallet/extension-dapp": ^1.3.79-1
Expand Down Expand Up @@ -6913,7 +6913,7 @@ __metadata:
"@polkadot/util-crypto": ^13.5.3
"@ramonak/react-progress-bar": ^5.0.3
"@reduxjs/toolkit": ^1.9.1
"@subwallet/chain-list": 0.2.127
"@subwallet/chain-list": 0.2.128-beta.1-pr-696-ce4807a0
"@subwallet/extension-base": ^1.3.79-1
"@subwallet/extension-chains": ^1.3.79-1
"@subwallet/extension-dapp": ^1.3.79-1
Expand Down
Loading