-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement argent web wallet connector
- Loading branch information
Showing
17 changed files
with
366 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from "./connector" | ||
export * from "./webwallet" | ||
export * from "./tokenboundAccount" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
src/connectors/tokenboundAccount/webwallet/helpers/mapTargetUrlToNetworkId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { constants } from "starknet" | ||
|
||
// Using NetworkName as a value. | ||
const Network: typeof constants.NetworkName = constants.NetworkName | ||
|
||
const DEVELOPMENT_NETWORK = Network.SN_SEPOLIA | ||
|
||
export function mapTargetUrlToNetworkId(target: string): constants.NetworkName { | ||
try { | ||
const { origin } = new URL(target) | ||
if (origin.includes("localhost") || origin.includes("127.0.0.1")) { | ||
return DEVELOPMENT_NETWORK | ||
} | ||
if (origin.includes("hydrogen")) { | ||
return Network.SN_SEPOLIA | ||
} | ||
if (origin.includes("staging")) { | ||
return Network.SN_MAIN | ||
} | ||
if (origin.includes("dev")) { | ||
return Network.SN_SEPOLIA | ||
} | ||
if (origin.includes("argent.xyz")) { | ||
return Network.SN_MAIN | ||
} | ||
} catch (e) { | ||
console.warn( | ||
"Could not determine network from target URL, defaulting to mainnet-alpha", | ||
) | ||
} | ||
return Network.SN_MAIN | ||
} |
2 changes: 1 addition & 1 deletion
2
...ebwallet/helpers/mapTargetUrlToNodeUrl.ts → ...ebwallet/helpers/mapTargetUrlToNodeUrl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
src/connectors/tokenboundAccount/webwallet/helpers/publicRcpNodes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export type PublicRpcNode = { | ||
mainnet: string | ||
testnet: string | ||
} | ||
|
||
// Public RPC nodes | ||
export const BLAST_RPC_NODE: PublicRpcNode = { | ||
mainnet: "https://starknet-mainnet.public.blastapi.io", | ||
testnet: "https://starknet-sepolia.public.blastapi.io", | ||
} as const | ||
|
||
export const LAVA_RPC_NODE: PublicRpcNode = { | ||
mainnet: "https://rpc.starknet.lava.build", | ||
testnet: "https://rpc.starknet-sepolia.lava.build", | ||
} as const | ||
|
||
export const PUBLIC_RPC_NODES = [BLAST_RPC_NODE, LAVA_RPC_NODE] as const | ||
|
||
export function getRandomPublicRPCNode() { | ||
const randomIndex = Math.floor(Math.random() * PUBLIC_RPC_NODES.length) | ||
return PUBLIC_RPC_NODES[randomIndex] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.