-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ayanworks/POLYNDI-45-schema-manager
feat: Implemented schema manager for W3C schema related operations
- Loading branch information
Showing
18 changed files
with
3,983 additions
and
93 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
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
node_modules | ||
.DS_Store | ||
build | ||
build | ||
.env | ||
artifacts | ||
cache |
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,166 @@ | ||
{ | ||
"manifestVersion": "3.2", | ||
"proxies": [ | ||
{ | ||
"address": "0xCdB4e190d6A5702294A7f825e04257E7ed5480a3", | ||
"txHash": "0x75d31570997138059eb7ed38c367792308d6539e1c0045415ef3b555054d9781", | ||
"kind": "transparent" | ||
}, | ||
{ | ||
"address": "0xF5B03bAaACC7dCc5a693B91b8EfD684EF52b8B68", | ||
"txHash": "0x95039b4bcca7c540f1a6be0218037078e0de50739ab6c59957095e31659eafb0", | ||
"kind": "transparent" | ||
}, | ||
{ | ||
"address": "0x568633430714858702D49c0C3E8482B70752236f", | ||
"txHash": "0x23c42837cf6ff6393fb73a9c2e6d9d19f440baac196f96898ee70b6ce89b6e3b", | ||
"kind": "transparent" | ||
} | ||
], | ||
"impls": { | ||
"ac1be2cf50e687736d809a3dbe19cb2fc2ead745f43705f7c57296f823630136": { | ||
"address": "0x84347670881A56ED2B42fab1bC157286223260D0", | ||
"txHash": "0x83fa6cf4a1a900bb316c5c94b7bb7deaea460ce4defa8c607c10f147e5d074ac", | ||
"layout": { | ||
"solcVersion": "0.8.16", | ||
"storage": [ | ||
{ | ||
"label": "owner", | ||
"offset": 0, | ||
"slot": "0", | ||
"type": "t_address", | ||
"contract": "SchemaRegistry", | ||
"src": "contracts/SchemaRegistry.sol:9" | ||
}, | ||
{ | ||
"label": "schemas", | ||
"offset": 0, | ||
"slot": "1", | ||
"type": "t_mapping(t_address,t_mapping(t_string_memory_ptr,t_struct(Schema)40_storage))", | ||
"contract": "SchemaRegistry", | ||
"src": "contracts/SchemaRegistry.sol:15" | ||
}, | ||
{ | ||
"label": "initialized", | ||
"offset": 0, | ||
"slot": "2", | ||
"type": "t_bool", | ||
"contract": "SchemaRegistry", | ||
"src": "contracts/SchemaRegistry.sol:19" | ||
} | ||
], | ||
"types": { | ||
"t_address": { | ||
"label": "address", | ||
"numberOfBytes": "20" | ||
}, | ||
"t_bool": { | ||
"label": "bool", | ||
"numberOfBytes": "1" | ||
}, | ||
"t_mapping(t_address,t_mapping(t_string_memory_ptr,t_struct(Schema)40_storage))": { | ||
"label": "mapping(address => mapping(string => struct SchemaRegistry.Schema))", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_mapping(t_string_memory_ptr,t_struct(Schema)40_storage)": { | ||
"label": "mapping(string => struct SchemaRegistry.Schema)", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_string_memory_ptr": { | ||
"label": "string", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_string_storage": { | ||
"label": "string", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_struct(Schema)40_storage": { | ||
"label": "struct SchemaRegistry.Schema", | ||
"members": [ | ||
{ | ||
"label": "schemaJson", | ||
"type": "t_string_storage", | ||
"offset": 0, | ||
"slot": "0" | ||
} | ||
], | ||
"numberOfBytes": "32" | ||
} | ||
}, | ||
"namespaces": {} | ||
} | ||
}, | ||
"2b89bc9b5130220a32261fccba0ee7dd3aaafb98bb9d4018ecbdb1be7ff48623": { | ||
"address": "0x6b045643F2c29b430427Fa0A6eaef7eE57bbC26e", | ||
"txHash": "0x715b0ee8af2c6c761628d5b4ad7273bb6b68533a935f77566e15fed8f3134a47", | ||
"layout": { | ||
"solcVersion": "0.8.16", | ||
"storage": [ | ||
{ | ||
"label": "owner", | ||
"offset": 0, | ||
"slot": "0", | ||
"type": "t_address", | ||
"contract": "SchemaRegistry", | ||
"src": "contracts/SchemaRegistry.sol:9" | ||
}, | ||
{ | ||
"label": "schemas", | ||
"offset": 0, | ||
"slot": "1", | ||
"type": "t_mapping(t_address,t_mapping(t_string_memory_ptr,t_struct(Schema)7_storage))", | ||
"contract": "SchemaRegistry", | ||
"src": "contracts/SchemaRegistry.sol:15" | ||
}, | ||
{ | ||
"label": "initialized", | ||
"offset": 0, | ||
"slot": "2", | ||
"type": "t_bool", | ||
"contract": "SchemaRegistry", | ||
"src": "contracts/SchemaRegistry.sol:19" | ||
} | ||
], | ||
"types": { | ||
"t_address": { | ||
"label": "address", | ||
"numberOfBytes": "20" | ||
}, | ||
"t_bool": { | ||
"label": "bool", | ||
"numberOfBytes": "1" | ||
}, | ||
"t_mapping(t_address,t_mapping(t_string_memory_ptr,t_struct(Schema)7_storage))": { | ||
"label": "mapping(address => mapping(string => struct SchemaRegistry.Schema))", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_mapping(t_string_memory_ptr,t_struct(Schema)7_storage)": { | ||
"label": "mapping(string => struct SchemaRegistry.Schema)", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_string_memory_ptr": { | ||
"label": "string", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_string_storage": { | ||
"label": "string", | ||
"numberOfBytes": "32" | ||
}, | ||
"t_struct(Schema)7_storage": { | ||
"label": "struct SchemaRegistry.Schema", | ||
"members": [ | ||
{ | ||
"label": "schemaJson", | ||
"type": "t_string_storage", | ||
"offset": 0, | ||
"slot": "0" | ||
} | ||
], | ||
"numberOfBytes": "32" | ||
} | ||
}, | ||
"namespaces": {} | ||
} | ||
} | ||
} | ||
} |
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,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.4.22 <0.9.0; | ||
|
||
contract Migrations { | ||
address public owner = msg.sender; | ||
uint public last_completed_migration; | ||
|
||
modifier restricted() { | ||
require( | ||
msg.sender == owner, | ||
"This function is restricted to the contract's owner" | ||
); | ||
_; | ||
} | ||
|
||
function setCompleted(uint completed) public restricted { | ||
last_completed_migration = completed; | ||
} | ||
} |
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,83 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.16; | ||
|
||
/** | ||
* @title SchemaRegistry | ||
* @dev Smart Contract for Polygon Schema Methods | ||
*/ | ||
contract SchemaRegistry { | ||
address private owner; | ||
|
||
struct Schema { | ||
string schemaJson; | ||
} | ||
|
||
mapping(address => mapping(string => Schema)) private schemas; | ||
|
||
event TransferOwnership(address indexed newOwner); | ||
event SchemaCreate(address indexed id, string schemaId, string schemaJson); | ||
bool private initialized; | ||
|
||
/** | ||
* @dev Initializes the ownership of the contract. | ||
*/ | ||
function initialize() public { | ||
require(!initialized, "Contract instance has already been initialized"); | ||
initialized = true; | ||
owner = msg.sender; | ||
} | ||
|
||
modifier onlyOwner() { | ||
require(msg.sender == owner, "Message sender is not the owner"); | ||
_; | ||
} | ||
|
||
/** | ||
* @dev Transfers the ownership of the contract. | ||
* @param _newOwner Address of the new owner. | ||
* @return Message indicating the success or failure of ownership transfer. | ||
*/ | ||
function transferOwnership(address _newOwner) public onlyOwner returns (string memory) { | ||
if (owner != _newOwner) { | ||
owner = _newOwner; | ||
emit TransferOwnership(owner); | ||
return "Ownership transferred successfully"; | ||
} else { | ||
return "Ownership cannot be transferred to the same account"; | ||
} | ||
} | ||
|
||
/* | ||
* @dev Reads the contract owner from the chain. | ||
* @return The address of the contract owner. | ||
*/ | ||
function getOwner() public view returns (address _owner) { | ||
return owner; | ||
} | ||
|
||
/* | ||
* @dev Creates a new schema. | ||
* @param _id Address identifier. | ||
* @param newSchemaId Identifier for the new schema. | ||
* @param _json JSON representation of the schema. | ||
* @return The created schema ID. | ||
*/ | ||
function createSchema(address _id, string memory newSchemaId, string memory _json) public returns (string memory schemaId) { | ||
Schema memory newSchema = Schema(_json); | ||
schemas[_id][newSchemaId] = newSchema; | ||
|
||
emit SchemaCreate(msg.sender, newSchemaId, _json); | ||
return newSchemaId; | ||
} | ||
|
||
/** | ||
* @dev Gets a schema by its ID. | ||
* @param _id Address identifier. | ||
* @param _schemaId Identifier of the schema. | ||
* @return The schema object. | ||
*/ | ||
function getSchemaById(address _id, string memory _schemaId) external view returns (Schema memory) { | ||
Schema memory schema = schemas[_id][_schemaId]; | ||
return schema; | ||
} | ||
} |
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,34 @@ | ||
/** | ||
* @type import('hardhat/config').HardhatUserConfig | ||
*/ | ||
|
||
// import 'hardhat'; | ||
require('@nomicfoundation/hardhat-ethers') | ||
require('@openzeppelin/hardhat-upgrades') | ||
require('@nomicfoundation/hardhat-verify') | ||
|
||
require('dotenv/config') | ||
|
||
module.exports = { | ||
solidity: { | ||
version: '0.8.16', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 200, | ||
}, | ||
}, | ||
}, | ||
networks: { | ||
hardhat: {}, | ||
mumbai: { | ||
url: process.env.RPCURL, // Update with Mumbai Matic RPC URL | ||
accounts: [`0x${process.env.SIGNER}`], | ||
}, | ||
}, | ||
etherscan: { | ||
apiKey: { | ||
polygonMumbai: process.env.VERIFICATION_KEY, | ||
}, | ||
}, | ||
} |
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.