-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Encryption dependency for signature parsing * Added migration to track ownership changes * Updated OwnershipChanges.md doc closes: #247
- Loading branch information
Carolyn Russell
committed
Dec 9, 2021
1 parent
61c2145
commit 883b957
Showing
7 changed files
with
179 additions
and
16 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
57 changes: 57 additions & 0 deletions
57
database/src/main/resources/db/migration/V1_39__Add_scope_transfers.sql
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,57 @@ | ||
SELECT 'Add nft_scope_value_owner' AS comment; | ||
CREATE TABLE IF NOT EXISTS nft_scope_value_owner | ||
( | ||
id SERIAL PRIMARY KEY, | ||
scope_id INT NOT NULL, | ||
scope_addr VARCHAR(128) NOT NULL, | ||
value_owner VARCHAR(256) NOT NULL, | ||
tx_id INT NOT NULL, | ||
block_height INT NOT NULL, | ||
tx_hash VARCHAR(64) NOT NULL | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS nft_scope_vo_scope_address_tx_idx | ||
ON nft_scope_value_owner (scope_id, value_owner, tx_id); | ||
CREATE INDEX IF NOT EXISTS nft_scope_vo_scope_id_idx ON nft_scope_value_owner (scope_id); | ||
CREATE INDEX IF NOT EXISTS nft_scope_vo_scope_addr_idx ON nft_scope_value_owner (scope_addr); | ||
CREATE INDEX IF NOT EXISTS nft_scope_vo_address_idx ON nft_scope_value_owner (value_owner); | ||
CREATE INDEX IF NOT EXISTS nft_scope_vo_block_height_idx ON nft_scope_value_owner (block_height); | ||
|
||
|
||
SELECT 'Add nft_scope_owner' AS comment; | ||
CREATE TABLE IF NOT EXISTS nft_scope_owner | ||
( | ||
id SERIAL PRIMARY KEY, | ||
scope_id INT NOT NULL, | ||
scope_addr VARCHAR(128) NOT NULL, | ||
owners_data JSONB NOT NULL, | ||
owners_data_hash TEXT NOT NULL, | ||
tx_id INT NOT NULL, | ||
block_height INT NOT NULL, | ||
tx_hash VARCHAR(64) NOT NULL | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS nft_scope_owner_scope_owners_data_tx_idx | ||
ON nft_scope_owner (scope_id, owners_data_hash, tx_id); | ||
CREATE INDEX IF NOT EXISTS nft_scope_owner_scope_id_idx ON nft_scope_owner (scope_id); | ||
CREATE INDEX IF NOT EXISTS nft_scope_owner_scope_addr_idx ON nft_scope_owner (scope_addr); | ||
CREATE INDEX IF NOT EXISTS nft_scope_owner_block_height_idx ON nft_scope_owner (block_height); | ||
|
||
SELECT 'Add nft_scope_data_access' AS comment; | ||
CREATE TABLE IF NOT EXISTS nft_scope_data_access | ||
( | ||
id SERIAL PRIMARY KEY, | ||
scope_id INT NOT NULL, | ||
scope_addr VARCHAR(128) NOT NULL, | ||
access_data JSONB NOT NULL, | ||
access_data_hash TEXT NOT NULL, | ||
tx_id INT NOT NULL, | ||
block_height INT NOT NULL, | ||
tx_hash VARCHAR(64) NOT NULL | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS nft_scope_data_access_scope_access_data_tx_idx | ||
ON nft_scope_data_access (scope_id, access_data_hash, tx_id); | ||
CREATE INDEX IF NOT EXISTS nft_scope_data_access_scope_id_idx ON nft_scope_data_access (scope_id); | ||
CREATE INDEX IF NOT EXISTS nft_scope_data_access_scope_addr_idx ON nft_scope_data_access (scope_addr); | ||
CREATE INDEX IF NOT EXISTS nft_scope_data_access_block_height_idx ON nft_scope_data_access (block_height); |
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 +1,110 @@ | ||
Track when a scope owner/value owner/data access is initiated or updated. | ||
# Owner / Valueowner / Data Access changes | ||
* track when the values change | ||
* use to count how many scopes the address owns / value owns | ||
|
||
### Owner changes | ||
* Can only be updated through a WriteScopeRequest or {Add|Delete}ScopeOwnerRequest | ||
* can be 1 or more entries | ||
|
||
### ValueOwner changes | ||
* Can only be updated through a WriteScopeRequest | ||
* only 1 entry | ||
|
||
### Data Access changes | ||
* Can be updated by P8eMemorializeContract - Adds only | ||
* Can be updated through a WriteScopeRequest or {Add|Delete}ScopeDataAccess | ||
* Can be 0 or more entries | ||
|
||
|
||
## Owner Changes | ||
* `nft_scope_owner` | ||
* id SERIAL PRIMARY KEY, | ||
* scope_id INT NOT NULL, | ||
* scope_addr VARCHAR(128) NOT NULL, | ||
* tx_id INT NOT NULL, | ||
* block_height INT NOT NULL, | ||
* tx_hash VARCHAR(64) NOT NULL, | ||
* owners_data JSONB NOT NULL, | ||
* owners_data_hash TEXT NOT NULL | ||
|
||
* owners_data object | ||
* list | ||
* owner | ||
* role - list | ||
|
||
* on insert, check for latest data, and compare hashes | ||
* to ensure compatibility, order owners alphabetically, then save/compare/hash | ||
|
||
* on fetch, gather list of objects, sorted by height | ||
* first record, all adds | ||
* second record, | ||
* if new address, add | ||
* if address doesnt exist, removal | ||
|
||
|
||
## Value Owner Changes | ||
* `nft_scope_value_owner` | ||
* id SERIAL PRIMARY KEY, | ||
* scope_id INT NOT NULL, | ||
* scope_addr VARCHAR(128) NOT NULL, | ||
* tx_id INT NOT NULL, | ||
* block_height INT NOT NULL, | ||
* tx_hash VARCHAR(64) NOT NULL, | ||
* value_owner VARCHAR(256) NOT NULL | ||
|
||
* on insert, check for latest data, and compare value_owner | ||
|
||
* on fetch, gather list of objects, sorted by height | ||
|
||
|
||
## Data Access Changes | ||
* `nft_scope_owner` | ||
* id SERIAL PRIMARY KEY, | ||
* scope_id INT NOT NULL, | ||
* scope_addr VARCHAR(128) NOT NULL, | ||
* tx_id INT NOT NULL, | ||
* block_height INT NOT NULL, | ||
* tx_hash VARCHAR(64) NOT NULL, | ||
* access_data JSONB NOT NULL, | ||
* access_data_hash TEXT NOT NULL | ||
|
||
* access_data object | ||
* address - list | ||
|
||
* on insert, check for latest data, and compare hashes | ||
* to ensure compatibility, order addresses alphabetically, then save/compare/hash | ||
|
||
* on fetch, gather list of objects, sorted by height | ||
* first record, all adds | ||
* second record, | ||
* if new address, add | ||
* if address doesnt exist, removal | ||
|
||
|
||
## Scraping | ||
* ensure its a successful tx before writing records | ||
|
||
* p8e memorialize | ||
* will need to scrape for the fields | ||
* will need to use the encryption stuff to decipher | ||
``` | ||
p8EData.Scope.Owners = contractRecitalParties | ||
p8EData.Scope.DataAccess = partyAddresses(contractRecitalParties) | ||
p8EData.Scope.ValueOwnerAddress, err = getValueOwner(msg.Contract.Invoker, msg.Contract.Recitals) | ||
if err != nil { | ||
return p8EData, err | ||
} | ||
``` | ||
|
||
* Write Scope | ||
* scrape for the fields | ||
|
||
* {Add|Delete}Scope{Owner|DataAccess} | ||
* scrape for fields | ||
* take last set of data, update and insert into table | ||
|
||
## API | ||
* Fetch value owner changes | ||
* Fetch owner changes | ||
* Fetch data access changes | ||
|
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
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