git.delta.rocks / unique-network / refs/commits / 2c288b082d41

difftreelog

fix(tests) keyring/logs/decimals parsing/comments

Daniel Shiposha2022-09-07parent: #4bcecc1.patch.diff
in: master

1 file changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
108 const dotPos = numberStr.length - decimals;108 const dotPos = numberStr.length - decimals;
109109
110 if (dotPos <= 0) {110 if (dotPos <= 0) {
111 return '0.' + numberStr;111 return '0.' + '0'.repeat(Math.abs(dotPos)) + numberStr;
112 } else {112 } else {
113 const intPart = numberStr.substring(0, dotPos);113 const intPart = numberStr.substring(0, dotPos);
114 const fractPart = numberStr.substring(dotPos);114 const fractPart = numberStr.substring(dotPos);
11151115
1116export async function paraSiblingSovereignAccount(paraid: number): Promise<string> {1116export async function paraSiblingSovereignAccount(paraid: number): Promise<string> {
1117 return usingApi(async api => {1117 return usingApi(async api => {
1118 // We are getting a *sibling* parachain sovereign account,
1119 // so we need a sibling prefix: encoded(b"sibl") == 0x7369626c
1118 const siblingPrefix = '0x7369626c';1120 const siblingPrefix = '0x7369626c';
1121
1119 const encodedParaId = api.createType('u32', paraid).toHex(true).substring(2);1122 const encodedParaId = api.createType('u32', paraid).toHex(true).substring(2);
1805 });1808 });
18061809
1807 if (neededEvent) {1810 if (neededEvent) {
1808 console.log(`Event \`${eventIdStr}\` is found`);
1809
1810 unsubscribe();1811 unsubscribe();
1811 resolve(neededEvent);1812 resolve(neededEvent);
18521853
1853let accountSeed = 10000;1854let accountSeed = 10000;
1854
1855const keyringEth = new Keyring({type: 'ethereum'});
1856const keyringEd25519 = new Keyring({type: 'ed25519'});
1857const keyringSr25519 = new Keyring({type: 'sr25519'});
18581855
1859export function generateKeyringPair(type: 'ethereum' | 'sr25519' | 'ed25519' = 'sr25519') {1856export function generateKeyringPair(keyring: Keyring) {
1860 const privateKey = `0xDEADBEEF${(accountSeed++).toString(16).padStart(56, '0')}`;1857 const privateKey = `0xDEADBEEF${(accountSeed++).toString(16).padStart(56, '0')}`;
1861 if (type == 'sr25519') {
1862 return keyringSr25519.addFromUri(privateKey);
1863 } else if (type == 'ed25519') {
1864 return keyringEd25519.addFromUri(privateKey);
1865 }
1866 return keyringEth.addFromUri(privateKey);1858 return keyring.addFromUri(privateKey);
1867}1859}
18681860