-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add transfer entity and deposit amount fields in user [SF-962]
- Loading branch information
1 parent
9357b88
commit d6e6a3a
Showing
7 changed files
with
296 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
import { Deposit } from '../generated/TokenVault/TokenVault'; | ||
import { getOrInitUser } from './helper/initializer'; | ||
import { Deposit, Withdraw } from '../generated/TokenVault/TokenVault'; | ||
import { initTransfer } from './helper/initializer'; | ||
|
||
export function handleDeposit(event: Deposit): void { | ||
getOrInitUser(event.params.user, event.block.timestamp); | ||
const id = | ||
event.transaction.hash.toHexString() + ':' + event.logIndex.toString(); | ||
initTransfer( | ||
id, | ||
event.params.user, | ||
event.params.ccy, | ||
event.params.amount, | ||
'Deposit', | ||
event.block.timestamp, | ||
event.block.number, | ||
event.transaction.hash | ||
); | ||
} | ||
|
||
export function handleWithdraw(event: Withdraw): void { | ||
const id = | ||
event.transaction.hash.toHexString() + ':' + event.logIndex.toString(); | ||
initTransfer( | ||
id, | ||
event.params.user, | ||
event.params.ccy, | ||
event.params.amount, | ||
'Withdraw', | ||
event.block.timestamp, | ||
event.block.number, | ||
event.transaction.hash | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './lending-controller'; | ||
export * from './lending-market'; | ||
export * from './liquidation'; | ||
export * from './token-vault'; |
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,70 @@ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
import { Address, BigInt, Bytes, ethereum } from '@graphprotocol/graph-ts'; | ||
import { newMockEvent } from 'matchstick-as/assembly/index'; | ||
import { Deposit, Withdraw } from '../../generated/TokenVault/TokenVault'; | ||
|
||
export function createDepositEvent( | ||
user: Address, | ||
ccy: Bytes, | ||
amount: BigInt | ||
): Deposit { | ||
const mockEvent = newMockEvent(); | ||
const event = new Deposit( | ||
mockEvent.address, | ||
mockEvent.logIndex, | ||
mockEvent.transactionLogIndex, | ||
mockEvent.logType, | ||
mockEvent.block, | ||
mockEvent.transaction, | ||
mockEvent.parameters, | ||
mockEvent.receipt | ||
); | ||
|
||
event.parameters = new Array(); | ||
event.parameters.push( | ||
new ethereum.EventParam('user', ethereum.Value.fromAddress(user)) | ||
); | ||
event.parameters.push( | ||
new ethereum.EventParam('ccy', ethereum.Value.fromBytes(ccy)) | ||
); | ||
event.parameters.push( | ||
new ethereum.EventParam( | ||
'amount', | ||
ethereum.Value.fromUnsignedBigInt(amount) | ||
) | ||
); | ||
return event; | ||
} | ||
|
||
export function createWithdrawEvent( | ||
user: Address, | ||
ccy: Bytes, | ||
amount: BigInt | ||
): Withdraw { | ||
const mockEvent = newMockEvent(); | ||
const event = new Withdraw( | ||
mockEvent.address, | ||
mockEvent.logIndex, | ||
mockEvent.transactionLogIndex, | ||
mockEvent.logType, | ||
mockEvent.block, | ||
mockEvent.transaction, | ||
mockEvent.parameters, | ||
mockEvent.receipt | ||
); | ||
|
||
event.parameters = new Array(); | ||
event.parameters.push( | ||
new ethereum.EventParam('user', ethereum.Value.fromAddress(user)) | ||
); | ||
event.parameters.push( | ||
new ethereum.EventParam('ccy', ethereum.Value.fromBytes(ccy)) | ||
); | ||
event.parameters.push( | ||
new ethereum.EventParam( | ||
'amount', | ||
ethereum.Value.fromUnsignedBigInt(amount) | ||
) | ||
); | ||
return event; | ||
} |
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