Skip to content
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

Picasso Integration with Moonbase and dependency updates #148

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/kind-schools-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@moonbeam-network/xcm-builder': patch
'@moonbeam-network/xcm-config': patch
'@moonbeam-network/xcm-utils': patch
'@moonbeam-network/xcm-sdk': patch
---

Picasso integration with Moonbase and dependency updates
845 changes: 412 additions & 433 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"changeset:publish": "npm run build && changeset publish"
},
"dependencies": {
"@polkadot/api": "^10.9.1",
"@polkadot/api-augment": "^10.9.1",
"@polkadot/types": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2"
"@polkadot/api": "^10.10.1",
"@polkadot/api-augment": "^10.10.1",
"@polkadot/types": "^10.10.1",
"@polkadot/util": "^12.5.1",
"@polkadot/util-crypto": "^12.5.1"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
Expand Down
10 changes: 5 additions & 5 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
"type-fest": "^3.8.0"
},
"peerDependencies": {
"@polkadot/api": "^10.9.1",
"@polkadot/api-augment": "^10.9.1",
"@polkadot/types": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2"
"@polkadot/api": "^10.10.1",
"@polkadot/api-augment": "^10.10.1",
"@polkadot/types": "^10.10.1",
"@polkadot/util": "^12.5.1",
"@polkadot/util-crypto": "^12.5.1"
}
}
6 changes: 3 additions & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"@moonbeam-network/xcm-types": "1.0.1"
},
"peerDependencies": {
"@polkadot/types": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2"
"@polkadot/types": "^10.10.1",
"@polkadot/util": "^12.5.1",
"@polkadot/util-crypto": "^12.5.1"
}
}
12 changes: 12 additions & 0 deletions packages/config/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export const astr = new Asset({
originSymbol: 'ASTR',
});

export const atom = new Asset({
key: 'atom',
originSymbol: 'ATOM',
});

