Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter out optimism-goerli-staging from chains #59

Merged
merged 6 commits into from
Oct 25, 2023
Merged
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
46 changes: 6 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"dependencies": {
"@ensdomains/ensjs": "3.0.0-alpha.64",
"@tableland/sdk": "^4.4.2",
"@tableland/sdk": "^4.5.3",
"@tableland/sqlparser": "^1.3.0",
"cli-select-2": "^2.0.0",
"cosmiconfig": "^8.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { extname } from "path";
import { Wallet, providers, getDefaultProvider } from "ethers";
import { helpers } from "@tableland/sdk";

// TODO: should be able to remove the "staging" filter since the SDK handles it
export const getChains = function (): typeof helpers.supportedChains {
return Object.fromEntries(
Object.entries(helpers.supportedChains).filter(
Expand Down
2 changes: 1 addition & 1 deletion packages/local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"up:dev": "node dist/esm/up.js --validator ../go-tableland --registry ../evm-tableland"
},
"dependencies": {
"@tableland/sdk": "^4.4.2",
"@tableland/sdk": "^4.5.3",
"@tableland/validator": "^1.8.1",
"cross-spawn": "^7.0.3",
"enquirer": "^2.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tableland/sdk",
"version": "4.5.3-dev.0",
"version": "4.5.3",
"description": "A database client and helpers for the Tableland network",
"publishConfig": {
"access": "public"
Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/src/helpers/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ const mapped = entries.map(([chainName, contractAddress]) => {
];
return entry;
});
// Filter out "optimism-goerli-staging"
const filtered = mapped.filter(
([chainName]) => chainName !== "optimism-goerli-staging"
);

/**
* The set of chains and their information as supported by the Tableland network.
*/
export const supportedChains = Object.fromEntries(mapped) as Record<
export const supportedChains = Object.fromEntries(filtered) as Record<
ChainName,
ChainInfo
>;
Expand Down
41 changes: 39 additions & 2 deletions packages/sdk/test/chains.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@ describe("chains", function () {
});

test("where ensure we have a default set of chains with ids", function () {
// Mainnets
strictEqual(getChainId("mainnet"), 1);
strictEqual(getChainId("localhost"), 31337);
strictEqual(getChainId("maticmum"), 80001);
strictEqual(getChainId("homestead"), 1);
strictEqual(getChainId("matic"), 137);
strictEqual(getChainId("optimism"), 10);
strictEqual(getChainId("arbitrum"), 42161);
strictEqual(getChainId("arbitrum-nova"), 42170);
strictEqual(getChainId("filecoin"), 314);
// Testnets
strictEqual(getChainId("sepolia"), 11155111);
strictEqual(getChainId("maticmum"), 80001);
strictEqual(getChainId("optimism-goerli"), 420);
strictEqual(getChainId("arbitrum-goerli"), 421613);
strictEqual(getChainId("filecoin-calibration"), 314159);
// Local
strictEqual(getChainId("localhost"), 31337);
});

test("where spot check a few chain info objects", function () {
Expand All @@ -94,6 +105,32 @@ describe("chains", function () {
strictEqual(maticmum.baseUrl, testnetsUrl);
strictEqual(maticmum.chainId, 80001);
});

test("where it fails when invalid chain is passed", function () {
// Should not exist for Optimism Goerli staging environment (filtered out)
throws(
() => getChainId("optimism-goerli-staging"),
(err: any) => {
strictEqual(
err.message,
"cannot use unsupported chain: optimism-goerli-staging"
);
return true;
}
);

// Try some random chain ID
throws(
() => getChainId(999999999999),
(err: any) => {
strictEqual(
err.message,
"cannot use unsupported chain: 999999999999"
);
return true;
}
);
});
});

describe("overrideDefaults()", function () {
Expand Down
Loading