thirdweb 5.93.4 → 5.93.5-nightly-e0e31826a8ed11041372f66b3b75fda293a2a05d-20250326035818
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.
- package/dist/cjs/contract/deployment/utils/bootstrap.js +4 -1
- package/dist/cjs/contract/deployment/utils/bootstrap.js.map +1 -1
- package/dist/cjs/exports/extensions/dynamic-contracts.js +11 -0
- package/dist/cjs/exports/extensions/dynamic-contracts.js.map +1 -0
- package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.js +151 -0
- package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.js.map +1 -0
- package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.js +117 -0
- package/dist/cjs/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.js.map +1 -0
- package/dist/cjs/extensions/dynamic-contracts/write/installPublishedExtension.js +60 -0
- package/dist/cjs/extensions/dynamic-contracts/write/installPublishedExtension.js.map +1 -0
- package/dist/cjs/extensions/dynamic-contracts/write/uninstallExtension.js +29 -0
- package/dist/cjs/extensions/dynamic-contracts/write/uninstallExtension.js.map +1 -0
- package/dist/cjs/extensions/prebuilts/deploy-marketplace.js +56 -60
- package/dist/cjs/extensions/prebuilts/deploy-marketplace.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/deploy-published.js +19 -0
- package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js +90 -0
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/cjs/extensions/thirdweb/write/publish.js +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +1 -0
- package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/contract/deployment/utils/bootstrap.js +4 -1
- package/dist/esm/contract/deployment/utils/bootstrap.js.map +1 -1
- package/dist/esm/exports/extensions/dynamic-contracts.js +6 -0
- package/dist/esm/exports/extensions/dynamic-contracts.js.map +1 -0
- package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.js +144 -0
- package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.js.map +1 -0
- package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.js +110 -0
- package/dist/esm/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.js.map +1 -0
- package/dist/esm/extensions/dynamic-contracts/write/installPublishedExtension.js +57 -0
- package/dist/esm/extensions/dynamic-contracts/write/installPublishedExtension.js.map +1 -0
- package/dist/esm/extensions/dynamic-contracts/write/uninstallExtension.js +26 -0
- package/dist/esm/extensions/dynamic-contracts/write/uninstallExtension.js.map +1 -0
- package/dist/esm/extensions/prebuilts/deploy-marketplace.js +56 -60
- package/dist/esm/extensions/prebuilts/deploy-marketplace.js.map +1 -1
- package/dist/esm/extensions/prebuilts/deploy-published.js +19 -0
- package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/esm/extensions/prebuilts/get-required-transactions.js +89 -0
- package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/esm/extensions/thirdweb/write/publish.js +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +1 -0
- package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/contract/deployment/utils/bootstrap.d.ts.map +1 -1
- package/dist/types/exports/extensions/dynamic-contracts.d.ts +6 -0
- package/dist/types/exports/extensions/dynamic-contracts.d.ts.map +1 -0
- package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.d.ts +113 -0
- package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.d.ts.map +1 -0
- package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.d.ts +79 -0
- package/dist/types/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.d.ts.map +1 -0
- package/dist/types/extensions/dynamic-contracts/write/installPublishedExtension.d.ts +30 -0
- package/dist/types/extensions/dynamic-contracts/write/installPublishedExtension.d.ts.map +1 -0
- package/dist/types/extensions/dynamic-contracts/write/uninstallExtension.d.ts +26 -0
- package/dist/types/extensions/dynamic-contracts/write/uninstallExtension.d.ts.map +1 -0
- package/dist/types/extensions/prebuilts/deploy-marketplace.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/get-required-transactions.d.ts +26 -0
- package/dist/types/extensions/prebuilts/get-required-transactions.d.ts.map +1 -1
- package/dist/types/extensions/thirdweb/write/publish.d.ts +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts +1 -0
- package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/bridge/Buy.test.ts +1 -1
- package/src/bridge/Routes.test.ts +1 -1
- package/src/bridge/Sell.test.ts +1 -1
- package/src/bridge/Status.test.ts +1 -1
- package/src/contract/deployment/deploy-dynamic.test.ts +52 -0
- package/src/contract/deployment/utils/bootstrap.ts +5 -1
- package/src/exports/extensions/dynamic-contracts.ts +11 -0
- package/src/extensions/dynamic-contracts/__generated__/IExtensionManager/write/addExtension.ts +193 -0
- package/src/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.ts +140 -0
- package/src/extensions/dynamic-contracts/write/installPublishedExtension.test.ts +61 -0
- package/src/extensions/dynamic-contracts/write/installPublishedExtension.ts +85 -0
- package/src/extensions/dynamic-contracts/write/uninstallExtension.test.ts +64 -0
- package/src/extensions/dynamic-contracts/write/uninstallExtension.ts +35 -0
- package/src/extensions/prebuilts/deploy-marketplace.ts +78 -81
- package/src/extensions/prebuilts/deploy-published.ts +24 -0
- package/src/extensions/prebuilts/get-required-transactions.test.ts +14 -0
- package/src/extensions/prebuilts/get-required-transactions.ts +138 -0
- package/src/extensions/thirdweb/write/publish.ts +1 -1
- package/src/react/web/ui/PayEmbed.tsx +1 -0
- package/src/version.ts +1 -1
package/src/extensions/dynamic-contracts/__generated__/IExtensionManager/write/removeExtension.ts
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type {
|
3
|
+
BaseTransactionOptions,
|
4
|
+
WithOverrides,
|
5
|
+
} from "../../../../../transaction/types.js";
|
6
|
+
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
7
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
8
|
+
import { once } from "../../../../../utils/promise/once.js";
|
9
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Represents the parameters for the "removeExtension" function.
|
13
|
+
*/
|
14
|
+
export type RemoveExtensionParams = WithOverrides<{
|
15
|
+
extensionName: AbiParameterToPrimitiveType<{
|
16
|
+
type: "string";
|
17
|
+
name: "extensionName";
|
18
|
+
}>;
|
19
|
+
}>;
|
20
|
+
|
21
|
+
export const FN_SELECTOR = "0xee7d2adf" as const;
|
22
|
+
const FN_INPUTS = [
|
23
|
+
{
|
24
|
+
type: "string",
|
25
|
+
name: "extensionName",
|
26
|
+
},
|
27
|
+
] as const;
|
28
|
+
const FN_OUTPUTS = [] as const;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Checks if the `removeExtension` method is supported by the given contract.
|
32
|
+
* @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.
|
33
|
+
* @returns A boolean indicating if the `removeExtension` method is supported.
|
34
|
+
* @extension DYNAMIC-CONTRACTS
|
35
|
+
* @example
|
36
|
+
* ```ts
|
37
|
+
* import { isRemoveExtensionSupported } from "thirdweb/extensions/dynamic-contracts";
|
38
|
+
*
|
39
|
+
* const supported = isRemoveExtensionSupported(["0x..."]);
|
40
|
+
* ```
|
41
|
+
*/
|
42
|
+
export function isRemoveExtensionSupported(availableSelectors: string[]) {
|
43
|
+
return detectMethod({
|
44
|
+
availableSelectors,
|
45
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Encodes the parameters for the "removeExtension" function.
|
51
|
+
* @param options - The options for the removeExtension function.
|
52
|
+
* @returns The encoded ABI parameters.
|
53
|
+
* @extension DYNAMIC-CONTRACTS
|
54
|
+
* @example
|
55
|
+
* ```ts
|
56
|
+
* import { encodeRemoveExtensionParams } from "thirdweb/extensions/dynamic-contracts";
|
57
|
+
* const result = encodeRemoveExtensionParams({
|
58
|
+
* extensionName: ...,
|
59
|
+
* });
|
60
|
+
* ```
|
61
|
+
*/
|
62
|
+
export function encodeRemoveExtensionParams(options: RemoveExtensionParams) {
|
63
|
+
return encodeAbiParameters(FN_INPUTS, [options.extensionName]);
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Encodes the "removeExtension" function into a Hex string with its parameters.
|
68
|
+
* @param options - The options for the removeExtension function.
|
69
|
+
* @returns The encoded hexadecimal string.
|
70
|
+
* @extension DYNAMIC-CONTRACTS
|
71
|
+
* @example
|
72
|
+
* ```ts
|
73
|
+
* import { encodeRemoveExtension } from "thirdweb/extensions/dynamic-contracts";
|
74
|
+
* const result = encodeRemoveExtension({
|
75
|
+
* extensionName: ...,
|
76
|
+
* });
|
77
|
+
* ```
|
78
|
+
*/
|
79
|
+
export function encodeRemoveExtension(options: RemoveExtensionParams) {
|
80
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
81
|
+
// we can do this because we know the specific formats of the values
|
82
|
+
return (FN_SELECTOR +
|
83
|
+
encodeRemoveExtensionParams(options).slice(
|
84
|
+
2,
|
85
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
86
|
+
}
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Prepares a transaction to call the "removeExtension" function on the contract.
|
90
|
+
* @param options - The options for the "removeExtension" function.
|
91
|
+
* @returns A prepared transaction object.
|
92
|
+
* @extension DYNAMIC-CONTRACTS
|
93
|
+
* @example
|
94
|
+
* ```ts
|
95
|
+
* import { sendTransaction } from "thirdweb";
|
96
|
+
* import { removeExtension } from "thirdweb/extensions/dynamic-contracts";
|
97
|
+
*
|
98
|
+
* const transaction = removeExtension({
|
99
|
+
* contract,
|
100
|
+
* extensionName: ...,
|
101
|
+
* overrides: {
|
102
|
+
* ...
|
103
|
+
* }
|
104
|
+
* });
|
105
|
+
*
|
106
|
+
* // Send the transaction
|
107
|
+
* await sendTransaction({ transaction, account });
|
108
|
+
* ```
|
109
|
+
*/
|
110
|
+
export function removeExtension(
|
111
|
+
options: BaseTransactionOptions<
|
112
|
+
| RemoveExtensionParams
|
113
|
+
| {
|
114
|
+
asyncParams: () => Promise<RemoveExtensionParams>;
|
115
|
+
}
|
116
|
+
>,
|
117
|
+
) {
|
118
|
+
const asyncOptions = once(async () => {
|
119
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
120
|
+
});
|
121
|
+
|
122
|
+
return prepareContractCall({
|
123
|
+
contract: options.contract,
|
124
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
125
|
+
params: async () => {
|
126
|
+
const resolvedOptions = await asyncOptions();
|
127
|
+
return [resolvedOptions.extensionName] as const;
|
128
|
+
},
|
129
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
130
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
131
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
132
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
133
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
134
|
+
maxPriorityFeePerGas: async () =>
|
135
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
136
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
137
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
138
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
139
|
+
});
|
140
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
|
3
|
+
import { readContract } from "src/transaction/read-contract.js";
|
4
|
+
import { resolveMethod } from "src/transaction/resolve-method.js";
|
5
|
+
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
6
|
+
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
7
|
+
import { TEST_ACCOUNT_A } from "../../../../test/src/test-wallets.js";
|
8
|
+
import { getContract } from "../../../contract/contract.js";
|
9
|
+
import { deployCloneFactory } from "../../../contract/deployment/utils/bootstrap.js";
|
10
|
+
import { deployPublishedContract } from "../../../extensions/prebuilts/deploy-published.js";
|
11
|
+
import { sendTransaction } from "../../../transaction/actions/send-transaction.js";
|
12
|
+
import { installPublishedExtension } from "./installPublishedExtension.js";
|
13
|
+
|
14
|
+
describe.runIf(process.env.TW_SECRET_KEY)("install extension", () => {
|
15
|
+
it.sequential("should install extension to a dynamic contract", async () => {
|
16
|
+
await deployCloneFactory({
|
17
|
+
chain: ANVIL_CHAIN,
|
18
|
+
client: TEST_CLIENT,
|
19
|
+
account: TEST_ACCOUNT_A,
|
20
|
+
});
|
21
|
+
|
22
|
+
const deployed = await deployPublishedContract({
|
23
|
+
chain: ANVIL_CHAIN,
|
24
|
+
client: TEST_CLIENT,
|
25
|
+
account: TEST_ACCOUNT_A,
|
26
|
+
contractId: "EvolvingNFT",
|
27
|
+
contractParams: {
|
28
|
+
name: "Evolving nft",
|
29
|
+
symbol: "ENFT",
|
30
|
+
defaultAdmin: TEST_ACCOUNT_A.address,
|
31
|
+
royaltyBps: 0n,
|
32
|
+
royaltyRecipient: TEST_ACCOUNT_A.address,
|
33
|
+
saleRecipient: TEST_ACCOUNT_A.address,
|
34
|
+
trustedForwarders: [],
|
35
|
+
contractURI: "",
|
36
|
+
},
|
37
|
+
});
|
38
|
+
|
39
|
+
const contract = getContract({
|
40
|
+
chain: ANVIL_CHAIN,
|
41
|
+
client: TEST_CLIENT,
|
42
|
+
address: deployed,
|
43
|
+
});
|
44
|
+
|
45
|
+
const transaction = installPublishedExtension({
|
46
|
+
account: TEST_ACCOUNT_A,
|
47
|
+
contract,
|
48
|
+
extensionName: "DirectListingsLogic",
|
49
|
+
});
|
50
|
+
|
51
|
+
await sendTransaction({ transaction, account: TEST_ACCOUNT_A });
|
52
|
+
|
53
|
+
const extensions = await readContract({
|
54
|
+
contract,
|
55
|
+
method: resolveMethod("getAllExtensions"),
|
56
|
+
params: [],
|
57
|
+
});
|
58
|
+
|
59
|
+
expect(extensions.length).toEqual(4);
|
60
|
+
});
|
61
|
+
});
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js";
|
2
|
+
import type { ThirdwebContract } from "../../../contract/contract.js";
|
3
|
+
import { getOrDeployInfraForPublishedContract } from "../../../contract/deployment/utils/bootstrap.js";
|
4
|
+
import {
|
5
|
+
generateExtensionFunctionsFromAbi,
|
6
|
+
getAllDefaultConstructorParamsForImplementation,
|
7
|
+
} from "../../../extensions/prebuilts/get-required-transactions.js";
|
8
|
+
import type { Account } from "../../../wallets/interfaces/wallet.js";
|
9
|
+
import { addExtension } from "../__generated__/IExtensionManager/write/addExtension.js";
|
10
|
+
|
11
|
+
export type InstallPublishedExtensionOptions = {
|
12
|
+
account: Account;
|
13
|
+
contract: ThirdwebContract;
|
14
|
+
extensionName: string;
|
15
|
+
publisher?: string;
|
16
|
+
version?: string;
|
17
|
+
constructorParams?: Record<string, unknown>;
|
18
|
+
};
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Install a published extension on a dynamic contract
|
22
|
+
* @param options - The options for installing a published extension
|
23
|
+
* @returns A prepared transaction to send
|
24
|
+
* @example
|
25
|
+
* ```ts
|
26
|
+
* import { installPublishedExtension } from "thirdweb/dynamic-contracts";
|
27
|
+
* const transaction = installPublishedExtension({
|
28
|
+
* client,
|
29
|
+
* chain,
|
30
|
+
* account,
|
31
|
+
* contract,
|
32
|
+
* extensionName: "MyExtension",
|
33
|
+
* publisherAddress: "0x...",
|
34
|
+
* });
|
35
|
+
* await sendTransaction({ transaction, account });
|
36
|
+
* ```
|
37
|
+
*/
|
38
|
+
export function installPublishedExtension(
|
39
|
+
options: InstallPublishedExtensionOptions,
|
40
|
+
) {
|
41
|
+
const {
|
42
|
+
account,
|
43
|
+
contract,
|
44
|
+
extensionName,
|
45
|
+
constructorParams,
|
46
|
+
publisher,
|
47
|
+
version,
|
48
|
+
} = options;
|
49
|
+
|
50
|
+
return addExtension({
|
51
|
+
contract,
|
52
|
+
asyncParams: async () => {
|
53
|
+
const deployedExtension = await getOrDeployInfraForPublishedContract({
|
54
|
+
chain: contract.chain,
|
55
|
+
client: contract.client,
|
56
|
+
account,
|
57
|
+
contractId: extensionName,
|
58
|
+
constructorParams:
|
59
|
+
constructorParams ||
|
60
|
+
(await getAllDefaultConstructorParamsForImplementation({
|
61
|
+
chain: contract.chain,
|
62
|
+
client: contract.client,
|
63
|
+
contractId: extensionName,
|
64
|
+
})),
|
65
|
+
publisher,
|
66
|
+
version,
|
67
|
+
});
|
68
|
+
|
69
|
+
const abi = await resolveContractAbi(
|
70
|
+
deployedExtension.implementationContract,
|
71
|
+
);
|
72
|
+
const functions = generateExtensionFunctionsFromAbi(abi);
|
73
|
+
return {
|
74
|
+
extension: {
|
75
|
+
metadata: {
|
76
|
+
name: extensionName,
|
77
|
+
metadataURI: "",
|
78
|
+
implementation: deployedExtension.implementationContract.address,
|
79
|
+
},
|
80
|
+
functions,
|
81
|
+
},
|
82
|
+
};
|
83
|
+
},
|
84
|
+
});
|
85
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
|
3
|
+
import { readContract } from "src/transaction/read-contract.js";
|
4
|
+
import { resolveMethod } from "src/transaction/resolve-method.js";
|
5
|
+
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
|
6
|
+
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
7
|
+
import { TEST_ACCOUNT_A } from "../../../../test/src/test-wallets.js";
|
8
|
+
import { getContract } from "../../../contract/contract.js";
|
9
|
+
import { deployCloneFactory } from "../../../contract/deployment/utils/bootstrap.js";
|
10
|
+
import { sendTransaction } from "../../../transaction/actions/send-transaction.js";
|
11
|
+
import { deployPublishedContract } from "../../prebuilts/deploy-published.js";
|
12
|
+
import { uninstallExtension } from "./uninstallExtension.js";
|
13
|
+
|
14
|
+
describe.runIf(process.env.TW_SECRET_KEY)("uninstall extension", () => {
|
15
|
+
it.sequential(
|
16
|
+
"should uninstall extension from a dynamic contract",
|
17
|
+
async () => {
|
18
|
+
await deployCloneFactory({
|
19
|
+
chain: ANVIL_CHAIN,
|
20
|
+
client: TEST_CLIENT,
|
21
|
+
account: TEST_ACCOUNT_A,
|
22
|
+
});
|
23
|
+
|
24
|
+
const deployed = await deployPublishedContract({
|
25
|
+
chain: ANVIL_CHAIN,
|
26
|
+
client: TEST_CLIENT,
|
27
|
+
account: TEST_ACCOUNT_A,
|
28
|
+
contractId: "EvolvingNFT",
|
29
|
+
contractParams: {
|
30
|
+
name: "Evolving nft",
|
31
|
+
symbol: "ENFT",
|
32
|
+
defaultAdmin: TEST_ACCOUNT_A.address,
|
33
|
+
royaltyBps: 0n,
|
34
|
+
royaltyRecipient: TEST_ACCOUNT_A.address,
|
35
|
+
saleRecipient: TEST_ACCOUNT_A.address,
|
36
|
+
trustedForwarders: [],
|
37
|
+
contractURI: "",
|
38
|
+
},
|
39
|
+
});
|
40
|
+
|
41
|
+
const contract = getContract({
|
42
|
+
chain: ANVIL_CHAIN,
|
43
|
+
client: TEST_CLIENT,
|
44
|
+
address: deployed,
|
45
|
+
});
|
46
|
+
|
47
|
+
const transaction = uninstallExtension({
|
48
|
+
account: TEST_ACCOUNT_A,
|
49
|
+
contract,
|
50
|
+
extensionName: "EvolvingNFTLogic",
|
51
|
+
});
|
52
|
+
|
53
|
+
await sendTransaction({ transaction, account: TEST_ACCOUNT_A });
|
54
|
+
|
55
|
+
const extensions = await readContract({
|
56
|
+
contract,
|
57
|
+
method: resolveMethod("getAllExtensions"),
|
58
|
+
params: [],
|
59
|
+
});
|
60
|
+
|
61
|
+
expect(extensions.length).toEqual(2);
|
62
|
+
},
|
63
|
+
);
|
64
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { ThirdwebContract } from "../../../contract/contract.js";
|
2
|
+
import type { Account } from "../../../wallets/interfaces/wallet.js";
|
3
|
+
import { removeExtension } from "../__generated__/IExtensionManager/write/removeExtension.js";
|
4
|
+
|
5
|
+
export type UninstallExtensionOptions = {
|
6
|
+
account: Account;
|
7
|
+
contract: ThirdwebContract;
|
8
|
+
extensionName: string;
|
9
|
+
};
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Uninstall an extension on a dynamic contract
|
13
|
+
* @param options - The options for uninstalling an extension
|
14
|
+
* @returns A prepared transaction to send
|
15
|
+
* @example
|
16
|
+
* ```ts
|
17
|
+
* import { uninstallExtension } from "thirdweb/dynamic-contracts";
|
18
|
+
* const transaction = uninstallExtension({
|
19
|
+
* client,
|
20
|
+
* chain,
|
21
|
+
* account,
|
22
|
+
* contract,
|
23
|
+
* extensionName: "MyExtension",
|
24
|
+
* });
|
25
|
+
* await sendTransaction({ transaction, account });
|
26
|
+
* ```
|
27
|
+
*/
|
28
|
+
export function uninstallExtension(options: UninstallExtensionOptions) {
|
29
|
+
const { contract, extensionName } = options;
|
30
|
+
|
31
|
+
return removeExtension({
|
32
|
+
contract,
|
33
|
+
extensionName,
|
34
|
+
});
|
35
|
+
}
|
@@ -1,10 +1,4 @@
|
|
1
|
-
import type {
|
2
|
-
Abi,
|
3
|
-
AbiFunction,
|
4
|
-
AbiParametersToPrimitiveTypes,
|
5
|
-
Address,
|
6
|
-
} from "abitype";
|
7
|
-
import { toFunctionSelector, toFunctionSignature } from "viem";
|
1
|
+
import type { AbiParametersToPrimitiveTypes, Address } from "abitype";
|
8
2
|
import type { ThirdwebClient } from "../../client/client.js";
|
9
3
|
import { resolveContractAbi } from "../../contract/actions/resolve-abi.js";
|
10
4
|
import type { ThirdwebContract } from "../../contract/contract.js";
|
@@ -19,6 +13,19 @@ import { getRoyaltyEngineV1ByChainId } from "../../utils/royalty-engine.js";
|
|
19
13
|
import type { Prettify } from "../../utils/type-utils.js";
|
20
14
|
import type { ClientAndChainAndAccount } from "../../utils/types.js";
|
21
15
|
import { initialize as initMarketplace } from "./__generated__/Marketplace/write/initialize.js";
|
16
|
+
import { generateExtensionFunctionsFromAbi } from "./get-required-transactions.js";
|
17
|
+
|
18
|
+
type Extension = {
|
19
|
+
metadata: {
|
20
|
+
name: string;
|
21
|
+
metadataURI: string;
|
22
|
+
implementation: `0x${string}`;
|
23
|
+
};
|
24
|
+
functions: {
|
25
|
+
functionSelector: string;
|
26
|
+
functionSignature: string;
|
27
|
+
}[];
|
28
|
+
};
|
22
29
|
|
23
30
|
export type MarketplaceContractParams = {
|
24
31
|
name: string;
|
@@ -74,41 +81,72 @@ export async function deployMarketplaceContract(
|
|
74
81
|
account,
|
75
82
|
contractId: "WETH9",
|
76
83
|
});
|
77
|
-
const direct = await getOrDeployInfraForPublishedContract({
|
78
|
-
chain,
|
79
|
-
client,
|
80
|
-
account,
|
81
|
-
contractId: "DirectListingsLogic",
|
82
|
-
constructorParams: { _nativeTokenWrapper: WETH.address },
|
83
|
-
});
|
84
84
|
|
85
|
-
|
86
|
-
chain,
|
87
|
-
client,
|
88
|
-
account,
|
89
|
-
contractId: "EnglishAuctionsLogic",
|
90
|
-
constructorParams: { _nativeTokenWrapper: WETH.address },
|
91
|
-
});
|
85
|
+
let extensions: Extension[] = [];
|
92
86
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
87
|
+
if (options.version !== "6.0.0") {
|
88
|
+
const direct = await getOrDeployInfraForPublishedContract({
|
89
|
+
chain,
|
90
|
+
client,
|
91
|
+
account,
|
92
|
+
contractId: "DirectListingsLogic",
|
93
|
+
constructorParams: { _nativeTokenWrapper: WETH.address },
|
94
|
+
});
|
99
95
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
96
|
+
const english = await getOrDeployInfraForPublishedContract({
|
97
|
+
chain,
|
98
|
+
client,
|
99
|
+
account,
|
100
|
+
contractId: "EnglishAuctionsLogic",
|
101
|
+
constructorParams: { _nativeTokenWrapper: WETH.address },
|
102
|
+
});
|
103
|
+
|
104
|
+
const offers = await getOrDeployInfraForPublishedContract({
|
105
|
+
chain,
|
106
|
+
client,
|
107
|
+
account,
|
108
|
+
contractId: "OffersLogic",
|
109
|
+
});
|
110
|
+
|
111
|
+
const [directFunctions, englishFunctions, offersFunctions] =
|
112
|
+
await Promise.all([
|
113
|
+
resolveContractAbi(direct.implementationContract).then(
|
114
|
+
generateExtensionFunctionsFromAbi,
|
115
|
+
),
|
116
|
+
resolveContractAbi(english.implementationContract).then(
|
117
|
+
generateExtensionFunctionsFromAbi,
|
118
|
+
),
|
119
|
+
resolveContractAbi(offers.implementationContract).then(
|
120
|
+
generateExtensionFunctionsFromAbi,
|
121
|
+
),
|
122
|
+
]);
|
123
|
+
extensions = [
|
124
|
+
{
|
125
|
+
metadata: {
|
126
|
+
name: "Direct Listings",
|
127
|
+
metadataURI: "",
|
128
|
+
implementation: direct.implementationContract.address,
|
129
|
+
},
|
130
|
+
functions: directFunctions,
|
131
|
+
},
|
132
|
+
{
|
133
|
+
metadata: {
|
134
|
+
name: "English Auctions",
|
135
|
+
metadataURI: "",
|
136
|
+
implementation: english.implementationContract.address,
|
137
|
+
},
|
138
|
+
functions: englishFunctions,
|
139
|
+
},
|
140
|
+
{
|
141
|
+
metadata: {
|
142
|
+
name: "Offers",
|
143
|
+
metadataURI: "",
|
144
|
+
implementation: offers.implementationContract.address,
|
145
|
+
},
|
146
|
+
functions: offersFunctions,
|
147
|
+
},
|
148
|
+
];
|
149
|
+
}
|
112
150
|
|
113
151
|
const { cloneFactoryContract, implementationContract } =
|
114
152
|
await getOrDeployInfraForPublishedContract({
|
@@ -118,32 +156,7 @@ export async function deployMarketplaceContract(
|
|
118
156
|
contractId: "MarketplaceV3",
|
119
157
|
constructorParams: {
|
120
158
|
_marketplaceV3Params: {
|
121
|
-
extensions
|
122
|
-
{
|
123
|
-
metadata: {
|
124
|
-
name: "Direct Listings",
|
125
|
-
metadataURI: "",
|
126
|
-
implementation: direct.implementationContract.address,
|
127
|
-
},
|
128
|
-
functions: directFunctions,
|
129
|
-
},
|
130
|
-
{
|
131
|
-
metadata: {
|
132
|
-
name: "English Auctions",
|
133
|
-
metadataURI: "",
|
134
|
-
implementation: english.implementationContract.address,
|
135
|
-
},
|
136
|
-
functions: englishFunctions,
|
137
|
-
},
|
138
|
-
{
|
139
|
-
metadata: {
|
140
|
-
name: "Offers",
|
141
|
-
metadataURI: "",
|
142
|
-
implementation: offers.implementationContract.address,
|
143
|
-
},
|
144
|
-
functions: offersFunctions,
|
145
|
-
},
|
146
|
-
],
|
159
|
+
extensions,
|
147
160
|
royaltyEngineAddress: getRoyaltyEngineV1ByChainId(chain.id),
|
148
161
|
nativeTokenWrapper: WETH.address,
|
149
162
|
} as MarketplaceConstructorParams[number],
|
@@ -199,22 +212,6 @@ async function getInitializeTransaction(options: {
|
|
199
212
|
});
|
200
213
|
}
|
201
214
|
|
202
|
-
// helperFns
|
203
|
-
|
204
|
-
function generateExtensionFunctionsFromAbi(abi: Abi): Array<{
|
205
|
-
functionSelector: string;
|
206
|
-
functionSignature: string;
|
207
|
-
}> {
|
208
|
-
const functions = abi.filter(
|
209
|
-
(item) => item.type === "function" && !item.name.startsWith("_"),
|
210
|
-
) as AbiFunction[];
|
211
|
-
|
212
|
-
return functions.map((fn) => ({
|
213
|
-
functionSelector: toFunctionSelector(fn),
|
214
|
-
functionSignature: toFunctionSignature(fn),
|
215
|
-
}));
|
216
|
-
}
|
217
|
-
|
218
215
|
// let's just ... put this down here
|
219
216
|
type MarketplaceConstructorParams = AbiParametersToPrimitiveTypes<
|
220
217
|
[
|
@@ -204,6 +204,29 @@ export async function deployContractfromDeployMetadata(
|
|
204
204
|
import("../../contract/deployment/deploy-via-autofactory.js"),
|
205
205
|
import("../../contract/deployment/utils/bootstrap.js"),
|
206
206
|
]);
|
207
|
+
|
208
|
+
if (
|
209
|
+
deployMetadata.routerType === "dynamic" &&
|
210
|
+
deployMetadata.defaultExtensions
|
211
|
+
) {
|
212
|
+
for (const e of deployMetadata.defaultExtensions) {
|
213
|
+
await getOrDeployInfraForPublishedContract({
|
214
|
+
chain,
|
215
|
+
client,
|
216
|
+
account,
|
217
|
+
contractId: e.extensionName,
|
218
|
+
version: e.extensionVersion || "latest",
|
219
|
+
publisher: e.publisherAddress,
|
220
|
+
constructorParams:
|
221
|
+
await getAllDefaultConstructorParamsForImplementation({
|
222
|
+
chain,
|
223
|
+
client,
|
224
|
+
contractId: e.extensionName,
|
225
|
+
}),
|
226
|
+
});
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
207
230
|
const { cloneFactoryContract, implementationContract } =
|
208
231
|
await getOrDeployInfraForPublishedContract({
|
209
232
|
chain,
|
@@ -216,6 +239,7 @@ export async function deployContractfromDeployMetadata(
|
|
216
239
|
chain,
|
217
240
|
client,
|
218
241
|
contractId: deployMetadata.name,
|
242
|
+
defaultExtensions: deployMetadata.defaultExtensions,
|
219
243
|
})),
|
220
244
|
publisher: deployMetadata.publisher,
|
221
245
|
version: deployMetadata.version,
|
@@ -64,6 +64,20 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
64
64
|
expect(results.length).toBe(7);
|
65
65
|
});
|
66
66
|
|
67
|
+
it("should count transactions for a dynamic contract", async () => {
|
68
|
+
const deployMetadata = await fetchPublishedContractMetadata({
|
69
|
+
client: TEST_CLIENT,
|
70
|
+
contractId: "EvolvingNFT",
|
71
|
+
});
|
72
|
+
const results = await getRequiredTransactions({
|
73
|
+
client: TEST_CLIENT,
|
74
|
+
chain: CLEAN_ANVIL_CHAIN,
|
75
|
+
deployMetadata,
|
76
|
+
});
|
77
|
+
|
78
|
+
expect(results.length).toBe(8);
|
79
|
+
});
|
80
|
+
|
67
81
|
it("should return default constructor params for zksync chains", async () => {
|
68
82
|
const params = await getAllDefaultConstructorParamsForImplementation({
|
69
83
|
chain: defineChain(300),
|