-
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
[ON-HOLD] feat: initial commit for kadena ledger lib #2458
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
<div> | ||
<button | ||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" | ||
onClick={() => openApp().then(() => setOpenAppResult('success'))} |
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.
onClick={async () => {
await openApp();
setOpenAppResult('success');
}}
<div> | ||
<button | ||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" | ||
onClick={() => |
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.
onClick={async () => {
const result = await getPublicKey(0);
setGetPublicKeyResult(result);
}}
<div> | ||
<button | ||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" | ||
onClick={() => getVersion().then((x) => setGetVersionResult(x))} |
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.
onClick={async () => {
const result = await getVersion();
setGetVersionResult(result);
}}
<div> | ||
<button | ||
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" | ||
onClick={() => |
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.
onClick={async () => {
const result = await signTransaction(0, 'transfer', {
recipient: '2017fee3fb15cfe840e5ed34bf101cc7d5579ffdd20dea09e32fd77c1757f946',
recipientChainId: '0',
networkId: 'testnet04',
amount: 0.1,
namespace_: '',
module_: '',
gasPrice: '1.0e-6',
gasLimit: '2300',
creationTime: '1723017869',
chainId: '0',
nonce: '',
ttl: '600',
type: 'transfer',
});
setSignTransactionResult(result);
}}
0x00, | ||
Buffer.from('Kadena', 'ascii'), | ||
); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); |
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 still don't know why this is here and it probably should not bere here, since is does not make sense.
@@ -0,0 +1,9 @@ | |||
import { StrictMode } from 'react'; |
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.
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './app.tsx';
const root = createRoot(document.getElementById('root')!);
root.render(
<StrictMode>
<App />
</StrictMode>,
);
@@ -0,0 +1,33 @@ | |||
import { KadenaLedger } from './ledger'; |
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.
add return types:
import { KadenaLedger } from './ledger';
import { TransactionParams } from './transaction';
let ledger: KadenaLedger | null = null;
async function getLedger(): Promise<KadenaLedger> {
if (!ledger) ledger = await KadenaLedger.findDevice();
return ledger;
}
export async function openApp(): Promise<void> {
const ledger = await getLedger();
return await ledger.openApp();
}
export async function getPublicKey(index: number): Promise<string> {
const ledger = await getLedger();
return await ledger.getPublicKey(index);
}
export async function signTransaction(
index: number,
type: 'transfer' | 'cross-chain-transfer',
params: TransactionParams,
): Promise<string> {
const ledger = await getLedger();
return await ledger.signTransaction(index, type, params);
}
export async function getVersion(): Promise<string> {
const ledger = await getLedger();
return await ledger.getVersion();
}
[StatusCodes.OK, 0x6e01], // 0x6e01 = already open | ||
); | ||
// Opening the app makes the device reconnect, wait a moment for this | ||
await new Promise((resolve) => setTimeout(resolve, 500)); |
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.
that's should be done more smarter, the reconnecting' isn't. there a event available we can listen to, this doesn't seem very error prone
appName: string; | ||
}> { | ||
const response = await this.transport.send( | ||
0x00, |
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 these codes be identified? in some sort of map.
e48c9d3
to
4915137
Compare
Modify this title
Related Issue/Asana ticket: _
Short description: Add a library called
@kadena/ledger
that allows integration with the kadena ledger app via browser HID.Currently ON-HOLD because the kadena app is being re-written.
Test scenarios
Reminders (if applicable)
pnpm install
andpnpm test
in the root of the monorepo(optionally with
--filter=...package...
to exclude non-affectedprojects)
pnpm changeset
in the root of the monorepodocs.kadena.io)