From 687325df9d8434f3041e0504ad83f9f33e9c64bc Mon Sep 17 00:00:00 2001 From: Darwin <77340894+charmful0x@users.noreply.github.com> Date: Sun, 22 Jan 2023 13:01:31 +0100 Subject: [PATCH 1/4] feat: add Redstone molecule --- src/molecules/redstone/atoms/oracle.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/molecules/redstone/atoms/oracle.js diff --git a/src/molecules/redstone/atoms/oracle.js b/src/molecules/redstone/atoms/oracle.js new file mode 100644 index 0000000..b8265b0 --- /dev/null +++ b/src/molecules/redstone/atoms/oracle.js @@ -0,0 +1,14 @@ +import { MOLECULE_API_ENDPOINT } from "../../../utils/constants.js" +import axios from "axios"; + +export async function getTokenPrice(ticker) { + try { + const result = await axios.get( + `${MOLECULE_API_ENDPOINT}/redstone/${ticker}` + ); + + return result?.data;; + } catch (error) { + return { molecule_error: "redstone_error" } + } +} From 4e1f44cfbdbe6efd6d87a7a0f5c7e4a1086561c5 Mon Sep 17 00:00:00 2001 From: Darwin <77340894+charmful0x@users.noreply.github.com> Date: Sun, 22 Jan 2023 13:02:10 +0100 Subject: [PATCH 2/4] feat: `/redstone/price` atom --- src/api.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api.js b/src/api.js index 49f3c1b..b91beb5 100644 --- a/src/api.js +++ b/src/api.js @@ -24,6 +24,7 @@ import { isTezSigner } from "./molecules/tez/atoms/verifySigner.js"; import { isAptosSigner } from "./molecules/aptos/atoms/verifySigner.js"; import { readNearOracleState } from "./molecules/near/atoms/read-contract.js"; import { getEverTxObject } from "./molecules/everpay/atoms/tx.js"; +import { getTokenPrice } from "./molecules/redstone/atoms/oracle.js"; import base64url from "base64url"; const app = express(); @@ -262,7 +263,20 @@ app.get("/everpay/tx/:txid", async (req, res) => { } }); +app.get("/redstone/price/:ticker", async (req, res) => { + try { + res.setHeader("Content-Type", "application/json"); + assert.equal(checkSubdomain(req, "redstone"), true); + const { ticker } = req.params; + const response = await getTokenPrice(ticker); + res.send(response); + return; + } catch (error) { + res.send({ molecule_error: "redstone_error" }); + return; + } +}); app.get("/n-view-state/:network/:address", async (req, res) => { try { From 2a5340d6a7546356e72cd45892b41daf0e3501d0 Mon Sep 17 00:00:00 2001 From: Darwin <77340894+charmful0x@users.noreply.github.com> Date: Sun, 22 Jan 2023 13:02:49 +0100 Subject: [PATCH 3/4] chore add `redstone` molecule key --- src/utils/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/constants.js b/src/utils/constants.js index 98dce5b..02bfcc2 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -15,6 +15,7 @@ export const MOLECULES = [ "massa", "ever", "fuel", + "redstone", "substrate", "rand", ]; From ece8efc76f705e4bf9f75cee0043b1d49421fa96 Mon Sep 17 00:00:00 2001 From: Darwin <77340894+charmful0x@users.noreply.github.com> Date: Sun, 22 Jan 2023 13:03:08 +0100 Subject: [PATCH 4/4] feat: v0.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c307fbb..67d4288 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "molecule", - "version": "0.2.0", + "version": "0.2.1", "type": "module", "description": "reusable EXM components and helper functions for a faster development", "main": "./src/api.js",