Skip to content

Instantly share code, notes, and snippets.

@chadoh
Created February 11, 2020 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadoh/a27c1753471a1d7651907e7d0d88ba39 to your computer and use it in GitHub Desktop.
Save chadoh/a27c1753471a1d7651907e7d0d88ba39 to your computer and use it in GitHub Desktop.

NEAR Studio

  • can we use Glitch instead?
  • why does "open near studio" button on https://nearprotocol.com/get-started/ open in a new tab instead of current?
  • when studio first opens, I feel a little overwhelmed. Contributing factors:
    • small font size
    • needing to pick an example – which one is the best to start with??
    • i'd rather have a super simple hello-world-type app open immediately
    • this is my complete intro to the NEAR stack – it doesn't seem like it's structured like a tutorial, though. All of a sudden it's asking me to make choices about wallet integrations vs smart contracts. If I don't even know what these things are yet, I'll probably just close this page
  • "Click the "Run" button on the top of the Studio window", says the README. When I look for it, my eyes are immediately drawn to the big red "report a bug". It took a while to find the small-and-buried "run" button.
  • "Building a DApp? Apply to the Beta Program!" – I'd prefer to show this after a user completes Step X of a tutorial process or something, rather than bombarding hesitant newbies with it right away. We should at least provide a way to hide it.

Who was the last person to say "hi!"?

README:

  • the "To Run" and "To Test" sections have disclaimers that say "in NEAR Studio" – the assumption should be that people interact with this app via NEAR Studio. Let's get rid of this text, it just makes newbies wonder if they're in the right place. fixed on branch template-01-readme-fixes

  • "To Run" instructions change from "you will" to "you would" at step 3, as if we've given up on the user. "This is what you would see, if you actually followed through. But we know you won't." fixed on branch template-01-readme-fixes

  • When it first loads, it says "??? was the last person to say "hi"? <|Click here to find out!|>" – let's just make it say "Who"

  • When you click, it says "Nobody was the last person to..." – no need for this state

  • Why is my name always italicized? Can we make it a link instead? – cannot make it a link yet, but "we can add that" – should I do that now??

  • is it worth removing bootstrap?

All fixed in various PRs as of 2020-01-31

Authorizing apps

I see this code:

window.walletAccount.requestSignIn(
  // The contract name that would be authorized to be called by the user's account.
  window.nearConfig.contractName,
  // This is the app name. It can be anything.
  'Who was the last person to say "Hi!"?',
  // We can also provide URLs to redirect on success and failure.
  // The current URL is used by default.
);

Two things surprise me here:

  1. the "app name" is just a string passed by the frontend – I expected this to come from the contract itself. Why doesn't it?
  2. no list of permissions requested – when the frontend says "this does not allow the app to transfer any tokens", it made me think that the contract (or the frontend sign-in process) would request specific permissions/scopes. Does that happen somewhere?

Calling functions

The contract comments say:

// It's helpful to use logs for debugging your functions or when you need to get some info
// from the change methods (since change methods don't return values to the front-end).

And then in our frontend, we do this:

window.contract.sayHi().then(updateWhoSaidHi);

So the change method (sayHi) does not return any values, but it is a promise that will only resolve once the data is written to the chain. Correct?

This makes the frontend clunky and results in unnecessary network requests, since we have to wait until the change method completes and then send another call to the contract to read the state. Why can't the change method also return some values?

Is there another architecture (subscription-based, maybe) that we should encourage to obviate this concern?

Loading contract

window.contract = await near.loadContract(nearConfig.contractName, {
  viewMethods: ['whoSaidHi'],
  changeMethods: ['sayHi'],
  sender: window.accountId,
});
  • Could we make near.loadContract(contractName) figure out viewMethods and changeMethods directly from the contract? Manually listing them in the frontend seems brittle.

Answer in Slack #wallet thread, 2020-01-30T16:57:54Z from Kendall Cole:

The biggest challenge is that app !== contract (at least in many cases) We have a few ideas on how to solve the data consistency issue (e.g. app registry smart contract), but it’s still concept stage

Then from Vlad:

One of the challenges is that we don't have anywhere to store key metadata yet. Can potentially be stored either on user's contract (using stuff @Evgeny Kuzyakov is working on) or on separate wallet contract (but this raises problem of billing for storage).

  • this "app registry" is something I could potentially work on

Wallet Experience

  • Recovery email confirmation didn't make me verify my email!
  • just used the wallet yesterday. Trying to use an app today says I'm signed out, has me choose a username. Account recovery page tells me to go to my email – I do that, click the link, get signed in, but when I go back to the app it still doesn't know me!
  • "TESTNET ?" – I expected clicking the question mark icon to give me some extra info about testnet. Instead it tried to open Discord. This is a clumsy experience.
  • How do I link to my profile? When I click the dropdown in the top right and select "profile", it goes to /profile, which will not work for anyone else. How do I link other people to my profile?

PRs

  • renderbot posting multiple times, twice each for two separate URLs configured for the PR.
    • make post once for each url

    • make posts explain what it's for and why we use renderbot

    • can we make renderbot post once with both URLs?

    • doesn't matter – only internal PRs get comments from renderbot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment