Skip to content

Commit

Permalink
fix eth send transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Feb 6, 2024
1 parent 44061fb commit dbc05ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Example/Shared/Signer/ETHSigner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ struct ETHSigner {
return AnyCodable(result)
}

func sendTransaction(_ params: AnyCodable) -> AnyCodable {
let params = try! params.get([EthereumTransaction].self)
func sendTransaction(_ params: AnyCodable) throws -> AnyCodable {
let params = try params.get([EthereumTransaction].self)
var transaction = params[0]
transaction.gas = EthereumQuantity(quantity: BigUInt("1234"))
transaction.nonce = EthereumQuantity(quantity: BigUInt("0"))
transaction.gasPrice = EthereumQuantity(quantity: BigUInt(0))
print(transaction.description)
let signedTx = try! transaction.sign(with: self.privateKey, chainId: 4)
let signedTx = try transaction.sign(with: self.privateKey, chainId: 4)
let (r, s, v) = (signedTx.r, signedTx.s, signedTx.v)
let result = r.hex() + s.hex().dropFirst(2) + String(v.quantity, radix: 16)
return AnyCodable(result)
Expand Down
2 changes: 1 addition & 1 deletion Example/Shared/Signer/Signer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Signer {
return signer.signTypedData(request.params)

case "eth_sendTransaction":
return signer.sendTransaction(request.params)
return try signer.sendTransaction(request.params)

case "solana_signTransaction":
return SOLSigner.signTransaction(request.params)
Expand Down

0 comments on commit dbc05ca

Please sign in to comment.