Skip to content

Commit 375549a

Browse files
authored
Make Authenticate more flexible (#58)
1 parent 48a62e1 commit 375549a

File tree

15 files changed

+334
-398
lines changed

15 files changed

+334
-398
lines changed

.csharpierrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 200,
3+
"useTabs": false,
4+
"tabWidth": 4,
5+
"preprocessorSymbolSets": [
6+
"",
7+
"DEBUG",
8+
"RELEASE"
9+
]
10+
}

.editorconfig

+57-112
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,51 @@
44

55
root = true
66

7-
# XML project files
8-
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
9-
indent_size = 2
10-
insert_final_newline = true
11-
trim_trailing_whitespace = true
12-
13-
# XML config files
14-
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
15-
indent_size = 2
16-
insert_final_newline = true
17-
trim_trailing_whitespace = true
18-
19-
# Code files
20-
[*.{cs,csx,vb,vbx}]
21-
indent_size = 4
22-
insert_final_newline = true
23-
trim_trailing_whitespace = true
24-
charset = utf-8-bom
25-
267
###############################
278
# .NET Coding Conventions #
289
###############################
2910

3011
[*.{cs,vb}]
3112
# Organize usings
32-
dotnet_sort_system_directives_first = true:error
33-
dotnet_separate_import_directive_groups = true:error
13+
dotnet_sort_system_directives_first = true:warning
14+
dotnet_separate_import_directive_groups = true:warning
3415

3516
# this. preferences
36-
dotnet_style_qualification_for_field = true:error
37-
dotnet_style_qualification_for_property = true:error
38-
dotnet_style_qualification_for_method = true:error
39-
dotnet_style_qualification_for_event = true:error
17+
dotnet_style_qualification_for_field = true:warning
18+
dotnet_style_qualification_for_property = true:warning
19+
dotnet_style_qualification_for_method = true:warning
20+
dotnet_style_qualification_for_event = true:warning
4021

4122
# Language keywords vs BCL types preferences
42-
dotnet_style_predefined_type_for_locals_parameters_members = true:error
43-
dotnet_style_predefined_type_for_member_access = true:error
23+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
24+
dotnet_style_predefined_type_for_member_access = true:warning
4425

4526
# Parentheses preferences
46-
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:error
47-
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:error
48-
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:error
49-
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:error
27+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
28+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
29+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
30+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
5031

5132
# Modifier preferences
52-
dotnet_style_require_accessibility_modifiers = always:error
53-
dotnet_style_readonly_field = true:error
33+
dotnet_style_require_accessibility_modifiers = always:warning
34+
dotnet_style_readonly_field = true:warning
5435

5536
# Expression-level preferences
56-
dotnet_style_object_initializer = true:error
57-
dotnet_style_collection_initializer = true:error
58-
dotnet_style_explicit_tuple_names = true:error
59-
dotnet_style_null_propagation = true:error
60-
dotnet_style_coalesce_expression = true:error
61-
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
62-
dotnet_style_prefer_inferred_tuple_names = true:error
63-
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
64-
dotnet_style_prefer_auto_properties = true:error
65-
dotnet_style_prefer_conditional_expression_over_assignment = true:error
66-
dotnet_style_prefer_conditional_expression_over_return = true:error
37+
dotnet_style_object_initializer = true:warning
38+
dotnet_style_collection_initializer = false:warning
39+
dotnet_style_prefer_collection_expression = false:warning
40+
dotnet_style_explicit_tuple_names = true:warning
41+
dotnet_style_null_propagation = true:warning
42+
dotnet_style_coalesce_expression = true:warning
43+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
44+
dotnet_style_prefer_inferred_tuple_names = true:warning
45+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
46+
dotnet_style_prefer_auto_properties = true:warning
47+
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
48+
dotnet_style_prefer_conditional_expression_over_return = true:warning
6749

6850
# Namespace preferences
69-
csharp_style_namespace_declarations = file_scoped:error
51+
csharp_style_namespace_declarations = file_scoped:warning
7052

7153
###############################
7254
# Naming Conventions #
@@ -77,15 +59,15 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
7759
dotnet_style_allow_multiple_blank_lines_experimental = false
7860

7961
# Use PascalCase for constant fields
80-
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = error
62+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
8163
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
8264
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
8365
dotnet_naming_symbols.constant_fields.applicable_kinds = field
8466
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
8567
dotnet_naming_symbols.constant_fields.required_modifiers = const
8668

