Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite type-extrinsics #173

Merged
merged 24 commits into from
Oct 1, 2018
Merged

Rewrite type-extrinsics #173

merged 24 commits into from
Oct 1, 2018

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Sep 28, 2018

API: extrinsics.timestamp.set(...) -> Returns correctly encoded Extrinsic.

TODO:

  • Add camelCase: extrinsics.balances.set_balance -> extrinsics.balances.setBalance
  • Remove type-params
  • Remove type-primitives

In another PR:

  • Add encode with publicKey
  • Add sign with private key

Notes:

  • skipped all failing tests in type-primitives
  • codec/ and legacy folders should be removed asap

@amaury1093 amaury1093 added WIP Work in Progress @type-extrinsics labels Sep 28, 2018
@amaury1093 amaury1093 force-pushed the am-extrinsics branch 2 times, most recently from 000b247 to 015cfda Compare September 28, 2018 15:06
@amaury1093 amaury1093 changed the base branch from jg-public-storage to master September 28, 2018 15:06
@amaury1093 amaury1093 force-pushed the am-extrinsics branch 3 times, most recently from 3c7d950 to 927e3c0 Compare September 28, 2018 15:55
@amaury1093 amaury1093 changed the base branch from master to jg-jsonrpc-update September 28, 2018 15:56
@jacogr
Copy link
Member

jacogr commented Sep 28, 2018

Related #161

@coveralls
Copy link

Coverage Status

Coverage increased (+9.7%) to 89.118% when pulling 927e3c0 on am-extrinsics into bd9d3e6 on jg-jsonrpc-update.

expect(newExtrinsics.timestamp.set([10101]).toU8a()).toEqual(
new Uint8Array([
// index
// 3, 0, // FIXME This was taken from the old tests, should work, but doesn't
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is length encoded. The 40 is the length. Passing isBare = true should give the result you expect.


return new Extrinsic(
u8aConcat(
new Uint8Array([index, meta.id.toU8a()[1]]),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that's the cleanest way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we get to 3,0... so... Just not sure this is u16 (not sure why it is not a u8) and the toU8a() encodes to little-endian, so the value we are actually interested in is in position 0?

i.e.

0x0004 -> Uint8Array([4, 0])

I would actually just toNumber() it there. It is supposed to fit in a byte, if it goes over 255 we have bigger issues.

...expectedArgs.map((argument, index) => {
const type = argument.type.toString(); // Argument type, as string

return createType(type, args[index]).toU8a(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be encoded? In the test you to toU8a(true), this should be ready for submittion.

@amaury1093 amaury1093 removed the WIP Work in Progress label Oct 1, 2018
Copy link
Member

@jacogr jacogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we have the encoding/signing in-place, we can actually test this e2e, we have the test keyring, we can send stuff, Alice is nicely operational on a local network.

@jacogr jacogr merged commit 8840f33 into master Oct 1, 2018
@jacogr jacogr deleted the am-extrinsics branch October 1, 2018 08:43
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants