Skip to content

Commit 03d8d6c

Browse files
authored
feat(TransactionButton): add gasless prop (#2859)
1 parent f12f9bb commit 03d8d6c

File tree

7 files changed

+20
-7
lines changed

7 files changed

+20
-7
lines changed

.changeset/dry-kangaroos-suffer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
add `gasless` prop to `<TransactionButton />`

packages/thirdweb/src/event/actions/watch-events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type WatchContractEventsOptions<
2727
* ### Listen to all events for a contract
2828
* ```ts
2929
* import { watchContractEvents } from "thirdweb";
30-
* const unwatch = watchEvents({
30+
* const unwatch = watchContractEvents({
3131
* contract: myContract,
3232
* onEvents: (events) => {
3333
* // do something with the events
@@ -41,7 +41,7 @@ export type WatchContractEventsOptions<
4141
* const myEvent = prepareEvent({
4242
* event: "event MyEvent(uint256 myArg)",
4343
* });
44-
* const events = await watchEvents({
44+
* const events = await watchContractEvents({
4545
* contract: myContract,
4646
* events: [myEvent],
4747
* onEvents: (events) => {

packages/thirdweb/src/extensions/airdrop/write/airdropERC1155WithSignature.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
3939
chain: ANVIL_CHAIN,
4040
client: TEST_CLIENT,
4141
contractId: "Airdrop",
42-
contractParams: [TEST_ACCOUNT_A.address],
42+
contractParams: [TEST_ACCOUNT_A.address, ""],
4343
}),
4444
chain: ANVIL_CHAIN,
4545
client: TEST_CLIENT,

packages/thirdweb/src/extensions/airdrop/write/airdropERC20WithSignature.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
3737
chain: ANVIL_CHAIN,
3838
client: TEST_CLIENT,
3939
contractId: "Airdrop",
40-
contractParams: [TEST_ACCOUNT_A.address],
40+
contractParams: [TEST_ACCOUNT_A.address, ""],
4141
}),
4242
chain: ANVIL_CHAIN,
4343
client: TEST_CLIENT,

packages/thirdweb/src/extensions/airdrop/write/airdropERC721WithSignature.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
3939
chain: ANVIL_CHAIN,
4040
client: TEST_CLIENT,
4141
contractId: "Airdrop",
42-
contractParams: [TEST_ACCOUNT_A.address],
42+
contractParams: [TEST_ACCOUNT_A.address, ""],
4343
}),
4444
chain: ANVIL_CHAIN,
4545
client: TEST_CLIENT,

packages/thirdweb/src/extensions/prebuilts/deploy-published.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
2929
chain: ANVIL_CHAIN,
3030
account: TEST_ACCOUNT_A,
3131
contractId: "Airdrop",
32-
contractParams: [TEST_ACCOUNT_A.address],
32+
contractParams: [TEST_ACCOUNT_A.address, ""],
3333
});
3434
expect(address).toBeDefined();
3535
expect(address.length).toBe(42);

packages/thirdweb/src/react/web/ui/TransactionButton/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from "react";
2+
import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
23
import {
34
type WaitForReceiptOptions,
45
waitForReceipt as doWaitForReceipt,
@@ -58,6 +59,12 @@ export type TransactionButtonProps = {
5859
* The `React.ReactNode` to be rendered inside the button
5960
*/
6061
children: React.ReactNode;
62+
63+
/**
64+
* Configuration for gasless transactions.
65+
* Refer to [`GaslessOptions`](https://portal.thirdweb.com/references/typescript/v5/GaslessOptions) for more details.
66+
*/
67+
gasless?: GaslessOptions;
6168
};
6269

6370
/**
@@ -85,13 +92,14 @@ export function TransactionButton(props: TransactionButtonProps) {
8592
onTransactionConfirmed,
8693
onError,
8794
onClick,
95+
gasless,
8896
...buttonProps
8997
} = props;
9098
const account = useActiveAccount();
9199
const wallet = useActiveWallet();
92100
const [isPending, setIsPending] = useState(false);
93101

94-
const sendTransaction = useSendTransactionCore();
102+
const sendTransaction = useSendTransactionCore(undefined, gasless);
95103

96104
if (!isPending) {
97105
return (

0 commit comments

Comments
 (0)