Skip to content

Commit

Permalink
Wasp reference docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron authored Mar 26, 2024
1 parent 233fc38 commit 418afcc
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 73 deletions.
10 changes: 1 addition & 9 deletions docs/build/iota-sdk/1.0/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/reference/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
magic-contract/*
!magic-contract/introduction.md
iscutils
60 changes: 0 additions & 60 deletions docs/build/isc/v1.0.0-rc.6/docs/reference/magic-contract.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
sidebar_position: 1
---

import DocCardList from '@theme/DocCardList';

# Introduction

This section documents the magic contract and all it's interfaces:

<DocCardList />

<!-- TODO: Remove -->
## 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).
28 changes: 27 additions & 1 deletion docs/build/isc/v1.0.0-rc.6/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '.'}],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -267,6 +292,7 @@ module.exports = {
},
],
},
iscutils_references,
{
type: 'doc',
label: 'WasmLib Data Types',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions scripts/get_wasp_references.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions src/utils/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const defaultSettings = require('../common/defaultContentPlugin');
const fs = require('fs');

/**
* Merges multiple configuration objects into one object.
Expand Down Expand Up @@ -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,
};

0 comments on commit 418afcc

Please sign in to comment.