-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AssetConversionApi #5694
Merged
jacogr
merged 2 commits into
polkadot-js:master
from
jsidorenko:js/add-asset-conversion-api
Jul 24, 2023
Merged
Add AssetConversionApi #5694
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
22 changes: 22 additions & 0 deletions
22
packages/types/src/interfaces/assetConversion/definitions.ts
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,22 @@ | ||
// Copyright 2017-2023 @polkadot/types authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// order important in structs... :) | ||
/* eslint-disable sort-keys */ | ||
|
||
import type { Definitions } from '../../types/index.js'; | ||
|
||
import { runtime } from './runtime.js'; | ||
|
||
export default { | ||
rpc: {}, | ||
runtime, | ||
types: { | ||
MultiAssetId: { | ||
_enum: { | ||
Native: null, | ||
Asset: 'AssetId' | ||
} | ||
} | ||
} | ||
} as Definitions; |
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,4 @@ | ||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit | ||
/* eslint-disable */ | ||
|
||
export * from './types.js'; |
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,72 @@ | ||
// Copyright 2017-2023 @polkadot/types authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import type { DefinitionsCall } from '../../types/index.js'; | ||
|
||
export const runtime: DefinitionsCall = { | ||
AssetConversionApi: [ | ||
{ | ||
methods: { | ||
get_reserves: { | ||
description: 'Get pool reserves', | ||
params: [ | ||
{ | ||
name: 'asset1', | ||
type: 'MultiAssetId' | ||
}, | ||
{ | ||
name: 'asset2', | ||
type: 'MultiAssetId' | ||
} | ||
], | ||
type: 'Option<(Balance,Balance)>' | ||
}, | ||
quote_price_exact_tokens_for_tokens: { | ||
description: 'Quote price: exact tokens for tokens', | ||
params: [ | ||
{ | ||
name: 'asset1', | ||
type: 'MultiAssetId' | ||
}, | ||
{ | ||
name: 'asset2', | ||
type: 'MultiAssetId' | ||
}, | ||
{ | ||
name: 'amount', | ||
type: 'u128' | ||
}, | ||
{ | ||
name: 'include_fee', | ||
type: 'bool' | ||
} | ||
], | ||
type: 'Option<(Balance)>' | ||
}, | ||
quote_price_tokens_for_exact_tokens: { | ||
description: 'Quote price: tokens for exact tokens', | ||
params: [ | ||
{ | ||
name: 'asset1', | ||
type: 'MultiAssetId' | ||
}, | ||
{ | ||
name: 'asset2', | ||
type: 'MultiAssetId' | ||
}, | ||
{ | ||
name: 'amount', | ||
type: 'u128' | ||
}, | ||
{ | ||
name: 'include_fee', | ||
type: 'bool' | ||
} | ||
], | ||
type: 'Option<(Balance)>' | ||
} | ||
}, | ||
version: 1 | ||
} | ||
] | ||
}; |
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,15 @@ | ||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit | ||
/* eslint-disable */ | ||
|
||
import type { Enum } from '@polkadot/types-codec'; | ||
import type { AssetId } from '@polkadot/types/interfaces/runtime'; | ||
|
||
/** @name MultiAssetId */ | ||
export interface MultiAssetId extends Enum { | ||
readonly isNative: boolean; | ||
readonly isAsset: boolean; | ||
readonly asAsset: AssetId; | ||
readonly type: 'Native' | 'Asset'; | ||
} | ||
|
||
export type PHANTOM_ASSETCONVERSION = 'assetConversion'; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsidorenko
I think, primary, we use asset-conversion on AssetHubs, so lets make them work at least,
so I would change it here to
Box<XcmV3MultiLocation>
(please, try it locally, should work),and then lets solve: https://github.com/paritytech/cumulus/issues/2915
and then lets find solution how to dynamically support: MultiAssetId (substrate node) vs MultiLocation (asset-hub),
because this could require some dynamic loading or some switch for node kind (substrate -> MultiAssetId, asset-hubs -> MultiLocation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tried, the
Box<XcmV3MultiLocation>
works well