Skip to content

Commit

Permalink
feat(simulation): update simulation models (breaking change) (#632)
Browse files Browse the repository at this point in the history
* feat(sim): update sim models (breaking change)

* update type

* fix: add cookie to resolutions

* fix: vulnerabilities and upgrade dependencies

---------

Co-authored-by: tirumerla <[email protected]>
  • Loading branch information
shahnami and tirumerla authored Dec 13, 2024
1 parent 01d227f commit 314f7d5
Show file tree
Hide file tree
Showing 18 changed files with 1,808 additions and 332 deletions.
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "ISC",
"devDependencies": {
"@types/jest": "^29.5.12",
"axios": "^1.7.2",
"axios": "^1.7.4",
"jest": "^29.7.0",
"ts-jest": "^29.1.2"
},
Expand Down
12 changes: 6 additions & 6 deletions examples/simulate-proposal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ async function main() {
},
});

// Check if simulation reverted under `simulation.meta.reverted`
// and the reason string `simulation.meta.returnString`
if (simulation.meta.reverted) {
console.log('Transaction reverted:', simulation.meta.returnString ?? simulation.meta.returnValue);
// Check if simulation reverted under `simulation.summary.reverted`
// and the reason string `simulation.summary.revertReason`
if (simulation.summary.reverted) {
console.log('Transaction reverted:', simulation.summary.result ?? simulation.summary.revertReason);
} else {
console.log(simulation);
}
Expand Down Expand Up @@ -121,10 +121,10 @@ async function main() {

console.log(`Created proposal (${proposalWithSimulation.proposalId})`);

if (proposalWithSimulation.simulation.meta.reverted) {
if (proposalWithSimulation.simulation.summary.reverted) {
console.log(
'Transaction reverted:',
proposalWithSimulation.simulation.meta.returnString ?? proposalWithSimulation.simulation.meta.returnValue,
proposalWithSimulation.simulation.summary.result ?? proposalWithSimulation.simulation.summary.revertReason,
);
} else {
console.log(proposalWithSimulation.simulation);
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "The OpenZeppelin Defender Software Development Kit",
"dependencies": {
"@actions/exec": "^1.1.1",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand Down Expand Up @@ -75,6 +75,11 @@
"es5-ext": "^0.10.64",
"semver": "^7.6.2",
"tough-cookie": "^4.0.0",
"tar": "^6.2.1"
"tar": "^6.2.1",
"cookie": "^0.7.2",
"cross-spawn": "^7.0.5",
"elliptic": "^6.6.0",
"rollup": "4.22.4",
"micromatch": "^4.0.8"
}
}
2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"jszip": "^3.10.1",
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21",
"glob": "^11.0.0",
"dotenv": "^16.3.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/approval-process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.6.7",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export type PublicNetwork =
| 'fantomtest'
| 'fuji'
| 'fuse'
| 'geist-polter'
| 'geist-mainnet'
| 'geist-polter'
| 'hedera'
| 'hederatest'
| 'holesky'
Expand Down Expand Up @@ -73,8 +73,8 @@ export const Networks: Network[] = [
'fantomtest',
'fuji',
'fuse',
'geist-polter',
'geist-mainnet',
'geist-polter',
'hedera',
'hederatest',
'holesky',
Expand Down Expand Up @@ -140,8 +140,8 @@ export const chainIds: { [key in Network]: number } = {
'fantomtest': 4002,
'fuji': 43113,
'fuse': 122,
'geist-polter': 631571,
'geist-mainnet': 63157,
'geist-polter': 631571,
'hedera': 295,
'hederatest': 296,
'holesky': 17000,
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kvstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21",
"fs-extra": "^11.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/monitor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"ethers": "^6.9.0",
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/notification-channel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/proposal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"ethers": "^6.9.0",
"lodash": "^4.17.21"
},
Expand Down
153 changes: 76 additions & 77 deletions packages/proposal/src/models/simulation.ts
Original file line number Diff line number Diff line change
@@ -1,97 +1,96 @@
// Copied from openzeppelin/defender/models/src/types/simulation.res.d.ts

export type Address = string;
export type EventArgs = EventArgValues[];
/**
* @minItems 3
*/
export type Log = [
Address | string[] | string,
Address | string[] | string,
Address | string[] | string,
...(Address | string[] | string)[],
];
export type BigUInt = string | string | number;
export type BigUInt = string | number;

export interface SimulationResponse {
contractProposalId: string;
createdAt: string;
transaction: SimulationTransaction;
meta: SimulationMetadata;
states: ContractState[];
events: LogEvent[];
logs?: Log[];
storage: StorageState[];
traces: TransactionTrace[];
transfers: TransactionTrace[];
export interface SimulationRequest {
blockNumber?: BigUInt;
transactionData: Transaction;
}
export interface SimulationTransaction {
export interface Transaction {
from?: string;
to: string;
from: string;
data: string;
value: string;
nonce: number;
gasPrice: number;
gasLimit?: number;
}
export interface SimulationMetadata {
network: string;
blockNumber: number;
forkedBlockNumber: number;
simulatedBlockNumber: number;
gasUsed: number;
returnValue: string;
returnString: string;
reverted: boolean;
value: BigUInt;
gasPrice?: number;
gas?: number;
nonce?: number;
maxFeePerGas?: number;
maxPriorityFeePerGas?: number;
}
export interface ContractState {
function: string;
types: string[];
states: {
previous: string;
current: string;

export interface SimulationResponse {
summary: {
network: string;
blockNumber: number;
totalCalls: number;
cummulativeGasUsed: number;
reverted: boolean;
result?: string;
revertReason?: string;
events: IEvent[];
contractStates: ContractState[];
states: TraceRecordStateDiff[];
transfers: TraceRecordTransaction[];
};
records: {
index: number;
transaction: TraceRecordTransaction;
events?: IEvent[];
states?: TraceRecordStateDiff[];
status: {
reverted: boolean;
gasUsed: string;
returnValue: string;
};
revertReason?: string;
}[];
contractProposalId: string;
createdAt: string;
error?: string;
}
export interface LogEvent {
address: Address;
export interface IEvent {
address?: string;
name: string;
signature: string;
topics?: string[];
args: EventArgs;
topics: string[];
args: EventArg[];
}
export interface EventArgValues {
name?: string;
type?: string;
indexed?: boolean;
value: string | Record<string, unknown>;
export interface EventArg {
value: string | number | boolean | object;
name: string;
indexed: boolean;
type: string;
}
export interface StorageState {
address: Address;
slot: string;
export interface ContractState {
address: string;
states: {
previous?: string;
current: string;
[k: string]: ContractStateValue;
};
}
export interface TransactionTrace {
depth: number;
type: string;
gas: BigUInt;
to: string;
value: BigUInt;
data: string;
export interface ContractStateValue {
types: string[];
pre: string;
post: string;
changed: boolean;
}

// Copied from openzeppelin/defender/models/src/types/simulation.req.d.ts

export interface SimulationRequest {
blockNumber?: BigUInt;
transactionData: TransactionData;
export interface TraceRecordStateDiff {
address: string;
key: string;
pre: string;
post: string;
changed: boolean;
}
export interface TransactionData {
to: Address;
from?: Address;
value: BigUInt;
export interface TraceRecordTransaction {
type: 'CALL' | 'DELEGATECALL' | 'STATICCALL';
data: string;
[k: string]: unknown;
from: string;
to: string;
gas?: string;
gasPrice?: string;
value?: string;
nonce?: string;
blockNumber?: string;
description?: {
[k: string]: unknown;
};
}
2 changes: 1 addition & 1 deletion packages/relay-group/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay-signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@ethersproject/logger": "^5.7.0",
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"amazon-cognito-identity-js": "^6.3.6",
"axios": "^1.7.2",
"axios": "^1.7.4",
"ethers": "^6.9.0",
"lodash": "^4.17.21"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.15.2",
"axios": "^1.7.2",
"axios": "^1.7.4",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
Loading

0 comments on commit 314f7d5

Please sign in to comment.