@alephium/web3 0.2.0-rc.3 → 0.2.0-rc.31
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 +117 -17
- package/dist/src/api/api-alephium.js +145 -79
- package/dist/src/api/api-explorer.d.ts +163 -48
- package/dist/src/api/api-explorer.js +157 -34
- package/dist/src/api/index.d.ts +14 -2
- package/dist/src/api/index.js +46 -4
- package/dist/src/api/types.d.ts +23 -0
- package/dist/src/api/types.js +240 -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 +110 -73
- package/dist/src/contract/contract.js +395 -451
- 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 +4 -0
- package/dist/{scripts/stop-devnet.js → src/global.js} +17 -11
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +23 -1
- package/dist/src/signer/index.d.ts +0 -1
- package/dist/src/signer/index.js +5 -2
- package/dist/src/signer/signer.d.ts +35 -28
- package/dist/src/signer/signer.js +79 -47
- 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 -3
- package/dist/src/utils/subscription.js +0 -1
- 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 -47
- package/src/api/api-alephium.ts +169 -25
- package/src/api/api-explorer.ts +234 -51
- package/src/api/index.ts +53 -3
- package/src/api/types.ts +233 -0
- package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
- package/src/contract/contract.ts +582 -550
- package/src/contract/events.ts +6 -5
- package/src/contract/ralph.ts +29 -4
- package/src/{transaction/sign-verify.ts → global.ts} +14 -15
- package/src/index.ts +7 -0
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +122 -85
- 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/.eslintrc.json +0 -21
- package/LICENSE +0 -165
- package/contracts/add/add.ral +0 -16
- package/contracts/greeter/greeter.ral +0 -7
- package/contracts/greeter/greeter_interface.ral +0 -3
- package/contracts/greeter_main.ral +0 -9
- package/contracts/main.ral +0 -6
- package/contracts/sub/sub.ral +0 -9
- package/contracts/test/metadata.ral +0 -17
- package/contracts/test/warnings.ral +0 -5
- 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/src/signer/node-wallet.d.ts +0 -13
- package/dist/src/signer/node-wallet.js +0 -60
- package/dist/src/test/index.d.ts +0 -7
- package/dist/src/test/index.js +0 -41
- package/dist/src/test/privatekey-wallet.d.ts +0 -12
- 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 -10
- 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 -74
- package/src/test/index.ts +0 -32
- package/src/test/privatekey-wallet.ts +0 -58
- package/src/transaction/sign-verify.test.ts +0 -50
- 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 -41
- 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 -197
- package/test/events.test.ts +0 -138
- package/test/transaction.test.ts +0 -72
package/dist/src/utils/index.js
CHANGED
|
@@ -18,7 +18,11 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
*/
|
|
19
19
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
20
|
if (k2 === undefined) k2 = k;
|
|
21
|
-
Object.
|
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
22
26
|
}) : (function(o, m, k, k2) {
|
|
23
27
|
if (k2 === undefined) k2 = k;
|
|
24
28
|
o[k2] = m[k];
|
|
@@ -30,6 +34,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
34
|
__exportStar(require("./address"), exports);
|
|
31
35
|
__exportStar(require("./bs58"), exports);
|
|
32
36
|
__exportStar(require("./djb2"), exports);
|
|
33
|
-
__exportStar(require("./password-crypto"), exports);
|
|
34
37
|
__exportStar(require("./utils"), exports);
|
|
35
38
|
__exportStar(require("./subscription"), exports);
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import { NodeProvider } from '../api';
|
|
3
2
|
declare type MessageCallback<Message> = (message: Message) => Promise<void>;
|
|
4
3
|
declare type ErrorCallback<Message> = (error: any, subscription: Subscription<Message>) => Promise<void>;
|
|
5
4
|
export interface SubscribeOptions<Message> {
|
|
6
|
-
provider: NodeProvider;
|
|
7
5
|
pollingInterval: number;
|
|
8
6
|
messageCallback: MessageCallback<Message>;
|
|
9
7
|
errorCallback: ErrorCallback<Message>;
|
|
10
8
|
}
|
|
11
9
|
export declare abstract class Subscription<Message> {
|
|
12
|
-
provider: NodeProvider;
|
|
13
10
|
pollingInterval: number;
|
|
14
11
|
protected messageCallback: MessageCallback<Message>;
|
|
15
12
|
protected errorCallback: ErrorCallback<Message>;
|
|
@@ -24,7 +24,6 @@ exports.Subscription = void 0;
|
|
|
24
24
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
25
25
|
class Subscription {
|
|
26
26
|
constructor(options) {
|
|
27
|
-
this.provider = options.provider;
|
|
28
27
|
this.pollingInterval = options.pollingInterval;
|
|
29
28
|
this.messageCallback = options.messageCallback;
|
|
30
29
|
this.errorCallback = options.errorCallback;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { ec as EC, SignatureInput } from 'elliptic';
|
|
2
|
-
import * as node from '../api/api-alephium';
|
|
3
|
-
import * as explorer from '../api/api-explorer';
|
|
4
|
-
export declare function convertHttpResponse<T>(response: node.HttpResponse<T, {
|
|
5
|
-
detail: string;
|
|
6
|
-
}> | explorer.HttpResponse<T, {
|
|
7
|
-
detail: string;
|
|
8
|
-
}>): T;
|
|
9
2
|
export declare function signatureEncode(signature: EC.Signature): string;
|
|
10
|
-
export declare
|
|
3
|
+
export declare function signatureDecode(ec: EC, signature: string): SignatureInput;
|
|
4
|
+
export declare function xorByte(intValue: number): number;
|
|
11
5
|
export declare function isHexString(input: string): boolean;
|
|
12
|
-
export declare
|
|
6
|
+
export declare function groupOfAddress(address: string): number;
|
|
13
7
|
export declare function contractIdFromAddress(address: string): Uint8Array;
|
|
14
8
|
export declare function tokenIdFromAddress(address: string): Uint8Array;
|
|
15
9
|
export declare function hexToBinUnsafe(hex: string): Uint8Array;
|
|
16
10
|
export declare function binToHex(bin: Uint8Array): string;
|
|
11
|
+
export declare function groupOfPrivateKey(privateKey: string): number;
|
|
17
12
|
export declare function publicKeyFromPrivateKey(privateKey: string): string;
|
|
18
13
|
export declare function addressFromPublicKey(publicKey: string): string;
|
|
19
14
|
export declare function addressFromContractId(contractId: string): string;
|
package/dist/src/utils/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.assertType = exports.timeout = exports.hexToString = exports.stringToHex = exports.subContractId = exports.contractIdFromTx = exports.addressFromContractId = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.binToHex = exports.hexToBinUnsafe = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isHexString = exports.
|
|
23
|
+
exports.assertType = exports.timeout = exports.hexToString = exports.stringToHex = exports.subContractId = exports.contractIdFromTx = exports.addressFromContractId = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.groupOfPrivateKey = exports.binToHex = exports.hexToBinUnsafe = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isHexString = exports.xorByte = exports.signatureDecode = exports.signatureEncode = void 0;
|
|
24
24
|
const elliptic_1 = require("elliptic");
|
|
25
25
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
26
26
|
const blakejs_1 = __importDefault(require("blakejs"));
|
|
@@ -29,15 +29,6 @@ const buffer_1 = require("buffer/");
|
|
|
29
29
|
const constants_1 = require("../constants");
|
|
30
30
|
const djb2_1 = __importDefault(require("./djb2"));
|
|
31
31
|
const ec = new elliptic_1.ec('secp256k1');
|
|
32
|
-
function convertHttpResponse(response) {
|
|
33
|
-
if (response.error) {
|
|
34
|
-
throw new Error(response.error.detail);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return response.data;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.convertHttpResponse = convertHttpResponse;
|
|
41
32
|
function signatureEncode(signature) {
|
|
42
33
|
let sNormalized = signature.s;
|
|
43
34
|
if (ec.n && signature.s.cmp(ec.nh) === 1) {
|
|
@@ -49,7 +40,7 @@ function signatureEncode(signature) {
|
|
|
49
40
|
}
|
|
50
41
|
exports.signatureEncode = signatureEncode;
|
|
51
42
|
// the signature should be in hex string format for 64 bytes
|
|
52
|
-
|
|
43
|
+
function signatureDecode(ec, signature) {
|
|
53
44
|
if (signature.length !== 128) {
|
|
54
45
|
throw new Error('Invalid signature length');
|
|
55
46
|
}
|
|
@@ -62,15 +53,16 @@ const signatureDecode = (ec, signature) => {
|
|
|
62
53
|
else {
|
|
63
54
|
throw new Error('The signature is not normalized');
|
|
64
55
|
}
|
|
65
|
-
}
|
|
56
|
+
}
|
|
66
57
|
exports.signatureDecode = signatureDecode;
|
|
67
|
-
|
|
58
|
+
function xorByte(intValue) {
|
|
68
59
|
const byte0 = (intValue >> 24) & 0xff;
|
|
69
60
|
const byte1 = (intValue >> 16) & 0xff;
|
|
70
61
|
const byte2 = (intValue >> 8) & 0xff;
|
|
71
62
|
const byte3 = intValue & 0xff;
|
|
72
63
|
return (byte0 ^ byte1 ^ byte2 ^ byte3) & 0xff;
|
|
73
|
-
}
|
|
64
|
+
}
|
|
65
|
+
exports.xorByte = xorByte;
|
|
74
66
|
function isHexString(input) {
|
|
75
67
|
return input.length % 2 === 0 && /[0-9a-f]*$/.test(input);
|
|
76
68
|
}
|
|
@@ -82,7 +74,7 @@ var AddressType;
|
|
|
82
74
|
AddressType[AddressType["P2SH"] = 2] = "P2SH";
|
|
83
75
|
AddressType[AddressType["P2C"] = 3] = "P2C";
|
|
84
76
|
})(AddressType || (AddressType = {}));
|
|
85
|
-
|
|
77
|
+
function groupOfAddress(address) {
|
|
86
78
|
const decoded = bs58_1.default.decode(address);
|
|
87
79
|
if (decoded.length == 0)
|
|
88
80
|
throw new Error('Address string is empty');
|
|
@@ -100,32 +92,32 @@ const groupOfAddress = (address) => {
|
|
|
100
92
|
else {
|
|
101
93
|
throw new Error(`Invalid asset address type: ${addressType}`);
|
|
102
94
|
}
|
|
103
|
-
}
|
|
95
|
+
}
|
|
104
96
|
exports.groupOfAddress = groupOfAddress;
|
|
105
|
-
|
|
97
|
+
function groupOfAddressBytes(bytes) {
|
|
106
98
|
const hint = (0, djb2_1.default)(bytes) | 1;
|
|
107
99
|
const hash = xorByte(hint);
|
|
108
100
|
const group = hash % constants_1.TOTAL_NUMBER_OF_GROUPS;
|
|
109
101
|
return group;
|
|
110
|
-
}
|
|
102
|
+
}
|
|
111
103
|
// Pay to public key hash address
|
|
112
|
-
|
|
104
|
+
function groupOfP2pkhAddress(address) {
|
|
113
105
|
if (address.length != 32) {
|
|
114
106
|
throw new Error(`Invalid p2pkh address length: ${address.length}`);
|
|
115
107
|
}
|
|
116
108
|
return groupOfAddressBytes(address);
|
|
117
|
-
}
|
|
109
|
+
}
|
|
118
110
|
// Pay to multiple public key hash address
|
|
119
|
-
|
|
111
|
+
function groupOfP2mpkhAddress(address) {
|
|
120
112
|
if ((address.length - 2) % 32 != 0) {
|
|
121
113
|
throw new Error(`Invalid p2mpkh address length: ${address.length}`);
|
|
122
114
|
}
|
|
123
115
|
return groupOfAddressBytes(address.slice(1, 33));
|
|
124
|
-
}
|
|
116
|
+
}
|
|
125
117
|
// Pay to script hash address
|
|
126
|
-
|
|
118
|
+
function groupOfP2shAddress(address) {
|
|
127
119
|
return groupOfAddressBytes(address);
|
|
128
|
-
}
|
|
120
|
+
}
|
|
129
121
|
function contractIdFromAddress(address) {
|
|
130
122
|
return idFromAddress(address);
|
|
131
123
|
}
|
|
@@ -155,6 +147,10 @@ function binToHex(bin) {
|
|
|
155
147
|
return buffer_1.Buffer.from(bin).toString('hex');
|
|
156
148
|
}
|
|
157
149
|
exports.binToHex = binToHex;
|
|
150
|
+
function groupOfPrivateKey(privateKey) {
|
|
151
|
+
return groupOfAddress(addressFromPublicKey(publicKeyFromPrivateKey(privateKey)));
|
|
152
|
+
}
|
|
153
|
+
exports.groupOfPrivateKey = groupOfPrivateKey;
|
|
158
154
|
function publicKeyFromPrivateKey(privateKey) {
|
|
159
155
|
const key = ec.keyFromPrivate(privateKey);
|
|
160
156
|
return key.getPublic(true, 'hex');
|
package/jest-config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testPathIgnorePatterns": [".*/node_modules/"],
|
|
3
|
+
"transform": {
|
|
4
|
+
"^.+\\.(t|j)sx?$": "ts-jest"
|
|
5
|
+
},
|
|
6
|
+
"testMatch": ["**/*.test.ts"],
|
|
7
|
+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
8
|
+
"collectCoverage": true,
|
|
9
|
+
"coverageDirectory": "./coverage/",
|
|
10
|
+
"collectCoverageFrom": ["src/**/*.ts"]
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephium/web3",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.31",
|
|
4
4
|
"description": "A JS/TS library to interact with the Alephium platform",
|
|
5
5
|
"license": "GPL",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -27,52 +27,28 @@
|
|
|
27
27
|
},
|
|
28
28
|
"author": "Alephium dev <dev@alephium.org>",
|
|
29
29
|
"config": {
|
|
30
|
-
"alephium_version": "1.5.0-
|
|
31
|
-
"explorer_backend_version": "1.
|
|
30
|
+
"alephium_version": "1.5.0-rc11",
|
|
31
|
+
"explorer_backend_version": "1.9.0-rc0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rm -rf dist/* && npx tsc --build . && webpack",
|
|
35
|
-
"
|
|
35
|
+
"test": "jest -i --config ./jest-config.json",
|
|
36
36
|
"update-schemas": "npm run update-schema:alephium && npm run update-schema:explorer",
|
|
37
|
-
"update-schema:alephium": "npx swagger-typescript-api -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
|
|
38
|
-
"update-schema:explorer": "npx swagger-typescript-api -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
|
|
39
|
-
"check-versions": "node scripts/check-versions.js ${npm_package_config_alephium_version} ${npm_package_config_explorer_backend_version}"
|
|
40
|
-
"dev": "tsnd --respawn lib/index.ts",
|
|
41
|
-
"lint": "eslint . --ext ts",
|
|
42
|
-
"lint:fix": "eslint . --fix --ext ts",
|
|
43
|
-
"test": "jest -i --config ./configs/jest.config.ts",
|
|
44
|
-
"test:client": "jest -i --config ./configs/jest-client.config.ts",
|
|
45
|
-
"test:unit": "jest -i --config ./configs/jest-unit.config.ts",
|
|
46
|
-
"test:watch": "npm run test -- --watch --coverage=false",
|
|
47
|
-
"test:watch:unit": "npm run test:unit -- --watch --coverage=false",
|
|
48
|
-
"test:watch:client": "npm run test:client -- --watch --coverage=false",
|
|
49
|
-
"prepublishOnly": "npm run build",
|
|
50
|
-
"prepack": "node scripts/rename-gitignore.js .gitignore gitignore",
|
|
51
|
-
"postpack": "node scripts/rename-gitignore.js gitignore .gitignore",
|
|
52
|
-
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
|
|
53
|
-
"start-devnet": "node scripts/start-devnet.js ${npm_package_config_alephium_version}",
|
|
54
|
-
"restart-devnet": "npm run start-devnet",
|
|
55
|
-
"stop-devnet": "node scripts/stop-devnet.js"
|
|
37
|
+
"update-schema:alephium": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
|
|
38
|
+
"update-schema:explorer": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
|
|
39
|
+
"check-versions": "node scripts/check-versions.js ${npm_package_config_alephium_version} ${npm_package_config_explorer_backend_version}"
|
|
56
40
|
},
|
|
57
41
|
"type": "commonjs",
|
|
58
|
-
"bin": {
|
|
59
|
-
"alephium": "dist/scripts/create-project.js"
|
|
60
|
-
},
|
|
61
42
|
"dependencies": {
|
|
62
43
|
"base-x": "4.0.0",
|
|
63
44
|
"blakejs": "1.2.1",
|
|
64
45
|
"buffer": "^6.0.3",
|
|
65
|
-
"commander": "^9.1.0",
|
|
66
46
|
"cross-fetch": "^3.1.5",
|
|
67
|
-
"crypto-js": "4.1.1",
|
|
68
47
|
"elliptic": "6.5.4",
|
|
69
|
-
"eventemitter3": "^4.0.7"
|
|
70
|
-
"find-up": "^2.1.0",
|
|
71
|
-
"fs-extra": "^10.0.1"
|
|
48
|
+
"eventemitter3": "^4.0.7"
|
|
72
49
|
},
|
|
73
50
|
"devDependencies": {
|
|
74
|
-
"@
|
|
75
|
-
"@types/elliptic": "^6.4.13",
|
|
51
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
76
52
|
"@types/find-up": "^2.1.0",
|
|
77
53
|
"@types/fs-extra": "^9.0.13",
|
|
78
54
|
"@types/jest": "^27.5.1",
|
|
@@ -81,14 +57,12 @@
|
|
|
81
57
|
"@types/rewire": "^2.5.28",
|
|
82
58
|
"@typescript-eslint/eslint-plugin": "^4.30.0",
|
|
83
59
|
"@typescript-eslint/parser": "^4.30.0",
|
|
84
|
-
"babel-eslint": "^10.1.0",
|
|
85
60
|
"clean-webpack-plugin": "4.0.0",
|
|
86
61
|
"crypto-browserify": "^3.12.0",
|
|
87
62
|
"eslint": "^7.32.0",
|
|
88
63
|
"eslint-config-prettier": "^8.5.0",
|
|
89
64
|
"eslint-plugin-header": "^3.1.1",
|
|
90
65
|
"eslint-plugin-prettier": "^4.0.0",
|
|
91
|
-
"eslint-plugin-react": "^7.29.4",
|
|
92
66
|
"eslint-plugin-security": "1.4.0",
|
|
93
67
|
"html-webpack-plugin": "5.5.0",
|
|
94
68
|
"jest": "^28.1.0",
|
|
@@ -98,7 +72,6 @@
|
|
|
98
72
|
"mock-socket": "^9.0.8",
|
|
99
73
|
"prettier": "^2.3.2",
|
|
100
74
|
"process": "^0.11.10",
|
|
101
|
-
"react-app-rewired": "^2.2.1",
|
|
102
75
|
"rewire": "^6.0.0",
|
|
103
76
|
"shelljs": "^0.8.5",
|
|
104
77
|
"stream-browserify": "^3.0.0",
|
|
@@ -107,21 +80,12 @@
|
|
|
107
80
|
"ts-jest": "^28.0.2",
|
|
108
81
|
"ts-node": "^10.7.0",
|
|
109
82
|
"tslib": "^2.3.1",
|
|
110
|
-
"typescript": "
|
|
83
|
+
"typescript": "4.7.4",
|
|
111
84
|
"webpack": "^5.72.0",
|
|
112
85
|
"webpack-cli": "^4.9.2"
|
|
113
86
|
},
|
|
114
87
|
"engines": {
|
|
115
|
-
"node": ">=
|
|
88
|
+
"node": ">=16.0.0",
|
|
116
89
|
"npm": ">=7.0.0"
|
|
117
|
-
},
|
|
118
|
-
"prettier": {
|
|
119
|
-
"printWidth": 120,
|
|
120
|
-
"tabWidth": 2,
|
|
121
|
-
"useTabs": false,
|
|
122
|
-
"semi": false,
|
|
123
|
-
"singleQuote": true,
|
|
124
|
-
"bracketSameLine": false,
|
|
125
|
-
"trailingComma": "none"
|
|
126
90
|
}
|
|
127
91
|
}
|
package/src/api/api-alephium.ts
CHANGED
|
@@ -124,6 +124,11 @@ export interface Banned {
|
|
|
124
124
|
type: string
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
export interface BlockAndEvents {
|
|
128
|
+
block: BlockEntry
|
|
129
|
+
events: ContractEventByBlockHash[]
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
export interface BlockEntry {
|
|
128
133
|
/** @format block-hash */
|
|
129
134
|
hash: string
|
|
@@ -174,6 +179,14 @@ export interface BlockHeaderEntry {
|
|
|
174
179
|
deps: string[]
|
|
175
180
|
}
|
|
176
181
|
|
|
182
|
+
export interface BlocksAndEventsPerTimeStampRange {
|
|
183
|
+
blocksAndEvents: BlockAndEvents[][]
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface BlocksPerTimeStampRange {
|
|
187
|
+
blocks: BlockEntry[][]
|
|
188
|
+
}
|
|
189
|
+
|
|
177
190
|
export interface BrokerInfo {
|
|
178
191
|
/** @format clique-id */
|
|
179
192
|
cliqueId: string
|
|
@@ -422,23 +435,44 @@ export interface ChangeActiveAddress {
|
|
|
422
435
|
}
|
|
423
436
|
|
|
424
437
|
export interface CompileContractResult {
|
|
438
|
+
name: string
|
|
425
439
|
bytecode: string
|
|
440
|
+
bytecodeDebugPatch: string
|
|
426
441
|
|
|
427
442
|
/** @format 32-byte-hash */
|
|
428
443
|
codeHash: string
|
|
444
|
+
|
|
445
|
+
/** @format 32-byte-hash */
|
|
446
|
+
codeHashDebug: string
|
|
429
447
|
fields: FieldsSig
|
|
430
448
|
functions: FunctionSig[]
|
|
431
449
|
events: EventSig[]
|
|
432
450
|
warnings: string[]
|
|
433
451
|
}
|
|
434
452
|
|
|
453
|
+
export interface CompileProjectResult {
|
|
454
|
+
contracts: CompileContractResult[]
|
|
455
|
+
scripts: CompileScriptResult[]
|
|
456
|
+
}
|
|
457
|
+
|
|
435
458
|
export interface CompileScriptResult {
|
|
459
|
+
name: string
|
|
436
460
|
bytecodeTemplate: string
|
|
461
|
+
bytecodeDebugPatch: string
|
|
437
462
|
fields: FieldsSig
|
|
438
463
|
functions: FunctionSig[]
|
|
439
464
|
warnings: string[]
|
|
440
465
|
}
|
|
441
466
|
|
|
467
|
+
export interface CompilerOptions {
|
|
468
|
+
ignoreUnusedConstantsWarnings?: boolean
|
|
469
|
+
ignoreUnusedVariablesWarnings?: boolean
|
|
470
|
+
ignoreUnusedFieldsWarnings?: boolean
|
|
471
|
+
ignoreUnusedPrivateFunctionsWarnings?: boolean
|
|
472
|
+
ignoreReadonlyCheckWarnings?: boolean
|
|
473
|
+
ignoreExternalCallCheckWarnings?: boolean
|
|
474
|
+
}
|
|
475
|
+
|
|
442
476
|
export interface Confirmed {
|
|
443
477
|
/** @format block-hash */
|
|
444
478
|
blockHash: string
|
|
@@ -459,6 +493,7 @@ export interface Confirmed {
|
|
|
459
493
|
|
|
460
494
|
export interface Contract {
|
|
461
495
|
code: string
|
|
496
|
+
compilerOptions?: CompilerOptions
|
|
462
497
|
}
|
|
463
498
|
|
|
464
499
|
export interface ContractEvent {
|
|
@@ -473,6 +508,18 @@ export interface ContractEvent {
|
|
|
473
508
|
fields: Val[]
|
|
474
509
|
}
|
|
475
510
|
|
|
511
|
+
export interface ContractEventByBlockHash {
|
|
512
|
+
/** @format 32-byte-hash */
|
|
513
|
+
txId: string
|
|
514
|
+
|
|
515
|
+
/** @format address */
|
|
516
|
+
contractAddress: string
|
|
517
|
+
|
|
518
|
+
/** @format int32 */
|
|
519
|
+
eventIndex: number
|
|
520
|
+
fields: Val[]
|
|
521
|
+
}
|
|
522
|
+
|
|
476
523
|
export interface ContractEventByTxId {
|
|
477
524
|
/** @format block-hash */
|
|
478
525
|
blockHash: string
|
|
@@ -492,11 +539,12 @@ export interface ContractEvents {
|
|
|
492
539
|
nextStart: number
|
|
493
540
|
}
|
|
494
541
|
|
|
542
|
+
export interface ContractEventsByBlockHash {
|
|
543
|
+
events: ContractEventByBlockHash[]
|
|
544
|
+
}
|
|
545
|
+
|
|
495
546
|
export interface ContractEventsByTxId {
|
|
496
547
|
events: ContractEventByTxId[]
|
|
497
|
-
|
|
498
|
-
/** @format int32 */
|
|
499
|
-
nextStart: number
|
|
500
548
|
}
|
|
501
549
|
|
|
502
550
|
export interface ContractOutput {
|
|
@@ -531,6 +579,12 @@ export interface ContractState {
|
|
|
531
579
|
asset: AssetState
|
|
532
580
|
}
|
|
533
581
|
|
|
582
|
+
export interface DebugMessage {
|
|
583
|
+
/** @format address */
|
|
584
|
+
contractAddress: string
|
|
585
|
+
message: string
|
|
586
|
+
}
|
|
587
|
+
|
|
534
588
|
export interface DecodeUnsignedTx {
|
|
535
589
|
unsignedTx: string
|
|
536
590
|
}
|
|
@@ -567,10 +621,6 @@ export interface EventSig {
|
|
|
567
621
|
fieldTypes: string[]
|
|
568
622
|
}
|
|
569
623
|
|
|
570
|
-
export interface FetchResponse {
|
|
571
|
-
blocks: BlockEntry[][]
|
|
572
|
-
}
|
|
573
|
-
|
|
574
624
|
export interface FieldsSig {
|
|
575
625
|
names: string[]
|
|
576
626
|
types: string[]
|
|
@@ -707,6 +757,11 @@ export interface Penalty {
|
|
|
707
757
|
type: string
|
|
708
758
|
}
|
|
709
759
|
|
|
760
|
+
export interface Project {
|
|
761
|
+
code: string
|
|
762
|
+
compilerOptions?: CompilerOptions
|
|
763
|
+
}
|
|
764
|
+
|
|
710
765
|
export interface Reachable {
|
|
711
766
|
peers: string[]
|
|
712
767
|
type: string
|
|
@@ -733,6 +788,7 @@ export interface RevealMnemonicResult {
|
|
|
733
788
|
|
|
734
789
|
export interface Script {
|
|
735
790
|
code: string
|
|
791
|
+
compilerOptions?: CompilerOptions
|
|
736
792
|
}
|
|
737
793
|
|
|
738
794
|
export interface SelfClique {
|
|
@@ -850,6 +906,7 @@ export interface TestContractResult {
|
|
|
850
906
|
txInputs: string[]
|
|
851
907
|
txOutputs: Output[]
|
|
852
908
|
events: ContractEventByTxId[]
|
|
909
|
+
debugMessages: DebugMessage[]
|
|
853
910
|
}
|
|
854
911
|
|
|
855
912
|
export interface TestInputAsset {
|
|
@@ -1062,16 +1119,7 @@ export interface WalletUnlock {
|
|
|
1062
1119
|
}
|
|
1063
1120
|
|
|
1064
1121
|
import 'cross-fetch/polyfill'
|
|
1065
|
-
|
|
1066
|
-
function convertHttpResponse<T>(
|
|
1067
|
-
response: HttpResponse<T, { detail: string }> | HttpResponse<T, { detail: string }>
|
|
1068
|
-
): T {
|
|
1069
|
-
if (response.error) {
|
|
1070
|
-
throw new Error(response.error.detail)
|
|
1071
|
-
} else {
|
|
1072
|
-
return response.data
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1122
|
+
import { convertHttpResponse } from './utils'
|
|
1075
1123
|
|
|
1076
1124
|
export type QueryParamsType = Record<string | number, any>
|
|
1077
1125
|
export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>
|
|
@@ -1275,7 +1323,6 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1275
1323
|
this.abortControllers.delete(cancelToken)
|
|
1276
1324
|
}
|
|
1277
1325
|
|
|
1278
|
-
if (!response.ok) throw data
|
|
1279
1326
|
return data
|
|
1280
1327
|
})
|
|
1281
1328
|
}
|
|
@@ -1834,13 +1881,36 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1834
1881
|
* No description
|
|
1835
1882
|
*
|
|
1836
1883
|
* @tags Blockflow
|
|
1837
|
-
* @name
|
|
1884
|
+
* @name GetBlockflowBlocks
|
|
1838
1885
|
* @summary List blocks on the given time interval
|
|
1839
|
-
* @request GET:/blockflow
|
|
1886
|
+
* @request GET:/blockflow/blocks
|
|
1840
1887
|
*/
|
|
1841
|
-
|
|
1842
|
-
this.request<
|
|
1843
|
-
|
|
1888
|
+
getBlockflowBlocks: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
|
|
1889
|
+
this.request<
|
|
1890
|
+
BlocksPerTimeStampRange,
|
|
1891
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
1892
|
+
>({
|
|
1893
|
+
path: `/blockflow/blocks`,
|
|
1894
|
+
method: 'GET',
|
|
1895
|
+
query: query,
|
|
1896
|
+
format: 'json',
|
|
1897
|
+
...params
|
|
1898
|
+
}).then(convertHttpResponse),
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* No description
|
|
1902
|
+
*
|
|
1903
|
+
* @tags Blockflow
|
|
1904
|
+
* @name GetBlockflowBlocksWithEvents
|
|
1905
|
+
* @summary List blocks with events on the given time interval
|
|
1906
|
+
* @request GET:/blockflow/blocks-with-events
|
|
1907
|
+
*/
|
|
1908
|
+
getBlockflowBlocksWithEvents: (query: { fromTs: number; toTs?: number }, params: RequestParams = {}) =>
|
|
1909
|
+
this.request<
|
|
1910
|
+
BlocksAndEventsPerTimeStampRange,
|
|
1911
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
1912
|
+
>({
|
|
1913
|
+
path: `/blockflow/blocks-with-events`,
|
|
1844
1914
|
method: 'GET',
|
|
1845
1915
|
query: query,
|
|
1846
1916
|
format: 'json',
|
|
@@ -1863,6 +1933,22 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
1863
1933
|
...params
|
|
1864
1934
|
}).then(convertHttpResponse),
|
|
1865
1935
|
|
|
1936
|
+
/**
|
|
1937
|
+
* No description
|
|
1938
|
+
*
|
|
1939
|
+
* @tags Blockflow
|
|
1940
|
+
* @name GetBlockflowBlocksWithEventsBlockHash
|
|
1941
|
+
* @summary Get a block and events with hash
|
|
1942
|
+
* @request GET:/blockflow/blocks-with-events/{block_hash}
|
|
1943
|
+
*/
|
|
1944
|
+
getBlockflowBlocksWithEventsBlockHash: (blockHash: string, params: RequestParams = {}) =>
|
|
1945
|
+
this.request<BlockAndEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
1946
|
+
path: `/blockflow/blocks-with-events/${blockHash}`,
|
|
1947
|
+
method: 'GET',
|
|
1948
|
+
format: 'json',
|
|
1949
|
+
...params
|
|
1950
|
+
}).then(convertHttpResponse),
|
|
1951
|
+
|
|
1866
1952
|
/**
|
|
1867
1953
|
* No description
|
|
1868
1954
|
*
|
|
@@ -2164,6 +2250,27 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2164
2250
|
...params
|
|
2165
2251
|
}).then(convertHttpResponse),
|
|
2166
2252
|
|
|
2253
|
+
/**
|
|
2254
|
+
* No description
|
|
2255
|
+
*
|
|
2256
|
+
* @tags Contracts
|
|
2257
|
+
* @name PostContractsCompileProject
|
|
2258
|
+
* @summary Compile a project
|
|
2259
|
+
* @request POST:/contracts/compile-project
|
|
2260
|
+
*/
|
|
2261
|
+
postContractsCompileProject: (data: Project, params: RequestParams = {}) =>
|
|
2262
|
+
this.request<
|
|
2263
|
+
CompileProjectResult,
|
|
2264
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
2265
|
+
>({
|
|
2266
|
+
path: `/contracts/compile-project`,
|
|
2267
|
+
method: 'POST',
|
|
2268
|
+
body: data,
|
|
2269
|
+
type: ContentType.Json,
|
|
2270
|
+
format: 'json',
|
|
2271
|
+
...params
|
|
2272
|
+
}).then(convertHttpResponse),
|
|
2273
|
+
|
|
2167
2274
|
/**
|
|
2168
2275
|
* No description
|
|
2169
2276
|
*
|
|
@@ -2355,6 +2462,23 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2355
2462
|
...params
|
|
2356
2463
|
}).then(convertHttpResponse),
|
|
2357
2464
|
|
|
2465
|
+
/**
|
|
2466
|
+
* No description
|
|
2467
|
+
*
|
|
2468
|
+
* @tags Miners
|
|
2469
|
+
* @name PostMinersCpuMiningMineOneBlock
|
|
2470
|
+
* @summary Mine a block on CPU miner. !!! for test only !!!
|
|
2471
|
+
* @request POST:/miners/cpu-mining/mine-one-block
|
|
2472
|
+
*/
|
|
2473
|
+
postMinersCpuMiningMineOneBlock: (query: { fromGroup: number; toGroup: number }, params: RequestParams = {}) =>
|
|
2474
|
+
this.request<boolean, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
2475
|
+
path: `/miners/cpu-mining/mine-one-block`,
|
|
2476
|
+
method: 'POST',
|
|
2477
|
+
query: query,
|
|
2478
|
+
format: 'json',
|
|
2479
|
+
...params
|
|
2480
|
+
}).then(convertHttpResponse),
|
|
2481
|
+
|
|
2358
2482
|
/**
|
|
2359
2483
|
* No description
|
|
2360
2484
|
*
|
|
@@ -2399,7 +2523,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2399
2523
|
*/
|
|
2400
2524
|
getEventsContractContractaddress: (
|
|
2401
2525
|
contractAddress: string,
|
|
2402
|
-
query: { start: number;
|
|
2526
|
+
query: { start: number; limit?: number; group?: number },
|
|
2403
2527
|
params: RequestParams = {}
|
|
2404
2528
|
) =>
|
|
2405
2529
|
this.request<ContractEvents, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
@@ -2431,7 +2555,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2431
2555
|
*
|
|
2432
2556
|
* @tags Events
|
|
2433
2557
|
* @name GetEventsTxIdTxid
|
|
2434
|
-
* @summary Get events for a
|
|
2558
|
+
* @summary Get contract events for a transaction
|
|
2435
2559
|
* @request GET:/events/tx-id/{txId}
|
|
2436
2560
|
*/
|
|
2437
2561
|
getEventsTxIdTxid: (txId: string, query?: { group?: number }, params: RequestParams = {}) =>
|
|
@@ -2444,6 +2568,26 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2444
2568
|
query: query,
|
|
2445
2569
|
format: 'json',
|
|
2446
2570
|
...params
|
|
2571
|
+
}).then(convertHttpResponse),
|
|
2572
|
+
|
|
2573
|
+
/**
|
|
2574
|
+
* No description
|
|
2575
|
+
*
|
|
2576
|
+
* @tags Events
|
|
2577
|
+
* @name GetEventsBlockHashBlockhash
|
|
2578
|
+
* @summary Get contract events for a block
|
|
2579
|
+
* @request GET:/events/block-hash/{blockHash}
|
|
2580
|
+
*/
|
|
2581
|
+
getEventsBlockHashBlockhash: (blockHash: string, query?: { group?: number }, params: RequestParams = {}) =>
|
|
2582
|
+
this.request<
|
|
2583
|
+
ContractEventsByBlockHash,
|
|
2584
|
+
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
|
|
2585
|
+
>({
|
|
2586
|
+
path: `/events/block-hash/${blockHash}`,
|
|
2587
|
+
method: 'GET',
|
|
2588
|
+
query: query,
|
|
2589
|
+
format: 'json',
|
|
2590
|
+
...params
|
|
2447
2591
|
}).then(convertHttpResponse)
|
|
2448
2592
|
}
|
|
2449
2593
|
}
|