thirdweb 0.2.8 → 0.3.1
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/README.md +5 -96
- package/dist/cli/index.js +5 -5
- package/dist/cli/index.js.map +1 -1
- package/package.json +8 -3
- package/src/cli/index.ts +17 -15
- package/src/common/error.ts +1 -191
- package/src/core/builder/brownie.ts +66 -0
- package/src/core/builder/build.ts +21 -1
- package/src/core/builder/builder-base.ts +14 -7
- package/src/core/builder/foundry.ts +4 -10
- package/src/core/builder/hardhat.ts +9 -14
- package/src/core/builder/truffle.ts +65 -0
- package/src/core/detection/brownie.ts +13 -0
- package/src/core/detection/detect.ts +36 -6
- package/src/core/detection/detector.ts +1 -1
- package/src/core/detection/foundry.ts +2 -2
- package/src/core/detection/hardhat.ts +2 -2
- package/src/core/detection/truffle.ts +13 -0
- package/src/core/helpers/storage.ts +3 -3
- package/src/core/interfaces/IStorage.ts +4 -4
- package/src/core/storage/ipfs-storage.ts +21 -15
- package/src/core/types/ProjectType.ts +6 -1
@@ -43,7 +43,7 @@ export interface IStorage {
|
|
43
43
|
upload(
|
44
44
|
data: string | FileOrBuffer,
|
45
45
|
contractAddress?: string,
|
46
|
-
signerAddress?: string
|
46
|
+
signerAddress?: string,
|
47
47
|
): Promise<string>;
|
48
48
|
|
49
49
|
/**
|
@@ -60,7 +60,7 @@ export interface IStorage {
|
|
60
60
|
files: (string | FileOrBuffer)[],
|
61
61
|
fileStartNumber?: number,
|
62
62
|
contractAddress?: string,
|
63
|
-
signerAddress?: string
|
63
|
+
signerAddress?: string,
|
64
64
|
): Promise<UploadMetadataBatchResult>;
|
65
65
|
|
66
66
|
/**
|
@@ -75,7 +75,7 @@ export interface IStorage {
|
|
75
75
|
uploadMetadata(
|
76
76
|
metadata: JsonObject,
|
77
77
|
contractAddress?: string,
|
78
|
-
signerAddress?: string
|
78
|
+
signerAddress?: string,
|
79
79
|
): Promise<string>;
|
80
80
|
|
81
81
|
/**
|
@@ -91,6 +91,6 @@ export interface IStorage {
|
|
91
91
|
metadatas: JsonObject[],
|
92
92
|
fileStartNumber?: number,
|
93
93
|
contractAddress?: string,
|
94
|
-
signerAddress?: string
|
94
|
+
signerAddress?: string,
|
95
95
|
): Promise<UploadMetadataBatchResult>;
|
96
96
|
}
|
@@ -8,14 +8,17 @@ import {
|
|
8
8
|
PINATA_IPFS_URL,
|
9
9
|
TW_IPFS_SERVER_URL,
|
10
10
|
} from "../../constants/urls";
|
11
|
-
import { IStorage } from "../interfaces/IStorage";
|
12
|
-
import { FileOrBuffer, JsonObject } from "../types";
|
13
11
|
import {
|
14
12
|
replaceFilePropertiesWithHashes,
|
15
13
|
replaceHashWithGatewayUrl,
|
16
14
|
resolveGatewayUrl,
|
17
15
|
} from "../helpers/storage";
|
16
|
+
import { IStorage } from "../interfaces/IStorage";
|
17
|
+
import { FileOrBuffer, JsonObject } from "../types";
|
18
18
|
|
19
|
+
const orig = process.emitWarning;
|
20
|
+
//suppress warnings whule we require a bunch of stuff
|
21
|
+
process.emitWarning = () => {};
|
19
22
|
require("isomorphic-fetch");
|
20
23
|
|
21
24
|
if (!globalThis.FormData) {
|
@@ -28,6 +31,9 @@ if (!globalThis.File) {
|
|
28
31
|
globalThis.File = require("@web-std/file").File;
|
29
32
|
}
|
30
33
|
|
34
|
+
//re-enable warnings
|
35
|
+
process.emitWarning = orig;
|
36
|
+
|
31
37
|
/**
|
32
38
|
* @internal
|
33
39
|
*/
|
@@ -56,13 +62,13 @@ export class IpfsStorage implements IStorage {
|
|
56
62
|
public async upload(
|
57
63
|
data: string | FileOrBuffer,
|
58
64
|
contractAddress?: string,
|
59
|
-
signerAddress?: string
|
65
|
+
signerAddress?: string,
|
60
66
|
): Promise<string> {
|
61
67
|
const cid = await this.uploadBatch(
|
62
68
|
[data],
|
63
69
|
0,
|
64
70
|
contractAddress,
|
65
|
-
signerAddress
|
71
|
+
signerAddress,
|
66
72
|
);
|
67
73
|
return `${cid}0`;
|
68
74
|
}
|
@@ -74,13 +80,13 @@ export class IpfsStorage implements IStorage {
|
|
74
80
|
files: (string | FileOrBuffer)[],
|
75
81
|
fileStartNumber = 0,
|
76
82
|
contractAddress?: string,
|
77
|
-
signerAddress?: string
|
83
|
+
signerAddress?: string,
|
78
84
|
) {
|
79
85
|
const { cid, fileNames } = await this.uploadBatchWithCid(
|
80
86
|
files,
|
81
87
|
fileStartNumber,
|
82
88
|
contractAddress,
|
83
|
-
signerAddress
|
89
|
+
signerAddress,
|
84
90
|
);
|
85
91
|
|
86
92
|
const baseUri = `ipfs://${cid}/`;
|
@@ -125,14 +131,14 @@ export class IpfsStorage implements IStorage {
|
|
125
131
|
public async uploadMetadata(
|
126
132
|
metadata: JsonObject,
|
127
133
|
contractAddress?: string,
|
128
|
-
signerAddress?: string
|
134
|
+
signerAddress?: string,
|
129
135
|
): Promise<string> {
|
130
136
|
// since there's only single object, always use the first index
|
131
137
|
const { metadataUris } = await this.uploadMetadataBatch(
|
132
138
|
[metadata],
|
133
139
|
0,
|
134
140
|
contractAddress,
|
135
|
-
signerAddress
|
141
|
+
signerAddress,
|
136
142
|
);
|
137
143
|
return metadataUris[0];
|
138
144
|
}
|
@@ -144,17 +150,17 @@ export class IpfsStorage implements IStorage {
|
|
144
150
|
metadatas: JsonObject[],
|
145
151
|
fileStartNumber?: number,
|
146
152
|
contractAddress?: string,
|
147
|
-
signerAddress?: string
|
153
|
+
signerAddress?: string,
|
148
154
|
) {
|
149
155
|
const metadataToUpload = (await this.batchUploadProperties(metadatas)).map(
|
150
|
-
(m: any) => JSON.stringify(m)
|
156
|
+
(m: any) => JSON.stringify(m),
|
151
157
|
);
|
152
158
|
|
153
159
|
const { cid, fileNames } = await this.uploadBatchWithCid(
|
154
160
|
metadataToUpload,
|
155
161
|
fileStartNumber,
|
156
162
|
contractAddress,
|
157
|
-
signerAddress
|
163
|
+
signerAddress,
|
158
164
|
);
|
159
165
|
|
160
166
|
const baseUri = `ipfs://${cid}/`;
|
@@ -195,7 +201,7 @@ export class IpfsStorage implements IStorage {
|
|
195
201
|
*/
|
196
202
|
private async batchUploadProperties(metadatas: JsonObject[]) {
|
197
203
|
const filesToUpload = metadatas.flatMap((m) =>
|
198
|
-
this.buildFilePropertiesMap(m, [])
|
204
|
+
this.buildFilePropertiesMap(m, []),
|
199
205
|
);
|
200
206
|
if (filesToUpload.length === 0) {
|
201
207
|
return metadatas;
|
@@ -210,7 +216,7 @@ export class IpfsStorage implements IStorage {
|
|
210
216
|
|
211
217
|
const finalMetadata = await replaceFilePropertiesWithHashes(
|
212
218
|
metadatas,
|
213
|
-
cids
|
219
|
+
cids,
|
214
220
|
);
|
215
221
|
return finalMetadata;
|
216
222
|
}
|
@@ -225,7 +231,7 @@ export class IpfsStorage implements IStorage {
|
|
225
231
|
*/
|
226
232
|
private buildFilePropertiesMap(
|
227
233
|
object: JsonObject,
|
228
|
-
files: (File | Buffer)[] = []
|
234
|
+
files: (File | Buffer)[] = [],
|
229
235
|
): (File | Buffer)[] {
|
230
236
|
if (Array.isArray(object)) {
|
231
237
|
object.forEach((element) => {
|
@@ -248,7 +254,7 @@ export class IpfsStorage implements IStorage {
|
|
248
254
|
files: (string | FileOrBuffer)[],
|
249
255
|
fileStartNumber = 0,
|
250
256
|
contractAddress?: string,
|
251
|
-
signerAddress?: string
|
257
|
+
signerAddress?: string,
|
252
258
|
): Promise<CidWithFileName> {
|
253
259
|
const token = await this.getUploadToken(contractAddress || "");
|
254
260
|
const metadata = {
|