Skip to content

Commit

Permalink
✨ Support minting via ipfs or ar id
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Jun 22, 2023
1 parent 2df1d15 commit 3b4aa45
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
4 changes: 2 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
"NFTPortal.loadingMessage.waitingImgFee": "Waiting for image upload transaction...",
"NFTPortal.mint.error":"Oops, something went wrong when {error}, please try again.",
"NFTPortal.placeholder.message":"Say Something ...",
"NFTPortal.placeholder.register":"https://like.co or iscn://likecoin-chain/dLbKMa8EVO9RF4UmoWKk2ocUq7IsxMcnQL1_Ps5Vg80/1",
"NFTPortal.placeholder.register":"https://... or iscn://... or ipfs://... or ar://...",
"NFTPortal.textfield.guide.add": "Add message to your collectors",
"NFTPortal.textfield.guide.edit": "Edit",
"NFTPortal.textfield.label.message": "Message",
Expand All @@ -331,7 +331,7 @@
"UploadForm.attention": "Do not connect to Ledger hardware wallets for signing.\n Ledger service temporarily unavailable.",
"UploadForm.button.back": "Back",
"UploadForm.button.confirm": "Confirm",
"UploadForm.button.mintUrl": "Has a URL? Mint NFT here",
"UploadForm.button.mintUrl": "Has a URL, Arweave or IPFS hash? Mint NFT here",
"UploadForm.button.selectFile": "Select a file",
"UploadForm.button.skip": "Skip Upload",
"UploadForm.button": "Start Upload",
Expand Down
21 changes: 19 additions & 2 deletions pages/new/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export default class NewIndexPage extends Vue {
) => ISCNRecordWithID[] | PromiseLike<ISCNRecordWithID[]>
state = 'init'
ipfsHash = ''
arweaveId = ''
ipfsHash = this.$route.query.ipfs_hash || ''
arweaveId = this.$route.query.arweave_id || ''
fileSHA256 = ''
fileData = ''
fileType = ''
Expand Down Expand Up @@ -146,6 +146,23 @@ export default class NewIndexPage extends Vue {
}
}
async mounted() {
if ((this.ipfsHash || this.arweaveId) && this.shouldSkipToMintNFT) {
this.state = 'iscn';
let url;
if (this.arweaveId) url = `https://arweave.net/${this.arweaveId}`;
else if (this.ipfsHash) url = `https://ipfs.io/ipfs/${this.ipfsHash}`;
if (url) {
const { data, headers } = await this.$axios.get(url, { responseType: 'blob' })
this.fileBlob = data as Blob
this.isImage = headers['content-type'].startsWith('image')
this.fileType = headers['content-type']
this.fileSize = headers['content-length']
this.fileData = `data:${this.fileType};base64,${Buffer.from(await data.arrayBuffer(), 'binary').toString('base64')}`
}
}
}
onSubmitUpload({
ipfsHash,
arweaveId,
Expand Down
20 changes: 20 additions & 0 deletions pages/nft/url/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,22 @@ export default class FetchIndex extends Vue {
break
}
if (this.url.startsWith('ipfs://') || this.url.startsWith('ar://') ) {
const ipfsHash = this.url.startsWith('ipfs://') ? this.url.replace('ipfs://', '') : undefined;
const arweaveId = this.url.startsWith('ar://') ? this.url.replace('ar://', '') : undefined;
this.$router.push(
this.localeLocation({
name: 'new',
query: {
ipfs_hash: ipfsHash,
arweave_id: arweaveId,
mint: '1',
},
})!,
)
break
}
if (this.$route.query.url !== this.url) {
this.$router.replace({
query: {
Expand Down Expand Up @@ -816,6 +832,10 @@ export default class FetchIndex extends Vue {
this.isInputValueValid = true
return
}
if (this.url.startsWith('ipfs://') || this.url.startsWith('ar://')) {
this.isInputValueValid = true
return
}
if (this.crawlURLRegex.test(url)) {
if (url.includes(LIKER_LAND_URL)) {
this.errorMessage = this.$t(
Expand Down

0 comments on commit 3b4aa45

Please sign in to comment.