Skip to content

Commit

Permalink
Merge branch 'main' into nic@review-dal-tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
timothymcmackin authored Dec 2, 2024
2 parents 1da2880 + 0a6e7d5 commit 0ceff64
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @trilitech/developer-success
* @trilitech/techrel-docs
2 changes: 2 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
node-version: 18
- run: npm ci
- run: npm run build
- run: npm run concat
- run: mv allPageSourceFiles.txt allTutorials.txt ./build/
- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_S3_PRODUCTION_KEY_ID }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ node_modules
out
build
_glossaryBuild
allPageSourceFiles.txt
allTutorials.txt
19 changes: 12 additions & 7 deletions docs/overview/tezos-different.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
---
title: What makes Tezos different?
last_update:
date: 13 September 2023
date: 29 November 2024
---

Here are some of the features that make Tezos different from other blockchains:

## Tezos can upgrade itself

Tezos has a built-in capability to upgrade itself, which allows the network to evolve without requiring a hard fork. Anyone can propose an upgrade to the protocol and have it adopted by the network without compromising the platform's stability or causing fragmentation. This feature allows Tezos to adapt regularly to new technologies and to address user needs rapidly.
Tezos has a built-in capability to upgrade itself, which allows the network to evolve without requiring a hard fork. Anyone can propose an upgrade to the protocol and have it adopted by the network without compromising the platform's stability or causing fragmentation. This feature allows Tezos to adapt regularly to new technologies and to address user needs rapidly. For more information, see [Governance](/architecture/governance).

## Everyone can participate in governance

Anyone who holds XTZ — the chain's native token — can propose changes to how Tezos works, such as changes to gas fees and block times, new features such as Smart Rollups, or even major changes like how the consensus mechanism works.

## Formal verification ensures trust and code quality

