@rabby-wallet/gnosis-sdk 1.4.8 → 1.4.9-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.
package/dist/api.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SafeTransactionDataPartial } from "@safe-global/types-kit";
2
2
  import { Axios, AxiosAdapter } from "axios";
3
+ export { GNOSIS_SUPPORT_CHAINS, HOST_MAP, getTxServiceUrl } from "./txService";
3
4
  export interface SafeInfo {
4
5
  address: string;
5
6
  fallbackHandler: string;
@@ -99,9 +100,6 @@ export type SafeOpenApiService = {
99
100
  signature: string;
100
101
  }) => Promise<void>;
101
102
  };
102
- export declare const GNOSIS_SUPPORT_CHAINS: string[];
103
- export declare const HOST_MAP: Record<string, string>;
104
- export declare const getTxServiceUrl: (chainId: string) => string;
105
103
  export default class RequestProvider {
106
104
  prefix: string;
107
105
  request: Axios;
@@ -130,4 +128,3 @@ export default class RequestProvider {
130
128
  getMessage(messageHash: string): Promise<any>;
131
129
  addMessageSignature(messageHash: string, signature: string): Promise<void>;
132
130
  }
133
- export {};
package/dist/api.js CHANGED
@@ -1,216 +1,8 @@
1
1
  import { ethers } from "ethers";
2
2
  import { isLegacyVersion } from "./utils";
3
3
  import axios from "axios";
4
- // https://github.com/safe-global/safe-core-sdk/blob/main/packages/api-kit/src/utils/config.ts
5
- const networks = [
6
- {
7
- chainId: "1",
8
- shortName: "eth",
9
- enum: "ETH",
10
- },
11
- {
12
- chainId: "10",
13
- shortName: "oeth",
14
- enum: "OP",
15
- },
16
- {
17
- chainId: "50",
18
- shortName: "xdc",
19
- },
20
- {
21
- chainId: "56",
22
- shortName: "bnb",
23
- enum: "BSC",
24
- },
25
- {
26
- chainId: "100",
27
- shortName: "gno",
28
- enum: "GNOSIS",
29
- },
30
- {
31
- chainId: "130",
32
- shortName: "unichain",
33
- enum: "UNI",
34
- },
35
- {
36
- chainId: "137",
37
- shortName: "pol",
38
- enum: "POLYGON",
39
- },
40
- {
41
- chainId: "143",
42
- shortName: "monad",
43
- enum: "MONAD",
44
- },
45
- {
46
- chainId: "146",
47
- shortName: "sonic",
48
- enum: "SONIC",
49
- },
50
- {
51
- chainId: "196",
52
- shortName: "okb",
53
- enum: "XLAYER",
54
- },
55
- {
56
- chainId: "204",
57
- shortName: "opbnb",
58
- enum: "OPBNB",
59
- },
60
- {
61
- chainId: "232",
62
- shortName: "lens",
63
- enum: "LENS",
64
- },
65
- {
66
- chainId: "324",
67
- shortName: "zksync",
68
- enum: "ERA",
69
- },
70
- {
71
- chainId: "480",
72
- shortName: "wc",
73
- enum: "WORLD",
74
- },
75
- {
76
- chainId: "988",
77
- shortName: "stable",
78
- enum: "STABLE",
79
- },
80
- {
81
- chainId: "999",
82
- shortName: "hyper",
83
- enum: "HYPER",
84
- },
85
- {
86
- chainId: "1101",
87
- shortName: "zkevm",
88
- },
89
- {
90
- chainId: "3338",
91
- shortName: "peaq",
92
- },
93
- {
94
- chainId: "3637",
95
- shortName: "btc",
96
- enum: "BOTANIX",
97
- },
98
- {
99
- chainId: "5000",
100
- shortName: "mantle",
101
- enum: "MANTLE",
102
- },
103
- {
104
- chainId: "8453",
105
- shortName: "base",
106
- enum: "BASE",
107
- },
108
- {
109
- chainId: "9745",
110
- shortName: "plasma",
111
- enum: "PLASMA",
112
- },
113
- {
114
- chainId: "10143",
115
- shortName: "monad-testnet",
116
- },
117
- {
118
- chainId: "10200",
119
- shortName: "chi",
120
- },
121
- {
122
- chainId: "16661",
123
- shortName: "0g",
124
- enum: "G0",
125
- },
126
- {
127
- chainId: "42161",
128
- shortName: "arb1",
129
- enum: "ARBITRUM",
130
- },
131
- {
132
- chainId: "42220",
133
- shortName: "celo",
134
- enum: "CELO",
135
- },
136
- {
137
- chainId: "43111",
138
- shortName: "hemi",
139
- enum: "HEMI",
140
- },
141
- {
142
- chainId: "43114",
143
- shortName: "avax",
144
- enum: "AVAX",
145
- },
146
- {
147
- chainId: "57073",
148
- shortName: "ink",
149
- enum: "INK",
150
- },
151
- {
152
- chainId: "59144",
153
- shortName: "linea",
154
- enum: "LINEA",
155
- },
156
- {
157
- chainId: "80069",
158
- shortName: "bep",
159
- },
160
- {
161
- chainId: "80094",
162
- shortName: "berachain",
163
- enum: "BERA",
164
- },
165
- {
166
- chainId: "81224",
167
- shortName: "codex",
168
- },
169
- {
170
- chainId: "84532",
171
- shortName: "basesep",
172
- },
173
- {
174
- chainId: "534352",
175
- shortName: "scr",
176
- enum: "SCRL",
177
- },
178
- {
179
- chainId: "747474",
180
- shortName: "katana",
181
- enum: "KATANA",
182
- },
183
- {
184
- chainId: "11155111",
185
- shortName: "sep",
186
- },
187
- {
188
- chainId: "1313161554",
189
- shortName: "aurora",
190
- enum: "AURORA",
191
- },
192
- ];
193
- export const GNOSIS_SUPPORT_CHAINS = networks
194
- .map((item) => item.enum)
195
- .filter((e) => Boolean(e))
196
- .concat(["BLAST"]);
197
- const networkMap = networks.reduce((acc, { chainId, shortName }) => {
198
- acc[chainId] = shortName;
199
- return acc;
200
- }, {});
201
- export const HOST_MAP = {
202
- /**
203
- * blast
204
- */
205
- "81457": "https://safe-transaction-blast.safe.global/api",
206
- };
207
- export const getTxServiceUrl = (chainId) => {
208
- const shortName = networkMap[chainId];
209
- if (shortName) {
210
- return `/v1/safe-tx-service/${shortName}/api`;
211
- }
212
- return HOST_MAP[chainId];
213
- };
4
+ import { getTxServiceUrl } from "./txService";
5
+ export { GNOSIS_SUPPORT_CHAINS, HOST_MAP, getTxServiceUrl } from "./txService";
214
6
  export default class RequestProvider {
215
7
  constructor({ networkId, adapter, openapiService, }) {
216
8
  const txServiceUrl = getTxServiceUrl(networkId);
@@ -0,0 +1,3 @@
1
+ export declare const GNOSIS_SUPPORT_CHAINS: string[];
2
+ export declare const HOST_MAP: Record<string, string>;
3
+ export declare const getTxServiceUrl: (chainId: string) => string;
@@ -0,0 +1,22 @@
1
+ import networks from "./txServiceNetworks.json";
2
+ export const GNOSIS_SUPPORT_CHAINS = networks
3
+ .map((item) => item.enum)
4
+ .filter((e) => Boolean(e))
5
+ .concat(["BLAST"]);
6
+ const networkMap = networks.reduce((acc, { chainId, shortName }) => {
7
+ acc[chainId] = shortName;
8
+ return acc;
9
+ }, {});
10
+ export const HOST_MAP = {
11
+ /**
12
+ * blast
13
+ */
14
+ "81457": "https://safe-transaction-blast.safe.global/api",
15
+ };
16
+ export const getTxServiceUrl = (chainId) => {
17
+ const shortName = networkMap[chainId];
18
+ if (shortName) {
19
+ return `/v1/safe-tx-service/${shortName}/api`;
20
+ }
21
+ return HOST_MAP[chainId];
22
+ };
@@ -0,0 +1,231 @@
1
+ [
2
+ {
3
+ "chainId": "1",
4
+ "shortName": "eth",
5
+ "enum": "ETH"
6
+ },
7
+ {
8
+ "chainId": "10",
9
+ "shortName": "oeth",
10
+ "enum": "OP"
11
+ },
12
+ {
13
+ "chainId": "50",
14
+ "shortName": "xdc",
15
+ "enum": "XDC"
16
+ },
17
+ {
18
+ "chainId": "56",
19
+ "shortName": "bnb",
20
+ "enum": "BSC"
21
+ },
22
+ {
23
+ "chainId": "100",
24
+ "shortName": "gno",
25
+ "enum": "GNOSIS"
26
+ },
27
+ {
28
+ "chainId": "130",
29
+ "shortName": "unichain",
30
+ "enum": "UNI"
31
+ },
32
+ {
33
+ "chainId": "137",
34
+ "shortName": "pol",
35
+ "enum": "POLYGON"
36
+ },
37
+ {
38
+ "chainId": "143",
39
+ "shortName": "monad",
40
+ "enum": "MONAD"
41
+ },
42
+ {
43
+ "chainId": "146",
44
+ "shortName": "sonic",
45
+ "enum": "SONIC"
46
+ },
47
+ {
48
+ "chainId": "196",
49
+ "shortName": "okb",
50
+ "enum": "XLAYER"
51
+ },
52
+ {
53
+ "chainId": "204",
54
+ "shortName": "opbnb",
55
+ "enum": "OPBNB"
56
+ },
57
+ {
58
+ "chainId": "232",
59
+ "shortName": "lens",
60
+ "enum": "LENS"
61
+ },
62
+ {
63
+ "chainId": "324",
64
+ "shortName": "zksync",
65
+ "enum": "ERA"
66
+ },
67
+ {
68
+ "chainId": "480",
69
+ "shortName": "wc",
70
+ "enum": "WORLD"
71
+ },
72
+ {
73
+ "chainId": "988",
74
+ "shortName": "stable",
75
+ "enum": "STABLE"
76
+ },
77
+ {
78
+ "chainId": "999",
79
+ "shortName": "hyper",
80
+ "enum": "HYPER"
81
+ },
82
+ {
83
+ "chainId": "1101",
84
+ "shortName": "zkevm"
85
+ },
86
+ {
87
+ "chainId": "1672",
88
+ "shortName": "pharos"
89
+ },
90
+ {
91
+ "chainId": "3338",
92
+ "shortName": "peaq"
93
+ },
94
+ {
95
+ "chainId": "3637",
96
+ "shortName": "btc",
97
+ "enum": "BOTANIX"
98
+ },
99
+ {
100
+ "chainId": "4217",
101
+ "shortName": "tempo",
102
+ "enum": "TEMPO"
103
+ },
104
+ {
105
+ "chainId": "4326",
106
+ "shortName": "mega",
107
+ "enum": "MEGAETH"
108
+ },
109
+ {
110
+ "chainId": "5000",
111
+ "shortName": "mantle",
112
+ "enum": "MANTLE"
113
+ },
114
+ {
115
+ "chainId": "5003",
116
+ "shortName": "mnt-sep"
117
+ },
118
+ {
119
+ "chainId": "8453",
120
+ "shortName": "base",
121
+ "enum": "BASE"
122
+ },
123
+ {
124
+ "chainId": "9745",
125
+ "shortName": "plasma",
126
+ "enum": "PLASMA"
127
+ },
128
+ {
129
+ "chainId": "10143",
130
+ "shortName": "monad-testnet"
131
+ },
132
+ {
133
+ "chainId": "10200",
134
+ "shortName": "chi"
135
+ },
136
+ {
137
+ "chainId": "16661",
138
+ "shortName": "0g",
139
+ "enum": "G0"
140
+ },
141
+ {
142
+ "chainId": "25363",
143
+ "shortName": "fluent"
144
+ },
145
+ {
146
+ "chainId": "42161",
147
+ "shortName": "arb1",
148
+ "enum": "ARBITRUM"
149
+ },
150
+ {
151
+ "chainId": "42220",
152
+ "shortName": "celo",
153
+ "enum": "CELO"
154
+ },
155
+ {
156
+ "chainId": "42431",
157
+ "shortName": "tempo-moderato"
158
+ },
159
+ {
160
+ "chainId": "43111",
161
+ "shortName": "hemi",
162
+ "enum": "HEMI"
163
+ },
164
+ {
165
+ "chainId": "43114",
166
+ "shortName": "avax",
167
+ "enum": "AVAX"
168
+ },
169
+ {
170
+ "chainId": "46630",
171
+ "shortName": "robinhood-testnet"
172
+ },
173
+ {
174
+ "chainId": "57073",
175
+ "shortName": "ink",
176
+ "enum": "INK"
177
+ },
178
+ {
179
+ "chainId": "59144",
180
+ "shortName": "linea",
181
+ "enum": "LINEA"
182
+ },
183
+ {
184
+ "chainId": "80069",
185
+ "shortName": "bep"
186
+ },
187
+ {
188
+ "chainId": "80094",
189
+ "shortName": "berachain",
190
+ "enum": "BERA"
191
+ },
192
+ {
193
+ "chainId": "81224",
194
+ "shortName": "codex"
195
+ },
196
+ {
197
+ "chainId": "84532",
198
+ "shortName": "basesep"
199
+ },
200
+ {
201
+ "chainId": "102030",
202
+ "shortName": "ctc"
203
+ },
204
+ {
205
+ "chainId": "534352",
206
+ "shortName": "scr",
207
+ "enum": "SCRL"
208
+ },
209
+ {
210
+ "chainId": "747474",
211
+ "shortName": "katana",
212
+ "enum": "KATANA"
213
+ },
214
+ {
215
+ "chainId": "5042002",
216
+ "shortName": "arc-testnet"
217
+ },
218
+ {
219
+ "chainId": "11142220",
220
+ "shortName": "celo-sep"
221
+ },
222
+ {
223
+ "chainId": "11155111",
224
+ "shortName": "sep"
225
+ },
226
+ {
227
+ "chainId": "1313161554",
228
+ "shortName": "aurora",
229
+ "enum": "AURORA"
230
+ }
231
+ ]
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@rabby-wallet/gnosis-sdk",
3
- "version": "1.4.8",
3
+ "version": "1.4.9-0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
+ "update-tx-service-networks": "node scripts/update-tx-service-networks.js",
8
9
  "prepublishOnly": "yarn build"
9
10
  },
10
11
  "author": "",
@@ -17,7 +18,7 @@
17
18
  "@ethersproject/solidity": "5.5.0",
18
19
  "@safe-global/api-kit": "4.0.0",
19
20
  "@safe-global/protocol-kit": "5.2.1",
20
- "@safe-global/safe-deployments": "1.37.49",
21
+ "@safe-global/safe-deployments": "1.37.56",
21
22
  "@safe-global/types-kit": "1.0.2",
22
23
  "axios": "0.24.0",
23
24
  "ethereumjs-util": "7.1.3",
@@ -0,0 +1,213 @@
1
+ const fs = require("fs/promises");
2
+ const path = require("path");
3
+ const https = require("https");
4
+
5
+ const SAFE_TX_SERVICE_NETWORKS_URL =
6
+ "https://raw.githubusercontent.com/safe-global/safe-docs/main/components/ApiReference/tx-service-networks.json";
7
+ const DEBANK_SUPPORTED_CHAINS_URL =
8
+ "https://static.debank.com/supported_chains.json";
9
+ const OUTPUT_PATH = path.resolve(__dirname, "../src/txServiceNetworks.json");
10
+
11
+ const chainServerIdEnumMap = {
12
+ eth: "ETH",
13
+ bsc: "BSC",
14
+ xdai: "GNOSIS",
15
+ matic: "POLYGON",
16
+ ftm: "FTM",
17
+ okt: "OKT",
18
+ heco: "HECO",
19
+ avax: "AVAX",
20
+ arb: "ARBITRUM",
21
+ op: "OP",
22
+ celo: "CELO",
23
+ movr: "MOVR",
24
+ cro: "CRO",
25
+ boba: "BOBA",
26
+ metis: "METIS",
27
+ btt: "BTT",
28
+ aurora: "AURORA",
29
+ mobm: "MOBM",
30
+ sbch: "SBCH",
31
+ hmy: "HMY",
32
+ fuse: "FUSE",
33
+ astar: "ASTAR",
34
+ klay: "KLAY",
35
+ rsk: "RSK",
36
+ iotx: "IOTX",
37
+ kcc: "KCC",
38
+ wan: "WAN",
39
+ sgb: "SGB",
40
+ evmos: "EVMOS",
41
+ dfk: "DFK",
42
+ tlos: "TLOS",
43
+ nova: "NOVA",
44
+ canto: "CANTO",
45
+ doge: "DOGE",
46
+ step: "STEP",
47
+ kava: "KAVA",
48
+ mada: "MADA",
49
+ cfx: "CFX",
50
+ brise: "BRISE",
51
+ ckb: "CKB",
52
+ tomb: "TOMB",
53
+ pze: "PZE",
54
+ era: "ERA",
55
+ eos: "EOS",
56
+ core: "CORE",
57
+ flr: "FLR",
58
+ wemix: "WEMIX",
59
+ mtr: "METER",
60
+ etc: "ETC",
61
+ fsn: "FSN",
62
+ pls: "PULSE",
63
+ rose: "ROSE",
64
+ ron: "RONIN",
65
+ oas: "OAS",
66
+ zora: "ZORA",
67
+ linea: "LINEA",
68
+ base: "BASE",
69
+ mnt: "MANTLE",
70
+ tenet: "TENET",
71
+ lyx: "LYX",
72
+ opbnb: "OPBNB",
73
+ loot: "LOOT",
74
+ shib: "SHIB",
75
+ manta: "MANTA",
76
+ scrl: "SCRL",
77
+ fx: "FX",
78
+ beam: "BEAM",
79
+ pego: "PEGO",
80
+ zkfair: "ZKFAIR",
81
+ fon: "FON",
82
+ bfc: "BFC",
83
+ alot: "ALOT",
84
+ xai: "XAI",
85
+ zeta: "ZETA",
86
+ rari: "RARI",
87
+ hubble: "HUBBLE",
88
+ mode: "MODE",
89
+ merlin: "MERLIN",
90
+ dym: "DYM",
91
+ eon: "EON",
92
+ blast: "BLAST",
93
+ sx: "SX",
94
+ platon: "PLATON",
95
+ map: "MAP",
96
+ frax: "FRAX",
97
+ aze: "AZE",
98
+ karak: "KARAK",
99
+ };
100
+
101
+ const fetchJson = (url) =>
102
+ new Promise((resolve, reject) => {
103
+ https
104
+ .get(url, (response) => {
105
+ if (
106
+ response.statusCode >= 300 &&
107
+ response.statusCode < 400 &&
108
+ response.headers.location
109
+ ) {
110
+ response.resume();
111
+ fetchJson(new URL(response.headers.location, url).toString())
112
+ .then(resolve)
113
+ .catch(reject);
114
+ return;
115
+ }
116
+
117
+ if (response.statusCode !== 200) {
118
+ response.resume();
119
+ reject(new Error(`Failed to fetch ${url}: ${response.statusCode}`));
120
+ return;
121
+ }
122
+
123
+ let body = "";
124
+ response.setEncoding("utf8");
125
+ response.on("data", (chunk) => {
126
+ body += chunk;
127
+ });
128
+ response.on("end", () => {
129
+ try {
130
+ resolve(JSON.parse(body));
131
+ } catch (error) {
132
+ reject(error);
133
+ }
134
+ });
135
+ })
136
+ .on("error", reject);
137
+ });
138
+
139
+ const readExistingNetworks = async () => {
140
+ try {
141
+ return JSON.parse(await fs.readFile(OUTPUT_PATH, "utf8"));
142
+ } catch (error) {
143
+ if (error.code === "ENOENT") {
144
+ return [];
145
+ }
146
+ throw error;
147
+ }
148
+ };
149
+
150
+ const toChainEnum = (debankChain) => {
151
+ if (!debankChain) {
152
+ return undefined;
153
+ }
154
+
155
+ return chainServerIdEnumMap[debankChain.id] || debankChain.id.toUpperCase();
156
+ };
157
+
158
+ const getTxServiceShortName = ({ shortName, txServiceUrl }) => {
159
+ const txServiceUrlShortName = txServiceUrl?.split("/").filter(Boolean).pop();
160
+ return txServiceUrlShortName || shortName;
161
+ };
162
+
163
+ const getMappedChainEnum = (serverId) => chainServerIdEnumMap[serverId];
164
+
165
+ const main = async () => {
166
+ const existingNetworks = await readExistingNetworks();
167
+ const [safeNetworks, debankChains] = await Promise.all([
168
+ fetchJson(SAFE_TX_SERVICE_NETWORKS_URL),
169
+ fetchJson(DEBANK_SUPPORTED_CHAINS_URL),
170
+ ]);
171
+
172
+ const debankChainByCommunityId = new Map(
173
+ debankChains.map((chain) => [String(chain.community_id), chain]),
174
+ );
175
+
176
+ const networks = safeNetworks.map((safeNetwork) => {
177
+ const { chainId, shortName } = safeNetwork;
178
+ const txServiceShortName = getTxServiceShortName(safeNetwork);
179
+ const enumName =
180
+ toChainEnum(debankChainByCommunityId.get(String(chainId))) ||
181
+ getMappedChainEnum(shortName) ||
182
+ getMappedChainEnum(txServiceShortName);
183
+ return {
184
+ chainId: String(chainId),
185
+ shortName: txServiceShortName,
186
+ ...(enumName ? { enum: enumName } : {}),
187
+ };
188
+ });
189
+
190
+ await fs.writeFile(OUTPUT_PATH, `${JSON.stringify(networks, null, 2)}\n`);
191
+
192
+ const enumCount = networks.filter((network) => network.enum).length;
193
+ const existingEnums = new Set(
194
+ existingNetworks.map((network) => network.enum).filter(Boolean),
195
+ );
196
+ const newEnums = networks
197
+ .map((network) => network.enum)
198
+ .filter((enumName) => enumName && !existingEnums.has(enumName));
199
+
200
+ console.log(
201
+ `Updated ${path.relative(process.cwd(), OUTPUT_PATH)} with ${
202
+ networks.length
203
+ } networks (${enumCount} with enum).`,
204
+ );
205
+ console.log(
206
+ `New enums: ${newEnums.length > 0 ? newEnums.join(", ") : "none"}.`,
207
+ );
208
+ };
209
+
210
+ main().catch((error) => {
211
+ console.error(error);
212
+ process.exit(1);
213
+ });
package/src/api.ts CHANGED
@@ -2,6 +2,9 @@ import { SafeTransactionDataPartial } from "@safe-global/types-kit";
2
2
  import { ethers } from "ethers";
3
3
  import { isLegacyVersion } from "./utils";
4
4
  import axios, { Axios, AxiosAdapter } from "axios";
5
+ import { getTxServiceUrl } from "./txService";
6
+
7
+ export { GNOSIS_SUPPORT_CHAINS, HOST_MAP, getTxServiceUrl } from "./txService";
5
8
 
6
9
  export interface SafeInfo {
7
10
  address: string;
@@ -102,229 +105,6 @@ export type SafeOpenApiService = {
102
105
  }) => Promise<void>;
103
106
  };
104
107
 
105
- type NetworkShortName = {
106
- shortName: string;
107
- chainId: string;
108
- enum?: string;
109
- };
110
-
111
- // https://github.com/safe-global/safe-core-sdk/blob/main/packages/api-kit/src/utils/config.ts
112
- const networks: NetworkShortName[] = [
113
- {
114
- chainId: "1",
115
- shortName: "eth",
116
- enum: "ETH",
117
- },
118
- {
119
- chainId: "10",
120
- shortName: "oeth",
121
- enum: "OP",
122
- },
123
- {
124
- chainId: "50",
125
- shortName: "xdc",
126
- },
127
- {
128
- chainId: "56",
129
- shortName: "bnb",
130
- enum: "BSC",
131
- },
132
- {
133
- chainId: "100",
134
- shortName: "gno",
135
- enum: "GNOSIS",
136
- },
137
- {
138
- chainId: "130",
139
- shortName: "unichain",
140
- enum: "UNI",
141
- },
142
- {
143
- chainId: "137",
144
- shortName: "pol",
145
- enum: "POLYGON",
146
- },
147
- {
148
- chainId: "143",
149
- shortName: "monad",
150
- enum: "MONAD",
151
- },
152
- {
153
- chainId: "146",
154
- shortName: "sonic",
155
- enum: "SONIC",
156
- },
157
- {
158
- chainId: "196",
159
- shortName: "okb",
160
- enum: "XLAYER",
161
- },
162
- {
163
- chainId: "204",
164
- shortName: "opbnb",
165
- enum: "OPBNB",
166
- },
167
- {
168
- chainId: "232",
169
- shortName: "lens",
170
- enum: "LENS",
171
- },
172
- {
173
- chainId: "324",
174
- shortName: "zksync",
175
- enum: "ERA",
176
- },
177
- {
178
- chainId: "480",
179
- shortName: "wc",
180
- enum: "WORLD",
181
- },
182
- {
183
- chainId: "988",
184
- shortName: "stable",
185
- enum: "STABLE",
186
- },
187
- {
188
- chainId: "999",
189
- shortName: "hyper",
190
- enum: "HYPER",
191
- },
192
- {
193
- chainId: "1101",
194
- shortName: "zkevm",
195
- },
196
- {
197
- chainId: "3338",
198
- shortName: "peaq",
199
- },
200
- {
201
- chainId: "3637",
202
- shortName: "btc",
203
- enum: "BOTANIX",
204
- },
205
- {
206
- chainId: "5000",
207
- shortName: "mantle",
208
- enum: "MANTLE",
209
- },
210
- {
211
- chainId: "8453",
212
- shortName: "base",
213
- enum: "BASE",
214
- },
215
- {
216
- chainId: "9745",
217
- shortName: "plasma",
218
- enum: "PLASMA",
219
- },
220
- {
221
- chainId: "10143",
222
- shortName: "monad-testnet",
223
- },
224
- {
225
- chainId: "10200",
226
- shortName: "chi",
227
- },
228
- {
229
- chainId: "16661",
230
- shortName: "0g",
231
- enum: "G0",
232
- },
233
- {
234
- chainId: "42161",
235
- shortName: "arb1",
236
- enum: "ARBITRUM",
237
- },
238
- {
239
- chainId: "42220",
240
- shortName: "celo",
241
- enum: "CELO",
242
- },
243
- {
244
- chainId: "43111",
245
- shortName: "hemi",
246
- enum: "HEMI",
247
- },
248
- {
249
- chainId: "43114",
250
- shortName: "avax",
251
- enum: "AVAX",
252
- },
253
- {
254
- chainId: "57073",
255
- shortName: "ink",
256
- enum: "INK",
257
- },
258
- {
259
- chainId: "59144",
260
- shortName: "linea",
261
- enum: "LINEA",
262
- },
263
- {
264
- chainId: "80069",
265
- shortName: "bep",
266
- },
267
- {
268
- chainId: "80094",
269
- shortName: "berachain",
270
- enum: "BERA",
271
- },
272
- {
273
- chainId: "81224",
274
- shortName: "codex",
275
- },
276
- {
277
- chainId: "84532",
278
- shortName: "basesep",
279
- },
280
- {
281
- chainId: "534352",
282
- shortName: "scr",
283
- enum: "SCRL",
284
- },
285
- {
286
- chainId: "747474",
287
- shortName: "katana",
288
- enum: "KATANA",
289
- },
290
- {
291
- chainId: "11155111",
292
- shortName: "sep",
293
- },
294
- {
295
- chainId: "1313161554",
296
- shortName: "aurora",
297
- enum: "AURORA",
298
- },
299
- ];
300
- export const GNOSIS_SUPPORT_CHAINS = networks
301
- .map((item) => item.enum)
302
- .filter((e): e is string => Boolean(e))
303
- .concat(["BLAST"]);
304
-
305
- const networkMap = networks.reduce<Record<string, string>>(
306
- (acc, { chainId, shortName }) => {
307
- acc[chainId] = shortName;
308
- return acc;
309
- },
310
- {}
311
- );
312
-
313
- export const HOST_MAP: Record<string, string> = {
314
- /**
315
- * blast
316
- */
317
- "81457": "https://safe-transaction-blast.safe.global/api",
318
- };
319
-
320
- export const getTxServiceUrl = (chainId: string) => {
321
- const shortName = networkMap[chainId];
322
- if (shortName) {
323
- return `/v1/safe-tx-service/${shortName}/api`;
324
- }
325
- return HOST_MAP[chainId];
326
- };
327
-
328
108
  export default class RequestProvider {
329
109
  prefix: string;
330
110
  request: Axios;
@@ -361,7 +141,7 @@ export default class RequestProvider {
361
141
 
362
142
  getPendingTransactions(
363
143
  safeAddress: string,
364
- nonce: number
144
+ nonce: number,
365
145
  ): Promise<{ results: SafeTransactionItem[] }> {
366
146
  const checksumAddress = ethers.utils.getAddress(safeAddress);
367
147
  if (
@@ -382,11 +162,14 @@ export default class RequestProvider {
382
162
  executed: false,
383
163
  nonce__gte: nonce,
384
164
  },
385
- }
165
+ },
386
166
  );
387
167
  }
388
168
 
389
- postTransactions(safeAddres: string, data: Record<string, any>): Promise<void> {
169
+ postTransactions(
170
+ safeAddres: string,
171
+ data: Record<string, any>,
172
+ ): Promise<void> {
390
173
  const checksumAddress = ethers.utils.getAddress(safeAddres);
391
174
  if (
392
175
  this.shouldUseOpenapiService &&
@@ -401,7 +184,7 @@ export default class RequestProvider {
401
184
 
402
185
  return this.request.post(
403
186
  `/v1/safes/${checksumAddress}/multisig-transactions/`,
404
- data
187
+ data,
405
188
  );
406
189
  }
407
190
 
@@ -414,14 +197,12 @@ export default class RequestProvider {
414
197
  });
415
198
  }
416
199
 
417
- return this.request.get(
418
- `/v1/safes/${checksumAddress}/`
419
- );
200
+ return this.request.get(`/v1/safes/${checksumAddress}/`);
420
201
  }
421
202
 
422
203
  confirmTransaction(
423
204
  safeTransactionHash: string,
424
- data: Record<string, any>
205
+ data: Record<string, any>,
425
206
  ): Promise<void> {
426
207
  if (
427
208
  this.shouldUseOpenapiService &&
@@ -436,7 +217,7 @@ export default class RequestProvider {
436
217
 
437
218
  return this.request.post(
438
219
  `/v1/multisig-transactions/${safeTransactionHash}/confirmations/`,
439
- data
220
+ data,
440
221
  );
441
222
  }
442
223
 
@@ -444,7 +225,7 @@ export default class RequestProvider {
444
225
  async getSafeTxGas(
445
226
  safeAddress: string,
446
227
  safeVersion: string,
447
- safeTxData: SafeTransactionDataPartial
228
+ safeTxData: SafeTransactionDataPartial,
448
229
  ): Promise<string | undefined> {
449
230
  const isSafeTxGasRequired = isLegacyVersion(safeVersion);
450
231
 
@@ -474,7 +255,7 @@ export default class RequestProvider {
474
255
  value: safeTxData.value || "0",
475
256
  data: safeTxData.data,
476
257
  operation: safeTxData.operation,
477
- }
258
+ },
478
259
  );
479
260
  return estimation.safeTxGas;
480
261
  } catch (e) {
@@ -484,7 +265,7 @@ export default class RequestProvider {
484
265
 
485
266
  getMessages(
486
267
  safeAddress: string,
487
- options?: Record<string, any>
268
+ options?: Record<string, any>,
488
269
  ): Promise<{ results: any[] }> {
489
270
  const checksumAddress = ethers.utils.getAddress(safeAddress);
490
271
  if (this.shouldUseOpenapiService && this.openapiService?.getSafeMessages) {
@@ -506,7 +287,7 @@ export default class RequestProvider {
506
287
  message: string | Record<string, any>;
507
288
  signature: string;
508
289
  safeAppId?: number;
509
- }
290
+ },
510
291
  ): Promise<void> {
511
292
  const checksumAddress = ethers.utils.getAddress(safeAddress);
512
293
  if (this.shouldUseOpenapiService && this.openapiService?.addSafeMessage) {
@@ -0,0 +1,34 @@
1
+ import networks from "./txServiceNetworks.json";
2
+
3
+ type NetworkShortName = {
4
+ shortName: string;
5
+ chainId: string;
6
+ enum?: string;
7
+ };
8
+
9
+ export const GNOSIS_SUPPORT_CHAINS = (networks as NetworkShortName[])
10
+ .map((item) => item.enum)
11
+ .filter((e): e is string => Boolean(e))
12
+ .concat(["BLAST"]);
13
+
14
+ const networkMap = (networks as NetworkShortName[]).reduce<
15
+ Record<string, string>
16
+ >((acc, { chainId, shortName }) => {
17
+ acc[chainId] = shortName;
18
+ return acc;
19
+ }, {});
20
+
21
+ export const HOST_MAP: Record<string, string> = {
22
+ /**
23
+ * blast
24
+ */
25
+ "81457": "https://safe-transaction-blast.safe.global/api",
26
+ };
27
+
28
+ export const getTxServiceUrl = (chainId: string) => {
29
+ const shortName = networkMap[chainId];
30
+ if (shortName) {
31
+ return `/v1/safe-tx-service/${shortName}/api`;
32
+ }
33
+ return HOST_MAP[chainId];
34
+ };
@@ -0,0 +1,231 @@
1
+ [
2
+ {
3
+ "chainId": "1",
4
+ "shortName": "eth",
5
+ "enum": "ETH"
6
+ },
7
+ {
8
+ "chainId": "10",
9
+ "shortName": "oeth",
10
+ "enum": "OP"
11
+ },
12
+ {
13
+ "chainId": "50",
14
+ "shortName": "xdc",
15
+ "enum": "XDC"
16
+ },
17
+ {
18
+ "chainId": "56",
19
+ "shortName": "bnb",
20
+ "enum": "BSC"
21
+ },
22
+ {
23
+ "chainId": "100",
24
+ "shortName": "gno",
25
+ "enum": "GNOSIS"
26
+ },
27
+ {
28
+ "chainId": "130",
29
+ "shortName": "unichain",
30
+ "enum": "UNI"
31
+ },
32
+ {
33
+ "chainId": "137",
34
+ "shortName": "pol",
35
+ "enum": "POLYGON"
36
+ },
37
+ {
38
+ "chainId": "143",
39
+ "shortName": "monad",
40
+ "enum": "MONAD"
41
+ },
42
+ {
43
+ "chainId": "146",
44
+ "shortName": "sonic",
45
+ "enum": "SONIC"
46
+ },
47
+ {
48
+ "chainId": "196",
49
+ "shortName": "okb",
50
+ "enum": "XLAYER"
51
+ },
52
+ {
53
+ "chainId": "204",
54
+ "shortName": "opbnb",
55
+ "enum": "OPBNB"
56
+ },
57
+ {
58
+ "chainId": "232",
59
+ "shortName": "lens",
60
+ "enum": "LENS"
61
+ },
62
+ {
63
+ "chainId": "324",
64
+ "shortName": "zksync",
65
+ "enum": "ERA"
66
+ },
67
+ {
68
+ "chainId": "480",
69
+ "shortName": "wc",
70
+ "enum": "WORLD"
71
+ },
72
+ {
73
+ "chainId": "988",
74
+ "shortName": "stable",
75
+ "enum": "STABLE"
76
+ },
77
+ {
78
+ "chainId": "999",
79
+ "shortName": "hyper",
80
+ "enum": "HYPER"
81
+ },
82
+ {
83
+ "chainId": "1101",
84
+ "shortName": "zkevm"
85
+ },
86
+ {
87
+ "chainId": "1672",
88
+ "shortName": "pharos"
89
+ },
90
+ {
91
+ "chainId": "3338",
92
+ "shortName": "peaq"
93
+ },
94
+ {
95
+ "chainId": "3637",
96
+ "shortName": "btc",
97
+ "enum": "BOTANIX"
98
+ },
99
+ {
100
+ "chainId": "4217",
101
+ "shortName": "tempo",
102
+ "enum": "TEMPO"
103
+ },
104
+ {
105
+ "chainId": "4326",
106
+ "shortName": "mega",
107
+ "enum": "MEGAETH"
108
+ },
109
+ {
110
+ "chainId": "5000",
111
+ "shortName": "mantle",
112
+ "enum": "MANTLE"
113
+ },
114
+ {
115
+ "chainId": "5003",
116
+ "shortName": "mnt-sep"
117
+ },
118
+ {
119
+ "chainId": "8453",
120
+ "shortName": "base",
121
+ "enum": "BASE"
122
+ },
123
+ {
124
+ "chainId": "9745",
125
+ "shortName": "plasma",
126
+ "enum": "PLASMA"
127
+ },
128
+ {
129
+ "chainId": "10143",
130
+ "shortName": "monad-testnet"
131
+ },
132
+ {
133
+ "chainId": "10200",
134
+ "shortName": "chi"
135
+ },
136
+ {
137
+ "chainId": "16661",
138
+ "shortName": "0g",
139
+ "enum": "G0"
140
+ },
141
+ {
142
+ "chainId": "25363",
143
+ "shortName": "fluent"
144
+ },
145
+ {
146
+ "chainId": "42161",
147
+ "shortName": "arb1",
148
+ "enum": "ARBITRUM"
149
+ },
150
+ {
151
+ "chainId": "42220",
152
+ "shortName": "celo",
153
+ "enum": "CELO"
154
+ },
155
+ {
156
+ "chainId": "42431",
157
+ "shortName": "tempo-moderato"
158
+ },
159
+ {
160
+ "chainId": "43111",
161
+ "shortName": "hemi",
162
+ "enum": "HEMI"
163
+ },
164
+ {
165
+ "chainId": "43114",
166
+ "shortName": "avax",
167
+ "enum": "AVAX"
168
+ },
169
+ {
170
+ "chainId": "46630",
171
+ "shortName": "robinhood-testnet"
172
+ },
173
+ {
174
+ "chainId": "57073",
175
+ "shortName": "ink",
176
+ "enum": "INK"
177
+ },
178
+ {
179
+ "chainId": "59144",
180
+ "shortName": "linea",
181
+ "enum": "LINEA"
182
+ },
183
+ {
184
+ "chainId": "80069",
185
+ "shortName": "bep"
186
+ },
187
+ {
188
+ "chainId": "80094",
189
+ "shortName": "berachain",
190
+ "enum": "BERA"
191
+ },
192
+ {
193
+ "chainId": "81224",
194
+ "shortName": "codex"
195
+ },
196
+ {
197
+ "chainId": "84532",
198
+ "shortName": "basesep"
199
+ },
200
+ {
201
+ "chainId": "102030",
202
+ "shortName": "ctc"
203
+ },
204
+ {
205
+ "chainId": "534352",
206
+ "shortName": "scr",
207
+ "enum": "SCRL"
208
+ },
209
+ {
210
+ "chainId": "747474",
211
+ "shortName": "katana",
212
+ "enum": "KATANA"
213
+ },
214
+ {
215
+ "chainId": "5042002",
216
+ "shortName": "arc-testnet"
217
+ },
218
+ {
219
+ "chainId": "11142220",
220
+ "shortName": "celo-sep"
221
+ },
222
+ {
223
+ "chainId": "11155111",
224
+ "shortName": "sep"
225
+ },
226
+ {
227
+ "chainId": "1313161554",
228
+ "shortName": "aurora",
229
+ "enum": "AURORA"
230
+ }
231
+ ]
package/tsconfig.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "module": "ESNext",
7
7
  "target": "ES2020",
8
8
  "moduleResolution": "node",
9
+ "resolveJsonModule": true,
9
10
  "noImplicitAny": false,
10
11
  "strict": true,
11
12
  "esModuleInterop": true,