@firmachain/firma-js 0.3.8 → 0.4.0-beta2

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 (131) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/sdk/FirmaAuthzService.js +20 -15
  4. package/dist/sdk/FirmaBankService.d.ts +1 -1
  5. package/dist/sdk/FirmaBankService.js +5 -4
  6. package/dist/sdk/FirmaConfig.js +4 -4
  7. package/dist/sdk/FirmaContractService.js +10 -8
  8. package/dist/sdk/FirmaDistributionService.js +20 -15
  9. package/dist/sdk/FirmaFeeGrantService.d.ts +0 -1
  10. package/dist/sdk/FirmaFeeGrantService.js +12 -14
  11. package/dist/sdk/FirmaGovService.d.ts +14 -0
  12. package/dist/sdk/FirmaGovService.js +58 -37
  13. package/dist/sdk/FirmaIbcService.js +4 -3
  14. package/dist/sdk/FirmaNftService.d.ts +3 -3
  15. package/dist/sdk/FirmaNftService.js +13 -10
  16. package/dist/sdk/FirmaStakingService.d.ts +4 -0
  17. package/dist/sdk/FirmaStakingService.js +58 -33
  18. package/dist/sdk/FirmaTokenService.js +17 -14
  19. package/dist/sdk/FirmaUtil.js +1 -1
  20. package/dist/sdk/FirmaWalletService.d.ts +1 -1
  21. package/dist/sdk/FirmaWalletService.js +11 -23
  22. package/dist/sdk/firmachain/authz/AuthzTxClient.js +2 -0
  23. package/dist/sdk/firmachain/bank/BankTxClient.js +1 -1
  24. package/dist/sdk/firmachain/common/CommonTxClient.js +3 -1
  25. package/dist/sdk/firmachain/common/FirmaLedger.d.ts +49 -0
  26. package/dist/sdk/firmachain/common/FirmaLedger.js +301 -0
  27. package/dist/sdk/firmachain/common/ITxClient.d.ts +1 -1
  28. package/dist/sdk/firmachain/common/ITxClient.js +6 -4
  29. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +5 -13
  30. package/dist/sdk/firmachain/common/LedgerWallet.js +1266 -124
  31. package/dist/sdk/firmachain/common/SigningProtobufStargateClient.js +3 -4
  32. package/dist/sdk/firmachain/common/SigningStargateClient.d.ts +2 -3
  33. package/dist/sdk/firmachain/common/SigningStargateClient.js +7 -10
  34. package/dist/sdk/firmachain/common/index.d.ts +1 -0
  35. package/dist/sdk/firmachain/common/index.js +1 -0
  36. package/dist/sdk/firmachain/common/signing.d.ts +4 -10
  37. package/dist/sdk/firmachain/common/signing.js +13 -60
  38. package/dist/sdk/firmachain/contract/ContractTxClient.js +1 -1
  39. package/dist/sdk/firmachain/contract/ContractTxTypes.js +54 -8
  40. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +1 -1
  41. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +3 -1
  42. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +1 -2
  43. package/dist/sdk/firmachain/google/protobuf/any.js +0 -12
  44. package/dist/sdk/firmachain/gov/GovTxClient.js +3 -0
  45. package/dist/sdk/firmachain/nft/NftTxClient.js +1 -1
  46. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +15 -0
  47. package/dist/sdk/firmachain/staking/StakingQueryClient.js +109 -0
  48. package/dist/sdk/firmachain/token/TokenTxClient.js +1 -1
  49. package/package.json +18 -9
  50. package/dist/test/00.wallet.test.d.ts +0 -1
  51. package/dist/test/00.wallet.test.js +0 -96
  52. package/dist/test/01.contract_tx.test.d.ts +0 -1
  53. package/dist/test/01.contract_tx.test.js +0 -157
  54. package/dist/test/02.contract_query.test.d.ts +0 -1
  55. package/dist/test/02.contract_query.test.js +0 -245
  56. package/dist/test/03.contract_scenario.test.d.ts +0 -1
  57. package/dist/test/03.contract_scenario.test.js +0 -406
  58. package/dist/test/04.bank_tx.test.d.ts +0 -1
  59. package/dist/test/04.bank_tx.test.js +0 -126
  60. package/dist/test/05.bank_query.test.d.ts +0 -1
  61. package/dist/test/05.bank_query.test.js +0 -162
  62. package/dist/test/06.feegrant_tx.test.d.ts +0 -1
  63. package/dist/test/06.feegrant_tx.test.js +0 -185
  64. package/dist/test/07.feegrant_query.test.d.ts +0 -1
  65. package/dist/test/07.feegrant_query.test.js +0 -129
  66. package/dist/test/08.gas_estimate.test.d.ts +0 -1
  67. package/dist/test/08.gas_estimate.test.js +0 -728
  68. package/dist/test/09.ipfs.test.d.ts +0 -1
  69. package/dist/test/09.ipfs.test.js +0 -72
  70. package/dist/test/10.nft_tx.test.d.ts +0 -1
  71. package/dist/test/10.nft_tx.test.js +0 -209
  72. package/dist/test/11.nft_query.test.d.ts +0 -1
  73. package/dist/test/11.nft_query.test.js +0 -165
  74. package/dist/test/12.staking_tx.test.d.ts +0 -1
  75. package/dist/test/12.staking_tx.test.js +0 -211
  76. package/dist/test/13.staking_query.test.d.ts +0 -1
  77. package/dist/test/13.staking_query.test.js +0 -275
  78. package/dist/test/14.distribution_tx.test.d.ts +0 -1
  79. package/dist/test/14.distribution_tx.test.js +0 -170
  80. package/dist/test/15.distribution_query.test.d.ts +0 -1
  81. package/dist/test/15.distribution_query.test.js +0 -243
  82. package/dist/test/16.gov_tx.test.d.ts +0 -1
  83. package/dist/test/16.gov_tx.test.js +0 -394
  84. package/dist/test/17.gov_query.test.d.ts +0 -1
  85. package/dist/test/17.gov_query.test.js +0 -181
  86. package/dist/test/18.util.test.d.ts +0 -1
  87. package/dist/test/18.util.test.js +0 -354
  88. package/dist/test/19.chain.test.d.ts +0 -1
  89. package/dist/test/19.chain.test.js +0 -127
  90. package/dist/test/20.slashing_query.test.d.ts +0 -1
  91. package/dist/test/20.slashing_query.test.js +0 -111
  92. package/dist/test/21.token_tx.test.d.ts +0 -1
  93. package/dist/test/21.token_tx.test.js +0 -149
  94. package/dist/test/22.token_query.test.d.ts +0 -1
  95. package/dist/test/22.token_query.test.js +0 -103
  96. package/dist/test/23.authz_tx.test.d.ts +0 -1
  97. package/dist/test/23.authz_tx.test.js +0 -380
  98. package/dist/test/24.authz_query.test.d.ts +0 -1
  99. package/dist/test/24.authz_query.test.js +0 -202
  100. package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
  101. package/dist/test/25.cosmwasm_tx.test.js +0 -229
  102. package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
  103. package/dist/test/26.cosmwasm_query.test.js +0 -275
  104. package/dist/test/27.arbitrary_sign.test.d.ts +0 -1
  105. package/dist/test/27.arbitrary_sign.test.js +0 -162
  106. package/dist/test/28.ibc_tx.test.d.ts +0 -1
  107. package/dist/test/28.ibc_tx.test.js +0 -98
  108. package/dist/test/29.mint_query.test.d.ts +0 -1
  109. package/dist/test/29.mint_query.test.js +0 -59
  110. package/dist/test/30.cw20_tx.test.d.ts +0 -1
  111. package/dist/test/30.cw20_tx.test.js +0 -450
  112. package/dist/test/31.cw20_query.test.d.ts +0 -1
  113. package/dist/test/31.cw20_query.test.js +0 -333
  114. package/dist/test/32.cw721_tx.test.d.ts +0 -1
  115. package/dist/test/32.cw721_tx.test.js +0 -431
  116. package/dist/test/33.cw721_query.test.d.ts +0 -1
  117. package/dist/test/33.cw721_query.test.js +0 -371
  118. package/dist/test/34.cw_bridge_tx.test.d.ts +0 -1
  119. package/dist/test/34.cw_bridge_tx.test.js +0 -476
  120. package/dist/test/35.cw_bridge_tx_low.test.d.ts +0 -1
  121. package/dist/test/35.cw_bridge_tx_low.test.js +0 -398
  122. package/dist/test/36.cw_bridge_query.test.d.ts +0 -1
  123. package/dist/test/36.cw_bridge_query.test.js +0 -318
  124. package/dist/test/37.cw_marketplace_tx.test.d.ts +0 -1
  125. package/dist/test/37.cw_marketplace_tx.test.js +0 -794
  126. package/dist/test/38.cw_marketplace_query.test.d.ts +0 -1
  127. package/dist/test/38.cw_marketplace_query.test.js +0 -128
  128. package/dist/test/config_test.d.ts +0 -11
  129. package/dist/test/config_test.js +0 -26
  130. package/dist/test/config_test.sample.d.ts +0 -11
  131. package/dist/test/config_test.sample.js +0 -14
