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