@pioneer-platform/walletguard 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @pioneer-platform/walletguard
2
2
 
3
+ ## 0.2.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.5.0
13
+ - @pioneer-platform/loggerdog@8.5.0
14
+ - @pioneer-platform/pioneer-coins@9.5.0
15
+ - @pioneer-platform/pioneer-caip@9.4.0
16
+
17
+ ## 0.1.1
18
+
19
+ ### Patch Changes
20
+
21
+ - Automated patch version bump for all packages
22
+ - Updated dependencies
23
+ - @pioneer-platform/maya-network@8.4.1
24
+ - @pioneer-platform/loggerdog@8.4.1
25
+ - @pioneer-platform/pioneer-coins@9.4.1
26
+ - @pioneer-platform/pioneer-caip@9.3.1
27
+
3
28
  ## 0.1.0
4
29
 
5
30
  ### Minor Changes
package/package.json CHANGED
@@ -1,17 +1,24 @@
1
1
  {
2
2
  "name": "@pioneer-platform/walletguard",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "dependencies": {
7
7
  "@keepkey/keepkey-sdk": "^0.2.57",
8
- "@pioneer-platform/loggerdog": "^8.4.0",
9
- "@pioneer-platform/maya-network": "^8.4.0",
10
- "@pioneer-platform/pioneer-caip": "^9.3.0",
11
- "@pioneer-platform/pioneer-coins": "^9.4.0",
8
+ "@pioneer-platform/loggerdog": "^8.5.0",
9
+ "@pioneer-platform/maya-network": "^8.5.0",
10
+ "@pioneer-platform/pioneer-caip": "^9.4.0",
11
+ "@pioneer-platform/pioneer-coins": "^9.5.0",
12
12
  "axios": "^1.6.0",
13
13
  "dotenv": "^8.2.0"
14
14
  },
15
+ "scripts": {
16
+ "npm": "pnpm i",
17
+ "test": "pnpm run build && node __tests__/test-module.js",
18
+ "build": "tsc -p .",
19
+ "prepublish": "pnpm run build",
20
+ "refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
21
+ },
15
22
  "devDependencies": {
16
23
  "@types/async-retry": "^1.4.8",
17
24
  "@types/bunyan": "^1.8.11",
@@ -25,12 +32,5 @@
25
32
  "ts-jest": "^29.0.5",
26
33
  "typescript": "^5.0.4"
27
34
  },
28
- "gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3",
29
- "scripts": {
30
- "npm": "pnpm i",
31
- "test": "pnpm run build && node __tests__/test-module.js",
32
- "build": "tsc -p .",
33
- "prepublish": "pnpm run build",
34
- "refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
35
- }
35
+ "gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3"
36
36
  }
