@rabby-wallet/rabby-action 0.1.2 → 0.1.4

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.
@@ -25,6 +25,7 @@ export const fetchDataApproveNFT = (options, likeAction) => __awaiter(void 0, vo
25
25
  protocol: null,
26
26
  isDanger: false,
27
27
  tokenBalance: '0',
28
+ hasInteraction: false,
28
29
  };
29
30
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
30
31
  const contractInfo = yield apiProvider.getContractInfo(action.spender, chainId);
@@ -47,6 +48,10 @@ export const fetchDataApproveNFT = (options, likeAction) => __awaiter(void 0, vo
47
48
  }));
48
49
  }
49
50
  }));
51
+ queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
52
+ const hasInteraction = yield apiProvider.hasInteraction(sender, chainId, action.spender);
53
+ result.hasInteraction = hasInteraction.has_interaction;
54
+ }));
50
55
  yield waitQueueFinished(queue);
51
56
  return result;
52
57
  });
@@ -21,6 +21,7 @@ export const fetchDataApproveToken = (options, likeAction) => __awaiter(void 0,
21
21
  isEOA: false,
22
22
  contract: null,
23
23
  riskExposure: 0,
24
+ hasInteraction: false,
24
25
  rank: null,
25
26
  bornAt: 0,
26
27
  protocol: null,
@@ -54,6 +55,10 @@ export const fetchDataApproveToken = (options, likeAction) => __awaiter(void 0,
54
55
  result.token = t;
55
56
  }));
56
57
  }
58
+ queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
59
+ const hasInteraction = yield apiProvider.hasInteraction(sender, chainId, spender);
60
+ result.hasInteraction = hasInteraction.has_interaction;
61
+ }));
57
62
  yield waitQueueFinished(queue);
58
63
  return result;
59
64
  });
@@ -29,6 +29,7 @@ export const fetchDataBatchPermit2 = (options) => __awaiter(void 0, void 0, void
29
29
  protocol: null,
30
30
  isDanger: false,
31
31
  tokens: tokens.map((token) => (Object.assign(Object.assign({}, token), { amount: 0, raw_amount_hex_str: '0x0' }))),
32
+ hasInteraction: false,
32
33
  };
33
34
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
34
35
  const contractInfo = yield apiProvider.getContractInfo(spender, chainId);
@@ -55,6 +56,10 @@ export const fetchDataBatchPermit2 = (options) => __awaiter(void 0, void 0, void
55
56
  const list = yield Promise.all(tokens.map((token) => apiProvider.getToken(sender, chainId, token.id)));
56
57
  result.tokens = list;
57
58
  }));
59
+ queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
60
+ const hasInteraction = yield apiProvider.hasInteraction(sender, chainId, spender);
61
+ result.hasInteraction = hasInteraction.has_interaction;
62
+ }));
58
63
  yield waitQueueFinished(queue);
59
64
  return result;
60
65
  });
@@ -29,6 +29,7 @@ export const fetchDataCommon = (options, likeAction) => __awaiter(void 0, void 0
29
29
  rank: null,
30
30
  unexpectedAddr: null,
31
31
  receiverInWallet: false,
32
+ hasInteraction: false,
32
33
  };
33
34
  if (options.type === 'typed_data') {
34
35
  result.sender = sender;
@@ -52,6 +53,10 @@ export const fetchDataCommon = (options, likeAction) => __awaiter(void 0, void 0
52
53
  result.bornAt = desc.born_at;
53
54
  }));
54
55
  }
56
+ queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
57
+ const hasInteraction = yield apiProvider.hasInteraction(sender, chainId, receiver);
58
+ result.hasInteraction = hasInteraction.has_interaction;
59
+ }));
55
60
  if (actionData.contractCall || actionData.common) {
56
61
  const chain = walletProvider.findChain({
57
62
  serverId: chainId,
@@ -34,6 +34,7 @@ export const fetchDataContractCall = (options) => __awaiter(void 0, void 0, void
34
34
  unexpectedAddr: null,
35
35
  receiverInWallet: false,
36
36
  isDanger: false,
37
+ hasInteraction: false,
37
38
  };
38
39
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
39
40
  const contractInfo = yield apiProvider.getContractInfo(contractCall.contract.id, chainId);
@@ -42,7 +43,7 @@ export const fetchDataContractCall = (options) => __awaiter(void 0, void 0, void
42
43
  }
43
44
  else {
44
45
  result.rank = contractInfo.credit.rank_at;
45
- result.isDanger = !!(contractInfo.is_danger.auto || contractInfo.is_danger.edit);
46
+ result.isDanger = !!contractInfo.is_phishing;
46
47
  }
47
48
  }));
48
49
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
@@ -55,6 +56,10 @@ export const fetchDataContractCall = (options) => __awaiter(void 0, void 0, void
55
56
  }
56
57
  result.protocol = getProtocol(desc.protocol, chainId);
57
58
  }));
59
+ queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
60
+ const hasInteraction = yield apiProvider.hasInteraction(sender, chainId, contractCall.contract.id);
61
+ result.hasInteraction = hasInteraction.has_interaction;
62
+ }));
58
63
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
59
64
  var _a, _b;
