thirdweb 5.88.2-nightly-0a292138ca21b2d7375db6ff9ef07dc91cffc7fc-20250211122816 → 5.88.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/cjs/exports/extensions/erc1155.js +4 -2
  2. package/dist/cjs/exports/extensions/erc1155.js.map +1 -1
  3. package/dist/cjs/exports/extensions/erc20.js +3 -1
  4. package/dist/cjs/exports/extensions/erc20.js.map +1 -1
  5. package/dist/cjs/exports/extensions/erc721.js +4 -2
  6. package/dist/cjs/exports/extensions/erc721.js.map +1 -1
  7. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.js +191 -0
  8. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.js.map +1 -0
  9. package/dist/cjs/extensions/erc1155/drops/read/canClaim.js +45 -0
  10. package/dist/cjs/extensions/erc1155/drops/read/canClaim.js.map +1 -0
  11. package/dist/cjs/extensions/erc20/__generated__/DropERC20/read/verifyClaim.js +182 -0
  12. package/dist/cjs/extensions/erc20/__generated__/DropERC20/read/verifyClaim.js.map +1 -0
  13. package/dist/cjs/extensions/erc20/drops/read/canClaim.js +51 -0
  14. package/dist/cjs/extensions/erc20/drops/read/canClaim.js.map +1 -0
  15. package/dist/cjs/extensions/erc721/__generated__/DropERC721/read/verifyClaim.js +182 -0
  16. package/dist/cjs/extensions/erc721/__generated__/DropERC721/read/verifyClaim.js.map +1 -0
  17. package/dist/cjs/extensions/erc721/drops/read/canClaim.js +42 -0
  18. package/dist/cjs/extensions/erc721/drops/read/canClaim.js.map +1 -0
  19. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +12 -5
  20. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  21. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +6 -5
  22. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  23. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +1 -1
  24. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +7 -3
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -1
  27. package/dist/cjs/react/web/utils/errors.js +6 -1
  28. package/dist/cjs/react/web/utils/errors.js.map +1 -1
  29. package/dist/cjs/transaction/extract-error.js +11 -4
  30. package/dist/cjs/transaction/extract-error.js.map +1 -1
  31. package/dist/cjs/version.js +1 -1
  32. package/dist/cjs/version.js.map +1 -1
  33. package/dist/esm/exports/extensions/erc1155.js +1 -0
  34. package/dist/esm/exports/extensions/erc1155.js.map +1 -1
  35. package/dist/esm/exports/extensions/erc20.js +1 -0
  36. package/dist/esm/exports/extensions/erc20.js.map +1 -1
  37. package/dist/esm/exports/extensions/erc721.js +1 -0
  38. package/dist/esm/exports/extensions/erc721.js.map +1 -1
  39. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.js +183 -0
  40. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.js.map +1 -0
  41. package/dist/esm/extensions/erc1155/drops/read/canClaim.js +42 -0
  42. package/dist/esm/extensions/erc1155/drops/read/canClaim.js.map +1 -0
  43. package/dist/esm/extensions/erc20/__generated__/DropERC20/read/verifyClaim.js +174 -0
  44. package/dist/esm/extensions/erc20/__generated__/DropERC20/read/verifyClaim.js.map +1 -0
  45. package/dist/esm/extensions/erc20/drops/read/canClaim.js +48 -0
  46. package/dist/esm/extensions/erc20/drops/read/canClaim.js.map +1 -0
  47. package/dist/esm/extensions/erc721/__generated__/DropERC721/read/verifyClaim.js +174 -0
  48. package/dist/esm/extensions/erc721/__generated__/DropERC721/read/verifyClaim.js.map +1 -0
  49. package/dist/esm/extensions/erc721/drops/read/canClaim.js +39 -0
  50. package/dist/esm/extensions/erc721/drops/read/canClaim.js.map +1 -0
  51. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +12 -5
  52. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  53. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +6 -5
  54. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  55. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +1 -1
  56. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  57. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js +7 -3
  58. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.js.map +1 -1
  59. package/dist/esm/react/web/utils/errors.js +6 -1
  60. package/dist/esm/react/web/utils/errors.js.map +1 -1
  61. package/dist/esm/transaction/extract-error.js +11 -5
  62. package/dist/esm/transaction/extract-error.js.map +1 -1
  63. package/dist/esm/version.js +1 -1
  64. package/dist/esm/version.js.map +1 -1
  65. package/dist/types/exports/extensions/erc1155.d.ts +1 -0
  66. package/dist/types/exports/extensions/erc1155.d.ts.map +1 -1
  67. package/dist/types/exports/extensions/erc20.d.ts +1 -0
  68. package/dist/types/exports/extensions/erc20.d.ts.map +1 -1
  69. package/dist/types/exports/extensions/erc721.d.ts +1 -0
  70. package/dist/types/exports/extensions/erc721.d.ts.map +1 -1
  71. package/dist/types/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.d.ts +143 -0
  72. package/dist/types/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.d.ts.map +1 -0
  73. package/dist/types/extensions/erc1155/drops/read/canClaim.d.ts +13 -0
  74. package/dist/types/extensions/erc1155/drops/read/canClaim.d.ts.map +1 -0
  75. package/dist/types/extensions/erc20/__generated__/DropERC20/read/verifyClaim.d.ts +136 -0
  76. package/dist/types/extensions/erc20/__generated__/DropERC20/read/verifyClaim.d.ts.map +1 -0
  77. package/dist/types/extensions/erc20/drops/read/canClaim.d.ts +15 -0
  78. package/dist/types/extensions/erc20/drops/read/canClaim.d.ts.map +1 -0
  79. package/dist/types/extensions/erc721/__generated__/DropERC721/read/verifyClaim.d.ts +136 -0
  80. package/dist/types/extensions/erc721/__generated__/DropERC721/read/verifyClaim.d.ts.map +1 -0
  81. package/dist/types/extensions/erc721/drops/read/canClaim.d.ts +12 -0
  82. package/dist/types/extensions/erc721/drops/read/canClaim.d.ts.map +1 -0
  83. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
  84. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.d.ts.map +1 -1
  85. package/dist/types/react/web/utils/errors.d.ts.map +1 -1
  86. package/dist/types/transaction/extract-error.d.ts +4 -0
  87. package/dist/types/transaction/extract-error.d.ts.map +1 -1
  88. package/dist/types/version.d.ts +1 -1
  89. package/dist/types/version.d.ts.map +1 -1
  90. package/package.json +1 -1
  91. package/src/exports/extensions/erc1155.ts +5 -0
  92. package/src/exports/extensions/erc20.ts +5 -0
  93. package/src/exports/extensions/erc721.ts +5 -0
  94. package/src/extensions/erc1155/__generated__/DropERC1155/read/verifyClaim.ts +223 -0
  95. package/src/extensions/erc1155/drop1155.test.ts +42 -0
  96. package/src/extensions/erc1155/drops/read/canClaim.ts +57 -0
  97. package/src/extensions/erc20/__generated__/DropERC20/read/verifyClaim.ts +213 -0
  98. package/src/extensions/erc20/drop20.test.ts +38 -0
  99. package/src/extensions/erc20/drops/read/canClaim.ts +65 -0
  100. package/src/extensions/erc721/__generated__/DropERC721/read/verifyClaim.ts +213 -0
  101. package/src/extensions/erc721/drop721.test.ts +39 -0
  102. package/src/extensions/erc721/drops/read/canClaim.ts +53 -0
  103. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +16 -3
  104. package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +27 -20
  105. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx +1 -2
  106. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.tsx +28 -16
  107. package/src/react/web/utils/errors.ts +6 -1
  108. package/src/transaction/actions/gasless/providers/engine.test.ts +1 -1
  109. package/src/transaction/actions/gasless/providers/openzeppelin.test.ts +1 -1
  110. package/src/transaction/extract-error.ts +15 -13
  111. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentSelectionScreen.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAC;AAO7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAIlG,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EACV,MAAM,+CAA+C,CAAC;AAOvD,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,sBAAsB,CAAC;AAG9E,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,sBAAsB,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,qBAAqB,EAAE,eAAe,GAAG,SAAS,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACnE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;CAC7B,8CAkMA"}
