Skip to content
This repository was archived by the owner on Dec 4, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
},
"main": "dist/index.js",
"module": "dist/index.es.js",
"browser": {
"localPorridge": false
},
"files": [
"dist"
],
"types": "dist/index.d.ts",
"dependencies": {
"arweave": "^1.9.1",
"cacheweave": "^1.0.0",
"localporridge": "^1.0.0",
"moment": "^2.28.0",
"node-fetch": "^2.6.1",
"smartweave": "^0.3.6"
Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const config = {
resolve({
preferBuiltins: true,
jsnext: true,
browser: true,
}),
alias({
"@utils": __dirname + "/src/utils",
Expand Down
15 changes: 8 additions & 7 deletions src/lib/get_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { maxInt } from "@utils/constants";
import { getData } from "cacheweave";
import Arweave from "arweave";
import { VertoToken, EdgeQueryResponse } from "types";
import localPorridge from "localporridge";

export const getTokens = async (
client: Arweave,
Expand All @@ -26,14 +27,14 @@ export const getTokens = async (
const IDs: { type: string; id: string }[] = [];
tokenTxs.map((tx) => IDs.push({ type: "tx", id: tx.node.id }));

// TODO(@johnletey): Use `localPorridge` to grab custom tokens.
// @ts-ignore
if (typeof window !== "undefined") {
const storage =
// @ts-ignore
const cache = JSON.parse(localStorage.getItem("customTokens") || "[]");

cache.map((entry: string) => IDs.push({ type: "contract", id: entry }));
}
typeof localStorage == "undefined"
? new localPorridge("./.cache.json")
: // @ts-ignore
localStorage;
const cache = JSON.parse(storage.getItem("customTokens") || "[]");
cache.map((entry: string) => IDs.push({ type: "contract", id: entry }));

const tokens: VertoToken[] = [];
for (const entry of IDs) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"noUnusedLocals": true,
"noImplicitReturns": true,
"target": "es2015",
"module": "es2015",
"module": "esnext",
"lib": ["es2015"],
"paths": {
"@queries/*": ["queries/*"],
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,11 @@ levn@^0.4.1:
prelude-ls "^1.2.1"
type-check "~0.4.0"

localporridge@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/localporridge/-/localporridge-1.0.0.tgz#718eb86547b075ec78b369a26b7d1b6fddd171d5"
integrity sha512-mCaTeK+CMBUElyxQiLOIB0GdEOTZwvYl/VyqynJ+ApQbelItugJnp4+45jBcFbSAvFV9lStnkCK1ZbCNL75iUg==

locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
Expand Down