Skip to content

Commit 043df32

Browse files
committed
Add support for handling CEP-18 entry points and improve TxSignatureRequestDto logic with isCep18Action validation
1 parent a6da935 commit 043df32

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/data/dto/txSignatureRequest/TxSignatureRequestDto.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
AssociatedKeysContractInfo,
66
AuctionManagerContractInfo,
77
CasperNetwork,
8+
CEP_18_ACTION_ENTRY_POINTS,
89
CSPR_COIN,
910
CSPRMarketContractInfo,
1011
IAccountInfo,
@@ -188,10 +189,7 @@ export function getTxSignatureRequestAction(
188189
contractPackage,
189190
collectionContractPackage,
190191
);
191-
} else if (
192-
contractTypeId === ContractTypeId.CustomCep18 ||
193-
contractTypeId === ContractTypeId.Cep18
194-
) {
192+
} else if (isCep18Action(tx, contractTypeId)) {
195193
return getTxSignatureRequestCep18Action(tx, accountInfoMap, contractPackage);
196194
} else if (
197195
contractTypeId === ContractTypeId.CEP78Nft ||
@@ -263,3 +261,12 @@ function isContractSpecificContractCall(tx: Transaction, contractInfo: IContract
263261
storedTargetId?.byPackageName?.name === contractInfo.contractPackageName
264262
);
265263
}
264+
265+
function isCep18Action(tx: Transaction, contractTypeId?: number): boolean {
266+
const entryPoint = tx.entryPoint.customEntryPoint ?? '';
267+
268+
return (
269+
(contractTypeId === ContractTypeId.CustomCep18 || contractTypeId === ContractTypeId.Cep18) &&
270+
CEP_18_ACTION_ENTRY_POINTS.includes(entryPoint.toLowerCase())
271+
);
272+
}

src/domain/constants/casperNetwork.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,14 @@ export const casperChainNameToCasperNetwork: Record<CasperNetworkName, CasperNet
219219
[CasperNetworkName.DevNet]: 'devnet',
220220
[CasperNetworkName.Integration]: 'integration',
221221
};
222+
223+
export const CEP_18_ACTION_ENTRY_POINTS = [
224+
'transfer',
225+
'approve',
226+
'transfer_from',
227+
'init',
228+
'increase_allowance',
229+
'decrease_allowance',
230+
'mint',
231+
'burn',
232+
];

0 commit comments

Comments
 (0)