Skip to content

Commit c2cb285

Browse files
authored
Merge b4837ed into 8a403c3
2 parents 8a403c3 + b4837ed commit c2cb285

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

packages/types/src/Proposal.ts

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,8 @@
22
// This software may be modified and distributed under the terms
33
// of the ISC license. See the LICENSE file for details.
44

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';
105
import Method from './Method';
116

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)
148
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-
}
579
}

0 commit comments

Comments
 (0)