near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 21 forks source link

code typo in example #100

Closed danielwpz closed 2 years ago

danielwpz commented 2 years ago

hey, I found the example writes:

  const attachedDeposit = '2 N';

  // This adds the key as a function access key on `create_account_and_claim`
  await root.call(linkdrop, 'send', {public_key}, {attachedDeposit});

however the attachedDeposit cannot be a string, it has to be a NEAR parsed object.

https://github.com/near/workspaces-js/blob/main/__tests__/03.single-use-access-keys-with-linkdrop.ava.ts#L42

Is this a typo? If so I can help fix the example

volovyks commented 2 years ago

It's passed as an object. When we are passing parameters with brackets they are passed as an object.

const someString = 'yo';
someFunc(someString);  <- passed as a string
someFunc({ someString });  <- passed as an object, transformed to "{"someString": "yo"}"

Other parameters in this type are optional, so it's ok. But you can make a PR that will have more self explanatory code, thanks :)

willemneal commented 2 years ago

@danielwpz It hasn't been published yet, but you can assign a string to attachedDeposit, see https://github.com/near/workspaces-js/pull/99