dash 3.22.1 → 3.23.0-dev.1
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/build/src/SDK/Client/Client.spec.js +2 -2
- package/build/src/SDK/Client/Platform/Platform.js +2 -0
- package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/register.js +3 -1
- package/build/src/SDK/Client/Platform/methods/identities/register.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/update.js +85 -0
- package/build/src/SDK/Client/Platform/methods/identities/update.js.map +1 -0
- package/build/src/SDK/SDK.js +1 -1
- package/build/src/SDK/SDK.js.map +1 -1
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js +4 -2
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js.map +1 -1
- package/build/src/test/fixtures/createTransactionFixtureInAccount.js +1 -1
- package/build/src/test/fixtures/createTransactionFixtureInAccount.js.map +1 -1
- package/dist/src/SDK/Client/Platform/Platform.d.ts +1 -0
- package/dist/src/SDK/Client/Platform/methods/identities/update.d.ts +17 -0
- package/dist/src/SDK/SDK.d.ts +7 -1
- package/package.json +8 -8
- package/src/SDK/Client/Client.spec.ts +2 -2
- package/src/SDK/Client/Platform/Platform.ts +3 -0
- package/src/SDK/Client/Platform/methods/identities/register.ts +5 -4
- package/src/SDK/Client/Platform/methods/identities/update.ts +45 -0
- package/src/SDK/SDK.ts +1 -1
- package/src/test/fixtures/createIdentityFixtureInAccount.ts +4 -3
- package/src/test/fixtures/createTransactionFixtureInAccount.ts +2 -2
|
@@ -78,7 +78,7 @@ describe('Dash - Client', function suite() {
|
|
|
78
78
|
switch (_b.label) {
|
|
79
79
|
case 0:
|
|
80
80
|
testMnemonic = 'agree country attract master mimic ball load beauty join gentle turtle hover';
|
|
81
|
-
testHDKey = "
|
|
81
|
+
testHDKey = "tprv8ZgxMBicQKsPeGi4CikhacVPz6UmErenu1PoD3S4XcEDSPP8auRaS8hG3DQtsQ2i9HACgohHwF5sgMVJNksoKqYoZbis8o75Pp1koCme2Yo";
|
|
82
82
|
client = new index_1.Client({
|
|
83
83
|
wallet: {
|
|
84
84
|
HDPrivateKey: testHDKey,
|
|
@@ -204,7 +204,7 @@ describe('Dash - Client', function suite() {
|
|
|
204
204
|
importedIdentityIds = account.identities.getIdentityIds();
|
|
205
205
|
// Check that we've imported identities properly
|
|
206
206
|
chai_1.expect(importedIdentityIds.length).to.be.equal(accountIdentitiesCountBeforeTest + 1);
|
|
207
|
-
chai_1.expect(importedIdentityIds[
|
|
207
|
+
chai_1.expect(importedIdentityIds[1]).to.be.equal(interceptedIdentityStateTransition.getIdentityId().toString());
|
|
208
208
|
return [2 /*return*/];
|
|
209
209
|
}
|
|
210
210
|
});
|
|
@@ -63,6 +63,7 @@ var get_2 = __importDefault(require("./methods/contracts/get"));
|
|
|
63
63
|
var get_3 = __importDefault(require("./methods/identities/get"));
|
|
64
64
|
var register_1 = __importDefault(require("./methods/identities/register"));
|
|
65
65
|
var topUp_1 = __importDefault(require("./methods/identities/topUp"));
|
|
66
|
+
var update_2 = __importDefault(require("./methods/identities/update"));
|
|
66
67
|
var register_2 = __importDefault(require("./methods/names/register"));
|
|
67
68
|
var resolve_1 = __importDefault(require("./methods/names/resolve"));
|
|
68
69
|
var resolveByRecord_1 = __importDefault(require("./methods/names/resolveByRecord"));
|
|
@@ -106,6 +107,7 @@ var Platform = /** @class */ (function () {
|
|
|
106
107
|
register: register_1.default.bind(this),
|
|
107
108
|
get: get_3.default.bind(this),
|
|
108
109
|
topUp: topUp_1.default.bind(this),
|
|
110
|
+
update: update_2.default.bind(this),
|
|
109
111
|
};
|
|
110
112
|
this.client = options.client;
|
|
111
113
|
var mappedProtocolVersion = Platform.networkToProtocolVersion.get(options.network);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../../../src/SDK/Client/Platform/Platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,qDAAgD;AAKhD,4EAA8D;AAC9D,sEAAwD;AACxD,gEAAkD;AAElD,wEAA0D;AAC1D,sEAAwD;AACxD,sEAAwD;AACxD,gEAAkD;AAElD,iEAAmD;AACnD,2EAA6D;AAC7D,qEAAuD;
|
|
1
|
+
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../../../src/SDK/Client/Platform/Platform.ts"],"names":[],"mappings":"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"}
|
|
@@ -80,7 +80,9 @@ function register(fundingAmount) {
|
|
|
80
80
|
case 7:
|
|
81
81
|
_c.sent();
|
|
82
82
|
// If state transition was broadcast without any errors, import identity to the account
|
|
83
|
-
account.storage
|
|
83
|
+
account.storage
|
|
84
|
+
.getWalletStore(account.walletId)
|
|
85
|
+
.insertIdentityIdAtIndex(identity.getId().toString(), identityIndex);
|
|
84
86
|
return [2 /*return*/, identity];
|
|
85
87
|
}
|
|
86
88
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../../../../src/SDK/Client/Platform/methods/identities/register.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gGAA0E;AAC1E,6GAAuF;AACvF,yFAAmE;AACnE,4FAAsE;AAEtE;;;;;GAKG;AACH,SAA8B,QAAQ,CAEpC,aAA8B;IAA9B,8BAAA,EAAA,qBAA8B;;;;;wBAE5B,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;oBAAvB,SAAuB,CAAC;oBAEhB,MAAM,GAAK,IAAI,OAAT,CAAU;oBAER,qBAAM,MAAM,CAAC,gBAAgB,EAAE,EAAA;;oBAAzC,OAAO,GAAG,SAA+B;oBAM3C,qBAAM,oCAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,EAAA;;oBAJnD,KAIF,SAAqD,EAHxC,oBAAoB,iBAAA,EACrB,mBAAmB,gBAAA,EAClB,oBAAoB,iBAAA;oBAGrC,mCAAmC;oBACnC,qBAAM,OAAO,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,EAAA;;oBADxD,mCAAmC;oBACnC,SAAwD,CAAC;oBAClC,qBAAM,8BAAoB,CAAC,IAAI,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,EAAA;;oBAA7F,cAAc,GAAG,SAA4E;oBAErC,qBAAM,wCAA8B,CAC9F,IAAI,EAAE,cAAc,EAAE,mBAAmB,CAC5C,EAAA;;oBAFK,KAAwD,SAE7D,EAFO,QAAQ,cAAA,EAAE,wBAAwB,8BAAA,EAAE,aAAa,mBAAA;oBAGzD,qBAAM,kCAAwB,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;oBAE/D,uFAAuF;
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../../../../src/SDK/Client/Platform/methods/identities/register.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gGAA0E;AAC1E,6GAAuF;AACvF,yFAAmE;AACnE,4FAAsE;AAEtE;;;;;GAKG;AACH,SAA8B,QAAQ,CAEpC,aAA8B;IAA9B,8BAAA,EAAA,qBAA8B;;;;;wBAE5B,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;oBAAvB,SAAuB,CAAC;oBAEhB,MAAM,GAAK,IAAI,OAAT,CAAU;oBAER,qBAAM,MAAM,CAAC,gBAAgB,EAAE,EAAA;;oBAAzC,OAAO,GAAG,SAA+B;oBAM3C,qBAAM,oCAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,EAAA;;oBAJnD,KAIF,SAAqD,EAHxC,oBAAoB,iBAAA,EACrB,mBAAmB,gBAAA,EAClB,oBAAoB,iBAAA;oBAGrC,mCAAmC;oBACnC,qBAAM,OAAO,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,EAAA;;oBADxD,mCAAmC;oBACnC,SAAwD,CAAC;oBAClC,qBAAM,8BAAoB,CAAC,IAAI,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,EAAA;;oBAA7F,cAAc,GAAG,SAA4E;oBAErC,qBAAM,wCAA8B,CAC9F,IAAI,EAAE,cAAc,EAAE,mBAAmB,CAC5C,EAAA;;oBAFK,KAAwD,SAE7D,EAFO,QAAQ,cAAA,EAAE,wBAAwB,8BAAA,EAAE,aAAa,mBAAA;oBAGzD,qBAAM,kCAAwB,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;oBAE/D,uFAAuF;oBACxF,OAAO,CAAC,OAAO;yBACb,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;yBAChC,uBAAuB,CACtB,QAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,EAC3B,aAAa,CACd,CAAC;oBAEF,sBAAO,QAAQ,EAAC;;;;CACnB;AAlCD,2BAkCC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.update = void 0;
|
|
43
|
+
var signStateTransition_1 = require("../../signStateTransition");
|
|
44
|
+
var broadcastStateTransition_1 = __importDefault(require("../../broadcastStateTransition"));
|
|
45
|
+
/**
|
|
46
|
+
* Update platform identities
|
|
47
|
+
*
|
|
48
|
+
* @param {Platform} this - bound instance class
|
|
49
|
+
* @param {Identity} identity - identity to update
|
|
50
|
+
* @param {{add: IdentityPublicKey[]; disable: IdentityPublicKey[]}} publicKeys - public keys to add
|
|
51
|
+
*
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
function update(identity, publicKeys) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var dpp, identityUpdateTransition, result;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, this.initialize()];
|
|
60
|
+
case 1:
|
|
61
|
+
_a.sent();
|
|
62
|
+
dpp = this.dpp;
|
|
63
|
+
identityUpdateTransition = dpp.identity.createIdentityUpdateTransition(identity, publicKeys);
|
|
64
|
+
return [4 /*yield*/, signStateTransition_1.signStateTransition(this, identityUpdateTransition, identity)];
|
|
65
|
+
case 2:
|
|
66
|
+
_a.sent();
|
|
67
|
+
return [4 /*yield*/, dpp.stateTransition.validateBasic(identityUpdateTransition)];
|
|
68
|
+
case 3:
|
|
69
|
+
result = _a.sent();
|
|
70
|
+
if (!result.isValid()) {
|
|
71
|
+
throw new Error("StateTransition is invalid - " + JSON.stringify(result.getErrors()));
|
|
72
|
+
}
|
|
73
|
+
// Broadcast ST
|
|
74
|
+
return [4 /*yield*/, broadcastStateTransition_1.default(this, identityUpdateTransition)];
|
|
75
|
+
case 4:
|
|
76
|
+
// Broadcast ST
|
|
77
|
+
_a.sent();
|
|
78
|
+
return [2 /*return*/, true];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.update = update;
|
|
84
|
+
exports.default = update;
|
|
85
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../../../src/SDK/Client/Platform/methods/identities/update.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,iEAAgE;AAEhE,4FAAsE;AAEtE;;;;;;;;GAQG;AACH,SAAsB,MAAM,CAE1B,QAAkB,EAClB,UAAwE;;;;;wBAExE,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;oBAAvB,SAAuB,CAAC;oBAEhB,GAAG,GAAK,IAAI,IAAT,CAAU;oBAEf,wBAAwB,GAAG,GAAG,CAAC,QAAQ,CAAC,8BAA8B,CAC1E,QAAQ,EACR,UAAU,CACX,CAAC;oBAEF,qBAAM,yCAAmB,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,CAAC,EAAA;;oBAAnE,SAAmE,CAAC;oBAErD,qBAAM,GAAG,CAAC,eAAe,CAAC,aAAa,CAAC,wBAAwB,CAAC,EAAA;;oBAA1E,MAAM,GAAG,SAAiE;oBAEhF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE;wBACrB,MAAM,IAAI,KAAK,CAAC,kCAAgC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAG,CAAC,CAAC;qBACvF;oBAED,eAAe;oBACf,qBAAM,kCAAwB,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAA;;oBAD9D,eAAe;oBACf,SAA8D,CAAC;oBAE/D,sBAAO,IAAI,EAAC;;;;CACb;AA1BD,wBA0BC;AAED,kBAAe,MAAM,CAAC"}
|
package/build/src/SDK/SDK.js
CHANGED
|
@@ -18,7 +18,7 @@ var SDK;
|
|
|
18
18
|
// Wallet-lib primitives
|
|
19
19
|
SDK.Wallet = wallet_lib_1.Wallet;
|
|
20
20
|
SDK.Account = wallet_lib_1.Account;
|
|
21
|
-
SDK.KeyChain = wallet_lib_1.
|
|
21
|
+
SDK.KeyChain = wallet_lib_1.DerivableKeyChain;
|
|
22
22
|
SDK.WalletLib = {
|
|
23
23
|
CONSTANTS: wallet_lib_1.CONSTANTS,
|
|
24
24
|
EVENTS: wallet_lib_1.EVENTS,
|
package/build/src/SDK/SDK.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDK.js","sourceRoot":"","sources":["../../../src/SDK/SDK.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6C;AAC7C,+BAAuC;AACvC,uCAAmD;AACnD,qEAA8D;AAE9D,kDAQ6B;AAE7B,IAAiB,GAAG,CAmBnB;AAnBD,WAAiB,GAAG;IACL,cAAU,GAAG,qBAAW,CAAC;IACzB,UAAM,GAAG,eAAO,CAAC;IAEjB,QAAI,GAAG,WAAK,CAAC;IACb,YAAQ,GAAG,mBAAS,CAAC;IAEhC,wBAAwB;IACb,UAAM,GAAG,mBAAO,CAAC;IACjB,WAAO,GAAG,oBAAQ,CAAC;IACnB,YAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"SDK.js","sourceRoot":"","sources":["../../../src/SDK/SDK.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6C;AAC7C,+BAAuC;AACvC,uCAAmD;AACnD,qEAA8D;AAE9D,kDAQ6B;AAE7B,IAAiB,GAAG,CAmBnB;AAnBD,WAAiB,GAAG;IACL,cAAU,GAAG,qBAAW,CAAC;IACzB,UAAM,GAAG,eAAO,CAAC;IAEjB,QAAI,GAAG,WAAK,CAAC;IACb,YAAQ,GAAG,mBAAS,CAAC;IAEhC,wBAAwB;IACb,UAAM,GAAG,mBAAO,CAAC;IACjB,WAAO,GAAG,oBAAQ,CAAC;IACnB,YAAQ,GAAG,8BAAS,CAAC;IAErB,aAAS,GAAG;QACnB,SAAS,EAAE,sBAAmB;QAC9B,MAAM,EAAE,mBAAgB;QACxB,OAAO,EAAE,oBAAiB;QAC1B,KAAK,EAAE,kBAAe;KACzB,CAAA;AAEL,CAAC,EAnBgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAmBnB;AACe,sBAAO"}
|
|
@@ -9,7 +9,7 @@ var IdentityPublicKey_1 = __importDefault(require("@dashevo/dpp/lib/identity/Ide
|
|
|
9
9
|
var getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFixture');
|
|
10
10
|
function createIdentityFixtureInAccount(account) {
|
|
11
11
|
var identityFixture = getIdentityFixture();
|
|
12
|
-
var identityFixtureIndex =
|
|
12
|
+
var identityFixtureIndex = 0;
|
|
13
13
|
var identityPrivateKey = account.identities.getIdentityHDKeyByIndex(identityFixtureIndex, 0).privateKey;
|
|
14
14
|
identityFixture.publicKeys[0] = new IdentityPublicKey_1.default({
|
|
15
15
|
id: 0,
|
|
@@ -18,7 +18,9 @@ function createIdentityFixtureInAccount(account) {
|
|
|
18
18
|
purpose: IdentityPublicKey_1.default.PURPOSES.AUTHENTICATION,
|
|
19
19
|
securityLevel: IdentityPublicKey_1.default.SECURITY_LEVELS.MASTER
|
|
20
20
|
});
|
|
21
|
-
account.storage
|
|
21
|
+
account.storage
|
|
22
|
+
.getWalletStore(account.walletId)
|
|
23
|
+
.insertIdentityIdAtIndex(identityFixture.getId().toString(), identityFixtureIndex);
|
|
22
24
|
return identityFixture;
|
|
23
25
|
}
|
|
24
26
|
exports.createIdentityFixtureInAccount = createIdentityFixtureInAccount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIdentityFixtureInAccount.js","sourceRoot":"","sources":["../../../../src/test/fixtures/createIdentityFixtureInAccount.ts"],"names":[],"mappings":";;;;;;AAAA,kGAA4E;AAC5E,aAAa;AACb,IAAM,kBAAkB,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAExF,SAAgB,8BAA8B,CAAC,OAAO;IAClD,IAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,IAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"createIdentityFixtureInAccount.js","sourceRoot":"","sources":["../../../../src/test/fixtures/createIdentityFixtureInAccount.ts"],"names":[],"mappings":";;;;;;AAAA,kGAA4E;AAC5E,aAAa;AACb,IAAM,kBAAkB,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAExF,SAAgB,8BAA8B,CAAC,OAAO;IAClD,IAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,IAAM,oBAAoB,GAAG,CAAC,CAAC;IACvB,IAAY,kBAAkB,GAAK,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,oBAAoB,EAAE,CAAC,CAAC,WAAxE,CAAyE;IAE/G,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,2BAAiB,CAAC;QAClD,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,2BAAiB,CAAC,KAAK,CAAC,eAAe;QAC7C,IAAI,EAAE,kBAAkB,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;QACjD,OAAO,EAAE,2BAAiB,CAAC,QAAQ,CAAC,cAAc;QAClD,aAAa,EAAE,2BAAiB,CAAC,eAAe,CAAC,MAAM;KAC1D,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO;SACZ,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;SAChC,uBAAuB,CACtB,eAAe,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,EAClC,oBAAoB,CACvB,CAAC;IAEF,OAAO,eAAe,CAAC;AAC3B,CAAC;AArBD,wEAqBC"}
|
|
@@ -52,7 +52,7 @@ function createTransactionInAccount(account) {
|
|
|
52
52
|
txid: new dashcore_lib_1.Transaction(undefined).hash,
|
|
53
53
|
}])
|
|
54
54
|
.to(account.getAddress(10).address, 100000);
|
|
55
|
-
return [4 /*yield*/, account.importTransactions([walletTransaction.serialize(true)])];
|
|
55
|
+
return [4 /*yield*/, account.importTransactions([[walletTransaction.serialize(true)]])];
|
|
56
56
|
case 1:
|
|
57
57
|
_a.sent();
|
|
58
58
|
return [2 /*return*/, walletTransaction];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransactionFixtureInAccount.js","sourceRoot":"","sources":["../../../../src/test/fixtures/createTransactionFixtureInAccount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAoD;AAEpD,SAAsB,0BAA0B,CAAC,OAAO;;;;;;oBAE9C,iBAAiB,GAAG,IAAI,0BAAW,CAAC,SAAS,CAAC;yBAC/C,IAAI,CAAC,CAAC;4BACH,MAAM,EAAE,MAAM;4BACd,MAAM,EAAE,oDAAoD;4BAC5D,WAAW,EAAE,CAAC;4BACd,IAAI,EAAE,IAAI,0BAAW,CAAC,SAAS,CAAC,CAAC,IAAI;yBACxC,CAAC,CAAC;yBACF,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAEhD,qBAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAA;;
|
|
1
|
+
{"version":3,"file":"createTransactionFixtureInAccount.js","sourceRoot":"","sources":["../../../../src/test/fixtures/createTransactionFixtureInAccount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAoD;AAEpD,SAAsB,0BAA0B,CAAC,OAAO;;;;;;oBAE9C,iBAAiB,GAAG,IAAI,0BAAW,CAAC,SAAS,CAAC;yBAC/C,IAAI,CAAC,CAAC;4BACH,MAAM,EAAE,MAAM;4BACd,MAAM,EAAE,oDAAoD;4BAC5D,WAAW,EAAE,CAAC;4BACd,IAAI,EAAE,IAAI,0BAAW,CAAC,SAAS,CAAC,CAAC,IAAI;yBACxC,CAAC,CAAC;yBACF,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAEhD,qBAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAA;;oBAAvE,SAAuE,CAAC;oBAExE,sBAAO,iBAAiB,EAAC;;;;CAC5B;AAdD,gEAcC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Identity from "@dashevo/dpp/lib/identity/Identity";
|
|
2
|
+
import { Platform } from "../../Platform";
|
|
3
|
+
import IdentityPublicKey from "@dashevo/dpp/lib/identity/IdentityPublicKey";
|
|
4
|
+
/**
|
|
5
|
+
* Update platform identities
|
|
6
|
+
*
|
|
7
|
+
* @param {Platform} this - bound instance class
|
|
8
|
+
* @param {Identity} identity - identity to update
|
|
9
|
+
* @param {{add: IdentityPublicKey[]; disable: IdentityPublicKey[]}} publicKeys - public keys to add
|
|
10
|
+
*
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export declare function update(this: Platform, identity: Identity, publicKeys: {
|
|
14
|
+
add?: IdentityPublicKey[];
|
|
15
|
+
disable?: IdentityPublicKey[];
|
|
16
|
+
}): Promise<any>;
|
|
17
|
+
export default update;
|
package/dist/src/SDK/SDK.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Client as _Client } from './Client';
|
|
3
3
|
import { Platform as _Platform } from './Platform';
|
|
4
|
-
import { Wallet as _Wallet, Account as _Account,
|
|
4
|
+
import { Wallet as _Wallet, Account as _Account, DerivableKeyChain as _KeyChain } from '@dashevo/wallet-lib';
|
|
5
5
|
export declare namespace SDK {
|
|
6
6
|
let DAPIClient: any;
|
|
7
7
|
let Client: typeof _Client;
|
|
@@ -45,6 +45,7 @@ export declare namespace SDK {
|
|
|
45
45
|
PRIVATEKEY: string;
|
|
46
46
|
SINGLE_ADDRESS: string;
|
|
47
47
|
HDWALLET: string;
|
|
48
|
+
HDPRIVATE: string;
|
|
48
49
|
HDPUBLIC: string;
|
|
49
50
|
};
|
|
50
51
|
INJECTION_LISTS: {
|
|
@@ -109,6 +110,11 @@ export declare namespace SDK {
|
|
|
109
110
|
calculateTransactionFees: typeof import("@dashevo/wallet-libsrc/utils/calculateTransactionFees");
|
|
110
111
|
categorizeTransactions: typeof import("@dashevo/wallet-libsrc/utils/categorizeTransactions");
|
|
111
112
|
mnemonicToHDPrivateKey: (mnemonic: any, network?: any, passphrase?: string) => any;
|
|
113
|
+
calculateDuffBalance: (addresses: any, chainStore: any, type?: {
|
|
114
|
+
confirmed: any;
|
|
115
|
+
unconfirmed: any;
|
|
116
|
+
total: any;
|
|
117
|
+
}) => number;
|
|
112
118
|
generateNewMnemonic: () => any;
|
|
113
119
|
seedToHDPrivateKey: (seed: any, network?: string) => any;
|
|
114
120
|
mnemonicToWalletId: (mnemonic: any) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dash",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0-dev.1",
|
|
4
4
|
"description": "Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"unpkg": "dist/dash.min.js",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/dashevo/DashJS#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@dashevo/dapi-client": "~0.
|
|
37
|
+
"@dashevo/dapi-client": "~0.23.0-dev.1",
|
|
38
38
|
"@dashevo/dashcore-lib": "~0.19.30",
|
|
39
|
-
"@dashevo/dashpay-contract": "~0.
|
|
40
|
-
"@dashevo/dpns-contract": "~0.
|
|
41
|
-
"@dashevo/dpp": "~0.
|
|
42
|
-
"@dashevo/grpc-common": "~0.
|
|
43
|
-
"@dashevo/masternode-reward-shares-contract": "~0.
|
|
44
|
-
"@dashevo/wallet-lib": "~7.
|
|
39
|
+
"@dashevo/dashpay-contract": "~0.23.0-dev.1",
|
|
40
|
+
"@dashevo/dpns-contract": "~0.23.0-dev.1",
|
|
41
|
+
"@dashevo/dpp": "~0.23.0-dev.1",
|
|
42
|
+
"@dashevo/grpc-common": "~0.23.0-dev.1",
|
|
43
|
+
"@dashevo/masternode-reward-shares-contract": "~0.23.0-dev.1",
|
|
44
|
+
"@dashevo/wallet-lib": "~7.23.0-dev.1",
|
|
45
45
|
"bs58": "^4.0.1",
|
|
46
46
|
"node-inspect-extracted": "^1.0.8"
|
|
47
47
|
},
|
|
@@ -37,7 +37,7 @@ describe('Dash - Client', function suite() {
|
|
|
37
37
|
|
|
38
38
|
beforeEach(async function beforeEach() {
|
|
39
39
|
testMnemonic = 'agree country attract master mimic ball load beauty join gentle turtle hover';
|
|
40
|
-
testHDKey = "
|
|
40
|
+
testHDKey = "tprv8ZgxMBicQKsPeGi4CikhacVPz6UmErenu1PoD3S4XcEDSPP8auRaS8hG3DQtsQ2i9HACgohHwF5sgMVJNksoKqYoZbis8o75Pp1koCme2Yo";
|
|
41
41
|
|
|
42
42
|
client = new Client({
|
|
43
43
|
wallet: {
|
|
@@ -145,7 +145,7 @@ describe('Dash - Client', function suite() {
|
|
|
145
145
|
const importedIdentityIds = account.identities.getIdentityIds();
|
|
146
146
|
// Check that we've imported identities properly
|
|
147
147
|
expect(importedIdentityIds.length).to.be.equal(accountIdentitiesCountBeforeTest + 1);
|
|
148
|
-
expect(importedIdentityIds[
|
|
148
|
+
expect(importedIdentityIds[1]).to.be.equal(interceptedIdentityStateTransition.getIdentityId().toString());
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
it('should throw TransitionBroadcastError when transport resolves error', async () => {
|
|
@@ -16,6 +16,7 @@ import getContract from "./methods/contracts/get";
|
|
|
16
16
|
import getIdentity from "./methods/identities/get";
|
|
17
17
|
import registerIdentity from "./methods/identities/register";
|
|
18
18
|
import topUpIdentity from "./methods/identities/topUp";
|
|
19
|
+
import updateIdentity from "./methods/identities/update";
|
|
19
20
|
|
|
20
21
|
import registerName from "./methods/names/register";
|
|
21
22
|
import resolveName from "./methods/names/resolve";
|
|
@@ -65,6 +66,7 @@ interface Identities {
|
|
|
65
66
|
get: Function,
|
|
66
67
|
register: Function,
|
|
67
68
|
topUp: Function,
|
|
69
|
+
update: Function,
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
interface DataContracts {
|
|
@@ -144,6 +146,7 @@ export class Platform {
|
|
|
144
146
|
register: registerIdentity.bind(this),
|
|
145
147
|
get: getIdentity.bind(this),
|
|
146
148
|
topUp: topUpIdentity.bind(this),
|
|
149
|
+
update: updateIdentity.bind(this),
|
|
147
150
|
};
|
|
148
151
|
|
|
149
152
|
this.client = options.client;
|
|
@@ -36,10 +36,11 @@ export default async function register(
|
|
|
36
36
|
await broadcastStateTransition(this, identityCreateTransition);
|
|
37
37
|
|
|
38
38
|
// If state transition was broadcast without any errors, import identity to the account
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
account.storage
|
|
40
|
+
.getWalletStore(account.walletId)
|
|
41
|
+
.insertIdentityIdAtIndex(
|
|
42
|
+
identity.getId().toString(),
|
|
43
|
+
identityIndex,
|
|
43
44
|
);
|
|
44
45
|
|
|
45
46
|
return identity;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Identity from "@dashevo/dpp/lib/identity/Identity";
|
|
2
|
+
import { Platform } from "../../Platform";
|
|
3
|
+
import IdentityPublicKey from "@dashevo/dpp/lib/identity/IdentityPublicKey"
|
|
4
|
+
import { signStateTransition } from '../../signStateTransition';
|
|
5
|
+
|
|
6
|
+
import broadcastStateTransition from "../../broadcastStateTransition";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Update platform identities
|
|
10
|
+
*
|
|
11
|
+
* @param {Platform} this - bound instance class
|
|
12
|
+
* @param {Identity} identity - identity to update
|
|
13
|
+
* @param {{add: IdentityPublicKey[]; disable: IdentityPublicKey[]}} publicKeys - public keys to add
|
|
14
|
+
*
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
export async function update(
|
|
18
|
+
this: Platform,
|
|
19
|
+
identity: Identity,
|
|
20
|
+
publicKeys: { add?: IdentityPublicKey[]; disable?: IdentityPublicKey[] },
|
|
21
|
+
): Promise<any> {
|
|
22
|
+
await this.initialize();
|
|
23
|
+
|
|
24
|
+
const { dpp } = this;
|
|
25
|
+
|
|
26
|
+
const identityUpdateTransition = dpp.identity.createIdentityUpdateTransition(
|
|
27
|
+
identity,
|
|
28
|
+
publicKeys,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
await signStateTransition(this, identityUpdateTransition, identity);
|
|
32
|
+
|
|
33
|
+
const result = await dpp.stateTransition.validateBasic(identityUpdateTransition);
|
|
34
|
+
|
|
35
|
+
if (!result.isValid()) {
|
|
36
|
+
throw new Error(`StateTransition is invalid - ${JSON.stringify(result.getErrors())}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Broadcast ST
|
|
40
|
+
await broadcastStateTransition(this, identityUpdateTransition);
|
|
41
|
+
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default update;
|
package/src/SDK/SDK.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { default as _DAPIClient } from '@dashevo/dapi-client';
|
|
|
6
6
|
import {
|
|
7
7
|
Wallet as _Wallet,
|
|
8
8
|
Account as _Account,
|
|
9
|
-
|
|
9
|
+
DerivableKeyChain as _KeyChain,
|
|
10
10
|
CONSTANTS as _WalletLibCONSTANTS,
|
|
11
11
|
EVENTS as _WalletLibEVENTS,
|
|
12
12
|
utils as _WalletLibUtils,
|
|
@@ -4,7 +4,7 @@ const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFi
|
|
|
4
4
|
|
|
5
5
|
export function createIdentityFixtureInAccount(account) {
|
|
6
6
|
const identityFixture = getIdentityFixture();
|
|
7
|
-
const identityFixtureIndex =
|
|
7
|
+
const identityFixtureIndex = 0;
|
|
8
8
|
const { privateKey: identityPrivateKey } = account.identities.getIdentityHDKeyByIndex(identityFixtureIndex, 0);
|
|
9
9
|
|
|
10
10
|
identityFixture.publicKeys[0] = new IdentityPublicKey({
|
|
@@ -15,8 +15,9 @@ export function createIdentityFixtureInAccount(account) {
|
|
|
15
15
|
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
account.storage
|
|
19
|
-
|
|
18
|
+
account.storage
|
|
19
|
+
.getWalletStore(account.walletId)
|
|
20
|
+
.insertIdentityIdAtIndex(
|
|
20
21
|
identityFixture.getId().toString(),
|
|
21
22
|
identityFixtureIndex,
|
|
22
23
|
);
|
|
@@ -11,7 +11,7 @@ export async function createTransactionInAccount(account) {
|
|
|
11
11
|
}])
|
|
12
12
|
.to(account.getAddress(10).address, 100000);
|
|
13
13
|
|
|
14
|
-
await account.importTransactions([walletTransaction.serialize(true)]);
|
|
14
|
+
await account.importTransactions([[walletTransaction.serialize(true)]]);
|
|
15
15
|
|
|
16
16
|
return walletTransaction;
|
|
17
|
-
}
|
|
17
|
+
}
|