|
2 | 2 | // This software may be modified and distributed under the terms
|
3 | 3 | // of the ISC license. See the LICENSE file for details.
|
4 | 4 |
|
5 |
| -import hexToU8a from '@polkadot/util/hex/toU8a'; |
6 |
| -import u8aConcat from '@polkadot/util/u8a/concat'; |
7 |
| -import u8aToHex from '@polkadot/util/u8a/toHex'; |
8 |
| - |
9 |
| -import Compact from './codec/Compact'; |
10 | 5 | import Method from './Method';
|
11 | 6 |
|
12 |
| -// A proposal in the system. It contains the same data as an extrinsic, but the encoding |
13 |
| -// does not allow for signatures or versions, only the callindex & parameters required |
| 7 | +// A proposal in the system. It just extends a method (Proposal = Call in Rust) |
14 | 8 | export default class Proposal extends Method {
|
15 |
| - get length (): number { |
16 |
| - return this.toU8a(true).length; |
17 |
| - } |
18 |
| - |
19 |
| - byteLength (): number { |
20 |
| - const length = this.length; |
21 |
| - |
22 |
| - return length + Compact.encode(length).length; |
23 |
| - } |
24 |
| - |
25 |
| - fromJSON (input: any): Proposal { |
26 |
| - super.fromU8a(hexToU8a(input)); |
27 |
| - |
28 |
| - return this; |
29 |
| - } |
30 |
| - |
31 |
| - fromU8a (input: Uint8Array): Proposal { |
32 |
| - const [offset, length] = Compact.decode(input); |
33 |
| - |
34 |
| - super.fromU8a(input.subarray(offset, offset + length.toNumber())); |
35 |
| - |
36 |
| - return this; |
37 |
| - } |
38 |
| - |
39 |
| - toU8a (isBare?: boolean): Uint8Array { |
40 |
| - const encoded = super.toU8a(); |
41 |
| - |
42 |
| - return isBare |
43 |
| - ? encoded |
44 |
| - : u8aConcat( |
45 |
| - Compact.encode(encoded.length), |
46 |
| - encoded |
47 |
| - ); |
48 |
| - } |
49 |
| - |
50 |
| - toHex (): string { |
51 |
| - return u8aToHex(this.toU8a()); |
52 |
| - } |
53 |
| - |
54 |
| - toJSON (): any { |
55 |
| - return this.toHex(); |
56 |
| - } |
57 | 9 | }
|
0 commit comments