@injectivelabs/wallet-core 0.0.2

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 (76) hide show
  1. package/README.md +77 -0
  2. package/dist/cjs/broadcaster/MsgBroadcaster.d.ts +125 -0
  3. package/dist/cjs/broadcaster/MsgBroadcaster.d.ts.map +1 -0
  4. package/dist/cjs/broadcaster/MsgBroadcaster.js +703 -0
  5. package/dist/cjs/broadcaster/MsgBroadcaster.js.map +1 -0
  6. package/dist/cjs/broadcaster/Web3Broadcaster.d.ts +30 -0
  7. package/dist/cjs/broadcaster/Web3Broadcaster.d.ts.map +1 -0
  8. package/dist/cjs/broadcaster/Web3Broadcaster.js +41 -0
  9. package/dist/cjs/broadcaster/Web3Broadcaster.js.map +1 -0
  10. package/dist/cjs/broadcaster/index.d.ts +4 -0
  11. package/dist/cjs/broadcaster/index.d.ts.map +1 -0
  12. package/dist/cjs/broadcaster/index.js +20 -0
  13. package/dist/cjs/broadcaster/index.js.map +1 -0
  14. package/dist/cjs/broadcaster/types.d.ts +33 -0
  15. package/dist/cjs/broadcaster/types.d.ts.map +1 -0
  16. package/dist/cjs/broadcaster/types.js +3 -0
  17. package/dist/cjs/broadcaster/types.js.map +1 -0
  18. package/dist/cjs/index.d.ts +4 -0
  19. package/dist/cjs/index.d.ts.map +1 -0
  20. package/dist/cjs/index.js +20 -0
  21. package/dist/cjs/index.js.map +1 -0
  22. package/dist/cjs/package.json +3 -0
  23. package/dist/cjs/strategy/BaseWalletStrategy.d.ts +45 -0
  24. package/dist/cjs/strategy/BaseWalletStrategy.d.ts.map +1 -0
  25. package/dist/cjs/strategy/BaseWalletStrategy.js +154 -0
  26. package/dist/cjs/strategy/BaseWalletStrategy.js.map +1 -0
  27. package/dist/cjs/strategy/index.d.ts +3 -0
  28. package/dist/cjs/strategy/index.d.ts.map +1 -0
  29. package/dist/cjs/strategy/index.js +9 -0
  30. package/dist/cjs/strategy/index.js.map +1 -0
  31. package/dist/cjs/utils/index.d.ts +2 -0
  32. package/dist/cjs/utils/index.d.ts.map +1 -0
  33. package/dist/cjs/utils/index.js +18 -0
  34. package/dist/cjs/utils/index.js.map +1 -0
  35. package/dist/cjs/utils/tx.d.ts +2 -0
  36. package/dist/cjs/utils/tx.d.ts.map +1 -0
  37. package/dist/cjs/utils/tx.js +12 -0
  38. package/dist/cjs/utils/tx.js.map +1 -0
  39. package/dist/esm/broadcaster/MsgBroadcaster.d.ts +125 -0
  40. package/dist/esm/broadcaster/MsgBroadcaster.d.ts.map +1 -0
  41. package/dist/esm/broadcaster/MsgBroadcaster.js +704 -0
  42. package/dist/esm/broadcaster/MsgBroadcaster.js.map +1 -0
  43. package/dist/esm/broadcaster/Web3Broadcaster.d.ts +30 -0
  44. package/dist/esm/broadcaster/Web3Broadcaster.d.ts.map +1 -0
  45. package/dist/esm/broadcaster/Web3Broadcaster.js +28 -0
  46. package/dist/esm/broadcaster/Web3Broadcaster.js.map +1 -0
  47. package/dist/esm/broadcaster/index.d.ts +4 -0
  48. package/dist/esm/broadcaster/index.d.ts.map +1 -0
  49. package/dist/esm/broadcaster/index.js +4 -0
  50. package/dist/esm/broadcaster/index.js.map +1 -0
  51. package/dist/esm/broadcaster/types.d.ts +33 -0
  52. package/dist/esm/broadcaster/types.d.ts.map +1 -0
  53. package/dist/esm/broadcaster/types.js +2 -0
  54. package/dist/esm/broadcaster/types.js.map +1 -0
  55. package/dist/esm/index.d.ts +4 -0
  56. package/dist/esm/index.d.ts.map +1 -0
  57. package/dist/esm/index.js +4 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/package.json +3 -0
  60. package/dist/esm/strategy/BaseWalletStrategy.d.ts +45 -0
  61. package/dist/esm/strategy/BaseWalletStrategy.d.ts.map +1 -0
  62. package/dist/esm/strategy/BaseWalletStrategy.js +121 -0
  63. package/dist/esm/strategy/BaseWalletStrategy.js.map +1 -0
  64. package/dist/esm/strategy/index.d.ts +3 -0
  65. package/dist/esm/strategy/index.d.ts.map +1 -0
  66. package/dist/esm/strategy/index.js +3 -0
  67. package/dist/esm/strategy/index.js.map +1 -0
  68. package/dist/esm/utils/index.d.ts +2 -0
  69. package/dist/esm/utils/index.d.ts.map +1 -0
  70. package/dist/esm/utils/index.js +2 -0
  71. package/dist/esm/utils/index.js.map +1 -0
  72. package/dist/esm/utils/tx.d.ts +2 -0
  73. package/dist/esm/utils/tx.d.ts.map +1 -0
  74. package/dist/esm/utils/tx.js +8 -0
  75. package/dist/esm/utils/tx.js.map +1 -0
  76. package/package.json +57 -0
