Skip to content

Commit 1a5843c

Browse files
committed
Merge branch 'main' into firekeeper/7702-wallet
2 parents 0b4cb47 + 108020e commit 1a5843c

File tree

17 files changed

+1191
-334
lines changed

17 files changed

+1191
-334
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<DefaultVersion>2.18.5</DefaultVersion>
4+
<DefaultVersion>2.20.1</DefaultVersion>
55
<DefaultTargetFrameworks>netstandard2.1;net6.0;net7.0;net8.0</DefaultTargetFrameworks>
66
</PropertyGroup>
77

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The Thirdweb .NET SDK is a comprehensive and easy to use library that allows dev
2121
- **Storage Solutions:** Download and upload files using IPFS.
2222
- **Transaction Builder:** Create, manipulate and send low level transactions.
2323
- **Session Keys:** Advanced control for smart wallets to manage permissions and session durations.
24-
- **Thirdweb Pay:** Easily integrate fiat onramps and cross-chain crypto purchases.
24+
- **Thirdweb Bridge:** Universal interface to use any asset onchain.
2525
- **Thirdweb Nebula:** Create blockchain-powered AI Agents.
2626
- **Thirdweb Insight:** Query blockchain data at the speed of light.
2727
- **Thirdweb Engine:** Interact in creative ways from your backend.

Thirdweb.Console/Program.cs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Thirdweb;
1414
using Thirdweb.AccountAbstraction;
1515
using Thirdweb.AI;
16+
using Thirdweb.Bridge;
1617
using Thirdweb.Indexer;
1718
using Thirdweb.Pay;
1819

@@ -41,6 +42,93 @@
4142

4243
#endregion
4344

45+
#region Bridge
46+
47+
// // Create a ThirdwebBridge instance
48+
// var bridge = await ThirdwebBridge.Create(client);
49+
50+
// // Buy - Get a quote for buying a specific amount of tokens
51+
// var buyQuote = await bridge.Buy_Quote(
52+
// originChainId: 1,
53+
// originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
54+
// destinationChainId: 324,
55+
// destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
56+
// buyAmountWei: BigInteger.Parse("0.1".ToWei())
57+
// );
58+
// Console.WriteLine($"Buy quote: {JsonConvert.SerializeObject(buyQuote, Formatting.Indented)}");
59+
60+
// // Buy - Get an executable set of transactions (alongside a quote) for buying a specific amount of tokens
61+
// var preparedBuy = await bridge.Buy_Prepare(
62+
// originChainId: 1,
63+
// originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
64+
// destinationChainId: 324,
65+
// destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
66+
// buyAmountWei: BigInteger.Parse("0.1".ToWei()),
67+
// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"),
68+
// receiver: await myWallet.GetAddress()
69+
// );
70+
// Console.WriteLine($"Prepared Buy contains {preparedBuy.Transactions.Count} transaction(s)!");
71+
72+
// // Sell - Get a quote for selling a specific amount of tokens
73+
// var sellQuote = await bridge.Sell_Quote(
74+
// originChainId: 324,
75+
// originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
76+
// destinationChainId: 1,
77+
// destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
78+
// sellAmountWei: BigInteger.Parse("0.1".ToWei())
79+
// );
80+
// Console.WriteLine($"Sell quote: {JsonConvert.SerializeObject(sellQuote, Formatting.Indented)}");
81+
82+
// // Sell - Get an executable set of transactions (alongside a quote) for selling a specific amount of tokens
83+
// var preparedSell = await bridge.Sell_Prepare(
84+
// originChainId: 324,
85+
// originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
86+
// destinationChainId: 1,
87+
// destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
88+
// sellAmountWei: BigInteger.Parse("0.1".ToWei()),
89+
// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"),
90+
// receiver: await myWallet.GetAddress()
91+
// );
92+
// Console.WriteLine($"Prepared Sell contains {preparedSell.Transactions.Count} transaction(s)!");
93+
94+
// // Transfer - Get an executable transaction for transferring a specific amount of tokens
95+
// var preparedTransfer = await bridge.Transfer_Prepare(
96+
// chainId: 137,
97+
// tokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
98+
// transferAmountWei: BigInteger.Parse("0.1".ToWei()),
99+
// sender: await Utils.GetAddressFromENS(client, "vitalik.eth"),
100+
// receiver: await myWallet.GetAddress()
101+
// );
102+
// Console.WriteLine($"Prepared Transfer: {JsonConvert.SerializeObject(preparedTransfer, Formatting.Indented)}");
103+
104+
// // You may use our extensions to execute yourself...
105+
// var myTx = await preparedTransfer.Transactions[0].ToThirdwebTransaction(myWallet);
106+
// var myHash = await ThirdwebTransaction.Send(myTx);
107+
108+
// // ...and poll for the status...
109+
// var status = await bridge.Status(transactionHash: myHash, chainId: 1);
110+
// var isComplete = status.StatusType == StatusType.COMPLETED;
111+
// Console.WriteLine($"Status: {JsonConvert.SerializeObject(status, Formatting.Indented)}");
112+
113+
// // Or use our Execute extensions directly to handle everything for you!
114+
115+
// // Execute a prepared Buy
116+
// var buyResult = await bridge.Execute(myWallet, preparedBuy);
117+
// var buyHashes = buyResult.Select(receipt => receipt.TransactionHash).ToList();
118+
// Console.WriteLine($"Buy hashes: {JsonConvert.SerializeObject(buyHashes, Formatting.Indented)}");
119+
120+
// // Execute a prepared Sell
121+
// var sellResult = await bridge.Execute(myWallet, preparedSell);
122+
// var sellHashes = sellResult.Select(receipt => receipt.TransactionHash).ToList();
123+
// Console.WriteLine($"Sell hashes: {JsonConvert.SerializeObject(sellHashes, Formatting.Indented)}");
124+
125+
// // Execute a prepared Transfer
126+
// var transferResult = await bridge.Execute(myWallet, preparedTransfer);
127+
// var transferHashes = transferResult.Select(receipt => receipt.TransactionHash).ToList();
128+
// Console.WriteLine($"Transfer hashes: {JsonConvert.SerializeObject(transferHashes, Formatting.Indented)}");
129+
130+
#endregion
131+
44132
#region Indexer
45133

