From 19545c7d036dc8dca4ecaf8bd83237d48895472e Mon Sep 17 00:00:00 2001 From: coffee-converter Date: Mon, 4 Jan 2021 16:20:13 -0600 Subject: [PATCH] add refundsponsor --- abis/RefundSponsor.json | 293 +++++++++++++++++++++++++++++++++++ config/mainnet.json | 4 + config/ropsten.json | 4 + schema.graphql | 1 + src/mapping-refundSponsor.ts | 9 ++ src/shared.ts | 1 + subgraph.template.yaml | 20 +++ 7 files changed, 332 insertions(+) create mode 100644 abis/RefundSponsor.json create mode 100644 src/mapping-refundSponsor.ts diff --git a/abis/RefundSponsor.json b/abis/RefundSponsor.json new file mode 100644 index 0000000..759ca46 --- /dev/null +++ b/abis/RefundSponsor.json @@ -0,0 +1,293 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "refundedTo", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RefundIssued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sponsor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SponsoredContribution", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_a", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_g", + "type": "uint256" + } + ], + "name": "addGasRefund", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newPauoutPercent", + "type": "uint256" + } + ], + "name": "changePayoutPercent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "flush", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "flushNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "x", + "type": "address" + } + ], + "name": "getHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "x", + "type": "address" + } + ], + "name": "getRefundAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "myRefundAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "payoutPercent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "refundAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "refundSponsor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "requestGasRefund", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resume", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_a", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_g", + "type": "uint256" + } + ], + "name": "setGasRefund", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_s", + "type": "address" + } + ], + "name": "setSponsoredContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "sponsoredAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sponsoredContract", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/config/mainnet.json b/config/mainnet.json index 8ab7754..409cac6 100644 --- a/config/mainnet.json +++ b/config/mainnet.json @@ -7,5 +7,9 @@ "wiseToken": { "address": "0x66a0f676479Cee1d7373f3DC2e2952778BfF5bd6", "startBlock": 11504583 + }, + "refundSponsor": { + "address": "0xc3FC68dDdB1bf4Cb61307eEf89729DC317f2325a", + "startBlock": 11576737 } } \ No newline at end of file diff --git a/config/ropsten.json b/config/ropsten.json index 7cd0acb..07f2dff 100644 --- a/config/ropsten.json +++ b/config/ropsten.json @@ -7,5 +7,9 @@ "wiseToken": { "address": "0xa89Cb3AA23F7d85DEF5dCCdb73450aE236AFEe61", "startBlock": 9312570 + }, + "refundSponsor": { + "address": "0xc3FC68dDdB1bf4Cb61307eEf89729DC317f2325a", + "startBlock": 11576737 } } \ No newline at end of file diff --git a/schema.graphql b/schema.graphql index c8ca1e0..40af770 100644 --- a/schema.graphql +++ b/schema.graphql @@ -24,6 +24,7 @@ type User @entity { stakeCount: BigInt! cmStatus: Boolean! cmStatusInLaunch: Boolean! + gasRefunded: BigInt! } type Reservation @entity { diff --git a/src/mapping-refundSponsor.ts b/src/mapping-refundSponsor.ts new file mode 100644 index 0000000..b113022 --- /dev/null +++ b/src/mapping-refundSponsor.ts @@ -0,0 +1,9 @@ +import { RefundIssued } from "../generated/RefundSponsor/RefundSponsor" +import { createUser } from "./shared" + +export function handleRefundIssued (event: RefundIssued): void { + let userID = event.params.refundedTo.toHexString() + let user = createUser(userID) + user.gasRefunded = event.params.amount + user.save() +} diff --git a/src/shared.ts b/src/shared.ts index baf6ae6..a2be049 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -39,5 +39,6 @@ export function createUser(id: string): User | null { user.stakeCount = ZERO user.cmStatus = false user.cmStatusInLaunch = false + user.gasRefunded = ZERO return user } \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index fbb9c24..913d323 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -60,3 +60,23 @@ dataSources: - event: GeneratedRandomSupply(indexed uint256,uint256) handler: handleGeneratedRandomSupply file: ./src/mapping-liquidityTransformer.ts + - kind: ethereum/contract + name: RefundSponsor + network: {{ network }} + source: + address: '{{ refundSponsor.address }}' + abi: RefundSponsor + startBlock: {{ refundSponsor.startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + entities: + - User + abis: + - name: RefundSponsor + file: ./abis/RefundSponsor.json + eventHandlers: + - event: RefundIssued(address,uint256) + handler: handleRefundIssued + file: ./src/mapping-refundSponsor.ts