@rabby-wallet/gnosis-sdk 1.4.3 → 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 +17 -1
- package/dist/api.js +19 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -5
- package/dist/utils.js +6 -2
- package/package.json +3 -3
- package/src/api.ts +34 -4
- package/src/index.ts +22 -6
- package/src/utils.ts +8 -4
package/dist/api.d.ts
CHANGED
|
@@ -122,11 +122,27 @@ export declare const HOST_MAP: {
|
|
|
122
122
|
* Berachain
|
|
123
123
|
*/
|
|
124
124
|
"80094": string;
|
|
125
|
+
/**
|
|
126
|
+
* ink
|
|
127
|
+
*/
|
|
128
|
+
"57073": string;
|
|
129
|
+
/**
|
|
130
|
+
* Hemi
|
|
131
|
+
*/
|
|
132
|
+
"43111": string;
|
|
133
|
+
/**
|
|
134
|
+
* Katana
|
|
135
|
+
*/
|
|
136
|
+
"747474": string;
|
|
125
137
|
};
|
|
126
138
|
export default class RequestProvider {
|
|
127
139
|
host: string;
|
|
128
140
|
request: Axios;
|
|
129
|
-
constructor(networkId
|
|
141
|
+
constructor({ networkId, adapter, apiKey, }: {
|
|
142
|
+
networkId: string;
|
|
143
|
+
adapter?: AxiosAdapter;
|
|
144
|
+
apiKey: string;
|
|
145
|
+
});
|
|
130
146
|
getPendingTransactions(safeAddress: string, nonce: number): Promise<{
|
|
131
147
|
results: SafeTransactionItem[];
|
|
132
148
|
}>;
|
package/dist/api.js
CHANGED
|
@@ -81,10 +81,22 @@ export const HOST_MAP = {
|
|
|
81
81
|
/**
|
|
82
82
|
* Berachain
|
|
83
83
|
*/
|
|
84
|
-
"80094": "https://safe-transaction-berachain.safe.global/api"
|
|
84
|
+
"80094": "https://safe-transaction-berachain.safe.global/api",
|
|
85
|
+
/**
|
|
86
|
+
* ink
|
|
87
|
+
*/
|
|
88
|
+
"57073": "https://safe-transaction-ink.safe.global/api",
|
|
89
|
+
/**
|
|
90
|
+
* Hemi
|
|
91
|
+
*/
|
|
92
|
+
"43111": "https://safe-transaction-hemi.safe.global/api",
|
|
93
|
+
/**
|
|
94
|
+
* Katana
|
|
95
|
+
*/
|
|
96
|
+
"747474": "https://safe-transaction-katana.safe.global/api",
|
|
85
97
|
};
|
|
86
98
|
export default class RequestProvider {
|
|
87
|
-
constructor(networkId, adapter) {
|
|
99
|
+
constructor({ networkId, adapter, apiKey, }) {
|
|
88
100
|
if (!(networkId in HOST_MAP)) {
|
|
89
101
|
throw new Error("Wrong networkId");
|
|
90
102
|
}
|
|
@@ -92,6 +104,11 @@ export default class RequestProvider {
|
|
|
92
104
|
this.request = axios.create({
|
|
93
105
|
baseURL: this.host,
|
|
94
106
|
adapter,
|
|
107
|
+
headers: apiKey
|
|
108
|
+
? {
|
|
109
|
+
Authorization: `Bearer ${apiKey}`,
|
|
110
|
+
}
|
|
111
|
+
: undefined,
|
|
95
112
|
});
|
|
96
113
|
this.request.interceptors.response.use((response) => {
|
|
97
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,9 +14,9 @@
|
|
|
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
|
-
"@safe-global/safe-deployments": "1.37.
|
|
19
|
+
"@safe-global/safe-deployments": "1.37.36",
|
|
20
20
|
"@safe-global/types-kit": "1.0.2",
|
|
21
21
|
"axios": "0.24.0",
|
|
22
22
|
"ethereumjs-util": "7.1.3",
|
package/src/api.ts
CHANGED
|
@@ -127,14 +127,34 @@ export const HOST_MAP = {
|
|
|
127
127
|
/**
|
|
128
128
|
* Berachain
|
|
129
129
|
*/
|
|
130
|
-
"80094": "https://safe-transaction-berachain.safe.global/api"
|
|
130
|
+
"80094": "https://safe-transaction-berachain.safe.global/api",
|
|
131
|
+
/**
|
|
132
|
+
* ink
|
|
133
|
+
*/
|
|
134
|
+
"57073": "https://safe-transaction-ink.safe.global/api",
|
|
135
|
+
/**
|
|
136
|
+
* Hemi
|
|
137
|
+
*/
|
|
138
|
+
"43111": "https://safe-transaction-hemi.safe.global/api",
|
|
139
|
+
/**
|
|
140
|
+
* Katana
|
|
141
|
+
*/
|
|
142
|
+
"747474": "https://safe-transaction-katana.safe.global/api",
|
|
131
143
|
};
|
|
132
144
|
|
|
133
145
|
export default class RequestProvider {
|
|
134
146
|
host: string;
|
|
135
147
|
request: Axios;
|
|
136
148
|
|
|
137
|
-
constructor(
|
|
149
|
+
constructor({
|
|
150
|
+
networkId,
|
|
151
|
+
adapter,
|
|
152
|
+
apiKey,
|
|
153
|
+
}: {
|
|
154
|
+
networkId: string;
|
|
155
|
+
adapter?: AxiosAdapter;
|
|
156
|
+
apiKey: string;
|
|
157
|
+
}) {
|
|
138
158
|
if (!(networkId in HOST_MAP)) {
|
|
139
159
|
throw new Error("Wrong networkId");
|
|
140
160
|
}
|
|
@@ -144,6 +164,12 @@ export default class RequestProvider {
|
|
|
144
164
|
this.request = axios.create({
|
|
145
165
|
baseURL: this.host,
|
|
146
166
|
adapter,
|
|
167
|
+
|
|
168
|
+
headers: apiKey
|
|
169
|
+
? {
|
|
170
|
+
Authorization: `Bearer ${apiKey}`,
|
|
171
|
+
}
|
|
172
|
+
: undefined,
|
|
147
173
|
});
|
|
148
174
|
|
|
149
175
|
this.request.interceptors.response.use((response) => {
|
|
@@ -156,7 +182,9 @@ export default class RequestProvider {
|
|
|
156
182
|
nonce: number
|
|
157
183
|
): Promise<{ results: SafeTransactionItem[] }> {
|
|
158
184
|
return this.request.get(
|
|
159
|
-
`/v1/safes/${ethers.utils.getAddress(
|
|
185
|
+
`/v1/safes/${ethers.utils.getAddress(
|
|
186
|
+
safeAddress
|
|
187
|
+
)}/multisig-transactions/`,
|
|
160
188
|
{
|
|
161
189
|
params: {
|
|
162
190
|
executed: false,
|
|
@@ -174,7 +202,9 @@ export default class RequestProvider {
|
|
|
174
202
|
}
|
|
175
203
|
|
|
176
204
|
getSafeInfo(safeAddress: string): Promise<SafeInfo> {
|
|
177
|
-
return this.request.get(
|
|
205
|
+
return this.request.get(
|
|
206
|
+
`/v1/safes/${ethers.utils.getAddress(safeAddress)}/`
|
|
207
|
+
);
|
|
178
208
|
}
|
|
179
209
|
|
|
180
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));
|