Chore/base configurations
This commit is contained in:
14
source/templates.ts
Normal file
14
source/templates.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { binToHex, sha256, utf8ToBin, stringify } from '@bitauth/libauth';
|
||||
import type { XOTemplate } from '@xo-cash/types';
|
||||
|
||||
/**
|
||||
* Generates a deterministic template identifier by hashing the template.
|
||||
*
|
||||
* @param template - The template to generate an identifier for.
|
||||
* @returns The template identifier for the template.
|
||||
*/
|
||||
export const generateTemplateIdentifier = (template: XOTemplate): string => {
|
||||
// TODO: Finalize on the stringify method and ensure unique identifier generation is sufficient.
|
||||
|
||||
return binToHex(sha256.hash(utf8ToBin(stringify(template))));
|
||||
};
|
||||
Reference in New Issue
Block a user