Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions db/migrations/9_add_confidential_assets_pallet.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
DO $$
BEGIN
IF NOT EXISTS (select 1 from pg_type where typname = '04c7376a01') then
create type "04c7376a01" AS ENUM (
'SenderAffirmed',

Check failure on line 5 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWpy&open=AZsKCBBu_1Th2ImzOWpy&pullRequest=322
'SenderReverted',

Check failure on line 6 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWpw&open=AZsKCBBu_1Th2ImzOWpw&pullRequest=322
'SenderCounterUpdated',

Check failure on line 7 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWpu&open=AZsKCBBu_1Th2ImzOWpu&pullRequest=322
'MediatorAffirmed',

Check failure on line 8 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWpv&open=AZsKCBBu_1Th2ImzOWpv&pullRequest=322
'MediatorRejected',

Check failure on line 9 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWpz&open=AZsKCBBu_1Th2ImzOWpz&pullRequest=322
'ReceiverAffirmed',

Check failure on line 10 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWpx&open=AZsKCBBu_1Th2ImzOWpx&pullRequest=322
'ReceiverClaimed'

Check failure on line 11 in db/migrations/9_add_confidential_assets_pallet.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 3 times.

See more on https://sonarcloud.io/project/issues?id=PolymeshAssociation_polymesh-subquery&issues=AZsKCBBu_1Th2ImzOWp0&open=AZsKCBBu_1Th2ImzOWp0&pullRequest=322
);
END IF;
END
$$;

alter type "7a0b4cc03e" add value if not exists 'confidentialassets' after 'validators';

alter type "8f5a39c8ee" add value if not exists 'AccountAssetRegistered' after 'StorageDepositTransferredAndReleased';
alter type "8f5a39c8ee" add value if not exists 'AccountCurveTreeRootUpdated' after 'AccountAssetRegistered';
alter type "8f5a39c8ee" add value if not exists 'AccountRegistered' after 'AccountCurveTreeRootUpdated';
alter type "8f5a39c8ee" add value if not exists 'AccountStateLeafInserted' after 'AccountRegistered';
alter type "8f5a39c8ee" add value if not exists 'AssetCreated' after 'AccountStateLeafInserted';
alter type "8f5a39c8ee" add value if not exists 'AssetCurveTreeRootUpdated' after 'AssetCreated';
alter type "8f5a39c8ee" add value if not exists 'AssetMinted' after 'AssetCurveTreeRootUpdated';
alter type "8f5a39c8ee" add value if not exists 'AssetStateLeafUpdated' after 'AssetMinted';
alter type "8f5a39c8ee" add value if not exists 'AssetUpdated' after 'AssetStateLeafUpdated';
alter type "8f5a39c8ee" add value if not exists 'EncryptionKeyRegistered' after 'AssetUpdated';
alter type "8f5a39c8ee" add value if not exists 'FeeAccountCurveTreeRootUpdated' after 'EncryptionKeyRegistered';
alter type "8f5a39c8ee" add value if not exists 'FeeAccountDeposited' after 'FeeAccountCurveTreeRootUpdated';
alter type "8f5a39c8ee" add value if not exists 'FeeAccountStateLeafInserted' after 'FeeAccountDeposited';
alter type "8f5a39c8ee" add value if not exists 'FeeAccountUpdated' after 'FeeAccountStateLeafInserted';
alter type "8f5a39c8ee" add value if not exists 'FeeAccountWithdrawn' after 'FeeAccountUpdated';
alter type "8f5a39c8ee" add value if not exists 'MediatorAffirmed' after 'FeeAccountWithdrawn';
alter type "8f5a39c8ee" add value if not exists 'MediatorRejected' after 'MediatorAffirmed';
alter type "8f5a39c8ee" add value if not exists 'ReceiverAffirmed' after 'MediatorRejected';
alter type "8f5a39c8ee" add value if not exists 'ReceiverClaimed' after 'ReceiverAffirmed';
alter type "8f5a39c8ee" add value if not exists 'RelayerBatchedProofs' after 'ReceiverClaimed';
alter type "8f5a39c8ee" add value if not exists 'SenderAffirmed' after 'RelayerBatchedProofs';
alter type "8f5a39c8ee" add value if not exists 'SenderCounterUpdated' after 'SenderAffirmed';
alter type "8f5a39c8ee" add value if not exists 'SenderReverted' after 'SenderCounterUpdated';
alter type "8f5a39c8ee" add value if not exists 'SettlementCreated' after 'SenderReverted';
alter type "8f5a39c8ee" add value if not exists 'SettlementStatusUpdated' after 'SettlementCreated';

