From 976964f39e61b1901be3ca80948269adc35de76b Mon Sep 17 00:00:00 2001 From: TranTrungTien <71311738+TranTrungTien@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:02:05 +0700 Subject: [PATCH] [fix][655] fix event log (#3609) * [fix][598] fix set token info * feat: Decode event log * [Feat][655] enhance event log * Apply decode ui * update: data decoded * remove config.json change * fix: enhance event log * merged commit * update: event log * --amend * fix: event log * fix: event log --------- Co-authored-by: tambui --- .../decode-message.component.html | 54 +++- .../decode-message.component.ts | 1 - .../evm-message/evm-message.component.ts | 117 +++++---- .../evm-transaction-event-log.component.html | 2 +- .../evm-transaction-event-log.component.ts | 1 + src/assets/config/config.json | 247 +++++++++--------- 6 files changed, 252 insertions(+), 170 deletions(-) diff --git a/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.html b/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.html index 54f52d51d..393182fbe 100644 --- a/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.html +++ b/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.html @@ -23,15 +23,61 @@ -
+

{{value}}

-
- +
+ {{data}} - {{data}} + {{data}} +
+
+
+
+
+
+

{{ data }}

+
+
+
+ +

{{item?.name}}

+ + {{item?.decode}} + +
+
+
+ + {{dataDecoded?.name}} + +

{{dataDecoded?.name}}

+
+
+
+

{{item?.decode}}

+
+
+
+
+
+
+
+ + +
diff --git a/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.ts b/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.ts index 515ed5554..3a2e6b36e 100644 --- a/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.ts +++ b/src/app/pages/transaction/evm-transaction/decode-message/decode-message.component.ts @@ -32,7 +32,6 @@ export class DecodeMessageComponent implements OnInit { this.data = this.decode; return; } - this.data = Array.isArray(this.decode) && this.decode?.map(item => { if(item?.type !== 'tuple') { return { diff --git a/src/app/pages/transaction/evm-transaction/evm-message/evm-message.component.ts b/src/app/pages/transaction/evm-transaction/evm-message/evm-message.component.ts index 15d99a951..8ee0578ba 100644 --- a/src/app/pages/transaction/evm-transaction/evm-message/evm-message.component.ts +++ b/src/app/pages/transaction/evm-transaction/evm-message/evm-message.component.ts @@ -136,6 +136,24 @@ export class EvmMessageComponent { }); } + mappingTopics(element){ + element['isAllowSwitchDecodeDataField'] = false; + return element?.topics?.map((i, tidx) => ({ + index: tidx, + decode: '', + value: i, + isAllowSwitchDecode: false, + })); + } + + mappingFunctionName(item){ + const {type, indexed, name} = item; + let param = type; + if (!indexed) param = `${type} ${name}` + else param = `${type} indexed ${name}` + return param; + } + getListTopicDecode() { this.transaction.eventLog.forEach((element, index) => { @@ -143,61 +161,68 @@ export class EvmMessageComponent { try { const abiInfo = this.abiContractData.find((f) => f.contractAddress === element.address); let decoded = []; + element.data = element?.data?.replace('\\x', ''); + element['isAllowSwitchDecodeDataField'] = true; + if (!abiInfo?.abi) { - decoded = element.topics.map((i, tidx) => ({ - index: tidx, - decode: '', - value: i, - isAllowSwitchDecode: false, - })); + decoded = this.mappingTopics(element) } else { - element.data = element?.data?.replace('\\x', ''); const paramsDecode = abiInfo.interfaceCoder.parseLog({ topics: element.topics?.filter((f) => f), data: `0x${element.data || this.transaction?.inputData}`, }); - const params = paramsDecode?.fragment?.inputs.map((i) => `${i.type} ${i.indexed ? 'indexed' : ''} ${i.name}`); - const decodeTopic0 = `> ${paramsDecode?.fragment?.name}(${params.join(', ')})`; - - decoded = [ - { - index: 0, - decode: decodeTopic0, - value: element.topics[0], - }, - ]; - - const inputs = paramsDecode?.fragment?.inputs - if (inputs?.length > 0) { - const params = []; - const data = []; - let currentParamIndex = 0; + if(!paramsDecode) decoded = this.mappingTopics(element) + else { + const params = paramsDecode?.fragment?.inputs.map(this.mappingFunctionName); + const decodeTopic0 = `> ${paramsDecode?.fragment?.name}(${params.join(', ')})`; + + decoded = [ + { + index: 0, + decode: decodeTopic0, + value: element.topics[0], + }, + ]; - inputs?.forEach((item, idx) => { - const param = { - indexed: item?.indexed, - name: item.name, - type: item.type, - isLink: item.type === 'address', - decode: paramsDecode.args[idx]?.toString(), - } - if(item?.indexed) { - param["indexed"] = item.indexed; - param["index"] = idx + 1; - param["isAllowSwitchDecode"] = true; - param["value"] = element.topics[currentParamIndex + 1], - currentParamIndex += 1; - params.push(param); - }else { - data.push(param); - } - }); - - element.dataDecoded = data; - decoded = [...decoded, ...params]; - } + const inputs = paramsDecode?.fragment?.inputs + if (inputs?.length > 0) { + const params = []; + const data = []; + let currentParamIndex = 0; + + inputs?.forEach((item, idx) => { + if(item?.type === "tuple") { + const tupleType = `(${item?.components?.map(this.mappingFunctionName)?.join(', ')}) ${item?.name}`; + const replaceTuple = new RegExp(`\\b${item?.type} ${item?.name}\\b`, 'g'); + decoded[0].decode = decoded[0]?.decode?.replace(replaceTuple, tupleType); + } + + const param = { + indexed: item?.indexed, + name: item.name, + type: item.type, + isLink: item.type === 'address', + decode: paramsDecode.args[idx]?.toString(), + } + if(item?.indexed) { + param["indexed"] = item.indexed; + param["index"] = currentParamIndex + 1; + param["isAllowSwitchDecode"] = true; + param["value"] = element.topics[currentParamIndex + 1], + currentParamIndex += 1; + params.push(param); + }else { + data.push(param); + } + }); + + element.dataDecoded = data; + decoded = [...decoded, ...params]; + }} } + console.log(decoded); + this.topicsDecoded[index] = decoded; } catch (e) {} this.arrTopicDecode[index] = arrTopicTemp; diff --git a/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.html b/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.html index 20fd055fc..d7ec71deb 100644 --- a/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.html +++ b/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.html @@ -44,7 +44,7 @@ [isDataField]="true" [value]="eventLog.data" [decode]="eventLog.dataDecoded" - [isAllowSwitchDecode]="true" + [isAllowSwitchDecode]="eventLog.isAllowSwitchDecodeDataField" [isHighlight]="true">
diff --git a/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.ts b/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.ts index 9f017394c..b5f08a53e 100644 --- a/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.ts +++ b/src/app/pages/transaction/evm-transaction/evm-transaction-event-log/evm-transaction-event-log.component.ts @@ -19,6 +19,7 @@ export class EvmTransactionEventLogComponent { }[]; data: string; dataDecoded?: string; + isAllowSwitchDecodeDataField ?:boolean }; @Input() index; } diff --git a/src/assets/config/config.json b/src/assets/config/config.json index 897e18c97..c8bc55046 100644 --- a/src/assets/config/config.json +++ b/src/assets/config/config.json @@ -1,147 +1,158 @@ { - "environment": { - "name": "develop", + "environment": { + "name": "serenity", "label": { - "desktop": "Develop Testnet Network", - "mobile": "Develop Testnet" + "desktop": "Serenity Testnet (v0.8.0)", + "mobile": "Serenity Testnet" }, "logo": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/dev-assets/token/download.png", "notice": { - "content": null, - "url": null + "content": null, + "url": null }, "nativeName": "Aura" - }, - "chainConfig": { + }, + "chainConfig": { "stakingTime": "86400", - "excludedAddresses": ["aura1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3wd7dmw"], - "blockTime": 5000, - "quotaSetPrivateName": 10, - "quotaSetWatchList": 10, + "excludedAddresses": [ + "aura1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3wd7dmw", + "aura1z9whsygd9hdquamn84vs76uy8ytatnw28aff3m", + "aura1752fawv92g2c9eegqedj5689gevgscsc0y7stk" + ], + "blockTime": 2000, + "quotaSetPrivateName": 20, + "quotaSetWatchList": 20, "quotaNotification": 100, "features": [], "chain_info": { - "chainId": "auradev_1235-3", - "chainName": "aura devnet", - "rpc": "https://rpc.dev.aura.network", - "rest": "https://lcd.dev.aura.network", - "bip44": { - "coinType": 118 - }, - "bech32Config": { - "bech32PrefixAccAddr": "aura", - "bech32PrefixAccPub": "aurapub", - "bech32PrefixValAddr": "auravaloper", - "bech32PrefixValPub": "auravaloperpub", - "bech32PrefixConsAddr": "auravalcons", - "bech32PrefixConsPub": "auravalconspub" - }, - "currencies": [ - { - "coinDenom": "TAURA", - "coinMinimalDenom": "utaura", - "coinDecimals": 6 - } - ], - "feeCurrencies": [ - { - "coinDenom": "TAURA", - "coinMinimalDenom": "utaura", - "coinDecimals": 6 - } - ], - "stakeCurrency": { - "coinDenom": "TAURA", - "coinMinimalDenom": "utaura", - "coinDecimals": 6 - }, - "coinType": 118, - "gasPriceStep": { - "low": 0.001, - "average": 0.0025, - "high": 0.004 - }, - "features": ["ibc-transfer"], - "walletUrlForStaking": "https://explorer.dev.aura.network/validators", - "logo": "https://i.imgur.com/zi0mTYb.png", - "explorer": "https://explorer.dev.aura.network/", - "beta": "false" + "chainId": "auradev_1236-2", + "chainName": "Aura serenity testnet", + "rpc": "https://rpc.serenity.aura.network", + "rest": "https://lcd.serenity.aura.network", + "bip44": { + "coinType": 118 + }, + "bech32Config": { + "bech32PrefixAccAddr": "aura", + "bech32PrefixAccPub": "aurapub", + "bech32PrefixValAddr": "auravaloper", + "bech32PrefixValPub": "auravaloperpub", + "bech32PrefixConsAddr": "auravalcons", + "bech32PrefixConsPub": "auravalconspub" + }, + "currencies": [ + { + "coinDenom": "AURA", + "coinMinimalDenom": "uaura", + "coinDecimals": 6 + } + ], + "feeCurrencies": [ + { + "coinDenom": "AURA", + "coinMinimalDenom": "uaura", + "coinDecimals": 6 + } + ], + "stakeCurrency": { + "coinDenom": "AURA", + "coinMinimalDenom": "uaura", + "coinDecimals": 6 + }, + "coinType": 118, + "gasPriceStep": { + "low": 0.001, + "average": 0.0025, + "high": 0.004 + }, + "features": [ + "ibc-transfer" + ], + "walletUrlForStaking": "https://serenity.aurascan.io/validators", + "logo": "https://i.imgur.com/zi0mTYb.png", + "explorer": "https://serenity.aurascan.io/", + "beta": "false" }, "evmChainInfo": { - "name": "Aura EVM Devnet", - "chain": "Aura-Dev", - "rpc": "https://jsonrpc.dev.aura.network", - "faucets": [""], - "nativeCurrency": { - "name": "test-Aura", - "symbol": "tAURA", - "denom": "atAURA", - "decimals": 18 - }, - "infoURL": "https://aura.network", - "shortName": "aura-devnet", - "chainId": 1235, - "networkId": 1235, - "slip44": 1, - "icon": "", - "stakeContract": "0x0000000000000000000000000000000000000800", - "claimContract": "0x0000000000000000000000000000000000000801", - "explorers": [ - { - "name": "Aura Explorer (Aurascan)", - "url": "https://explorer.dev.aura.network", - "standard": "none", - "icon": "" - } - ] + "name": "Aura EVM Serenity", + "chain": "Aura-Serenity", + "rpc": "https://jsonrpc.serenity.aura.network", + "faucets": [ + "" + ], + "nativeCurrency": { + "name": "test-Aura", + "symbol": "AURA", + "denom": "aAURA", + "decimals": 18 + }, + "infoURL": "https://aura.network", + "shortName": "aura-serenity", + "chainId": 1236, + "networkId": 1236, + "slip44": 1, + "icon": "", + "stakeContract": "0x0000000000000000000000000000000000000800", + "claimContract": "0x0000000000000000000000000000000000000801", + "explorers": [ + { + "name": "Aura Explorer (Aurascan)", + "url": "https://serenity.aurascan.io", + "standard": "none", + "icon": "" + } + ] } - }, - "etherJsonRpc": "https://jsonrpc.dev.aura.network", - "image": { + }, + "image": { "validator": "https://validator-logos.s3.ap-southeast-1.amazonaws.com", - "assets": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/dev-assets/", + "assets": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/serenity-assets/", "banner": [ - { - "src": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/dev-assets/images/pages/banner_aurascan.png", - "url": "https://beta.seekhype.io/" - }, - { - "src": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/dev-assets/images/pages/banner_aurascan-2.png", - "url": "https://beta.seekhype.io/" - } + { + "src": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/serenity-assets/images/pages/banner_aurascan-2.png", + "url": "https://beta.seekhype.io/" + }, + { + "src": "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/serenity-assets/images/pages/banner_aurascan-2.png", + "url": "https://beta.seekhype.io/" + } ] - }, - "api": { - "backend": "https://explorer-api.dev.aura.network/api/v1", - "socket": "https://explorer-api.dev.aura.network", + }, + "api": { + "backend": "https://serenity-api.aurascan.io/api/v1", + "socket": "https://serenity-api.aurascan.io", "ipfsDomain": "https://ipfs.io/", "verifyContract": "https://indexer-v2.dev.aurascan.io/verify-contract/v1", "coingecko": { - "url": "https://api.coingecko.com/api/v3", - "ids": ["aura-network"] + "url": "https://api.coingecko.com/api/v3", + "ids": [ + "aura-network" + ] }, "google": { - "url": "apps.googleusercontent.com", - "clientId": "3465782004-hp7u6vlitgs109rl0emrsf1oc7bjvu08", - "siteKeyCaptcha": "6Lf3_rYoAAAAAAERC5hKPYug-DSJ37t55O8O_1yc" + "url": "apps.googleusercontent.com", + "clientId": "3465782004-hp7u6vlitgs109rl0emrsf1oc7bjvu08", + "siteKeyCaptcha": "6Lf3_rYoAAAAAAERC5hKPYug-DSJ37t55O8O_1yc" }, "horoscope": { - "url": "https://indexer-v2.dev.aurascan.io/api", - "graphql": "/v2/graphql", - "rest": "/v2", - "chain": "auratestnet" + "url": "https://indexer-v2.dev.aurascan.io/api", + "graphql": "/v2/graphql", + "rest": "/v2", + "chain": "serenity" }, "walletConnect": { - "signClient": { - "projectId": "ae69ca1df362a7183412731fb570a54b", - "relayUrl": "wss://relay.walletconnect.org", - "metadata": { - "name": "Aurascan", - "description": "Aura Network Explorer", - "url": "https://explorer.dev.aurascan.io/", - "icons": ["https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/dev-assets/token/download.png"] + "signClient": { + "projectId": "ae69ca1df362a7183412731fb570a54b", + "relayUrl": "wss://relay.walletconnect.org", + "metadata": { + "name": "Aurascan", + "description": "Aura Network Explorer", + "url": "https://serenity.aurascan.io/", + "icons": [ + "https://aura-explorer-assets.s3.ap-southeast-1.amazonaws.com/dev-assets/token/download.png" + ] + } } - } } - } } +} \ No newline at end of file