Skip to content

Commit

Permalink
Merge 51eeb61 into e5b71a3
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Oct 17, 2018
2 parents e5b71a3 + 51eeb61 commit 5a34e3e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions packages/api-observable/src/classes.ts
Expand Up @@ -9,9 +9,9 @@ import { Struct, Tuple, Vector } from '@polkadot/types/codec';
export class RxProposal extends Struct.with({ id: PropIndex, proposal: Proposal, address: AccountId }) {
constructor (value: Tuple) {
super({
id: value.get(0),
proposal: value.get(1),
address: value.get(2)
id: value.getAtIndex(0),
proposal: value.getAtIndex(1),
address: value.getAtIndex(2)
});
}

Expand All @@ -31,8 +31,8 @@ export class RxProposal extends Struct.with({ id: PropIndex, proposal: Proposal,
export class RxProposalDeposits extends Struct.with({ balance: Balance, addresses: Vector.with(AccountId) }) {
constructor (value: Tuple) {
super({
balance: value.get(0),
addresses: value.get(1)
balance: value.getAtIndex(0),
addresses: value.getAtIndex(1)
});
}

Expand All @@ -48,9 +48,9 @@ export class RxProposalDeposits extends Struct.with({ balance: Balance, addresse
export class RxReferendum extends Struct.with({ blockNumber: BlockNumber, proposal: Proposal, voteThreshold: VoteThreshold, id: ReferendumIndex }) {
constructor (value: Tuple, id: ReferendumIndex | BN | number) {
super({
blockNumber: value.get(0),
proposal: value.get(1),
voteThreshold: value.get(2),
blockNumber: value.getAtIndex(0),
proposal: value.getAtIndex(1),
voteThreshold: value.getAtIndex(2),
id
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/Metadata.ts
Expand Up @@ -94,11 +94,11 @@ export class OuterEventMetadataEvent extends Tuple {
}

get events (): Vector<EventMetadata> {
return this.get(1) as Vector<EventMetadata>;
return this.getAtIndex(1) as Vector<EventMetadata>;
}

get name (): Text {
return this.get(0) as Text;
return this.getAtIndex(0) as Text;
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/types/src/Method.ts
Expand Up @@ -125,15 +125,15 @@ export default class Method extends Struct {
}

get args (): Array<Base> {
return (this.get(1) as Struct<Base>).values();
return (this.getAtIndex(1) as Struct<Base>).values();
}

get callIndex (): Uint8Array {
return (this.get(0) as MethodIndex).callIndex;
return (this.getAtIndex(0) as MethodIndex).callIndex;
}

get data (): Uint8Array {
return (this.get(1) as Struct<Base>).toU8a();
return (this.getAtIndex(1) as Struct<Base>).toU8a();
}

get meta (): FunctionMetadata {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/codec/Struct.ts
Expand Up @@ -124,7 +124,7 @@ export default class Struct<
}, 0);
}

get (index: number): Base {
getAtIndex (index: number): Base {
return this.values()[index];
}

Expand Down
6 changes: 3 additions & 3 deletions packages/types/src/codec/Tuple.spec.js
Expand Up @@ -58,8 +58,8 @@ describe('Tuple', () => {
threshold: VoteThreshold
}))('0x62190000000000000003507b0a092230783432223a202230783433220a7d0a01');

expect(test.get(0).toNumber()).toEqual(6498);
expect(test.get(1).callIndex).toEqual(new Uint8Array([0, 3]));
expect(test.get(2).toNumber()).toEqual(1);
expect(test.getAtIndex(0).toNumber()).toEqual(6498);
expect(test.getAtIndex(1).callIndex).toEqual(new Uint8Array([0, 3]));
expect(test.getAtIndex(2).toNumber()).toEqual(1);
});
});
6 changes: 3 additions & 3 deletions packages/types/src/codec/Vector.spec.js
Expand Up @@ -53,9 +53,9 @@ describe('Vector', () => {
]));
const first = test.get(0);

expect(first.get(0).toNumber()).toEqual(10);
expect(first.get(1).callIndex).toEqual(new Uint8Array([0, 3]));
expect(first.get(2).toString()).toEqual('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ');
expect(first.getAtIndex(0).toNumber()).toEqual(10);
expect(first.getAtIndex(1).callIndex).toEqual(new Uint8Array([0, 3]));
expect(first.getAtIndex(2).toString()).toEqual('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ');
});

describe('array-like functions', () => {
Expand Down

0 comments on commit 5a34e3e

Please sign in to comment.