Sub-Adapters 1
Preview and test each sub adapter.
Rainbow Bridge (rainbow-ethereum)
Metadata
- ID
- rainbow-ethereum
- name
"Rainbow Bridge"
- icon
- chainA
"ethereum"
- chainB
"near"
- category
"light-client"
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'NEAR Rainbow Bridge';
2export const version = '0.2.1';
3export const license = 'MIT';
4
5export function setup(sdk: Context) {
6 const getSubgraphQuery = (isImported: boolean) => async () => {
7 const query = `{
8 tokens(where: {
9 price_lt: 100000,
10 price_gt: 0,
11 imported: ${isImported}
12 }) {
13 id
14 name
15 price
16 imported
17 amountBridgedUSD
18 }
19 }`;
20
21 const data = await sdk.graph.query('dmihal/rainbow-bridge', query);
22
23 let total = 0;
24 for (const token of data.tokens) {
25 total += Math.abs(parseFloat(token.amountBridgedUSD));
26 }
27
28 return total;
29 }
30
31 sdk.registerBundle('rainbow', {
32 name: 'Rainbow Bridge',
33 icon: sdk.ipfs.getDataURILoader('QmdK7WvoNtm5choEhZyB1oxBGJaZ8CSFxBe4kW4wmvngM6', 'image/svg+xml'),
34 category: 'light-client',
35 });
36
37 sdk.register({
38 id: 'rainbow-ethereum',
39 bundle: 'rainbow',
40 queries: {
41 currentValueBridgedAToB: getSubgraphQuery(true),
42 currentValueBridgedBToA: getSubgraphQuery(false),
43 },
44 metadata: {
45 name: 'Rainbow Bridge',
46 icon: sdk.ipfs.getDataURILoader('QmdK7WvoNtm5choEhZyB1oxBGJaZ8CSFxBe4kW4wmvngM6', 'image/svg+xml'),
47
48 chainA: 'ethereum',
49 chainB: 'near',
50 category: 'light-client',
51 },
52 });
53}
54
It's something off?
Report it to the discussion board on Discord, we will take care of it.