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

pkgname=etherwall
pkgver=3.0.3
_ewnodecommit=6cbe77d6bc7568e4c49f04401e3d4ea68136d7e9
_trezorcommit=db106e8f2766155bc72802e4dc3f9f59c90d9c3e
pkgrel=1
pkgdesc="Ethereum GUI Wallet (QT5)"
arch=('x86_64')
url="https://etherwall.com"
license=('GPL3')
depends=('qt5-declarative' 'qt5-graphicaleffects' 'qt5-quickcontrols' 'qt5-quickcontrols2' 'qt5-websockets' 'geth' 'protobuf' 'libhidapi-libusb.so' 'libusb' 'systemd-libs')
makedepends=('hidapi')
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=('1d13eac2882dbbab952ec61a071918012e6645e597dd44c3cfd4cce92891c9f14145b9ca944b9c7a43e0b878cad4addc9defcef4e099c47b0d1557f6e65bfa48'
            '4d8728c92ab42d6beaef1bebe72586ddb71df8f0479f5ca64e538a7716d2ebe30bdbddbbc4169050278e508d67df0296ce4f81be67c2be719d4ae849f87ad23c'
            '745044fe0686c4f2843a67440e3be8501d8c1d5b8b7275fad7310cfd1110d5cc00378ba4205bed6f5926636a65aa986448594fc6fe276b9f46c902c642ad0373'
            '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
}
