mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
700d5f85b7
Built on top of https://github.com/paritytech/polkadot-sdk/pull/2826/ which was a trial run. Guide: https://github.com/w3f/polkadot-wiki/blob/master/docs/maintain/maintain-guides-async-backing.md --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Dónal Murray <donal.murray@parity.io> Co-authored-by: Dmitry Sinyavin <dmitry.sinyavin@parity.io> Co-authored-by: s0me0ne-unkn0wn <48632512+s0me0ne-unkn0wn@users.noreply.github.com> Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
70 lines
2.0 KiB
JavaScript
70 lines
2.0 KiB
JavaScript
const assert = require("assert");
|
|
|
|
async function run(nodeName, networkInfo, _jsArgs) {
|
|
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
|
|
const api = await zombie.connect(wsUri, userDefinedTypes);
|
|
|
|
await zombie.util.cryptoWaitReady();
|
|
|
|
// account to submit tx
|
|
const keyring = new zombie.Keyring({ type: "sr25519" });
|
|
const alice = keyring.addFromUri("//Alice");
|
|
|
|
const calls = [
|
|
// Default broker configuration
|
|
api.tx.broker.configure({
|
|
advanceNotice: 5,
|
|
interludeLength: 1,
|
|
leadinLength: 1,
|
|
regionLength: 1,
|
|
idealBulkProportion: 100,
|
|
limitCoresOffered: null,
|
|
renewalBump: 10,
|
|
contributionTimeout: 5,
|
|
}),
|
|
// We need MOARE cores.
|
|
api.tx.broker.requestCoreCount(2),
|
|
// Set a lease for the broker chain itself.
|
|
api.tx.broker.setLease(
|
|
1005,
|
|
1000,
|
|
),
|
|
// Set a lease for parachain 100
|
|
api.tx.broker.setLease(
|
|
100,
|
|
1000,
|
|
),
|
|
// Start sale to make the broker "work", but we don't offer any cores
|
|
// as we have fixed leases only anyway.
|
|
api.tx.broker.startSales(1, 0),
|
|
];
|
|
const sudo_batch = api.tx.sudo.sudo(api.tx.utility.batch(calls));
|
|
|
|
await new Promise(async (resolve, reject) => {
|
|
const unsub = await sudo_batch.signAndSend(alice, (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) {
|
|
// Probably happens because of: https://github.com/paritytech/polkadot-sdk/issues/1202.
|
|
console.log(`Transaction error`);
|
|
// We ignore the error because it is very likely misleading, because of the issue mentioned above.
|
|
unsub();
|
|
return resolve();
|
|
}
|
|
});
|
|
});
|
|
|
|
return 0;
|
|
}
|
|
|
|
module.exports = { run };
|