Skip to content

Commit

Permalink
remove @solana/spl-token-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
supermean-ayaz committed Jul 13, 2022
1 parent 03c9209 commit c1408df
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 68 deletions.
23 changes: 1 addition & 22 deletions lib/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeTokenAmount = exports.sleep = exports.getTokenList = exports.getCoinGeckoPrices = exports.getRaydiumPrices = exports.createProgram = exports.createAnchorProvider = exports.createReadonlyWallet = exports.createConnection = exports.options = exports.MSP_ID = exports.USDC_PUBKEY = exports.SMEAN_INFO = exports.SMEAN_PUBKEY = exports.MEAN_INFO = exports.MEAN_PUBKEY = void 0;
exports.normalizeTokenAmount = exports.sleep = exports.getCoinGeckoPrices = exports.getRaydiumPrices = exports.createProgram = exports.createAnchorProvider = exports.createReadonlyWallet = exports.createConnection = exports.options = exports.MSP_ID = exports.USDC_PUBKEY = exports.SMEAN_INFO = exports.SMEAN_PUBKEY = exports.MEAN_INFO = exports.MEAN_PUBKEY = void 0;
const web3_js_1 = require("@solana/web3.js");
const anchor_1 = require("@project-serum/anchor");
const spl_token_registry_1 = require("@solana/spl-token-registry");
const cross_fetch_1 = require("cross-fetch");
//tokens prod
exports.MEAN_PUBKEY = new web3_js_1.PublicKey("MEANeD3XDdUmNMsRGjASkSWdC8prLYsoRJ61pPeHctD");
Expand Down Expand Up @@ -82,26 +81,6 @@ const getCoinGeckoPrices = (ids) => __awaiter(void 0, void 0, void 0, function*
return result;
});
exports.getCoinGeckoPrices = getCoinGeckoPrices;
const getTokenList = (includedTokens, excludedTokens) => __awaiter(void 0, void 0, void 0, function* () {
if (includedTokens && excludedTokens) {
throw new Error("Can not pass both included and excluded token lists");
}
const res = yield new spl_token_registry_1.TokenListProvider().resolve();
let resultTokenList = res
.filterByChainId(101)
.excludeByTag("nft")
.getList();
if (includedTokens) {
resultTokenList = resultTokenList
.filter(t => includedTokens.findIndex(a => a === t.address) >= 0);
}
if (excludedTokens) {
resultTokenList = resultTokenList
.filter(t => excludedTokens.findIndex(a => a === t.address) === -1);
}
return resultTokenList;
});
exports.getTokenList = getTokenList;
const sleep = (ms, log = true) => {
if (log) {
console.log("Sleeping for", ms / 1000, "seconds");
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"dependencies": {
"@mean-dao/msp": "^2.5.3",
"@project-serum/anchor": "^0.25.0",
"@solana/spl-token-registry": "^0.2.4574",
"@solana/web3.js": "^1.47.3",
"cross-fetch": "^3.1.5",
"dayjs": "^1.11.3",
Expand Down
26 changes: 0 additions & 26 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Commitment, Connection, ConnectionConfig, Keypair, PublicKey, ConfirmOptions } from "@solana/web3.js";
import { Program, Idl, Wallet, AnchorProvider } from "@project-serum/anchor";
import { TokenInfo, TokenListProvider } from "@solana/spl-token-registry";
import { fetch } from 'cross-fetch';

//tokens prod
Expand Down Expand Up @@ -91,31 +90,6 @@ export const getCoinGeckoPrices = async (ids: { [k: string]: string }): Promise<
return result;
};

export const getTokenList = async (includedTokens?: string[], excludedTokens?: string[]): Promise<TokenInfo[]> => {

if (includedTokens && excludedTokens) {
throw new Error("Can not pass both included and excluded token lists");
}

const res = await new TokenListProvider().resolve();
let resultTokenList = res
.filterByChainId(101)
.excludeByTag("nft")
.getList();

if (includedTokens) {
resultTokenList = resultTokenList
.filter(t => includedTokens.findIndex(a => a === t.address) >= 0);
}

if (excludedTokens) {
resultTokenList = resultTokenList
.filter(t => excludedTokens.findIndex(a => a === t.address) === -1);
}

return resultTokenList;
}

export const sleep = (ms: number, log: boolean = true) => {
if (log) { console.log("Sleeping for", ms / 1000, "seconds"); }
return new Promise((resolve) => setTimeout(resolve, ms));
Expand Down
19 changes: 0 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@
dependencies:
buffer "~6.0.3"

"@solana/spl-token-registry@^0.2.4574":
version "0.2.4574"
resolved "https://registry.yarnpkg.com/@solana/spl-token-registry/-/spl-token-registry-0.2.4574.tgz#13f4636b7bec90d2bb43bbbb83512cd90d2ce257"
integrity sha512-JzlfZmke8Rxug20VT/VpI2XsXlsqMlcORIUivF+Yucj7tFi7A0dXG7h+2UnD0WaZJw8BrUz2ABNkUnv89vbv1A==
dependencies:
cross-fetch "3.0.6"

"@solana/spl-token@^0.1.8":
version "0.1.8"
resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.1.8.tgz#f06e746341ef8d04165e21fc7f555492a2a0faa6"
Expand Down Expand Up @@ -312,13 +305,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==

[email protected]:
version "3.0.6"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.6.tgz#3a4040bc8941e653e0e9cf17f29ebcd177d3365c"
integrity sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ==
dependencies:
node-fetch "2.6.1"

cross-fetch@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
Expand Down Expand Up @@ -546,11 +532,6 @@ node-fetch@2, [email protected]:
dependencies:
whatwg-url "^5.0.0"

[email protected]:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==

node-gyp-build@^4.2.0, node-gyp-build@^4.3.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.5.0.tgz#7a64eefa0b21112f89f58379da128ac177f20e40"
Expand Down

0 comments on commit c1408df

Please sign in to comment.