@firmachain/firma-js 0.2.54 → 0.2.56

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.
@@ -14,6 +14,12 @@ export interface Cw20MarketingInfo {
14
14
  logo: string;
15
15
  marketing: string;
16
16
  }
17
+ export interface Cw20TokenInfo {
18
+ name: string;
19
+ symbol: string;
20
+ decimals: number;
21
+ total_supply: string;
22
+ }
17
23
  export interface ExpiresAtHeight {
18
24
  at_height: number;
19
25
  }
@@ -92,12 +98,12 @@ export declare class FirmaCosmWasmCw20Service {
92
98
  getGasEstimationSendFrom(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, owner: string, amount: string, msg: any): Promise<number>;
93
99
  getBalance(contractAddress: string, address: string): Promise<string>;
94
100
  getTotalSupply(contractAddress: string): Promise<string>;
95
- getTokenInfo(contractAddress: string): Promise<string>;
101
+ getTokenInfo(contractAddress: string): Promise<Cw20TokenInfo>;
96
102
  getMinter(contractAddress: string): Promise<Cw20Minter>;
97
103
  getAllowance(contractAddress: string, owner: string, spender: string): Promise<Cw20Allowance>;
98
104
  getAllAllowances(contractAddress: string, owner: string, limit?: number, start_after?: string): Promise<Cw20SpenderAllowance[]>;
99
105
  getAllSpenderAllowances(contractAddress: string, spender: string, limit?: number, start_after?: string): Promise<Cw20SpenderAllowance>;
100
- getAllAccounts(contractAddress: string, limit?: number, start_after?: string): Promise<string>;
106
+ getAllAccounts(contractAddress: string, limit?: number, start_after?: string): Promise<string[]>;
101
107
  getMarketingInfo(contractAddress: string): Promise<Cw20MarketingInfo>;
102
108
  getDownloadLogo(contractAddress: string): Promise<string>;
103
109
  }
@@ -854,7 +854,7 @@ var FirmaCosmWasmCw20Service = /** @class */ (function () {
854
854
  case 1:
855
855
  result = _a.sent();
856
856
  data = JSON.parse(result);
857
- return [2 /*return*/, data];
857
+ return [2 /*return*/, data.accounts];
858
858
  case 2:
859
859
  error_10 = _a.sent();
860
860
  FirmaUtil_1.FirmaUtil.printLog(error_10);
@@ -69,9 +69,9 @@ export declare class FirmaCosmWasmCwBridgeService {
69
69
  getOwner(contractAddress: string): Promise<string>;
70
70
  getAuthorizedUsers(contractAddress: string): Promise<string[]>;
71
71
  getNftInfo(contractAddress: string, tokenId: string): Promise<NftInfo>;
72
- getOwnerNfts(contractAddress: string, ownerAddress: string): Promise<string[]>;
73
- getOwnerNftsInfo(contractAddress: string, ownerAddress: string): Promise<NftInfo[]>;
74
- getOwnerWithdrawableNfts(contractAddress: string, ownerAddress: string): Promise<NftInfo[]>;
75
- getOwnerUnlockableNfts(contractAddress: string, ownerAddress: string): Promise<NftInfo[]>;
72
+ getOwnerNfts(contractAddress: string, ownerAddress: string, limit?: number, start_after?: string): Promise<string[]>;
73
+ getOwnerNftsInfo(contractAddress: string, ownerAddress: string, limit?: number, start_after?: string): Promise<NftInfo[]>;
74
+ getOwnerWithdrawableNfts(contractAddress: string, ownerAddress: string, limit?: number, start_after?: string): Promise<NftInfo[]>;
75
+ getOwnerUnlockableNfts(contractAddress: string, ownerAddress: string, limit?: number, start_after?: string): Promise<NftInfo[]>;
76
76
  getGlobalTxCounts(contractAddress: string): Promise<BridgeGlobalTxCounts>;
77
77
  }
@@ -502,13 +502,15 @@ var FirmaCosmWasmCwBridgeService = /** @class */ (function () {
502
502
  });
503
503
  });
504
504
  };
