@rabby-wallet/rabby-action 0.1.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 (256) hide show
  1. package/README.md +7 -0
  2. package/dist/actions/approveNFT/fetchData.d.ts +4 -0
  3. package/dist/actions/approveNFT/fetchData.js +60 -0
  4. package/dist/actions/approveNFT/formatSecurityEngine.d.ts +2 -0
  5. package/dist/actions/approveNFT/formatSecurityEngine.js +31 -0
  6. package/dist/actions/approveNFT/parseAction.d.ts +2 -0
  7. package/dist/actions/approveNFT/parseAction.js +9 -0
  8. package/dist/actions/approveNFTCollection/fetchData.d.ts +2 -0
  9. package/dist/actions/approveNFTCollection/fetchData.js +19 -0
  10. package/dist/actions/approveNFTCollection/formatSecurityEngine.d.ts +2 -0
  11. package/dist/actions/approveNFTCollection/formatSecurityEngine.js +31 -0
  12. package/dist/actions/approveNFTCollection/parseAction.d.ts +2 -0
  13. package/dist/actions/approveNFTCollection/parseAction.js +9 -0
  14. package/dist/actions/approveToken/fetchData.d.ts +6 -0
  15. package/dist/actions/approveToken/fetchData.js +64 -0
  16. package/dist/actions/approveToken/formatSecurityEngine.d.ts +2 -0
  17. package/dist/actions/approveToken/formatSecurityEngine.js +31 -0
  18. package/dist/actions/approveToken/parseAction.d.ts +2 -0
  19. package/dist/actions/approveToken/parseAction.js +13 -0
  20. package/dist/actions/assetOrder/fetchData.d.ts +2 -0
  21. package/dist/actions/assetOrder/fetchData.js +29 -0
  22. package/dist/actions/assetOrder/formatSecurityEngine.d.ts +2 -0
  23. package/dist/actions/assetOrder/formatSecurityEngine.js +30 -0
  24. package/dist/actions/assetOrder/parseAction.d.ts +2 -0
  25. package/dist/actions/assetOrder/parseAction.js +18 -0
  26. package/dist/actions/batchPermit2/fetchData.d.ts +2 -0
  27. package/dist/actions/batchPermit2/fetchData.js +65 -0
  28. package/dist/actions/batchPermit2/formatSecurityEngine.d.ts +2 -0
  29. package/dist/actions/batchPermit2/formatSecurityEngine.js +30 -0
  30. package/dist/actions/batchPermit2/parseAction.d.ts +2 -0
  31. package/dist/actions/batchPermit2/parseAction.js +9 -0
  32. package/dist/actions/batchSellNFT/fetchData.d.ts +2 -0
  33. package/dist/actions/batchSellNFT/fetchData.js +21 -0
  34. package/dist/actions/batchSellNFT/formatSecurityEngine.d.ts +2 -0
  35. package/dist/actions/batchSellNFT/formatSecurityEngine.js +33 -0
  36. package/dist/actions/batchSellNFT/parseAction.d.ts +2 -0
  37. package/dist/actions/batchSellNFT/parseAction.js +9 -0
  38. package/dist/actions/buyNFT/fetchData.d.ts +2 -0
  39. package/dist/actions/buyNFT/fetchData.js +21 -0
  40. package/dist/actions/buyNFT/formatSecurityEngine.d.ts +2 -0
  41. package/dist/actions/buyNFT/formatSecurityEngine.js +33 -0
  42. package/dist/actions/buyNFT/parseAction.d.ts +2 -0
  43. package/dist/actions/buyNFT/parseAction.js +9 -0
  44. package/dist/actions/cancelTx/fetchData.d.ts +2 -0
  45. package/dist/actions/cancelTx/fetchData.js +32 -0
  46. package/dist/actions/cancelTx/formatSecurityEngine.d.ts +2 -0
  47. package/dist/actions/cancelTx/formatSecurityEngine.js +12 -0
  48. package/dist/actions/cancelTx/parseAction.d.ts +2 -0
  49. package/dist/actions/cancelTx/parseAction.js +11 -0
  50. package/dist/actions/coboSafeCreate/fetchData.d.ts +2 -0
  51. package/dist/actions/coboSafeCreate/fetchData.js +12 -0
  52. package/dist/actions/coboSafeCreate/formatSecurityEngine.d.ts +2 -0
  53. package/dist/actions/coboSafeCreate/formatSecurityEngine.js +12 -0
  54. package/dist/actions/coboSafeCreate/parseAction.d.ts +2 -0
  55. package/dist/actions/coboSafeCreate/parseAction.js +9 -0
  56. package/dist/actions/coboSafeModificationDelegatedAddress/fetchData.d.ts +2 -0
  57. package/dist/actions/coboSafeModificationDelegatedAddress/fetchData.js +12 -0
  58. package/dist/actions/coboSafeModificationDelegatedAddress/formatSecurityEngine.d.ts +2 -0
  59. package/dist/actions/coboSafeModificationDelegatedAddress/formatSecurityEngine.js +12 -0
  60. package/dist/actions/coboSafeModificationDelegatedAddress/parseAction.d.ts +2 -0
  61. package/dist/actions/coboSafeModificationDelegatedAddress/parseAction.js +9 -0
  62. package/dist/actions/coboSafeModificationRole/fetchData.d.ts +2 -0
  63. package/dist/actions/coboSafeModificationRole/fetchData.js +12 -0
  64. package/dist/actions/coboSafeModificationRole/formatSecurityEngine.d.ts +2 -0
  65. package/dist/actions/coboSafeModificationRole/formatSecurityEngine.js +12 -0
  66. package/dist/actions/coboSafeModificationRole/parseAction.d.ts +2 -0
  67. package/dist/actions/coboSafeModificationRole/parseAction.js +9 -0
  68. package/dist/actions/coboSafeModificationTokenApproval/fetchData.d.ts +2 -0
  69. package/dist/actions/coboSafeModificationTokenApproval/fetchData.js +12 -0
  70. package/dist/actions/coboSafeModificationTokenApproval/formatSecurityEngine.d.ts +2 -0
  71. package/dist/actions/coboSafeModificationTokenApproval/formatSecurityEngine.js +12 -0
  72. package/dist/actions/coboSafeModificationTokenApproval/parseAction.d.ts +2 -0
  73. package/dist/actions/coboSafeModificationTokenApproval/parseAction.js +9 -0
  74. package/dist/actions/common/fetchData.d.ts +4 -0
  75. package/dist/actions/common/fetchData.js +119 -0
  76. package/dist/actions/common/formatSecurityEngine.d.ts +2 -0
  77. package/dist/actions/common/formatSecurityEngine.js +21 -0
  78. package/dist/actions/common/parseAction.d.ts +2 -0
  79. package/dist/actions/common/parseAction.js +14 -0
  80. package/dist/actions/contractCall/fetchData.d.ts +2 -0
  81. package/dist/actions/contractCall/fetchData.js +115 -0
  82. package/dist/actions/contractCall/formatSecurityEngine.d.ts +2 -0
  83. package/dist/actions/contractCall/formatSecurityEngine.js +25 -0
  84. package/dist/actions/contractCall/parseAction.d.ts +2 -0
  85. package/dist/actions/contractCall/parseAction.js +5 -0
  86. package/dist/actions/createKey/fetchData.d.ts +2 -0
  87. package/dist/actions/createKey/fetchData.js +12 -0
  88. package/dist/actions/createKey/formatSecurityEngine.d.ts +2 -0
  89. package/dist/actions/createKey/formatSecurityEngine.js +24 -0
  90. package/dist/actions/createKey/parseAction.d.ts +2 -0
  91. package/dist/actions/createKey/parseAction.js +9 -0
  92. package/dist/actions/crossSwapToken/fetchData.d.ts +2 -0
  93. package/dist/actions/crossSwapToken/fetchData.js +19 -0
  94. package/dist/actions/crossSwapToken/formatSecurityEngine.d.ts +2 -0
  95. package/dist/actions/crossSwapToken/formatSecurityEngine.js +38 -0
  96. package/dist/actions/crossSwapToken/parseAction.d.ts +2 -0
  97. package/dist/actions/crossSwapToken/parseAction.js +26 -0
  98. package/dist/actions/crossToken/fetchData.d.ts +2 -0
  99. package/dist/actions/crossToken/fetchData.js +19 -0
  100. package/dist/actions/crossToken/formatSecurityEngine.d.ts +2 -0
  101. package/dist/actions/crossToken/formatSecurityEngine.js +38 -0
  102. package/dist/actions/crossToken/parseAction.d.ts +2 -0
  103. package/dist/actions/crossToken/parseAction.js +22 -0
  104. package/dist/actions/deployContract/fetchData.d.ts +2 -0
  105. package/dist/actions/deployContract/fetchData.js +12 -0
  106. package/dist/actions/deployContract/formatSecurityEngine.d.ts +2 -0
  107. package/dist/actions/deployContract/formatSecurityEngine.js +12 -0
  108. package/dist/actions/deployContract/parseAction.d.ts +2 -0
  109. package/dist/actions/deployContract/parseAction.js +9 -0
  110. package/dist/actions/permit/fetchData.d.ts +2 -0
  111. package/dist/actions/permit/fetchData.js +19 -0
  112. package/dist/actions/permit/formatSecurityEngine.d.ts +2 -0
  113. package/dist/actions/permit/formatSecurityEngine.js +30 -0
  114. package/dist/actions/permit/parseAction.d.ts +2 -0
  115. package/dist/actions/permit/parseAction.js +9 -0
  116. package/dist/actions/permit2/fetchData.d.ts +2 -0
  117. package/dist/actions/permit2/fetchData.js +19 -0
  118. package/dist/actions/permit2/formatSecurityEngine.d.ts +2 -0
  119. package/dist/actions/permit2/formatSecurityEngine.js +30 -0
  120. package/dist/actions/permit2/parseAction.d.ts +2 -0
  121. package/dist/actions/permit2/parseAction.js +9 -0
  122. package/dist/actions/permit2BatchRevokeToken/fetchData.d.ts +2 -0
  123. package/dist/actions/permit2BatchRevokeToken/fetchData.js +30 -0
  124. package/dist/actions/permit2BatchRevokeToken/formatSecurityEngine.d.ts +2 -0
  125. package/dist/actions/permit2BatchRevokeToken/formatSecurityEngine.js +12 -0
  126. package/dist/actions/permit2BatchRevokeToken/parseAction.d.ts +2 -0
  127. package/dist/actions/permit2BatchRevokeToken/parseAction.js +9 -0
  128. package/dist/actions/pushMultiSig/fetchData.d.ts +2 -0
  129. package/dist/actions/pushMultiSig/fetchData.js +27 -0
  130. package/dist/actions/pushMultiSig/formatSecurityEngine.d.ts +2 -0
  131. package/dist/actions/pushMultiSig/formatSecurityEngine.js +12 -0
  132. package/dist/actions/pushMultiSig/parseAction.d.ts +2 -0
  133. package/dist/actions/pushMultiSig/parseAction.js +9 -0
  134. package/dist/actions/revokeNFT/fetchData.d.ts +2 -0
  135. package/dist/actions/revokeNFT/fetchData.js +19 -0
  136. package/dist/actions/revokeNFT/formatSecurityEngine.d.ts +2 -0
  137. package/dist/actions/revokeNFT/formatSecurityEngine.js +12 -0
  138. package/dist/actions/revokeNFT/parseAction.d.ts +2 -0
  139. package/dist/actions/revokeNFT/parseAction.js +9 -0
  140. package/dist/actions/revokeNFTCollection/fetchData.d.ts +2 -0
  141. package/dist/actions/revokeNFTCollection/fetchData.js +19 -0
  142. package/dist/actions/revokeNFTCollection/formatSecurityEngine.d.ts +2 -0
  143. package/dist/actions/revokeNFTCollection/formatSecurityEngine.js +12 -0
  144. package/dist/actions/revokeNFTCollection/parseAction.d.ts +2 -0
  145. package/dist/actions/revokeNFTCollection/parseAction.js +9 -0
  146. package/dist/actions/revokePermit/fetchData.d.ts +2 -0
  147. package/dist/actions/revokePermit/fetchData.js +19 -0
  148. package/dist/actions/revokePermit/formatSecurityEngine.d.ts +2 -0
  149. package/dist/actions/revokePermit/formatSecurityEngine.js +12 -0
  150. package/dist/actions/revokePermit/parseAction.d.ts +2 -0
  151. package/dist/actions/revokePermit/parseAction.js +9 -0
  152. package/dist/actions/revokePermit2/fetchData.d.ts +2 -0
  153. package/dist/actions/revokePermit2/fetchData.js +19 -0
  154. package/dist/actions/revokePermit2/formatSecurityEngine.d.ts +2 -0
  155. package/dist/actions/revokePermit2/formatSecurityEngine.js +12 -0
  156. package/dist/actions/revokePermit2/parseAction.d.ts +2 -0
  157. package/dist/actions/revokePermit2/parseAction.js +13 -0
  158. package/dist/actions/revokeToken/fetchData.d.ts +2 -0
  159. package/dist/actions/revokeToken/fetchData.js +19 -0
  160. package/dist/actions/revokeToken/formatSecurityEngine.d.ts +2 -0
  161. package/dist/actions/revokeToken/formatSecurityEngine.js +25 -0
  162. package/dist/actions/revokeToken/parseAction.d.ts +2 -0
  163. package/dist/actions/revokeToken/parseAction.js +14 -0
  164. package/dist/actions/sellNFT/fetchData.d.ts +2 -0
  165. package/dist/actions/sellNFT/fetchData.js +21 -0
  166. package/dist/actions/sellNFT/formatSecurityEngine.d.ts +2 -0
  167. package/dist/actions/sellNFT/formatSecurityEngine.js +33 -0
  168. package/dist/actions/sellNFT/parseAction.d.ts +2 -0
  169. package/dist/actions/sellNFT/parseAction.js +9 -0
  170. package/dist/actions/send/fetchData.d.ts +8 -0
  171. package/dist/actions/send/fetchData.js +103 -0
  172. package/dist/actions/send/formatSecurityEngine.d.ts +2 -0
  173. package/dist/actions/send/formatSecurityEngine.js +47 -0
  174. package/dist/actions/send/parseAction.d.ts +2 -0
  175. package/dist/actions/send/parseAction.js +9 -0
  176. package/dist/actions/sendNFT/fetchData.d.ts +2 -0
  177. package/dist/actions/sendNFT/fetchData.js +26 -0
  178. package/dist/actions/sendNFT/formatSecurityEngine.d.ts +2 -0
  179. package/dist/actions/sendNFT/formatSecurityEngine.js +46 -0
  180. package/dist/actions/sendNFT/parseAction.d.ts +2 -0
  181. package/dist/actions/sendNFT/parseAction.js +9 -0
  182. package/dist/actions/signMultiSig/fetchData.d.ts +2 -0
  183. package/dist/actions/signMultiSig/fetchData.js +27 -0
  184. package/dist/actions/signMultiSig/formatSecurityEngine.d.ts +2 -0
  185. package/dist/actions/signMultiSig/formatSecurityEngine.js +12 -0
  186. package/dist/actions/signMultiSig/parseAction.d.ts +2 -0
  187. package/dist/actions/signMultiSig/parseAction.js +9 -0
  188. package/dist/actions/swap/fetchData.d.ts +4 -0
  189. package/dist/actions/swap/fetchData.js +51 -0
  190. package/dist/actions/swap/formatSecurityEngine.d.ts +2 -0
  191. package/dist/actions/swap/formatSecurityEngine.js +39 -0
  192. package/dist/actions/swap/parseAction.d.ts +2 -0
  193. package/dist/actions/swap/parseAction.js +43 -0
  194. package/dist/actions/swapTokenOrder/fetchData.d.ts +2 -0
  195. package/dist/actions/swapTokenOrder/fetchData.js +21 -0
  196. package/dist/actions/swapTokenOrder/formatSecurityEngine.d.ts +2 -0
  197. package/dist/actions/swapTokenOrder/formatSecurityEngine.js +35 -0
  198. package/dist/actions/swapTokenOrder/parseAction.d.ts +2 -0
  199. package/dist/actions/swapTokenOrder/parseAction.js +27 -0
  200. package/dist/actions/unwrapToken/fetchData.d.ts +2 -0
  201. package/dist/actions/unwrapToken/fetchData.js +19 -0
  202. package/dist/actions/unwrapToken/formatSecurityEngine.d.ts +2 -0
  203. package/dist/actions/unwrapToken/formatSecurityEngine.js +34 -0
  204. package/dist/actions/unwrapToken/parseAction.d.ts +2 -0
  205. package/dist/actions/unwrapToken/parseAction.js +17 -0
  206. package/dist/actions/verifyAddress/fetchData.d.ts +2 -0
  207. package/dist/actions/verifyAddress/fetchData.js +12 -0
  208. package/dist/actions/verifyAddress/formatSecurityEngine.d.ts +2 -0
  209. package/dist/actions/verifyAddress/formatSecurityEngine.js +24 -0
  210. package/dist/actions/verifyAddress/parseAction.d.ts +2 -0
  211. package/dist/actions/verifyAddress/parseAction.js +9 -0
  212. package/dist/actions/wrapToken/fetchData.d.ts +2 -0
  213. package/dist/actions/wrapToken/fetchData.js +19 -0
  214. package/dist/actions/wrapToken/formatSecurityEngine.d.ts +2 -0
  215. package/dist/actions/wrapToken/formatSecurityEngine.js +34 -0
  216. package/dist/actions/wrapToken/parseAction.d.ts +2 -0
  217. package/dist/actions/wrapToken/parseAction.js +17 -0
  218. package/dist/fetchActionRequiredData.d.ts +2 -0
  219. package/dist/fetchActionRequiredData.js +87 -0
  220. package/dist/formatSecurityEngineContext.d.ts +2 -0
  221. package/dist/formatSecurityEngineContext.js +89 -0
  222. package/dist/index.d.ts +5 -0
  223. package/dist/index.js +5 -0
  224. package/dist/parseAction.d.ts +4 -0
  225. package/dist/parseAction.js +66 -0
  226. package/dist/types/actionRequireData.d.ts +158 -0
  227. package/dist/types/actionRequireData.js +1 -0
  228. package/dist/types/fetchActionRequiredData.d.ts +24 -0
  229. package/dist/types/fetchActionRequiredData.js +1 -0
  230. package/dist/types/formatSecurityEngineContext.d.ts +40 -0
  231. package/dist/types/formatSecurityEngineContext.js +1 -0
  232. package/dist/types/index.d.ts +5 -0
  233. package/dist/types/index.js +5 -0
  234. package/dist/types/parseAction.d.ts +26 -0
  235. package/dist/types/parseAction.js +1 -0
  236. package/dist/types/parsedActionData.d.ts +161 -0
  237. package/dist/types/parsedActionData.js +1 -0
  238. package/dist/types/walletProvider.d.ts +79 -0
  239. package/dist/types/walletProvider.js +1 -0
  240. package/dist/utils/calcSlippageTolerance.d.ts +1 -0
  241. package/dist/utils/calcSlippageTolerance.js +12 -0
  242. package/dist/utils/calcUSDValueChange.d.ts +1 -0
  243. package/dist/utils/calcUSDValueChange.js +12 -0
  244. package/dist/utils/getProtocol.d.ts +6 -0
  245. package/dist/utils/getProtocol.js +7 -0
  246. package/dist/utils/isSameAddress.d.ts +4 -0
  247. package/dist/utils/isSameAddress.js +8 -0
  248. package/dist/utils/keyring.d.ts +10 -0
  249. package/dist/utils/keyring.js +10 -0
  250. package/dist/utils/parseTextAction.d.ts +2 -0
  251. package/dist/utils/parseTextAction.js +9 -0
  252. package/dist/utils/parseTypedDataAction.d.ts +2 -0
  253. package/dist/utils/parseTypedDataAction.js +25 -0
  254. package/dist/utils/waitQueueFinished.d.ts +2 -0
  255. package/dist/utils/waitQueueFinished.js +8 -0
  256. package/package.json +56 -0
