我用的是hedera-sdk-js,
2.37.0版,在NPM上从@hashgraph/sdk
安装.
当我在NodeJS中运行脚本时,该进程将无限期地保持打开状态,
为了迫使它终止,
我一直在用process.exit(0);
美元.
这是可行的,但并不理想--我更希望它优雅地结束.
有办法做到这一点吗?
详细信息:
以下是当前脚本
import dotenv from 'dotenv';
import {
Client,
AccountId,
PrivateKey,
} from '@hashgraph/sdk';
dotenv.config();
main();
async function main() {
if (!process.env.ACCOUNT_ID ||
!process.env.ACCOUNT_PRIVATE_KEY) {
throw new Error('Please set required keys in .env file.');
}
const accountId = AccountId.fromString(process.env.ACCOUNT_ID);
const accountKey = PrivateKey.fromStringECDSA(process.env.ACCOUNT_PRIVATE_KEY);
const client = Client.forTestnet().setOperator(accountId, accountKey);
// ... do some things here ...
process.exit(0); // <-- NOTE would like to remove this
}