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
Original file line number Diff line number Diff line change
Expand Up @@ -102,39 +102,39 @@ public async Task SendGaslessZkTx_Success()
// Assert.True(hash.Length == 66);
// }

[Fact(Timeout = 120000)]
public async Task SendGaslessZkTx_Abstract_Success()
{
var account = await this.GetSmartAccount(zkChainId: 11124);
var hash = await account.SendTransaction(
new ThirdwebTransactionInput(11124)
{
From = await account.GetAddress(),
To = await account.GetAddress(),
Value = new Nethereum.Hex.HexTypes.HexBigInteger(0),
Data = "0x"
}
);
Assert.NotNull(hash);
Assert.True(hash.Length == 66);
}
// [Fact(Timeout = 120000)]
// public async Task SendGaslessZkTx_Abstract_Success()
// {
// var account = await this.GetSmartAccount(zkChainId: 11124);
// var hash = await account.SendTransaction(
// new ThirdwebTransactionInput(11124)
// {
// From = await account.GetAddress(),
// To = await account.GetAddress(),
// Value = new Nethereum.Hex.HexTypes.HexBigInteger(0),
// Data = "0x"
// }
// );
// Assert.NotNull(hash);
// Assert.True(hash.Length == 66);
// }

[Fact(Timeout = 120000)]
public async Task SendGaslessZkTx_Creator_Success()
{
var account = await this.GetSmartAccount(zkChainId: 4654);
var hash = await account.SendTransaction(
new ThirdwebTransactionInput(4654)
{
From = await account.GetAddress(),
To = await account.GetAddress(),
Value = new Nethereum.Hex.HexTypes.HexBigInteger(0),
Data = "0x"
}
);
Assert.NotNull(hash);
Assert.True(hash.Length == 66);
}
// [Fact(Timeout = 120000)]
// public async Task SendGaslessZkTx_Creator_Success()
// {
// var account = await this.GetSmartAccount(zkChainId: 4654);
// var hash = await account.SendTransaction(
// new ThirdwebTransactionInput(4654)
// {
// From = await account.GetAddress(),
// To = await account.GetAddress(),
// Value = new Nethereum.Hex.HexTypes.HexBigInteger(0),
// Data = "0x"
// }
// );
// Assert.NotNull(hash);
// Assert.True(hash.Length == 66);
// }

[Fact(Timeout = 120000)]
public async Task ZkSync_Switch()
Expand Down
19 changes: 18 additions & 1 deletion Thirdweb.Tests/Thirdweb.Wallets/Thirdweb.Wallets.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public WalletTests(ITestOutputHelper output)
private async Task<SmartWallet> GetSmartAccount()
{
var privateKeyAccount = await PrivateKeyWallet.Generate(this.Client);
var smartAccount = await SmartWallet.Create(personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);
var smartAccount = await SmartWallet.Create(personalWallet: privateKeyAccount, chainId: 421614);
return smartAccount;
}

Expand Down Expand Up @@ -230,4 +230,21 @@ public async Task RecoverAddress_AllVariants_NullTests()
);
#nullable restore
}

[Fact(Timeout = 120000)]
public async Task SwitchNetwork_Success()
{
var smartWallet = await this.GetSmartAccount();
var wrappedSmartWallet = await SmartWallet.Create(personalWallet: smartWallet, chainId: 421614);

Assert.Equal(421614, smartWallet.ActiveChainId);
Assert.Equal(421614, wrappedSmartWallet.ActiveChainId);

await wrappedSmartWallet.SwitchNetwork(11155111);

Assert.Equal(11155111, wrappedSmartWallet.ActiveChainId);
Assert.Equal(11155111, smartWallet.ActiveChainId);

await (await PrivateKeyWallet.Generate(this.Client)).SwitchNetwork(11155111);
}
}
2 changes: 1 addition & 1 deletion Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public async Task<TResponse> SendRequestAsync<TResponse>(string method, params o
private ThirdwebRPC(ThirdwebClient client, BigInteger chainId)
{
this._httpClient = client.HttpClient;
this._rpcUrl = new Uri($"https://{chainId}.rpc.thirdweb.com/");
this._rpcUrl = new Uri($"https://{chainId}.rpc.thirdweb.com/{client.ClientId}");
this._rpcTimeout = TimeSpan.FromMilliseconds(client.FetchTimeoutOptions.GetTimeout(TimeoutType.Rpc));
_ = this.StartBackgroundFlushAsync();
}
Expand Down
6 changes: 6 additions & 0 deletions Thirdweb/Thirdweb.Wallets/IThirdwebWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ Task<List<LinkedAccount>> LinkAccount(
/// <param name="willSelfExecute">Set to true if the wallet will also be the executor of the transaction, otherwise false.</param>
/// <returns>The signed authorization as an <see cref="EIP7702Authorization"/> that can be used with <see cref="ThirdwebTransactionInput.AuthorizationList"/>.</returns>
Task<EIP7702Authorization> SignAuthorization(BigInteger chainId, string contractAddress, bool willSelfExecute);

/// <summary>
/// Attempts to set the active network to the specified chain ID.
/// </summary>
/// <param name="chainId">The chain ID to switch to.</param>
Task SwitchNetwork(BigInteger chainId);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,5 +986,10 @@ public Task<EIP7702Authorization> SignAuthorization(BigInteger chainId, string c
throw new NotImplementedException();
}

public Task SwitchNetwork(BigInteger chainId)
{
return Task.CompletedTask;
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,10 @@ public async Task<EIP7702Authorization> SignAuthorization(BigInteger chainId, st
return new EIP7702Authorization(chainId, contractAddress, nonce, authorizationSignature.V, authorizationSignature.R, authorizationSignature.S);
}

public Task SwitchNetwork(BigInteger chainId)
{
return Task.CompletedTask;
}

#endregion
}
Loading
Loading