-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from galacticcouncil/fix/hub-keys
Fix hub foreign asset keys
- Loading branch information
Showing
23 changed files
with
1,222 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@galacticcouncil/xcm-cfg': patch | ||
--- | ||
|
||
Fix assethub foreign balance location (v3 -> v4) |
276 changes: 159 additions & 117 deletions
276
integration-tests/xcm-test/src/__snapshots__/call.spec.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
505 changes: 505 additions & 0 deletions
505
integration-tests/xcm-test/src/__snapshots__/e2e.spec.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Asset, AssetAmount } from '@galacticcouncil/xcm-core'; | ||
|
||
export const getAmount = async ( | ||
amount: number, | ||
asset: Asset, | ||
assetDecimals: number | ||
) => { | ||
const assetAmount = amount * 10 ** assetDecimals; | ||
return AssetAmount.fromAsset(asset, { | ||
decimals: assetDecimals, | ||
amount: BigInt(assetAmount), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import type { | ||
DispatchError, | ||
EventRecord, | ||
} from '@polkadot/types/interfaces/system'; | ||
import type { AnyJson } from '@polkadot/types-codec/types'; | ||
import { ApiPromise } from '@polkadot/api'; | ||
|
||
import { findNestedKey } from '../utils'; | ||
|
||
export function checkIfFailed(api: ApiPromise, events: EventRecord[]): boolean { | ||
return events.some(({ event: { method, section, data } }) => { | ||
const eventData = data.toHuman(); | ||
if (section === 'system' && method === 'ExtrinsicFailed') { | ||
logEvent(section, method, eventData); | ||
logError(api, data); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
export function checkIfSent(events: EventRecord[]): boolean { | ||
return events.some(({ event: { method, section, data } }) => { | ||
const eventData = data.toHuman(); | ||
switch (section) { | ||
case 'xcmpQueue': | ||
logEvent(section, method, eventData); | ||
return method === 'XcmpMessageSent'; | ||
default: | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
export function checkIfProcessed(events: EventRecord[]): boolean { | ||
return events.some(({ event: { method, section, data } }) => { | ||
const eventData = data.toHuman(); | ||
switch (section) { | ||
case 'messageQueue': | ||
logEvent(section, method, eventData); | ||
return method === 'Processed' && checkProcessedStatus(eventData); | ||
case 'xcmpQueue': | ||
logEvent(section, method, eventData); | ||
return method === 'Success'; | ||
case 'dmpQueue': | ||
logEvent(section, method, eventData); | ||
return method === 'ExecutedDownward'; | ||
default: | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
function checkProcessedStatus(data: AnyJson): boolean { | ||
const dataEntry = findNestedKey(data, 'success'); | ||
return dataEntry['success'] === true; | ||
} | ||
|
||
function logEvent(section: string, method: string, data: AnyJson) { | ||
console.log('🥢 STATUS: ' + section + '.' + method, data); | ||
} | ||
|
||
function logError(api: ApiPromise, data: any) { | ||
const { dispatchError } = data; | ||
const error = dispatchError as DispatchError; | ||
const decoded = api.registry.findMetaError(error.asModule); | ||
console.error( | ||
`🥢 ${decoded.section}.${decoded.method}: ${decoded.docs.join(' ')}` | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as moonbeam from './moonbeam'; |
Oops, something went wrong.