@rabby-wallet/gnosis-sdk 1.4.7 → 1.4.8-alpha-2
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 +42 -11
- package/dist/api.js +54 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/utils.js +2 -1
- package/package.json +1 -1
- package/src/api.ts +106 -13
- package/src/index.ts +9 -1
- package/src/utils.ts +2 -1
package/dist/api.d.ts
CHANGED
|
@@ -41,27 +41,58 @@ export interface SafeTransactionItem {
|
|
|
41
41
|
confirmations: ConfirmationItem[];
|
|
42
42
|
signatures: string | null;
|
|
43
43
|
}
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
export type SafeOpenApiService = {
|
|
45
|
+
getSafePendingTransactions?: (params: {
|
|
46
|
+
txServiceUrl: string;
|
|
47
|
+
safeAddress: string;
|
|
48
|
+
nonce: number;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
results: SafeTransactionItem[];
|
|
51
|
+
}>;
|
|
52
|
+
postSafeTransactions?: (params: {
|
|
53
|
+
txServiceUrl: string;
|
|
54
|
+
safeAddress: string;
|
|
55
|
+
data: Record<string, any>;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
getSafeInfo?: (params: {
|
|
58
|
+
txServiceUrl: string;
|
|
59
|
+
safeAddress: string;
|
|
60
|
+
}) => Promise<SafeInfo>;
|
|
61
|
+
confirmSafeTransaction?: (params: {
|
|
62
|
+
txServiceUrl: string;
|
|
63
|
+
safeTransactionHash: string;
|
|
64
|
+
data: Record<string, any>;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
getSafeTxGas?: (params: {
|
|
67
|
+
txServiceUrl: string;
|
|
68
|
+
safeAddress: string;
|
|
69
|
+
safeTxData: {
|
|
70
|
+
to: string;
|
|
71
|
+
value?: string;
|
|
72
|
+
data?: string | null;
|
|
73
|
+
operation?: number;
|
|
74
|
+
};
|
|
75
|
+
}) => Promise<string | undefined>;
|
|
50
76
|
};
|
|
51
|
-
export declare const
|
|
77
|
+
export declare const GNOSIS_SUPPORT_CHAINS: string[];
|
|
78
|
+
export declare const HOST_MAP: Record<string, string>;
|
|
79
|
+
export declare const getTxServiceUrl: (chainId: string) => string;
|
|
52
80
|
export default class RequestProvider {
|
|
53
|
-
|
|
81
|
+
prefix: string;
|
|
54
82
|
request: Axios;
|
|
55
|
-
|
|
83
|
+
openapiService?: SafeOpenApiService;
|
|
84
|
+
shouldUseOpenapiService: boolean;
|
|
85
|
+
constructor({ networkId, adapter, openapiService, }: {
|
|
56
86
|
networkId: string;
|
|
57
87
|
adapter?: AxiosAdapter;
|
|
88
|
+
openapiService?: SafeOpenApiService;
|
|
58
89
|
});
|
|
59
90
|
getPendingTransactions(safeAddress: string, nonce: number): Promise<{
|
|
60
91
|
results: SafeTransactionItem[];
|
|
61
92
|
}>;
|
|
62
|
-
postTransactions(safeAddres: string, data: any): Promise<void>;
|
|
93
|
+
postTransactions(safeAddres: string, data: Record<string, any>): Promise<void>;
|
|
63
94
|
getSafeInfo(safeAddress: string): Promise<SafeInfo>;
|
|
64
|
-
confirmTransaction(safeTransactionHash: string, data: any): Promise<void>;
|
|
95
|
+
confirmTransaction(safeTransactionHash: string, data: Record<string, any>): Promise<void>;
|
|
65
96
|
getSafeTxGas(safeAddress: string, safeVersion: string, safeTxData: SafeTransactionDataPartial): Promise<string | undefined>;
|
|
66
97
|
}
|
|
67
98
|
export {};
|
package/dist/api.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { isLegacyVersion } from "./utils";
|
|
3
3
|
import axios from "axios";
|
|
4
|
-
const TRANSACTION_SERVICE_URL = "https://api.rabby.io/v1/safe-tx-service";
|
|
5
4
|
// https://github.com/safe-global/safe-core-sdk/blob/main/packages/api-kit/src/utils/config.ts
|
|
6
5
|
const networks = [
|
|
7
6
|
{
|
|
@@ -208,19 +207,21 @@ export const HOST_MAP = {
|
|
|
208
207
|
export const getTxServiceUrl = (chainId) => {
|
|
209
208
|
const shortName = networkMap[chainId];
|
|
210
209
|
if (shortName) {
|
|
211
|
-
return
|
|
210
|
+
return `/v1/safe-tx-service/${shortName}/api`;
|
|
212
211
|
}
|
|
213
212
|
return HOST_MAP[chainId];
|
|
214
213
|
};
|
|
215
214
|
export default class RequestProvider {
|
|
216
|
-
constructor({ networkId, adapter, }) {
|
|
215
|
+
constructor({ networkId, adapter, openapiService, }) {
|
|
217
216
|
const txServiceUrl = getTxServiceUrl(networkId);
|
|
218
217
|
if (!txServiceUrl) {
|
|
219
218
|
throw new Error("Wrong networkId");
|
|
220
219
|
}
|
|
221
|
-
this.
|
|
220
|
+
this.prefix = txServiceUrl;
|
|
221
|
+
this.openapiService = openapiService;
|
|
222
|
+
this.shouldUseOpenapiService = !/^https?:\/\//i.test(this.prefix);
|
|
222
223
|
this.request = axios.create({
|
|
223
|
-
baseURL: this.
|
|
224
|
+
baseURL: this.prefix,
|
|
224
225
|
adapter,
|
|
225
226
|
});
|
|
226
227
|
this.request.interceptors.response.use((response) => {
|
|
@@ -228,7 +229,16 @@ export default class RequestProvider {
|
|
|
228
229
|
});
|
|
229
230
|
}
|
|
230
231
|
getPendingTransactions(safeAddress, nonce) {
|
|
231
|
-
|
|
232
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
233
|
+
if (this.shouldUseOpenapiService &&
|
|
234
|
+
this.openapiService?.getSafePendingTransactions) {
|
|
235
|
+
return this.openapiService.getSafePendingTransactions({
|
|
236
|
+
txServiceUrl: this.prefix,
|
|
237
|
+
safeAddress: checksumAddress,
|
|
238
|
+
nonce,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return this.request.get(`/v1/safes/${checksumAddress}/multisig-transactions/`, {
|
|
232
242
|
params: {
|
|
233
243
|
executed: false,
|
|
234
244
|
nonce__gte: nonce,
|
|
@@ -236,12 +246,36 @@ export default class RequestProvider {
|
|
|
236
246
|
});
|
|
237
247
|
}
|
|
238
248
|
postTransactions(safeAddres, data) {
|
|
239
|
-
|
|
249
|
+
const checksumAddress = ethers.utils.getAddress(safeAddres);
|
|
250
|
+
if (this.shouldUseOpenapiService &&
|
|
251
|
+
this.openapiService?.postSafeTransactions) {
|
|
252
|
+
return this.openapiService.postSafeTransactions({
|
|
253
|
+
txServiceUrl: this.prefix,
|
|
254
|
+
safeAddress: checksumAddress,
|
|
255
|
+
data,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return this.request.post(`/v1/safes/${checksumAddress}/multisig-transactions/`, data);
|
|
240
259
|
}
|
|
241
260
|
getSafeInfo(safeAddress) {
|
|
242
|
-
|
|
261
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
262
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeInfo) {
|
|
263
|
+
return this.openapiService.getSafeInfo({
|
|
264
|
+
txServiceUrl: this.prefix,
|
|
265
|
+
safeAddress: checksumAddress,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return this.request.get(`/v1/safes/${checksumAddress}/`);
|
|
243
269
|
}
|
|
244
270
|
confirmTransaction(safeTransactionHash, data) {
|
|
271
|
+
if (this.shouldUseOpenapiService &&
|
|
272
|
+
this.openapiService?.confirmSafeTransaction) {
|
|
273
|
+
return this.openapiService.confirmSafeTransaction({
|
|
274
|
+
txServiceUrl: this.prefix,
|
|
275
|
+
safeTransactionHash,
|
|
276
|
+
data,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
245
279
|
return this.request.post(`/v1/multisig-transactions/${safeTransactionHash}/confirmations/`, data);
|
|
246
280
|
}
|
|
247
281
|
// https://github.com/safe-global/safe-wallet-web/blob/dev/src/services/tx/tx-sender/recommendedNonce.ts#L24
|
|
@@ -251,6 +285,18 @@ export default class RequestProvider {
|
|
|
251
285
|
if (!isSafeTxGasRequired)
|
|
252
286
|
return "0";
|
|
253
287
|
const address = ethers.utils.getAddress(safeAddress);
|
|
288
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeTxGas) {
|
|
289
|
+
return this.openapiService.getSafeTxGas({
|
|
290
|
+
txServiceUrl: this.prefix,
|
|
291
|
+
safeAddress: address,
|
|
292
|
+
safeTxData: {
|
|
293
|
+
to: ethers.utils.getAddress(safeTxData.to),
|
|
294
|
+
value: safeTxData.value || "0",
|
|
295
|
+
data: safeTxData.data,
|
|
296
|
+
operation: safeTxData.operation,
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
}
|
|
254
300
|
try {
|
|
255
301
|
const estimation = await this.request.post(`/v1/safes/${address}/multisig-transactions/estimations/`, {
|
|
256
302
|
to: ethers.utils.getAddress(safeTxData.to),
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Contract, providers } from "ethers";
|
|
|
4
4
|
import { TransactionOptions, TransactionResult, SafeSignature, SafeTransaction, SafeTransactionDataPartial } from "@safe-global/types-kit";
|
|
5
5
|
import { EthSafeMessage, EthSafeTransaction } from "@safe-global/protocol-kit";
|
|
6
6
|
import SafeApiKit, { SafeMessage as ApiKitSafeMessage } from "@safe-global/api-kit";
|
|
7
|
-
import RequestProvider, { SafeInfo } from "./api";
|
|
7
|
+
import RequestProvider, { SafeInfo, SafeOpenApiService } from "./api";
|
|
8
8
|
declare class Safe {
|
|
9
9
|
contract: Contract;
|
|
10
10
|
safeAddress: string;
|
|
@@ -16,6 +16,7 @@ declare class Safe {
|
|
|
16
16
|
network: string;
|
|
17
17
|
apiKit: SafeApiKit;
|
|
18
18
|
static adapter: AxiosAdapter;
|
|
19
|
+
static openapiService?: SafeOpenApiService;
|
|
19
20
|
constructor(safeAddress: string, version: string, provider: providers.Web3Provider, network?: string);
|
|
20
21
|
/**
|
|
21
22
|
* @deprecated
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { calculateSafeMessageHash } from "@safe-global/protocol-kit/dist/src/uti
|
|
|
5
5
|
import SafeApiKit from "@safe-global/api-kit";
|
|
6
6
|
// import { getTransactionServiceUrl } from "@safe-global/api-kit/dist/src/utils/config";
|
|
7
7
|
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
8
|
-
import RequestProvider, { getTxServiceUrl } from "./api";
|
|
8
|
+
import RequestProvider, { getTxServiceUrl, } from "./api";
|
|
9
9
|
import { generatePreValidatedSignature, generateSignature, sameString, standardizeSafeTransactionData, } from "./utils";
|
|
10
10
|
class Safe {
|
|
11
11
|
constructor(safeAddress, version, provider, network = "1") {
|
|
@@ -56,6 +56,7 @@ class Safe {
|
|
|
56
56
|
this.request = new RequestProvider({
|
|
57
57
|
networkId: network,
|
|
58
58
|
adapter: Safe.adapter,
|
|
59
|
+
openapiService: Safe.openapiService,
|
|
59
60
|
});
|
|
60
61
|
this.apiKit = Safe.createSafeApiKit(network);
|
|
61
62
|
// this.init();
|
|
@@ -70,6 +71,7 @@ class Safe {
|
|
|
70
71
|
const request = new RequestProvider({
|
|
71
72
|
networkId: network,
|
|
72
73
|
adapter: Safe.adapter,
|
|
74
|
+
openapiService: Safe.openapiService,
|
|
73
75
|
});
|
|
74
76
|
return request.getSafeInfo(ethers.utils.getAddress(safeAddress));
|
|
75
77
|
}
|
|
@@ -77,6 +79,7 @@ class Safe {
|
|
|
77
79
|
const request = new RequestProvider({
|
|
78
80
|
networkId: network,
|
|
79
81
|
adapter: Safe.adapter,
|
|
82
|
+
openapiService: Safe.openapiService,
|
|
80
83
|
});
|
|
81
84
|
const transactions = await request.getPendingTransactions(safeAddress, nonce);
|
|
82
85
|
return transactions;
|
package/dist/utils.js
CHANGED
|
@@ -100,12 +100,13 @@ export async function standardizeSafeTransactionData(safeAddress, safeContract,
|
|
|
100
100
|
const request = new RequestProvider({
|
|
101
101
|
networkId: network,
|
|
102
102
|
adapter: Safe.adapter,
|
|
103
|
+
openapiService: Safe.openapiService,
|
|
103
104
|
});
|
|
104
105
|
const safeTxGas = tx.safeTxGas ??
|
|
105
106
|
(await request.getSafeTxGas(safeAddress, version, standardizedTxs));
|
|
106
107
|
return {
|
|
107
108
|
...standardizedTxs,
|
|
108
|
-
safeTxGas: safeTxGas || "0"
|
|
109
|
+
safeTxGas: `${safeTxGas || "0"}`,
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
export function generatePreValidatedSignature(ownerAddress) {
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -47,7 +47,37 @@ export interface SafeTransactionItem {
|
|
|
47
47
|
signatures: string | null;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
export type SafeOpenApiService = {
|
|
51
|
+
getSafePendingTransactions?: (params: {
|
|
52
|
+
txServiceUrl: string;
|
|
53
|
+
safeAddress: string;
|
|
54
|
+
nonce: number;
|
|
55
|
+
}) => Promise<{ results: SafeTransactionItem[] }>;
|
|
56
|
+
postSafeTransactions?: (params: {
|
|
57
|
+
txServiceUrl: string;
|
|
58
|
+
safeAddress: string;
|
|
59
|
+
data: Record<string, any>;
|
|
60
|
+
}) => Promise<void>;
|
|
61
|
+
getSafeInfo?: (params: {
|
|
62
|
+
txServiceUrl: string;
|
|
63
|
+
safeAddress: string;
|
|
64
|
+
}) => Promise<SafeInfo>;
|
|
65
|
+
confirmSafeTransaction?: (params: {
|
|
66
|
+
txServiceUrl: string;
|
|
67
|
+
safeTransactionHash: string;
|
|
68
|
+
data: Record<string, any>;
|
|
69
|
+
}) => Promise<void>;
|
|
70
|
+
getSafeTxGas?: (params: {
|
|
71
|
+
txServiceUrl: string;
|
|
72
|
+
safeAddress: string;
|
|
73
|
+
safeTxData: {
|
|
74
|
+
to: string;
|
|
75
|
+
value?: string;
|
|
76
|
+
data?: string | null;
|
|
77
|
+
operation?: number;
|
|
78
|
+
};
|
|
79
|
+
}) => Promise<string | undefined>;
|
|
80
|
+
};
|
|
51
81
|
|
|
52
82
|
type NetworkShortName = {
|
|
53
83
|
shortName: string;
|
|
@@ -257,7 +287,7 @@ const networkMap = networks.reduce<Record<string, string>>(
|
|
|
257
287
|
{}
|
|
258
288
|
);
|
|
259
289
|
|
|
260
|
-
export const HOST_MAP = {
|
|
290
|
+
export const HOST_MAP: Record<string, string> = {
|
|
261
291
|
/**
|
|
262
292
|
* blast
|
|
263
293
|
*/
|
|
@@ -267,31 +297,37 @@ export const HOST_MAP = {
|
|
|
267
297
|
export const getTxServiceUrl = (chainId: string) => {
|
|
268
298
|
const shortName = networkMap[chainId];
|
|
269
299
|
if (shortName) {
|
|
270
|
-
return
|
|
300
|
+
return `/v1/safe-tx-service/${shortName}/api`;
|
|
271
301
|
}
|
|
272
302
|
return HOST_MAP[chainId];
|
|
273
303
|
};
|
|
274
304
|
|
|
275
305
|
export default class RequestProvider {
|
|
276
|
-
|
|
306
|
+
prefix: string;
|
|
277
307
|
request: Axios;
|
|
308
|
+
openapiService?: SafeOpenApiService;
|
|
309
|
+
shouldUseOpenapiService: boolean;
|
|
278
310
|
|
|
279
311
|
constructor({
|
|
280
312
|
networkId,
|
|
281
313
|
adapter,
|
|
314
|
+
openapiService,
|
|
282
315
|
}: {
|
|
283
316
|
networkId: string;
|
|
284
317
|
adapter?: AxiosAdapter;
|
|
318
|
+
openapiService?: SafeOpenApiService;
|
|
285
319
|
}) {
|
|
286
320
|
const txServiceUrl = getTxServiceUrl(networkId);
|
|
287
321
|
if (!txServiceUrl) {
|
|
288
322
|
throw new Error("Wrong networkId");
|
|
289
323
|
}
|
|
290
324
|
|
|
291
|
-
this.
|
|
325
|
+
this.prefix = txServiceUrl;
|
|
326
|
+
this.openapiService = openapiService;
|
|
327
|
+
this.shouldUseOpenapiService = !/^https?:\/\//i.test(this.prefix);
|
|
292
328
|
|
|
293
329
|
this.request = axios.create({
|
|
294
|
-
baseURL: this.
|
|
330
|
+
baseURL: this.prefix,
|
|
295
331
|
adapter,
|
|
296
332
|
});
|
|
297
333
|
|
|
@@ -304,10 +340,20 @@ export default class RequestProvider {
|
|
|
304
340
|
safeAddress: string,
|
|
305
341
|
nonce: number
|
|
306
342
|
): Promise<{ results: SafeTransactionItem[] }> {
|
|
343
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
344
|
+
if (
|
|
345
|
+
this.shouldUseOpenapiService &&
|
|
346
|
+
this.openapiService?.getSafePendingTransactions
|
|
347
|
+
) {
|
|
348
|
+
return this.openapiService.getSafePendingTransactions({
|
|
349
|
+
txServiceUrl: this.prefix,
|
|
350
|
+
safeAddress: checksumAddress,
|
|
351
|
+
nonce,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
307
355
|
return this.request.get(
|
|
308
|
-
`/v1/safes/${
|
|
309
|
-
safeAddress
|
|
310
|
-
)}/multisig-transactions/`,
|
|
356
|
+
`/v1/safes/${checksumAddress}/multisig-transactions/`,
|
|
311
357
|
{
|
|
312
358
|
params: {
|
|
313
359
|
executed: false,
|
|
@@ -317,20 +363,54 @@ export default class RequestProvider {
|
|
|
317
363
|
);
|
|
318
364
|
}
|
|
319
365
|
|
|
320
|
-
postTransactions(safeAddres: string, data): Promise<void> {
|
|
366
|
+
postTransactions(safeAddres: string, data: Record<string, any>): Promise<void> {
|
|
367
|
+
const checksumAddress = ethers.utils.getAddress(safeAddres);
|
|
368
|
+
if (
|
|
369
|
+
this.shouldUseOpenapiService &&
|
|
370
|
+
this.openapiService?.postSafeTransactions
|
|
371
|
+
) {
|
|
372
|
+
return this.openapiService.postSafeTransactions({
|
|
373
|
+
txServiceUrl: this.prefix,
|
|
374
|
+
safeAddress: checksumAddress,
|
|
375
|
+
data,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
321
379
|
return this.request.post(
|
|
322
|
-
`/v1/safes/${
|
|
380
|
+
`/v1/safes/${checksumAddress}/multisig-transactions/`,
|
|
323
381
|
data
|
|
324
382
|
);
|
|
325
383
|
}
|
|
326
384
|
|
|
327
385
|
getSafeInfo(safeAddress: string): Promise<SafeInfo> {
|
|
386
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
387
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeInfo) {
|
|
388
|
+
return this.openapiService.getSafeInfo({
|
|
389
|
+
txServiceUrl: this.prefix,
|
|
390
|
+
safeAddress: checksumAddress,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
328
394
|
return this.request.get(
|
|
329
|
-
`/v1/safes/${
|
|
395
|
+
`/v1/safes/${checksumAddress}/`
|
|
330
396
|
);
|
|
331
397
|
}
|
|
332
398
|
|
|
333
|
-
confirmTransaction(
|
|
399
|
+
confirmTransaction(
|
|
400
|
+
safeTransactionHash: string,
|
|
401
|
+
data: Record<string, any>
|
|
402
|
+
): Promise<void> {
|
|
403
|
+
if (
|
|
404
|
+
this.shouldUseOpenapiService &&
|
|
405
|
+
this.openapiService?.confirmSafeTransaction
|
|
406
|
+
) {
|
|
407
|
+
return this.openapiService.confirmSafeTransaction({
|
|
408
|
+
txServiceUrl: this.prefix,
|
|
409
|
+
safeTransactionHash,
|
|
410
|
+
data,
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
334
414
|
return this.request.post(
|
|
335
415
|
`/v1/multisig-transactions/${safeTransactionHash}/confirmations/`,
|
|
336
416
|
data
|
|
@@ -350,6 +430,19 @@ export default class RequestProvider {
|
|
|
350
430
|
|
|
351
431
|
const address = ethers.utils.getAddress(safeAddress);
|
|
352
432
|
|
|
433
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeTxGas) {
|
|
434
|
+
return this.openapiService.getSafeTxGas({
|
|
435
|
+
txServiceUrl: this.prefix,
|
|
436
|
+
safeAddress: address,
|
|
437
|
+
safeTxData: {
|
|
438
|
+
to: ethers.utils.getAddress(safeTxData.to),
|
|
439
|
+
value: safeTxData.value || "0",
|
|
440
|
+
data: safeTxData.data,
|
|
441
|
+
operation: safeTxData.operation,
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
353
446
|
try {
|
|
354
447
|
const estimation: { safeTxGas: string } = await this.request.post(
|
|
355
448
|
`/v1/safes/${address}/multisig-transactions/estimations/`,
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,11 @@ import SafeApiKit, {
|
|
|
16
16
|
} from "@safe-global/api-kit";
|
|
17
17
|
// import { getTransactionServiceUrl } from "@safe-global/api-kit/dist/src/utils/config";
|
|
18
18
|
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
19
|
-
import RequestProvider, {
|
|
19
|
+
import RequestProvider, {
|
|
20
|
+
getTxServiceUrl,
|
|
21
|
+
SafeInfo,
|
|
22
|
+
SafeOpenApiService,
|
|
23
|
+
} from "./api";
|
|
20
24
|
import {
|
|
21
25
|
estimateGasForTransactionExecution,
|
|
22
26
|
generatePreValidatedSignature,
|
|
@@ -37,6 +41,7 @@ class Safe {
|
|
|
37
41
|
apiKit: SafeApiKit;
|
|
38
42
|
|
|
39
43
|
static adapter: AxiosAdapter;
|
|
44
|
+
static openapiService?: SafeOpenApiService;
|
|
40
45
|
|
|
41
46
|
constructor(
|
|
42
47
|
safeAddress: string,
|
|
@@ -59,6 +64,7 @@ class Safe {
|
|
|
59
64
|
this.request = new RequestProvider({
|
|
60
65
|
networkId: network,
|
|
61
66
|
adapter: Safe.adapter,
|
|
67
|
+
openapiService: Safe.openapiService,
|
|
62
68
|
});
|
|
63
69
|
this.apiKit = Safe.createSafeApiKit(network);
|
|
64
70
|
|
|
@@ -75,6 +81,7 @@ class Safe {
|
|
|
75
81
|
const request = new RequestProvider({
|
|
76
82
|
networkId: network,
|
|
77
83
|
adapter: Safe.adapter,
|
|
84
|
+
openapiService: Safe.openapiService,
|
|
78
85
|
});
|
|
79
86
|
return request.getSafeInfo(ethers.utils.getAddress(safeAddress));
|
|
80
87
|
}
|
|
@@ -87,6 +94,7 @@ class Safe {
|
|
|
87
94
|
const request = new RequestProvider({
|
|
88
95
|
networkId: network,
|
|
89
96
|
adapter: Safe.adapter,
|
|
97
|
+
openapiService: Safe.openapiService,
|
|
90
98
|
});
|
|
91
99
|
const transactions = await request.getPendingTransactions(
|
|
92
100
|
safeAddress,
|
package/src/utils.ts
CHANGED
|
@@ -135,13 +135,14 @@ export async function standardizeSafeTransactionData(
|
|
|
135
135
|
const request = new RequestProvider({
|
|
136
136
|
networkId: network,
|
|
137
137
|
adapter: Safe.adapter,
|
|
138
|
+
openapiService: Safe.openapiService,
|
|
138
139
|
});
|
|
139
140
|
const safeTxGas =
|
|
140
141
|
tx.safeTxGas ??
|
|
141
142
|
(await request.getSafeTxGas(safeAddress, version, standardizedTxs));
|
|
142
143
|
return {
|
|
143
144
|
...standardizedTxs,
|
|
144
|
-
safeTxGas: safeTxGas || "0"
|
|
145
|
+
safeTxGas: `${safeTxGas || "0"}`,
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
|