Skip to content

Commit

Permalink
handle multiple skip conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
joegeorge-git committed Oct 24, 2024
1 parent e71caec commit 560a261
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
96 changes: 48 additions & 48 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
interface TransactionItem {
canisterId: string;
methodName: string;
args: any;
idl: any;
onSuccess: any;
onFail: any;
updateNextStep: any;
skipCondition:string
canisterId: string;
methodName: string;
args: any;
idl: any;
onSuccess: any;
onFail: any;
updateNextStep: any;
skipCondition: string | string[];
}
type BatchTransactType = {
[key: string]: TransactionItem[];
[key: string]: TransactionItem[];
};

type ConnectObjType = { host: string; whitelist: string[] }
type ConnectObjType = {host: string; whitelist: string[]};

const Artemis = class Artemis {
constructor(connectObj?: ConnectObjType);
accountId: string;
principalId: string;
walletActive: string;
provider: any;
balance: number;
wallets: [];
canisterActors: {};
connectedWalletInfo: { id: string, icon: string, name: string };
connect(wallet: string, connectObj?: ConnectObjType):Promise<string> ;
autoConnect(connectObj?: ConnectObjType): Promise<string>;
disconnect(): Promise<any>;
isLoaded(): Promise<any>;
getWalletBalance(returnType: string): Promise<number>;
requestICPTransfer(transferRequest: any): Promise<any>;
getCanisterActor(canisterId: string, idl: any, isAnon: boolean , isForced?:boolean): Promise<any>;
batchTransact(transactions: BatchTransactType): Promise<any>;
trxArray:[TransactionItem[]]
}
constructor(connectObj?: ConnectObjType);
accountId: string;
principalId: string;
walletActive: string;
provider: any;
balance: number;
wallets: [];
canisterActors: {};
connectedWalletInfo: {id: string; icon: string; name: string};
connect(wallet: string, connectObj?: ConnectObjType): Promise<string>;
autoConnect(connectObj?: ConnectObjType): Promise<string>;
disconnect(): Promise<any>;
isLoaded(): Promise<any>;
getWalletBalance(returnType: string): Promise<number>;
requestICPTransfer(transferRequest: any): Promise<any>;
getCanisterActor(canisterId: string, idl: any, isAnon: boolean, isForced?: boolean): Promise<any>;
batchTransact(transactions: BatchTransactType): Promise<any>;
trxArray: [TransactionItem[]];
};

const BatchTransact = class BatchTransact {
state: 'idle' | 'running' | 'error' | 'done';
transactionLlist: BatchTransactType;
stepsList: string[];
pending: string[];
completed: string[];
previousStep: string;
activeStep: string;
nextStep: ()=>void;
failedSteps: string[];
transactionResults: {};
trxArray:[];
execute(): any;
retryExecute(): any;
constructor(transactionList: any, artemis: Artemis)
}
state: "idle" | "running" | "error" | "done";
transactionLlist: BatchTransactType;
stepsList: string[];
pending: string[];
completed: string[];
previousStep: string;
activeStep: string;
nextStep: () => void;
failedSteps: string[];
transactionResults: {};
trxArray: [];
execute(): any;
retryExecute(): any;
constructor(transactionList: any, artemis: Artemis);
};

const principalIdFromHex:(params:string)=> {};
declare module 'artemis-web3-adapter' {
export { Artemis , BatchTransact , principalIdFromHex , ArtemisAdapter , TransactionItem , BatchTransactType}
}
const principalIdFromHex: (params: string) => {};
declare module "artemis-web3-adapter" {
export {Artemis, BatchTransact, principalIdFromHex, ArtemisAdapter, TransactionItem, BatchTransactType};
}
3 changes: 2 additions & 1 deletion src/libs/batchTransact.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const BatchTransaction = class BatchTransaction {
const onSucessCall = el.onSuccess;
const onFailCall = el.onError;
const ErrorStat = data.err ? data.err : data.Err ? data.Err : data.ERR;
if (ErrorStat && (JSON.stringify(ErrorStat) != el?.skipCondition)) {
if (ErrorStat && !el?.skipCondition.includes((JSON.stringify(ErrorStat)))) {
self.failedSteps.push(self.stepsList[stepIndex]);
self.transactionResults[self.stepsList[stepIndex]] = ErrorStat;
self.state = 'error';
Expand All @@ -67,6 +67,7 @@ export const BatchTransaction = class BatchTransaction {
self.activeStep = self.stepsList[stepIndex];
self.state = 'error';
_this.state = 'error';
self._info = err;
if (onFailCall) await onFailCall(err)
return false;
}
Expand Down

0 comments on commit 560a261

Please sign in to comment.