Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .csharpierrc

This file was deleted.

45 changes: 43 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
###############################
# Core EditorConfig Options #
# Core EditorConfig Options #
###############################

root = true

###############################
# .NET Coding Conventions #
# Generated Code Exclusions #
###############################

# Exclude Thirdweb.Api generated files from all linting and formatting rules
[Thirdweb/Thirdweb.Api/GeneratedClient.cs]
generated_code = true
dotnet_analyzer_diagnostic.severity = none
dotnet_style_qualification_for_field = false
dotnet_style_qualification_for_property = false
dotnet_style_qualification_for_method = false
dotnet_style_qualification_for_event = false
csharp_style_namespace_declarations = block_scoped
dotnet_diagnostic.IDE0130.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.IDE0045.severity = none
dotnet_diagnostic.IDE0066.severity = none
dotnet_diagnostic.IDE0028.severity = none
dotnet_diagnostic.CA1822.severity = none
dotnet_diagnostic.IDE0290.severity = none
# Disable all naming convention rules for generated code
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = none
dotnet_naming_rule.public_members_should_be_pascal_case.severity = none
dotnet_naming_rule.private_fields_should_have_underscore_prefix.severity = none

###############################
# Configurable behaviors #
###############################

[*.{cs,csx}]
end_of_line = crlf
indent_style = space
indent_size = 4
max_line_length = 200

###############################
# .NET Coding Conventions #
###############################

[*.{cs,vb}]
Expand Down Expand Up @@ -148,3 +183,9 @@ dotnet_diagnostic.CA1822.severity = suggestion

# IDE0290: Use primary constructor
dotnet_diagnostic.IDE0290.severity = silent

# JSON002: Probable JSON string detected
dotnet_diagnostic.JSON002.severity = silent

# CS8981: The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
dotnet_diagnostic.CS8981.severity = suggestion
17 changes: 0 additions & 17 deletions Directory.Build.props

This file was deleted.

26 changes: 0 additions & 26 deletions Directory.Packages.props

This file was deleted.

4 changes: 0 additions & 4 deletions Makefile

This file was deleted.

62 changes: 32 additions & 30 deletions Thirdweb.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
#pragma warning disable IDE0005
#pragma warning disable IDE0059

using System.Diagnostics;
using System.Numerics;
using System.Text;
using dotenv.net;
using Nethereum.ABI;
using Nethereum.Hex.HexConvertors.Extensions;
using Nethereum.Hex.HexTypes;
using Nethereum.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Thirdweb;
using Thirdweb.AccountAbstraction;
using Thirdweb.AI;
using Thirdweb.Bridge;
using Thirdweb.Indexer;
using Thirdweb.Pay;

DotEnv.Load();

// Do not use secret keys client side, use client id/bundle id instead
var secretKey = Environment.GetEnvironmentVariable("THIRDWEB_SECRET_KEY");

// Do not use private keys client side, use InAppWallet/SmartWallet instead
var privateKey = Environment.GetEnvironmentVariable("PRIVATE_KEY");

// Fetch timeout options are optional, default is 120000ms
var client = ThirdwebClient.Create(secretKey: secretKey);

#region Basic Wallet Interaction

// Create a private key wallet
var privateKeyWallet = await PrivateKeyWallet.Generate(client);

// var walletAddress = await privateKeyWallet.GetAddress();
// Console.WriteLine($"PK Wallet address: {walletAddress}");
var walletAddress = await privateKeyWallet.GetAddress();
Console.WriteLine($"PK Wallet address: {walletAddress}");

#region Contract Interaction
#endregion

#region Basic Contract Interaction

// var contract = await ThirdwebContract.Create(client: client, address: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d", chain: 1);
// var nfts = await contract.ERC721_GetAllNFTs();
// Console.WriteLine($"NFTs: {JsonConvert.SerializeObject(nfts, Formatting.Indented)}");

#endregion

#region Deploy Contract

// var serverWallet = await ServerWallet.Create(client: client, label: "TestFromDotnet");

// var abi =
// "[ { \"inputs\": [], \"name\": \"welcome\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"pure\", \"type\": \"function\" } ]";

