@alephium/web3 0.2.0-test.1 → 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 (128) 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 +115 -17
  7. package/dist/src/api/api-alephium.js +145 -80
  8. package/dist/src/api/api-explorer.d.ts +178 -51
  9. package/dist/src/api/api-explorer.js +172 -37
  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 +68 -55
  17. package/dist/src/contract/contract.js +235 -384
  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 +6 -2
  24. package/dist/src/global.js +19 -3
  25. package/dist/src/index.d.ts +2 -1
  26. package/dist/src/index.js +23 -2
  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 -70
  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 -2
  40. package/dist/src/utils/subscription.js +0 -2
  41. package/dist/src/utils/utils.d.ts +4 -9
  42. package/dist/src/utils/utils.js +20 -24
  43. package/jest-config.json +11 -0
  44. package/package.json +11 -45
  45. package/src/api/api-alephium.ts +162 -25
  46. package/src/api/api-explorer.ts +247 -54
  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 +398 -429
  51. package/src/contract/events.ts +6 -5
  52. package/src/contract/ralph.ts +29 -4
  53. package/src/global.ts +23 -3
  54. package/src/index.ts +7 -1
  55. package/src/signer/index.ts +0 -1
  56. package/src/signer/signer.ts +165 -135
  57. package/src/transaction/index.ts +0 -1
  58. package/src/transaction/status.ts +5 -2
  59. package/src/utils/bs58.ts +11 -0
  60. package/src/utils/index.ts +0 -1
  61. package/src/utils/subscription.ts +0 -4
  62. package/src/utils/utils.ts +11 -19
  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 -13
  67. package/contracts/greeter/greeter.ral +0 -7
  68. package/contracts/greeter/greeter_interface.ral +0 -4
  69. package/contracts/greeter_main.ral +0 -7
  70. package/contracts/main.ral +0 -4
  71. package/contracts/sub/sub.ral +0 -10
  72. package/contracts/test/metadata.ral +0 -18
  73. package/contracts/test/warnings.ral +0 -8
  74. package/dev/user.conf +0 -29
  75. package/dist/scripts/create-project.d.ts +0 -2
  76. package/dist/scripts/create-project.js +0 -125
  77. package/dist/scripts/rename-gitignore.d.ts +0 -1
  78. package/dist/scripts/start-devnet.d.ts +0 -1
  79. package/dist/scripts/start-devnet.js +0 -131
  80. package/dist/scripts/stop-devnet.d.ts +0 -1
  81. package/dist/scripts/stop-devnet.js +0 -32
  82. package/dist/src/signer/node-wallet.d.ts +0 -11
  83. package/dist/src/signer/node-wallet.js +0 -57
  84. package/dist/src/test/index.d.ts +0 -6
  85. package/dist/src/test/index.js +0 -41
  86. package/dist/src/test/privatekey-wallet.d.ts +0 -11
  87. package/dist/src/test/privatekey-wallet.js +0 -68
  88. package/dist/src/transaction/sign-verify.d.ts +0 -2
  89. package/dist/src/transaction/sign-verify.js +0 -58
  90. package/dist/src/utils/password-crypto.d.ts +0 -2
  91. package/dist/src/utils/password-crypto.js +0 -69
  92. package/gitignore +0 -9
  93. package/scripts/create-project.ts +0 -137
  94. package/scripts/start-devnet.js +0 -141
  95. package/scripts/stop-devnet.js +0 -32
  96. package/src/contract/ralph.test.ts +0 -178
  97. package/src/fixtures/address.json +0 -36
  98. package/src/fixtures/balance.json +0 -9
  99. package/src/fixtures/self-clique.json +0 -19
  100. package/src/fixtures/transaction.json +0 -13
  101. package/src/fixtures/transactions.json +0 -179
  102. package/src/signer/fixtures/genesis.json +0 -26
  103. package/src/signer/fixtures/wallets.json +0 -26
  104. package/src/signer/node-wallet.ts +0 -65
  105. package/src/test/index.ts +0 -31
  106. package/src/test/privatekey-wallet.ts +0 -57
  107. package/src/transaction/sign-verify.test.ts +0 -50
  108. package/src/transaction/sign-verify.ts +0 -39
  109. package/src/utils/address.test.ts +0 -47
  110. package/src/utils/djb2.test.ts +0 -35
  111. package/src/utils/password-crypto.test.ts +0 -27
  112. package/src/utils/password-crypto.ts +0 -77
  113. package/src/utils/utils.test.ts +0 -161
  114. package/templates/base/README.md +0 -34
  115. package/templates/base/package.json +0 -35
  116. package/templates/base/src/greeter.ts +0 -42
  117. package/templates/base/tsconfig.json +0 -19
  118. package/templates/react/README.md +0 -34
  119. package/templates/react/config-overrides.js +0 -18
  120. package/templates/react/package.json +0 -66
  121. package/templates/react/src/App.tsx +0 -42
  122. package/templates/react/src/artifacts/greeter.ral.json +0 -26
  123. package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
  124. package/templates/shared/.eslintrc.json +0 -12
  125. package/templates/shared/scripts/header.js +0 -0
  126. package/test/contract.test.ts +0 -213
  127. package/test/events.test.ts +0 -141
  128. package/test/transaction.test.ts +0 -73
