@firmachain/firma-js 0.2.37 → 0.2.40

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.
Files changed (181) hide show
  1. package/dist/index.d.ts +16 -0
  2. package/dist/index.js +32 -0
  3. package/dist/sdk/FirmaAuthzService.d.ts +41 -0
  4. package/dist/sdk/FirmaAuthzService.js +633 -0
  5. package/dist/sdk/FirmaBankService.d.ts +17 -0
  6. package/dist/sdk/FirmaBankService.js +236 -0
  7. package/dist/sdk/FirmaChainService.d.ts +8 -0
  8. package/dist/sdk/FirmaChainService.js +86 -0
  9. package/dist/sdk/FirmaConfig.d.ts +18 -0
  10. package/dist/sdk/FirmaConfig.js +63 -0
  11. package/dist/sdk/FirmaContractService.d.ts +32 -0
  12. package/dist/sdk/FirmaContractService.js +434 -0
  13. package/dist/sdk/FirmaCosmWasmService.d.ts +38 -0
  14. package/dist/sdk/FirmaCosmWasmService.js +667 -0
  15. package/dist/sdk/FirmaDistributionService.d.ts +32 -0
  16. package/dist/sdk/FirmaDistributionService.js +527 -0
  17. package/dist/sdk/FirmaFeeGrantService.d.ts +21 -0
  18. package/dist/sdk/FirmaFeeGrantService.js +341 -0
  19. package/dist/sdk/FirmaGovService.d.ts +35 -0
  20. package/dist/sdk/FirmaGovService.js +775 -0
  21. package/dist/sdk/FirmaIbcService.d.ts +15 -0
  22. package/dist/sdk/FirmaIbcService.js +144 -0
  23. package/dist/sdk/FirmaIpfsService.d.ts +10 -0
  24. package/dist/sdk/FirmaIpfsService.js +143 -0
  25. package/dist/sdk/FirmaMobileSDK.d.ts +29 -0
  26. package/dist/sdk/FirmaMobileSDK.js +48 -0
  27. package/dist/sdk/FirmaNftService.d.ts +31 -0
  28. package/dist/sdk/FirmaNftService.js +372 -0
  29. package/dist/sdk/FirmaSDK.d.ts +35 -0
  30. package/dist/sdk/FirmaSDK.js +57 -0
  31. package/dist/sdk/FirmaSlashingService.d.ts +9 -0
  32. package/dist/sdk/FirmaSlashingService.js +105 -0
  33. package/dist/sdk/FirmaStakingService.d.ts +47 -0
  34. package/dist/sdk/FirmaStakingService.js +611 -0
  35. package/dist/sdk/FirmaTokenService.d.ts +26 -0
  36. package/dist/sdk/FirmaTokenService.js +416 -0
  37. package/dist/sdk/FirmaUtil.d.ts +56 -0
  38. package/dist/sdk/FirmaUtil.js +430 -0
  39. package/dist/sdk/FirmaWalletService.d.ts +39 -0
  40. package/dist/sdk/FirmaWalletService.js +317 -0
  41. package/dist/sdk/firmachain/amino/addresses.d.ts +5 -0
  42. package/dist/sdk/firmachain/amino/addresses.js +46 -0
  43. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +281 -0
  44. package/dist/sdk/firmachain/amino/aminomsgs.js +77 -0
  45. package/dist/sdk/firmachain/amino/aminotypes.d.ts +22 -0
  46. package/dist/sdk/firmachain/amino/aminotypes.js +525 -0
  47. package/dist/sdk/firmachain/amino/coins.d.ts +30 -0
  48. package/dist/sdk/firmachain/amino/coins.js +69 -0
  49. package/dist/sdk/firmachain/amino/encoding.d.ts +24 -0
  50. package/dist/sdk/firmachain/amino/encoding.js +238 -0
  51. package/dist/sdk/firmachain/amino/multisig.d.ts +10 -0
  52. package/dist/sdk/firmachain/amino/multisig.js +42 -0
  53. package/dist/sdk/firmachain/amino/paths.d.ts +6 -0
  54. package/dist/sdk/firmachain/amino/paths.js +18 -0
  55. package/dist/sdk/firmachain/amino/pubkeys.d.ts +47 -0
  56. package/dist/sdk/firmachain/amino/pubkeys.js +29 -0
  57. package/dist/sdk/firmachain/amino/signature.d.ts +16 -0
  58. package/dist/sdk/firmachain/amino/signature.js +36 -0
  59. package/dist/sdk/firmachain/amino/signdoc.d.ts +26 -0
  60. package/dist/sdk/firmachain/amino/signdoc.js +42 -0
  61. package/dist/sdk/firmachain/amino/signer.d.ts +32 -0
  62. package/dist/sdk/firmachain/amino/signer.js +2 -0
  63. package/dist/sdk/firmachain/amino/stdtx.d.ts +15 -0
  64. package/dist/sdk/firmachain/amino/stdtx.js +17 -0
  65. package/dist/sdk/firmachain/amino/wallet.d.ts +32 -0
  66. package/dist/sdk/firmachain/amino/wallet.js +136 -0
  67. package/dist/sdk/firmachain/authz/AuthzQueryClient.d.ts +48 -0
  68. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +142 -0
  69. package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +23 -0
  70. package/dist/sdk/firmachain/authz/AuthzTxClient.js +47 -0
  71. package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +147 -0
  72. package/dist/sdk/firmachain/authz/AuthzTxTypes.js +358 -0
  73. package/dist/sdk/firmachain/authz/index.d.ts +4 -0
  74. package/dist/sdk/firmachain/authz/index.js +20 -0
  75. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +12 -0
  76. package/dist/sdk/firmachain/bank/BankQueryClient.js +116 -0
  77. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +18 -0
  78. package/dist/sdk/firmachain/bank/BankTxClient.js +43 -0
  79. package/dist/sdk/firmachain/bank/index.d.ts +3 -0
  80. package/dist/sdk/firmachain/bank/index.js +19 -0
  81. package/dist/sdk/firmachain/common/CommonTxClient.d.ts +7 -0
  82. package/dist/sdk/firmachain/common/CommonTxClient.js +79 -0
  83. package/dist/sdk/firmachain/common/ITxClient.d.ts +18 -0
  84. package/dist/sdk/firmachain/common/ITxClient.js +117 -0
  85. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +27 -0
  86. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +165 -0
  87. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +14 -0
  88. package/dist/sdk/firmachain/common/LedgerWallet.js +151 -0
  89. package/dist/sdk/firmachain/common/QueryCommon.d.ts +4 -0
  90. package/dist/sdk/firmachain/common/QueryCommon.js +2 -0
  91. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +42 -0
  92. package/dist/sdk/firmachain/common/TendermintQueryClient.js +111 -0
  93. package/dist/sdk/firmachain/common/TxCommon.d.ts +87 -0
  94. package/dist/sdk/firmachain/common/TxCommon.js +18 -0
  95. package/dist/sdk/firmachain/common/accounts.d.ts +16 -0
  96. package/dist/sdk/firmachain/common/accounts.js +64 -0
  97. package/dist/sdk/firmachain/common/index.d.ts +2 -0
  98. package/dist/sdk/firmachain/common/index.js +18 -0
  99. package/dist/sdk/firmachain/common/signing.d.ts +10 -0
  100. package/dist/sdk/firmachain/common/signing.js +79 -0
  101. package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +50 -0
  102. package/dist/sdk/firmachain/common/signingaminostargateclient.js +267 -0
  103. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +44 -0
  104. package/dist/sdk/firmachain/common/signingstargateclient.js +361 -0
  105. package/dist/sdk/firmachain/common/stargateclient.d.ts +46 -0
  106. package/dist/sdk/firmachain/common/stargateclient.js +211 -0
  107. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +32 -0
  108. package/dist/sdk/firmachain/contract/ContractQueryClient.js +156 -0
  109. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +18 -0
  110. package/dist/sdk/firmachain/contract/ContractTxClient.js +43 -0
  111. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +69 -0
  112. package/dist/sdk/firmachain/contract/ContractTxTypes.js +483 -0
  113. package/dist/sdk/firmachain/contract/index.d.ts +3 -0
  114. package/dist/sdk/firmachain/contract/index.js +19 -0
  115. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.d.ts +52 -0
  116. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +193 -0
  117. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +38 -0
  118. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +59 -0
  119. package/dist/sdk/firmachain/cosmwasm/index.d.ts +3 -0
  120. package/dist/sdk/firmachain/cosmwasm/index.js +19 -0
  121. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +18 -0
  122. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +167 -0
  123. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +28 -0
  124. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +51 -0
  125. package/dist/sdk/firmachain/distribution/index.d.ts +3 -0
  126. package/dist/sdk/firmachain/distribution/index.js +19 -0
  127. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +17 -0
  128. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +86 -0
  129. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +18 -0
  130. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +43 -0
  131. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +76 -0
  132. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +194 -0
  133. package/dist/sdk/firmachain/feegrant/index.d.ts +3 -0
  134. package/dist/sdk/firmachain/feegrant/index.js +19 -0
  135. package/dist/sdk/firmachain/google/protobuf/any.d.ts +128 -0
  136. package/dist/sdk/firmachain/google/protobuf/any.js +106 -0
  137. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +996 -0
  138. package/dist/sdk/firmachain/google/protobuf/descriptor.js +5329 -0
  139. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +91 -0
  140. package/dist/sdk/firmachain/google/protobuf/duration.js +107 -0
  141. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +109 -0
  142. package/dist/sdk/firmachain/google/protobuf/timestamp.js +107 -0
  143. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +61 -0
  144. package/dist/sdk/firmachain/gov/GovQueryClient.js +152 -0
  145. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +23 -0
  146. package/dist/sdk/firmachain/gov/GovTxClient.js +47 -0
  147. package/dist/sdk/firmachain/gov/index.d.ts +3 -0
  148. package/dist/sdk/firmachain/gov/index.js +19 -0
  149. package/dist/sdk/firmachain/ibc/IbcQueryClient.d.ts +34 -0
  150. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +71 -0
  151. package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +13 -0
  152. package/dist/sdk/firmachain/ibc/IbcTxClient.js +39 -0
  153. package/dist/sdk/firmachain/ibc/index.d.ts +3 -0
  154. package/dist/sdk/firmachain/ibc/index.js +19 -0
  155. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +20 -0
  156. package/dist/sdk/firmachain/nft/NftQueryClient.js +125 -0
  157. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +23 -0
  158. package/dist/sdk/firmachain/nft/NftTxClient.js +47 -0
  159. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +86 -0
  160. package/dist/sdk/firmachain/nft/NftTxTypes.js +424 -0
  161. package/dist/sdk/firmachain/nft/index.d.ts +3 -0
  162. package/dist/sdk/firmachain/nft/index.js +19 -0
  163. package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +22 -0
  164. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +101 -0
  165. package/dist/sdk/firmachain/slashing/index.d.ts +2 -0
  166. package/dist/sdk/firmachain/slashing/index.js +18 -0
  167. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +106 -0
  168. package/dist/sdk/firmachain/staking/StakingQueryClient.js +243 -0
  169. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +33 -0
  170. package/dist/sdk/firmachain/staking/StakingTxClient.js +55 -0
  171. package/dist/sdk/firmachain/staking/index.d.ts +3 -0
  172. package/dist/sdk/firmachain/staking/index.js +19 -0
  173. package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +24 -0
  174. package/dist/sdk/firmachain/token/TokenQueryClient.js +106 -0
  175. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +28 -0
  176. package/dist/sdk/firmachain/token/TokenTxClient.js +51 -0
  177. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +116 -0
  178. package/dist/sdk/firmachain/token/TokenTxTypes.js +685 -0
  179. package/dist/sdk/firmachain/token/index.d.ts +3 -0
  180. package/dist/sdk/firmachain/token/index.js +19 -0
  181. package/package.json +3 -7
