Skip to content

Commit b297b08

Browse files
authored
Readme update (trustwallet#945)
* Add resources * Update readme * Add test to check root dir for images Fixes trustwallet#642
1 parent 6acdbf1 commit b297b08

File tree

4 files changed

+45
-15
lines changed

4 files changed

+45
-15
lines changed

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1+
# Trust Wallet Token Images
2+
This repository (repo) provides token images for Trust Wallet mobile clients iOS and Android
3+
<center><img src='https://raw.githubusercontent.com/TrustWallet/tokens/master/tutorial/trust-wallet.png'></center>
4+
15
Directory of token images for ERC20 contracts
26

37
# Add custom image:
48
## Requirements
5-
- name of the file in lowercase: `contract_address.png`. Ex: `0xd26114cd6ee289accf82350c8d8487fedb8a0c07.png`
6-
- format: `PNG`
7-
- size: `256px by 256px`
8-
9-
## Steps
10-
1) Press on `Fork` in the top right corner.
11-
2) Upload an image in `images/` folder on your own fork and commit changes.
12-
3) Press on `New Pull Request` on your own fork page and submit it!
9+
- format: `png`
10+
- name of the file in lowercase fromat: `contract_address.png`. Ex: `0xd26114cd6ee289accf82350c8d8487fedb8a0c07.png`
11+
- size: minimum `256px by 256px`
12+
- background: preferably transparant
13+
14+
## How To Add
15+
1) Press on `Fork` in the top right corner, wait for process to complite
16+
2) Navigate to `tokens` folder on your own fork.
17+
3) Press on `Upload File` in the top right corner.
18+
4) Choose file, make sure it follows requirments above
19+
5) Press on `Commitchanges`
20+
6) Press on `New pull request` on your own fork page and submit it by pressing on `Create pull request`!
21+
7) Add short description including name and token symbol in a header field
22+
8) Press on `Create pull request`
23+
9) Once tests complited and verifies your image follows requirments maintainer will merge it and in 5-10 minutes token became searchable in Trust Wallet
1324

1425
### Youtube: Upload ERC20 Token Image to Trust Wallet:
1526

16-
[![Upload ERC20 Token Image to Trust Wallet
17-
](https://img.youtube.com/vi/EFrJT_b11m4/0.jpg)](https://www.youtube.com/watch?v=EFrJT_b11m4)
27+
<center>
28+
<video alignwidth="720" height="480" controls>
29+
<source src="./tutorial/upload-token-image.mov" type="video/mp4">
30+
</video>
31+
</center>
32+
33+
[![Upload ERC20 Token Image to Trust Wallet]
34+
(https://img.youtube.com/vi/EFrJT_b11m4/0.jpg)](https://www.youtube.com/watch?v=EFrJT_b11m4)
1835

1936

2037
## How to Use It? (For Developers)

test/index.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('fs')
22

3-
const imgExp = /\.png$/
3+
const pngExp = /\.png$/
44
const upperCaseExp = /[A-F]/
55
const OxExp = /^0x/
66
const addressExp = /[0-9a-f]{40}$/i
@@ -11,15 +11,15 @@ const exitWithMsg = (msg) => {
1111
}
1212

1313
const isAddress = address => addressExp.test(address)
14-
15-
const remoteExtension = string => string.replace(/.png/g, '')
14+
const isFilePng = name => pngExp.test(name)
15+
const remotePngExtension = string => string.replace(/.png/g, '')
1616

1717
const imageFileNames = fs.readdirSync('./tokens')
1818

1919
imageFileNames.forEach(image => {
20-
const address = remoteExtension(image)
20+
const address = remotePngExtension(image)
2121

22-
if (!imgExp.test(image)) {
22+
if (!isFilePng(image)) {
2323
exitWithMsg(`${image} image must be png`)
2424
}
2525

@@ -36,4 +36,17 @@ imageFileNames.forEach(image => {
3636
}
3737
})
3838

39+
// Checking root directory for not containing images
40+
const checkRootDirectory = () => {
41+
fs.readdirSync(".").forEach(file => {
42+
if(isFilePng(file)) {
43+
exitWithMsg(`Move ${file} to ./tokens folder`)
44+
}
45+
46+
})
47+
}
48+
checkRootDirectory()
49+
50+
51+
3952
console.log(`Passed all tests`)

tutorial/trust-wallet.png

75.5 KB
Loading

tutorial/upload-token-image.mov

27.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)