launchpad-ledger: Add MsgSend to demo
This commit is contained in:
parent
4b9b40f69b
commit
e89c456634
@ -20,5 +20,5 @@ input {
|
||||
|
||||
textarea {
|
||||
width: 32em;
|
||||
height: 14em;
|
||||
height: 28em;
|
||||
}
|
||||
|
||||
@ -31,17 +31,6 @@
|
||||
<div>
|
||||
<label>Message</label>
|
||||
<textarea id="message">
|
||||
{
|
||||
"account_number": 0,
|
||||
"chain_id": "testing",
|
||||
"fee": {
|
||||
"amount": [{ "amount": 100, "denom": "ucosm" }],
|
||||
"gas": 250
|
||||
},
|
||||
"memo": "Some memo",
|
||||
"msgs": [],
|
||||
"sequence": 0
|
||||
}
|
||||
</textarea>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@ -5,18 +5,45 @@ import { LedgerSigner } from "../ledgersigner";
|
||||
declare const window: any;
|
||||
declare const document: any;
|
||||
|
||||
function createMessage(address: string): string {
|
||||
return `{
|
||||
"account_number": 0,
|
||||
"chain_id": "testing",
|
||||
"fee": {
|
||||
"amount": [{ "amount": 100, "denom": "ucosm" }],
|
||||
"gas": 250
|
||||
},
|
||||
"memo": "Some memo",
|
||||
"msgs": [{
|
||||
"type": "cosmos-sdk/MsgSend",
|
||||
"value": {
|
||||
"amount": [{
|
||||
"amount": "1234567",
|
||||
"denom": "ucosm"
|
||||
}],
|
||||
"from_address": "${address}",
|
||||
"to_address": "${address}"
|
||||
}
|
||||
}],
|
||||
"sequence": 0
|
||||
}`;
|
||||
}
|
||||
|
||||
const signer = new LedgerSigner({ testModeAllowed: true });
|
||||
|
||||
window.getAccounts = async function getAccounts(): Promise<void> {
|
||||
const addressInput = document.getElementById("address");
|
||||
const accountsDiv = document.getElementById("accounts");
|
||||
const messageTextArea = document.getElementById("message");
|
||||
accountsDiv.textContent = "Loading...";
|
||||
|
||||
try {
|
||||
const accounts = await signer.getAccounts();
|
||||
const prettyAccounts = accounts.map((account) => ({ ...account, pubkey: toHex(account.pubkey) }));
|
||||
accountsDiv.textContent = JSON.stringify(prettyAccounts, null, "\t");
|
||||
addressInput.value = accounts[0].address;
|
||||
const address = accounts[0].address;
|
||||
addressInput.value = address;
|
||||
messageTextArea.textContent = createMessage(address);
|
||||
} catch (error) {
|
||||
accountsDiv.textContent = error;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user