dequanto 0.2.52 → 0.2.53
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/ContractStorageReaderBase.js.map +1 -1
- package/lib/cjs/contracts/deploy/proxy/$proxyDeploy.js +4 -4
- package/lib/cjs/contracts/deploy/proxy/$proxyDeploy.js.map +1 -1
- package/lib/cjs/gen/GeneratorStorageReader.js +13 -2
- package/lib/cjs/gen/GeneratorStorageReader.js.map +1 -1
- package/lib/cjs/solidity/SlotsParser/Ast.js +20 -2
- package/lib/cjs/solidity/SlotsParser/Ast.js.map +1 -1
- package/lib/cjs/solidity/SlotsParser.js +31 -19
- package/lib/cjs/solidity/SlotsParser.js.map +1 -1
- package/lib/cjs/solidity/SlotsStorage.js +4 -1
- package/lib/cjs/solidity/SlotsStorage.js.map +1 -1
- package/lib/cjs/solidity/storage/SlotsStorageTransport.js +6 -9
- package/lib/cjs/solidity/storage/SlotsStorageTransport.js.map +1 -1
- package/lib/cjs/solidity/storage/handlers/SlotDynamicArrayHandler.js +1 -1
- package/lib/cjs/solidity/storage/handlers/SlotDynamicArrayHandler.js.map +1 -1
- package/lib/cjs/utils/$bigint.js +3 -1
- package/lib/cjs/utils/$bigint.js.map +1 -1
- package/lib/esm/contracts/ContractStorageReaderBase.js.map +1 -1
- package/lib/esm/contracts/deploy/proxy/$proxyDeploy.js.map +1 -1
- package/lib/esm/contracts/deploy/proxy/$proxyDeploy.mjs +4 -4
- package/lib/esm/gen/GeneratorStorageReader.js.map +1 -1
- package/lib/esm/gen/GeneratorStorageReader.mjs +13 -2
- package/lib/esm/solidity/SlotsParser/Ast.js.map +1 -1
- package/lib/esm/solidity/SlotsParser/Ast.mjs +20 -2
- package/lib/esm/solidity/SlotsParser.js.map +1 -1
- package/lib/esm/solidity/SlotsParser.mjs +31 -19
- package/lib/esm/solidity/SlotsStorage.js.map +1 -1
- package/lib/esm/solidity/SlotsStorage.mjs +4 -1
- package/lib/esm/solidity/storage/SlotsStorageTransport.js.map +1 -1
- package/lib/esm/solidity/storage/SlotsStorageTransport.mjs +6 -9
- package/lib/esm/solidity/storage/handlers/SlotDynamicArrayHandler.js.map +1 -1
- package/lib/esm/solidity/storage/handlers/SlotDynamicArrayHandler.mjs +1 -1
- package/lib/esm/utils/$bigint.js.map +1 -1
- package/lib/esm/utils/$bigint.mjs +3 -1
- package/lib/types/contracts/ContractStorageReaderBase.d.ts +2 -2
- package/lib/types/gen/GeneratorStorageReader.d.ts +1 -0
- package/lib/types/solidity/SlotsParser/models.d.ts +6 -1
- package/lib/types/solidity/SlotsStorage.d.ts +4 -4
- package/lib/types/solidity/storage/SlotsStorageTransport.d.ts +5 -5
- package/lib/types/utils/$bigint.d.ts +1 -1
- package/package.json +2 -2
- package/src/contracts/ContractStorageReaderBase.ts +2 -2
- package/src/contracts/deploy/proxy/$proxyDeploy.ts +4 -4
- package/src/gen/GeneratorStorageReader.ts +20 -7
- package/src/solidity/SlotsParser/Ast.ts +20 -2
- package/src/solidity/SlotsParser/models.ts +5 -1
- package/src/solidity/SlotsParser.ts +38 -22
- package/src/solidity/SlotsStorage.ts +8 -3
- package/src/solidity/storage/SlotsStorageTransport.ts +6 -9
- package/src/solidity/storage/handlers/SlotDynamicArrayHandler.ts +1 -1
- package/src/utils/$bigint.ts +4 -1
- package/tsconfig.json +2 -1
- package/lib/cjs/gen/Ast.js +0 -14
- package/lib/cjs/gen/Ast.js.map +0 -1
- package/lib/esm/gen/Ast.js.map +0 -1
- package/lib/esm/gen/Ast.mjs +0 -10
- package/lib/types/gen/Ast.d.ts +0 -3
- package/src/gen/Ast.ts +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotDynamicArrayHandler.js","sourceRoot":"","sources":["../../../../../src/solidity/storage/handlers/SlotDynamicArrayHandler.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,+DAA4D;AAC5D,sDAAmD;AACnD,qDAAkD;AAElD,oEA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,qDAA6B,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACvH,IAAI,OAAO,GAAG,IAAI,2BAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrD,OAAO,OAAO,CAAC;IACnB,CAAC;CAEJ;AAjDD,0DAiDC"}
|
|
@@ -37,7 +37,7 @@ export class SlotDynamicArrayHandler extends ASlotDynamicArray {
|
|
|
37
37
|
let baseType = $abiType.array.getBaseType(this.slot.type);
|
|
38
38
|
let baseSlots = await SlotsParser.slotsFromAbi(baseType);
|
|
39
39
|
// take the last slot index as that one will give us the TOTAL SLOTs per element
|
|
40
|
-
let slotsPerElement = baseSlots[baseSlots.length - 1].slot +
|
|
40
|
+
let slotsPerElement = baseSlots[baseSlots.length - 1].slot + 1n;
|
|
41
41
|
let transport = new SlotsStorageTransportForArray(this.transport, this.slot.slot, key.key, slotsPerElement, this.slot);
|
|
42
42
|
let storage = new SlotsStorage(transport, baseSlots);
|
|
43
43
|
return storage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$bigint.js","sourceRoot":"","sources":["../../../src/utils/$bigint.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AACpC,yCAAsC;AACtC,4CAAyC;AAEzC,IAAiB,OAAO,
|
|
1
|
+
{"version":3,"file":"$bigint.js","sourceRoot":"","sources":["../../../src/utils/$bigint.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AACpC,yCAAsC;AACtC,4CAAyC;AAEzC,IAAiB,OAAO,CA6SvB;AA7SD,WAAiB,SAAO;IAEP,wBAAc,GAAG,EAAE,CAAC;IACpB,uBAAa,GAAG,CAAC,CAAC;IAClB,qBAAW,GAAG,mEAAmE,CAAC;IAClF,0BAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEhE,SAAgB,GAAG,C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^18", "123456", "1.7e18"
|
|
69
|
+
* @param amount e.g "2.4 ether", "10 gwei", "1.7^18", "123456", "1.7e18", "1_000_000"
|
|
70
70
|
*/
|
|
71
71
|
function parse(amount) {
|
|
72
|
+
// clean 1_000
|
|
73
|
+
amount = amount.replaceAll('_', '');
|
|
72
74
|
if (/^\d+$/.test(amount) || $is.Hex(amount)) {
|
|
73
75
|
return BigInt(amount);
|
|
74
76
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ISlotVarDefinitionInput } from 'dequanto/solidity/SlotsParser/models';
|
|
2
2
|
import { IBlockchainExplorer } from 'dequanto/explorer/IBlockchainExplorer';
|
|
3
3
|
import { Web3Client } from 'dequanto/clients/Web3Client';
|
|
4
4
|
import { TAddress } from 'dequanto/models/TAddress';
|
|
@@ -11,5 +11,5 @@ export declare class ContractStorageReaderBase {
|
|
|
11
11
|
constructor(address: TAddress, client: Web3Client, explorer: IBlockchainExplorer);
|
|
12
12
|
$get(...args: Parameters<SlotsStorage['get']>): Promise<any>;
|
|
13
13
|
$set(...args: Parameters<SlotsStorage['set']>): Promise<void>;
|
|
14
|
-
protected $createHandler(slots:
|
|
14
|
+
protected $createHandler(slots: ISlotVarDefinitionInput[]): void;
|
|
15
15
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TEth } from 'dequanto/models/TEth';
|
|
1
2
|
import type { SourceFile } from './SourceFile';
|
|
2
3
|
export type TSourceFileImport = {
|
|
3
4
|
error?: string;
|
|
@@ -5,7 +6,7 @@ export type TSourceFileImport = {
|
|
|
5
6
|
file: SourceFile;
|
|
6
7
|
};
|
|
7
8
|
export interface ISlotVarDefinition {
|
|
8
|
-
slot:
|
|
9
|
+
slot: bigint;
|
|
9
10
|
position: number;
|
|
10
11
|
name: string;
|
|
11
12
|
type: string;
|
|
@@ -13,6 +14,10 @@ export interface ISlotVarDefinition {
|
|
|
13
14
|
memory?: 'storage' | 'constant' | 'immutable';
|
|
14
15
|
value?: string | number | bigint;
|
|
15
16
|
}
|
|
17
|
+
/** Slot definitions accepted from callers, including older generated readers. */
|
|
18
|
+
export type ISlotVarDefinitionInput = Omit<ISlotVarDefinition, 'slot'> & {
|
|
19
|
+
slot: number | bigint | TEth.Hex | string;
|
|
20
|
+
};
|
|
16
21
|
export interface ISlotsParserOption {
|
|
17
22
|
files?: {
|
|
18
23
|
path: string;
|
|
@@ -2,16 +2,16 @@ import { Web3Client } from 'dequanto/clients/Web3Client';
|
|
|
2
2
|
import { ISlotsStorageTransport } from './storage/SlotsStorageTransport';
|
|
3
3
|
import { TAddress } from 'dequanto/models/TAddress';
|
|
4
4
|
import { IAccessorItem } from './storage/Accessor';
|
|
5
|
-
import { ISlotVarDefinition } from './SlotsParser/models';
|
|
5
|
+
import { ISlotVarDefinition, ISlotVarDefinitionInput } from './SlotsParser/models';
|
|
6
6
|
import { TEth } from 'dequanto/models/TEth';
|
|
7
7
|
export declare class SlotsStorage {
|
|
8
8
|
transport: ISlotsStorageTransport;
|
|
9
|
-
slots:
|
|
10
|
-
static createWithClient(client: Web3Client, address: TAddress, slots: ISlotVarDefinition[], params?: {
|
|
9
|
+
static createWithClient(client: Web3Client, address: TAddress, slots: ISlotVarDefinitionInput[], params?: {
|
|
11
10
|
blockNumber?: number;
|
|
12
11
|
storageOffset?: TEth.Hex | bigint;
|
|
13
12
|
}): SlotsStorage;
|
|
14
|
-
|
|
13
|
+
slots: ISlotVarDefinition[];
|
|
14
|
+
constructor(transport: ISlotsStorageTransport, slots: ISlotVarDefinitionInput[]);
|
|
15
15
|
get<T = any>(path?: string | (string | number | bigint)[] | IAccessorItem[]): Promise<T>;
|
|
16
16
|
set(path: string | IAccessorItem[], value: any): Promise<void>;
|
|
17
17
|
fetchAll(): Promise<any>;
|
|
@@ -28,7 +28,7 @@ export declare class SlotsCursorTransport implements ISlotsStorageTransport {
|
|
|
28
28
|
extractMappingKeys(ctx: any): Promise<{
|
|
29
29
|
keys: (string | number | bigint)[][];
|
|
30
30
|
}>;
|
|
31
|
-
mapToGlobalSlot(slot?: number): bigint;
|
|
31
|
+
mapToGlobalSlot(slot?: string | number | bigint): bigint;
|
|
32
32
|
}
|
|
33
33
|
export declare class SlotsStorageTransport implements ISlotsStorageTransport {
|
|
34
34
|
client: Web3Client;
|
|
@@ -44,7 +44,7 @@ export declare class SlotsStorageTransport implements ISlotsStorageTransport {
|
|
|
44
44
|
extractMappingKeys(ctx: any): Promise<{
|
|
45
45
|
keys: (string | number | bigint)[][];
|
|
46
46
|
}>;
|
|
47
|
-
mapToGlobalSlot(slot?: number): bigint;
|
|
47
|
+
mapToGlobalSlot(slot?: string | number | bigint): bigint;
|
|
48
48
|
protected getStorageAtInner(slot: number | bigint | TEth.Hex): Promise<`0x${string}`>;
|
|
49
49
|
}
|
|
50
50
|
export declare class SlotsStorageTransportForArray implements ISlotsStorageTransport {
|
|
@@ -53,10 +53,10 @@ export declare class SlotsStorageTransportForArray implements ISlotsStorageTrans
|
|
|
53
53
|
private elementI;
|
|
54
54
|
private slotsPerElement;
|
|
55
55
|
private slot?;
|
|
56
|
-
constructor(transport: ISlotsStorageTransport, slotNr: number | bigint, elementI?: number, slotsPerElement?: number, slot?: ISlotVarDefinition);
|
|
56
|
+
constructor(transport: ISlotsStorageTransport, slotNr: number | bigint, elementI?: number, slotsPerElement?: number | bigint, slot?: ISlotVarDefinition);
|
|
57
57
|
getStorageAt(slot: string | number | bigint, position?: number, size?: number): Promise<string>;
|
|
58
58
|
setStorageAt(slot: string | number | bigint, position: number, size: number, buffer: string | number | bigint | boolean): Promise<void>;
|
|
59
|
-
mapToGlobalSlot(slotPositionNr?: number | bigint): bigint;
|
|
59
|
+
mapToGlobalSlot(slotPositionNr?: string | number | bigint): bigint;
|
|
60
60
|
extractMappingKeys(ctx: any): Promise<{
|
|
61
61
|
keys: (string | number | bigint)[][];
|
|
62
62
|
}>;
|
|
@@ -67,7 +67,7 @@ export declare class SlotsStorageTransportForMapping implements ISlotsStorageTra
|
|
|
67
67
|
private slotNr;
|
|
68
68
|
private key;
|
|
69
69
|
private slotsPerElement;
|
|
70
|
-
constructor(transport: ISlotsStorageTransport, slotNr: number, key: any, slotsPerElement?: number);
|
|
70
|
+
constructor(transport: ISlotsStorageTransport, slotNr: number | bigint, key: any, slotsPerElement?: number | bigint);
|
|
71
71
|
getStorageAt(slot: string | number | bigint, position: number, size: number): Promise<string>;
|
|
72
72
|
setStorageAt(slot: string | number | bigint, position: number, size: number, buffer: string | number | bigint | boolean): Promise<void>;
|
|
73
73
|
mapToGlobalSlot(slotPositionNr?: number | string | bigint): bigint;
|
|
@@ -9,7 +9,7 @@ export declare namespace $bigint {
|
|
|
9
9
|
function toBigInt(amount: string | number | bigint | Uint8Array): bigint;
|
|
10
10
|
function from(amount: number | bigint | string): bigint;
|
|
11
11
|
/**
|
|
12
|
-
* @param amount e.g "2.4 ether", "10 gwei", "1.7^18", "123456", "1.7e18"
|
|
12
|
+
* @param amount e.g "2.4 ether", "10 gwei", "1.7^18", "123456", "1.7e18", "1_000_000"
|
|
13
13
|
*/
|
|
14
14
|
function parse(amount: string): bigint;
|
|
15
15
|
function ensureWei(amount: number | bigint, decimals: number): bigint;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dequanto",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.53",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Alex Kit",
|
|
6
6
|
"email": "alex.kit@atmajs.com"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@noble/hashes": "^1.3.2",
|
|
69
69
|
"@scure/bip32": "^1.3.2",
|
|
70
70
|
"@scure/bip39": "^1.2.1",
|
|
71
|
-
"@solidity-parser/parser": "^0.
|
|
71
|
+
"@solidity-parser/parser": "^0.20.2",
|
|
72
72
|
"a-di": "^1.0.29",
|
|
73
73
|
"alot": "^0.3.12",
|
|
74
74
|
"appcfg": "^0.5.12",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ISlotVarDefinitionInput } from 'dequanto/solidity/SlotsParser/models';
|
|
2
2
|
import { IBlockchainExplorer } from 'dequanto/explorer/IBlockchainExplorer';
|
|
3
3
|
import { Web3Client } from 'dequanto/clients/Web3Client';
|
|
4
4
|
import { TAddress } from 'dequanto/models/TAddress';
|
|
@@ -23,7 +23,7 @@ export class ContractStorageReaderBase {
|
|
|
23
23
|
return this.$storage.set(...args);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
protected $createHandler(slots:
|
|
26
|
+
protected $createHandler(slots: ISlotVarDefinitionInput[]) {
|
|
27
27
|
this.$storage = SlotsStorage.createWithClient(this.client, this.address, slots);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -277,14 +277,14 @@ export namespace $proxyDeploy {
|
|
|
277
277
|
// Dynamic variables occupy a single slot.
|
|
278
278
|
return {
|
|
279
279
|
variable: $var,
|
|
280
|
-
offset: $var.slot *
|
|
281
|
-
length:
|
|
280
|
+
offset: BigInt($var.slot) * 256n,
|
|
281
|
+
length: 256n
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
284
|
return {
|
|
285
285
|
variable: $var,
|
|
286
|
-
offset: $var.slot *
|
|
287
|
-
length: $var.size
|
|
286
|
+
offset: BigInt($var.slot) * 256n + BigInt($var.position),
|
|
287
|
+
length: BigInt($var.size)
|
|
288
288
|
};
|
|
289
289
|
}
|
|
290
290
|
function serializePath (path: string, $var: ISlotVarDefinition) {
|
|
@@ -11,6 +11,7 @@ import { $path } from 'dequanto/utils/$path'
|
|
|
11
11
|
import { $gen } from './utils/$gen'
|
|
12
12
|
import { ISlotVarDefinition } from 'dequanto/solidity/SlotsParser/models'
|
|
13
13
|
|
|
14
|
+
|
|
14
15
|
export class GeneratorStorageReader {
|
|
15
16
|
|
|
16
17
|
async generate(opts: {
|
|
@@ -72,12 +73,12 @@ export class GeneratorStorageReader {
|
|
|
72
73
|
let code = template
|
|
73
74
|
.replace(`$NAME$`, className)
|
|
74
75
|
.replace(`/* METHODS */`, () => codeMethods)
|
|
75
|
-
.replace(`$SLOTS$`, () =>
|
|
76
|
+
.replace(`$SLOTS$`, () => this.serializeSlotDefinitions(slots))
|
|
76
77
|
|
|
77
78
|
let codeTypings = templateTypings
|
|
78
79
|
.replace(`$NAME$`, className)
|
|
79
80
|
.replace(`/* METHODS */`, () => codeMethodsTypings)
|
|
80
|
-
.replace(`$SLOTS$`, () =>
|
|
81
|
+
.replace(`$SLOTS$`, () => this.serializeSlotDefinitions(slots))
|
|
81
82
|
|
|
82
83
|
return {
|
|
83
84
|
className: className,
|
|
@@ -87,7 +88,19 @@ export class GeneratorStorageReader {
|
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
private
|
|
91
|
+
private serializeSlotDefinitions(slots: ISlotVarDefinition[]): string {
|
|
92
|
+
return JSON.stringify(slots, function (_key, value) {
|
|
93
|
+
if (typeof value !== 'bigint') {
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
if (value < Number.MAX_SAFE_INTEGER) {
|
|
97
|
+
return Number(value);
|
|
98
|
+
}
|
|
99
|
+
return value.toString();
|
|
100
|
+
}, ' ');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private serializeSlots(slots: ISlotVarDefinition[]) {
|
|
91
104
|
return slots
|
|
92
105
|
.map(slot => this.serializeSlot(slot))
|
|
93
106
|
.map(entry => {
|
|
@@ -99,14 +112,14 @@ export class GeneratorStorageReader {
|
|
|
99
112
|
});
|
|
100
113
|
}
|
|
101
114
|
|
|
102
|
-
private serializeSlot
|
|
115
|
+
private serializeSlot(slot: ISlotVarDefinition) {
|
|
103
116
|
let name = slot.name;
|
|
104
117
|
let type = slot.type;
|
|
105
118
|
let { parametersTypes, parametersCall, returnType } = this.getParameters(type);
|
|
106
119
|
return {
|
|
107
120
|
ts: `
|
|
108
121
|
async ${name}(${parametersTypes?.ts ?? ''}): Promise<${returnType}> {
|
|
109
|
-
return this.$storage.get(['${name}', ${
|
|
122
|
+
return this.$storage.get(['${name}', ${parametersCall ?? ''}]);
|
|
110
123
|
}
|
|
111
124
|
`,
|
|
112
125
|
types: `
|
|
@@ -114,13 +127,13 @@ export class GeneratorStorageReader {
|
|
|
114
127
|
`,
|
|
115
128
|
js: `
|
|
116
129
|
async ${name}(${parametersTypes?.js ?? ''}) {
|
|
117
|
-
return this.$storage.get(['${name}', ${
|
|
130
|
+
return this.$storage.get(['${name}', ${parametersCall ?? ''}]);
|
|
118
131
|
}
|
|
119
132
|
`
|
|
120
133
|
};
|
|
121
134
|
}
|
|
122
135
|
|
|
123
|
-
private getParameters
|
|
136
|
+
private getParameters(type: string): { parametersTypes?: { ts, js }, parametersCall?, returnType } {
|
|
124
137
|
|
|
125
138
|
if (type.startsWith('mapping')) {
|
|
126
139
|
let valueType = $abiType.mapping.getValueType(type);
|
|
@@ -43,6 +43,7 @@ import { $abiUtils } from 'dequanto/utils/$abiUtils';
|
|
|
43
43
|
import { SourceFile, TSourceFileContract } from './SourceFile';
|
|
44
44
|
import { $array } from 'dequanto/utils/$array';
|
|
45
45
|
import { $types } from '../utils/$types';
|
|
46
|
+
import { $bigint } from 'dequanto/utils/$bigint';
|
|
46
47
|
|
|
47
48
|
export namespace Ast {
|
|
48
49
|
export function parse(code: string, opts?: { path: string; }): { ast: SourceUnit, version: string } {
|
|
@@ -520,8 +521,23 @@ export namespace Ast {
|
|
|
520
521
|
}
|
|
521
522
|
|
|
522
523
|
export function evaluate<TResult extends bigint | string = bigint | string>(node: Expression): TResult {
|
|
523
|
-
if (isNumberLiteral(node)) {
|
|
524
|
-
return
|
|
524
|
+
if (isNumberLiteral(node) && node.subdenomination == null) {
|
|
525
|
+
return $bigint.parse(node.number) as TResult;
|
|
526
|
+
}
|
|
527
|
+
if (node.type === 'TupleExpression' && node.components.length === 1 && node.components[0] != null) {
|
|
528
|
+
return evaluate(node.components[0] as Expression);
|
|
529
|
+
}
|
|
530
|
+
if (Ast.isUnaryOperation(node)) {
|
|
531
|
+
let value = evaluate(node.subExpression);
|
|
532
|
+
if (node.operator === '-') {
|
|
533
|
+
return -value as TResult;
|
|
534
|
+
}
|
|
535
|
+
if (node.operator === '+') {
|
|
536
|
+
return value as TResult;
|
|
537
|
+
}
|
|
538
|
+
if (node.operator === '~') {
|
|
539
|
+
return ~value as TResult;
|
|
540
|
+
}
|
|
525
541
|
}
|
|
526
542
|
if (isBinaryOperation(node)) {
|
|
527
543
|
let a = evaluate<bigint>(node.left);
|
|
@@ -541,6 +557,8 @@ export namespace Ast {
|
|
|
541
557
|
return a % b as TResult;
|
|
542
558
|
case '<<':
|
|
543
559
|
return a << b as TResult;
|
|
560
|
+
case '|':
|
|
561
|
+
return (a | b) as TResult;
|
|
544
562
|
case '>>':
|
|
545
563
|
return a >> b as TResult;
|
|
546
564
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TEth } from 'dequanto/models/TEth'
|
|
1
2
|
import type { SourceFile } from './SourceFile'
|
|
2
3
|
|
|
3
4
|
export type TSourceFileImport = {
|
|
@@ -8,7 +9,7 @@ export type TSourceFileImport = {
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
export interface ISlotVarDefinition {
|
|
11
|
-
slot:
|
|
12
|
+
slot: bigint
|
|
12
13
|
position: number
|
|
13
14
|
name: string
|
|
14
15
|
type: string
|
|
@@ -20,6 +21,9 @@ export interface ISlotVarDefinition {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
|
|
24
|
+
/** Slot definitions accepted from callers, including older generated readers. */
|
|
25
|
+
export type ISlotVarDefinitionInput = Omit<ISlotVarDefinition, 'slot'> & { slot: number | bigint | TEth.Hex | string };
|
|
26
|
+
|
|
23
27
|
export interface ISlotsParserOption {
|
|
24
28
|
/* Optionally provide additional sources in memory */
|
|
25
29
|
files?: { path: string, content: string }[]
|
|
@@ -4,7 +4,9 @@ import type {
|
|
|
4
4
|
ArrayTypeName,
|
|
5
5
|
ContractDefinition,
|
|
6
6
|
ElementaryTypeName,
|
|
7
|
+
Expression,
|
|
7
8
|
Mapping,
|
|
9
|
+
StateVariableDeclarationVariable,
|
|
8
10
|
StructDefinition,
|
|
9
11
|
TypeName,
|
|
10
12
|
UserDefinedTypeName
|
|
@@ -19,6 +21,7 @@ import { Ast } from './SlotsParser/Ast';
|
|
|
19
21
|
import { ISlotsParserOption, ISlotVarDefinition } from './SlotsParser/models';
|
|
20
22
|
|
|
21
23
|
import type { TAbiInput } from 'dequanto/types/TAbi';
|
|
24
|
+
import { $bigint } from 'dequanto/utils/$bigint';
|
|
22
25
|
|
|
23
26
|
const SLOT_SIZE = 256;
|
|
24
27
|
export namespace SlotsParser {
|
|
@@ -34,7 +37,7 @@ export namespace SlotsParser {
|
|
|
34
37
|
let util = TypeAbiUtil.get(input)
|
|
35
38
|
if (util) {
|
|
36
39
|
return {
|
|
37
|
-
slot: null as
|
|
40
|
+
slot: null as bigint,
|
|
38
41
|
position: null as number,
|
|
39
42
|
name: input.name,
|
|
40
43
|
size: await util.sizeOf(),
|
|
@@ -81,10 +84,20 @@ export namespace SlotsParser {
|
|
|
81
84
|
})
|
|
82
85
|
.toArray();
|
|
83
86
|
|
|
84
|
-
let offset = { slot:
|
|
87
|
+
let offset = { slot: 0n, position: 0 };
|
|
88
|
+
let contract = inheritanceChain[inheritanceChain.length - 1]?.contract;
|
|
89
|
+
if (Ast.isContractDefinition(contract) && contract.storageLayout != null) {
|
|
90
|
+
// The most derived contract sets the base slot for the entire inheritance chain.
|
|
91
|
+
let baseSlot = $require.notNull(Ast.evaluate<bigint>(contract.storageLayout), `StorageLayout eval failed`);
|
|
92
|
+
if (baseSlot < 0n || baseSlot >= 2n ** 256n) {
|
|
93
|
+
throw new Error('Custom storage layout must be within the uint256 slot range');
|
|
94
|
+
}
|
|
95
|
+
offset.slot = baseSlot;
|
|
96
|
+
}
|
|
85
97
|
slotsDef = applyPositions(slotsDef, offset);
|
|
86
98
|
return slotsDef;
|
|
87
99
|
}
|
|
100
|
+
|
|
88
101
|
async function extractSlotsSingle (contract: TypeUtil.ITypeCtx, opts?: {
|
|
89
102
|
withConstants?: boolean
|
|
90
103
|
withImmutables?: boolean
|
|
@@ -92,6 +105,9 @@ export namespace SlotsParser {
|
|
|
92
105
|
|
|
93
106
|
let vars = Ast.isStructDefinition(contract.contract) ? contract.contract.members : alot(Ast.getVariableDeclarations(contract.contract))
|
|
94
107
|
.map($var => {
|
|
108
|
+
if (($var as StateVariableDeclarationVariable).isTransient) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
95
111
|
if ($var.isDeclaredConst && opts?.withConstants !== true) {
|
|
96
112
|
return null;
|
|
97
113
|
}
|
|
@@ -108,7 +124,7 @@ export namespace SlotsParser {
|
|
|
108
124
|
let util = TypeUtil.get(v.typeName, contract);
|
|
109
125
|
if (util) {
|
|
110
126
|
let $var = {
|
|
111
|
-
slot: null as
|
|
127
|
+
slot: null as bigint,
|
|
112
128
|
position: null as number,
|
|
113
129
|
name: v.name,
|
|
114
130
|
size: await util.sizeOf(),
|
|
@@ -137,8 +153,8 @@ export namespace SlotsParser {
|
|
|
137
153
|
return slotsDef;
|
|
138
154
|
}
|
|
139
155
|
|
|
140
|
-
function applyPositions ($vars: ISlotVarDefinition[], offset?: { slot: number, position: number }) {
|
|
141
|
-
|
|
156
|
+
function applyPositions ($vars: ISlotVarDefinition[], offset?: { slot: number | bigint, position: number }) {
|
|
157
|
+
let cursor = { slot: BigInt(offset?.slot ?? 0), position: offset?.position ?? 0 };
|
|
142
158
|
|
|
143
159
|
$vars.forEach($var => {
|
|
144
160
|
if ($var.memory === 'constant' || $var.memory === 'immutable') {
|
|
@@ -146,38 +162,38 @@ export namespace SlotsParser {
|
|
|
146
162
|
return;
|
|
147
163
|
}
|
|
148
164
|
if ($var.size === Infinity) {
|
|
149
|
-
if (
|
|
165
|
+
if (cursor.position > 0) {
|
|
150
166
|
// was previously moved further in a slot, so just take the next slot
|
|
151
|
-
|
|
152
|
-
|
|
167
|
+
cursor.position = 0;
|
|
168
|
+
cursor.slot += 1n;
|
|
153
169
|
}
|
|
154
170
|
|
|
155
|
-
$var.slot =
|
|
171
|
+
$var.slot = cursor.slot;
|
|
156
172
|
$var.position = 0;
|
|
157
173
|
|
|
158
174
|
// move to the start of the next slot
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
cursor.slot += 1n;
|
|
176
|
+
cursor.position = 0;
|
|
161
177
|
return;
|
|
162
178
|
}
|
|
163
|
-
if ($var.size <= SLOT_SIZE -
|
|
164
|
-
$var.slot =
|
|
165
|
-
$var.position =
|
|
166
|
-
|
|
179
|
+
if ($var.size <= SLOT_SIZE - cursor.position && TypeUtil.isComplexType($var.type) === false) {
|
|
180
|
+
$var.slot = cursor.slot;
|
|
181
|
+
$var.position = cursor.position;
|
|
182
|
+
cursor.position += $var.size;
|
|
167
183
|
return;
|
|
168
184
|
}
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
185
|
+
if (cursor.position > 0) {
|
|
186
|
+
cursor.slot += 1n;
|
|
187
|
+
cursor.position = 0;
|
|
172
188
|
// > moves to next slot
|
|
173
189
|
}
|
|
174
|
-
$var.slot =
|
|
175
|
-
$var.position =
|
|
190
|
+
$var.slot = cursor.slot;
|
|
191
|
+
$var.position = cursor.position;
|
|
176
192
|
|
|
177
193
|
let slots = Math.floor($var.size / SLOT_SIZE);
|
|
178
194
|
|
|
179
|
-
|
|
180
|
-
|
|
195
|
+
cursor.slot += BigInt(slots);
|
|
196
|
+
cursor.position = $var.size % SLOT_SIZE;
|
|
181
197
|
});
|
|
182
198
|
return $vars;
|
|
183
199
|
}
|
|
@@ -13,7 +13,7 @@ import { SlotMappingHandler } from './storage/handlers/SlotMappingHandler';
|
|
|
13
13
|
import { SlotStringHandler } from './storage/handlers/SlotStringHandler';
|
|
14
14
|
import { Accessor, IAccessorItem } from './storage/Accessor';
|
|
15
15
|
import { SlotStructHandler } from './storage/handlers/SlotStructHandler';
|
|
16
|
-
import { ISlotVarDefinition } from './SlotsParser/models';
|
|
16
|
+
import { ISlotVarDefinition, ISlotVarDefinitionInput } from './SlotsParser/models';
|
|
17
17
|
import { $types } from './utils/$types';
|
|
18
18
|
import { SlotBytesHandler } from './storage/handlers/SlotBytesHandler';
|
|
19
19
|
import { SlotValueConstantHandler } from './storage/handlers/SlotValueConstantHandler';
|
|
@@ -22,7 +22,7 @@ import { TEth } from 'dequanto/models/TEth';
|
|
|
22
22
|
|
|
23
23
|
export class SlotsStorage {
|
|
24
24
|
|
|
25
|
-
static createWithClient(client: Web3Client, address: TAddress, slots:
|
|
25
|
+
static createWithClient(client: Web3Client, address: TAddress, slots: ISlotVarDefinitionInput[], params?: {
|
|
26
26
|
blockNumber?: number
|
|
27
27
|
storageOffset?: TEth.Hex | bigint
|
|
28
28
|
}) {
|
|
@@ -35,8 +35,13 @@ export class SlotsStorage {
|
|
|
35
35
|
return new SlotsStorage(transport, slots)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
public slots: ISlotVarDefinition[];
|
|
39
39
|
|
|
40
|
+
constructor(public transport: ISlotsStorageTransport, slots: ISlotVarDefinitionInput[]) {
|
|
41
|
+
this.slots = slots.map(slot => ({
|
|
42
|
+
...slot,
|
|
43
|
+
slot: slot.slot == null ? null : BigInt(slot.slot)
|
|
44
|
+
}));
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
async get<T = any>(path?: string | (string | number | bigint)[] |IAccessorItem[]): Promise<T> {
|
|
@@ -56,7 +56,7 @@ export class SlotsCursorTransport implements ISlotsStorageTransport {
|
|
|
56
56
|
return this.transport.extractMappingKeys(ctx)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
mapToGlobalSlot (slot =
|
|
59
|
+
mapToGlobalSlot (slot: string | number | bigint = 0n) {
|
|
60
60
|
return BigInt(this.cursor.slot) + BigInt(slot);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -109,7 +109,7 @@ export class SlotsStorageTransport implements ISlotsStorageTransport {
|
|
|
109
109
|
throw new Error(`SlotMappingReader does not support the fetchAll method, as the size could be infinite`);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
mapToGlobalSlot (slot =
|
|
112
|
+
mapToGlobalSlot (slot: string | number | bigint = 0n) {
|
|
113
113
|
return BigInt(slot);
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -122,26 +122,23 @@ export class SlotsStorageTransportForArray implements ISlotsStorageTransport {
|
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
constructor (public transport: ISlotsStorageTransport, private slotNr: number | bigint, private elementI: number = 0, private slotsPerElement: number =
|
|
125
|
+
constructor (public transport: ISlotsStorageTransport, private slotNr: number | bigint, private elementI: number = 0, private slotsPerElement: number | bigint = 1n, private slot?: ISlotVarDefinition) {
|
|
126
126
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
async getStorageAt (slot: string | number | bigint, position = 0, size = 256) {
|
|
130
|
-
if (typeof slot !== 'number') {
|
|
131
|
-
throw new Error(`Array slot reader supports only numeric positions. Slot ${slot}`);
|
|
132
|
-
}
|
|
133
130
|
let location = this.mapToGlobalSlot(slot);
|
|
134
131
|
let memory = await this.getUnderlyingTransport().getStorageAt(location, position, size);
|
|
135
132
|
return memory;
|
|
136
133
|
}
|
|
137
134
|
|
|
138
135
|
async setStorageAt(slot: string | number | bigint, position: number, size: number, buffer: string | number | bigint | boolean): Promise<void> {
|
|
139
|
-
let location = this.mapToGlobalSlot(
|
|
136
|
+
let location = this.mapToGlobalSlot(BigInt(slot));
|
|
140
137
|
let memory = await this.transport.setStorageAt(location, position, size, buffer);
|
|
141
138
|
return memory;
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
mapToGlobalSlot (slotPositionNr: number | bigint =
|
|
141
|
+
mapToGlobalSlot (slotPositionNr: string | number | bigint = 0n) {
|
|
145
142
|
let packedRoot = this.transport?.mapToGlobalSlot(this.slotNr) ?? 0n;
|
|
146
143
|
let packedNextHash = $abiUtils.encodePacked({
|
|
147
144
|
value: $hex.padBytes($hex.toHexBuffer(packedRoot), 32),
|
|
@@ -165,7 +162,7 @@ export class SlotsStorageTransportForArray implements ISlotsStorageTransport {
|
|
|
165
162
|
}
|
|
166
163
|
|
|
167
164
|
export class SlotsStorageTransportForMapping implements ISlotsStorageTransport {
|
|
168
|
-
constructor (public transport: ISlotsStorageTransport, private slotNr: number, private key: any, private slotsPerElement: number =
|
|
165
|
+
constructor (public transport: ISlotsStorageTransport, private slotNr: number | bigint, private key: any, private slotsPerElement: number | bigint = 1n) {
|
|
169
166
|
|
|
170
167
|
}
|
|
171
168
|
|
|
@@ -48,7 +48,7 @@ export class SlotDynamicArrayHandler extends ASlotDynamicArray {
|
|
|
48
48
|
let baseSlots = await SlotsParser.slotsFromAbi(baseType);
|
|
49
49
|
|
|
50
50
|
// take the last slot index as that one will give us the TOTAL SLOTs per element
|
|
51
|
-
let slotsPerElement = baseSlots[baseSlots.length - 1].slot +
|
|
51
|
+
let slotsPerElement = baseSlots[baseSlots.length - 1].slot + 1n;
|
|
52
52
|
|
|
53
53
|
let transport = new SlotsStorageTransportForArray(this.transport, this.slot.slot, key.key, slotsPerElement, this.slot);
|
|
54
54
|
let storage = new SlotsStorage(transport, baseSlots);
|