Skip to content

Commit

Permalink
Ceffu EA
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll committed Jan 20, 2025
1 parent 1c516b6 commit b005196
Show file tree
Hide file tree
Showing 41 changed files with 983 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-hats-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/por-address-list-adapter': patch
---

Update output format for Ceffu
5 changes: 5 additions & 0 deletions .changeset/famous-penguins-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/ceffu-adapter': major
---

Init
5 changes: 5 additions & 0 deletions .changeset/perfect-mice-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/proof-of-reserves-adapter': patch
---

Support ceffu
74 changes: 74 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/fsevents-patch-6b67494872-10.zip
Binary file not shown.
Binary file added .yarn/cache/fsevents-patch-afc6995412-10.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 11 additions & 9 deletions packages/composites/proof-of-reserves/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,24 @@ At least one of each of the following categories must be set as an environment v
| | `SOCHAIN_ADAPTER_URL` | The location of a SoChain external adapter | | |
| | `STADER_BALANCE_ADAPTER_URL` | The location of a Stader Balance external adapter | | |
| | `TOKEN_BALANCE_ADAPTER_URL` | The location of a Token Balance external adapter | | |
| | `CEFFU_ADAPTER_URL` | The location of a Ceffu external adapter | | |

## Running

See the [Composite Adapter README](../README.md) for more information on how to get started.

### Input Params

| Required? | Name | Description | Options | Defaults to |
| :-------: | :--------------------------------: | :--------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------: |
|| `protocol` | The protocol external adapter to use | `celsius_address_list`, `chain_reserve_wallet`, `coinbase_prime`, `coinbase_prime_eth` `gemini`,`moonbeam_address_list`, `multi_address_list`, `ignition_address_list`, `list`, `por_address_list`, `renvm`, `stader_address_list`, `swell_address_list`, `wbtc`, `wrapped` | |
| | `protocolEndpoint` | Optional endpoint for the protocol external adapter to use | | |
|| `indexer` | The indexer external adapter to use | `ada_balance`, `amberdata`, `avalanche_platform`, `bitcoin_json_rpc`, `blockchain_com`. `blockchair`, `blockcypher`, `btc_com`, `cryptoapis`, `eth_balance`, `eth_beacon`, `lotus`, `polkadot_balance`, `por_indexer`, `sochain`, `stader_balance`, `token_balance` | |
| | `confirmations` | The number of confirmations required for a transaction to be counted when getting an address balance | | 6 |
| | `addresses` | An array of addresses to get the balance from, when "protocol" is set to `list` | | |
| | `disableAddressValidation` | if this parameter is set to `true` address validation will be turned off | `true`, `false` | `false` |
| | `disableDuplicateAddressFiltering` | if this parameter is set to `true` duplicate address filtering will be turned off | `true`, `false` | `false` |
| Required? | Name | Description | Options | Defaults to |
| :-------: | :--------------------------------: | :--------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------: |
|| `protocol` | The protocol external adapter to use | `celsius_address_list`, `chain_reserve_wallet`, `coinbase_prime`, `coinbase_prime_eth` `gemini`,`moonbeam_address_list`, `multi_address_list`, `ignition_address_list`, `list`, `por_address_list`, `renvm`, `stader_address_list`, `swell_address_list`, `wbtc`, `wrapped` | |
| | `protocolEndpoint` | Optional endpoint for the protocol external adapter to use | | |
|| `indexer` | The indexer external adapter to use | `ada_balance`, `amberdata`, `avalanche_platform`, `bitcoin_json_rpc`, `blockchain_com`. `blockchair`, `blockcypher`, `btc_com`, `cryptoapis`, `eth_balance`, `eth_beacon`, `lotus`, `polkadot_balance`, `por_indexer`, `sochain`, `stader_balance`, `token_balance`, `ceffu` | |
| | `indexerEndpoint` | Optional endpoint for the indexer external adapter to use | | |
| | `confirmations` | The number of confirmations required for a transaction to be counted when getting an address balance | | 6 |
| | `addresses` | An array of addresses to get the balance from, when "protocol" is set to `list` | | |
| | `disableAddressValidation` | if this parameter is set to `true` address validation will be turned off | `true`, `false` | `false` |
| | `disableDuplicateAddressFiltering` | if this parameter is set to `true` duplicate address filtering will be turned off | `true`, `false` | `false` |

Additionally the first underlying adapter in the sequence, in this case the protocol adapter, may have parameters.

