@typus/typus-sdk 1.0.2 → 1.0.4
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/lib/config.json +18 -0
- package/lib/constants.d.ts +26 -0
- package/lib/constants.js +37 -0
- package/lib/scripts/getSubVault.d.ts +0 -0
- package/lib/scripts/getSubVault.js +6 -0
- package/lib/scripts/sui.d.ts +1 -0
- package/lib/scripts/sui.js +174 -0
- package/lib/test/authorized/testAuthorizedNewPortfolioVault.d.ts +1 -0
- package/lib/test/authorized/testAuthorizedNewPortfolioVault.js +82 -0
- package/lib/test/authorized/testAuthorizedUpdateUpcomingVaultConfig.d.ts +1 -0
- package/lib/test/authorized/testAuthorizedUpdateUpcomingVaultConfig.js +71 -0
- package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.d.ts +1 -0
- package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.js +68 -0
- package/lib/test/getBidData.d.ts +1 -0
- package/lib/test/getBidData.js +55 -0
- package/lib/test/getVaultData.d.ts +1 -0
- package/lib/test/getVaultData.js +55 -0
- package/lib/test/getWhiteListFromRegistry.d.ts +1 -0
- package/lib/test/getWhiteListFromRegistry.js +55 -0
- package/lib/test/helper/getAuctionMaxSize.d.ts +1 -0
- package/lib/test/helper/getAuctionMaxSize.js +76 -0
- package/lib/test/helper/getUserStatus.d.ts +1 -0
- package/lib/test/helper/getUserStatus.js +83 -0
- package/lib/test/testCrypto.d.ts +1 -0
- package/lib/test/testCrypto.js +54 -0
- package/lib/test/testMint.d.ts +1 -0
- package/lib/test/testMint.js +137 -0
- package/lib/test/testSDK.d.ts +1 -0
- package/lib/test/testSDK.js +74 -0
- package/lib/test/testSubscribeEvent.d.ts +1 -0
- package/lib/test/testSubscribeEvent.js +97 -0
- package/lib/test/user/testClaim.d.ts +1 -0
- package/lib/test/user/testClaim.js +68 -0
- package/lib/test/user/testCompound.d.ts +1 -0
- package/lib/test/user/testCompound.js +68 -0
- package/lib/test/user/testDeposit.d.ts +1 -0
- package/lib/test/user/testDeposit.js +79 -0
- package/lib/test/user/testHarvest.d.ts +1 -0
- package/lib/test/user/testHarvest.js +68 -0
- package/lib/test/user/testNewBid.d.ts +1 -0
- package/lib/test/user/testNewBid.js +77 -0
- package/lib/test/user/testUnsubscribe.d.ts +1 -0
- package/lib/test/user/testUnsubscribe.js +69 -0
- package/lib/test/user/testWithdraw.d.ts +1 -0
- package/lib/test/user/testWithdraw.js +70 -0
- package/lib/utils/auction/getBid.d.ts +3 -0
- package/lib/utils/auction/getBid.js +77 -0
- package/lib/utils/auction/sealedAuction.d.ts +33 -0
- package/lib/utils/auction/sealedAuction.js +64 -0
- package/lib/utils/fetchData.d.ts +95 -0
- package/lib/utils/fetchData.js +38 -0
- package/lib/utils/getMintTx.d.ts +2 -0
- package/lib/utils/getMintTx.js +60 -0
- package/lib/utils/getTypeArgumentFromToken.d.ts +2 -0
- package/lib/utils/getTypeArgumentFromToken.js +74 -0
- package/lib/utils/getVaultData.d.ts +4 -0
- package/lib/utils/getVaultData.js +229 -0
- package/lib/utils/getWhiteListFromRegistry.d.ts +2 -0
- package/lib/utils/getWhiteListFromRegistry.js +75 -0
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.js +63 -0
- package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.d.ts +1 -0
- package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.js +61 -0
- package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.d.ts +38 -0
- package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.js +116 -0
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.js +63 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.d.ts +1 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.js +60 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.js +70 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.d.ts +1 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.js +64 -0
- package/lib/utils/portfolio/helper/getAuctionMaxSize.d.ts +8 -0
- package/lib/utils/portfolio/helper/getAuctionMaxSize.js +64 -0
- package/lib/utils/portfolio/helper/getUserStatus.d.ts +30 -0
- package/lib/utils/portfolio/helper/getUserStatus.js +100 -0
- package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.d.ts +8 -0
- package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.js +67 -0
- package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.d.ts +10 -0
- package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.js +70 -0
- package/lib/utils/portfolio/manager/getCloseAuctionTx.d.ts +1 -0
- package/lib/utils/portfolio/manager/getCloseAuctionTx.js +62 -0
- package/lib/utils/portfolio/manager/getCloseVaultTx.d.ts +1 -0
- package/lib/utils/portfolio/manager/getCloseVaultTx.js +60 -0
- package/lib/utils/portfolio/manager/getDeliveryTx.d.ts +1 -0
- package/lib/utils/portfolio/manager/getDeliveryTx.js +62 -0
- package/lib/utils/portfolio/manager/getEvolutionTx.d.ts +15 -0
- package/lib/utils/portfolio/manager/getEvolutionTx.js +78 -0
- package/lib/utils/portfolio/manager/getNewManagerTx.d.ts +8 -0
- package/lib/utils/portfolio/manager/getNewManagerTx.js +66 -0
- package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.d.ts +38 -0
- package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.js +116 -0
- package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.d.ts +8 -0
- package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.js +67 -0
- package/lib/utils/portfolio/manager/getRemoveManagerTx.d.ts +6 -0
- package/lib/utils/portfolio/manager/getRemoveManagerTx.js +63 -0
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.d.ts +10 -0
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.js +70 -0
- package/lib/utils/portfolio/manager/getUpdateCapacityTx.d.ts +1 -0
- package/lib/utils/portfolio/manager/getUpdateCapacityTx.js +61 -0
- package/lib/utils/portfolio/user/getClaimAndHarvestTx.d.ts +10 -0
- package/lib/utils/portfolio/user/getClaimAndHarvestTx.js +66 -0
- package/lib/utils/portfolio/user/getClaimTx.d.ts +10 -0
- package/lib/utils/portfolio/user/getClaimTx.js +66 -0
- package/lib/utils/portfolio/user/getCompoundTx.d.ts +9 -0
- package/lib/utils/portfolio/user/getCompoundTx.js +66 -0
- package/lib/utils/portfolio/user/getDepositTx.d.ts +12 -0
- package/lib/utils/portfolio/user/getDepositTx.js +73 -0
- package/lib/utils/portfolio/user/getHarvestTx.d.ts +10 -0
- package/lib/utils/portfolio/user/getHarvestTx.js +66 -0
- package/lib/utils/portfolio/user/getNewBidTx.d.ts +14 -0
- package/lib/utils/portfolio/user/getNewBidTx.js +77 -0
- package/lib/utils/portfolio/user/getUnsubscribeTx.d.ts +10 -0
- package/lib/utils/portfolio/user/getUnsubscribeTx.js +66 -0
- package/lib/utils/portfolio/user/getWithdrawTx.d.ts +10 -0
- package/lib/utils/portfolio/user/getWithdrawTx.js +67 -0
- package/package.json +2 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.constructBidInfo = exports.getBidHash = exports.decryptBid = exports.encryptBid = void 0;
|
|
7
|
+
var bcs_1 = require("@mysten/bcs");
|
|
8
|
+
var js_sha3_1 = require("js-sha3");
|
|
9
|
+
var encrypt_with_password_1 = __importDefault(require("encrypt-with-password"));
|
|
10
|
+
var random_bigint_1 = __importDefault(require("random-bigint"));
|
|
11
|
+
/**
|
|
12
|
+
* Encrypt bid info
|
|
13
|
+
* @param {bigint} price bid price
|
|
14
|
+
* @param {bigint} size bid size
|
|
15
|
+
* @param {string} secret secret to encrypt the bid info
|
|
16
|
+
* @returns the first element is the random number generated during bid encryption process,
|
|
17
|
+
* and the second is bid ciphertext
|
|
18
|
+
*/
|
|
19
|
+
function encryptBid(price, size, secret) {
|
|
20
|
+
var randomNumber = (0, random_bigint_1.default)(64);
|
|
21
|
+
var msg = constructBidInfo(price, size, randomNumber);
|
|
22
|
+
var res = encrypt_with_password_1.default.encrypt(msg.toString("hex"), secret);
|
|
23
|
+
return [randomNumber, res];
|
|
24
|
+
}
|
|
25
|
+
exports.encryptBid = encryptBid;
|
|
26
|
+
/**
|
|
27
|
+
* Decrypt to bid info
|
|
28
|
+
* @param {string} encryptedBid bid ciphertext
|
|
29
|
+
* @param {string} secret secret to decrypt the ciphertext to plain bid info
|
|
30
|
+
* @returns [bid price, bid size, blindingFactor]
|
|
31
|
+
*/
|
|
32
|
+
function decryptBid(encryptedBid, secret) {
|
|
33
|
+
var res = encrypt_with_password_1.default.decrypt(encryptedBid, secret);
|
|
34
|
+
var buffer = Buffer.from(res, "hex");
|
|
35
|
+
var price = buffer.slice(0, buffer.length / 3).readBigUInt64LE(0);
|
|
36
|
+
var size = buffer.slice(buffer.length / 3, buffer.length / 3 * 2).readBigUInt64LE(0);
|
|
37
|
+
var blindingFactor = buffer.slice(buffer.length / 3 * 2).readBigUInt64LE(0);
|
|
38
|
+
return [price, size, blindingFactor];
|
|
39
|
+
}
|
|
40
|
+
exports.decryptBid = decryptBid;
|
|
41
|
+
/**
|
|
42
|
+
* Get hash of bid info - should be same as onchain
|
|
43
|
+
* @param {bigint} price bid price
|
|
44
|
+
* @param {bigint} size bid size
|
|
45
|
+
* @param {bigint} blindingFactor a random number
|
|
46
|
+
* @returns {string} the hash of bid info
|
|
47
|
+
*/
|
|
48
|
+
function getBidHash(price, size, blindingFactor) {
|
|
49
|
+
var msg = constructBidInfo(price, size, blindingFactor);
|
|
50
|
+
var hash = (0, js_sha3_1.sha3_256)(msg.toBytes());
|
|
51
|
+
return hash;
|
|
52
|
+
}
|
|
53
|
+
exports.getBidHash = getBidHash;
|
|
54
|
+
/**
|
|
55
|
+
* Serialize bid info to BCS buffer - should be same as onchain
|
|
56
|
+
* @param {bigint} price bid price
|
|
57
|
+
* @param {bigint} size bid size
|
|
58
|
+
* @param {bigint} blindingFactor a random number
|
|
59
|
+
* @returns {BcsWriter} the serialized bid info
|
|
60
|
+
*/
|
|
61
|
+
function constructBidInfo(price, size, blindingFactor) {
|
|
62
|
+
return new bcs_1.BcsWriter().write64(price).write64(size).write64(blindingFactor);
|
|
63
|
+
}
|
|
64
|
+
exports.constructBidInfo = constructBidInfo;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export interface PortfolioVault {
|
|
2
|
+
vaultId: string;
|
|
3
|
+
typeArgs: string[];
|
|
4
|
+
assets: string[];
|
|
5
|
+
info: Info;
|
|
6
|
+
config: Config;
|
|
7
|
+
depositVault: DepositVault;
|
|
8
|
+
bidVault: BidVault;
|
|
9
|
+
auction: Auction;
|
|
10
|
+
authority: string[];
|
|
11
|
+
tvl: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Info {
|
|
14
|
+
index: string;
|
|
15
|
+
creator: string;
|
|
16
|
+
createTsMs: string;
|
|
17
|
+
round: string;
|
|
18
|
+
deliveryInfo: DeliveryInfo;
|
|
19
|
+
}
|
|
20
|
+
export interface Config {
|
|
21
|
+
optionType: string;
|
|
22
|
+
period: number;
|
|
23
|
+
activationTsMs: string;
|
|
24
|
+
expirationTsMs: string;
|
|
25
|
+
dTokenDecimal: string;
|
|
26
|
+
bTokenDecimal: string;
|
|
27
|
+
oTokenDecimal: string;
|
|
28
|
+
lotSize: string;
|
|
29
|
+
capacity: string;
|
|
30
|
+
leverage: string;
|
|
31
|
+
hasNext: boolean;
|
|
32
|
+
activeVaultConfig: VaultConfig;
|
|
33
|
+
warmupVaultConfig: VaultConfig;
|
|
34
|
+
upcomingVaultConfig: VaultConfig;
|
|
35
|
+
}
|
|
36
|
+
export declare function parseVaultConfig(vaultConfigF: any): VaultConfig;
|
|
37
|
+
export declare function parsePayoffConfig(payoffConfigF: any): PayoffConfig;
|
|
38
|
+
export interface PayoffConfig {
|
|
39
|
+
strikePct: string;
|
|
40
|
+
weight: string;
|
|
41
|
+
isBuyer: boolean;
|
|
42
|
+
strike: string;
|
|
43
|
+
}
|
|
44
|
+
export interface VaultConfig {
|
|
45
|
+
payoffConfigs: PayoffConfig[];
|
|
46
|
+
strikeIncrement: string;
|
|
47
|
+
decaySpeed: string;
|
|
48
|
+
initialPrice: string;
|
|
49
|
+
finalPrice: string;
|
|
50
|
+
auctionDurationInMs: string;
|
|
51
|
+
}
|
|
52
|
+
export interface DeliveryInfo {
|
|
53
|
+
round: string;
|
|
54
|
+
price: string;
|
|
55
|
+
size: string;
|
|
56
|
+
premium: string;
|
|
57
|
+
tsMs: string;
|
|
58
|
+
}
|
|
59
|
+
export interface DepositVault {
|
|
60
|
+
activeSubVault: SubVault;
|
|
61
|
+
deactivatingSubVault: SubVault;
|
|
62
|
+
inactiveSubVault: SubVault;
|
|
63
|
+
warmupSubVault: SubVault;
|
|
64
|
+
hasNext: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface BidVault {
|
|
67
|
+
bidderSubVault: SubVault;
|
|
68
|
+
premiumSubVault: SubVault;
|
|
69
|
+
performanceFeeSubVault: SubVault;
|
|
70
|
+
}
|
|
71
|
+
export interface SubVault {
|
|
72
|
+
balance: string;
|
|
73
|
+
shareSupply: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function parseSubVault(subVaultF: any): SubVault;
|
|
76
|
+
export interface Auction {
|
|
77
|
+
startTsMs: string;
|
|
78
|
+
endTsMs: string;
|
|
79
|
+
priceConfig: PriceConfig;
|
|
80
|
+
index: string;
|
|
81
|
+
totalBidSize: string;
|
|
82
|
+
ableToRemoveBid: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface PriceConfig {
|
|
85
|
+
decaySpeed: string;
|
|
86
|
+
initialPrice: string;
|
|
87
|
+
finalPrice: string;
|
|
88
|
+
}
|
|
89
|
+
export interface Bid {
|
|
90
|
+
price: string;
|
|
91
|
+
size: string;
|
|
92
|
+
tsMs: string;
|
|
93
|
+
tokenBalance: string;
|
|
94
|
+
ownerAddress: string;
|
|
95
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSubVault = exports.parsePayoffConfig = exports.parseVaultConfig = void 0;
|
|
4
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
5
|
+
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.devnetConnection); //for read only operations
|
|
6
|
+
var decode = function (str) {
|
|
7
|
+
return Buffer.from(str, "base64").toString("binary");
|
|
8
|
+
};
|
|
9
|
+
function parseVaultConfig(vaultConfigF) {
|
|
10
|
+
var payoffConfigs = vaultConfigF.payoff_configs.map(function (x) {
|
|
11
|
+
return parsePayoffConfig(x.fields);
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
payoffConfigs: payoffConfigs,
|
|
15
|
+
strikeIncrement: vaultConfigF.strike_increment,
|
|
16
|
+
decaySpeed: vaultConfigF.decay_speed,
|
|
17
|
+
initialPrice: vaultConfigF.initial_price,
|
|
18
|
+
finalPrice: vaultConfigF.final_price,
|
|
19
|
+
auctionDurationInMs: vaultConfigF.auction_duration_in_ms,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.parseVaultConfig = parseVaultConfig;
|
|
23
|
+
function parsePayoffConfig(payoffConfigF) {
|
|
24
|
+
return {
|
|
25
|
+
strikePct: payoffConfigF.strike_pct,
|
|
26
|
+
weight: payoffConfigF.weight,
|
|
27
|
+
isBuyer: payoffConfigF.is_buyer,
|
|
28
|
+
strike: payoffConfigF.strike,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.parsePayoffConfig = parsePayoffConfig;
|
|
32
|
+
function parseSubVault(subVaultF) {
|
|
33
|
+
return {
|
|
34
|
+
balance: subVaultF.balance,
|
|
35
|
+
shareSupply: subVaultF.share_supply,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.parseSubVault = parseSubVault;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getMintTx = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
41
|
+
function getMintTx(gasBudget, packageId, registry, moduleName, amount) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var tx, target, txArguments;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
tx = new sui_js_1.TransactionBlock();
|
|
46
|
+
target = "".concat(packageId, "::").concat(moduleName, "::mint");
|
|
47
|
+
txArguments = [tx.pure(registry), tx.pure(amount)];
|
|
48
|
+
tx.moveCall({
|
|
49
|
+
target: target,
|
|
50
|
+
arguments: txArguments,
|
|
51
|
+
});
|
|
52
|
+
tx.setGasBudget(gasBudget);
|
|
53
|
+
return [2 /*return*/, tx];
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.getMintTx = getMintTx;
|
|
58
|
+
/*
|
|
59
|
+
sui client call --gas-budget 10000 --package 0xe879e96fb90a8559127091f1176a2d10bb67c6ff --module "token_btc" --function "mint" --args 0x5dce92f67eeda471369b734deac0d540b751cea6 10000
|
|
60
|
+
*/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getTypeArgumentFromToken = void 0;
|
|
40
|
+
function getTypeArgumentFromToken(token, provider) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var tokenInfo, typeArgument, e_1;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0:
|
|
46
|
+
_a.trys.push([0, 2, , 3]);
|
|
47
|
+
return [4 /*yield*/, provider.getObject({
|
|
48
|
+
id: token,
|
|
49
|
+
options: { showContent: true },
|
|
50
|
+
})];
|
|
51
|
+
case 1:
|
|
52
|
+
tokenInfo = _a.sent();
|
|
53
|
+
if (tokenInfo.error !== undefined) {
|
|
54
|
+
console.log("obj not exists, but is:");
|
|
55
|
+
console.log(tokenInfo.error.tag);
|
|
56
|
+
return [2 /*return*/];
|
|
57
|
+
}
|
|
58
|
+
1;
|
|
59
|
+
console.log(tokenInfo);
|
|
60
|
+
typeArgument = tokenInfo.data.content.type;
|
|
61
|
+
console.log(typeArgument);
|
|
62
|
+
typeArgument = typeArgument.split("<")[1];
|
|
63
|
+
typeArgument = typeArgument.split(">")[0];
|
|
64
|
+
return [2 /*return*/, typeArgument];
|
|
65
|
+
case 2:
|
|
66
|
+
e_1 = _a.sent();
|
|
67
|
+
console.error(e_1);
|
|
68
|
+
return [3 /*break*/, 3];
|
|
69
|
+
case 3: return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.getTypeArgumentFromToken = getTypeArgumentFromToken;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
+
import { PortfolioVault } from "./fetchData";
|
|
3
|
+
export declare function getVaultDataFromRegistry(registry: string, provider: JsonRpcProvider): Promise<PortfolioVault[]>;
|
|
4
|
+
export declare function getNodesKeyFromLinkedList(linkedList: string, provider: JsonRpcProvider): Promise<string[]>;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.getNodesKeyFromLinkedList = exports.getVaultDataFromRegistry = void 0;
|
|
51
|
+
var fetchData_1 = require("./fetchData");
|
|
52
|
+
function getVaultDataFromRegistry(registry, provider) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var vaults, coveredCallVaults, coveredCallVaultsId, objsInfo, objsInfo_1, objsInfo_1_1, objInfo, vaultId, type, typeArgs, assets, infoFields, deliveryInfo, fields, info, config, configRes, depositVaultField, depositVault, bidVaultField, bidVault, auctionField, auctionRes, auction, priceConfig, priceConfigRes, tvl, authorityId, authority, portfolioVaults, e_1_1;
|
|
55
|
+
var e_1, _a;
|
|
56
|
+
return __generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
vaults = [];
|
|
60
|
+
return [4 /*yield*/, provider.getDynamicFields({
|
|
61
|
+
parentId: registry,
|
|
62
|
+
})];
|
|
63
|
+
case 1:
|
|
64
|
+
coveredCallVaults = (_b.sent()).data;
|
|
65
|
+
coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
|
|
66
|
+
return [4 /*yield*/, provider.multiGetObjects({
|
|
67
|
+
ids: coveredCallVaultsId,
|
|
68
|
+
options: { showContent: true },
|
|
69
|
+
})];
|
|
70
|
+
case 2:
|
|
71
|
+
objsInfo = _b.sent();
|
|
72
|
+
_b.label = 3;
|
|
73
|
+
case 3:
|
|
74
|
+
_b.trys.push([3, 8, 9, 10]);
|
|
75
|
+
objsInfo_1 = __values(objsInfo), objsInfo_1_1 = objsInfo_1.next();
|
|
76
|
+
_b.label = 4;
|
|
77
|
+
case 4:
|
|
78
|
+
if (!!objsInfo_1_1.done) return [3 /*break*/, 7];
|
|
79
|
+
objInfo = objsInfo_1_1.value;
|
|
80
|
+
if (objInfo.error !== undefined) {
|
|
81
|
+
console.log("obj not exist");
|
|
82
|
+
return [3 /*break*/, 6];
|
|
83
|
+
}
|
|
84
|
+
vaultId = objInfo.data.content.fields.id.id;
|
|
85
|
+
type = objInfo.data.content.fields.value.type;
|
|
86
|
+
type = type.split("<")[1];
|
|
87
|
+
type = type.split(">")[0];
|
|
88
|
+
typeArgs = type.split(", ");
|
|
89
|
+
assets = typeArgs.map(function (x) { return x.split("::")[2]; });
|
|
90
|
+
infoFields = objInfo.data.content.fields.value.fields.info.fields;
|
|
91
|
+
deliveryInfo = void 0;
|
|
92
|
+
//@ts-ignore
|
|
93
|
+
if (infoFields.delivery_info) {
|
|
94
|
+
fields =
|
|
95
|
+
//@ts-ignore
|
|
96
|
+
infoFields.delivery_info.fields;
|
|
97
|
+
deliveryInfo = {
|
|
98
|
+
round: fields.round,
|
|
99
|
+
price: fields.price,
|
|
100
|
+
size: fields.size,
|
|
101
|
+
premium: fields.premium,
|
|
102
|
+
tsMs: fields.ts_ms,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
deliveryInfo = {};
|
|
107
|
+
}
|
|
108
|
+
info = {
|
|
109
|
+
index: infoFields.index,
|
|
110
|
+
creator: infoFields.creator,
|
|
111
|
+
createTsMs: infoFields.create_ts_ms,
|
|
112
|
+
round: infoFields.round,
|
|
113
|
+
deliveryInfo: deliveryInfo,
|
|
114
|
+
};
|
|
115
|
+
config = objInfo.data.content.fields.value.fields.config.fields;
|
|
116
|
+
configRes = {
|
|
117
|
+
optionType: config.option_type,
|
|
118
|
+
period: config.period,
|
|
119
|
+
activationTsMs: config.activation_ts_ms,
|
|
120
|
+
expirationTsMs: config.expiration_ts_ms,
|
|
121
|
+
dTokenDecimal: config.d_token_decimal,
|
|
122
|
+
bTokenDecimal: config.b_token_decimal,
|
|
123
|
+
oTokenDecimal: config.o_token_decimal,
|
|
124
|
+
lotSize: config.lot_size,
|
|
125
|
+
capacity: (Number(config.capacity) /
|
|
126
|
+
Math.pow(10, config.d_token_decimal)).toString(),
|
|
127
|
+
leverage: config.leverage,
|
|
128
|
+
hasNext: config.has_next,
|
|
129
|
+
activeVaultConfig: (0, fetchData_1.parseVaultConfig)(config.active_vault_config.fields),
|
|
130
|
+
warmupVaultConfig: (0, fetchData_1.parseVaultConfig)(config.warmup_vault_config.fields),
|
|
131
|
+
upcomingVaultConfig: (0, fetchData_1.parseVaultConfig)(config.upcoming_vault_config.fields),
|
|
132
|
+
};
|
|
133
|
+
depositVaultField =
|
|
134
|
+
//@ts-ignore
|
|
135
|
+
objInfo.data.content.fields.value.fields.deposit_vault.fields;
|
|
136
|
+
depositVault = {
|
|
137
|
+
activeSubVault: (0, fetchData_1.parseSubVault)(depositVaultField.active_sub_vault.fields),
|
|
138
|
+
deactivatingSubVault: (0, fetchData_1.parseSubVault)(depositVaultField.deactivating_sub_vault.fields),
|
|
139
|
+
inactiveSubVault: (0, fetchData_1.parseSubVault)(depositVaultField.inactive_sub_vault.fields),
|
|
140
|
+
warmupSubVault: (0, fetchData_1.parseSubVault)(depositVaultField.warmup_sub_vault.fields),
|
|
141
|
+
hasNext: depositVaultField.has_next,
|
|
142
|
+
};
|
|
143
|
+
bidVaultField =
|
|
144
|
+
//@ts-ignore
|
|
145
|
+
objInfo.data.content.fields.value.fields.bid_vault.fields;
|
|
146
|
+
bidVault = {
|
|
147
|
+
bidderSubVault: (0, fetchData_1.parseSubVault)(bidVaultField.bidder_sub_vault.fields),
|
|
148
|
+
premiumSubVault: (0, fetchData_1.parseSubVault)(bidVaultField.premium_sub_vault.fields),
|
|
149
|
+
performanceFeeSubVault: (0, fetchData_1.parseSubVault)(bidVaultField.performance_fee_sub_vault.fields),
|
|
150
|
+
};
|
|
151
|
+
auctionField = objInfo.data.content.fields.value.fields.auction;
|
|
152
|
+
auctionRes = void 0;
|
|
153
|
+
if (auctionField) {
|
|
154
|
+
auction = auctionField.fields;
|
|
155
|
+
priceConfig = auction.price_config.fields;
|
|
156
|
+
priceConfigRes = {
|
|
157
|
+
decaySpeed: priceConfig.decay_speed,
|
|
158
|
+
initialPrice: priceConfig.initial_price,
|
|
159
|
+
finalPrice: priceConfig.final_price,
|
|
160
|
+
};
|
|
161
|
+
auctionRes = {
|
|
162
|
+
startTsMs: auction.start_ts_ms,
|
|
163
|
+
endTsMs: auction.end_ts_ms,
|
|
164
|
+
priceConfig: priceConfigRes,
|
|
165
|
+
index: auction.index,
|
|
166
|
+
totalBidSize: auction.total_bid_size,
|
|
167
|
+
ableToRemoveBid: auction.able_to_remove_bid,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
auctionRes = {};
|
|
172
|
+
}
|
|
173
|
+
tvl = Number(depositVault.activeSubVault.balance) +
|
|
174
|
+
Number(depositVault.warmupSubVault.balance);
|
|
175
|
+
authorityId =
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
objInfo.data.content.fields.value.fields.authority.fields.whitelist.fields
|
|
178
|
+
.id.id;
|
|
179
|
+
return [4 /*yield*/, getNodesKeyFromLinkedList(authorityId, provider)];
|
|
180
|
+
case 5:
|
|
181
|
+
authority = _b.sent();
|
|
182
|
+
portfolioVaults = {
|
|
183
|
+
vaultId: vaultId,
|
|
184
|
+
typeArgs: typeArgs,
|
|
185
|
+
assets: assets,
|
|
186
|
+
info: info,
|
|
187
|
+
config: configRes,
|
|
188
|
+
depositVault: depositVault,
|
|
189
|
+
bidVault: bidVault,
|
|
190
|
+
auction: auctionRes,
|
|
191
|
+
authority: authority,
|
|
192
|
+
tvl: tvl.toString(),
|
|
193
|
+
};
|
|
194
|
+
vaults.push(portfolioVaults);
|
|
195
|
+
_b.label = 6;
|
|
196
|
+
case 6:
|
|
197
|
+
objsInfo_1_1 = objsInfo_1.next();
|
|
198
|
+
return [3 /*break*/, 4];
|
|
199
|
+
case 7: return [3 /*break*/, 10];
|
|
200
|
+
case 8:
|
|
201
|
+
e_1_1 = _b.sent();
|
|
202
|
+
e_1 = { error: e_1_1 };
|
|
203
|
+
return [3 /*break*/, 10];
|
|
204
|
+
case 9:
|
|
205
|
+
try {
|
|
206
|
+
if (objsInfo_1_1 && !objsInfo_1_1.done && (_a = objsInfo_1.return)) _a.call(objsInfo_1);
|
|
207
|
+
}
|
|
208
|
+
finally { if (e_1) throw e_1.error; }
|
|
209
|
+
return [7 /*endfinally*/];
|
|
210
|
+
case 10: return [2 /*return*/, vaults];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
exports.getVaultDataFromRegistry = getVaultDataFromRegistry;
|
|
216
|
+
function getNodesKeyFromLinkedList(linkedList, provider) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
var linkedListNodes;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: linkedList })];
|
|
222
|
+
case 1:
|
|
223
|
+
linkedListNodes = (_a.sent()).data.map(function (d) { return d.name.value; });
|
|
224
|
+
return [2 /*return*/, linkedListNodes];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
exports.getNodesKeyFromLinkedList = getNodesKeyFromLinkedList;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getWhiteListFromRegistry = void 0;
|
|
40
|
+
function getWhiteListFromRegistry(registry, provider) {
|
|
41
|
+
var _a;
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var whiteLists, registryInfo, whiteListsTable, whiteListsNodes, whiteListsTablesId, whiteListsTableAddress;
|
|
44
|
+
return __generator(this, function (_b) {
|
|
45
|
+
switch (_b.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
whiteLists = [];
|
|
48
|
+
return [4 /*yield*/, provider.getObject({
|
|
49
|
+
id: registry,
|
|
50
|
+
options: { showContent: true },
|
|
51
|
+
})];
|
|
52
|
+
case 1:
|
|
53
|
+
registryInfo = _b.sent();
|
|
54
|
+
whiteListsTable =
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
(_a = registryInfo.data) === null || _a === void 0 ? void 0 : _a.content.fields.authority.fields.whitelist.fields.id.id;
|
|
57
|
+
return [4 /*yield*/, provider.getDynamicFields({ parentId: whiteListsTable })];
|
|
58
|
+
case 2:
|
|
59
|
+
whiteListsNodes = (_b.sent()).data;
|
|
60
|
+
whiteListsTablesId = whiteListsNodes.map(function (e) { return e.objectId; });
|
|
61
|
+
return [4 /*yield*/, provider.multiGetObjects({
|
|
62
|
+
ids: whiteListsTablesId,
|
|
63
|
+
options: {
|
|
64
|
+
showContent: true,
|
|
65
|
+
},
|
|
66
|
+
})];
|
|
67
|
+
case 3:
|
|
68
|
+
whiteListsTableAddress = _b.sent();
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
return [2 /*return*/, whiteListsTableAddress.map(function (w) { var _a; return (_a = w.data) === null || _a === void 0 ? void 0 : _a.content.fields.name; })];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.getWhiteListFromRegistry = getWhiteListFromRegistry;
|