Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add tests #8

Merged
merged 9 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This CODEOWNERS file sets the individuals responsible for code in the zksync2-go Golang SDK repository.

# These users are the default owners for everything in the repo.
# They will be requested for review when someone opens a pull request.
* @zksync-sdk/txfusion

# You can also specify code owners for specific directories or files.
# For example:
# /src/ @developer1 @developer2
# /docs/ @documenter
84 changes: 84 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Contributing

## Welcome! 👋

Hello there, contributor! We're delighted that you're considering contributing to the `zksync2-examples` project. This document is here to guide you through the steps and best practices for contributing to this repository.

Please take a moment to review this document to ensure a smooth and efficient contribution process for everyone involved.

## Getting Started

- **Fork the repository.** Begin by forking the main `zksync2-examples` repository to your personal GitHub account.

- **Clone the repository.** After forking, clone the repository to your local machine:

```bash
git clone https://github.com/<your-github-username>/zksync2-examples.git
```

- **Create a new branch.** Use descriptive names for your branches to help identify the feature, bugfix, or enhancement you're addressing:

```bash
git checkout -b feature/description-of-your-feature
```

## Making Changes

### Go examples

- **Write your code.** Ensure your code is thoroughly tested and functions as expected. Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
- **Compile and test.** Before submitting a pull request, ensure your code compiles, passes lint checks, and all tests are successful. You should also write unit tests for your contributions.
- **Lint your code.** Follow basic coding style guidelines and ensure your code is formatted and lint checks pass.

Use the following commands for these checks:

```bash
gofmt -w .
got test ./test/...
```

### JavaScript examples

- **Write your code.** Ensure your code is thoroughly tested and functions as expected. Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
- **Compile and test.** Before submitting a pull request, ensure your code compiles, passes lint checks, and all tests are successful. You should also write unit tests for your contributions.
- **Lint your code.** Follow basic coding style guidelines and ensure your code is formatted and lint checks pass.

Use the following commands for these checks:

```bash
yarn lint
yarn test
yarn types
yarn build
```

## Submitting changes

