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

release 1.0.22 #41

Merged
merged 5 commits into from
Dec 7, 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
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