Skip to content

Commit

Permalink
extracts generic functions
Browse files Browse the repository at this point in the history
drops duplicate abi generation
adds a dummy definition for local builds

updates abis

Signed-off-by: stadolf <[email protected]>
  • Loading branch information
elmariachi111 committed Oct 27, 2023
1 parent 8b1d945 commit f38c2c2
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 276 deletions.
112 changes: 112 additions & 0 deletions subgraph/abis/CrowdSale.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "AlreadyClaimed",
Expand Down Expand Up @@ -40,6 +45,11 @@
"name": "BidTooLow",
"type": "error"
},
{
"inputs": [],
"name": "FeesTooHigh",
"type": "error"
},
{
"inputs": [],
"name": "SaleAlreadyActive",
Expand Down Expand Up @@ -161,6 +171,38 @@
"name": "Failed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint16",
"name": "feeBp",
"type": "uint16"
}
],
"name": "FeesUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -243,6 +285,12 @@
"internalType": "struct Sale",
"name": "sale",
"type": "tuple"
},
{
"indexed": false,
"internalType": "uint16",
"name": "percentageFee",
"type": "uint16"
}
],
"name": "Started",
Expand Down Expand Up @@ -314,6 +362,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentFeeBp",
"outputs": [
{
"internalType": "uint16",
"name": "",
"type": "uint16"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -374,6 +435,11 @@
"internalType": "bool",
"name": "claimed",
"type": "bool"
},
{
"internalType": "uint16",
"name": "feeBp",
"type": "uint16"
}
],
"internalType": "struct SaleInfo",
Expand All @@ -384,6 +450,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand All @@ -407,6 +486,26 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "newFeeBp",
"type": "uint16"
}
],
"name": "setCurrentFeesBp",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -475,5 +574,18 @@
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
13 changes: 13 additions & 0 deletions subgraph/abis/IPNFT.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "authorizer",
"type": "address"
}
],
"name": "AuthorizerUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
60 changes: 55 additions & 5 deletions subgraph/abis/StakedLockingCrowdSale.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "AlreadyClaimed",
Expand Down Expand Up @@ -50,6 +45,11 @@
"name": "BidTooLow",
"type": "error"
},
{
"inputs": [],
"name": "FeesTooHigh",
"type": "error"
},
{
"inputs": [],
"name": "IncompatibleVestingContract",
Expand Down Expand Up @@ -227,6 +227,19 @@
"name": "Failed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint16",
"name": "feeBp",
"type": "uint16"
}
],
"name": "FeesUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -555,6 +568,12 @@
"internalType": "struct Sale",
"name": "sale",
"type": "tuple"
},
{
"indexed": false,
"internalType": "uint16",
"name": "percentageFee",
"type": "uint16"
}
],
"name": "Started",
Expand Down Expand Up @@ -664,6 +683,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "currentFeeBp",
"outputs": [
{
"internalType": "uint16",
"name": "",
"type": "uint16"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -753,6 +785,11 @@
"internalType": "bool",
"name": "claimed",
"type": "bool"
},
{
"internalType": "uint16",
"name": "feeBp",
"type": "uint16"
}
],
"internalType": "struct SaleInfo",
Expand Down Expand Up @@ -873,6 +910,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "newFeeBp",
"type": "uint16"
}
],
"name": "setCurrentFeesBp",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
45 changes: 45 additions & 0 deletions subgraph/src/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { BigInt } from '@graphprotocol/graph-ts'
import { IERC20Metadata } from '../generated/CrowdSale/IERC20Metadata'

import { ERC20Token, IPT, TimelockedToken } from '../generated/schema'

export function makeTimelockedToken(
_contract: IERC20Metadata,
underlyingToken: ERC20Token
): TimelockedToken {
let token = TimelockedToken.load(_contract._address)

if (!token) {
token = new TimelockedToken(_contract._address)
token.id = _contract._address
token.decimals = BigInt.fromI32(_contract.decimals())
token.symbol = _contract.symbol()
token.name = _contract.name()
token.underlyingToken = underlyingToken.id

let ipt = IPT.load(underlyingToken.id.toHexString())
if (ipt) {
token.ipt = ipt.id
ipt.lockedToken = token.id
ipt.save()
}
token.save()
}

return token
}

export function makeERC20Token(_contract: IERC20Metadata): ERC20Token {
let token = ERC20Token.load(_contract._address)

if (!token) {
token = new ERC20Token(_contract._address)
token.id = _contract._address
token.decimals = BigInt.fromI32(_contract.decimals())
token.symbol = _contract.symbol()
token.name = _contract.name()
token.save()
}

return token
}
Loading

0 comments on commit f38c2c2

Please sign in to comment.