stackswap-front-api-test-02 1.0.102 → 1.0.105
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 +10 -10
- package/dist/esm/index.d.ts +86 -86
- package/dist/esm/index.js +145 -145
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stackswap/config.d.ts +117 -114
- package/dist/esm/stackswap/config.js +194 -188
- package/dist/esm/stackswap/config.js.map +1 -1
- package/dist/esm/stackswap/manager/farm.manager.d.ts +41 -41
- package/dist/esm/stackswap/manager/farm.manager.js +293 -293
- package/dist/esm/stackswap/manager/farm2.manager.d.ts +60 -60
- package/dist/esm/stackswap/manager/farm2.manager.js +403 -403
- package/dist/esm/stackswap/manager/governance.manager.d.ts +9 -9
- package/dist/esm/stackswap/manager/governance.manager.js +53 -53
- package/dist/esm/stackswap/manager/launchpad.manager.d.ts +13 -13
- package/dist/esm/stackswap/manager/launchpad.manager.js +147 -147
- package/dist/esm/stackswap/manager/lbtc.manager.d.ts +31 -31
- package/dist/esm/stackswap/manager/lbtc.manager.js +326 -326
- package/dist/esm/stackswap/manager/lbtcstaking.manager.d.ts +51 -51
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js +191 -191
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/multisig.manager.d.ts +11 -11
- package/dist/esm/stackswap/manager/multisig.manager.js +51 -51
- package/dist/esm/stackswap/manager/nft.manager.d.ts +52 -52
- package/dist/esm/stackswap/manager/nft.manager.js +243 -243
- package/dist/esm/stackswap/manager/operator.manager.d.ts +17 -17
- package/dist/esm/stackswap/manager/operator.manager.js +85 -85
- package/dist/esm/stackswap/manager/other.manager.d.ts +9 -9
- package/dist/esm/stackswap/manager/other.manager.js +47 -47
- package/dist/esm/stackswap/manager/pool.manager.d.ts +34 -34
- package/dist/esm/stackswap/manager/pool.manager.js +171 -171
- package/dist/esm/stackswap/manager/poxl.manager.d.ts +16 -16
- package/dist/esm/stackswap/manager/poxl.manager.js +71 -71
- package/dist/esm/stackswap/manager/staking.manager.d.ts +25 -25
- package/dist/esm/stackswap/manager/staking.manager.js +233 -233
- package/dist/esm/stackswap/manager/swap.manager.d.ts +39 -39
- package/dist/esm/stackswap/manager/swap.manager.js +332 -332
- package/dist/esm/stackswap/manager/token.manager.d.ts +31 -31
- package/dist/esm/stackswap/manager/token.manager.js +133 -133
- package/dist/esm/stackswap/util.d.ts +35 -35
- package/dist/esm/stackswap/util.js +201 -201
- package/dist/esm/stackswap/util.js.map +1 -1
- package/dist/index.d.ts +86 -86
- package/dist/index.js +154 -154
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/stackswap/config.d.ts +117 -114
- package/dist/stackswap/config.js +199 -193
- package/dist/stackswap/config.js.map +1 -1
- package/dist/stackswap/manager/farm.manager.d.ts +41 -41
- package/dist/stackswap/manager/farm.manager.js +301 -301
- package/dist/stackswap/manager/farm2.manager.d.ts +60 -60
- package/dist/stackswap/manager/farm2.manager.js +410 -410
- package/dist/stackswap/manager/governance.manager.d.ts +9 -9
- package/dist/stackswap/manager/governance.manager.js +60 -60
- package/dist/stackswap/manager/launchpad.manager.d.ts +13 -13
- package/dist/stackswap/manager/launchpad.manager.js +151 -151
- package/dist/stackswap/manager/lbtc.manager.d.ts +31 -31
- package/dist/stackswap/manager/lbtc.manager.js +333 -333
- package/dist/stackswap/manager/lbtcstaking.manager.d.ts +51 -51
- package/dist/stackswap/manager/lbtcstaking.manager.js +198 -198
- package/dist/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/stackswap/manager/multisig.manager.d.ts +11 -11
- package/dist/stackswap/manager/multisig.manager.js +55 -55
- package/dist/stackswap/manager/nft.manager.d.ts +52 -52
- package/dist/stackswap/manager/nft.manager.js +250 -250
- package/dist/stackswap/manager/operator.manager.d.ts +17 -17
- package/dist/stackswap/manager/operator.manager.js +92 -92
- package/dist/stackswap/manager/other.manager.d.ts +9 -9
- package/dist/stackswap/manager/other.manager.js +54 -54
- package/dist/stackswap/manager/pool.manager.d.ts +34 -34
- package/dist/stackswap/manager/pool.manager.js +179 -179
- package/dist/stackswap/manager/poxl.manager.d.ts +16 -16
- package/dist/stackswap/manager/poxl.manager.js +78 -78
- package/dist/stackswap/manager/staking.manager.d.ts +25 -25
- package/dist/stackswap/manager/staking.manager.js +240 -240
- package/dist/stackswap/manager/swap.manager.d.ts +39 -39
- package/dist/stackswap/manager/swap.manager.js +339 -339
- package/dist/stackswap/manager/token.manager.d.ts +31 -31
- package/dist/stackswap/manager/token.manager.js +141 -141
- package/dist/stackswap/util.d.ts +35 -35
- package/dist/stackswap/util.js +218 -218
- package/dist/stackswap/util.js.map +1 -1
- package/package.json +43 -43
- package/src/index.ts +207 -207
- package/src/stackswap/config.ts +305 -297
- package/src/stackswap/manager/farm.manager.ts +399 -399
- package/src/stackswap/manager/farm2.manager.ts +463 -463
- package/src/stackswap/manager/governance.manager.ts +95 -95
- package/src/stackswap/manager/launchpad.manager.ts +190 -190
- package/src/stackswap/manager/lbtcstaking.manager.ts +277 -277
- package/src/stackswap/manager/multisig.manager.ts +87 -87
- package/src/stackswap/manager/nft.manager.ts +307 -307
- package/src/stackswap/manager/operator.manager.ts +123 -123
- package/src/stackswap/manager/other.manager.ts +71 -71
- package/src/stackswap/manager/pool.manager.ts +202 -202
- package/src/stackswap/manager/poxl.manager.ts +99 -99
- package/src/stackswap/manager/staking.manager.ts +321 -321
- package/src/stackswap/manager/swap.manager.ts +392 -392
- package/src/stackswap/manager/token.manager.ts +167 -167
- package/src/stackswap/util.ts +237 -237
|
@@ -1,251 +1,251 @@
|
|
|
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.NftManager = void 0;
|
|
7
|
-
const util_1 = require("../util");
|
|
8
|
-
const connect_1 = require("@stacks/connect");
|
|
9
|
-
const transactions_1 = require("@stacks/transactions");
|
|
10
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
11
|
-
const axios_1 = __importDefault(require("axios"));
|
|
12
|
-
class NftManager {
|
|
13
|
-
constructor(stackswap) {
|
|
14
|
-
this.stackswap = stackswap;
|
|
15
|
-
}
|
|
16
|
-
async getNFTAsset(tokenStr) {
|
|
17
|
-
const token_addr = tokenStr.split('.');
|
|
18
|
-
const url = this.stackswap.config.STACKS_API_URL() + '/v2/contracts/interface/' + token_addr[0] + '/' + token_addr[1];
|
|
19
|
-
const result = await axios_1.default.get(url);
|
|
20
|
-
if (result.data.non_fungible_tokens.length === 1) {
|
|
21
|
-
return tokenStr + '::' + result.data.non_fungible_tokens[0].name;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return tokenStr + '::' + result.data.non_fungible_tokens[0].name;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async getPostConditionFromAssetNFT(account, tokenStr, condition, id) {
|
|
28
|
-
const assetString = await this.getNFTAsset(tokenStr);
|
|
29
|
-
return (0, transactions_1.makeStandardNonFungiblePostCondition)(account, condition, assetString, (0, transactions_1.uintCV)(id));
|
|
30
|
-
}
|
|
31
|
-
async mintNFT(price, addr, callback = null) {
|
|
32
|
-
const post_condition = [];
|
|
33
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.BASE_WSTX_DATA().addr, price, transactions_1.FungibleConditionCode.Equal));
|
|
34
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, addr, 'mint', [
|
|
35
|
-
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress())
|
|
36
|
-
], post_condition, callback);
|
|
37
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
38
|
-
}
|
|
39
|
-
async mintNFT2(mint_fee, callback = null) {
|
|
40
|
-
const post_condition = [];
|
|
41
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.BASE_WSTX_DATA().addr, mint_fee * 1000000, transactions_1.FungibleConditionCode.Equal));
|
|
42
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_WSTX_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
43
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STX_STSW_LP(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
44
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
45
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
46
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'mint', [
|
|
47
|
-
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress()),
|
|
48
|
-
], post_condition, callback);
|
|
49
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
50
|
-
}
|
|
51
|
-
async batchSetMintPass(lists, addr, callback = null) {
|
|
52
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, addr, 'batch-set-mint-pass', [
|
|
53
|
-
(0, transactions_1.listCV)(lists),
|
|
54
|
-
], [], callback);
|
|
55
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
56
|
-
}
|
|
57
|
-
async listInUstx(id, price, comm = this.stackswap.config.CONTRACT_NAME_COMMISSION(), callback = null) {
|
|
58
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'list-in-ustx', [
|
|
59
|
-
(0, transactions_1.uintCV)(id),
|
|
60
|
-
(0, transactions_1.uintCV)(price),
|
|
61
|
-
this.stackswap.getQualifiedAddress(comm),
|
|
62
|
-
], [], callback);
|
|
63
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
64
|
-
}
|
|
65
|
-
async unlistInUstx(id, callback = null) {
|
|
66
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'unlist-in-ustx', [
|
|
67
|
-
(0, transactions_1.uintCV)(id),
|
|
68
|
-
], [], callback);
|
|
69
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
70
|
-
}
|
|
71
|
-
async buyInUstx(id, price, owner, comm = this.stackswap.config.CONTRACT_NAME_COMMISSION(), callback = null) {
|
|
72
|
-
const post_condition = [];
|
|
73
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.BASE_WSTX_DATA().addr, new bignumber_js_1.default(price).multipliedBy(1.075).toFixed(), transactions_1.FungibleConditionCode.LessEqual));
|
|
74
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_WSTX_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
75
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STX_STSW_LP(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
76
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
77
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
78
|
-
post_condition.push(await this.getPostConditionFromAssetNFT(owner, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), transactions_1.NonFungibleConditionCode.DoesNotOwn, '' + id));
|
|
79
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'buy-in-ustx', [
|
|
80
|
-
(0, transactions_1.uintCV)(id),
|
|
81
|
-
(0, transactions_1.contractPrincipalCV)(this.stackswap.config.STACKSWAP_ADDRESS(), comm),
|
|
82
|
-
], post_condition, callback);
|
|
83
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
84
|
-
}
|
|
85
|
-
async reTouchNFT(id, amount, callback = null) {
|
|
86
|
-
const post_condition = [];
|
|
87
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, amount, transactions_1.FungibleConditionCode.Equal));
|
|
88
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_WSTX_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
89
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STX_STSW_LP(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
90
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
91
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
92
|
-
post_condition.push(await this.getPostConditionFromAssetNFT(this.stackswap.getSenderAddress(), this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), transactions_1.NonFungibleConditionCode.DoesNotOwn, '' + id));
|
|
93
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 're-touch', [
|
|
94
|
-
(0, transactions_1.uintCV)(id)
|
|
95
|
-
], post_condition, callback);
|
|
96
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
97
|
-
}
|
|
98
|
-
async regressNFT(id, price = '90000000', callback = null) {
|
|
99
|
-
const post_condition = [];
|
|
100
|
-
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_LBTC_DATA().addr, price, transactions_1.FungibleConditionCode.Equal));
|
|
101
|
-
post_condition.push(await this.getPostConditionFromAssetNFT(this.stackswap.getSenderAddress(), this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), transactions_1.NonFungibleConditionCode.DoesNotOwn, '' + id));
|
|
102
|
-
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'regress-token', [
|
|
103
|
-
(0, transactions_1.uintCV)(id)
|
|
104
|
-
], post_condition, callback);
|
|
105
|
-
await (0, connect_1.openContractCall)(function_option);
|
|
106
|
-
}
|
|
107
|
-
async getNFTData(id) {
|
|
108
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-nft-data', [
|
|
109
|
-
(0, transactions_1.uintCV)(id),
|
|
110
|
-
]);
|
|
111
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
112
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
113
|
-
return result.value;
|
|
114
|
-
}
|
|
115
|
-
async getOwner(id) {
|
|
116
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-owner', [
|
|
117
|
-
(0, transactions_1.uintCV)(id),
|
|
118
|
-
]);
|
|
119
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
120
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
121
|
-
try {
|
|
122
|
-
return result.value.value;
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
return '';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async getMintPass(contract) {
|
|
129
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, contract, 'get-mint-pass-balance', [
|
|
130
|
-
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress()),
|
|
131
|
-
]);
|
|
132
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
133
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
134
|
-
try {
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
catch (e) {
|
|
138
|
-
return '';
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async getPassBalance(contract) {
|
|
142
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, contract, 'get-balance', [
|
|
143
|
-
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress()),
|
|
144
|
-
]);
|
|
145
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
146
|
-
try {
|
|
147
|
-
return (0, transactions_1.cvToValue)(result_raw);
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
return '0';
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async getReserveAmount(id) {
|
|
154
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-reserve-amount', [
|
|
155
|
-
(0, transactions_1.uintCV)(id),
|
|
156
|
-
]);
|
|
157
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
158
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
159
|
-
return result.value;
|
|
160
|
-
}
|
|
161
|
-
async getTokenURI(id) {
|
|
162
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-token-uri', [
|
|
163
|
-
(0, transactions_1.uintCV)(id),
|
|
164
|
-
]);
|
|
165
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
166
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
167
|
-
return result.value;
|
|
168
|
-
}
|
|
169
|
-
async getTotalList() {
|
|
170
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-total-list', []);
|
|
171
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
172
|
-
try {
|
|
173
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
|
-
catch (e) {
|
|
177
|
-
return [];
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async getMarketList() {
|
|
181
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-market-list', []);
|
|
182
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
183
|
-
try {
|
|
184
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
185
|
-
return result;
|
|
186
|
-
}
|
|
187
|
-
catch (e) {
|
|
188
|
-
return [];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
async getMarketListing(id) {
|
|
192
|
-
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-listing-in-ustx', [
|
|
193
|
-
(0, transactions_1.uintCV)(id),
|
|
194
|
-
]);
|
|
195
|
-
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
196
|
-
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
197
|
-
try {
|
|
198
|
-
return result.value.price.value;
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
return 0;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
async getPASSData(isGold) {
|
|
205
|
-
const contractaddr = isGold ? this.stackswap.config.CONTRACT_NAME_GOLD_PASS() : this.stackswap.config.CONTRACT_NAME_SILVER_PASS();
|
|
206
|
-
const temp = {
|
|
207
|
-
id: 0,
|
|
208
|
-
name: 'loading...',
|
|
209
|
-
img_url: `loading...`,
|
|
210
|
-
json_url: isGold ? 'https://gateway.ipfs.io/ipfs/QmQtSMAPvKFEr11VfKio2NHqwayJk4CTUkfmkxgXTR7Q2w' : 'https://gateway.ipfs.io/ipfs/QmQMArAThFXsFtDUyBWBepThCUbANjomWSw9cnmLALLcaM',
|
|
211
|
-
desc: 'loading...',
|
|
212
|
-
attr: {},
|
|
213
|
-
price: 0,
|
|
214
|
-
owner: 'loading...',
|
|
215
|
-
locked_amt: 0,
|
|
216
|
-
addr: contractaddr,
|
|
217
|
-
contract_name: this.stackswap.config.STACKSWAP_ADDRESS() + '.' + contractaddr
|
|
218
|
-
};
|
|
219
|
-
const json_result = await axios_1.default.get(temp.json_url);
|
|
220
|
-
temp.desc = json_result.data.description;
|
|
221
|
-
temp.name = json_result.data.name;
|
|
222
|
-
temp.img_url = 'https://gateway.ipfs/ipfs/' + json_result.data.image.substr(7, json_result.data.image.length);
|
|
223
|
-
return temp;
|
|
224
|
-
}
|
|
225
|
-
async getNFTDataFromID(id_) {
|
|
226
|
-
const temp = {
|
|
227
|
-
id: id_,
|
|
228
|
-
name: 'loading...',
|
|
229
|
-
img_url: `loading...`,
|
|
230
|
-
json_url: `https://gateway.ipfs.io/ipfs/Qmaa5RRUMa9HQRHWJw3HWG3i1NUmb5VgJXT9Zqqg5VHQjX/${id_}.json`,
|
|
231
|
-
desc: 'loading...',
|
|
232
|
-
attr: {
|
|
233
|
-
reTouch: 0,
|
|
234
|
-
},
|
|
235
|
-
price: 0,
|
|
236
|
-
owner: 'loading...',
|
|
237
|
-
locked_amt: 0,
|
|
238
|
-
contract_name: this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT()
|
|
239
|
-
};
|
|
240
|
-
const json_result = await axios_1.default.get(`https://gateway.ipfs.io/ipfs/Qmaa5RRUMa9HQRHWJw3HWG3i1NUmb5VgJXT9Zqqg5VHQjX/${id_}.json`);
|
|
241
|
-
temp.img_url = 'https://gateway.ipfs.io/ipfs/' + json_result.data.image.substr(7, json_result.data.image.length);
|
|
242
|
-
temp.desc = json_result.data.description;
|
|
243
|
-
temp.name = json_result.data.name;
|
|
244
|
-
temp.attr.reTouch = json_result.data.attributes[0].value;
|
|
245
|
-
temp.price = await this.getMarketListing(id_);
|
|
246
|
-
temp.locked_amt = await this.getReserveAmount(id_);
|
|
247
|
-
return temp;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
exports.NftManager = NftManager;
|
|
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.NftManager = void 0;
|
|
7
|
+
const util_1 = require("../util");
|
|
8
|
+
const connect_1 = require("@stacks/connect");
|
|
9
|
+
const transactions_1 = require("@stacks/transactions");
|
|
10
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
class NftManager {
|
|
13
|
+
constructor(stackswap) {
|
|
14
|
+
this.stackswap = stackswap;
|
|
15
|
+
}
|
|
16
|
+
async getNFTAsset(tokenStr) {
|
|
17
|
+
const token_addr = tokenStr.split('.');
|
|
18
|
+
const url = this.stackswap.config.STACKS_API_URL() + '/v2/contracts/interface/' + token_addr[0] + '/' + token_addr[1];
|
|
19
|
+
const result = await axios_1.default.get(url);
|
|
20
|
+
if (result.data.non_fungible_tokens.length === 1) {
|
|
21
|
+
return tokenStr + '::' + result.data.non_fungible_tokens[0].name;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return tokenStr + '::' + result.data.non_fungible_tokens[0].name;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async getPostConditionFromAssetNFT(account, tokenStr, condition, id) {
|
|
28
|
+
const assetString = await this.getNFTAsset(tokenStr);
|
|
29
|
+
return (0, transactions_1.makeStandardNonFungiblePostCondition)(account, condition, assetString, (0, transactions_1.uintCV)(id));
|
|
30
|
+
}
|
|
31
|
+
async mintNFT(price, addr, callback = null) {
|
|
32
|
+
const post_condition = [];
|
|
33
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.BASE_WSTX_DATA().addr, price, transactions_1.FungibleConditionCode.Equal));
|
|
34
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, addr, 'mint', [
|
|
35
|
+
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress())
|
|
36
|
+
], post_condition, callback);
|
|
37
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
38
|
+
}
|
|
39
|
+
async mintNFT2(mint_fee, callback = null) {
|
|
40
|
+
const post_condition = [];
|
|
41
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.BASE_WSTX_DATA().addr, mint_fee * 1000000, transactions_1.FungibleConditionCode.Equal));
|
|
42
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_WSTX_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
43
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STX_STSW_LP(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
44
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
45
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
46
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'mint', [
|
|
47
|
+
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress()),
|
|
48
|
+
], post_condition, callback);
|
|
49
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
50
|
+
}
|
|
51
|
+
async batchSetMintPass(lists, addr, callback = null) {
|
|
52
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, addr, 'batch-set-mint-pass', [
|
|
53
|
+
(0, transactions_1.listCV)(lists),
|
|
54
|
+
], [], callback);
|
|
55
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
56
|
+
}
|
|
57
|
+
async listInUstx(id, price, comm = this.stackswap.config.CONTRACT_NAME_COMMISSION(), callback = null) {
|
|
58
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'list-in-ustx', [
|
|
59
|
+
(0, transactions_1.uintCV)(id),
|
|
60
|
+
(0, transactions_1.uintCV)(price),
|
|
61
|
+
this.stackswap.getQualifiedAddress(comm),
|
|
62
|
+
], [], callback);
|
|
63
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
64
|
+
}
|
|
65
|
+
async unlistInUstx(id, callback = null) {
|
|
66
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'unlist-in-ustx', [
|
|
67
|
+
(0, transactions_1.uintCV)(id),
|
|
68
|
+
], [], callback);
|
|
69
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
70
|
+
}
|
|
71
|
+
async buyInUstx(id, price, owner, comm = this.stackswap.config.CONTRACT_NAME_COMMISSION(), callback = null) {
|
|
72
|
+
const post_condition = [];
|
|
73
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.BASE_WSTX_DATA().addr, new bignumber_js_1.default(price).multipliedBy(1.075).toFixed(), transactions_1.FungibleConditionCode.LessEqual));
|
|
74
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_WSTX_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
75
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STX_STSW_LP(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
76
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
77
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
78
|
+
post_condition.push(await this.getPostConditionFromAssetNFT(owner, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), transactions_1.NonFungibleConditionCode.DoesNotOwn, '' + id));
|
|
79
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'buy-in-ustx', [
|
|
80
|
+
(0, transactions_1.uintCV)(id),
|
|
81
|
+
(0, transactions_1.contractPrincipalCV)(this.stackswap.config.STACKSWAP_ADDRESS(), comm),
|
|
82
|
+
], post_condition, callback);
|
|
83
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
84
|
+
}
|
|
85
|
+
async reTouchNFT(id, amount, callback = null) {
|
|
86
|
+
const post_condition = [];
|
|
87
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, amount, transactions_1.FungibleConditionCode.Equal));
|
|
88
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_WSTX_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
89
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STX_STSW_LP(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
90
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_STSW_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
91
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, transactions_1.FungibleConditionCode.GreaterEqual));
|
|
92
|
+
post_condition.push(await this.getPostConditionFromAssetNFT(this.stackswap.getSenderAddress(), this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), transactions_1.NonFungibleConditionCode.DoesNotOwn, '' + id));
|
|
93
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 're-touch', [
|
|
94
|
+
(0, transactions_1.uintCV)(id)
|
|
95
|
+
], post_condition, callback);
|
|
96
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
97
|
+
}
|
|
98
|
+
async regressNFT(id, price = '90000000', callback = null) {
|
|
99
|
+
const post_condition = [];
|
|
100
|
+
post_condition.push(await (0, util_1.getPostConditionFromAsset)(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), this.stackswap.config.BASE_LBTC_DATA().addr, price, transactions_1.FungibleConditionCode.Equal));
|
|
101
|
+
post_condition.push(await this.getPostConditionFromAssetNFT(this.stackswap.getSenderAddress(), this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT(), transactions_1.NonFungibleConditionCode.DoesNotOwn, '' + id));
|
|
102
|
+
const function_option = (0, util_1.getWriteOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'regress-token', [
|
|
103
|
+
(0, transactions_1.uintCV)(id)
|
|
104
|
+
], post_condition, callback);
|
|
105
|
+
await (0, connect_1.openContractCall)(function_option);
|
|
106
|
+
}
|
|
107
|
+
async getNFTData(id) {
|
|
108
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-nft-data', [
|
|
109
|
+
(0, transactions_1.uintCV)(id),
|
|
110
|
+
]);
|
|
111
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
112
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
113
|
+
return result.value;
|
|
114
|
+
}
|
|
115
|
+
async getOwner(id) {
|
|
116
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-owner', [
|
|
117
|
+
(0, transactions_1.uintCV)(id),
|
|
118
|
+
]);
|
|
119
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
120
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
121
|
+
try {
|
|
122
|
+
return result.value.value;
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async getMintPass(contract) {
|
|
129
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, contract, 'get-mint-pass-balance', [
|
|
130
|
+
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress()),
|
|
131
|
+
]);
|
|
132
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
133
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
134
|
+
try {
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
return '';
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async getPassBalance(contract) {
|
|
142
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, contract, 'get-balance', [
|
|
143
|
+
(0, transactions_1.standardPrincipalCV)(this.stackswap.getSenderAddress()),
|
|
144
|
+
]);
|
|
145
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
146
|
+
try {
|
|
147
|
+
return (0, transactions_1.cvToValue)(result_raw);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
return '0';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async getReserveAmount(id) {
|
|
154
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-reserve-amount', [
|
|
155
|
+
(0, transactions_1.uintCV)(id),
|
|
156
|
+
]);
|
|
157
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
158
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
159
|
+
return result.value;
|
|
160
|
+
}
|
|
161
|
+
async getTokenURI(id) {
|
|
162
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-token-uri', [
|
|
163
|
+
(0, transactions_1.uintCV)(id),
|
|
164
|
+
]);
|
|
165
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
166
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
167
|
+
return result.value;
|
|
168
|
+
}
|
|
169
|
+
async getTotalList() {
|
|
170
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-total-list', []);
|
|
171
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
172
|
+
try {
|
|
173
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async getMarketList() {
|
|
181
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-market-list', []);
|
|
182
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
183
|
+
try {
|
|
184
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async getMarketListing(id) {
|
|
192
|
+
const function_option = (0, util_1.getReadOptions)(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'get-listing-in-ustx', [
|
|
193
|
+
(0, transactions_1.uintCV)(id),
|
|
194
|
+
]);
|
|
195
|
+
const result_raw = await (0, transactions_1.callReadOnlyFunction)(function_option);
|
|
196
|
+
const result = (0, transactions_1.cvToValue)(result_raw);
|
|
197
|
+
try {
|
|
198
|
+
return result.value.price.value;
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async getPASSData(isGold) {
|
|
205
|
+
const contractaddr = isGold ? this.stackswap.config.CONTRACT_NAME_GOLD_PASS() : this.stackswap.config.CONTRACT_NAME_SILVER_PASS();
|
|
206
|
+
const temp = {
|
|
207
|
+
id: 0,
|
|
208
|
+
name: 'loading...',
|
|
209
|
+
img_url: `loading...`,
|
|
210
|
+
json_url: isGold ? 'https://gateway.ipfs.io/ipfs/QmQtSMAPvKFEr11VfKio2NHqwayJk4CTUkfmkxgXTR7Q2w' : 'https://gateway.ipfs.io/ipfs/QmQMArAThFXsFtDUyBWBepThCUbANjomWSw9cnmLALLcaM',
|
|
211
|
+
desc: 'loading...',
|
|
212
|
+
attr: {},
|
|
213
|
+
price: 0,
|
|
214
|
+
owner: 'loading...',
|
|
215
|
+
locked_amt: 0,
|
|
216
|
+
addr: contractaddr,
|
|
217
|
+
contract_name: this.stackswap.config.STACKSWAP_ADDRESS() + '.' + contractaddr
|
|
218
|
+
};
|
|
219
|
+
const json_result = await axios_1.default.get(temp.json_url);
|
|
220
|
+
temp.desc = json_result.data.description;
|
|
221
|
+
temp.name = json_result.data.name;
|
|
222
|
+
temp.img_url = 'https://gateway.ipfs/ipfs/' + json_result.data.image.substr(7, json_result.data.image.length);
|
|
223
|
+
return temp;
|
|
224
|
+
}
|
|
225
|
+
async getNFTDataFromID(id_) {
|
|
226
|
+
const temp = {
|
|
227
|
+
id: id_,
|
|
228
|
+
name: 'loading...',
|
|
229
|
+
img_url: `loading...`,
|
|
230
|
+
json_url: `https://gateway.ipfs.io/ipfs/Qmaa5RRUMa9HQRHWJw3HWG3i1NUmb5VgJXT9Zqqg5VHQjX/${id_}.json`,
|
|
231
|
+
desc: 'loading...',
|
|
232
|
+
attr: {
|
|
233
|
+
reTouch: 0,
|
|
234
|
+
},
|
|
235
|
+
price: 0,
|
|
236
|
+
owner: 'loading...',
|
|
237
|
+
locked_amt: 0,
|
|
238
|
+
contract_name: this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT()
|
|
239
|
+
};
|
|
240
|
+
const json_result = await axios_1.default.get(`https://gateway.ipfs.io/ipfs/Qmaa5RRUMa9HQRHWJw3HWG3i1NUmb5VgJXT9Zqqg5VHQjX/${id_}.json`);
|
|
241
|
+
temp.img_url = 'https://gateway.ipfs.io/ipfs/' + json_result.data.image.substr(7, json_result.data.image.length);
|
|
242
|
+
temp.desc = json_result.data.description;
|
|
243
|
+
temp.name = json_result.data.name;
|
|
244
|
+
temp.attr.reTouch = json_result.data.attributes[0].value;
|
|
245
|
+
temp.price = await this.getMarketListing(id_);
|
|
246
|
+
temp.locked_amt = await this.getReserveAmount(id_);
|
|
247
|
+
return temp;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.NftManager = NftManager;
|
|
251
251
|
//# sourceMappingURL=nft.manager.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { StackswapAPI } from "../../index";
|
|
2
|
-
export declare class OperatorManager {
|
|
3
|
-
stackswap: StackswapAPI;
|
|
4
|
-
constructor(stackswap: StackswapAPI);
|
|
5
|
-
collectSwapFees(token_x: any, token_y: any, token_liquidity: any, callback?: any): Promise<void>;
|
|
6
|
-
add_liquidity_dist(contract_name: string, token_x_amount: string, token_y_amount: string, callback?: any): Promise<void>;
|
|
7
|
-
invest_to_farm_dist(contract_name: string, callback?: any): Promise<void>;
|
|
8
|
-
STSWInvestTx(invest_amount: string, callback?: any): Promise<void>;
|
|
9
|
-
farmClaimDistributor(round: string, callback?: any): Promise<void>;
|
|
10
|
-
STSWAwdDistributor(amount: string, callback?: any): Promise<void>;
|
|
11
|
-
STSWStaking(amount: string, month?: string, callback?: any): Promise<void>;
|
|
12
|
-
distributorGetInvestor(): Promise<any>;
|
|
13
|
-
distributorGetReclaim(): Promise<any>;
|
|
14
|
-
distributorReclaimLP(amount: string, callback?: any): Promise<void>;
|
|
15
|
-
distributorClaimSTSW(amount: string, callback?: any): Promise<void>;
|
|
16
|
-
propose(start_block: string, title: string, url: string, changes: any, callback?: any): Promise<void>;
|
|
17
|
-
}
|
|
1
|
+
import { StackswapAPI } from "../../index";
|
|
2
|
+
export declare class OperatorManager {
|
|
3
|
+
stackswap: StackswapAPI;
|
|
4
|
+
constructor(stackswap: StackswapAPI);
|
|
5
|
+
collectSwapFees(token_x: any, token_y: any, token_liquidity: any, callback?: any): Promise<void>;
|
|
6
|
+
add_liquidity_dist(contract_name: string, token_x_amount: string, token_y_amount: string, callback?: any): Promise<void>;
|
|
7
|
+
invest_to_farm_dist(contract_name: string, callback?: any): Promise<void>;
|
|
8
|
+
STSWInvestTx(invest_amount: string, callback?: any): Promise<void>;
|
|
9
|
+
farmClaimDistributor(round: string, callback?: any): Promise<void>;
|
|
10
|
+
STSWAwdDistributor(amount: string, callback?: any): Promise<void>;
|
|
11
|
+
STSWStaking(amount: string, month?: string, callback?: any): Promise<void>;
|
|
12
|
+
distributorGetInvestor(): Promise<any>;
|
|
13
|
+
distributorGetReclaim(): Promise<any>;
|
|
14
|
+
distributorReclaimLP(amount: string, callback?: any): Promise<void>;
|
|
15
|
+
distributorClaimSTSW(amount: string, callback?: any): Promise<void>;
|
|
16
|
+
propose(start_block: string, title: string, url: string, changes: any, callback?: any): Promise<void>;
|
|
17
|
+
}
|