abel-ghost-sdk 0.0.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/README.md +11 -0
- package/dist/examples/assets.d.ts +1 -0
- package/dist/examples/assets.js +14 -0
- package/dist/examples/deployed.d.ts +1 -0
- package/dist/examples/deployed.js +31 -0
- package/dist/examples/run.d.ts +1 -0
- package/dist/examples/run.js +48 -0
- package/dist/examples/single.d.ts +1 -0
- package/dist/examples/single.js +21 -0
- package/dist/generated/AbelReaderSDK.d.ts +729 -0
- package/dist/generated/AbelReaderSDK.js +511 -0
- package/dist/generated/RetiReaderSDK.d.ts +3236 -0
- package/dist/generated/RetiReaderSDK.js +1773 -0
- package/dist/generated/sdk.d.ts +2474 -0
- package/dist/generated/sdk.js +1388 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +45 -0
- package/dist/utils/chunk.d.ts +1 -0
- package/dist/utils/chunk.js +9 -0
- package/dist/utils/chunked.d.ts +7 -0
- package/dist/utils/chunked.js +35 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Abel Ghost SDK
|
|
2
|
+
|
|
3
|
+
Tiny Ghostkit SDK for Abel, allowing algo.surf to batch look up assets on any network, while also supporting the abel label registry on Mainnet.
|
|
4
|
+
|
|
5
|
+
https://github.com/Algorand-Developer-Retreat/abel
|
|
6
|
+
|
|
7
|
+
https://github.com/d13co/ghostkit
|
|
8
|
+
|
|
9
|
+
## Examples
|
|
10
|
+
|
|
11
|
+
See projects/sdk/examples
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
|
|
2
|
+
import { RetiGhostSDK } from "..";
|
|
3
|
+
const registryAppId = 2714516089;
|
|
4
|
+
const sdk = new RetiGhostSDK({
|
|
5
|
+
algorand: AlgorandClient.mainNet(),
|
|
6
|
+
registryAppId,
|
|
7
|
+
});
|
|
8
|
+
(async () => {
|
|
9
|
+
console.time("run");
|
|
10
|
+
const assetIds = process.argv.slice(2).map((id) => BigInt(id));
|
|
11
|
+
const data = await sdk.getAssets(assetIds);
|
|
12
|
+
console.timeEnd("run");
|
|
13
|
+
console.log(data);
|
|
14
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
|
|
2
|
+
import { RetiGhostSDK } from "..";
|
|
3
|
+
import algosdk from "algosdk";
|
|
4
|
+
const deployer = algosdk.mnemonicToSecretKey("city climb pledge blue dry live choose sorry exotic lucky whip paddle rain miss off report dish health shove mom museum burden reunion abstract term");
|
|
5
|
+
const algorand = AlgorandClient.testNet();
|
|
6
|
+
const factory = algorand.client.getTypedAppFactory(RetiGhostSDK.ghost.factory, {
|
|
7
|
+
defaultSender: deployer.addr,
|
|
8
|
+
defaultSigner: algosdk.makeBasicAccountTransactionSigner(deployer),
|
|
9
|
+
});
|
|
10
|
+
(async () => {
|
|
11
|
+
// const { appClient } = await factory.send.create.getBlockTimestamps({ args: { num: 0n }})
|
|
12
|
+
// console.log(`Deployed RetiReader at app ID: ${appClient.appId}`)
|
|
13
|
+
const deployed = new RetiGhostSDK({
|
|
14
|
+
algorand,
|
|
15
|
+
registryAppId: 0n,
|
|
16
|
+
ghostAppId: 752173746n,
|
|
17
|
+
});
|
|
18
|
+
await deployed.getBlockTimestamps(10);
|
|
19
|
+
console.log("--dEPlOyED--");
|
|
20
|
+
console.time("deployed");
|
|
21
|
+
await deployed.getBlockTimestamps(10);
|
|
22
|
+
console.timeEnd("deployed");
|
|
23
|
+
console.log("--ghost--");
|
|
24
|
+
const ghost = new RetiGhostSDK({
|
|
25
|
+
algorand,
|
|
26
|
+
registryAppId: 0n,
|
|
27
|
+
});
|
|
28
|
+
console.time("ghost");
|
|
29
|
+
await ghost.getBlockTimestamps(10);
|
|
30
|
+
console.timeEnd("ghost");
|
|
31
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
|
|
2
|
+
import { RetiGhostSDK } from "..";
|
|
3
|
+
const registryAppId = 2714516089;
|
|
4
|
+
const sdk = new RetiGhostSDK({
|
|
5
|
+
algorand: AlgorandClient.mainNet(),
|
|
6
|
+
registryAppId,
|
|
7
|
+
});
|
|
8
|
+
(async () => {
|
|
9
|
+
console.time("run");
|
|
10
|
+
const numValidators = await sdk.getNumValidators();
|
|
11
|
+
const validatorIds = new Array(numValidators).fill(0).map((_, i) => i + 1);
|
|
12
|
+
const a = sdk.getNodePoolAssignments(validatorIds).then((nodePoolAssignments) => {
|
|
13
|
+
console.log("Retrieved node pool assignments:", nodePoolAssignments.length);
|
|
14
|
+
console.log("Sample", nodePoolAssignments[0]);
|
|
15
|
+
console.log(" --");
|
|
16
|
+
});
|
|
17
|
+
const b = sdk.getValidatorConfig(validatorIds).then((configs) => {
|
|
18
|
+
console.log("Retrieved validator configs:", configs.length);
|
|
19
|
+
console.log("Sample", configs[0]);
|
|
20
|
+
console.log(" --");
|
|
21
|
+
});
|
|
22
|
+
const c = sdk.getValidatorStates(validatorIds).then((states) => {
|
|
23
|
+
console.log("Retrieved validator states:", states.length);
|
|
24
|
+
console.log("Sample", states[0]);
|
|
25
|
+
console.log(" --");
|
|
26
|
+
});
|
|
27
|
+
const d = sdk.getPools(validatorIds).then(async (pools) => {
|
|
28
|
+
console.log("Retrieved pools:", pools.length);
|
|
29
|
+
console.log("Samples 1 63 95 96", pools[0], pools[62], pools[94], pools[95]);
|
|
30
|
+
// at time of writing:
|
|
31
|
+
// validator id 63 has 0
|
|
32
|
+
// validator id 95 has 3
|
|
33
|
+
// validator id 96 has 1
|
|
34
|
+
console.log(" --");
|
|
35
|
+
const poolAppIds = pools.flatMap((pools, index) => pools.map((poolInfo) => poolInfo.poolAppId));
|
|
36
|
+
console.time("algodversions");
|
|
37
|
+
const algodVersions = await sdk.getPoolAlgodVersions(poolAppIds.map((id) => Number(id)));
|
|
38
|
+
console.log(algodVersions.length, algodVersions[0]);
|
|
39
|
+
console.timeEnd("algodversions");
|
|
40
|
+
return pools;
|
|
41
|
+
});
|
|
42
|
+
const bt = sdk.getBlockTimestamps(10).then((blockTimestamps) => {
|
|
43
|
+
console.log("Block Timestamps:", blockTimestamps);
|
|
44
|
+
console.log(" --");
|
|
45
|
+
});
|
|
46
|
+
await Promise.all([a, b, c, d, bt]);
|
|
47
|
+
console.timeEnd("run");
|
|
48
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
|
|
2
|
+
import { RetiGhostSDK } from "..";
|
|
3
|
+
import { chunk } from "../utils/chunk";
|
|
4
|
+
import pMap from "p-map";
|
|
5
|
+
const registryAppId = 2714516089;
|
|
6
|
+
const sdk = new RetiGhostSDK({
|
|
7
|
+
algorand: AlgorandClient.mainNet(),
|
|
8
|
+
registryAppId,
|
|
9
|
+
});
|
|
10
|
+
(async () => {
|
|
11
|
+
console.time("run");
|
|
12
|
+
const numValidators = await sdk.getNumValidators();
|
|
13
|
+
const validatorIds = Array(numValidators).fill(0).map((_, i) => i + 1);
|
|
14
|
+
const chunks = chunk(validatorIds, 64);
|
|
15
|
+
await pMap(chunks, async (ids, i) => {
|
|
16
|
+
console.time(`getValidators(${i})`);
|
|
17
|
+
const data = await sdk.getValidators(ids);
|
|
18
|
+
console.timeEnd(`getValidators(${i})`);
|
|
19
|
+
}, { concurrency: 2 });
|
|
20
|
+
console.timeEnd("run");
|
|
21
|
+
})();
|