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 @@ -94,7 +94,7 @@
"@polkadot/types-codec": "10.10.1",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@subwallet/chain-list": "0.2.70-beta.6",
"@subwallet/chain-list": "0.2.71-beta.0",
"@subwallet/keyring": "file:./local-libs/keyring",
"@subwallet/ui-keyring": "file:./local-libs/ui-keyring",
"babel-core": "^7.0.0-bridge.0",
Expand Down
7 changes: 3 additions & 4 deletions packages/extension-base/src/services/chain-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const openbitChainInfoMap = (() => {
'botanixEvmTest',
'bounceBitEvm',
'bounceBitEvmTest',
'layerEdge_testnet'
'layerEdge_testnet',
'bevm_testnet'
];
const enableList = nativeList.concat(bitcoinL2List);

Expand Down Expand Up @@ -1926,9 +1927,7 @@ export class ChainService {
let existedToken: _ChainAsset | undefined;

for (const token of Object.values(assetRegistry)) {
const ticker = token?.slug;

if (ticker === data.ticker && token.assetType === data.type && token.originChain === data.originChain) {
if (token?.symbol === data.ticker && token?.assetType === data.type && token?.originChain === data.originChain) {
existedToken = token;
break;
}
Expand Down
14 changes: 14 additions & 0 deletions packages/extension-base/src/services/hiro-service/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,17 @@ export function getPreviewUrl (inscriptionId: string) {
throw error;
}
}

export function isValidBrc20Ticker (ticker: string) {
const bytesLength = getByteLength(ticker);

return bytesLength === 4 || bytesLength === 5;
}

function getByteLength (str: string): number {
const encoder = new TextEncoder();
const encodedStr = encoder.encode(str);

// Return the length of the encoded array, which represents the number of bytes
return encodedStr.length;
}
10 changes: 7 additions & 3 deletions packages/extension-base/src/services/rune-service/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ export async function getAllCollectionRunes (isTestnet = false) {
}
}

export async function getRuneMetadata (runeid: string, isTestnet = false) {
export async function getRuneMetadata (runeId: string, isTestnet = false) {
const runeService = RunesService.getInstance(isTestnet);

try {
return await runeService.getRuneMetadata(runeid);
return await runeService.getRuneMetadata(runeId);
} catch (error) {
console.error(`Failed to get rune ${runeid} metadata`, error);
console.error(`Failed to get rune ${runeId} metadata`, error);
throw error;
}
}

export function isValidRuneId (runeId: string) {
return runeId.includes(':');
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import { _AssetType, _ChainInfo } from '@subwallet/chain-list/types';
import { _getTokenTypesSupportedByChain, _isChainTestNet, _parseMetadataForBrc20Asset, _parseMetadataForRuneAsset, _parseMetadataForSmartContractAsset } from '@subwallet/extension-base/services/chain-service/utils';
import { isValidBrc20Ticker } from '@subwallet/extension-base/services/hiro-service/utils';
import { isValidRuneId } from '@subwallet/extension-base/services/rune-service/utils';
import { isValidSubstrateAddress } from '@subwallet/extension-base/utils';
import { AddressInput, ChainSelector, Layout, PageWrapper, TokenTypeSelector } from '@subwallet/extension-koni-ui/components';
import { DataContext } from '@subwallet/extension-koni-ui/contexts/DataContext';
import { useChainChecker, useDefaultNavigate, useGetChainPrefixBySlug, useGetFungibleContractSupportedChains, useNotification, useTranslation } from '@subwallet/extension-koni-ui/hooks';
import { upsertCustomToken, validateCustomBrc20, validateCustomRune, validateCustomToken } from '@subwallet/extension-koni-ui/messaging';
import { FormCallbacks, FormRule, Theme, ThemeProps } from '@subwallet/extension-koni-ui/types';
import { convertFieldToError, convertFieldToObject, reformatAddress, simpleCheckForm } from '@subwallet/extension-koni-ui/utils';
import { isBitcoinAddress } from '@subwallet/keyring';
import { Col, Field, Form, Icon, Input, Row } from '@subwallet/react-ui';
import SwAvatar from '@subwallet/react-ui/es/sw-avatar';
import { PlusCircle } from 'phosphor-react';
Expand Down Expand Up @@ -114,11 +115,12 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
const selectedTokenType = getFieldValue('type') as _AssetType;
const isValidEvmContract = [_AssetType.ERC20].includes(selectedTokenType) && isEthereumAddress(inputMetadata);
const isValidWasmContract = [_AssetType.PSP22].includes(selectedTokenType) && isValidSubstrateAddress(inputMetadata);
const isValidRune = [_AssetType.RUNE].includes(selectedTokenType) && isBitcoinAddress(inputMetadata);
const isValidBrc20 = [_AssetType.BRC20].includes(selectedTokenType) && isBitcoinAddress(inputMetadata);
const reformattedContractAddress = reformatAddress(inputMetadata, chainNetworkPrefix);
const isValidRune = [_AssetType.RUNE].includes(selectedTokenType) && isValidRuneId(inputMetadata);
const isValidBrc20 = [_AssetType.BRC20].includes(selectedTokenType) && isValidBrc20Ticker(inputMetadata);

if (isValidEvmContract || isValidWasmContract) {
const reformattedContractAddress = reformatAddress(inputMetadata, chainNetworkPrefix);

setLoading(true);
validateCustomToken({
contractAddress: reformattedContractAddress,
Expand Down Expand Up @@ -158,7 +160,6 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
type: selectedTokenType
})
.then((validationResult) => {
console.log('validationResult');
setLoading(false);

if (validationResult.isExist) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6241,14 +6241,14 @@ __metadata:
languageName: node
linkType: hard

"@subwallet/chain-list@npm:0.2.70-beta.6":
version: 0.2.70-beta.6
resolution: "@subwallet/chain-list@npm:0.2.70-beta.6"
"@subwallet/chain-list@npm:0.2.71-beta.0":
version: 0.2.71-beta.0
resolution: "@subwallet/chain-list@npm:0.2.71-beta.0"
dependencies:
"@polkadot/dev": 0.67.167
"@polkadot/util": ^12.5.1
eventemitter3: ^5.0.1
checksum: d4e5085eb6501555202879233cdbc23c37e4926fb0488ab3691c7b5e0354e763f6e34c3029918944346cc3f1eaa3e201a3e9eec78f01d1332c41a8d10c2331e2
checksum: 811e36c63651b798ccb260bf29bbf4847900bafc9c2cce2ad547ab85123a41756fcb4bb276d98f7d59548771ad00b72e56b0b0ba4c3fbd610ae28cbb9e112fb9
languageName: node
linkType: hard

Expand Down