From 5e65eeceaf73838807cb1d6429fda6d8f8aad238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilo=20Acu=C3=B1a?= Date: Fri, 6 Oct 2023 05:09:33 +0200 Subject: [PATCH] refactor: change Util by server in tutorials --- docs/quick-start.md | 8 ++++---- docs/syncs/contract.md | 6 ++++-- docs/tutorials/3-webhooks-essentials.md | 8 ++++---- docs/tutorials/5-sc-triggers.md | 22 +++++++++++----------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/docs/quick-start.md b/docs/quick-start.md index 3975921..37ca9bd 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -47,14 +47,14 @@ values={[ ```js const Darchlabs = require("darchlabs"); -const { Synchronizers } = new Darchlabs(""); +const { synchronizers } = new Darchlabs(""); // new contract to synchronize -const created = await Synchronizers.Contracts.createContract({ +const created = await synchronizers.Contracts.createContract({ name: "MyContract", network: "ethereum", address: "0x1234abcd...", - abi: [/* ABI contract json */]; + abi: [/* ABI contract json */]; }); console.log("contract", created); @@ -76,7 +76,7 @@ const created = await synchronizers.contracts.createContract({ name: "MyContract", network: "ethereum", address: "0x1234abcd...", - abi: [/* ABI contract json */]; + abi: [/* ABI contract json */]; }); console.log("contract", created); diff --git a/docs/syncs/contract.md b/docs/syncs/contract.md index c8527ad..d1852f9 100644 --- a/docs/syncs/contract.md +++ b/docs/syncs/contract.md @@ -45,7 +45,7 @@ const created = await synchronizers.contracts.createContract({ name: "MyContract", network: "ethereum", address: "0x1234abcd...", - abi: [/* ABI contract json */]; + abi: [/* ABI contract json */]; }); console.log("created contract", created); @@ -64,7 +64,7 @@ const created = await synchronizers.contracts.createContract({ name: "MyContract", network: "ethereum", address: "0x1234abcd...", - abi: [/* ABI contract json */]; + abi: [/* ABI contract json */]; }); console.log("created contract", created); @@ -331,6 +331,7 @@ const { synchronizers } = new Darchlabs(""); await synchronizers.contracts.updateContract("0x1234abcd...", { name: "UpdatedContractName", + webhook: "https://www.fakeapi.com/api/v1/webhook", }); console.log("Contract updated successfully"); @@ -346,6 +347,7 @@ const { synchronizers } = new Darchlabs(""); await synchronizers.contracts.updateContract("0x1234abcd...", { name: "UpdatedContractName", + webhook: "https://www.fakeapi.com/api/v1/webhook", }); console.log("Contract updated successfully"); diff --git a/docs/tutorials/3-webhooks-essentials.md b/docs/tutorials/3-webhooks-essentials.md index be70178..ff76a39 100644 --- a/docs/tutorials/3-webhooks-essentials.md +++ b/docs/tutorials/3-webhooks-essentials.md @@ -60,9 +60,9 @@ values={[ - Add the following code to `webhook.js`: ```js -const { Util } = require("darchlabs"); +const { server } = require("darchlabs"); -Util.ListenServer(3000, "/api/v1/webhook", (wh) => { +server.ListenServer(3000, "/api/v1/webhook", (wh) => { console.log(`Received webhook with ID: ${wh.id}`); }); ``` @@ -82,9 +82,9 @@ Util.ListenServer(3000, "/api/v1/webhook", (wh) => { - Add the following code to `webhook.ts`: ```ts -import { Util, type Webhook } from "darchlabs"; +import { server, type Webhook } from "darchlabs"; -Util.ListenServer(3000, "/api/v1/webhook", (wh: Webhook) => { +server.ListenServer(3000, "/api/v1/webhook", (wh: Webhook) => { console.log(`Received webhook with ID: ${wh.id}`); }); ``` diff --git a/docs/tutorials/5-sc-triggers.md b/docs/tutorials/5-sc-triggers.md index 62d205c..e4c263b 100644 --- a/docs/tutorials/5-sc-triggers.md +++ b/docs/tutorials/5-sc-triggers.md @@ -35,9 +35,9 @@ values={[ ```js -const { Util } = require("darchlabs"); +const { server } = require("darchlabs"); -Util.ListenServer(3000, "/api/v1/webhook", (wh) => { +server.ListenServer(3000, "/api/v1/webhook", (wh) => { console.log(`received webhook with ID: ${wh.id}`); }); ``` @@ -46,9 +46,9 @@ Util.ListenServer(3000, "/api/v1/webhook", (wh) => { ```ts -import { Util, type Webhook } from "darchlabs"; +import { server, type Webhook } from "darchlabs"; -Util.ListenServer(3000, "/api/v1/webhook", (wh: Webhook) => { +server.ListenServer(3000, "/api/v1/webhook", (wh: Webhook) => { console.log(`received webhook with ID: ${wh.id}`); }); ``` @@ -70,18 +70,18 @@ values={[ ```js -const { Util } = require("darchlabs"); +const { server } = require("darchlabs"); const dotenv = require("dotenv"); dotenv.config(); -Util.ListenServer(3000, "/api/v1/webhook", async (wh) => { +server.ListenServer(3000, "/api/v1/webhook", async (wh) => { console.log(`received webhook with ID: ${wh.id}`); // do anything with the webhook ... // trigger the method on the smart contract in response to the webhook - const tx = await Util.TriggerEVMMethod({ + const tx = await server.TriggerEVMMethod({ network: "mumbai", nodeUrl: process.env.NODE_URL!, abi: [/* ABI contract json */], @@ -98,18 +98,18 @@ Util.ListenServer(3000, "/api/v1/webhook", async (wh) => { ```ts -import { Util, type Webhook } from "darchlabs"; +import { server, type Webhook } from "darchlabs"; import dotenv from "dotenv"; dotenv.config(); -Util.ListenServer(3000, "/api/v1/webhook", async (wh: Webhook) => { +server.ListenServer(3000, "/api/v1/webhook", async (wh: Webhook) => { console.log(`received webhook with ID: ${wh.id}`); // do anything with the webhook ... // trigger the method on the smart contract in response to the webhook - const tx = await Util.TriggerEVMMethod({ + const tx = await server.TriggerEVMMethod({ network: "mumbai", nodeUrl: process.env.NODE_URL!, abi: [ @@ -129,7 +129,7 @@ Util.ListenServer(3000, "/api/v1/webhook", async (wh: Webhook) => { :::info -The `Util.TriggerEVMMethod` method is implement ed using the [ethers.js library](https://docs.ethers.io/v5/). You can view its implementation [here](https://github.com/darchlabs/client-nodejs/blob/main/src/util/evm-trigger-method.ts). The `increment` method is from our demo Solidity contract, which can be found [here](https://github.com/darchlabs/demo-integration-starter-kit/blob/main/demo-storage-contract/storage.sol). +The `server.TriggerEVMMethod` method is implement ed using the [ethers.js library](https://docs.ethers.io/v5/). You can view its implementation [here](https://github.com/darchlabs/client-nodejs/blob/main/src/server/evm-trigger-method.ts). The `increment` method is from our demo Solidity contract, which can be found [here](https://github.com/darchlabs/demo-integration-starter-kit/blob/main/demo-storage-contract/storage.sol). :::