@getpara/graz-connector 0.1.0-alpha.3 → 0.1.0-alpha.5

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.
@@ -1,18 +1,27 @@
1
+ import ParaWeb from '@getpara/react-sdk';
1
2
  import type { Environment, ParaModalProps } from '@getpara/react-sdk';
2
- import type { Key as GrazKey } from 'graz';
3
+ import type { Wallet, Key as GrazKey } from 'graz';
3
4
  import type { OfflineAminoSigner, OfflineDirectSigner, AminoSignResponse, StdSignDoc, StdSignature } from '@keplr-wallet/types';
5
+ export type ParaGrazModalProps = Omit<ParaModalProps, 'para'>;
4
6
  export interface ParaGrazConfig {
5
7
  apiKey: string;
6
8
  env: Environment;
7
- modalProps?: ParaModalProps;
9
+ modalProps?: ParaGrazModalProps;
8
10
  }
9
- export declare class ParaGrazInternalProvider {
11
+ export declare class ParaGrazInternalProvider implements Omit<Wallet, 'experimentalSuggestChain'> {
10
12
  private paraWebClient;
11
13
  private config;
14
+ private isModalClosed;
12
15
  constructor(config: ParaGrazConfig);
16
+ closeModal: () => void;
17
+ private waitForLogin;
18
+ private waitForAccounts;
19
+ enable(chainIds: string | string[]): Promise<void>;
20
+ getParaWebClient(): ParaWeb;
21
+ getConfig(): ParaGrazConfig;
13
22
  getKey(chainId: string): Promise<GrazKey>;
14
- getOfflineSigner(chainId: string): Promise<OfflineAminoSigner & OfflineDirectSigner>;
15
- getOfflineSignerOnlyAmino(chainId: string): Promise<OfflineAminoSigner>;
23
+ getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
24
+ getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
16
25
  getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
17
26
  signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: any): Promise<AminoSignResponse>;
18
27
  signDirect(chainId: string, signer: string, signDoc: any, signOptions?: any): Promise<{
@@ -1,16 +1,77 @@
1
+ "use client";
1
2
  import {
2
3
  __async
3
- } from "./chunk-4AFQP74Z.js";
4
+ } from "./chunk-IV3L3JVM.js";
4
5
  import ParaWeb from "@getpara/react-sdk";
5
6
  import { ParaProtoSigner } from "@getpara/cosmjs-v0-integration";
6
7
  import { fromBech32 } from "@cosmjs/encoding";
8
+ import { renderModal } from "./connectorModal.js";
9
+ const TEN_MINUTES_MS = 6e5;
7
10
  class ParaGrazInternalProvider {
8
11
  constructor(config) {
12
+ this.closeModal = () => {
13
+ this.isModalClosed = true;
14
+ };
9
15
  if (!config || !config.apiKey || !config.env) {
10
16
  throw new Error("Para Connector: Missing API Key or Environment in config.");
11
17
  }
12
18
  this.config = config;
13
19
  this.paraWebClient = new ParaWeb(config.env, config.apiKey);
20
+ this.isModalClosed = true;
21
+ }
22
+ waitForLogin() {
23
+ return __async(this, arguments, function* (timeoutMs = TEN_MINUTES_MS) {
24
+ const startTime = Date.now();
25
+ while (Date.now() - startTime < timeoutMs) {
26
+ if (yield this.paraWebClient.isFullyLoggedIn()) {
27
+ return true;
28
+ }
29
+ if (this.isModalClosed) {
30
+ throw new Error("user closed modal");
31
+ }
32
+ yield new Promise((resolve) => setTimeout(resolve, 2e3));
33
+ }
34
+ throw new Error("timed out waiting for user to log in");
35
+ });
36
+ }
37
+ waitForAccounts(chainIds, timeoutMs = 5e3) {
38
+ return __async(this, null, function* () {
39
+ const startTime = Date.now();
40
+ while (Date.now() - startTime < timeoutMs) {
41
+ const wallets = Object.values(this.paraWebClient.getWalletsByType("COSMOS"));
42
+ if (wallets && wallets.length > 0) {
43
+ return true;
44
+ }
45
+ yield new Promise((resolve) => setTimeout(resolve, 500));
46
+ }
47
+ throw new Error("timed out waiting for accounts to load");
48
+ });
49
+ }
50
+ enable(chainIds) {
51
+ return __async(this, null, function* () {
52
+ if (yield this.paraWebClient.isFullyLoggedIn()) {
53
+ const wallets = Object.values(this.paraWebClient.getWalletsByType("COSMOS"));
54
+ if (wallets && wallets.length > 0) {
55
+ return;
56
+ }
57
+ }
58
+ this.isModalClosed = false;
59
+ renderModal(this.paraWebClient, this.config.modalProps, () => {
60
+ this.isModalClosed = true;
61
+ });
62
+ yield this.waitForLogin();
63
+ try {
64
+ yield this.waitForAccounts(chainIds);
65
+ } catch (error) {
66
+ throw new Error("accounts not available after login");
67
+ }
68
+ });
69
+ }
70
+ getParaWebClient() {
71
+ return this.paraWebClient;
72
+ }
73
+ getConfig() {
74
+ return this.config;
14
75
  }
15
76
  getKey(chainId) {
16
77
  return __async(this, null, function* () {
@@ -44,7 +105,7 @@ class ParaGrazInternalProvider {
44
105
  }
45
106
  getOfflineSignerAuto(chainId) {
46
107
  console.warn(`Para Connector: getOfflineSignerAuto called for ${chainId} - Needs Implementation`);
47
- return this.getOfflineSignerOnlyAmino(chainId);
108
+ throw new Error("getOfflineSignerAuto not implemented");
48
109
  }
49
110
  signAmino(chainId, signer, signDoc, signOptions) {
50
111
  return __async(this, null, function* () {
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = (value) => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+
42
+ export {
43
+ __spreadValues,
44
+ __spreadProps,
45
+ __async
46
+ };
@@ -0,0 +1,2 @@
1
+ import ParaWeb, { ParaModalProps } from '@getpara/react-sdk';
2
+ export declare function renderModal(para: ParaWeb, modalProps: Partial<ParaModalProps>, onCloseArg: () => void): void;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __spreadProps,
5
+ __spreadValues
6
+ } from "./chunk-IV3L3JVM.js";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { ParaModal } from "@getpara/react-sdk";
9
+ function renderModal(para, modalProps, onCloseArg) {
10
+ const existingContainer = document.getElementById("para-modal");
11
+ const container = existingContainer != null ? existingContainer : document.createElement("div");
12
+ container.id = "para-modal";
13
+ if (!existingContainer) {
14
+ document.body.appendChild(container);
15
+ }
16
+ const onClose = () => {
17
+ onCloseArg();
18
+ modalProps.onClose && modalProps.onClose();
19
+ render(false);
20
+ };
21
+ const render = (isOpen) => __async(this, null, function* () {
22
+ const Modal = /* @__PURE__ */ jsx(ParaModal, __spreadProps(__spreadValues({}, modalProps), { onClose, para, isOpen }));
23
+ try {
24
+ const client = yield import("react-dom/client");
25
+ const root = client.createRoot(container);
26
+ root.render(Modal);
27
+ } catch (e) {
28
+ const ReactDOM = yield import("react-dom");
29
+ ReactDOM.render(Modal, container);
30
+ }
31
+ });
32
+ render(true);
33
+ }
34
+ export {
35
+ renderModal
36
+ };
@@ -1,4 +1,3 @@
1
1
  export { WalletType, AuthLayout, AuthMethod, OAuthMethod, Environment } from '@getpara/react-sdk';
2
- export type { ParaWeb, ParaModal, ParaModalProps, ParaModalTheme, Wallet } from '@getpara/react-sdk';
3
2
  export { ParaGrazInternalProvider } from './ParaGrazProvider.js';
4
- export type { ParaGrazConfig } from './ParaGrazProvider.js';
3
+ export type { ParaGrazConfig, ParaGrazModalProps } from './ParaGrazProvider.js';
@@ -1,4 +1,5 @@
1
- import "./chunk-4AFQP74Z.js";
1
+ "use client";
2
+ import "./chunk-IV3L3JVM.js";
2
3
  import { WalletType, AuthLayout, AuthMethod, OAuthMethod, Environment } from "@getpara/react-sdk";
3
4
  import { ParaGrazInternalProvider } from "./ParaGrazProvider.js";
4
5
  export {
package/package.json CHANGED
@@ -1,21 +1,17 @@
1
1
  {
2
2
  "name": "@getpara/graz-connector",
3
- "version": "0.1.0-alpha.3",
4
- "main": "dist/cjs/index.js",
5
- "module": "dist/esm/index.js",
6
- "types": "dist/types/index.d.ts",
7
- "typings": "dist/types/index.d.ts",
3
+ "version": "0.1.0-alpha.5",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
8
7
  "sideEffects": false,
9
8
  "dependencies": {
10
9
  "@getpara/react-sdk": "1.11.0",
11
10
  "@getpara/cosmjs-v0-integration": "1.11.0"
12
11
  },
13
12
  "scripts": {
14
- "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
15
- "old-build": "yarn build:cjs && yarn build:esm && yarn build:types",
16
- "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
17
- "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
18
- "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration"
13
+ "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
14
+ "typegen": "tsc --emitDeclarationOnly"
19
15
  },
20
16
  "devDependencies": {
21
17
  "@cosmjs/amino": "^0.32.3",
package/scripts/build.mjs CHANGED
@@ -1,51 +1,36 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import * as fs from 'fs/promises';
3
- import * as path from 'path';
4
3
  import { fileURLToPath } from 'url';
5
- import { dirname } from 'path';
4
+ import { dirname, resolve } from 'path';
6
5
  import { glob } from 'glob';
7
6
 
8
7
  const entryPoints = await glob('src/**/*.{ts,tsx,js,jsx}');
9
8
 
10
9
  const __dirname = dirname(fileURLToPath(import.meta.url));
11
- const distDir = path.resolve(__dirname, '../dist');
10
+ const distDir = resolve(__dirname, '../dist');
12
11
 
13
- await fs.mkdir(`${distDir}/cjs`, { recursive: true });
14
- await fs.writeFile(`${distDir}/cjs/package.json`, JSON.stringify({ type: 'commonjs' }, null, 2));
15
-
16
- await fs.mkdir(`${distDir}/esm`, { recursive: true });
17
- await fs.writeFile(`${distDir}/esm/package.json`, JSON.stringify({ type: 'module', sideEffects: false }, null, 2));
12
+ await fs.mkdir(distDir, { recursive: true });
13
+ await fs.writeFile(`${distDir}/package.json`, JSON.stringify({ type: 'module', sideEffects: false }, null, 2));
18
14
 
19
15
  /** @type {import('esbuild').BuildOptions} */
20
16
  await esbuild.build({
17
+ banner: {
18
+ js: '"use client";', // Required for Next 13 App Router
19
+ },
21
20
  bundle: false,
22
21
  write: true,
23
22
  format: 'esm',
24
23
  loader: {
24
+ '.png': 'dataurl',
25
+ '.svg': 'dataurl',
25
26
  '.json': 'text',
26
27
  },
27
28
  platform: 'browser',
28
29
  entryPoints,
29
- outdir: 'dist/esm',
30
+ outdir: distDir,
30
31
  allowOverwrite: true,
31
32
  splitting: true, // Required for tree shaking
32
33
  minify: false,
33
34
  target: ['es2015'],
34
35
  packages: 'external',
35
36
  });
36
-
37
- await esbuild.build({
38
- bundle: false,
39
- write: true,
40
- format: 'cjs',
41
- loader: {
42
- '.json': 'text',
43
- },
44
- platform: 'node',
45
- entryPoints,
46
- outdir: 'dist/cjs',
47
- allowOverwrite: true,
48
- minify: false,
49
- target: ['es2015'],
50
- packages: 'external',
51
- });
@@ -10,16 +10,22 @@ import type {
10
10
  } from '@keplr-wallet/types';
11
11
  import { ParaAminoSigner, ParaProtoSigner } from '@getpara/cosmjs-v0-integration';
12
12
  import { fromBech32 } from '@cosmjs/encoding';
13
+ import { renderModal } from './connectorModal.js';
14
+
15
+ const TEN_MINUTES_MS = 600000;
16
+
17
+ export type ParaGrazModalProps = Omit<ParaModalProps, 'para'>;
13
18
 
14
19
  export interface ParaGrazConfig {
15
20
  apiKey: string;
16
21
  env: Environment;
17
- modalProps?: ParaModalProps;
22
+ modalProps?: ParaGrazModalProps;
18
23
  }
19
24
 
20
- export class ParaGrazInternalProvider /* implements NeededWalletMethods */ {
25
+ export class ParaGrazInternalProvider implements Omit<Wallet, 'experimentalSuggestChain'> {
21
26
  private paraWebClient: ParaWeb;
22
27
  private config: ParaGrazConfig;
28
+ private isModalClosed: boolean;
23
29
 
24
30
  constructor(config: ParaGrazConfig) {
25
31
  if (!config || !config.apiKey || !config.env) {
@@ -27,6 +33,71 @@ export class ParaGrazInternalProvider /* implements NeededWalletMethods */ {
27
33
  }
28
34
  this.config = config;
29
35
  this.paraWebClient = new ParaWeb(config.env, config.apiKey);
36
+ this.isModalClosed = true;
37
+ }
38
+
39
+ closeModal = () => {
40
+ this.isModalClosed = true;
41
+ };
42
+
43
+ private async waitForLogin(timeoutMs = TEN_MINUTES_MS): Promise<boolean> {
44
+ const startTime = Date.now();
45
+ while (Date.now() - startTime < timeoutMs) {
46
+ if (await this.paraWebClient.isFullyLoggedIn()) {
47
+ return true;
48
+ }
49
+
50
+ if (this.isModalClosed) {
51
+ throw new Error('user closed modal');
52
+ }
53
+
54
+ await new Promise(resolve => setTimeout(resolve, 2000));
55
+ }
56
+
57
+ throw new Error('timed out waiting for user to log in');
58
+ }
59
+
60
+ private async waitForAccounts(chainIds: string | string[], timeoutMs = 5000): Promise<boolean> {
61
+ const startTime = Date.now();
62
+ while (Date.now() - startTime < timeoutMs) {
63
+ const wallets = Object.values(this.paraWebClient.getWalletsByType('COSMOS'));
64
+ if (wallets && wallets.length > 0) {
65
+ return true;
66
+ }
67
+ await new Promise(resolve => setTimeout(resolve, 500));
68
+ }
69
+
70
+ throw new Error('timed out waiting for accounts to load');
71
+ }
72
+
73
+ async enable(chainIds: string | string[]): Promise<void> {
74
+ if (await this.paraWebClient.isFullyLoggedIn()) {
75
+ const wallets = Object.values(this.paraWebClient.getWalletsByType('COSMOS'));
76
+ if (wallets && wallets.length > 0) {
77
+ return;
78
+ }
79
+ }
80
+
81
+ this.isModalClosed = false;
82
+ renderModal(this.paraWebClient, this.config.modalProps, () => {
83
+ this.isModalClosed = true;
84
+ });
85
+
86
+ await this.waitForLogin();
87
+
88
+ try {
89
+ await this.waitForAccounts(chainIds);
90
+ } catch (error) {
91
+ throw new Error('accounts not available after login');
92
+ }
93
+ }
94
+
95
+ getParaWebClient(): ParaWeb {
96
+ return this.paraWebClient;
97
+ }
98
+
99
+ getConfig(): ParaGrazConfig {
100
+ return this.config;
30
101
  }
31
102
 
32
103
  async getKey(chainId: string): Promise<GrazKey> {
@@ -53,19 +124,19 @@ export class ParaGrazInternalProvider /* implements NeededWalletMethods */ {
53
124
  };
54
125
  }
55
126
 
56
- getOfflineSigner(chainId: string): Promise<OfflineAminoSigner & OfflineDirectSigner> {
127
+ getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner {
57
128
  console.warn(`Para Connector: getOfflineSigner called for ${chainId} - Needs Implementation`);
58
129
  throw new Error('getOfflineSigner not implemented');
59
130
  }
60
131
 
61
- getOfflineSignerOnlyAmino(chainId: string): Promise<OfflineAminoSigner> {
132
+ getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner {
62
133
  console.warn(`Para Connector: getOfflineSignerOnlyAmino called for ${chainId} - Needs Implementation`);
63
134
  throw new Error('getOfflineSignerOnlyAmino not implemented');
64
135
  }
65
136
 
66
137
  getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner> {
67
138
  console.warn(`Para Connector: getOfflineSignerAuto called for ${chainId} - Needs Implementation`);
68
- return this.getOfflineSignerOnlyAmino(chainId);
139
+ throw new Error('getOfflineSignerAuto not implemented');
69
140
  }
70
141
 
71
142
  async signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: any): Promise<AminoSignResponse> {
@@ -0,0 +1,32 @@
1
+ import ParaWeb, { ParaModal, ParaModalProps } from '@getpara/react-sdk';
2
+
3
+ export function renderModal(para: ParaWeb, modalProps: Partial<ParaModalProps>, onCloseArg: () => void): void {
4
+ const existingContainer = document.getElementById('para-modal');
5
+ const container = existingContainer ?? document.createElement('div');
6
+ container.id = 'para-modal';
7
+
8
+ if (!existingContainer) {
9
+ document.body.appendChild(container);
10
+ }
11
+
12
+ const onClose = () => {
13
+ onCloseArg();
14
+ modalProps.onClose && modalProps.onClose();
15
+ render(false);
16
+ };
17
+
18
+ const render = async (isOpen: boolean) => {
19
+ const Modal = <ParaModal {...modalProps} onClose={onClose} para={para} isOpen={isOpen} />;
20
+
21
+ try {
22
+ const client = await import('react-dom/client');
23
+ const root = client.createRoot(container);
24
+ root.render(Modal);
25
+ } catch (e) {
26
+ const ReactDOM = await import('react-dom');
27
+ ReactDOM.render(Modal, container);
28
+ }
29
+ };
30
+
31
+ render(true);
32
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { WalletType, AuthLayout, AuthMethod, OAuthMethod, Environment } from '@getpara/react-sdk';
2
- export type { ParaWeb, ParaModal, ParaModalProps, ParaModalTheme, Wallet } from '@getpara/react-sdk';
3
2
  export { ParaGrazInternalProvider } from './ParaGrazProvider.js';
4
- export type { ParaGrazConfig } from './ParaGrazProvider.js';
3
+ export type { ParaGrazConfig, ParaGrazModalProps } from './ParaGrazProvider.js';
package/tsconfig.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "declaration": false,
5
- "outDir": "./dist"
4
+ "outDir": "./dist",
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "jsx": "react-jsx",
7
+ "module": "ESNext",
8
+ "declaration": true,
9
+ "declarationDir": "dist"
6
10
  },
7
- "include": ["**/*.ts"],
11
+ "include": ["**/*.ts", "**/*.tsx"],
8
12
  "exclude": ["node_modules", "dist"]
9
13
  }
@@ -1,125 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
- var ParaGrazProvider_exports = {};
49
- __export(ParaGrazProvider_exports, {
50
- ParaGrazInternalProvider: () => ParaGrazInternalProvider
51
- });
52
- module.exports = __toCommonJS(ParaGrazProvider_exports);
53
- var import_react_sdk = __toESM(require("@getpara/react-sdk"));
54
- var import_cosmjs_v0_integration = require("@getpara/cosmjs-v0-integration");
55
- var import_encoding = require("@cosmjs/encoding");
56
- class ParaGrazInternalProvider {
57
- constructor(config) {
58
- if (!config || !config.apiKey || !config.env) {
59
- throw new Error("Para Connector: Missing API Key or Environment in config.");
60
- }
61
- this.config = config;
62
- this.paraWebClient = new import_react_sdk.default(config.env, config.apiKey);
63
- }
64
- getKey(chainId) {
65
- return __async(this, null, function* () {
66
- const wallets = Object.values(this.paraWebClient.getWalletsByType("COSMOS"));
67
- if (wallets.length === 0) {
68
- throw new Error(`Para Connector: No wallets found for chainId ${chainId}`);
69
- }
70
- const walletSigner = new import_cosmjs_v0_integration.ParaProtoSigner(this.paraWebClient, wallets[0].id);
71
- const accountData = yield walletSigner.getAccounts();
72
- if (accountData.length === 0) {
73
- throw new Error(`Para Connector: No accounts found for wallet ${wallets[0].id}`);
74
- }
75
- return {
76
- address: (0, import_encoding.fromBech32)(accountData[0].address).data,
77
- bech32Address: accountData[0].address,
78
- algo: accountData[0].algo,
79
- name: accountData[0].address,
80
- pubKey: accountData[0].pubkey,
81
- isKeystone: false,
82
- isNanoLedger: false
83
- };
84
- });
85
- }
86
- getOfflineSigner(chainId) {
87
- console.warn(`Para Connector: getOfflineSigner called for ${chainId} - Needs Implementation`);
88
- throw new Error("getOfflineSigner not implemented");
89
- }
90
- getOfflineSignerOnlyAmino(chainId) {
91
- console.warn(`Para Connector: getOfflineSignerOnlyAmino called for ${chainId} - Needs Implementation`);
92
- throw new Error("getOfflineSignerOnlyAmino not implemented");
93
- }
94
- getOfflineSignerAuto(chainId) {
95
- console.warn(`Para Connector: getOfflineSignerAuto called for ${chainId} - Needs Implementation`);
96
- return this.getOfflineSignerOnlyAmino(chainId);
97
- }
98
- signAmino(chainId, signer, signDoc, signOptions) {
99
- return __async(this, null, function* () {
100
- console.warn(`Para Connector: signAmino called for ${chainId} - Needs Implementation`);
101
- throw new Error("signAmino not implemented");
102
- });
103
- }
104
- signDirect(chainId, signer, signDoc, signOptions) {
105
- return __async(this, null, function* () {
106
- console.warn(`Para Connector: signDirect called for ${chainId} - Needs Implementation`);
107
- throw new Error("signDirect not implemented");
108
- });
109
- }
110
- signArbitrary(chainId, signer, data) {
111
- return __async(this, null, function* () {
112
- console.warn(`Para Connector: signArbitrary called for ${chainId} - Needs Implementation`);
113
- throw new Error("signArbitrary not implemented");
114
- });
115
- }
116
- disconnect() {
117
- return __async(this, null, function* () {
118
- yield this.paraWebClient.logout();
119
- });
120
- }
121
- }
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- ParaGrazInternalProvider
125
- });
package/dist/cjs/index.js DELETED
@@ -1,38 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var src_exports = {};
19
- __export(src_exports, {
20
- AuthLayout: () => import_react_sdk.AuthLayout,
21
- AuthMethod: () => import_react_sdk.AuthMethod,
22
- Environment: () => import_react_sdk.Environment,
23
- OAuthMethod: () => import_react_sdk.OAuthMethod,
24
- ParaGrazInternalProvider: () => import_ParaGrazProvider.ParaGrazInternalProvider,
25
- WalletType: () => import_react_sdk.WalletType
26
- });
27
- module.exports = __toCommonJS(src_exports);
28
- var import_react_sdk = require("@getpara/react-sdk");
29
- var import_ParaGrazProvider = require("./ParaGrazProvider.js");
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- AuthLayout,
33
- AuthMethod,
34
- Environment,
35
- OAuthMethod,
36
- ParaGrazInternalProvider,
37
- WalletType
38
- });
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,24 +0,0 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
-
22
- export {
23
- __async
24
- };
File without changes