@rabby-wallet/gnosis-sdk 1.4.8-alpha-1 → 1.4.8-alpha-3
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 +28 -9
- package/dist/api.js +24 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +10 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/src/api.ts +58 -3
- package/src/index.ts +12 -1
- package/src/utils.ts +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -73,15 +73,26 @@ export type SafeOpenApiService = {
|
|
|
73
73
|
operation?: number;
|
|
74
74
|
};
|
|
75
75
|
}) => Promise<string | undefined>;
|
|
76
|
+
getSafeMessages?: (params: {
|
|
77
|
+
txServiceUrl: string;
|
|
78
|
+
safeAddress: string;
|
|
79
|
+
options?: Record<string, any>;
|
|
80
|
+
}) => Promise<{
|
|
81
|
+
results: any[];
|
|
82
|
+
}>;
|
|
83
|
+
addSafeMessage?: (params: {
|
|
84
|
+
txServiceUrl: string;
|
|
85
|
+
safeAddress: string;
|
|
86
|
+
data: {
|
|
87
|
+
message: string | Record<string, any>;
|
|
88
|
+
signature: string;
|
|
89
|
+
safeAppId?: number;
|
|
90
|
+
};
|
|
91
|
+
}) => Promise<void>;
|
|
76
92
|
};
|
|
77
93
|
export declare const GNOSIS_SUPPORT_CHAINS: string[];
|
|
78
|
-
export declare const HOST_MAP:
|
|
79
|
-
|
|
80
|
-
* blast
|
|
81
|
-
*/
|
|
82
|
-
"81457": string;
|
|
83
|
-
};
|
|
84
|
-
export declare const getTxServiceUrl: (chainId: string) => any;
|
|
94
|
+
export declare const HOST_MAP: Record<string, string>;
|
|
95
|
+
export declare const getTxServiceUrl: (chainId: string) => string;
|
|
85
96
|
export default class RequestProvider {
|
|
86
97
|
prefix: string;
|
|
87
98
|
request: Axios;
|
|
@@ -95,9 +106,17 @@ export default class RequestProvider {
|
|
|
95
106
|
getPendingTransactions(safeAddress: string, nonce: number): Promise<{
|
|
96
107
|
results: SafeTransactionItem[];
|
|
97
108
|
}>;
|
|
98
|
-
postTransactions(safeAddres: string, data: any): Promise<void>;
|
|
109
|
+
postTransactions(safeAddres: string, data: Record<string, any>): Promise<void>;
|
|
99
110
|
getSafeInfo(safeAddress: string): Promise<SafeInfo>;
|
|
100
|
-
confirmTransaction(safeTransactionHash: string, data: any): Promise<void>;
|
|
111
|
+
confirmTransaction(safeTransactionHash: string, data: Record<string, any>): Promise<void>;
|
|
101
112
|
getSafeTxGas(safeAddress: string, safeVersion: string, safeTxData: SafeTransactionDataPartial): Promise<string | undefined>;
|
|
113
|
+
getMessages(safeAddress: string, options?: Record<string, any>): Promise<{
|
|
114
|
+
results: any[];
|
|
115
|
+
}>;
|
|
116
|
+
addMessage(safeAddress: string, data: {
|
|
117
|
+
message: string | Record<string, any>;
|
|
118
|
+
signature: string;
|
|
119
|
+
safeAppId?: number;
|
|
120
|
+
}): Promise<void>;
|
|
102
121
|
}
|
|
103
122
|
export {};
|
package/dist/api.js
CHANGED
|
@@ -310,4 +310,28 @@ export default class RequestProvider {
|
|
|
310
310
|
console.error(e);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
+
getMessages(safeAddress, options) {
|
|
314
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
315
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeMessages) {
|
|
316
|
+
return this.openapiService.getSafeMessages({
|
|
317
|
+
txServiceUrl: this.prefix,
|
|
318
|
+
safeAddress: checksumAddress,
|
|
319
|
+
options,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return this.request.get(`/v1/safes/${checksumAddress}/messages/`, {
|
|
323
|
+
params: options,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
addMessage(safeAddress, data) {
|
|
327
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
328
|
+
if (this.shouldUseOpenapiService && this.openapiService?.addSafeMessage) {
|
|
329
|
+
return this.openapiService.addSafeMessage({
|
|
330
|
+
txServiceUrl: this.prefix,
|
|
331
|
+
safeAddress: checksumAddress,
|
|
332
|
+
data,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return this.request.post(`/v1/safes/${checksumAddress}/messages/`, data);
|
|
336
|
+
}
|
|
313
337
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AxiosAdapter } from "axios";
|
|
|
3
3
|
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
|
-
import SafeApiKit, { SafeMessage as ApiKitSafeMessage } from "@safe-global/api-kit";
|
|
6
|
+
import SafeApiKit, { GetSafeMessageListOptions, SafeMessage as ApiKitSafeMessage } from "@safe-global/api-kit";
|
|
7
7
|
import RequestProvider, { SafeInfo, SafeOpenApiService } from "./api";
|
|
8
8
|
declare class Safe {
|
|
9
9
|
contract: Contract;
|
|
@@ -75,6 +75,9 @@ declare class Safe {
|
|
|
75
75
|
addMessage({ safeMessage, }: {
|
|
76
76
|
safeMessage: EthSafeMessage;
|
|
77
77
|
}): Promise<void>;
|
|
78
|
+
getMessages(options?: GetSafeMessageListOptions): Promise<{
|
|
79
|
+
results: any[];
|
|
80
|
+
}>;
|
|
78
81
|
}
|
|
79
82
|
export default Safe;
|
|
80
83
|
export type BasicSafeInfo = Awaited<ReturnType<Safe["getBasicSafeInfo"]>>;
|
package/dist/index.js
CHANGED
|
@@ -249,7 +249,7 @@ class Safe {
|
|
|
249
249
|
async addMessage({ safeMessage, }) {
|
|
250
250
|
const safeAddress = this.safeAddress;
|
|
251
251
|
try {
|
|
252
|
-
return this.
|
|
252
|
+
return this.request.addMessage(safeAddress, {
|
|
253
253
|
message: safeMessage.data,
|
|
254
254
|
signature: safeMessage.encodedSignatures(),
|
|
255
255
|
});
|
|
@@ -258,6 +258,15 @@ class Safe {
|
|
|
258
258
|
throw new Error("Could not add a new off-chain message to the Safe account");
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
+
async getMessages(options) {
|
|
262
|
+
const safeAddress = this.safeAddress;
|
|
263
|
+
try {
|
|
264
|
+
return this.request.getMessages(safeAddress, options);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
throw new Error("Could not get off-chain messages of the Safe account");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
261
270
|
}
|
|
262
271
|
Safe.createSafeApiKit = (network) => {
|
|
263
272
|
return new SafeApiKit({
|
package/dist/utils.js
CHANGED
|
@@ -106,7 +106,7 @@ export async function standardizeSafeTransactionData(safeAddress, safeContract,
|
|
|
106
106
|
(await request.getSafeTxGas(safeAddress, version, standardizedTxs));
|
|
107
107
|
return {
|
|
108
108
|
...standardizedTxs,
|
|
109
|
-
safeTxGas: safeTxGas || "0"
|
|
109
|
+
safeTxGas: `${safeTxGas || "0"}`,
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
export function generatePreValidatedSignature(ownerAddress) {
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -77,6 +77,20 @@ export type SafeOpenApiService = {
|
|
|
77
77
|
operation?: number;
|
|
78
78
|
};
|
|
79
79
|
}) => Promise<string | undefined>;
|
|
80
|
+
getSafeMessages?: (params: {
|
|
81
|
+
txServiceUrl: string;
|
|
82
|
+
safeAddress: string;
|
|
83
|
+
options?: Record<string, any>;
|
|
84
|
+
}) => Promise<{ results: any[] }>;
|
|
85
|
+
addSafeMessage?: (params: {
|
|
86
|
+
txServiceUrl: string;
|
|
87
|
+
safeAddress: string;
|
|
88
|
+
data: {
|
|
89
|
+
message: string | Record<string, any>;
|
|
90
|
+
signature: string;
|
|
91
|
+
safeAppId?: number;
|
|
92
|
+
};
|
|
93
|
+
}) => Promise<void>;
|
|
80
94
|
};
|
|
81
95
|
|
|
82
96
|
type NetworkShortName = {
|
|
@@ -287,7 +301,7 @@ const networkMap = networks.reduce<Record<string, string>>(
|
|
|
287
301
|
{}
|
|
288
302
|
);
|
|
289
303
|
|
|
290
|
-
export const HOST_MAP = {
|
|
304
|
+
export const HOST_MAP: Record<string, string> = {
|
|
291
305
|
/**
|
|
292
306
|
* blast
|
|
293
307
|
*/
|
|
@@ -363,7 +377,7 @@ export default class RequestProvider {
|
|
|
363
377
|
);
|
|
364
378
|
}
|
|
365
379
|
|
|
366
|
-
postTransactions(safeAddres: string, data): Promise<void> {
|
|
380
|
+
postTransactions(safeAddres: string, data: Record<string, any>): Promise<void> {
|
|
367
381
|
const checksumAddress = ethers.utils.getAddress(safeAddres);
|
|
368
382
|
if (
|
|
369
383
|
this.shouldUseOpenapiService &&
|
|
@@ -396,7 +410,10 @@ export default class RequestProvider {
|
|
|
396
410
|
);
|
|
397
411
|
}
|
|
398
412
|
|
|
399
|
-
confirmTransaction(
|
|
413
|
+
confirmTransaction(
|
|
414
|
+
safeTransactionHash: string,
|
|
415
|
+
data: Record<string, any>
|
|
416
|
+
): Promise<void> {
|
|
400
417
|
if (
|
|
401
418
|
this.shouldUseOpenapiService &&
|
|
402
419
|
this.openapiService?.confirmSafeTransaction
|
|
@@ -455,4 +472,42 @@ export default class RequestProvider {
|
|
|
455
472
|
console.error(e);
|
|
456
473
|
}
|
|
457
474
|
}
|
|
475
|
+
|
|
476
|
+
getMessages(
|
|
477
|
+
safeAddress: string,
|
|
478
|
+
options?: Record<string, any>
|
|
479
|
+
): Promise<{ results: any[] }> {
|
|
480
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
481
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeMessages) {
|
|
482
|
+
return this.openapiService.getSafeMessages({
|
|
483
|
+
txServiceUrl: this.prefix,
|
|
484
|
+
safeAddress: checksumAddress,
|
|
485
|
+
options,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return this.request.get(`/v1/safes/${checksumAddress}/messages/`, {
|
|
490
|
+
params: options,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
addMessage(
|
|
495
|
+
safeAddress: string,
|
|
496
|
+
data: {
|
|
497
|
+
message: string | Record<string, any>;
|
|
498
|
+
signature: string;
|
|
499
|
+
safeAppId?: number;
|
|
500
|
+
}
|
|
501
|
+
): Promise<void> {
|
|
502
|
+
const checksumAddress = ethers.utils.getAddress(safeAddress);
|
|
503
|
+
if (this.shouldUseOpenapiService && this.openapiService?.addSafeMessage) {
|
|
504
|
+
return this.openapiService.addSafeMessage({
|
|
505
|
+
txServiceUrl: this.prefix,
|
|
506
|
+
safeAddress: checksumAddress,
|
|
507
|
+
data,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return this.request.post(`/v1/safes/${checksumAddress}/messages/`, data);
|
|
512
|
+
}
|
|
458
513
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { EthSafeMessage, EthSafeTransaction } from "@safe-global/protocol-kit";
|
|
13
13
|
import { calculateSafeMessageHash } from "@safe-global/protocol-kit/dist/src/utils";
|
|
14
14
|
import SafeApiKit, {
|
|
15
|
+
GetSafeMessageListOptions,
|
|
15
16
|
SafeMessage as ApiKitSafeMessage,
|
|
16
17
|
} from "@safe-global/api-kit";
|
|
17
18
|
// import { getTransactionServiceUrl } from "@safe-global/api-kit/dist/src/utils/config";
|
|
@@ -402,7 +403,7 @@ class Safe {
|
|
|
402
403
|
const safeAddress = this.safeAddress;
|
|
403
404
|
|
|
404
405
|
try {
|
|
405
|
-
return this.
|
|
406
|
+
return this.request.addMessage(safeAddress, {
|
|
406
407
|
message: safeMessage.data as string | ApiKitEIP712TypedData,
|
|
407
408
|
signature: safeMessage.encodedSignatures(),
|
|
408
409
|
});
|
|
@@ -412,6 +413,16 @@ class Safe {
|
|
|
412
413
|
);
|
|
413
414
|
}
|
|
414
415
|
}
|
|
416
|
+
|
|
417
|
+
async getMessages(options?: GetSafeMessageListOptions) {
|
|
418
|
+
const safeAddress = this.safeAddress;
|
|
419
|
+
|
|
420
|
+
try {
|
|
421
|
+
return this.request.getMessages(safeAddress, options);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
throw new Error("Could not get off-chain messages of the Safe account");
|
|
424
|
+
}
|
|
425
|
+
}
|
|
415
426
|
}
|
|
416
427
|
|
|
417
428
|
export default Safe;
|
package/src/utils.ts
CHANGED