Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fcd60ec64 | ||
|
|
0006e547a4 |
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.79
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/wallets@2.5.21
|
||||
|
||||
## 4.1.78
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.78",
|
||||
"version": "4.1.79",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.13.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/sdk@4.0.81
|
||||
- @thirdweb-dev/wallets@2.5.21
|
||||
- @thirdweb-dev/auth@4.1.79
|
||||
|
||||
## 0.13.86
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/cli",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.13.86",
|
||||
"version": "0.13.87",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.6.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/sdk@4.0.81
|
||||
- @thirdweb-dev/wallets@2.5.21
|
||||
- @thirdweb-dev/auth@4.1.79
|
||||
|
||||
## 4.6.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.6.19",
|
||||
"version": "4.6.20",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.6.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/sdk@4.0.81
|
||||
- @thirdweb-dev/react-core@4.6.20
|
||||
- @thirdweb-dev/wallets@2.5.21
|
||||
|
||||
## 4.6.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.6.19",
|
||||
"version": "4.6.20",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.81
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`0006e54`](https://github.com/thirdweb-dev/js/commit/0006e547a4425406101ef85c635b83c5c6186d1d)]:
|
||||
- thirdweb@5.19.1
|
||||
|
||||
## 4.0.80
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.80",
|
||||
"version": "4.0.81",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.6.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/sdk@4.0.81
|
||||
- @thirdweb-dev/wallets@2.5.21
|
||||
- @thirdweb-dev/auth@4.1.79
|
||||
|
||||
## 0.6.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.6.29",
|
||||
"version": "0.6.30",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.5.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/sdk@4.0.81
|
||||
|
||||
## 2.5.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.5.20",
|
||||
"version": "2.5.21",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,13 @@
|
||||
# thirdweb
|
||||
|
||||
## 5.19.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3005](https://github.com/thirdweb-dev/js/pull/3005) [`0006e54`](https://github.com/thirdweb-dev/js/commit/0006e547a4425406101ef85c635b83c5c6186d1d) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - - useSendTransaction now switches chain if needed
|
||||
- Fix chain switching with in-app smart accounts
|
||||
- Fix tx simulation for pay modal
|
||||
|
||||
## 5.19.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"version": "5.19.0",
|
||||
"version": "5.19.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
||||
|
||||
@@ -5,12 +5,17 @@ import { sendTransaction } from "../../../../transaction/actions/send-transactio
|
||||
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
|
||||
import type { Account } from "../../../../wallets/interfaces/wallet.js";
|
||||
import {
|
||||
type GetWalletBalanceResult,
|
||||
getWalletBalance,
|
||||
} from "../../../../wallets/utils/getWalletBalance.js";
|
||||
import { fetchBuySupportedDestinations } from "../../../web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js";
|
||||
import { useActiveAccount } from "../wallets/wallet-hooks.js";
|
||||
import {
|
||||
useActiveAccount,
|
||||
useActiveWallet,
|
||||
useSwitchActiveWalletChain,
|
||||
} from "../wallets/wallet-hooks.js";
|
||||
|
||||
type ShowModalData = {
|
||||
tx: PreparedTransaction;
|
||||
@@ -37,10 +42,21 @@ export function useSendTransactionCore(
|
||||
showPayModal?: (data: ShowModalData) => void,
|
||||
gasless?: GaslessOptions,
|
||||
): UseMutationResult<WaitForReceiptOptions, Error, PreparedTransaction> {
|
||||
const account = useActiveAccount();
|
||||
let _account = useActiveAccount();
|
||||
const wallet = useActiveWallet();
|
||||
const switchChain = useSwitchActiveWalletChain();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (tx) => {
|
||||
// switch chain if needed
|
||||
if (wallet && tx.chain.id !== wallet.getChain()?.id) {
|
||||
await switchChain(tx.chain);
|
||||
// in smart wallet case, account may change after chain switch
|
||||
_account = wallet.getAccount();
|
||||
}
|
||||
|
||||
const account = _account;
|
||||
|
||||
if (!account) {
|
||||
throw new Error("No active account");
|
||||
}
|
||||
@@ -90,7 +106,7 @@ export function useSendTransactionCore(
|
||||
chain: tx.chain,
|
||||
client: tx.client,
|
||||
}),
|
||||
getTotalTxCostForBuy(tx),
|
||||
getTotalTxCostForBuy(tx, account),
|
||||
]);
|
||||
|
||||
const walletBalanceWei = walletBalance.value;
|
||||
@@ -122,9 +138,13 @@ export function useSendTransactionCore(
|
||||
});
|
||||
}
|
||||
|
||||
export async function getTotalTxCostForBuy(tx: PreparedTransaction) {
|
||||
export async function getTotalTxCostForBuy(
|
||||
tx: PreparedTransaction,
|
||||
account?: Account,
|
||||
) {
|
||||
const gasCost = await estimateGasCost({
|
||||
transaction: tx,
|
||||
account,
|
||||
});
|
||||
|
||||
const bufferCost = gasCost.wei / 10n;
|
||||
|
||||
@@ -102,7 +102,7 @@ export function ConnectButton(props: ConnectButtonProps) {
|
||||
wallets: wallets,
|
||||
locale: props.locale || "en_US",
|
||||
connectLocale: localeQuery.data,
|
||||
chain: props.chain,
|
||||
chain: props.chain || props.accountAbstraction?.chain,
|
||||
chains: props.chains,
|
||||
walletConnect: props.walletConnect,
|
||||
accountAbstraction: props.accountAbstraction,
|
||||
|
||||
@@ -389,7 +389,7 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
|
||||
wallets: wallets,
|
||||
locale: localeId,
|
||||
connectLocale: localeQuery.data,
|
||||
chain: props.chain,
|
||||
chain: props.chain || props.accountAbstraction?.chain,
|
||||
chains: props.chains,
|
||||
walletConnect: props.walletConnect,
|
||||
accountAbstraction: props.accountAbstraction,
|
||||
|
||||
@@ -217,6 +217,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
||||
buyForTx,
|
||||
hasEditedAmount,
|
||||
isMainScreen: screen.type === "main",
|
||||
account,
|
||||
});
|
||||
|
||||
// check if the screen is expanded or not
|
||||
|
||||
+12
-3
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { formatNumber } from "../../../../../../../utils/formatNumber.js";
|
||||
import { toEther } from "../../../../../../../utils/units.js";
|
||||
import type { Account } from "../../../../../../../wallets/interfaces/wallet.js";
|
||||
import { getTotalTxCostForBuy } from "../../../../../../core/hooks/contract/useSendTransaction.js";
|
||||
import { wait } from "../../../../../../core/utils/wait.js";
|
||||
import type { BuyForTx } from "./types.js";
|
||||
@@ -10,8 +11,10 @@ export function useBuyTxStates(options: {
|
||||
buyForTx?: BuyForTx;
|
||||
hasEditedAmount: boolean;
|
||||
isMainScreen: boolean;
|
||||
account?: Account;
|
||||
}) {
|
||||
const { buyForTx, hasEditedAmount, isMainScreen, setTokenAmount } = options;
|
||||
const { buyForTx, hasEditedAmount, isMainScreen, setTokenAmount, account } =
|
||||
options;
|
||||
const shouldRefreshTokenAmount = !hasEditedAmount && isMainScreen;
|
||||
const stopUpdatingAll = !isMainScreen;
|
||||
|
||||
@@ -35,7 +38,7 @@ export function useBuyTxStates(options: {
|
||||
}
|
||||
|
||||
try {
|
||||
const totalCost = await getTotalTxCostForBuy(buyForTx.tx);
|
||||
const totalCost = await getTotalTxCostForBuy(buyForTx.tx, account);
|
||||
|
||||
if (!mounted) {
|
||||
return;
|
||||
@@ -64,7 +67,13 @@ export function useBuyTxStates(options: {
|
||||
return () => {
|
||||
mounted = false;
|
||||
};
|
||||
}, [buyForTx, shouldRefreshTokenAmount, setTokenAmount, stopUpdatingAll]);
|
||||
}, [
|
||||
buyForTx,
|
||||
shouldRefreshTokenAmount,
|
||||
setTokenAmount,
|
||||
stopUpdatingAll,
|
||||
account,
|
||||
]);
|
||||
|
||||
return {
|
||||
amountNeeded,
|
||||
|
||||
@@ -8,11 +8,7 @@ import {
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import type { TransactionReceipt } from "../../../../transaction/types.js";
|
||||
import { stringify } from "../../../../utils/json.js";
|
||||
import {
|
||||
useActiveAccount,
|
||||
useActiveWallet,
|
||||
useSwitchActiveWalletChain,
|
||||
} from "../../../core/hooks/wallets/wallet-hooks.js";
|
||||
import { useActiveAccount } from "../../../core/hooks/wallets/wallet-hooks.js";
|
||||
import {
|
||||
type SendTransactionPayModalConfig,
|
||||
useSendTransaction,
|
||||
@@ -131,9 +127,7 @@ export function TransactionButton(props: TransactionButtonProps) {
|
||||
...buttonProps
|
||||
} = props;
|
||||
const account = useActiveAccount();
|
||||
const wallet = useActiveWallet();
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
const switchChain = useSwitchActiveWalletChain();
|
||||
|
||||
const sendTransaction = useSendTransaction({
|
||||
gasless,
|
||||
@@ -153,11 +147,6 @@ export function TransactionButton(props: TransactionButtonProps) {
|
||||
try {
|
||||
setIsPending(true);
|
||||
const resolvedTx = await transaction();
|
||||
|
||||
if (wallet && wallet.getChain()?.id !== resolvedTx.chain.id) {
|
||||
await switchChain(resolvedTx.chain);
|
||||
}
|
||||
|
||||
const result = await sendTransaction.mutateAsync(resolvedTx);
|
||||
|
||||
if (onTransactionSent) {
|
||||
|
||||
@@ -25,10 +25,14 @@ export async function connectInAppWallet(
|
||||
client: options.client,
|
||||
authAccount,
|
||||
smartAccountOptions: createOptions.smartAccount,
|
||||
chain: options.chain,
|
||||
});
|
||||
}
|
||||
|
||||
return [authAccount, options.chain || ethereum] as const;
|
||||
return [
|
||||
authAccount,
|
||||
options.chain || createOptions?.smartAccount?.chain || ethereum,
|
||||
] as const;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,16 +55,21 @@ export async function autoConnectInAppWallet(
|
||||
client: options.client,
|
||||
authAccount,
|
||||
smartAccountOptions: createOptions.smartAccount,
|
||||
chain: options.chain,
|
||||
});
|
||||
}
|
||||
|
||||
return [authAccount, options.chain || ethereum] as const;
|
||||
return [
|
||||
authAccount,
|
||||
options.chain || createOptions?.smartAccount?.chain || ethereum,
|
||||
] as const;
|
||||
}
|
||||
|
||||
async function convertToSmartAccount(options: {
|
||||
client: ThirdwebClient;
|
||||
authAccount: Account;
|
||||
smartAccountOptions: CreateWalletArgs<"smart">[1];
|
||||
chain?: Chain;
|
||||
}) {
|
||||
const [{ smartWallet }, { connectSmartWallet }] = await Promise.all([
|
||||
import("../../../create-wallet.js"),
|
||||
@@ -73,6 +82,7 @@ async function convertToSmartAccount(options: {
|
||||
{
|
||||
client: options.client,
|
||||
personalAccount: options.authAccount,
|
||||
chain: options.chain,
|
||||
},
|
||||
options.smartAccountOptions,
|
||||
);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user