@onflow/sdk
Advanced tools
Comparing version 0.0.32 to 0.0.33
@@ -5,2 +5,7 @@ ### Unreleased | ||
### 0.0.33 - 2020-09-29 | ||
- 2020-09-29 -- Proxy sdk.resolveArguments to `@onflow/sdk-resolve-arguments` | ||
- 2020-09-29 -- VSN `@onflow/sdk-resolve-cadence` 0.0.0 -> 0.0.1 | ||
### 0.0.32 -- 2020-09-29 | ||
@@ -7,0 +12,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/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]})}; | ||
var e=require("@onflow/interaction"),r=require("@onflow/send"),n=require("@onflow/decode"),t=require("@qvvg/templar"),o=require("@onflow/sdk-resolve-arguments"),i=require("@onflow/sdk-resolve-cadence"),u=require("@onflow/encode");function s(r){return void 0===r&&(r=[]),e.pipe(e.interaction(),r)}var a=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 p(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 l(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 d={asArgument:function(e){return e},asInjection:function(e){return e}},m={asArgument:function(e){return e},asInjection:function(e){return e}},v=[],y="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function g(e,r,n){if(!e.s){if(n instanceof h){if(!n.s)return void(n.o=g.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(g.bind(null,e,r),g.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var h=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{g(t,1,i(this.v))}catch(e){g(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?g(t,1,r?r(o):o):n?g(t,1,n(o)):g(t,2,o)}catch(e){g(t,2,e)}},t},e}();function k(e){return e instanceof h&&1&e.s}var b=function(e){return"function"==typeof e},P=function(e){return"number"==typeof e},O=function(e){return"string"==typeof e},x=function(e,r){if(!e){var n,t=new Error("INVARIANT "+r);throw t.stack=t.stack.split("\n").filter(function(e){return!/at invariant/.test(e)}).join("\n"),(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat([].slice.call(arguments,2),["\n\n---\n\n"])),t}},I=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)))},w=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})||{}},S=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[y]){var t,o,i,u=e[y]();if(function e(n){try{for(;!(t=u.next()).done;)if((n=r(t.value))&&n.then){if(!k(n))return void n.then(e,i||(i=g.bind(null,o=new h,2)));n=n.v}o?g(o,1,n):o=n}catch(e){g(o||(o=new h),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 a=[],c=0;c<e.length;c++)a.push(e[c]);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(!k(u))return void u.then(n,o||(o=g.bind(null,t=new h,2)));u=u.v}t?g(t,1,u):t=u}catch(e){g(t||(t=new h),2,e)}}(),t}(a,function(e){return r(a[e])})}(Object.entries(r.accounts),function(e){var n=e[0],t=e[1];function o(){x(I(r.accounts[n]),"Account unable to fulfill role",r.accounts[n])}var i=function(){if(b(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:w([e.kind,n.kind]),tempId:w([e.tempId,n.tempId]),addr:w([e.addr,n.addr]),keyId:(i=[e.keyId,n.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(P)[0]?i.filter(P)[0]:null),sequenceNum:"number"==typeof j([e,n]).sequenceNum?j([e,n]).sequenceNum:e.sequenceNum,signature:w([e.signature,n.signature]),signingFunction:w([e.signingFunction,n.signingFunction]),resolve:w([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];x(I(s),"Account unable to fulfill roles",s)}return Promise.resolve(e.Ok(r))}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 p(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)?p(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}}),Object.defineProperty(exports,"resolveArguments",{enumerable:!0,get:function(){return o.resolveArguments}}),exports.arg=function(e,r){return void 0===r&&(r=m),{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=s,exports.getAccount=l,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(){var n=[].slice.call(arguments);if(n.length>1){var t=n,o=t[0],i=t[1];return r(function(e,r){var n=r.Bad;return o?(0,r.Ok)(e):n(e,i)})}var u=n[0];return function(r){return u(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=d),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=a,exports.resolveAccounts=S,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;"),i.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(s([l(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(s([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(B(r,n.insideSigners,u.encodeTransactionPayload(A(r)))).then(function(e){var n=q(r,e);return Promise.resolve(B(r,t,u.encodeTransactionEnvelope(c({},A(r),{payloadSigs:n})))).then(function(e){return q(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,[].slice.call(arguments)))])},exports.transaction=function(){return e.pipe([e.makeTransaction,e.put("ix.cadence",t.templar.apply(void 0,[].slice.call(arguments))),function(r){return r.message.computeLimit=r.message.computeLimit||10,r.message.refBlock=r.message.refBlock||null,r.authorizations=r.authorizations||v,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 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}; | ||
import{pipe as e,interaction as n,makeAuthorizer as r,makeGetAccount as o,Ok as t,makeGetEvents as s,makeGetLatestBlock as a,makeGetBlockById as c,makeGetBlockByHeight as i,makeGetTransactionStatus as u,makeParam as d,makeArgument as l,makeProposer as p,makePayer as f,makePing as m,makeScript as g,put as y,makeTransaction as k,update as v,Bad as w,isTransaction as h,get as I}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{send as b}from"@onflow/send";export{send}from"@onflow/send";import{decodeResponse as N}from"@onflow/decode";export{decode,decodeResponse}from"@onflow/decode";import{templar as A}from"@qvvg/templar";export{templar as cadence,templar as cdc}from"@qvvg/templar";export{resolveArguments}from"@onflow/sdk-resolve-arguments";import{resolveCadence as q}from"@onflow/sdk-resolve-cadence";import{encodeTransactionPayload as x,encodeTransactionEnvelope as z}from"@onflow/encode";function B(r=[]){return e(n(),r)}const O=e;function S(){return(S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function j(n=[]){return e(n.map(e=>r(S({},"function"==typeof e?{resolve:e}:e,{role:{authorizer:!0}}))))}function F(e,n,r,o){return{addr:e,signingFunction:n,keyId:r,sequenceNum:o}}function L(n){return e([o,e=>(e.accountAddr=n,t(e))])}function T(n,r,o){return e([s,e=>(e.events.eventType=n,t(e)),e=>(e.events.start=r,t(e)),e=>(e.events.end=o,t(e))])}function E(n=!1){return e([a,e=>(e.block.isSealed=n,t(e))])}function P(n){return e([c,e=>(e.block.id=n,t(e))])}function R(n){return e([i,e=>(e.block.height=n,t(e))])}function D(n){return e([u,e=>(e.transactionId=n,t(e))])}function K(n){return e([e=>(e.message.computeLimit=n,t(e))])}function $(n=[]){return e(n.map(e=>d("function"==typeof e?{resolve:e}:e)))}const C={asArgument:e=>e,asInjection:e=>e};function V(e,n=C,r=null){return{key:r,value:e,xform:n}}function Y(n=[]){return e(n.map(e=>l("function"==typeof e?{resolve:e}:e)))}const G={asArgument:e=>e,asInjection:e=>e};function H(e,n=G){return{value:e,xform:n}}async function J(e){return p("function"==typeof e?{resolve:e,role:{proposer:!0}}:S({},e,{role:{proposer:!0}}))}function M(e){return f(S({},"function"==typeof e?{resolve:e}:e,{role:{payer:!0}}))}function Q(){return e([m])}function U(n){return e([e=>(e.message.refBlock=n,t(e))])}function W(...n){return e([g,y("ix.cadence",A(...n))])}const X=[];function Z(...n){return e([k,y("ix.cadence",A(...n)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||X,t(e))])}function _(e){return v("ix.validators",n=>Array.isArray(n)?n.push(e):[e])}function ee(...e){if(e.length>1){const[n,r]=e;return ee((e,{Ok:o,Bad:t})=>n?o(e):t(e,r))}const[n]=e;return e=>n(e,{Ok:t,Bad:w})}const ne=e=>"function"==typeof e,re=e=>"number"==typeof e,oe=e=>"string"==typeof e,te=(e,n,...r)=>{if(!e){const e=new Error("INVARIANT "+n);throw e.stack=e.stack.split("\n").filter(e=>!/at invariant/.test(e)).join("\n"),console.error("\n\n---\n\n",e,"\n\n",...r,"\n\n---\n\n"),e}},se=e=>!(e.role.proposer&&!(oe(e.addr)&&re(e.keyId)&&re(e.sequenceNum)&&ne(e.signingFunction))||e.role.payer&&!(oe(e.addr)&&re(e.keyId)&&ne(e.signingFunction))||e.role.authorizer&&!(oe(e.addr)&&re(e.keyId)&&ne(e.signingFunction))),ae=(e=[])=>e.filter(Boolean)[0]||null,ce=(e=[])=>"number"==typeof e.filter(re)[0]?e.filter(re)[0]:null,ie=(e=[])=>e.find(e=>e.role.proposer)||{},ue=e([async e=>{if(!h(e))return t(e);for(let[n,r]of Object.entries(e.accounts))ne(r.resolve)&&(e.accounts[n]=await r.resolve(r)),te(se(e.accounts[n]),"Account unable to fulfill role",e.accounts[n]);return t(e)},async e=>{if(!h(e))return t(e);for(let o of Object.values(e.accounts)){const t=`${o.addr}|${o.keyId}`;e.accounts[t]=null!=e.accounts[t]?(n=e.accounts[t],r=S({tempId:t},o),{kind:ae([n.kind,r.kind]),tempId:ae([n.tempId,r.tempId]),addr:ae([n.addr,r.addr]),keyId:ce([n.keyId,r.keyId]),sequenceNum:"number"==typeof ie([n,r]).sequenceNum?ie([n,r]).sequenceNum:n.sequenceNum,signature:ae([n.signature,r.signature]),signingFunction:ae([n.signingFunction,r.signingFunction]),resolve:ae([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:t},o),e.proposer===o.tempId&&(e.proposer=t),e.payer===o.tempId&&(e.payer=t),e.authorizations=e.authorizations.map(e=>e===o.tempId?t:e),delete e.accounts[o.tempId]}var n,r;for(let n of Object.values(e.accounts))te(se(n),"Account unable to fulfill roles",n);return t(e)}]);function de(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;"),q(e)}function le(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(n=>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(n=>e.accounts[n].addr)}}async function pe(e,n=[],r){return Promise.all(n.map(async n=>{const o=await e.accounts[n].signingFunction({message:r,addr:e.accounts[n].addr,keyId:e.accounts[n].keyId,roles:e.accounts[n].role,interaction:e});if(o.cid=n,e.accounts[n].addr!==o.addr)throw new Error(n+" — mismatching address in composite signature");if(e.accounts[n].keyId!==o.keyId)throw new Error(n+" — mismatching keyId in composite signature");return o.sig=o.signature,o.address=o.addr,o}))}function fe(e,n){for(let{cid:r,signature:o}of n)e.accounts[r].signature=o;return n}async function me(e){if(!h(e))return e;const{insideSigners:n,outsideSigners:r}=function(e){let n=new Set(e.authorizations);n.add(e.proposer),n.delete(e.payer),n=Array.from(n);let r=new Set([e.payer]);return r=Array.from(r),{insideSigners:n,outsideSigners:r}}(e),o=fe(e,await pe(e,n,x(le(e))));return fe(e,await pe(e,r,z(S({},le(e),{payloadSigs:o})))),e}async function ge(n){const r=I(n,"ix.validators",[]);return e(n,r.map(e=>n=>e(n,{Ok:t,Bad:w})))}const ye=({node:e})=>async n=>{if(!h(n))return t(n);if(n.accounts[n.proposer].sequenceNum)return t(n);const r=await b(await B([L(n.accounts[n.proposer].addr)]),{node:e}),o=await N(r);return n.accounts[n.proposer].sequenceNum=o.keys[n.accounts[n.proposer].keyId].sequenceNumber,t(n)},ke=({node:e})=>async n=>{if(!h(n))return t(n);if(n.message.refBlock)return t(n);const r=await b(await B([E()]),{node:e}),o=await N(r);return n.message.refBlock=o.id,t(n)};export{H as arg,Y as args,F as authorization,j as authorizations,B as build,L as getAccount,R as getBlockByHeight,P as getBlockById,T as getEvents,E as getLatestBlock,D as getTransactionStatus,ee as invariant,K as limit,V as param,$ as params,M as payer,Q as ping,J as proposer,U as ref,O as resolve,ue as resolveAccounts,de as resolveParams,ye as resolveProposerSequenceNumber,ke as resolveRefBlockId,me as resolveSignatures,ge as resolveValidators,W as script,Z as transaction,_ 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 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}; | ||
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 a,makeGetTransactionStatus as s,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 k,isTransaction as b,get as w}from"@onflow/interaction";export{isBad,isOk,pipe,why}from"@onflow/interaction";import{send as I}from"@onflow/send";export{send}from"@onflow/send";import{decodeResponse as P}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";export{resolveArguments}from"@onflow/sdk-resolve-arguments";import{resolveCadence as S}from"@onflow/sdk-resolve-cadence";import{encodeTransactionPayload as A,encodeTransactionEnvelope as N}from"@onflow/encode";function x(n){return void 0===n&&(n=[]),r(e(),n)}var O=r;function q(){return(q=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(q({},"function"==typeof r?{resolve:r}:r,{role:{authorizer:!0}}))}))}function F(r,e,n,t){return{addr:r,signingFunction:e,keyId:n,sequenceNum:t}}function T(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 E(e){return void 0===e&&(e=!1),r([u,function(r){return r.block.isSealed=e,o(r)}])}function R(e){return r([c,function(r){return r.block.id=e,o(r)}])}function C(e){return r([a,function(r){return r.block.height=e,o(r)}])}function D(e){return r([s,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 V(r,e,n){return void 0===e&&(e=U),void 0===n&&(n=null),{key:n,value:r,xform:e}}function Y(e){return void 0===e&&(e=[]),r(e.map(function(r){return l("function"==typeof r?{resolve:r}:r)}))}var $={asArgument:function(r){return r},asInjection:function(r){return r}};function G(r,e){return void 0===e&&(e=$),{value:r,xform:e}}var H=function(r){try{return J(r)?Promise.resolve(d({resolve:r,role:{proposer:!0}})):Promise.resolve(d(q({},r,{role:{proposer:!0}})))}catch(r){return Promise.reject(r)}},J=function(r){return"function"==typeof r};function Q(r){return m(q({},"function"==typeof r?{resolve:r}:r,{role:{payer:!0}}))}function W(){return r([p])}function X(e){return r([function(r){return r.message.refBlock=e,o(r)}])}function Z(){return r([v,y("ix.cadence",j.apply(void 0,[].slice.call(arguments)))])}var _=[];function rr(){return r([h,y("ix.cadence",j.apply(void 0,[].slice.call(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(){var r=[].slice.call(arguments);if(r.length>1){var e=r,n=e[0],t=e[1];return nr(function(r,e){var o=e.Bad;return n?(0,e.Ok)(r):o(r,t)})}var i=r[0];return function(r){return i(r,{Ok:o,Bad:k})}}var tr="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function or(r,e,n){if(!r.s){if(n instanceof ir){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;var t=r.o;t&&t(r)}}var ir=function(){function r(){}return r.prototype.then=function(e,n){var t=new r,o=this.s;if(o){var i=1&o?e:n;if(i){try{or(t,1,i(this.v))}catch(r){or(t,2,r)}return t}return this}return this.o=function(r){try{var 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 ur(r){return r instanceof ir&&1&r.s}var cr=function(r){return"function"==typeof r},ar=function(r){return"number"==typeof r},sr=function(r){return"string"==typeof r},fr=function(r,e){if(!r){var n,t=new Error("INVARIANT "+e);throw t.stack=t.stack.split("\n").filter(function(r){return!/at invariant/.test(r)}).join("\n"),(n=console).error.apply(n,["\n\n---\n\n",t,"\n\n"].concat([].slice.call(arguments,2),["\n\n---\n\n"])),t}},lr=function(r){return!(r.role.proposer&&!(sr(r.addr)&&ar(r.keyId)&&ar(r.sequenceNum)&&cr(r.signingFunction))||r.role.payer&&!(sr(r.addr)&&ar(r.keyId)&&cr(r.signingFunction))||r.role.authorizer&&!(sr(r.addr)&&ar(r.keyId)&&cr(r.signingFunction)))},dr=function(r){return void 0===r&&(r=[]),r.filter(Boolean)[0]||null},mr=function(r){return void 0===r&&(r=[]),r.find(function(r){return r.role.proposer})||{}},pr=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[tr]){var t,o,i,u=r[tr]();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=or.bind(null,o=new ir,2)));n=n.v}o?or(o,1,n):o=n}catch(r){or(o||(o=new ir),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 a=[],s=0;s<r.length;s++)a.push(r[s]);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=or.bind(null,t=new ir,2)));u=u.v}t?or(t,1,u):t=u}catch(r){or(t||(t=new ir),2,r)}}(),t}(a,function(r){return e(a[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 i=function(){if(cr(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(!b(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=q({tempId:c},u),{kind:dr([e.kind,o.kind]),tempId:dr([e.tempId,o.tempId]),addr:dr([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 mr([e,o]).sequenceNum?mr([e,o]).sequenceNum:e.sequenceNum,signature:dr([e.signature,o.signature]),signingFunction:dr([e.signingFunction,o.signingFunction]),resolve:dr([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}}):q({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];fr(lr(c),"Account unable to fulfill roles",c)}return Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}]);function vr(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;"),S(r)}function yr(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 hr=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(gr(r,e.insideSigners,A(yr(r)))).then(function(e){var t=kr(r,e);return Promise.resolve(gr(r,n,N(q({},yr(r),{payloadSigs:t})))).then(function(e){return kr(r,e),r})})}catch(r){return Promise.reject(r)}},gr=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 kr(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 br=function(e){try{var n=w(e,"ix.validators",[]);return Promise.resolve(r(e,n.map(function(r){return function(e){return r(e,{Ok:o,Bad:k})}})))}catch(r){return Promise.reject(r)}},wr=function(r){var e=r.node;return function(r){try{return b(r)?r.accounts[r.proposer].sequenceNum?Promise.resolve(o(r)):Promise.resolve(x([T(r.accounts[r.proposer].addr)])).then(function(n){return Promise.resolve(I(n,{node:e})).then(function(e){return Promise.resolve(P(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)}}},Ir=function(r){var e=r.node;return function(r){try{return b(r)?r.message.refBlock?Promise.resolve(o(r)):Promise.resolve(x([E()])).then(function(n){return Promise.resolve(I(n,{node:e})).then(function(e){return Promise.resolve(P(e)).then(function(e){return r.message.refBlock=e.id,o(r)})})}):Promise.resolve(o(r))}catch(r){return Promise.reject(r)}}};export{G as arg,Y as args,F as authorization,B as authorizations,x as build,T as getAccount,C as getBlockByHeight,R as getBlockById,L as getEvents,E as getLatestBlock,D as getTransactionStatus,nr as invariant,K as limit,V as param,M as params,Q as payer,W as ping,H as proposer,X as ref,O as resolve,pr as resolveAccounts,vr as resolveParams,wr as resolveProposerSequenceNumber,Ir as resolveRefBlockId,hr as resolveSignatures,br as resolveValidators,Z as script,rr as transaction,er as validator}; | ||
//# sourceMappingURL=sdk.module.js.map |
@@ -1,2 +0,2 @@ | ||
!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]})}}); | ||
!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-arguments"),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-arguments","@onflow/sdk-resolve-cadence","@onflow/encode"],n):n((e=e||self).sdk={},e.interaction,e.send,e.decode,e.templar,e.sdkResolveArguments,e.sdkResolveCadence,e.encode)}(this,function(e,n,r,t,o,i,u,c){function a(e){return void 0===e&&(e=[]),n.pipe(n.interaction(),e)}var s=n.pipe;function l(){return(l=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 d(e){return n.pipe([n.makeGetAccount,function(r){return r.accountAddr=e,n.Ok(r)}])}function p(e){return void 0===e&&(e=!1),n.pipe([n.makeGetLatestBlock,function(r){return r.block.isSealed=e,n.Ok(r)}])}var m={asArgument:function(e){return e},asInjection:function(e){return e}},v={asArgument:function(e){return e},asInjection:function(e){return e}},y=[],g="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function h(e,n,r){if(!e.s){if(r instanceof k){if(!r.s)return void(r.o=h.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(h.bind(null,e,n),h.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var k=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{h(t,1,i(this.v))}catch(e){h(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?h(t,1,n?n(o):o):r?h(t,1,r(o)):h(t,2,o)}catch(e){h(t,2,e)}},t},e}();function b(e){return e instanceof k&&1&e.s}var P=function(e){return"function"==typeof e},O=function(e){return"number"==typeof e},w=function(e){return"string"==typeof e},I=function(e,n){if(!e){var r,t=new Error("INVARIANT "+n);throw t.stack=t.stack.split("\n").filter(function(e){return!/at invariant/.test(e)}).join("\n"),(r=console).error.apply(r,["\n\n---\n\n",t,"\n\n"].concat([].slice.call(arguments,2),["\n\n---\n\n"])),t}},j=function(e){return!(e.role.proposer&&!(w(e.addr)&&O(e.keyId)&&O(e.sequenceNum)&&P(e.signingFunction))||e.role.payer&&!(w(e.addr)&&O(e.keyId)&&P(e.signingFunction))||e.role.authorizer&&!(w(e.addr)&&O(e.keyId)&&P(e.signingFunction)))},A=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})||{}},B=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[g]){var t,o,i,u=e[g]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!b(r))return void r.then(e,i||(i=h.bind(null,o=new k,2)));r=r.v}o?h(o,1,r):o=r}catch(e){h(o||(o=new k),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(!b(u))return void u.then(r,o||(o=h.bind(null,t=new k,2)));u=u.v}t?h(t,1,u):t=u}catch(e){h(t||(t=new k),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(j(e.accounts[r]),"Account unable to fulfill role",e.accounts[r])}var i=function(){if(P(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=l({tempId:c},u),{kind:A([n.kind,r.kind]),tempId:A([n.tempId,r.tempId]),addr:A([n.addr,r.addr]),keyId:(i=[n.keyId,r.keyId],void 0===i&&(i=[]),"number"==typeof i.filter(O)[0]?i.filter(O)[0]:null),sequenceNum:"number"==typeof S([n,r]).sequenceNum?S([n,r]).sequenceNum:n.sequenceNum,signature:A([n.signature,r.signature]),signingFunction:A([n.signingFunction,r.signingFunction]),resolve:A([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}}):l({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(j(c),"Account unable to fulfill roles",c)}return Promise.resolve(n.Ok(e))}catch(e){return Promise.reject(e)}}]);function q(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 N=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}}),Object.defineProperty(e,"resolveArguments",{enumerable:!0,get:function(){return i.resolveArguments}}),e.arg=function(e,n){return void 0===n&&(n=v),{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(l({},"function"==typeof e?{resolve:e}:e,{role:{authorizer:!0}}))}))},e.build=a,e.getAccount=d,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=p,e.getTransactionStatus=function(e){return n.pipe([n.makeGetTransactionStatus,function(r){return r.transactionId=e,n.Ok(r)}])},e.invariant=function e(){var r=[].slice.call(arguments);if(r.length>1){var t=r,o=t[0],i=t[1];return e(function(e,n){var r=n.Bad;return o?(0,n.Ok)(e):r(e,i)})}var u=r[0];return function(e){return u(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=m),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(l({},"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}}:l({},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=s,e.resolveAccounts=B,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;"),u.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(a([d(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(a([p()])).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(N(e,r.insideSigners,c.encodeTransactionPayload(q(e)))).then(function(n){var r=T(e,n);return Promise.resolve(N(e,t,c.encodeTransactionEnvelope(l({},q(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,[].slice.call(arguments)))])},e.transaction=function(){return n.pipe([n.makeTransaction,n.put("ix.cadence",o.templar.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||y,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.32", | ||
"version": "0.0.33", | ||
"description": "Flow SDK", | ||
@@ -21,5 +21,5 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"jest": "25.3.0", | ||
"jest": "26.4.2", | ||
"jest-esm-transformer": "1.0.0", | ||
"microbundle": "0.12.0-next.8" | ||
"microbundle": "0.12.4" | ||
}, | ||
@@ -41,3 +41,4 @@ "source": "src/sdk.js", | ||
"@onflow/interaction": "0.0.10", | ||
"@onflow/sdk-resolve-cadence": "0.0.0", | ||
"@onflow/sdk-resolve-arguments": "0.0.1", | ||
"@onflow/sdk-resolve-cadence": "0.0.1", | ||
"@onflow/send": "0.0.20", | ||
@@ -44,0 +45,0 @@ "@qvvg/templar": "0.0.1" |
@@ -1,25 +0,1 @@ | ||
import {isTransaction, isScript, Ok} from "@onflow/interaction" | ||
export const resolveArguments = async (ix) => { | ||
if (!(isTransaction(ix) || isScript(ix))) return Ok(ix) | ||
let unresolvedArguments = Object | ||
.values(ix.arguments) | ||
let args = await Promise.all(unresolvedArguments.map( | ||
async function resArg(ua) { | ||
if (typeof ua.resolve === "function") return ({ | ||
...await ua.resolve(), | ||
tempId: ua.tempId | ||
}) | ||
return ua | ||
} | ||
)) | ||
args.forEach(a => { | ||
ix.arguments[a.tempId] = { | ||
...a, | ||
asArgument: a.xform.asArgument(a.value), | ||
} | ||
}) | ||
return Ok(ix) | ||
} | ||
export {resolveArguments} from "@onflow/sdk-resolve-arguments" |
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
208560
7
845
+ Added@onflow/sdk-resolve-arguments@0.0.1(transitive)
+ Added@onflow/sdk-resolve-cadence@0.0.1(transitive)
- Removed@onflow/sdk-resolve-cadence@0.0.0(transitive)