jr can now post a sale on aegora testnet!
This commit is contained in:
@@ -383,6 +383,11 @@ tx_sign
|
|||||||
secret_key : Uint8Array)
|
secret_key : Uint8Array)
|
||||||
: Promise<{signedTransaction : string}>
|
: Promise<{signedTransaction : string}>
|
||||||
{
|
{
|
||||||
|
// debug: show tx
|
||||||
|
let mansplained_tx : object = await vdk_aeser.mansplain(tx_str);
|
||||||
|
console.log('mansplained_tx,', mansplained_tx);
|
||||||
|
|
||||||
|
|
||||||
let tx_bytes : Uint8Array = (await vdk_aeser.unbaseNcheck(tx_str)).bytes;
|
let tx_bytes : Uint8Array = (await vdk_aeser.unbaseNcheck(tx_str)).bytes;
|
||||||
// thank you ulf
|
// thank you ulf
|
||||||
// https://github.com/aeternity/protocol/tree/fd179822fc70241e79cbef7636625cf344a08109/consensus#transaction-signature
|
// https://github.com/aeternity/protocol/tree/fd179822fc70241e79cbef7636625cf344a08109/consensus#transaction-signature
|
||||||
@@ -396,6 +401,11 @@ tx_sign
|
|||||||
let signature : Uint8Array = nacl.sign.detached(sign_data, secret_key);
|
let signature : Uint8Array = nacl.sign.detached(sign_data, secret_key);
|
||||||
let signed_tx_bytes : Uint8Array = vdk_aeser.signed_tx([signature], tx_bytes);
|
let signed_tx_bytes : Uint8Array = vdk_aeser.signed_tx([signature], tx_bytes);
|
||||||
let signed_tx_str : string = await vdk_aeser.baseNcheck('tx', signed_tx_bytes);
|
let signed_tx_str : string = await vdk_aeser.baseNcheck('tx', signed_tx_bytes);
|
||||||
|
|
||||||
|
// debugging
|
||||||
|
let mansplained_stx : object = await vdk_aeser.mansplain(signed_tx_str);
|
||||||
|
console.log('mansplained signed tx:', mansplained_stx);
|
||||||
|
|
||||||
return {signedTransaction: signed_tx_str};
|
return {signedTransaction: signed_tx_str};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,12 @@ export {
|
|||||||
shasha4,
|
shasha4,
|
||||||
unbaseNcheck,
|
unbaseNcheck,
|
||||||
baseNcheck,
|
baseNcheck,
|
||||||
signed_tx
|
signed_tx,
|
||||||
|
mansplain
|
||||||
|
}
|
||||||
|
|
||||||
|
export type {
|
||||||
|
baseNchecked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -165,8 +170,11 @@ unbase64check
|
|||||||
: Promise<baseNchecked>
|
: Promise<baseNchecked>
|
||||||
{
|
{
|
||||||
let bytes : Uint8Array = vdk_base64.decode(baseNstr);
|
let bytes : Uint8Array = vdk_base64.decode(baseNstr);
|
||||||
let check_bytes : Uint8Array = bytes.slice(0, 4);
|
// ah ok here is the bug
|
||||||
let data_bytes : Uint8Array = bytes.slice(4);
|
let bytes_len : number = bytes.byteLength;
|
||||||
|
let data_bytes_len : number = bytes_len - 4;
|
||||||
|
let data_bytes : Uint8Array = bytes.slice(0, data_bytes_len);
|
||||||
|
let check_bytes : Uint8Array = bytes.slice(data_bytes_len);
|
||||||
let correct_check_bytes : Uint8Array = await shasha4(data_bytes);
|
let correct_check_bytes : Uint8Array = await shasha4(data_bytes);
|
||||||
let check_passed : boolean = vdk_binary.bytes_eq(correct_check_bytes, check_bytes);
|
let check_passed : boolean = vdk_binary.bytes_eq(correct_check_bytes, check_bytes);
|
||||||
return {bytes : data_bytes,
|
return {bytes : data_bytes,
|
||||||
@@ -180,8 +188,10 @@ unbase58check
|
|||||||
: Promise<baseNchecked>
|
: Promise<baseNchecked>
|
||||||
{
|
{
|
||||||
let bytes : Uint8Array = vdk_base58.decode(baseNstr);
|
let bytes : Uint8Array = vdk_base58.decode(baseNstr);
|
||||||
let check_bytes : Uint8Array = bytes.slice(0, 4);
|
let bytes_len : number = bytes.byteLength;
|
||||||
let data_bytes : Uint8Array = bytes.slice(4);
|
let data_bytes_len : number = bytes_len - 4;
|
||||||
|
let data_bytes : Uint8Array = bytes.slice(0, data_bytes_len);
|
||||||
|
let check_bytes : Uint8Array = bytes.slice(data_bytes_len);
|
||||||
let correct_check_bytes : Uint8Array = await shasha4(data_bytes);
|
let correct_check_bytes : Uint8Array = await shasha4(data_bytes);
|
||||||
let check_passed : boolean = vdk_binary.bytes_eq(correct_check_bytes, check_bytes);
|
let check_passed : boolean = vdk_binary.bytes_eq(correct_check_bytes, check_bytes);
|
||||||
return {bytes : data_bytes,
|
return {bytes : data_bytes,
|
||||||
@@ -277,3 +287,40 @@ signed_tx
|
|||||||
// result is [tag, vsn, signatures, tx]
|
// result is [tag, vsn, signatures, tx]
|
||||||
return vdk_rlp.encode([tag_bytes, vsn_bytes, signatures, tx]);
|
return vdk_rlp.encode([tag_bytes, vsn_bytes, signatures, tx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take apart some API-encoded data and show its component parts
|
||||||
|
*
|
||||||
|
* For debugging purposes
|
||||||
|
*/
|
||||||
|
async function
|
||||||
|
mansplain
|
||||||
|
(api_str : string)
|
||||||
|
: Promise<object>
|
||||||
|
{
|
||||||
|
let prefix : string
|
||||||
|
|
||||||
|
let x = await unbaseNcheck(api_str);
|
||||||
|
|
||||||
|
let check_passed : boolean = x.check_passed;
|
||||||
|
let data_bytes : Uint8Array = x.bytes;
|
||||||
|
|
||||||
|
let mansplained_data : object = mansplain_bytes(data_bytes);
|
||||||
|
|
||||||
|
return {check_passed : check_passed,
|
||||||
|
data : mansplained_data};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take RLP encoded bytes and mansplain them
|
||||||
|
*/
|
||||||
|
function
|
||||||
|
mansplain_bytes
|
||||||
|
(data_bytes : Uint8Array)
|
||||||
|
: object
|
||||||
|
{
|
||||||
|
return vdk_rlp.decode(data_bytes);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user