46134
// // Create a ThirdwebInsight instance
Lines changed: 57 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// using System.Numerics;
2+
using System.Numerics;
23
using Thirdweb.AI;
34

45
namespace Thirdweb.Tests.AI;
56

67
public class NebulaTests : BaseTests
78
{
8-
// private const string NEBULA_TEST_CONTRACT = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8";
9-
// private const string NEBULA_TEST_USDC_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
10-
// private const int NEBULA_TEST_CHAIN = 11155111;
9+
private const string NEBULA_TEST_USDC_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
10+
11+
private const string NEBULA_TEST_CONTRACT = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8";
12+
13+
private const int NEBULA_TEST_CHAIN = 11155111;
1114

1215
public NebulaTests(ITestOutputHelper output)
1316
: base(output) { }
@@ -33,104 +36,58 @@ public async Task Create_ResumesSession()
3336
Assert.Equal(sessionId, nebula.SessionId);
3437
}
3538

36-
// [Fact(Timeout = 120000)]
37-
// public async Task Chat_Single_ReturnsResponse()
38-
// {
39-
// var nebula = await ThirdwebNebula.Create(this.Client);
40-
// var response = await nebula.Chat(
41-
// message: "What's the symbol of this contract?",
42-
// context: new NebulaContext(contractAddresses: new List<string> { NEBULA_TEST_CONTRACT }, chainIds: new List<BigInteger> { NEBULA_TEST_CHAIN })
43-
// );
44-
// Assert.NotNull(response);
45-
// Assert.NotNull(response.Message);
46-
// Assert.Contains("CAT", response.Message);
47-
// }
48-
49-
// [Fact(Timeout = 120000)]
50-
// public async Task Chat_Single_NoContext_ReturnsResponse()
51-
// {
52-
// var nebula = await ThirdwebNebula.Create(this.Client);
53-
// var response = await nebula.Chat(message: $"What's the symbol of this contract: {NEBULA_TEST_CONTRACT} (Sepolia)?");
54-
// Assert.NotNull(response);
55-
// Assert.NotNull(response.Message);
56-
// Assert.Contains("CAT", response.Message);
57-
// }
58-
59-
// [Fact(Timeout = 120000)]
60-
// public async Task Chat_Multiple_ReturnsResponse()
61-
// {
62-
// var nebula = await ThirdwebNebula.Create(this.Client);
63-
// var response = await nebula.Chat(
64-
// messages: new List<NebulaChatMessage>
65-
// {
66-
// new("What's the symbol of this contract?", NebulaChatRole.User),
67-
// new("The symbol is CAT", NebulaChatRole.Assistant),
68-
// new("What's the name of this contract?", NebulaChatRole.User),
69-
// },
70-
// context: new NebulaContext(contractAddresses: new List<string> { NEBULA_TEST_CONTRACT }, chainIds: new List<BigInteger> { NEBULA_TEST_CHAIN })
71-
// );
72-
// Assert.NotNull(response);
73-
// Assert.NotNull(response.Message);
74-
// Assert.Contains("CatDrop", response.Message, StringComparison.OrdinalIgnoreCase);
75-
// }
39+
[Fact(Timeout = 120000)]
40+
public async Task Chat_Single_ReturnsResponse()
41+
{
42+
var nebula = await ThirdwebNebula.Create(this.Client);
43+
var response = await nebula.Chat(message: $"What's the symbol of this contract {NEBULA_TEST_CONTRACT}?", context: new NebulaContext(chainIds: new List<BigInteger>() { NEBULA_TEST_CHAIN }));
44+
Assert.NotNull(response);
45+
Assert.NotNull(response.Message);
46+
Assert.Contains("CAT", response.Message);
47+
}
7648

