@firmachain/firma-js 0.2.46 → 0.2.48

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 (132) hide show
  1. package/dist/index.js +1 -5
  2. package/dist/sdk/FirmaAuthzService.js +5 -5
  3. package/dist/sdk/FirmaBankService.js +1 -1
  4. package/dist/sdk/FirmaChainService.d.ts +5 -0
  5. package/dist/sdk/FirmaChainService.js +44 -0
  6. package/dist/sdk/FirmaContractService.js +5 -5
  7. package/dist/sdk/FirmaCosmWasmCw20.d.ts +17 -0
  8. package/dist/sdk/FirmaCosmWasmCw20.js +269 -0
  9. package/dist/sdk/FirmaCosmWasmService.js +9 -9
  10. package/dist/sdk/FirmaDistributionService.js +5 -5
  11. package/dist/sdk/FirmaFeeGrantService.js +3 -3
  12. package/dist/sdk/FirmaGovService.js +7 -7
  13. package/dist/sdk/FirmaIbcService.js +1 -1
  14. package/dist/sdk/FirmaNftService.js +5 -5
  15. package/dist/sdk/FirmaSDK.d.ts +3 -1
  16. package/dist/sdk/FirmaSDK.js +4 -1
  17. package/dist/sdk/FirmaStakingService.js +5 -5
  18. package/dist/sdk/FirmaTokenService.js +4 -4
  19. package/dist/sdk/FirmaUtil.js +16 -20
  20. package/dist/sdk/FirmaWalletService.js +3 -3
  21. package/dist/sdk/firmachain/amino/addresses.js +11 -11
  22. package/dist/sdk/firmachain/amino/aminotypes.js +32 -36
  23. package/dist/sdk/firmachain/amino/encoding.js +26 -30
  24. package/dist/sdk/firmachain/amino/multisig.js +5 -5
  25. package/dist/sdk/firmachain/amino/signature.js +4 -4
  26. package/dist/sdk/firmachain/amino/signdoc.js +1 -1
  27. package/dist/sdk/firmachain/amino/wallet.js +10 -14
  28. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +3 -3
  29. package/dist/sdk/firmachain/authz/index.js +1 -5
  30. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  31. package/dist/sdk/firmachain/bank/index.js +1 -5
  32. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
  33. package/dist/sdk/firmachain/common/LedgerWallet.js +10 -14
  34. package/dist/sdk/firmachain/common/accounts.js +2 -2
  35. package/dist/sdk/firmachain/common/index.js +1 -5
  36. package/dist/sdk/firmachain/common/signing.js +5 -9
  37. package/dist/sdk/firmachain/common/signingaminostargateclient.js +16 -16
  38. package/dist/sdk/firmachain/common/signingstargateclient.js +14 -18
  39. package/dist/sdk/firmachain/common/stargateclient.js +6 -6
  40. package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
  41. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
  42. package/dist/sdk/firmachain/contract/index.js +1 -5
  43. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +8 -8
  44. package/dist/sdk/firmachain/cosmwasm/index.js +1 -5
  45. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
  46. package/dist/sdk/firmachain/distribution/index.js +1 -5
  47. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
  48. package/dist/sdk/firmachain/feegrant/index.js +1 -5
  49. package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
  50. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
  51. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
  52. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
  53. package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
  54. package/dist/sdk/firmachain/gov/index.js +1 -5
  55. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +1 -1
  56. package/dist/sdk/firmachain/ibc/index.js +1 -5
  57. package/dist/sdk/firmachain/mint/index.js +1 -5
  58. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
  59. package/dist/sdk/firmachain/nft/index.js +1 -5
  60. package/dist/sdk/firmachain/slashing/index.js +1 -5
  61. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +2 -2
  62. package/dist/sdk/firmachain/staking/StakingQueryClient.js +8 -8
  63. package/dist/sdk/firmachain/staking/index.js +1 -5
  64. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
  65. package/dist/sdk/firmachain/token/index.js +1 -5
  66. package/package.json +24 -24
  67. package/dist/test/00.wallet.test.d.ts +0 -1
  68. package/dist/test/00.wallet.test.js +0 -87
  69. package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.d.ts +0 -1
  70. package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.js +0 -302
  71. package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.d.ts +0 -1
  72. package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.js +0 -436
  73. package/dist/test/01.contract_tx.test.d.ts +0 -1
  74. package/dist/test/01.contract_tx.test.js +0 -146
  75. package/dist/test/02.contract_query.test.d.ts +0 -1
  76. package/dist/test/02.contract_query.test.js +0 -219
  77. package/dist/test/03.contract_scenario.test.d.ts +0 -1
  78. package/dist/test/03.contract_scenario.test.js +0 -559
  79. package/dist/test/04.bank_tx.test.d.ts +0 -1
  80. package/dist/test/04.bank_tx.test.js +0 -124
  81. package/dist/test/05.bank_query.test.d.ts +0 -1
  82. package/dist/test/05.bank_query.test.js +0 -164
  83. package/dist/test/06.feegrant_tx.test.d.ts +0 -1
  84. package/dist/test/06.feegrant_tx.test.js +0 -173
  85. package/dist/test/07.feegrant_query.test.d.ts +0 -1
  86. package/dist/test/07.feegrant_query.test.js +0 -81
  87. package/dist/test/08.gas_estimate.test.d.ts +0 -1
  88. package/dist/test/08.gas_estimate.test.js +0 -702
  89. package/dist/test/09.ipfs.test.d.ts +0 -1
  90. package/dist/test/09.ipfs.test.js +0 -69
  91. package/dist/test/10.nft_tx.test.d.ts +0 -1
  92. package/dist/test/10.nft_tx.test.js +0 -137
  93. package/dist/test/11.nft_query.test.d.ts +0 -1
  94. package/dist/test/11.nft_query.test.js +0 -167
  95. package/dist/test/12.staking_tx.test.d.ts +0 -1
  96. package/dist/test/12.staking_tx.test.js +0 -213
  97. package/dist/test/13.staking_query.test.d.ts +0 -1
  98. package/dist/test/13.staking_query.test.js +0 -206
  99. package/dist/test/14.distribution_tx.test.d.ts +0 -1
  100. package/dist/test/14.distribution_tx.test.js +0 -176
  101. package/dist/test/15.distribution_query.test.d.ts +0 -1
  102. package/dist/test/15.distribution_query.test.js +0 -216
  103. package/dist/test/16.gov_tx.test.d.ts +0 -1
  104. package/dist/test/16.gov_tx.test.js +0 -237
  105. package/dist/test/17.gov_query.test.d.ts +0 -1
  106. package/dist/test/17.gov_query.test.js +0 -115
  107. package/dist/test/18.util.test.d.ts +0 -1
  108. package/dist/test/18.util.test.js +0 -246
  109. package/dist/test/19.chain.test.d.ts +0 -1
  110. package/dist/test/19.chain.test.js +0 -67
  111. package/dist/test/20.slashing_query.test.d.ts +0 -1
  112. package/dist/test/20.slashing_query.test.js +0 -82
  113. package/dist/test/21.token_tx.test.d.ts +0 -1
  114. package/dist/test/21.token_tx.test.js +0 -154
  115. package/dist/test/22.token_query.test.d.ts +0 -1
  116. package/dist/test/22.token_query.test.js +0 -96
  117. package/dist/test/23.authz_tx.test.d.ts +0 -1
  118. package/dist/test/23.authz_tx.test.js +0 -468
  119. package/dist/test/24.authz_query.test.d.ts +0 -1
  120. package/dist/test/24.authz_query.test.js +0 -140
  121. package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
  122. package/dist/test/25.cosmwasm_tx.test.js +0 -188
  123. package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
  124. package/dist/test/26.cosmwasm_query.test.js +0 -167
  125. package/dist/test/27.arbitary_sign.test.d.ts +0 -1
  126. package/dist/test/27.arbitary_sign.test.js +0 -164
  127. package/dist/test/28.ibc_tx.test.d.ts +0 -1
  128. package/dist/test/28.ibc_tx.test.js +0 -83
  129. package/dist/test/29.mint_query.copy.d.ts +0 -1
  130. package/dist/test/29.mint_query.copy.js +0 -54
  131. package/dist/test/config_test.d.ts +0 -5
  132. package/dist/test/config_test.js +0 -27
