Skip to content

Commit

Permalink
Merge branch 'main' into fix/node-type-style-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja7ad authored Aug 4, 2024
2 parents 0d272ea + 36bfcce commit 133ac90
Show file tree
Hide file tree
Showing 153 changed files with 1,525 additions and 1,263 deletions.
2 changes: 1 addition & 1 deletion .github/releasers/macos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
</dict>
</plist>
</plist>
44 changes: 44 additions & 0 deletions .github/releasers/macos/gtk3-launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

if test "x$GTK_DEBUG_LAUNCHER" != x; then
set -x
fi

if test "x$GTK_DEBUG_GDB" != x; then
EXEC="gdb --args"
else
EXEC=exec
fi

name=`basename "$0"`
tmp="$0"
tmp=`dirname "$tmp"`
tmp=`dirname "$tmp"`
bundle=`dirname "$tmp"`
bundle_contents="$bundle"/Contents
bundle_res="$bundle_contents"/Resources
bundle_lib="$bundle_res"/lib
bundle_bin="$bundle_res"/bin
bundle_data="$bundle_res"/share
bundle_etc="$bundle_res"/etc

export DYLD_FALLBACK_LIBRARY_PATH="$bundle_lib"
export XDG_CONFIG_DIRS="$bundle_etc"/xdg
export XDG_DATA_DIRS="$bundle_data"
export GTK_DATA_PREFIX="$bundle_res"
export GTK_EXE_PREFIX="$bundle_res"
export GTK_PATH="$bundle_res"

export GDK_PIXBUF_MODULE_FILE="$bundle_lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
if [ `uname -r | cut -d . -f 1` -ge 10 ]; then
export GTK_IM_MODULE_FILE="$bundle_lib/gtk-3.0/3.0.0/immodules.cache"
fi

APP=$name

# Strip out the argument added by the OS.
if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
shift 1
fi

$EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS
106 changes: 102 additions & 4 deletions .github/releasers/macos/gui.bundle
Original file line number Diff line number Diff line change
@@ -1,16 +1,114 @@
<?xml version="1.0" standalone="no"?>
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<app-bundle>

<meta>
<prefix name="default">${env:PREFIX}</prefix>
<!-- Where to pick up the GTK+ installation, icon themes,
etc. Note that "${env:JHBUILD_PREFIX}" is evaluated to the
value of the environment variable JHBUILD_PREFIX. You can
define additional prefixes and refer to them in paths
throughout this file on the form "${prefix:name}". This is
useful for installing certain libraries or even the
application itself separately. Note that JHBUILD_PREFIX is
defined by jhbuild, so it you are not using jhbuild you can
either define your own or just hardcode the path here.
-->
<prefix name="default">${env:LIB_HOME}</prefix>

<prefix name="bundle">${env:GUI_BUNDLE}</prefix>
<!-- The project directory is the default location of the created
app. If you leave out the path, the current directory is
used. Note the usage of an environment variable here again.
-->
<destination overwrite="yes">${env:ROOT_DIR}</destination>

<image>
<!-- Not implemented yet (DMG image). -->
</image>

<!-- Comment this out to keep the install names in binaries -->
<run-install-name-tool/>

<!-- Optionally specify a launcher script to use. If the
application sets up everything needed itself, like
environment variable, linker paths, etc, a launcher script is
not needed. If the source path is left out, the default
script will be used.
-->
<launcher-script>${project}/gtk3-launcher.sh</launcher-script >

<!-- Not implemented: Optional runtime, could be python or mono
for example.
-->
<!-- runtime copy="yes">/usr/bin/python</runtime -->
<!-- Indicate the active gtk version to use. This is needed only
for gtk+-3.0 projects. -->
<gtk>gtk+-3.0</gtk>
</meta>
<plist>${prefix:bundle}/Info.plist</plist>

<!-- The special macro "${project}" refers to the directory where
this bundle file is located. The application name and bundle
identifier are taken from the plist file.
-->
<plist>${project}/Info.plist</plist>

