@rabby-wallet/gnosis-sdk 1.4.4 → 1.4.5-alpha.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 +5 -1
- package/dist/api.js +7 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -5
- package/dist/utils.js +6 -2
- package/package.json +2 -2
- package/src/api.ts +22 -4
- package/src/index.ts +22 -6
- package/src/utils.ts +8 -4
package/dist/api.d.ts
CHANGED
|
@@ -138,7 +138,11 @@ export declare const HOST_MAP: {
|
|
|
138
138
|
export default class RequestProvider {
|
|
139
139
|
host: string;
|
|
140
140
|
request: Axios;
|
|
141
|
-
constructor(networkId
|
|
141
|
+
constructor({ networkId, adapter, apiKey, }: {
|
|
142
|
+
networkId: string;
|
|
143
|
+
adapter?: AxiosAdapter;
|
|
144
|
+
apiKey: string;
|
|
145
|
+
});
|
|
142
146
|
getPendingTransactions(safeAddress: string, nonce: number): Promise<{
|
|
143
147
|
results: SafeTransactionItem[];
|
|
144
148
|
}>;
|
package/dist/api.js
CHANGED
|
@@ -93,10 +93,10 @@ export const HOST_MAP = {
|
|
|
93
93
|
/**
|
|
94
94
|
* Katana
|
|
95
95
|
*/
|
|
96
|
-
"747474": "https://safe-transaction-katana.safe.global/api"
|
|
96
|
+
"747474": "https://safe-transaction-katana.safe.global/api",
|
|
97
97
|
};
|
|
98
98
|
export default class RequestProvider {
|
|
99
|
-
constructor(networkId, adapter) {
|
|
99
|
+
constructor({ networkId, adapter, apiKey, }) {
|
|
100
100
|
if (!(networkId in HOST_MAP)) {
|
|
101
101
|
throw new Error("Wrong networkId");
|
|
102
102
|
}
|
|
@@ -104,6 +104,11 @@ export default class RequestProvider {
|
|
|
104
104
|
this.request = axios.create({
|
|
105
105
|
baseURL: this.host,
|
|
106
106
|
adapter,
|
|
107
|
+
headers: apiKey
|
|
108
|
+
? {
|
|
109
|
+
Authorization: `Bearer ${apiKey}`,
|
|
110
|
+
}
|
|
111
|
+
: undefined,
|
|
107
112
|
});
|
|
108
113
|
this.request.interceptors.response.use((response) => {
|
|
109
114
|
return response.data;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Contract, ethers } from "ethers";
|
|
|
3
3
|
import { EthSafeTransaction } from "@safe-global/protocol-kit";
|
|
4
4
|
import { calculateSafeMessageHash } from "@safe-global/protocol-kit/dist/src/utils";
|
|
5
5
|
import SafeApiKit from "@safe-global/api-kit";
|
|
6
|
-
import {
|
|
6
|
+
import { getTransactionServiceUrl } from "@safe-global/api-kit/dist/src/utils/config";
|
|
7
7
|
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
8
8
|
import RequestProvider, { HOST_MAP } from "./api";
|
|
9
9
|
import { estimateGasForTransactionExecution, generatePreValidatedSignature, generateSignature, sameString, standardizeSafeTransactionData, } from "./utils";
|
|
@@ -53,7 +53,11 @@ class Safe {
|
|
|
53
53
|
this.version = version;
|
|
54
54
|
this.safeAddress = safeAddress;
|
|
55
55
|
this.network = network;
|
|
56
|
-
this.request = new RequestProvider(
|
|
56
|
+
this.request = new RequestProvider({
|
|
57
|
+
networkId: network,
|
|
58
|
+
adapter: Safe.adapter,
|
|
59
|
+
apiKey: Safe.apiKey,
|
|
60
|
+
});
|
|
57
61
|
this.apiKit = Safe.createSafeApiKit(network);
|
|
58
62
|
// this.init();
|
|
59
63
|
}
|
|
@@ -64,11 +68,19 @@ class Safe {
|
|
|
64
68
|
* @returns
|
|
65
69
|
*/
|
|
66
70
|
static getSafeInfo(safeAddress, network) {
|
|
67
|
-
const request = new RequestProvider(
|
|
71
|
+
const request = new RequestProvider({
|
|
72
|
+
networkId: network,
|
|
73
|
+
adapter: Safe.adapter,
|
|
74
|
+
apiKey: Safe.apiKey,
|
|
75
|
+
});
|
|
68
76
|
return request.getSafeInfo(ethers.utils.getAddress(safeAddress));
|
|
69
77
|
}
|
|
70
78
|
static async getPendingTransactions(safeAddress, network, nonce) {
|
|
71
|
-
const request = new RequestProvider(
|
|
79
|
+
const request = new RequestProvider({
|
|
80
|
+
networkId: network,
|
|
81
|
+
adapter: Safe.adapter,
|
|
82
|
+
apiKey: Safe.apiKey,
|
|
83
|
+
});
|
|
72
84
|
const transactions = await request.getPendingTransactions(safeAddress, nonce);
|
|
73
85
|
return transactions;
|
|
74
86
|
}
|
|
@@ -246,7 +258,10 @@ class Safe {
|
|
|
246
258
|
Safe.createSafeApiKit = (network) => {
|
|
247
259
|
return new SafeApiKit({
|
|
248
260
|
chainId: BigInt(network),
|
|
249
|
-
txServiceUrl: HOST_MAP[network] ||
|
|
261
|
+
txServiceUrl: HOST_MAP[network] ||
|
|
262
|
+
getTransactionServiceUrl(BigInt(network)) ||
|
|
263
|
+
undefined,
|
|
264
|
+
apiKey: Safe.apiKey,
|
|
250
265
|
});
|
|
251
266
|
};
|
|
252
267
|
export default Safe;
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
2
|
-
import { OperationType } from "@safe-global/types-kit";
|
|
2
|
+
import { OperationType, } from "@safe-global/types-kit";
|
|
3
3
|
import { EthSafeSignature } from "@safe-global/protocol-kit";
|
|
4
4
|
import { bufferToHex, ecrecover, pubToAddress } from "ethereumjs-util";
|
|
5
5
|
import { ZERO_ADDRESS, SENTINEL_ADDRESS } from "./constants";
|
|
@@ -97,7 +97,11 @@ export async function standardizeSafeTransactionData(safeAddress, safeContract,
|
|
|
97
97
|
refundReceiver: tx.refundReceiver || ZERO_ADDRESS,
|
|
98
98
|
nonce: tx.nonce ?? (await safeContract.nonce()).toNumber(),
|
|
99
99
|
};
|
|
100
|
-
const request = new RequestProvider(
|
|
100
|
+
const request = new RequestProvider({
|
|
101
|
+
networkId: network,
|
|
102
|
+
adapter: Safe.adapter,
|
|
103
|
+
apiKey: Safe.apiKey,
|
|
104
|
+
});
|
|
101
105
|
const safeTxGas = tx.safeTxGas ??
|
|
102
106
|
(await request.getSafeTxGas(safeAddress, version, standardizedTxs));
|
|
103
107
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabby-wallet/gnosis-sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@ethersproject/contracts": "5.5.0",
|
|
15
15
|
"@ethersproject/providers": "5.5.0",
|
|
16
16
|
"@ethersproject/solidity": "5.5.0",
|
|
17
|
-
"@safe-global/api-kit": "
|
|
17
|
+
"@safe-global/api-kit": "4.0.0",
|
|
18
18
|
"@safe-global/protocol-kit": "5.2.1",
|
|
19
19
|
"@safe-global/safe-deployments": "1.37.36",
|
|
20
20
|
"@safe-global/types-kit": "1.0.2",
|
package/src/api.ts
CHANGED
|
@@ -139,14 +139,22 @@ export const HOST_MAP = {
|
|
|
139
139
|
/**
|
|
140
140
|
* Katana
|
|
141
141
|
*/
|
|
142
|
-
"747474": "https://safe-transaction-katana.safe.global/api"
|
|
142
|
+
"747474": "https://safe-transaction-katana.safe.global/api",
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
export default class RequestProvider {
|
|
146
146
|
host: string;
|
|
147
147
|
request: Axios;
|
|
148
148
|
|
|
149
|
-
constructor(
|
|
149
|
+
constructor({
|
|
150
|
+
networkId,
|
|
151
|
+
adapter,
|
|
152
|
+
apiKey,
|
|
153
|
+
}: {
|
|
154
|
+
networkId: string;
|
|
155
|
+
adapter?: AxiosAdapter;
|
|
156
|
+
apiKey: string;
|
|
157
|
+
}) {
|
|
150
158
|
if (!(networkId in HOST_MAP)) {
|
|
151
159
|
throw new Error("Wrong networkId");
|
|
152
160
|
}
|
|
@@ -156,6 +164,12 @@ export default class RequestProvider {
|
|
|
156
164
|
this.request = axios.create({
|
|
157
165
|
baseURL: this.host,
|
|
158
166
|
adapter,
|
|
167
|
+
|
|
168
|
+
headers: apiKey
|
|
169
|
+
? {
|
|
170
|
+
Authorization: `Bearer ${apiKey}`,
|
|
171
|
+
}
|
|
172
|
+
: undefined,
|
|
159
173
|
});
|
|
160
174
|
|
|
161
175
|
this.request.interceptors.response.use((response) => {
|
|
@@ -168,7 +182,9 @@ export default class RequestProvider {
|
|
|
168
182
|
nonce: number
|
|
169
183
|
): Promise<{ results: SafeTransactionItem[] }> {
|
|
170
184
|
return this.request.get(
|
|
171
|
-
`/v1/safes/${ethers.utils.getAddress(
|
|
185
|
+
`/v1/safes/${ethers.utils.getAddress(
|
|
186
|
+
safeAddress
|
|
187
|
+
)}/multisig-transactions/`,
|
|
172
188
|
{
|
|
173
189
|
params: {
|
|
174
190
|
executed: false,
|
|
@@ -186,7 +202,9 @@ export default class RequestProvider {
|
|
|
186
202
|
}
|
|
187
203
|
|
|
188
204
|
getSafeInfo(safeAddress: string): Promise<SafeInfo> {
|
|
189
|
-
return this.request.get(
|
|
205
|
+
return this.request.get(
|
|
206
|
+
`/v1/safes/${ethers.utils.getAddress(safeAddress)}/`
|
|
207
|
+
);
|
|
190
208
|
}
|
|
191
209
|
|
|
192
210
|
confirmTransaction(safeTransactionHash: string, data): Promise<void> {
|
package/src/index.ts
CHANGED
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
SafeSignature,
|
|
8
8
|
SafeTransaction,
|
|
9
9
|
SafeTransactionDataPartial,
|
|
10
|
+
EIP712TypedData as ApiKitEIP712TypedData,
|
|
10
11
|
} from "@safe-global/types-kit";
|
|
11
12
|
import { EthSafeMessage, EthSafeTransaction } from "@safe-global/protocol-kit";
|
|
12
13
|
import { calculateSafeMessageHash } from "@safe-global/protocol-kit/dist/src/utils";
|
|
13
14
|
import SafeApiKit, {
|
|
14
|
-
EIP712TypedData as ApiKitEIP712TypedData,
|
|
15
15
|
SafeMessage as ApiKitSafeMessage,
|
|
16
16
|
} from "@safe-global/api-kit";
|
|
17
|
-
import {
|
|
17
|
+
import { getTransactionServiceUrl } from "@safe-global/api-kit/dist/src/utils/config";
|
|
18
18
|
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
19
19
|
import RequestProvider, { HOST_MAP, SafeInfo } from "./api";
|
|
20
20
|
import {
|
|
@@ -37,6 +37,7 @@ class Safe {
|
|
|
37
37
|
apiKit: SafeApiKit;
|
|
38
38
|
|
|
39
39
|
static adapter: AxiosAdapter;
|
|
40
|
+
static apiKey: string;
|
|
40
41
|
|
|
41
42
|
constructor(
|
|
42
43
|
safeAddress: string,
|
|
@@ -56,7 +57,11 @@ class Safe {
|
|
|
56
57
|
this.version = version;
|
|
57
58
|
this.safeAddress = safeAddress;
|
|
58
59
|
this.network = network;
|
|
59
|
-
this.request = new RequestProvider(
|
|
60
|
+
this.request = new RequestProvider({
|
|
61
|
+
networkId: network,
|
|
62
|
+
adapter: Safe.adapter,
|
|
63
|
+
apiKey: Safe.apiKey,
|
|
64
|
+
});
|
|
60
65
|
this.apiKit = Safe.createSafeApiKit(network);
|
|
61
66
|
|
|
62
67
|
// this.init();
|
|
@@ -69,7 +74,11 @@ class Safe {
|
|
|
69
74
|
* @returns
|
|
70
75
|
*/
|
|
71
76
|
static getSafeInfo(safeAddress: string, network: string) {
|
|
72
|
-
const request = new RequestProvider(
|
|
77
|
+
const request = new RequestProvider({
|
|
78
|
+
networkId: network,
|
|
79
|
+
adapter: Safe.adapter,
|
|
80
|
+
apiKey: Safe.apiKey,
|
|
81
|
+
});
|
|
73
82
|
return request.getSafeInfo(ethers.utils.getAddress(safeAddress));
|
|
74
83
|
}
|
|
75
84
|
|
|
@@ -78,7 +87,11 @@ class Safe {
|
|
|
78
87
|
network: string,
|
|
79
88
|
nonce: number
|
|
80
89
|
) {
|
|
81
|
-
const request = new RequestProvider(
|
|
90
|
+
const request = new RequestProvider({
|
|
91
|
+
networkId: network,
|
|
92
|
+
adapter: Safe.adapter,
|
|
93
|
+
apiKey: Safe.apiKey,
|
|
94
|
+
});
|
|
82
95
|
const transactions = await request.getPendingTransactions(
|
|
83
96
|
safeAddress,
|
|
84
97
|
nonce
|
|
@@ -91,7 +104,10 @@ class Safe {
|
|
|
91
104
|
return new SafeApiKit({
|
|
92
105
|
chainId: BigInt(network),
|
|
93
106
|
txServiceUrl:
|
|
94
|
-
HOST_MAP[network] ||
|
|
107
|
+
HOST_MAP[network] ||
|
|
108
|
+
getTransactionServiceUrl(BigInt(network)) ||
|
|
109
|
+
undefined,
|
|
110
|
+
apiKey: Safe.apiKey,
|
|
95
111
|
});
|
|
96
112
|
};
|
|
97
113
|
|
package/src/utils.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
SafeSignature,
|
|
6
6
|
SafeTransaction,
|
|
7
7
|
SafeTransactionData,
|
|
8
|
-
SafeTransactionDataPartial
|
|
9
|
-
} from "@safe-global/types-kit"
|
|
10
|
-
import { EthSafeSignature } from "@safe-global/protocol-kit"
|
|
8
|
+
SafeTransactionDataPartial,
|
|
9
|
+
} from "@safe-global/types-kit";
|
|
10
|
+
import { EthSafeSignature } from "@safe-global/protocol-kit";
|
|
11
11
|
import { bufferToHex, ecrecover, pubToAddress } from "ethereumjs-util";
|
|
12
12
|
import { ZERO_ADDRESS, SENTINEL_ADDRESS } from "./constants";
|
|
13
13
|
import semverSatisfies from "semver/functions/satisfies";
|
|
@@ -132,7 +132,11 @@ export async function standardizeSafeTransactionData(
|
|
|
132
132
|
refundReceiver: tx.refundReceiver || ZERO_ADDRESS,
|
|
133
133
|
nonce: tx.nonce ?? (await safeContract.nonce()).toNumber(),
|
|
134
134
|
};
|
|
135
|
-
const request = new RequestProvider(
|
|
135
|
+
const request = new RequestProvider({
|
|
136
|
+
networkId: network,
|
|
137
|
+
adapter: Safe.adapter,
|
|
138
|
+
apiKey: Safe.apiKey,
|
|
139
|
+
});
|
|
136
140
|
const safeTxGas =
|
|
137
141
|
tx.safeTxGas ??
|
|
138
142
|
(await request.getSafeTxGas(safeAddress, version, standardizedTxs));
|