@@ -0,0 +1,235 @@
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.fromApiVal = exports.fromApiArray = exports.fromApiVals = exports.toApiVal = exports.toApiArray = exports.toApiAddress = exports.toApiByteVec = exports.fromApiNumber256 = exports.toApiNumber256Optional = exports.toApiNumber256 = exports.toApiBoolean = exports.fromApiTokens = exports.fromApiToken = exports.toApiTokens = exports.toApiToken = void 0;
21
+ const utils_1 = require("../utils");
22
+ utils_1.assertType;
23
+ function toApiToken(token) {
24
+ return { id: token.id, amount: toApiNumber256(token.amount) };
25
+ }
26
+ exports.toApiToken = toApiToken;
27
+ function toApiTokens(tokens) {
28
+ return tokens?.map(toApiToken);
29
+ }
30
+ exports.toApiTokens = toApiTokens;
31
+ function fromApiToken(token) {
32
+ return { id: token.id, amount: fromApiNumber256(token.amount) };
33
+ }
34
+ exports.fromApiToken = fromApiToken;
35
+ function fromApiTokens(tokens) {
36
+ return tokens?.map(fromApiToken);
37
+ }
38
+ exports.fromApiTokens = fromApiTokens;
39
+ function toApiBoolean(v) {
40
+ if (typeof v === 'boolean') {
41
+ return v;
42
+ }
43
+ else {
44
+ throw new Error(`Invalid boolean value: ${v}`);
45
+ }
46
+ }
47
+ exports.toApiBoolean = toApiBoolean;
48
+ // TODO: check integer bounds
49
+ function toApiNumber256(v) {
50
+ if ((typeof v === 'number' && Number.isInteger(v)) || typeof v === 'bigint') {
51
+ return v.toString();
52
+ }
53
+ else if (typeof v === 'string') {
54
+ return v;
55
+ }
56
+ else {
57
+ throw new Error(`Invalid 256 bit number: ${v}`);
58
+ }
59
+ }
60
+ exports.toApiNumber256 = toApiNumber256;
61
+ function toApiNumber256Optional(v) {
62
+ return v === undefined ? undefined : toApiNumber256(v);
63
+ }
64
+ exports.toApiNumber256Optional = toApiNumber256Optional;
65
+ function fromApiNumber256(n) {
66
+ return BigInt(n);
67
+ }
68
+ exports.fromApiNumber256 = fromApiNumber256;
69
+ // TODO: check hex string
70
+ function toApiByteVec(v) {
71
+ if (typeof v === 'string') {
72
+ // try to convert from address to contract id
73
+ try {
74
+ const address = utils_1.bs58.decode(v);
75
+ if (address.length == 33 && address[0] == 3) {
76
+ return Buffer.from(address.slice(1)).toString('hex');
77
+ }
78
+ }
79
+ catch (_) {
80
+ return v;
81
+ }
82
+ return v;
83
+ }
84
+ else {
85
+ throw new Error(`Invalid string: ${v}`);
86
+ }
87
+ }
88
+ exports.toApiByteVec = toApiByteVec;
89
+ function toApiAddress(v) {
90
+ if (typeof v === 'string') {
91
+ try {
92
+ utils_1.bs58.decode(v);
93
+ return v;
94
+ }
95
+ catch (error) {
96
+ throw new Error(`Invalid base58 string: ${v}`);
97
+ }
98
+ }
99
+ else {
100
+ throw new Error(`Invalid string: ${v}`);
101
+ }
102
+ }
103
+ exports.toApiAddress = toApiAddress;
104
+ function toApiArray(tpe, v) {
105
+ if (!Array.isArray(v)) {
106
+ throw new Error(`Expected array, got ${v}`);
107
+ }
108
+ const semiColonIndex = tpe.lastIndexOf(';');
109
+ if (semiColonIndex == -1) {
110
+ throw new Error(`Invalid Val type: ${tpe}`);
111
+ }
112
+ const subType = tpe.slice(1, semiColonIndex);
113
+ const dim = parseInt(tpe.slice(semiColonIndex + 1, -1));
114
+ if (v.length != dim) {
115
+ throw new Error(`Invalid val dimension: ${v}`);
116
+ }
117
+ else {
118
+ return { value: v.map((v) => toApiVal(v, subType)), type: 'Array' };
119
+ }
120
+ }
121
+ exports.toApiArray = toApiArray;
122
+ function toApiVal(v, tpe) {
123
+ if (tpe === 'Bool') {
124
+ return { value: toApiBoolean(v), type: tpe };
125
+ }
126
+ else if (tpe === 'U256' || tpe === 'I256') {
127
+ return { value: toApiNumber256(v), type: tpe };
128
+ }
129
+ else if (tpe === 'ByteVec') {
130
+ return { value: toApiByteVec(v), type: tpe };
131
+ }
132
+ else if (tpe === 'Address') {
133
+ return { value: toApiAddress(v), type: tpe };
134
+ }
135
+ else {
136
+ return toApiArray(tpe, v);
137
+ }
138
+ }
139
+ exports.toApiVal = toApiVal;
140
+ function _fromApiVal(vals, valIndex, tpe) {
141
+ if (vals.length === 0) {
142
+ throw new Error('Not enough Vals');
143
+ }
144
+ const firstVal = vals[`${valIndex}`];
145
+ if (tpe === 'Bool' && firstVal.type === tpe) {
146
+ return [firstVal.value, valIndex + 1];
147
+ }
148
+ else if ((tpe === 'U256' || tpe === 'I256') && firstVal.type === tpe) {
149
+ return [fromApiNumber256(firstVal.value), valIndex + 1];
150
+ }
151
+ else if ((tpe === 'ByteVec' || tpe === 'Address') && firstVal.type === tpe) {
152
+ return [firstVal.value, valIndex + 1];
153
+ }
154
+ else {
155
+ const [baseType, dims] = decodeArrayType(tpe);
156
+ const arraySize = dims.reduce((a, b) => a * b);
157
+ const nextIndex = valIndex + arraySize;
158
+ const valsToUse = vals.slice(valIndex, nextIndex);
159
+ if (valsToUse.length == arraySize && valsToUse.every((val) => val.type === baseType)) {
160
+ const localVals = valsToUse.map((val) => fromApiVal(val, baseType));
161
+ return [foldVals(localVals, dims), nextIndex];
162
+ }
163
+ else {
164
+ throw new Error(`Invalid array Val type: ${valsToUse}, ${tpe}`);
165
+ }
166
+ }
167
+ }
168
+ function fromApiVals(vals, names, types) {
169
+ let valIndex = 0;
170
+ const result = {};
171
+ types.forEach((currentType, index) => {
172
+ const currentName = names[`${index}`];
173
+ const [val, nextIndex] = _fromApiVal(vals, valIndex, currentType);
174
+ valIndex = nextIndex;
175
+ result[`${currentName}`] = val;
176
+ });
177
+ return result;
178
+ }
179
+ exports.fromApiVals = fromApiVals;
180
+ function fromApiArray(vals, types) {
181
+ let valIndex = 0;
182
+ const result = [];
183
+ for (const currentType of types) {
184
+ const [val, nextIndex] = _fromApiVal(vals, valIndex, currentType);
185
+ result.push(val);
186
+ valIndex = nextIndex;
187
+ }
188
+ return result;
189
+ }
190
+ exports.fromApiArray = fromApiArray;
191
+ function fromApiVal(v, tpe) {
192
+ if (v.type === 'Bool' && v.type === tpe) {
193
+ return v.value;
194
+ }
195
+ else if ((v.type === 'U256' || v.type === 'I256') && v.type === tpe) {
196
+ return fromApiNumber256(v.value);
197
+ }
198
+ else if ((v.type === 'ByteVec' || v.type === 'Address') && v.type === tpe) {
199
+ return v.value;
200
+ }
201
+ else {
202
+ throw new Error(`Invalid node.Val type: ${v}`);
203
+ }
204
+ }
205
+ exports.fromApiVal = fromApiVal;
206
+ function decodeArrayType(tpe) {
207
+ const semiColonIndex = tpe.lastIndexOf(';');
208
+ if (semiColonIndex === -1) {
209
+ throw new Error(`Invalid Val type: ${tpe}`);
210
+ }
211
+ const subType = tpe.slice(1, semiColonIndex);
212
+ const dim = parseInt(tpe.slice(semiColonIndex + 1, -1));
213
+ if (subType[0] == '[') {
214
+ const [baseType, subDim] = decodeArrayType(subType);
215
+ return [baseType, (subDim.unshift(dim), subDim)];
216
+ }
217
+ else {
218
+ return [subType, [dim]];
219
+ }
220
+ }
221
+ function foldVals(vals, dims) {
222
+ if (dims.length == 1) {
223
+ return vals;
224
+ }
225
+ else {
226
+ const result = [];
227
+ const chunkSize = vals.length / dims[0];
228
+ const chunkDims = dims.slice(1);
229
+ for (let i = 0; i < vals.length; i += chunkSize) {
230
+ const chunk = vals.slice(i, i + chunkSize);
231
+ result.push(foldVals(chunk, chunkDims));
232
+ }
233
+ return result;
234
+ }
235
+ }
@@ -0,0 +1,6 @@
1
+ export declare function convertHttpResponse<T>(response: {
2
+ data: T;
3
+ error?: {
4
+ detail: string;
5
+ };
6
+ }): T;
@@ -16,9 +16,14 @@ GNU Lesser General Public License for more details.
16
16
  You should have received a copy of the GNU Lesser General Public License
