Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/cargo/color-print-0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteolaf committed May 6, 2024
2 parents 67cc241 + 42d4e46 commit 1002a14
Show file tree
Hide file tree
Showing 31 changed files with 1,177 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Install Rust
run: cargo install [email protected]
run: cargo install --git https://github.com/paritytech/psvm --rev a3ecef700e4c1429c2d01e265a145654ceb3cc49 psvm
- name: Check Dependency Versions
run: |
chmod +x ./scripts/check-dependency-versions.sh
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ bin/

node_modules
**/package-lock.json
**/build
46 changes: 44 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,25 @@ pallet-aura = { version = "27.0.0", default-features = false }
pallet-authorship = { version = "28.0.0", default-features = false }
pallet-balances = { version = "28.0.0", default-features = false }
pallet-broker = { version = "0.6.0", default-features = false }
pallet-collective = { version = "28.0.0", default-features = false }
pallet-conviction-voting = { version = "28.0.0", default-features = false }
pallet-session = { version = "28.0.0", default-features = false }
pallet-sudo = { version = "28.0.0", default-features = false }
pallet-timestamp = { version = "27.0.0", default-features = false }
pallet-transaction-payment = { version = "28.0.0", default-features = false }
pallet-asset-rate = { version = "7.0.0", default-features = false }
pallet-asset-tx-payment = { version = "28.0.0", default-features = false }
pallet-referenda = { version = "28.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-features = false }
pallet-membership = { version = "28.0.0", default-features = false }
pallet-message-queue = { version = "31.0.0", default-features = false }
pallet-multisig = { version = "28.0.0", default-features = false }
pallet-proxy = { version = "28.0.0", default-features = false }
pallet-preimage = { version = "28.0.0", default-features = false }
pallet-scheduler = { version = "29.0.0", default-features = false }
pallet-treasury = { version = "27.0.0", default-features = false }
pallet-utility = { version = "28.0.0", default-features = false }
pallet-whitelist = { version = "27.0.0", default-features = false }
sp-api = { version = "26.0.0", default-features = false }
sp-blockchain = { version = "28.0.0", default-features = false }
sp-io = { version = "30.0.0", default-features = false }
Expand Down Expand Up @@ -139,6 +147,8 @@ orml-asset-registry = { version = "0.7.0", default-features = false }
orml-currencies = { version = "0.7.0", default-features = false }
orml-tokens = { version = "0.7.0", default-features = false }
orml-traits = { version = "0.7.0", default-features = false }
orml-unknown-tokens = { version = "0.7.0", default-features = false }
orml-xcm-support = { version = "0.7.0", default-features = false }

# Polytope Labs
ismp = { git="https://github.com/Szegoo/hyperbridge.git", branch="fix-to-string", default-features = false }
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
2. Build the `regionx-node` by running:

```
cargo build --release
cargo build --release --features fast-runtime
```

3. Get the polkadot binary:
Expand All @@ -19,8 +19,23 @@
export PATH=/home/<username>/RegionX-Node/:$PATH
```

4. Run the test:
4. Run the tests:

- block production

```
zombienet-linux -p native test ./zombienet_tests/0001-smoke-test.zndsl
```

```
zombienet-linux -p native test ./zombienet_tests/0001-block-production.zndsl
```

- native fee payment

```
zombienet-linux -p native test ./zombienet_tests/0002-native-fee-payment.zndsl
```

- custom fee payment

```
zombienet-linux -p native test ./zombienet_tests/0003-custom-fee-payment.zndsl
```
24 changes: 0 additions & 24 deletions e2e_tests/common.js

This file was deleted.

57 changes: 57 additions & 0 deletions e2e_tests/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ApiPromise } from "@polkadot/api";
import { SubmittableExtrinsic, SignerOptions } from "@polkadot/api/types";
import { KeyringPair } from "@polkadot/keyring/types";

const RELAY_ASSET_ID = 1;

async function submitExtrinsic(signer: KeyringPair, call: SubmittableExtrinsic<"promise">, options: Partial<SignerOptions>): Promise<void> {
return new Promise(async (resolve, reject) => {
const unsub = await call.signAndSend(signer, options, (result) => {
console.log(`Current status is ${result.status}`);
if (result.status.isInBlock) {
console.log(
`Transaction included at blockHash ${result.status.asInBlock}`
);
} else if (result.status.isFinalized) {
console.log(
`Transaction finalized at blockHash ${result.status.asFinalized}`
);
unsub();
return resolve();
} else if (result.isError) {
console.log(`Transaction error`);
unsub();
return reject();
}
});
});
}

async function setupRelayAsset(api: ApiPromise, signer: KeyringPair) {
const assetMetadata = {
decimals: 12,
name: "ROC",
symbol: "ROC",
existentialDeposit: 10n ** 3n,
location: null,
additional: null,
};

const assetSetupCalls = [
api.tx.assetRegistry.registerAsset(assetMetadata, RELAY_ASSET_ID),
api.tx.assetRate.create(RELAY_ASSET_ID, 1_000_000_000_000_000_000n), // 1 on 1
api.tx.tokens.setBalance(
signer.address,
RELAY_ASSET_ID,
10n ** 12n,
0,
),
];

const batchCall = api.tx.utility.batch(assetSetupCalls);
const sudoCall = api.tx.sudo.sudo(batchCall);

await submitExtrinsic(signer, sudoCall, {});
}

export { submitExtrinsic, setupRelayAsset, RELAY_ASSET_ID }
48 changes: 0 additions & 48 deletions e2e_tests/custom-fee-payment.js

This file was deleted.

73 changes: 73 additions & 0 deletions e2e_tests/fee-payment/custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { ApiPromise, WsProvider, Keyring } from "@polkadot/api";
import { submitExtrinsic, setupRelayAsset, RELAY_ASSET_ID } from "../common";

async function run(nodeName: string, networkInfo: any, _jsArgs: any) {
const { wsUri: regionXUri } = networkInfo.nodesByName[nodeName];
const { wsUri: rococoUri } = networkInfo.nodesByName["rococo-validator01"];

const rococoApi = await ApiPromise.create({ provider: new WsProvider(rococoUri) });
const regionXApi = await ApiPromise.create({
provider: new WsProvider(regionXUri),
signedExtensions: {
ChargeAssetTxPayment: {
extrinsic: {
tip: "Compact<Balance>",
assetId: "Option<AssetId>",
},
payload: {},
},
},
});

// account to submit tx
const keyring = new Keyring({ type: "sr25519" });
const alice = keyring.addFromUri("//Alice");

const setXcmVersion = rococoApi.tx.xcmPallet.forceDefaultXcmVersion([3]);
await submitExtrinsic(alice, rococoApi.tx.sudo.sudo(setXcmVersion), {});

await setupRelayAsset(regionXApi, alice);

const receiverKeypair = new Keyring();
receiverKeypair.addFromAddress(alice.address);

const feeAssetItem = 0;
const weightLimit = "Unlimited";
const reserveTransfer = rococoApi.tx.xcmPallet.limitedReserveTransferAssets(
{ V3: { parents: 0, interior: { X1: { Parachain: 2000 } } } }, //dest
{
V3: {
parents: 0,
interior: {
X1: {
AccountId32: {
chain: "Any",
id: receiverKeypair.pairs[0].publicKey,
},
},
},
},
}, //beneficiary
{
V3: [
{
id: {
Concrete: { parents: 0, interior: "Here" },
},
fun: {
Fungible: 10n ** 9n,
},
},
],
}, //asset
feeAssetItem,
weightLimit
);
await submitExtrinsic(alice, reserveTransfer, {});

// Try to pay for fees with relay chain asset.
const remarkCall = regionXApi.tx.system.remark("0x44");
await submitExtrinsic(alice, remarkCall, { assetId: RELAY_ASSET_ID });
}

export { run };
Loading

0 comments on commit 1002a14

Please sign in to comment.