Skip to content

Conversation

farhanW3
Copy link
Contributor

Added AWS KMS Support using ENV Variables. The implementation checks for awsKms Wallet ENV Variables and walletPPK. If neither present prints an Error and stops server.

@zeet-co
Copy link

zeet-co bot commented Jun 30, 2023

We're building your pull request over on Zeet.
Click me for more info about your build and deployment.
Once built, this branch can be tested at: https://web3-api-akbv-farhan-plat-1047.chainsaw-dev.zeet.app before merging 😉

@zeet-co
Copy link

zeet-co bot commented Jun 30, 2023

We're building your pull request over on Zeet.
Click me for more info about your build and deployment.
Once built, this branch can be tested at: https://web3-api-7qzi-farhan-plat-1047.zeet-nftlabs.zeet.app before merging 😉

core/sdk/sdk.ts Outdated

// TODO: PLAT-982
// Currently we require WALLET_PRIVATE_KEY to be set in order to instantiate the SDK
// But we need to implement wallet.generate() and wallet.save() to save the private key to file system

// Need to make this instantiate SDK with read/write. For that will need wallet information
const sdk = await ThirdwebSDK.fromWallet(wallet, chainName, {
const sdk = await ThirdwebSDK.fromWallet(wallet!, chainName, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should throw if wallet is not initialized here, in general avoid using !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have this function in startup/index.ts -> walletEnvVariablesCheck() which checks for all the wallet env variables and throws an error if its missing & shuts down the server. But yeah, I can add a throw here too.

@farhanW3
Copy link
Contributor Author

@joaquim-verges

Updated Readme too.

for (let key in obj) {
for (let str of obj[key]) {
server.log.info(
`\t Checking for ${key.toLowerCase()} -> ${str} in env`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably don't want to log the private key here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just logging the ENV variables and not the value of it.


export const walletEnvVariablesCheck = async (
server: FastifyInstance,
variables: { [key: string]: string[] }[],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually need this? feels much simpler to just do the checks in getSDK no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal was to not allow the server to start if the ENV variables required are missing. Otherwise, if I added it inside getSDK then the error will only be thrown when and if user pings an end-point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants