Added pseudo code for next steps

This commit is contained in:
Chris Troutner
2021-09-17 10:00:21 -07:00
parent 39e6b56686
commit 4557761d08
2 changed files with 23 additions and 91 deletions
+23 -4
View File
@@ -23,15 +23,23 @@ class OfferLib {
try {
// console.log('createOffer(entryObj): ', entryObj)
// Input Validation
const offerEntity = this.offerEntity.validate(entryObj)
// console.log('offerEntity: ', offerEntity)
// Ensure sufficient tokens exist to create the offer.
// await this.ensureFunds(offerEntity)
// Move the tokens to holding address.
// const utxoInfo = await moveTokens(offerEntity)
// Update the offer with the new UTXO information.
// Burn PSF token to pay for P2WDB write.
const txid = await this.adapters.wallet.burnPsf()
console.log('burn txid: ', txid)
console.log(`https://simpleledger.info/tx/${txid}`)
// Input Validation
const offerEntity = this.offerEntity.validate(entryObj)
// console.log('offerEntity: ', offerEntity)
// TODO: Move tokens to holding address, which will generate the UTXO to
// use in the Offer.
@@ -60,6 +68,17 @@ class OfferLib {
throw err
}
}
// Move the tokens indicated in the offer to a temporary holding address.
// This will generate the UTXO used in the Signal message. This function
// moves the funds and returns the UTXO information.
async moveTokens () {
try {
//
} catch (err) {
console.error('Error in moveTokens()')
}
}
}
module.exports = OfferLib
-87
View File
@@ -152,91 +152,4 @@ describe('#Offer-Entity', () => {
}
})
})
// describe('#validate', () => {
// it('should throw an error if entry is not provided', () => {
// try {
// uut.validate()
// } catch (err) {
// assert.include(err.message, "Property 'entry' must be a string!")
// }
// })
//
// it('should throw an error if description is not provided', () => {
// try {
// const inputData = {
// entry: 'entry'
// }
// uut.validate(inputData)
// } catch (err) {
// assert.include(err.message, "Property 'description' must be a string!")
// }
// })
//
// it('should throw an error if slpAddress is not provided', () => {
// try {
// const inputData = {
// entry: 'entry',
// description: 'test'
// }
// uut.validate(inputData)
// } catch (err) {
// assert.include(err.message, "Property 'slpAddress' must be a string!")
// }
// })
//
// it('should throw an error if signature is not provided', () => {
// try {
// const inputData = {
// entry: 'entry',
// description: 'test',
// slpAddress: 'simpleledger:qpnty9t0w93fez04h7yzevujpv8pun204qqp0jfafg'
// }
// uut.validate(inputData)
// } catch (err) {
// assert.include(err.message, "Property 'signature' must be a string!")
// }
// })
// it('should throw an error if category is not provided', () => {
// try {
// const inputData = {
// entry: 'entry',
// description: 'test',
// slpAddress: 'simpleledger:qpnty9t0w93fez04h7yzevujpv8pun204qqp0jfafg',
// signature: 'IFytRg6KpvTHCzcW0ZwVhPqdKtRGpoRDcuEb958yIgJFUJlb1F5qPzt/JnlYE7r012BSFj+UT67DZVTU8oNB5vw='
// }
// uut.validate(inputData)
// } catch (err) {
// assert.include(err.message, "Property 'category' must be a string!")
// }
// })
//
// it('should return a Entry object', () => {
// const inputData = {
// entry: 'entry',
// description: 'test',
// slpAddress: 'simpleledger:qpnty9t0w93fez04h7yzevujpv8pun204qqp0jfafg',
// signature: 'IFytRg6KpvTHCzcW0ZwVhPqdKtRGpoRDcuEb958yIgJFUJlb1F5qPzt/JnlYE7r012BSFj+UT67DZVTU8oNB5vw=',
// category: 'test'
// }
//
// const entry = uut.validate(inputData)
// // console.log('entry: ', entry)
//
// assert.property(entry, 'entry')
// assert.equal(entry.entry, inputData.entry)
//
// assert.property(entry, 'description')
// assert.equal(entry.description, inputData.description)
//
// assert.property(entry, 'slpAddress')
// assert.equal(entry.slpAddress, inputData.slpAddress)
//
// assert.property(entry, 'signature')
// assert.equal(entry.signature, inputData.signature)
//
// assert.property(entry, 'slpAddress')
// assert.equal(entry.category, inputData.category)
// })
// })
})