Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove network name across SDK #162

Merged
merged 4 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/safe-apps-provider/dist/provider.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-provider/dist/provider.js.map

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

8 changes: 1 addition & 7 deletions packages/safe-apps-provider/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import { EventEmitter } from 'events';
import { EIP1193Provider } from './types';
import { getLowerCase } from './utils';

const NETWORK_CHAIN_ID: Record<string, number> = {
MAINNET: 1,
RINKEBY: 4,
XDAI: 100,
};

// The API is based on Ethereum JavaScript API Provider Standard. Link: https://eips.ethereum.org/EIPS/eip-1193
export class SafeAppProvider implements EIP1193Provider {
private readonly safe: SafeInfo;
Expand Down Expand Up @@ -47,7 +41,7 @@ export class SafeAppProvider implements EIP1193Provider {
}

public get chainId(): number {
return NETWORK_CHAIN_ID[this.safe.network];
return this.safe.chainId;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
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.

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 @@ -17,7 +17,7 @@ interface Props {
export const SafeProvider: React.FC<Props> = ({ loader = null, opts, children }) => {
const [sdk] = useState(() => new SafeAppsSDK(opts));
const [connected, setConnected] = useState(false);
const [safe, setSafe] = useState<SafeInfo>({ safeAddress: '', network: 'RINKEBY' });
const [safe, setSafe] = useState<SafeInfo>({ safeAddress: '', chainId: 1 });
const contextValue = useMemo(() => ({ sdk, connected, safe }), [sdk, connected, safe]);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Safe information can be obtained by calling `.getSafeInfo()`
const safe = await appsSdk.getSafeInfo();
// {
// "safeAddress": "0x2fC97b3c7324EFc0BeC094bf75d5dCdFEb082C53",
// "network": "RINKEBY"
// "chainId": 4
// }
```

Expand Down
3 changes: 1 addition & 2 deletions packages/safe-apps-sdk/dist/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { METHODS } from './communication/methods';
import { RPC_CALLS } from './eth/constants';
import { TXs } from './txs';
import { Eth } from './eth';
export declare type Networks = 'MAINNET' | 'MORDEN' | 'ROPSTEN' | 'RINKEBY' | 'GOERLI' | 'KOVAN' | 'XDAI' | 'ENERGY_WEB_CHAIN' | 'VOLTA' | 'UNKNOWN';
export interface Transaction {
to: string;
value: string;
Expand All @@ -25,7 +24,7 @@ export interface SdkInstance {
}
export interface SafeInfo {
safeAddress: string;
network: Networks;
chainId: number;
}
export declare type Methods = keyof typeof METHODS;
export declare type SDKRequestData<M extends Methods = Methods, P = unknown> = {
Expand Down
2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/src/types.js.map

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

14 changes: 1 addition & 13 deletions packages/safe-apps-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ import { RPC_CALLS } from './eth/constants';
import { TXs } from './txs';
import { Eth } from './eth';

export type Networks =
| 'MAINNET'
| 'MORDEN'
| 'ROPSTEN'
| 'RINKEBY'
| 'GOERLI'
| 'KOVAN'
| 'XDAI'
| 'ENERGY_WEB_CHAIN'
| 'VOLTA'
| 'UNKNOWN';

export interface Transaction {
to: string;
value: string;
Expand Down Expand Up @@ -43,7 +31,7 @@ export interface SdkInstance {

export interface SafeInfo {
safeAddress: string;
network: Networks;
chainId: number;
}

export type Methods = keyof typeof METHODS;
Expand Down