<main-binary>${prefix:bundle}/pactus-gui</main-binary>

<!-- Copy in the input methods. Dunno if they actually work with
OSX. Note the ${gtkdir} macro, which expands to the correct
library subdirectory for the specified gtk version. -->
<binary>
${prefix}/lib/${gtkdir}/${pkg:${gtk}:gtk_binary_version}/immodules/*.so
</binary>

<!-- And the print backends -->
<!-- <binary>
${prefix}/lib/${gtkdir}/${pkg:${gtk}:gtk_binary_version}/printbackends/*.so
</binary> -->

<!-- Starting with 2.24, gdk-pixbuf installs into its own directory. -->
<binary>
${prefix}/lib/gdk-pixbuf-2.0/${pkg:gdk-pixbuf-2.0:gdk_pixbuf_binary_version}/loaders/*.so
</binary>

</app-bundle>
<binary>
${prefix}/lib/gio/modules/libgiognutls.so
</binary>

<!-- Translation filenames, one for each program or library that you
want to copy in to the bundle. The "dest" attribute is
optional, as usual. Bundler will find all translations of that
library/program under the indicated directory and copy them.-->
<!-- <translations name="gtk30">
${prefix}/share/locale
</translations> -->


<!-- Data to copy in, usually Glade/UI files, images, sounds files
etc. The destination inside the bundle can be specified if the
files should end up at a different location, by using the
"dest" property. The destination must then start with the macro
"${bundle}", which refers to the bundle root directory.
-->
<!-- data>
${prefix}/share/gtk3-demo
</data -->

<!-- Copy in the themes data. You may want to trim this to save space
in your bundle. -->
<data>
${prefix}/share/themes
</data>

<data>
${prefix}/share/icons
</data>

<!-- Copy icons. Note that the .icns file is an Apple format which
contains up to 4 sizes of icon. You can use
/Developer/Applications/Utilities/Icon Composer.app to import
artwork and create the file. -->
<data dest="${bundle}/Contents/Resources">
${prefix:bundle}/pactus.icns
</data>

</app-bundle>
38 changes: 38 additions & 0 deletions .github/releasers/macos/run-install-name-tool-change.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

if [ $# -lt 3 ]; then
echo "Usage: $0 library old_prefix new_prefix action"
exit 1
fi

LIBRARY=$1
WRONG_PREFIX=$2
RIGHT_PREFIX="@executable_path/../$3"
ACTION=$4

chmod u+w $LIBRARY

if [ "x$ACTION" = "xchange" ]; then
libs="`otool -L $LIBRARY 2>/dev/null | fgrep compatibility | cut -d\( -f1 | grep $WRONG_PREFIX | sort | uniq`"
for lib in $libs; do
if ! echo $lib | grep --silent "@executable_path" ; then
if echo $lib | grep --silent "${LIB_HOME}/Cellar/"; then
fixed=`echo $lib | sed -e "s|${LIB_HOME}/Cellar/\([^/]*\)/[^/]*/|@executable_path/../Resources/opt/\1/|"`
else
fixed=`echo $lib | sed -e s,\${WRONG_PREFIX},\${RIGHT_PREFIX},`
fi
echo $lib $fixed $LIBRARY
install_name_tool -change $lib $fixed $LIBRARY
fi
done;
elif [ "x$ACTION" = "xid" ]; then
# echo "$LIBRARY $WRONG_PREFIX to $RIGHT_PREFIX"
lib=$(otool -D "$LIBRARY" 2>/dev/null | grep ^"$WRONG_PREFIX" | sed s,"$WRONG_PREFIX",,)
if [ -n "$lib" ]; then
# echo "Rewrite $lib"
install_name_tool -id "${RIGHT_PREFIX}/${lib}" $LIBRARY;
# else
# path=$(otool -D "$LIBRARY" 2>/dev/null | sed -n 2p)
# echo "Empty Result $path"
fi
fi
11 changes: 11 additions & 0 deletions .github/releasers/releaser_gui_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ go build -ldflags "-s -w" -trimpath -tags gtk -o ${BUILD_DIR}/pactus-gui ./cmd/g
echo "Installing gtk-mac-bundler"
git clone https://gitlab.gnome.org/GNOME/gtk-mac-bundler.git
cd gtk-mac-bundler

