diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml
index b17fa42f8e..058febaf22 100644
--- a/.github/workflows/reviewdog.yml
+++ b/.github/workflows/reviewdog.yml
@@ -1,7 +1,8 @@
name: Reviewdog
on:
- pull_request:
+ pull_request: {}
+ push:
branches: [main]
jobs:
diff --git a/components/chart/PriceChart.vue b/components/chart/PriceChart.vue
index 8eb72f85fb..0160504ee1 100644
--- a/components/chart/PriceChart.vue
+++ b/components/chart/PriceChart.vue
@@ -87,7 +87,6 @@
diff --git a/components/common/autoTeleport/AutoTeleportActionButton.vue b/components/common/autoTeleport/AutoTeleportActionButton.vue
index a352ac235c..ce5788dc93 100644
--- a/components/common/autoTeleport/AutoTeleportActionButton.vue
+++ b/components/common/autoTeleport/AutoTeleportActionButton.vue
@@ -154,7 +154,7 @@ const { $i18n } = useNuxtApp()
const { chainSymbol, name } = useChain()
const { isModalOpen } = useAutoTeleportModal()
-const amount = ref()
+const amounts = ref()
const {
isAvailable: isAutoTeleportAvailable,
@@ -167,7 +167,7 @@ const {
clear,
} = useAutoTeleport(
computed(() => props.actions),
- computed(() => amount.value),
+ computed(() => amounts.value),
props.fees,
)
@@ -337,7 +337,7 @@ watch(allowAutoTeleport, (allow) => {
watchSyncEffect(() => {
if (!isModalOpen.value) {
- amount.value = props.amount
+ amounts.value = props.amount
}
})
diff --git a/components/common/shoppingCart/ShoppingCartModal.vue b/components/common/shoppingCart/ShoppingCartModal.vue
index d42b3b4e0e..2bdce860ac 100644
--- a/components/common/shoppingCart/ShoppingCartModal.vue
+++ b/components/common/shoppingCart/ShoppingCartModal.vue
@@ -146,6 +146,7 @@ const clearAllItems = () => {
}
const sortedItems = computed(() =>
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
items.value.sort((a, b) => b.addedAt - a.addedAt),
)
diff --git a/components/create/CreateNft.vue b/components/create/CreateNft.vue
index 203934173e..e206d6522f 100644
--- a/components/create/CreateNft.vue
+++ b/components/create/CreateNft.vue
@@ -387,6 +387,8 @@ const imagePreview = computed(() => {
if (form.file) {
return URL?.createObjectURL(form.file)
}
+
+ return null
})
// select available blockchain
diff --git a/components/gallery/GalleryItem.vue b/components/gallery/GalleryItem.vue
index 23097805a2..9391a0f8f3 100644
--- a/components/gallery/GalleryItem.vue
+++ b/components/gallery/GalleryItem.vue
@@ -329,6 +329,8 @@ const seoCard = computed(() => {
nftMimeType.value,
)
}
+
+ return ''
})
useSeoMeta({
diff --git a/components/gallery/GalleryItemDescription.vue b/components/gallery/GalleryItemDescription.vue
index 542fc11a6b..f15779f2ef 100644
--- a/components/gallery/GalleryItemDescription.vue
+++ b/components/gallery/GalleryItemDescription.vue
@@ -302,11 +302,7 @@ const descSource = computed(() => {
nftMetadata.value?.description?.replaceAll('\n', ' \n') || '',
)
})
-const parent = computed(() => {
- if (nft.value?.parent?.id) {
- return useGalleryItem(nft.value?.parent?.id)
- }
-})
+const parent = computed(() => nft.value?.parent?.id ? useGalleryItem(nft.value?.parent?.id) : undefined)
const isLewd = computed(() => {
return Boolean(
properties.value?.find((item) => {
@@ -324,6 +320,8 @@ const recipient = computed(() => {
return nft.value?.recipient
}
}
+
+ return undefined
})
defineExpose({ isLewd })
@@ -334,6 +332,8 @@ const parentNftUrl = computed(() => {
return `/${urlPrefix.value}/${url}/${parent.value?.nft.value?.id}`
}
+
+ return ''
})
const properties = computed(() => {
diff --git a/components/gallery/GalleryItemTabsPanel/GalleryItemTabsPanel.vue b/components/gallery/GalleryItemTabsPanel/GalleryItemTabsPanel.vue
index c09e624a95..193392863b 100644
--- a/components/gallery/GalleryItemTabsPanel/GalleryItemTabsPanel.vue
+++ b/components/gallery/GalleryItemTabsPanel/GalleryItemTabsPanel.vue
@@ -1,6 +1,6 @@
props.galleryItem.nft.value)
-const activeTab = ref('1')
+const active = ref('1')
const collectionId = ref('')
watchEffect(() => {
if (props.activeTab) {
- activeTab.value = props.activeTab
+ active.value = props.activeTab
}
collectionId.value = nft.value?.collection.id || ''
diff --git a/components/profile/create/stages/Form.vue b/components/profile/create/stages/Form.vue
index b07fdca369..f69804fa44 100644
--- a/components/profile/create/stages/Form.vue
+++ b/components/profile/create/stages/Form.vue
@@ -246,6 +246,8 @@ const deleteConfirmSafetyDelayText = computed(() => {
),
])
}
+
+ return ''
})
const deleteConfirmText = computed(() =>
diff --git a/components/rmrk/service/Consolidator.ts b/components/rmrk/service/Consolidator.ts
index 6be4ef3f68..fc00346508 100644
--- a/components/rmrk/service/Consolidator.ts
+++ b/components/rmrk/service/Consolidator.ts
@@ -1,48 +1,5 @@
import { u8aToHex } from '@polkadot/util'
import { decodeAddress } from '@polkadot/keyring'
-import type { NFT } from './scheme'
-
-export default class Consolidator {
- public static isPermitedInteraction(): boolean {
- return true
- }
-
- public static canTransfer(nft: NFT): void {
- if (!nft.transferable) {
- throw new ValidationError(`NFT ${nft._id} is not transferable`)
- }
- }
-
- public static isAvailableForSale(nft: NFT, previousOwner: string): boolean {
- return Consolidator.callerEquals(nft.currentOwner, previousOwner)
- }
-
- // private static canMintNft() {
-
- // }
-
- // private static canSend() {
-
- // }
-
- // private static canList() {
-
- // }
-
- // private static canChangeIssuer() {
-
- // }
-
- // public static isValidCollection() {
-
- // }
-
- // public static validate() {}
-
- private static callerEquals(ownerId: string, caller: string): boolean {
- return ownerId === caller
- }
-}
function accountIdToPubKey(accountId: string) {
return (accountId && u8aToHex(decodeAddress(accountId))) || ''
@@ -61,10 +18,3 @@ export function generateId(caller: string, symbol: string): string {
+ (symbol || '')
).toUpperCase()
}
-
-class ValidationError extends Error {
- constructor(message: string) {
- super(message)
- this.name = 'ValidationError'
- }
-}
diff --git a/components/rmrk/service/NftUtils.ts b/components/rmrk/service/NftUtils.ts
index 92e256bdff..09fb3de337 100644
--- a/components/rmrk/service/NftUtils.ts
+++ b/components/rmrk/service/NftUtils.ts
@@ -1,15 +1,6 @@
-import { hexToString, isHex } from '@polkadot/util'
-import slugify from 'slugify'
-import { upperTrim } from '@kodadot1/minimark/utils'
-import type { UpdateFunction } from '@kodadot1/minimark/common'
-import { generateId } from '../service/Consolidator'
import type {
Collection,
- NFT,
- NFTWithMeta,
- RmrkCreatedNft,
- SimpleNFT,
- RmrkWithMetaType } from './scheme'
+ RmrkCreatedNft } from './scheme'
export type MintType = {
collection: Collection
@@ -18,205 +9,3 @@ export type MintType = {
export const basicUpdateFunction = (name: string, index: number): string =>
`${name} #${index + 1}`
-
-class NFTUtils {
- public static decode(value: string): string {
- return decodeURIComponent(value)
- }
-
- public static decodeRmrk(rmrkString: string): string {
- return NFTUtils.decode(
- isHex(rmrkString) ? hexToString(rmrkString) : rmrkString,
- )
- }
-
- public static toString(
- rmrkType: RmrkCreatedNft | Collection,
- version = '1.0.0',
- ): string {
- if (NFTUtils.isCollection(rmrkType)) {
- return NFTUtils.encodeCollection(rmrkType, version)
- }
-
- if (NFTUtils.isNFT(rmrkType)) {
- return NFTUtils.encodeNFT(rmrkType, version)
- }
-
- return ''
- }
-
- public static encodeCollection(
- collection: Collection,
- version: string,
- ): string {
- return `RMRK::MINT::${version}::${encodeURIComponent(
- JSON.stringify(collection),
- )}`
- }
-
- public static encodeNFT(nft: RmrkCreatedNft, version: string): string {
- return `RMRK::MINTNFT::${version}::${encodeURIComponent(
- JSON.stringify(nft),
- )}`
- }
-
- public static collectionFromNFT(
- symbol: string,
- nft: NFT,
- version = '1.0.0',
- ): Collection {
- return NFTUtils.createCollection(
- nft.currentOwner,
- symbol,
- nft.name,
- nft.metadata,
- 1,
- version,
- )
- }
-
- public static createCollection(
- caller: string,
- symbol: string,
- name: string,
- metadata: string,
- max = 1,
- version = '1.0.0',
- ): {
- id: string
- _id: string
- symbol: string
- issuer: string
- version: string
- name: string
- max: number
- metadata: string
- } {
- const trimmedSymbol = slugify(symbol.trim().toUpperCase(), '_')
- return {
- id: generateId(caller, trimmedSymbol),
- _id: '',
- symbol: trimmedSymbol,
- issuer: caller,
- version,
- name: name.trim(),
- max,
- metadata,
- }
- }
-
- public static createNFT(
- caller: string,
- index: number,
- collectionId: string,
- name: string,
- metadata: string,
- ): RmrkCreatedNft {
- const instance = upperTrim(name, true)
- const sn = NFTUtils.nftSerialNumber(index)
- return {
- name: name.trim(),
- instance,
- transferable: 1,
- collection: collectionId,
- sn,
- metadata,
- currentOwner: caller,
- }
- }
-
- public static createMultipleNFT(
- max: number,
- caller: string,
- collectionId: string,
- name: string,
- metadata: string,
- offset = 0,
- updateName?: UpdateFunction,
- ): RmrkCreatedNft[] {
- return Array(max)
- .fill(null)
- .map((_, i) =>
- NFTUtils.createNFT(
- caller,
- i + offset,
- collectionId,
- updateName ? updateName(name, i) : name,
- metadata,
- ),
- )
- }
-
- public static nftSerialNumber(
- index: number,
- offset = 0,
- plusOne = true,
- ): string {
- return String(index + offset + Number(plusOne)).padStart(16, '0')
- }
-
- public static isCollection(
- object: Collection | RmrkCreatedNft | RmrkWithMetaType,
- ): object is Collection {
- return 'issuer' in object && 'symbol' in object
- }
-
- public static isNFT(
- object: Collection | RmrkCreatedNft | RmrkWithMetaType,
- ): object is NFT | NFTWithMeta {
- return 'currentOwner' in object && 'instance' in object
- }
-
- public static generateRemarks(
- mint: SimpleNFT,
- caller: string,
- version = '1.0.0',
- encode?: boolean,
- updateName?: UpdateFunction,
- ): MintType | string[] {
- const collection = NFTUtils.createCollection(
- caller,
- mint.symbol,
- mint.name,
- mint.metadata,
- mint.max,
- version,
- )
- const nfts = Array(mint.max)
- .fill(null)
- .map((e, i) =>
- NFTUtils.createNFT(
- caller,
- i,
- collection.id,
- updateName ? updateName(mint.name, i) : mint.name,
- mint.metadata,
- ),
- )
-
- if (encode) {
- return [
- NFTUtils.encodeCollection(collection, version),
- ...nfts.map(nft => NFTUtils.encodeNFT(nft, version)),
- ]
- }
-
- return {
- collection,
- nfts,
- }
- }
-}
-
-export class RmrkActionRegex {
- static MINTNFT = /^[rR][mM][rR][kK]::MINTNFT::/
- static MINT = /^[rR][mM][rR][kK]::MINT::/
- static SEND = /^[rR][mM][rR][kK]::SEND::/
- static BUY = /^[rR][mM][rR][kK]::BUY::/
- static CONSUME = /^[rR][mM][rR][kK]::CONSUME::/
- static CHANGEISSUER = /^[rR][mM][rR][kK]::CHANGEISSUER::/
- static LIST = /^[rR][mM][rR][kK]::LIST::/
- static EMOTE = /^[rR][mM][rR][kK]::EMOTE::/
-}
-
-export default NFTUtils
diff --git a/components/search/Search.vue b/components/search/Search.vue
index 557f74fb59..9b2af27213 100644
--- a/components/search/Search.vue
+++ b/components/search/Search.vue
@@ -58,8 +58,7 @@ const emit = defineEmits<{
(e: 'update:sortByMultiple', value: string[]): void
(e: 'update:listed', listed: boolean): void
(e: 'resetPage'): void
- (e: 'update:priceMin', value?: number): void
- (e: 'update:priceMax', value?: number): void
+ (e: 'update:priceMin' | 'update:priceMax', value?: number): void
}>()
const { neoModal } = useProgrammatic()
@@ -104,6 +103,7 @@ const isExplorePage = computed(() => routePathList.value.includes(route.path))
type Listed = boolean | { listed: boolean, min?: string, max?: string }
const vListed = computed({
get() {
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
query.listed = props.listed
return props.listed
},
diff --git a/components/shared/AudioMedia.vue b/components/shared/AudioMedia.vue
index 82bfc0c614..e6bd6c2854 100644
--- a/components/shared/AudioMedia.vue
+++ b/components/shared/AudioMedia.vue
@@ -70,6 +70,8 @@ const handleCoverHover = async (hovering: boolean) => {
await audioPlayer.value.pause()
}
}
- catch (error) {}
+ catch (error) {
+ console.error('Error playing audio', error)
+ }
}
diff --git a/components/shared/DropUpload.vue b/components/shared/DropUpload.vue
index 76ef969a3a..981fabf59a 100644
--- a/components/shared/DropUpload.vue
+++ b/components/shared/DropUpload.vue
@@ -143,7 +143,7 @@ const onPasteImage = (pasteEvent: ClipboardEvent) => {
}
}
-const createInput = (inputFile: Blob): void | boolean => {
+const createInput = (inputFile: Blob): undefined | boolean => {
const fileSize = inputFile.size / Math.pow(1024, 2)
if (fileSize > fileSizeLimit.value) {
fileSizeFailed.value = true
diff --git a/components/shared/TransactionSteps/TransactionSteps.vue b/components/shared/TransactionSteps/TransactionSteps.vue
index 5df53ff7c2..6b634d9eca 100644
--- a/components/shared/TransactionSteps/TransactionSteps.vue
+++ b/components/shared/TransactionSteps/TransactionSteps.vue
@@ -83,20 +83,21 @@ const getStepItem = (step: TransactionStepWithActive): TransactionStepItem => {
tooltip: step.tooltip,
}
- let { status, text } = getTransactionStepDetails(step, $i18n.t)
+ const { status, text } = getTransactionStepDetails(step, $i18n.t)
+ let tsxText = text
const withCustomSubtitle
- = step.stepStatusTextOverride?.hasOwnProperty(status) || false
+ = Object.prototype.hasOwnProperty.call(step.stepStatusTextOverride, status) || false
if (withCustomSubtitle) {
- text = step.stepStatusTextOverride?.[status] || ''
+ tsxText = step.stepStatusTextOverride?.[status] || ''
}
return {
...baseStep,
status: step.stepStatus ? step.stepStatus : status,
title: step.title,
- subtitle: text,
+ subtitle: tsxText,
withCustomSubtitle,
}
}
diff --git a/components/shared/audioPlayer/AudioPlayer.vue b/components/shared/audioPlayer/AudioPlayer.vue
index d8febdb628..3be2881b52 100644
--- a/components/shared/audioPlayer/AudioPlayer.vue
+++ b/components/shared/audioPlayer/AudioPlayer.vue
@@ -125,7 +125,9 @@ const flushPreviouseActions = async () => {
await Promise.allSettled(actionStack.value.map(action => action.reject()))
actionStack.value = []
}
- catch (error) {}
+ catch (error) {
+ console.error(error)
+ }
}
const pushToActionStack = ({ promise, reject }) => {
diff --git a/components/shared/format/BasicMoney.vue b/components/shared/format/BasicMoney.vue
index 44caad1199..9aecf7acbb 100644
--- a/components/shared/format/BasicMoney.vue
+++ b/components/shared/format/BasicMoney.vue
@@ -28,14 +28,14 @@ const { decimals, chainSymbol } = useChain()
const realUnit = computed(() => (props.hideUnit ? '' : ' ' + chainSymbol.value))
const finalValue = computed(() =>
- round(
+ roundValue(
formatBalance(checkInvalidBalanceFilter(props.value), decimals.value, ''),
props.round,
false,
),
)
-const round = (value: string, limit: number, disableFilter: boolean) => {
+const roundValue = (value: string, limit: number, disableFilter: boolean) => {
const number = Number(value.replace(/,/g, ''))
if (disableFilter) {
return parseFloat(number.toString())
diff --git a/components/unique/NftUtils.ts b/components/unique/NftUtils.ts
index 2a37542018..b802e13bd6 100644
--- a/components/unique/NftUtils.ts
+++ b/components/unique/NftUtils.ts
@@ -1,6 +1,3 @@
-type Id = string | number
-type Owner = { Id: string }
-
export enum NFTAction {
SEND = 'SEND',
CONSUME = 'CONSUME',
@@ -23,65 +20,3 @@ export const actionResolver: Record = {
export const basicUpdateFunction = (name: string, index: number): string =>
`${name} #${index + 1}`
-
-class NFTUtils {
- static createCollection(id: Id, admin: string): [string, Owner] {
- return [String(id), { Id: admin }]
- }
-
- static createNFT(
- classId: Id,
- id: Id,
- owner: string,
- ): [string, string, Owner] {
- return [String(classId), String(id), { Id: owner }]
- }
-
- static getActionParams(
- selectedAction: NFTAction,
- classId: Id,
- id: Id,
- meta: string,
- ): Id[] {
- switch (selectedAction) {
- case NFTAction.SEND:
- case NFTAction.CONSUME:
- case NFTAction.DELEGATE:
- case NFTAction.REVOKE:
- return [classId, id, meta]
- case NFTAction.FREEZE:
- case NFTAction.THAW:
- return [classId, id]
- default:
- throw new Error('Action not found')
- }
- }
-
- static apiCall(selectedAction: NFTAction): [string, string] {
- return actionResolver[selectedAction] || new Error('Action not found')
- }
-
- static correctMeta(
- selectedAction: NFTAction,
- meta: string,
- currentOwner: string,
- delegate: string,
- ): string {
- switch (selectedAction) {
- case NFTAction.SEND:
- case NFTAction.DELEGATE:
- return meta
- case NFTAction.CONSUME:
- return currentOwner
- case NFTAction.REVOKE:
- return delegate
- case NFTAction.FREEZE:
- case NFTAction.THAW:
- return ''
- default:
- throw new Error('Action not found')
- }
- }
-}
-
-export default NFTUtils
diff --git a/composables/autoTeleport/types.ts b/composables/autoTeleport/types.ts
index 8cde2d8367..3a560d8989 100644
--- a/composables/autoTeleport/types.ts
+++ b/composables/autoTeleport/types.ts
@@ -42,7 +42,7 @@ export type AutoTeleportActionHandlerParams = { isRetry: boolean }
export type AutoTeleportAction = {
transaction?: (item: Actions, prefix: string) => Promise
- handler?: (params: AutoTeleportActionHandlerParams) => Promise
+ handler?: (params: AutoTeleportActionHandlerParams) => Promise
} & AutoTeleportBaseAction
export type AutoTeleportFeeParams = {
diff --git a/composables/useKeyboardEvents.ts b/composables/useKeyboardEvents.ts
index 48d0f7d9ee..b96b07fb3b 100644
--- a/composables/useKeyboardEvents.ts
+++ b/composables/useKeyboardEvents.ts
@@ -22,6 +22,7 @@ export function useKeyboardEvents(primaryKeyEvents) {
}
const onKeyUp = (event) => {
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete keysPressed.value[event.key]
}
diff --git a/composables/usePlayerEventBus.ts b/composables/usePlayerEventBus.ts
index 9335a1847e..12a4b57ba8 100644
--- a/composables/usePlayerEventBus.ts
+++ b/composables/usePlayerEventBus.ts
@@ -27,20 +27,17 @@ export function usePlayerEventBus() {
const unsubscribe = eventBus.on((event, payload) => {
switch (event) {
case PlayerEvent.ADD_PLAYER:
- const addPlayerPayload = payload as AddPlayerEventPayload
- audios.value.set(addPlayerPayload.id, { pause: addPlayerPayload.pause })
+ audios.value.set((payload as AddPlayerEventPayload).id, { pause: (payload as AddPlayerEventPayload).pause })
break
case PlayerEvent.PLAY:
- const playPlayerEventPayload = payload as PayloadWithId
audios.value.forEach((player: { pause: Pause }, id) => {
- if (playPlayerEventPayload.id !== id) {
+ if ((payload as PayloadWithId).id !== id) {
player.pause().catch(error => error)
}
})
break
case PlayerEvent.REMOVE_PLAYER:
- const removePlayerEventPayload = payload as PayloadWithId
- audios.value.delete(removePlayerEventPayload.id)
+ audios.value.delete((payload as PayloadWithId).id)
break
}
})
diff --git a/libs/static/src/indexers.ts b/libs/static/src/indexers.ts
index 68c0c794d8..dec3e57b67 100644
--- a/libs/static/src/indexers.ts
+++ b/libs/static/src/indexers.ts
@@ -34,7 +34,6 @@ const reducer = (
export const APOLLO_ENDPOINTS: Config = Object.entries(
INDEXERS,
- // eslint-disable-next-line unicorn/no-array-reduce
).reduce(
(accumulator, element) => reducer(accumulator, element),
{} as Config,
diff --git a/libs/ui/src/components/TheImage/TheImage.vue b/libs/ui/src/components/TheImage/TheImage.vue
index 85527f9dee..0f2fa799d3 100644
--- a/libs/ui/src/components/TheImage/TheImage.vue
+++ b/libs/ui/src/components/TheImage/TheImage.vue
@@ -40,6 +40,7 @@ const omit = (
): Omit => {
const clone = { ...obj } as const
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
keys.forEach(key => delete clone[key])
return clone
}
diff --git a/plugins/keyboardEvents.client.ts b/plugins/keyboardEvents.client.ts
index a0c01442ff..b36a421a2a 100644
--- a/plugins/keyboardEvents.client.ts
+++ b/plugins/keyboardEvents.client.ts
@@ -87,6 +87,7 @@ const listenGlobalKeyboardEvents = (app) => {
})
document.addEventListener('keyup', (event) => {
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete keysPressed[event.key]
})
}
diff --git a/utils/api/Query.ts b/utils/api/Query.ts
deleted file mode 100644
index 96b91f1ad1..0000000000
--- a/utils/api/Query.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { ApiPromise } from '@polkadot/api'
-import type BN from 'bn.js'
-import correctFormat from '../ss58Format'
-
-export type ChainProperties = {
- ss58Format: number
- tokenDecimals: number
- tokenSymbol: string
- blockExplorer?: string
- genesisHash?: string
-}
-
-class Query {
- static async getNonce(api: ApiPromise, address: string): Promise {
- const { nonce } = await api.query.system.account(address)
- return nonce.toBn()
- }
-
- static async getTokenBalance(
- api: ApiPromise,
- accountId: string,
- ): Promise {
- const { availableBalance } = await api.derive.balances.all(accountId)
- return availableBalance.toString()
- }
-
- static getChainProperties(api: ApiPromise): ChainProperties {
- const { chainSS58, chainDecimals, chainTokens } = api.registry
- return {
- ss58Format: correctFormat(chainSS58),
- tokenDecimals: chainDecimals[0] || 12,
- tokenSymbol: chainTokens[0] || 'Unit',
- }
- }
-}
-
-export default Query
diff --git a/utils/teleport.ts b/utils/teleport.ts
index be273dd29b..2a3390b418 100644
--- a/utils/teleport.ts
+++ b/utils/teleport.ts
@@ -2,11 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import type { Prefix } from '@kodadot1/static'
-import type { ApiPromise } from '@polkadot/api'
-import type { SubmittableExtrinsicFunction } from '@polkadot/api/types'
-import type { XcmVersionedMultiLocation } from '@polkadot/types/lookup'
-import type { AnyTuple } from '@polkadot/types/types'
-import { isFunction } from '@polkadot/util'
import * as paraspell from '@paraspell/sdk'
import { ApiFactory } from '@kodadot1/sub-api'
import { getChainEndpointByPrefix } from '@/utils/chain'
@@ -14,20 +9,6 @@ import type { TeleportParams } from '@/composables/useTeleport'
import { getAddress } from '@/utils/extension'
import { toDefaultAddress } from '@/utils/account'
-type Extrisic = SubmittableExtrinsicFunction<'promise', AnyTuple>
-
-// import { KUSAMA_GENESIS } from '@polkadot/apps-config';
-
-const KUSAMA_GENESIS = ''
-// 4 * BaseXcmWeight on Kusama
-const KUSAMA_WEIGHT = 4 * 1_000_000_000
-
-const DEFAULT_WEIGHT = KUSAMA_WEIGHT
-
-const KNOWN_WEIGHTS: Record = {
- [KUSAMA_GENESIS]: KUSAMA_WEIGHT,
-}
-
export enum Chain {
KUSAMA = 'Kusama',
ASSETHUBKUSAMA = 'AssetHubKusama',
@@ -102,62 +83,6 @@ export const whichTeleportType = ({
}
}
-export function getTeleportWeight(api: ApiPromise): number {
- return KNOWN_WEIGHTS[api.genesisHash.toHex()] || DEFAULT_WEIGHT
-}
-
-export function findCall(api: ApiPromise): Extrisic {
- const m = XCM_LOC.filter(
- x => api.tx[x] && XCM_FNS.some(f => isFunction(api.tx[x][f])),
- )[0]
- const f = XCM_FNS.filter(f => isFunction(api.tx[m][f]))[0]
-
- return api.tx[m][f]
-}
-
-export const XCM_LOC = ['xcm', 'xcmPallet', 'polkadotXcm']
-export const XCM_FNS = ['limitedTeleportAssets', 'teleportAssets']
-
-export function getApiParams(
- api: ApiPromise,
- call: Extrisic,
- isParaTeleport: string | undefined,
- account: string,
- amount: string,
-): any[] {
- const firstType = api.createType(
- call.meta.args[0].type.toString(),
- )
- const isCurrent = firstType.defKeys.includes('V1')
-
- const dst = isParaTeleport ? { X1: 'Parent' } : { X1: { ParaChain: 1000 } }
-
- const acc = {
- X1: {
- AccountId32: {
- id: api.createType('AccountId32', account).toHex(),
- network: 'Any',
- },
- },
- }
- const ass = isParaTeleport
- ? [{ ConcreteFungible: { amount, id: { X1: 'Parent' } } }]
- : // forgo id - 'Here' for 9100, 'Null' for 9110 (both is the default enum value)
- [{ ConcreteFungible: { amount } }]
-
- const destWeight = getTeleportWeight(api)
-
- return isCurrent
- ? call.meta.args.length === 5
- ? // with weight
- call.method === 'limitedTeleportAssets'
- ? [{ V0: dst }, { V0: acc }, { V0: ass }, 0, { Unlimited: null }]
- : [{ V0: dst }, { V0: acc }, { V0: ass }, 0, destWeight]
- : // without weight
- [{ V0: dst }, { V0: acc }, { V0: ass }, 0]
- : [dst, acc, ass, destWeight]
-}
-
const getApi = (chain: Chain) => {
const endpoint = getChainEndpointByPrefix(chainToPrefixMap[chain]) as string
return ApiFactory.useApiInstance(endpoint)