@@ -116,7 +116,7 @@ var SigningProtobufStargateClient = /** @class */ (function (_super) {
116
116
  };
117
117
  SigningProtobufStargateClient.prototype.experimentalAdr36Sign = function (signerAddress, data) {
118
118
  return __awaiter(this, void 0, void 0, function () {
119
- var accountNumber, sequence, chainId, datas, msgs, accountFromSigner, txBody, fee, pubkey, signerInfo, authInfo, signDoc, signBytes, hash, rawWallet, privKey, signature, signatureBytes, jsonData;
119
+ var accountNumber, sequence, chainId, datas, msgs, accountFromSigner, txBody, fee, pubkey, signerInfo, authInfo, signDoc, signBytes, hash, privKey, signature, signatureBytes, jsonData;
120
120
  return __generator(this, function (_a) {
121
121
  switch (_a.label) {
122
122
  case 0:
@@ -178,8 +178,7 @@ var SigningProtobufStargateClient = /** @class */ (function (_super) {
178
178
  });
179
179
  signBytes = (0, proto_signing_1.makeSignBytes)(signDoc);
180
180
  hash = (0, crypto_1.sha256)(signBytes);
181
- rawWallet = this.signer;
182
- privKey = rawWallet.privkey;
181
+ privKey = this.signer.privkey;
183
182
  if (!privKey) {
184
183
  throw new Error("Private key not accessible for ADR-036 signing");
185
184
  }
@@ -303,7 +302,7 @@ var SigningProtobufStargateClient = /** @class */ (function (_super) {
303
302
  if (!finalData) {
304
303
  return [2 /*return*/, null];
305
304
  }
306
- account = any_1.Any.decode(Buffer.from(finalData, "base64"));
305
+ account = any_1.Any.decode(Uint8Array.from(Buffer.from(finalData, "base64")));
307
306
  finalAccount = (0, accounts_1.accountFromAny)(account);
308
307
  return [2 /*return*/, finalAccount];
309
308
  case 2:
@@ -23,7 +23,6 @@ export interface SigningStargateClientOptions extends StargateClientOptions {
23
23
  export declare class SigningStargateClient extends StargateClient {
24
24
  readonly registry: Registry;
25
25
  private readonly signer;
26
- private static _endpoint;
27
26
  static connectWithSigner(endpoint: string | HttpEndpoint, signer: OfflineDirectSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
28
27
  static createWithSigner(cometClient: CometClient, signer: OfflineDirectSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
29
28
  protected constructor(cometClient: CometClient | undefined, signer: OfflineDirectSigner, options: SigningStargateClientOptions);
@@ -32,6 +31,6 @@ export declare class SigningStargateClient extends StargateClient {
32
31
  sign(signerAddress: string, messages: readonly EncodeObject[], fee: Fee, memo: string, explicitSignerData?: SignerData): Promise<TxRaw>;
33
32
  private signDirect;
34
33
  signDirectForSignDoc(signerAddress: string, signDoc: SignDoc): Promise<TxRawExt>;
35
- static getSequence(address: string): Promise<SequenceResponse>;
36
- static getAccount(address: string): Promise<Account | null>;
34
+ static getSequence(address: string, serverUrl: string): Promise<SequenceResponse>;
35
+ static getAccount(address: string, serverUrl: string): Promise<Account | null>;
37
36
  }
@@ -146,12 +146,10 @@ var SigningStargateClient = /** @class */ (function (_super) {
146
146
  var _a, accountNumber, sequence, account, pubkeyBytes, pubkey, pubkeyAny, anyMsgs, txBody, bodyBytes, authInfoBytes;
147
147
  return __generator(this, function (_b) {
148
148
  switch (_b.label) {
149
- case 0:
150
- SigningStargateClient._endpoint = serverUrl;
151
- return [4 /*yield*/, SigningStargateClient.getSequence(signerAddress)];
149
+ case 0: return [4 /*yield*/, SigningStargateClient.getSequence(signerAddress, serverUrl)];
152
150
  case 1:
153
151
  _a = _b.sent(), accountNumber = _a.accountNumber, sequence = _a.sequence;
154
- return [4 /*yield*/, SigningStargateClient.getAccount(signerAddress)];
152
+ return [4 /*yield*/, SigningStargateClient.getAccount(signerAddress, serverUrl)];
155
153
  case 2:
156
154
  account = _b.sent();
157
155
  if (account == null)
@@ -266,12 +264,12 @@ var SigningStargateClient = /** @class */ (function (_super) {
266
264
  });
267
265
  });
268
266
  };
269
- SigningStargateClient.getSequence = function (address) {
267
+ SigningStargateClient.getSequence = function (address, serverUrl) {
270
268
  return __awaiter(this, void 0, void 0, function () {
271
269
  var account;
272
270
  return __generator(this, function (_a) {
273
271
  switch (_a.label) {
274
- case 0: return [4 /*yield*/, this.getAccount(address)];
272
+ case 0: return [4 /*yield*/, this.getAccount(address, serverUrl)];
275
273
  case 1:
276
274
  account = _a.sent();
277
275
  if (!account) {
@@ -285,7 +283,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
285
283
  });
286
284
  });
287
285
  };
288
- SigningStargateClient.getAccount = function (address) {
286
+ SigningStargateClient.getAccount = function (address, serverUrl) {
289
287
  return __awaiter(this, void 0, void 0, function () {
290
288
  var accAddress, hexAccAddress, axiosInstance, path, result, finalData, account, error_1;
291
289
  return __generator(this, function (_a) {
@@ -295,7 +293,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
295
293
  accAddress = (0, encoding_1.fromBech32)(address).data;
296
294
  hexAccAddress = "0x01".concat(Buffer.from(accAddress).toString("hex"));
297
295
  axiosInstance = axios_1.default.create({
298
- baseURL: SigningStargateClient._endpoint,
296
+ baseURL: serverUrl,
299
297
  headers: {
300
298
  Accept: "application/json",
301
299
  },
@@ -306,7 +304,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
306
304
  case 1:
307
305
  result = _a.sent();
308
306
  finalData = result.data.result.response.value;
309
- account = any_1.Any.decode(Buffer.from(finalData, "base64"));
307
+ account = any_1.Any.decode(Uint8Array.from(Buffer.from(finalData, "base64")));
310
308
  return [2 /*return*/, (0, accounts_1.accountFromAny)(account)];
311
309
  case 2:
312
310
  error_1 = _a.sent();
@@ -316,7 +314,6 @@ var SigningStargateClient = /** @class */ (function (_super) {
316
314
  });
317
315
  });
318
316
  };
319
- SigningStargateClient._endpoint = "";
320
317
  return SigningStargateClient;
321
318
  }(StargateClient_1.StargateClient));
322
319
  exports.SigningStargateClient = SigningStargateClient;
@@ -1,2 +1,3 @@
1
1
  export * from './TxCommon';
2
2
  export * from './QueryCommon';
3
+ export * from './FirmaLedger';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./TxCommon"), exports);
18
18
  __exportStar(require("./QueryCommon"), exports);
19
+ __exportStar(require("./FirmaLedger"), exports);
@@ -6,14 +6,8 @@ export interface SignerData {
6
6
  readonly pubkey: Any;
7
7
  readonly sequence: number;
8
8
  }
9
- export declare function makeAuthInfoBytes(signers: ReadonlyArray<SignerData>, feeAmount: readonly Coin[], gasLimit: number, granter?: string, payer?: string, signMode?: SignMode): Uint8Array;
10
- export declare function makeSignDoc(bodyBytes: Uint8Array, authInfoBytes: Uint8Array, chainId: string, accountNumber: number): SignDoc;
9
+ export declare function makeAuthInfoBytes(signers: ReadonlyArray<SignerData>, feeAmount: readonly Coin[], gasLimit: bigint | number, granter?: string, payer?: string, signMode?: SignMode): Uint8Array;
10
+ export declare function makeSignDoc(bodyBytes: Uint8Array, authInfoBytes: Uint8Array, chainId: string, accountNumber: bigint | number): SignDoc;
11
11
  export declare function makeSignBytes(signDoc: SignDoc): Uint8Array;
12
- /**
13
- * Creates AuthInfo bytes for protobuf signing with enhanced type safety
14
- */
15
- export declare function makeAuthInfoBytesProtobuf(signers: ReadonlyArray<SignerData>, feeAmount: readonly Coin[], gasLimit: bigint | number, granter?: string, payer?: string): Uint8Array;
16
- /**
17
- * Creates a protobuf SignDoc with validation
18
- */
19
- export declare function makeSignDocProtobuf(bodyBytes: Uint8Array, authInfoBytes: Uint8Array, chainId: string, accountNumber: bigint | number): SignDoc;
12
+ export declare const makeAuthInfoBytesProtobuf: typeof makeAuthInfoBytes;
13
+ export declare const makeSignDocProtobuf: typeof makeSignDoc;
@@ -26,8 +26,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  exports.makeSignDocProtobuf = exports.makeAuthInfoBytesProtobuf = exports.makeSignBytes = exports.makeSignDoc = exports.makeAuthInfoBytes = void 0;
29
- /* eslint-disable @typescript-eslint/naming-convention */
30
- var coin_1 = require("cosmjs-types/cosmos/base/v1beta1/coin");
31
29
  var signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
32
30
  var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
33
31
  function makeSignerInfos(signers, signMode) {
@@ -46,7 +44,7 @@ function makeAuthInfoBytes(signers, feeAmount, gasLimit, granter, payer, signMod
46
44
  if (signMode === void 0) { signMode = signing_1.SignMode.SIGN_MODE_DIRECT; }
47
45
  var fee = tx_1.Fee.fromPartial({
48
46
  amount: __spreadArray([], __read(feeAmount), false),
49
- gasLimit: BigInt(gasLimit),
47
+ gasLimit: typeof gasLimit === "bigint" ? gasLimit : BigInt(gasLimit),
50
48
  granter: granter || "",
51
49
  payer: payer || "",
52
50
  });
@@ -58,60 +56,6 @@ function makeAuthInfoBytes(signers, feeAmount, gasLimit, granter, payer, signMod
58
56
  }
59
57
  exports.makeAuthInfoBytes = makeAuthInfoBytes;
60
58
  function makeSignDoc(bodyBytes, authInfoBytes, chainId, accountNumber) {
61
- return tx_1.SignDoc.fromPartial({
62
- bodyBytes: bodyBytes,
63
- authInfoBytes: authInfoBytes,
64
- chainId: chainId,
65
- accountNumber: BigInt(accountNumber),
66
- });
67
- }
68
- exports.makeSignDoc = makeSignDoc;
69
- function makeSignBytes(signDoc) {
70
- // Ensure all required fields are present
71
- if (!signDoc.bodyBytes || !signDoc.authInfoBytes || !signDoc.chainId || signDoc.accountNumber === undefined) {
72
- throw new Error("SignDoc is missing required fields");
73
- }
74
- var doc = tx_1.SignDoc.fromPartial({
75
- accountNumber: signDoc.accountNumber,
76
- authInfoBytes: signDoc.authInfoBytes,
77
- bodyBytes: signDoc.bodyBytes,
78
- chainId: signDoc.chainId,
79
- });
80
- return tx_1.SignDoc.encode(doc).finish();
81
- }
82
- exports.makeSignBytes = makeSignBytes;
83
- /**
84
- * Creates AuthInfo bytes for protobuf signing with enhanced type safety
85
- */
86
- function makeAuthInfoBytesProtobuf(signers, feeAmount, gasLimit, granter, payer) {
87
- var normalizedGasLimit = typeof gasLimit === 'bigint' ? gasLimit : BigInt(gasLimit);
88
- var fee = tx_1.Fee.fromPartial({
89
- amount: feeAmount.map(function (coin) { return coin_1.Coin.fromPartial(coin); }),
90
- gasLimit: normalizedGasLimit,
91
- granter: granter || "",
92
- payer: payer || "",
93
- });
94
- var signerInfos = signers.map(function (_a) {
95
- var pubkey = _a.pubkey, sequence = _a.sequence;
96
- return tx_1.SignerInfo.fromPartial({
97
- publicKey: pubkey,
98
- modeInfo: {
99
- single: { mode: signing_1.SignMode.SIGN_MODE_DIRECT },
100
- },
101
- sequence: BigInt(sequence),
102
- });
103
- });
104
- var authInfo = tx_1.AuthInfo.fromPartial({
105
- signerInfos: signerInfos,
106
- fee: fee,
107
- });
108
- return tx_1.AuthInfo.encode(authInfo).finish();
109
- }
110
- exports.makeAuthInfoBytesProtobuf = makeAuthInfoBytesProtobuf;
111
- /**
112
- * Creates a protobuf SignDoc with validation
113
- */
114
- function makeSignDocProtobuf(bodyBytes, authInfoBytes, chainId, accountNumber) {
115
59
  if (!bodyBytes || bodyBytes.length === 0) {
116
60
  throw new Error("bodyBytes cannot be empty");
117
61
  }
@@ -121,12 +65,21 @@ function makeSignDocProtobuf(bodyBytes, authInfoBytes, chainId, accountNumber) {
121
65
  if (!chainId) {
122
66
  throw new Error("chainId cannot be empty");
123
67
  }
124
- var normalizedAccountNumber = typeof accountNumber === 'bigint' ? accountNumber : BigInt(accountNumber);
125
68
  return tx_1.SignDoc.fromPartial({
126
69
  bodyBytes: bodyBytes,
127
70
  authInfoBytes: authInfoBytes,
128
71
  chainId: chainId,
129
- accountNumber: normalizedAccountNumber,
72
+ accountNumber: typeof accountNumber === "bigint" ? accountNumber : BigInt(accountNumber),
130
73
  });
131
74
  }
132
- exports.makeSignDocProtobuf = makeSignDocProtobuf;
75
+ exports.makeSignDoc = makeSignDoc;
76
+ function makeSignBytes(signDoc) {
77
+ if (!signDoc.bodyBytes || !signDoc.authInfoBytes || !signDoc.chainId || signDoc.accountNumber === undefined) {
78
+ throw new Error("SignDoc is missing required fields");
79
+ }
80
+ return tx_1.SignDoc.encode(signDoc).finish();
81
+ }
82
+ exports.makeSignBytes = makeSignBytes;
83
+ // Backward-compatible aliases for existing callers
84
+ exports.makeAuthInfoBytesProtobuf = makeAuthInfoBytes;
85
+ exports.makeSignDocProtobuf = makeSignDoc;
@@ -21,7 +21,7 @@ var ContractTxTypes_1 = require("./ContractTxTypes");
21
21
  var ITxClient_1 = require("../common/ITxClient");
22
22
  var types = [
23
23
  ["/firmachain.contract.MsgCreateContractFile", ContractTxTypes_1.MsgCreateContractFile],
24
- ["/firmachain.contract.MsgAddContractLog", ContractTxTypes_1.MsgAddContractLog]
24
+ ["/firmachain.contract.MsgAddContractLog", ContractTxTypes_1.MsgAddContractLog],
25
25
  ];
26
26
  var registry = new proto_signing_1.Registry(types);
27
27
  var ContractTxClient = /** @class */ (function (_super) {
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  var __values = (this && this.__values) || function(o) {
14
50
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
51
  if (m) return m.call(o);
@@ -448,17 +484,27 @@ var MsgClientImpl = /** @class */ (function () {
448
484
  this.rpc = rpc;
449
485
  }
450
486
  MsgClientImpl.prototype.CreateContractFile = function (request) {
451
- var data = exports.MsgCreateContractFile.encode(request).finish();
452
- var promise = this.rpc.request("firmachain.contract.Msg", "CreateContractFile", data);
453
- return promise.then(function (data) {
454
- return exports.MsgCreateContractFileResponse.decode(new minimal_1.Reader(data));
487
+ return __awaiter(this, void 0, void 0, function () {
488
+ var data, promise;
489
+ return __generator(this, function (_a) {
490
+ data = exports.MsgCreateContractFile.encode(request).finish();
491
+ promise = this.rpc.request("firmachain.contract.Msg", "CreateContractFile", data);
492
+ return [2 /*return*/, promise.then(function (data) {
493
+ return exports.MsgCreateContractFileResponse.decode(new minimal_1.Reader(data));
494
+ })];
495
+ });
455
496
  });
456
497
  };
457
498
  MsgClientImpl.prototype.AddContractLog = function (request) {
458
- var data = exports.MsgAddContractLog.encode(request).finish();
459
- var promise = this.rpc.request("firmachain.contract.Msg", "AddContractLog", data);
460
- return promise.then(function (data) {
461
- return exports.MsgAddContractLogResponse.decode(new minimal_1.Reader(data));
499
+ return __awaiter(this, void 0, void 0, function () {
500
+ var data, promise;
501
+ return __generator(this, function (_a) {
502
+ data = exports.MsgAddContractLog.encode(request).finish();
503
+ promise = this.rpc.request("firmachain.contract.Msg", "AddContractLog", data);
504
+ return [2 /*return*/, promise.then(function (data) {
505
+ return exports.MsgAddContractLogResponse.decode(new minimal_1.Reader(data));
506
+ })];
507
+ });
462
508
  });
463
509
  };
464
510
  return MsgClientImpl;
@@ -23,7 +23,7 @@ var types = [
23
23
  ["/cosmos.distribution.v1beta1.MsgFundCommunityPool", tx_1.MsgFundCommunityPool],
24
24
  ["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", tx_1.MsgSetWithdrawAddress],
25
25
  ["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", tx_1.MsgWithdrawDelegatorReward],
26
- ["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", tx_1.MsgWithdrawValidatorCommission]
26
+ ["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", tx_1.MsgWithdrawValidatorCommission],
27
27
  ];
28
28
  var registry = new proto_signing_1.Registry(types);
29
29
  var DistributionTxClient = /** @class */ (function (_super) {
@@ -19,9 +19,11 @@ exports.FeeGrantTxClient = void 0;
19
19
  var proto_signing_1 = require("@cosmjs/proto-signing");
20
20
  var FeeGrantTxTypes_1 = require("./FeeGrantTxTypes");
21
21
  var ITxClient_1 = require("../common/ITxClient");
22
+ // FeeGrantTxTypes are protobufjs-generated without a `decode` method, so they
23
+ // cannot satisfy GeneratedType directly.
22
24
  var types = [
23
25
  ["/cosmos.feegrant.v1beta1.MsgGrantAllowance", FeeGrantTxTypes_1.MsgGrantAllowance],
24
- ["/cosmos.feegrant.v1beta1.MsgRevokeAllowance", FeeGrantTxTypes_1.MsgRevokeAllowance]
26
+ ["/cosmos.feegrant.v1beta1.MsgRevokeAllowance", FeeGrantTxTypes_1.MsgRevokeAllowance],
25
27
  ];
26
28
  var registry = new proto_signing_1.Registry(types);
27
29
  var FeeGrantTxClient = /** @class */ (function (_super) {
@@ -1,4 +1,3 @@
1
- /// <reference types="long" />
2
1
  import { Any } from "../google/protobuf/any";
3
2
  import { BinaryWriter } from "cosmjs-types/binary";
4
3
  export interface MsgGrantAllowance {
@@ -28,7 +27,7 @@ export interface AllowedMsgAllowance {
28
27
  export declare const AllowedMsgAllowance: {
29
28
  encode(message: AllowedMsgAllowance, writer?: BinaryWriter): BinaryWriter;
30
29
  };
31
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long;
30
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
32
31
  export 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 {} ? {
33
32
  [K in keyof T]?: DeepPartial<T[K]>;
34
33
  } : Partial<T>;
@@ -91,17 +91,5 @@ var globalThis = (function () {
91
91
  return global;
92
92
  throw "Unable to locate global object";
93
93
  })();
94
- //const atob: (b64: string) => string =
95
- // globalThis.atob ||
96
- // ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
97
- function bytesFromBase64(b64) {
98
- //const bin = globalThis.Buffer.from(b64, "base64").toString("binary");
99
- var bin = atob(b64);
100
- var arr = new Uint8Array(bin.length);
101
- for (var i = 0; i < bin.length; ++i) {
102
- arr[i] = bin.charCodeAt(i);
103
- }
104
- return arr;
105
- }
106
94
  // If you get a compile-error about 'Constructor<Long> and ... have no overlap',
107
95
  // add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.
@@ -22,6 +22,9 @@ var tx_2 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1beta1/tx");
22
22
  // temporarly using kintsugi-tech/cosmjs-types - this will be returned to original cosmjs-types after the PR is merged
23
23
  var tx_3 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx");
24
24
  var ITxClient_1 = require("../common/ITxClient");
25
+ // @kintsugi-tech/cosmjs-types uses a different BinaryWriter than cosmjs-types,
26
+ // so these types are structurally incompatible with GeneratedType despite being
27
+ // functionally equivalent.
25
28
  var types = [
26
29
  ["/cosmos.gov.v1.MsgDeposit", tx_1.MsgDeposit],
27
30
  ["/cosmos.gov.v1.MsgSubmitProposal", tx_1.MsgSubmitProposal],
@@ -22,7 +22,7 @@ var ITxClient_1 = require("../common/ITxClient");
22
22
  var types = [
23
23
  ["/firmachain.nft.MsgTransfer", NftTxTypes_1.MsgTransfer],
24
24
  ["/firmachain.nft.MsgMint", NftTxTypes_1.MsgMint],
25
- ["/firmachain.nft.MsgBurn", NftTxTypes_1.MsgBurn]
25
+ ["/firmachain.nft.MsgBurn", NftTxTypes_1.MsgBurn],
26
26
  ];
27
27
  var registry = new proto_signing_1.Registry(types);
28
28
  var NftTxClient = /** @class */ (function (_super) {
@@ -85,6 +85,21 @@ export declare class StakingQueryClient {
85
85
  queryGetDelegationInfoFromValidator(address: string, validatorAddress: string): Promise<DelegationInfo>;
86
86
  queryGetTotalUndelegateInfo(address: string): Promise<UndelegationInfo[]>;
87
87
  querygetTotalRedelegationInfo(address: string): Promise<RedelegationInfo[]>;
88
+ /**
89
+ * Returns redelegations involving the given validator (as src or dst), aggregated
90
+ * across all delegators. The Cosmos SDK's gRPC `Redelegations` query accepts an
91
+ * empty `delegator_addr` together with `src_validator_addr` (or
92
+ * `dst_validator_addr`) to fetch chain-wide redelegations from / to a validator;
93
+ * this method exposes that capability through the standard REST URL with an
94
+ * empty delegator path segment.
95
+ *
96
+ * Two requests are issued (src filter + dst filter) and the results are merged
97
+ * with deduplication.
98
+ */
99
+ queryGetRedelegationListFromValidator(valoperAddress: string, paginationKey?: string): Promise<{
100
+ dataList: RedelegationInfo[];
101
+ pagination: Pagination;
102
+ }>;
88
103
  queryGetUndelegationListFromValidator(valoperAddress: string, paginationKey?: string): Promise<{
89
104
  dataList: UndelegationInfo[];
90
105
  pagination: Pagination;
@@ -35,6 +35,42 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
63
+ var __values = (this && this.__values) || function(o) {
64
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
65
+ if (m) return m.call(o);
66
+ if (o && typeof o.length === "number") return {
67
+ next: function () {
68
+ if (o && i >= o.length) o = void 0;
69
+ return { value: o && o[i++], done: !o };
70
+ }
71
+ };
72
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
73
+ };
38
74
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
75
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
76
  };
@@ -113,6 +149,79 @@ var StakingQueryClient = /** @class */ (function () {
113
149
  });
114
150
  });
115
151
  };
152
+ /**
153
+ * Returns redelegations involving the given validator (as src or dst), aggregated
154
+ * across all delegators. The Cosmos SDK's gRPC `Redelegations` query accepts an
155
+ * empty `delegator_addr` together with `src_validator_addr` (or
156
+ * `dst_validator_addr`) to fetch chain-wide redelegations from / to a validator;
157
+ * this method exposes that capability through the standard REST URL with an
158
+ * empty delegator path segment.
159
+ *
160
+ * Two requests are issued (src filter + dst filter) and the results are merged
161
+ * with deduplication.
162
+ */
163
+ StakingQueryClient.prototype.queryGetRedelegationListFromValidator = function (valoperAddress, paginationKey) {
164
+ if (paginationKey === void 0) { paginationKey = ""; }
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ var path, fetchByFilter, _a, fromList, toList, seen, merged, _b, _c, r, k;
167
+ var e_1, _d;
168
+ var _this = this;
169
+ return __generator(this, function (_e) {
170
+ switch (_e.label) {
171
+ case 0:
172
+ path = "/cosmos/staking/v1beta1/delegators//redelegations";
173
+ fetchByFilter = function (filterKey) { return __awaiter(_this, void 0, void 0, function () {
174
+ var params, result;
175
+ var _a;
176
+ return __generator(this, function (_b) {
177
+ switch (_b.label) {
178
+ case 0:
179
+ params = (_a = {},
180
+ _a[filterKey] = valoperAddress,
181
+ _a["pagination.limit"] = 1000,
182
+ _a);
183
+ if (paginationKey)
184
+ params["pagination.key"] = paginationKey;
185
+ return [4 /*yield*/, this.axios.get(path, { params: params })];
186
+ case 1:
187
+ result = _b.sent();
188
+ return [2 /*return*/, result.data.redelegation_responses || []];
189
+ }
190
+ });
191
+ }); };
192
+ return [4 /*yield*/, Promise.all([
193
+ fetchByFilter('src_validator_addr'),
194
+ fetchByFilter('dst_validator_addr'),
195
+ ])];
196
+ case 1:
197
+ _a = __read.apply(void 0, [_e.sent(), 2]), fromList = _a[0], toList = _a[1];
198
+ seen = new Set();
199
+ merged = [];
200
+ try {
201
+ for (_b = __values(__spreadArray(__spreadArray([], __read(fromList), false), __read(toList), false)), _c = _b.next(); !_c.done; _c = _b.next()) {
202
+ r = _c.value;
203
+ k = "".concat(r.redelegation.delegator_address, "|").concat(r.redelegation.validator_src_address, "|").concat(r.redelegation.validator_dst_address);
204
+ if (seen.has(k))
205
+ continue;
206
+ seen.add(k);
207
+ merged.push(r);
208
+ }
209
+ }
210
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
211
+ finally {
212
+ try {
213
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
214
+ }
215
+ finally { if (e_1) throw e_1.error; }
216
+ }
217
+ return [2 /*return*/, {
218
+ dataList: merged,
219
+ pagination: { next_key: '', total: merged.length },
220
+ }];
221
+ }
222
+ });
223
+ });
224
+ };
116
225
  StakingQueryClient.prototype.queryGetUndelegationListFromValidator = function (valoperAddress, paginationKey) {
117
226
  if (paginationKey === void 0) { paginationKey = ""; }
118
227
  return __awaiter(this, void 0, void 0, function () {
@@ -23,7 +23,7 @@ var types = [
23
23
  ["/firmachain.token.MsgCreateToken", TokenTxTypes_1.MsgCreateToken],
24
24
  ["/firmachain.token.MsgUpdateTokenURI", TokenTxTypes_1.MsgUpdateTokenURI],
25
25
  ["/firmachain.token.MsgMint", TokenTxTypes_1.MsgMint],
26
- ["/firmachain.token.MsgBurn", TokenTxTypes_1.MsgBurn]
26
+ ["/firmachain.token.MsgBurn", TokenTxTypes_1.MsgBurn],
27
27
  ];
28
28
  var registry = new proto_signing_1.Registry(types);
29
29
  var TokenTxClient = /** @class */ (function (_super) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.3.8",
3
+ "version": "0.4.0-beta2",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -8,12 +8,14 @@
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
- "test": "mocha test/**/*.test.ts -r ts-node/register --timeout 1200000",
11
+ "test:integration": "NODE_OPTIONS=--no-experimental-strip-types TS_NODE_TRANSPILE_ONLY=true mocha 'test/integration/**/*.test.ts'",
12
+ "test:ledger": "NODE_OPTIONS=--no-experimental-strip-types TS_NODE_TRANSPILE_ONLY=true mocha 'test/ledger/**/*.test.ts'",
12
13
  "lint": "eslint src test --ext .ts,.tsx",
13
14
  "nodemon": "nodemon",
14
15
  "dev": "ts-node ./test/test_index.ts",
15
16
  "clean": "rm -rf dist",
16
- "build": "npm run clean && tsc --module commonjs"
17
+ "build": "npm run clean && tsc --module commonjs",
18
+ "prepare": "npm run build"
17
19
  },
18
20
  "repository": {
19
21
  "type": "git",
@@ -38,25 +40,32 @@
38
40
  "@cosmjs/stargate": "0.34.0",
39
41
  "@cosmjs/tendermint-rpc": "0.34.0",
40
42
  "@kintsugi-tech/cosmjs-types": "^0.10.0",
43
+ "@ledgerhq/hw-transport-webhid": "^6.29.4",
41
44
  "@tharsis/address-converter": "0.1.8",
42
45
  "@types/pako": "2.0.0",
43
- "axios": "0.27.2",
46
+ "@zondax/ledger-cosmos-js": "^4.0.1",
47
+ "axios": "1.15.1",
44
48
  "bignumber.js": "^9.3.0",
45
49
  "cosmjs-types": "0.9.0",
46
- "crypto-js": "4.1.1",
50
+ "crypto-js": "4.2.0",
47
51
  "fast-deep-equal": "^3.1.3",
48
- "form-data": "4.0.0",
52
+ "form-data": "4.0.4",
49
53
  "pako": "2.0.2",
50
- "protobufjs": "6.10.2",
54
+ "protobufjs": "7.5.5",
51
55
  "readline-sync": "1.4.10"
52
56
  },
57
+ "overrides": {
58
+ "diff": "8.0.4",
59
+ "serialize-javascript": "7.0.5"
60
+ },
53
61
  "devDependencies": {
62
+ "@ledgerhq/hw-transport-node-hid": "^6.33.0",
54
63
  "@types/chai": "4.2.21",
55
64
  "@types/mocha": "9.0.0",
56
65
  "@types/node": "16.4.3",
57
66
  "chai": "4.3.4",
58
- "mocha": "9.1.1",
59
- "nodemon": "2.0.12",
67
+ "mocha": "11.7.5",
68
+ "nodemon": "3.1.14",
60
69
  "ts-node": "10.2.1",
61
70
  "typescript": "^4.9.5"
62
71
  }
@@ -1 +0,0 @@
1
- export {};