@keplr-wallet/background 0.12.313 → 0.13.0

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 (83) hide show
  1. package/build/index.d.ts +1 -0
  2. package/build/index.js +7 -1
  3. package/build/index.js.map +1 -1
  4. package/build/keyring-cosmos/service.d.ts +10 -0
  5. package/build/keyring-cosmos/service.js +100 -0
  6. package/build/keyring-cosmos/service.js.map +1 -1
  7. package/build/keyring-ethereum/service.d.ts +5 -0
  8. package/build/keyring-ethereum/service.js +66 -0
  9. package/build/keyring-ethereum/service.js.map +1 -1
  10. package/build/recent-send-history/api.d.ts +31 -0
  11. package/build/recent-send-history/api.js +97 -0
  12. package/build/recent-send-history/api.js.map +1 -0
  13. package/build/recent-send-history/handler.js +36 -0
  14. package/build/recent-send-history/handler.js.map +1 -1
  15. package/build/recent-send-history/init.js +5 -0
  16. package/build/recent-send-history/init.js.map +1 -1
  17. package/build/recent-send-history/messages.d.ts +76 -1
  18. package/build/recent-send-history/messages.js +121 -1
  19. package/build/recent-send-history/messages.js.map +1 -1
  20. package/build/recent-send-history/service.d.ts +262 -9
  21. package/build/recent-send-history/service.js +2103 -812
  22. package/build/recent-send-history/service.js.map +1 -1
  23. package/build/recent-send-history/types.d.ts +214 -22
  24. package/build/recent-send-history/types.js +21 -0
  25. package/build/recent-send-history/types.js.map +1 -1
  26. package/build/tx/service.d.ts +2 -0
  27. package/build/tx/service.js +35 -0
  28. package/build/tx/service.js.map +1 -1
  29. package/build/tx-ethereum/service.d.ts +2 -0
  30. package/build/tx-ethereum/service.js +42 -0
  31. package/build/tx-ethereum/service.js.map +1 -1
  32. package/build/tx-executor/constants.d.ts +1 -0
  33. package/build/tx-executor/constants.js +5 -0
  34. package/build/tx-executor/constants.js.map +1 -0
  35. package/build/tx-executor/handler.d.ts +3 -0
  36. package/build/tx-executor/handler.js +45 -0
  37. package/build/tx-executor/handler.js.map +1 -0
  38. package/build/tx-executor/index.d.ts +3 -0
  39. package/build/tx-executor/index.js +20 -0
  40. package/build/tx-executor/index.js.map +1 -0
  41. package/build/tx-executor/init.d.ts +3 -0
  42. package/build/tx-executor/init.js +14 -0
  43. package/build/tx-executor/init.js.map +1 -0
  44. package/build/tx-executor/internal.d.ts +4 -0
  45. package/build/tx-executor/internal.js +24 -0
  46. package/build/tx-executor/internal.js.map +1 -0
  47. package/build/tx-executor/messages.d.ts +53 -0
  48. package/build/tx-executor/messages.js +116 -0
  49. package/build/tx-executor/messages.js.map +1 -0
  50. package/build/tx-executor/service.d.ts +67 -0
  51. package/build/tx-executor/service.js +715 -0
  52. package/build/tx-executor/service.js.map +1 -0
  53. package/build/tx-executor/types.d.ts +105 -0
  54. package/build/tx-executor/types.js +33 -0
  55. package/build/tx-executor/types.js.map +1 -0
  56. package/build/tx-executor/utils/cosmos.d.ts +59 -0
  57. package/build/tx-executor/utils/cosmos.js +526 -0
  58. package/build/tx-executor/utils/cosmos.js.map +1 -0
  59. package/build/tx-executor/utils/evm.d.ts +4 -0
  60. package/build/tx-executor/utils/evm.js +236 -0
  61. package/build/tx-executor/utils/evm.js.map +1 -0
  62. package/package.json +13 -13
  63. package/src/index.ts +24 -1
  64. package/src/keyring-cosmos/service.ts +151 -0
  65. package/src/keyring-ethereum/service.ts +103 -6
  66. package/src/recent-send-history/api.ts +119 -0
  67. package/src/recent-send-history/handler.ts +84 -0
  68. package/src/recent-send-history/init.ts +10 -0
  69. package/src/recent-send-history/messages.ts +163 -1
  70. package/src/recent-send-history/service.ts +3042 -1153
  71. package/src/recent-send-history/types.ts +268 -31
  72. package/src/tx/service.ts +41 -0
  73. package/src/tx-ethereum/service.ts +57 -0
  74. package/src/tx-executor/constants.ts +1 -0
  75. package/src/tx-executor/handler.ts +71 -0
  76. package/src/tx-executor/index.ts +3 -0
  77. package/src/tx-executor/init.ts +20 -0
  78. package/src/tx-executor/internal.ts +9 -0
  79. package/src/tx-executor/messages.ts +157 -0
  80. package/src/tx-executor/service.ts +1025 -0
  81. package/src/tx-executor/types.ts +161 -0
  82. package/src/tx-executor/utils/cosmos.ts +771 -0
  83. package/src/tx-executor/utils/evm.ts +310 -0
