diff --git a/.changeset/cuddly-hairs-speak.md b/.changeset/cuddly-hairs-speak.md new file mode 100644 index 00000000..0707f037 --- /dev/null +++ b/.changeset/cuddly-hairs-speak.md @@ -0,0 +1,7 @@ +--- +'@moonbeam-network/xcm-builder': patch +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +Pendulum integration with Moonbase diff --git a/.github/workflows/publish-dev.yml b/.github/workflows/publish-dev.yml index 79268333..4e9b1d4f 100644 --- a/.github/workflows/publish-dev.yml +++ b/.github/workflows/publish-dev.yml @@ -22,7 +22,7 @@ jobs: - run: npm ci --ignore-scripts - name: ✌️ Update versions - run: npx ts-node --esm ./scripts/update-dev-versions.ts + run: npx bun ./scripts/update-dev-versions.ts - name: 🛠️ Build run: npm run build diff --git a/.vscode/settings.json b/.vscode/settings.json index 26ef47ff..31aad05b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -38,7 +38,7 @@ "editor.formatOnSaveMode": "file", "typescript.preferences.importModuleSpecifier": "relative", "editor.codeActionsOnSave": { - "source.organizeImports": true, - "source.fixAll.eslint": true + "source.organizeImports": "explicit", + "source.fixAll.eslint": "explicit" } } diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index cb021f41..62f1e4f1 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -6,7 +6,7 @@ "type": "module", "main": "index.ts", "scripts": { - "start": "ts-node --esm index.ts" + "start": "bun index.ts" }, "keywords": [], "author": "", @@ -17,6 +17,6 @@ "@moonbeam-network/xcm-utils": "1.0.3" }, "devDependencies": { - "ts-node": "^10.9.1" + "bun": "^1.0.20" } } diff --git a/package-lock.json b/package-lock.json index da2ff33d..194eb4aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.59.8", + "bun": "^1.0.20", "dotenv": "^16.3.1", "eslint": "^8.41.0", "eslint-config-airbnb-base": "^15.0.0", @@ -38,7 +39,6 @@ "lint-staged": "^13.2.3", "prettier": "^2.8.8", "ts-jest": "^29.1.0", - "ts-node": "^10.9.1", "tsup": "^6.7.0", "turbo": "^1.9.9", "typescript": "^5.0.4", @@ -54,7 +54,7 @@ "@moonbeam-network/xcm-utils": "1.0.3" }, "devDependencies": { - "ts-node": "^10.9.1" + "bun": "^1.0.20" } }, "node_modules/@acala-network/type-definitions": { @@ -1016,6 +1016,8 @@ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -1028,6 +1030,8 @@ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -4054,6 +4058,84 @@ "lodash.merge": "^4.6.2" } }, + "node_modules/@oven/bun-darwin-aarch64": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.0.20.tgz", + "integrity": "sha512-8eB/OtkCuesoUI8qk6CywuJ+OSH5rk3LDStn2+c91dmHhXZ5q++D8nJKNOkyRh4nWsR3q2loav+CPQddbEJp9g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-darwin-x64": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.0.20.tgz", + "integrity": "sha512-esoLmnV8/FrAMb1DaXdmPJXni1Ow7wjOd6qoq6yd/CkMwkO2LIGBOpR1fG31QKW78GgsHiDFi4NfyNBVvOc/mA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-darwin-x64-baseline": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.0.20.tgz", + "integrity": "sha512-QF1Bja1lhKjG25UkTkZ1VzJ9ZzkVPppskSKX/y2zx8xwKPlCgoxLXrvx4edKpqIgbD0zGTSRO8EOuPn/VbGDAA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-linux-aarch64": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.0.20.tgz", + "integrity": "sha512-Zy4PwUb1JRnBoPc3N9S1XtMzRIz+2R5VME9O08bFRlj2sg2mf7bSFElavsRTTEPys5X/QJU3E3GngWFxKpc4Vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.0.20.tgz", + "integrity": "sha512-1iA6EFGfAGCPbmEvRXCmayoFZXNm/8KrLF5RJt51FBt1mHmbVE7vX/xOexAQbh69bO1EFy6ruslPV3arLLie+g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64-baseline": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.0.20.tgz", + "integrity": "sha512-lZUcUsq4Fk3CxhF5UhZhB2hhNViYzAFPprL47LxuFuvtybPtXVCOCyGSP37MiMfA6QxE+nNW6w7oJQqXkC1exg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@parallel-finance/type-definitions": { "version": "1.7.17", "resolved": "https://registry.npmjs.org/@parallel-finance/type-definitions/-/type-definitions-1.7.17.tgz", @@ -5648,25 +5730,33 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/@types/babel__core": { "version": "7.20.1", @@ -6258,6 +6348,8 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.4.0" } @@ -6375,7 +6467,9 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/argparse": { "version": "1.0.10", @@ -6898,6 +6992,33 @@ "node": ">=6.14.2" } }, + "node_modules/bun": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/bun/-/bun-1.0.20.tgz", + "integrity": "sha512-dBTDB8ombE6JzBgxRqY1GCjl5gcYziNcC9lvgqXx7bnq+bTBeW3rd8TKIgPNmmJbdwXTLJRe/5G7E2Po4CxGlA==", + "cpu": [ + "arm64", + "x64" + ], + "dev": true, + "hasInstallScript": true, + "os": [ + "darwin", + "linux" + ], + "bin": { + "bun": "bin/bun", + "bunx": "bin/bun" + }, + "optionalDependencies": { + "@oven/bun-darwin-aarch64": "1.0.20", + "@oven/bun-darwin-x64": "1.0.20", + "@oven/bun-darwin-x64-baseline": "1.0.20", + "@oven/bun-linux-aarch64": "1.0.20", + "@oven/bun-linux-x64": "1.0.20", + "@oven/bun-linux-x64-baseline": "1.0.20" + } + }, "node_modules/bundle-require": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-4.0.1.tgz", @@ -7300,7 +7421,9 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/cross-spawn": { "version": "7.0.3", @@ -7530,6 +7653,8 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.3.1" } @@ -15749,6 +15874,8 @@ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -16301,7 +16428,9 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/v8-to-istanbul": { "version": "9.1.0", @@ -16827,6 +16956,8 @@ "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=6" } diff --git a/package.json b/package.json index f346ee92..2a72cf45 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.59.8", + "bun": "^1.0.20", "dotenv": "^16.3.1", "eslint": "^8.41.0", "eslint-config-airbnb-base": "^15.0.0", @@ -61,7 +62,6 @@ "lint-staged": "^13.2.3", "prettier": "^2.8.8", "ts-jest": "^29.1.0", - "ts-node": "^10.9.1", "tsup": "^6.7.0", "turbo": "^1.9.9", "typescript": "^5.0.4", diff --git a/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts b/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts index 56afd29e..6fee58d5 100644 --- a/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts +++ b/packages/builder/src/contract/contracts/Xtokens/Xtokens.ts @@ -6,9 +6,11 @@ import { decodeAddress } from '@polkadot/util-crypto'; import { ContractConfigBuilder } from '../../ContractBuilder.interfaces'; import { ContractConfig } from '../../ContractConfig'; +const U_64_MAX = 18446744073709551615n; + export function Xtokens() { return { - transfer: (weight = 4_000_000_000): ContractConfigBuilder => ({ + transfer: (weight = U_64_MAX): ContractConfigBuilder => ({ build: ({ address, amount, asset, destination }) => new ContractConfig({ args: [ @@ -21,9 +23,7 @@ export function Xtokens() { module: 'Xtokens', }), }), - transferMultiCurrencies: ( - weight = 4_000_000_000, - ): ContractConfigBuilder => ({ + transferMultiCurrencies: (weight = U_64_MAX): ContractConfigBuilder => ({ build: ({ address, amount, asset, destination, fee, feeAsset }) => new ContractConfig({ args: [ diff --git a/packages/config/src/assets.ts b/packages/config/src/assets.ts index 59ae920e..cc0da809 100644 --- a/packages/config/src/assets.ts +++ b/packages/config/src/assets.ts @@ -10,6 +10,11 @@ export const alan = new Asset({ originSymbol: 'ALAN', }); +export const ampe = new Asset({ + key: 'ampe', + originSymbol: 'AMPE', +}); + export const astr = new Asset({ key: 'astr', originSymbol: 'ASTR', @@ -308,6 +313,7 @@ export const ztg = new Asset({ export const assetsList: Asset[] = [ aca, alan, + ampe, astr, atom, auq, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 6b2acd87..6ba801b2 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -7,6 +7,7 @@ import { import { aca, alan, + ampe, aseed, astr, atom, @@ -689,6 +690,10 @@ export const moonbaseAlpha = new EvmParachain({ id: '0x9133c5a22024118804089f1fB752b7B2ce2a6351', metadataId: 0, // no metadata for ERC20 tokens }, + { + asset: ampe, + id: '170050401128744171791743427490841452054', + }, { asset: atom, id: '244316754493307480955066032215622931381', @@ -1150,6 +1155,30 @@ export const parallelHeiko = new Parachain({ ws: 'wss://heiko-rpc.parallel.fi', }); +export const pendulumAlphanet = new Parachain({ + assetsData: [ + { + asset: ampe, + id: 'Native', + metadataId: 0, + }, + { + asset: dev, + decimals: 18, + id: { XCM: 1 }, + }, + ], + ecosystem: Ecosystem.AlphanetRelay, + genesisHash: + '0xe83b546ddeccf999d4b7fef4d83271034e82bb5db538e769c242c2731f61e8d6', + isTestChain: true, + key: 'pendulum-alphanet', + name: 'Foucoco', + parachainId: 2124, + ss58Format: 57, + ws: 'wss://moonbeam-00.pendulumchain.tech:443', +}); + export const phala = new Parachain({ assetsData: [ { @@ -1418,6 +1447,7 @@ export const chainsList: AnyChain[] = [ originTrailAlphanet, parallel, parallelHeiko, + pendulumAlphanet, phala, picasso, picassoAlphanet, diff --git a/packages/config/src/configs/index.ts b/packages/config/src/configs/index.ts index 77538590..f1597b49 100644 --- a/packages/config/src/configs/index.ts +++ b/packages/config/src/configs/index.ts @@ -34,6 +34,7 @@ import { originTrailConfig } from './originTrail'; import { originTrailAlphanetConfig } from './originTrailAlphanet'; import { parallelConfig } from './parallel'; import { parallelHeikoConfig } from './parallelHeiko'; +import { pendulumAlphanetConfig } from './pendulumAlphanet'; import { phalaConfig } from './phala'; import { picassoConfig } from './picasso'; import { picassoAlphanetConfig } from './picassoAlphanet'; @@ -80,6 +81,7 @@ export const chainsConfigList: ChainConfig[] = [ originTrailAlphanetConfig, parallelConfig, parallelHeikoConfig, + pendulumAlphanetConfig, phalaConfig, picassoConfig, picassoAlphanetConfig, diff --git a/packages/config/src/configs/moonbaseAlpha.ts b/packages/config/src/configs/moonbaseAlpha.ts index ee4d7478..dea9b312 100644 --- a/packages/config/src/configs/moonbaseAlpha.ts +++ b/packages/config/src/configs/moonbaseAlpha.ts @@ -1,6 +1,7 @@ import { BalanceBuilder, ContractBuilder } from '@moonbeam-network/xcm-builder'; import { alan, + ampe, atom, dev, eq, @@ -22,6 +23,7 @@ import { moonbaseAlpha, moonbaseBeta, originTrailAlphanet, + pendulumAlphanet, picassoAlphanet, turingAlphanet, } from '../chains'; @@ -63,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: pendulumAlphanet, + destinationFee: { + amount: 0.0000001, + asset: dev, + balance: BalanceBuilder().substrate().system().account(), + }, + }), new AssetConfig({ asset: dev, balance: BalanceBuilder().substrate().system().account(), @@ -104,6 +117,21 @@ export const moonbaseAlphaConfig = new ChainConfig({ // balance: BalanceBuilder().substrate().system().account(), // }, // }), + new AssetConfig({ + asset: ampe, + balance: BalanceBuilder().substrate().assets().account(), + contract: ContractBuilder().Xtokens().transfer(), + destination: pendulumAlphanet, + destinationFee: { + amount: 0.001, + asset: ampe, + balance: BalanceBuilder().substrate().assets().account(), + }, + fee: { + asset: dev, + balance: BalanceBuilder().substrate().system().account(), + }, + }), new AssetConfig({ asset: eq, balance: BalanceBuilder().substrate().assets().account(), diff --git a/packages/config/src/configs/pendulumAlphanet.ts b/packages/config/src/configs/pendulumAlphanet.ts new file mode 100644 index 00000000..6827d549 --- /dev/null +++ b/packages/config/src/configs/pendulumAlphanet.ts @@ -0,0 +1,41 @@ +import { + BalanceBuilder, + ExtrinsicBuilder, + FeeBuilder, +} from '@moonbeam-network/xcm-builder'; +import { ampe, dev } from '../assets'; +import { moonbaseAlpha, pendulumAlphanet } from '../chains'; +import { AssetConfig } from '../types/AssetConfig'; +import { ChainConfig } from '../types/ChainConfig'; + +export const pendulumAlphanetConfig = new ChainConfig({ + assets: [ + new AssetConfig({ + asset: ampe, + balance: BalanceBuilder().substrate().system().account(), + destination: moonbaseAlpha, + destinationFee: { + amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + asset: ampe, + balance: BalanceBuilder().substrate().system().account(), + }, + extrinsic: ExtrinsicBuilder().xTokens().transfer(), + }), + new AssetConfig({ + asset: dev, + balance: BalanceBuilder().substrate().tokens().accounts(), + destination: moonbaseAlpha, + destinationFee: { + amount: 0.01, + asset: dev, + balance: BalanceBuilder().substrate().tokens().accounts(), + }, + extrinsic: ExtrinsicBuilder().xTokens().transfer(), + fee: { + asset: ampe, + balance: BalanceBuilder().substrate().system().account(), + }, + }), + ], + chain: pendulumAlphanet, +});