diff --git a/package.json b/package.json index b41c414..350890a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starknetkit", - "version": "1.0.21", + "version": "1.0.22", "repository": "github:argentlabs/starknetkit", "private": false, "browser": { @@ -104,7 +104,7 @@ "zod": "^3.20.6" }, "peerDependencies": { - "starknet": "^5.18.0" + "starknet": "^5.24.3" }, "gitHead": "b16688a8638cc138938e74e1a39d004760165d75" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2bb2187..ebeffe8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,13 +28,13 @@ dependencies: version: 3.3.0 get-starknet-core: specifier: ^3.1.0 - version: 3.1.0(starknet@5.18.0) + version: 3.1.0(starknet@5.24.3) lodash-es: specifier: ^4.17.21 version: 4.17.21 starknet: - specifier: ^5.18.0 - version: 5.18.0 + specifier: ^5.24.3 + version: 5.24.3 svelte-forms: specifier: ^2.3.1 version: 2.3.1 @@ -911,14 +911,10 @@ packages: glob: 7.1.7 dev: true - /@noble/curves@1.0.0: - resolution: {integrity: sha512-2upgEu0iLiDVDZkNLeFV2+ht0BAVgQnEmCk6JsOch9Rp8xfkMCbvbAZlA2pBHQc73dbl+vFOXfqkf4uemdn0bw==} + /@noble/curves@1.2.0: + resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} dependencies: - '@noble/hashes': 1.3.0 - dev: false - - /@noble/hashes@1.3.0: - resolution: {integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==} + '@noble/hashes': 1.3.2 dev: false /@noble/hashes@1.3.2: @@ -1124,6 +1120,17 @@ packages: string-argv: 0.3.2 dev: true + /@scure/base@1.1.3: + resolution: {integrity: sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==} + dev: false + + /@scure/starknet@0.3.0: + resolution: {integrity: sha512-Ma66yZlwa5z00qI5alSxdWtIpky5LBhy22acVFdoC5kwwbd9uDyMWEYzWHdNyKmQg9t5Y2UOXzINMeb3yez+Gw==} + dependencies: + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + dev: false + /@semantic-release/commit-analyzer@10.0.4(semantic-release@21.1.1): resolution: {integrity: sha512-pFGn99fn8w4/MHE0otb2A/l5kxgOuxaaauIh4u30ncoTJuqWj4hXTgEJ03REqjS+w1R2vPftSsO26WC61yOcpw==} engines: {node: '>=18'} @@ -3717,12 +3724,12 @@ packages: has-symbols: 1.0.3 dev: true - /get-starknet-core@3.1.0(starknet@5.18.0): + /get-starknet-core@3.1.0(starknet@5.24.3): resolution: {integrity: sha512-SPeYnzqKRXuukNoEr5aobxBmvhUSt4uWs6kFhMXl+3fG2R43u2D2DreDkA1n6T5DF10x5zLogldiHqn/jGlxEA==} peerDependencies: starknet: ^5.14.1 dependencies: - starknet: 5.18.0 + starknet: 5.24.3 dev: false /get-stream@6.0.1: @@ -4857,13 +4864,6 @@ packages: engines: {node: '>= 8'} dev: true - /micro-starknet@0.2.3: - resolution: {integrity: sha512-6XBcC+GerlwJSR4iA0VaeXtS2wrayWFcA4PEzrJPMuFmWCaUtuGIq5K/DB5F/XgnL54/zl2Bxo690Lj7mYVA8A==} - dependencies: - '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.2 - dev: false - /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} engines: {node: '>=8.6'} @@ -6128,13 +6128,14 @@ packages: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} dev: true - /starknet@5.18.0: - resolution: {integrity: sha512-2b5+F+kfp8fTBAfBpHNmtjhuljZb3P2JMhubP/KWIJAGXwBAalPklOwEYY7Bb2slkPjfkDH0kPxI4037sQcQ+Q==} + /starknet@5.24.3: + resolution: {integrity: sha512-v0TuaNc9iNtHdbIRzX372jfQH1vgx2rwBHQDMqK4DqjJbwFEE5dog8Go6rGiZVW750NqRSWrZ7ahqyRNc3bscg==} dependencies: - '@noble/curves': 1.0.0 + '@noble/curves': 1.2.0 + '@scure/base': 1.1.3 + '@scure/starknet': 0.3.0 isomorphic-fetch: 3.0.0 lossless-json: 2.0.11 - micro-starknet: 0.2.3 pako: 2.1.0 url-join: 4.0.1 transitivePeerDependencies: diff --git a/src/connectors/webwallet/constants.ts b/src/connectors/webwallet/constants.ts index d209e53..f1a69bd 100644 --- a/src/connectors/webwallet/constants.ts +++ b/src/connectors/webwallet/constants.ts @@ -14,3 +14,9 @@ export const DEFAULT_WEBWALLET_ICON = ` ` + +export const RPC_NODE_URL_TESTNET = + "https://api.hydrogen.argent47.net/v1/starknet/goerli/rpc/v0.5" + +export const RPC_NODE_URL_MAINNET = + "https://cloud.argent-api.com/v1/starknet/goerli/rpc/v0.5" diff --git a/src/connectors/webwallet/helpers/mapTargetUrlToNodeUrl.ts b/src/connectors/webwallet/helpers/mapTargetUrlToNodeUrl.ts new file mode 100644 index 0000000..d3f83de --- /dev/null +++ b/src/connectors/webwallet/helpers/mapTargetUrlToNodeUrl.ts @@ -0,0 +1,24 @@ +import { RPC_NODE_URL_MAINNET, RPC_NODE_URL_TESTNET } from "../constants" + +export function mapTargetUrlToNodeUrl(target: string): string { + try { + const { origin } = new URL(target) + if (origin.includes("localhost") || origin.includes("127.0.0.1")) { + return RPC_NODE_URL_TESTNET + } + if (origin.includes("hydrogen")) { + return RPC_NODE_URL_TESTNET + } + if (origin.includes("staging")) { + return RPC_NODE_URL_MAINNET + } + if (origin.includes("argent.xyz")) { + return RPC_NODE_URL_MAINNET + } + } catch (e) { + console.warn( + "Could not determine rpc nodeUrl from target URL, defaulting to mainnet", + ) + } + return RPC_NODE_URL_MAINNET +} diff --git a/src/connectors/webwallet/starknetWindowObject/getWebWalletStarknetObject.ts b/src/connectors/webwallet/starknetWindowObject/getWebWalletStarknetObject.ts index ffca03d..a7ae80e 100644 --- a/src/connectors/webwallet/starknetWindowObject/getWebWalletStarknetObject.ts +++ b/src/connectors/webwallet/starknetWindowObject/getWebWalletStarknetObject.ts @@ -1,7 +1,7 @@ import type { CreateTRPCProxyClient } from "@trpc/client" -import { SequencerProvider } from "starknet" +import { RpcProvider } from "starknet" -import { mapTargetUrlToNetworkId } from "../../../helpers/mapTargetUrlToNetworkId" +import { mapTargetUrlToNodeUrl } from "../helpers/mapTargetUrlToNodeUrl" import type { AppRouter } from "../helpers/trpc" import type { WebWalletStarknetWindowObject } from "./argentStarknetWindowObject" import { getArgentStarknetWindowObject } from "./argentStarknetWindowObject" @@ -15,8 +15,8 @@ export const getWebWalletStarknetObject = async ( throw new Error("window is not defined") } - const network = mapTargetUrlToNetworkId(target) - const defaultProvider = new SequencerProvider({ network }) + const nodeUrl = mapTargetUrlToNodeUrl(target) + const defaultProvider = new RpcProvider({ nodeUrl }) const starknetWindowObject = getArgentStarknetWindowObject( { host: globalWindow.location.origin,