Skip to content

Commit e05f30a

Browse files
committed
Genesis
1 parent d006c97 commit e05f30a

40 files changed

+2515
-2
lines changed

.eslintrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["./node_modules/@corepass/ylem-scripts/lib/eslint-config.js"]
3+
}
4+

.gitignore

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
package-lock.json
10+
yarn.lock
11+
12+
# Diagnostic reports (https://nodejs.org/api/report.html)
13+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14+
15+
# Runtime data
16+
pids
17+
*.pid
18+
*.seed
19+
*.pid.lock
20+
21+
# Directory for instrumented libs generated by jscoverage/JSCover
22+
lib-cov
23+
24+
# Coverage directory used by tools like istanbul
25+
coverage
26+
*.lcov
27+
28+
# nyc test coverage
29+
.nyc_output
30+
31+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32+
.grunt
33+
34+
# Bower dependency directory (https://bower.io/)
35+
bower_components
36+
37+
# node-waf configuration
38+
.lock-wscript
39+
40+
# Compiled binary addons (https://nodejs.org/api/addons.html)
41+
build/Release
42+
43+
# Dependency directories
44+
node_modules/
45+
jspm_packages/
46+
47+
# Snowpack dependency directory (https://snowpack.dev/)
48+
web_modules/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional stylelint cache
60+
.stylelintcache
61+
62+
# Microbundle cache
63+
.rpt2_cache/
64+
.rts2_cache_cjs/
65+
.rts2_cache_es/
66+
.rts2_cache_umd/
67+
68+
# Optional REPL history
69+
.node_repl_history
70+
71+
# Output of 'npm pack'
72+
*.tgz
73+
74+
# Yarn Integrity file
75+
.yarn-integrity
76+
77+
# dotenv environment variable files
78+
.env
79+
.env.development.local
80+
.env.test.local
81+
.env.production.local
82+
.env.local
83+
84+
# parcel-bundler cache (https://parceljs.org/)
85+
.cache
86+
.parcel-cache
87+
88+
# Next.js build output
89+
.next
90+
out
91+
92+
# Nuxt.js build / generate output
93+
.nuxt
94+
dist
95+
96+
# Gatsby files
97+
.cache/
98+
# Comment in the public line in if your project uses Gatsby and not Next.js
99+
# https://nextjs.org/blog/next-9-1#public-directory-support
100+
# public
101+
102+
# vuepress build output
103+
.vuepress/dist
104+
105+
# vuepress v2.x temp and cache directory
106+
.temp
107+
.cache
108+
109+
# Docusaurus cache and generated files
110+
.docusaurus
111+
112+
# Serverless directories
113+
.serverless/
114+
115+
# FuseBox cache
116+
.fusebox/
117+
118+
# DynamoDB Local files
119+
.dynamodb/
120+
121+
# TernJS port file
122+
.tern-port
123+
124+
# Stores VSCode versions used for testing VSCode extensions
125+
.vscode-test
126+
127+
# yarn v2
128+
.yarn/cache
129+
.yarn/unplugged
130+
.yarn/build-state.yml
131+
.yarn/install-state.gz
132+
.pnp.*
133+
134+
# ylem-scripts
135+
builds
136+
.npmrc
137+
138+
### macOS ###
139+
# General
140+
.DS_Store
141+
.AppleDouble
142+
.LSOverride
143+
144+
# Icon must end with two \r
145+
Icon
146+
147+
# Thumbnails
148+
._*
149+
150+
# Files that might appear in the root of a volume
151+
.DocumentRevisions-V100
152+
.fseventsd
153+
.Spotlight-V100
154+
.TemporaryItems
155+
.Trashes
156+
.VolumeIcon.icns
157+
.com.apple.timemachine.donotpresent
158+
159+
# Directories potentially created on remote AFP share
160+
.AppleDB
161+
.AppleDesktop
162+
Network Trash Folder
163+
Temporary Items
164+
.apdisk
165+
166+
### macOS Patch ###
167+
# iCloud generated files
168+
*.icloud

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16.13

.prettierrc.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": "*.sol",
5+
"options":
6+
{
7+
"printWidth": 80,
8+
"tabWidth": 4,
9+
"useTabs": false,
10+
"singleQuote": false,
11+
"bracketSpacing": false,
12+
"explicitTypes": "always"
13+
}
14+
}
15+
]
16+
}

.solhint.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "solhint:default",
3+
"rules": {
4+
"compiler-version": "off",
5+
"avoid-sha3": "off",
6+
"reason-string": {
7+
"0": "warn",
8+
"1": {
9+
"maxLength": 64
10+
}
11+
}
12+
}
13+
}

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CORE License v1.0
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"),
5+
to to deal in the Software without restriction, including without limitation
6+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
and/or sell copies of the Software, and to permit persons to whom the
8+
Software is furnished to do so, subject to the following conditions:
9+
10+
All distribution of the Covered Software in Source Code Form, including any
11+
Modifications and/or Contributions must be disclosed and publicly available.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY CLAIM, DAMAGES OR
17+
OTHER LIABILITIES, WHETHER IN AN ACTION OF A CONTRACT, TORT, OR OTHERWISE,
18+
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE, OR
19+
OTHER DEALINGS IN THE SOFTWARE.

