@typus/typus-sdk 0.0.1 → 0.0.2

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/.env ADDED
@@ -0,0 +1,11 @@
1
+ NODE_ENV=development
2
+ HOSTNAME=typus-db.cwtf2o8jkdpt.ap-southeast-1.rds.amazonaws.com
3
+ DATABASE=postgres
4
+ USERNAME=postgres
5
+ PASSWORD=3n6z8VzIX6jKd4fGrOuh
6
+ CLUSTER=devnet
7
+ RPC_ENDPOINT=https://fullnode.devnet.sui.io:443
8
+ PORT=5432
9
+ SERVER_PORT=5432
10
+ PACKAGE=0xfbbdd33ab4c02e7a315e2477931bae4cbdf46381
11
+ VAULT_REGISTRY=0x0a9d87a1b6c00415708d2f1c62784b52f797213c
File without changes
package/package.json CHANGED
@@ -2,13 +2,13 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "0.0.1",
5
+ "version": "0.0.2",
6
6
  "dependencies": {
7
7
  "@mysten/sui.js": "^0.17.1",
8
8
  "fetch": "^1.1.0",
9
9
  "node-fetch": "^3.3.0"
10
10
  },
11
- "main": "index.js",
11
+ "main": "index.ts",
12
12
  "devDependencies": {},
13
13
  "scripts": {
14
14
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -22,4 +22,4 @@
22
22
  "url": "https://github.com/Typus-Lab/typus-sdk/issues"
23
23
  },
24
24
  "homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
25
- }
25
+ }
@@ -0,0 +1,5 @@
1
+ import { subVaults } from '../utils/utils_ts/getSubVault';
2
+ (async () => {
3
+ let res = await subVaults()
4
+ console.log(res)
5
+ })();
package/scripts/sui.ts CHANGED
@@ -2,6 +2,7 @@ import { JsonRpcProvider, Ed25519Keypair, RawSigner, SuiEventEnvelope, Network,
2
2
  import { fromB64 } from '@mysten/bcs';
3
3
  import fs from "fs";
4
4
  import fetch from 'cross-fetch';
5
+
5
6
  const { execSync } = require('child_process');
6
7
  const rpc = new JsonRpcProvider('https://fullnode.devnet.sui.io:443');
7
8
  const provider = new JsonRpcProvider(Network.DEVNET);//for read only operations
@@ -214,3 +215,5 @@ function readJsonFile<T>(filePath: string): T {
214
215
  // console.log('moveCallTxn', moveCallTxn);
215
216
  // }
216
217
 
218
+
219
+
@@ -0,0 +1,43 @@
1
+ import { JsonRpcProvider, Network } from '@mysten/sui.js';
2
+ const provider = new JsonRpcProvider(Network.DEVNET);//for read only operations
3
+
4
+ export async function subVaults(): Promise<any> {
5
+ //packageID and registry
6
+ let packageID = process.env.PACKAGE!
7
+ let registry = process.env.VAULT_REGISTRY!
8
+ console.log("packageID: " + packageID)
9
+ console.log("registry: " + registry)
10
+
11
+ //vault
12
+ let tmpObj1 = await provider.getObjectsOwnedByObject(registry)
13
+ let vault = tmpObj1[0].objectId
14
+ console.log("vault: " + vault)
15
+
16
+ //table
17
+ let tmpObj2 = await provider.getObject(vault)
18
+ //@ts-ignore
19
+ let table = tmpObj2.details.data.fields.value.fields.sub_vaults.fields.id.id
20
+ console.log("table: " + table)
21
+
22
+ //sub vault (maker / rolling / no_rolling) id
23
+ let tmpObj3 = await provider.getObjectsOwnedByObject(table)
24
+ let subVaultsId: string[] = [];
25
+ tmpObj3.map(e => {
26
+ subVaultsId.push(e.objectId as string)
27
+ }
28
+ )
29
+ console.log("subVaults: ")
30
+ //@ts-ignore
31
+ console.log(subVaultsId)
32
+
33
+ //sub vault data
34
+ const subVaultsMap = new Map();
35
+ //@ts-ignore
36
+ for (let e of subVaultsId) {
37
+ let tmpObj4 = await provider.getObject(e)
38
+ //@ts-ignore
39
+ subVaultsMap.set(tmpObj4.details.data.fields.name, tmpObj4.details.data.fields)
40
+ }
41
+ // console.log(subVaultsMap.get("rolling").value.fields.users_table)
42
+ return subVaultsMap
43
+ }