@alephium/web3 0.2.0-rc.5 → 0.2.0-rc.8
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/contracts/greeter/greeter.ral +1 -1
- 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/scripts/create-project.js +1 -1
- package/dist/src/api/api-alephium.d.ts +19 -6
- package/dist/src/api/api-explorer.d.ts +16 -16
- package/dist/src/api/index.js +5 -1
- package/dist/src/contract/contract.d.ts +30 -8
- package/dist/src/contract/contract.js +105 -58
- package/dist/src/contract/index.js +5 -1
- package/dist/src/global.d.ts +3 -0
- package/{src/utils/djb2.test.ts → dist/src/global.js} +20 -17
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +20 -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 +1 -1
- package/dist/src/signer/signer.js +8 -3
- package/dist/src/transaction/index.d.ts +0 -1
- package/dist/src/transaction/index.js +5 -2
- 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 -1
- package/dist/src/utils/subscription.js +2 -1
- package/dist/src/utils/utils.d.ts +3 -2
- package/dist/src/utils/utils.js +16 -15
- package/jest-config.json +11 -0
- package/package.json +6 -32
- package/scripts/create-project.ts +1 -1
- package/src/api/api-alephium.ts +14 -0
- package/src/contract/contract.ts +161 -65
- package/src/{test/index.ts → global.ts} +14 -10
- package/src/index.ts +3 -0
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +3 -2
- package/src/transaction/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/subscription.ts +2 -2
- package/src/utils/utils.ts +7 -7
- package/templates/base/package.json +2 -2
- package/templates/base/src/greeter.ts +8 -7
- package/templates/react/package.json +2 -2
- package/templates/react/src/App.tsx +2 -2
- package/.eslintrc.json +0 -21
- package/LICENSE +0 -165
- package/contracts/add/add.ral +0 -15
- package/contracts/main.ral +0 -4
- package/contracts/sub/sub.ral +0 -10
- package/contracts/test/metadata.ral +0 -18
- package/contracts/test/warnings.ral +0 -8
- package/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 -9
- 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/privatekey-wallet.ts +0 -58
- package/src/transaction/sign-verify.test.ts +0 -50
- package/src/transaction/sign-verify.ts +0 -39
- package/src/utils/address.test.ts +0 -47
- package/src/utils/password-crypto.test.ts +0 -27
- package/src/utils/password-crypto.ts +0 -77
- package/src/utils/utils.test.ts +0 -161
- package/test/contract.test.ts +0 -213
- package/test/events.test.ts +0 -143
- package/test/transaction.test.ts +0 -74
|
@@ -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
|
-
names: ['x', 'y', 'z', 'a'],
|
|
137
|
-
types: ['Bool', 'U256', 'ByteVec', 'Address'],
|
|
138
|
-
isMutable: [false, false, false, false]
|
|
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
|
-
names: ['a', 'b', 'c', 'd', 'e'],
|
|
154
|
-
types: ['I256', 'U256', 'ByteVec', 'Address', '[Bool;2]'],
|
|
155
|
-
isMutable: [false, false, false, false]
|
|
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,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
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"oneInputOneOutput": {
|
|
3
|
-
"hash": "c99559da00e05bf967227c452f9dc33904cc8aac9819f71ca9b3382d037317c1",
|
|
4
|
-
"blockHash": "000000000000d3a4088bd4a177dd4c99f8df7642e095dd6f375d99d3a4a2760a",
|
|
5
|
-
"timestamp": 1639679587756,
|
|
6
|
-
"inputs": [
|
|
7
|
-
{
|
|
8
|
-
"outputRef": {
|
|
9
|
-
"hint": 269352581,
|
|
10
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
11
|
-
},
|
|
12
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
13
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
14
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
15
|
-
"amount": "100000000000000000000"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"outputs": [
|
|
19
|
-
{
|
|
20
|
-
"hint": 1770492891,
|
|
21
|
-
"key": "685eedf4a7eef2cccd55dfcc0d7d72c2aef788b118236d2dc8b27d924206da9d",
|
|
22
|
-
"amount": "409200570768056060",
|
|
23
|
-
"address": "1D3cMU5kaHmm8rnhF5ZErqErnRgp5xopDheubHVUizWA2",
|
|
24
|
-
"spent": "4d8e564e1731ecc09e167211c25da7b91a3fab8096a951a0df3b7ce1549d6cd9"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"hint": 269352581,
|
|
28
|
-
"key": "162784ca82a5dfc796bc6514658453e51aacdb48ed7bec716850152a61b55b82",
|
|
29
|
-
"amount": "50000000000000000000",
|
|
30
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
31
|
-
"spent": "f823bcb78fbbc6c18dea882fe697cb8be9c5e2cb020e65670041dbe39b80c3d8"
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"gasAmount": 68060,
|
|
35
|
-
"gasPrice": "100000000000"
|
|
36
|
-
},
|
|
37
|
-
"twoInputsOneOutput": {
|
|
38
|
-
"hash": "c99559da00e05bf967227c452f9dc33904cc8aac9819f71ca9b3382d037317c1",
|
|
39
|
-
"blockHash": "000000000000d3a4088bd4a177dd4c99f8df7642e095dd6f375d99d3a4a2760a",
|
|
40
|
-
"timestamp": 1639679587756,
|
|
41
|
-
"inputs": [
|
|
42
|
-
{
|
|
43
|
-
"outputRef": {
|
|
44
|
-
"hint": 269352581,
|
|
45
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
46
|
-
},
|
|
47
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
48
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
49
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
50
|
-
"amount": "100000000000000000000"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"outputRef": {
|
|
54
|
-
"hint": 269352581,
|
|
55
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
56
|
-
},
|
|
57
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
58
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
59
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
60
|
-
"amount": "100000000000000000000"
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"outputs": [
|
|
64
|
-
{
|
|
65
|
-
"hint": 1770492891,
|
|
66
|
-
"key": "685eedf4a7eef2cccd55dfcc0d7d72c2aef788b118236d2dc8b27d924206da9d",
|
|
67
|
-
"amount": "150000000000000000000",
|
|
68
|
-
"address": "1D3cMU5kaHmm8rnhF5ZErqErnRgp5xopDheubHVUizWA2",
|
|
69
|
-
"spent": "4d8e564e1731ecc09e167211c25da7b91a3fab8096a951a0df3b7ce1549d6cd9"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"hint": 269352581,
|
|
73
|
-
"key": "162784ca82a5dfc796bc6514658453e51aacdb48ed7bec716850152a61b55b82",
|
|
74
|
-
"amount": "50000000000000000000",
|
|
75
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
76
|
-
"spent": "f823bcb78fbbc6c18dea882fe697cb8be9c5e2cb020e65670041dbe39b80c3d8"
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
"gasAmount": 68060,
|
|
80
|
-
"gasPrice": "100000000000"
|
|
81
|
-
},
|
|
82
|
-
"twoInputsZeroOutput": {
|
|
83
|
-
"hash": "c99559da00e05bf967227c452f9dc33904cc8aac9819f71ca9b3382d037317c1",
|
|
84
|
-
"blockHash": "000000000000d3a4088bd4a177dd4c99f8df7642e095dd6f375d99d3a4a2760a",
|
|
85
|
-
"timestamp": 1639679587756,
|
|
86
|
-
"inputs": [
|
|
87
|
-
{
|
|
88
|
-
"outputRef": {
|
|
89
|
-
"hint": 269352581,
|
|
90
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
91
|
-
},
|
|
92
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
93
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
94
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
95
|
-
"amount": "100000000000000000000"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"outputRef": {
|
|
99
|
-
"hint": 269352581,
|
|
100
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
101
|
-
},
|
|
102
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
103
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
104
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
105
|
-
"amount": "100000000000000000000"
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
"outputs": [
|
|
109
|
-
{
|
|
110
|
-
"hint": 1770492891,
|
|
111
|
-
"key": "685eedf4a7eef2cccd55dfcc0d7d72c2aef788b118236d2dc8b27d924206da9d",
|
|
112
|
-
"amount": "150000000000000000000",
|
|
113
|
-
"address": "1D3cMU5kaHmm8rnhF5ZErqErnRgp5xopDheubHVUizWA2",
|
|
114
|
-
"spent": "4d8e564e1731ecc09e167211c25da7b91a3fab8096a951a0df3b7ce1549d6cd9"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"hint": 269352581,
|
|
118
|
-
"key": "162784ca82a5dfc796bc6514658453e51aacdb48ed7bec716850152a61b55b82",
|
|
119
|
-
"amount": "50000000000000000000",
|
|
120
|
-
"address": "1D3cMU5kaHmm8rnhF5ZErqErnRgp5xopDheubHVUizWA3",
|
|
121
|
-
"spent": "f823bcb78fbbc6c18dea882fe697cb8be9c5e2cb020e65670041dbe39b80c3d8"
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
"gasAmount": 68060,
|
|
125
|
-
"gasPrice": "100000000000"
|
|
126
|
-
},
|
|
127
|
-
"missingInputs": {
|
|
128
|
-
"hash": "c99559da00e05bf967227c452f9dc33904cc8aac9819f71ca9b3382d037317c1",
|
|
129
|
-
"blockHash": "000000000000d3a4088bd4a177dd4c99f8df7642e095dd6f375d99d3a4a2760a",
|
|
130
|
-
"timestamp": 1639679587756,
|
|
131
|
-
"outputs": [
|
|
132
|
-
{
|
|
133
|
-
"hint": 1770492891,
|
|
134
|
-
"key": "685eedf4a7eef2cccd55dfcc0d7d72c2aef788b118236d2dc8b27d924206da9d",
|
|
135
|
-
"amount": "150000000000000000000",
|
|
136
|
-
"address": "1D3cMU5kaHmm8rnhF5ZErqErnRgp5xopDheubHVUizWA2",
|
|
137
|
-
"spent": "4d8e564e1731ecc09e167211c25da7b91a3fab8096a951a0df3b7ce1549d6cd9"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"hint": 269352581,
|
|
141
|
-
"key": "162784ca82a5dfc796bc6514658453e51aacdb48ed7bec716850152a61b55b82",
|
|
142
|
-
"amount": "50000000000000000000",
|
|
143
|
-
"address": "1D3cMU5kaHmm8rnhF5ZErqErnRgp5xopDheubHVUizWA3",
|
|
144
|
-
"spent": "f823bcb78fbbc6c18dea882fe697cb8be9c5e2cb020e65670041dbe39b80c3d8"
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
"gasAmount": 68060,
|
|
148
|
-
"gasPrice": "100000000000"
|
|
149
|
-
},
|
|
150
|
-
"missingOutputs": {
|
|
151
|
-
"hash": "c99559da00e05bf967227c452f9dc33904cc8aac9819f71ca9b3382d037317c1",
|
|
152
|
-
"blockHash": "000000000000d3a4088bd4a177dd4c99f8df7642e095dd6f375d99d3a4a2760a",
|
|
153
|
-
"timestamp": 1639679587756,
|
|
154
|
-
"inputs": [
|
|
155
|
-
{
|
|
156
|
-
"outputRef": {
|
|
157
|
-
"hint": 269352581,
|
|
158
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
159
|
-
},
|
|
160
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
161
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
162
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
163
|
-
"amount": "100000000000000000000"
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
"outputRef": {
|
|
167
|
-
"hint": 269352581,
|
|
168
|
-
"key": "25abffce393aea71c3acf15c701ada53d69ccb4361d28f4b980560bca3303864"
|
|
169
|
-
},
|
|
170
|
-
"unlockScript": "00026e6e0839c322d59b54feb6501b207b8439ada411839268a5842e298acf8608d5",
|
|
171
|
-
"txHashRef": "1bd6040d255021cb4a551644f343344a2f1f0f32093244cbb273f6cdef55567f",
|
|
172
|
-
"address": "16sR3EMn2BdFgENRhz6N2TJ78nfaADdv3prKXUQMaB6m3",
|
|
173
|
-
"amount": "100000000000000000000"
|
|
174
|
-
}
|
|
175
|
-
],
|
|
176
|
-
"gasAmount": 68060,
|
|
177
|
-
"gasPrice": "100000000000"
|
|
178
|
-
}
|
|
179
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"address": "19XWyoWy6DjrRp7erWqPfBnh7HL1Sb2Ub8SVjux2d71Eb",
|
|
4
|
-
"pubKey": "03d3400977a9dabf737714ce672dd60e3e74afc7f9d61fa6a6d74f3e2909f7dc00",
|
|
5
|
-
"priKey": "fff733a4e95a5366625610e30d942587168130f82785c3609d92ae84c149e05e",
|
|
6
|
-
"mnemonic": "space window beach above tiger attract barrel noodle autumn grain update either twelve security shoe teach quote flip reflect maple bike polar ivory gadget"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"address": "1CsutTzw8WVhqr1PB6F1tYinuLihAsAm9FxE7rVkC3Z2u",
|
|
10
|
-
"pubKey": "02b3a0175856c1ac653720cc05eeb84263ec2036e9eeced748e8d643a8607901ae",
|
|
11
|
-
"priKey": "f004e2a5b9435531adef0954ce4106a494731379ee626365907d4e3ac639e9c6",
|
|
12
|
-
"mnemonic": "length hazard scene rabbit tiny soup page almost argue helmet cliff soap then bean artist teach guess sense dose near topic dinner option isolate"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"address": "1CwD52BrUj9e4WDJSZ7RXLU2A8us4ZFSmYBDKu98p7szi",
|
|
16
|
-
"pubKey": "03372b642615c8f32a4af2ca318bc5fc471828428dbc11e29d1a816d0d208d217d",
|
|
17
|
-
"priKey": "7ed7be6e1ba50c217b06f70a0b1e26e844907b3dec2e479ff5d206ad62a073e9",
|
|
18
|
-
"mnemonic": "head add industry horn prepare green budget divide attack reason finish purse flip congress book allow message salute turkey video quote pulse present private"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"address": "1BHSQ8JMeYHZe2kj3KmLjuQCSM3mvzYjNutz14uRPbxZM",
|
|
22
|
-
"pubKey": "02ea6e8cf78e57d4ab758ded570e1a6cd721e6586f34a1200f55a3d3c2a1b0374f",
|
|
23
|
-
"priKey": "7ced95c635863187db397d1b6406497654d27202e9b69edf9ae7f23ab346984b",
|
|
24
|
-
"mnemonic": "lottery mystery chase fatal rural snake moral cricket cash south pitch enlist loyal point turkey rally journey earth rifle deputy metal arm hospital tree"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"wallets": [
|
|
3
|
-
{
|
|
4
|
-
"mnemonic": "scan pause slender around cube flavor neck shrug gadget ramp rude lend capable tone nose unhappy gift across cluster minor tragic fever detail script",
|
|
5
|
-
"seed": "f585d130dd79d3b5bd63aa99d9bc6e6107cfbbe393b86d70e865f6e75c60a37496afc1b25cd4d1ab3b82d9b41f469c6c112a9f310e441814147ff27a5d65882b",
|
|
6
|
-
"password": "36ae0b75ef06d2e902e473c879c6e853193760ffa5dc29dc8da76133149e0892",
|
|
7
|
-
"file": {
|
|
8
|
-
"encrypted": "b686b4fff0c97e7fcacfd47babccf3ebac60c65035ed1370741424b3de5dbb75d87ac7f7bc0a2309725ec3370c53cd0bc705e3d1e919cdbad539d334398498d29b97689b37c9447b4aaeef3b99d11cadb85028ece6baa62fe74750a26d02f06a71b8e2ff69e112d78999c7f787a7029120bc25ad28e2acfaf4f088b30fea2973e30bd3ced24880a610c121ceddab4e271c17d6dcd0bcec7e6aff921c9409a0bb2e478a5028f1aacc70c72ee7fc64ebc58b4e63db",
|
|
9
|
-
"salt": "fd90b530931ad2fc9a195b719c7f1ecea8519e49a5e9b96d527c87549445c587dd34385f28446b570062286e79600430d190a885198b224e1b10678a0cd6648b",
|
|
10
|
-
"iv": "620bec5b5c612ac5f1f82b529dbdb818ba78c0d5e298a08d4ed9ea63a0bf762ca54414d12bd312e101d16ef95350c46b5ea18cf78d83ed025d5a400406bcdf70",
|
|
11
|
-
"version": 1
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"mnemonic": "fence motor uncle pass zero curve garlic match palm kingdom quality keep undo scissors host lend ginger human loop mad sting horse swap track",
|
|
16
|
-
"seed": "f346de0a6cb3c8f50eb651ed4f17d572f7184813d3366215b4a1a61d7c776bedca41373d9008176bac8cb2ff8216d5cc3542f37fd520b4938295ca85013dbb3c",
|
|
17
|
-
"password": "36ae0b75ef06d2e902e473c879c6e853193760ffa5dc29dc8da76133149e0892",
|
|
18
|
-
"file": {
|
|
19
|
-
"encrypted": "d908a9e2816be754f17b4e80789546783d9e4538240e6585fda17c16343569d03aaac0a10c61122e23d9aa1c988f55d9e88b4d7b271e1f631e8aee02d5dc9e077e6150732381ec06c6f18d4fdde7ed3e09494762d002232a12fbcb5d1f0ca9ac3e6d964d3eb06ed530b10b8b151a66e2ea1eb4e60241b24c631edb31aa7ae99cf5c7f74692f39c534e7deee4e168375da2e6b93b7236fdfcafaade2d2e641498e61888b16d05147a43bb8024",
|
|
20
|
-
"salt": "e30c12732903502d8257cec78c3a1d25b29cd77a45378c43d4c9aed0386fd3c278149354221bdcf18e156d6384f1cb20c120975957f37fa433526f516528d597",
|
|
21
|
-
"iv": "d28a2821343d525a5afc8a17167e0e7f52a7dbc36dcbfbc95819c7f33afd5c6a1cc97a65a2b2bc95387b220a2e9fda7237bd897dfd59ab98e9a7add0c5eeab30",
|
|
22
|
-
"version": 1
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,74 +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 { NodeProvider } from '../api'
|
|
20
|
-
import { Account, SignerWithNodeProvider } from '../signer'
|
|
21
|
-
|
|
22
|
-
export class NodeWallet extends SignerWithNodeProvider {
|
|
23
|
-
public walletName: string
|
|
24
|
-
public accounts: Account[] | undefined
|
|
25
|
-
|
|
26
|
-
constructor(provider: NodeProvider, walletName: string, alwaysSubmitTx = true) {
|
|
27
|
-
super(provider, alwaysSubmitTx)
|
|
28
|
-
this.walletName = walletName
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async getAccounts(): Promise<Account[]> {
|
|
32
|
-
if (typeof this.accounts === 'undefined') {
|
|
33
|
-
this.accounts = await this.getAllAccounts()
|
|
34
|
-
}
|
|
35
|
-
return this.accounts
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private async getAllAccounts(): Promise<Account[]> {
|
|
39
|
-
const walletAddresses = await this.provider.wallets.getWalletsWalletNameAddresses(this.walletName)
|
|
40
|
-
const accounts: Account[] = walletAddresses.addresses.map<Account>((acc) => ({
|
|
41
|
-
publicKey: acc.publicKey,
|
|
42
|
-
address: acc.address,
|
|
43
|
-
group: acc.group
|
|
44
|
-
}))
|
|
45
|
-
return accounts
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static async FromCliqueClient(
|
|
49
|
-
provider: NodeProvider,
|
|
50
|
-
walletName: string,
|
|
51
|
-
alwaysSubmitTx = true
|
|
52
|
-
): Promise<NodeWallet> {
|
|
53
|
-
return new NodeWallet(provider, walletName, alwaysSubmitTx)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async signRaw(signerAddress: string, hexString: string): Promise<string> {
|
|
57
|
-
const currentActiveAddressResponse = await this.provider.wallets.getWalletsWalletNameAddresses(this.walletName)
|
|
58
|
-
const { activeAddress } = currentActiveAddressResponse
|
|
59
|
-
await this.provider.wallets.postWalletsWalletNameChangeActiveAddress(this.walletName, { address: signerAddress })
|
|
60
|
-
const { signature } = await this.provider.wallets.postWalletsWalletNameSign(this.walletName, { data: hexString })
|
|
61
|
-
|
|
62
|
-
await this.provider.wallets.postWalletsWalletNameChangeActiveAddress(this.walletName, { address: activeAddress }) // set the address that's active back to previous state
|
|
63
|
-
|
|
64
|
-
return signature
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async unlock(password: string): Promise<void> {
|
|
68
|
-
return await this.provider.wallets.postWalletsWalletNameUnlock(this.walletName, { password })
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async lock(): Promise<void> {
|
|
72
|
-
return await this.provider.wallets.postWalletsWalletNameLock(this.walletName)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,58 +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 { ec as EC } from 'elliptic'
|
|
20
|
-
import { NodeProvider } from '../api'
|
|
21
|
-
import { Account, SignerWithNodeProvider } from '../signer'
|
|
22
|
-
import * as utils from '../utils'
|
|
23
|
-
|
|
24
|
-
const ec = new EC('secp256k1')
|
|
25
|
-
|
|
26
|
-
export class PrivateKeyWallet extends SignerWithNodeProvider {
|
|
27
|
-
readonly privateKey: string
|
|
28
|
-
readonly publicKey: string
|
|
29
|
-
readonly address: string
|
|
30
|
-
readonly group: number
|
|
31
|
-
|
|
32
|
-
constructor(provider: NodeProvider, privateKey: string, alwaysSubmitTx = true) {
|
|
33
|
-
super(provider, alwaysSubmitTx)
|
|
34
|
-
this.privateKey = privateKey
|
|
35
|
-
this.publicKey = utils.publicKeyFromPrivateKey(privateKey)
|
|
36
|
-
this.address = utils.addressFromPublicKey(this.publicKey)
|
|
37
|
-
this.group = utils.groupOfAddress(this.address)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static Random(provider: NodeProvider, alwaysSubmitTx = true): PrivateKeyWallet {
|
|
41
|
-
const keyPair = ec.genKeyPair()
|
|
42
|
-
return new PrivateKeyWallet(provider, keyPair.getPrivate().toString('hex'), alwaysSubmitTx)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async getAccounts(): Promise<Account[]> {
|
|
46
|
-
return [{ address: this.address, publicKey: this.publicKey, group: this.group }]
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async signRaw(signerAddress: string, hexString: string): Promise<string> {
|
|
50
|
-
if (signerAddress !== this.address) {
|
|
51
|
-
throw Error('Unmatched signer address')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const key = ec.keyFromPrivate(this.privateKey)
|
|
55
|
-
const signature = key.sign(hexString)
|
|
56
|
-
return utils.signatureEncode(signature)
|
|
57
|
-
}
|
|
58
|
-
}
|