Skip to content

Commit

Permalink
reset eslint, remove debug statements, remove array return type
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanGodara committed May 3, 2024
1 parent f921352 commit fb94876
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 47 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules/
dist/
www/
src/
www/
35 changes: 3 additions & 32 deletions __tests__/utils/calldataDecode.test.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,18 @@
import { DecodeConfig } from '../../src/types';

import {
// Account,
BigNumberish,
CairoUint256,
// CairoCustomEnum,
// CairoOption,
// CairoOptionVariant,
// CairoResult,
// CairoResultVariant,
// CairoUint256,
// CairoUint512,
CallData,
Calldata,
// CompiledSierra,
// Contract,
// DeclareDeployUDCResponse,
RawArgsArray,
RawArgsObject,
// byteArray,
cairo,
// ec,
// hash,
// num,
// selector,
// shortString,
// stark,
// types,
// type Uint512,
} from '../../src';

import {
// compiledC1v2,
// compiledHelloSierra,
compiledComplexSierra,
} from '../config/fixtures';
import { compiledComplexSierra } from '../config/fixtures';

const {
// uint256,
tuple,
// isCairo1Abi
} = cairo;
const { tuple } = cairo;

describe('Cairo 1', () => {
test('should correctly compile and decompile complex data structures', async () => {
Expand Down Expand Up @@ -135,10 +107,9 @@ describe('Cairo 1', () => {
'constructor',
compiledDataFromArray,
config,
true
);

expect(decompiledDataFromObject).toEqual(myRawArgsObject);
expect(decompiledDataFromArray).toEqual(myRawArgsArray);
expect(decompiledDataFromArray).toEqual(myRawArgsObject);
});
});
4 changes: 0 additions & 4 deletions src/utils/calldata/calldataDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function decodeBaseTypes(
case isTypeUint(type):
switch (true) {
case CairoUint256.isAbiType(type):
console.log('got 256 uint value');
const low = it.next().value;
const high = it.next().value;

Expand Down Expand Up @@ -134,7 +133,6 @@ function decodeBaseTypes(

case isTypeFelt(type):
temp = String(it.next().value);
console.log('Original temp = ', temp);
const configFeltConstructor = config?.['core::felt252'];
if (configFeltConstructor) {
if (configFeltConstructor === String) return decodeShortString(temp);
Expand All @@ -145,7 +143,6 @@ function decodeBaseTypes(
return BigInt(temp);

default:
console.log('went to default block for ');
temp = it.next().value;
return BigInt(temp);
}
Expand Down Expand Up @@ -294,7 +291,6 @@ function decodeCalldataValue(
parsedDataArr.push(val);
}
}
console.log('Returning array: ', parsedDataArr);
const configConstructor = config?.[element.name];
if (configConstructor) {
const concatenatedString = parsedDataArr.join('');
Expand Down
9 changes: 0 additions & 9 deletions src/utils/calldata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ export class CallData {
method: string,
calldata: string[],
config?: DecodeConfig,
returnArray?: boolean
): RawArgs {
const abiMethod = this.abi.find(
(entry) => entry.name === method && entry.type === 'function'
Expand All @@ -273,14 +272,6 @@ export class CallData {
return acc;
}, {} as RawArgsObject);

if (returnArray === true) {
const decodedArgsArray: RawArgsArray = [];
abiMethod.inputs.forEach((input) => {
const value = decodedArgs[input.name];
decodedArgsArray.push(value);
});
}

return decodedArgs;
}

Expand Down

0 comments on commit fb94876

Please sign in to comment.