-
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.
1 parent
f6cf781
commit 6ab7d52
Showing
3 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ChainId, ChainType } from '@portkey/provider-types'; | ||
|
||
/** | ||
* format address like "aaa...bbb" to "ELF_aaa...bbb_AELF" | ||
* @param address | ||
* @param chainId | ||
* @param chainType | ||
* @returns | ||
*/ | ||
export const addressFormat = ( | ||
address: string = 'address', | ||
chainId: ChainId = 'AELF', | ||
chainType: ChainType = 'aelf', | ||
): string => { | ||
if (chainType !== 'aelf') return address; | ||
const arr = address.split('_'); | ||
if (address.includes('_') && arr.length < 3) return address; | ||
if (address.includes('_')) return `ELF_${arr[1]}_${chainId}`; | ||
return `ELF_${address}_${chainId}`; | ||
}; |
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