I am developing a wallet app with the help of WalletConnectV2. I’m having issues with the transaction hash. it is 132 characters long. (0x + 130 characters)
r and s are each 64 characters long (+ 0x) and v is two characters long. The transaction hash should be 0x + 64 characters.
Can someone please tell me what did I miss?
func showSessionRequest(_ sessionRequest: Request) {
Task{
print("showSessionRequest",sessionRequest)
print("showSessionRequest",sessionRequest.method)
let resultSession: AnyCodable = Signer.sign(request: sessionRequest)
try await Sign.instance.respond(topic: sessionRequest.topic, requestId: sessionRequest.id, response: .response(resultSession))
}
}
class Signer {
private init() {}
static func sign(request: Request) -> AnyCodable {
switch request.method {
case "personal_sign":
return ETHSigner.personalSign(request.params)
case "eth_signTypedData_v4":
return ETHSigner.signTypedData(request.params)
case "eth_sendTransaction":
return ETHSigner.sendTransaction(request.params)
default:
fatalError("not implemented")
}
}
}
static func sendTransaction(_ params: AnyCodable) -> AnyCodable {
let params = try! params.get([EthereumTransaction].self)
var transaction = params[0]
transaction.gasPrice = EthereumQuantity(quantity: BigUInt("20000000000"))
transaction.gas = EthereumQuantity(quantity: BigUInt("6721975"))
transaction.nonce = EthereumQuantity(quantity: BigUInt("204"))
let signedTx = try! transaction.sign(with: self.privateKey)
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)
}