17
17
  along with the library. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
- const { rename } = require('fs');
20
- rename(process.argv[2], process.argv[3], function (error) {
21
- if (error)
22
- console.log(error);
23
- console.log(`Renamed ${process.argv[2]} to ${process.argv[3]}.`);
24
- });
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.convertHttpResponse = void 0;
21
+ function convertHttpResponse(response) {
22
+ if (response.error) {
23
+ throw new Error(`[Node API Error] - ${response.error.detail}`);
24
+ }
25
+ else {
26
+ return response.data;
27
+ }
28
+ }
29
+ exports.convertHttpResponse = convertHttpResponse;
@@ -1,35 +1,35 @@
1
- import { node, NodeProvider } from '../api';
2
- import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerWithNodeProvider } from '../signer';
3
- import { CompileContractResult, CompileScriptResult } from '../api/api-alephium';
4
- declare type FieldsSig = node.FieldsSig;
5
- declare type EventSig = node.EventSig;
6
- declare type FunctionSig = node.FunctionSig;
1
+ import { NamedVals, node, Number256, Token, Val } from '../api';
2
+ import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerProvider, SignExecuteScriptTxResult, SignDeployContractTxResult } from '../signer';
3
+ export declare type FieldsSig = node.FieldsSig;
4
+ export declare type EventSig = node.EventSig;
5
+ export declare type FunctionSig = node.FunctionSig;
6
+ export declare type Fields = NamedVals;
7
+ export declare type Arguments = NamedVals;
7
8
  declare enum SourceType {
8
9
  Contract = 0,
9
10
  Script = 1,
10
11
  AbstractContract = 2,
11
12
  Interface = 3
12
13
  }
