-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat(transfer): javascript playground #624
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Ignored Deployments
|
9587a5a
to
bffeff4
Compare
5c39a8d
to
5daf4b1
Compare
85033bc
to
acfe6d4
Compare
There are some conflicting files. Can we resolve these and try again? From checking the screenshot @sstraatemans provided (see below) I cant really see the problem. Could have to do with the versioning of the client |
e7c9ac2
to
bad545f
Compare
379add2
to
714c1f1
Compare
cd3b6bc
to
35d679b
Compare
export interface IAceEditorProps { | ||
code?: string; | ||
width?: string; | ||
height?: string; | ||
readonly?: boolean; | ||
onChange?: IOnchange; | ||
} | ||
|
||
const AceViewerComponent: FC<IAceEditorProps> = ({ code }) => ( | ||
const AceViewerComponent: FC<IAceEditorProps> = ({ | ||
code, | ||
width, | ||
height, | ||
readonly, | ||
onChange, | ||
}) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know Ace Editor has support for Vim-mode. Can we enable that with a toggle? Not blocking for this PR, just a thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. Only code review, not execution
const client = getClient(); | ||
|
||
export default client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's preferred to use named exports. It's easier to resolve a missing import that way. Also making it a bit more specific might help to distinguish from other clients.
const client = getClient(); | |
export default client; | |
export const kadenaClient = getClient(); |
const result = (await fundExistingAccount( | ||
accountName, | ||
chainID, | ||
AMOUNT_OF_COINS_FUNDED, | ||
)) as IFundExistingAccountResponse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this type be set in the fundExistingAccount
function?
|
||
const FunctionPage: FC = () => { | ||
Debug('kadena-transfer:pages:transfer:module-explorer:module:function'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this being used?
Usually you assign the return value to a variable to use in other places.
This can be assigned outside the component as it doesn't change in other components
const FunctionPage: FC = () => { | |
Debug('kadena-transfer:pages:transfer:module-explorer:module:function'); | |
const log = Debug('kadena-transfer:pages:transfer:module-explorer:module:function'); | |
const FunctionPage: FC = () => { | |
log('executing FunctionPage'); // example |
import React, { FC, useEffect, useState } from 'react'; | ||
|
||
const ModulePage: FC = () => { | ||
Debug('kadena-transfer:pages:transfer:module-explorer:module'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
const apiHost = getKadenaConstantByNetwork('TESTNET').apiHost({ | ||
networkId: NETWORK_ID, | ||
chainId, | ||
}); | ||
|
||
await transactionBuilder.send(apiHost); | ||
transaction.sigs = [{ sig: signature1.sig }, { sig: signature2.sig }]; | ||
|
||
return await transactionBuilder.pollUntil(apiHost, { | ||
onPoll, | ||
}); | ||
const { submit, pollStatus } = getClient(apiHost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this work with WalletConnect? Take the network from the walletconnect settings, this will open up using this on the devnet as well.
Might be better to do in a next PR though
return await local(transaction, { | ||
preflight: false, | ||
signatureVerification: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use dirtyRead
from getClient
@@ -26,27 +25,29 @@ export const listModules = async ( | |||
ttl: number = kadenaConstants.API_TTL, | |||
): Promise<IModulesResult> => { | |||
debug(listModules.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
const response = await local(transaction, { | ||
preflight: false, | ||
signatureVerification: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
const response = await local(transaction, { | ||
preflight: false, | ||
signatureVerification: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
const response = await local(transaction, { | ||
preflight: false, | ||
signatureVerification: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. Only code review, not execution
This PR is stale because it is open for 60 days with no activity |
Ticket
This PR updates the depency on
@kadena/client
to the latest (~1.0.0) version. Also, it extends the module explorer functinoality with a JavaScript playground. It should be considered if the module explorer extension should better be moved to another PR and limit the current PR to just the kadena client version update.The approach to the module explorer and the JavaScript playground is as follows.
Routing
Users can search modules on any chain by typing in the search field. Below the form, a list of modules in the selected the chain are displayed, filtered on the search query. Clicking on any module name will navigate the user to a
/module-explorer/networks/{network}/chains/{chain/modules/{moduleName}
route. On the respective page, the pact code as well as a list of functions, capabilities and interfaces are displayed. Clicking on a function name will navigate the user to a/module-explorer/networks/{network}/chains/{chain/modules/{moduleName}/functions/{function}
route. This page contains a code editor and a readonly output frame.Evaluating user provided JavaScript
A user can enter JavaScript code in the editor and click the "Run" button to execute the JavaScript. the
scopedEval
npm package is used to execute the user provided JavaScript within the scope of the application. For security purposes, only{ Pact, getClient, signWithChainweaver, isSignedCommand }
from the@kadena/client
as well as a simple Logger to display output are available in the scope where the user provided JavaScript is executed in. This approach does require a thorough evaluation with regard to security.Example code snippets
The codebase contains many example code snippets, e.g. in the cookbook and the client-examples directory. It could help the onboarding of new developers on the Kadena platform, if we could provide example code snippets for use in the aforementioned JavaScript editor. This would require a way to match example code snippets to the function that someone wants to use. As a proof of concept I have created a git repository on my own github account with a directory structure that mirrors the routing of the module explorer described above. If we agree on this approach, we should probably find a good central location for the example code snippets in this kadena repository. To give an example of how it works, there is an example script for the get-balance function of the coin module on chain 9 of TESTNET located in /networks/TESTNET/chains/9/modules/coin/functions/get-balance.js. If the transfer app can find this file, it will show a button "Load example code". When it is clicked, the example code from the git repository will be loaded into the code editor and can be executed by clicking the "Run" button. It could also be an idea to turn the
get-balance.js
file into a./get-balance
directory containing multiple example snippets for the function at hand. Maintainability of this approach needs to be discussed, because it may not be practical to maintain example snippets separately for every chain in case a Pact module is deployed on all chains. On the other hand, A module with the same name may have a different implementation on another chain.to do