From 0588d64188fb87fca327fdc012f40754eeb11329 Mon Sep 17 00:00:00 2001 From: eum602 Date: Tue, 27 Jun 2023 12:17:13 -0500 Subject: [PATCH] refactor: add 'isRoot', update chain of trust abi interface --- src/constants/lacchain/chain.of.trust.abi.ts | 466 ++---------------- .../chain-of-trust/chain.of.trust.ts | 3 +- src/services/chain-of-trust/chain.of.trust.ts | 8 +- 3 files changed, 37 insertions(+), 440 deletions(-) diff --git a/src/constants/lacchain/chain.of.trust.abi.ts b/src/constants/lacchain/chain.of.trust.abi.ts index bf81e7c..6890544 100644 --- a/src/constants/lacchain/chain.of.trust.abi.ts +++ b/src/constants/lacchain/chain.of.trust.abi.ts @@ -1,40 +1,39 @@ export const CHAIN_OF_TRUST_ABI = [ { - inputs: [], - stateMutability: 'nonpayable', - type: 'constructor' - }, - { - anonymous: false, inputs: [ { - indexed: false, internalType: 'address', - name: 'previousAdmin', + name: 'trustedForwarderAddress', type: 'address' }, { - indexed: false, - internalType: 'address', - name: 'newAdmin', - type: 'address' - } - ], - name: 'AdminChanged', - type: 'event' - }, - { - anonymous: false, - inputs: [ + internalType: 'uint8', + name: 'chainDepth', + type: 'uint8' + }, + { + internalType: 'string', + name: 'did', + type: 'string' + }, { - indexed: true, internalType: 'address', - name: 'beacon', + name: 'rootEntityManager', type: 'address' + }, + { + internalType: 'uint8', + name: 'revokeMode', + type: 'uint8' + }, + { + internalType: 'bool', + name: 'rootMaintainer', + type: 'bool' } ], - name: 'BeaconUpgraded', - type: 'event' + stateMutability: 'nonpayable', + type: 'constructor' }, { anonymous: false, @@ -86,31 +85,6 @@ export const CHAIN_OF_TRUST_ABI = [ name: 'DidChanged', type: 'event' }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'by', - type: 'address' - }, - { - indexed: true, - internalType: 'address', - name: 'didRegistry', - type: 'address' - }, - { - indexed: false, - internalType: 'bool', - name: 'status', - type: 'bool' - } - ], - name: 'DidRegistryChange', - type: 'event' - }, { anonymous: false, inputs: [ @@ -197,19 +171,6 @@ export const CHAIN_OF_TRUST_ABI = [ name: 'GroupMemberRevoked', type: 'event' }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint8', - name: 'version', - type: 'uint8' - } - ], - name: 'Initialized', - type: 'event' - }, { anonymous: false, inputs: [ @@ -229,31 +190,6 @@ export const CHAIN_OF_TRUST_ABI = [ name: 'MaintainerModeChanged', type: 'event' }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'delegateType', - type: 'bytes32' - }, - { - indexed: true, - internalType: 'address', - name: 'by', - type: 'address' - }, - { - indexed: false, - internalType: 'bool', - name: 'status', - type: 'bool' - } - ], - name: 'NewDelegateTypeChange', - type: 'event' - }, { anonymous: false, inputs: [ @@ -323,19 +259,6 @@ export const CHAIN_OF_TRUST_ABI = [ name: 'RootManagerUpdated', type: 'event' }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'implementation', - type: 'address' - } - ], - name: 'Upgraded', - type: 'event' - }, { inputs: [], name: 'ALLANCESTORS', @@ -362,32 +285,6 @@ export const CHAIN_OF_TRUST_ABI = [ stateMutability: 'view', type: 'function' }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'delegateType', - type: 'bytes32' - } - ], - name: 'addDelegateType', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'didRegistryAddress', - type: 'address' - } - ], - name: 'addDidRegistry', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, { inputs: [ { @@ -411,60 +308,6 @@ export const CHAIN_OF_TRUST_ABI = [ stateMutability: 'nonpayable', type: 'function' }, - { - inputs: [ - { - internalType: 'address', - name: 'parentEntity', - type: 'address' - }, - { - internalType: 'address', - name: 'memberEntity', - type: 'address' - }, - { - internalType: 'string', - name: 'did', - type: 'string' - }, - { - internalType: 'uint256', - name: 'period', - type: 'uint256' - } - ], - name: 'addOrUpdateGroupMemberByDelegate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [], - name: 'defaultDelegateType', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [], - name: 'defaultDidRegistry', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - stateMutability: 'view', - type: 'function' - }, { inputs: [], name: 'depth', @@ -478,68 +321,6 @@ export const CHAIN_OF_TRUST_ABI = [ stateMutability: 'view', type: 'function' }, - { - inputs: [ - { - internalType: 'address', - name: '', - type: 'address' - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32' - } - ], - name: 'didDelegateTypes', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - name: 'didRegistries', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'identity', - type: 'address' - } - ], - name: 'getDidRegistry', - outputs: [ - { - internalType: 'address', - name: 'didRegistryAddress', - type: 'address' - } - ], - stateMutability: 'view', - type: 'function' - }, { inputs: [ { @@ -573,9 +354,9 @@ export const CHAIN_OF_TRUST_ABI = [ type: 'address' }, { - internalType: 'address', - name: 'didAddress', - type: 'address' + internalType: 'string', + name: 'did', + type: 'string' }, { internalType: 'bool', @@ -606,61 +387,13 @@ export const CHAIN_OF_TRUST_ABI = [ name: 'gId', type: 'uint256' }, - { - internalType: 'address', - name: 'didAddress', - type: 'address' - } - ], - stateMutability: 'view', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'trustedForwarderAddress', - type: 'address' - }, - { - internalType: 'uint8', - name: 'chainDepth', - type: 'uint8' - }, { internalType: 'string', name: 'did', type: 'string' - }, - { - internalType: 'address', - name: 'rootEntityManager', - type: 'address' - }, - { - internalType: 'uint8', - name: 'revokeMode', - type: 'uint8' - }, - { - internalType: 'bool', - name: 'rootMaintainer', - type: 'bool' - }, - { - internalType: 'address', - name: 'didRegistry', - type: 'address' - }, - { - internalType: 'bytes32', - name: 'delegateType', - type: 'bytes32' } ], - name: 'initialize', - outputs: [], - stateMutability: 'nonpayable', + stateMutability: 'view', type: 'function' }, { @@ -676,30 +409,6 @@ export const CHAIN_OF_TRUST_ABI = [ stateMutability: 'view', type: 'function' }, - { - inputs: [ - { - internalType: 'address', - name: 'identity', - type: 'address' - }, - { - internalType: 'bytes32', - name: 'delegateType', - type: 'bytes32' - } - ], - name: 'isValidDelegateType', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool' - } - ], - stateMutability: 'view', - type: 'function' - }, { inputs: [ { @@ -747,37 +456,17 @@ export const CHAIN_OF_TRUST_ABI = [ }, { inputs: [], - name: 'proxiableUUID', + name: 'prevBlock', outputs: [ { - internalType: 'bytes32', + internalType: 'uint256', name: '', - type: 'bytes32' + type: 'uint256' } ], stateMutability: 'view', type: 'function' }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'delegateType', - type: 'bytes32' - } - ], - name: 'removeDelegateType', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [], - name: 'removeDidRegistry', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, { inputs: [], name: 'renounceOwnership', @@ -834,52 +523,6 @@ export const CHAIN_OF_TRUST_ABI = [ stateMutability: 'nonpayable', type: 'function' }, - { - inputs: [ - { - internalType: 'address', - name: 'ancestor', - type: 'address' - }, - { - internalType: 'address', - name: 'memberEntity', - type: 'address' - }, - { - internalType: 'string', - name: 'did', - type: 'string' - } - ], - name: 'revokeMemberByAnyAncestorByTheirDelegate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'parentEntity', - type: 'address' - }, - { - internalType: 'address', - name: 'memberEntity', - type: 'address' - }, - { - internalType: 'string', - name: 'did', - type: 'string' - } - ], - name: 'revokeMemberByDelegate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, { inputs: [ { @@ -898,24 +541,6 @@ export const CHAIN_OF_TRUST_ABI = [ stateMutability: 'nonpayable', type: 'function' }, - { - inputs: [ - { - internalType: 'address', - name: 'memberEntity', - type: 'address' - }, - { - internalType: 'string', - name: 'did', - type: 'string' - } - ], - name: 'revokeMemberByRootByTheirDelegate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, { inputs: [ { @@ -1041,36 +666,5 @@ export const CHAIN_OF_TRUST_ABI = [ outputs: [], stateMutability: 'nonpayable', type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'newImplementation', - type: 'address' - } - ], - name: 'upgradeTo', - outputs: [], - stateMutability: 'nonpayable', - type: 'function' - }, - { - inputs: [ - { - internalType: 'address', - name: 'newImplementation', - type: 'address' - }, - { - internalType: 'bytes', - name: 'data', - type: 'bytes' - } - ], - name: 'upgradeToAndCall', - outputs: [], - stateMutability: 'payable', - type: 'function' } ]; diff --git a/src/interfaces/chain-of-trust/chain.of.trust.ts b/src/interfaces/chain-of-trust/chain.of.trust.ts index cc0cc65..4a4acbc 100644 --- a/src/interfaces/chain-of-trust/chain.of.trust.ts +++ b/src/interfaces/chain-of-trust/chain.of.trust.ts @@ -15,6 +15,7 @@ export interface ChainOfTrustMemberDetails { exp: number; gId: number; trustedBy: string; - didAddress: string; + did: string; isValid: boolean; + isRoot: boolean; } diff --git a/src/services/chain-of-trust/chain.of.trust.ts b/src/services/chain-of-trust/chain.of.trust.ts index 31b23a9..5c31f1b 100644 --- a/src/services/chain-of-trust/chain.of.trust.ts +++ b/src/services/chain-of-trust/chain.of.trust.ts @@ -37,15 +37,17 @@ export class ChainOfTrust extends LacchainBaseContract { const exp = parseInt(ethers.utils.formatUnits(member[1], 0)); const gId = parseInt(ethers.utils.formatUnits(member[2], 0)); const trustedBy = member[3]; - const didAddress = member[4]; + const did = member[4]; const isValid = member[5]; + const isRoot = gId == 1; return { iat, exp, gId, trustedBy, - didAddress, - isValid + did, + isValid, + isRoot } as ChainOfTrustMemberDetails; }