- **Commit your changes.** Adhere to the [Conventional Commits](https://www.conventionalcommits.org/) standard when writing commit messages.

- **Push your changes.** Push the changes to your forked repository:

```bash
git push -u origin feature/description-of-your-feature
```

## Submitting a Pull Request

- **Initiate a pull request (PR).** Go to the main `zksync2-go` repository. Your recently pushed branch should be highlighted, showing a "Compare & pull request" button. Click on it and provide a clear, detailed description of your changes in the PR.

- **Await a review.** Our maintainers will review your PR. They might request changes or clarifications, so be ready to address any feedback.


## Need Assistance?

If you're unsure about something or have questions, don't hesitate to open an issue or initiate a discussion in our [zkSync Community Hub](https://github.com/zkSync-Community-Hub/zkSync-developers/discussions). We're here to assist!

## What's Next?

Once your PR is approved and merged, your contribution will be integrated into the `zksync2-go` repository. Congratulations, and thank you! We value your contribution and look forward to future collaborations.

Remember, the best contributions come from enjoying the process, being respectful, and continuously learning. Thanks for being a part of our community!

---

*Last updated: Dec 22, 2023*
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Bug report
about: Use this template for reporting issues
title: ""
labels: bug
assignees: ''

---

### 🐛 Bug Report for zksync2-js JavaScript SDK

#### 📝 Description

Provide a clear and concise description of the bug.


#### 🔄 Reproduction Steps

1. Step 1
2. Step 2
3. ...

#### 🤔 Expected Behavior

Describe what you expected to happen.

#### 😯 Current Behavior

Describe what actually happened.

#### 🖥️ Environment

- **Node version**: [e.g., Node 18.16.1]
- **Operating System & Version**: [e.g., Ubuntu 20.04]
- **Other relevant environment details**:

#### 📋 Additional Context

Add any other context about the problem here. If applicable, add screenshots to help explain.

#### 📎 Log Output

```
Paste any relevant log output here.
```
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
blank_issues_enabled: true
contact_links:
- name: zksync-developers Discussion
url: https://github.com/zkSync-Community-Hub/zkync-developers/discussions
about: Please provide feedback, and ask questions here.
- name: zksync-web3 SDK documentation page
url: https://era.zksync.io/docs/api/js/
about: Please refer to the documentation for immediate answers.
- name: zksync2-js SDK documentation page
url: https://era.zksync.io/docs/api/js/zksync2-js
about: Please refer to the documentation for immediate answers.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Feature request
about: Use this template for requesting features
title: ""
labels: feat
assignees: ''

---

### 🌟 Feature Request

#### 📝 Description

Provide a clear and concise description of the feature you'd like to see.

#### 🤔 Rationale

Explain why this feature is important and how it benefits the project.

#### 🖼️ Mockups/Examples

If applicable, provide mockups or examples of how the feature would work.

#### 📋 Additional Context

Add any other context or information about the feature request here.
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# What :computer:
* First thing updated with this PR
* Second thing updated with this PR
* Third thing updated with this PR

# Why :hand:
* Reason why first thing was added to PR
* Reason why second thing was added to PR
* Reason why third thing was added to PR

# Evidence :camera:
Include screenshots, screen recordings, or `console` output here demonstrating that your changes work as intended

<!-- All sections below are optional. You can erase any section not applicable to your Pull Request. -->

# Notes :memo:
* Any notes/thoughts that the reviewers should know prior to reviewing the code?
31 changes: 31 additions & 0 deletions .github/workflows/test-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run tests Go
on:
workflow_dispatch:
pull_request:
branch: main
types: [ opened, reopened, synchronize ]

permissions:
contents: read # for checkout

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/[email protected]
- name: Install dependencies
run: cd go && go mod download
- name: Run local-setup
run: |
git clone https://github.com/matter-labs/local-setup.git
pushd local-setup
docker-compose up -d
popd
- name: Run tests
run: cd go && go test ./test/...
37 changes: 37 additions & 0 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run tests
on:
workflow_dispatch:
pull_request:
branch: main
types: [ opened, reopened, synchronize ]

permissions:
contents: read # for checkout

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: cd js && yarn install
- name: Run local-setup
run: |
git clone https://github.com/matter-labs/local-setup.git
pushd local-setup
docker-compose up -d
popd
- name: Wait for local-setup to be ready
run: cd js && yarn test:wait
- name: Prepare environment
run: cd js && yarn test:prepare
- name: Run tests
run: cd js && yarn test
96 changes: 96 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Validate
on:
pull_request:
branch: main
types: [ opened, reopened, synchronize ]

permissions:
contents: read # for checkout

jobs:
lint-go:
name: Check code format for Go
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/[email protected]
- name: Run gofmt
run: |
cd go
fmt_output=$(gofmt -l .)

if [ -n "$fmt_output" ]; then
echo "Code not formatted correctly:"
echo "$fmt_output"
exit 1
else
echo "Code is formatted correctly"
exit 0
fi
lint-js:
name: Check code format for JavaScript
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: cd js && yarn install
- name: Prepare environment
run: cd js && yarn lint:check
commits:
name: Check commits
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: npm install -g @commitlint/cli @commitlint/config-conventional
- name: Configure
run: |
echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js
- name: Validate
run: |
git fetch
npx commitlint \
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \
--to ${{ github.event.pull_request.head.sha }} \
--verbose
commits-fork:
name: Check commits from forks
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: npm install -g @commitlint/cli @commitlint/config-conventional
- name: Configure
run: |
echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js
- name: Validate
run: |
git fetch origin "+refs/pull/${{ github.event.pull_request.number }}/head:refs/pull/${{ github.event.pull_request.number }}/head"
git checkout "refs/pull/${{ github.event.pull_request.number }}/head"
npx commitlint \
--from HEAD~${{ github.event.pull_request.commits }} \
--to HEAD \
--verbose
1 change: 1 addition & 0 deletions go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/token.json
2 changes: 2 additions & 0 deletions go/08_get_confirmed_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
)

// WARNING
// Method client.ConfirmedTokens will be removed in the future
func main() {
var (
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
Expand Down
Loading
Loading