@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.
Files changed (128) 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.js +12 -9
  17. package/dist/sdk/FirmaTokenService.js +17 -14
  18. package/dist/sdk/FirmaUtil.js +1 -1
  19. package/dist/sdk/FirmaWalletService.d.ts +1 -1
  20. package/dist/sdk/FirmaWalletService.js +11 -23
  21. package/dist/sdk/firmachain/authz/AuthzTxClient.js +2 -0
  22. package/dist/sdk/firmachain/bank/BankTxClient.js +1 -1
  23. package/dist/sdk/firmachain/common/CommonTxClient.js +3 -1
  24. package/dist/sdk/firmachain/common/FirmaLedger.d.ts +49 -0
  25. package/dist/sdk/firmachain/common/FirmaLedger.js +301 -0
  26. package/dist/sdk/firmachain/common/ITxClient.d.ts +1 -1
  27. package/dist/sdk/firmachain/common/ITxClient.js +6 -4
  28. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +5 -13
  29. package/dist/sdk/firmachain/common/LedgerWallet.js +1266 -124
  30. package/dist/sdk/firmachain/common/SigningProtobufStargateClient.js +3 -4
  31. package/dist/sdk/firmachain/common/SigningStargateClient.d.ts +2 -3
  32. package/dist/sdk/firmachain/common/SigningStargateClient.js +7 -10
  33. package/dist/sdk/firmachain/common/index.d.ts +1 -0
  34. package/dist/sdk/firmachain/common/index.js +1 -0
  35. package/dist/sdk/firmachain/common/signing.d.ts +4 -10
  36. package/dist/sdk/firmachain/common/signing.js +13 -60
  37. package/dist/sdk/firmachain/contract/ContractTxClient.js +1 -1
  38. package/dist/sdk/firmachain/contract/ContractTxTypes.js +54 -8
  39. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +1 -1
  40. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +3 -1
  41. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +1 -2
  42. package/dist/sdk/firmachain/google/protobuf/any.js +0 -12
  43. package/dist/sdk/firmachain/gov/GovTxClient.js +3 -0
  44. package/dist/sdk/firmachain/nft/NftTxClient.js +1 -1
  45. package/dist/sdk/firmachain/token/TokenTxClient.js +1 -1
  46. package/package.json +16 -8
  47. package/dist/test/00.wallet.test.d.ts +0 -1
  48. package/dist/test/00.wallet.test.js +0 -96
  49. package/dist/test/01.contract_tx.test.d.ts +0 -1
  50. package/dist/test/01.contract_tx.test.js +0 -157
  51. package/dist/test/02.contract_query.test.d.ts +0 -1
  52. package/dist/test/02.contract_query.test.js +0 -245
  53. package/dist/test/03.contract_scenario.test.d.ts +0 -1
  54. package/dist/test/03.contract_scenario.test.js +0 -406
  55. package/dist/test/04.bank_tx.test.d.ts +0 -1
  56. package/dist/test/04.bank_tx.test.js +0 -126
  57. package/dist/test/05.bank_query.test.d.ts +0 -1
  58. package/dist/test/05.bank_query.test.js +0 -162
  59. package/dist/test/06.feegrant_tx.test.d.ts +0 -1
  60. package/dist/test/06.feegrant_tx.test.js +0 -185
  61. package/dist/test/07.feegrant_query.test.d.ts +0 -1
  62. package/dist/test/07.feegrant_query.test.js +0 -129
  63. package/dist/test/08.gas_estimate.test.d.ts +0 -1
  64. package/dist/test/08.gas_estimate.test.js +0 -728
  65. package/dist/test/09.ipfs.test.d.ts +0 -1
  66. package/dist/test/09.ipfs.test.js +0 -72
  67. package/dist/test/10.nft_tx.test.d.ts +0 -1
  68. package/dist/test/10.nft_tx.test.js +0 -209
  69. package/dist/test/11.nft_query.test.d.ts +0 -1
  70. package/dist/test/11.nft_query.test.js +0 -165
  71. package/dist/test/12.staking_tx.test.d.ts +0 -1
  72. package/dist/test/12.staking_tx.test.js +0 -211
  73. package/dist/test/13.staking_query.test.d.ts +0 -1
  74. package/dist/test/13.staking_query.test.js +0 -275
  75. package/dist/test/14.distribution_tx.test.d.ts +0 -1
  76. package/dist/test/14.distribution_tx.test.js +0 -170
  77. package/dist/test/15.distribution_query.test.d.ts +0 -1
  78. package/dist/test/15.distribution_query.test.js +0 -243
  79. package/dist/test/16.gov_tx.test.d.ts +0 -1
  80. package/dist/test/16.gov_tx.test.js +0 -394
  81. package/dist/test/17.gov_query.test.d.ts +0 -1
  82. package/dist/test/17.gov_query.test.js +0 -181
  83. package/dist/test/18.util.test.d.ts +0 -1
  84. package/dist/test/18.util.test.js +0 -354
  85. package/dist/test/19.chain.test.d.ts +0 -1
  86. package/dist/test/19.chain.test.js +0 -127
  87. package/dist/test/20.slashing_query.test.d.ts +0 -1
  88. package/dist/test/20.slashing_query.test.js +0 -111
  89. package/dist/test/21.token_tx.test.d.ts +0 -1
  90. package/dist/test/21.token_tx.test.js +0 -149
  91. package/dist/test/22.token_query.test.d.ts +0 -1
  92. package/dist/test/22.token_query.test.js +0 -103
  93. package/dist/test/23.authz_tx.test.d.ts +0 -1
  94. package/dist/test/23.authz_tx.test.js +0 -380
  95. package/dist/test/24.authz_query.test.d.ts +0 -1
  96. package/dist/test/24.authz_query.test.js +0 -202
  97. package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
  98. package/dist/test/25.cosmwasm_tx.test.js +0 -229
  99. package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
  100. package/dist/test/26.cosmwasm_query.test.js +0 -275
  101. package/dist/test/27.arbitrary_sign.test.d.ts +0 -1
  102. package/dist/test/27.arbitrary_sign.test.js +0 -162
  103. package/dist/test/28.ibc_tx.test.d.ts +0 -1
  104. package/dist/test/28.ibc_tx.test.js +0 -98
  105. package/dist/test/29.mint_query.test.d.ts +0 -1
  106. package/dist/test/29.mint_query.test.js +0 -59
  107. package/dist/test/30.cw20_tx.test.d.ts +0 -1
  108. package/dist/test/30.cw20_tx.test.js +0 -450
  109. package/dist/test/31.cw20_query.test.d.ts +0 -1
  110. package/dist/test/31.cw20_query.test.js +0 -333
  111. package/dist/test/32.cw721_tx.test.d.ts +0 -1
  112. package/dist/test/32.cw721_tx.test.js +0 -431
  113. package/dist/test/33.cw721_query.test.d.ts +0 -1
  114. package/dist/test/33.cw721_query.test.js +0 -371
  115. package/dist/test/34.cw_bridge_tx.test.d.ts +0 -1
  116. package/dist/test/34.cw_bridge_tx.test.js +0 -476
  117. package/dist/test/35.cw_bridge_tx_low.test.d.ts +0 -1
  118. package/dist/test/35.cw_bridge_tx_low.test.js +0 -398
  119. package/dist/test/36.cw_bridge_query.test.d.ts +0 -1
  120. package/dist/test/36.cw_bridge_query.test.js +0 -318
  121. package/dist/test/37.cw_marketplace_tx.test.d.ts +0 -1
  122. package/dist/test/37.cw_marketplace_tx.test.js +0 -794
  123. package/dist/test/38.cw_marketplace_query.test.d.ts +0 -1
  124. package/dist/test/38.cw_marketplace_query.test.js +0 -128
  125. package/dist/test/config_test.d.ts +0 -11
  126. package/dist/test/config_test.js +0 -26
  127. package/dist/test/config_test.sample.d.ts +0 -11
  128. 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) {
@@ -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-beta1",
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,7 +8,8 @@
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",
@@ -38,25 +39,32 @@
38
39
  "@cosmjs/stargate": "0.34.0",
39
40
  "@cosmjs/tendermint-rpc": "0.34.0",
40
41
  "@kintsugi-tech/cosmjs-types": "^0.10.0",
42
+ "@ledgerhq/hw-transport-webhid": "^6.29.4",
41
43
  "@tharsis/address-converter": "0.1.8",
42
44
  "@types/pako": "2.0.0",
43
- "axios": "0.27.2",
45
+ "@zondax/ledger-cosmos-js": "^4.0.1",
46
+ "axios": "1.15.1",
44
47
  "bignumber.js": "^9.3.0",
45
48
  "cosmjs-types": "0.9.0",
46
- "crypto-js": "4.1.1",
49
+ "crypto-js": "4.2.0",
47
50
  "fast-deep-equal": "^3.1.3",
48
- "form-data": "4.0.0",
51
+ "form-data": "4.0.4",
49
52
  "pako": "2.0.2",
50
- "protobufjs": "6.10.2",
53
+ "protobufjs": "7.5.5",
51
54
  "readline-sync": "1.4.10"
52
55
  },
