Skip to content

Commit

Permalink
feat: added callback function and bigint in transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
prix0007 committed Aug 29, 2023
1 parent 73ce00d commit b1402a8
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 398 deletions.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"src/index.ts"
],
"treeshake": true,
"sourcemap": "inline",
"sourcemap": true,
"minify": true,
"clean": true,
"dts": true,
Expand All @@ -47,18 +47,24 @@
"external": [
"react"
],
"outDir": "dist",
"injectStyle": false
},
"types": "./dist/index.d.ts",
"exports": {
".": {
"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"
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
173 changes: 0 additions & 173 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions src/ABIForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<ABIFormProps> = ({ abi }) => {
export const ABIForm: React.FC<ABIFormProps> = ({ abi, callBackFn }) => {
try {
abiSchema.validateSync(abi);
} catch (e) {
Expand Down Expand Up @@ -87,19 +98,21 @@ export const ABIForm: React.FC<ABIFormProps> = ({ abi }) => {
<Content value="read">
{viewFunctions.map((viewFn) => (
<FunctionForm
key={`viewFn${selector.getSelectorFromName(viewFn?.name)}`}
key={`viewFn-${viewFn.name}`}
functionAbi={viewFn}
structs={structs}
callbackFn={callBackFn}
// enums={enums}
/>
))}
</Content>
<Content value="write">
{externalFunctions.map((externalFn) => (
<FunctionForm
key={`externalFn${selector.getSelectorFromName(externalFn?.name)}`}
key={`externalFn-${externalFn.name}`}
functionAbi={externalFn}
structs={structs}
callbackFn={callBackFn}
// enums={enums}
/>
))}
Expand Down
Loading

0 comments on commit b1402a8

Please sign in to comment.