@keplr-wallet/background 0.12.313 → 0.13.1

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,157 @@
1
+ import { KeplrError, Message } from "@keplr-wallet/router";
2
+ import { ROUTE } from "./constants";
3
+ import {
4
+ BackgroundTx,
5
+ BackgroundTxStatus,
6
+ TxExecutionType,
7
+ TxExecution,
8
+ ExecutionTypeToHistoryData,
9
+ TxExecutionResult,
10
+ IBCSwapMinimalTrackingData,
11
+ } from "./types";
12
+
13
+ /**
14
+ * Record and execute multiple transactions
15
+ * execution id is returned if the transactions are recorded successfully
16
+ * and the execution will be started automatically after the transactions are recorded.
17
+ */
18
+ export class RecordAndExecuteTxsMsg<
19
+ T extends TxExecutionType = TxExecutionType
20
+ > extends Message<TxExecutionResult> {
21
+ public static type() {
22
+ return "record-and-execute-txs";
23
+ }
24
+
25
+ constructor(
26
+ public readonly vaultId: string,
27
+ public readonly executionType: T,
28
+ public readonly txs: (BackgroundTx & {
29
+ status: BackgroundTxStatus.PENDING | BackgroundTxStatus.CONFIRMED;
30
+ })[],
31
+ public readonly executableChainIds: string[],
32
+ public readonly historyData?: T extends TxExecutionType.UNDEFINED
33
+ ? undefined
34
+ : ExecutionTypeToHistoryData[T],
35
+ public readonly historyTxIndex?: number
36
+ ) {
37
+ super();
38
+ }
39
+
40
+ validateBasic(): void {
41
+ if (!this.vaultId) {
42
+ throw new KeplrError("direct-tx-executor", 110, "vaultId is empty");
43
+ }
44
+
45
+ if (!this.executionType) {
46
+ throw new KeplrError("direct-tx-executor", 111, "executionType is empty");
47
+ }
48
+
49
+ if (!this.txs || this.txs.length === 0) {
50
+ throw new KeplrError("direct-tx-executor", 112, "txs is empty");
51
+ }
52
+
53
+ if (!this.executableChainIds || this.executableChainIds.length === 0) {
54
+ throw new KeplrError(
55
+ "direct-tx-executor",
56
+ 113,
57
+ "executableChainIds is empty"
58
+ );
59
+ }
60
+
61
+ if (this.historyTxIndex != null && this.historyTxIndex < 0) {
62
+ throw new KeplrError(
63
+ "direct-tx-executor",
64
+ 114,
65
+ "historyTxIndex is invalid"
66
+ );
67
+ }
68
+ }
69
+
70
+ override approveExternal(): boolean {
71
+ return false;
72
+ }
73
+
74
+ route(): string {
75
+ return ROUTE;
76
+ }
77
+
78
+ type(): string {
79
+ return RecordAndExecuteTxsMsg.type();
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Resume existing direct transactions by execution id and transaction index
85
+ * This message is used to resume the execution of direct transactions that were paused by waiting for the asset to be bridged or other reasons.
86
+ */
87
+ export class ResumeTxMsg extends Message<TxExecutionResult> {
88
+ public static type() {
89
+ return "resume-tx";
90
+ }
91
+
92
+ constructor(
93
+ public readonly id: string,
94
+ public readonly txIndex: number,
95
+ public readonly signedTx: string,
96
+ public readonly ibcSwapData?: IBCSwapMinimalTrackingData
97
+ ) {
98
+ super();
99
+ }
100
+
101
+ validateBasic(): void {
102
+ if (!this.id) {
103
+ throw new KeplrError("direct-tx-executor", 115, "id is empty");
104
+ }
105
+
106
+ if (this.txIndex != null && this.txIndex < 0) {
107
+ throw new KeplrError("direct-tx-executor", 116, "txIndex is invalid");
108
+ }
109
+
110
+ if (this.signedTx != null && this.signedTx.length === 0) {
111
+ throw new KeplrError("direct-tx-executor", 117, "signedTx is empty");
112
+ }
113
+ }
114
+
115
+ override approveExternal(): boolean {
116
+ return false;
117
+ }
118
+
119
+ route(): string {
120
+ return ROUTE;
121
+ }
122
+
123
+ type(): string {
124
+ return ResumeTxMsg.type();
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Get execution data by execution id
130
+ */
131
+ export class GetTxExecutionMsg extends Message<TxExecution | undefined> {
132
+ public static type() {
133
+ return "get-tx-execution";
134
+ }
135
+
136
+ constructor(public readonly id: string) {
137
+ super();
138
+ }
139
+
140
+ validateBasic(): void {
141
+ if (!this.id) {
142
+ throw new KeplrError("direct-tx-executor", 115, "id is empty");
143
+ }
144
+ }
145
+
146
+ override approveExternal(): boolean {
147
+ return false;
148
+ }
149
+
150
+ route(): string {
151
+ return ROUTE;
152
+ }
153
+
154
+ type(): string {
155
+ return GetTxExecutionMsg.type();
156
+ }
157
+ }