@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.
- package/README.md +7 -0
- package/dist/actions/approveNFT/fetchData.d.ts +4 -0
- package/dist/actions/approveNFT/fetchData.js +60 -0
- package/dist/actions/approveNFT/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/approveNFT/formatSecurityEngine.js +31 -0
- package/dist/actions/approveNFT/parseAction.d.ts +2 -0
- package/dist/actions/approveNFT/parseAction.js +9 -0
- package/dist/actions/approveNFTCollection/fetchData.d.ts +2 -0
- package/dist/actions/approveNFTCollection/fetchData.js +19 -0
- package/dist/actions/approveNFTCollection/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/approveNFTCollection/formatSecurityEngine.js +31 -0
- package/dist/actions/approveNFTCollection/parseAction.d.ts +2 -0
- package/dist/actions/approveNFTCollection/parseAction.js +9 -0
- package/dist/actions/approveToken/fetchData.d.ts +6 -0
- package/dist/actions/approveToken/fetchData.js +64 -0
- package/dist/actions/approveToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/approveToken/formatSecurityEngine.js +31 -0
- package/dist/actions/approveToken/parseAction.d.ts +2 -0
- package/dist/actions/approveToken/parseAction.js +13 -0
- package/dist/actions/assetOrder/fetchData.d.ts +2 -0
- package/dist/actions/assetOrder/fetchData.js +29 -0
- package/dist/actions/assetOrder/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/assetOrder/formatSecurityEngine.js +30 -0
- package/dist/actions/assetOrder/parseAction.d.ts +2 -0
- package/dist/actions/assetOrder/parseAction.js +18 -0
- package/dist/actions/batchPermit2/fetchData.d.ts +2 -0
- package/dist/actions/batchPermit2/fetchData.js +65 -0
- package/dist/actions/batchPermit2/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/batchPermit2/formatSecurityEngine.js +30 -0
- package/dist/actions/batchPermit2/parseAction.d.ts +2 -0
- package/dist/actions/batchPermit2/parseAction.js +9 -0
- package/dist/actions/batchSellNFT/fetchData.d.ts +2 -0
- package/dist/actions/batchSellNFT/fetchData.js +21 -0
- package/dist/actions/batchSellNFT/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/batchSellNFT/formatSecurityEngine.js +33 -0
- package/dist/actions/batchSellNFT/parseAction.d.ts +2 -0
- package/dist/actions/batchSellNFT/parseAction.js +9 -0
- package/dist/actions/buyNFT/fetchData.d.ts +2 -0
- package/dist/actions/buyNFT/fetchData.js +21 -0
- package/dist/actions/buyNFT/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/buyNFT/formatSecurityEngine.js +33 -0
- package/dist/actions/buyNFT/parseAction.d.ts +2 -0
- package/dist/actions/buyNFT/parseAction.js +9 -0
- package/dist/actions/cancelTx/fetchData.d.ts +2 -0
- package/dist/actions/cancelTx/fetchData.js +32 -0
- package/dist/actions/cancelTx/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/cancelTx/formatSecurityEngine.js +12 -0
- package/dist/actions/cancelTx/parseAction.d.ts +2 -0
- package/dist/actions/cancelTx/parseAction.js +11 -0
- package/dist/actions/coboSafeCreate/fetchData.d.ts +2 -0
- package/dist/actions/coboSafeCreate/fetchData.js +12 -0
- package/dist/actions/coboSafeCreate/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/coboSafeCreate/formatSecurityEngine.js +12 -0
- package/dist/actions/coboSafeCreate/parseAction.d.ts +2 -0
- package/dist/actions/coboSafeCreate/parseAction.js +9 -0
- package/dist/actions/coboSafeModificationDelegatedAddress/fetchData.d.ts +2 -0
- package/dist/actions/coboSafeModificationDelegatedAddress/fetchData.js +12 -0
- package/dist/actions/coboSafeModificationDelegatedAddress/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/coboSafeModificationDelegatedAddress/formatSecurityEngine.js +12 -0
- package/dist/actions/coboSafeModificationDelegatedAddress/parseAction.d.ts +2 -0
- package/dist/actions/coboSafeModificationDelegatedAddress/parseAction.js +9 -0
- package/dist/actions/coboSafeModificationRole/fetchData.d.ts +2 -0
- package/dist/actions/coboSafeModificationRole/fetchData.js +12 -0
- package/dist/actions/coboSafeModificationRole/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/coboSafeModificationRole/formatSecurityEngine.js +12 -0
- package/dist/actions/coboSafeModificationRole/parseAction.d.ts +2 -0
- package/dist/actions/coboSafeModificationRole/parseAction.js +9 -0
- package/dist/actions/coboSafeModificationTokenApproval/fetchData.d.ts +2 -0
- package/dist/actions/coboSafeModificationTokenApproval/fetchData.js +12 -0
- package/dist/actions/coboSafeModificationTokenApproval/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/coboSafeModificationTokenApproval/formatSecurityEngine.js +12 -0
- package/dist/actions/coboSafeModificationTokenApproval/parseAction.d.ts +2 -0
- package/dist/actions/coboSafeModificationTokenApproval/parseAction.js +9 -0
- package/dist/actions/common/fetchData.d.ts +4 -0
- package/dist/actions/common/fetchData.js +119 -0
- package/dist/actions/common/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/common/formatSecurityEngine.js +21 -0
- package/dist/actions/common/parseAction.d.ts +2 -0
- package/dist/actions/common/parseAction.js +14 -0
- package/dist/actions/contractCall/fetchData.d.ts +2 -0
- package/dist/actions/contractCall/fetchData.js +115 -0
- package/dist/actions/contractCall/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/contractCall/formatSecurityEngine.js +25 -0
- package/dist/actions/contractCall/parseAction.d.ts +2 -0
- package/dist/actions/contractCall/parseAction.js +5 -0
- package/dist/actions/createKey/fetchData.d.ts +2 -0
- package/dist/actions/createKey/fetchData.js +12 -0
- package/dist/actions/createKey/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/createKey/formatSecurityEngine.js +24 -0
- package/dist/actions/createKey/parseAction.d.ts +2 -0
- package/dist/actions/createKey/parseAction.js +9 -0
- package/dist/actions/crossSwapToken/fetchData.d.ts +2 -0
- package/dist/actions/crossSwapToken/fetchData.js +19 -0
- package/dist/actions/crossSwapToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/crossSwapToken/formatSecurityEngine.js +38 -0
- package/dist/actions/crossSwapToken/parseAction.d.ts +2 -0
- package/dist/actions/crossSwapToken/parseAction.js +26 -0
- package/dist/actions/crossToken/fetchData.d.ts +2 -0
- package/dist/actions/crossToken/fetchData.js +19 -0
- package/dist/actions/crossToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/crossToken/formatSecurityEngine.js +38 -0
- package/dist/actions/crossToken/parseAction.d.ts +2 -0
- package/dist/actions/crossToken/parseAction.js +22 -0
- package/dist/actions/deployContract/fetchData.d.ts +2 -0
- package/dist/actions/deployContract/fetchData.js +12 -0
- package/dist/actions/deployContract/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/deployContract/formatSecurityEngine.js +12 -0
- package/dist/actions/deployContract/parseAction.d.ts +2 -0
- package/dist/actions/deployContract/parseAction.js +9 -0
- package/dist/actions/permit/fetchData.d.ts +2 -0
- package/dist/actions/permit/fetchData.js +19 -0
- package/dist/actions/permit/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/permit/formatSecurityEngine.js +30 -0
- package/dist/actions/permit/parseAction.d.ts +2 -0
- package/dist/actions/permit/parseAction.js +9 -0
- package/dist/actions/permit2/fetchData.d.ts +2 -0
- package/dist/actions/permit2/fetchData.js +19 -0
- package/dist/actions/permit2/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/permit2/formatSecurityEngine.js +30 -0
- package/dist/actions/permit2/parseAction.d.ts +2 -0
- package/dist/actions/permit2/parseAction.js +9 -0
- package/dist/actions/permit2BatchRevokeToken/fetchData.d.ts +2 -0
- package/dist/actions/permit2BatchRevokeToken/fetchData.js +30 -0
- package/dist/actions/permit2BatchRevokeToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/permit2BatchRevokeToken/formatSecurityEngine.js +12 -0
- package/dist/actions/permit2BatchRevokeToken/parseAction.d.ts +2 -0
- package/dist/actions/permit2BatchRevokeToken/parseAction.js +9 -0
- package/dist/actions/pushMultiSig/fetchData.d.ts +2 -0
- package/dist/actions/pushMultiSig/fetchData.js +27 -0
- package/dist/actions/pushMultiSig/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/pushMultiSig/formatSecurityEngine.js +12 -0
- package/dist/actions/pushMultiSig/parseAction.d.ts +2 -0
- package/dist/actions/pushMultiSig/parseAction.js +9 -0
- package/dist/actions/revokeNFT/fetchData.d.ts +2 -0
- package/dist/actions/revokeNFT/fetchData.js +19 -0
- package/dist/actions/revokeNFT/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/revokeNFT/formatSecurityEngine.js +12 -0
- package/dist/actions/revokeNFT/parseAction.d.ts +2 -0
- package/dist/actions/revokeNFT/parseAction.js +9 -0
- package/dist/actions/revokeNFTCollection/fetchData.d.ts +2 -0
- package/dist/actions/revokeNFTCollection/fetchData.js +19 -0
- package/dist/actions/revokeNFTCollection/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/revokeNFTCollection/formatSecurityEngine.js +12 -0
- package/dist/actions/revokeNFTCollection/parseAction.d.ts +2 -0
- package/dist/actions/revokeNFTCollection/parseAction.js +9 -0
- package/dist/actions/revokePermit/fetchData.d.ts +2 -0
- package/dist/actions/revokePermit/fetchData.js +19 -0
- package/dist/actions/revokePermit/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/revokePermit/formatSecurityEngine.js +12 -0
- package/dist/actions/revokePermit/parseAction.d.ts +2 -0
- package/dist/actions/revokePermit/parseAction.js +9 -0
- package/dist/actions/revokePermit2/fetchData.d.ts +2 -0
- package/dist/actions/revokePermit2/fetchData.js +19 -0
- package/dist/actions/revokePermit2/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/revokePermit2/formatSecurityEngine.js +12 -0
- package/dist/actions/revokePermit2/parseAction.d.ts +2 -0
- package/dist/actions/revokePermit2/parseAction.js +13 -0
- package/dist/actions/revokeToken/fetchData.d.ts +2 -0
- package/dist/actions/revokeToken/fetchData.js +19 -0
- package/dist/actions/revokeToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/revokeToken/formatSecurityEngine.js +25 -0
- package/dist/actions/revokeToken/parseAction.d.ts +2 -0
- package/dist/actions/revokeToken/parseAction.js +14 -0
- package/dist/actions/sellNFT/fetchData.d.ts +2 -0
- package/dist/actions/sellNFT/fetchData.js +21 -0
- package/dist/actions/sellNFT/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/sellNFT/formatSecurityEngine.js +33 -0
- package/dist/actions/sellNFT/parseAction.d.ts +2 -0
- package/dist/actions/sellNFT/parseAction.js +9 -0
- package/dist/actions/send/fetchData.d.ts +8 -0
- package/dist/actions/send/fetchData.js +103 -0
- package/dist/actions/send/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/send/formatSecurityEngine.js +47 -0
- package/dist/actions/send/parseAction.d.ts +2 -0
- package/dist/actions/send/parseAction.js +9 -0
- package/dist/actions/sendNFT/fetchData.d.ts +2 -0
- package/dist/actions/sendNFT/fetchData.js +26 -0
- package/dist/actions/sendNFT/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/sendNFT/formatSecurityEngine.js +46 -0
- package/dist/actions/sendNFT/parseAction.d.ts +2 -0
- package/dist/actions/sendNFT/parseAction.js +9 -0
- package/dist/actions/signMultiSig/fetchData.d.ts +2 -0
- package/dist/actions/signMultiSig/fetchData.js +27 -0
- package/dist/actions/signMultiSig/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/signMultiSig/formatSecurityEngine.js +12 -0
- package/dist/actions/signMultiSig/parseAction.d.ts +2 -0
- package/dist/actions/signMultiSig/parseAction.js +9 -0
- package/dist/actions/swap/fetchData.d.ts +4 -0
- package/dist/actions/swap/fetchData.js +51 -0
- package/dist/actions/swap/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/swap/formatSecurityEngine.js +39 -0
- package/dist/actions/swap/parseAction.d.ts +2 -0
- package/dist/actions/swap/parseAction.js +43 -0
- package/dist/actions/swapTokenOrder/fetchData.d.ts +2 -0
- package/dist/actions/swapTokenOrder/fetchData.js +21 -0
- package/dist/actions/swapTokenOrder/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/swapTokenOrder/formatSecurityEngine.js +35 -0
- package/dist/actions/swapTokenOrder/parseAction.d.ts +2 -0
- package/dist/actions/swapTokenOrder/parseAction.js +27 -0
- package/dist/actions/unwrapToken/fetchData.d.ts +2 -0
- package/dist/actions/unwrapToken/fetchData.js +19 -0
- package/dist/actions/unwrapToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/unwrapToken/formatSecurityEngine.js +34 -0
- package/dist/actions/unwrapToken/parseAction.d.ts +2 -0
- package/dist/actions/unwrapToken/parseAction.js +17 -0
- package/dist/actions/verifyAddress/fetchData.d.ts +2 -0
- package/dist/actions/verifyAddress/fetchData.js +12 -0
- package/dist/actions/verifyAddress/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/verifyAddress/formatSecurityEngine.js +24 -0
- package/dist/actions/verifyAddress/parseAction.d.ts +2 -0
- package/dist/actions/verifyAddress/parseAction.js +9 -0
- package/dist/actions/wrapToken/fetchData.d.ts +2 -0
- package/dist/actions/wrapToken/fetchData.js +19 -0
- package/dist/actions/wrapToken/formatSecurityEngine.d.ts +2 -0
- package/dist/actions/wrapToken/formatSecurityEngine.js +34 -0
- package/dist/actions/wrapToken/parseAction.d.ts +2 -0
- package/dist/actions/wrapToken/parseAction.js +17 -0
- package/dist/fetchActionRequiredData.d.ts +2 -0
- package/dist/fetchActionRequiredData.js +87 -0
- package/dist/formatSecurityEngineContext.d.ts +2 -0
- package/dist/formatSecurityEngineContext.js +89 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/parseAction.d.ts +4 -0
- package/dist/parseAction.js +66 -0
- package/dist/types/actionRequireData.d.ts +158 -0
- package/dist/types/actionRequireData.js +1 -0
- package/dist/types/fetchActionRequiredData.d.ts +24 -0
- package/dist/types/fetchActionRequiredData.js +1 -0
- package/dist/types/formatSecurityEngineContext.d.ts +40 -0
- package/dist/types/formatSecurityEngineContext.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/parseAction.d.ts +26 -0
- package/dist/types/parseAction.js +1 -0
- package/dist/types/parsedActionData.d.ts +161 -0
- package/dist/types/parsedActionData.js +1 -0
- package/dist/types/walletProvider.d.ts +79 -0
- package/dist/types/walletProvider.js +1 -0
- package/dist/utils/calcSlippageTolerance.d.ts +1 -0
- package/dist/utils/calcSlippageTolerance.js +12 -0
- package/dist/utils/calcUSDValueChange.d.ts +1 -0
- package/dist/utils/calcUSDValueChange.js +12 -0
- package/dist/utils/getProtocol.d.ts +6 -0
- package/dist/utils/getProtocol.js +7 -0
- package/dist/utils/isSameAddress.d.ts +4 -0
- package/dist/utils/isSameAddress.js +8 -0
- package/dist/utils/keyring.d.ts +10 -0
- package/dist/utils/keyring.js +10 -0
- package/dist/utils/parseTextAction.d.ts +2 -0
- package/dist/utils/parseTextAction.js +9 -0
- package/dist/utils/parseTypedDataAction.d.ts +2 -0
- package/dist/utils/parseTypedDataAction.js +25 -0
- package/dist/utils/waitQueueFinished.d.ts +2 -0
- package/dist/utils/waitQueueFinished.js +8 -0
- package/package.json +56 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { TokenItem, NFTItem, RevokeTokenApproveAction, PushMultiSigAction, ApproveNFTAction, BatchSellNFTOrderAction, BuyNFTOrderAction, CreateCoboSafeAction, CreateKeyAction, SellNFTOrderAction, SendAction, SignMultiSigActions, SubmitDelegatedAddressModificationAction, SubmitSafeRoleModificationAction, SubmitTokenApprovalModificationAction, VerifyAddressAction, BatchPermit2Action, Permit2Action, PermitAction, RevokeNFTAction, SendNFTAction, ApproveAction, ApproveNFTCollectionAction, RevokeNFTCollectionAction, RevokePermit2Action } from '@rabby-wallet/rabby-api/dist/types';
|
|
2
|
+
import { ActionType } from './parseAction';
|
|
3
|
+
export interface ReceiveTokenItem extends TokenItem {
|
|
4
|
+
min_amount: number;
|
|
5
|
+
min_raw_amount: string;
|
|
6
|
+
}
|
|
7
|
+
interface PermitActionData extends PermitAction {
|
|
8
|
+
expire_at: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
interface Permit2ActionData extends Permit2Action {
|
|
11
|
+
sig_expire_at: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface BatchPermit2ActionData extends BatchPermit2Action {
|
|
14
|
+
sig_expire_at: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
export type ParsedTransactionActionData = {
|
|
17
|
+
swap?: {
|
|
18
|
+
payToken: TokenItem;
|
|
19
|
+
receiveToken: ReceiveTokenItem;
|
|
20
|
+
minReceive: TokenItem;
|
|
21
|
+
slippageTolerance: number | null;
|
|
22
|
+
receiver: string;
|
|
23
|
+
usdValueDiff: string | null;
|
|
24
|
+
usdValuePercentage: number | null;
|
|
25
|
+
balanceChange: {
|
|
26
|
+
support: boolean;
|
|
27
|
+
success: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
crossToken?: {
|
|
31
|
+
payToken: TokenItem;
|
|
32
|
+
receiveToken: ReceiveTokenItem;
|
|
33
|
+
receiver: string;
|
|
34
|
+
usdValueDiff: string;
|
|
35
|
+
usdValuePercentage: number;
|
|
36
|
+
};
|
|
37
|
+
crossSwapToken?: {
|
|
38
|
+
payToken: TokenItem;
|
|
39
|
+
receiveToken: ReceiveTokenItem;
|
|
40
|
+
receiver: string;
|
|
41
|
+
usdValueDiff: string;
|
|
42
|
+
usdValuePercentage: number;
|
|
43
|
+
};
|
|
44
|
+
approveToken?: ApproveAction;
|
|
45
|
+
sendNFT?: SendNFTAction;
|
|
46
|
+
revokeNFT?: RevokeNFTAction;
|
|
47
|
+
approveNFTCollection?: ApproveNFTCollectionAction;
|
|
48
|
+
revokeNFTCollection?: RevokeNFTCollectionAction;
|
|
49
|
+
revokeToken?: {
|
|
50
|
+
spender: string;
|
|
51
|
+
token: TokenItem;
|
|
52
|
+
gasUsed: number;
|
|
53
|
+
};
|
|
54
|
+
revokePermit2?: RevokePermit2Action;
|
|
55
|
+
wrapToken?: {
|
|
56
|
+
payToken: TokenItem;
|
|
57
|
+
receiveToken: ReceiveTokenItem;
|
|
58
|
+
slippageTolerance: number;
|
|
59
|
+
receiver: string;
|
|
60
|
+
};
|
|
61
|
+
unWrapToken?: {
|
|
62
|
+
payToken: TokenItem;
|
|
63
|
+
receiveToken: ReceiveTokenItem;
|
|
64
|
+
slippageTolerance: number;
|
|
65
|
+
receiver: string;
|
|
66
|
+
};
|
|
67
|
+
deployContract?: Record<string, never>;
|
|
68
|
+
cancelTx?: {
|
|
69
|
+
nonce: string;
|
|
70
|
+
};
|
|
71
|
+
pushMultiSig?: PushMultiSigAction;
|
|
72
|
+
permit2BatchRevokeToken?: {
|
|
73
|
+
permit2_id: string;
|
|
74
|
+
revoke_list: RevokeTokenApproveAction[];
|
|
75
|
+
};
|
|
76
|
+
approveNFT?: ApproveNFTAction;
|
|
77
|
+
send?: SendAction;
|
|
78
|
+
contractCall?: object;
|
|
79
|
+
assetOrder?: {
|
|
80
|
+
payTokenList: TokenItem[];
|
|
81
|
+
payNFTList: NFTItem[];
|
|
82
|
+
receiveTokenList: TokenItem[];
|
|
83
|
+
receiveNFTList: NFTItem[];
|
|
84
|
+
takers: string[];
|
|
85
|
+
receiver: string | null;
|
|
86
|
+
expireAt: string | null;
|
|
87
|
+
};
|
|
88
|
+
common?: {
|
|
89
|
+
title: string;
|
|
90
|
+
desc: string;
|
|
91
|
+
is_asset_changed: boolean;
|
|
92
|
+
is_involving_privacy: boolean;
|
|
93
|
+
receiver?: string;
|
|
94
|
+
from: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export type ParsedTypedDataActionData = {
|
|
98
|
+
chainId?: string;
|
|
99
|
+
brand?: {
|
|
100
|
+
logo_url: string;
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
contractId?: string;
|
|
104
|
+
sender: string;
|
|
105
|
+
actionType: string | null;
|
|
106
|
+
sellNFT?: SellNFTOrderAction;
|
|
107
|
+
batchSellNFT?: BatchSellNFTOrderAction;
|
|
108
|
+
signMultiSig?: SignMultiSigActions;
|
|
109
|
+
buyNFT?: BuyNFTOrderAction;
|
|
110
|
+
permit?: PermitActionData;
|
|
111
|
+
permit2?: Permit2ActionData;
|
|
112
|
+
batchPermit2?: BatchPermit2ActionData;
|
|
113
|
+
swapTokenOrder?: {
|
|
114
|
+
payToken: TokenItem;
|
|
115
|
+
receiveToken: TokenItem;
|
|
116
|
+
receiver: string;
|
|
117
|
+
usdValueDiff: string;
|
|
118
|
+
usdValuePercentage: number;
|
|
119
|
+
expireAt: number | null;
|
|
120
|
+
};
|
|
121
|
+
createKey?: CreateKeyAction;
|
|
122
|
+
verifyAddress?: VerifyAddressAction;
|
|
123
|
+
coboSafeCreate?: CreateCoboSafeAction;
|
|
124
|
+
coboSafeModificationDelegatedAddress?: SubmitSafeRoleModificationAction;
|
|
125
|
+
coboSafeModificationRole?: SubmitDelegatedAddressModificationAction;
|
|
126
|
+
coboSafeModificationTokenApproval?: SubmitTokenApprovalModificationAction;
|
|
127
|
+
revokePermit?: RevokeTokenApproveAction;
|
|
128
|
+
approveNFT?: ApproveNFTAction;
|
|
129
|
+
send?: SendAction;
|
|
130
|
+
contractCall?: object;
|
|
131
|
+
assetOrder?: {
|
|
132
|
+
payTokenList: TokenItem[];
|
|
133
|
+
payNFTList: NFTItem[];
|
|
134
|
+
receiveTokenList: TokenItem[];
|
|
135
|
+
receiveNFTList: NFTItem[];
|
|
136
|
+
takers: string[];
|
|
137
|
+
receiver: string | null;
|
|
138
|
+
expireAt: string | null;
|
|
139
|
+
};
|
|
140
|
+
common?: {
|
|
141
|
+
title: string;
|
|
142
|
+
desc: string;
|
|
143
|
+
is_asset_changed: boolean;
|
|
144
|
+
is_involving_privacy: boolean;
|
|
145
|
+
receiver?: string;
|
|
146
|
+
from: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export type ParsedTextActionData = {
|
|
150
|
+
sender: string;
|
|
151
|
+
createKey?: CreateKeyAction;
|
|
152
|
+
verifyAddress?: VerifyAddressAction;
|
|
153
|
+
common?: {
|
|
154
|
+
desc: string;
|
|
155
|
+
title: string;
|
|
156
|
+
is_asset_changed: boolean;
|
|
157
|
+
is_involving_privacy: boolean;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export type ParsedActionData<T extends ActionType | undefined = undefined> = T extends 'typed_data' ? ParsedTypedDataActionData : T extends 'transaction' ? ParsedTransactionActionData : T extends 'text' ? ParsedTextActionData : ParsedTransactionActionData | ParsedTypedDataActionData | ParsedTextActionData;
|
|
161
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Tx, TxPushType, ExplainTxResponse, BasicDappInfo } from '@rabby-wallet/rabby-api/dist/types';
|
|
2
|
+
import { ParsedActionData } from './parsedActionData';
|
|
3
|
+
import { ActionRequireData } from './actionRequireData';
|
|
4
|
+
import { CHAINS_ENUM, Chain } from '@debank/common';
|
|
5
|
+
export interface ConnectedSite {
|
|
6
|
+
origin: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
name: string;
|
|
9
|
+
chain: CHAINS_ENUM;
|
|
10
|
+
e?: number;
|
|
11
|
+
isSigned: boolean;
|
|
12
|
+
isTop: boolean;
|
|
13
|
+
order?: number;
|
|
14
|
+
isConnected: boolean;
|
|
15
|
+
preferMetamask?: boolean;
|
|
16
|
+
isFavorite?: boolean;
|
|
17
|
+
info?: BasicDappInfo;
|
|
18
|
+
}
|
|
19
|
+
export interface TransactionHistoryItem {
|
|
20
|
+
rawTx: Tx;
|
|
21
|
+
createdAt: number;
|
|
22
|
+
isCompleted: boolean;
|
|
23
|
+
hash?: string;
|
|
24
|
+
failed: boolean;
|
|
25
|
+
gasUsed?: number;
|
|
26
|
+
isSubmitFailed?: boolean;
|
|
27
|
+
site?: ConnectedSite;
|
|
28
|
+
pushType?: TxPushType;
|
|
29
|
+
reqId?: string;
|
|
30
|
+
isWithdrawed?: boolean;
|
|
31
|
+
explain?: TransactionGroup['explain'];
|
|
32
|
+
action?: TransactionGroup['action'];
|
|
33
|
+
}
|
|
34
|
+
export interface TransactionSigningItem {
|
|
35
|
+
rawTx: Tx;
|
|
36
|
+
explain?: ExplainTxResponse & {
|
|
37
|
+
approvalId: string;
|
|
38
|
+
calcSuccess: boolean;
|
|
39
|
+
};
|
|
40
|
+
action?: {
|
|
41
|
+
actionData: ParsedActionData;
|
|
42
|
+
requiredData: ActionRequireData;
|
|
43
|
+
};
|
|
44
|
+
id: string;
|
|
45
|
+
isSubmitted?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface TransactionGroup {
|
|
48
|
+
chainId: number;
|
|
49
|
+
nonce: number;
|
|
50
|
+
txs: TransactionHistoryItem[];
|
|
51
|
+
isPending: boolean;
|
|
52
|
+
createdAt: number;
|
|
53
|
+
explain?: ExplainTxResponse & {
|
|
54
|
+
approvalId: string;
|
|
55
|
+
calcSuccess: boolean;
|
|
56
|
+
};
|
|
57
|
+
action?: {
|
|
58
|
+
actionData: ParsedActionData;
|
|
59
|
+
requiredData: ActionRequireData;
|
|
60
|
+
};
|
|
61
|
+
isFailed: boolean;
|
|
62
|
+
isSubmitFailed?: boolean;
|
|
63
|
+
$ctx?: any;
|
|
64
|
+
}
|
|
65
|
+
export type WalletProvider = {
|
|
66
|
+
hasAddress: (address: string) => Promise<boolean>;
|
|
67
|
+
hasPrivateKeyInWallet: (address: string) => Promise<string>;
|
|
68
|
+
getWhitelist: () => Promise<string[]>;
|
|
69
|
+
isWhitelistEnabled: () => Promise<boolean>;
|
|
70
|
+
getPendingTxsByNonce: (address: string, chainId: number, nonce: number) => Promise<any[]>;
|
|
71
|
+
findChain: (params: {
|
|
72
|
+
enum?: CHAINS_ENUM | string | null;
|
|
73
|
+
id?: number | null;
|
|
74
|
+
serverId?: string | null;
|
|
75
|
+
hex?: string | null;
|
|
76
|
+
networkId?: string | null;
|
|
77
|
+
}) => Chain | null | undefined;
|
|
78
|
+
ALIAS_ADDRESS: Record<string, string>;
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calcSlippageTolerance: (base: string, actual: string) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
export const calcSlippageTolerance = (base, actual) => {
|
|
3
|
+
const baseBn = new BigNumber(base);
|
|
4
|
+
const actualBn = new BigNumber(actual);
|
|
5
|
+
if (baseBn.eq(0) && actualBn.eq(0))
|
|
6
|
+
return 0;
|
|
7
|
+
if (baseBn.eq(0))
|
|
8
|
+
return 1;
|
|
9
|
+
if (actualBn.eq(0))
|
|
10
|
+
return -1;
|
|
11
|
+
return baseBn.minus(actualBn).div(baseBn).toNumber();
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calcUSDValueChange: (pay: string, receive: string) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
export const calcUSDValueChange = (pay, receive) => {
|
|
3
|
+
const payBn = new BigNumber(pay);
|
|
4
|
+
const receiveBn = new BigNumber(receive);
|
|
5
|
+
if (payBn.eq(0) && receiveBn.eq(0))
|
|
6
|
+
return 0;
|
|
7
|
+
if (payBn.eq(0))
|
|
8
|
+
return 1;
|
|
9
|
+
if (receiveBn.eq(0))
|
|
10
|
+
return -1;
|
|
11
|
+
return receiveBn.minus(payBn).div(payBn).toNumber();
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const KEYRING_TYPE: {
|
|
2
|
+
readonly HdKeyring: "HD Key Tree";
|
|
3
|
+
readonly SimpleKeyring: "Simple Key Pair";
|
|
4
|
+
readonly HardwareKeyring: "hardware";
|
|
5
|
+
readonly WatchAddressKeyring: "Watch Address";
|
|
6
|
+
readonly WalletConnectKeyring: "WalletConnect";
|
|
7
|
+
readonly GnosisKeyring: "Gnosis";
|
|
8
|
+
readonly CoboArgusKeyring: "CoboArgus";
|
|
9
|
+
readonly CoinbaseKeyring: "Coinbase";
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const KEYRING_TYPE = {
|
|
2
|
+
HdKeyring: 'HD Key Tree',
|
|
3
|
+
SimpleKeyring: 'Simple Key Pair',
|
|
4
|
+
HardwareKeyring: 'hardware',
|
|
5
|
+
WatchAddressKeyring: 'Watch Address',
|
|
6
|
+
WalletConnectKeyring: 'WalletConnect',
|
|
7
|
+
GnosisKeyring: 'Gnosis',
|
|
8
|
+
CoboArgusKeyring: 'CoboArgus',
|
|
9
|
+
CoinbaseKeyring: 'Coinbase',
|
|
10
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const parseTypedDataAction = (fn) => {
|
|
2
|
+
return (options) => {
|
|
3
|
+
var _a;
|
|
4
|
+
const { data, typedData, sender } = options;
|
|
5
|
+
const result = {
|
|
6
|
+
sender,
|
|
7
|
+
actionType: null,
|
|
8
|
+
brand: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.brand,
|
|
9
|
+
};
|
|
10
|
+
if (typedData === null || typedData === void 0 ? void 0 : typedData.domain) {
|
|
11
|
+
if (typedData.domain.verifyingContract) {
|
|
12
|
+
result.contractId = typedData.domain.verifyingContract;
|
|
13
|
+
}
|
|
14
|
+
if (typedData.domain.chainId) {
|
|
15
|
+
result.chainId = typedData.domain.chainId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
result.actionType = (data === null || data === void 0 ? void 0 : data.type) || null;
|
|
19
|
+
const action = fn(options);
|
|
20
|
+
if ('contractCall' in action && action.contractCall && result.actionType) {
|
|
21
|
+
result.actionType = 'contractCall';
|
|
22
|
+
}
|
|
23
|
+
return Object.assign(Object.assign({}, result), action);
|
|
24
|
+
};
|
|
25
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rabby-wallet/rabby-action",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"p-queue": "^8.0.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@babel/preset-env": "^7.19.1",
|
|
17
|
+
"@debank/common": "^0.3.60",
|
|
18
|
+
"@rabby-wallet/rabby-api": "^0.7.26",
|
|
19
|
+
"@rabby-wallet/rabby-security-engine": "^2.0.5",
|
|
20
|
+
"@types/jest": "^29.0.3",
|
|
21
|
+
"@types/lodash": "^4.14.185",
|
|
22
|
+
"@types/node": "^18.7.18",
|
|
23
|
+
"babel-jest": "^29.0.3",
|
|
24
|
+
"bignumber.js": "^9.1.2",
|
|
25
|
+
"husky": ">=6",
|
|
26
|
+
"jest": "^29.7.0",
|
|
27
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
28
|
+
"jest-mock-axios": "^4.7.0-beta",
|
|
29
|
+
"lint-staged": ">=10",
|
|
30
|
+
"prettier": "^2.7.1",
|
|
31
|
+
"rimraf": "^3.0.2",
|
|
32
|
+
"ts-jest": "^29.2.4",
|
|
33
|
+
"ts-node": "^10.9.1",
|
|
34
|
+
"typescript": "^5.5.4"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "jest",
|
|
38
|
+
"build": "rimraf dist && tsc",
|
|
39
|
+
"preversion": "npm run build",
|
|
40
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
41
|
+
"prepare": "husky install"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@debank/common": "^0.3.60",
|
|
45
|
+
"@rabby-wallet/rabby-api": "^0.7.26",
|
|
46
|
+
"@rabby-wallet/rabby-security-engine": "^2.0.5",
|
|
47
|
+
"bignumber.js": "*"
|
|
48
|
+
},
|
|
49
|
+
"author": "rabby",
|
|
50
|
+
"description": "",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"lint-staged": {
|
|
53
|
+
"*.{ts,css,md}": "prettier --write"
|
|
54
|
+
},
|
|
55
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
56
|
+
}
|