@alephium/web3 0.2.0-rc.1 → 0.2.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/contracts/greeter/greeter.ral +2 -2
  4. package/contracts/greeter/greeter_interface.ral +1 -0
  5. package/contracts/greeter_main.ral +0 -2
  6. package/dist/alephium-web3.min.js +1 -1
  7. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  8. package/dist/alephium-web3.min.js.map +1 -1
  9. package/dist/scripts/create-project.js +3 -2
  10. package/dist/src/api/api-alephium.d.ts +44 -11
  11. package/dist/src/api/api-alephium.js +16 -0
  12. package/dist/src/api/api-explorer.d.ts +16 -16
  13. package/dist/src/api/index.d.ts +2 -2
  14. package/dist/src/api/index.js +18 -3
  15. package/dist/src/contract/contract.d.ts +101 -52
  16. package/dist/src/contract/contract.js +353 -219
  17. package/dist/src/contract/index.js +5 -1
  18. package/dist/src/global.d.ts +4 -0
  19. package/dist/src/global.js +38 -0
  20. package/dist/src/index.d.ts +2 -0
  21. package/dist/src/index.js +20 -1
  22. package/dist/src/signer/index.d.ts +0 -1
  23. package/dist/src/signer/index.js +5 -2
  24. package/dist/src/signer/signer.d.ts +1 -1
  25. package/dist/src/signer/signer.js +8 -3
  26. package/dist/src/transaction/index.d.ts +0 -1
  27. package/dist/src/transaction/index.js +5 -2
  28. package/dist/src/utils/index.d.ts +0 -1
  29. package/dist/src/utils/index.js +5 -2
  30. package/dist/src/utils/subscription.d.ts +0 -1
  31. package/dist/src/utils/subscription.js +2 -1
  32. package/dist/src/utils/utils.d.ts +5 -4
  33. package/dist/src/utils/utils.js +17 -16
  34. package/jest-config.json +11 -0
  35. package/package.json +6 -34
  36. package/scripts/create-project.ts +3 -2
  37. package/src/api/api-alephium.ts +53 -5
  38. package/src/api/index.ts +13 -3
  39. package/src/contract/contract.ts +505 -318
  40. package/src/contract/events.ts +2 -2
  41. package/src/{transaction/sign-verify.ts → global.ts} +14 -15
  42. package/src/index.ts +3 -0
  43. package/src/signer/index.ts +0 -1
  44. package/src/signer/signer.ts +3 -2
  45. package/src/transaction/index.ts +0 -1
  46. package/src/transaction/status.ts +1 -1
  47. package/src/utils/index.ts +0 -1
  48. package/src/utils/subscription.ts +3 -3
  49. package/src/utils/utils.ts +10 -10
  50. package/templates/base/package.json +2 -2
  51. package/templates/base/src/greeter.ts +8 -7
  52. package/templates/react/package.json +2 -2
  53. package/templates/react/src/App.tsx +2 -2
  54. package/.eslintrc.json +0 -21
  55. package/LICENSE +0 -165
  56. package/contracts/add/add.ral +0 -16
  57. package/contracts/main.ral +0 -6
  58. package/contracts/sub/sub.ral +0 -9
  59. package/dist/src/signer/node-wallet.d.ts +0 -13
  60. package/dist/src/signer/node-wallet.js +0 -60
  61. package/dist/src/test/index.d.ts +0 -7
  62. package/dist/src/test/index.js +0 -41
  63. package/dist/src/test/privatekey-wallet.d.ts +0 -12
  64. package/dist/src/test/privatekey-wallet.js +0 -68
  65. package/dist/src/transaction/sign-verify.d.ts +0 -2
  66. package/dist/src/transaction/sign-verify.js +0 -58
  67. package/dist/src/utils/password-crypto.d.ts +0 -2
  68. package/dist/src/utils/password-crypto.js +0 -69
  69. package/gitignore +0 -10
  70. package/src/contract/ralph.test.ts +0 -178
  71. package/src/fixtures/address.json +0 -36
  72. package/src/fixtures/balance.json +0 -9
  73. package/src/fixtures/self-clique.json +0 -19
  74. package/src/fixtures/transaction.json +0 -13
  75. package/src/fixtures/transactions.json +0 -179
  76. package/src/signer/fixtures/genesis.json +0 -26
  77. package/src/signer/fixtures/wallets.json +0 -26
  78. package/src/signer/node-wallet.ts +0 -74
  79. package/src/test/index.ts +0 -32
  80. package/src/test/privatekey-wallet.ts +0 -58
  81. package/src/transaction/sign-verify.test.ts +0 -50
  82. package/src/utils/address.test.ts +0 -47
  83. package/src/utils/djb2.test.ts +0 -35
  84. package/src/utils/password-crypto.test.ts +0 -27
  85. package/src/utils/password-crypto.ts +0 -77
  86. package/src/utils/utils.test.ts +0 -161
  87. package/test/contract.test.ts +0 -178
  88. package/test/events.test.ts +0 -138
  89. package/test/transaction.test.ts +0 -72
