Skip to content

Commit

Permalink
Merge branch 'refs/heads/subwallet-dev' into koni/dev/issue-3911
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/extension-base/src/koni/background/handlers/Extension.ts
  • Loading branch information
bluezdot committed Jan 3, 2025
2 parents bd0383c + a5ef355 commit 9f599b4
Show file tree
Hide file tree
Showing 101 changed files with 3,326 additions and 361 deletions.
6 changes: 5 additions & 1 deletion .123trigger
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@
1.3.4
1.3.5
1.3.6
1.3.7
1.3.7
1.3.8
1.3.9
1.3.10
1.3.11
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ BITTENSOR_API_KEY_3=abafdbad3
BITTENSOR_API_KEY_4=abafdbad4
BITTENSOR_API_KEY_5=abafdbad5
BITTENSOR_API_KEY_6=abafdbad6
SIMPLE_SWAP_API_KEY=abacasdf
1 change: 1 addition & 0 deletions .github/workflows/push-koni-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
GH_RELEASE_FILES: master-build.zip,master-src.zip
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
REF_NAME: ${{ github.ref_name }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
yarn install --immutable | grep -v 'YN0013'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push-web-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
BRANCH_NAME: master
run: |
yarn install --immutable | grep -v 'YN0013'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
CHAINFLIP_BROKER_API: ${{ secrets.CHAINFLIP_BROKER_API }}
BITTENSOR_API_KEY_1: ${{ secrets.BITTENSOR_API_KEY_1 }}
BITTENSOR_API_KEY_2: ${{ secrets.BITTENSOR_API_KEY_2 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
yarn install --immutable | grep -v 'YN0013'
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# CHANGELOG

## 1.3.11
Build date: Dec 23, 2024.

Features & Update:
- Support swap TAO on SimpleSwap (#3855)
- Update content on unstake screen for some earning options (#3778)

Bug fixed:
- Fix errors when making transactions on Tangle mainnet (#3861)

## 1.3.10
Build date: Dec 12, 2024.

Features & Update:
- Update version polkadot api (#3888)
- Unable to transfer local token on Bifrost (#3896)


## 1.3.9
Build date: Dec 09, 2024.

Features & Update:
- Allow Polkadot namespace use EVM address (#3870)
- Support Generic ledger app for Vara network (#3835)

Bug fixed:
- Fixed bug validating recipient balance when sending Substrate token (#3713)
- Fixed bug send NFT on Ethereum network (#3762)


## 1.3.8
Build date: Dec 03, 2024.

Features & Update:
- Improve chain-list online patch (#3132)
- Support Unified bridge on Polygon (#3826)
- ETH: Ethereum -> Polygon zkEVM
- ETH: Polygon zkEVM -> Ethereum
- Update chain-list
- Add support for G6 network testnet
- Add support for LOVA token (PAH, Hydration)
- Add support for PIP token (Storty Odyssey Testnet)
- Add support for Fraxtal Mainnet
- Add support for Cyber
- Update Aventus Block Explorer
- Delete Story Public Tesnet (Iliad testnet)


## 1.3.7
Build date: Nov 23, 2024.

Expand Down
16 changes: 8 additions & 8 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
2891 AnhMTV Release version 1.3.7
2546 Nam Phạm [Issue 3747] chore: fix eslint
2369 S2kael [Issue-3852] Update metadata for case KSM and DOT
2914 AnhMTV Release version 1.3.11
2552 Nam Phạm [Issue 3855] test: add log
2380 S2kael [Issue-3855] Remove log
869 lw-cdm [MasterAccount] Update logic to reorder account on select account modal
568 nguyentiendung [Issue-3553] [Issue-3553] Refactor code and add recipient to swap history.
490 bluezdot [Issue-3888] build: update version @galacticcouncil/sdk to 5.1.0
465 Jaco 0.42.5 (#969)
463 bluezdot [Issue-3814] fix: handle exceptions
354 Thiendekaco [Issue-3707] [fix] Unified account - fix dApp ui bug #4
186 dominhquang [Issue-3507] Fix UI bug for Notification
185 quangdo
Expand All @@ -13,27 +13,27 @@
160 Automation Bot [CI Skip] Auto increase webapp build number
104 khainh predefine metadata for Polkadot & Kusama chains
96 lw
91 PDTnhah [Issue-3861] Fix: Update link navigate to explorer
83 Hieu Dao Update README.md
83 leewong
82 Thibaut Sardan Add account filtering feature (#832)
73 bluedot [Issue-3579] fix: update check fully migrate
73 PDTnhah [Issue-3846] Update chainlist
77 tunghp2002 [update] Reformat sender address
74 bluedot [Issue-3888] build: upgrade version polkadot api
63 Roman fix ui issues
53 Dominhquangdev update Bridge code
43 tunghp2002 [Update] Fix UI
26 S2kael
10 Trang Trịnh api get karura and acala nfts
9 Minh Le
9 minhld1029 [#115] [ForgetAccount] catch exception refList undefined
7 Ivan Rukhavets Mention derivation in FAQ (#334)
6 tunghp2002
6 unknown refactor code
5 anhnhu [issue-2231]: add condition branch_name webapp-dev auto increase run scripts change build number
4 Amaury Martiny PostMessageProvider with on('connected' | 'disconnected') (#279)
4 namph update UI for nft
4 Quangdm-cdm
3 Antoine Estienne Add eth test for extension signature (#909)
3 quangdm Update style for Auth Transaction Screen, Export Screen, Derive Screen
3 tunghp2002
2 Axel Chalon Add typings to messages (#130)
2 Bartłomiej Rutkowski Allow account creation by derivation from existing one (#296)
2 carumusan Support ipfs and ipns urls (#667)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://github.com/Koniverse/Subwallet-V2.git"
},
"sideEffects": false,
"version": "1.3.7",
"version": "1.3.11",
"workspaces": [
"packages/*"
],
Expand Down Expand Up @@ -105,12 +105,12 @@
"@polkadot/types-support": "^15.0.1",
"@polkadot/util": "^13.2.3",
"@polkadot/util-crypto": "^13.2.3",
"@subwallet/chain-list": "0.2.95",
"@subwallet/chain-list": "0.2.96-beta.8",
"@subwallet/keyring": "^0.1.8-beta.0",
"@subwallet/react-ui": "5.1.2-b79",
"@subwallet/ui-keyring": "0.1.8-beta.0",
"@types/bn.js": "^5.1.6",
"@zondax/ledger-substrate": "0.44.2",
"@zondax/ledger-substrate": "1.0.1",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^29.3.1",
"browserify-sign": "^4.2.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "1.3.7-0",
"version": "1.3.11-0",
"main": "index.js",
"dependencies": {
"@acala-network/api": "^5.0.2",
Expand Down Expand Up @@ -55,11 +55,11 @@
"@reduxjs/toolkit": "^1.9.1",
"@sora-substrate/type-definitions": "^1.17.7",
"@substrate/connect": "^0.8.9",
"@subwallet/chain-list": "0.2.95-beta.1",
"@subwallet/extension-base": "^1.3.7-0",
"@subwallet/extension-chains": "^1.3.7-0",
"@subwallet/extension-dapp": "^1.3.7-0",
"@subwallet/extension-inject": "^1.3.7-0",
"@subwallet/chain-list": "0.2.96-beta.8",
"@subwallet/extension-base": "^1.3.11-0",
"@subwallet/extension-chains": "^1.3.11-0",
"@subwallet/extension-dapp": "^1.3.11-0",
"@subwallet/extension-inject": "^1.3.11-0",
"@subwallet/keyring": "^0.1.8-beta.0",
"@subwallet/ui-keyring": "^0.1.8-beta.0",
"@ton/core": "^0.56.3",
Expand Down Expand Up @@ -105,7 +105,7 @@
"web3-utils": "^1.10.0"
},
"devDependencies": {
"@subwallet/extension-mocks": "^1.3.7-0",
"@subwallet/extension-mocks": "^1.3.11-0",
"@types/uuid": "^9.0.1"
}
}
3 changes: 3 additions & 0 deletions packages/extension-base/src/background/KoniTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ export interface CreateHardwareAccountItem {
name: string;
isEthereum: boolean;
isGeneric: boolean;
isLedgerRecovery?: boolean;
}

export interface RequestAccountCreateHardwareV2 extends CreateHardwareAccountItem {
Expand Down Expand Up @@ -1264,6 +1265,8 @@ export interface LedgerNetwork {
isEthereum: boolean;
/** Hide networks that are supported by the dot migration app */
isHide?: boolean;
/** Recovery app */
isRecovery?: boolean;
/** Slip44 in the derivation path */
slip44: number;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/extension-base/src/background/errors/SwapError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const defaultErrorMap: Record<SwapErrorType, { message: string, code?: number }>
MAKE_POOL_NOT_ENOUGH_EXISTENTIAL_DEPOSIT: {
message: detectTranslate('Insufficient liquidity to complete the swap. Lower your amount and try again'),
code: undefined
},
NOT_MEET_MIN_EXPECTED: {
// TODO: update message
message: detectTranslate('Unable to process this swap at the moment. Try again later'),
code: undefined
}
};

Expand Down
5 changes: 5 additions & 0 deletions packages/extension-base/src/constants/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ export const PREDEFINED_STAKING_POOL: Record<string, number> = {
export const MAX_NOMINATIONS = '16';

export const PREDEFINED_EARNING_POOL_PROMISE = fetchStaticData<Record<string, number[]>>('nomination-pool-recommendation');

export type ChainRecommendValidator = {
maxCount: number;
preSelectValidators: string;
};
29 changes: 28 additions & 1 deletion packages/extension-base/src/core/logic-validation/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SwapError } from '@subwallet/extension-base/background/errors/SwapError
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
import { _getAssetDecimals, _getTokenMinAmount, _isChainEvmCompatible, _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
import { BasicTxErrorType } from '@subwallet/extension-base/types';
import { AssetHubPreValidationMetadata, ChainflipPreValidationMetadata, HydradxPreValidationMetadata, SwapErrorType } from '@subwallet/extension-base/types/swap';
import { AssetHubPreValidationMetadata, ChainflipPreValidationMetadata, HydradxPreValidationMetadata, SimpleSwapValidationMetadata, SwapErrorType } from '@subwallet/extension-base/types/swap';
import { formatNumber } from '@subwallet/extension-base/utils';
import BigN from 'bignumber.js';

Expand Down Expand Up @@ -163,3 +163,30 @@ export function _getEarlyAssetHubValidationError (error: SwapErrorType, metadata
return new SwapError(error);
}
}

export function _getSimpleSwapEarlyValidationError (error: SwapErrorType, metadata: SimpleSwapValidationMetadata): SwapError { // todo: support more providers
switch (error) {
case SwapErrorType.NOT_MEET_MIN_SWAP: {
const message = `Amount too low. Increase your amount above ${metadata.minSwap.value} ${metadata.minSwap.symbol} and try again`;

return new SwapError(error, message);
}

case SwapErrorType.SWAP_EXCEED_ALLOWANCE: {
if (metadata.maxSwap) {
return new SwapError(error, `Amount too high. Lower your amount below ${metadata.maxSwap.value} ${metadata.maxSwap.symbol} and try again`);
} else {
return new SwapError(error, 'Amount too high. Lower your amount and try again');
}
}

case SwapErrorType.ASSET_NOT_SUPPORTED:
return new SwapError(error, 'This swap pair is not supported');
case SwapErrorType.UNKNOWN:
return new SwapError(error, `Undefined error. Check your Internet and ${metadata.chain.slug} connection or contact support`);
case SwapErrorType.ERROR_FETCHING_QUOTE:
return new SwapError(error, 'No swap quote found. Adjust your amount or try again later.');
default:
return new SwapError(error);
}
}
19 changes: 17 additions & 2 deletions packages/extension-base/src/core/substrate/xcm-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
import { _Address } from '@subwallet/extension-base/background/KoniTypes';
import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
import { _isPosChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
import { _getChainSubstrateAddressPrefix, _getEvmChainId, _getSubstrateParaId, _getSubstrateRelayParent, _getXcmAssetMultilocation, _isChainEvmCompatible, _isPureEvmChain, _isSubstrateParaChain } from '@subwallet/extension-base/services/chain-service/utils';

import { decodeAddress, evmToAddress } from '@polkadot/util-crypto';
Expand Down Expand Up @@ -63,7 +64,7 @@ export function _getXcmMultiLocation (originChainInfo: _ChainInfo, destChainInfo
}

export function _isXcmTransferUnstable (originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): boolean {
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo);
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo) || _isPosBridgeXcm(originChainInfo, destChainInfo);
}

function getAssetHubBridgeUnstableWarning (originChainInfo: _ChainInfo): string {
Expand Down Expand Up @@ -104,8 +105,18 @@ function getPolygonBridgeWarning (originChainInfo: _ChainInfo): string {
}
}

function getPosBridgeWarning (originChainInfo: _ChainInfo): string {
if (originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM || originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
return 'Cross-chain transfer of this token may take up to 22 minutes. Do you still want to continue?';
} else {
return 'Cross-chain transfer of this token may take up to 90 minutes, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
}
}

export function _getXcmUnstableWarning (originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): string {
if (_isPolygonBridgeXcm(originChainInfo, destChainInfo)) {
if (_isPosBridgeXcm(originChainInfo, destChainInfo)) {
return getPosBridgeWarning(originChainInfo);
} else if (_isPolygonBridgeXcm(originChainInfo, destChainInfo)) {
return getPolygonBridgeWarning(originChainInfo);
} else if (_isAvailBridgeXcm(originChainInfo, destChainInfo)) {
return getAvailBridgeWarning();
Expand Down Expand Up @@ -141,6 +152,10 @@ export function _isPolygonBridgeXcm (originChainInfo: _ChainInfo, destChainInfo:
return _isPolygonChainBridge(originChainInfo.slug, destChainInfo.slug);
}

export function _isPosBridgeXcm (originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean {
return _isPosChainBridge(originChainInfo.slug, destChainInfo.slug);
}

// ---------------------------------------------------------------------------------------------------------------------

function _getMultiLocationParent (originChainInfo: _ChainInfo, isWithinSameConsensus: boolean): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const _AVAIL_BRIDGE_GATEWAY_ABI: Record<string, any> = require('./avail_b
export const _AVAIL_TEST_BRIDGE_GATEWAY_ABI: Record<string, any> = require('./avail_test_bridge_abi.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
export const _POLYGON_BRIDGE_ABI: Record<string, any> = require('./polygon_bridge_abi.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
export const _POS_BRIDGE_ABI: Record<string, any> = require('./pos_bridge_abi.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
export const _POS_BRIDGE_L2_ABI: Record<string, any> = require('./pos_bridge_l2_abi.json');

const SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x27ca963C279c93801941e1eB8799c23f407d68e7';
const SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd';
Expand Down Expand Up @@ -72,3 +76,29 @@ export function getPolygonBridgeContract (chain: string): string {

throw new Error('Invalid chain');
}

const POSBRIDGE_GATEWAY_AMOY_CONTRACT_ADDRESS = '0x52eF3d68BaB452a294342DC3e5f464d7f610f72E';
const POSBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x34F5A25B627f50Bb3f5cAb72807c4D4F405a9232';

const POSBRIDGE_GATEWAY_CONTRACT_ADDRESS = '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619';
const POSBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0xA0c68C638235ee32657e8f720a23ceC1bFc77C77';

export function getPosL2BridgeContract (chain: string): string {
if (chain === 'polygon_amoy' || chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
return POSBRIDGE_GATEWAY_AMOY_CONTRACT_ADDRESS;
} else if (chain === 'polygon' || chain === COMMON_CHAIN_SLUGS.ETHEREUM) {
return POSBRIDGE_GATEWAY_CONTRACT_ADDRESS;
}

throw new Error('Invalid chain');
}

export function getPosL1BridgeContract (chain: string): string {
if (chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
return POSBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
} else if (chain === COMMON_CHAIN_SLUGS.ETHEREUM) {
return POSBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
}

throw new Error('Invalid chain');
}
Loading

0 comments on commit 9f599b4

Please sign in to comment.