# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Ales Katona <almindor@gmail.com>

pkgname=etherwall
pkgver=2.3.2
_ewnodecommit=7d8ed7de3dcb6d2be63745e755bd492e30bd4111
_trezorcommit=8ea2d044785b2285c4390b3afddb08e8d093cc8e
pkgrel=1
pkgdesc="Ethereum GUI Wallet (QT5)"
arch=('x86_64')
url="http://etherwall.com"
license=('GPL3')
depends=('qt5-declarative' 'qt5-graphicaleffects' 'qt5-quickcontrols' 'qt5-websockets' 'geth' 'protobuf' 'hidapi' 'systemd-libs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/almindor/${pkgname}/archive/v$pkgver.tar.gz"
        "ew-node-$_ewnodecommit.tar.gz::https://github.com/almindor/ew-node/archive/$_ewnodecommit.tar.gz"
        "trezor-common-$_trezorcommit.tar.gz::https://github.com/trezor/trezor-common/archive/$_trezorcommit.tar.gz"
        etherwall.desktop)
sha512sums=('d18a17f8d6d72adc9d2bc39d3602c1c71c696e2f065c3a8b3b502232582dba190f36dcce74626301c9779398fbaa4ddd4887e02e2ae7637b9a63c245191c52fd'
            '1ced81663bb742e7a9378eff60f12865ecc2bed7b2657511723eefa0bcb4aa7a461f6de94d117581f5a19a4d1816757519981914d828f5b2f1b757406816df97'
            '862b3e678751bbd26380c085036f1526aa576fc75473e06a43c6476085168cb46a904bab716fe905d6970c923b0ae0081365cec0f7df01a3b91f948947fd6594'
            '82ecee1f1d7a6fe7014b928e3ab79ed507c3c5795ac3e832e0be1aca8fc5659212c5a4323d5dec4571b9e9255c5c46615bd9865dc03eba85d8be9b969b534d57')

build() {
  cd "etherwall-$pkgver"
  rmdir "src/ew-node"
  ln -s "../../ew-node-$_ewnodecommit" "src/ew-node"

  SRCDIR="../trezor-common-$_trezorcommit/protob" ./generate_protobuf.sh
  qmake -config release && make
}

package() {
  mkdir -p "$pkgdir/usr/bin"
  mkdir -p "$pkgdir/usr/share/pixmaps"
  mkdir -p "$pkgdir/usr/share/applications"

  cd "etherwall-$pkgver"
  cp "$srcdir"/etherwall.desktop "$pkgdir"/usr/share/applications
  cp "./Etherwall" "$pkgdir"/usr/bin/etherwall
  cp "./qml/images/icon.png" "$pkgdir"/usr/share/pixmaps/etherwall.png
}