@@ -1,468 +0,0 @@
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
- var chai_1 = require("chai");
40
- var authz_1 = require("../sdk/firmachain/authz");
41
- var bank_1 = require("../sdk/firmachain/bank");
42
- var distribution_1 = require("../sdk/firmachain/distribution");
43
- var staking_1 = require("../sdk/firmachain/staking");
44
- var FirmaSDK_1 = require("../sdk/FirmaSDK");
45
- var FirmaUtil_1 = require("../sdk/FirmaUtil");
46
- var config_test_1 = require("./config_test");
47
- describe('[23. Authz Tx Test]', function () {
48
- var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
49
- // grant type check
50
- // authorization_type="send"|"generic"|"delegate"|"unbond"|"redelegate"
51
- it('Authz Grant Send', function () { return __awaiter(void 0, void 0, void 0, function () {
52
- var aliceWallet, bobAddress, expirationDate, maxFCT, result;
53
- return __generator(this, function (_a) {
54
- switch (_a.label) {
55
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
56
- case 1:
57
- aliceWallet = _a.sent();
58
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
59
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
60
- case 3:
61
- bobAddress = _a.sent();
62
- expirationDate = new Date();
63
- expirationDate.setFullYear(expirationDate.getFullYear() + 1);
64
- maxFCT = 10;
65
- return [4 /*yield*/, firma.Authz.grantSendAuthorization(aliceWallet, bobAddress, expirationDate, maxFCT)];
66
- case 4:
67
- result = _a.sent();
68
- //console.log(result);
69
- (0, chai_1.expect)(result.code).to.be.equal(0);
70
- return [2 /*return*/];
71
- }
72
- });
73
- }); });
74
- it('Authz ExecuteAllowance-Send', function () { return __awaiter(void 0, void 0, void 0, function () {
75
- var aliceWallet, bobWallet, amountFCT, address, toAddress, sendAmount, msgSend, anyData, result;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
79
- case 1:
80
- aliceWallet = _a.sent();
81
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
82
- case 2:
83
- bobWallet = _a.sent();
84
- amountFCT = 9;
85
- return [4 /*yield*/, aliceWallet.getAddress()];
86
- case 3:
87
- address = _a.sent();
88
- return [4 /*yield*/, bobWallet.getAddress()];
89
- case 4:
90
- toAddress = _a.sent();
91
- sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
92
- msgSend = bank_1.BankTxClient.msgSend({
93
- fromAddress: address,
94
- toAddress: toAddress,
95
- amount: [sendAmount]
96
- });
97
- anyData = FirmaUtil_1.FirmaUtil.getAnyData(bank_1.BankTxClient.getRegistry(), msgSend);
98
- return [4 /*yield*/, firma.Authz.executeAllowance(bobWallet, [anyData])];
99
- case 5:
100
- result = _a.sent();
101
- //console.log(result);
102
- (0, chai_1.expect)(result.code).to.be.equal(0);
103
- return [2 /*return*/];
104
- }
105
- });
106
- }); });
107
- it.skip('Authz Revoke Send', function () { return __awaiter(void 0, void 0, void 0, function () {
108
- var aliceWallet, bobAddress, result;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
112
- case 1:
113
- aliceWallet = _a.sent();
114
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
115
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
116
- case 3:
117
- bobAddress = _a.sent();
118
- return [4 /*yield*/, firma.Authz.revokeSendAuthorization(aliceWallet, bobAddress)];
119
- case 4:
120
- result = _a.sent();
121
- //console.log(result);
122
- (0, chai_1.expect)(result.code).to.be.equal(0);
123
- return [2 /*return*/];
124
- }
125
- });
126
- }); });
127
- it('Authz Grant Delegate', function () { return __awaiter(void 0, void 0, void 0, function () {
128
- var aliceWallet, bobAddress, delegationInfo, _a, _b, validatorAddress, expirationDate, maxFCT, result;
129
- return __generator(this, function (_c) {
130
- switch (_c.label) {
131
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
132
- case 1:
133
- aliceWallet = _c.sent();
134
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
135
- case 2: return [4 /*yield*/, (_c.sent()).getAddress()];
136
- case 3:
137
- bobAddress = _c.sent();
138
- _b = (_a = firma.Staking).getTotalDelegationInfo;
139
- return [4 /*yield*/, aliceWallet.getAddress()];
140
- case 4: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
141
- case 5:
142
- delegationInfo = (_c.sent()).dataList;
143
- validatorAddress = delegationInfo[0].delegation.validator_address;
144
- expirationDate = new Date();
145
- expirationDate.setFullYear(expirationDate.getFullYear() + 1);
146
- maxFCT = 100;
147
- return [4 /*yield*/, firma.Authz.grantStakeAuthorization(aliceWallet, bobAddress, [validatorAddress], authz_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE, expirationDate, maxFCT)];
148
- case 6:
149
- result = _c.sent();
150
- // in case of undefine maxFCT
151
- //var result = await firma.Authz.grantStakeAuthorization(wallet, bobAddress, validatorAddress, AuthorizationType.AUTHORIZATION_TYPE_DELEGATE, expirationDate);
152
- //console.log(result);
153
- (0, chai_1.expect)(result.code).to.be.equal(0);
154
- return [2 /*return*/];
155
- }
156
- });
157
- }); });
158
- it('Authz ExecuteAllowance-Delegate', function () { return __awaiter(void 0, void 0, void 0, function () {
159
- var aliceWallet, bobWallet, delegationInfo, _a, _b, validatorAddress, amountFCT, address, sendAmount, msgDelegate, anyData, result;
160
- return __generator(this, function (_c) {
161
- switch (_c.label) {
162
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
163
- case 1:
164
- aliceWallet = _c.sent();
165
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
166
- case 2:
167
- bobWallet = _c.sent();
168
- _b = (_a = firma.Staking).getTotalDelegationInfo;
169
- return [4 /*yield*/, aliceWallet.getAddress()];
170
- case 3: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
171
- case 4:
172
- delegationInfo = (_c.sent()).dataList;
173
- validatorAddress = delegationInfo[0].delegation.validator_address;
174
- amountFCT = 9;
175
- return [4 /*yield*/, aliceWallet.getAddress()];
176
- case 5:
177
- address = _c.sent();
178
- sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
179
- msgDelegate = staking_1.StakingTxClient.msgDelegate({
180
- delegatorAddress: address,
181
- validatorAddress: validatorAddress,
182
- amount: sendAmount
183
- });
184
- anyData = FirmaUtil_1.FirmaUtil.getAnyData(staking_1.StakingTxClient.getRegistry(), msgDelegate);
185
- return [4 /*yield*/, firma.Authz.executeAllowance(bobWallet, [anyData])];
186
- case 6:
187
- result = _c.sent();
188
- //console.log(result);
189
- (0, chai_1.expect)(result.code).to.be.equal(0);
190
- return [2 /*return*/];
191
- }
192
- });
193
- }); });
194
- it.skip('Authz Revoke Delegate', function () { return __awaiter(void 0, void 0, void 0, function () {
195
- var aliceWallet, bobAddress, result;
196
- return __generator(this, function (_a) {
197
- switch (_a.label) {
198
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
199
- case 1:
200
- aliceWallet = _a.sent();
201
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
202
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
203
- case 3:
204
- bobAddress = _a.sent();
205
- return [4 /*yield*/, firma.Authz.revokeStakeAuthorization(aliceWallet, bobAddress, authz_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE)];
206
- case 4:
207
- result = _a.sent();
208
- //console.log(result);
209
- (0, chai_1.expect)(result.code).to.be.equal(0);
210
- return [2 /*return*/];
211
- }
212
- });
213
- }); });
214
- it('Authz Grant UnDelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
215
- var aliceWallet, bobAddress, delegationInfo, _a, _b, validatorAddress, expirationDate, maxFCT, result;
216
- return __generator(this, function (_c) {
217
- switch (_c.label) {
218
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
219
- case 1:
220
- aliceWallet = _c.sent();
221
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
222
- case 2: return [4 /*yield*/, (_c.sent()).getAddress()];
223
- case 3:
224
- bobAddress = _c.sent();
225
- _b = (_a = firma.Staking).getTotalDelegationInfo;
226
- return [4 /*yield*/, aliceWallet.getAddress()];
227
- case 4: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
228
- case 5:
229
- delegationInfo = (_c.sent()).dataList;
230
- validatorAddress = delegationInfo[0].delegation.validator_address;
231
- expirationDate = new Date();
232
- expirationDate.setFullYear(expirationDate.getFullYear() + 1);
233
- maxFCT = 10;
234
- return [4 /*yield*/, firma.Authz.grantStakeAuthorization(aliceWallet, bobAddress, [validatorAddress], authz_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE, expirationDate, maxFCT)];
235
- case 6:
236
- result = _c.sent();
237
- //console.log(result);
238
- (0, chai_1.expect)(result.code).to.be.equal(0);
239
- return [2 /*return*/];
240
- }
241
- });
242
- }); });
243
- it('Authz ExecuteAllowance-Undelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
244
- var aliceWallet, bobWallet, delegationInfo, _a, _b, validatorAddress, amountFCT, address, sendAmount, msgUndelegate, anyData, result;
245
- return __generator(this, function (_c) {
246
- switch (_c.label) {
247
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
248
- case 1:
249
- aliceWallet = _c.sent();
250
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
251
- case 2:
252
- bobWallet = _c.sent();
253
- _b = (_a = firma.Staking).getTotalDelegationInfo;
254
- return [4 /*yield*/, aliceWallet.getAddress()];
255
- case 3: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
256
- case 4:
257
- delegationInfo = (_c.sent()).dataList;
258
- validatorAddress = delegationInfo[0].delegation.validator_address;
259
- amountFCT = 9;
260
- return [4 /*yield*/, aliceWallet.getAddress()];
261
- case 5:
262
- address = _c.sent();
263
- sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
264
- msgUndelegate = staking_1.StakingTxClient.msgUndelegate({
265
- delegatorAddress: address,
266
- validatorAddress: validatorAddress,
267
- amount: sendAmount
268
- });
269
- anyData = FirmaUtil_1.FirmaUtil.getAnyData(staking_1.StakingTxClient.getRegistry(), msgUndelegate);
270
- return [4 /*yield*/, firma.Authz.executeAllowance(bobWallet, [anyData])];
271
- case 6:
272
- result = _c.sent();
273
- //console.log(result);
274
- (0, chai_1.expect)(result.code).to.be.equal(0);
275
- return [2 /*return*/];
276
- }
277
- });
278
- }); });
279
- it.skip('Authz Revoke UnDelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
280
- var aliceWallet, bobAddress, result;
281
- return __generator(this, function (_a) {
282
- switch (_a.label) {
283
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
284
- case 1:
285
- aliceWallet = _a.sent();
286
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
287
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
288
- case 3:
289
- bobAddress = _a.sent();
290
- return [4 /*yield*/, firma.Authz.revokeStakeAuthorization(aliceWallet, bobAddress, authz_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE)];
291
- case 4:
292
- result = _a.sent();
293
- //console.log(result);
294
- (0, chai_1.expect)(result.code).to.be.equal(0);
295
- return [2 /*return*/];
296
- }
297
- });
298
- }); });
299
- it('Authz Grant ReDelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
300
- var aliceWallet, bobAddress, delegationInfo, _a, _b, validatorAddress, expirationDate, maxFCT, result;
301
- return __generator(this, function (_c) {
302
- switch (_c.label) {
303
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
304
- case 1:
305
- aliceWallet = _c.sent();
306
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
307
- case 2: return [4 /*yield*/, (_c.sent()).getAddress()];
308
- case 3:
309
- bobAddress = _c.sent();
310
- _b = (_a = firma.Staking).getTotalDelegationInfo;
311
- return [4 /*yield*/, aliceWallet.getAddress()];
312
- case 4: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
313
- case 5:
314
- delegationInfo = (_c.sent()).dataList;
315
- validatorAddress = delegationInfo[0].delegation.validator_address;
316
- expirationDate = new Date();
317
- expirationDate.setFullYear(expirationDate.getFullYear() + 1);
318
- maxFCT = 10;
319
- return [4 /*yield*/, firma.Authz.grantStakeAuthorization(aliceWallet, bobAddress, [validatorAddress], authz_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE, expirationDate, maxFCT)];
320
- case 6:
321
- result = _c.sent();
322
- //console.log(result);
323
- (0, chai_1.expect)(result.code).to.be.equal(0);
324
- return [2 /*return*/];
325
- }
326
- });
327
- }); });
328
- it.skip('Authz ExecuteAllowance-ReDelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
329
- var aliceWallet, bobWallet, delegationInfo, _a, _b, validatorSrcAddress, validatorDstAddress, amountFCT, address, sendAmount, msgRedelegate, anyData, result;
330
- return __generator(this, function (_c) {
331
- switch (_c.label) {
332
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
333
- case 1:
334
- aliceWallet = _c.sent();
335
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
336
- case 2:
337
- bobWallet = _c.sent();
338
- _b = (_a = firma.Staking).getTotalDelegationInfo;
339
- return [4 /*yield*/, aliceWallet.getAddress()];
340
- case 3: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
341
- case 4:
342
- delegationInfo = (_c.sent()).dataList;
343
- validatorSrcAddress = delegationInfo[0].delegation.validator_address;
344
- validatorDstAddress = validatorSrcAddress;
345
- amountFCT = 9;
346
- return [4 /*yield*/, aliceWallet.getAddress()];
347
- case 5:
348
- address = _c.sent();
349
- sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
350
- msgRedelegate = staking_1.StakingTxClient.msgRedelegate({
351
- delegatorAddress: address,
352
- validatorSrcAddress: validatorSrcAddress,
353
- validatorDstAddress: validatorDstAddress,
354
- amount: sendAmount
355
- });
356
- anyData = FirmaUtil_1.FirmaUtil.getAnyData(staking_1.StakingTxClient.getRegistry(), msgRedelegate);
357
- return [4 /*yield*/, firma.Authz.executeAllowance(bobWallet, [anyData])];
358
- case 6:
359
- result = _c.sent();
360
- //console.log(result);
361
- (0, chai_1.expect)(result.code).to.be.equal(0);
362
- return [2 /*return*/];
363
- }
364
- });
365
- }); });
366
- it.skip('Authz Revoke ReDelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
367
- var aliceWallet, bobAddress, result;
368
- return __generator(this, function (_a) {
369
- switch (_a.label) {
370
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
371
- case 1:
372
- aliceWallet = _a.sent();
373
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
374
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
375
- case 3:
376
- bobAddress = _a.sent();
377
- return [4 /*yield*/, firma.Authz.revokeStakeAuthorization(aliceWallet, bobAddress, authz_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE)];
378
- case 4:
379
- result = _a.sent();
380
- //console.log(result);
381
- (0, chai_1.expect)(result.code).to.be.equal(0);
382
- return [2 /*return*/];
383
- }
384
- });
385
- }); });
386
- // GenericAuthorization: MsgWithdrawDelegatorReward case
387
- it('Authz Grant-GenericAuthorization MsgWithdrawDelegatorReward', function () { return __awaiter(void 0, void 0, void 0, function () {
388
- var aliceWallet, bobAddress, msg, expirationDate, result;
389
- return __generator(this, function (_a) {
390
- switch (_a.label) {
391
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
392
- case 1:
393
- aliceWallet = _a.sent();
394
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
395
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
396
- case 3:
397
- bobAddress = _a.sent();
398
- msg = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
399
- expirationDate = new Date();
400
- expirationDate.setFullYear(expirationDate.getFullYear() + 1);
401
- return [4 /*yield*/, firma.Authz.grantGenericAuthorization(aliceWallet, bobAddress, msg, expirationDate)];
402
- case 4:
403
- result = _a.sent();
404
- //console.log(result);
405
- (0, chai_1.expect)(result.code).to.be.equal(0);
406
- return [2 /*return*/];
407
- }
408
- });
409
- }); });
410
- it('Authz GenericAuthorization ExecuteAllowance-MsgWithdrawDelegatorReward', function () { return __awaiter(void 0, void 0, void 0, function () {
411
- var aliceWallet, bobWallet, delegationInfo, _a, _b, validatorAddress, amountFCT, address, sendAmount, msgWithdrawDelegatorReward, anyData, result;
412
- return __generator(this, function (_c) {
413
- switch (_c.label) {
414
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
415
- case 1:
416
- aliceWallet = _c.sent();
417
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
418
- case 2:
419
- bobWallet = _c.sent();
420
- _b = (_a = firma.Staking).getTotalDelegationInfo;
421
- return [4 /*yield*/, aliceWallet.getAddress()];
422
- case 3: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
423
- case 4:
424
- delegationInfo = (_c.sent()).dataList;
425
- validatorAddress = delegationInfo[0].delegation.validator_address;
426
- amountFCT = 10;
427
- return [4 /*yield*/, aliceWallet.getAddress()];
428
- case 5:
429
- address = _c.sent();
430
- sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
431
- msgWithdrawDelegatorReward = distribution_1.DistributionTxClient.msgWithdrawDelegatorReward({
432
- delegatorAddress: address,
433
- validatorAddress: validatorAddress,
434
- });
435
- anyData = FirmaUtil_1.FirmaUtil.getAnyData(distribution_1.DistributionTxClient.getRegistry(), msgWithdrawDelegatorReward);
436
- return [4 /*yield*/, firma.Authz.executeAllowance(bobWallet, [anyData])];
437
- case 6:
438
- result = _c.sent();
439
- //console.log(result);
440
- (0, chai_1.expect)(result.code).to.be.equal(0);
441
- return [2 /*return*/];
442
- }
443
- });
444
- }); });
445
- it.skip('Authz Revoke-GenericAuthorization MsgWithdrawDelegatorReward', function () { return __awaiter(void 0, void 0, void 0, function () {
446
- var aliceWallet, bobAddress, msgType, result;
447
- return __generator(this, function (_a) {
448
- switch (_a.label) {
449
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
450
- case 1:
451
- aliceWallet = _a.sent();
452
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
453
- case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
454
- case 3:
455
- bobAddress = _a.sent();
456
- msgType = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
457
- return [4 /*yield*/, firma.Authz.revokeGenericAuthorization(aliceWallet, bobAddress, msgType)
458
- //console.log(result);
459
- ];
460
- case 4:
461
- result = _a.sent();
462
- //console.log(result);
463
- (0, chai_1.expect)(result.code).to.be.equal(0);
464
- return [2 /*return*/];
465
- }
466
- });
467
- }); });
468
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,140 +0,0 @@
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
- var AuthzTxTypes_1 = require("../sdk/firmachain/authz/AuthzTxTypes");
40
- var FirmaSDK_1 = require("../sdk/FirmaSDK");
41
- var config_test_1 = require("./config_test");
42
- describe('[24. Authz query Test]', function () {
43
- var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
44
- it('Authz getSendGrantData', function () { return __awaiter(void 0, void 0, void 0, function () {
45
- var granter, grantee, result;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
49
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
50
- case 2:
51
- granter = _a.sent();
52
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
53
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
54
- case 4:
55
- grantee = _a.sent();
56
- return [4 /*yield*/, firma.Authz.getSendGrantData(granter, grantee)];
57
- case 5:
58
- result = _a.sent();
59
- return [2 /*return*/];
60
- }
61
- });
62
- }); });
63
- it('Authz getGenericGrantData', function () { return __awaiter(void 0, void 0, void 0, function () {
64
- var granter, grantee, msg, result;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
68
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
69
- case 2:
70
- granter = _a.sent();
71
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
72
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
73
- case 4:
74
- grantee = _a.sent();
75
- msg = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
76
- return [4 /*yield*/, firma.Authz.getGenericGrantData(granter, grantee, msg)];
77
- case 5:
78
- result = (_a.sent()).dataList;
79
- return [2 /*return*/];
80
- }
81
- });
82
- }); });
83
- it('Authz getStakingGrantData - delegate', function () { return __awaiter(void 0, void 0, void 0, function () {
84
- var granter, grantee, result;
85
- return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
88
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
89
- case 2:
90
- granter = _a.sent();
91
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
92
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
93
- case 4:
94
- grantee = _a.sent();
95
- return [4 /*yield*/, firma.Authz.getStakingGrantData(granter, grantee, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE)];
96
- case 5:
97
- result = (_a.sent()).dataList;
98
- return [2 /*return*/];
99
- }
100
- });
101
- }); });
102
- it('Authz getStakingGrantData - redelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
103
- var granter, grantee, result;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
107
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
108
- case 2:
109
- granter = _a.sent();
110
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
111
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
112
- case 4:
113
- grantee = _a.sent();
114
- return [4 /*yield*/, firma.Authz.getStakingGrantData(granter, grantee, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE)];
115
- case 5:
116
- result = (_a.sent()).dataList;
117
- return [2 /*return*/];
118
- }
119
- });
120
- }); });
121
- it('Authz getStakingGrantData - undelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
122
- var granter, grantee, result;
123
- return __generator(this, function (_a) {
124
- switch (_a.label) {
125
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
126
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
127
- case 2:
128
- granter = _a.sent();
129
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
130
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
131
- case 4:
132
- grantee = _a.sent();
133
- return [4 /*yield*/, firma.Authz.getStakingGrantData(granter, grantee, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE)];
134
- case 5:
135
- result = (_a.sent()).dataList;
136
- return [2 /*return*/];
137
- }
138
- });
139
- }); });
140
- });
@@ -1 +0,0 @@
1
- export {};