@firmachain/firma-js 0.3.8 → 0.4.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sdk/FirmaAuthzService.js +20 -15
- package/dist/sdk/FirmaBankService.d.ts +1 -1
- package/dist/sdk/FirmaBankService.js +5 -4
- package/dist/sdk/FirmaConfig.js +4 -4
- package/dist/sdk/FirmaContractService.js +10 -8
- package/dist/sdk/FirmaDistributionService.js +20 -15
- package/dist/sdk/FirmaFeeGrantService.d.ts +0 -1
- package/dist/sdk/FirmaFeeGrantService.js +12 -14
- package/dist/sdk/FirmaGovService.d.ts +14 -0
- package/dist/sdk/FirmaGovService.js +58 -37
- package/dist/sdk/FirmaIbcService.js +4 -3
- package/dist/sdk/FirmaNftService.d.ts +3 -3
- package/dist/sdk/FirmaNftService.js +13 -10
- package/dist/sdk/FirmaStakingService.js +12 -9
- package/dist/sdk/FirmaTokenService.js +17 -14
- package/dist/sdk/FirmaUtil.js +1 -1
- package/dist/sdk/FirmaWalletService.d.ts +1 -1
- package/dist/sdk/FirmaWalletService.js +11 -23
- package/dist/sdk/firmachain/authz/AuthzTxClient.js +2 -0
- package/dist/sdk/firmachain/bank/BankTxClient.js +1 -1
- package/dist/sdk/firmachain/common/CommonTxClient.js +3 -1
- package/dist/sdk/firmachain/common/FirmaLedger.d.ts +49 -0
- package/dist/sdk/firmachain/common/FirmaLedger.js +301 -0
- package/dist/sdk/firmachain/common/ITxClient.d.ts +1 -1
- package/dist/sdk/firmachain/common/ITxClient.js +6 -4
- package/dist/sdk/firmachain/common/LedgerWallet.d.ts +5 -13
- package/dist/sdk/firmachain/common/LedgerWallet.js +1266 -124
- package/dist/sdk/firmachain/common/SigningProtobufStargateClient.js +3 -4
- package/dist/sdk/firmachain/common/SigningStargateClient.d.ts +2 -3
- package/dist/sdk/firmachain/common/SigningStargateClient.js +7 -10
- package/dist/sdk/firmachain/common/index.d.ts +1 -0
- package/dist/sdk/firmachain/common/index.js +1 -0
- package/dist/sdk/firmachain/common/signing.d.ts +4 -10
- package/dist/sdk/firmachain/common/signing.js +13 -60
- package/dist/sdk/firmachain/contract/ContractTxClient.js +1 -1
- package/dist/sdk/firmachain/contract/ContractTxTypes.js +54 -8
- package/dist/sdk/firmachain/distribution/DistributionTxClient.js +1 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +3 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +1 -2
- package/dist/sdk/firmachain/google/protobuf/any.js +0 -12
- package/dist/sdk/firmachain/gov/GovTxClient.js +3 -0
- package/dist/sdk/firmachain/nft/NftTxClient.js +1 -1
- package/dist/sdk/firmachain/token/TokenTxClient.js +1 -1
- package/package.json +16 -8
- package/dist/test/00.wallet.test.d.ts +0 -1
- package/dist/test/00.wallet.test.js +0 -96
- package/dist/test/01.contract_tx.test.d.ts +0 -1
- package/dist/test/01.contract_tx.test.js +0 -157
- package/dist/test/02.contract_query.test.d.ts +0 -1
- package/dist/test/02.contract_query.test.js +0 -245
- package/dist/test/03.contract_scenario.test.d.ts +0 -1
- package/dist/test/03.contract_scenario.test.js +0 -406
- package/dist/test/04.bank_tx.test.d.ts +0 -1
- package/dist/test/04.bank_tx.test.js +0 -126
- package/dist/test/05.bank_query.test.d.ts +0 -1
- package/dist/test/05.bank_query.test.js +0 -162
- package/dist/test/06.feegrant_tx.test.d.ts +0 -1
- package/dist/test/06.feegrant_tx.test.js +0 -185
- package/dist/test/07.feegrant_query.test.d.ts +0 -1
- package/dist/test/07.feegrant_query.test.js +0 -129
- package/dist/test/08.gas_estimate.test.d.ts +0 -1
- package/dist/test/08.gas_estimate.test.js +0 -728
- package/dist/test/09.ipfs.test.d.ts +0 -1
- package/dist/test/09.ipfs.test.js +0 -72
- package/dist/test/10.nft_tx.test.d.ts +0 -1
- package/dist/test/10.nft_tx.test.js +0 -209
- package/dist/test/11.nft_query.test.d.ts +0 -1
- package/dist/test/11.nft_query.test.js +0 -165
- package/dist/test/12.staking_tx.test.d.ts +0 -1
- package/dist/test/12.staking_tx.test.js +0 -211
- package/dist/test/13.staking_query.test.d.ts +0 -1
- package/dist/test/13.staking_query.test.js +0 -275
- package/dist/test/14.distribution_tx.test.d.ts +0 -1
- package/dist/test/14.distribution_tx.test.js +0 -170
- package/dist/test/15.distribution_query.test.d.ts +0 -1
- package/dist/test/15.distribution_query.test.js +0 -243
- package/dist/test/16.gov_tx.test.d.ts +0 -1
- package/dist/test/16.gov_tx.test.js +0 -394
- package/dist/test/17.gov_query.test.d.ts +0 -1
- package/dist/test/17.gov_query.test.js +0 -181
- package/dist/test/18.util.test.d.ts +0 -1
- package/dist/test/18.util.test.js +0 -354
- package/dist/test/19.chain.test.d.ts +0 -1
- package/dist/test/19.chain.test.js +0 -127
- package/dist/test/20.slashing_query.test.d.ts +0 -1
- package/dist/test/20.slashing_query.test.js +0 -111
- package/dist/test/21.token_tx.test.d.ts +0 -1
- package/dist/test/21.token_tx.test.js +0 -149
- package/dist/test/22.token_query.test.d.ts +0 -1
- package/dist/test/22.token_query.test.js +0 -103
- package/dist/test/23.authz_tx.test.d.ts +0 -1
- package/dist/test/23.authz_tx.test.js +0 -380
- package/dist/test/24.authz_query.test.d.ts +0 -1
- package/dist/test/24.authz_query.test.js +0 -202
- package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
- package/dist/test/25.cosmwasm_tx.test.js +0 -229
- package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
- package/dist/test/26.cosmwasm_query.test.js +0 -275
- package/dist/test/27.arbitrary_sign.test.d.ts +0 -1
- package/dist/test/27.arbitrary_sign.test.js +0 -162
- package/dist/test/28.ibc_tx.test.d.ts +0 -1
- package/dist/test/28.ibc_tx.test.js +0 -98
- package/dist/test/29.mint_query.test.d.ts +0 -1
- package/dist/test/29.mint_query.test.js +0 -59
- package/dist/test/30.cw20_tx.test.d.ts +0 -1
- package/dist/test/30.cw20_tx.test.js +0 -450
- package/dist/test/31.cw20_query.test.d.ts +0 -1
- package/dist/test/31.cw20_query.test.js +0 -333
- package/dist/test/32.cw721_tx.test.d.ts +0 -1
- package/dist/test/32.cw721_tx.test.js +0 -431
- package/dist/test/33.cw721_query.test.d.ts +0 -1
- package/dist/test/33.cw721_query.test.js +0 -371
- package/dist/test/34.cw_bridge_tx.test.d.ts +0 -1
- package/dist/test/34.cw_bridge_tx.test.js +0 -476
- package/dist/test/35.cw_bridge_tx_low.test.d.ts +0 -1
- package/dist/test/35.cw_bridge_tx_low.test.js +0 -398
- package/dist/test/36.cw_bridge_query.test.d.ts +0 -1
- package/dist/test/36.cw_bridge_query.test.js +0 -318
- package/dist/test/37.cw_marketplace_tx.test.d.ts +0 -1
- package/dist/test/37.cw_marketplace_tx.test.js +0 -794
- package/dist/test/38.cw_marketplace_query.test.d.ts +0 -1
- package/dist/test/38.cw_marketplace_query.test.js +0 -128
- package/dist/test/config_test.d.ts +0 -11
- package/dist/test/config_test.js +0 -26
- package/dist/test/config_test.sample.d.ts +0 -11
- package/dist/test/config_test.sample.js +0 -14
|
@@ -1,162 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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 FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
41
|
-
var config_test_1 = require("./config_test");
|
|
42
|
-
describe('[05. Bank test]', function () {
|
|
43
|
-
var firma;
|
|
44
|
-
var aliceWallet;
|
|
45
|
-
var aliceAddress;
|
|
46
|
-
beforeEach(function () {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
52
|
-
return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
|
|
53
|
-
case 1:
|
|
54
|
-
aliceWallet = _a.sent();
|
|
55
|
-
return [4 /*yield*/, aliceWallet.getAddress()];
|
|
56
|
-
case 2:
|
|
57
|
-
aliceAddress = _a.sent();
|
|
58
|
-
return [2 /*return*/];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
it('Bank getBalance() of a user who has never been created.', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
-
var newWallet, result, _a, _b, result2, _c, _d;
|
|
65
|
-
return __generator(this, function (_e) {
|
|
66
|
-
switch (_e.label) {
|
|
67
|
-
case 0: return [4 /*yield*/, firma.Wallet.newWallet()];
|
|
68
|
-
case 1:
|
|
69
|
-
newWallet = _e.sent();
|
|
70
|
-
_b = (_a = firma.Bank).getBalance;
|
|
71
|
-
return [4 /*yield*/, newWallet.getAddress()];
|
|
72
|
-
case 2: return [4 /*yield*/, _b.apply(_a, [_e.sent()])];
|
|
73
|
-
case 3:
|
|
74
|
-
result = _e.sent();
|
|
75
|
-
(0, chai_1.expect)(result).to.be.equal("0");
|
|
76
|
-
_d = (_c = firma.Bank).getBalance;
|
|
77
|
-
return [4 /*yield*/, newWallet.getAddress()];
|
|
78
|
-
case 4: return [4 /*yield*/, _d.apply(_c, [_e.sent()])];
|
|
79
|
-
case 5:
|
|
80
|
-
result2 = _e.sent();
|
|
81
|
-
(0, chai_1.expect)(result2).to.be.equal("0");
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}); });
|
|
86
|
-
it('Bank getBalance()', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
var result;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0: return [4 /*yield*/, firma.Bank.getBalance(aliceAddress)];
|
|
91
|
-
case 1:
|
|
92
|
-
result = _a.sent();
|
|
93
|
-
(0, chai_1.expect)(result).to.not.equal("");
|
|
94
|
-
return [2 /*return*/];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}); });
|
|
98
|
-
it('Bank getTokenBalance()', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
-
var tokenID, result;
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0:
|
|
103
|
-
tokenID = "ukomx6";
|
|
104
|
-
return [4 /*yield*/, firma.Bank.getTokenBalance(aliceAddress, tokenID)];
|
|
105
|
-
case 1:
|
|
106
|
-
result = _a.sent();
|
|
107
|
-
(0, chai_1.expect)(result).to.not.equal("");
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}); });
|
|
112
|
-
it('Bank getTokenBalance() - not exist tokenID', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
-
var tokenID, result;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0:
|
|
117
|
-
tokenID = "ukomx6sdfakljfd";
|
|
118
|
-
return [4 /*yield*/, firma.Bank.getTokenBalance(aliceAddress, tokenID)];
|
|
119
|
-
case 1:
|
|
120
|
-
result = _a.sent();
|
|
121
|
-
(0, chai_1.expect)(result).to.not.equal("");
|
|
122
|
-
return [2 /*return*/];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}); });
|
|
126
|
-
it('Bank getTokenBalanceList()', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
-
var result;
|
|
128
|
-
return __generator(this, function (_a) {
|
|
129
|
-
switch (_a.label) {
|
|
130
|
-
case 0: return [4 /*yield*/, firma.Bank.getTokenBalanceList(aliceAddress)];
|
|
131
|
-
case 1:
|
|
132
|
-
result = _a.sent();
|
|
133
|
-
(0, chai_1.expect)(result).to.not.equal(null);
|
|
134
|
-
return [2 /*return*/];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}); });
|
|
138
|
-
it('Bank getSupply()', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
-
var result;
|
|
140
|
-
return __generator(this, function (_a) {
|
|
141
|
-
switch (_a.label) {
|
|
142
|
-
case 0: return [4 /*yield*/, firma.Bank.getSupply()];
|
|
143
|
-
case 1:
|
|
144
|
-
result = _a.sent();
|
|
145
|
-
(0, chai_1.expect)(result).to.not.equal("0");
|
|
146
|
-
return [2 /*return*/];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}); });
|
|
150
|
-
it('Bank getTokenSupply()', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
-
var result;
|
|
152
|
-
return __generator(this, function (_a) {
|
|
153
|
-
switch (_a.label) {
|
|
154
|
-
case 0: return [4 /*yield*/, firma.Bank.getTokenSupply("ukomx1670550348")];
|
|
155
|
-
case 1:
|
|
156
|
-
result = _a.sent();
|
|
157
|
-
(0, chai_1.expect)(result).to.not.equal("");
|
|
158
|
-
return [2 /*return*/];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}); });
|
|
162
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,185 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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 FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
41
|
-
var config_test_1 = require("./config_test");
|
|
42
|
-
var FirmaUtil_1 = require("../sdk/FirmaUtil");
|
|
43
|
-
describe('[06. Feegrant Tx Test]', function () {
|
|
44
|
-
var firma;
|
|
45
|
-
var aliceWallet;
|
|
46
|
-
var aliceAddress;
|
|
47
|
-
var bobWallet;
|
|
48
|
-
var bobAddress;
|
|
49
|
-
beforeEach(function () {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
55
|
-
return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
|
|
56
|
-
case 1:
|
|
57
|
-
aliceWallet = _a.sent();
|
|
58
|
-
return [4 /*yield*/, aliceWallet.getAddress()];
|
|
59
|
-
case 2:
|
|
60
|
-
aliceAddress = _a.sent();
|
|
61
|
-
return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
|
|
62
|
-
case 3:
|
|
63
|
-
bobWallet = _a.sent();
|
|
64
|
-
return [4 /*yield*/, bobWallet.getAddress()];
|
|
65
|
-
case 4:
|
|
66
|
-
bobAddress = _a.sent();
|
|
67
|
-
return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
it('feegrant GrantPeriodicAllowance tx', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var expirationDate, grantResult;
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
expirationDate = new Date();
|
|
78
|
-
expirationDate.setDate(expirationDate.getDate() + 1);
|
|
79
|
-
return [4 /*yield*/, firma.FeeGrant.grantBasicAllowance(aliceWallet, bobAddress, {
|
|
80
|
-
spendLimit: [{
|
|
81
|
-
amount: "10000",
|
|
82
|
-
denom: firma.Config.denom
|
|
83
|
-
}],
|
|
84
|
-
expiration: {
|
|
85
|
-
seconds: BigInt(Math.floor(expirationDate.getTime() / 1000)),
|
|
86
|
-
nanos: (expirationDate.getTime() % 1000) * 1000000
|
|
87
|
-
}
|
|
88
|
-
})];
|
|
89
|
-
case 1:
|
|
90
|
-
grantResult = _a.sent();
|
|
91
|
-
(0, chai_1.expect)(grantResult.code).to.equal(0);
|
|
92
|
-
return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); });
|
|
96
|
-
it('feegrant RevokeAllowance tx', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var result, _a, _b, _c;
|
|
98
|
-
return __generator(this, function (_d) {
|
|
99
|
-
switch (_d.label) {
|
|
100
|
-
case 0:
|
|
101
|
-
_b = (_a = firma.FeeGrant).revokeAllowance;
|
|
102
|
-
_c = [aliceWallet];
|
|
103
|
-
return [4 /*yield*/, bobWallet.getAddress()];
|
|
104
|
-
case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
105
|
-
case 2:
|
|
106
|
-
result = _d.sent();
|
|
107
|
-
(0, chai_1.expect)(result.code).to.equal(0);
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}); });
|
|
112
|
-
it('feegrant GrantBasicAllowance tx', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
-
var result, revokeResult;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0: return [4 /*yield*/, firma.FeeGrant.grantBasicAllowance(aliceWallet, bobAddress, {
|
|
117
|
-
spendLimit: [{
|
|
118
|
-
denom: firma.Config.denom,
|
|
119
|
-
amount: "10000"
|
|
120
|
-
}]
|
|
121
|
-
})];
|
|
122
|
-
case 1:
|
|
123
|
-
result = _a.sent();
|
|
124
|
-
(0, chai_1.expect)(result.code).to.be.equal(0);
|
|
125
|
-
return [4 /*yield*/, firma.FeeGrant.revokeAllowance(aliceWallet, bobAddress)];
|
|
126
|
-
case 2:
|
|
127
|
-
revokeResult = _a.sent();
|
|
128
|
-
(0, chai_1.expect)(revokeResult.code).to.be.equal(0);
|
|
129
|
-
return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}); });
|
|
133
|
-
it('feegrant send tx', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
134
|
-
var error_1, spendAmount, amount, expirationDate, periodicAllowanceData, grantResult, sendResult, revokeResult;
|
|
135
|
-
return __generator(this, function (_a) {
|
|
136
|
-
switch (_a.label) {
|
|
137
|
-
case 0:
|
|
138
|
-
_a.trys.push([0, 2, , 3]);
|
|
139
|
-
return [4 /*yield*/, firma.FeeGrant.revokeAllowance(aliceWallet, bobAddress)];
|
|
140
|
-
case 1:
|
|
141
|
-
_a.sent();
|
|
142
|
-
return [3 /*break*/, 3];
|
|
143
|
-
case 2:
|
|
144
|
-
error_1 = _a.sent();
|
|
145
|
-
return [3 /*break*/, 3];
|
|
146
|
-
case 3:
|
|
147
|
-
spendAmount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr("10");
|
|
148
|
-
amount = 0.1;
|
|
149
|
-
expirationDate = new Date();
|
|
150
|
-
expirationDate.setMinutes(expirationDate.getMinutes() + 20);
|
|
151
|
-
periodicAllowanceData = {
|
|
152
|
-
basic: {
|
|
153
|
-
spendLimit: [
|
|
154
|
-
{ amount: spendAmount, denom: firma.Config.denom }
|
|
155
|
-
]
|
|
156
|
-
},
|
|
157
|
-
period: { seconds: BigInt(60 * 60 * 24), nanos: 0 },
|
|
158
|
-
periodSpendLimit: [
|
|
159
|
-
{ amount: spendAmount, denom: firma.Config.denom }
|
|
160
|
-
],
|
|
161
|
-
periodCanSpend: [
|
|
162
|
-
{ amount: spendAmount, denom: firma.Config.denom }
|
|
163
|
-
],
|
|
164
|
-
periodReset: {
|
|
165
|
-
seconds: BigInt(Math.floor(expirationDate.getTime() / 1000)),
|
|
166
|
-
nanos: (expirationDate.getTime() % 1000) * 1000000
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
return [4 /*yield*/, firma.FeeGrant.grantPeriodicAllowance(aliceWallet, bobAddress, periodicAllowanceData)];
|
|
170
|
-
case 4:
|
|
171
|
-
grantResult = _a.sent();
|
|
172
|
-
(0, chai_1.expect)(grantResult.code).to.equal(0);
|
|
173
|
-
return [4 /*yield*/, firma.Bank.send(bobWallet, aliceAddress, amount, { feeGranter: aliceAddress })];
|
|
174
|
-
case 5:
|
|
175
|
-
sendResult = _a.sent();
|
|
176
|
-
(0, chai_1.expect)(sendResult.code).to.equal(0);
|
|
177
|
-
return [4 /*yield*/, firma.FeeGrant.revokeAllowance(aliceWallet, bobAddress)];
|
|
178
|
-
case 6:
|
|
179
|
-
revokeResult = _a.sent();
|
|
180
|
-
(0, chai_1.expect)(revokeResult.code).to.equal(0);
|
|
181
|
-
return [2 /*return*/];
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}); });
|
|
185
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,129 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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 FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
41
|
-
var FirmaUtil_1 = require("../sdk/FirmaUtil");
|
|
42
|
-
var config_test_1 = require("./config_test");
|
|
43
|
-
describe('[07. Feegrant Query Test]', function () {
|
|
44
|
-
var firma;
|
|
45
|
-
var aliceWallet;
|
|
46
|
-
var aliceAddress;
|
|
47
|
-
var bobWallet;
|
|
48
|
-
var bobAddress;
|
|
49
|
-
beforeEach(function () {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
55
|
-
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:
|
|
60
|
-
bobWallet = _a.sent();
|
|
61
|
-
return [4 /*yield*/, aliceWallet.getAddress()];
|
|
62
|
-
case 3:
|
|
63
|
-
aliceAddress = _a.sent();
|
|
64
|
-
return [4 /*yield*/, bobWallet.getAddress()];
|
|
65
|
-
case 4:
|
|
66
|
-
bobAddress = _a.sent();
|
|
67
|
-
return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
afterEach(function () {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0: return [4 /*yield*/, firma.FeeGrant.revokeAllowance(aliceWallet, bobAddress)];
|
|
77
|
-
case 1:
|
|
78
|
-
_a.sent();
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
it('feegrant getGranteeAllowance', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
-
var expirationDate, grantResult, allowance;
|
|
86
|
-
return __generator(this, function (_a) {
|
|
87
|
-
switch (_a.label) {
|
|
88
|
-
case 0:
|
|
89
|
-
expirationDate = new Date();
|
|
90
|
-
expirationDate.setDate(expirationDate.getDate() + 1);
|
|
91
|
-
return [4 /*yield*/, firma.FeeGrant.grantBasicAllowance(aliceWallet, bobAddress, {
|
|
92
|
-
spendLimit: [{
|
|
93
|
-
amount: "10000",
|
|
94
|
-
denom: firma.Config.denom
|
|
95
|
-
}],
|
|
96
|
-
expiration: {
|
|
97
|
-
seconds: BigInt(Math.floor(expirationDate.getTime() / 1000)),
|
|
98
|
-
nanos: (expirationDate.getTime() % 1000) * 1000000
|
|
99
|
-
}
|
|
100
|
-
})];
|
|
101
|
-
case 1:
|
|
102
|
-
grantResult = _a.sent();
|
|
103
|
-
(0, chai_1.expect)(grantResult.code).to.equal(0);
|
|
104
|
-
return [4 /*yield*/, firma.FeeGrant.getGranteeAllowance(aliceAddress, bobAddress)];
|
|
105
|
-
case 2:
|
|
106
|
-
allowance = _a.sent();
|
|
107
|
-
(0, chai_1.expect)(allowance).to.not.equal(null);
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}); });
|
|
112
|
-
it('feegrant getGranteeAllowanceAll', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
-
var result;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0: return [4 /*yield*/, firma.FeeGrant.getGranteeAllowanceAll(bobAddress)];
|
|
117
|
-
case 1:
|
|
118
|
-
result = _a.sent();
|
|
119
|
-
if (result.length === 0) {
|
|
120
|
-
(0, chai_1.expect)(true).to.be.equal(true);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
(0, chai_1.expect)(FirmaUtil_1.FirmaUtil.isValidAddress(result[0].granter)).to.be.equal(true);
|
|
124
|
-
}
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); });
|
|
129
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|