@firmachain/firma-js 0.2.11 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './sdk/FirmaSDK';
2
+ export * from './sdk/FirmaMobileSDK';
2
3
  export * from './sdk/FirmaConfig';
3
4
  export * from './sdk/FirmaUtil';
package/dist/index.js CHANGED
@@ -11,5 +11,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./sdk/FirmaSDK"), exports);
14
+ __exportStar(require("./sdk/FirmaMobileSDK"), exports);
14
15
  __exportStar(require("./sdk/FirmaConfig"), exports);
15
16
  __exportStar(require("./sdk/FirmaUtil"), exports);
@@ -1,4 +1,4 @@
1
- import { TxMisc } from "./firmachain/bank";
1
+ import { TxMisc, Token } from "./firmachain/bank";
2
2
  import { FirmaWalletService } from "./FirmaWalletService";
3
3
  import { FirmaConfig } from "./FirmaConfig";
4
4
  import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
@@ -6,7 +6,10 @@ export declare class FirmaBankService {
6
6
  private readonly config;
7
7
  constructor(config: FirmaConfig);
8
8
  getGasEstimationSend(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<number>;
9
+ sendToken(wallet: FirmaWalletService, targetAddress: string, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
9
10
  send(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
11
+ getTokenBalanceList(address: string): Promise<Token[]>;
12
+ getTokenBalance(address: string, tokenID: string): Promise<string>;
10
13
  getBalance(address: string): Promise<string>;
11
14
  private getSignedTxSend;
12
15
  }
@@ -51,7 +51,7 @@ var FirmaBankService = /** @class */ (function () {
51
51
  switch (_a.label) {
52
52
  case 0:
53
53
  _a.trys.push([0, 3, , 4]);
54
- return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, amount, txMisc)];
54
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, this.config.denom, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount), txMisc)];
55
55
  case 1:
56
56
  txRaw = _a.sent();
57
57
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -65,7 +65,7 @@ var FirmaBankService = /** @class */ (function () {
65
65
  });
66
66
  });
67
67
  };
68
- FirmaBankService.prototype.send = function (wallet, targetAddress, amount, txMisc) {
68
+ FirmaBankService.prototype.sendToken = function (wallet, targetAddress, tokenID, amount, decimal, txMisc) {
69
69
  if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
70
70
  return __awaiter(this, void 0, void 0, function () {
71
71
  var txRaw, bankTxClient, error_2;
@@ -73,7 +73,7 @@ var FirmaBankService = /** @class */ (function () {
73
73
  switch (_a.label) {
74
74
  case 0:
75
75
  _a.trys.push([0, 3, , 4]);
76
- return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, amount, txMisc)];
76
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, tokenID, FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amount, decimal), txMisc)];
77
77
  case 1:
78
78
  txRaw = _a.sent();
79
79
  bankTxClient = new bank_1.BankTxClient(wallet.getRawWallet(), this.config.rpcAddress);
@@ -88,9 +88,81 @@ var FirmaBankService = /** @class */ (function () {
88
88
  });
89
89
  });
90
90
  };