Expand Down
1 change: 1 addition & 0 deletions packages/composites/proof-of-reserves/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@chainlink/blockchair-adapter": "workspace:*",
"@chainlink/blockcypher-adapter": "workspace:*",
"@chainlink/btc.com-adapter": "workspace:*",
"@chainlink/ceffu-adapter": "workspace:*",
"@chainlink/celsius-address-list-adapter": "workspace:*",
"@chainlink/chain-reserve-wallet-adapter": "workspace:*",
"@chainlink/coinbase-prime-adapter": "workspace:*",
Expand Down
3 changes: 3 additions & 0 deletions packages/composites/proof-of-reserves/schemas/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
},
{
"required": ["TOKEN_BALANCE_ADAPTER_URL"]
},
{
"required": ["CEFFU_ADAPTER_URL"]
}
]
}
Expand Down
14 changes: 14 additions & 0 deletions packages/composites/proof-of-reserves/src/utils/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { adapter as ethBeacon } from '@chainlink/eth-beacon-adapter'
import { adapter as lotus } from '@chainlink/lotus-adapter'
import { adapter as porIndexer } from '@chainlink/por-indexer-adapter'
import { adapter as tokenBalance } from '@chainlink/token-balance-adapter'
import { adapter as ceffu } from '@chainlink/ceffu-adapter'

// TODO: type
export const adaptersV2: v2AdapterImplementation[] = [
Expand All @@ -49,6 +50,7 @@ export const adaptersV3: v3AdapterImplementation[] = [
lotus,
porIndexer,
tokenBalance,
ceffu,
]

// Get balances for address set
Expand All @@ -72,6 +74,9 @@ export const runBalanceAdapter = async (
case tokenBalance.name:
next = buildTokenBalanceRequest(input, confirmations)
break
case ceffu.name:
next = buildCeffuRequest(input)
break
case ethBeacon.name:
next = {
id: input.jobRunID,
Expand Down Expand Up @@ -157,3 +162,12 @@ function buildTokenBalanceRequest(input: AdapterResponse, minConfirmations: numb
},
}
}

function buildCeffuRequest(input: AdapterResponse) {
return {
id: input.jobRunID,
data: {
addresses: input.data.result,
},
}
}
14 changes: 12 additions & 2 deletions packages/composites/proof-of-reserves/src/utils/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { adapter as bitcoinPorIndexer } from '@chainlink/por-indexer-adapter'
import * as adaBalance from '@chainlink/ada-balance-adapter'
import { adapter as lotus } from '@chainlink/lotus-adapter'
import { adapter as tokenBalance } from '@chainlink/token-balance-adapter'
import { adapter as ceffu } from '@chainlink/ceffu-adapter'
import { ethers } from 'ethers'

const returnParsedUnits = (
jobRunID: string,
result: string,
units: number,
units: number, // How many decimal to scale
skipConvert = false,
finalDecimals?: number, // The decimal of the final result
) => {
const convertedResult =
skipConvert || units === 0 ? result : ethers.utils.parseUnits(result, units).toString()
Expand All @@ -23,7 +25,7 @@ const returnParsedUnits = (
data: {
result: convertedResult,
statusCode: 200,
decimals: units,
decimals: finalDecimals || units,
},
}
}
Expand All @@ -42,6 +44,14 @@ export const runReduceAdapter = async (
return returnParsedUnits(input.jobRunID, input.data.result as string, 8)
case tokenBalance.name:
return returnParsedUnits(input.jobRunID, input.data.result as string, 18, true)
case ceffu.name:
return returnParsedUnits(
input.jobRunID,
input.data.result as string,
18 - (input.data.decimals as number),
false,
18,
)
case lotus.name:
case adaBalance.NAME:
// TODO: type makeExecute response
Expand Down
1 change: 1 addition & 0 deletions packages/composites/proof-of-reserves/test-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const indexerEnvironmentVariables = [
{ envKey: 'CRYPTOAPIS_ADAPTER_URL', value: 'cryptoapis' },
{ envKey: 'POR_INDEXER_ADAPTER_URL', value: 'por_indexer' },
{ envKey: 'TOKEN_BALANCE_ADAPTER_URL', value: 'token_balance' },
{ envKey: 'CEFFU_ADAPTER_URL', value: 'ceffu' },
{ envKey: 'SOCHAIN_ADAPTER_URL', value: 'sochain' },
]

Expand Down
3 changes: 2 additions & 1 deletion packages/composites/proof-of-reserves/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
{ "path": "../../sources/polkadot-balance" },
{ "path": "../../composites/multi-address-list" },
{ "path": "../../sources/ignition-address-list" },
{ "path": "../../sources/token-balance" }
{ "path": "../../sources/token-balance" },
{ "path": "../../sources/ceffu" }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ export const SoakTestBlacklist: string[] = [
'bravenewcoin', // Our API Key has expired
'celsius-address-list', // Not deployed internally
'instruxi-sxt', // Developed by external party
'ceffu', // Missing: RPC URL
]
Empty file.
3 changes: 3 additions & 0 deletions packages/sources/ceffu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Chainlink External Adapter for ceffu

This README will be generated automatically when code is merged to `main`. If you would like to generate a preview of the README, please run `yarn generate:readme ceffu`.
Loading

0 comments on commit b005196

Please sign in to comment.