@coopenomics/sdk 2.2.4 → 2.2.6-alpha.0
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/dist/index.cjs +468 -254
- package/dist/index.d.cts +779 -616
- package/dist/index.d.mts +779 -616
- package/dist/index.d.ts +779 -616
- package/dist/index.mjs +468 -254
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -11,17 +11,17 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
const WebSocket__default = /*#__PURE__*/_interopDefaultCompat(WebSocket);
|
|
13
13
|
|
|
14
|
-
var __defProp$
|
|
15
|
-
var __defNormalProp$
|
|
16
|
-
var __publicField$
|
|
17
|
-
__defNormalProp$
|
|
14
|
+
var __defProp$4 = Object.defineProperty;
|
|
15
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __publicField$4 = (obj, key, value) => {
|
|
17
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
18
18
|
return value;
|
|
19
19
|
};
|
|
20
20
|
class Account {
|
|
21
21
|
constructor() {
|
|
22
|
-
__publicField$
|
|
23
|
-
__publicField$
|
|
24
|
-
__publicField$
|
|
22
|
+
__publicField$4(this, "username");
|
|
23
|
+
__publicField$4(this, "private_key");
|
|
24
|
+
__publicField$4(this, "public_key");
|
|
25
25
|
this.username = Account.generateUsername();
|
|
26
26
|
const keys = Account.generateKeys();
|
|
27
27
|
this.private_key = keys.private_key;
|
|
@@ -54,52 +54,209 @@ class Account {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
var __defProp$
|
|
58
|
-
var __defNormalProp$
|
|
59
|
-
var __publicField$
|
|
60
|
-
__defNormalProp$
|
|
57
|
+
var __defProp$3 = Object.defineProperty;
|
|
58
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
59
|
+
var __publicField$3 = (obj, key, value) => {
|
|
60
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
63
|
+
class Blockchain {
|
|
64
|
+
/**
|
|
65
|
+
* Конструктор класса Blockchain.
|
|
66
|
+
* @param config Конфигурация блокчейна, включающая URL цепочки и идентификатор цепочки.
|
|
67
|
+
*/
|
|
68
|
+
constructor(config) {
|
|
69
|
+
this.config = config;
|
|
70
|
+
__publicField$3(this, "apiClient");
|
|
71
|
+
__publicField$3(this, "contractKit");
|
|
72
|
+
__publicField$3(this, "session");
|
|
73
|
+
this.apiClient = new antelope.APIClient({ url: config.chain_url });
|
|
74
|
+
this.contractKit = new contract.ContractKit({ client: this.apiClient });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Получение информации о блокчейне.
|
|
78
|
+
* @returns Объект с информацией о текущем состоянии блокчейна.
|
|
79
|
+
*/
|
|
80
|
+
async getInfo() {
|
|
81
|
+
return this.apiClient.v1.chain.get_info();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Устанавливает приватный ключ (WIF) для текущей сессии.
|
|
85
|
+
* @param username Имя пользователя (аккаунт).
|
|
86
|
+
* @param wif Приватный ключ в формате WIF.
|
|
87
|
+
* @param permission Тип разрешения, который используется для подписания транзакции (по умолчанию = 'active')
|
|
88
|
+
* @returns Текущий экземпляр Blockchain для цепочного вызова.
|
|
89
|
+
*/
|
|
90
|
+
setWif(username, wif, permission = "active") {
|
|
91
|
+
this.session = new session.Session({
|
|
92
|
+
actor: username,
|
|
93
|
+
permission,
|
|
94
|
+
chain: {
|
|
95
|
+
id: this.config.chain_id,
|
|
96
|
+
url: this.config.chain_url
|
|
97
|
+
},
|
|
98
|
+
walletPlugin: new walletPluginPrivatekey.WalletPluginPrivateKey(antelope.PrivateKey.fromString(wif))
|
|
99
|
+
});
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Выполнение транзакции с передачей одного или нескольких действий.
|
|
104
|
+
* @param actionOrActions Действие или массив действий для выполнения.
|
|
105
|
+
* @param broadcast Если true, транзакция будет отправлена в сеть.
|
|
106
|
+
* @returns Результат выполнения транзакции.
|
|
107
|
+
* @throws Ошибка, если сессия не инициализирована.
|
|
108
|
+
*/
|
|
109
|
+
async transact(actionOrActions, broadcast = true) {
|
|
110
|
+
if (!this.session)
|
|
111
|
+
throw new Error("\u0421\u0435\u0441\u0441\u0438\u044F \u043D\u0435 \u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u0430.");
|
|
112
|
+
const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
|
|
113
|
+
return this.session.transact({ actions }, { broadcast });
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Получение всех строк таблицы смарт-контракта.
|
|
117
|
+
* @param code Код (аккаунт) контракта.
|
|
118
|
+
* @param scope Область видимости (scope) таблицы.
|
|
119
|
+
* @param tableName Имя таблицы.
|
|
120
|
+
* @returns Массив строк таблицы.
|
|
121
|
+
*/
|
|
122
|
+
async getAllRows(code, scope, tableName) {
|
|
123
|
+
const abi = await this.getAbi(code);
|
|
124
|
+
const table = this.createTable(code, tableName, abi);
|
|
125
|
+
const rows = await table.all({ scope });
|
|
126
|
+
return JSON.parse(JSON.stringify(rows));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Запрос строк таблицы с использованием фильтров.
|
|
130
|
+
* @param code Код (аккаунт) контракта.
|
|
131
|
+
* @param scope Область видимости (scope) таблицы.
|
|
132
|
+
* @param tableName Имя таблицы.
|
|
133
|
+
* @param options Опции для фильтрации данных.
|
|
134
|
+
* @returns Массив строк, соответствующих фильтрам.
|
|
135
|
+
*/
|
|
136
|
+
async query(code, scope, tableName, options = { indexPosition: "primary" }) {
|
|
137
|
+
const { indexPosition = "primary", from, to, maxRows } = options;
|
|
138
|
+
const abi = await this.getAbi(code);
|
|
139
|
+
const table = this.createTable(code, tableName, abi);
|
|
140
|
+
const rows = await table.query({
|
|
141
|
+
scope,
|
|
142
|
+
index_position: indexPosition,
|
|
143
|
+
from,
|
|
144
|
+
to,
|
|
145
|
+
maxRows
|
|
146
|
+
});
|
|
147
|
+
return JSON.parse(JSON.stringify(rows));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Получение одной строки таблицы по первичному ключу.
|
|
151
|
+
* @param code Код (аккаунт) контракта.
|
|
152
|
+
* @param scope Область видимости (scope) таблицы.
|
|
153
|
+
* @param tableName Имя таблицы.
|
|
154
|
+
* @param primaryKey Первичный ключ строки.
|
|
155
|
+
* @param indexPosition Индекс для поиска строки (по умолчанию 'primary').
|
|
156
|
+
* @returns Строка таблицы или null, если не найдена.
|
|
157
|
+
*/
|
|
158
|
+
async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
|
|
159
|
+
const abi = await this.getAbi(code);
|
|
160
|
+
const table = this.createTable(code, tableName, abi);
|
|
161
|
+
const row = await table.get(String(primaryKey), {
|
|
162
|
+
scope,
|
|
163
|
+
index_position: indexPosition
|
|
164
|
+
});
|
|
165
|
+
return row ? JSON.parse(JSON.stringify(row)) : null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Создает объект действия (Action) из ABI контракта.
|
|
169
|
+
* @param action Объект действия.
|
|
170
|
+
* @returns Объект Action.
|
|
171
|
+
*/
|
|
172
|
+
async formActionFromAbi(action) {
|
|
173
|
+
const abi = await this.getAbi(action.account);
|
|
174
|
+
return antelope.Action.from(action, abi);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Получение ABI контракта.
|
|
178
|
+
* @param account Код (аккаунт) контракта.
|
|
179
|
+
* @returns ABI контракта.
|
|
180
|
+
* @throws Ошибка, если ABI не найден.
|
|
181
|
+
*/
|
|
182
|
+
async getAbi(account) {
|
|
183
|
+
const { abi } = await this.apiClient.v1.chain.get_abi(account);
|
|
184
|
+
if (!abi)
|
|
185
|
+
throw new Error(`ABI \u0434\u043B\u044F \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 "${account}" \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D.`);
|
|
186
|
+
return abi;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Создает объект таблицы (Table) для работы с данными.
|
|
190
|
+
* @param code Код (аккаунт) контракта.
|
|
191
|
+
* @param tableName Имя таблицы.
|
|
192
|
+
* @param abi ABI контракта.
|
|
193
|
+
* @returns Объект Table.
|
|
194
|
+
*/
|
|
195
|
+
createTable(code, tableName, abi) {
|
|
196
|
+
return new contract.Table({
|
|
197
|
+
abi,
|
|
198
|
+
account: code,
|
|
199
|
+
name: tableName,
|
|
200
|
+
client: this.apiClient
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var __defProp$2 = Object.defineProperty;
|
|
206
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
207
|
+
var __publicField$2 = (obj, key, value) => {
|
|
208
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
61
209
|
return value;
|
|
62
210
|
};
|
|
63
211
|
class Canvas {
|
|
212
|
+
/**
|
|
213
|
+
* Создаёт экземпляр класса `Canvas` и подготавливает холст для рисования подписи.
|
|
214
|
+
*
|
|
215
|
+
* @param container - HTML-элемент, внутри которого создаётся `<canvas>`.
|
|
216
|
+
* @param opts - Настройки:
|
|
217
|
+
* - `lineWidth` - Толщина линии для рисования (по умолчанию 5).
|
|
218
|
+
* - `strokeStyle` - Цвет линии для рисования (по умолчанию чёрный, `#000`).
|
|
219
|
+
*/
|
|
64
220
|
constructor(container, opts = {}) {
|
|
65
221
|
this.container = container;
|
|
66
222
|
this.opts = opts;
|
|
67
|
-
__publicField$
|
|
68
|
-
__publicField$
|
|
69
|
-
__publicField$
|
|
70
|
-
__publicField$
|
|
71
|
-
__publicField$
|
|
72
|
-
__publicField$
|
|
223
|
+
__publicField$2(this, "canvas");
|
|
224
|
+
__publicField$2(this, "ctx");
|
|
225
|
+
__publicField$2(this, "drawing", false);
|
|
226
|
+
__publicField$2(this, "lastX", 0);
|
|
227
|
+
__publicField$2(this, "lastY", 0);
|
|
228
|
+
__publicField$2(this, "onMouseDown", (e) => {
|
|
73
229
|
e.preventDefault();
|
|
74
230
|
this.drawing = true;
|
|
75
231
|
const rect = this.canvas.getBoundingClientRect();
|
|
76
232
|
this.lastX = e.clientX - rect.left;
|
|
77
233
|
this.lastY = e.clientY - rect.top;
|
|
78
234
|
});
|
|
79
|
-
__publicField$
|
|
235
|
+
__publicField$2(this, "onMouseMove", (e) => {
|
|
80
236
|
if (!this.drawing)
|
|
81
237
|
return;
|
|
82
238
|
e.preventDefault();
|
|
83
239
|
this.drawLine(e.clientX, e.clientY);
|
|
84
240
|
});
|
|
85
|
-
__publicField$
|
|
241
|
+
__publicField$2(this, "onMouseUp", () => {
|
|
86
242
|
this.drawing = false;
|
|
87
243
|
});
|
|
88
|
-
__publicField$
|
|
244
|
+
__publicField$2(this, "onTouchStart", (e) => {
|
|
89
245
|
e.preventDefault();
|
|
90
246
|
this.drawing = true;
|
|
91
247
|
const rect = this.canvas.getBoundingClientRect();
|
|
92
|
-
|
|
93
|
-
this.
|
|
248
|
+
const t = e.touches[0];
|
|
249
|
+
this.lastX = t.clientX - rect.left;
|
|
250
|
+
this.lastY = t.clientY - rect.top;
|
|
94
251
|
});
|
|
95
|
-
__publicField$
|
|
252
|
+
__publicField$2(this, "onTouchMove", (e) => {
|
|
96
253
|
if (!this.drawing)
|
|
97
254
|
return;
|
|
98
255
|
e.preventDefault();
|
|
99
256
|
const t = e.touches[0];
|
|
100
257
|
this.drawLine(t.clientX, t.clientY);
|
|
101
258
|
});
|
|
102
|
-
__publicField$
|
|
259
|
+
__publicField$2(this, "onTouchEnd", () => {
|
|
103
260
|
this.drawing = false;
|
|
104
261
|
});
|
|
105
262
|
this.canvas = document.createElement("canvas");
|
|
@@ -109,7 +266,7 @@ class Canvas {
|
|
|
109
266
|
container.appendChild(this.canvas);
|
|
110
267
|
const ctx = this.canvas.getContext("2d");
|
|
111
268
|
if (!ctx) {
|
|
112
|
-
throw new Error("Canvas
|
|
269
|
+
throw new Error("Canvas \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F");
|
|
113
270
|
}
|
|
114
271
|
this.ctx = ctx;
|
|
115
272
|
this.ctx.lineWidth = this.opts.lineWidth ?? 5;
|
|
@@ -119,19 +276,21 @@ class Canvas {
|
|
|
119
276
|
this.initEvents();
|
|
120
277
|
}
|
|
121
278
|
/**
|
|
122
|
-
*
|
|
279
|
+
* Очищает холст.
|
|
123
280
|
*/
|
|
124
281
|
clearCanvas() {
|
|
125
282
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
126
283
|
}
|
|
127
284
|
/**
|
|
128
|
-
*
|
|
285
|
+
* Возвращает содержимое холста (подпись) в формате base64 (PNG).
|
|
286
|
+
*
|
|
287
|
+
* @returns Подпись в формате base64.
|
|
129
288
|
*/
|
|
130
289
|
getSignature() {
|
|
131
290
|
return this.canvas.toDataURL("image/png");
|
|
132
291
|
}
|
|
133
292
|
/**
|
|
134
|
-
*
|
|
293
|
+
* Снимает все обработчики событий и очищает ресурсы.
|
|
135
294
|
*/
|
|
136
295
|
destroy() {
|
|
137
296
|
this.canvas.removeEventListener("mousedown", this.onMouseDown);
|
|
@@ -142,6 +301,9 @@ class Canvas {
|
|
|
142
301
|
this.canvas.removeEventListener("touchend", this.onTouchEnd);
|
|
143
302
|
}
|
|
144
303
|
// Внутренние методы
|
|
304
|
+
/**
|
|
305
|
+
* Навешивает обработчики событий мыши и тач-устройств.
|
|
306
|
+
*/
|
|
145
307
|
initEvents() {
|
|
146
308
|
this.canvas.addEventListener("mousedown", this.onMouseDown);
|
|
147
309
|
this.canvas.addEventListener("mousemove", this.onMouseMove);
|
|
@@ -163,101 +325,70 @@ class Canvas {
|
|
|
163
325
|
}
|
|
164
326
|
}
|
|
165
327
|
|
|
166
|
-
var __defProp = Object.defineProperty;
|
|
167
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
168
|
-
var __publicField = (obj, key, value) => {
|
|
169
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
328
|
+
var __defProp$1 = Object.defineProperty;
|
|
329
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
330
|
+
var __publicField$1 = (obj, key, value) => {
|
|
331
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
170
332
|
return value;
|
|
171
333
|
};
|
|
172
|
-
class
|
|
173
|
-
constructor(config) {
|
|
174
|
-
this.config = config;
|
|
175
|
-
__publicField(this, "apiClient");
|
|
176
|
-
__publicField(this, "contractKit");
|
|
177
|
-
__publicField(this, "session");
|
|
178
|
-
this.apiClient = new antelope.APIClient({ url: config.chain_url });
|
|
179
|
-
this.contractKit = new contract.ContractKit({ client: this.apiClient });
|
|
180
|
-
}
|
|
181
|
-
async getInfo() {
|
|
182
|
-
return this.apiClient.v1.chain.get_info();
|
|
183
|
-
}
|
|
334
|
+
class Document {
|
|
184
335
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @param
|
|
187
|
-
* @param wif - приватный ключ
|
|
188
|
-
* @returns
|
|
336
|
+
* Инициализация класса Document с WIF-ключом.
|
|
337
|
+
* @param wifKey WIF-ключ, используемый для подписи.
|
|
189
338
|
*/
|
|
190
|
-
|
|
191
|
-
this
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
chain: {
|
|
195
|
-
id: this.config.chain_id,
|
|
196
|
-
url: this.config.chain_url
|
|
197
|
-
},
|
|
198
|
-
walletPlugin: new walletPluginPrivatekey.WalletPluginPrivateKey(antelope.PrivateKey.fromString(wif))
|
|
199
|
-
});
|
|
200
|
-
return this;
|
|
339
|
+
constructor(wifKey) {
|
|
340
|
+
__publicField$1(this, "wif");
|
|
341
|
+
if (wifKey)
|
|
342
|
+
this.wif = antelope.PrivateKey.fromString(wifKey);
|
|
201
343
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
async getAllRows(code, scope, tableName) {
|
|
209
|
-
const abi = await this.getAbi(code);
|
|
210
|
-
const table = this.createTable(code, tableName, abi);
|
|
211
|
-
const rows = await table.all({ scope });
|
|
212
|
-
return JSON.parse(JSON.stringify(rows));
|
|
213
|
-
}
|
|
214
|
-
async query(code, scope, tableName, options = { indexPosition: "primary" }) {
|
|
215
|
-
const { indexPosition = "primary", from, to, maxRows } = options;
|
|
216
|
-
const abi = await this.getAbi(code);
|
|
217
|
-
const table = this.createTable(code, tableName, abi);
|
|
218
|
-
const rows = await table.query({
|
|
219
|
-
scope,
|
|
220
|
-
index_position: indexPosition,
|
|
221
|
-
from,
|
|
222
|
-
to,
|
|
223
|
-
maxRows
|
|
224
|
-
});
|
|
225
|
-
return JSON.parse(JSON.stringify(rows));
|
|
226
|
-
}
|
|
227
|
-
async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
|
|
228
|
-
const abi = await this.getAbi(code);
|
|
229
|
-
const table = this.createTable(code, tableName, abi);
|
|
230
|
-
const row = await table.get(String(primaryKey), {
|
|
231
|
-
scope,
|
|
232
|
-
index_position: indexPosition
|
|
233
|
-
});
|
|
234
|
-
return row ? JSON.parse(JSON.stringify(row)) : null;
|
|
235
|
-
}
|
|
236
|
-
async formActionFromAbi(action) {
|
|
237
|
-
const abi = await this.getAbi(action.account);
|
|
238
|
-
return antelope.Action.from(action, abi);
|
|
344
|
+
/**
|
|
345
|
+
* Замена текущего WIF-ключа на новый.
|
|
346
|
+
* @param wifKey Новый WIF-ключ.
|
|
347
|
+
*/
|
|
348
|
+
setWif(wifKey) {
|
|
349
|
+
this.wif = antelope.PrivateKey.fromString(wifKey);
|
|
239
350
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
351
|
+
/**
|
|
352
|
+
* Подписывает документ и возвращает его в формате ISignedDocument.
|
|
353
|
+
* @param document Сгенерированный документ для подписи.
|
|
354
|
+
* @returns Подписанный документ.
|
|
355
|
+
*/
|
|
356
|
+
async signDocument(document) {
|
|
357
|
+
const digitalSignature = this.signDigest(document.hash);
|
|
358
|
+
return {
|
|
359
|
+
hash: document.hash,
|
|
360
|
+
public_key: digitalSignature.public_key,
|
|
361
|
+
signature: digitalSignature.signature,
|
|
362
|
+
meta: document.meta
|
|
363
|
+
};
|
|
245
364
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Подписывает хэш (digest) документа и проверяет подпись.
|
|
367
|
+
* @param digest Хэш документа для подписи.
|
|
368
|
+
* @returns Детали подписи.
|
|
369
|
+
*/
|
|
370
|
+
signDigest(digest) {
|
|
371
|
+
if (!this.wif)
|
|
372
|
+
throw new Error(`\u041A\u043B\u044E\u0447 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D, \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u0432\u044B\u0437\u043E\u0432 \u043C\u0435\u0442\u043E\u0434\u0430 setWif \u043F\u0435\u0440\u0435\u0434 \u043F\u043E\u0434\u043F\u0438\u0441\u044C\u044E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430`);
|
|
373
|
+
const signed = this.wif.signDigest(digest);
|
|
374
|
+
const verified = signed.verifyDigest(digest, this.wif.toPublic());
|
|
375
|
+
if (!verified) {
|
|
376
|
+
throw new Error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u043F\u043E\u0434\u043F\u0438\u0441\u0438");
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
message: digest,
|
|
380
|
+
signature: signed.toString(),
|
|
381
|
+
public_key: this.wif.toPublic().toString()
|
|
382
|
+
};
|
|
253
383
|
}
|
|
254
384
|
}
|
|
255
385
|
|
|
256
386
|
const Classes = {
|
|
257
387
|
__proto__: null,
|
|
258
388
|
Account: Account,
|
|
389
|
+
Blockchain: Blockchain,
|
|
259
390
|
Canvas: Canvas,
|
|
260
|
-
|
|
391
|
+
Document: Document
|
|
261
392
|
};
|
|
262
393
|
|
|
263
394
|
const AllTypesProps = {
|
|
@@ -297,7 +428,6 @@ const AllTypesProps = {
|
|
|
297
428
|
},
|
|
298
429
|
CreateProjectFreeDecisionInput: {},
|
|
299
430
|
DateTime: `scalar.DateTime`,
|
|
300
|
-
DeleteAccountInput: {},
|
|
301
431
|
DeleteBranchInput: {},
|
|
302
432
|
DeletePaymentMethodInput: {},
|
|
303
433
|
DeleteTrustedAccountInput: {},
|
|
@@ -333,7 +463,6 @@ const AllTypesProps = {
|
|
|
333
463
|
soviet: "SovietMemberInput"
|
|
334
464
|
},
|
|
335
465
|
JSON: `scalar.JSON`,
|
|
336
|
-
LangType: "enum",
|
|
337
466
|
LoginInput: {},
|
|
338
467
|
LogoutInput: {},
|
|
339
468
|
MetaDocumentInput: {},
|
|
@@ -359,9 +488,6 @@ const AllTypesProps = {
|
|
|
359
488
|
createProjectOfFreeDecision: {
|
|
360
489
|
data: "CreateProjectFreeDecisionInput"
|
|
361
490
|
},
|
|
362
|
-
deleteAccount: {
|
|
363
|
-
data: "DeleteAccountInput"
|
|
364
|
-
},
|
|
365
491
|
deleteBranch: {
|
|
366
492
|
data: "DeleteBranchInput"
|
|
367
493
|
},
|
|
@@ -517,7 +643,6 @@ const AllTypesProps = {
|
|
|
517
643
|
entrepreneur_data: "CreateEntrepreneurDataInput",
|
|
518
644
|
individual_data: "CreateIndividualDataInput",
|
|
519
645
|
organization_data: "CreateOrganizationDataInput",
|
|
520
|
-
role: "RegisterRole",
|
|
521
646
|
type: "AccountType"
|
|
522
647
|
},
|
|
523
648
|
RegisterParticipantInput: {
|
|
@@ -891,7 +1016,7 @@ const ReturnTypes = {
|
|
|
891
1016
|
created_at: "String",
|
|
892
1017
|
decision_id: "Float",
|
|
893
1018
|
generator: "String",
|
|
894
|
-
lang: "
|
|
1019
|
+
lang: "String",
|
|
895
1020
|
links: "String",
|
|
896
1021
|
project_id: "String",
|
|
897
1022
|
registry_id: "Int",
|
|
@@ -928,7 +1053,7 @@ const ReturnTypes = {
|
|
|
928
1053
|
coopname: "String",
|
|
929
1054
|
created_at: "String",
|
|
930
1055
|
generator: "String",
|
|
931
|
-
lang: "
|
|
1056
|
+
lang: "String",
|
|
932
1057
|
links: "String",
|
|
933
1058
|
registry_id: "Int",
|
|
934
1059
|
timezone: "String",
|
|
@@ -958,7 +1083,6 @@ const ReturnTypes = {
|
|
|
958
1083
|
createDepositPayment: "Payment",
|
|
959
1084
|
createInitialPayment: "Payment",
|
|
960
1085
|
createProjectOfFreeDecision: "CreatedProjectFreeDecision",
|
|
961
|
-
deleteAccount: "Boolean",
|
|
962
1086
|
deleteBranch: "Boolean",
|
|
963
1087
|
deletePaymentMethod: "Boolean",
|
|
964
1088
|
deleteTrustedAccount: "Branch",
|
|
@@ -1036,7 +1160,7 @@ const ReturnTypes = {
|
|
|
1036
1160
|
created_at: "String",
|
|
1037
1161
|
decision_id: "Float",
|
|
1038
1162
|
generator: "String",
|
|
1039
|
-
lang: "
|
|
1163
|
+
lang: "String",
|
|
1040
1164
|
links: "String",
|
|
1041
1165
|
registry_id: "Int",
|
|
1042
1166
|
timezone: "String",
|
|
@@ -1056,7 +1180,7 @@ const ReturnTypes = {
|
|
|
1056
1180
|
coopname: "String",
|
|
1057
1181
|
created_at: "String",
|
|
1058
1182
|
generator: "String",
|
|
1059
|
-
lang: "
|
|
1183
|
+
lang: "String",
|
|
1060
1184
|
links: "String",
|
|
1061
1185
|
registry_id: "Int",
|
|
1062
1186
|
timezone: "String",
|
|
@@ -1144,7 +1268,7 @@ const ReturnTypes = {
|
|
|
1144
1268
|
coopname: "String",
|
|
1145
1269
|
created_at: "String",
|
|
1146
1270
|
generator: "String",
|
|
1147
|
-
lang: "
|
|
1271
|
+
lang: "String",
|
|
1148
1272
|
links: "String",
|
|
1149
1273
|
project_id: "String",
|
|
1150
1274
|
registry_id: "Int",
|
|
@@ -1214,7 +1338,7 @@ const ReturnTypes = {
|
|
|
1214
1338
|
coopname: "String",
|
|
1215
1339
|
created_at: "String",
|
|
1216
1340
|
generator: "String",
|
|
1217
|
-
lang: "
|
|
1341
|
+
lang: "String",
|
|
1218
1342
|
links: "String",
|
|
1219
1343
|
registry_id: "Int",
|
|
1220
1344
|
timezone: "String",
|
|
@@ -1829,10 +1953,6 @@ var Country = /* @__PURE__ */ ((Country2) => {
|
|
|
1829
1953
|
Country2["Russia"] = "Russia";
|
|
1830
1954
|
return Country2;
|
|
1831
1955
|
})(Country || {});
|
|
1832
|
-
var LangType = /* @__PURE__ */ ((LangType2) => {
|
|
1833
|
-
LangType2["ru"] = "ru";
|
|
1834
|
-
return LangType2;
|
|
1835
|
-
})(LangType || {});
|
|
1836
1956
|
var OrganizationType = /* @__PURE__ */ ((OrganizationType2) => {
|
|
1837
1957
|
OrganizationType2["AO"] = "AO";
|
|
1838
1958
|
OrganizationType2["COOP"] = "COOP";
|
|
@@ -1873,7 +1993,7 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
|
1873
1993
|
return UserStatus2;
|
|
1874
1994
|
})(UserStatus || {});
|
|
1875
1995
|
|
|
1876
|
-
const index$
|
|
1996
|
+
const index$o = {
|
|
1877
1997
|
__proto__: null,
|
|
1878
1998
|
$: $,
|
|
1879
1999
|
AccountType: AccountType,
|
|
@@ -1886,7 +2006,6 @@ const index$k = {
|
|
|
1886
2006
|
HOST: HOST,
|
|
1887
2007
|
InternalArgsBuilt: InternalArgsBuilt,
|
|
1888
2008
|
InternalsBuildQuery: InternalsBuildQuery,
|
|
1889
|
-
LangType: LangType,
|
|
1890
2009
|
OrganizationType: OrganizationType,
|
|
1891
2010
|
PaymentStatus: PaymentStatus,
|
|
1892
2011
|
PrepareScalarPaths: PrepareScalarPaths,
|
|
@@ -1964,7 +2083,7 @@ const updateExtension = {
|
|
|
1964
2083
|
name: name$K
|
|
1965
2084
|
};
|
|
1966
2085
|
|
|
1967
|
-
const index$
|
|
2086
|
+
const index$n = {
|
|
1968
2087
|
__proto__: null,
|
|
1969
2088
|
InstallExtension: installExtension,
|
|
1970
2089
|
UninstallExtension: uninstallExtension,
|
|
@@ -2034,7 +2153,7 @@ const updateBankAccount = {
|
|
|
2034
2153
|
name: name$H
|
|
2035
2154
|
};
|
|
2036
2155
|
|
|
2037
|
-
const index$
|
|
2156
|
+
const index$m = {
|
|
2038
2157
|
__proto__: null,
|
|
2039
2158
|
CreateBankAccount: createBankAccount,
|
|
2040
2159
|
DeletePaymentMethod: deletePaymentMethod,
|
|
@@ -2600,7 +2719,7 @@ const selectBranch = {
|
|
|
2600
2719
|
|
|
2601
2720
|
const name$A = "generateSelectBranchDocument";
|
|
2602
2721
|
const mutation$q = Selector("Mutation")({
|
|
2603
|
-
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2722
|
+
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, generateSelectBranchDocumentSelector]
|
|
2604
2723
|
});
|
|
2605
2724
|
|
|
2606
2725
|
const generateSelectBranchDocument = {
|
|
@@ -2609,7 +2728,7 @@ const generateSelectBranchDocument = {
|
|
|
2609
2728
|
name: name$A
|
|
2610
2729
|
};
|
|
2611
2730
|
|
|
2612
|
-
const index$
|
|
2731
|
+
const index$l = {
|
|
2613
2732
|
__proto__: null,
|
|
2614
2733
|
AddTrustedAccount: addTrustedAccount,
|
|
2615
2734
|
CreateBranch: createBranch,
|
|
@@ -2632,7 +2751,7 @@ const projectFreeDecisionDocumentSelector = Selector("ProjectFreeDecisionDocumen
|
|
|
2632
2751
|
|
|
2633
2752
|
const name$z = "generateProjectOfFreeDecision";
|
|
2634
2753
|
const mutation$p = Selector("Mutation")({
|
|
2635
|
-
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2754
|
+
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, projectFreeDecisionDocumentSelector]
|
|
2636
2755
|
});
|
|
2637
2756
|
|
|
2638
2757
|
const generateProjectOfFreeDecisionDocument = {
|
|
@@ -2662,7 +2781,7 @@ const createdProjectFreeDecisionSelector = Selector("CreatedProjectFreeDecision"
|
|
|
2662
2781
|
|
|
2663
2782
|
const name$y = "generateFreeDecision";
|
|
2664
2783
|
const mutation$o = Selector("Mutation")({
|
|
2665
|
-
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2784
|
+
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, freeDecisionDocumentSelector]
|
|
2666
2785
|
});
|
|
2667
2786
|
|
|
2668
2787
|
const generateFreeDecision = {
|
|
@@ -2693,7 +2812,7 @@ const createProjectOfFreeDecision = {
|
|
|
2693
2812
|
name: name$w
|
|
2694
2813
|
};
|
|
2695
2814
|
|
|
2696
|
-
const index$
|
|
2815
|
+
const index$k = {
|
|
2697
2816
|
__proto__: null,
|
|
2698
2817
|
CreateProjectOfFreeDecision: createProjectOfFreeDecision,
|
|
2699
2818
|
GenerateFreeDecision: generateFreeDecision,
|
|
@@ -2701,17 +2820,6 @@ const index$g = {
|
|
|
2701
2820
|
PublishProjectOfFreeDecision: publishProjectOfFreeDecision
|
|
2702
2821
|
};
|
|
2703
2822
|
|
|
2704
|
-
const name$v = "updateAccount";
|
|
2705
|
-
const mutation$l = Selector("Mutation")({
|
|
2706
|
-
[name$v]: [{ data: $("data", "UpdateAccountInput!") }, accountSelector]
|
|
2707
|
-
});
|
|
2708
|
-
|
|
2709
|
-
const updateAccount = {
|
|
2710
|
-
__proto__: null,
|
|
2711
|
-
mutation: mutation$l,
|
|
2712
|
-
name: name$v
|
|
2713
|
-
};
|
|
2714
|
-
|
|
2715
2823
|
const rawTokenSelector = {
|
|
2716
2824
|
expires: true,
|
|
2717
2825
|
token: true
|
|
@@ -2728,12 +2836,23 @@ const registeredAccountSelector = Selector("RegisteredAccount")(
|
|
|
2728
2836
|
rawRegisteredAccountSelector
|
|
2729
2837
|
);
|
|
2730
2838
|
|
|
2731
|
-
const name$
|
|
2732
|
-
const mutation$
|
|
2733
|
-
[name$
|
|
2839
|
+
const name$v = "registerAccount";
|
|
2840
|
+
const mutation$l = Selector("Mutation")({
|
|
2841
|
+
[name$v]: [{ data: $("data", "RegisterAccountInput!") }, registeredAccountSelector]
|
|
2734
2842
|
});
|
|
2735
2843
|
|
|
2736
2844
|
const registerAccount = {
|
|
2845
|
+
__proto__: null,
|
|
2846
|
+
mutation: mutation$l,
|
|
2847
|
+
name: name$v
|
|
2848
|
+
};
|
|
2849
|
+
|
|
2850
|
+
const name$u = "resetKey";
|
|
2851
|
+
const mutation$k = Selector("Mutation")({
|
|
2852
|
+
[name$u]: [{ data: $("data", "ResetKeyInput!") }, true]
|
|
2853
|
+
});
|
|
2854
|
+
|
|
2855
|
+
const resetKey = {
|
|
2737
2856
|
__proto__: null,
|
|
2738
2857
|
mutation: mutation$k,
|
|
2739
2858
|
name: name$u
|
|
@@ -2750,18 +2869,18 @@ const startResetKey = {
|
|
|
2750
2869
|
name: name$t
|
|
2751
2870
|
};
|
|
2752
2871
|
|
|
2753
|
-
const name$s = "
|
|
2872
|
+
const name$s = "updateAccount";
|
|
2754
2873
|
const mutation$i = Selector("Mutation")({
|
|
2755
|
-
[name$s]: [{ data: $("data", "
|
|
2874
|
+
[name$s]: [{ data: $("data", "UpdateAccountInput!") }, accountSelector]
|
|
2756
2875
|
});
|
|
2757
2876
|
|
|
2758
|
-
const
|
|
2877
|
+
const updateAccount = {
|
|
2759
2878
|
__proto__: null,
|
|
2760
2879
|
mutation: mutation$i,
|
|
2761
2880
|
name: name$s
|
|
2762
2881
|
};
|
|
2763
2882
|
|
|
2764
|
-
const index$
|
|
2883
|
+
const index$j = {
|
|
2765
2884
|
__proto__: null,
|
|
2766
2885
|
RegisterAccount: registerAccount,
|
|
2767
2886
|
ResetKey: resetKey,
|
|
@@ -2802,7 +2921,7 @@ const login = {
|
|
|
2802
2921
|
name: name$p
|
|
2803
2922
|
};
|
|
2804
2923
|
|
|
2805
|
-
const index$
|
|
2924
|
+
const index$i = {
|
|
2806
2925
|
__proto__: null,
|
|
2807
2926
|
Login: login,
|
|
2808
2927
|
Logout: logout,
|
|
@@ -2853,7 +2972,7 @@ const updateSystem = {
|
|
|
2853
2972
|
name: name$l
|
|
2854
2973
|
};
|
|
2855
2974
|
|
|
2856
|
-
const index$
|
|
2975
|
+
const index$h = {
|
|
2857
2976
|
__proto__: null,
|
|
2858
2977
|
InitSystem: initSystem,
|
|
2859
2978
|
InstallSystem: installSystem,
|
|
@@ -2863,7 +2982,7 @@ const index$d = {
|
|
|
2863
2982
|
|
|
2864
2983
|
const name$k = "generateParticipantApplication";
|
|
2865
2984
|
const mutation$a = Selector("Mutation")({
|
|
2866
|
-
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2985
|
+
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDocumentSelector]
|
|
2867
2986
|
});
|
|
2868
2987
|
|
|
2869
2988
|
const generateParticipantApplication = {
|
|
@@ -2874,7 +2993,7 @@ const generateParticipantApplication = {
|
|
|
2874
2993
|
|
|
2875
2994
|
const name$j = "generateParticipantApplicationDecision";
|
|
2876
2995
|
const mutation$9 = Selector("Mutation")({
|
|
2877
|
-
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2996
|
+
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDecisionDocumentSelector]
|
|
2878
2997
|
});
|
|
2879
2998
|
|
|
2880
2999
|
const generateParticipantApplicationDecision = {
|
|
@@ -2905,7 +3024,7 @@ const addParticipant = {
|
|
|
2905
3024
|
name: name$h
|
|
2906
3025
|
};
|
|
2907
3026
|
|
|
2908
|
-
const index$
|
|
3027
|
+
const index$g = {
|
|
2909
3028
|
__proto__: null,
|
|
2910
3029
|
AddParticipant: addParticipant,
|
|
2911
3030
|
GenerateParticipantApplication: generateParticipantApplication,
|
|
@@ -2971,7 +3090,7 @@ const setPaymentStatus = {
|
|
|
2971
3090
|
name: name$e
|
|
2972
3091
|
};
|
|
2973
3092
|
|
|
2974
|
-
const index$
|
|
3093
|
+
const index$f = {
|
|
2975
3094
|
__proto__: null,
|
|
2976
3095
|
CreateDepositPayment: createDeposit,
|
|
2977
3096
|
CreateInitialPayment: createInitial,
|
|
@@ -2980,7 +3099,7 @@ const index$b = {
|
|
|
2980
3099
|
|
|
2981
3100
|
const name$d = "generatePrivacyAgreement";
|
|
2982
3101
|
const mutation$3 = Selector("Mutation")({
|
|
2983
|
-
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3102
|
+
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2984
3103
|
});
|
|
2985
3104
|
|
|
2986
3105
|
const generatePrivacyAgreement = {
|
|
@@ -2991,7 +3110,7 @@ const generatePrivacyAgreement = {
|
|
|
2991
3110
|
|
|
2992
3111
|
const name$c = "generateSignatureAgreement";
|
|
2993
3112
|
const mutation$2 = Selector("Mutation")({
|
|
2994
|
-
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3113
|
+
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2995
3114
|
});
|
|
2996
3115
|
|
|
2997
3116
|
const generateSignatureAgreement = {
|
|
@@ -3002,7 +3121,7 @@ const generateSignatureAgreement = {
|
|
|
3002
3121
|
|
|
3003
3122
|
const name$b = "generateWalletAgreement";
|
|
3004
3123
|
const mutation$1 = Selector("Mutation")({
|
|
3005
|
-
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3124
|
+
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3006
3125
|
});
|
|
3007
3126
|
|
|
3008
3127
|
const generateWalletAgreement = {
|
|
@@ -3013,7 +3132,7 @@ const generateWalletAgreement = {
|
|
|
3013
3132
|
|
|
3014
3133
|
const name$a = "generateUserAgreement";
|
|
3015
3134
|
const mutation = Selector("Mutation")({
|
|
3016
|
-
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3135
|
+
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3017
3136
|
});
|
|
3018
3137
|
|
|
3019
3138
|
const generateUserAgreement = {
|
|
@@ -3022,7 +3141,7 @@ const generateUserAgreement = {
|
|
|
3022
3141
|
name: name$a
|
|
3023
3142
|
};
|
|
3024
3143
|
|
|
3025
|
-
const index$
|
|
3144
|
+
const index$e = {
|
|
3026
3145
|
__proto__: null,
|
|
3027
3146
|
GeneratePrivacyAgreement: generatePrivacyAgreement,
|
|
3028
3147
|
GenerateSignatureAgreement: generateSignatureAgreement,
|
|
@@ -3032,16 +3151,16 @@ const index$a = {
|
|
|
3032
3151
|
|
|
3033
3152
|
const Mutations = {
|
|
3034
3153
|
__proto__: null,
|
|
3035
|
-
Accounts: index$
|
|
3036
|
-
Agreements: index$
|
|
3037
|
-
Auth: index$
|
|
3038
|
-
Branches: index$
|
|
3039
|
-
Extensions: index$
|
|
3040
|
-
FreeDecisions: index$
|
|
3041
|
-
Participants: index$
|
|
3042
|
-
PaymentMethods: index$
|
|
3043
|
-
Payments: index$
|
|
3044
|
-
System: index$
|
|
3154
|
+
Accounts: index$j,
|
|
3155
|
+
Agreements: index$e,
|
|
3156
|
+
Auth: index$i,
|
|
3157
|
+
Branches: index$l,
|
|
3158
|
+
Extensions: index$n,
|
|
3159
|
+
FreeDecisions: index$k,
|
|
3160
|
+
Participants: index$g,
|
|
3161
|
+
PaymentMethods: index$m,
|
|
3162
|
+
Payments: index$f,
|
|
3163
|
+
System: index$h
|
|
3045
3164
|
};
|
|
3046
3165
|
|
|
3047
3166
|
const name$9 = "getExtensions";
|
|
@@ -3055,7 +3174,7 @@ const getExtensions = {
|
|
|
3055
3174
|
query: query$9
|
|
3056
3175
|
};
|
|
3057
3176
|
|
|
3058
|
-
const index$
|
|
3177
|
+
const index$d = {
|
|
3059
3178
|
__proto__: null,
|
|
3060
3179
|
GetExtensions: getExtensions
|
|
3061
3180
|
};
|
|
@@ -3080,7 +3199,7 @@ const getPaymentMethods = {
|
|
|
3080
3199
|
query: query$8
|
|
3081
3200
|
};
|
|
3082
3201
|
|
|
3083
|
-
const index$
|
|
3202
|
+
const index$c = {
|
|
3084
3203
|
__proto__: null,
|
|
3085
3204
|
GetPaymentMethods: getPaymentMethods
|
|
3086
3205
|
};
|
|
@@ -3096,7 +3215,7 @@ const getSystemInfo = {
|
|
|
3096
3215
|
query: query$7
|
|
3097
3216
|
};
|
|
3098
3217
|
|
|
3099
|
-
const index$
|
|
3218
|
+
const index$b = {
|
|
3100
3219
|
__proto__: null,
|
|
3101
3220
|
GetSystemInfo: getSystemInfo
|
|
3102
3221
|
};
|
|
@@ -3126,7 +3245,7 @@ const getAccounts = {
|
|
|
3126
3245
|
query: query$5
|
|
3127
3246
|
};
|
|
3128
3247
|
|
|
3129
|
-
const index$
|
|
3248
|
+
const index$a = {
|
|
3130
3249
|
__proto__: null,
|
|
3131
3250
|
GetAccount: getAccount,
|
|
3132
3251
|
GetAccounts: getAccounts
|
|
@@ -3154,7 +3273,7 @@ const getPublicBranches = {
|
|
|
3154
3273
|
query: query$3
|
|
3155
3274
|
};
|
|
3156
3275
|
|
|
3157
|
-
const index$
|
|
3276
|
+
const index$9 = {
|
|
3158
3277
|
__proto__: null,
|
|
3159
3278
|
GetBranches: getBranches,
|
|
3160
3279
|
GetPublicBranches: getPublicBranches
|
|
@@ -3171,7 +3290,7 @@ const getPayments = {
|
|
|
3171
3290
|
query: query$2
|
|
3172
3291
|
};
|
|
3173
3292
|
|
|
3174
|
-
const index$
|
|
3293
|
+
const index$8 = {
|
|
3175
3294
|
__proto__: null,
|
|
3176
3295
|
GetPayments: getPayments
|
|
3177
3296
|
};
|
|
@@ -3235,7 +3354,7 @@ const getDocuments = {
|
|
|
3235
3354
|
query: query$1
|
|
3236
3355
|
};
|
|
3237
3356
|
|
|
3238
|
-
const index$
|
|
3357
|
+
const index$7 = {
|
|
3239
3358
|
__proto__: null,
|
|
3240
3359
|
GetDocuments: getDocuments
|
|
3241
3360
|
};
|
|
@@ -3286,75 +3405,101 @@ const getAgenda = {
|
|
|
3286
3405
|
query: query
|
|
3287
3406
|
};
|
|
3288
3407
|
|
|
3289
|
-
const index$
|
|
3408
|
+
const index$6 = {
|
|
3290
3409
|
__proto__: null,
|
|
3291
3410
|
GetAgenda: getAgenda
|
|
3292
3411
|
};
|
|
3293
3412
|
|
|
3294
|
-
const index$
|
|
3413
|
+
const index$5 = {
|
|
3295
3414
|
__proto__: null,
|
|
3296
|
-
Accounts: index$
|
|
3297
|
-
Agenda: index$
|
|
3298
|
-
Branches: index$
|
|
3299
|
-
Documents: index$
|
|
3300
|
-
Extensions: index$
|
|
3301
|
-
PaymentMethods: index$
|
|
3302
|
-
Payments: index$
|
|
3303
|
-
System: index$
|
|
3415
|
+
Accounts: index$a,
|
|
3416
|
+
Agenda: index$6,
|
|
3417
|
+
Branches: index$9,
|
|
3418
|
+
Documents: index$7,
|
|
3419
|
+
Extensions: index$d,
|
|
3420
|
+
PaymentMethods: index$c,
|
|
3421
|
+
Payments: index$8,
|
|
3422
|
+
System: index$b
|
|
3304
3423
|
};
|
|
3305
3424
|
|
|
3306
|
-
const index = {
|
|
3425
|
+
const index$4 = {
|
|
3307
3426
|
__proto__: null
|
|
3308
3427
|
};
|
|
3309
3428
|
|
|
3429
|
+
const index$3 = {
|
|
3430
|
+
__proto__: null
|
|
3431
|
+
};
|
|
3432
|
+
|
|
3433
|
+
const index$2 = {
|
|
3434
|
+
__proto__: null
|
|
3435
|
+
};
|
|
3436
|
+
|
|
3437
|
+
const index$1 = {
|
|
3438
|
+
__proto__: null
|
|
3439
|
+
};
|
|
3440
|
+
|
|
3441
|
+
const index = {
|
|
3442
|
+
__proto__: null,
|
|
3443
|
+
Blockchain: index$4,
|
|
3444
|
+
Client: index$3,
|
|
3445
|
+
Controller: index$2,
|
|
3446
|
+
Document: index$1
|
|
3447
|
+
};
|
|
3448
|
+
|
|
3449
|
+
var __defProp = Object.defineProperty;
|
|
3450
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3451
|
+
var __publicField = (obj, key, value) => {
|
|
3452
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3453
|
+
return value;
|
|
3454
|
+
};
|
|
3310
3455
|
if (typeof globalThis.WebSocket === "undefined") {
|
|
3311
3456
|
globalThis.WebSocket = WebSocket__default;
|
|
3312
3457
|
}
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3458
|
+
const _Client = class _Client {
|
|
3459
|
+
constructor(options) {
|
|
3460
|
+
this.options = options;
|
|
3461
|
+
__publicField(this, "currentHeaders", {});
|
|
3462
|
+
__publicField(this, "blockchain");
|
|
3463
|
+
__publicField(this, "document");
|
|
3464
|
+
__publicField(this, "thunder");
|
|
3465
|
+
this.currentHeaders = options.headers || {};
|
|
3466
|
+
this.thunder = _Client.createThunder(options.api_url);
|
|
3467
|
+
this.blockchain = new Blockchain(options);
|
|
3468
|
+
this.document = new Document(options.wif);
|
|
3469
|
+
if (options.wif && options.username) {
|
|
3470
|
+
this.blockchain.setWif(options.username, options.wif);
|
|
3471
|
+
this.document.setWif(options.wif);
|
|
3472
|
+
} else if (options.wif && !options.username || !options.wif && options.username) {
|
|
3473
|
+
throw new Error("wif \u0438 username \u0434\u043E\u043B\u0436\u043D\u044B \u0431\u044B\u0442\u044C \u0443\u043A\u0430\u0437\u0430\u043D\u044B \u043E\u0434\u043D\u043E\u0432\u0440\u0435\u043C\u0435\u043D\u043D\u043E");
|
|
3474
|
+
}
|
|
3320
3475
|
}
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
"Content-Type": "application/json",
|
|
3329
|
-
...currentHeaders
|
|
3330
|
-
// Используем текущие заголовки, включая Authorization
|
|
3331
|
-
}
|
|
3332
|
-
});
|
|
3333
|
-
if (!response.ok) {
|
|
3334
|
-
return new Promise((resolve, reject) => {
|
|
3335
|
-
response.text().then((text) => {
|
|
3336
|
-
try {
|
|
3337
|
-
reject(JSON.parse(text));
|
|
3338
|
-
} catch (err) {
|
|
3339
|
-
reject(text);
|
|
3340
|
-
}
|
|
3341
|
-
}).catch(reject);
|
|
3342
|
-
});
|
|
3476
|
+
/**
|
|
3477
|
+
* Инициализация клиента с заданными опциями.
|
|
3478
|
+
* @param options Параметры соединения.
|
|
3479
|
+
*/
|
|
3480
|
+
static create(options) {
|
|
3481
|
+
if (!this.instance) {
|
|
3482
|
+
this.instance = new _Client(options);
|
|
3343
3483
|
}
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3484
|
+
return this.getInstance();
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Возвращает текущий экземпляр клиента.
|
|
3488
|
+
*/
|
|
3489
|
+
static getInstance() {
|
|
3490
|
+
if (!this.instance) {
|
|
3491
|
+
throw new Error("\u041A\u043B\u0438\u0435\u043D\u0442 \u043D\u0435 \u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D. \u0412\u044B\u0437\u043E\u0432\u0438\u0442\u0435 Client.create() \u043F\u0435\u0440\u0435\u0434 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435\u043C.");
|
|
3348
3492
|
}
|
|
3349
|
-
return
|
|
3350
|
-
}
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3493
|
+
return this.instance;
|
|
3494
|
+
}
|
|
3495
|
+
/**
|
|
3496
|
+
* Логин пользователя с использованием email и WIF.
|
|
3497
|
+
* @param email Email пользователя.
|
|
3498
|
+
* @param wif Приватный ключ в формате WIF.
|
|
3499
|
+
* @returns Результат логина.
|
|
3500
|
+
*/
|
|
3501
|
+
async login(email, wif) {
|
|
3502
|
+
const now = (await this.blockchain.getInfo()).head_block_time.toString();
|
|
3358
3503
|
const privateKey = session.PrivateKey.fromString(wif);
|
|
3359
3504
|
const bytes = session.Bytes.fromString(now, "utf8");
|
|
3360
3505
|
const checksum = session.Checksum256.hash(bytes);
|
|
@@ -3366,35 +3511,104 @@ function createClient(options) {
|
|
|
3366
3511
|
signature
|
|
3367
3512
|
}
|
|
3368
3513
|
};
|
|
3369
|
-
const { [name$p]: result } = await thunder("mutation")(
|
|
3514
|
+
const { [name$p]: result } = await this.thunder("mutation")(
|
|
3370
3515
|
mutation$f,
|
|
3371
3516
|
{
|
|
3372
3517
|
variables
|
|
3373
3518
|
}
|
|
3374
3519
|
);
|
|
3375
|
-
|
|
3520
|
+
const username = result.account.username;
|
|
3521
|
+
this.blockchain.setWif(username, wif);
|
|
3522
|
+
this.document.setWif(wif);
|
|
3523
|
+
this.currentHeaders.Authorization = `Bearer ${result.tokens.access.token}`;
|
|
3376
3524
|
return result;
|
|
3377
3525
|
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3526
|
+
/**
|
|
3527
|
+
* Установка токена авторизации.
|
|
3528
|
+
* @param token Токен для заголовков Authorization.
|
|
3529
|
+
*/
|
|
3530
|
+
setToken(token) {
|
|
3531
|
+
this.currentHeaders.Authorization = `Bearer ${token}`;
|
|
3382
3532
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3533
|
+
/**
|
|
3534
|
+
* Доступ к Blockchain.
|
|
3535
|
+
*/
|
|
3536
|
+
get Blockchain() {
|
|
3537
|
+
return this.blockchain;
|
|
3538
|
+
}
|
|
3539
|
+
/**
|
|
3540
|
+
* Доступ к Document.
|
|
3541
|
+
*/
|
|
3542
|
+
get Document() {
|
|
3543
|
+
return this.document;
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* Доступ к GraphQL-запросам.
|
|
3547
|
+
*/
|
|
3548
|
+
get Query() {
|
|
3549
|
+
return this.thunder("query");
|
|
3550
|
+
}
|
|
3551
|
+
/**
|
|
3552
|
+
* Доступ к GraphQL-мутациям.
|
|
3553
|
+
*/
|
|
3554
|
+
get Mutation() {
|
|
3555
|
+
return this.thunder("mutation");
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* Подписка на GraphQL-события.
|
|
3559
|
+
*/
|
|
3560
|
+
get Subscription() {
|
|
3561
|
+
return Subscription(this.options.api_url.replace(/^http/, "ws"));
|
|
3562
|
+
}
|
|
3563
|
+
/**
|
|
3564
|
+
* Создает функцию Thunder для выполнения GraphQL-запросов.
|
|
3565
|
+
* @param baseUrl URL GraphQL API.
|
|
3566
|
+
* @returns Функция Thunder.
|
|
3567
|
+
*/
|
|
3568
|
+
static createThunder(baseUrl) {
|
|
3569
|
+
return Thunder(async (query, variables) => {
|
|
3570
|
+
const response = await fetch(baseUrl, {
|
|
3571
|
+
body: JSON.stringify({ query, variables }),
|
|
3572
|
+
method: "POST",
|
|
3573
|
+
headers: {
|
|
3574
|
+
"Content-Type": "application/json",
|
|
3575
|
+
..._Client.getInstance().currentHeaders
|
|
3576
|
+
}
|
|
3577
|
+
});
|
|
3578
|
+
if (!response.ok) {
|
|
3579
|
+
return new Promise((resolve, reject) => {
|
|
3580
|
+
response.text().then((text) => {
|
|
3581
|
+
try {
|
|
3582
|
+
reject(JSON.parse(text));
|
|
3583
|
+
} catch {
|
|
3584
|
+
reject(text);
|
|
3585
|
+
}
|
|
3586
|
+
}).catch(reject);
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3589
|
+
const json = await response.json();
|
|
3590
|
+
if (json.errors) {
|
|
3591
|
+
console.log("json.errors", json.errors);
|
|
3592
|
+
throw json.errors;
|
|
3593
|
+
}
|
|
3594
|
+
return json.data;
|
|
3595
|
+
}, { scalars: _Client.scalars });
|
|
3596
|
+
}
|
|
3597
|
+
};
|
|
3598
|
+
__publicField(_Client, "instance", null);
|
|
3599
|
+
__publicField(_Client, "scalars", ZeusScalars({
|
|
3600
|
+
DateTime: {
|
|
3601
|
+
decode: (e) => new Date(e),
|
|
3602
|
+
// Преобразует строку в объект Date
|
|
3603
|
+
encode: (e) => e.toISOString()
|
|
3604
|
+
// Преобразует Date в ISO-строку
|
|
3605
|
+
}
|
|
3606
|
+
}));
|
|
3607
|
+
let Client = _Client;
|
|
3394
3608
|
|
|
3395
3609
|
exports.Classes = Classes;
|
|
3610
|
+
exports.Client = Client;
|
|
3396
3611
|
exports.Mutations = Mutations;
|
|
3397
|
-
exports.Queries = index$
|
|
3612
|
+
exports.Queries = index$5;
|
|
3398
3613
|
exports.Types = index;
|
|
3399
|
-
exports.Zeus = index$
|
|
3400
|
-
exports.createClient = createClient;
|
|
3614
|
+
exports.Zeus = index$o;
|