Skip to content

Commit

Permalink
Add rpc node info to coin configuration (#524)
Browse files Browse the repository at this point in the history
* add rpc node info to coins.json and codegen coins.md

* Fix codacy warnings

* refix codacy warnings
  • Loading branch information
hewigovens authored and vikmeup committed Jun 20, 2019
1 parent e0761db commit a718618
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 104 deletions.
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

0 comments on commit a718618

Please sign in to comment.