Skip to content

Commit 5b2f09a

Browse files
authored
ToString overrides on ALL types (#12)
1 parent 8d477f6 commit 5b2f09a

File tree

1 file changed

+225
-0
lines changed

1 file changed

+225
-0
lines changed

Assets/Thirdweb/Scripts/Types.cs

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,37 @@ public struct NFTMetadata
1515
public string name;
1616
public string external_url;
1717
public Dictionary<string, object> properties;
18+
19+
public override string ToString()
20+
{
21+
string propertiesStr = "";
22+
foreach (var property in properties)
23+
propertiesStr = $"\n>>key: {property.Key.ToString()} // value: {property.Value.ToString()}";
24+
return
25+
$"NFTMetadata:"
26+
+ $"\n>id: {id}"
27+
+ $"\n>uri: {uri}"
28+
+ $"\n>description: {description}"
29+
+ $"\n>image: {image}"
30+
+ $"\n>name: {name}"
31+
+ $"\n>external_url: {external_url}"
32+
+ $"\n>properties: {propertiesStr}";
33+
}
1834
}
1935

2036
[System.Serializable]
2137
public struct NFTMetadataWithSupply
2238
{
2339
public NFTMetadata metadata;
2440
public int supply;
41+
42+
public override string ToString()
43+
{
44+
return
45+
$"NFTMetadataWithSupply:"
46+
+ $"\n>>>>>\n{metadata.ToString()}\n<<<<<\n"
47+
+ $"\n>supply: {supply}";
48+
}
2549
}
2650

2751
[System.Serializable]
@@ -32,6 +56,17 @@ public struct NFT
3256
public string type;
3357
public int supply;
3458
public int quantityOwned; // only for ERC1155.GetOwned()
59+
60+
public override string ToString()
61+
{
62+
return
63+
$"NFT:"
64+
+ $"\n>>>>>\n{metadata.ToString()}\n<<<<<\n"
65+
+ $"\n>owner: {owner}"
66+
+ $"\n>type: {type}"
67+
+ $"\n>supply: {supply}"
68+
+ $"\n>quantityOwned: {quantityOwned}";
69+
}
3570
}
3671

3772
// Tokens
@@ -42,6 +77,15 @@ public struct Currency
4277
public string name;
4378
public string symbol;
4479
public string decimals;
80+
81+
public override string ToString()
82+
{
83+
return
84+
$"Currency:"
85+
+ $"\n>name: {name}"
86+
+ $"\n>symbol: {symbol}"
87+
+ $"\n>decimals: {decimals}";
88+
}
4589
}
4690

4791
[System.Serializable]
@@ -52,6 +96,17 @@ public struct CurrencyValue
5296
public string decimals;
5397
public string value;
5498
public string displayValue;
99+
100+
public override string ToString()
101+
{
102+
return
103+
$"CurrencyValue:"
104+
+ $"\n>name: {name}"
105+
+ $"\n>symbol: {symbol}"
106+
+ $"\n>decimals: {decimals}"
107+
+ $"\n>value: {value}"
108+
+ $"\n>displayValue: {displayValue}";
109+
}
55110
}
56111

57112
// Marketplace
@@ -69,13 +124,38 @@ public class Listing
69124
public string buyoutPrice;
70125
public CurrencyValue buyoutCurrencyValuePerToken;
71126
public int type;
127+
128+
public override string ToString()
129+
{
130+
return
131+
$"Listing:"
132+
+ $"\n>id: {id}"
133+
+ $"\n>sellerAddress: {sellerAddress}"
134+
+ $"\n>assetContractAddress: {assetContractAddress}"
135+
+ $"\n>tokenId: {tokenId}"
136+
+ $"\n>>>>>\n{asset.ToString()}\n<<<<<\n"
137+
+ $"\n>quantity: {quantity}"
138+
+ $"\n>currencyContractAddress: {currencyContractAddress}"
139+
+ $"\n>buyoutPrice: {buyoutPrice}"
140+
+ $"\n>>>>>\n{buyoutCurrencyValuePerToken.ToString()}\n<<<<<\n"
141+
+ $"\n>type: {type}";
142+
}
72143
}
73144

