-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f33de3
commit b9d3d04
Showing
8 changed files
with
29 additions
and
23 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
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"name": "@sora-substrate/connection", | ||
"version": "1.21.7", | ||
"version": "1.21.8", | ||
"license": "Apache-2.0", | ||
"main": "./build/index.js", | ||
"typings": "./build/index.d.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@sora-substrate/api": "1.21.7" | ||
"@sora-substrate/api": "1.21.8" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"name": "@sora-substrate/liquidity-proxy", | ||
"version": "1.21.7", | ||
"version": "1.21.8", | ||
"license": "Apache-2.0", | ||
"main": "./build/index.js", | ||
"typings": "./build/index.d.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@sora-substrate/math": "1.21.7" | ||
"@sora-substrate/math": "1.21.8" | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,24 +1,30 @@ | ||
import type { ApiPromise } from '@polkadot/api'; | ||
import type { CodecString } from '@sora-substrate/math'; | ||
import type { u32, u128 } from '@polkadot/types'; | ||
import type { Option } from '@polkadot/types-codec'; | ||
import type { XcmV3MultiLocation } from '@polkadot/types/lookup'; | ||
|
||
export class SoraParachainApi { | ||
public async getRelayChainBlockNumber(blockHash: string, api: ApiPromise): Promise<number> { | ||
const apiInstanceAtBlock = await api.at(blockHash); | ||
const blockNumber = await apiInstanceAtBlock.query.parachainSystem.lastRelayChainBlockNumber(); | ||
const blockNumber = (await apiInstanceAtBlock.query.parachainSystem.lastRelayChainBlockNumber()) as u32; | ||
|
||
return Number(blockNumber.toString()); | ||
return blockNumber.toNumber(); | ||
} | ||
|
||
public async getAssetMulilocation(assetId: string, api: ApiPromise) { | ||
const multilocation = await api.query.xcmApp.assetIdToMultilocation(assetId); | ||
public async getAssetMulilocation(assetId: string, api: ApiPromise): Promise<XcmV3MultiLocation | null> { | ||
const multilocation = (await api.query.xcmApp.assetIdToMultilocation(assetId)) as Option<XcmV3MultiLocation>; | ||
|
||
return multilocation; | ||
return multilocation.isSome ? multilocation.unwrap() : null; | ||
} | ||
|
||
public async getAssetMinimumAmount(assetId: string, api: ApiPromise): Promise<CodecString> { | ||
const multilocation = await this.getAssetMulilocation(assetId, api); | ||
const amount = await api.query.xcmApp.assetMinimumAmount(multilocation); | ||
|
||
return amount.toString(); | ||
if (!multilocation) return '0'; | ||
|
||
const amount = (await api.query.xcmApp.assetMinimumAmount(multilocation)) as Option<u128>; | ||
|
||
return amount.isSome ? amount.unwrap().toString() : '0'; | ||
} | ||
} |