Skip to content

Commit

Permalink
feat: add conflux data feed
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Jul 15, 2021
1 parent e636a26 commit 29fee3a
Show file tree
Hide file tree
Showing 17 changed files with 511 additions and 57 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/repository/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class FeedRepository {
}

public getTotalCount () {
return this.collection.count()
return this.collection.countDocuments()
}

private normalizeId (feed: FeedDbObject): FeedDbObjectNormalized {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/repository/ResultRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class ResultRequestRepository {
.find({
feedId: feedId.toString()
})
.sort({ timestamp: -1 })
.toArray()
).map(this.normalizeId)
}
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export type Context = {
export enum Network {
Goerli = 'goerli',
Kovan = 'kovan',
Rinkeby = 'rinkeby'
Rinkeby = 'rinkeby',
Conflux = 'conflux'
}

export type FeedInfo = {
Expand Down
116 changes: 116 additions & 0 deletions packages/api/src/web3Middleware/abi/ConfluxBtcUsd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[
{
"inputs": [
{ "internalType": "address", "name": "_wrb", "type": "address" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"name": "PriceUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "",
"type": "string"
}
],
"name": "ResultError",
"type": "event"
},
{
"inputs": [],
"name": "BTCUSD3ID",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "lastPrice",
"outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "lastRequestId",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "pending",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "request",
"outputs": [
{
"internalType": "contract WitnetRequest",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "timestamp",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "requestUpdate",
"outputs": [],
"stateMutability": "payable",
"type": "function",
"payable": true
},
{
"inputs": [],
"name": "completeUpdate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }],
"name": "valueFor",
"outputs": [
{ "internalType": "int256", "name": "", "type": "int256" },
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "uint256", "name": "", "type": "uint256" }
],
"stateMutability": "view",
"type": "function",
"constant": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
[
{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "from",
"type": "address"
}
],
"name": "DestroyedRequest",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "stub",
"type": "address"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "from",
"type": "address"
}
],
"name": "PostedRequest",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "from",
"type": "address"
}
],
"name": "PostedResult",
"type": "event"
},
{ "stateMutability": "payable", "type": "fallback", "payable": true },
{
"inputs": [],
"name": "codehash",
"outputs": [
{ "internalType": "bytes32", "name": "_codehash", "type": "bytes32" }
],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [],
"name": "isUpgradable",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{ "stateMutability": "payable", "type": "receive", "payable": true },
{
"inputs": [],
"name": "destroy",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "bytes", "name": "_initData", "type": "bytes" }
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "pure",
"type": "function",
"constant": true
},
{
"inputs": [
{ "internalType": "address[]", "name": "reporters", "type": "address[]" }
],
"name": "setReporters",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "readDr",
"outputs": [
{
"components": [
{ "internalType": "address", "name": "addr", "type": "address" },
{ "internalType": "address", "name": "requestor", "type": "address" },
{ "internalType": "uint256", "name": "codehash", "type": "uint256" },
{ "internalType": "uint256", "name": "gasprice", "type": "uint256" },
{ "internalType": "uint256", "name": "reward", "type": "uint256" },
{ "internalType": "uint256", "name": "txhash", "type": "uint256" }
],
"internalType": "struct WitnetTypes.DataRequest",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "readDataRequest",
"outputs": [
{ "internalType": "bytes", "name": "_bytecode", "type": "bytes" }
],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "readGasPrice",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [
{ "internalType": "uint256", "name": "id", "type": "uint256" },
{ "internalType": "uint256", "name": "txhash", "type": "uint256" },
{ "internalType": "bytes", "name": "result", "type": "bytes" }
],
"name": "reportResult",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "requestsCount",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [
{ "internalType": "uint256", "name": "gasPrice", "type": "uint256" }
],
"name": "estimateGasCost",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "pure",
"type": "function",
"constant": true
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "destroyResult",
"outputs": [
{ "internalType": "bytes", "name": "_result", "type": "bytes" }
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "requestAddr", "type": "address" }
],
"name": "postDataRequest",
"outputs": [
{ "internalType": "uint256", "name": "_id", "type": "uint256" }
],
"stateMutability": "payable",
"type": "function",
"payable": true
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "readDrTxHash",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "readResult",
"outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"inputs": [{ "internalType": "uint256", "name": "id", "type": "uint256" }],
"name": "upgradeDataRequest",
"outputs": [],
"stateMutability": "payable",
"type": "function",
"payable": true
}
]
Loading

0 comments on commit 29fee3a

Please sign in to comment.