Skip to content

Commit

Permalink
feat: add SingleRequestProxyFactory subgraph (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
aimensahnoun authored Nov 5, 2024
1 parent bda8d6a commit ac12613
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 10 deletions.
282 changes: 282 additions & 0 deletions abis/SingleRequestProxyFactory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_ethereumFeeProxy",
"type": "address"
},
{
"internalType": "address",
"name": "_erc20FeeProxy",
"type": "address"
},
{
"internalType": "address",
"name": "_owner",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "newERC20FeeProxy",
"type": "address"
}
],
"name": "ERC20FeeProxyUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "proxyAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "payee",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"indexed": true,
"internalType": "bytes",
"name": "paymentReference",
"type": "bytes"
}
],
"name": "ERC20SingleRequestProxyCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "newEthereumFeeProxy",
"type": "address"
}
],
"name": "EthereumFeeProxyUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "proxyAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "payee",
"type": "address"
},
{
"indexed": true,
"internalType": "bytes",
"name": "paymentReference",
"type": "bytes"
}
],
"name": "EthereumSingleRequestProxyCreated",
"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"
},
{
"inputs": [
{
"internalType": "address",
"name": "_payee",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenAddress",
"type": "address"
},
{
"internalType": "bytes",
"name": "_paymentReference",
"type": "bytes"
},
{
"internalType": "address",
"name": "_feeAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "_feeAmount",
"type": "uint256"
}
],
"name": "createERC20SingleRequestProxy",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_payee",
"type": "address"
},
{
"internalType": "bytes",
"name": "_paymentReference",
"type": "bytes"
},
{
"internalType": "address",
"name": "_feeAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "_feeAmount",
"type": "uint256"
}
],
"name": "createEthereumSingleRequestProxy",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "erc20FeeProxy",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ethereumFeeProxy",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_newERC20FeeProxy",
"type": "address"
}
],
"name": "setERC20FeeProxy",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_newEthereumFeeProxy",
"type": "address"
}
],
"name": "setEthereumFeeProxy",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
16 changes: 11 additions & 5 deletions cli/lib/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ethConversionArtifact,
erc20EscrowToPayArtifact,
erc20TransferableReceivableArtifact,
singleRequestProxyFactoryArtifact,
} from "@requestnetwork/smart-contracts";
import { EventFragment } from "@ethersproject/abi";
import { camelCase } from "lodash";
Expand All @@ -24,6 +25,7 @@ const paymentNetworks = {
EthConversionProxy: ethConversionArtifact,
ERC20EscrowToPay: erc20EscrowToPayArtifact,
ERC20TransferrableReceivable: erc20TransferableReceivableArtifact,
SingleRequestProxyFactory: singleRequestProxyFactoryArtifact,
};

type DataSource = {
Expand All @@ -44,14 +46,14 @@ type DataSource = {
const getArtifactInfo = (artifact: ContractArtifact<any>, network: string) => {
return artifact
.getAllAddresses(network)
.filter(x => Boolean(x.address))
.filter((x) => Boolean(x.address))
.map(({ version }) => ({
...artifact.getDeploymentInformation(network, version),
version,
}))
.filter(
(artifact, index, self) =>
self.findIndex(x => x.address === artifact.address) === index,
self.findIndex((x) => x.address === artifact.address) === index,
);
};

Expand All @@ -64,6 +66,8 @@ const ignoredEvents = [
"ApprovalForAll",
"Transfer",
"TransferableReceivablePayment",
"EthereumFeeProxyUpdated",
"ERC20FeeProxyUpdated",
];

export const getManifest = (
Expand All @@ -76,6 +80,8 @@ export const getManifest = (
let graphEntities: string[];
if (pn === "ERC20EscrowToPay") {
graphEntities = ["Payment", "Escrow", "EscrowEvent"];
} else if (pn === "SingleRequestProxyFactory") {
graphEntities = ["SingleRequestProxyDeployment"];
} else {
graphEntities = ["Payment"];
}
Expand All @@ -91,9 +97,9 @@ export const getManifest = (
infoArray.forEach(({ address, creationBlockNumber, version }) => {
const events = artifact
.getContractAbi(version)
.filter(x => x.type === "event")
.filter(x => x.name && !ignoredEvents.includes(x.name))
.map(x => ({
.filter((x) => x.type === "event")
.filter((x) => x.name && !ignoredEvents.includes(x.name))
.map((x) => ({
handlerName: "handle" + x.name,
eventSignature: EventFragment.fromObject(x)
.format("minimal")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@graphprotocol/graph-cli": "^0.81.0",
"@graphprotocol/graph-ts": "^0.35.1",
"@requestnetwork/smart-contracts": "0.38.1-next.2071",
"@requestnetwork/smart-contracts": "0.38.1-next.2082",
"graphql-request": "^3.5.0",
"ipfs-only-hash": "^4.0.0",
"lodash": "^4.17.21"
Expand Down
17 changes: 17 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ type EscrowEvent @entity {
gasUsed: BigInt!
gasPrice: BigInt!
}

enum SingleRequestProxyType {
Ethereum
ERC20
}

type SingleRequestProxyDeployment @entity {
id: ID!
proxyAddress: Bytes!
payee: Bytes!
tokenAddress: Bytes
paymentReference: Bytes!
proxyType: SingleRequestProxyType!
block: Int!
timestamp: Int!
txHash: Bytes!
}
Loading

0 comments on commit ac12613

Please sign in to comment.