# A workaround to make bundle without builing GTK+ using jhbuild.
rm bundler/run-install-name-tool-change.sh
cp ${ROOT_DIR}/.github/releasers/macos/run-install-name-tool-change.sh bundler/run-install-name-tool-change.sh
chmod +x bundler/run-install-name-tool-change.sh

# make sure launcher is executable
chmod +x ${ROOT_DIR}/.github/releasers/macos/gtk3-launcher.sh

make install

export PATH=${PATH}:${HOME}/.bin:${HOME}/local/bin
Expand Down Expand Up @@ -64,6 +73,8 @@ export ROOT_DIR

${BUNDLER} ${GUI_BUNDLE}/gui.bundle

# Removing Cellar as workaround
rm -rf ${ROOT_DIR}/pactus-gui.app/Contents/Resources/Cellar

echo "Creating dmg"
# https://github.com/create-dmg/create-dmg
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
build-gui-macos:
runs-on: macos-12
env:
PREFIX: /usr/local
LIB_HOME: /usr/local

outputs:
checksums: ${{ steps.calc_checksums.outputs.checksums }}
Expand All @@ -106,7 +106,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install Dependencies
run: brew install gtk+3 librsvg create-dmg coreutils pkg-config gdk-pixbuf
run: brew install gtk+3 librsvg create-dmg coreutils pkg-config gdk-pixbuf glib glib-networking

- name: Install Go
uses: actions/setup-go@v5
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
# In M1 `/usr/local` moved to `/opt/homebrew`.
# More info: https://earthly.dev/blog/homebrew-on-m1/
#
PREFIX: /opt/homebrew
LIB_HOME: /opt/homebrew

outputs:
checksums: ${{ steps.calc_checksums.outputs.checksums }}
Expand All @@ -150,7 +150,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install Dependencies
run: brew install gtk+3 librsvg create-dmg coreutils pkg-config gdk-pixbuf
run: brew install gtk+3 librsvg create-dmg coreutils pkg-config gdk-pixbuf glib glib-networking

- name: Install Go
uses: actions/setup-go@v5
Expand Down Expand Up @@ -267,4 +267,4 @@ jobs:
with:
files: .github/releasers/pactus_downloader.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
http
jsonrpc
nanomsg
windows
linux
macos
# Configure that a scope must always be provided.
requireScope: true
# The subject should not start with an uppercase character and should not end with a period.
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Changelog

## [1.4.0](https://github.com/pactus-project/pactus/compare/v1.3.0...v1.4.0) (2024-08-01)

### Feat

