Generic Viem HaLo account provider (#444)

This commit is contained in:
Michał Leszczyński
2025-03-12 15:15:04 +01:00
committed by GitHub
parent 0106ff9e44
commit 5f222914a7
5 changed files with 322 additions and 69 deletions

25
docs/viem-account.md Normal file
View File

@@ -0,0 +1,25 @@
# Using HaLo with Viem
```
import {createViemHaloAccount} from "@arx-research/libhalo/api/common";
import {execHaloCmdWeb} from '@arx-research/libhalo/api/web';
import {HaloResSign, HexString} from "@arx-research/libhalo/types";
const HALO_KEY_NO = 8;
const HALO_PASSWORD = "000000";
async function haloSignDigest(address: Hex, digest: HexString): Promise<HaloResSign> {
return await execHaloCmdWeb({
digest,
keyNo: HALO_KEY_NO,
password: HALO_PASSWORD,
})
}
const account = createViemHaloAccount(
address,
async (digest: string): Promise<HaloResSign> => await haloSignDigest(address, digest)
)
// the "account" is ready to be used with Viem wallet/public clients
```