74145
[System.Serializable]
75146
public class DirectListing : Listing
76147
{
77148
public string startTimeInSeconds;
78149
public string secondsUntilEnd;
150+
151+
public override string ToString()
152+
{
153+
return
154+
$"DirectListing:"
155+
+ $"\n>>>>>\n{base.ToString()}\n<<<<<\n"
156+
+ $"\n>startTimeInSeconds: {startTimeInSeconds}"
157+
+ $"\n>secondsUntilEnd: {secondsUntilEnd}";
158+
}
79159
}
80160

81161
[System.Serializable]
@@ -85,6 +165,17 @@ public class AuctionListing : Listing
85165
public string endTimeInEpochSeconds;
86166
public string reservePrice;
87167
public CurrencyValue reservePriceCurrencyValuePerToken;
168+
169+
public override string ToString()
170+
{
171+
return
172+
$"AuctionListing:"
173+
+ $"\n>>>>>\n{base.ToString()}\n<<<<<\n"
174+
+ $"\n>startTimeInEpochSeconds: {startTimeInEpochSeconds}"
175+
+ $"\n>endTimeInEpochSeconds: {endTimeInEpochSeconds}"
176+
+ $"\n>reservePrice: {reservePrice}"
177+
+ $"\n>>>>>\n{reservePriceCurrencyValuePerToken.ToString()}\n<<<<<\n";
178+
}
88179
}
89180

90181
[System.Serializable]
@@ -99,6 +190,21 @@ public abstract class NewListing
99190
public string currencyContractAddress;
100191
public string reservePricePerToken;
101192
public string buyoutPricePerToken;
193+
194+
public override string ToString()
195+
{
196+
return
197+
$"NewListing:"
198+
+ $"\n>type: {type}"
199+
+ $"\n>assetContractAddress: {assetContractAddress}"
200+
+ $"\n>tokenId: {tokenId}"
201+
+ $"\n>startTimestamp: {startTimestamp}"
202+
+ $"\n>listingDurationInSeconds: {listingDurationInSeconds}"
203+
+ $"\n>quantity: {quantity}"
204+
+ $"\n>currencyContractAddress: {currencyContractAddress}"
205+
+ $"\n>reservePricePerToken: {reservePricePerToken}"
206+
+ $"\n>buyoutPricePerToken: {buyoutPricePerToken}";
207+
}
102208
}
103209

104210
[System.Serializable]
@@ -110,6 +216,14 @@ public NewAuctionListing()
110216
{
111217
this.type = "NewAuctionListing";
112218
}
219+
220+
public override string ToString()
221+
{
222+
return
223+
$"NewAuctionListing:"
224+
+ $"\n>>>>>\n{base.ToString()}\n<<<<<\n"
225+
+ $"\n>reservePricePerToken: {reservePricePerToken}";
226+
}
113227
}
114228

115229
[System.Serializable]
@@ -119,6 +233,13 @@ public NewDirectListing()
119233
{
120234
this.type = "NewDirectListing";
121235
}
236+
237+
public override string ToString()
238+
{
239+
return
240+
$"NewDirectListing:"
241+
+ $"\n>>>>>\n{base.ToString()}\n<<<<<\n";
242+
}
122243
}
123244

124245
[System.Serializable]
@@ -130,13 +251,33 @@ public struct Offer
130251
public string pricePerToken;
131252
public CurrencyValue currencyValue;
132253
public string currencyContractAddress;
254+
255+
public override string ToString()
256+
{
257+
return
258+
$"Offer:"
259+
+ $"\n>listingId: {listingId}"
260+
+ $"\n>buyerAddress: {buyerAddress}"
261+
+ $"\n>quantityDesired: {quantityDesired}"
262+
+ $"\n>pricePerToken: {pricePerToken}"
263+
+ $"\n>>>>>\n{currencyValue.ToString()}\n<<<<<\n"
264+
+ $"\n>currencyContractAddress: {currencyContractAddress}";
265+
}
133266
}
134267

135268
[System.Serializable]
136269
public class QueryAllParams
137270
{
138271
public int start;
139272
public int count;
273+
274+
public override string ToString()
275+
{
276+
return
277+
$"QueryAllParams:"
278+
+ $"\n>start: {start}"
279+
+ $"\n>count: {count}";
280+
}
140281
}
141282

142283
[System.Serializable]
@@ -145,6 +286,16 @@ public class MarketplaceFilter : QueryAllParams
145286
public string seller;
146287
public string tokenContract;
147288
public string tokenId;
289+
290+
public override string ToString()
291+
{
292+
return
293+
$"MarketplaceFilter:"
294+
+ $"\n>>>>>\n{base.ToString()}\n<<<<<\n"
295+
+ $"\n>seller: {seller}"
296+
+ $"\n>tokenContract: {tokenContract}"
297+
+ $"\n>tokenId: {tokenId}";
298+
}
148299
}
149300

