Skip to content

Commit 3ad9f7d

Browse files
[SDK] Allow passing overrides to common extension functions (#8041)
1 parent 0b45405 commit 3ad9f7d

File tree

22 files changed

+169
-66
lines changed

22 files changed

+169
-66
lines changed

.changeset/two-steaks-melt.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+
Allow passing overrides to common extension functions

apps/playground-web/src/components/account-abstraction/gateway.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
TableRow,
2929
} from "../ui/table";
3030

31-
const url = `http://${process.env.NEXT_PUBLIC_API_URL}`;
31+
const url = `https://${process.env.NEXT_PUBLIC_API_URL}`;
3232

3333
const chain = baseSepolia;
3434
const editionDropAddress = "0x638263e3eAa3917a53630e61B1fBa685308024fa";

packages/thirdweb/src/extensions/erc1155/drops/write/claimTo.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { BaseTransactionOptions } from "../../../../transaction/types.js";
1+
import type {
2+
BaseTransactionOptions,
3+
WithOverrides,
4+
} from "../../../../transaction/types.js";
25
import { getClaimParams } from "../../../../utils/extensions/drops/get-claim-params.js";
36
import { isGetContractMetadataSupported } from "../../../common/read/getContractMetadata.js";
47
import * as GeneratedClaim from "../../__generated__/IDrop1155/write/claim.js";
@@ -51,7 +54,9 @@ export type ClaimToParams = {
5154
* @throws If no claim condition is set
5255
* @returns The prepared transaction
5356
*/
54-
export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
57+
export function claimTo(
58+
options: BaseTransactionOptions<WithOverrides<ClaimToParams>>,
59+
) {
5560
return GeneratedClaim.claim({
5661
async asyncParams() {
5762
const params = await getClaimParams({
@@ -70,6 +75,7 @@ export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
7075
};
7176
},
7277
contract: options.contract,
78+
overrides: options.overrides,
7379
});
7480
}
7581

packages/thirdweb/src/extensions/erc1155/drops/write/resetClaimEligibility.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { Hex } from "viem";
2-
import type { BaseTransactionOptions } from "../../../../transaction/types.js";
2+
import type {
3+
BaseTransactionOptions,
4+
WithOverrides,
5+
} from "../../../../transaction/types.js";
36
import type { ClaimCondition } from "../../../../utils/extensions/drops/types.js";
47
import {
58
isSetClaimConditionsSupported,
@@ -40,7 +43,9 @@ export type ResetClaimEligibilityParams = GetClaimConditionsParams;
4043
* ```
4144
*/
4245
export function resetClaimEligibility(
43-
options: BaseTransactionOptions<ResetClaimEligibilityParams> & {
46+
options: BaseTransactionOptions<
47+
WithOverrides<ResetClaimEligibilityParams>
48+
> & {
4449
singlePhaseDrop?: boolean;
4550
},
4651
) {
@@ -79,6 +84,7 @@ export function resetClaimEligibility(
7984
};
8085
},
8186
contract: options.contract,
87+
overrides: options.overrides,
8288
});
8389
}
8490
// download existing conditions
@@ -101,6 +107,7 @@ export function resetClaimEligibility(
101107
};
102108
},
103109
contract: options.contract,
110+
overrides: options.overrides,
104111
});
105112
}
106113

packages/thirdweb/src/extensions/erc1155/drops/write/setClaimConditions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { BaseTransactionOptions } from "../../../../transaction/types.js";
1+
import type {
2+
BaseTransactionOptions,
3+
WithOverrides,
4+
} from "../../../../transaction/types.js";
25
import { getMulticallSetClaimConditionTransactions } from "../../../../utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js";
36
import type { ClaimConditionsInput } from "../../../../utils/extensions/drops/types.js";
47
import { isSetContractURISupported } from "../../../common/__generated__/IContractMetadata/write/setContractURI.js";
@@ -49,7 +52,7 @@ export type SetClaimConditionsParams = {
4952
* ```
5053
*/
5154
export function setClaimConditions(
52-
options: BaseTransactionOptions<SetClaimConditionsParams>,
55+
options: BaseTransactionOptions<WithOverrides<SetClaimConditionsParams>>,
5356
) {
5457
return multicall({
5558
asyncParams: async () => {
@@ -65,6 +68,7 @@ export function setClaimConditions(
6568
};
6669
},
6770
contract: options.contract,
71+
overrides: options.overrides,
6872
});
6973
}
7074

packages/thirdweb/src/extensions/erc1155/drops/write/updateMetadata.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { BaseTransactionOptions } from "../../../../transaction/types.js";
1+
import type {
2+
BaseTransactionOptions,
3+
WithOverrides,
4+
} from "../../../../transaction/types.js";
25
import type { NFT, NFTInput } from "../../../../utils/nft/parseNft.js";
36
import * as BaseURICount from "../../../erc721/__generated__/IBatchMintMetadata/read/getBaseURICount.js";
47
import * as BatchAtIndex from "../../__generated__/BatchMintMetadata/read/getBatchIdAtIndex.js";
@@ -116,12 +119,13 @@ async function getUpdateMetadataParams(
116119
* ```
117120
*/
118121
export function updateMetadata(
119-
options: BaseTransactionOptions<UpdateMetadataParams>,
122+
options: BaseTransactionOptions<WithOverrides<UpdateMetadataParams>>,
120123
) {
121124
const { contract } = options;
122125
return BatchBaseURI.updateBatchBaseURI({
123126
asyncParams: async () => getUpdateMetadataParams(options),
124127
contract,
128+
overrides: options.overrides,
125129
});
126130
}
127131

packages/thirdweb/src/extensions/erc1155/write/lazyMint.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { FileOrBufferOrString } from "../../../storage/upload/types.js";
2-
import type { BaseTransactionOptions } from "../../../transaction/types.js";
2+
import type {
3+
BaseTransactionOptions,
4+
WithOverrides,
5+
} from "../../../transaction/types.js";
36
import {
47
getBaseUriFromBatch,
58
uploadOrExtractURIs,
@@ -31,9 +34,9 @@ type NFTInput = Prettify<
3134
/**
3235
* @extension ERC1155
3336
*/
34-
export type LazyMintParams = {
37+
export type LazyMintParams = WithOverrides<{
3538
nfts: (NFTInput | string)[];
36-
};
39+
}>;
3740

3841
/**
3942
* Lazily mints ERC1155 tokens.
@@ -83,6 +86,7 @@ export function lazyMint(options: BaseTransactionOptions<LazyMintParams>) {
8386
} as const;
8487
},
8588
contract: options.contract,
89+
overrides: options.overrides,
8690
});
8791
}
8892

packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyTo.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import type { BaseTransactionOptions } from "../../../transaction/types.js";
1+
import type {
2+
BaseTransactionOptions,
3+
WithOverrides,
4+
} from "../../../transaction/types.js";
25
import * as URI from "../__generated__/IERC1155/read/uri.js";
36
import * as MintTo from "../__generated__/IMintableERC1155/write/mintTo.js";
47

58
/**
69
* @extension ERC1155
710
*/
8-
export type MintAdditionalSupplyToParams = {
11+
export type MintAdditionalSupplyToParams = WithOverrides<{
912
to: string;
1013
tokenId: bigint;
1114
supply: bigint;
12-
};
15+
}>;
1316

1417
/**
1518
* Mints a "supply" number of additional ERC1155 tokens to the specified "to" address.
@@ -46,6 +49,7 @@ export function mintAdditionalSupplyTo(
4649
};
4750
},
4851
contract: options.contract,
52+
overrides: options.overrides,
4953
});
5054
}
5155

packages/thirdweb/src/extensions/erc1155/write/updateTokenURI.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { upload } from "../../../storage/upload.js";
2-
import type { BaseTransactionOptions } from "../../../transaction/types.js";
2+
import type {
3+
BaseTransactionOptions,
4+
WithOverrides,
5+
} from "../../../transaction/types.js";
36
import type { NFTInput } from "../../../utils/nft/parseNft.js";
47
import {
58
type SetTokenURIParams,
@@ -10,10 +13,10 @@ export { isSetTokenURISupported as isUpdateTokenURISupported } from "../../erc11
1013
/**
1114
* @extension ERC1155
1215
*/
13-
export type UpdateTokenURIParams = {
16+
export type UpdateTokenURIParams = WithOverrides<{
1417
tokenId: bigint;
1518
newMetadata: NFTInput;
16-
};
19+
}>;
1720

1821
/**
1922
* This function is an abstracted layer of the [`setTokenURI` extension](https://portal.thirdweb.com/references/typescript/v5/erc1155/setTokenURI),
@@ -47,6 +50,7 @@ export function updateTokenURI(
4750
return setTokenURI({
4851
asyncParams: async () => getUpdateTokenParams(options),
4952
contract,
53+
overrides: options.overrides,
5054
});
5155
}
5256

packages/thirdweb/src/extensions/erc20/drops/write/claimTo.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { Address } from "abitype";
2-
import type { BaseTransactionOptions } from "../../../../transaction/types.js";
2+
import type {
3+
BaseTransactionOptions,
4+
WithOverrides,
5+
} from "../../../../transaction/types.js";
36
import { getClaimParams } from "../../../../utils/extensions/drops/get-claim-params.js";
47
import { isGetContractMetadataSupported } from "../../../common/read/getContractMetadata.js";
58
import * as GeneratedClaim from "../../__generated__/IDropERC20/write/claim.js";
@@ -51,7 +54,9 @@ export type ClaimToParams = {
5154
* @throws If no claim condition is set
5255
* @returns A promise that resolves with the submitted transaction hash.
5356
*/
54-
export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
57+
export function claimTo(
58+
options: BaseTransactionOptions<WithOverrides<ClaimToParams>>,
59+
) {
5560
return GeneratedClaim.claim({
5661
asyncParams: async () => {
5762
const quantity = await (async () => {
@@ -77,6 +82,7 @@ export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
7782
});
7883
},
7984
contract: options.contract,
85+
overrides: options.overrides,
8086
});
8187
}
8288

0 commit comments

Comments
 (0)