diff --git a/docs/build/iota-sdk/1.0/sidebars.js b/docs/build/iota-sdk/1.0/sidebars.js index 0972a123011..819e1658ecf 100644 --- a/docs/build/iota-sdk/1.0/sidebars.js +++ b/docs/build/iota-sdk/1.0/sidebars.js @@ -9,15 +9,7 @@ Create as many sidebars as you want. */ -const fs = require('fs'); - -function directoryExists(path) { - try { - return fs.statSync(path).isDirectory(); - } catch (err) { - return false; - } -} +const { directoryExists } = require('../../../../src/utils/config'); var python_references = {}; if (directoryExists(__dirname + '/docs/references/python')) { diff --git a/docs/build/isc/v1.0.0-rc.6/docs/getting-started/networks-and-chains.mdx b/docs/build/isc/v1.0.0-rc.6/docs/getting-started/networks-and-chains.mdx index 8186bf8a98d..dc71f1cdd01 100644 --- a/docs/build/isc/v1.0.0-rc.6/docs/getting-started/networks-and-chains.mdx +++ b/docs/build/isc/v1.0.0-rc.6/docs/getting-started/networks-and-chains.mdx @@ -47,4 +47,4 @@ The other values (network name and currency symbol) can be whatever value you li Both [ShimmerEVM](#shimmerEVM) and the [TestnetEVM](#testnetEVM) networks have 7 [core contracts](../reference/core-contracts/overview.md) deployed, as well as the -[Magic Contract](../reference/magic-contract.md). +[Magic Contract](../reference/magic-contract/introduction.md). diff --git a/docs/build/isc/v1.0.0-rc.6/docs/how-tos/core-contracts/introduction.md b/docs/build/isc/v1.0.0-rc.6/docs/how-tos/core-contracts/introduction.md index 27cacfd0ced..e85ae9d87a7 100644 --- a/docs/build/isc/v1.0.0-rc.6/docs/how-tos/core-contracts/introduction.md +++ b/docs/build/isc/v1.0.0-rc.6/docs/how-tos/core-contracts/introduction.md @@ -15,7 +15,7 @@ tags: # The Core Contracts -The [core contracs](../../explanations/core-contracts.md) are contracts deployed on every chain and are vital to interact with L1 and the chain itself. They can be called in Solidity through the [ISC Magic Contract](../../reference/magic-contract.md). +The [core contracs](../../explanations/core-contracts.md) are contracts deployed on every chain and are vital to interact with L1 and the chain itself. They can be called in Solidity through the [ISC Magic Contract](../../reference/magic-contract/introduction.md). ## The ISC Magic Contract @@ -43,6 +43,12 @@ import "@iota/iscmagic/ISC.sol"; The Magic contract also provides proxy ERC20 contracts to manipulate ISC base tokens and native tokens on L2. +:::info Reference Docs + +If you need further info about magic contracts interfaces you can check out the [magic contract docs](../../reference/magic-contract/introduction.md). + +::: + ## Call a Function In the example below, `ISC.sandbox.getEntropy()` calls the diff --git a/docs/build/isc/v1.0.0-rc.6/docs/reference/.gitignore b/docs/build/isc/v1.0.0-rc.6/docs/reference/.gitignore new file mode 100644 index 00000000000..31a1d0913e6 --- /dev/null +++ b/docs/build/isc/v1.0.0-rc.6/docs/reference/.gitignore @@ -0,0 +1,3 @@ +magic-contract/* +!magic-contract/introduction.md +iscutils diff --git a/docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract.md b/docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract.md deleted file mode 100644 index 6b4e3feb30f..00000000000 --- a/docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract.md +++ /dev/null @@ -1,60 +0,0 @@ -# Magic Contract - -- [Common type definitions](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCTypes.sol) -- [ISC library](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISC.sol) -- [ISCSandbox](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCSandbox.sol) - interface, available at `ISC.sandbox` -- [ISCAccounts](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCAccounts.sol) - interface, available at `ISC.accounts` -- [ISCUtil](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCUtil.sol) - interface, available at `ISC.util` -- [ERC20BaseTokens](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ERC20BaseTokens.sol) - contract, available at `ISC.baseTokens` - (address `0x1074010000000000000000000000000000000000`) -- [ERC20NativeTokens](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ERC20NativeTokens.sol) - contract, available at `ISC.nativeTokens(foundrySN)` after being registered - by the foundry owner by calling - [`registerERC20NativeToken`](./core-contracts/evm.md#registerERC20NativeToken) - (address `0x107402xxxxxxxx00000000000000000000000000` where `xxxxxxxx` is the - little-endian encoding of the foundry serial number) -- [ERC20ExternalNativeTokens](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ERC20ExternalNativeTokens.sol) - contract, available at a dynamically assigned address after being registered - by the foundry owner by calling - [`registerERC20NativeTokenOnRemoteChain`](./core-contracts/evm.md#registerERC20NativeTokenOnRemoteChain) - on the chain that controls the foundry. -- [ERC721NFTs](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ERC721NFTs.sol) - contract, available at `ISC.nfts` - (address `0x1074030000000000000000000000000000000000`) -- [ERC721NFTCollection](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ERC721NFTCollection.sol) - contract, available at `ISC.erc721NFTCollection(collectionID)`, after being - registered by calling [`registerERC721NFTCollection`](./core-contracts/evm.md#registerERC721NFTCollection). - -There are some usage examples in -the [ISC How-To Guides](../how-tos/introduction.md) and the [ISCTest.sol](https://github.com/iotaledger/wasp/blob/develop/packages/evm/evmtest/ISCTest.sol) contract (used -internally in unit tests). - -## Call a Native Contract - -You can call native contracts using [`ISC.sandbox.call`](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCSandbox.sol#L56): - -```solidity -pragma solidity >=0.8.5; - -import "@iota/iscmagic/ISC.sol"; - -contract MyEVMContract { - event EntropyEvent(bytes32 entropy); - - function callInccounter() public { - ISCDict memory params = ISCDict(new ISCDictItem[](1)); - bytes memory int64Encoded42 = hex"2A00000000000000"; - params.items[0] = ISCDictItem("counter", int64Encoded42); - ISCAssets memory allowance; - ISC.sandbox.call(ISC.util.hn("inccounter"), ISC.util.hn("incCounter"), params, allowance); - } -} -``` - -`ISC.util.hn` is used to get the `hname` of the `inccounter` contract and the -`incCounter` entry point. You can also call view entry points using -[ISC.sandbox.callView](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCSandbox.sol#L59). diff --git a/docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract/introduction.md b/docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract/introduction.md new file mode 100644 index 00000000000..3ca44996914 --- /dev/null +++ b/docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract/introduction.md @@ -0,0 +1,38 @@ +--- +sidebar_position: 1 +--- + +import DocCardList from '@theme/DocCardList'; + +# Introduction + +This section documents the magic contract and all it's interfaces: + + + + +## Call a Native Contract + +You can call native contracts using [`ISC.sandbox.call`](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCSandbox.sol#L56): + +```solidity +pragma solidity >=0.8.5; + +import "@iota/iscmagic/ISC.sol"; + +contract MyEVMContract { + event EntropyEvent(bytes32 entropy); + + function callInccounter() public { + ISCDict memory params = ISCDict(new ISCDictItem[](1)); + bytes memory int64Encoded42 = hex"2A00000000000000"; + params.items[0] = ISCDictItem("counter", int64Encoded42); + ISCAssets memory allowance; + ISC.sandbox.call(ISC.util.hn("inccounter"), ISC.util.hn("incCounter"), params, allowance); + } +} +``` + +`ISC.util.hn` is used to get the `hname` of the `inccounter` contract and the +`incCounter` entry point. You can also call view entry points using +[ISC.sandbox.callView](https://github.com/iotaledger/wasp/blob/develop/packages/vm/core/evm/iscmagic/ISCSandbox.sol#L59). diff --git a/docs/build/isc/v1.0.0-rc.6/sidebars.js b/docs/build/isc/v1.0.0-rc.6/sidebars.js index e3e788847bf..3ddd14b7d8c 100644 --- a/docs/build/isc/v1.0.0-rc.6/sidebars.js +++ b/docs/build/isc/v1.0.0-rc.6/sidebars.js @@ -9,6 +9,22 @@ Create as many sidebars as you want. */ +const { directoryExists } = require('../../../../src/utils/config'); + +var iscutils_references = {}; +if (directoryExists(__dirname + '/docs/reference/iscutils')) { + iscutils_references = { + type: 'category', + label: 'ISC Utilities', + items: [ + { + type: 'autogenerated', + dirName: 'reference/iscutils', + }, + ], + }; +} + module.exports = { // By default, Docusaurus generates a sidebar from the docs folder structure //tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], @@ -220,7 +236,16 @@ module.exports = { label: 'Reference', items: [ 'reference/json-rpc-spec', - 'reference/magic-contract', + { + type: 'category', + label: 'Magic Contract', + items: [ + { + type: 'autogenerated', + dirName: 'reference/magic-contract', + }, + ], + }, { type: 'category', label: 'Core Contracts', @@ -267,6 +292,7 @@ module.exports = { }, ], }, + iscutils_references, { type: 'doc', label: 'WasmLib Data Types', diff --git a/package.json b/package.json index 415c5c27a95..3eb36bb64bf 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build:theme": "yarn ./theme build", "checkout": "git submodule update --init", "checkout:remote": "yarn checkout --remote", - "generate:api": "docusaurus gen-api-docs all && ./scripts/get_sdk_references.sh", + "generate:api": "docusaurus gen-api-docs all && ./scripts/get_sdk_references.sh && ./scripts/get_wasp_references.sh", "lint": "eslint --cache --fix .", "lint:check": "eslint --cache .", "lint:links": "iota-wiki check", diff --git a/scripts/get_wasp_references.sh b/scripts/get_wasp_references.sh new file mode 100755 index 00000000000..a9e19a4c50b --- /dev/null +++ b/scripts/get_wasp_references.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Create temporaty directory to work in +mkdir tmp +cd tmp + +# Download and copy docs +curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.0/iscmagic.tar.gz | tar xzv +cp -Rv docs/iscmagic/* ../docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract/ + +curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.0/iscutils.tar.gz | tar xzv +cp -Rv docs/iscutils ../docs/build/isc/v1.0.0-rc.6/docs/reference/ + +# Return to root and cleanup +cd - +rm -rf tmp diff --git a/src/utils/config.js b/src/utils/config.js index 7d98f995b25..27c67533e27 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -1,5 +1,6 @@ const path = require('path'); const defaultSettings = require('../common/defaultContentPlugin'); +const fs = require('fs'); /** * Merges multiple configuration objects into one object. @@ -137,9 +138,18 @@ async function create_doc_plugin({ ...options }) { ]; } +function directoryExists(path) { + try { + return fs.statSync(path).isDirectory(); + } catch (err) { + return false; + } +} + module.exports = { glob, merge, create_doc_plugin, globStatic, + directoryExists, };