@lidofinance/lsv-cli 1.7.0 → 1.8.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/abi/defi-wrapper/GenericStrategy.d.ts +308 -0
- package/dist/abi/defi-wrapper/GenericStrategy.js +409 -0
- package/dist/abi/defi-wrapper/GenericStrategy.js.map +1 -0
- package/dist/abi/defi-wrapper/index.d.ts +1 -0
- package/dist/abi/defi-wrapper/index.js +1 -0
- package/dist/abi/defi-wrapper/index.js.map +1 -1
- package/dist/abi/defi-wrapper/sources.d.ts +103 -0
- package/dist/abi/defi-wrapper/sources.js +104 -0
- package/dist/abi/defi-wrapper/sources.js.map +1 -0
- package/dist/configs/deployed.d.ts +5 -0
- package/dist/configs/deployed.js +20 -2
- package/dist/configs/deployed.js.map +1 -1
- package/dist/configs/envs.js +2 -0
- package/dist/configs/envs.js.map +1 -1
- package/dist/contracts/defi-wrapper/generic-strategy.d.ts +5 -0
- package/dist/contracts/defi-wrapper/generic-strategy.js +12 -0
- package/dist/contracts/defi-wrapper/generic-strategy.js.map +1 -0
- package/dist/contracts/defi-wrapper/index.d.ts +1 -0
- package/dist/contracts/defi-wrapper/index.js +1 -0
- package/dist/contracts/defi-wrapper/index.js.map +1 -1
- package/dist/features/defi-wrapper/defi-wrapper-factory.d.ts +3 -0
- package/dist/features/defi-wrapper/defi-wrapper-factory.js +4 -1
- package/dist/features/defi-wrapper/defi-wrapper-factory.js.map +1 -1
- package/dist/features/defi-wrapper/index.d.ts +1 -0
- package/dist/features/defi-wrapper/index.js +1 -0
- package/dist/features/defi-wrapper/index.js.map +1 -1
- package/dist/features/defi-wrapper/pool-info.d.ts +18 -1
- package/dist/features/defi-wrapper/pool-info.js +47 -3
- package/dist/features/defi-wrapper/pool-info.js.map +1 -1
- package/dist/features/defi-wrapper/timelock-roles.d.ts +5 -0
- package/dist/features/defi-wrapper/timelock-roles.js +43 -0
- package/dist/features/defi-wrapper/timelock-roles.js.map +1 -0
- package/dist/features/defi-wrapper/timelock.d.ts +1 -6
- package/dist/features/defi-wrapper/timelock.js +2 -45
- package/dist/features/defi-wrapper/timelock.js.map +1 -1
- package/dist/features/defi-wrapper/verify-contracts.d.ts +20 -0
- package/dist/features/defi-wrapper/verify-contracts.js +145 -0
- package/dist/features/defi-wrapper/verify-contracts.js.map +1 -0
- package/dist/features/utils/try-fetch.js +2 -0
- package/dist/features/utils/try-fetch.js.map +1 -1
- package/dist/programs/account/write.js +2 -1
- package/dist/programs/account/write.js.map +1 -1
- package/dist/programs/defi-wrapper/contracts/factory/write.js +77 -6
- package/dist/programs/defi-wrapper/contracts/factory/write.js.map +1 -1
- package/dist/programs/defi-wrapper/contracts/index.d.ts +1 -0
- package/dist/programs/defi-wrapper/contracts/index.js +1 -0
- package/dist/programs/defi-wrapper/contracts/index.js.map +1 -1
- package/dist/programs/defi-wrapper/contracts/strategy/config.d.ts +3 -0
- package/dist/programs/defi-wrapper/contracts/strategy/config.js +40 -0
- package/dist/programs/defi-wrapper/contracts/strategy/config.js.map +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/index.d.ts +3 -0
- package/dist/programs/defi-wrapper/contracts/strategy/index.js +4 -0
- package/dist/programs/defi-wrapper/contracts/strategy/index.js.map +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/main.d.ts +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/main.js +6 -0
- package/dist/programs/defi-wrapper/contracts/strategy/main.js.map +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/read.d.ts +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/read.js +30 -0
- package/dist/programs/defi-wrapper/contracts/strategy/read.js.map +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/write.d.ts +1 -0
- package/dist/programs/defi-wrapper/contracts/strategy/write.js +34 -0
- package/dist/programs/defi-wrapper/contracts/strategy/write.js.map +1 -0
- package/dist/programs/defi-wrapper/contracts/stv-steth-pool/write.js +25 -21
- package/dist/programs/defi-wrapper/contracts/stv-steth-pool/write.js.map +1 -1
- package/dist/programs/defi-wrapper/contracts/withdrawal-queue/write.js +3 -4
- package/dist/programs/defi-wrapper/contracts/withdrawal-queue/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/distributor/write.js +1 -0
- package/dist/programs/defi-wrapper/use-cases/distributor/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/common/read.js +3 -3
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/common/read.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/common/write.js +3 -3
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/common/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/dashboard/write.js +3 -3
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/dashboard/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/index.d.ts +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/index.js +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/index.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/pool/write.js +4 -4
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/pool/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/proxy/write.js +3 -3
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/proxy/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/index.d.ts +2 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/index.js +3 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/index.js.map +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/main.d.ts +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/main.js +6 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/main.js.map +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/write.d.ts +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/write.js +57 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/strategy/write.js.map +1 -0
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/withdrawal-queue/write.js +4 -4
- package/dist/programs/defi-wrapper/use-cases/timelock-governance/withdrawal-queue/write.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/wrapper-operations/read.js +32 -11
- package/dist/programs/defi-wrapper/use-cases/wrapper-operations/read.js.map +1 -1
- package/dist/programs/defi-wrapper/use-cases/wrapper-operations/write.js +14 -12
- package/dist/programs/defi-wrapper/use-cases/wrapper-operations/write.js.map +1 -1
- package/dist/programs/use-cases/consolidation/write.js +2 -0
- package/dist/programs/use-cases/consolidation/write.js.map +1 -1
- package/dist/providers/wallet.d.ts +88 -72
- package/dist/providers/wallet.js +74 -2
- package/dist/providers/wallet.js.map +1 -1
- package/dist/tests/integration/gas-estimation.test.d.ts +1 -0
- package/dist/tests/integration/gas-estimation.test.js +76 -0
- package/dist/tests/integration/gas-estimation.test.js.map +1 -0
- package/dist/tests/integration/helpers/test-client.d.ts +52 -52
- package/dist/tests/utils/arguments-security.test.d.ts +1 -0
- package/dist/tests/utils/arguments-security.test.js +34 -0
- package/dist/tests/utils/arguments-security.test.js.map +1 -0
- package/dist/tests/utils/arguments.test.js +2 -20
- package/dist/tests/utils/arguments.test.js.map +1 -1
- package/dist/tests/utils/cache-security.test.d.ts +1 -0
- package/dist/tests/utils/cache-security.test.js +62 -0
- package/dist/tests/utils/cache-security.test.js.map +1 -0
- package/dist/tests/utils/contract-write-stateoverride.test.d.ts +1 -0
- package/dist/tests/utils/contract-write-stateoverride.test.js +135 -0
- package/dist/tests/utils/contract-write-stateoverride.test.js.map +1 -0
- package/dist/tests/utils/data-validators.test.js +21 -5
- package/dist/tests/utils/data-validators.test.js.map +1 -1
- package/dist/tests/utils/deployed-security.test.d.ts +1 -0
- package/dist/tests/utils/deployed-security.test.js +51 -0
- package/dist/tests/utils/deployed-security.test.js.map +1 -0
- package/dist/tests/utils/get-confirmations.test.d.ts +1 -0
- package/dist/tests/utils/get-confirmations.test.js +40 -0
- package/dist/tests/utils/get-confirmations.test.js.map +1 -0
- package/dist/tests/utils/ipfs-security.test.d.ts +1 -0
- package/dist/tests/utils/ipfs-security.test.js +105 -0
- package/dist/tests/utils/ipfs-security.test.js.map +1 -0
- package/dist/tests/utils/public-client-gas-estimation.test.d.ts +1 -0
- package/dist/tests/utils/public-client-gas-estimation.test.js +231 -0
- package/dist/tests/utils/public-client-gas-estimation.test.js.map +1 -0
- package/dist/tests/utils/rate-limit-security.test.d.ts +1 -0
- package/dist/tests/utils/rate-limit-security.test.js +82 -0
- package/dist/tests/utils/rate-limit-security.test.js.map +1 -0
- package/dist/tests/utils/salt.test.d.ts +1 -0
- package/dist/tests/utils/salt.test.js +20 -0
- package/dist/tests/utils/salt.test.js.map +1 -0
- package/dist/utils/arguments.d.ts +2 -7
- package/dist/utils/arguments.js +21 -17
- package/dist/utils/arguments.js.map +1 -1
- package/dist/utils/cache.js +15 -13
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/data-validators.d.ts +3 -2
- package/dist/utils/data-validators.js +8 -11
- package/dist/utils/data-validators.js.map +1 -1
- package/dist/utils/fetch-cl.js +2 -1
- package/dist/utils/fetch-cl.js.map +1 -1
- package/dist/utils/index.d.ts +6 -5
- package/dist/utils/index.js +6 -5
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/ipfs.js +18 -1
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/logging/console.d.ts +1 -0
- package/dist/utils/logging/console.js +23 -2
- package/dist/utils/logging/console.js.map +1 -1
- package/dist/utils/prompts/account.d.ts +1 -0
- package/dist/utils/prompts/account.js +13 -0
- package/dist/utils/prompts/account.js.map +1 -0
- package/dist/utils/prompts/index.d.ts +3 -0
- package/dist/utils/prompts/index.js +3 -0
- package/dist/utils/prompts/index.js.map +1 -1
- package/dist/utils/prompts/strategy.d.ts +15398 -0
- package/dist/utils/prompts/strategy.js +10 -0
- package/dist/utils/prompts/strategy.js.map +1 -0
- package/dist/utils/prompts/timelock-roles.d.ts +1 -0
- package/dist/utils/prompts/timelock-roles.js +13 -0
- package/dist/utils/prompts/timelock-roles.js.map +1 -0
- package/dist/utils/rate-limit.d.ts +6 -9
- package/dist/utils/rate-limit.js +27 -5
- package/dist/utils/rate-limit.js.map +1 -1
- package/dist/utils/salt.d.ts +3 -0
- package/dist/utils/salt.js +8 -0
- package/dist/utils/salt.js.map +1 -0
- package/dist/utils/transactions/tx-private-key.d.ts +2 -1
- package/dist/utils/transactions/tx-private-key.js +5 -8
- package/dist/utils/transactions/tx-private-key.js.map +1 -1
- package/dist/utils/transactions/tx-wc.js +3 -7
- package/dist/utils/transactions/tx-wc.js.map +1 -1
- package/dist/utils/transactions/utils.d.ts +1 -0
- package/dist/utils/transactions/utils.js +12 -0
- package/dist/utils/transactions/utils.js.map +1 -1
- package/dist/version/index.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { describe, test, expect, beforeAll } from 'vitest';
|
|
2
|
+
import { createPublicClient, http, parseEther, maxUint256 } from 'viem';
|
|
3
|
+
import { getChain } from '../../configs/index.js';
|
|
4
|
+
import { loadTestConfig } from './helpers/test-config.js';
|
|
5
|
+
import { createAnvilTestClient, mintEth, getAccountFromPrivateKey, } from './helpers/test-client.js';
|
|
6
|
+
import { setupIntegrationTestsBeforeEach } from './helpers/test-setup.js';
|
|
7
|
+
/**
|
|
8
|
+
* Integration tests for the gas estimation stateOverride fix.
|
|
9
|
+
*
|
|
10
|
+
* Proves that stateOverride in eth_estimateGas allows accurate gas estimation
|
|
11
|
+
* for low-balance accounts on a real Anvil fork.
|
|
12
|
+
*/
|
|
13
|
+
// Anvil's default account #1 (not the one used by the test suite)
|
|
14
|
+
const LOW_BALANCE_KEY = '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d';
|
|
15
|
+
describe('gas estimation with stateOverride', () => {
|
|
16
|
+
setupIntegrationTestsBeforeEach();
|
|
17
|
+
let rpcUrl;
|
|
18
|
+
let chainObj;
|
|
19
|
+
beforeAll(async () => {
|
|
20
|
+
const config = loadTestConfig();
|
|
21
|
+
rpcUrl = config.EL_URL;
|
|
22
|
+
chainObj = await getChain();
|
|
23
|
+
});
|
|
24
|
+
test('stateOverride: low-balance account succeeds with balance override', async () => {
|
|
25
|
+
const testClient = createAnvilTestClient(chainObj, rpcUrl);
|
|
26
|
+
const lowBalanceAccount = getAccountFromPrivateKey(LOW_BALANCE_KEY);
|
|
27
|
+
await mintEth(testClient, lowBalanceAccount.address, parseEther('0.0001'));
|
|
28
|
+
const publicClient = createPublicClient({
|
|
29
|
+
chain: chainObj,
|
|
30
|
+
transport: http(rpcUrl),
|
|
31
|
+
});
|
|
32
|
+
// With stateOverride — estimation succeeds regardless of real balance
|
|
33
|
+
const gas = await publicClient.estimateGas({
|
|
34
|
+
account: lowBalanceAccount,
|
|
35
|
+
to: '0x0000000000000000000000000000000000000001',
|
|
36
|
+
value: 0n,
|
|
37
|
+
stateOverride: [
|
|
38
|
+
{
|
|
39
|
+
address: lowBalanceAccount.address,
|
|
40
|
+
balance: maxUint256,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
expect(gas).toBeGreaterThan(0n);
|
|
45
|
+
expect(gas).toBeLessThanOrEqual(100000n);
|
|
46
|
+
});
|
|
47
|
+
test('contract interaction: estimateGas with stateOverride on ERC-20 approve', async () => {
|
|
48
|
+
const testClient = createAnvilTestClient(chainObj, rpcUrl);
|
|
49
|
+
const lowBalanceAccount = getAccountFromPrivateKey(LOW_BALANCE_KEY);
|
|
50
|
+
await mintEth(testClient, lowBalanceAccount.address, parseEther('0.0001'));
|
|
51
|
+
const publicClient = createPublicClient({
|
|
52
|
+
chain: chainObj,
|
|
53
|
+
transport: http(rpcUrl),
|
|
54
|
+
});
|
|
55
|
+
// ERC-20 approve(spender, amount) on WETH
|
|
56
|
+
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
57
|
+
const approveData = '0x095ea7b3' +
|
|
58
|
+
'000000000000000000000000deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' +
|
|
59
|
+
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
|
|
60
|
+
const gas = await publicClient.estimateGas({
|
|
61
|
+
account: lowBalanceAccount,
|
|
62
|
+
to: WETH,
|
|
63
|
+
data: approveData,
|
|
64
|
+
stateOverride: [
|
|
65
|
+
{
|
|
66
|
+
address: lowBalanceAccount.address,
|
|
67
|
+
balance: maxUint256,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
// approve() typically costs ~46k gas
|
|
72
|
+
expect(gas).toBeGreaterThan(20000n);
|
|
73
|
+
expect(gas).toBeLessThan(200000n);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=gas-estimation.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas-estimation.test.js","sourceRoot":"","sources":["../../../tests/integration/gas-estimation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E;;;;;GAKG;AAEH,kEAAkE;AAClE,MAAM,eAAe,GACnB,oEAAoE,CA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AC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC3D,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC;QAEpE,MAAM,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE3E,MAAM,YAAY,GAAG,kBAAkB,CAAC;YACtC,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC;SACxB,CAAC,CAAC;QAEH,0CAA0C;QAC1C,MAAM,IAAI,GAAG,4CAA4C,CAAC;QAC1D,MAAM,WAAW,GACf,YAAY;YACZ,kEAAkE;YAClE,kEAAkE,CAAC;QAErE,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC;YACzC,OAAO,EAAE,iBAAiB;YAC1B,EAAE,EAAE,IAAqB;YACzB,IAAI,EAAE,WAA4B;YAClC,aAAa,EAAE;gBACb;oBACE,OAAO,EAAE,iBAAiB,CAAC,OAAO;oBAClC,OAAO,EAAE,UAAU;iBACpB;aACF;SACF,CAAC,CAAC;QAEH,qCAAqC;QACrC,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC,MAAO,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,OAAQ,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -4194,21 +4194,24 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4194
4194
|
[x: `bool[${string}]`]: undefined;
|
|
4195
4195
|
[x: `bytes[${string}]`]: undefined;
|
|
4196
4196
|
[x: `bytes11[${string}]`]: undefined;
|
|
4197
|
-
[x: `bytes1[${string}]`]: undefined;
|
|
4198
4197
|
[x: `bytes2[${string}]`]: undefined;
|
|
4198
|
+
[x: `bytes1[${string}]`]: undefined;
|
|
4199
|
+
[x: `bytes16[${string}]`]: undefined;
|
|
4200
|
+
[x: `bytes32[${string}]`]: undefined;
|
|
4201
|
+
[x: `bytes8[${string}]`]: undefined;
|
|
4202
|
+
[x: `bytes24[${string}]`]: undefined;
|
|
4203
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
4204
|
+
[x: `bytes31[${string}]`]: undefined;
|
|
4205
|
+
[x: `bytes10[${string}]`]: undefined;
|
|
4206
|
+
[x: `bytes9[${string}]`]: undefined;
|
|
4199
4207
|
[x: `bytes3[${string}]`]: undefined;
|
|
4200
4208
|
[x: `bytes4[${string}]`]: undefined;
|
|
4201
4209
|
[x: `bytes5[${string}]`]: undefined;
|
|
4202
4210
|
[x: `bytes6[${string}]`]: undefined;
|
|
4203
|
-
[x: `bytes7[${string}]`]: undefined;
|
|
4204
|
-
[x: `bytes8[${string}]`]: undefined;
|
|
4205
|
-
[x: `bytes9[${string}]`]: undefined;
|
|
4206
|
-
[x: `bytes10[${string}]`]: undefined;
|
|
4207
4211
|
[x: `bytes12[${string}]`]: undefined;
|
|
4208
4212
|
[x: `bytes13[${string}]`]: undefined;
|
|
4209
4213
|
[x: `bytes14[${string}]`]: undefined;
|
|
4210
4214
|
[x: `bytes15[${string}]`]: undefined;
|
|
4211
|
-
[x: `bytes16[${string}]`]: undefined;
|
|
4212
4215
|
[x: `bytes17[${string}]`]: undefined;
|
|
4213
4216
|
[x: `bytes18[${string}]`]: undefined;
|
|
4214
4217
|
[x: `bytes19[${string}]`]: undefined;
|
|
@@ -4216,31 +4219,28 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4216
4219
|
[x: `bytes21[${string}]`]: undefined;
|
|
4217
4220
|
[x: `bytes22[${string}]`]: undefined;
|
|
4218
4221
|
[x: `bytes23[${string}]`]: undefined;
|
|
4219
|
-
[x: `bytes24[${string}]`]: undefined;
|
|
4220
4222
|
[x: `bytes25[${string}]`]: undefined;
|
|
4221
4223
|
[x: `bytes26[${string}]`]: undefined;
|
|
4222
4224
|
[x: `bytes27[${string}]`]: undefined;
|
|
4223
4225
|
[x: `bytes28[${string}]`]: undefined;
|
|
4224
4226
|
[x: `bytes29[${string}]`]: undefined;
|
|
4225
4227
|
[x: `bytes30[${string}]`]: undefined;
|
|
4226
|
-
[x: `bytes31[${string}]`]: undefined;
|
|
4227
|
-
[x: `bytes32[${string}]`]: undefined;
|
|
4228
4228
|
[x: `int[${string}]`]: undefined;
|
|
4229
|
-
[x: `int8[${string}]`]: undefined;
|
|
4230
4229
|
[x: `int16[${string}]`]: undefined;
|
|
4231
|
-
[x: `int24[${string}]`]: undefined;
|
|
4232
4230
|
[x: `int32[${string}]`]: undefined;
|
|
4233
|
-
[x: `
|
|
4231
|
+
[x: `int64[${string}]`]: undefined;
|
|
4234
4232
|
[x: `int48[${string}]`]: undefined;
|
|
4233
|
+
[x: `int8[${string}]`]: undefined;
|
|
4234
|
+
[x: `int24[${string}]`]: undefined;
|
|
4235
|
+
[x: `int80[${string}]`]: undefined;
|
|
4236
|
+
[x: `int120[${string}]`]: undefined;
|
|
4237
|
+
[x: `int40[${string}]`]: undefined;
|
|
4235
4238
|
[x: `int56[${string}]`]: undefined;
|
|
4236
|
-
[x: `int64[${string}]`]: undefined;
|
|
4237
4239
|
[x: `int72[${string}]`]: undefined;
|
|
4238
|
-
[x: `int80[${string}]`]: undefined;
|
|
4239
4240
|
[x: `int88[${string}]`]: undefined;
|
|
4240
4241
|
[x: `int96[${string}]`]: undefined;
|
|
4241
4242
|
[x: `int104[${string}]`]: undefined;
|
|
4242
4243
|
[x: `int112[${string}]`]: undefined;
|
|
4243
|
-
[x: `int120[${string}]`]: undefined;
|
|
4244
4244
|
[x: `int128[${string}]`]: undefined;
|
|
4245
4245
|
[x: `int136[${string}]`]: undefined;
|
|
4246
4246
|
[x: `int144[${string}]`]: undefined;
|
|
@@ -4259,21 +4259,21 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4259
4259
|
[x: `int248[${string}]`]: undefined;
|
|
4260
4260
|
[x: `int256[${string}]`]: undefined;
|
|
4261
4261
|
[x: `uint[${string}]`]: undefined;
|
|
4262
|
-
[x: `uint8[${string}]`]: undefined;
|
|
4263
4262
|
[x: `uint16[${string}]`]: undefined;
|
|
4264
|
-
[x: `uint24[${string}]`]: undefined;
|
|
4265
4263
|
[x: `uint32[${string}]`]: undefined;
|
|
4266
|
-
[x: `
|
|
4264
|
+
[x: `uint64[${string}]`]: undefined;
|
|
4267
4265
|
[x: `uint48[${string}]`]: undefined;
|
|
4266
|
+
[x: `uint8[${string}]`]: undefined;
|
|
4267
|
+
[x: `uint24[${string}]`]: undefined;
|
|
4268
|
+
[x: `uint80[${string}]`]: undefined;
|
|
4269
|
+
[x: `uint120[${string}]`]: undefined;
|
|
4270
|
+
[x: `uint40[${string}]`]: undefined;
|
|
4268
4271
|
[x: `uint56[${string}]`]: undefined;
|
|
4269
|
-
[x: `uint64[${string}]`]: undefined;
|
|
4270
4272
|
[x: `uint72[${string}]`]: undefined;
|
|
4271
|
-
[x: `uint80[${string}]`]: undefined;
|
|
4272
4273
|
[x: `uint88[${string}]`]: undefined;
|
|
4273
4274
|
[x: `uint96[${string}]`]: undefined;
|
|
4274
4275
|
[x: `uint104[${string}]`]: undefined;
|
|
4275
4276
|
[x: `uint112[${string}]`]: undefined;
|
|
4276
|
-
[x: `uint120[${string}]`]: undefined;
|
|
4277
4277
|
[x: `uint128[${string}]`]: undefined;
|
|
4278
4278
|
[x: `uint136[${string}]`]: undefined;
|
|
4279
4279
|
[x: `uint144[${string}]`]: undefined;
|
|
@@ -4296,21 +4296,24 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4296
4296
|
bool?: undefined;
|
|
4297
4297
|
bytes?: undefined;
|
|
4298
4298
|
bytes11?: undefined;
|
|
4299
|
-
bytes1?: undefined;
|
|
4300
4299
|
bytes2?: undefined;
|
|
4300
|
+
bytes1?: undefined;
|
|
4301
|
+
bytes16?: undefined;
|
|
4302
|
+
bytes32?: undefined;
|
|
4303
|
+
bytes8?: undefined;
|
|
4304
|
+
bytes24?: undefined;
|
|
4305
|
+
bytes7?: undefined;
|
|
4306
|
+
bytes31?: undefined;
|
|
4307
|
+
bytes10?: undefined;
|
|
4308
|
+
bytes9?: undefined;
|
|
4301
4309
|
bytes3?: undefined;
|
|
4302
4310
|
bytes4?: undefined;
|
|
4303
4311
|
bytes5?: undefined;
|
|
4304
4312
|
bytes6?: undefined;
|
|
4305
|
-
bytes7?: undefined;
|
|
4306
|
-
bytes8?: undefined;
|
|
4307
|
-
bytes9?: undefined;
|
|
4308
|
-
bytes10?: undefined;
|
|
4309
4313
|
bytes12?: undefined;
|
|
4310
4314
|
bytes13?: undefined;
|
|
4311
4315
|
bytes14?: undefined;
|
|
4312
4316
|
bytes15?: undefined;
|
|
4313
|
-
bytes16?: undefined;
|
|
4314
4317
|
bytes17?: undefined;
|
|
4315
4318
|
bytes18?: undefined;
|
|
4316
4319
|
bytes19?: undefined;
|
|
@@ -4318,30 +4321,27 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4318
4321
|
bytes21?: undefined;
|
|
4319
4322
|
bytes22?: undefined;
|
|
4320
4323
|
bytes23?: undefined;
|
|
4321
|
-
bytes24?: undefined;
|
|
4322
4324
|
bytes25?: undefined;
|
|
4323
4325
|
bytes26?: undefined;
|
|
4324
4326
|
bytes27?: undefined;
|
|
4325
4327
|
bytes28?: undefined;
|
|
4326
4328
|
bytes29?: undefined;
|
|
4327
4329
|
bytes30?: undefined;
|
|
4328
|
-
bytes31?: undefined;
|
|
4329
|
-
bytes32?: undefined;
|
|
4330
|
-
int8?: undefined;
|
|
4331
4330
|
int16?: undefined;
|
|
4332
|
-
int24?: undefined;
|
|
4333
4331
|
int32?: undefined;
|
|
4334
|
-
|
|
4332
|
+
int64?: undefined;
|
|
4335
4333
|
int48?: undefined;
|
|
4334
|
+
int8?: undefined;
|
|
4335
|
+
int24?: undefined;
|
|
4336
|
+
int80?: undefined;
|
|
4337
|
+
int120?: undefined;
|
|
4338
|
+
int40?: undefined;
|
|
4336
4339
|
int56?: undefined;
|
|
4337
|
-
int64?: undefined;
|
|
4338
4340
|
int72?: undefined;
|
|
4339
|
-
int80?: undefined;
|
|
4340
4341
|
int88?: undefined;
|
|
4341
4342
|
int96?: undefined;
|
|
4342
4343
|
int104?: undefined;
|
|
4343
4344
|
int112?: undefined;
|
|
4344
|
-
int120?: undefined;
|
|
4345
4345
|
int128?: undefined;
|
|
4346
4346
|
int136?: undefined;
|
|
4347
4347
|
int144?: undefined;
|
|
@@ -4359,21 +4359,21 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4359
4359
|
int240?: undefined;
|
|
4360
4360
|
int248?: undefined;
|
|
4361
4361
|
int256?: undefined;
|
|
4362
|
-
uint8?: undefined;
|
|
4363
4362
|
uint16?: undefined;
|
|
4364
|
-
uint24?: undefined;
|
|
4365
4363
|
uint32?: undefined;
|
|
4366
|
-
|
|
4364
|
+
uint64?: undefined;
|
|
4367
4365
|
uint48?: undefined;
|
|
4366
|
+
uint8?: undefined;
|
|
4367
|
+
uint24?: undefined;
|
|
4368
|
+
uint80?: undefined;
|
|
4369
|
+
uint120?: undefined;
|
|
4370
|
+
uint40?: undefined;
|
|
4368
4371
|
uint56?: undefined;
|
|
4369
|
-
uint64?: undefined;
|
|
4370
4372
|
uint72?: undefined;
|
|
4371
|
-
uint80?: undefined;
|
|
4372
4373
|
uint88?: undefined;
|
|
4373
4374
|
uint96?: undefined;
|
|
4374
4375
|
uint104?: undefined;
|
|
4375
4376
|
uint112?: undefined;
|
|
4376
|
-
uint120?: undefined;
|
|
4377
4377
|
uint128?: undefined;
|
|
4378
4378
|
uint136?: undefined;
|
|
4379
4379
|
uint144?: undefined;
|
|
@@ -4442,12 +4442,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4442
4442
|
withdrawals?: import("viem").Withdrawal[] | undefined | undefined;
|
|
4443
4443
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
4444
4444
|
transactions: includeTransactions extends true ? ({
|
|
4445
|
+
value: bigint;
|
|
4445
4446
|
type: "legacy";
|
|
4446
4447
|
to: Address | null;
|
|
4447
4448
|
from: Address;
|
|
4448
4449
|
gas: bigint;
|
|
4449
4450
|
nonce: number;
|
|
4450
|
-
value: bigint;
|
|
4451
4451
|
blobVersionedHashes?: undefined | undefined;
|
|
4452
4452
|
gasPrice: bigint;
|
|
4453
4453
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4467,12 +4467,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4467
4467
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_1 ? T_1 extends (blockTag extends "pending" ? true : false) ? T_1 extends true ? null : `0x${string}` : never : never;
|
|
4468
4468
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_2 ? T_2 extends (blockTag extends "pending" ? true : false) ? T_2 extends true ? null : number : never : never;
|
|
4469
4469
|
} | {
|
|
4470
|
+
value: bigint;
|
|
4470
4471
|
type: "eip2930";
|
|
4471
4472
|
to: Address | null;
|
|
4472
4473
|
from: Address;
|
|
4473
4474
|
gas: bigint;
|
|
4474
4475
|
nonce: number;
|
|
4475
|
-
value: bigint;
|
|
4476
4476
|
blobVersionedHashes?: undefined | undefined;
|
|
4477
4477
|
gasPrice: bigint;
|
|
4478
4478
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4492,12 +4492,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4492
4492
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_4 ? T_4 extends (blockTag extends "pending" ? true : false) ? T_4 extends true ? null : `0x${string}` : never : never;
|
|
4493
4493
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_5 ? T_5 extends (blockTag extends "pending" ? true : false) ? T_5 extends true ? null : number : never : never;
|
|
4494
4494
|
} | {
|
|
4495
|
+
value: bigint;
|
|
4495
4496
|
type: "eip1559";
|
|
4496
4497
|
to: Address | null;
|
|
4497
4498
|
from: Address;
|
|
4498
4499
|
gas: bigint;
|
|
4499
4500
|
nonce: number;
|
|
4500
|
-
value: bigint;
|
|
4501
4501
|
blobVersionedHashes?: undefined | undefined;
|
|
4502
4502
|
gasPrice?: undefined | undefined;
|
|
4503
4503
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4517,12 +4517,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4517
4517
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_7 ? T_7 extends (blockTag extends "pending" ? true : false) ? T_7 extends true ? null : `0x${string}` : never : never;
|
|
4518
4518
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_8 ? T_8 extends (blockTag extends "pending" ? true : false) ? T_8 extends true ? null : number : never : never;
|
|
4519
4519
|
} | {
|
|
4520
|
+
value: bigint;
|
|
4520
4521
|
type: "eip4844";
|
|
4521
4522
|
to: Address | null;
|
|
4522
4523
|
from: Address;
|
|
4523
4524
|
gas: bigint;
|
|
4524
4525
|
nonce: number;
|
|
4525
|
-
value: bigint;
|
|
4526
4526
|
blobVersionedHashes: readonly import("viem").Hex[];
|
|
4527
4527
|
gasPrice?: undefined | undefined;
|
|
4528
4528
|
maxFeePerBlobGas: bigint;
|
|
@@ -4542,12 +4542,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4542
4542
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_10 ? T_10 extends (blockTag extends "pending" ? true : false) ? T_10 extends true ? null : `0x${string}` : never : never;
|
|
4543
4543
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_11 ? T_11 extends (blockTag extends "pending" ? true : false) ? T_11 extends true ? null : number : never : never;
|
|
4544
4544
|
} | {
|
|
4545
|
+
value: bigint;
|
|
4545
4546
|
type: "eip7702";
|
|
4546
4547
|
to: Address | null;
|
|
4547
4548
|
from: Address;
|
|
4548
4549
|
gas: bigint;
|
|
4549
4550
|
nonce: number;
|
|
4550
|
-
value: bigint;
|
|
4551
4551
|
blobVersionedHashes?: undefined | undefined;
|
|
4552
4552
|
gasPrice?: undefined | undefined;
|
|
4553
4553
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4593,12 +4593,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4593
4593
|
} | undefined) => Promise<import("viem").EstimateMaxPriorityFeePerGasReturnType>;
|
|
4594
4594
|
getStorageAt: (args: import("viem").GetStorageAtParameters) => Promise<import("viem").GetStorageAtReturnType>;
|
|
4595
4595
|
getTransaction: <blockTag extends import("viem").BlockTag = "latest">(args: import("viem").GetTransactionParameters<blockTag>) => Promise<{
|
|
4596
|
+
value: bigint;
|
|
4596
4597
|
type: "legacy";
|
|
4597
4598
|
to: Address | null;
|
|
4598
4599
|
from: Address;
|
|
4599
4600
|
gas: bigint;
|
|
4600
4601
|
nonce: number;
|
|
4601
|
-
value: bigint;
|
|
4602
4602
|
blobVersionedHashes?: undefined | undefined;
|
|
4603
4603
|
gasPrice: bigint;
|
|
4604
4604
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4618,12 +4618,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4618
4618
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_1 ? T_1 extends (blockTag extends "pending" ? true : false) ? T_1 extends true ? null : `0x${string}` : never : never;
|
|
4619
4619
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_2 ? T_2 extends (blockTag extends "pending" ? true : false) ? T_2 extends true ? null : number : never : never;
|
|
4620
4620
|
} | {
|
|
4621
|
+
value: bigint;
|
|
4621
4622
|
type: "eip2930";
|
|
4622
4623
|
to: Address | null;
|
|
4623
4624
|
from: Address;
|
|
4624
4625
|
gas: bigint;
|
|
4625
4626
|
nonce: number;
|
|
4626
|
-
value: bigint;
|
|
4627
4627
|
blobVersionedHashes?: undefined | undefined;
|
|
4628
4628
|
gasPrice: bigint;
|
|
4629
4629
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4643,12 +4643,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4643
4643
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_4 ? T_4 extends (blockTag extends "pending" ? true : false) ? T_4 extends true ? null : `0x${string}` : never : never;
|
|
4644
4644
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_5 ? T_5 extends (blockTag extends "pending" ? true : false) ? T_5 extends true ? null : number : never : never;
|
|
4645
4645
|
} | {
|
|
4646
|
+
value: bigint;
|
|
4646
4647
|
type: "eip1559";
|
|
4647
4648
|
to: Address | null;
|
|
4648
4649
|
from: Address;
|
|
4649
4650
|
gas: bigint;
|
|
4650
4651
|
nonce: number;
|
|
4651
|
-
value: bigint;
|
|
4652
4652
|
blobVersionedHashes?: undefined | undefined;
|
|
4653
4653
|
gasPrice?: undefined | undefined;
|
|
4654
4654
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -4668,12 +4668,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4668
4668
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_7 ? T_7 extends (blockTag extends "pending" ? true : false) ? T_7 extends true ? null : `0x${string}` : never : never;
|
|
4669
4669
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_8 ? T_8 extends (blockTag extends "pending" ? true : false) ? T_8 extends true ? null : number : never : never;
|
|
4670
4670
|
} | {
|
|
4671
|
+
value: bigint;
|
|
4671
4672
|
type: "eip4844";
|
|
4672
4673
|
to: Address | null;
|
|
4673
4674
|
from: Address;
|
|
4674
4675
|
gas: bigint;
|
|
4675
4676
|
nonce: number;
|
|
4676
|
-
value: bigint;
|
|
4677
4677
|
blobVersionedHashes: readonly import("viem").Hex[];
|
|
4678
4678
|
gasPrice?: undefined | undefined;
|
|
4679
4679
|
maxFeePerBlobGas: bigint;
|
|
@@ -4693,12 +4693,12 @@ export declare const createAnvilTestClient: (chain: Chain, rpcUrl: string) => im
|
|
|
4693
4693
|
blockHash: (blockTag extends "pending" ? true : false) extends infer T_10 ? T_10 extends (blockTag extends "pending" ? true : false) ? T_10 extends true ? null : `0x${string}` : never : never;
|
|
4694
4694
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_11 ? T_11 extends (blockTag extends "pending" ? true : false) ? T_11 extends true ? null : number : never : never;
|
|
4695
4695
|
} | {
|
|
4696
|
+
value: bigint;
|
|
4696
4697
|
type: "eip7702";
|
|
4697
4698
|
to: Address | null;
|
|
4698
4699
|
from: Address;
|
|
4699
4700
|
gas: bigint;
|
|
4700
4701
|
nonce: number;
|
|
4701
|
-
value: bigint;
|
|
4702
4702
|
blobVersionedHashes?: undefined | undefined;
|
|
4703
4703
|
gasPrice?: undefined | undefined;
|
|
4704
4704
|
maxFeePerBlobGas?: undefined | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, test, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import { jsonToRoleAssignment, stringToBigInt, } from '../../utils/arguments.js';
|
|
4
|
+
vi.mock('commander', () => ({ program: { error: vi.fn() } }));
|
|
5
|
+
let programError;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
programError = program.error;
|
|
8
|
+
vi.clearAllMocks();
|
|
9
|
+
});
|
|
10
|
+
describe('jsonToRoleAssignment structural validation (M3)', () => {
|
|
11
|
+
test('rejects non-array JSON', () => {
|
|
12
|
+
expect(() => jsonToRoleAssignment('{"account":"0x1","role":"0x2"}')).toThrow('must be an array');
|
|
13
|
+
});
|
|
14
|
+
test('rejects entries missing account field', () => {
|
|
15
|
+
expect(() => jsonToRoleAssignment('[{"role":"0x2"}]')).toThrow('must contain account and role fields');
|
|
16
|
+
});
|
|
17
|
+
test('rejects entries missing role field', () => {
|
|
18
|
+
expect(() => jsonToRoleAssignment('[{"account":"0x1"}]')).toThrow('must contain account and role fields');
|
|
19
|
+
});
|
|
20
|
+
test('rejects null entries', () => {
|
|
21
|
+
expect(() => jsonToRoleAssignment('[null]')).toThrow('must contain account and role fields');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('stringToBigInt safe parsing (M5)', () => {
|
|
25
|
+
test('calls program.error on invalid input', () => {
|
|
26
|
+
stringToBigInt('not-a-number');
|
|
27
|
+
expect(programError).toHaveBeenCalledWith(expect.stringContaining('Invalid BigInt value'), expect.objectContaining({ exitCode: 1 }));
|
|
28
|
+
});
|
|
29
|
+
test('calls program.error on float input', () => {
|
|
30
|
+
stringToBigInt('1.5');
|
|
31
|
+
expect(programError).toHaveBeenCalledWith(expect.stringContaining('Invalid BigInt value'), expect.objectContaining({ exitCode: 1 }));
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=arguments-security.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arguments-security.test.js","sourceRoot":"","sources":["../../../tests/utils/arguments-security.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAElC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAE9D,IAAI,YAAkB,CAAC;AAEvB,UAAU,CAAC,GAAG,EAAE;IACd,YAAY,GAAG,OAAO,CAAC,KAAwB,CAAC;IAChD,EAAE,CAAC,aAAa,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tB,MAAM,CAAC,YAAY,CAAC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,EAC/C,MAAM,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CACzC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { program } from 'commander';
|
|
6
|
-
import { stringToBigIntArray, stringToBigIntArrayWei, stringToHexArray,
|
|
6
|
+
import { stringToBigIntArray, stringToBigIntArrayWei, stringToHexArray, jsonToRoleAssignment, stringToBigInt, etherToWei, stringToNumber, parseDepositArray, stringToAddress, stringTo2dArray, stringToHex, jsonFileToPubkeys, stringToNumberArray, etherToWeiArray, stringToBoolean, parseDeposit, parseValidatorTopUpArray, stringToHash, } from '../../utils/arguments.js';
|
|
7
7
|
const MOCK_HEX_ARRAY = [
|
|
8
8
|
'82f3254f7bf057539113fc6b5971d80958618a9893eea717ab5ad345e083df7fceaf55f48716409d3df5adb4f38c4900',
|
|
9
9
|
'23f3254f7bf057539113fc6b5971d80958618a1234eea717ab5ad345e083df7fceaf55f48716409d3df5adb4f38c4900',
|
|
@@ -30,11 +30,6 @@ describe('arguments utils', () => {
|
|
|
30
30
|
expect(stringToHexArray(MOCK_HEX_ARRAY.join(','))).toEqual(MOCK_HEX_ARRAY.map((hex) => `0x${hex}`));
|
|
31
31
|
expect(stringToHexArray(MOCK_HEX_ARRAY.map((hex) => `0x${hex}`).join(','))).toEqual(MOCK_HEX_ARRAY.map((hex) => `0x${hex}`));
|
|
32
32
|
});
|
|
33
|
-
test('jsonToPermit', () => {
|
|
34
|
-
const permit = { value: '1', deadline: '2', v: 1, r: '0x1', s: '0x2' };
|
|
35
|
-
expect(jsonToPermit(JSON.stringify(permit))).toEqual(permit);
|
|
36
|
-
expect(() => jsonToPermit('{')).toThrow();
|
|
37
|
-
});
|
|
38
33
|
test('jsonToRoleAssignment', () => {
|
|
39
34
|
const roles = [{ account: '0x1', role: '0x2' }];
|
|
40
35
|
expect(jsonToRoleAssignment(JSON.stringify(roles))).toEqual(roles);
|
|
@@ -79,24 +74,11 @@ describe('arguments utils', () => {
|
|
|
79
74
|
test('stringToNumberArray', () => {
|
|
80
75
|
expect(stringToNumberArray('1,2,3')).toEqual([1, 2, 3]);
|
|
81
76
|
});
|
|
82
|
-
test('
|
|
83
|
-
expect(etherToGwei('1')).toBe(1000000000n);
|
|
77
|
+
test('etherToWeiArray', () => {
|
|
84
78
|
expect(etherToWeiArray('1,0.5')).toEqual([
|
|
85
79
|
1000000000000000000n,
|
|
86
80
|
500000000000000000n,
|
|
87
81
|
]);
|
|
88
|
-
expect(etherToGweiArray('1,2')).toEqual([1000000000n, 2000000000n]);
|
|
89
|
-
});
|
|
90
|
-
test('parseTiers and parseTier', () => {
|
|
91
|
-
const tier = {
|
|
92
|
-
shareLimit: '1',
|
|
93
|
-
reserveRatioBP: '2',
|
|
94
|
-
forcedRebalanceThresholdBP: '3',
|
|
95
|
-
treasuryFeeBP: '4',
|
|
96
|
-
};
|
|
97
|
-
expect(parseTiers(JSON.stringify([tier]))).toEqual([tier]);
|
|
98
|
-
expect(parseTier(JSON.stringify(tier))).toEqual(tier);
|
|
99
|
-
expect(() => parseTiers('[')).toThrow();
|
|
100
82
|
});
|
|
101
83
|
test('parseDepositArray', () => {
|
|
102
84
|
const arr = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arguments.test.js","sourceRoot":"","sources":["../../../tests/utils/arguments.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE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
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
vi.mock('fs/promises', () => ({
|
|
3
|
+
default: {
|
|
4
|
+
readFile: vi.fn(),
|
|
5
|
+
writeFile: vi.fn(),
|
|
6
|
+
mkdir: vi.fn(),
|
|
7
|
+
},
|
|
8
|
+
}));
|
|
9
|
+
vi.mock('../../utils/share-rate.js', () => ({
|
|
10
|
+
calculateShareRate: vi.fn(),
|
|
11
|
+
}));
|
|
12
|
+
vi.mock('../../utils/rebase-rewards.js', () => ({
|
|
13
|
+
calculateRebaseReward: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
vi.mock('../../utils/logging/index.js', () => ({
|
|
16
|
+
logInfo: vi.fn(),
|
|
17
|
+
}));
|
|
18
|
+
import fs from 'node:fs/promises';
|
|
19
|
+
import { cache } from '../../utils/cache.js';
|
|
20
|
+
const mockReadFile = fs.readFile;
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
vi.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
describe('safeJsonParse prototype pollution prevention (M8)', () => {
|
|
25
|
+
it('should strip __proto__ keys from cached JSON', async () => {
|
|
26
|
+
const malicious = '{"100": "999", "__proto__": {"polluted": true}}';
|
|
27
|
+
mockReadFile.mockResolvedValue(malicious);
|
|
28
|
+
const result = await cache.getShareRate(100);
|
|
29
|
+
expect(result).toBe(999n);
|
|
30
|
+
const obj = {};
|
|
31
|
+
expect(obj.polluted).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
it('should strip constructor keys from cached JSON', async () => {
|
|
34
|
+
const malicious = '{"100": "999", "constructor": {"prototype": {"injected": true}}}';
|
|
35
|
+
mockReadFile.mockResolvedValue(malicious);
|
|
36
|
+
const result = await cache.getShareRate(100);
|
|
37
|
+
expect(result).toBe(999n);
|
|
38
|
+
const obj = {};
|
|
39
|
+
expect(obj.injected).toBeUndefined();
|
|
40
|
+
});
|
|
41
|
+
it('should strip prototype keys from cached JSON', async () => {
|
|
42
|
+
const malicious = '{"100": "999", "prototype": {"leaked": true}}';
|
|
43
|
+
mockReadFile.mockResolvedValue(malicious);
|
|
44
|
+
const result = await cache.getShareRate(100);
|
|
45
|
+
expect(result).toBe(999n);
|
|
46
|
+
});
|
|
47
|
+
it('should strip nested __proto__ keys', async () => {
|
|
48
|
+
const malicious = '{"100": {"transfer": [], "minted": [], "burned": [], "__proto__": {"bad": true}}}';
|
|
49
|
+
mockReadFile.mockResolvedValue(malicious);
|
|
50
|
+
const result = await cache.getIndexedEventsByBlock('0xpool', 100n);
|
|
51
|
+
expect(result).toBeDefined();
|
|
52
|
+
expect(result).toHaveProperty('transfer');
|
|
53
|
+
const obj = {};
|
|
54
|
+
expect(obj.bad).toBeUndefined();
|
|
55
|
+
});
|
|
56
|
+
it('should handle normal JSON without dangerous keys', async () => {
|
|
57
|
+
mockReadFile.mockResolvedValue(JSON.stringify({ 100: '500' }));
|
|
58
|
+
const result = await cache.getShareRate(100);
|
|
59
|
+
expect(result).toBe(500n);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=cache-security.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-security.test.js","sourceRoot":"","sources":["../../../tests/utils/cache-security.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAa,MAAM,QAAQ,CAAC;AAEzE,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;QACjB,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;QAClB,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;KACf;CACF,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CA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