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

depositValue not defined in tutorial #109

Closed
cag opened this issue Mar 20, 2018 · 3 comments
Closed

depositValue not defined in tutorial #109

cag opened this issue Mar 20, 2018 · 3 comments

Comments

@cag
Copy link
Contributor

cag commented Mar 20, 2018

@zupino noticed this:

In this section of the tutorial, there is an example:

async function buyAllOutcomes() {
    const txResults = await Promise.all([
        [gnosis.etherToken.constructor, await gnosis.etherToken.deposit.sendTransaction({ value: depositValue })],
        [gnosis.etherToken.constructor, await gnosis.etherToken.approve.sendTransaction(event.address, depositValue)],
        [event.constructor, await event.buyAllOutcomes.sendTransaction(depositValue)],
    ].map(([contract, txHash]) => contract.syncTransaction(txHash)))

    // Make sure everything worked
    const expectedEvents = [
        'Deposit',
        'Approval',
        'OutcomeTokenSetIssuance',
    ]
    txResults.forEach((txResult, i) => {
        Gnosis.requireEventFromTXResult(txResult, expectedEvents[i])
    })
}
buyAllOutcomes()

which is missing a definition for depositValue (should be 4 ETH following the tutorial text):

const depositValue = 4e18
@srameshr
Copy link

srameshr commented Mar 31, 2018

@cag Also what does the following do?

        [gnosis.etherToken.constructor, await gnosis.etherToken.deposit.sendTransaction({ value: depositValue })],
        [gnosis.etherToken.constructor, await gnosis.etherToken.approve.sendTransaction(event.address, depositValue)],
        [event.constructor, await event.buyAllOutcomes.sendTransaction(depositValue)],

What is deposit, approve doing here? Assume intention of the user here is just to buy some tokens and nothing else.

@cag
Copy link
Contributor Author

cag commented Apr 3, 2018

@srameshr This is a consequence of the way wrapped ether is specified and the way ERC20 tokens are specified respectively.

In short, deposit comes from the mechanics of W-ETH. Basically, it's so ether can be used as an ERC20 token.

And approve comes from the ERC20 standard itself. Referring to the linked article, you (0x111...) have to authorize the event contract (0x222...) to perform a transferFrom during the execution of buyAllOutcomes.

@cag
Copy link
Contributor Author

cag commented Apr 5, 2018

Okay, the original issue should be addressed in the docs at #115 now. I will close this issue when that gets merged, and then I will open another issue wrt srameshr's comment

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

No branches or pull requests

2 participants