-
Notifications
You must be signed in to change notification settings - Fork 607
fix: Update aztec sandbox getting started markdown #2374
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,27 @@ | ||
| /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
|
|
||
| /* eslint-disable import/no-duplicates */ | ||
| // docs:start:imports | ||
| import { | ||
| AztecRPC, | ||
| Fr, | ||
| computeMessageSecretHash, | ||
| createAztecRpcClient, | ||
| createDebugLogger, | ||
| getSchnorrAccount, | ||
| waitForSandbox, | ||
| } from '@aztec/aztec.js'; | ||
| // docs:end:imports | ||
|
|
||
| /* eslint-enable @typescript-eslint/no-unused-vars */ | ||
| // Note: this is a hack to make the docs use http://localhost:8080 and CI to use the SANDBOX_URL | ||
| import { createAztecRpcClient as createAztecRpcClient2 } from '@aztec/aztec.js'; | ||
| import { GrumpkinScalar } from '@aztec/circuits.js'; | ||
| import { TokenContract } from '@aztec/noir-contracts/types'; | ||
|
|
||
| const { SANDBOX_URL = 'http://localhost:8080' } = process.env; | ||
| // docs:end:imports | ||
|
|
||
| describe('e2e_sandbox_example', () => { | ||
| // Note: this is a hack to make the docs use http://localhost:8080 and CI to use the SANDBOX_URL | ||
| const createAztecRpcClient = (_url: string) => { | ||
| return createAztecRpcClient2(SANDBOX_URL!); | ||
| }; | ||
|
|
||
| it('sandbox example works', async () => { | ||
| // docs:start:setup | ||
| ////////////// CREATE THE CLIENT INTERFACE AND CONTACT THE SANDBOX ////////////// | ||
| const logger = createDebugLogger('token'); | ||
| const sandboxUrl = 'http://localhost:8080'; | ||
|
|
||
| // We create AztecRPC client connected to the sandbox URL | ||
| const aztecRpc = createAztecRpcClient(sandboxUrl); | ||
| const aztecRpc = createAztecRpcClient(SANDBOX_URL); | ||
| // Wait for sandbox to be ready | ||
| await waitForSandbox(aztecRpc); | ||
|
|
||
|
|
@@ -98,7 +86,6 @@ describe('e2e_sandbox_example', () => { | |
| ////////////// DEPLOY OUR TOKEN CONTRACT ////////////// | ||
|
|
||
| // Deploy a token contract, create a contract abstraction object and link it to the owner's wallet | ||
| // The contract's constructor takes 2 arguments, the initial supply and the owner of that initial supply | ||
| const initialSupply = 1_000_000n; | ||
|
|
||
| logger(`Deploying token contract minting an initial ${initialSupply} tokens to Alice...`); | ||
|
|
@@ -107,6 +94,7 @@ describe('e2e_sandbox_example', () => { | |
| // Create the contract abstraction and link to Alice's wallet for future signing | ||
| const tokenContractAlice = await TokenContract.at(contract.address, await accounts[0].getWallet()); | ||
|
|
||
| // Initialize the contract and add Bob as a minter | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be cleaner to use |
||
| await tokenContractAlice.methods._initialize({ address: alice }).send().wait(); | ||
| await tokenContractAlice.methods.set_minter({ address: bob }, true).send().wait(); | ||
|
|
||
|
|
@@ -127,7 +115,8 @@ describe('e2e_sandbox_example', () => { | |
| ////////////// QUERYING THE TOKEN BALANCE FOR EACH ACCOUNT ////////////// | ||
|
|
||
| // Bob wants to mint some funds, the contract is already deployed, create an abstraction and link it his wallet | ||
| const tokenContractBob = await TokenContract.at(contract.address, await accounts[1].getWallet()); | ||
| // Since we already have a token link, we can simply create a new instance of the contract linked to Bob's wallet | ||
| const tokenContractBob = tokenContractAlice.withWallet(await accounts[1].getWallet()); | ||
|
|
||
| let aliceBalance = await tokenContractAlice.methods.balance_of_private({ address: alice }).view(); | ||
| logger(`Alice's balance ${aliceBalance}`); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Would want it to be depending on the tests, but not sure what the best way is for that right now and just wanted it fixed in this case as people need it shortly