@firmachain/firma-js 0.2.43 → 0.2.44
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,7 +1,9 @@
|
|
|
1
1
|
import { NftItemType, Pagination, TxMisc } from "./firmachain/nft";
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
3
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
4
|
+
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
4
5
|
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
6
|
+
import { EncodeObject } from "@cosmjs/proto-signing";
|
|
5
7
|
export declare class NftService {
|
|
6
8
|
private readonly config;
|
|
7
9
|
constructor(config: FirmaConfig);
|
|
@@ -23,9 +25,11 @@ export declare class NftService {
|
|
|
23
25
|
private getSignedTxTransfer;
|
|
24
26
|
transfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
25
27
|
getGasEstimationBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<number>;
|
|
26
|
-
|
|
28
|
+
getSignedTxBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<TxRaw>;
|
|
27
29
|
burn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
30
|
+
getGasEstimationFromEncodeObject(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<number>;
|
|
28
31
|
getGasEstimationMint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<number>;
|
|
29
32
|
private getSignedTxMint;
|
|
30
33
|
mint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
34
|
+
signAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
31
35
|
}
|
|
@@ -298,15 +298,16 @@ var NftService = /** @class */ (function () {
|
|
|
298
298
|
});
|
|
299
299
|
});
|
|
300
300
|
};
|
|
301
|
-
NftService.prototype.
|
|
301
|
+
NftService.prototype.getGasEstimationFromEncodeObject = function (wallet, msgList, txMisc) {
|
|
302
302
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
303
303
|
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
-
var txRaw, error_12;
|
|
304
|
+
var nftTxClient, txRaw, error_12;
|
|
305
305
|
return __generator(this, function (_a) {
|
|
306
306
|
switch (_a.label) {
|
|
307
307
|
case 0:
|
|
308
308
|
_a.trys.push([0, 3, , 4]);
|
|
309
|
-
|
|
309
|
+
nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
|
|
310
|
+
return [4 /*yield*/, nftTxClient.sign(msgList, (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
|
|
310
311
|
case 1:
|
|
311
312
|
txRaw = _a.sent();
|
|
312
313
|
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
@@ -320,10 +321,32 @@ var NftService = /** @class */ (function () {
|
|
|
320
321
|
});
|
|
321
322
|
});
|
|
322
323
|
};
|
|
324
|
+
NftService.prototype.getGasEstimationMint = function (wallet, tokenURI, txMisc) {
|
|
325
|
+
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
326
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
327
|
+
var txRaw, error_13;
|
|
328
|
+
return __generator(this, function (_a) {
|
|
329
|
+
switch (_a.label) {
|
|
330
|
+
case 0:
|
|
331
|
+
_a.trys.push([0, 3, , 4]);
|
|
332
|
+
return [4 /*yield*/, this.getSignedTxMint(wallet, tokenURI, txMisc)];
|
|
333
|
+
case 1:
|
|
334
|
+
txRaw = _a.sent();
|
|
335
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
336
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
337
|
+
case 3:
|
|
338
|
+
error_13 = _a.sent();
|
|
339
|
+
FirmaUtil_1.FirmaUtil.printLog(error_13);
|
|
340
|
+
throw error_13;
|
|
341
|
+
case 4: return [2 /*return*/];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
323
346
|
NftService.prototype.getSignedTxMint = function (wallet, tokenURI, txMisc) {
|
|
324
347
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
325
348
|
return __awaiter(this, void 0, void 0, function () {
|
|
326
|
-
var address, message, nftTxClient,
|
|
349
|
+
var address, message, nftTxClient, error_14;
|
|
327
350
|
return __generator(this, function (_a) {
|
|
328
351
|
switch (_a.label) {
|
|
329
352
|
case 0:
|
|
@@ -336,9 +359,9 @@ var NftService = /** @class */ (function () {
|
|
|
336
359
|
return [4 /*yield*/, nftTxClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
|
|
337
360
|
case 2: return [2 /*return*/, _a.sent()];
|
|
338
361
|
case 3:
|
|
339
|
-
|
|
340
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
341
|
-
throw
|
|
362
|
+
error_14 = _a.sent();
|
|
363
|
+
FirmaUtil_1.FirmaUtil.printLog(error_14);
|
|
364
|
+
throw error_14;
|
|
342
365
|
case 4: return [2 /*return*/];
|
|
343
366
|
}
|
|
344
367
|
});
|
|
@@ -347,7 +370,7 @@ var NftService = /** @class */ (function () {
|
|
|
347
370
|
NftService.prototype.mint = function (wallet, tokenURI, txMisc) {
|
|
348
371
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
349
372
|
return __awaiter(this, void 0, void 0, function () {
|
|
350
|
-
var txRaw, nftTxClient,
|
|
373
|
+
var txRaw, nftTxClient, error_15;
|
|
351
374
|
return __generator(this, function (_a) {
|
|
352
375
|
switch (_a.label) {
|
|
353
376
|
case 0:
|
|
@@ -359,14 +382,34 @@ var NftService = /** @class */ (function () {
|
|
|
359
382
|
return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
|
|
360
383
|
case 2: return [2 /*return*/, _a.sent()];
|
|
361
384
|
case 3:
|
|
362
|
-
|
|
363
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
364
|
-
throw
|
|
385
|
+
error_15 = _a.sent();
|
|
386
|
+
FirmaUtil_1.FirmaUtil.printLog(error_15);
|
|
387
|
+
throw error_15;
|
|
365
388
|
case 4: return [2 /*return*/];
|
|
366
389
|
}
|
|
367
390
|
});
|
|
368
391
|
});
|
|
369
392
|
};
|
|
393
|
+
NftService.prototype.signAndBroadcast = function (wallet, msgList, txMisc) {
|
|
394
|
+
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
395
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
396
|
+
var contractTxClient, error_16;
|
|
397
|
+
return __generator(this, function (_a) {
|
|
398
|
+
switch (_a.label) {
|
|
399
|
+
case 0:
|
|
400
|
+
_a.trys.push([0, 2, , 3]);
|
|
401
|
+
contractTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
|
|
402
|
+
return [4 /*yield*/, contractTxClient.signAndBroadcast(msgList, (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
|
|
403
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
404
|
+
case 2:
|
|
405
|
+
error_16 = _a.sent();
|
|
406
|
+
FirmaUtil_1.FirmaUtil.printLog(error_16);
|
|
407
|
+
throw error_16;
|
|
408
|
+
case 3: return [2 /*return*/];
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
};
|
|
370
413
|
return NftService;
|
|
371
414
|
}());
|
|
372
415
|
exports.NftService = NftService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firmachain/firma-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.44",
|
|
4
4
|
"description": "The Official FirmaChain Javascript SDK written in Typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@cosmjs/tendermint-rpc": "^0.26.0",
|
|
39
39
|
"@types/pako": "^2.0.0",
|
|
40
40
|
"axios": "^0.27.2",
|
|
41
|
+
"big-number": "^2.0.0",
|
|
41
42
|
"cosmjs-types": "^0.2.0",
|
|
42
43
|
"crypto-js": "^4.1.1",
|
|
43
44
|
"form-data": "^4.0.0",
|