@firmachain/firma-js 0.2.31 → 0.2.32
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/FirmaAuthzService.d.ts +13 -4
- package/dist/sdk/FirmaAuthzService.js +9 -6
- package/dist/sdk/FirmaIbcService.d.ts +15 -0
- package/dist/sdk/FirmaIbcService.js +144 -0
- package/dist/sdk/FirmaSDK.d.ts +3 -1
- package/dist/sdk/FirmaSDK.js +4 -1
- package/dist/sdk/FirmaStakingService.d.ts +17 -5
- package/dist/sdk/FirmaStakingService.js +12 -8
- package/dist/sdk/FirmaUtil.d.ts +6 -0
- package/dist/sdk/FirmaUtil.js +64 -0
- package/dist/sdk/FirmaWalletService.d.ts +3 -0
- package/dist/sdk/FirmaWalletService.js +18 -10
- package/dist/sdk/firmachain/amino/signer.d.ts +1 -2
- package/dist/sdk/firmachain/authz/AuthzQueryClient.d.ts +13 -3
- package/dist/sdk/firmachain/authz/AuthzQueryClient.js +39 -12
- package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +50 -0
- package/dist/sdk/firmachain/common/signingaminostargateclient.js +267 -0
- package/dist/sdk/firmachain/ibc/IbcQueryClient.d.ts +34 -0
- package/dist/sdk/firmachain/ibc/IbcQueryClient.js +71 -0
- package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +12 -0
- package/dist/sdk/firmachain/ibc/IbcTxClient.js +36 -0
- package/dist/sdk/firmachain/ibc/index.d.ts +3 -0
- package/dist/sdk/firmachain/ibc/index.js +15 -0
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +17 -4
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +38 -18
- package/package.json +1 -1
- package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +0 -94
- package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +0 -437
- package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +0 -23
- package/dist/sdk/firmachain/amino/secp256k1wallet.js +0 -141
|
@@ -2,7 +2,7 @@ import { FirmaWalletService } from "./FirmaWalletService";
|
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
3
|
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
4
4
|
import { Any } from "./firmachain/google/protobuf/any";
|
|
5
|
-
import { GrantGenericData, GrantSendData, GrantStakingData, TxMisc } from "./firmachain/authz";
|
|
5
|
+
import { GrantGenericData, GrantSendData, GrantStakingData, Pagination, TxMisc } from "./firmachain/authz";
|
|
6
6
|
import { AuthorizationType } from "./firmachain/authz/AuthzTxTypes";
|
|
7
7
|
export declare class FirmaAuthzService {
|
|
8
8
|
private readonly config;
|
|
@@ -26,7 +26,16 @@ export declare class FirmaAuthzService {
|
|
|
26
26
|
revokeStakeAuthorization(wallet: FirmaWalletService, granteeAddress: string, type: AuthorizationType, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
27
27
|
getGasEstimationExecuteAllowance(wallet: FirmaWalletService, msgs: Any[], txMisc?: TxMisc): Promise<number>;
|
|
28
28
|
executeAllowance(wallet: FirmaWalletService, msgs: Any[], txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
29
|
-
getSendGrantData(granterAddress: string, granteeAddress: string): Promise<
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
getSendGrantData(granterAddress: string, granteeAddress: string, paginationKey?: string): Promise<{
|
|
30
|
+
dataList: GrantSendData[];
|
|
31
|
+
pagination: Pagination;
|
|
32
|
+
}>;
|
|
33
|
+
getGenericGrantData(granterAddress: string, granteeAddress: string, msgType: string, paginationKey?: string): Promise<{
|
|
34
|
+
dataList: GrantGenericData[];
|
|
35
|
+
pagination: Pagination;
|
|
36
|
+
}>;
|
|
37
|
+
getStakingGrantData(granterAddress: string, granteeAddress: string, msgType: AuthorizationType, paginationKey?: string): Promise<{
|
|
38
|
+
dataList: GrantStakingData[];
|
|
39
|
+
pagination: Pagination;
|
|
40
|
+
}>;
|
|
32
41
|
}
|
|
@@ -562,7 +562,8 @@ var FirmaAuthzService = /** @class */ (function () {
|
|
|
562
562
|
});
|
|
563
563
|
};
|
|
564
564
|
// query
|
|
565
|
-
FirmaAuthzService.prototype.getSendGrantData = function (granterAddress, granteeAddress) {
|
|
565
|
+
FirmaAuthzService.prototype.getSendGrantData = function (granterAddress, granteeAddress, paginationKey) {
|
|
566
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
566
567
|
return __awaiter(this, void 0, void 0, function () {
|
|
567
568
|
var queryClient, result, error_20;
|
|
568
569
|
return __generator(this, function (_a) {
|
|
@@ -570,7 +571,7 @@ var FirmaAuthzService = /** @class */ (function () {
|
|
|
570
571
|
case 0:
|
|
571
572
|
_a.trys.push([0, 2, , 3]);
|
|
572
573
|
queryClient = new authz_1.AuthzQueryClient(this.config.restApiAddress);
|
|
573
|
-
return [4 /*yield*/, queryClient.getSendGrantData(granterAddress, granteeAddress)];
|
|
574
|
+
return [4 /*yield*/, queryClient.getSendGrantData(granterAddress, granteeAddress, paginationKey)];
|
|
574
575
|
case 1:
|
|
575
576
|
result = _a.sent();
|
|
576
577
|
return [2 /*return*/, result];
|
|
@@ -583,7 +584,8 @@ var FirmaAuthzService = /** @class */ (function () {
|
|
|
583
584
|
});
|
|
584
585
|
});
|
|
585
586
|
};
|
|
586
|
-
FirmaAuthzService.prototype.getGenericGrantData = function (granterAddress, granteeAddress, msgType) {
|
|
587
|
+
FirmaAuthzService.prototype.getGenericGrantData = function (granterAddress, granteeAddress, msgType, paginationKey) {
|
|
588
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
587
589
|
return __awaiter(this, void 0, void 0, function () {
|
|
588
590
|
var queryClient, result, error_21;
|
|
589
591
|
return __generator(this, function (_a) {
|
|
@@ -591,7 +593,7 @@ var FirmaAuthzService = /** @class */ (function () {
|
|
|
591
593
|
case 0:
|
|
592
594
|
_a.trys.push([0, 2, , 3]);
|
|
593
595
|
queryClient = new authz_1.AuthzQueryClient(this.config.restApiAddress);
|
|
594
|
-
return [4 /*yield*/, queryClient.getGenericGrantData(granterAddress, granteeAddress, msgType)];
|
|
596
|
+
return [4 /*yield*/, queryClient.getGenericGrantData(granterAddress, granteeAddress, msgType, paginationKey)];
|
|
595
597
|
case 1:
|
|
596
598
|
result = _a.sent();
|
|
597
599
|
return [2 /*return*/, result];
|
|
@@ -604,7 +606,8 @@ var FirmaAuthzService = /** @class */ (function () {
|
|
|
604
606
|
});
|
|
605
607
|
});
|
|
606
608
|
};
|
|
607
|
-
FirmaAuthzService.prototype.getStakingGrantData = function (granterAddress, granteeAddress, msgType) {
|
|
609
|
+
FirmaAuthzService.prototype.getStakingGrantData = function (granterAddress, granteeAddress, msgType, paginationKey) {
|
|
610
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
608
611
|
return __awaiter(this, void 0, void 0, function () {
|
|
609
612
|
var queryClient, result, error_22;
|
|
610
613
|
return __generator(this, function (_a) {
|
|
@@ -612,7 +615,7 @@ var FirmaAuthzService = /** @class */ (function () {
|
|
|
612
615
|
case 0:
|
|
613
616
|
_a.trys.push([0, 2, , 3]);
|
|
614
617
|
queryClient = new authz_1.AuthzQueryClient(this.config.restApiAddress);
|
|
615
|
-
return [4 /*yield*/, queryClient.getStakingGrantData(granterAddress, granteeAddress, msgType)];
|
|
618
|
+
return [4 /*yield*/, queryClient.getStakingGrantData(granterAddress, granteeAddress, msgType, paginationKey)];
|
|
616
619
|
case 1:
|
|
617
620
|
result = _a.sent();
|
|
618
621
|
return [2 /*return*/, result];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FirmaWalletService } from "./FirmaWalletService";
|
|
2
|
+
import { FirmaConfig } from "./FirmaConfig";
|
|
3
|
+
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
4
|
+
import { ClientState, IbcTxClient, TxMisc } from "./firmachain/ibc";
|
|
5
|
+
import Long from "long";
|
|
6
|
+
import { Height } from "cosmjs-types/ibc/core/client/v1/client";
|
|
7
|
+
export declare class FirmaIbcService {
|
|
8
|
+
private readonly config;
|
|
9
|
+
constructor(config: FirmaConfig);
|
|
10
|
+
getTxClient(wallet: FirmaWalletService): IbcTxClient;
|
|
11
|
+
getGasEstimationTransfer(wallet: FirmaWalletService, sourcePort: string, sourceChannel: string, denom: string, amount: string, receiver: string, timeoutHeight: Height, timeoutTimestamp: Long, txMisc?: TxMisc): Promise<number>;
|
|
12
|
+
transfer(wallet: FirmaWalletService, sourcePort: string, sourceChannel: string, denom: string, amount: string, receiver: string, timeoutHeight: Height, timeoutTimestamp: Long, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
13
|
+
private getSignedTxTransfer;
|
|
14
|
+
getClientState(sourceChannel: string, sourcePort: string): Promise<ClientState>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
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.FirmaIbcService = void 0;
|
|
40
|
+
var FirmaUtil_1 = require("./FirmaUtil");
|
|
41
|
+
var ibc_1 = require("./firmachain/ibc");
|
|
42
|
+
var FirmaIbcService = /** @class */ (function () {
|
|
43
|
+
function FirmaIbcService(config) {
|
|
44
|
+
this.config = config;
|
|
45
|
+
}
|
|
46
|
+
FirmaIbcService.prototype.getTxClient = function (wallet) {
|
|
47
|
+
return new ibc_1.IbcTxClient(wallet, this.config.rpcAddress);
|
|
48
|
+
};
|
|
49
|
+
FirmaIbcService.prototype.getGasEstimationTransfer = function (wallet, sourcePort, sourceChannel, denom, amount, receiver, timeoutHeight, timeoutTimestamp, txMisc) {
|
|
50
|
+
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var txRaw, error_1;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
_a.trys.push([0, 3, , 4]);
|
|
57
|
+
return [4 /*yield*/, this.getSignedTxTransfer(wallet, sourcePort, sourceChannel, denom, amount, receiver, timeoutHeight, timeoutTimestamp, txMisc)];
|
|
58
|
+
case 1:
|
|
59
|
+
txRaw = _a.sent();
|
|
60
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
61
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
62
|
+
case 3:
|
|
63
|
+
error_1 = _a.sent();
|
|
64
|
+
FirmaUtil_1.FirmaUtil.printLog(error_1);
|
|
65
|
+
throw error_1;
|
|
66
|
+
case 4: return [2 /*return*/];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
FirmaIbcService.prototype.transfer = function (wallet, sourcePort, sourceChannel, denom, amount, receiver, timeoutHeight, timeoutTimestamp, txMisc) {
|
|
72
|
+
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var txRaw, bankTxClient, error_2;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
_a.trys.push([0, 3, , 4]);
|
|
79
|
+
return [4 /*yield*/, this.getSignedTxTransfer(wallet, sourcePort, sourceChannel, denom, amount, receiver, timeoutHeight, timeoutTimestamp, txMisc)];
|
|
80
|
+
case 1:
|
|
81
|
+
txRaw = _a.sent();
|
|
82
|
+
bankTxClient = new ibc_1.IbcTxClient(wallet, this.config.rpcAddress);
|
|
83
|
+
return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
|
|
84
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
85
|
+
case 3:
|
|
86
|
+
error_2 = _a.sent();
|
|
87
|
+
FirmaUtil_1.FirmaUtil.printLog(error_2);
|
|
88
|
+
throw error_2;
|
|
89
|
+
case 4: return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
FirmaIbcService.prototype.getSignedTxTransfer = function (wallet, sourcePort, sourceChannel, denom, amount, receiver, timeoutHeight, timeoutTimestamp, txMisc) {
|
|
95
|
+
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
var ibcTxClient, address, message, error_3;
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
_a.trys.push([0, 3, , 4]);
|
|
102
|
+
ibcTxClient = new ibc_1.IbcTxClient(wallet, this.config.rpcAddress);
|
|
103
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
104
|
+
case 1:
|
|
105
|
+
address = _a.sent();
|
|
106
|
+
message = ibcTxClient.msgTransfer({ sourcePort: sourcePort, sourceChannel: sourceChannel, sender: address, receiver: receiver,
|
|
107
|
+
token: { denom: denom, amount: amount },
|
|
108
|
+
timeoutHeight: timeoutHeight, timeoutTimestamp: timeoutTimestamp });
|
|
109
|
+
return [4 /*yield*/, ibcTxClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
110
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
111
|
+
case 3:
|
|
112
|
+
error_3 = _a.sent();
|
|
113
|
+
FirmaUtil_1.FirmaUtil.printLog(error_3);
|
|
114
|
+
throw error_3;
|
|
115
|
+
case 4: return [2 /*return*/];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
// query
|
|
121
|
+
FirmaIbcService.prototype.getClientState = function (sourceChannel, sourcePort) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
var queryClient, result, error_4;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
_a.trys.push([0, 2, , 3]);
|
|
128
|
+
queryClient = new ibc_1.IbcQueryClient(this.config.restApiAddress);
|
|
129
|
+
return [4 /*yield*/, queryClient.getClientState(sourceChannel, sourcePort)];
|
|
130
|
+
case 1:
|
|
131
|
+
result = _a.sent();
|
|
132
|
+
return [2 /*return*/, result];
|
|
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
|
+
return FirmaIbcService;
|
|
143
|
+
}());
|
|
144
|
+
exports.FirmaIbcService = FirmaIbcService;
|
package/dist/sdk/FirmaSDK.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { ChainService } from "./FirmaChainService";
|
|
|
13
13
|
import { SlashingService } from "./FirmaSlashingService";
|
|
14
14
|
import { FirmaAuthzService } from "./FirmaAuthzService";
|
|
15
15
|
import { FirmaCosmWasmService } from "./FirmaCosmWasmService";
|
|
16
|
+
import { FirmaIbcService } from "./FirmaIbcService";
|
|
16
17
|
export declare class FirmaSDK {
|
|
17
18
|
Config: FirmaConfig;
|
|
18
19
|
Wallet: FirmaWalletService;
|
|
@@ -29,5 +30,6 @@ export declare class FirmaSDK {
|
|
|
29
30
|
Slashing: SlashingService;
|
|
30
31
|
Authz: FirmaAuthzService;
|
|
31
32
|
CosmWasm: FirmaCosmWasmService;
|
|
32
|
-
|
|
33
|
+
Ibc: FirmaIbcService;
|
|
34
|
+
constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Token?: TokenService, Contract?: ContractService, Ipfs?: IpfsService, BlockChain?: ChainService, Slashing?: SlashingService, Authz?: FirmaAuthzService, CosmWasm?: FirmaCosmWasmService, Ibc?: FirmaIbcService);
|
|
33
35
|
}
|
package/dist/sdk/FirmaSDK.js
CHANGED
|
@@ -16,8 +16,9 @@ var FirmaChainService_1 = require("./FirmaChainService");
|
|
|
16
16
|
var FirmaSlashingService_1 = require("./FirmaSlashingService");
|
|
17
17
|
var FirmaAuthzService_1 = require("./FirmaAuthzService");
|
|
18
18
|
var FirmaCosmWasmService_1 = require("./FirmaCosmWasmService");
|
|
19
|
+
var FirmaIbcService_1 = require("./FirmaIbcService");
|
|
19
20
|
var FirmaSDK = /** @class */ (function () {
|
|
20
|
-
function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing, Authz, CosmWasm) {
|
|
21
|
+
function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing, Authz, CosmWasm, Ibc) {
|
|
21
22
|
if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
|
|
22
23
|
if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
|
|
23
24
|
if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
|
|
@@ -32,6 +33,7 @@ var FirmaSDK = /** @class */ (function () {
|
|
|
32
33
|
if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
|
|
33
34
|
if (Authz === void 0) { Authz = new FirmaAuthzService_1.FirmaAuthzService(Config); }
|
|
34
35
|
if (CosmWasm === void 0) { CosmWasm = new FirmaCosmWasmService_1.FirmaCosmWasmService(Config); }
|
|
36
|
+
if (Ibc === void 0) { Ibc = new FirmaIbcService_1.FirmaIbcService(Config); }
|
|
35
37
|
this.Config = Config;
|
|
36
38
|
this.Wallet = Wallet;
|
|
37
39
|
this.Bank = Bank;
|
|
@@ -47,6 +49,7 @@ var FirmaSDK = /** @class */ (function () {
|
|
|
47
49
|
this.Slashing = Slashing;
|
|
48
50
|
this.Authz = Authz;
|
|
49
51
|
this.CosmWasm = CosmWasm;
|
|
52
|
+
this.Ibc = Ibc;
|
|
50
53
|
FirmaUtil_1.FirmaUtil.config = Config;
|
|
51
54
|
}
|
|
52
55
|
return FirmaSDK;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StakingTxClient, TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo } from "./firmachain/staking";
|
|
1
|
+
import { StakingTxClient, TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo, Pagination } from "./firmachain/staking";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
4
|
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
@@ -25,11 +25,23 @@ export declare class FirmaStakingService {
|
|
|
25
25
|
getDelegationInfoFromValidator(address: string, validatorAddress: string): Promise<DelegationInfo>;
|
|
26
26
|
getTotalUndelegateInfo(address: string): Promise<UndelegationInfo[]>;
|
|
27
27
|
getTotalRedelegationInfo(address: string): Promise<RedelegationInfo[]>;
|
|
28
|
-
getUndelegationListFromValidator(valoperAddress: string): Promise<
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
getUndelegationListFromValidator(valoperAddress: string, paginationKey?: string): Promise<{
|
|
29
|
+
dataList: UndelegationInfo[];
|
|
30
|
+
pagination: Pagination;
|
|
31
|
+
}>;
|
|
32
|
+
getDelegationListFromValidator(valoperAddress: string, paginationKey?: string): Promise<{
|
|
33
|
+
dataList: DelegationInfo[];
|
|
34
|
+
pagination: Pagination;
|
|
35
|
+
}>;
|
|
36
|
+
getTotalDelegationInfo(address: string, paginationKey?: string): Promise<{
|
|
37
|
+
dataList: DelegationInfo[];
|
|
38
|
+
pagination: Pagination;
|
|
39
|
+
}>;
|
|
31
40
|
getParams(): Promise<ParamsDataType>;
|
|
32
41
|
getPool(): Promise<PoolDataType>;
|
|
33
42
|
getValidator(valoperAddress: string): Promise<ValidatorDataType>;
|
|
34
|
-
getValidatorList(): Promise<
|
|
43
|
+
getValidatorList(paginationKey?: string): Promise<{
|
|
44
|
+
dataList: ValidatorDataType[];
|
|
45
|
+
pagination: Pagination;
|
|
46
|
+
}>;
|
|
35
47
|
}
|
|
@@ -455,7 +455,8 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
455
455
|
});
|
|
456
456
|
});
|
|
457
457
|
};
|
|
458
|
-
FirmaStakingService.prototype.getUndelegationListFromValidator = function (valoperAddress) {
|
|
458
|
+
FirmaStakingService.prototype.getUndelegationListFromValidator = function (valoperAddress, paginationKey) {
|
|
459
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
459
460
|
return __awaiter(this, void 0, void 0, function () {
|
|
460
461
|
var queryClient, result, error_18;
|
|
461
462
|
return __generator(this, function (_a) {
|
|
@@ -463,7 +464,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
463
464
|
case 0:
|
|
464
465
|
_a.trys.push([0, 2, , 3]);
|
|
465
466
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
466
|
-
return [4 /*yield*/, queryClient.queryGetUndelegationListFromValidator(valoperAddress)];
|
|
467
|
+
return [4 /*yield*/, queryClient.queryGetUndelegationListFromValidator(valoperAddress, paginationKey)];
|
|
467
468
|
case 1:
|
|
468
469
|
result = _a.sent();
|
|
469
470
|
return [2 /*return*/, result];
|
|
@@ -476,7 +477,8 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
476
477
|
});
|
|
477
478
|
});
|
|
478
479
|
};
|
|
479
|
-
FirmaStakingService.prototype.getDelegationListFromValidator = function (valoperAddress) {
|
|
480
|
+
FirmaStakingService.prototype.getDelegationListFromValidator = function (valoperAddress, paginationKey) {
|
|
481
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
480
482
|
return __awaiter(this, void 0, void 0, function () {
|
|
481
483
|
var queryClient, result, error_19;
|
|
482
484
|
return __generator(this, function (_a) {
|
|
@@ -484,7 +486,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
484
486
|
case 0:
|
|
485
487
|
_a.trys.push([0, 2, , 3]);
|
|
486
488
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
487
|
-
return [4 /*yield*/, queryClient.queryGetDelegateListFromValidator(valoperAddress)];
|
|
489
|
+
return [4 /*yield*/, queryClient.queryGetDelegateListFromValidator(valoperAddress, paginationKey)];
|
|
488
490
|
case 1:
|
|
489
491
|
result = _a.sent();
|
|
490
492
|
return [2 /*return*/, result];
|
|
@@ -497,7 +499,8 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
497
499
|
});
|
|
498
500
|
});
|
|
499
501
|
};
|
|
500
|
-
FirmaStakingService.prototype.getTotalDelegationInfo = function (address) {
|
|
502
|
+
FirmaStakingService.prototype.getTotalDelegationInfo = function (address, paginationKey) {
|
|
503
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
501
504
|
return __awaiter(this, void 0, void 0, function () {
|
|
502
505
|
var queryClient, result, error_20;
|
|
503
506
|
return __generator(this, function (_a) {
|
|
@@ -505,7 +508,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
505
508
|
case 0:
|
|
506
509
|
_a.trys.push([0, 2, , 3]);
|
|
507
510
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
508
|
-
return [4 /*yield*/, queryClient.queryGetTotalDelegationInfo(address)];
|
|
511
|
+
return [4 /*yield*/, queryClient.queryGetTotalDelegationInfo(address, paginationKey)];
|
|
509
512
|
case 1:
|
|
510
513
|
result = _a.sent();
|
|
511
514
|
return [2 /*return*/, result];
|
|
@@ -581,7 +584,8 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
581
584
|
});
|
|
582
585
|
});
|
|
583
586
|
};
|
|
584
|
-
FirmaStakingService.prototype.getValidatorList = function () {
|
|
587
|
+
FirmaStakingService.prototype.getValidatorList = function (paginationKey) {
|
|
588
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
585
589
|
return __awaiter(this, void 0, void 0, function () {
|
|
586
590
|
var queryClient, result, error_24;
|
|
587
591
|
return __generator(this, function (_a) {
|
|
@@ -589,7 +593,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
589
593
|
case 0:
|
|
590
594
|
_a.trys.push([0, 2, , 3]);
|
|
591
595
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
592
|
-
return [4 /*yield*/, queryClient.queryValidators()];
|
|
596
|
+
return [4 /*yield*/, queryClient.queryValidators(paginationKey)];
|
|
593
597
|
case 1:
|
|
594
598
|
result = _a.sent();
|
|
595
599
|
return [2 /*return*/, result];
|
package/dist/sdk/FirmaUtil.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
3
|
import { SignerData } from "./firmachain/common/LedgerSigningStargateClient";
|
|
4
4
|
import { SignAndBroadcastOptions, TxMisc } from "./firmachain/common";
|
|
5
|
+
import { ArbitraryVerifyData } from "./firmachain/common/signingaminostargateclient";
|
|
6
|
+
import { FirmaWalletService } from "./FirmaWalletService";
|
|
5
7
|
export declare class FirmaUtil {
|
|
6
8
|
static config: FirmaConfig;
|
|
7
9
|
static readonly FctDecimal: number;
|
|
@@ -11,6 +13,8 @@ export declare class FirmaUtil {
|
|
|
11
13
|
static getTokenStringFromUTokenStr(uTokenAmount: string, decimal: number): string;
|
|
12
14
|
static getUTokenStringFromToken(tokenAmount: number, decimal: number): string;
|
|
13
15
|
static getUTokenFromToken(tokenAmount: number, decimal: number): number;
|
|
16
|
+
static arrayBufferToBase64(buffer: Uint8Array): string;
|
|
17
|
+
static base64ToArrayBuffer(base64: string): Uint8Array;
|
|
14
18
|
static getTokenStringFromUToken(uTokenAmount: number, decimal: number): string;
|
|
15
19
|
static getUFCTStringFromFCTStr(fctAmount: string): string;
|
|
16
20
|
static getUFCTFromFCT(fctAmount: number): number;
|
|
@@ -28,6 +32,8 @@ export declare class FirmaUtil {
|
|
|
28
32
|
static estimateGas(txRaw: TxRaw): Promise<number>;
|
|
29
33
|
static estimateGasRaw(txRaw: Uint8Array): Promise<number>;
|
|
30
34
|
static printLog(log: any): void;
|
|
35
|
+
static experimentalAdr36Sign(wallet: FirmaWalletService, data: string): Promise<ArbitraryVerifyData>;
|
|
36
|
+
static experimentalAdr36Verify(data: ArbitraryVerifyData, checkMsg: string): Promise<boolean>;
|
|
31
37
|
}
|
|
32
38
|
export declare const DefaultTxMisc: {
|
|
33
39
|
memo: string;
|
package/dist/sdk/FirmaUtil.js
CHANGED
|
@@ -46,6 +46,8 @@ var CryptoJS = require("crypto-js");
|
|
|
46
46
|
var sha1 = require("crypto-js/sha1");
|
|
47
47
|
var sha256 = require("crypto-js/sha256");
|
|
48
48
|
var encHex = require("crypto-js/enc-hex");
|
|
49
|
+
var signingaminostargateclient_1 = require("./firmachain/common/signingaminostargateclient");
|
|
50
|
+
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
49
51
|
var FirmaUtil = /** @class */ (function () {
|
|
50
52
|
function FirmaUtil(firmaConfig) {
|
|
51
53
|
FirmaUtil.config = firmaConfig;
|
|
@@ -86,6 +88,24 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
86
88
|
var newBig = big.toFixed(0);
|
|
87
89
|
return Number.parseInt(newBig);
|
|
88
90
|
};
|
|
91
|
+
FirmaUtil.arrayBufferToBase64 = function (buffer) {
|
|
92
|
+
var binary = '';
|
|
93
|
+
var bytes = new Uint8Array(buffer);
|
|
94
|
+
var len = bytes.byteLength;
|
|
95
|
+
for (var i = 0; i < len; i++) {
|
|
96
|
+
binary += String.fromCharCode(bytes[i]);
|
|
97
|
+
}
|
|
98
|
+
return btoa(binary);
|
|
99
|
+
};
|
|
100
|
+
FirmaUtil.base64ToArrayBuffer = function (base64) {
|
|
101
|
+
var binary_string = atob(base64);
|
|
102
|
+
var len = binary_string.length;
|
|
103
|
+
var bytes = new Uint8Array(len);
|
|
104
|
+
for (var i = 0; i < len; i++) {
|
|
105
|
+
bytes[i] = binary_string.charCodeAt(i);
|
|
106
|
+
}
|
|
107
|
+
return bytes;
|
|
108
|
+
};
|
|
89
109
|
FirmaUtil.getTokenStringFromUToken = function (uTokenAmount, decimal) {
|
|
90
110
|
var fixedUTokenAmount = Math.floor(uTokenAmount);
|
|
91
111
|
var decimalMutiplyer = Math.pow(10, decimal);
|
|
@@ -227,6 +247,50 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
227
247
|
return;
|
|
228
248
|
console.log("[FirmaSDK] " + log);
|
|
229
249
|
};
|
|
250
|
+
FirmaUtil.experimentalAdr36Sign = function (wallet, data) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
+
var registry, aliceClient, address, userData, error_4;
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
switch (_a.label) {
|
|
255
|
+
case 0:
|
|
256
|
+
_a.trys.push([0, 4, , 5]);
|
|
257
|
+
registry = new proto_signing_1.Registry();
|
|
258
|
+
return [4 /*yield*/, signingaminostargateclient_1.SigningAminoStargateClient.connectWithSigner(FirmaUtil.config.rpcAddress, wallet.getRawAminoWallet(), registry)];
|
|
259
|
+
case 1:
|
|
260
|
+
aliceClient = _a.sent();
|
|
261
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
262
|
+
case 2:
|
|
263
|
+
address = _a.sent();
|
|
264
|
+
userData = Buffer.from(data);
|
|
265
|
+
return [4 /*yield*/, aliceClient.experimentalAdr36Sign(address, userData)];
|
|
266
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
267
|
+
case 4:
|
|
268
|
+
error_4 = _a.sent();
|
|
269
|
+
FirmaUtil.printLog(error_4);
|
|
270
|
+
throw error_4;
|
|
271
|
+
case 5: return [2 /*return*/];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
FirmaUtil.experimentalAdr36Verify = function (data, checkMsg) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
var error_5;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
_a.trys.push([0, 2, , 3]);
|
|
283
|
+
return [4 /*yield*/, signingaminostargateclient_1.SigningAminoStargateClient.experimentalAdr36Verify(data, checkMsg)];
|
|
284
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
285
|
+
case 2:
|
|
286
|
+
error_5 = _a.sent();
|
|
287
|
+
FirmaUtil.printLog(error_5);
|
|
288
|
+
throw error_5;
|
|
289
|
+
case 3: return [2 /*return*/];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
};
|
|
230
294
|
FirmaUtil.FctDecimal = 6;
|
|
231
295
|
return FirmaUtil;
|
|
232
296
|
}());
|
|
@@ -4,16 +4,19 @@ import { FirmaConfig } from "./FirmaConfig";
|
|
|
4
4
|
import { SignAndBroadcastOptions } from "./firmachain/common";
|
|
5
5
|
import { LedgerWalletInterface } from "./firmachain/common/LedgerWallet";
|
|
6
6
|
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
7
|
+
import { Secp256k1Wallet } from "@cosmjs/amino";
|
|
7
8
|
export declare class FirmaWalletService {
|
|
8
9
|
private readonly config;
|
|
9
10
|
private mnemonic;
|
|
10
11
|
private privateKey;
|
|
11
12
|
private accountIndex;
|
|
13
|
+
private aminoWallet;
|
|
12
14
|
private wallet;
|
|
13
15
|
private ledger;
|
|
14
16
|
getHdPath(): string;
|
|
15
17
|
getPrefix(): string;
|
|
16
18
|
getRawWallet(): DirectSecp256k1Wallet;
|
|
19
|
+
getRawAminoWallet(): Secp256k1Wallet;
|
|
17
20
|
getPrivateKey(): string;
|
|
18
21
|
getMnemonic(): string;
|
|
19
22
|
isLedger(): boolean;
|
|
@@ -41,6 +41,7 @@ var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
|
41
41
|
var crypto_1 = require("@cosmjs/crypto");
|
|
42
42
|
var FirmaUtil_1 = require("./FirmaUtil");
|
|
43
43
|
var LedgerWallet_1 = require("./firmachain/common/LedgerWallet");
|
|
44
|
+
var amino_1 = require("@cosmjs/amino");
|
|
44
45
|
var CryptoJS = require("crypto-js");
|
|
45
46
|
var FirmaWalletService = /** @class */ (function () {
|
|
46
47
|
function FirmaWalletService(config) {
|
|
@@ -58,6 +59,9 @@ var FirmaWalletService = /** @class */ (function () {
|
|
|
58
59
|
FirmaWalletService.prototype.getRawWallet = function () {
|
|
59
60
|
return this.wallet;
|
|
60
61
|
};
|
|
62
|
+
FirmaWalletService.prototype.getRawAminoWallet = function () {
|
|
63
|
+
return this.aminoWallet;
|
|
64
|
+
};
|
|
61
65
|
FirmaWalletService.prototype.getPrivateKey = function () {
|
|
62
66
|
return this.privateKey;
|
|
63
67
|
};
|
|
@@ -163,7 +167,7 @@ var FirmaWalletService = /** @class */ (function () {
|
|
|
163
167
|
return [4 /*yield*/, crypto_1.Bip39.mnemonicToSeed(mnemonicChecked)];
|
|
164
168
|
case 1:
|
|
165
169
|
seed = _a.sent();
|
|
166
|
-
hdpath = FirmaWalletService.getHdPath(this.getHdPath(),
|
|
170
|
+
hdpath = FirmaWalletService.getHdPath(this.getHdPath(), accountIndex);
|
|
167
171
|
privkey = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, seed, hdpath[0]).privkey;
|
|
168
172
|
privateKey = "0x" + Buffer.from(privkey).toString("hex");
|
|
169
173
|
return [2 /*return*/, privateKey];
|
|
@@ -178,23 +182,27 @@ var FirmaWalletService = /** @class */ (function () {
|
|
|
178
182
|
};
|
|
179
183
|
FirmaWalletService.prototype.initFromPrivateKey = function (privateKey) {
|
|
180
184
|
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
-
var tempPrivateKey, _a, error_4;
|
|
182
|
-
return __generator(this, function (
|
|
183
|
-
switch (
|
|
185
|
+
var tempPrivateKey, _a, _b, error_4;
|
|
186
|
+
return __generator(this, function (_c) {
|
|
187
|
+
switch (_c.label) {
|
|
184
188
|
case 0:
|
|
185
|
-
|
|
189
|
+
_c.trys.push([0, 3, , 4]);
|
|
186
190
|
tempPrivateKey = Buffer.from(privateKey.replace("0x", ""), "hex");
|
|
187
191
|
_a = this;
|
|
188
192
|
return [4 /*yield*/, proto_signing_1.DirectSecp256k1Wallet.fromKey(tempPrivateKey, this.getPrefix())];
|
|
189
193
|
case 1:
|
|
190
|
-
_a.wallet =
|
|
191
|
-
|
|
192
|
-
return [
|
|
194
|
+
_a.wallet = _c.sent();
|
|
195
|
+
_b = this;
|
|
196
|
+
return [4 /*yield*/, amino_1.Secp256k1Wallet.fromKey(tempPrivateKey, this.getPrefix())];
|
|
193
197
|
case 2:
|
|
194
|
-
|
|
198
|
+
_b.aminoWallet = _c.sent();
|
|
199
|
+
this.privateKey = privateKey;
|
|
200
|
+
return [3 /*break*/, 4];
|
|
201
|
+
case 3:
|
|
202
|
+
error_4 = _c.sent();
|
|
195
203
|
FirmaUtil_1.FirmaUtil.printLog(error_4);
|
|
196
204
|
throw error_4;
|
|
197
|
-
case
|
|
205
|
+
case 4: return [2 /*return*/];
|
|
198
206
|
}
|
|
199
207
|
});
|
|
200
208
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { StdSignature } from "
|
|
2
|
-
import { StdSignDoc } from "./signdoc";
|
|
1
|
+
import { StdSignature, StdSignDoc } from "@cosmjs/amino";
|
|
3
2
|
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
|
|
4
3
|
export interface AccountData {
|
|
5
4
|
/** A printable address (typically bech32 encoded) */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
2
|
+
import { Pagination } from ".";
|
|
2
3
|
import { AuthorizationType } from "./AuthzTxTypes";
|
|
3
4
|
export interface GrantSendData {
|
|
4
5
|
authorization: authorization_send;
|
|
@@ -32,7 +33,16 @@ export interface allowList {
|
|
|
32
33
|
export declare class AuthzQueryClient {
|
|
33
34
|
private readonly axios;
|
|
34
35
|
constructor(baseUrl: string);
|
|
35
|
-
getSendGrantData(granterAddress: string, granteeAddress: string): Promise<
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
getSendGrantData(granterAddress: string, granteeAddress: string, paginationKey?: string): Promise<{
|
|
37
|
+
dataList: GrantSendData[];
|
|
38
|
+
pagination: Pagination;
|
|
39
|
+
}>;
|
|
40
|
+
getGenericGrantData(granterAddress: string, granteeAddress: string, msgType: string, paginationKey?: string): Promise<{
|
|
41
|
+
dataList: GrantGenericData[];
|
|
42
|
+
pagination: Pagination;
|
|
43
|
+
}>;
|
|
44
|
+
getStakingGrantData(granterAddress: string, granteeAddress: string, type: AuthorizationType, paginationKey?: string): Promise<{
|
|
45
|
+
dataList: GrantStakingData[];
|
|
46
|
+
pagination: Pagination;
|
|
47
|
+
}>;
|
|
38
48
|
}
|