thirdweb 5.93.4 → 5.93.5-nightly-b51157c0ff17e9535029fc8790cfa8538d1c995f-20250326000337
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/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/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/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/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/bridge/Sell.test.ts
CHANGED
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
|
3
3
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
4
|
import * as Sell from "./Sell.js";
|
5
5
|
|
6
|
-
describe("Bridge.Sell.quote", () => {
|
6
|
+
describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.quote", () => {
|
7
7
|
it("should get a valid quote", async () => {
|
8
8
|
const quote = await Sell.quote({
|
9
9
|
originChainId: 1,
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|
2
2
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
3
3
|
import { status } from "./Status.js";
|
4
4
|
|
5
|
-
describe("Bridge.status", () => {
|
5
|
+
describe.runIf(process.env.TW_SECRET_KEY)("Bridge.status", () => {
|
6
6
|
it("should handle successful status", async () => {
|
7
7
|
const result = await status({
|
8
8
|
transactionHash:
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { readContract } from "src/transaction/read-contract.js";
|
2
|
+
import { resolveMethod } from "src/transaction/resolve-method.js";
|
3
|
+
import { describe, expect, it } from "vitest";
|
4
|
+
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
5
|
+
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
6
|
+
import { TEST_ACCOUNT_A } from "../../../test/src/test-wallets.js";
|
7
|
+
import { deployPublishedContract } from "../../extensions/prebuilts/deploy-published.js";
|
8
|
+
import { getContract } from "../contract.js";
|
9
|
+
import { deployCloneFactory } from "./utils/bootstrap.js";
|
10
|
+
|
11
|
+
describe.runIf(process.env.TW_SECRET_KEY)("deploy dynamic", () => {
|
12
|
+
it.sequential("should deploy dynamic contract with extensions", async () => {
|
13
|
+
await deployCloneFactory({
|
14
|
+
chain: ANVIL_CHAIN,
|
15
|
+
client: TEST_CLIENT,
|
16
|
+
account: TEST_ACCOUNT_A,
|
17
|
+
});
|
18
|
+
|
19
|
+
const deployed = await deployPublishedContract({
|
20
|
+
chain: ANVIL_CHAIN,
|
21
|
+
client: TEST_CLIENT,
|
22
|
+
account: TEST_ACCOUNT_A,
|
23
|
+
contractId: "EvolvingNFT",
|
24
|
+
contractParams: {
|
25
|
+
name: "Evolving nft",
|
26
|
+
symbol: "ENFT",
|
27
|
+
defaultAdmin: TEST_ACCOUNT_A.address,
|
28
|
+
royaltyBps: 0n,
|
29
|
+
royaltyRecipient: TEST_ACCOUNT_A.address,
|
30
|
+
saleRecipient: TEST_ACCOUNT_A.address,
|
31
|
+
trustedForwarders: [],
|
32
|
+
contractURI: "",
|
33
|
+
},
|
34
|
+
});
|
35
|
+
|
36
|
+
expect(deployed).toBeDefined();
|
37
|
+
|
38
|
+
const contract = getContract({
|
39
|
+
client: TEST_CLIENT,
|
40
|
+
address: deployed,
|
41
|
+
chain: ANVIL_CHAIN,
|
42
|
+
});
|
43
|
+
|
44
|
+
const extensions = await readContract({
|
45
|
+
contract,
|
46
|
+
method: resolveMethod("getAllExtensions"),
|
47
|
+
params: [],
|
48
|
+
});
|
49
|
+
|
50
|
+
expect(extensions.length).toEqual(3);
|
51
|
+
});
|
52
|
+
});
|
@@ -142,7 +142,11 @@ export async function getOrDeployInfraForPublishedContract(
|
|
142
142
|
version,
|
143
143
|
});
|
144
144
|
}
|
145
|
-
|
145
|
+
|
146
|
+
return {
|
147
|
+
cloneFactoryContract,
|
148
|
+
implementationContract,
|
149
|
+
};
|
146
150
|
}
|
147
151
|
|
148
152
|
/**
|
@@ -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),
|
@@ -1,5 +1,8 @@
|
|
1
|
+
import type { Abi, AbiFunction } from "abitype";
|
2
|
+
import { toFunctionSelector, toFunctionSignature } from "viem";
|
1
3
|
import type { Chain } from "../../chains/types.js";
|
2
4
|
import type { ThirdwebClient } from "../../client/client.js";
|
5
|
+
import { resolveContractAbi } from "../../contract/actions/resolve-abi.js";
|
3
6
|
import { getDeployedCreate2Factory } from "../../contract/deployment/utils/create-2-factory.js";
|
4
7
|
import { getDeployedInfraContract } from "../../contract/deployment/utils/infra.js";
|
5
8
|
import { getDeployedInfraContractFromMetadata } from "../../contract/deployment/utils/infra.js";
|
@@ -19,6 +22,15 @@ type DeployTransactionType =
|
|
19
22
|
| "extension"
|
20
23
|
| "proxy";
|
21
24
|
|
25
|
+
/**
|
26
|
+
* @internal
|
27
|
+
*/
|
28
|
+
type DynamicContractExtension = {
|
29
|
+
extensionName: string;
|
30
|
+
extensionVersion: string;
|
31
|
+
publisherAddress: string;
|
32
|
+
};
|
33
|
+
|
22
34
|
/**
|
23
35
|
* @internal
|
24
36
|
*/
|
@@ -131,6 +143,10 @@ async function getTransactionsForImplementation(options: {
|
|
131
143
|
return getTransactionsForMaketplaceV3(options);
|
132
144
|
}
|
133
145
|
|
146
|
+
if (deployMetadata.routerType === "dynamic") {
|
147
|
+
return getTransactionsForDynamicContract(options);
|
148
|
+
}
|
149
|
+
|
134
150
|
const constructorParams =
|
135
151
|
implementationConstructorParams ??
|
136
152
|
(await getAllDefaultConstructorParamsForImplementation({
|
@@ -211,6 +227,54 @@ async function getTransactionsForMaketplaceV3(options: {
|
|
211
227
|
return transactions;
|
212
228
|
}
|
213
229
|
|
230
|
+
async function getTransactionsForDynamicContract(options: {
|
231
|
+
chain: Chain;
|
232
|
+
client: ThirdwebClient;
|
233
|
+
deployMetadata: FetchDeployMetadataResult;
|
234
|
+
}): Promise<DeployTransactionResult[]> {
|
235
|
+
const { chain, client } = options;
|
236
|
+
const WETHAdress = await computePublishedContractAddress({
|
237
|
+
chain,
|
238
|
+
client,
|
239
|
+
contractId: "WETH9",
|
240
|
+
});
|
241
|
+
const wethTx = await getDeployedInfraContract({
|
242
|
+
chain,
|
243
|
+
client,
|
244
|
+
contractId: "WETH9",
|
245
|
+
}).then((c) =>
|
246
|
+
c ? null : ({ type: "infra", contractId: "WETH9" } as const),
|
247
|
+
);
|
248
|
+
const extensions: (DeployTransactionResult | null)[] = options.deployMetadata
|
249
|
+
.defaultExtensions
|
250
|
+
? await Promise.all(
|
251
|
+
options.deployMetadata.defaultExtensions.map((e) => {
|
252
|
+
return getDeployedInfraContract({
|
253
|
+
chain,
|
254
|
+
client,
|
255
|
+
contractId: e.extensionName,
|
256
|
+
publisher: e.publisherAddress,
|
257
|
+
version: e.extensionVersion || "latest",
|
258
|
+
constructorParams: { _nativeTokenWrapper: WETHAdress },
|
259
|
+
}).then((c) =>
|
260
|
+
c
|
261
|
+
? null
|
262
|
+
: ({ type: "extension", contractId: e.extensionName } as const),
|
263
|
+
);
|
264
|
+
}),
|
265
|
+
)
|
266
|
+
: [];
|
267
|
+
// hacky assumption: if we need to deploy any of the extensions, we also need to deploy the implementation
|
268
|
+
const transactions = [...extensions, wethTx].filter((e) => e !== null);
|
269
|
+
if (transactions.length) {
|
270
|
+
transactions.push({
|
271
|
+
type: "implementation",
|
272
|
+
contractId: options.deployMetadata.name,
|
273
|
+
});
|
274
|
+
}
|
275
|
+
return transactions;
|
276
|
+
}
|
277
|
+
|
214
278
|
/**
|
215
279
|
* Gets the default constructor parameters required for contract implementation deployment
|
216
280
|
* @param args - The arguments object
|
@@ -226,6 +290,7 @@ export async function getAllDefaultConstructorParamsForImplementation(args: {
|
|
226
290
|
chain: Chain;
|
227
291
|
client: ThirdwebClient;
|
228
292
|
contractId: string;
|
293
|
+
defaultExtensions?: DynamicContractExtension[];
|
229
294
|
}) {
|
230
295
|
const { chain, client } = args;
|
231
296
|
const isZkSync = await isZkSyncChain(chain);
|
@@ -251,8 +316,81 @@ export async function getAllDefaultConstructorParamsForImplementation(args: {
|
|
251
316
|
contractId: "WETH9",
|
252
317
|
}),
|
253
318
|
]);
|
319
|
+
|
320
|
+
const defaultExtensionInput = args.defaultExtensions
|
321
|
+
? await generateExtensionInput({
|
322
|
+
defaultExtensions: args.defaultExtensions,
|
323
|
+
chain,
|
324
|
+
client,
|
325
|
+
forwarder,
|
326
|
+
nativeTokenWrapper: weth,
|
327
|
+
})
|
328
|
+
: [];
|
329
|
+
|
254
330
|
return {
|
255
331
|
trustedForwarder: forwarder,
|
256
332
|
nativeTokenWrapper: weth,
|
333
|
+
extensions: defaultExtensionInput,
|
257
334
|
};
|
258
335
|
}
|
336
|
+
|
337
|
+
async function generateExtensionInput(args: {
|
338
|
+
defaultExtensions: DynamicContractExtension[];
|
339
|
+
chain: Chain;
|
340
|
+
client: ThirdwebClient;
|
341
|
+
forwarder: string;
|
342
|
+
nativeTokenWrapper: string;
|
343
|
+
}) {
|
344
|
+
const { defaultExtensions, chain, client, forwarder, nativeTokenWrapper } =
|
345
|
+
args;
|
346
|
+
|
347
|
+
const deployedExtensions = await Promise.all(
|
348
|
+
defaultExtensions.map((e) =>
|
349
|
+
getDeployedInfraContract({
|
350
|
+
chain,
|
351
|
+
client,
|
352
|
+
contractId: e.extensionName,
|
353
|
+
publisher: e.publisherAddress,
|
354
|
+
version: e.extensionVersion || "latest",
|
355
|
+
constructorParams: { forwarder, nativeTokenWrapper },
|
356
|
+
}).then((c) => ({
|
357
|
+
name: e.extensionName,
|
358
|
+
metadataURI: "",
|
359
|
+
implementation: c,
|
360
|
+
})),
|
361
|
+
),
|
362
|
+
);
|
363
|
+
|
364
|
+
const extensionInput = await Promise.all(
|
365
|
+
deployedExtensions.map(async (e) => {
|
366
|
+
if (!e.implementation) {
|
367
|
+
throw new Error("Extension not deployed");
|
368
|
+
}
|
369
|
+
return resolveContractAbi(e.implementation)
|
370
|
+
.then(generateExtensionFunctionsFromAbi)
|
371
|
+
.then((c) => ({
|
372
|
+
metadata: {
|
373
|
+
...e,
|
374
|
+
implementation: e.implementation?.address,
|
375
|
+
},
|
376
|
+
functions: c,
|
377
|
+
}));
|
378
|
+
}),
|
379
|
+
);
|
380
|
+
|
381
|
+
return extensionInput;
|
382
|
+
}
|
383
|
+
|
384
|
+
export function generateExtensionFunctionsFromAbi(abi: Abi): Array<{
|
385
|
+
functionSelector: string;
|
386
|
+
functionSignature: string;
|
387
|
+
}> {
|
388
|
+
const functions = abi.filter(
|
389
|
+
(item) => item.type === "function" && !item.name.startsWith("_"),
|
390
|
+
) as AbiFunction[];
|
391
|
+
|
392
|
+
return functions.map((fn) => ({
|
393
|
+
functionSelector: toFunctionSelector(fn),
|
394
|
+
functionSignature: toFunctionSignature(fn),
|
395
|
+
}));
|
396
|
+
}
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.93.
|
1
|
+
export const version = "5.93.5-nightly-b51157c0ff17e9535029fc8790cfa8538d1c995f-20250326000337";
|