91
+ FirmaBankService.prototype.send = function (wallet, targetAddress, amount, txMisc) {
92
+ if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ var txRaw, bankTxClient, error_3;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ _a.trys.push([0, 3, , 4]);
99
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, this.config.denom, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount), txMisc)];
100
+ case 1:
101
+ txRaw = _a.sent();
102
+ bankTxClient = new bank_1.BankTxClient(wallet.getRawWallet(), this.config.rpcAddress);
103
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
104
+ case 2: return [2 /*return*/, _a.sent()];
105
+ case 3:
106
+ error_3 = _a.sent();
107
+ FirmaUtil_1.FirmaUtil.printLog(error_3);
108
+ throw error_3;
109
+ case 4: return [2 /*return*/];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ FirmaBankService.prototype.getTokenBalanceList = function (address) {
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ var bankQueryClient, result, tokenList, i, error_4;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ _a.trys.push([0, 2, , 3]);
121
+ bankQueryClient = new bank_1.BankQueryClient(this.config.restApiAddress);
122
+ return [4 /*yield*/, bankQueryClient.queryBalanceList(address)];
123
+ case 1:
124
+ result = _a.sent();
125
+ tokenList = [];
126
+ for (i = 0; i < result.length; i++) {
127
+ // ignore config.denom
128
+ if (result[i].denom === this.config.denom)
129
+ continue;
130
+ tokenList.push(result[i]);
131
+ }
132
+ return [2 /*return*/, tokenList];
133
+ case 2:
134
+ error_4 = _a.sent();
135
+ FirmaUtil_1.FirmaUtil.printLog(error_4);
136
+ throw error_4;
137
+ case 3: return [2 /*return*/];
138
+ }
139
+ });
140
+ });
141
+ };
142
+ FirmaBankService.prototype.getTokenBalance = function (address, tokenID) {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ var bankQueryClient, result, error_5;
145
+ return __generator(this, function (_a) {
146
+ switch (_a.label) {
147
+ case 0:
148
+ _a.trys.push([0, 2, , 3]);
149
+ bankQueryClient = new bank_1.BankQueryClient(this.config.restApiAddress);
150
+ return [4 /*yield*/, bankQueryClient.queryTokenBalance(address, tokenID)];
151
+ case 1:
152
+ result = _a.sent();
153
+ return [2 /*return*/, result.amount];
154
+ case 2:
155
+ error_5 = _a.sent();
156
+ FirmaUtil_1.FirmaUtil.printLog(error_5);
157
+ throw error_5;
158
+ case 3: return [2 /*return*/];
159
+ }
160
+ });
161
+ });
162
+ };
91
163
  FirmaBankService.prototype.getBalance = function (address) {
92
164
  return __awaiter(this, void 0, void 0, function () {
93
- var bankQueryClient, result, error_3;
165
+ var bankQueryClient, result, error_6;
94
166
  return __generator(this, function (_a) {
95
167
  switch (_a.label) {
96
168
  case 0:
@@ -99,20 +171,20 @@ var FirmaBankService = /** @class */ (function () {
99
171
  return [4 /*yield*/, bankQueryClient.queryBalance(address, this.config.denom)];
100
172
  case 1:
101
173
  result = _a.sent();
102
- return [2 /*return*/, result];
174
+ return [2 /*return*/, result.amount];
103
175
  case 2:
104
- error_3 = _a.sent();
105
- FirmaUtil_1.FirmaUtil.printLog(error_3);
106
- throw error_3;
176
+ error_6 = _a.sent();
177
+ FirmaUtil_1.FirmaUtil.printLog(error_6);
178
+ throw error_6;
107
179
  case 3: return [2 /*return*/];
108
180
  }
109
181
  });
110
182
  });
111
183
  };
112
- FirmaBankService.prototype.getSignedTxSend = function (wallet, targetAddress, amount, txMisc) {
184
+ FirmaBankService.prototype.getSignedTxSend = function (wallet, targetAddress, denom, amount, txMisc) {
113
185
  if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
114
186
  return __awaiter(this, void 0, void 0, function () {
115
- var bankTxClient, address, sendAmount, message, error_4;
187
+ var bankTxClient, address, sendAmount, message, error_7;
116
188
  return __generator(this, function (_a) {
117
189
  switch (_a.label) {
118
190
  case 0:
@@ -121,14 +193,14 @@ var FirmaBankService = /** @class */ (function () {
121
193
  return [4 /*yield*/, wallet.getAddress()];
122
194
  case 1:
123
195
  address = _a.sent();
124
- sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
196
+ sendAmount = { denom: denom, amount: amount };
125
197
  message = bankTxClient.msgSend({ fromAddress: address, toAddress: targetAddress, amount: [sendAmount] });
126
198
  return [4 /*yield*/, bankTxClient.sign([message], bank_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
127
199
  case 2: return [2 /*return*/, _a.sent()];
128
200
  case 3:
129
- error_4 = _a.sent();
130
- FirmaUtil_1.FirmaUtil.printLog(error_4);
131
- throw error_4;
201
+ error_7 = _a.sent();
202
+ FirmaUtil_1.FirmaUtil.printLog(error_7);
203
+ throw error_7;
132
204
  case 4: return [2 /*return*/];
133
205
  }
134
206
  });
@@ -28,8 +28,8 @@ var FirmaConfig = /** @class */ (function () {
28
28
  };
29
29
  FirmaConfig.TestNetConfig = {
30
30
  chainID: "colosseum-1",
31
- rpcAddress: "https://imperium-node1.firmachain.org:26657",
32
- restApiAddress: "https://imperium-node1.firmachain.org:1317",
31
+ rpcAddress: "https://colosseum-lcd.firmachain.dev:26657",
32
+ restApiAddress: "https://colosseum-lcd.firmachain.dev:1317",
33
33
  ipfsNodeAddress: "ipfs-api-firma-devnet.firmachain.org",
34
34
  ipfsNodePort: 5001,
35
35
  ipfsWebApiAddress: "https://ipfs-firma-devnet.firmachain.org",
@@ -0,0 +1,27 @@
1
+ import { FirmaConfig } from "./FirmaConfig";
2
+ import { FirmaBankService } from "./FirmaBankService";
3
+ import { FirmaFeeGrantService } from "./FirmaFeeGrantService";
4
+ import { FirmaStakingService } from "./FirmaStakingService";
5
+ import { FirmaDistributionService } from "./FirmaDistributionService";
6
+ import { NftService } from "./FirmaNftService";
7
+ import { TokenService } from "./FirmaTokenService";
8
+ import { ContractService } from "./FirmaContractService";
9
+ import { FirmaWalletService } from "./FirmaWalletService";
10
+ import { FirmaGovService } from "./FirmaGovService";
11
+ import { ChainService } from "./FirmaChainService";
12
+ import { SlashingService } from "./FirmaSlashingService";
13
+ export declare class FirmaMobileSDK {
14
+ Config: FirmaConfig;
15
+ Wallet: FirmaWalletService;
16
+ Bank: FirmaBankService;
17
+ FeeGrant: FirmaFeeGrantService;
18
+ Staking: FirmaStakingService;
19
+ Distribution: FirmaDistributionService;
20
+ Gov: FirmaGovService;
21
+ Nft: NftService;
22
+ Token: TokenService;
23
+ Contract: ContractService;
24
+ BlockChain: ChainService;
25
+ Slashing: SlashingService;
26
+ constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Token?: TokenService, Contract?: ContractService, BlockChain?: ChainService, Slashing?: SlashingService);
27
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FirmaMobileSDK = void 0;
4
+ var FirmaBankService_1 = require("./FirmaBankService");
5
+ var FirmaFeeGrantService_1 = require("./FirmaFeeGrantService");
6
+ var FirmaStakingService_1 = require("./FirmaStakingService");
7
+ var FirmaDistributionService_1 = require("./FirmaDistributionService");
8
+ var FirmaNftService_1 = require("./FirmaNftService");
9
+ var FirmaTokenService_1 = require("./FirmaTokenService");
10
+ var FirmaContractService_1 = require("./FirmaContractService");
11
+ var FirmaWalletService_1 = require("./FirmaWalletService");
12
+ var FirmaUtil_1 = require("./FirmaUtil");
13
+ var FirmaGovService_1 = require("./FirmaGovService");
14
+ var FirmaChainService_1 = require("./FirmaChainService");
15
+ var FirmaSlashingService_1 = require("./FirmaSlashingService");
16
+ var FirmaMobileSDK = /** @class */ (function () {
17
+ function FirmaMobileSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, BlockChain, Slashing) {
18
+ if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
19
+ if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
20
+ if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
21
+ if (Staking === void 0) { Staking = new FirmaStakingService_1.FirmaStakingService(Config); }
22
+ if (Distribution === void 0) { Distribution = new FirmaDistributionService_1.FirmaDistributionService(Config); }
23
+ if (Gov === void 0) { Gov = new FirmaGovService_1.FirmaGovService(Config); }
24
+ if (Nft === void 0) { Nft = new FirmaNftService_1.NftService(Config); }
25
+ if (Token === void 0) { Token = new FirmaTokenService_1.TokenService(Config); }
26
+ if (Contract === void 0) { Contract = new FirmaContractService_1.ContractService(Config); }
27
+ if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
28
+ if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
29
+ this.Config = Config;
30
+ this.Wallet = Wallet;
31
+ this.Bank = Bank;
32
+ this.FeeGrant = FeeGrant;
33
+ this.Staking = Staking;
34
+ this.Distribution = Distribution;
35
+ this.Gov = Gov;
36
+ this.Nft = Nft;
37
+ this.Token = Token;
38
+ this.Contract = Contract;
39
+ this.BlockChain = BlockChain;
40
+ this.Slashing = Slashing;
41
+ FirmaUtil_1.FirmaUtil.config = Config;
42
+ }
43
+ return FirmaMobileSDK;
44
+ }());
45
+ exports.FirmaMobileSDK = FirmaMobileSDK;
@@ -4,6 +4,7 @@ import { FirmaFeeGrantService } from "./FirmaFeeGrantService";
4
4
  import { FirmaStakingService } from "./FirmaStakingService";
5
5
  import { FirmaDistributionService } from "./FirmaDistributionService";
6
6
  import { NftService } from "./FirmaNftService";
7
+ import { TokenService } from "./FirmaTokenService";
7
8
  import { ContractService } from "./FirmaContractService";
8
9
  import { IpfsService } from "./FirmaIpfsService";
9
10
  import { FirmaWalletService } from "./FirmaWalletService";
@@ -19,9 +20,10 @@ export declare class FirmaSDK {
19
20
  Distribution: FirmaDistributionService;
20
21
  Gov: FirmaGovService;
21
22
  Nft: NftService;
23
+ Token: TokenService;
22
24
  Contract: ContractService;
23
25
  Ipfs: IpfsService;
24
26
  BlockChain: ChainService;
25
27
  Slashing: SlashingService;
26
- constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Contract?: ContractService, Ipfs?: IpfsService, BlockChain?: ChainService, Slashing?: SlashingService);
28
+ 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);
27
29
  }
@@ -6,6 +6,7 @@ var FirmaFeeGrantService_1 = require("./FirmaFeeGrantService");
6
6
  var FirmaStakingService_1 = require("./FirmaStakingService");
7
7
  var FirmaDistributionService_1 = require("./FirmaDistributionService");
8
8
  var FirmaNftService_1 = require("./FirmaNftService");
9
+ var FirmaTokenService_1 = require("./FirmaTokenService");
9
10
  var FirmaContractService_1 = require("./FirmaContractService");
10
11
  var FirmaIpfsService_1 = require("./FirmaIpfsService");
11
12
  var FirmaWalletService_1 = require("./FirmaWalletService");
@@ -14,7 +15,7 @@ var FirmaGovService_1 = require("./FirmaGovService");
14
15
  var FirmaChainService_1 = require("./FirmaChainService");
15
16
  var FirmaSlashingService_1 = require("./FirmaSlashingService");
16
17
  var FirmaSDK = /** @class */ (function () {
17
- function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Contract, Ipfs, BlockChain, Slashing) {
18
+ function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing) {
18
19
  if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
19
20
  if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
20
21
  if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
@@ -22,6 +23,7 @@ var FirmaSDK = /** @class */ (function () {
22
23
  if (Distribution === void 0) { Distribution = new FirmaDistributionService_1.FirmaDistributionService(Config); }
23
24
  if (Gov === void 0) { Gov = new FirmaGovService_1.FirmaGovService(Config); }
24
25
  if (Nft === void 0) { Nft = new FirmaNftService_1.NftService(Config); }
26
+ if (Token === void 0) { Token = new FirmaTokenService_1.TokenService(Config); }
25
27
  if (Contract === void 0) { Contract = new FirmaContractService_1.ContractService(Config); }
26
28
  if (Ipfs === void 0) { Ipfs = new FirmaIpfsService_1.IpfsService(Config); }
27
29
  if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
@@ -34,6 +36,7 @@ var FirmaSDK = /** @class */ (function () {
34
36
  this.Distribution = Distribution;
35
37
  this.Gov = Gov;
36
38
  this.Nft = Nft;
39
+ this.Token = Token;
37
40
  this.Contract = Contract;
38
41
  this.Ipfs = Ipfs;
39
42
  this.BlockChain = BlockChain;
@@ -0,0 +1,26 @@
1
+ import { TxMisc, TokenDataType, Pagination } from "./firmachain/token";
2
+ import { FirmaConfig } from "./FirmaConfig";
3
+ import { FirmaWalletService } from "./FirmaWalletService";
4
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
5
+ export declare class TokenService {
6
+ private readonly config;
7
+ constructor(config: FirmaConfig);
8
+ getGasEstimationCreateToken(wallet: FirmaWalletService, tokenName: string, tokenSymbol: string, tokenURI: string, totalSupply: number, decimal: number, isMintable: boolean, isBurnable: boolean, txMisc?: TxMisc): Promise<number>;
9
+ getGasEstimationMint(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, toAddress: string, txMisc?: TxMisc): Promise<number>;
10
+ getGasEstimationBurn(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<number>;
11
+ getGasEstimationUpdateTokenURI(wallet: FirmaWalletService, tokenID: string, tokenURI: string, txMisc?: TxMisc): Promise<number>;
12
+ private getSignedTxUpdateTokenURI;
13
+ private getSignedTxBurn;
14
+ private getSignedTxMint;
15
+ private getSignedTxCreateToken;
16
+ createToken(wallet: FirmaWalletService, tokenName: string, tokenSymbol: string, tokenURI: string, totalSupply: number, decimal: number, isMintable: boolean, isBurnable: boolean, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
17
+ mint(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, toAddress: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
18
+ burn(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
19
+ updateTokenURI(wallet: FirmaWalletService, tokenID: string, tokenURI: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
20
+ getGetTokenDataAll(paginationKey?: string): Promise<{
21
+ dataList: TokenDataType[];
22
+ pagination: Pagination;
23
+ }>;
24
+ getTokenData(tokenID: string): Promise<TokenDataType>;
25
+ getTokenDataListFromOwner(ownerAddress: string): Promise<string[]>;
26
+ }