Task {
do {
let domain = ScanEip712Domain(
name: "MyToken",
version: "1",
chainId: "eip155:1",
verifyingContract: "0xa0b86991c6218b36c1d19d4a2e9Eb0cE3606eB48",
salt: nil
)
let types: [String: [ScanEip712TypeProperty]] = [
"EIP712Domain": [
ScanEip712TypeProperty(name: "name", type: "string"),
ScanEip712TypeProperty(name: "version", type: "string"),
ScanEip712TypeProperty(name: "chainId", type: "uint256"),
ScanEip712TypeProperty(name: "verifyingContract", type: "address")
],
"Permit": [
ScanEip712TypeProperty(name: "owner", type: "address"),
ScanEip712TypeProperty(name: "spender", type: "address"),
ScanEip712TypeProperty(name: "value", type: "uint256"),
ScanEip712TypeProperty(name: "nonce", type: "uint256"),
ScanEip712TypeProperty(name: "deadline", type: "uint256")
]
]
let message = ScanEip712TypedData(
primaryType: "Permit",
types: types,
domain: domain,
message: [
"owner": AnyCodable("0x7b1363f33b86d16ef7c8d03d11f4394a37d95c36"),
"spender": AnyCodable("0x67beb4dd770a9c2cbc7133ba428b9eecdcf09186"),
"value": AnyCodable(3000),
"nonce": AnyCodable(0),
"deadline": AnyCodable(50000000000)
]
)
let request = ScanEip712Request(
walletAddress: "0x7b1363f33b86d16ef7c8d03d11f4394a37d95c36",
chainId: "eip155:1",
eip712Message: message,
showFullFindings: nil,
policy: nil
)
let response = try await portal.security.hypernative.scanEip712Tx(request: request)
if let rawResponse = response.data?.rawResponse {
print("Success: \(rawResponse.success)")
if let data = rawResponse.data {
print("Recommendation: \(data.recommendation)")
print("Assessment ID: \(data.assessmentId ?? "N/A")")
}
}
} catch {
print("Error scanning EIP-712 transaction: \(error)")
}
}