@rabby-wallet/gnosis-sdk 1.4.8-alpha-2 → 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 +24 -0
- package/dist/api.js +24 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +10 -1
- package/package.json +1 -1
- package/src/api.ts +52 -0
- package/src/index.ts +12 -1
package/dist/api.d.ts
CHANGED
|
@@ -73,6 +73,22 @@ 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
94
|
export declare const HOST_MAP: Record<string, string>;
|
|
@@ -94,5 +110,13 @@ export default class RequestProvider {
|
|
|
94
110
|
getSafeInfo(safeAddress: string): Promise<SafeInfo>;
|
|
95
111
|
confirmTransaction(safeTransactionHash: string, data: Record<string, any>): Promise<void>;
|
|
96
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>;
|
|
97
121
|
}
|
|
98
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/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 = {
|
|
@@ -458,4 +472,42 @@ export default class RequestProvider {
|
|
|
458
472
|
console.error(e);
|
|
459
473
|
}
|
|
460
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
|
+
}
|
|
461
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;
|