Skip to content

Commit

Permalink
Update nodes & refactor handleAddress function
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldev5 committed Oct 16, 2023
1 parent 16b5a1e commit 7eaec37
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 332 deletions.
40 changes: 19 additions & 21 deletions docs/supportedNodes.md

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions src/maps/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1613,17 +1613,6 @@
}
]
},
"Dorafactory": {
"paraId": 2115,
"relayChainAssetSymbol": "KSM",
"nativeAssets": [
{
"symbol": "DORA",
"decimals": 12
}
],
"otherAssets": []
},
"Encointer": {
"paraId": 1001,
"relayChainAssetSymbol": "KSM",
Expand Down Expand Up @@ -3939,16 +3928,5 @@
"decimals": 9
}
]
},
"Efinity": {
"paraId": 2021,
"relayChainAssetSymbol": "DOT",
"nativeAssets": [
{
"symbol": "EFI",
"decimals": 18
}
],
"otherAssets": []
}
}
8 changes: 1 addition & 7 deletions src/maps/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ParachainNode from '../nodes/ParachainNode'
import Unique from '../nodes/supported/Unique'
import { TNode } from '../types'
import Crust from '../nodes/supported/Crust'
import Efinity from '../nodes/supported/Efinity'
import { BifrostPolkadot } from '../nodes/supported/BifrostPolkadot'
import Bitgreen from '../nodes/supported/Bitgreen'
import { Centrifuge } from '../nodes/supported/Centrifuge'
Expand Down Expand Up @@ -34,7 +33,6 @@ import Kintsugi from '../nodes/supported/Kintsugi'
import Kico from '../nodes/supported/Kico'
import Calamari from '../nodes/supported/Calamari'
import CrustShadow from '../nodes/supported/CrustShadow'
import Dorafactory from '../nodes/supported/Dorafactory'
import Imbue from '../nodes/supported/Imbue'
import Integritee from '../nodes/supported/Integritee'
import InvArchTinker from '../nodes/supported/InvArchTinker'
Expand Down Expand Up @@ -77,7 +75,6 @@ export const NODE_NAMES = [
'Calamari',
'CrustShadow',
'Crab',
'Dorafactory',
'Imbue',
'Integritee',
'InvArchTinker',
Expand All @@ -96,8 +93,7 @@ export const NODE_NAMES = [
'Turing',
'Equilibrium',
'Unique',
'Crust',
'Efinity'
'Crust'
] as const

export const nodes: Record<TNode, ParachainNode> = {
Expand All @@ -107,7 +103,6 @@ export const nodes: Record<TNode, ParachainNode> = {
Equilibrium: new Equilibrium(),
Unique: new Unique(),
Crust: new Crust(),
Efinity: new Efinity(),
BifrostPolkadot: new BifrostPolkadot(),
Bitgreen: new Bitgreen(),
Centrifuge: new Centrifuge(),
Expand All @@ -131,7 +126,6 @@ export const nodes: Record<TNode, ParachainNode> = {
Calamari: new Calamari(),
CrustShadow: new CrustShadow(),
Crab: new Crab(),
Dorafactory: new Dorafactory(),
Imbue: new Imbue(),
Integritee: new Integritee(),
InvArchTinker: new InvArchTinker(),
Expand Down
8 changes: 0 additions & 8 deletions src/maps/pallets.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@
"defaultPallet": "PolkadotXcm",
"supportedPallets": ["PolkadotXcm"]
},
"Dorafactory": {
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens"]
},
"Imbue": {
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens"]
Expand Down Expand Up @@ -182,9 +178,5 @@
"Crust": {
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens"]
},
"Efinity": {
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens"]
}
}
20 changes: 17 additions & 3 deletions src/nodes/ParachainNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
TSerializedApiCall
} from '../types'
import {
handleAddress,
generateAddressPayload,
getFees,
createHeaderPolkadotXCM,
createCurrencySpecification
Expand Down Expand Up @@ -82,15 +82,29 @@ abstract class ParachainNode {
currency: currencySymbol,
currencyID: currencyId,
amount,
addressSelection: handleAddress(scenario, 'xTokens', api, to, this.version, paraId),
addressSelection: generateAddressPayload(
api,
scenario,
'XTokens',
to,
this.version,
paraId
),
fees: getFees(scenario),
serializedApiCallEnabled
})
} else if (supportsPolkadotXCM(this)) {
return this.transferPolkadotXCM({
api,
header: createHeaderPolkadotXCM(scenario, this.version, paraId),
addressSelection: handleAddress(scenario, 'polkadotXCM', api, to, this.version, paraId),
addressSelection: generateAddressPayload(
api,
scenario,
'PolkadotXcm',
to,
this.version,
paraId
),
currencySelection: createCurrencySpecification(
amount,
scenario,
Expand Down
18 changes: 0 additions & 18 deletions src/nodes/supported/Dorafactory.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/nodes/supported/Efinity.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/nodes/supported/Turing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Turing extends ParachainNode implements IXTokensTransfer {
}

transferXTokens(input: XTokensTransferInput) {
const { currencyID, fees } = input
const { currencyID } = input
return XTokensTransferImpl.transferXTokens(input, currencyID)
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/pallets/xcmPallet/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import type { ApiPromise } from '@polkadot/api'
import { Extrinsic, TNode, TSerializedApiCall, Version } from '../../types'
import {
handleAddress,
createHeaderPolkadotXCM,
createCurrencySpecification,
getNode,
callPolkadotJsTxFunction
callPolkadotJsTxFunction,
generateAddressPayload
} from '../../utils'
import { getParaId, getRelayChainSymbol, hasSupportForAsset } from '../assets'
import { getAssetBySymbolOrId } from '../assets/assetsUtils'
Expand Down Expand Up @@ -104,7 +104,7 @@ export const transferRelayToParaCommon = (
section: 'limitedTeleportAssets',
parameters: [
createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId),
handleAddress('RelayToPara', '', api, to, Version.V3, paraId),
generateAddressPayload(api, 'RelayToPara', null, to, Version.V3, paraId),
createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination),
0,
'Unlimited'
Expand All @@ -120,7 +120,7 @@ export const transferRelayToParaCommon = (
section: 'limitedTeleportAssets',
parameters: [
createHeaderPolkadotXCM('RelayToPara', Version.V1, paraId),
handleAddress('RelayToPara', '', api, to, Version.V1, paraId),
generateAddressPayload(api, 'RelayToPara', null, to, Version.V1, paraId),
createCurrencySpecification(amount, 'RelayToPara', Version.V1, destination),
0,
'Unlimited'
Expand All @@ -142,7 +142,7 @@ export const transferRelayToParaCommon = (
section: 'reserveTransferAssets',
parameters: [
createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId),
handleAddress('RelayToPara', '', api, to, Version.V3, paraId),
generateAddressPayload(api, 'RelayToPara', null, to, Version.V3, paraId),
createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination),
0
]
Expand Down
4 changes: 1 addition & 3 deletions src/scripts/updateAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const nodeToQuery: NodeToAssetModuleMap = {
Calamari: 'assets.metadata',
Crab: null, // No assets metadata query
CrustShadow: 'assets.metadata',
Dorafactory: null, // No assets metadata query
Encointer: null, // No assets metadata query
Imbue: null, // Assets query returns empty array
Integritee: null, // No assets metadata query
Expand All @@ -60,8 +59,7 @@ const nodeToQuery: NodeToAssetModuleMap = {
Turing: 'assetRegistry.metadata',
Equilibrium: null, // No foreign assets metadata query
Unique: null, // Foreign assets query returns empty array
Crust: 'assets.metadata',
Efinity: null // No foreign assets metadata query
Crust: 'assets.metadata'
}

const fetchNativeAssets = async (api: ApiPromise): Promise<TNativeAssetDetails[]> => {
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ export interface IPolkadotXCMTransfer {
}

export enum Version {
V1,
V3
V1 = 'V1',
V3 = 'V3'
}
Loading

0 comments on commit 7eaec37

Please sign in to comment.