Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rpc node info to coin configuration #524

Merged
merged 3 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions codegen/bin/coins
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ def self.format_name(n)
formatted
end

def self.coin_type(path)
path.split('/')[2].chomp("'")
end

def self.coin_img(coin)
"<img src=\"https://raw.githubusercontent.com/TrustWallet/tokens/master/coins/#{coin}.png\" width=\"32\" />"
end

json_string = File.read('coins.json')
coins = JSON.parse(json_string).sort_by { |x| x['name'] }
coins_md = coins.sort_by { |x| Integer(coin_type(x['derivationPath'])) }

erbs = [
{'template' => 'coins.cpp.erb', 'folder' => 'src/Generated', 'file' => 'Coins.cpp'},
{'template' => 'coins.md.erb', 'folder' => 'docs', 'file' => 'coins.md'},
{'template' => 'hrp.cpp.erb', 'folder' => 'src/Generated', 'file' => 'TWHRP.cpp'},
{'template' => 'hrp.h.erb', 'folder' => 'include/TrustWalletCore', 'file' => 'TWHRP.h'}
]
Expand Down
9 changes: 9 additions & 0 deletions codegen/lib/templates/coins.md.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Full list

This list is generated from `src/coins.json`

| Index | Name | Symbol | Logo | URL |
| ------- | ------------- | ------ | ------------------------------------------------------------------------------------------------------ | ------------------------------ |
<% coins_md.each do |coin| -%>
| <%= coin_type(coin['derivationPath']).ljust(7, " ") %> | <%= coin['name'].ljust(16, " ") %> | <%= coin['symbol'].ljust(6, " ") %> | <%= coin_img(coin_type(coin['derivationPath'])).ljust(102) %> | <%= "<#{coin['url']}>".ljust(30, " ") %>> |
<% end -%>
Loading