@alephium/web3 0.0.3 → 0.1.0-rc.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.
- package/.editorconfig +13 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +21 -0
- package/README.md +2 -2
- package/contracts/add.ral +7 -3
- package/contracts/greeter.ral +3 -1
- package/contracts/greeter_interface.ral +3 -0
- package/contracts/greeter_main.ral +9 -0
- package/contracts/main.ral +3 -5
- package/dev/user.conf +8 -4
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/scripts/check-versions.d.ts +1 -0
- package/dist/scripts/check-versions.js +39 -0
- package/dist/{cli → scripts}/create-project.d.ts +0 -0
- package/dist/scripts/create-project.js +124 -0
- package/dist/scripts/header.d.ts +0 -0
- package/dist/scripts/header.js +18 -0
- package/dist/scripts/rename-gitignore.d.ts +1 -0
- package/dist/scripts/rename-gitignore.js +24 -0
- package/dist/scripts/start-devnet.d.ts +1 -0
- package/dist/scripts/start-devnet.js +131 -0
- package/dist/scripts/stop-devnet.d.ts +1 -0
- package/dist/scripts/stop-devnet.js +32 -0
- package/dist/{api → src/api}/api-alephium.d.ts +287 -168
- package/dist/{api → src/api}/api-alephium.js +497 -115
- package/dist/{api → src/api}/api-explorer.d.ts +117 -19
- package/dist/{api → src/api}/api-explorer.js +206 -46
- package/dist/src/api/index.d.ts +10 -0
- package/dist/src/api/index.js +55 -0
- package/dist/{lib → src}/constants.d.ts +0 -0
- package/dist/{lib → src}/constants.js +0 -0
- package/dist/src/contract/contract.d.ts +182 -0
- package/dist/src/contract/contract.js +760 -0
- package/dist/src/contract/events.d.ts +29 -0
- package/dist/src/contract/events.js +77 -0
- package/dist/src/contract/index.d.ts +3 -0
- package/dist/src/contract/index.js +32 -0
- package/dist/src/contract/ralph.d.ts +12 -0
- package/dist/src/contract/ralph.js +362 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +34 -0
- package/dist/src/signer/index.d.ts +2 -0
- package/dist/src/signer/index.js +31 -0
- package/dist/src/signer/node-wallet.d.ts +13 -0
- package/dist/src/signer/node-wallet.js +60 -0
- package/dist/src/signer/signer.d.ts +143 -0
- package/dist/src/signer/signer.js +184 -0
- package/dist/src/test/index.d.ts +7 -0
- package/dist/src/test/index.js +41 -0
- package/dist/src/test/privatekey-wallet.d.ts +12 -0
- package/dist/src/test/privatekey-wallet.js +68 -0
- package/dist/{lib → src/utils}/address.d.ts +0 -0
- package/dist/{lib → src/utils}/address.js +1 -1
- package/dist/{lib → src/utils}/bs58.d.ts +2 -2
- package/dist/{lib → src/utils}/bs58.js +3 -1
- package/dist/{lib → src/utils}/djb2.d.ts +0 -0
- package/dist/{lib → src/utils}/djb2.js +1 -1
- package/dist/src/utils/index.d.ts +6 -0
- package/dist/src/utils/index.js +35 -0
- package/dist/{lib → src/utils}/password-crypto.d.ts +0 -0
- package/dist/{lib → src/utils}/password-crypto.js +8 -7
- package/dist/src/utils/transaction.d.ts +2 -0
- package/dist/src/utils/transaction.js +58 -0
- package/dist/src/utils/utils.d.ts +30 -0
- package/dist/{lib → src/utils}/utils.js +83 -19
- package/gitignore +5 -4
- package/package.json +56 -40
- package/scripts/create-project.ts +136 -0
- package/scripts/header.js +17 -0
- package/scripts/start-devnet.js +3 -3
- package/src/api/api-alephium.ts +2323 -0
- package/src/api/api-explorer.ts +808 -0
- package/src/api/index.ts +35 -0
- package/src/constants.ts +20 -0
- package/src/contract/contract.ts +1014 -0
- package/src/contract/events.ts +102 -0
- package/src/contract/index.ts +21 -0
- package/src/contract/ralph.test.ts +178 -0
- package/src/contract/ralph.ts +362 -0
- package/src/fixtures/address.json +36 -0
- package/src/fixtures/balance.json +9 -0
- package/src/fixtures/self-clique.json +19 -0
- package/src/fixtures/transaction.json +13 -0
- package/src/fixtures/transactions.json +179 -0
- package/src/index.ts +24 -0
- package/src/signer/fixtures/genesis.json +26 -0
- package/src/signer/fixtures/wallets.json +26 -0
- package/src/signer/index.ts +20 -0
- package/src/signer/node-wallet.ts +74 -0
- package/src/signer/signer.ts +313 -0
- package/src/test/index.ts +32 -0
- package/src/test/privatekey-wallet.ts +58 -0
- package/src/utils/address.test.ts +47 -0
- package/src/utils/address.ts +39 -0
- package/src/utils/bs58.ts +26 -0
- package/src/utils/djb2.test.ts +35 -0
- package/src/utils/djb2.ts +25 -0
- package/src/utils/index.ts +24 -0
- package/src/utils/password-crypto.test.ts +27 -0
- package/src/utils/password-crypto.ts +77 -0
- package/src/utils/transaction.test.ts +50 -0
- package/src/utils/transaction.ts +39 -0
- package/src/utils/utils.test.ts +160 -0
- package/src/utils/utils.ts +209 -0
- package/templates/{README.md → base/README.md} +4 -4
- package/templates/base/package.json +35 -0
- package/templates/base/src/greeter.ts +41 -0
- package/templates/base/tsconfig.json +19 -0
- package/templates/react/README.md +34 -0
- package/templates/react/config-overrides.js +18 -0
- package/templates/react/package.json +66 -0
- package/templates/react/src/App.tsx +42 -0
- package/templates/react/src/artifacts/greeter.ral.json +26 -0
- package/templates/react/src/artifacts/greeter_main.ral.json +22 -0
- package/templates/shared/.eslintrc.json +12 -0
- package/templates/shared/scripts/header.js +0 -0
- package/test/contract.test.ts +161 -0
- package/test/events.test.ts +139 -0
- package/webpack.config.js +1 -1
- package/contracts/greeter-main.ral +0 -8
- package/dist/cli/create-project.js +0 -87
- package/dist/lib/clique.d.ts +0 -23
- package/dist/lib/clique.js +0 -149
- package/dist/lib/contract.d.ts +0 -152
- package/dist/lib/contract.js +0 -711
- package/dist/lib/explorer.d.ts +0 -8
- package/dist/lib/explorer.js +0 -46
- package/dist/lib/index.d.ts +0 -12
- package/dist/lib/index.js +0 -60
- package/dist/lib/node.d.ts +0 -10
- package/dist/lib/node.js +0 -64
- package/dist/lib/numbers.d.ts +0 -7
- package/dist/lib/numbers.js +0 -128
- package/dist/lib/signer.d.ts +0 -17
- package/dist/lib/signer.js +0 -70
- package/dist/lib/storage-browser.d.ts +0 -9
- package/dist/lib/storage-browser.js +0 -52
- package/dist/lib/storage-node.d.ts +0 -9
- package/dist/lib/storage-node.js +0 -65
- package/dist/lib/utils.d.ts +0 -11
- package/dist/lib/wallet.d.ts +0 -30
- package/dist/lib/wallet.js +0 -142
- package/templates/package.json +0 -29
|
@@ -9,29 +9,17 @@
|
|
|
9
9
|
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
|
10
10
|
* ---------------------------------------------------------------
|
|
11
11
|
*/
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
|
-
var t = {};
|
|
23
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
-
t[p] = s[p];
|
|
25
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
-
t[p[i]] = s[p[i]];
|
|
29
|
-
}
|
|
30
|
-
return t;
|
|
31
|
-
};
|
|
32
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
13
|
exports.Api = exports.HttpClient = exports.ContentType = void 0;
|
|
34
14
|
require("cross-fetch/polyfill");
|
|
15
|
+
function convertHttpResponse(response) {
|
|
16
|
+
if (response.error) {
|
|
17
|
+
throw new Error(response.error.detail);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return response.data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
35
23
|
var ContentType;
|
|
36
24
|
(function (ContentType) {
|
|
37
25
|
ContentType["Json"] = "application/json";
|
|
@@ -85,23 +73,30 @@ class HttpClient {
|
|
|
85
73
|
this.abortControllers.delete(cancelToken);
|
|
86
74
|
}
|
|
87
75
|
};
|
|
88
|
-
this.request = (
|
|
89
|
-
var { body, secure, path, type, query, format, baseUrl, cancelToken } = _a, params = __rest(_a, ["body", "secure", "path", "type", "query", "format", "baseUrl", "cancelToken"]);
|
|
76
|
+
this.request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => {
|
|
90
77
|
const secureParams = ((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) &&
|
|
91
78
|
this.securityWorker &&
|
|
92
|
-
(
|
|
79
|
+
(await this.securityWorker(this.securityData))) ||
|
|
93
80
|
{};
|
|
94
81
|
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
95
82
|
const queryString = query && this.toQueryString(query);
|
|
96
83
|
const payloadFormatter = this.contentFormatters[type || ContentType.Json];
|
|
97
84
|
const responseFormat = format || requestParams.format;
|
|
98
|
-
return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`,
|
|
85
|
+
return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, {
|
|
86
|
+
...requestParams,
|
|
87
|
+
headers: {
|
|
88
|
+
...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
|
|
89
|
+
...(requestParams.headers || {})
|
|
90
|
+
},
|
|
91
|
+
signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
|
|
92
|
+
body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
|
|
93
|
+
}).then(async (response) => {
|
|
99
94
|
const r = response;
|
|
100
95
|
r.data = null;
|
|
101
96
|
r.error = null;
|
|
102
97
|
const data = !responseFormat
|
|
103
98
|
? r
|
|
104
|
-
:
|
|
99
|
+
: await response[responseFormat]()
|
|
105
100
|
.then((data) => {
|
|
106
101
|
if (r.ok) {
|
|
107
102
|
r.data = data;
|
|
@@ -121,8 +116,8 @@ class HttpClient {
|
|
|
121
116
|
if (!response.ok)
|
|
122
117
|
throw data;
|
|
123
118
|
return data;
|
|
124
|
-
})
|
|
125
|
-
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
126
121
|
Object.assign(this, apiConfig);
|
|
127
122
|
}
|
|
128
123
|
encodeQueryParam(key, value) {
|
|
@@ -148,7 +143,16 @@ class HttpClient {
|
|
|
148
143
|
return queryString ? `?${queryString}` : '';
|
|
149
144
|
}
|
|
150
145
|
mergeRequestParams(params1, params2) {
|
|
151
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
...this.baseApiParams,
|
|
148
|
+
...params1,
|
|
149
|
+
...(params2 || {}),
|
|
150
|
+
headers: {
|
|
151
|
+
...(this.baseApiParams.headers || {}),
|
|
152
|
+
...(params1.headers || {}),
|
|
153
|
+
...((params2 && params2.headers) || {})
|
|
154
|
+
}
|
|
155
|
+
};
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
exports.HttpClient = HttpClient;
|
|
@@ -167,7 +171,13 @@ class Api extends HttpClient {
|
|
|
167
171
|
* @name GetBlocks
|
|
168
172
|
* @request GET:/blocks
|
|
169
173
|
*/
|
|
170
|
-
getBlocks: (query, params = {}) => this.request(
|
|
174
|
+
getBlocks: (query, params = {}) => this.request({
|
|
175
|
+
path: `/blocks`,
|
|
176
|
+
method: 'GET',
|
|
177
|
+
query: query,
|
|
178
|
+
format: 'json',
|
|
179
|
+
...params
|
|
180
|
+
}).then(convertHttpResponse),
|
|
171
181
|
/**
|
|
172
182
|
* @description Get a block with hash
|
|
173
183
|
*
|
|
@@ -175,7 +185,12 @@ class Api extends HttpClient {
|
|
|
175
185
|
* @name GetBlocksBlockHash
|
|
176
186
|
* @request GET:/blocks/{block-hash}
|
|
177
187
|
*/
|
|
178
|
-
getBlocksBlockHash: (blockHash, params = {}) => this.request(
|
|
188
|
+
getBlocksBlockHash: (blockHash, params = {}) => this.request({
|
|
189
|
+
path: `/blocks/${blockHash}`,
|
|
190
|
+
method: 'GET',
|
|
191
|
+
format: 'json',
|
|
192
|
+
...params
|
|
193
|
+
}).then(convertHttpResponse),
|
|
179
194
|
/**
|
|
180
195
|
* @description Get block's transactions
|
|
181
196
|
*
|
|
@@ -183,7 +198,13 @@ class Api extends HttpClient {
|
|
|
183
198
|
* @name GetBlocksBlockHashTransactions
|
|
184
199
|
* @request GET:/blocks/{block-hash}/transactions
|
|
185
200
|
*/
|
|
186
|
-
getBlocksBlockHashTransactions: (blockHash, query, params = {}) => this.request(
|
|
201
|
+
getBlocksBlockHashTransactions: (blockHash, query, params = {}) => this.request({
|
|
202
|
+
path: `/blocks/${blockHash}/transactions`,
|
|
203
|
+
method: 'GET',
|
|
204
|
+
query: query,
|
|
205
|
+
format: 'json',
|
|
206
|
+
...params
|
|
207
|
+
}).then(convertHttpResponse)
|
|
187
208
|
};
|
|
188
209
|
this.transactions = {
|
|
189
210
|
/**
|
|
@@ -193,25 +214,67 @@ class Api extends HttpClient {
|
|
|
193
214
|
* @name GetTransactionsTransactionHash
|
|
194
215
|
* @request GET:/transactions/{transaction-hash}
|
|
195
216
|
*/
|
|
196
|
-
getTransactionsTransactionHash: (transactionHash, params = {}) => this.request(
|
|
217
|
+
getTransactionsTransactionHash: (transactionHash, params = {}) => this.request({
|
|
218
|
+
path: `/transactions/${transactionHash}`,
|
|
219
|
+
method: 'GET',
|
|
220
|
+
format: 'json',
|
|
221
|
+
...params
|
|
222
|
+
}).then(convertHttpResponse)
|
|
197
223
|
};
|
|
198
224
|
this.addresses = {
|
|
199
225
|
/**
|
|
200
226
|
* @description Get address information
|
|
201
227
|
*
|
|
202
|
-
* @tags
|
|
228
|
+
* @tags Addresses
|
|
203
229
|
* @name GetAddressesAddress
|
|
204
230
|
* @request GET:/addresses/{address}
|
|
205
231
|
*/
|
|
206
|
-
getAddressesAddress: (address, params = {}) => this.request(
|
|
232
|
+
getAddressesAddress: (address, params = {}) => this.request({
|
|
233
|
+
path: `/addresses/${address}`,
|
|
234
|
+
method: 'GET',
|
|
235
|
+
format: 'json',
|
|
236
|
+
...params
|
|
237
|
+
}).then(convertHttpResponse),
|
|
207
238
|
/**
|
|
208
239
|
* @description List transactions of a given address
|
|
209
240
|
*
|
|
210
|
-
* @tags
|
|
241
|
+
* @tags Addresses
|
|
211
242
|
* @name GetAddressesAddressTransactions
|
|
212
243
|
* @request GET:/addresses/{address}/transactions
|
|
213
244
|
*/
|
|
214
|
-
getAddressesAddressTransactions: (address, query, params = {}) => this.request(
|
|
245
|
+
getAddressesAddressTransactions: (address, query, params = {}) => this.request({
|
|
246
|
+
path: `/addresses/${address}/transactions`,
|
|
247
|
+
method: 'GET',
|
|
248
|
+
query: query,
|
|
249
|
+
format: 'json',
|
|
250
|
+
...params
|
|
251
|
+
}).then(convertHttpResponse),
|
|
252
|
+
/**
|
|
253
|
+
* @description Get total transactions of a given address
|
|
254
|
+
*
|
|
255
|
+
* @tags Addresses
|
|
256
|
+
* @name GetAddressesAddressTotalTransactions
|
|
257
|
+
* @request GET:/addresses/{address}/total-transactions
|
|
258
|
+
*/
|
|
259
|
+
getAddressesAddressTotalTransactions: (address, params = {}) => this.request({
|
|
260
|
+
path: `/addresses/${address}/total-transactions`,
|
|
261
|
+
method: 'GET',
|
|
262
|
+
format: 'json',
|
|
263
|
+
...params
|
|
264
|
+
}).then(convertHttpResponse),
|
|
265
|
+
/**
|
|
266
|
+
* @description Get address balance
|
|
267
|
+
*
|
|
268
|
+
* @tags Addresses
|
|
269
|
+
* @name GetAddressesAddressBalance
|
|
270
|
+
* @request GET:/addresses/{address}/balance
|
|
271
|
+
*/
|
|
272
|
+
getAddressesAddressBalance: (address, params = {}) => this.request({
|
|
273
|
+
path: `/addresses/${address}/balance`,
|
|
274
|
+
method: 'GET',
|
|
275
|
+
format: 'json',
|
|
276
|
+
...params
|
|
277
|
+
}).then(convertHttpResponse)
|
|
215
278
|
};
|
|
216
279
|
this.infos = {
|
|
217
280
|
/**
|
|
@@ -221,7 +284,12 @@ class Api extends HttpClient {
|
|
|
221
284
|
* @name GetInfos
|
|
222
285
|
* @request GET:/infos
|
|
223
286
|
*/
|
|
224
|
-
getInfos: (params = {}) => this.request(
|
|
287
|
+
getInfos: (params = {}) => this.request({
|
|
288
|
+
path: `/infos`,
|
|
289
|
+
method: 'GET',
|
|
290
|
+
format: 'json',
|
|
291
|
+
...params
|
|
292
|
+
}).then(convertHttpResponse),
|
|
225
293
|
/**
|
|
226
294
|
* @description List latest height for each chain
|
|
227
295
|
*
|
|
@@ -229,7 +297,12 @@ class Api extends HttpClient {
|
|
|
229
297
|
* @name GetInfosHeights
|
|
230
298
|
* @request GET:/infos/heights
|
|
231
299
|
*/
|
|
232
|
-
getInfosHeights: (params = {}) => this.request(
|
|
300
|
+
getInfosHeights: (params = {}) => this.request({
|
|
301
|
+
path: `/infos/heights`,
|
|
302
|
+
method: 'GET',
|
|
303
|
+
format: 'json',
|
|
304
|
+
...params
|
|
305
|
+
}).then(convertHttpResponse),
|
|
233
306
|
/**
|
|
234
307
|
* @description Get token supply list
|
|
235
308
|
*
|
|
@@ -237,7 +310,13 @@ class Api extends HttpClient {
|
|
|
237
310
|
* @name GetInfosSupply
|
|
238
311
|
* @request GET:/infos/supply
|
|
239
312
|
*/
|
|
240
|
-
getInfosSupply: (query, params = {}) => this.request(
|
|
313
|
+
getInfosSupply: (query, params = {}) => this.request({
|
|
314
|
+
path: `/infos/supply`,
|
|
315
|
+
method: 'GET',
|
|
316
|
+
query: query,
|
|
317
|
+
format: 'json',
|
|
318
|
+
...params
|
|
319
|
+
}).then(convertHttpResponse),
|
|
241
320
|
/**
|
|
242
321
|
* @description Get the ALPH total supply
|
|
243
322
|
*
|
|
@@ -245,7 +324,11 @@ class Api extends HttpClient {
|
|
|
245
324
|
* @name GetInfosSupplyTotalAlph
|
|
246
325
|
* @request GET:/infos/supply/total-alph
|
|
247
326
|
*/
|
|
248
|
-
getInfosSupplyTotalAlph: (params = {}) => this.request(
|
|
327
|
+
getInfosSupplyTotalAlph: (params = {}) => this.request({
|
|
328
|
+
path: `/infos/supply/total-alph`,
|
|
329
|
+
method: 'GET',
|
|
330
|
+
...params
|
|
331
|
+
}).then(convertHttpResponse),
|
|
249
332
|
/**
|
|
250
333
|
* @description Get the ALPH circulating supply
|
|
251
334
|
*
|
|
@@ -253,7 +336,35 @@ class Api extends HttpClient {
|
|
|
253
336
|
* @name GetInfosSupplyCirculatingAlph
|
|
254
337
|
* @request GET:/infos/supply/circulating-alph
|
|
255
338
|
*/
|
|
256
|
-
getInfosSupplyCirculatingAlph: (params = {}) => this.request(
|
|
339
|
+
getInfosSupplyCirculatingAlph: (params = {}) => this.request({
|
|
340
|
+
path: `/infos/supply/circulating-alph`,
|
|
341
|
+
method: 'GET',
|
|
342
|
+
...params
|
|
343
|
+
}).then(convertHttpResponse),
|
|
344
|
+
/**
|
|
345
|
+
* @description Get the ALPH reserved supply
|
|
346
|
+
*
|
|
347
|
+
* @tags Infos
|
|
348
|
+
* @name GetInfosSupplyReservedAlph
|
|
349
|
+
* @request GET:/infos/supply/reserved-alph
|
|
350
|
+
*/
|
|
351
|
+
getInfosSupplyReservedAlph: (params = {}) => this.request({
|
|
352
|
+
path: `/infos/supply/reserved-alph`,
|
|
353
|
+
method: 'GET',
|
|
354
|
+
...params
|
|
355
|
+
}).then(convertHttpResponse),
|
|
356
|
+
/**
|
|
357
|
+
* @description Get the ALPH locked supply
|
|
358
|
+
*
|
|
359
|
+
* @tags Infos
|
|
360
|
+
* @name GetInfosSupplyLockedAlph
|
|
361
|
+
* @request GET:/infos/supply/locked-alph
|
|
362
|
+
*/
|
|
363
|
+
getInfosSupplyLockedAlph: (params = {}) => this.request({
|
|
364
|
+
path: `/infos/supply/locked-alph`,
|
|
365
|
+
method: 'GET',
|
|
366
|
+
...params
|
|
367
|
+
}).then(convertHttpResponse),
|
|
257
368
|
/**
|
|
258
369
|
* @description Get the total number of transactions
|
|
259
370
|
*
|
|
@@ -261,7 +372,11 @@ class Api extends HttpClient {
|
|
|
261
372
|
* @name GetInfosTotalTransactions
|
|
262
373
|
* @request GET:/infos/total-transactions
|
|
263
374
|
*/
|
|
264
|
-
getInfosTotalTransactions: (params = {}) => this.request(
|
|
375
|
+
getInfosTotalTransactions: (params = {}) => this.request({
|
|
376
|
+
path: `/infos/total-transactions`,
|
|
377
|
+
method: 'GET',
|
|
378
|
+
...params
|
|
379
|
+
}).then(convertHttpResponse),
|
|
265
380
|
/**
|
|
266
381
|
* @description Get the average block time for each chain
|
|
267
382
|
*
|
|
@@ -269,7 +384,12 @@ class Api extends HttpClient {
|
|
|
269
384
|
* @name GetInfosAverageBlockTimes
|
|
270
385
|
* @request GET:/infos/average-block-times
|
|
271
386
|
*/
|
|
272
|
-
getInfosAverageBlockTimes: (params = {}) => this.request(
|
|
387
|
+
getInfosAverageBlockTimes: (params = {}) => this.request({
|
|
388
|
+
path: `/infos/average-block-times`,
|
|
389
|
+
method: 'GET',
|
|
390
|
+
format: 'json',
|
|
391
|
+
...params
|
|
392
|
+
}).then(convertHttpResponse)
|
|
273
393
|
};
|
|
274
394
|
this.charts = {
|
|
275
395
|
/**
|
|
@@ -277,10 +397,46 @@ class Api extends HttpClient {
|
|
|
277
397
|
*
|
|
278
398
|
* @tags Charts
|
|
279
399
|
* @name GetChartsHashrates
|
|
280
|
-
* @summary Get
|
|
400
|
+
* @summary Get hashrate chart in H/s
|
|
281
401
|
* @request GET:/charts/hashrates
|
|
282
402
|
*/
|
|
283
|
-
getChartsHashrates: (query, params = {}) => this.request(
|
|
403
|
+
getChartsHashrates: (query, params = {}) => this.request({
|
|
404
|
+
path: `/charts/hashrates`,
|
|
405
|
+
method: 'GET',
|
|
406
|
+
query: query,
|
|
407
|
+
format: 'json',
|
|
408
|
+
...params
|
|
409
|
+
}).then(convertHttpResponse),
|
|
410
|
+
/**
|
|
411
|
+
* @description `interval-type` query param: hourly, daily
|
|
412
|
+
*
|
|
413
|
+
* @tags Charts
|
|
414
|
+
* @name GetChartsTransactionsCount
|
|
415
|
+
* @summary Get transaction count history
|
|
416
|
+
* @request GET:/charts/transactions-count
|
|
417
|
+
*/
|
|
418
|
+
getChartsTransactionsCount: (query, params = {}) => this.request({
|
|
419
|
+
path: `/charts/transactions-count`,
|
|
420
|
+
method: 'GET',
|
|
421
|
+
query: query,
|
|
422
|
+
format: 'json',
|
|
423
|
+
...params
|
|
424
|
+
}).then(convertHttpResponse),
|
|
425
|
+
/**
|
|
426
|
+
* @description `interval-type` query param: hourly, daily
|
|
427
|
+
*
|
|
428
|
+
* @tags Charts
|
|
429
|
+
* @name GetChartsTransactionsCountPerChain
|
|
430
|
+
* @summary Get transaction count history per chain
|
|
431
|
+
* @request GET:/charts/transactions-count-per-chain
|
|
432
|
+
*/
|
|
433
|
+
getChartsTransactionsCountPerChain: (query, params = {}) => this.request({
|
|
434
|
+
path: `/charts/transactions-count-per-chain`,
|
|
435
|
+
method: 'GET',
|
|
436
|
+
query: query,
|
|
437
|
+
format: 'json',
|
|
438
|
+
...params
|
|
439
|
+
}).then(convertHttpResponse)
|
|
284
440
|
};
|
|
285
441
|
this.utils = {
|
|
286
442
|
/**
|
|
@@ -290,7 +446,11 @@ class Api extends HttpClient {
|
|
|
290
446
|
* @name PutUtilsSanityCheck
|
|
291
447
|
* @request PUT:/utils/sanity-check
|
|
292
448
|
*/
|
|
293
|
-
putUtilsSanityCheck: (params = {}) => this.request(
|
|
449
|
+
putUtilsSanityCheck: (params = {}) => this.request({
|
|
450
|
+
path: `/utils/sanity-check`,
|
|
451
|
+
method: 'PUT',
|
|
452
|
+
...params
|
|
453
|
+
}).then(convertHttpResponse)
|
|
294
454
|
};
|
|
295
455
|
}
|
|
296
456
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Api as NodeApi } from './api-alephium';
|
|
2
|
+
import { Api as ExplorerApi } from './api-explorer';
|
|
3
|
+
export declare class NodeProvider extends NodeApi<null> {
|
|
4
|
+
constructor(baseUrl: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class ExplorerProvider extends ExplorerApi<null> {
|
|
7
|
+
constructor(baseUrl: string);
|
|
8
|
+
}
|
|
9
|
+
export * as node from './api-alephium';
|
|
10
|
+
export * as explorer from './api-explorer';
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.explorer = exports.node = exports.ExplorerProvider = exports.NodeProvider = void 0;
|
|
40
|
+
const api_alephium_1 = require("./api-alephium");
|
|
41
|
+
const api_explorer_1 = require("./api-explorer");
|
|
42
|
+
class NodeProvider extends api_alephium_1.Api {
|
|
43
|
+
constructor(baseUrl) {
|
|
44
|
+
super({ baseUrl: baseUrl });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.NodeProvider = NodeProvider;
|
|
48
|
+
class ExplorerProvider extends api_explorer_1.Api {
|
|
49
|
+
constructor(baseUrl) {
|
|
50
|
+
super({ baseUrl: baseUrl });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ExplorerProvider = ExplorerProvider;
|
|
54
|
+
exports.node = __importStar(require("./api-alephium"));
|
|
55
|
+
exports.explorer = __importStar(require("./api-explorer"));
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { NodeProvider } from '../api';
|
|
2
|
+
import { node } from '../api';
|
|
3
|
+
import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerWithNodeProvider } from '../signer';
|
|
4
|
+
export declare abstract class Common {
|
|
5
|
+
readonly sourceCodeSha256: string;
|
|
6
|
+
readonly functions: node.FunctionSig[];
|
|
7
|
+
static readonly importRegex: RegExp;
|
|
8
|
+
static readonly contractRegex: RegExp;
|
|
9
|
+
static readonly interfaceRegex: RegExp;
|
|
10
|
+
static readonly scriptRegex: RegExp;
|
|
11
|
+
private static _artifactCache;
|
|
12
|
+
static artifactCacheCapacity: number;
|
|
13
|
+
protected static _getArtifactFromCache(codeHash: string): Contract | Script | undefined;
|
|
14
|
+
protected static _putArtifactToCache(contract: Contract): void;
|
|
15
|
+
constructor(sourceCodeSha256: string, functions: node.FunctionSig[]);
|
|
16
|
+
protected static _contractPath(fileName: string): string;
|
|
17
|
+
protected static _artifactPath(fileName: string): string;
|
|
18
|
+
protected static _artifactsFolder(): string;
|
|
19
|
+
protected static _handleImports(contractStr: string, importsCache: string[]): Promise<string>;
|
|
20
|
+
protected static _loadContractStr(fileName: string, importsCache: string[], validate: (fileName: string) => void): Promise<string>;
|
|
21
|
+
static checkFileNameExtension(fileName: string): void;
|
|
22
|
+
protected static _from<T extends {
|
|
23
|
+
sourceCodeSha256: string;
|
|
24
|
+
}>(provider: NodeProvider, fileName: string, loadContractStr: (fileName: string, importsCache: string[]) => Promise<string>, compile: (provider: NodeProvider, fileName: string, contractStr: string, contractHash: string) => Promise<T>): Promise<T>;
|
|
25
|
+
protected _saveToFile(fileName: string): Promise<void>;
|
|
26
|
+
abstract buildByteCodeToDeploy(initialFields?: Fields): string;
|
|
27
|
+
}
|
|
28
|
+
export declare class Contract extends Common {
|
|
29
|
+
readonly bytecode: string;
|
|
30
|
+
readonly codeHash: string;
|
|
31
|
+
readonly fieldsSig: node.FieldsSig;
|
|
32
|
+
readonly eventsSig: node.EventSig[];
|
|
33
|
+
constructor(sourceCodeSha256: string, bytecode: string, codeHash: string, fieldsSig: node.FieldsSig, eventsSig: node.EventSig[], functions: node.FunctionSig[]);
|
|
34
|
+
static checkCodeType(fileName: string, contractStr: string): void;
|
|
35
|
+
private static loadContractStr;
|
|
36
|
+
static fromSource(provider: NodeProvider, fileName: string): Promise<Contract>;
|
|
37
|
+
private static compile;
|
|
38
|
+
static fromJson(artifact: any): Contract;
|
|
39
|
+
static fromArtifactFile(fileName: string): Promise<Contract>;
|
|
40
|
+
toString(): string;
|
|
41
|
+
toState(fields: Fields, asset: Asset, address?: string): ContractState;
|
|
42
|
+
static randomAddress(): string;
|
|
43
|
+
private _test;
|
|
44
|
+
testPublicMethod(provider: NodeProvider, funcName: string, params: TestContractParams): Promise<TestContractResult>;
|
|
45
|
+
testPrivateMethod(provider: NodeProvider, funcName: string, params: TestContractParams): Promise<TestContractResult>;
|
|
46
|
+
toApiFields(fields?: Fields): node.Val[];
|
|
47
|
+
toApiArgs(funcName: string, args?: Arguments): node.Val[];
|
|
48
|
+
getMethodIndex(funcName: string): number;
|
|
49
|
+
toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
|
|
50
|
+
toTestContract(funcName: string, params: TestContractParams): node.TestContract;
|
|
51
|
+
static fromCodeHash(codeHash: string): Promise<Contract>;
|
|
52
|
+
static getFieldsSig(state: node.ContractState): Promise<node.FieldsSig>;
|
|
53
|
+
fromApiContractState(state: node.ContractState): Promise<ContractState>;
|
|
54
|
+
static ContractCreatedEvent: node.EventSig;
|
|
55
|
+
static ContractDestroyedEvent: node.EventSig;
|
|
56
|
+
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): Promise<ContractEventByTxId>;
|
|
57
|
+
fromTestContractResult(methodIndex: number, result: node.TestContractResult): Promise<TestContractResult>;
|
|
58
|
+
paramsForDeployment(params: BuildDeployContractTx): Promise<SignDeployContractTxParams>;
|
|
59
|
+
transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<DeployContractTransaction>;
|
|
60
|
+
buildByteCodeToDeploy(initialFields: Fields): string;
|
|
61
|
+
}
|
|
62
|
+
export declare class Script extends Common {
|
|
63
|
+
readonly bytecodeTemplate: string;
|
|
64
|
+
readonly fieldsSig: node.FieldsSig;
|
|
65
|
+
constructor(sourceCodeSha256: string, bytecodeTemplate: string, fieldsSig: node.FieldsSig, functions: node.FunctionSig[]);
|
|
66
|
+
static checkCodeType(fileName: string, contractStr: string): void;
|
|
67
|
+
private static loadContractStr;
|
|
68
|
+
static fromSource(provider: NodeProvider, fileName: string): Promise<Script>;
|
|
69
|
+
private static compile;
|
|
70
|
+
static fromJson(artifact: any): Script;
|
|
71
|
+
static fromArtifactFile(fileName: string): Promise<Script>;
|
|
72
|
+
toString(): string;
|
|
73
|
+
paramsForDeployment(params: BuildExecuteScriptTx): Promise<SignExecuteScriptTxParams>;
|
|
74
|
+
transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<BuildScriptTxResult>;
|
|
75
|
+
buildByteCodeToDeploy(initialFields: Fields): string;
|
|
76
|
+
}
|
|
77
|
+
export declare type Number256 = number | bigint | string;
|
|
78
|
+
export declare type Val = Number256 | boolean | string | Val[];
|
|
79
|
+
export declare type NamedVals = Record<string, Val>;
|
|
80
|
+
export declare type Fields = NamedVals;
|
|
81
|
+
export declare type Arguments = NamedVals;
|
|
82
|
+
export declare function extractArray(tpe: string, v: Val): node.Val;
|
|
83
|
+
export declare function toApiVal(v: Val, tpe: string): node.Val;
|
|
84
|
+
export interface Asset {
|
|
85
|
+
alphAmount: Number256;
|
|
86
|
+
tokens?: Token[];
|
|
87
|
+
}
|
|
88
|
+
export interface Token {
|
|
89
|
+
id: string;
|
|
90
|
+
amount: Number256;
|
|
91
|
+
}
|
|
92
|
+
export interface InputAsset {
|
|
93
|
+
address: string;
|
|
94
|
+
asset: Asset;
|
|
95
|
+
}
|
|
96
|
+
export interface ContractState {
|
|
97
|
+
address: string;
|
|
98
|
+
contractId: string;
|
|
99
|
+
bytecode: string;
|
|
100
|
+
initialStateHash?: string;
|
|
101
|
+
codeHash: string;
|
|
102
|
+
fields: Fields;
|
|
103
|
+
fieldsSig: node.FieldsSig;
|
|
104
|
+
asset: Asset;
|
|
105
|
+
}
|
|
106
|
+
export interface TestContractParams {
|
|
107
|
+
group?: number;
|
|
108
|
+
address?: string;
|
|
109
|
+
initialFields?: Fields;
|
|
110
|
+
initialAsset?: Asset;
|
|
111
|
+
testMethodIndex?: number;
|
|
112
|
+
testArgs?: Arguments;
|
|
113
|
+
existingContracts?: ContractState[];
|
|
114
|
+
inputAssets?: InputAsset[];
|
|
115
|
+
}
|
|
116
|
+
export interface ContractEvent {
|
|
117
|
+
blockHash: string;
|
|
118
|
+
txId: string;
|
|
119
|
+
name: string;
|
|
120
|
+
fields: Fields;
|
|
121
|
+
}
|
|
122
|
+
export interface ContractEventByTxId {
|
|
123
|
+
blockHash: string;
|
|
124
|
+
contractAddress: string;
|
|
125
|
+
name: string;
|
|
126
|
+
fields: Fields;
|
|
127
|
+
}
|
|
128
|
+
export interface TestContractResult {
|
|
129
|
+
address: string;
|
|
130
|
+
contractId: string;
|
|
131
|
+
returns: Val[];
|
|
132
|
+
gasUsed: number;
|
|
133
|
+
contracts: ContractState[];
|
|
134
|
+
txOutputs: Output[];
|
|
135
|
+
events: ContractEventByTxId[];
|
|
136
|
+
}
|
|
137
|
+
export declare type Output = AssetOutput | ContractOutput;
|
|
138
|
+
export interface AssetOutput extends Asset {
|
|
139
|
+
type: string;
|
|
140
|
+
address: string;
|
|
141
|
+
lockTime: number;
|
|
142
|
+
message: string;
|
|
143
|
+
}
|
|
144
|
+
export interface ContractOutput {
|
|
145
|
+
type: string;
|
|
146
|
+
address: string;
|
|
147
|
+
alphAmount: Number256;
|
|
148
|
+
tokens: Token[];
|
|
149
|
+
}
|
|
150
|
+
export interface DeployContractTransaction {
|
|
151
|
+
fromGroup: number;
|
|
152
|
+
toGroup: number;
|
|
153
|
+
unsignedTx: string;
|
|
154
|
+
txId: string;
|
|
155
|
+
contractAddress: string;
|
|
156
|
+
contractId: string;
|
|
157
|
+
}
|
|
158
|
+
export interface BuildDeployContractTx {
|
|
159
|
+
signerAddress: string;
|
|
160
|
+
initialFields?: Fields;
|
|
161
|
+
initialAlphAmount?: string;
|
|
162
|
+
initialTokenAmounts?: Token[];
|
|
163
|
+
issueTokenAmount?: Number256;
|
|
164
|
+
gasAmount?: number;
|
|
165
|
+
gasPrice?: Number256;
|
|
166
|
+
submitTx?: boolean;
|
|
167
|
+
}
|
|
168
|
+
export interface BuildExecuteScriptTx {
|
|
169
|
+
signerAddress: string;
|
|
170
|
+
initialFields?: Fields;
|
|
171
|
+
alphAmount?: Number256;
|
|
172
|
+
tokens?: Token[];
|
|
173
|
+
gasAmount?: number;
|
|
174
|
+
gasPrice?: Number256;
|
|
175
|
+
submitTx?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface BuildScriptTxResult {
|
|
178
|
+
fromGroup: number;
|
|
179
|
+
toGroup: number;
|
|
180
|
+
unsignedTx: string;
|
|
181
|
+
txId: string;
|
|
182
|
+
}
|