Last active
January 21, 2016 21:37
-
-
Save profOnno/908119c528f52e4b41ac to your computer and use it in GitHub Desktop.
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
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
hash: DS.attr(), | |
size: DS.attr(), | |
height: DS.attr(), | |
version: DS.attr(), | |
merkleroot: DS.attr(), | |
time: DS.attr(), | |
nonce: DS.attr(), | |
bits: DS.attr(), | |
difficulty: DS.attr(), | |
mint: DS.attr(), | |
previousblockhash: DS.attr(), | |
nextblockhash: DS.attr(), | |
flags: DS.attr(), | |
proofhash: DS.attr(), | |
entropybit: DS.attr(), | |
modifier: DS.attr(), | |
modifierchecksum: DS.attr(), | |
tx: DS.attr(), | |
txs: DS.hasMany("tx", { async: true }) | |
}); | |
~ | |
~ |
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
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
txid: DS.attr(), | |
version: DS.attr(), | |
locktime: DS.attr(), | |
isCoinbase: DS.attr(), | |
isCoinstake: DS.attr(), | |
vin: DS.attr(), | |
vout: DS.attr(), | |
blockhash: DS.belongsTo("block"), | |
confirmations: DS.attr(), | |
time: DS.attr(), | |
blocktime: DS.attr() | |
}); |
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
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: config.locationType | |
}); | |
Router.map(function() { | |
+ this.route('about'); | |
+ this.route('block', { path: "block/:block_id" }); | |
+ this.route('info'); | |
+ this.route('coin'); | |
+ this.route('tx', { path: "tx/:tx_id" }); | |
}); | |
~ | |
export default Router; |
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
import DS from 'ember-data'; | |
//export default DS.RESTSerializer.extend({ | |
export default DS.JSONAPISerializer.extend({ | |
normalizeFindRecordResponse(store, type, payload){ | |
payload.data.txs = payload.data.tx; //one used as string array the other for DS.hasMany | |
return{ | |
data: { | |
id: payload.data.hash, | |
type: type.modelName, | |
attributes: payload.data | |
} | |
}; | |
}, | |
}); |
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
import DS from 'ember-data'; | |
export default DS.JSONAPISerializer.extend({ | |
normalizeFindRecordResponse(store, type, payload){ | |
console.log(payload); | |
console.log(payload.data.tx.txid); | |
// use CamelCase function.. | |
payload.data.tx.isCoinbase = payload.data.tx.is_coinbase; | |
payload.data.tx.isCoinstake = payload.data.tx.is_coinstake; | |
return{ | |
data: { | |
id: payload.data.tx.txid, | |
type: type.modelName, | |
//for now use data.tx as model | |
attributes: payload.data.tx | |
} | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment