@alephium/web3 0.41.0 → 0.42.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.
@@ -18,3 +18,4 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
19
  export * from './status'
20
20
  export * from './sign-verify'
21
+ export * from './utils'
@@ -0,0 +1,38 @@
1
+ /*
2
+ Copyright 2018 - 2022 The Alephium Authors
3
+ This file is part of the alephium project.
4
+
5
+ The library is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ The library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ import { node } from '../api'
20
+ import { getCurrentNodeProvider } from '../global'
21
+
22
+ function isConfirmed(txStatus: node.TxStatus): txStatus is node.Confirmed {
23
+ return txStatus.type === 'Confirmed'
24
+ }
25
+
26
+ export async function waitForTxConfirmation(
27
+ txId: string,
28
+ confirmations: number,
29
+ requestInterval: number
30
+ ): Promise<node.Confirmed> {
31
+ const provider = getCurrentNodeProvider()
32
+ const status = await provider.transactions.getTransactionsStatus({ txId: txId })
33
+ if (isConfirmed(status) && status.chainConfirmations >= confirmations) {
34
+ return status
35
+ }
36
+ await new Promise((r) => setTimeout(r, requestInterval))
37
+ return waitForTxConfirmation(txId, confirmations, requestInterval)
38
+ }
package/webpack.config.js CHANGED
@@ -41,7 +41,6 @@ module.exports = {
41
41
  fs: false,
42
42
  stream: require.resolve('stream-browserify'),
43
43
  crypto: require.resolve('crypto-browserify'),
44
- path: require.resolve('path-browserify'),
45
44
  buffer: require.resolve('buffer/')
46
45
  }
47
46
  },
@@ -1,15 +0,0 @@
1
- declare class CompilationError {
2
- lineStart: number;
3
- column: number;
4
- errorType: string;
5
- line: number;
6
- codeLine: string;
7
- errorIndicator: string;
8
- message: string;
9
- additionalLine1?: string | undefined;
10
- additionalLine2?: string | undefined;
11
- constructor(lineStart: number, column: number, errorType: string, line: number, codeLine: string, errorIndicator: string, message: string, additionalLine1?: string | undefined, additionalLine2?: string | undefined);
12
- reformat(line: number, file: string): string;
13
- }
14
- export declare function parseError(error: string): CompilationError | undefined;
15
- export {};
@@ -1,66 +0,0 @@
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.parseError = void 0;
21
- class CompilationError {
22
- constructor(lineStart, column, errorType, line, codeLine, errorIndicator, message, additionalLine1, additionalLine2) {
23
- this.lineStart = lineStart;
24
- this.column = column;
25
- this.errorType = errorType;
26
- this.line = line;
27
- this.codeLine = codeLine;
28
- this.errorIndicator = errorIndicator;
29
- this.message = message;
30
- this.additionalLine1 = additionalLine1;
31
- this.additionalLine2 = additionalLine2;
32
- }
33
- reformat(line, file) {
34
- const spaces = `${line}`.replace(/\d/g, ' ');
35
- const newError = `${file} (${line}:${this.column}): ${this.errorType}
36
- ${line} |${this.codeLine}
37
- ${spaces} |${this.errorIndicator}
38
- ${spaces} |${this.message}`;
39
- if (this.additionalLine1 && this.additionalLine2) {
40
- return `${newError}\n${spaces} |${this.additionalLine1}\n${spaces} |${this.additionalLine2}`;
41
- }
42
- else {
43
- return newError;
44
- }
45
- }
46
- }
47
- const errorRegex = /error \((\d+):(\d+)\):\s*(.*)\n\s*(\d+)\s*\|(.*)\n.*\|(.*)\n\s*\|(.*)(?:\n\s*\|(.*)\n\s*\|(.*))?/;
48
- function parseError(error) {
49
- const match = error.match(errorRegex);
50
- if (match) {
51
- const lineStart = parseInt(match[1]);
52
- const column = parseInt(match[2]);
53
- const errorType = match[3];
54
- const line = parseInt(match[4]);
55
- const codeLine = match[5];
56
- const errorIndicator = match[6];
57
- const message = match[7];
58
- const additionalLine1 = match[8];
59
- const additionalLine2 = match[9];
60
- return new CompilationError(lineStart, column, errorType, line, codeLine, errorIndicator, message, additionalLine1, additionalLine2);
61
- }
62
- else {
63
- undefined;
64
- }
65
- }
66
- exports.parseError = parseError;
@@ -1,77 +0,0 @@
1
- /*
2
- Copyright 2018 - 2022 The Alephium Authors
3
- This file is part of the alephium project.
4
-
5
- The library is free software: you can redistribute it and/or modify
6
- it under the terms of the GNU Lesser General Public License as published by
7
- the Free Software Foundation, either version 3 of the License, or
8
- (at your option) any later version.
9
-
10
- The library is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU Lesser General Public License for more details.
14
-
15
- You should have received a copy of the GNU Lesser General Public License
16
- along with the library. If not, see <http://www.gnu.org/licenses/>.
17
- */
18
-
19
- class CompilationError {
20
- constructor(
21
- public lineStart: number,
22
- public column: number,
23
- public errorType: string,
24
- public line: number,
25
- public codeLine: string,
26
- public errorIndicator: string,
27
- public message: string,
28
- public additionalLine1?: string,
29
- public additionalLine2?: string
30
- ) {}
31
-
32
- reformat(line: number, file: string): string {
33
- const spaces = `${line}`.replace(/\d/g, ' ')
34
- const newError = `${file} (${line}:${this.column}): ${this.errorType}
35
- ${line} |${this.codeLine}
36
- ${spaces} |${this.errorIndicator}
37
- ${spaces} |${this.message}`
38
-
39
- if (this.additionalLine1 && this.additionalLine2) {
40
- return `${newError}\n${spaces} |${this.additionalLine1}\n${spaces} |${this.additionalLine2}`
41
- } else {
42
- return newError
43
- }
44
- }
45
- }
46
-
47
- const errorRegex = /error \((\d+):(\d+)\):\s*(.*)\n\s*(\d+)\s*\|(.*)\n.*\|(.*)\n\s*\|(.*)(?:\n\s*\|(.*)\n\s*\|(.*))?/
48
-
49
- export function parseError(error: string): CompilationError | undefined {
50
- const match = error.match(errorRegex)
51
-
52
- if (match) {
53
- const lineStart = parseInt(match[1])
54
- const column = parseInt(match[2])
55
- const errorType = match[3]
56
- const line = parseInt(match[4])
57
- const codeLine = match[5]
58
- const errorIndicator = match[6]
59
- const message = match[7]
60
- const additionalLine1 = match[8]
61
- const additionalLine2 = match[9]
62
-
63
- return new CompilationError(
64
- lineStart,
65
- column,
66
- errorType,
67
- line,
68
- codeLine,
69
- errorIndicator,
70
- message,
71
- additionalLine1,
72
- additionalLine2
73
- )
74
- } else {
75
- undefined
76
- }
77
- }