[wip] add primitive message sign functionality
This commit is contained in:
@@ -27,60 +27,50 @@
|
||||
<!-- step 1 detect -->
|
||||
|
||||
<h1>1. Detect wallet</h1>
|
||||
<button id="detect">Detect</button>
|
||||
<h4 id="detected" style="color: red;">not detected</h4>
|
||||
<pre id="detect-info"></pre>
|
||||
<button id="detect">Detect</button>
|
||||
<h4 id="detected" style="color: red;">not detected</h4>
|
||||
<pre id="detect-info"></pre>
|
||||
|
||||
<h1>2. Connect to wallet</h1>
|
||||
<button id="connect">Connect</button>
|
||||
<h4 id="connected" style="color: red;">not connected</h4>
|
||||
<pre id="connect-info"></pre>
|
||||
<button id="connect">Connect</button>
|
||||
<h4 id="connected" style="color: red;">not connected</h4>
|
||||
<pre id="connect-info"></pre>
|
||||
|
||||
<h1>3. Get the wallet address</h1>
|
||||
<button id="address">Address</button>
|
||||
<h4 id="addressed" style="color: red;">not addressed</h4>
|
||||
<pre id="address-info"></pre>
|
||||
<button id="address">Address</button>
|
||||
<h4 id="addressed" style="color: red;">not addressed</h4>
|
||||
<pre id="address-info"></pre>
|
||||
|
||||
<h1>4. Sign a transaction</h1>
|
||||
|
||||
<h2>4.1 Transaction info (information needed from you)</h2>
|
||||
|
||||
<ol>
|
||||
<li>Source address (step 3): <code class="pv-address"></code></li>
|
||||
<li>Target address: <input type="text" id="tx-info-target" value="ak_wM8yFU8eSETXU7VSN48HMDmevGoCMiuveQZgkPuRn1nTiRqyv"></input></li>
|
||||
<li>Amount (aettos): <input type="text" id="tx-info-amount" value="10"></input></li>
|
||||
<li>Network: (FIXME: radio buttons)</li>
|
||||
</ol>
|
||||
<h2>4.1 Transaction info (information needed from you)</h2>
|
||||
<ol>
|
||||
<li>Source address (step 3): <code class="pv-address"></code></li>
|
||||
<li>Target address: <input type="text" id="tx-info-target" value="ak_wM8yFU8eSETXU7VSN48HMDmevGoCMiuveQZgkPuRn1nTiRqyv"></input></li>
|
||||
<li>Amount (aettos): <input type="text" id="tx-info-amount" value="10"></input></li>
|
||||
<li>Network: (FIXME: radio buttons)</li>
|
||||
</ol>
|
||||
<h2>4.2 Form transaction (using parasite)</h2>
|
||||
<p>This uses a shim JavaScript library called parasite to form the transaction
|
||||
data for the wallet to sign. In a commercial application, this should be done
|
||||
by your backend</p>
|
||||
<button id='mk-spendtx'>Make SpendTx</button>
|
||||
<h5>SpendTx JS object</h5>
|
||||
<pre id="spendtx-json"></pre>
|
||||
<h5>SpendTx Base64</h5>
|
||||
<pre class="pv-spendtx-base64"></pre>
|
||||
<h2>4.3 Sign the transaction (sidekick)</h2>
|
||||
<ol>
|
||||
<li><pre class="pv-spendtx-base64"></pre></li>
|
||||
</ol>
|
||||
<button id="sign-spendtx">Sign Transaction</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>
|
||||
|
||||
|
||||
<h2>4.2 Form transaction (using parasite)</h2>
|
||||
|
||||
<p>This uses a shim JavaScript library called parasite to form the transaction
|
||||
data for the wallet to sign. In a commercial application, this should be done
|
||||
by your backend</p>
|
||||
|
||||
<button id='mk-spendtx'>Make SpendTx</button>
|
||||
|
||||
<h5>SpendTx JS object</h5>
|
||||
<pre id="spendtx-json"></pre>
|
||||
|
||||
<h5>SpendTx Base64</h5>
|
||||
<pre class="pv-spendtx-base64"></pre>
|
||||
|
||||
<h2>4.3 Sign the transaction (sidekick)</h2>
|
||||
|
||||
<ol>
|
||||
<li><pre class="pv-spendtx-base64"></pre></li>
|
||||
</ol>
|
||||
|
||||
<button id="sign-spendtx">Sign Transaction</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>
|
||||
<h1>5. Sign a message</h1>
|
||||
<button id="sign-message">Sign Message</button>
|
||||
|
||||
<!-- script -->
|
||||
<script type="module" src="dist/connection.js"></script>
|
||||
|
||||
@@ -197,6 +197,13 @@ sign_tx
|
||||
document.getElementById("sign-spendtx-result")!.innerHTML = JSON.stringify(signedTx, undefined, 4);
|
||||
}
|
||||
|
||||
async function sign_msg(logger: sk.Logger): Promise<void> {
|
||||
console.log('poop');
|
||||
let acc_pubkey : string = pv_address;
|
||||
let signed_msg = await sk.msg_sign('sk-msg-sign-1', acc_pubkey, 'I make stinky poo poo', sk.TIMEOUT_DEF_TX_SIGN_NOPROP_MS, 'stinky poo poo too long', logger);
|
||||
console.log('signed message:', signed_msg);
|
||||
}
|
||||
|
||||
function
|
||||
main
|
||||
()
|
||||
@@ -212,6 +219,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-message')!.onclick = function() { sign_msg(logger); };
|
||||
|
||||
//set_pv_address("ak_2XhCkjzTwcq1coXSSzHJoMZkUzTwnjH88zmPGkkowUsFNTo9UE");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user