difftreelog
fix hrmpchannel gov script
in: master
1 file changed
js-packages/scripts/hrmpchannel.tsdiffbeforeafterboth4export const paraChildSovereignAccount = (relayApi: ApiPromise, paraid: number) => {4export const paraChildSovereignAccount = (relayApi: ApiPromise, paraid: number) => {5 // We are getting a *child* parachain sovereign account,5 // We are getting a *child* parachain sovereign account,6 // so we need a child prefix: encoded(b"para") == 0x706172616 // so we need a child prefix: encoded(b"para") == 0x706172617 const childPrefix = '0x70617261';7 const childPrefix = '70617261';889 const encodedParaId = relayApi.createType('u32', paraid).toHex(true).substring(2);9 const encodedParaId = relayApi10 .createType('u32', paraid)11 .toHex(true)12 .substring(2 /* skip 0x */);1310 const suffix = '000000000000000000000000000000000000000000000000';14 const addrBytesLen = 32;1115 const byteLenInHex = 2;12 return childPrefix + encodedParaId + suffix;16 return '0x' + (childPrefix + encodedParaId).padEnd(addrBytesLen * byteLenInHex, '0');13};17};141815const proposeOpenChannel = async (relayApi: ApiPromise, relayFee: bigint, senderParaId: number, receiverParaId: number) => {19const proposeOpenChannel = async (relayApi: ApiPromise, relayFee: bigint, senderParaId: number, receiverParaId: number) => {21 const senderDeposit = BigInt(conf.hrmpSenderDeposit);25 const senderDeposit = BigInt(conf.hrmpSenderDeposit);222623 const requiredBalance = relayFee + senderDeposit;27 const requiredBalance = relayFee + senderDeposit;24 const sovereignAccount = await paraChildSovereignAccount(relayApi, senderParaId);28 const sovereignAccount = paraChildSovereignAccount(relayApi, senderParaId);25 const balance = await relayApi.query.system.account(sovereignAccount)29 const balance = await relayApi.query.system.account(sovereignAccount)26 .then(accountInfo => (accountInfo.toJSON() as any).data.free as bigint);30 .then(accountInfo => (accountInfo.toJSON() as any).data.free as bigint);2731434744 const requiredBalance = relayFee + recipientDeposit;48 const requiredBalance = relayFee + recipientDeposit;454946 const sovereignAccount = await paraChildSovereignAccount(relayApi, recipientParaId);50 const sovereignAccount = paraChildSovereignAccount(relayApi, recipientParaId);47 const balance = await relayApi.query.system.account(sovereignAccount)51 const balance = await relayApi.query.system.account(sovereignAccount)48 .then(accountInfo => (accountInfo.toJSON() as any).data.free as bigint);52 .then(accountInfo => (accountInfo.toJSON() as any).data.free as bigint);4953