56
+ "overrides": {
57
+ "diff": "8.0.4",
58
+ "serialize-javascript": "7.0.5"
59
+ },
53
60
  "devDependencies": {
61
+ "@ledgerhq/hw-transport-node-hid": "^6.33.0",
54
62
  "@types/chai": "4.2.21",
55
63
  "@types/mocha": "9.0.0",
56
64
  "@types/node": "16.4.3",
57
65
  "chai": "4.3.4",
58
- "mocha": "9.1.1",
59
- "nodemon": "2.0.12",
66
+ "mocha": "11.7.5",
67
+ "nodemon": "3.1.14",
60
68
  "ts-node": "10.2.1",
61
69
  "typescript": "^4.9.5"
62
70
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,96 +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('[00. Wallet Test]', function () {
43
- var firma;
44
- var aliceWallet;
45
- beforeEach(function () {
46
- return __awaiter(this, void 0, void 0, function () {
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0:
50
- firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
51
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
52
- case 1:
53
- aliceWallet = _a.sent();
54
- return [2 /*return*/];
55
- }
56
- });
57
- });
58
- });
59
- it('fromMnemonic check', function () { return __awaiter(void 0, void 0, void 0, function () {
60
- return __generator(this, function (_a) {
61
- (0, chai_1.expect)(aliceWallet.getMnemonic()).to.equal(config_test_1.aliceMnemonic);
62
- return [2 /*return*/];
63
- });
64
- }); });
65
- it('Wallet.fromPrivateKey check', function () { return __awaiter(void 0, void 0, void 0, function () {
66
- var privateKey, privateKeyFromWallet;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- privateKey = "0x15bc0d2e445ef5b13f9d3c6d227f21524fd05d5afda713d1aff1ecc8db49a62d";
71
- return [4 /*yield*/, firma.Wallet.fromPrivateKey(privateKey)];
72
- case 1:
73
- privateKeyFromWallet = (_a.sent()).getPrivateKey();
74
- (0, chai_1.expect)(privateKeyFromWallet).to.equal(privateKey);
75
- return [2 /*return*/];
76
- }
77
- });
78
- }); });
79
- it('Wallet.getPubKey check with new mnemonic', function () { return __awaiter(void 0, void 0, void 0, function () {
80
- var randomMnemonic, wallet, pubkey;
81
- return __generator(this, function (_a) {
82
- switch (_a.label) {
83
- case 0:
84
- randomMnemonic = "inmate stock silly toy divide example orchard harbor pulse gasp acquire bulk predict spin salon quiz record office party today narrow crumble remember sing";
85
- return [4 /*yield*/, firma.Wallet.fromMnemonic(randomMnemonic)];
86
- case 1:
87
- wallet = _a.sent();
88
- return [4 /*yield*/, wallet.getPubKey()];
89
- case 2:
90
- pubkey = _a.sent();
91
- (0, chai_1.expect)(pubkey).to.equal("AvzyjjaXumyGNQR1DRkDdozJge+MPJPFuNaMr+DAK2ks");
92
- return [2 /*return*/];
93
- }
94
- });
95
- }); });
96
- });
@@ -1 +0,0 @@
1
- export {};