8769
# Use PascalCase for public members (properties, methods, events)
88-
dotnet_naming_rule.public_members_should_be_pascal_case.severity = error
70+
dotnet_naming_rule.public_members_should_be_pascal_case.severity = warning
8971
dotnet_naming_rule.public_members_should_be_pascal_case.symbols = public_members
9072
dotnet_naming_rule.public_members_should_be_pascal_case.style = pascal_case_style
9173
dotnet_naming_symbols.public_members.applicable_kinds = property,method,event,field
@@ -94,7 +76,7 @@ dotnet_naming_symbols.public_members.applicable_accessibilities = public,protect
9476
# Use camelCase with '_' prefix for private fields
9577
dotnet_naming_style.underscore_prefix_style.capitalization = camel_case
9678
dotnet_naming_style.underscore_prefix_style.required_prefix = _
97-
dotnet_naming_rule.private_fields_should_have_underscore_prefix.severity = error
79+
dotnet_naming_rule.private_fields_should_have_underscore_prefix.severity = warning
9880
dotnet_naming_rule.private_fields_should_have_underscore_prefix.symbols = private_fields
9981
dotnet_naming_rule.private_fields_should_have_underscore_prefix.style = underscore_prefix_style
10082
dotnet_naming_symbols.private_fields.applicable_kinds = field
@@ -104,93 +86,56 @@ dotnet_naming_symbols.private_fields.applicable_accessibilities = private
10486
# Analyzers #
10587
###############################
10688

107-
dotnet_analyzer_diagnostic.category-CodeQuality.severity = error
108-
dotnet_analyzer_diagnostic.category-Documentation.severity = error
109-
dotnet_analyzer_diagnostic.category-Design.severity = error
110-
dotnet_analyzer_diagnostic.category-Performance.severity = error
111-
dotnet_analyzer_diagnostic.category-Reliability.severity = error
112-
dotnet_analyzer_diagnostic.category-Security.severity = error
113-
dotnet_analyzer_diagnostic.category-Style.severity = error
89+
dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning
90+
dotnet_analyzer_diagnostic.category-Documentation.severity = warning
91+
dotnet_analyzer_diagnostic.category-Design.severity = warning
92+
dotnet_analyzer_diagnostic.category-Performance.severity = warning
93+
dotnet_analyzer_diagnostic.category-Reliability.severity = warning
94+
dotnet_analyzer_diagnostic.category-Security.severity = warning
95+
dotnet_analyzer_diagnostic.category-Style.severity = warning
11496

11597
# Explicit code exclusions
11698
# Namespace does not match folder structure
11799
dotnet_diagnostic.IDE0130.severity = none
118-
# Collection initialization can be simplified
119-
dotnet_diagnostic.IDE0301.severity = none
120-
dotnet_diagnostic.IDE0300.severity = none
121-
dotnet_diagnostic.IDE0305.severity = none
122100
# If statement can be simplified
123101
dotnet_diagnostic.IDE0046.severity = none
124102
dotnet_diagnostic.IDE0045.severity = none
125103
# Use switch expression
126104
dotnet_diagnostic.IDE0066.severity = none
105+
# Use collection initializers or expressions
106+
# dotnet_diagnostic.IDE0028.severity = none
127107

128108
###############################
129109
# C# Coding Conventions #
130110
###############################
131111
[*.cs]
132112
# var preferences
133-
csharp_style_var_for_built_in_types = true:error
134-
csharp_style_var_when_type_is_apparent = true:error
135-
csharp_style_var_elsewhere = true:error
113+
csharp_style_var_for_built_in_types = true:warning
114+
csharp_style_var_when_type_is_apparent = true:warning
115+
csharp_style_var_elsewhere = true:warning
136116

137117
# Expression-bodied members
138-
csharp_style_expression_bodied_methods = when_possible:error
139-
csharp_style_expression_bodied_constructors = when_possible:error
140-
csharp_style_expression_bodied_operators = when_possible:error
141-
csharp_style_expression_bodied_properties = when_possible:error
142-
csharp_style_expression_bodied_indexers = when_possible:error
143-
csharp_style_expression_bodied_accessors = when_possible:error
118+
csharp_style_expression_bodied_methods = when_possible:warning
119+
csharp_style_expression_bodied_constructors = when_possible:warning
120+
csharp_style_expression_bodied_operators = when_possible:warning
121+
csharp_style_expression_bodied_properties = when_possible:warning
122+
csharp_style_expression_bodied_indexers = when_possible:warning
123+
csharp_style_expression_bodied_accessors = when_possible:warning
144124

145125
# Pattern matching preferences
146-
csharp_style_pattern_matching_over_is_with_cast_check = true:error
147-
csharp_style_pattern_matching_over_as_with_null_check = true:error
126+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
127+
csharp_style_pattern_matching_over_as_with_null_check = true:warning
148128

149129
# Null-checking preferences
150-
csharp_style_throw_expression = true:error
151-
csharp_style_conditional_delegate_call = true:error
130+
csharp_style_throw_expression = true:warning
131+
csharp_style_conditional_delegate_call = true:warning
152132

153133
# Modifier preferences
154134
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error
155135