@@ -1,13 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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 = {}));
@@ -1,243 +0,0 @@
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 {};
@@ -1,123 +0,0 @@
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 = {}));
@@ -1,4 +0,0 @@
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";
@@ -1,10 +0,0 @@
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 DELETED
@@ -1,36 +0,0 @@
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 DELETED
@@ -1,120 +0,0 @@
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
- };
package/lib/server.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { SimulationResponse, TransactionArgs, TransactionType, SoftLockedAssetsResponse } from './Transaction';
2
- export declare const fetchTransaction: (args: TransactionArgs, type: TransactionType) => Promise<SimulationResponse>;
3
- export declare const fetchLockedAssets: (address: string) => Promise<SoftLockedAssetsResponse | null>;
4
- export declare function getTransactionEndpoint(chainId: string): string;
5
- export declare function getSignatureEndpoint(chainId: string): string;
package/lib/server.js DELETED
@@ -1,191 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- 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);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.fetchLockedAssets = exports.fetchTransaction = void 0;
40
- exports.getTransactionEndpoint = getTransactionEndpoint;
41
- exports.getSignatureEndpoint = getSignatureEndpoint;
42
- var Transaction_1 = require("./Transaction");
43
- var environment_1 = require("./environment");
44
- var fetchTransaction = function (args, type) { return __awaiter(void 0, void 0, void 0, function () {
45
- var simulationURL, response, data, result_1, result_2, result, e_1, result;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0:
49
- _a.trys.push([0, 5, , 6]);
50
- simulationURL = type === Transaction_1.TransactionType.Transaction ?
51
- getTransactionEndpoint(args.chainId) : getSignatureEndpoint(args.chainId);
52
- return [4 /*yield*/, fetch(simulationURL, {
53
- method: 'POST',
54
- headers: {
55
- Accept: 'application/json',
56
- 'Content-Type': 'application/json',
57
- },
58
- body: JSON.stringify(args),
59
- })];
60
- case 1:
61
- response = _a.sent();
62
- console.log("response", response);
63
- if (!(response.status === 200)) return [3 /*break*/, 3];
64
- return [4 /*yield*/, response.json()];
65
- case 2:
66
- data = _a.sent();
67
- return [2 /*return*/, data];
68
- case 3:
69
- if (response.status === 403) {
70
- result_1 = {
71
- error: {
72
- type: Transaction_1.ErrorType.Unauthorized,
73
- message: 'Unauthorized',
74
- extraData: null,
75
- },
76
- };
77
- return [2 /*return*/, result_1];
78
- }
79
- else if (response.status === 429) {
80
- result_2 = {
81
- error: {
82
- type: Transaction_1.ErrorType.TooManyRequests,
83
- message: 'Rate limit hit',
84
- extraData: null,
85
- },
86
- };
87
- return [2 /*return*/, result_2];
88
- }
89
- _a.label = 4;
90
- case 4:
91
- result = {
92
- error: {
93
- type: Transaction_1.ErrorType.GeneralError,
94
- message: 'Unrecognized status code returned',
95
- extraData: null,
96
- },
97
- };
98
- return [2 /*return*/, result];
99
- case 5:
100
- e_1 = _a.sent();
101
- result = {
102
- error: {
103
- type: Transaction_1.ErrorType.UnknownError,
104
- message: 'an unknown error has occurred',
105
- extraData: null,
106
- },
107
- };
108
- return [2 /*return*/, result];
109
- case 6: return [2 /*return*/];
110
- }
111
- });
112
- }); };
113
- exports.fetchTransaction = fetchTransaction;
114
- var fetchLockedAssets = function (address) { return __awaiter(void 0, void 0, void 0, function () {
115
- var response, data, e_2;
116
- return __generator(this, function (_a) {
117
- switch (_a.label) {
118
- case 0:
119
- _a.trys.push([0, 4, , 5]);
120
- return [4 /*yield*/, fetch("".concat(environment_1.SERVER_URL_PROD, "/soft-lock/locked-assets?address=").concat(address), {
121
- method: 'GET',
122
- headers: {
123
- Accept: 'application/json',
124
- 'Content-Type': 'application/json',
125
- },
126
- })];
127
- case 1:
128
- response = _a.sent();
129
- if (!(response.status === 200)) return [3 /*break*/, 3];
130
- return [4 /*yield*/, response.json()];
131
- case 2:
132
- data = _a.sent();
133
- return [2 /*return*/, data];
134
- case 3: return [2 /*return*/, null];
135
- case 4:
136
- e_2 = _a.sent();
137
- console.error('error fetching soft locked assets', e_2);
138
- return [2 /*return*/, null];
139
- case 5: return [2 /*return*/];
140
- }
141
- });
142
- }); };
143
- exports.fetchLockedAssets = fetchLockedAssets;
144
- function getTransactionEndpoint(chainId) {
145
- switch (chainId.toLowerCase()) {
146
- case '0x1':
147
- case '1':
148
- return "".concat(environment_1.SERVER_URL_PROD, "/eth/mainnet/transaction");
149
- case '0xa4b1':
150
- case '42161':
151
- return "".concat(environment_1.SERVER_URL_PROD, "/arb/mainnet/transaction");
152
- case '0x89':
153
- case '137':
154
- return "".concat(environment_1.SERVER_URL_PROD, "/polygon/mainnet/transaction");
155
- case '0xa':
156
- case '10':
157
- return "".concat(environment_1.SERVER_URL_PROD, "/optimism/mainnet/transaction");
158
- case '8453':
159
- case '0x2105':
160
- return "".concat(environment_1.SERVER_URL_PROD, "/base/mainnet/transaction");
161
- case '56':
162
- case '0x38':
163
- return "".concat(environment_1.SERVER_URL_PROD, "/bsc/mainnet/transaction");
164
- case '59144':
165
- case '0xe708':
166
- return "".concat(environment_1.SERVER_URL_PROD, "/linea/mainnet/transaction");
167
- default:
168
- return "".concat(environment_1.SERVER_URL_PROD, "/eth/mainnet/transaction");
169
- }
170
- }
171
- function getSignatureEndpoint(chainId) {
172
- switch (chainId.toLowerCase()) {
173
- case '0x1':
174
- case '1':
175
- return "".concat(environment_1.SERVER_URL_PROD_V1, "/eth/mainnet/signature");
176
- case '0xa4b1':
177
- case '42161':
178
- return "".concat(environment_1.SERVER_URL_PROD_V1, "/arb/mainnet/signature");
179
- case '0x89':
180
- case '137':
181
- return "".concat(environment_1.SERVER_URL_PROD_V1, "/polygon/mainnet/signature");
182
- case '0xa':
183
- case '10':
184
- return "".concat(environment_1.SERVER_URL_PROD_V1, "/optimism/mainnet/signature");
185
- case '8453':
186
- case '0x2105':
187
- return "".concat(environment_1.SERVER_URL_PROD_V1, "/base/mainnet/signature");
188
- default:
189
- return "".concat(environment_1.SERVER_URL_PROD_V1, "/eth/mainnet/signature");
190
- }
191
- }