Skip to content

Commit fc5e098

Browse files
adding XML docs
1 parent 8d21b85 commit fc5e098

File tree

4 files changed

+143
-9
lines changed

4 files changed

+143
-9
lines changed

Assets/Thirdweb/Scripts/Contract.cs

+24
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,21 @@ public class Contract
99
{
1010
public string chain;
1111
public string address;
12+
/// <summary>
13+
/// Call any ERC20 supported functions
14+
/// </summary>
1215
public ERC20 ERC20;
16+
/// <summary>
17+
/// Call any ERC721 supported functions
18+
/// </summary>
1319
public ERC721 ERC721;
20+
/// <summary>
21+
/// Call any ERC1155 supported functions
22+
/// </summary>
1423
public ERC1155 ERC1155;
24+
/// <summary>
25+
/// Call any Marketplace supported functions
26+
/// </summary>
1527
public Marketplace marketplace;
1628

1729
public Contract(string chain, string address) {
@@ -23,6 +35,12 @@ public Contract(string chain, string address) {
2335
this.marketplace = new Marketplace(chain, address);
2436
}
2537

38+
/// <summary>
39+
/// Read data from a contract
40+
/// </summary>
41+
/// <param name="functionName">The contract function name to call</param>
42+
/// <param name="args">The function arguments. Structs and Lists will get serialized automatically</param>
43+
/// <returns>The data deserialized to the given typed</returns>
2644
public async Task<T> Read<T>(string functionName, params object[] args)
2745
{
2846
string [] argsEncoded = new string[args.Length + 1];
@@ -31,6 +49,12 @@ public async Task<T> Read<T>(string functionName, params object[] args)
3149
return await Bridge.InvokeRoute<T>(getRoute("call"), argsEncoded);
3250
}
3351

52+
/// <summary>
53+
/// Execute a write transaction on a contract
54+
/// </summary>
55+
/// <param name="functionName">The contract function name to call</param>
56+
/// <param name="args">The function arguments. Structs and Lists will get serialized automatically</param>
57+
/// <returns>The transaction receipt</returns>
3458
public async Task<TransactionResult> Write(string functionName, params object[] args)
3559
{
3660
string [] argsEncoded = new string[args.Length + 1];

Assets/Thirdweb/Scripts/ERC20.cs

+54-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public class ERC20
1010
{
1111
public string chain;
1212
public string address;
13+
/// <summary>
14+
/// Handle signature minting functionality
15+
/// </summary>
1316
public ERC20Signature signature;
1417

1518
public ERC20(string chain, string address)
@@ -19,76 +22,115 @@ public ERC20(string chain, string address)
1922
this.signature = new ERC20Signature(chain, address);
2023
}
2124

22-
/// READ FUNCTIONS
25+
// READ FUNCTIONS
2326

27+
/// <summary>
28+
/// Get the currency information
29+
/// </summary>
2430
public async Task<Currency> Get()
2531
{
2632
return await Bridge.InvokeRoute<Currency>(getRoute("get"), new string[] { });
2733
}
2834

35+
/// <summary>
36+
/// Get the balance of the connected wallet
37+
/// </summary>
2938
public async Task<CurrencyValue> Balance()
3039
{
3140
return await Bridge.InvokeRoute<CurrencyValue>(getRoute("balance"), new string[] { });
3241
}
3342

43+
/// <summary>
44+
/// Get the balance of the specified wallet
45+
/// </summary>
3446
public async Task<CurrencyValue> BalanceOf(string address)
3547
{
3648
return await Bridge.InvokeRoute<CurrencyValue>(getRoute("balanceOf"), Utils.ToJsonStringArray(address));
3749
}
3850

51+
/// <summary>
52+
/// Get how much allowance the given address is allowed to spend on behalf of the connected wallet
53+
/// </summary>
3954
public async Task<string> Allowance(string spender)
4055
{
4156
return await Bridge.InvokeRoute<string>(getRoute("allowance"), Utils.ToJsonStringArray(spender));
4257
}
4358

59+
/// <summary>
60+
/// Get how much allowance the given address is allowed to spend on behalf of the specified wallet
61+
/// </summary>
4462
public async Task<string> AllowanceOf(string owner, string spender)
4563
{
4664
return await Bridge.InvokeRoute<string>(getRoute("allowanceOf"), Utils.ToJsonStringArray(owner, spender));
4765
}
4866

67+
/// <summary>
68+
/// Get the total supply in circulation
69+
/// </summary>
4970
public async Task<CurrencyValue> TotalSupply()
5071
{
5172
return await Bridge.InvokeRoute<CurrencyValue>(getRoute("totalSupply"), new string[] { });
5273
}
5374

54-
/// WRITE FUNCTIONS
75+
// WRITE FUNCTIONS
5576

77+
/// <summary>
78+
/// Set how much allowance the given address is allowed to spend on behalf of the connected wallet
79+
/// </summary>
5680
public async Task<TransactionResult> SetAllowance(string spender, bool amount)
5781
{
5882
return await Bridge.InvokeRoute<TransactionResult>(getRoute("setAllowance"), Utils.ToJsonStringArray(spender, amount));
5983
}
6084

85+
/// <summary>
86+
/// Transfer a given amount of currency to another wallet
87+
/// </summary>
6188
public async Task<TransactionResult> Transfer(string to, string amount)
6289
{
6390
return await Bridge.InvokeRoute<TransactionResult>(getRoute("transfer"), Utils.ToJsonStringArray(to, amount));
6491
}
6592

93+
/// <summary>
94+
/// Burn a given amount of currency
95+
/// </summary>
6696
public async Task<TransactionResult> Burn(string amount)
6797
{
6898
return await Bridge.InvokeRoute<TransactionResult>(getRoute("burn"), Utils.ToJsonStringArray(amount));
6999
}
70100

101+
/// <summary>
102+
/// Claim a given amount of currency for compatible drop contracts
103+
/// </summary>
71104
public async Task<TransactionResult[]> Claim(string amount)
72105
{
73106
return await Bridge.InvokeRoute<TransactionResult[]>(getRoute("claim"), Utils.ToJsonStringArray(amount));
74107
}
75108

109+
/// <summary>
110+
/// Claim a given amount of currency to a given destination wallet for compatible drop contracts
111+
/// </summary>
76112
public async Task<TransactionResult[]> ClaimTo(string address, int amount)
77113
{
78114
return await Bridge.InvokeRoute<TransactionResult[]>(getRoute("claimTo"), Utils.ToJsonStringArray(address, amount));
79115
}
80116

117+
/// <summary>
118+
/// Mint a given amount of currency
119+
/// </summary>
81120
public async Task<TransactionResult> Mint(string amount)
82121
{
83122
return await Bridge.InvokeRoute<TransactionResult>(getRoute("mint"), Utils.ToJsonStringArray(amount));
84123
}
85124

125+
/// <summary>
126+
/// Mint a given amount of currency to a given destination wallet
127+
/// </summary>
86128
public async Task<TransactionResult> MintTo(string address, string amount)
87129
{
88130
return await Bridge.InvokeRoute<TransactionResult>(getRoute("mintTo"), Utils.ToJsonStringArray(address, amount));
89131
}
90132

91-
/// PRIVATE
133+
// PRIVATE
92134

93135
private string getRoute(string functionPath) {
94136
return this.address + ".erc20." + functionPath;
@@ -153,16 +195,25 @@ public ERC20Signature(string chain, string address)
153195
this.address = address;
154196
}
155197

198+
/// <summary>
199+
/// Generate a signed mintable payload. Requires minting permission.
200+
/// </summary>
156201
public async Task<ERC20SignedPayload> Generate(ERC20MintPayload payloadToSign)
157202
{
158203
return await Bridge.InvokeRoute<ERC20SignedPayload>(getRoute("generate"), Utils.ToJsonStringArray(payloadToSign));
159204
}
160205

206+
/// <summary>
207+
/// Verify that a signed mintable payload is valid
208+
/// </summary>
161209
public async Task<bool> Verify(ERC20SignedPayload signedPayload)
162210
{
163211
return await Bridge.InvokeRoute<bool>(getRoute("verify"), Utils.ToJsonStringArray(signedPayload));
164212
}
165213

214+
/// <summary>
215+
/// Mint a signed mintable payload
216+
/// </summary>
166217
public async Task<TransactionResult> Mint(ERC20SignedPayload signedPayload)
167218
{
168219
return await Bridge.InvokeRoute<TransactionResult>(getRoute("mint"), Utils.ToJsonStringArray(signedPayload));

Assets/Thirdweb/Scripts/ThirdwebSDK.cs

+29
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ namespace Thirdweb
55
/// </summary>
66
public class ThirdwebSDK
77
{
8+
/// <summary>
9+
/// Options for the thirdweb SDK.
10+
/// </summary>
811
[System.Serializable]
912
public struct Options
1013
{
1114
public GaslessOptions? gasless;
1215
}
1316

17+
/// <summary>
18+
/// Gasless configuration options.
19+
/// </summary>
1420
[System.Serializable]
1521
public struct GaslessOptions
1622
{
@@ -19,13 +25,19 @@ public struct GaslessOptions
1925
public bool experimentalChainlessSupport;
2026
}
2127

28+
/// <summary>
29+
/// OpenZeppelin Defender Gasless configuration options.
30+
/// </summary>
2231
[System.Serializable]
2332
public struct OZDefenderOptions
2433
{
2534
public string relayerUrl;
2635
public string relayerForwarderAddress;
2736
}
2837

38+
/// <summary>
39+
/// Biconomy Gasless configuration options.
40+
/// </summary>
2941
[System.Serializable]
3042
public struct BiconomyOptions
3143
{
@@ -34,9 +46,21 @@ public struct BiconomyOptions
3446
}
3547

3648
private string chainOrRPC;
49+
50+
/// <summary>
51+
/// Connect and Interact with a user's wallet
52+
/// </summary>
3753
public Wallet wallet;
54+
/// <summary>
55+
/// Deploy new contracts
56+
/// </summary>
3857
public Deployer deployer;
3958

59+
/// <summary>
60+
/// Create an instance of the thirdweb SDK. Requires a webGL browser context.
61+
/// </summary>
62+
/// <param name="chainOrRPC">The chain name or RPC url to connect to</param>
63+
/// <param name="options">Configuration options</param>
4064
public ThirdwebSDK(string chainOrRPC, Options options = new Options())
4165
{
4266
this.chainOrRPC = chainOrRPC;
@@ -45,6 +69,11 @@ public struct BiconomyOptions
4569
Bridge.Initialize(chainOrRPC, options);
4670
}
4771

72+
/// <summary>
73+
/// Get an instance of a deployed contract.
74+
/// </summary>
75+
/// <param name="address">The contract address</param>
76+
/// <returns>A contract instance</returns>
4877
public Contract GetContract(string address)
4978
{
5079
return new Contract(this.chainOrRPC, address);

Assets/Thirdweb/Scripts/Wallet.cs

+36-6
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,95 @@
33
namespace Thirdweb
44
{
55
/// <summary>
6-
/// Interact with a Wallet.
6+
/// Connect and Interact with a Wallet.
77
/// </summary>
88
public class Wallet
99
{
10+
/// <summary>
11+
/// Connect a user's wallet via browser extension
12+
/// </summary>
1013
public Task<string> Connect()
1114
{
1215
return Bridge.Connect();
1316
}
1417

18+
/// <summary>
19+
/// Authenticate the user by signing a payload that can be used to securely identify users. See https://portal.thirdweb.com/auth
20+
/// </summary>
21+
/// <param name="domain">The domain to authenticate to</param>
1522
public async Task<LoginPayload> Authenticate(string domain)
1623
{
1724
return await Bridge.InvokeRoute<LoginPayload>("sdk#auth.login", Utils.ToJsonStringArray(domain));
1825
}
1926

27+
/// <summary>
28+
/// Get the balance of the connected wallet
29+
/// </summary>
30+
/// <param name="currencyAddress">Optional address of the currency to check balance of</param>
2031
public async Task<CurrencyValue> GetBalance(string currencyAddress = Utils.NativeTokenAddress)
2132
{
2233
return await Bridge.InvokeRoute<CurrencyValue>(getRoute("balance"), Utils.ToJsonStringArray(currencyAddress));
2334
}
2435

36+
/// <summary>
37+
/// Get the connected wallet address
38+
/// </summary>
2539
public async Task<string> GetAddress()
2640
{
2741
return await Bridge.InvokeRoute<string>(getRoute("getAddress"), new string[] { });
2842
}
2943

44+
/// <summary>
45+
/// Check if a wallet is connected
46+
/// </summary>
3047
public async Task<bool> IsConnected()
3148
{
3249
return await Bridge.InvokeRoute<bool>(getRoute("isConnected"), new string[] { });
3350
}
3451

52+
/// <summary>
53+
/// Get the connected chainId
54+
/// </summary>
3555
public async Task<int> GetChainId()
3656
{
3757
return await Bridge.InvokeRoute<int>(getRoute("getChainId"), new string[] { });
3858
}
3959

40-
public async Task<bool> IsOnCorrectChain()
41-
{
42-
return await Bridge.InvokeRoute<bool>(getRoute("isOnCorrectChain"), new string[] { });
43-
}
44-
60+
/// <summary>
61+
/// Prompt the connected wallet to switch to the giiven chainId
62+
/// </summary>
4563
public void SwitchNetwork(int chainId)
4664
{
4765
Bridge.SwitchNetwork(chainId);
4866
}
4967

68+
/// <summary>
69+
/// Transfer currency to a given address
70+
/// </summary>
5071
public async Task<TransactionResult> Transfer(string to, string amount, string currencyAddress = Utils.NativeTokenAddress)
5172
{
5273
return await Bridge.InvokeRoute<TransactionResult>(getRoute("transfer"), Utils.ToJsonStringArray(to, amount, currencyAddress));
5374
}
5475

76+
/// <summary>
77+
/// Prompt the connected wallet to sign the given message
78+
/// </summary>
5579
public async Task<string> Sign(string message)
5680
{
5781
return await Bridge.InvokeRoute<string>(getRoute("sign"), Utils.ToJsonStringArray(message));
5882
}
5983

84+
/// <summary>
85+
/// Recover the original wallet address that signed a message
86+
/// </summary>
6087
public async Task<string> RecoverAddress(string message, string signature)
6188
{
6289
return await Bridge.InvokeRoute<string>(getRoute("recoverAddress"), Utils.ToJsonStringArray(message, signature));
6390
}
6491

92+
/// <summary>
93+
/// Send a raw transaction from the connected wallet
94+
/// </summary>
6595
public async Task<TransactionResult> SendRawTransaction(TransactionRequest transactionRequest)
6696
{
6797
return await Bridge.InvokeRoute<TransactionResult>(getRoute("sendRawTransaction"), Utils.ToJsonStringArray(transactionRequest));

0 commit comments

Comments
 (0)