jupiter-fs
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -6,2 +6,9 @@ # Changelog | ||
## [0.2.0] - 2020-07-25 | ||
### Added | ||
- Use jupiter-fs metadata subtype to filter all the metadata transactions | ||
### Changed | ||
- Update jupiter-node-sdk version to 0.4.0 increasing fee for binary transactions | ||
## [0.1.1] - 2020-07-20 | ||
@@ -8,0 +15,0 @@ ### Added |
@@ -41,4 +41,4 @@ "use strict"; | ||
const CHUNK_SIZE_PATTERN = /.{1,40000}/g; | ||
const TYPE_MESSAGING = 1; | ||
const SUBTYPE_MESSAGING_METIS_DATA = 15; | ||
const SUBTYPE_MESSAGING_METIS_DATA = 16; | ||
const SUBTYPE_MESSAGING_METIS_METADATA = 17; | ||
return { | ||
@@ -87,3 +87,3 @@ key: `jupiter-fs`, | ||
}; | ||
await this.client.storeRecord(newAddyInfo, SUBTYPE_MESSAGING_METIS_DATA); | ||
await this.client.storeRecord(newAddyInfo, SUBTYPE_MESSAGING_METIS_METADATA); | ||
addy = newAddyInfo; | ||
@@ -117,3 +117,3 @@ } | ||
// Get all the transactions for the main jupiter account | ||
const allTxns = await this.client.getAllTransactions(true, TYPE_MESSAGING, SUBTYPE_MESSAGING_METIS_DATA); | ||
const allTxns = await this.client.getAllMatadataTransactions(); | ||
// for each transaction, check if contains the jupiter-fs metaDataKey and | ||
@@ -142,3 +142,3 @@ // decrypt the chuncked transactions | ||
async ls() { | ||
const allTxns = await this.client.getAllTransactions(true, TYPE_MESSAGING, SUBTYPE_MESSAGING_METIS_DATA); | ||
const allTxns = await this.client.getAllMatadataTransactions(); | ||
const allFilesObj = (await Promise.all(allTxns.map(async (txn) => { | ||
@@ -195,7 +195,7 @@ try { | ||
}; | ||
await this.client.storeRecord(masterRecord, SUBTYPE_MESSAGING_METIS_DATA); | ||
await this.client.storeRecord(masterRecord, SUBTYPE_MESSAGING_METIS_METADATA); | ||
return masterRecord; | ||
}, | ||
async deleteFile(id) { | ||
await this.client.storeRecord({ id, isDeleted: true }, SUBTYPE_MESSAGING_METIS_DATA); | ||
await this.client.storeRecord({ id, isDeleted: true }, SUBTYPE_MESSAGING_METIS_METADATA); | ||
return true; | ||
@@ -218,3 +218,2 @@ }, | ||
// if not found, search in the confirmed transactions | ||
txns = await this.binaryClient.getAllConfirmedTransactions(true, TYPE_MESSAGING, SUBTYPE_MESSAGING_METIS_DATA); | ||
const files = await this.ls(); | ||
@@ -221,0 +220,0 @@ const targetFile = files.find((t) => (id && id === t.id) || t.fileName === name); |
@@ -34,2 +34,3 @@ "use strict"; | ||
const addy = await jupFs.getOrCreateBinaryAddress(); | ||
console.log(addy); | ||
assert_1.default.strictEqual(typeof addy.address === 'string', true); | ||
@@ -41,2 +42,3 @@ }); | ||
const files = await jupFs.ls(); | ||
console.log(files); | ||
assert_1.default.strictEqual(files instanceof Array, true); | ||
@@ -47,3 +49,3 @@ }); | ||
it(`should write a file to a jupiter account without error`, async () => { | ||
const fileData = await fs_1.default.promises.readFile(path_1.default.join(__dirname, '../testFiles/medium.jpg'), { encoding: null }); | ||
const fileData = await fs_1.default.promises.readFile(path_1.default.join(__dirname, '../testFiles/big.jpg'), { encoding: null }); | ||
console.log("filename " + testFilename); | ||
@@ -61,3 +63,3 @@ const res = await jupFs.writeFile(testFilename, fileData, function (errorr) { | ||
const fileData = await jupFs.getFile({ name: testFilename }); | ||
const origFileData = await fs_1.default.promises.readFile(path_1.default.join(__dirname, '../testFiles/medium.jpg'), 'utf-8'); | ||
const origFileData = await fs_1.default.promises.readFile(path_1.default.join(__dirname, '../testFiles/big.jpg'), 'utf-8'); | ||
assert_1.default.strictEqual(fileData instanceof Buffer, true); | ||
@@ -64,0 +66,0 @@ assert_1.default.strictEqual(fileData.length > 0, true); |
{ | ||
"name": "jupiter-fs", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A small file system implementation for the Jupiter blockchain.", | ||
@@ -26,3 +26,3 @@ "main": "./dist/JupiterFs.js", | ||
"dependencies": { | ||
"jupiter-node-sdk": "^0.3.1", | ||
"jupiter-node-sdk": "^0.4.0", | ||
"uuid": "^8.3.2" | ||
@@ -29,0 +29,0 @@ }, |
@@ -23,3 +23,3 @@ import assert from 'assert' | ||
describe('#newBinaryAddress()', function() { | ||
describe('#newBinaryAddress()', function() { | ||
it(`should get a new JUP address from a passphrase`, async () => { | ||
@@ -34,2 +34,3 @@ const info = await jupFs.newBinaryAddress() | ||
const addy = await jupFs.getOrCreateBinaryAddress() | ||
console.log(addy); | ||
assert.strictEqual(typeof addy.address === 'string', true) | ||
@@ -42,2 +43,3 @@ }) | ||
const files = await jupFs.ls() | ||
console.log(files) | ||
assert.strictEqual(files instanceof Array, true) | ||
@@ -50,3 +52,3 @@ }) | ||
const fileData = await fs.promises.readFile( | ||
path.join(__dirname, '../testFiles/medium.jpg'), | ||
path.join(__dirname, '../testFiles/big.jpg'), | ||
{ encoding: null } | ||
@@ -68,3 +70,3 @@ ) | ||
const origFileData = await fs.promises.readFile( | ||
path.join(__dirname, '../testFiles/medium.jpg'), | ||
path.join(__dirname, '../testFiles/big.jpg'), | ||
'utf-8' | ||
@@ -71,0 +73,0 @@ ) |
@@ -28,4 +28,4 @@ import assert from 'assert' | ||
const TYPE_MESSAGING = 1; | ||
const SUBTYPE_MESSAGING_METIS_DATA = 15; | ||
const SUBTYPE_MESSAGING_METIS_DATA = 16; | ||
const SUBTYPE_MESSAGING_METIS_METADATA = 17; | ||
@@ -83,3 +83,3 @@ return { | ||
} | ||
await this.client.storeRecord(newAddyInfo, SUBTYPE_MESSAGING_METIS_DATA) | ||
await this.client.storeRecord(newAddyInfo, SUBTYPE_MESSAGING_METIS_METADATA) | ||
addy = newAddyInfo | ||
@@ -120,3 +120,3 @@ } | ||
// Get all the transactions for the main jupiter account | ||
const allTxns = await this.client.getAllTransactions(true, TYPE_MESSAGING, SUBTYPE_MESSAGING_METIS_DATA) | ||
const allTxns = await this.client.getAllMatadataTransactions() | ||
// for each transaction, check if contains the jupiter-fs metaDataKey and | ||
@@ -155,3 +155,3 @@ // decrypt the chuncked transactions | ||
async ls() { | ||
const allTxns = await this.client.getAllTransactions(true, TYPE_MESSAGING, SUBTYPE_MESSAGING_METIS_DATA) | ||
const allTxns = await this.client.getAllMatadataTransactions() | ||
const allFilesObj: any = ( | ||
@@ -228,3 +228,3 @@ await Promise.all( | ||
await this.client.storeRecord(masterRecord, SUBTYPE_MESSAGING_METIS_DATA) | ||
await this.client.storeRecord(masterRecord, SUBTYPE_MESSAGING_METIS_METADATA) | ||
return masterRecord | ||
@@ -234,3 +234,3 @@ }, | ||
async deleteFile(id: string): Promise<boolean> { | ||
await this.client.storeRecord({ id, isDeleted: true }, SUBTYPE_MESSAGING_METIS_DATA) | ||
await this.client.storeRecord({ id, isDeleted: true }, SUBTYPE_MESSAGING_METIS_METADATA) | ||
return true | ||
@@ -261,3 +261,2 @@ }, | ||
// if not found, search in the confirmed transactions | ||
txns = await this.binaryClient.getAllConfirmedTransactions(true, TYPE_MESSAGING, SUBTYPE_MESSAGING_METIS_DATA) | ||
const files = await this.ls() | ||
@@ -264,0 +263,0 @@ const targetFile = files.find( |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
845
237913
+ Addedjupiter-node-sdk@0.4.1(transitive)
- Removedjupiter-node-sdk@0.3.1(transitive)
Updatedjupiter-node-sdk@^0.4.0