@firmachain/firma-js 0.2.28 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk/FirmaAuthzService.d.ts +32 -0
- package/dist/sdk/FirmaAuthzService.js +630 -0
- package/dist/sdk/FirmaBankService.d.ts +2 -1
- package/dist/sdk/FirmaBankService.js +3 -0
- package/dist/sdk/FirmaCosmWasmService.d.ts +38 -0
- package/dist/sdk/FirmaCosmWasmService.js +667 -0
- package/dist/sdk/FirmaDistributionService.d.ts +2 -1
- package/dist/sdk/FirmaDistributionService.js +3 -0
- package/dist/sdk/FirmaMobileSDK.d.ts +3 -1
- package/dist/sdk/FirmaMobileSDK.js +4 -1
- package/dist/sdk/FirmaSDK.d.ts +5 -1
- package/dist/sdk/FirmaSDK.js +7 -1
- package/dist/sdk/FirmaStakingService.d.ts +2 -1
- package/dist/sdk/FirmaStakingService.js +3 -0
- package/dist/sdk/FirmaUtil.d.ts +1 -0
- package/dist/sdk/FirmaUtil.js +9 -4
- package/dist/sdk/firmachain/authz/AuthzQueryClient.d.ts +38 -0
- package/dist/sdk/firmachain/authz/AuthzQueryClient.js +115 -0
- package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +22 -0
- package/dist/sdk/firmachain/authz/AuthzTxClient.js +44 -0
- package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +147 -0
- package/dist/sdk/firmachain/authz/AuthzTxTypes.js +358 -0
- package/dist/sdk/firmachain/authz/index.d.ts +3 -0
- package/dist/sdk/firmachain/authz/index.js +15 -0
- package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -0
- package/dist/sdk/firmachain/common/ITxClient.js +9 -0
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.d.ts +52 -0
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +193 -0
- package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +37 -0
- package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +56 -0
- package/dist/sdk/firmachain/cosmwasm/index.d.ts +3 -0
- package/dist/sdk/firmachain/cosmwasm/index.js +15 -0
- package/package.json +4 -2
|
@@ -43,6 +43,9 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
43
43
|
function FirmaDistributionService(config) {
|
|
44
44
|
this.config = config;
|
|
45
45
|
}
|
|
46
|
+
FirmaDistributionService.prototype.getTxClient = function (wallet) {
|
|
47
|
+
return new distribution_1.DistributionTxClient(wallet, this.config.rpcAddress);
|
|
48
|
+
};
|
|
46
49
|
FirmaDistributionService.prototype.getGasEstimationSetWithdrawAddress = function (wallet, withdrawAddress, txMisc) {
|
|
47
50
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
48
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -10,6 +10,7 @@ import { FirmaWalletService } from "./FirmaWalletService";
|
|
|
10
10
|
import { FirmaGovService } from "./FirmaGovService";
|
|
11
11
|
import { ChainService } from "./FirmaChainService";
|
|
12
12
|
import { SlashingService } from "./FirmaSlashingService";
|
|
13
|
+
import { FirmaAuthzService } from "./FirmaAuthzService";
|
|
13
14
|
export declare class FirmaMobileSDK {
|
|
14
15
|
Config: FirmaConfig;
|
|
15
16
|
Wallet: FirmaWalletService;
|
|
@@ -23,5 +24,6 @@ export declare class FirmaMobileSDK {
|
|
|
23
24
|
Contract: ContractService;
|
|
24
25
|
BlockChain: ChainService;
|
|
25
26
|
Slashing: SlashingService;
|
|
26
|
-
|
|
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);
|
|
27
29
|
}
|
|
@@ -13,8 +13,9 @@ var FirmaUtil_1 = require("./FirmaUtil");
|
|
|
13
13
|
var FirmaGovService_1 = require("./FirmaGovService");
|
|
14
14
|
var FirmaChainService_1 = require("./FirmaChainService");
|
|
15
15
|
var FirmaSlashingService_1 = require("./FirmaSlashingService");
|
|
16
|
+
var FirmaAuthzService_1 = require("./FirmaAuthzService");
|
|
16
17
|
var FirmaMobileSDK = /** @class */ (function () {
|
|
17
|
-
function FirmaMobileSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, BlockChain, Slashing) {
|
|
18
|
+
function FirmaMobileSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, BlockChain, Slashing, Authz) {
|
|
18
19
|
if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
|
|
19
20
|
if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
|
|
20
21
|
if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
|
|
@@ -26,6 +27,7 @@ var FirmaMobileSDK = /** @class */ (function () {
|
|
|
26
27
|
if (Contract === void 0) { Contract = new FirmaContractService_1.ContractService(Config); }
|
|
27
28
|
if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
|
|
28
29
|
if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
|
|
30
|
+
if (Authz === void 0) { Authz = new FirmaAuthzService_1.FirmaAuthzService(Config); }
|
|
29
31
|
this.Config = Config;
|
|
30
32
|
this.Wallet = Wallet;
|
|
31
33
|
this.Bank = Bank;
|
|
@@ -38,6 +40,7 @@ var FirmaMobileSDK = /** @class */ (function () {
|
|
|
38
40
|
this.Contract = Contract;
|
|
39
41
|
this.BlockChain = BlockChain;
|
|
40
42
|
this.Slashing = Slashing;
|
|
43
|
+
this.Authz = Authz;
|
|
41
44
|
FirmaUtil_1.FirmaUtil.config = Config;
|
|
42
45
|
}
|
|
43
46
|
return FirmaMobileSDK;
|
package/dist/sdk/FirmaSDK.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ import { FirmaWalletService } from "./FirmaWalletService";
|
|
|
11
11
|
import { FirmaGovService } from "./FirmaGovService";
|
|
12
12
|
import { ChainService } from "./FirmaChainService";
|
|
13
13
|
import { SlashingService } from "./FirmaSlashingService";
|
|
14
|
+
import { FirmaAuthzService } from "./FirmaAuthzService";
|
|
15
|
+
import { FirmaCosmWasmService } from "./FirmaCosmWasmService";
|
|
14
16
|
export declare class FirmaSDK {
|
|
15
17
|
Config: FirmaConfig;
|
|
16
18
|
Wallet: FirmaWalletService;
|
|
@@ -25,5 +27,7 @@ export declare class FirmaSDK {
|
|
|
25
27
|
Ipfs: IpfsService;
|
|
26
28
|
BlockChain: ChainService;
|
|
27
29
|
Slashing: SlashingService;
|
|
28
|
-
|
|
30
|
+
Authz: FirmaAuthzService;
|
|
31
|
+
CosmWasm: FirmaCosmWasmService;
|
|
32
|
+
constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Token?: TokenService, Contract?: ContractService, Ipfs?: IpfsService, BlockChain?: ChainService, Slashing?: SlashingService, Authz?: FirmaAuthzService, CosmWasm?: FirmaCosmWasmService);
|
|
29
33
|
}
|
package/dist/sdk/FirmaSDK.js
CHANGED
|
@@ -14,8 +14,10 @@ var FirmaUtil_1 = require("./FirmaUtil");
|
|
|
14
14
|
var FirmaGovService_1 = require("./FirmaGovService");
|
|
15
15
|
var FirmaChainService_1 = require("./FirmaChainService");
|
|
16
16
|
var FirmaSlashingService_1 = require("./FirmaSlashingService");
|
|
17
|
+
var FirmaAuthzService_1 = require("./FirmaAuthzService");
|
|
18
|
+
var FirmaCosmWasmService_1 = require("./FirmaCosmWasmService");
|
|
17
19
|
var FirmaSDK = /** @class */ (function () {
|
|
18
|
-
function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing) {
|
|
20
|
+
function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, Ipfs, BlockChain, Slashing, Authz, CosmWasm) {
|
|
19
21
|
if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
|
|
20
22
|
if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
|
|
21
23
|
if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
|
|
@@ -28,6 +30,8 @@ var FirmaSDK = /** @class */ (function () {
|
|
|
28
30
|
if (Ipfs === void 0) { Ipfs = new FirmaIpfsService_1.IpfsService(Config); }
|
|
29
31
|
if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
|
|
30
32
|
if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
|
|
33
|
+
if (Authz === void 0) { Authz = new FirmaAuthzService_1.FirmaAuthzService(Config); }
|
|
34
|
+
if (CosmWasm === void 0) { CosmWasm = new FirmaCosmWasmService_1.FirmaCosmWasmService(Config); }
|
|
31
35
|
this.Config = Config;
|
|
32
36
|
this.Wallet = Wallet;
|
|
33
37
|
this.Bank = Bank;
|
|
@@ -41,6 +45,8 @@ var FirmaSDK = /** @class */ (function () {
|
|
|
41
45
|
this.Ipfs = Ipfs;
|
|
42
46
|
this.BlockChain = BlockChain;
|
|
43
47
|
this.Slashing = Slashing;
|
|
48
|
+
this.Authz = Authz;
|
|
49
|
+
this.CosmWasm = CosmWasm;
|
|
44
50
|
FirmaUtil_1.FirmaUtil.config = Config;
|
|
45
51
|
}
|
|
46
52
|
return FirmaSDK;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo } from "./firmachain/staking";
|
|
1
|
+
import { StakingTxClient, TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo } from "./firmachain/staking";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
4
|
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
@@ -7,6 +7,7 @@ import { MsgCreateValidator } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
|
|
7
7
|
export declare class FirmaStakingService {
|
|
8
8
|
private readonly config;
|
|
9
9
|
constructor(config: FirmaConfig);
|
|
10
|
+
getTxClient(wallet: FirmaWalletService): StakingTxClient;
|
|
10
11
|
getGasEstimationDelegate(wallet: FirmaWalletService, validatorAddres: string, amount: number, txMisc?: TxMisc): Promise<number>;
|
|
11
12
|
getGasEstimationUndelegate(wallet: FirmaWalletService, validatorAddres: string, amount: number, txMisc?: TxMisc): Promise<number>;
|
|
12
13
|
getGasEstimationRedelegate(wallet: FirmaWalletService, validatorSrcAddress: string, validatorDstAddress: string, amount: number, txMisc?: TxMisc): Promise<number>;
|
|
@@ -43,6 +43,9 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
43
43
|
function FirmaStakingService(config) {
|
|
44
44
|
this.config = config;
|
|
45
45
|
}
|
|
46
|
+
FirmaStakingService.prototype.getTxClient = function (wallet) {
|
|
47
|
+
return new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
|
|
48
|
+
};
|
|
46
49
|
FirmaStakingService.prototype.getGasEstimationDelegate = function (wallet, validatorAddres, amount, txMisc) {
|
|
47
50
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
48
51
|
return __awaiter(this, void 0, void 0, function () {
|
package/dist/sdk/FirmaUtil.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class FirmaUtil {
|
|
|
13
13
|
static getUTokenFromToken(tokenAmount: number, decimal: number): number;
|
|
14
14
|
static getTokenStringFromUToken(uTokenAmount: number, decimal: number): string;
|
|
15
15
|
static getUFCTStringFromFCTStr(fctAmount: string): string;
|
|
16
|
+
static getUFCTFromFCT(fctAmount: number): number;
|
|
16
17
|
static getFCTStringFromUFCTStr(uFctAmount: string): string;
|
|
17
18
|
static getUFCTStringFromFCT(fctAmount: number): string;
|
|
18
19
|
static getFCTStringFromUFCT(uFctAmount: number): string;
|
package/dist/sdk/FirmaUtil.js
CHANGED
|
@@ -68,7 +68,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
68
68
|
var fct = Number.parseFloat(tokenAmount);
|
|
69
69
|
var decimalMutiplyer = Math.pow(10, decimal);
|
|
70
70
|
var big = fct * decimalMutiplyer;
|
|
71
|
-
return big.
|
|
71
|
+
return big.toFixed(0);
|
|
72
72
|
};
|
|
73
73
|
FirmaUtil.getTokenStringFromUTokenStr = function (uTokenAmount, decimal) {
|
|
74
74
|
var ufct = Number.parseInt(uTokenAmount);
|
|
@@ -78,20 +78,25 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
78
78
|
FirmaUtil.getUTokenStringFromToken = function (tokenAmount, decimal) {
|
|
79
79
|
var decimalMutiplyer = Math.pow(10, decimal);
|
|
80
80
|
var big = tokenAmount * decimalMutiplyer;
|
|
81
|
-
return big.
|
|
81
|
+
return big.toFixed(0);
|
|
82
82
|
};
|
|
83
83
|
FirmaUtil.getUTokenFromToken = function (tokenAmount, decimal) {
|
|
84
84
|
var decimalMutiplyer = Math.pow(10, decimal);
|
|
85
85
|
var big = tokenAmount * decimalMutiplyer;
|
|
86
|
-
|
|
86
|
+
var newBig = big.toFixed(0);
|
|
87
|
+
return Number.parseInt(newBig);
|
|
87
88
|
};
|
|
88
89
|
FirmaUtil.getTokenStringFromUToken = function (uTokenAmount, decimal) {
|
|
90
|
+
var fixedUTokenAmount = Math.floor(uTokenAmount);
|
|
89
91
|
var decimalMutiplyer = Math.pow(10, decimal);
|
|
90
|
-
return (
|
|
92
|
+
return (fixedUTokenAmount / decimalMutiplyer).toString();
|
|
91
93
|
};
|
|
92
94
|
FirmaUtil.getUFCTStringFromFCTStr = function (fctAmount) {
|
|
93
95
|
return this.getUTokenStringFromTokenStr(fctAmount, this.FctDecimal);
|
|
94
96
|
};
|
|
97
|
+
FirmaUtil.getUFCTFromFCT = function (fctAmount) {
|
|
98
|
+
return this.getUTokenFromToken(fctAmount, this.FctDecimal);
|
|
99
|
+
};
|
|
95
100
|
FirmaUtil.getFCTStringFromUFCTStr = function (uFctAmount) {
|
|
96
101
|
return this.getTokenStringFromUTokenStr(uFctAmount, this.FctDecimal);
|
|
97
102
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
2
|
+
import { AuthorizationType } from "./AuthzTxTypes";
|
|
3
|
+
export interface GrantSendData {
|
|
4
|
+
authorization: authorization_send;
|
|
5
|
+
expiration: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GrantGenericData {
|
|
8
|
+
authorization: authorization_generic;
|
|
9
|
+
expiration: string;
|
|
10
|
+
}
|
|
11
|
+
export interface GrantStakingData {
|
|
12
|
+
authorization: authorization_staking;
|
|
13
|
+
expiration: string;
|
|
14
|
+
}
|
|
15
|
+
export interface authorization_send {
|
|
16
|
+
"@type": string;
|
|
17
|
+
spend_limit: Coin[];
|
|
18
|
+
}
|
|
19
|
+
export interface authorization_generic {
|
|
20
|
+
"@type": string;
|
|
21
|
+
msg: string;
|
|
22
|
+
}
|
|
23
|
+
export interface authorization_staking {
|
|
24
|
+
"@type": string;
|
|
25
|
+
max_tokens: Coin;
|
|
26
|
+
allow_list: allowList;
|
|
27
|
+
authorization_type: string;
|
|
28
|
+
}
|
|
29
|
+
export interface allowList {
|
|
30
|
+
address: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare class AuthzQueryClient {
|
|
33
|
+
private readonly axios;
|
|
34
|
+
constructor(baseUrl: string);
|
|
35
|
+
getSendGrantData(granterAddress: string, granteeAddress: string): Promise<GrantSendData[]>;
|
|
36
|
+
getGenericGrantData(granterAddress: string, granteeAddress: string, msgType: string): Promise<GrantGenericData[]>;
|
|
37
|
+
getStakingGrantData(granterAddress: string, granteeAddress: string, type: AuthorizationType): Promise<GrantStakingData[]>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
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.AuthzQueryClient = void 0;
|
|
43
|
+
var axios_1 = __importDefault(require("axios"));
|
|
44
|
+
var AuthzTxTypes_1 = require("./AuthzTxTypes");
|
|
45
|
+
var AuthzQueryClient = /** @class */ (function () {
|
|
46
|
+
function AuthzQueryClient(baseUrl) {
|
|
47
|
+
this.axios = axios_1.default.create({
|
|
48
|
+
baseURL: baseUrl,
|
|
49
|
+
headers: {
|
|
50
|
+
Accept: "application/json",
|
|
51
|
+
},
|
|
52
|
+
timeout: 15000,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
AuthzQueryClient.prototype.getSendGrantData = function (granterAddress, granteeAddress) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var msgType, path, result;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
msgType = "/cosmos.bank.v1beta1.MsgSend";
|
|
62
|
+
path = "/cosmos/authz/v1beta1/grants?granter=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
|
|
63
|
+
return [4 /*yield*/, this.axios.get(path)];
|
|
64
|
+
case 1:
|
|
65
|
+
result = _a.sent();
|
|
66
|
+
return [2 /*return*/, result.data.grants];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
AuthzQueryClient.prototype.getGenericGrantData = function (granterAddress, granteeAddress, msgType) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var path, result;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
path = "/cosmos/authz/v1beta1/grants?granter=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
|
|
78
|
+
return [4 /*yield*/, this.axios.get(path)];
|
|
79
|
+
case 1:
|
|
80
|
+
result = _a.sent();
|
|
81
|
+
return [2 /*return*/, result.data.grants];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
AuthzQueryClient.prototype.getStakingGrantData = function (granterAddress, granteeAddress, type) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var msgType, path, result;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
msgType = "none";
|
|
93
|
+
switch (type) {
|
|
94
|
+
case AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE:
|
|
95
|
+
msgType = "/cosmos.staking.v1beta1.MsgDelegate";
|
|
96
|
+
break;
|
|
97
|
+
case AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE:
|
|
98
|
+
msgType = "/cosmos.staking.v1beta1.MsgUndelegate";
|
|
99
|
+
break;
|
|
100
|
+
case AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE:
|
|
101
|
+
msgType = "/cosmos.staking.v1beta1.MsgBeginRedelegate";
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
path = "/cosmos/authz/v1beta1/grants?granter=" + granterAddress + "&grantee=" + granteeAddress + "&msg_type_url=" + msgType;
|
|
105
|
+
return [4 /*yield*/, this.axios.get(path)];
|
|
106
|
+
case 1:
|
|
107
|
+
result = _a.sent();
|
|
108
|
+
return [2 /*return*/, result.data.grants];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
return AuthzQueryClient;
|
|
114
|
+
}());
|
|
115
|
+
exports.AuthzQueryClient = AuthzQueryClient;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EncodeObject } from "@cosmjs/proto-signing";
|
|
2
|
+
import { MsgExec, MsgGrant, MsgRevoke } from "./AuthzTxTypes";
|
|
3
|
+
import { ITxClient } from "../common/ITxClient";
|
|
4
|
+
import { FirmaWalletService } from "../../FirmaWalletService";
|
|
5
|
+
export interface MsgExecAllowanceEncodeObject extends EncodeObject {
|
|
6
|
+
readonly typeUrl: "/cosmos.authz.v1beta1.MsgExec";
|
|
7
|
+
readonly value: Partial<MsgExec>;
|
|
8
|
+
}
|
|
9
|
+
export interface MsgGrantAllowanceEncodeObject extends EncodeObject {
|
|
10
|
+
readonly typeUrl: "/cosmos.authz.v1beta1.MsgGrant";
|
|
11
|
+
readonly value: Partial<MsgGrant>;
|
|
12
|
+
}
|
|
13
|
+
export interface MsgRevokeAllowanceEncodeObject extends EncodeObject {
|
|
14
|
+
readonly typeUrl: "/cosmos.authz.v1beta1.MsgRevoke";
|
|
15
|
+
readonly value: Partial<MsgRevoke>;
|
|
16
|
+
}
|
|
17
|
+
export declare class AuthzTxClient extends ITxClient {
|
|
18
|
+
constructor(wallet: FirmaWalletService, serverUrl: string);
|
|
19
|
+
msgExecAllowance(data: MsgExec): MsgExecAllowanceEncodeObject;
|
|
20
|
+
msgGrantAllowance(data: MsgGrant): MsgGrantAllowanceEncodeObject;
|
|
21
|
+
msgRevokeAllowance(data: MsgRevoke): MsgRevokeAllowanceEncodeObject;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AuthzTxClient = void 0;
|
|
19
|
+
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
20
|
+
var AuthzTxTypes_1 = require("./AuthzTxTypes");
|
|
21
|
+
var ITxClient_1 = require("../common/ITxClient");
|
|
22
|
+
var types = [
|
|
23
|
+
["/cosmos.authz.v1beta1.MsgExec", AuthzTxTypes_1.MsgExec],
|
|
24
|
+
["/cosmos.authz.v1beta1.MsgGrant", AuthzTxTypes_1.MsgGrant],
|
|
25
|
+
["/cosmos.authz.v1beta1.MsgRevoke", AuthzTxTypes_1.MsgRevoke],
|
|
26
|
+
];
|
|
27
|
+
var registry = new proto_signing_1.Registry(types);
|
|
28
|
+
var AuthzTxClient = /** @class */ (function (_super) {
|
|
29
|
+
__extends(AuthzTxClient, _super);
|
|
30
|
+
function AuthzTxClient(wallet, serverUrl) {
|
|
31
|
+
return _super.call(this, wallet, serverUrl, registry) || this;
|
|
32
|
+
}
|
|
33
|
+
AuthzTxClient.prototype.msgExecAllowance = function (data) {
|
|
34
|
+
return { typeUrl: "/cosmos.authz.v1beta1.MsgExec", value: data };
|
|
35
|
+
};
|
|
36
|
+
AuthzTxClient.prototype.msgGrantAllowance = function (data) {
|
|
37
|
+
return { typeUrl: "/cosmos.authz.v1beta1.MsgGrant", value: data };
|
|
38
|
+
};
|
|
39
|
+
AuthzTxClient.prototype.msgRevokeAllowance = function (data) {
|
|
40
|
+
return { typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", value: data };
|
|
41
|
+
};
|
|
42
|
+
return AuthzTxClient;
|
|
43
|
+
}(ITxClient_1.ITxClient));
|
|
44
|
+
exports.AuthzTxClient = AuthzTxClient;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/// <reference types="long" />
|
|
2
|
+
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
3
|
+
import _m0 from "protobufjs/minimal";
|
|
4
|
+
import { Writer } from "protobufjs/minimal";
|
|
5
|
+
import { Timestamp } from "../google/protobuf/timestamp";
|
|
6
|
+
import { Any } from "../google/protobuf/any";
|
|
7
|
+
export interface GenericAuthorization {
|
|
8
|
+
/** Msg, identified by it's type URL, to grant unrestricted permissions to execute */
|
|
9
|
+
msg: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Grant {
|
|
12
|
+
authorization?: Any;
|
|
13
|
+
expiration?: Timestamp;
|
|
14
|
+
}
|
|
15
|
+
export interface MsgGrant {
|
|
16
|
+
granter: string;
|
|
17
|
+
grantee: string;
|
|
18
|
+
grant?: Grant;
|
|
19
|
+
}
|
|
20
|
+
/** MsgExecResponse defines the Msg/MsgExecResponse response type. */
|
|
21
|
+
export interface MsgExecResponse {
|
|
22
|
+
results: Uint8Array[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* MsgExec attempts to execute the provided messages using
|
|
26
|
+
* authorizations granted to the grantee. Each message should have only
|
|
27
|
+
* one signer corresponding to the granter of the authorization.
|
|
28
|
+
*/
|
|
29
|
+
export interface MsgExec {
|
|
30
|
+
grantee: string;
|
|
31
|
+
/**
|
|
32
|
+
* Authorization Msg requests to execute. Each msg must implement Authorization interface
|
|
33
|
+
* The x/authz will try to find a grant matching (msg.signers[0], grantee, MsgTypeURL(msg))
|
|
34
|
+
* triple and validate it.
|
|
35
|
+
*/
|
|
36
|
+
msgs: Any[];
|
|
37
|
+
}
|
|
38
|
+
/** MsgGrantResponse defines the Msg/MsgGrant response type. */
|
|
39
|
+
export interface MsgGrantResponse {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* MsgRevoke revokes any authorization with the provided sdk.Msg type on the
|
|
43
|
+
* granter's account with that has been granted to the grantee.
|
|
44
|
+
*/
|
|
45
|
+
export interface MsgRevoke {
|
|
46
|
+
granter: string;
|
|
47
|
+
grantee: string;
|
|
48
|
+
msgTypeUrl: string;
|
|
49
|
+
}
|
|
50
|
+
/** MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. */
|
|
51
|
+
export interface MsgRevokeResponse {
|
|
52
|
+
}
|
|
53
|
+
export declare const MsgGrant: {
|
|
54
|
+
encode(message: MsgGrant, writer?: _m0.Writer): _m0.Writer;
|
|
55
|
+
fromPartial(object: DeepPartial<MsgGrant>): MsgGrant;
|
|
56
|
+
};
|
|
57
|
+
export declare const MsgExecResponse: {
|
|
58
|
+
encode(message: MsgExecResponse, writer?: _m0.Writer): _m0.Writer;
|
|
59
|
+
fromPartial(object: DeepPartial<MsgExecResponse>): MsgExecResponse;
|
|
60
|
+
};
|
|
61
|
+
export declare const MsgExec: {
|
|
62
|
+
encode(message: MsgExec, writer?: _m0.Writer): _m0.Writer;
|
|
63
|
+
fromPartial(object: DeepPartial<MsgExec>): MsgExec;
|
|
64
|
+
};
|
|
65
|
+
export declare const MsgGrantResponse: {
|
|
66
|
+
encode(_: MsgGrantResponse, writer?: _m0.Writer): _m0.Writer;
|
|
67
|
+
fromPartial(object: DeepPartial<MsgGrantResponse>): MsgGrantResponse;
|
|
68
|
+
};
|
|
69
|
+
export declare const MsgRevoke: {
|
|
70
|
+
encode(message: MsgRevoke, writer?: _m0.Writer): _m0.Writer;
|
|
71
|
+
fromPartial(object: DeepPartial<MsgRevoke>): MsgRevoke;
|
|
72
|
+
};
|
|
73
|
+
export declare const MsgRevokeResponse: {
|
|
74
|
+
encode(_: MsgRevokeResponse, writer?: _m0.Writer): _m0.Writer;
|
|
75
|
+
fromPartial(object: DeepPartial<MsgRevokeResponse>): MsgRevokeResponse;
|
|
76
|
+
};
|
|
77
|
+
export declare const Grant: {
|
|
78
|
+
encode(message: Grant, writer?: _m0.Writer): _m0.Writer;
|
|
79
|
+
fromPartial(object: DeepPartial<Grant>): Grant;
|
|
80
|
+
};
|
|
81
|
+
export declare const GenericAuthorization: {
|
|
82
|
+
encode(message: GenericAuthorization, writer?: _m0.Writer): _m0.Writer;
|
|
83
|
+
fromPartial(object: DeepPartial<GenericAuthorization>): GenericAuthorization;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* AuthorizationType defines the type of staking module authorization type
|
|
87
|
+
*
|
|
88
|
+
* Since: cosmos-sdk 0.43
|
|
89
|
+
*/
|
|
90
|
+
export declare enum AuthorizationType {
|
|
91
|
+
/** AUTHORIZATION_TYPE_UNSPECIFIED - AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type */
|
|
92
|
+
AUTHORIZATION_TYPE_UNSPECIFIED = 0,
|
|
93
|
+
/** AUTHORIZATION_TYPE_DELEGATE - AUTHORIZATION_TYPE_DELEGATE defines an authorization type for Msg/Delegate */
|
|
94
|
+
AUTHORIZATION_TYPE_DELEGATE = 1,
|
|
95
|
+
/** AUTHORIZATION_TYPE_UNDELEGATE - AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for Msg/Undelegate */
|
|
96
|
+
AUTHORIZATION_TYPE_UNDELEGATE = 2,
|
|
97
|
+
/** AUTHORIZATION_TYPE_REDELEGATE - AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for Msg/BeginRedelegate */
|
|
98
|
+
AUTHORIZATION_TYPE_REDELEGATE = 3,
|
|
99
|
+
UNRECOGNIZED = -1
|
|
100
|
+
}
|
|
101
|
+
export declare function authorizationTypeFromJSON(object: any): AuthorizationType;
|
|
102
|
+
export declare function authorizationTypeToJSON(object: AuthorizationType): string;
|
|
103
|
+
/**
|
|
104
|
+
* StakeAuthorization defines authorization for delegate/undelegate/redelegate.
|
|
105
|
+
*
|
|
106
|
+
* Since: cosmos-sdk 0.43
|
|
107
|
+
*/
|
|
108
|
+
export interface StakeAuthorization {
|
|
109
|
+
/**
|
|
110
|
+
* max_tokens specifies the maximum amount of tokens can be delegate to a validator. If it is
|
|
111
|
+
* empty, there is no spend limit and any amount of coins can be delegated.
|
|
112
|
+
*/
|
|
113
|
+
maxTokens?: Coin;
|
|
114
|
+
/**
|
|
115
|
+
* allow_list specifies list of validator addresses to whom grantee can delegate tokens on behalf of granter's
|
|
116
|
+
* account.
|
|
117
|
+
*/
|
|
118
|
+
allowList?: StakeAuthorization_Validators | undefined;
|
|
119
|
+
/** deny_list specifies list of validator addresses to whom grantee can not delegate tokens. */
|
|
120
|
+
denyList?: StakeAuthorization_Validators | undefined;
|
|
121
|
+
/** authorization_type defines one of AuthorizationType. */
|
|
122
|
+
authorizationType: AuthorizationType;
|
|
123
|
+
}
|
|
124
|
+
/** Validators defines list of validator addresses. */
|
|
125
|
+
export interface StakeAuthorization_Validators {
|
|
126
|
+
address: string[];
|
|
127
|
+
}
|
|
128
|
+
export declare const StakeAuthorization: {
|
|
129
|
+
encode(message: StakeAuthorization, writer?: _m0.Writer): _m0.Writer;
|
|
130
|
+
fromPartial(object: DeepPartial<StakeAuthorization>): StakeAuthorization;
|
|
131
|
+
};
|
|
132
|
+
export declare const StakeAuthorization_Validators: {
|
|
133
|
+
encode(message: StakeAuthorization_Validators, writer?: _m0.Writer): _m0.Writer;
|
|
134
|
+
fromPartial(object: DeepPartial<StakeAuthorization_Validators>): StakeAuthorization_Validators;
|
|
135
|
+
};
|
|
136
|
+
export interface SendAuthorization {
|
|
137
|
+
spendLimit: Coin[];
|
|
138
|
+
}
|
|
139
|
+
export declare const SendAuthorization: {
|
|
140
|
+
encode(message: SendAuthorization, writer?: _m0.Writer): _m0.Writer;
|
|
141
|
+
fromPartial(object: DeepPartial<SendAuthorization>): SendAuthorization;
|
|
142
|
+
};
|
|
143
|
+
declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long;
|
|
144
|
+
export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
145
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
146
|
+
} : Partial<T>;
|
|
147
|
+
export {};
|