- **cmd**: add node type page to the startup assistant ([#1431](https://github.com/pactus-project/pactus/pull/1431))
- **grpc**: adding is-pruned and pruning-height to blockchain info API ([#1420](https://github.com/pactus-project/pactus/pull/1420))
- **daemon**: add import command to download pruned snapshots ([#1424](https://github.com/pactus-project/pactus/pull/1424))
- **util**: file downloader with verify sha256 hash ([#1422](https://github.com/pactus-project/pactus/pull/1422))
- **sync**: define full and prune service ([#1412](https://github.com/pactus-project/pactus/pull/1412))
- **pip**: implement PIP-23 ([#1397](https://github.com/pactus-project/pactus/pull/1397))
- **firewall**: check valid gossip and stream messages ([#1402](https://github.com/pactus-project/pactus/pull/1402))
- **state**: prune block on commit ([#1404](https://github.com/pactus-project/pactus/pull/1404))
- **core**: pruning client by prune command ([#1400](https://github.com/pactus-project/pactus/pull/1400))
- **store**: prune block function ([#1399](https://github.com/pactus-project/pactus/pull/1399))
- **wallet**: add timeout client connection ([#1396](https://github.com/pactus-project/pactus/pull/1396))
- add backup tool script ([#1373](https://github.com/pactus-project/pactus/pull/1373))

### Fix

- **consensus**: handle query for decided proposal ([#1438](https://github.com/pactus-project/pactus/pull/1438))
- **gtk**: solve dynamic library dependencies and import path on macOS ([#1435](https://github.com/pactus-project/pactus/pull/1435))
- **cmd**: prevent sudden crash on download error ([#1432](https://github.com/pactus-project/pactus/pull/1432))
- **store**: pruning height returns zero when store is not in prune mode ([#1430](https://github.com/pactus-project/pactus/pull/1430))
- **grpc**: add last-block-time to blockchain-info API ([#1428](https://github.com/pactus-project/pactus/pull/1428))
- **grpc**: show negative pruning height when is pruned false ([#1429](https://github.com/pactus-project/pactus/pull/1429))
- **sync**: fix syncing issue on prune mode ([#1415](https://github.com/pactus-project/pactus/pull/1415))
- **grpc**: return error on invalid arguments for VerifyMessage ([#1411](https://github.com/pactus-project/pactus/pull/1411))
- **network**: accept messages originating from self ([#1408](https://github.com/pactus-project/pactus/pull/1408))
- change wallet rpc ip to dns address ([#1398](https://github.com/pactus-project/pactus/pull/1398))
- **pactus-shell**: pactus shell support basic auth ([#1384](https://github.com/pactus-project/pactus/pull/1384))
- **gui**: support ctrl+c for interrupt gui ([#1385](https://github.com/pactus-project/pactus/pull/1385))
- **grpc**: add basic auth in swagger header ([#1383](https://github.com/pactus-project/pactus/pull/1383))

### Refactor

- **execution**: simplify executors and tests ([#1425](https://github.com/pactus-project/pactus/pull/1425))

## [1.3.0](https://github.com/pactus-project/pactus/compare/v1.2.0...v1.3.0) (2024-06-27)

### Feat
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ You can use these commands in the Makefile:
Error and log messages should not start with a capital letter (unless it's a proper noun or acronym) and
should not end with punctuation.

All changes on core must contain proper and well-defined unit-tests, also previous tests must be passed as well.
This codebase used `testify` for unit tests, make sure you follow these guide for tests:

- For panic cases make sure you use `assert.Panics`
- For checking err using `assert.ErrorIs` make sure you pass expected error as second argument.
- For checking equality using `assert.Equal` make sure you pass expected value as the first argument.


> This code guideline must be followed for both contributors and maintainers to review the PRs.
#### Examples

- Correct ✅: "unable to connect to server"
Expand Down
4 changes: 2 additions & 2 deletions cmd/gtk/assets/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@
</object>
</child>
<child>
<object class="GtkMenuItem" id="id_learn_menu">
<object class="GtkMenuItem" id="id_documentation_menu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Learn</property>
<property name="label" translatable="yes">_Documentation</property>
<property name="use-underline">True</property>
</object>
</child>
Expand Down
6 changes: 6 additions & 0 deletions cmd/gtk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"path/filepath"
"runtime"

"github.com/gofrs/flock"
"github.com/gotk3/gotk3/gdk"
Expand All @@ -33,6 +34,11 @@ func init() {
passwordOpt = flag.String("password", "", "wallet password")
testnetOpt = flag.Bool("testnet", false, "initializing for the testnet")
version.NodeAgent.AppType = "gui"
// the gtk on macos should run on main thread.
if runtime.GOOS == "darwin" {
runtime.UnlockOSThread()
runtime.LockOSThread()
}
gtk.Init(nil)
}

Expand Down
Loading

0 comments on commit 133ac90

Please sign in to comment.