Compare commits

...

14 Commits

Author SHA1 Message Date
nico ffe1112270 woop 9 months ago
Sun Hyuk Ahn 178d0509e0
Merge pull request #295 from MaxMustermann2/data-signing 12 months ago
Max c38f4e498c
governance: do not allow `approval` hex interpret (#302) 1 year ago
Max aecd7314c0
governance: fix voting support for `approval` etc (#301) 1 year ago
Soph ba01a1871f
[github action] ubuntu22 and fix macos build (#299) 2 years ago
Max 72a36bccc3
pkg/ledger: fix transaction signing (#298) 2 years ago
MaxMustermann2 24c5bf63c1
Merge branch console-data-field of MuKnIO/go-sdk 2 years ago
MaxMustermann2 5cbf0c66dc
cmd: add support for `data` signing 2 years ago
Soph 5d91d48bba
update github action (#294) 2 years ago
Soph 6de63a336d
Merge pull request #285 from Frozen/mac_m1_fix 2 years ago
Soph 4409ecfa78
Merge pull request #293 from MaxMustermann2/muldefs 2 years ago
MaxMustermann2 6675575fbb
build: remove multiple definitions error 2 years ago
Ian Denhardt 17c2359fc4 console: support `data:` field to {send,sign}Transaction. 3 years ago
Konstantin 7abe0ba4c1 Fix for mac. 3 years ago
  1. 239
      .github/workflows/hmybuild.yml
  2. 103
      .github/workflows/test-build.yml
  3. 6
      .gitignore
  4. 39
      Makefile
  5. 95
      README.md
  6. 6
      cmd/main.go
  7. 8
      cmd/subcommands/balance.go
  8. 14
      cmd/subcommands/blockchain.go
  9. 14
      cmd/subcommands/command.go
  10. 2
      cmd/subcommands/completion.go
  11. 6
      cmd/subcommands/custom-flags.go
  12. 2
      cmd/subcommands/delegation.go
  13. 99
      cmd/subcommands/ethtransfer.go
  14. 2
      cmd/subcommands/failures.go
  15. 29
      cmd/subcommands/governance.go
  16. 20
      cmd/subcommands/keys.go
  17. 39
      cmd/subcommands/root.go
  18. 38
      cmd/subcommands/staking.go
  19. 31
      cmd/subcommands/transfer.go
  20. 10
      cmd/subcommands/utility.go
  21. 2
      cmd/subcommands/validator.go
  22. 57
      cmd/subcommands/values.go
  23. 8
      go.mod
  24. 22
      go.sum
  25. 2
      pkg/account/account_test.go
  26. 6
      pkg/account/creation.go
  27. 4
      pkg/account/export.go
  28. 15
      pkg/account/import.go
  29. 8
      pkg/account/removal.go
  30. 2
      pkg/common/numeric.go
  31. 2
      pkg/common/store.go
  32. 10
      pkg/common/values.go
  33. 4
      pkg/console/bridge.go
  34. 89
      pkg/console/console.go
  35. 6
      pkg/console/web3ext/web3ext.go
  36. 9
      pkg/console/wiki.go
  37. 4
      pkg/governance/cli.go
  38. 41
      pkg/governance/eip712.go
  39. 6
      pkg/governance/signing.go
  40. 6
      pkg/governance/signing_test.go
  41. 114
      pkg/governance/types.go
  42. 20
      pkg/keys/bls.go
  43. 22
      pkg/keys/keys.go
  44. 2
      pkg/keys/mnemonic.go
  45. 10
      pkg/ledger/hw_wallet.go
  46. 30
      pkg/ledger/nano_S_driver.go
  47. 2
      pkg/rpc/eth/methods.go
  48. 6
      pkg/rpc/methods.go
  49. 2
      pkg/rpc/query.go
  50. 4
      pkg/rpc/v1/methods.go
  51. 8
      pkg/sharding/structure.go
  52. 16
      pkg/store/local.go
  53. 19
      pkg/transaction/controller.go
  54. 2
      pkg/transaction/errors.go
  55. 69
      pkg/transaction/ethcontroller.go
  56. 8
      pkg/transaction/transaction.go
  57. 17
      pkg/transaction/util.go
  58. 2
      pkg/validation/validation_test.go
  59. 4
      scripts/stress-test
  60. 70
      scripts/wiki-csv.py
  61. 20
      scripts/wiki.sh

@ -1,70 +1,52 @@
name: release hmy
name: release wiki
on:
push:
tags:
- v*
jobs:
env:
GOPATH: ${{ github.workspace }}
GOBIN: ${{ github.workspace }}/bin
build-x8664:
name: Build hmy binary for Linux x8664
jobs:
build-x86_64:
name: Build wiki binary for x86_64
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-18.04 ]
os: [ ubuntu-22.04, macos-latest ]
steps:
- name: Set up Go 1.16.5
uses: actions/setup-go@v2
- name: Checkout wiki code
uses: actions/checkout@v3
with:
go-version: 1.16.5
path: go-sdk
- name: Checkout hmy code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
path: go/src/github.com/harmony-one/go-sdk
- name: Debug
run: |
pwd
echo ${HOME}
echo ${GITHUB_WORKSPACE}
echo ${GOPATH}
echo ${GOROOT}
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
go-version-file: go-sdk/go.mod
- name: Checkout dependence repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: harmony-one/mcl
path: go/src/github.com/harmony-one/mcl
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
repository: woop-chain/mcl
path: ${{ github.workspace }}/src/github.com/woop-chain/mcl
- name: Checkout dependence repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: harmony-one/bls
path: go/src/github.com/harmony-one/bls
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
repository: woop-chain/bls
path: ${{ github.workspace }}/src/github.com/woop-chain/bls
- name: Checkout dependence code
uses: actions/checkout@v2
with:
repository: harmony-one/harmony
path: go/src/github.com/harmony-one/harmony
repository: woop-chain/woop
path: ${{ github.workspace }}/src/github.com/woop-chain/woop
ref: main
fetch-depth: 0
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
- name: Get latest version and release
run: |
@ -72,29 +54,49 @@ jobs:
RELEASE=$(git describe --long | cut -f2 -d-)
echo "build_version=$VERSION" >> $GITHUB_ENV
echo "build_release=$RELEASE" >> $GITHUB_ENV
working-directory: /home/runner/work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
working-directory: go-sdk
- name: Debug
run: |
pwd
echo ${HOME}
echo ${GITHUB_WORKSPACE}
echo ${GOPATH}
echo ${GOROOT}
- name: Build hmy binary for Linux
if: matrix.os == 'ubuntu-18.04'
- name: Build wiki binary for Linux
if: matrix.os == 'ubuntu-22.04'
run: |
make static
working-directory: /home/runner/work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
working-directory: go-sdk
- name: Build libs for macos-latest
if: matrix.os == 'macos-latest'
run: |
brew install gmp
brew install openssl
sudo mkdir -p /opt/homebrew/opt/
sudo ln -sf /usr/local/opt/openssl@1.1 /opt/homebrew/opt/openssl@1.1
echo "ls -l /opt/homebrew/opt/openssl@1.1"; ls -l /opt/homebrew/opt/openssl@1.1
make libs
working-directory: ${{ github.workspace }}/src/github.com/woop-chain/woop
- name: Build wiki binary for macos-latest x86_64
if: matrix.os == 'macos-latest'
run: |
make all
mv dist/wiki dist/wiki-darwin-x86_64
working-directory: go-sdk
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: hmy
path: /home/runner/work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk/dist/*
name: wiki
path: ${{ github.workspace }}/go-sdk/dist/*
retention-days: 1
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
# build-arm64:
# name: Build hmy binary
# name: Build wiki binary
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
@ -108,10 +110,10 @@ jobs:
# go-version: 1.16.5
# - name: Checkout hmy code
# - name: Checkout wiki code
# uses: actions/checkout@v2
# with:
# path: go/src/github.com/harmony-one/go-sdk
# path: go/src/github.com/woop-chain/go-sdk
# - name: Debug
# run: |
@ -126,66 +128,62 @@ jobs:
# - name: Checkout dependence repo
# uses: actions/checkout@v2
# with:
# repository: harmony-one/mcl
# path: go/src/github.com/harmony-one/mcl
# repository: woop-chain/mcl
# path: go/src/github.com/woop-chain/mcl
# env:
# GOPATH: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go
# - name: Checkout dependence repo
# uses: actions/checkout@v2
# with:
# repository: harmony-one/bls
# path: go/src/github.com/harmony-one/bls
# repository: woop-chain/bls
# path: go/src/github.com/woop-chain/bls
# env:
# GOPATH: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go
# - name: Checkout dependence code
# uses: actions/checkout@v2
# with:
# repository: harmony-one/harmony
# path: go/src/github.com/harmony-one/harmony
# repository: woop-chain/woop
# path: go/src/github.com/woop-chain/woop
# ref: main
# fetch-depth: 0
# env:
# GOPATH: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go
# - name: Build hmy binary for Arm
# - name: Build wiki binary for Arm
# run: |
# make static
# mv dist/hmy dist/hmy-arm64
# chmod +x dist/hmy-arm64
# working-directory: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk
# mv dist/wiki dist/wiki-arm64
# chmod +x dist/wiki-arm64
# working-directory: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go/src/github.com/woop-chain/go-sdk
# env:
# GOPATH: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go
# - name: Upload artifact
# uses: actions/upload-artifact@v2
# with:
# name: hmy-arm64
# path: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk/dist/*
# name: wiki-arm64
# path: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go/src/github.com/woop-chain/go-sdk/dist/*
# retention-days: 1
# env:
# GOPATH: /home/ubuntu/actions-runner/_work/go-sdk/go-sdk/go
release-page:
name: Sign binary and create and publish release page
needs: [ build-x8664 ]
runs-on: ubuntu-18.04
needs: [ build-x86_64 ]
runs-on: ubuntu-22.04
steps:
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.HMY_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.HMY_GPG_PRIVATE_KEY_PASS }}
gpg-private-key: ${{ secrets.WIKI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.WIKI_GPG_PRIVATE_KEY_PASS }}
- name: Checkout hmy core code
uses: actions/checkout@v2
- name: Checkout wiki core code
uses: actions/checkout@v3
with:
path: go/src/github.com/harmony-one/go-sdk
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
path: go-sdk
- name: Get latest version
run: |
@ -195,122 +193,89 @@ jobs:
echo "build_version=$VERSION" >> $GITHUB_ENV
echo "build_version_long=$VERSION_LONG" >> $GITHUB_ENV
echo "build_release=$RELEASE" >> $GITHUB_ENV
working-directory: /home/runner/work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk
env:
GOPATH: /home/runner/work/go-sdk/go-sdk/go
working-directory: go-sdk
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: hmy
- name: Signed amd64 hmy binary
run: |
gpg --detach-sign hmy
sha256sum hmy >> hmy.sha256
# - name: Download artifact
# uses: actions/download-artifact@v2
# with:
# name: hmy-arm64
# - name: Signed arm64 hmy binary
# run: |
# gpg --detach-sign hmy-arm64
# sha256sum hmy-arm64 >> hmy-arm64.sha256
name: wiki
- name: Display structure of downloaded files
run: ls -R
- name: Signed darwin x86_64 wiki binary
run: |
gpg --detach-sign wiki-darwin-x86_64
sha256sum wiki-darwin-x86_64 >> wiki-darwin-x86_64.sha256
- name: Get tag message
env:
TAG_SHA: ${{ github.event.after }}
GOPATH: /home/runner/work/go-sdk/go
run: |
touch ./tag_message.md
echo -e "$TAG_SHA\n\nThe released version: $build_version_long" >> ./tag_message.md
working-directory: /home/runner/work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk
working-directory: go-sdk
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /home/runner/work/go-sdk/go-sdk/go
with:
tag_name: ${{ github.ref }}
release_name: Mainnet Release ${{ env.build_version }}
draft: true
prerelease: false
body_path: /home/runner/work/go-sdk/go-sdk/go/src/github.com/harmony-one/go-sdk/tag_message.md
body_path: ${{ github.workspace }}/go-sdk/tag_message.md
- name: Upload hmy binary for Linux (amd64)
- name: Upload wiki binary for Linux (x86_64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /home/runner/work/go-sdk/go-sdk/go
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./hmy
asset_name: hmy
asset_path: ./wiki
asset_name: wiki
asset_content_type: application/octet-stream
- name: Upload sha256 signature of hmy amd64 binary
- name: Upload wiki binary darwin-x86_64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./hmy.sha256
asset_name: hmy.sha256
asset_content_type: text/plain
- name: Upload gpg signature of hmy amd64 binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./hmy.sig
asset_name: hmy.sig
asset_path: ./wiki-darwin-x86_64
asset_name: wiki-darwin-x86_64
asset_content_type: application/octet-stream
# - name: Upload hmy binary for ARM64
# - name: Upload wiki binary for ARM64
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GOPATH: /home/runner/work/go-sdk/go-sdk/go
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./hmy-arm64
# asset_name: hmy-arm64
# asset_path: ./wiki-arm64
# asset_name: wiki-arm64
# asset_content_type: application/octet-stream
# - name: Upload sha256 signature of hmy arm64 binary
# - name: Upload sha256 signature of wiki arm64 binary
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./hmy-arm64.sha256
# asset_name: hmy-arm64.sha256
# asset_path: ./wiki-arm64.sha256
# asset_name: wiki-arm64.sha256
# asset_content_type: text/plain
# - name: Upload gpg signature of hmy arm64 binary
# - name: Upload gpg signature of wiki arm64 binary
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./hmy-arm64.sig
# asset_name: hmy-arm64.sig
# asset_content_type: application/octet-stream
# asset_path: ./wiki-arm64.sig
# asset_name: wiki-arm64.sig
# asset_content_type: application/octet-stream

@ -0,0 +1,103 @@
name: test build
on:
push:
env:
GOPATH: ${{ github.workspace }}
GOBIN: ${{ github.workspace }}/bin
jobs:
build-x86_64:
name: Build wiki binary for x86_64
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-22.04, macos-latest ]
steps:
- name: Checkout wiki code
uses: actions/checkout@v3
with:
path: go-sdk
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go-sdk/go.mod
- name: Checkout dependence repo
uses: actions/checkout@v3
with:
repository: woop-chain/mcl
path: ${{ github.workspace }}/src/github.com/woop-chain/mcl
- name: Checkout dependence repo
uses: actions/checkout@v3
with:
repository: woop-chain/bls
path: ${{ github.workspace }}/src/github.com/woop-chain/bls
- name: Checkout dependence code
uses: actions/checkout@v2
with:
repository: woop-chain/woop
path: ${{ github.workspace }}/src/github.com/woop-chain/woop
ref: main
fetch-depth: 0
- name: Get latest version and release
run: |
VERSION=$(git tag -l --sort=-v:refname | head -n 1 | tr -d v)
RELEASE=$(git describe --long | cut -f2 -d-)
echo "build_version=$VERSION" >> $GITHUB_ENV
echo "build_release=$RELEASE" >> $GITHUB_ENV
working-directory: go-sdk
- name: Debug
run: |
pwd
echo ${HOME}
echo ${GITHUB_WORKSPACE}
echo ${GOPATH}
echo ${GOROOT}
ls ${{ github.workspace }}/src/github.com/woop-chain/
- name: Build wiki binary for linux ubuntu
if: matrix.os == 'ubuntu-22.04'
run: |
make static
working-directory: go-sdk
- name: Build libs for macos-latest
if: matrix.os == 'macos-latest'
run: |
brew install gmp
brew install openssl
sudo mkdir -p /opt/homebrew/opt/
sudo ln -sf /usr/local/opt/openssl@1.1 /opt/homebrew/opt/openssl@1.1
echo "ls -l /opt/homebrew/opt/openssl@1.1"; ls -l /opt/homebrew/opt/openssl@1.1
make libs
working-directory: ${{ github.workspace }}/src/github.com/woop-chain/woop
- name: Build wiki binary for macos-latest x86_64
if: matrix.os == 'macos-latest'
run: |
make all
working-directory: go-sdk
- name: Upload artifact for linux
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-22.04'
with:
name: wiki-linux
path: ${{ github.workspace }}/go-sdk/dist/*
retention-days: 1
- name: Upload artifact for darwin
uses: actions/upload-artifact@v3
if: matrix.os == 'macos-latest'
with:
name: wiki-darwin
path: ${{ github.workspace }}/go-sdk/dist/*
retention-days: 1

6
.gitignore vendored

@ -1,6 +1,6 @@
hmy
hmy-docs
wiki
wiki-docs
dist
.idea/
*.key
hmy_version
wiki_version

@ -1,16 +1,19 @@
SHELL := /bin/bash
TOP:=$(realpath ..)
export LD_LIBRARY_PATH:=$(TOP)/bls/lib:$(TOP)/mcl/lib:/usr/local/opt/openssl/lib:/opt/homebrew/opt/gmp/lib/:/opt/homebrew/opt/openssl/lib
export LIBRARY_PATH:=$(LD_LIBRARY_PATH)
version := $(shell git rev-list --count HEAD)
commit := $(shell git describe --always --long --dirty)
built_at := $(shell date +%FT%T%z)
built_by := ${USER}@harmony.one
built_by := ${USER}@wikiwoop.com
flags := -gcflags="all=-N -l -c 2"
flags := -gcflags="all=-N -l"
ldflags := -X main.version=v${version} -X main.commit=${commit}
ldflags += -X main.builtAt=${built_at} -X main.builtBy=${built_by}
cli := ./dist/hmy
upload-path-darwin := 's3://pub.harmony.one/release/darwin-x86_64/mainnet/hmy'
upload-path-linux := 's3://pub.harmony.one/release/linux-x86_64/mainnet/hmy'
upload-path-linux-version := 's3://pub.harmony.one/release/linux-x86_64/mainnet/hmy_version'
cli := ./dist/wiki
upload-path-darwin := 's3://pub.wikiwoop.com/release/darwin-x86_64/mainnet/wiki'
upload-path-linux := 's3://pub.wikiwoop.com/release/linux-x86_64/mainnet/wiki'
upload-path-linux-version := 's3://pub.wikiwoop.com/release/linux-x86_64/mainnet/wiki_version'
uname := $(shell uname)
env := GO111MODULE=on
@ -19,18 +22,18 @@ DIR := ${CURDIR}
export CGO_LDFLAGS=-L$(DIR)/dist/lib -Wl,-rpath -Wl,\$ORIGIN/lib
all:
source $(shell go env GOPATH)/src/github.com/harmony-one/harmony/scripts/setup_bls_build_flags.sh && $(env) go build -o $(cli) -ldflags="$(ldflags)" cmd/main.go
cp $(cli) hmy
source $(shell go env GOPATH)/src/github.com/woop-chain/woop/scripts/setup_bls_build_flags.sh && $(env) go build -o $(cli) -ldflags="$(ldflags)" cmd/main.go
cp $(cli) wiki
static:
make -C $(shell go env GOPATH)/src/github.com/harmony-one/mcl
make -C $(shell go env GOPATH)/src/github.com/harmony-one/bls minimised_static BLS_SWAP_G=1
source $(shell go env GOPATH)/src/github.com/harmony-one/harmony/scripts/setup_bls_build_flags.sh && $(env) go build -o $(cli) -ldflags="$(ldflags) -w -extldflags \"-static -z muldefs\"" cmd/main.go
cp $(cli) hmy
make -C $(shell go env GOPATH)/src/github.com/woop-chain/mcl
make -C $(shell go env GOPATH)/src/github.com/woop-chain/bls minimised_static BLS_SWAP_G=1
source $(shell go env GOPATH)/src/github.com/woop-chain/woop/scripts/setup_bls_build_flags.sh && $(env) go build -o $(cli) -ldflags="$(ldflags) -w -extldflags \"-static\"" cmd/main.go
cp $(cli) wiki
debug:
source $(shell go env GOPATH)/src/github.com/harmony-one/harmony/scripts/setup_bls_build_flags.sh && $(env) go build $(flags) -o $(cli) -ldflags="$(ldflags)" cmd/main.go
cp $(cli) hmy
source $(shell go env GOPATH)/src/github.com/woop-chain/woop/scripts/setup_bls_build_flags.sh && $(env) go build $(flags) -o $(cli) -ldflags="$(ldflags)" cmd/main.go
cp $(cli) wiki
install:all
cp $(cli) ~/.local/bin
@ -46,7 +49,7 @@ test-rpc:
# Notice assumes you have correct uploading credentials
upload-darwin:all
ifeq (${uname}, Darwin)
aws --profile upload s3 cp ./hmy ${upload-path-darwin}
aws --profile upload s3 cp ./wiki ${upload-path-darwin}
else
@echo "Wrong operating system for target upload"
endif
@ -54,9 +57,9 @@ endif
# Only the linux build will upload the CLI version
upload-linux:static
ifeq (${uname}, Linux)
aws --profile upload s3 cp ./hmy ${upload-path-linux}
./hmy version &> ./hmy_version
aws --profile upload s3 cp ./hmy_version ${upload-path-linux-version}
aws --profile upload s3 cp ./wiki ${upload-path-linux}
./wiki version &> ./wiki_version
aws --profile upload s3 cp ./wiki_version ${upload-path-linux-version}
else
@echo "Wrong operating system for target upload"
endif

@ -1,21 +1,21 @@
# Harmony's go-sdk
# Woop's go-sdk
This is a go layer on top of the Harmony RPC, included is a CLI tool that you can build with a
This is a go layer on top of the Woop RPC, included is a CLI tool that you can build with a
simple invocation of `make`
See https://docs.harmony.one/home/network/wallets/harmony-cli/download-setup for detailed
documentation on how to use the `hmy` CLI tools
See https://docs.wikiwoop.com/home/network/wallets/woop-cli/download-setup for detailed
documentation on how to use the `wiki` CLI tools
# Build
Working directly on this repo can be challenging because of the upstream dependencies. Follow the
README in the main repo for an already ready development environment:
https://github.com/harmony-one/harmony/blob/master/README.md.
https://github.com/woop-chain/woop/blob/master/README.md.
...for the impatient:
```
$ docker run -it harmonyone/main:stable /bin/bash
$ docker run -it woopchain/main:stable /bin/bash
$ cd ../go-sdk
$ git pull -r origin master
$ make
@ -23,20 +23,20 @@ $ make
# Usage & Examples
`hmy` implements a fluent API, that is, there is a hierarchy of commands.
`wiki` implements a fluent API, that is, there is a hierarchy of commands.
# bash completions
once built, add `hmy` to your path and add to your `.bashrc`
once built, add `wiki` to your path and add to your `.bashrc`
```
. <(hmy completion)
. <(wiki completion)
```
invoke the following command to see the most command usages of `hmy`
invoke the following command to see the most command usages of `wiki`
```
$ hmy cookbook
$ wiki cookbook
Cookbook of Usage
@ -52,89 +52,88 @@ Note:
Examples:
1. Check account balance on given chain
./hmy --node=https://api.s0.t.hmny.io balances <SOME_ONE_ADDRESS>
./wiki --node=https://api.s0.t.hmny.io balances <SOME_ONE_ADDRESS>
2. Check sent transaction
./hmy --node=https://api.s0.t.hmny.io blockchain transaction-by-hash <SOME_TX_HASH>
./wiki --node=https://api.s0.t.hmny.io blockchain transaction-by-hash <SOME_TX_HASH>
3. List local account keys
./hmy keys list
./wiki keys list
4. Sending a transaction (waits 40 seconds for transaction confirmation)
./hmy --node=https://api.s0.t.hmny.io transfer \
./wiki --node=https://api.s0.t.hmny.io transfer \
--from <SOME_ONE_ADDRESS> --to <SOME_ONE_ADDRESS> \
--from-shard 0 --to-shard 1 --amount 200 --passphrase
5. Sending a batch of transactions as dictated from a file (the `--dry-run` options still apply)
./hmy --node=https://api.s0.t.hmny.io transfer --file <PATH_TO_JSON_FILE>
./wiki --node=https://api.s0.t.hmny.io transfer --file <PATH_TO_JSON_FILE>
Check README for details on json file format.
6. Check a completed transaction receipt
./hmy --node=https://api.s0.t.hmny.io blockchain transaction-receipt <SOME_TX_HASH>
./wiki --node=https://api.s0.t.hmny.io blockchain transaction-receipt <SOME_TX_HASH>
7. Import an account using the mnemonic. Prompts the user to give the mnemonic.
./hmy keys recover-from-mnemonic <ACCOUNT_NAME>
./wiki keys recover-from-mnemonic <ACCOUNT_NAME>
8. Import an existing keystore file
./hmy keys import-ks <PATH_TO_KEYSTORE_JSON>
./wiki keys import-ks <PATH_TO_KEYSTORE_JSON>
9. Import a keystore file using a secp256k1 private key
./hmy keys import-private-key <secp256k1_PRIVATE_KEY>
./wiki keys import-private-key <secp256k1_PRIVATE_KEY>
10. Export a keystore file's secp256k1 private key
./hmy keys export-private-key <ACCOUNT_ADDRESS> --passphrase
./wiki keys export-private-key <ACCOUNT_ADDRESS> --passphrase
11. Generate a BLS key then encrypt and save the private key to the specified location.
./hmy keys generate-bls-key --bls-file-path <PATH_FOR_BLS_KEY_FILE>
./wiki keys generate-bls-key --bls-file-path <PATH_FOR_BLS_KEY_FILE>
12. Create a new validator with a list of BLS keys
./hmy --node=https://api.s0.t.hmny.io staking create-validator --amount 10 --validator-addr <SOME_ONE_ADDRESS> \
./wiki --node=https://api.s0.t.hmny.io staking create-validator --amount 10 --validator-addr <SOME_ONE_ADDRESS> \
--bls-pubkeys <BLS_KEY_1>,<BLS_KEY_2>,<BLS_KEY_3> \
--identity foo --details bar --name baz --max-change-rate 0.1 --max-rate 0.1 --max-total-delegation 10 \
--min-self-delegation 10 --rate 0.1 --security-contact Leo --website harmony.one --passphrase
--min-self-delegation 10 --rate 0.1 --security-contact Leo --website wikiwoop.com --passphrase
13. Edit an existing validator
./hmy --node=https://api.s0.t.hmny.io staking edit-validator \
./wiki --node=https://api.s0.t.hmny.io staking edit-validator \
--validator-addr <SOME_ONE_ADDRESS> --identity foo --details bar \
--name baz --security-contact EK --website harmony.one \
--name baz --security-contact EK --website wikiwoop.com \
--min-self-delegation 0 --max-total-delegation 10 --rate 0.1\
--add-bls-key <SOME_BLS_KEY> --remove-bls-key <OTHER_BLS_KEY> --passphrase
14. Delegate an amount to a validator
./hmy --node=https://api.s0.t.hmny.io staking delegate \
./wiki --node=https://api.s0.t.hmny.io staking delegate \
--delegator-addr <SOME_ONE_ADDRESS> --validator-addr <VALIDATOR_ONE_ADDRESS> \
--amount 10 --passphrase
15. Undelegate to a validator
./hmy --node=https://api.s0.t.hmny.io staking undelegate \
./wiki --node=https://api.s0.t.hmny.io staking undelegate \
--delegator-addr <SOME_ONE_ADDRESS> --validator-addr <VALIDATOR_ONE_ADDRESS> \
--amount 10 --passphrase
16. Collect block rewards as a delegator
./hmy --node=https://api.s0.t.hmny.io staking collect-rewards \
./wiki --node=https://api.s0.t.hmny.io staking collect-rewards \
--delegator-addr <SOME_ONE_ADDRESS> --passphrase
17. Check elected validators
./hmy --node=https://api.s0.t.hmny.io blockchain validator elected
./wiki --node=https://api.s0.t.hmny.io blockchain validator elected
18. Get current staking utility metrics
./hmy --node=https://api.s0.t.hmny.io blockchain utility-metrics
./wiki --node=https://api.s0.t.hmny.io blockchain utility-metrics
19. Check in-memory record of failed staking transactions
./hmy --node=https://api.s0.t.hmny.io failures staking
./wiki --node=https://api.s0.t.hmny.io failures staking
20. Check which shard your BLS public key would be assigned to as a validator
./hmy --node=https://api.s0.t.hmny.io utility shard-for-bls <BLS_PUBLIC_KEY>
./wiki --node=https://api.s0.t.hmny.io utility shard-for-bls <BLS_PUBLIC_KEY>
21. Vote on a governance proposal on https://snapshot.org
./hmy governance vote-proposal --space=[harmony-mainnet.eth] \
./wiki governance vote-proposal --space=[woop-mainnet.eth] \
--proposal=<PROPOSAL_IPFS_HASH> --proposal-type=[single-choice] \
--choice=<VOTING_CHOICE(S)> --app=[APP] --key=<ACCOUNT_ADDRESS_OR_NAME> \
--privacy=[PRIVACY TYPE]
PS: key must first use (hmy keys import-private-key) to import
--choice=<VOTING_CHOICE(S)> --app=[APP] --key=<ACCOUNT_ADDRESS_OR_NAME>
PS: key must first use (wiki keys import-private-key) to import
22. Enter Console
./hmy command --net=testnet
./wiki command --net=testnet
```
# Sending batched transactions
@ -145,7 +144,7 @@ off **in sequential order**.
Example:
```
hmy --node="https://api.s1.t.hmny.io/" transfer --file ./batchTransactions.json
wiki --node="https://api.s1.t.hmny.io/" transfer --file ./batchTransactions.json
```
> Note that the `--wait-for-confirm` and `--dry-run` options still apply when sending batched transactions
@ -157,13 +156,13 @@ The JSON file will be a JSON array where each element has the following attribut
| :------------------:|:----------:| :----------------|
| `from` | string | [**Required**] Sender's one address, must have key in keystore. |
| `to` | string | [**Required**] The receivers one address. |
| `amount` | string | [**Required**] The amount to send in $ONE. |
| `amount` | string | [**Required**] The amount to send in $WOOP. |
| `from-shard` | string | [**Required**] The source shard. |
| `to-shard` | string | [**Required**] The destination shard. |
| `passphrase-file` | string | [*Optional*] The file path to file containing the passphrase in plain text. If none is provided, check for passphrase string. |
| `passphrase-string` | string | [*Optional*] The passphrase as a string in plain text. If none is provided, passphrase is ''. |
| `nonce` | string | [*Optional*] The nonce of a specific transaction, default uses nonce from blockchain. |
| `gas-price` | string | [*Optional*] The gas price to pay in NANO (1e-9 of $ONE), default is 1. |
| `gas-price` | string | [*Optional*] The gas price to pay in NANO (1e-9 of $WOOP), default is 1. |
| `gas-limit` | string | [*Optional*] The gas limit, default is 21000. |
| `stop-on-error` | boolean | [*Optional*] If true, stop sending transactions if an error occurred, default is false. |
| `true-nonce` | boolean | [*Optional*] If true, send transaction using true on-chain nonce. Cannot be used with `nonce`. If none is provided, use tx pool nonce. |
@ -243,26 +242,26 @@ Example of returned JSON Array:
## Offline sign transfer
1. Get Nonce From a Account. (Need to be online, but no passphrase required)
```bash
./hmy get-nonce --node=https://api.s0.t.hmny.io --from=[ONE address]
./wiki get-nonce --node=https://api.s0.t.hmny.io --from=[ONE address]
```
2. Sign transfer and write to file. (Passphrase required, But no need to be online)
```bash
./hmy transfer --offline-sign --nonce=[nonce value from previous] --from=[ONE address] --to=[ONE address] --amount=1000 --from-shard=0 --to-shard=0 > signed.json
./wiki transfer --offline-sign --nonce=[nonce value from previous] --from=[ONE address] --to=[ONE address] --amount=1000 --from-shard=0 --to-shard=0 > signed.json
```
3. send `signed.json` to Harmony blockchain! (Need to be online, but no passphrase required)
3. send `signed.json` to Woop blockchain! (Need to be online, but no passphrase required)
```bash
./hmy offline-sign-transfer --node=https://api.s0.b.hmny.io --file ./signed.json
./wiki offline-sign-transfer --node=https://api.s0.b.hmny.io --file ./signed.json
```
# Debugging
The go-sdk code respects `HMY_RPC_DEBUG HMY_TX_DEBUG` as debugging
The go-sdk code respects `WIKI_RPC_DEBUG WIKI_TX_DEBUG` as debugging
based environment variables.
```bash
HMY_RPC_DEBUG=true HMY_TX_DEBUG=true ./hmy blockchain protocol-version
WIKI_RPC_DEBUG=true WIKI_TX_DEBUG=true ./wiki blockchain protocol-version
```
# Contract Deploy
@ -270,7 +269,7 @@ HMY_RPC_DEBUG=true HMY_TX_DEBUG=true ./hmy blockchain protocol-version
You can deploy the contract use the command;
```bash
./hmy command --node="https://api.s0.b.hmny.io" --net=testnet
./wiki command --node="https://api.s0.b.hmny.io" --net=testnet
```
Then you can test this code to deploy a smart contract

@ -5,10 +5,10 @@ import (
"os"
"path"
cmd "github.com/harmony-one/go-sdk/cmd/subcommands"
cmd "github.com/woop-chain/go-sdk/cmd/subcommands"
// Need this side effect
_ "github.com/harmony-one/go-sdk/pkg/store"
"github.com/spf13/cobra"
_ "github.com/woop-chain/go-sdk/pkg/store"
)
var (
@ -29,7 +29,7 @@ func main() {
Short: "Show version",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Fprintf(os.Stderr,
"Harmony (C) 2020. %v, version %v-%v (%v %v)\n",
"Woop (C) 2024. %v, version %v-%v (%v %v)\n",
path.Base(os.Args[0]), version, commit, builtBy, builtAt)
os.Exit(0)
return nil

@ -6,17 +6,17 @@ import (
"net"
"strings"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/go-sdk/pkg/sharding"
)
func init() {
cmdQuery := &cobra.Command{
Use: "balances",
Short: "Check account balance on all shards",
Long: "Query for the latest account balance given a Harmony Address",
Long: "Query for the latest account balance given a Woop Address",
Args: cobra.ExactArgs(1),
PreRunE: validateAddress,
RunE: func(cmd *cobra.Command, args []string) error {

@ -3,9 +3,9 @@ package cmd
import (
"fmt"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
)
var (
@ -40,9 +40,9 @@ Look up information about delegation
cmdBlockchain := &cobra.Command{
Use: "blockchain",
Short: "Interact with the Harmony.one Blockchain",
Short: "Interact with WoopChain",
Long: `
Query Harmony's blockchain for completed transaction, historic records
Query Woop's blockchain for completed transaction, historic records
`,
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()
@ -77,7 +77,7 @@ High level information about each transaction for given account
subCommands := []*cobra.Command{{
Use: "block-by-number",
Short: "Get a harmony blockchain block by block number",
Short: "Get a woop blockchain block by block number",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
@ -92,9 +92,9 @@ High level information about each transaction for given account
},
}, {
Use: "protocol-version",
Short: "The version of the Harmony Protocol",
Short: "The version of the Woop Protocol",
Long: `
Query Harmony's blockchain for high level metrics, queries
Query Woop's blockchain for high level metrics, queries
`,
RunE: func(cmd *cobra.Command, args []string) error {
return request(rpc.Method.ProtocolVersion, []interface{}{})

@ -2,11 +2,11 @@ package cmd
import (
ethereum_rpc "github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/console"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/console"
"github.com/woop-chain/go-sdk/pkg/rpc"
"log"
"os"
"path"
@ -30,13 +30,13 @@ func init() {
func checkAndMakeDirIfNeeded() string {
userDir, _ := homedir.Dir()
hmyCLIDir := path.Join(userDir, common.DefaultConfigDirName, common.DefaultCommandAliasesDirName)
if _, err := os.Stat(hmyCLIDir); os.IsNotExist(err) {
wikiCLIDir := path.Join(userDir, common.DefaultConfigDirName, common.DefaultCommandAliasesDirName)
if _, err := os.Stat(wikiCLIDir); os.IsNotExist(err) {
// Double check with Leo what is right file persmission
os.Mkdir(hmyCLIDir, 0700)
os.Mkdir(wikiCLIDir, 0700)
}
return hmyCLIDir
return wikiCLIDir
}
// remoteConsole will connect to a remote node instance, attaching a JavaScript

@ -12,7 +12,7 @@ func init() {
Short: "Generates bash completion scripts",
Long: `To load completion, run:
. <(hmy completion)
. <(wiki completion)
Add the line to your ~/.bashrc to enable completiony for each bash session.
`,

@ -1,10 +1,10 @@
package cmd
import (
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/validation"
"github.com/pkg/errors"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/validation"
)
type oneAddress struct {

@ -1,8 +1,8 @@
package cmd
import (
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/rpc"
)
var (

@ -5,18 +5,19 @@ import (
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
"time"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
rpcEth "github.com/harmony-one/go-sdk/pkg/rpc/eth"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/go-sdk/pkg/transaction"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/core"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
rpcEth "github.com/woop-chain/go-sdk/pkg/rpc/eth"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/transaction"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/core"
"github.com/spf13/cobra"
)
@ -43,9 +44,13 @@ func ethHandlerForShard(node string) (*rpc.HTTPMessenger, error) {
// Note that the vars need to be set before calling this handler.
func ethHandlerForTransaction(txLog *transactionLog) error {
from := fromAddress.String()
networkHandler, err := ethHandlerForShard(node)
if handlerForError(txLog, err) != nil {
return err
var networkHandler *rpc.HTTPMessenger
if !offlineSign {
var err error
networkHandler, err = ethHandlerForShard(node)
if handlerForError(txLog, err) != nil {
return err
}
}
var ctrlr *transaction.EthController
@ -98,12 +103,17 @@ func ethHandlerForTransaction(txLog *transactionLog) error {
gLimit = uint64(tempLimit)
}
dataByte, err := transaction.StringToByte(data)
if err != nil {
return handlerForError(txLog, err)
}
txLog.TimeSigned = time.Now().UTC().Format(timeFormat) // Approximate time of signature
err = ctrlr.ExecuteEthTransaction(
nonce, gLimit,
toAddress.String(),
amt, gPrice,
[]byte{},
dataByte,
)
if dryRun {
@ -187,6 +197,9 @@ func ethOpts(ctlr *transaction.EthController) {
if dryRun {
ctlr.Behavior.DryRun = true
}
if offlineSign {
ctlr.Behavior.OfflineSign = true
}
if useLedgerWallet {
ctlr.Behavior.SigningImpl = transaction.Ledger
}
@ -201,9 +214,12 @@ func init() {
Short: "Create and send an Ethereum compatible transaction",
Args: cobra.ExactArgs(0),
Long: `
Create an Ethereum compatible transaction, sign it, and send off to the Harmony blockchain
Create an Ethereum compatible transaction, sign it, and send off to the Woop blockchain
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if offlineSign {
dryRun = true
}
if givenFilePath == "" {
for _, flagName := range [...]string{"from", "to", "amount", "chain-id"} {
_ = cmd.MarkFlagRequired(flagName)
@ -269,15 +285,72 @@ Create an Ethereum compatible transaction, sign it, and send off to the Harmony
cmdEthTransfer.Flags().Var(&fromAddress, "from", "sender's one address, keystore must exist locally")
cmdEthTransfer.Flags().Var(&toAddress, "to", "the destination one address")
cmdEthTransfer.Flags().BoolVar(&dryRun, "dry-run", false, "do not send signed transaction")
cmdEthTransfer.Flags().BoolVar(&offlineSign, "offline-sign", false, "output offline signing")
cmdEthTransfer.Flags().BoolVar(&trueNonce, "true-nonce", false, "send transaction with on-chain nonce")
cmdEthTransfer.Flags().StringVar(&amount, "amount", "0", "amount to send (ONE)")
cmdEthTransfer.Flags().StringVar(&gasPrice, "gas-price", "100", "gas price to pay (NANO)")
cmdEthTransfer.Flags().StringVar(&gasLimit, "gas-limit", "", "gas limit")
cmdEthTransfer.Flags().StringVar(&inputNonce, "nonce", "", "set nonce for tx")
cmdEthTransfer.Flags().StringVar(&data, "data", "", "transaction data")
cmdEthTransfer.Flags().StringVar(&targetChain, "chain-id", "", "what chain ID to target")
cmdEthTransfer.Flags().Uint32Var(&timeout, "timeout", defaultTimeout, "set timeout in seconds. Set to 0 to not wait for confirm")
cmdEthTransfer.Flags().BoolVar(&userProvidesPassphrase, "passphrase", false, ppPrompt)
cmdEthTransfer.Flags().StringVar(&passphraseFilePath, "passphrase-file", "", "path to a file containing the passphrase")
RootCmd.AddCommand(cmdEthTransfer)
cmdOfflineSignEthTransfer := &cobra.Command{
Use: "offline-sign-eth-transfer",
Short: "Send a Offline Signed Ethereum transaction",
Args: cobra.ExactArgs(0),
Long: `
Send a offline signed transaction to the Woop blockchain (on the same shard)
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if givenFilePath == "" {
return fmt.Errorf("must give a offline-signed file")
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
var txLogs []*transactionLog
networkHandler := rpc.NewHTTPHandler(node)
openFile, err := os.Open(givenFilePath)
if err != nil {
return err
}
defer openFile.Close()
err = json.NewDecoder(openFile).Decode(&txLogs)
if err != nil {
return err
}
for _, txLog := range txLogs {
if len(txLog.Errors) > 0 {
continue
}
ctrlr := transaction.NewEthController(networkHandler, nil, nil, *chainName.chainID, ethOpts)
err := ctrlr.ExecuteRawTransaction(txLog.RawTxn)
if handlerForError(txLog, err) != nil {
txLog.Errors = append(txLog.Errors, err.Error())
continue
}
if txHash := ctrlr.TransactionHash(); txHash != nil {
txLog.TxHash = *txHash
}
txLog.Receipt = ctrlr.Receipt()["result"]
}
fmt.Println(common.ToJSONUnsafe(txLogs, true))
return nil
},
}
RootCmd.AddCommand(cmdOfflineSignEthTransfer)
}

@ -1,8 +1,8 @@
package cmd
import (
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/rpc"
)
func init() {

@ -3,18 +3,18 @@ package cmd
import (
"fmt"
"github.com/harmony-one/go-sdk/pkg/governance"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/harmony/accounts"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/governance"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/woop/accounts"
)
func init() {
cmdGovernance := &cobra.Command{
Use: "governance",
Short: "Interact with the Harmony spaces on https://snapshot.org",
Short: "Interact with the Woop spaces on https://snapshot.org",
Long: `
Support interaction with the Harmony governance space on Snapshot, especially for validators that do not want to import their account private key into either metamask or onewallet.
Support interaction with the Woop governance space on Snapshot, especially for validators that do not want to import their account private key into either metamask or onewallet.
`,
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()
@ -35,8 +35,9 @@ func commandVote() (cmd *cobra.Command) {
var choice string
var key string
var proposalType string
var privacy string
// var privacy string
var app string
var reason string
cmd = &cobra.Command{
Use: "vote-proposal",
@ -63,20 +64,22 @@ func commandVote() (cmd *cobra.Command) {
Proposal: proposal,
ProposalType: proposalType,
Choice: choice,
Privacy: privacy,
App: app,
From: account.Address.Hex(),
// Privacy: privacy,
App: app,
From: account.Address.Hex(),
Reason: reason,
})
},
}
cmd.Flags().StringVar(&key, "key", "", "Account name. Must first use (hmy keys import-private-key) to import.")
cmd.Flags().StringVar(&space, "space", "harmony-mainnet.eth", "Snapshot space")
cmd.Flags().StringVar(&key, "key", "", "Account name. Must first use (wiki keys import-private-key) to import.")
cmd.Flags().StringVar(&space, "space", "woop-mainnet.eth", "Snapshot space")
cmd.Flags().StringVar(&proposal, "proposal", "", "Proposal hash")
cmd.Flags().StringVar(&proposalType, "proposal-type", "single-choice", "Proposal type like single-choice, approval, quadratic, etc.")
cmd.Flags().StringVar(&choice, "choice", "", "Vote choice either as integer, list of integers (e.x. when using ranked choice voting), or string")
cmd.Flags().StringVar(&privacy, "privacy", "", "Vote privacy ex. shutter")
cmd.Flags().StringVar(&app, "app", "", "Voting app")
// cmd.Flags().StringVar(&privacy, "privacy", "", "Vote privacy e.x. shutter")
cmd.Flags().StringVar(&app, "app", "snapshot", "Voting app")
cmd.Flags().StringVar(&reason, "reason", "", "Reason for your choice")
cmd.Flags().BoolVar(&userProvidesPassphrase, "passphrase", false, ppPrompt)
cmd.MarkFlagRequired("key")

@ -13,13 +13,13 @@ import (
"github.com/tyler-smith/go-bip39"
"golang.org/x/crypto/ssh/terminal"
"github.com/harmony-one/go-sdk/pkg/account"
c "github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/keys"
"github.com/harmony-one/go-sdk/pkg/ledger"
"github.com/harmony-one/go-sdk/pkg/mnemonic"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/go-sdk/pkg/validation"
"github.com/woop-chain/go-sdk/pkg/account"
c "github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/keys"
"github.com/woop-chain/go-sdk/pkg/ledger"
"github.com/woop-chain/go-sdk/pkg/mnemonic"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/validation"
)
const (
@ -120,7 +120,7 @@ func keysSub() []*cobra.Command {
cmdLocation := &cobra.Command{
Use: "location",
Short: "Show where `hmy` keeps accounts & their keys",
Short: "Show where `wiki` keeps accounts & their keys",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println(store.DefaultLocation())
return nil
@ -144,7 +144,7 @@ func keysSub() []*cobra.Command {
Passphrase: passphrase,
}
if recoverFromMnemonic {
fmt.Fprintf(os.Stderr, "deprecated method: use `./hmy keys recover-from-mnemonic` instead.\n")
fmt.Fprintf(os.Stderr, "deprecated method: use `./wiki keys recover-from-mnemonic` instead.\n")
fmt.Println("Enter mnemonic to recover keys from")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
@ -341,7 +341,7 @@ func keysSub() []*cobra.Command {
Short: "Generates multiple bls keys for a given shard network configuration and then encrypts and saves the private key with a requested passphrase",
RunE: func(cmd *cobra.Command, args []string) error {
if err := validation.ValidateNodeConnection(node); err != nil {
fmt.Fprintf(os.Stderr, "Cannot connect to node %v, using Harmony mainnet endpoint %v\n",
fmt.Fprintf(os.Stderr, "Cannot connect to node %v, using Woop mainnet endpoint %v\n",
node, defaultMainnetEndpoint)
node = defaultMainnetEndpoint
}

@ -4,23 +4,24 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/harmony-one/go-sdk/pkg/address"
"net/http"
"os"
"path"
"regexp"
"strings"
"github.com/woop-chain/go-sdk/pkg/address"
color "github.com/fatih/color"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
rpcEth "github.com/harmony-one/go-sdk/pkg/rpc/eth"
rpcV1 "github.com/harmony-one/go-sdk/pkg/rpc/v1"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
rpcEth "github.com/woop-chain/go-sdk/pkg/rpc/eth"
rpcV1 "github.com/woop-chain/go-sdk/pkg/rpc/v1"
"github.com/woop-chain/go-sdk/pkg/sharding"
"github.com/woop-chain/go-sdk/pkg/store"
)
var (
@ -51,15 +52,15 @@ var (
}
// RootCmd is single entry point of the CLI
RootCmd = &cobra.Command{
Use: "hmy",
Short: "Harmony blockchain",
Use: "wiki",
Short: "Woop blockchain",
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if verbose {
common.EnableAllVerbose()
}
switch rpcPrefix {
case "hmy":
case "wiki":
rpc.Method = rpcV1.Method
case "eth":
rpc.Method = rpcEth.Method
@ -95,7 +96,7 @@ var (
}
} else if endpoint.Match([]byte(node)) {
chainName = endpointToChainID(node)
} else if strings.Contains(node, "api.harmony.one") {
} else if strings.Contains(node, "api.wikiwoop.com") {
chainName = chainIDWrapper{chainID: &common.Chain.MainNet}
} else {
chainName = chainIDWrapper{chainID: &common.Chain.TestNet}
@ -111,9 +112,9 @@ var (
return nil
},
Long: fmt.Sprintf(`
CLI interface to the Harmony blockchain
CLI interface to the Woop blockchain
%s`, g("Invoke 'hmy cookbook' for examples of the most common, important usages")),
%s`, g("Invoke 'wiki cookbook' for examples of the most common, important usages")),
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()
return nil
@ -122,7 +123,7 @@ CLI interface to the Harmony blockchain
)
func init() {
vS := "dump out debug information, same as env var HMY_ALL_DEBUG=true"
vS := "dump out debug information, same as env var WIKI_ALL_DEBUG=true"
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, vS)
RootCmd.PersistentFlags().StringVarP(&node, "node", "n", defaultNodeAddr, "<host>")
RootCmd.PersistentFlags().StringVarP(&rpcPrefix, "rpc-prefix", "r", defaultRpcPrefix, "<rpc>")
@ -161,10 +162,10 @@ func init() {
RootCmd.PersistentFlags().StringVar(&givenFilePath, "file", "", "Path to file for given command when applicable")
RootCmd.AddCommand(&cobra.Command{
Use: "docs",
Short: fmt.Sprintf("Generate docs to a local %s directory", hmyDocsDir),
Short: fmt.Sprintf("Generate docs to a local %s directory", wikiDocsDir),
RunE: func(cmd *cobra.Command, args []string) error {
cwd, _ := os.Getwd()
docDir := path.Join(cwd, hmyDocsDir)
docDir := path.Join(cwd, wikiDocsDir)
os.Mkdir(docDir, 0700)
doc.GenMarkdownTree(RootCmd, docDir)
return nil
@ -175,12 +176,12 @@ func init() {
var (
// VersionWrapDump meant to be set from main.go
VersionWrapDump = ""
cookbook = color.GreenString("hmy cookbook")
versionLink = "https://harmony.one/hmycli_ver"
cookbook = color.GreenString("wiki cookbook")
versionLink = "https://wikiwoop.com/wikicli_ver"
versionFormat = regexp.MustCompile("v[0-9]+-[a-z0-9]{7}")
)
// Execute kicks off the hmy CLI
// Execute kicks off the wiki CLI
func Execute() {
RootCmd.SilenceErrors = true
if err := RootCmd.Execute(); err != nil {

@ -9,25 +9,25 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
bls_core "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/keys"
"github.com/harmony-one/go-sdk/pkg/ledger"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/go-sdk/pkg/transaction"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/crypto/bls"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/shard"
"github.com/harmony-one/harmony/staking/effective"
staking "github.com/harmony-one/harmony/staking/types"
"github.com/pkg/errors"
"github.com/spf13/cobra"
bls_core "github.com/woop-chain/bls/ffi/go/bls"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/keys"
"github.com/woop-chain/go-sdk/pkg/ledger"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/transaction"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
"github.com/woop-chain/woop/common/denominations"
"github.com/woop-chain/woop/core"
"github.com/woop-chain/woop/crypto/bls"
"github.com/woop-chain/woop/numeric"
"github.com/woop-chain/woop/shard"
"github.com/woop-chain/woop/staking/effective"
staking "github.com/woop-chain/woop/staking/types"
)
const (
@ -184,7 +184,7 @@ func confirmTx(networkHandler *rpc.HTTPMessenger, confirmWaitTime uint32, txHash
for _, txError := range transactionErrors {
fmt.Println(txError.Error().Error())
}
fmt.Println("Try increasing the `timeout` or look for the transaction receipt with `hmy blockchain transaction-receipt <txHash>`")
fmt.Println("Try increasing the `timeout` or look for the transaction receipt with `wiki blockchain transaction-receipt <txHash>`")
return fmt.Errorf("could not confirm %s even after %d seconds", txHash, confirmWaitTime)
}
transactionErrors, _ := transaction.GetError(txHash, networkHandler)
@ -846,7 +846,7 @@ func init() {
Use: "staking",
Short: "newvalidator, editvalidator, delegate, undelegate or redelegate",
Long: `
Create a staking transaction, sign it, and send off to the Harmony blockchain
Create a staking transaction, sign it, and send off to the Woop blockchain
`,
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()

@ -10,15 +10,15 @@ import (
"strings"
"time"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/go-sdk/pkg/transaction"
"github.com/harmony-one/go-sdk/pkg/validation"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/core"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/go-sdk/pkg/sharding"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/transaction"
"github.com/woop-chain/go-sdk/pkg/validation"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/core"
"github.com/spf13/cobra"
)
@ -42,6 +42,7 @@ var (
transferFileFlags []transferFlags
timeout uint32
timeFormat = "2006-01-02 15:04:05.000000"
data string
)
type transactionLog struct {
@ -169,6 +170,11 @@ func handlerForTransaction(txLog *transactionLog) error {
gLimit = uint64(tempLimit)
}
dataByte, err := transaction.StringToByte(data)
if err != nil {
return handlerForError(txLog, err)
}
addr := toAddress.String()
txLog.TimeSigned = time.Now().UTC().Format(timeFormat) // Approximate time of signature
@ -177,7 +183,7 @@ func handlerForTransaction(txLog *transactionLog) error {
&addr,
fromShardID, toShardID,
amt, gPrice,
[]byte{},
dataByte,
)
if dryRun {
@ -336,7 +342,7 @@ func init() {
Short: "Create and send a transaction",
Args: cobra.ExactArgs(0),
Long: `
Create a transaction, sign it, and send off to the Harmony blockchain
Create a transaction, sign it, and send off to the Woop blockchain
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if offlineSign {
@ -414,6 +420,7 @@ Create a transaction, sign it, and send off to the Harmony blockchain
cmdTransfer.Flags().StringVar(&inputNonce, "nonce", "", "set nonce for tx")
cmdTransfer.Flags().Uint32Var(&fromShardID, "from-shard", 0, "source shard id")
cmdTransfer.Flags().Uint32Var(&toShardID, "to-shard", 0, "target shard id")
cmdTransfer.Flags().StringVar(&data, "data", "", "transaction data")
cmdTransfer.Flags().StringVar(&targetChain, "chain-id", "", "what chain ID to target")
cmdTransfer.Flags().Uint32Var(&timeout, "timeout", defaultTimeout, "set timeout in seconds. Set to 0 to not wait for confirm")
cmdTransfer.Flags().BoolVar(&userProvidesPassphrase, "passphrase", false, ppPrompt)
@ -449,7 +456,7 @@ Get Nonce From a Account
Short: "Send a Offline Signed transaction",
Args: cobra.ExactArgs(0),
Long: `
Send a offline signed to the Harmony blockchain
Send a offline signed transaction to the Woop blockchain
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if givenFilePath == "" {

@ -6,17 +6,17 @@ import (
"math/big"
"strings"
bls_core "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/harmony/crypto/bls"
"github.com/spf13/cobra"
bls_core "github.com/woop-chain/bls/ffi/go/bls"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/woop/crypto/bls"
)
func init() {
cmdUtilities := &cobra.Command{
Use: "utility",
Short: "common harmony blockchain utilities",
Short: "common woop blockchain utilities",
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()
return nil

@ -4,9 +4,9 @@ import (
"fmt"
"strconv"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/woop-chain/go-sdk/pkg/rpc"
)
var (

@ -7,9 +7,9 @@ import (
)
const (
hmyDocsDir = "hmy-docs"
wikiDocsDir = "wiki-docs"
defaultNodeAddr = "http://localhost:9500"
defaultRpcPrefix = "hmy"
defaultRpcPrefix = "wiki"
defaultMainnetEndpoint = "https://api.s0.t.hmny.io/"
)
@ -30,89 +30,88 @@ Note:
Examples:
%s
./hmy --node=[NODE] balances <SOME_ONE_ADDRESS>
./wiki --node=[NODE] balances <SOME_ONE_ADDRESS>
%s
./hmy --node=[NODE] blockchain transaction-by-hash <SOME_TX_HASH>
./wiki --node=[NODE] blockchain transaction-by-hash <SOME_TX_HASH>
%s
./hmy keys list
./wiki keys list
%s
./hmy --node=[NODE] transfer \
./wiki --node=[NODE] transfer \
--from <SOME_ONE_ADDRESS> --to <SOME_ONE_ADDRESS> \
--from-shard 0 --to-shard 1 --amount 200 --passphrase
%s
./hmy --node=[NODE] transfer --file <PATH_TO_JSON_FILE>
./wiki --node=[NODE] transfer --file <PATH_TO_JSON_FILE>
Check README for details on json file format.
%s
./hmy --node=[NODE] blockchain transaction-receipt <SOME_TX_HASH>
./wiki --node=[NODE] blockchain transaction-receipt <SOME_TX_HASH>
%s
./hmy keys recover-from-mnemonic <ACCOUNT_NAME> --passphrase
./wiki keys recover-from-mnemonic <ACCOUNT_NAME> --passphrase
%s
./hmy keys import-ks <PATH_TO_KEYSTORE_JSON>
./wiki keys import-ks <PATH_TO_KEYSTORE_JSON>
%s
./hmy keys import-private-key <secp256k1_PRIVATE_KEY>
./wiki keys import-private-key <secp256k1_PRIVATE_KEY>
%s
./hmy keys export-private-key <ACCOUNT_ADDRESS> --passphrase
./wiki keys export-private-key <ACCOUNT_ADDRESS> --passphrase
%s
./hmy keys generate-bls-key --bls-file-path <PATH_FOR_BLS_KEY_FILE>
./wiki keys generate-bls-key --bls-file-path <PATH_FOR_BLS_KEY_FILE>
%s
./hmy --node=[NODE] staking create-validator --amount 10 --validator-addr <SOME_ONE_ADDRESS> \
./wiki --node=[NODE] staking create-validator --amount 10 --validator-addr <SOME_ONE_ADDRESS> \
--bls-pubkeys <BLS_KEY_1>,<BLS_KEY_2>,<BLS_KEY_3> \
--identity foo --details bar --name baz --max-change-rate 0.1 --max-rate 0.1 --max-total-delegation 10 \
--min-self-delegation 10 --rate 0.1 --security-contact Leo --website harmony.one --passphrase
--min-self-delegation 10 --rate 0.1 --security-contact Leo --website wikiwoop.com --passphrase
%s
./hmy --node=[NODE] staking edit-validator \
./wiki --node=[NODE] staking edit-validator \
--validator-addr <SOME_ONE_ADDRESS> --identity foo --details bar \
--name baz --security-contact EK --website harmony.one \
--name baz --security-contact EK --website wikiwoop.com \
--min-self-delegation 0 --max-total-delegation 10 --rate 0.1\
--add-bls-key <SOME_BLS_KEY> --remove-bls-key <OTHER_BLS_KEY> --passphrase
%s
./hmy --node=[NODE] staking delegate \
./wiki --node=[NODE] staking delegate \
--delegator-addr <SOME_ONE_ADDRESS> --validator-addr <VALIDATOR_ONE_ADDRESS> \
--amount 10 --passphrase
%s
./hmy --node=[NODE] staking undelegate \
./wiki --node=[NODE] staking undelegate \
--delegator-addr <SOME_ONE_ADDRESS> --validator-addr <VALIDATOR_ONE_ADDRESS> \
--amount 10 --passphrase
%s
./hmy --node=[NODE] staking collect-rewards \
./wiki --node=[NODE] staking collect-rewards \
--delegator-addr <SOME_ONE_ADDRESS> --passphrase
%s
./hmy --node=[NODE] blockchain validator elected
./wiki --node=[NODE] blockchain validator elected
%s
./hmy --node=[NODE] blockchain utility-metrics
./wiki --node=[NODE] blockchain utility-metrics
%s
./hmy --node=[NODE] failures staking
./wiki --node=[NODE] failures staking
%s
./hmy --node=[NODE] utility shard-for-bls <BLS_PUBLIC_KEY>
./wiki --node=[NODE] utility shard-for-bls <BLS_PUBLIC_KEY>
%s
./hmy governance vote-proposal --space=[harmony-mainnet.eth] \
./wiki governance vote-proposal --space=[woop-mainnet.eth] \
--proposal=<PROPOSAL_IPFS_HASH> --proposal-type=[single-choice] \
--choice=<VOTING_CHOICE(S)> --app=[APP] --key=<ACCOUNT_ADDRESS_OR_NAME> \
--privacy=[PRIVACY TYPE]
PS: key must first use (hmy keys import-private-key) to import
--choice=<VOTING_CHOICE(S)> --app=[APP] --key=<ACCOUNT_ADDRESS_OR_NAME>
PS: key must first use (wiki keys import-private-key) to import
%s
./hmy command --net=testnet
./wiki command --net=testnet
`,
g("1. Check account balance on given chain"),
g("2. Check sent transaction"),

@ -1,4 +1,4 @@
module github.com/harmony-one/go-sdk
module github.com/woop-chain/go-sdk
go 1.14
@ -12,9 +12,9 @@ require (
github.com/ethereum/go-ethereum v1.9.23
github.com/fatih/color v1.9.0
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 // indirect
github.com/harmony-one/bls v0.0.7-0.20191214005344-88c23f91a8a9
github.com/harmony-one/harmony v1.10.2-0.20210123081216-6993b9ad0ca1
github.com/karalabe/hid v1.0.0
github.com/woop-chain/bls v0.0.7-0.20191214005344-88c23f91a8a9
github.com/woop-chain/woop v1.10.2-0.20210123081216-6993b9ad0ca1
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356
github.com/mattn/go-colorable v0.1.9
github.com/mitchellh/go-homedir v1.1.0
github.com/olekukonko/tablewriter v0.0.5 // indirect

@ -352,16 +352,16 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846/go.mod h1:YZcPnufUw70msUSudLvxcQOSpnZJgaMS9WIU8IGEtBg=
github.com/harmony-one/abool v1.0.1/go.mod h1:9sq0PJzb1SqRpKrpEV4Ttvm9WV5uud8sfrsPw3AIBJA=
github.com/harmony-one/bls v0.0.6/go.mod h1:ML9osB/z3hR9WAYZVj7qH+IP6oaPRPmshDbxrQyia7g=
github.com/harmony-one/bls v0.0.7-0.20191214005344-88c23f91a8a9 h1:mG6rcfYadQAkWJn5mnfRnJ4plNf2XNvuadiirLcsmr0=
github.com/harmony-one/bls v0.0.7-0.20191214005344-88c23f91a8a9/go.mod h1:ML9osB/z3hR9WAYZVj7qH+IP6oaPRPmshDbxrQyia7g=
github.com/harmony-one/harmony v1.10.2-0.20210123081216-6993b9ad0ca1 h1:bu87yqH7Vy5kN33Z9c3/fh5bWkiKBDDnlwY+i2qJook=
github.com/harmony-one/harmony v1.10.2-0.20210123081216-6993b9ad0ca1/go.mod h1:QsUfRGisvY6k1KvpzVeBI3VBdHhYLlpVQTEbzrMmw1U=
github.com/harmony-one/taggedrlp v0.1.4 h1:RZ+qy0VCzT+d/mTfq23gH3an5tSvxOhg6AddLDO6tKw=
github.com/harmony-one/taggedrlp v0.1.4/go.mod h1:osO5TRXLKdgCP+oj2J9qfqhywMOOA+4nP5q+o8nDSYA=
github.com/harmony-one/vdf v0.0.0-20190924175951-620379da8849/go.mod h1:EgNU7X5HLNBBho+OqCm1A1NrpD6xb1SHfi9pMCYaKKw=
github.com/woop-chain/gencodec v0.0.0-20190215044613-e6740dbdd846/go.mod h1:YZcPnufUw70msUSudLvxcQOSpnZJgaMS9WIU8IGEtBg=
github.com/woop-chain/abool v1.0.1/go.mod h1:9sq0PJzb1SqRpKrpEV4Ttvm9WV5uud8sfrsPw3AIBJA=
github.com/woop-chain/bls v0.0.6/go.mod h1:ML9osB/z3hR9WAYZVj7qH+IP6oaPRPmshDbxrQyia7g=
github.com/woop-chain/bls v0.0.7-0.20191214005344-88c23f91a8a9 h1:mG6rcfYadQAkWJn5mnfRnJ4plNf2XNvuadiirLcsmr0=
github.com/woop-chain/bls v0.0.7-0.20191214005344-88c23f91a8a9/go.mod h1:ML9osB/z3hR9WAYZVj7qH+IP6oaPRPmshDbxrQyia7g=
github.com/woop-chain/woop v1.10.2-0.20210123081216-6993b9ad0ca1 h1:bu87yqH7Vy5kN33Z9c3/fh5bWkiKBDDnlwY+i2qJook=
github.com/woop-chain/woop v1.10.2-0.20210123081216-6993b9ad0ca1/go.mod h1:QsUfRGisvY6k1KvpzVeBI3VBdHhYLlpVQTEbzrMmw1U=
github.com/woop-chain/taggedrlp v0.1.4 h1:RZ+qy0VCzT+d/mTfq23gH3an5tSvxOhg6AddLDO6tKw=
github.com/woop-chain/taggedrlp v0.1.4/go.mod h1:osO5TRXLKdgCP+oj2J9qfqhywMOOA+4nP5q+o8nDSYA=
github.com/woop-chain/vdf v0.0.0-20190924175951-620379da8849/go.mod h1:EgNU7X5HLNBBho+OqCm1A1NrpD6xb1SHfi9pMCYaKKw=
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@ -471,8 +471,6 @@ github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0=
github.com/karalabe/hid v1.0.0 h1:+/CIMNXhSU/zIJgnIvBD2nKHxS/bnRHhhs9xBryLpPo=
github.com/karalabe/hid v1.0.0/go.mod h1:Vr51f8rUOLYrfrWDFlV12GGQgM5AT8sVh+2fY4MPeu8=
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356 h1:I/yrLt2WilKxlQKCM52clh5rGzTKpVctGT1lH4Dc8Jw=
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=

@ -3,7 +3,7 @@ package account
import (
"testing"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/store"
)
func TestAccountGetsRemoved(t *testing.T) {

@ -3,9 +3,9 @@ package account
import (
"errors"
"github.com/harmony-one/go-sdk/pkg/keys"
"github.com/harmony-one/go-sdk/pkg/mnemonic"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/keys"
"github.com/woop-chain/go-sdk/pkg/mnemonic"
"github.com/woop-chain/go-sdk/pkg/store"
)
var (

@ -5,8 +5,8 @@ import (
"fmt"
"path/filepath"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/harmony/accounts"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/woop/accounts"
)
var (

@ -3,21 +3,22 @@ package account
import (
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"github.com/mitchellh/go-homedir"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/ethereum/go-ethereum/crypto"
"github.com/mitchellh/go-homedir"
"github.com/btcsuite/btcd/btcec"
mapset "github.com/deckarep/golang-set"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/mnemonic"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/mnemonic"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/woop/accounts/keystore"
)
// ImportFromPrivateKey allows import of an ECDSA private key

@ -5,9 +5,9 @@ import (
"os"
"path"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/mitchellh/go-homedir"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/store"
)
// RemoveAccount - removes an account from the keystore
@ -19,8 +19,8 @@ func RemoveAccount(name string) error {
}
uDir, _ := homedir.Dir()
hmyCLIDir := path.Join(uDir, common.DefaultConfigDirName, common.DefaultConfigAccountAliasesDirName)
accountDir := fmt.Sprintf("%s/%s", hmyCLIDir, name)
wikiCLIDir := path.Join(uDir, common.DefaultConfigDirName, common.DefaultConfigAccountAliasesDirName)
accountDir := fmt.Sprintf("%s/%s", wikiCLIDir, name)
os.RemoveAll(accountDir)
return nil

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/harmony-one/harmony/numeric"
"github.com/woop-chain/woop/numeric"
)
var (

@ -1,7 +1,7 @@
package common
import (
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/woop-chain/woop/accounts/keystore"
)
func KeyStoreForPath(p string) *keystore.KeyStore {

@ -4,11 +4,11 @@ import (
"errors"
"os"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/woop-chain/woop/accounts/keystore"
)
const (
DefaultConfigDirName = ".hmy_cli"
DefaultConfigDirName = ".wiki_cli"
DefaultConfigAccountAliasesDirName = "account-keys"
DefaultCommandAliasesDirName = "command"
DefaultPassphrase = ""
@ -28,13 +28,13 @@ var (
)
func init() {
if _, enabled := os.LookupEnv("HMY_RPC_DEBUG"); enabled != false {
if _, enabled := os.LookupEnv("WIKI_RPC_DEBUG"); enabled != false {
DebugRPC = true
}
if _, enabled := os.LookupEnv("HMY_TX_DEBUG"); enabled != false {
if _, enabled := os.LookupEnv("WIKI_TX_DEBUG"); enabled != false {
DebugTransaction = true
}
if _, enabled := os.LookupEnv("HMY_ALL_DEBUG"); enabled != false {
if _, enabled := os.LookupEnv("WIKI_ALL_DEBUG"); enabled != false {
EnableAllVerbose()
}
}

@ -3,8 +3,8 @@ package console
import (
"encoding/json"
"fmt"
"github.com/harmony-one/go-sdk/pkg/console/jsre"
"github.com/harmony-one/go-sdk/pkg/console/prompt"
"github.com/woop-chain/go-sdk/pkg/console/jsre"
"github.com/woop-chain/go-sdk/pkg/console/prompt"
"io"
"reflect"
"strings"

@ -4,18 +4,6 @@ import (
"encoding/hex"
"errors"
"fmt"
ethereum_rpc "github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/go-sdk/pkg/account"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/console/jsre"
"github.com/harmony-one/go-sdk/pkg/console/jsre/deps"
"github.com/harmony-one/go-sdk/pkg/console/prompt"
"github.com/harmony-one/go-sdk/pkg/console/web3ext"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/harmony-one/go-sdk/pkg/transaction"
"github.com/harmony-one/harmony/accounts"
"io"
"io/ioutil"
"math/big"
@ -29,6 +17,19 @@ import (
"syscall"
"time"
ethereum_rpc "github.com/ethereum/go-ethereum/rpc"
"github.com/woop-chain/go-sdk/pkg/account"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/console/jsre"
"github.com/woop-chain/go-sdk/pkg/console/jsre/deps"
"github.com/woop-chain/go-sdk/pkg/console/prompt"
"github.com/woop-chain/go-sdk/pkg/console/web3ext"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/go-sdk/pkg/store"
"github.com/woop-chain/go-sdk/pkg/transaction"
"github.com/woop-chain/woop/accounts"
"github.com/dop251/goja"
"github.com/mattn/go-colorable"
"github.com/peterh/liner"
@ -57,9 +58,9 @@ type Config struct {
Prompter prompt.UserPrompter // Input prompter to allow interactive user feedback (defaults to TerminalPrompter)
Printer io.Writer // Output writer to serialize any display strings to (defaults to os.Stdout)
Preload []string // Absolute paths to JavaScript files to preload
NodeUrl string // Hmy Node url
ShardId int // Hmy Shard ID
Net string // Hmy Network
NodeUrl string // Wiki Node url
ShardId int // Wiki Shard ID
Net string // Wiki Network
}
// Console is a JavaScript interpreted runtime environment. It is a fully fledged
@ -73,9 +74,9 @@ type Console struct {
histPath string // Absolute path to the console scrollback history
history []string // Scroll history maintained by the console
printer io.Writer // Output writer to serialize any display strings to
nodeUrl string // Hmy Node url
shardId int // Hmy Shard ID
net string // Hmy Network
nodeUrl string // Wiki Node url
shardId int // Wiki Shard ID
net string // Wiki Network
}
// New initializes a JavaScript interpreted runtime environment and sets defaults
@ -242,14 +243,14 @@ func (c *Console) initPersonal(vm *goja.Runtime, bridge *bridge) {
if personal == nil || c.prompter == nil {
return
}
personal.Set("getListAccounts", jsre.MakeCallback(vm, bridge.HmyGetListAccounts))
personal.Set("signTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmySignTransaction)))
personal.Set("sendTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmySendTransaction)))
personal.Set("lockAccount", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmyLockAccount)))
personal.Set("importRawKey", jsre.MakeCallback(vm, bridge.HmyImportRawKey))
personal.Set("unlockAccount", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmyUnlockAccount)))
personal.Set("newAccount", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmyNewAccount)))
personal.Set("sign", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmySign)))
personal.Set("getListAccounts", jsre.MakeCallback(vm, bridge.WikiGetListAccounts))
personal.Set("signTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiSignTransaction)))
personal.Set("sendTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiSendTransaction)))
personal.Set("lockAccount", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiLockAccount)))
personal.Set("importRawKey", jsre.MakeCallback(vm, bridge.WikiImportRawKey))
personal.Set("unlockAccount", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiUnlockAccount)))
personal.Set("newAccount", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiNewAccount)))
personal.Set("sign", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiSign)))
_, err := vm.RunString(`Object.defineProperty(personal, "listAccounts", {get: personal.getListAccounts});`)
if err != nil {
@ -263,8 +264,8 @@ func (c *Console) initEth(vm *goja.Runtime, bridge *bridge) {
return
}
eth.Set("sendTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmySendTransaction)))
eth.Set("signTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.HmySignTransaction)))
eth.Set("sendTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiSendTransaction)))
eth.Set("signTransaction", jsre.MakeCallback(vm, bridge.callbackProtected(bridge.WikiSignTransaction)))
}
func (c *Console) clearHistory() {
@ -318,7 +319,7 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
// Welcome show summary of current Geth instance and some metadata about the
// console's available modules.
func (c *Console) Welcome() {
message := "Welcome to the Hmy JavaScript console!\n\n"
message := "Welcome to the Wiki JavaScript console!\n\n"
// Print some generic Geth metadata
if res, err := c.jsre.Run(`
@ -326,7 +327,7 @@ func (c *Console) Welcome() {
try {
message += "coinbase: " + eth.coinbase + "\n";
} catch (err) {}
message += "at shard: " + hmy.shardID + "\n";
message += "at shard: " + wiki.shardID + "\n";
message += "at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")\n";
try {
message += " datadir: " + admin.datadir + "\n";
@ -530,7 +531,7 @@ func (b *bridge) callbackProtected(protectedFunc func(call jsre.Call) (goja.Valu
}
}
func (b *bridge) HmyGetListAccounts(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiGetListAccounts(call jsre.Call) (goja.Value, error) {
var accounts = []string{}
for _, name := range store.LocalAccounts() {
@ -544,7 +545,7 @@ func (b *bridge) HmyGetListAccounts(call jsre.Call) (goja.Value, error) {
return call.VM.ToValue(accounts), nil
}
func (b *bridge) HmySignTransaction(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiSignTransaction(call jsre.Call) (goja.Value, error) {
txObj := call.Arguments[0].ToObject(call.VM)
password := call.Arguments[1].String()
@ -553,6 +554,10 @@ func (b *bridge) HmySignTransaction(call jsre.Call) (goja.Value, error) {
gasLimit := getStringFromJsObjWithDefault(txObj, "gas", "1000000")
amount := getStringFromJsObjWithDefault(txObj, "value", "0")
gasPrice := getStringFromJsObjWithDefault(txObj, "gasPrice", "1")
input, err := transaction.StringToByte(getStringFromJsObjWithDefault(txObj, "data", ""))
if err != nil {
return nil, err
}
networkHandler := rpc.NewHTTPHandler(b.console.nodeUrl)
chanId, err := common.StringToChainID(b.console.net)
@ -598,7 +603,7 @@ func (b *bridge) HmySignTransaction(call jsre.Call) (goja.Value, error) {
toP,
uint32(b.console.shardId), uint32(b.console.shardId),
amt, gPrice,
[]byte{},
input,
)
if err != nil {
return nil, err
@ -623,7 +628,7 @@ func (b *bridge) HmySignTransaction(call jsre.Call) (goja.Value, error) {
}), nil
}
func (b *bridge) HmySendTransaction(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiSendTransaction(call jsre.Call) (goja.Value, error) {
txObj := call.Arguments[0].ToObject(call.VM)
password := ""
if len(call.Arguments) > 1 {
@ -635,6 +640,10 @@ func (b *bridge) HmySendTransaction(call jsre.Call) (goja.Value, error) {
gasLimit := getStringFromJsObjWithDefault(txObj, "gas", "1000000")
amount := getStringFromJsObjWithDefault(txObj, "value", "0")
gasPrice := getStringFromJsObjWithDefault(txObj, "gasPrice", "1")
input, err := transaction.StringToByte(getStringFromJsObjWithDefault(txObj, "data", ""))
if err != nil {
return nil, err
}
networkHandler := rpc.NewHTTPHandler(b.console.nodeUrl)
chanId, err := common.StringToChainID(b.console.net)
@ -680,7 +689,7 @@ func (b *bridge) HmySendTransaction(call jsre.Call) (goja.Value, error) {
toP,
uint32(b.console.shardId), uint32(b.console.shardId),
amt, gPrice,
[]byte{},
input,
)
if err != nil {
return nil, err
@ -689,7 +698,7 @@ func (b *bridge) HmySendTransaction(call jsre.Call) (goja.Value, error) {
return call.VM.ToValue(*ctrlr.TransactionHash()), nil
}
func (b *bridge) HmyLockAccount(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiLockAccount(call jsre.Call) (goja.Value, error) {
address := call.Arguments[0].String()
_, _, err := store.LockKeystore(address)
@ -700,7 +709,7 @@ func (b *bridge) HmyLockAccount(call jsre.Call) (goja.Value, error) {
return goja.Null(), nil
}
func (b *bridge) HmyImportRawKey(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiImportRawKey(call jsre.Call) (goja.Value, error) {
privateKey := call.Arguments[0].String()
password := call.Arguments[1].String()
@ -712,7 +721,7 @@ func (b *bridge) HmyImportRawKey(call jsre.Call) (goja.Value, error) {
return call.VM.ToValue(name), nil
}
func (b *bridge) HmyUnlockAccount(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiUnlockAccount(call jsre.Call) (goja.Value, error) {
if len(call.Arguments) < 3 {
return nil, errors.New("arguments < 3")
}
@ -728,11 +737,11 @@ func (b *bridge) HmyUnlockAccount(call jsre.Call) (goja.Value, error) {
return goja.Null(), nil
}
func (b *bridge) HmyNewAccount(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiNewAccount(call jsre.Call) (goja.Value, error) {
return goja.Null(), nil
}
func (b *bridge) HmySign(call jsre.Call) (goja.Value, error) {
func (b *bridge) WikiSign(call jsre.Call) (goja.Value, error) {
dataToSign := call.Arguments[0].String()
addressStr := call.Arguments[1].String()
password := call.Arguments[2].String()

@ -17,7 +17,7 @@ var Modules = map[string]string{
"txpool": TxpoolJs,
"les": LESJs,
"vflux": VfluxJs,
"hmy": HmyJs,
"wiki": WikiJs,
}
const ChequebookJs = `
@ -904,9 +904,9 @@ web3._extend({
});
`
const HmyJs = `
const WikiJs = `
web3._extend({
property: 'hmy',
property: 'wiki',
methods:
[

@ -2,11 +2,12 @@ package console
import (
"fmt"
"github.com/dop251/goja"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/harmony-one/harmony/crypto/hash"
"strconv"
"github.com/dop251/goja"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
"github.com/woop-chain/woop/crypto/hash"
)
func signMessageWithPassword(keyStore *keystore.KeyStore, account accounts.Account, password string, data []byte) (sign []byte, err error) {

@ -3,8 +3,8 @@ package governance
import (
"fmt"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
)
func DoVote(keyStore *keystore.KeyStore, account accounts.Account, vote Vote) error {

@ -125,6 +125,12 @@ func (typedData *TypedData) String() (string, error) {
Types core.Types `json:"types"`
Message core.TypedDataMessage `json:"message"`
}
var ts uint64
var err error
if ts, err = toUint64(typedData.Message["timestamp"]); err != nil {
// should not happen
return "", errors.Wrapf(err, "timestamp")
}
formatted := data{
Domain: domain{
Name: typedData.Domain.Name,
@ -136,14 +142,35 @@ func (typedData *TypedData) String() (string, error) {
Message: core.TypedDataMessage{
"space": typedData.Message["space"],
"proposal": typedData.Message["proposal"],
"choice": toUint64(typedData.Message["choice"]),
"choice": typedData.Message["choice"],
"app": typedData.Message["app"],
"reason": typedData.Message["reason"],
// this conversion is required to stop snapshot
// from complaining about `wrong envelope format`
"timestamp": toUint64(typedData.Message["timestamp"]),
"timestamp": ts,
"from": typedData.Message["from"],
},
}
// same comment as above
if typedData.Types["Vote"][4].Type == "uint32" {
if choice, err := toUint64(typedData.Message["choice"]); err != nil {
return "", errors.Wrapf(err, "choice")
} else {
formatted.Message["choice"] = choice
}
// prevent hex choice interpretation
} else if typedData.Types["Vote"][4].Type == "uint32[]" {
arr := typedData.Message["choice"].([]interface{})
res := make([]uint64, len(arr))
for i, a := range arr {
if c, err := toUint64(a); err != nil {
return "", errors.Wrapf(err, "choice member %d", i)
} else {
res[i] = c
}
}
formatted.Message["choice"] = res
}
message, err := json.Marshal(formatted)
if err != nil {
return "", err
@ -152,11 +179,13 @@ func (typedData *TypedData) String() (string, error) {
}
}
func toUint64(x interface{}) uint64 {
func toUint64(x interface{}) (uint64, error) {
y, ok := x.(*math.HexOrDecimal256)
if !ok {
panic("not a *math.HexOrDecimal256")
return 0, errors.New(
fmt.Sprintf("%+v is not a *math.HexOrDecimal256", x),
)
}
z := (*big.Int)(y)
return z.Uint64()
}
return z.Uint64(), nil
}

@ -4,10 +4,10 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/harmony-one/harmony/crypto/hash"
"github.com/pkg/errors"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
"github.com/woop-chain/woop/crypto/hash"
)
func encodeForSigning(typedData *TypedData) ([]byte, error) {

@ -7,8 +7,8 @@ import (
"testing"
"github.com/btcsuite/btcd/btcec"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/harmony/accounts"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/woop/accounts"
)
func TestSigning(t *testing.T) {
@ -28,7 +28,7 @@ func TestSigning(t *testing.T) {
}
// add a temporary key store with the below private key
location := path.Join(os.TempDir(), "hmy-test")
location := path.Join(os.TempDir(), "wiki-test")
keyStore := common.KeyStoreForPath(location)
privateKeyBytes, _ := hex.DecodeString("91c8360c4cb4b5fac45513a7213f31d4e4a7bfcb4630e9fbf074f42a203ac0b9")
sk, _ := btcec.PrivKeyFromBytes(btcec.S256(), privateKeyBytes)

@ -2,6 +2,7 @@ package governance
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
@ -12,15 +13,24 @@ import (
"github.com/pkg/errors"
)
var (
voteToNumberMapping = map[string]int64{
"for": 1,
"against": 2,
"abstain": 3,
}
)
type Vote struct {
From string // --key
Space string // --space
Proposal string // --proposal
ProposalType string // --proposal-type
Choice string // --choice
Privacy string // --privacy
App string // --app
Timestamp int64 // not exposed to the end user
// Privacy string // --privacy
App string // --app
Reason string // --reason
Timestamp int64 // not exposed to the end user
}
func (v *Vote) ToEIP712() (*TypedData, error) {
@ -64,35 +74,70 @@ func (v *Vote) ToEIP712() (*TypedData, error) {
proposal = v.Proposal
}
// vote type, vote choice and vote privacy
// vote type, vote choice and vote privacy (TODO)
// choice needs to be converted into its native format for envelope
var choice interface{}
// The space between [1, 2, 3] does not matter since we parse it
// wiki governance vote-proposal \
// --space woop-mainnet.eth \
// --proposal 0xTruncated \
// --proposal-type {"approval","ranked-choice"} \
// --choice "[1, 2, 3]" \
// --key <name of pk>
if v.ProposalType == "approval" || v.ProposalType == "ranked-choice" {
myType = append(myType, eip712.Type{
Name: "choice",
Type: "uint32[]",
})
var is []int
var is []int64
if err := json.Unmarshal([]byte(v.Choice), &is); err == nil {
choice = is
local := make([]interface{}, len(is))
for i := range is {
local[i] = math.NewHexOrDecimal256(is[i])
}
choice = local
} else {
return nil, errors.Wrapf(err,
"unexpected value of choice %s (expected uint32[])", choice,
)
}
// The space between --choice {value} does not matter to snapshot.org
// But for comparing with the snapshot-js library, remove it
// wiki governance vote-proposal \
// --space woop-mainnet.eth \
// --proposal 0xTruncated \
// # either quadratic or weighted
// --proposal-type {"quadratic","weighted"} \
// # 20, 20, 40 of my vote (total 80) goes to 1, 2, 3 - note the single / double quotes
// --choice '{"1":20,"2":20,"3":40}' \
// --key <name of pk>
} else if v.ProposalType == "quadratic" || v.ProposalType == "weighted" {
myType = append(myType, eip712.Type{
Name: "choice",
Type: "string",
})
choice = v.Choice
} else if v.Privacy == "shutter" {
myType = append(myType, eip712.Type{
Name: "choice",
Type: "string",
})
choice = v.Choice
} else {
// TODO Untested
// wiki governance vote-proposal \
// --space woop-mainnet.eth \
// --proposal 0xTruncated \
// --proposal-type ANY \
// --choice "unknown-format" \
// --key <name of pk>
// --privacy shutter
// } else if v.Privacy == "shutter" {
// myType = append(myType, eip712.Type{
// Name: "choice",
// Type: "string",
// })
// choice = v.Choice
// wiki governance vote-proposal \
// --space woop-mainnet.eth \
// --proposal 0xTruncated \
// --proposal-type single-choice \
// --choice 1 \
// --key <name of pk>
} else if v.ProposalType == "single-choice" {
myType = append(myType, eip712.Type{
Name: "choice",
Type: "uint32",
@ -104,19 +149,53 @@ func (v *Vote) ToEIP712() (*TypedData, error) {
} else {
choice = math.NewHexOrDecimal256(int64(x))
}
// wiki governance vote-proposal \
// --space woop-mainnet.eth \
// --proposal 0xTruncated \
// --proposal-type basic \
// # any character case works
// --choice {aBstAin/agAiNst/for} \
// --key <name of pk>
} else if v.ProposalType == "basic" {
myType = append(myType, eip712.Type{
Name: "choice",
Type: "uint32",
})
if number, ok := voteToNumberMapping[strings.ToLower(v.Choice)]; ok {
choice = math.NewHexOrDecimal256(number)
} else {
return nil, errors.New(
fmt.Sprintf(
"unknown basic choice %s",
v.Choice,
),
)
}
} else {
return nil, errors.New(
fmt.Sprintf(
"unknown proposal type %s",
v.ProposalType,
),
)
}
// order matters so this is added last
// order matters so these are added last
myType = append(myType, eip712.Type{
Name: "reason",
Type: "string",
})
myType = append(myType, eip712.Type{
Name: "app",
Type: "string",
})
// metadata is skipped in this code intentionally
if v.Timestamp == 0 {
v.Timestamp = time.Now().Unix()
}
typedData := TypedData{
return &TypedData{
eip712.TypedData{
Domain: eip712.TypedDataDomain{
Name: name,
@ -142,11 +221,10 @@ func (v *Vote) ToEIP712() (*TypedData, error) {
"timestamp": math.NewHexOrDecimal256(v.Timestamp),
"proposal": proposal,
"choice": choice,
"reason": v.Reason,
"app": v.App,
},
PrimaryType: "Vote",
},
}
return &typedData, nil
}, nil
}

@ -16,17 +16,17 @@ import (
"path"
"strings"
bls_core "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/harmony-one/go-sdk/pkg/validation"
"github.com/harmony-one/harmony/crypto/bls"
"github.com/harmony-one/harmony/crypto/hash"
"github.com/harmony-one/harmony/staking/types"
bls_core "github.com/woop-chain/bls/ffi/go/bls"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/sharding"
"github.com/woop-chain/go-sdk/pkg/validation"
"github.com/woop-chain/woop/crypto/bls"
"github.com/woop-chain/woop/crypto/hash"
"github.com/woop-chain/woop/staking/types"
"golang.org/x/crypto/ssh/terminal"
)
//BlsKey - struct to represent bls key data
// BlsKey - struct to represent bls key data
type BlsKey struct {
PrivateKey *bls_core.SecretKey
PublicKey *bls_core.PublicKey
@ -37,7 +37,7 @@ type BlsKey struct {
ShardPublicKey *bls.SerializedPublicKey
}
//Initialize - initialize a bls key and assign a random private bls key if not already done
// Initialize - initialize a bls key and assign a random private bls key if not already done
func (blsKey *BlsKey) Initialize() {
if blsKey.PrivateKey == nil {
blsKey.PrivateKey = bls.RandPrivateKey()
@ -47,7 +47,7 @@ func (blsKey *BlsKey) Initialize() {
}
}
//Reset - resets the currently assigned private and public key fields
// Reset - resets the currently assigned private and public key fields
func (blsKey *BlsKey) Reset() {
blsKey.PrivateKey = nil
blsKey.PrivateKeyHex = ""

@ -7,8 +7,8 @@ import (
"strings"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/woop/accounts/keystore"
// "github.com/ethereum/go-ethereum/crypto"
@ -17,33 +17,33 @@ import (
func checkAndMakeKeyDirIfNeeded() string {
userDir, _ := homedir.Dir()
hmyCLIDir := path.Join(userDir, ".hmy_cli", "keystore")
if _, err := os.Stat(hmyCLIDir); os.IsNotExist(err) {
wikiCLIDir := path.Join(userDir, ".wiki_cli", "keystore")
if _, err := os.Stat(wikiCLIDir); os.IsNotExist(err) {
// Double check with Leo what is right file persmission
os.Mkdir(hmyCLIDir, 0700)
os.Mkdir(wikiCLIDir, 0700)
}
return hmyCLIDir
return wikiCLIDir
}
func ListKeys(keystoreDir string) {
hmyCLIDir := checkAndMakeKeyDirIfNeeded()
wikiCLIDir := checkAndMakeKeyDirIfNeeded()
scryptN := keystore.StandardScryptN
scryptP := keystore.StandardScryptP
ks := keystore.NewKeyStore(hmyCLIDir, scryptN, scryptP)
ks := keystore.NewKeyStore(wikiCLIDir, scryptN, scryptP)
// keystore.KeyStore
allAccounts := ks.Accounts()
fmt.Printf("Harmony Address:%s File URL:\n", strings.Repeat(" ", ethCommon.AddressLength*2))
fmt.Printf("Woop Address:%s File URL:\n", strings.Repeat(" ", ethCommon.AddressLength*2))
for _, account := range allAccounts {
fmt.Printf("%s\t\t %s\n", address.ToBech32(account.Address), account.URL)
}
}
func AddNewKey(password string) {
hmyCLIDir := checkAndMakeKeyDirIfNeeded()
wikiCLIDir := checkAndMakeKeyDirIfNeeded()
scryptN := keystore.StandardScryptN
scryptP := keystore.StandardScryptP
ks := keystore.NewKeyStore(hmyCLIDir, scryptN, scryptP)
ks := keystore.NewKeyStore(wikiCLIDir, scryptN, scryptP)
account, err := ks.NewAccount(password)
if err != nil {
fmt.Printf("new account error: %v\n", err)

@ -8,7 +8,7 @@ import (
"github.com/tyler-smith/go-bip39"
)
// FromMnemonicSeedAndPassphrase mimics the Harmony JS sdk in deriving the
// FromMnemonicSeedAndPassphrase mimics the Woop JS sdk in deriving the
// private, public key pair from the mnemonic, its index, and empty string password.
// Note that an index k would be the k-th key generated using the same mnemonic.
func FromMnemonicSeedAndPassphrase(mnemonic string, index int) (*secp256k1.PrivateKey, *secp256k1.PublicKey) {

@ -13,9 +13,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/harmony/core/types"
staking "github.com/harmony-one/harmony/staking/types"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/woop/core/types"
staking "github.com/woop-chain/woop/staking/types"
)
var (
@ -36,7 +36,7 @@ func getLedger() *NanoS {
return nanos
}
//ProcessAddressCommand list the address associated with Ledger Nano S
// ProcessAddressCommand list the address associated with Ledger Nano S
func GetAddress() string {
n := getLedger()
oneAddr, err := n.GetAddress()
@ -48,7 +48,7 @@ func GetAddress() string {
return oneAddr
}
//ProcessAddressCommand list the address associated with Ledger Nano S
// ProcessAddressCommand list the address associated with Ledger Nano S
func ProcessAddressCommand() {
n := getLedger()
oneAddr, err := n.GetAddress()

@ -6,8 +6,9 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/karalabe/hid"
"io"
"github.com/karalabe/usb"
)
const (
@ -207,12 +208,22 @@ func (n *NanoS) GetAddress() (oneAddr string, err error) {
}
func (n *NanoS) SignTxn(txn []byte) (sig [signatureSize]byte, err error) {
buf := bytes.NewBuffer(txn)
var resp []byte
var p1 byte = p1More
resp, err = n.Exchange(cmdSignTx, p1, p2SignHash, txn)
if err != nil {
return [signatureSize]byte{}, err
for buf.Len() > 0 {
var p1 byte = p1More
var p2 byte = p2SignHash
if resp == nil {
p1 = p1First
}
if buf.Len() < packetSize {
p2 = p2Finish
}
resp, err = n.Exchange(cmdSignTx, p1, p2, buf.Next(packetSize))
if err != nil {
return [signatureSize]byte{}, err
}
}
copy(sig[:], resp)
@ -262,11 +273,14 @@ func OpenNanoS() (*NanoS, error) {
)
// search for Nano S
devices := hid.Enumerate(ledgerVendorID, ledgerNanoSProductID)
devices, err := usb.EnumerateHid(ledgerVendorID, ledgerNanoSProductID)
if err != nil {
return nil, err
}
if len(devices) == 0 {
return nil, errors.New("Nano S not detected")
return nil, errors.New("nano S not detected")
} else if len(devices) > 1 {
return nil, errors.New("Unexpected error -- Is the one wallet app running?")
return nil, errors.New("detected multiple Nano S devices")
}
// open the device

@ -3,7 +3,7 @@ package v1
import (
"fmt"
rpcCommon "github.com/harmony-one/go-sdk/pkg/rpc/common"
rpcCommon "github.com/woop-chain/go-sdk/pkg/rpc/common"
)
const (

@ -3,13 +3,13 @@ package rpc
import (
"fmt"
rpcCommon "github.com/harmony-one/go-sdk/pkg/rpc/common"
rpcV1 "github.com/harmony-one/go-sdk/pkg/rpc/v1"
"github.com/pkg/errors"
rpcCommon "github.com/woop-chain/go-sdk/pkg/rpc/common"
rpcV1 "github.com/woop-chain/go-sdk/pkg/rpc/v1"
)
var (
RPCPrefix = "hmy"
RPCPrefix = "wiki"
Method rpcCommon.RpcEnumList = rpcV1.Method
)

@ -8,7 +8,7 @@ import (
"github.com/valyala/fasthttp"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/common"
)
var (

@ -3,11 +3,11 @@ package v1
import (
"fmt"
rpcCommon "github.com/harmony-one/go-sdk/pkg/rpc/common"
rpcCommon "github.com/woop-chain/go-sdk/pkg/rpc/common"
)
const (
prefix = "hmy"
prefix = "wiki"
)
// Method is a list of known RPC methods

@ -5,10 +5,10 @@ import (
"encoding/json"
"fmt"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/numeric"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/woop/common/denominations"
"github.com/woop-chain/woop/numeric"
)
var (

@ -7,21 +7,21 @@ import (
"path"
"time"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
c "github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/pkg/errors"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
c "github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
homedir "github.com/mitchellh/go-homedir"
)
func init() {
uDir, _ := homedir.Dir()
hmyCLIDir := path.Join(uDir, common.DefaultConfigDirName, common.DefaultConfigAccountAliasesDirName)
if _, err := os.Stat(hmyCLIDir); os.IsNotExist(err) {
os.MkdirAll(hmyCLIDir, 0700)
wikiCLIDir := path.Join(uDir, common.DefaultConfigDirName, common.DefaultConfigAccountAliasesDirName)
if _, err := os.Stat(wikiCLIDir); os.IsNotExist(err) {
os.MkdirAll(wikiCLIDir, 0700)
}
}

@ -9,15 +9,15 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/ledger"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/numeric"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/ledger"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
"github.com/woop-chain/woop/common/denominations"
"github.com/woop-chain/woop/core/types"
"github.com/woop-chain/woop/numeric"
)
var (
@ -205,7 +205,6 @@ func (C *Controller) setAmount(amount numeric.Dec) {
return
}
}
C.transactionForRPC.params["transfer-amount"] = amountInAtto
}

@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/woop-chain/go-sdk/pkg/rpc"
)
var (

@ -7,13 +7,13 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/accounts/keystore"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/numeric"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/common"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/woop/accounts"
"github.com/woop-chain/woop/accounts/keystore"
"github.com/woop-chain/woop/core/types"
"github.com/woop-chain/woop/numeric"
)
type ethTransactionForRPC struct {
@ -134,34 +134,37 @@ func (C *EthController) setAmount(amount numeric.Dec) {
})
return
}
balanceRPCReply, err := C.messenger.SendRPC(
rpc.Method.GetBalance,
p{address.ToBech32(C.sender.account.Address), "latest"},
)
if err != nil {
C.executionError = err
return
}
currentBalance, _ := balanceRPCReply["result"].(string)
bal, _ := new(big.Int).SetString(currentBalance[2:], 16)
balance := numeric.NewDecFromBigInt(bal)
gasAsDec := C.transactionForRPC.params["gas-price"].(numeric.Dec)
gasAsDec = gasAsDec.Mul(numeric.NewDec(int64(C.transactionForRPC.params["gas-limit"].(uint64))))
amountInAtto := amount.Mul(oneAsDec)
total := amountInAtto.Add(gasAsDec)
if total.GT(balance) {
balanceInOne := balance.Quo(oneAsDec)
C.executionError = ErrBadTransactionParam
errorMsg := fmt.Sprintf(
"insufficient balance of %s in shard %d for the requested transfer of %s",
balanceInOne.String(), C.transactionForRPC.params["from-shard"].(uint32), amount.String(),
if !C.Behavior.OfflineSign {
balanceRPCReply, err := C.messenger.SendRPC(
rpc.Method.GetBalance,
p{address.ToBech32(C.sender.account.Address), "latest"},
)
C.transactionErrors = append(C.transactionErrors, &Error{
ErrMessage: &errorMsg,
TimestampOfRejection: time.Now().Unix(),
})
return
if err != nil {
C.executionError = err
return
}
currentBalance, _ := balanceRPCReply["result"].(string)
bal, _ := new(big.Int).SetString(currentBalance[2:], 16)
balance := numeric.NewDecFromBigInt(bal)
if total.GT(balance) {
balanceInOne := balance.Quo(oneAsDec)
C.executionError = ErrBadTransactionParam
errorMsg := fmt.Sprintf(
"insufficient balance of %s in shard %d for the requested transfer of %s",
balanceInOne.String(), C.transactionForRPC.params["from-shard"].(uint32), amount.String(),
)
C.transactionErrors = append(C.transactionErrors, &Error{
ErrMessage: &errorMsg,
TimestampOfRejection: time.Now().Unix(),
})
return
}
}
C.transactionForRPC.params["transfer-amount"] = amountInAtto
}
@ -304,4 +307,10 @@ func (C *EthController) ExecuteEthTransaction(
return C.executionError
}
// TODO: add logic to create staking transactions in the SDK.
func (C *EthController) ExecuteRawTransaction(txn string) error {
C.transactionForRPC.signature = &txn
C.sendSignedTx()
C.txConfirmation()
return C.executionError
}

@ -3,10 +3,10 @@ package transaction
import (
"math/big"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/go-sdk/pkg/rpc"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/numeric"
"github.com/woop-chain/go-sdk/pkg/address"
"github.com/woop-chain/go-sdk/pkg/rpc"
"github.com/woop-chain/woop/core/types"
"github.com/woop-chain/woop/numeric"
)
// NewTransaction - create a new Transaction based on supplied params

@ -0,0 +1,17 @@
package transaction
import (
"encoding/hex"
"fmt"
"strings"
)
func StringToByte(dataStr string) ([]byte, error) {
if len(dataStr) == 0 {
return []byte{}, nil
}
if !strings.HasPrefix(dataStr, "0x") {
return nil, fmt.Errorf("invalid data literal: %q", dataStr)
}
return hex.DecodeString(dataStr[2:])
}

@ -3,7 +3,7 @@ package validation
import (
"testing"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/woop-chain/go-sdk/pkg/sharding"
)
func TestIsValidAddress(t *testing.T) {

@ -2,7 +2,7 @@
set -ieu
source ../harmony/scripts/setup_bls_build_flags.sh
source ../woop/scripts/setup_bls_build_flags.sh
sender='one1yc06ghr2p8xnl2380kpfayweguuhxdtupkhqzw'
receiver='one1q6gkzcap0uruuu8r6sldxuu47pd4ww9w9t7tg6'
@ -21,7 +21,7 @@ for iter in $(seq 100); do
value=$(c "${iter}/100")
bump=$(c "${value}+${rand}")
amount=$(printf "%.2f" ${bump})
./hmy --node=${shard_zero} \
./wiki --node=${shard_zero} \
transfer --from ${sender} --to ${receiver} \
--from-shard 0 --to-shard 0 --amount ${amount} \
--passphrase='' &

@ -9,19 +9,19 @@ Due to a possible Nonce mismatch, it is recommended to NOT have 1 'from' address
appear in multiple CSV files that are ran at the same time.
Example:
./hmy-csv.py /path/to/csv/file.csv --node https://api.s0.t.hmny.io/
./hmy-csv.py /path/to/csv/file.csv --fast -n https://api.s0.t.hmny.io/
./hmy-csv.py /path/to/csv/file.csv --fast --use-default-passphrase --yes -n https://api.s0.t.hmny.io/
./hmy-csv.py /path/to/csv/file.csv --fast --use-default-passphrase --yes --batch-size 100 -n https://api.s0.t.hmny.io/
./wiki-csv.py /path/to/csv/file.csv --node https://api.s0.t.hmny.io/
./wiki-csv.py /path/to/csv/file.csv --fast -n https://api.s0.t.hmny.io/
./wiki-csv.py /path/to/csv/file.csv --fast --use-default-passphrase --yes -n https://api.s0.t.hmny.io/
./wiki-csv.py /path/to/csv/file.csv --fast --use-default-passphrase --yes --batch-size 100 -n https://api.s0.t.hmny.io/
Sample CSV file:
https://docs.google.com/spreadsheets/d/1nkF8N16S3y28cn7SM1cYJca8lzHPOzyR42S1V-OOAeQ/edit?usp=sharing
For detail help message:
./hmy-csv.py --help
./wiki-csv.py --help
Install with:
curl -O https://raw.githubusercontent.com/harmony-one/go-sdk/master/scripts/hmy-csv.py && chmod +x hmy-csv.py
curl -O https://raw.githubusercontent.com/woop-chain/go-sdk/master/scripts/wiki-csv.py && chmod +x wiki-csv.py
"""
import sys
import time
@ -36,7 +36,7 @@ import json
import ssl
script_directory = os.path.dirname(os.path.realpath(__file__))
_hmy_call_and_prefix = [f"{script_directory}/hmy"]
_wiki_call_and_prefix = [f"{script_directory}/wiki"]
chain_id_options = {"mainnet", "testnet", "stressnet", "partner", "dryrun"}
default_passphrase = ""
@ -57,19 +57,19 @@ class Typgpy(str):
UNDERLINE = '\033[4m'
def _hmy(cli_args, timeout=200):
def _wiki(cli_args, timeout=200):
"""
Helper function to call the CLI with the given args.
Assumes `_setup_hmy` has been called prior to using this function.
Assumes `_setup_wiki` has been called prior to using this function.
Raises subprocess.CalledProcessError if call errored.
"""
assert isinstance(cli_args, list)
hmy_and_args = _hmy_call_and_prefix + [str(x) for x in cli_args]
wiki_and_args = _wiki_call_and_prefix + [str(x) for x in cli_args]
if args.verbose:
hmy_and_args.append("--verbose")
return subprocess.check_output(hmy_and_args, env=os.environ, timeout=timeout).decode()
wiki_and_args.append("--verbose")
return subprocess.check_output(wiki_and_args, env=os.environ, timeout=timeout).decode()
def get_shard_count(node):
@ -79,7 +79,7 @@ def get_shard_count(node):
Will raise a KeyError if the RPC returns back an error.
Will raise a subprocess.CalledProcessError if CLI errored.
"""
response = _hmy(["utility", "shards", "-n", node])
response = _wiki(["utility", "shards", "-n", node])
return len(json.loads(response)['result'])
@ -102,7 +102,7 @@ def send_transactions(transactions, batch_size, node, chain_id, timeout=40, fast
for i in range(0, len(transactions), batch_size):
batch_tx = transactions[i: i + batch_size]
temp_file = f"/tmp/hmy-csv-{hash(str(batch_tx))}.json"
temp_file = f"/tmp/wiki-csv-{hash(str(batch_tx))}.json"
batch_log_file = f"{script_directory}/batch_tx_{time.time()}.log"
with open(temp_file, "w") as f:
json.dump(batch_tx, f) # Assume to work since `transactions` should be built by `parse_csv`
@ -110,15 +110,15 @@ def send_transactions(transactions, batch_size, node, chain_id, timeout=40, fast
print(
f"{Typgpy.OKBLUE}Sending a batch of {Typgpy.OKGREEN}{len(batch_tx)}{Typgpy.OKBLUE} transaction(s){Typgpy.ENDC}")
print(f"{Typgpy.OKBLUE}Logs for this batch will be at {Typgpy.OKGREEN}{batch_log_file}{Typgpy.ENDC}")
hmy_args = ["transfer", "--file", temp_file, "--node", node]
wiki_args = ["transfer", "--file", temp_file, "--node", node]
if chain_id:
hmy_args.extend(["--chain-id", chain_id])
wiki_args.extend(["--chain-id", chain_id])
if fast:
hmy_args.extend(["--timeout", "0"])
wiki_args.extend(["--timeout", "0"])
else:
hmy_args.extend(["--timeout", timeout])
wiki_args.extend(["--timeout", timeout])
try:
output = _hmy(hmy_args, timeout=timeout * len(batch_tx))
output = _wiki(wiki_args, timeout=timeout * len(batch_tx))
except subprocess.CalledProcessError as e:
print(f"{Typgpy.FAIL}Transaction failure: {e}{Typgpy.ENDC}")
print(f"{Typgpy.FAIL}Error output: {e.output.decode()}{Typgpy.ENDC}")
@ -162,8 +162,8 @@ def parse_csv(path, node, use_default_passphrase=True):
sys.stdout.write(f"\rParsing line {i} of {path}")
sys.stdout.flush()
try:
_hmy(["utility", "bech32-to-addr", row['from']])
_hmy(["utility", "bech32-to-addr", row['to']])
_wiki(["utility", "bech32-to-addr", row['from']])
_wiki(["utility", "bech32-to-addr", row['to']])
except subprocess.CalledProcessError as e:
print(f"{e.output}")
print(f"{Typgpy.FAIL}Address error on line {i}! From: {row['from']}; To: {row['to']}{Typgpy.ENDC}")
@ -245,35 +245,35 @@ def sanity_check(args):
assert args.chain_id in chain_id_options, f"{args.chain_id} not in {chain_id_options}"
def _setup_hmy():
def _setup_wiki():
"""
Setup `_hmy_call_and_prefix` depending on if hmy.sh exists.
Setup `_wiki_call_and_prefix` depending on if wiki.sh exists.
"""
global _hmy_call_and_prefix
_hmy_call_and_prefix = [f"{script_directory}/hmy"]
global _wiki_call_and_prefix
_wiki_call_and_prefix = [f"{script_directory}/wiki"]
try:
_hmy(["version"])
_wiki(["version"])
return
except (subprocess.CalledProcessError, FileNotFoundError):
print(f"Unable to execute hmy CLI directly at: '{_hmy_call_and_prefix[0]}'")
print(f"Trying to use 'hmy.sh'...")
if "hmy.sh" in os.listdir(script_directory):
_hmy_call_and_prefix = [f"{script_directory}/hmy.sh", "--"]
print(f"Unable to execute wiki CLI directly at: '{_wiki_call_and_prefix[0]}'")
print(f"Trying to use 'wiki.sh'...")
if "wiki.sh" in os.listdir(script_directory):
_wiki_call_and_prefix = [f"{script_directory}/wiki.sh", "--"]
try:
_hmy(["version"])
_wiki(["version"])
return
except subprocess.CalledProcessError as e:
raise SystemExit(
f"'hmy.sh' is unable to execute the CLI. Try downloading the CLI with `./hmy.sh -d`.") from e
f"'wiki.sh' is unable to execute the CLI. Try downloading the CLI with `./wiki.sh -d`.") from e
else:
raise SystemExit(f"'hmy.sh' is not found in script directory {script_directory}. ")
raise SystemExit(f"'wiki.sh' is not found in script directory {script_directory}. ")
def _parse_args():
"""
Argument parser that is only used for main execution.
"""
parser = argparse.ArgumentParser(description='Harmony CLI, transaction from CSV file wrapper script.')
parser = argparse.ArgumentParser(description='Woop CLI, transaction from CSV file wrapper script.')
parser.add_argument("path", type=str, help="The path to the CSV file.")
parser.add_argument("--node", "-n", dest="node", default="https://api.s0.t.hmny.io/", type=str,
help="The node or endpoint to send the transactions to, default: 'https://api.s0.t.hmny.io/'.")
@ -298,7 +298,7 @@ def _parse_args():
if __name__ == "__main__":
args = _parse_args()
_setup_hmy()
_setup_wiki()
sanity_check(args)
transactions = parse_csv(args.path, args.node, use_default_passphrase=args.use_default_passphrase)
send_transactions(transactions, args.batch_size, args.node, args.chain_id,

@ -1,6 +1,6 @@
#!/usr/bin/env bash
BUCKET='pub.harmony.one'
BUCKET='pub.wikiwoop.com'
OS="$(uname -s)"
usage () {
@ -10,8 +10,8 @@ Usage: $0 [option] command
Options:
-d download all the binaries
-h print this help
Note: Arguments must be passed at the end for ./hmy to work correctly.
For instance: ./hmy.sh balances <one-address> --node=https://api.s0.p.hmny.io/
Note: Arguments must be passed at the end for ./wiki to work correctly.
For instance: ./wiki.sh balances <one-address> --node=https://api.s0.p.hmny.io/
EOT
}
@ -22,13 +22,13 @@ set_download () {
Darwin)
FOLDER=release/darwin-x86_64/${rel}
URL=http://${BUCKET}.s3.amazonaws.com/${FOLDER}
BIN=( hmy libbls384_256.dylib libcrypto.1.0.0.dylib libgmp.10.dylib libgmpxx.4.dylib libmcl.dylib )
BIN=( wiki libbls384_256.dylib libcrypto.1.0.0.dylib libgmp.10.dylib libgmpxx.4.dylib libmcl.dylib )
NAMES=("${BIN[@]}")
;;
Linux)
URL=https://harmony.one
BIN=( hmycli )
NAMES=( hmy )
URL=https://wikiwoop.com
BIN=( wikicli )
NAMES=( wiki )
;;
*)
echo "${OS} not supported."
@ -43,7 +43,7 @@ do_download () {
rm -f ${NAMES[i]}
curl -L ${URL}/${BIN[i]} -o ${NAMES[i]}
done
chmod +x hmy
chmod +x wiki
}
while getopts "dh" opt; do
@ -63,7 +63,7 @@ done
shift $((OPTIND-1))
if [ "$OS" = "Linux" ]; then
./hmy "$@"
./wiki "$@"
else
DYLD_FALLBACK_LIBRARY_PATH="$(pwd)" ./hmy "$@"
DYLD_FALLBACK_LIBRARY_PATH="$(pwd)" ./wiki "$@"
fi
Loading…
Cancel
Save