From a11746d043d74edf38c12c2855f4f194edcdc088 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 2 Jul 2022 19:44:41 -0600 Subject: [PATCH 1/2] chore: npm run fmt --- 1-Identities-and-Names/identity-register.js | 12 ++++---- .../identity-retrieve-account-ids.js | 12 ++++---- 1-Identities-and-Names/identity-retrieve.js | 8 ++--- 1-Identities-and-Names/identity-topup.js | 12 ++++---- 1-Identities-and-Names/name-register-alias.js | 14 ++++----- 1-Identities-and-Names/name-register.js | 14 ++++----- .../name-resolve-by-name.js | 10 +++---- .../name-resolve-by-record.js | 12 ++++---- 1-Identities-and-Names/name-search-by-name.js | 14 ++++----- .../contract-register-minimal.js | 16 +++++----- .../contract-retrieve.js | 8 ++--- .../contract-update-minimal.js | 24 ++++++++------- 2-Contracts-and-Documents/document-delete.js | 14 ++++----- .../document-retrieve.js | 19 +++++------- 2-Contracts-and-Documents/document-submit.js | 16 +++++----- 2-Contracts-and-Documents/document-update.js | 16 +++++----- README.md | 29 ++++++++++--------- connect.js | 8 ++--- create-wallet.js | 22 +++++++------- send-funds.js | 16 +++++----- use-dapi-client-methods.js | 8 ++--- 21 files changed, 154 insertions(+), 150 deletions(-) diff --git a/1-Identities-and-Names/identity-register.js b/1-Identities-and-Names/identity-register.js index 8a6ff53..dfc14cc 100644 --- a/1-Identities-and-Names/identity-register.js +++ b/1-Identities-and-Names/identity-register.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-register-an-identity -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { - network: 'testnet', + network: "testnet", wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -19,6 +19,6 @@ const createIdentity = async () => { }; createIdentity() - .then((d) => console.log('Identity:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Identity:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/identity-retrieve-account-ids.js b/1-Identities-and-Names/identity-retrieve-account-ids.js index 2addfcb..988023a 100644 --- a/1-Identities-and-Names/identity-retrieve-account-ids.js +++ b/1-Identities-and-Names/identity-retrieve-account-ids.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-an-accounts-identities -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const client = new Dash.Client({ - network: 'testnet', + network: "testnet", wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -19,6 +19,6 @@ const retrieveIdentityIds = async () => { }; retrieveIdentityIds() - .then((d) => console.log('Mnemonic identities:\n', d)) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Mnemonic identities:\n", d)) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/identity-retrieve.js b/1-Identities-and-Names/identity-retrieve.js index a5f0b8e..7ecf9a4 100644 --- a/1-Identities-and-Names/identity-retrieve.js +++ b/1-Identities-and-Names/identity-retrieve.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-an-identity -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const client = new Dash.Client(); @@ -10,6 +10,6 @@ const retrieveIdentity = async () => { }; retrieveIdentity() - .then((d) => console.log('Identity retrieved:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) + .then((d) => console.log("Identity retrieved:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/identity-topup.js b/1-Identities-and-Names/identity-topup.js index fc51ded..b1e19df 100644 --- a/1-Identities-and-Names/identity-topup.js +++ b/1-Identities-and-Names/identity-topup.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-topup-an-identity-balance -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { - network: 'testnet', + network: "testnet", wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -23,6 +23,6 @@ const topupIdentity = async () => { }; topupIdentity() - .then((d) => console.log('Identity credit balance: ', d.balance)) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Identity credit balance: ", d.balance)) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-register-alias.js b/1-Identities-and-Names/name-register-alias.js index 05c5613..1ed1f5f 100644 --- a/1-Identities-and-Names/name-register-alias.js +++ b/1-Identities-and-Names/name-register-alias.js @@ -1,13 +1,13 @@ // See https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); -const aliasToRegister = ''; // Enter alias to register +const aliasToRegister = ""; // Enter alias to register const clientOpts = { wallet: { - mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds + mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { skipSynchronizationBeforeHeight: 675000, // only sync from early-2022 }, @@ -28,6 +28,6 @@ const registerAlias = async () => { }; registerAlias() - .then((d) => console.log('Alias registered:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Alias registered:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-register.js b/1-Identities-and-Names/name-register.js index ea1215d..0a31844 100644 --- a/1-Identities-and-Names/name-register.js +++ b/1-Identities-and-Names/name-register.js @@ -1,13 +1,13 @@ // See https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); -const nameToRegister = ''; // Enter name to register +const nameToRegister = ""; // Enter name to register const clientOpts = { wallet: { - mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds + mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { skipSynchronizationBeforeHeight: 675000, // only sync from early-2022 }, @@ -29,6 +29,6 @@ const registerName = async () => { }; registerName() - .then((d) => console.log('Name registered:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Name registered:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-resolve-by-name.js b/1-Identities-and-Names/name-resolve-by-name.js index e17efb1..efb6089 100644 --- a/1-Identities-and-Names/name-resolve-by-name.js +++ b/1-Identities-and-Names/name-resolve-by-name.js @@ -1,9 +1,9 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-name -const Dash = require('dash'); +const Dash = require("dash"); const client = new Dash.Client(); -const nameToRetrieve = ''; // Enter name to retrieve +const nameToRetrieve = ""; // Enter name to retrieve const retrieveName = async () => { // Retrieve by full name (e.g., myname.dash) @@ -11,6 +11,6 @@ const retrieveName = async () => { }; retrieveName() - .then((d) => console.log('Name retrieved:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Name retrieved:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-resolve-by-record.js b/1-Identities-and-Names/name-resolve-by-record.js index 9d53cb5..600d585 100644 --- a/1-Identities-and-Names/name-resolve-by-record.js +++ b/1-Identities-and-Names/name-resolve-by-record.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-name -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const client = new Dash.Client(); @@ -8,12 +8,12 @@ const client = new Dash.Client(); const retrieveNameByRecord = async () => { // Retrieve by a name's identity ID return client.platform.names.resolveByRecord( - 'dashUniqueIdentityId', + "dashUniqueIdentityId", process.env.IDENTITY_ID, // Your identity ID ); }; retrieveNameByRecord() - .then((d) => console.log('Name retrieved:\n', d[0].toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Name retrieved:\n", d[0].toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-search-by-name.js b/1-Identities-and-Names/name-search-by-name.js index 943dc37..aa28ebd 100644 --- a/1-Identities-and-Names/name-search-by-name.js +++ b/1-Identities-and-Names/name-search-by-name.js @@ -1,22 +1,22 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-name -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); -const searchPrefix = 'a'; // Enter prefix character(s) to search for +const searchPrefix = "a"; // Enter prefix character(s) to search for const client = new Dash.Client(); const retrieveNameBySearch = async () => { // Search for names (e.g. `user*`) - return client.platform.names.search(searchPrefix, 'dash'); + return client.platform.names.search(searchPrefix, "dash"); }; retrieveNameBySearch() .then((d) => { for (const name of d) { - console.log('Name retrieved:\n', name.toJSON()); + console.log("Name retrieved:\n", name.toJSON()); } }) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/contract-register-minimal.js b/2-Contracts-and-Documents/contract-register-minimal.js index 57a075a..54c8c38 100644 --- a/2-Contracts-and-Documents/contract-register-minimal.js +++ b/2-Contracts-and-Documents/contract-register-minimal.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-register-a-data-contract -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { @@ -19,10 +19,10 @@ const registerContract = async () => { const contractDocuments = { note: { - type: 'object', + type: "object", properties: { message: { - type: 'string', + type: "string", }, }, additionalProperties: false, @@ -37,7 +37,7 @@ const registerContract = async () => { const validationResult = await platform.dpp.dataContract.validate(contract); if (validationResult.isValid()) { - console.log('Validation passed, broadcasting contract..'); + console.log("Validation passed, broadcasting contract.."); // Sign and submit the data contract return platform.contracts.publish(contract, identity); } @@ -46,6 +46,6 @@ const registerContract = async () => { }; registerContract() - .then((d) => console.log('Contract registered:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Contract registered:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/contract-retrieve.js b/2-Contracts-and-Documents/contract-retrieve.js index 33bc0cc..0931320 100644 --- a/2-Contracts-and-Documents/contract-retrieve.js +++ b/2-Contracts-and-Documents/contract-retrieve.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-data-contract -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const client = new Dash.Client(); @@ -12,5 +12,5 @@ const retrieveContract = async () => { retrieveContract() .then((d) => console.dir(d.toJSON(), { depth: 5 })) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/contract-update-minimal.js b/2-Contracts-and-Documents/contract-update-minimal.js index 4a8d68c..ec2e42d 100644 --- a/2-Contracts-and-Documents/contract-update-minimal.js +++ b/2-Contracts-and-Documents/contract-update-minimal.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-update-documents -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { @@ -17,21 +17,25 @@ const updateContract = async () => { const { platform } = client; const identity = await platform.identities.get(process.env.IDENTITY_ID); // Your identity ID - const existingDataContract = await platform.contracts.get(process.env.CONTRACT_ID); + const existingDataContract = await platform.contracts.get( + process.env.CONTRACT_ID, + ); const documents = existingDataContract.getDocuments(); documents.note.properties.author = { - type: 'string', + type: "string", }; existingDataContract.setDocuments(documents); - + // Make sure contract passes validation checks await platform.dpp.initialize(); - const validationResult = await platform.dpp.dataContract.validate(existingDataContract); + const validationResult = await platform.dpp.dataContract.validate( + existingDataContract, + ); if (validationResult.isValid()) { - console.log('Validation passed, broadcasting contract..'); + console.log("Validation passed, broadcasting contract.."); // Sign and submit the data contract return platform.contracts.update(existingDataContract, identity); } @@ -40,6 +44,6 @@ const updateContract = async () => { }; updateContract() - .then((d) => console.log('Contract updated:\n', d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Contract updated:\n", d.toJSON())) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-delete.js b/2-Contracts-and-Documents/document-delete.js index 7c927e5..ed0d6d7 100644 --- a/2-Contracts-and-Documents/document-delete.js +++ b/2-Contracts-and-Documents/document-delete.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-delete-documents -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { @@ -25,8 +25,8 @@ const deleteNoteDocument = async () => { // Retrieve the existing document const [document] = await client.platform.documents.get( - 'tutorialContract.note', - { where: [['$id', '==', documentId]] }, + "tutorialContract.note", + { where: [["$id", "==", documentId]] }, ); // Sign and submit the document delete transition @@ -34,6 +34,6 @@ const deleteNoteDocument = async () => { }; deleteNoteDocument() - .then((d) => console.log('Document deleted:\n', d)) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Document deleted:\n", d)) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-retrieve.js b/2-Contracts-and-Documents/document-retrieve.js index 9b8bab6..9df868a 100644 --- a/2-Contracts-and-Documents/document-retrieve.js +++ b/2-Contracts-and-Documents/document-retrieve.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-documents -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { @@ -13,19 +13,16 @@ const clientOpts = { const client = new Dash.Client(clientOpts); const getDocuments = async () => { - return client.platform.documents.get( - 'tutorialContract.note', - { - limit: 2, // Only retrieve 2 document - }, - ); + return client.platform.documents.get("tutorialContract.note", { + limit: 2, // Only retrieve 2 document + }); }; getDocuments() .then((d) => { for (const n of d) { - console.log('Document:\n', n.toJSON()); + console.log("Document:\n", n.toJSON()); } }) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-submit.js b/2-Contracts-and-Documents/document-submit.js index 895d095..48ef713 100644 --- a/2-Contracts-and-Documents/document-submit.js +++ b/2-Contracts-and-Documents/document-submit.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-submit-documents -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { - network: 'testnet', + network: "testnet", wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -29,15 +29,15 @@ const submitNoteDocument = async () => { // Create the note document const noteDocument = await platform.documents.create( - 'tutorialContract.note', + "tutorialContract.note", identity, docProperties, ); const documentBatch = { create: [noteDocument], // Document(s) to create - replace: [], // Document(s) to update - delete: [], // Document(s) to delete + replace: [], // Document(s) to update + delete: [], // Document(s) to delete }; // Sign and submit the document(s) return platform.documents.broadcast(documentBatch, identity); @@ -45,5 +45,5 @@ const submitNoteDocument = async () => { submitNoteDocument() .then((d) => console.log(d.toJSON())) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-update.js b/2-Contracts-and-Documents/document-update.js index 3704cf2..a89bab0 100644 --- a/2-Contracts-and-Documents/document-update.js +++ b/2-Contracts-and-Documents/document-update.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-update-documents -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { @@ -25,18 +25,18 @@ const updateNoteDocument = async () => { // Retrieve the existing document const [document] = await client.platform.documents.get( - 'tutorialContract.note', - { where: [['$id', '==', documentId]] }, + "tutorialContract.note", + { where: [["$id", "==", documentId]] }, ); // Update document - document.set('message', `Updated document @ ${new Date().toUTCString()}`); + document.set("message", `Updated document @ ${new Date().toUTCString()}`); // Sign and submit the document replace transition return platform.documents.broadcast({ replace: [document] }, identity); }; updateNoteDocument() - .then((d) => console.log('Document updated:\n', d)) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Document updated:\n", d)) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/README.md b/README.md index d7926fe..3420913 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,17 @@ [![SDK Version](https://img.shields.io/github/package-json/dependency-version/dashevo/platform-readme-tutorials/dash)](https://github.com/dashevo/platform-readme-tutorials/blob/main/package.json) -Code for the tutorials found on the [Platform documentation site](https://dashplatform.readme.io/). +Code for the tutorials found on the +[Platform documentation site](https://dashplatform.readme.io/). ## Install -Note: [NodeJS](https://nodejs.org/en/download/) (v12+) must be installed to run the tutorial code. +Note: [NodeJS](https://nodejs.org/en/download/) (v12+) must be installed to run +the tutorial code. ### Clone this repository -``` shell +```shell git clone https://github.com/dashevo/platform-readme-tutorials.git ``` @@ -18,7 +20,7 @@ git clone https://github.com/dashevo/platform-readme-tutorials.git Do a clean install of project dependencies: -``` shell +```shell npm ci ``` @@ -26,15 +28,16 @@ npm ci 1. Check connection: `node connect.js` 1. Create wallet: `node create-wallet.js` -1. Go to the [Testnet faucet](https://testnet-faucet.dash.org/) and add funds to the address - reported in the previous step -1. Create an `.env` file (See [`.env.example`](./.env.example) for an example `.env` file). Set - `MNEMONIC` to the wallet mnemonic from step 2. - -Proceed with the tutorials [Identities and Names tutorials](./1-Identities-and-Names/) first and the -[Contracts And Documents tutorials](./2-Contracts-and-Documents/) next. They align with the -tutorials section found on the [documentation -site](https://dashplatform.readme.io/docs/tutorials-introduction). +1. Go to the [Testnet faucet](https://testnet-faucet.dash.org/) and add funds to + the address reported in the previous step +1. Create an `.env` file (See [`.env.example`](./.env.example) for an example + `.env` file). Set `MNEMONIC` to the wallet mnemonic from step 2. + +Proceed with the tutorials +[Identities and Names tutorials](./1-Identities-and-Names/) first and the +[Contracts And Documents tutorials](./2-Contracts-and-Documents/) next. They +align with the tutorials section found on the +[documentation site](https://dashplatform.readme.io/docs/tutorials-introduction). ## Contributing diff --git a/connect.js b/connect.js index 4c13285..2d61013 100644 --- a/connect.js +++ b/connect.js @@ -1,5 +1,5 @@ // See https://dashplatform.readme.io/docs/tutorial-connecting-to-testnet -const Dash = require('dash'); +const Dash = require("dash"); const client = new Dash.Client(); @@ -8,6 +8,6 @@ async function connect() { } connect() - .then((d) => console.log('Connected. Best block hash:\n', d)) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Connected. Best block hash:\n", d)) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); diff --git a/create-wallet.js b/create-wallet.js index 248674b..6c43768 100644 --- a/create-wallet.js +++ b/create-wallet.js @@ -1,14 +1,14 @@ // See https://dashplatform.readme.io/docs/tutorial-create-and-fund-a-wallet -const Dash = require('dash'); +const Dash = require("dash"); const clientOpts = { - network: 'testnet', + network: "testnet", wallet: { mnemonic: null, // this indicates that we want a new wallet to be generated - // if you want to get a new address for an existing wallet - // replace 'null' with an existing wallet mnemonic - offlineMode: true, // this indicates we don't want to sync the chain - // it can only be used when the mnemonic is set to 'null' + // if you want to get a new address for an existing wallet + // replace 'null' with an existing wallet mnemonic + offlineMode: true, // this indicates we don't want to sync the chain + // it can only be used when the mnemonic is set to 'null' }, }; @@ -19,16 +19,16 @@ const createWallet = async () => { const mnemonic = client.wallet.exportWallet(); const address = account.getUnusedAddress(); - console.log('Mnemonic:', mnemonic); - console.log('Unused address:', address.address); + console.log("Mnemonic:", mnemonic); + console.log("Unused address:", address.address); }; createWallet() - .catch((e) => console.error('Something went wrong:\n', e)) + .catch((e) => console.error("Something went wrong:\n", e)) .finally(() => client.disconnect()); // Handle wallet async errors -client.on('error', (error, context) => { +client.on("error", (error, context) => { console.error(`Client error: ${error.name}`); console.error(context); -}); \ No newline at end of file +}); diff --git a/send-funds.js b/send-funds.js index f224ef8..2baf685 100644 --- a/send-funds.js +++ b/send-funds.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-send-funds -const Dash = require('dash'); -const dotenv = require('dotenv'); +const Dash = require("dash"); +const dotenv = require("dotenv"); dotenv.config(); const clientOpts = { - network: 'testnet', + network: "testnet", wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -18,19 +18,19 @@ const sendFunds = async () => { const account = await client.getWalletAccount(); const transaction = account.createTransaction({ - recipient: 'yP8A3cbdxRtLRduy5mXDsBnJtMzHWs6ZXr', // Testnet faucet + recipient: "yP8A3cbdxRtLRduy5mXDsBnJtMzHWs6ZXr", // Testnet faucet satoshis: 10000000, // 0.1 Dash }); return account.broadcastTransaction(transaction); }; sendFunds() - .then((d) => console.log('Transaction broadcast!\nTransaction ID:', d)) - .catch((e) => console.error('Something went wrong:\n', e)) + .then((d) => console.log("Transaction broadcast!\nTransaction ID:", d)) + .catch((e) => console.error("Something went wrong:\n", e)) .finally(() => client.disconnect()); // Handle wallet async errors -client.on('error', (error, context) => { +client.on("error", (error, context) => { console.error(`Client error: ${error.name}`); console.error(context); -}); \ No newline at end of file +}); diff --git a/use-dapi-client-methods.js b/use-dapi-client-methods.js index f6a70ee..255737a 100644 --- a/use-dapi-client-methods.js +++ b/use-dapi-client-methods.js @@ -1,5 +1,5 @@ // See https://dashplatform.readme.io/docs/tutorial-use-dapi-client-methods -const Dash = require('dash'); +const Dash = require("dash"); const client = new Dash.Client(); @@ -12,6 +12,6 @@ async function dapiClientMethods() { } dapiClientMethods() - .then((d) => console.log('Core status:\n', d)) - .catch((e) => console.error('Something went wrong:\n', e)) - .finally(() => client.disconnect()); \ No newline at end of file + .then((d) => console.log("Core status:\n", d)) + .catch((e) => console.error("Something went wrong:\n", e)) + .finally(() => client.disconnect()); From dc8ade26a37dfbd73d5b96f2f45ead29c22ea08a Mon Sep 17 00:00:00 2001 From: thephez Date: Mon, 11 Jul 2022 14:06:02 -0400 Subject: [PATCH 2/2] chore: npm run fmt --- 1-Identities-and-Names/identity-register.js | 10 +++++----- .../identity-retrieve-account-ids.js | 10 +++++----- 1-Identities-and-Names/identity-retrieve.js | 8 ++++---- 1-Identities-and-Names/identity-topup.js | 10 +++++----- 1-Identities-and-Names/name-register-alias.js | 10 +++++----- 1-Identities-and-Names/name-register.js | 10 +++++----- 1-Identities-and-Names/name-resolve-by-name.js | 8 ++++---- 1-Identities-and-Names/name-resolve-by-record.js | 10 +++++----- 1-Identities-and-Names/name-search-by-name.js | 12 ++++++------ .../contract-register-minimal.js | 14 +++++++------- 2-Contracts-and-Documents/contract-retrieve.js | 6 +++--- .../contract-update-minimal.js | 12 ++++++------ 2-Contracts-and-Documents/document-delete.js | 12 ++++++------ 2-Contracts-and-Documents/document-retrieve.js | 10 +++++----- 2-Contracts-and-Documents/document-submit.js | 10 +++++----- 2-Contracts-and-Documents/document-update.js | 14 +++++++------- connect.js | 6 +++--- create-wallet.js | 12 ++++++------ send-funds.js | 14 +++++++------- use-dapi-client-methods.js | 6 +++--- 20 files changed, 102 insertions(+), 102 deletions(-) diff --git a/1-Identities-and-Names/identity-register.js b/1-Identities-and-Names/identity-register.js index dfc14cc..3554ab7 100644 --- a/1-Identities-and-Names/identity-register.js +++ b/1-Identities-and-Names/identity-register.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-register-an-identity -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { - network: "testnet", + network: 'testnet', wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -19,6 +19,6 @@ const createIdentity = async () => { }; createIdentity() - .then((d) => console.log("Identity:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Identity:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/identity-retrieve-account-ids.js b/1-Identities-and-Names/identity-retrieve-account-ids.js index 988023a..86e636f 100644 --- a/1-Identities-and-Names/identity-retrieve-account-ids.js +++ b/1-Identities-and-Names/identity-retrieve-account-ids.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-an-accounts-identities -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const client = new Dash.Client({ - network: "testnet", + network: 'testnet', wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -19,6 +19,6 @@ const retrieveIdentityIds = async () => { }; retrieveIdentityIds() - .then((d) => console.log("Mnemonic identities:\n", d)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Mnemonic identities:\n', d)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/identity-retrieve.js b/1-Identities-and-Names/identity-retrieve.js index 7ecf9a4..a5f0b8e 100644 --- a/1-Identities-and-Names/identity-retrieve.js +++ b/1-Identities-and-Names/identity-retrieve.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-an-identity -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const client = new Dash.Client(); @@ -10,6 +10,6 @@ const retrieveIdentity = async () => { }; retrieveIdentity() - .then((d) => console.log("Identity retrieved:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Identity retrieved:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/identity-topup.js b/1-Identities-and-Names/identity-topup.js index b1e19df..3f39570 100644 --- a/1-Identities-and-Names/identity-topup.js +++ b/1-Identities-and-Names/identity-topup.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-topup-an-identity-balance -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { - network: "testnet", + network: 'testnet', wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -23,6 +23,6 @@ const topupIdentity = async () => { }; topupIdentity() - .then((d) => console.log("Identity credit balance: ", d.balance)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Identity credit balance: ', d.balance)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-register-alias.js b/1-Identities-and-Names/name-register-alias.js index 1ed1f5f..66a0a02 100644 --- a/1-Identities-and-Names/name-register-alias.js +++ b/1-Identities-and-Names/name-register-alias.js @@ -1,9 +1,9 @@ // See https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); -const aliasToRegister = ""; // Enter alias to register +const aliasToRegister = ''; // Enter alias to register const clientOpts = { wallet: { @@ -28,6 +28,6 @@ const registerAlias = async () => { }; registerAlias() - .then((d) => console.log("Alias registered:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Alias registered:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-register.js b/1-Identities-and-Names/name-register.js index 0a31844..5cab61e 100644 --- a/1-Identities-and-Names/name-register.js +++ b/1-Identities-and-Names/name-register.js @@ -1,9 +1,9 @@ // See https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); -const nameToRegister = ""; // Enter name to register +const nameToRegister = ''; // Enter name to register const clientOpts = { wallet: { @@ -29,6 +29,6 @@ const registerName = async () => { }; registerName() - .then((d) => console.log("Name registered:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Name registered:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-resolve-by-name.js b/1-Identities-and-Names/name-resolve-by-name.js index efb6089..2647d1d 100644 --- a/1-Identities-and-Names/name-resolve-by-name.js +++ b/1-Identities-and-Names/name-resolve-by-name.js @@ -1,9 +1,9 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-name -const Dash = require("dash"); +const Dash = require('dash'); const client = new Dash.Client(); -const nameToRetrieve = ""; // Enter name to retrieve +const nameToRetrieve = ''; // Enter name to retrieve const retrieveName = async () => { // Retrieve by full name (e.g., myname.dash) @@ -11,6 +11,6 @@ const retrieveName = async () => { }; retrieveName() - .then((d) => console.log("Name retrieved:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Name retrieved:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-resolve-by-record.js b/1-Identities-and-Names/name-resolve-by-record.js index 600d585..a47b41d 100644 --- a/1-Identities-and-Names/name-resolve-by-record.js +++ b/1-Identities-and-Names/name-resolve-by-record.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-name -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const client = new Dash.Client(); @@ -8,12 +8,12 @@ const client = new Dash.Client(); const retrieveNameByRecord = async () => { // Retrieve by a name's identity ID return client.platform.names.resolveByRecord( - "dashUniqueIdentityId", + 'dashUniqueIdentityId', process.env.IDENTITY_ID, // Your identity ID ); }; retrieveNameByRecord() - .then((d) => console.log("Name retrieved:\n", d[0].toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Name retrieved:\n', d[0].toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/1-Identities-and-Names/name-search-by-name.js b/1-Identities-and-Names/name-search-by-name.js index aa28ebd..96e117e 100644 --- a/1-Identities-and-Names/name-search-by-name.js +++ b/1-Identities-and-Names/name-search-by-name.js @@ -1,22 +1,22 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-name -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); -const searchPrefix = "a"; // Enter prefix character(s) to search for +const searchPrefix = 'a'; // Enter prefix character(s) to search for const client = new Dash.Client(); const retrieveNameBySearch = async () => { // Search for names (e.g. `user*`) - return client.platform.names.search(searchPrefix, "dash"); + return client.platform.names.search(searchPrefix, 'dash'); }; retrieveNameBySearch() .then((d) => { for (const name of d) { - console.log("Name retrieved:\n", name.toJSON()); + console.log('Name retrieved:\n', name.toJSON()); } }) - .catch((e) => console.error("Something went wrong:\n", e)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/contract-register-minimal.js b/2-Contracts-and-Documents/contract-register-minimal.js index 54c8c38..43d1dd1 100644 --- a/2-Contracts-and-Documents/contract-register-minimal.js +++ b/2-Contracts-and-Documents/contract-register-minimal.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-register-a-data-contract -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { @@ -19,10 +19,10 @@ const registerContract = async () => { const contractDocuments = { note: { - type: "object", + type: 'object', properties: { message: { - type: "string", + type: 'string', }, }, additionalProperties: false, @@ -37,7 +37,7 @@ const registerContract = async () => { const validationResult = await platform.dpp.dataContract.validate(contract); if (validationResult.isValid()) { - console.log("Validation passed, broadcasting contract.."); + console.log('Validation passed, broadcasting contract..'); // Sign and submit the data contract return platform.contracts.publish(contract, identity); } @@ -46,6 +46,6 @@ const registerContract = async () => { }; registerContract() - .then((d) => console.log("Contract registered:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Contract registered:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/contract-retrieve.js b/2-Contracts-and-Documents/contract-retrieve.js index 0931320..d281370 100644 --- a/2-Contracts-and-Documents/contract-retrieve.js +++ b/2-Contracts-and-Documents/contract-retrieve.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-a-data-contract -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const client = new Dash.Client(); @@ -12,5 +12,5 @@ const retrieveContract = async () => { retrieveContract() .then((d) => console.dir(d.toJSON(), { depth: 5 })) - .catch((e) => console.error("Something went wrong:\n", e)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/contract-update-minimal.js b/2-Contracts-and-Documents/contract-update-minimal.js index ec2e42d..7c1f1ca 100644 --- a/2-Contracts-and-Documents/contract-update-minimal.js +++ b/2-Contracts-and-Documents/contract-update-minimal.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-update-documents -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { @@ -23,7 +23,7 @@ const updateContract = async () => { const documents = existingDataContract.getDocuments(); documents.note.properties.author = { - type: "string", + type: 'string', }; existingDataContract.setDocuments(documents); @@ -35,7 +35,7 @@ const updateContract = async () => { ); if (validationResult.isValid()) { - console.log("Validation passed, broadcasting contract.."); + console.log('Validation passed, broadcasting contract..'); // Sign and submit the data contract return platform.contracts.update(existingDataContract, identity); } @@ -44,6 +44,6 @@ const updateContract = async () => { }; updateContract() - .then((d) => console.log("Contract updated:\n", d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Contract updated:\n', d.toJSON())) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-delete.js b/2-Contracts-and-Documents/document-delete.js index ed0d6d7..8ca7dda 100644 --- a/2-Contracts-and-Documents/document-delete.js +++ b/2-Contracts-and-Documents/document-delete.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-delete-documents -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { @@ -25,8 +25,8 @@ const deleteNoteDocument = async () => { // Retrieve the existing document const [document] = await client.platform.documents.get( - "tutorialContract.note", - { where: [["$id", "==", documentId]] }, + 'tutorialContract.note', + { where: [['$id', '==', documentId]] }, ); // Sign and submit the document delete transition @@ -34,6 +34,6 @@ const deleteNoteDocument = async () => { }; deleteNoteDocument() - .then((d) => console.log("Document deleted:\n", d)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Document deleted:\n', d)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-retrieve.js b/2-Contracts-and-Documents/document-retrieve.js index 9df868a..d1e8472 100644 --- a/2-Contracts-and-Documents/document-retrieve.js +++ b/2-Contracts-and-Documents/document-retrieve.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-retrieve-documents -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { @@ -13,7 +13,7 @@ const clientOpts = { const client = new Dash.Client(clientOpts); const getDocuments = async () => { - return client.platform.documents.get("tutorialContract.note", { + return client.platform.documents.get('tutorialContract.note', { limit: 2, // Only retrieve 2 document }); }; @@ -21,8 +21,8 @@ const getDocuments = async () => { getDocuments() .then((d) => { for (const n of d) { - console.log("Document:\n", n.toJSON()); + console.log('Document:\n', n.toJSON()); } }) - .catch((e) => console.error("Something went wrong:\n", e)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-submit.js b/2-Contracts-and-Documents/document-submit.js index 48ef713..6c2deb7 100644 --- a/2-Contracts-and-Documents/document-submit.js +++ b/2-Contracts-and-Documents/document-submit.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-submit-documents -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { - network: "testnet", + network: 'testnet', wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -29,7 +29,7 @@ const submitNoteDocument = async () => { // Create the note document const noteDocument = await platform.documents.create( - "tutorialContract.note", + 'tutorialContract.note', identity, docProperties, ); @@ -45,5 +45,5 @@ const submitNoteDocument = async () => { submitNoteDocument() .then((d) => console.log(d.toJSON())) - .catch((e) => console.error("Something went wrong:\n", e)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/2-Contracts-and-Documents/document-update.js b/2-Contracts-and-Documents/document-update.js index a89bab0..dc11819 100644 --- a/2-Contracts-and-Documents/document-update.js +++ b/2-Contracts-and-Documents/document-update.js @@ -1,6 +1,6 @@ // See https://dashplatform.readme.io/docs/tutorial-update-documents -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { @@ -25,18 +25,18 @@ const updateNoteDocument = async () => { // Retrieve the existing document const [document] = await client.platform.documents.get( - "tutorialContract.note", - { where: [["$id", "==", documentId]] }, + 'tutorialContract.note', + { where: [['$id', '==', documentId]] }, ); // Update document - document.set("message", `Updated document @ ${new Date().toUTCString()}`); + document.set('message', `Updated document @ ${new Date().toUTCString()}`); // Sign and submit the document replace transition return platform.documents.broadcast({ replace: [document] }, identity); }; updateNoteDocument() - .then((d) => console.log("Document updated:\n", d)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Document updated:\n', d)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/connect.js b/connect.js index 2d61013..ba2ee8b 100644 --- a/connect.js +++ b/connect.js @@ -1,5 +1,5 @@ // See https://dashplatform.readme.io/docs/tutorial-connecting-to-testnet -const Dash = require("dash"); +const Dash = require('dash'); const client = new Dash.Client(); @@ -8,6 +8,6 @@ async function connect() { } connect() - .then((d) => console.log("Connected. Best block hash:\n", d)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Connected. Best block hash:\n', d)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); diff --git a/create-wallet.js b/create-wallet.js index 6c43768..e6903e6 100644 --- a/create-wallet.js +++ b/create-wallet.js @@ -1,8 +1,8 @@ // See https://dashplatform.readme.io/docs/tutorial-create-and-fund-a-wallet -const Dash = require("dash"); +const Dash = require('dash'); const clientOpts = { - network: "testnet", + network: 'testnet', wallet: { mnemonic: null, // this indicates that we want a new wallet to be generated // if you want to get a new address for an existing wallet @@ -19,16 +19,16 @@ const createWallet = async () => { const mnemonic = client.wallet.exportWallet(); const address = account.getUnusedAddress(); - console.log("Mnemonic:", mnemonic); - console.log("Unused address:", address.address); + console.log('Mnemonic:', mnemonic); + console.log('Unused address:', address.address); }; createWallet() - .catch((e) => console.error("Something went wrong:\n", e)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); // Handle wallet async errors -client.on("error", (error, context) => { +client.on('error', (error, context) => { console.error(`Client error: ${error.name}`); console.error(context); }); diff --git a/send-funds.js b/send-funds.js index 2baf685..3297634 100644 --- a/send-funds.js +++ b/send-funds.js @@ -1,10 +1,10 @@ // See https://dashplatform.readme.io/docs/tutorial-send-funds -const Dash = require("dash"); -const dotenv = require("dotenv"); +const Dash = require('dash'); +const dotenv = require('dotenv'); dotenv.config(); const clientOpts = { - network: "testnet", + network: 'testnet', wallet: { mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds unsafeOptions: { @@ -18,19 +18,19 @@ const sendFunds = async () => { const account = await client.getWalletAccount(); const transaction = account.createTransaction({ - recipient: "yP8A3cbdxRtLRduy5mXDsBnJtMzHWs6ZXr", // Testnet faucet + recipient: 'yP8A3cbdxRtLRduy5mXDsBnJtMzHWs6ZXr', // Testnet faucet satoshis: 10000000, // 0.1 Dash }); return account.broadcastTransaction(transaction); }; sendFunds() - .then((d) => console.log("Transaction broadcast!\nTransaction ID:", d)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Transaction broadcast!\nTransaction ID:', d)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect()); // Handle wallet async errors -client.on("error", (error, context) => { +client.on('error', (error, context) => { console.error(`Client error: ${error.name}`); console.error(context); }); diff --git a/use-dapi-client-methods.js b/use-dapi-client-methods.js index 255737a..4711940 100644 --- a/use-dapi-client-methods.js +++ b/use-dapi-client-methods.js @@ -1,5 +1,5 @@ // See https://dashplatform.readme.io/docs/tutorial-use-dapi-client-methods -const Dash = require("dash"); +const Dash = require('dash'); const client = new Dash.Client(); @@ -12,6 +12,6 @@ async function dapiClientMethods() { } dapiClientMethods() - .then((d) => console.log("Core status:\n", d)) - .catch((e) => console.error("Something went wrong:\n", e)) + .then((d) => console.log('Core status:\n', d)) + .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect());