forked from trustwallet/assets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[internal] Wanchain uses special reverse checksum format (trustwallet…
…#3216) * ReverseCase * Wanchain uses special reverse checksum format. * Fix existing 6 wanchain assets, revert checksum format. Co-authored-by: Catenocrypt <[email protected]>
- Loading branch information
Showing
12 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[ | ||
"0x0F2E7c0e904A525a24ff6F658053F6Ba5cE7a209", | ||
"0x350BB91c9c8eF4E8c0E19FBDC6a90a24BCB1Ec2a", | ||
"0x3beb80170272F07Aca12987af86a59888255a807", | ||
"0x51316966907EF568689775066E97C46A4fFDE1A4", | ||
"0xa13A41A2349d09c1e3A0Dd4D9448aF4Ad799Fc4a", | ||
"0xC6F4465A6a521124C8e3096B62575c157999D361" | ||
"0x0f2e7C0E904a525A24FF6f658053f6bA5Ce7A209", | ||
"0x350bb91C9C8Ef4e8C0e19fbdc6A90A24bcb1eC2A", | ||
"0x3BEB80170272f07aCA12987AF86A59888255A807", | ||
"0x51316966907ef568689775066e97c46a4Ffde1a4", | ||
"0xA13a41a2349D09C1E3a0dD4d9448Af4aD799fC4A", | ||
"0xc6f4465a6A521124c8E3096b62575C157999d361" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
import { reverseCase } from "./types"; | ||
|
||
const Web3 = require('web3'); | ||
|
||
const web3 = new Web3('ws://localhost:8546'); | ||
|
||
export const isChecksum = (address: string): boolean => web3.utils.checkAddressChecksum(address); | ||
export const toChecksum = (address: string): string => web3.utils.toChecksumAddress(address); | ||
export const isChecksumEthereum = (address: string): boolean => web3.utils.checkAddressChecksum(address); | ||
export const toChecksumEthereum = (address: string): string => web3.utils.toChecksumAddress(address); | ||
|
||
export function toChecksum(address: string, chain: string = "ethereum"): string { | ||
var checksumEthereum = toChecksumEthereum(address); | ||
|
||
// special handling for Wanchain | ||
if (chain.toLowerCase() === "wanchain") { | ||
const checksumWanchain = reverseCase(checksumEthereum).replace("X", "x"); | ||
return checksumWanchain; | ||
} | ||
|
||
return checksumEthereum; | ||
} | ||
|
||
export function isChecksum(address: string, chain: string = "ethereum"): boolean { | ||
// special handling for Wanchain | ||
if (chain.toLowerCase() === "wanchain") { | ||
const addressEthereum = reverseCase(address).replace("X", "x"); | ||
return isChecksumEthereum(addressEthereum); | ||
} | ||
|
||
return isChecksumEthereum(address); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters