From b1402a83f67c4f66596aeea18d55c8074b9963cb Mon Sep 17 00:00:00 2001 From: Prince Anuragi Date: Tue, 29 Aug 2023 17:23:15 +0530 Subject: [PATCH] feat: added callback function and bigint in transforms --- package.json | 12 +- pnpm-lock.yaml | 173 ---------------- src/ABIForm.tsx | 21 +- src/FunctionForm.tsx | 39 ++-- src/StructForm.tsx | 122 ------------ src/stories/ABIForm.stories.tsx | 342 +++++++++++++++++++++++++------- src/types/dataTypes.ts | 7 +- src/types/helper.ts | 7 +- tailwind.config.js | 2 +- 9 files changed, 327 insertions(+), 398 deletions(-) delete mode 100644 src/StructForm.tsx diff --git a/package.json b/package.json index 597947f..deddc94 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "src/index.ts" ], "treeshake": true, - "sourcemap": "inline", + "sourcemap": true, "minify": true, "clean": true, "dts": true, @@ -47,6 +47,7 @@ "external": [ "react" ], + "outDir": "dist", "injectStyle": false }, "types": "./dist/index.d.ts", @@ -54,11 +55,16 @@ ".": { "require": "./dist/index.js", "import": "./dist/index.mjs" + }, + "./index.css": { + "require": "./dist/index.css", + "import": "./dist/index.css" } }, "files": [ - "dist" + "dist/*" ], + "style": "dist/index.css", "lint-staged": { "./{src,tests}/**/*.{ts,js,jsx,tsx}": [ "eslint --ignore-path .gitignore --fix" @@ -139,7 +145,6 @@ "eslint-plugin-storybook": "0.6.13", "eslint-plugin-typescript-sort-keys": "2.3.0", "eslint-plugin-unused-imports": "3.0.0", - "ethers": "^6.7.1", "formik": "^2.4.3", "husky": "8.0.3", "jsdom": "^22.1.0", @@ -152,7 +157,6 @@ "react-dom": "18.2.0", "react-test-renderer": "18.2.0", "release-it": "16.1.3", - "starknet": "^5.14.1", "storybook": "7.2.1", "tailwindcss": "^3.3.3", "tsup": "7.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0854810..4091735 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -175,9 +175,6 @@ devDependencies: eslint-plugin-unused-imports: specifier: 3.0.0 version: 3.0.0(@typescript-eslint/eslint-plugin@6.3.0)(eslint@8.46.0) - ethers: - specifier: ^6.7.1 - version: 6.7.1 formik: specifier: ^2.4.3 version: 2.4.3(react@18.2.0) @@ -214,9 +211,6 @@ devDependencies: release-it: specifier: 16.1.3 version: 16.1.3 - starknet: - specifier: ^5.14.1 - version: 5.14.1 storybook: specifier: 7.2.1 version: 7.2.1 @@ -258,13 +252,6 @@ packages: } dev: true - /@adraffy/ens-normalize@1.9.2: - resolution: - { - integrity: sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==, - } - dev: true - /@alloc/quick-lru@5.2.0: resolution: { @@ -2922,44 +2909,6 @@ packages: tar-fs: 2.1.1 dev: true - /@noble/curves@1.0.0: - resolution: - { - integrity: sha512-2upgEu0iLiDVDZkNLeFV2+ht0BAVgQnEmCk6JsOch9Rp8xfkMCbvbAZlA2pBHQc73dbl+vFOXfqkf4uemdn0bw==, - } - dependencies: - '@noble/hashes': 1.3.0 - dev: true - - /@noble/hashes@1.1.2: - resolution: - { - integrity: sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==, - } - dev: true - - /@noble/hashes@1.3.0: - resolution: - { - integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==, - } - dev: true - - /@noble/hashes@1.3.2: - resolution: - { - integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==, - } - engines: { node: '>= 16' } - dev: true - - /@noble/secp256k1@1.7.1: - resolution: - { - integrity: sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==, - } - dev: true - /@nodelib/fs.scandir@2.1.5: resolution: { @@ -6455,13 +6404,6 @@ packages: } dev: true - /@types/node@18.15.13: - resolution: - { - integrity: sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==, - } - dev: true - /@types/node@20.4.7: resolution: { @@ -7297,13 +7239,6 @@ packages: regex-parser: 2.2.11 dev: true - /aes-js@4.0.0-beta.5: - resolution: - { - integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==, - } - dev: true - /agent-base@5.1.1: resolution: { @@ -10820,25 +10755,6 @@ packages: engines: { node: '>= 0.6' } dev: true - /ethers@6.7.1: - resolution: - { - integrity: sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA==, - } - engines: { node: '>=14.0.0' } - dependencies: - '@adraffy/ens-normalize': 1.9.2 - '@noble/hashes': 1.1.2 - '@noble/secp256k1': 1.7.1 - '@types/node': 18.15.13 - aes-js: 4.0.0-beta.5 - tslib: 2.4.0 - ws: 8.5.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - /events@3.3.0: resolution: { @@ -13143,18 +13059,6 @@ packages: engines: { node: '>=0.10.0' } dev: true - /isomorphic-fetch@3.0.0: - resolution: - { - integrity: sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==, - } - dependencies: - node-fetch: 2.7.0 - whatwg-fetch: 3.6.17 - transitivePeerDependencies: - - encoding - dev: true - /issue-parser@6.0.0: resolution: { @@ -14117,13 +14021,6 @@ packages: js-tokens: 4.0.0 dev: true - /lossless-json@2.0.11: - resolution: - { - integrity: sha512-BP0vn+NGYvzDielvBZaFain/wgeJ1hTvURCqtKvhr1SCPePdaaTanmmcplrHfEJSJOUql7hk4FHwToNJjWRY3g==, - } - dev: true - /loupe@2.3.6: resolution: { @@ -14408,16 +14305,6 @@ packages: engines: { node: '>= 0.6' } dev: true - /micro-starknet@0.2.3: - resolution: - { - integrity: sha512-6XBcC+GerlwJSR4iA0VaeXtS2wrayWFcA4PEzrJPMuFmWCaUtuGIq5K/DB5F/XgnL54/zl2Bxo690Lj7mYVA8A==, - } - dependencies: - '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.2 - dev: true - /micromatch@4.0.5: resolution: { @@ -15382,13 +15269,6 @@ packages: } dev: true - /pako@2.1.0: - resolution: - { - integrity: sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==, - } - dev: true - /param-case@3.0.4: resolution: { @@ -17742,22 +17622,6 @@ packages: } dev: true - /starknet@5.14.1: - resolution: - { - integrity: sha512-EtJwQ6RmFsqSLGuMP+PRp4DwNsMYXy63HDnd1plLCdQKl3FMYajqNKf5RbDl03uGU0uE5ctGp+OW3firHuv6IA==, - } - dependencies: - '@noble/curves': 1.0.0 - isomorphic-fetch: 3.0.0 - lossless-json: 2.0.11 - micro-starknet: 0.2.3 - pako: 2.1.0 - url-join: 4.0.1 - transitivePeerDependencies: - - encoding - dev: true - /statuses@2.0.1: resolution: { @@ -18636,13 +18500,6 @@ packages: } dev: true - /tslib@2.4.0: - resolution: - { - integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==, - } - dev: true - /tslib@2.6.2: resolution: { @@ -19090,13 +18947,6 @@ packages: punycode: 2.3.0 dev: true - /url-join@4.0.1: - resolution: - { - integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==, - } - dev: true - /url-join@5.0.0: resolution: { @@ -19578,13 +19428,6 @@ packages: iconv-lite: 0.6.3 dev: true - /whatwg-fetch@3.6.17: - resolution: - { - integrity: sha512-c4ghIvG6th0eudYwKZY5keb81wtFz9/WeAHAoy8+r18kcWlitUIrmGFQ2rWEl4UCKUilD3zCLHOIPheHx5ypRQ==, - } - dev: true - /whatwg-mimetype@3.0.0: resolution: { @@ -19865,22 +19708,6 @@ packages: optional: true dev: true - /ws@8.5.0: - resolution: - { - integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==, - } - engines: { node: '>=10.0.0' } - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: true - /xdg-basedir@5.1.0: resolution: { diff --git a/src/ABIForm.tsx b/src/ABIForm.tsx index b8f49b7..879adae 100644 --- a/src/ABIForm.tsx +++ b/src/ABIForm.tsx @@ -2,7 +2,6 @@ import './ABIForm.css'; import React, { useMemo, useState } from 'react'; -import { selector } from 'starknet'; import { ABI, abiSchema } from './types/index'; import { extractFunctionFromRawAbi, @@ -13,11 +12,23 @@ import FunctionForm from './FunctionForm'; import { Content, List, Root, Trigger } from './UIComponents/Tabs/Tabs'; import { ActiveTabClasses, DefaultTabClasses } from './utils/tailwindClasses'; +export type CallbackReturnType = { + functionName: string; + raw: {}; + starkli?: { + bigint: bigint[]; + decimal: string; + hex: string; + }; + stateMutability: 'view' | 'external'; +}; + export type ABIFormProps = { abi?: ABI; + callBackFn: (value: CallbackReturnType) => void; }; -export const ABIForm: React.FC = ({ abi }) => { +export const ABIForm: React.FC = ({ abi, callBackFn }) => { try { abiSchema.validateSync(abi); } catch (e) { @@ -87,9 +98,10 @@ export const ABIForm: React.FC = ({ abi }) => { {viewFunctions.map((viewFn) => ( ))} @@ -97,9 +109,10 @@ export const ABIForm: React.FC = ({ abi }) => { {externalFunctions.map((externalFn) => ( ))} diff --git a/src/FunctionForm.tsx b/src/FunctionForm.tsx index d9bc943..82e981b 100644 --- a/src/FunctionForm.tsx +++ b/src/FunctionForm.tsx @@ -25,6 +25,7 @@ import { flattenToRawCallData, transformStringArrayToInteger, } from './types/helper'; +import { CallbackReturnType } from './ABIForm'; const typeToTagColor = (name: string): TagColors => { try { @@ -57,12 +58,6 @@ const typeToTagColor = (name: string): TagColors => { } }; -type IFunctionForm = { - functionAbi: ABIFunction; - structs: ABIStruct[]; - // enums: ABIEnum[]; -}; - type IParseInputFieldsFromObject = { abiTypes: Record>; errors: Record>; @@ -368,9 +363,17 @@ const ParseInputFieldsFromObject: React.FC = ({ return

Could not parse type!!

; }; +type IFunctionForm = { + callbackFn: (value: CallbackReturnType) => void; + functionAbi: ABIFunction; + structs: ABIStruct[]; + // enums: ABIEnum[]; +}; + const FunctionForm: React.FC = ({ functionAbi, structs, + callbackFn, // enums, }) => { // Check if functionAbi is correct with yup validation schema @@ -401,18 +404,24 @@ const FunctionForm: React.FC = ({ const starkliValues = transformStringArrayToInteger( flattenArrays(flattenToRawCallData(finalValues)) as string[] ); - // @ts-ignore - console.log('final values:', { + + const callbackReturnValues: CallbackReturnType = { raw: finalValues, - starkli: starkliValues, - starkliString: starkliValues.join(' '), - starkliHexString: starkliValues - .map((v) => `0x${v.toString(15)}`) - .join(' '), - }); + functionName: functionAbi?.name, + stateMutability: functionAbi?.state_mutability, + starkli: { + bigint: starkliValues, + decimal: starkliValues.map((v) => v.toString(10)).join(' '), + hex: starkliValues.map((v) => `0x${v.toString(16)}`).join(' '), + }, + }; + callbackFn(callbackReturnValues); } catch (e) { - console.log({ + console.error(e); + callbackFn({ raw: finalValues, + functionName: functionAbi?.name, + stateMutability: functionAbi?.state_mutability, }); } }, diff --git a/src/StructForm.tsx b/src/StructForm.tsx deleted file mode 100644 index c15d449..0000000 --- a/src/StructForm.tsx +++ /dev/null @@ -1,122 +0,0 @@ -// import React from 'react'; -// import { ABIEnum, ABIStruct, yupAbiStructSchema } from './types'; -// import { isACoreType } from './types/dataTypes'; -// import { -// extractSubTypesFromType, -// hasArrayOfSubType, -// hasSubTypes, -// } from './types/helper'; - -// type IStructForm = { -// structParamName: string; -// structAbi: ABIStruct; -// structs?: ABIStruct[]; -// enums?: ABIEnum[]; -// }; - -// const StructForm: React.FC = ({ -// structParamName, -// structAbi, -// structs, -// enums, -// }) => { -// try { -// yupAbiStructSchema.validateSync(structAbi); -// } catch (e) { -// return

Not a valid struct schema

; -// } -// console.log(structAbi); -// return ( -//
-//

-// {structParamName} | {structAbi?.name} -//

-// {structAbi?.members.map((structMember) => { -// if (isACoreType(structMember?.type)) -// return ( -//
-// -// -//
-// ); - -// const structIdx = -// structs?.findIndex((struct) => struct.name === structMember?.type) || -// -1; - -// if (structIdx !== -1 && structs) { -// return ( -// -// ); -// } - -// // Check if is a array -// if (hasArrayOfSubType(structMember?.type)) { -// const isSubTypes = extractSubTypesFromType(structMember?.type); -// if ( -// isSubTypes?.contains && -// isSubTypes?.types && -// isSubTypes?.types?.length > 0 -// ) { -// const arrSubType = isSubTypes?.types[0]; // Safe to take 1 element only, since we can only have homogenous arrays -// console.log(structMember?.name); -// console.log('Found Array of types: ', arrSubType); - -// if (isACoreType(arrSubType)) { -// return ( -//
-// -// -//
-// ); -// } - -// const structIdx = -// structs?.findIndex((struct) => struct.name === arrSubType) || -1; - -// if (structIdx !== -1 && structs) { -// return ( -// `} -// structAbi={structs[structIdx]} -// structs={structs} -// enums={enums} -// /> -// ); -// } -// } -// } - -// // Check if have subTypes -// if (hasSubTypes(structMember?.type)) { -// console.log('Found SubTypes', structMember.type); -// } -// })} -//
-// ); -// }; - -// export default StructForm; diff --git a/src/stories/ABIForm.stories.tsx b/src/stories/ABIForm.stories.tsx index 3a5afb7..75a27b0 100644 --- a/src/stories/ABIForm.stories.tsx +++ b/src/stories/ABIForm.stories.tsx @@ -1931,66 +1931,255 @@ export const Primary = Template.bind({}); // Sample ABI 5 // Goerli Contract Address: 0x07de87b39455a44e4c55e1930d5518e526b14e8f7ed320381ba8cce02a11b533 +// const sampleAbi = [ +// { +// type: 'impl', +// name: 'Balance', +// interface_name: 'scarb_test_2::IBalance', +// }, +// { +// type: 'interface', +// name: 'scarb_test_2::IBalance', +// items: [ +// { +// type: 'function', +// name: 'get', +// inputs: [], +// outputs: [ +// { +// type: 'core::integer::u128', +// }, +// ], +// state_mutability: 'view', +// }, +// { +// type: 'function', +// name: 'increase', +// inputs: [ +// { +// name: 'a', +// type: 'core::integer::u128', +// }, +// ], +// outputs: [], +// state_mutability: 'external', +// }, +// { +// type: 'function', +// name: 'decrease', +// inputs: [ +// { +// name: 'decrease_by', +// type: 'core::integer::u128', +// }, +// ], +// outputs: [], +// state_mutability: 'external', +// }, +// ], +// }, +// { +// type: 'struct', +// name: 'core::integer::u256', +// members: [ +// { +// name: 'low', +// type: 'core::integer::u128', +// }, +// { +// name: 'high', +// type: 'core::integer::u128', +// }, +// ], +// }, +// { +// type: 'enum', +// name: 'core::bool', +// variants: [ +// { +// name: 'False', +// type: '()', +// }, +// { +// name: 'True', +// type: '()', +// }, +// ], +// }, +// { +// type: 'struct', +// name: 'scarb_test_2::Balance::Complex', +// members: [ +// { +// name: 'name', +// type: 'core::integer::u256', +// }, +// { +// name: 'age', +// type: 'core::integer::u16', +// }, +// { +// name: 'status', +// type: 'core::bool', +// }, +// { +// name: 'votes', +// type: 'core::array::Array::', +// }, +// ], +// }, +// { +// type: 'function', +// name: 'complex_input', +// inputs: [ +// { +// name: 'complex', +// type: 'core::array::Array::', +// }, +// ], +// outputs: [], +// state_mutability: 'external', +// }, +// { +// type: 'function', +// name: 'user_input', +// inputs: [ +// { +// name: 'state', +// type: 'core::array::Array::', +// }, +// ], +// outputs: [], +// state_mutability: 'external', +// }, +// { +// type: 'constructor', +// name: 'constructor', +// inputs: [ +// { +// name: 'value_', +// type: 'core::integer::u128', +// }, +// ], +// }, +// { +// type: 'event', +// name: 'scarb_test_2::Balance::Event', +// kind: 'enum', +// variants: [], +// }, +// ]; + +// Sample ABI 6 +// Goerli Contract Address: 0x0571229a6620BaDD612EA5995Ed64F32398C1e552A3dAdAbb8a1758b267Aa450 const sampleAbi = [ { - type: 'impl', - name: 'Balance', - interface_name: 'scarb_test_2::IBalance', + type: 'struct', + name: 'core::integer::u256', + members: [ + { + name: 'low', + type: 'core::integer::u128', + }, + { + name: 'high', + type: 'core::integer::u128', + }, + ], }, { - type: 'interface', - name: 'scarb_test_2::IBalance', - items: [ + type: 'constructor', + name: 'constructor', + inputs: [ { - type: 'function', - name: 'get', - inputs: [], - outputs: [ - { - type: 'core::integer::u128', - }, - ], - state_mutability: 'view', + name: 'initial_supply', + type: 'core::integer::u256', }, { - type: 'function', - name: 'increase', - inputs: [ - { - name: 'a', - type: 'core::integer::u128', - }, - ], - outputs: [], - state_mutability: 'external', + name: 'recipient', + type: 'core::starknet::contract_address::ContractAddress', }, + ], + }, + { + type: 'function', + name: 'name', + inputs: [], + outputs: [ { - type: 'function', - name: 'decrease', - inputs: [ - { - name: 'decrease_by', - type: 'core::integer::u128', - }, - ], - outputs: [], - state_mutability: 'external', + type: 'core::felt252', }, ], + state_mutability: 'view', }, { - type: 'struct', - name: 'core::integer::u256', - members: [ + type: 'function', + name: 'symbol', + inputs: [], + outputs: [ { - name: 'low', - type: 'core::integer::u128', + type: 'core::felt252', }, + ], + state_mutability: 'view', + }, + { + type: 'function', + name: 'decimals', + inputs: [], + outputs: [ { - name: 'high', - type: 'core::integer::u128', + type: 'core::integer::u8', }, ], + state_mutability: 'view', + }, + { + type: 'function', + name: 'total_supply', + inputs: [], + outputs: [ + { + type: 'core::integer::u256', + }, + ], + state_mutability: 'view', + }, + { + type: 'function', + name: 'balance_of', + inputs: [ + { + name: 'account', + type: 'core::starknet::contract_address::ContractAddress', + }, + ], + outputs: [ + { + type: 'core::integer::u256', + }, + ], + state_mutability: 'view', + }, + { + type: 'function', + name: 'allowance', + inputs: [ + { + name: 'owner', + type: 'core::starknet::contract_address::ContractAddress', + }, + { + name: 'spender', + type: 'core::starknet::contract_address::ContractAddress', + }, + ], + outputs: [ + { + type: 'core::integer::u256', + }, + ], + state_mutability: 'view', }, { type: 'enum', @@ -2007,64 +2196,72 @@ const sampleAbi = [ ], }, { - type: 'struct', - name: 'scarb_test_2::Balance::Complex', - members: [ + type: 'function', + name: 'transfer', + inputs: [ { - name: 'name', - type: 'core::integer::u256', + name: 'recipient', + type: 'core::starknet::contract_address::ContractAddress', }, { - name: 'age', - type: 'core::integer::u16', + name: 'amount', + type: 'core::integer::u256', }, + ], + outputs: [ { - name: 'status', type: 'core::bool', }, - { - name: 'votes', - type: 'core::array::Array::', - }, ], + state_mutability: 'external', }, { type: 'function', - name: 'complex_input', + name: 'transfer_from', inputs: [ { - name: 'complex', - type: 'core::array::Array::', + name: 'sender', + type: 'core::starknet::contract_address::ContractAddress', + }, + { + name: 'recipient', + type: 'core::starknet::contract_address::ContractAddress', + }, + { + name: 'amount', + type: 'core::integer::u256', + }, + ], + outputs: [ + { + type: 'core::bool', }, ], - outputs: [], state_mutability: 'external', }, { type: 'function', - name: 'user_input', + name: 'approve', inputs: [ { - name: 'state', - type: 'core::array::Array::', + name: 'spender', + type: 'core::starknet::contract_address::ContractAddress', + }, + { + name: 'amount', + type: 'core::integer::u256', }, ], - outputs: [], - state_mutability: 'external', - }, - { - type: 'constructor', - name: 'constructor', - inputs: [ + outputs: [ { - name: 'value_', - type: 'core::integer::u128', + type: 'core::bool', }, ], + state_mutability: 'external', }, { type: 'event', - name: 'scarb_test_2::Balance::Event', + name: 'erc20::MyToken::Event', kind: 'enum', variants: [], }, @@ -2072,4 +2269,7 @@ const sampleAbi = [ Primary.args = { abi: sampleAbi, + callBackFn: (value) => { + console.log({ storybook: value }); + }, }; diff --git a/src/types/dataTypes.ts b/src/types/dataTypes.ts index 32f35c9..38c5f18 100644 --- a/src/types/dataTypes.ts +++ b/src/types/dataTypes.ts @@ -1,4 +1,3 @@ -import { uint256 } from 'starknet'; import { BigNumber } from 'bignumber.js'; import * as Yup from 'yup'; @@ -36,9 +35,11 @@ function validateCoreType(type: string, val: string): boolean { case 'core::integer::u64': return value.lte(2 ** 64 - 1); case 'core::integer::u128': - return value.lte(uint256.UINT_128_MAX.toString()); + return value.lte('340282366920938463463374607431768211455'); case 'core::felt252': - return value.lte(uint256.UINT_128_MAX.toString()); + return value.lte( + '3618502788666131213697322783095070105623107215331596699973092056135872020480' + ); case 'core::starknet::contract_address::ContractAddress': // TODO: Add Proper Validation for address here. return true; diff --git a/src/types/helper.ts b/src/types/helper.ts index 508d367..fe50896 100644 --- a/src/types/helper.ts +++ b/src/types/helper.ts @@ -112,13 +112,10 @@ export function extractSubTypesFromType(type: string): ReturnExtractedSubTypes { export const flattenArrays = (value: any) => _.flattenDeep(value); -export const transformStringArrayToInteger = (value: string[]): number[] => +export const transformStringArrayToInteger = (value: string[]): bigint[] => value.map((lValue) => { if (typeof lValue === 'string') { - if (!Number.isNaN(parseInt(lValue, 10))) { - return parseInt(lValue, 10); - } - return Number.NaN; + return BigInt(lValue); } return lValue; }); diff --git a/tailwind.config.js b/tailwind.config.js index 86689c9..79e640b 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ['./src/**/*.{jsx,js,ts,tsx}'], + content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'], theme: { extend: { keyframes: {