@coopenomics/sdk 2.2.4 → 2.2.5
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 +451 -231
- package/dist/index.d.cts +647 -441
- package/dist/index.d.mts +647 -441
- package/dist/index.d.ts +647 -441
- package/dist/index.mjs +451 -231
- 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;
|
|
195
|
-
}
|
|
196
|
-
async transact(actionOrActions, broadcast = true) {
|
|
197
|
-
if (!this.session)
|
|
198
|
-
throw new Error("Session is not initialized.");
|
|
199
|
-
const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
|
|
200
|
-
return this.session.transact({ actions }, { broadcast });
|
|
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));
|
|
333
|
+
constructor(wifKey) {
|
|
334
|
+
__publicField$1(this, "wif");
|
|
335
|
+
if (wifKey)
|
|
336
|
+
this.wif = PrivateKey.fromString(wifKey);
|
|
207
337
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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 = {
|
|
@@ -327,7 +458,6 @@ const AllTypesProps = {
|
|
|
327
458
|
soviet: "SovietMemberInput"
|
|
328
459
|
},
|
|
329
460
|
JSON: `scalar.JSON`,
|
|
330
|
-
LangType: "enum",
|
|
331
461
|
LoginInput: {},
|
|
332
462
|
LogoutInput: {},
|
|
333
463
|
MetaDocumentInput: {},
|
|
@@ -885,7 +1015,7 @@ const ReturnTypes = {
|
|
|
885
1015
|
created_at: "String",
|
|
886
1016
|
decision_id: "Float",
|
|
887
1017
|
generator: "String",
|
|
888
|
-
lang: "
|
|
1018
|
+
lang: "String",
|
|
889
1019
|
links: "String",
|
|
890
1020
|
project_id: "String",
|
|
891
1021
|
registry_id: "Int",
|
|
@@ -922,7 +1052,7 @@ const ReturnTypes = {
|
|
|
922
1052
|
coopname: "String",
|
|
923
1053
|
created_at: "String",
|
|
924
1054
|
generator: "String",
|
|
925
|
-
lang: "
|
|
1055
|
+
lang: "String",
|
|
926
1056
|
links: "String",
|
|
927
1057
|
registry_id: "Int",
|
|
928
1058
|
timezone: "String",
|
|
@@ -1030,7 +1160,7 @@ const ReturnTypes = {
|
|
|
1030
1160
|
created_at: "String",
|
|
1031
1161
|
decision_id: "Float",
|
|
1032
1162
|
generator: "String",
|
|
1033
|
-
lang: "
|
|
1163
|
+
lang: "String",
|
|
1034
1164
|
links: "String",
|
|
1035
1165
|
registry_id: "Int",
|
|
1036
1166
|
timezone: "String",
|
|
@@ -1050,7 +1180,7 @@ const ReturnTypes = {
|
|
|
1050
1180
|
coopname: "String",
|
|
1051
1181
|
created_at: "String",
|
|
1052
1182
|
generator: "String",
|
|
1053
|
-
lang: "
|
|
1183
|
+
lang: "String",
|
|
1054
1184
|
links: "String",
|
|
1055
1185
|
registry_id: "Int",
|
|
1056
1186
|
timezone: "String",
|
|
@@ -1138,7 +1268,7 @@ const ReturnTypes = {
|
|
|
1138
1268
|
coopname: "String",
|
|
1139
1269
|
created_at: "String",
|
|
1140
1270
|
generator: "String",
|
|
1141
|
-
lang: "
|
|
1271
|
+
lang: "String",
|
|
1142
1272
|
links: "String",
|
|
1143
1273
|
project_id: "String",
|
|
1144
1274
|
registry_id: "Int",
|
|
@@ -1208,7 +1338,7 @@ const ReturnTypes = {
|
|
|
1208
1338
|
coopname: "String",
|
|
1209
1339
|
created_at: "String",
|
|
1210
1340
|
generator: "String",
|
|
1211
|
-
lang: "
|
|
1341
|
+
lang: "String",
|
|
1212
1342
|
links: "String",
|
|
1213
1343
|
registry_id: "Int",
|
|
1214
1344
|
timezone: "String",
|
|
@@ -1303,7 +1433,7 @@ const Ops = {
|
|
|
1303
1433
|
const HOST = "Specify host";
|
|
1304
1434
|
const HEADERS = {};
|
|
1305
1435
|
const apiSubscription = (options) => {
|
|
1306
|
-
const client = createClient
|
|
1436
|
+
const client = createClient({
|
|
1307
1437
|
url: String(options[0]),
|
|
1308
1438
|
connectionParams: Object.fromEntries(new Headers(options[1]?.headers).entries())
|
|
1309
1439
|
});
|
|
@@ -1823,10 +1953,6 @@ var Country = /* @__PURE__ */ ((Country2) => {
|
|
|
1823
1953
|
Country2["Russia"] = "Russia";
|
|
1824
1954
|
return Country2;
|
|
1825
1955
|
})(Country || {});
|
|
1826
|
-
var LangType = /* @__PURE__ */ ((LangType2) => {
|
|
1827
|
-
LangType2["ru"] = "ru";
|
|
1828
|
-
return LangType2;
|
|
1829
|
-
})(LangType || {});
|
|
1830
1956
|
var OrganizationType = /* @__PURE__ */ ((OrganizationType2) => {
|
|
1831
1957
|
OrganizationType2["AO"] = "AO";
|
|
1832
1958
|
OrganizationType2["COOP"] = "COOP";
|
|
@@ -1867,7 +1993,7 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
|
1867
1993
|
return UserStatus2;
|
|
1868
1994
|
})(UserStatus || {});
|
|
1869
1995
|
|
|
1870
|
-
const index$
|
|
1996
|
+
const index$o = {
|
|
1871
1997
|
__proto__: null,
|
|
1872
1998
|
$: $,
|
|
1873
1999
|
AccountType: AccountType,
|
|
@@ -1880,7 +2006,6 @@ const index$k = {
|
|
|
1880
2006
|
HOST: HOST,
|
|
1881
2007
|
InternalArgsBuilt: InternalArgsBuilt,
|
|
1882
2008
|
InternalsBuildQuery: InternalsBuildQuery,
|
|
1883
|
-
LangType: LangType,
|
|
1884
2009
|
OrganizationType: OrganizationType,
|
|
1885
2010
|
PaymentStatus: PaymentStatus,
|
|
1886
2011
|
PrepareScalarPaths: PrepareScalarPaths,
|
|
@@ -1958,7 +2083,7 @@ const updateExtension = {
|
|
|
1958
2083
|
name: name$K
|
|
1959
2084
|
};
|
|
1960
2085
|
|
|
1961
|
-
const index$
|
|
2086
|
+
const index$n = {
|
|
1962
2087
|
__proto__: null,
|
|
1963
2088
|
InstallExtension: installExtension,
|
|
1964
2089
|
UninstallExtension: uninstallExtension,
|
|
@@ -2028,7 +2153,7 @@ const updateBankAccount = {
|
|
|
2028
2153
|
name: name$H
|
|
2029
2154
|
};
|
|
2030
2155
|
|
|
2031
|
-
const index$
|
|
2156
|
+
const index$m = {
|
|
2032
2157
|
__proto__: null,
|
|
2033
2158
|
CreateBankAccount: createBankAccount,
|
|
2034
2159
|
DeletePaymentMethod: deletePaymentMethod,
|
|
@@ -2594,7 +2719,7 @@ const selectBranch = {
|
|
|
2594
2719
|
|
|
2595
2720
|
const name$A = "generateSelectBranchDocument";
|
|
2596
2721
|
const mutation$q = Selector("Mutation")({
|
|
2597
|
-
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2722
|
+
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, generateSelectBranchDocumentSelector]
|
|
2598
2723
|
});
|
|
2599
2724
|
|
|
2600
2725
|
const generateSelectBranchDocument = {
|
|
@@ -2603,7 +2728,7 @@ const generateSelectBranchDocument = {
|
|
|
2603
2728
|
name: name$A
|
|
2604
2729
|
};
|
|
2605
2730
|
|
|
2606
|
-
const index$
|
|
2731
|
+
const index$l = {
|
|
2607
2732
|
__proto__: null,
|
|
2608
2733
|
AddTrustedAccount: addTrustedAccount,
|
|
2609
2734
|
CreateBranch: createBranch,
|
|
@@ -2626,7 +2751,7 @@ const projectFreeDecisionDocumentSelector = Selector("ProjectFreeDecisionDocumen
|
|
|
2626
2751
|
|
|
2627
2752
|
const name$z = "generateProjectOfFreeDecision";
|
|
2628
2753
|
const mutation$p = Selector("Mutation")({
|
|
2629
|
-
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2754
|
+
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, projectFreeDecisionDocumentSelector]
|
|
2630
2755
|
});
|
|
2631
2756
|
|
|
2632
2757
|
const generateProjectOfFreeDecisionDocument = {
|
|
@@ -2656,7 +2781,7 @@ const createdProjectFreeDecisionSelector = Selector("CreatedProjectFreeDecision"
|
|
|
2656
2781
|
|
|
2657
2782
|
const name$y = "generateFreeDecision";
|
|
2658
2783
|
const mutation$o = Selector("Mutation")({
|
|
2659
|
-
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2784
|
+
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, freeDecisionDocumentSelector]
|
|
2660
2785
|
});
|
|
2661
2786
|
|
|
2662
2787
|
const generateFreeDecision = {
|
|
@@ -2687,7 +2812,7 @@ const createProjectOfFreeDecision = {
|
|
|
2687
2812
|
name: name$w
|
|
2688
2813
|
};
|
|
2689
2814
|
|
|
2690
|
-
const index$
|
|
2815
|
+
const index$k = {
|
|
2691
2816
|
__proto__: null,
|
|
2692
2817
|
CreateProjectOfFreeDecision: createProjectOfFreeDecision,
|
|
2693
2818
|
GenerateFreeDecision: generateFreeDecision,
|
|
@@ -2755,7 +2880,7 @@ const resetKey = {
|
|
|
2755
2880
|
name: name$s
|
|
2756
2881
|
};
|
|
2757
2882
|
|
|
2758
|
-
const index$
|
|
2883
|
+
const index$j = {
|
|
2759
2884
|
__proto__: null,
|
|
2760
2885
|
RegisterAccount: registerAccount,
|
|
2761
2886
|
ResetKey: resetKey,
|
|
@@ -2796,7 +2921,7 @@ const login = {
|
|
|
2796
2921
|
name: name$p
|
|
2797
2922
|
};
|
|
2798
2923
|
|
|
2799
|
-
const index$
|
|
2924
|
+
const index$i = {
|
|
2800
2925
|
__proto__: null,
|
|
2801
2926
|
Login: login,
|
|
2802
2927
|
Logout: logout,
|
|
@@ -2847,7 +2972,7 @@ const updateSystem = {
|
|
|
2847
2972
|
name: name$l
|
|
2848
2973
|
};
|
|
2849
2974
|
|
|
2850
|
-
const index$
|
|
2975
|
+
const index$h = {
|
|
2851
2976
|
__proto__: null,
|
|
2852
2977
|
InitSystem: initSystem,
|
|
2853
2978
|
InstallSystem: installSystem,
|
|
@@ -2857,7 +2982,7 @@ const index$d = {
|
|
|
2857
2982
|
|
|
2858
2983
|
const name$k = "generateParticipantApplication";
|
|
2859
2984
|
const mutation$a = Selector("Mutation")({
|
|
2860
|
-
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2985
|
+
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDocumentSelector]
|
|
2861
2986
|
});
|
|
2862
2987
|
|
|
2863
2988
|
const generateParticipantApplication = {
|
|
@@ -2868,7 +2993,7 @@ const generateParticipantApplication = {
|
|
|
2868
2993
|
|
|
2869
2994
|
const name$j = "generateParticipantApplicationDecision";
|
|
2870
2995
|
const mutation$9 = Selector("Mutation")({
|
|
2871
|
-
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2996
|
+
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDecisionDocumentSelector]
|
|
2872
2997
|
});
|
|
2873
2998
|
|
|
2874
2999
|
const generateParticipantApplicationDecision = {
|
|
@@ -2899,7 +3024,7 @@ const addParticipant = {
|
|
|
2899
3024
|
name: name$h
|
|
2900
3025
|
};
|
|
2901
3026
|
|
|
2902
|
-
const index$
|
|
3027
|
+
const index$g = {
|
|
2903
3028
|
__proto__: null,
|
|
2904
3029
|
AddParticipant: addParticipant,
|
|
2905
3030
|
GenerateParticipantApplication: generateParticipantApplication,
|
|
@@ -2965,7 +3090,7 @@ const setPaymentStatus = {
|
|
|
2965
3090
|
name: name$e
|
|
2966
3091
|
};
|
|
2967
3092
|
|
|
2968
|
-
const index$
|
|
3093
|
+
const index$f = {
|
|
2969
3094
|
__proto__: null,
|
|
2970
3095
|
CreateDepositPayment: createDeposit,
|
|
2971
3096
|
CreateInitialPayment: createInitial,
|
|
@@ -2974,7 +3099,7 @@ const index$b = {
|
|
|
2974
3099
|
|
|
2975
3100
|
const name$d = "generatePrivacyAgreement";
|
|
2976
3101
|
const mutation$3 = Selector("Mutation")({
|
|
2977
|
-
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3102
|
+
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2978
3103
|
});
|
|
2979
3104
|
|
|
2980
3105
|
const generatePrivacyAgreement = {
|
|
@@ -2985,7 +3110,7 @@ const generatePrivacyAgreement = {
|
|
|
2985
3110
|
|
|
2986
3111
|
const name$c = "generateSignatureAgreement";
|
|
2987
3112
|
const mutation$2 = Selector("Mutation")({
|
|
2988
|
-
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3113
|
+
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2989
3114
|
});
|
|
2990
3115
|
|
|
2991
3116
|
const generateSignatureAgreement = {
|
|
@@ -2996,7 +3121,7 @@ const generateSignatureAgreement = {
|
|
|
2996
3121
|
|
|
2997
3122
|
const name$b = "generateWalletAgreement";
|
|
2998
3123
|
const mutation$1 = Selector("Mutation")({
|
|
2999
|
-
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3124
|
+
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3000
3125
|
});
|
|
3001
3126
|
|
|
3002
3127
|
const generateWalletAgreement = {
|
|
@@ -3007,7 +3132,7 @@ const generateWalletAgreement = {
|
|
|
3007
3132
|
|
|
3008
3133
|
const name$a = "generateUserAgreement";
|
|
3009
3134
|
const mutation = Selector("Mutation")({
|
|
3010
|
-
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3135
|
+
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3011
3136
|
});
|
|
3012
3137
|
|
|
3013
3138
|
const generateUserAgreement = {
|
|
@@ -3016,7 +3141,7 @@ const generateUserAgreement = {
|
|
|
3016
3141
|
name: name$a
|
|
3017
3142
|
};
|
|
3018
3143
|
|
|
3019
|
-
const index$
|
|
3144
|
+
const index$e = {
|
|
3020
3145
|
__proto__: null,
|
|
3021
3146
|
GeneratePrivacyAgreement: generatePrivacyAgreement,
|
|
3022
3147
|
GenerateSignatureAgreement: generateSignatureAgreement,
|
|
@@ -3026,16 +3151,16 @@ const index$a = {
|
|
|
3026
3151
|
|
|
3027
3152
|
const Mutations = {
|
|
3028
3153
|
__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$
|
|
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
|
|
3039
3164
|
};
|
|
3040
3165
|
|
|
3041
3166
|
const name$9 = "getExtensions";
|
|
@@ -3049,7 +3174,7 @@ const getExtensions = {
|
|
|
3049
3174
|
query: query$9
|
|
3050
3175
|
};
|
|
3051
3176
|
|
|
3052
|
-
const index$
|
|
3177
|
+
const index$d = {
|
|
3053
3178
|
__proto__: null,
|
|
3054
3179
|
GetExtensions: getExtensions
|
|
3055
3180
|
};
|
|
@@ -3074,7 +3199,7 @@ const getPaymentMethods = {
|
|
|
3074
3199
|
query: query$8
|
|
3075
3200
|
};
|
|
3076
3201
|
|
|
3077
|
-
const index$
|
|
3202
|
+
const index$c = {
|
|
3078
3203
|
__proto__: null,
|
|
3079
3204
|
GetPaymentMethods: getPaymentMethods
|
|
3080
3205
|
};
|
|
@@ -3090,7 +3215,7 @@ const getSystemInfo = {
|
|
|
3090
3215
|
query: query$7
|
|
3091
3216
|
};
|
|
3092
3217
|
|
|
3093
|
-
const index$
|
|
3218
|
+
const index$b = {
|
|
3094
3219
|
__proto__: null,
|
|
3095
3220
|
GetSystemInfo: getSystemInfo
|
|
3096
3221
|
};
|
|
@@ -3120,7 +3245,7 @@ const getAccounts = {
|
|
|
3120
3245
|
query: query$5
|
|
3121
3246
|
};
|
|
3122
3247
|
|
|
3123
|
-
const index$
|
|
3248
|
+
const index$a = {
|
|
3124
3249
|
__proto__: null,
|
|
3125
3250
|
GetAccount: getAccount,
|
|
3126
3251
|
GetAccounts: getAccounts
|
|
@@ -3148,7 +3273,7 @@ const getPublicBranches = {
|
|
|
3148
3273
|
query: query$3
|
|
3149
3274
|
};
|
|
3150
3275
|
|
|
3151
|
-
const index$
|
|
3276
|
+
const index$9 = {
|
|
3152
3277
|
__proto__: null,
|
|
3153
3278
|
GetBranches: getBranches,
|
|
3154
3279
|
GetPublicBranches: getPublicBranches
|
|
@@ -3165,7 +3290,7 @@ const getPayments = {
|
|
|
3165
3290
|
query: query$2
|
|
3166
3291
|
};
|
|
3167
3292
|
|
|
3168
|
-
const index$
|
|
3293
|
+
const index$8 = {
|
|
3169
3294
|
__proto__: null,
|
|
3170
3295
|
GetPayments: getPayments
|
|
3171
3296
|
};
|
|
@@ -3229,7 +3354,7 @@ const getDocuments = {
|
|
|
3229
3354
|
query: query$1
|
|
3230
3355
|
};
|
|
3231
3356
|
|
|
3232
|
-
const index$
|
|
3357
|
+
const index$7 = {
|
|
3233
3358
|
__proto__: null,
|
|
3234
3359
|
GetDocuments: getDocuments
|
|
3235
3360
|
};
|
|
@@ -3280,75 +3405,101 @@ const getAgenda = {
|
|
|
3280
3405
|
query: query
|
|
3281
3406
|
};
|
|
3282
3407
|
|
|
3283
|
-
const index$
|
|
3408
|
+
const index$6 = {
|
|
3284
3409
|
__proto__: null,
|
|
3285
3410
|
GetAgenda: getAgenda
|
|
3286
3411
|
};
|
|
3287
3412
|
|
|
3288
|
-
const index$
|
|
3413
|
+
const index$5 = {
|
|
3289
3414
|
__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$
|
|
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
|
|
3298
3423
|
};
|
|
3299
3424
|
|
|
3300
|
-
const index = {
|
|
3425
|
+
const index$4 = {
|
|
3301
3426
|
__proto__: null
|
|
3302
3427
|
};
|
|
3303
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
|
+
};
|
|
3304
3455
|
if (typeof globalThis.WebSocket === "undefined") {
|
|
3305
3456
|
globalThis.WebSocket = WebSocket;
|
|
3306
3457
|
}
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
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
|
+
}
|
|
3314
3475
|
}
|
|
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
|
-
});
|
|
3476
|
+
/**
|
|
3477
|
+
* Инициализация клиента с заданными опциями.
|
|
3478
|
+
* @param options Параметры соединения.
|
|
3479
|
+
*/
|
|
3480
|
+
static create(options) {
|
|
3481
|
+
if (!this.instance) {
|
|
3482
|
+
this.instance = new _Client(options);
|
|
3337
3483
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
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.");
|
|
3342
3492
|
}
|
|
3343
|
-
return
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
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();
|
|
3352
3503
|
const privateKey = PrivateKey$1.fromString(wif);
|
|
3353
3504
|
const bytes = Bytes.fromString(now, "utf8");
|
|
3354
3505
|
const checksum = Checksum256.hash(bytes);
|
|
@@ -3360,30 +3511,99 @@ function createClient(options) {
|
|
|
3360
3511
|
signature
|
|
3361
3512
|
}
|
|
3362
3513
|
};
|
|
3363
|
-
const { [name$p]: result } = await thunder("mutation")(
|
|
3514
|
+
const { [name$p]: result } = await this.thunder("mutation")(
|
|
3364
3515
|
mutation$f,
|
|
3365
3516
|
{
|
|
3366
3517
|
variables
|
|
3367
3518
|
}
|
|
3368
3519
|
);
|
|
3369
|
-
|
|
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}`;
|
|
3370
3524
|
return result;
|
|
3371
3525
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3526
|
+
/**
|
|
3527
|
+
* Установка токена авторизации.
|
|
3528
|
+
* @param token Токен для заголовков Authorization.
|
|
3529
|
+
*/
|
|
3530
|
+
setToken(token) {
|
|
3531
|
+
this.currentHeaders.Authorization = `Bearer ${token}`;
|
|
3376
3532
|
}
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
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;
|
|
3388
3608
|
|
|
3389
|
-
export { Classes, Mutations, index$
|
|
3609
|
+
export { Classes, Client, Mutations, index$5 as Queries, index as Types, index$o as Zeus };
|