git.delta.rocks / unique-network / refs/commits / f5e3860bbbbb

difftreelog

feat add bitintToDecimals and sovereign account util

Daniel Shiposha2022-10-11parent: #646fe67.patch.diff
in: master

1 file changed

modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
253 return isSuccess;253 return isSuccess;
254 }254 }
255
256 static bigIntToDecimals(number: bigint, decimals = 18) {
257 const numberStr = number.toString();
258 const dotPos = numberStr.length - decimals;
259
260 if (dotPos <= 0) {
261 return '0.' + '0'.repeat(Math.abs(dotPos)) + numberStr;
262 } else {
263 const intPart = numberStr.substring(0, dotPos);
264 const fractPart = numberStr.substring(dotPos);
265 return intPart + '.' + fractPart;
266 }
267 }
255}268}
256269
257class UniqueEventHelper {270class UniqueEventHelper {
2283 return CrossAccountId.translateSubToEth(subAddress);2296 return CrossAccountId.translateSubToEth(subAddress);
2284 }2297 }
2298
2299 paraSiblingSovereignAccount(paraid: number) {
2300 // We are getting a *sibling* parachain sovereign account,
2301 // so we need a sibling prefix: encoded(b"sibl") == 0x7369626c
2302 const siblingPrefix = '0x7369626c';
2303
2304 const encodedParaId = this.helper.getApi().createType('u32', paraid).toHex(true).substring(2);
2305 const suffix = '000000000000000000000000000000000000000000000000';
2306
2307 return siblingPrefix + encodedParaId + suffix;
2308 }
2285}2309}
22862310
2287class StakingGroup extends HelperGroup<UniqueHelper> {2311class StakingGroup extends HelperGroup<UniqueHelper> {
2601 super(logger, options.helperBase ?? UniqueHelper);2625 super(logger, options.helperBase ?? UniqueHelper);
26022626
2603 this.balance = new BalanceGroup(this);2627 this.balance = new BalanceGroup(this);
2604 this.address = new AddressGroup(this);
2605 this.collection = new CollectionGroup(this);2628 this.collection = new CollectionGroup(this);
2606 this.nft = new NFTGroup(this);2629 this.nft = new NFTGroup(this);
2607 this.rft = new RFTGroup(this);2630 this.rft = new RFTGroup(this);