Merge pull request #5 from aeternity/pharpend/sidekick-tx-sign-yesprop
Add tx_sign_yesprop function
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{type, library}.
|
||||
{realm, local}.
|
||||
{name, awcp}.
|
||||
{version, "0.2.1"}.
|
||||
{version, "0.2.2"}.
|
||||
{deps, []}.
|
||||
|
||||
+178
-7
@@ -257,13 +257,13 @@ export {
|
||||
RpcResp_W2A_address_subscribe,
|
||||
EventData_A2W_address_subscribe,
|
||||
EventData_W2A_address_subscribe,
|
||||
//// transaction.sign (propagate)
|
||||
//Params_A2W_tx_sign_yesprop,
|
||||
//Result_W2A_tx_sign_yesprop,
|
||||
//RpcCall_A2W_tx_sign_yesprop,
|
||||
//RpcResp_W2A_tx_sign_yesprop,
|
||||
//EventData_A2W_tx_sign_yesprop,
|
||||
//EventData_W2A_tx_sign_yesprop,
|
||||
// transaction.sign (propagate)
|
||||
Params_A2W_tx_sign_yesprop,
|
||||
Result_W2A_tx_sign_yesprop,
|
||||
RpcCall_A2W_tx_sign_yesprop,
|
||||
RpcResp_W2A_tx_sign_yesprop,
|
||||
EventData_A2W_tx_sign_yesprop,
|
||||
EventData_W2A_tx_sign_yesprop,
|
||||
// transaction.sign (do not propagate)
|
||||
Params_A2W_tx_sign_noprop,
|
||||
Result_W2A_tx_sign_noprop,
|
||||
@@ -1110,6 +1110,177 @@ type EventData_W2A_address_subscribe
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// transaction.sign (do propagate)
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parameters for "transaction.sign" (do propagate)
|
||||
*
|
||||
* If `returnSigned` is `false`, then Superhero will propagate the transaction.
|
||||
*
|
||||
* (layer 4)
|
||||
*
|
||||
* @example
|
||||
* ```json
|
||||
* {
|
||||
* "tx": "tx_+FgMAaEBuzbuuWjOzR7ecjOY8+u7HdNk0KoxTQcCDerZELEQ+UShAXtm5sMFBwg25Ol5IFI9w+pZy7/YbFi6BwPqi80KuKdsCoYPJvVhyAAAAYdoYWluYW5h9uAnNQ==",
|
||||
* "returnSigned": false,
|
||||
* "networkId": "ae_uat"
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
type Params_A2W_tx_sign_yesprop
|
||||
= {tx : string,
|
||||
returnSigned : false,
|
||||
networkId : string}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Success result type for "transaction.sign" (do propagate)
|
||||
*
|
||||
* (layer 4)
|
||||
*
|
||||
* @example
|
||||
* ```json
|
||||
* "transactionHash": {
|
||||
* "blockHash": "mh_uJZ65APpLtiagJKjTNPZL1g1LJ7oqc2uG44qVqp1gVWwWUgLb",
|
||||
* "blockHeight": 806313,
|
||||
* "hash": "th_o3cudpezVywd99a7VMef9Yg7XPixTFueaCqGjdsnqLM99a78t",
|
||||
* "signatures": [
|
||||
* "sg_U36NDTFJFP4QEWCdjyhELDUDxsVGZNkq3DrcBCxby4NPUsPjQsFDG7VHN9s7TNUsEAd7qdC5aEjZKrqsKyfqA8apNrotz"
|
||||
* ],
|
||||
* "tx": {
|
||||
* "amount": 10,
|
||||
* "fee": 16800000000000,
|
||||
* "nonce": 13,
|
||||
* "payload": "ba_aGFpbmFuYWbkNu8=",
|
||||
* "recipientId": "ak_wM8yFU8eSETXU7VSN48HMDmevGoCMiuveQZgkPuRn1nTiRqyv",
|
||||
* "senderId": "ak_2XhCkjzTwcq1coXSSzHJoMZkUzTwnjH88zmPGkkowUsFNTo9UE",
|
||||
* "type": "SpendTx",
|
||||
* "version": 1
|
||||
* },
|
||||
* "rawTx": "tx_+KILAfhCuEDOpyHRaYj8MnRwqOzMyRJSh4qud6jRK01wiAWfRHBDo/4e9klk7MsvM0Cr0ENaNkqKfwCDcaga/iDnogN5cukNuFr4WAwBoQHJY35GAOerO8Lmf8ZA6CN2RET0MFXaXVV4pJo3WvoY3KEBe2bmwwUHCDbk6XkgUj3D6lnLv9hsWLoHA+qLzQq4p2wKhg9HjghAAAANh2hhaW5hbmHkTCSc"
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
type Result_W2A_tx_sign_yesprop
|
||||
= {transactionHash : {blockHash : string,
|
||||
blockHeight : number,
|
||||
hash : string,
|
||||
signatures : Array<string>,
|
||||
tx : {amount : number,
|
||||
fee : number,
|
||||
nonce : number,
|
||||
payload : string,
|
||||
recipientId : string,
|
||||
senderId : string,
|
||||
type : string,
|
||||
version : number},
|
||||
rawTx : string}};
|
||||
|
||||
|
||||
/**
|
||||
* Request type for "transaction.sign" (do propagate)
|
||||
*
|
||||
* (layer 3)
|
||||
*
|
||||
* @example
|
||||
* ```json
|
||||
* {
|
||||
* "jsonrpc": "2.0",
|
||||
* "id": "sk-tx-sign-1",
|
||||
* "method": "transaction.sign",
|
||||
* "params": {
|
||||
* "tx": "tx_+FgMAaEBuzbuuWjOzR7ecjOY8+u7HdNk0KoxTQcCDerZELEQ+UShAXtm5sMFBwg25Ol5IFI9w+pZy7/YbFi6BwPqi80KuKdsCoYPJvVhyAAAAYdoYWluYW5h9uAnNQ==",
|
||||
* "returnSigned": true,
|
||||
* "networkId": "ae_uat"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
type RpcCall_A2W_tx_sign_yesprop
|
||||
= RpcCall<"transaction.sign",
|
||||
Params_A2W_tx_sign_yesprop>;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Response type for "transaction.sign" (do propagate)
|
||||
*
|
||||
* (layer 3)
|
||||
*
|
||||
* @example
|
||||
* ```json
|
||||
* {
|
||||
* "jsonrpc": "2.0",
|
||||
* "id": "sk-tx-sign-1",
|
||||
* "method": "transaction.sign",
|
||||
* "result": {
|
||||
* "signedTransaction": "tx_+KILAfhCuEDxWnvffMvyrkFWnrImYej38rh99vM9f6pORl/yWTvU97nvUcY8/ck8lgtPA8w5odGSDb9LGY/JSZXsmsXhgKkHuFr4WAwBoQG7Nu65aM7NHt5yM5jz67sd02TQqjFNBwIN6tkQsRD5RKEBe2bmwwUHCDbk6XkgUj3D6lnLv9hsWLoHA+qLzQq4p2wKhg8m9WHIAAABh2hhaW5hbmF7X54G"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
type RpcResp_W2A_tx_sign_yesprop
|
||||
= RpcResp<"transaction.sign",
|
||||
Result_W2A_tx_sign_yesprop>;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Event data for aepp-to-waellet "transaction.sign" (do propagate) message
|
||||
*
|
||||
* (layer 2)
|
||||
*
|
||||
* @example
|
||||
* ```json
|
||||
* {
|
||||
* "type": "to_waellet",
|
||||
* "data": {
|
||||
* "jsonrpc": "2.0",
|
||||
* "id": "sk-tx-sign-1",
|
||||
* "method": "transaction.sign",
|
||||
* "params": {
|
||||
* "tx": "tx_+FgMAaEBuzbuuWjOzR7ecjOY8+u7HdNk0KoxTQcCDerZELEQ+UShAXtm5sMFBwg25Ol5IFI9w+pZy7/YbFi6BwPqi80KuKdsCoYPJvVhyAAAAYdoYWluYW5h9uAnNQ==",
|
||||
* "returnSigned": false,
|
||||
* "networkId": "ae_uat"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
type EventData_A2W_tx_sign_yesprop
|
||||
= EventData_A2W<RpcCall_A2W_tx_sign_yesprop>;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Event data for waellet-to-aepp "transaction.sign" (do propagate) response
|
||||
*
|
||||
* (layer 2)
|
||||
*
|
||||
* @example
|
||||
* ```json
|
||||
* {
|
||||
* "type": "to_aepp",
|
||||
* "data": {
|
||||
* "jsonrpc": "2.0",
|
||||
* "id": "sk-tx-sign-1",
|
||||
* "method": "transaction.sign",
|
||||
* "result": {
|
||||
* "signedTransaction": "tx_+KILAfhCuEDxWnvffMvyrkFWnrImYej38rh99vM9f6pORl/yWTvU97nvUcY8/ck8lgtPA8w5odGSDb9LGY/JSZXsmsXhgKkHuFr4WAwBoQG7Nu65aM7NHt5yM5jz67sd02TQqjFNBwIN6tkQsRD5RKEBe2bmwwUHCDbk6XkgUj3D6lnLv9hsWLoHA+qLzQq4p2wKhg8m9WHIAAABh2hhaW5hbmF7X54G"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
type EventData_W2A_tx_sign_yesprop
|
||||
= EventData_W2A<RpcResp_W2A_tx_sign_yesprop>;
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// transaction.sign (do not propagate)
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{type, library}.
|
||||
{realm, local}.
|
||||
{name, parasite}.
|
||||
{version, "0.2.0"}.
|
||||
{version, "0.2.2"}.
|
||||
{deps, []}.
|
||||
|
||||
@@ -23,7 +23,7 @@ import * as ae_compiler from './ae_compiler.js'
|
||||
// CONSTANTS
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
export const MIN_FEE = 16660000000000;
|
||||
export const MIN_FEE = 16800000000000;
|
||||
export const MIN_CONTRACT_FEE = 79080000000000;
|
||||
export const MIN_GAS_PRICE = 1000000000;
|
||||
export const URL_MAINNET = "https://mainnet.aeternity.io/v3";
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{type, library}.
|
||||
{realm, local}.
|
||||
{name, sidekick}.
|
||||
{version, "0.2.1"}.
|
||||
{deps, ["local-awcp-0.2.1"]}.
|
||||
{version, "0.2.2"}.
|
||||
{deps, ["local-awcp-0.2.2"]}.
|
||||
|
||||
@@ -79,6 +79,7 @@ export {
|
||||
// connect
|
||||
connect,
|
||||
address,
|
||||
tx_sign_yesprop,
|
||||
tx_sign_noprop,
|
||||
msg_sign,
|
||||
|
||||
@@ -92,7 +93,7 @@ export {
|
||||
// IMPORTS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
import * as awcp from './jex_include/local-awcp-0.2.1/dist/awcp.js';
|
||||
import * as awcp from './jex_include/local-awcp-0.2.2/dist/awcp.js';
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1038,8 +1039,44 @@ msg_sign
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// API: tx sign (no prop)
|
||||
// API: tx sign (do prop)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Ask the wallet to sign the transaction and propagate it into the network
|
||||
*/
|
||||
async function
|
||||
tx_sign_yesprop
|
||||
(id : number | string,
|
||||
params : awcp.Params_A2W_tx_sign_yesprop,
|
||||
timeout_ms : number,
|
||||
timeout_msg : string,
|
||||
logger : Logger)
|
||||
: Promise<Safe<awcp.Result_W2A_tx_sign_yesprop, awcp.RpcError | SkTimeoutError>>
|
||||
{
|
||||
logger.debug('address', {id:id, params:params, timeout_ms:timeout_ms, timeout_msg:timeout_msg});
|
||||
let msgr = new MsgR(logger);
|
||||
// FIXME: for type purposes, making the correct RPC message should be up here
|
||||
// this way we can enforce that it's a correct RPC call with typescript
|
||||
// Ideal:
|
||||
// let result = await msgr.send_raseev(id, awcp.METHOD_CONNECTION_OPEN, params, target, timeout_ms, timeout_msg);
|
||||
let result =
|
||||
await msgr.send_raseev
|
||||
<"transaction.sign", awcp.Params_A2W_tx_sign_yesprop, awcp.Result_W2A_tx_sign_yesprop>
|
||||
(id, "transaction.sign", params, timeout_ms, timeout_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// API: tx sign (do not propagate transaction)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Ask the wallet to sign the transaction but do not propagate the transaction,
|
||||
* instead just return the signed data
|
||||
*/
|
||||
async function
|
||||
tx_sign_noprop
|
||||
(id : number | string,
|
||||
|
||||
@@ -62,11 +62,17 @@
|
||||
<ol>
|
||||
<li><pre class="pv-spendtx-base64"></pre></li>
|
||||
</ol>
|
||||
<button id="sign-spendtx">Sign Transaction</button>
|
||||
|
||||
<button id="sign-spendtx">Sign Transaction but do not propagate</button>
|
||||
<h5>Result:</h5>
|
||||
<pre id="sign-spendtx-result"></pre>
|
||||
<h2>4.4 Propagate the transaction (parasite)</h2>
|
||||
<h2>4.5 Verify the transaction was propagated (parasite)</h2>
|
||||
|
||||
<br>
|
||||
<button id="sign-spendtx-prop">Sign Transaction and have superhero propagate transaction</button>
|
||||
<h5>Result:</h5>
|
||||
<pre id="sign-spendtx-prop-result"></pre>
|
||||
<h2>4.4 Propagate the transaction (parasite) FIXME</h2>
|
||||
<h2>4.5 Verify the transaction was propagated (parasite) FIXME</h2>
|
||||
|
||||
|
||||
<h1>5. Sign a message</h1>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{type, library}.
|
||||
{realm, local}.
|
||||
{name, sidekick_examples}.
|
||||
{version, "0.1.0"}.
|
||||
{deps, ["local-awcp-0.2.1",
|
||||
"local-parasite-0.2.0",
|
||||
"local-sidekick-0.2.1"]}.
|
||||
{version, "0.2.2"}.
|
||||
{deps, ["local-awcp-0.2.2",
|
||||
"local-parasite-0.2.2",
|
||||
"local-sidekick-0.2.2"]}.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as ae_node from './jex_include/local-parasite-0.2.0/dist/ae_node.js';
|
||||
import * as awcp from './jex_include/local-awcp-0.2.1/dist/awcp.js';
|
||||
import * as sk from './jex_include/local-sidekick-0.2.1/dist/sidekick.js';
|
||||
import * as ae_node from './jex_include/local-parasite-0.2.2/dist/ae_node.js';
|
||||
import * as awcp from './jex_include/local-awcp-0.2.2/dist/awcp.js';
|
||||
import * as sk from './jex_include/local-sidekick-0.2.2/dist/sidekick.js';
|
||||
|
||||
var pv_address: string;
|
||||
var pv_spendtx_base64: string;
|
||||
@@ -181,6 +181,7 @@ form_tx
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
async function
|
||||
sign_tx
|
||||
(logger: sk.Logger)
|
||||
@@ -197,6 +198,24 @@ sign_tx
|
||||
document.getElementById("sign-spendtx-result")!.innerHTML = JSON.stringify(signedTx, undefined, 4);
|
||||
}
|
||||
|
||||
|
||||
async function
|
||||
sign_tx_prop
|
||||
(logger: sk.Logger)
|
||||
: Promise<void>
|
||||
{
|
||||
let sign_params = {
|
||||
tx: pv_spendtx_base64,
|
||||
// returnsigned: false tells it to propagate the transaction
|
||||
// returnsigned: true just signs it and returns the signed tx back
|
||||
returnSigned: false as false,
|
||||
networkId: "ae_uat"
|
||||
};
|
||||
let signedTx = await sk.tx_sign_yesprop('sk-tx-sign-2', sign_params, sk.TIMEOUT_DEF_TX_SIGN_NOPROP_MS, 'sign transaction timed out', logger);
|
||||
document.getElementById("sign-spendtx-prop-result")!.innerHTML = JSON.stringify(signedTx, undefined, 4);
|
||||
}
|
||||
|
||||
|
||||
async function
|
||||
sign_msg
|
||||
(logger: sk.Logger)
|
||||
@@ -224,6 +243,7 @@ main
|
||||
document.getElementById('address')!.onclick = function() { address(logger); };
|
||||
document.getElementById('mk-spendtx')!.onclick = function() { form_tx(logger); };
|
||||
document.getElementById('sign-spendtx')!.onclick = function() { sign_tx(logger); };
|
||||
document.getElementById('sign-spendtx-prop')!.onclick = function() { sign_tx_prop(logger); };
|
||||
document.getElementById('sign-message')!.onclick = function() { sign_msg(logger); };
|
||||
|
||||
//set_pv_address("ak_2XhCkjzTwcq1coXSSzHJoMZkUzTwnjH88zmPGkkowUsFNTo9UE");
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import * as sk from './jex_include/local-sidekick-0.2.1/dist/sidekick.js';
|
||||
import * as sk from './jex_include/local-sidekick-0.2.2/dist/sidekick.js';
|
||||
|
||||
sk.hello();
|
||||
|
||||
+31
-12
@@ -95,12 +95,14 @@
|
||||
TypeScript stuff (hurray).</p>
|
||||
|
||||
<p>Vanillae started as our own internal toolset that we developed in the
|
||||
process of making <a href="https://aegora.jp/">Aegora.jp</a>. In
|
||||
particular, Craig developed Vanillae.erl because talking to the blockchain
|
||||
was needlessly annoying, and Peter developed Sidekick because the Æternity
|
||||
JavaScript SDK was (is) impossible to use. We then open-sourced our
|
||||
tooling, and the Æternity Foundation decided to pay us to continue to
|
||||
develop it and expand it.</p>
|
||||
process of making <a href="https://aegora.jp/">Aegora.jp</a>. Aegora is a
|
||||
normal, vanilla, e-commerce site. We just happen to use Æternity as the
|
||||
payment backend. In particular, Craig developed Vanillae.erl because
|
||||
talking to the blockchain from the server backend was needlessly annoying,
|
||||
and Peter developed Sidekick because the Æternity JavaScript SDK was (is)
|
||||
impossible to use. We then open-sourced our "talk to Æternity" tooling,
|
||||
and the Æternity Foundation decided to pay us to continue to develop it and
|
||||
expand it.</p>
|
||||
|
||||
<p>Aegora is the first normal e-commerce platform that utilizes any form of
|
||||
cryptocurrency. We would like if Aegora made us billionaires, but really
|
||||
@@ -120,17 +122,34 @@
|
||||
|
||||
<p>Our hypothesis is that most cryptocurrencies (i.e. every coin except
|
||||
Æternity) are technically deficient to the point that they are totally
|
||||
useless in the space of Things That Actually Have To Work (i.e.
|
||||
business).</p>
|
||||
useless in The Space Of Things That Actually Have To Work (e.g.
|
||||
non-scam commerce). To test this hypothesis, our goal is to make Æternity
|
||||
easily usable and see if people start using it in The Space Of Things That
|
||||
Actually Have To Work.</p>
|
||||
|
||||
<p>As of July 2023, Æternity is still in the same usability class as Arch
|
||||
Linux. Our goal with this project to get to like Debian.<p>
|
||||
|
||||
<p>From our personal experience building Aegora, <i>once you understand how
|
||||
to use it</i>, Æternity is <b><i>by far</i></b> the easiest electronic
|
||||
payment system to use in a commercial application. It is the genuine
|
||||
manifestation of Satoshi's dream.</p>
|
||||
</div>
|
||||
|
||||
<div class="section yellowish" id="s-vanillae-erl">
|
||||
<h2>4. Vanillae.erl</h2>
|
||||
|
||||
<p>
|
||||
This is an Erlang application that smooths over the rough edges
|
||||
involved in talking to Æternity nodes.
|
||||
</p>
|
||||
<p>This is an Erlang application that smooths over the rough edges
|
||||
involved in talking to Æternity nodes from an Erlang program.</p>
|
||||
|
||||
<p>Vanillae.erl is also a standard that is meant to be mimicked in other
|
||||
languages. The idea is to have a "library" (Erlangers: it's an Erlang
|
||||
application) of Erlang function calls that return natural Erlang data
|
||||
structures. The API is designed in such a way that the API should
|
||||
generalize to other languages. We would like there to be a Vanillae.py for
|
||||
instance (Python 2 of course), which would maybe require startup or
|
||||
something, maybe the natural idiom would be whatever you do to make `with`
|
||||
syntax work, whatever. The point is, there should be a
|
||||
</div>
|
||||
|
||||
<div class="section skyish" id="s-sidekick">
|
||||
|
||||
Reference in New Issue
Block a user