@pioneer-platform/walletguard 0.2.0 → 0.3.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/.turbo/turbo-build.log +2 -0
- package/CHANGELOG.md +14 -0
- package/build.sh +22 -0
- package/lib/PhishingResponse.d.ts +13 -0
- package/lib/PhishingResponse.js +9 -0
- package/lib/Transaction.d.ts +243 -0
- package/lib/Transaction.js +123 -0
- package/lib/environment.d.ts +4 -0
- package/lib/environment.js +10 -0
- package/lib/index.d.ts +36 -0
- package/lib/index.js +120 -0
- package/lib/index.js.map +74 -0
- package/lib/server.d.ts +5 -0
- package/lib/server.js +191 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pioneer-platform/walletguard
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Automated minor version bump for all packages
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/maya-network@8.6.0
|
|
13
|
+
- @pioneer-platform/loggerdog@8.6.0
|
|
14
|
+
- @pioneer-platform/pioneer-coins@9.6.0
|
|
15
|
+
- @pioneer-platform/pioneer-caip@9.5.0
|
|
16
|
+
|
|
3
17
|
## 0.2.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/build.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Fast Bun build (replaces slow tsc)
|
|
3
|
+
|
|
4
|
+
OUTDIR="${1:-lib}"
|
|
5
|
+
ENTRY="${2:-src/index.ts}"
|
|
6
|
+
|
|
7
|
+
# Clean output
|
|
8
|
+
rm -rf "$OUTDIR"
|
|
9
|
+
mkdir -p "$OUTDIR"
|
|
10
|
+
|
|
11
|
+
# Build with Bun (10x faster than tsc)
|
|
12
|
+
bun build "$ENTRY" \
|
|
13
|
+
--outdir "$OUTDIR" \
|
|
14
|
+
--target node \
|
|
15
|
+
--format cjs \
|
|
16
|
+
--sourcemap \
|
|
17
|
+
--minify
|
|
18
|
+
|
|
19
|
+
# Generate TypeScript declarations
|
|
20
|
+
bunx tsc --emitDeclarationOnly --outDir "$OUTDIR" --project .
|
|
21
|
+
|
|
22
|
+
echo "✅ Built $OUTDIR"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RiskFactor } from './Transaction';
|
|
2
|
+
export interface PhishingResponse {
|
|
3
|
+
domainName: string;
|
|
4
|
+
verified: boolean;
|
|
5
|
+
recommendedAction: RecommendedAction;
|
|
6
|
+
riskFactors: RiskFactor[] | null;
|
|
7
|
+
status: 'IN_PROGRESS' | 'COMPLETE';
|
|
8
|
+
}
|
|
9
|
+
export declare enum RecommendedAction {
|
|
10
|
+
Block = "BLOCK",
|
|
11
|
+
Warn = "WARN",
|
|
12
|
+
None = "NONE"
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecommendedAction = void 0;
|
|
4
|
+
var RecommendedAction;
|
|
5
|
+
(function (RecommendedAction) {
|
|
6
|
+
RecommendedAction["Block"] = "BLOCK";
|
|
7
|
+
RecommendedAction["Warn"] = "WARN";
|
|
8
|
+
RecommendedAction["None"] = "NONE";
|
|
9
|
+
})(RecommendedAction || (exports.RecommendedAction = RecommendedAction = {}));
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { PhishingResponse } from './PhishingResponse';
|
|
2
|
+
export interface Transaction {
|
|
3
|
+
from: string;
|
|
4
|
+
to: string;
|
|
5
|
+
data?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare enum TransactionType {
|
|
9
|
+
Transaction = "Transaction",
|
|
10
|
+
Signature = "Signature"
|
|
11
|
+
}
|
|
12
|
+
export declare enum ResponseType {
|
|
13
|
+
Success = "success",
|
|
14
|
+
Revert = "revert",
|
|
15
|
+
Error = "error"
|
|
16
|
+
}
|
|
17
|
+
export declare enum TokenType {
|
|
18
|
+
ERC721 = "ERC721",
|
|
19
|
+
ERC1155 = "ERC1155",
|
|
20
|
+
ERC20 = "ERC20"
|
|
21
|
+
}
|
|
22
|
+
export declare enum SimulationMethodType {
|
|
23
|
+
EthSignTypedDataV3 = "eth_signTypedData_v3",
|
|
24
|
+
EthSignTypedDataV4 = "eth_signTypedData_v4",
|
|
25
|
+
EthSendTransaction = "eth_sendTransaction",
|
|
26
|
+
EthSign = "eth_sign",
|
|
27
|
+
PersonalSign = "personal_sign"
|
|
28
|
+
}
|
|
29
|
+
export type TransactionArgs = SimulateRequestArgs | SignatureRequestArgs | SignatureHashSignArgs | PersonalSignArgs | UnstandardizedSignatureRequestArgs;
|
|
30
|
+
export interface SimulateRequestArgs extends RequestArgs {
|
|
31
|
+
transaction: Transaction;
|
|
32
|
+
}
|
|
33
|
+
export interface UnstandardizedSignatureRequestArgs extends RequestArgs {
|
|
34
|
+
params: any;
|
|
35
|
+
}
|
|
36
|
+
export interface SignatureRequestArgs extends RequestArgs {
|
|
37
|
+
domain: any;
|
|
38
|
+
message: any;
|
|
39
|
+
primaryType: string;
|
|
40
|
+
}
|
|
41
|
+
export interface SignatureHashSignArgs extends RequestArgs {
|
|
42
|
+
hash: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PersonalSignArgs extends RequestArgs {
|
|
45
|
+
signMessage: string;
|
|
46
|
+
}
|
|
47
|
+
interface RequestArgs {
|
|
48
|
+
id: string;
|
|
49
|
+
chainId: string;
|
|
50
|
+
signer: string;
|
|
51
|
+
origin: string;
|
|
52
|
+
method: SimulationMethodType | string;
|
|
53
|
+
bypassed?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export type SimulationResponse = SimulationSuccessResponse | SimulationErrorResponse;
|
|
56
|
+
export type SoftLockedAssetsResponse = {
|
|
57
|
+
ownerAddress: string;
|
|
58
|
+
lastUpdatedAt: string;
|
|
59
|
+
lockedAssets: AssetKey[] | null;
|
|
60
|
+
};
|
|
61
|
+
export type AssetKey = {
|
|
62
|
+
ownerAddress: string;
|
|
63
|
+
ercType: string;
|
|
64
|
+
contractAddress: string;
|
|
65
|
+
tokenId: string;
|
|
66
|
+
};
|
|
67
|
+
export type SimulationErrorResponse = {
|
|
68
|
+
error: SimulationError;
|
|
69
|
+
scanResult?: PhishingResponse;
|
|
70
|
+
};
|
|
71
|
+
export type SimulationSuccessResponse = {
|
|
72
|
+
recommendedAction: RecommendedActionType;
|
|
73
|
+
overviewMessage: string;
|
|
74
|
+
stateChanges: StateChange[] | null;
|
|
75
|
+
addressDetails: SimulationAddressDetails;
|
|
76
|
+
decodedMessage?: string;
|
|
77
|
+
scanResult: PhishingResponse;
|
|
78
|
+
riskFactors: RiskFactor[] | null;
|
|
79
|
+
gas?: SimulatedGas;
|
|
80
|
+
error: null;
|
|
81
|
+
extraInfo: ExtraInfoData | null;
|
|
82
|
+
};
|
|
83
|
+
export type SimulationApiResponse = {
|
|
84
|
+
recommendedAction: RecommendedActionType;
|
|
85
|
+
overviewMessage: string;
|
|
86
|
+
stateChanges: StateChange[] | null;
|
|
87
|
+
addressDetails: SimulationAddressDetails;
|
|
88
|
+
decodedMessage?: string;
|
|
89
|
+
scanResult: PhishingResponse;
|
|
90
|
+
riskFactors: RiskFactor[] | null;
|
|
91
|
+
gas?: SimulatedGas;
|
|
92
|
+
error: SimulationError | null;
|
|
93
|
+
extraInfo: ExtraInfoData | null;
|
|
94
|
+
};
|
|
95
|
+
export declare enum ExtraInfoType {
|
|
96
|
+
UnresolvableSignature = "UNRESOLVABLE_SIGNATURE"
|
|
97
|
+
}
|
|
98
|
+
export type ExtraInfoData = {
|
|
99
|
+
type: ExtraInfoType;
|
|
100
|
+
message: string;
|
|
101
|
+
};
|
|
102
|
+
export type SimulatedGas = {
|
|
103
|
+
gasUsedEth: string;
|
|
104
|
+
fiatValue: string;
|
|
105
|
+
currency: Currency;
|
|
106
|
+
};
|
|
107
|
+
export declare enum Currency {
|
|
108
|
+
USD = "USD"
|
|
109
|
+
}
|
|
110
|
+
export declare enum RecommendedActionType {
|
|
111
|
+
None = "NONE",
|
|
112
|
+
Warn = "WARN",
|
|
113
|
+
Block = "BLOCK"
|
|
114
|
+
}
|
|
115
|
+
export type RiskFactor = {
|
|
116
|
+
severity: Severity;
|
|
117
|
+
type: WarningType;
|
|
118
|
+
message: string;
|
|
119
|
+
value?: string;
|
|
120
|
+
};
|
|
121
|
+
export declare enum WarningType {
|
|
122
|
+
Bypass = "BYPASS",
|
|
123
|
+
Similarity = "SIMILARITY",
|
|
124
|
+
RecentlyCreated = "RECENTLY_CREATED",
|
|
125
|
+
Malware = "MALWARE",
|
|
126
|
+
Homoglyph = "HOMOGLYPH",
|
|
127
|
+
Blocklisted = "BLOCKLISTED",
|
|
128
|
+
MLInference = "ML_INFERENCE",
|
|
129
|
+
Drainer = "DRAINER",
|
|
130
|
+
BlurListing = "BLUR_LISTING",
|
|
131
|
+
OpenseaListing = "OPENSEA_LISTING",
|
|
132
|
+
EthSign = "ETH_SIGN",
|
|
133
|
+
LooksrareListing = "LOOKSRARE_LISTING",
|
|
134
|
+
DrainerRequest = "DRAINER_REQUEST"
|
|
135
|
+
}
|
|
136
|
+
export declare enum Severity {
|
|
137
|
+
Low = "LOW",
|
|
138
|
+
High = "HIGH",
|
|
139
|
+
Critical = "CRITICAL"
|
|
140
|
+
}
|
|
141
|
+
export type SimulationError = {
|
|
142
|
+
type: ErrorType;
|
|
143
|
+
message: string;
|
|
144
|
+
extraData: object | null;
|
|
145
|
+
};
|
|
146
|
+
export declare enum ErrorType {
|
|
147
|
+
Unauthorized = "UNAUTHORIZED",
|
|
148
|
+
InsufficientFunds = "INSUFFICIENT_FUNDS",
|
|
149
|
+
MaxFeePerGasLessThanBlockBaseFee = "MAX_FEE_PER_GAS_LESS_THAN_BLOCK_BASE_FEE",
|
|
150
|
+
UnsupportedSignature = "UNSUPPORTED_SIGNATURE",
|
|
151
|
+
Revert = "REVERT",
|
|
152
|
+
TooManyRequests = "TOO_MANY_REQUESTS",
|
|
153
|
+
GeneralError = "ERROR",
|
|
154
|
+
UnknownError = "UNKNOWN_ERROR"
|
|
155
|
+
}
|
|
156
|
+
export declare enum SimulationWarningType {
|
|
157
|
+
None = "NONE",
|
|
158
|
+
Info = "INFO",
|
|
159
|
+
Warn = "WARN"
|
|
160
|
+
}
|
|
161
|
+
export declare enum SimulationChangeType {
|
|
162
|
+
OpenSeaListing = "OPENSEA_LISTING",
|
|
163
|
+
OpenSeaReceive = "OPENSEA_RECEIVE",
|
|
164
|
+
LooksRareAskReceive = "LOOKSRARE_ASK_RECEIVE",
|
|
165
|
+
LooksRareAskListing = "LOOKSRARE_ASK_LISTING",
|
|
166
|
+
LooksRareBidReceive = "LOOKSRARE_BID_RECEIVE",
|
|
167
|
+
LooksRareBidOffer = "LOOKSRARE_BID_OFFER",
|
|
168
|
+
ReceiveApproval = "RECEIVE_APPROVAL",
|
|
169
|
+
ReceiveApprovalForAll = "RECEIVE_APPROVAL_FOR_ALL",
|
|
170
|
+
ListingReceive = "LISTING_RECEIVE",
|
|
171
|
+
ListingTransfer = "LISTING_TRANSFER",
|
|
172
|
+
PermitTransfer = "PERMIT_TRANSFER",
|
|
173
|
+
PermitReceive = "PERMIT_RECEIVE",
|
|
174
|
+
ApprovalForAll = "APPROVAL_FOR_ALL",
|
|
175
|
+
Approve = "APPROVE",
|
|
176
|
+
RevokeApprovalForAll = "REVOKE_APPROVAL_FOR_ALL",
|
|
177
|
+
Revoke = "REVOKE_APPROVE",
|
|
178
|
+
Transfer = "TRANSFER",
|
|
179
|
+
Receive = "RECEIVE",
|
|
180
|
+
Bidding = "BIDDING",
|
|
181
|
+
Listing = "LISTING"
|
|
182
|
+
}
|
|
183
|
+
export declare enum SimulationAssetTypes {
|
|
184
|
+
ERC20 = "ERC20",
|
|
185
|
+
ERC721 = "ERC721",
|
|
186
|
+
ERC1155 = "ERC1155",
|
|
187
|
+
Native = "NATIVE"
|
|
188
|
+
}
|
|
189
|
+
export declare enum AddressType {
|
|
190
|
+
EOA = "EOA",
|
|
191
|
+
Contract = "CONTRACT"
|
|
192
|
+
}
|
|
193
|
+
export type SimulationAddressDetails = {
|
|
194
|
+
address: string;
|
|
195
|
+
addressType: AddressType;
|
|
196
|
+
etherscanVerified: boolean;
|
|
197
|
+
etherscanLink: string;
|
|
198
|
+
addressName: string;
|
|
199
|
+
};
|
|
200
|
+
export type TokenData = {
|
|
201
|
+
verified?: Verified;
|
|
202
|
+
address: string;
|
|
203
|
+
name?: string;
|
|
204
|
+
symbol?: string;
|
|
205
|
+
tokenID?: string;
|
|
206
|
+
tokenURI?: string;
|
|
207
|
+
decimals?: number;
|
|
208
|
+
logo?: string;
|
|
209
|
+
EIP: string;
|
|
210
|
+
};
|
|
211
|
+
export type ApprovalStateChange = {
|
|
212
|
+
approval: boolean;
|
|
213
|
+
allTokens: boolean;
|
|
214
|
+
tokenID: string;
|
|
215
|
+
amount: number;
|
|
216
|
+
address: string;
|
|
217
|
+
};
|
|
218
|
+
export type Verified = {
|
|
219
|
+
etherscan?: boolean;
|
|
220
|
+
sourcify?: boolean;
|
|
221
|
+
};
|
|
222
|
+
export type StateChange = {
|
|
223
|
+
assetType: SimulationAssetTypes;
|
|
224
|
+
changeType: SimulationChangeType;
|
|
225
|
+
address: string;
|
|
226
|
+
amount: string;
|
|
227
|
+
symbol: string;
|
|
228
|
+
decimals: number;
|
|
229
|
+
contractAddress: string;
|
|
230
|
+
name: string;
|
|
231
|
+
logo: string;
|
|
232
|
+
tokenID: string;
|
|
233
|
+
tokenURI: string;
|
|
234
|
+
tokenName: string;
|
|
235
|
+
openSeaFloorPrice: number;
|
|
236
|
+
openSeaVerified: boolean;
|
|
237
|
+
etherscanVerified: boolean;
|
|
238
|
+
fiatValue: string;
|
|
239
|
+
coinmarketcapLink: string;
|
|
240
|
+
openSeaLink: string;
|
|
241
|
+
locked: boolean;
|
|
242
|
+
};
|
|
243
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddressType = exports.SimulationAssetTypes = exports.SimulationChangeType = exports.SimulationWarningType = exports.ErrorType = exports.Severity = exports.WarningType = exports.RecommendedActionType = exports.Currency = exports.ExtraInfoType = exports.SimulationMethodType = exports.TokenType = exports.ResponseType = exports.TransactionType = void 0;
|
|
4
|
+
var TransactionType;
|
|
5
|
+
(function (TransactionType) {
|
|
6
|
+
TransactionType["Transaction"] = "Transaction";
|
|
7
|
+
TransactionType["Signature"] = "Signature";
|
|
8
|
+
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
9
|
+
var ResponseType;
|
|
10
|
+
(function (ResponseType) {
|
|
11
|
+
ResponseType["Success"] = "success";
|
|
12
|
+
ResponseType["Revert"] = "revert";
|
|
13
|
+
ResponseType["Error"] = "error";
|
|
14
|
+
})(ResponseType || (exports.ResponseType = ResponseType = {}));
|
|
15
|
+
var TokenType;
|
|
16
|
+
(function (TokenType) {
|
|
17
|
+
TokenType["ERC721"] = "ERC721";
|
|
18
|
+
TokenType["ERC1155"] = "ERC1155";
|
|
19
|
+
TokenType["ERC20"] = "ERC20";
|
|
20
|
+
})(TokenType || (exports.TokenType = TokenType = {}));
|
|
21
|
+
var SimulationMethodType;
|
|
22
|
+
(function (SimulationMethodType) {
|
|
23
|
+
SimulationMethodType["EthSignTypedDataV3"] = "eth_signTypedData_v3";
|
|
24
|
+
SimulationMethodType["EthSignTypedDataV4"] = "eth_signTypedData_v4";
|
|
25
|
+
SimulationMethodType["EthSendTransaction"] = "eth_sendTransaction";
|
|
26
|
+
SimulationMethodType["EthSign"] = "eth_sign";
|
|
27
|
+
SimulationMethodType["PersonalSign"] = "personal_sign";
|
|
28
|
+
})(SimulationMethodType || (exports.SimulationMethodType = SimulationMethodType = {}));
|
|
29
|
+
;
|
|
30
|
+
;
|
|
31
|
+
;
|
|
32
|
+
;
|
|
33
|
+
var ExtraInfoType;
|
|
34
|
+
(function (ExtraInfoType) {
|
|
35
|
+
ExtraInfoType["UnresolvableSignature"] = "UNRESOLVABLE_SIGNATURE";
|
|
36
|
+
})(ExtraInfoType || (exports.ExtraInfoType = ExtraInfoType = {}));
|
|
37
|
+
var Currency;
|
|
38
|
+
(function (Currency) {
|
|
39
|
+
// add support for more currencies here in the future
|
|
40
|
+
Currency["USD"] = "USD";
|
|
41
|
+
})(Currency || (exports.Currency = Currency = {}));
|
|
42
|
+
var RecommendedActionType;
|
|
43
|
+
(function (RecommendedActionType) {
|
|
44
|
+
RecommendedActionType["None"] = "NONE";
|
|
45
|
+
RecommendedActionType["Warn"] = "WARN";
|
|
46
|
+
RecommendedActionType["Block"] = "BLOCK";
|
|
47
|
+
})(RecommendedActionType || (exports.RecommendedActionType = RecommendedActionType = {}));
|
|
48
|
+
var WarningType;
|
|
49
|
+
(function (WarningType) {
|
|
50
|
+
WarningType["Bypass"] = "BYPASS";
|
|
51
|
+
WarningType["Similarity"] = "SIMILARITY";
|
|
52
|
+
WarningType["RecentlyCreated"] = "RECENTLY_CREATED";
|
|
53
|
+
WarningType["Malware"] = "MALWARE";
|
|
54
|
+
WarningType["Homoglyph"] = "HOMOGLYPH";
|
|
55
|
+
WarningType["Blocklisted"] = "BLOCKLISTED";
|
|
56
|
+
WarningType["MLInference"] = "ML_INFERENCE";
|
|
57
|
+
WarningType["Drainer"] = "DRAINER";
|
|
58
|
+
WarningType["BlurListing"] = "BLUR_LISTING";
|
|
59
|
+
WarningType["OpenseaListing"] = "OPENSEA_LISTING";
|
|
60
|
+
WarningType["EthSign"] = "ETH_SIGN";
|
|
61
|
+
WarningType["LooksrareListing"] = "LOOKSRARE_LISTING";
|
|
62
|
+
WarningType["DrainerRequest"] = "DRAINER_REQUEST";
|
|
63
|
+
})(WarningType || (exports.WarningType = WarningType = {}));
|
|
64
|
+
var Severity;
|
|
65
|
+
(function (Severity) {
|
|
66
|
+
Severity["Low"] = "LOW";
|
|
67
|
+
Severity["High"] = "HIGH";
|
|
68
|
+
Severity["Critical"] = "CRITICAL";
|
|
69
|
+
})(Severity || (exports.Severity = Severity = {}));
|
|
70
|
+
var ErrorType;
|
|
71
|
+
(function (ErrorType) {
|
|
72
|
+
ErrorType["Unauthorized"] = "UNAUTHORIZED";
|
|
73
|
+
ErrorType["InsufficientFunds"] = "INSUFFICIENT_FUNDS";
|
|
74
|
+
ErrorType["MaxFeePerGasLessThanBlockBaseFee"] = "MAX_FEE_PER_GAS_LESS_THAN_BLOCK_BASE_FEE";
|
|
75
|
+
ErrorType["UnsupportedSignature"] = "UNSUPPORTED_SIGNATURE";
|
|
76
|
+
ErrorType["Revert"] = "REVERT";
|
|
77
|
+
ErrorType["TooManyRequests"] = "TOO_MANY_REQUESTS";
|
|
78
|
+
ErrorType["GeneralError"] = "ERROR";
|
|
79
|
+
ErrorType["UnknownError"] = "UNKNOWN_ERROR";
|
|
80
|
+
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
|
81
|
+
var SimulationWarningType;
|
|
82
|
+
(function (SimulationWarningType) {
|
|
83
|
+
SimulationWarningType["None"] = "NONE";
|
|
84
|
+
SimulationWarningType["Info"] = "INFO";
|
|
85
|
+
SimulationWarningType["Warn"] = "WARN";
|
|
86
|
+
})(SimulationWarningType || (exports.SimulationWarningType = SimulationWarningType = {}));
|
|
87
|
+
var SimulationChangeType;
|
|
88
|
+
(function (SimulationChangeType) {
|
|
89
|
+
// v0 (+ everything from v1 except bid, listing, and revoke)
|
|
90
|
+
SimulationChangeType["OpenSeaListing"] = "OPENSEA_LISTING";
|
|
91
|
+
SimulationChangeType["OpenSeaReceive"] = "OPENSEA_RECEIVE";
|
|
92
|
+
SimulationChangeType["LooksRareAskReceive"] = "LOOKSRARE_ASK_RECEIVE";
|
|
93
|
+
SimulationChangeType["LooksRareAskListing"] = "LOOKSRARE_ASK_LISTING";
|
|
94
|
+
SimulationChangeType["LooksRareBidReceive"] = "LOOKSRARE_BID_RECEIVE";
|
|
95
|
+
SimulationChangeType["LooksRareBidOffer"] = "LOOKSRARE_BID_OFFER";
|
|
96
|
+
SimulationChangeType["ReceiveApproval"] = "RECEIVE_APPROVAL";
|
|
97
|
+
SimulationChangeType["ReceiveApprovalForAll"] = "RECEIVE_APPROVAL_FOR_ALL";
|
|
98
|
+
SimulationChangeType["ListingReceive"] = "LISTING_RECEIVE";
|
|
99
|
+
SimulationChangeType["ListingTransfer"] = "LISTING_TRANSFER";
|
|
100
|
+
SimulationChangeType["PermitTransfer"] = "PERMIT_TRANSFER";
|
|
101
|
+
SimulationChangeType["PermitReceive"] = "PERMIT_RECEIVE";
|
|
102
|
+
// v1
|
|
103
|
+
SimulationChangeType["ApprovalForAll"] = "APPROVAL_FOR_ALL";
|
|
104
|
+
SimulationChangeType["Approve"] = "APPROVE";
|
|
105
|
+
SimulationChangeType["RevokeApprovalForAll"] = "REVOKE_APPROVAL_FOR_ALL";
|
|
106
|
+
SimulationChangeType["Revoke"] = "REVOKE_APPROVE";
|
|
107
|
+
SimulationChangeType["Transfer"] = "TRANSFER";
|
|
108
|
+
SimulationChangeType["Receive"] = "RECEIVE";
|
|
109
|
+
SimulationChangeType["Bidding"] = "BIDDING";
|
|
110
|
+
SimulationChangeType["Listing"] = "LISTING";
|
|
111
|
+
})(SimulationChangeType || (exports.SimulationChangeType = SimulationChangeType = {}));
|
|
112
|
+
var SimulationAssetTypes;
|
|
113
|
+
(function (SimulationAssetTypes) {
|
|
114
|
+
SimulationAssetTypes["ERC20"] = "ERC20";
|
|
115
|
+
SimulationAssetTypes["ERC721"] = "ERC721";
|
|
116
|
+
SimulationAssetTypes["ERC1155"] = "ERC1155";
|
|
117
|
+
SimulationAssetTypes["Native"] = "NATIVE";
|
|
118
|
+
})(SimulationAssetTypes || (exports.SimulationAssetTypes = SimulationAssetTypes = {}));
|
|
119
|
+
var AddressType;
|
|
120
|
+
(function (AddressType) {
|
|
121
|
+
AddressType["EOA"] = "EOA";
|
|
122
|
+
AddressType["Contract"] = "CONTRACT";
|
|
123
|
+
})(AddressType || (exports.AddressType = AddressType = {}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const SERVER_URL_PROD = "https://api.walletguard.app/extension/v0";
|
|
2
|
+
export declare const SERVER_URL_PROD_V1 = "https://api.walletguard.app/extension/v1";
|
|
3
|
+
export declare const CHATWEB3_SERVER_URL_PROD = "https://api.chatweb3.walletguard.app";
|
|
4
|
+
export declare const CDN_URL_PROD = "https://cdn.walletguard.app";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CDN_URL_PROD = exports.CHATWEB3_SERVER_URL_PROD = exports.SERVER_URL_PROD_V1 = exports.SERVER_URL_PROD = void 0;
|
|
4
|
+
// Security API - For business inquiries please visit https://docs.walletguard.app
|
|
5
|
+
exports.SERVER_URL_PROD = 'https://api.walletguard.app/extension/v0';
|
|
6
|
+
exports.SERVER_URL_PROD_V1 = 'https://api.walletguard.app/extension/v1';
|
|
7
|
+
// CHATWEB3
|
|
8
|
+
exports.CHATWEB3_SERVER_URL_PROD = 'https://api.chatweb3.walletguard.app';
|
|
9
|
+
// CDN
|
|
10
|
+
exports.CDN_URL_PROD = 'https://cdn.walletguard.app';
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
declare const TAG = " | WalletGuard | ";
|
|
2
|
+
type BaseDecimal = string | number;
|
|
3
|
+
declare const axios: any;
|
|
4
|
+
declare const log: any;
|
|
5
|
+
declare enum TransactionType {
|
|
6
|
+
Transaction = "transaction",
|
|
7
|
+
Message = "message"
|
|
8
|
+
}
|
|
9
|
+
declare enum SimulationMethodType {
|
|
10
|
+
EthSendTransaction = "eth_sendTransaction",
|
|
11
|
+
EthSignTransaction = "eth_signTransaction"
|
|
12
|
+
}
|
|
13
|
+
declare const fetchTransaction: (transactionArgs: any, type: TransactionType) => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
risk: {
|
|
16
|
+
score: number;
|
|
17
|
+
level: string;
|
|
18
|
+
alerts: never[];
|
|
19
|
+
};
|
|
20
|
+
simulation: {
|
|
21
|
+
status: string;
|
|
22
|
+
gasUsed: string;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
declare const simulate_tx: (chainId: any, tx: any) => Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
risk: {
|
|
28
|
+
score: number;
|
|
29
|
+
level: string;
|
|
30
|
+
alerts: never[];
|
|
31
|
+
};
|
|
32
|
+
simulation: {
|
|
33
|
+
status: string;
|
|
34
|
+
gasUsed: string;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
WalletGuard Integration
|
|
4
|
+
- Highlander
|
|
5
|
+
|
|
6
|
+
BASE
|
|
7
|
+
https://docs.base.org/contracts/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var TAG = " | WalletGuard | ";
|
|
49
|
+
var axios = require('axios');
|
|
50
|
+
var log = require('@pioneer-platform/loggerdog')();
|
|
51
|
+
// Mock enums instead of importing
|
|
52
|
+
var TransactionType;
|
|
53
|
+
(function (TransactionType) {
|
|
54
|
+
TransactionType["Transaction"] = "transaction";
|
|
55
|
+
TransactionType["Message"] = "message";
|
|
56
|
+
})(TransactionType || (TransactionType = {}));
|
|
57
|
+
var SimulationMethodType;
|
|
58
|
+
(function (SimulationMethodType) {
|
|
59
|
+
SimulationMethodType["EthSendTransaction"] = "eth_sendTransaction";
|
|
60
|
+
SimulationMethodType["EthSignTransaction"] = "eth_signTransaction";
|
|
61
|
+
})(SimulationMethodType || (SimulationMethodType = {}));
|
|
62
|
+
// Mock the fetchTransaction function
|
|
63
|
+
var fetchTransaction = function (transactionArgs, type) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
// Return mock data
|
|
66
|
+
return [2 /*return*/, {
|
|
67
|
+
success: true,
|
|
68
|
+
risk: {
|
|
69
|
+
score: 0,
|
|
70
|
+
level: 'SAFE',
|
|
71
|
+
alerts: []
|
|
72
|
+
},
|
|
73
|
+
simulation: {
|
|
74
|
+
status: 'SUCCESS',
|
|
75
|
+
gasUsed: '100000'
|
|
76
|
+
}
|
|
77
|
+
}];
|
|
78
|
+
});
|
|
79
|
+
}); };
|
|
80
|
+
module.exports = {
|
|
81
|
+
init: function (settings) {
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
84
|
+
getSimulation: function (chainId, tx) {
|
|
85
|
+
return simulate_tx(chainId, tx);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var simulate_tx = function (chainId, tx) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var tag, output, transactionArgs, result, e_1;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
tag = TAG + " | simulate_tx | ";
|
|
95
|
+
_a.label = 1;
|
|
96
|
+
case 1:
|
|
97
|
+
_a.trys.push([1, 3, , 4]);
|
|
98
|
+
output = {};
|
|
99
|
+
log.info(tag, "tx: ", tx);
|
|
100
|
+
transactionArgs = {
|
|
101
|
+
id: "some-unique-id", // You should generate a unique id
|
|
102
|
+
chainId: chainId,
|
|
103
|
+
signer: tx.from,
|
|
104
|
+
origin: "your-dapp-origin.com", // Specify the domain origin of your dApp
|
|
105
|
+
method: SimulationMethodType.EthSendTransaction, // Using EthSendTransaction as the method type
|
|
106
|
+
transaction: tx, // the actual transaction data provided
|
|
107
|
+
};
|
|
108
|
+
return [4 /*yield*/, fetchTransaction(transactionArgs, TransactionType.Transaction)];
|
|
109
|
+
case 2:
|
|
110
|
+
result = _a.sent();
|
|
111
|
+
return [2 /*return*/, result];
|
|
112
|
+
case 3:
|
|
113
|
+
e_1 = _a.sent();
|
|
114
|
+
console.error(tag, "e: ", e_1);
|
|
115
|
+
throw e_1;
|
|
116
|
+
case 4: return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|