13
- export declare type CompilerOptions = {
14
+ export declare type CompilerOptions = node.CompilerOptions & {
14
15
  errorOnWarnings: boolean;
15
- ignoreUnusedConstantsWarnings: boolean;
16
16
  };
17
+ export declare const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions;
17
18
  export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
18
19
  declare class TypedMatcher<T extends SourceType> {
19
20
  matcher: RegExp;
20
21
  type: T;
21
- name: string | undefined;
22
22
  constructor(pattern: string, type: T);
23
23
  match(str: string): number;
24
24
  }
25
25
  declare class SourceFile {
26
26
  type: SourceType;
27
- typeId: string;
28
27
  contractPath: string;
29
28
  sourceCode: string;
30
29
  sourceCodeHash: string;
31
- getArtifactPath(artifactsRootPath: string): string;
32
- constructor(type: SourceType, typeId: string, sourceCode: string, contractPath: string);
30
+ getArtifactPath(artifactsRootDir: string): string;
31
+ constructor(type: SourceType, sourceCode: string, sourceCodeHash: string, contractPath: string);
32
+ static from(type: SourceType, sourceCode: string, contractPath: string): Promise<SourceFile>;
33
33
  }
34
34
  declare class Compiled<T extends Artifact> {
35
35
  sourceFile: SourceFile;
@@ -37,37 +37,56 @@ declare class Compiled<T extends Artifact> {
37
37
  warnings: string[];
38
38
  constructor(sourceFile: SourceFile, artifact: T, warnings: string[]);
39
39
  }
40
+ declare type CodeInfo = {
41
+ sourceCodeHash: string;
42
+ bytecodeDebugPatch: string;
43
+ codeHashDebug: string;
44
+ warnings: string[];
45
+ };
46
+ declare class ProjectArtifact {
47
+ static readonly artifactFileName = ".project.json";
48
+ compilerOptionsUsed: node.CompilerOptions;
49
+ infos: Map<string, CodeInfo>;
50
+ static checkCompilerOptionsParameter(compilerOptions: node.CompilerOptions): void;
51
+ constructor(compilerOptionsUsed: node.CompilerOptions, infos: Map<string, CodeInfo>);
52
+ saveToFile(rootPath: string): Promise<void>;
53
+ needToReCompile(compilerOptions: node.CompilerOptions, files: SourceFile[]): boolean;
54
+ static from(rootPath: string): Promise<ProjectArtifact | undefined>;
55
+ }
40
56
  export declare class Project {
41
57
  sourceFiles: SourceFile[];
42
58
  contracts: Compiled<Contract>[];
43
59
  scripts: Compiled<Script>[];
44
- readonly contractsRootPath: string;
45
- readonly artifactsRootPath: string;
46
- readonly nodeProvider: NodeProvider;
60
+ projectArtifact: ProjectArtifact;
61
+ readonly contractsRootDir: string;
62
+ readonly artifactsRootDir: string;
47
63
  static currentProject: Project;
48
64
  static readonly abstractContractMatcher: TypedMatcher<SourceType>;
49
65
  static readonly contractMatcher: TypedMatcher<SourceType.Contract>;
50
66
  static readonly interfaceMatcher: TypedMatcher<SourceType.Interface>;
51
67
  static readonly scriptMatcher: TypedMatcher<SourceType.Script>;
52
68
  static readonly matchers: TypedMatcher<SourceType>[];
69
+ static buildProjectArtifact(sourceFiles: SourceFile[], contracts: Compiled<Contract>[], scripts: Compiled<Script>[], compilerOptions: node.CompilerOptions): ProjectArtifact;
53
70
  private constructor();
54
71
  private getContractPath;
55
- private static checkCompilerWarnings;
56
- static contract(path: string, compilerOptions?: Partial<CompilerOptions>): Contract;
57
- static script(path: string, compilerOptions?: Partial<CompilerOptions>): Script;
72
+ static checkCompilerWarnings(warnings: string[], errorOnWarnings: boolean): void;
73
+ static contract(name: string): Contract;
74
+ static script(name: string): Script;
58
75
  private saveArtifactsToFile;
59
76
  contractByCodeHash(codeHash: string): Contract;
60
- private saveProjectArtifactToFile;
61
77
  private static compile;
62
78
  private static loadArtifacts;
63
79
  private static loadSourceFile;
64
80
  private static loadSourceFiles;
65
- static build(contractsRootPath?: string, artifactsRootPath?: string): Promise<void>;
81
+ static readonly DEFAULT_CONTRACTS_DIR = "contracts";
82
+ static readonly DEFAULT_ARTIFACTS_DIR = "artifacts";
83
+ static build(compilerOptionsPartial?: Partial<CompilerOptions>, contractsRootDir?: string, artifactsRootDir?: string): Promise<void>;
66
84
  }
67
85
  export declare abstract class Artifact {
68
- readonly typeId: string;
86
+ readonly version: string;
87
+ readonly name: string;
69
88
  readonly functions: FunctionSig[];
70
- constructor(typeId: string, functions: FunctionSig[]);
89
+ constructor(version: string, name: string, functions: FunctionSig[]);
71
90
  abstract buildByteCodeToDeploy(initialFields?: Fields): string;
72
91
  publicFunctions(): string[];
73
92
  usingPreapprovedAssetsFunctions(): string[];
@@ -75,61 +94,55 @@ export declare abstract class Artifact {
75
94
  }
76
95
  export declare class Contract extends Artifact {
77
96
  readonly bytecode: string;
97
+ readonly bytecodeDebugPatch: string;
78
98
  readonly codeHash: string;
79
99
  readonly fieldsSig: FieldsSig;
80
100
  readonly eventsSig: EventSig[];
81
- constructor(typeId: string, bytecode: string, codeHash: string, fieldsSig: FieldsSig, eventsSig: EventSig[], functions: FunctionSig[]);
82
- static fromJson(artifact: any): Contract;
83
- static fromCompileResult(typeId: string, result: CompileContractResult): Contract;
84
- static fromArtifactFile(path: string): Promise<Contract>;
101
+ readonly bytecodeDebug: string;
102
+ readonly codeHashDebug: string;
103
+ constructor(version: string, name: string, bytecode: string, bytecodeDebugPatch: string, codeHash: string, codeHashDebug: string, fieldsSig: FieldsSig, eventsSig: EventSig[], functions: FunctionSig[]);
104
+ static fromJson(artifact: any, bytecodeDebugPatch?: string, codeHashDebug?: string): Contract;
105
+ static fromCompileResult(result: node.CompileContractResult): Contract;
106
+ static fromArtifactFile(path: string, bytecodeDebugPatch: string, codeHashDebug: string): Promise<Contract>;
85
107
  fetchState(address: string, group: number): Promise<ContractState>;
86
108
  toString(): string;
87
109
  toState(fields: Fields, asset: Asset, address?: string): ContractState;
88
110
  static randomAddress(): string;
111
+ private _printDebugMessages;
89
112
  private _test;
90
- testPublicMethod(funcName: string, params: TestContractParams): Promise<TestContractResult>;
91
- testPrivateMethod(funcName: string, params: TestContractParams): Promise<TestContractResult>;
113
+ testPublicMethod(funcName: string, params: TestContractParams, printDebugMessages?: boolean): Promise<TestContractResult>;
114
+ testPrivateMethod(funcName: string, params: TestContractParams, printDebugMessages?: boolean): Promise<TestContractResult>;
92
115
  toApiFields(fields?: Fields): node.Val[];
93
116
  toApiArgs(funcName: string, args?: Arguments): node.Val[];
94
117
  getMethodIndex(funcName: string): number;
95
118
  toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
96
119
  toTestContract(funcName: string, params: TestContractParams): node.TestContract;
97
- fromApiContractState(state: node.ContractState): Promise<ContractState>;
120
+ fromApiContractState(state: node.ContractState): ContractState;
98
121
  static ContractCreatedEvent: EventSig;
99
122
  static ContractDestroyedEvent: EventSig;
100
- static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): Promise<ContractEventByTxId>;
101
- fromTestContractResult(methodIndex: number, result: node.TestContractResult): Promise<TestContractResult>;
102
- paramsForDeployment(params: BuildDeployContractTx): Promise<SignDeployContractTxParams>;
103
- transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<DeployContractTransaction>;
123
+ static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): ContractEventByTxId;
124
+ fromTestContractResult(methodIndex: number, result: node.TestContractResult): TestContractResult;
125
+ txParamsForDeployment(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<SignDeployContractTxParams>;
126
+ deploy(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<SignDeployContractTxResult>;
104
127
  buildByteCodeToDeploy(initialFields: Fields): string;
105
128
  }
106
129
  export declare class Script extends Artifact {
107
130
  readonly bytecodeTemplate: string;
131
+ readonly bytecodeDebugPatch: string;
108
132
  readonly fieldsSig: FieldsSig;
109
- constructor(typeId: string, bytecodeTemplate: string, fieldsSig: FieldsSig, functions: FunctionSig[]);
110
- static fromCompileResult(typeId: string, result: CompileScriptResult): Script;
111
- static fromJson(artifact: any): Script;
112
- static fromArtifactFile(path: string): Promise<Script>;
133
+ constructor(version: string, name: string, bytecodeTemplate: string, bytecodeDebugPatch: string, fieldsSig: FieldsSig, functions: FunctionSig[]);
134
+ static fromCompileResult(result: node.CompileScriptResult): Script;
135
+ static fromJson(artifact: any, bytecodeDebugPatch?: string): Script;
136
+ static fromArtifactFile(path: string, bytecodeDebugPatch: string): Promise<Script>;
113
137
  toString(): string;
114
- paramsForDeployment(params: BuildExecuteScriptTx): Promise<SignExecuteScriptTxParams>;
115
- transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<BuildScriptTxResult>;
138
+ txParamsForExecution(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<SignExecuteScriptTxParams>;
139
+ execute(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<SignExecuteScriptTxResult>;
116
140
  buildByteCodeToDeploy(initialFields: Fields): string;
117
141
  }
118
- export declare type Number256 = number | bigint | string;
119
- export declare type Val = Number256 | boolean | string | Val[];
120
- export declare type NamedVals = Record<string, Val>;
121
- export declare type Fields = NamedVals;
122
- export declare type Arguments = NamedVals;
123
- export declare function extractArray(tpe: string, v: Val): node.Val;
124
- export declare function toApiVal(v: Val, tpe: string): node.Val;
125
142
  export interface Asset {
126
143
  alphAmount: Number256;
127
144
  tokens?: Token[];
128
145
  }
129
- export interface Token {
130
- id: string;
131
- amount: Number256;
132
- }
133
146
  export interface InputAsset {
134
147
  address: string;
135
148
  asset: Asset;
@@ -166,14 +179,16 @@ export interface ContractEventByTxId {
166
179
  name: string;
167
180
  fields: Fields;
168
181
  }
182
+ export declare type DebugMessage = node.DebugMessage;
169
183
  export interface TestContractResult {
170
- address: string;
171
184
  contractId: string;
185
+ contractAddress: string;
172
186
  returns: Val[];
173
187
  gasUsed: number;
174
188
  contracts: ContractState[];
175
189
  txOutputs: Output[];
176
190
  events: ContractEventByTxId[];
191
+ debugMessages: DebugMessage[];
177
192
  }
178
193
  export declare type Output = AssetOutput | ContractOutput;
179
194
  export interface AssetOutput extends Asset {
@@ -186,7 +201,7 @@ export interface ContractOutput {
186
201
  type: string;
187
202
  address: string;
188
203
  alphAmount: Number256;
189
- tokens: Token[];
204
+ tokens?: Token[];
190
205
  }
191
206
  export interface DeployContractTransaction {
192
207
  fromGroup: number;
@@ -199,12 +214,11 @@ export interface DeployContractTransaction {
199
214
  export interface BuildDeployContractTx {
200
215
  signerAddress: string;
201
216
  initialFields?: Fields;
202
- initialAttoAlphAmount?: string;
217
+ initialAttoAlphAmount?: Number256;
203
218
  initialTokenAmounts?: Token[];
204
219
  issueTokenAmount?: Number256;
205
220
  gasAmount?: number;
206
221
  gasPrice?: Number256;
207
- submitTx?: boolean;
208
222
  }
209
223
  export interface BuildExecuteScriptTx {
210
224
  signerAddress: string;
@@ -213,7 +227,6 @@ export interface BuildExecuteScriptTx {
213
227
  tokens?: Token[];
214
228
  gasAmount?: number;
215
229
  gasPrice?: Number256;
216
- submitTx?: boolean;
217
230
  }
218
231
  export interface BuildScriptTxResult {
219
232
  fromGroup: number;