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: app data tutorials #21

Merged
merged 10 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Report any bugs or unexpected behaviour in the tutorials site
title: "bug: "
labels: bug, track:maintenance
assignees: ""
---

### Problem

A clear and concise description of what the bug is.

### To reproduce

If you can reproduce the behaviour, steps to reproduce:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

### Expected behaviour

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

### Screenshots/logs

If applicable, add screenshots or logs to help explain your problem.

### tutorial version/commit hash

State the version of tutorials where you've encountered the bug or, if built off a specific commit, the relevant commit hash.

- e.g. `v0.9` or `ed53bcd`

### Additional context

Add any other context about the problem here.
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contact_links:
- name: Questions & Support Requests
url: https://discord.gg/cowprotocol
about: Ask in the CoW Protocol Discord
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Feature request
about: Suggest an idea for the tutorials (not currently covered)
title: "feat: "
labels: track:production
assignees: ""
---

### Problem

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

### Suggested solution

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

### Alternatives considered

A clear and concise description of any alternative solutions or features you've considered.

### Additional context

Add any other context or screenshots about the feature request here.

### Acceptance criteria

A list of tasks that need to be done for the issue to be considered resolved.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Improvement
about: Suggest improvements to the tutorials.
title: "chore:"
labels: track:maintenance
assignees: ""
---

### Background

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]; There is a spelling error in [...]; It's difficult to understand the tutorial in [...]

### Details

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

### Acceptance criteria

A list of tasks that need to be done for the issue to be considered resolved.
Binary file added .github/cow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Description

<!--- Describe your changes to provide context for reviewers, including why it is needed -->

# Changes

<!-- List of detailed changes (how the change is accomplished) -->

- [ ] ...
- [ ] ...

<!--
## Related Issues

Fixes #
-->
16 changes: 16 additions & 0 deletions .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Add new issues to project board

on:
issues:
types: [opened]

jobs:
add-to-project:
if: github.repository_owner == 'cowprotocol'
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/cowprotocol/projects/8
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
23 changes: 23 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "cla"

on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]