1
+ {"version":3,"file":"PaymentSelectionScreen.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/react/web/ui/ConnectWallet/screens/Buy/swap/PaymentSelectionScreen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAC;AAO7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAIlG,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EACV,MAAM,+CAA+C,CAAC;AAOvD,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,sBAAsB,CAAC;AAG9E,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,sBAAsB,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,qBAAqB,EAAE,eAAe,GAAG,SAAS,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACnE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;CAC7B,8CA8MA"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/react/web/utils/errors.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE;QACL,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,cAAc,8BAA8B,CAAC;AAE1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAQlD"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/react/web/utils/errors.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE;QACL,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,cAAc,8BAA8B,CAAC;AAE1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAalD"}
@@ -7,4 +7,8 @@ export declare function extractError<abi extends Abi>(args: {
7
7
  error: unknown;
8
8
  contract?: ThirdwebContract<abi>;
9
9
  }): Promise<unknown>;
10
+ export declare function extractErrorResult<abi extends Abi>(args: {
11
+ error: unknown;
12
+ contract?: ThirdwebContract<abi>;
13
+ }): Promise<string | undefined>;
10
14
  //# sourceMappingURL=extract-error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract-error.d.ts","sourceRoot":"","sources":["../../../src/transaction/extract-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,SAAS,GAAG,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;CAClC,oBAiCA"}
