@rabby-wallet/gnosis-sdk 1.4.8-alpha-3 → 1.4.8-alpha-4
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 +11 -0
- package/dist/api.js +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +24 -0
- package/package.json +1 -1
- package/src/api.ts +37 -0
- package/src/index.ts +27 -0
package/dist/api.d.ts
CHANGED
|
@@ -89,6 +89,15 @@ export type SafeOpenApiService = {
|
|
|
89
89
|
safeAppId?: number;
|
|
90
90
|
};
|
|
91
91
|
}) => Promise<void>;
|
|
92
|
+
getSafeMessage?: (params: {
|
|
93
|
+
txServiceUrl: string;
|
|
94
|
+
messageHash: string;
|
|
95
|
+
}) => Promise<any>;
|
|
96
|
+
addSafeMessageSignature?: (params: {
|
|
97
|
+
txServiceUrl: string;
|
|
98
|
+
messageHash: string;
|
|
99
|
+
signature: string;
|
|
100
|
+
}) => Promise<void>;
|
|
92
101
|
};
|
|
93
102
|
export declare const GNOSIS_SUPPORT_CHAINS: string[];
|
|
94
103
|
export declare const HOST_MAP: Record<string, string>;
|
|
@@ -118,5 +127,7 @@ export default class RequestProvider {
|
|
|
118
127
|
signature: string;
|
|
119
128
|
safeAppId?: number;
|
|
120
129
|
}): Promise<void>;
|
|
130
|
+
getMessage(messageHash: string): Promise<any>;
|
|
131
|
+
addMessageSignature(messageHash: string, signature: string): Promise<void>;
|
|
121
132
|
}
|
|
122
133
|
export {};
|
package/dist/api.js
CHANGED
|
@@ -334,4 +334,26 @@ export default class RequestProvider {
|
|
|
334
334
|
}
|
|
335
335
|
return this.request.post(`/v1/safes/${checksumAddress}/messages/`, data);
|
|
336
336
|
}
|
|
337
|
+
getMessage(messageHash) {
|
|
338
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeMessage) {
|
|
339
|
+
return this.openapiService.getSafeMessage({
|
|
340
|
+
txServiceUrl: this.prefix,
|
|
341
|
+
messageHash,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
return this.request.get(`/v1/messages/${messageHash}/`);
|
|
345
|
+
}
|
|
346
|
+
addMessageSignature(messageHash, signature) {
|
|
347
|
+
if (this.shouldUseOpenapiService &&
|
|
348
|
+
this.openapiService?.addSafeMessageSignature) {
|
|
349
|
+
return this.openapiService.addSafeMessageSignature({
|
|
350
|
+
txServiceUrl: this.prefix,
|
|
351
|
+
messageHash,
|
|
352
|
+
signature,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return this.request.post(`/v1/messages/${messageHash}/signatures/`, {
|
|
356
|
+
signature,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
337
359
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare class Safe {
|
|
|
28
28
|
static getPendingTransactions(safeAddress: string, network: string, nonce: number): Promise<{
|
|
29
29
|
results: import("./api").SafeTransactionItem[];
|
|
30
30
|
}>;
|
|
31
|
+
static getMessage(messageHash: string, network: string): Promise<any>;
|
|
31
32
|
static createSafeApiKit: (network: string) => SafeApiKit;
|
|
32
33
|
getPendingTransactions(): Promise<{
|
|
33
34
|
results: import("./api").SafeTransactionItem[];
|
|
@@ -78,6 +79,8 @@ declare class Safe {
|
|
|
78
79
|
getMessages(options?: GetSafeMessageListOptions): Promise<{
|
|
79
80
|
results: any[];
|
|
80
81
|
}>;
|
|
82
|
+
getMessage(messageHash: string): Promise<any>;
|
|
83
|
+
addMessageSignature(messageHash: string, signature: string): Promise<void>;
|
|
81
84
|
}
|
|
82
85
|
export default Safe;
|
|
83
86
|
export type BasicSafeInfo = Awaited<ReturnType<Safe["getBasicSafeInfo"]>>;
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,14 @@ class Safe {
|
|
|
84
84
|
const transactions = await request.getPendingTransactions(safeAddress, nonce);
|
|
85
85
|
return transactions;
|
|
86
86
|
}
|
|
87
|
+
static async getMessage(messageHash, network) {
|
|
88
|
+
const request = new RequestProvider({
|
|
89
|
+
networkId: network,
|
|
90
|
+
adapter: Safe.adapter,
|
|
91
|
+
openapiService: Safe.openapiService,
|
|
92
|
+
});
|
|
93
|
+
return request.getMessage(messageHash);
|
|
94
|
+
}
|
|
87
95
|
async getPendingTransactions() {
|
|
88
96
|
const nonce = await this.getNonce();
|
|
89
97
|
const transactions = await this.request.getPendingTransactions(this.safeAddress, nonce);
|
|
@@ -267,6 +275,22 @@ class Safe {
|
|
|
267
275
|
throw new Error("Could not get off-chain messages of the Safe account");
|
|
268
276
|
}
|
|
269
277
|
}
|
|
278
|
+
async getMessage(messageHash) {
|
|
279
|
+
try {
|
|
280
|
+
return this.request.getMessage(messageHash);
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
throw new Error("Could not get off-chain message of the Safe account");
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async addMessageSignature(messageHash, signature) {
|
|
287
|
+
try {
|
|
288
|
+
return this.request.addMessageSignature(messageHash, signature);
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
throw new Error("Could not add an off-chain message signature to the Safe account");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
270
294
|
}
|
|
271
295
|
Safe.createSafeApiKit = (network) => {
|
|
272
296
|
return new SafeApiKit({
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -91,6 +91,15 @@ export type SafeOpenApiService = {
|
|
|
91
91
|
safeAppId?: number;
|
|
92
92
|
};
|
|
93
93
|
}) => Promise<void>;
|
|
94
|
+
getSafeMessage?: (params: {
|
|
95
|
+
txServiceUrl: string;
|
|
96
|
+
messageHash: string;
|
|
97
|
+
}) => Promise<any>;
|
|
98
|
+
addSafeMessageSignature?: (params: {
|
|
99
|
+
txServiceUrl: string;
|
|
100
|
+
messageHash: string;
|
|
101
|
+
signature: string;
|
|
102
|
+
}) => Promise<void>;
|
|
94
103
|
};
|
|
95
104
|
|
|
96
105
|
type NetworkShortName = {
|
|
@@ -510,4 +519,32 @@ export default class RequestProvider {
|
|
|
510
519
|
|
|
511
520
|
return this.request.post(`/v1/safes/${checksumAddress}/messages/`, data);
|
|
512
521
|
}
|
|
522
|
+
|
|
523
|
+
getMessage(messageHash: string): Promise<any> {
|
|
524
|
+
if (this.shouldUseOpenapiService && this.openapiService?.getSafeMessage) {
|
|
525
|
+
return this.openapiService.getSafeMessage({
|
|
526
|
+
txServiceUrl: this.prefix,
|
|
527
|
+
messageHash,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return this.request.get(`/v1/messages/${messageHash}/`);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
addMessageSignature(messageHash: string, signature: string): Promise<void> {
|
|
535
|
+
if (
|
|
536
|
+
this.shouldUseOpenapiService &&
|
|
537
|
+
this.openapiService?.addSafeMessageSignature
|
|
538
|
+
) {
|
|
539
|
+
return this.openapiService.addSafeMessageSignature({
|
|
540
|
+
txServiceUrl: this.prefix,
|
|
541
|
+
messageHash,
|
|
542
|
+
signature,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return this.request.post(`/v1/messages/${messageHash}/signatures/`, {
|
|
547
|
+
signature,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
513
550
|
}
|
package/src/index.ts
CHANGED
|
@@ -105,6 +105,15 @@ class Safe {
|
|
|
105
105
|
return transactions;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
static async getMessage(messageHash: string, network: string) {
|
|
109
|
+
const request = new RequestProvider({
|
|
110
|
+
networkId: network,
|
|
111
|
+
adapter: Safe.adapter,
|
|
112
|
+
openapiService: Safe.openapiService,
|
|
113
|
+
});
|
|
114
|
+
return request.getMessage(messageHash);
|
|
115
|
+
}
|
|
116
|
+
|
|
108
117
|
static createSafeApiKit = (network: string) => {
|
|
109
118
|
return new SafeApiKit({
|
|
110
119
|
chainId: BigInt(network),
|
|
@@ -423,6 +432,24 @@ class Safe {
|
|
|
423
432
|
throw new Error("Could not get off-chain messages of the Safe account");
|
|
424
433
|
}
|
|
425
434
|
}
|
|
435
|
+
|
|
436
|
+
async getMessage(messageHash: string) {
|
|
437
|
+
try {
|
|
438
|
+
return this.request.getMessage(messageHash);
|
|
439
|
+
} catch (error) {
|
|
440
|
+
throw new Error("Could not get off-chain message of the Safe account");
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async addMessageSignature(messageHash: string, signature: string) {
|
|
445
|
+
try {
|
|
446
|
+
return this.request.addMessageSignature(messageHash, signature);
|
|
447
|
+
} catch (error) {
|
|
448
|
+
throw new Error(
|
|
449
|
+
"Could not add an off-chain message signature to the Safe account",
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
426
453
|
}
|
|
427
454
|
|
|
428
455
|
export default Safe;
|