Open jtyoui opened 3 years ago
Hello author:
I find that I run program appear fatal errro,Beacuse project src file have a bug that sourece src/lib/ledger-api/state.ts
public async loadParticipant(): Promise<{ participant: Participant, organization: Organization }> {
const id = this.getAttributeValue(ID_FIELD);
try {
logger.info(`print id=${id}`);
const participant = await this.ctx.getParticipantList().get(id);
logger.info(`print participant=${participant}`);
logger.info(`print participant.orgId=${participant.orgId}`);
return {
organization: await this.ctx.getOrganizationList().get(participant.orgId),
participant,
};
} catch (err) {
throw new Error(`Unable to load participant for client ${id} ERROR: ${err.message}`);
}
}
I print participant.orgId===undefined
. I find function this.ctx.getOrganizationList().get
to address src/lib/ledger-api/statelist.ts
public async get(key: string): Promise<T> {
const ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
const data = await this.ctx.stub.getState(ledgerKey);
if (data.length === 0) {
throw new Error(`Cannot get state. No state exists for key ${key} ${this.name}`);
}
const state = State.deserialize(data, this.supportedClasses) as T;
return state;
}
I find State.splitKey(key)
appear error! beacuse key===undefined
.
public static splitKey(key: string | undefined): string[] {
logger.info(`print :key=${key}`);
if (key) {
return key.split(':');
}
return [];
}
Hello author: I find that I run program appear fatal errro,Beacuse project src file have a bug that sourece
src/lib/ledger-api/state.ts
public async loadParticipant(): Promise<{ participant: Participant, organization: Organization }> { const id = this.getAttributeValue(ID_FIELD); try { logger.info(`print id=${id}`); const participant = await this.ctx.getParticipantList().get(id); logger.info(`print participant=${participant}`); logger.info(`print participant.orgId=${participant.orgId}`); return { organization: await this.ctx.getOrganizationList().get(participant.orgId), participant, }; } catch (err) { throw new Error(`Unable to load participant for client ${id} ERROR: ${err.message}`); } }
I print
participant.orgId===undefined
. I find functionthis.ctx.getOrganizationList().get
to addresssrc/lib/ledger-api/statelist.ts
public async get(key: string): Promise<T> { const ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key)); const data = await this.ctx.stub.getState(ledgerKey); if (data.length === 0) { throw new Error(`Cannot get state. No state exists for key ${key} ${this.name}`); } const state = State.deserialize(data, this.supportedClasses) as T; return state; }
I find
State.splitKey(key)
appear error! beacusekey===undefined
.public static splitKey(key: string | undefined): string[] { logger.info(`print :key=${key}`); if (key) { return key.split(':'); } return []; }
Great bro!Do you know how to solve this BUG?Any help from you will be greatly appreciated!!
Hello author: This is program appear fatal error that I run.