@skalenetwork/upgrade-tools 1.0.0-develop.10 → 1.0.0-develop.13
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.
|
@@ -20,6 +20,6 @@ interface SafeMultisigTransaction {
|
|
|
20
20
|
}
|
|
21
21
|
export declare function getSafeTransactionUrl(chainId: number): string;
|
|
22
22
|
export declare function getSafeRelayUrl(chainId: number): string;
|
|
23
|
-
export declare function createMultiSendTransaction(ethers: Ethers, safeAddress: string, privateKey: string, transactions: string[],
|
|
23
|
+
export declare function createMultiSendTransaction(ethers: Ethers, safeAddress: string, privateKey: string, transactions: string[], nonce?: number): Promise<SafeMultisigTransaction>;
|
|
24
24
|
export declare function sendSafeTransaction(safe: string, chainId: number, safeTx: SafeMultisigTransaction): Promise<void>;
|
|
25
25
|
export {};
|
package/dist/src/gnosis-safe.js
CHANGED
|
@@ -111,7 +111,7 @@ function concatTransactions(transactions) {
|
|
|
111
111
|
}
|
|
112
112
|
}).join("");
|
|
113
113
|
}
|
|
114
|
-
function createMultiSendTransaction(ethers, safeAddress, privateKey, transactions,
|
|
114
|
+
function createMultiSendTransaction(ethers, safeAddress, privateKey, transactions, nonce) {
|
|
115
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
116
|
const chainId = (yield ethers.provider.getNetwork()).chainId;
|
|
117
117
|
const multiSendAddress = getMultiSendAddress(chainId);
|
|
@@ -119,11 +119,11 @@ function createMultiSendTransaction(ethers, safeAddress, privateKey, transaction
|
|
|
119
119
|
const multiSend = new ethers.Contract(multiSendAddress, new ethers.utils.Interface(multiSendAbi), ethers.provider);
|
|
120
120
|
const safeAbi = [{ "constant": true, "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "enum Enum.Operation", "name": "operation", "type": "uint8" }, { "internalType": "uint256", "name": "safeTxGas", "type": "uint256" }, { "internalType": "uint256", "name": "baseGas", "type": "uint256" }, { "internalType": "uint256", "name": "gasPrice", "type": "uint256" }, { "internalType": "address", "name": "gasToken", "type": "address" }, { "internalType": "address", "name": "refundReceiver", "type": "address" }, { "internalType": "uint256", "name": "_nonce", "type": "uint256" }], "name": "getTransactionHash", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "payable": false, "stateMutability": "view", "type": "function" }];
|
|
121
121
|
const safe = new ethers.Contract(safeAddress, new ethers.utils.Interface(safeAbi), ethers.provider);
|
|
122
|
-
let
|
|
123
|
-
if (
|
|
122
|
+
let nonceValue = 0;
|
|
123
|
+
if (nonce === undefined) {
|
|
124
124
|
try {
|
|
125
125
|
const nonceResponse = yield axios_1.default.get(`${getSafeTransactionUrl(chainId)}/api/v1/safes/${safeAddress}/`);
|
|
126
|
-
|
|
126
|
+
nonceValue = nonceResponse.data.nonce;
|
|
127
127
|
}
|
|
128
128
|
catch (e) {
|
|
129
129
|
if (!(e instanceof Error) || !e.toString().startsWith("Error: Can't get safe-transaction url")) {
|
|
@@ -131,6 +131,9 @@ function createMultiSendTransaction(ethers, safeAddress, privateKey, transaction
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
else {
|
|
135
|
+
nonceValue = nonce;
|
|
136
|
+
}
|
|
134
137
|
const tx = {
|
|
135
138
|
"safe": safeAddress,
|
|
136
139
|
"to": multiSend.address,
|
|
@@ -142,7 +145,7 @@ function createMultiSendTransaction(ethers, safeAddress, privateKey, transaction
|
|
|
142
145
|
"baseGas": 0,
|
|
143
146
|
"gasPrice": 0,
|
|
144
147
|
"refundReceiver": ethers.constants.AddressZero,
|
|
145
|
-
"nonce":
|
|
148
|
+
"nonce": nonceValue, // Nonce of the Safe, transaction cannot be executed until Safe's nonce is not equal to this nonce
|
|
146
149
|
};
|
|
147
150
|
const digestHex = yield safe.getTransactionHash(tx.to, tx.value, tx.data, tx.operation, tx.safeTxGas, tx.baseGas, tx.gasPrice, tx.gasToken, tx.refundReceiver, tx.nonce);
|
|
148
151
|
const privateKeyBuffer = ethUtil.toBuffer(privateKey);
|
package/dist/src/upgrade.js
CHANGED
|
@@ -171,7 +171,7 @@ function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, saf
|
|
|
171
171
|
// Use random one because we most probable run tests
|
|
172
172
|
privateKey = hardhat_1.ethers.Wallet.createRandom().privateKey;
|
|
173
173
|
}
|
|
174
|
-
const safeTx = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, safeTransactions, safeMock !== undefined);
|
|
174
|
+
const safeTx = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, safeTransactions, safeMock !== undefined ? 0 : undefined);
|
|
175
175
|
let transactionsBatches;
|
|
176
176
|
if (afterUpgrade !== undefined) {
|
|
177
177
|
transactionsBatches = yield afterUpgrade(abi, contractManager);
|
|
@@ -183,8 +183,8 @@ function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, saf
|
|
|
183
183
|
const chainId = (yield hardhat_1.ethers.provider.getNetwork()).chainId;
|
|
184
184
|
yield (0, gnosis_safe_1.sendSafeTransaction)(safe, chainId, safeTx);
|
|
185
185
|
if (transactionsBatches !== undefined) {
|
|
186
|
-
for (const batch of transactionsBatches) {
|
|
187
|
-
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch,
|
|
186
|
+
for (const { batch, index } of transactionsBatches.map((batch, index) => ({ batch, index }))) {
|
|
187
|
+
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch, safeTx.nonce + index + 1);
|
|
188
188
|
yield (0, gnosis_safe_1.sendSafeTransaction)(safe, chainId, multiSendTransaction);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -199,7 +199,7 @@ function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, saf
|
|
|
199
199
|
})).wait();
|
|
200
200
|
if (transactionsBatches !== undefined) {
|
|
201
201
|
for (const batch of transactionsBatches) {
|
|
202
|
-
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch,
|
|
202
|
+
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch, 0);
|
|
203
203
|
yield (yield deployer.sendTransaction({
|
|
204
204
|
to: safeMock.address,
|
|
205
205
|
value: multiSendTransaction.value,
|