From 98aa2e52524f4f9aa000d62d9f948aa712e861b8 Mon Sep 17 00:00:00 2001 From: Antoine De Vuyst Date: Tue, 29 Oct 2019 13:37:01 -0400 Subject: [PATCH 01/10] update --- README.md | 3 +- examples/functions.js | 15 ++++---- tutorials/1-Metaverse-Wallet/README.md | 11 +++--- tutorials/1-Metaverse-Wallet/index2.html | 43 ---------------------- tutorials/1-Metaverse-Wallet/solution.html | 1 - tutorials/1-Metaverse-Wallet/solution.js | 2 - tutorials/2-Avatars-and-MSTs/solution.js | 11 +++++- tutorials/3-MITs/solution.js | 1 - 8 files changed, 22 insertions(+), 65 deletions(-) delete mode 100644 tutorials/1-Metaverse-Wallet/index2.html diff --git a/README.md b/README.md index 2f313bc..26ae346 100644 --- a/README.md +++ b/README.md @@ -128,8 +128,7 @@ and add ``` - -To interact with webapps you must generate "index.js" from mvs-blockchain-js and "metaverse.min.js" from metaversejs. To generate these files you must clone each repository and simply run +To interact with webapps you must generate "index.js" from mvs-blockchain-js and "metaverse.min.js" from metaversejs. To generate these files you must clone each repository separately, namely [metaversjs](https://github.com/canguruhh/metaversejs) and [mvs-blockchain-js](https://github.com/mvs-org/mvs-blockchain-js) and simply run ``` grunt diff --git a/examples/functions.js b/examples/functions.js index 670cd78..1d94aa5 100644 --- a/examples/functions.js +++ b/examples/functions.js @@ -5,7 +5,7 @@ let blockchain = require('../mvs-blockchain-js')({ let Metaverse = require('metaversejs'); var wallet -var mnemonic = "van juice oak general lyrics gravity hammer shield over eager crew volume survey join lonely purchase kitten artwork mass cousin process mixture add knife" +var mnemonic = "butter vacuum breeze glow virtual mutual veteran argue want pipe elite blast judge write sand toilet file joy exotic reflect truck topic receive wait" var addresses var balances @@ -22,7 +22,7 @@ async function run(){ console.log("Sending ETP..............") let amountToSend = 10000000 - //await sendETP(amountToSend) + await sendETP(amountToSend) console.log("ETP Sent") console.log("Depositing ETP............") @@ -32,8 +32,8 @@ async function run(){ console.log("ETP deposited") console.log("Registering Avatar............") - let avatarName = "testguy3" - let avatarAddress = wallet.getAddress(0) + let avatarName = "testguy4" + let avatarAddress = wallet.getAddress(2) //await registerAvatar(avatarName,avatarAddress) console.log("avatar " + avatarName + " Registered to " + avatarAddress) @@ -55,14 +55,14 @@ async function run(){ var target = { "COOOL": 1 }; - await sendMST(target) + //await sendMST(target) console.log("MST Sent") console.log("Registering MIT................") - let MITsymbol = "testar2" + let MITsymbol = "testar7" let avatar = "testguy3" let content = "some test content" //await issueMIT(avatar,MITsymbol,content) @@ -75,7 +75,7 @@ async function run(){ let MITToSend = "testar" let sender_avatar = "testguy3" let recipient_avatar = "Tal" - await sendMIT(sender_avatar,recipient_avatar,MITToSend) +// await sendMIT(sender_avatar,recipient_avatar,MITToSend) } @@ -101,7 +101,6 @@ async function getBalances(){ let height = await blockchain.height() let txs = await blockchain.addresses.txs(wallet.getAddresses()) - console.log(txs) let utxo = await Metaverse.output.calculateUtxo(txs.transactions, wallet.getAddresses()) let balances = await blockchain.balance.all(utxo, wallet.getAddresses(), height) diff --git a/tutorials/1-Metaverse-Wallet/README.md b/tutorials/1-Metaverse-Wallet/README.md index df8debb..9da1d4d 100644 --- a/tutorials/1-Metaverse-Wallet/README.md +++ b/tutorials/1-Metaverse-Wallet/README.md @@ -32,7 +32,7 @@ Start by setting up a directory to work in ``` cd MetaverseTutorials/tutorials/playground -touch tut1.html +touch index.html touch tut1.js ``` @@ -77,6 +77,8 @@ Open tut1.html and use this HTML front end as the base of your app. ``` + + You should now be set up to use the Metaverse javascript libraries. We are using the async/await syntax. The await keyword can only be used in async functions so we will create async functions to perform all actions. First lets define some key variables @@ -234,9 +236,6 @@ Next serve the webpage with python -m SimpleHTTPServer 3333 ``` -or however you prefer - -Verify that you have connected metaverse to the webapp by opening the browser console and typing "Metaverse". You should see the Metaverse object come up and look something like +or however you prefer. -_TODO: Expand upon once metaversjs referencing is completed_ -Now connect elements to the js functions and youre done! +The next step is to connect the elements to the functions diff --git a/tutorials/1-Metaverse-Wallet/index2.html b/tutorials/1-Metaverse-Wallet/index2.html deleted file mode 100644 index 579bdd1..0000000 --- a/tutorials/1-Metaverse-Wallet/index2.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - -

Create new Wallet

- - - -

Send ETP

- - - -

Check ETP Balance

- -

Issue MST

- -

Send MST

- -

Deposit

- -

Create Avatar

- -

Get Avatar

- -

Create MIT

- -

Transfer MIT

- -

Send Multisig transaction

- -

Send Locked Asset

- - - - diff --git a/tutorials/1-Metaverse-Wallet/solution.html b/tutorials/1-Metaverse-Wallet/solution.html index 736ebfe..9a833c3 100644 --- a/tutorials/1-Metaverse-Wallet/solution.html +++ b/tutorials/1-Metaverse-Wallet/solution.html @@ -28,7 +28,6 @@
Addresses and Balances
-

Send ETP

diff --git a/tutorials/1-Metaverse-Wallet/solution.js b/tutorials/1-Metaverse-Wallet/solution.js index 430e8ee..dcd4b63 100644 --- a/tutorials/1-Metaverse-Wallet/solution.js +++ b/tutorials/1-Metaverse-Wallet/solution.js @@ -12,8 +12,6 @@ var hidden = true async function initialize(){ blockchain = await Blockchain({url: "https://explorer-testnet.mvs.org/api/"}) - let test = document.getElementById("addressSelect") - console.log(test) } async function generateMnemonic(){ diff --git a/tutorials/2-Avatars-and-MSTs/solution.js b/tutorials/2-Avatars-and-MSTs/solution.js index 2d5a361..4ac7921 100644 --- a/tutorials/2-Avatars-and-MSTs/solution.js +++ b/tutorials/2-Avatars-and-MSTs/solution.js @@ -71,12 +71,19 @@ async function issueMST(){ let txs = await blockchain.addresses.txs(wallet.getAddresses()) let utxos = await Metaverse.output.calculateUtxo(txs.transactions, wallet.getAddresses()) //Get all utxo let result = await Metaverse.output.findUtxo(utxos, {}, height, 1000000000) //Collect utxo to pay for the fee of 10 ETP - let tx = await Metaverse.transaction_builder.issueAsset(result.utxo, recipient_address, symbol, max_supply, precision, issuer, description, 0,false, change_address, result.change,true,0,'testnet',null,undefined) - console.log(tx); + console.log(result.utxo) + let tx = await Metaverse.transaction_builder.issueAsset(result.utxo, recipient_address, symbol, max_supply, precision, issuer, description, 0,false, change_address, result.change,false,0,'testnet') + console.log(tx); tx = await wallet.sign(tx) + console.log(tx); + tx = await tx.encode() + console.log(tx); + tx = await tx.toString('hex') + console.log(tx); + tx = await blockchain.transaction.broadcast(tx) console.log(tx); diff --git a/tutorials/3-MITs/solution.js b/tutorials/3-MITs/solution.js index 53e5675..0e2a624 100644 --- a/tutorials/3-MITs/solution.js +++ b/tutorials/3-MITs/solution.js @@ -30,7 +30,6 @@ async function initialize(){ // .then(tx=>tx.toString('hex')) console.log(tx) - } From ce96ef57ef90cfca25c5ce0f111715fcbcfb3e55 Mon Sep 17 00:00:00 2001 From: Antoine De Vuyst Date: Tue, 29 Oct 2019 16:21:07 -0400 Subject: [PATCH 02/10] fixed Tutorial 2 solution --- examples/functions.js | 18 ++--- tutorials/2-Avatars-and-MSTs/solution.html | 9 ++- tutorials/2-Avatars-and-MSTs/solution.js | 92 ++++++++++++++++------ tutorials/playground/index.html | 11 +++ tutorials/playground/testScript.js | 15 ++++ 5 files changed, 109 insertions(+), 36 deletions(-) create mode 100644 tutorials/playground/index.html create mode 100644 tutorials/playground/testScript.js diff --git a/examples/functions.js b/examples/functions.js index 1d94aa5..33bef10 100644 --- a/examples/functions.js +++ b/examples/functions.js @@ -22,7 +22,7 @@ async function run(){ console.log("Sending ETP..............") let amountToSend = 10000000 - await sendETP(amountToSend) + //wait sendETP(amountToSend) console.log("ETP Sent") console.log("Depositing ETP............") @@ -32,24 +32,24 @@ async function run(){ console.log("ETP deposited") console.log("Registering Avatar............") - let avatarName = "testguy4" + let avatarName = "canfr" let avatarAddress = wallet.getAddress(2) //await registerAvatar(avatarName,avatarAddress) console.log("avatar " + avatarName + " Registered to " + avatarAddress) console.log("getting Avatar Info......") - let avatarInfo = await getAvatarInfo("Tal") + let avatarInfo = await getAvatarInfo("PEI") console.log(avatarInfo) console.log("Issuing MST.............") - let issuingAddress = wallet.getAddress(0), - symbol = 'COOOL', + let issuingAddress = wallet.getAddress(2), + symbol = 'AABBCCDD', max_supply = 100000, precision = 8, - issuer = 'testguy3', + issuer = 'cangr', description = 'cool asset is cool'; - //await issueMST(issuingAddress,symbol,max_supply,precision,issuer,description) + await issueMST(issuingAddress,symbol,max_supply,precision,issuer,description) console.log("Transferring MST.............") var target = { @@ -225,8 +225,8 @@ async function issueMIT(issuer_avatar,symbol,content){ ETP: 10000 }; - let recipient_address = wallet.getAddress(0) - let change_address = wallet.getAddress(0) + let recipient_address = wallet.getAddress(2) + let change_address = wallet.getAddress(2) let height = await blockchain.height() let txs = await blockchain.addresses.txs(wallet.getAddresses()) diff --git a/tutorials/2-Avatars-and-MSTs/solution.html b/tutorials/2-Avatars-and-MSTs/solution.html index ee70fd7..bf0f773 100644 --- a/tutorials/2-Avatars-and-MSTs/solution.html +++ b/tutorials/2-Avatars-and-MSTs/solution.html @@ -46,15 +46,18 @@

Balances

+ +
Symbol AmountDecimals

Send MST

-