dash 3.23.0-dev.1 → 3.23.0-dev.4
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 +30 -3
- 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 +15 -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 +2 -2
- package/package.json +16 -12
- 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 +17 -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
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
1
|
import Identifier from "@dashevo/dpp/lib/Identifier";
|
|
3
2
|
import {Platform} from "../../Platform";
|
|
4
3
|
|
|
5
|
-
import createAssetLockTransaction from "../../createAssetLockTransaction";
|
|
6
|
-
import createAssetLockProof from "./internal/createAssetLockProof";
|
|
7
|
-
import createIdentityTopUpTransition from "./internal/createIdnetityTopUpTransition";
|
|
8
4
|
import broadcastStateTransition from "../../broadcastStateTransition";
|
|
9
5
|
|
|
10
6
|
/**
|
|
@@ -28,15 +24,16 @@ export async function topUp(this: Platform, identityId: Identifier | string, amo
|
|
|
28
24
|
transaction: assetLockTransaction,
|
|
29
25
|
privateKey: assetLockPrivateKey,
|
|
30
26
|
outputIndex: assetLockOutputIndex
|
|
31
|
-
} = await createAssetLockTransaction(
|
|
27
|
+
} = await this.identities.utils.createAssetLockTransaction(amount);
|
|
32
28
|
|
|
33
29
|
// Broadcast Asset Lock transaction
|
|
34
30
|
await account.broadcastTransaction(assetLockTransaction);
|
|
35
31
|
// Create a proof for the asset lock transaction
|
|
36
|
-
const assetLockProof = await
|
|
32
|
+
const assetLockProof = await this.identities.utils
|
|
33
|
+
.createAssetLockProof(assetLockTransaction, assetLockOutputIndex);
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const identityTopUpTransition = await this.identities.utils
|
|
36
|
+
.createIdentityTopUpTransition(assetLockProof, assetLockPrivateKey, identityId);
|
|
40
37
|
|
|
41
38
|
// Broadcast ST
|
|
42
39
|
await broadcastStateTransition(this, identityTopUpTransition);
|
|
@@ -11,6 +11,7 @@ import broadcastStateTransition from "../../broadcastStateTransition";
|
|
|
11
11
|
* @param {Platform} this - bound instance class
|
|
12
12
|
* @param {Identity} identity - identity to update
|
|
13
13
|
* @param {{add: IdentityPublicKey[]; disable: IdentityPublicKey[]}} publicKeys - public keys to add
|
|
14
|
+
* @param {Object<string, any>} privateKeys - public keys to add
|
|
14
15
|
*
|
|
15
16
|
* @returns {boolean}
|
|
16
17
|
*/
|
|
@@ -18,6 +19,7 @@ export async function update(
|
|
|
18
19
|
this: Platform,
|
|
19
20
|
identity: Identity,
|
|
20
21
|
publicKeys: { add?: IdentityPublicKey[]; disable?: IdentityPublicKey[] },
|
|
22
|
+
privateKeys: { string, any },
|
|
21
23
|
): Promise<any> {
|
|
22
24
|
await this.initialize();
|
|
23
25
|
|
|
@@ -28,7 +30,39 @@ export async function update(
|
|
|
28
30
|
publicKeys,
|
|
29
31
|
);
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
const signerKeyIndex = 0;
|
|
34
|
+
|
|
35
|
+
// Create key proofs
|
|
36
|
+
if (identityUpdateTransition.getPublicKeysToAdd()) {
|
|
37
|
+
const signerKey = identity.getPublicKeys()[signerKeyIndex];
|
|
38
|
+
|
|
39
|
+
// must be run sequentially! will not work with Promise.all!
|
|
40
|
+
// more info at https://jrsinclair.com/articles/2019/how-to-run-async-js-in-parallel-or-sequential/
|
|
41
|
+
|
|
42
|
+
const starterPromise = Promise.resolve(null);
|
|
43
|
+
|
|
44
|
+
await identityUpdateTransition.getPublicKeysToAdd().reduce(
|
|
45
|
+
(previousPromise, publicKey) => previousPromise.then(async () => {
|
|
46
|
+
const privateKey = privateKeys[publicKey.getId()];
|
|
47
|
+
|
|
48
|
+
if (!privateKey) {
|
|
49
|
+
throw new Error(`Private key for key ${publicKey.getId()} not found`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
identityUpdateTransition.setSignaturePublicKeyId(signerKey.getId());
|
|
53
|
+
|
|
54
|
+
await identityUpdateTransition.signByPrivateKey(privateKey, publicKey.getType());
|
|
55
|
+
|
|
56
|
+
publicKey.setSignature(identityUpdateTransition.getSignature());
|
|
57
|
+
|
|
58
|
+
identityUpdateTransition.setSignature(undefined);
|
|
59
|
+
identityUpdateTransition.setSignaturePublicKeyId(undefined);
|
|
60
|
+
}),
|
|
61
|
+
starterPromise,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await signStateTransition(this, identityUpdateTransition, identity, signerKeyIndex);
|
|
32
66
|
|
|
33
67
|
const result = await dpp.stateTransition.validateBasic(identityUpdateTransition);
|
|
34
68
|
|
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)"
|