mirror of
				https://github.com/Instadapp/compound-dsa-managers.git
				synced 2024-07-29 21:48:19 +00:00 
			
		
		
		
	multiple market support
This commit is contained in:
		
							parent
							
								
									48b8b717b0
								
							
						
					
					
						commit
						7cfb43190c
					
				|  | @ -1,14 +1,16 @@ | ||||||
| type Owner @entity { | type Owner @entity { | ||||||
|   # address of the owner. |   # address of the owner + "#" + market Address. | ||||||
|   id: ID! |   id: ID! | ||||||
|   # address of the owner. |   # address of the owner. | ||||||
|   address: Bytes! |   address: Bytes! | ||||||
|  |   # compound market address | ||||||
|  |   market: Bytes! | ||||||
|   # lists of all enabled and disabled managers. |   # lists of all enabled and disabled managers. | ||||||
|   manager: [Manager!]! @derivedFrom(field: "owner") |   manager: [Manager!]! @derivedFrom(field: "owner") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Manager @entity { | type Manager @entity { | ||||||
|   # manager address + "#" + owner address. |   # manager address + "#" + owner address + "#" + market address. | ||||||
|   id: ID! |   id: ID! | ||||||
|   # address of the manager. |   # address of the manager. | ||||||
|   address: Bytes! |   address: Bytes! | ||||||
|  | @ -18,12 +20,14 @@ type Manager @entity { | ||||||
|   isAllowed: Boolean! |   isAllowed: Boolean! | ||||||
|   # whether the manager is DSA or not. |   # whether the manager is DSA or not. | ||||||
|   isDSA: Boolean! |   isDSA: Boolean! | ||||||
|  |   # compound market address | ||||||
|  |   market: Bytes! | ||||||
|   # transction details of the transaction when manager enabled or disabled.  |   # transction details of the transaction when manager enabled or disabled.  | ||||||
|   transactionData: TransactionData! |   transactionData: TransactionData! | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type TransactionData @entity { | type TransactionData @entity { | ||||||
|   # transaction hash |   # transaction hash + "#" + log index | ||||||
|   id: ID! |   id: ID! | ||||||
|   # transaction index |   # transaction index | ||||||
|   txnIndex: BigInt! |   txnIndex: BigInt! | ||||||
|  |  | ||||||
|  | @ -5,8 +5,8 @@ import { | ||||||
| import { createOrLoadManager, createOrLoadOwner, createOrLoadTransaction, isDSA, ZERO } from "./utils"; | import { createOrLoadManager, createOrLoadOwner, createOrLoadTransaction, isDSA, ZERO } from "./utils"; | ||||||
| 
 | 
 | ||||||
| export function handleManagerToggled(event: Approval): void { | export function handleManagerToggled(event: Approval): void { | ||||||
|   let ownerID = event.params.owner.toHexString(); |   let ownerID = event.params.owner.toHexString() + "#" + event.address.toHexString(); | ||||||
|   let managerID = event.params.spender.toHexString() + "#" + event.params.owner.toHexString(); |   let managerID = event.params.spender.toHexString() + "#" + event.params.owner.toHexString() + "#" + event.address.toHexString(); | ||||||
|   let transactionID = event.transaction.hash.toHexString() +  "#" + event.logIndex.toString(); |   let transactionID = event.transaction.hash.toHexString() +  "#" + event.logIndex.toString(); | ||||||
| 
 | 
 | ||||||
|   let transactionData = createOrLoadTransaction(transactionID); |   let transactionData = createOrLoadTransaction(transactionID); | ||||||
|  | @ -26,11 +26,13 @@ export function handleManagerToggled(event: Approval): void { | ||||||
|   manager.address = event.params.spender; |   manager.address = event.params.spender; | ||||||
|   manager.isAllowed = event.params.amount == ZERO ? false : true; |   manager.isAllowed = event.params.amount == ZERO ? false : true; | ||||||
|   manager.owner = ownerID; |   manager.owner = ownerID; | ||||||
|  |   manager.market = event.address; | ||||||
|   manager.isDSA = isDSA(event.params.spender); |   manager.isDSA = isDSA(event.params.spender); | ||||||
|   manager.transactionData = transactionID; |   manager.transactionData = transactionID; | ||||||
| 
 | 
 | ||||||
|   let owner = createOrLoadOwner(ownerID); |   let owner = createOrLoadOwner(ownerID); | ||||||
|   owner.address = event.params.owner; |   owner.address = event.params.owner; | ||||||
|  |   owner.market = event.address; | ||||||
| 
 | 
 | ||||||
|   transactionData.save(); |   transactionData.save(); | ||||||
|   manager.save(); |   manager.save(); | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ export function createOrLoadOwner(id: string): Owner { | ||||||
|   if (account == null) { |   if (account == null) { | ||||||
|     account = new Owner(id); |     account = new Owner(id); | ||||||
|     account.address = new Address(0); |     account.address = new Address(0); | ||||||
|  |     account.market = new Address(0); | ||||||
|   } |   } | ||||||
|   return account; |   return account; | ||||||
| } | } | ||||||
|  | @ -36,6 +37,7 @@ export function createOrLoadManager(id: string): Manager { | ||||||
|   if (account == null) { |   if (account == null) { | ||||||
|     account = new Manager(id); |     account = new Manager(id); | ||||||
|     account.address = new Address(0); |     account.address = new Address(0); | ||||||
|  |     account.market = new Address(0); | ||||||
|     account.owner = ""; |     account.owner = ""; | ||||||
|     account.isAllowed = false; |     account.isAllowed = false; | ||||||
|     account.isDSA = false; |     account.isDSA = false; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Richa-iitr
						Richa-iitr