@@ -0,0 +1,161 @@
1
+ import { UnsignedTransaction } from "@ethersproject/transactions";
2
+ import { StdFee } from "@keplr-wallet/types";
3
+ import { Any } from "@keplr-wallet/proto-types/google/protobuf/any";
4
+ import { Msg } from "@keplr-wallet/types";
5
+ import { SwapV2HistoryData } from "../recent-send-history";
6
+
7
+ export {
8
+ SwapProvider,
9
+ SwapV2HistoryData,
10
+ IBCSwapMinimalTrackingData,
11
+ } from "../recent-send-history";
12
+
13
+ // Transaction status
14
+ export enum BackgroundTxStatus {
15
+ PENDING = "pending",
16
+ CONFIRMED = "confirmed",
17
+ FAILED = "failed",
18
+ BLOCKED = "blocked",
19
+ }
20
+
21
+ // Transaction type
22
+ export enum BackgroundTxType {
23
+ EVM = "evm",
24
+ COSMOS = "cosmos",
25
+ }
26
+
27
+ // Base transaction interface
28
+ interface BackgroundTxBase {
29
+ readonly chainId: string;
30
+
31
+ status: BackgroundTxStatus;
32
+ feeType?: BackgroundTxFeeType;
33
+ feeCurrencyDenom?: string;
34
+
35
+ // Cosmos: base64 encoded, EVM: hex encoded (0x prefix)
36
+ signedTx?: string;
37
+
38
+ // Transaction hash for completed tx
39
+ txHash?: string;
40
+
41
+ // Error message if failed
42
+ error?: string;
43
+ }
44
+
45
+ export interface EVMBackgroundTx extends BackgroundTxBase {
46
+ readonly type: BackgroundTxType.EVM;
47
+ txData: UnsignedTransaction;
48
+ }
49
+
50
+ export interface CosmosBackgroundTx extends BackgroundTxBase {
51
+ readonly type: BackgroundTxType.COSMOS;
52
+ txData: {
53
+ aminoMsgs?: Msg[];
54
+ protoMsgs: Any[];
55
+
56
+ // Add rlp types data if you need to support ethermint with ledger.
57
+ // Must include `MsgValue`.
58
+ rlpTypes?: Record<
59
+ string,
60
+ Array<{
61
+ name: string;
62
+ type: string;
63
+ }>
64
+ >;
65
+
66
+ fee?: StdFee;
67
+ memo?: string;
68
+ };
69
+ }
70
+
71
+ // Single transaction data with discriminated union based on type
72
+ export type BackgroundTx = EVMBackgroundTx | CosmosBackgroundTx;
73
+
74
+ export enum TxExecutionStatus {
75
+ PENDING = "pending",
76
+ PROCESSING = "processing",
77
+ BLOCKED = "blocked",
78
+ COMPLETED = "completed",
79
+ FAILED = "failed",
80
+ }
81
+
82
+ export enum TxExecutionType {
83
+ UNDEFINED = "undefined",
84
+ SWAP_V2 = "swap-v2",
85
+ }
86
+
87
+ export type BackgroundTxFeeType = "low" | "average" | "high";
88
+
89
+ export interface TxExecutionBase {
90
+ readonly id: string;
91
+ status: TxExecutionStatus;
92
+
93
+ // keyring vault id
94
+ readonly vaultId: string;
95
+
96
+ // transactions
97
+ readonly txs: BackgroundTx[];
98
+ txIndex: number; // Current transaction being processed
99
+
100
+ executableChainIds: string[]; // executable chain ids
101
+
102
+ readonly timestamp: number; // Timestamp when execution started
103
+
104
+ // If true, automatic signing is prevented and this execution may be blocked.
105
+ // This happens when:
106
+ // 1. Some txs are not immediately executable (chainId not in executableChainIds)
107
+ // 2. Hardware wallet (ledger/keystone) - requires user interaction for signing
108
+ // When preventAutoSign is true, the execution will be persisted to KVStore.
109
+ readonly preventAutoSign: boolean;
110
+
111
+ readonly historyTxIndex?: number;
112
+ }
113
+
114
+ export interface UndefinedTxExecution extends TxExecutionBase {
115
+ readonly type: TxExecutionType.UNDEFINED;
116
+ historyData?: never;
117
+ }
118
+
119
+ export interface SwapV2TxExecution extends TxExecutionBase {
120
+ readonly type: TxExecutionType.SWAP_V2;
121
+ historyData?: SwapV2HistoryData;
122
+
123
+ historyId?: string;
124
+ }
125
+
126
+ export type ExecutionTypeToHistoryData = {
127
+ [TxExecutionType.SWAP_V2]: SwapV2HistoryData;
128
+ [TxExecutionType.UNDEFINED]: undefined;
129
+ };
130
+
131
+ export type TxExecution = UndefinedTxExecution | SwapV2TxExecution;
132
+
133
+ export type TxExecutionEvent =
134
+ | {
135
+ type: "executable";
136
+ executionId: string;
137
+ executableChainIds: string[];
138
+ }
139
+ | {
140
+ type: "remove";
141
+ executionId: string;
142
+ };
143
+
144
+ /**
145
+ * Result of executing a single pending transaction.
146
+ * Used to batch state updates and reduce autorun triggers.
147
+ */
148
+ export interface PendingTxExecutionResult {
149
+ status: BackgroundTxStatus;
150
+ txHash?: string;
151
+ error?: string;
152
+ }
153
+
154
+ /**
155
+ * Result of executing a single transaction.
156
+ * Used to batch state updates and reduce autorun triggers.
157
+ */
158
+ export interface TxExecutionResult {
159
+ status: TxExecutionStatus;
160
+ error?: string;
161
+ }