Skip to content

Commit 8c6f130

Browse files
committed
fix: satoshis typo
1 parent a31ef7f commit 8c6f130

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

demo/redirect-flow-example/src/components/UserCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Dropdown } from "./DropDown";
1212
import { TextField } from "./TextField";
1313

1414
const UserCard: React.FC = () => {
15-
const { drawerHeading, setDrawerHeading, drawerInfo, setDrawerInfo, userInfo, coreKitInstance, networkName } = useCoreKit();
15+
const { drawerHeading, setDrawerHeading, drawerInfo, setDrawerInfo, userInfo, coreKitInstance, coin } = useCoreKit();
1616
const { getAccount, account, getBalance } = useUnifiedRPC();
1717
const [openConsole, setOpenConsole] = React.useState(false);
1818
const [ balance, setBalance ] = React.useState<string>("");
@@ -28,7 +28,7 @@ const UserCard: React.FC = () => {
2828
const fetchWalletAddresses = async () => {
2929
const indices = await coreKitInstance.getTssWalletIndices();
3030
indices.push({ address: account, index: 0 })
31-
indices.sort((a, b) => a.index - b.index);
31+
indices.sort((a: { index: number }, b: { index: number }) => a.index - b.index);
3232
setWalletAddresses(indices);
3333
if (indices.length > 0) {
3434
setSelectedWallet(indices[1].address);
@@ -40,7 +40,7 @@ const UserCard: React.FC = () => {
4040
if (account) {
4141
fetchWalletAddresses();
4242
const balance = await getBalance();
43-
setBalance(`${balance} ${networkName}`);
43+
setBalance(`${balance} ${coin}`);
4444
}
4545
}
4646
init();

demo/redirect-flow-example/src/components/transactions/TransactionCard.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { KeyType } from "@tkey/common-types";
99
const TransactionCard: React.FC = () => {
1010
const [amount, setAmount] = React.useState("0.0001");
1111
const [toAddress, setToAddress] = React.useState("");
12-
const { setDrawerHeading, setDrawerInfo, networkName } = useCoreKit();
12+
const { setDrawerHeading, setDrawerInfo, networkName, coin } = useCoreKit();
1313
const [isLoading, setIsLoading] = React.useState(false);
1414
const { sendTransaction, account } = useUnifiedRPC();
1515
const [faucetLink, setFaucetLink] = React.useState("");
@@ -27,7 +27,7 @@ const TransactionCard: React.FC = () => {
2727
setAmount("0.001");
2828
} else if (networkName === "BTC") {
2929
setFaucetLink("https://coinfaucet.eu/en/btc-testnet/");
30-
setAmount("1000");
30+
setAmount("0.000001");
3131
}
3232
}, [networkName]);
3333

@@ -78,8 +78,8 @@ const TransactionCard: React.FC = () => {
7878
<TextField
7979
value={amount}
8080
onChange={(e) => setAmount(e.target.value)}
81-
label={`Amount ${networkName}`}
82-
placeholder={`Enter amount in ${networkName}`}
81+
label={`Amount in ${coin}`}
82+
placeholder={`Enter amount in ${coin}`}
8383
className="mb-4 rounded-md"
8484
classes={{
8585
container: "flex flex-col justify-center items-center",

demo/redirect-flow-example/src/composibles/useBtc.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ const useBtcRPC = () => {
6262
const address = getAddress(signer, type);
6363
if (!address) throw new Error("Failed to generate address");
6464
const utxos = await fetchUtxos(address);
65-
const balance = utxos.reduce((acc, utxo) => acc + utxo.value, 0);
66-
setBtcBalance(balance.toString());
67-
return balance.toString();
65+
const balanceInSatoshis = utxos.reduce((acc, utxo) => acc + utxo.value, 0);
66+
const balanceInBtc = (balanceInSatoshis || 0) / 100000000;
67+
68+
setBtcBalance(balanceInBtc.toString());
69+
return balanceInBtc.toString();
6870
} catch (err) {
6971
return (err as Error).message;
7072
}

demo/redirect-flow-example/src/composibles/useCoreKit.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { COREKIT_STATUS, CoreKitMode, makeEthereumSigner, UserInfo, WEB3AUTH_NETWORK, Web3AuthMPCCoreKit } from "@web3auth/mpc-core-kit";
1+
import { COREKIT_STATUS, CoreKitMode, makeEthereumSigner, UserInfo, WEB3AUTH_NETWORK, Web3AuthMPCCoreKit } from "@guru_test/mpc-core-kit";
22
// import { PasskeysPlugin } from "@web3auth/mpc-passkey-plugin";
33
import React, { createContext, useContext, useState, useEffect } from "react";
44
import { tssLib as tssLibDkls } from "@toruslabs/tss-dkls-lib";
@@ -56,6 +56,7 @@ interface CoreKitContextType {
5656
setKeyType: React.Dispatch<React.SetStateAction<KeyType>>;
5757
keyType: KeyType;
5858
networkName: "ETH" | "SOL" | "BTC" | undefined;
59+
coin: "ETH" | "SOL" | "SATS" | undefined;
5960
}
6061

6162
// Create the context with default values
@@ -86,6 +87,7 @@ const CoreKitContext = createContext<CoreKitContextType>({
8687
getShareDescriptions: () => { },
8788
shareDescriptions: null,
8889
networkName: undefined,
90+
coin: undefined,
8991
setKeyType: () => { },
9092
keyType: localStorage.getItem("keyType") as KeyType || KeyType.secp256k1,
9193
existingModules: [],
@@ -119,13 +121,18 @@ export const CoreKitProvider: React.FC<CoreKitProviderProps> = ({ children }) =>
119121
const [existingModules, setExistingModules] = React.useState<string[]>([]);
120122
const [keyType, setKeyType] = React.useState<KeyType>(localStorage.getItem("keyType") as KeyType || KeyType.secp256k1);
121123
const [networkName, setNetworkName] = useState<"ETH" | "SOL" | "BTC">();
124+
const [coin, setCoin] = useState<"ETH" | "SOL" | "SATS">();
122125

123126
useEffect(() => {
124127
localStorage.setItem("keyType", keyType);
125128
setNetworkName(keyType === KeyType.secp256k1 ? "ETH"
126129
: keyType === KeyType.ed25519 ? "SOL"
127130
: "BTC"
128131
);
132+
setCoin(keyType === KeyType.secp256k1 ? "ETH"
133+
: keyType === KeyType.ed25519 ? "SOL"
134+
: "SATS"
135+
);
129136
setCoreKitInstance(new Web3AuthMPCCoreKit({
130137
...initialWeb3AuthConfig,
131138
tssLib: keyType === KeyType.secp256k1 ? tssLibDkls : keyType === "BTC" as KeyType ? tssLibFrostBip340 : tssLibFrost,
@@ -209,7 +216,7 @@ export const CoreKitProvider: React.FC<CoreKitProviderProps> = ({ children }) =>
209216
getShareDescriptions,
210217
shareDescriptions, existingModules,
211218
keyType, setKeyType,
212-
networkName,
219+
networkName, coin,
213220
}}>{children}</CoreKitContext.Provider>
214221
);
215222
};

0 commit comments

Comments
 (0)