1234import {usingPlaygrounds, Pallets} from './index';56const relayUrl0 = process.argv[2] ?? 'localhost:9844';7const relayUrl = `ws${relayUrl0.includes('localhost') ? '' : 's'}://${relayUrl0}`;89const paraUrl0 = process.argv[3] ?? 'localhost:9944';10const paraUrl = `ws${paraUrl0.includes('localhost') ? '' : 's'}://${paraUrl0}`;1112const key = process.argv.length > 4 ? process.argv.slice(4).join(' ') : '//Alice';131415const setIdentities = async (): Promise<void> => {16 const identities: any[] = [];17 await usingPlaygrounds(async helper => {18 try {19 for(const [key, v] of await helper.getApi().query.identity.identityOf.entries()) {20 const value = v as any;21 if (!value.isSome) continue;22 if (value.unwrap().toHuman().judgements.filter((x: any) => x[1] == 'Reasonable' || x[1] == 'KnownGood').length == 0) continue;23 identities.push([key, value]);24 }25 } catch (error) {26 console.error(error);27 throw Error('Error during fetching identities');28 }29 }, relayUrl);3031 await usingPlaygrounds(async (helper, privateKey) => {32 if (helper.fetchMissingPalletNames([Pallets.Identity]).length != 0) console.error('pallet-identity is not included in parachain.');33 try {34 const superuser = await privateKey(key);35 36 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.identity.setIdentities', [identities]);37 console.log(`Tried to upload ${identities.length} identities. `38 + `Now there are ${(await helper.getApi().query.identity.identityOf.keys()).length}.`);39 } catch (error) {40 console.error(error);41 throw Error('Error during setting identities');42 }43 }, paraUrl);44};4546setIdentities().catch(() => process.exit(1));