@@ -1,41 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
27
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.testWallet = exports.testPassword = exports.testAddress = exports.testWalletName = void 0;
31
- const signer_1 = require("../signer");
32
- exports.testWalletName = 'alephium-web3-test-only-wallet';
33
- exports.testAddress = '1DrDyTr9RpRsQnDnXo2YRiPzPW4ooHX5LLoqXrqfMrpQH';
34
- exports.testPassword = 'alph';
35
- async function testWallet(provider) {
36
- const wallet = new signer_1.NodeWallet(provider, exports.testWalletName);
37
- await wallet.unlock(exports.testPassword);
38
- return wallet;
39
- }
40
- exports.testWallet = testWallet;
41
- __exportStar(require("./privatekey-wallet"), exports);
@@ -1,12 +0,0 @@
1
- import { NodeProvider } from '../api';
2
- import { Account, SignerWithNodeProvider } from '../signer';
3
- export declare class PrivateKeyWallet extends SignerWithNodeProvider {
4
- readonly privateKey: string;
5
- readonly publicKey: string;
6
- readonly address: string;
7
- readonly group: number;
8
- constructor(provider: NodeProvider, privateKey: string, alwaysSubmitTx?: boolean);
9
- static Random(provider: NodeProvider, alwaysSubmitTx?: boolean): PrivateKeyWallet;
10
- getAccounts(): Promise<Account[]>;
11
- signRaw(signerAddress: string, hexString: string): Promise<string>;
12
- }
@@ -1,68 +0,0 @@
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.PrivateKeyWallet = void 0;
40
- const elliptic_1 = require("elliptic");
41
- const signer_1 = require("../signer");
42
- const utils = __importStar(require("../utils"));
43
- const ec = new elliptic_1.ec('secp256k1');
44
- class PrivateKeyWallet extends signer_1.SignerWithNodeProvider {
45
- constructor(provider, privateKey, alwaysSubmitTx = true) {
46
- super(provider, alwaysSubmitTx);
47
- this.privateKey = privateKey;
48
- this.publicKey = utils.publicKeyFromPrivateKey(privateKey);
49
- this.address = utils.addressFromPublicKey(this.publicKey);
50
- this.group = utils.groupOfAddress(this.address);
51
- }
52
- static Random(provider, alwaysSubmitTx = true) {
53
- const keyPair = ec.genKeyPair();
54
- return new PrivateKeyWallet(provider, keyPair.getPrivate().toString('hex'), alwaysSubmitTx);
55
- }
56
- async getAccounts() {
57
- return [{ address: this.address, publicKey: this.publicKey, group: this.group }];
58
- }
59
- async signRaw(signerAddress, hexString) {
60
- if (signerAddress !== this.address) {
61
- throw Error('Unmatched signer address');
62
- }
63
- const key = ec.keyFromPrivate(this.privateKey);
64
- const signature = key.sign(hexString);
65
- return utils.signatureEncode(signature);
66
- }
67
- }
68
- exports.PrivateKeyWallet = PrivateKeyWallet;
@@ -1,2 +0,0 @@
1
- export declare function transactionSign(txHash: string, privateKey: string): string;
2
- export declare function transactionVerifySignature(txHash: string, publicKey: string, signature: string): boolean;
@@ -1,58 +0,0 @@
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.transactionVerifySignature = exports.transactionSign = void 0;
40
- const elliptic_1 = require("elliptic");
41
- const utils = __importStar(require("../utils"));
42
- const ec = new elliptic_1.ec('secp256k1');
43
- function transactionSign(txHash, privateKey) {
44
- const keyPair = ec.keyFromPrivate(privateKey);
45
- const signature = keyPair.sign(txHash);
46
- return utils.signatureEncode(signature);
47
- }
48
- exports.transactionSign = transactionSign;
49
- function transactionVerifySignature(txHash, publicKey, signature) {
50
- try {
51
- const key = ec.keyFromPublic(publicKey, 'hex');
52
- return key.verify(txHash, utils.signatureDecode(ec, signature));
53
- }
54
- catch (error) {
55
- return false;
56
- }
57
- }
58
- exports.transactionVerifySignature = transactionVerifySignature;
@@ -1,2 +0,0 @@
1
- export declare const encrypt: (password: string, dataRaw: string) => string;
2
- export declare const decrypt: (password: string, payloadRaw: string) => string;
@@ -1,69 +0,0 @@
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.decrypt = exports.encrypt = void 0;
21
- const buffer_1 = require("buffer/");
22
- const crypto_1 = require("crypto");
23
- const saltByteLength = 64;
24
- const ivByteLength = 64;
25
- const authTagLength = 16;
26
- const encrypt = (password, dataRaw) => {
27
- const data = buffer_1.Buffer.from(dataRaw, 'utf8');
28
- const salt = (0, crypto_1.randomBytes)(saltByteLength);
29
- const derivedKey = keyFromPassword(password, salt);
30
- const iv = (0, crypto_1.randomBytes)(ivByteLength);
31
- const cipher = createCipher(derivedKey, iv);
32
- const encrypted = buffer_1.Buffer.concat([cipher.update(data), cipher.final()]);
33
- const authTag = cipher.getAuthTag();
34
- const payload = {
35
- salt: salt.toString('hex'),
36
- iv: iv.toString('hex'),
37
- encrypted: buffer_1.Buffer.concat([encrypted, authTag]).toString('hex'),
38
- version: 1
39
- };
40
- return JSON.stringify(payload);
41
- };
42
- exports.encrypt = encrypt;
43
- const decrypt = (password, payloadRaw) => {
44
- const payload = JSON.parse(payloadRaw);
45
- const version = payload.version;
46
- if (version !== 1) {
47
- throw new Error(`Invalid version: got ${version}, expected: 1`);
48
- }
49
- const salt = buffer_1.Buffer.from(payload.salt, 'hex');
50
- const iv = buffer_1.Buffer.from(payload.iv, 'hex');
51
- const encrypted = buffer_1.Buffer.from(payload.encrypted, 'hex');
52
- const derivedKey = keyFromPassword(password, salt);
53
- const decipher = createDecipher(derivedKey, iv);
54
- const data = encrypted.slice(0, encrypted.length - authTagLength);
55
- const authTag = encrypted.slice(encrypted.length - authTagLength, encrypted.length);
56
- decipher.setAuthTag(authTag);
57
- const decrypted = buffer_1.Buffer.concat([decipher.update(data), decipher.final()]);
58
- return decrypted.toString('utf8');
59
- };
60
- exports.decrypt = decrypt;
61
- const createCipher = (key, iv) => {
62
- return (0, crypto_1.createCipheriv)('aes-256-gcm', key, iv);
63
- };
64
- const createDecipher = (key, iv) => {
65
- return (0, crypto_1.createDecipheriv)('aes-256-gcm', key, iv);
66
- };
67
- const keyFromPassword = (password, salt) => {
68
- return (0, crypto_1.pbkdf2Sync)(password, salt, 10000, 32, 'sha256');
69
- };
package/gitignore DELETED
@@ -1,10 +0,0 @@
1
- node_modules/
2
- dist/
3
- build/
4
- web/
5
- .vscode
6
- .DS_Store
7
- coverage/
8
- /dev/
9
- !dev/user.conf
10
- /artifacts/
@@ -1,178 +0,0 @@
1
- /*
2
- Copyright 2018 - 2022 The Alephium Authors
3
- This file is part of the alephium project.
4
-
5
- The library is free software: you can redistribute it and/or modify
6
- it under the terms of the GNU Lesser General Public License as published by
7
- the Free Software Foundation, either version 3 of the License, or
8
- (at your option) any later version.
9
-
10
- The library is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU Lesser General Public License for more details.
14
-
15
- You should have received a copy of the GNU Lesser General Public License
16
- along with the library. If not, see <http://www.gnu.org/licenses/>.
17
- */
18
-
19
- import { node } from '../api'
20
- import * as ralph from './ralph'
21
- import * as utils from '../utils'
22
- import { Fields } from './contract'
23
-
24
- describe('contract', function () {
25
- it('should encode I256', async () => {
26
- function test(i256: bigint, expected: string) {
27
- expect(utils.binToHex(ralph.encodeI256(i256))).toEqual(expected)
28
- }
29
- test(BigInt('0'), '00')
30
- test(BigInt('1'), '01')
31
- test(BigInt('2'), '02')
32
- test(BigInt('-1'), '3f')
33
- test(BigInt('-2'), '3e')
34
- test(BigInt('32'), '4020')
35
- test(BigInt('33'), '4021')
36
- test(BigInt('34'), '4022')
37
- test(BigInt('31'), '1f')
38
- test(BigInt('30'), '1e')
39
- test(BigInt('8192'), '80002000')
40
- test(BigInt('8193'), '80002001')
41
- test(BigInt('8194'), '80002002')
42
- test(BigInt('8191'), '5fff')
43
- test(BigInt('8190'), '5ffe')
44
- test(BigInt('536870912'), 'c020000000')
45
- test(BigInt('536870913'), 'c020000001')
46
- test(BigInt('536870914'), 'c020000002')
47
- test(BigInt('536870911'), '9fffffff')
48
- test(BigInt('536870910'), '9ffffffe')
49
- test(
50
- BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819967'),
51
- 'dc7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
52
- )
53
- test(
54
- BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819966'),
55
- 'dc7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe'
56
- )
57
- test(
58
- BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819965'),
59
- 'dc7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'
60
- )
61
- test(
62
- BigInt('-57896044618658097711785492504343953926634992332820282019728792003956564819968'),
63
- 'dc8000000000000000000000000000000000000000000000000000000000000000'
64
- )
65
- test(
66
- BigInt('-57896044618658097711785492504343953926634992332820282019728792003956564819967'),
67
- 'dc8000000000000000000000000000000000000000000000000000000000000001'
68
- )
69
- test(
70
- BigInt('-57896044618658097711785492504343953926634992332820282019728792003956564819966'),
71
- 'dc8000000000000000000000000000000000000000000000000000000000000002'
72
- )
73
-
74
- function fail(n: bigint) {
75
- expect(() => ralph.encodeI256(n)).toThrow()
76
- }
77
- fail(BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819968'))
78
- fail(BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819969'))
79
- fail(BigInt('-57896044618658097711785492504343953926634992332820282019728792003956564819969'))
80
- fail(BigInt('-57896044618658097711785492504343953926634992332820282019728792003956564819970'))
81
- })
82
-
83
- it('should encode U256', async () => {
84
- function test(u256: bigint, expected: string) {
85
- expect(utils.binToHex(ralph.encodeU256(u256))).toEqual(expected)
86
- }
87
- test(BigInt('0'), '00')
88
- test(BigInt('1'), '01')
89
- test(BigInt('2'), '02')
90
- fail(BigInt('-1'))
91
- fail(BigInt('-2'))
92
- test(BigInt('64'), '4040')
93
- test(BigInt('65'), '4041')
94
- test(BigInt('66'), '4042')
95
- test(BigInt('63'), '3f')
96
- test(BigInt('62'), '3e')
97
- test(BigInt('16384'), '80004000')
98
- test(BigInt('16385'), '80004001')
99
- test(BigInt('16386'), '80004002')
100
- test(BigInt('16383'), '7fff')
101
- test(BigInt('16382'), '7ffe')
102
- test(BigInt('1073741824'), 'c040000000')
103
- test(BigInt('1073741825'), 'c040000001')
104
- test(BigInt('1073741826'), 'c040000002')
105
- test(BigInt('1073741823'), 'bfffffff')
106
- test(BigInt('1073741822'), 'bffffffe')
107
- test(
108
- BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639935'),
109
- 'dcffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
110
- )
111
- test(
112
- BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639934'),
113
- 'dcfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe'
114
- )
115
- test(
116
- BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639933'),
117
- 'dcfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'
118
- )
119
-
120
- function fail(n: bigint) {
121
- expect(() => ralph.encodeU256(n)).toThrow()
122
- }
123
- fail(BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639936'))
124
- fail(BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639937'))
125
- })
126
-
127
- it('should encode ByteVec', async () => {
128
- const bytes = 'b382fc88aa31d63f4c2f3f8a03715ba2a629552e85431fb1c1d909bab46d1aae'
129
- const bytecode = ralph.encodeScriptFieldAsString('ByteVec', bytes)
130
- expect(bytecode).toEqual('144020b382fc88aa31d63f4c2f3f8a03715ba2a629552e85431fb1c1d909bab46d1aae')
131
- })
132
-
133
- it('should test buildScriptByteCode', async () => {
134
- const variables = { x: true, y: 0x05, z: 'ff', a: '1C2RAVWSuaXw8xtUxqVERR7ChKBE1XgscNFw73NSHE1v3' }
135
- const fieldsSig: node.FieldsSig = {
136
- signature: 'Not really',
137
- names: ['x', 'y', 'z', 'a'],
138
- types: ['Bool', 'U256', 'ByteVec', 'Address']
139
- }
140
- const bytecode = ralph.buildScriptByteCode('-{0}-{1}-{2}-{3}-', variables, fieldsSig)
141
- expect(bytecode).toEqual('-03-1305-1401ff-1500a3cd757be03c7dac8d48bf79e2a7d6e735e018a9c054b99138c7b29738c437ec-')
142
- })
143
-
144
- it('should test buildContractByteCode', async () => {
145
- const fields: Fields = {
146
- a: -1,
147
- b: 1,
148
- c: '23',
149
- d: '1C2RAVWSuaXw8xtUxqVERR7ChKBE1XgscNFw73NSHE1v3',
150
- e: [false, true]
151
- }
152
- const fieldsSig: node.FieldsSig = {
153
- signature: 'Not really',
154
- names: ['a', 'b', 'c', 'd', 'e'],
155
- types: ['I256', 'U256', 'ByteVec', 'Address', '[Bool;2]']
156
- }
157
- const encoded = ralph.buildContractByteCode('ff', fields, fieldsSig)
158
- expect(encoded).toEqual(
159
- 'ff06013f02010301230400a3cd757be03c7dac8d48bf79e2a7d6e735e018a9c054b99138c7b29738c437ec00000001'
160
- )
161
- })
162
-
163
- // it('should test buildByteCode', async () => {
164
- // const compiled = {
165
- // type: 'TemplateContractByteCode',
166
- // filedLength: 1,
167
- // methodsByteCode: [
168
- // '01000203021205160016015f{subContractId:ByteVec}1702a00016002a16012aa100a000160016011602010002',
169
- // '00000202020416001601000002'
170
- // ]
171
- // }
172
- // const variables = { subContractId: '55834baf25f40fe5a8d6ac83c5f2b76a1677ed3ddbd6a79c4dea274992982e2b' }
173
- // const bytecode = ralph.buildContractByteCode(compiled, variables)
174
- // expect(bytecode).toEqual(
175
- // '01024046405301000203021205160016015f14402055834baf25f40fe5a8d6ac83c5f2b76a1677ed3ddbd6a79c4dea274992982e2b1702a00016002a16012aa100a00016001601160201000200000202020416001601000002'
176
- // )
177
- // })
178
- })
@@ -1,36 +0,0 @@
1
- {
2
- "hash": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
3
- "details": {
4
- "balance": "string",
5
- "txNumber": 0
6
- },
7
- "transactions": [
8
- {
9
- "hash": "string",
10
- "blockHash": "string",
11
- "timestamp": 0,
12
- "inputs": [
13
- {
14
- "outputRef": {
15
- "hint": 0,
16
- "key": "string"
17
- },
18
- "unlockScript": "string",
19
- "txHashRef": "string",
20
- "address": "string",
21
- "amount": "string"
22
- }
23
- ],
24
- "outputs": [
25
- {
26
- "amount": "string",
27
- "address": "string",
28
- "lockTime": 0,
29
- "spent": "string"
30
- }
31
- ],
32
- "gasAmount": 0,
33
- "gasPrice": "string"
34
- }
35
- ]
36
- }
@@ -1,9 +0,0 @@
1
- {
2
- "data": {
3
- "balance": "0",
4
- "balanceHint": "0 ALPH",
5
- "lockedBalance": "0",
6
- "lockedBalanceHint": "0 ALPH",
7
- "utxoNum": 0
8
- }
9
- }
@@ -1,19 +0,0 @@
1
- {
2
- "data": {
3
- "cliqueId": "02f342de9b742719e1e9c939c54a13db5a7e3c4926b04428cbc45d70f8e6bcef4d",
4
- "networkId": 0,
5
- "numZerosAtLeastInHash": 37,
6
- "nodes": [
7
- {
8
- "address": "127.0.0.1",
9
- "restPort": 12973,
10
- "wsPort": 11973,
11
- "minerApiPort": 10973
12
- }
13
- ],
14
- "selfReady": true,
15
- "synced": true,
16
- "groupNumPerBroker": 4,
17
- "groups": 4
18
- }
19
- }
@@ -1,13 +0,0 @@
1
- {
2
- "created": {
3
- "unsignedTx": "0ecd20654c2e2be708495853e8da35c664247040c00bd10b9b13",
4
- "txId": "798e9e137aec7c2d59d9655b4ffa640f301f628bf7c365083bb255f6aa5f89ef",
5
- "fromGroup": 2,
6
- "toGroup": 1
7
- },
8
- "submitted": {
9
- "txId": "503bfb16230888af4924aa8f8250d7d348b862e267d75d3147f1998050b6da69",
10
- "fromGroup": 2,
11
- "toGroup": 1
12
- }
13
- }