@cfxjs/sirius-next-common 0.4.0 → 0.5.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/chunk-6A3FV7ST.js +106 -0
- package/dist/chunk-6A3FV7ST.js.map +1 -0
- package/dist/{chunk-6XQWKKL5.js → chunk-B7IDVT2B.js} +2 -2
- package/dist/{chunk-GGLZLKNJ.js → chunk-H26P76N6.js} +2 -2
- package/dist/{chunk-ZUO2WVSN.js → chunk-HTRUONHE.js} +2 -2
- package/dist/{chunk-EIDH56XO.js → chunk-IVE75CAC.js} +3 -3
- package/dist/{chunk-YL3I4UMA.js → chunk-OGZSZDXL.js} +2 -2
- package/dist/{chunk-RX44WEW6.js → chunk-QBF7EJFY.js} +2 -2
- package/dist/{chunk-OVGNIKRY.js → chunk-SBFEY7I7.js} +74 -4
- package/dist/{chunk-OVGNIKRY.js.map → chunk-SBFEY7I7.js.map} +1 -1
- package/dist/components/AAFailedReason/index.js +3 -2
- package/dist/components/AAFailedReason/index.js.map +1 -1
- package/dist/components/OutputData/ErrorDecode.js +4 -3
- package/dist/components/OutputData/index.js +5 -4
- package/dist/components/TransactionTrace/TraceDetail.js +7 -6
- package/dist/components/TransactionTrace/TreeTraceTable.js +8 -7
- package/dist/components/TransactionTrace/index.js +8 -7
- package/dist/utils/hooks/useDecodeFunctionData.js +3 -2
- package/dist/utils/hooks/useDecodeFunctionError.js +3 -2
- package/dist/utils/hooks/useSimulateTrace.d.ts +3 -1
- package/dist/utils/hooks/useSimulateTrace.js +26 -6
- package/dist/utils/hooks/useSimulateTrace.js.map +1 -1
- package/dist/utils/sdk.d.ts +29 -8
- package/dist/utils/sdk.js +2 -1
- package/dist/utils/transactionLists.d.ts +28 -0
- package/dist/utils/transactionLists.js +14 -0
- package/dist/utils/transactionLists.js.map +1 -0
- package/package.json +2 -2
- /package/dist/{chunk-6XQWKKL5.js.map → chunk-B7IDVT2B.js.map} +0 -0
- /package/dist/{chunk-GGLZLKNJ.js.map → chunk-H26P76N6.js.map} +0 -0
- /package/dist/{chunk-ZUO2WVSN.js.map → chunk-HTRUONHE.js.map} +0 -0
- /package/dist/{chunk-EIDH56XO.js.map → chunk-IVE75CAC.js.map} +0 -0
- /package/dist/{chunk-YL3I4UMA.js.map → chunk-OGZSZDXL.js.map} +0 -0
- /package/dist/{chunk-RX44WEW6.js.map → chunk-QBF7EJFY.js.map} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useDecodeFunctionError
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-B7IDVT2B.js";
|
|
4
|
+
import "../../chunk-SBFEY7I7.js";
|
|
5
|
+
import "../../chunk-6A3FV7ST.js";
|
|
5
6
|
import "../../chunk-2WY3J56A.js";
|
|
6
7
|
import "../../chunk-XIQH26WA.js";
|
|
7
8
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/AAFailedReason/index.tsx"],"sourcesContent":["import { useDecodeFunctionError } from 'src/utils/hooks/useDecodeFunctionError';\n\ninterface Props {\n data?: string;\n fallback?: React.ReactNode;\n}\n\nexport const AAFailedReason = function ({ data, fallback }: Props) {\n const isHexData = data?.startsWith('0x');\n const [decodedError, isLoading] = useDecodeFunctionError({\n errorData: isHexData ? (data as `0x${string}`) : undefined,\n space: 'evm',\n supportErrorAbi: true,\n });\n if (!isHexData) return data;\n if (\n isLoading ||\n !decodedError ||\n !decodedError.abiItem ||\n decodedError.failed ||\n decodedError.noAbi ||\n decodedError.abiItem.type !== 'error'\n ) {\n return fallback;\n }\n return decodedError.errorName;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/AAFailedReason/index.tsx"],"sourcesContent":["import { useDecodeFunctionError } from 'src/utils/hooks/useDecodeFunctionError';\n\ninterface Props {\n data?: string;\n fallback?: React.ReactNode;\n}\n\nexport const AAFailedReason = function ({ data, fallback }: Props) {\n const isHexData = data?.startsWith('0x');\n const [decodedError, isLoading] = useDecodeFunctionError({\n errorData: isHexData ? (data as `0x${string}`) : undefined,\n space: 'evm',\n supportErrorAbi: true,\n });\n if (!isHexData) return data;\n if (\n isLoading ||\n !decodedError ||\n !decodedError.abiItem ||\n decodedError.failed ||\n decodedError.noAbi ||\n decodedError.abiItem.type !== 'error'\n ) {\n return fallback;\n }\n return decodedError.errorName;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAOO,IAAM,iBAAiB,SAAU,EAAE,MAAM,SAAS,GAAU;AACjE,QAAM,YAAY,MAAM,WAAW,IAAI;AACvC,QAAM,CAAC,cAAc,SAAS,IAAI,uBAAuB;AAAA,IACvD,WAAW,YAAa,OAAyB;AAAA,IACjD,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB,CAAC;AACD,MAAI,CAAC;AAAW,WAAO;AACvB,MACE,aACA,CAAC,gBACD,CAAC,aAAa,WACd,aAAa,UACb,aAAa,SACb,aAAa,QAAQ,SAAS,SAC9B;AACA,WAAO;AAAA,EACT;AACA,SAAO,aAAa;AACtB;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ErrorDecode
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-H26P76N6.js";
|
|
4
4
|
import "../../chunk-XGSBVC7P.js";
|
|
5
5
|
import "../../chunk-GPHUCEN2.js";
|
|
6
6
|
import "../../chunk-B74PZXOZ.js";
|
|
@@ -12,8 +12,9 @@ import "../../chunk-GZMSESHY.js";
|
|
|
12
12
|
import "../../chunk-XI5WO2NW.js";
|
|
13
13
|
import "../../chunk-TPUZ46LY.js";
|
|
14
14
|
import "../../chunk-X35GBAUQ.js";
|
|
15
|
-
import "../../chunk-
|
|
16
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-B7IDVT2B.js";
|
|
16
|
+
import "../../chunk-SBFEY7I7.js";
|
|
17
|
+
import "../../chunk-6A3FV7ST.js";
|
|
17
18
|
import "../../chunk-2WY3J56A.js";
|
|
18
19
|
import "../../chunk-XIQH26WA.js";
|
|
19
20
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OutputData
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-QBF7EJFY.js";
|
|
4
|
+
import "../../chunk-H26P76N6.js";
|
|
5
5
|
import "../../chunk-XGSBVC7P.js";
|
|
6
6
|
import "../../chunk-4MVQ3JTN.js";
|
|
7
7
|
import "../../chunk-GPHUCEN2.js";
|
|
@@ -15,8 +15,9 @@ import "../../chunk-GZMSESHY.js";
|
|
|
15
15
|
import "../../chunk-XI5WO2NW.js";
|
|
16
16
|
import "../../chunk-TPUZ46LY.js";
|
|
17
17
|
import "../../chunk-X35GBAUQ.js";
|
|
18
|
-
import "../../chunk-
|
|
19
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-B7IDVT2B.js";
|
|
19
|
+
import "../../chunk-SBFEY7I7.js";
|
|
20
|
+
import "../../chunk-6A3FV7ST.js";
|
|
20
21
|
import "../../chunk-2WY3J56A.js";
|
|
21
22
|
import "../../chunk-XIQH26WA.js";
|
|
22
23
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TraceDetail
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-IVE75CAC.js";
|
|
4
|
+
import "../../chunk-OGZSZDXL.js";
|
|
5
5
|
import "../../chunk-7FIPVSHQ.js";
|
|
6
6
|
import "../../chunk-UM5J477V.js";
|
|
7
7
|
import "../../chunk-XJPWKT2J.js";
|
|
8
8
|
import "../../chunk-TAEXZ5LI.js";
|
|
9
9
|
import "../../chunk-NWVSTRCG.js";
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-QBF7EJFY.js";
|
|
11
|
+
import "../../chunk-H26P76N6.js";
|
|
12
12
|
import "../../chunk-TIWELXT7.js";
|
|
13
13
|
import "../../chunk-XGSBVC7P.js";
|
|
14
14
|
import "../../chunk-4MVQ3JTN.js";
|
|
@@ -26,8 +26,9 @@ import "../../chunk-O6NJ56NA.js";
|
|
|
26
26
|
import "../../chunk-XCKMXAL2.js";
|
|
27
27
|
import "../../chunk-TPUZ46LY.js";
|
|
28
28
|
import "../../chunk-X35GBAUQ.js";
|
|
29
|
-
import "../../chunk-
|
|
30
|
-
import "../../chunk-
|
|
29
|
+
import "../../chunk-B7IDVT2B.js";
|
|
30
|
+
import "../../chunk-SBFEY7I7.js";
|
|
31
|
+
import "../../chunk-6A3FV7ST.js";
|
|
31
32
|
import "../../chunk-2WY3J56A.js";
|
|
32
33
|
import "../../chunk-XIQH26WA.js";
|
|
33
34
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TreeTraceTable
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-HTRUONHE.js";
|
|
4
|
+
import "../../chunk-IVE75CAC.js";
|
|
5
|
+
import "../../chunk-OGZSZDXL.js";
|
|
6
6
|
import "../../chunk-7FIPVSHQ.js";
|
|
7
7
|
import "../../chunk-UM5J477V.js";
|
|
8
8
|
import "../../chunk-4WLXG7ZY.js";
|
|
9
9
|
import "../../chunk-XJPWKT2J.js";
|
|
10
10
|
import "../../chunk-TAEXZ5LI.js";
|
|
11
11
|
import "../../chunk-NWVSTRCG.js";
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-QBF7EJFY.js";
|
|
13
|
+
import "../../chunk-H26P76N6.js";
|
|
14
14
|
import "../../chunk-TIWELXT7.js";
|
|
15
15
|
import "../../chunk-XGSBVC7P.js";
|
|
16
16
|
import "../../chunk-4MVQ3JTN.js";
|
|
@@ -29,8 +29,9 @@ import "../../chunk-O6NJ56NA.js";
|
|
|
29
29
|
import "../../chunk-XCKMXAL2.js";
|
|
30
30
|
import "../../chunk-TPUZ46LY.js";
|
|
31
31
|
import "../../chunk-X35GBAUQ.js";
|
|
32
|
-
import "../../chunk-
|
|
33
|
-
import "../../chunk-
|
|
32
|
+
import "../../chunk-B7IDVT2B.js";
|
|
33
|
+
import "../../chunk-SBFEY7I7.js";
|
|
34
|
+
import "../../chunk-6A3FV7ST.js";
|
|
34
35
|
import "../../chunk-2WY3J56A.js";
|
|
35
36
|
import "../../chunk-XIQH26WA.js";
|
|
36
37
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TreeTraceTable
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-HTRUONHE.js";
|
|
4
4
|
import {
|
|
5
5
|
TraceDetail
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-IVE75CAC.js";
|
|
7
|
+
import "../../chunk-OGZSZDXL.js";
|
|
8
8
|
import "../../chunk-7FIPVSHQ.js";
|
|
9
9
|
import "../../chunk-UM5J477V.js";
|
|
10
10
|
import "../../chunk-4WLXG7ZY.js";
|
|
11
11
|
import "../../chunk-XJPWKT2J.js";
|
|
12
12
|
import "../../chunk-TAEXZ5LI.js";
|
|
13
13
|
import "../../chunk-NWVSTRCG.js";
|
|
14
|
-
import "../../chunk-
|
|
15
|
-
import "../../chunk-
|
|
14
|
+
import "../../chunk-QBF7EJFY.js";
|
|
15
|
+
import "../../chunk-H26P76N6.js";
|
|
16
16
|
import "../../chunk-TIWELXT7.js";
|
|
17
17
|
import "../../chunk-XGSBVC7P.js";
|
|
18
18
|
import "../../chunk-4MVQ3JTN.js";
|
|
@@ -31,8 +31,9 @@ import "../../chunk-O6NJ56NA.js";
|
|
|
31
31
|
import "../../chunk-XCKMXAL2.js";
|
|
32
32
|
import "../../chunk-TPUZ46LY.js";
|
|
33
33
|
import "../../chunk-X35GBAUQ.js";
|
|
34
|
-
import "../../chunk-
|
|
35
|
-
import "../../chunk-
|
|
34
|
+
import "../../chunk-B7IDVT2B.js";
|
|
35
|
+
import "../../chunk-SBFEY7I7.js";
|
|
36
|
+
import "../../chunk-6A3FV7ST.js";
|
|
36
37
|
import "../../chunk-2WY3J56A.js";
|
|
37
38
|
import "../../chunk-XIQH26WA.js";
|
|
38
39
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useDecodeFunctionData
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-OGZSZDXL.js";
|
|
4
4
|
import "../../chunk-7FIPVSHQ.js";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-SBFEY7I7.js";
|
|
6
|
+
import "../../chunk-6A3FV7ST.js";
|
|
6
7
|
import "../../chunk-2WY3J56A.js";
|
|
7
8
|
import "../../chunk-2ZR25NMU.js";
|
|
8
9
|
import "../../chunk-CGDNDBBP.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useDecodeFunctionError
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-B7IDVT2B.js";
|
|
4
|
+
import "../../chunk-SBFEY7I7.js";
|
|
5
|
+
import "../../chunk-6A3FV7ST.js";
|
|
5
6
|
import "../../chunk-2WY3J56A.js";
|
|
6
7
|
import "../../chunk-XIQH26WA.js";
|
|
7
8
|
import "../../chunk-2ZR25NMU.js";
|
|
@@ -2,6 +2,7 @@ import * as swr from 'swr';
|
|
|
2
2
|
import { ProxyType, TreeTraceForUI } from './useTxTrace.js';
|
|
3
3
|
import { AddressNameMap } from '../request.types.js';
|
|
4
4
|
import { Hex, Space } from '../types.js';
|
|
5
|
+
import { TransactionLists } from '../transactionLists.js';
|
|
5
6
|
import '../sdk.js';
|
|
6
7
|
import 'viem';
|
|
7
8
|
import 'cive/accounts';
|
|
@@ -36,7 +37,7 @@ interface SimulateTraceResponse {
|
|
|
36
37
|
methodMap?: Record<string, Record<string, string>>;
|
|
37
38
|
nameMap?: Record<string, AddressNameMap>;
|
|
38
39
|
}
|
|
39
|
-
interface SimulateTraceTxParams {
|
|
40
|
+
interface SimulateTraceTxParams extends TransactionLists {
|
|
40
41
|
from: Hex;
|
|
41
42
|
to?: Hex;
|
|
42
43
|
value?: string;
|
|
@@ -44,6 +45,7 @@ interface SimulateTraceTxParams {
|
|
|
44
45
|
gas?: string;
|
|
45
46
|
gasPrice?: string;
|
|
46
47
|
maxFeePerGas?: string;
|
|
48
|
+
maxPriorityFeePerGas?: string;
|
|
47
49
|
space: Exclude<Space, 'core'>;
|
|
48
50
|
}
|
|
49
51
|
interface SimulateTraceConfig {
|
|
@@ -5,7 +5,10 @@ import {
|
|
|
5
5
|
} from "../../chunk-36EB4LRH.js";
|
|
6
6
|
import {
|
|
7
7
|
estimateGas
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-SBFEY7I7.js";
|
|
9
|
+
import {
|
|
10
|
+
normalizeTransactionLists
|
|
11
|
+
} from "../../chunk-6A3FV7ST.js";
|
|
9
12
|
import "../../chunk-2ZR25NMU.js";
|
|
10
13
|
import "../../chunk-CGDNDBBP.js";
|
|
11
14
|
import "../../chunk-S6O6Q2GQ.js";
|
|
@@ -126,7 +129,21 @@ var querySimulateTrace = async (tx, tag = "latest", params = {
|
|
|
126
129
|
}
|
|
127
130
|
}) => {
|
|
128
131
|
const url = `/traceCallView`;
|
|
129
|
-
const { space, ...
|
|
132
|
+
const { space, ...rawTx } = tx;
|
|
133
|
+
if (space !== "evm") {
|
|
134
|
+
throw new Error("Simulate trace only supports EVM Space");
|
|
135
|
+
}
|
|
136
|
+
const simulateTx = { ...rawTx, ...normalizeTransactionLists(rawTx) };
|
|
137
|
+
if (!simulateTx.maxFeePerGas && !simulateTx.gasPrice) {
|
|
138
|
+
let feeCap = 22000000000n;
|
|
139
|
+
if (simulateTx.maxPriorityFeePerGas !== void 0) {
|
|
140
|
+
const priorityFee = BigInt(simulateTx.maxPriorityFeePerGas);
|
|
141
|
+
if (priorityFee > feeCap) {
|
|
142
|
+
feeCap = priorityFee;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
simulateTx.maxFeePerGas = `0x${feeCap.toString(16)}`;
|
|
146
|
+
}
|
|
130
147
|
if (!simulateTx.gas) {
|
|
131
148
|
try {
|
|
132
149
|
const gasLimit = await estimateGas({
|
|
@@ -134,16 +151,19 @@ var querySimulateTrace = async (tx, tag = "latest", params = {
|
|
|
134
151
|
to: simulateTx.to,
|
|
135
152
|
value: simulateTx.value,
|
|
136
153
|
data: simulateTx.data,
|
|
137
|
-
space
|
|
154
|
+
space,
|
|
155
|
+
accessList: simulateTx.accessList,
|
|
156
|
+
authorizationList: simulateTx.authorizationList,
|
|
157
|
+
gasPrice: simulateTx.gasPrice,
|
|
158
|
+
maxFeePerGas: simulateTx.maxFeePerGas,
|
|
159
|
+
maxPriorityFeePerGas: simulateTx.maxPriorityFeePerGas,
|
|
160
|
+
tag
|
|
138
161
|
});
|
|
139
162
|
simulateTx.gas = `0x${gasLimit.toString(16)}`;
|
|
140
163
|
} catch (error) {
|
|
141
164
|
console.log("estimate gas failed:", error);
|
|
142
165
|
}
|
|
143
166
|
}
|
|
144
|
-
if (!simulateTx.maxFeePerGas && !simulateTx.gasPrice) {
|
|
145
|
-
simulateTx.maxFeePerGas = "0x51f4d5c00";
|
|
146
|
-
}
|
|
147
167
|
const data = JSON.stringify({
|
|
148
168
|
id: generateRandomId(),
|
|
149
169
|
jsonrpc: "2.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/hooks/useSimulateTrace.ts"],"sourcesContent":["import useSWRImmutable from 'swr/immutable';\nimport { fetchWithPrefix } from '../request';\nimport { formatABI, generateRandomId } from '..';\nimport {\n isCreateCall,\n isDelegateCall,\n isStaticCall,\n ProxyType,\n TreeTraceForUI,\n} from './useTxTrace';\nimport { AddressNameMap } from '../request.types';\nimport { AbiFunctionWithoutGas, estimateGas } from '../sdk';\nimport { formatAddress } from '../address';\nimport BigNumber from 'bignumber.js';\nimport { Hex, Space } from '../types';\n\nexport interface SimulateLog {\n address: string;\n topics: string[];\n data: string;\n transactionLogIndex?: number;\n}\n\ntype BlockTag = 'latest' | 'safe' | 'finalized' | 'earliest' | 'pending' | Hex;\n\ninterface SimulateTraceCall {\n from: string;\n to: string;\n gas: string;\n gasUsed: string;\n input: `0x${string}`;\n output?: `0x${string}`;\n value: string;\n type: string;\n error?: string;\n calls?: SimulateTraceCall[];\n isCallImpl?: boolean;\n logs?: SimulateLog[];\n}\n\nexport interface SimulateTraceResponse {\n traceCall: SimulateTraceCall;\n addressArray: string[];\n authMap?: Record<string, string>;\n proxyMap?: Record<string, ProxyType>;\n methodMap?: Record<string, Record<string, string>>;\n nameMap?: Record<string, AddressNameMap>;\n}\n\nexport interface SimulateTraceTxParams {\n from: Hex;\n to?: Hex;\n value?: string;\n data?: Hex;\n gas?: string;\n gasPrice?: string;\n maxFeePerGas?: string;\n // simulate trace not support core space now\n space: Exclude<Space, 'core'>;\n}\n\nexport interface SimulateTraceConfig {\n // other tracer has different response, not support now\n // | '4byteTracer'\n // | 'prestateTracer'\n // | 'flatCallTracer'\n // | 'muxTracer'\n // | 'erc7562Tracer';\n tracer: 'callTracer';\n tracerConfig?: {\n disableStorage?: boolean;\n disableStack?: boolean;\n enableMemory?: boolean;\n enableReturnData?: boolean;\n onlyTopCall?: boolean;\n withLog?: boolean;\n timeout?: number;\n };\n}\n\nconst formatSimulateTraceData = (\n data: SimulateTraceResponse,\n space: 'evm' | 'core',\n) => {\n const addressType = space === 'core' ? 'base32' : 'hex';\n const proxyMap = data.proxyMap || {};\n const methodMap = data.methodMap || {};\n const nameMap = data.nameMap || {};\n const authMap = data.authMap || {};\n\n let total = 0;\n const logs: SimulateLog[] = [];\n\n const formatList = (\n t: SimulateTraceCall[],\n parent?: TreeTraceForUI,\n ): TreeTraceForUI[] => {\n total += t.length;\n return t.map((item, index) => formatItem(item, index, parent, t));\n };\n const formatItem = (\n t: SimulateTraceCall,\n index: number,\n parent: TreeTraceForUI | undefined,\n list: SimulateTraceCall[],\n ): TreeTraceForUI => {\n if (t.logs) {\n logs.push(...t.logs);\n }\n const type = t.type?.toLowerCase();\n const isContractCreated = isCreateCall(type);\n const methodId = t.input?.slice(0, 10);\n const from = formatAddress(t.from, addressType);\n const to = !isContractCreated\n ? formatAddress(t.to, addressType)\n : undefined;\n const delegatedTo = to && authMap[to];\n let method = methodId;\n let abi: AbiFunctionWithoutGas[] | undefined = undefined;\n const methodABI =\n methodId && (delegatedTo || to)\n ? methodMap[methodId]?.[delegatedTo || to]\n : undefined;\n if (methodABI) {\n try {\n const result = formatABI(`[\"${methodABI}\"]`, {\n json: true,\n allowEmpty: true,\n });\n abi = JSON.parse(result) as AbiFunctionWithoutGas[];\n const jsonABI = abi[0];\n method = jsonABI?.name || methodId;\n } catch (error) {\n console.log('parse method abi error: ', methodABI, error);\n }\n }\n\n const item: TreeTraceForUI = {\n index: `${parent?.index ? `${parent.index}_` : ''}${index}`,\n type: type,\n from: from,\n to: to,\n input: t.input,\n value: t.value,\n gas: t.gas ? new BigNumber(t.gas).toString() : undefined,\n gasUsed: t.gasUsed ? new BigNumber(t.gasUsed).toString() : undefined,\n output: t.output,\n outcome: !t.error\n ? 'success'\n : t.error === 'Reverted'\n ? 'reverted'\n : 'fail',\n method,\n abi,\n contractCreated: isContractCreated ? t.to : undefined,\n nameMap,\n delegatedTo,\n isCallImpl: t.isCallImpl,\n };\n if (\n parent &&\n parent.to &&\n proxyMap[parent.to] &&\n from === parent.to &&\n to\n ) {\n // proxy call\n if (\n index === 0 &&\n proxyMap[parent.to] === 'Proxy' &&\n isDelegateCall(type)\n ) {\n parent.proxy = {\n type: 'Proxy',\n implAddress: to,\n };\n item.isCallImpl = true;\n }\n // beacon proxy call\n const second = list[1];\n if (\n index === 0 &&\n proxyMap[parent.to] === 'BeaconProxy' &&\n isStaticCall(type) &&\n second &&\n second.to &&\n second.from === parent.to &&\n isDelegateCall(second.type)\n ) {\n parent.proxy = {\n type: 'BeaconProxy',\n beaconAddress: to,\n implAddress: second.to,\n };\n item.isCallBeacon = true;\n second.isCallImpl = true;\n }\n }\n if (t.calls) {\n item.calls = formatList(t.calls, item);\n }\n return item;\n };\n const list = formatList([data.traceCall]);\n return {\n total,\n list,\n // TODO: use real log index, and sort\n logs: logs.map((item, index) => ({ ...item, transactionLogIndex: index })),\n };\n};\nexport const querySimulateTrace = async (\n tx: SimulateTraceTxParams,\n tag: BlockTag = 'latest',\n params: SimulateTraceConfig = {\n tracer: 'callTracer',\n tracerConfig: {\n onlyTopCall: false,\n },\n },\n) => {\n const url = `/traceCallView`;\n\n const { space, ...simulateTx } = tx;\n\n if (!simulateTx.gas) {\n try {\n const gasLimit = await estimateGas({\n account: simulateTx.from,\n to: simulateTx.to,\n value: simulateTx.value,\n data: simulateTx.data as `0x${string}`,\n space,\n });\n simulateTx.gas = `0x${gasLimit.toString(16)}`;\n } catch (error) {\n console.log('estimate gas failed:', error);\n }\n }\n if (!simulateTx.maxFeePerGas && !simulateTx.gasPrice) {\n simulateTx.maxFeePerGas = '0x51f4d5c00'; // 22 Gdrip\n }\n\n const data = JSON.stringify({\n id: generateRandomId(),\n jsonrpc: '2.0',\n method: 'debug_traceCall',\n params: [simulateTx, tag, params],\n });\n return fetchWithPrefix<SimulateTraceResponse>(url, {\n method: 'POST',\n body: data,\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n\nexport const useSimulateTrace = ({\n tx,\n tag = 'latest',\n params = {\n tracer: 'callTracer',\n tracerConfig: {\n onlyTopCall: false,\n withLog: true,\n },\n },\n disabled = false,\n}: {\n tx?: SimulateTraceTxParams;\n tag?: BlockTag;\n params?: SimulateTraceConfig;\n disabled?: boolean;\n}) => {\n let key = null;\n if (!disabled && tx) {\n key = JSON.stringify([tx, tag, params]);\n }\n\n return useSWRImmutable(\n key,\n () =>\n tx &&\n querySimulateTrace(tx, tag, params).then(resp => {\n if (resp?.traceCall) {\n return formatSimulateTraceData(resp, tx.space);\n }\n }),\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,qBAAqB;AAa5B,OAAO,eAAe;AAmEtB,IAAM,0BAA0B,CAC9B,MACA,UACG;AACH,QAAM,cAAc,UAAU,SAAS,WAAW;AAClD,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,YAAY,KAAK,aAAa,CAAC;AACrC,QAAM,UAAU,KAAK,WAAW,CAAC;AACjC,QAAM,UAAU,KAAK,WAAW,CAAC;AAEjC,MAAI,QAAQ;AACZ,QAAM,OAAsB,CAAC;AAE7B,QAAM,aAAa,CACjB,GACA,WACqB;AACrB,aAAS,EAAE;AACX,WAAO,EAAE,IAAI,CAAC,MAAM,UAAU,WAAW,MAAM,OAAO,QAAQ,CAAC,CAAC;AAAA,EAClE;AACA,QAAM,aAAa,CACjB,GACA,OACA,QACAA,UACmB;AACnB,QAAI,EAAE,MAAM;AACV,WAAK,KAAK,GAAG,EAAE,IAAI;AAAA,IACrB;AACA,UAAM,OAAO,EAAE,MAAM,YAAY;AACjC,UAAM,oBAAoB,aAAa,IAAI;AAC3C,UAAM,WAAW,EAAE,OAAO,MAAM,GAAG,EAAE;AACrC,UAAM,OAAO,cAAc,EAAE,MAAM,WAAW;AAC9C,UAAM,KAAK,CAAC,oBACR,cAAc,EAAE,IAAI,WAAW,IAC/B;AACJ,UAAM,cAAc,MAAM,QAAQ,EAAE;AACpC,QAAI,SAAS;AACb,QAAI,MAA2C;AAC/C,UAAM,YACJ,aAAa,eAAe,MACxB,UAAU,QAAQ,IAAI,eAAe,E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AS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,EACF,CAAC;AACH;AAEO,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,cAAc;AAAA,MACZ,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,WAAW;AACb,MAKM;AACJ,MAAI,MAAM;AACV,MAAI,CAAC,YAAY,IAAI;AACnB,UAAM,KAAK,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC;AAAA,EACxC;AAEA,SAAO;AAAA,IACL;AAAA,IACA,MACE,MACA,mBAAmB,IAAI,KAAK,MAAM,EAAE,KAAK,UAAQ;AAC/C,UAAI,MAAM,WAAW;AACnB,eAAO,wBAAwB,MAAM,GAAG,KAAK;AAAA,MAC/C;AAAA,IACF,CAAC;AAAA,EACL;AACF;","names":["list"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/hooks/useSimulateTrace.ts"],"sourcesContent":["import useSWRImmutable from 'swr/immutable';\nimport { fetchWithPrefix } from '../request';\nimport { formatABI, generateRandomId } from '..';\nimport {\n isCreateCall,\n isDelegateCall,\n isStaticCall,\n ProxyType,\n TreeTraceForUI,\n} from './useTxTrace';\nimport { AddressNameMap } from '../request.types';\nimport { AbiFunctionWithoutGas, estimateGas } from '../sdk';\nimport { formatAddress } from '../address';\nimport BigNumber from 'bignumber.js';\nimport { Hex, Space } from '../types';\nimport {\n normalizeTransactionLists,\n type TransactionLists,\n} from '../transactionLists';\n\nexport interface SimulateLog {\n address: string;\n topics: string[];\n data: string;\n transactionLogIndex?: number;\n}\n\ntype BlockTag = 'latest' | 'safe' | 'finalized' | 'earliest' | 'pending' | Hex;\n\ninterface SimulateTraceCall {\n from: string;\n to: string;\n gas: string;\n gasUsed: string;\n input: `0x${string}`;\n output?: `0x${string}`;\n value: string;\n type: string;\n error?: string;\n calls?: SimulateTraceCall[];\n isCallImpl?: boolean;\n logs?: SimulateLog[];\n}\n\nexport interface SimulateTraceResponse {\n traceCall: SimulateTraceCall;\n addressArray: string[];\n authMap?: Record<string, string>;\n proxyMap?: Record<string, ProxyType>;\n methodMap?: Record<string, Record<string, string>>;\n nameMap?: Record<string, AddressNameMap>;\n}\n\nexport interface SimulateTraceTxParams extends TransactionLists {\n from: Hex;\n to?: Hex;\n value?: string;\n data?: Hex;\n gas?: string;\n gasPrice?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n // simulate trace not support core space now\n space: Exclude<Space, 'core'>;\n}\n\nexport interface SimulateTraceConfig {\n // other tracer has different response, not support now\n // | '4byteTracer'\n // | 'prestateTracer'\n // | 'flatCallTracer'\n // | 'muxTracer'\n // | 'erc7562Tracer';\n tracer: 'callTracer';\n tracerConfig?: {\n disableStorage?: boolean;\n disableStack?: boolean;\n enableMemory?: boolean;\n enableReturnData?: boolean;\n onlyTopCall?: boolean;\n withLog?: boolean;\n timeout?: number;\n };\n}\n\nconst formatSimulateTraceData = (\n data: SimulateTraceResponse,\n space: 'evm' | 'core',\n) => {\n const addressType = space === 'core' ? 'base32' : 'hex';\n const proxyMap = data.proxyMap || {};\n const methodMap = data.methodMap || {};\n const nameMap = data.nameMap || {};\n const authMap = data.authMap || {};\n\n let total = 0;\n const logs: SimulateLog[] = [];\n\n const formatList = (\n t: SimulateTraceCall[],\n parent?: TreeTraceForUI,\n ): TreeTraceForUI[] => {\n total += t.length;\n return t.map((item, index) => formatItem(item, index, parent, t));\n };\n const formatItem = (\n t: SimulateTraceCall,\n index: number,\n parent: TreeTraceForUI | undefined,\n list: SimulateTraceCall[],\n ): TreeTraceForUI => {\n if (t.logs) {\n logs.push(...t.logs);\n }\n const type = t.type?.toLowerCase();\n const isContractCreated = isCreateCall(type);\n const methodId = t.input?.slice(0, 10);\n const from = formatAddress(t.from, addressType);\n const to = !isContractCreated\n ? formatAddress(t.to, addressType)\n : undefined;\n const delegatedTo = to && authMap[to];\n let method = methodId;\n let abi: AbiFunctionWithoutGas[] | undefined = undefined;\n const methodABI =\n methodId && (delegatedTo || to)\n ? methodMap[methodId]?.[delegatedTo || to]\n : undefined;\n if (methodABI) {\n try {\n const result = formatABI(`[\"${methodABI}\"]`, {\n json: true,\n allowEmpty: true,\n });\n abi = JSON.parse(result) as AbiFunctionWithoutGas[];\n const jsonABI = abi[0];\n method = jsonABI?.name || methodId;\n } catch (error) {\n console.log('parse method abi error: ', methodABI, error);\n }\n }\n\n const item: TreeTraceForUI = {\n index: `${parent?.index ? `${parent.index}_` : ''}${index}`,\n type: type,\n from: from,\n to: to,\n input: t.input,\n value: t.value,\n gas: t.gas ? new BigNumber(t.gas).toString() : undefined,\n gasUsed: t.gasUsed ? new BigNumber(t.gasUsed).toString() : undefined,\n output: t.output,\n outcome: !t.error\n ? 'success'\n : t.error === 'Reverted'\n ? 'reverted'\n : 'fail',\n method,\n abi,\n contractCreated: isContractCreated ? t.to : undefined,\n nameMap,\n delegatedTo,\n isCallImpl: t.isCallImpl,\n };\n if (\n parent &&\n parent.to &&\n proxyMap[parent.to] &&\n from === parent.to &&\n to\n ) {\n // proxy call\n if (\n index === 0 &&\n proxyMap[parent.to] === 'Proxy' &&\n isDelegateCall(type)\n ) {\n parent.proxy = {\n type: 'Proxy',\n implAddress: to,\n };\n item.isCallImpl = true;\n }\n // beacon proxy call\n const second = list[1];\n if (\n index === 0 &&\n proxyMap[parent.to] === 'BeaconProxy' &&\n isStaticCall(type) &&\n second &&\n second.to &&\n second.from === parent.to &&\n isDelegateCall(second.type)\n ) {\n parent.proxy = {\n type: 'BeaconProxy',\n beaconAddress: to,\n implAddress: second.to,\n };\n item.isCallBeacon = true;\n second.isCallImpl = true;\n }\n }\n if (t.calls) {\n item.calls = formatList(t.calls, item);\n }\n return item;\n };\n const list = formatList([data.traceCall]);\n return {\n total,\n list,\n // TODO: use real log index, and sort\n logs: logs.map((item, index) => ({ ...item, transactionLogIndex: index })),\n };\n};\nexport const querySimulateTrace = async (\n tx: SimulateTraceTxParams,\n tag: BlockTag = 'latest',\n params: SimulateTraceConfig = {\n tracer: 'callTracer',\n tracerConfig: {\n onlyTopCall: false,\n },\n },\n) => {\n const url = `/traceCallView`;\n\n const { space, ...rawTx } = tx;\n if (space !== 'evm') {\n throw new Error('Simulate trace only supports EVM Space');\n }\n const simulateTx = { ...rawTx, ...normalizeTransactionLists(rawTx) };\n\n if (!simulateTx.maxFeePerGas && !simulateTx.gasPrice) {\n let feeCap = 22_000_000_000n; // 22 Gdrip\n if (simulateTx.maxPriorityFeePerGas !== undefined) {\n const priorityFee = BigInt(simulateTx.maxPriorityFeePerGas);\n if (priorityFee > feeCap) {\n feeCap = priorityFee;\n }\n }\n simulateTx.maxFeePerGas = `0x${feeCap.toString(16)}`;\n }\n\n if (!simulateTx.gas) {\n try {\n const gasLimit = await estimateGas({\n account: simulateTx.from,\n to: simulateTx.to,\n value: simulateTx.value,\n data: simulateTx.data as `0x${string}`,\n space,\n accessList: simulateTx.accessList,\n authorizationList: simulateTx.authorizationList,\n gasPrice: simulateTx.gasPrice,\n maxFeePerGas: simulateTx.maxFeePerGas,\n maxPriorityFeePerGas: simulateTx.maxPriorityFeePerGas,\n tag,\n });\n simulateTx.gas = `0x${gasLimit.toString(16)}`;\n } catch (error) {\n console.log('estimate gas failed:', error);\n }\n }\n\n const data = JSON.stringify({\n id: generateRandomId(),\n jsonrpc: '2.0',\n method: 'debug_traceCall',\n params: [simulateTx, tag, params],\n });\n return fetchWithPrefix<SimulateTraceResponse>(url, {\n method: 'POST',\n body: data,\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n};\n\nexport const useSimulateTrace = ({\n tx,\n tag = 'latest',\n params = {\n tracer: 'callTracer',\n tracerConfig: {\n onlyTopCall: false,\n withLog: true,\n },\n },\n disabled = false,\n}: {\n tx?: SimulateTraceTxParams;\n tag?: BlockTag;\n params?: SimulateTraceConfig;\n disabled?: boolean;\n}) => {\n let key = null;\n if (!disabled && tx) {\n key = JSON.stringify([tx, tag, params]);\n }\n\n return useSWRImmutable(\n key,\n () =>\n tx &&\n querySimulateTrace(tx, tag, params).then(resp => {\n if (resp?.traceCall) {\n return formatSimulateTraceData(resp, tx.space);\n }\n }),\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,qBAAqB;AAa5B,OAAO,eAAe;AAwEtB,IAAM,0BAA0B,CAC9B,MACA,UACG;AACH,QAAM,cAAc,UAAU,SAAS,WAAW;AAClD,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,QAAM,YAAY,KAAK,aAAa,CAAC;AACrC,QAAM,UAAU,KAAK,WAAW,CAAC;AACjC,QAAM,UAAU,KAAK,WAAW,CAAC;AAEjC,MAAI,QAAQ;AACZ,QAAM,OAAsB,CAAC;AAE7B,QAAM,aAAa,CACjB,GACA,WACqB;AACrB,aAAS,EAAE;AACX,WAAO,EAAE,IAAI,CAAC,MAAM,UAAU,WAAW,MAAM,OAAO,QAAQ,CAAC,CAAC;AAAA,EAClE;AACA,QAAM,aAAa,CACjB,GACA,OACA,QACAA,UACmB;AACnB,QAAI,EAAE,MAAM;AACV,WAAK,KAAK,GAAG,EAAE,IAAI;AAAA,IACrB;AACA,UAAM,OAAO,EAAE,MAAM,YAAY;AACjC,UAAM,oBAAoB,aAAa,IAAI;AAC3C,UAAM,WAAW,EAAE,OAAO,MAAM,GAAG,EAAE;AACrC,UAAM,OAAO,cAAc,EAAE,MAAM,WAAW;AAC9C,UAAM,KAAK,CAAC,oBACR,cAAc,EAAE,IAAI,WAAW,IAC/B;AACJ,UAAM,cAAc,MAAM,QAAQ,EAAE;AACpC,QAAI,SAAS;AACb,QAAI,MAA2C;AAC/C,UAAM,YACJ,aAAa,eAAe,MACxB,UAAU,QAAQ,IAAI,eAAe,EAAE,IACvC;AACN,QAAI,WAAW;AACb,UAAI;AACF,cAAM,SAAS,UAAU,KAAK,eAAe;AAAA,UAC3C,MAAM;AAAA,UACN,YAAY;AAAA,QACd,CAAC;AACD,c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AAA,IAC5C,SAAS,OAAP;AACA,cAAQ,IAAI,wBAAwB,KAAK;AAAA,IAC3C;AAAA,EACF;AAEA,QAAM,OAAO,KAAK,UAAU;AAAA,IAC1B,IAAI,iBAAiB;AAAA,IACrB,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ,CAAC,YAAY,KAAK,MAAM;AAAA,EAClC,CAAC;AACD,SAAO,gBAAuC,KAAK;AAAA,IACjD,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,EACF,CAAC;AACH;AAEO,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,cAAc;AAAA,MACZ,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,WAAW;AACb,MAKM;AACJ,MAAI,MAAM;AACV,MAAI,CAAC,YAAY,IAAI;AACnB,UAAM,KAAK,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC;AAAA,EACxC;AAEA,SAAO;AAAA,IACL;AAAA,IACA,MACE,MACA,mBAAmB,IAAI,KAAK,MAAM,EAAE,KAAK,UAAQ;AAC/C,UAAI,MAAM,WAAW;AACnB,eAAO,wBAAwB,MAAM,GAAG,KAAK;AAAA,MAC/C;AAAA,IACF,CAAC;AAAA,EACL;AACF;","names":["list"]}
|
package/dist/utils/sdk.d.ts
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { Hex, RpcAuthorizationList, BlockTag, Abi, AbiItem } from 'viem';
|
|
3
3
|
export { AbiItem, AbiParameter, AbiStateMutability, getAbiItem } from 'viem';
|
|
4
4
|
import * as cive_accounts from 'cive/accounts';
|
|
5
5
|
import * as cive from 'cive';
|
|
6
|
+
import { PublicClient } from 'cive';
|
|
6
7
|
import { Space } from './types.js';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
type CoreEstimateGasTag = NonNullable<Parameters<PublicClient['estimateGasAndCollateral']>[0]['epochTag']> | Hex;
|
|
10
|
+
type EstimateGasParams = {
|
|
11
|
+
value?: string;
|
|
12
|
+
account?: string;
|
|
13
|
+
data?: Hex;
|
|
14
|
+
to?: string;
|
|
15
|
+
gasPrice?: string;
|
|
16
|
+
maxFeePerGas?: string;
|
|
17
|
+
maxPriorityFeePerGas?: string;
|
|
18
|
+
accessList?: readonly {
|
|
19
|
+
address: string;
|
|
20
|
+
storageKeys: readonly Hex[];
|
|
21
|
+
}[];
|
|
22
|
+
} & ({
|
|
23
|
+
space: 'evm';
|
|
24
|
+
authorizationList?: RpcAuthorizationList;
|
|
25
|
+
tag?: BlockTag | Hex;
|
|
26
|
+
} | {
|
|
27
|
+
space: 'core';
|
|
28
|
+
authorizationList?: never;
|
|
29
|
+
tag?: CoreEstimateGasTag;
|
|
30
|
+
} | {
|
|
13
31
|
space: Space;
|
|
14
|
-
|
|
32
|
+
authorizationList?: never;
|
|
33
|
+
tag?: never;
|
|
34
|
+
});
|
|
35
|
+
declare const estimateGas: ({ to, data, value, account, space, accessList, authorizationList, tag, gasPrice, maxFeePerGas, maxPriorityFeePerGas, }: EstimateGasParams) => Promise<bigint>;
|
|
15
36
|
declare const simulateContract: ({ address, functionName, args, abi, value, account, space, }: {
|
|
16
37
|
value?: string | undefined;
|
|
17
38
|
account?: string | undefined;
|
|
@@ -57,4 +78,4 @@ type AbiFunctionWithoutGas = Omit<AbiItem & {
|
|
|
57
78
|
type: 'function';
|
|
58
79
|
}, 'gas'>;
|
|
59
80
|
|
|
60
|
-
export { AbiError, AbiFunctionWithoutGas, decodeErrorResult, decodeFunctionData, decodeFunctionResult, encodeFunctionData, estimateGas, simulateContract };
|
|
81
|
+
export { AbiError, AbiFunctionWithoutGas, CoreEstimateGasTag, EstimateGasParams, decodeErrorResult, decodeFunctionData, decodeFunctionResult, encodeFunctionData, estimateGas, simulateContract };
|
package/dist/utils/sdk.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AccessList, RpcAuthorizationList } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface TransactionLists {
|
|
4
|
+
accessList?: AccessList;
|
|
5
|
+
authorizationList?: RpcAuthorizationList;
|
|
6
|
+
}
|
|
7
|
+
type TransactionListField = keyof TransactionLists;
|
|
8
|
+
declare const MAX_TRANSACTION_LIST_URL_LENGTH: number;
|
|
9
|
+
declare class TransactionListError extends Error {
|
|
10
|
+
readonly field: TransactionListField;
|
|
11
|
+
constructor(field: TransactionListField, message: string);
|
|
12
|
+
}
|
|
13
|
+
/** Validate EVM lists and normalize quantities without changing list order. */
|
|
14
|
+
declare const normalizeTransactionLists: ({ accessList, authorizationList, to, }: {
|
|
15
|
+
accessList?: unknown;
|
|
16
|
+
authorizationList?: unknown;
|
|
17
|
+
to?: unknown;
|
|
18
|
+
}) => TransactionLists;
|
|
19
|
+
/** URL values must each be a single JSON array, never repeated query keys. */
|
|
20
|
+
declare const parseTransactionListsFromUrl: (params: Record<string, unknown>) => {
|
|
21
|
+
ok: true;
|
|
22
|
+
lists: TransactionLists;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
field: TransactionListField;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { MAX_TRANSACTION_LIST_URL_LENGTH, TransactionListError, TransactionListField, TransactionLists, normalizeTransactionLists, parseTransactionListsFromUrl };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_TRANSACTION_LIST_URL_LENGTH,
|
|
3
|
+
TransactionListError,
|
|
4
|
+
normalizeTransactionLists,
|
|
5
|
+
parseTransactionListsFromUrl
|
|
6
|
+
} from "../chunk-6A3FV7ST.js";
|
|
7
|
+
import "../chunk-WQG2LZMB.js";
|
|
8
|
+
export {
|
|
9
|
+
MAX_TRANSACTION_LIST_URL_LENGTH,
|
|
10
|
+
TransactionListError,
|
|
11
|
+
normalizeTransactionLists,
|
|
12
|
+
parseTransactionListsFromUrl
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=transactionLists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfxjs/sirius-next-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**"
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"typescript": "^5.4.2",
|
|
87
87
|
"unocss": "0.58.6",
|
|
88
88
|
"vitest": "3.2.3",
|
|
89
|
-
"@cfxjs/sirius-next-i18n": "0.3.3",
|
|
90
89
|
"@cfxjs/sirius-next-eslint-config": "0.0.0",
|
|
90
|
+
"@cfxjs/sirius-next-i18n": "0.3.4",
|
|
91
91
|
"@cfxjs/sirius-next-typescript-config": "0.0.0"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|