@@ -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 address, message, ibcTxClient, error_3;
98
+ return __generator(this, function (_a) {
99
+ switch (_a.label) {
100
+ case 0:
101
+ _a.trys.push([0, 3, , 4]);
102
+ return [4 /*yield*/, wallet.getAddress()];
103
+ case 1:
104
+ address = _a.sent();
105
+ message = ibc_1.IbcTxClient.msgTransfer({ sourcePort: sourcePort, sourceChannel: sourceChannel, sender: address, receiver: receiver,
106
+ token: { denom: denom, amount: amount },
107
+ timeoutHeight: timeoutHeight, timeoutTimestamp: timeoutTimestamp });
108
+ ibcTxClient = new ibc_1.IbcTxClient(wallet, this.config.rpcAddress);
109
+ return [4 /*yield*/, ibcTxClient.sign([message], (0, 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;
@@ -0,0 +1,10 @@
1
+ import { FirmaConfig } from "./FirmaConfig";
2
+ export declare class IpfsService {
3
+ private readonly config;
4
+ constructor(config: FirmaConfig);
5
+ private getBasePostUrl;
6
+ addJson(jsonData: string): Promise<string>;
7
+ addBuffer(buffer: ArrayBuffer): Promise<string>;
8
+ addFile(fileUrl: string): Promise<string>;
9
+ getURLFromHash(hash: string): string;
10
+ }
@@ -0,0 +1,143 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.IpfsService = void 0;
43
+ var fs_1 = __importDefault(require("fs"));
44
+ var FirmaUtil_1 = require("./FirmaUtil");
45
+ var axios_1 = __importDefault(require("axios"));
46
+ var IpfsService = /** @class */ (function () {
47
+ function IpfsService(config) {
48
+ this.config = config;
49
+ }
50
+ IpfsService.prototype.getBasePostUrl = function () {
51
+ return this.config.ipfsNodeAddress + ":" + this.config.ipfsNodePort + "/api/v0/add";
52
+ };
53
+ IpfsService.prototype.addJson = function (jsonData) {
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ var FormData_1, bodyData, response, error_1;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ _a.trys.push([0, 2, , 3]);
60
+ FormData_1 = require('form-data');
61
+ bodyData = new FormData_1();
62
+ bodyData.append('json', jsonData);
63
+ return [4 /*yield*/, axios_1.default.request({
64
+ url: this.getBasePostUrl(),
65
+ method: 'POST',
66
+ headers: bodyData.getHeaders(),
67
+ data: bodyData
68
+ })];
69
+ case 1:
70
+ response = _a.sent();
71
+ return [2 /*return*/, response.data.Hash];
72
+ case 2:
73
+ error_1 = _a.sent();
74
+ FirmaUtil_1.FirmaUtil.printLog(error_1);
75
+ throw error_1;
76
+ case 3: return [2 /*return*/];
77
+ }
78
+ });
79
+ });
80
+ };
81
+ IpfsService.prototype.addBuffer = function (buffer) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var FormData_2, bodyData, response, error_2;
84
+ return __generator(this, function (_a) {
85
+ switch (_a.label) {
86
+ case 0:
87
+ _a.trys.push([0, 2, , 3]);
88
+ FormData_2 = require('form-data');
89
+ bodyData = new FormData_2();
90
+ bodyData.append('buffer', Buffer.from(buffer));
91
+ return [4 /*yield*/, axios_1.default.request({
92
+ url: this.getBasePostUrl(),
93
+ method: 'POST',
94
+ headers: bodyData.getHeaders(),
95
+ data: bodyData
96
+ })];
97
+ case 1:
98
+ response = _a.sent();
99
+ return [2 /*return*/, response.data.Hash];
100
+ case 2:
101
+ error_2 = _a.sent();
102
+ FirmaUtil_1.FirmaUtil.printLog(error_2);
103
+ throw error_2;
104
+ case 3: return [2 /*return*/];
105
+ }
106
+ });
107
+ });
108
+ };
109
+ IpfsService.prototype.addFile = function (fileUrl) {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var FormData_3, bodyData, fileBuffer, response, error_3;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0:
115
+ _a.trys.push([0, 2, , 3]);
116
+ FormData_3 = require('form-data');
117
+ bodyData = new FormData_3();
118
+ fileBuffer = fs_1.default.readFileSync(fileUrl);
119
+ bodyData.append('file', fileBuffer);
120
+ return [4 /*yield*/, axios_1.default.request({
121
+ url: this.getBasePostUrl(),
122
+ method: 'POST',
123
+ headers: bodyData.getHeaders(),
124
+ data: bodyData
125
+ })];
126
+ case 1:
127
+ response = _a.sent();
128
+ return [2 /*return*/, response.data.Hash];
129
+ case 2:
130
+ error_3 = _a.sent();
131
+ FirmaUtil_1.FirmaUtil.printLog(error_3);
132
+ throw error_3;
133
+ case 3: return [2 /*return*/];
134
+ }
135
+ });
136
+ });
137
+ };
138
+ IpfsService.prototype.getURLFromHash = function (hash) {
139
+ return this.config.ipfsWebApiAddress + "/ipfs/" + hash;
140
+ };
141
+ return IpfsService;
142
+ }());
143
+ exports.IpfsService = IpfsService;
@@ -0,0 +1,29 @@
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
+ import { FirmaAuthzService } from "./FirmaAuthzService";
14
+ export declare class FirmaMobileSDK {
15
+ Config: FirmaConfig;
16
+ Wallet: FirmaWalletService;
17
+ Bank: FirmaBankService;
18
+ FeeGrant: FirmaFeeGrantService;
19
+ Staking: FirmaStakingService;
20
+ Distribution: FirmaDistributionService;
21
+ Gov: FirmaGovService;
22
+ Nft: NftService;
23
+ Token: TokenService;
24
+ Contract: ContractService;
25
+ BlockChain: ChainService;
26
+ Slashing: SlashingService;
27
+ Authz: FirmaAuthzService;
28
+ 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, Authz?: FirmaAuthzService);
29
+ }
@@ -0,0 +1,48 @@
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 FirmaAuthzService_1 = require("./FirmaAuthzService");
17
+ var FirmaMobileSDK = /** @class */ (function () {
18
+ function FirmaMobileSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, BlockChain, Slashing, Authz) {
19
+ if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
20
+ if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
21
+ if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
22
+ if (Staking === void 0) { Staking = new FirmaStakingService_1.FirmaStakingService(Config); }
23
+ if (Distribution === void 0) { Distribution = new FirmaDistributionService_1.FirmaDistributionService(Config); }
24
+ if (Gov === void 0) { Gov = new FirmaGovService_1.FirmaGovService(Config); }
25
+ if (Nft === void 0) { Nft = new FirmaNftService_1.NftService(Config); }
26
+ if (Token === void 0) { Token = new FirmaTokenService_1.TokenService(Config); }
27
+ if (Contract === void 0) { Contract = new FirmaContractService_1.ContractService(Config); }
28
+ if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
29
+ if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
30
+ if (Authz === void 0) { Authz = new FirmaAuthzService_1.FirmaAuthzService(Config); }
31
+ this.Config = Config;
32
+ this.Wallet = Wallet;
33
+ this.Bank = Bank;
34
+ this.FeeGrant = FeeGrant;
35
+ this.Staking = Staking;
36
+ this.Distribution = Distribution;
37
+ this.Gov = Gov;
38
+ this.Nft = Nft;
39
+ this.Token = Token;
40
+ this.Contract = Contract;
41
+ this.BlockChain = BlockChain;
42
+ this.Slashing = Slashing;
43
+ this.Authz = Authz;
44
+ FirmaUtil_1.FirmaUtil.config = Config;
45
+ }
46
+ return FirmaMobileSDK;
47
+ }());
48
+ exports.FirmaMobileSDK = FirmaMobileSDK;
@@ -0,0 +1,31 @@
1
+ import { NftItemType, Pagination, TxMisc } from "./firmachain/nft";
2
+ import { FirmaConfig } from "./FirmaConfig";
3
+ import { FirmaWalletService } from "./FirmaWalletService";
4
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
5
+ export declare class NftService {
6
+ private readonly config;
7
+ constructor(config: FirmaConfig);
8
+ getNftItemAll(paginationKey?: string): Promise<{
9
+ dataList: NftItemType[];
10
+ pagination: Pagination;
11
+ }>;
12
+ getNftItem(nftId: string): Promise<NftItemType>;
13
+ getNftItemAllFromAddress(ownerAddress: string, paginationKey?: string): Promise<{
14
+ dataList: NftItemType[];
15
+ pagination: Pagination;
16
+ }>;
17
+ getNftIdListOfOwner(ownerAddress: string, paginationKey?: string): Promise<{
18
+ nftIdList: string[];
19
+ pagination: Pagination;
20
+ }>;
21
+ getBalanceOf(ownerAddress: string): Promise<number>;
22
+ getGasEstimationTransfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<number>;
23
+ private getSignedTxTransfer;
24
+ transfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
25
+ getGasEstimationBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<number>;
26
+ private getSignedTxBurn;
27
+ burn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
28
+ getGasEstimationMint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<number>;
29
+ private getSignedTxMint;
30
+ mint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
31
+ }