README.md

100644100755
+30-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1-
# smart-contracts
2-
Ylem Smart Contracts for CorePass
1+
## CorePass Smart Contracts
2+
3+
Repository with CorePass Smart Contracts.
4+
5+
### Roles and Fields
6+
7+
A Role is an abstraction of a document. It is calculated as sha256 of the document name. The Role is a unique ID of a document.
8+
9+
Each document field also has a unique ID, calculated as sha3 of the string "SH_documentName_fieldName". So, different documents have different IDs for similar fields (phone number, etc).
10+
11+
A list of all fields, connected with the Role, is stored inside the KYCVault contract in the _roleFields mapping. This mapping doesn't have a public getter.
12+
13+
A list of all the field's parameters (parent role, required, and completed parameters) is stored inside the KYCVault contract in the _fields mapping. One could get this information about any field with the public function **field(bytes32 id)**.
14+
15+
To create a new role and connect a new list of fields to it, one must call **setRoleFields** function (only Admin). To rewrite an existing list, connected to an old role, one must call the same function. WARNING: it just sets a list of fields, connected to a role. To define the parameters of those fields, you should use **setFields**
16+
17+
To batch define or redefine required/completed parameters of fields, you should use **setFields**
18+
19+
#### Managing Roles
20+
21+
To add or modify a role one must:
22+
23+
1. call **setRoleFields** with the list of new fields, connected to this role (document)
24+
1. call **setFields** with the list of all new fields for this role, alongside two boolean lists of required and completed parameters, corresponding to the new list of fields.
25+
1. create a new KYCVoucherer for a new document, connected with this role. Call **grantRole(role, KYCVouchere.address)** in KYCVault, to get this Voucherer rights to submit.
26+
1. in KYCVoucherer call **grantRole(0, accountAddress)** for the account, that will verify the data.
27+
28+
## License
29+
30+
Licensed under the [CORE License](LICENSE).

contracts/NameService.sol

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
import {AccessControl} from "./utils/AccessControl.sol";
5+
6+
contract NameService is AccessControl {
7+
struct Service {
8+
string name;
9+
string image;
10+
address addr;
11+
}
12+
13+
Service[] private services;
14+
15+
event ServiceAdded(string name, string image, address addr);
16+
event ServiceRemoved(string name, string image, address addr);
17+
18+
function addService(
19+
string memory _name,
20+
string memory _image,
21+
address _addr
22+
) external onlyAdmin {
23+
services.push(Service(_name, _image, _addr));
24+
25+
emit ServiceAdded(_name, _image, _addr);
26+
}
27+
28+
function removeService(uint256 _index) external onlyAdmin {
29+
require(_index < services.length, "NameService: invalid index");
30+
31+
Service memory service = services[_index];
32+
33+
services[_index] = services[services.length - 1];
34+
services.pop();
35+
36+
emit ServiceRemoved(service.name, service.image, service.addr);
37+
}
38+
39+
function getServices()
40+
external
41+
view
42+
returns (
43+
string[] memory,
44+
string[] memory,
45+
address[] memory
46+
)
47+
{
48+
string[] memory names = new string[](services.length);
49+
string[] memory images = new string[](services.length);
50+
address[] memory addresses = new address[](services.length);
51+
52+
for (uint256 i = 0; i < services.length; i++) {
53+
names[i] = services[i].name;
54+
images[i] = services[i].image;
55+
addresses[i] = services[i].addr;
56+
}
57+
58+
return (names, images, addresses);
59+
}
60+
}

contracts/Registry.sol

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
import {AccessControl} from "./utils/AccessControl.sol";
5+
6+
contract Registry is AccessControl {
7+
mapping(bytes32 => bytes) private _fields;
8+
9+
event FieldSet(bytes32 indexed key, bytes value);
10+
11+
function setBatch(bytes32[] calldata keys, bytes[] calldata values)
12+
external
13+
{
14+
require(
15+
keys.length == values.length,
16+
"Registry: keys and values should have same length"
17+
);
18+
for (uint256 i = 0; i < keys.length; i++) {
19+
set(keys[i], values[i]);
20+
}
21+
}
22+
23+
function get(bytes32 key) external view returns (bytes memory) {
24+
return _fields[key];
25+
}
26+
27+
function set(bytes32 key, bytes calldata value) public onlyRole(key) {
28+
_fields[key] = value;
29+
emit FieldSet(key, value);
30+
}
31+
}

contracts/coretoken/AssetToken.sol

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
import {BaseToken} from "./BaseToken.sol";
5+
6+
contract AssetToken is BaseToken("AssetToken", "AST", 18) {
7+
constructor() {
8+
_mint(msg.sender, 10**32);
9+
}
10+
}

0 commit comments

Comments
 (0)