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 b0820d2
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
@@ -1,5 +1,6 @@
import { mockLedgerAccount, mockMnemonicAccount, mockSecretKeyAccount } from "@umami/core";
import { mockImplicitAddress } from "@umami/tezos";
import { produce } from "immer";

import { accountsMigrations, mainStoreMigrations } from "./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

1 comment on commit b0820d2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title Lines Statements Branches Functions
apps/desktop Coverage: 84%
83.88% (1764/2103) 79.35% (838/1056) 78.45% (448/571)
apps/web Coverage: 84%
83.88% (1764/2103) 79.35% (838/1056) 78.45% (448/571)
packages/components Coverage: 97%
97.51% (196/201) 95.91% (94/98) 88.13% (52/59)
packages/core Coverage: 81%
81.91% (222/271) 71.22% (99/139) 81.96% (50/61)
packages/crypto Coverage: 100%
100% (43/43) 90.9% (10/11) 100% (7/7)
packages/data-polling Coverage: 97%
95.27% (141/148) 87.5% (21/24) 92.85% (39/42)
packages/multisig Coverage: 98%
98.47% (129/131) 85.71% (18/21) 100% (36/36)
packages/social-auth Coverage: 100%
100% (21/21) 100% (11/11) 100% (3/3)
packages/state Coverage: 85%
84.89% (815/960) 80.86% (186/230) 79% (301/381)
packages/tezos Coverage: 89%
88.72% (118/133) 94.59% (35/37) 86.84% (33/38)
packages/tzkt Coverage: 89%
87.32% (62/71) 87.5% (14/16) 80.48% (33/41)

Please sign in to comment.