@@ -7,11 +7,8 @@ namespace Thirdweb
7
7
/// <summary>
8
8
/// Interact with any ERC1155 compatible contract.
9
9
/// </summary>
10
- public class ERC1155
10
+ public class ERC1155 : Routable
11
11
{
12
- public string chain ;
13
- public string address ;
14
- public string abi ;
15
12
/// <summary>
16
13
/// Handle signature minting functionality
17
14
/// </summary>
@@ -24,13 +21,10 @@ public class ERC1155
24
21
/// <summary>
25
22
/// Interact with any ERC1155 compatible contract.
26
23
/// </summary>
27
- public ERC1155 ( string chain , string address , string abi = " ")
24
+ public ERC1155 ( string parentRoute ) : base ( $ " { parentRoute } .erc1155 ")
28
25
{
29
- this . chain = chain ;
30
- this . address = address ;
31
- this . abi = abi ;
32
- this . signature = new ERC1155Signature ( chain , address , abi ) ;
33
- this . claimConditions = new ERC1155ClaimConditions ( chain , address , abi ) ;
26
+ this . signature = new ERC1155Signature ( baseRoute ) ;
27
+ this . claimConditions = new ERC1155ClaimConditions ( baseRoute ) ;
34
28
}
35
29
36
30
// READ FUNCTIONS
@@ -172,29 +166,15 @@ public async Task<TransactionResult> MintAdditionalSupplyTo(string address, stri
172
166
{
173
167
return await Bridge . InvokeRoute < TransactionResult > ( getRoute ( "mintAdditionalSupplyTo" ) , Utils . ToJsonStringArray ( address , tokenId , additionalSupply ) ) ;
174
168
}
175
-
176
- // PRIVATE
177
-
178
- private string getRoute ( string functionPath )
179
- {
180
- return abi != "" ? this . address + "#" + abi + ".erc1155." + functionPath : this . address + ".erc1155." + functionPath ;
181
- }
182
169
}
183
170
184
171
/// <summary>
185
172
/// Fetch claim conditions for a given ERC1155 drop contract
186
173
/// </summary>
187
- public class ERC1155ClaimConditions
174
+ public class ERC1155ClaimConditions : Routable
188
175
{
189
- public string chain ;
190
- public string address ;
191
- public string abi ;
192
-
193
- public ERC1155ClaimConditions ( string chain , string address , string abi = "" )
176
+ public ERC1155ClaimConditions ( string parentRoute ) : base ( $ "{ parentRoute } .claimConditions")
194
177
{
195
- this . chain = chain ;
196
- this . address = address ;
197
- this . abi = abi ;
198
178
}
199
179
200
180
/// <summary>
@@ -228,16 +208,11 @@ public async Task<bool> GetClaimerProofs(string tokenId, string claimerAddress)
228
208
{
229
209
return await Bridge . InvokeRoute < bool > ( getRoute ( "getClaimerProofs" ) , Utils . ToJsonStringArray ( claimerAddress ) ) ;
230
210
}
231
-
232
- private string getRoute ( string functionPath )
233
- {
234
- return abi != "" ? this . address + "#" + abi + ".erc1155.claimConditions." + functionPath : this . address + ".erc1155.claimConditions." + functionPath ;
235
- }
236
211
}
237
212
238
213
// TODO switch to another JSON serializer that supports polymorphism
239
214
[ System . Serializable ]
240
- #nullable enable
215
+ #nullable enable
241
216
public class ERC1155MintPayload
242
217
{
243
218
public string to ;
@@ -327,19 +302,21 @@ public struct ERC1155SignedPayload
327
302
public ERC1155SignedPayloadOutput payload ;
328
303
}
329
304
330
- public class ERC1155Signature
305
+ /// <summary>
306
+ /// Generate, verify and mint signed mintable payloads
307
+ /// </summary>
308
+ public class ERC1155Signature : Routable
331
309
{
332
- public string chain ;
333
- public string address ;
334
- public string abi ;
335
-
336
- public ERC1155Signature ( string chain , string address , string abi = "" )
310
+ /// <summary>
311
+ /// Generate, verify and mint signed mintable payloads
312
+ /// </summary>
313
+ public ERC1155Signature ( string parentRoute ) : base ( $ "{ parentRoute } .signature")
337
314
{
338
- this . chain = chain ;
339
- this . address = address ;
340
- this . abi = abi ;
341
315
}
342
316
317
+ /// <summary>
318
+ /// Generate a signed mintable payload. Requires minting permission.
319
+ /// </summary>
343
320
public async Task < ERC1155SignedPayload > Generate ( ERC1155MintPayload payloadToSign )
344
321
{
345
322
return await Bridge . InvokeRoute < ERC1155SignedPayload > ( getRoute ( "generate" ) , Utils . ToJsonStringArray ( payloadToSign ) ) ;
@@ -350,19 +327,20 @@ public async Task<ERC1155SignedPayload> GenerateFromTokenId(ERC1155MintAdditiona
350
327
return await Bridge . InvokeRoute < ERC1155SignedPayload > ( getRoute ( "generateFromTokenId" ) , Utils . ToJsonStringArray ( payloadToSign ) ) ;
351
328
}
352
329
330
+ /// <summary>
331
+ /// Verify that a signed mintable payload is valid
332
+ /// </summary>
353
333
public async Task < bool > Verify ( ERC1155SignedPayload signedPayload )
354
334
{
355
335
return await Bridge . InvokeRoute < bool > ( getRoute ( "verify" ) , Utils . ToJsonStringArray ( signedPayload ) ) ;
356
336
}
357
337
338
+ /// <summary>
339
+ /// Mint a signed mintable payload
340
+ /// </summary>
358
341
public async Task < TransactionResult > Mint ( ERC1155SignedPayload signedPayload )
359
342
{
360
343
return await Bridge . InvokeRoute < TransactionResult > ( getRoute ( "mint" ) , Utils . ToJsonStringArray ( signedPayload ) ) ;
361
344
}
362
-
363
- private string getRoute ( string functionPath )
364
- {
365
- return abi != "" ? this . address + "#" + abi + ".erc1155.signature." + functionPath : this . address + ".erc1155.signature." + functionPath ;
366
- }
367
345
}
368
346
}
0 commit comments