fix: 简化天河链设置项
This commit is contained in:
@@ -8,6 +8,7 @@ import { TianheProvider } from './tianhe.provider';
|
||||
|
||||
const TIANHE_TEST_URL = 'https://test.api.tichain.tianhecloud.com';
|
||||
const TIANHE_PRODUCTION_URL = 'https://api.tichain.tianhecloud.com';
|
||||
const DEFAULT_TIANHE_USER_ID = 'artveris-platform';
|
||||
|
||||
@Injectable()
|
||||
export class BlockchainService {
|
||||
@@ -45,8 +46,20 @@ export class BlockchainService {
|
||||
baseUrl: configuredBaseUrl,
|
||||
appId: settings.tianheAppId || this.config.get<string>('blockchain.tianhe.appId') || '',
|
||||
appKey: settings.tianheAppKey || this.config.get<string>('blockchain.tianhe.appKey') || '',
|
||||
userId: settings.tianheUserId || this.config.get<string>('blockchain.tianhe.userId') || '',
|
||||
userKey: settings.tianheUserKey || this.config.get<string>('blockchain.tianhe.userKey') || '',
|
||||
userId: this.tianheUserId(settings),
|
||||
userKey: this.tianheUserKey(settings),
|
||||
});
|
||||
}
|
||||
|
||||
private tianheUserId(settings: Record<string, string>): string {
|
||||
return settings.tianheUserId || this.config.get<string>('blockchain.tianhe.userId') || DEFAULT_TIANHE_USER_ID;
|
||||
}
|
||||
|
||||
private tianheUserKey(settings: Record<string, string>): string {
|
||||
const configured = settings.tianheUserKey || this.config.get<string>('blockchain.tianhe.userKey');
|
||||
if (configured) return configured;
|
||||
const appId = settings.tianheAppId || this.config.get<string>('blockchain.tianhe.appId') || '';
|
||||
const appKey = settings.tianheAppKey || this.config.get<string>('blockchain.tianhe.appKey') || '';
|
||||
return createHash('sha256').update(`artveris:tianhe:${appId}:${appKey}`).digest('hex');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user