@typus/typus-sdk 0.1.2 → 0.1.3

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 CHANGED
@@ -13,14 +13,10 @@ npm i
13
13
  npx ts-node scripts/sui.ts
14
14
  ```
15
15
  ### mint customized token
16
- - get package object id from dov, run:
17
- ```bash
18
- sui client call --gas-budget 10000 --package $PACKAGE --module "token" --function "new"
19
- ```
20
- to create registry, and use the registry mint 10001 token:
16
+ - get package object id and one of asset registry(for example:BTC )from sui-dev-token, and use the registry mint 10001 token:
21
17
 
22
18
  ```bash
23
- sui client call --gas-budget 10000 --package $PACKAGE --module "token" --function "mint" --args $REGISTRY 10001
19
+ sui client call --gas-budget 10000 --package $PACKAGE --module "token_btc" --function "mint" --args $REGISTRY 10001
24
20
  ```
25
21
 
26
22
  you will get different object with balance every time after mint, and all of them created by a same registry.
@@ -1,5 +1,5 @@
1
- export declare const TOKEN_PACKAGE = "0x27b3674c685046f66cad1d5496d2967894fa5329";
2
- export declare const TOKEN_REGISTRY = "0xfaa99efa7efa1ec0a265c898bf31dd7f10637f38";
1
+ export declare const TOKEN_PACKAGE = "0xe879e96fb90a8559127091f1176a2d10bb67c6ff";
2
+ export declare const TOKEN_REGISTRY = "0x5dce92f67eeda471369b734deac0d540b751cea6";
3
3
  export declare const SHARKFIN_PACKAGE = "0x3085e089d748e09ae2a5859531ec3bc34b1e13b4";
4
4
  export declare const SHARKFIN_REGISTRY = "0xd27515bcf75daba9cff1da5b93bd4f08c781cea2";
5
5
  export declare const DOV_PACKAGE = "0x6fbe0bd487e9ca263f682f8d192750ef4ecce73d";
@@ -8,3 +8,11 @@ export declare const COVERED_CALL_REGISTRY = "0xb02452d0bbef3cbdc7840ea5bad27bcd
8
8
  export declare const COVERED_CALL_MANAGER = "0x8517b2dbaae56eeb84352e4869b289459c68965b";
9
9
  export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
10
10
  export declare const TEST_MNEMONIC = "tackle wheat jungle viable memory dwarf swift fold purpose cattle impose horn";
11
+ export declare const TOKEN_NAME: string[];
12
+ export declare const TOKEN_NAME_TO_MODULE: {
13
+ BTC: string;
14
+ ETH: string;
15
+ SUI: string;
16
+ USDC: string;
17
+ USDT: string;
18
+ };
package/lib/constants.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEST_MNEMONIC = exports.DEFAULT_TYPE_ARGUMENT = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.DOV_PACKAGE = exports.SHARKFIN_REGISTRY = exports.SHARKFIN_PACKAGE = exports.TOKEN_REGISTRY = exports.TOKEN_PACKAGE = void 0;
4
- exports.TOKEN_PACKAGE = "0x27b3674c685046f66cad1d5496d2967894fa5329";
5
- exports.TOKEN_REGISTRY = "0xfaa99efa7efa1ec0a265c898bf31dd7f10637f38";
3
+ exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.DEFAULT_TYPE_ARGUMENT = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.DOV_PACKAGE = exports.SHARKFIN_REGISTRY = exports.SHARKFIN_PACKAGE = exports.TOKEN_REGISTRY = exports.TOKEN_PACKAGE = void 0;
4
+ exports.TOKEN_PACKAGE = "0xe879e96fb90a8559127091f1176a2d10bb67c6ff";
5
+ exports.TOKEN_REGISTRY = "0x5dce92f67eeda471369b734deac0d540b751cea6"; //fake btc registry
6
6
  exports.SHARKFIN_PACKAGE = "0x3085e089d748e09ae2a5859531ec3bc34b1e13b4";
7
7
  exports.SHARKFIN_REGISTRY = "0xd27515bcf75daba9cff1da5b93bd4f08c781cea2";
8
8
  exports.DOV_PACKAGE = "0x6fbe0bd487e9ca263f682f8d192750ef4ecce73d";
@@ -11,3 +11,11 @@ exports.COVERED_CALL_REGISTRY = "0xb02452d0bbef3cbdc7840ea5bad27bcdd4031675";
11
11
  exports.COVERED_CALL_MANAGER = "0x8517b2dbaae56eeb84352e4869b289459c68965b";
12
12
  exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
13
13
  exports.TEST_MNEMONIC = "tackle wheat jungle viable memory dwarf swift fold purpose cattle impose horn";
14
+ exports.TOKEN_NAME = ["BTC", "ETH", "SUI", "USDC", "USDT"];
15
+ exports.TOKEN_NAME_TO_MODULE = {
16
+ "BTC": "token_btc",
17
+ "ETH": "token_eth",
18
+ "SUI": "token_sui",
19
+ "USDC": "token_usdc",
20
+ "USDT": "token_usdt",
21
+ };
@@ -39,13 +39,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var getMintTx_1 = require("../utils/getMintTx");
40
40
  var constants_1 = require("../constants");
41
41
  (function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var amount, mintTx;
42
+ var amount, moduleName, mintTx;
43
43
  return __generator(this, function (_a) {
44
44
  switch (_a.label) {
45
45
  case 0:
46
46
  console.log("test for getMintTx()");
47
47
  amount = 10000;
48
- return [4 /*yield*/, (0, getMintTx_1.getMintTx)(constants_1.TOKEN_PACKAGE, constants_1.TOKEN_REGISTRY, amount)];
48
+ moduleName = constants_1.TOKEN_NAME["BTC"] //reference: sui-dev-token repo
49
+ ;
50
+ return [4 /*yield*/, (0, getMintTx_1.getMintTx)(constants_1.TOKEN_PACKAGE, constants_1.TOKEN_REGISTRY, moduleName, amount)];
49
51
  case 1:
50
52
  mintTx = _a.sent();
51
53
  console.log(mintTx);
@@ -41,9 +41,10 @@ var getSubVault_1 = require("../utils/getSubVault");
41
41
  var res;
42
42
  return __generator(this, function (_a) {
43
43
  switch (_a.label) {
44
- case 0: return [4 /*yield*/, (0, getSubVault_1.subVaults)()];
44
+ case 0: return [4 /*yield*/, (0, getSubVault_1.subVaults)()]; //TODO: let registry be input variable
45
45
  case 1:
46
- res = _a.sent();
46
+ res = _a.sent() //TODO: let registry be input variable
47
+ ;
47
48
  console.log(res);
48
49
  return [2 /*return*/];
49
50
  }
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var getMintTx_1 = require("../utils/getMintTx");
40
- var getCreateTokenRegistryTx_1 = require("../utils/getCreateTokenRegistryTx");
41
40
  var constants_1 = require("../constants");
42
41
  var sui_js_1 = require("@mysten/sui.js");
43
42
  var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
@@ -45,45 +44,46 @@ var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
45
44
  var signer = new sui_js_1.RawSigner(keypair, provider);
46
45
  var mintAmount = 10005;
47
46
  (function () { return __awaiter(void 0, void 0, void 0, function () {
48
- var createTokenRegistryTx, moveCallTxn, digest, txn, newRegistry, mintTx, digest, tokenObjectId, tokenObj, newTokenId, tokenAmount;
47
+ var obj, type, tokenName, moudleName, mintTx, moveCallTxn, digest, txn, tokenObjectId, tokenObj, newTokenId;
49
48
  return __generator(this, function (_a) {
50
49
  switch (_a.label) {
51
50
  case 0:
52
51
  console.log("test for mint, try to mint " + mintAmount + " ...");
53
- console.log("create registry in pakcage:");
54
- return [4 /*yield*/, (0, getCreateTokenRegistryTx_1.getCreateTokenRegistryTx)(constants_1.TOKEN_PACKAGE)];
52
+ return [4 /*yield*/, provider.getObject(constants_1.TOKEN_REGISTRY)];
55
53
  case 1:
56
- createTokenRegistryTx = _a.sent();
57
- return [4 /*yield*/, signer.executeMoveCall(createTokenRegistryTx)];
54
+ obj = _a.sent();
55
+ type = obj.details.data.fields.supply.type;
56
+ tokenName = constants_1.TOKEN_NAME.find(function (e) { return type.includes(e); });
57
+ if (!tokenName) {
58
+ console.log("can't find token in type: " + type);
59
+ return [2 /*return*/];
60
+ }
61
+ moudleName = constants_1.TOKEN_NAME_TO_MODULE[tokenName];
62
+ //@ts-ignore
63
+ console.log("Before: total mint fake " + tokenName + " token in the registry: " + obj.details.data.fields.supply.fields.value);
64
+ return [4 /*yield*/, (0, getMintTx_1.getMintTx)(constants_1.TOKEN_PACKAGE, constants_1.TOKEN_REGISTRY, moudleName, mintAmount)];
58
65
  case 2:
59
- moveCallTxn = _a.sent();
60
- digest = moveCallTxn.EffectsCert.certificate.transactionDigest;
61
- return [4 /*yield*/, provider.getTransactionWithEffects(digest)];
62
- case 3:
63
- txn = _a.sent();
64
- newRegistry = txn.effects.created[0].reference.objectId;
65
- console.log("new registry for mint token: " + newRegistry);
66
- return [4 /*yield*/, (0, getMintTx_1.getMintTx)(constants_1.TOKEN_PACKAGE, newRegistry, mintAmount)];
67
- case 4:
68
66
  mintTx = _a.sent();
69
67
  return [4 /*yield*/, signer.executeMoveCall(mintTx)];
70
- case 5:
68
+ case 3:
71
69
  moveCallTxn = _a.sent();
72
70
  digest = moveCallTxn.EffectsCert.certificate.transactionDigest;
73
71
  return [4 /*yield*/, provider.getTransactionWithEffects(digest)];
74
- case 6:
75
- // console.log("digest: " + digest);
72
+ case 4:
76
73
  txn = _a.sent();
77
74
  tokenObjectId = txn.effects.created[0].reference.objectId;
78
75
  return [4 /*yield*/, provider.getObject(tokenObjectId)
79
76
  //@ts-ignore
80
77
  ];
81
- case 7:
78
+ case 5:
82
79
  tokenObj = _a.sent();
83
80
  newTokenId = tokenObj.details.data.fields.id.id;
84
81
  console.log("newTokenId: " + newTokenId);
85
- tokenAmount = tokenObj.details.data.fields.balance;
86
- console.log("tokenAmount: " + tokenAmount);
82
+ return [4 /*yield*/, provider.getObject(constants_1.TOKEN_REGISTRY)];
83
+ case 6:
84
+ obj = _a.sent();
85
+ //@ts-ignore
86
+ console.log("After: total mint fake " + tokenName + " token in the registry: " + obj.details.data.fields.supply.fields.value);
87
87
  return [2 /*return*/];
88
88
  }
89
89
  });
@@ -1 +1 @@
1
- export declare function getMintTx(packageId: string, registry: string, amount: number): Promise<any>;
1
+ export declare function getMintTx(packageId: string, registry: string, moduleName: string, amount: number): Promise<any>;
@@ -37,13 +37,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getMintTx = void 0;
40
- function getMintTx(packageId, registry, amount) {
40
+ function getMintTx(packageId, registry, moduleName, amount) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
44
44
  tx = {
45
45
  packageObjectId: packageId,
46
- module: 'token',
46
+ module: moduleName,
47
47
  function: 'mint',
48
48
  typeArguments: [],
49
49
  arguments: [
@@ -58,5 +58,5 @@ function getMintTx(packageId, registry, amount) {
58
58
  }
59
59
  exports.getMintTx = getMintTx;
60
60
  /*
61
- sui client call --gas-budget 10000 --package $PACKAGE --module "token" --function "mint" --args $REGISTRY 10000
61
+ sui client call --gas-budget 10000 --package 0xe879e96fb90a8559127091f1176a2d10bb67c6ff --module "token_btc" --function "mint" --args 0x5dce92f67eeda471369b734deac0d540b751cea6 10000
62
62
  */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "0.1.2",
5
+ "version": "0.1.3",
6
6
  "dependencies": {
7
7
  "@mysten/sui.js": "^0.17.1",
8
8
  "@types/node": "^17.0.0",