Skip to content

Commit 2e8f526

Browse files
committed
feat(accs): add .evmContract function and simply the APIs
1 parent 4859fc8 commit 2e8f526

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

packages/access-control-conditions/src/lib/createAccBuilder.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,27 @@ class AccessControlConditionBuilder implements AccBuilder {
561561

562562
this.pendingCondition = {
563563
conditionType: 'evmBasic',
564-
contractAddress: p.contractAddress as string,
565-
standardContractType: p.standardContractType as StandardContractType,
566-
method: p.method as string,
567-
parameters: p.parameters as string[],
568-
returnValueTest: p.returnValueTest as any,
569-
} as Partial<EvmBasicAcc>;
564+
...p,
565+
};
566+
567+
this.setChain(p.chain as EvmChain);
568+
return this;
569+
}
570+
571+
evmContract(
572+
params: Omit<EvmContractAcc, 'conditionType'>
573+
): AccBuilder {
574+
const p = params as Partial<EvmContractAcc>;
575+
576+
// For raw evmContract, chain must be provided in params
577+
if (!p.chain) {
578+
throw new Error('Chain must be specified in params for evmContract method');
579+
}
580+
581+
this.pendingCondition = {
582+
conditionType: 'evmContract',
583+
...p,
584+
};
570585

571586
this.setChain(p.chain as EvmChain);
572587
return this;
@@ -584,13 +599,8 @@ class AccessControlConditionBuilder implements AccBuilder {
584599

585600
this.pendingCondition = {
586601
conditionType: 'solRpc',
587-
method: p.method as string,
588-
params: p.params as string[],
589-
pdaParams: p.pdaParams as string[],
590-
pdaInterface: p.pdaInterface as any,
591-
pdaKey: p.pdaKey as string,
592-
returnValueTest: p.returnValueTest as any,
593-
} as Partial<SolAcc>;
602+
...p,
603+
};
594604

595605
this.setChain(p.chain as SolanaChain);
596606
return this;
@@ -608,9 +618,8 @@ class AccessControlConditionBuilder implements AccBuilder {
608618

609619
this.pendingCondition = {
610620
conditionType: 'cosmos',
611-
path: p.path as string,
612-
returnValueTest: p.returnValueTest as any,
613-
} as Partial<AtomAcc>;
621+
...p,
622+
};
614623

615624
this.setChain(p.chain as CosmosChain);
616625
return this;

0 commit comments

Comments
 (0)