Skip to content

Commit

Permalink
Merge branch 'main' into issue-10747
Browse files Browse the repository at this point in the history
  • Loading branch information
hassnian committed Aug 9, 2024
2 parents 45830bc + c1fc3bf commit 3d3c6c3
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const logoSrc = computed(() => {
const dropsPath = computed(() => {
const prefix = pickByVm({
SUB: 'ahp',
EVM: 'base',
EVM: urlPrefix.value,
})
return `/${prefix}/drops`
})
Expand Down
7 changes: 4 additions & 3 deletions components/carousel/CarouselTypeDrops.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
<script lang="ts" setup>
import type { Drop } from '@/components/drops/useDrops'
import { useDrops } from '@/components/drops/useDrops'
import { vmOf } from '@/utils/config/chain.config'
let queries = {
limit: 12,
limit: 14,
active: [true],
chain: ['ahp', 'base'],
}
Expand All @@ -47,7 +48,7 @@ if (!isProduction && urlPrefix.value === 'ahk') {
const container = ref()
const { accountId } = useAuth()
const { vmOf, vm } = useChain()
const { vm } = useChain()
const router = useRouter()
const { doAfterReconnect } = useDoAfterReconnect()
const { cols, isReady: isDynamicGridReady } = useDynamicGrid({
Expand All @@ -63,7 +64,7 @@ const skeletonCount = computed(() =>
Number.isInteger(perView.value) ? perView.value : Math.ceil(perView.value),
)
const { drops, loaded: isReady } = useDrops(queries)
const { drops, loaded: isReady } = useDrops(queries, { filterOutMinted: true })
const dropsAlias = computed(() => drops.value.map(drop => drop.alias))
const onDropClick = ({ path, drop }: { path: string, drop: Drop }) => {
Expand Down
4 changes: 2 additions & 2 deletions components/drops/useDrops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const DROP_LIST_ORDER = [

const ONE_DAYH_IN_MS = 24 * 60 * 60 * 1000

export function useDrops(query?: GetDropsQuery, { async = false }: { async?: boolean } = { }) {
export function useDrops(query?: GetDropsQuery, { async = false, filterOutMinted = false }: { async?: boolean, filterOutMinted?: boolean } = { }) {
const drops = ref<Drop[]>([])
const dropsList = ref<DropItem[]>([])
const count = computed(() => dropsList.value.length)
Expand Down Expand Up @@ -79,7 +79,7 @@ export function useDrops(query?: GetDropsQuery, { async = false }: { async?: boo
else {
drops.value = await Promise.all(
dropsList.value.map(async drop => getFormattedDropItem(drop, drop)),
)
).then(dropsList => filterOutMinted ? dropsList.filter(drop => !drop.isMintedOut) : dropsList)

loaded.value = true
}
Expand Down
3 changes: 2 additions & 1 deletion composables/transaction/transactionBurn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@kodadot1/minimark/v2'
import type { ApiPromise } from '@polkadot/api'
import type { PalletNftsDestroyWitness } from '@polkadot/types/lookup'
import type { Prefix } from '@kodadot1/static'
import { GENSOL_ABI } from './evm/utils'
import type {
ActionDeleteCollection,
Expand All @@ -31,7 +32,7 @@ function execBurnEvm(item: ActionConsume, executeTransaction: ExecuteTransaction
}

export function execBurnTx(item: ActionConsume, api, executeTransaction) {
if (item.urlPrefix === 'base' || item.urlPrefix === 'imx') {
if (isEvm(item.urlPrefix as Prefix)) {
return execBurnEvm(item, executeTransaction)
}

Expand Down
2 changes: 1 addition & 1 deletion composables/transaction/transactionMintDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function execMintDrop({ item, ...params }: MintDropParams) {
} as SubstrateMintDropParams)
}

if (item.prefix === 'base') {
if (isEvm(item.prefix)) {
return execEvmMintDrop({
item,
...params,
Expand Down
3 changes: 2 additions & 1 deletion composables/transaction/transactionSend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createInteraction as createNewInteraction,
} from '@kodadot1/minimark/v2'
import { checkAddress, isAddress } from '@polkadot/util-crypto'
import type { Prefix } from '@kodadot1/static'
import type { ActionSend, ExecuteTransaction } from './types'
import { GENSOL_ABI } from './evm/utils'
import {
Expand Down Expand Up @@ -82,7 +83,7 @@ export function execSendTx(
api,
executeTransaction: ExecuteTransaction,
) {
if (item.urlPrefix === 'base') {
if (isEvm(item.urlPrefix as Prefix)) {
return execSendEvm(item, executeTransaction)
}

Expand Down
3 changes: 0 additions & 3 deletions composables/useChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ export default function () {
)
}

const vmOf = (prefix: Prefix): ChainVM => chainPropListOf(prefix).vm

const existentialDeposit = computed<number>(
() => chainsExistentialDeposit[urlPrefix.value],
)
Expand Down Expand Up @@ -86,7 +84,6 @@ export default function () {
withoutDecimals,
unit,
vm,
vmOf,
offersDisabled,
chainProperties,
availableChains,
Expand Down
12 changes: 6 additions & 6 deletions composables/useIsChain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Prefix } from '@kodadot1/static'
import type { ComputedRef } from 'vue'
import { chainPropListOf } from '@/utils/config/chain.config'
import { vmOf } from '@/utils/config/chain.config'

export const isEvm = (prefix: Prefix) => vmOf(prefix) === 'EVM'
export const isSub = (prefix: Prefix) => vmOf(prefix) === 'SUB'

export default function (prefix: ComputedRef<Prefix>) {
const isRemark = computed(
Expand All @@ -15,15 +18,12 @@ export default function (prefix: ComputedRef<Prefix>) {

const isBase = computed(() => 'base' === prefix.value)

const isEvm = computed(() => chainPropListOf(prefix.value).vm === 'EVM')
const isSub = computed(() => chainPropListOf(prefix.value).vm === 'SUB')

return {
isRemark,
isAssetHub,
isEvm,
isSub,
isRmrk,
isBase,
isEvm: computed(() => isEvm(prefix.value)),
isSub: computed(() => isSub(prefix.value)),
}
}
4 changes: 4 additions & 0 deletions composables/useMultipleBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const networkToPrefix: Partial<Record<ChainType, Prefix>> = {
polkadotHub: 'ahp',
base: 'base',
immutablex: 'imx',
mantle: 'mnt',
// rococoHub: 'ahr',
}

Expand All @@ -34,6 +35,7 @@ export const prefixToNetwork: Partial<Record<Prefix, ChainType>> = {
ahp: 'polkadotHub',
base: 'base',
imx: 'immutablex',
mnt: 'mantle',
// ahr: 'rococoHub',
}

Expand Down Expand Up @@ -87,6 +89,8 @@ export default function (refetchPeriodically: boolean = false) {
multiBalances.value.chains.base?.eth?.nativeBalance,
[Chain.IMMUTABLEX]:
multiBalances.value.chains.immutablex?.eth?.nativeBalance,
[Chain.MANTLE]:
multiBalances.value.chains.mantle?.mnt?.nativeBalance,
}))

const currentChain = computed(() => prefixToChainMap[urlPrefix.value])
Expand Down
4 changes: 2 additions & 2 deletions composables/useWagmi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultWagmiConfig } from '@web3modal/wagmi/vue'
import { base, immutableZkEvm } from 'viem/chains'
import { base, immutableZkEvm, mantle } from 'viem/chains'
import { useAccount, useDisconnect } from 'use-wagmi'
import type { DisconnectMutateAsync } from 'use-wagmi/query'

Expand All @@ -11,7 +11,7 @@ export const buildWagmiConfig = () => {
icons: ['https://avatars.githubusercontent.com/u/37784886'],
}

const chains = [base, immutableZkEvm]
const chains = [base, immutableZkEvm, mantle]

return defaultWagmiConfig({
chains,
Expand Down
8 changes: 7 additions & 1 deletion libs/static/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export const CHAINS: Config<ChainProperties> = {
dot: toChainProperty(0, 10, 'DOT', 'https://polkadot.subscan.io/', 'SUB'),
ahp: toChainProperty(0, 10, 'DOT', 'https://statemint.subscan.io/', 'SUB'),
imx: toChainProperty(42, 18, 'IMX', 'https://explorer.immutable.com/', 'EVM'), // ss58Format is not available
base: toChainProperty(42, 18, 'ETH', 'https://basescan.org', 'EVM'), // ss58Format is not available
base: toChainProperty(42, 18, 'ETH', 'https://basescan.org', 'EVM'),
mnt: toChainProperty(42, 18, 'MNT', 'https://mantlescan.xyz', 'EVM'), // ss58Format is not available
// ahr: toChainProperty(42, 12, 'ROC', 'https://rockmine.subscan.io/'),
// movr: toChainProperty(1285, 18, 'MOVR', 'https://moonriver.subscan.io/'),
// glmr: toChainProperty(1284, 18, 'GLMR', 'https://moonbeam.subscan.io/'),
Expand All @@ -53,6 +54,7 @@ export const chainPrefixes: Prefix[] = [
'dot',
'imx',
'base',
'mnt',
// 'ahr',
// 'movr',
// 'glmr',
Expand All @@ -73,6 +75,7 @@ export const chainInfo: Record<Prefix, string> = {
ahp: 'statemint',
imx: 'immutable',
base: 'base',
mnt: 'mantle',
// ahr: 'rockmine',
// movr: 'moonriver',
// glmr: 'moonbeam',
Expand All @@ -86,6 +89,7 @@ export const chainNames: Record<Prefix, string> = {
ahp: 'Polkadot AssetHub',
imx: 'Immutable zkEVM',
base: 'Base',
mnt: 'Mantle',
// ahr: 'Rococo AssetHub',
// movr: 'Moonriver',
// glmr: 'Moonbeam',
Expand Down Expand Up @@ -113,6 +117,7 @@ export const teleportExistentialDeposit: Record<Prefix, number> = {
ahp: 5000000000,
imx: 0,
base: 0,
mnt: 0,
}

export const existentialDeposit: Record<Prefix, number> = {
Expand All @@ -123,4 +128,5 @@ export const existentialDeposit: Record<Prefix, number> = {
ahp: 1e8,
imx: 1e15, // nothing like ED in EVM :)
base: 1e15,
mnt: 1e15,
}
2 changes: 2 additions & 0 deletions libs/static/src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const ALTERNATIVE_ENDPOINT_MAP: Config<ENDPOINT_URL[]> = {
ahp: AHP_ENDPOINTS,
imx: ['https://rpc.immutable.com'],
base: ['https://mainnet.base.org'],
mnt: ['https://rpc.mantle.xyz'],
// ahr: ['wss://rococo-asset-hub-rpc.polkadot.io'],
// glmr: ['wss://public-rpc.pinknode.io/moonbeam'],
// movr: ['wss://wss.api.moonriver.moonbeam.network'],
Expand All @@ -56,6 +57,7 @@ export const ENDPOINT_MAP: Config<ENDPOINT_URL> = {
ahp: AHP_ENDPOINTS[0],
imx: 'https://rpc.immutable.com',
base: 'https://mainnet.base.org',
mnt: 'https://rpc.mantle.xyz',
// ahr: 'wss://rococo-asset-hub-rpc.polkadot.io',
// glmr: 'wss://public-rpc.pinknode.io/moonbeam',
// movr: 'wss://wss.api.moonriver.moonbeam.network',
Expand Down
1 change: 1 addition & 0 deletions libs/static/src/indexers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const INDEXERS: Config<SquidEndpoint> = {
dot: 'https://squid.subsquid.io/rubick/graphql', // TODO: change to dot indexer when available
imx: 'https://squid.subsquid.io/flick/graphql',
base: 'https://kodadot.squids.live/basick/graphql',
mnt: 'https://squid.subsquid.io/flock/graphql',
// ahr: 'https://squid.subsquid.io/snack/graphql',
// movr: 'https://squid.subsquid.io/antick/v/001-rc0/graphql',
// glmr: 'https://squid.subsquid.io/click/v/002/graphql',
Expand Down
1 change: 1 addition & 0 deletions libs/static/src/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const NAMES: Record<Prefix, string> = {
ahp: 'PolkadotHub',
imx: 'Immutable zkEVM',
base: 'Base',
mnt: 'Mantle',
// ahr: 'RococoHub',
// glmr: 'Moonbeam [Beta]',
// movr: 'Moonriver [Beta]',
Expand Down
1 change: 1 addition & 0 deletions libs/static/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const EXPLORERS: Record<Prefix, string> = {
ahp: 'https://assethub-polkadot.subscan.io/account/',
imx: 'https://explorer.immutable.com/address/',
base: 'https://basescan.org/address/',
mnt: 'https://mantlescan.xyz/address/',
// ahr: 'https://assethub-rococo.subscan.io/account/',
// movr: 'https://moonriver.subscan.io/account/',
// glmr: 'https://moonbeam.subscan.io/account/',
Expand Down
4 changes: 2 additions & 2 deletions libs/static/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export type Prefix = 'rmrk' | 'ksm' | 'ahk' | 'dot' | 'ahp' | 'imx' | 'base'
export type Prefix = 'rmrk' | 'ksm' | 'ahk' | 'dot' | 'ahp' | 'imx' | 'base' | 'mnt'
// | 'ahr'
// | 'glmr'
// | 'movr'

export type Squid = 'rubick' | 'marck' | 'stick' | 'speck' | 'flick' | 'basick'
export type Squid = 'rubick' | 'marck' | 'stick' | 'speck' | 'flick' | 'basick' | 'flock'
// | 'snack'
// | 'click'
// | 'antick'
Expand Down
23 changes: 10 additions & 13 deletions stores/fiat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import type { TokenName } from '~/utils/coinprice'
type FiatPrice = string | number | null

interface State {
fiatPrice: {
kusama: {
usd: FiatPrice
}
polkadot: {
usd: FiatPrice
}
ethereum: {
usd: FiatPrice
}
}
fiatPrice: Record<TokenName, {
usd: FiatPrice
}>
}

export const useFiatStore = defineStore('fiat', {
Expand All @@ -29,6 +21,9 @@ export const useFiatStore = defineStore('fiat', {
ethereum: {
usd: null,
},
mantle: {
usd: null,
},
},
}),
getters: {
Expand All @@ -42,14 +37,16 @@ export const useFiatStore = defineStore('fiat', {
getCurrentROCValue: (_state): FiatPrice => 0,
getCurrentTokenValue:
state =>
(token: string): FiatPrice => {
(token: Token): FiatPrice => {
switch (token) {
case 'KSM':
return state.fiatPrice.kusama.usd
case 'DOT':
return state.fiatPrice.polkadot.usd
case 'ETH':
return state.fiatPrice.ethereum.usd
case 'MNT':
return state.fiatPrice.mantle.usd
default:
return 0
}
Expand All @@ -58,7 +55,7 @@ export const useFiatStore = defineStore('fiat', {
actions: {
async fetchFiatPrice() {
const prices = await Promise.all(
(['kusama', 'polkadot', 'ethereum'] as TokenName[]).map(getPrice),
(['kusama', 'polkadot', 'ethereum', 'mantle'] as TokenName[]).map(getPrice),
)
prices.forEach((price) => {
this.fiatPrice = Object.assign({}, this.fiatPrice, price)
Expand Down
5 changes: 4 additions & 1 deletion stores/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const DEFAULT_BALANCE_STATE = {
dot: '0',
ahp: '0',
eth: '0',
mnt: '0',
// ahr: '0',
// glmr: '0',
// movr: '0',
Expand All @@ -34,6 +35,7 @@ export type ChainType =
| 'polkadotHub'
| 'base'
| 'immutablex'
| 'mantle'
// | 'rococoHub'

type ChainDetail = {
Expand All @@ -43,7 +45,7 @@ type ChainDetail = {
selected: boolean
address: string
}
export type ChainToken = Partial<Record<'dot' | 'ksm' | 'eth', ChainDetail>>
export type ChainToken = Partial<Record<'dot' | 'ksm' | 'eth' | 'mnt', ChainDetail>>

interface MultiBalances {
address: string
Expand Down Expand Up @@ -105,6 +107,7 @@ export const useIdentityStore = defineStore('identity', {
{ chain: 'polkadotHub', token: 'DOT' },
{ chain: 'base', token: 'ETH' },
{ chain: 'immutablex', token: 'ETH' },
{ chain: 'mantle', token: 'MNT' },
],
multiBalanceAssetsTestnet: [
// { chain: 'rococoHub', token: 'ROC' },
Expand Down
6 changes: 4 additions & 2 deletions utils/coinprice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ export const getPrice = async (id: string): Promise<GetPrice> => {
return emptyPrice
}

export type TokenName = 'kusama' | 'polkadot' | 'ethereum'
export type Token = 'KSM' | 'DOT' | 'ETH' | 'MNT'
export type TokenName = 'kusama' | 'polkadot' | 'ethereum' | 'mantle'
// tokenMap but reversed
const tokenMap: Record<string, TokenName> = {
const tokenMap: Record<Token, TokenName> = {
KSM: 'kusama',
DOT: 'polkadot',
ETH: 'ethereum',
MNT: 'mantle',
}

export const getApproximatePriceOf = async (id: string): Promise<number> => {
Expand Down
Loading

0 comments on commit 3d3c6c3

Please sign in to comment.