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