Skip to content

Commit

Permalink
Fix {BNC, RING} Ref Integrity (#217)
Browse files Browse the repository at this point in the history
* Fix statemint-kusama
  • Loading branch information
mkchungs committed Dec 7, 2022
1 parent 4cf5eae commit bb340f4
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 30 deletions.
10 changes: 5 additions & 5 deletions public/xcminfows.js
Expand Up @@ -75,7 +75,7 @@ ${fin}<br/>`
}

out += `${txHash}
<b>Extrinsic Hash:</b> ${getShortHash(origination.extrinsicHash)}<br/>
<b>Extrinsic Hash:</b> ${getShortHash(origination.extrinsicHash)}<br/>
<b>Extrinsic ID:</b> ${presentExtrinsicIDHash(origination.extrinsicID, origination.extrinsicHash)}<br/>`
if ( origination.sender ) {
out += `<div><b>Sender:</b> ${presentAddress(origination.sender)}</div>`
Expand All @@ -90,7 +90,7 @@ out += `<B>Module:</B> <button type="button" class="btn btn-outline-primary text
out += `<div><b>Transaction Fee Paid:</b> ${origination.txFee} ${origination.txFeeSymbol}</div>`
}
if ( origination.remoteEVMTx ) {
out += show_remoteEVMTx_origination(origination.remoteEVMTx, origination.id)
out += show_remoteEVMTx_origination(origination.remoteEVMTx, origination.id)
}
return out
}
Expand Down Expand Up @@ -131,7 +131,7 @@ function showDestination(destination, symbol)
if ( destination.paraID > 0 ) out += ` [Para ID: ${destination.paraID}]`;
out += ` ${destination.chainName}`
out += `</h6>`

let cls = finalized ? 'finalized' : 'unfinalized';
out += `<div class='${cls}'>`

