mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
Merge pull request #37 from christroutner/unstable
fix(NFT): Prototyping NFT generation
This commit is contained in:
@@ -361,6 +361,61 @@ class TokenType1 {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
// Parent NFT
|
||||
generateNFTGenesisOpReturn(configObj) {
|
||||
try {
|
||||
// TODO: Add input validation.
|
||||
|
||||
// Prevent error if user fails to add the document hash.
|
||||
if (!configObj.documentHash) configObj.documentHash = ""
|
||||
|
||||
// If mint baton is not specified, then replace it with null.
|
||||
if (!configObj.mintBatonVout) configObj.mintBatonVout = null
|
||||
|
||||
const script = slpMdm.NFT1.Group.genesis(
|
||||
configObj.ticker,
|
||||
configObj.name,
|
||||
configObj.documentUrl,
|
||||
configObj.documentHash,
|
||||
0,
|
||||
configObj.mintBatonVout,
|
||||
new slpMdm.BN("1")
|
||||
)
|
||||
|
||||
return script
|
||||
} catch (err) {
|
||||
console.log(`Error in generateNFTGenesisOpReturn()`)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
generateNFTChildOpReturn(configObj) {
|
||||
try {
|
||||
// TODO: Add input validation.
|
||||
|
||||
// Prevent error if user fails to add the document hash.
|
||||
if (!configObj.documentHash) configObj.documentHash = ""
|
||||
|
||||
// If mint baton is not specified, then replace it with null.
|
||||
if (!configObj.mintBatonVout) configObj.mintBatonVout = null
|
||||
|
||||
const script = slpMdm.NFT1.Group.genesis(
|
||||
configObj.ticker,
|
||||
configObj.name,
|
||||
configObj.documentUrl,
|
||||
configObj.documentHash,
|
||||
0,
|
||||
configObj.mintBatonVout,
|
||||
new slpMdm.BN("1")
|
||||
)
|
||||
|
||||
return script
|
||||
} catch (err) {
|
||||
console.log(`Error in generateNFTChildOpReturn()`)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TokenType1
|
||||
|
||||
@@ -413,4 +413,40 @@ describe("#SLP TokenType1", () => {
|
||||
assert.equal(Buffer.isBuffer(result), true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#generateNFTOpReturn", () => {
|
||||
it("should generate NFT Genesis OP_RETURN code", async () => {
|
||||
const configObj = {
|
||||
name: "SLP Test Token",
|
||||
ticker: "SLPTEST",
|
||||
documentUrl: "https://bchjs.cash",
|
||||
documentHash: ""
|
||||
}
|
||||
|
||||
const result = await bchjs.SLP.TokenType1.generateNFTGenesisOpReturn(
|
||||
configObj
|
||||
)
|
||||
// console.log(`result: `, result)
|
||||
|
||||
assert.equal(Buffer.isBuffer(result), true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#generateNFTChildOpReturn", () => {
|
||||
it("should generate NFT Genesis OP_RETURN code", async () => {
|
||||
const configObj = {
|
||||
name: "SLP Test Token",
|
||||
ticker: "SLPTEST",
|
||||
documentUrl: "https://bchjs.cash",
|
||||
documentHash: ""
|
||||
}
|
||||
|
||||
const result = await bchjs.SLP.TokenType1.generateNFTChildOpReturn(
|
||||
configObj
|
||||
)
|
||||
// console.log(`result: `, result)
|
||||
|
||||
assert.equal(Buffer.isBuffer(result), true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user