@alephium/web3 0.2.0-test.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -2
- package/README.md +2 -135
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +116 -18
- package/dist/src/api/api-alephium.js +146 -81
- package/dist/src/api/api-explorer.d.ts +178 -51
- package/dist/src/api/api-explorer.js +172 -37
- package/dist/src/api/index.d.ts +40 -5
- package/dist/src/api/index.js +115 -7
- package/dist/src/api/types.d.ts +23 -0
- package/dist/src/api/types.js +235 -0
- package/dist/src/api/utils.d.ts +6 -0
- package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
- package/dist/src/contract/contract.d.ts +69 -55
- package/dist/src/contract/contract.js +241 -387
- package/dist/src/contract/events.d.ts +4 -4
- package/dist/src/contract/events.js +2 -1
- package/dist/src/contract/index.js +5 -1
- package/dist/src/contract/ralph.d.ts +5 -4
- package/dist/src/contract/ralph.js +27 -1
- package/dist/src/global.d.ts +6 -2
- package/dist/src/global.js +19 -3
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +23 -2
- package/dist/src/signer/index.d.ts +0 -1
- package/dist/src/signer/index.js +5 -2
- package/dist/src/signer/signer.d.ts +59 -60
- package/dist/src/signer/signer.js +99 -70
- package/dist/src/transaction/index.d.ts +0 -1
- package/dist/src/transaction/index.js +5 -2
- package/dist/src/transaction/status.d.ts +2 -1
- package/dist/src/transaction/status.js +2 -1
- package/dist/src/utils/bs58.d.ts +1 -0
- package/dist/src/utils/bs58.js +13 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +5 -2
- package/dist/src/utils/subscription.d.ts +0 -2
- package/dist/src/utils/subscription.js +0 -2
- package/dist/src/utils/utils.d.ts +4 -9
- package/dist/src/utils/utils.js +20 -24
- package/jest-config.json +11 -0
- package/package.json +11 -45
- package/src/api/api-alephium.ts +163 -26
- package/src/api/api-explorer.ts +247 -54
- package/src/api/index.ts +140 -6
- package/src/api/types.ts +229 -0
- package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
- package/src/contract/contract.ts +405 -432
- package/src/contract/events.ts +6 -5
- package/src/contract/ralph.ts +29 -4
- package/src/global.ts +23 -3
- package/src/index.ts +7 -1
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +165 -135
- package/src/transaction/index.ts +0 -1
- package/src/transaction/status.ts +5 -2
- package/src/utils/bs58.ts +11 -0
- package/src/utils/index.ts +0 -1
- package/src/utils/subscription.ts +0 -4
- package/src/utils/utils.ts +11 -19
- package/webpack.config.js +3 -0
- package/.eslintrc.json +0 -21
- package/LICENSE +0 -165
- package/contracts/add/add.ral +0 -13
- package/contracts/greeter/greeter.ral +0 -7
- package/contracts/greeter/greeter_interface.ral +0 -4
- package/contracts/greeter_main.ral +0 -7
- package/contracts/main.ral +0 -4
- package/contracts/sub/sub.ral +0 -10
- package/contracts/test/metadata.ral +0 -18
- package/contracts/test/warnings.ral +0 -8
- package/dev/user.conf +0 -29
- package/dist/scripts/create-project.d.ts +0 -2
- package/dist/scripts/create-project.js +0 -125
- package/dist/scripts/rename-gitignore.d.ts +0 -1
- package/dist/scripts/start-devnet.d.ts +0 -1
- package/dist/scripts/start-devnet.js +0 -131
- package/dist/scripts/stop-devnet.d.ts +0 -1
- package/dist/scripts/stop-devnet.js +0 -32
- package/dist/src/signer/node-wallet.d.ts +0 -11
- package/dist/src/signer/node-wallet.js +0 -57
- package/dist/src/test/index.d.ts +0 -6
- package/dist/src/test/index.js +0 -41
- package/dist/src/test/privatekey-wallet.d.ts +0 -11
- package/dist/src/test/privatekey-wallet.js +0 -68
- package/dist/src/transaction/sign-verify.d.ts +0 -2
- package/dist/src/transaction/sign-verify.js +0 -58
- package/dist/src/utils/password-crypto.d.ts +0 -2
- package/dist/src/utils/password-crypto.js +0 -69
- package/gitignore +0 -9
- package/scripts/create-project.ts +0 -137
- package/scripts/start-devnet.js +0 -141
- package/scripts/stop-devnet.js +0 -32
- package/src/contract/ralph.test.ts +0 -178
- package/src/fixtures/address.json +0 -36
- package/src/fixtures/balance.json +0 -9
- package/src/fixtures/self-clique.json +0 -19
- package/src/fixtures/transaction.json +0 -13
- package/src/fixtures/transactions.json +0 -179
- package/src/signer/fixtures/genesis.json +0 -26
- package/src/signer/fixtures/wallets.json +0 -26
- package/src/signer/node-wallet.ts +0 -65
- package/src/test/index.ts +0 -31
- package/src/test/privatekey-wallet.ts +0 -57
- package/src/transaction/sign-verify.test.ts +0 -50
- package/src/transaction/sign-verify.ts +0 -39
- package/src/utils/address.test.ts +0 -47
- package/src/utils/djb2.test.ts +0 -35
- package/src/utils/password-crypto.test.ts +0 -27
- package/src/utils/password-crypto.ts +0 -77
- package/src/utils/utils.test.ts +0 -161
- package/templates/base/README.md +0 -34
- package/templates/base/package.json +0 -35
- package/templates/base/src/greeter.ts +0 -42
- package/templates/base/tsconfig.json +0 -19
- package/templates/react/README.md +0 -34
- package/templates/react/config-overrides.js +0 -18
- package/templates/react/package.json +0 -66
- package/templates/react/src/App.tsx +0 -42
- package/templates/react/src/artifacts/greeter.ral.json +0 -26
- package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
- package/templates/shared/.eslintrc.json +0 -12
- package/templates/shared/scripts/header.js +0 -0
- package/test/contract.test.ts +0 -213
- package/test/events.test.ts +0 -141
- 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
|
+
}
|
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,
|
|
2
|
-
import { SignDeployContractTxParams, SignExecuteScriptTxParams,
|
|
3
|
-
|
|
4
|
-
declare type
|
|
5
|
-
declare type
|
|
6
|
-
declare type
|
|
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(
|
|
32
|
-
constructor(type: SourceType,
|
|
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
|
-
|
|
45
|
-
readonly
|
|
46
|
-
readonly
|
|
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
|
-
|
|
56
|
-
static contract(
|
|
57
|
-
static 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
|
|
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
|
|
86
|
+
readonly version: string;
|
|
87
|
+
readonly name: string;
|
|
69
88
|
readonly functions: FunctionSig[];
|
|
70
|
-
constructor(
|
|
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,56 @@ 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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
static
|
|
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):
|
|
120
|
+
fromApiContractState(state: node.ContractState): ContractState;
|
|
121
|
+
static fromApiContractState(state: node.ContractState): ContractState;
|
|
98
122
|
static ContractCreatedEvent: EventSig;
|
|
99
123
|
static ContractDestroyedEvent: EventSig;
|
|
100
|
-
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined):
|
|
101
|
-
fromTestContractResult(methodIndex: number, result: node.TestContractResult):
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): ContractEventByTxId;
|
|
125
|
+
fromTestContractResult(methodIndex: number, result: node.TestContractResult): TestContractResult;
|
|
126
|
+
txParamsForDeployment(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<SignDeployContractTxParams>;
|
|
127
|
+
deploy(signer: SignerProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<SignDeployContractTxResult>;
|
|
104
128
|
buildByteCodeToDeploy(initialFields: Fields): string;
|
|
105
129
|
}
|
|
106
130
|
export declare class Script extends Artifact {
|
|
107
131
|
readonly bytecodeTemplate: string;
|
|
132
|
+
readonly bytecodeDebugPatch: string;
|
|
108
133
|
readonly fieldsSig: FieldsSig;
|
|
109
|
-
constructor(
|
|
110
|
-
static fromCompileResult(
|
|
111
|
-
static fromJson(artifact: any): Script;
|
|
112
|
-
static fromArtifactFile(path: string): Promise<Script>;
|
|
134
|
+
constructor(version: string, name: string, bytecodeTemplate: string, bytecodeDebugPatch: string, fieldsSig: FieldsSig, functions: FunctionSig[]);
|
|
135
|
+
static fromCompileResult(result: node.CompileScriptResult): Script;
|
|
136
|
+
static fromJson(artifact: any, bytecodeDebugPatch?: string): Script;
|
|
137
|
+
static fromArtifactFile(path: string, bytecodeDebugPatch: string): Promise<Script>;
|
|
113
138
|
toString(): string;
|
|
114
|
-
|
|
115
|
-
|
|
139
|
+
txParamsForExecution(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<SignExecuteScriptTxParams>;
|
|
140
|
+
execute(signer: SignerProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<SignExecuteScriptTxResult>;
|
|
116
141
|
buildByteCodeToDeploy(initialFields: Fields): string;
|
|
117
142
|
}
|
|
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
143
|
export interface Asset {
|
|
126
144
|
alphAmount: Number256;
|
|
127
145
|
tokens?: Token[];
|
|
128
146
|
}
|
|
129
|
-
export interface Token {
|
|
130
|
-
id: string;
|
|
131
|
-
amount: Number256;
|
|
132
|
-
}
|
|
133
147
|
export interface InputAsset {
|
|
134
148
|
address: string;
|
|
135
149
|
asset: Asset;
|
|
@@ -166,14 +180,16 @@ export interface ContractEventByTxId {
|
|
|
166
180
|
name: string;
|
|
167
181
|
fields: Fields;
|
|
168
182
|
}
|
|
183
|
+
export declare type DebugMessage = node.DebugMessage;
|
|
169
184
|
export interface TestContractResult {
|
|
170
|
-
address: string;
|
|
171
185
|
contractId: string;
|
|
186
|
+
contractAddress: string;
|
|
172
187
|
returns: Val[];
|
|
173
188
|
gasUsed: number;
|
|
174
189
|
contracts: ContractState[];
|
|
175
190
|
txOutputs: Output[];
|
|
176
191
|
events: ContractEventByTxId[];
|
|
192
|
+
debugMessages: DebugMessage[];
|
|
177
193
|
}
|
|
178
194
|
export declare type Output = AssetOutput | ContractOutput;
|
|
179
195
|
export interface AssetOutput extends Asset {
|
|
@@ -186,7 +202,7 @@ export interface ContractOutput {
|
|
|
186
202
|
type: string;
|
|
187
203
|
address: string;
|
|
188
204
|
alphAmount: Number256;
|
|
189
|
-
tokens
|
|
205
|
+
tokens?: Token[];
|
|
190
206
|
}
|
|
191
207
|
export interface DeployContractTransaction {
|
|
192
208
|
fromGroup: number;
|
|
@@ -199,12 +215,11 @@ export interface DeployContractTransaction {
|
|
|
199
215
|
export interface BuildDeployContractTx {
|
|
200
216
|
signerAddress: string;
|
|
201
217
|
initialFields?: Fields;
|
|
202
|
-
initialAttoAlphAmount?:
|
|
218
|
+
initialAttoAlphAmount?: Number256;
|
|
203
219
|
initialTokenAmounts?: Token[];
|
|
204
220
|
issueTokenAmount?: Number256;
|
|
205
221
|
gasAmount?: number;
|
|
206
222
|
gasPrice?: Number256;
|
|
207
|
-
submitTx?: boolean;
|
|
208
223
|
}
|
|
209
224
|
export interface BuildExecuteScriptTx {
|
|
210
225
|
signerAddress: string;
|
|
@@ -213,7 +228,6 @@ export interface BuildExecuteScriptTx {
|
|
|
213
228
|
tokens?: Token[];
|
|
214
229
|
gasAmount?: number;
|
|
215
230
|
gasPrice?: Number256;
|
|
216
|
-
submitTx?: boolean;
|
|
217
231
|
}
|
|
218
232
|
export interface BuildScriptTxResult {
|
|
219
233
|
fromGroup: number;
|