jobs:
cla:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: ((github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target') && github.repository_owner == 'cowprotocol' && github.repository != 'cowprotocol/cla'
uses: contributor-assistant/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN : ${{ secrets.ORG_TOKEN }}
with:
branch: 'cla-signatures'
path-to-signatures: 'signatures/version1/cla.json'
path-to-document: 'https://github.com/cowprotocol/cla/blob/main/CLA.md'
allowlist: '*[bot]'
32 changes: 0 additions & 32 deletions .github/workflows/node.js.yml

This file was deleted.

20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
# CoW Tutorial
<p align="center">
<img alt="CoW Protocol Logo" width="400" src="./.github/cow.png">
</p>

A soup-to-nuts interactive tutorial on how to build apps with Svelte.
# CoW Tutorials

A grass-to-glass tutorial on how to build with CoW Protocol.

## Setup

This repo uses [pnpm](https://pnpm.io/).
This repo uses [yarn](https://yarnpkg.com/).

## Developing the app

First, run `node scripts/create-common-bundle`. This packages up everything that's needed to run a SvelteKit app (Vite, esbuild, SvelteKit, Svelte compiler, etc.) which can subsequently be unpacked on a server to create and run an instance of a SvelteKit application (which powers the output window of the tutorial). Then, run `dev`:
First, run `node scripts/create-common-bundle`. This packages up everything that's needed to run the app within the webcontainer (Vite, typescript, CoW dependencies, etc.) which can subsequently be unpacked on a server to create and run an instance of a CoW application (which powers the output window of the tutorial). Then, run `dev`:

```bash
node scripts/create-common-bundle
pnpm dev
yarn dev
```

To build for production and run locally:

```bash
pnpm build
pnpm preview
yarn build
yarn preview
```

## Creating new tutorials
Expand All @@ -28,4 +32,4 @@ Tutorials live inside `content`. Each tutorial consists of a `README.md`, which

## Bumping tutorial dependencies

Bump the dependency (for example Svelte) in both the root and the `content/common` `package.json`. In the root do `pnpm i` (to update `pnpm-lock.yaml`), in `content/common` do `npm i` (to update `package-lock.json`).
Bump the dependency (for example `cow-sdk`) in both the root and the `content/common` `package.json`. In the root do `yarn` (to update `yarn.lock`), in `content/common` do `yarn` (to update `yarn.lock`).
5 changes: 0 additions & 5 deletions content/tutorial/01-orders/02-app-data/02-app-data/README.md

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ In the above case, we can see that:
- the `feeAmount` is `1881812051493698` atomic units of `wxDAI` (which is `0.001881812051493698` `wxDAI`)
- the `kind` is `sell`

The above `OrderQuoteResponse` object actually maps to the [`GPv2Order.Data`](https://beta.docs.cow.fi/cow-protocol/reference/contracts/core/settlement#gpv2orderdata-struct) struct for the smart contract, so this is what we will sign in the [next tutorial](/tutorial/sign) for our swap.
The above `OrderQuoteResponse` object actually maps to the [`GPv2Order.Data`](https://beta.docs.cow.fi/cow-protocol/reference/contracts/core/settlement#gpv2orderdata-struct) struct for the smart contract, so this is what we will sign in the [next tutorial](/tutorial/sign-order) for our swap.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Signing
---

Here we will build on the previous tutorial and sign the quote we got from the [quote tutorial](/tutorial/quote), so that we can place an order on CoW Protocol.
Here we will build on the previous tutorial and sign the quote we got from the [quote tutorial](/tutorial/quote-order), so that we can place an order on CoW Protocol.

## Intents and signatures

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Submitting
---

Further building on the previous tutorial, we will now submit the order we signed in the [sign order tutorial](/tutorial/sign) to CoW Protocol.
Further building on the previous tutorial, we will now submit the order we signed in the [sign order tutorial](/tutorial/sign-order) to CoW Protocol.

## Submitting an order

Expand Down Expand Up @@ -58,4 +58,4 @@ An example `orderId` should look like:
A couple of errors may easily result when running this code:

- **`InsufficientBalance`**: The wallet you have signed with does not have enough balance for the `sellToken`. A reminder in this example, the `sellToken` is `wxDai` on Gnosis chain.
- **`InsufficientAllowance`**: In this case, the wallet has enough balance, however you have missed out a step in the [approve tutorial](/tutorial/approve) and have not approved the `relayerAddress` to spend the `sellToken` on your behalf.
- **`InsufficientAllowance`**: In this case, the wallet has enough balance, however you have missed out a step in the [approve tutorial](/tutorial/approve-sell-token-order) and have not approved the `relayerAddress` to spend the `sellToken` on your behalf.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ With CoW Protocol, the only way to view the status of an order that has not yet

## Instantiate the SDK

We will start from the basic setup from the [quote tutorial](/tutorial/quote) after we have instantiated the `OrderBookApi`.
We will start from the basic setup from the [quote tutorial](/tutorial/quote-order) after we have instantiated the `OrderBookApi`.

### Query parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To cancel an order, we need to know the `orderUid` of the order we want to cance

### Instantiate the SDK

We will start from the basic setup from the [quote tutorial](/tutorial/quote) after we have instantiated the `OrderBookApi` and configured the `signer`.
We will start from the basic setup from the [quote tutorial](/tutorial/quote-order) after we have instantiated the `OrderBookApi` and configured the `signer`.

### Cancellation parameters

Expand All @@ -36,7 +36,7 @@ export async function run(provider: Web3Provider): Promise<unknown> {

### Signing the cancellation

Just like we did in the [sign order tutorial](/tutorial/sign), we need to sign the cancellation. To do this, we will use the `OrderSigningUtils` utility.
Just like we did in the [sign order tutorial](/tutorial/sign-order), we need to sign the cancellation. To do this, we will use the `OrderSigningUtils` utility.

```typescript
/// file: run.ts
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function run(provider: Web3Provider): Promise<unknown> {
}
```

Just as we did in the [submit order tutorial](/tutorial/submit), we are using a `try/catch` block to handle errors.
Just as we did in the [submit order tutorial](/tutorial/submit-order), we are using a `try/catch` block to handle errors.

## Run the code

Expand Down
Loading