// var contractAddress = await ThirdwebContract.Deploy(
// client: client,
// chainId: 11155111,
// serverWalletAddress: await serverWallet.GetAddress(),
// bytecode: "6080604052348015600e575f5ffd5b5061014e8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c8063b627cf3b1461002d575b5f5ffd5b61003561004b565b60405161004291906100f8565b60405180910390f35b60606040518060400160405280601481526020017f57656c636f6d6520746f20746869726477656221000000000000000000000000815250905090565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6100ca82610088565b6100d48185610092565b93506100e48185602086016100a2565b6100ed816100b0565b840191505092915050565b5f6020820190508181035f83015261011081846100c0565b90509291505056fea264697066735822122001498e9d7d6125ce22613ef32fdb7e8e03bf11ad361d7b00e210b82d7b7e0d4464736f6c634300081e0033",
// abi: abi
// );
// Console.WriteLine($"Contract deployed at: {contractAddress}");

// var contract = await ThirdwebContract.Create(client: client, address: contractAddress, chain: 11155111, abi: abi);
// var welcomeMessage = await contract.Read<string>("welcome");
// Console.WriteLine($"Welcome message from deployed contract: {welcomeMessage}");

#endregion

#region Bridge

// // Create a ThirdwebBridge instance
Expand Down Expand Up @@ -325,18 +334,11 @@

#region AA ZkSync

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

// var hash = await zkSmartWallet.SendTransaction(
// new ThirdwebTransactionInput(4654)
// {
// To = await zkSmartWallet.GetAddress(),
// Value = new HexBigInteger(BigInteger.Zero),
// Data = "0x",
// }
// );
var hash = await zkSmartWallet.SendTransaction(new ThirdwebTransactionInput(chainId: 11124, to: await zkSmartWallet.GetAddress(), value: 0, data: "0x"));

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

#endregion

Expand Down
12 changes: 4 additions & 8 deletions Thirdweb.Console/Thirdweb.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Thirdweb\Thirdweb.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="dotenv.net" />
<PackageReference Include="dotenv.net" Version="3.1.3" />
</ItemGroup>

<ItemGroup>
<None Update=".env">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
</Project>
8 changes: 4 additions & 4 deletions Thirdweb.Tests/Thirdweb.Contracts/Thirdweb.Contracts.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public async Task SignatureMint_Generate()
Value = BigInteger.Zero,
Gas = BigInteger.Zero,
Nonce = BigInteger.Zero,
Data = "0x"
Data = "0x",
};
var signature = await EIP712.GenerateSignature_MinimalForwarder(randomDomain, randomVersion, randomChainId, randomContractAddress, forwardRequest, signer);
Assert.NotNull(signature);
Expand All @@ -243,7 +243,7 @@ public async Task SignatureMint_Generate()
Currency = Constants.ADDRESS_ZERO,
ValidityEndTimestamp = 0,
ValidityStartTimestamp = Utils.GetUnixTimeStampIn10Years(),
Uid = new byte[] { 0x01 }
Uid = new byte[] { 0x01 },
};
var signature20 = await EIP712.GenerateSignature_TokenERC20(randomDomain, randomVersion, randomChainId, randomContractAddress, mintRequest20, signer);
Assert.NotNull(signature20);
Expand All @@ -261,7 +261,7 @@ public async Task SignatureMint_Generate()
Currency = Constants.ADDRESS_ZERO,
ValidityEndTimestamp = 0,
ValidityStartTimestamp = Utils.GetUnixTimeStampIn10Years(),
Uid = new byte[] { 0x01 }
Uid = new byte[] { 0x01 },
};
var signature721 = await EIP712.GenerateSignature_TokenERC721(randomDomain, randomVersion, randomChainId, randomContractAddress, mintRequest721, signer);
Assert.NotNull(signature721);
Expand All @@ -281,7 +281,7 @@ public async Task SignatureMint_Generate()
Currency = Constants.ADDRESS_ZERO,
ValidityEndTimestamp = 0,
ValidityStartTimestamp = Utils.GetUnixTimeStampIn10Years(),
Uid = new byte[] { 0x01 }
Uid = new byte[] { 0x01 },
};
var signature1155 = await EIP712.GenerateSignature_TokenERC1155(randomDomain, randomVersion, randomChainId, randomContractAddress, mintRequest1155, signer);
Assert.NotNull(signature1155);
Expand Down
Loading
Loading