Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit cbf28fe

Browse files
committed
* Add signTypedDataV4 API
1 parent 90fa270 commit cbf28fe

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Sources/MagicSDK/Modules/Web3/Web3Extension.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ public extension Web3.Eth {
6464
)
6565
properties.provider.send(request: req, response: response)
6666
}
67+
68+
func signTypedDataV4(
69+
account: EthereumAddress,
70+
data: EIP712TypedData,
71+
response: @escaping Web3ResponseCompletion<EthereumData>
72+
) {
73+
let req = RPCRequest<SignTypedDataCallParams>(
74+
id: properties.rpcId,
75+
jsonrpc: Web3.jsonrpc,
76+
method: "eth_signTypedData_v4",
77+
params: SignTypedDataCallParams(
78+
account: account, data: data
79+
)
80+
)
81+
properties.provider.send(request: req, response: response)
82+
}
6783
}
6884

6985
// MARK: - web3 extension Promises
@@ -95,6 +111,20 @@ public extension Web3.Eth {
95111
signTypedDataV3(account: account, data: data, response: promiseResolver(resolver))
96112
}
97113
}
114+
115+
func signTypedDataV4(
116+
account: EthereumAddress, data: EIP712TypedData) -> Promise<EthereumData> {
117+
return Promise { resolver in
118+
signTypedDataV4(account: account, data: data, response: promiseResolver(resolver))
119+
}
120+
}
121+
122+
func ecRecover(
123+
message: String, signature: String) -> Promise<EthereumAddress> {
124+
return Promise { resolver in
125+
ecRecover(message: message, signature: signature, response: promiseResolver(resolver))
126+
}
127+
}
98128
}
99129

100130
public extension RPCRequest {

0 commit comments

Comments
 (0)