From 9a92a0051f36bc81ef0c5a9ffb42c7d2a1e00a06 Mon Sep 17 00:00:00 2001 From: bluecco Date: Thu, 17 Oct 2024 13:11:52 +0200 Subject: [PATCH] feat: add keplr and okx extensions --- package.json | 2 +- pnpm-lock.yaml | 30 +++---- .../connect/ConnectButtonStarknetkitNext.tsx | 82 +++++++++++++------ 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 6e922ea..483227c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "starknet-react-chains-next": "npm:@starknet-react/chains@3.0.0-beta.3", "starknet-react-core-next": "npm:@starknet-react/core@3.0.1-beta.0", "starknetkit-latest": "npm:starknetkit@^1.1.9", - "starknetkit-next": "npm:starknetkit@^2.3.2" + "starknetkit-next": "npm:starknetkit@^2.3.3" }, "devDependencies": { "@types/lodash-es": "^4.17.12", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24af880..15f1a14 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,8 +72,8 @@ importers: specifier: npm:starknetkit@^1.1.9 version: starknetkit@1.1.9(starknet@6.11.0) starknetkit-next: - specifier: npm:starknetkit@^2.3.2 - version: starknetkit@2.3.2(starknet@6.11.0) + specifier: npm:starknetkit@^2.3.3 + version: starknetkit@2.3.3(starknet@6.11.0) devDependencies: '@types/lodash-es': specifier: ^4.17.12 @@ -632,11 +632,11 @@ packages: '@stablelib/x25519@1.0.3': resolution: {integrity: sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw==} - '@starknet-io/get-starknet-core@4.0.0': - resolution: {integrity: sha512-M++JTbMxZJ5wCkw1f4vAXCY3BTlRMdxFScqsIgZonLXD3GKHPyM/pFi/JqorPO1o4RKHLnFX6M7r0izZ/NWpvA==} + '@starknet-io/get-starknet-core@4.0.2': + resolution: {integrity: sha512-JxUOMV6HYVUzmGJb0lyI+/L3KGQCcyQlCuEA9UvPVcR8okqTFFQgZpUm8YTyrgwF/5P/eRH620+Kc73i341eLw==} - '@starknet-io/get-starknet@4.0.0': - resolution: {integrity: sha512-SmnRzBewS0BVjtKzViSrWXi+SvOnSrj9hnvlx8B3ZnCq9A2NuX8pNI550lDBLl/ilIr587FH2VNAj6jdgsyhJQ==} + '@starknet-io/get-starknet@4.0.2': + resolution: {integrity: sha512-/yp6xE0sBYTtnRxOO+T1m1kMgw5AohBF/ppWuBxuT2Xc2GL/V9z7CGe1ltjvFLSSTHT7tly+0HpvYmBEst/QFQ==} '@starknet-io/types-js@0.7.7': resolution: {integrity: sha512-WLrpK7LIaIb8Ymxu6KF/6JkGW1sso988DweWu7p5QY/3y7waBIiPvzh27D9bX5KIJNRDyOoOVoHVEKYUYWZ/RQ==} @@ -2565,8 +2565,8 @@ packages: peerDependencies: starknet: ^6.7.0 - starknetkit@2.3.2: - resolution: {integrity: sha512-qedc6m8r5c5lqn6Ovf+TdDnGtoIYsx2A+VYyHAD9vxTVrRDKightKJB5jN2A/dTEewZoCgssqmjdsAoAiCdcdQ==} + starknetkit@2.3.3: + resolution: {integrity: sha512-RBr+tVT0KphghG3OO7mnAureOryqzNAxGvt2juYvAEUxRSbvCUlprxDUk7/wYt9dfSLGD4mLKFq0P36/8MVB9w==} peerDependencies: starknet: ^6.9.0 @@ -3591,14 +3591,14 @@ snapshots: '@stablelib/random': 1.0.2 '@stablelib/wipe': 1.0.1 - '@starknet-io/get-starknet-core@4.0.0': + '@starknet-io/get-starknet-core@4.0.2': dependencies: '@module-federation/runtime': 0.1.21 '@starknet-io/types-js': 0.7.7 - '@starknet-io/get-starknet@4.0.0': + '@starknet-io/get-starknet@4.0.2': dependencies: - '@starknet-io/get-starknet-core': 4.0.0 + '@starknet-io/get-starknet-core': 4.0.2 bowser: 2.11.0 '@starknet-io/types-js@0.7.7': {} @@ -5960,10 +5960,10 @@ snapshots: - uWebSockets.js - utf-8-validate - starknetkit@2.3.2(starknet@6.11.0): + starknetkit@2.3.3(starknet@6.11.0): dependencies: - '@starknet-io/get-starknet': 4.0.0 - '@starknet-io/get-starknet-core': 4.0.0 + '@starknet-io/get-starknet': 4.0.2 + '@starknet-io/get-starknet-core': 4.0.2 '@starknet-io/types-js': 0.7.7 '@trpc/client': 10.45.2(@trpc/server@10.45.2) '@trpc/server': 10.45.2 @@ -6324,7 +6324,7 @@ snapshots: webauthn-p256@0.0.5: dependencies: '@noble/curves': 1.4.0 - '@noble/hashes': 1.4.0 + '@noble/hashes': 1.5.0 webidl-conversions@3.0.1: {} diff --git a/src/components/connect/ConnectButtonStarknetkitNext.tsx b/src/components/connect/ConnectButtonStarknetkitNext.tsx index c139a06..b15aa50 100644 --- a/src/components/connect/ConnectButtonStarknetkitNext.tsx +++ b/src/components/connect/ConnectButtonStarknetkitNext.tsx @@ -8,7 +8,11 @@ import { starknetkitVersionAtom } from "@/state/versionState" import { Button, Flex } from "@chakra-ui/react" import { useSetAtom } from "jotai" import { useRouter } from "next/navigation" +import { useState } from "react" import { connect } from "starknetkit-next" +import { ArgentMobileBaseConnector } from "starknetkit-next/argentMobile" +import { InjectedConnector } from "starknetkit-next/injected" +import { WebWalletConnector } from "starknetkit-next/webwallet" const ConnectButtonStarknetkitNext = () => { const setWallet = useSetAtom(walletStarknetkitNextAtom) @@ -17,17 +21,38 @@ const ConnectButtonStarknetkitNext = () => { const setStarknetkitVersion = useSetAtom(starknetkitVersionAtom) const navigate = useRouter() + const [withAdditionalWallets, setWithAdditionalWallets] = useState(false) + const connectFn = async () => { - const res = await connect({ - modalMode: "alwaysAsk", - webWalletUrl: ARGENT_WEBWALLET_URL, - argentMobileOptions: { - dappName: "Starknetkit example dapp", - url: window.location.hostname, - chainId: CHAIN_ID, - icons: [], - }, - }) + const res = await connect( + withAdditionalWallets + ? { + modalMode: "alwaysAsk", + connectors: [ + new InjectedConnector({ options: { id: "argentX" } }), + new InjectedConnector({ options: { id: "braavos" } }), + new InjectedConnector({ options: { id: "keplr" } }), + new InjectedConnector({ options: { id: "okxwallet" } }), + new ArgentMobileBaseConnector({ + dappName: "Starknetkit example dapp", + url: window.location.hostname, + chainId: CHAIN_ID, + icons: [], + }), + new WebWalletConnector({ url: ARGENT_WEBWALLET_URL }), + ], + } + : { + modalMode: "alwaysAsk", + webWalletUrl: ARGENT_WEBWALLET_URL, + argentMobileOptions: { + dappName: "Starknetkit example dapp", + url: window.location.hostname, + chainId: CHAIN_ID, + icons: [], + }, + }, + ) const { wallet, connectorData, connector } = res setWallet(wallet) @@ -40,19 +65,30 @@ const ConnectButtonStarknetkitNext = () => { } return ( - - - (with session keys) {/* TODO: will be removed */} - + <> + + + + + setWithAdditionalWallets(!withAdditionalWallets)} + /> + Include Keplr and OKX wallets with starknetkit@next ( + {process.env.starknetkitNextVersion}) + + ) }