-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add table, string, frombcs, acl, secp2561k, gasschedule module (#231)
* add some function in Compare (#180) * [Feature] Simple map (#182) * Add SimpleMap * Add SimpleMap * update Language version * add secp256k1 file * Replace from `script` tag to `entry` * std name for new move * move 6 binary byte code changed * Fix integration test * Fix type info * Event util and typeinfo * Add from_bcs module and native function * Add from_bcs module and native function * New module for FromBCS * add table module from branch 'table_module' * add table module from branch 'table_module' * add some function of Table module * Add ACL to StarcoinFramework * Add ACL to StarcoinFramework * Revert big vector * Add spawn_from for vector slice * Add test spawn_from for vector slice * Add test spawn_from for vector slice * [Feature] Simple map (#182) * Add SimpleMap * Add SimpleMap * update Language version * add secp256k1 file * Replace from `script` tag to `entry` * std name for new move * move 6 binary byte code changed * Fix integration test * Fix type info * Event util and typeinfo * Add from_bcs module and native function * Add from_bcs module and native function * New module for FromBCS * add table module from branch 'table_module' * add table module from branch 'table_module' * add some function of Table module * Add ACL to StarcoinFramework * Add ACL to StarcoinFramework * Revert big vector * Add spawn_from for vector slice * Add test spawn_from for vector slice * Add test spawn_from for vector slice * Merge from remote * Merge from remote * Retest some integration test * Retest some integration test * Retest some integration test * Retest some integration test * Retest some integration test * Retest some integration test * Fix checkpoints test error * Change test mpm to tag: v1.13.5-alpha.0 * merge from gas schedule * add gas for new native functions * fix the name of the gas fee * Merge some bytecodes from GasSchedule * dev setup for alpha * integration test * Fix simple map unittest failure * add gas schedule in integration test * add gas schedule documents --------- Co-authored-by: WGB5445 <919603023@qq.com> Co-authored-by: nk_ysg <nk_ysg@163.com> Co-authored-by: jackzhhuang <jackzhhuang@gmail.com>
- Loading branch information
1 parent
2b726cc
commit 7ce805c
Showing
55 changed files
with
4,138 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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 |
---|---|---|
@@ -0,0 +1,205 @@ | ||
|
||
<a name="0x1_ACL"></a> | ||
|
||
# Module `0x1::ACL` | ||
|
||
Access control list (acl) module. An acl is a list of account addresses who | ||
have the access permission to a certain object. | ||
This module uses a <code>vector</code> to represent the list, but can be refactored to | ||
use a "set" instead when it's available in the language in the future. | ||
|
||
|
||
- [Struct `ACL`](#0x1_ACL_ACL) | ||
- [Constants](#@Constants_0) | ||
- [Function `empty`](#0x1_ACL_empty) | ||
- [Function `add`](#0x1_ACL_add) | ||
- [Function `remove`](#0x1_ACL_remove) | ||
- [Function `contains`](#0x1_ACL_contains) | ||
- [Function `assert_contains`](#0x1_ACL_assert_contains) | ||
|
||
|
||
<pre><code><b>use</b> <a href="Errors.md#0x1_Errors">0x1::Errors</a>; | ||
<b>use</b> <a href="Vector.md#0x1_Vector">0x1::Vector</a>; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_ACL_ACL"></a> | ||
|
||
## Struct `ACL` | ||
|
||
|
||
|
||
<pre><code><b>struct</b> <a href="ACL.md#0x1_ACL">ACL</a> <b>has</b> <b>copy</b>, drop, store | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Fields</summary> | ||
|
||
|
||
<dl> | ||
<dt> | ||
<code>list: vector<<b>address</b>></code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
|
||
</details> | ||
|
||
<a name="@Constants_0"></a> | ||
|
||
## Constants | ||
|
||
|
||
<a name="0x1_ACL_ECONTAIN"></a> | ||
|
||
The ACL already contains the address. | ||
|
||
|
||
<pre><code><b>const</b> <a href="ACL.md#0x1_ACL_ECONTAIN">ECONTAIN</a>: u64 = 0; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_ACL_ENOT_CONTAIN"></a> | ||
|
||
The ACL does not contain the address. | ||
|
||
|
||
<pre><code><b>const</b> <a href="ACL.md#0x1_ACL_ENOT_CONTAIN">ENOT_CONTAIN</a>: u64 = 1; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_ACL_empty"></a> | ||
|
||
## Function `empty` | ||
|
||
Return an empty ACL. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_empty">empty</a>(): <a href="ACL.md#0x1_ACL_ACL">ACL::ACL</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_empty">empty</a>(): <a href="ACL.md#0x1_ACL">ACL</a> { | ||
<a href="ACL.md#0x1_ACL">ACL</a>{ list: <a href="Vector.md#0x1_Vector_empty">Vector::empty</a><<b>address</b>>() } | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_ACL_add"></a> | ||
|
||
## Function `add` | ||
|
||
Add the address to the ACL. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_add">add</a>(acl: &<b>mut</b> <a href="ACL.md#0x1_ACL_ACL">ACL::ACL</a>, addr: <b>address</b>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_add">add</a>(acl: &<b>mut</b> <a href="ACL.md#0x1_ACL">ACL</a>, addr: <b>address</b>) { | ||
<b>assert</b>!(!<a href="Vector.md#0x1_Vector_contains">Vector::contains</a>(&<b>mut</b> acl.list, &addr), <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="ACL.md#0x1_ACL_ECONTAIN">ECONTAIN</a>)); | ||
<a href="Vector.md#0x1_Vector_push_back">Vector::push_back</a>(&<b>mut</b> acl.list, addr); | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_ACL_remove"></a> | ||
|
||
## Function `remove` | ||
|
||
Remove the address from the ACL. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_remove">remove</a>(acl: &<b>mut</b> <a href="ACL.md#0x1_ACL_ACL">ACL::ACL</a>, addr: <b>address</b>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_remove">remove</a>(acl: &<b>mut</b> <a href="ACL.md#0x1_ACL">ACL</a>, addr: <b>address</b>) { | ||
<b>let</b> (found, index) = <a href="Vector.md#0x1_Vector_index_of">Vector::index_of</a>(&<b>mut</b> acl.list, &addr); | ||
<b>assert</b>!(found, <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="ACL.md#0x1_ACL_ENOT_CONTAIN">ENOT_CONTAIN</a>)); | ||
<a href="Vector.md#0x1_Vector_remove">Vector::remove</a>(&<b>mut</b> acl.list, index); | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_ACL_contains"></a> | ||
|
||
## Function `contains` | ||
|
||
Return true iff the ACL contains the address. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_contains">contains</a>(acl: &<a href="ACL.md#0x1_ACL_ACL">ACL::ACL</a>, addr: <b>address</b>): bool | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_contains">contains</a>(acl: &<a href="ACL.md#0x1_ACL">ACL</a>, addr: <b>address</b>): bool { | ||
<a href="Vector.md#0x1_Vector_contains">Vector::contains</a>(&acl.list, &addr) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_ACL_assert_contains"></a> | ||
|
||
## Function `assert_contains` | ||
|
||
assert! that the ACL has the address. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_assert_contains">assert_contains</a>(acl: &<a href="ACL.md#0x1_ACL_ACL">ACL::ACL</a>, addr: <b>address</b>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="ACL.md#0x1_ACL_assert_contains">assert_contains</a>(acl: &<a href="ACL.md#0x1_ACL">ACL</a>, addr: <b>address</b>) { | ||
<b>assert</b>!(<a href="ACL.md#0x1_ACL_contains">contains</a>(acl, addr), <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="ACL.md#0x1_ACL_ENOT_CONTAIN">ENOT_CONTAIN</a>)); | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> |
This file contains 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
Oops, something went wrong.