@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
@@ -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,101 +1,148 @@
1
- import { NodeProvider } from '../api';
2
- import { node } from '../api';
3
- import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerWithNodeProvider } from '../signer';
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;
8
+ declare enum SourceType {
9
+ Contract = 0,
10
+ Script = 1,
11
+ AbstractContract = 2,
12
+ Interface = 3
13
+ }
14
+ export declare type CompilerOptions = node.CompilerOptions & {
15
+ errorOnWarnings: boolean;
16
+ };
17
+ export declare const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions;
18
+ export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
19
+ declare class TypedMatcher<T extends SourceType> {
20
+ matcher: RegExp;
21
+ type: T;
22
+ constructor(pattern: string, type: T);
23
+ match(str: string): number;
24
+ }
4
25
  declare class SourceFile {
5
- readonly dirs: string[];
6
- readonly dirPath: string;
7
- readonly contractPath: string;
8
- readonly artifactPath: string;
9
- constructor(dirs: string[], fileName: string);
10
- }
11
- export declare abstract class Common {
12
- readonly sourceCodeSha256: string;
13
- readonly functions: node.FunctionSig[];
14
- static readonly importRegex: RegExp;
15
- static readonly contractRegex: RegExp;
16
- static readonly interfaceRegex: RegExp;
17
- static readonly scriptRegex: RegExp;
18
- private static _artifactCache;
19
- static artifactCacheCapacity: number;
20
- protected static _getArtifactFromCache(codeHash: string): Contract | Script | undefined;
21
- protected static _putArtifactToCache(contract: Contract): void;
22
- constructor(sourceCodeSha256: string, functions: node.FunctionSig[]);
23
- protected static _artifactsFolder(): string;
24
- static getSourceFile(path: string, _dirs: string[]): SourceFile;
25
- protected static _handleImports(pathes: string[], contractStr: string, importsCache: string[]): Promise<string>;
26
- protected static _loadContractStr(sourceFile: SourceFile, importsCache: string[], validate: (code: string) => void): Promise<string>;
27
- static checkFileNameExtension(fileName: string): void;
28
- protected static _from<T extends {
29
- sourceCodeSha256: string;
30
- }>(provider: NodeProvider, sourceFile: SourceFile, loadContractStr: (sourceFile: SourceFile, importsCache: string[]) => Promise<string>, compile: (provider: NodeProvider, sourceFile: SourceFile, contractStr: string, contractHash: string) => Promise<T>): Promise<T>;
31
- protected _saveToFile(sourceFile: SourceFile): Promise<void>;
26
+ type: SourceType;
27
+ contractPath: string;
28
+ sourceCode: string;
29
+ sourceCodeHash: 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
+ }
34
+ declare class Compiled<T extends Artifact> {
35
+ sourceFile: SourceFile;
36
+ artifact: T;
37
+ warnings: string[];
38
+ constructor(sourceFile: SourceFile, artifact: T, warnings: string[]);
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
+ }
56
+ export declare class Project {
57
+ sourceFiles: SourceFile[];
58
+ contracts: Compiled<Contract>[];
59
+ scripts: Compiled<Script>[];
60
+ projectArtifact: ProjectArtifact;
61
+ readonly contractsRootDir: string;
62
+ readonly artifactsRootDir: string;
63
+ static currentProject: Project;
64
+ static readonly abstractContractMatcher: TypedMatcher<SourceType>;
65
+ static readonly contractMatcher: TypedMatcher<SourceType.Contract>;
66
+ static readonly interfaceMatcher: TypedMatcher<SourceType.Interface>;
67
+ static readonly scriptMatcher: TypedMatcher<SourceType.Script>;
68
+ static readonly matchers: TypedMatcher<SourceType>[];
69
+ static buildProjectArtifact(sourceFiles: SourceFile[], contracts: Compiled<Contract>[], scripts: Compiled<Script>[], compilerOptions: node.CompilerOptions): ProjectArtifact;
70
+ private constructor();
71
+ private getContractPath;
72
+ static checkCompilerWarnings(warnings: string[], errorOnWarnings: boolean): void;
73
+ static contract(name: string): Contract;
74
+ static script(name: string): Script;
75
+ private saveArtifactsToFile;
76
+ contractByCodeHash(codeHash: string): Contract;
77
+ private static compile;
78
+ private static loadArtifacts;
79
+ private static loadSourceFile;
80
+ private static loadSourceFiles;
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>;
84
+ }
85
+ export declare abstract class Artifact {
86
+ readonly version: string;
87
+ readonly name: string;
88
+ readonly functions: FunctionSig[];
89
+ constructor(version: string, name: string, functions: FunctionSig[]);
32
90
  abstract buildByteCodeToDeploy(initialFields?: Fields): string;
91
+ publicFunctions(): string[];
92
+ usingPreapprovedAssetsFunctions(): string[];
93
+ usingAssetsInContractFunctions(): string[];
33
94
  }
