-
Notifications
You must be signed in to change notification settings - Fork 71
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
Feature/lit 3125 sdk for wrapping up walletx 2 #487
Merged
DashKash54
merged 160 commits into
master
from
feature/lit-3125-sdk-for-wrapping-up-walletx-2
Jul 1, 2024
Merged
Feature/lit 3125 sdk for wrapping up walletx 2 #487
DashKash54
merged 160 commits into
master
from
feature/lit-3125-sdk-for-wrapping-up-walletx-2
Jul 1, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…broadcasting from Lit Action
joshLong145
reviewed
Jun 5, 2024
DashKash54
reviewed
Jun 6, 2024
…pes in favour of composition for the 'custom' case
…nclude `litNetwork` rather than the entire LitNodeClient instance. Clarify types of `litNetwork` returned from previously persisted data
…ts` and eliminate circular type imports
…ute correct keyType in `generatePrivateKey()`
…ddress-algo Wrapped Keys
joshLong145
reviewed
Jul 1, 2024
…sts; was throwing '❌Error: TypeError: testFunction is not a function'.
MaximusHaximus
approved these changes
Jul 1, 2024
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.
👍 Let's do it!
DashKash54
approved these changes
Jul 1, 2024
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.
Approving to be merged
DashKash54
approved these changes
Jul 1, 2024
glitch003
approved these changes
Jul 1, 2024
spacesailor24
approved these changes
Jul 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Author: @DashKash54
What
We add a new SDK package:
wrapped-keys
. It's been published with thebeta
tag: https://www.npmjs.com/package/@lit-protocol/wrapped-keys/v/6.0.3-wrapped-keys.beta.2AWS
SDK package
The idea is to provide very easy to use functions for:
importPrivateKey
- Imports a private key as a string and stores in our DynamoDBgeneratePrivateKey
- For new users generate a random private key inside the Lit Action and return it to the SDK that internally stores it in DynamoDBexportPrivateKey
- Fetches the DynamoDB item and decrypts usingdecryptString
and provides the decrypted private key to the user after stripping the pre-pended "lit_"signTransactionWithEncryptedKey
- Fetches the item from DynamoDB and calls the Lit Action to sign the user provided transaction object. Optionally, broadcasts the signed transaction and returns the tx hash or just returns the signed tx that the user can broadcast themselvessignMessageWithEncryptedKey
- Fetches the item from DynamoDB and calls the Lit Action to sign the user provided message objectAccess Control
The private data is encrypted with the condition to allow only the specific PKP wallet address to decrypt it. We prepend "lit_" to the private key hex string for security reasons.
Supported Chains
We currently support all the EVM chains supported by the Lit nodes in the
rpc.config.yaml
file and all 3 Solana chains.Lit Actions
The idea is that the only place where the bare (un-encrypted) private key exist is the Lit Action (that too on a single node). Hence the SDK only fetches the encrypted private key from DynamoDB and provide it to the Lit Action where it is internally decrypted and used to sign and finally return the signed tx/message.
Since the idea is to provide a default function that doesn't require the user to provide a Lit Action we have published all the Lit Actions and use their
ipfsCid
instead of passing the code as a string.There are separate Lit Actions for Solana & EVM wrapped keys because they have different dependencies like Solana Lit Actions need the
solana/web3
to be bundled (wrapped-keys/esbuild.config.js
).Since Solana tx have several params we accept an unsigned serialized tx in the Lit Action param whereas for EVM we accept tx params and craft the transaction object inside the Lit Action.
Note: We don't wait for the transaction to be confirmed after broadcasting from inside the Lit Action since it could take very long and the Lit Action can timeout.
Tests
There are unit test for utility functions and Tinny test to test several valid and invalid scenarios for all the 5 functionalities listed above.
Special Attention
While reviewing please pay special attention to the assertion in the tests which should be strict and the error handling i.e. we're throwing error when either the AWS DB throws an error or when the SDK throws an error eg:
executeJs
. Finally we're doing a bunch of if conditional checks after receiving the response from theexecuteJs