diff --git a/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/configs.ts b/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/configs.ts index 4534a20b4..b027ca268 100644 --- a/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/configs.ts +++ b/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/configs.ts @@ -14,7 +14,8 @@ const NetworkEndpoints = { [NetworkNames.Quartz]: "https://quartz.api.subscan.io/", [NetworkNames.Unique]: "https://unique.api.subscan.io/", [NetworkNames.Vara]: "https://vara.api.subscan.io/", - [NetworkNames.AssetHub]: "https://assethub-polkadot.api.subscan.io/", + [NetworkNames.AssetHubDOT]: "https://assethub-polkadot.api.subscan.io/", + [NetworkNames.AssetHubKSM]: "https://assethub-kusama.api.subscan.io/", }; export { NetworkEndpoints }; diff --git a/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/index.ts b/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/index.ts index 536d59cf6..845f6c4df 100644 --- a/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/index.ts +++ b/packages/extension/src/providers/polkadot/libs/activity-handlers/providers/subscan/index.ts @@ -17,7 +17,14 @@ const getAddressActivity = async ( ): Promise => { return cacheFetch( { - url: `${endpoint}api/scan/transfers?address=${address}&row=50`, + url: `${endpoint}api/v2/scan/transfers`, + post: { + address: address, + row: 50, + }, + headers: { + "Content-Type": "application/json", + }, }, TTL ).then((res) => { @@ -59,7 +66,7 @@ export default async ( activity.asset_symbol !== "" ? activity.asset_symbol : network.currencyName, - price: price, + price: activity.asset_symbol === network.currencyName ? price : "0", }, }; }); diff --git a/packages/extension/src/providers/polkadot/libs/asset-handler.ts b/packages/extension/src/providers/polkadot/libs/asset-handler.ts index ddd35c1fc..6d6fe6959 100644 --- a/packages/extension/src/providers/polkadot/libs/asset-handler.ts +++ b/packages/extension/src/providers/polkadot/libs/asset-handler.ts @@ -68,15 +68,11 @@ export default async ( .map((tokenOption) => { if (knownTokens) { const knownToken = knownTokens.find( - (knownToken) => - knownToken.name === tokenOption.name && - knownToken.symbol === tokenOption.symbol && - knownToken.id === tokenOption.id + (knownToken) => knownToken.id === tokenOption.id ); if (knownToken) { tokenOption.coingeckoID = knownToken.coingeckoID; tokenOption.icon = knownToken.icon; - console.log(tokenOption); } } return tokenOption; @@ -87,15 +83,21 @@ export default async ( }); const balances = await apiPromise.query.assets.account.multi(queries); balances.forEach((balanceInfo, index) => { - const data = balanceInfo.toJSON(); + const data: { + balance: string; + status?: string; + } = balanceInfo.toJSON() as any; if (data) { - tokenOptions[index].balance = (data as any).balance.toString(); + tokenOptions[index].balance = data.balance.toString(); + if (data.status && data.status.toString() === "Frozen") { + tokenOptions[index].name = `${tokenOptions[index].name} (Frozen)`; + } } }); } const nativeAsset = new SubstrateNativeToken({ name: network.currencyNameLong, - symbol: network.name, + symbol: network.currencyName, decimals: network.decimals, existentialDeposit: network.existentialDeposit, icon: network.icon, diff --git a/packages/extension/src/providers/polkadot/networks/assethub/assethub-dot.ts b/packages/extension/src/providers/polkadot/networks/assethub/assethub-dot.ts new file mode 100644 index 000000000..226b45faa --- /dev/null +++ b/packages/extension/src/providers/polkadot/networks/assethub/assethub-dot.ts @@ -0,0 +1,37 @@ +import { NetworkNames } from "@enkryptcom/types"; +import { toBN } from "web3-utils"; +import { + SubstrateNetwork, + SubstrateNetworkOptions, +} from "@/providers/polkadot/types/substrate-network"; +import { subscanActivity } from "@/providers/polkadot/libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; +import assetHandler from "@/providers/polkadot/libs/asset-handler"; +import assets from "./assets-dot"; +import { toBase } from "@enkryptcom/utils"; + +const assetHubOptions: SubstrateNetworkOptions = { + name: NetworkNames.AssetHubDOT, + name_long: "Asset Hub | Polkadot", + homePage: "https://polkadot.network", + blockExplorerTX: "https://assethub-polkadot.subscan.io/extrinsic/[[txHash]]", + blockExplorerAddr: "https://assethub-polkadot.subscan.io/account/[[address]]", + isTestNetwork: false, + currencyName: "DOT", + currencyNameLong: "Polkadot", + icon: require("../icons/assethub.png"), + decimals: 10, + prefix: 0, + node: "wss://statemint-rpc.dwellir.com/", + coingeckoID: "polkadot", + genesisHash: + "0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f", + activityHandler: wrapActivityHandler(subscanActivity), + existentialDeposit: toBN(toBase("0.01", 10)), + assetHandler, + knownTokens: assets, +}; + +const assetHub = new SubstrateNetwork(assetHubOptions); + +export default assetHub; diff --git a/packages/extension/src/providers/polkadot/networks/assethub/assethub-ksm.ts b/packages/extension/src/providers/polkadot/networks/assethub/assethub-ksm.ts new file mode 100644 index 000000000..ebc3ec06e --- /dev/null +++ b/packages/extension/src/providers/polkadot/networks/assethub/assethub-ksm.ts @@ -0,0 +1,37 @@ +import { NetworkNames } from "@enkryptcom/types"; +import { toBN } from "web3-utils"; +import { + SubstrateNetwork, + SubstrateNetworkOptions, +} from "@/providers/polkadot/types/substrate-network"; +import { subscanActivity } from "@/providers/polkadot/libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; +import assetHandler from "@/providers/polkadot/libs/asset-handler"; +import assets from "./assets-ksm"; +import { toBase } from "@enkryptcom/utils"; + +const assetHubOptions: SubstrateNetworkOptions = { + name: NetworkNames.AssetHubKSM, + name_long: "Asset Hub | Kusama", + homePage: "https://kusama.network/", + blockExplorerTX: "https://assethub-kusama.subscan.io/extrinsic/[[txHash]]", + blockExplorerAddr: "https://assethub-kusama.subscan.io/account/[[address]]", + isTestNetwork: false, + currencyName: "KSM", + currencyNameLong: "Kusama", + icon: require("../icons/assethub.png"), + decimals: 12, + prefix: 2, + node: "wss://kusama-asset-hub-rpc.polkadot.io/", + coingeckoID: "kusama", + genesisHash: + "0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a", + activityHandler: wrapActivityHandler(subscanActivity), + existentialDeposit: toBN(toBase("0.000003333333", 12)), + assetHandler, + knownTokens: assets, +}; + +const assetHub = new SubstrateNetwork(assetHubOptions); + +export default assetHub; diff --git a/packages/extension/src/providers/polkadot/networks/assethub/assets-dot.ts b/packages/extension/src/providers/polkadot/networks/assethub/assets-dot.ts new file mode 100644 index 000000000..02fab2e4a --- /dev/null +++ b/packages/extension/src/providers/polkadot/networks/assethub/assets-dot.ts @@ -0,0 +1,26 @@ +import { KnownTokenDisplay } from "@/providers/polkadot/types"; + +const assets: KnownTokenDisplay[] = [ + { + name: "USD Coin", + symbol: "USDC", + coingeckoID: "usd-coin", + icon: require("./icons/usdc.png"), + id: "1337", + }, + { + name: "Tether USD", + symbol: "USDt", + coingeckoID: "tether", + icon: require("./icons/usdt.png"), + id: "1984", + }, + { + name: "DOT is Dead", + symbol: "DED", + icon: require("./icons/ded.png"), + id: "30", + }, +]; + +export default assets; diff --git a/packages/extension/src/providers/polkadot/networks/assethub/assets-ksm.ts b/packages/extension/src/providers/polkadot/networks/assethub/assets-ksm.ts new file mode 100644 index 000000000..d2b439a21 --- /dev/null +++ b/packages/extension/src/providers/polkadot/networks/assethub/assets-ksm.ts @@ -0,0 +1,20 @@ +import { KnownTokenDisplay } from "@/providers/polkadot/types"; + +const assets: KnownTokenDisplay[] = [ + { + name: "RMRK.app", + symbol: "RMRK", + coingeckoID: "rmrk", + icon: require("./icons/rmrk.png"), + id: "8", + }, + { + name: "Tether USD", + symbol: "USDt", + coingeckoID: "tether", + icon: require("./icons/usdt.png"), + id: "1984", + }, +]; + +export default assets; diff --git a/packages/extension/src/providers/polkadot/networks/assethub/assets.ts b/packages/extension/src/providers/polkadot/networks/assethub/assets.ts deleted file mode 100644 index 8e2036991..000000000 --- a/packages/extension/src/providers/polkadot/networks/assethub/assets.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { KnownTokenDisplay } from "@/providers/polkadot/types"; - -const assets: KnownTokenDisplay[] = [ - // { - // name: "Acala", - // symbol: "ACA", - // coingeckoID: "acala", - // icon: require("./icons/ACA.png"), - // }, - // { - // name: "Polkadot", - // symbol: "DOT", - // coingeckoID: "polkadot", - // icon: require("../../icons/polkadot.svg"), - // }, - // { - // name: "Acala Dollar", - // symbol: "aUSD", - // icon: require("./icons/AUSD.png"), - // coingeckoID: "acala-dollar", - // }, - // { - // name: "Liquid DOT", - // symbol: "LDOT", - // icon: require("./icons/LDOT.png"), - // }, -]; - -export default assets; diff --git a/packages/extension/src/providers/polkadot/networks/assethub/icons/rmrk.png b/packages/extension/src/providers/polkadot/networks/assethub/icons/rmrk.png new file mode 100644 index 000000000..f902d7f90 Binary files /dev/null and b/packages/extension/src/providers/polkadot/networks/assethub/icons/rmrk.png differ diff --git a/packages/extension/src/providers/polkadot/networks/assethub/index.ts b/packages/extension/src/providers/polkadot/networks/assethub/index.ts index 8a3c7808d..ff07c3041 100644 --- a/packages/extension/src/providers/polkadot/networks/assethub/index.ts +++ b/packages/extension/src/providers/polkadot/networks/assethub/index.ts @@ -1,35 +1,4 @@ -import { NetworkNames } from "@enkryptcom/types"; -import { toBN } from "web3-utils"; -import { - SubstrateNetwork, - SubstrateNetworkOptions, -} from "@/providers/polkadot/types/substrate-network"; -import { subscanActivity } from "@/providers/polkadot/libs/activity-handlers"; -import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; -import assetHandler from "@/providers/polkadot/libs/asset-handler"; +import assethubDOT from "./assethub-dot"; +import assethubKSM from "./assethub-ksm"; -const assetHubOptions: SubstrateNetworkOptions = { - name: NetworkNames.AssetHub, - name_long: "Asset Hub", - homePage: "https://polkadot.network", - blockExplorerTX: "https://assethub-polkadot.subscan.io/extrinsic/[[txHash]]", - blockExplorerAddr: "https://assethub-polkadot.subscan.io/account/[[address]]", - isTestNetwork: false, - currencyName: "DOT", - currencyNameLong: "Polkadot", - icon: require("../icons/assethub.png"), - decimals: 10, - prefix: 0, - node: "wss://statemint-rpc.dwellir.com/", - coingeckoID: "polkadot", - genesisHash: - "0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f", - activityHandler: wrapActivityHandler(subscanActivity), - existentialDeposit: toBN("10000000000"), - assetHandler, - knownTokens: [], -}; - -const assetHub = new SubstrateNetwork(assetHubOptions); - -export default assetHub; +export { assethubDOT, assethubKSM }; diff --git a/packages/extension/src/providers/polkadot/networks/index.ts b/packages/extension/src/providers/polkadot/networks/index.ts index 932bc0e3a..cdc6589d4 100644 --- a/packages/extension/src/providers/polkadot/networks/index.ts +++ b/packages/extension/src/providers/polkadot/networks/index.ts @@ -14,7 +14,10 @@ import uniqueNode from "./unique/unique"; import penNode from "./pendulum/pendulum"; import ampeNode from "./pendulum/amplitude"; import varaNode from "./vara"; -import assetHubNode from "./assethub"; +import { + assethubDOT as assetHubDotNode, + assethubKSM as assetHubKsmNode, +} from "./assethub"; export default { acala: acaNode, @@ -33,5 +36,6 @@ export default { pendulum: penNode, amplitude: ampeNode, vara: varaNode, - assetHub: assetHubNode, + assetHubDOT: assetHubDotNode, + assetHubKSM: assetHubKsmNode, }; diff --git a/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue b/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue index 723abb621..5d4712c87 100644 --- a/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue @@ -71,7 +71,7 @@ diff --git a/packages/types/src/networks.ts b/packages/types/src/networks.ts index f2c5f8ced..349c22df4 100644 --- a/packages/types/src/networks.ts +++ b/packages/types/src/networks.ts @@ -63,7 +63,8 @@ export enum NetworkNames { ArtheraTest = "AATest", Arthera = "AA", FormTestnet = "FormTestnet", - AssetHub = "AssetHub", + AssetHubDOT = "AssetHubDOT", + AssetHubKSM = "AssetHubKSM", } export enum CoingeckoPlatform {