Skip to content

Commit

Permalink
Update node pallets - monthly check 🔧
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldev5 committed Dec 22, 2023
1 parent 2e228f9 commit bb00336
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 134 deletions.
103 changes: 51 additions & 52 deletions docs/supportedNodes.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion scripts/updateAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const nodeToQuery: NodeToAssetModuleMap = {
Darwinia: null, // No assets metadata query
HydraDX: 'assetRegistry.assetMetadataMap',
Interlay: 'assetRegistry.metadata',
Kylin: 'assets.metadata',
Litentry: null, // Assets query returns empty array
Moonbeam: 'assets.metadata',
Parallel: 'assets.metadata',
Expand Down
17 changes: 0 additions & 17 deletions src/maps/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -906,23 +906,6 @@
}
]
},
"Kylin": {
"paraId": 2052,
"relayChainAssetSymbol": "DOT",
"nativeAssets": [
{
"symbol": "KYL",
"decimals": 18
}
],
"otherAssets": [
{
"assetId": "1",
"symbol": "DOT",
"decimals": 0
}
]
},
"Litentry": {
"paraId": 2013,
"relayChainAssetSymbol": "DOT",
Expand Down
3 changes: 0 additions & 3 deletions src/maps/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Clover from '../nodes/supported/Clover'
import ComposableFinance from '../nodes/supported/ComposableFinance'
import HydraDX from '../nodes/supported/HydraDX'
import Interlay from '../nodes/supported/Interlay'
import Kylin from '../nodes/supported/Kylin'
import Litentry from '../nodes/supported/Litentry'
import Moonbeam from '../nodes/supported/Moonbeam'
import Parallel from '../nodes/supported/Parallel'
Expand Down Expand Up @@ -65,7 +64,6 @@ export const NODE_NAMES = [
'Darwinia',
'HydraDX',
'Interlay',
'Kylin',
'Litentry',
'Moonbeam',
'Parallel',
Expand Down Expand Up @@ -123,7 +121,6 @@ export const nodes: Record<TNode, ParachainNode> = {
Darwinia: new Darwinia(),
HydraDX: new HydraDX(),
Interlay: new Interlay(),
Kylin: new Kylin(),
Litentry: new Litentry(),
Moonbeam: new Moonbeam(),
Parallel: new Parallel(),
Expand Down
4 changes: 0 additions & 4 deletions src/maps/pallets.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens"]
},
"Kylin": {
"defaultPallet": "OrmlXTokens",
"supportedPallets": ["PolkadotXcm", "OrmlXTokens"]
},
"Litentry": {
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens"]
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/ParachainNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
} from '../utils'
import { constructRelayToParaParameters } from '../pallets/xcmPallet/utils'

const supportsXTokens = (obj: any): obj is IXTokensTransfer => {
export const supportsXTokens = (obj: any): obj is IXTokensTransfer => {
return 'transferXTokens' in obj
}

const supportsPolkadotXCM = (obj: any): obj is IPolkadotXCMTransfer => {
export const supportsPolkadotXCM = (obj: any): obj is IPolkadotXCMTransfer => {
return 'transferPolkadotXCM' in obj
}

Expand Down
81 changes: 78 additions & 3 deletions src/nodes/supported/Astar.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
// Contains detailed structure of XCM call construction for Astar Parachain

import { type ApiPromise } from '@polkadot/api'
import { NoXCMSupportImplementedError } from '../../errors'
import { getParaId } from '../../pallets/assets'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
type Extrinsic,
type TSerializedApiCall
type TSerializedApiCall,
type TNode,
type TScenario,
type IXTokensTransfer,
type XTokensTransferInput
} from '../../types'
import ParachainNode from '../ParachainNode'
import {
generateAddressPayload,
getFees,
createHeaderPolkadotXCM,
createCurrencySpecification
} from '../../utils'
import ParachainNode, { supportsPolkadotXCM, supportsXTokens } from '../ParachainNode'
import PolkadotXCMTransferImpl from '../PolkadotXCMTransferImpl'
import XTokensTransferImpl from '../XTokensTransferImpl'

class Astar extends ParachainNode implements IPolkadotXCMTransfer {
class Astar extends ParachainNode implements IPolkadotXCMTransfer, IXTokensTransfer {
constructor() {
super('Astar', 'astar', 'polkadot', Version.V3)
}
Expand All @@ -21,6 +35,67 @@ class Astar extends ParachainNode implements IPolkadotXCMTransfer {
input.scenario === 'ParaToPara' ? 'reserveTransferAssets' : 'reserveWithdrawAssets'
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method)
}

transferXTokens(input: XTokensTransferInput): Extrinsic | TSerializedApiCall {
return XTokensTransferImpl.transferXTokens(input, input.currencyID)
}

transfer(
api: ApiPromise,
currencySymbol: string | undefined,
currencyId: string | undefined,
amount: string,
to: string,
destination?: TNode,
serializedApiCallEnabled = false
): Extrinsic | TSerializedApiCall {
const scenario: TScenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay'
const paraId = destination !== undefined ? getParaId(destination) : undefined
const node = this.node
if (supportsXTokens(this) && currencySymbol !== 'ASTR') {
return this.transferXTokens({
api,
currency: currencySymbol,
currencyID: currencyId,
amount,
addressSelection: generateAddressPayload(
api,
scenario,
'XTokens',
to,
this.version,
paraId
),
fees: getFees(scenario),
scenario,
serializedApiCallEnabled
})
} else if (supportsPolkadotXCM(this)) {
return this.transferPolkadotXCM({
api,
header: createHeaderPolkadotXCM(scenario, this.version, paraId),
addressSelection: generateAddressPayload(
api,
scenario,
'PolkadotXcm',
to,
this.version,
paraId
),
currencySelection: createCurrencySpecification(
amount,
scenario,
this.version,
node,
currencyId
),
scenario,
currencySymbol,
serializedApiCallEnabled
})
}
throw new NoXCMSupportImplementedError(node)
}
}

export default Astar
22 changes: 10 additions & 12 deletions src/nodes/supported/Darwinia.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
// Contains detailed structure of XCM call construction for Darwinia Parachain

import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
type Extrinsic,
type TSerializedApiCall
type TSerializedApiCall,
type IXTokensTransfer,
type XTokensTransferInput
} from '../../types'
import { ScenarioNotSupportedError } from '../../errors/ScenarioNotSupportedError'
import ParachainNode from '../ParachainNode'
import PolkadotXCMTransferImpl from '../PolkadotXCMTransferImpl'
import { NodeNotSupportedError } from '../../errors'
import XTokensTransferImpl from '../XTokensTransferImpl'

class Darwinia extends ParachainNode implements IPolkadotXCMTransfer {
class Darwinia extends ParachainNode implements IXTokensTransfer {
constructor() {
super('Darwinia', 'darwinia', 'polkadot', Version.V3)
}

transferPolkadotXCM(input: PolkadotXCMTransferInput): Extrinsic | TSerializedApiCall {
// TESTED https://polkadot.subscan.io/xcm_message/polkadot-55c5c36c8fe8794c8cfbea725c9f8bc5984c6b05
if (input.scenario === 'ParaToPara') {
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserveTransferAssets')
}
throw new ScenarioNotSupportedError(this.node, input.scenario)
transferXTokens(input: XTokensTransferInput): Extrinsic | TSerializedApiCall {
return XTokensTransferImpl.transferXTokens(
input,
input.currency === 'RING' ? 'SelfReserve' : { ForeignAsset: input.currencyID }
)
}

transferRelayToPara(): TSerializedApiCall {
Expand Down
24 changes: 0 additions & 24 deletions src/nodes/supported/Kylin.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/nodes/supported/Pendulum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import XTokensTransferImpl from '../XTokensTransferImpl'

class Pendulum extends ParachainNode implements IXTokensTransfer {
constructor() {
super('Pendulum', 'pendulum', 'polkadot', Version.V1)
super('Pendulum', 'pendulum', 'polkadot', Version.V3)
}

transferXTokens(input: XTokensTransferInput): Extrinsic | TSerializedApiCall {
Expand Down
81 changes: 78 additions & 3 deletions src/nodes/supported/Shiden.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
// Contains detailed structure of XCM call construction for Shiden Parachain

import { type ApiPromise } from '@polkadot/api'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
type Extrinsic,
type TSerializedApiCall
type TSerializedApiCall,
type IXTokensTransfer,
type XTokensTransferInput,
type TNode,
type TScenario
} from '../../types'
import ParachainNode from '../ParachainNode'
import {
createCurrencySpecification,
createHeaderPolkadotXCM,
generateAddressPayload,
getFees
} from '../../utils'
import ParachainNode, { supportsPolkadotXCM, supportsXTokens } from '../ParachainNode'
import PolkadotXCMTransferImpl from '../PolkadotXCMTransferImpl'
import XTokensTransferImpl from '../XTokensTransferImpl'
import { getParaId } from '../../pallets/assets'
import { NoXCMSupportImplementedError } from '../../errors'

class Shiden extends ParachainNode implements IPolkadotXCMTransfer {
class Shiden extends ParachainNode implements IPolkadotXCMTransfer, IXTokensTransfer {
constructor() {
super('Shiden', 'shiden', 'kusama', Version.V3)
}
Expand All @@ -22,6 +36,67 @@ class Shiden extends ParachainNode implements IPolkadotXCMTransfer {
input.scenario === 'ParaToPara' ? 'reserveTransferAssets' : 'reserveWithdrawAssets'
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method)
}

transferXTokens(input: XTokensTransferInput): Extrinsic | TSerializedApiCall {
return XTokensTransferImpl.transferXTokens(input, input.currencyID)
}

transfer(
api: ApiPromise,
currencySymbol: string | undefined,
currencyId: string | undefined,
amount: string,
to: string,
destination?: TNode,
serializedApiCallEnabled = false
): Extrinsic | TSerializedApiCall {
const scenario: TScenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay'
const paraId = destination !== undefined ? getParaId(destination) : undefined
const node = this.node
if (supportsXTokens(this) && currencySymbol !== 'SDN') {
return this.transferXTokens({
api,
currency: currencySymbol,
currencyID: currencyId,
amount,
addressSelection: generateAddressPayload(
api,
scenario,
'XTokens',
to,
this.version,
paraId
),
fees: getFees(scenario),
scenario,
serializedApiCallEnabled
})
} else if (supportsPolkadotXCM(this)) {
return this.transferPolkadotXCM({
api,
header: createHeaderPolkadotXCM(scenario, this.version, paraId),
addressSelection: generateAddressPayload(
api,
scenario,
'PolkadotXcm',
to,
this.version,
paraId
),
currencySelection: createCurrencySpecification(
amount,
scenario,
this.version,
node,
currencyId
),
scenario,
currencySymbol,
serializedApiCallEnabled
})
}
throw new NoXCMSupportImplementedError(node)
}
}

export default Shiden
12 changes: 0 additions & 12 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,6 @@ export const getNode = (node: TNode): ParachainNode => {
export const getNodeEndpointOption = (node: TNode): any => {
const { type, name } = getNode(node)
const { linked } = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama

// TMP Fix because some nodes don't have providers in endpoint options
if (node === 'Kylin') {
return {
info: 'kylin',
paraId: 2052,
providers: {
'Kylin Network': 'wss://polkadot.kylin-node.co.uk'
}
}
}

return linked !== undefined ? linked.find((o: any) => o.info === name) : undefined
}

Expand Down

0 comments on commit bb00336

Please sign in to comment.