git.delta.rocks / unique-network / refs/commits / 4a02655589a8

difftreelog

feat catch dispatchError in playgrounds

Daniel Shiposha2022-10-06parent: #a693ced.patch.diff
in: master

2 files changed

modifiedtests/src/util/playgrounds/types.tsdiffbeforeafterboth
14export interface ITransactionResult {14export interface ITransactionResult {
15 status: 'Fail' | 'Success';15 status: 'Fail' | 'Success';
16 result: {16 result: {
17 dispatchError: any,
17 events: {18 events: {
18 phase: any, // {ApplyExtrinsic: number} | 'Initialization',19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',
19 event: IEvent;20 event: IEvent;
47 call: string;48 call: string;
48 params: any[];49 params: any[];
49 moduleError?: string;50 moduleError?: string;
51 dispatchError?: any;
50 events?: any;52 events?: any;
51}53}
5254
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
514 params,514 params,
515 } as IUniqueHelperLog;515 } as IUniqueHelperLog;
516516
517 if(result.status !== this.transactionStatus.SUCCESS && result.moduleError) log.moduleError = result.moduleError;517 if(result.status !== this.transactionStatus.SUCCESS) {
518 if (result.moduleError) log.moduleError = result.moduleError;
519 else if (result.result.dispatchError) log.dispatchError = result.result.dispatchError;
520 }
518 if(events.length > 0) log.events = events;521 if(events.length > 0) log.events = events;
519522
520 this.chainLog.push(log);523 this.chainLog.push(log);
521524
522 if(expectSuccess && result.status !== this.transactionStatus.SUCCESS) throw Error(`${result.moduleError}`);525 if(expectSuccess && result.status !== this.transactionStatus.SUCCESS) {
526 if (result.moduleError) throw Error(`${result.moduleError}`);
527 else if (result.result.dispatchError) throw Error(JSON.stringify(result.result.dispatchError));
528 }
523 return result;529 return result;
524 }530 }
525531