150301
// Claim conditions
@@ -159,6 +310,19 @@ public class ClaimConditions
159310
public string maxClaimableSupply;
160311
public string maxClaimablePerWallet;
161312
public string waitInSeconds;
313+
314+
public override string ToString()
315+
{
316+
return
317+
$"ClaimConditions:"
318+
+ $"\n>availableSupply: {availableSupply}"
319+
+ $"\n>currentMintSupply: {currentMintSupply}"
320+
+ $"\n>>>>>\n{currencyMetadata.ToString()}\n<<<<<\n"
321+
+ $"\n>currencyAddress: {currencyAddress}"
322+
+ $"\n>maxClaimableSupply: {maxClaimableSupply}"
323+
+ $"\n>maxClaimablePerWallet: {maxClaimablePerWallet}"
324+
+ $"\n>waitInSeconds: {waitInSeconds}";
325+
}
162326
}
163327

164328
[System.Serializable]
@@ -168,6 +332,16 @@ public class SnapshotEntry
168332
public string maxClaimable;
169333
public string price;
170334
public string currencyAddress;
335+
336+
public override string ToString()
337+
{
338+
return
339+
$"SnapshotEntry:"
340+
+ $"\n>address: {address}"
341+
+ $"\n>maxClaimable: {maxClaimable}"
342+
+ $"\n>price: {price}"
343+
+ $"\n>currencyAddress: {currencyAddress}";
344+
}
171345
}
172346

173347
// Transactions
@@ -181,6 +355,18 @@ public struct Receipt
181355
public string gasUsed;
182356
public string blockHash;
183357
public string transactionHash;
358+
359+
public override string ToString()
360+
{
361+
return
362+
$"Receipt:"
363+
+ $"\n>from: {from}"
364+
+ $"\n>to: {to}"
365+
+ $"\n>transactionIndex: {transactionIndex}"
366+
+ $"\n>gasUsed: {gasUsed}"
367+
+ $"\n>blockHash: {blockHash}"
368+
+ $"\n>transactionHash: {transactionHash}";
369+
}
184370
}
185371

186372
[System.Serializable]
@@ -193,6 +379,14 @@ public bool isSuccessful()
193379
{
194380
return receipt.transactionHash != null;
195381
}
382+
383+
public override string ToString()
384+
{
385+
return
386+
$"TransactionResult:"
387+
+ $"\n{receipt.ToString()}"
388+
+ $"\n>id: {id}";
389+
}
196390
}
197391

198392
[System.Serializable]
@@ -204,13 +398,33 @@ public struct TransactionRequest
204398
public string value;
205399
public string gasLimit;
206400
public string gasPrice;
401+
402+
public override string ToString()
403+
{
404+
return
405+
$"TransactionRequest:"
406+
+ $"\n>from: {from}"
407+
+ $"\n>to: {to}"
408+
+ $"\n>data: {data}"
409+
+ $"\n>value: {value}"
410+
+ $"\n>gasLimit: {gasLimit}"
411+
+ $"\n>gasPrice: {gasPrice}";
412+
}
207413
}
208414

209415
[System.Serializable]
210416
public struct LoginPayload
211417
{
212418
public LoginPayloadData payload;
213419
public string signature;
420+
421+
public override string ToString()
422+
{
423+
return
424+
$"LoginPayloadData:"
425+
+ $"\n>>>>>\n{payload.ToString()}\n<<<<<\n"
426+
+ $"\n>signature: {signature}";
427+
}
214428
}
215429

216430
[System.Serializable]
@@ -221,5 +435,16 @@ public struct LoginPayloadData
221435
public string nonce;
222436
public string expiration_time;
223437
public string chain_id;
438+
439+
public override string ToString()
440+
{
441+
return
442+
$"LoginPayloadData:"
443+
+ $"\n>domain: {domain}"
444+
+ $"\n>address: {address}"
445+
+ $"\n>nonce: {nonce}"
446+
+ $"\n>expiration_time: {expiration_time}"
447+
+ $"\n>chain_id: {chain_id}";
448+
}
224449
}
225450
}

0 commit comments

Comments
 (0)