alter type "0bf3c7d4ef" add value if not exists 'batched_settlement' after 'ensure_updated';
alter type "0bf3c7d4ef" add value if not exists 'create_asset' after 'batched_settlement';
alter type "0bf3c7d4ef" add value if not exists 'create_settlement' after 'create_asset';
alter type "0bf3c7d4ef" add value if not exists 'execute_instant_settlement' after 'create_settlement';
alter type "0bf3c7d4ef" add value if not exists 'instant_receiver_affirmation' after 'execute_instant_settlement';
alter type "0bf3c7d4ef" add value if not exists 'instant_sender_affirmation' after 'instant_receiver_affirmation';
alter type "0bf3c7d4ef" add value if not exists 'mediator_affirmation' after 'instant_sender_affirmation';
alter type "0bf3c7d4ef" add value if not exists 'mint_asset' after 'mediator_affirmation';
alter type "0bf3c7d4ef" add value if not exists 'receiver_affirmation' after 'mint_asset';
alter type "0bf3c7d4ef" add value if not exists 'receiver_claim' after 'receiver_affirmation';
alter type "0bf3c7d4ef" add value if not exists 'register_account_assets' after 'receiver_claim';
alter type "0bf3c7d4ef" add value if not exists 'register_accounts' after 'register_account_assets';
alter type "0bf3c7d4ef" add value if not exists 'register_encryption_keys' after 'register_accounts';
alter type "0bf3c7d4ef" add value if not exists 'register_fee_accounts' after 'register_encryption_keys';
alter type "0bf3c7d4ef" add value if not exists 'relayer_submit_batched_proofs' after 'register_fee_accounts';
alter type "0bf3c7d4ef" add value if not exists 'sender_affirmation' after 'relayer_submit_batched_proofs';
alter type "0bf3c7d4ef" add value if not exists 'sender_revert' after 'sender_affirmation';
alter type "0bf3c7d4ef" add value if not exists 'sender_update_counter' after 'sender_revert';
alter type "0bf3c7d4ef" add value if not exists 'submit_batched_proofs' after 'sender_update_counter';
alter type "0bf3c7d4ef" add value if not exists 'topup_fee_accounts' after 'submit_batched_proofs';

