@firmachain/firma-js 0.2.9 → 0.2.13
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/sdk/FirmaBankService.d.ts +4 -1
- package/dist/sdk/FirmaBankService.js +86 -14
- package/dist/sdk/FirmaChainService.d.ts +3 -2
- package/dist/sdk/FirmaChainService.js +2 -2
- package/dist/sdk/FirmaConfig.js +2 -2
- package/dist/sdk/FirmaGovService.d.ts +2 -3
- package/dist/sdk/FirmaGovService.js +6 -4
- package/dist/sdk/FirmaSDK.d.ts +5 -1
- package/dist/sdk/FirmaSDK.js +7 -1
- package/dist/sdk/FirmaSlashingService.d.ts +9 -0
- package/dist/sdk/FirmaSlashingService.js +105 -0
- package/dist/sdk/FirmaTokenService.d.ts +26 -0
- package/dist/sdk/FirmaTokenService.js +416 -0
- package/dist/sdk/FirmaUtil.d.ts +6 -0
- package/dist/sdk/FirmaUtil.js +30 -9
- package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +7 -1
- package/dist/sdk/firmachain/bank/BankQueryClient.js +31 -1
- package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +37 -2
- package/dist/sdk/firmachain/common/TendermintQueryClient.js +3 -3
- package/dist/sdk/firmachain/common/TxCommon.js +2 -2
- package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +22 -0
- package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +101 -0
- package/dist/sdk/firmachain/slashing/index.d.ts +2 -0
- package/dist/sdk/firmachain/slashing/index.js +14 -0
- package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +24 -0
- package/dist/sdk/firmachain/token/TokenQueryClient.js +106 -0
- package/dist/sdk/firmachain/token/TokenTxClient.d.ts +26 -0
- package/dist/sdk/firmachain/token/TokenTxClient.js +48 -0
- package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +116 -0
- package/dist/sdk/firmachain/token/TokenTxTypes.js +685 -0
- package/dist/sdk/firmachain/token/index.d.ts +3 -0
- package/dist/sdk/firmachain/token/index.js +15 -0
- package/package.json +1 -1
|
@@ -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.
|
|
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,
|
|
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
|
-
|
|
105
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
106
|
-
throw
|
|
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,
|
|
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:
|
|
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
|
-
|
|
130
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
131
|
-
throw
|
|
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
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FirmaConfig } from "./FirmaConfig";
|
|
2
|
+
import { ChainSyncInfo, TransactionHash } from "./firmachain/common/TendermintQueryClient";
|
|
2
3
|
export declare class ChainService {
|
|
3
4
|
private readonly config;
|
|
4
5
|
constructor(config: FirmaConfig);
|
|
5
|
-
|
|
6
|
-
getTransactionByHash(txHash: string): Promise<
|
|
6
|
+
getChainSyncInfo(): Promise<ChainSyncInfo>;
|
|
7
|
+
getTransactionByHash(txHash: string): Promise<TransactionHash>;
|
|
7
8
|
}
|
|
@@ -43,7 +43,7 @@ var ChainService = /** @class */ (function () {
|
|
|
43
43
|
function ChainService(config) {
|
|
44
44
|
this.config = config;
|
|
45
45
|
}
|
|
46
|
-
ChainService.prototype.
|
|
46
|
+
ChainService.prototype.getChainSyncInfo = function () {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function () {
|
|
48
48
|
var queryClient, error_1;
|
|
49
49
|
return __generator(this, function (_a) {
|
|
@@ -51,7 +51,7 @@ var ChainService = /** @class */ (function () {
|
|
|
51
51
|
case 0:
|
|
52
52
|
_a.trys.push([0, 2, , 3]);
|
|
53
53
|
queryClient = new TendermintQueryClient_1.TendermintQueryClient(this.config.rpcAddress);
|
|
54
|
-
return [4 /*yield*/, queryClient.
|
|
54
|
+
return [4 /*yield*/, queryClient.queryChainSyncInfo()];
|
|
55
55
|
case 1: return [2 /*return*/, _a.sent()];
|
|
56
56
|
case 2:
|
|
57
57
|
error_1 = _a.sent();
|
package/dist/sdk/FirmaConfig.js
CHANGED
|
@@ -28,8 +28,8 @@ var FirmaConfig = /** @class */ (function () {
|
|
|
28
28
|
};
|
|
29
29
|
FirmaConfig.TestNetConfig = {
|
|
30
30
|
chainID: "colosseum-1",
|
|
31
|
-
rpcAddress: "https://
|
|
32
|
-
restApiAddress: "https://
|
|
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",
|
|
@@ -2,14 +2,13 @@ import { TxMisc, ParamChangeOption, VotingOption, ProposalInfo, ProposalStatus,
|
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
4
|
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
5
|
-
import Long from "long";
|
|
6
5
|
export declare class FirmaGovService {
|
|
7
6
|
private readonly config;
|
|
8
7
|
constructor(config: FirmaConfig);
|
|
9
8
|
getGasEstimationVote(wallet: FirmaWalletService, proposalId: number, option: VotingOption, txMisc?: TxMisc): Promise<number>;
|
|
10
9
|
getGasEstimationDeposit(wallet: FirmaWalletService, proposalId: number, amount: number, txMisc?: TxMisc): Promise<number>;
|
|
11
10
|
getGasEstimationSubmitCancelSoftwareUpgradeProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, txMisc?: TxMisc): Promise<number>;
|
|
12
|
-
getGasEstimationSubmitSoftwareUpgradeProposalByHeight(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, upgradeName: string, height:
|
|
11
|
+
getGasEstimationSubmitSoftwareUpgradeProposalByHeight(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, upgradeName: string, height: number, txMisc?: TxMisc): Promise<number>;
|
|
13
12
|
getGasEstimationSubmitParameterChangeProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, paramList: ParamChangeOption[], txMisc?: TxMisc): Promise<number>;
|
|
14
13
|
getGasEstimationSubmitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, amount: number, recipient: string, txMisc?: TxMisc): Promise<number>;
|
|
15
14
|
getGasEstimationSubmitTextProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, txMisc?: TxMisc): Promise<number>;
|
|
@@ -19,7 +18,7 @@ export declare class FirmaGovService {
|
|
|
19
18
|
private getSignedTxSubmitParameterChangeProposal;
|
|
20
19
|
private getSignedTxSubmitCommunityPoolSpendProposal;
|
|
21
20
|
submitCancelSoftwareUpgradeProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
22
|
-
submitSoftwareUpgradeProposalByHeight(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, upgradeName: string, height:
|
|
21
|
+
submitSoftwareUpgradeProposalByHeight(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, upgradeName: string, height: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
23
22
|
submitSoftwareUpgradeProposalByTime(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, upgradeName: string, upgradeTime: Date, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
24
23
|
submitParameterChangeProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, paramList: ParamChangeOption[], txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
25
24
|
submitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, amount: number, recipient: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
@@ -123,15 +123,16 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
123
123
|
FirmaGovService.prototype.getGasEstimationSubmitSoftwareUpgradeProposalByHeight = function (wallet, title, description, initialDepositFCT, upgradeName, height, txMisc) {
|
|
124
124
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
125
125
|
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var plan, txRaw, error_4;
|
|
126
|
+
var upgradeHeight, plan, txRaw, error_4;
|
|
127
127
|
return __generator(this, function (_a) {
|
|
128
128
|
switch (_a.label) {
|
|
129
129
|
case 0:
|
|
130
130
|
_a.trys.push([0, 3, , 4]);
|
|
131
|
+
upgradeHeight = long_1.default.fromInt(height);
|
|
131
132
|
plan = {
|
|
132
133
|
name: upgradeName,
|
|
133
134
|
time: undefined,
|
|
134
|
-
height:
|
|
135
|
+
height: upgradeHeight,
|
|
135
136
|
info: undefined,
|
|
136
137
|
upgradedClientState: undefined
|
|
137
138
|
};
|
|
@@ -439,15 +440,16 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
439
440
|
FirmaGovService.prototype.submitSoftwareUpgradeProposalByHeight = function (wallet, title, description, initialDeposit, upgradeName, height, txMisc) {
|
|
440
441
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
441
442
|
return __awaiter(this, void 0, void 0, function () {
|
|
442
|
-
var plan, txRaw, txClient, error_14;
|
|
443
|
+
var upgradeHeight, plan, txRaw, txClient, error_14;
|
|
443
444
|
return __generator(this, function (_a) {
|
|
444
445
|
switch (_a.label) {
|
|
445
446
|
case 0:
|
|
446
447
|
_a.trys.push([0, 3, , 4]);
|
|
448
|
+
upgradeHeight = long_1.default.fromInt(height);
|
|
447
449
|
plan = {
|
|
448
450
|
name: upgradeName,
|
|
449
451
|
time: undefined,
|
|
450
|
-
height:
|
|
452
|
+
height: upgradeHeight,
|
|
451
453
|
info: undefined,
|
|
452
454
|
upgradedClientState: undefined
|
|
453
455
|
};
|
package/dist/sdk/FirmaSDK.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ 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";
|
|
10
11
|
import { FirmaGovService } from "./FirmaGovService";
|
|
11
12
|
import { ChainService } from "./FirmaChainService";
|
|
13
|
+
import { SlashingService } from "./FirmaSlashingService";
|
|
12
14
|
export declare class FirmaSDK {
|
|
13
15
|
Config: FirmaConfig;
|
|
14
16
|
Wallet: FirmaWalletService;
|
|
@@ -18,8 +20,10 @@ export declare class FirmaSDK {
|
|
|
18
20
|
Distribution: FirmaDistributionService;
|
|
19
21
|
Gov: FirmaGovService;
|
|
20
22
|
Nft: NftService;
|
|
23
|
+
Token: TokenService;
|
|
21
24
|
Contract: ContractService;
|
|
22
25
|
Ipfs: IpfsService;
|
|
23
26
|
BlockChain: ChainService;
|
|
24
|
-
|
|
27
|
+
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);
|
|
25
29
|
}
|
package/dist/sdk/FirmaSDK.js
CHANGED
|
@@ -6,14 +6,16 @@ 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");
|
|
12
13
|
var FirmaUtil_1 = require("./FirmaUtil");
|
|
13
14
|
var FirmaGovService_1 = require("./FirmaGovService");
|
|
14
15
|
var FirmaChainService_1 = require("./FirmaChainService");
|
|
16
|
+
var FirmaSlashingService_1 = require("./FirmaSlashingService");
|
|
15
17
|
var FirmaSDK = /** @class */ (function () {
|
|
16
|
-
function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Contract, Ipfs, BlockChain) {
|
|
18
|
+
function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing) {
|
|
17
19
|
if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
|
|
18
20
|
if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
|
|
19
21
|
if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
|
|
@@ -21,9 +23,11 @@ var FirmaSDK = /** @class */ (function () {
|
|
|
21
23
|
if (Distribution === void 0) { Distribution = new FirmaDistributionService_1.FirmaDistributionService(Config); }
|
|
22
24
|
if (Gov === void 0) { Gov = new FirmaGovService_1.FirmaGovService(Config); }
|
|
23
25
|
if (Nft === void 0) { Nft = new FirmaNftService_1.NftService(Config); }
|
|
26
|
+
if (Token === void 0) { Token = new FirmaTokenService_1.TokenService(Config); }
|
|
24
27
|
if (Contract === void 0) { Contract = new FirmaContractService_1.ContractService(Config); }
|
|
25
28
|
if (Ipfs === void 0) { Ipfs = new FirmaIpfsService_1.IpfsService(Config); }
|
|
26
29
|
if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
|
|
30
|
+
if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
|
|
27
31
|
this.Config = Config;
|
|
28
32
|
this.Wallet = Wallet;
|
|
29
33
|
this.Bank = Bank;
|
|
@@ -32,9 +36,11 @@ var FirmaSDK = /** @class */ (function () {
|
|
|
32
36
|
this.Distribution = Distribution;
|
|
33
37
|
this.Gov = Gov;
|
|
34
38
|
this.Nft = Nft;
|
|
39
|
+
this.Token = Token;
|
|
35
40
|
this.Contract = Contract;
|
|
36
41
|
this.Ipfs = Ipfs;
|
|
37
42
|
this.BlockChain = BlockChain;
|
|
43
|
+
this.Slashing = Slashing;
|
|
38
44
|
FirmaUtil_1.FirmaUtil.config = Config;
|
|
39
45
|
}
|
|
40
46
|
return FirmaSDK;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FirmaConfig } from "./FirmaConfig";
|
|
2
|
+
import { SigningInfo, SlashingParam } from "./firmachain/slashing/SlashingQueryClient";
|
|
3
|
+
export declare class SlashingService {
|
|
4
|
+
private readonly config;
|
|
5
|
+
constructor(config: FirmaConfig);
|
|
6
|
+
getSlashingParam(): Promise<SlashingParam>;
|
|
7
|
+
getSigningInfos(): Promise<SigningInfo[]>;
|
|
8
|
+
getSigningInfo(consAddress: string): Promise<SigningInfo>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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.SlashingService = void 0;
|
|
40
|
+
var FirmaUtil_1 = require("./FirmaUtil");
|
|
41
|
+
var SlashingQueryClient_1 = require("./firmachain/slashing/SlashingQueryClient");
|
|
42
|
+
var SlashingService = /** @class */ (function () {
|
|
43
|
+
function SlashingService(config) {
|
|
44
|
+
this.config = config;
|
|
45
|
+
}
|
|
46
|
+
SlashingService.prototype.getSlashingParam = function () {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var queryClient, error_1;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
_a.trys.push([0, 2, , 3]);
|
|
53
|
+
queryClient = new SlashingQueryClient_1.SlashingQueryClient(this.config.restApiAddress);
|
|
54
|
+
return [4 /*yield*/, queryClient.queryGetSlashingParam()];
|
|
55
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
56
|
+
case 2:
|
|
57
|
+
error_1 = _a.sent();
|
|
58
|
+
FirmaUtil_1.FirmaUtil.printLog(error_1);
|
|
59
|
+
throw error_1;
|
|
60
|
+
case 3: return [2 /*return*/];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
SlashingService.prototype.getSigningInfos = function () {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var queryClient, error_2;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
_a.trys.push([0, 2, , 3]);
|
|
72
|
+
queryClient = new SlashingQueryClient_1.SlashingQueryClient(this.config.restApiAddress);
|
|
73
|
+
return [4 /*yield*/, queryClient.queryGetSigningInfos()];
|
|
74
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
75
|
+
case 2:
|
|
76
|
+
error_2 = _a.sent();
|
|
77
|
+
FirmaUtil_1.FirmaUtil.printLog(error_2);
|
|
78
|
+
throw error_2;
|
|
79
|
+
case 3: return [2 /*return*/];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
SlashingService.prototype.getSigningInfo = function (consAddress) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
var queryClient, error_3;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
_a.trys.push([0, 2, , 3]);
|
|
91
|
+
queryClient = new SlashingQueryClient_1.SlashingQueryClient(this.config.restApiAddress);
|
|
92
|
+
return [4 /*yield*/, queryClient.queryGetSigningInfo(consAddress)];
|
|
93
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
94
|
+
case 2:
|
|
95
|
+
error_3 = _a.sent();
|
|
96
|
+
FirmaUtil_1.FirmaUtil.printLog(error_3);
|
|
97
|
+
throw error_3;
|
|
98
|
+
case 3: return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
return SlashingService;
|
|
104
|
+
}());
|
|
105
|
+
exports.SlashingService = SlashingService;
|
|
@@ -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
|
+
}
|