dequanto 0.1.75 → 0.1.80
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/lib/cjs/contracts/deploy/Deployments.js +4 -1
- package/lib/cjs/contracts/deploy/Deployments.js.map +1 -1
- package/lib/cjs/contracts/deploy/proxy/ProxyDeployment.js +11 -5
- package/lib/cjs/contracts/deploy/proxy/ProxyDeployment.js.map +1 -1
- package/lib/cjs/hardhat/HardhatProvider.js +3 -1
- package/lib/cjs/hardhat/HardhatProvider.js.map +1 -1
- package/lib/cjs/safe/GnosisSafeHandler.js +2 -1
- package/lib/cjs/safe/GnosisSafeHandler.js.map +1 -1
- package/lib/cjs/solidity/SlotsStorage.js +3 -6
- package/lib/cjs/solidity/SlotsStorage.js.map +1 -1
- package/lib/cjs/solidity/SolidityParser.js +12 -0
- package/lib/cjs/solidity/SolidityParser.js.map +1 -1
- package/lib/cjs/solidity/storage/SlotsStorageTransport.js +2 -2
- package/lib/cjs/solidity/storage/SlotsStorageTransport.js.map +1 -1
- package/lib/cjs/solidity/storage/handlers/SlotBytesHandler.js +1 -1
- package/lib/cjs/solidity/storage/handlers/SlotBytesHandler.js.map +1 -1
- package/lib/cjs/solidity/storage/handlers/SlotMappingHandler.js +1 -1
- package/lib/cjs/solidity/storage/handlers/SlotMappingHandler.js.map +1 -1
- package/lib/esm/contracts/deploy/Deployments.js.map +1 -1
- package/lib/esm/contracts/deploy/Deployments.mjs +4 -1
- package/lib/esm/contracts/deploy/proxy/ProxyDeployment.js.map +1 -1
- package/lib/esm/contracts/deploy/proxy/ProxyDeployment.mjs +11 -5
- package/lib/esm/hardhat/HardhatProvider.js.map +1 -1
- package/lib/esm/hardhat/HardhatProvider.mjs +3 -1
- package/lib/esm/safe/GnosisSafeHandler.js.map +1 -1
- package/lib/esm/safe/GnosisSafeHandler.mjs +2 -1
- package/lib/esm/solidity/SlotsStorage.js.map +1 -1
- package/lib/esm/solidity/SlotsStorage.mjs +3 -6
- package/lib/esm/solidity/SolidityParser.js.map +1 -1
- package/lib/esm/solidity/SolidityParser.mjs +12 -0
- package/lib/esm/solidity/storage/SlotsStorageTransport.js.map +1 -1
- package/lib/esm/solidity/storage/SlotsStorageTransport.mjs +2 -2
- package/lib/esm/solidity/storage/handlers/SlotBytesHandler.js.map +1 -1
- package/lib/esm/solidity/storage/handlers/SlotBytesHandler.mjs +1 -1
- package/lib/esm/solidity/storage/handlers/SlotMappingHandler.js.map +1 -1
- package/lib/esm/solidity/storage/handlers/SlotMappingHandler.mjs +1 -1
- package/lib/types/contracts/deploy/Deployments.d.ts +4 -0
- package/lib/types/contracts/deploy/proxy/ProxyDeployment.d.ts +1 -0
- package/lib/types/hardhat/HardhatProvider.d.ts +1 -0
- package/lib/types/solidity/storage/SlotsStorageTransport.d.ts +1 -1
- package/package.json +1 -1
- package/src/contracts/deploy/Deployments.ts +12 -1
- package/src/contracts/deploy/proxy/ProxyDeployment.ts +17 -12
- package/src/hardhat/HardhatProvider.ts +4 -1
- package/src/safe/GnosisSafeHandler.ts +2 -1
- package/src/solidity/SlotsStorage.ts +3 -6
- package/src/solidity/SolidityParser.ts +12 -1
- package/src/solidity/storage/SlotsStorageTransport.ts +2 -2
- package/src/solidity/storage/handlers/SlotBytesHandler.ts +1 -1
- package/src/solidity/storage/handlers/SlotMappingHandler.ts +1 -1
|
@@ -22,6 +22,7 @@ import { TAddress } from '@dequanto/models/TAddress';
|
|
|
22
22
|
import { $promise } from '@dequanto/utils/$promise';
|
|
23
23
|
import { l } from '@dequanto/utils/$logger';
|
|
24
24
|
import { $bytecode } from '@dequanto/evm/utils/$bytecode';
|
|
25
|
+
import { THex } from '@dequanto/models/THex';
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
|
@@ -37,6 +38,13 @@ type TDeploymentOptions = {
|
|
|
37
38
|
|
|
38
39
|
// Will be used for verification process
|
|
39
40
|
proxyFor?: TAddress
|
|
41
|
+
|
|
42
|
+
deployment?: {
|
|
43
|
+
// Pending deployment transaction will be re-checked
|
|
44
|
+
tx?: TEth.Hex
|
|
45
|
+
// When false, the implementation won't be updated in proxy
|
|
46
|
+
upgradeProxy?: boolean
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
type TVerificationOptions = TDeploymentOptions & {
|
|
42
50
|
// otherwise will be fetched from the deployment TX
|
|
@@ -252,6 +260,7 @@ export class Deployments {
|
|
|
252
260
|
arguments: constructorArgs,
|
|
253
261
|
client: this.client,
|
|
254
262
|
deployer: this.deployer as any,
|
|
263
|
+
tx: opts.deployment?.tx
|
|
255
264
|
});
|
|
256
265
|
|
|
257
266
|
let deployment = await this.store.saveDeployment(deployedContract, {
|
|
@@ -304,6 +313,7 @@ export class Deployments {
|
|
|
304
313
|
force: opts?.force,
|
|
305
314
|
latest: this.opts?.checkBytecode !== false,
|
|
306
315
|
verification: opts?.verification,
|
|
316
|
+
deployment: opts?.deployment
|
|
307
317
|
});
|
|
308
318
|
|
|
309
319
|
let data = serializeInitData(id, contractImpl, opts.initialize);
|
|
@@ -321,7 +331,8 @@ export class Deployments {
|
|
|
321
331
|
implementation: {
|
|
322
332
|
address: implementationAddress,
|
|
323
333
|
initData: data
|
|
324
|
-
}
|
|
334
|
+
},
|
|
335
|
+
upgradeImplementation: opts?.deployment?.upgradeProxy ?? true
|
|
325
336
|
})
|
|
326
337
|
|
|
327
338
|
if (contractImplDeployment.implementation == null) {
|
|
@@ -45,6 +45,7 @@ interface IDeploymentCtx {
|
|
|
45
45
|
options?: {
|
|
46
46
|
skipStorageLayoutCheck?: boolean
|
|
47
47
|
}
|
|
48
|
+
upgradeImplementation?: boolean
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
interface IProxyDeploymentCtx extends IDeploymentCtx {
|
|
@@ -151,6 +152,7 @@ export class ProxyDeployment {
|
|
|
151
152
|
|
|
152
153
|
|
|
153
154
|
let hasProxy = await deployments.has(Proxy, proxyOpts);
|
|
155
|
+
let shouldUpdate = ctx.upgradeImplementation ?? true;
|
|
154
156
|
let {
|
|
155
157
|
contract: contractProxy,
|
|
156
158
|
receipt: contractProxyReceipt,
|
|
@@ -201,18 +203,21 @@ export class ProxyDeployment {
|
|
|
201
203
|
let slotValue = await client.getStorageAt(contractProxy.address, SLOT);
|
|
202
204
|
let address = `0x` + slotValue.slice(-40);
|
|
203
205
|
if ($address.eq(address, implAddress) === false) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
206
|
+
if (shouldUpdate) {
|
|
207
|
+
await this.requireCompatibleStorageLayout(proxyId, ctx);
|
|
208
|
+
$logger.log(`Upgrading ProxyAdmin(${contractProxyAdmin.address}) to ${implAddress} (${v}) from ${address}`);
|
|
209
|
+
let receipt = await Interfaces.call(
|
|
210
|
+
deployer,
|
|
211
|
+
contractProxyAdmin,
|
|
212
|
+
Interfaces.TransparentProxy[v].contractProxyAdmin.upgradeAndCall,
|
|
213
|
+
contractProxy.address,
|
|
214
|
+
implAddress,
|
|
215
|
+
null // data
|
|
216
|
+
);
|
|
217
|
+
await this.saveStorageLayout(proxyId, ctx);
|
|
218
|
+
} else {
|
|
219
|
+
$logger.log(`Skip upgrade ProxyAdmin(${contractProxyAdmin.address}) to ${implAddress} (${v}) from ${address}`);
|
|
220
|
+
}
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
if (hasProxy === false && contractProxyReceipt != null) {
|
|
@@ -142,6 +142,7 @@ export class HardhatProvider {
|
|
|
142
142
|
deployer?: EoAccount
|
|
143
143
|
arguments?: any[]
|
|
144
144
|
client?: Web3Client
|
|
145
|
+
tx?: TEth.Hex
|
|
145
146
|
}): Promise<{
|
|
146
147
|
contract: T
|
|
147
148
|
receipt: TEth.TxReceipt
|
|
@@ -155,7 +156,9 @@ export class HardhatProvider {
|
|
|
155
156
|
let receipt: TEth.TxReceipt;
|
|
156
157
|
|
|
157
158
|
try {
|
|
158
|
-
receipt =
|
|
159
|
+
receipt = options?.tx
|
|
160
|
+
? await client.getTransactionReceipt(options.tx)
|
|
161
|
+
: await factory.deploy();
|
|
159
162
|
} catch (error) {
|
|
160
163
|
let wrapped = new Error(`Deploy ${Ctor.name} failed: ` + error.message + `\n ${error.stack}`);
|
|
161
164
|
(wrapped as any).data = error.data;
|
|
@@ -304,7 +304,8 @@ export class GnosisSafeHandler {
|
|
|
304
304
|
if (typeof mix === 'object') {
|
|
305
305
|
return mix;
|
|
306
306
|
}
|
|
307
|
-
|
|
307
|
+
let account = await ChainAccountService.get(mix);
|
|
308
|
+
return $require.notNull(account, `Account not found: ${mix}`);
|
|
308
309
|
})
|
|
309
310
|
.toArrayAsync();
|
|
310
311
|
|
|
@@ -104,12 +104,9 @@ export class SlotsStorage {
|
|
|
104
104
|
|
|
105
105
|
if (is_Object(value)) {
|
|
106
106
|
// object
|
|
107
|
-
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
await this.set([{ key: entry.key, type: 'key' }], entry.value);
|
|
111
|
-
})
|
|
112
|
-
.toArrayAsync();
|
|
107
|
+
for (let key in value) {
|
|
108
|
+
await this.set([{ key: key, type: 'key' }], value[key]);
|
|
109
|
+
}
|
|
113
110
|
return;
|
|
114
111
|
}
|
|
115
112
|
|
|
@@ -55,6 +55,18 @@ export namespace SolidityParser {
|
|
|
55
55
|
})
|
|
56
56
|
.toArrayAsync({ threads: 1 });
|
|
57
57
|
|
|
58
|
+
// fix: remove duplicates due to interfaces and multiple inheritance.
|
|
59
|
+
abisDef = alot(abisDef)
|
|
60
|
+
.map(def => {
|
|
61
|
+
let key = `${def.type} ${def.name} ${def.inputs?.map(input => input.type).join(',')}`;
|
|
62
|
+
return {
|
|
63
|
+
key,
|
|
64
|
+
def,
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
.distinctBy(x => x.key)
|
|
68
|
+
.map(x => x.def)
|
|
69
|
+
.toArray();
|
|
58
70
|
return abisDef;
|
|
59
71
|
}
|
|
60
72
|
|
|
@@ -91,7 +103,6 @@ export namespace SolidityParser {
|
|
|
91
103
|
.mapAsync(async $event => Ast.getAbi($event, ctx, inheritanceChain))
|
|
92
104
|
.toArrayAsync();
|
|
93
105
|
|
|
94
|
-
|
|
95
106
|
return [
|
|
96
107
|
...abiFns,
|
|
97
108
|
...abiGetters,
|
|
@@ -169,13 +169,13 @@ export class SlotsStorageTransportForMapping implements ISlotsStorageTransport {
|
|
|
169
169
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
async getStorageAt (slot: string | number | bigint) {
|
|
172
|
+
async getStorageAt (slot: string | number | bigint, position: number, size: number) {
|
|
173
173
|
let isValidType = typeof slot === 'number' || typeof slot === 'bigint' || $is.Hex(slot);
|
|
174
174
|
if (isValidType === false) {
|
|
175
175
|
throw new Error(`Mapping Slot reader supports only numbers for position ${slot}`);
|
|
176
176
|
}
|
|
177
177
|
let location = this.mapToGlobalSlot(BigInt(slot));
|
|
178
|
-
let memory = await this.getUnderlyingTransport().getStorageAt(location,
|
|
178
|
+
let memory = await this.getUnderlyingTransport().getStorageAt(location, position, size);
|
|
179
179
|
return memory;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -122,7 +122,7 @@ export class SlotBytesHandler extends ASlotsStorageHandler {
|
|
|
122
122
|
let slotValue = await this.transport.setStorageAt(this.getSlot(i), 0, 256, buf);
|
|
123
123
|
return slotValue;
|
|
124
124
|
})
|
|
125
|
-
.toArrayAsync()
|
|
125
|
+
.toArrayAsync({ threads: 1 })
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
protected getSlot (idx: number) {
|