@@ -0,0 +1,19 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { fetchDataSwap } from '../swap/fetchData';
11
+ export const fetchDataWrapToken = (options) => __awaiter(void 0, void 0, void 0, function* () {
12
+ if (options.type !== 'transaction') {
13
+ return {};
14
+ }
15
+ if (!options.actionData.wrapToken) {
16
+ return {};
17
+ }
18
+ return fetchDataSwap(options, options.actionData.wrapToken);
19
+ });
@@ -0,0 +1,2 @@
1
+ import { FormatSecurityEngineContext } from '../../types';
2
+ export declare const formatSecurityEngineWrapToken: FormatSecurityEngineContext;
@@ -0,0 +1,34 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const formatSecurityEngineWrapToken = (options) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (options.type !== 'transaction') {
12
+ return {};
13
+ }
14
+ const { actionData, requireData, chainId, provider } = options;
15
+ if (!actionData.wrapToken || !chainId) {
16
+ return {};
17
+ }
18
+ const { slippageTolerance, receiver } = actionData.wrapToken;
19
+ const data = requireData;
20
+ return {
21
+ wrapToken: {
22
+ slippageTolerance,
23
+ receiver,
24
+ from: data.sender,
25
+ chainId,
26
+ id: data.id,
27
+ receiverInWallet: data.receiverInWallet,
28
+ },
29
+ contractCall: {
30
+ id: data.id,
31
+ chainId,
32
+ },
33
+ };
34
+ });
@@ -0,0 +1,2 @@
1
+ import { ParseAction } from '../../types';
2
+ export declare const parseActionWrapToken: ParseAction<'transaction'>;
@@ -0,0 +1,17 @@
1
+ import { calcSlippageTolerance } from '../../utils/calcSlippageTolerance';
2
+ export const parseActionWrapToken = (options) => {
3
+ const { data } = options;
4
+ if ((data === null || data === void 0 ? void 0 : data.type) !== 'wrap_token') {
5
+ return {};
6
+ }
7
+ const { pay_token, receive_token, receiver } = data.data;
8
+ const slippageTolerance = calcSlippageTolerance(pay_token.raw_amount || '0', receive_token.min_raw_amount || '0');
9
+ return {
10
+ wrapToken: {
11
+ payToken: pay_token,
12
+ receiveToken: receive_token,
13
+ slippageTolerance,
14
+ receiver,
15
+ },
16
+ };
17
+ };
@@ -0,0 +1,2 @@
1
+ import { FetchActionRequiredData } from './types/fetchActionRequiredData';
2
+ export declare const fetchActionRequiredData: FetchActionRequiredData;
@@ -0,0 +1,87 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { fetchDataDeployContract } from './actions/deployContract/fetchData';
11
+ import { fetchDataSend } from './actions/send/fetchData';
12
+ import { fetchDataSendNFT } from './actions/sendNFT/fetchData';
13
+ import { fetchDataSwap } from './actions/swap/fetchData';
14
+ import { fetchDataCrossToken } from './actions/crossToken/fetchData';
15
+ import { fetchDataCrossSwapToken } from './actions/crossSwapToken/fetchData';
16
+ import { fetchDataApproveToken } from './actions/approveToken/fetchData';
17
+ import { fetchDataApproveNFT } from './actions/approveNFT/fetchData';
18
+ import { fetchDataCancelTx } from './actions/cancelTx/fetchData';
19
+ import { fetchDataContractCall } from './actions/contractCall/fetchData';
20
+ import { fetchDataRevokeNFT } from './actions/revokeNFT/fetchData';
21
+ import { fetchDataRevokePermit2 } from './actions/revokePermit2/fetchData';
22
+ import { fetchDataRevokeToken } from './actions/revokeToken/fetchData';
23
+ import { fetchDataWrapToken } from './actions/wrapToken/fetchData';
24
+ import { fetchDataUnwrapToken } from './actions/unwrapToken/fetchData';
25
+ import { fetchDataApproveNFTCollection } from './actions/approveNFTCollection/fetchData';
26
+ import { fetchDataAssetOrder } from './actions/assetOrder/fetchData';
27
+ import { fetchDataCommon } from './actions/common/fetchData';
28
+ import { fetchDataPushMultiSig } from './actions/pushMultiSig/fetchData';
29
+ import { fetchDataRevokeNFTCollection } from './actions/revokeNFTCollection/fetchData';
30
+ import { fetchDataPermit2BatchRevokeToken } from './actions/permit2BatchRevokeToken/fetchData';
31
+ import { fetchDataBatchPermit2 } from './actions/batchPermit2/fetchData';
32
+ import { fetchDataBatchSellNFT } from './actions/batchSellNFT/fetchData';
33
+ import { fetchDataBuyNFT } from './actions/buyNFT/fetchData';
34
+ import { fetchDataCoboSafeCreate } from './actions/coboSafeCreate/fetchData';
35
+ import { fetchDataCoboSafeModificationDelegatedAddress } from './actions/coboSafeModificationDelegatedAddress/fetchData';
36
+ import { fetchDataCoboSafeModificationRole } from './actions/coboSafeModificationRole/fetchData';
37
+ import { fetchDataCoboSafeModificationTokenApproval } from './actions/coboSafeModificationTokenApproval/fetchData';
38
+ import { fetchDataCreateKey } from './actions/createKey/fetchData';
39
+ import { fetchDataPermit } from './actions/permit/fetchData';
40
+ import { fetchDataPermit2 } from './actions/permit2/fetchData';
41
+ import { fetchDataRevokePermit } from './actions/revokePermit/fetchData';
42
+ import { fetchDataSellNFT } from './actions/sellNFT/fetchData';
43
+ import { fetchDataSignMultiSig } from './actions/signMultiSig/fetchData';
44
+ import { fetchDataSwapTokenOrder } from './actions/swapTokenOrder/fetchData';
45
+ import { fetchDataVerifyAddress } from './actions/verifyAddress/fetchData';
46
+ export const fetchActionRequiredData = (options) => __awaiter(void 0, void 0, void 0, function* () {
47
+ const result = yield Promise.all([
48
+ fetchDataApproveNFT(options),
49
+ fetchDataApproveNFTCollection(options),
50
+ fetchDataApproveToken(options),
51
+ fetchDataAssetOrder(options),
52
+ fetchDataCancelTx(options),
53
+ // @deprecated we don't parse common action data anymore, will be removed in the future
54
+ fetchDataCommon(options),
55
+ fetchDataContractCall(options),
56
+ fetchDataCrossSwapToken(options),
57
+ fetchDataCrossToken(options),
58
+ fetchDataDeployContract(options),
59
+ fetchDataPushMultiSig(options),
60
+ fetchDataRevokeNFT(options),
61
+ fetchDataRevokeNFTCollection(options),
62
+ fetchDataRevokePermit2(options),
63
+ fetchDataRevokeToken(options),
64
+ fetchDataSend(options),
65
+ fetchDataSendNFT(options),
66
+ fetchDataSwap(options),
67
+ fetchDataUnwrapToken(options),
68
+ fetchDataWrapToken(options),
69
+ fetchDataPermit2BatchRevokeToken(options),
70
+ fetchDataSellNFT(options),
71
+ fetchDataBatchSellNFT(options),
72
+ fetchDataSignMultiSig(options),
73
+ fetchDataBuyNFT(options),
74
+ fetchDataPermit(options),
75
+ fetchDataPermit2(options),
76
+ fetchDataBatchPermit2(options),
77
+ fetchDataSwapTokenOrder(options),
78
+ fetchDataCreateKey(options),
79
+ fetchDataVerifyAddress(options),
80
+ fetchDataCoboSafeCreate(options),
81
+ fetchDataCoboSafeModificationDelegatedAddress(options),
82
+ fetchDataCoboSafeModificationRole(options),
83
+ fetchDataCoboSafeModificationTokenApproval(options),
84
+ fetchDataRevokePermit(options),
85
+ ]);
86
+ return result.reduce((acc, val) => (Object.assign(Object.assign({}, acc), val)), {});
87
+ });
@@ -0,0 +1,2 @@
1
+ import { FormatSecurityEngineContext } from './types/formatSecurityEngineContext';
2
+ export declare const formatSecurityEngineContext: FormatSecurityEngineContext;
@@ -0,0 +1,89 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { formatSecurityEngineApproveNFT } from './actions/approveNFT/formatSecurityEngine';
11
+ import { formatSecurityEngineApproveNFTCollection } from './actions/approveNFTCollection/formatSecurityEngine';
12
+ import { formatSecurityEngineApproveToken } from './actions/approveToken/formatSecurityEngine';
13
+ import { formatSecurityEngineAssetOrder } from './actions/assetOrder/formatSecurityEngine';
14
+ import { formatSecurityEngineCancelTx } from './actions/cancelTx/formatSecurityEngine';
15
+ import { formatSecurityEngineCommon } from './actions/common/formatSecurityEngine';
16
+ import { formatSecurityEngineContractCall } from './actions/contractCall/formatSecurityEngine';
17
+ import { formatSecurityEngineCrossSwapToken } from './actions/crossSwapToken/formatSecurityEngine';
18
+ import { formatSecurityEngineCrossToken } from './actions/crossToken/formatSecurityEngine';
19
+ import { formatSecurityEngineDeployContract } from './actions/deployContract/formatSecurityEngine';
20
+ import { formatSecurityEnginePushMultiSig } from './actions/pushMultiSig/formatSecurityEngine';
21
+ import { formatSecurityEngineRevokeNFT } from './actions/revokeNFT/formatSecurityEngine';
22
+ import { formatSecurityEngineRevokeNFTCollection } from './actions/revokeNFTCollection/formatSecurityEngine';
23
+ import { formatSecurityEngineRevokePermit2 } from './actions/revokePermit2/formatSecurityEngine';
24
+ import { formatSecurityEngineRevokeToken } from './actions/revokeToken/formatSecurityEngine';
25
+ import { formatSecurityEngineSend } from './actions/send/formatSecurityEngine';
26
+ import { formatSecurityEngineSendNFT } from './actions/sendNFT/formatSecurityEngine';
27
+ import { formatSecurityEngineSwap } from './actions/swap/formatSecurityEngine';
28
+ import { formatSecurityEngineUnwrapToken } from './actions/unwrapToken/formatSecurityEngine';
29
+ import { formatSecurityEngineWrapToken } from './actions/wrapToken/formatSecurityEngine';
30
+ import { formatSecurityEnginePermit2BatchRevokeToken } from './actions/permit2BatchRevokeToken/formatSecurityEngine';
31
+ import { formatSecurityEngineBatchPermit2 } from './actions/batchPermit2/formatSecurityEngine';
32
+ import { formatSecurityEngineBatchSellNFT } from './actions/batchSellNFT/formatSecurityEngine';
33
+ import { formatSecurityEngineBuyNFT } from './actions/buyNFT/formatSecurityEngine';
34
+ import { formatSecurityEngineCoboSafeCreate } from './actions/coboSafeCreate/formatSecurityEngine';
35
+ import { formatSecurityEngineCoboSafeModificationDelegatedAddress } from './actions/coboSafeModificationDelegatedAddress/formatSecurityEngine';
36
+ import { formatSecurityEngineCoboSafeModificationRole } from './actions/coboSafeModificationRole/formatSecurityEngine';
37
+ import { formatSecurityEngineCoboSafeModificationTokenApproval } from './actions/coboSafeModificationTokenApproval/formatSecurityEngine';
38
+ import { formatSecurityEngineCreateKey } from './actions/createKey/formatSecurityEngine';
39
+ import { formatSecurityEnginePermit } from './actions/permit/formatSecurityEngine';
40
+ import { formatSecurityEnginePermit2 } from './actions/permit2/formatSecurityEngine';
41
+ import { formatSecurityEngineRevokePermit } from './actions/revokePermit/formatSecurityEngine';
42
+ import { formatSecurityEngineSellNFT } from './actions/sellNFT/formatSecurityEngine';
43
+ import { formatSecurityEngineSignMultiSig } from './actions/signMultiSig/formatSecurityEngine';
44
+ import { formatSecurityEngineSwapTokenOrder } from './actions/swapTokenOrder/formatSecurityEngine';
45
+ import { formatSecurityEngineVerifyAddress } from './actions/verifyAddress/formatSecurityEngine';
46
+ export const formatSecurityEngineContext = (options) => __awaiter(void 0, void 0, void 0, function* () {
47
+ if (options.type !== 'text' && options.isTestnet) {
48
+ return {};
49
+ }
50
+ const result = yield Promise.all([
51
+ formatSecurityEngineApproveNFT(options),
52
+ formatSecurityEngineApproveNFTCollection(options),
53
+ formatSecurityEngineApproveToken(options),
54
+ formatSecurityEngineAssetOrder(options),
55
+ formatSecurityEngineCancelTx(options),
56
+ formatSecurityEngineCommon(options),
57
+ formatSecurityEngineContractCall(options),
58
+ formatSecurityEngineCrossSwapToken(options),
59
+ formatSecurityEngineCrossToken(options),
60
+ formatSecurityEngineDeployContract(options),
61
+ formatSecurityEnginePushMultiSig(options),
62
+ formatSecurityEngineRevokeNFT(options),
63
+ formatSecurityEngineRevokeNFTCollection(options),
64
+ formatSecurityEngineRevokePermit2(options),
65
+ formatSecurityEngineRevokeToken(options),
66
+ formatSecurityEngineSend(options),
67
+ formatSecurityEngineSendNFT(options),
68
+ formatSecurityEngineSwap(options),
69
+ formatSecurityEngineUnwrapToken(options),
70
+ formatSecurityEngineWrapToken(options),
71
+ formatSecurityEnginePermit2BatchRevokeToken(options),
72
+ formatSecurityEngineSellNFT(options),
73
+ formatSecurityEngineBatchSellNFT(options),
74
+ formatSecurityEngineSignMultiSig(options),
75
+ formatSecurityEngineBuyNFT(options),
76
+ formatSecurityEnginePermit(options),
77
+ formatSecurityEnginePermit2(options),
78
+ formatSecurityEngineBatchPermit2(options),
79
+ formatSecurityEngineSwapTokenOrder(options),
80
+ formatSecurityEngineCreateKey(options),
81
+ formatSecurityEngineVerifyAddress(options),
82
+ formatSecurityEngineCoboSafeCreate(options),
83
+ formatSecurityEngineCoboSafeModificationDelegatedAddress(options),
84
+ formatSecurityEngineCoboSafeModificationRole(options),
85
+ formatSecurityEngineCoboSafeModificationTokenApproval(options),
86
+ formatSecurityEngineRevokePermit(options),
87
+ ]);
88
+ return result.reduce((acc, val) => (Object.assign(Object.assign({}, acc), val)), {});
89
+ });
@@ -0,0 +1,5 @@
1
+ export * from './parseAction';
2
+ export * from './fetchActionRequiredData';
3
+ export * from './formatSecurityEngineContext';
4
+ export * from './types';
5
+ export * from './utils/getProtocol';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './parseAction';
2
+ export * from './fetchActionRequiredData';
3
+ export * from './formatSecurityEngineContext';
4
+ export * from './types';
5
+ export * from './utils/getProtocol';
@@ -0,0 +1,4 @@
1
+ import { ParsedActionData, ParseTextActionParameters, ParseTransactionActionParameters, ParseTypedDataActionParameters } from './types';
2
+ export declare function parseAction(options: ParseTypedDataActionParameters): ParsedActionData<'typed_data'>;
3
+ export declare function parseAction(options: ParseTransactionActionParameters): ParsedActionData<'transaction'>;
4
+ export declare function parseAction(options: ParseTextActionParameters): ParsedActionData<'text'>;
@@ -0,0 +1,66 @@
1
+ import { parseActionSend } from './actions/send/parseAction';
2
+ import { parseActionApproveNFT } from './actions/approveNFT/parseAction';
3
+ import { parseActionApproveNFTCollection } from './actions/approveNFTCollection/parseAction';
4
+ import { parseActionApproveToken } from './actions/approveToken/parseAction';
5
+ import { parseActionAssetOrder } from './actions/assetOrder/parseAction';
6
+ import { parseActionCancelTx } from './actions/cancelTx/parseAction';
7
+ import { parseActionCommon } from './actions/common/parseAction';
8
+ import { parseActionContractCall } from './actions/contractCall/parseAction';
9
+ import { parseActionCrossSwapToken } from './actions/crossSwapToken/parseAction';
10
+ import { parseActionCrossToken } from './actions/crossToken/parseAction';
11
+ import { parseActionDeployContract } from './actions/deployContract/parseAction';
12
+ import { parseActionPushMultiSig } from './actions/pushMultiSig/parseAction';
13
+ import { parseActionRevokeNFT } from './actions/revokeNFT/parseAction';
14
+ import { parseActionRevokeNFTCollection } from './actions/revokeNFTCollection/parseAction';
15
+ import { parseActionRevokePermit2 } from './actions/revokePermit2/parseAction';
16
+ import { parseActionRevokeToken } from './actions/revokeToken/parseAction';
17
+ import { parseActionSendNFT } from './actions/sendNFT/parseAction';
18
+ import { parseActionSwap } from './actions/swap/parseAction';
19
+ import { parseActionUnwrapToken } from './actions/unwrapToken/parseAction';
20
+ import { parseActionWrapToken } from './actions/wrapToken/parseAction';
21
+ import { parseActionPermit2BatchRevokeToken } from './actions/permit2BatchRevokeToken/parseAction';
22
+ import { parseActionBatchPermit2 } from './actions/batchPermit2/parseAction';
23
+ import { parseActionBatchSellNFT } from './actions/batchSellNFT/parseAction';
24
+ import { parseActionBuyNFT } from './actions/buyNFT/parseAction';
25
+ import { parseActionCoboSafeCreate } from './actions/coboSafeCreate/parseAction';
26
+ import { parseActionCoboSafeModificationDelegatedAddress } from './actions/coboSafeModificationDelegatedAddress/parseAction';
27
+ import { parseActionCoboSafeModificationRole } from './actions/coboSafeModificationRole/parseAction';
28
+ import { parseActionCoboSafeModificationTokenApproval } from './actions/coboSafeModificationTokenApproval/parseAction';
29
+ import { parseActionCreateKey } from './actions/createKey/parseAction';
30
+ import { parseActionPermit } from './actions/permit/parseAction';
31
+ import { parseActionPermit2 } from './actions/permit2/parseAction';
32
+ import { parseActionRevokePermit } from './actions/revokePermit/parseAction';
33
+ import { parseActionSellNFT } from './actions/sellNFT/parseAction';
34
+ import { parseActionSignMultiSig } from './actions/signMultiSig/parseAction';
35
+ import { parseActionSwapTokenOrder } from './actions/swapTokenOrder/parseAction';
36
+ import { parseActionVerifyAddress } from './actions/verifyAddress/parseAction';
37
+ import { parseTypedDataAction } from './utils/parseTypedDataAction';
38
+ import { parseTextAction } from './utils/parseTextAction';
39
+ export function parseAction(options) {
40
+ const result = [];
41
+ if (options.type === 'transaction') {
42
+ result.push(parseActionApproveNFT(options), parseActionApproveNFTCollection(options), parseActionApproveToken(options), parseActionAssetOrder(options), parseActionCancelTx(options), parseActionCommon(options), parseActionCrossSwapToken(options), parseActionCrossToken(options), parseActionDeployContract(options), parseActionPushMultiSig(options), parseActionRevokeNFT(options), parseActionRevokeNFTCollection(options), parseActionRevokePermit2(options), parseActionRevokeToken(options), parseActionSend(options), parseActionSendNFT(options), parseActionSwap(options), parseActionUnwrapToken(options), parseActionWrapToken(options), parseActionPermit2BatchRevokeToken(options));
43
+ }
44
+ if (options.type === 'typed_data') {
45
+ result.push(parseTypedDataAction(parseActionCommon)(options), parseTypedDataAction(parseActionAssetOrder)(options), parseTypedDataAction(parseActionSend)(options), parseTypedDataAction(parseActionApproveNFT)(options), parseTypedDataAction(parseActionCreateKey)(options), parseTypedDataAction(parseActionVerifyAddress)(options), parseTypedDataAction(parseActionSellNFT)(options), parseTypedDataAction(parseActionBatchSellNFT)(options), parseTypedDataAction(parseActionSignMultiSig)(options), parseTypedDataAction(parseActionBuyNFT)(options), parseTypedDataAction(parseActionPermit)(options), parseTypedDataAction(parseActionPermit2)(options), parseTypedDataAction(parseActionBatchPermit2)(options), parseTypedDataAction(parseActionSwapTokenOrder)(options), parseTypedDataAction(parseActionCoboSafeCreate)(options), parseTypedDataAction(parseActionCoboSafeModificationDelegatedAddress)(options), parseTypedDataAction(parseActionCoboSafeModificationRole)(options), parseTypedDataAction(parseActionCoboSafeModificationTokenApproval)(options), parseTypedDataAction(parseActionRevokePermit)(options));
46
+ }
47
+ if (options.type === 'text') {
48
+ result.push(parseTextAction(parseActionCommon)(options), parseTextAction(parseActionCreateKey)(options), parseTextAction(parseActionVerifyAddress)(options));
49
+ }
50
+ const action = result.reduce((acc, val) => (Object.assign(Object.assign({}, acc), val)), {});
51
+ // filter out typedData or text keys
52
+ const actionKeys = Object.keys(action).filter((key) => !['sender', 'actionType', 'brand', 'contractId', 'chainId'].includes(key));
53
+ if (actionKeys.length > 1) {
54
+ console.error('parseAction: more than one action found', Object.keys(action));
55
+ }
56
+ if (actionKeys.length === 0) {
57
+ if (options.type === 'typed_data') {
58
+ return parseTypedDataAction(parseActionContractCall)(options);
59
+ }
60
+ else if (options.type === 'transaction') {
61
+ return parseActionContractCall(options);
62
+ }
63
+ return {};
64
+ }
65
+ return action;
66
+ }
@@ -0,0 +1,158 @@
1
+ import { ContractDesc, UsedChain, CollectionWithFloorPrice, TokenItem, ParseTxResponse, Chain } from '@rabby-wallet/rabby-api/dist/types';
2
+ import { TransactionGroup } from './walletProvider';
3
+ export interface SwapRequireData {
4
+ id: string;
5
+ protocol: {
6
+ name: string;
7
+ logo_url: string;
8
+ } | null;
9
+ bornAt: number;
10
+ hasInteraction: boolean;
11
+ rank: number | null;
12
+ sender: string;
13
+ receiverInWallet: boolean;
14
+ }
15
+ export interface SendRequireData {
16
+ eoa: {
17
+ id: string;
18
+ bornAt: number;
19
+ } | null;
20
+ cex: {
21
+ id: string;
22
+ name: string;
23
+ logo: string;
24
+ bornAt: number;
25
+ isDeposit: boolean;
26
+ supportToken?: boolean;
27
+ } | null;
28
+ contract: Record<string, ContractDesc> | null;
29
+ usd_value: number;
30
+ protocol: {
31
+ id: string;
32
+ logo_url: string;
33
+ name: string;
34
+ } | null;
35
+ hasTransfer: boolean;
36
+ isTokenContract: boolean;
37
+ usedChains: UsedChain[];
38
+ name: string | null;
39
+ onTransferWhitelist: boolean;
40
+ whitelistEnable: boolean;
41
+ receiverIsSpoofing: boolean;
42
+ hasReceiverPrivateKeyInWallet: boolean;
43
+ hasReceiverMnemonicInWallet: boolean;
44
+ }
45
+ export interface SendNFTRequireData extends SendRequireData {
46
+ collection?: CollectionWithFloorPrice | null;
47
+ }
48
+ export interface ApproveTokenRequireData {
49
+ isEOA: boolean;
50
+ contract: Record<string, ContractDesc> | null;
51
+ riskExposure: number;
52
+ rank: number | null;
53
+ hasInteraction: boolean;
54
+ bornAt: number;
55
+ protocol: {
56
+ id: string;
57
+ name: string;
58
+ logo_url: string;
59
+ } | null;
60
+ isDanger: boolean | null;
61
+ token: TokenItem;
62
+ }
63
+ export type RevokeTokenApproveRequireData = ApproveTokenRequireData;
64
+ export interface WrapTokenRequireData {
65
+ id: string;
66
+ protocol: {
67
+ name: string;
68
+ logo_url: string;
69
+ } | null;
70
+ bornAt: number;
71
+ hasInteraction: boolean;
72
+ rank: number | null;
73
+ sender: string;
74
+ receiverInWallet: boolean;
75
+ }
76
+ export interface ContractCallRequireData {
77
+ id: string;
78
+ contract: Record<string, ContractDesc> | null;
79
+ rank: number | null;
80
+ hasInteraction: boolean;
81
+ bornAt: number;
82
+ protocol: {
83
+ name: string;
84
+ logo_url: string;
85
+ } | null;
86
+ call: NonNullable<ParseTxResponse['contract_call']>;
87
+ payNativeTokenAmount: string;
88
+ nativeTokenSymbol: string;
89
+ unexpectedAddr: ReceiverData | null;
90
+ receiverInWallet: boolean;
91
+ }
92
+ export type ApproveNFTRequireData = Omit<ApproveTokenRequireData, 'token'> & {
93
+ tokenBalance: string;
94
+ };
95
+ export type RevokeNFTRequireData = ApproveNFTRequireData;
96
+ export interface CancelTxRequireData {
97
+ pendingTxs: TransactionGroup[];
98
+ }
99
+ export interface PushMultiSigRequireData {
100
+ contract: Record<string, ContractDesc> | null;
101
+ id: string;
102
+ }
103
+ export type BatchRevokePermit2RequireData = Record<string, Omit<ApproveTokenRequireData, 'token'>>;
104
+ export interface ReceiverData {
105
+ title?: string;
106
+ address: string;
107
+ chain: Chain;
108
+ eoa: {
109
+ id: string;
110
+ bornAt: number;
111
+ } | null;
112
+ cex: {
113
+ id: string;
114
+ name: string;
115
+ logo: string;
116
+ bornAt: number;
117
+ isDeposit: boolean;
118
+ supportToken?: boolean;
119
+ } | null;
120
+ contract: Record<string, ContractDesc> | null;
121
+ usd_value: number;
122
+ hasTransfer: boolean;
123
+ isTokenContract: boolean;
124
+ name: string | null;
125
+ onTransferWhitelist: boolean;
126
+ token?: TokenItem;
127
+ isLabelAddress?: boolean;
128
+ labelAddressLogo?: string;
129
+ hasReceiverMnemonicInWallet?: boolean;
130
+ hasReceiverPrivateKeyInWallet?: boolean;
131
+ rank?: number;
132
+ }
133
+ export interface ContractRequireData {
134
+ id: string;
135
+ protocol: {
136
+ name: string;
137
+ logo_url: string;
138
+ } | null;
139
+ bornAt: number;
140
+ hasInteraction: boolean;
141
+ rank: number | null;
142
+ unexpectedAddr: ReceiverData | null;
143
+ receiverInWallet: boolean;
144
+ }
145
+ export interface AssetOrderRequireData extends ContractRequireData {
146
+ sender: string;
147
+ }
148
+ export interface MultiSigRequireData {
149
+ id: string;
150
+ contract: Record<string, ContractDesc> | null;
151
+ }
152
+ export interface SwapTokenOrderRequireData extends ContractRequireData {
153
+ sender: string;
154
+ }
155
+ export type BatchApproveTokenRequireData = Omit<ApproveTokenRequireData, 'token'> & {
156
+ tokens: TokenItem[];
157
+ };
158
+ export type ActionRequireData = SwapRequireData | ApproveTokenRequireData | SendRequireData | ApproveNFTRequireData | RevokeNFTRequireData | ContractCallRequireData | Record<string, any> | ContractCallRequireData | CancelTxRequireData | WrapTokenRequireData | PushMultiSigRequireData | AssetOrderRequireData | BatchRevokePermit2RequireData | SwapTokenOrderRequireData | ContractRequireData | MultiSigRequireData | BatchApproveTokenRequireData | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { ParseTxResponse, Tx } from '@rabby-wallet/rabby-api/dist/types';
2
+ import { ParsedActionData } from './parsedActionData';
3
+ import { OpenApiService } from '@rabby-wallet/rabby-api';
4
+ import { WalletProvider } from './walletProvider';
5
+ import { ActionRequireData } from './actionRequireData';
6
+ type BaseFetchActionRequiredDataParameters<T extends 'typed_data' | 'transaction' | undefined> = {
7
+ actionData: ParsedActionData<T>;
8
+ sender: string;
9
+ walletProvider: WalletProvider;
10
+ apiProvider: OpenApiService;
11
+ };
12
+ export type FetchTransactionRequiredDataParameters = BaseFetchActionRequiredDataParameters<'transaction'> & {
13
+ type: 'transaction';
14
+ contractCall?: ParseTxResponse['contract_call'] | null;
15
+ chainId: string;
16
+ tx: Tx;
17
+ };
18
+ export type FetchTypedDataRequiredDataParameters = BaseFetchActionRequiredDataParameters<'typed_data'> & {
19
+ type: 'typed_data';
20
+ chainId?: string;
21
+ };
22
+ export type FetchActionRequiredDataParameters = FetchTransactionRequiredDataParameters | FetchTypedDataRequiredDataParameters;
23
+ export type FetchActionRequiredData<T = undefined> = (options: FetchActionRequiredDataParameters, likeAction?: T) => Promise<ActionRequireData>;
24
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { ContextActionData } from '@rabby-wallet/rabby-security-engine/dist/rules';
2
+ import { ActionRequireData } from './actionRequireData';
3
+ import { ParsedActionData } from './parsedActionData';
4
+ export type FormatSecurityEngineContextParameters = {
5
+ type: 'transaction';
6
+ actionData: ParsedActionData<'transaction'>;
7
+ requireData: ActionRequireData;
8
+ isTestnet: boolean;
9
+ chainId?: string;
10
+ provider: {
11
+ getTimeSpan: (time: number) => {
12
+ d: number;
13
+ h: number;
14
+ m: number;
15
+ s: number;
16
+ };
17
+ hasAddress: (address: string) => Promise<boolean>;
18
+ };
19
+ } | {
20
+ type: 'typed_data';
21
+ actionData: ParsedActionData<'typed_data'>;
22
+ requireData?: ActionRequireData;
23
+ isTestnet: boolean;
24
+ chainId?: string;
25
+ origin: string;
26
+ provider: {
27
+ getTimeSpan: (time: number) => {
28
+ d: number;
29
+ h: number;
30
+ m: number;
31
+ s: number;
32
+ };
33
+ hasAddress: (address: string) => Promise<boolean>;
34
+ };
35
+ } | {
36
+ type: 'text';
37
+ actionData: ParsedActionData<'text'>;
38
+ origin: string;
39
+ };
40
+ export type FormatSecurityEngineContext = (options: FormatSecurityEngineContextParameters) => Promise<ContextActionData>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './actionRequireData';
2
+ export * from './fetchActionRequiredData';
3
+ export * from './formatSecurityEngineContext';
4
+ export * from './parseAction';
5
+ export * from './parsedActionData';
@@ -0,0 +1,5 @@
1
+ export * from './actionRequireData';
2
+ export * from './fetchActionRequiredData';
3
+ export * from './formatSecurityEngineContext';
4
+ export * from './parseAction';
5
+ export * from './parsedActionData';
@@ -0,0 +1,26 @@
1
+ import { ParseTxResponse, ExplainTxResponse, Tx, ParseTypedDataResponse, ParseTextResponse } from '@rabby-wallet/rabby-api/dist/types';
2
+ import { ParsedActionData } from './parsedActionData';
3
+ export type ParseTransactionActionParameters = {
4
+ type: 'transaction';
5
+ data: ParseTxResponse['action'];
6
+ balanceChange: ExplainTxResponse['balance_change'];
7
+ tx: Tx;
8
+ preExecVersion: 'v0' | 'v1' | 'v2';
9
+ gasUsed: number;
10
+ };
11
+ export type ParseTypedDataActionParameters = {
12
+ type: 'typed_data';
13
+ data: ParseTypedDataResponse['action'];
14
+ typedData: null | Record<string, any>;
15
+ sender: string;
16
+ };
17
+ export type ParseTextActionParameters = {
18
+ type: 'text';
19
+ data: ParseTextResponse['action'];
20
+ text: string;
21
+ sender: string;
22
+ };
23
+ export type ParseActionParameters = ParseTransactionActionParameters | ParseTypedDataActionParameters | ParseTextActionParameters;
24
+ export type ActionType = ParseActionParameters['type'];
25
+ export type ParseAction<T extends ActionType | undefined = undefined> = (options: T extends 'transaction' ? ParseTransactionActionParameters : T extends 'typed_data' ? ParseTypedDataActionParameters : T extends 'text' ? ParseTextActionParameters : ParseActionParameters) => ParsedActionData<T>;
26
+ export type PartialParseAction<T extends ActionType | undefined = undefined> = (options: T extends 'transaction' ? ParseTransactionActionParameters : T extends 'typed_data' ? ParseTypedDataActionParameters : T extends 'text' ? ParseTextActionParameters : ParseActionParameters) => Partial<ParsedActionData<T>>;
@@ -0,0 +1 @@
1
+ export {};