@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.mjs
CHANGED
|
@@ -3,19 +3,19 @@ import WebSocket from 'isomorphic-ws';
|
|
|
3
3
|
import { PrivateKey, APIClient, Action } from '@wharfkit/antelope';
|
|
4
4
|
import { ContractKit, Table } from '@wharfkit/contract';
|
|
5
5
|
import { WalletPluginPrivateKey } from '@wharfkit/wallet-plugin-privatekey';
|
|
6
|
-
import { createClient
|
|
6
|
+
import { createClient } from 'graphql-ws';
|
|
7
7
|
|
|
8
|
-
var __defProp$
|
|
9
|
-
var __defNormalProp$
|
|
10
|
-
var __publicField$
|
|
11
|
-
__defNormalProp$
|
|
8
|
+
var __defProp$4 = Object.defineProperty;
|
|
9
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __publicField$4 = (obj, key, value) => {
|
|
11
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
12
12
|
return value;
|
|
13
13
|
};
|
|
14
14
|
class Account {
|
|
15
15
|
constructor() {
|
|
16
|
-
__publicField$
|
|
17
|
-
__publicField$
|
|
18
|
-
__publicField$
|
|
16
|
+
__publicField$4(this, "username");
|
|
17
|
+
__publicField$4(this, "private_key");
|
|
18
|
+
__publicField$4(this, "public_key");
|
|
19
19
|
this.username = Account.generateUsername();
|
|
20
20
|
const keys = Account.generateKeys();
|
|
21
21
|
this.private_key = keys.private_key;
|
|
@@ -48,52 +48,209 @@ class Account {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
var __defProp$
|
|
52
|
-
var __defNormalProp$
|
|
53
|
-
var __publicField$
|
|
54
|
-
__defNormalProp$
|
|
51
|
+
var __defProp$3 = Object.defineProperty;
|
|
52
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
53
|
+
var __publicField$3 = (obj, key, value) => {
|
|
54
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
class Blockchain {
|
|
58
|
+
/**
|
|
59
|
+
* Конструктор класса Blockchain.
|
|
60
|
+
* @param config Конфигурация блокчейна, включающая URL цепочки и идентификатор цепочки.
|
|
61
|
+
*/
|
|
62
|
+
constructor(config) {
|
|
63
|
+
this.config = config;
|
|
64
|
+
__publicField$3(this, "apiClient");
|
|
65
|
+
__publicField$3(this, "contractKit");
|
|
66
|
+
__publicField$3(this, "session");
|
|
67
|
+
this.apiClient = new APIClient({ url: config.chain_url });
|
|
68
|
+
this.contractKit = new ContractKit({ client: this.apiClient });
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Получение информации о блокчейне.
|
|
72
|
+
* @returns Объект с информацией о текущем состоянии блокчейна.
|
|
73
|
+
*/
|
|
74
|
+
async getInfo() {
|
|
75
|
+
return this.apiClient.v1.chain.get_info();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Устанавливает приватный ключ (WIF) для текущей сессии.
|
|
79
|
+
* @param username Имя пользователя (аккаунт).
|
|
80
|
+
* @param wif Приватный ключ в формате WIF.
|
|
81
|
+
* @param permission Тип разрешения, который используется для подписания транзакции (по умолчанию = 'active')
|
|
82
|
+
* @returns Текущий экземпляр Blockchain для цепочного вызова.
|
|
83
|
+
*/
|
|
84
|
+
setWif(username, wif, permission = "active") {
|
|
85
|
+
this.session = new Session({
|
|
86
|
+
actor: username,
|
|
87
|
+
permission,
|
|
88
|
+
chain: {
|
|
89
|
+
id: this.config.chain_id,
|
|
90
|
+
url: this.config.chain_url
|
|
91
|
+
},
|
|
92
|
+
walletPlugin: new WalletPluginPrivateKey(PrivateKey.fromString(wif))
|
|
93
|
+
});
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Выполнение транзакции с передачей одного или нескольких действий.
|
|
98
|
+
* @param actionOrActions Действие или массив действий для выполнения.
|
|
99
|
+
* @param broadcast Если true, транзакция будет отправлена в сеть.
|
|
100
|
+
* @returns Результат выполнения транзакции.
|
|
101
|
+
* @throws Ошибка, если сессия не инициализирована.
|
|
102
|
+
*/
|
|
103
|
+
async transact(actionOrActions, broadcast = true) {
|
|
104
|
+
if (!this.session)
|
|
105
|
+
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.");
|
|
106
|
+
const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
|
|
107
|
+
return this.session.transact({ actions }, { broadcast });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Получение всех строк таблицы смарт-контракта.
|
|
111
|
+
* @param code Код (аккаунт) контракта.
|
|
112
|
+
* @param scope Область видимости (scope) таблицы.
|
|
113
|
+
* @param tableName Имя таблицы.
|
|
114
|
+
* @returns Массив строк таблицы.
|
|
115
|
+
*/
|
|
116
|
+
async getAllRows(code, scope, tableName) {
|
|
117
|
+
const abi = await this.getAbi(code);
|
|
118
|
+
const table = this.createTable(code, tableName, abi);
|
|
119
|
+
const rows = await table.all({ scope });
|
|
120
|
+
return JSON.parse(JSON.stringify(rows));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Запрос строк таблицы с использованием фильтров.
|
|
124
|
+
* @param code Код (аккаунт) контракта.
|
|
125
|
+
* @param scope Область видимости (scope) таблицы.
|
|
126
|
+
* @param tableName Имя таблицы.
|
|
127
|
+
* @param options Опции для фильтрации данных.
|
|
128
|
+
* @returns Массив строк, соответствующих фильтрам.
|
|
129
|
+
*/
|
|
130
|
+
async query(code, scope, tableName, options = { indexPosition: "primary" }) {
|
|
131
|
+
const { indexPosition = "primary", from, to, maxRows } = options;
|
|
132
|
+
const abi = await this.getAbi(code);
|
|
133
|
+
const table = this.createTable(code, tableName, abi);
|
|
134
|
+
const rows = await table.query({
|
|
135
|
+
scope,
|
|
136
|
+
index_position: indexPosition,
|
|
137
|
+
from,
|
|
138
|
+
to,
|
|
139
|
+
maxRows
|
|
140
|
+
});
|
|
141
|
+
return JSON.parse(JSON.stringify(rows));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Получение одной строки таблицы по первичному ключу.
|
|
145
|
+
* @param code Код (аккаунт) контракта.
|
|
146
|
+
* @param scope Область видимости (scope) таблицы.
|
|
147
|
+
* @param tableName Имя таблицы.
|
|
148
|
+
* @param primaryKey Первичный ключ строки.
|
|
149
|
+
* @param indexPosition Индекс для поиска строки (по умолчанию 'primary').
|
|
150
|
+
* @returns Строка таблицы или null, если не найдена.
|
|
151
|
+
*/
|
|
152
|
+
async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
|
|
153
|
+
const abi = await this.getAbi(code);
|
|
154
|
+
const table = this.createTable(code, tableName, abi);
|
|
155
|
+
const row = await table.get(String(primaryKey), {
|
|
156
|
+
scope,
|
|
157
|
+
index_position: indexPosition
|
|
158
|
+
});
|
|
159
|
+
return row ? JSON.parse(JSON.stringify(row)) : null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Создает объект действия (Action) из ABI контракта.
|
|
163
|
+
* @param action Объект действия.
|
|
164
|
+
* @returns Объект Action.
|
|
165
|
+
*/
|
|
166
|
+
async formActionFromAbi(action) {
|
|
167
|
+
const abi = await this.getAbi(action.account);
|
|
168
|
+
return Action.from(action, abi);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Получение ABI контракта.
|
|
172
|
+
* @param account Код (аккаунт) контракта.
|
|
173
|
+
* @returns ABI контракта.
|
|
174
|
+
* @throws Ошибка, если ABI не найден.
|
|
175
|
+
*/
|
|
176
|
+
async getAbi(account) {
|
|
177
|
+
const { abi } = await this.apiClient.v1.chain.get_abi(account);
|
|
178
|
+
if (!abi)
|
|
179
|
+
throw new Error(`ABI \u0434\u043B\u044F \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 "${account}" \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D.`);
|
|
180
|
+
return abi;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Создает объект таблицы (Table) для работы с данными.
|
|
184
|
+
* @param code Код (аккаунт) контракта.
|
|
185
|
+
* @param tableName Имя таблицы.
|
|
186
|
+
* @param abi ABI контракта.
|
|
187
|
+
* @returns Объект Table.
|
|
188
|
+
*/
|
|
189
|
+
createTable(code, tableName, abi) {
|
|
190
|
+
return new Table({
|
|
191
|
+
abi,
|
|
192
|
+
account: code,
|
|
193
|
+
name: tableName,
|
|
194
|
+
client: this.apiClient
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var __defProp$2 = Object.defineProperty;
|
|
200
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
201
|
+
var __publicField$2 = (obj, key, value) => {
|
|
202
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
55
203
|
return value;
|
|
56
204
|
};
|
|
57
205
|
class Canvas {
|
|
206
|
+
/**
|
|
207
|
+
* Создаёт экземпляр класса `Canvas` и подготавливает холст для рисования подписи.
|
|
208
|
+
*
|
|
209
|
+
* @param container - HTML-элемент, внутри которого создаётся `<canvas>`.
|
|
210
|
+
* @param opts - Настройки:
|
|
211
|
+
* - `lineWidth` - Толщина линии для рисования (по умолчанию 5).
|
|
212
|
+
* - `strokeStyle` - Цвет линии для рисования (по умолчанию чёрный, `#000`).
|
|
213
|
+
*/
|
|
58
214
|
constructor(container, opts = {}) {
|
|
59
215
|
this.container = container;
|
|
60
216
|
this.opts = opts;
|
|
61
|
-
__publicField$
|
|
62
|
-
__publicField$
|
|
63
|
-
__publicField$
|
|
64
|
-
__publicField$
|
|
65
|
-
__publicField$
|
|
66
|
-
__publicField$
|
|
217
|
+
__publicField$2(this, "canvas");
|
|
218
|
+
__publicField$2(this, "ctx");
|
|
219
|
+
__publicField$2(this, "drawing", false);
|
|
220
|
+
__publicField$2(this, "lastX", 0);
|
|
221
|
+
__publicField$2(this, "lastY", 0);
|
|
222
|
+
__publicField$2(this, "onMouseDown", (e) => {
|
|
67
223
|
e.preventDefault();
|
|
68
224
|
this.drawing = true;
|
|
69
225
|
const rect = this.canvas.getBoundingClientRect();
|
|
70
226
|
this.lastX = e.clientX - rect.left;
|
|
71
227
|
this.lastY = e.clientY - rect.top;
|
|
72
228
|
});
|
|
73
|
-
__publicField$
|
|
229
|
+
__publicField$2(this, "onMouseMove", (e) => {
|
|
74
230
|
if (!this.drawing)
|
|
75
231
|
return;
|
|
76
232
|
e.preventDefault();
|
|
77
233
|
this.drawLine(e.clientX, e.clientY);
|
|
78
234
|
});
|
|
79
|
-
__publicField$
|
|
235
|
+
__publicField$2(this, "onMouseUp", () => {
|
|
80
236
|
this.drawing = false;
|
|
81
237
|
});
|
|
82
|
-
__publicField$
|
|
238
|
+
__publicField$2(this, "onTouchStart", (e) => {
|
|
83
239
|
e.preventDefault();
|
|
84
240
|
this.drawing = true;
|
|
85
241
|
const rect = this.canvas.getBoundingClientRect();
|
|
86
|
-
|
|
87
|
-
this.
|
|
242
|
+
const t = e.touches[0];
|
|
243
|
+
this.lastX = t.clientX - rect.left;
|
|
244
|
+
this.lastY = t.clientY - rect.top;
|
|
88
245
|
});
|
|
89
|
-
__publicField$
|
|
246
|
+
__publicField$2(this, "onTouchMove", (e) => {
|
|
90
247
|
if (!this.drawing)
|
|
91
248
|
return;
|
|
92
249
|
e.preventDefault();
|
|
93
250
|
const t = e.touches[0];
|
|
94
251
|
this.drawLine(t.clientX, t.clientY);
|
|
95
252
|
});
|
|
96
|
-
__publicField$
|
|
253
|
+
__publicField$2(this, "onTouchEnd", () => {
|
|
97
254
|
this.drawing = false;
|
|
98
255
|
});
|
|
99
256
|
this.canvas = document.createElement("canvas");
|
|
@@ -103,7 +260,7 @@ class Canvas {
|
|
|
103
260
|
container.appendChild(this.canvas);
|
|
104
261
|
const ctx = this.canvas.getContext("2d");
|
|
105
262
|
if (!ctx) {
|
|
106
|
-
throw new Error("Canvas
|
|
263
|
+
throw new Error("Canvas \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F");
|
|
107
264
|
}
|
|
108
265
|
this.ctx = ctx;
|
|
109
266
|
this.ctx.lineWidth = this.opts.lineWidth ?? 5;
|
|
@@ -113,19 +270,21 @@ class Canvas {
|
|
|
113
270
|
this.initEvents();
|
|
114
271
|
}
|
|
115
272
|
/**
|
|
116
|
-
*
|
|
273
|
+
* Очищает холст.
|
|
117
274
|
*/
|
|
118
275
|
clearCanvas() {
|
|
119
276
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
120
277
|
}
|
|
121
278
|
/**
|
|
122
|
-
*
|
|
279
|
+
* Возвращает содержимое холста (подпись) в формате base64 (PNG).
|
|
280
|
+
*
|
|
281
|
+
* @returns Подпись в формате base64.
|
|
123
282
|
*/
|
|
124
283
|
getSignature() {
|
|
125
284
|
return this.canvas.toDataURL("image/png");
|
|
126
285
|
}
|
|
127
286
|
/**
|
|
128
|
-
*
|
|
287
|
+
* Снимает все обработчики событий и очищает ресурсы.
|
|
129
288
|
*/
|
|
130
289
|
destroy() {
|
|
131
290
|
this.canvas.removeEventListener("mousedown", this.onMouseDown);
|
|
@@ -136,6 +295,9 @@ class Canvas {
|
|
|
136
295
|
this.canvas.removeEventListener("touchend", this.onTouchEnd);
|
|
137
296
|
}
|
|
138
297
|
// Внутренние методы
|
|
298
|
+
/**
|
|
299
|
+
* Навешивает обработчики событий мыши и тач-устройств.
|
|
300
|
+
*/
|
|
139
301
|
initEvents() {
|
|
140
302
|
this.canvas.addEventListener("mousedown", this.onMouseDown);
|
|
141
303
|
this.canvas.addEventListener("mousemove", this.onMouseMove);
|
|
@@ -157,101 +319,70 @@ class Canvas {
|
|
|
157
319
|
}
|
|
158
320
|
}
|
|
159
321
|
|
|
160
|
-
var __defProp = Object.defineProperty;
|
|
161
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
162
|
-
var __publicField = (obj, key, value) => {
|
|
163
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
322
|
+
var __defProp$1 = Object.defineProperty;
|
|
323
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
324
|
+
var __publicField$1 = (obj, key, value) => {
|
|
325
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
164
326
|
return value;
|
|
165
327
|
};
|
|
166
|
-
class
|
|
167
|
-
constructor(config) {
|
|
168
|
-
this.config = config;
|
|
169
|
-
__publicField(this, "apiClient");
|
|
170
|
-
__publicField(this, "contractKit");
|
|
171
|
-
__publicField(this, "session");
|
|
172
|
-
this.apiClient = new APIClient({ url: config.chain_url });
|
|
173
|
-
this.contractKit = new ContractKit({ client: this.apiClient });
|
|
174
|
-
}
|
|
175
|
-
async getInfo() {
|
|
176
|
-
return this.apiClient.v1.chain.get_info();
|
|
177
|
-
}
|
|
328
|
+
class Document {
|
|
178
329
|
/**
|
|
179
|
-
*
|
|
180
|
-
* @param
|
|
181
|
-
* @param wif - приватный ключ
|
|
182
|
-
* @returns
|
|
330
|
+
* Инициализация класса Document с WIF-ключом.
|
|
331
|
+
* @param wifKey WIF-ключ, используемый для подписи.
|
|
183
332
|
*/
|
|
184
|
-
|
|
185
|
-
this
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
chain: {
|
|
189
|
-
id: this.config.chain_id,
|
|
190
|
-
url: this.config.chain_url
|
|
191
|
-
},
|
|
192
|
-
walletPlugin: new WalletPluginPrivateKey(PrivateKey.fromString(wif))
|
|
193
|
-
});
|
|
194
|
-
return this;
|
|
333
|
+
constructor(wifKey) {
|
|
334
|
+
__publicField$1(this, "wif");
|
|
335
|
+
if (wifKey)
|
|
336
|
+
this.wif = PrivateKey.fromString(wifKey);
|
|
195
337
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
async getAllRows(code, scope, tableName) {
|
|
203
|
-
const abi = await this.getAbi(code);
|
|
204
|
-
const table = this.createTable(code, tableName, abi);
|
|
205
|
-
const rows = await table.all({ scope });
|
|
206
|
-
return JSON.parse(JSON.stringify(rows));
|
|
207
|
-
}
|
|
208
|
-
async query(code, scope, tableName, options = { indexPosition: "primary" }) {
|
|
209
|
-
const { indexPosition = "primary", from, to, maxRows } = options;
|
|
210
|
-
const abi = await this.getAbi(code);
|
|
211
|
-
const table = this.createTable(code, tableName, abi);
|
|
212
|
-
const rows = await table.query({
|
|
213
|
-
scope,
|
|
214
|
-
index_position: indexPosition,
|
|
215
|
-
from,
|
|
216
|
-
to,
|
|
217
|
-
maxRows
|
|
218
|
-
});
|
|
219
|
-
return JSON.parse(JSON.stringify(rows));
|
|
220
|
-
}
|
|
221
|
-
async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
|
|
222
|
-
const abi = await this.getAbi(code);
|
|
223
|
-
const table = this.createTable(code, tableName, abi);
|
|
224
|
-
const row = await table.get(String(primaryKey), {
|
|
225
|
-
scope,
|
|
226
|
-
index_position: indexPosition
|
|
227
|
-
});
|
|
228
|
-
return row ? JSON.parse(JSON.stringify(row)) : null;
|
|
229
|
-
}
|
|
230
|
-
async formActionFromAbi(action) {
|
|
231
|
-
const abi = await this.getAbi(action.account);
|
|
232
|
-
return Action.from(action, abi);
|
|
338
|
+
/**
|
|
339
|
+
* Замена текущего WIF-ключа на новый.
|
|
340
|
+
* @param wifKey Новый WIF-ключ.
|
|
341
|
+
*/
|
|
342
|
+
setWif(wifKey) {
|
|
343
|
+
this.wif = PrivateKey.fromString(wifKey);
|
|
233
344
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Подписывает документ и возвращает его в формате ISignedDocument.
|
|
347
|
+
* @param document Сгенерированный документ для подписи.
|
|
348
|
+
* @returns Подписанный документ.
|
|
349
|
+
*/
|
|
350
|
+
async signDocument(document) {
|
|
351
|
+
const digitalSignature = this.signDigest(document.hash);
|
|
352
|
+
return {
|
|
353
|
+
hash: document.hash,
|
|
354
|
+
public_key: digitalSignature.public_key,
|
|
355
|
+
signature: digitalSignature.signature,
|
|
356
|
+
meta: document.meta
|
|
357
|
+
};
|
|
239
358
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Подписывает хэш (digest) документа и проверяет подпись.
|
|
361
|
+
* @param digest Хэш документа для подписи.
|
|
362
|
+
* @returns Детали подписи.
|
|
363
|
+
*/
|
|
364
|
+
signDigest(digest) {
|
|
365
|
+
if (!this.wif)
|
|
366
|
+
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`);
|
|
367
|
+
const signed = this.wif.signDigest(digest);
|
|
368
|
+
const verified = signed.verifyDigest(digest, this.wif.toPublic());
|
|
369
|
+
if (!verified) {
|
|
370
|
+
throw new Error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u043F\u043E\u0434\u043F\u0438\u0441\u0438");
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
message: digest,
|
|
374
|
+
signature: signed.toString(),
|
|
375
|
+
public_key: this.wif.toPublic().toString()
|
|
376
|
+
};
|
|
247
377
|
}
|
|
248
378
|
}
|
|
249
379
|
|
|
250
380
|
const Classes = {
|
|
251
381
|
__proto__: null,
|
|
252
382
|
Account: Account,
|
|
383
|
+
Blockchain: Blockchain,
|
|
253
384
|
Canvas: Canvas,
|
|
254
|
-
|
|
385
|
+
Document: Document
|
|
255
386
|
};
|
|
256
387
|
|
|
257
388
|
const AllTypesProps = {
|
|
@@ -291,7 +422,6 @@ const AllTypesProps = {
|
|
|
291
422
|
},
|
|
292
423
|
CreateProjectFreeDecisionInput: {},
|
|
293
424
|
DateTime: `scalar.DateTime`,
|
|
294
|
-
DeleteAccountInput: {},
|
|
295
425
|
DeleteBranchInput: {},
|
|
296
426
|
DeletePaymentMethodInput: {},
|
|
297
427
|
DeleteTrustedAccountInput: {},
|
|
@@ -327,7 +457,6 @@ const AllTypesProps = {
|
|
|
327
457
|
soviet: "SovietMemberInput"
|
|
328
458
|
},
|
|
329
459
|
JSON: `scalar.JSON`,
|
|
330
|
-
LangType: "enum",
|
|
331
460
|
LoginInput: {},
|
|
332
461
|
LogoutInput: {},
|
|
333
462
|
MetaDocumentInput: {},
|
|
@@ -353,9 +482,6 @@ const AllTypesProps = {
|
|
|
353
482
|
createProjectOfFreeDecision: {
|
|
354
483
|
data: "CreateProjectFreeDecisionInput"
|
|
355
484
|
},
|
|
356
|
-
deleteAccount: {
|
|
357
|
-
data: "DeleteAccountInput"
|
|
358
|
-
},
|
|
359
485
|
deleteBranch: {
|
|
360
486
|
data: "DeleteBranchInput"
|
|
361
487
|
},
|
|
@@ -511,7 +637,6 @@ const AllTypesProps = {
|
|
|
511
637
|
entrepreneur_data: "CreateEntrepreneurDataInput",
|
|
512
638
|
individual_data: "CreateIndividualDataInput",
|
|
513
639
|
organization_data: "CreateOrganizationDataInput",
|
|
514
|
-
role: "RegisterRole",
|
|
515
640
|
type: "AccountType"
|
|
516
641
|
},
|
|
517
642
|
RegisterParticipantInput: {
|
|
@@ -885,7 +1010,7 @@ const ReturnTypes = {
|
|
|
885
1010
|
created_at: "String",
|
|
886
1011
|
decision_id: "Float",
|
|
887
1012
|
generator: "String",
|
|
888
|
-
lang: "
|
|
1013
|
+
lang: "String",
|
|
889
1014
|
links: "String",
|
|
890
1015
|
project_id: "String",
|
|
891
1016
|
registry_id: "Int",
|
|
@@ -922,7 +1047,7 @@ const ReturnTypes = {
|
|
|
922
1047
|
coopname: "String",
|
|
923
1048
|
created_at: "String",
|
|
924
1049
|
generator: "String",
|
|
925
|
-
lang: "
|
|
1050
|
+
lang: "String",
|
|
926
1051
|
links: "String",
|
|
927
1052
|
registry_id: "Int",
|
|
928
1053
|
timezone: "String",
|
|
@@ -952,7 +1077,6 @@ const ReturnTypes = {
|
|
|
952
1077
|
createDepositPayment: "Payment",
|
|
953
1078
|
createInitialPayment: "Payment",
|
|
954
1079
|
createProjectOfFreeDecision: "CreatedProjectFreeDecision",
|
|
955
|
-
deleteAccount: "Boolean",
|
|
956
1080
|
deleteBranch: "Boolean",
|
|
957
1081
|
deletePaymentMethod: "Boolean",
|
|
958
1082
|
deleteTrustedAccount: "Branch",
|
|
@@ -1030,7 +1154,7 @@ const ReturnTypes = {
|
|
|
1030
1154
|
created_at: "String",
|
|
1031
1155
|
decision_id: "Float",
|
|
1032
1156
|
generator: "String",
|
|
1033
|
-
lang: "
|
|
1157
|
+
lang: "String",
|
|
1034
1158
|
links: "String",
|
|
1035
1159
|
registry_id: "Int",
|
|
1036
1160
|
timezone: "String",
|
|
@@ -1050,7 +1174,7 @@ const ReturnTypes = {
|
|
|
1050
1174
|
coopname: "String",
|
|
1051
1175
|
created_at: "String",
|
|
1052
1176
|
generator: "String",
|
|
1053
|
-
lang: "
|
|
1177
|
+
lang: "String",
|
|
1054
1178
|
links: "String",
|
|
1055
1179
|
registry_id: "Int",
|
|
1056
1180
|
timezone: "String",
|
|
@@ -1138,7 +1262,7 @@ const ReturnTypes = {
|
|
|
1138
1262
|
coopname: "String",
|
|
1139
1263
|
created_at: "String",
|
|
1140
1264
|
generator: "String",
|
|
1141
|
-
lang: "
|
|
1265
|
+
lang: "String",
|
|
1142
1266
|
links: "String",
|
|
1143
1267
|
project_id: "String",
|
|
1144
1268
|
registry_id: "Int",
|
|
@@ -1208,7 +1332,7 @@ const ReturnTypes = {
|
|
|
1208
1332
|
coopname: "String",
|
|
1209
1333
|
created_at: "String",
|
|
1210
1334
|
generator: "String",
|
|
1211
|
-
lang: "
|
|
1335
|
+
lang: "String",
|
|
1212
1336
|
links: "String",
|
|
1213
1337
|
registry_id: "Int",
|
|
1214
1338
|
timezone: "String",
|
|
@@ -1303,7 +1427,7 @@ const Ops = {
|
|
|
1303
1427
|
const HOST = "Specify host";
|
|
1304
1428
|
const HEADERS = {};
|
|
1305
1429
|
const apiSubscription = (options) => {
|
|
1306
|
-
const client = createClient
|
|
1430
|
+
const client = createClient({
|
|
1307
1431
|
url: String(options[0]),
|
|
1308
1432
|
connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries())
|
|
1309
1433
|
});
|
|
@@ -1823,10 +1947,6 @@ var Country = /* @__PURE__ */ ((Country2) => {
|
|
|
1823
1947
|
Country2["Russia"] = "Russia";
|
|
1824
1948
|
return Country2;
|
|
1825
1949
|
})(Country || {});
|
|
1826
|
-
var LangType = /* @__PURE__ */ ((LangType2) => {
|
|
1827
|
-
LangType2["ru"] = "ru";
|
|
1828
|
-
return LangType2;
|
|
1829
|
-
})(LangType || {});
|
|
1830
1950
|
var OrganizationType = /* @__PURE__ */ ((OrganizationType2) => {
|
|
1831
1951
|
OrganizationType2["AO"] = "AO";
|
|
1832
1952
|
OrganizationType2["COOP"] = "COOP";
|
|
@@ -1867,7 +1987,7 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
|
1867
1987
|
return UserStatus2;
|
|
1868
1988
|
})(UserStatus || {});
|
|
1869
1989
|
|
|
1870
|
-
const index$
|
|
1990
|
+
const index$o = {
|
|
1871
1991
|
__proto__: null,
|
|
1872
1992
|
$: $,
|
|
1873
1993
|
AccountType: AccountType,
|
|
@@ -1880,7 +2000,6 @@ const index$k = {
|
|
|
1880
2000
|
HOST: HOST,
|
|
1881
2001
|
InternalArgsBuilt: InternalArgsBuilt,
|
|
1882
2002
|
InternalsBuildQuery: InternalsBuildQuery,
|
|
1883
|
-
LangType: LangType,
|
|
1884
2003
|
OrganizationType: OrganizationType,
|
|
1885
2004
|
PaymentStatus: PaymentStatus,
|
|
1886
2005
|
PrepareScalarPaths: PrepareScalarPaths,
|
|
@@ -1958,7 +2077,7 @@ const updateExtension = {
|
|
|
1958
2077
|
name: name$K
|
|
1959
2078
|
};
|
|
1960
2079
|
|
|
1961
|
-
const index$
|
|
2080
|
+
const index$n = {
|
|
1962
2081
|
__proto__: null,
|
|
1963
2082
|
InstallExtension: installExtension,
|
|
1964
2083
|
UninstallExtension: uninstallExtension,
|
|
@@ -2028,7 +2147,7 @@ const updateBankAccount = {
|
|
|
2028
2147
|
name: name$H
|
|
2029
2148
|
};
|
|
2030
2149
|
|
|
2031
|
-
const index$
|
|
2150
|
+
const index$m = {
|
|
2032
2151
|
__proto__: null,
|
|
2033
2152
|
CreateBankAccount: createBankAccount,
|
|
2034
2153
|
DeletePaymentMethod: deletePaymentMethod,
|
|
@@ -2594,7 +2713,7 @@ const selectBranch = {
|
|
|
2594
2713
|
|
|
2595
2714
|
const name$A = "generateSelectBranchDocument";
|
|
2596
2715
|
const mutation$q = Selector("Mutation")({
|
|
2597
|
-
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2716
|
+
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, generateSelectBranchDocumentSelector]
|
|
2598
2717
|
});
|
|
2599
2718
|
|
|
2600
2719
|
const generateSelectBranchDocument = {
|
|
@@ -2603,7 +2722,7 @@ const generateSelectBranchDocument = {
|
|
|
2603
2722
|
name: name$A
|
|
2604
2723
|
};
|
|
2605
2724
|
|
|
2606
|
-
const index$
|
|
2725
|
+
const index$l = {
|
|
2607
2726
|
__proto__: null,
|
|
2608
2727
|
AddTrustedAccount: addTrustedAccount,
|
|
2609
2728
|
CreateBranch: createBranch,
|
|
@@ -2626,7 +2745,7 @@ const projectFreeDecisionDocumentSelector = Selector("ProjectFreeDecisionDocumen
|
|
|
2626
2745
|
|
|
2627
2746
|
const name$z = "generateProjectOfFreeDecision";
|
|
2628
2747
|
const mutation$p = Selector("Mutation")({
|
|
2629
|
-
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2748
|
+
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, projectFreeDecisionDocumentSelector]
|
|
2630
2749
|
});
|
|
2631
2750
|
|
|
2632
2751
|
const generateProjectOfFreeDecisionDocument = {
|
|
@@ -2656,7 +2775,7 @@ const createdProjectFreeDecisionSelector = Selector("CreatedProjectFreeDecision"
|
|
|
2656
2775
|
|
|
2657
2776
|
const name$y = "generateFreeDecision";
|
|
2658
2777
|
const mutation$o = Selector("Mutation")({
|
|
2659
|
-
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2778
|
+
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, freeDecisionDocumentSelector]
|
|
2660
2779
|
});
|
|
2661
2780
|
|
|
2662
2781
|
const generateFreeDecision = {
|
|
@@ -2687,7 +2806,7 @@ const createProjectOfFreeDecision = {
|
|
|
2687
2806
|
name: name$w
|
|
2688
2807
|
};
|
|
2689
2808
|
|
|
2690
|
-
const index$
|
|
2809
|
+
const index$k = {
|
|
2691
2810
|
__proto__: null,
|
|
2692
2811
|
CreateProjectOfFreeDecision: createProjectOfFreeDecision,
|
|
2693
2812
|
GenerateFreeDecision: generateFreeDecision,
|
|
@@ -2695,17 +2814,6 @@ const index$g = {
|
|
|
2695
2814
|
PublishProjectOfFreeDecision: publishProjectOfFreeDecision
|
|
2696
2815
|
};
|
|
2697
2816
|
|
|
2698
|
-
const name$v = "updateAccount";
|
|
2699
|
-
const mutation$l = Selector("Mutation")({
|
|
2700
|
-
[name$v]: [{ data: $("data", "UpdateAccountInput!") }, accountSelector]
|
|
2701
|
-
});
|
|
2702
|
-
|
|
2703
|
-
const updateAccount = {
|
|
2704
|
-
__proto__: null,
|
|
2705
|
-
mutation: mutation$l,
|
|
2706
|
-
name: name$v
|
|
2707
|
-
};
|
|
2708
|
-
|
|
2709
2817
|
const rawTokenSelector = {
|
|
2710
2818
|
expires: true,
|
|
2711
2819
|
token: true
|
|
@@ -2722,12 +2830,23 @@ const registeredAccountSelector = Selector("RegisteredAccount")(
|
|
|
2722
2830
|
rawRegisteredAccountSelector
|
|
2723
2831
|
);
|
|
2724
2832
|
|
|
2725
|
-
const name$
|
|
2726
|
-
const mutation$
|
|
2727
|
-
[name$
|
|
2833
|
+
const name$v = "registerAccount";
|
|
2834
|
+
const mutation$l = Selector("Mutation")({
|
|
2835
|
+
[name$v]: [{ data: $("data", "RegisterAccountInput!") }, registeredAccountSelector]
|
|
2728
2836
|
});
|
|
2729
2837
|
|
|
2730
2838
|
const registerAccount = {
|
|
2839
|
+
__proto__: null,
|
|
2840
|
+
mutation: mutation$l,
|
|
2841
|
+
name: name$v
|
|
2842
|
+
};
|
|
2843
|
+
|
|
2844
|
+
const name$u = "resetKey";
|
|
2845
|
+
const mutation$k = Selector("Mutation")({
|
|
2846
|
+
[name$u]: [{ data: $("data", "ResetKeyInput!") }, true]
|
|
2847
|
+
});
|
|
2848
|
+
|
|
2849
|
+
const resetKey = {
|
|
2731
2850
|
__proto__: null,
|
|
2732
2851
|
mutation: mutation$k,
|
|
2733
2852
|
name: name$u
|
|
@@ -2744,18 +2863,18 @@ const startResetKey = {
|
|
|
2744
2863
|
name: name$t
|
|
2745
2864
|
};
|
|
2746
2865
|
|
|
2747
|
-
const name$s = "
|
|
2866
|
+
const name$s = "updateAccount";
|
|
2748
2867
|
const mutation$i = Selector("Mutation")({
|
|
2749
|
-
[name$s]: [{ data: $("data", "
|
|
2868
|
+
[name$s]: [{ data: $("data", "UpdateAccountInput!") }, accountSelector]
|
|
2750
2869
|
});
|
|
2751
2870
|
|
|
2752
|
-
const
|
|
2871
|
+
const updateAccount = {
|
|
2753
2872
|
__proto__: null,
|
|
2754
2873
|
mutation: mutation$i,
|
|
2755
2874
|
name: name$s
|
|
2756
2875
|
};
|
|
2757
2876
|
|
|
2758
|
-
const index$
|
|
2877
|
+
const index$j = {
|
|
2759
2878
|
__proto__: null,
|
|
2760
2879
|
RegisterAccount: registerAccount,
|
|
2761
2880
|
ResetKey: resetKey,
|
|
@@ -2796,7 +2915,7 @@ const login = {
|
|
|
2796
2915
|
name: name$p
|
|
2797
2916
|
};
|
|
2798
2917
|
|
|
2799
|
-
const index$
|
|
2918
|
+
const index$i = {
|
|
2800
2919
|
__proto__: null,
|
|
2801
2920
|
Login: login,
|
|
2802
2921
|
Logout: logout,
|
|
@@ -2847,7 +2966,7 @@ const updateSystem = {
|
|
|
2847
2966
|
name: name$l
|
|
2848
2967
|
};
|
|
2849
2968
|
|
|
2850
|
-
const index$
|
|
2969
|
+
const index$h = {
|
|
2851
2970
|
__proto__: null,
|
|
2852
2971
|
InitSystem: initSystem,
|
|
2853
2972
|
InstallSystem: installSystem,
|
|
@@ -2857,7 +2976,7 @@ const index$d = {
|
|
|
2857
2976
|
|
|
2858
2977
|
const name$k = "generateParticipantApplication";
|
|
2859
2978
|
const mutation$a = Selector("Mutation")({
|
|
2860
|
-
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2979
|
+
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDocumentSelector]
|
|
2861
2980
|
});
|
|
2862
2981
|
|
|
2863
2982
|
const generateParticipantApplication = {
|
|
@@ -2868,7 +2987,7 @@ const generateParticipantApplication = {
|
|
|
2868
2987
|
|
|
2869
2988
|
const name$j = "generateParticipantApplicationDecision";
|
|
2870
2989
|
const mutation$9 = Selector("Mutation")({
|
|
2871
|
-
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2990
|
+
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDecisionDocumentSelector]
|
|
2872
2991
|
});
|
|
2873
2992
|
|
|
2874
2993
|
const generateParticipantApplicationDecision = {
|
|
@@ -2899,7 +3018,7 @@ const addParticipant = {
|
|
|
2899
3018
|
name: name$h
|
|
2900
3019
|
};
|
|
2901
3020
|
|
|
2902
|
-
const index$
|
|
3021
|
+
const index$g = {
|
|
2903
3022
|
__proto__: null,
|
|
2904
3023
|
AddParticipant: addParticipant,
|
|
2905
3024
|
GenerateParticipantApplication: generateParticipantApplication,
|
|
@@ -2965,7 +3084,7 @@ const setPaymentStatus = {
|
|
|
2965
3084
|
name: name$e
|
|
2966
3085
|
};
|
|
2967
3086
|
|
|
2968
|
-
const index$
|
|
3087
|
+
const index$f = {
|
|
2969
3088
|
__proto__: null,
|
|
2970
3089
|
CreateDepositPayment: createDeposit,
|
|
2971
3090
|
CreateInitialPayment: createInitial,
|
|
@@ -2974,7 +3093,7 @@ const index$b = {
|
|
|
2974
3093
|
|
|
2975
3094
|
const name$d = "generatePrivacyAgreement";
|
|
2976
3095
|
const mutation$3 = Selector("Mutation")({
|
|
2977
|
-
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3096
|
+
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2978
3097
|
});
|
|
2979
3098
|
|
|
2980
3099
|
const generatePrivacyAgreement = {
|
|
@@ -2985,7 +3104,7 @@ const generatePrivacyAgreement = {
|
|
|
2985
3104
|
|
|
2986
3105
|
const name$c = "generateSignatureAgreement";
|
|
2987
3106
|
const mutation$2 = Selector("Mutation")({
|
|
2988
|
-
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3107
|
+
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2989
3108
|
});
|
|
2990
3109
|
|
|
2991
3110
|
const generateSignatureAgreement = {
|
|
@@ -2996,7 +3115,7 @@ const generateSignatureAgreement = {
|
|
|
2996
3115
|
|
|
2997
3116
|
const name$b = "generateWalletAgreement";
|
|
2998
3117
|
const mutation$1 = Selector("Mutation")({
|
|
2999
|
-
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3118
|
+
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3000
3119
|
});
|
|
3001
3120
|
|
|
3002
3121
|
const generateWalletAgreement = {
|
|
@@ -3007,7 +3126,7 @@ const generateWalletAgreement = {
|
|
|
3007
3126
|
|
|
3008
3127
|
const name$a = "generateUserAgreement";
|
|
3009
3128
|
const mutation = Selector("Mutation")({
|
|
3010
|
-
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3129
|
+
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3011
3130
|
});
|
|
3012
3131
|
|
|
3013
3132
|
const generateUserAgreement = {
|
|
@@ -3016,7 +3135,7 @@ const generateUserAgreement = {
|
|
|
3016
3135
|
name: name$a
|
|
3017
3136
|
};
|
|
3018
3137
|
|
|
3019
|
-
const index$
|
|
3138
|
+
const index$e = {
|
|
3020
3139
|
__proto__: null,
|
|
3021
3140
|
GeneratePrivacyAgreement: generatePrivacyAgreement,
|
|
3022
3141
|
GenerateSignatureAgreement: generateSignatureAgreement,
|
|
@@ -3026,16 +3145,16 @@ const index$a = {
|
|
|
3026
3145
|
|
|
3027
3146
|
const Mutations = {
|
|
3028
3147
|
__proto__: null,
|
|
3029
|
-
Accounts: index$
|
|
3030
|
-
Agreements: index$
|
|
3031
|
-
Auth: index$
|
|
3032
|
-
Branches: index$
|
|
3033
|
-
Extensions: index$
|
|
3034
|
-
FreeDecisions: index$
|
|
3035
|
-
Participants: index$
|
|
3036
|
-
PaymentMethods: index$
|
|
3037
|
-
Payments: index$
|
|
3038
|
-
System: index$
|
|
3148
|
+
Accounts: index$j,
|
|
3149
|
+
Agreements: index$e,
|
|
3150
|
+
Auth: index$i,
|
|
3151
|
+
Branches: index$l,
|
|
3152
|
+
Extensions: index$n,
|
|
3153
|
+
FreeDecisions: index$k,
|
|
3154
|
+
Participants: index$g,
|
|
3155
|
+
PaymentMethods: index$m,
|
|
3156
|
+
Payments: index$f,
|
|
3157
|
+
System: index$h
|
|
3039
3158
|
};
|
|
3040
3159
|
|
|
3041
3160
|
const name$9 = "getExtensions";
|
|
@@ -3049,7 +3168,7 @@ const getExtensions = {
|
|
|
3049
3168
|
query: query$9
|
|
3050
3169
|
};
|
|
3051
3170
|
|
|
3052
|
-
const index$
|
|
3171
|
+
const index$d = {
|
|
3053
3172
|
__proto__: null,
|
|
3054
3173
|
GetExtensions: getExtensions
|
|
3055
3174
|
};
|
|
@@ -3074,7 +3193,7 @@ const getPaymentMethods = {
|
|
|
3074
3193
|
query: query$8
|
|
3075
3194
|
};
|
|
3076
3195
|
|
|
3077
|
-
const index$
|
|
3196
|
+
const index$c = {
|
|
3078
3197
|
__proto__: null,
|
|
3079
3198
|
GetPaymentMethods: getPaymentMethods
|
|
3080
3199
|
};
|
|
@@ -3090,7 +3209,7 @@ const getSystemInfo = {
|
|
|
3090
3209
|
query: query$7
|
|
3091
3210
|
};
|
|
3092
3211
|
|
|
3093
|
-
const index$
|
|
3212
|
+
const index$b = {
|
|
3094
3213
|
__proto__: null,
|
|
3095
3214
|
GetSystemInfo: getSystemInfo
|
|
3096
3215
|
};
|
|
@@ -3120,7 +3239,7 @@ const getAccounts = {
|
|
|
3120
3239
|
query: query$5
|
|
3121
3240
|
};
|
|
3122
3241
|
|
|
3123
|
-
const index$
|
|
3242
|
+
const index$a = {
|
|
3124
3243
|
__proto__: null,
|
|
3125
3244
|
GetAccount: getAccount,
|
|
3126
3245
|
GetAccounts: getAccounts
|
|
@@ -3148,7 +3267,7 @@ const getPublicBranches = {
|
|
|
3148
3267
|
query: query$3
|
|
3149
3268
|
};
|
|
3150
3269
|
|
|
3151
|
-
const index$
|
|
3270
|
+
const index$9 = {
|
|
3152
3271
|
__proto__: null,
|
|
3153
3272
|
GetBranches: getBranches,
|
|
3154
3273
|
GetPublicBranches: getPublicBranches
|
|
@@ -3165,7 +3284,7 @@ const getPayments = {
|
|
|
3165
3284
|
query: query$2
|
|
3166
3285
|
};
|
|
3167
3286
|
|
|
3168
|
-
const index$
|
|
3287
|
+
const index$8 = {
|
|
3169
3288
|
__proto__: null,
|
|
3170
3289
|
GetPayments: getPayments
|
|
3171
3290
|
};
|
|
@@ -3229,7 +3348,7 @@ const getDocuments = {
|
|
|
3229
3348
|
query: query$1
|
|
3230
3349
|
};
|
|
3231
3350
|
|
|
3232
|
-
const index$
|
|
3351
|
+
const index$7 = {
|
|
3233
3352
|
__proto__: null,
|
|
3234
3353
|
GetDocuments: getDocuments
|
|
3235
3354
|
};
|
|
@@ -3280,75 +3399,101 @@ const getAgenda = {
|
|
|
3280
3399
|
query: query
|
|
3281
3400
|
};
|
|
3282
3401
|
|
|
3283
|
-
const index$
|
|
3402
|
+
const index$6 = {
|
|
3284
3403
|
__proto__: null,
|
|
3285
3404
|
GetAgenda: getAgenda
|
|
3286
3405
|
};
|
|
3287
3406
|
|
|
3288
|
-
const index$
|
|
3407
|
+
const index$5 = {
|
|
3289
3408
|
__proto__: null,
|
|
3290
|
-
Accounts: index$
|
|
3291
|
-
Agenda: index$
|
|
3292
|
-
Branches: index$
|
|
3293
|
-
Documents: index$
|
|
3294
|
-
Extensions: index$
|
|
3295
|
-
PaymentMethods: index$
|
|
3296
|
-
Payments: index$
|
|
3297
|
-
System: index$
|
|
3409
|
+
Accounts: index$a,
|
|
3410
|
+
Agenda: index$6,
|
|
3411
|
+
Branches: index$9,
|
|
3412
|
+
Documents: index$7,
|
|
3413
|
+
Extensions: index$d,
|
|
3414
|
+
PaymentMethods: index$c,
|
|
3415
|
+
Payments: index$8,
|
|
3416
|
+
System: index$b
|
|
3298
3417
|
};
|
|
3299
3418
|
|
|
3300
|
-
const index = {
|
|
3419
|
+
const index$4 = {
|
|
3301
3420
|
__proto__: null
|
|
3302
3421
|
};
|
|
3303
3422
|
|
|
3423
|
+
const index$3 = {
|
|
3424
|
+
__proto__: null
|
|
3425
|
+
};
|
|
3426
|
+
|
|
3427
|
+
const index$2 = {
|
|
3428
|
+
__proto__: null
|
|
3429
|
+
};
|
|
3430
|
+
|
|
3431
|
+
const index$1 = {
|
|
3432
|
+
__proto__: null
|
|
3433
|
+
};
|
|
3434
|
+
|
|
3435
|
+
const index = {
|
|
3436
|
+
__proto__: null,
|
|
3437
|
+
Blockchain: index$4,
|
|
3438
|
+
Client: index$3,
|
|
3439
|
+
Controller: index$2,
|
|
3440
|
+
Document: index$1
|
|
3441
|
+
};
|
|
3442
|
+
|
|
3443
|
+
var __defProp = Object.defineProperty;
|
|
3444
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3445
|
+
var __publicField = (obj, key, value) => {
|
|
3446
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3447
|
+
return value;
|
|
3448
|
+
};
|
|
3304
3449
|
if (typeof globalThis.WebSocket === "undefined") {
|
|
3305
3450
|
globalThis.WebSocket = WebSocket;
|
|
3306
3451
|
}
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3452
|
+
const _Client = class _Client {
|
|
3453
|
+
constructor(options) {
|
|
3454
|
+
this.options = options;
|
|
3455
|
+
__publicField(this, "currentHeaders", {});
|
|
3456
|
+
__publicField(this, "blockchain");
|
|
3457
|
+
__publicField(this, "document");
|
|
3458
|
+
__publicField(this, "thunder");
|
|
3459
|
+
this.currentHeaders = options.headers || {};
|
|
3460
|
+
this.thunder = _Client.createThunder(options.api_url);
|
|
3461
|
+
this.blockchain = new Blockchain(options);
|
|
3462
|
+
this.document = new Document(options.wif);
|
|
3463
|
+
if (options.wif && options.username) {
|
|
3464
|
+
this.blockchain.setWif(options.username, options.wif);
|
|
3465
|
+
this.document.setWif(options.wif);
|
|
3466
|
+
} else if (options.wif && !options.username || !options.wif && options.username) {
|
|
3467
|
+
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");
|
|
3468
|
+
}
|
|
3314
3469
|
}
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
"Content-Type": "application/json",
|
|
3323
|
-
...currentHeaders
|
|
3324
|
-
// Используем текущие заголовки, включая Authorization
|
|
3325
|
-
}
|
|
3326
|
-
});
|
|
3327
|
-
if (!response.ok) {
|
|
3328
|
-
return new Promise((resolve, reject) => {
|
|
3329
|
-
response.text().then((text) => {
|
|
3330
|
-
try {
|
|
3331
|
-
reject(JSON.parse(text));
|
|
3332
|
-
} catch (err) {
|
|
3333
|
-
reject(text);
|
|
3334
|
-
}
|
|
3335
|
-
}).catch(reject);
|
|
3336
|
-
});
|
|
3470
|
+
/**
|
|
3471
|
+
* Инициализация клиента с заданными опциями.
|
|
3472
|
+
* @param options Параметры соединения.
|
|
3473
|
+
*/
|
|
3474
|
+
static create(options) {
|
|
3475
|
+
if (!this.instance) {
|
|
3476
|
+
this.instance = new _Client(options);
|
|
3337
3477
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3478
|
+
return this.getInstance();
|
|
3479
|
+
}
|
|
3480
|
+
/**
|
|
3481
|
+
* Возвращает текущий экземпляр клиента.
|
|
3482
|
+
*/
|
|
3483
|
+
static getInstance() {
|
|
3484
|
+
if (!this.instance) {
|
|
3485
|
+
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.");
|
|
3342
3486
|
}
|
|
3343
|
-
return
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3487
|
+
return this.instance;
|
|
3488
|
+
}
|
|
3489
|
+
/**
|
|
3490
|
+
* Логин пользователя с использованием email и WIF.
|
|
3491
|
+
* @param email Email пользователя.
|
|
3492
|
+
* @param wif Приватный ключ в формате WIF.
|
|
3493
|
+
* @returns Результат логина.
|
|
3494
|
+
*/
|
|
3495
|
+
async login(email, wif) {
|
|
3496
|
+
const now = (await this.blockchain.getInfo()).head_block_time.toString();
|
|
3352
3497
|
const privateKey = PrivateKey$1.fromString(wif);
|
|
3353
3498
|
const bytes = Bytes.fromString(now, "utf8");
|
|
3354
3499
|
const checksum = Checksum256.hash(bytes);
|
|
@@ -3360,30 +3505,99 @@ function createClient(options) {
|
|
|
3360
3505
|
signature
|
|
3361
3506
|
}
|
|
3362
3507
|
};
|
|
3363
|
-
const { [name$p]: result } = await thunder("mutation")(
|
|
3508
|
+
const { [name$p]: result } = await this.thunder("mutation")(
|
|
3364
3509
|
mutation$f,
|
|
3365
3510
|
{
|
|
3366
3511
|
variables
|
|
3367
3512
|
}
|
|
3368
3513
|
);
|
|
3369
|
-
|
|
3514
|
+
const username = result.account.username;
|
|
3515
|
+
this.blockchain.setWif(username, wif);
|
|
3516
|
+
this.document.setWif(wif);
|
|
3517
|
+
this.currentHeaders.Authorization = `Bearer ${result.tokens.access.token}`;
|
|
3370
3518
|
return result;
|
|
3371
3519
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3520
|
+
/**
|
|
3521
|
+
* Установка токена авторизации.
|
|
3522
|
+
* @param token Токен для заголовков Authorization.
|
|
3523
|
+
*/
|
|
3524
|
+
setToken(token) {
|
|
3525
|
+
this.currentHeaders.Authorization = `Bearer ${token}`;
|
|
3376
3526
|
}
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3527
|
+
/**
|
|
3528
|
+
* Доступ к Blockchain.
|
|
3529
|
+
*/
|
|
3530
|
+
get Blockchain() {
|
|
3531
|
+
return this.blockchain;
|
|
3532
|
+
}
|
|
3533
|
+
/**
|
|
3534
|
+
* Доступ к Document.
|
|
3535
|
+
*/
|
|
3536
|
+
get Document() {
|
|
3537
|
+
return this.document;
|
|
3538
|
+
}
|
|
3539
|
+
/**
|
|
3540
|
+
* Доступ к GraphQL-запросам.
|
|
3541
|
+
*/
|
|
3542
|
+
get Query() {
|
|
3543
|
+
return this.thunder("query");
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* Доступ к GraphQL-мутациям.
|
|
3547
|
+
*/
|
|
3548
|
+
get Mutation() {
|
|
3549
|
+
return this.thunder("mutation");
|
|
3550
|
+
}
|
|
3551
|
+
/**
|
|
3552
|
+
* Подписка на GraphQL-события.
|
|
3553
|
+
*/
|
|
3554
|
+
get Subscription() {
|
|
3555
|
+
return Subscription(this.options.api_url.replace(/^http/, "ws"));
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* Создает функцию Thunder для выполнения GraphQL-запросов.
|
|
3559
|
+
* @param baseUrl URL GraphQL API.
|
|
3560
|
+
* @returns Функция Thunder.
|
|
3561
|
+
*/
|
|
3562
|
+
static createThunder(baseUrl) {
|
|
3563
|
+
return Thunder(async (query, variables) => {
|
|
3564
|
+
const response = await fetch(baseUrl, {
|
|
3565
|
+
body: JSON.stringify({ query, variables }),
|
|
3566
|
+
method: "POST",
|
|
3567
|
+
headers: {
|
|
3568
|
+
"Content-Type": "application/json",
|
|
3569
|
+
..._Client.getInstance().currentHeaders
|
|
3570
|
+
}
|
|
3571
|
+
});
|
|
3572
|
+
if (!response.ok) {
|
|
3573
|
+
return new Promise((resolve, reject) => {
|
|
3574
|
+
response.text().then((text) => {
|
|
3575
|
+
try {
|
|
3576
|
+
reject(JSON.parse(text));
|
|
3577
|
+
} catch {
|
|
3578
|
+
reject(text);
|
|
3579
|
+
}
|
|
3580
|
+
}).catch(reject);
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
const json = await response.json();
|
|
3584
|
+
if (json.errors) {
|
|
3585
|
+
console.log("json.errors", json.errors);
|
|
3586
|
+
throw json.errors;
|
|
3587
|
+
}
|
|
3588
|
+
return json.data;
|
|
3589
|
+
}, { scalars: _Client.scalars });
|
|
3590
|
+
}
|
|
3591
|
+
};
|
|
3592
|
+
__publicField(_Client, "instance", null);
|
|
3593
|
+
__publicField(_Client, "scalars", ZeusScalars({
|
|
3594
|
+
DateTime: {
|
|
3595
|
+
decode: (e) => new Date(e),
|
|
3596
|
+
// Преобразует строку в объект Date
|
|
3597
|
+
encode: (e) => e.toISOString()
|
|
3598
|
+
// Преобразует Date в ISO-строку
|
|
3599
|
+
}
|
|
3600
|
+
}));
|
|
3601
|
+
let Client = _Client;
|
|
3388
3602
|
|
|
3389
|
-
export { Classes, Mutations, index$
|
|
3603
|
+
export { Classes, Client, Mutations, index$5 as Queries, index as Types, index$o as Zeus };
|