@onflow/sdk
Advanced tools
Comparing version 0.0.31 to 0.0.32
@@ -5,2 +5,6 @@ ### Unreleased | ||
### 0.0.32 -- 2020-09-29 | ||
- 2020-09-29 -- Deprecate resolverParams | ||
### 0.0.31 -- 2020-08-25 | ||
@@ -7,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/interaction"),r=require("@onflow/send"),n=require("@onflow/decode"),t=require("@qvvg/templar"),o=require("@onflow/encode");function i(r){return void 0===r&&(r=[]),e.pipe(e.interaction(),r)}var u=e.pipe;function s(){return(s=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function a(r){return e.pipe([e.makeGetAccount,function(n){return n.accountAddr=r,e.Ok(n)}])}function f(r){return void 0===r&&(r=!1),e.pipe([e.makeGetLatestBlock,function(n){return n.block.isSealed=r,e.Ok(n)}])}var p={asArgument:function(e){return e},asInjection:function(e){return e}},l={asArgument:function(e){return e},asInjection:function(e){return e}},d=[];const m=function(){function e(){}return e.prototype.then=function(r,n){const t=new e,o=this.s;if(o){const e=1&o?r:n;if(e){try{v(t,1,e(this.v))}catch(e){v(t,2,e)}return t}return this}return this.o=function(e){try{const o=e.v;1&e.s?v(t,1,r?r(o):o):n?v(t,1,n(o)):v(t,2,o)}catch(e){v(t,2,e)}},t},e}();function v(e,r,n){if(!e.s){if(n instanceof m){if(!n.s)return void(n.o=v.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(v.bind(null,e,r),v.bind(null,e,2));e.s=r,e.v=n;const t=e.o;t&&t(e)}}function y(e){return e instanceof m&&1&e.s}const h="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var g=function(e){return"function"==typeof e},k=function(e){return"number"==typeof e},b=function(e){return"string"==typeof e},P=function(e,r){if(!e){var n,t=new Error("INVARIANT "+r);t.stack=t.stack.split("\n").filter(function(e){return!/at invariant/.test(e)}).join("\n");for(var o=arguments.length,i=new Array(o>2?o-2:0),u=2;u<o;u++)i[u-2]=arguments[u];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(i,["\n\n---\n\n"])),t}},O=function(e){return!(e.role.proposer&&!(b(e.addr)&&k(e.keyId)&&k(e.sequenceNum)&&g(e.signingFunction))||e.role.payer&&!(b(e.addr)&&k(e.keyId)&&g(e.signingFunction))||e.role.authorizer&&!(b(e.addr)&&k(e.keyId)&&g(e.signingFunction)))},x=function(e){return void 0===e&&(e=[]),e.filter(Boolean)[0]||null},I=function(e){return void 0===e&&(e=[]),e.find(function(e){return e.role.proposer})||{}},j=e.pipe([function(r){try{var n=function(){return e.Ok(r)};if(!e.isTransaction(r))return Promise.resolve(e.Ok(r));var t=function(e,r,n){if("function"==typeof e[h]){var t,o,i,u=e[h]();if(function e(n){try{for(;!(t=u.next()).done;)if((n=r(t.value))&&n.then){if(!y(n))return void n.then(e,i||(i=v.bind(null,o=new m,2)));n=n.v}o?v(o,1,n):o=n}catch(e){v(o||(o=new m),2,e)}}(),u.return){var s=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],a=0;a<e.length;a++)c.push(e[a]);return function(e,r,n){var t,o,i=-1;return function n(u){try{for(;++i<e.length;)if((u=r(i))&&u.then){if(!y(u))return void u.then(n,o||(o=v.bind(null,t=new m,2)));u=u.v}t?v(t,1,u):t=u}catch(e){v(t||(t=new m),2,e)}}(),t}(c,function(e){return r(c[e])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){P(O(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var i=function(){if(g(t.resolve))return Promise.resolve(t.resolve(t)).then(function(e){r.accounts[n]=e})}();return i&&i.then?i.then(o):o()});return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},function(r){try{if(!e.isTransaction(r))return Promise.resolve(e.Ok(r));for(var n=function(){var e,n,i,u=o[t],c=u.addr+"|"+u.keyId;r.accounts[c]=null!=r.accounts[c]?(e=r.accounts[c],n=s({tempId:c},u),{kind:x([e.kind,n.kind]),tempId:x([e.tempId,n.tempId]),addr:x([e.addr,n.addr]),keyId:(i=[e.keyId,n.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(k)[0]?i.filter(k)[0]:null),sequenceNum:"number"==typeof I([e,n]).sequenceNum?I([e,n]).sequenceNum:e.sequenceNum,signature:x([e.signature,n.signature]),signingFunction:x([e.signingFunction,n.signingFunction]),resolve:x([e.resolve,n.resolve]),role:{proposer:e.role.proposer||n.role.proposer,authorizer:e.role.authorizer||n.role.authorizer,payer:e.role.payer||n.role.payer,param:e.role.param||n.role.param}}):s({tempId:c},u),r.proposer===u.tempId&&(r.proposer=c),r.payer===u.tempId&&(r.payer=c),r.authorizations=r.authorizations.map(function(e){return e===u.tempId?c:e}),delete r.accounts[u.tempId]},t=0,o=Object.values(r.accounts);t<o.length;t++)n();for(var i=0,u=Object.values(r.accounts);i<u.length;i++){var c=u[i];P(O(c),"Account unable to fulfill roles",c)}return Promise.resolve(e.Ok(r))}catch(e){return Promise.reject(e)}}]);function S(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(r){return e.arguments[r].asArgument}),proposalKey:{address:e.accounts[e.proposer].addr,keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:e.accounts[e.payer].addr,authorizers:e.authorizations.map(function(r){return e.accounts[r].addr})}}var w=function(e,r,n){void 0===r&&(r=[]);try{return Promise.all(r.map(function(r){try{return Promise.resolve(e.accounts[r].signingFunction({message:n,addr:e.accounts[r].addr,keyId:e.accounts[r].keyId,roles:e.accounts[r].role,interaction:e})).then(function(n){if(n.cid=r,e.accounts[r].addr!==n.addr)throw new Error(r+" — mismatching address in composite signature");if(e.accounts[r].keyId!==n.keyId)throw new Error(r+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function A(e,r){for(var n,t=function(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return c(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(r);!(n=t()).done;){var o=n.value;e.accounts[o.cid].signature=o.signature}return r}Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return r.send}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(exports,"decodeResponse",{enumerable:!0,get:function(){return n.decodeResponse}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return t.templar}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return t.templar}}),exports.arg=function(e,r){return void 0===r&&(r=l),{value:e,xform:r}},exports.args=function(r){return void 0===r&&(r=[]),e.pipe(r.map(function(r){return e.makeArgument("function"==typeof r?{resolve:r}:r)}))},exports.authorization=function(e,r,n,t){return{addr:e,signingFunction:r,keyId:n,sequenceNum:t}},exports.authorizations=function(r){return void 0===r&&(r=[]),e.pipe(r.map(function(r){return e.makeAuthorizer(s({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))},exports.build=i,exports.getAccount=a,exports.getBlockByHeight=function(r){return e.pipe([e.makeGetBlockByHeight,function(n){return n.block.height=r,e.Ok(n)}])},exports.getBlockById=function(r){return e.pipe([e.makeGetBlockById,function(n){return n.block.id=r,e.Ok(n)}])},exports.getEvents=function(r,n,t){return e.pipe([e.makeGetEvents,function(n){return n.events.eventType=r,e.Ok(n)},function(r){return r.events.start=n,e.Ok(r)},function(r){return r.events.end=t,e.Ok(r)}])},exports.getLatestBlock=f,exports.getTransactionStatus=function(r){return e.pipe([e.makeGetTransactionStatus,function(n){return n.transactionId=r,e.Ok(n)}])},exports.invariant=function r(){for(var n=arguments.length,t=new Array(n),o=0;o<n;o++)t[o]=arguments[o];if(t.length>1){var i=t[0],u=t[1];return r(function(e,r){var n=r.Bad;return i?(0,r.Ok)(e):n(e,u)})}var s=t[0];return function(r){return s(r,{Ok:e.Ok,Bad:e.Bad})}},exports.limit=function(r){return e.pipe([function(n){return n.message.computeLimit=r,e.Ok(n)}])},exports.param=function(e,r,n){return void 0===r&&(r=p),void 0===n&&(n=null),{key:n,value:e,xform:r}},exports.params=function(r){return void 0===r&&(r=[]),e.pipe(r.map(function(r){return e.makeParam("function"==typeof r?{resolve:r}:r)}))},exports.payer=function(r){return e.makePayer(s({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))},exports.ping=function(){return e.pipe([e.makePing])},exports.proposer=function(r){try{return Promise.resolve(e.makeProposer("function"==typeof r?{resolve:r,role:{proposer:!0}}:s({},r,{role:{proposer:!0}})))}catch(e){return Promise.reject(e)}},exports.ref=function(r){return e.pipe([function(n){return n.message.refBlock=r,e.Ok(n)}])},exports.resolve=u,exports.resolveAccounts=j,exports.resolveArguments=function(r){try{if(!e.isTransaction(r)&&!e.isScript(r))return Promise.resolve(e.Ok(r));var n=Object.values(r.arguments);return Promise.resolve(Promise.all(n.map(function(e){try{var r=!1,n=function(){if("function"==typeof e.resolve)return r=!0,Promise.resolve(e.resolve()).then(function(r){return s({},r,{tempId:e.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return r?n:e}):r?n:e)}catch(e){return Promise.reject(e)}}))).then(function(n){return n.forEach(function(e){r.arguments[e.tempId]=s({},e,{asArgument:e.xform.asArgument(e.value)})}),e.Ok(r)})}catch(e){return Promise.reject(e)}},exports.resolveParams=function(r){try{var n=function(e){if(t)return e;throw new Error("Invalid Cadence Value")},t=!1;if(!e.isTransaction(r)&&!e.isScript(r))return Promise.resolve(e.Ok(r));var o=e.get(r,"ix.cadence");if("string"==typeof o)return r.message.cadence=o,Promise.resolve(e.Ok(r));var i=function(){if("function"==typeof o){var n=Object.values(r.params);return Promise.resolve(Promise.all(n.map(function(e){try{var r=!1,n=function(){if("function"==typeof e.resolve)return r=!0,Promise.resolve(e.resolve()).then(function(r){return s({},r,{tempId:e.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return r?n:e}):r?n:e)}catch(e){return Promise.reject(e)}}))).then(function(n){return n.forEach(function(e){r.params[e.tempId]=e}),n=Object.fromEntries(n.filter(function(e){return null!=e.key}).map(function(e){return[e.key,e.xform.asInjection(e.value)]})),r.message.cadence=o(n),t=!0,e.Ok(r)})}}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(e){return Promise.reject(e)}},exports.resolveProposerSequenceNumber=function(t){var o=t.node;return function(t){try{return e.isTransaction(t)?t.accounts[t.proposer].sequenceNum?Promise.resolve(e.Ok(t)):Promise.resolve(i([a(t.accounts[t.proposer].addr)])).then(function(i){return Promise.resolve(r.send(i,{node:o})).then(function(r){return Promise.resolve(n.decodeResponse(r)).then(function(r){return t.accounts[t.proposer].sequenceNum=r.keys[t.accounts[t.proposer].keyId].sequenceNumber,e.Ok(t)})})}):Promise.resolve(e.Ok(t))}catch(e){return Promise.reject(e)}}},exports.resolveRefBlockId=function(t){var o=t.node;return function(t){try{return e.isTransaction(t)?t.message.refBlock?Promise.resolve(e.Ok(t)):Promise.resolve(i([f()])).then(function(i){return Promise.resolve(r.send(i,{node:o})).then(function(r){return Promise.resolve(n.decodeResponse(r)).then(function(r){return t.message.refBlock=r.id,e.Ok(t)})})}):Promise.resolve(e.Ok(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=function(r){try{if(!e.isTransaction(r))return Promise.resolve(r);var n=function(e){var r=new Set(e.authorizations);r.add(e.proposer),r.delete(e.payer),r=Array.from(r);var n=new Set([e.payer]);return{insideSigners:r,outsideSigners:n=Array.from(n)}}(r),t=n.outsideSigners;return Promise.resolve(w(r,n.insideSigners,o.encodeTransactionPayload(S(r)))).then(function(e){var n=A(r,e);return Promise.resolve(w(r,t,o.encodeTransactionEnvelope(s({},S(r),{payloadSigs:n})))).then(function(e){return A(r,e),r})})}catch(e){return Promise.reject(e)}},exports.resolveValidators=function(r){try{var n=e.get(r,"ix.validators",[]);return Promise.resolve(e.pipe(r,n.map(function(r){return function(n){return r(n,{Ok:e.Ok,Bad:e.Bad})}})))}catch(e){return Promise.reject(e)}},exports.script=function(){return e.pipe([e.makeScript,e.put("ix.cadence",t.templar.apply(void 0,arguments))])},exports.transaction=function(){return e.pipe([e.makeTransaction,e.put("ix.cadence",t.templar.apply(void 0,arguments)),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||d,e.Ok(r)}])},exports.validator=function(r){return e.update("ix.validators",function(e){return Array.isArray(e)?e.push(r):[r]})}; | ||
var e=require("@onflow/interaction"),r=require("@onflow/send"),n=require("@onflow/decode"),t=require("@qvvg/templar"),o=require("@onflow/sdk-resolve-cadence"),i=require("@onflow/encode");function u(r){return void 0===r&&(r=[]),e.pipe(e.interaction(),r)}var s=e.pipe;function c(){return(c=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function p(r){return e.pipe([e.makeGetAccount,function(n){return n.accountAddr=r,e.Ok(n)}])}function f(r){return void 0===r&&(r=!1),e.pipe([e.makeGetLatestBlock,function(n){return n.block.isSealed=r,e.Ok(n)}])}var l={asArgument:function(e){return e},asInjection:function(e){return e}},d={asArgument:function(e){return e},asInjection:function(e){return e}},m=[];const v=function(){function e(){}return e.prototype.then=function(r,n){const t=new e,o=this.s;if(o){const e=1&o?r:n;if(e){try{y(t,1,e(this.v))}catch(e){y(t,2,e)}return t}return this}return this.o=function(e){try{const o=e.v;1&e.s?y(t,1,r?r(o):o):n?y(t,1,n(o)):y(t,2,o)}catch(e){y(t,2,e)}},t},e}();function y(e,r,n){if(!e.s){if(n instanceof v){if(!n.s)return void(n.o=y.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(y.bind(null,e,r),y.bind(null,e,2));e.s=r,e.v=n;const t=e.o;t&&t(e)}}function g(e){return e instanceof v&&1&e.s}const h="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var k=function(e){return"function"==typeof e},b=function(e){return"number"==typeof e},P=function(e){return"string"==typeof e},O=function(e,r){if(!e){var n,t=new Error("INVARIANT "+r);t.stack=t.stack.split("\n").filter(function(e){return!/at invariant/.test(e)}).join("\n");for(var o=arguments.length,i=new Array(o>2?o-2:0),u=2;u<o;u++)i[u-2]=arguments[u];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(i,["\n\n---\n\n"])),t}},x=function(e){return!(e.role.proposer&&!(P(e.addr)&&b(e.keyId)&&b(e.sequenceNum)&&k(e.signingFunction))||e.role.payer&&!(P(e.addr)&&b(e.keyId)&&k(e.signingFunction))||e.role.authorizer&&!(P(e.addr)&&b(e.keyId)&&k(e.signingFunction)))},I=function(e){return void 0===e&&(e=[]),e.filter(Boolean)[0]||null},j=function(e){return void 0===e&&(e=[]),e.find(function(e){return e.role.proposer})||{}},w=e.pipe([function(r){try{var n=function(){return e.Ok(r)};if(!e.isTransaction(r))return Promise.resolve(e.Ok(r));var t=function(e,r,n){if("function"==typeof e[h]){var t,o,i,u=e[h]();if(function e(n){try{for(;!(t=u.next()).done;)if((n=r(t.value))&&n.then){if(!g(n))return void n.then(e,i||(i=y.bind(null,o=new v,2)));n=n.v}o?y(o,1,n):o=n}catch(e){y(o||(o=new v),2,e)}}(),u.return){var s=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],a=0;a<e.length;a++)c.push(e[a]);return function(e,r,n){var t,o,i=-1;return function n(u){try{for(;++i<e.length;)if((u=r(i))&&u.then){if(!g(u))return void u.then(n,o||(o=y.bind(null,t=new v,2)));u=u.v}t?y(t,1,u):t=u}catch(e){y(t||(t=new v),2,e)}}(),t}(c,function(e){return r(c[e])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){O(x(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var i=function(){if(k(t.resolve))return Promise.resolve(t.resolve(t)).then(function(e){r.accounts[n]=e})}();return i&&i.then?i.then(o):o()});return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},function(r){try{if(!e.isTransaction(r))return Promise.resolve(e.Ok(r));for(var n=function(){var e,n,i,u=o[t],s=u.addr+"|"+u.keyId;r.accounts[s]=null!=r.accounts[s]?(e=r.accounts[s],n=c({tempId:s},u),{kind:I([e.kind,n.kind]),tempId:I([e.tempId,n.tempId]),addr:I([e.addr,n.addr]),keyId:(i=[e.keyId,n.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(b)[0]?i.filter(b)[0]:null),sequenceNum:"number"==typeof j([e,n]).sequenceNum?j([e,n]).sequenceNum:e.sequenceNum,signature:I([e.signature,n.signature]),signingFunction:I([e.signingFunction,n.signingFunction]),resolve:I([e.resolve,n.resolve]),role:{proposer:e.role.proposer||n.role.proposer,authorizer:e.role.authorizer||n.role.authorizer,payer:e.role.payer||n.role.payer,param:e.role.param||n.role.param}}):c({tempId:s},u),r.proposer===u.tempId&&(r.proposer=s),r.payer===u.tempId&&(r.payer=s),r.authorizations=r.authorizations.map(function(e){return e===u.tempId?s:e}),delete r.accounts[u.tempId]},t=0,o=Object.values(r.accounts);t<o.length;t++)n();for(var i=0,u=Object.values(r.accounts);i<u.length;i++){var s=u[i];O(x(s),"Account unable to fulfill roles",s)}return Promise.resolve(e.Ok(r))}catch(e){return Promise.reject(e)}}]);function S(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(r){return e.arguments[r].asArgument}),proposalKey:{address:e.accounts[e.proposer].addr,keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:e.accounts[e.payer].addr,authorizers:e.authorizations.map(function(r){return e.accounts[r].addr})}}var A=function(e,r,n){void 0===r&&(r=[]);try{return Promise.all(r.map(function(r){try{return Promise.resolve(e.accounts[r].signingFunction({message:n,addr:e.accounts[r].addr,keyId:e.accounts[r].keyId,roles:e.accounts[r].role,interaction:e})).then(function(n){if(n.cid=r,e.accounts[r].addr!==n.addr)throw new Error(r+" — mismatching address in composite signature");if(e.accounts[r].keyId!==n.keyId)throw new Error(r+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function B(e,r){for(var n,t=function(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return a(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(r);!(n=t()).done;){var o=n.value;e.accounts[o.cid].signature=o.signature}return r}Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return r.send}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(exports,"decodeResponse",{enumerable:!0,get:function(){return n.decodeResponse}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return t.templar}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return t.templar}}),exports.arg=function(e,r){return void 0===r&&(r=d),{value:e,xform:r}},exports.args=function(r){return void 0===r&&(r=[]),e.pipe(r.map(function(r){return e.makeArgument("function"==typeof r?{resolve:r}:r)}))},exports.authorization=function(e,r,n,t){return{addr:e,signingFunction:r,keyId:n,sequenceNum:t}},exports.authorizations=function(r){return void 0===r&&(r=[]),e.pipe(r.map(function(r){return e.makeAuthorizer(c({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))},exports.build=u,exports.getAccount=p,exports.getBlockByHeight=function(r){return e.pipe([e.makeGetBlockByHeight,function(n){return n.block.height=r,e.Ok(n)}])},exports.getBlockById=function(r){return e.pipe([e.makeGetBlockById,function(n){return n.block.id=r,e.Ok(n)}])},exports.getEvents=function(r,n,t){return e.pipe([e.makeGetEvents,function(n){return n.events.eventType=r,e.Ok(n)},function(r){return r.events.start=n,e.Ok(r)},function(r){return r.events.end=t,e.Ok(r)}])},exports.getLatestBlock=f,exports.getTransactionStatus=function(r){return e.pipe([e.makeGetTransactionStatus,function(n){return n.transactionId=r,e.Ok(n)}])},exports.invariant=function r(){for(var n=arguments.length,t=new Array(n),o=0;o<n;o++)t[o]=arguments[o];if(t.length>1){var i=t[0],u=t[1];return r(function(e,r){var n=r.Bad;return i?(0,r.Ok)(e):n(e,u)})}var s=t[0];return function(r){return s(r,{Ok:e.Ok,Bad:e.Bad})}},exports.limit=function(r){return e.pipe([function(n){return n.message.computeLimit=r,e.Ok(n)}])},exports.param=function(e,r,n){return void 0===r&&(r=l),void 0===n&&(n=null),{key:n,value:e,xform:r}},exports.params=function(r){return void 0===r&&(r=[]),e.pipe(r.map(function(r){return e.makeParam("function"==typeof r?{resolve:r}:r)}))},exports.payer=function(r){return e.makePayer(c({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))},exports.ping=function(){return e.pipe([e.makePing])},exports.proposer=function(r){try{return Promise.resolve(e.makeProposer("function"==typeof r?{resolve:r,role:{proposer:!0}}:c({},r,{role:{proposer:!0}})))}catch(e){return Promise.reject(e)}},exports.ref=function(r){return e.pipe([function(n){return n.message.refBlock=r,e.Ok(n)}])},exports.resolve=s,exports.resolveAccounts=w,exports.resolveArguments=function(r){try{if(!e.isTransaction(r)&&!e.isScript(r))return Promise.resolve(e.Ok(r));var n=Object.values(r.arguments);return Promise.resolve(Promise.all(n.map(function(e){try{var r=!1,n=function(){if("function"==typeof e.resolve)return r=!0,Promise.resolve(e.resolve()).then(function(r){return c({},r,{tempId:e.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return r?n:e}):r?n:e)}catch(e){return Promise.reject(e)}}))).then(function(n){return n.forEach(function(e){r.arguments[e.tempId]=c({},e,{asArgument:e.xform.asArgument(e.value)})}),e.Ok(r)})}catch(e){return Promise.reject(e)}},exports.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),o.resolveCadence(e)},exports.resolveProposerSequenceNumber=function(t){var o=t.node;return function(t){try{return e.isTransaction(t)?t.accounts[t.proposer].sequenceNum?Promise.resolve(e.Ok(t)):Promise.resolve(u([p(t.accounts[t.proposer].addr)])).then(function(i){return Promise.resolve(r.send(i,{node:o})).then(function(r){return Promise.resolve(n.decodeResponse(r)).then(function(r){return t.accounts[t.proposer].sequenceNum=r.keys[t.accounts[t.proposer].keyId].sequenceNumber,e.Ok(t)})})}):Promise.resolve(e.Ok(t))}catch(e){return Promise.reject(e)}}},exports.resolveRefBlockId=function(t){var o=t.node;return function(t){try{return e.isTransaction(t)?t.message.refBlock?Promise.resolve(e.Ok(t)):Promise.resolve(u([f()])).then(function(i){return Promise.resolve(r.send(i,{node:o})).then(function(r){return Promise.resolve(n.decodeResponse(r)).then(function(r){return t.message.refBlock=r.id,e.Ok(t)})})}):Promise.resolve(e.Ok(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=function(r){try{if(!e.isTransaction(r))return Promise.resolve(r);var n=function(e){var r=new Set(e.authorizations);r.add(e.proposer),r.delete(e.payer),r=Array.from(r);var n=new Set([e.payer]);return{insideSigners:r,outsideSigners:n=Array.from(n)}}(r),t=n.outsideSigners;return Promise.resolve(A(r,n.insideSigners,i.encodeTransactionPayload(S(r)))).then(function(e){var n=B(r,e);return Promise.resolve(A(r,t,i.encodeTransactionEnvelope(c({},S(r),{payloadSigs:n})))).then(function(e){return B(r,e),r})})}catch(e){return Promise.reject(e)}},exports.resolveValidators=function(r){try{var n=e.get(r,"ix.validators",[]);return Promise.resolve(e.pipe(r,n.map(function(r){return function(n){return r(n,{Ok:e.Ok,Bad:e.Bad})}})))}catch(e){return Promise.reject(e)}},exports.script=function(){return e.pipe([e.makeScript,e.put("ix.cadence",t.templar.apply(void 0,arguments))])},exports.transaction=function(){return e.pipe([e.makeTransaction,e.put("ix.cadence",t.templar.apply(void 0,arguments)),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||m,e.Ok(r)}])},exports.validator=function(r){return e.update("ix.validators",function(e){return Array.isArray(e)?e.push(r):[r]})}; | ||
//# sourceMappingURL=sdk.js.map |
@@ -1,2 +0,2 @@ | ||
import{pipe as r,interaction as e,makeAuthorizer as n,makeGetAccount as t,Ok as o,makeGetEvents as u,makeGetLatestBlock as i,makeGetBlockById as c,makeGetBlockByHeight as s,makeGetTransactionStatus as a,makeParam as f,makeArgument as l,makeProposer as m,makePayer as d,makePing as v,makeScript as p,put as y,makeTransaction as h,update as g,Bad as P,isTransaction as b,isScript as I,get as k}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{send as w}from"@onflow/send";export{send}from"@onflow/send";import{decodeResponse as j}from"@onflow/decode";export{decode,decodeResponse}from"@onflow/decode";import{templar as S}from"@qvvg/templar";export{templar as cadence,templar as cdc}from"@qvvg/templar";import{encodeTransactionPayload as A,encodeTransactionEnvelope as x}from"@onflow/encode";function O(n){return void 0===n&&(n=[]),r(e(),n)}var q=r;function N(){return(N=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}function z(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}function B(e){return void 0===e&&(e=[]),r(e.map(function(r){return n(N({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))}function E(r,e,n,t){return{addr:r,signingFunction:e,keyId:n,sequenceNum:t}}function F(e){return r([t,function(r){return r.accountAddr=e,o(r)}])}function L(e,n,t){return r([u,function(r){return r.events.eventType=e,o(r)},function(r){return r.events.start=n,o(r)},function(r){return r.events.end=t,o(r)}])}function T(e){return void 0===e&&(e=!1),r([i,function(r){return r.block.isSealed=e,o(r)}])}function C(e){return r([c,function(r){return r.block.id=e,o(r)}])}function R(e){return r([s,function(r){return r.block.height=e,o(r)}])}function V(e){return r([a,function(r){return r.transactionId=e,o(r)}])}function K(e){return r([function(r){return r.message.computeLimit=e,o(r)}])}function M(e){return void 0===e&&(e=[]),r(e.map(function(r){return f("function"==typeof r?{resolve:r}:r)}))}var U={asArgument:function(r){return r},asInjection:function(r){return r}};function $(r,e,n){return void 0===e&&(e=U),void 0===n&&(n=null),{key:n,value:r,xform:e}}function D(e){return void 0===e&&(e=[]),r(e.map(function(r){return l("function"==typeof r?{resolve:r}:r)}))}var G={asArgument:function(r){return r},asInjection:function(r){return r}};function H(r,e){return void 0===e&&(e=G),{value:r,xform:e}}var J=function(r){try{return Q(r)?Promise.resolve(m({resolve:r,role:{proposer:!0}})):Promise.resolve(m(N({},r,{role:{proposer:!0}})))}catch(r){return Promise.reject(r)}},Q=function(r){return"function"==typeof r};function W(r){return d(N({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))}function X(){return r([v])}function Y(e){return r([function(r){return r.message.refBlock=e,o(r)}])}function Z(){return r([p,y("ix.cadence",S.apply(void 0,arguments))])}var _=[];function rr(){return r([h,y("ix.cadence",S.apply(void 0,arguments)),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||_,o(r)}])}function er(r){return g("ix.validators",function(e){return Array.isArray(e)?e.push(r):[r]})}function nr(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];if(e.length>1){var t=e[0],u=e[1];return nr(function(r,e){var n=e.Bad;return t?(0,e.Ok)(r):n(r,u)})}var i=e[0];return function(r){return i(r,{Ok:o,Bad:P})}}const tr=function(){function r(){}return r.prototype.then=function(e,n){const t=new r,o=this.s;if(o){const r=1&o?e:n;if(r){try{or(t,1,r(this.v))}catch(r){or(t,2,r)}return t}return this}return this.o=function(r){try{const o=r.v;1&r.s?or(t,1,e?e(o):o):n?or(t,1,n(o)):or(t,2,o)}catch(r){or(t,2,r)}},t},r}();function or(r,e,n){if(!r.s){if(n instanceof tr){if(!n.s)return void(n.o=or.bind(null,r,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(or.bind(null,r,e),or.bind(null,r,2));r.s=e,r.v=n;const t=r.o;t&&t(r)}}function ur(r){return r instanceof tr&&1&r.s}const ir="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var cr=function(r){return"function"==typeof r},sr=function(r){return"number"==typeof r},ar=function(r){return"string"==typeof r},fr=function(r,e){if(!r){var n,t=new Error("INVARIANT "+e);t.stack=t.stack.split("\n").filter(function(r){return!/at invariant/.test(r)}).join("\n");for(var o=arguments.length,u=new Array(o>2?o-2:0),i=2;i<o;i++)u[i-2]=arguments[i];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(u,["\n\n---\n\n"])),t}},lr=function(r){return!(r.role.proposer&&!(ar(r.addr)&&sr(r.keyId)&&sr(r.sequenceNum)&&cr(r.signingFunction))||r.role.payer&&!(ar(r.addr)&&sr(r.keyId)&&cr(r.signingFunction))||r.role.authorizer&&!(ar(r.addr)&&sr(r.keyId)&&cr(r.signingFunction)))},mr=function(r){return void 0===r&&(r=[]),r.filter(Boolean)[0]||null},dr=function(r){return void 0===r&&(r=[]),r.find(function(r){return r.role.proposer})||{}},vr=r([function(r){try{var e=function(){return o(r)};if(!b(r))return Promise.resolve(o(r));var n=function(r,e,n){if("function"==typeof r[ir]){var t,o,u,i=r[ir]();if(function r(n){try{for(;!(t=i.next()).done;)if((n=e(t.value))&&n.then){if(!ur(n))return void n.then(r,u||(u=or.bind(null,o=new tr,2)));n=n.v}o?or(o,1,n):o=n}catch(r){or(o||(o=new tr),2,r)}}(),i.return){var c=function(r){try{t.done||i.return()}catch(r){}return r};if(o&&o.then)return o.then(c,function(r){throw c(r)});c()}return o}if(!("length"in r))throw new TypeError("Object is not iterable");for(var s=[],a=0;a<r.length;a++)s.push(r[a]);return function(r,e,n){var t,o,u=-1;return function n(i){try{for(;++u<r.length;)if((i=e(u))&&i.then){if(!ur(i))return void i.then(n,o||(o=or.bind(null,t=new tr,2)));i=i.v}t?or(t,1,i):t=i}catch(r){or(t||(t=new tr),2,r)}}(),t}(s,function(r){return e(s[r])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){fr(lr(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var u=function(){if(cr(t.resolve))return Promise.resolve(t.resolve(t)).then(function(e){r.accounts[n]=e})}();return u&&u.then?u.then(o):o()});return Promise.resolve(n&&n.then?n.then(e):e())}catch(r){return Promise.reject(r)}},function(r){try{if(!b(r))return Promise.resolve(o(r));for(var e=function(){var e,o,u,i=t[n],c=i.addr+"|"+i.keyId;r.accounts[c]=null!=r.accounts[c]?(e=r.accounts[c],o=N({tempId:c},i),{kind:mr([e.kind,o.kind]),tempId:mr([e.tempId,o.tempId]),addr:mr([e.addr,o.addr]),keyId:(u=[e.keyId,o.keyId],void 0===u&&(u=[]),"number"==typeof u.filter(sr)[0]?u.filter(sr)[0]:null),sequenceNum:"number"==typeof dr([e,o]).sequenceNum?dr([e,o]).sequenceNum:e.sequenceNum,signature:mr([e.signature,o.signature]),signingFunction:mr([e.signingFunction,o.signingFunction]),resolve:mr([e.resolve,o.resolve]),role:{proposer:e.role.proposer||o.role.proposer,authorizer:e.role.authorizer||o.role.authorizer,payer:e.role.payer||o.role.payer,param:e.role.param||o.role.param}}):N({tempId:c},i),r.proposer===i.tempId&&(r.proposer=c),r.payer===i.tempId&&(r.payer=c),r.authorizations=r.authorizations.map(function(r){return r===i.tempId?c:r}),delete r.accounts[i.tempId]},n=0,t=Object.values(r.accounts);n<t.length;n++)e();for(var u=0,i=Object.values(r.accounts);u<i.length;u++){var c=i[u];fr(lr(c),"Account unable to fulfill roles",c)}return Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}]),pr=function(r){try{if(!b(r)&&!I(r))return Promise.resolve(o(r));var e=Object.values(r.arguments);return Promise.resolve(Promise.all(e.map(function(r){try{var e=!1,n=function(){if("function"==typeof r.resolve)return e=!0,Promise.resolve(r.resolve()).then(function(e){return N({},e,{tempId:r.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return e?n:r}):e?n:r)}catch(r){return Promise.reject(r)}}))).then(function(e){return e.forEach(function(e){r.arguments[e.tempId]=N({},e,{asArgument:e.xform.asArgument(e.value)})}),o(r)})}catch(r){return Promise.reject(r)}},yr=function(r){try{var e=function(r){if(n)return r;throw new Error("Invalid Cadence Value")},n=!1;if(!b(r)&&!I(r))return Promise.resolve(o(r));var t=k(r,"ix.cadence");if("string"==typeof t)return r.message.cadence=t,Promise.resolve(o(r));var u=function(){if("function"==typeof t){var e=Object.values(r.params);return Promise.resolve(Promise.all(e.map(function(r){try{var e=!1,n=function(){if("function"==typeof r.resolve)return e=!0,Promise.resolve(r.resolve()).then(function(e){return N({},e,{tempId:r.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return e?n:r}):e?n:r)}catch(r){return Promise.reject(r)}}))).then(function(e){return e.forEach(function(e){r.params[e.tempId]=e}),e=Object.fromEntries(e.filter(function(r){return null!=r.key}).map(function(r){return[r.key,r.xform.asInjection(r.value)]})),r.message.cadence=t(e),n=!0,o(r)})}}();return Promise.resolve(u&&u.then?u.then(e):e(u))}catch(r){return Promise.reject(r)}};function hr(r){return{script:r.message.cadence,refBlock:r.message.refBlock||null,gasLimit:r.message.computeLimit,arguments:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),proposalKey:{address:r.accounts[r.proposer].addr,keyId:r.accounts[r.proposer].keyId,sequenceNum:r.accounts[r.proposer].sequenceNum},payer:r.accounts[r.payer].addr,authorizers:r.authorizations.map(function(e){return r.accounts[e].addr})}}var gr=function(r){try{if(!b(r))return Promise.resolve(r);var e=function(r){var e=new Set(r.authorizations);e.add(r.proposer),e.delete(r.payer),e=Array.from(e);var n=new Set([r.payer]);return{insideSigners:e,outsideSigners:n=Array.from(n)}}(r),n=e.outsideSigners;return Promise.resolve(Pr(r,e.insideSigners,A(hr(r)))).then(function(e){var t=br(r,e);return Promise.resolve(Pr(r,n,x(N({},hr(r),{payloadSigs:t})))).then(function(e){return br(r,e),r})})}catch(r){return Promise.reject(r)}},Pr=function(r,e,n){void 0===e&&(e=[]);try{return Promise.all(e.map(function(e){try{return Promise.resolve(r.accounts[e].signingFunction({message:n,addr:r.accounts[e].addr,keyId:r.accounts[e].keyId,roles:r.accounts[e].role,interaction:r})).then(function(n){if(n.cid=e,r.accounts[e].addr!==n.addr)throw new Error(e+" — mismatching address in composite signature");if(r.accounts[e].keyId!==n.keyId)throw new Error(e+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(r){return Promise.reject(r)}}))}catch(r){return Promise.reject(r)}};function br(r,e){for(var n,t=function(r,e){var n;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(n=function(r,e){if(r){if("string"==typeof r)return z(r,void 0);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(r,void 0):void 0}}(r))){n&&(r=n);var t=0;return function(){return t>=r.length?{done:!0}:{done:!1,value:r[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=r[Symbol.iterator]()).next.bind(n)}(e);!(n=t()).done;){var o=n.value;r.accounts[o.cid].signature=o.signature}return e}var Ir=function(e){try{var n=k(e,"ix.validators",[]);return Promise.resolve(r(e,n.map(function(r){return function(e){return r(e,{Ok:o,Bad:P})}})))}catch(r){return Promise.reject(r)}},kr=function(r){var e=r.node;return function(r){try{return b(r)?r.accounts[r.proposer].sequenceNum?Promise.resolve(o(r)):Promise.resolve(O([F(r.accounts[r.proposer].addr)])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(j(e)).then(function(e){return r.accounts[r.proposer].sequenceNum=e.keys[r.accounts[r.proposer].keyId].sequenceNumber,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}},wr=function(r){var e=r.node;return function(r){try{return b(r)?r.message.refBlock?Promise.resolve(o(r)):Promise.resolve(O([T()])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(j(e)).then(function(e){return r.message.refBlock=e.id,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}};export{H as arg,D as args,E as authorization,B as authorizations,O as build,F as getAccount,R as getBlockByHeight,C as getBlockById,L as getEvents,T as getLatestBlock,V as getTransactionStatus,nr as invariant,K as limit,$ as param,M as params,W as payer,X as ping,J as proposer,Y as ref,q as resolve,vr as resolveAccounts,pr as resolveArguments,yr as resolveParams,kr as resolveProposerSequenceNumber,wr as resolveRefBlockId,gr as resolveSignatures,Ir as resolveValidators,Z as script,rr as transaction,er as validator}; | ||
import{pipe as r,interaction as e,makeAuthorizer as n,makeGetAccount as t,Ok as o,makeGetEvents as i,makeGetLatestBlock as u,makeGetBlockById as c,makeGetBlockByHeight as s,makeGetTransactionStatus as a,makeParam as f,makeArgument as l,makeProposer as d,makePayer as m,makePing as p,makeScript as v,put as y,makeTransaction as h,update as g,Bad as b,isTransaction as k,isScript as I,get as P}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{send as w}from"@onflow/send";export{send}from"@onflow/send";import{decodeResponse as S}from"@onflow/decode";export{decode,decodeResponse}from"@onflow/decode";import{templar as j}from"@qvvg/templar";export{templar as cadence,templar as cdc}from"@qvvg/templar";import{resolveCadence as A}from"@onflow/sdk-resolve-cadence";import{encodeTransactionPayload as N,encodeTransactionEnvelope as O}from"@onflow/encode";function x(n){return void 0===n&&(n=[]),r(e(),n)}var q=r;function z(){return(z=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}function B(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}function F(e){return void 0===e&&(e=[]),r(e.map(function(r){return n(z({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))}function T(r,e,n,t){return{addr:r,signingFunction:e,keyId:n,sequenceNum:t}}function E(e){return r([t,function(r){return r.accountAddr=e,o(r)}])}function L(e,n,t){return r([i,function(r){return r.events.eventType=e,o(r)},function(r){return r.events.start=n,o(r)},function(r){return r.events.end=t,o(r)}])}function R(e){return void 0===e&&(e=!1),r([u,function(r){return r.block.isSealed=e,o(r)}])}function C(e){return r([c,function(r){return r.block.id=e,o(r)}])}function D(e){return r([s,function(r){return r.block.height=e,o(r)}])}function K(e){return r([a,function(r){return r.transactionId=e,o(r)}])}function M(e){return r([function(r){return r.message.computeLimit=e,o(r)}])}function U(e){return void 0===e&&(e=[]),r(e.map(function(r){return f("function"==typeof r?{resolve:r}:r)}))}var V={asArgument:function(r){return r},asInjection:function(r){return r}};function Y(r,e,n){return void 0===e&&(e=V),void 0===n&&(n=null),{key:n,value:r,xform:e}}function $(e){return void 0===e&&(e=[]),r(e.map(function(r){return l("function"==typeof r?{resolve:r}:r)}))}var G={asArgument:function(r){return r},asInjection:function(r){return r}};function H(r,e){return void 0===e&&(e=G),{value:r,xform:e}}var J=function(r){try{return Q(r)?Promise.resolve(d({resolve:r,role:{proposer:!0}})):Promise.resolve(d(z({},r,{role:{proposer:!0}})))}catch(r){return Promise.reject(r)}},Q=function(r){return"function"==typeof r};function W(r){return m(z({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))}function X(){return r([p])}function Z(e){return r([function(r){return r.message.refBlock=e,o(r)}])}function _(){return r([v,y("ix.cadence",j.apply(void 0,arguments))])}var rr=[];function er(){return r([h,y("ix.cadence",j.apply(void 0,arguments)),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||rr,o(r)}])}function nr(r){return g("ix.validators",function(e){return Array.isArray(e)?e.push(r):[r]})}function tr(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];if(e.length>1){var t=e[0],i=e[1];return tr(function(r,e){var n=e.Bad;return t?(0,e.Ok)(r):n(r,i)})}var u=e[0];return function(r){return u(r,{Ok:o,Bad:b})}}const or=function(){function r(){}return r.prototype.then=function(e,n){const t=new r,o=this.s;if(o){const r=1&o?e:n;if(r){try{ir(t,1,r(this.v))}catch(r){ir(t,2,r)}return t}return this}return this.o=function(r){try{const o=r.v;1&r.s?ir(t,1,e?e(o):o):n?ir(t,1,n(o)):ir(t,2,o)}catch(r){ir(t,2,r)}},t},r}();function ir(r,e,n){if(!r.s){if(n instanceof or){if(!n.s)return void(n.o=ir.bind(null,r,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(ir.bind(null,r,e),ir.bind(null,r,2));r.s=e,r.v=n;const t=r.o;t&&t(r)}}function ur(r){return r instanceof or&&1&r.s}const cr="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var sr=function(r){return"function"==typeof r},ar=function(r){return"number"==typeof r},fr=function(r){return"string"==typeof r},lr=function(r,e){if(!r){var n,t=new Error("INVARIANT "+e);t.stack=t.stack.split("\n").filter(function(r){return!/at invariant/.test(r)}).join("\n");for(var o=arguments.length,i=new Array(o>2?o-2:0),u=2;u<o;u++)i[u-2]=arguments[u];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(i,["\n\n---\n\n"])),t}},dr=function(r){return!(r.role.proposer&&!(fr(r.addr)&&ar(r.keyId)&&ar(r.sequenceNum)&&sr(r.signingFunction))||r.role.payer&&!(fr(r.addr)&&ar(r.keyId)&&sr(r.signingFunction))||r.role.authorizer&&!(fr(r.addr)&&ar(r.keyId)&&sr(r.signingFunction)))},mr=function(r){return void 0===r&&(r=[]),r.filter(Boolean)[0]||null},pr=function(r){return void 0===r&&(r=[]),r.find(function(r){return r.role.proposer})||{}},vr=r([function(r){try{var e=function(){return o(r)};if(!k(r))return Promise.resolve(o(r));var n=function(r,e,n){if("function"==typeof r[cr]){var t,o,i,u=r[cr]();if(function r(n){try{for(;!(t=u.next()).done;)if((n=e(t.value))&&n.then){if(!ur(n))return void n.then(r,i||(i=ir.bind(null,o=new or,2)));n=n.v}o?ir(o,1,n):o=n}catch(r){ir(o||(o=new or),2,r)}}(),u.return){var c=function(r){try{t.done||u.return()}catch(r){}return r};if(o&&o.then)return o.then(c,function(r){throw c(r)});c()}return o}if(!("length"in r))throw new TypeError("Object is not iterable");for(var s=[],a=0;a<r.length;a++)s.push(r[a]);return function(r,e,n){var t,o,i=-1;return function n(u){try{for(;++i<r.length;)if((u=e(i))&&u.then){if(!ur(u))return void u.then(n,o||(o=ir.bind(null,t=new or,2)));u=u.v}t?ir(t,1,u):t=u}catch(r){ir(t||(t=new or),2,r)}}(),t}(s,function(r){return e(s[r])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){lr(dr(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var i=function(){if(sr(t.resolve))return Promise.resolve(t.resolve(t)).then(function(e){r.accounts[n]=e})}();return i&&i.then?i.then(o):o()});return Promise.resolve(n&&n.then?n.then(e):e())}catch(r){return Promise.reject(r)}},function(r){try{if(!k(r))return Promise.resolve(o(r));for(var e=function(){var e,o,i,u=t[n],c=u.addr+"|"+u.keyId;r.accounts[c]=null!=r.accounts[c]?(e=r.accounts[c],o=z({tempId:c},u),{kind:mr([e.kind,o.kind]),tempId:mr([e.tempId,o.tempId]),addr:mr([e.addr,o.addr]),keyId:(i=[e.keyId,o.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(ar)[0]?i.filter(ar)[0]:null),sequenceNum:"number"==typeof pr([e,o]).sequenceNum?pr([e,o]).sequenceNum:e.sequenceNum,signature:mr([e.signature,o.signature]),signingFunction:mr([e.signingFunction,o.signingFunction]),resolve:mr([e.resolve,o.resolve]),role:{proposer:e.role.proposer||o.role.proposer,authorizer:e.role.authorizer||o.role.authorizer,payer:e.role.payer||o.role.payer,param:e.role.param||o.role.param}}):z({tempId:c},u),r.proposer===u.tempId&&(r.proposer=c),r.payer===u.tempId&&(r.payer=c),r.authorizations=r.authorizations.map(function(r){return r===u.tempId?c:r}),delete r.accounts[u.tempId]},n=0,t=Object.values(r.accounts);n<t.length;n++)e();for(var i=0,u=Object.values(r.accounts);i<u.length;i++){var c=u[i];lr(dr(c),"Account unable to fulfill roles",c)}return Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}]),yr=function(r){try{if(!k(r)&&!I(r))return Promise.resolve(o(r));var e=Object.values(r.arguments);return Promise.resolve(Promise.all(e.map(function(r){try{var e=!1,n=function(){if("function"==typeof r.resolve)return e=!0,Promise.resolve(r.resolve()).then(function(e){return z({},e,{tempId:r.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return e?n:r}):e?n:r)}catch(r){return Promise.reject(r)}}))).then(function(e){return e.forEach(function(e){r.arguments[e.tempId]=z({},e,{asArgument:e.xform.asArgument(e.value)})}),o(r)})}catch(r){return Promise.reject(r)}};function hr(r){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),A(r)}function gr(r){return{script:r.message.cadence,refBlock:r.message.refBlock||null,gasLimit:r.message.computeLimit,arguments:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),proposalKey:{address:r.accounts[r.proposer].addr,keyId:r.accounts[r.proposer].keyId,sequenceNum:r.accounts[r.proposer].sequenceNum},payer:r.accounts[r.payer].addr,authorizers:r.authorizations.map(function(e){return r.accounts[e].addr})}}var br=function(r){try{if(!k(r))return Promise.resolve(r);var e=function(r){var e=new Set(r.authorizations);e.add(r.proposer),e.delete(r.payer),e=Array.from(e);var n=new Set([r.payer]);return{insideSigners:e,outsideSigners:n=Array.from(n)}}(r),n=e.outsideSigners;return Promise.resolve(kr(r,e.insideSigners,N(gr(r)))).then(function(e){var t=Ir(r,e);return Promise.resolve(kr(r,n,O(z({},gr(r),{payloadSigs:t})))).then(function(e){return Ir(r,e),r})})}catch(r){return Promise.reject(r)}},kr=function(r,e,n){void 0===e&&(e=[]);try{return Promise.all(e.map(function(e){try{return Promise.resolve(r.accounts[e].signingFunction({message:n,addr:r.accounts[e].addr,keyId:r.accounts[e].keyId,roles:r.accounts[e].role,interaction:r})).then(function(n){if(n.cid=e,r.accounts[e].addr!==n.addr)throw new Error(e+" — mismatching address in composite signature");if(r.accounts[e].keyId!==n.keyId)throw new Error(e+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(r){return Promise.reject(r)}}))}catch(r){return Promise.reject(r)}};function Ir(r,e){for(var n,t=function(r,e){var n;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(n=function(r,e){if(r){if("string"==typeof r)return B(r,void 0);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(r,void 0):void 0}}(r))){n&&(r=n);var t=0;return function(){return t>=r.length?{done:!0}:{done:!1,value:r[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=r[Symbol.iterator]()).next.bind(n)}(e);!(n=t()).done;){var o=n.value;r.accounts[o.cid].signature=o.signature}return e}var Pr=function(e){try{var n=P(e,"ix.validators",[]);return Promise.resolve(r(e,n.map(function(r){return function(e){return r(e,{Ok:o,Bad:b})}})))}catch(r){return Promise.reject(r)}},wr=function(r){var e=r.node;return function(r){try{return k(r)?r.accounts[r.proposer].sequenceNum?Promise.resolve(o(r)):Promise.resolve(x([E(r.accounts[r.proposer].addr)])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(S(e)).then(function(e){return r.accounts[r.proposer].sequenceNum=e.keys[r.accounts[r.proposer].keyId].sequenceNumber,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}},Sr=function(r){var e=r.node;return function(r){try{return k(r)?r.message.refBlock?Promise.resolve(o(r)):Promise.resolve(x([R()])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(S(e)).then(function(e){return r.message.refBlock=e.id,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}};export{H as arg,$ as args,T as authorization,F as authorizations,x as build,E as getAccount,D as getBlockByHeight,C as getBlockById,L as getEvents,R as getLatestBlock,K as getTransactionStatus,tr as invariant,M as limit,Y as param,U as params,W as payer,X as ping,J as proposer,Z as ref,q as resolve,vr as resolveAccounts,yr as resolveArguments,hr as resolveParams,wr as resolveProposerSequenceNumber,Sr as resolveRefBlockId,br as resolveSignatures,Pr as resolveValidators,_ as script,er as transaction,nr as validator}; | ||
//# sourceMappingURL=sdk.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import{pipe as r,interaction as e,makeAuthorizer as n,makeGetAccount as t,Ok as o,makeGetEvents as u,makeGetLatestBlock as i,makeGetBlockById as c,makeGetBlockByHeight as s,makeGetTransactionStatus as a,makeParam as f,makeArgument as l,makeProposer as m,makePayer as d,makePing as v,makeScript as p,put as y,makeTransaction as h,update as g,Bad as P,isTransaction as b,isScript as I,get as k}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{send as w}from"@onflow/send";export{send}from"@onflow/send";import{decodeResponse as j}from"@onflow/decode";export{decode,decodeResponse}from"@onflow/decode";import{templar as S}from"@qvvg/templar";export{templar as cadence,templar as cdc}from"@qvvg/templar";import{encodeTransactionPayload as A,encodeTransactionEnvelope as x}from"@onflow/encode";function O(n){return void 0===n&&(n=[]),r(e(),n)}var q=r;function N(){return(N=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}function z(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}function B(e){return void 0===e&&(e=[]),r(e.map(function(r){return n(N({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))}function E(r,e,n,t){return{addr:r,signingFunction:e,keyId:n,sequenceNum:t}}function F(e){return r([t,function(r){return r.accountAddr=e,o(r)}])}function L(e,n,t){return r([u,function(r){return r.events.eventType=e,o(r)},function(r){return r.events.start=n,o(r)},function(r){return r.events.end=t,o(r)}])}function T(e){return void 0===e&&(e=!1),r([i,function(r){return r.block.isSealed=e,o(r)}])}function C(e){return r([c,function(r){return r.block.id=e,o(r)}])}function R(e){return r([s,function(r){return r.block.height=e,o(r)}])}function V(e){return r([a,function(r){return r.transactionId=e,o(r)}])}function K(e){return r([function(r){return r.message.computeLimit=e,o(r)}])}function M(e){return void 0===e&&(e=[]),r(e.map(function(r){return f("function"==typeof r?{resolve:r}:r)}))}var U={asArgument:function(r){return r},asInjection:function(r){return r}};function $(r,e,n){return void 0===e&&(e=U),void 0===n&&(n=null),{key:n,value:r,xform:e}}function D(e){return void 0===e&&(e=[]),r(e.map(function(r){return l("function"==typeof r?{resolve:r}:r)}))}var G={asArgument:function(r){return r},asInjection:function(r){return r}};function H(r,e){return void 0===e&&(e=G),{value:r,xform:e}}var J=function(r){try{return Q(r)?Promise.resolve(m({resolve:r,role:{proposer:!0}})):Promise.resolve(m(N({},r,{role:{proposer:!0}})))}catch(r){return Promise.reject(r)}},Q=function(r){return"function"==typeof r};function W(r){return d(N({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))}function X(){return r([v])}function Y(e){return r([function(r){return r.message.refBlock=e,o(r)}])}function Z(){return r([p,y("ix.cadence",S.apply(void 0,arguments))])}var _=[];function rr(){return r([h,y("ix.cadence",S.apply(void 0,arguments)),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||_,o(r)}])}function er(r){return g("ix.validators",function(e){return Array.isArray(e)?e.push(r):[r]})}function nr(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];if(e.length>1){var t=e[0],u=e[1];return nr(function(r,e){var n=e.Bad;return t?(0,e.Ok)(r):n(r,u)})}var i=e[0];return function(r){return i(r,{Ok:o,Bad:P})}}const tr=function(){function r(){}return r.prototype.then=function(e,n){const t=new r,o=this.s;if(o){const r=1&o?e:n;if(r){try{or(t,1,r(this.v))}catch(r){or(t,2,r)}return t}return this}return this.o=function(r){try{const o=r.v;1&r.s?or(t,1,e?e(o):o):n?or(t,1,n(o)):or(t,2,o)}catch(r){or(t,2,r)}},t},r}();function or(r,e,n){if(!r.s){if(n instanceof tr){if(!n.s)return void(n.o=or.bind(null,r,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(or.bind(null,r,e),or.bind(null,r,2));r.s=e,r.v=n;const t=r.o;t&&t(r)}}function ur(r){return r instanceof tr&&1&r.s}const ir="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var cr=function(r){return"function"==typeof r},sr=function(r){return"number"==typeof r},ar=function(r){return"string"==typeof r},fr=function(r,e){if(!r){var n,t=new Error("INVARIANT "+e);t.stack=t.stack.split("\n").filter(function(r){return!/at invariant/.test(r)}).join("\n");for(var o=arguments.length,u=new Array(o>2?o-2:0),i=2;i<o;i++)u[i-2]=arguments[i];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(u,["\n\n---\n\n"])),t}},lr=function(r){return!(r.role.proposer&&!(ar(r.addr)&&sr(r.keyId)&&sr(r.sequenceNum)&&cr(r.signingFunction))||r.role.payer&&!(ar(r.addr)&&sr(r.keyId)&&cr(r.signingFunction))||r.role.authorizer&&!(ar(r.addr)&&sr(r.keyId)&&cr(r.signingFunction)))},mr=function(r){return void 0===r&&(r=[]),r.filter(Boolean)[0]||null},dr=function(r){return void 0===r&&(r=[]),r.find(function(r){return r.role.proposer})||{}},vr=r([function(r){try{var e=function(){return o(r)};if(!b(r))return Promise.resolve(o(r));var n=function(r,e,n){if("function"==typeof r[ir]){var t,o,u,i=r[ir]();if(function r(n){try{for(;!(t=i.next()).done;)if((n=e(t.value))&&n.then){if(!ur(n))return void n.then(r,u||(u=or.bind(null,o=new tr,2)));n=n.v}o?or(o,1,n):o=n}catch(r){or(o||(o=new tr),2,r)}}(),i.return){var c=function(r){try{t.done||i.return()}catch(r){}return r};if(o&&o.then)return o.then(c,function(r){throw c(r)});c()}return o}if(!("length"in r))throw new TypeError("Object is not iterable");for(var s=[],a=0;a<r.length;a++)s.push(r[a]);return function(r,e,n){var t,o,u=-1;return function n(i){try{for(;++u<r.length;)if((i=e(u))&&i.then){if(!ur(i))return void i.then(n,o||(o=or.bind(null,t=new tr,2)));i=i.v}t?or(t,1,i):t=i}catch(r){or(t||(t=new tr),2,r)}}(),t}(s,function(r){return e(s[r])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){fr(lr(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var u=function(){if(cr(t.resolve))return Promise.resolve(t.resolve(t)).then(function(e){r.accounts[n]=e})}();return u&&u.then?u.then(o):o()});return Promise.resolve(n&&n.then?n.then(e):e())}catch(r){return Promise.reject(r)}},function(r){try{if(!b(r))return Promise.resolve(o(r));for(var e=function(){var e,o,u,i=t[n],c=i.addr+"|"+i.keyId;r.accounts[c]=null!=r.accounts[c]?(e=r.accounts[c],o=N({tempId:c},i),{kind:mr([e.kind,o.kind]),tempId:mr([e.tempId,o.tempId]),addr:mr([e.addr,o.addr]),keyId:(u=[e.keyId,o.keyId],void 0===u&&(u=[]),"number"==typeof u.filter(sr)[0]?u.filter(sr)[0]:null),sequenceNum:"number"==typeof dr([e,o]).sequenceNum?dr([e,o]).sequenceNum:e.sequenceNum,signature:mr([e.signature,o.signature]),signingFunction:mr([e.signingFunction,o.signingFunction]),resolve:mr([e.resolve,o.resolve]),role:{proposer:e.role.proposer||o.role.proposer,authorizer:e.role.authorizer||o.role.authorizer,payer:e.role.payer||o.role.payer,param:e.role.param||o.role.param}}):N({tempId:c},i),r.proposer===i.tempId&&(r.proposer=c),r.payer===i.tempId&&(r.payer=c),r.authorizations=r.authorizations.map(function(r){return r===i.tempId?c:r}),delete r.accounts[i.tempId]},n=0,t=Object.values(r.accounts);n<t.length;n++)e();for(var u=0,i=Object.values(r.accounts);u<i.length;u++){var c=i[u];fr(lr(c),"Account unable to fulfill roles",c)}return Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}]),pr=function(r){try{if(!b(r)&&!I(r))return Promise.resolve(o(r));var e=Object.values(r.arguments);return Promise.resolve(Promise.all(e.map(function(r){try{var e=!1,n=function(){if("function"==typeof r.resolve)return e=!0,Promise.resolve(r.resolve()).then(function(e){return N({},e,{tempId:r.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return e?n:r}):e?n:r)}catch(r){return Promise.reject(r)}}))).then(function(e){return e.forEach(function(e){r.arguments[e.tempId]=N({},e,{asArgument:e.xform.asArgument(e.value)})}),o(r)})}catch(r){return Promise.reject(r)}},yr=function(r){try{var e=function(r){if(n)return r;throw new Error("Invalid Cadence Value")},n=!1;if(!b(r)&&!I(r))return Promise.resolve(o(r));var t=k(r,"ix.cadence");if("string"==typeof t)return r.message.cadence=t,Promise.resolve(o(r));var u=function(){if("function"==typeof t){var e=Object.values(r.params);return Promise.resolve(Promise.all(e.map(function(r){try{var e=!1,n=function(){if("function"==typeof r.resolve)return e=!0,Promise.resolve(r.resolve()).then(function(e){return N({},e,{tempId:r.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return e?n:r}):e?n:r)}catch(r){return Promise.reject(r)}}))).then(function(e){return e.forEach(function(e){r.params[e.tempId]=e}),e=Object.fromEntries(e.filter(function(r){return null!=r.key}).map(function(r){return[r.key,r.xform.asInjection(r.value)]})),r.message.cadence=t(e),n=!0,o(r)})}}();return Promise.resolve(u&&u.then?u.then(e):e(u))}catch(r){return Promise.reject(r)}};function hr(r){return{script:r.message.cadence,refBlock:r.message.refBlock||null,gasLimit:r.message.computeLimit,arguments:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),proposalKey:{address:r.accounts[r.proposer].addr,keyId:r.accounts[r.proposer].keyId,sequenceNum:r.accounts[r.proposer].sequenceNum},payer:r.accounts[r.payer].addr,authorizers:r.authorizations.map(function(e){return r.accounts[e].addr})}}var gr=function(r){try{if(!b(r))return Promise.resolve(r);var e=function(r){var e=new Set(r.authorizations);e.add(r.proposer),e.delete(r.payer),e=Array.from(e);var n=new Set([r.payer]);return{insideSigners:e,outsideSigners:n=Array.from(n)}}(r),n=e.outsideSigners;return Promise.resolve(Pr(r,e.insideSigners,A(hr(r)))).then(function(e){var t=br(r,e);return Promise.resolve(Pr(r,n,x(N({},hr(r),{payloadSigs:t})))).then(function(e){return br(r,e),r})})}catch(r){return Promise.reject(r)}},Pr=function(r,e,n){void 0===e&&(e=[]);try{return Promise.all(e.map(function(e){try{return Promise.resolve(r.accounts[e].signingFunction({message:n,addr:r.accounts[e].addr,keyId:r.accounts[e].keyId,roles:r.accounts[e].role,interaction:r})).then(function(n){if(n.cid=e,r.accounts[e].addr!==n.addr)throw new Error(e+" — mismatching address in composite signature");if(r.accounts[e].keyId!==n.keyId)throw new Error(e+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(r){return Promise.reject(r)}}))}catch(r){return Promise.reject(r)}};function br(r,e){for(var n,t=function(r,e){var n;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(n=function(r,e){if(r){if("string"==typeof r)return z(r,void 0);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(r,void 0):void 0}}(r))){n&&(r=n);var t=0;return function(){return t>=r.length?{done:!0}:{done:!1,value:r[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=r[Symbol.iterator]()).next.bind(n)}(e);!(n=t()).done;){var o=n.value;r.accounts[o.cid].signature=o.signature}return e}var Ir=function(e){try{var n=k(e,"ix.validators",[]);return Promise.resolve(r(e,n.map(function(r){return function(e){return r(e,{Ok:o,Bad:P})}})))}catch(r){return Promise.reject(r)}},kr=function(r){var e=r.node;return function(r){try{return b(r)?r.accounts[r.proposer].sequenceNum?Promise.resolve(o(r)):Promise.resolve(O([F(r.accounts[r.proposer].addr)])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(j(e)).then(function(e){return r.accounts[r.proposer].sequenceNum=e.keys[r.accounts[r.proposer].keyId].sequenceNumber,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}},wr=function(r){var e=r.node;return function(r){try{return b(r)?r.message.refBlock?Promise.resolve(o(r)):Promise.resolve(O([T()])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(j(e)).then(function(e){return r.message.refBlock=e.id,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}};export{H as arg,D as args,E as authorization,B as authorizations,O as build,F as getAccount,R as getBlockByHeight,C as getBlockById,L as getEvents,T as getLatestBlock,V as getTransactionStatus,nr as invariant,K as limit,$ as param,M as params,W as payer,X as ping,J as proposer,Y as ref,q as resolve,vr as resolveAccounts,pr as resolveArguments,yr as resolveParams,kr as resolveProposerSequenceNumber,wr as resolveRefBlockId,gr as resolveSignatures,Ir as resolveValidators,Z as script,rr as transaction,er as validator}; | ||
import{pipe as r,interaction as e,makeAuthorizer as n,makeGetAccount as t,Ok as o,makeGetEvents as i,makeGetLatestBlock as u,makeGetBlockById as c,makeGetBlockByHeight as s,makeGetTransactionStatus as a,makeParam as f,makeArgument as l,makeProposer as d,makePayer as m,makePing as p,makeScript as v,put as y,makeTransaction as h,update as g,Bad as b,isTransaction as k,isScript as I,get as P}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{send as w}from"@onflow/send";export{send}from"@onflow/send";import{decodeResponse as S}from"@onflow/decode";export{decode,decodeResponse}from"@onflow/decode";import{templar as j}from"@qvvg/templar";export{templar as cadence,templar as cdc}from"@qvvg/templar";import{resolveCadence as A}from"@onflow/sdk-resolve-cadence";import{encodeTransactionPayload as N,encodeTransactionEnvelope as O}from"@onflow/encode";function x(n){return void 0===n&&(n=[]),r(e(),n)}var q=r;function z(){return(z=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r}).apply(this,arguments)}function B(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}function F(e){return void 0===e&&(e=[]),r(e.map(function(r){return n(z({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))}function T(r,e,n,t){return{addr:r,signingFunction:e,keyId:n,sequenceNum:t}}function E(e){return r([t,function(r){return r.accountAddr=e,o(r)}])}function L(e,n,t){return r([i,function(r){return r.events.eventType=e,o(r)},function(r){return r.events.start=n,o(r)},function(r){return r.events.end=t,o(r)}])}function R(e){return void 0===e&&(e=!1),r([u,function(r){return r.block.isSealed=e,o(r)}])}function C(e){return r([c,function(r){return r.block.id=e,o(r)}])}function D(e){return r([s,function(r){return r.block.height=e,o(r)}])}function K(e){return r([a,function(r){return r.transactionId=e,o(r)}])}function M(e){return r([function(r){return r.message.computeLimit=e,o(r)}])}function U(e){return void 0===e&&(e=[]),r(e.map(function(r){return f("function"==typeof r?{resolve:r}:r)}))}var V={asArgument:function(r){return r},asInjection:function(r){return r}};function Y(r,e,n){return void 0===e&&(e=V),void 0===n&&(n=null),{key:n,value:r,xform:e}}function $(e){return void 0===e&&(e=[]),r(e.map(function(r){return l("function"==typeof r?{resolve:r}:r)}))}var G={asArgument:function(r){return r},asInjection:function(r){return r}};function H(r,e){return void 0===e&&(e=G),{value:r,xform:e}}var J=function(r){try{return Q(r)?Promise.resolve(d({resolve:r,role:{proposer:!0}})):Promise.resolve(d(z({},r,{role:{proposer:!0}})))}catch(r){return Promise.reject(r)}},Q=function(r){return"function"==typeof r};function W(r){return m(z({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))}function X(){return r([p])}function Z(e){return r([function(r){return r.message.refBlock=e,o(r)}])}function _(){return r([v,y("ix.cadence",j.apply(void 0,arguments))])}var rr=[];function er(){return r([h,y("ix.cadence",j.apply(void 0,arguments)),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||rr,o(r)}])}function nr(r){return g("ix.validators",function(e){return Array.isArray(e)?e.push(r):[r]})}function tr(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];if(e.length>1){var t=e[0],i=e[1];return tr(function(r,e){var n=e.Bad;return t?(0,e.Ok)(r):n(r,i)})}var u=e[0];return function(r){return u(r,{Ok:o,Bad:b})}}const or=function(){function r(){}return r.prototype.then=function(e,n){const t=new r,o=this.s;if(o){const r=1&o?e:n;if(r){try{ir(t,1,r(this.v))}catch(r){ir(t,2,r)}return t}return this}return this.o=function(r){try{const o=r.v;1&r.s?ir(t,1,e?e(o):o):n?ir(t,1,n(o)):ir(t,2,o)}catch(r){ir(t,2,r)}},t},r}();function ir(r,e,n){if(!r.s){if(n instanceof or){if(!n.s)return void(n.o=ir.bind(null,r,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(ir.bind(null,r,e),ir.bind(null,r,2));r.s=e,r.v=n;const t=r.o;t&&t(r)}}function ur(r){return r instanceof or&&1&r.s}const cr="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var sr=function(r){return"function"==typeof r},ar=function(r){return"number"==typeof r},fr=function(r){return"string"==typeof r},lr=function(r,e){if(!r){var n,t=new Error("INVARIANT "+e);t.stack=t.stack.split("\n").filter(function(r){return!/at invariant/.test(r)}).join("\n");for(var o=arguments.length,i=new Array(o>2?o-2:0),u=2;u<o;u++)i[u-2]=arguments[u];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(i,["\n\n---\n\n"])),t}},dr=function(r){return!(r.role.proposer&&!(fr(r.addr)&&ar(r.keyId)&&ar(r.sequenceNum)&&sr(r.signingFunction))||r.role.payer&&!(fr(r.addr)&&ar(r.keyId)&&sr(r.signingFunction))||r.role.authorizer&&!(fr(r.addr)&&ar(r.keyId)&&sr(r.signingFunction)))},mr=function(r){return void 0===r&&(r=[]),r.filter(Boolean)[0]||null},pr=function(r){return void 0===r&&(r=[]),r.find(function(r){return r.role.proposer})||{}},vr=r([function(r){try{var e=function(){return o(r)};if(!k(r))return Promise.resolve(o(r));var n=function(r,e,n){if("function"==typeof r[cr]){var t,o,i,u=r[cr]();if(function r(n){try{for(;!(t=u.next()).done;)if((n=e(t.value))&&n.then){if(!ur(n))return void n.then(r,i||(i=ir.bind(null,o=new or,2)));n=n.v}o?ir(o,1,n):o=n}catch(r){ir(o||(o=new or),2,r)}}(),u.return){var c=function(r){try{t.done||u.return()}catch(r){}return r};if(o&&o.then)return o.then(c,function(r){throw c(r)});c()}return o}if(!("length"in r))throw new TypeError("Object is not iterable");for(var s=[],a=0;a<r.length;a++)s.push(r[a]);return function(r,e,n){var t,o,i=-1;return function n(u){try{for(;++i<r.length;)if((u=e(i))&&u.then){if(!ur(u))return void u.then(n,o||(o=ir.bind(null,t=new or,2)));u=u.v}t?ir(t,1,u):t=u}catch(r){ir(t||(t=new or),2,r)}}(),t}(s,function(r){return e(s[r])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){lr(dr(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var i=function(){if(sr(t.resolve))return Promise.resolve(t.resolve(t)).then(function(e){r.accounts[n]=e})}();return i&&i.then?i.then(o):o()});return Promise.resolve(n&&n.then?n.then(e):e())}catch(r){return Promise.reject(r)}},function(r){try{if(!k(r))return Promise.resolve(o(r));for(var e=function(){var e,o,i,u=t[n],c=u.addr+"|"+u.keyId;r.accounts[c]=null!=r.accounts[c]?(e=r.accounts[c],o=z({tempId:c},u),{kind:mr([e.kind,o.kind]),tempId:mr([e.tempId,o.tempId]),addr:mr([e.addr,o.addr]),keyId:(i=[e.keyId,o.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(ar)[0]?i.filter(ar)[0]:null),sequenceNum:"number"==typeof pr([e,o]).sequenceNum?pr([e,o]).sequenceNum:e.sequenceNum,signature:mr([e.signature,o.signature]),signingFunction:mr([e.signingFunction,o.signingFunction]),resolve:mr([e.resolve,o.resolve]),role:{proposer:e.role.proposer||o.role.proposer,authorizer:e.role.authorizer||o.role.authorizer,payer:e.role.payer||o.role.payer,param:e.role.param||o.role.param}}):z({tempId:c},u),r.proposer===u.tempId&&(r.proposer=c),r.payer===u.tempId&&(r.payer=c),r.authorizations=r.authorizations.map(function(r){return r===u.tempId?c:r}),delete r.accounts[u.tempId]},n=0,t=Object.values(r.accounts);n<t.length;n++)e();for(var i=0,u=Object.values(r.accounts);i<u.length;i++){var c=u[i];lr(dr(c),"Account unable to fulfill roles",c)}return Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}]),yr=function(r){try{if(!k(r)&&!I(r))return Promise.resolve(o(r));var e=Object.values(r.arguments);return Promise.resolve(Promise.all(e.map(function(r){try{var e=!1,n=function(){if("function"==typeof r.resolve)return e=!0,Promise.resolve(r.resolve()).then(function(e){return z({},e,{tempId:r.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return e?n:r}):e?n:r)}catch(r){return Promise.reject(r)}}))).then(function(e){return e.forEach(function(e){r.arguments[e.tempId]=z({},e,{asArgument:e.xform.asArgument(e.value)})}),o(r)})}catch(r){return Promise.reject(r)}};function hr(r){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),A(r)}function gr(r){return{script:r.message.cadence,refBlock:r.message.refBlock||null,gasLimit:r.message.computeLimit,arguments:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),proposalKey:{address:r.accounts[r.proposer].addr,keyId:r.accounts[r.proposer].keyId,sequenceNum:r.accounts[r.proposer].sequenceNum},payer:r.accounts[r.payer].addr,authorizers:r.authorizations.map(function(e){return r.accounts[e].addr})}}var br=function(r){try{if(!k(r))return Promise.resolve(r);var e=function(r){var e=new Set(r.authorizations);e.add(r.proposer),e.delete(r.payer),e=Array.from(e);var n=new Set([r.payer]);return{insideSigners:e,outsideSigners:n=Array.from(n)}}(r),n=e.outsideSigners;return Promise.resolve(kr(r,e.insideSigners,N(gr(r)))).then(function(e){var t=Ir(r,e);return Promise.resolve(kr(r,n,O(z({},gr(r),{payloadSigs:t})))).then(function(e){return Ir(r,e),r})})}catch(r){return Promise.reject(r)}},kr=function(r,e,n){void 0===e&&(e=[]);try{return Promise.all(e.map(function(e){try{return Promise.resolve(r.accounts[e].signingFunction({message:n,addr:r.accounts[e].addr,keyId:r.accounts[e].keyId,roles:r.accounts[e].role,interaction:r})).then(function(n){if(n.cid=e,r.accounts[e].addr!==n.addr)throw new Error(e+" — mismatching address in composite signature");if(r.accounts[e].keyId!==n.keyId)throw new Error(e+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(r){return Promise.reject(r)}}))}catch(r){return Promise.reject(r)}};function Ir(r,e){for(var n,t=function(r,e){var n;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(n=function(r,e){if(r){if("string"==typeof r)return B(r,void 0);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(r,void 0):void 0}}(r))){n&&(r=n);var t=0;return function(){return t>=r.length?{done:!0}:{done:!1,value:r[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=r[Symbol.iterator]()).next.bind(n)}(e);!(n=t()).done;){var o=n.value;r.accounts[o.cid].signature=o.signature}return e}var Pr=function(e){try{var n=P(e,"ix.validators",[]);return Promise.resolve(r(e,n.map(function(r){return function(e){return r(e,{Ok:o,Bad:b})}})))}catch(r){return Promise.reject(r)}},wr=function(r){var e=r.node;return function(r){try{return k(r)?r.accounts[r.proposer].sequenceNum?Promise.resolve(o(r)):Promise.resolve(x([E(r.accounts[r.proposer].addr)])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(S(e)).then(function(e){return r.accounts[r.proposer].sequenceNum=e.keys[r.accounts[r.proposer].keyId].sequenceNumber,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}},Sr=function(r){var e=r.node;return function(r){try{return k(r)?r.message.refBlock?Promise.resolve(o(r)):Promise.resolve(x([R()])).then(function(n){return Promise.resolve(w(n,{node:e})).then(function(e){return Promise.resolve(S(e)).then(function(e){return r.message.refBlock=e.id,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}};export{H as arg,$ as args,T as authorization,F as authorizations,x as build,E as getAccount,D as getBlockByHeight,C as getBlockById,L as getEvents,R as getLatestBlock,K as getTransactionStatus,tr as invariant,M as limit,Y as param,U as params,W as payer,X as ping,J as proposer,Z as ref,q as resolve,vr as resolveAccounts,yr as resolveArguments,hr as resolveParams,wr as resolveProposerSequenceNumber,Sr as resolveRefBlockId,br as resolveSignatures,Pr as resolveValidators,_ as script,er as transaction,nr as validator}; | ||
//# sourceMappingURL=sdk.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@onflow/interaction"),require("@onflow/send"),require("@onflow/decode"),require("@qvvg/templar"),require("@onflow/encode")):"function"==typeof define&&define.amd?define(["exports","@onflow/interaction","@onflow/send","@onflow/decode","@qvvg/templar","@onflow/encode"],r):r((e=e||self).sdk={},e.interaction,e.send,e.decode,e.templar,e.encode)}(this,function(e,r,n,t,o,i){function u(e){return void 0===e&&(e=[]),r.pipe(r.interaction(),e)}var c=r.pipe;function a(){return(a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}function s(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function f(e){return r.pipe([r.makeGetAccount,function(n){return n.accountAddr=e,r.Ok(n)}])}function l(e){return void 0===e&&(e=!1),r.pipe([r.makeGetLatestBlock,function(n){return n.block.isSealed=e,r.Ok(n)}])}var d={asArgument:function(e){return e},asInjection:function(e){return e}},p={asArgument:function(e){return e},asInjection:function(e){return e}},m=[];const v=function(){function e(){}return e.prototype.then=function(r,n){const t=new e,o=this.s;if(o){const e=1&o?r:n;if(e){try{y(t,1,e(this.v))}catch(e){y(t,2,e)}return t}return this}return this.o=function(e){try{const o=e.v;1&e.s?y(t,1,r?r(o):o):n?y(t,1,n(o)):y(t,2,o)}catch(e){y(t,2,e)}},t},e}();function y(e,r,n){if(!e.s){if(n instanceof v){if(!n.s)return void(n.o=y.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(y.bind(null,e,r),y.bind(null,e,2));e.s=r,e.v=n;const t=e.o;t&&t(e)}}function h(e){return e instanceof v&&1&e.s}const g="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var k=function(e){return"function"==typeof e},b=function(e){return"number"==typeof e},P=function(e){return"string"==typeof e},O=function(e,r){if(!e){var n,t=new Error("INVARIANT "+r);t.stack=t.stack.split("\n").filter(function(e){return!/at invariant/.test(e)}).join("\n");for(var o=arguments.length,i=new Array(o>2?o-2:0),u=2;u<o;u++)i[u-2]=arguments[u];throw(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat(i,["\n\n---\n\n"])),t}},I=function(e){return!(e.role.proposer&&!(P(e.addr)&&b(e.keyId)&&b(e.sequenceNum)&&k(e.signingFunction))||e.role.payer&&!(P(e.addr)&&b(e.keyId)&&k(e.signingFunction))||e.role.authorizer&&!(P(e.addr)&&b(e.keyId)&&k(e.signingFunction)))},j=function(e){return void 0===e&&(e=[]),e.filter(Boolean)[0]||null},w=function(e){return void 0===e&&(e=[]),e.find(function(e){return e.role.proposer})||{}},S=r.pipe([function(e){try{var n=function(){return r.Ok(e)};if(!r.isTransaction(e))return Promise.resolve(r.Ok(e));var t=function(e,r,n){if("function"==typeof e[g]){var t,o,i,u=e[g]();if(function e(n){try{for(;!(t=u.next()).done;)if((n=r(t.value))&&n.then){if(!h(n))return void n.then(e,i||(i=y.bind(null,o=new v,2)));n=n.v}o?y(o,1,n):o=n}catch(e){y(o||(o=new v),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,r,n){var t,o,i=-1;return function n(u){try{for(;++i<e.length;)if((u=r(i))&&u.then){if(!h(u))return void u.then(n,o||(o=y.bind(null,t=new v,2)));u=u.v}t?y(t,1,u):t=u}catch(e){y(t||(t=new v),2,e)}}(),t}(a,function(e){return r(a[e])})}(Object.entries(e.accounts),function(r){var n=r[0],t=r[1];function o(){O(I(e.accounts[n]),"Account unable to fulfill role",e.accounts[n])}var i=function(){if(k(t.resolve))return Promise.resolve(t.resolve(t)).then(function(r){e.accounts[n]=r})}();return i&&i.then?i.then(o):o()});return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},function(e){try{if(!r.isTransaction(e))return Promise.resolve(r.Ok(e));for(var n=function(){var r,n,i,u=o[t],c=u.addr+"|"+u.keyId;e.accounts[c]=null!=e.accounts[c]?(r=e.accounts[c],n=a({tempId:c},u),{kind:j([r.kind,n.kind]),tempId:j([r.tempId,n.tempId]),addr:j([r.addr,n.addr]),keyId:(i=[r.keyId,n.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(b)[0]?i.filter(b)[0]:null),sequenceNum:"number"==typeof w([r,n]).sequenceNum?w([r,n]).sequenceNum:r.sequenceNum,signature:j([r.signature,n.signature]),signingFunction:j([r.signingFunction,n.signingFunction]),resolve:j([r.resolve,n.resolve]),role:{proposer:r.role.proposer||n.role.proposer,authorizer:r.role.authorizer||n.role.authorizer,payer:r.role.payer||n.role.payer,param:r.role.param||n.role.param}}):a({tempId:c},u),e.proposer===u.tempId&&(e.proposer=c),e.payer===u.tempId&&(e.payer=c),e.authorizations=e.authorizations.map(function(e){return e===u.tempId?c:e}),delete e.accounts[u.tempId]},t=0,o=Object.values(e.accounts);t<o.length;t++)n();for(var i=0,u=Object.values(e.accounts);i<u.length;i++){var c=u[i];O(I(c),"Account unable to fulfill roles",c)}return Promise.resolve(r.Ok(e))}catch(e){return Promise.reject(e)}}]);function A(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(r){return e.arguments[r].asArgument}),proposalKey:{address:e.accounts[e.proposer].addr,keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:e.accounts[e.payer].addr,authorizers:e.authorizations.map(function(r){return e.accounts[r].addr})}}var B=function(e,r,n){void 0===r&&(r=[]);try{return Promise.all(r.map(function(r){try{return Promise.resolve(e.accounts[r].signingFunction({message:n,addr:e.accounts[r].addr,keyId:e.accounts[r].keyId,roles:e.accounts[r].role,interaction:e})).then(function(n){if(n.cid=r,e.accounts[r].addr!==n.addr)throw new Error(r+" — mismatching address in composite signature");if(e.accounts[r].keyId!==n.keyId)throw new Error(r+" — mismatching keyId in composite signature");return n.sig=n.signature,n.address=n.addr,n})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function q(e,r){for(var n,t=function(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(r);!(n=t()).done;){var o=n.value;e.accounts[o.cid].signature=o.signature}return r}Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return r.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return r.isOk}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return r.pipe}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return r.why}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return t.decode}}),Object.defineProperty(e,"decodeResponse",{enumerable:!0,get:function(){return t.decodeResponse}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return o.templar}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return o.templar}}),e.arg=function(e,r){return void 0===r&&(r=p),{value:e,xform:r}},e.args=function(e){return void 0===e&&(e=[]),r.pipe(e.map(function(e){return r.makeArgument("function"==typeof e?{resolve:e}:e)}))},e.authorization=function(e,r,n,t){return{addr:e,signingFunction:r,keyId:n,sequenceNum:t}},e.authorizations=function(e){return void 0===e&&(e=[]),r.pipe(e.map(function(e){return r.makeAuthorizer(a({},"function"==typeof e?{resolve:e}:e,{role:{authorizer:!0}}))}))},e.build=u,e.getAccount=f,e.getBlockByHeight=function(e){return r.pipe([r.makeGetBlockByHeight,function(n){return n.block.height=e,r.Ok(n)}])},e.getBlockById=function(e){return r.pipe([r.makeGetBlockById,function(n){return n.block.id=e,r.Ok(n)}])},e.getEvents=function(e,n,t){return r.pipe([r.makeGetEvents,function(n){return n.events.eventType=e,r.Ok(n)},function(e){return e.events.start=n,r.Ok(e)},function(e){return e.events.end=t,r.Ok(e)}])},e.getLatestBlock=l,e.getTransactionStatus=function(e){return r.pipe([r.makeGetTransactionStatus,function(n){return n.transactionId=e,r.Ok(n)}])},e.invariant=function e(){for(var n=arguments.length,t=new Array(n),o=0;o<n;o++)t[o]=arguments[o];if(t.length>1){var i=t[0],u=t[1];return e(function(e,r){var n=r.Bad;return i?(0,r.Ok)(e):n(e,u)})}var c=t[0];return function(e){return c(e,{Ok:r.Ok,Bad:r.Bad})}},e.limit=function(e){return r.pipe([function(n){return n.message.computeLimit=e,r.Ok(n)}])},e.param=function(e,r,n){return void 0===r&&(r=d),void 0===n&&(n=null),{key:n,value:e,xform:r}},e.params=function(e){return void 0===e&&(e=[]),r.pipe(e.map(function(e){return r.makeParam("function"==typeof e?{resolve:e}:e)}))},e.payer=function(e){return r.makePayer(a({},"function"==typeof e?{resolve:e}:e,{role:{payer:!0}}))},e.ping=function(){return r.pipe([r.makePing])},e.proposer=function(e){try{return Promise.resolve(r.makeProposer("function"==typeof e?{resolve:e,role:{proposer:!0}}:a({},e,{role:{proposer:!0}})))}catch(e){return Promise.reject(e)}},e.ref=function(e){return r.pipe([function(n){return n.message.refBlock=e,r.Ok(n)}])},e.resolve=c,e.resolveAccounts=S,e.resolveArguments=function(e){try{if(!r.isTransaction(e)&&!r.isScript(e))return Promise.resolve(r.Ok(e));var n=Object.values(e.arguments);return Promise.resolve(Promise.all(n.map(function(e){try{var r=!1,n=function(){if("function"==typeof e.resolve)return r=!0,Promise.resolve(e.resolve()).then(function(r){return a({},r,{tempId:e.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return r?n:e}):r?n:e)}catch(e){return Promise.reject(e)}}))).then(function(n){return n.forEach(function(r){e.arguments[r.tempId]=a({},r,{asArgument:r.xform.asArgument(r.value)})}),r.Ok(e)})}catch(e){return Promise.reject(e)}},e.resolveParams=function(e){try{var n=function(e){if(t)return e;throw new Error("Invalid Cadence Value")},t=!1;if(!r.isTransaction(e)&&!r.isScript(e))return Promise.resolve(r.Ok(e));var o=r.get(e,"ix.cadence");if("string"==typeof o)return e.message.cadence=o,Promise.resolve(r.Ok(e));var i=function(){if("function"==typeof o){var n=Object.values(e.params);return Promise.resolve(Promise.all(n.map(function(e){try{var r=!1,n=function(){if("function"==typeof e.resolve)return r=!0,Promise.resolve(e.resolve()).then(function(r){return a({},r,{tempId:e.tempId})})}();return Promise.resolve(n&&n.then?n.then(function(n){return r?n:e}):r?n:e)}catch(e){return Promise.reject(e)}}))).then(function(n){return n.forEach(function(r){e.params[r.tempId]=r}),n=Object.fromEntries(n.filter(function(e){return null!=e.key}).map(function(e){return[e.key,e.xform.asInjection(e.value)]})),e.message.cadence=o(n),t=!0,r.Ok(e)})}}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(e){return Promise.reject(e)}},e.resolveProposerSequenceNumber=function(e){var o=e.node;return function(e){try{return r.isTransaction(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(r.Ok(e)):Promise.resolve(u([f(e.accounts[e.proposer].addr)])).then(function(i){return Promise.resolve(n.send(i,{node:o})).then(function(n){return Promise.resolve(t.decodeResponse(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,r.Ok(e)})})}):Promise.resolve(r.Ok(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){var o=e.node;return function(e){try{return r.isTransaction(e)?e.message.refBlock?Promise.resolve(r.Ok(e)):Promise.resolve(u([l()])).then(function(i){return Promise.resolve(n.send(i,{node:o})).then(function(n){return Promise.resolve(t.decodeResponse(n)).then(function(n){return e.message.refBlock=n.id,r.Ok(e)})})}):Promise.resolve(r.Ok(e))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=function(e){try{if(!r.isTransaction(e))return Promise.resolve(e);var n=function(e){var r=new Set(e.authorizations);r.add(e.proposer),r.delete(e.payer),r=Array.from(r);var n=new Set([e.payer]);return{insideSigners:r,outsideSigners:n=Array.from(n)}}(e),t=n.outsideSigners;return Promise.resolve(B(e,n.insideSigners,i.encodeTransactionPayload(A(e)))).then(function(r){var n=q(e,r);return Promise.resolve(B(e,t,i.encodeTransactionEnvelope(a({},A(e),{payloadSigs:n})))).then(function(r){return q(e,r),e})})}catch(e){return Promise.reject(e)}},e.resolveValidators=function(e){try{var n=r.get(e,"ix.validators",[]);return Promise.resolve(r.pipe(e,n.map(function(e){return function(n){return e(n,{Ok:r.Ok,Bad:r.Bad})}})))}catch(e){return Promise.reject(e)}},e.script=function(){return r.pipe([r.makeScript,r.put("ix.cadence",o.templar.apply(void 0,arguments))])},e.transaction=function(){return r.pipe([r.makeTransaction,r.put("ix.cadence",o.templar.apply(void 0,arguments)),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||m,r.Ok(e)}])},e.validator=function(e){return r.update("ix.validators",function(r){return Array.isArray(r)?r.push(e):[e]})}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/interaction"),require("@onflow/send"),require("@onflow/decode"),require("@qvvg/templar"),require("@onflow/sdk-resolve-cadence"),require("@onflow/encode")):"function"==typeof define&&define.amd?define(["exports","@onflow/interaction","@onflow/send","@onflow/decode","@qvvg/templar","@onflow/sdk-resolve-cadence","@onflow/encode"],n):n((e=e||self).sdk={},e.interaction,e.send,e.decode,e.templar,e.sdkResolveCadence,e.encode)}(this,function(e,n,r,t,o,i,u){function c(e){return void 0===e&&(e=[]),n.pipe(n.interaction(),e)}var a=n.pipe;function s(){return(s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function l(e){return n.pipe([n.makeGetAccount,function(r){return r.accountAddr=e,n.Ok(r)}])}function d(e){return void 0===e&&(e=!1),n.pipe([n.makeGetLatestBlock,function(r){return r.block.isSealed=e,n.Ok(r)}])}var p={asArgument:function(e){return e},asInjection:function(e){return e}},m={asArgument:function(e){return e},asInjection:function(e){return e}},v=[];const y=function(){function e(){}return e.prototype.then=function(n,r){const t=new e,o=this.s;if(o){const e=1&o?n:r;if(e){try{g(t,1,e(this.v))}catch(e){g(t,2,e)}return t}return this}return this.o=function(e){try{const o=e.v;1&e.s?g(t,1,n?n(o):o):r?g(t,1,r(o)):g(t,2,o)}catch(e){g(t,2,e)}},t},e}();function g(e,n,r){if(!e.s){if(r instanceof y){if(!r.s)return void(r.o=g.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(g.bind(null,e,n),g.bind(null,e,2));e.s=n,e.v=r;const t=e.o;t&&t(e)}}function h(e){return e instanceof y&&1&e.s}const k="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var b=function(e){return"function"==typeof e},P=function(e){return"number"==typeof e},O=function(e){return"string"==typeof e},I=function(e,n){if(!e){var r,t=new Error("INVARIANT "+n);t.stack=t.stack.split("\n").filter(function(e){return!/at invariant/.test(e)}).join("\n");for(var o=arguments.length,i=new Array(o>2?o-2:0),u=2;u<o;u++)i[u-2]=arguments[u];throw(r=console).error.apply(r,["\n\n---\n\n",t,"\n\n"].concat(i,["\n\n---\n\n"])),t}},w=function(e){return!(e.role.proposer&&!(O(e.addr)&&P(e.keyId)&&P(e.sequenceNum)&&b(e.signingFunction))||e.role.payer&&!(O(e.addr)&&P(e.keyId)&&b(e.signingFunction))||e.role.authorizer&&!(O(e.addr)&&P(e.keyId)&&b(e.signingFunction)))},j=function(e){return void 0===e&&(e=[]),e.filter(Boolean)[0]||null},S=function(e){return void 0===e&&(e=[]),e.find(function(e){return e.role.proposer})||{}},A=n.pipe([function(e){try{var r=function(){return n.Ok(e)};if(!n.isTransaction(e))return Promise.resolve(n.Ok(e));var t=function(e,n,r){if("function"==typeof e[k]){var t,o,i,u=e[k]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!h(r))return void r.then(e,i||(i=g.bind(null,o=new y,2)));r=r.v}o?g(o,1,r):o=r}catch(e){g(o||(o=new y),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!h(u))return void u.then(r,o||(o=g.bind(null,t=new y,2)));u=u.v}t?g(t,1,u):t=u}catch(e){g(t||(t=new y),2,e)}}(),t}(a,function(e){return n(a[e])})}(Object.entries(e.accounts),function(n){var r=n[0],t=n[1];function o(){I(w(e.accounts[r]),"Account unable to fulfill role",e.accounts[r])}var i=function(){if(b(t.resolve))return Promise.resolve(t.resolve(t)).then(function(n){e.accounts[r]=n})}();return i&&i.then?i.then(o):o()});return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},function(e){try{if(!n.isTransaction(e))return Promise.resolve(n.Ok(e));for(var r=function(){var n,r,i,u=o[t],c=u.addr+"|"+u.keyId;e.accounts[c]=null!=e.accounts[c]?(n=e.accounts[c],r=s({tempId:c},u),{kind:j([n.kind,r.kind]),tempId:j([n.tempId,r.tempId]),addr:j([n.addr,r.addr]),keyId:(i=[n.keyId,r.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(P)[0]?i.filter(P)[0]:null),sequenceNum:"number"==typeof S([n,r]).sequenceNum?S([n,r]).sequenceNum:n.sequenceNum,signature:j([n.signature,r.signature]),signingFunction:j([n.signingFunction,r.signingFunction]),resolve:j([n.resolve,r.resolve]),role:{proposer:n.role.proposer||r.role.proposer,authorizer:n.role.authorizer||r.role.authorizer,payer:n.role.payer||r.role.payer,param:n.role.param||r.role.param}}):s({tempId:c},u),e.proposer===u.tempId&&(e.proposer=c),e.payer===u.tempId&&(e.payer=c),e.authorizations=e.authorizations.map(function(e){return e===u.tempId?c:e}),delete e.accounts[u.tempId]},t=0,o=Object.values(e.accounts);t<o.length;t++)r();for(var i=0,u=Object.values(e.accounts);i<u.length;i++){var c=u[i];I(w(c),"Account unable to fulfill roles",c)}return Promise.resolve(n.Ok(e))}catch(e){return Promise.reject(e)}}]);function B(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:e.accounts[e.proposer].addr,keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:e.accounts[e.payer].addr,authorizers:e.authorizations.map(function(n){return e.accounts[n].addr})}}var q=function(e,n,r){void 0===n&&(n=[]);try{return Promise.all(n.map(function(n){try{return Promise.resolve(e.accounts[n].signingFunction({message:r,addr:e.accounts[n].addr,keyId:e.accounts[n].keyId,roles:e.accounts[n].role,interaction:e})).then(function(r){if(r.cid=n,e.accounts[n].addr!==r.addr)throw new Error(n+" — mismatching address in composite signature");if(e.accounts[n].keyId!==r.keyId)throw new Error(n+" — mismatching keyId in composite signature");return r.sig=r.signature,r.address=r.addr,r})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function T(e,n){for(var r,t=function(e,n){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return f(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,void 0):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}(n);!(r=t()).done;){var o=r.value;e.accounts[o.cid].signature=o.signature}return n}Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return r.send}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return t.decode}}),Object.defineProperty(e,"decodeResponse",{enumerable:!0,get:function(){return t.decodeResponse}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return o.templar}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return o.templar}}),e.arg=function(e,n){return void 0===n&&(n=m),{value:e,xform:n}},e.args=function(e){return void 0===e&&(e=[]),n.pipe(e.map(function(e){return n.makeArgument("function"==typeof e?{resolve:e}:e)}))},e.authorization=function(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}},e.authorizations=function(e){return void 0===e&&(e=[]),n.pipe(e.map(function(e){return n.makeAuthorizer(s({},"function"==typeof e?{resolve:e}:e,{role:{authorizer:!0}}))}))},e.build=c,e.getAccount=l,e.getBlockByHeight=function(e){return n.pipe([n.makeGetBlockByHeight,function(r){return r.block.height=e,n.Ok(r)}])},e.getBlockById=function(e){return n.pipe([n.makeGetBlockById,function(r){return r.block.id=e,n.Ok(r)}])},e.getEvents=function(e,r,t){return n.pipe([n.makeGetEvents,function(r){return r.events.eventType=e,n.Ok(r)},function(e){return e.events.start=r,n.Ok(e)},function(e){return e.events.end=t,n.Ok(e)}])},e.getLatestBlock=d,e.getTransactionStatus=function(e){return n.pipe([n.makeGetTransactionStatus,function(r){return r.transactionId=e,n.Ok(r)}])},e.invariant=function e(){for(var r=arguments.length,t=new Array(r),o=0;o<r;o++)t[o]=arguments[o];if(t.length>1){var i=t[0],u=t[1];return e(function(e,n){var r=n.Bad;return i?(0,n.Ok)(e):r(e,u)})}var c=t[0];return function(e){return c(e,{Ok:n.Ok,Bad:n.Bad})}},e.limit=function(e){return n.pipe([function(r){return r.message.computeLimit=e,n.Ok(r)}])},e.param=function(e,n,r){return void 0===n&&(n=p),void 0===r&&(r=null),{key:r,value:e,xform:n}},e.params=function(e){return void 0===e&&(e=[]),n.pipe(e.map(function(e){return n.makeParam("function"==typeof e?{resolve:e}:e)}))},e.payer=function(e){return n.makePayer(s({},"function"==typeof e?{resolve:e}:e,{role:{payer:!0}}))},e.ping=function(){return n.pipe([n.makePing])},e.proposer=function(e){try{return Promise.resolve(n.makeProposer("function"==typeof e?{resolve:e,role:{proposer:!0}}:s({},e,{role:{proposer:!0}})))}catch(e){return Promise.reject(e)}},e.ref=function(e){return n.pipe([function(r){return r.message.refBlock=e,n.Ok(r)}])},e.resolve=a,e.resolveAccounts=A,e.resolveArguments=function(e){try{if(!n.isTransaction(e)&&!n.isScript(e))return Promise.resolve(n.Ok(e));var r=Object.values(e.arguments);return Promise.resolve(Promise.all(r.map(function(e){try{var n=!1,r=function(){if("function"==typeof e.resolve)return n=!0,Promise.resolve(e.resolve()).then(function(n){return s({},n,{tempId:e.tempId})})}();return Promise.resolve(r&&r.then?r.then(function(r){return n?r:e}):n?r:e)}catch(e){return Promise.reject(e)}}))).then(function(r){return r.forEach(function(n){e.arguments[n.tempId]=s({},n,{asArgument:n.xform.asArgument(n.value)})}),n.Ok(e)})}catch(e){return Promise.reject(e)}},e.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),i.resolveCadence(e)},e.resolveProposerSequenceNumber=function(e){var o=e.node;return function(e){try{return n.isTransaction(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(n.Ok(e)):Promise.resolve(c([l(e.accounts[e.proposer].addr)])).then(function(i){return Promise.resolve(r.send(i,{node:o})).then(function(r){return Promise.resolve(t.decodeResponse(r)).then(function(r){return e.accounts[e.proposer].sequenceNum=r.keys[e.accounts[e.proposer].keyId].sequenceNumber,n.Ok(e)})})}):Promise.resolve(n.Ok(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){var o=e.node;return function(e){try{return n.isTransaction(e)?e.message.refBlock?Promise.resolve(n.Ok(e)):Promise.resolve(c([d()])).then(function(i){return Promise.resolve(r.send(i,{node:o})).then(function(r){return Promise.resolve(t.decodeResponse(r)).then(function(r){return e.message.refBlock=r.id,n.Ok(e)})})}):Promise.resolve(n.Ok(e))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=function(e){try{if(!n.isTransaction(e))return Promise.resolve(e);var r=function(e){var n=new Set(e.authorizations);n.add(e.proposer),n.delete(e.payer),n=Array.from(n);var r=new Set([e.payer]);return{insideSigners:n,outsideSigners:r=Array.from(r)}}(e),t=r.outsideSigners;return Promise.resolve(q(e,r.insideSigners,u.encodeTransactionPayload(B(e)))).then(function(n){var r=T(e,n);return Promise.resolve(q(e,t,u.encodeTransactionEnvelope(s({},B(e),{payloadSigs:r})))).then(function(n){return T(e,n),e})})}catch(e){return Promise.reject(e)}},e.resolveValidators=function(e){try{var r=n.get(e,"ix.validators",[]);return Promise.resolve(n.pipe(e,r.map(function(e){return function(r){return e(r,{Ok:n.Ok,Bad:n.Bad})}})))}catch(e){return Promise.reject(e)}},e.script=function(){return n.pipe([n.makeScript,n.put("ix.cadence",o.templar.apply(void 0,arguments))])},e.transaction=function(){return n.pipe([n.makeTransaction,n.put("ix.cadence",o.templar.apply(void 0,arguments)),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||v,n.Ok(e)}])},e.validator=function(e){return n.update("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}}); | ||
//# sourceMappingURL=sdk.umd.js.map |
{ | ||
"name": "@onflow/sdk", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"description": "Flow SDK", | ||
@@ -40,2 +40,3 @@ "license": "Apache-2.0", | ||
"@onflow/interaction": "0.0.10", | ||
"@onflow/sdk-resolve-cadence": "0.0.0", | ||
"@onflow/send": "0.0.20", | ||
@@ -42,0 +43,0 @@ "@qvvg/templar": "0.0.1" |
@@ -1,37 +0,18 @@ | ||
import {isTransaction, isScript, get, Ok} from "@onflow/interaction" | ||
import {resolveCadence} from "@onflow/sdk-resolve-cadence" | ||
const isFn = d => typeof d === "function" | ||
const isString = s => typeof s === "string" | ||
export function resolveParams (ix) { | ||
console.error( | ||
` | ||
%cFCL/SDK Deprecation Notice | ||
============================ | ||
export const resolveParams = async (ix) => { | ||
if (!(isTransaction(ix) || isScript(ix))) return Ok(ix) | ||
const cadence = get(ix, 'ix.cadence') | ||
if (isString(cadence)) { | ||
ix.message.cadence = cadence | ||
return Ok(ix) | ||
} | ||
if (isFn(cadence)) { | ||
let unresolvedParams = Object | ||
.values(ix.params) | ||
let params = await Promise.all(unresolvedParams.map( | ||
async function resParam(up) { | ||
if (typeof up.resolve === "function") return ({ | ||
...await up.resolve(), | ||
tempId: up.tempId | ||
}) | ||
return up | ||
} | ||
)) | ||
params.forEach(p => { | ||
ix.params[p.tempId] = p | ||
}) | ||
params = Object.fromEntries(params | ||
.filter(param => param.key != null) | ||
.map(param => [param.key, param.xform.asInjection(param.value)])) | ||
The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence | ||
You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver | ||
ix.message.cadence = cadence(params) | ||
============================ | ||
`, | ||
"font-weight:bold;font-family:monospace;" | ||
) | ||
return Ok(ix) | ||
} | ||
throw new Error("Invalid Cadence Value") | ||
return resolveCadence(ix) | ||
} |
# Transitions | ||
### 0001 Deprecate Params | ||
## 0002 Deprecate Resolve Params Resolver | ||
- **Date:** Sept 29th 2020 | ||
- **Issue:** [#177](https://github.com/onflow/flow-js-sdk/issues/177) | ||
- **Type:** Deprecation of resolveParams Resolver | ||
At the time of writing this if you are writing script and transaction interactions and building up your resolvers yourself you will likely have a piece of code that looks something like this. | ||
```javascript | ||
import * as sdk from "@onflow/sdk" | ||
sdk.resolve(ix, [ | ||
sdk.resolveParams, | ||
]) | ||
``` | ||
We are introducing a more generic resolver that covers core cadence concepts: `@onflow/sdk-resolve-cadence`. | ||
The above code using `sdk.resolveParams` will still work for now as a proxy to `@onflow/sdk-resolve-cadence` (with deprecation notice), but we can't promise it will stay around for ever in the future. | ||
Instead we would recommend that you use the following in its place: | ||
```javascript | ||
import * as sdk from "@onflow/sdk" | ||
import {resolveCadence} from "@onflow/sdk-resolve-cadence" | ||
sdk.resolve(ix, [ | ||
resolveCadence, | ||
]) | ||
``` | ||
As part of our ongoing effort to break the sdk down into smaller and smaller pieces, at this time we are not considering adding in an `sdk.resolveCadence`. | ||
## 0001 Deprecate Params | ||
- **Date:** July 22nd 2020 | ||
@@ -6,0 +38,0 @@ - **Issue:** [#177](https://github.com/onflow/flow-js-sdk/issues/177) |
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
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
314239
6
893
+ Added@onflow/sdk-resolve-cadence@0.0.0(transitive)