*Formal verification* is a process that ensures that a smart contract does what it says it does and has no side effects. Formal verification reduces errors, bugs, and security vulnerabilities in contracts and allows users to trust them. For more information, see [Formal Verification](https://opentezos.com/formal-verification) on opentezos.com.

## Tezos uses proof of stake

The proof-of-stake consensus model eliminates the need for high energy use, making it the "green" choice for blockchains. Instead of competing to achieve consensus as in proof-of-work models, Tezos nodes (called *bakers*) stake Tezos tokens to earn the right to create blocks and receive rewards. Users who want to participate without running a node themselves can delegate tokens to a baker for a share of the rewards. The bakers keep control of their tokens in that they can unstake them later; and delegators keep complete control of their tokens. Tezos's approach to consensus has been described as [Liquid Proof of Stake](https://medium.com/tezos/liquid-proof-of-stake-aec2f7ef1da7).
The proof-of-stake consensus model eliminates the need for high energy use, making it the "green" choice for blockchains. Instead of competing to achieve consensus as in proof-of-work models, Tezos nodes (called *bakers*) stake Tezos tokens to earn the right to create blocks and receive rewards. Tezos's approach to consensus has been described as [Liquid Proof of Stake](https://medium.com/tezos/liquid-proof-of-stake-aec2f7ef1da7).

Users who want to participate without running a node themselves can delegate and stake tokens to a baker for a share of the baker's rewards. Users retain full control of their delegated and staked tokens; delegated tokens remain liquid and staked tokens are frozen for a short time but remain in the user's account and can be made liquid after a short delay.
<!-- TODO link to more detailed info about delegating and staking from the non-baker perspective -->

The proof-of-stake model improves scalability and encourages cooperation via incentives. It also increases the cost of 51% attacks and avoids environmentally wasteful proof-of-work. Tezos launched in June 2018 as one of the first major proof-of-stake networks.

Expand All @@ -29,3 +28,9 @@ For more information about how Tezos handles proof of stake, see https://tezos.g
## Tezos accepts multiple languages

Tezos provides a few different languages for developers to choose from, according to their use case, including versions of Python and JavaScript/TypeScript. For more information, see [Languages](/smart-contracts/languages/).

## Tezos has a robust layer 2 ecosystem

Tezos provides tools that allow high scalability on a layer above the primary Tezos blockchain, known as layer 2. [Smart Rollups](/architecture/smart-rollups) can run large amounts of logic and handle large amounts of data in a separate environment without slowing Tezos itself down. The [Data Availability Layer](/architecture/data-availability-layer) provides high-throughput data to Smart Rollups.

The framework for these layer 2 systems is enshrined in the layer 1 protocol. All layer 2 activity is secured by verifiable commitments and attestations on layer 1.
14 changes: 9 additions & 5 deletions docs/tutorials/create-an-nft/nft-tznft.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Create NFTs from the command line
authors: 'Sol Lederer, Tim McMackin'
last_update:
date: 18 September 2023
date: 28 November 2024
---

This tutorial covers how to create a collection of NFTs on Tezos and manipulate them using the `tznft` command-line tool.
Expand All @@ -27,15 +27,15 @@ NFTs can represent ownership over digital or physical assets like virtual collec
Like other types of Tezos tokens, a collection of NFTs is managed by a smart contract.
The smart contract defines what information is in each token and how the tokens behave, such as what happens when a user transfers an NFT to another user.

In this tutorial, you create NFTs that comply with the FA2 standard (formally known as the [TZIP-12](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-12/tzip-12.md) standard), the current standard for tokens on Tezos.
In this tutorial, you create NFTs that comply with the [FA2](/architecture/tokens/FA2) standard, a popular and flexible standard for tokens on Tezos.
The FA2 standard creates a framework for how tokens behave on Tezos, including fungible, non-fungible, and other types of tokens.
It provides a standard API to transfer tokens, check token balances, manage operators (addresses that are permitted to transfer tokens on behalf of the token owner), and manage token metadata.

## Prerequisites

To run this tutorial you need Node.JS, NPM, and Docker Desktop to install and use the `tznft` CLI tool, which helps you create and test NFT collections on Tezos.

- Install Node.JS version 18 (not 20) and NPM.
- Install Node.JS version 18 (no later) and NPM.
See https://nodejs.org/.
You can verify that they are installed by running these commands:

Expand Down Expand Up @@ -119,7 +119,7 @@ The first step in creating NFTs is to create local metadata files that describe
```

The new metadata file is named `my_collection.json` and has information such as the name, description, home page, and creator of the collection.
It also includes the interfaces that the NFTs support, including the TZIP-12 interface that was mentioned earlier.
It also includes the interfaces that the NFTs support, including the TZIP-12 interface that is the basis for the FA2 standard.

1. Optional: Edit the `my_collection.json` file to put your information in the `name`, `description`, and `authors` fields.

Expand Down Expand Up @@ -476,14 +476,18 @@ Similarly, you can use the same collection alias because `tznft` keeps aliases s
tznft create-collection my-account --meta_file my_collection.json --alias my_collection
```
If you see an error that says that the request failed with the message `getaddrinfo ENOTFOUND`, the problem could be that the Tezos testnet node is not available.
If you see this error, open the `tznft.json` file, go to the `testnet` section, and change the `providerUrl` field to the URL of a testnet RPC node from the site https://teztnets.com.
1. Mint the tokens on the testnet.
The command is the same as for the sandbox:
```bash
tznft mint my-account my_collection --tokens '1, ipfs://abcde12345'
```
You can add more NFTs until you freeze the collection.
You must use the same account alias that you used to create the collection because that account becomes the administrator of the collection.
Just like in the sandbox, you can add more NFTs until you freeze the collection.
1. View your token balances.
The command is the same as for the sandbox:
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/join-dal-baker/run-dal-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ For example, this command initializes the DAL node with the address of a local `

This, too, may take some time to launch the first time because it needs to generate a new identity file, this time for the DAL network.

To set the address and port that the node listens on, pass the `--net-addr` argument.
By default, it listens on port 11732 on all available network interfaces, equivalent to `--net-addr 0.0.0.0:11732`.
If you need to change the address or port that the DAL node listens for connections to other nodes on, pass the `--public-addr` argument.
By default, it listens on port 11732 on all available network interfaces, equivalent to `--public-addr 0.0.0.0:11732`.

1. Verify that the DAL node is connected to the DAL network by running this command:

Expand Down
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "node ./src/scripts/process_downloaded_glossary.js && docusaurus build",
"concat": "node ./src/scripts/concatenate.mjs",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand Down Expand Up @@ -41,8 +42,10 @@
"minimist": "1.2.8",
"mocha": "10.2.0",
"rehype-stringify": "10.0.0",
"remark": "^15.0.1",
"remark-parse": "11.0.0",
"remark-rehype": "11.0.0",
"strip-markdown": "^6.0.0",
"unified": "11.0.4",
"unist-util-visit": "5.0.0"
},
Expand Down
147 changes: 147 additions & 0 deletions src/scripts/concatenate.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import path from 'path';
import fs from 'fs';

import {remark} from 'remark'
import strip from 'strip-markdown';

import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));

import sidebars from '../../sidebars.js';
// Map sidebars to output file names
const fileNames = {
documentationSidebar: 'allPageSourceFiles.txt',
tutorialsSidebar: 'allTutorials.txt',
}
const pathsToFilterOut = [
'overview/glossary',
];

// Given a docusaurus sidebar object, return a list of the local doc IDs in it
function getIdsRecursive(sidebarObject) {
if (typeof sidebarObject === 'string') {
return sidebarObject;
}
if (sidebarObject.constructor.name == "Array") {
return sidebarObject.reduce((list, oneSidebarObj) =>
list.concat(getIdsRecursive(oneSidebarObj)),
[]);
}
switch(sidebarObject.type) {
case 'category':
return [sidebarObject?.link?.id].concat(getIdsRecursive(sidebarObject.items));
case 'doc':
return sidebarObject.id;
case 'link':
if (sidebarObject.href && sidebarObject.href.startsWith('http')) {
return null;
} else {
return sidebarObject.href;
}
default:
return null;
}
}

// Given a doc file ID from the sidebar, get the filename path
async function getFilePath(fileId) {
const mdPath = path.resolve(__dirname, '../../docs', fileId) + '.md';
try {
await fs.promises.access(mdPath, fs.constants.F_OK);
return mdPath;
} catch {
// Do nothing
}
const mdxPath = mdPath + 'x';
try {
await fs.promises.access(mdxPath, fs.constants.F_OK);
return mdxPath;
} catch {
console.error("Could not file file with sidebar ID", fileId);
}
}

// Remove the front matter from an MD file and replace with an H1
// Got to remove FM because multiple FM blocks break some markdown tools
// Could do this with gray-matter but I don't want to add the dependency
function removeFrontMatter(mdText) {
const lines = mdText.split('\n');
let inFrontMatter = false;
let doneWithFrontMatter = false;
const h1Regex = /^title:\s+(.*)$/;
let titleLine = '';
let line = '';

while (lines.length > 0) {
line = lines.shift();
if (line == '---') {
doneWithFrontMatter = inFrontMatter;
inFrontMatter = true;
}
if (inFrontMatter && !doneWithFrontMatter && h1Regex.test(line)) {
const result = h1Regex.exec(line);
titleLine = '# ' + result[1];
}
if (line != '---' && doneWithFrontMatter) {
return [titleLine, ''].concat(lines).join('\n');
}
}
}

// Unified tools put escapes in places
// We could get around this by forking mdast-util-to-string as described here:
// https://github.com/remarkjs/strip-markdown/issues/28#issuecomment-1290847745
function cleanUpEscapes(text) {
return text
// Fix stripped markdown escaping such as `_` to `\_`
.replaceAll('\\\_', '_')
.replaceAll('\\<', '<')
.replaceAll('\\[', '[')
.replaceAll(/^\\-/gm, '-')
.replaceAll('\\.', '.')
.replaceAll('\\*', '*');
}

async function concatSidebar(sidebarName) {
const outputPath = path.resolve(__dirname, '../../', fileNames[sidebarName]);

// Remove old concatenated file if it exists
try {
await fs.promises.access(outputPath, fs.constants.F_OK);
await fs.promises.unlink(outputPath);
} catch {
// Do nothing because the file does not exist
}

const allMdIds = getIdsRecursive(sidebars[sidebarName])
.filter((id) => !pathsToFilterOut.includes(id))
.filter((item) => item);

// Find the matching file paths
const allFilePaths = await Promise.all(allMdIds.map(getFilePath));

// Read and concat the files in TOC order
await allFilePaths.reduce(async (previousPromise, oneFilePath) => {
await previousPromise;
const markdownText = removeFrontMatter(await fs.promises.readFile(oneFilePath, 'utf8'));
const oneFileText = await remark()
.use(strip)
.process(markdownText);
const oneFileTextFixEscaped = cleanUpEscapes(String(oneFileText));
return fs.promises.appendFile(outputPath, oneFileTextFixEscaped + '\n\n');
}, Promise.resolve());

console.log(`Wrote concatenated file for sidebar ${sidebarName} to ${outputPath}`);
}

// Concatenate the sidebars listed in fileNames to separate single files
async function concatSidebars() {
const sidebarNames = Object.keys(sidebars);
await Promise.all(sidebarNames
.filter((oneSidebarName) => Object.keys(fileNames).includes(oneSidebarName))
.map(concatSidebar));
}

concatSidebars();

0 comments on commit 0ceff64

Please sign in to comment.