dash-platform-sdk 1.3.0-dev.1 → 1.3.0-dev.11
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/bundle.min.js +21 -2
- package/index.d.ts +1 -1
- package/index.js +2 -5
- package/package.json +32 -31
- package/proto/generated/google/protobuf/wrappers.d.ts +260 -29
- package/proto/generated/google/protobuf/wrappers.js +562 -345
- package/proto/generated/platform.client.d.ts +261 -0
- package/proto/generated/platform.client.js +182 -0
- package/proto/generated/platform.d.ts +3795 -1938
- package/proto/generated/platform.js +8338 -18362
- package/src/DashPlatformSDK.d.ts +18 -19
- package/src/DashPlatformSDK.js +52 -45
- package/src/constants.d.ts +2 -0
- package/src/constants.js +7 -8
- package/src/contestedResources/createStateTransition.d.ts +2 -0
- package/src/contestedResources/createStateTransition.js +6 -0
- package/src/contestedResources/getContestedResourceVoteState.d.ts +3 -3
- package/src/contestedResources/getContestedResourceVoteState.js +67 -118
- package/src/contestedResources/index.d.ts +3 -3
- package/src/contestedResources/index.js +9 -55
- package/src/dataContracts/create.d.ts +1 -1
- package/src/dataContracts/create.js +5 -8
- package/src/dataContracts/createStateTransition.js +10 -14
- package/src/dataContracts/getDataContractByIdentifier.d.ts +2 -2
- package/src/dataContracts/getDataContractByIdentifier.js +40 -79
- package/src/dataContracts/index.d.ts +2 -2
- package/src/dataContracts/index.js +17 -63
- package/src/documents/create.d.ts +1 -1
- package/src/documents/create.js +3 -6
- package/src/documents/createStateTransition.d.ts +1 -1
- package/src/documents/createStateTransition.js +19 -31
- package/src/documents/index.d.ts +2 -2
- package/src/documents/index.js +25 -72
- package/src/documents/query.d.ts +2 -2
- package/src/documents/query.js +58 -90
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/grpcConnectionPool.js +63 -121
- package/src/identities/createStateTransition.d.ts +2 -2
- package/src/identities/createStateTransition.js +24 -26
- package/src/identities/getIdentityBalance.d.ts +2 -2
- package/src/identities/getIdentityBalance.js +37 -80
- package/src/identities/getIdentityByIdentifier.d.ts +2 -2
- package/src/identities/getIdentityByIdentifier.js +37 -80
- package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +1 -1
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +41 -82
- package/src/identities/getIdentityByPublicKeyHash.d.ts +1 -1
- package/src/identities/getIdentityByPublicKeyHash.js +37 -80
- package/src/identities/getIdentityContractNonce.d.ts +2 -2
- package/src/identities/getIdentityContractNonce.js +40 -83
- package/src/identities/getIdentityNonce.d.ts +2 -2
- package/src/identities/getIdentityNonce.js +38 -81
- package/src/identities/getIdentityPublicKeys.d.ts +3 -3
- package/src/identities/getIdentityPublicKeys.js +51 -80
- package/src/identities/index.d.ts +9 -6
- package/src/identities/index.js +72 -155
- package/src/keyPair/deriveChild.d.ts +2 -2
- package/src/keyPair/deriveChild.js +2 -49
- package/src/keyPair/derivePath.d.ts +2 -2
- package/src/keyPair/derivePath.js +2 -49
- package/src/keyPair/index.d.ts +39 -114
- package/src/keyPair/index.js +62 -296
- package/src/keyPair/mnemonicToSeed.d.ts +1 -1
- package/src/keyPair/mnemonicToSeed.js +3 -46
- package/src/names/index.d.ts +44 -3
- package/src/names/index.js +81 -69
- package/src/names/registerName.d.ts +3 -0
- package/src/names/registerName.js +64 -0
- package/src/names/searchByIdentity.d.ts +3 -0
- package/src/names/searchByIdentity.js +5 -0
- package/src/names/searchByName.d.ts +3 -0
- package/src/names/searchByName.js +16 -0
- package/src/names/testNameContested.d.ts +1 -0
- package/src/names/testNameContested.js +3 -0
- package/src/names/validateName.d.ts +1 -0
- package/src/names/validateName.js +11 -0
- package/src/node/epochs.d.ts +1 -1
- package/src/node/epochs.js +43 -85
- package/src/node/index.d.ts +5 -5
- package/src/node/index.js +18 -77
- package/src/node/status.d.ts +2 -2
- package/src/node/status.js +37 -81
- package/src/node/totalCredits.d.ts +3 -2
- package/src/node/totalCredits.js +32 -73
- package/src/stateTransitions/broadcast.d.ts +1 -1
- package/src/stateTransitions/broadcast.js +7 -57
- package/src/stateTransitions/index.d.ts +1 -1
- package/src/stateTransitions/index.js +13 -66
- package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
- package/src/stateTransitions/waitForStateTransitionResult.js +48 -61
- package/src/tokens/createStateTransition.d.ts +1 -1
- package/src/tokens/createStateTransition.js +23 -35
- package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
- package/src/tokens/getIdentitiesTokenBalances.js +40 -83
- package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
- package/src/tokens/getIdentityTokensBalances.js +40 -83
- package/src/tokens/getTokenContractInfo.d.ts +2 -2
- package/src/tokens/getTokenContractInfo.js +40 -83
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +3 -0
- package/src/tokens/getTokenDirectPurchasePrices.js +40 -0
- package/src/tokens/getTokenTotalSupply.d.ts +2 -2
- package/src/tokens/getTokenTotalSupply.js +38 -81
- package/src/tokens/index.d.ts +13 -5
- package/src/tokens/index.js +46 -113
- package/src/types.d.ts +20 -16
- package/src/types.js +6 -16
- package/src/utils/base58ToBytes.js +3 -6
- package/src/utils/bytesToHex.js +2 -5
- package/src/utils/bytesToTypedArray.d.ts +1 -0
- package/src/utils/bytesToTypedArray.js +3 -0
- package/src/utils/calculateMsgHash.d.ts +1 -1
- package/src/utils/calculateMsgHash.js +10 -13
- package/src/utils/calculateSignHash.d.ts +2 -2
- package/src/utils/calculateSignHash.js +7 -10
- package/src/utils/calculateStateIdHash.d.ts +2 -2
- package/src/utils/calculateStateIdHash.js +8 -10
- package/src/utils/convertToHomographSafeChars.d.ts +0 -4
- package/src/utils/convertToHomographSafeChars.js +2 -9
- package/src/utils/createMasternodeIdentityId.d.ts +2 -0
- package/src/utils/createMasternodeIdentityId.js +4 -0
- package/src/utils/createVoterIdentityId.d.ts +2 -0
- package/src/utils/createVoterIdentityId.js +13 -0
- package/src/utils/getEvonodeList.d.ts +2 -2
- package/src/utils/getEvonodeList.js +10 -61
- package/src/utils/getQuorumPublicKey.js +15 -66
- package/src/utils/getRandomArrayItem.js +1 -4
- package/src/utils/getRandomBytes.d.ts +1 -0
- package/src/utils/getRandomBytes.js +4 -0
- package/src/utils/hexToBytes.js +2 -6
- package/src/utils/index.d.ts +19 -3
- package/src/utils/index.js +45 -31
- package/src/utils/indexBytesToString.js +2 -5
- package/src/utils/sha256.d.ts +1 -1
- package/src/utils/sha256.js +10 -8
- package/src/utils/signHash.d.ts +1 -1
- package/src/utils/signHash.js +9 -12
- package/src/utils/signRequestId.d.ts +1 -1
- package/src/utils/signRequestId.js +9 -12
- package/src/utils/sleep.d.ts +1 -0
- package/src/utils/sleep.js +3 -0
- package/src/utils/stringToIndexValueBytes.js +4 -7
- package/src/utils/verifyTenderdashProof.d.ts +2 -2
- package/src/utils/verifyTenderdashProof.js +13 -17
- package/src/voting/createStateTransition.d.ts +2 -0
- package/src/voting/createStateTransition.js +6 -0
- package/src/voting/createVote.d.ts +2 -0
- package/src/voting/createVote.js +5 -0
- package/src/voting/index.d.ts +37 -0
- package/src/voting/index.js +55 -0
- package/test/unit/ContestedResources.spec.js +91 -90
- package/test/unit/DataContract.spec.js +44 -111
- package/test/unit/Document.spec.js +93 -183
- package/test/unit/Identity.spec.js +254 -357
- package/test/unit/KeyPair.spec.js +30 -145
- package/test/unit/Names.spec.d.ts +1 -0
- package/test/unit/Names.spec.js +35 -0
- package/test/unit/Node.spec.js +55 -126
- package/test/unit/SDK.spec.js +7 -9
- package/test/unit/Tokens.spec.js +112 -262
- package/bundle.min.js.LICENSE.txt +0 -1
- package/src/keyPair/keyToPublicKey.d.ts +0 -2
- package/src/keyPair/keyToPublicKey.js +0 -47
- package/src/keyPair/keyToWalletId.d.ts +0 -2
- package/src/keyPair/keyToWalletId.js +0 -50
- package/src/keyPair/keyToXPrivateKey.d.ts +0 -3
- package/src/keyPair/keyToXPrivateKey.js +0 -50
- package/src/keyPair/keyToXPublicKey.d.ts +0 -3
- package/src/keyPair/keyToXPublicKey.js +0 -50
- package/src/keyPair/mnemonicToIdentityKey.d.ts +0 -3
- package/src/keyPair/mnemonicToIdentityKey.js +0 -57
- package/src/keyPair/mnemonicToWallet.d.ts +0 -2
- package/src/keyPair/mnemonicToWallet.js +0 -55
- package/src/keyPair/privateKeyToWif.d.ts +0 -2
- package/src/keyPair/privateKeyToWif.js +0 -50
- package/src/keyPair/publicKeyToAddress.d.ts +0 -2
- package/src/keyPair/publicKeyToAddress.js +0 -50
- package/src/keyPair/seedToWallet.d.ts +0 -2
- package/src/keyPair/seedToWallet.js +0 -50
- package/src/keyPair/walletToIdentityKey.d.ts +0 -3
- package/src/keyPair/walletToIdentityKey.js +0 -56
- package/src/keyPair/xkeyToHDXKey.d.ts +0 -2
- package/src/keyPair/xkeyToHDXKey.js +0 -50
- package/src/names/search.d.ts +0 -3
- package/src/names/search.js +0 -63
- package/src/signer/AbstractSigner.d.ts +0 -12
- package/src/signer/AbstractSigner.js +0 -2
- package/src/signer/PrivateKeySigner.d.ts +0 -0
- package/src/signer/PrivateKeySigner.js +0 -64
- package/src/signer/setSigner.d.ts +0 -2
- package/src/signer/setSigner.js +0 -8
|
@@ -1,84 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
exports.default = getIdentityNonce;
|
|
40
|
-
var platform_1 = require("../../proto/generated/platform");
|
|
41
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
42
|
-
var getQuorumPublicKey_1 = require("../utils/getQuorumPublicKey");
|
|
43
|
-
var bytesToHex_1 = require("../utils/bytesToHex");
|
|
44
|
-
var verifyTenderdashProof_1 = require("../utils/verifyTenderdashProof");
|
|
45
|
-
var IDENTITY_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
46
|
-
function getIdentityNonce(grpcPool, identifier) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var id, getIdentityNonceRequest, v0, _a, proof, metadata, _b, rootHash, nonce, quorumPublicKey, verify;
|
|
49
|
-
return __generator(this, function (_c) {
|
|
50
|
-
switch (_c.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
id = new pshenmic_dpp_1.IdentifierWASM(identifier);
|
|
53
|
-
getIdentityNonceRequest = platform_1.GetIdentityNonceRequest.fromPartial({
|
|
54
|
-
v0: {
|
|
55
|
-
identityId: id.bytes(),
|
|
56
|
-
prove: true
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return [4 /*yield*/, grpcPool.getClient().getIdentityNonce(getIdentityNonceRequest)];
|
|
60
|
-
case 1:
|
|
61
|
-
v0 = (_c.sent()).v0;
|
|
62
|
-
_a = v0, proof = _a.proof, metadata = _a.metadata;
|
|
63
|
-
if (proof == null) {
|
|
64
|
-
throw new Error('Proof not found');
|
|
65
|
-
}
|
|
66
|
-
if (metadata == null) {
|
|
67
|
-
throw new Error('Metadata not found');
|
|
68
|
-
}
|
|
69
|
-
_b = (0, pshenmic_dpp_1.verifyIdentityNonceProof)(proof.grovedbProof, id.bytes(), true, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9), rootHash = _b.rootHash, nonce = _b.nonce;
|
|
70
|
-
if (nonce == null) {
|
|
71
|
-
return [2 /*return*/, BigInt(0)];
|
|
72
|
-
}
|
|
73
|
-
return [4 /*yield*/, (0, getQuorumPublicKey_1.getQuorumPublicKey)(grpcPool.network, proof.quorumType, (0, bytesToHex_1.default)(proof.quorumHash))];
|
|
74
|
-
case 2:
|
|
75
|
-
quorumPublicKey = _c.sent();
|
|
76
|
-
verify = (0, verifyTenderdashProof_1.default)(proof, metadata, rootHash, quorumPublicKey);
|
|
77
|
-
if (!verify) {
|
|
78
|
-
throw new Error('Failed to verify query');
|
|
79
|
-
}
|
|
80
|
-
return [2 /*return*/, BigInt(nonce) & IDENTITY_NONCE_VALUE_FILTER];
|
|
1
|
+
import { GetIdentityNonceRequest } from '../../proto/generated/platform.js';
|
|
2
|
+
import { IdentifierWASM, PlatformVersionWASM, verifyIdentityNonceProof } from 'pshenmic-dpp';
|
|
3
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
const IDENTITY_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF);
|
|
7
|
+
export default async function getIdentityNonce(grpcPool, identifier) {
|
|
8
|
+
const id = new IdentifierWASM(identifier);
|
|
9
|
+
const getIdentityNonceRequest = GetIdentityNonceRequest.create({
|
|
10
|
+
version: {
|
|
11
|
+
oneofKind: 'v0',
|
|
12
|
+
v0: {
|
|
13
|
+
identityId: id.bytes(),
|
|
14
|
+
prove: true
|
|
81
15
|
}
|
|
82
|
-
}
|
|
16
|
+
}
|
|
83
17
|
});
|
|
18
|
+
const { response } = await grpcPool.getClient().getIdentityNonce(getIdentityNonceRequest);
|
|
19
|
+
const { version } = response;
|
|
20
|
+
if (version.oneofKind !== 'v0') {
|
|
21
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
22
|
+
}
|
|
23
|
+
const { v0 } = version;
|
|
24
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
25
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
26
|
+
}
|
|
27
|
+
const { result: { proof }, metadata } = v0;
|
|
28
|
+
if (metadata == null) {
|
|
29
|
+
throw new Error('Metadata not found');
|
|
30
|
+
}
|
|
31
|
+
const { rootHash, nonce } = verifyIdentityNonceProof(proof.grovedbProof, id.bytes(), true, PlatformVersionWASM.PLATFORM_V9);
|
|
32
|
+
if (nonce == null) {
|
|
33
|
+
return BigInt(0);
|
|
34
|
+
}
|
|
35
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
36
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
37
|
+
if (!verify) {
|
|
38
|
+
throw new Error('Failed to verify query');
|
|
39
|
+
}
|
|
40
|
+
return BigInt(nonce) & IDENTITY_NONCE_VALUE_FILTER;
|
|
84
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IdentityPublicKeyWASM } from 'pshenmic-dpp';
|
|
2
|
-
import { IdentifierLike } from '../types';
|
|
3
|
-
import GRPCConnectionPool from '../grpcConnectionPool';
|
|
4
|
-
export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<IdentityPublicKeyWASM[]>;
|
|
2
|
+
import { IdentifierLike } from '../types.js';
|
|
3
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
4
|
+
export default function getIdentityPublicKeys(grpcPool: GRPCConnectionPool, identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
|
|
@@ -1,85 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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;
|
|
1
|
+
import { GetIdentityKeysRequest, KeyRequestType } from '../../proto/generated/platform.js';
|
|
2
|
+
import { IdentifierWASM, PlatformVersionWASM, verifyIdentityKeysByIdentifierProof } from 'pshenmic-dpp';
|
|
3
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
export default async function getIdentityPublicKeys(grpcPool, identifier, keyIds) {
|
|
7
|
+
const id = new IdentifierWASM(identifier);
|
|
8
|
+
let requestType = {
|
|
9
|
+
request: {
|
|
10
|
+
oneofKind: 'allKeys',
|
|
11
|
+
allKeys: {}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
if (keyIds != null) {
|
|
15
|
+
requestType = {
|
|
16
|
+
request: {
|
|
17
|
+
oneofKind: 'specificKeys',
|
|
18
|
+
specificKeys: { keyIds }
|
|
32
19
|
}
|
|
33
|
-
|
|
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 };
|
|
20
|
+
};
|
|
36
21
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var verifyTenderdashProof_1 = require("../utils/verifyTenderdashProof");
|
|
45
|
-
function getIdentityPublicKeys(grpcPool, identifier) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
var id, getIdentityKeysRequest, v0, _a, proof, metadata, _b, rootHash, identity, quorumPublicKey, verify, loadedKeysIds;
|
|
48
|
-
return __generator(this, function (_c) {
|
|
49
|
-
switch (_c.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
id = new pshenmic_dpp_1.IdentifierWASM(identifier);
|
|
52
|
-
getIdentityKeysRequest = platform_1.GetIdentityKeysRequest.fromPartial({
|
|
53
|
-
v0: {
|
|
54
|
-
identityId: id.bytes(),
|
|
55
|
-
requestType: platform_1.KeyRequestType.fromPartial({ allKeys: {} }),
|
|
56
|
-
prove: true
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return [4 /*yield*/, grpcPool.getClient().getIdentityKeys(getIdentityKeysRequest)];
|
|
60
|
-
case 1:
|
|
61
|
-
v0 = (_c.sent()).v0;
|
|
62
|
-
_a = v0, proof = _a.proof, metadata = _a.metadata;
|
|
63
|
-
if (proof == null) {
|
|
64
|
-
throw new Error('Proof not found');
|
|
65
|
-
}
|
|
66
|
-
if (metadata == null) {
|
|
67
|
-
throw new Error('Metadata not found');
|
|
68
|
-
}
|
|
69
|
-
_b = (0, pshenmic_dpp_1.verifyIdentityKeysByIdentifierProof)(proof.grovedbProof, id.bytes(), null, false, false, true, null, null, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9), rootHash = _b.rootHash, identity = _b.identity;
|
|
70
|
-
if (identity == null) {
|
|
71
|
-
throw new Error("Identity with identifier ".concat(id.base58(), " not found"));
|
|
72
|
-
}
|
|
73
|
-
return [4 /*yield*/, (0, getQuorumPublicKey_1.getQuorumPublicKey)(grpcPool.network, proof.quorumType, (0, bytesToHex_1.default)(proof.quorumHash))];
|
|
74
|
-
case 2:
|
|
75
|
-
quorumPublicKey = _c.sent();
|
|
76
|
-
verify = (0, verifyTenderdashProof_1.default)(proof, metadata, rootHash, quorumPublicKey);
|
|
77
|
-
if (!verify) {
|
|
78
|
-
throw new Error('Failed to verify query');
|
|
79
|
-
}
|
|
80
|
-
loadedKeysIds = Object.keys(identity.loadedPublicKeys);
|
|
81
|
-
return [2 /*return*/, loadedKeysIds.map(function (id) { return identity.loadedPublicKeys[id]; })];
|
|
22
|
+
const getIdentityKeysRequest = GetIdentityKeysRequest.create({
|
|
23
|
+
version: {
|
|
24
|
+
oneofKind: 'v0',
|
|
25
|
+
v0: {
|
|
26
|
+
identityId: id.bytes(),
|
|
27
|
+
requestType: KeyRequestType.create(requestType),
|
|
28
|
+
prove: true
|
|
82
29
|
}
|
|
83
|
-
}
|
|
30
|
+
}
|
|
84
31
|
});
|
|
32
|
+
const { response } = await grpcPool.getClient().getIdentityKeys(getIdentityKeysRequest);
|
|
33
|
+
const { version } = response;
|
|
34
|
+
if (version.oneofKind !== 'v0') {
|
|
35
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
36
|
+
}
|
|
37
|
+
const { v0 } = version;
|
|
38
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
39
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
40
|
+
}
|
|
41
|
+
const { result: { proof }, metadata } = v0;
|
|
42
|
+
if (metadata == null) {
|
|
43
|
+
throw new Error('Metadata not found');
|
|
44
|
+
}
|
|
45
|
+
const { rootHash, identity } = verifyIdentityKeysByIdentifierProof(proof.grovedbProof, id.bytes(), keyIds != null ? keyIds : null, false, false, true, null, null, PlatformVersionWASM.PLATFORM_V9);
|
|
46
|
+
if (identity == null) {
|
|
47
|
+
throw new Error(`Identity with identifier ${id.base58()} not found`);
|
|
48
|
+
}
|
|
49
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
50
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
51
|
+
if (!verify) {
|
|
52
|
+
throw new Error('Failed to verify query');
|
|
53
|
+
}
|
|
54
|
+
const loadedKeysIds = Object.keys(identity.loadedPublicKeys);
|
|
55
|
+
return loadedKeysIds.map((id) => identity.loadedPublicKeys[id]);
|
|
85
56
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IdentifierLike, IdentityTransitionParams } from '../types';
|
|
2
|
-
import GRPCConnectionPool from '../grpcConnectionPool';
|
|
1
|
+
import { IdentifierLike, IdentityTransitionParams } from '../types.js';
|
|
2
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
3
3
|
import { IdentityPublicKeyWASM, IdentityWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods to query identities and its related data
|
|
@@ -56,11 +56,12 @@ export declare class IdentitiesController {
|
|
|
56
56
|
getIdentityContractNonce(identifier: IdentifierLike, dataContract: IdentifierLike): Promise<bigint>;
|
|
57
57
|
/**
|
|
58
58
|
* Retrieve given Identity's public keys
|
|
59
|
-
* @param identifier
|
|
59
|
+
* @param identifier {IdentifierLike}
|
|
60
|
+
* @param keyIds {=number[]} optional, specific keyIds to request
|
|
60
61
|
*
|
|
61
62
|
* @return {Promise<IdentityPublicKeyWASM[]>}
|
|
62
63
|
*/
|
|
63
|
-
getIdentityPublicKeys(identifier: IdentifierLike): Promise<IdentityPublicKeyWASM[]>;
|
|
64
|
+
getIdentityPublicKeys(identifier: IdentifierLike, keyIds?: number[]): Promise<IdentityPublicKeyWASM[]>;
|
|
64
65
|
/**
|
|
65
66
|
* Helper function for creating {StateTransitionWASM} for Identity transitions
|
|
66
67
|
*
|
|
@@ -68,8 +69,10 @@ export declare class IdentitiesController {
|
|
|
68
69
|
* all necessary AssetLockProof data to make the transaction.
|
|
69
70
|
* Both InstantSend and ChainLock AssetLock proofs supported
|
|
70
71
|
*
|
|
71
|
-
*
|
|
72
|
+
* Please refer to Identity.spec.js or README for example commands
|
|
73
|
+
*
|
|
74
|
+
* @param type {string} type of transition, must be a one of ('create' | 'update' | 'topUp' | 'creditTransfer' | 'withdrawal')
|
|
72
75
|
* @param params {IdentityTransitionParams} params
|
|
73
76
|
*/
|
|
74
|
-
createStateTransition(type: 'create' | 'update' | 'topUp', params: IdentityTransitionParams): StateTransitionWASM;
|
|
77
|
+
createStateTransition(type: 'create' | 'update' | 'topUp' | 'creditTransfer' | 'withdrawal', params: IdentityTransitionParams): StateTransitionWASM;
|
|
75
78
|
}
|
package/src/identities/index.js
CHANGED
|
@@ -1,59 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
exports.IdentitiesController = void 0;
|
|
40
|
-
var getIdentityContractNonce_1 = require("./getIdentityContractNonce");
|
|
41
|
-
var getIdentityPublicKeys_1 = require("./getIdentityPublicKeys");
|
|
42
|
-
var getIdentityNonce_1 = require("./getIdentityNonce");
|
|
43
|
-
var getIdentityBalance_1 = require("./getIdentityBalance");
|
|
44
|
-
var getIdentityByPublicKeyHash_1 = require("./getIdentityByPublicKeyHash");
|
|
45
|
-
var getIdentityByIdentifier_1 = require("./getIdentityByIdentifier");
|
|
46
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
47
|
-
var createStateTransition_1 = require("./createStateTransition");
|
|
48
|
-
var getIdentityByNonUniquePublicKeyHash_1 = require("./getIdentityByNonUniquePublicKeyHash");
|
|
49
|
-
var hexToBytes_1 = require("../utils/hexToBytes");
|
|
1
|
+
import getIdentityContractNonce from './getIdentityContractNonce.js';
|
|
2
|
+
import getIdentityPublicKeys from './getIdentityPublicKeys.js';
|
|
3
|
+
import getIdentityNonce from './getIdentityNonce.js';
|
|
4
|
+
import getIdentityBalance from './getIdentityBalance.js';
|
|
5
|
+
import getIdentityByPublicKeyHash from './getIdentityByPublicKeyHash.js';
|
|
6
|
+
import getIdentityByIdentifier from './getIdentityByIdentifier.js';
|
|
7
|
+
import { AssetLockProofWASM, ContractBoundsWASM, CoreScriptWASM, IdentifierWASM, IdentityPublicKeyInCreationWASM, OutPointWASM, PoolingWASM } from 'pshenmic-dpp';
|
|
8
|
+
import createStateTransition from './createStateTransition.js';
|
|
9
|
+
import getIdentityByNonUniquePublicKeyHash from './getIdentityByNonUniquePublicKeyHash.js';
|
|
10
|
+
import hexToBytes from '../utils/hexToBytes.js';
|
|
11
|
+
import { base58 } from '@scure/base';
|
|
50
12
|
/**
|
|
51
13
|
* Collection of methods to query identities and its related data
|
|
52
14
|
*
|
|
53
15
|
* @hideconstructor
|
|
54
16
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
17
|
+
export class IdentitiesController {
|
|
18
|
+
/** @ignore */
|
|
19
|
+
grpcPool;
|
|
20
|
+
constructor(grpcPool) {
|
|
57
21
|
this.grpcPool = grpcPool;
|
|
58
22
|
}
|
|
59
23
|
/**
|
|
@@ -63,16 +27,9 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
63
27
|
*
|
|
64
28
|
* @return {Promise<bigint>}
|
|
65
29
|
*/
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
switch (_a.label) {
|
|
70
|
-
case 0: return [4 /*yield*/, (0, getIdentityBalance_1.default)(this.grpcPool, identifier)];
|
|
71
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
30
|
+
async getIdentityBalance(identifier) {
|
|
31
|
+
return await getIdentityBalance(this.grpcPool, identifier);
|
|
32
|
+
}
|
|
76
33
|
/**
|
|
77
34
|
* Retrieves an Identity from the network by give public key hash
|
|
78
35
|
*
|
|
@@ -80,20 +37,12 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
80
37
|
*
|
|
81
38
|
* @return {Promise<IdentityWASM>}
|
|
82
39
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
throw new Error('Public key hash should equal 40');
|
|
90
|
-
}
|
|
91
|
-
return [4 /*yield*/, (0, getIdentityByPublicKeyHash_1.default)(this.grpcPool, hex)];
|
|
92
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
40
|
+
async getIdentityByPublicKeyHash(hex) {
|
|
41
|
+
if (hex.length !== 40) {
|
|
42
|
+
throw new Error('Public key hash should equal 40');
|
|
43
|
+
}
|
|
44
|
+
return await getIdentityByPublicKeyHash(this.grpcPool, hex);
|
|
45
|
+
}
|
|
97
46
|
/**
|
|
98
47
|
* Retrieves an Identity from the network by non-unique public key hash (like Voter Identity, SHA160)
|
|
99
48
|
*
|
|
@@ -101,50 +50,28 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
101
50
|
*
|
|
102
51
|
* @return {Promise<IdentityWASM>}
|
|
103
52
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw new Error('Public key hash should equal 40');
|
|
111
|
-
}
|
|
112
|
-
return [4 /*yield*/, (0, getIdentityByNonUniquePublicKeyHash_1.default)(this.grpcPool, hex)];
|
|
113
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
};
|
|
53
|
+
async getIdentityByNonUniquePublicKeyHash(hex) {
|
|
54
|
+
if (hex.length !== 40) {
|
|
55
|
+
throw new Error('Public key hash should equal 40');
|
|
56
|
+
}
|
|
57
|
+
return await getIdentityByNonUniquePublicKeyHash(this.grpcPool, hex);
|
|
58
|
+
}
|
|
118
59
|
/**
|
|
119
60
|
* Retrieves Identity by identifier from the network
|
|
120
61
|
* @param identifier {IdentifierLike} identifier
|
|
121
62
|
*
|
|
122
63
|
* @return {Promise<IdentityWASM>}
|
|
123
64
|
*/
|
|
124
|
-
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
switch (_a.label) {
|
|
128
|
-
case 0: return [4 /*yield*/, (0, getIdentityByIdentifier_1.default)(this.grpcPool, identifier)];
|
|
129
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
65
|
+
async getIdentityByIdentifier(identifier) {
|
|
66
|
+
return await getIdentityByIdentifier(this.grpcPool, identifier);
|
|
67
|
+
}
|
|
134
68
|
/**
|
|
135
69
|
* Get Identity Nonce (usually used by Identity transitions)
|
|
136
70
|
* @param identifier
|
|
137
71
|
*/
|
|
138
|
-
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
switch (_a.label) {
|
|
142
|
-
case 0: return [4 /*yield*/, (0, getIdentityNonce_1.default)(this.grpcPool, identifier)];
|
|
143
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
72
|
+
async getIdentityNonce(identifier) {
|
|
73
|
+
return await getIdentityNonce(this.grpcPool, identifier);
|
|
74
|
+
}
|
|
148
75
|
/**
|
|
149
76
|
* Get Identity Contract Nonce (usually used by Document transitions)
|
|
150
77
|
* @param identifier
|
|
@@ -152,32 +79,19 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
152
79
|
*
|
|
153
80
|
* @return {Promise<bigint>}
|
|
154
81
|
*/
|
|
155
|
-
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0: return [4 /*yield*/, (0, getIdentityContractNonce_1.default)(this.grpcPool, identifier, dataContract)];
|
|
160
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
};
|
|
82
|
+
async getIdentityContractNonce(identifier, dataContract) {
|
|
83
|
+
return await getIdentityContractNonce(this.grpcPool, identifier, dataContract);
|
|
84
|
+
}
|
|
165
85
|
/**
|
|
166
86
|
* Retrieve given Identity's public keys
|
|
167
|
-
* @param identifier
|
|
87
|
+
* @param identifier {IdentifierLike}
|
|
88
|
+
* @param keyIds {=number[]} optional, specific keyIds to request
|
|
168
89
|
*
|
|
169
90
|
* @return {Promise<IdentityPublicKeyWASM[]>}
|
|
170
91
|
*/
|
|
171
|
-
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
switch (_a.label) {
|
|
175
|
-
case 0: return [4 /*yield*/, (0, getIdentityPublicKeys_1.default)(this.grpcPool, identifier)];
|
|
176
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
};
|
|
92
|
+
async getIdentityPublicKeys(identifier, keyIds) {
|
|
93
|
+
return await getIdentityPublicKeys(this.grpcPool, identifier, keyIds);
|
|
94
|
+
}
|
|
181
95
|
/**
|
|
182
96
|
* Helper function for creating {StateTransitionWASM} for Identity transitions
|
|
183
97
|
*
|
|
@@ -185,53 +99,56 @@ var IdentitiesController = /** @class */ (function () {
|
|
|
185
99
|
* all necessary AssetLockProof data to make the transaction.
|
|
186
100
|
* Both InstantSend and ChainLock AssetLock proofs supported
|
|
187
101
|
*
|
|
188
|
-
*
|
|
102
|
+
* Please refer to Identity.spec.js or README for example commands
|
|
103
|
+
*
|
|
104
|
+
* @param type {string} type of transition, must be a one of ('create' | 'update' | 'topUp' | 'creditTransfer' | 'withdrawal')
|
|
189
105
|
* @param params {IdentityTransitionParams} params
|
|
190
106
|
*/
|
|
191
|
-
|
|
107
|
+
createStateTransition(type, params) {
|
|
192
108
|
if (params.identityId != null) {
|
|
193
|
-
params.identityId = new
|
|
109
|
+
params.identityId = new IdentifierWASM(params.identityId);
|
|
194
110
|
}
|
|
195
111
|
if (params.disablePublicKeyIds == null) {
|
|
196
112
|
params.disablePublicKeyIds = [];
|
|
197
113
|
}
|
|
198
114
|
if (params.assetLockProof != null) {
|
|
199
|
-
|
|
200
|
-
if (
|
|
201
|
-
|
|
115
|
+
const { type } = params.assetLockProof;
|
|
116
|
+
if (type === 'chainLock') {
|
|
117
|
+
const { txid, outputIndex, coreChainLockedHeight } = params.assetLockProof;
|
|
202
118
|
// @ts-expect-error
|
|
203
|
-
params.assetLockProof =
|
|
119
|
+
params.assetLockProof = AssetLockProofWASM.createChainAssetLockProof(coreChainLockedHeight, new OutPointWASM(txid, outputIndex));
|
|
204
120
|
}
|
|
205
|
-
else if (
|
|
206
|
-
|
|
121
|
+
else if (type === 'instantLock') {
|
|
122
|
+
const { transaction, outputIndex, instantLock } = params.assetLockProof;
|
|
207
123
|
// @ts-expect-error
|
|
208
|
-
params.assetLockProof =
|
|
124
|
+
params.assetLockProof = AssetLockProofWASM.createInstantAssetLockProof(hexToBytes(instantLock), hexToBytes(transaction), outputIndex);
|
|
209
125
|
}
|
|
210
|
-
else if (
|
|
126
|
+
else if (type == null) {
|
|
211
127
|
throw new Error('Missing Asset Lock type in the params');
|
|
212
128
|
}
|
|
213
129
|
else {
|
|
214
|
-
throw new Error(
|
|
130
|
+
throw new Error(`Unknown Asset Lock type: ${type}`);
|
|
215
131
|
}
|
|
216
132
|
}
|
|
217
133
|
if (params.addPublicKeys != null) {
|
|
218
134
|
// @ts-expect-error
|
|
219
135
|
params.addPublicKeys = params.addPublicKeys
|
|
220
|
-
.map(
|
|
221
|
-
var id = _a.id, purpose = _a.purpose, securityLevel = _a.securityLevel, keyType = _a.keyType, readOnly = _a.readOnly, data = _a.data, signature = _a.signature, contractBounds = _a.contractBounds;
|
|
222
|
-
return new pshenmic_dpp_1.IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new pshenmic_dpp_1.ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined);
|
|
223
|
-
});
|
|
136
|
+
.map(({ id, purpose, securityLevel, keyType, readOnly, data, signature, contractBounds }) => new IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined));
|
|
224
137
|
}
|
|
225
138
|
if (params.publicKeys != null) {
|
|
226
139
|
// @ts-expect-error
|
|
227
140
|
params.publicKeys = params.publicKeys
|
|
228
|
-
.map(
|
|
229
|
-
var id = _a.id, purpose = _a.purpose, securityLevel = _a.securityLevel, keyType = _a.keyType, readOnly = _a.readOnly, data = _a.data, signature = _a.signature, contractBounds = _a.contractBounds;
|
|
230
|
-
return new pshenmic_dpp_1.IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new pshenmic_dpp_1.ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined);
|
|
231
|
-
});
|
|
141
|
+
.map(({ id, purpose, securityLevel, keyType, readOnly, data, signature, contractBounds }) => new IdentityPublicKeyInCreationWASM(id, purpose, securityLevel, keyType, readOnly, data, signature, (contractBounds != null) ? new ContractBoundsWASM(contractBounds.dataContractId, contractBounds.documentType) : undefined));
|
|
232
142
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
143
|
+
if (params.recipientId != null) {
|
|
144
|
+
params.recipientId = new IdentifierWASM(params.recipientId);
|
|
145
|
+
}
|
|
146
|
+
if (type === 'withdrawal') {
|
|
147
|
+
// @ts-expect-error
|
|
148
|
+
params.pooling = params.pooling != null ? PoolingWASM[params.pooling] : PoolingWASM.Standard;
|
|
149
|
+
params.coreFeePerByte = params.coreFeePerByte ?? 1;
|
|
150
|
+
params.outputScript = params.outputScript ?? (params.withdrawalAddress != null ? CoreScriptWASM.newP2PKH(base58.decode(params.withdrawalAddress).slice(1, 21)) : undefined);
|
|
151
|
+
}
|
|
152
|
+
return createStateTransition(type, params);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HDKey } from '
|
|
2
|
-
export default function deriveChild(
|
|
1
|
+
import { HDKey } from '@scure/bip32';
|
|
2
|
+
export default function deriveChild(hdKey: HDKey, index: number): HDKey;
|