60
65
  const addr = (_a = actionData.common) === null || _a === void 0 ? void 0 : _a.receiver;
@@ -46,7 +46,7 @@ export const fetchDataSend = (options, likeSendAction) => __awaiter(void 0, void
46
46
  result.hasTransfer = has_transfer;
47
47
  }));
48
48
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
49
- var _a;
49
+ var _a, _b;
50
50
  const { desc } = yield apiProvider.addrDesc(sendAction.to);
51
51
  if ((_a = desc.cex) === null || _a === void 0 ? void 0 : _a.id) {
52
52
  result.cex = {
@@ -66,6 +66,9 @@ export const fetchDataSend = (options, likeSendAction) => __awaiter(void 0, void
66
66
  bornAt: desc.born_at,
67
67
  };
68
68
  }
69
+ if ((_b = desc.protocol) === null || _b === void 0 ? void 0 : _b[chainId]) {
70
+ result.protocol = desc.protocol[chainId];
71
+ }
69
72
  result.usd_value = desc.usd_value;
70
73
  if (result.cex) {
71
74
  const { support } = yield apiProvider.depositCexSupport(sendAction.token.id, sendAction.token.chain, result.cex.id);
@@ -35,6 +35,7 @@ export const fetchDataSwap = (options, likeSwapAction) => __awaiter(void 0, void
35
35
  rank: null,
36
36
  sender,
37
37
  receiverInWallet,
38
+ hasInteraction: false,
38
39
  };
39
40
  queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
40
41
  const contractInfo = yield apiProvider.getContractInfo(id, chainId);
@@ -47,6 +48,10 @@ export const fetchDataSwap = (options, likeSwapAction) => __awaiter(void 0, void
47
48
  result.protocol = contractInfo.protocol;
48
49
  }
49
50
  }));
51
+ queue.add(() => __awaiter(void 0, void 0, void 0, function* () {
52
+ const hasInteraction = yield apiProvider.hasInteraction(sender, chainId, id);
53
+ result.hasInteraction = hasInteraction.has_interaction;
54
+ }));
50
55
  yield waitQueueFinished(queue);
51
56
  return result;
52
57
  });
@@ -10,6 +10,7 @@ export interface SwapRequireData {
10
10
  rank: number | null;
11
11
  sender: string;
12
12
  receiverInWallet: boolean;
13
+ hasInteraction: boolean;
13
14
  }
14
15
  export interface SendRequireData {
15
16
  eoa: {
@@ -57,6 +58,7 @@ export interface ApproveTokenRequireData {
57
58
  } | null;
58
59
  isDanger: boolean | null;
59
60
  token: TokenItem;
61
+ hasInteraction: boolean;
60
62
  }
61
63
  export type RevokeTokenApproveRequireData = ApproveTokenRequireData;
62
64
  export interface WrapTokenRequireData {
@@ -69,6 +71,7 @@ export interface WrapTokenRequireData {
69
71
  rank: number | null;
70
72
  sender: string;
71
73
  receiverInWallet: boolean;
74
+ hasInteraction: boolean;
72
75
  }
73
76
  export interface ContractCallRequireData {
74
77
  id: string;
@@ -85,6 +88,7 @@ export interface ContractCallRequireData {
85
88
  unexpectedAddr: ReceiverData | null;
86
89
  receiverInWallet: boolean;
87
90
  isDanger?: boolean;
91
+ hasInteraction: boolean;
88
92
  }
89
93
  export type ApproveNFTRequireData = Omit<ApproveTokenRequireData, 'token'> & {
90
94
  tokenBalance: string;
@@ -140,6 +144,7 @@ export interface ContractRequireData {
140
144
  rank: number | null;
141
145
  unexpectedAddr: ReceiverData | null;
142
146
  receiverInWallet: boolean;
147
+ hasInteraction: boolean;
143
148
  }
144
149
  export interface AssetOrderRequireData extends ContractRequireData {
145
150
  sender: string;
@@ -5,8 +5,8 @@ export const calcSlippageTolerance = (base, actual) => {
5
5
  if (baseBn.eq(0) && actualBn.eq(0))
6
6
  return 0;
7
7
  if (baseBn.eq(0))
8
- return 1;
9
- if (actualBn.eq(0))
10
8
  return -1;
9
+ if (actualBn.eq(0))
10
+ return 1;
11
11
  return baseBn.minus(actualBn).div(baseBn).toNumber();
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-action",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -12,7 +12,7 @@
12
12
  "devDependencies": {
13
13
  "@babel/preset-env": "^7.19.1",
14
14
  "@debank/common": "^0.3.60",
15
- "@rabby-wallet/rabby-api": "0.7.28",
15
+ "@rabby-wallet/rabby-api": "0.7.33",
16
16
  "@rabby-wallet/rabby-security-engine": "2.0.7",
17
17
  "@types/jest": "^29.0.3",
18
18
  "@types/lodash": "^4.14.185",