Skip to content

Commit

Permalink
fix: Add CoretimeKusama
Browse files Browse the repository at this point in the history
  • Loading branch information
poppyseedDev authored and dudo50 committed Feb 19, 2024
1 parent 4b6580c commit 65b98cf
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
7 changes: 6 additions & 1 deletion e2e/xcm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const getAssetsForNode = (node: TNode): string[] => {
}

const filteredNodes = NODE_NAMES.filter(
node => node !== 'Quartz' && node !== 'Clover' && node !== 'Bitgreen' && node !== 'Bajun'
node =>
node !== 'Quartz' &&
node !== 'Clover' &&
node !== 'Bitgreen' &&
node !== 'Bajun' &&
node !== 'CoretimeKusama'
)

const findTransferableNodeAndAsset = (
Expand Down
12 changes: 12 additions & 0 deletions src/maps/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4076,6 +4076,18 @@
}
]
},
"CoretimeKusama": {
"paraId": 1005,
"relayChainAssetSymbol": "KSM",
"nativeAssetSymbol": "KSM",
"nativeAssets": [
{
"symbol": "KSM",
"decimals": 12
}
],
"otherAssets": []
},
"Turing": {
"paraId": 2114,
"relayChainAssetSymbol": "KSM",
Expand Down
3 changes: 3 additions & 0 deletions src/maps/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import InvArchTinker from '../nodes/supported/InvArchTinker'
import Karura from '../nodes/supported/Karura'
import AssetHubPolkadot from '../nodes/supported/AssetHubPolkadot'
import AssetHubKusama from '../nodes/supported/AssetHubKusama'
import CoretimeKusama from '../nodes/supported/CoretimeKusama'
import Encointer from '../nodes/supported/Encointer'
import Robonomics from '../nodes/supported/Robonomics'
import Astar from '../nodes/supported/Astar'
Expand Down Expand Up @@ -71,6 +72,7 @@ export const NODE_NAMES = [
'Moonbeam',
'Parallel',
'AssetHubKusama',
'CoretimeKusama',
'Encointer',
'Altair',
'Amplitude',
Expand Down Expand Up @@ -131,6 +133,7 @@ export const nodes: Record<TNode, ParachainNode> = {
Moonbeam: new Moonbeam(),
Parallel: new Parallel(),
AssetHubKusama: new AssetHubKusama(),
CoretimeKusama: new CoretimeKusama(),
Encointer: new Encointer(),
Altair: new Altair(),
Amplitude: new Amplitude(),
Expand Down
1 change: 1 addition & 0 deletions src/maps/existential-deposits.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Moonbeam": "0",
"Parallel": "100000000000",
"AssetHubKusama": "33333333",
"CoretimeKusama": "3333333",
"Encointer": "33333333",
"Altair": "1000000000000",
"Amplitude": "1000000000",
Expand Down
4 changes: 4 additions & 0 deletions src/maps/pallets.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"defaultPallet": "PolkadotXcm",
"supportedPallets": ["PolkadotXcm"]
},
"CoretimeKusama": {
"defaultPallet": "PolkadotXcm",
"supportedPallets": ["PolkadotXcm"]
},
"Centrifuge": {
"defaultPallet": "XTokens",
"supportedPallets": ["PolkadotXcm", "XTokens", "OrmlXTokens"]
Expand Down
41 changes: 41 additions & 0 deletions src/nodes/supported/CoretimeKusama.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Contains detailed structure of XCM call construction for AssetHubKusama Parachain

import { constructRelayToParaParameters } from '../../pallets/xcmPallet/utils'
import {
type IPolkadotXCMTransfer,
type PolkadotXCMTransferInput,
Version,
type Extrinsic,
type TSerializedApiCall,
type TTransferRelayToParaOptions
} from '../../types'
import ParachainNode from '../ParachainNode'
import PolkadotXCMTransferImpl from '../PolkadotXCMTransferImpl'

class CoretimeKusama extends ParachainNode implements IPolkadotXCMTransfer {
constructor() {
super('CoretimeKusama', 'KusamaCoretime', 'kusama', Version.V3)
}

_assetCheckEnabled = false

transferPolkadotXCM(input: PolkadotXCMTransferInput): Extrinsic | TSerializedApiCall {
// TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
const { scenario } = input
const method =
scenario === 'ParaToPara' ? 'limitedReserveTransferAssets' : 'limitedTeleportAssets'
return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited')
}

transferRelayToPara(options: TTransferRelayToParaOptions): TSerializedApiCall {
// TESTED block hash on Rococo: 0x28929f7b2aeadbf3333f05d35bed18214a4b23dd270bd072f99e8a0131d22456
// https://rococo.subscan.io/extrinsic/0x469eec7dccb22696b0c95cf4f5eec4b367ad3dc23243a346cc2aad3cc9522800
return {
module: 'xcmPallet',
section: 'limitedTeleportAssets',
parameters: constructRelayToParaParameters(options, Version.V3, true)
}
}
}

export default CoretimeKusama
4 changes: 4 additions & 0 deletions src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ describe('getNodeDetails', () => {
describe('getNodeEndpointOption', () => {
it('should return endpoint option for all nodes', () => {
NODE_NAMES.forEach(node => {
// Coretime does not have endpoint options yet
if (node === 'CoretimeKusama') {
return
}
const option = getNodeEndpointOption(node)
expect(option).toBeDefined()
expect(option).toHaveProperty('providers')
Expand Down

0 comments on commit 65b98cf

Please sign in to comment.