77-
// [Fact(Timeout = 120000)]
78-
// public async Task Chat_UnderstandsWalletContext()
79-
// {
80-
// var wallet = await PrivateKeyWallet.Generate(this.Client);
81-
// var expectedAddress = await wallet.GetAddress();
82-
// var nebula = await ThirdwebNebula.Create(this.Client);
83-
// var response = await nebula.Chat(message: "What is my wallet address?", wallet: wallet);
84-
// Assert.NotNull(response);
85-
// Assert.NotNull(response.Message);
86-
// Assert.Contains(expectedAddress, response.Message);
87-
// }
49+
[Fact(Timeout = 120000)]
50+
public async Task Chat_Single_NoContext_ReturnsResponse()
51+
{
52+
var nebula = await ThirdwebNebula.Create(this.Client);
53+
var response = await nebula.Chat(message: $"What's the symbol of this contract: {NEBULA_TEST_CONTRACT} (Sepolia)?");
54+
Assert.NotNull(response);
55+
Assert.NotNull(response.Message);
56+
Assert.Contains("CAT", response.Message);
57+
}
8858

89-
// [Fact(Timeout = 120000)]
90-
// public async Task Execute_ReturnsMessageAndReceipt()
91-
// {
92-
// var signer = await PrivateKeyWallet.Generate(this.Client);
93-
// var wallet = await SmartWallet.Create(signer, NEBULA_TEST_CHAIN);
94-
// var nebula = await ThirdwebNebula.Create(this.Client);
95-
// var response = await nebula.Execute(
96-
// new List<NebulaChatMessage>
97-
// {
98-
// new("What's the address of vitalik.eth", NebulaChatRole.User),
99-
// new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
100-
// new("Approve 1 USDC to them", NebulaChatRole.User),
101-
// },
102-
// wallet: wallet,
103-
// context: new NebulaContext(contractAddresses: new List<string>() { NEBULA_TEST_USDC_ADDRESS })
104-
// );
105-
// Assert.NotNull(response);
106-
// Assert.NotNull(response.Message);
107-
// Assert.NotNull(response.TransactionReceipts);
108-
// Assert.NotEmpty(response.TransactionReceipts);
109-
// Assert.NotNull(response.TransactionReceipts[0].TransactionHash);
110-
// Assert.True(response.TransactionReceipts[0].TransactionHash.Length == 66);
111-
// }
59+
[Fact(Timeout = 120000)]
60+
public async Task Chat_UnderstandsWalletContext()
61+
{
62+
var wallet = await PrivateKeyWallet.Generate(this.Client);
63+
var expectedAddress = await wallet.GetAddress();
64+
var nebula = await ThirdwebNebula.Create(this.Client);
65+
var response = await nebula.Chat(message: "What is my wallet address?", wallet: wallet);
66+
Assert.NotNull(response);
67+
Assert.NotNull(response.Message);
68+
Assert.Contains(expectedAddress, response.Message);
69+
}
11270

113-
// [Fact(Timeout = 120000)]
114-
// public async Task Execute_ReturnsMessageAndReceipts()
115-
// {
116-
// var signer = await PrivateKeyWallet.Generate(this.Client);
117-
// var wallet = await SmartWallet.Create(signer, NEBULA_TEST_CHAIN);
118-
// var nebula = await ThirdwebNebula.Create(this.Client);
119-
// var response = await nebula.Execute(
120-
// new List<NebulaChatMessage>
121-
// {
122-
// new("What's the address of vitalik.eth", NebulaChatRole.User),
123-
// new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
124-
// new("Approve 1 USDC to them", NebulaChatRole.User),
125-
// },
126-
// wallet: wallet,
127-
// context: new NebulaContext(contractAddresses: new List<string>() { NEBULA_TEST_USDC_ADDRESS })
128-
// );
129-
// Assert.NotNull(response);
130-
// Assert.NotNull(response.Message);
131-
// Assert.NotNull(response.TransactionReceipts);
132-
// Assert.NotEmpty(response.TransactionReceipts);
133-
// Assert.NotNull(response.TransactionReceipts[0].TransactionHash);
134-
// Assert.True(response.TransactionReceipts[0].TransactionHash.Length == 66);
135-
// }
71+
[Fact(Timeout = 120000)]
72+
public async Task Execute_ReturnsMessageAndReceipt()
73+
{
74+
var signer = await PrivateKeyWallet.Generate(this.Client);
75+
var wallet = await SmartWallet.Create(signer, NEBULA_TEST_CHAIN);
76+
var nebula = await ThirdwebNebula.Create(this.Client);
77+
var response = await nebula.Execute(
78+
new List<NebulaChatMessage>
79+
{
80+
new("What's the address of vitalik.eth", NebulaChatRole.User),
81+
new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
82+
new($"Approve 1 USDC (this contract: {NEBULA_TEST_USDC_ADDRESS}) to them", NebulaChatRole.User),
83+
},
84+
wallet: wallet
85+
);
86+
Assert.NotNull(response);
87+
Assert.NotNull(response.Message);
88+
Assert.NotNull(response.TransactionReceipts);
89+
Assert.NotEmpty(response.TransactionReceipts);
90+
Assert.NotNull(response.TransactionReceipts[0].TransactionHash);
91+
Assert.True(response.TransactionReceipts[0].TransactionHash.Length == 66);
92+
}
13693
}

Thirdweb/Thirdweb.AI/FeedbackClient.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)