Expand All @@ -141,7 +141,7 @@ function showDestination(destination, symbol)
let fin = finalized ? `<b>Finalized:</b> ${presentFinalized(finalized)}<br/>` : `<i>Unfinalized</i><br/>`
out += `${fin}`
if ( destination.blockNumber ) {
out += `<b>Received At Block:</b> ` + presentBlockNumber(destination.id, destination.id, destination.blockNumber)
out += `<b>Received At Block:</b> ` + presentBlockNumber(destination.id, destination.id, destination.blockNumber)
}
if ( destination.beneficiary ) {
out += `<div><b>Beneficiary:</b> ${presentAddress(destination.beneficiary)}</div>`
Expand All @@ -158,7 +158,7 @@ function showDestination(destination, symbol)
}
if ( destination.teleportFee ) {
let usd = ( destination.teleportFeeUSD ) ? currency_format(destination.teleportFeeUSD) : "";
out += `<div><b>Teleport Fees:</b> ${destination.teleportFee} ${destination.teleportFeeChainSymbol} ${usd}</div>`
out += `<div><b>XCM Fees:</b> ${destination.teleportFee} ${destination.teleportFeeChainSymbol} ${usd}</div>`
}
if ( destination.executionStatus ) {
out += show_executionStatus(destination.executionStatus)
Expand Down
1 change: 1 addition & 0 deletions substrate/assetManager.js
Expand Up @@ -829,6 +829,7 @@ module.exports = class AssetManager extends PolkaholicDB {
if (this.symbolRelayChainAsset[symbolRelayChain]) {
return true;
}
if (this.debugLevel >= paraTool.debugErrorOnly) console.log(`validXCMSymbol: symbolRelayChain=${symbolRelayChain} not found!`)
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions substrate/chains/chainparser.js
Expand Up @@ -1744,6 +1744,7 @@ module.exports = class ChainParser {
paraIDDest = x1.parachain
chainIDDest = paraIDDest + paraIDExtra
}
if (paraIDDest == 0) chainIDDest = relayChainID
let destObj = {
paraIDDest: 0,
chainIDDest: -1,
Expand Down Expand Up @@ -1776,6 +1777,7 @@ module.exports = class ChainParser {
} else {
//if (this.debugLevel >= paraTool.debugErrorOnly) console.log(`processX2 unknown x2_1`, x2)
}
if (paraIDDest == 0) chainIDDest = relayChainID
//let accKey = x2[1]
destAddress = this.processAccountKey(x2[1], decorate, indexer)
}
Expand Down
10 changes: 5 additions & 5 deletions substrate/indexer.js
Expand Up @@ -1160,10 +1160,10 @@ module.exports = class Indexer extends AssetManager {
return (inp.substring(0, maxLen));
}

validXcmSymbol(xcmSymbol, chainID, ctx, o) {
validXcmAssetSymbol(xcmSymbol, chainID, ctx, o) {
if (xcmSymbol == false || (typeof xcmSymbol == "string" && xcmSymbol.includes("0x") && (chainID == paraTool.chainIDKarura || chainID == paraTool.chainIDAcala))) {
let err = `InvalidAsset ${assetKey}`
this.log_indexing_error(err, "validXCMSymbol", {
let err = `validXcmAssetSymbol ${xcmSymbol}`
this.log_indexing_error(err, "validXcmAssetSymbol", {
"ctx": ctx,
"o": o
})
Expand Down Expand Up @@ -1267,7 +1267,7 @@ module.exports = class Indexer extends AssetManager {
let numXCMTransfersOut = {}
for (let i = 0; i < xcmtransferKeys.length; i++) {
let r = this.xcmtransfer[xcmtransferKeys[i]];
if (r.innerCall == undefined && (r.xcmSymbol && !this.validXcmSymbol(r.xcmSymbol, r.chainID, "xcmtransfer", r))) {
if (r.innerCall == undefined && (r.xcmSymbol && !this.validXcmAssetSymbol(r.xcmSymbol, r.chainID, "xcmtransfer", r))) {
console.log(`invalid asset`, r.xcmSymbol, r.chainID, "xcmtransfer", r)
} else {
let innerCall = (r.innerCall) ? `'${r.innerCall}'` : `NULL`
Expand Down Expand Up @@ -5138,7 +5138,7 @@ module.exports = class Indexer extends AssetManager {
//[x.chainIDDest, x.idDest] = this.convertChainID(x.chainIDDest)
x.id = (id == false) ? null : id
x.chainName = this.getChainName(x.chainID);
x.paraIDDest = paraTool.getParaIDfromChainID(x.chainID)
x.paraID = paraTool.getParaIDfromChainID(x.chainID)
let chainIDOriginationInfo = this.chainInfos[x.chainID]
if (chainIDOriginationInfo != undefined && chainIDOriginationInfo.ss58Format != undefined) {
if (x.fromAddress != undefined) {
Expand Down
5 changes: 3 additions & 2 deletions substrate/paraTool.js
Expand Up @@ -689,8 +689,9 @@ function getRelayChainID(relaychain = 'polkadot') {
}

function getChainIDFromParaIDAndRelayChain(paraID, relayChain = 'polkadot') {
let relayChainID = getRelayChainID(relayChain)
let paraIDExtra = getParaIDExtra(relayChain)
//if ((paraID == 0) || (paraID == 2) || (paraID == 60000)) return (paraID)
if (paraID == 0) return relayChainID
return paraIDExtra + paraID
}

Expand Down Expand Up @@ -1968,4 +1969,4 @@ module.exports = {
getXCMTransactList: function(msgHash, msgStr) {
return getXCMTransactList(msgHash, msgStr)
},
};
};
19 changes: 10 additions & 9 deletions views/header.ejs
Expand Up @@ -648,7 +648,7 @@ let chains = [
let baseiconUrl = "/browser_icon.png";
let iconUrl = "/browser_icon.png";
if ( site ) {
baseiconUrl = site.baseiconUrl;
baseiconUrl = site.baseiconUrl;
}
if (req.cookies && req.cookies.selchain) {
selchain = req.cookies.selchain;
Expand All @@ -662,7 +662,7 @@ let chains = [
for (const c of chains ) {
if ( c.id == selchain) {
sel = c;
}
}
}
Expand Down Expand Up @@ -804,11 +804,12 @@ let chains = [
<li>
<a class="dropdown-item" href="/xcmtransfers?xcmType=xcmtransfer">XCM Transfers</a>
</li>
<% if ( sel && sel.isEVM ) { %>
<% if ( sel && sel.isEVM ) { %>
<li>
<a class="dropdown-item" href="/xcmtransfers?xcmType=xcmtransact">XCM Remote Executions</a>
</li>
<% } %>
<li>
<a class="dropdown-item" href="/xcmtransfers?xcmType=xcmtransact">Remote Executions</a>
</li>
<% } %>
<li>
<a class="dropdown-item" href="/xcmmessages">XCM Messages</a>
</li>
Expand All @@ -817,6 +818,9 @@ let chains = [
<a class="dropdown-item" href="/channels">XCM Channels</a>
</li>
<% } %>

<a class="dropdown-item" href="/xcminfows/<%= selid %>">XCM WebSocket</a>
</li>
</ul>
</li>
<li class="nav-item dropdown">
Expand All @@ -834,9 +838,6 @@ let chains = [
<li>
<a class="dropdown-item" href="/remoteexecution">Remote Execution Tool</a>
</li>
<li>
<a class="dropdown-item" href="/xcminfows/<%= selid %>">XCM Info Channel</a>
</li>
<% if ( false ) { %>
<li>
<a class="dropdown-item" href="/ss58">SS58 Converter</a>
Expand Down
15 changes: 7 additions & 8 deletions views/multilocation.ejs
@@ -1,10 +1,10 @@
<%- include('header', {chainInfo: chainInfo, title: `${chain.chainName} Chain`}); %>

<div class="alert" role="alert" data-mdb-color="warning">
This tool is to support XCM Transfers and Remote Executions on Moonbase Alpha/Beta (active) and Moonriver + Moonbeam (planned) only (<a target="_new" href="https://docs.moonbeam.network/builders/xcm/xcm-transactor/">learn more ...</a>)
This page is moving to a stand-alone, open-source repo. (<a target="_new" href="https://github.com/colorfulnotion/xcm-global-registry/">learn more</a>)
</div>

<h5>Multilocation Tool</h5>
<h5>Multilocation Tool / Global Asset Registry</h5>

<div class="btn-group">
<a href="javascript:showmultilocation(0, 'polkadot');" class="btn btn-primary">Polkadot</a>
Expand All @@ -13,11 +13,11 @@ This tool is to support XCM Transfers and Remote Executions on Moonbase Alpha/Be
</div>

<div>
Given a symbol on a network, this shows:
This tool is built around XcmInteriorKey/XCMV1Multilocation:
<ul>
<li>(v1) Multilocation and EVM Multi Location Bytes, which can be used for submitting Substrate extrinsics (e.g. xTokens:Transfer) and EVM Transactions (e.g. interacting with <a href='/address/0x000000000000000000000000000000000000080d'>XCMTransactorV2 System Contract</a></li>
<li>XC20 Contract Addresses on EVM Chains, which behave like ERC20s and can be used to pay for XCM fees (<a href='https://docs.moonbeam.network/builders/xcm/xc20/overview/'> learn more ...</a>)</li>
<li>CurrencyIDs on EVM + Substrate Chains, which are required inputs to XCM Transfer (e.g. <a href='https://docs.moonbeam.network/builders/xcm/xc20/xtokens/'>xTokens:transfer</a>) </li>
<li>Multilocation - A relative identifier that it can only be used to define the relative path between two locations, and cannot generally be used to refer to a location universally (<a target="_new" href="https://wiki.polkadot.network/docs/learn-xcm">learn more ...</a>)</li>
<li>XcmInteriorKey - A flattened XCMV1Multilocation struct with the relative path starting from relayChain. Polkaholic uses xcmInteriorKeys to uniquely identify xcAssets across parachains</li>

</div>

<div>
Expand All @@ -41,7 +41,7 @@ Given a symbol on a network, this shows:
</p>
</div>
</div>

<div class="card">
<div class="card-body">
<h5 class="card-title"><%- include("tooltip", {k: "xc20contractaddress"}) %>XC20 Contract Addresses</h5>
Expand Down Expand Up @@ -71,4 +71,3 @@ $(document).ready(function() {
})
</script>
<%- include('footer', {apiUrl: apiUrl}); %>

1 change: 1 addition & 0 deletions views/tooltip.ejs
Expand Up @@ -146,6 +146,7 @@ let tooltips = {
"executionstatus": "Whether the XCM Message has been successfully processed, or an error",
"receivedatblock": "The block number of the destination chain which received the XCM Message",
"teleportfees": "Fees charged by the destination chain for processing the XCM Message",
"xcmfees": "Fees charged by the destination chain for processing the XCM Message",
"evmtransaction": "Every EVM Transaction has a associated substrate extrinsic, which have two different hashes: there is a substrate extrinsic hash (which may not be unique, because of the possibility of reaped accounts) and a unique transaction hash.",
"selectwalletaccounts": "Connect your substrate and evm accounts by toggling and untoggling them from the dropdown menu",
"relayparentnumber": "The validation data provides information about how to create the inputs for validation of a para block candidate. Such data(i.e. relayChain's BlockNumber) informs collator the context which this parachain block is being built on.",
Expand Down
2 changes: 1 addition & 1 deletion views/xcminfo.ejs
Expand Up @@ -141,7 +141,7 @@
let teleportFeeSymbol = (xcm.destination.teleportFeeSymbol != undefined)? xcm.destination.teleportFeeSymbol : xcm.destination.teleportFeeChainSymbol
%>
<p class="text-muted">
<%- include("tooltip", {k: "teleportfees"}) %><B>Teleport Fees:</B>
<%- include("tooltip", {k: "xcmfees"}) %><B>XCM Fees:</B>
<%- uiTool.presentFloat(xcm.destination.teleportFee, 10) %> <%= teleportFeeSymbol %> (<%- uiTool.currencyFormat(xcm.destination.teleportFeeUSD, xcm.priceUSD, xcm.priceUSDCurrent) %>)
</p>
<% } %>
Expand Down

0 comments on commit bb340f4

Please sign in to comment.