156136
# Expression-level preferences
157-
csharp_prefer_braces = true:error
158-
csharp_style_deconstructed_variable_declaration = true:error
159-
csharp_prefer_simple_default_expression = true:error
160-
csharp_style_pattern_local_over_anonymous_function = true:error
161-
csharp_style_inlined_variable_declaration = true:error
162-
163-
###############################
164-
# C# Formatting Rules #
165-
###############################
166-
167-
# New line preferences
168-
csharp_new_line_before_open_brace = all
169-
csharp_new_line_before_else = true
170-
csharp_new_line_before_catch = true
171-
csharp_new_line_before_finally = true
172-
csharp_new_line_before_members_in_object_initializers = true
173-
csharp_new_line_before_members_in_anonymous_types = true
174-
csharp_new_line_between_query_expression_clauses = true
175-
176-
# Indentation preferences
177-
csharp_indent_case_contents = true
178-
csharp_indent_switch_labels = true
179-
csharp_indent_labels = flush_left
180-
181-
# Space preferences
182-
csharp_space_after_cast = false
183-
csharp_space_after_keywords_in_control_flow_statements = true
184-
csharp_space_between_method_call_parameter_list_parentheses = false
185-
csharp_space_between_method_declaration_parameter_list_parentheses = false
186-
csharp_space_between_parentheses = false
187-
csharp_space_before_colon_in_inheritance_clause = true
188-
csharp_space_after_colon_in_inheritance_clause = true
189-
csharp_space_around_binary_operators = before_and_after
190-
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
191-
csharp_space_between_method_call_name_and_opening_parenthesis = false
192-
csharp_space_between_method_call_empty_parameter_list_parentheses = false
193-
194-
# Wrapping preferences
195-
csharp_preserve_single_line_statements = true
196-
csharp_preserve_single_line_blocks = true
137+
csharp_prefer_braces = true:warning
138+
csharp_style_deconstructed_variable_declaration = true:warning
139+
csharp_prefer_simple_default_expression = false:warning
140+
csharp_style_pattern_local_over_anonymous_function = true:warning
141+
csharp_style_inlined_variable_declaration = true:warning

Thirdweb.Console/Program.cs

+33
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Newtonsoft.Json;
99
using Nethereum.Hex.HexTypes;
1010
using System.Numerics;
11+
using Newtonsoft.Json.Linq;
1112

1213
DotEnv.Load();
1314

@@ -22,6 +23,7 @@
2223

2324
// Create a private key wallet
2425
var privateKeyWallet = await PrivateKeyWallet.Generate(client: client);
26+
2527
// var walletAddress = await privateKeyWallet.GetAddress();
2628
// Console.WriteLine($"PK Wallet address: {walletAddress}");
2729

@@ -119,6 +121,37 @@
119121

120122
#endregion
121123

124+
#region Smart Wallet - Authenticate
125+
126+
// var appWallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Google);
127+
// if (!await appWallet.IsConnected())
128+
// {
129+
// _ = await appWallet.LoginWithOauth(
130+
// isMobile: false,
131+
// (url) =>
132+
// {
133+
// var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true };
134+
// _ = Process.Start(psi);
135+
// },
136+
// "thirdweb://",
137+
// new InAppWalletBrowser()
138+
// );
139+
// }
140+
// var smartWallet = await SmartWallet.Create(appWallet, 37714555429);
141+
142+
// var data = await smartWallet.Authenticate<JObject>(
143+
// domain: "https://myepicdomain.com",
144+
// chainId: 37714555429,
145+
// authPayloadPath: "/my-epic-auth/login",
146+
// authLoginPath: "/my-epic-auth/login",
147+
// separatePayloadAndSignatureInBody: true,
148+
// authPayloadMethod: "GET",
149+
// authLoginMethod: "POST"
150+
// );
151+
// Console.WriteLine($"Token: {data["token"]}");
152+
153+
#endregion
154+
122155
#region ERC20 Smart Wallet - Base USDC
123156

124157
// var erc20SmartWallet = await SmartWallet.Create(

Thirdweb.Tests/Thirdweb.Contracts/Thirdweb.Contracts.Tests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public async Task ReadTest_PartialSig()
9393

9494
private sealed class AllowlistProof
9595
{
96-
public List<byte[]> Proof { get; set; } = [];
96+
public List<byte[]> Proof { get; set; } = new List<byte[]>();
9797
public BigInteger QuantityLimitPerWallet { get; set; } = BigInteger.Zero;
9898
public BigInteger PricePerToken { get; set; } = BigInteger.Zero;
9999
public string Currency { get; set; } = Constants.ADDRESS_ZERO;

Thirdweb/Thirdweb.Contracts/ThirdwebContract.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ThirdwebContract
1414
internal BigInteger Chain { get; private set; }
1515
internal string Abi { get; private set; }
1616

17-
private static readonly Dictionary<string, string> _contractAbiCache = [];
17+
private static readonly Dictionary<string, string> _contractAbiCache = new();
1818
private static readonly object _cacheLock = new();
1919

2020
private ThirdwebContract(ThirdwebClient client, string address, BigInteger chain, string abi)

0 commit comments

Comments
 (0)