Skip to content

Fixes & chain improvements #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.19.0
nodejs 20.13.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CHAINLINK_BASEURL=http://localhost:6688 yarn start

Now navigate to http://localhost:3000.

If sign-in doesn't work, check your network console, it's probably a CORS issue. You may need to run your chainlink node with `ALLOW_ORIGINS=http://localhost:3000` set.
If sign-in doesn't work, check your network console, it's probably a CORS issue. You may need to run your chainlink node with `[WebServer] AllowOrigins=http://localhost:3000` set in TOML config.

## Running Tests

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"artifacts"
],
"engines": {
"node": "^18.0.0"
"node": "^20.0.0"
},
"scripts": {
"lint": "eslint --ext js,jsx,ts,tsx .",
Expand Down
2 changes: 1 addition & 1 deletion src/Private.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Private = ({ classes }: { classes: { content: string } }) => {
<ChainsScreen />
</PrivateRoute>

<PrivateRoute path="/chains/:chainId">
<PrivateRoute path="/chains/:network/:chainId">
<ChainShow />
</PrivateRoute>

Expand Down
32 changes: 0 additions & 32 deletions src/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,45 +333,13 @@ const RECEIVE_CREATE_SUCCESS_ACTION = {
type: ResourceActionType.RECEIVE_CREATE_SUCCESS,
}

const receiveDeleteSuccess = (id: string) =>
({
type: ResourceActionType.RECEIVE_DELETE_SUCCESS,
id,
} as const)

export const submitSignIn = (data: Parameter<Sessions['createSession']>) =>
sendSignIn(data)

export const submitSignOut = () => sendSignOut

export const beginRegistration = () => sendBeginRegistration()

export const deleteChain = (
id: string,
successCallback: React.ReactNode,
errorCallback: React.ReactNode,
) => {
return (dispatch: Dispatch) => {
dispatch({ type: ResourceActionType.REQUEST_DELETE })

const endpoint = api.v2.chains

return endpoint
.destroyChain(id)
.then((doc) => {
dispatch(receiveDeleteSuccess(id))
dispatch(notifySuccess(successCallback, doc))
})
.catch((error: Errors) => {
curryErrorHandler(
dispatch,
ResourceActionType.RECEIVE_DELETE_ERROR,
)(error)
dispatch(notifyError(errorCallback, error))
})
}
}

export const createJobRunV2 = (
id: string,
pipelineInput: string,
Expand Down
52 changes: 10 additions & 42 deletions src/api/v2/chains.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,20 @@
import * as jsonapi from 'utils/json-api-client'
import * as models from 'core/store/models'

export const ENDPOINT = '/v2/chains/evm'
const UPDATE_ENDPOINT = `${ENDPOINT}/:id`
export const ENDPOINT = '/v2/chains/:network'

export class Chains {
constructor(private api: jsonapi.Api) {}

public getChains = (): Promise<jsonapi.ApiResponse<models.Chain[]>> => {
return this.index()
}

public createChain = (
request: models.CreateChainRequest,
): Promise<jsonapi.ApiResponse<models.Chain>> => {
return this.create(request)
}

public destroyChain = (id: string): Promise<jsonapi.ApiResponse<null>> => {
return this.destroy(undefined, { id })
public getChains = (
network: string,
): Promise<jsonapi.ApiResponse<models.Chain[]>> => {
return this.index(undefined, { network })
}

public updateChain = (
id: string,
req: models.UpdateChainRequest,
): Promise<jsonapi.ApiResponse<models.Chain>> => {
return this.update(req, { id })
}

private index = this.api.fetchResource<object, models.Chain[]>(ENDPOINT)

private create = this.api.createResource<
models.CreateChainRequest,
models.Chain
private index = this.api.fetchResource<
object,
models.Chain[],
{ network: string }
>(ENDPOINT)

private destroy = this.api.deleteResource<
undefined,
null,
{
id: string
}
>(UPDATE_ENDPOINT)

private update = this.api.updateResource<
models.UpdateChainRequest,
models.Chain,
{
id: string
}
>(UPDATE_ENDPOINT)
}
9 changes: 9 additions & 0 deletions src/components/Form/ChainConfigurationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ describe('ChainConfigurationForm', () => {
solanaKeys: {
results: [],
},
starknetKeys: {
results: [],
},
tronKeys: {
results: [],
},
Expand Down Expand Up @@ -408,6 +411,9 @@ test('should be able to select OCR2 Job Type with Key Bundle ID', async () => {
solanaKeys: {
results: [],
},
starknetKeys: {
results: [],
},
tronKeys: {
results: [],
},
Expand Down Expand Up @@ -484,6 +490,9 @@ function renderChainConfigurationForm(
solanaKeys: {
results: [{ id: 'solana_xxxx' }],
},
starknetKeys: {
results: [{ id: 'starknet_xxxx' }],
},
tronKeys: {
results: [{ id: 'tron_xxxx' }],
},
Expand Down
12 changes: 6 additions & 6 deletions src/components/Form/ChainConfigurationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export type FormValues = {
ocr2RebalancerPluginEnabled: boolean
}

const isStarknet = (chainID: string): boolean => {
return chainID === 'SN_MAIN' || chainID === 'SN_SEPOLIA'
const isStarknet = (chainType: string): boolean => {
return chainType === 'STARKNET'
}

const ValidationSchema = Yup.object().shape({
Expand Down Expand Up @@ -117,7 +117,7 @@ interface AccountAddrFieldProps extends FieldAttributes<any> {

const AccountAddrField = ({ addresses, ...props }: AccountAddrFieldProps) => {
const {
values: { chainID, accountAddr },
values: { chainID, chainType, accountAddr },
setFieldValue,
} = useFormikContext<FormValues>()

Expand Down Expand Up @@ -148,7 +148,7 @@ const AccountAddrField = ({ addresses, ...props }: AccountAddrFieldProps) => {

return (
<>
{!isStarknet(chainID) && (
{!isStarknet(chainType) && (
<Field
{...props}
select
Expand All @@ -162,7 +162,7 @@ const AccountAddrField = ({ addresses, ...props }: AccountAddrFieldProps) => {
))}
</Field>
)}
{isStarknet(chainID) && (
{isStarknet(chainType) && (
<Field
component={TextField}
id="accountAddr"
Expand All @@ -174,7 +174,7 @@ const AccountAddrField = ({ addresses, ...props }: AccountAddrFieldProps) => {
fullWidth
/>
)}
{isStarknet(chainID) && (
{isStarknet(chainType) && (
<div>
<Field
component={TextField}
Expand Down
12 changes: 12 additions & 0 deletions src/hooks/queries/useNonEvmAccountsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export const SOLANA_KEYS_PAYLOAD__RESULTS_FIELDS = gql`
}
`

export const STARKNET_KEYS_PAYLOAD__RESULTS_FIELDS = gql`
fragment StarknetKeysPayload_ResultsFields on StarkNetKey {
id
}
`

export const TRON_KEYS_PAYLOAD__RESULTS_FIELDS = gql`
fragment TronKeysPayload_ResultsFields on TronKey {
id
Expand All @@ -22,6 +28,7 @@ export const TRON_KEYS_PAYLOAD__RESULTS_FIELDS = gql`
export const NON_EVM_KEYS_QUERY = gql`
${APTOS_KEYS_PAYLOAD__RESULTS_FIELDS}
${SOLANA_KEYS_PAYLOAD__RESULTS_FIELDS}
${STARKNET_KEYS_PAYLOAD__RESULTS_FIELDS}
${TRON_KEYS_PAYLOAD__RESULTS_FIELDS}
query FetchNonEvmKeys {
aptosKeys {
Expand All @@ -34,6 +41,11 @@ export const NON_EVM_KEYS_QUERY = gql`
...SolanaKeysPayload_ResultsFields
}
}
starknetKeys {
results {
...StarknetKeysPayload_ResultsFields
}
}
tronKeys {
results {
...TronKeysPayload_ResultsFields
Expand Down
Loading
Loading