@stabilitydao/host 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm.yml +19 -0
- package/.github/workflows/prettier.yml +25 -0
- package/.github/workflows/test.yml +29 -0
- package/.prettierignore +4 -0
- package/.prettierrc +1 -0
- package/LICENSE +674 -0
- package/README.md +35 -0
- package/jest.config.js +9 -0
- package/logo.png +0 -0
- package/out/index.js +30 -0
- package/package.json +28 -0
- package/src/activity/builder.ts +141 -0
- package/src/activity/index.ts +34 -0
- package/src/agents.ts +31 -0
- package/src/api.ts +51 -0
- package/src/assets.ts +1579 -0
- package/src/chains.ts +604 -0
- package/src/host.ts +1212 -0
- package/src/index.ts +36 -0
- package/src/storage/daoMetaData.ts +312 -0
- package/src/storage/daos.ts +306 -0
- package/src/tokenlist.json +1938 -0
- package/tests/assets.test.ts +61 -0
- package/tests/chains.test.ts +22 -0
- package/tests/host.test.ts +811 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getAsset, assets } from "../src";
|
|
2
|
+
import { tokenlist } from "../src";
|
|
3
|
+
|
|
4
|
+
describe("testing assets", () => {
|
|
5
|
+
test("getAsset", () => {
|
|
6
|
+
expect(
|
|
7
|
+
getAsset("137", "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619")?.symbol,
|
|
8
|
+
).toBe("WETH");
|
|
9
|
+
expect(
|
|
10
|
+
getAsset("555", "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619")?.symbol,
|
|
11
|
+
).toBe(undefined);
|
|
12
|
+
expect(
|
|
13
|
+
getAsset("8453", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")?.symbol,
|
|
14
|
+
).toBe("USDC");
|
|
15
|
+
});
|
|
16
|
+
test("check if assets addresses exist in tokenlist.json", () => {
|
|
17
|
+
const _tokenlist = tokenlist.tokens;
|
|
18
|
+
|
|
19
|
+
for (const asset of assets) {
|
|
20
|
+
for (const address of Object.values(asset.addresses).flat()) {
|
|
21
|
+
const matchingToken = _tokenlist.find(
|
|
22
|
+
(token) => token.address.toLowerCase() === address.toLowerCase(),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(matchingToken).toBeDefined();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
test("check if tokens from tokenlist exist in assets.ts", () => {
|
|
30
|
+
const _tokenlist = tokenlist.tokens;
|
|
31
|
+
|
|
32
|
+
//PROFIT and SDIV
|
|
33
|
+
const addressesToSkip = [
|
|
34
|
+
"0x48469a0481254d5945e7e56c1eb9861429c02f44",
|
|
35
|
+
"0x9844a1c30462b55cd383a2c06f90bb4171f9d4bb",
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
for (const token of _tokenlist) {
|
|
39
|
+
if (addressesToSkip.includes(token.address.toLowerCase())) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let addressFound = false;
|
|
44
|
+
|
|
45
|
+
for (const asset of assets) {
|
|
46
|
+
for (const address of Object.values(asset.addresses).flat()) {
|
|
47
|
+
if (token.address.toLowerCase() === address.toLowerCase()) {
|
|
48
|
+
addressFound = true;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (addressFound) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
expect(addressFound).toBe(true);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChainName,
|
|
3
|
+
getChainByName,
|
|
4
|
+
chains,
|
|
5
|
+
ChainStatus,
|
|
6
|
+
chainStatusInfo,
|
|
7
|
+
} from "../src";
|
|
8
|
+
|
|
9
|
+
describe("testing chains", () => {
|
|
10
|
+
test("getChainByName", () => {
|
|
11
|
+
let s = getChainByName(ChainName.POLYGON);
|
|
12
|
+
expect(s.name).toEqual("Polygon");
|
|
13
|
+
const t = () => {
|
|
14
|
+
s = getChainByName("incorrect" as ChainName);
|
|
15
|
+
};
|
|
16
|
+
expect(t).toThrow(Error);
|
|
17
|
+
});
|
|
18
|
+
test("chains, chainStatusInfo", () => {
|
|
19
|
+
expect(chains["2046399126"].status).toEqual(ChainStatus.NOT_SUPPORTED);
|
|
20
|
+
expect(chainStatusInfo[ChainStatus.SUPPORTED].title).toEqual("Supported");
|
|
21
|
+
});
|
|
22
|
+
});
|