Skip to content

Commit

Permalink
Update rpc urls and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Dec 3, 2024
1 parent 1cecc29 commit fa9a474
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/embed-iframe-mainnet/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"headers": [
{
"key": "Content-Security-Policy",
"value": "default-src 'self'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; font-src 'self' https://fonts.gstatic.com; script-src 'self'; object-src 'none'; connect-src 'self' https://umamiwallet.com https://www.googleapis.com https://graph.facebook.com https://mainnet.ecadinfra.com https://kukai.eu.auth0.com https://fnd.web3auth.io https://*.node.web3auth.io https://*.tor.us https://prod.tcinfra.net https://api.mainnet.tzkt.io https://vitals.vercel-insights.com; img-src 'self' data:; frame-ancestors 'self' https://kanvas-poa.vercel.app https://kanvas-poa-git-poa-release-trili-tech.vercel.app"
"value": "default-src 'self'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; font-src 'self' https://fonts.gstatic.com; script-src 'self'; object-src 'none'; connect-src 'self' https://umamiwallet.com https://www.googleapis.com https://graph.facebook.com https://mainnet.tezos.ecadinfra.com https://kukai.eu.auth0.com https://fnd.web3auth.io https://*.node.web3auth.io https://*.tor.us https://prod.tcinfra.net https://api.mainnet.tzkt.io https://vitals.vercel-insights.com; img-src 'self' data:; frame-ancestors 'self' https://kanvas-poa.vercel.app https://kanvas-poa-git-poa-release-trili-tech.vercel.app"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/embed-iframe/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"headers": [
{
"key": "Content-Security-Policy",
"value": "default-src 'self'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; font-src 'self' https://fonts.gstatic.com; script-src 'self'; object-src 'none'; connect-src 'self' https://umamiwallet.com https://www.googleapis.com https://graph.facebook.com https://kukai.eu.auth0.com https://fnd.web3auth.io https://*.node.web3auth.io https://*.tor.us https://ghostnet.ecadinfra.com https://api.ghostnet.tzkt.io https://vitals.vercel-insights.com; img-src 'self' data:"
"value": "default-src 'self'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; font-src 'self' https://fonts.gstatic.com; script-src 'self'; object-src 'none'; connect-src 'self' https://umamiwallet.com https://www.googleapis.com https://graph.facebook.com https://kukai.eu.auth0.com https://fnd.web3auth.io https://*.node.web3auth.io https://*.tor.us https://ghostnet.tezos.ecadinfra.com https://api.ghostnet.tzkt.io https://vitals.vercel-insights.com; img-src 'self' data:"
}
]
}
Expand Down
61 changes: 61 additions & 0 deletions packages/state/src/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { mockLedgerAccount, mockMnemonicAccount, mockSecretKeyAccount } from "@u
import { mockImplicitAddress } from "@umami/tezos";

import { accountsMigrations, mainStoreMigrations } from "./migrations";

Check warning on line 4 in packages/state/src/migrations.test.ts

View workflow job for this annotation

GitHub Actions / test

There should be at least one empty line between import groups
import { produce } from "immer";

Check warning on line 5 in packages/state/src/migrations.test.ts

View workflow job for this annotation

GitHub Actions / test

`immer` import should occur before import of `./migrations`

describe("migrations", () => {
describe("main migrations", () => {
Expand Down Expand Up @@ -97,6 +98,66 @@ describe("migrations", () => {
assets: { accountStates: {}, block: { level: 5 } },
});
});

describe("9", () => {
const migration = mainStoreMigrations[9];

it("should update rpcUrl for mainnet", () => {
const initialState = {
networks: {
current: { name: "mainnet", rpcUrl: "" },
available: [
{ name: "mainnet", rpcUrl: "" },
{ name: "ghostnet", rpcUrl: "" },
{ name: "testnet", rpcUrl: "" },
],
},
};

const expectedState = {
networks: {
current: { name: "mainnet", rpcUrl: "https://mainnet.tezos.ecadinfra.com" },
available: [
{ name: "mainnet", rpcUrl: "https://mainnet.tezos.ecadinfra.com" },
{ name: "ghostnet", rpcUrl: "https://ghostnet.tezos.ecadinfra.com" },
{ name: "testnet", rpcUrl: "" }, // Unchanged
],
},
};

const migratedState = produce(initialState, (draft: any) => migration(draft));

expect(migratedState).toEqual(expectedState);
});

it("should update rpcUrl for ghostnet", () => {
const initialState = {
networks: {
current: { name: "ghostnet", rpcUrl: "" },
available: [
{ name: "mainnet", rpcUrl: "" },
{ name: "ghostnet", rpcUrl: "" },
{ name: "testnet", rpcUrl: "" },
],
},
};

const expectedState = {
networks: {
current: { name: "ghostnet", rpcUrl: "https://ghostnet.tezos.ecadinfra.com" },
available: [
{ name: "mainnet", rpcUrl: "https://mainnet.tezos.ecadinfra.com" },
{ name: "ghostnet", rpcUrl: "https://ghostnet.tezos.ecadinfra.com" },
{ name: "testnet", rpcUrl: "" }, // Unchanged
],
},
};

const migratedState = produce(initialState, (draft: any) => migration(draft));

expect(migratedState).toEqual(expectedState);
});
});
});

describe("account migrations", () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/state/src/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ export const mainStoreMigrations = {
9: (state: any) =>
produce(state, (draft: any) => {
if (draft.networks.current.name === "mainnet") {
draft.networks.current.rpcUrl = "https://mainnet.ecadinfra.com";
draft.networks.current.rpcUrl = "https://mainnet.tezos.ecadinfra.com";
} else if (draft.networks.current.name === "ghostnet") {
draft.networks.current.rpcUrl = "https://ghostnet.tezos.ecadinfra.com";
}
for (const network of draft.networks.available) {
if (network.name === "mainnet") {
network.rpcUrl = "https://mainnet.ecadinfra.com";
break;
network.rpcUrl = "https://mainnet.tezos.ecadinfra.com";
} else if (network.name === "ghostnet") {
network.rpcUrl = "https://ghostnet.tezos.ecadinfra.com";
}
}
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/tezos/src/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { type Network } from "./types";

export const MAINNET: Network = {
name: "mainnet",
rpcUrl: "https://mainnet.ecadinfra.com",
rpcUrl: "https://mainnet.tezos.ecadinfra.com",
tzktApiUrl: "https://api.mainnet.tzkt.io",
tzktExplorerUrl: "https://tzkt.io",
buyTezUrl: "https://widget.wert.io",
};

export const GHOSTNET: Network = {
name: "ghostnet",
rpcUrl: "https://ghostnet.ecadinfra.com",
rpcUrl: "https://ghostnet.tezos.ecadinfra.com",
tzktApiUrl: "https://api.ghostnet.tzkt.io",
tzktExplorerUrl: "https://ghostnet.tzkt.io",
buyTezUrl: "https://faucet.ghostnet.teztnets.com/",
Expand Down

0 comments on commit fa9a474

Please sign in to comment.