@cfxjs/sirius-next-common 0.2.16 → 0.2.17

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDecodeFunctionData
3
- } from "./chunk-AYH6CLQB.js";
3
+ } from "./chunk-LUCBUM2Y.js";
4
4
  import {
5
5
  useDecodedDataType
6
6
  } from "./chunk-UM5J477V.js";
@@ -189,4 +189,4 @@ var TraceDetail = (props) => {
189
189
  export {
190
190
  TraceDetail
191
191
  };
192
- //# sourceMappingURL=chunk-A6ND7FSQ.js.map
192
+ //# sourceMappingURL=chunk-CL6QEKM6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TraceDetail
3
- } from "./chunk-A6ND7FSQ.js";
3
+ } from "./chunk-CL6QEKM6.js";
4
4
  import {
5
5
  Table
6
6
  } from "./chunk-XZ7IV2FF.js";
@@ -79,4 +79,4 @@ var TreeTraceTable = ({
79
79
  export {
80
80
  TreeTraceTable
81
81
  };
82
- //# sourceMappingURL=chunk-VJSXGYWN.js.map
82
+ //# sourceMappingURL=chunk-LBWKTQYK.js.map
@@ -41,13 +41,13 @@ var decodeFunctionDataByAbi = ({
41
41
  });
42
42
  let decodedResults = success ? !isReturnDataEmpty ? decodeFunctionResult({
43
43
  abi,
44
- functionName: decodedParams.functionName,
44
+ functionName: methodID,
45
45
  data: output,
46
46
  space
47
47
  }) : void 0 : output;
48
48
  const abiItem = getAbiItem({
49
49
  abi,
50
- name: decodedParams.functionName ?? methodID
50
+ name: methodID
51
51
  });
52
52
  const results = decodedResults === void 0 ? void 0 : abiItem.outputs.length === 1 ? [decodedResults] : decodedResults;
53
53
  if (!withOutput) {
@@ -199,4 +199,4 @@ var useDecodeFunctionData = ({
199
199
  export {
200
200
  useDecodeFunctionData
201
201
  };
202
- //# sourceMappingURL=chunk-AYH6CLQB.js.map
202
+ //# sourceMappingURL=chunk-LUCBUM2Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/hooks/useDecodeFunctionData.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n decodeFunctionData,\n decodeFunctionResult,\n getAbiItem,\n AbiFunctionWithoutGas,\n} from 'src/utils/sdk';\nimport { useContractDetail } from './useContractDetail';\nimport { formatABI } from '..';\nimport { useMethodAbi } from './useMethodAbi';\n\nconst fields = ['abi' as const];\n\nexport type Hex = `0x${string}`;\n\nconst decodeFunctionDataByAbi = ({\n abi: _abi,\n input,\n output,\n space,\n success,\n withOutput = false,\n similarWarning,\n}: {\n input: Hex;\n output?: Hex;\n abi?: AbiFunctionWithoutGas[] | string;\n space: 'evm' | 'core';\n success?: boolean;\n withOutput?: boolean;\n similarWarning?: boolean;\n}) => {\n try {\n const abi = typeof _abi === 'string' ? JSON.parse(_abi) : _abi;\n const hasAbi = abi && abi.length > 0;\n if (!hasAbi) return null;\n const isReturnDataEmpty = !output || output === '0x';\n const methodID = input.slice(0, 10);\n const decodedParams = decodeFunctionData({\n abi: abi,\n data: input,\n space,\n });\n let decodedResults = success\n ? !isReturnDataEmpty\n ? decodeFunctionResult({\n abi: abi,\n functionName: methodID,\n data: output,\n space,\n })\n : undefined\n : output;\n const abiItem = getAbiItem({\n abi: abi,\n name: methodID,\n }) as AbiFunctionWithoutGas;\n // if the output has only one value, decodeFunctionResult will return the value directly, otherwise it will return an array,\n // so we need to check the length of abiItem.outputs to determine whether to wrap decodedResults in an array\n const results =\n decodedResults === undefined\n ? undefined\n : abiItem.outputs.length === 1\n ? [decodedResults]\n : (decodedResults as unknown[]);\n if (!withOutput) {\n abiItem.outputs = [];\n }\n const fullName = formatABI([abiItem])[0];\n return {\n decodedParams,\n decodedResults: results,\n abiItem,\n fullName: fullName,\n failed: false,\n similarWarning,\n };\n } catch (error) {\n console.log('decode function data and result error', error);\n return {\n failed: true,\n similarWarning,\n };\n }\n};\n\nexport interface DecodedFunctionData {\n decodedParams?: {\n args: readonly unknown[] | undefined;\n functionName: string;\n };\n decodedResults?: unknown[];\n abiItem?: AbiFunctionWithoutGas;\n fullName?: string;\n // no abi for decoded\n noAbi?: boolean;\n // decoded failed\n failed?: boolean;\n // decoded by method abi, not contract abi\n similarWarning?: boolean;\n}\n\nexport const useDecodeFunctionData = ({\n to,\n abi: outerAbi,\n implementation: _implementation,\n input,\n output,\n space,\n success,\n supportMethodAbi,\n withOutput,\n}: {\n input: Hex;\n output?: Hex;\n to?: string;\n implementation?: string;\n abi?: AbiFunctionWithoutGas[];\n space: 'evm' | 'core';\n success?: boolean;\n supportMethodAbi?: boolean;\n withOutput?: boolean;\n}): [DecodedFunctionData, boolean] => {\n const hasOuterAbi = outerAbi && outerAbi.length > 0;\n const needContractAbi = !hasOuterAbi && !!input;\n const { data: contractData, isLoading: contractLoading } = useContractDetail(\n to,\n fields,\n needContractAbi,\n );\n const implementation =\n _implementation ?? contractData?.implementation?.address;\n const { data: implementationData, isLoading: implementationLoading } =\n useContractDetail(implementation, fields, needContractAbi);\n const decodedByOuterAbi = useMemo(() => {\n return decodeFunctionDataByAbi({\n abi: outerAbi,\n input,\n output,\n space,\n success,\n withOutput,\n });\n }, [input, output, outerAbi, success, space, withOutput]);\n const decodedByContractAbi = useMemo(() => {\n if (!contractData?.abi) return null;\n return decodeFunctionDataByAbi({\n abi: contractData.abi as string,\n input,\n output,\n space,\n success,\n withOutput,\n });\n }, [input, output, contractData?.abi, success, space, withOutput]);\n const decodedByImplementationAbi = useMemo(() => {\n if (!implementationData?.abi) return null;\n return decodeFunctionDataByAbi({\n abi: implementationData.abi as string,\n input,\n output,\n space,\n success,\n withOutput,\n });\n }, [input, output, implementationData?.abi, success, space, withOutput]);\n const needMethodAbi =\n !!supportMethodAbi &&\n needContractAbi &&\n // contract abi decoded failed\n !contractLoading &&\n (!decodedByContractAbi || decodedByContractAbi.failed) &&\n // implementation contract abi decoded failed\n !implementationLoading &&\n (!decodedByImplementationAbi || decodedByImplementationAbi.failed);\n const { data: methodAbi, isLoading: methodAbiLoading } = useMethodAbi(\n input.slice(0, 10),\n needMethodAbi,\n );\n const decodedByMethodAbi = useMemo(() => {\n // decode tx data with function abi only if there is only one function\n if (!methodAbi || methodAbi.list.length !== 1) return null;\n try {\n // e.g. transfer(address,uint256)\n const fullName = methodAbi.list[0]!.fullName;\n // e.g. function transfer(address recipient, uint256 amount) returns (bool)\n const formatWithArg = methodAbi.list[0]!.formatWithArg;\n const abi = formatABI([formatWithArg || `function ${fullName}`], {\n json: true,\n });\n return decodeFunctionDataByAbi({\n abi: abi,\n input,\n output,\n space,\n success,\n withOutput,\n similarWarning: true,\n });\n } catch (error) {\n console.log('decode function data and result error', error);\n return {\n failed: true,\n };\n }\n }, [input, output, methodAbi, success, space, withOutput]);\n\n return useMemo(() => {\n if (!input) return [{}, false];\n if (decodedByOuterAbi && !decodedByOuterAbi.failed)\n return [decodedByOuterAbi, false];\n if (decodedByImplementationAbi && !decodedByImplementationAbi.failed)\n return [decodedByImplementationAbi, implementationLoading];\n if (decodedByContractAbi && !decodedByContractAbi.failed)\n return [decodedByContractAbi, contractLoading];\n if (decodedByMethodAbi && !decodedByMethodAbi.failed)\n return [decodedByMethodAbi, methodAbiLoading];\n if (implementationLoading || contractLoading || methodAbiLoading) {\n return [{}, true];\n }\n if (\n (decodedByOuterAbi && decodedByOuterAbi.failed) ||\n (decodedByImplementationAbi && decodedByImplementationAbi.failed) ||\n (decodedByContractAbi && decodedByContractAbi.failed) ||\n (decodedByMethodAbi && decodedByMethodAbi.failed)\n ) {\n return [\n {\n failed: true,\n },\n false,\n ];\n }\n return [\n {\n noAbi: true,\n },\n false,\n ];\n }, [\n input,\n decodedByOuterAbi,\n decodedByContractAbi,\n decodedByImplementationAbi,\n decodedByMethodAbi,\n contractLoading,\n implementationLoading,\n methodAbiLoading,\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AAWxB,IAAM,SAAS,CAAC,KAAc;AAI9B,IAAM,0BAA0B,CAAC;AAAA,EAC/B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E,OAAO;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TraceDetail
3
- } from "../../chunk-A6ND7FSQ.js";
4
- import "../../chunk-AYH6CLQB.js";
3
+ } from "../../chunk-CL6QEKM6.js";
4
+ import "../../chunk-LUCBUM2Y.js";
5
5
  import "../../chunk-UM5J477V.js";
6
6
  import "../../chunk-E3ZD2GGG.js";
7
7
  import "../../chunk-YIZCD4WG.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  TreeTraceTable
3
- } from "../../chunk-VJSXGYWN.js";
4
- import "../../chunk-A6ND7FSQ.js";
5
- import "../../chunk-AYH6CLQB.js";
3
+ } from "../../chunk-LBWKTQYK.js";
4
+ import "../../chunk-CL6QEKM6.js";
5
+ import "../../chunk-LUCBUM2Y.js";
6
6
  import "../../chunk-UM5J477V.js";
7
7
  import "../../chunk-E3ZD2GGG.js";
8
8
  import "../../chunk-XZ7IV2FF.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  TreeTraceTable
3
- } from "../../chunk-VJSXGYWN.js";
3
+ } from "../../chunk-LBWKTQYK.js";
4
4
  import {
5
5
  TraceDetail
6
- } from "../../chunk-A6ND7FSQ.js";
7
- import "../../chunk-AYH6CLQB.js";
6
+ } from "../../chunk-CL6QEKM6.js";
7
+ import "../../chunk-LUCBUM2Y.js";
8
8
  import "../../chunk-UM5J477V.js";
9
9
  import "../../chunk-E3ZD2GGG.js";
10
10
  import "../../chunk-XZ7IV2FF.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDecodeFunctionData
3
- } from "../../chunk-AYH6CLQB.js";
3
+ } from "../../chunk-LUCBUM2Y.js";
4
4
  import "../../chunk-E3ZD2GGG.js";
5
5
  import "../../chunk-6SXAFSBF.js";
6
6
  import "../../chunk-JIRLY7OG.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfxjs/sirius-next-common",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**"
@@ -79,8 +79,8 @@
79
79
  "unocss": "0.58.6",
80
80
  "vitest": "3.2.3",
81
81
  "@cfxjs/sirius-next-typescript-config": "0.0.0",
82
- "@cfxjs/sirius-next-i18n": "0.2.9",
83
- "@cfxjs/sirius-next-eslint-config": "0.0.0"
82
+ "@cfxjs/sirius-next-eslint-config": "0.0.0",
83
+ "@cfxjs/sirius-next-i18n": "0.2.9"
84
84
  },
85
85
  "publishConfig": {
86
86
  "access": "public"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/hooks/useDecodeFunctionData.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n decodeFunctionData,\n decodeFunctionResult,\n getAbiItem,\n AbiFunctionWithoutGas,\n} from 'src/utils/sdk';\nimport { useContractDetail } from './useContractDetail';\nimport { formatABI } from '..';\nimport { useMethodAbi } from './useMethodAbi';\n\nconst fields = ['abi' as const];\n\nexport type Hex = `0x${string}`;\n\nconst decodeFunctionDataByAbi = ({\n abi: _abi,\n input,\n output,\n space,\n success,\n withOutput = false,\n similarWarning,\n}: {\n input: Hex;\n output?: Hex;\n abi?: AbiFunctionWithoutGas[] | string;\n space: 'evm' | 'core';\n success?: boolean;\n withOutput?: boolean;\n similarWarning?: boolean;\n}) => {\n try {\n const abi = typeof _abi === 'string' ? JSON.parse(_abi) : _abi;\n const hasAbi = abi && abi.length > 0;\n if (!hasAbi) return null;\n const isReturnDataEmpty = !output || output === '0x';\n const methodID = input.slice(0, 10);\n const decodedParams = decodeFunctionData({\n abi: abi,\n data: input,\n space,\n });\n let decodedResults = success\n ? !isReturnDataEmpty\n ? decodeFunctionResult({\n abi: abi,\n functionName: decodedParams.functionName,\n data: output,\n space,\n })\n : undefined\n : output;\n const abiItem = getAbiItem({\n abi: abi,\n name: decodedParams.functionName ?? methodID,\n }) as AbiFunctionWithoutGas;\n // if the output has only one value, decodeFunctionResult will return the value directly, otherwise it will return an array,\n // so we need to check the length of abiItem.outputs to determine whether to wrap decodedResults in an array\n const results =\n decodedResults === undefined\n ? undefined\n : abiItem.outputs.length === 1\n ? [decodedResults]\n : (decodedResults as unknown[]);\n if (!withOutput) {\n abiItem.outputs = [];\n }\n const fullName = formatABI([abiItem])[0];\n return {\n decodedParams,\n decodedResults: results,\n abiItem,\n fullName: fullName,\n failed: false,\n similarWarning,\n };\n } catch (error) {\n console.log('decode function data and result error', error);\n return {\n failed: true,\n similarWarning,\n };\n }\n};\n\nexport interface DecodedFunctionData {\n decodedParams?: {\n args: readonly unknown[] | undefined;\n functionName: string;\n };\n decodedResults?: unknown[];\n abiItem?: AbiFunctionWithoutGas;\n fullName?: string;\n // no abi for decoded\n noAbi?: boolean;\n // decoded failed\n failed?: boolean;\n // decoded by method abi, not contract abi\n similarWarning?: boolean;\n}\n\nexport const useDecodeFunctionData = ({\n to,\n abi: outerAbi,\n implementation: _implementation,\n input,\n output,\n space,\n success,\n supportMethodAbi,\n withOutput,\n}: {\n input: Hex;\n output?: Hex;\n to?: string;\n implementation?: string;\n abi?: AbiFunctionWithoutGas[];\n space: 'evm' | 'core';\n success?: boolean;\n supportMethodAbi?: boolean;\n withOutput?: boolean;\n}): [DecodedFunctionData, boolean] => {\n const hasOuterAbi = outerAbi && outerAbi.length > 0;\n const needContractAbi = !hasOuterAbi && !!input;\n const { data: contractData, isLoading: contractLoading } = useContractDetail(\n to,\n fields,\n needContractAbi,\n );\n const implementation =\n _implementation ?? contractData?.implementation?.address;\n const { data: implementationData, isLoading: implementationLoading } =\n useContractDetail(implementation, fields, needContractAbi);\n const decodedByOuterAbi = useMemo(() => {\n return decodeFunctionDataByAbi({\n abi: outerAbi,\n input,\n output,\n space,\n success,\n withOutput,\n });\n }, [input, output, outerAbi, success, space, withOutput]);\n const decodedByContractAbi = useMemo(() => {\n if (!contractData?.abi) return null;\n return decodeFunctionDataByAbi({\n abi: contractData.abi as string,\n input,\n output,\n space,\n success,\n withOutput,\n });\n }, [input, output, contractData?.abi, success, space, withOutput]);\n const decodedByImplementationAbi = useMemo(() => {\n if (!implementationData?.abi) return null;\n return decodeFunctionDataByAbi({\n abi: implementationData.abi as string,\n input,\n output,\n space,\n success,\n withOutput,\n });\n }, [input, output, implementationData?.abi, success, space, withOutput]);\n const needMethodAbi =\n !!supportMethodAbi &&\n needContractAbi &&\n // contract abi decoded failed\n !contractLoading &&\n (!decodedByContractAbi || decodedByContractAbi.failed) &&\n // implementation contract abi decoded failed\n !implementationLoading &&\n (!decodedByImplementationAbi || decodedByImplementationAbi.failed);\n const { data: methodAbi, isLoading: methodAbiLoading } = useMethodAbi(\n input.slice(0, 10),\n needMethodAbi,\n );\n const decodedByMethodAbi = useMemo(() => {\n // decode tx data with function abi only if there is only one function\n if (!methodAbi || methodAbi.list.length !== 1) return null;\n try {\n // e.g. transfer(address,uint256)\n const fullName = methodAbi.list[0]!.fullName;\n // e.g. function transfer(address recipient, uint256 amount) returns (bool)\n const formatWithArg = methodAbi.list[0]!.formatWithArg;\n const abi = formatABI([formatWithArg || `function ${fullName}`], {\n json: true,\n });\n return decodeFunctionDataByAbi({\n abi: abi,\n input,\n output,\n space,\n success,\n withOutput,\n similarWarning: true,\n });\n } catch (error) {\n console.log('decode function data and result error', error);\n return {\n failed: true,\n };\n }\n }, [input, output, methodAbi, success, space, withOutput]);\n\n return useMemo(() => {\n if (!input) return [{}, false];\n if (decodedByOuterAbi && !decodedByOuterAbi.failed)\n return [decodedByOuterAbi, false];\n if (decodedByImplementationAbi && !decodedByImplementationAbi.failed)\n return [decodedByImplementationAbi, implementationLoading];\n if (decodedByContractAbi && !decodedByContractAbi.failed)\n return [decodedByContractAbi, contractLoading];\n if (decodedByMethodAbi && !decodedByMethodAbi.failed)\n return [decodedByMethodAbi, methodAbiLoading];\n if (implementationLoading || contractLoading || methodAbiLoading) {\n return [{}, true];\n }\n if (\n (decodedByOuterAbi && decodedByOuterAbi.failed) ||\n (decodedByImplementationAbi && decodedByImplementationAbi.failed) ||\n (decodedByContractAbi && decodedByContractAbi.failed) ||\n (decodedByMethodAbi && decodedByMethodAbi.failed)\n ) {\n return [\n {\n failed: true,\n },\n false,\n ];\n }\n return [\n {\n noAbi: true,\n },\n false,\n ];\n }, [\n input,\n decodedByOuterAbi,\n decodedByContractAbi,\n decodedByImplementationAbi,\n decodedByMethodAbi,\n contractLoading,\n implementationLoading,\n methodAbiLoading,\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AAWxB,IAAM,SAAS,CAAC,KAAc;AAI9B,IAAM,0BAA0B,CAAC;AAAA,EAC/B,KAAK;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AACF,MAQM;AACJ,MAAI;AACF,UAAM,MAAM,OAAO,SAAS,WAAW,KAAK,MAAM,IAAI,IAAI;AAC1D,UAAM,SAAS,OAAO,IAAI,SAAS;AACnC,QAAI,CAAC;AAAQ,aAAO;AACpB,UAAM,oBAAoB,CAAC,UAAU,WAAW;AAChD,UAAM,WAAW,MAAM,MAAM,GAAG,EAAE;AAClC,UAAM,gBAAgB,mBAAmB;AAAA,MACvC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,QAAI,iBAAiB,UACjB,CAAC,oBACC,qBAAqB;AAAA,MACnB;AAAA,MACA,cAAc,cAAc;AAAA,MAC5B,MAAM;AAAA,MACN;AAAA,IACF,CAAC,IACD,SACF;AACJ,UAAM,UAAU,WAAW;AAAA,MACzB;AAAA,MACA,MAAM,cAAc,gBAAgB;AAAA,IACtC,CAAC;AAGD,UAAM,UACJ,mBAAmB,SACf,SACA,QAAQ,QAAQ,WAAW,IACzB,CAAC,cAAc,IACd;AACT,QAAI,CAAC,YAAY;AACf,c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