@@ -0,0 +1,125 @@
1
+ import { TxResponse } from '@injectivelabs/sdk-ts';
2
+ import { NetworkEndpoints } from '@injectivelabs/networks';
3
+ import { ChainId, EthereumChainId } from '@injectivelabs/ts-types';
4
+ import { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types';
5
+ import BaseWalletStrategy from '../strategy/BaseWalletStrategy';
6
+ /**
7
+ * This class is used to broadcast transactions
8
+ * using the WalletStrategy as a handler
9
+ * for the sign/broadcast flow of the transactions
10
+ *
11
+ * Mainly used for building UI products
12
+ */
13
+ export declare class MsgBroadcaster {
14
+ options: MsgBroadcasterOptions;
15
+ walletStrategy: BaseWalletStrategy;
16
+ endpoints: NetworkEndpoints;
17
+ chainId: ChainId;
18
+ txTimeout: number;
19
+ simulateTx: boolean;
20
+ txTimeoutOnFeeDelegation: boolean;
21
+ ethereumChainId?: EthereumChainId;
22
+ gasBufferCoefficient: number;
23
+ constructor(options: MsgBroadcasterOptions);
24
+ setOptions(options: Partial<MsgBroadcasterOptions>): void;
25
+ /**
26
+ * Broadcasting the transaction using the client
27
+ * side approach for both cosmos and ethereum native wallets
28
+ *
29
+ * @param tx
30
+ * @returns {string} transaction hash
31
+ */
32
+ broadcast(tx: MsgBroadcasterTxOptions): Promise<TxResponse>;
33
+ /**
34
+ * Broadcasting the transaction using the client
35
+ * side approach for both cosmos and ethereum native wallets
36
+ * Note: using EIP712_V2 for Ethereum wallets
37
+ *
38
+ * @param tx
39
+ * @returns {string} transaction hash
40
+ */
41
+ broadcastV2(tx: MsgBroadcasterTxOptions): Promise<TxResponse>;
42
+ /**
43
+ * Broadcasting the transaction using the feeDelegation
44
+ * support approach for both cosmos and ethereum native wallets
45
+ *
46
+ * @param tx
47
+ * @returns {string} transaction hash
48
+ */
49
+ broadcastWithFeeDelegation(tx: MsgBroadcasterTxOptions): Promise<TxResponse>;
50
+ /**
51
+ * Prepare/sign/broadcast transaction using
52
+ * Ethereum native wallets on the client side.
53
+ *
54
+ * Note: Gas estimation not available
55
+ *
56
+ * @param tx The transaction that needs to be broadcasted
57
+ * @returns transaction hash
58
+ */
59
+ private broadcastWeb3;
60
+ /**
61
+ * Prepare/sign/broadcast transaction using
62
+ * Ethereum native wallets on the client side.
63
+ *
64
+ * Note: Gas estimation not available
65
+ *
66
+ * @param tx The transaction that needs to be broadcasted
67
+ * @returns transaction hash
68
+ */
69
+ private broadcastWeb3V2;
70
+ /**
71
+ * Prepare/sign/broadcast transaction using
72
+ * Ethereum native wallets using the Web3Gateway.
73
+ *
74
+ * @param tx The transaction that needs to be broadcasted
75
+ * @returns transaction hash
76
+ */
77
+ private broadcastWeb3WithFeeDelegation;
78
+ /**
79
+ * Prepare/sign/broadcast transaction using
80
+ * Cosmos native wallets on the client side.
81
+ *
82
+ * @param tx The transaction that needs to be broadcasted
83
+ * @returns transaction hash
84
+ */
85
+ private broadcastCosmos;
86
+ /**
87
+ * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
88
+ *
89
+ * Note: Gas estimation not available
90
+ * @param tx the transaction that needs to be broadcasted
91
+ */
92
+ private experimentalBroadcastWalletThroughLedger;
93
+ /**
94
+ * Prepare/sign/broadcast transaction using
95
+ * Cosmos native wallets using the Web3Gateway.
96
+ *
97
+ * @param tx The transaction that needs to be broadcasted
98
+ * @returns transaction hash
99
+ */
100
+ private broadcastCosmosWithFeeDelegation;
101
+ /**
102
+ * Fetch the fee payer's pub key from the web3 gateway
103
+ *
104
+ * Returns a base64 version of it
105
+ */
106
+ private fetchFeePayerPubKey;
107
+ /**
108
+ * In case we don't want to simulate the transaction
109
+ * we get the gas limit based on the message type.
110
+ *
111
+ * If we want to simulate the transaction we set the
112
+ * gas limit based on the simulation and add a small multiplier
113
+ * to be safe (factor of 1.2 as default)
114
+ */
115
+ private getTxWithSignersAndStdFee;
116
+ /**
117
+ * Create TxRaw and simulate it
118
+ */
119
+ private simulateTxRaw;
120
+ /**
121
+ * Create TxRaw and simulate it
122
+ */
123
+ private simulateTxWithSigners;
124
+ }
125
+ //# sourceMappingURL=MsgBroadcaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgBroadcaster.d.ts","sourceRoot":"","sources":["../../../src/broadcaster/MsgBroadcaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,EAoBX,MAAM,uBAAuB,CAAA;AAY9B,OAAO,EAEL,gBAAgB,EAEjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EAExB,MAAM,SAAS,CAAA;AAYhB,OAAO,kBAAkB,MAAM,gCAAgC,CAAA;AAkB/D;;;;;;GAMG;AACH,qBAAa,cAAc;IAClB,OAAO,EAAE,qBAAqB,CAAA;IAE9B,cAAc,EAAE,kBAAkB,CAAA;IAElC,SAAS,EAAE,gBAAgB,CAAA;IAE3B,OAAO,EAAE,OAAO,CAAA;IAEhB,SAAS,SAA+B;IAExC,UAAU,EAAE,OAAO,CAAO;IAE1B,wBAAwB,EAAE,OAAO,CAAQ;IAEzC,eAAe,CAAC,EAAE,eAAe,CAAA;IAEjC,oBAAoB,EAAE,MAAM,CAAM;gBAE7B,OAAO,EAAE,qBAAqB;IAmB1C,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAOlD;;;;;;OAMG;IACG,SAAS,CAAC,EAAE,EAAE,uBAAuB;IAqB3C;;;;;;;OAOG;IACG,WAAW,CAAC,EAAE,EAAE,uBAAuB;IAmB7C;;;;;;OAMG;IACG,0BAA0B,CAAC,EAAE,EAAE,uBAAuB;IAmB5D;;;;;;;;OAQG;YACW,aAAa;IAuG3B;;;;;;;;OAQG;YACW,eAAe;IAsG7B;;;;;;OAMG;YACW,8BAA8B;IA2F5C;;;;;;OAMG;YACW,eAAe;IA8F7B;;;;;OAKG;YACW,wCAAwC;IAoItD;;;;;;OAMG;YACW,gCAAgC;IAqH9C;;;;OAIG;YACW,mBAAmB;IA0BjC;;;;;;;OAOG;YACW,yBAAyB;IAuCvC;;OAEG;YACW,aAAa;IAY3B;;OAEG;YACW,qBAAqB;CAcpC"}