Skip to content

Commit

Permalink
t sign
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Apr 15, 2024
1 parent 2badbc4 commit a668fb4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Thirdweb.Tests/Thirdweb.Transactions.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ public async Task SetValue_SetsGasPrice()
Assert.Equal(gas.ToHexBigInteger(), transaction.Input.GasPrice);
}

[Fact]
public async Task Sign_SmartWallet_SignsTransaction()
{
var client = ThirdwebClient.Create(secretKey: _secretKey);
var privateKeyAccount = await PrivateKeyWallet.Create(client, _testPrivateKey);
var smartAccount = await SmartWallet.Create(client, personalWallet: privateKeyAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);
var transaction = await ThirdwebTransaction.Create(
client,
smartAccount,
new TransactionInput()
{
To = Constants.ADDRESS_ZERO,
Value = new HexBigInteger(0),
Data = "0x"
},
421614
);
var signed = await ThirdwebTransaction.Sign(transaction);
Assert.NotNull(signed);
}

[Fact]
public async Task Send_ThrowsIfToAddressNotProvided()
{
Expand Down
2 changes: 1 addition & 1 deletion Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static async Task<string> Send(ThirdwebTransaction transaction)
{
case ThirdwebAccountType.PrivateKeyAccount:
transaction.Input.Nonce ??= new HexBigInteger(await rpc.SendRequestAsync<string>("eth_getTransactionCount", await transaction._wallet.GetAddress(), "latest"));
var signedTx = await transaction._wallet.SignTransaction(transaction.Input, transaction.Input.ChainId.Value);
var signedTx = await Sign(transaction);
hash = await rpc.SendRequestAsync<string>("eth_sendRawTransaction", signedTx);
break;
case ThirdwebAccountType.SmartAccount:
Expand Down

0 comments on commit a668fb4

Please sign in to comment.