@magic-ext/flow 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import{Extension as n}from"@magic-sdk/commons";import*as t from"@onflow/fcl";function o(){return(o=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&(n[e]=o[e])}return n}).apply(this,arguments)}class e extends n.Internal{constructor(n){var e;super(),e=this,this.flowConfig=void 0,this.name="flow",this.config={},this.authorization=async function(n={}){t.config().put("accessNode.api",e.config.rpcUrl);const r=await e.request({id:42,jsonrpc:"2.0",method:"flow_getAccount",params:{}});let s;if(n.role.proposer){const n=await t.send([t.getAccount(r)]);s=(await t.decode(n)).keys[0].sequenceNumber}return o({},n,{addr:r,keyId:0,signingFunction:async function(n){const t=await e.request({id:42,jsonrpc:"2.0",method:"flow_signTransaction",params:{message:n.message}});return{addr:r,keyId:0,signature:t}},sequenceNum:s})},this.flowConfig=n,this.config={rpcUrl:n.rpcUrl,chainType:"FLOW"}}}export{e as FlowExtension};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import { Extension } from '@magic-sdk/commons';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as fcl from '@onflow/fcl';\nimport { FlowConfig } from './type';\n\nexport class FlowExtension extends Extension.Internal<'flow', any> {\n name = 'flow' as const;\n config: any = {};\n\n constructor(public flowConfig: FlowConfig) {\n super();\n\n this.config = {\n rpcUrl: flowConfig.rpcUrl,\n chainType: 'FLOW',\n };\n }\n\n authorization = async (account: any = {}) => {\n fcl.config().put('accessNode.api', this.config.rpcUrl);\n const addr = await this.request({\n id: 42,\n jsonrpc: '2.0',\n method: 'flow_getAccount',\n params: {},\n });\n const keyId = 0;\n let sequenceNum;\n if (account.role.proposer) {\n const response = await fcl.send([fcl.getAccount(addr)]);\n const acct = await fcl.decode(response);\n sequenceNum = acct.keys[keyId].sequenceNumber;\n }\n\n const signingFunction = async (data: any) => {\n const signature = await this.request({\n id: 42,\n jsonrpc: '2.0',\n method: 'flow_signTransaction',\n params: {\n message: data.message,\n },\n });\n\n return {\n addr,\n keyId,\n signature,\n };\n };\n\n return {\n ...account,\n addr,\n keyId,\n signingFunction,\n sequenceNum,\n };\n };\n}\n"],"names":["FlowExtension","Extension","Internal","constructor","flowConfig","super","name","config","authorization","async","account","fcl","put","_this","rpcUrl","addr","request","id","jsonrpc","method","params","sequenceNum","role","proposer","response","send","getAccount","decode","keys","sequenceNumber","keyId","signingFunction","data","signature","message","this","chainType"],"mappings":"kSAOaA,UAAsBC,EAAUC,SAI3CC,YAAmBC,SACjBC,oBADiBD,uBAHnBE,KAAO,YACPC,OAAc,QAWdC,cAAgBC,eAAOC,EAAe,IACpCC,EAAIJ,SAASK,IAAI,iBAAkBC,EAAKN,OAAOO,QAC/C,MAAMC,QAAaF,EAAKG,QAAQ,CAC9BC,GAAI,GACJC,QAAS,MACTC,OAAQ,kBACRC,OAAQ,KAGV,IAAIC,EACJ,GAAIX,EAAQY,KAAKC,SAAU,CACzB,MAAMC,QAAiBb,EAAIc,KAAK,CAACd,EAAIe,WAAWX,KAEhDM,SADmBV,EAAIgB,OAAOH,IACXI,KALP,GAKmBC,eAoBjC,YACKnB,GACHK,KAAAA,EACAe,MA5BY,EA6BZC,gBArBsBtB,eAAOuB,GAC7B,MAAMC,QAAkBpB,EAAKG,QAAQ,CACnCC,GAAI,GACJC,QAAS,MACTC,OAAQ,uBACRC,OAAQ,CACNc,QAASF,EAAKE,WAIlB,MAAO,CACLnB,KAAAA,EACAe,MApBU,EAqBVG,UAAAA,IASFZ,YAAAA,KA/Cec,gBAAA/B,EAGjB+B,KAAK5B,OAAS,CACZO,OAAQV,EAAWU,OACnBsB,UAAW"}
@@ -0,0 +1,2 @@
1
+ var e=require("@magic-sdk/commons");function r(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var t=r(require("@onflow/fcl"));function n(){return(n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function o(e,r){return(o=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}exports.FlowExtension=function(e){var r,c;function i(r){var o;return(o=e.call(this)||this).flowConfig=void 0,o.name="flow",o.config={},o.authorization=function(e){void 0===e&&(e={});try{return t.config().put("accessNode.api",o.config.rpcUrl),Promise.resolve(o.request({id:42,jsonrpc:"2.0",method:"flow_getAccount",params:{}})).then(function(r){function c(){return n({},e,{addr:r,keyId:u,signingFunction:function(e){try{return Promise.resolve(o.request({id:42,jsonrpc:"2.0",method:"flow_signTransaction",params:{message:e.message}})).then(function(e){return{addr:r,keyId:u,signature:e}})}catch(e){return Promise.reject(e)}},sequenceNum:i})}var i,u=0,s=function(){if(e.role.proposer)return Promise.resolve(t.send([t.getAccount(r)])).then(function(e){return Promise.resolve(t.decode(e)).then(function(e){i=e.keys[u].sequenceNumber})})}();return s&&s.then?s.then(c):c()})}catch(e){return Promise.reject(e)}},o.flowConfig=r,o.config={rpcUrl:r.rpcUrl,chainType:"FLOW"},o}return c=e,(r=i).prototype=Object.create(c.prototype),r.prototype.constructor=r,o(r,c),i}(e.Extension.Internal);
2
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sources":["../../src/index.ts"],"sourcesContent":["import { Extension } from '@magic-sdk/commons';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as fcl from '@onflow/fcl';\nimport { FlowConfig } from './type';\n\nexport class FlowExtension extends Extension.Internal<'flow', any> {\n name = 'flow' as const;\n config: any = {};\n\n constructor(public flowConfig: FlowConfig) {\n super();\n\n this.config = {\n rpcUrl: flowConfig.rpcUrl,\n chainType: 'FLOW',\n };\n }\n\n authorization = async (account: any = {}) => {\n fcl.config().put('accessNode.api', this.config.rpcUrl);\n const addr = await this.request({\n id: 42,\n jsonrpc: '2.0',\n method: 'flow_getAccount',\n params: {},\n });\n const keyId = 0;\n let sequenceNum;\n if (account.role.proposer) {\n const response = await fcl.send([fcl.getAccount(addr)]);\n const acct = await fcl.decode(response);\n sequenceNum = acct.keys[keyId].sequenceNumber;\n }\n\n const signingFunction = async (data: any) => {\n const signature = await this.request({\n id: 42,\n jsonrpc: '2.0',\n method: 'flow_signTransaction',\n params: {\n message: data.message,\n },\n });\n\n return {\n addr,\n keyId,\n signature,\n };\n };\n\n return {\n ...account,\n addr,\n keyId,\n signingFunction,\n sequenceNum,\n };\n };\n}\n"],"names":["flowConfig","_this","name","config","authorization","account","fcl","put","rpcUrl","request","id","jsonrpc","method","params","addr","keyId","signingFunction","data","message","signature","sequenceNum","role","proposer","send","getAccount","response","decode","acct","keys","sequenceNumber","chainType","Extension","Internal"],"mappings":"uqBAWE,WAAmBA,gBACjBC,sBADiBD,oBAHnBE,KAAO,SACPC,OAAc,KAWdC,uBAAuBC,YAAAA,IAAAA,EAAe,eACpCC,EAAIH,SAASI,IAAI,iBAAkBN,EAAKE,OAAOK,wBAC5BP,EAAKQ,QAAQ,CAC9BC,GAAI,GACJC,QAAS,MACTC,OAAQ,kBACRC,OAAQ,oBAJJC,gBA+BN,YACKT,GACHS,KAAAA,EACAC,MAAAA,EACAC,yBArB6BC,8BACLhB,EAAKQ,QAAQ,CACnCC,GAAI,GACJC,QAAS,MACTC,OAAQ,uBACRC,OAAQ,CACNK,QAASD,EAAKC,0BALZC,GASN,MAAO,CACLL,KAAAA,EACAC,MAAAA,EACAI,UAAAA,KAbiB,oCAsBnBC,YAAAA,IA9BF,IACIA,EADEL,EAAQ,kBAEVV,EAAQgB,KAAKC,gCACQhB,EAAIiB,KAAK,CAACjB,EAAIkB,WAAWV,oBAA1CW,0BACanB,EAAIoB,OAAOD,kBAAxBE,GACNP,EAAcO,EAAKC,KAAKb,GAAOc,2FAtBhB5B,aAAAD,EAGjBC,EAAKE,OAAS,CACZK,OAAQR,EAAWQ,OACnBsB,UAAW,UATjB,0FAAmCC,YAAUC"}
@@ -1,2 +1,2 @@
1
- import { FlowExtension } from './index';
2
- export { FlowExtension as default };
1
+ import { FlowExtension } from './index';
2
+ export { FlowExtension as default };
@@ -1,9 +1,9 @@
1
- import { Extension } from 'magic-sdk';
2
- import { FlowConfig } from './type';
3
- export declare class FlowExtension extends Extension.Internal<'flow', any> {
4
- flowConfig: FlowConfig;
5
- name: "flow";
6
- config: any;
7
- constructor(flowConfig: FlowConfig);
8
- authorization: (account?: any) => Promise<any>;
9
- }
1
+ import { Extension } from '@magic-sdk/commons';
2
+ import { FlowConfig } from './type';
3
+ export declare class FlowExtension extends Extension.Internal<'flow', any> {
4
+ flowConfig: FlowConfig;
5
+ name: "flow";
6
+ config: any;
7
+ constructor(flowConfig: FlowConfig);
8
+ authorization: (account?: any) => Promise<any>;
9
+ }
package/package.json CHANGED
@@ -1,59 +1,38 @@
1
1
  {
2
2
  "name": "@magic-ext/flow",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "magic flow extension",
5
- "author": "Fortmatic <team@fortmatic.com> (https://fortmatic.com/)",
5
+ "author": "Magic <team@magic.link> (https://magic.link/)",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/fortmatic/magic-sdk-extensions"
9
+ "url": "https://github.com/magiclabs/magic-js"
10
10
  },
11
11
  "files": [
12
- "dist/**/*"
12
+ "dist"
13
13
  ],
14
- "umdGlobal": "MagicFlowExtrnsion",
15
- "main": "dist/npm/commonjs/index.js",
16
- "umd:main": "dist/extension.js",
17
- "module": "dist/npm/module/index.js",
18
- "types": "dist/npm/commonjs/index.d.ts",
19
- "scripts": {
20
- "precommit": "lint-staged"
14
+ "target": "web",
15
+ "cdnGlobalName": "MagicFlowExtension",
16
+ "main": "./dist/cjs/index.js",
17
+ "module": "./dist/es/index.js",
18
+ "types": "./dist/types/index.d.ts",
19
+ "jsdelivr": "./dist/extension.js",
20
+ "react-native": "./dist/react-native/index.native.js",
21
+ "exports": {
22
+ "import": "./dist/modern/index.mjs",
23
+ "require": "./dist/cjs/index.js"
21
24
  },
22
- "devDependencies": {
23
- "@onflow/fcl": "0.0.41",
24
- "magic-sdk": "^2.1.0"
25
- },
26
- "peerDependencies": {
27
- "magic-sdk": "^2.1.0",
28
- "@onflow/fcl": "0.0.41"
29
- },
30
- "ava": {
31
- "require": [
32
- "ts-node/register",
33
- "./test/setup.ts"
34
- ],
35
- "files": [
36
- "test/**/*.spec.ts"
37
- ],
38
- "extensions": [
39
- "ts"
40
- ],
41
- "verbose": true
42
- },
43
- "nyc": {
44
- "extends": "@istanbuljs/nyc-config-typescript",
45
- "all": false,
46
- "check-coverage": true,
47
- "per-file": true,
48
- "lines": 99,
49
- "statements": 99,
50
- "functions": 99,
51
- "branches": 99,
52
- "reporter": [
53
- "lcov"
25
+ "externals": {
26
+ "include": [
27
+ "@magic-sdk/commons",
28
+ "@onflow/fcl",
29
+ "@onflow/types"
54
30
  ]
55
31
  },
56
- "dependencies": {
32
+ "devDependencies": {
33
+ "@magic-sdk/commons": "^2.2.1",
34
+ "@onflow/fcl": "0.0.41",
57
35
  "@onflow/types": "0.0.3"
58
- }
36
+ },
37
+ "gitHead": "89934a470863df3e54228c02f677c90fc4de364c"
59
38
  }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = void 0;
4
- var index_1 = require("./index");
5
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return index_1.FlowExtension; } });
6
- //# sourceMappingURL=index.cdn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cdn.js","sourceRoot":"","sources":["../../../src/index.cdn.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AAEd,wFAFjB,qBAAa,OAEW"}
@@ -1,9 +0,0 @@
1
- import { Extension } from 'magic-sdk';
2
- import { FlowConfig } from './type';
3
- export declare class FlowExtension extends Extension.Internal<'flow', any> {
4
- flowConfig: FlowConfig;
5
- name: "flow";
6
- config: any;
7
- constructor(flowConfig: FlowConfig);
8
- authorization: (account?: any) => Promise<any>;
9
- }
@@ -1,161 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/ban-ts-ignore */
3
- var __extends = (this && this.__extends) || (function () {
4
- var extendStatics = function (d, b) {
5
- extendStatics = Object.setPrototypeOf ||
6
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8
- return extendStatics(d, b);
9
- };
10
- return function (d, b) {
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
- if (k2 === undefined) k2 = k;
29
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
30
- }) : (function(o, m, k, k2) {
31
- if (k2 === undefined) k2 = k;
32
- o[k2] = m[k];
33
- }));
34
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
- Object.defineProperty(o, "default", { enumerable: true, value: v });
36
- }) : function(o, v) {
37
- o["default"] = v;
38
- });
39
- var __importStar = (this && this.__importStar) || function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
47
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
- return new (P || (P = Promise))(function (resolve, reject) {
49
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
50
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
51
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
52
- step((generator = generator.apply(thisArg, _arguments || [])).next());
53
- });
54
- };
55
- var __generator = (this && this.__generator) || function (thisArg, body) {
56
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
57
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
- function verb(n) { return function (v) { return step([n, v]); }; }
59
- function step(op) {
60
- if (f) throw new TypeError("Generator is already executing.");
61
- while (_) try {
62
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
- if (y = 0, t) op = [op[0] & 2, t.value];
64
- switch (op[0]) {
65
- case 0: case 1: t = op; break;
66
- case 4: _.label++; return { value: op[1], done: false };
67
- case 5: _.label++; y = op[1]; op = [0]; continue;
68
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
- default:
70
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
- if (t[2]) _.ops.pop();
75
- _.trys.pop(); continue;
76
- }
77
- op = body.call(thisArg, _);
78
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
80
- }
81
- };
82
- Object.defineProperty(exports, "__esModule", { value: true });
83
- exports.FlowExtension = void 0;
84
- var magic_sdk_1 = require("magic-sdk");
85
- // @ts-ignore
86
- var fcl = __importStar(require("@onflow/fcl"));
87
- var FlowExtension = /** @class */ (function (_super) {
88
- __extends(FlowExtension, _super);
89
- function FlowExtension(flowConfig) {
90
- var _this = _super.call(this) || this;
91
- _this.flowConfig = flowConfig;
92
- _this.name = 'flow';
93
- _this.config = {};
94
- _this.authorization = function (account) {
95
- if (account === void 0) { account = {}; }
96
- return __awaiter(_this, void 0, void 0, function () {
97
- var addr, keyId, sequenceNum, response, acct, signingFunction;
98
- var _this = this;
99
- return __generator(this, function (_a) {
100
- switch (_a.label) {
101
- case 0:
102
- fcl.config().put('accessNode.api', this.config.rpcUrl);
103
- return [4 /*yield*/, this.request({
104
- id: 42,
105
- jsonrpc: '2.0',
106
- method: 'flow_getAccount',
107
- params: {},
108
- })];
109
- case 1:
110
- addr = _a.sent();
111
- keyId = 0;
112
- if (!account.role.proposer) return [3 /*break*/, 4];
113
- return [4 /*yield*/, fcl.send([fcl.getAccount(addr)])];
114
- case 2:
115
- response = _a.sent();
116
- return [4 /*yield*/, fcl.decode(response)];
117
- case 3:
118
- acct = _a.sent();
119
- sequenceNum = acct.keys[keyId].sequenceNumber;
120
- _a.label = 4;
121
- case 4:
122
- signingFunction = function (data) { return __awaiter(_this, void 0, void 0, function () {
123
- var signature;
124
- return __generator(this, function (_a) {
125
- switch (_a.label) {
126
- case 0: return [4 /*yield*/, this.request({
127
- id: 42,
128
- jsonrpc: '2.0',
129
- method: 'flow_signTransaction',
130
- params: {
131
- message: data.message,
132
- },
133
- })];
134
- case 1:
135
- signature = _a.sent();
136
- return [2 /*return*/, {
137
- addr: addr,
138
- keyId: keyId,
139
- signature: signature,
140
- }];
141
- }
142
- });
143
- }); };
144
- return [2 /*return*/, __assign(__assign({}, account), { addr: addr,
145
- keyId: keyId,
146
- signingFunction: signingFunction,
147
- sequenceNum: sequenceNum })];
148
- }
149
- });
150
- });
151
- };
152
- _this.config = {
153
- rpcUrl: flowConfig.rpcUrl,
154
- chainType: 'FLOW',
155
- };
156
- return _this;
157
- }
158
- return FlowExtension;
159
- }(magic_sdk_1.Extension.Internal));
160
- exports.FlowExtension = FlowExtension;
161
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,uCAAsC;AACtC,aAAa;AACb,+CAAmC;AAGnC;IAAmC,iCAA+B;IAIhE,uBAAmB,UAAsB;QAAzC,YACE,iBAAO,SAMR;QAPkB,gBAAU,GAAV,UAAU,CAAY;QAHzC,UAAI,GAAG,MAAe,CAAC;QACvB,YAAM,GAAQ,EAAE,CAAC;QAWjB,mBAAa,GAAG,UAAO,OAAiB;YAAjB,wBAAA,EAAA,YAAiB;;;;;;;4BACtC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;4BAC1C,qBAAM,IAAI,CAAC,OAAO,CAAC;oCAC9B,EAAE,EAAE,EAAE;oCACN,OAAO,EAAE,KAAK;oCACd,MAAM,EAAE,iBAAiB;oCACzB,MAAM,EAAE,EAAE;iCACX,CAAC,EAAA;;4BALI,IAAI,GAAG,SAKX;4BACI,KAAK,GAAG,CAAC,CAAC;iCAEZ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAArB,wBAAqB;4BACN,qBAAM,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAA;;4BAAjD,QAAQ,GAAG,SAAsC;4BAC1C,qBAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAA;;4BAAjC,IAAI,GAAG,SAA0B;4BACvC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;;;4BAG1C,eAAe,GAAG,UAAO,IAAS;;;;gDACpB,qBAAM,IAAI,CAAC,OAAO,CAAC;gDACnC,EAAE,EAAE,EAAE;gDACN,OAAO,EAAE,KAAK;gDACd,MAAM,EAAE,sBAAsB;gDAC9B,MAAM,EAAE;oDACN,OAAO,EAAE,IAAI,CAAC,OAAO;iDACtB;6CACF,CAAC,EAAA;;4CAPI,SAAS,GAAG,SAOhB;4CAEF,sBAAO;oDACL,IAAI,MAAA;oDACJ,KAAK,OAAA;oDACL,SAAS,WAAA;iDACV,EAAC;;;iCACH,CAAC;4BAEF,4CACK,OAAO,KACV,IAAI,MAAA;oCACJ,KAAK,OAAA;oCACL,eAAe,iBAAA;oCACf,WAAW,aAAA,KACX;;;;SACH,CAAC;QA9CA,KAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,SAAS,EAAE,MAAM;SAClB,CAAC;;IACJ,CAAC;IA2CH,oBAAC;AAAD,CAAC,AAtDD,CAAmC,qBAAS,CAAC,QAAQ,GAsDpD;AAtDY,sCAAa"}
@@ -1,7 +0,0 @@
1
- export interface FlowConfig {
2
- rpcUrl: string;
3
- }
4
- export interface ConfigType {
5
- rpcUrl: string;
6
- chainType: string;
7
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/type.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { FlowExtension } from './index';
2
- export { FlowExtension as default };
@@ -1,3 +0,0 @@
1
- import { FlowExtension } from './index';
2
- export { FlowExtension as default };
3
- //# sourceMappingURL=index.cdn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cdn.js","sourceRoot":"","sources":["../../../src/index.cdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,CAAC"}
@@ -1,139 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-ignore */
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
- return new (P || (P = Promise))(function (resolve, reject) {
29
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
- step((generator = generator.apply(thisArg, _arguments || [])).next());
33
- });
34
- };
35
- var __generator = (this && this.__generator) || function (thisArg, body) {
36
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
- function verb(n) { return function (v) { return step([n, v]); }; }
39
- function step(op) {
40
- if (f) throw new TypeError("Generator is already executing.");
41
- while (_) try {
42
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
- if (y = 0, t) op = [op[0] & 2, t.value];
44
- switch (op[0]) {
45
- case 0: case 1: t = op; break;
46
- case 4: _.label++; return { value: op[1], done: false };
47
- case 5: _.label++; y = op[1]; op = [0]; continue;
48
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
- default:
50
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
- if (t[2]) _.ops.pop();
55
- _.trys.pop(); continue;
56
- }
57
- op = body.call(thisArg, _);
58
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
- }
61
- };
62
- import { Extension } from 'magic-sdk';
63
- // @ts-ignore
64
- import * as fcl from '@onflow/fcl';
65
- var FlowExtension = /** @class */ (function (_super) {
66
- __extends(FlowExtension, _super);
67
- function FlowExtension(flowConfig) {
68
- var _this = _super.call(this) || this;
69
- _this.flowConfig = flowConfig;
70
- _this.name = 'flow';
71
- _this.config = {};
72
- _this.authorization = function (account) {
73
- if (account === void 0) { account = {}; }
74
- return __awaiter(_this, void 0, void 0, function () {
75
- var addr, keyId, sequenceNum, response, acct, signingFunction;
76
- var _this = this;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0:
80
- fcl.config().put('accessNode.api', this.config.rpcUrl);
81
- return [4 /*yield*/, this.request({
82
- id: 42,
83
- jsonrpc: '2.0',
84
- method: 'flow_getAccount',
85
- params: {},
86
- })];
87
- case 1:
88
- addr = _a.sent();
89
- keyId = 0;
90
- if (!account.role.proposer) return [3 /*break*/, 4];
91
- return [4 /*yield*/, fcl.send([fcl.getAccount(addr)])];
92
- case 2:
93
- response = _a.sent();
94
- return [4 /*yield*/, fcl.decode(response)];
95
- case 3:
96
- acct = _a.sent();
97
- sequenceNum = acct.keys[keyId].sequenceNumber;
98
- _a.label = 4;
99
- case 4:
100
- signingFunction = function (data) { return __awaiter(_this, void 0, void 0, function () {
101
- var signature;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0: return [4 /*yield*/, this.request({
105
- id: 42,
106
- jsonrpc: '2.0',
107
- method: 'flow_signTransaction',
108
- params: {
109
- message: data.message,
110
- },
111
- })];
112
- case 1:
113
- signature = _a.sent();
114
- return [2 /*return*/, {
115
- addr: addr,
116
- keyId: keyId,
117
- signature: signature,
118
- }];
119
- }
120
- });
121
- }); };
122
- return [2 /*return*/, __assign(__assign({}, account), { addr: addr,
123
- keyId: keyId,
124
- signingFunction: signingFunction,
125
- sequenceNum: sequenceNum })];
126
- }
127
- });
128
- });
129
- };
130
- _this.config = {
131
- rpcUrl: flowConfig.rpcUrl,
132
- chainType: 'FLOW',
133
- };
134
- return _this;
135
- }
136
- return FlowExtension;
137
- }(Extension.Internal));
138
- export { FlowExtension };
139
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,aAAa;AACb,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAGnC;IAAmC,iCAA+B;IAIhE,uBAAmB,UAAsB;QAAzC,YACE,iBAAO,SAMR;QAPkB,gBAAU,GAAV,UAAU,CAAY;QAHzC,UAAI,GAAG,MAAe,CAAC;QACvB,YAAM,GAAQ,EAAE,CAAC;QAWjB,mBAAa,GAAG,UAAO,OAAiB;YAAjB,wBAAA,EAAA,YAAiB;;;;;;;4BACtC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;4BAC1C,qBAAM,IAAI,CAAC,OAAO,CAAC;oCAC9B,EAAE,EAAE,EAAE;oCACN,OAAO,EAAE,KAAK;oCACd,MAAM,EAAE,iBAAiB;oCACzB,MAAM,EAAE,EAAE;iCACX,CAAC,EAAA;;4BALI,IAAI,GAAG,SAKX;4BACI,KAAK,GAAG,CAAC,CAAC;iCAEZ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAArB,wBAAqB;4BACN,qBAAM,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAA;;4BAAjD,QAAQ,GAAG,SAAsC;4BAC1C,qBAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAA;;4BAAjC,IAAI,GAAG,SAA0B;4BACvC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;;;4BAG1C,eAAe,GAAG,UAAO,IAAS;;;;gDACpB,qBAAM,IAAI,CAAC,OAAO,CAAC;gDACnC,EAAE,EAAE,EAAE;gDACN,OAAO,EAAE,KAAK;gDACd,MAAM,EAAE,sBAAsB;gDAC9B,MAAM,EAAE;oDACN,OAAO,EAAE,IAAI,CAAC,OAAO;iDACtB;6CACF,CAAC,EAAA;;4CAPI,SAAS,GAAG,SAOhB;4CAEF,sBAAO;oDACL,IAAI,MAAA;oDACJ,KAAK,OAAA;oDACL,SAAS,WAAA;iDACV,EAAC;;;iCACH,CAAC;4BAEF,4CACK,OAAO,KACV,IAAI,MAAA;oCACJ,KAAK,OAAA;oCACL,eAAe,iBAAA;oCACf,WAAW,aAAA,KACX;;;;SACH,CAAC;QA9CA,KAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,SAAS,EAAE,MAAM;SAClB,CAAC;;IACJ,CAAC;IA2CH,oBAAC;AAAD,CAAC,AAtDD,CAAmC,SAAS,CAAC,QAAQ,GAsDpD"}
@@ -1,7 +0,0 @@
1
- export interface FlowConfig {
2
- rpcUrl: string;
3
- }
4
- export interface ConfigType {
5
- rpcUrl: string;
6
- chainType: string;
7
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/type.ts"],"names":[],"mappings":""}