diff --git a/packages/safe-apps-provider/dist/provider.js b/packages/safe-apps-provider/dist/provider.js index 99f17f5c..f3aff377 100644 --- a/packages/safe-apps-provider/dist/provider.js +++ b/packages/safe-apps-provider/dist/provider.js @@ -3,11 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.SafeAppProvider = void 0; const events_1 = require("events"); const utils_1 = require("./utils"); -const NETWORK_CHAIN_ID = { - MAINNET: 1, - RINKEBY: 4, - XDAI: 100, -}; // The API is based on Ethereum JavaScript API Provider Standard. Link: https://eips.ethereum.org/EIPS/eip-1193 class SafeAppProvider { constructor(safe, sdk) { @@ -36,7 +31,7 @@ class SafeAppProvider { this.events.removeListener(event, listener); } get chainId() { - return NETWORK_CHAIN_ID[this.safe.network]; + return this.safe.chainId; } // eslint-disable-next-line @typescript-eslint/no-explicit-any async request(request) { @@ -125,6 +120,8 @@ class SafeAppProvider { throw Error(`"${request.method}" not implemented`); } } + // this method is needed for ethers v4 + // https://github.com/ethers-io/ethers.js/blob/427e16826eb15d52d25c4f01027f8db22b74b76c/src.ts/providers/web3-provider.ts#L41-L55 send(request, callback) { if (!request) callback('Undefined request'); diff --git a/packages/safe-apps-provider/dist/provider.js.map b/packages/safe-apps-provider/dist/provider.js.map index 43dc2162..7ed6f4ff 100644 --- a/packages/safe-apps-provider/dist/provider.js.map +++ b/packages/safe-apps-provider/dist/provider.js.map @@ -1 +1 @@ -{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;AACA,mCAAsC;AAEtC,mCAAuC;AAEvC,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,+GAA+G;AAC/G,MAAa,eAAe;IAM1B,YAAY,IAAc,EAAE,GAAgB;QAHpC,iBAAY,GAAG,IAAI,GAAG,EAAiC,CAAC;QACxD,WAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;QAGlC,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B,CAAC,CAAC;gBACtB,OAAO,CAAC,CAAC;aACV;YAED,KAAK,UAAU,CAAC,CAAC;gBACf,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAClD;YAED,KAAK,aAAa;gBAChB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE/C;gBACE,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,mBAAmB,CAAC,CAAC;SACtD;IACH,CAAC;IAED,sCAAsC;IACtC,iIAAiI;IACjI,IAAI,CAAC,OAAY,EAAE,QAA8C;QAC/D,IAAI,CAAC,OAAO;YAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;aAClB,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;aAC5E,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF;AA3JD,0CA2JC"} \ No newline at end of file diff --git a/packages/safe-apps-provider/src/provider.ts b/packages/safe-apps-provider/src/provider.ts index 0eedeacf..16c86dab 100644 --- a/packages/safe-apps-provider/src/provider.ts +++ b/packages/safe-apps-provider/src/provider.ts @@ -3,12 +3,6 @@ import { EventEmitter } from 'events'; import { EIP1193Provider } from './types'; import { getLowerCase } from './utils'; -const NETWORK_CHAIN_ID: Record = { - 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; @@ -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 diff --git a/packages/safe-apps-react-sdk/dist/index.js b/packages/safe-apps-react-sdk/dist/index.js index 269916c9..7db8e742 100644 --- a/packages/safe-apps-react-sdk/dist/index.js +++ b/packages/safe-apps-react-sdk/dist/index.js @@ -20,7 +20,7 @@ const SafeContext = react_1.createContext(undefined); const SafeProvider = ({ loader = null, opts, children }) => { const [sdk] = react_1.useState(() => new safe_apps_sdk_1.default(opts)); const [connected, setConnected] = react_1.useState(false); - const [safe, setSafe] = react_1.useState({ safeAddress: '', network: 'RINKEBY' }); + const [safe, setSafe] = react_1.useState({ safeAddress: '', chainId: 1 }); const contextValue = react_1.useMemo(() => ({ sdk, connected, safe }), [sdk, connected, safe]); react_1.useEffect(() => { let active = true; diff --git a/packages/safe-apps-react-sdk/dist/index.js.map b/packages/safe-apps-react-sdk/dist/index.js.map index db31b0a4..448cde41 100644 --- a/packages/safe-apps-react-sdk/dist/index.js.map +++ b/packages/safe-apps-react-sdk/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAA8F;AAC9F,6EAAkF;AAQlF,MAAM,WAAW,GAAG,qBAAa,CAAkC,SAAS,CAAC,CAAC;AAOvE,MAAM,YAAY,GAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IACjF,MAAM,CAAC,GAAG,CAAC,GAAG,gBAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,uBAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,gB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CAAC,CAAC;aACpB;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,MAAM,EAAE;oBACX,OAAO;iBACR;gBACD,YAAY,CAAC,KAAK,CAAC,CAAC;aACrB;QACH,CAAC,CAAA,CAAC;QAEF,aAAa,EAAE,CAAC;QAEhB,OAAO,GAAG,EAAE;YACV,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE;QACxB,OAAO,MAAM,CAAC;KACf;IAED,OAAO,kBAAC,WAAW,CAAC,QAAQ,kBAAC,KAAK,EAAE,YAAY,gBAAG,QAAQ,YAAwB,CAAC;AACtF,CAAC,CAAC;AArCW,QAAA,YAAY,gBAqCvB;AAEK,MAAM,cAAc,GAAG,GAAwB,EAAE;IACtD,MAAM,KAAK,GAAG,kBAAU,CAAC,WAAW,CAAC,CAAC;IAEtC,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB;AAEF,kBAAe,oBAAY,CAAC"} \ No newline at end of file diff --git a/packages/safe-apps-react-sdk/src/index.tsx b/packages/safe-apps-react-sdk/src/index.tsx index c11954fe..da914685 100644 --- a/packages/safe-apps-react-sdk/src/index.tsx +++ b/packages/safe-apps-react-sdk/src/index.tsx @@ -17,7 +17,7 @@ interface Props { export const SafeProvider: React.FC = ({ loader = null, opts, children }) => { const [sdk] = useState(() => new SafeAppsSDK(opts)); const [connected, setConnected] = useState(false); - const [safe, setSafe] = useState({ safeAddress: '', network: 'RINKEBY' }); + const [safe, setSafe] = useState({ safeAddress: '', chainId: 1 }); const contextValue = useMemo(() => ({ sdk, connected, safe }), [sdk, connected, safe]); useEffect(() => { diff --git a/packages/safe-apps-sdk/README.md b/packages/safe-apps-sdk/README.md index fda10a3a..60cb0f42 100644 --- a/packages/safe-apps-sdk/README.md +++ b/packages/safe-apps-sdk/README.md @@ -66,7 +66,7 @@ Safe information can be obtained by calling `.getSafeInfo()` const safe = await appsSdk.getSafeInfo(); // { // "safeAddress": "0x2fC97b3c7324EFc0BeC094bf75d5dCdFEb082C53", -// "network": "RINKEBY" +// "chainId": 4 // } ``` diff --git a/packages/safe-apps-sdk/dist/src/types.d.ts b/packages/safe-apps-sdk/dist/src/types.d.ts index 3966adc7..5e9c736f 100644 --- a/packages/safe-apps-sdk/dist/src/types.d.ts +++ b/packages/safe-apps-sdk/dist/src/types.d.ts @@ -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; @@ -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 = { diff --git a/packages/safe-apps-sdk/dist/src/types.js.map b/packages/safe-apps-sdk/dist/src/types.js.map index ded0ee06..28b90ada 100644 --- a/packages/safe-apps-sdk/dist/src/types.js.map +++ b/packages/safe-apps-sdk/dist/src/types.js.map @@ -1 +1 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AA+FlD,4GAA4G;AAE5G,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,yCAAI,CAAA;IACJ,2DAAa,CAAA;IACb,6CAAM,CAAA;AACR,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;AAED,6HAA6H;AAC7H,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,iDAA8B,CAAA;IAC9B,0DAAuC,CAAA;AACzC,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED,IAAY,qBAcX;AAdD,WAAY,qBAAqB;IAC/B,wCAAe,CAAA;IACf,oEAA2C,CAAA;IAC3C,2EAAkD,CAAA;IAClD,qDAA4B,CAAA;IAC5B,iFAAwD,CAAA;IACxD,iDAAwB,CAAA;IACxB,6DAAoC,CAAA;IACpC,gEAAuC,CAAA;IACvC,uDAA8B,CAAA;IAC9B,yDAAgC,CAAA;IAChC,mFAA0D,CAAA;IAC1D,qDAA4B,CAAA;IAC5B,6DAAoC,CAAA;AACtC,CAAC,EAdW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAchC"} \ No newline at end of file +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAmFlD,4GAA4G;AAE5G,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,yCAAI,CAAA;IACJ,2DAAa,CAAA;IACb,6CAAM,CAAA;AACR,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;AAED,6HAA6H;AAC7H,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,iDAA8B,CAAA;IAC9B,0DAAuC,CAAA;AACzC,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED,IAAY,qBAcX;AAdD,WAAY,qBAAqB;IAC/B,wCAAe,CAAA;IACf,oEAA2C,CAAA;IAC3C,2EAAkD,CAAA;IAClD,qDAA4B,CAAA;IAC5B,iFAAwD,CAAA;IACxD,iDAAwB,CAAA;IACxB,6DAAoC,CAAA;IACpC,gEAAuC,CAAA;IACvC,uDAA8B,CAAA;IAC9B,yDAAgC,CAAA;IAChC,mFAA0D,CAAA;IAC1D,qDAA4B,CAAA;IAC5B,6DAAoC,CAAA;AACtC,CAAC,EAdW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAchC"} \ No newline at end of file diff --git a/packages/safe-apps-sdk/src/types.ts b/packages/safe-apps-sdk/src/types.ts index 21575abe..237f5940 100644 --- a/packages/safe-apps-sdk/src/types.ts +++ b/packages/safe-apps-sdk/src/types.ts @@ -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; @@ -43,7 +31,7 @@ export interface SdkInstance { export interface SafeInfo { safeAddress: string; - network: Networks; + chainId: number; } export type Methods = keyof typeof METHODS;