@keplr-ewallet/ewallet-sdk-eth
Version:
45 lines • 1.43 kB
JavaScript
import { serializeTypedData } from "viem";
import { toRpcTransactionRequest } from "../utils";
export async function toViemAccount() {
const publicKey = await this.getPublicKey();
const address = await this.getAddress();
const sign = this.makeSignature;
const account = {
address,
type: "local",
source: "ewallet",
publicKey,
signMessage: async ({ message }) => {
const { signature } = await sign({
type: "personal_sign",
data: {
address,
message,
},
});
return signature;
},
signTransaction: async (transaction) => {
const { signedTransaction } = await sign({
type: "sign_transaction",
data: {
address,
transaction: toRpcTransactionRequest(transaction),
},
});
return signedTransaction;
},
signTypedData: async (typedData) => {
const { signature } = await sign({
type: "sign_typedData_v4",
data: {
address,
serializedTypedData: serializeTypedData(typedData),
},
});
return signature;
},
};
return account;
}
//# sourceMappingURL=to_viem_account.js.map