Merge pull request #8 from FlipsideCrypto/js-package-name-and-version

pass along sdk package name and version
This commit is contained in:
Jim Myers 2022-10-31 14:31:03 -04:00 committed by GitHub
commit 6a71269515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 62 additions and 29311 deletions

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"printWidth": 120,
"semi": true
}

View File

@ -19,6 +19,6 @@ More Details at [ShroomDK](https://sdk.flipsidecrypto.xyz)
| Language | Version | Status |
| ------------------------ | ------- | ---------------------------------------------------------------------------------- |
| ✅ [JS/TypeScript](./js) | 1.0.0 | ![tests](https://github.com/flipsidecrypto/sdk/actions/workflows/ci_js.yml/badge.svg) |
| ✅ [JS/TypeScript](./js) | 1.1.1 | ![tests](https://github.com/flipsidecrypto/sdk/actions/workflows/ci_js.yml/badge.svg) |
| ✅ [Python](./python/) | 1.0.1 | [![tests](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_python.yml/badge.svg)](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_python.yml) |
| ✅ [R](./r/shroomDK/) | 0.1.1 | available on CRAN |

View File

@ -0,0 +1,7 @@
/**
* @type {import('@types/eslint').Linter.Config}
*/
module.exports = {
root: true,
ignorePatterns: ["node_modules", "dist", "public"],
};

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/eslint": "^8.4.8",
"@types/jest": "^27.5.2",
"@types/node": "^16.11.45",
"@types/react": "^18.0.15",

View File

@ -12,7 +12,7 @@ interface ButtonProps {
function getBg(color: string) {
let bgColor = "bg-[#7C7C7C]";
let bgColorHover = "hover:bg-[#BCBCca]";
if (color == "blue") {
if (color === "blue") {
bgColor = "bg-[#2A3492]";
bgColorHover = "hover:bg-[#2A34ca]";
} else if (color === "green") {

View File

@ -1,6 +1,5 @@
import { useEffect, useState } from "react";
import toast from "react-hot-toast";
import { QueryResultSet } from "@flipsidecrypto/sdk";
import { Input } from "../components/input";
import { RetroButton } from "../components/retro-buttons";

View File

@ -1885,6 +1885,14 @@
"@types/estree" "*"
"@types/json-schema" "*"
"@types/eslint@^8.4.8":
version "8.4.8"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.8.tgz#720dd6a32b8219b9aba1a07b13e9d03b622695fd"
integrity sha512-zUCKQI1bUCTi+0kQs5ZQzQ/XILWRLIlh15FXWNykJ+NG3TMKMVvwwC6GP3DR1Ylga15fB7iAExSzc4PNlR5i3w==
dependencies:
"@types/estree" "*"
"@types/json-schema" "*"
"@types/estree@*":
version "1.0.0"
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz"

7
js/.eslintrc.js Normal file
View File

@ -0,0 +1,7 @@
/**
* @type {import('@types/eslint').Linter.Config}
*/
module.exports = {
root: true,
ignorePatterns: ["node_modules", "dist", "public"],
};

View File

@ -1,6 +1,6 @@
{
"name": "@flipsidecrypto/sdk",
"version": "1.1.0",
"version": "1.1.1",
"description": "The official Flipside Crypto SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -30,6 +30,7 @@
"author": "dev@flipsidecrypto.com",
"license": "MIT",
"dependencies": {
"@types/eslint": "^8.4.8",
"axios": "^0.27.2"
}
}

View File

@ -15,9 +15,13 @@ const PARSE_ERROR_MSG =
export class API implements ApiClient {
#baseUrl: string;
#headers: Record<string, string>;
#sdkVersion: string;
#sdkPackage: string;
constructor(baseUrl: string, apiKey: string) {
constructor(baseUrl: string, sdkPackage: string, sdkVersion: string, apiKey: string) {
this.#baseUrl = baseUrl;
this.#sdkPackage = sdkPackage;
this.#sdkVersion = sdkVersion;
this.#headers = {
Accept: "application/json",
"Content-Type": "application/json",
@ -38,6 +42,8 @@ export class API implements ApiClient {
sql: query.sql,
ttl_minutes: query.ttlMinutes,
cached: query.cached,
sdk_package: this.#sdkPackage,
sdk_version: this.#sdkVersion,
},
{ headers: this.#headers }
);

View File

@ -1,14 +1,18 @@
import { API } from "./api";
import { QueryIntegration } from "./integrations";
import { version } from '../package.json';
const API_BASE_URL = "https://api.flipsidecrypto.com";
const SDK_PACKAGE = "js";
const SDK_VERSION = version;
export class Flipside {
query: QueryIntegration;
constructor(apiKey: string, apiBaseUrl: string = API_BASE_URL) {
// Setup API, which will be passed to integrations
const api = new API(apiBaseUrl, apiKey);
const api = new API(apiBaseUrl, SDK_PACKAGE, SDK_VERSION, apiKey);
// declare integrations on Flipside client
this.query = new QueryIntegration(api);

View File

@ -33,7 +33,7 @@
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
"resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */

View File

@ -47,11 +47,29 @@
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.1.tgz#e2c6e73e0bdeb2521d00756d099218e9f5d90a04"
integrity sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==
"@types/eslint@^8.4.8":
version "8.4.8"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.8.tgz#720dd6a32b8219b9aba1a07b13e9d03b622695fd"
integrity sha512-zUCKQI1bUCTi+0kQs5ZQzQ/XILWRLIlh15FXWNykJ+NG3TMKMVvwwC6GP3DR1Ylga15fB7iAExSzc4PNlR5i3w==
dependencies:
"@types/estree" "*"
"@types/json-schema" "*"
"@types/estree@*":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2"
integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==
"@types/istanbul-lib-coverage@^2.0.1":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==
"@types/json-schema@*":
version "7.0.11"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
"@vitest/ui@latest":
version "0.12.6"
resolved "https://registry.yarnpkg.com/@vitest/ui/-/ui-0.12.6.tgz#6dba9bd6781ce1280452e4b25160b3914eb5e435"