dash 3.22.0-dev.9 → 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/internal/createAssetLockProof.js +76 -11
- package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js +103 -0
- package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js.map +1 -0
- 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/internal/waitForCoreChainLockedHeight.d.ts +5 -0
- package/dist/src/SDK/Client/Platform/methods/identities/update.d.ts +17 -0
- package/dist/src/SDK/SDK.d.ts +8 -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/internal/createAssetLockProof.ts +100 -2
- package/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts +69 -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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"}
|
|
@@ -35,7 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var waitForCoreChainLockedHeight_1 = __importDefault(require("./waitForCoreChainLockedHeight"));
|
|
43
|
+
var _a = require('@dashevo/wallet-lib/src/errors'), InstantLockTimeoutError = _a.InstantLockTimeoutError, TxMetadataTimeoutError = _a.TxMetadataTimeoutError;
|
|
39
44
|
/**
|
|
40
45
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
41
46
|
* @param {Platform} platform
|
|
@@ -46,22 +51,82 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
51
|
*/
|
|
47
52
|
function createAssetLockProof(platform, assetLockTransaction, outputIndex) {
|
|
48
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
-
var account, dpp,
|
|
50
|
-
return __generator(this, function (
|
|
51
|
-
switch (
|
|
54
|
+
var account, dpp, _a, instantLockPromise, cancelInstantLock, _b, txMetadataPromise, cancelTxMetadata, cancelObtainCoreChainLockedHeight, rejectTimer, rejectionTimeout;
|
|
55
|
+
return __generator(this, function (_c) {
|
|
56
|
+
switch (_c.label) {
|
|
52
57
|
case 0: return [4 /*yield*/, platform.initialize()];
|
|
53
58
|
case 1:
|
|
54
|
-
|
|
59
|
+
_c.sent();
|
|
55
60
|
return [4 /*yield*/, platform.client.getWalletAccount()];
|
|
56
61
|
case 2:
|
|
57
|
-
account =
|
|
62
|
+
account = _c.sent();
|
|
58
63
|
dpp = platform.dpp;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
_a = account.waitForInstantLock(assetLockTransaction.hash), instantLockPromise = _a.promise, cancelInstantLock = _a.cancel;
|
|
65
|
+
_b = account.waitForTxMetadata(assetLockTransaction.hash), txMetadataPromise = _b.promise, cancelTxMetadata = _b.cancel;
|
|
66
|
+
rejectionTimeout = account.waitForTxMetadataTimeout > account.waitForInstantLockTimeout
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
? account.waitForTxMetadataTimeout + 360000 // wait for platform to sync core chain locked height
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
: account.waitForInstantLockTimeout;
|
|
71
|
+
return [2 /*return*/, Promise.race([
|
|
72
|
+
// Wait for Instant Lock
|
|
73
|
+
instantLockPromise
|
|
74
|
+
.then(function (instantLock) {
|
|
75
|
+
clearTimeout(rejectTimer);
|
|
76
|
+
cancelTxMetadata();
|
|
77
|
+
if (cancelObtainCoreChainLockedHeight) {
|
|
78
|
+
cancelObtainCoreChainLockedHeight();
|
|
79
|
+
}
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
return dpp.identity.createInstantAssetLockProof(instantLock, assetLockTransaction, outputIndex);
|
|
82
|
+
})
|
|
83
|
+
.catch(function (error) {
|
|
84
|
+
if (error instanceof InstantLockTimeoutError) {
|
|
85
|
+
// Instant Lock is timed out.
|
|
86
|
+
// Allow chain proof to win the race
|
|
87
|
+
return new Promise(function () { });
|
|
88
|
+
}
|
|
89
|
+
return Promise.reject(error);
|
|
90
|
+
}),
|
|
91
|
+
// Wait for transaction is mined and platform chain synced core height to the transaction height
|
|
92
|
+
txMetadataPromise
|
|
93
|
+
.then(function (assetLockMetadata) {
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
return waitForCoreChainLockedHeight_1.default(platform, assetLockMetadata.height)
|
|
96
|
+
.then(function (_a) {
|
|
97
|
+
var promise = _a.promise, cancel = _a.cancel;
|
|
98
|
+
cancelObtainCoreChainLockedHeight = cancel;
|
|
99
|
+
return promise;
|
|
100
|
+
})
|
|
101
|
+
.then(function () {
|
|
102
|
+
clearTimeout(rejectTimer);
|
|
103
|
+
cancelInstantLock();
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
return dpp.identity.createChainAssetLockProof(
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
assetLockMetadata.height, assetLockTransaction.getOutPointBuffer(outputIndex));
|
|
108
|
+
});
|
|
109
|
+
})
|
|
110
|
+
.catch(function (error) {
|
|
111
|
+
if (error instanceof TxMetadataTimeoutError) {
|
|
112
|
+
// Instant Lock is timed out.
|
|
113
|
+
// Allow instant proof to win the race
|
|
114
|
+
return new Promise(function () { });
|
|
115
|
+
}
|
|
116
|
+
return Promise.reject(error);
|
|
117
|
+
}),
|
|
118
|
+
// Common timeout for getting proofs
|
|
119
|
+
new Promise(function (_, reject) {
|
|
120
|
+
rejectTimer = setTimeout(function () {
|
|
121
|
+
cancelTxMetadata();
|
|
122
|
+
if (cancelObtainCoreChainLockedHeight) {
|
|
123
|
+
cancelObtainCoreChainLockedHeight();
|
|
124
|
+
}
|
|
125
|
+
cancelInstantLock();
|
|
126
|
+
reject(new Error('Asset Lock Proof creation timeout'));
|
|
127
|
+
}, rejectionTimeout);
|
|
128
|
+
})
|
|
129
|
+
])];
|
|
65
130
|
}
|
|
66
131
|
});
|
|
67
132
|
});
|
package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAssetLockProof.js","sourceRoot":"","sources":["../../../../../../../../src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createAssetLockProof.js","sourceRoot":"","sources":["../../../../../../../../src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts"],"names":[],"mappings":"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"}
|
package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var systemIds_1 = require("@dashevo/dpns-contract/lib/systemIds");
|
|
40
|
+
function waitForCoreChainLockedHeight(platform, expectedCoreHeight) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
function cancel() {
|
|
43
|
+
if (timeout) {
|
|
44
|
+
clearTimeout(timeout);
|
|
45
|
+
}
|
|
46
|
+
isCanceled = true;
|
|
47
|
+
}
|
|
48
|
+
var interval, isCanceled, timeout, coreChainLockedHeight, promise;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, platform.initialize()];
|
|
52
|
+
case 1:
|
|
53
|
+
_a.sent();
|
|
54
|
+
interval = 5000;
|
|
55
|
+
isCanceled = false;
|
|
56
|
+
coreChainLockedHeight = 0;
|
|
57
|
+
promise = new Promise(function (resolve, reject) {
|
|
58
|
+
function obtainCoreChainLockedHeight() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var identityResponse, metadata, e_1;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
_a.trys.push([0, 2, , 3]);
|
|
65
|
+
return [4 /*yield*/, platform.identities.get(systemIds_1.ownerId)];
|
|
66
|
+
case 1:
|
|
67
|
+
identityResponse = _a.sent();
|
|
68
|
+
if (!identityResponse) {
|
|
69
|
+
reject(new Error('Identity using to obtain core chain locked height is not present'));
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
}
|
|
72
|
+
metadata = identityResponse.getMetadata();
|
|
73
|
+
coreChainLockedHeight = metadata.getCoreChainLockedHeight();
|
|
74
|
+
return [3 /*break*/, 3];
|
|
75
|
+
case 2:
|
|
76
|
+
e_1 = _a.sent();
|
|
77
|
+
reject(e_1);
|
|
78
|
+
return [2 /*return*/];
|
|
79
|
+
case 3:
|
|
80
|
+
if (coreChainLockedHeight >= expectedCoreHeight) {
|
|
81
|
+
resolve();
|
|
82
|
+
return [2 /*return*/];
|
|
83
|
+
}
|
|
84
|
+
if (!isCanceled) {
|
|
85
|
+
timeout = setTimeout(obtainCoreChainLockedHeight, interval);
|
|
86
|
+
}
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
obtainCoreChainLockedHeight();
|
|
93
|
+
});
|
|
94
|
+
return [2 /*return*/, {
|
|
95
|
+
promise: promise,
|
|
96
|
+
cancel: cancel,
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
exports.default = waitForCoreChainLockedHeight;
|
|
103
|
+
//# sourceMappingURL=waitForCoreChainLockedHeight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitForCoreChainLockedHeight.js","sourceRoot":"","sources":["../../../../../../../../src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kEAA8E;AAE9E,SAA8B,4BAA4B,CACxD,QAAmB,EACnB,kBAA2B;;QA8C3B,SAAS,MAAM;YACb,IAAI,OAAO,EAAE;gBACX,YAAY,CAAC,OAAO,CAAC,CAAC;aACvB;YAED,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC;;;;wBAlDD,qBAAM,QAAQ,CAAC,UAAU,EAAE,EAAA;;oBAA3B,SAA2B,CAAC;oBAEtB,QAAQ,GAAG,IAAI,CAAC;oBAElB,UAAU,GAAG,KAAK,CAAC;oBAInB,qBAAqB,GAAG,CAAC,CAAC;oBAExB,OAAO,GAAG,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBAC1C,SAAe,2BAA2B;;;;;;;4CAEb,qBAAM,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,mBAAW,CAAC,EAAA;;4CAA7D,gBAAgB,GAAG,SAA0C;4CAEnE,IAAI,CAAC,gBAAgB,EAAE;gDACpB,MAAM,CAAC,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC,CAAC;gDAEtF,sBAAO;6CACT;4CAEK,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC;4CAEhD,qBAAqB,GAAG,QAAQ,CAAC,wBAAwB,EAAE,CAAC;;;;4CAE5D,MAAM,CAAC,GAAC,CAAC,CAAC;4CAEV,sBAAO;;4CAGT,IAAI,qBAAqB,IAAI,kBAAkB,EAAE;gDAC/C,OAAO,EAAE,CAAC;gDAEV,sBAAO;6CACR;4CAED,IAAI,CAAC,UAAU,EAAE;gDACf,OAAO,GAAG,UAAU,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC;6CAC7D;;;;;yBACF;wBAED,2BAA2B,EAAE,CAAC;oBAChC,CAAC,CAAC,CAAC;oBAUH,sBAAO;4BACL,OAAO,SAAA;4BACP,MAAM,QAAA;yBACP,EAAA;;;;CACF;AA5DD,+CA4DC"}
|
|
@@ -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: {
|
|
@@ -97,6 +98,7 @@ export declare namespace SDK {
|
|
|
97
98
|
REHYDRATE_STATE_FAILED: string;
|
|
98
99
|
REHYDRATE_STATE_SUCCESS: string;
|
|
99
100
|
INSTANT_LOCK: string;
|
|
101
|
+
TX_METADATA: string;
|
|
100
102
|
};
|
|
101
103
|
plugins: {
|
|
102
104
|
StandardPlugin: typeof import("@dashevo/wallet-libsrc/plugins/StandardPlugin");
|
|
@@ -108,6 +110,11 @@ export declare namespace SDK {
|
|
|
108
110
|
calculateTransactionFees: typeof import("@dashevo/wallet-libsrc/utils/calculateTransactionFees");
|
|
109
111
|
categorizeTransactions: typeof import("@dashevo/wallet-libsrc/utils/categorizeTransactions");
|
|
110
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;
|
|
111
118
|
generateNewMnemonic: () => any;
|
|
112
119
|
seedToHDPrivateKey: (seed: any, network?: string) => any;
|
|
113
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;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Transaction } from "@dashevo/dashcore-lib";
|
|
2
2
|
import { Platform } from "../../../Platform";
|
|
3
3
|
|
|
4
|
+
import waitForCoreChainLockedHeight from "./waitForCoreChainLockedHeight";
|
|
5
|
+
|
|
6
|
+
const { InstantLockTimeoutError, TxMetadataTimeoutError } = require('@dashevo/wallet-lib/src/errors');
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
6
10
|
* @param {Platform} platform
|
|
@@ -15,9 +19,103 @@ export default async function createAssetLockProof(platform : Platform, assetLoc
|
|
|
15
19
|
const account = await platform.client.getWalletAccount();
|
|
16
20
|
const { dpp } = platform;
|
|
17
21
|
|
|
18
|
-
let instantLock = await account.waitForInstantLock(assetLockTransaction.hash);
|
|
19
22
|
// Create poof that the transaction won't be double spend
|
|
20
23
|
|
|
24
|
+
const {
|
|
25
|
+
promise: instantLockPromise,
|
|
26
|
+
cancel: cancelInstantLock
|
|
27
|
+
} = account.waitForInstantLock(assetLockTransaction.hash);
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
promise: txMetadataPromise,
|
|
31
|
+
cancel: cancelTxMetadata,
|
|
32
|
+
} = account.waitForTxMetadata(assetLockTransaction.hash);
|
|
33
|
+
|
|
34
|
+
let cancelObtainCoreChainLockedHeight;
|
|
35
|
+
|
|
36
|
+
let rejectTimer;
|
|
37
|
+
|
|
21
38
|
// @ts-ignore
|
|
22
|
-
|
|
39
|
+
const rejectionTimeout = account.waitForTxMetadataTimeout > account.waitForInstantLockTimeout
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
? account.waitForTxMetadataTimeout + 360000 // wait for platform to sync core chain locked height
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
: account.waitForInstantLockTimeout;
|
|
44
|
+
|
|
45
|
+
return Promise.race([
|
|
46
|
+
// Wait for Instant Lock
|
|
47
|
+
instantLockPromise
|
|
48
|
+
.then((instantLock) => {
|
|
49
|
+
clearTimeout(rejectTimer);
|
|
50
|
+
|
|
51
|
+
cancelTxMetadata();
|
|
52
|
+
|
|
53
|
+
if (cancelObtainCoreChainLockedHeight) {
|
|
54
|
+
cancelObtainCoreChainLockedHeight();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
return dpp.identity.createInstantAssetLockProof(
|
|
59
|
+
instantLock,
|
|
60
|
+
assetLockTransaction,
|
|
61
|
+
outputIndex,
|
|
62
|
+
);
|
|
63
|
+
})
|
|
64
|
+
.catch((error) => {
|
|
65
|
+
if (error instanceof InstantLockTimeoutError) {
|
|
66
|
+
// Instant Lock is timed out.
|
|
67
|
+
// Allow chain proof to win the race
|
|
68
|
+
return new Promise(() => {});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return Promise.reject(error);
|
|
72
|
+
}),
|
|
73
|
+
|
|
74
|
+
// Wait for transaction is mined and platform chain synced core height to the transaction height
|
|
75
|
+
txMetadataPromise
|
|
76
|
+
.then((assetLockMetadata) => {
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
return waitForCoreChainLockedHeight(platform, assetLockMetadata.height)
|
|
79
|
+
.then(({ promise, cancel }) => {
|
|
80
|
+
cancelObtainCoreChainLockedHeight = cancel;
|
|
81
|
+
|
|
82
|
+
return promise;
|
|
83
|
+
})
|
|
84
|
+
.then(() => {
|
|
85
|
+
clearTimeout(rejectTimer);
|
|
86
|
+
cancelInstantLock();
|
|
87
|
+
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
return dpp.identity.createChainAssetLockProof(
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
assetLockMetadata.height,
|
|
92
|
+
assetLockTransaction.getOutPointBuffer(outputIndex),
|
|
93
|
+
);
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
if (error instanceof TxMetadataTimeoutError) {
|
|
98
|
+
// Instant Lock is timed out.
|
|
99
|
+
// Allow instant proof to win the race
|
|
100
|
+
return new Promise(() => {});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return Promise.reject(error);
|
|
104
|
+
}),
|
|
105
|
+
|
|
106
|
+
// Common timeout for getting proofs
|
|
107
|
+
new Promise((_, reject) => {
|
|
108
|
+
rejectTimer = setTimeout(() => {
|
|
109
|
+
cancelTxMetadata();
|
|
110
|
+
|
|
111
|
+
if (cancelObtainCoreChainLockedHeight) {
|
|
112
|
+
cancelObtainCoreChainLockedHeight();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
cancelInstantLock();
|
|
116
|
+
|
|
117
|
+
reject(new Error('Asset Lock Proof creation timeout'));
|
|
118
|
+
}, rejectionTimeout)
|
|
119
|
+
})
|
|
120
|
+
]);
|
|
23
121
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Platform } from "../../../Platform";
|
|
2
|
+
|
|
3
|
+
import { ownerId as dpnsOwnerId } from "@dashevo/dpns-contract/lib/systemIds";
|
|
4
|
+
|
|
5
|
+
export default async function waitForCoreChainLockedHeight(
|
|
6
|
+
platform : Platform,
|
|
7
|
+
expectedCoreHeight : number,
|
|
8
|
+
): Promise<{ promise: Promise<any>, cancel: Function }> {
|
|
9
|
+
await platform.initialize();
|
|
10
|
+
|
|
11
|
+
const interval = 5000;
|
|
12
|
+
|
|
13
|
+
let isCanceled = false;
|
|
14
|
+
|
|
15
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
16
|
+
|
|
17
|
+
let coreChainLockedHeight = 0;
|
|
18
|
+
|
|
19
|
+
const promise = new Promise((resolve, reject) => {
|
|
20
|
+
async function obtainCoreChainLockedHeight() {
|
|
21
|
+
try {
|
|
22
|
+
const identityResponse = await platform.identities.get(dpnsOwnerId);
|
|
23
|
+
|
|
24
|
+
if (!identityResponse) {
|
|
25
|
+
reject(new Error('Identity using to obtain core chain locked height is not present'));
|
|
26
|
+
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const metadata = identityResponse.getMetadata();
|
|
31
|
+
|
|
32
|
+
coreChainLockedHeight = metadata.getCoreChainLockedHeight();
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (coreChainLockedHeight >= expectedCoreHeight) {
|
|
40
|
+
resolve();
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!isCanceled) {
|
|
46
|
+
timeout = setTimeout(obtainCoreChainLockedHeight, interval);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
obtainCoreChainLockedHeight();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function cancel() {
|
|
54
|
+
if (timeout) {
|
|
55
|
+
clearTimeout(timeout);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isCanceled = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
promise,
|
|
63
|
+
cancel,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
@@ -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
|
+
}
|