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 { | ||||
|   # address of the owner. | ||||
|   # address of the owner + "#" + market Address. | ||||
|   id: ID! | ||||
|   # address of the owner. | ||||
|   address: Bytes! | ||||
|   # compound market address | ||||
|   market: Bytes! | ||||
|   # lists of all enabled and disabled managers. | ||||
|   manager: [Manager!]! @derivedFrom(field: "owner") | ||||
| } | ||||
| 
 | ||||
| type Manager @entity { | ||||
|   # manager address + "#" + owner address. | ||||
|   # manager address + "#" + owner address + "#" + market address. | ||||
|   id: ID! | ||||
|   # address of the manager. | ||||
|   address: Bytes! | ||||
|  | @ -18,12 +20,14 @@ type Manager @entity { | |||
|   isAllowed: Boolean! | ||||
|   # whether the manager is DSA or not. | ||||
|   isDSA: Boolean! | ||||
|   # compound market address | ||||
|   market: Bytes! | ||||
|   # transction details of the transaction when manager enabled or disabled.  | ||||
|   transactionData: TransactionData! | ||||
| } | ||||
| 
 | ||||
| type TransactionData @entity { | ||||
|   # transaction hash | ||||
|   # transaction hash + "#" + log index | ||||
|   id: ID! | ||||
|   # transaction index | ||||
|   txnIndex: BigInt! | ||||
|  |  | |||
|  | @ -5,8 +5,8 @@ import { | |||
| import { createOrLoadManager, createOrLoadOwner, createOrLoadTransaction, isDSA, ZERO } from "./utils"; | ||||
| 
 | ||||
| export function handleManagerToggled(event: Approval): void { | ||||
|   let ownerID = event.params.owner.toHexString(); | ||||
|   let managerID = event.params.spender.toHexString() + "#" + event.params.owner.toHexString(); | ||||
|   let ownerID = event.params.owner.toHexString() + "#" + event.address.toHexString(); | ||||
|   let managerID = event.params.spender.toHexString() + "#" + event.params.owner.toHexString() + "#" + event.address.toHexString(); | ||||
|   let transactionID = event.transaction.hash.toHexString() +  "#" + event.logIndex.toString(); | ||||
| 
 | ||||
|   let transactionData = createOrLoadTransaction(transactionID); | ||||
|  | @ -26,11 +26,13 @@ export function handleManagerToggled(event: Approval): void { | |||
|   manager.address = event.params.spender; | ||||
|   manager.isAllowed = event.params.amount == ZERO ? false : true; | ||||
|   manager.owner = ownerID; | ||||
|   manager.market = event.address; | ||||
|   manager.isDSA = isDSA(event.params.spender); | ||||
|   manager.transactionData = transactionID; | ||||
| 
 | ||||
|   let owner = createOrLoadOwner(ownerID); | ||||
|   owner.address = event.params.owner; | ||||
|   owner.market = event.address; | ||||
| 
 | ||||
|   transactionData.save(); | ||||
|   manager.save(); | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ export function createOrLoadOwner(id: string): Owner { | |||
|   if (account == null) { | ||||
|     account = new Owner(id); | ||||
|     account.address = new Address(0); | ||||
|     account.market = new Address(0); | ||||
|   } | ||||
|   return account; | ||||
| } | ||||
|  | @ -36,6 +37,7 @@ export function createOrLoadManager(id: string): Manager { | |||
|   if (account == null) { | ||||
|     account = new Manager(id); | ||||
|     account.address = new Address(0); | ||||
|     account.market = new Address(0); | ||||
|     account.owner = ""; | ||||
|     account.isAllowed = false; | ||||
|     account.isDSA = false; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Richa-iitr
						Richa-iitr