-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALL-3061 NFT IPFS file upload (#979)
* ALL-3061 Implemented ipfs file upload * ALL-3061 Updated jest version * ALL-3061 Mint nft in one action --------- Co-authored-by: Oleksandr Loiko <[email protected]>
- Loading branch information
Showing
13 changed files
with
1,024 additions
and
979 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ipfs' | ||
export * from './ipfs.dto' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface UploadFile { | ||
/** | ||
* Data to be uploaded | ||
*/ | ||
file: BlobPart | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Container, Service } from 'typedi' | ||
import { TatumConnector } from '../../connector/tatum.connector' | ||
import { CONFIG, ErrorUtils, ResponseDto } from '../../util' | ||
import { TatumConfig } from '../tatum' | ||
import { UploadFile } from './ipfs.dto' | ||
|
||
@Service({ | ||
factory: (data: { id: string }) => { | ||
return new Ipfs(data.id) | ||
}, | ||
transient: true, | ||
}) | ||
export class Ipfs { | ||
protected readonly connector: TatumConnector | ||
protected readonly config: TatumConfig | ||
|
||
constructor(private readonly id: string) { | ||
this.config = Container.of(this.id).get(CONFIG) | ||
this.connector = Container.of(this.id).get(TatumConnector) | ||
} | ||
|
||
/** | ||
* Upload file to the IPFS storage. | ||
* @param body Body of the request with file to be uploaded. | ||
* @returns ResponseDto<{txId: string}> IPFS hash id of the uploaded file. | ||
*/ | ||
async uploadFile(body: UploadFile): Promise<ResponseDto<{ ipfsHash: string }>> { | ||
return ErrorUtils.tryFail(() => | ||
this.connector.uploadFile<{ ipfsHash: string }>({ | ||
path: `ipfs`, | ||
body: body.file, | ||
}), | ||
) | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.