export const auq = new Asset({
key: 'auq',
originSymbol: 'AUQ',
Expand Down Expand Up @@ -170,6 +175,11 @@ export const pha = new Asset({
originSymbol: 'PHA',
});

export const pica = new Asset({
key: 'pica',
originSymbol: 'PICA',
});

export const ring = new Asset({
key: 'ring',
originSymbol: 'RING',
Expand Down Expand Up @@ -274,6 +284,7 @@ export const assetsList: Asset[] = [
aca,
alan,
astr,
atom,
auq,
aseed,
bnc,
Expand Down Expand Up @@ -304,6 +315,7 @@ export const assetsList: Asset[] = [
para,
paring,
pha,
pica,
ring,
rmrk,
sdn,
Expand Down
38 changes: 38 additions & 0 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
alan,
aseed,
astr,
atom,
auq,
betaDEV,
bnc,
Expand Down Expand Up @@ -39,6 +40,7 @@ import {
para,
paring,
pha,
pica,
ring,
rmrk,
sdn,
Expand Down Expand Up @@ -199,6 +201,7 @@ export const bifrostPolkadot = new Parachain({
{
asset: vdot,
id: { VToken2: 0 },
metadataId: { VToken2: 0 },
},
{
asset: vfil,
Expand Down Expand Up @@ -672,6 +675,10 @@ export const moonbaseAlpha = new EvmParachain({
id: '0x9133c5a22024118804089f1fB752b7B2ce2a6351',
metadataId: 0, // no metadata for ERC20 tokens
},
{
asset: atom,
id: '244316754493307480955066032215622931381',
},
{
asset: auq,
id: '69536036667157951501899290870203586130',
Expand Down Expand Up @@ -702,6 +709,10 @@ export const moonbaseAlpha = new EvmParachain({
asset: paring,
id: '173481220575862801646329923366065693029',
},
{
asset: pica,
id: '22417088946346045371238623691600461855',
},
{
asset: soon,
id: '205153165378836428058230526014907639736',
Expand Down Expand Up @@ -1122,6 +1133,32 @@ export const phala = new Parachain({
ws: 'wss://api.phala.network/ws',
});

export const picassoAlphanet = new Parachain({
assetsData: [
{
asset: pica,
id: 1,
},
{
asset: atom,
id: 7,
},
{
asset: dev,
id: 10,
},
],
ecosystem: Ecosystem.AlphanetRelay,
genesisHash:
'0x3db2074093ab964732631d842b99d6612a6dc75a379738a660642b05ccad59c8',
isTestChain: true,
key: 'picasso-alphanet',
name: 'Picasso Alphanet',
parachainId: 2019,
ss58Format: 49,
ws: 'wss://boot-01.picasso2270.composablenodes.tech/',
});

export const polkadot = new Parachain({
ecosystem: Ecosystem.Polkadot,
genesisHash:
Expand Down Expand Up @@ -1306,6 +1343,7 @@ export const chainsList: AnyChain[] = [
parallel,
parallelHeiko,
phala,
picassoAlphanet,
polkadot,
robonomics,
shiden,
Expand Down
2 changes: 2 additions & 0 deletions packages/config/src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { originTrailAlphanetConfig } from './originTrailAlphanet';
import { parallelConfig } from './parallel';
import { parallelHeikoConfig } from './parallelHeiko';
import { phalaConfig } from './phala';
import { picassoAlphanetConfig } from './picassoAlphanet';
import { polkadotConfig } from './polkadot';
import { polkadotAssetHubConfig } from './polkadotAssetHub';
import { robonomicsConfig } from './robonomics';
Expand Down Expand Up @@ -78,6 +79,7 @@ export const chainsConfigList: ChainConfig[] = [
parallelConfig,
parallelHeikoConfig,
phalaConfig,
picassoAlphanetConfig,
polkadotConfig,
robonomicsConfig,
shidenConfig,
Expand Down
44 changes: 44 additions & 0 deletions packages/config/src/configs/moonbaseAlpha.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { BalanceBuilder, ContractBuilder } from '@moonbeam-network/xcm-builder';
import {
alan,
atom,
dev,
eq,
eqd,
lit,
otp,
paring,
pica,
soon,
tt1,
tur,
Expand All @@ -21,6 +23,7 @@ import {
moonbaseAlpha,
moonbaseBeta,
originTrailAlphanet,
picassoAlphanet,
subsocialAlphanet,
turingAlphanet,
} from '../chains';
Expand Down Expand Up @@ -62,6 +65,17 @@ export const moonbaseAlphaConfig = new ChainConfig({
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: dev,
balance: BalanceBuilder().substrate().system().account(),
contract: ContractBuilder().Xtokens().transfer(),
destination: picassoAlphanet,
destinationFee: {
amount: 0.00000001,
asset: dev,
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: alan,
balance: BalanceBuilder().evm().erc20(),
Expand Down Expand Up @@ -167,6 +181,36 @@ export const moonbaseAlphaConfig = new ChainConfig({
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: atom,
balance: BalanceBuilder().substrate().assets().account(),
contract: ContractBuilder().Xtokens().transfer(),
destination: picassoAlphanet,
destinationFee: {
amount: 0.0001,
asset: atom,
balance: BalanceBuilder().substrate().assets().account(),
},
fee: {
asset: dev,
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: pica,
balance: BalanceBuilder().substrate().assets().account(),
contract: ContractBuilder().Xtokens().transfer(),
destination: picassoAlphanet,
destinationFee: {
amount: 0.01,
asset: pica,
balance: BalanceBuilder().substrate().assets().account(),
},
fee: {
asset: dev,
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: soon,
balance: BalanceBuilder().substrate().assets().account(),
Expand Down
56 changes: 56 additions & 0 deletions packages/config/src/configs/picassoAlphanet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
BalanceBuilder,
ExtrinsicBuilder,
FeeBuilder,
} from '@moonbeam-network/xcm-builder';
import { atom, dev, pica } from '../assets';
import { moonbaseAlpha, picassoAlphanet } from '../chains';
import { AssetConfig } from '../types/AssetConfig';
import { ChainConfig } from '../types/ChainConfig';

export const picassoAlphanetConfig = new ChainConfig({
assets: [
new AssetConfig({
asset: pica,
balance: BalanceBuilder().substrate().system().account(),
destination: moonbaseAlpha,
destinationFee: {
amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(),
asset: pica,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetConfig({
asset: atom,
balance: BalanceBuilder().substrate().tokens().accounts(),
destination: moonbaseAlpha,
destinationFee: {
amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(),
asset: pica,
balance: BalanceBuilder().substrate().system().account(),
},
extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(),
fee: {
asset: pica,
balance: BalanceBuilder().substrate().system().account(),
},
}),
new AssetConfig({
asset: dev,
balance: BalanceBuilder().substrate().tokens().accounts(),
destination: moonbaseAlpha,
destinationFee: {
amount: 0.0001,
asset: dev,
balance: BalanceBuilder().substrate().tokens().accounts(),
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
fee: {
asset: pica,
balance: BalanceBuilder().substrate().system().account(),
},
}),
],
chain: picassoAlphanet,
});
8 changes: 4 additions & 4 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"big.js": "^6.2.1"
},
"peerDependencies": {
"@polkadot/api": "^10.9.1",
"@polkadot/api-augment": "^10.9.1",
"@polkadot/types": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/api": "^10.10.1",
"@polkadot/api-augment": "^10.10.1",
"@polkadot/types": "^10.10.1",
"@polkadot/util": "^12.5.1",
"ethers": "^5.7.2",
"viem": "^1.10.3"
}
Expand Down
21 changes: 18 additions & 3 deletions packages/sdk/src/polkadot/PolkadotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { getPolkadotApi } from '@moonbeam-network/xcm-utils';
import { ApiPromise } from '@polkadot/api';
import type { Signer as PolkadotSigner } from '@polkadot/api/types';
import { Option, u128 } from '@polkadot/types';
import { Option, u128, u8 } from '@polkadot/types';
import { IKeyringPair } from '@polkadot/types/types';
import { AssetMetadata } from './PolkadotService.interfaces';

Expand Down Expand Up @@ -135,10 +135,25 @@ export class PolkadotService {
};
}

async getAssetDecimalsFromQuery(
asset: ChainAssetId,
): Promise<number | undefined> {
const fn = this.api.query.assetsRegistry?.assetDecimals;

if (!fn) {
return undefined;
}

const data = (await fn(asset)) as Option<u8>;

return data.unwrapOrDefault().toNumber();
}

async getAssetDecimals(asset: Asset): Promise<number> {
const metaId = this.chain.getMetadataAssetId(asset);
return (
(await this.getAssetMeta(this.chain.getMetadataAssetId(asset)))
?.decimals ||
(await this.getAssetDecimalsFromQuery(metaId)) ||
(await this.getAssetMeta(metaId))?.decimals ||
this.chain.getAssetDecimals(asset) ||
this.decimals
);
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
},
"peerDependencies": {
"@polkadot/apps-config": "^0.132.1",
"@polkadot/api": "^10.9.1"
"@polkadot/api": "^10.10.1"
}
}
Loading