Comments (13)
Yes, its in what will be the 5.0.0 release, this is imminent BTW, should be done this coming weekend.
from cbor.
Plus correct me if I'm wrong but the decoding process isn't nested right?
When 5.0.0 is released the process will be nested, just a matter of putting the list of bytes inside a CborBytes
from cbor.
Package version 5.0.0 is now published, please check if your concerns above have now been addressed.
from cbor.
Thanks @shamblett ! It's my first time dealing with CBOR and low level stuff, so I'm excited for the simple module, it might finally crack what I'm doing. 😁
from cbor.
@shamblett just wanted to ask since i'm learning stuff about CBOR if you don't mind.
Since this library uses RFC7049, is it a possible why i can't decode my cardano related CBOR data since it's under RFC 8949 standard? Thanks!
I'm having troubles in (or could be my lack of understanding) decoding the following hex encoded cbor string with how I use this package, what is the correct way to decode this one?:
821a1a714f07b81b581c00c63a76731b1f4212b2f1346e651821b924e230305e630d5d272f50a14a4153494d4f423030323001581c0b28027fdb48b5f7f97e8c93e5939bc85eb9f0e7fe93e354672ce67da24b69736c6164697761363439014b69736c616469776137313301581c0bc68c0973a7e8374d232afad629939ad6e3da45329c96c211d19a05a5506d63687672735072697661746534323101516d6368767273507269766174653436333501516d6368767273507269766174653437343101516d6368767273507269766174653531343801516d6368767273507269766174653732343201581c11ff0e0d9ad037d18e3ed575cd35a0513b8473f83008124db89f1d8fa2504861707079486f70706572303535343801504861707079486f70706572303834313801581c1ec19c1629869bffd649e748e29bc81c951de172b1b54217138b35c9a7484f4f5a3145533435014a4f4f5a31455331393732014a4f4f5a31455336303533014a4f4f5a31455337373333014a4f4f5a31455337373739014a4f4f5a31455338393232014a4f4f5a3145533939383901581c3691ce00d8a2bd035a85d77e5428e34da58de9acbeedeee8256b8175a54e5350414345424142455a33323539014e5350414345424142455a33373236014e5350414345424142455a34323836014e5350414345424142455a35393135014e5350414345424142455a3631303301581c3c1169f0336f60c46aa0651bd8130c8f35a001005cf7599bb25d7cf8a15142616279416c69656e526f636b3035333701581c3d8a6c3ffb3c07447d46738d4189b2e32dc8c56ef1faf5a9e6609c77a44a4173696d6f6230313937014a4173696d6f6231353734014a4173696d6f6234353936014a4173696d6f623436373801581c4b9c44c53a20cdfaec04f6a24dd6572037a54aed27a4647b400255f3a14c48617264466f726b3139383501581c4c9f7d6c24ba8e2b12f3269ac38d706025e39a50a524afe6eaf79d95a14f5665676769656d617465303739383801581c4d30f867d7a0e4cc0b7d783f47bc128ce00c2f035a92da0e8d64529aa15543617264616e6976616c584c6f77506f6c7930313701581c7724da6519bbdda506e4d8acce11e01e01019726ddf017418f9c958aa15043727970746f446f676769653638303101581c8d4eaf81bbdae53cc6492d1b61895fa57f97784a6ef8086918240dcba14f536861726b436f6e7472616374323401581c9bfb38db521cce63c0b54593454b4e6705c18e57d90ead1323dc69bfa1504669736879467269656e64303630363001581ca02684b9ece84a4341585d2ae813163356ba0ca950091d1935bdb905a7514855534b59484f53544c4552303034343301514855534b59484f53544c4552303639323501514855534b59484f53544c4552313032363201514855534b59484f53544c4552313136383501514855534b59484f53544c4552313336353301514855534b59484f53544c4552313934353201514855534b59484f53544c4552313934383801581ca0aa1eb2440251208cd4ba62a2ce8fe874879be7a395e8d513f47fb8a1545468654c61737447756e736c696e67657231323601581ca5bb0e5bb275a573d744a021f9b3bff73595468e002755b447e01559a556484f534b5943617368477261623030303034303534300156484f534b5943617368477261623030303034303534310156484f534b5943617368477261623030303034303534320156484f534b5943617368477261623030303034303534330156484f534b59436173684772616230303030343035343401581cbbea68880f8b15bccfa00f23307a0e6adaa2b2c044c7266a4df86188a14c434e4654436172643032323701581cbe8e242b0419d87a15b23f037eff046796fc60c281dce89bb7966bc0a447416c6963653633014856696f6c65743938014b41706f63616c7970736531014d44726177737472696e6731373501581cc7fe3a3c3443a2a3d453efb7df0c276712bb22f8470f12965f5cae42a250477265656e466f756e646572323333330150477265656e466f756e6465723431393701581cc89c51e846cf06b0e3a3b4335337cf6e15b2226de03eb5bebd580d74a2515072656d696e74696e67546573744e465401581e546f6b656e4e616d65507265666978504c414345484f4c4445523030303101581cc9633bdd95c8410270a7b052cc3652eb2f7bdecdd834be92202f7136a14f435a30313132434f4d4d4f4e33373201581cca3aeaa53c0b21fccf28c8c724141473d325fe9ea8d0314f7c3b4240a24f4269746c616e647330783034313537014f4269746c616e64733078303534343901581cd1afc688aaa8b4f18d440074da1f54f5e9dbaa3eef8957e24ef21a7aa14c466f6f54657374496d61676501581cec2e1c314ee754cea4ba3afc69f74b2130f87bb3928e1a1e8534c209a24f526167696e675465656e3030343139014f526167696e675465656e303332303101581cf11ddbdadbc7b78b7110293281844ba8acac918f1ed5767539d7d52ea14d476f6f667947616e673437323601581cf1ead232c80a327005f3a5836430aa25adb1b63a532d09dd61be802aa54e484f534b45564552534533353933014e484f534b45564552534536373638014e484f534b45564552534538343033014e484f534b45564552534538343036014e484f534b4556455253453936333501
from cbor.
Version 5.0.0 has also been updated to RFC8949 standard. I'll look at this as soon as 5.0.0 is released.
from cbor.
Thanks! Btw just wanted to add this to help with your investigation: I'm able to convert it using this service: https://cbor.me/
from cbor.
@shamblett ! I was able to figure it out now, sorry for the bother. There are no issues with the package when it comes to decoding it. It was just too low level unlike the service i was using. Plus correct me if I'm wrong but the decoding process isn't nested right? And i still need to decode the hex per item here? Since this is already the correct data, but it's just a matter of decoding the List's to hex. Is there a property I could toggle to automatically do that?
[[443633415, {[0, 198, 58, 118, 115, 27, 31, 66, 18, 178, 241, 52, 110, 101, 24, 33, 185, 36, 226, 48, 48, 94, 99, 13, 93, 39, 47, 80]: {[65, 83, 73, 77, 79, 66, 48, 48, 50, 48]: 1}, [11, 40, 2, 127, 219, 72, 181, 247, 249, 126, 140, 147, 229, 147, 155, 200, 94, 185, 240, 231, 254, 147, 227, 84, 103, 44, 230, 125]: {[105, 115, 108, 97, 100, 105, 119, 97, 54, 52, 57]: 1, [105, 115, 108, 97, 100, 105, 119, 97, 55, 49, 51]: 1}, [11, 198, 140, 9, 115, 167, 232, 55, 77, 35, 42, 250, 214, 41, 147, 154, 214, 227, 218, 69, 50, 156, 150, 194, 17, 209, 154, 5]: {[109, 99, 104, 118, 114, 115, 80, 114, 105, 118, 97, 116, 101, 52, 50, 49]: 1, [109, 99, 104, 118, 114, 115, 80, 114, 105, 118, 97, 116, 101, 52, 54, 51, 53]: 1, [109, 99, 104, 118, 114, 115, 80, 114, 105, 118, 97, 116, 101, 52, 55, 52, 49]: 1, [109, 99, 104, 118, 114, 115, 80, 114, 105, 118, 97, 116, 101, 53, 49, 52, 56]: 1, [109, 99, 104, 118, 114, 115, 80, 114, 105, 118, 97, 116, 101, 55, 50, 52, 50]: 1}, [17, 255, 14, 13, 154, 208, 55, 209, 142, 62, 213, 117, 205, 53, 160, 81, 59, 132, 115, 248, 48, 8, 18, 77, 184, 159, 29, 143]: {[72, 97, 112, 112, 121, 72, 111, 112, 112, 101, 114, 48, 53, 53, 52, 56]: 1, [72, 97, 112, 112, 121, 72, 111, 112, 112, 101, 114, 48, 56, 52, 49, 56]: 1}, [30, 193, 156, 22, 41, 134, 155, 255, 214, 73, 231, 72, 226, 155, 200, 28, 149, 29, 225, 114, 177, 181, 66, 23, 19, 139, 53, 201]: {[79, 79, 90, 49, 69, 83, 52, 53]: 1, [79, 79, 90, 49, 69, 83, 49, 57, 55, 50]: 1, [79, 79, 90, 49, 69, 83, 54, 48, 53, 51]: 1, [79, 79, 90, 49, 69, 83, 55, 55, 51, 51]: 1, [79, 79, 90, 49, 69, 83, 55, 55, 55, 57]: 1, [79, 79, 90, 49, 69, 83, 56, 57, 50, 50]: 1, [79, 79, 90, 49, 69, 83, 57, 57, 56, 57]: 1}, [54, 145, 206, 0, 216, 162, 189, 3, 90, 133, 215, 126, 84, 40, 227, 77, 165, 141, 233, 172, 190, 237, 238, 232, 37, 107, 129, 117]: {[83, 80, 65, 67, 69, 66, 65, 66, 69, 90, 51, 50, 53, 57]: 1, [83, 80, 65, 67, 69, 66, 65, 66, 69, 90, 51, 55, 50, 54]: 1, [83, 80, 65, 67, 69, 66, 65, 66, 69, 90, 52, 50, 56, 54]: 1, [83, 80, 65, 67, 69, 66, 65, 66, 69, 90, 53, 57, 49, 53]: 1, [83, 80, 65, 67, 69, 66, 65, 66, 69, 90, 54, 49, 48, 51]: 1}, [60, 17, 105, 240, 51, 111, 96, 196, 106, 160, 101, 27, 216, 19, 12, 143, 53, 160, 1, 0, 92, 247, 89, 155, 178, 93, 124, 248]: {[66, 97, 98, 121, 65, 108, 105, 101, 110, 82, 111, 99, 107, 48, 53, 51, 55]: 1}, [61, 138, 108, 63, 251, 60, 7, 68, 125, 70, 115, 141, 65, 137, 178, 227, 45, 200, 197, 110, 241, 250, 245, 169, 230, 96, 156, 119]: {[65, 115, 105, 109, 111, 98, 48, 49, 57, 55]: 1, [65, 115, 105, 109, 111, 98, 49, 53, 55, 52]: 1, [65, 115, 105, 109, 111, 98, 52, 53, 57, 54]: 1, [65, 115, 105, 109, 111, 98, 52, 54, 55, 56]: 1}, [75, 156, 68, 197, 58, 32, 205, 250, 236, 4, 246, 162, 77, 214, 87, 32, 55, 165, 74, 237, 39, 164, 100, 123, 64, 2, 85, 243]: {[72, 97, 114, 100, 70, 111, 114, 107, 49, 57, 56, 53]: 1}, [76, 159, 125, 108, 36, 186, 142, 43, 18, 243, 38, 154, 195, 141, 112, 96, 37, 227, 154, 80, 165, 36, 175, 230, 234, 247, 157, 149]: {[86, 101, 103, 103, 105, 101, 109, 97, 116, 101, 48, 55, 57, 56, 56]: 1}, [77, 48, 248, 103, 215, 160, 228, 204, 11, 125, 120, 63, 71, 188, 18, 140, 224, 12, 47, 3, 90, 146, 218, 14, 141, 100, 82, 154]: {[67, 97, 114, 100, 97, 110, 105, 118, 97, 108, 88, 76, 111, 119, 80, 111, 108, 121, 48, 49, 55]: 1}, [119, 36, 218, 101, 25, 187, 221, 165, 6, 228, 216, 172, 206, 17, 224, 30, 1, 1, 151, 38, 221, 240, 23, 65, 143, 156, 149, 138]: {[67, 114, 121, 112, 116, 111, 68, 111, 103, 103, 105, 101, 54, 56, 48, 49]: 1}, [141, 78, 175, 129, 187, 218, 229, 60, 198, 73, 45, 27, 97, 137, 95, 165, 127, 151, 120, 74, 110, 248, 8, 105, 24, 36, 13, 203]: {[83, 104, 97, 114, 107, 67, 111, 110, 116, 114, 97, 99, 116, 50, 52]: 1}, [155, 251, 56, 219, 82, 28, 206, 99, 192, 181, 69, 147, 69, 75, 78, 103, 5, 193, 142, 87, 217, 14, 173, 19, 35, 220, 105, 191]: {[70, 105, 115, 104, 121, 70, 114, 105, 101, 110, 100, 48, 54, 48, 54, 48]: 1}, [160, 38, 132, 185, 236, 232, 74, 67, 65, 88, 93, 42, 232, 19, 22, 51, 86, 186, 12, 169, 80, 9, 29, 25, 53, 189, 185, 5]: {[72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 48, 48, 52, 52, 51]: 1, [72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 48, 54, 57, 50, 53]: 1, [72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 49, 48, 50, 54, 50]: 1, [72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 49, 49, 54, 56, 53]: 1, [72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 49, 51, 54, 53, 51]: 1, [72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 49, 57, 52, 53, 50]: 1, [72, 85, 83, 75, 89, 72, 79, 83, 84, 76, 69, 82, 49, 57, 52, 56, 56]: 1}, [160, 170, 30, 178, 68, 2, 81, 32, 140, 212, 186, 98, 162, 206, 143, 232, 116, 135, 155, 231, 163, 149, 232, 213, 19, 244, 127, 184]: {[84, 104, 101, 76, 97, 115, 116, 71, 117, 110, 115, 108, 105, 110, 103, 101, 114, 49, 50, 54]: 1}, [165, 187, 14, 91, 178, 117, 165, 115, 215, 68, 160, 33, 249, 179, 191, 247, 53, 149, 70, 142, 0, 39, 85, 180, 71, 224, 21, 89]: {[72, 79, 83, 75, 89, 67, 97, 115, 104, 71, 114, 97, 98, 48, 48, 48, 48, 52, 48, 53, 52, 48]: 1, [72, 79, 83, 75, 89, 67, 97, 115, 104, 71, 114, 97, 98, 48, 48, 48, 48, 52, 48, 53, 52, 49]: 1, [72, 79, 83, 75, 89, 67, 97, 115, 104, 71, 114, 97, 98, 48, 48, 48, 48, 52, 48, 53, 52, 50]: 1, [72, 79, 83, 75, 89, 67, 97, 115, 104, 71, 114, 97, 98, 48, 48, 48, 48, 52, 48, 53, 52, 51]: 1, [72, 79, 83, 75, 89, 67, 97, 115, 104, 71, 114, 97, 98, 48, 48, 48, 48, 52, 48, 53, 52, 52]: 1}, [187, 234, 104, 136, 15, 139, 21, 188, 207, 160, 15, 35, 48, 122, 14, 106, 218, 162, 178, 192, 68, 199, 38, 106, 77, 248, 97, 136]: {[67, 78, 70, 84, 67, 97, 114, 100, 48, 50, 50, 55]: 1}, [190, 142, 36, 43, 4, 25, 216, 122, 21, 178, 63, 3, 126, 255, 4, 103, 150, 252, 96, 194, 129, 220, 232, 155, 183, 150, 107, 192]: {[65, 108, 105, 99, 101, 54, 51]: 1, [86, 105, 111, 108, 101, 116, 57, 56]: 1, [65, 112, 111, 99, 97, 108, 121, 112, 115, 101, 49]: 1, [68, 114, 97, 119, 115, 116, 114, 105, 110, 103, 49, 55, 53]: 1}, [199, 254, 58, 60, 52, 67, 162, 163, 212, 83, 239, 183, 223, 12, 39, 103, 18, 187, 34, 248, 71, 15, 18, 150, 95, 92, 174, 66]: {[71, 114, 101, 101, 110, 70, 111, 117, 110, 100, 101, 114, 50, 51, 51, 51]: 1, [71, 114, 101, 101, 110, 70, 111, 117, 110, 100, 101, 114, 52, 49, 57, 55]: 1}, [200, 156, 81, 232, 70, 207, 6, 176, 227, 163, 180, 51, 83, 55, 207, 110, 21, 178, 34, 109, 224, 62, 181, 190, 189, 88, 13, 116]: {[80, 114, 101, 109, 105, 110, 116, 105, 110, 103, 84, 101, 115, 116, 78, 70, 84]: 1, [84, 111, 107, 101, 110, 78, 97, 109, 101, 80, 114, 101, 102, 105, 120, 80, 76, 65, 67, 69, 72, 79, 76, 68, 69, 82, 48, 48, 48, 49]: 1}, [201, 99, 59, 221, 149, 200, 65, 2, 112, 167, 176, 82, 204, 54, 82, 235, 47, 123, 222, 205, 216, 52, 190, 146, 32, 47, 113, 54]: {[67, 90, 48, 49, 49, 50, 67, 79, 77, 77, 79, 78, 51, 55, 50]: 1}, [202, 58, 234, 165, 60, 11, 33, 252, 207, 40, 200, 199, 36, 20, 20, 115, 211, 37, 254, 158, 168, 208, 49, 79, 124, 59, 66, 64]: {[66, 105, 116, 108, 97, 110, 100, 115, 48, 120, 48, 52, 49, 53, 55]: 1, [66, 105, 116, 108, 97, 110, 100, 115, 48, 120, 48, 53, 52, 52, 57]: 1}, [209, 175, 198, 136, 170, 168, 180, 241, 141, 68, 0, 116, 218, 31, 84, 245, 233, 219, 170, 62, 239, 137, 87, 226, 78, 242, 26, 122]: {[70, 111, 111, 84, 101, 115, 116, 73, 109, 97, 103, 101]: 1}, [236, 46, 28, 49, 78, 231, 84, 206, 164, 186, 58, 252, 105, 247, 75, 33, 48, 248, 123, 179, 146, 142, 26, 30, 133, 52, 194, 9]: {[82, 97, 103, 105, 110, 103, 84, 101, 101, 110, 48, 48, 52, 49, 57]: 1, [82, 97, 103, 105, 110, 103, 84, 101, 101, 110, 48, 51, 50, 48, 49]: 1}, [241, 29, 219, 218, 219, 199, 183, 139, 113, 16, 41, 50, 129, 132, 75, 168, 172, 172, 145, 143, 30, 213, 118, 117, 57, 215, 213, 46]: {[71, 111, 111, 102, 121, 71, 97, 110, 103, 52, 55, 50, 54]: 1}, [241, 234, 210, 50, 200, 10, 50, 112, 5, 243, 165, 131, 100, 48, 170, 37, 173, 177, 182, 58, 83, 45, 9, 221, 97, 190, 128, 42]: {[72, 79, 83, 75, 69, 86, 69, 82, 83, 69, 51, 53, 57, 51]: 1, [72, 79, 83, 75, 69, 86, 69, 82, 83, 69, 54, 55, 54, 56]: 1, [72, 79, 83, 75, 69, 86, 69, 82, 83, 69, 56, 52, 48, 51]: 1, [72, 79, 83, 75, 69, 86, 69, 82, 83, 69, 56, 52, 48, 54]: 1, [72, 79, 83, 75, 69, 86, 69, 82, 83, 69, 57, 54, 51, 53]: 1}}]]
from cbor.
Alright, thanks!
from cbor.
Thanks @shamblett !
from cbor.
Hi @nicbn @shamblett ! It converts recursively now, thanks! I just need help in understanding what kind of encoding does CborJsonEncoder().convert
use. It didn't come out as my expected data but it's consistent judging by the conversion of 4173696D6F62343
to QXNpbW9iNDY
(these are prefixes of asset names). :D
Raw hex encoded bytes string:
821a4dddd31aa2581c3d8a6c3ffb3c07447d46738d4189b2e32dc8c56ef1faf5a9e6609c77a24a4173696d6f6234353936014a4173696d6f623436373801581c884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903aea14550415649411903e8
what i did:
final walletBalance = await ada.getBalanceFuture; // hex encoded bytes string
final payload = hex.decode(walletBalance);
final value = cbor.cborDecode(payload);
print(cbor.CborJsonEncoder().convert(value));
result via the code above:
[1306383130,{"PYpsP_s8B0R9RnONQYmy4y3IxW7x-vWp5mCcdw":{"QXNpbW9iNDU5Ng":1,"QXNpbW9iNDY3OA":1},"iEiSvNw2C874fWs_gG5_nNWsMNmZ1Jlw56kDrg":{"UEFWSUE":1000}}]
my expected result via https://www.cbor.me:
[1306383130, {h'3D8A6C3FFB3C07447D46738D4189B2E32DC8C56EF1FAF5A9E6609C77': {h'4173696D6F6234353936': 1, h'4173696D6F6234363738': 1}, h'884892BCDC360BCEF87D6B3F806E7F9CD5AC30D999D49970E7A903AE': {h'5041564941': 1000}}]
from cbor.
Update: It seems that the Asset names (i.e. QXNpbW9iNDU5Ng
) are in base64 but the policy id's (i.e. PYpsP_s8B0R9RnONQYmy4y3IxW7x-vWp5mCcdw
) aren't.
from cbor.
The CborJsonEncoder
encodes bytes as base64, cbor.me shows diagnostic notation which converts these to hexadecimal instead. Currently there is no way to print diagnostic notation, but pretty print will show the bytes plus annotations, which you can compare to cbor.me byte notation.
The conversion that CborJsonEncoder
uses is described in the RFC 8949 (https://www.rfc-editor.org/rfc/rfc8949.html). It always converts bytes to base64 unless you apply hints.
from cbor.
Related Issues (20)
- runtimeType String checking fails for web release builds HOT 3
- Bad state: No element HOT 2
- Bad state: No element - map tagetSize out of bounds HOT 5
- Changes to the API HOT 7
- Please provide transition examples from 4.1 to 5.0 HOT 8
- encode int num 43008 decode another num -22528 HOT 4
- CborFloat HOT 3
- Add funding links to package HOT 1
- How does toJson decode Bytes List? HOT 4
- Add repository tag to pubspec HOT 1
- Add codecov to CI/CD HOT 1
- Impossible to get same object between 2 libraries HOT 2
- Split _CborListImpl into _CborDefiniteLengthListImpl and _CborIndefiniteLengthListImpl HOT 3
- FormatException: Expected at most one CBOR value. HOT 5
- Update to Dart 3 HOT 1
- Error: The class 'Sink' can't be extended outside of its library because it's an interface class. HOT 3
- Allow to define Map type while decoding HOT 1
- Any plans to support custom types? HOT 3
- Weird json conversion from cbor HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbor.