Skip to content

Commit

Permalink
Convert to Flow Go SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
psiemens committed Dec 27, 2019
0 parents commit dbbe9a6
Show file tree
Hide file tree
Showing 184 changed files with 28,305 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[Makefile]
indent_style = tab
indent_size = 4
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Bug report
about: Issue tracker for bug reports

---

## 🐞 Bug Report

A clear and concise description of what the bug is.

## What is the severity of this bug?

**Critical - Urgent:** We can't do anything if this isn't actioned immediately (product doesn't function without this, it's blocking us or users, or it resolves a high severity security issue). Whole team should drop what they're doing and work on this.

**Critical:** We can't do anything if this isn't actioned immediately (product doesn't function without this, it's blocking us or users, or it resolves a high severity security issue). One person should look at this right now.

**Important:** * We have to do this before we ship, but it can wait until the next sprint (product or feature won't function without it, but it's not blocking us or users right now). Team should do this in the next sprint.

**Should have:** * It would be better if we do this before we ship, but it's OK if we don't (product functions without this, but it's a better user experience). Consider adding to a future sprint.

**Could have:** It really doesn't matter if we do this (product functions without this, impact to user is minimal).

## Reproduction steps

Steps to reproduce the behaviour:

1. Make API call '...'
1. See error

- [ ] I followed these steps and was able to reproduce the issue

## Expected behaviour

A clear and concise description of what you expected to happen.

## Screenshots

If applicable, add screenshots to help explain your problem.

## Specifications

- System: (e.g. macOS 10.13.4, Linux)
- Go: (e.g. 1.13)

## Additional context

Add any other context about the problem here.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/micro-decision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Micro Decision
about: A template to describe a problem and a proposed solution. Enables fast iterations
on decisions.
title: "[MDF] <Replace title here>"
labels: MDF
assignees: ''

---

## Problem
<!--- Please try limit problem description to 100 words. --->

## The Proposed Solution
<!--- Please propose only one solution, and to try to limit to 100 words. If more than one good solution, narrow it down with teammates before posting. If a different solution is needed, then a new issue will be created. --->

---

### Note
<!--- Please do not remove the following block --->
This is part of the decision framework described in https://github.com/dapperlabs/bamboo/issues/576 .
These issues are meant to be resolved quickly, therefore:
- Comments or discussions should happen in direct communication (slack, sync, etc')
- Comments on this thread should be limited to one of these short replies:
- `I agree`
- `I'm OK with this`
- `I would like further discussions before deciding`
- `I disagree`
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/standard-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Standard issue
about: Our standard issue
title: ''
labels: ''
assignees: ''

---

## Context

Why are we doing this work? How does it interact with other work being done? For example:

Access nodes need to receive transactions in order to store them, so we need a communication solution for relaying transactions between access nodes.

## Definition of Done

What do we need to achieve to consider this issue resolved? For example:

* Access nodes must send transactions to at least some of their peers
* Processing hooks are in place for received transactions, to be implemented in a later issue
* Transactions must be received by the entire network, although this doesn't have to be immediate (i.e. transactions could be gossiped)

## Further reading:

Any additional materials that provide context and background, beyond the typical scope for an issue. For example this might be links to the Bamboo technical primer.
7 changes: 7 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
template: |
## Changes
$CHANGES
17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 90
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- Gigster
- Idea
# Label to use when marking an issue as stale
staleLabel: Stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/cmd/flow/flow

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Coverage artifacts
coverage.zip
cover.json
cover-summary
index.html

# Since we have tooling that uses node
node_modules

.DS_Store

flow.json
flowdb

# IDE related files
.idea
.vscode
git
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: go
go_import_path: github.com/dapperlabs/flow-go

go:
- 1.13

branches:
only:
- master

cache:
bundler: true
directories:
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod

script:
- make ci
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# The short Git commit hash
SHORT_COMMIT := $(shell git rev-parse --short HEAD)
# The Git commit hash
COMMIT := $(shell git rev-parse HEAD)
# The tag of the current commit, otherwise empty
VERSION := $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
# Name of the cover profile
COVER_PROFILE := cover.out
# Disable go sum database lookup for private repos
GOPRIVATE=github.com/dapperlabs/*
# OS
UNAME := $(shell uname)

.PHONY: install-tools
install-tools: check-go-version
cd ${GOPATH}; \
GO111MODULE=on go get github.com/golang/mock/[email protected]; \
GO111MODULE=on go get github.com/kevinburke/go-bindata/[email protected];

.PHONY: test
test:
GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) $(if $(JSON_OUTPUT),-json,) ./...

.PHONY: coverage
coverage:
ifeq ($(COVER), true)
# file has to be called index.html
gocov convert $(COVER_PROFILE) > cover.json
./cover-summary.sh
gocov-html cover.json > index.html
# coverage.zip will automatically be picked up by teamcity
zip coverage.zip index.html
endif

.PHONY: generate
generate: generate-mocks

.PHONY: generate-mocks
generate-mocks:
GO111MODULE=on mockgen -destination=client/mocks/mock_client.go -package=mocks github.com/dapperlabs/flow-go-sdk/client RPCClient
GO111MODULE=on mockgen -destination=emulator/mocks/blockchain_api.go -package=mocks github.com/dapperlabs/flow-go-sdk/emulator BlockchainAPI
GO111MODULE=on mockgen -destination=emulator/storage/mocks/store.go -package=mocks github.com/dapperlabs/flow-go-sdk/emulator/storage Store

.PHONY: ci
ci: install-tools generate test coverage

cmd/flow/flow:
GO111MODULE=on go build \
-ldflags \
"-X github.com/dapperlabs/flow-go-sdk/utils/build.commit=$(COMMIT) -X github.com/dapperlabs/flow-go-sdk/utils/build.semver=$(VERSION)" \
-o ./cmd/flow/flow ./cmd/flow

.PHONY: install-cli
install-cli: cmd/flow/flow
cp cmd/flow/flow $$GOPATH/bin/

.PHONY: docker-build-emulator
docker-build-emulator:
docker build -f cmd/flow/emulator/Dockerfile -t gcr.io/dl-flow/emulator:latest -t "gcr.io/dl-flow/emulator:$(SHORT_COMMIT)" .

docker-push-emulator:
docker push gcr.io/dl-flow/emulator:latest
docker push "gcr.io/dl-flow/emulator:$(SHORT_COMMIT)"

# Check if the go version is 1.13. flow-go-sdk only supports go 1.13
.PHONY: check-go-version
check-go-version:
go version | grep 1.13
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Flow Go SDK

A collection of libraries and tools for building Go applications on Flow.
49 changes: 49 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package flow

import (
"github.com/dapperlabs/flow-go/crypto"
)

// Account represents an account on the Flow network.
//
// An account can be an externally owned account or a contract account with code.
type Account struct {
Address Address
Balance uint64
Code []byte
Keys []AccountPublicKey
}

// AccountPublicKey is a public key associated with an account.
//
// An account public key contains the public key, signing and hashing algorithms, and a key weight.
type AccountPublicKey struct {
PublicKey crypto.PublicKey
SignAlgo crypto.SigningAlgorithm
HashAlgo crypto.HashingAlgorithm
SeqNumber uint64
Weight int
}

// AccountPrivateKey is a private key associated with an account.
type AccountPrivateKey struct {
PrivateKey crypto.PrivateKey
SignAlgo crypto.SigningAlgorithm
HashAlgo crypto.HashingAlgorithm
}

// PublicKey returns a weighted public key.
func (a AccountPrivateKey) PublicKey(weight int) AccountPublicKey {
return AccountPublicKey{
PublicKey: a.PrivateKey.PublicKey(),
SignAlgo: a.SignAlgo,
HashAlgo: a.HashAlgo,
Weight: weight,
}
}

// AccountSignature is a signature associated with an account.
type AccountSignature struct {
Account Address
Signature []byte
}
Loading

0 comments on commit dbbe9a6

Please sign in to comment.