27 changes: 27 additions & 0 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,33 @@ const filters = {
VenuesBlocked: ['handleVenuesBlocked'],
FundsMoved: ['handleConfidentialAssetMoveFunds'],
},
confidentialAssets: {
AccountAssetRegistered: ['handleDartAccountAssetRegistered'],
AccountCurveTreeRootUpdated: ['handleDartAccountCurveTreeRootUpdated'],
AccountRegistered: ['handleDartAccountRegistered'],
AccountStateLeafInserted: ['handleDartAccountStateLeafInserted'],
AssetCreated: ['handleDartAssetCreated'],
AssetCurveTreeRootUpdated: ['handleDartAssetCurveTreeRootUpdated'],
AssetMinted: ['handleDartAssetMinted'],
AssetStateLeafUpdated: ['handleDartAssetStateLeafUpdated'],
AssetUpdated: ['handleDartAssetUpdated'],
EncryptionKeyRegistered: ['handleDartEncryptionKeyRegistered'],
FeeAccountCurveTreeRootUpdated: ['handleDartFeeAccountCurveTreeRootUpdated'],
FeeAccountDeposited: ['handleDartFeeAccountDeposited'],
FeeAccountStateLeafInserted: ['handleDartFeeAccountStateLeafInserted'],
FeeAccountUpdated: ['handleDartFeeAccountUpdated'],
FeeAccountWithdrawn: ['handleDartFeeAccountWithdrawn'],
MediatorAffirmed: ['handleDartMediatorAffirmed'],
MediatorRejected: ['handleDartMediatorRejected'],
ReceiverAffirmed: ['handleDartReceiverAffirmed'],
ReceiverClaimed: ['handleDartReceiverClaimed'],
RelayerBatchedProofs: ['handleDartRelayerBatchedProofs'],
SenderAffirmed: ['handleDartSenderAffirmed'],
SenderCounterUpdated: ['handleDartSenderCounterUpdated'],
SenderReverted: ['handleDartSenderReverted'],
SettlementCreated: ['handleDartSettlementCreated'],
SettlementStatusUpdated: ['handleDartSettlementStatusUpdated'],
},
corporateAction: {
CAInitiated: [],
CALinkedToDoc: [],
Expand Down
278 changes: 278 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3033,6 +3033,284 @@ type ConfidentialAssetMovement @entity {
createdEvent: Event!
}

## DART confidential assets ##

enum DartLegActionEnum {
SenderAffirmed
SenderReverted
SenderCounterUpdated
MediatorAffirmed
MediatorRejected
ReceiverAffirmed
ReceiverClaimed
}

"""
Represents an encryption key registered on the DART confidential assets pallet
"""
type DartConfidentialEncryptionKey @entity {
id: ID!
caller: Identity!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Represents a confidential account registered on the DART confidential assets pallet
"""
type DartConfidentialAccount @entity {
id: ID!
caller: Identity!
encryptionKey: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
assets: [DartConfidentialAccountAsset!]! @derivedFrom(field: "account")
}

"""
Links a confidential account to an asset registration
"""
type DartConfidentialAccountAsset @entity {
id: ID!
account: DartConfidentialAccount!
assetId: Int!
caller: Identity!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Stores account curve tree root updates
"""
type DartConfidentialAccountCurveRoot @entity {
id: ID!
root: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Stores account state leaf insertions
"""
type DartConfidentialAccountStateLeaf @entity {
id: ID!
leafIndex: BigInt!
commitment: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Represents a confidential asset created on the DART confidential assets pallet
"""
type DartConfidentialAsset @entity {
id: ID!
assetId: Int!
caller: Identity!
mediators: [String!]
auditors: [String!]
name: String!
symbol: String!
decimals: Int!
data: String
totalSupply: BigInt
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
mints: [DartConfidentialAssetMint!]! @derivedFrom(field: "asset")
}

"""
Captures updates to mediators/auditors for a confidential asset
"""
type DartConfidentialAssetUpdate @entity {
id: ID!
asset: DartConfidentialAsset!
mediators: [String!]
auditors: [String!]
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Stores asset curve tree root updates
"""
type DartConfidentialAssetCurveRoot @entity {
id: ID!
root: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Stores asset state leaf updates
"""
type DartConfidentialAssetStateLeaf @entity {
id: ID!
leafIndex: BigInt!
leaf: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Represents a mint of a DART confidential asset
"""
type DartConfidentialAssetMint @entity {
id: ID!
asset: DartConfidentialAsset! @index(unique: false)
account: DartConfidentialAccount
caller: Identity!
amount: BigInt!
totalSupply: BigInt!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Represents a fee account registration or top-up event
"""
type DartConfidentialFeeAccount @entity {
id: ID!
account: String!
caller: Identity!
isRegistration: Boolean!
amount: BigInt!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Stores fee account curve tree root updates
"""
type DartConfidentialFeeAccountCurveRoot @entity {
id: ID!
root: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Stores fee account state leaf insertions
"""
type DartConfidentialFeeAccountStateLeaf @entity {
id: ID!
leafIndex: BigInt!
commitment: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Captures deposits into the fee account
"""
type DartConfidentialFeeAccountDeposit @entity {
id: ID!
sender: String!
amount: BigInt!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Captures withdrawals from the fee account
"""
type DartConfidentialFeeAccountWithdraw @entity {
id: ID!
receiver: String!
amount: BigInt!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Captures actions on a settlement leg
"""
type DartConfidentialLegAction @entity {
id: ID!
legRef: String!
action: DartLegActionEnum!
keyIndex: Int
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Captures relayer batch submissions
"""
type DartConfidentialRelayerBatch @entity {
id: ID!
relayer: String!
amount: BigInt!
batchHash: String!
batchResult: String
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Represents a confidential settlement on DART
"""
type DartConfidentialSettlement @entity {
id: ID!
settlementRef: String!
memo: String
assetRootBlock: Int!
legs: [String!]!
status: String
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
statuses: [DartConfidentialSettlementStatus!]! @derivedFrom(field: "settlement")
}

"""
Tracks settlement status changes
"""
type DartConfidentialSettlementStatus @entity {
id: ID!
settlement: DartConfidentialSettlement!
status: String!
eventIdx: Int!
createdBlock: Block!
updatedBlock: Block!
createdEvent: Event!
}

"""
Represent asset pre-approvals from an Identity. These entries will not require an affirmation when the identity is receiving them
"""
Expand Down
Loading