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

Add SEP0010 transaction challenge builder. #375

Merged
merged 6 commits into from Jul 23, 2019
Merged

Conversation

abuiles
Copy link
Contributor

@abuiles abuiles commented Jul 19, 2019

Add utils helper to build a SEP0010 valid challenge.

Sample output

AAAAAHRD4zvCiabbOMksn5mg8bNn3xycAk52LmIMZKB4iqgFAAAAZAAAAAAAAAAAAAAAAQAAAABdNzGaAAAAAF03MsYAAAAAAAAAAQAAAAEAAAAARon01E/j0N3bMk5bp8DPaQV5jXIGx8KSZdaDzo2OodEAAAAKAAAADGFidWlsZXMgYXV0aAAAAAEAAABAHQOZOayLVxkitGwVeiulzbdXPRs46IZmutCzC4U5HxQ6xer93GBrsqd6GwST8P35EztYEeIHgmxgHjfIRF4zNgAAAAAAAAABeIqoBQAAAEAi53zg8SaPdt+VebY2AOm/7A20hw6t5biRQ2JxgSTeuaL4AGDxrXkY3gpPx8COTytekS3+1ttNo0XAZvm8sJIE

Fixes #370

Example

import { Utils, Keypair, Network }  from 'stellar-sdk'

Network.useTestNetwork();

let serverKeyPair = Keypair.fromSecret("some-secret")
let challenge = Utils.buildChallengeTx(serverKeyPair, "some-stellar-account-id", "SDF")

@abuiles
Copy link
Contributor Author

abuiles commented Jul 19, 2019

@morleyzhi I need to do a couple of cleanups and then it should be good - why did we disable namespaces in TypeScript?

src/utils.ts Outdated Show resolved Hide resolved
@abuiles abuiles requested a review from morleyzhi July 19, 2019 22:12
@abuiles abuiles force-pushed the abuiles/sep-10-challenge branch 2 times, most recently from c13c0c1 to 82d7d28 Compare July 19, 2019 22:18
@Akuukis
Copy link
Contributor

Akuukis commented Jul 19, 2019

@abuiles Because of Babel not supporting it there was a lot FUD of namespaces being "deprecated" or not "official", although Typescript team never said so. And then support came to Babel 20 days ago (babel/babel#9785). Unfortunately the whole FUD got so far as a linter rule.

I'm all for using namespaces.

Copy link
Contributor

@morleyzhi morleyzhi left a comment

Choose a reason for hiding this comment

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

I didn’t intentionally ban namespaces. If that rule is defined in stellar/product-conventions we should disable it.

src/utils.ts Outdated Show resolved Hide resolved
abuiles added a commit to abuiles/product-conventions that referenced this pull request Jul 22, 2019
This is turned on by `tslint:recommended`, but now that it is
supported by babel we can use it safely.

See @Akuukis comment here stellar/js-stellar-sdk#375 (comment).
morleyzhi pushed a commit to stellar/product-conventions that referenced this pull request Jul 22, 2019
This is turned on by `tslint:recommended`, but now that it is
supported by babel we can use it safely.

See @Akuukis comment here stellar/js-stellar-sdk#375 (comment).
@abuiles abuiles changed the title [WIP] Implement SEP0010 transaction challenge builder. Implement SEP0010 transaction challenge builder. Jul 22, 2019
@abuiles abuiles changed the title Implement SEP0010 transaction challenge builder. Add SEP0010 transaction challenge builder. Jul 23, 2019
Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

LGTM!

src/utils.ts Outdated
@@ -0,0 +1,66 @@
import { randomBytes } from "crypto";
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we removed dependency on crypto package in stellar/js-stellar-base#169. You should probably use randombytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bartekn thanks for the heads up, fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create "Challenge" Transaction
4 participants