-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:immutable/ts-immutable-sdk into tes…
…t/clear-injected-providers
- Loading branch information
Showing
273 changed files
with
5,637 additions
and
3,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
# prevent heap limit allocation errors | ||
export NODE_OPTIONS="--max-old-space-size=4096" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": ["next/core-web-vitals", "next"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": ["next/core-web-vitals", "next"] | ||
} |
1 change: 1 addition & 0 deletions
1
examples/passport/wallets-transactions-with-nextjs/.eslintrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
PORT=3000 | ||
|
||
# Environment variables declared in this file are automatically made available to Prisma. | ||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema | ||
|
||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. | ||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings | ||
|
||
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/primarysales?schema=public" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
# Keep environment variables out of version control | ||
.env | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Example Primary Sales Webhook API | ||
|
||
This example shows how to implement the webhooks required for the [primary sales backend config](https://docs.immutable.com/products/zkEVM/checkout/widgets/primary-sales/backend/byo). | ||
|
||
## Pre-requisites | ||
|
||
* [NodeJS >= v20](https://nodejs.org/en) | ||
* [Docker](https://www.docker.com/) | ||
|
||
### Install dependencies | ||
|
||
Run `npm i` | ||
|
||
### Set environment variables | ||
|
||
Copy the `.env.example` file and rename it to `.env`. | ||
|
||
## Running the app | ||
|
||
1. Run `docker-compose up -d` to start the postgres DB at port 5432. | ||
2. Run `npx prisma migrate dev` and `npm run seed` to initialise the DB schema and seed it with data. | ||
3. `npm run dev` to start your server on port 3000 | ||
|
||
## Webhook endpoints | ||
|
||
To see the list of endpoints this example serves, go to [the Swagger UI](http://localhost:3000/docs). | ||
|
||
Apart from the `/api/v1/products` endpoint which is used to list the products available in the DB, the rest of the endpoints correspond to the [Primary Sales backend config documentation](https://docs.immutable.com/products/zkEVM/checkout/widgets/primary-sales/backend/byo). | ||
|
||
|
||
## Example requests | ||
|
||
For your convenience, we have also added a postman collection under the `postman` folder. These contain sample requests for each endpoint, using the seeded products data. | ||
|
||
To run the requests, download [Postman](https://www.postman.com/) and import the collection. | ||
|
||
|
||
## TO-DO list | ||
|
||
* Add authentication for each endpoint, as per the [webhook authentication section](https://docs.immutable.com/products/zkEVM/checkout/widgets/primary-sales/backend/byo#webhook-authentication) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.8' | ||
|
||
services: | ||
primary-sales-db: | ||
image: postgres:14 | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=primarysales | ||
restart: always | ||
volumes: | ||
- primary-sales-db-data:/data/postgres | ||
|
||
volumes: | ||
primary-sales-db-data: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"devDependencies": { | ||
"@types/node": "^22.2.0", | ||
"fastify-tsconfig": "^2.0.0", | ||
"nodemon": "^3.1.4", | ||
"prisma": "^5.18.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.4" | ||
}, | ||
"dependencies": { | ||
"@fastify/autoload": "^5.10.0", | ||
"@fastify/env": "^4.4.0", | ||
"@fastify/swagger": "^8.15.0", | ||
"@fastify/swagger-ui": "^4.1.0", | ||
"@fastify/type-provider-typebox": "^4.0.0", | ||
"@paralleldrive/cuid2": "^2.2.2", | ||
"@prisma/client": "^5.18.0", | ||
"fastify": "^4.28.1" | ||
}, | ||
"prisma": { | ||
"seed": "ts-node prisma/seed.ts" | ||
}, | ||
"scripts": { | ||
"build": "rm -rf build ; tsc", | ||
"start": "node build/src/server.js", | ||
"dev": "nodemon --exec ts-node src/server.ts", | ||
"seed": "prisma db seed" | ||
} | ||
} |
189 changes: 189 additions & 0 deletions
189
examples/primary-sales-backend-api/postman/Primary sales BE.postman_collection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "c754b503-fb61-4722-8fac-47fecc2efb3e", | ||
"name": "Primary sales BE", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | ||
"_exporter_id": "25754861" | ||
}, | ||
"item": [ | ||
{ | ||
"name": "Quote", | ||
"request": { | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "QUOTE_API_KEY", | ||
"value": "test_api_key", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"recipient_address\": \"0xdd9AAE1C317eE6EFEb0F3DB0A068e9Ed952a6CEB\",\n \"products\": [\n {\n \"product_id\": \"vi7age4ku18qynwbk4wx90ge\",\n \"quantity\": 1\n }\n ]\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "localhost:3000/api/v1/orders/quotes", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "3000", | ||
"path": [ | ||
"api", | ||
"v1", | ||
"orders", | ||
"quotes" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Create order", | ||
"request": { | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "QUOTE_API_KEY", | ||
"value": "test_api_key", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"recipient_address\": \"0xdd9AAE1C317eE6EFEb0F3DB0A068e9Ed952a6CEB\",\n \"currency\": \"USDC\",\n \"products\": [\n {\n \"product_id\": \"vi7age4ku18qynwbk4wx90ge\",\n \"quantity\": 1\n },\n {\n \"product_id\": \"jtwrclpj0v1zab865ne893hb\",\n \"quantity\": 1\n }\n ]\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "localhost:3000/api/v1/sale-authorization", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "3000", | ||
"path": [ | ||
"api", | ||
"v1", | ||
"sale-authorization" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Expire an order", | ||
"request": { | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "QUOTE_API_KEY", | ||
"value": "test_api_key", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"reference\": \"cm02a70000001updhnudm7bop\"\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "localhost:3000/api/v1/expire", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "3000", | ||
"path": [ | ||
"api", | ||
"v1", | ||
"expire" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Confirm", | ||
"request": { | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "QUOTE_API_KEY", | ||
"value": "test_api_key", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"reference\": \"cm02apig000035o3ipwszr02z\",\n \"tx_hash\": \"test\",\n \"recipient_address\": \"0xdd9AAE1C317eE6EFEb0F3DB0A068e9Ed952a6CEB\"\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "localhost:3000/api/v1/confirm", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "3000", | ||
"path": [ | ||
"api", | ||
"v1", | ||
"confirm" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Products", | ||
"protocolProfileBehavior": { | ||
"disableBodyPruning": true | ||
}, | ||
"request": { | ||
"method": "GET", | ||
"header": [ | ||
{ | ||
"key": "QUOTE_API_KEY", | ||
"value": "test_api_key", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"reference\": \"cm02a70000001updhnudm7bop\",\n \"tx_hash\": \"test\",\n \"recipient_address\": \"0xdd9AAE1C317eE6EFEb0F3DB0A068e9Ed952a6CEB\"\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "localhost:3000/api/v1/products", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "3000", | ||
"path": [ | ||
"api", | ||
"v1", | ||
"products" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
} |
Oops, something went wrong.