Skip to content

Commit

Permalink
Ignition EA (#3485)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll authored Oct 17, 2024
1 parent 59a1f37 commit fba3273
Show file tree
Hide file tree
Showing 25 changed files with 378 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/quick-flowers-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@chainlink/ignition-address-list-adapter': major
'@chainlink/proof-of-reserves-adapter': minor
---

Add ignition address list
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
id-token: write
contents: read
strategy:
max-parallel: 5
matrix: ${{fromJson(needs.calculate-changes.outputs.adapter-list)}}
env:
ECR_URL: ${{ secrets.SDLC_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION_ECR_PRIVATE }}.amazonaws.com
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
id-token: write
contents: read
strategy:
max-parallel: 5
matrix: ${{fromJson(needs.calculate-changes.outputs.adapter-list)}}
env:
PUBLIC_ECR_URL: public.ecr.aws/chainlink
Expand Down
21 changes: 21 additions & 0 deletions .pnp.cjs

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

17 changes: 9 additions & 8 deletions packages/composites/proof-of-reserves/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ At least one of each of the following categories must be set as an environment v
| | `GEMINI_ADAPTER_URL` | The location of a Gemini external adapter | | |
| | `MOONBEAM_ADDRESS_LIST_ADAPTER_URL` | The location of a Moonbeam Address List external adapter | | |
| | `MULTI_ADDRESS_LIST_ADAPTER_URL` | The location of a Multi Address List external adapter | | |
| | `IGNITION_ADDRESS_LIST_ADAPTER_URL` | The location of a Ignition Address List external adapter | | |
| | `POR_ADDRESS_LIST_ADAPTER_URL` | The location of a PoR Address List external adapter | | |
| | `RENVM_ADAPTER_URL` | The location of a RenVM external adapter | | |
| | `STADER_ADDRESS_LIST_ADAPTER_URL` | The location of a Stader Address List external adapter | | |
Expand Down Expand Up @@ -53,14 +54,14 @@ See the [Composite Adapter README](../README.md) for more information on how to

### 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`, `list`, `por_address_list`, `renvm`, `stader_address_list`, `swell_address_list`, `wbtc`, `wrapped` | |
|| `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` | |
| | `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` | |
|| `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` | |
| | `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 @@ -48,6 +48,7 @@
"@chainlink/eth-balance-adapter": "workspace:*",
"@chainlink/eth-beacon-adapter": "workspace:*",
"@chainlink/gemini-adapter": "workspace:*",
"@chainlink/ignition-address-list-adapter": "workspace:*",
"@chainlink/lotus-adapter": "workspace:*",
"@chainlink/moonbeam-address-list-adapter": "workspace:*",
"@chainlink/multi-address-list-adapter": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions packages/composites/proof-of-reserves/src/utils/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { adapter as wBTC } from '@chainlink/wbtc-address-set-adapter'
import * as wrapped from '@chainlink/wrapped-adapter'
import { adapter as coinbasePrime } from '@chainlink/coinbase-prime-adapter'
import { adapter as multiAddressList } from '@chainlink/multi-address-list-adapter'
import { adapter as ignitionAddressList } from '@chainlink/ignition-address-list-adapter'

export const LIST_ADAPTER = 'LIST'

Expand All @@ -41,6 +42,7 @@ export const adaptersV3: v3AdapterImplementation[] = [
porAddressList,
coinbasePrime,
multiAddressList,
ignitionAddressList,
]

type AddressData = { token: string; chainId: string; network: string } | AddressList
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 @@ -36,6 +36,7 @@
{ "path": "../../sources/por-address-list" },
{ "path": "../../sources/moonbeam-address-list" },
{ "path": "../../sources/polkadot-balance" },
{ "path": "../../composites/multi-address-list" }
{ "path": "../../composites/multi-address-list" },
{ "path": "../../sources/ignition-address-list" }
]
}
Empty file.
3 changes: 3 additions & 0 deletions packages/sources/ignition-address-list/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Chainlink External Adapter for ignition-address-list

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 ignition-address-list`.
40 changes: 40 additions & 0 deletions packages/sources/ignition-address-list/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@chainlink/ignition-address-list-adapter",
"version": "0.0.0",
"description": "Chainlink ignition-address-list adapter.",
"keywords": [
"Chainlink",
"LINK",
"blockchain",
"oracle",
"ignition-address-list"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"repository": {
"url": "https://github.com/smartcontractkit/external-adapters-js",
"type": "git"
},
"license": "MIT",
"scripts": {
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
"prepack": "yarn build",
"build": "tsc -b",
"server": "node -e 'require(\"./index.js\").server()'",
"server:dist": "node -e 'require(\"./dist/index.js\").server()'",
"start": "yarn server:dist"
},
"devDependencies": {
"@types/jest": "27.5.2",
"@types/node": "16.11.68",
"nock": "13.5.4",
"typescript": "5.0.4"
},
"dependencies": {
"@chainlink/external-adapter-framework": "1.5.0",
"tslib": "2.4.1"
}
}
15 changes: 15 additions & 0 deletions packages/sources/ignition-address-list/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'

export const config = new AdapterConfig({
API_KEY: {
description: 'An API key for Data Provider',
type: 'string',
required: true,
sensitive: true,
},
API_ENDPOINT: {
description: 'An API endpoint for Data Provider',
type: 'string',
default: 'https://fbtc.phalcon.blocksec.com/api/v1/extension/fbtc-reserved-addr',
},
})
41 changes: 41 additions & 0 deletions packages/sources/ignition-address-list/src/endpoint/address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
import {
PoRAddressEndpoint,
PoRAddressResponse,
} from '@chainlink/external-adapter-framework/adapter/por'
import { config } from '../config'
import { httpTransport } from '../transport/address'

export const inputParameters = new InputParameters(
{
network: {
description: 'The network name to associate with the addresses',
type: 'string',
required: true,
},
chainId: {
description: 'The chain ID to associate with the addresses',
type: 'string',
required: true,
},
},
[
{
network: 'bitcoin',
chainId: 'mainnet',
},
],
)

export type BaseEndpointTypes = {
Parameters: typeof inputParameters.definition
Response: PoRAddressResponse
Settings: typeof config.settings
}

export const endpoint = new PoRAddressEndpoint({
name: 'address',
aliases: [],
transport: httpTransport,
inputParameters,
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { endpoint as address } from './address'
21 changes: 21 additions & 0 deletions packages/sources/ignition-address-list/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expose, ServerInstance } from '@chainlink/external-adapter-framework'
import { PoRAdapter } from '@chainlink/external-adapter-framework/adapter/por'
import { config } from './config'
import { address } from './endpoint'

export const adapter = new PoRAdapter({
defaultEndpoint: address.name,
name: 'IGNITION_ADDRESS_LIST',
config,
endpoints: [address],
rateLimiting: {
tiers: {
default: {
rateLimit1m: 6,
note: 'The same IP address can only send one request within 5 seconds',
},
},
},
})

export const server = (): Promise<ServerInstance | undefined> => expose(adapter)
63 changes: 63 additions & 0 deletions packages/sources/ignition-address-list/src/transport/address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { HttpTransport } from '@chainlink/external-adapter-framework/transports'
import { BaseEndpointTypes } from '../endpoint/address'

export interface ResponseSchema {
total_records: number
result: {
address: string
address_type: string
balance: number
}[]
}

export type HttpTransportTypes = BaseEndpointTypes & {
Provider: {
RequestBody: never
ResponseBody: ResponseSchema & { message: string }
}
}
export const httpTransport = new HttpTransport<HttpTransportTypes>({
prepareRequests: (params, config) => {
return params.map((param) => {
return {
params: [param],
request: {
baseURL: config.API_ENDPOINT,
headers: {
'access-token': config.API_KEY,
},
},
}
})
},
parseResponse: (params, response) => {
return params.map((param) => {
if (!response.data || response.data.result.length == 0) {
return {
params: param,
response: {
errorMessage: response.data?.message || `The data provider didn't return any value`,
statusCode: 502,
},
}
}
const addresses = response.data.result
.map((r) => ({
address: r.address,
network: param.network,
chainId: param.chainId,
}))
.sort((a, b) => a.address.localeCompare(b.address))

return {
params: param,
response: {
result: null,
data: {
result: addresses,
},
},
}
})
},
})
6 changes: 6 additions & 0 deletions packages/sources/ignition-address-list/test-payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"requests": [{
"network": "bitcoin",
"chainId": "mainnet"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`execute address endpoint should return success 1`] = `
{
"data": {
"result": [
{
"address": "bc1qhu98nf6ddz6ja73rn72encdr8ezsyhexwpdzap0vcs7lg2wpmrnq5ygfsl",
"chainId": "mainnet",
"network": "bitcoin",
},
{
"address": "bc1qsdq75g6pmk6uz9a897pmgsmzr44822hg55adz8",
"chainId": "mainnet",
"network": "bitcoin",
},
],
},
"result": null,
"statusCode": 200,
"timestamps": {
"providerDataReceivedUnixMs": 978347471111,
"providerDataRequestedUnixMs": 978347471111,
},
}
`;
Loading

0 comments on commit fba3273

Please sign in to comment.