505
- FirmaCosmWasmCwBridgeService.prototype.getOwnerNfts = function (contractAddress, ownerAddress) {
505
+ FirmaCosmWasmCwBridgeService.prototype.getOwnerNfts = function (contractAddress, ownerAddress, limit, start_after) {
506
+ if (limit === void 0) { limit = 10; }
507
+ if (start_after === void 0) { start_after = ""; }
506
508
  return __awaiter(this, void 0, void 0, function () {
507
509
  var query, result;
508
510
  return __generator(this, function (_a) {
509
511
  switch (_a.label) {
510
512
  case 0:
511
- query = "{\"owner_nfts\": { \"owner_addr\": \"" + ownerAddress + "\" }}";
513
+ query = "{\"owner_nfts\": { \"owner_addr\": \"" + ownerAddress + "\", \"limit\": " + limit + ", \"start_after\": \"" + start_after + "\" }}";
512
514
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
513
515
  case 1:
514
516
  result = _a.sent();
@@ -517,13 +519,15 @@ var FirmaCosmWasmCwBridgeService = /** @class */ (function () {
517
519
  });
518
520
  });
519
521
  };
520
- FirmaCosmWasmCwBridgeService.prototype.getOwnerNftsInfo = function (contractAddress, ownerAddress) {
522
+ FirmaCosmWasmCwBridgeService.prototype.getOwnerNftsInfo = function (contractAddress, ownerAddress, limit, start_after) {
523
+ if (limit === void 0) { limit = 10; }
524
+ if (start_after === void 0) { start_after = ""; }
521
525
  return __awaiter(this, void 0, void 0, function () {
522
526
  var query, result;
523
527
  return __generator(this, function (_a) {
524
528
  switch (_a.label) {
525
529
  case 0:
526
- query = "{\"owner_nfts_info\": { \"owner_addr\": \"" + ownerAddress + "\" }}";
530
+ query = "{\"owner_nfts_info\": { \"owner_addr\": \"" + ownerAddress + "\", \"limit\": " + limit + ", \"start_after\": \"" + start_after + "\" }}";
527
531
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
528
532
  case 1:
529
533
  result = _a.sent();
@@ -532,13 +536,15 @@ var FirmaCosmWasmCwBridgeService = /** @class */ (function () {
532
536
  });
533
537
  });
534
538
  };
535
- FirmaCosmWasmCwBridgeService.prototype.getOwnerWithdrawableNfts = function (contractAddress, ownerAddress) {
539
+ FirmaCosmWasmCwBridgeService.prototype.getOwnerWithdrawableNfts = function (contractAddress, ownerAddress, limit, start_after) {
540
+ if (limit === void 0) { limit = 10; }
541
+ if (start_after === void 0) { start_after = ""; }
536
542
  return __awaiter(this, void 0, void 0, function () {
537
543
  var query, result;
538
544
  return __generator(this, function (_a) {
539
545
  switch (_a.label) {
540
546
  case 0:
541
- query = "{\"owner_withdrawable_nfts\": { \"owner_addr\": \"" + ownerAddress + "\" }}";
547
+ query = "{\"owner_withdrawable_nfts\": { \"owner_addr\": \"" + ownerAddress + "\", \"limit\": " + limit + ", \"start_after\": \"" + start_after + "\" }}";
542
548
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
543
549
  case 1:
544
550
  result = _a.sent();
@@ -547,13 +553,15 @@ var FirmaCosmWasmCwBridgeService = /** @class */ (function () {
547
553
  });
548
554
  });
549
555
  };
550
- FirmaCosmWasmCwBridgeService.prototype.getOwnerUnlockableNfts = function (contractAddress, ownerAddress) {
556
+ FirmaCosmWasmCwBridgeService.prototype.getOwnerUnlockableNfts = function (contractAddress, ownerAddress, limit, start_after) {
557
+ if (limit === void 0) { limit = 10; }
558
+ if (start_after === void 0) { start_after = ""; }
551
559
  return __awaiter(this, void 0, void 0, function () {
552
560
  var query, result;
553
561
  return __generator(this, function (_a) {
554
562
  switch (_a.label) {
555
563
  case 0:
556
- query = "{\"owner_unlockable_nfts\": { \"owner_addr\": \"" + ownerAddress + "\" }}";
564
+ query = "{\"owner_unlockable_nfts\": { \"owner_addr\": \"" + ownerAddress + "\", \"limit\": " + limit + ", \"start_after\": \"" + start_after + "\" }}";
557
565
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
558
566
  case 1:
559
567
  result = _a.sent();
@@ -0,0 +1,74 @@
1
+ import { FirmaConfig } from "./FirmaConfig";
2
+ import { FirmaCosmWasmService } from "./FirmaCosmWasmService";
3
+ import { FirmaWalletService } from "./FirmaWalletService";
4
+ import { TxMisc } from "./firmachain/common";
5
+ import { EncodeObject } from "@cosmjs/proto-signing";
6
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
7
+ import { FirmaCosmWasmCw721Service } from "./FirmaCosmWasmCw721";
8
+ import { FirmaCosmWasmCw20Service } from "./FirmaCosmWasmCw20";
9
+ export interface MarketplaceConfig {
10
+ owner: string;
11
+ cw721_address: string;
12
+ cw20_addresses: string[];
13
+ fee_address: string;
14
+ fee_rate: number;
15
+ firma_fee_address: string;
16
+ firma_fee_rate: number;
17
+ }
18
+ export interface MarketplaceRegisterData {
19
+ seller: string;
20
+ token_id: string;
21
+ sale_type: string;
22
+ amount: string;
23
+ cw20_address: string;
24
+ }
25
+ export declare class CwMarketplaceMsgData {
26
+ static getMsgDataChangeOwner(new_owner: string): string;
27
+ static getMsgDataRegisterSaleFCT(amount: string): {
28
+ action: string;
29
+ cw20_address: string;
30
+ amount: string;
31
+ };
32
+ static getMsgDataRegisterSaleCw20(cw20_address: string, amount: string): {
33
+ action: string;
34
+ cw20_address: string;
35
+ amount: string;
36
+ };
37
+ static getMsgDataPurchaseSaleFCT(token_id: string): string;
38
+ static getMsgDataPurchaseSaleCw20(token_id: string): {
39
+ action: string;
40
+ token_id: string;
41
+ };
42
+ static getMsgDataCancelSale(token_id: string): string;
43
+ }
44
+ export declare class FirmaCosmWasmCwMarketplaceService {
45
+ private readonly config;
46
+ private readonly cosmwasmService;
47
+ private readonly cw721Service;
48
+ private readonly cw20Service;
49
+ constructor(config: FirmaConfig, cosmwasmService: FirmaCosmWasmService, cw721Service: FirmaCosmWasmCw721Service, cw20Service: FirmaCosmWasmCw20Service);
50
+ getCwMarketplaceMsgData(): typeof CwMarketplaceMsgData;
51
+ changeOwner(wallet: FirmaWalletService, contractAddress: string, new_owner: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
52
+ getUnsignedTxChangeOwner(wallet: FirmaWalletService, contractAddress: string, new_owner: string): Promise<EncodeObject>;
53
+ registerSaleFCT(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, fctAmount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
54
+ getUnsignedTxRegisterSaleFCT(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, fctAmount: number): Promise<EncodeObject>;
55
+ registerSaleCw20(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, cw20Address: string, cw20Amount: number, cw20Decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
56
+ purchaseSaleFCT(wallet: FirmaWalletService, contractAddress: string, tokenId: string, fctAmount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
57
+ getUnsignedTxPurchaseSaleFCT(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, fctAmount: string): Promise<EncodeObject>;
58
+ purchaseSaleCw20(wallet: FirmaWalletService, contractAddress: string, tokenId: string, cw20Address: string, cw20Amount: number, cw20Decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
59
+ getUnsignedTxPurchaseSaleCw20(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, cw20Address: string, cw20Amount: number, cw20Decimal: number): Promise<EncodeObject>;
60
+ cancelSale(wallet: FirmaWalletService, contractAddress: string, tokenId: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
61
+ getUnsignedTxCancelSale(wallet: FirmaWalletService, contractAddress: string, tokenId: string): Promise<EncodeObject>;
62
+ signAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<BroadcastTxResponse>;
63
+ getGasEstimationSignAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<number>;
64
+ getGasEstimationChangeOwner(wallet: FirmaWalletService, contractAddress: string, new_owner: string): Promise<number>;
65
+ getGasEstimationRegisterSaleFCT(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, fctAmount: number): Promise<number>;
66
+ getGasEstimationRegisterSaleCw20(wallet: FirmaWalletService, contractAddress: string, cw721ContractAddress: string, tokenId: string, cw20Address: string, cw20Amount: number, cw20Decimal: number): Promise<number>;
67
+ getGasEstimationPurchaseSaleFCT(wallet: FirmaWalletService, contractAddress: string, tokenId: string, fctAmount: number): Promise<number>;
68
+ getGasEstimationPurchaseSaleCw20(wallet: FirmaWalletService, contractAddress: string, tokenId: string, cw20Address: string, cw20Amount: number, cw20Decimal: number): Promise<number>;
69
+ getGasEstimationCancelSale(wallet: FirmaWalletService, contractAddress: string, tokenId: string): Promise<number>;
70
+ getConfig(contractAddress: string): Promise<CwMarketplaceMsgData>;
71
+ getOwner(contractAddress: string): Promise<string>;
72
+ getRegisterList(contractAddress: string, limit?: number, start_after?: string): Promise<MarketplaceRegisterData[]>;
73
+ getRegisterListByAddress(contractAddress: string, address: string, limit?: number, start_after?: string): Promise<MarketplaceRegisterData[]>;
74
+ }
@@ -0,0 +1,457 @@
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 (_) 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.FirmaCosmWasmCwMarketplaceService = exports.CwMarketplaceMsgData = void 0;
40
+ var FirmaUtil_1 = require("./FirmaUtil");
41
+ var CosmWasmTxClient_1 = require("./firmachain/cosmwasm/CosmWasmTxClient");
42
+ // staic util
43
+ var noFunds = [];
44
+ var CwMarketplaceMsgData = /** @class */ (function () {
45
+ function CwMarketplaceMsgData() {
46
+ }
47
+ CwMarketplaceMsgData.getMsgDataChangeOwner = function (new_owner) {
48
+ return JSON.stringify({
49
+ "change_owner": {
50
+ new_owner: new_owner,
51
+ }
52
+ });
53
+ };
54
+ CwMarketplaceMsgData.getMsgDataRegisterSaleFCT = function (amount) {
55
+ return {
56
+ action: "registerSaleFct",
57
+ cw20_address: "",
58
+ amount: amount
59
+ };
60
+ };
61
+ CwMarketplaceMsgData.getMsgDataRegisterSaleCw20 = function (cw20_address, amount) {
62
+ return {
63
+ action: "registerSaleCw20",
64
+ cw20_address: cw20_address,
65
+ amount: amount
66
+ };
67
+ };
68
+ CwMarketplaceMsgData.getMsgDataPurchaseSaleFCT = function (token_id) {
69
+ return JSON.stringify({
70
+ "purchase_sale_fct": {
71
+ token_id: token_id,
72
+ }
73
+ });
74
+ };
75
+ CwMarketplaceMsgData.getMsgDataPurchaseSaleCw20 = function (token_id) {
76
+ return {
77
+ action: "purchaseSaleCW20",
78
+ token_id: token_id,
79
+ };
80
+ };
81
+ CwMarketplaceMsgData.getMsgDataCancelSale = function (token_id) {
82
+ return JSON.stringify({
83
+ "cancel_sale": {
84
+ token_id: token_id,
85
+ }
86
+ });
87
+ };
88
+ return CwMarketplaceMsgData;
89
+ }());
90
+ exports.CwMarketplaceMsgData = CwMarketplaceMsgData;
91
+ var FirmaCosmWasmCwMarketplaceService = /** @class */ (function () {
92
+ function FirmaCosmWasmCwMarketplaceService(config, cosmwasmService, cw721Service, cw20Service) {
93
+ this.config = config;
94
+ this.cosmwasmService = cosmwasmService;
95
+ this.cw721Service = cw721Service;
96
+ this.cw20Service = cw20Service;
97
+ }
98
+ FirmaCosmWasmCwMarketplaceService.prototype.getCwMarketplaceMsgData = function () {
99
+ return CwMarketplaceMsgData;
100
+ };
101
+ FirmaCosmWasmCwMarketplaceService.prototype.changeOwner = function (wallet, contractAddress, new_owner, txMisc) {
102
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var msgData;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0:
108
+ msgData = CwMarketplaceMsgData.getMsgDataChangeOwner(new_owner);
109
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
110
+ case 1: return [2 /*return*/, _a.sent()];
111
+ }
112
+ });
113
+ });
114
+ };
115
+ FirmaCosmWasmCwMarketplaceService.prototype.getUnsignedTxChangeOwner = function (wallet, contractAddress, new_owner) {
116
+ return __awaiter(this, void 0, void 0, function () {
117
+ var msgData;
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0:
121
+ msgData = JSON.stringify({
122
+ "change_owner": {
123
+ new_owner: new_owner,
124
+ }
125
+ });
126
+ return [4 /*yield*/, this.cosmwasmService.getUnsignedTxExecuteContract(wallet, contractAddress, msgData, noFunds)];
127
+ case 1: return [2 /*return*/, _a.sent()];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ FirmaCosmWasmCwMarketplaceService.prototype.registerSaleFCT = function (wallet, contractAddress, cw721ContractAddress, tokenId, fctAmount, txMisc) {
133
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
134
+ return __awaiter(this, void 0, void 0, function () {
135
+ var amount, msgData;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0:
139
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(fctAmount);
140
+ msgData = CwMarketplaceMsgData.getMsgDataRegisterSaleFCT(amount);
141
+ return [4 /*yield*/, this.cw721Service.sendNft(wallet, cw721ContractAddress, contractAddress, tokenId, msgData, txMisc)];
142
+ case 1: return [2 /*return*/, _a.sent()];
143
+ }
144
+ });
145
+ });
146
+ };
147
+ FirmaCosmWasmCwMarketplaceService.prototype.getUnsignedTxRegisterSaleFCT = function (wallet, contractAddress, cw721ContractAddress, tokenId, fctAmount) {
148
+ return __awaiter(this, void 0, void 0, function () {
149
+ var amount, msgData;
150
+ return __generator(this, function (_a) {
151
+ switch (_a.label) {
152
+ case 0:
153
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(fctAmount);
154
+ msgData = CwMarketplaceMsgData.getMsgDataRegisterSaleFCT(amount);
155
+ return [4 /*yield*/, this.cw721Service.getUnsignedTxSendNft(wallet, cw721ContractAddress, contractAddress, tokenId, msgData)];
156
+ case 1: return [2 /*return*/, _a.sent()];
157
+ }
158
+ });
159
+ });
160
+ };
161
+ FirmaCosmWasmCwMarketplaceService.prototype.registerSaleCw20 = function (wallet, contractAddress, cw721ContractAddress, tokenId, cw20Address, cw20Amount, cw20Decimal, txMisc) {
162
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
163
+ return __awaiter(this, void 0, void 0, function () {
164
+ var amount, msgData;
165
+ return __generator(this, function (_a) {
166
+ switch (_a.label) {
167
+ case 0:
168
+ amount = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(cw20Amount, cw20Decimal);
169
+ msgData = CwMarketplaceMsgData.getMsgDataRegisterSaleCw20(cw20Address, amount);
170
+ return [4 /*yield*/, this.cw721Service.sendNft(wallet, cw721ContractAddress, contractAddress, tokenId, msgData, txMisc)];
171
+ case 1: return [2 /*return*/, _a.sent()];
172
+ }
173
+ });
174
+ });
175
+ };
176
+ FirmaCosmWasmCwMarketplaceService.prototype.purchaseSaleFCT = function (wallet, contractAddress, tokenId, fctAmount, txMisc) {
177
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
178
+ return __awaiter(this, void 0, void 0, function () {
179
+ var amount, msgData, funds;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0:
183
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(fctAmount);
184
+ msgData = CwMarketplaceMsgData.getMsgDataPurchaseSaleFCT(tokenId);
185
+ funds = [{ denom: this.config.denom, amount: amount }];
186
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, funds, txMisc)];
187
+ case 1: return [2 /*return*/, _a.sent()];
188
+ }
189
+ });
190
+ });
191
+ };
192
+ FirmaCosmWasmCwMarketplaceService.prototype.getUnsignedTxPurchaseSaleFCT = function (wallet, contractAddress, cw721ContractAddress, tokenId, fctAmount) {
193
+ return __awaiter(this, void 0, void 0, function () {
194
+ var amount, msgData, funds;
195
+ return __generator(this, function (_a) {
196
+ switch (_a.label) {
197
+ case 0:
198
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(fctAmount);
199
+ msgData = CwMarketplaceMsgData.getMsgDataPurchaseSaleFCT(amount);
200
+ funds = [{ denom: this.config.denom, amount: amount }];
201
+ return [4 /*yield*/, this.cosmwasmService.getUnsignedTxExecuteContract(wallet, contractAddress, msgData, funds)];
202
+ case 1: return [2 /*return*/, _a.sent()];
203
+ }
204
+ });
205
+ });
206
+ };
207
+ FirmaCosmWasmCwMarketplaceService.prototype.purchaseSaleCw20 = function (wallet, contractAddress, tokenId, cw20Address, cw20Amount, cw20Decimal, txMisc) {
208
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
209
+ return __awaiter(this, void 0, void 0, function () {
210
+ var amount, msgData;
211
+ return __generator(this, function (_a) {
212
+ switch (_a.label) {
213
+ case 0:
214
+ amount = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(cw20Amount, cw20Decimal);
215
+ msgData = CwMarketplaceMsgData.getMsgDataPurchaseSaleCw20(tokenId);
216
+ return [4 /*yield*/, this.cw20Service.send(wallet, cw20Address, contractAddress, amount, msgData, txMisc)];
217
+ case 1: return [2 /*return*/, _a.sent()];
218
+ }
219
+ });
220
+ });
221
+ };
222
+ FirmaCosmWasmCwMarketplaceService.prototype.getUnsignedTxPurchaseSaleCw20 = function (wallet, contractAddress, cw721ContractAddress, tokenId, cw20Address, cw20Amount, cw20Decimal) {
223
+ return __awaiter(this, void 0, void 0, function () {
224
+ var amount, msgData;
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
227
+ case 0:
228
+ amount = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(cw20Amount, cw20Decimal);
229
+ msgData = CwMarketplaceMsgData.getMsgDataPurchaseSaleCw20(amount);
230
+ return [4 /*yield*/, this.cw20Service.getUnsignedTxSend(wallet, cw20Address, contractAddress, amount, msgData)];
231
+ case 1: return [2 /*return*/, _a.sent()];
232
+ }
233
+ });
234
+ });
235
+ };
236
+ FirmaCosmWasmCwMarketplaceService.prototype.cancelSale = function (wallet, contractAddress, tokenId, txMisc) {
237
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ var msgData;
240
+ return __generator(this, function (_a) {
241
+ switch (_a.label) {
242
+ case 0:
243
+ msgData = CwMarketplaceMsgData.getMsgDataCancelSale(tokenId);
244
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
245
+ case 1: return [2 /*return*/, _a.sent()];
246
+ }
247
+ });
248
+ });
249
+ };
250
+ FirmaCosmWasmCwMarketplaceService.prototype.getUnsignedTxCancelSale = function (wallet, contractAddress, tokenId) {
251
+ return __awaiter(this, void 0, void 0, function () {
252
+ var msgData;
253
+ return __generator(this, function (_a) {
254
+ switch (_a.label) {
255
+ case 0:
256
+ msgData = CwMarketplaceMsgData.getMsgDataCancelSale(tokenId);
257
+ return [4 /*yield*/, this.cosmwasmService.getUnsignedTxExecuteContract(wallet, contractAddress, msgData, noFunds)];
258
+ case 1: return [2 /*return*/, _a.sent()];
259
+ }
260
+ });
261
+ });
262
+ };
263
+ FirmaCosmWasmCwMarketplaceService.prototype.signAndBroadcast = function (wallet, msgList, txMisc) {
264
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
265
+ return __awaiter(this, void 0, void 0, function () {
266
+ var txClient, error_1;
267
+ return __generator(this, function (_a) {
268
+ switch (_a.label) {
269
+ case 0:
270
+ _a.trys.push([0, 2, , 3]);
271
+ txClient = new CosmWasmTxClient_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
272
+ return [4 /*yield*/, txClient.signAndBroadcast(msgList, FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
273
+ case 1: return [2 /*return*/, _a.sent()];
274
+ case 2:
275
+ error_1 = _a.sent();
276
+ FirmaUtil_1.FirmaUtil.printLog(error_1);
277
+ throw error_1;
278
+ case 3: return [2 /*return*/];
279
+ }
280
+ });
281
+ });
282
+ };
283
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationSignAndBroadcast = function (wallet, msgList, txMisc) {
284
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
285
+ return __awaiter(this, void 0, void 0, function () {
286
+ var txClient, txRaw, error_2;
287
+ return __generator(this, function (_a) {
288
+ switch (_a.label) {
289
+ case 0:
290
+ _a.trys.push([0, 3, , 4]);
291
+ txClient = new CosmWasmTxClient_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
292
+ return [4 /*yield*/, txClient.sign(msgList, FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
293
+ case 1:
294
+ txRaw = _a.sent();
295
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
296
+ case 2: return [2 /*return*/, _a.sent()];
297
+ case 3:
298
+ error_2 = _a.sent();
299
+ FirmaUtil_1.FirmaUtil.printLog(error_2);
300
+ throw error_2;
301
+ case 4: return [2 /*return*/];
302
+ }
303
+ });
304
+ });
305
+ };
306
+ // gas
307
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationChangeOwner = function (wallet, contractAddress, new_owner) {
308
+ return __awaiter(this, void 0, void 0, function () {
309
+ var msgData;
310
+ return __generator(this, function (_a) {
311
+ switch (_a.label) {
312
+ case 0:
313
+ msgData = CwMarketplaceMsgData.getMsgDataChangeOwner(new_owner);
314
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
315
+ case 1: return [2 /*return*/, _a.sent()];
316
+ }
317
+ });
318
+ });
319
+ };
320
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationRegisterSaleFCT = function (wallet, contractAddress, cw721ContractAddress, tokenId, fctAmount) {
321
+ return __awaiter(this, void 0, void 0, function () {
322
+ var amount, msgData;
323
+ return __generator(this, function (_a) {
324
+ switch (_a.label) {
325
+ case 0:
326
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(fctAmount);
327
+ msgData = CwMarketplaceMsgData.getMsgDataRegisterSaleFCT(amount);
328
+ return [4 /*yield*/, this.cw721Service.getGasEstimationSendNft(wallet, cw721ContractAddress, contractAddress, tokenId, msgData)];
329
+ case 1: return [2 /*return*/, _a.sent()];
330
+ }
331
+ });
332
+ });
333
+ };
334
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationRegisterSaleCw20 = function (wallet, contractAddress, cw721ContractAddress, tokenId, cw20Address, cw20Amount, cw20Decimal) {
335
+ return __awaiter(this, void 0, void 0, function () {
336
+ var amount, msgData;
337
+ return __generator(this, function (_a) {
338
+ switch (_a.label) {
339
+ case 0:
340
+ amount = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(cw20Amount, cw20Decimal);
341
+ msgData = CwMarketplaceMsgData.getMsgDataRegisterSaleCw20(cw20Address, amount);
342
+ return [4 /*yield*/, this.cw721Service.getGasEstimationSendNft(wallet, cw721ContractAddress, contractAddress, tokenId, msgData)];
343
+ case 1: return [2 /*return*/, _a.sent()];
344
+ }
345
+ });
346
+ });
347
+ };
348
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationPurchaseSaleFCT = function (wallet, contractAddress, tokenId, fctAmount) {
349
+ return __awaiter(this, void 0, void 0, function () {
350
+ var amount, msgData, funds;
351
+ return __generator(this, function (_a) {
352
+ switch (_a.label) {
353
+ case 0:
354
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(fctAmount);
355
+ msgData = CwMarketplaceMsgData.getMsgDataPurchaseSaleFCT(tokenId);
356
+ funds = [{ denom: this.config.denom, amount: amount }];
357
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, funds)];
358
+ case 1: return [2 /*return*/, _a.sent()];
359
+ }
360
+ });
361
+ });
362
+ };
363
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationPurchaseSaleCw20 = function (wallet, contractAddress, tokenId, cw20Address, cw20Amount, cw20Decimal) {
364
+ return __awaiter(this, void 0, void 0, function () {
365
+ var amount, msgData;
366
+ return __generator(this, function (_a) {
367
+ switch (_a.label) {
368
+ case 0:
369
+ amount = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(cw20Amount, cw20Decimal);
370
+ msgData = CwMarketplaceMsgData.getMsgDataPurchaseSaleCw20(tokenId);
371
+ return [4 /*yield*/, this.cw20Service.getGasEstimationSend(wallet, cw20Address, contractAddress, amount, msgData)];
372
+ case 1: return [2 /*return*/, _a.sent()];
373
+ }
374
+ });
375
+ });
376
+ };
377
+ FirmaCosmWasmCwMarketplaceService.prototype.getGasEstimationCancelSale = function (wallet, contractAddress, tokenId) {
378
+ return __awaiter(this, void 0, void 0, function () {
379
+ var msgData;
380
+ return __generator(this, function (_a) {
381
+ switch (_a.label) {
382
+ case 0:
383
+ msgData = CwMarketplaceMsgData.getMsgDataCancelSale(tokenId);
384
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
385
+ case 1: return [2 /*return*/, _a.sent()];
386
+ }
387
+ });
388
+ });
389
+ };
390
+ // query
391
+ FirmaCosmWasmCwMarketplaceService.prototype.getConfig = function (contractAddress) {
392
+ return __awaiter(this, void 0, void 0, function () {
393
+ var query, result;
394
+ return __generator(this, function (_a) {
395
+ switch (_a.label) {
396
+ case 0:
397
+ query = "{\"get_config\": {}}";
398
+ return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
399
+ case 1:
400
+ result = _a.sent();
401
+ return [2 /*return*/, JSON.parse(result)];
402
+ }
403
+ });
404
+ });
405
+ };
406
+ FirmaCosmWasmCwMarketplaceService.prototype.getOwner = function (contractAddress) {
407
+ return __awaiter(this, void 0, void 0, function () {
408
+ var query, result;
409
+ return __generator(this, function (_a) {
410
+ switch (_a.label) {
411
+ case 0:
412
+ query = "{\"get_owner\": {}}";
413
+ return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
414
+ case 1:
415
+ result = _a.sent();
416
+ return [2 /*return*/, JSON.parse(result)];
417
+ }
418
+ });
419
+ });
420
+ };
421
+ FirmaCosmWasmCwMarketplaceService.prototype.getRegisterList = function (contractAddress, limit, start_after) {
422
+ if (limit === void 0) { limit = 10; }
423
+ if (start_after === void 0) { start_after = ""; }
424
+ return __awaiter(this, void 0, void 0, function () {
425
+ var query, result;
426
+ return __generator(this, function (_a) {
427
+ switch (_a.label) {
428
+ case 0:
429
+ query = "{\"get_register_list\": { \"limit\": " + limit + ", \"start_after\": \"" + start_after + "\" }}";
430
+ return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
431
+ case 1:
432
+ result = _a.sent();
433
+ return [2 /*return*/, JSON.parse(result)];
434
+ }
435
+ });
436
+ });
437
+ };
438
+ FirmaCosmWasmCwMarketplaceService.prototype.getRegisterListByAddress = function (contractAddress, address, limit, start_after) {
439
+ if (limit === void 0) { limit = 10; }
440
+ if (start_after === void 0) { start_after = ""; }
441
+ return __awaiter(this, void 0, void 0, function () {
442
+ var query, result;
443
+ return __generator(this, function (_a) {
444
+ switch (_a.label) {
445
+ case 0:
446
+ query = "{\"get_register_list_by_address\": { \"address\": \"" + address + "\", \"limit\": " + limit + ", \"start_after\": \"" + start_after + "\" }}";
447
+ return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
448
+ case 1:
449
+ result = _a.sent();
450
+ return [2 /*return*/, JSON.parse(result)];
451
+ }
452
+ });
453
+ });
454
+ };
455
+ return FirmaCosmWasmCwMarketplaceService;
456
+ }());
457
+ exports.FirmaCosmWasmCwMarketplaceService = FirmaCosmWasmCwMarketplaceService;
@@ -18,6 +18,7 @@ import { FirmaIbcService } from "./FirmaIbcService";
18
18
  import { FirmaMintService } from "./FirmaMintService";
19
19
  import { FirmaCosmWasmCw721Service } from "./FirmaCosmWasmCw721";
20
20
  import { FirmaCosmWasmCwBridgeService } from "./FirmaCosmWasmCwBridge";
21
+ import { FirmaCosmWasmCwMarketplaceService } from "./FirmaCosmWasmCwMarketplace";
21
22
  export declare class FirmaSDK {
22
23
  Config: FirmaConfig;
23
24
  Wallet: FirmaWalletService;
@@ -39,5 +40,6 @@ export declare class FirmaSDK {
39
40
  Cw20: FirmaCosmWasmCw20Service;
40
41
  Cw721: FirmaCosmWasmCw721Service;
41
42
  CwBridge: FirmaCosmWasmCwBridgeService;
42
- constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Token?: TokenService, Contract?: ContractService, Ipfs?: IpfsService, BlockChain?: ChainService, Slashing?: SlashingService, Authz?: FirmaAuthzService, CosmWasm?: FirmaCosmWasmService, Ibc?: FirmaIbcService, Mint?: FirmaMintService, Cw20?: FirmaCosmWasmCw20Service, Cw721?: FirmaCosmWasmCw721Service, CwBridge?: FirmaCosmWasmCwBridgeService);
43
+ CwMarketplace: FirmaCosmWasmCwMarketplaceService;
44
+ constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Token?: TokenService, Contract?: ContractService, Ipfs?: IpfsService, BlockChain?: ChainService, Slashing?: SlashingService, Authz?: FirmaAuthzService, CosmWasm?: FirmaCosmWasmService, Ibc?: FirmaIbcService, Mint?: FirmaMintService, Cw20?: FirmaCosmWasmCw20Service, Cw721?: FirmaCosmWasmCw721Service, CwBridge?: FirmaCosmWasmCwBridgeService, CwMarketplace?: FirmaCosmWasmCwMarketplaceService);
43
45
  }
@@ -21,8 +21,9 @@ var FirmaIbcService_1 = require("./FirmaIbcService");
21
21
  var FirmaMintService_1 = require("./FirmaMintService");
22
22
  var FirmaCosmWasmCw721_1 = require("./FirmaCosmWasmCw721");
23
23
  var FirmaCosmWasmCwBridge_1 = require("./FirmaCosmWasmCwBridge");
24
+ var FirmaCosmWasmCwMarketplace_1 = require("./FirmaCosmWasmCwMarketplace");
24
25
  var FirmaSDK = /** @class */ (function () {
25
- function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing, Authz, CosmWasm, Ibc, Mint, Cw20, Cw721, CwBridge) {
26
+ function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing, Authz, CosmWasm, Ibc, Mint, Cw20, Cw721, CwBridge, CwMarketplace) {
26
27
  if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
27
28
  if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
28
29
  if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
@@ -42,6 +43,7 @@ var FirmaSDK = /** @class */ (function () {
42
43
  if (Cw20 === void 0) { Cw20 = new FirmaCosmWasmCw20_1.FirmaCosmWasmCw20Service(Config, CosmWasm); }
43
44
  if (Cw721 === void 0) { Cw721 = new FirmaCosmWasmCw721_1.FirmaCosmWasmCw721Service(Config, CosmWasm); }
44
45
  if (CwBridge === void 0) { CwBridge = new FirmaCosmWasmCwBridge_1.FirmaCosmWasmCwBridgeService(Config, CosmWasm, Cw721); }
46
+ if (CwMarketplace === void 0) { CwMarketplace = new FirmaCosmWasmCwMarketplace_1.FirmaCosmWasmCwMarketplaceService(Config, CosmWasm, Cw721, Cw20); }
45
47
  this.Config = Config;
46
48
  this.Wallet = Wallet;
47
49
  this.Bank = Bank;
@@ -62,6 +64,7 @@ var FirmaSDK = /** @class */ (function () {
62
64
  this.Cw20 = Cw20;
63
65
  this.Cw721 = Cw721;
64
66
  this.CwBridge = CwBridge;
67
+ this.CwMarketplace = CwMarketplace;
65
68
  FirmaUtil_1.FirmaUtil.config = Config;
66
69
  }
67
70
  return FirmaSDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.2.54",
3
+ "version": "0.2.56",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",