@alephium/web3 0.2.0-test.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/dist/alephium-web3.min.js +1 -1
  4. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  5. package/dist/alephium-web3.min.js.map +1 -1
  6. package/dist/src/api/api-alephium.d.ts +152 -24
  7. package/dist/src/api/api-alephium.js +163 -82
  8. package/dist/src/api/api-explorer.d.ts +192 -49
  9. package/dist/src/api/api-explorer.js +195 -34
  10. package/dist/src/api/index.d.ts +40 -5
  11. package/dist/src/api/index.js +115 -7
  12. package/dist/src/api/types.d.ts +23 -0
  13. package/dist/src/api/types.js +235 -0
  14. package/dist/src/api/utils.d.ts +6 -0
  15. package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
  16. package/dist/src/contract/contract.d.ts +127 -80
  17. package/dist/src/contract/contract.js +425 -467
  18. package/dist/src/contract/events.d.ts +4 -4
  19. package/dist/src/contract/events.js +2 -1
  20. package/dist/src/contract/index.js +5 -1
  21. package/dist/src/contract/ralph.d.ts +5 -4
  22. package/dist/src/contract/ralph.js +27 -1
  23. package/dist/src/global.d.ts +7 -0
  24. package/dist/src/global.js +54 -0
  25. package/dist/src/index.d.ts +2 -0
  26. package/dist/src/index.js +23 -1
  27. package/dist/src/signer/index.d.ts +0 -1
  28. package/dist/src/signer/index.js +5 -2
  29. package/dist/src/signer/signer.d.ts +59 -60
  30. package/dist/src/signer/signer.js +99 -69
  31. package/dist/src/transaction/index.d.ts +0 -1
  32. package/dist/src/transaction/index.js +5 -2
  33. package/dist/src/transaction/status.d.ts +2 -1
  34. package/dist/src/transaction/status.js +2 -1
  35. package/dist/src/utils/bs58.d.ts +1 -0
  36. package/dist/src/utils/bs58.js +13 -1
  37. package/dist/src/utils/index.d.ts +0 -1
  38. package/dist/src/utils/index.js +5 -2
  39. package/dist/src/utils/subscription.d.ts +0 -3
  40. package/dist/src/utils/subscription.js +0 -1
  41. package/dist/src/utils/utils.d.ts +6 -11
  42. package/dist/src/utils/utils.js +22 -26
  43. package/jest-config.json +11 -0
  44. package/package.json +11 -47
  45. package/src/api/api-alephium.ts +219 -33
  46. package/src/api/api-explorer.ts +275 -52
  47. package/src/api/index.ts +140 -6
  48. package/src/api/types.ts +229 -0
  49. package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
  50. package/src/contract/contract.ts +663 -581
  51. package/src/contract/events.ts +8 -7
  52. package/src/contract/ralph.ts +29 -4
  53. package/src/global.ts +56 -0
  54. package/src/index.ts +7 -0
  55. package/src/signer/index.ts +0 -1
  56. package/src/signer/signer.ts +165 -134
  57. package/src/transaction/index.ts +0 -1
  58. package/src/transaction/status.ts +6 -3
  59. package/src/utils/bs58.ts +11 -0
  60. package/src/utils/index.ts +0 -1
  61. package/src/utils/subscription.ts +1 -5
  62. package/src/utils/utils.ts +15 -23
  63. package/webpack.config.js +3 -0
  64. package/.eslintrc.json +0 -21
  65. package/LICENSE +0 -165
  66. package/contracts/add/add.ral +0 -16
  67. package/contracts/greeter/greeter.ral +0 -7
  68. package/contracts/greeter/greeter_interface.ral +0 -3
  69. package/contracts/greeter_main.ral +0 -9
  70. package/contracts/main.ral +0 -6
  71. package/contracts/sub/sub.ral +0 -9
  72. package/dev/user.conf +0 -29
  73. package/dist/scripts/create-project.d.ts +0 -2
  74. package/dist/scripts/create-project.js +0 -124
  75. package/dist/scripts/rename-gitignore.d.ts +0 -1
  76. package/dist/scripts/start-devnet.d.ts +0 -1
  77. package/dist/scripts/start-devnet.js +0 -131
  78. package/dist/scripts/stop-devnet.d.ts +0 -1
  79. package/dist/scripts/stop-devnet.js +0 -32
  80. package/dist/src/signer/node-wallet.d.ts +0 -13
  81. package/dist/src/signer/node-wallet.js +0 -60
  82. package/dist/src/test/index.d.ts +0 -7
  83. package/dist/src/test/index.js +0 -41
  84. package/dist/src/test/privatekey-wallet.d.ts +0 -12
  85. package/dist/src/test/privatekey-wallet.js +0 -68
  86. package/dist/src/transaction/sign-verify.d.ts +0 -2
  87. package/dist/src/transaction/sign-verify.js +0 -58
  88. package/dist/src/utils/password-crypto.d.ts +0 -2
  89. package/dist/src/utils/password-crypto.js +0 -69
  90. package/gitignore +0 -10
  91. package/scripts/create-project.ts +0 -136
  92. package/scripts/start-devnet.js +0 -141
  93. package/scripts/stop-devnet.js +0 -32
  94. package/src/contract/ralph.test.ts +0 -178
  95. package/src/fixtures/address.json +0 -36
  96. package/src/fixtures/balance.json +0 -9
  97. package/src/fixtures/self-clique.json +0 -19
  98. package/src/fixtures/transaction.json +0 -13
  99. package/src/fixtures/transactions.json +0 -179
  100. package/src/signer/fixtures/genesis.json +0 -26
  101. package/src/signer/fixtures/wallets.json +0 -26
  102. package/src/signer/node-wallet.ts +0 -74
  103. package/src/test/index.ts +0 -32
  104. package/src/test/privatekey-wallet.ts +0 -58
  105. package/src/transaction/sign-verify.test.ts +0 -50
  106. package/src/transaction/sign-verify.ts +0 -39
  107. package/src/utils/address.test.ts +0 -47
  108. package/src/utils/djb2.test.ts +0 -35
  109. package/src/utils/password-crypto.test.ts +0 -27
  110. package/src/utils/password-crypto.ts +0 -77
  111. package/src/utils/utils.test.ts +0 -161
  112. package/templates/base/README.md +0 -34
  113. package/templates/base/package.json +0 -35
  114. package/templates/base/src/greeter.ts +0 -41
  115. package/templates/base/tsconfig.json +0 -19
  116. package/templates/react/README.md +0 -34
  117. package/templates/react/config-overrides.js +0 -18
  118. package/templates/react/package.json +0 -66
  119. package/templates/react/src/App.tsx +0 -42
  120. package/templates/react/src/artifacts/greeter.ral.json +0 -26
  121. package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
  122. package/templates/shared/.eslintrc.json +0 -12
  123. package/templates/shared/scripts/header.js +0 -0
  124. package/test/contract.test.ts +0 -178
  125. package/test/events.test.ts +0 -138
  126. package/test/transaction.test.ts +0 -72
@@ -1,11 +1,11 @@
1
- import { ContractEvent } from '../api/api-alephium';
1
+ import { node } from '../api';
2
2
  import { Subscription, SubscribeOptions } from '../utils';
3
- export declare class EventSubscription extends Subscription<ContractEvent> {
3
+ export declare class EventSubscription extends Subscription<node.ContractEvent> {
4
4
  readonly contractAddress: string;
5
5
  private fromCount;
6
- constructor(options: SubscribeOptions<ContractEvent>, contractAddress: string, fromCount?: number);
6
+ constructor(options: SubscribeOptions<node.ContractEvent>, contractAddress: string, fromCount?: number);
7
7
  startPolling(): void;
8
8
  currentEventCount(): number;
9
9
  polling(): Promise<void>;
10
10
  }
11
- export declare function subscribeToEvents(options: SubscribeOptions<ContractEvent>, contractAddress: string, fromCount?: number): EventSubscription;
11
+ export declare function subscribeToEvents(options: SubscribeOptions<node.ContractEvent>, contractAddress: string, fromCount?: number): EventSubscription;
@@ -18,6 +18,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.subscribeToEvents = exports.EventSubscription = void 0;
21
+ const __1 = require("..");
21
22
  const utils_1 = require("../utils");
22
23
  class EventSubscription extends utils_1.Subscription {
23
24
  constructor(options, contractAddress, fromCount) {
@@ -37,7 +38,7 @@ class EventSubscription extends utils_1.Subscription {
37
38
  }
38
39
  async polling() {
39
40
  try {
40
- const events = await this.provider.events.getEventsContractContractaddress(this.contractAddress, {
41
+ const events = await __1.web3.getCurrentNodeProvider().events.getEventsContractContractaddress(this.contractAddress, {
41
42
  start: this.fromCount
42
43
  });
43
44
  if (this.cancelled) {
@@ -18,7 +18,11 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
20
  if (k2 === undefined) k2 = k;
21
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
22
26
  }) : (function(o, m, k, k2) {
23
27
  if (k2 === undefined) k2 = k;
24
28
  o[k2] = m[k];
@@ -1,5 +1,5 @@
1
- import { node } from '../api';
2
- import { Fields, Val } from './contract';
1
+ import { Val } from '../api';
2
+ import { Fields, FieldsSig } from './contract';
3
3
  export declare function encodeBool(bool: boolean): Uint8Array;
4
4
  export declare function encodeI256(i256: bigint): Uint8Array;
5
5
  export declare function encodeU256(u256: bigint): Uint8Array;
@@ -7,6 +7,7 @@ export declare function encodeByteVec(bytes: string): Uint8Array;
7
7
  export declare function encodeAddress(address: string): Uint8Array;
8
8
  export declare function encodeScriptFieldAsString(tpe: string, value: Val): string;
9
9
  export declare function encodeScriptField(tpe: string, value: Val): Uint8Array;
10
- export declare function buildScriptByteCode(bytecodeTemplate: string, fields: Fields, fieldsSig: node.FieldsSig): string;
11
- export declare function buildContractByteCode(bytecode: string, fields: Fields, fieldsSig: node.FieldsSig): string;
10
+ export declare function buildScriptByteCode(bytecodeTemplate: string, fields: Fields, fieldsSig: FieldsSig): string;
11
+ export declare function buildContractByteCode(bytecode: string, fields: Fields, fieldsSig: FieldsSig): string;
12
12
  export declare function encodeContractField(tpe: string, value: Val): Uint8Array[];
13
+ export declare function buildDebugBytecode(bytecode: string, bytecodePatch: string): string;
@@ -18,7 +18,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  var _a;
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.encodeContractField = exports.buildContractByteCode = exports.buildScriptByteCode = exports.encodeScriptField = exports.encodeScriptFieldAsString = exports.encodeAddress = exports.encodeByteVec = exports.encodeU256 = exports.encodeI256 = exports.encodeBool = void 0;
21
+ exports.buildDebugBytecode = exports.encodeContractField = exports.buildContractByteCode = exports.buildScriptByteCode = exports.encodeScriptField = exports.encodeScriptFieldAsString = exports.encodeAddress = exports.encodeByteVec = exports.encodeU256 = exports.encodeI256 = exports.encodeBool = void 0;
22
22
  const buffer_1 = require("buffer/");
23
23
  const utils_1 = require("../utils");
24
24
  const bigIntZero = BigInt(0);
@@ -343,6 +343,32 @@ exports.encodeContractField = encodeContractField;
343
343
  function invalidVal(tpe, value) {
344
344
  return Error(`Invalid API value ${value} for type ${tpe}`);
345
345
  }
346
+ function buildDebugBytecode(bytecode, bytecodePatch) {
347
+ if (bytecodePatch === '') {
348
+ return bytecode;
349
+ }
350
+ const pattern = /[=+-][0-9a-f]*/g;
351
+ let result = '';
352
+ let index = 0;
353
+ for (const parts of bytecodePatch.matchAll(pattern)) {
354
+ const part = parts[0];
355
+ const diffType = part[0];
356
+ if (diffType === '=') {
357
+ const length = parseInt(part.substring(1));
358
+ result = result + bytecode.slice(index, index + length);
359
+ index = index + length;
360
+ }
361
+ else if (diffType === '+') {
362
+ result = result + part.substring(1);
363
+ }
364
+ else {
365
+ const length = parseInt(part.substring(1));
366
+ index = index + length;
367
+ }
368
+ }
369
+ return result;
370
+ }
371
+ exports.buildDebugBytecode = buildDebugBytecode;
346
372
  // export function buildContractByteCode(
347
373
  // compiled: node.TemplateContractByteCode,
348
374
  // templateVariables: TemplateVariables
@@ -0,0 +1,7 @@
1
+ import { ExplorerProvider, NodeProvider } from './api';
2
+ export declare function setCurrentNodeProvider(provider: NodeProvider): void;
3
+ export declare function setCurrentNodeProvider(baseUrl: string, apiKey?: string): void;
4
+ export declare function getCurrentNodeProvider(): NodeProvider;
5
+ export declare function setCurrentExplorerProvider(provider: ExplorerProvider): void;
6
+ export declare function setCurrentExplorerProvider(baseUrl: string, apiKey?: string): void;
7
+ export declare function getCurrentExplorerProvider(): ExplorerProvider | undefined;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getCurrentExplorerProvider = exports.setCurrentExplorerProvider = exports.getCurrentNodeProvider = exports.setCurrentNodeProvider = void 0;
21
+ const api_1 = require("./api");
22
+ let _currentNodeProvider = undefined;
23
+ function setCurrentNodeProvider(provider, apiKey) {
24
+ if (typeof provider == 'string') {
25
+ _currentNodeProvider = new api_1.NodeProvider(provider, apiKey);
26
+ }
27
+ else {
28
+ _currentNodeProvider = provider;
29
+ }
30
+ }
31
+ exports.setCurrentNodeProvider = setCurrentNodeProvider;
32
+ function getCurrentNodeProvider() {
33
+ if (typeof _currentNodeProvider === 'undefined') {
34
+ throw Error('No node provider is set.');
35
+ }
36
+ return _currentNodeProvider;
37
+ }
38
+ exports.getCurrentNodeProvider = getCurrentNodeProvider;
39
+ let _currentExplorerProvider = undefined;
40
+ function setCurrentExplorerProvider(provider, apiKey) {
41
+ if (typeof provider == 'string') {
42
+ _currentExplorerProvider = new api_1.ExplorerProvider(provider, apiKey);
43
+ }
44
+ else {
45
+ _currentExplorerProvider = provider;
46
+ }
47
+ }
48
+ exports.setCurrentExplorerProvider = setCurrentExplorerProvider;
49
+ // Different from `NodeProvider`, this may return `undefined`
50
+ // as ExplorerProvider is not necessary for all applications
51
+ function getCurrentExplorerProvider() {
52
+ return _currentExplorerProvider;
53
+ }
54
+ exports.getCurrentExplorerProvider = getCurrentExplorerProvider;
@@ -4,3 +4,5 @@ export * from './signer';
4
4
  export * from './utils';
5
5
  export * from './transaction';
6
6
  export * from './constants';
7
+ export * as web3 from './global';
8
+ export * as utils from './utils';
package/dist/src/index.js CHANGED
@@ -18,18 +18,40 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
20
  if (k2 === undefined) k2 = k;
21
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
22
26
  }) : (function(o, m, k, k2) {
23
27
  if (k2 === undefined) k2 = k;
24
28
  o[k2] = m[k];
25
29
  }));
30
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
31
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
32
+ }) : function(o, v) {
33
+ o["default"] = v;
34
+ });
26
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
37
  };
38
+ var __importStar = (this && this.__importStar) || function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
29
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.utils = exports.web3 = void 0;
47
+ BigInt.prototype['toJSON'] = function () {
48
+ return this.toString();
49
+ };
30
50
  __exportStar(require("./api"), exports);
31
51
  __exportStar(require("./contract"), exports);
32
52
  __exportStar(require("./signer"), exports);
33
53
  __exportStar(require("./utils"), exports);
34
54
  __exportStar(require("./transaction"), exports);
35
55
  __exportStar(require("./constants"), exports);
56
+ exports.web3 = __importStar(require("./global"));
57
+ exports.utils = __importStar(require("./utils"));
@@ -1,2 +1 @@
1
1
  export * from './signer';
2
- export * from './node-wallet';
@@ -18,7 +18,11 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
20
  if (k2 === undefined) k2 = k;
21
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
22
26
  }) : (function(o, m, k, k2) {
23
27
  if (k2 === undefined) k2 = k;
24
28
  o[k2] = m[k];
@@ -28,4 +32,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
32
  };
29
33
  Object.defineProperty(exports, "__esModule", { value: true });
30
34
  __exportStar(require("./signer"), exports);
31
- __exportStar(require("./node-wallet"), exports);
@@ -1,33 +1,20 @@
1
- import { NodeProvider } from '../api';
1
+ import { ExplorerProvider, NodeProvider, Number256, Token } from '../api';
2
2
  import { node } from '../api';
3
- import { Token } from '../api/api-alephium';
4
- export interface SignResult {
5
- fromGroup: number;
6
- toGroup: number;
7
- unsignedTx: string;
8
- txId: string;
9
- signature: string;
10
- }
3
+ export declare type OutputRef = node.OutputRef;
11
4
  export interface Account {
12
5
  address: string;
13
6
  group: number;
14
7
  publicKey: string;
15
8
  }
16
- export declare type SubmitTx = {
17
- submitTx?: boolean;
18
- };
19
9
  export declare type SignerAddress = {
20
10
  signerAddress: string;
21
11
  };
22
- export declare type GetAccountsParams = undefined;
23
- export declare type GetAccountsResult = Account[];
24
12
  export interface SignTransferTxParams {
25
13
  signerAddress: string;
26
- destinations: node.Destination[];
27
- utxos?: node.OutputRef[];
14
+ destinations: Destination[];
15
+ utxos?: OutputRef[];
28
16
  gasAmount?: number;
29
- gasPrice?: string;
30
- submitTx?: boolean;
17
+ gasPrice?: Number256;
31
18
  }
32
19
  export interface SignTransferTxResult {
33
20
  fromGroup: number;
@@ -35,16 +22,17 @@ export interface SignTransferTxResult {
35
22
  unsignedTx: string;
36
23
  txId: string;
37
24
  signature: string;
25
+ gasAmount: number;
26
+ gasPrice: Number256;
38
27
  }
39
28
  export interface SignDeployContractTxParams {
40
29
  signerAddress: string;
41
30
  bytecode: string;
42
- initialAttoAlphAmount?: string;
31
+ initialAttoAlphAmount?: Number256;
43
32
  initialTokenAmounts?: Token[];
44
- issueTokenAmount?: string;
33
+ issueTokenAmount?: Number256;
45
34
  gasAmount?: number;
46
- gasPrice?: string;
47
- submitTx?: boolean;
35
+ gasPrice?: Number256;
48
36
  }
49
37
  export interface SignDeployContractTxResult {
50
38
  fromGroup: number;
@@ -54,15 +42,16 @@ export interface SignDeployContractTxResult {
54
42
  signature: string;
55
43
  contractId: string;
56
44
  contractAddress: string;
45
+ gasAmount: number;
46
+ gasPrice: Number256;
57
47
  }
58
48
  export interface SignExecuteScriptTxParams {
59
49
  signerAddress: string;
60
50
  bytecode: string;
61
- attoAlphAmount?: string;
62
- tokens?: node.Token[];
51
+ attoAlphAmount?: Number256;
52
+ tokens?: Token[];
63
53
  gasAmount?: number;
64
- gasPrice?: string;
65
- submitTx?: boolean;
54
+ gasPrice?: Number256;
66
55
  }
67
56
  export interface SignExecuteScriptTxResult {
68
57
  fromGroup: number;
@@ -70,11 +59,12 @@ export interface SignExecuteScriptTxResult {
70
59
  unsignedTx: string;
71
60
  txId: string;
72
61
  signature: string;
62
+ gasAmount: number;
63
+ gasPrice: Number256;
73
64
  }
74
65
  export interface SignUnsignedTxParams {
75
66
  signerAddress: string;
76
67
  unsignedTx: string;
77
- submitTx?: boolean;
78
68
  }
79
69
  export interface SignUnsignedTxResult {
80
70
  fromGroup: number;
@@ -82,13 +72,8 @@ export interface SignUnsignedTxResult {
82
72
  unsignedTx: string;
83
73
  txId: string;
84
74
  signature: string;
85
- }
86
- export interface SignHexStringParams {
87
- signerAddress: string;
88
- hexString: string;
89
- }
90
- export interface SignHexStringResult {
91
- signature: string;
75
+ gasAmount: number;
76
+ gasPrice: Number256;
92
77
  }
93
78
  export interface SignMessageParams {
94
79
  signerAddress: string;
@@ -97,24 +82,36 @@ export interface SignMessageParams {
97
82
  export interface SignMessageResult {
98
83
  signature: string;
99
84
  }
85
+ export interface SubmitTransactionParams {
86
+ unsignedTx: string;
87
+ signature: string;
88
+ }
89
+ export interface SubmissionResult {
90
+ txId: string;
91
+ fromGroup: number;
92
+ toGroup: number;
93
+ }
100
94
  export interface SignerProvider {
101
- getAccounts(): Promise<Account[]>;
102
- signTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
103
- signDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
104
- signExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
95
+ get nodeProvider(): NodeProvider | undefined;
96
+ get explorerProvider(): ExplorerProvider | undefined;
97
+ getSelectedAccount(): Promise<Account>;
98
+ signAndSubmitTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
99
+ signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
100
+ signAndSubmitExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
101
+ signAndSubmitUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
105
102
  signUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
106
- signHexString(params: SignHexStringParams): Promise<SignHexStringResult>;
107
103
  signMessage(params: SignMessageParams): Promise<SignMessageResult>;
108
104
  }
109
- export declare abstract class SignerWithNodeProvider implements SignerProvider {
110
- readonly provider: NodeProvider;
111
- alwaysSubmitTx: boolean;
112
- abstract getAccounts(): Promise<Account[]>;
113
- getAccount(signerAddress: string): Promise<Account>;
114
- constructor(provider: NodeProvider, alwaysSubmitTx: boolean);
115
- private defaultSignerAddress;
116
- submitTransaction(unsignedTx: string, txHash: string, signerAddress?: string): Promise<SubmissionResult>;
117
- private shouldSubmitTx;
105
+ export declare abstract class SignerProviderSimple implements SignerProvider {
106
+ abstract get nodeProvider(): NodeProvider | undefined;
107
+ abstract get explorerProvider(): ExplorerProvider | undefined;
108
+ abstract getSelectedAccount(): Promise<Account>;
109
+ private getNodeProvider;
110
+ submitTransaction(params: SubmitTransactionParams): Promise<SubmissionResult>;
111
+ signAndSubmitTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
112
+ signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
113
+ signAndSubmitExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
114
+ signAndSubmitUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
118
115
  private usePublicKey;
119
116
  signTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
120
117
  buildTransferTx(params: SignTransferTxParams): Promise<node.BuildTransactionResult>;
@@ -123,21 +120,23 @@ export declare abstract class SignerWithNodeProvider implements SignerProvider {
123
120
  signExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
124
121
  buildScriptTx(params: SignExecuteScriptTxParams): Promise<node.BuildExecuteScriptTxResult>;
125
122
  signUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
126
- protected handleSign(response: {
127
- fromGroup: number;
128
- toGroup: number;
129
- signerAddress: string;
130
- unsignedTx: string;
131
- txId: string;
132
- }, submitTx: boolean): Promise<SignResult>;
133
- signHexString(params: SignHexStringParams): Promise<SignHexStringResult>;
134
123
  signMessage(params: SignMessageParams): Promise<SignMessageResult>;
135
124
  abstract signRaw(signerAddress: string, hexString: string): Promise<string>;
136
125
  }
137
- export interface SubmissionResult {
138
- txId: string;
139
- fromGroup: number;
140
- toGroup: number;
126
+ export declare abstract class SignerProviderWithMultipleAccounts extends SignerProviderSimple {
127
+ abstract getAccounts(): Promise<Account[]>;
128
+ getAccount(signerAddress: string): Promise<Account>;
129
+ abstract setSelectedAccount(address: string): Promise<void>;
141
130
  }
142
131
  export declare function verifyHexString(hexString: string, publicKey: string, signature: string): boolean;
143
132
  export declare function verifySignedMessage(message: string, publicKey: string, signature: string): boolean;
133
+ export interface Destination {
134
+ address: string;
135
+ attoAlphAmount: Number256;
136
+ tokens?: Token[];
137
+ lockTime?: number;
138
+ message?: string;
139
+ }
140
+ export declare function toApiDestination(data: Destination): node.Destination;
141
+ export declare function toApiDestinations(data: Destination[]): node.Destination[];
142
+ export declare function fromApiDestination(data: node.Destination): Destination;