Skip to content

Commit

Permalink
Merge pull request #41 from argentlabs/develop
Browse files Browse the repository at this point in the history
release 1.0.22
  • Loading branch information
vladutjs authored Dec 7, 2023
2 parents 80aedf1 + 9d9dd2b commit 6f59c47
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starknetkit",
"version": "1.0.21",
"version": "1.0.22",
"repository": "github:argentlabs/starknetkit",
"private": false,
"browser": {
Expand Down Expand Up @@ -104,7 +104,7 @@
"zod": "^3.20.6"
},
"peerDependencies": {
"starknet": "^5.18.0"
"starknet": "^5.24.3"
},
"gitHead": "b16688a8638cc138938e74e1a39d004760165d75"
}
47 changes: 24 additions & 23 deletions pnpm-lock.yaml

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

6 changes: 6 additions & 0 deletions src/connectors/webwallet/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ export const DEFAULT_WEBWALLET_ICON = `<svg
fill="currentColor"
/>
</svg>`

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"
24 changes: 24 additions & 0 deletions src/connectors/webwallet/helpers/mapTargetUrlToNodeUrl.ts
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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,
Expand Down

0 comments on commit 6f59c47

Please sign in to comment.