[wip] i forgot to write the s2i function, but progress on showing address to user
This commit is contained in:
+2
-1
@@ -3,4 +3,5 @@
|
|||||||
{name, jrx}.
|
{name, jrx}.
|
||||||
{version, "0.1.0"}.
|
{version, "0.1.0"}.
|
||||||
{deps, ["local-tweetnacl-1.0.3",
|
{deps, ["local-tweetnacl-1.0.3",
|
||||||
"local-awcp-0.2.2"]}.
|
"local-awcp-0.2.2",
|
||||||
|
"local-vdk_aeser-0.1.0"]}.
|
||||||
|
|||||||
+14
-6
@@ -97,10 +97,6 @@ b_main
|
|||||||
{
|
{
|
||||||
console.log('b_main');
|
console.log('b_main');
|
||||||
|
|
||||||
// get state
|
|
||||||
let state: bi_state = await bi_get_state();
|
|
||||||
console.log(state);
|
|
||||||
|
|
||||||
// handle messages from content or popup scripts
|
// handle messages from content or popup scripts
|
||||||
browser.runtime.onMessage.addListener(bi_runtime_msg_handler);
|
browser.runtime.onMessage.addListener(bi_runtime_msg_handler);
|
||||||
}
|
}
|
||||||
@@ -113,6 +109,7 @@ b_main
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// !bi_types
|
// !bi_types
|
||||||
|
// !bi_state
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @example
|
* @example
|
||||||
@@ -256,6 +253,7 @@ bi_msg_handler_content
|
|||||||
sendResponse : any)
|
sendResponse : any)
|
||||||
: Promise<bi_w2a_return_data>
|
: Promise<bi_w2a_return_data>
|
||||||
{
|
{
|
||||||
|
console.log('bi_msg_handler_content', {msg: msg});
|
||||||
//console.log('msg', msg);
|
//console.log('msg', msg);
|
||||||
//console.log('sender', sender);
|
//console.log('sender', sender);
|
||||||
//console.log('sendResponse', sendResponse);
|
//console.log('sendResponse', sendResponse);
|
||||||
@@ -282,6 +280,7 @@ bi_msg_handler_content
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log('jr bg content message handler method:', msg.data.method);
|
||||||
switch (msg.data.method) {
|
switch (msg.data.method) {
|
||||||
case "connection.open":
|
case "connection.open":
|
||||||
return w2a_ok({id : "jr",
|
return w2a_ok({id : "jr",
|
||||||
@@ -292,15 +291,22 @@ bi_msg_handler_content
|
|||||||
|
|
||||||
// TODO: factor this out into a function
|
// TODO: factor this out into a function
|
||||||
case "address.subscribe":
|
case "address.subscribe":
|
||||||
|
console.log('jr bg content message handler address.subscribe');
|
||||||
// get the state
|
// get the state
|
||||||
let i_state : bi_state = await bi_get_state();
|
let i_state : bi_state = await bi_get_state();
|
||||||
|
|
||||||
|
console.log('poop');
|
||||||
|
|
||||||
// get the keypairs
|
// get the keypairs
|
||||||
// for now only getting the first one
|
// for now only getting the first one
|
||||||
let address_bytes : Uint8Array = i_state.keypairs[0].publicKey;
|
let address_bytes : Uint8Array = i_state.keypairs[0].publicKey;
|
||||||
|
|
||||||
|
console.log('pee');
|
||||||
|
|
||||||
// convert it to a string
|
// convert it to a string
|
||||||
let address_ak_str : string = vdk_aeser.pubkey2ak_str(address_bytes);
|
let address_ak_str : string = await vdk_aeser.pubkey2ak_str(address_bytes);
|
||||||
|
|
||||||
|
console.log('poopoo peepee');
|
||||||
|
|
||||||
return w2a_ok({subscription : ["connected"],
|
return w2a_ok({subscription : ["connected"],
|
||||||
address : {current : {address_ak_str: {}},
|
address : {current : {address_ak_str: {}},
|
||||||
@@ -425,11 +431,13 @@ bi_get_state
|
|||||||
// if there is such a state, get it
|
// if there is such a state, get it
|
||||||
// @ts-ignore ts doesn't understand querying if a key exists
|
// @ts-ignore ts doesn't understand querying if a key exists
|
||||||
if (!!(gotten_state.jr_state)) {
|
if (!!(gotten_state.jr_state)) {
|
||||||
// @ts-ignore ts doesn't understand that we have proved that the key exists
|
console.log('foo');
|
||||||
|
// FIXME: write s2i
|
||||||
return bi_s2i(gotten_state);
|
return bi_s2i(gotten_state);
|
||||||
}
|
}
|
||||||
// otherwise return default state
|
// otherwise return default state
|
||||||
else {
|
else {
|
||||||
|
console.log('bar');
|
||||||
// set the state
|
// set the state
|
||||||
let default_i_state : bi_state = bi_state_default();
|
let default_i_state : bi_state = bi_state_default();
|
||||||
await bi_set_state(default_i_state);
|
await bi_set_state(default_i_state);
|
||||||
|
|||||||
Reference in New Issue
Block a user