dash 3.23.0-dev.1 → 3.23.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -14
- package/build/src/SDK/Client/Client.spec.js +2 -4
- package/build/src/SDK/Client/Client.spec.js.map +1 -1
- package/build/src/SDK/Client/Platform/Platform.js +12 -0
- package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
- package/build/src/SDK/Client/Platform/broadcastStateTransition.js +16 -9
- package/build/src/SDK/Client/Platform/broadcastStateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/createAssetLockTransaction.js +8 -4
- package/build/src/SDK/Client/Platform/createAssetLockTransaction.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/publish.js +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/publish.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/update.js +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/update.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/documents/broadcast.js +1 -1
- package/build/src/SDK/Client/Platform/methods/documents/broadcast.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js +8 -4
- package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +42 -17
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js +8 -4
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js +7 -3
- package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/register.js +31 -8
- package/build/src/SDK/Client/Platform/methods/identities/register.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/topUp.js +5 -7
- package/build/src/SDK/Client/Platform/methods/identities/topUp.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/update.js +34 -5
- package/build/src/SDK/Client/Platform/methods/identities/update.js.map +1 -1
- package/build/src/SDK/SDK.js +10 -0
- package/build/src/SDK/SDK.js.map +1 -1
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js +13 -3
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js.map +1 -1
- package/build/src/test/fixtures/createTransactionFixtureInAccount.js +2 -2
- package/build/src/test/fixtures/createTransactionFixtureInAccount.js.map +1 -1
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js +2 -2
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js.map +1 -1
- package/build/tests/fixtures/contracts.json +1 -1
- package/build-utils/ws.js +15 -0
- package/dist/dash.min.js +9 -0
- package/dist/dash.min.js.LICENSE.txt +80 -0
- package/dist/dash.min.js.map +1 -0
- package/dist/src/SDK/Client/Platform/Platform.d.ts +7 -0
- package/dist/src/SDK/Client/Platform/broadcastStateTransition.d.ts +6 -1
- package/dist/src/SDK/Client/Platform/createAssetLockTransaction.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.d.ts +2 -1
- package/dist/src/SDK/Client/Platform/methods/identities/update.d.ts +4 -0
- package/dist/src/SDK/SDK.d.ts +9 -0
- package/docs/README.md +11 -52
- package/docs/_sidebar.md +0 -17
- package/docs/examples/fetch-an-identity-from-its-name.md +5 -9
- package/docs/examples/generate-a-new-mnemonic.md +1 -1
- package/docs/examples/pay-to-another-address.md +16 -13
- package/docs/examples/receive-money-and-check-balance.md +55 -39
- package/docs/examples/sign-and-verify-messages.md +19 -9
- package/docs/examples/use-different-account.md +5 -17
- package/docs/getting-started/core-concepts.md +6 -5
- package/docs/getting-started/dash-platform-applications.md +1 -1
- package/docs/getting-started/quickstart.md +7 -24
- package/docs/getting-started/with-typescript.md +5 -2
- package/docs/index.html +2 -2
- package/docs/platform/about-platform.md +5 -5
- package/docs/platform/contracts/about-contracts.md +2 -2
- package/docs/platform/contracts/create.md +5 -5
- package/docs/platform/contracts/get.md +1 -1
- package/docs/platform/contracts/publish.md +3 -3
- package/docs/platform/contracts/update.md +1 -4
- package/docs/platform/documents/broadcast.md +15 -15
- package/docs/platform/documents/create.md +5 -5
- package/docs/platform/documents/get.md +6 -5
- package/docs/platform/identities/about-identity.md +1 -1
- package/docs/platform/identities/get.md +1 -1
- package/docs/platform/identities/register.md +1 -1
- package/docs/platform/identities/topUp.md +2 -2
- package/docs/platform/names/about-dpns.md +1 -1
- package/docs/platform/names/register.md +9 -9
- package/docs/platform/names/resolve.md +1 -1
- package/docs/platform/names/resolveByRecord.md +9 -8
- package/docs/platform/names/search.md +1 -1
- package/docs/usage/dashcorelib-primitives.md +48 -37
- package/docs/wallet/about-wallet-lib.md +3 -3
- package/docs/wallet/accounts.md +11 -7
- package/docs/wallet/signing-encrypt.md +12 -6
- package/package.json +19 -15
- package/src/SDK/Client/Client.spec.ts +2 -4
- package/src/SDK/Client/Platform/Platform.ts +21 -0
- package/src/SDK/Client/Platform/broadcastStateTransition.ts +15 -6
- package/src/SDK/Client/Platform/createAssetLockTransaction.ts +5 -2
- package/src/SDK/Client/Platform/methods/contracts/publish.ts +1 -1
- package/src/SDK/Client/Platform/methods/contracts/update.ts +1 -1
- package/src/SDK/Client/Platform/methods/documents/broadcast.ts +1 -1
- package/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts +5 -2
- package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +38 -7
- package/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.ts +5 -2
- package/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts +4 -3
- package/src/SDK/Client/Platform/methods/identities/register.ts +33 -9
- package/src/SDK/Client/Platform/methods/identities/topUp.ts +5 -8
- package/src/SDK/Client/Platform/methods/identities/update.ts +35 -1
- package/src/SDK/SDK.ts +34 -21
- package/src/test/fixtures/createIdentityFixtureInAccount.ts +14 -3
- package/src/test/fixtures/createTransactionFixtureInAccount.ts +2 -2
- package/src/test/mocks/createAndAttachTransportMocksToClient.ts +2 -2
- package/tests/fixtures/contracts.json +1 -1
- package/tests/fixtures/ratePlatform.schema.json +1 -1
- package/webpack.base.config.js +14 -0
- package/webpack.config.js +6 -2
- package/docs/examples/publishing-a-new-contract.md +0 -68
- package/docs/examples/updating-a-contract.md +0 -55
- package/docs/examples/use-local-evonet.md +0 -19
- package/examples/node/create-and-fund-wallet.js +0 -28
- package/examples/node/register-contract.js +0 -34
- package/examples/node/register-identity.js +0 -23
- package/examples/node/register-name.js +0 -19
- package/examples/node/retrieve-contract.js +0 -20
- package/examples/node/retrieve-documents.js +0 -22
- package/examples/node/retrieve-identity.js +0 -20
- package/examples/node/retrieve-name.js +0 -14
- package/examples/node/sign-and-verify-messages.js +0 -29
- package/examples/schema.json +0 -58
- package/examples/web/usage.web.html +0 -12
- package/examples/web/usage.web.js +0 -28
package/src/SDK/SDK.ts
CHANGED
|
@@ -3,34 +3,47 @@ import { Core as _Core } from './Core';
|
|
|
3
3
|
import { Platform as _Platform } from './Platform';
|
|
4
4
|
import { default as _DAPIClient } from '@dashevo/dapi-client';
|
|
5
5
|
|
|
6
|
+
import { StateTransitionBroadcastError } from '../errors/StateTransitionBroadcastError'
|
|
7
|
+
|
|
6
8
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
Wallet as _Wallet,
|
|
10
|
+
Account as _Account,
|
|
11
|
+
DerivableKeyChain as _KeyChain,
|
|
12
|
+
CONSTANTS as _WalletLibCONSTANTS,
|
|
13
|
+
EVENTS as _WalletLibEVENTS,
|
|
14
|
+
utils as _WalletLibUtils,
|
|
15
|
+
plugins as _WalletLibPlugins
|
|
14
16
|
} from '@dashevo/wallet-lib';
|
|
15
17
|
|
|
16
18
|
export namespace SDK {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
export let DAPIClient = _DAPIClient;
|
|
20
|
+
export let Client = _Client;
|
|
21
|
+
|
|
22
|
+
export let Core = _Core;
|
|
23
|
+
// TODO: consider marking as DEPRECATED and use PlatformProtocol below instead
|
|
24
|
+
export let Platform = _Platform;
|
|
25
|
+
|
|
26
|
+
// Wallet-lib primitives
|
|
27
|
+
export let Wallet = _Wallet;
|
|
28
|
+
export let Account = _Account;
|
|
29
|
+
export let KeyChain = _KeyChain;
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
// TODO: consider merging into Wallet above and mark as DEPRECATED
|
|
32
|
+
export let WalletLib = {
|
|
33
|
+
CONSTANTS: _WalletLibCONSTANTS,
|
|
34
|
+
EVENTS: _WalletLibEVENTS,
|
|
35
|
+
plugins: _WalletLibPlugins,
|
|
36
|
+
utils: _WalletLibUtils,
|
|
37
|
+
}
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
export let Wallet = _Wallet;
|
|
25
|
-
export let Account = _Account;
|
|
26
|
-
export let KeyChain = _KeyChain;
|
|
39
|
+
export let PlatformProtocol = Platform.DashPlatformProtocol;
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
plugins: _WalletLibPlugins,
|
|
32
|
-
utils: _WalletLibUtils,
|
|
33
|
-
}
|
|
41
|
+
export let Essentials = {
|
|
42
|
+
Buffer,
|
|
43
|
+
}
|
|
34
44
|
|
|
45
|
+
export let Errors = {
|
|
46
|
+
StateTransitionBroadcastError
|
|
47
|
+
}
|
|
35
48
|
}
|
|
36
49
|
export { SDK as default };
|
|
@@ -5,14 +5,25 @@ const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFi
|
|
|
5
5
|
export function createIdentityFixtureInAccount(account) {
|
|
6
6
|
const identityFixture = getIdentityFixture();
|
|
7
7
|
const identityFixtureIndex = 0;
|
|
8
|
-
const { privateKey:
|
|
8
|
+
const { privateKey: identityMasterPrivateKey } = account.identities.getIdentityHDKeyByIndex(identityFixtureIndex, 0);
|
|
9
|
+
const { privateKey: identitySecondPrivateKey } = account.identities.getIdentityHDKeyByIndex(identityFixtureIndex, 1);
|
|
9
10
|
|
|
10
11
|
identityFixture.publicKeys[0] = new IdentityPublicKey({
|
|
11
12
|
id: 0,
|
|
12
13
|
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
13
|
-
data:
|
|
14
|
+
data: identityMasterPrivateKey.toPublicKey().toBuffer(),
|
|
14
15
|
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
15
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER
|
|
16
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER,
|
|
17
|
+
readOnly: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
identityFixture.publicKeys[1] = new IdentityPublicKey({
|
|
21
|
+
id: 1,
|
|
22
|
+
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
23
|
+
data: identitySecondPrivateKey.toPublicKey().toBuffer(),
|
|
24
|
+
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
25
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.HIGH,
|
|
26
|
+
readOnly: false,
|
|
16
27
|
});
|
|
17
28
|
|
|
18
29
|
account.storage
|
|
@@ -4,12 +4,12 @@ export async function createTransactionInAccount(account) {
|
|
|
4
4
|
// add fake tx to the wallet so it will be able to create transactions
|
|
5
5
|
const walletTransaction = new Transaction(undefined)
|
|
6
6
|
.from([{
|
|
7
|
-
amount:
|
|
7
|
+
amount: 1500000,
|
|
8
8
|
script: '76a914f9996443a7d5e2694560f8715e5e8fe602133c6088ac',
|
|
9
9
|
outputIndex: 0,
|
|
10
10
|
txid: new Transaction(undefined).hash,
|
|
11
11
|
}])
|
|
12
|
-
.to(account.getAddress(10).address,
|
|
12
|
+
.to(account.getAddress(10).address, 1000000);
|
|
13
13
|
|
|
14
14
|
await account.importTransactions([[walletTransaction.serialize(true)]]);
|
|
15
15
|
|
|
@@ -58,7 +58,7 @@ function makeGetIdentityRespondWithIdentity(client, dapiClientMock) {
|
|
|
58
58
|
let identityToResolve = new Identity({
|
|
59
59
|
protocolVersion: interceptedIdentityStateTransition.getProtocolVersion(),
|
|
60
60
|
id: interceptedIdentityStateTransition.getIdentityId().toBuffer(),
|
|
61
|
-
publicKeys: interceptedIdentityStateTransition.getPublicKeys().map((key) => key.toObject()),
|
|
61
|
+
publicKeys: interceptedIdentityStateTransition.getPublicKeys().map((key) => key.toObject({ skipSignature: true })),
|
|
62
62
|
balance: interceptedIdentityStateTransition.getAssetLockProof().getOutput().satoshis,
|
|
63
63
|
revision: 0,
|
|
64
64
|
});
|
|
@@ -87,7 +87,7 @@ export async function createAndAttachTransportMocksToClient(client, sinon) {
|
|
|
87
87
|
await accountPromise;
|
|
88
88
|
|
|
89
89
|
// Putting data in transport stubs
|
|
90
|
-
transportMock.
|
|
90
|
+
transportMock.getIdentitiesByPublicKeyHashes.resolves([]);
|
|
91
91
|
makeTxStreamEmitISLocksForTransactions(transportMock, txStreamMock);
|
|
92
92
|
makeGetIdentityRespondWithIdentity(client, dapiClientMock);
|
|
93
93
|
|
package/webpack.base.config.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const webpack = require('webpack');
|
|
3
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
3
4
|
|
|
4
5
|
const baseConfig = {
|
|
5
6
|
entry: './src/index.ts',
|
|
7
|
+
devtool: 'eval',
|
|
6
8
|
module: {
|
|
7
9
|
rules: [
|
|
8
10
|
{
|
|
@@ -12,6 +14,14 @@ const baseConfig = {
|
|
|
12
14
|
},
|
|
13
15
|
],
|
|
14
16
|
},
|
|
17
|
+
optimization: {
|
|
18
|
+
minimize: true,
|
|
19
|
+
minimizer: [new TerserPlugin({
|
|
20
|
+
terserOptions: {
|
|
21
|
+
keep_classnames: true // fixes empty string in `object.constructor.name`
|
|
22
|
+
}
|
|
23
|
+
})],
|
|
24
|
+
},
|
|
15
25
|
resolve: {
|
|
16
26
|
extensions: ['.ts', '.js', '.json'],
|
|
17
27
|
fallback: {
|
|
@@ -29,6 +39,10 @@ const baseConfig = {
|
|
|
29
39
|
zlib: require.resolve('browserify-zlib'),
|
|
30
40
|
events: require.resolve('events/'),
|
|
31
41
|
string_decoder: require.resolve('string_decoder/'),
|
|
42
|
+
tls: require.resolve('tls/'),
|
|
43
|
+
net: require.resolve('net/'),
|
|
44
|
+
// Browser build have to use native WebSocket
|
|
45
|
+
ws: require.resolve('./build-utils/ws'),
|
|
32
46
|
},
|
|
33
47
|
},
|
|
34
48
|
plugins: [
|
package/webpack.config.js
CHANGED
|
@@ -4,11 +4,15 @@ const webpackBaseConfig = require("./webpack.base.config");
|
|
|
4
4
|
const webConfig = {
|
|
5
5
|
...webpackBaseConfig,
|
|
6
6
|
entry: './build/src/index.js',
|
|
7
|
+
devtool: 'source-map',
|
|
7
8
|
mode: 'production',
|
|
9
|
+
target: 'web',
|
|
8
10
|
output: {
|
|
9
11
|
path: path.resolve(__dirname, 'dist'),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
library: {
|
|
13
|
+
name: 'Dash',
|
|
14
|
+
type: 'umd'
|
|
15
|
+
},
|
|
12
16
|
filename: 'dash.min.js',
|
|
13
17
|
// fixes ReferenceError: window is not defined
|
|
14
18
|
globalObject: "(typeof self !== 'undefined' ? self : this)"
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
## Publishing a new contract
|
|
2
|
-
|
|
3
|
-
Right now, Evonet does not support publishing a public contract. You will have to run a local instance or wait for updates to the [Dash Platform documentation](https://dashplatform.readme.io/docs) regarding how to run a devnet locally and publish a contract.
|
|
4
|
-
|
|
5
|
-
For now you can try your luck using the [Dash Network Deploy tool](https://github.com/dashevo/dash-network-deploy) and refer to [how to use a local evonet](../examples/use-local-evonet.md).
|
|
6
|
-
|
|
7
|
-
## Create your contract
|
|
8
|
-
|
|
9
|
-
After having [registered an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
|
|
10
|
-
and [attached to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity) crafted your schema (you can see how on [about schemas](getting-started/about-schemas.md) and read the [DPNS schema](https://github.com/dashevo/dpns-contract/blob/v0.2-dev/src/schema/dpns-documents.json) as an example), you then can perform the below actions :
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
const schema = {};// You JSON schema defining the app.
|
|
14
|
-
const client = new Dash.Client({
|
|
15
|
-
wallet: {
|
|
16
|
-
mnemonic: '', // Your app mnemonic, which holds the identity
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// This is the name previously registered in DPNS.
|
|
21
|
-
const appName = 'MyApp';
|
|
22
|
-
client.isReady().then(registerContract);
|
|
23
|
-
|
|
24
|
-
async function getIdentity(idName) {
|
|
25
|
-
const {identities, names} = client.platform;
|
|
26
|
-
const identityId = (await names.get(idName)).data.records.dashIdentity;
|
|
27
|
-
const identity = await identities.get(identityId);
|
|
28
|
-
return identity
|
|
29
|
-
}
|
|
30
|
-
async function registerContract() {
|
|
31
|
-
const {platform} = client;
|
|
32
|
-
const identity = await getIdentity(appName);
|
|
33
|
-
const contract = platform.contracts.create(schema, identity)
|
|
34
|
-
const contractId = await platform.contracts.publish(contract, identity);
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Fetch or publish documents on your app
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
const schema = {};// You JSON schema defining the app.
|
|
42
|
-
|
|
43
|
-
// This is the name previously registered in DPNS.
|
|
44
|
-
const client = new Dash.Client({
|
|
45
|
-
wallet: {
|
|
46
|
-
mnemonic: "", // Your app mnemonic, which holds the identity
|
|
47
|
-
},
|
|
48
|
-
apps:{
|
|
49
|
-
myapp:{
|
|
50
|
-
contractId:""// The registered contract id
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
client.isReady().then(getDocuments);
|
|
56
|
-
|
|
57
|
-
async function getDocuments() {
|
|
58
|
-
const {documents} = client.platform;
|
|
59
|
-
const docs = await documents.fetch('myapp.myfield',{});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function publishDocument(){
|
|
63
|
-
const identity = await getIdentity(appName);
|
|
64
|
-
const {documents} = client.platform;
|
|
65
|
-
const doc = await documents.create('myapp.myfield',identity, {myproperties:'my value'});
|
|
66
|
-
await documents.broadcast(doc, identity)
|
|
67
|
-
}
|
|
68
|
-
```
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
## Updating an existing contract
|
|
2
|
-
|
|
3
|
-
To update your existing data contract you have to follow these steps:
|
|
4
|
-
|
|
5
|
-
### Fetch your exising contract
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
const schema = {};// You JSON schema defining the app.
|
|
9
|
-
const client = new Dash.Client({
|
|
10
|
-
wallet: {
|
|
11
|
-
mnemonic: '', // Your app mnemonic, which holds the identity
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const exisingContractId = ''; // Your existing data contract id
|
|
16
|
-
|
|
17
|
-
const existingDataContract = await client.platform.contracts.get(exisingContractId);
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Update document definitions
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
// Update an existing document
|
|
24
|
-
const documentDefinition = existingDataContract.getDocumentDefinition('myDocumentType');
|
|
25
|
-
|
|
26
|
-
// adding optional field
|
|
27
|
-
documentDefinition.properties.newField = {
|
|
28
|
-
type: 'integer',
|
|
29
|
-
minimum: 1,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
existingDataContract.setDocumentDefinition('myDocumentType', documentDefinition);
|
|
33
|
-
|
|
34
|
-
// ... or, add a new one
|
|
35
|
-
const newDocumentDefinition = {
|
|
36
|
-
type: 'object',
|
|
37
|
-
properties: {
|
|
38
|
-
someField: {
|
|
39
|
-
type: 'integer',
|
|
40
|
-
minimum: 42,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
required: ['someField'],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
existingDataContract.setDocumentDefinition('myNewDocument', newDocumentDefinition);
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Broadcast your changes
|
|
50
|
-
|
|
51
|
-
```js
|
|
52
|
-
await client.platform.contracts.update(existingDataContract, yourExistingIdentity);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**Note, that update will be only allowed if schema is backward compatible. Also, version incremented by 1 and only one of following fields updated: `$defs`, `documents` or `version`**
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
## Use a local evonet
|
|
2
|
-
|
|
3
|
-
You can refer to https://github.com/dashevo/dash-network-deploy to deploy a devnet locally.
|
|
4
|
-
|
|
5
|
-
You will then need to pass the seed ip, and [register the DPNS contract](https://github.com/dashevo/dpns-contract), and reference its `contractId` below.
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
const seeds = [{service: '54.245.133.124'}];
|
|
9
|
-
const client = new Dash.Client({
|
|
10
|
-
seeds,
|
|
11
|
-
apps: {
|
|
12
|
-
dpns: {
|
|
13
|
-
contractId: '77w8Xqn25HwJhjodrHW133aXhjuTsTv9ozQaYpSHACE3'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
After that, usage is the same.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
const clientOpts = {
|
|
3
|
-
network: 'testnet',
|
|
4
|
-
wallet: {
|
|
5
|
-
mnemonic: null, // Will generate a new address, you should keep it.
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
const client = new Dash.Client(clientOpts);
|
|
9
|
-
|
|
10
|
-
const displayFundingAddress = async function () {
|
|
11
|
-
const {account, wallet} = client;
|
|
12
|
-
|
|
13
|
-
const mnemonic = wallet.exportWallet();
|
|
14
|
-
const address = account.getUnusedAddress().address;
|
|
15
|
-
console.log('Mnemonic:', mnemonic);
|
|
16
|
-
console.log('Total balance', account.getTotalBalance());
|
|
17
|
-
console.log('Unused address:', address);
|
|
18
|
-
// Fund this address using the faucet : http://devnet-evonet-1117662964.us-west-2.elb.amazonaws.com/
|
|
19
|
-
};
|
|
20
|
-
const onReceivedTransaction = function(data){
|
|
21
|
-
const {account} = client;
|
|
22
|
-
console.log('Received tx',data.txid);
|
|
23
|
-
console.log('Total pending confirmation', account.getUnconfirmedBalance());
|
|
24
|
-
console.log('Total balance', account.getTotalBalance());
|
|
25
|
-
}
|
|
26
|
-
client.account.on('FETCHED/UNCONFIRMED_TRANSACTION',onReceivedTransaction)
|
|
27
|
-
client.isReady().then(displayFundingAddress);
|
|
28
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const DashJS = require('dash');
|
|
2
|
-
|
|
3
|
-
const sdkOpts = {
|
|
4
|
-
network: 'testnet',
|
|
5
|
-
wallet: {
|
|
6
|
-
mnemonic: 'your mnemonic here',
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
const sdk = new DashJS.Client(sdkOpts);
|
|
10
|
-
|
|
11
|
-
const registerContract = async function () {
|
|
12
|
-
await sdk.isReady();
|
|
13
|
-
let platform = sdk.platform;
|
|
14
|
-
const identity = await platform.identities.get('your identity id here');
|
|
15
|
-
|
|
16
|
-
const contractDocuments = {
|
|
17
|
-
note: {
|
|
18
|
-
properties: {
|
|
19
|
-
message: {
|
|
20
|
-
type: "string"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
indices: [
|
|
24
|
-
{ "message": "asc"}
|
|
25
|
-
],
|
|
26
|
-
additionalProperties: false
|
|
27
|
-
}};
|
|
28
|
-
|
|
29
|
-
const contract = await platform.contracts.create(contractDocuments, identity);
|
|
30
|
-
await platform.dpp.dataContract.validate(contract)
|
|
31
|
-
await platform.contracts.publish(contract, identity);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
registerContract();
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
const clientOpts = {
|
|
3
|
-
network: 'testnet',
|
|
4
|
-
wallet: {
|
|
5
|
-
mnemonic: 'your mnemonic here',
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
const client = new Dash.Client(clientOpts);
|
|
9
|
-
|
|
10
|
-
const createIdentity = async function () {
|
|
11
|
-
await client.isReady();
|
|
12
|
-
|
|
13
|
-
let platform = client.platform;
|
|
14
|
-
|
|
15
|
-
platform
|
|
16
|
-
.identities
|
|
17
|
-
.register()
|
|
18
|
-
.then((identityId) => {
|
|
19
|
-
console.log({identityId});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
createIdentity();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
const clientOpts = {
|
|
3
|
-
network: 'testnet',
|
|
4
|
-
wallet: {
|
|
5
|
-
mnemonic: 'your mnemonic here',
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
const identityId = 'your identity id';
|
|
9
|
-
const client = new Dash.Client(clientOpts);
|
|
10
|
-
|
|
11
|
-
const registerName = async function () {
|
|
12
|
-
let platform = client.platform;
|
|
13
|
-
await client.isReady();
|
|
14
|
-
|
|
15
|
-
const identity = await platform.identities.get(identityId);
|
|
16
|
-
const nameRegistration = await platform.names.register('alice', identity);
|
|
17
|
-
console.log({nameRegistration});
|
|
18
|
-
};
|
|
19
|
-
registerName();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
|
|
3
|
-
const clientOpts = {
|
|
4
|
-
network: 'testnet'
|
|
5
|
-
};
|
|
6
|
-
const client = new Dash.Client(clientOpts);
|
|
7
|
-
|
|
8
|
-
const getContract = async function () {
|
|
9
|
-
let platform = client.platform;
|
|
10
|
-
await client.isReady();
|
|
11
|
-
|
|
12
|
-
platform
|
|
13
|
-
.contracts
|
|
14
|
-
.get('77w8Xqn25HwJhjodrHW133aXhjuTsTv9ozQaYpSHACE3')
|
|
15
|
-
.then((contract) => {
|
|
16
|
-
console.dir({contract},{depth:5});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
getContract();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
|
|
3
|
-
const clientOpts = {
|
|
4
|
-
network: 'testnet'
|
|
5
|
-
};
|
|
6
|
-
const client = new Dash.Client(clientOpts);
|
|
7
|
-
|
|
8
|
-
const getDocuments = async function () {
|
|
9
|
-
let platform = client.platform;
|
|
10
|
-
await client.isReady();
|
|
11
|
-
|
|
12
|
-
const queryOpts = {
|
|
13
|
-
where: [
|
|
14
|
-
['normalizedLabel', 'startsWith', 'd'],
|
|
15
|
-
['normalizedParentDomainName', '==', 'dash'],
|
|
16
|
-
],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const documents = await platform.documents.get('dpns.domain', queryOpts);
|
|
20
|
-
console.dir({documents},{depth:5});
|
|
21
|
-
};
|
|
22
|
-
getDocuments();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
|
|
3
|
-
const clientOpts = {
|
|
4
|
-
network: 'testnet'
|
|
5
|
-
};
|
|
6
|
-
const client = new Dash.Client(clientOpts);
|
|
7
|
-
|
|
8
|
-
const getIdentity = async function () {
|
|
9
|
-
let platform = client.platform;
|
|
10
|
-
await client.isReady();
|
|
11
|
-
|
|
12
|
-
platform
|
|
13
|
-
.identities
|
|
14
|
-
.get('3GegupTgRfdN9JMS8R6QXF3B2VbZtiw63eyudh1oMJAk')
|
|
15
|
-
.then((identity) => {
|
|
16
|
-
console.log({identity});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
getIdentity();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
|
|
3
|
-
const clientOpts = {
|
|
4
|
-
network: 'testnet'
|
|
5
|
-
};
|
|
6
|
-
const client = new Dash.Client(clientOpts);
|
|
7
|
-
|
|
8
|
-
const platform = client.platform;
|
|
9
|
-
|
|
10
|
-
async function retrieveName(){
|
|
11
|
-
const user = await platform.names.get('alice');
|
|
12
|
-
console.dir({user}, {depth:5});
|
|
13
|
-
}
|
|
14
|
-
retrieveName();
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const Dash = require('dash');
|
|
2
|
-
|
|
3
|
-
const clientOpts = {
|
|
4
|
-
network: 'testnet',
|
|
5
|
-
wallet: {
|
|
6
|
-
mnemonic: null,
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const client = new Dash.Client(clientOpts);
|
|
11
|
-
|
|
12
|
-
const message = new Dash.Core.Message('hello, world');
|
|
13
|
-
|
|
14
|
-
const signAndVerify = async function () {
|
|
15
|
-
const {account, wallet} = client;
|
|
16
|
-
|
|
17
|
-
const mnemonic = wallet.exportWallet();
|
|
18
|
-
console.log('Mnemonic:', mnemonic);
|
|
19
|
-
|
|
20
|
-
const idKey = account.getIdentityHDKey()
|
|
21
|
-
const idPrivateKey = idKey.privateKey;
|
|
22
|
-
const idAddress = idPrivateKey.toAddress().toString()
|
|
23
|
-
|
|
24
|
-
const signed = account.sign(message, idPrivateKey);
|
|
25
|
-
const verify = message.verify(idAddress, signed.toString());
|
|
26
|
-
console.log(verify);
|
|
27
|
-
};
|
|
28
|
-
client.isReady().then(signAndVerify);
|
|
29
|
-
|
package/examples/schema.json
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"contact": {
|
|
3
|
-
"indices": [
|
|
4
|
-
{
|
|
5
|
-
"name": "userIdToUserId",
|
|
6
|
-
"unique": true,
|
|
7
|
-
"properties": [
|
|
8
|
-
{
|
|
9
|
-
"$userId": "asc"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"toUserId": "asc"
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
"required": [
|
|
18
|
-
"toUserId",
|
|
19
|
-
"publicKey"
|
|
20
|
-
],
|
|
21
|
-
"properties": {
|
|
22
|
-
"toUserId": {
|
|
23
|
-
"type": "string"
|
|
24
|
-
},
|
|
25
|
-
"publicKey": {
|
|
26
|
-
"type": "string"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"additionalProperties": false
|
|
30
|
-
},
|
|
31
|
-
"profile": {
|
|
32
|
-
"indices": [
|
|
33
|
-
{
|
|
34
|
-
"name": "userId",
|
|
35
|
-
"unique": true,
|
|
36
|
-
"properties": [
|
|
37
|
-
{
|
|
38
|
-
"$userId": "asc"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"required": [
|
|
44
|
-
"avatarUrl",
|
|
45
|
-
"about"
|
|
46
|
-
],
|
|
47
|
-
"properties": {
|
|
48
|
-
"about": {
|
|
49
|
-
"type": "string"
|
|
50
|
-
},
|
|
51
|
-
"avatarUrl": {
|
|
52
|
-
"type": "string",
|
|
53
|
-
"format": "url"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"additionalProperties": false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const network = "testnet";
|
|
2
|
-
const opts = {
|
|
3
|
-
network,
|
|
4
|
-
wallet: {
|
|
5
|
-
mnemonic: "arena light cheap control apple buffalo indicate rare motor valid accident isolate",
|
|
6
|
-
},
|
|
7
|
-
apps: {
|
|
8
|
-
dashpay: {
|
|
9
|
-
contractId: ''// Provide the dashpay contract id here
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const clientInstance = new Dash.Client(opts);
|
|
14
|
-
|
|
15
|
-
(async ()=>{
|
|
16
|
-
const { platform } = clientInstance;
|
|
17
|
-
account = await clientInstance.getWalletAccount();
|
|
18
|
-
|
|
19
|
-
async function sendPayment() {
|
|
20
|
-
const tx = await account.createTransaction({recipient: 'yNPbcFfabtNmmxKdGwhHomdYfVs6gikbPf', satoshis: 12000});
|
|
21
|
-
console.log(await account.broadcastTransaction(tx));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function readDocument() {
|
|
25
|
-
const profile = await platform.documents.fetch('dashpay.profile', {});
|
|
26
|
-
console.log(profile);
|
|
27
|
-
}
|
|
28
|
-
})()
|