Skip to content

Commit

Permalink
update: convert hex to string (#3618)
Browse files Browse the repository at this point in the history
  • Loading branch information
TranTrungTien authored Jul 10, 2024
1 parent c8506aa commit aaf1e75
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/app/core/utils/ethers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ export async function addNetwork(chain) {
}
}

export const hex2a = (hex: string) => {
if(!hex && typeof hex != 'string') return "";
const data = hex.toString();
let str = '';
for (let i = 0; i < data.length; i += 2)
str += String.fromCharCode(parseInt(data.substr(i, 2), 16));
return str;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</ng-container>
</div>

<div class="log-data body-02 break-word box-decoded overflow-auto" *ngIf="typeInput === inputDataType.DECODED">
<div class="log-data body-02 break-word box-decoded" *ngIf="typeInput === inputDataType.DECODED">
<ng-container *ngIf="isEvmContract">
<ng-container *ngIf="!env.isMobile">
<div class="row pb-3 text--gray-4 body-01 fw-semibold decoded-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CommonService } from 'src/app/core/services/common.service';
import { ContractService } from 'src/app/core/services/contract.service';
import { TransactionService } from 'src/app/core/services/transaction.service';
import { getBalance } from 'src/app/core/utils/common/parsing';
import { hex2a } from 'src/app/core/utils/ethers/utils';

@Component({
selector: 'app-evm-transaction',
Expand Down Expand Up @@ -131,7 +132,7 @@ export class EvmTransactionComponent implements OnChanges {
next: (res) => {
if (res?.evm_smart_contract?.length > 0)
this.isEvmContract = true;
else this.transaction.memo = this.transaction.inputData as any;
else this.transaction.memo = hex2a(this.transaction.inputData as any);
},
});
}
Expand Down

0 comments on commit aaf1e75

Please sign in to comment.