diff --git a/templates/01-hello-username/assembly/main.ts b/templates/01-hello-username/assembly/main.ts index 4ee1c27..52cb414 100755 --- a/templates/01-hello-username/assembly/main.ts +++ b/templates/01-hello-username/assembly/main.ts @@ -11,14 +11,15 @@ export function sayHi(): void { // context.sender is the account_id of the user who sent this call to the contract // It's provided by the Blockchain runtime. For now we just store it in a local variable. let sender = context.sender; - // `near` class contains some helper functions, e.g. logging. + + // `near-runtime-ts` contains some helper classes, e.g. `logging` // Logs are not persistently stored on the blockchain, but produced by the blockchain runtime. // 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). logging.log(sender + " says \"Hi!\""); + // storage is a helper class that allows contracts to modify the persistent state // and read from it. setString allows you to persitently store a string value for a given string key. - // We'll store the last sender of this contract who called this method. storage.setString(LAST_SENDER_KEY, sender); } diff --git a/templates/01-hello-username/assembly/model.ts b/templates/01-hello-username/assembly/model.ts deleted file mode 100644 index 44e1770..0000000 --- a/templates/01-hello-username/assembly/model.ts +++ /dev/null @@ -1,2 +0,0 @@ -//@nearfile -// TODO: Define data model here \ No newline at end of file diff --git a/templates/01-hello-username/src/config.js b/templates/01-hello-username/src/config.js index 1414991..29be5f4 100644 --- a/templates/01-hello-username/src/config.js +++ b/templates/01-hello-username/src/config.js @@ -1,5 +1,5 @@ (function() { - const CONTRACT_NAME = 'near-hello-devnet'; /* TODO: fill this in! */ + const CONTRACT_NAME = 'near-hello-devnet'; const DEFAULT_ENV = 'development'; function getConfig(env) { diff --git a/templates/01-hello-username/src/main.js b/templates/01-hello-username/src/main.js index 2e248c8..816f97a 100755 --- a/templates/01-hello-username/src/main.js +++ b/templates/01-hello-username/src/main.js @@ -9,12 +9,14 @@ async function initContract() { // is hosted at https://wallet.nearprotocol.com window.walletAccount = new nearlib.WalletAccount(window.near); - // Getting the Account ID. If unauthorized yet, it's just empty string. + // Getting the Account ID. If currently unauthorized, it's just empty string. window.accountId = window.walletAccount.getAccountId(); // Initializing our contract APIs by contract name and configuration. window.contract = await near.loadContract(nearConfig.contractName, { // NOTE: This configuration only needed while NEAR is still in development + // See https://github.com/nearprotocol/NEPs/pull/3 + // View methods are read only. They don't modify the state, but usually return some value. viewMethods: ['whoSaidHi'], // Change methods can modify the state. But you don't receive the returned value when called. @@ -38,7 +40,7 @@ async function doWork() { function signedOutFlow() { // Displaying the signed out flow container. Array.from(document.querySelectorAll('.signed-out')).forEach(el => el.style.display = ''); - // Adding an event to a sing-in button. + // Adding an event to a sign-in button. document.getElementById('sign-in').addEventListener('click', () => { window.walletAccount.requestSignIn( // The contract name that would be authorized to be called by the user's account. @@ -65,7 +67,7 @@ function signedInFlow() { window.contract.sayHi().then(updateWhoSaidHi); }); - // Adding an event to a sing-out button. + // Adding an event to a sign-out button. document.getElementById('sign-out').addEventListener('click', e => { e.preventDefault(); walletAccount.signOut();