Notice
Recent Posts
Recent Comments
반응형
오늘도 공부
Tronweb에 NextJs15 이슈 본문
반응형
NextJs15이상 버전 에서 tronweb을 사용시
ReferenceError: Cannot access 'TypedDataEncoder' before initialization
오류가 나온다면 다음과 같은 PR 을 참고하면 된다.
fix(#627): circular dependency issue for TypedDataEncoder by heyitsarpit · Pull Request #630 · tronprotocol/tronweb
this is fix for issue #627, which crashes builds in turbopack due a circular import for TypedDataEncoder. I ran this locally on my own codebase to confirm this does work without crashing now.
github.com
🛠️ patch-package로 PR 미적용된 tronweb 수정 적용하기
✅ 1. tronweb과 patch-package 설치
bash
복사편집
npm install tronweb npm install patch-package --save-dev
또는 yarn 사용 시:
bash
복사편집
yarn add tronweb yarn add patch-package --dev
✅ 2. package.json에 스크립트 추가
json
복사편집
"scripts": { "postinstall": "patch-package" }
이렇게 하면 npm install 혹은 yarn install 할 때마다 패치가 자동 적용됩니다.
패치 내용은 patches 폴더내 tronweb+6.0.3.patch 으로 만든 후
diff --git a/node_modules/tronweb/lib/esm/utils/typedData.js b/node_modules/tronweb/lib/esm/utils/typedData.js
index 6fad6ff..eb2fad7 100644
--- a/node_modules/tronweb/lib/esm/utils/typedData.js
+++ b/node_modules/tronweb/lib/esm/utils/typedData.js
@@ -1,10 +1,17 @@
-import { TronWeb } from '../tronweb.js';
import { keccak256, recoverAddress, concat, defineProperties, getBigInt, getBytes, hexlify, isHexString, mask, toBeHex, toQuantity, toTwos, zeroPadValue, assertArgument, id, } from 'ethers';
import { ADDRESS_PREFIX_REGEX } from './address.js';
+
+let TronWeb;
function getAddress(address) {
+ if (!TronWeb) {
+ TronWeb = require('../tronweb.js').TronWeb;
+ }
return TronWeb.address.toHex(address).replace(ADDRESS_PREFIX_REGEX, '0x');
}
function getTronAddress(address) {
+ if (!TronWeb) {
+ TronWeb = require('../tronweb.js').TronWeb;
+ }
return TronWeb.address.toHex(address);
}
const padding = new Uint8Array(32);
반응형
'블록체인' 카테고리의 다른 글
Smart Wallet: AI 에이전트가 탑재된 차세대 블록체인 지갑 (0) | 2025.10.01 |
---|---|
ERC-6551 완벽 가이드: NFT가 스마트 계정이 되는 혁명적인 표준의 모든 것 (1) | 2025.09.24 |
에이셔 노드 운영 전략 및 수익 모델 분석 (11) | 2025.06.23 |
이더리움(Geth)에 사용되는 키스토어 암호화 및 복호화 설명 (1) | 2025.05.21 |
우분투에서 fish 터미널 셸 설치 및 사용법 (0) | 2025.05.19 |