1
+ {"version":3,"file":"extract-error.d.ts","sourceRoot":"","sources":["../../../src/transaction/extract-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,SAAS,GAAG,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;CAClC,oBAOA;AAED,wBAAsB,kBAAkB,CAAC,GAAG,SAAS,GAAG,EAAE,IAAI,EAAE;IAC9D,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;CAClC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAwB9B"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.88.2-nightly-0a292138ca21b2d7375db6ff9ef07dc91cffc7fc-20250211122816";
1
+ export declare const version = "5.88.2";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.88.2-nightly-0a292138ca21b2d7375db6ff9ef07dc91cffc7fc-20250211122816",
3
+ "version": "5.88.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -107,6 +107,11 @@ export {
107
107
  type GetClaimConditionsParams,
108
108
  isGetClaimConditionsSupported,
109
109
  } from "../../extensions/erc1155/drops/read/getClaimConditions.js";
110
+ export {
111
+ canClaim,
112
+ type CanClaimParams,
113
+ type CanClaimResult,
114
+ } from "../../extensions/erc1155/drops/read/canClaim.js";
110
115
 
111
116
  // WRITE
112
117
  export {
@@ -75,6 +75,11 @@ export {
75
75
  getActiveClaimCondition,
76
76
  isGetActiveClaimConditionSupported,
77
77
  } from "../../extensions/erc20/drops/read/getActiveClaimCondition.js";
78
+ export {
79
+ canClaim,
80
+ type CanClaimParams,
81
+ type CanClaimResult,
82
+ } from "../../extensions/erc20/drops/read/canClaim.js";
78
83
 
79
84
  // WRITE
80
85
  export {
@@ -109,6 +109,11 @@ export {
109
109
  getActiveClaimCondition,
110
110
  isGetActiveClaimConditionSupported,
111
111
  } from "../../extensions/erc721/drops/read/getActiveClaimCondition.js";
112
+ export {
113
+ canClaim,
114
+ type CanClaimParams,
115
+ type CanClaimResult,
116
+ } from "../../extensions/erc721/drops/read/canClaim.js";
112
117
 
113
118
  // WRITE
114
119
  export {
@@ -0,0 +1,223 @@
1
+ import type { AbiParameterToPrimitiveType } from "abitype";
2
+ import { readContract } from "../../../../../transaction/read-contract.js";
3
+ import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
4
+ import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
5
+ import { decodeAbiParameters } from "viem";
6
+ import type { Hex } from "../../../../../utils/encoding/hex.js";
7
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
8
+
9
+ /**
10
+ * Represents the parameters for the "verifyClaim" function.
11
+ */
12
+ export type VerifyClaimParams = {
13
+ conditionId: AbiParameterToPrimitiveType<{
14
+ type: "uint256";
15
+ name: "_conditionId";
16
+ }>;
17
+ claimer: AbiParameterToPrimitiveType<{ type: "address"; name: "_claimer" }>;
18
+ tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_tokenId" }>;
19
+ quantity: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_quantity" }>;
20
+ currency: AbiParameterToPrimitiveType<{ type: "address"; name: "_currency" }>;
21
+ pricePerToken: AbiParameterToPrimitiveType<{
22
+ type: "uint256";
23
+ name: "_pricePerToken";
24
+ }>;
25
+ allowlistProof: AbiParameterToPrimitiveType<{
26
+ type: "tuple";
27
+ name: "_allowlistProof";
28
+ components: [
29
+ { type: "bytes32[]"; name: "proof" },
30
+ { type: "uint256"; name: "quantityLimitPerWallet" },
31
+ { type: "uint256"; name: "pricePerToken" },
32
+ { type: "address"; name: "currency" },
33
+ ];
34
+ }>;
35
+ };
36
+
37
+ export const FN_SELECTOR = "0xea1def9c" as const;
38
+ const FN_INPUTS = [
39
+ {
40
+ type: "uint256",
41
+ name: "_conditionId",
42
+ },
43
+ {
44
+ type: "address",
45
+ name: "_claimer",
46
+ },
47
+ {
48
+ type: "uint256",
49
+ name: "_tokenId",
50
+ },
51
+ {
52
+ type: "uint256",
53
+ name: "_quantity",
54
+ },
55
+ {
56
+ type: "address",
57
+ name: "_currency",
58
+ },
59
+ {
60
+ type: "uint256",
61
+ name: "_pricePerToken",
62
+ },
63
+ {
64
+ type: "tuple",
65
+ name: "_allowlistProof",
66
+ components: [
67
+ {
68
+ type: "bytes32[]",
69
+ name: "proof",
70
+ },
71
+ {
72
+ type: "uint256",
73
+ name: "quantityLimitPerWallet",
74
+ },
75
+ {
76
+ type: "uint256",
77
+ name: "pricePerToken",
78
+ },
79
+ {
80
+ type: "address",
81
+ name: "currency",
82
+ },
83
+ ],
84
+ },
85
+ ] as const;
86
+ const FN_OUTPUTS = [
87
+ {
88
+ type: "bool",
89
+ name: "isOverride",
90
+ },
91
+ ] as const;
92
+
93
+ /**
94
+ * Checks if the `verifyClaim` method is supported by the given contract.
95
+ * @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
96
+ * @returns A boolean indicating if the `verifyClaim` method is supported.
97
+ * @extension ERC1155
98
+ * @example
99
+ * ```ts
100
+ * import { isVerifyClaimSupported } from "thirdweb/extensions/erc1155";
101
+ * const supported = isVerifyClaimSupported(["0x..."]);
102
+ * ```
103
+ */
104
+ export function isVerifyClaimSupported(availableSelectors: string[]) {
105
+ return detectMethod({
106
+ availableSelectors,
107
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
108
+ });
109
+ }
110
+
111
+ /**
112
+ * Encodes the parameters for the "verifyClaim" function.
113
+ * @param options - The options for the verifyClaim function.
114
+ * @returns The encoded ABI parameters.
115
+ * @extension ERC1155
116
+ * @example
117
+ * ```ts
118
+ * import { encodeVerifyClaimParams } from "thirdweb/extensions/erc1155";
119
+ * const result = encodeVerifyClaimParams({
120
+ * conditionId: ...,
121
+ * claimer: ...,
122
+ * tokenId: ...,
123
+ * quantity: ...,
124
+ * currency: ...,
125
+ * pricePerToken: ...,
126
+ * allowlistProof: ...,
127
+ * });
128
+ * ```
129
+ */
130
+ export function encodeVerifyClaimParams(options: VerifyClaimParams) {
131
+ return encodeAbiParameters(FN_INPUTS, [
132
+ options.conditionId,
133
+ options.claimer,
134
+ options.tokenId,
135
+ options.quantity,
136
+ options.currency,
137
+ options.pricePerToken,
138
+ options.allowlistProof,
139
+ ]);
140
+ }
141
+
142
+ /**
143
+ * Encodes the "verifyClaim" function into a Hex string with its parameters.
144
+ * @param options - The options for the verifyClaim function.
145
+ * @returns The encoded hexadecimal string.
146
+ * @extension ERC1155
147
+ * @example
148
+ * ```ts
149
+ * import { encodeVerifyClaim } from "thirdweb/extensions/erc1155";
150
+ * const result = encodeVerifyClaim({
151
+ * conditionId: ...,
152
+ * claimer: ...,
153
+ * tokenId: ...,
154
+ * quantity: ...,
155
+ * currency: ...,
156
+ * pricePerToken: ...,
157
+ * allowlistProof: ...,
158
+ * });
159
+ * ```
160
+ */
161
+ export function encodeVerifyClaim(options: VerifyClaimParams) {
162
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
163
+ // we can do this because we know the specific formats of the values
164
+ return (FN_SELECTOR +
165
+ encodeVerifyClaimParams(options).slice(
166
+ 2,
167
+ )) as `${typeof FN_SELECTOR}${string}`;
168
+ }
169
+
170
+ /**
171
+ * Decodes the result of the verifyClaim function call.
172
+ * @param result - The hexadecimal result to decode.
173
+ * @returns The decoded result as per the FN_OUTPUTS definition.
174
+ * @extension ERC1155
175
+ * @example
176
+ * ```ts
177
+ * import { decodeVerifyClaimResult } from "thirdweb/extensions/erc1155";
178
+ * const result = decodeVerifyClaimResultResult("...");
179
+ * ```
180
+ */
181
+ export function decodeVerifyClaimResult(result: Hex) {
182
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
183
+ }
184
+
185
+ /**
186
+ * Calls the "verifyClaim" function on the contract.
187
+ * @param options - The options for the verifyClaim function.
188
+ * @returns The parsed result of the function call.
189
+ * @extension ERC1155
190
+ * @example
191
+ * ```ts
192
+ * import { verifyClaim } from "thirdweb/extensions/erc1155";
193
+ *
194
+ * const result = await verifyClaim({
195
+ * contract,
196
+ * conditionId: ...,
197
+ * claimer: ...,
198
+ * tokenId: ...,
199
+ * quantity: ...,
200
+ * currency: ...,
201
+ * pricePerToken: ...,
202
+ * allowlistProof: ...,
203
+ * });
204
+ *
205
+ * ```
206
+ */
207
+ export async function verifyClaim(
208
+ options: BaseTransactionOptions<VerifyClaimParams>,
209
+ ) {
210
+ return readContract({
211
+ contract: options.contract,
212
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
213
+ params: [
214
+ options.conditionId,
215
+ options.claimer,
216
+ options.tokenId,
217
+ options.quantity,
218
+ options.currency,
219
+ options.pricePerToken,
220
+ options.allowlistProof,
221
+ ],
222
+ });
223
+ }
@@ -22,6 +22,7 @@ import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
22
22
  import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
23
23
  import { totalSupply } from "./__generated__/IERC1155/read/totalSupply.js";
24
24
  import { nextTokenIdToMint } from "./__generated__/IERC1155Enumerable/read/nextTokenIdToMint.js";
25
+ import { canClaim } from "./drops/read/canClaim.js";
25
26
  import { getActiveClaimCondition } from "./drops/read/getActiveClaimCondition.js";
26
27
  import { getClaimConditions } from "./drops/read/getClaimConditions.js";
27
28
  import { claimTo } from "./drops/write/claimTo.js";
@@ -130,6 +131,20 @@ describe.runIf(process.env.TW_SECRET_KEY)(
130
131
  }),
131
132
  account: TEST_ACCOUNT_C,
132
133
  });
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
+
133
148
  const claimTx = claimTo({
134
149
  contract,
135
150
  to: TEST_ACCOUNT_C.address,
@@ -205,6 +220,33 @@ describe.runIf(process.env.TW_SECRET_KEY)(
205
220
  balanceOf({ contract, owner: TEST_ACCOUNT_B.address, tokenId }),
206
221
  ).resolves.toBe(0n);
207
222
 
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
+
208
250
  await sendAndConfirmTransaction({
209
251
  account: TEST_ACCOUNT_C,
210
252
  transaction: claimTo({
@@ -0,0 +1,57 @@
1
+ import { extractErrorResult } from "../../../../transaction/extract-error.js";
2
+ import type { BaseTransactionOptions } from "../../../../transaction/types.js";
3
+ import { getClaimParams } from "../../../../utils/extensions/drops/get-claim-params.js";
4
+ import { verifyClaim } from "../../__generated__/DropERC1155/read/verifyClaim.js";
5
+ import { getActiveClaimConditionId } from "../../__generated__/IDrop1155/read/getActiveClaimConditionId.js";
6
+
7
+ export type CanClaimParams = {
8
+ claimer: string;
9
+ quantity: bigint;
10
+ tokenId: bigint;
11
+ from?: string;
12
+ };
13
+
14
+ export type CanClaimResult = {
15
+ result: boolean;
16
+ reason?: string;
17
+ };
18
+
19
+ export async function canClaim(
20
+ options: BaseTransactionOptions<CanClaimParams>,
21
+ ): Promise<CanClaimResult> {
22
+ const [conditionId, { quantity, currency, pricePerToken, allowlistProof }] =
23
+ await Promise.all([
24
+ getActiveClaimConditionId({
25
+ contract: options.contract,
26
+ tokenId: options.tokenId,
27
+ }),
28
+ getClaimParams({
29
+ contract: options.contract,
30
+ quantity: options.quantity,
31
+ to: options.claimer,
32
+ type: "erc1155",
33
+ tokenId: options.tokenId,
34
+ from: options.from,
35
+ }),
36
+ ]);
37
+ try {
38
+ await verifyClaim({
39
+ contract: options.contract,
40
+ claimer: options.claimer,
41
+ quantity,
42
+ currency,
43
+ pricePerToken,
44
+ allowlistProof,
45
+ conditionId,
46
+ tokenId: options.tokenId,
47
+ });
48
+ return {
49
+ result: true,
50
+ };
51
+ } catch (error) {
52
+ return {
53
+ result: false,
54
+ reason: await extractErrorResult({ error, contract: options.contract }),
55
+ };
56
+ }
57
+ }
@@ -0,0 +1,213 @@
1
+ import type { AbiParameterToPrimitiveType } from "abitype";
2
+ import { readContract } from "../../../../../transaction/read-contract.js";
3
+ import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
4
+ import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
5
+ import { decodeAbiParameters } from "viem";
6
+ import type { Hex } from "../../../../../utils/encoding/hex.js";
7
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
8
+
9
+ /**
10
+ * Represents the parameters for the "verifyClaim" function.
11
+ */
12
+ export type VerifyClaimParams = {
13
+ conditionId: AbiParameterToPrimitiveType<{
14
+ type: "uint256";
15
+ name: "_conditionId";
16
+ }>;
17
+ claimer: AbiParameterToPrimitiveType<{ type: "address"; name: "_claimer" }>;
18
+ quantity: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_quantity" }>;
19
+ currency: AbiParameterToPrimitiveType<{ type: "address"; name: "_currency" }>;
20
+ pricePerToken: AbiParameterToPrimitiveType<{
21
+ type: "uint256";
22
+ name: "_pricePerToken";
23
+ }>;
24
+ allowlistProof: AbiParameterToPrimitiveType<{
25
+ type: "tuple";
26
+ name: "_allowlistProof";
27
+ components: [
28
+ { type: "bytes32[]"; name: "proof" },
29
+ { type: "uint256"; name: "quantityLimitPerWallet" },
30
+ { type: "uint256"; name: "pricePerToken" },
31
+ { type: "address"; name: "currency" },
32
+ ];
33
+ }>;
34
+ };
35
+
36
+ export const FN_SELECTOR = "0x23a2902b" as const;
37
+ const FN_INPUTS = [
38
+ {
39
+ type: "uint256",
40
+ name: "_conditionId",
41
+ },
42
+ {
43
+ type: "address",
44
+ name: "_claimer",
45
+ },
46
+ {
47
+ type: "uint256",
48
+ name: "_quantity",
49
+ },
50
+ {
51
+ type: "address",
52
+ name: "_currency",
53
+ },
54
+ {
55
+ type: "uint256",
56
+ name: "_pricePerToken",
57
+ },
58
+ {
59
+ type: "tuple",
60
+ name: "_allowlistProof",
61
+ components: [
62
+ {
63
+ type: "bytes32[]",
64
+ name: "proof",
65
+ },
66
+ {
67
+ type: "uint256",
68
+ name: "quantityLimitPerWallet",
69
+ },
70
+ {
71
+ type: "uint256",
72
+ name: "pricePerToken",
73
+ },
74
+ {
75
+ type: "address",
76
+ name: "currency",
77
+ },
78
+ ],
79
+ },
80
+ ] as const;
81
+ const FN_OUTPUTS = [
82
+ {
83
+ type: "bool",
84
+ name: "isOverride",
85
+ },
86
+ ] as const;
87
+
88
+ /**
89
+ * Checks if the `verifyClaim` method is supported by the given contract.
90
+ * @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
91
+ * @returns A boolean indicating if the `verifyClaim` method is supported.
92
+ * @extension ERC20
93
+ * @example
94
+ * ```ts
95
+ * import { isVerifyClaimSupported } from "thirdweb/extensions/erc20";
96
+ * const supported = isVerifyClaimSupported(["0x..."]);
97
+ * ```
98
+ */
99
+ export function isVerifyClaimSupported(availableSelectors: string[]) {
100
+ return detectMethod({
101
+ availableSelectors,
102
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
103
+ });
104
+ }
105
+
106
+ /**
107
+ * Encodes the parameters for the "verifyClaim" function.
108
+ * @param options - The options for the verifyClaim function.
109
+ * @returns The encoded ABI parameters.
110
+ * @extension ERC20
111
+ * @example
112
+ * ```ts
113
+ * import { encodeVerifyClaimParams } from "thirdweb/extensions/erc20";
114
+ * const result = encodeVerifyClaimParams({
115
+ * conditionId: ...,
116
+ * claimer: ...,
117
+ * quantity: ...,
118
+ * currency: ...,
119
+ * pricePerToken: ...,
120
+ * allowlistProof: ...,
121
+ * });
122
+ * ```
123
+ */
124
+ export function encodeVerifyClaimParams(options: VerifyClaimParams) {
125
+ return encodeAbiParameters(FN_INPUTS, [
126
+ options.conditionId,
127
+ options.claimer,
128
+ options.quantity,
129
+ options.currency,
130
+ options.pricePerToken,
131
+ options.allowlistProof,
132
+ ]);
133
+ }
134
+
135
+ /**
136
+ * Encodes the "verifyClaim" function into a Hex string with its parameters.
137
+ * @param options - The options for the verifyClaim function.
138
+ * @returns The encoded hexadecimal string.
139
+ * @extension ERC20
140
+ * @example
141
+ * ```ts
142
+ * import { encodeVerifyClaim } from "thirdweb/extensions/erc20";
143
+ * const result = encodeVerifyClaim({
144
+ * conditionId: ...,
145
+ * claimer: ...,
146
+ * quantity: ...,
147
+ * currency: ...,
148
+ * pricePerToken: ...,
149
+ * allowlistProof: ...,
150
+ * });
151
+ * ```
152
+ */
153
+ export function encodeVerifyClaim(options: VerifyClaimParams) {
154
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
155
+ // we can do this because we know the specific formats of the values
156
+ return (FN_SELECTOR +
157
+ encodeVerifyClaimParams(options).slice(
158
+ 2,
159
+ )) as `${typeof FN_SELECTOR}${string}`;
160
+ }
161
+
162
+ /**
163
+ * Decodes the result of the verifyClaim function call.
164
+ * @param result - The hexadecimal result to decode.
165
+ * @returns The decoded result as per the FN_OUTPUTS definition.
166
+ * @extension ERC20
167
+ * @example
168
+ * ```ts
169
+ * import { decodeVerifyClaimResult } from "thirdweb/extensions/erc20";
170
+ * const result = decodeVerifyClaimResultResult("...");
171
+ * ```
172
+ */
173
+ export function decodeVerifyClaimResult(result: Hex) {
174
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
175
+ }
176
+
177
+ /**
178
+ * Calls the "verifyClaim" function on the contract.
179
+ * @param options - The options for the verifyClaim function.
180
+ * @returns The parsed result of the function call.
181
+ * @extension ERC20
182
+ * @example
183
+ * ```ts
184
+ * import { verifyClaim } from "thirdweb/extensions/erc20";
185
+ *
186
+ * const result = await verifyClaim({
187
+ * contract,
188
+ * conditionId: ...,
189
+ * claimer: ...,
190
+ * quantity: ...,
191
+ * currency: ...,
192
+ * pricePerToken: ...,
193
+ * allowlistProof: ...,
194
+ * });
195
+ *
196
+ * ```
197
+ */
198
+ export async function verifyClaim(
199
+ options: BaseTransactionOptions<VerifyClaimParams>,
200
+ ) {
201
+ return readContract({
202
+ contract: options.contract,
203
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
204
+ params: [
205
+ options.conditionId,
206
+ options.claimer,
207
+ options.quantity,
208
+ options.currency,
209
+ options.pricePerToken,
210
+ options.allowlistProof,
211
+ ],
212
+ });
213
+ }