add msg_sign example to sidekick

This commit is contained in:
Foo Bar
2022-11-28 19:17:48 -07:00
parent 36cb75c51d
commit 41249baf3c
2 changed files with 22 additions and 4 deletions
+18
View File
@@ -854,6 +854,24 @@ address
//-----------------------------------------------------------------------------
// API: message sign
//-----------------------------------------------------------------------------
/**
* Sign the given message, return the message signature
*
* @example
* This function is triggered when a "sign message" button is pressed. A text
* input with `id="message-text"` contains the message to be signed.
* ```ts
* async function sign_msg (logger: sk.Logger) : Promise<void> {
* let acc_pubkey : string = pv_address;
* // @ts-ignore value property exists because i say so
* let msg_text : string = document.getElementById('message-text').value;
* let signed_msg = await sk.msg_sign('sk-msg-sign-1', acc_pubkey, msg_text, sk.TIMEOUT_DEF_MSG_SIGN_MS, 'message signing took too long', logger);
* console.log('signed message:', signed_msg);
* }
* ```
*/
async function
msg_sign
(id : number | string,
+4 -4
View File
@@ -195,14 +195,14 @@ cfg() ->
-spec cfg(MaybeSafe) -> Result
when MaybeSafe :: safe | unsafe
Result :: {ok, Cfg :: proplist()}
when MaybeSafe :: safe | unsafe,
Result :: {ok, Cfg :: proplists:proplist()}
| {error, Reason :: term()}.
% @doc "safe" means it checks to make sure the
cfg(unsafe) ->
{ok, Terms} = file:consult("jex.eterms");
Terms;
{ok, Terms} = file:consult("jex.eterms"),
{ok, Terms};
cfg(safe) ->
case file:consult("jex.eterms") of
{ok, Terms} -> cfg2(Terms);