@webacy-xyz/sdk-threat 1.1.1 → 1.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/dist/cjs/client.js +19 -45
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/constants.js +34 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resources/addresses.js +68 -0
- package/dist/cjs/resources/addresses.js.map +1 -1
- package/dist/cjs/resources/contracts.js +49 -0
- package/dist/cjs/resources/contracts.js.map +1 -1
- package/dist/cjs/resources/index.js +5 -1
- package/dist/cjs/resources/index.js.map +1 -1
- package/dist/cjs/resources/ledger.js +8 -4
- package/dist/cjs/resources/ledger.js.map +1 -1
- package/dist/cjs/resources/scan.js +254 -0
- package/dist/cjs/resources/scan.js.map +1 -0
- package/dist/cjs/resources/transactions.js +89 -0
- package/dist/cjs/resources/transactions.js.map +1 -0
- package/dist/cjs/resources/url.js +6 -4
- package/dist/cjs/resources/url.js.map +1 -1
- package/dist/cjs/resources/usage.js +58 -4
- package/dist/cjs/resources/usage.js.map +1 -1
- package/dist/cjs/types/scan.js +3 -0
- package/dist/cjs/types/scan.js.map +1 -0
- package/dist/cjs/types/transaction.js +3 -0
- package/dist/cjs/types/transaction.js.map +1 -0
- package/dist/esm/client.js +20 -46
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/constants.js +31 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/addresses.js +69 -1
- package/dist/esm/resources/addresses.js.map +1 -1
- package/dist/esm/resources/contracts.js +49 -0
- package/dist/esm/resources/contracts.js.map +1 -1
- package/dist/esm/resources/index.js +2 -0
- package/dist/esm/resources/index.js.map +1 -1
- package/dist/esm/resources/ledger.js +8 -4
- package/dist/esm/resources/ledger.js.map +1 -1
- package/dist/esm/resources/scan.js +250 -0
- package/dist/esm/resources/scan.js.map +1 -0
- package/dist/esm/resources/transactions.js +85 -0
- package/dist/esm/resources/transactions.js.map +1 -0
- package/dist/esm/resources/url.js +7 -5
- package/dist/esm/resources/url.js.map +1 -1
- package/dist/esm/resources/usage.js +58 -4
- package/dist/esm/resources/usage.js.map +1 -1
- package/dist/esm/types/scan.js +2 -0
- package/dist/esm/types/scan.js.map +1 -0
- package/dist/esm/types/transaction.js +2 -0
- package/dist/esm/types/transaction.js.map +1 -0
- package/dist/types/client.d.ts +15 -37
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/constants.d.ts +15 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/addresses.d.ts +43 -1
- package/dist/types/resources/addresses.d.ts.map +1 -1
- package/dist/types/resources/contracts.d.ts +37 -1
- package/dist/types/resources/contracts.d.ts.map +1 -1
- package/dist/types/resources/index.d.ts +2 -0
- package/dist/types/resources/index.d.ts.map +1 -1
- package/dist/types/resources/ledger.d.ts +6 -4
- package/dist/types/resources/ledger.d.ts.map +1 -1
- package/dist/types/resources/scan.d.ts +156 -0
- package/dist/types/resources/scan.d.ts.map +1 -0
- package/dist/types/resources/transactions.d.ts +63 -0
- package/dist/types/resources/transactions.d.ts.map +1 -0
- package/dist/types/resources/url.d.ts +5 -4
- package/dist/types/resources/url.d.ts.map +1 -1
- package/dist/types/resources/usage.d.ts +35 -5
- package/dist/types/resources/usage.d.ts.map +1 -1
- package/dist/types/types/address.d.ts +98 -2
- package/dist/types/types/address.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +127 -3
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +5 -3
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/scan.d.ts +203 -0
- package/dist/types/types/scan.d.ts.map +1 -0
- package/dist/types/types/transaction.d.ts +78 -0
- package/dist/types/types/transaction.d.ts.map +1 -0
- package/dist/types/types/usage.d.ts +15 -0
- package/dist/types/types/usage.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cjs/client.js
CHANGED
|
@@ -9,6 +9,8 @@ const wallets_1 = require("./resources/wallets");
|
|
|
9
9
|
const ledger_1 = require("./resources/ledger");
|
|
10
10
|
const account_trace_1 = require("./resources/account-trace");
|
|
11
11
|
const usage_1 = require("./resources/usage");
|
|
12
|
+
const transactions_1 = require("./resources/transactions");
|
|
13
|
+
const scan_1 = require("./resources/scan");
|
|
12
14
|
/**
|
|
13
15
|
* Webacy Threat SDK Client
|
|
14
16
|
*
|
|
@@ -78,6 +80,18 @@ class ThreatClient extends sdk_core_1.BaseClient {
|
|
|
78
80
|
* API usage statistics and quota management.
|
|
79
81
|
*/
|
|
80
82
|
usage;
|
|
83
|
+
/**
|
|
84
|
+
* Transactions resource
|
|
85
|
+
*
|
|
86
|
+
* Transaction risk analysis for blockchain transactions.
|
|
87
|
+
*/
|
|
88
|
+
transactions;
|
|
89
|
+
/**
|
|
90
|
+
* Scan resource
|
|
91
|
+
*
|
|
92
|
+
* Pre-signing security analysis for transactions and EIP-712 messages.
|
|
93
|
+
*/
|
|
94
|
+
scan;
|
|
81
95
|
/**
|
|
82
96
|
* Create a new ThreatClient instance
|
|
83
97
|
*
|
|
@@ -112,53 +126,13 @@ class ThreatClient extends sdk_core_1.BaseClient {
|
|
|
112
126
|
// Initialize resources with the HTTP client and default chain
|
|
113
127
|
this.addresses = new addresses_1.AddressesResource(this.httpClient, this.defaultChain);
|
|
114
128
|
this.contracts = new contracts_1.ContractsResource(this.httpClient, this.defaultChain);
|
|
115
|
-
this.url = new url_1.UrlResource(this.httpClient);
|
|
129
|
+
this.url = new url_1.UrlResource(this.httpClient, this.defaultChain);
|
|
116
130
|
this.wallets = new wallets_1.WalletsResource(this.httpClient, this.defaultChain);
|
|
117
|
-
this.ledger = new ledger_1.LedgerResource(this.httpClient);
|
|
131
|
+
this.ledger = new ledger_1.LedgerResource(this.httpClient, this.defaultChain);
|
|
118
132
|
this.accountTrace = new account_trace_1.AccountTraceResource(this.httpClient, this.defaultChain);
|
|
119
|
-
this.usage = new usage_1.UsageResource(this.httpClient);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* Add a request interceptor
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* client.addRequestInterceptor((url, config) => {
|
|
127
|
-
* console.log(`Making request to ${url}`);
|
|
128
|
-
* return config;
|
|
129
|
-
* });
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
addRequestInterceptor(interceptor) {
|
|
133
|
-
super.addRequestInterceptor(interceptor);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Add a response interceptor
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```typescript
|
|
140
|
-
* client.addResponseInterceptor((response) => {
|
|
141
|
-
* console.log(`Received ${response.status} response`);
|
|
142
|
-
* return response;
|
|
143
|
-
* });
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
addResponseInterceptor(interceptor) {
|
|
147
|
-
super.addResponseInterceptor(interceptor);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Add an error interceptor
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```typescript
|
|
154
|
-
* client.addErrorInterceptor((error) => {
|
|
155
|
-
* console.error(`Request failed: ${error.message}`);
|
|
156
|
-
* return error;
|
|
157
|
-
* });
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
addErrorInterceptor(interceptor) {
|
|
161
|
-
super.addErrorInterceptor(interceptor);
|
|
133
|
+
this.usage = new usage_1.UsageResource(this.httpClient, this.defaultChain);
|
|
134
|
+
this.transactions = new transactions_1.TransactionsResource(this.httpClient, this.defaultChain);
|
|
135
|
+
this.scan = new scan_1.ScanResource(this.httpClient, this.defaultChain);
|
|
162
136
|
}
|
|
163
137
|
}
|
|
164
138
|
exports.ThreatClient = ThreatClient;
|
package/dist/cjs/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,mDAAsE;AACtE,qDAA0D;AAC1D,qDAA0D;AAC1D,yCAA8C;AAC9C,iDAAsD;AACtD,+CAAoD;AACpD,6DAAiE;AACjE,6CAAkD;AAClD,2DAAgE;AAChE,2CAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,YAAa,SAAQ,qBAAU;IAC1C;;;;;OAKG;IACa,SAAS,CAAoB;IAE7C;;;;;OAKG;IACa,SAAS,CAAoB;IAE7C;;;;OAIG;IACa,GAAG,CAAc;IAEjC;;;;OAIG;IACa,OAAO,CAAkB;IAEzC;;;;OAIG;IACa,MAAM,CAAiB;IAEvC;;;;OAIG;IACa,YAAY,CAAuB;IAEnD;;;;OAIG;IACa,KAAK,CAAgB;IAErC;;;;OAIG;IACa,YAAY,CAAuB;IAEnD;;;;OAIG;IACa,IAAI,CAAe;IAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,8DAA8D;QAC9D,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3E,IAAI,CAAC,GAAG,GAAG,IAAI,iBAAW,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACrE,IAAI,CAAC,YAAY,GAAG,IAAI,oCAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,IAAI,CAAC,YAAY,GAAG,IAAI,mCAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAY,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnE,CAAC;CAIF;AAhHD,oCAgHC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_QUICK_PROFILE_CHAINS = exports.SUPPORTED_TX_CHAINS = exports.VALID_SCAN_CHAIN_IDS = void 0;
|
|
4
|
+
const sdk_core_1 = require("@webacy-xyz/sdk-core");
|
|
5
|
+
/**
|
|
6
|
+
* Valid chain IDs for transaction scanning
|
|
7
|
+
*/
|
|
8
|
+
exports.VALID_SCAN_CHAIN_IDS = [1, 56, 137, 10, 42161, 8453];
|
|
9
|
+
/**
|
|
10
|
+
* Supported chains for transaction analysis
|
|
11
|
+
*/
|
|
12
|
+
exports.SUPPORTED_TX_CHAINS = [
|
|
13
|
+
sdk_core_1.Chain.ETH,
|
|
14
|
+
sdk_core_1.Chain.BASE,
|
|
15
|
+
sdk_core_1.Chain.BSC,
|
|
16
|
+
sdk_core_1.Chain.POL,
|
|
17
|
+
sdk_core_1.Chain.OPT,
|
|
18
|
+
sdk_core_1.Chain.ARB,
|
|
19
|
+
sdk_core_1.Chain.SOL,
|
|
20
|
+
sdk_core_1.Chain.STELLAR,
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Supported chains for quick profile
|
|
24
|
+
*/
|
|
25
|
+
exports.SUPPORTED_QUICK_PROFILE_CHAINS = [
|
|
26
|
+
sdk_core_1.Chain.ETH,
|
|
27
|
+
sdk_core_1.Chain.BASE,
|
|
28
|
+
sdk_core_1.Chain.BSC,
|
|
29
|
+
sdk_core_1.Chain.POL,
|
|
30
|
+
sdk_core_1.Chain.OPT,
|
|
31
|
+
sdk_core_1.Chain.ARB,
|
|
32
|
+
sdk_core_1.Chain.SOL,
|
|
33
|
+
];
|
|
34
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAG7C;;GAEG;AACU,QAAA,oBAAoB,GAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAEjF;;GAEG;AACU,QAAA,mBAAmB,GAAY;IAC1C,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,IAAI;IACV,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,OAAO;CACd,CAAC;AAEF;;GAEG;AACU,QAAA,8BAA8B,GAAY;IACrD,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,IAAI;IACV,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;IACT,gBAAK,CAAC,GAAG;CACV,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NetworkError = exports.NotFoundError = exports.ValidationError = exports.RateLimitError = exports.AuthenticationError = exports.WebacyError = exports.TokenStandard = exports.TypeOfAddress = exports.RiskLevel = exports.RiskScore = exports.RiskModule = exports.CHAIN_NAMES = exports.isEvmChain = exports.ChainCompatibility = exports.Chain = exports.UsageResource = exports.AccountTraceResource = exports.LedgerResource = exports.WalletsResource = exports.UrlResource = exports.ContractsResource = exports.AddressesResource = exports.ThreatClient = void 0;
|
|
3
|
+
exports.NetworkError = exports.NotFoundError = exports.ValidationError = exports.RateLimitError = exports.AuthenticationError = exports.WebacyError = exports.TokenStandard = exports.TypeOfAddress = exports.RiskLevel = exports.RiskScore = exports.RiskModule = exports.CHAIN_NAMES = exports.isEvmChain = exports.ChainCompatibility = exports.Chain = exports.ScanResource = exports.TransactionsResource = exports.UsageResource = exports.AccountTraceResource = exports.LedgerResource = exports.WalletsResource = exports.UrlResource = exports.ContractsResource = exports.AddressesResource = exports.ThreatClient = void 0;
|
|
4
4
|
// Client
|
|
5
5
|
var client_1 = require("./client");
|
|
6
6
|
Object.defineProperty(exports, "ThreatClient", { enumerable: true, get: function () { return client_1.ThreatClient; } });
|
|
@@ -13,6 +13,8 @@ Object.defineProperty(exports, "WalletsResource", { enumerable: true, get: funct
|
|
|
13
13
|
Object.defineProperty(exports, "LedgerResource", { enumerable: true, get: function () { return resources_1.LedgerResource; } });
|
|
14
14
|
Object.defineProperty(exports, "AccountTraceResource", { enumerable: true, get: function () { return resources_1.AccountTraceResource; } });
|
|
15
15
|
Object.defineProperty(exports, "UsageResource", { enumerable: true, get: function () { return resources_1.UsageResource; } });
|
|
16
|
+
Object.defineProperty(exports, "TransactionsResource", { enumerable: true, get: function () { return resources_1.TransactionsResource; } });
|
|
17
|
+
Object.defineProperty(exports, "ScanResource", { enumerable: true, get: function () { return resources_1.ScanResource; } });
|
|
16
18
|
// Re-export commonly used types from core
|
|
17
19
|
var sdk_core_1 = require("@webacy-xyz/sdk-core");
|
|
18
20
|
Object.defineProperty(exports, "Chain", { enumerable: true, get: function () { return sdk_core_1.Chain; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAS;AACT,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAErB,YAAY;AACZ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAS;AACT,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAErB,YAAY;AACZ,yCAUqB;AATnB,8GAAA,iBAAiB,OAAA;AACjB,8GAAA,iBAAiB,OAAA;AACjB,wGAAA,WAAW,OAAA;AACX,4GAAA,eAAe,OAAA;AACf,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,0GAAA,aAAa,OAAA;AACb,iHAAA,oBAAoB,OAAA;AACpB,yGAAA,YAAY,OAAA;AA6Fd,0CAA0C;AAC1C,iDAqB8B;AApB5B,iGAAA,KAAK,OAAA;AACL,8GAAA,kBAAkB,OAAA;AAClB,sGAAA,UAAU,OAAA;AACV,uGAAA,WAAW,OAAA;AACX,sGAAA,UAAU,OAAA;AACV,qGAAA,SAAS,OAAA;AACT,qGAAA,SAAS,OAAA;AACT,yGAAA,aAAa,OAAA;AACb,yGAAA,aAAa,OAAA;AACb,uGAAA,WAAW,OAAA;AACX,+GAAA,mBAAmB,OAAA;AACnB,0GAAA,cAAc,OAAA;AACd,2GAAA,eAAe,OAAA;AACf,yGAAA,aAAa,OAAA;AACb,wGAAA,YAAY,OAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AddressesResource = void 0;
|
|
4
4
|
const sdk_core_1 = require("@webacy-xyz/sdk-core");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
5
6
|
/**
|
|
6
7
|
* Resource for address risk analysis
|
|
7
8
|
*
|
|
@@ -157,6 +158,73 @@ class AddressesResource extends sdk_core_1.BaseResource {
|
|
|
157
158
|
});
|
|
158
159
|
return response.data;
|
|
159
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Get a quick risk profile for an address
|
|
163
|
+
*
|
|
164
|
+
* Returns a lightweight risk assessment including:
|
|
165
|
+
* - Risk score and level
|
|
166
|
+
* - Risk tags
|
|
167
|
+
* - Token approvals (optional)
|
|
168
|
+
* - Account age and activity summary
|
|
169
|
+
*
|
|
170
|
+
* @param address - Address to analyze
|
|
171
|
+
* @param options - Request options
|
|
172
|
+
* @returns Quick profile result
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // Basic quick profile
|
|
177
|
+
* const profile = await client.addresses.getQuickProfile('0x...', {
|
|
178
|
+
* chain: Chain.ETH,
|
|
179
|
+
* });
|
|
180
|
+
* console.log(`Risk score: ${profile.riskScore}`);
|
|
181
|
+
*
|
|
182
|
+
* // With token approvals
|
|
183
|
+
* const profile = await client.addresses.getQuickProfile('0x...', {
|
|
184
|
+
* chain: Chain.ETH,
|
|
185
|
+
* withApprovals: true,
|
|
186
|
+
* });
|
|
187
|
+
* for (const approval of profile.approvals ?? []) {
|
|
188
|
+
* console.log(`${approval.symbol} approved to ${approval.spenderName}`);
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* // Hide trust flags
|
|
192
|
+
* const profile = await client.addresses.getQuickProfile('0x...', {
|
|
193
|
+
* chain: Chain.ETH,
|
|
194
|
+
* hideTrustFlags: true,
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
async getQuickProfile(address, options = {}) {
|
|
199
|
+
const chain = this.resolveQuickProfileChain(options);
|
|
200
|
+
this.validateAddress(address, chain);
|
|
201
|
+
const queryParams = new URLSearchParams();
|
|
202
|
+
queryParams.append('chain', chain);
|
|
203
|
+
if (options.withApprovals !== undefined) {
|
|
204
|
+
queryParams.append('withApprovals', String(options.withApprovals));
|
|
205
|
+
}
|
|
206
|
+
if (options.hideTrustFlags !== undefined) {
|
|
207
|
+
queryParams.append('hide_trust_flags', String(options.hideTrustFlags));
|
|
208
|
+
}
|
|
209
|
+
const response = await this.httpClient.get(`/quick-profile/${encodeURIComponent(address)}?${queryParams.toString()}`, {
|
|
210
|
+
timeout: options.timeout,
|
|
211
|
+
signal: options.signal,
|
|
212
|
+
});
|
|
213
|
+
return response.data;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Resolve the chain for quick profile requests
|
|
217
|
+
*/
|
|
218
|
+
resolveQuickProfileChain(options) {
|
|
219
|
+
const chain = options?.chain ?? this.defaultChain;
|
|
220
|
+
if (!chain) {
|
|
221
|
+
throw new sdk_core_1.ValidationError('Chain is required. Either specify chain in options or set defaultChain in client configuration.');
|
|
222
|
+
}
|
|
223
|
+
if (!constants_1.SUPPORTED_QUICK_PROFILE_CHAINS.includes(chain)) {
|
|
224
|
+
throw new sdk_core_1.ValidationError(`Chain "${chain}" is not supported for quick profile. Supported chains: ${constants_1.SUPPORTED_QUICK_PROFILE_CHAINS.join(', ')}`);
|
|
225
|
+
}
|
|
226
|
+
return chain;
|
|
227
|
+
}
|
|
160
228
|
}
|
|
161
229
|
exports.AddressesResource = AddressesResource;
|
|
162
230
|
//# sourceMappingURL=addresses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/resources/addresses.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/resources/addresses.ts"],"names":[],"mappings":";;;AAAA,mDAA0F;AAW1F,4CAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,iBA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A2D,0CAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtH,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxPD,8CAwPC"}
|
|
@@ -182,6 +182,55 @@ class ContractsResource extends sdk_core_1.BaseResource {
|
|
|
182
182
|
});
|
|
183
183
|
return response.data;
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Get static code analysis for a contract
|
|
187
|
+
*
|
|
188
|
+
* Performs static analysis on verified contract source code
|
|
189
|
+
* to identify security vulnerabilities and code quality issues.
|
|
190
|
+
*
|
|
191
|
+
* @param address - Contract address
|
|
192
|
+
* @param options - Analysis options (chain is optional if defaultChain is set)
|
|
193
|
+
* @returns Code analysis result
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const analysis = await client.contracts.getCodeAnalysis('0x...', {
|
|
198
|
+
* chain: Chain.ETH,
|
|
199
|
+
* });
|
|
200
|
+
*
|
|
201
|
+
* console.log(`Security score: ${analysis.securityScore}`);
|
|
202
|
+
* console.log(`Findings: ${analysis.findings.length}`);
|
|
203
|
+
*
|
|
204
|
+
* // Check for critical/high severity issues
|
|
205
|
+
* const critical = analysis.findings.filter(f =>
|
|
206
|
+
* f.severity === 'critical' || f.severity === 'high'
|
|
207
|
+
* );
|
|
208
|
+
* for (const finding of critical) {
|
|
209
|
+
* console.warn(`${finding.severity}: ${finding.title}`);
|
|
210
|
+
* console.warn(` ${finding.description}`);
|
|
211
|
+
* }
|
|
212
|
+
*
|
|
213
|
+
* // Force refresh cache
|
|
214
|
+
* const fresh = await client.contracts.getCodeAnalysis('0x...', {
|
|
215
|
+
* chain: Chain.ETH,
|
|
216
|
+
* refreshCache: true,
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
async getCodeAnalysis(address, options = {}) {
|
|
221
|
+
const chain = this.resolveChain(options);
|
|
222
|
+
this.validateAddress(address, chain);
|
|
223
|
+
const queryParams = new URLSearchParams();
|
|
224
|
+
queryParams.append('chain', chain);
|
|
225
|
+
if (options.refreshCache !== undefined) {
|
|
226
|
+
queryParams.append('refreshCache', String(options.refreshCache));
|
|
227
|
+
}
|
|
228
|
+
const response = await this.httpClient.get(`/contracts/${encodeURIComponent(address)}/code-analysis?${queryParams.toString()}`, {
|
|
229
|
+
timeout: options.timeout,
|
|
230
|
+
signal: options.signal,
|
|
231
|
+
});
|
|
232
|
+
return response.data;
|
|
233
|
+
}
|
|
185
234
|
}
|
|
186
235
|
exports.ContractsResource = ContractsResource;
|
|
187
236
|
//# sourceMappingURL=contracts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/resources/contracts.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/resources/contracts.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAclE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,iBAAkB,SAAQ,uBAAY;IACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,KAAK,CAAC,OAAO,CACX,OAAe,EACf,UAAmC,EAAE;QAErC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAErC,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;QAC1C,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEnC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACvC,WAAW,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,QAAQ,GAAuC,MAAM,IAAI,CAAC,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O,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AA7PD,8CA6PC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UsageResource = exports.AccountTraceResource = exports.LedgerResource = exports.WalletsResource = exports.UrlResource = exports.ContractsResource = exports.AddressesResource = void 0;
|
|
3
|
+
exports.ScanResource = exports.TransactionsResource = exports.UsageResource = exports.AccountTraceResource = exports.LedgerResource = exports.WalletsResource = exports.UrlResource = exports.ContractsResource = exports.AddressesResource = void 0;
|
|
4
4
|
var addresses_1 = require("./addresses");
|
|
5
5
|
Object.defineProperty(exports, "AddressesResource", { enumerable: true, get: function () { return addresses_1.AddressesResource; } });
|
|
6
6
|
var contracts_1 = require("./contracts");
|
|
@@ -15,4 +15,8 @@ var account_trace_1 = require("./account-trace");
|
|
|
15
15
|
Object.defineProperty(exports, "AccountTraceResource", { enumerable: true, get: function () { return account_trace_1.AccountTraceResource; } });
|
|
16
16
|
var usage_1 = require("./usage");
|
|
17
17
|
Object.defineProperty(exports, "UsageResource", { enumerable: true, get: function () { return usage_1.UsageResource; } });
|
|
18
|
+
var transactions_1 = require("./transactions");
|
|
19
|
+
Object.defineProperty(exports, "TransactionsResource", { enumerable: true, get: function () { return transactions_1.TransactionsResource; } });
|
|
20
|
+
var scan_1 = require("./scan");
|
|
21
|
+
Object.defineProperty(exports, "ScanResource", { enumerable: true, get: function () { return scan_1.ScanResource; } });
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAC1B,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAC1B,6BAAoC;AAA3B,kGAAA,WAAW,OAAA;AACpB,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,iDAAuD;AAA9C,qHAAA,oBAAoB,OAAA;AAC7B,iCAAwC;AAA/B,sGAAA,aAAa,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAC1B,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAC1B,6BAAoC;AAA3B,kGAAA,WAAW,OAAA;AACpB,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,iDAAuD;AAA9C,qHAAA,oBAAoB,OAAA;AAC7B,iCAAwC;AAA/B,sGAAA,aAAa,OAAA;AACtB,+CAAsD;AAA7C,oHAAA,oBAAoB,OAAA;AAC7B,+BAAsC;AAA7B,oGAAA,YAAY,OAAA"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LedgerResource = void 0;
|
|
4
|
+
const sdk_core_1 = require("@webacy-xyz/sdk-core");
|
|
4
5
|
/**
|
|
5
6
|
* Resource for hardware wallet transaction scanning
|
|
6
7
|
*
|
|
7
8
|
* Provides security analysis for transactions before signing on
|
|
8
9
|
* hardware wallets (Ledger devices).
|
|
9
10
|
*
|
|
11
|
+
* Note: This resource uses numeric chain IDs in the request body
|
|
12
|
+
* rather than the Chain enum, as required by the underlying API.
|
|
13
|
+
*
|
|
10
14
|
* @example
|
|
11
15
|
* ```typescript
|
|
12
16
|
* // Scan a transaction before signing
|
|
@@ -20,10 +24,10 @@ exports.LedgerResource = void 0;
|
|
|
20
24
|
* }
|
|
21
25
|
* ```
|
|
22
26
|
*/
|
|
23
|
-
class LedgerResource {
|
|
24
|
-
|
|
25
|
-
constructor(httpClient) {
|
|
26
|
-
|
|
27
|
+
class LedgerResource extends sdk_core_1.BaseResource {
|
|
28
|
+
// Note: Ledger uses numeric chain IDs in request body, defaultChain is accepted for consistency
|
|
29
|
+
constructor(httpClient, _defaultChain) {
|
|
30
|
+
super(httpClient, _defaultChain);
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
33
|
* Scan a transaction before signing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/resources/ledger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/resources/ledger.ts"],"names":[],"mappings":";;;AAAA,mDAAyE;AASzE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,cAAe,SAAQ,uBAAY;IAC9C,gGAAgG;IAChG,YAAY,UAAqD,EAAE,aAAqB;QACtF,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,KAAK,CAAC,eAAe,CACnB,MAAoB,EACpB,OAA0B,EAC1B,OAA2B;QAE3B,MAAM,QAAQ,GAAqC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAC3E,WAAW,MAAM,UAAU,EAC3B,OAAO,EACP;YACE,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,KAAK,CAAC,UAAU,CACd,MAAoB,EACpB,OAA4B,EAC5B,OAA2B;QAE3B,MAAM,QAAQ,GAAqC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAC3E,WAAW,MAAM,eAAe,EAChC,OAAO,EACP;YACE,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,MAAM,EAAE,OAAO,EAAE,MAAM;SACxB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAtHD,wCAsHC"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScanResource = void 0;
|
|
4
|
+
const sdk_core_1 = require("@webacy-xyz/sdk-core");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
/**
|
|
7
|
+
* Resource for transaction and message scanning
|
|
8
|
+
*
|
|
9
|
+
* Provides pre-signing security analysis for:
|
|
10
|
+
* - Raw transaction scanning
|
|
11
|
+
* - EIP-712 typed message scanning
|
|
12
|
+
*
|
|
13
|
+
* Note: This resource uses numeric chain IDs (1, 56, 137, etc.) in the request body
|
|
14
|
+
* rather than the Chain enum, as required by the underlying API.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Scan a transaction before signing
|
|
19
|
+
* const result = await client.scan.scanTransaction('0xSigner', {
|
|
20
|
+
* tx: { from: '0xSigner', raw: '0xRawTx...' },
|
|
21
|
+
* chain: 1, // Ethereum
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Scan an EIP-712 message
|
|
25
|
+
* const result = await client.scan.scanEip712('0xSigner', {
|
|
26
|
+
* msg: {
|
|
27
|
+
* from: '0xSigner',
|
|
28
|
+
* data: { types: {...}, primaryType: 'Permit', domain: {...}, message: {...} },
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
class ScanResource extends sdk_core_1.BaseResource {
|
|
34
|
+
// Note: Scan uses numeric chain IDs in request body, defaultChain is accepted for consistency
|
|
35
|
+
constructor(httpClient, _defaultChain) {
|
|
36
|
+
super(httpClient, _defaultChain);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Scan a transaction for security risks before signing
|
|
40
|
+
*
|
|
41
|
+
* Analyzes raw transaction data and returns:
|
|
42
|
+
* - Risk assessment and warnings
|
|
43
|
+
* - Simulated asset changes
|
|
44
|
+
* - Contract interaction details
|
|
45
|
+
* - Domain reputation (if provided)
|
|
46
|
+
*
|
|
47
|
+
* @param fromAddress - The signer address
|
|
48
|
+
* @param request - Transaction scan request
|
|
49
|
+
* @param options - Request options
|
|
50
|
+
* @returns Transaction scan result
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const result = await client.scan.scanTransaction('0xSigner...', {
|
|
55
|
+
* tx: {
|
|
56
|
+
* from: '0xSigner...',
|
|
57
|
+
* raw: '0x02f8...',
|
|
58
|
+
* },
|
|
59
|
+
* chain: 1, // Ethereum mainnet
|
|
60
|
+
* domain: 'uniswap.org',
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* if (result.riskLevel === 'high' || result.riskLevel === 'critical') {
|
|
64
|
+
* console.warn('High risk transaction!');
|
|
65
|
+
* for (const warning of result.warnings) {
|
|
66
|
+
* console.warn(`${warning.severity}: ${warning.description}`);
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // Check simulated asset changes
|
|
71
|
+
* if (result.assetChanges) {
|
|
72
|
+
* for (const change of result.assetChanges) {
|
|
73
|
+
* console.log(`${change.type}: ${change.amount} ${change.symbol}`);
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
async scanTransaction(fromAddress, request, options = {}) {
|
|
79
|
+
this.validateSignerAddress(fromAddress);
|
|
80
|
+
this.validateTransactionRequest(request);
|
|
81
|
+
this.validateSignerAddressMatch(fromAddress, request.tx.from, 'tx.from');
|
|
82
|
+
const queryParams = new URLSearchParams();
|
|
83
|
+
if (options.refreshCache !== undefined) {
|
|
84
|
+
queryParams.append('refreshCache', String(options.refreshCache));
|
|
85
|
+
}
|
|
86
|
+
const queryString = queryParams.toString();
|
|
87
|
+
const path = `/scan/${encodeURIComponent(fromAddress)}/transactions${queryString ? `?${queryString}` : ''}`;
|
|
88
|
+
const response = await this.httpClient.post(path, request, {
|
|
89
|
+
timeout: options.timeout,
|
|
90
|
+
signal: options.signal,
|
|
91
|
+
});
|
|
92
|
+
return response.data;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Scan an EIP-712 typed message for security risks before signing
|
|
96
|
+
*
|
|
97
|
+
* Analyzes EIP-712 typed data and returns:
|
|
98
|
+
* - Risk assessment and warnings
|
|
99
|
+
* - Message type analysis (permit, order, etc.)
|
|
100
|
+
* - Spender analysis for approvals
|
|
101
|
+
* - Domain reputation (if provided)
|
|
102
|
+
*
|
|
103
|
+
* @param fromAddress - The signer address
|
|
104
|
+
* @param request - EIP-712 scan request
|
|
105
|
+
* @param options - Request options
|
|
106
|
+
* @returns EIP-712 scan result
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const result = await client.scan.scanEip712('0xSigner...', {
|
|
111
|
+
* msg: {
|
|
112
|
+
* from: '0xSigner...',
|
|
113
|
+
* data: {
|
|
114
|
+
* types: {
|
|
115
|
+
* EIP712Domain: [
|
|
116
|
+
* { name: 'name', type: 'string' },
|
|
117
|
+
* { name: 'version', type: 'string' },
|
|
118
|
+
* { name: 'chainId', type: 'uint256' },
|
|
119
|
+
* { name: 'verifyingContract', type: 'address' },
|
|
120
|
+
* ],
|
|
121
|
+
* Permit: [
|
|
122
|
+
* { name: 'owner', type: 'address' },
|
|
123
|
+
* { name: 'spender', type: 'address' },
|
|
124
|
+
* { name: 'value', type: 'uint256' },
|
|
125
|
+
* { name: 'nonce', type: 'uint256' },
|
|
126
|
+
* { name: 'deadline', type: 'uint256' },
|
|
127
|
+
* ],
|
|
128
|
+
* },
|
|
129
|
+
* primaryType: 'Permit',
|
|
130
|
+
* domain: {
|
|
131
|
+
* name: 'Token',
|
|
132
|
+
* version: '1',
|
|
133
|
+
* chainId: 1,
|
|
134
|
+
* verifyingContract: '0xToken...',
|
|
135
|
+
* },
|
|
136
|
+
* message: {
|
|
137
|
+
* owner: '0xSigner...',
|
|
138
|
+
* spender: '0xSpender...',
|
|
139
|
+
* value: '1000000000000000000',
|
|
140
|
+
* nonce: 0,
|
|
141
|
+
* deadline: 1735689600,
|
|
142
|
+
* },
|
|
143
|
+
* },
|
|
144
|
+
* },
|
|
145
|
+
* domain: 'app.uniswap.org',
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* if (result.messageType?.isPermit) {
|
|
149
|
+
* console.log('This is a permit/approval signature');
|
|
150
|
+
* if (result.spenderAnalysis?.riskLevel === 'high') {
|
|
151
|
+
* console.warn('High risk spender!');
|
|
152
|
+
* }
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
async scanEip712(fromAddress, request, options = {}) {
|
|
157
|
+
this.validateSignerAddress(fromAddress);
|
|
158
|
+
this.validateEip712Request(request);
|
|
159
|
+
this.validateSignerAddressMatch(fromAddress, request.msg.from, 'msg.from');
|
|
160
|
+
const queryParams = new URLSearchParams();
|
|
161
|
+
if (options.refreshCache !== undefined) {
|
|
162
|
+
queryParams.append('refreshCache', String(options.refreshCache));
|
|
163
|
+
}
|
|
164
|
+
const queryString = queryParams.toString();
|
|
165
|
+
const path = `/scan/${encodeURIComponent(fromAddress)}/eip712${queryString ? `?${queryString}` : ''}`;
|
|
166
|
+
const response = await this.httpClient.post(path, request, {
|
|
167
|
+
timeout: options.timeout,
|
|
168
|
+
signal: options.signal,
|
|
169
|
+
});
|
|
170
|
+
return response.data;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Validate signer address format (basic non-empty check)
|
|
174
|
+
*
|
|
175
|
+
* Note: This is a simpler validation than the chain-aware validation in BaseResource,
|
|
176
|
+
* as scan requests accept EVM addresses only.
|
|
177
|
+
*/
|
|
178
|
+
validateSignerAddress(address) {
|
|
179
|
+
if (!address || typeof address !== 'string' || address.trim() === '') {
|
|
180
|
+
throw new sdk_core_1.ValidationError('Address is required and must be a non-empty string.');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Validate that the signer address matches the address in the request
|
|
185
|
+
*/
|
|
186
|
+
validateSignerAddressMatch(signerAddress, requestAddress, fieldName) {
|
|
187
|
+
if (signerAddress.toLowerCase() !== requestAddress.toLowerCase()) {
|
|
188
|
+
throw new sdk_core_1.ValidationError(`Signer address must match ${fieldName}.`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Validate transaction scan request
|
|
193
|
+
*/
|
|
194
|
+
validateTransactionRequest(request) {
|
|
195
|
+
if (!request) {
|
|
196
|
+
throw new sdk_core_1.ValidationError('Request body is required.');
|
|
197
|
+
}
|
|
198
|
+
if (!request.tx) {
|
|
199
|
+
throw new sdk_core_1.ValidationError('Transaction data (tx) is required.');
|
|
200
|
+
}
|
|
201
|
+
if (!request.tx.from || typeof request.tx.from !== 'string') {
|
|
202
|
+
throw new sdk_core_1.ValidationError('Transaction from address (tx.from) is required.');
|
|
203
|
+
}
|
|
204
|
+
if (!request.tx.raw || typeof request.tx.raw !== 'string') {
|
|
205
|
+
throw new sdk_core_1.ValidationError('Raw transaction data (tx.raw) is required.');
|
|
206
|
+
}
|
|
207
|
+
if (!constants_1.VALID_SCAN_CHAIN_IDS.includes(request.chain)) {
|
|
208
|
+
throw new sdk_core_1.ValidationError(`Invalid chain ID. Supported chain IDs: ${constants_1.VALID_SCAN_CHAIN_IDS.join(', ')} (1=ETH, 56=BSC, 137=POL, 10=OPT, 42161=ARB, 8453=BASE)`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Validate EIP-712 scan request
|
|
213
|
+
*/
|
|
214
|
+
validateEip712Request(request) {
|
|
215
|
+
if (!request) {
|
|
216
|
+
throw new sdk_core_1.ValidationError('Request body is required.');
|
|
217
|
+
}
|
|
218
|
+
if (!request.msg) {
|
|
219
|
+
throw new sdk_core_1.ValidationError('Message data (msg) is required.');
|
|
220
|
+
}
|
|
221
|
+
if (!request.msg.from || typeof request.msg.from !== 'string') {
|
|
222
|
+
throw new sdk_core_1.ValidationError('Message from address (msg.from) is required.');
|
|
223
|
+
}
|
|
224
|
+
if (!request.msg.data) {
|
|
225
|
+
throw new sdk_core_1.ValidationError('EIP-712 typed data (msg.data) is required.');
|
|
226
|
+
}
|
|
227
|
+
if (!request.msg.data.types || typeof request.msg.data.types !== 'object') {
|
|
228
|
+
throw new sdk_core_1.ValidationError('EIP-712 types (msg.data.types) is required.');
|
|
229
|
+
}
|
|
230
|
+
if (!request.msg.data.primaryType || typeof request.msg.data.primaryType !== 'string') {
|
|
231
|
+
throw new sdk_core_1.ValidationError('EIP-712 primaryType (msg.data.primaryType) is required.');
|
|
232
|
+
}
|
|
233
|
+
if (!request.msg.data.domain || typeof request.msg.data.domain !== 'object') {
|
|
234
|
+
throw new sdk_core_1.ValidationError('EIP-712 domain (msg.data.domain) is required.');
|
|
235
|
+
}
|
|
236
|
+
if (typeof request.msg.data.domain.chainId !== 'number') {
|
|
237
|
+
throw new sdk_core_1.ValidationError('EIP-712 domain chainId (msg.data.domain.chainId) is required.');
|
|
238
|
+
}
|
|
239
|
+
if (request.msg.data.domain.chainId <= 0) {
|
|
240
|
+
throw new sdk_core_1.ValidationError('EIP-712 domain chainId must be a positive integer.');
|
|
241
|
+
}
|
|
242
|
+
if (!constants_1.VALID_SCAN_CHAIN_IDS.includes(request.msg.data.domain.chainId)) {
|
|
243
|
+
throw new sdk_core_1.ValidationError(`Invalid chain ID in EIP-712 domain. Supported chain IDs: ${constants_1.VALID_SCAN_CHAIN_IDS.join(', ')} (1=ETH, 56=BSC, 137=POL, 10=OPT, 42161=ARB, 8453=BASE)`);
|
|
244
|
+
}
|
|
245
|
+
if (!request.msg.data.message || typeof request.msg.data.message !== 'object') {
|
|
246
|
+
throw new sdk_core_1.ValidationError('EIP-712 message (msg.data.message) is required.');
|
|
247
|
+
}
|
|
248
|
+
if (Object.keys(request.msg.data.message).length === 0) {
|
|
249
|
+
throw new sdk_core_1.ValidationError('EIP-712 message (msg.data.message) cannot be empty.');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.ScanResource = ScanResource;
|
|
254
|
+
//# sourceMappingURL=scan.js.map
|