Skip to content

Commit af93bb8

Browse files
committed
Marketplace Extensions
1 parent 179904c commit af93bb8

File tree

7 files changed

+762
-2
lines changed

7 files changed

+762
-2
lines changed

Thirdweb.Console/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
#endregion
7676

77-
// #region AA ZkSync
77+
#region AA ZkSync
7878

7979
// var zkSmartWallet = await SmartWallet.Create(personalWallet: privateKeyWallet, chainId: 4654, gasless: true);
8080

@@ -89,7 +89,7 @@
8989

9090
// Console.WriteLine($"Transaction hash: {hash}");
9191

92-
// #endregion
92+
#endregion
9393

9494
#region Ecosystem Wallet
9595

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Numerics;
2+
3+
namespace Thirdweb.Tests.Extensions;
4+
5+
public class MarketplaceExtensionsTests : BaseTests
6+
{
7+
private readonly string _marketplaceContractAddress = "0xc9671F631E8313D53ec0b5358e1a499c574fCe6A";
8+
9+
private readonly BigInteger _chainId = 421614;
10+
11+
public MarketplaceExtensionsTests(ITestOutputHelper output)
12+
: base(output) { }
13+
14+
private async Task<IThirdwebWallet> GetSmartWallet()
15+
{
16+
var privateKeyWallet = await PrivateKeyWallet.Generate(this.Client);
17+
return await SmartWallet.Create(personalWallet: privateKeyWallet, chainId: 421614);
18+
}
19+
20+
private async Task<ThirdwebContract> GetMarketplaceContract()
21+
{
22+
return await ThirdwebContract.Create(this.Client, this._marketplaceContractAddress, this._chainId);
23+
}
24+
25+
#region IDirectListings
26+
27+
#endregion
28+
29+
#region IEnglishAuctions
30+
31+
#endregion
32+
33+
#region IOffers
34+
35+
#endregion
36+
}

Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ public static class ThirdwebExtensions
99
{
1010
#region Common
1111

12+
public static async Task<bool> SupportsInterface(this ThirdwebContract contract, string interfaceId)
13+
{
14+
if (contract == null)
15+
{
16+
throw new ArgumentNullException(nameof(contract));
17+
}
18+
19+
return await ThirdwebContract.Read<bool>(contract, "supportsInterface", interfaceId);
20+
}
21+
1222
/// <summary>
1323
/// Reads data from the contract using the specified method.
1424
/// </summary>
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
using System.Numerics;
2+
using Nethereum.ABI.FunctionEncoding.Attributes;
3+
4+
namespace Thirdweb;
5+
6+
#region Common
7+
8+
public enum TokenType : byte
9+
{
10+
ERC721 = 0,
11+
ERC1155 = 1,
12+
ERC20 = 2
13+
}
14+
15+
public enum Status : byte
16+
{
17+
UNSET = 0,
18+
CREATED = 1,
19+
COMPLETED = 2,
20+
CANCELLED = 3
21+
}
22+
23+
#endregion
24+
25+
#region IDirectListings
26+
27+
[Struct("ListingParameters")]
28+
public class ListingParameters
29+
{
30+
[Parameter("address", "assetContract", 1)]
31+
public string AssetContract { get; set; }
32+
33+
[Parameter("uint256", "tokenId", 2)]
34+
public BigInteger TokenId { get; set; }
35+
36+
[Parameter("uint256", "quantity", 3)]
37+
public BigInteger Quantity { get; set; }
38+
39+
[Parameter("address", "currency", 4)]
40+
public string Currency { get; set; }
41+
42+
[Parameter("uint256", "pricePerToken", 5)]
43+
public BigInteger PricePerToken { get; set; }
44+
45+
[Parameter("uint128", "startTimestamp", 6)]
46+
public BigInteger StartTimestamp { get; set; }
47+
48+
[Parameter("uint128", "endTimestamp", 7)]
49+
public BigInteger EndTimestamp { get; set; }
50+
51+
[Parameter("bool", "reserved", 8)]
52+
public bool Reserved { get; set; }
53+
}
54+
55+
[Struct("Listing")]
56+
public class Listing
57+
{
58+
[Parameter("uint256", "listingId", 1)]
59+
public BigInteger ListingId { get; set; }
60+
61+
[Parameter("uint256", "tokenId", 2)]
62+
public BigInteger TokenId { get; set; }
63+
64+
[Parameter("uint256", "quantity", 3)]
65+
public BigInteger Quantity { get; set; }
66+
67+
[Parameter("uint256", "pricePerToken", 4)]
68+
public BigInteger PricePerToken { get; set; }
69+
70+
[Parameter("uint128", "startTimestamp", 5)]
71+
public BigInteger StartTimestamp { get; set; }
72+
73+
[Parameter("uint128", "endTimestamp", 6)]
74+
public BigInteger EndTimestamp { get; set; }
75+
76+
[Parameter("address", "listingCreator", 7)]
77+
public string ListingCreator { get; set; }
78+
79+
[Parameter("address", "assetContract", 8)]
80+
public string AssetContract { get; set; }
81+
82+
[Parameter("address", "currency", 9)]
83+
public string Currency { get; set; }
84+
85+
[Parameter("uint8", "tokenType", 10)]
86+
public TokenType TokenTypeEnum { get; set; }
87+
88+
[Parameter("uint8", "status", 11)]
89+
public Status StatusEnum { get; set; }
90+
91+
[Parameter("bool", "reserved", 12)]
92+
public bool Reserved { get; set; }
93+
}
94+
95+
#endregion
96+
97+
#region IEnglishAuctions
98+
99+
[Struct("AuctionParameters")]
100+
public class AuctionParameters
101+
{
102+
[Parameter("address", "assetContract", 1)]
103+
public string AssetContract { get; set; }
104+
105+
[Parameter("uint256", "tokenId", 2)]
106+
public BigInteger TokenId { get; set; }
107+
108+
[Parameter("uint256", "quantity", 3)]
109+
public BigInteger Quantity { get; set; }
110+
111+
[Parameter("address", "currency", 4)]
112+
public string Currency { get; set; }
113+
114+
[Parameter("uint256", "minimumBidAmount", 5)]
115+
public BigInteger MinimumBidAmount { get; set; }
116+
117+
[Parameter("uint256", "buyoutBidAmount", 6)]
118+
public BigInteger BuyoutBidAmount { get; set; }
119+
120+
[Parameter("uint64", "timeBufferInSeconds", 7)]
121+
public ulong TimeBufferInSeconds { get; set; }
122+
123+
[Parameter("uint64", "bidBufferBps", 8)]
124+
public ulong BidBufferBps { get; set; }
125+
126+
[Parameter("uint64", "startTimestamp", 9)]
127+
public ulong StartTimestamp { get; set; }
128+
129+
[Parameter("uint64", "endTimestamp", 10)]
130+
public ulong EndTimestamp { get; set; }
131+
}
132+
133+
[Struct("Auction")]
134+
public class Auction
135+
{
136+
[Parameter("uint256", "auctionId", 1)]
137+
public BigInteger AuctionId { get; set; }
138+
139+
[Parameter("uint256", "tokenId", 2)]
140+
public BigInteger TokenId { get; set; }
141+
142+
[Parameter("uint256", "quantity", 3)]
143+
public BigInteger Quantity { get; set; }
144+
145+
[Parameter("uint256", "minimumBidAmount", 4)]
146+
public BigInteger MinimumBidAmount { get; set; }
147+
148+
[Parameter("uint256", "buyoutBidAmount", 5)]
149+
public BigInteger BuyoutBidAmount { get; set; }
150+
151+
[Parameter("uint64", "timeBufferInSeconds", 6)]
152+
public ulong TimeBufferInSeconds { get; set; }
153+
154+
[Parameter("uint64", "bidBufferBps", 7)]
155+
public ulong BidBufferBps { get; set; }
156+
157+
[Parameter("uint64", "startTimestamp", 8)]
158+
public ulong StartTimestamp { get; set; }
159+
160+
[Parameter("uint64", "endTimestamp", 9)]
161+
public ulong EndTimestamp { get; set; }
162+
163+
[Parameter("address", "auctionCreator", 10)]
164+
public string AuctionCreator { get; set; }
165+
166+
[Parameter("address", "assetContract", 11)]
167+
public string AssetContract { get; set; }
168+
169+
[Parameter("address", "currency", 12)]
170+
public string Currency { get; set; }
171+
172+
[Parameter("uint8", "tokenType", 13)]
173+
public TokenType TokenTypeEnum { get; set; }
174+
175+
[Parameter("uint8", "status", 14)]
176+
public Status StatusEnum { get; set; }
177+
}
178+
179+
[Struct("Bid")]
180+
public class Bid
181+
{
182+
[Parameter("uint256", "auctionId", 1)]
183+
public BigInteger AuctionId { get; set; }
184+
185+
[Parameter("address", "bidder", 2)]
186+
public string Bidder { get; set; }
187+
188+
[Parameter("uint256", "bidAmount", 3)]
189+
public BigInteger BidAmount { get; set; }
190+
}
191+
192+
[Struct("AuctionPayoutStatus")]
193+
public class AuctionPayoutStatus
194+
{
195+
[Parameter("bool", "paidOutAuctionTokens", 1)]
196+
public bool PaidOutAuctionTokens { get; set; }
197+
198+
[Parameter("bool", "paidOutBidAmount", 2)]
199+
public bool PaidOutBidAmount { get; set; }
200+
}
201+
202+
#endregion
203+
204+
#region IOffers
205+
206+
[Struct("OfferParams")]
207+
public class OfferParams
208+
{
209+
[Parameter("address", "assetContract", 1)]
210+
public string AssetContract { get; set; }
211+
212+
[Parameter("uint256", "tokenId", 2)]
213+
public BigInteger TokenId { get; set; }
214+
215+
[Parameter("uint256", "quantity", 3)]
216+
public BigInteger Quantity { get; set; }
217+
218+
[Parameter("address", "currency", 4)]
219+
public string Currency { get; set; }
220+
221+
[Parameter("uint256", "totalPrice", 5)]
222+
public BigInteger TotalPrice { get; set; }
223+
224+
[Parameter("uint256", "expirationTimestamp", 6)]
225+
public BigInteger ExpirationTimestamp { get; set; }
226+
}
227+
228+
[Struct("Offer")]
229+
public class Offer
230+
{
231+
[Parameter("uint256", "offerId", 1)]
232+
public BigInteger OfferId { get; set; }
233+
234+
[Parameter("uint256", "tokenId", 2)]
235+
public BigInteger TokenId { get; set; }
236+
237+
[Parameter("uint256", "quantity", 3)]
238+
public BigInteger Quantity { get; set; }
239+
240+
[Parameter("uint256", "totalPrice", 4)]
241+
public BigInteger TotalPrice { get; set; }
242+
243+
[Parameter("uint256", "expirationTimestamp", 5)]
244+
public BigInteger ExpirationTimestamp { get; set; }
245+
246+
[Parameter("address", "offeror", 6)]
247+
public string Offeror { get; set; }
248+
249+
[Parameter("address", "assetContract", 7)]
250+
public string AssetContract { get; set; }
251+
252+
[Parameter("address", "currency", 8)]
253+
public string Currency { get; set; }
254+
255+
[Parameter("uint8", "tokenType", 9)]
256+
public TokenType TokenTypeEnum { get; set; }
257+
258+
[Parameter("uint8", "status", 10)]
259+
public Status StatusEnum { get; set; }
260+
}
261+
262+
#endregion

0 commit comments

Comments
 (0)