34
- export declare class Contract extends Common {
95
+ export declare class Contract extends Artifact {
35
96
  readonly bytecode: string;
97
+ readonly bytecodeDebugPatch: string;
36
98
  readonly codeHash: string;
37
- readonly fieldsSig: node.FieldsSig;
38
- readonly eventsSig: node.EventSig[];
39
- constructor(sourceCodeSha256: string, bytecode: string, codeHash: string, fieldsSig: node.FieldsSig, eventsSig: node.EventSig[], functions: node.FunctionSig[]);
40
- static checkCodeType(fileName: string, contractStr: string): void;
41
- private static loadContractStr;
42
- static fromSource(provider: NodeProvider, path: string): Promise<Contract>;
43
- private static compile;
44
- static fromJson(artifact: any): Contract;
45
- static fromArtifactFile(path: string): Promise<Contract>;
46
- fetchState(provider: NodeProvider, address: string, group: number): Promise<ContractState>;
99
+ readonly fieldsSig: FieldsSig;
100
+ readonly eventsSig: EventSig[];
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>;
107
+ fetchState(address: string, group: number): Promise<ContractState>;
47
108
  toString(): string;
48
109
  toState(fields: Fields, asset: Asset, address?: string): ContractState;
49
110
  static randomAddress(): string;
111
+ private _printDebugMessages;
50
112
  private _test;
51
- testPublicMethod(provider: NodeProvider, funcName: string, params: TestContractParams): Promise<TestContractResult>;
52
- testPrivateMethod(provider: NodeProvider, 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>;
53
115
  toApiFields(fields?: Fields): node.Val[];
54
116
  toApiArgs(funcName: string, args?: Arguments): node.Val[];
55
117
  getMethodIndex(funcName: string): number;
56
118
  toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
57
119
  toTestContract(funcName: string, params: TestContractParams): node.TestContract;
58
- static fromCodeHash(codeHash: string): Promise<Contract>;
59
- static getFieldsSig(state: node.ContractState): Promise<node.FieldsSig>;
60
- fromApiContractState(state: node.ContractState): Promise<ContractState>;
61
- static ContractCreatedEvent: node.EventSig;
62
- static ContractDestroyedEvent: node.EventSig;
63
- static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): Promise<ContractEventByTxId>;
64
- fromTestContractResult(methodIndex: number, result: node.TestContractResult): Promise<TestContractResult>;
65
- paramsForDeployment(params: BuildDeployContractTx): Promise<SignDeployContractTxParams>;
66
- transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<DeployContractTransaction>;
120
+ fromApiContractState(state: node.ContractState): ContractState;
121
+ static ContractCreatedEvent: EventSig;
122
+ static ContractDestroyedEvent: EventSig;
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>;
67
127
  buildByteCodeToDeploy(initialFields: Fields): string;
68
128
  }
69
- export declare class Script extends Common {
129
+ export declare class Script extends Artifact {
70
130
  readonly bytecodeTemplate: string;
71
- readonly fieldsSig: node.FieldsSig;
72
- constructor(sourceCodeSha256: string, bytecodeTemplate: string, fieldsSig: node.FieldsSig, functions: node.FunctionSig[]);
73
- static checkCodeType(fileName: string, contractStr: string): void;
74
- private static loadContractStr;
75
- static fromSource(provider: NodeProvider, path: string): Promise<Script>;
76
- private static compile;
77
- static fromJson(artifact: any): Script;
78
- static fromArtifactFile(path: string): Promise<Script>;
131
+ readonly bytecodeDebugPatch: string;
132
+ readonly fieldsSig: FieldsSig;
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>;
79
137
  toString(): string;
80
- paramsForDeployment(params: BuildExecuteScriptTx): Promise<SignExecuteScriptTxParams>;
81
- 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>;
82
140
  buildByteCodeToDeploy(initialFields: Fields): string;
83
141
  }
84
- export declare type Number256 = number | bigint | string;
85
- export declare type Val = Number256 | boolean | string | Val[];
86
- export declare type NamedVals = Record<string, Val>;
87
- export declare type Fields = NamedVals;
88
- export declare type Arguments = NamedVals;
89
- export declare function extractArray(tpe: string, v: Val): node.Val;
90
- export declare function toApiVal(v: Val, tpe: string): node.Val;
91
142
  export interface Asset {
92
143
  alphAmount: Number256;
93
144
  tokens?: Token[];
94
145
  }
95
- export interface Token {
96
- id: string;
97
- amount: Number256;
98
- }
99
146
  export interface InputAsset {
100
147
  address: string;
101
148
  asset: Asset;
@@ -107,7 +154,7 @@ export interface ContractState {
107
154
  initialStateHash?: string;
108
155
  codeHash: string;
109
156
  fields: Fields;
110
- fieldsSig: node.FieldsSig;
157
+ fieldsSig: FieldsSig;
111
158
  asset: Asset;
112
159
  }
113
160
  export interface TestContractParams {
@@ -132,14 +179,16 @@ export interface ContractEventByTxId {
132
179
  name: string;
133
180
  fields: Fields;
134
181
  }
182
+ export declare type DebugMessage = node.DebugMessage;
135
183
  export interface TestContractResult {
136
- address: string;
137
184
  contractId: string;
185
+ contractAddress: string;
138
186
  returns: Val[];
139
187
  gasUsed: number;
140
188
  contracts: ContractState[];
141
189
  txOutputs: Output[];
142
190
  events: ContractEventByTxId[];
191
+ debugMessages: DebugMessage[];
143
192
  }
144
193
  export declare type Output = AssetOutput | ContractOutput;
145
194
  export interface AssetOutput extends Asset {
@@ -152,7 +201,7 @@ export interface ContractOutput {
152
201
  type: string;
153
202
  address: string;
154
203
  alphAmount: Number256;
155
- tokens: Token[];
204
+ tokens?: Token[];
156
205
  }
157
206
  export interface DeployContractTransaction {
158
207
  fromGroup: number;
@@ -165,12 +214,11 @@ export interface DeployContractTransaction {
165
214
  export interface BuildDeployContractTx {
166
215
  signerAddress: string;
167
216
  initialFields?: Fields;
168
- initialAttoAlphAmount?: string;
217
+ initialAttoAlphAmount?: Number256;
169
218
  initialTokenAmounts?: Token[];
170
219
  issueTokenAmount?: Number256;
171
220
  gasAmount?: number;
172
221
  gasPrice?: Number256;
173
- submitTx?: boolean;
174
222
  }
175
223
  export interface BuildExecuteScriptTx {
176
224
  signerAddress: string;
@@ -179,7 +227,6 @@ export interface BuildExecuteScriptTx {
179
227
  tokens?: Token[];
180
228
  gasAmount?: number;
181
229
  gasPrice?: Number256;
182
- submitTx?: boolean;
183
230
  }
184
231
  export interface BuildScriptTxResult {
185
232
  fromGroup: number;