dash-platform-sdk 1.1.0 → 1.1.2
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 +1 -1
- package/package.json +7 -6
- package/proto/generated/platform.d.ts +340 -115
- package/proto/generated/platform.js +3732 -2333
- package/src/DashPlatformSDK.d.ts +18 -5
- package/src/DashPlatformSDK.js +20 -7
- package/src/constants.d.ts +4 -0
- package/src/constants.js +5 -1
- package/src/contestedResources/getContestedResourceVoteState.d.ts +6 -0
- package/src/contestedResources/getContestedResourceVoteState.js +124 -0
- package/src/contestedResources/index.d.ts +29 -0
- package/src/contestedResources/index.js +75 -0
- package/src/dataContracts/create.js +1 -1
- package/src/dataContracts/createStateTransition.d.ts +1 -1
- package/src/dataContracts/createStateTransition.js +5 -6
- package/src/dataContracts/getDataContractByIdentifier.js +5 -5
- package/src/dataContracts/index.d.ts +2 -3
- package/src/dataContracts/index.js +1 -1
- package/src/documents/create.d.ts +1 -1
- package/src/documents/create.js +1 -41
- package/src/documents/createStateTransition.d.ts +2 -2
- package/src/documents/createStateTransition.js +9 -10
- package/src/documents/index.d.ts +3 -3
- package/src/documents/index.js +3 -7
- package/src/documents/query.js +3 -5
- package/src/grpcConnectionPool.d.ts +3 -2
- package/src/grpcConnectionPool.js +52 -48
- package/src/identities/getIdentityBalance.js +4 -4
- package/src/identities/getIdentityByIdentifier.js +4 -4
- package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +3 -0
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +87 -0
- package/src/identities/getIdentityByPublicKeyHash.js +4 -4
- package/src/identities/getIdentityContractNonce.js +4 -4
- package/src/identities/getIdentityNonce.js +4 -4
- package/src/identities/getIdentityPublicKeys.js +4 -4
- package/src/identities/index.d.ts +9 -1
- package/src/identities/index.js +23 -1
- package/src/node/epochs.d.ts +10 -0
- package/src/node/epochs.js +82 -0
- package/src/node/index.d.ts +16 -1
- package/src/node/index.js +35 -1
- package/src/node/totalCredits.d.ts +2 -0
- package/src/node/totalCredits.js +77 -0
- package/src/stateTransitions/broadcast.js +3 -0
- package/src/tokens/getIdentitiesTokenBalances.d.ts +8 -0
- package/src/tokens/getIdentitiesTokenBalances.js +87 -0
- package/src/tokens/getIdentityTokensBalances.d.ts +8 -0
- package/src/tokens/getIdentityTokensBalances.js +87 -0
- package/src/tokens/getTokenContractInfo.d.ts +8 -0
- package/src/tokens/getTokenContractInfo.js +87 -0
- package/src/tokens/getTokenTotalSupply.d.ts +9 -0
- package/src/tokens/getTokenTotalSupply.js +85 -0
- package/src/tokens/index.d.ts +50 -0
- package/src/tokens/index.js +124 -0
- package/src/types.d.ts +30 -0
- package/src/types.js +14 -1
- package/src/utils/indexBytesToString.d.ts +1 -0
- package/src/utils/indexBytesToString.js +7 -0
- package/src/utils/stringToIndexValueBytes.d.ts +1 -0
- package/src/utils/stringToIndexValueBytes.js +13 -0
- package/test/unit/ContestedResources.spec.d.ts +1 -0
- package/test/unit/ContestedResources.spec.js +257 -0
- package/test/unit/DataContract.spec.js +16 -6
- package/test/unit/DocumentsBatch.spec.js +6 -6
- package/test/unit/Identity.spec.js +15 -3
- package/test/unit/Node.spec.js +40 -0
- package/test/unit/Tokens.spec.d.ts +1 -0
- package/test/unit/Tokens.spec.js +100 -0
package/src/DashPlatformSDK.d.ts
CHANGED
|
@@ -7,9 +7,17 @@ import { KeyPairController } from './keyPair';
|
|
|
7
7
|
import { NodeController } from './node';
|
|
8
8
|
import { NamesController } from './names';
|
|
9
9
|
import { DataContractsController } from './dataContracts';
|
|
10
|
+
import ContestedResourcesController from './contestedResources';
|
|
11
|
+
import TokensController from './tokens';
|
|
10
12
|
import { AbstractSigner } from './signer/AbstractSigner';
|
|
13
|
+
export interface GRPCOptions {
|
|
14
|
+
poolLimit: 5;
|
|
15
|
+
dapiUrl?: string | string[];
|
|
16
|
+
}
|
|
11
17
|
export interface SDKOptions {
|
|
12
18
|
network: 'testnet' | 'mainnet';
|
|
19
|
+
grpc?: GRPCOptions;
|
|
20
|
+
/** @deprecated Use {GRPCOptions} instead, will be removed in next major version **/
|
|
13
21
|
dapiUrl?: string | string[];
|
|
14
22
|
signer?: AbstractSigner;
|
|
15
23
|
}
|
|
@@ -20,15 +28,19 @@ export declare class DashPlatformSDK {
|
|
|
20
28
|
network: 'testnet' | 'mainnet';
|
|
21
29
|
/** @ignore **/
|
|
22
30
|
grpcPool: GRPCConnectionPool;
|
|
23
|
-
|
|
31
|
+
/** @ignore **/
|
|
32
|
+
options?: SDKOptions;
|
|
33
|
+
contestedResources: ContestedResourcesController;
|
|
34
|
+
stateTransitions: StateTransitionsController;
|
|
35
|
+
dataContracts: DataContractsController;
|
|
24
36
|
identities: IdentitiesController;
|
|
25
37
|
documents: DocumentsController;
|
|
26
|
-
stateTransitions: StateTransitionsController;
|
|
27
38
|
keyPair: KeyPairController;
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
tokens: TokensController;
|
|
40
|
+
utils: UtilsController;
|
|
30
41
|
names: NamesController;
|
|
31
42
|
signer?: AbstractSigner;
|
|
43
|
+
node: NodeController;
|
|
32
44
|
/**
|
|
33
45
|
* Constructs a new DashPlatformSDK instance, optionally pass options
|
|
34
46
|
* if you want to configure the SDK instance (network, dapiUrl, signer)
|
|
@@ -42,8 +54,9 @@ export declare class DashPlatformSDK {
|
|
|
42
54
|
* Internal function to initialize SDK GRPC connection pool. Is not meant to be used outside the SDK
|
|
43
55
|
*
|
|
44
56
|
* @param grpcPool
|
|
57
|
+
* @param network
|
|
45
58
|
*/
|
|
46
|
-
_initialize(grpcPool: GRPCConnectionPool): void;
|
|
59
|
+
_initialize(grpcPool: GRPCConnectionPool, network: 'testnet' | 'mainnet'): void;
|
|
47
60
|
setSigner(signer: AbstractSigner): void;
|
|
48
61
|
/**
|
|
49
62
|
* Get currently used network
|
package/src/DashPlatformSDK.js
CHANGED
|
@@ -10,6 +10,8 @@ var keyPair_1 = require("./keyPair");
|
|
|
10
10
|
var node_1 = require("./node");
|
|
11
11
|
var names_1 = require("./names");
|
|
12
12
|
var dataContracts_1 = require("./dataContracts");
|
|
13
|
+
var contestedResources_1 = require("./contestedResources");
|
|
14
|
+
var tokens_1 = require("./tokens");
|
|
13
15
|
var wasm_drive_verify_1 = require("wasm-drive-verify");
|
|
14
16
|
var base_1 = require("@scure/base");
|
|
15
17
|
/**
|
|
@@ -23,15 +25,21 @@ var DashPlatformSDK = /** @class */ (function () {
|
|
|
23
25
|
* @param options {SDKOptions=}
|
|
24
26
|
*/
|
|
25
27
|
function DashPlatformSDK(options) {
|
|
26
|
-
var _a;
|
|
28
|
+
var _a, _b;
|
|
27
29
|
if (options != null && (options.network == null || !['testnet', 'mainnet'].includes(options.network))) {
|
|
28
30
|
throw new Error('If options is passed, network must be set (either mainnet or testnet)');
|
|
29
31
|
}
|
|
30
32
|
this.network = (_a = options === null || options === void 0 ? void 0 : options.network) !== null && _a !== void 0 ? _a : 'testnet';
|
|
31
33
|
this.signer = options === null || options === void 0 ? void 0 : options.signer;
|
|
34
|
+
this.options = options;
|
|
32
35
|
this.utils = new utils_1.UtilsController();
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
// Compatibility
|
|
37
|
+
if ((options === null || options === void 0 ? void 0 : options.dapiUrl) != null && ((options === null || options === void 0 ? void 0 : options.grpc) == null)) {
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
this.options.grpc = { dapiUrl: options.dapiUrl };
|
|
40
|
+
}
|
|
41
|
+
this.grpcPool = new grpcConnectionPool_1.default(this.network, (_b = this.options) === null || _b === void 0 ? void 0 : _b.grpc);
|
|
42
|
+
this._initialize(this.grpcPool, this.network);
|
|
35
43
|
var driveVerifyWASMBytes = base_1.base64.decode(wasm_drive_verify_1.wasmBase64);
|
|
36
44
|
(0, wasm_drive_verify_1.initSync)({ module: driveVerifyWASMBytes });
|
|
37
45
|
}
|
|
@@ -41,14 +49,18 @@ var DashPlatformSDK = /** @class */ (function () {
|
|
|
41
49
|
* Internal function to initialize SDK GRPC connection pool. Is not meant to be used outside the SDK
|
|
42
50
|
*
|
|
43
51
|
* @param grpcPool
|
|
52
|
+
* @param network
|
|
44
53
|
*/
|
|
45
|
-
DashPlatformSDK.prototype._initialize = function (grpcPool) {
|
|
54
|
+
DashPlatformSDK.prototype._initialize = function (grpcPool, network) {
|
|
55
|
+
this.grpcPool = grpcPool;
|
|
46
56
|
this.stateTransitions = new stateTransitions_1.StateTransitionsController(grpcPool);
|
|
57
|
+
this.contestedResources = new contestedResources_1.default(grpcPool);
|
|
47
58
|
this.dataContracts = new dataContracts_1.DataContractsController(grpcPool);
|
|
48
59
|
this.identities = new identities_1.IdentitiesController(grpcPool);
|
|
49
60
|
this.documents = new documents_1.DocumentsController(grpcPool);
|
|
61
|
+
this.node = new node_1.NodeController(grpcPool, network);
|
|
62
|
+
this.tokens = new tokens_1.default(grpcPool);
|
|
50
63
|
this.names = new names_1.NamesController(grpcPool);
|
|
51
|
-
this.node = new node_1.NodeController(grpcPool);
|
|
52
64
|
this.keyPair = new keyPair_1.KeyPairController();
|
|
53
65
|
};
|
|
54
66
|
DashPlatformSDK.prototype.setSigner = function (signer) {
|
|
@@ -68,12 +80,13 @@ var DashPlatformSDK = /** @class */ (function () {
|
|
|
68
80
|
* @param network {string}
|
|
69
81
|
*/
|
|
70
82
|
DashPlatformSDK.prototype.setNetwork = function (network) {
|
|
83
|
+
var _a;
|
|
71
84
|
if (network !== 'testnet' && network !== 'mainnet') {
|
|
72
85
|
throw new Error('Unknown network, should be mainnet or testnet');
|
|
73
86
|
}
|
|
74
87
|
this.network = network;
|
|
75
|
-
var grpcPool = new grpcConnectionPool_1.default(this.network);
|
|
76
|
-
this._initialize(grpcPool);
|
|
88
|
+
var grpcPool = new grpcConnectionPool_1.default(this.network, (_a = this.options) === null || _a === void 0 ? void 0 : _a.grpc);
|
|
89
|
+
this._initialize(grpcPool, this.network);
|
|
77
90
|
};
|
|
78
91
|
return DashPlatformSDK;
|
|
79
92
|
}());
|
package/src/constants.d.ts
CHANGED
|
@@ -2,3 +2,7 @@
|
|
|
2
2
|
* Default amount of documents to retrieve from DAPI
|
|
3
3
|
*/
|
|
4
4
|
export declare const DAPI_DEFAULT_LIMIT = 100;
|
|
5
|
+
export declare const HALVING_INTERVAL = 210240;
|
|
6
|
+
export declare const TESTNET_ACTIVATION_HEIGHT = 1066900;
|
|
7
|
+
export declare const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
8
|
+
export declare const GRPC_DEFAULT_POOL_LIMIT = 5;
|
package/src/constants.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DAPI_DEFAULT_LIMIT = void 0;
|
|
3
|
+
exports.GRPC_DEFAULT_POOL_LIMIT = exports.MAINNET_ACTIVATION_HEIGHT = exports.TESTNET_ACTIVATION_HEIGHT = exports.HALVING_INTERVAL = exports.DAPI_DEFAULT_LIMIT = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Default amount of documents to retrieve from DAPI
|
|
6
6
|
*/
|
|
7
7
|
exports.DAPI_DEFAULT_LIMIT = 100;
|
|
8
|
+
exports.HALVING_INTERVAL = 210240;
|
|
9
|
+
exports.TESTNET_ACTIVATION_HEIGHT = 1066900;
|
|
10
|
+
exports.MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
11
|
+
exports.GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContestedResourceVoteState, ContestedStateResultType } from '../types';
|
|
2
|
+
import GRPCConnectionPool from '../grpcConnectionPool';
|
|
3
|
+
import { GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_StartAtIdentifierInfo } from '../../proto/generated/platform';
|
|
4
|
+
import { DataContractWASM } from 'pshenmic-dpp';
|
|
5
|
+
export type StartAtIdentifierInfo = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_StartAtIdentifierInfo;
|
|
6
|
+
export default function getContestedResourceVoteState(grpcPool: GRPCConnectionPool, contract: DataContractWASM, documentTypeName: string, indexName: string, indexValues: Array<Uint8Array<ArrayBufferLike>>, resultType: ContestedStateResultType, allowIncludeLockedAndAbstainingVoteTally: boolean, startAtIdentifierInfo?: StartAtIdentifierInfo, count?: number): Promise<ContestedResourceVoteState>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.default = getContestedResourceVoteState;
|
|
51
|
+
var platform_1 = require("../../proto/generated/platform");
|
|
52
|
+
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
53
|
+
var wasm_drive_verify_1 = require("wasm-drive-verify");
|
|
54
|
+
var verifyTenderdashProof_1 = require("../utils/verifyTenderdashProof");
|
|
55
|
+
var getQuorumPublicKey_1 = require("../utils/getQuorumPublicKey");
|
|
56
|
+
var bytesToHex_1 = require("../utils/bytesToHex");
|
|
57
|
+
function getContestedResourceVoteState(grpcPool, contract, documentTypeName, indexName, indexValues, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var getContestedResourceVoteStateRequest, v0, _a, proof, metadata, _b, rootHash, result, quorumPublicKey, verify, contenders, winner;
|
|
60
|
+
var _c, _d;
|
|
61
|
+
return __generator(this, function (_e) {
|
|
62
|
+
switch (_e.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (startAtIdentifierInfo != null) {
|
|
65
|
+
startAtIdentifierInfo = {
|
|
66
|
+
startIdentifier: (new pshenmic_dpp_1.IdentifierWASM(startAtIdentifierInfo.startIdentifier)).bytes(),
|
|
67
|
+
startIdentifierIncluded: startAtIdentifierInfo.startIdentifierIncluded
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
getContestedResourceVoteStateRequest = platform_1.GetContestedResourceVoteStateRequest.fromPartial({
|
|
71
|
+
v0: {
|
|
72
|
+
contractId: contract.id.bytes(),
|
|
73
|
+
documentTypeName: documentTypeName,
|
|
74
|
+
indexName: indexName,
|
|
75
|
+
indexValues: indexValues,
|
|
76
|
+
resultType: resultType,
|
|
77
|
+
allowIncludeLockedAndAbstainingVoteTally: allowIncludeLockedAndAbstainingVoteTally,
|
|
78
|
+
startAtIdentifierInfo: startAtIdentifierInfo,
|
|
79
|
+
count: count,
|
|
80
|
+
prove: true
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return [4 /*yield*/, grpcPool.getClient().getContestedResourceVoteState(getContestedResourceVoteStateRequest)];
|
|
84
|
+
case 1:
|
|
85
|
+
v0 = (_e.sent()).v0;
|
|
86
|
+
_a = v0, proof = _a.proof, metadata = _a.metadata;
|
|
87
|
+
if (proof == null) {
|
|
88
|
+
throw new Error('Proof not found');
|
|
89
|
+
}
|
|
90
|
+
if (metadata == null) {
|
|
91
|
+
throw new Error('Metadata not found');
|
|
92
|
+
}
|
|
93
|
+
_b = (0, wasm_drive_verify_1.verifyVotePollVoteStateProof)(proof.grovedbProof, contract.bytes(pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9), documentTypeName, indexName, indexValues, resultType, allowIncludeLockedAndAbstainingVoteTally, count, startAtIdentifierInfo, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9), rootHash = _b.root_hash, result = _b.result;
|
|
94
|
+
return [4 /*yield*/, (0, getQuorumPublicKey_1.getQuorumPublicKey)(proof.quorumType, (0, bytesToHex_1.default)(proof.quorumHash))];
|
|
95
|
+
case 2:
|
|
96
|
+
quorumPublicKey = _e.sent();
|
|
97
|
+
verify = (0, verifyTenderdashProof_1.default)(proof, metadata, rootHash, quorumPublicKey);
|
|
98
|
+
if (!verify) {
|
|
99
|
+
throw new Error('Failed to verify query');
|
|
100
|
+
}
|
|
101
|
+
contenders = (result !== null && result !== void 0 ? result : { contenders: [] }).contenders;
|
|
102
|
+
winner = (result !== null && result !== void 0 ? result : { winner: undefined }).winner;
|
|
103
|
+
if (contenders.length === 0) {
|
|
104
|
+
throw new Error('Vote state not found');
|
|
105
|
+
}
|
|
106
|
+
return [2 /*return*/, {
|
|
107
|
+
contenders: contenders.map(function (contender) { return (__assign(__assign({}, contender), { identifier: new pshenmic_dpp_1.IdentifierWASM(contender.identifier), document: contender.document != null ? pshenmic_dpp_1.DocumentWASM.fromBytes(contender.document, contract, documentTypeName, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9) : undefined })); }),
|
|
108
|
+
abstainVoteTally: (_c = result === null || result === void 0 ? void 0 : result.abstainVoteTally) !== null && _c !== void 0 ? _c : 0,
|
|
109
|
+
lockVoteTally: (_d = result === null || result === void 0 ? void 0 : result.lockVoteTally) !== null && _d !== void 0 ? _d : 0,
|
|
110
|
+
finishedVoteInfo: (winner != null)
|
|
111
|
+
? {
|
|
112
|
+
type: winner.type,
|
|
113
|
+
wonByIdentityId: winner.identityId != null ? new pshenmic_dpp_1.IdentifierWASM(winner.identityId) : undefined,
|
|
114
|
+
finishedAtBlockHeight: winner.blockInfo.height,
|
|
115
|
+
finishedAtCoreBlockHeight: winner.blockInfo.coreHeight,
|
|
116
|
+
finishedAtBlockTimeMs: winner.blockInfo.timeMs,
|
|
117
|
+
finishedAtEpoch: winner.blockInfo.epoch
|
|
118
|
+
}
|
|
119
|
+
: undefined
|
|
120
|
+
}];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool';
|
|
2
|
+
import { ContestedResourceVoteState, ContestedStateResultType } from '../types';
|
|
3
|
+
import { StartAtIdentifierInfo } from './getContestedResourceVoteState';
|
|
4
|
+
import { DataContractWASM } from 'pshenmic-dpp';
|
|
5
|
+
/**
|
|
6
|
+
* Contested Resources controller for requesting information about contested resources
|
|
7
|
+
*
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
10
|
+
export default class ContestedResourcesController {
|
|
11
|
+
/** @ignore **/
|
|
12
|
+
grpcPool: GRPCConnectionPool;
|
|
13
|
+
constructor(grpcPool: GRPCConnectionPool);
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves an info about vote state for contested resource
|
|
16
|
+
*
|
|
17
|
+
* @param contract {DataContractWASM} - instance of contract with contested resource
|
|
18
|
+
* @param documentTypeName {string} - document type name of contested resource
|
|
19
|
+
* @param indexName {string} - index name of contested resource
|
|
20
|
+
* @param indexValuesBytes {Uint8Array[]} - Array of contested values in bytes
|
|
21
|
+
* @param resultType {ContestedResourceVoteState} - enum for result info
|
|
22
|
+
* @param allowIncludeLockedAndAbstainingVoteTally {boolean}
|
|
23
|
+
* @param startAtIdentifierInfo {StartAtIdentifierInfo=}
|
|
24
|
+
* @param count {number=}
|
|
25
|
+
*
|
|
26
|
+
* @return {Promise<ContestedResourceVoteState>}
|
|
27
|
+
*/
|
|
28
|
+
getContestedResourceVoteState(contract: DataContractWASM, documentTypeName: string, indexName: string, indexValuesBytes: Uint8Array[], resultType: ContestedStateResultType, allowIncludeLockedAndAbstainingVoteTally: boolean, startAtIdentifierInfo?: StartAtIdentifierInfo, count?: number): Promise<ContestedResourceVoteState>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 = 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
|
+
var getContestedResourceVoteState_1 = require("./getContestedResourceVoteState");
|
|
40
|
+
/**
|
|
41
|
+
* Contested Resources controller for requesting information about contested resources
|
|
42
|
+
*
|
|
43
|
+
* @hideconstructor
|
|
44
|
+
*/
|
|
45
|
+
var ContestedResourcesController = /** @class */ (function () {
|
|
46
|
+
function ContestedResourcesController(grpcPool) {
|
|
47
|
+
this.grpcPool = grpcPool;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves an info about vote state for contested resource
|
|
51
|
+
*
|
|
52
|
+
* @param contract {DataContractWASM} - instance of contract with contested resource
|
|
53
|
+
* @param documentTypeName {string} - document type name of contested resource
|
|
54
|
+
* @param indexName {string} - index name of contested resource
|
|
55
|
+
* @param indexValuesBytes {Uint8Array[]} - Array of contested values in bytes
|
|
56
|
+
* @param resultType {ContestedResourceVoteState} - enum for result info
|
|
57
|
+
* @param allowIncludeLockedAndAbstainingVoteTally {boolean}
|
|
58
|
+
* @param startAtIdentifierInfo {StartAtIdentifierInfo=}
|
|
59
|
+
* @param count {number=}
|
|
60
|
+
*
|
|
61
|
+
* @return {Promise<ContestedResourceVoteState>}
|
|
62
|
+
*/
|
|
63
|
+
ContestedResourcesController.prototype.getContestedResourceVoteState = function (contract, documentTypeName, indexName, indexValuesBytes, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0: return [4 /*yield*/, (0, getContestedResourceVoteState_1.default)(this.grpcPool, contract, documentTypeName, indexName, indexValuesBytes, resultType, allowIncludeLockedAndAbstainingVoteTally, startAtIdentifierInfo, count)];
|
|
68
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
return ContestedResourcesController;
|
|
74
|
+
}());
|
|
75
|
+
exports.default = ContestedResourcesController;
|
|
@@ -6,7 +6,7 @@ function createDataContract(ownerId, identityNonce, schema, tokenConfiguration,
|
|
|
6
6
|
var id = new pshenmic_dpp_1.IdentifierWASM(ownerId);
|
|
7
7
|
var dataContract = new pshenmic_dpp_1.DataContractWASM(id, identityNonce, schema,
|
|
8
8
|
// we don't know what that param means yet
|
|
9
|
-
null, tokenConfiguration, fullValidation !== null && fullValidation !== void 0 ? fullValidation : true, platformVersion !== null && platformVersion !== void 0 ? platformVersion : pshenmic_dpp_1.PlatformVersionWASM.
|
|
9
|
+
null, tokenConfiguration, fullValidation !== null && fullValidation !== void 0 ? fullValidation : true, platformVersion !== null && platformVersion !== void 0 ? platformVersion : pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9);
|
|
10
10
|
if (config != null) {
|
|
11
11
|
dataContract.setConfig(config, platformVersion);
|
|
12
12
|
}
|
|
@@ -3,4 +3,4 @@ export declare enum DataContractTransitionType {
|
|
|
3
3
|
Create = 0,
|
|
4
4
|
Update = 1
|
|
5
5
|
}
|
|
6
|
-
export default function createStateTransition(dataContract: DataContractWASM, type:
|
|
6
|
+
export default function createStateTransition(dataContract: DataContractWASM, type: 'create' | 'update', identityNonce: bigint): StateTransitionWASM;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.DataContractTransitionType = void 0;
|
|
5
4
|
exports.default = createStateTransition;
|
|
@@ -9,14 +8,14 @@ var DataContractTransitionType;
|
|
|
9
8
|
DataContractTransitionType[DataContractTransitionType["Create"] = 0] = "Create";
|
|
10
9
|
DataContractTransitionType[DataContractTransitionType["Update"] = 1] = "Update";
|
|
11
10
|
})(DataContractTransitionType || (exports.DataContractTransitionType = DataContractTransitionType = {}));
|
|
12
|
-
var dataContractTransitionsMap =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
var dataContractTransitionsMap = {
|
|
12
|
+
create: pshenmic_dpp_1.DataContractCreateTransitionWASM,
|
|
13
|
+
update: pshenmic_dpp_1.DataContractUpdateTransitionWASM
|
|
14
|
+
};
|
|
16
15
|
function createStateTransition(dataContract, type, identityNonce) {
|
|
17
16
|
var TransitionClass = dataContractTransitionsMap[type];
|
|
18
17
|
if (TransitionClass == null) {
|
|
19
|
-
throw new Error("Unknown DataContract transition type: ".concat(type));
|
|
18
|
+
throw new Error("Unknown DataContract transition type: ".concat(type, ". Should be 'create' or 'update'."));
|
|
20
19
|
}
|
|
21
20
|
// @ts-expect-error
|
|
22
21
|
var dataContractTransition = new TransitionClass(dataContract, identityNonce);
|
|
@@ -66,7 +66,10 @@ function getByIdentifier(grpcPool, identifier) {
|
|
|
66
66
|
if (metadata == null) {
|
|
67
67
|
throw new Error('Metadata not found');
|
|
68
68
|
}
|
|
69
|
-
_b = (0, wasm_drive_verify_1.verifyContract)(proof.grovedbProof, undefined, true, false, id.bytes(),
|
|
69
|
+
_b = (0, wasm_drive_verify_1.verifyContract)(proof.grovedbProof, undefined, true, false, id.bytes(), pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9), rootHash = _b.root_hash, contract = _b.contract;
|
|
70
|
+
if (contract == null) {
|
|
71
|
+
throw new Error("Data Contract with identifier ".concat(id.base58(), " not found"));
|
|
72
|
+
}
|
|
70
73
|
return [4 /*yield*/, (0, getQuorumPublicKey_1.getQuorumPublicKey)(proof.quorumType, (0, bytesToHex_1.default)(proof.quorumHash))];
|
|
71
74
|
case 2:
|
|
72
75
|
quorumPublicKey = _c.sent();
|
|
@@ -74,10 +77,7 @@ function getByIdentifier(grpcPool, identifier) {
|
|
|
74
77
|
if (!verify) {
|
|
75
78
|
throw new Error('Failed to verify query');
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
throw new Error("Data Contract with identifier ".concat(id.base58(), " not found"));
|
|
79
|
-
}
|
|
80
|
-
return [2 /*return*/, pshenmic_dpp_1.DataContractWASM.fromBytes(contract, true, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V8)];
|
|
80
|
+
return [2 /*return*/, pshenmic_dpp_1.DataContractWASM.fromBytes(contract, true, pshenmic_dpp_1.PlatformVersionWASM.PLATFORM_V9)];
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataContractConfig, IdentifierLike } from '../types';
|
|
2
2
|
import { DataContractWASM, PlatformVersionWASM, StateTransitionWASM, TokenConfigurationWASM } from 'pshenmic-dpp';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool';
|
|
4
|
-
import { DataContractTransitionType } from './createStateTransition';
|
|
5
4
|
/**
|
|
6
5
|
* Collection of methods necessary to work with Data Contracts in the network,
|
|
7
6
|
* such as data contract creation or retrieval
|
|
@@ -41,10 +40,10 @@ export declare class DataContractsController {
|
|
|
41
40
|
* to make: create or update.
|
|
42
41
|
*
|
|
43
42
|
* @param dataContract {DataContractWASM} An instance of DataContractWASM to create or update
|
|
44
|
-
* @param type {
|
|
43
|
+
* @param type {string} type of identity state transition to do, must be 'create' or 'update'
|
|
45
44
|
* @param identityNonce {bigint} identity contract nonce
|
|
46
45
|
*
|
|
47
46
|
* @return {StateTransitionWASM}
|
|
48
47
|
*/
|
|
49
|
-
createStateTransition(dataContract: DataContractWASM, type:
|
|
48
|
+
createStateTransition(dataContract: DataContractWASM, type: 'create' | 'update', identityNonce: bigint): StateTransitionWASM;
|
|
50
49
|
}
|
|
@@ -90,7 +90,7 @@ var DataContractsController = /** @class */ (function () {
|
|
|
90
90
|
* to make: create or update.
|
|
91
91
|
*
|
|
92
92
|
* @param dataContract {DataContractWASM} An instance of DataContractWASM to create or update
|
|
93
|
-
* @param type {
|
|
93
|
+
* @param type {string} type of identity state transition to do, must be 'create' or 'update'
|
|
94
94
|
* @param identityNonce {bigint} identity contract nonce
|
|
95
95
|
*
|
|
96
96
|
* @return {StateTransitionWASM}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DocumentWASM } from 'pshenmic-dpp';
|
|
2
2
|
import { IdentifierLike } from '../types';
|
|
3
|
-
export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint, documentId?: IdentifierLike):
|
|
3
|
+
export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint, documentId?: IdentifierLike): DocumentWASM;
|
package/src/documents/create.js
CHANGED
|
@@ -1,47 +1,7 @@
|
|
|
1
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 = 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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.default = createDocument;
|
|
40
4
|
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
41
5
|
function createDocument(dataContractId, documentType, data, owner, revision, documentId) {
|
|
42
|
-
return
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
return [2 /*return*/, new pshenmic_dpp_1.DocumentWASM(data, documentType, revision !== null && revision !== void 0 ? revision : BigInt(1), dataContractId, owner, documentId)];
|
|
45
|
-
});
|
|
46
|
-
});
|
|
6
|
+
return new pshenmic_dpp_1.DocumentWASM(data, documentType, revision !== null && revision !== void 0 ? revision : BigInt(1), dataContractId, owner, documentId);
|
|
47
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
2
|
import { CreateStateTransitionDocumentBatchParams } from '../types';
|
|
3
|
-
export default function createStateTransition(document: DocumentWASM, type:
|
|
3
|
+
export default function createStateTransition(document: DocumentWASM, type: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', identityContractNonce: bigint, params?: CreateStateTransitionDocumentBatchParams | undefined): StateTransitionWASM;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.default = createStateTransition;
|
|
5
4
|
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
6
|
-
var documentBatchTypesMap =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
var documentBatchTypesMap = {
|
|
6
|
+
create: pshenmic_dpp_1.DocumentCreateTransitionWASM,
|
|
7
|
+
replace: pshenmic_dpp_1.DocumentReplaceTransitionWASM,
|
|
8
|
+
delete: pshenmic_dpp_1.DocumentDeleteTransitionWASM,
|
|
9
|
+
updatePrice: pshenmic_dpp_1.DocumentUpdatePriceTransitionWASM,
|
|
10
|
+
transfer: pshenmic_dpp_1.DocumentTransferTransitionWASM,
|
|
11
|
+
purchase: pshenmic_dpp_1.DocumentPurchaseTransitionWASM
|
|
12
|
+
};
|
|
14
13
|
function createStateTransition(document, type, identityContractNonce, params) {
|
|
15
14
|
var _a;
|
|
16
15
|
var TransitionClass = documentBatchTypesMap[type];
|
|
17
16
|
if (TransitionClass == null) {
|
|
18
|
-
throw new Error("Unknown batch type: ".concat(type));
|
|
17
|
+
throw new Error("Unknown batch type: ".concat(type, ". Should be 'create' or 'replace' or 'delete' or 'updatePrice' or 'transfer' or 'purchase'"));
|
|
19
18
|
}
|
|
20
19
|
// @ts-expect-error
|
|
21
20
|
var documentTransition = new TransitionClass(document, identityContractNonce, (_a = params === null || params === void 0 ? void 0 : params.recipient) !== null && _a !== void 0 ? _a : params === null || params === void 0 ? void 0 : params.price).toDocumentTransition();
|
package/src/documents/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreateStateTransitionDocumentBatchParams, IdentifierLike } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { DocumentWASM, IdentifierWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
3
3
|
import GRPCConnectionPool from '../grpcConnectionPool';
|
|
4
4
|
/**
|
|
5
5
|
* Collection of methods to work with documents like creation, querying or preparing a transition action
|
|
@@ -45,9 +45,9 @@ export declare class DocumentsController {
|
|
|
45
45
|
* 6) Purchase - purchase a document from identity (if price was set)
|
|
46
46
|
*
|
|
47
47
|
* @param document {DocumentWASM} Instance of the document to make transition with
|
|
48
|
-
* @param batchType {
|
|
48
|
+
* @param batchType {string} Type of the document transition, must be a one of ('create' | 'replace' | 'delete' |'updatePrice' |'transfer' | 'purchase')
|
|
49
49
|
* @param identityContractNonce {bigint} Identity contract nonce
|
|
50
50
|
* @param params {CreateStateTransitionDocumentBatchParams=} Additional params, required for Transfer, SetPrice, Purchase transitions
|
|
51
51
|
*/
|
|
52
|
-
createStateTransition(document: DocumentWASM, batchType:
|
|
52
|
+
createStateTransition(document: DocumentWASM, batchType: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', identityContractNonce: bigint, params?: CreateStateTransitionDocumentBatchParams): StateTransitionWASM;
|
|
53
53
|
}
|