@firmachain/firma-js 0.2.50 → 0.2.52

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.
@@ -1,4 +1,5 @@
1
1
  import { BankTxClient, TxMisc, Token } from "./firmachain/bank";
2
+ import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
2
3
  import { FirmaWalletService } from "./FirmaWalletService";
3
4
  import { FirmaConfig } from "./FirmaConfig";
4
5
  import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
@@ -16,5 +17,5 @@ export declare class FirmaBankService {
16
17
  getTokenBalanceList(address: string): Promise<Token[]>;
17
18
  getTokenBalance(address: string, tokenID: string): Promise<string>;
18
19
  getBalance(address: string): Promise<string>;
19
- private getSignedTxSend;
20
+ getSignedTxSend(wallet: FirmaWalletService, targetAddress: string, denom: string, amount: string, txMisc?: TxMisc): Promise<TxRaw>;
20
21
  }
@@ -1,17 +1,72 @@
1
1
  import { FirmaConfig } from "./FirmaConfig";
2
2
  import { FirmaCosmWasmService } from "./FirmaCosmWasmService";
3
+ import { FirmaWalletService } from "./FirmaWalletService";
4
+ import { TxMisc } from "./firmachain/common";
5
+ export interface Cw20Minter {
6
+ minter: string;
7
+ cap: string;
8
+ }
9
+ export interface Cw20MarketingInfo {
10
+ project: string;
11
+ description: string;
12
+ logo: string;
13
+ marketing: string;
14
+ }
15
+ export interface ExpiresAtHeight {
16
+ at_height: number;
17
+ }
18
+ export interface ExpiresAtTime {
19
+ at_time: number;
20
+ }
21
+ export interface ExpiresNever {
22
+ never: {};
23
+ }
24
+ export declare type Expires = ExpiresAtHeight | ExpiresAtTime | ExpiresNever;
25
+ export interface Cw20Allowance {
26
+ allowance: string;
27
+ expires: Expires;
28
+ }
29
+ export interface Cw20SpenderAllowance {
30
+ allowance: string;
31
+ expires: Expires;
32
+ spender: string;
33
+ }
3
34
  export declare class FirmaCosmWasmCw20Service {
4
35
  private readonly config;
5
36
  private readonly cosmwasmService;
6
37
  constructor(config: FirmaConfig, cosmwasmService: FirmaCosmWasmService);
38
+ transfer(wallet: FirmaWalletService, contractAddress: string, recipient: string, amount: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
39
+ transferFrom(wallet: FirmaWalletService, contractAddress: string, owner: string, recipient: string, amount: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
40
+ mint(wallet: FirmaWalletService, contractAddress: string, recipient: string, amount: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
41
+ burn(wallet: FirmaWalletService, contractAddress: string, amount: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
42
+ burnFrom(wallet: FirmaWalletService, contractAddress: string, owner: string, amount: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
43
+ increaseAllowance(wallet: FirmaWalletService, contractAddress: string, spender: string, amount: string, expires: Expires, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
44
+ decreaseAllowance(wallet: FirmaWalletService, contractAddress: string, spender: string, amount: string, expires: Expires, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
45
+ updateMinter(wallet: FirmaWalletService, contractAddress: string, new_minter: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
46
+ updateMarketing(wallet: FirmaWalletService, contractAddress: string, description: string, marketing: string, project: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
47
+ uploadLogo(wallet: FirmaWalletService, contractAddress: string, url: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
48
+ send(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, amount: string, msg: any, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
49
+ sendFrom(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, owner: string, amount: string, msg: any, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
50
+ getGasEstimationTransfer(wallet: FirmaWalletService, contractAddress: string, recipient: string, amount: string): Promise<number>;
51
+ getGasEstimationTransferFrom(wallet: FirmaWalletService, contractAddress: string, owner: string, recipient: string, amount: string): Promise<number>;
52
+ getGasEstimationMint(wallet: FirmaWalletService, contractAddress: string, recipient: string, amount: string): Promise<number>;
53
+ getGasEstimationBurn(wallet: FirmaWalletService, contractAddress: string, amount: string): Promise<number>;
54
+ getGasEstimationBurnFrom(wallet: FirmaWalletService, contractAddress: string, owner: string, amount: string): Promise<number>;
55
+ getGasEstimationIncreaseAllowance(wallet: FirmaWalletService, contractAddress: string, spender: string, amount: string, expires: Expires): Promise<number>;
56
+ getGasEstimationDecreaseAllowance(wallet: FirmaWalletService, contractAddress: string, spender: string, amount: string, expires: Expires): Promise<number>;
57
+ getGasEstimationUpdateMinter(wallet: FirmaWalletService, contractAddress: string, new_minter: string): Promise<number>;
58
+ getGasEstimationUpdateMarketing(wallet: FirmaWalletService, contractAddress: string, description: string, marketing: string, project: string): Promise<number>;
59
+ getGasEstimationUploadLogo(wallet: FirmaWalletService, contractAddress: string, logo: string): Promise<number>;
60
+ getGasEstimationSend(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, amount: string, msg: any): Promise<number>;
61
+ getGasEstimationSendFrom(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, owner: string, amount: string, msg: any): Promise<number>;
7
62
  getBalance(contractAddress: string, address: string): Promise<string>;
8
63
  getTotalSupply(contractAddress: string): Promise<string>;
9
64
  getTokenInfo(contractAddress: string): Promise<string>;
10
- getMinter(contractAddress: string): Promise<string>;
11
- getAllowance(contractAddress: string, owner: string, spender: string): Promise<string>;
12
- getAllAllowances(contractAddress: string, owner: string): Promise<string>;
13
- getAllSpenderAllowances(contractAddress: string, spender: string): Promise<string>;
65
+ getMinter(contractAddress: string): Promise<Cw20Minter>;
66
+ getAllowance(contractAddress: string, owner: string, spender: string): Promise<Cw20Allowance>;
67
+ getAllAllowances(contractAddress: string, owner: string): Promise<Cw20SpenderAllowance[]>;
68
+ getAllSpenderAllowances(contractAddress: string, spender: string): Promise<Cw20SpenderAllowance>;
14
69
  getAllAccounts(contractAddress: string): Promise<string>;
15
- getMarketingInfo(contractAddress: string): Promise<string>;
70
+ getMarketingInfo(contractAddress: string): Promise<Cw20MarketingInfo>;
16
71
  getDownloadLogo(contractAddress: string): Promise<string>;
17
72
  }
@@ -38,11 +38,440 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.FirmaCosmWasmCw20Service = void 0;
40
40
  var FirmaUtil_1 = require("./FirmaUtil");
41
+ // staic util
42
+ var noFunds = [];
43
+ function getMsgDataTransfer(recipient, amount) {
44
+ return JSON.stringify({
45
+ "transfer": {
46
+ recipient: recipient,
47
+ amount: amount
48
+ }
49
+ });
50
+ }
51
+ function getMsgDataTransferFrom(owner, recipient, amount) {
52
+ return JSON.stringify({
53
+ "transfer_from": {
54
+ owner: owner,
55
+ recipient: recipient,
56
+ amount: amount
57
+ }
58
+ });
59
+ }
60
+ function getMsgDataMint(recipient, amount) {
61
+ return JSON.stringify({
62
+ "mint": {
63
+ recipient: recipient,
64
+ amount: amount
65
+ }
66
+ });
67
+ }
68
+ function getMsgDataBurn(amount) {
69
+ return JSON.stringify({
70
+ "burn": {
71
+ amount: amount
72
+ }
73
+ });
74
+ }
75
+ function getMsgDataBurnFrom(owner, amount) {
76
+ return JSON.stringify({
77
+ "burn_from": {
78
+ owner: owner,
79
+ amount: amount
80
+ }
81
+ });
82
+ }
83
+ function getMsgDataIncreaseAllowance(spender, amount, expires) {
84
+ return JSON.stringify({
85
+ "increase_allowance": {
86
+ spender: spender,
87
+ amount: amount,
88
+ expires: expires
89
+ }
90
+ });
91
+ }
92
+ function getMsgDataDecreaseAllowance(spender, amount, expires) {
93
+ return JSON.stringify({
94
+ "decrease_allowance": {
95
+ spender: spender,
96
+ amount: amount,
97
+ expires: expires
98
+ }
99
+ });
100
+ }
101
+ function getMsgDataUpdateMinter(new_minter) {
102
+ return JSON.stringify({
103
+ "update_minter": {
104
+ new_minter: new_minter,
105
+ }
106
+ });
107
+ }
108
+ function getMsgDataUpdateMarketing(description, marketing, project) {
109
+ return JSON.stringify({
110
+ "update_marketing": {
111
+ description: description,
112
+ marketing: marketing,
113
+ project: project
114
+ }
115
+ });
116
+ }
117
+ function getMsgDataUploadLogo(url) {
118
+ return JSON.stringify({
119
+ "upload_logo": {
120
+ url: url
121
+ }
122
+ });
123
+ }
124
+ function getMsgDataSend(contract, amount, msg) {
125
+ return JSON.stringify({
126
+ "send": {
127
+ contract: contract,
128
+ amount: amount,
129
+ msg: btoa(JSON.stringify(msg))
130
+ }
131
+ });
132
+ }
133
+ function getMsgDataSendFrom(contract, owner, amount, msg) {
134
+ return JSON.stringify({
135
+ "send_from": {
136
+ contract: contract,
137
+ owner: owner,
138
+ amount: amount,
139
+ msg: btoa(JSON.stringify(msg))
140
+ }
141
+ });
142
+ }
143
+ // class
41
144
  var FirmaCosmWasmCw20Service = /** @class */ (function () {
42
145
  function FirmaCosmWasmCw20Service(config, cosmwasmService) {
43
146
  this.config = config;
44
147
  this.cosmwasmService = cosmwasmService;
45
148
  }
149
+ // tx
150
+ FirmaCosmWasmCw20Service.prototype.transfer = function (wallet, contractAddress, recipient, amount, txMisc) {
151
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var msgData;
154
+ return __generator(this, function (_a) {
155
+ switch (_a.label) {
156
+ case 0:
157
+ msgData = getMsgDataTransfer(recipient, amount);
158
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
159
+ case 1: return [2 /*return*/, _a.sent()];
160
+ }
161
+ });
162
+ });
163
+ };
164
+ FirmaCosmWasmCw20Service.prototype.transferFrom = function (wallet, contractAddress, owner, recipient, amount, txMisc) {
165
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
166
+ return __awaiter(this, void 0, void 0, function () {
167
+ var msgData;
168
+ return __generator(this, function (_a) {
169
+ switch (_a.label) {
170
+ case 0:
171
+ msgData = getMsgDataTransferFrom(owner, recipient, amount);
172
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
173
+ case 1: return [2 /*return*/, _a.sent()];
174
+ }
175
+ });
176
+ });
177
+ };
178
+ FirmaCosmWasmCw20Service.prototype.mint = function (wallet, contractAddress, recipient, amount, txMisc) {
179
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
180
+ return __awaiter(this, void 0, void 0, function () {
181
+ var msgData;
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0:
185
+ msgData = getMsgDataMint(recipient, amount);
186
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
187
+ case 1: return [2 /*return*/, _a.sent()];
188
+ }
189
+ });
190
+ });
191
+ };
192
+ FirmaCosmWasmCw20Service.prototype.burn = function (wallet, contractAddress, amount, txMisc) {
193
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
194
+ return __awaiter(this, void 0, void 0, function () {
195
+ var msgData;
196
+ return __generator(this, function (_a) {
197
+ switch (_a.label) {
198
+ case 0:
199
+ msgData = getMsgDataBurn(amount);
200
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
201
+ case 1: return [2 /*return*/, _a.sent()];
202
+ }
203
+ });
204
+ });
205
+ };
206
+ FirmaCosmWasmCw20Service.prototype.burnFrom = function (wallet, contractAddress, owner, amount, txMisc) {
207
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
208
+ return __awaiter(this, void 0, void 0, function () {
209
+ var msgData;
210
+ return __generator(this, function (_a) {
211
+ switch (_a.label) {
212
+ case 0:
213
+ msgData = getMsgDataBurnFrom(owner, amount);
214
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
215
+ case 1: return [2 /*return*/, _a.sent()];
216
+ }
217
+ });
218
+ });
219
+ };
220
+ FirmaCosmWasmCw20Service.prototype.increaseAllowance = function (wallet, contractAddress, spender, amount, expires, txMisc) {
221
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
222
+ return __awaiter(this, void 0, void 0, function () {
223
+ var msgData;
224
+ return __generator(this, function (_a) {
225
+ switch (_a.label) {
226
+ case 0:
227
+ msgData = getMsgDataIncreaseAllowance(spender, amount, expires);
228
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
229
+ case 1: return [2 /*return*/, _a.sent()];
230
+ }
231
+ });
232
+ });
233
+ };
234
+ FirmaCosmWasmCw20Service.prototype.decreaseAllowance = function (wallet, contractAddress, spender, amount, expires, txMisc) {
235
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var msgData;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0:
241
+ msgData = getMsgDataDecreaseAllowance(spender, amount, expires);
242
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
243
+ case 1: return [2 /*return*/, _a.sent()];
244
+ }
245
+ });
246
+ });
247
+ };
248
+ FirmaCosmWasmCw20Service.prototype.updateMinter = function (wallet, contractAddress, new_minter, txMisc) {
249
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
250
+ return __awaiter(this, void 0, void 0, function () {
251
+ var msgData;
252
+ return __generator(this, function (_a) {
253
+ switch (_a.label) {
254
+ case 0:
255
+ msgData = getMsgDataUpdateMinter(new_minter);
256
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
257
+ case 1: return [2 /*return*/, _a.sent()];
258
+ }
259
+ });
260
+ });
261
+ };
262
+ FirmaCosmWasmCw20Service.prototype.updateMarketing = function (wallet, contractAddress, description, marketing, project, txMisc) {
263
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
264
+ return __awaiter(this, void 0, void 0, function () {
265
+ var msgData;
266
+ return __generator(this, function (_a) {
267
+ switch (_a.label) {
268
+ case 0:
269
+ msgData = getMsgDataUpdateMarketing(description, marketing, project);
270
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
271
+ case 1: return [2 /*return*/, _a.sent()];
272
+ }
273
+ });
274
+ });
275
+ };
276
+ FirmaCosmWasmCw20Service.prototype.uploadLogo = function (wallet, contractAddress, url, txMisc) {
277
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
278
+ return __awaiter(this, void 0, void 0, function () {
279
+ var msgData;
280
+ return __generator(this, function (_a) {
281
+ switch (_a.label) {
282
+ case 0:
283
+ msgData = getMsgDataUploadLogo(url);
284
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
285
+ case 1: return [2 /*return*/, _a.sent()];
286
+ }
287
+ });
288
+ });
289
+ };
290
+ FirmaCosmWasmCw20Service.prototype.send = function (wallet, contractAddress, targetContractAddress, amount, msg, txMisc) {
291
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
292
+ return __awaiter(this, void 0, void 0, function () {
293
+ var msgData;
294
+ return __generator(this, function (_a) {
295
+ switch (_a.label) {
296
+ case 0:
297
+ msgData = getMsgDataSend(targetContractAddress, amount, msg);
298
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
299
+ case 1: return [2 /*return*/, _a.sent()];
300
+ }
301
+ });
302
+ });
303
+ };
304
+ FirmaCosmWasmCw20Service.prototype.sendFrom = function (wallet, contractAddress, targetContractAddress, owner, amount, msg, txMisc) {
305
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ var msgData;
308
+ return __generator(this, function (_a) {
309
+ switch (_a.label) {
310
+ case 0:
311
+ msgData = getMsgDataSendFrom(targetContractAddress, owner, amount, msg);
312
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
313
+ case 1: return [2 /*return*/, _a.sent()];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ // gas
319
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationTransfer = function (wallet, contractAddress, recipient, amount) {
320
+ return __awaiter(this, void 0, void 0, function () {
321
+ var msgData;
322
+ return __generator(this, function (_a) {
323
+ switch (_a.label) {
324
+ case 0:
325
+ msgData = getMsgDataTransfer(recipient, amount);
326
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
327
+ case 1: return [2 /*return*/, _a.sent()];
328
+ }
329
+ });
330
+ });
331
+ };
332
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationTransferFrom = function (wallet, contractAddress, owner, recipient, amount) {
333
+ return __awaiter(this, void 0, void 0, function () {
334
+ var msgData;
335
+ return __generator(this, function (_a) {
336
+ switch (_a.label) {
337
+ case 0:
338
+ msgData = getMsgDataTransferFrom(owner, recipient, amount);
339
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
340
+ case 1: return [2 /*return*/, _a.sent()];
341
+ }
342
+ });
343
+ });
344
+ };
345
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationMint = function (wallet, contractAddress, recipient, amount) {
346
+ return __awaiter(this, void 0, void 0, function () {
347
+ var msgData;
348
+ return __generator(this, function (_a) {
349
+ switch (_a.label) {
350
+ case 0:
351
+ msgData = getMsgDataMint(recipient, amount);
352
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
353
+ case 1: return [2 /*return*/, _a.sent()];
354
+ }
355
+ });
356
+ });
357
+ };
358
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationBurn = function (wallet, contractAddress, amount) {
359
+ return __awaiter(this, void 0, void 0, function () {
360
+ var msgData;
361
+ return __generator(this, function (_a) {
362
+ switch (_a.label) {
363
+ case 0:
364
+ msgData = getMsgDataBurn(amount);
365
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
366
+ case 1: return [2 /*return*/, _a.sent()];
367
+ }
368
+ });
369
+ });
370
+ };
371
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationBurnFrom = function (wallet, contractAddress, owner, amount) {
372
+ return __awaiter(this, void 0, void 0, function () {
373
+ var msgData;
374
+ return __generator(this, function (_a) {
375
+ switch (_a.label) {
376
+ case 0:
377
+ msgData = getMsgDataBurnFrom(owner, amount);
378
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
379
+ case 1: return [2 /*return*/, _a.sent()];
380
+ }
381
+ });
382
+ });
383
+ };
384
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationIncreaseAllowance = function (wallet, contractAddress, spender, amount, expires) {
385
+ return __awaiter(this, void 0, void 0, function () {
386
+ var msgData;
387
+ return __generator(this, function (_a) {
388
+ switch (_a.label) {
389
+ case 0:
390
+ msgData = getMsgDataIncreaseAllowance(spender, amount, expires);
391
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
392
+ case 1: return [2 /*return*/, _a.sent()];
393
+ }
394
+ });
395
+ });
396
+ };
397
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationDecreaseAllowance = function (wallet, contractAddress, spender, amount, expires) {
398
+ return __awaiter(this, void 0, void 0, function () {
399
+ var msgData;
400
+ return __generator(this, function (_a) {
401
+ switch (_a.label) {
402
+ case 0:
403
+ msgData = getMsgDataDecreaseAllowance(spender, amount, expires);
404
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
405
+ case 1: return [2 /*return*/, _a.sent()];
406
+ }
407
+ });
408
+ });
409
+ };
410
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationUpdateMinter = function (wallet, contractAddress, new_minter) {
411
+ return __awaiter(this, void 0, void 0, function () {
412
+ var msgData;
413
+ return __generator(this, function (_a) {
414
+ switch (_a.label) {
415
+ case 0:
416
+ msgData = getMsgDataUpdateMinter(new_minter);
417
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
418
+ case 1: return [2 /*return*/, _a.sent()];
419
+ }
420
+ });
421
+ });
422
+ };
423
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationUpdateMarketing = function (wallet, contractAddress, description, marketing, project) {
424
+ return __awaiter(this, void 0, void 0, function () {
425
+ var msgData;
426
+ return __generator(this, function (_a) {
427
+ switch (_a.label) {
428
+ case 0:
429
+ msgData = getMsgDataUpdateMarketing(description, marketing, project);
430
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
431
+ case 1: return [2 /*return*/, _a.sent()];
432
+ }
433
+ });
434
+ });
435
+ };
436
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationUploadLogo = function (wallet, contractAddress, logo) {
437
+ return __awaiter(this, void 0, void 0, function () {
438
+ var msgData;
439
+ return __generator(this, function (_a) {
440
+ switch (_a.label) {
441
+ case 0:
442
+ msgData = getMsgDataUploadLogo(logo);
443
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
444
+ case 1: return [2 /*return*/, _a.sent()];
445
+ }
446
+ });
447
+ });
448
+ };
449
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationSend = function (wallet, contractAddress, targetContractAddress, amount, msg) {
450
+ return __awaiter(this, void 0, void 0, function () {
451
+ var msgData;
452
+ return __generator(this, function (_a) {
453
+ switch (_a.label) {
454
+ case 0:
455
+ msgData = getMsgDataSend(targetContractAddress, amount, msg);
456
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
457
+ case 1: return [2 /*return*/, _a.sent()];
458
+ }
459
+ });
460
+ });
461
+ };
462
+ FirmaCosmWasmCw20Service.prototype.getGasEstimationSendFrom = function (wallet, contractAddress, targetContractAddress, owner, amount, msg) {
463
+ return __awaiter(this, void 0, void 0, function () {
464
+ var msgData;
465
+ return __generator(this, function (_a) {
466
+ switch (_a.label) {
467
+ case 0:
468
+ msgData = getMsgDataSendFrom(targetContractAddress, owner, amount, msg);
469
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
470
+ case 1: return [2 /*return*/, _a.sent()];
471
+ }
472
+ });
473
+ });
474
+ };
46
475
  // query
47
476
  FirmaCosmWasmCw20Service.prototype.getBalance = function (contractAddress, address) {
48
477
  return __awaiter(this, void 0, void 0, function () {
@@ -166,7 +595,7 @@ var FirmaCosmWasmCw20Service = /** @class */ (function () {
166
595
  case 1:
167
596
  result = _a.sent();
168
597
  data = JSON.parse(result);
169
- return [2 /*return*/, data];
598
+ return [2 /*return*/, data.allowances];
170
599
  case 2:
171
600
  error_6 = _a.sent();
172
601
  FirmaUtil_1.FirmaUtil.printLog(error_6);
@@ -1,10 +1,21 @@
1
1
  import { FirmaConfig } from "./FirmaConfig";
2
2
  import { FirmaCosmWasmService } from "./FirmaCosmWasmService";
3
- import { Uint64 } from "@cosmjs/math";
4
- export interface ExpireAll {
5
- never: string;
6
- at_height: Uint64;
7
- at_time: string;
3
+ import { FirmaWalletService } from "./FirmaWalletService";
4
+ import { TxMisc } from "./firmachain/common";
5
+ export interface ExpiresAtHeight {
6
+ at_height: number;
7
+ }
8
+ export interface ExpiresAtTime {
9
+ at_time: number;
10
+ }
11
+ export interface ExpiresNever {
12
+ never: {};
13
+ }
14
+ export declare type Expires = ExpiresAtHeight | ExpiresAtTime | ExpiresNever;
15
+ interface OwnershipResponse {
16
+ owner: string | null;
17
+ pending_owner: string | null;
18
+ pending_expiry: Expires | null;
8
19
  }
9
20
  export interface Cw721NftInfo {
10
21
  access: {
@@ -22,16 +33,39 @@ export interface Cw721ContractInfo {
22
33
  }
23
34
  export interface Cw721Approval {
24
35
  spender: string;
25
- expires: ExpireAll;
36
+ expires: Expires;
26
37
  }
27
38
  export declare class FirmaCosmWasmCw721Service {
28
39
  private readonly config;
29
40
  private readonly cosmwasmService;
30
41
  constructor(config: FirmaConfig, cosmwasmService: FirmaCosmWasmService);
42
+ mint(wallet: FirmaWalletService, contractAddress: string, owner: string, token_id: string, token_uri?: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
43
+ burn(wallet: FirmaWalletService, contractAddress: string, token_id: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
44
+ transfer(wallet: FirmaWalletService, contractAddress: string, recipient: string, token_id: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
45
+ approve(wallet: FirmaWalletService, contractAddress: string, spender: string, token_id: string, expires: Expires, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
46
+ revoke(wallet: FirmaWalletService, contractAddress: string, spender: string, token_id: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
47
+ approveAll(wallet: FirmaWalletService, contractAddress: string, operator: string, expires: Expires, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
48
+ revokeAll(wallet: FirmaWalletService, contractAddress: string, operator: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
49
+ sendNft(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, token_id: string, msg: any, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
50
+ updateOwnerShipTransfer(wallet: FirmaWalletService, contractAddress: string, new_owner: string, expiry: Expires, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
51
+ updateOwnerShipAccept(wallet: FirmaWalletService, contractAddress: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
52
+ updateOwnerShipRenounce(wallet: FirmaWalletService, contractAddress: string, txMisc?: TxMisc): Promise<import("./firmachain/common/stargateclient").BroadcastTxResponse>;
53
+ getGasEstimationMint(wallet: FirmaWalletService, contractAddress: string, owner: string, token_id: string, token_uri?: string): Promise<number>;
54
+ getGasEstimationBurn(wallet: FirmaWalletService, contractAddress: string, token_id: string): Promise<number>;
55
+ getGasEstimationTransfer(wallet: FirmaWalletService, contractAddress: string, recipient: string, token_id: string): Promise<number>;
56
+ getGasEstimationApprove(wallet: FirmaWalletService, contractAddress: string, spender: string, token_id: string, expires: Expires): Promise<number>;
57
+ getGasEstimationRevoke(wallet: FirmaWalletService, contractAddress: string, spender: string, token_id: string): Promise<number>;
58
+ getGasEstimationApproveAll(wallet: FirmaWalletService, contractAddress: string, operator: string, expires: Expires): Promise<number>;
59
+ getGasEstimationRevokeAll(wallet: FirmaWalletService, contractAddress: string, operator: string): Promise<number>;
60
+ getGasEstimationSendNft(wallet: FirmaWalletService, contractAddress: string, targetContractAddress: string, token_id: string, msg: any): Promise<number>;
61
+ getGasEstimationUpdateOwnerShipTransfer(wallet: FirmaWalletService, contractAddress: string, new_owner: string, expiry: Expires): Promise<number>;
62
+ getGasEstimationUpdateOwnerShipAccept(wallet: FirmaWalletService, contractAddress: string): Promise<number>;
63
+ getGasEstimationUpdateOwnerShipRenounce(wallet: FirmaWalletService, contractAddress: string): Promise<number>;
31
64
  getOwnerFromNftID(contractAddress: string, tokenId: string): Promise<string>;
32
65
  getApproval(contractAddress: string, tokenId: string, spender: string, isIncludeExpired?: boolean): Promise<Cw721Approval>;
33
66
  getApprovals(contractAddress: string, tokenId: string, isIncludeExpired?: boolean): Promise<Cw721Approval[]>;
34
67
  getAllOperators(contractAddress: string, owner: string, isIncludeExpired?: boolean): Promise<Cw721Approval[]>;
68
+ getOperator(contractAddress: string, owner: string, operator: string, isIncludeExpired?: boolean): Promise<Cw721Approval>;
35
69
  getTotalNfts(contractAddress: string): Promise<number>;
36
70
  getContractInfo(contractAddress: string): Promise<Cw721ContractInfo>;
37
71
  getNftTokenUri(contractAddress: string, tokenId: string): Promise<string>;
@@ -40,4 +74,6 @@ export declare class FirmaCosmWasmCw721Service {
40
74
  getAllNftIdList(contractAddress: string): Promise<string[]>;
41
75
  getMinter(contractAddress: string): Promise<string>;
42
76
  getExtension(contractAddress: string): Promise<any>;
77
+ getOwnerShip(contractAddress: string): Promise<OwnershipResponse>;
43
78
  }
79
+ export {};
@@ -38,11 +38,400 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.FirmaCosmWasmCw721Service = void 0;
40
40
  var FirmaUtil_1 = require("./FirmaUtil");
41
+ // staic util
42
+ var noFunds = [];
43
+ function getMsgDataMint(owner, token_id, token_uri) {
44
+ return JSON.stringify({
45
+ "mint": {
46
+ token_id: token_id,
47
+ owner: owner,
48
+ extension: {},
49
+ token_uri: token_uri
50
+ }
51
+ });
52
+ }
53
+ function getMsgDataBurn(token_id) {
54
+ return JSON.stringify({
55
+ "burn": {
56
+ token_id: token_id
57
+ }
58
+ });
59
+ }
60
+ function getMsgDataTransfer(recipient, token_id) {
61
+ return JSON.stringify({
62
+ "transfer_nft": {
63
+ recipient: recipient,
64
+ token_id: token_id
65
+ }
66
+ });
67
+ }
68
+ function getMsgDataApprove(spender, token_id, expires) {
69
+ return JSON.stringify({
70
+ "approve": {
71
+ spender: spender,
72
+ token_id: token_id,
73
+ expires: expires
74
+ }
75
+ });
76
+ }
77
+ function getMsgDataRevoke(spender, token_id) {
78
+ return JSON.stringify({
79
+ "revoke": {
80
+ spender: spender,
81
+ token_id: token_id
82
+ }
83
+ });
84
+ }
85
+ function getMsgDataApproveAll(operator, expires) {
86
+ return JSON.stringify({
87
+ "approve_all": {
88
+ operator: operator,
89
+ expires: expires
90
+ }
91
+ });
92
+ }
93
+ function getMsgDataRevokeAll(operator) {
94
+ return JSON.stringify({
95
+ "revoke_all": {
96
+ operator: operator
97
+ }
98
+ });
99
+ }
100
+ function getMsgDataSendNft(contract, token_id, msg) {
101
+ return JSON.stringify({
102
+ "send_nft": {
103
+ contract: contract,
104
+ token_id: token_id,
105
+ msg: btoa(JSON.stringify(msg))
106
+ }
107
+ });
108
+ }
109
+ function getMsgUpdateOwnerShipTransfer(new_owner, expiry) {
110
+ return JSON.stringify({
111
+ "update_ownership": {
112
+ "transfer_ownership": {
113
+ new_owner: new_owner,
114
+ expiry: expiry
115
+ }
116
+ }
117
+ });
118
+ }
119
+ function getMsgUpdateOwnerShipAccept() {
120
+ return JSON.stringify({
121
+ "update_ownership": "accept_ownership"
122
+ });
123
+ }
124
+ function getMsgUpdateOwnerShipRenounce() {
125
+ return JSON.stringify({
126
+ "update_ownership": "renounce_ownership"
127
+ });
128
+ }
41
129
  var FirmaCosmWasmCw721Service = /** @class */ (function () {
42
130
  function FirmaCosmWasmCw721Service(config, cosmwasmService) {
43
131
  this.config = config;
44
132
  this.cosmwasmService = cosmwasmService;
45
133
  }
134
+ // tx
135
+ FirmaCosmWasmCw721Service.prototype.mint = function (wallet, contractAddress, owner, token_id, token_uri, txMisc) {
136
+ if (token_uri === void 0) { token_uri = ""; }
137
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
138
+ return __awaiter(this, void 0, void 0, function () {
139
+ var msgData;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ msgData = getMsgDataMint(owner, token_id, token_uri);
144
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
145
+ case 1: return [2 /*return*/, _a.sent()];
146
+ }
147
+ });
148
+ });
149
+ };
150
+ FirmaCosmWasmCw721Service.prototype.burn = function (wallet, contractAddress, token_id, txMisc) {
151
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var msgData;
154
+ return __generator(this, function (_a) {
155
+ switch (_a.label) {
156
+ case 0:
157
+ msgData = getMsgDataBurn(token_id);
158
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
159
+ case 1: return [2 /*return*/, _a.sent()];
160
+ }
161
+ });
162
+ });
163
+ };
164
+ FirmaCosmWasmCw721Service.prototype.transfer = function (wallet, contractAddress, recipient, token_id, txMisc) {
165
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
166
+ return __awaiter(this, void 0, void 0, function () {
167
+ var msgData;
168
+ return __generator(this, function (_a) {
169
+ switch (_a.label) {
170
+ case 0:
171
+ msgData = getMsgDataTransfer(recipient, token_id);
172
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
173
+ case 1: return [2 /*return*/, _a.sent()];
174
+ }
175
+ });
176
+ });
177
+ };
178
+ FirmaCosmWasmCw721Service.prototype.approve = function (wallet, contractAddress, spender, token_id, expires, txMisc) {
179
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
180
+ return __awaiter(this, void 0, void 0, function () {
181
+ var msgData;
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0:
185
+ msgData = getMsgDataApprove(spender, token_id, expires);
186
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
187
+ case 1: return [2 /*return*/, _a.sent()];
188
+ }
189
+ });
190
+ });
191
+ };
192
+ FirmaCosmWasmCw721Service.prototype.revoke = function (wallet, contractAddress, spender, token_id, txMisc) {
193
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
194
+ return __awaiter(this, void 0, void 0, function () {
195
+ var msgData;
196
+ return __generator(this, function (_a) {
197
+ switch (_a.label) {
198
+ case 0:
199
+ msgData = getMsgDataRevoke(spender, token_id);
200
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
201
+ case 1: return [2 /*return*/, _a.sent()];
202
+ }
203
+ });
204
+ });
205
+ };
206
+ FirmaCosmWasmCw721Service.prototype.approveAll = function (wallet, contractAddress, operator, expires, txMisc) {
207
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
208
+ return __awaiter(this, void 0, void 0, function () {
209
+ var msgData;
210
+ return __generator(this, function (_a) {
211
+ switch (_a.label) {
212
+ case 0:
213
+ msgData = getMsgDataApproveAll(operator, expires);
214
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
215
+ case 1: return [2 /*return*/, _a.sent()];
216
+ }
217
+ });
218
+ });
219
+ };
220
+ FirmaCosmWasmCw721Service.prototype.revokeAll = function (wallet, contractAddress, operator, txMisc) {
221
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
222
+ return __awaiter(this, void 0, void 0, function () {
223
+ var msgData;
224
+ return __generator(this, function (_a) {
225
+ switch (_a.label) {
226
+ case 0:
227
+ msgData = getMsgDataRevokeAll(operator);
228
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
229
+ case 1: return [2 /*return*/, _a.sent()];
230
+ }
231
+ });
232
+ });
233
+ };
234
+ FirmaCosmWasmCw721Service.prototype.sendNft = function (wallet, contractAddress, targetContractAddress, token_id, msg, txMisc) {
235
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var msgData;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0:
241
+ msgData = getMsgDataSendNft(targetContractAddress, token_id, msg);
242
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
243
+ case 1: return [2 /*return*/, _a.sent()];
244
+ }
245
+ });
246
+ });
247
+ };
248
+ FirmaCosmWasmCw721Service.prototype.updateOwnerShipTransfer = function (wallet, contractAddress, new_owner, expiry, txMisc) {
249
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
250
+ return __awaiter(this, void 0, void 0, function () {
251
+ var msgData;
252
+ return __generator(this, function (_a) {
253
+ switch (_a.label) {
254
+ case 0:
255
+ msgData = getMsgUpdateOwnerShipTransfer(new_owner, expiry);
256
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
257
+ case 1: return [2 /*return*/, _a.sent()];
258
+ }
259
+ });
260
+ });
261
+ };
262
+ FirmaCosmWasmCw721Service.prototype.updateOwnerShipAccept = function (wallet, contractAddress, txMisc) {
263
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
264
+ return __awaiter(this, void 0, void 0, function () {
265
+ var msgData;
266
+ return __generator(this, function (_a) {
267
+ switch (_a.label) {
268
+ case 0:
269
+ msgData = getMsgUpdateOwnerShipAccept();
270
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
271
+ case 1: return [2 /*return*/, _a.sent()];
272
+ }
273
+ });
274
+ });
275
+ };
276
+ FirmaCosmWasmCw721Service.prototype.updateOwnerShipRenounce = function (wallet, contractAddress, txMisc) {
277
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
278
+ return __awaiter(this, void 0, void 0, function () {
279
+ var msgData;
280
+ return __generator(this, function (_a) {
281
+ switch (_a.label) {
282
+ case 0:
283
+ msgData = getMsgUpdateOwnerShipRenounce();
284
+ return [4 /*yield*/, this.cosmwasmService.executeContract(wallet, contractAddress, msgData, noFunds, txMisc)];
285
+ case 1: return [2 /*return*/, _a.sent()];
286
+ }
287
+ });
288
+ });
289
+ };
290
+ // gas
291
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationMint = function (wallet, contractAddress, owner, token_id, token_uri) {
292
+ if (token_uri === void 0) { token_uri = ""; }
293
+ return __awaiter(this, void 0, void 0, function () {
294
+ var msgData;
295
+ return __generator(this, function (_a) {
296
+ switch (_a.label) {
297
+ case 0:
298
+ msgData = getMsgDataMint(owner, token_id, token_uri);
299
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
300
+ case 1: return [2 /*return*/, _a.sent()];
301
+ }
302
+ });
303
+ });
304
+ };
305
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationBurn = function (wallet, contractAddress, token_id) {
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ var msgData;
308
+ return __generator(this, function (_a) {
309
+ switch (_a.label) {
310
+ case 0:
311
+ msgData = getMsgDataBurn(token_id);
312
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
313
+ case 1: return [2 /*return*/, _a.sent()];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationTransfer = function (wallet, contractAddress, recipient, token_id) {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ var msgData;
321
+ return __generator(this, function (_a) {
322
+ switch (_a.label) {
323
+ case 0:
324
+ msgData = getMsgDataTransfer(recipient, token_id);
325
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
326
+ case 1: return [2 /*return*/, _a.sent()];
327
+ }
328
+ });
329
+ });
330
+ };
331
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationApprove = function (wallet, contractAddress, spender, token_id, expires) {
332
+ return __awaiter(this, void 0, void 0, function () {
333
+ var msgData;
334
+ return __generator(this, function (_a) {
335
+ switch (_a.label) {
336
+ case 0:
337
+ msgData = getMsgDataApprove(spender, token_id, expires);
338
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
339
+ case 1: return [2 /*return*/, _a.sent()];
340
+ }
341
+ });
342
+ });
343
+ };
344
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationRevoke = function (wallet, contractAddress, spender, token_id) {
345
+ return __awaiter(this, void 0, void 0, function () {
346
+ var msgData;
347
+ return __generator(this, function (_a) {
348
+ switch (_a.label) {
349
+ case 0:
350
+ msgData = getMsgDataRevoke(spender, token_id);
351
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
352
+ case 1: return [2 /*return*/, _a.sent()];
353
+ }
354
+ });
355
+ });
356
+ };
357
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationApproveAll = function (wallet, contractAddress, operator, expires) {
358
+ return __awaiter(this, void 0, void 0, function () {
359
+ var msgData;
360
+ return __generator(this, function (_a) {
361
+ switch (_a.label) {
362
+ case 0:
363
+ msgData = getMsgDataApproveAll(operator, expires);
364
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
365
+ case 1: return [2 /*return*/, _a.sent()];
366
+ }
367
+ });
368
+ });
369
+ };
370
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationRevokeAll = function (wallet, contractAddress, operator) {
371
+ return __awaiter(this, void 0, void 0, function () {
372
+ var msgData;
373
+ return __generator(this, function (_a) {
374
+ switch (_a.label) {
375
+ case 0:
376
+ msgData = getMsgDataRevokeAll(operator);
377
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
378
+ case 1: return [2 /*return*/, _a.sent()];
379
+ }
380
+ });
381
+ });
382
+ };
383
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationSendNft = function (wallet, contractAddress, targetContractAddress, token_id, msg) {
384
+ return __awaiter(this, void 0, void 0, function () {
385
+ var msgData;
386
+ return __generator(this, function (_a) {
387
+ switch (_a.label) {
388
+ case 0:
389
+ msgData = getMsgDataSendNft(targetContractAddress, token_id, msg);
390
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
391
+ case 1: return [2 /*return*/, _a.sent()];
392
+ }
393
+ });
394
+ });
395
+ };
396
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationUpdateOwnerShipTransfer = function (wallet, contractAddress, new_owner, expiry) {
397
+ return __awaiter(this, void 0, void 0, function () {
398
+ var msgData;
399
+ return __generator(this, function (_a) {
400
+ switch (_a.label) {
401
+ case 0:
402
+ msgData = getMsgUpdateOwnerShipTransfer(new_owner, expiry);
403
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
404
+ case 1: return [2 /*return*/, _a.sent()];
405
+ }
406
+ });
407
+ });
408
+ };
409
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationUpdateOwnerShipAccept = function (wallet, contractAddress) {
410
+ return __awaiter(this, void 0, void 0, function () {
411
+ var msgData;
412
+ return __generator(this, function (_a) {
413
+ switch (_a.label) {
414
+ case 0:
415
+ msgData = getMsgUpdateOwnerShipAccept();
416
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
417
+ case 1: return [2 /*return*/, _a.sent()];
418
+ }
419
+ });
420
+ });
421
+ };
422
+ FirmaCosmWasmCw721Service.prototype.getGasEstimationUpdateOwnerShipRenounce = function (wallet, contractAddress) {
423
+ return __awaiter(this, void 0, void 0, function () {
424
+ var msgData;
425
+ return __generator(this, function (_a) {
426
+ switch (_a.label) {
427
+ case 0:
428
+ msgData = getMsgUpdateOwnerShipRenounce();
429
+ return [4 /*yield*/, this.cosmwasmService.getGasEstimationExecuteContract(wallet, contractAddress, msgData, noFunds)];
430
+ case 1: return [2 /*return*/, _a.sent()];
431
+ }
432
+ });
433
+ });
434
+ };
46
435
  // query
47
436
  FirmaCosmWasmCw721Service.prototype.getOwnerFromNftID = function (contractAddress, tokenId) {
48
437
  return __awaiter(this, void 0, void 0, function () {
@@ -135,19 +524,20 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
135
524
  });
136
525
  });
137
526
  };
138
- FirmaCosmWasmCw721Service.prototype.getTotalNfts = function (contractAddress) {
527
+ FirmaCosmWasmCw721Service.prototype.getOperator = function (contractAddress, owner, operator, isIncludeExpired) {
528
+ if (isIncludeExpired === void 0) { isIncludeExpired = false; }
139
529
  return __awaiter(this, void 0, void 0, function () {
140
530
  var query, result, data, error_5;
141
531
  return __generator(this, function (_a) {
142
532
  switch (_a.label) {
143
533
  case 0:
144
534
  _a.trys.push([0, 2, , 3]);
145
- query = "{\"num_tokens\": { }}";
535
+ query = "{\"operator\": { \"owner\": \"" + owner + "\", \"operator\": \"" + operator + "\" ,\"include_expired\" : " + isIncludeExpired + " }}";
146
536
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
147
537
  case 1:
148
538
  result = _a.sent();
149
539
  data = JSON.parse(result);
150
- return [2 /*return*/, data.count];
540
+ return [2 /*return*/, data.approval];
151
541
  case 2:
152
542
  error_5 = _a.sent();
153
543
  FirmaUtil_1.FirmaUtil.printLog(error_5);
@@ -157,19 +547,19 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
157
547
  });
158
548
  });
159
549
  };
160
- FirmaCosmWasmCw721Service.prototype.getContractInfo = function (contractAddress) {
550
+ FirmaCosmWasmCw721Service.prototype.getTotalNfts = function (contractAddress) {
161
551
  return __awaiter(this, void 0, void 0, function () {
162
552
  var query, result, data, error_6;
163
553
  return __generator(this, function (_a) {
164
554
  switch (_a.label) {
165
555
  case 0:
166
556
  _a.trys.push([0, 2, , 3]);
167
- query = "{\"contract_info\": { }}";
557
+ query = "{\"num_tokens\": { }}";
168
558
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
169
559
  case 1:
170
560
  result = _a.sent();
171
561
  data = JSON.parse(result);
172
- return [2 /*return*/, data];
562
+ return [2 /*return*/, data.count];
173
563
  case 2:
174
564
  error_6 = _a.sent();
175
565
  FirmaUtil_1.FirmaUtil.printLog(error_6);
@@ -179,19 +569,19 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
179
569
  });
180
570
  });
181
571
  };
182
- FirmaCosmWasmCw721Service.prototype.getNftTokenUri = function (contractAddress, tokenId) {
572
+ FirmaCosmWasmCw721Service.prototype.getContractInfo = function (contractAddress) {
183
573
  return __awaiter(this, void 0, void 0, function () {
184
574
  var query, result, data, error_7;
185
575
  return __generator(this, function (_a) {
186
576
  switch (_a.label) {
187
577
  case 0:
188
578
  _a.trys.push([0, 2, , 3]);
189
- query = "{\"nft_info\": { \"token_id\": \"" + tokenId + "\" }}";
579
+ query = "{\"contract_info\": { }}";
190
580
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
191
581
  case 1:
192
582
  result = _a.sent();
193
583
  data = JSON.parse(result);
194
- return [2 /*return*/, data.token_uri];
584
+ return [2 /*return*/, data];
195
585
  case 2:
196
586
  error_7 = _a.sent();
197
587
  FirmaUtil_1.FirmaUtil.printLog(error_7);
@@ -201,19 +591,19 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
201
591
  });
202
592
  });
203
593
  };
204
- FirmaCosmWasmCw721Service.prototype.getNftData = function (contractAddress, tokenId) {
594
+ FirmaCosmWasmCw721Service.prototype.getNftTokenUri = function (contractAddress, tokenId) {
205
595
  return __awaiter(this, void 0, void 0, function () {
206
596
  var query, result, data, error_8;
207
597
  return __generator(this, function (_a) {
208
598
  switch (_a.label) {
209
599
  case 0:
210
600
  _a.trys.push([0, 2, , 3]);
211
- query = "{\"all_nft_info\": { \"token_id\": \"" + tokenId + "\" }}";
601
+ query = "{\"nft_info\": { \"token_id\": \"" + tokenId + "\" }}";
212
602
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
213
603
  case 1:
214
604
  result = _a.sent();
215
605
  data = JSON.parse(result);
216
- return [2 /*return*/, data];
606
+ return [2 /*return*/, data.token_uri];
217
607
  case 2:
218
608
  error_8 = _a.sent();
219
609
  FirmaUtil_1.FirmaUtil.printLog(error_8);
@@ -223,19 +613,19 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
223
613
  });
224
614
  });
225
615
  };
226
- FirmaCosmWasmCw721Service.prototype.getNFTIdListOfOwner = function (contractAddress, owner) {
616
+ FirmaCosmWasmCw721Service.prototype.getNftData = function (contractAddress, tokenId) {
227
617
  return __awaiter(this, void 0, void 0, function () {
228
618
  var query, result, data, error_9;
229
619
  return __generator(this, function (_a) {
230
620
  switch (_a.label) {
231
621
  case 0:
232
622
  _a.trys.push([0, 2, , 3]);
233
- query = "{\"tokens\": { \"owner\": \"" + owner + "\" }}";
623
+ query = "{\"all_nft_info\": { \"token_id\": \"" + tokenId + "\" }}";
234
624
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
235
625
  case 1:
236
626
  result = _a.sent();
237
627
  data = JSON.parse(result);
238
- return [2 /*return*/, data.tokens];
628
+ return [2 /*return*/, data];
239
629
  case 2:
240
630
  error_9 = _a.sent();
241
631
  FirmaUtil_1.FirmaUtil.printLog(error_9);
@@ -245,15 +635,14 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
245
635
  });
246
636
  });
247
637
  };
248
- // TODO: for many items, limit, start_after can be added later
249
- FirmaCosmWasmCw721Service.prototype.getAllNftIdList = function (contractAddress) {
638
+ FirmaCosmWasmCw721Service.prototype.getNFTIdListOfOwner = function (contractAddress, owner) {
250
639
  return __awaiter(this, void 0, void 0, function () {
251
640
  var query, result, data, error_10;
252
641
  return __generator(this, function (_a) {
253
642
  switch (_a.label) {
254
643
  case 0:
255
644
  _a.trys.push([0, 2, , 3]);
256
- query = "{\"all_tokens\": { }}";
645
+ query = "{\"tokens\": { \"owner\": \"" + owner + "\" }}";
257
646
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
258
647
  case 1:
259
648
  result = _a.sent();
@@ -268,19 +657,20 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
268
657
  });
269
658
  });
270
659
  };
271
- FirmaCosmWasmCw721Service.prototype.getMinter = function (contractAddress) {
660
+ // TODO: for many items, limit, start_after can be added later
661
+ FirmaCosmWasmCw721Service.prototype.getAllNftIdList = function (contractAddress) {
272
662
  return __awaiter(this, void 0, void 0, function () {
273
663
  var query, result, data, error_11;
274
664
  return __generator(this, function (_a) {
275
665
  switch (_a.label) {
276
666
  case 0:
277
667
  _a.trys.push([0, 2, , 3]);
278
- query = "{\"minter\": { }}";
668
+ query = "{\"all_tokens\": { }}";
279
669
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
280
670
  case 1:
281
671
  result = _a.sent();
282
672
  data = JSON.parse(result);
283
- return [2 /*return*/, data.minter];
673
+ return [2 /*return*/, data.tokens];
284
674
  case 2:
285
675
  error_11 = _a.sent();
286
676
  FirmaUtil_1.FirmaUtil.printLog(error_11);
@@ -290,20 +680,19 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
290
680
  });
291
681
  });
292
682
  };
293
- // NOTICE: need to check how to use extension
294
- FirmaCosmWasmCw721Service.prototype.getExtension = function (contractAddress) {
683
+ FirmaCosmWasmCw721Service.prototype.getMinter = function (contractAddress) {
295
684
  return __awaiter(this, void 0, void 0, function () {
296
685
  var query, result, data, error_12;
297
686
  return __generator(this, function (_a) {
298
687
  switch (_a.label) {
299
688
  case 0:
300
689
  _a.trys.push([0, 2, , 3]);
301
- query = "{\"extension\": { \"msg\": {} }}";
690
+ query = "{\"minter\": { }}";
302
691
  return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
303
692
  case 1:
304
693
  result = _a.sent();
305
694
  data = JSON.parse(result);
306
- return [2 /*return*/, data];
695
+ return [2 /*return*/, data.minter];
307
696
  case 2:
308
697
  error_12 = _a.sent();
309
698
  FirmaUtil_1.FirmaUtil.printLog(error_12);
@@ -313,6 +702,50 @@ var FirmaCosmWasmCw721Service = /** @class */ (function () {
313
702
  });
314
703
  });
315
704
  };
705
+ FirmaCosmWasmCw721Service.prototype.getExtension = function (contractAddress) {
706
+ return __awaiter(this, void 0, void 0, function () {
707
+ var query, result, data, error_13;
708
+ return __generator(this, function (_a) {
709
+ switch (_a.label) {
710
+ case 0:
711
+ _a.trys.push([0, 2, , 3]);
712
+ query = "{\"extension\": { \"msg\": {} }}";
713
+ return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
714
+ case 1:
715
+ result = _a.sent();
716
+ data = JSON.parse(result);
717
+ return [2 /*return*/, data];
718
+ case 2:
719
+ error_13 = _a.sent();
720
+ FirmaUtil_1.FirmaUtil.printLog(error_13);
721
+ throw error_13;
722
+ case 3: return [2 /*return*/];
723
+ }
724
+ });
725
+ });
726
+ };
727
+ FirmaCosmWasmCw721Service.prototype.getOwnerShip = function (contractAddress) {
728
+ return __awaiter(this, void 0, void 0, function () {
729
+ var query, result, data, error_14;
730
+ return __generator(this, function (_a) {
731
+ switch (_a.label) {
732
+ case 0:
733
+ _a.trys.push([0, 2, , 3]);
734
+ query = "{\"ownership\": { }}";
735
+ return [4 /*yield*/, this.cosmwasmService.getContractSmartQueryData(contractAddress, query)];
736
+ case 1:
737
+ result = _a.sent();
738
+ data = JSON.parse(result);
739
+ return [2 /*return*/, data];
740
+ case 2:
741
+ error_14 = _a.sent();
742
+ FirmaUtil_1.FirmaUtil.printLog(error_14);
743
+ throw error_14;
744
+ case 3: return [2 /*return*/];
745
+ }
746
+ });
747
+ });
748
+ };
316
749
  return FirmaCosmWasmCw721Service;
317
750
  }());
318
751
  exports.FirmaCosmWasmCw721Service = FirmaCosmWasmCw721Service;
@@ -17,7 +17,7 @@ export declare class TokenService {
17
17
  mint(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, toAddress: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
18
18
  burn(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
19
19
  updateTokenURI(wallet: FirmaWalletService, tokenID: string, tokenURI: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
20
- getGetTokenDataAll(paginationKey?: string): Promise<{
20
+ getTokenDataAll(paginationKey?: string): Promise<{
21
21
  dataList: TokenDataType[];
22
22
  pagination: Pagination;
23
23
  }>;
@@ -349,7 +349,7 @@ var TokenService = /** @class */ (function () {
349
349
  });
350
350
  };
351
351
  // query
352
- TokenService.prototype.getGetTokenDataAll = function (paginationKey) {
352
+ TokenService.prototype.getTokenDataAll = function (paginationKey) {
353
353
  if (paginationKey === void 0) { paginationKey = ""; }
354
354
  return __awaiter(this, void 0, void 0, function () {
355
355
  var queryClient, error_13;
@@ -57,6 +57,11 @@ function accountFromAny(input) {
57
57
  var baseAccount = (_g = (_f = vesting_1.PeriodicVestingAccount.decode(value)) === null || _f === void 0 ? void 0 : _f.baseVestingAccount) === null || _g === void 0 ? void 0 : _g.baseAccount;
58
58
  return accountFromBaseAccount(baseAccount);
59
59
  }
60
+ case "/ethermint.types.v1.EthAccount":
61
+ {
62
+ var baseAccount = auth_1.ModuleAccount.decode(value).baseAccount;
63
+ return accountFromBaseAccount(baseAccount);
64
+ }
60
65
  default:
61
66
  throw new Error("Unsupported type: '" + typeUrl + "'");
62
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",