-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
314 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "sender", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "string", | ||
"name": "configId", | ||
"type": "string" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "value", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "ConfigUpdated", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "user", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "string[]", | ||
"name": "ids", | ||
"type": "string[]" | ||
} | ||
], | ||
"name": "getValues", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256[]", | ||
"name": "values", | ||
"type": "uint256[]" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "string[]", | ||
"name": "ids", | ||
"type": "string[]" | ||
}, | ||
{ | ||
"internalType": "uint256[]", | ||
"name": "values", | ||
"type": "uint256[]" | ||
} | ||
], | ||
"name": "setValues", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
|
||
import { | ||
ethereum, | ||
JSONValue, | ||
TypedMap, | ||
Entity, | ||
Bytes, | ||
Address, | ||
BigInt, | ||
} from "@graphprotocol/graph-ts"; | ||
|
||
export class ConfigUpdated extends ethereum.Event { | ||
get params(): ConfigUpdated__Params { | ||
return new ConfigUpdated__Params(this); | ||
} | ||
} | ||
|
||
export class ConfigUpdated__Params { | ||
_event: ConfigUpdated; | ||
|
||
constructor(event: ConfigUpdated) { | ||
this._event = event; | ||
} | ||
|
||
get sender(): Address { | ||
return this._event.parameters[0].value.toAddress(); | ||
} | ||
|
||
get configId(): Bytes { | ||
return this._event.parameters[1].value.toBytes(); | ||
} | ||
|
||
get value(): BigInt { | ||
return this._event.parameters[2].value.toBigInt(); | ||
} | ||
} | ||
|
||
export class IVeDelegateConfigs extends ethereum.SmartContract { | ||
static bind(address: Address): IVeDelegateConfigs { | ||
return new IVeDelegateConfigs("IVeDelegateConfigs", address); | ||
} | ||
|
||
getValues(user: Address, ids: Array<string>): Array<BigInt> { | ||
let result = super.call( | ||
"getValues", | ||
"getValues(address,string[]):(uint256[])", | ||
[ethereum.Value.fromAddress(user), ethereum.Value.fromStringArray(ids)], | ||
); | ||
|
||
return result[0].toBigIntArray(); | ||
} | ||
|
||
try_getValues( | ||
user: Address, | ||
ids: Array<string>, | ||
): ethereum.CallResult<Array<BigInt>> { | ||
let result = super.tryCall( | ||
"getValues", | ||
"getValues(address,string[]):(uint256[])", | ||
[ethereum.Value.fromAddress(user), ethereum.Value.fromStringArray(ids)], | ||
); | ||
if (result.reverted) { | ||
return new ethereum.CallResult(); | ||
} | ||
let value = result.value; | ||
return ethereum.CallResult.fromValue(value[0].toBigIntArray()); | ||
} | ||
} | ||
|
||
export class SetValuesCall extends ethereum.Call { | ||
get inputs(): SetValuesCall__Inputs { | ||
return new SetValuesCall__Inputs(this); | ||
} | ||
|
||
get outputs(): SetValuesCall__Outputs { | ||
return new SetValuesCall__Outputs(this); | ||
} | ||
} | ||
|
||
export class SetValuesCall__Inputs { | ||
_call: SetValuesCall; | ||
|
||
constructor(call: SetValuesCall) { | ||
this._call = call; | ||
} | ||
|
||
get ids(): Array<string> { | ||
return this._call.inputValues[0].value.toStringArray(); | ||
} | ||
|
||
get values(): Array<BigInt> { | ||
return this._call.inputValues[1].value.toBigIntArray(); | ||
} | ||
} | ||
|
||
export class SetValuesCall__Outputs { | ||
_call: SetValuesCall; | ||
|
||
constructor(call: SetValuesCall) { | ||
this._call = call; | ||
} | ||
} |
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,17 @@ | ||
import { ConfigUpdated as ConfigUpdatedEvent } from '../generated/vedelegate-configs/IVeDelegateConfigs' | ||
import { fetchAccount } from '../node_modules/@openzeppelin/subgraphs/src/fetch/account' | ||
import { VeDelegateConfig } from '../generated/schema'; | ||
|
||
export function handleConfigUpdated(event: ConfigUpdatedEvent): void { | ||
let sender = fetchAccount(event.params.sender) | ||
const id = [sender.id.toHexString(), event.params.configId.toHexString()].join('/') | ||
let config = VeDelegateConfig.load(id) | ||
if (!config) { | ||
config = new VeDelegateConfig(id) | ||
config.account = sender.id | ||
} | ||
|
||
config.configId = event.params.configId.toHexString() | ||
config.value = event.params.value | ||
config.save() | ||
} |
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