Skip to content

Commit b48ca59

Browse files
[SDK] feat: Add verifyClaim export and canClaim function
1 parent dceb47d commit b48ca59

File tree

18 files changed

+1003
-21
lines changed

18 files changed

+1003
-21
lines changed

.changeset/orange-ravens-remain.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+
Expose `canClaim` extension function for erc20/721/1155 drops

apps/playground-web/src/components/pay/embed.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { THIRDWEB_CLIENT } from "@/lib/client";
44
import { useTheme } from "next-themes";
5-
import { base } from "thirdweb/chains";
5+
import { arbitrumNova, base } from "thirdweb/chains";
66
import { PayEmbed } from "thirdweb/react";
77
import { StyledConnectButton } from "../styled-connect-button";
88

@@ -11,9 +11,20 @@ export function StyledPayEmbedPreview() {
1111

1212
return (
1313
<div className="flex flex-col items-center justify-center">
14-
<StyledConnectButton />
14+
<StyledConnectButton
15+
accountAbstraction={{
16+
chain: base,
17+
sponsorGas: true,
18+
}}
19+
/>
1520
<div className="h-10" />
1621
<PayEmbed
22+
connectOptions={{
23+
accountAbstraction: {
24+
chain: base,
25+
sponsorGas: true,
26+
},
27+
}}
1728
client={THIRDWEB_CLIENT}
1829
theme={theme === "light" ? "light" : "dark"}
1930
payOptions={{
@@ -22,7 +33,12 @@ export function StyledPayEmbedPreview() {
2233
name: "Get funds",
2334
},
2435
prefillBuy: {
25-
chain: base,
36+
chain: arbitrumNova,
37+
token: {
38+
address: "0xb5130F4767AB0ACC579f25a76e8f9E977CB3F948",
39+
name: "GOD",
40+
symbol: "GOD",
41+
},
2642
amount: "0.01",
2743
},
2844
}}

packages/thirdweb/scripts/generate/abis/erc1155/DropERC1155.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"function setMaxTotalSupply(uint256 _tokenId, uint256 _maxTotalSupply)",
33
"function setSaleRecipientForToken(uint256 _tokenId, address _saleRecipient)",
44
"function updateBatchBaseURI(uint256 _index, string calldata _uri)",
5-
"function freezeBatchBaseURI(uint256 _index)"
5+
"function freezeBatchBaseURI(uint256 _index)",
6+
"function verifyClaim(uint256 _conditionId, address _claimer, uint256 _tokenId, uint256 _quantity, address _currency, uint256 _pricePerToken, (bytes32[] proof, uint256 quantityLimitPerWallet, uint256 pricePerToken, address currency) _allowlistProof) view returns (bool isOverride)"
67
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
"function verifyClaim(uint256 _conditionId, address _claimer, uint256 _quantity, address _currency, uint256 _pricePerToken, (bytes32[] proof, uint256 quantityLimitPerWallet, uint256 pricePerToken, address currency) _allowlistProof) view returns (bool isOverride)"
3+
]
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
"function updateBatchBaseURI(uint256 _index, string calldata _uri)",
33
"function freezeBatchBaseURI(uint256 _index)",
4-
"function setMaxTotalSupply(uint256 _maxTotalSupply)"
4+
"function setMaxTotalSupply(uint256 _maxTotalSupply)",
5+
"function verifyClaim(uint256 _conditionId, address _claimer, uint256 _quantity, address _currency, uint256 _pricePerToken, (bytes32[] proof, uint256 quantityLimitPerWallet, uint256 pricePerToken, address currency) _allowlistProof) view returns (bool isOverride)"
56
]

packages/thirdweb/src/exports/extensions/erc1155.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ export {
107107
type GetClaimConditionsParams,
108108
isGetClaimConditionsSupported,
109109
} from "../../extensions/erc1155/drops/read/getClaimConditions.js";
110+
export {
111+
verifyClaim,
112+
type VerifyClaimParams,
113+
isVerifyClaimSupported,
114+
} from "../../extensions/erc1155/__generated__/IClaimableERC1155/read/verifyClaim.js";
110115

111116
// WRITE
112117
export {

packages/thirdweb/src/exports/extensions/erc721.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ export {
109109
getActiveClaimCondition,
110110
isGetActiveClaimConditionSupported,
111111
} from "../../extensions/erc721/drops/read/getActiveClaimCondition.js";
112+
export {
113+
verifyClaim,
114+
type VerifyClaimParams,
115+
isVerifyClaimSupported,
116+
} from "../../extensions/erc721/__generated__/IClaimableERC721/read/verifyClaim.js";
112117

113118
// WRITE
114119
export {

packages/thirdweb/src/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.ts

Lines changed: 223 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/erc1155/drop1155.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { claimTo } from "./drops/write/claimTo.js";
2828
import { resetClaimEligibility } from "./drops/write/resetClaimEligibility.js";
2929
import { setClaimConditions } from "./drops/write/setClaimConditions.js";
3030
import { updateMetadata } from "./drops/write/updateMetadata.js";
31+
import { canClaim } from "./read/canClaim.js";
3132
import { getNFT } from "./read/getNFT.js";
3233
import { isGetNFTsSupported } from "./read/getNFTs.js";
3334
import { lazyMint } from "./write/lazyMint.js";
@@ -130,6 +131,20 @@ describe.runIf(process.env.TW_SECRET_KEY)(
130131
}),
131132
account: TEST_ACCOUNT_C,
132133
});
134+
135+
expect(
136+
await canClaim({
137+
contract,
138+
claimer: TEST_ACCOUNT_C.address,
139+
quantity: 1n,
140+
tokenId: 0n,
141+
}),
142+
).toMatchInlineSnapshot(`
143+
{
144+
"result": true,
145+
}
146+
`);
147+
133148
const claimTx = claimTo({
134149
contract,
135150
to: TEST_ACCOUNT_C.address,
@@ -205,6 +220,33 @@ describe.runIf(process.env.TW_SECRET_KEY)(
205220
balanceOf({ contract, owner: TEST_ACCOUNT_B.address, tokenId }),
206221
).resolves.toBe(0n);
207222

223+
expect(
224+
await canClaim({
225+
contract,
226+
claimer: TEST_ACCOUNT_C.address,
227+
quantity: 1n,
228+
tokenId,
229+
}),
230+
).toMatchInlineSnapshot(`
231+
{
232+
"result": true,
233+
}
234+
`);
235+
236+
expect(
237+
await canClaim({
238+
contract,
239+
claimer: TEST_ACCOUNT_B.address,
240+
quantity: 1n,
241+
tokenId,
242+
}),
243+
).toMatchInlineSnapshot(`
244+
{
245+
"reason": "DropClaimExceedLimit - 0,1",
246+
"result": false,
247+
}
248+
`);
249+
208250
await sendAndConfirmTransaction({
209251
account: TEST_ACCOUNT_C,
210252
transaction: claimTo({

0 commit comments

Comments
 (0)