Skip to content

Commit

Permalink
Feature: Make logging manageable (#146)
Browse files Browse the repository at this point in the history
* add debug flag

* use active flag in useEffect

* remove unused file in react sdk, fix sdk reinit, update build

* add .eslintignore
  • Loading branch information
mmv08 authored May 17, 2021
1 parent 8be1ba5 commit 44bb31c
Show file tree
Hide file tree
Showing 26 changed files with 152 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
build

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions packages/safe-apps-onboard/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions packages/safe-apps-onboard/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Initialization, API } from 'bnc-onboard/dist/src/interfaces';
export declare const Onboard: (options: Initialization) => API;
export default Onboard;
10 changes: 10 additions & 0 deletions packages/safe-apps-onboard/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/safe-apps-onboard/dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions packages/safe-apps-onboard/dist/wrapper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { SafeInfo } from '@gnosis.pm/safe-apps-sdk';
import { Initialization, API, ConfigOptions, UserState } from 'bnc-onboard/dist/src/interfaces';
export declare class OnboardWrapper implements API {
private sdk;
private onboardApi;
private subscriptions?;
private safe;
private state;
constructor(options: Initialization);
connectedSafe(timeout?: number): Promise<SafeInfo | undefined>;
checkSafeApp(): Promise<void>;
reset(): void;
walletSelect(autoSelectWallet?: string): Promise<boolean>;
walletCheck(): Promise<boolean>;
walletReset(): void;
accountSelect(): Promise<boolean>;
config(options: ConfigOptions): void;
getState(): UserState;
}
91 changes: 91 additions & 0 deletions packages/safe-apps-onboard/dist/wrapper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/safe-apps-onboard/dist/wrapper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/safe-apps-react-sdk/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/safe-apps-react-sdk/dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions packages/safe-apps-react-sdk/dist/sdk.d.ts

This file was deleted.

10 changes: 0 additions & 10 deletions packages/safe-apps-react-sdk/dist/sdk.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/safe-apps-react-sdk/dist/sdk.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion packages/safe-apps-react-sdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Props {
}

export const SafeProvider: React.FC<Props> = ({ loader = null, opts, children }) => {
const [sdk] = useState(new SafeAppsSDK(opts));
const [sdk] = useState(() => new SafeAppsSDK(opts));
const [connected, setConnected] = useState(false);
const [safe, setSafe] = useState<SafeInfo>({ safeAddress: '', network: 'RINKEBY' });
const contextValue = useMemo(() => ({ sdk, connected, safe }), [sdk, connected, safe]);
Expand Down
5 changes: 0 additions & 5 deletions packages/safe-apps-react-sdk/src/sdk.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ And for Linux:
Apps built with the Safe Apps SDK are meant to be run in an iframe inside the Safe Web UI.
This library exposes a class as a default export. It accepts an optional options object:
`whitelistedDomains` - Array of regular expressions for origins you want to accept messages from. If not passed, accepts
messages from any origin (default).
`debug` - Boolean. If enabled, it will log outgoing/incoming messages.

```js
import SafeAppsSDK from '@gnosis.pm/safe-apps-sdk';
Expand Down
3 changes: 2 additions & 1 deletion packages/safe-apps-sdk/dist/src/communication/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Communicator, Response } from '../types';
declare class PostMessageCommunicator implements Communicator {
private readonly allowedOrigins;
private callbacks;
constructor(allowedOrigins?: RegExp[] | null);
private debugMode;
constructor(allowedOrigins?: RegExp[] | null, debugMode?: boolean);
private isValidMessage;
private logIncomingMessage;
private onParentMessage;
Expand Down
6 changes: 4 additions & 2 deletions packages/safe-apps-sdk/dist/src/communication/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/src/communication/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/safe-apps-sdk/dist/src/sdk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TXs } from './txs';
import { Eth } from './eth';
export declare type Opts = {
whitelistedDomains?: RegExp[];
debug?: boolean;
};
declare class SafeAppsSDK {
private readonly communicator;
Expand Down
Loading

0 comments on commit 44bb31c

Please sign in to comment.