Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/decode

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/decode - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

WARNINGS.md

6

CHANGELOG.md

@@ -5,2 +5,8 @@ ### Unreleased

### 0.0.7 -- 2020-08-25
- 2020-08-25 -- Deprecates operating upon data from the latestBlock field of the response object.
- 2020-08-24 -- Updates decode to decode GetLatestBlock, GetBlockByHeight and GetBlockByHeight responses.
- 2020-08-19 -- Updtates UFix64 and Fix64 types to now decode into Strings.
### 0.0.6 -- 2020-05-04

@@ -7,0 +13,0 @@

2

dist/decode.js

@@ -1,2 +0,2 @@

function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var r=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},t=function(e){return Promise.resolve(e)},n=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&c(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},o={UInt:r,Int:r,UInt8:r,Int8:r,UInt16:r,Int16:r,UInt32:r,Int32:r,UInt64:r,Int64:r,UInt128:r,Int128:r,UInt256:r,Int256:r,Word8:r,Word16:r,Word32:r,Word64:r,UFix64:r,Fix64:r,String:t,Character:t,Bool:t,Address:t,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?i(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(i(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(i(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:n,Resource:n,Struct:n},c=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},i=function(e,r,t){try{var n=c(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},s=function(r,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var c=e({},o,{},t);return Promise.resolve(i(r,c,n))};exports.decode=s,exports.decodeResponse=function(r,t){void 0===t&&(t={});try{var n=!1,c=e({},o,{},t),i=r.encodedData?(n=!0,Promise.resolve(s(r.encodedData,c))):r.transaction?(n=!0,Promise.resolve(Promise.all(r.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return e({},r.transaction,{events:t})})):r.events?(n=!0,Promise.resolve(Promise.all(r.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):r.account?(n=!0,r.account):r.latestBlock?(n=!0,r.latestBlock):r.transactionId?(n=!0,r.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}};
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var r=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},t=function(e){return Promise.resolve(e)},n=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&c(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},o={UInt:r,Int:r,UInt8:r,Int8:r,UInt16:r,Int16:r,UInt32:r,Int32:r,UInt64:r,Int64:r,UInt128:r,Int128:r,UInt256:r,Int256:r,Word8:r,Word16:r,Word32:r,Word64:r,UFix64:t,Fix64:t,String:t,Character:t,Bool:t,Address:t,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?i(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(i(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(i(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:n,Resource:n,Struct:n},c=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},i=function(e,r,t){try{var n=c(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},s=function(r,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var c=e({},o,{},t);return Promise.resolve(i(r,c,n))};exports.decode=s,exports.decodeResponse=function(r,t){void 0===t&&(t={});try{var n=!1,c=e({},o,{},t),i=r.encodedData?(n=!0,Promise.resolve(s(r.encodedData,c))):r.transaction?(n=!0,Promise.resolve(Promise.all(r.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return e({},r.transaction,{events:t})})):r.events?(n=!0,Promise.resolve(Promise.all(r.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):r.account?(n=!0,r.account):r.block?(n=!0,r.block):r.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=!0,r.latestBlock):r.transactionId?(n=!0,r.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}};
//# sourceMappingURL=decode.js.map

@@ -1,2 +0,2 @@

function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var r=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},t=function(e){return Promise.resolve(e)},n=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&c(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},o={UInt:r,Int:r,UInt8:r,Int8:r,UInt16:r,Int16:r,UInt32:r,Int32:r,UInt64:r,Int64:r,UInt128:r,Int128:r,UInt256:r,Int256:r,Word8:r,Word16:r,Word32:r,Word64:r,UFix64:r,Fix64:r,String:t,Character:t,Bool:t,Address:t,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?i(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(i(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(i(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:n,Resource:n,Struct:n},c=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},i=function(e,r,t){try{var n=c(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},s=function(r,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var c=e({},o,{},t);return Promise.resolve(i(r,c,n))},a=function(r,t){void 0===t&&(t={});try{var n=!1,c=e({},o,{},t),i=r.encodedData?(n=!0,Promise.resolve(s(r.encodedData,c))):r.transaction?(n=!0,Promise.resolve(Promise.all(r.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return e({},r.transaction,{events:t})})):r.events?(n=!0,Promise.resolve(Promise.all(r.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):r.account?(n=!0,r.account):r.latestBlock?(n=!0,r.latestBlock):r.transactionId?(n=!0,r.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}};export{s as decode,a as decodeResponse};
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var r=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},t=function(e){return Promise.resolve(e)},n=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&c(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},o={UInt:r,Int:r,UInt8:r,Int8:r,UInt16:r,Int16:r,UInt32:r,Int32:r,UInt64:r,Int64:r,UInt128:r,Int128:r,UInt256:r,Int256:r,Word8:r,Word16:r,Word32:r,Word64:r,UFix64:t,Fix64:t,String:t,Character:t,Bool:t,Address:t,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?i(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(i(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(i(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:n,Resource:n,Struct:n},c=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},i=function(e,r,t){try{var n=c(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},s=function(r,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var c=e({},o,{},t);return Promise.resolve(i(r,c,n))},a=function(r,t){void 0===t&&(t={});try{var n=!1,c=e({},o,{},t),i=r.encodedData?(n=!0,Promise.resolve(s(r.encodedData,c))):r.transaction?(n=!0,Promise.resolve(Promise.all(r.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return e({},r.transaction,{events:t})})):r.events?(n=!0,Promise.resolve(Promise.all(r.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):r.account?(n=!0,r.account):r.block?(n=!0,r.block):r.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=!0,r.latestBlock):r.transactionId?(n=!0,r.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}};export{s as decode,a as decodeResponse};
//# sourceMappingURL=decode.modern.js.map

@@ -1,2 +0,2 @@

function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var r=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},t=function(e){return Promise.resolve(e)},n=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&c(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},o={UInt:r,Int:r,UInt8:r,Int8:r,UInt16:r,Int16:r,UInt32:r,Int32:r,UInt64:r,Int64:r,UInt128:r,Int128:r,UInt256:r,Int256:r,Word8:r,Word16:r,Word32:r,Word64:r,UFix64:r,Fix64:r,String:t,Character:t,Bool:t,Address:t,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?i(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(i(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(i(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:n,Resource:n,Struct:n},c=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},i=function(e,r,t){try{var n=c(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},s=function(r,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var c=e({},o,{},t);return Promise.resolve(i(r,c,n))},a=function(r,t){void 0===t&&(t={});try{var n=!1,c=e({},o,{},t),i=r.encodedData?(n=!0,Promise.resolve(s(r.encodedData,c))):r.transaction?(n=!0,Promise.resolve(Promise.all(r.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return e({},r.transaction,{events:t})})):r.events?(n=!0,Promise.resolve(Promise.all(r.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):r.account?(n=!0,r.account):r.latestBlock?(n=!0,r.latestBlock):r.transactionId?(n=!0,r.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}};export{s as decode,a as decodeResponse};
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var r=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},t=function(e){return Promise.resolve(e)},n=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&c(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},o={UInt:r,Int:r,UInt8:r,Int8:r,UInt16:r,Int16:r,UInt32:r,Int32:r,UInt64:r,Int64:r,UInt128:r,Int128:r,UInt256:r,Int256:r,Word8:r,Word16:r,Word32:r,Word64:r,UFix64:t,Fix64:t,String:t,Character:t,Bool:t,Address:t,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?i(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(i(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(i(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(i(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:n,Resource:n,Struct:n},c=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},i=function(e,r,t){try{var n=c(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},s=function(r,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var c=e({},o,{},t);return Promise.resolve(i(r,c,n))},a=function(r,t){void 0===t&&(t={});try{var n=!1,c=e({},o,{},t),i=r.encodedData?(n=!0,Promise.resolve(s(r.encodedData,c))):r.transaction?(n=!0,Promise.resolve(Promise.all(r.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return e({},r.transaction,{events:t})})):r.events?(n=!0,Promise.resolve(Promise.all(r.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,o=e.type;return Promise.resolve(s(e.payload,c)).then(function(e){return{type:o,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):r.account?(n=!0,r.account):r.block?(n=!0,r.block):r.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=!0,r.latestBlock):r.transactionId?(n=!0,r.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}};export{s as decode,a as decodeResponse};
//# sourceMappingURL=decode.module.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).decode={})}(this,function(e){function r(){return(r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var t=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},n=function(e){return Promise.resolve(e)},o=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(s(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&i(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},c={UInt:t,Int:t,UInt8:t,Int8:t,UInt16:t,Int16:t,UInt32:t,Int32:t,UInt64:t,Int64:t,UInt128:t,Int128:t,UInt256:t,Int256:t,Word8:t,Word16:t,Word32:t,Word64:t,UFix64:t,Fix64:t,String:n,Character:n,Bool:n,Address:n,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?s(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(s(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(s(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(s(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:o,Resource:o,Struct:o},i=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},s=function(e,r,t){try{var n=i(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},u=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var o=r({},c,{},t);return Promise.resolve(s(e,o,n))};e.decode=u,e.decodeResponse=function(e,t){void 0===t&&(t={});try{var n=!1,o=r({},c,{},t),i=e.encodedData?(n=!0,Promise.resolve(u(e.encodedData,o))):e.transaction?(n=!0,Promise.resolve(Promise.all(e.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,c=e.type;return Promise.resolve(u(e.payload,o)).then(function(e){return{type:c,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return r({},e.transaction,{events:t})})):e.events?(n=!0,Promise.resolve(Promise.all(e.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,c=e.type;return Promise.resolve(u(e.payload,o)).then(function(e){return{type:c,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=!0,e.account):e.latestBlock?(n=!0,e.latestBlock):e.transactionId?(n=!0,e.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).decode={})}(this,function(e){function r(){return(r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var t=function(e,r,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},n=function(e){return Promise.resolve(e)},o=function(e,r,t){try{return Promise.resolve(e.fields.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(s(n.value,r,[].concat(t,[n.name]))).then(function(r){return e[n.name]=r,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var n=e.id&&i(r,e.id);return n?Promise.resolve(n(t)):t})}catch(e){return Promise.reject(e)}},c={UInt:t,Int:t,UInt8:t,Int8:t,UInt16:t,Int16:t,UInt32:t,Int32:t,UInt64:t,Int64:t,UInt128:t,Int128:t,UInt256:t,Int256:t,Word8:t,Word16:t,Word32:t,Word64:t,UFix64:n,Fix64:n,String:n,Character:n,Bool:n,Address:n,Void:function(){return Promise.resolve(null)},Optional:function(e,r,t){return Promise.resolve(e?s(e,r,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,r,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(n){try{return Promise.resolve(s(e,r,[].concat(t,[e.type]))).then(n)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,r,t){try{return Promise.resolve(e.reduce(function(e,n){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(s(n.key,r,[].concat(t,[n.key]))).then(function(o){return Promise.resolve(s(n.value,r,[].concat(t,[n.key]))).then(function(r){return e[o]=r,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:o,Resource:o,Struct:o},i=function(e,r){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(r):e===r});return r&&t&&e[t]},s=function(e,r,t){try{var n=i(r,e.type);if(!n)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(n(e.value,r,t))}catch(e){return Promise.reject(e)}},a=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var o=r({},c,{},t);return Promise.resolve(s(e,o,n))};e.decode=a,e.decodeResponse=function(e,t){void 0===t&&(t={});try{var n=!1,o=r({},c,{},t),i=e.encodedData?(n=!0,Promise.resolve(a(e.encodedData,o))):e.transaction?(n=!0,Promise.resolve(Promise.all(e.transaction.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,c=e.type;return Promise.resolve(a(e.payload,o)).then(function(e){return{type:c,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return r({},e.transaction,{events:t})})):e.events?(n=!0,Promise.resolve(Promise.all(e.events.map(function(e){try{var r=e.eventIndex,t=e.transactionIndex,n=e.transactionId,c=e.type;return Promise.resolve(a(e.payload,o)).then(function(e){return{type:c,transactionId:n,transactionIndex:t,eventIndex:r,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=!0,e.account):e.block?(n=!0,e.block):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=!0,e.latestBlock):e.transactionId?(n=!0,e.transactionId):void 0;return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}}});
//# sourceMappingURL=decode.umd.js.map
{
"name": "@onflow/decode",
"version": "0.0.6",
"version": "0.0.7",
"description": "Flow SDK Decoder",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -0,1 +1,18 @@

const latestBlockDeprecationNotice = () => {
console.error(
`
%c@onflow/decode Deprecation Notice
========================
Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.
Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field
=======================
`
.replace(/\n\s+/g, "\n")
.trim(),
"font-weight:bold;font-family:monospace;"
)
}
const decodeNumber = async (num, _, stack) => {

@@ -66,4 +83,4 @@ try {

Word64: decodeNumber,
UFix64: decodeNumber,
Fix64: decodeNumber,
UFix64: decodeImplicit,
Fix64: decodeImplicit,
String: decodeImplicit,

@@ -146,3 +163,6 @@ Character: decodeImplicit,

return response.account
} else if (response.block) {
return response.block
} else if (response.latestBlock) {
latestBlockDeprecationNotice()
return response.latestBlock

@@ -149,0 +169,0 @@ } else if (response.transactionId) {

@@ -315,3 +315,3 @@ import * as root from "./decode"

expect(decoded).toStrictEqual(789.0012301)
expect(decoded).toStrictEqual("789.00123010")
})

@@ -324,3 +324,3 @@

expect(decoded).toStrictEqual(-12345.006789)
expect(decoded).toStrictEqual("-12345.00678900")
})

@@ -333,3 +333,3 @@

expect(decoded).toStrictEqual(789.0012301)
expect(decoded).toStrictEqual("789.00123010")
})

@@ -336,0 +336,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc