@coopenomics/sdk 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,16 +1,111 @@
1
1
  'use strict';
2
2
 
3
+ const session = require('@wharfkit/session');
3
4
  const WebSocket = require('isomorphic-ws');
4
- const graphqlWs = require('graphql-ws');
5
5
  const antelope = require('@wharfkit/antelope');
6
6
  const contract = require('@wharfkit/contract');
7
- const session = require('@wharfkit/session');
8
7
  const walletPluginPrivatekey = require('@wharfkit/wallet-plugin-privatekey');
8
+ const graphqlWs = require('graphql-ws');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
11
 
12
12
  const WebSocket__default = /*#__PURE__*/_interopDefaultCompat(WebSocket);
13
13
 
14
+ var __defProp = Object.defineProperty;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
+ var __publicField = (obj, key, value) => {
17
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
18
+ return value;
19
+ };
20
+ class Wallet {
21
+ constructor(config) {
22
+ this.config = config;
23
+ __publicField(this, "apiClient");
24
+ __publicField(this, "contractKit");
25
+ __publicField(this, "session");
26
+ this.apiClient = new antelope.APIClient({ url: config.chain_url });
27
+ this.contractKit = new contract.ContractKit({ client: this.apiClient });
28
+ }
29
+ async getInfo() {
30
+ return this.apiClient.v1.chain.get_info();
31
+ }
32
+ /**
33
+ * Метод установки приватного ключа в кошелёк
34
+ * @param username - имя пользователя
35
+ * @param wif - приватный ключ
36
+ * @returns
37
+ */
38
+ setWif(username, wif) {
39
+ this.session = new session.Session({
40
+ actor: username,
41
+ permission: "active",
42
+ chain: {
43
+ id: this.config.chain_id,
44
+ url: this.config.chain_url
45
+ },
46
+ walletPlugin: new walletPluginPrivatekey.WalletPluginPrivateKey(antelope.PrivateKey.fromString(wif))
47
+ });
48
+ return this;
49
+ }
50
+ async transact(actionOrActions, broadcast = true) {
51
+ if (!this.session)
52
+ throw new Error("Session is not initialized.");
53
+ const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
54
+ return this.session.transact({ actions }, { broadcast });
55
+ }
56
+ async getAllRows(code, scope, tableName) {
57
+ const abi = await this.getAbi(code);
58
+ const table = this.createTable(code, tableName, abi);
59
+ const rows = await table.all({ scope });
60
+ return JSON.parse(JSON.stringify(rows));
61
+ }
62
+ async query(code, scope, tableName, options = { indexPosition: "primary" }) {
63
+ const { indexPosition = "primary", from, to, maxRows } = options;
64
+ const abi = await this.getAbi(code);
65
+ const table = this.createTable(code, tableName, abi);
66
+ const rows = await table.query({
67
+ scope,
68
+ index_position: indexPosition,
69
+ from,
70
+ to,
71
+ maxRows
72
+ });
73
+ return JSON.parse(JSON.stringify(rows));
74
+ }
75
+ async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
76
+ const abi = await this.getAbi(code);
77
+ const table = this.createTable(code, tableName, abi);
78
+ const row = await table.get(String(primaryKey), {
79
+ scope,
80
+ index_position: indexPosition
81
+ });
82
+ return row ? JSON.parse(JSON.stringify(row)) : null;
83
+ }
84
+ async formActionFromAbi(action) {
85
+ const abi = await this.getAbi(action.account);
86
+ return antelope.Action.from(action, abi);
87
+ }
88
+ async getAbi(account) {
89
+ const { abi } = await this.apiClient.v1.chain.get_abi(account);
90
+ if (!abi)
91
+ throw new Error(`ABI for account "${account}" not found.`);
92
+ return abi;
93
+ }
94
+ createTable(code, tableName, abi) {
95
+ return new contract.Table({
96
+ abi,
97
+ account: code,
98
+ name: tableName,
99
+ client: this.apiClient
100
+ });
101
+ }
102
+ }
103
+
104
+ const Classes = {
105
+ __proto__: null,
106
+ Wallet: Wallet
107
+ };
108
+
14
109
  const AllTypesProps = {
15
110
  AccountType: "enum",
16
111
  AddParticipantInput: {
@@ -1614,136 +1709,44 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
1614
1709
  return UserStatus2;
1615
1710
  })(UserStatus || {});
1616
1711
 
1617
- const index$l = {
1618
- __proto__: null,
1619
- $: $,
1620
- AccountType: AccountType,
1621
- Chain: Chain,
1622
- Country: Country,
1623
- GRAPHQL_TYPE_SEPARATOR: GRAPHQL_TYPE_SEPARATOR,
1624
- Gql: Gql,
1625
- GraphQLError: GraphQLError,
1626
- HEADERS: HEADERS,
1627
- HOST: HOST,
1628
- InternalArgsBuilt: InternalArgsBuilt,
1629
- InternalsBuildQuery: InternalsBuildQuery,
1630
- LangType: LangType,
1631
- OrganizationType: OrganizationType,
1632
- PaymentStatus: PaymentStatus,
1633
- PrepareScalarPaths: PrepareScalarPaths,
1634
- RegisterRole: RegisterRole,
1635
- ResolveFromPath: ResolveFromPath,
1636
- SEPARATOR: SEPARATOR,
1637
- START_VAR_NAME: START_VAR_NAME,
1638
- Selector: Selector,
1639
- Subscription: Subscription,
1640
- SubscriptionThunder: SubscriptionThunder,
1641
- SystemStatus: SystemStatus,
1642
- Thunder: Thunder,
1643
- TypeFromSelector: TypeFromSelector,
1644
- UserStatus: UserStatus,
1645
- Zeus: Zeus,
1646
- ZeusScalars: ZeusScalars,
1647
- ZeusSelect: ZeusSelect,
1648
- apiFetch: apiFetch,
1649
- apiSubscription: apiSubscription,
1650
- decodeScalarsInResponse: decodeScalarsInResponse,
1651
- fields: fields,
1652
- purifyGraphQLKey: purifyGraphQLKey,
1653
- resolverFor: resolverFor,
1654
- traverseResponse: traverseResponse
1655
- };
1656
-
1657
- var __defProp = Object.defineProperty;
1658
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1659
- var __publicField = (obj, key, value) => {
1660
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1661
- return value;
1662
- };
1663
- class Wallet {
1664
- constructor(config) {
1665
- this.config = config;
1666
- __publicField(this, "apiClient");
1667
- __publicField(this, "contractKit");
1668
- __publicField(this, "session");
1669
- this.apiClient = new antelope.APIClient({ url: config.chain_url });
1670
- this.contractKit = new contract.ContractKit({ client: this.apiClient });
1671
- }
1672
- /**
1673
- * Метод установки приватного ключа в кошелёк
1674
- * @param username - имя пользователя
1675
- * @param wif - приватный ключ
1676
- * @returns
1677
- */
1678
- setWif(username, wif) {
1679
- this.session = new session.Session({
1680
- actor: username,
1681
- permission: "active",
1682
- chain: {
1683
- id: this.config.chain_id,
1684
- url: this.config.chain_url
1685
- },
1686
- walletPlugin: new walletPluginPrivatekey.WalletPluginPrivateKey(antelope.PrivateKey.fromString(wif))
1687
- });
1688
- return this;
1689
- }
1690
- async transact(actionOrActions, broadcast = true) {
1691
- if (!this.session)
1692
- throw new Error("Session is not initialized.");
1693
- const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
1694
- return this.session.transact({ actions }, { broadcast });
1695
- }
1696
- async getAllRows(code, scope, tableName) {
1697
- const abi = await this.getAbi(code);
1698
- const table = this.createTable(code, tableName, abi);
1699
- const rows = await table.all({ scope });
1700
- return JSON.parse(JSON.stringify(rows));
1701
- }
1702
- async query(code, scope, tableName, options = { indexPosition: "primary" }) {
1703
- const { indexPosition = "primary", from, to, maxRows } = options;
1704
- const abi = await this.getAbi(code);
1705
- const table = this.createTable(code, tableName, abi);
1706
- const rows = await table.query({
1707
- scope,
1708
- index_position: indexPosition,
1709
- from,
1710
- to,
1711
- maxRows
1712
- });
1713
- return JSON.parse(JSON.stringify(rows));
1714
- }
1715
- async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
1716
- const abi = await this.getAbi(code);
1717
- const table = this.createTable(code, tableName, abi);
1718
- const row = await table.get(String(primaryKey), {
1719
- scope,
1720
- index_position: indexPosition
1721
- });
1722
- return row ? JSON.parse(JSON.stringify(row)) : null;
1723
- }
1724
- async formActionFromAbi(action) {
1725
- const abi = await this.getAbi(action.account);
1726
- return antelope.Action.from(action, abi);
1727
- }
1728
- async getAbi(account) {
1729
- const { abi } = await this.apiClient.v1.chain.get_abi(account);
1730
- if (!abi)
1731
- throw new Error(`ABI for account "${account}" not found.`);
1732
- return abi;
1733
- }
1734
- createTable(code, tableName, abi) {
1735
- return new contract.Table({
1736
- abi,
1737
- account: code,
1738
- name: tableName,
1739
- client: this.apiClient
1740
- });
1741
- }
1742
- }
1743
-
1744
- const Classes = {
1745
- __proto__: null,
1746
- Wallet: Wallet
1712
+ const index$k = {
1713
+ __proto__: null,
1714
+ $: $,
1715
+ AccountType: AccountType,
1716
+ Chain: Chain,
1717
+ Country: Country,
1718
+ GRAPHQL_TYPE_SEPARATOR: GRAPHQL_TYPE_SEPARATOR,
1719
+ Gql: Gql,
1720
+ GraphQLError: GraphQLError,
1721
+ HEADERS: HEADERS,
1722
+ HOST: HOST,
1723
+ InternalArgsBuilt: InternalArgsBuilt,
1724
+ InternalsBuildQuery: InternalsBuildQuery,
1725
+ LangType: LangType,
1726
+ OrganizationType: OrganizationType,
1727
+ PaymentStatus: PaymentStatus,
1728
+ PrepareScalarPaths: PrepareScalarPaths,
1729
+ RegisterRole: RegisterRole,
1730
+ ResolveFromPath: ResolveFromPath,
1731
+ SEPARATOR: SEPARATOR,
1732
+ START_VAR_NAME: START_VAR_NAME,
1733
+ Selector: Selector,
1734
+ Subscription: Subscription,
1735
+ SubscriptionThunder: SubscriptionThunder,
1736
+ SystemStatus: SystemStatus,
1737
+ Thunder: Thunder,
1738
+ TypeFromSelector: TypeFromSelector,
1739
+ UserStatus: UserStatus,
1740
+ Zeus: Zeus,
1741
+ ZeusScalars: ZeusScalars,
1742
+ ZeusSelect: ZeusSelect,
1743
+ apiFetch: apiFetch,
1744
+ apiSubscription: apiSubscription,
1745
+ decodeScalarsInResponse: decodeScalarsInResponse,
1746
+ fields: fields,
1747
+ purifyGraphQLKey: purifyGraphQLKey,
1748
+ resolverFor: resolverFor,
1749
+ traverseResponse: traverseResponse
1747
1750
  };
1748
1751
 
1749
1752
  const rawExtensionSelector = {
@@ -1770,9 +1773,9 @@ const mutation$C = Selector("Mutation")({
1770
1773
  });
1771
1774
 
1772
1775
  const installExtension = {
1773
- __proto__: null,
1774
- mutation: mutation$C,
1775
- name: name$M
1776
+ __proto__: null,
1777
+ mutation: mutation$C,
1778
+ name: name$M
1776
1779
  };
1777
1780
 
1778
1781
  const name$L = "uninstallExtension";
@@ -1781,9 +1784,9 @@ const mutation$B = Selector("Mutation")({
1781
1784
  });
1782
1785
 
1783
1786
  const uninstallExtension = {
1784
- __proto__: null,
1785
- mutation: mutation$B,
1786
- name: name$L
1787
+ __proto__: null,
1788
+ mutation: mutation$B,
1789
+ name: name$L
1787
1790
  };
1788
1791
 
1789
1792
  const name$K = "updateExtension";
@@ -1792,16 +1795,16 @@ const mutation$A = Selector("Mutation")({
1792
1795
  });
1793
1796
 
1794
1797
  const updateExtension = {
1795
- __proto__: null,
1796
- mutation: mutation$A,
1797
- name: name$K
1798
+ __proto__: null,
1799
+ mutation: mutation$A,
1800
+ name: name$K
1798
1801
  };
1799
1802
 
1800
- const index$k = {
1801
- __proto__: null,
1802
- InstallExtension: installExtension,
1803
- UninstallExtension: uninstallExtension,
1804
- UpdateExtension: updateExtension
1803
+ const index$j = {
1804
+ __proto__: null,
1805
+ InstallExtension: installExtension,
1806
+ UninstallExtension: uninstallExtension,
1807
+ UpdateExtension: updateExtension
1805
1808
  };
1806
1809
 
1807
1810
  const rawBankAccountSelector = {
@@ -1840,9 +1843,9 @@ const mutation$z = Selector("Mutation")({
1840
1843
  });
1841
1844
 
1842
1845
  const createBankAccount = {
1843
- __proto__: null,
1844
- mutation: mutation$z,
1845
- name: name$J
1846
+ __proto__: null,
1847
+ mutation: mutation$z,
1848
+ name: name$J
1846
1849
  };
1847
1850
 
1848
1851
  const name$I = "deletePaymentMethod";
@@ -1851,9 +1854,9 @@ const mutation$y = Selector("Mutation")({
1851
1854
  });
1852
1855
 
1853
1856
  const deletePaymentMethod = {
1854
- __proto__: null,
1855
- mutation: mutation$y,
1856
- name: name$I
1857
+ __proto__: null,
1858
+ mutation: mutation$y,
1859
+ name: name$I
1857
1860
  };
1858
1861
 
1859
1862
  const name$H = "updateBankAccount";
@@ -1862,16 +1865,16 @@ const mutation$x = Selector("Mutation")({
1862
1865
  });
1863
1866
 
1864
1867
  const updateBankAccount = {
1865
- __proto__: null,
1866
- mutation: mutation$x,
1867
- name: name$H
1868
+ __proto__: null,
1869
+ mutation: mutation$x,
1870
+ name: name$H
1868
1871
  };
1869
1872
 
1870
- const index$j = {
1871
- __proto__: null,
1872
- CreateBankAccount: createBankAccount,
1873
- DeletePaymentMethod: deletePaymentMethod,
1874
- UpdateBankAccount: updateBankAccount
1873
+ const index$i = {
1874
+ __proto__: null,
1875
+ CreateBankAccount: createBankAccount,
1876
+ DeletePaymentMethod: deletePaymentMethod,
1877
+ UpdateBankAccount: updateBankAccount
1875
1878
  };
1876
1879
 
1877
1880
  const rawBlockchainAccountSelector = {
@@ -2371,9 +2374,9 @@ const mutation$w = Selector("Mutation")({
2371
2374
  });
2372
2375
 
2373
2376
  const addTrustedAccount = {
2374
- __proto__: null,
2375
- mutation: mutation$w,
2376
- name: name$G
2377
+ __proto__: null,
2378
+ mutation: mutation$w,
2379
+ name: name$G
2377
2380
  };
2378
2381
 
2379
2382
  const name$F = "createBranch";
@@ -2382,9 +2385,9 @@ const mutation$v = Selector("Mutation")({
2382
2385
  });
2383
2386
 
2384
2387
  const createBranch = {
2385
- __proto__: null,
2386
- mutation: mutation$v,
2387
- name: name$F
2388
+ __proto__: null,
2389
+ mutation: mutation$v,
2390
+ name: name$F
2388
2391
  };
2389
2392
 
2390
2393
  const name$E = "deleteBranch";
@@ -2393,9 +2396,9 @@ const mutation$u = Selector("Mutation")({
2393
2396
  });
2394
2397
 
2395
2398
  const deleteBranch = {
2396
- __proto__: null,
2397
- mutation: mutation$u,
2398
- name: name$E
2399
+ __proto__: null,
2400
+ mutation: mutation$u,
2401
+ name: name$E
2399
2402
  };
2400
2403
 
2401
2404
  const name$D = "deleteTrustedAccount";
@@ -2404,9 +2407,9 @@ const mutation$t = Selector("Mutation")({
2404
2407
  });
2405
2408
 
2406
2409
  const deleteTrustedAccount = {
2407
- __proto__: null,
2408
- mutation: mutation$t,
2409
- name: name$D
2410
+ __proto__: null,
2411
+ mutation: mutation$t,
2412
+ name: name$D
2410
2413
  };
2411
2414
 
2412
2415
  const name$C = "editBranch";
@@ -2415,9 +2418,9 @@ const mutation$s = Selector("Mutation")({
2415
2418
  });
2416
2419
 
2417
2420
  const editBranch = {
2418
- __proto__: null,
2419
- mutation: mutation$s,
2420
- name: name$C
2421
+ __proto__: null,
2422
+ mutation: mutation$s,
2423
+ name: name$C
2421
2424
  };
2422
2425
 
2423
2426
  const name$B = "selectBranch";
@@ -2426,9 +2429,9 @@ const mutation$r = Selector("Mutation")({
2426
2429
  });
2427
2430
 
2428
2431
  const selectBranch = {
2429
- __proto__: null,
2430
- mutation: mutation$r,
2431
- name: name$B
2432
+ __proto__: null,
2433
+ mutation: mutation$r,
2434
+ name: name$B
2432
2435
  };
2433
2436
 
2434
2437
  const name$A = "generateSelectBranchDocument";
@@ -2437,20 +2440,20 @@ const mutation$q = Selector("Mutation")({
2437
2440
  });
2438
2441
 
2439
2442
  const generateSelectBranchDocument = {
2440
- __proto__: null,
2441
- mutation: mutation$q,
2442
- name: name$A
2443
+ __proto__: null,
2444
+ mutation: mutation$q,
2445
+ name: name$A
2443
2446
  };
2444
2447
 
2445
- const index$i = {
2446
- __proto__: null,
2447
- AddTrustedAccount: addTrustedAccount,
2448
- CreateBranch: createBranch,
2449
- DeleteBranch: deleteBranch,
2450
- DeleteTrustedAccount: deleteTrustedAccount,
2451
- EditBranch: editBranch,
2452
- GenerateSelectBranchDocument: generateSelectBranchDocument,
2453
- SelectBranch: selectBranch
2448
+ const index$h = {
2449
+ __proto__: null,
2450
+ AddTrustedAccount: addTrustedAccount,
2451
+ CreateBranch: createBranch,
2452
+ DeleteBranch: deleteBranch,
2453
+ DeleteTrustedAccount: deleteTrustedAccount,
2454
+ EditBranch: editBranch,
2455
+ GenerateSelectBranchDocument: generateSelectBranchDocument,
2456
+ SelectBranch: selectBranch
2454
2457
  };
2455
2458
 
2456
2459
  const rawProjectFreeDecisionDocumentSelector = {
@@ -2469,9 +2472,9 @@ const mutation$p = Selector("Mutation")({
2469
2472
  });
2470
2473
 
2471
2474
  const generateProjectOfFreeDecisionDocument = {
2472
- __proto__: null,
2473
- mutation: mutation$p,
2474
- name: name$z
2475
+ __proto__: null,
2476
+ mutation: mutation$p,
2477
+ name: name$z
2475
2478
  };
2476
2479
 
2477
2480
  const rawFreeDecisionDocumentSelector = {
@@ -2499,9 +2502,9 @@ const mutation$o = Selector("Mutation")({
2499
2502
  });
2500
2503
 
2501
2504
  const generateFreeDecision = {
2502
- __proto__: null,
2503
- mutation: mutation$o,
2504
- name: name$y
2505
+ __proto__: null,
2506
+ mutation: mutation$o,
2507
+ name: name$y
2505
2508
  };
2506
2509
 
2507
2510
  const name$x = "publishProjectOfFreeDecision";
@@ -2510,9 +2513,9 @@ const mutation$n = Selector("Mutation")({
2510
2513
  });
2511
2514
 
2512
2515
  const publishProjectOfFreeDecision = {
2513
- __proto__: null,
2514
- mutation: mutation$n,
2515
- name: name$x
2516
+ __proto__: null,
2517
+ mutation: mutation$n,
2518
+ name: name$x
2516
2519
  };
2517
2520
 
2518
2521
  const name$w = "createProjectOfFreeDecision";
@@ -2521,17 +2524,17 @@ const mutation$m = Selector("Mutation")({
2521
2524
  });
2522
2525
 
2523
2526
  const createProjectOfFreeDecision = {
2524
- __proto__: null,
2525
- mutation: mutation$m,
2526
- name: name$w
2527
+ __proto__: null,
2528
+ mutation: mutation$m,
2529
+ name: name$w
2527
2530
  };
2528
2531
 
2529
- const index$h = {
2530
- __proto__: null,
2531
- CreateProjectOfFreeDecision: createProjectOfFreeDecision,
2532
- GenerateFreeDecision: generateFreeDecision,
2533
- GenerateProjectOfFreeDecision: generateProjectOfFreeDecisionDocument,
2534
- PublishProjectOfFreeDecision: publishProjectOfFreeDecision
2532
+ const index$g = {
2533
+ __proto__: null,
2534
+ CreateProjectOfFreeDecision: createProjectOfFreeDecision,
2535
+ GenerateFreeDecision: generateFreeDecision,
2536
+ GenerateProjectOfFreeDecision: generateProjectOfFreeDecisionDocument,
2537
+ PublishProjectOfFreeDecision: publishProjectOfFreeDecision
2535
2538
  };
2536
2539
 
2537
2540
  const name$v = "updateAccount";
@@ -2540,9 +2543,9 @@ const mutation$l = Selector("Mutation")({
2540
2543
  });
2541
2544
 
2542
2545
  const updateAccount = {
2543
- __proto__: null,
2544
- mutation: mutation$l,
2545
- name: name$v
2546
+ __proto__: null,
2547
+ mutation: mutation$l,
2548
+ name: name$v
2546
2549
  };
2547
2550
 
2548
2551
  const rawTokenSelector = {
@@ -2567,9 +2570,9 @@ const mutation$k = Selector("Mutation")({
2567
2570
  });
2568
2571
 
2569
2572
  const registerAccount = {
2570
- __proto__: null,
2571
- mutation: mutation$k,
2572
- name: name$u
2573
+ __proto__: null,
2574
+ mutation: mutation$k,
2575
+ name: name$u
2573
2576
  };
2574
2577
 
2575
2578
  const name$t = "startResetKey";
@@ -2578,9 +2581,9 @@ const mutation$j = Selector("Mutation")({
2578
2581
  });
2579
2582
 
2580
2583
  const startResetKey = {
2581
- __proto__: null,
2582
- mutation: mutation$j,
2583
- name: name$t
2584
+ __proto__: null,
2585
+ mutation: mutation$j,
2586
+ name: name$t
2584
2587
  };
2585
2588
 
2586
2589
  const name$s = "resetKey";
@@ -2589,17 +2592,17 @@ const mutation$i = Selector("Mutation")({
2589
2592
  });
2590
2593
 
2591
2594
  const resetKey = {
2592
- __proto__: null,
2593
- mutation: mutation$i,
2594
- name: name$s
2595
+ __proto__: null,
2596
+ mutation: mutation$i,
2597
+ name: name$s
2595
2598
  };
2596
2599
 
2597
- const index$g = {
2598
- __proto__: null,
2599
- RegisterAccount: registerAccount,
2600
- ResetKey: resetKey,
2601
- StartResetKey: startResetKey,
2602
- UpdateAccount: updateAccount
2600
+ const index$f = {
2601
+ __proto__: null,
2602
+ RegisterAccount: registerAccount,
2603
+ ResetKey: resetKey,
2604
+ StartResetKey: startResetKey,
2605
+ UpdateAccount: updateAccount
2603
2606
  };
2604
2607
 
2605
2608
  const name$r = "refresh";
@@ -2608,9 +2611,9 @@ const mutation$h = Selector("Mutation")({
2608
2611
  });
2609
2612
 
2610
2613
  const refresh = {
2611
- __proto__: null,
2612
- mutation: mutation$h,
2613
- name: name$r
2614
+ __proto__: null,
2615
+ mutation: mutation$h,
2616
+ name: name$r
2614
2617
  };
2615
2618
 
2616
2619
  const name$q = "logout";
@@ -2619,9 +2622,9 @@ const mutation$g = Selector("Mutation")({
2619
2622
  });
2620
2623
 
2621
2624
  const logout = {
2622
- __proto__: null,
2623
- mutation: mutation$g,
2624
- name: name$q
2625
+ __proto__: null,
2626
+ mutation: mutation$g,
2627
+ name: name$q
2625
2628
  };
2626
2629
 
2627
2630
  const name$p = "login";
@@ -2630,16 +2633,16 @@ const mutation$f = Selector("Mutation")({
2630
2633
  });
2631
2634
 
2632
2635
  const login = {
2633
- __proto__: null,
2634
- mutation: mutation$f,
2635
- name: name$p
2636
+ __proto__: null,
2637
+ mutation: mutation$f,
2638
+ name: name$p
2636
2639
  };
2637
2640
 
2638
- const index$f = {
2639
- __proto__: null,
2640
- Login: login,
2641
- Logout: logout,
2642
- Refresh: refresh
2641
+ const index$e = {
2642
+ __proto__: null,
2643
+ Login: login,
2644
+ Logout: logout,
2645
+ Refresh: refresh
2643
2646
  };
2644
2647
 
2645
2648
  const name$o = "initSystem";
@@ -2648,9 +2651,9 @@ const mutation$e = Selector("Mutation")({
2648
2651
  });
2649
2652
 
2650
2653
  const initSystem = {
2651
- __proto__: null,
2652
- mutation: mutation$e,
2653
- name: name$o
2654
+ __proto__: null,
2655
+ mutation: mutation$e,
2656
+ name: name$o
2654
2657
  };
2655
2658
 
2656
2659
  const name$n = "installSystem";
@@ -2659,9 +2662,9 @@ const mutation$d = Selector("Mutation")({
2659
2662
  });
2660
2663
 
2661
2664
  const installSystem = {
2662
- __proto__: null,
2663
- mutation: mutation$d,
2664
- name: name$n
2665
+ __proto__: null,
2666
+ mutation: mutation$d,
2667
+ name: name$n
2665
2668
  };
2666
2669
 
2667
2670
  const name$m = "setWif";
@@ -2670,9 +2673,9 @@ const mutation$c = Selector("Mutation")({
2670
2673
  });
2671
2674
 
2672
2675
  const setWif = {
2673
- __proto__: null,
2674
- mutation: mutation$c,
2675
- name: name$m
2676
+ __proto__: null,
2677
+ mutation: mutation$c,
2678
+ name: name$m
2676
2679
  };
2677
2680
 
2678
2681
  const name$l = "updateSystem";
@@ -2681,17 +2684,17 @@ const mutation$b = Selector("Mutation")({
2681
2684
  });
2682
2685
 
2683
2686
  const updateSystem = {
2684
- __proto__: null,
2685
- mutation: mutation$b,
2686
- name: name$l
2687
+ __proto__: null,
2688
+ mutation: mutation$b,
2689
+ name: name$l
2687
2690
  };
2688
2691
 
2689
- const index$e = {
2690
- __proto__: null,
2691
- InitSystem: initSystem,
2692
- InstallSystem: installSystem,
2693
- SetWif: setWif,
2694
- UpdateSystem: updateSystem
2692
+ const index$d = {
2693
+ __proto__: null,
2694
+ InitSystem: initSystem,
2695
+ InstallSystem: installSystem,
2696
+ SetWif: setWif,
2697
+ UpdateSystem: updateSystem
2695
2698
  };
2696
2699
 
2697
2700
  const name$k = "generateParticipantApplication";
@@ -2700,9 +2703,9 @@ const mutation$a = Selector("Mutation")({
2700
2703
  });
2701
2704
 
2702
2705
  const generateParticipantApplication = {
2703
- __proto__: null,
2704
- mutation: mutation$a,
2705
- name: name$k
2706
+ __proto__: null,
2707
+ mutation: mutation$a,
2708
+ name: name$k
2706
2709
  };
2707
2710
 
2708
2711
  const name$j = "generateParticipantApplicationDecision";
@@ -2711,9 +2714,9 @@ const mutation$9 = Selector("Mutation")({
2711
2714
  });
2712
2715
 
2713
2716
  const generateParticipantApplicationDecision = {
2714
- __proto__: null,
2715
- mutation: mutation$9,
2716
- name: name$j
2717
+ __proto__: null,
2718
+ mutation: mutation$9,
2719
+ name: name$j
2717
2720
  };
2718
2721
 
2719
2722
  const name$i = "registerParticipant";
@@ -2722,9 +2725,9 @@ const mutation$8 = Selector("Mutation")({
2722
2725
  });
2723
2726
 
2724
2727
  const registerParticipant = {
2725
- __proto__: null,
2726
- mutation: mutation$8,
2727
- name: name$i
2728
+ __proto__: null,
2729
+ mutation: mutation$8,
2730
+ name: name$i
2728
2731
  };
2729
2732
 
2730
2733
  const name$h = "addParticipant";
@@ -2733,17 +2736,17 @@ const mutation$7 = Selector("Mutation")({
2733
2736
  });
2734
2737
 
2735
2738
  const addParticipant = {
2736
- __proto__: null,
2737
- mutation: mutation$7,
2738
- name: name$h
2739
+ __proto__: null,
2740
+ mutation: mutation$7,
2741
+ name: name$h
2739
2742
  };
2740
2743
 
2741
- const index$d = {
2742
- __proto__: null,
2743
- AddParticipant: addParticipant,
2744
- GenerateParticipantApplication: generateParticipantApplication,
2745
- GenerateParticipantApplicationDecision: generateParticipantApplicationDecision,
2746
- RegisterParticipant: registerParticipant
2744
+ const index$c = {
2745
+ __proto__: null,
2746
+ AddParticipant: addParticipant,
2747
+ GenerateParticipantApplication: generateParticipantApplication,
2748
+ GenerateParticipantApplicationDecision: generateParticipantApplicationDecision,
2749
+ RegisterParticipant: registerParticipant
2747
2750
  };
2748
2751
 
2749
2752
  const rawPaymentDetailsSelector = {
@@ -2777,9 +2780,9 @@ const mutation$6 = Selector("Mutation")({
2777
2780
  });
2778
2781
 
2779
2782
  const createInitial = {
2780
- __proto__: null,
2781
- mutation: mutation$6,
2782
- name: name$g
2783
+ __proto__: null,
2784
+ mutation: mutation$6,
2785
+ name: name$g
2783
2786
  };
2784
2787
 
2785
2788
  const name$f = "createDepositPayment";
@@ -2788,9 +2791,9 @@ const mutation$5 = Selector("Mutation")({
2788
2791
  });
2789
2792
 
2790
2793
  const createDeposit = {
2791
- __proto__: null,
2792
- mutation: mutation$5,
2793
- name: name$f
2794
+ __proto__: null,
2795
+ mutation: mutation$5,
2796
+ name: name$f
2794
2797
  };
2795
2798
 
2796
2799
  const name$e = "setPaymentStatus";
@@ -2799,16 +2802,16 @@ const mutation$4 = Selector("Mutation")({
2799
2802
  });
2800
2803
 
2801
2804
  const setPaymentStatus = {
2802
- __proto__: null,
2803
- mutation: mutation$4,
2804
- name: name$e
2805
+ __proto__: null,
2806
+ mutation: mutation$4,
2807
+ name: name$e
2805
2808
  };
2806
2809
 
2807
- const index$c = {
2808
- __proto__: null,
2809
- CreateDepositPayment: createDeposit,
2810
- CreateInitialPayment: createInitial,
2811
- SetPaymentStatus: setPaymentStatus
2810
+ const index$b = {
2811
+ __proto__: null,
2812
+ CreateDepositPayment: createDeposit,
2813
+ CreateInitialPayment: createInitial,
2814
+ SetPaymentStatus: setPaymentStatus
2812
2815
  };
2813
2816
 
2814
2817
  const name$d = "generatePrivacyAgreement";
@@ -2817,9 +2820,9 @@ const mutation$3 = Selector("Mutation")({
2817
2820
  });
2818
2821
 
2819
2822
  const generatePrivacyAgreement = {
2820
- __proto__: null,
2821
- mutation: mutation$3,
2822
- name: name$d
2823
+ __proto__: null,
2824
+ mutation: mutation$3,
2825
+ name: name$d
2823
2826
  };
2824
2827
 
2825
2828
  const name$c = "generateSignatureAgreement";
@@ -2828,9 +2831,9 @@ const mutation$2 = Selector("Mutation")({
2828
2831
  });
2829
2832
 
2830
2833
  const generateSignatureAgreement = {
2831
- __proto__: null,
2832
- mutation: mutation$2,
2833
- name: name$c
2834
+ __proto__: null,
2835
+ mutation: mutation$2,
2836
+ name: name$c
2834
2837
  };
2835
2838
 
2836
2839
  const name$b = "generateWalletAgreement";
@@ -2839,9 +2842,9 @@ const mutation$1 = Selector("Mutation")({
2839
2842
  });
2840
2843
 
2841
2844
  const generateWalletAgreement = {
2842
- __proto__: null,
2843
- mutation: mutation$1,
2844
- name: name$b
2845
+ __proto__: null,
2846
+ mutation: mutation$1,
2847
+ name: name$b
2845
2848
  };
2846
2849
 
2847
2850
  const name$a = "generateUserAgreement";
@@ -2850,31 +2853,31 @@ const mutation = Selector("Mutation")({
2850
2853
  });
2851
2854
 
2852
2855
  const generateUserAgreement = {
2853
- __proto__: null,
2854
- mutation: mutation,
2855
- name: name$a
2856
- };
2857
-
2858
- const index$b = {
2859
- __proto__: null,
2860
- GeneratePrivacyAgreement: generatePrivacyAgreement,
2861
- GenerateSignatureAgreement: generateSignatureAgreement,
2862
- GenerateUserAgreement: generateUserAgreement,
2863
- GenerateWalletAgreement: generateWalletAgreement
2856
+ __proto__: null,
2857
+ mutation: mutation,
2858
+ name: name$a
2864
2859
  };
2865
2860
 
2866
2861
  const index$a = {
2867
- __proto__: null,
2868
- Accounts: index$g,
2869
- Agreements: index$b,
2870
- Auth: index$f,
2871
- Branches: index$i,
2872
- Extensions: index$k,
2873
- FreeDecisions: index$h,
2874
- Participants: index$d,
2875
- PaymentMethods: index$j,
2876
- Payments: index$c,
2877
- System: index$e
2862
+ __proto__: null,
2863
+ GeneratePrivacyAgreement: generatePrivacyAgreement,
2864
+ GenerateSignatureAgreement: generateSignatureAgreement,
2865
+ GenerateUserAgreement: generateUserAgreement,
2866
+ GenerateWalletAgreement: generateWalletAgreement
2867
+ };
2868
+
2869
+ const Mutations = {
2870
+ __proto__: null,
2871
+ Accounts: index$f,
2872
+ Agreements: index$a,
2873
+ Auth: index$e,
2874
+ Branches: index$h,
2875
+ Extensions: index$j,
2876
+ FreeDecisions: index$g,
2877
+ Participants: index$c,
2878
+ PaymentMethods: index$i,
2879
+ Payments: index$b,
2880
+ System: index$d
2878
2881
  };
2879
2882
 
2880
2883
  const name$9 = "getExtensions";
@@ -2883,14 +2886,14 @@ const query$9 = Selector("Query")({
2883
2886
  });
2884
2887
 
2885
2888
  const getExtensions = {
2886
- __proto__: null,
2887
- name: name$9,
2888
- query: query$9
2889
+ __proto__: null,
2890
+ name: name$9,
2891
+ query: query$9
2889
2892
  };
2890
2893
 
2891
2894
  const index$9 = {
2892
- __proto__: null,
2893
- GetExtensions: getExtensions
2895
+ __proto__: null,
2896
+ GetExtensions: getExtensions
2894
2897
  };
2895
2898
 
2896
2899
  const paginationSelector = {
@@ -2909,13 +2912,13 @@ const query$8 = Selector("Query")({
2909
2912
  });
2910
2913
 
2911
2914
  const getPaymentMethods = {
2912
- __proto__: null,
2913
- query: query$8
2915
+ __proto__: null,
2916
+ query: query$8
2914
2917
  };
2915
2918
 
2916
2919
  const index$8 = {
2917
- __proto__: null,
2918
- GetPaymentMethods: getPaymentMethods
2920
+ __proto__: null,
2921
+ GetPaymentMethods: getPaymentMethods
2919
2922
  };
2920
2923
 
2921
2924
  const name$7 = "getSystemInfo";
@@ -2924,14 +2927,14 @@ const query$7 = Selector("Query")({
2924
2927
  });
2925
2928
 
2926
2929
  const getSystemInfo = {
2927
- __proto__: null,
2928
- name: name$7,
2929
- query: query$7
2930
+ __proto__: null,
2931
+ name: name$7,
2932
+ query: query$7
2930
2933
  };
2931
2934
 
2932
2935
  const index$7 = {
2933
- __proto__: null,
2934
- GetSystemInfo: getSystemInfo
2936
+ __proto__: null,
2937
+ GetSystemInfo: getSystemInfo
2935
2938
  };
2936
2939
 
2937
2940
  const name$6 = "getAccount";
@@ -2940,9 +2943,9 @@ const query$6 = Selector("Query")({
2940
2943
  });
2941
2944
 
2942
2945
  const getAccount = {
2943
- __proto__: null,
2944
- name: name$6,
2945
- query: query$6
2946
+ __proto__: null,
2947
+ name: name$6,
2948
+ query: query$6
2946
2949
  };
2947
2950
 
2948
2951
  const rawAccountsPaginationSelector = { ...paginationSelector, items: rawAccountSelector };
@@ -2954,15 +2957,15 @@ const query$5 = Selector("Query")({
2954
2957
  });
2955
2958
 
2956
2959
  const getAccounts = {
2957
- __proto__: null,
2958
- name: name$5,
2959
- query: query$5
2960
+ __proto__: null,
2961
+ name: name$5,
2962
+ query: query$5
2960
2963
  };
2961
2964
 
2962
2965
  const index$6 = {
2963
- __proto__: null,
2964
- GetAccount: getAccount,
2965
- GetAccounts: getAccounts
2966
+ __proto__: null,
2967
+ GetAccount: getAccount,
2968
+ GetAccounts: getAccounts
2966
2969
  };
2967
2970
 
2968
2971
  const name$4 = "getBranches";
@@ -2971,9 +2974,9 @@ const query$4 = Selector("Query")({
2971
2974
  });
2972
2975
 
2973
2976
  const getBranches = {
2974
- __proto__: null,
2975
- name: name$4,
2976
- query: query$4
2977
+ __proto__: null,
2978
+ name: name$4,
2979
+ query: query$4
2977
2980
  };
2978
2981
 
2979
2982
  const name$3 = "getBranches";
@@ -2982,15 +2985,15 @@ const query$3 = Selector("Query")({
2982
2985
  });
2983
2986
 
2984
2987
  const getPublicBranches = {
2985
- __proto__: null,
2986
- name: name$3,
2987
- query: query$3
2988
+ __proto__: null,
2989
+ name: name$3,
2990
+ query: query$3
2988
2991
  };
2989
2992
 
2990
2993
  const index$5 = {
2991
- __proto__: null,
2992
- GetBranches: getBranches,
2993
- GetPublicBranches: getPublicBranches
2994
+ __proto__: null,
2995
+ GetBranches: getBranches,
2996
+ GetPublicBranches: getPublicBranches
2994
2997
  };
2995
2998
 
2996
2999
  const paymentPaginationSelector = { ...paginationSelector, items: rawPaymentSelector };
@@ -3000,13 +3003,13 @@ const query$2 = Selector("Query")({
3000
3003
  });
3001
3004
 
3002
3005
  const getPayments = {
3003
- __proto__: null,
3004
- query: query$2
3006
+ __proto__: null,
3007
+ query: query$2
3005
3008
  };
3006
3009
 
3007
3010
  const index$4 = {
3008
- __proto__: null,
3009
- GetPayments: getPayments
3011
+ __proto__: null,
3012
+ GetPayments: getPayments
3010
3013
  };
3011
3014
 
3012
3015
  const rawParticipantApplicationDocumentSelector = {
@@ -3064,13 +3067,13 @@ const query$1 = Selector("Query")({
3064
3067
  });
3065
3068
 
3066
3069
  const getDocuments = {
3067
- __proto__: null,
3068
- query: query$1
3070
+ __proto__: null,
3071
+ query: query$1
3069
3072
  };
3070
3073
 
3071
3074
  const index$3 = {
3072
- __proto__: null,
3073
- GetDocuments: getDocuments
3075
+ __proto__: null,
3076
+ GetDocuments: getDocuments
3074
3077
  };
3075
3078
 
3076
3079
  const rawSignedBlockchainDocumentSelector = {
@@ -3114,30 +3117,30 @@ const query = Selector("Query")({
3114
3117
  });
3115
3118
 
3116
3119
  const getAgenda = {
3117
- __proto__: null,
3118
- name: name,
3119
- query: query
3120
+ __proto__: null,
3121
+ name: name,
3122
+ query: query
3120
3123
  };
3121
3124
 
3122
3125
  const index$2 = {
3123
- __proto__: null,
3124
- GetAgenda: getAgenda
3126
+ __proto__: null,
3127
+ GetAgenda: getAgenda
3125
3128
  };
3126
3129
 
3127
3130
  const index$1 = {
3128
- __proto__: null,
3129
- Accounts: index$6,
3130
- Agenda: index$2,
3131
- Branches: index$5,
3132
- Documents: index$3,
3133
- Extensions: index$9,
3134
- PaymentMethods: index$8,
3135
- Payments: index$4,
3136
- System: index$7
3131
+ __proto__: null,
3132
+ Accounts: index$6,
3133
+ Agenda: index$2,
3134
+ Branches: index$5,
3135
+ Documents: index$3,
3136
+ Extensions: index$9,
3137
+ PaymentMethods: index$8,
3138
+ Payments: index$4,
3139
+ System: index$7
3137
3140
  };
3138
3141
 
3139
3142
  const index = {
3140
- __proto__: null
3143
+ __proto__: null
3141
3144
  };
3142
3145
 
3143
3146
  if (typeof globalThis.WebSocket === "undefined") {
@@ -3178,9 +3181,31 @@ function createClient(options) {
3178
3181
  currentHeaders = options.headers || {};
3179
3182
  const thunder = createThunder(options.api_url);
3180
3183
  const wallet = new Wallet(options);
3181
- if (options.wif && options.username)
3184
+ async function login(email, wif) {
3185
+ const now = (await wallet.getInfo()).head_block_time.toString();
3186
+ const privateKey = session.PrivateKey.fromString(wif);
3187
+ const bytes = session.Bytes.fromString(now, "utf8");
3188
+ const checksum = session.Checksum256.hash(bytes);
3189
+ const signature = privateKey.signDigest(checksum).toString();
3190
+ const variables = {
3191
+ data: {
3192
+ email,
3193
+ now,
3194
+ signature
3195
+ }
3196
+ };
3197
+ const { [name$p]: result } = await thunder("mutation")(
3198
+ mutation$f,
3199
+ {
3200
+ variables
3201
+ }
3202
+ );
3203
+ currentHeaders.Authorization = `Bearer ${result.tokens.access.token}`;
3204
+ return result;
3205
+ }
3206
+ if (options.wif && options.username) {
3182
3207
  wallet.setWif(options.username, options.wif);
3183
- else if (options.wif && !options.username || !options.wif && options.username) {
3208
+ } else if (options.wif && !options.username || !options.wif && options.username) {
3184
3209
  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");
3185
3210
  }
3186
3211
  return {
@@ -3190,13 +3215,14 @@ function createClient(options) {
3190
3215
  Query: thunder("query"),
3191
3216
  Mutation: thunder("mutation"),
3192
3217
  Subscription: Subscription(options.api_url.replace(/^http/, "ws")),
3193
- Wallet: wallet
3218
+ Wallet: wallet,
3219
+ login
3194
3220
  };
3195
3221
  }
3196
3222
 
3197
3223
  exports.Classes = Classes;
3198
- exports.Mutations = index$a;
3224
+ exports.Mutations = Mutations;
3199
3225
  exports.Queries = index$1;
3200
3226
  exports.Types = index;
3201
- exports.Zeus = index$l;
3227
+ exports.Zeus = index$k;
3202
3228
  exports.createClient = createClient;