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/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/sidebars.js b/docs/build/isc/v1.0.0-rc.6/sidebars.js index 41b39592bde..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: '.'}], @@ -276,16 +292,7 @@ module.exports = { }, ], }, - { - type: 'category', - label: 'ISC Utilities', - items: [ - { - type: 'autogenerated', - dirName: 'reference/iscutils', - }, - ], - }, + iscutils_references, { type: 'doc', label: 'WasmLib Data Types', 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, };