Skip to content

Conversation

@adam-maj
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Sep 16, 2022

🦋 Changeset detected

Latest commit: 3cb3361

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@thirdweb-dev/storage Major
@thirdweb-dev/sdk Patch
@thirdweb-dev/solana Patch
@thirdweb-dev/auth Patch
thirdweb Patch
@thirdweb-dev/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@adam-maj adam-maj changed the title Add update storage SDK Update Storage SDK Sep 17, 2022
Copy link
Member

@joaquim-verges joaquim-verges left a comment

Choose a reason for hiding this comment

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

looks so much cleaner! excited for this

await this.uploadProperties(file);
}
}
export function MockStorage(): ThirdwebStorage {
Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to move this to the storage package? maybe as an internal class?

right now we have to duplicate this between solana / ts sdk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was thinking of doing this but left it since we had the duplicate from before. I think this generally makes sense - could be useful for other people testing?

Otherwise might be bleeding of our own implementations

}
export function MockStorage(): ThirdwebStorage {
const uploader = new MockStorageUploader();
const downloader = new MockStorageDownloader();
Copy link
Member

Choose a reason for hiding this comment

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

btw your mapping doesn't need to be declared top level. can just create a new one in this method (I'd make it static too) and pass it in the mock uploader/downloader constructors. That way it's all nicely self contained

"ipfs://": [
"https://gateway.ipfscdn.io/ipfs/",
"https://cloudflare-ipfs.com/ipfs/",
"https://ipfs.io/ipfs/",
Copy link
Member

Choose a reason for hiding this comment

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

always found it error prone that you have to pass the /ipfs/ at the end. so easy to forget

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'm thinking of this as a generic string match/replace - issue is that for other schemes, there's not necessarily an obvious thing to add on top like that - and would like the replacement to be as explicit as possible for the user.

Definitely might be nice to do some additional checks for the user though

import { StorageDownloader } from "./downloaders/storage-downloader";
import { IpfsUploader } from "./uploaders/ipfs-uploader";

export class ThirdwebStorage<T extends UploadOptions = IpfsUploadBatchOptions> {
Copy link
Member

Choose a reason for hiding this comment

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

make sure to add some docs / examples

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed - will put these in separate PR like Solana


export type Json = JsonLiteral | FileOrBuffer | JsonObject | Json[];

export type JsonObject = { [key: string]: Json };
Copy link
Member

Choose a reason for hiding this comment

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

I think i duplicated these in solana, can you check that we're importing from here in both ts SDK/solana?

await this.contractWrapper.getSigner()?.getAddress(),
{
rewriteFileNames: {
fileStartNumber: 0,
Copy link
Member

Choose a reason for hiding this comment

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

niceee

@joaquim-verges
Copy link
Member

@jnsdls any idea why the e2e react test would timeout on mount?

@adam-maj
Copy link
Contributor Author

@jnsdls any idea why the e2e react test would timeout on mount?

Trying to debug it now - it doesn't like the FileOrBufferOrStringSchema and is saying it's undefined - definitely something with Buffer on browser here, trying to try stuff out.

@adam-maj
Copy link
Contributor Author

Fixed!

Copy link
Member

@joaquim-verges joaquim-verges left a comment

Choose a reason for hiding this comment

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

Lgtm!

@adam-maj adam-maj enabled auto-merge (squash) September 19, 2022 16:51
@adam-maj adam-maj merged commit 57432d2 into main Sep 19, 2022
@adam-maj adam-maj deleted the am/storage branch September 19, 2022 16:58
@github-actions github-actions bot mentioned this pull request Sep 19, 2022
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.

3 participants