diff --git a/.circleci/config.yml b/.circleci/config.yml index 62977ae6112..958f13e5fbe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -157,7 +157,7 @@ jobs: - *checkout - *setup_env - run: - name: "Build" + name: "Build and test" command: build l1-contracts yarn-project-base: @@ -177,17 +177,6 @@ jobs: name: "Build" command: build yarn-project-base - ethereum-js: - machine: - image: ubuntu-2004:202010-01 - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: "Build and test" - command: build ethereum.js - foundation: machine: image: ubuntu-2004:202010-01 @@ -441,9 +430,10 @@ workflows: - yarn-project-base: requires: - circuits-wasm-linux-clang + - l1-contracts <<: *defaults + - l1-contracts: *defaults - - ethereum-js: *yarn_project - aztec-js: *yarn_project - end-to-end: *yarn_project - foundation: *yarn_project @@ -461,7 +451,6 @@ workflows: - e2e-join: requires: - - ethereum-js - aztec-js - end-to-end - noir-contracts diff --git a/build_manifest.json b/build_manifest.json index c6b39043b80..26ed7de3c21 100644 --- a/build_manifest.json +++ b/build_manifest.json @@ -53,21 +53,30 @@ "rebuildPatterns": [ "^l1-contracts/" ], - "dependencies": [ - "ethereum.js", - "foundation" - ] + "dependencies": [] + }, + "l1-artifacts": { + "buildDir": "yarn-project", + "projectDir": "yarn-project/l1-artifacts", + "dockerfile": "l1-artifacts/Dockerfile", + "rebuildPatterns": [ + "^l1-contracts/", + "^yarn-project/l1-artifacts/" + ], + "dependencies": [] }, "yarn-project-base": { "buildDir": "yarn-project", "dockerfile": "yarn-project-base/Dockerfile", "rebuildPatterns": [ "^circuits/", + "^l1-contracts/", "^yarn-project/yarn-project-base/", "^yarn-project/yarn.lock" ], "dependencies": [ - "circuits-wasm-linux-clang" + "circuits-wasm-linux-clang", + "l1-contracts" ] }, "acir-simulator": { @@ -94,9 +103,8 @@ "^yarn-project/archiver/" ], "dependencies": [ - "ethereum.js", "foundation", - "l1-contracts", + "l1-artifacts", "types" ] }, @@ -179,21 +187,10 @@ "aztec-node", "aztec.js", "foundation", - "l1-contracts", + "l1-artifacts", "noir-contracts" ] }, - "ethereum.js": { - "buildDir": "yarn-project", - "projectDir": "yarn-project/ethereum.js", - "dockerfile": "ethereum.js/Dockerfile", - "rebuildPatterns": [ - "^yarn-project/ethereum.js/" - ], - "dependencies": [ - "foundation" - ] - }, "foundation": { "buildDir": "yarn-project", "projectDir": "yarn-project/foundation", @@ -227,20 +224,6 @@ "foundation" ] }, - "l2-block": { - "buildDir": "yarn-project", - "projectDir": "yarn-project/l2-block", - "dockerfile": "l2-block/Dockerfile", - "rebuildPatterns": [ - "^yarn-project/l2-block/" - ], - "dependencies": [ - "circuits.js", - "foundation", - "l1-contracts", - "tx" - ] - }, "merkle-tree": { "buildDir": "yarn-project", "projectDir": "yarn-project/merkle-tree", @@ -298,9 +281,8 @@ "dependencies": [ "archiver", "barretenberg.js", - "ethereum.js", "foundation", - "l1-contracts", + "l1-artifacts", "merkle-tree", "p2p", "sequencer-client", @@ -318,29 +300,14 @@ "dependencies": [ "acir-simulator", "circuits.js", - "ethereum.js", "foundation", - "l1-contracts", + "l1-artifacts", "merkle-tree", "p2p", "types", "world-state" ] }, - "tx": { - "buildDir": "yarn-project", - "projectDir": "yarn-project/tx", - "dockerfile": "tx/Dockerfile", - "rebuildPatterns": [ - "^yarn-project/tx/" - ], - "dependencies": [ - "barretenberg.js", - "circuits.js", - "foundation", - "types" - ] - }, "types": { "buildDir": "yarn-project", "projectDir": "yarn-project/types", @@ -351,7 +318,7 @@ "dependencies": [ "circuits.js", "foundation", - "l1-contracts" + "l1-artifacts" ] }, "world-state": { diff --git a/l1-contracts/Dockerfile b/l1-contracts/Dockerfile index 7a963e49c28..7d554412023 100644 --- a/l1-contracts/Dockerfile +++ b/l1-contracts/Dockerfile @@ -3,13 +3,13 @@ FROM ubuntu:focal as builder # Required for foundry RUN apt-get update && apt install -y git curl -WORKDIR /usr/src/contracts +WORKDIR /usr/src/l1-contracts # Install foundry RUN git init -COPY ./scripts/install_foundry.sh ./scripts/install_foundry.sh +COPY . . RUN ./scripts/install_foundry.sh -ENV PATH="/usr/src/contracts/.foundry/bin:${PATH}" +ENV PATH="/usr/src/l1-contracts/.foundry/bin:${PATH}" # Install deps RUN forge install --no-commit \ @@ -17,9 +17,7 @@ RUN forge install --no-commit \ https://github.com/openzeppelin/openzeppelin-contracts ENV MAINNET_RPC_URL='https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c' -COPY . . - # Run build and tests RUN forge clean && forge fmt --check && forge build && forge test -WORKDIR /usr/src/contracts \ No newline at end of file +WORKDIR /usr/src/l1-contracts diff --git a/yarn-project/.prettierignore b/yarn-project/.prettierignore index 28e987d199a..6b484bbdd1c 100644 --- a/yarn-project/.prettierignore +++ b/yarn-project/.prettierignore @@ -2,5 +2,3 @@ node_modules/ dest/ *.md -ethereum.js/example/ -ethereum.js/src/contract/fixtures/ \ No newline at end of file diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index d080b10e108..5487bacdcc5 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -34,9 +34,8 @@ "rootDir": "./src" }, "dependencies": { - "@aztec/ethereum.js": "workspace:^", "@aztec/foundation": "workspace:^", - "@aztec/l1-contracts": "workspace:^", + "@aztec/l1-artifacts": "workspace:^", "@aztec/types": "workspace:^", "debug": "^4.3.4", "tsc-watch": "^6.0.0", diff --git a/yarn-project/archiver/src/archiver/archiver.test.ts b/yarn-project/archiver/src/archiver/archiver.test.ts index 060f5fccaec..68e301f8a5d 100644 --- a/yarn-project/archiver/src/archiver/archiver.test.ts +++ b/yarn-project/archiver/src/archiver/archiver.test.ts @@ -1,4 +1,4 @@ -import { RollupAbi, UnverifiedDataEmitterAbi } from '@aztec/l1-contracts/viem'; +import { RollupAbi, UnverifiedDataEmitterAbi } from '@aztec/l1-artifacts'; import { ContractData, ContractPublicData, EncodedContractFunction, L2Block } from '@aztec/types'; import { MockProxy, mock } from 'jest-mock-extended'; import { Chain, HttpTransport, Log, PublicClient, Transaction, encodeFunctionData, toHex } from 'viem'; diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 91d47ffe461..869c98a111a 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -4,8 +4,8 @@ import { RunningPromise } from '@aztec/foundation/running-promise'; import { EthAddress } from '@aztec/foundation/eth-address'; import { BufferReader } from '@aztec/foundation/serialize'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { INITIAL_L2_BLOCK_NUM } from '@aztec/l1-contracts'; -import { RollupAbi, UnverifiedDataEmitterAbi } from '@aztec/l1-contracts/viem'; +import { INITIAL_L2_BLOCK_NUM } from '@aztec/types'; +import { RollupAbi, UnverifiedDataEmitterAbi } from '@aztec/l1-artifacts'; import { ContractData, ContractPublicData, diff --git a/yarn-project/archiver/src/archiver/config.ts b/yarn-project/archiver/src/archiver/config.ts index d84c94a73c4..513877a7bbf 100644 --- a/yarn-project/archiver/src/archiver/config.ts +++ b/yarn-project/archiver/src/archiver/config.ts @@ -1,5 +1,5 @@ import { EthAddress } from '@aztec/foundation/eth-address'; -import { L1Addresses } from '@aztec/l1-contracts'; +import { L1Addresses } from '@aztec/types'; /** * The archiver configuration. diff --git a/yarn-project/archiver/tsconfig.json b/yarn-project/archiver/tsconfig.json index 00f72ffe42b..cf8af360206 100644 --- a/yarn-project/archiver/tsconfig.json +++ b/yarn-project/archiver/tsconfig.json @@ -6,14 +6,11 @@ "tsBuildInfoFile": ".tsbuildinfo" }, "references": [ - { - "path": "../ethereum.js" - }, { "path": "../foundation" }, { - "path": "../l1-contracts" + "path": "../l1-artifacts" }, { "path": "../types" diff --git a/yarn-project/aztec-node/package.json b/yarn-project/aztec-node/package.json index b7b85661988..8ec814b695c 100644 --- a/yarn-project/aztec-node/package.json +++ b/yarn-project/aztec-node/package.json @@ -33,9 +33,8 @@ "dependencies": { "@aztec/archiver": "workspace:^", "@aztec/barretenberg.js": "workspace:^", - "@aztec/ethereum.js": "workspace:^", "@aztec/foundation": "workspace:^", - "@aztec/l1-contracts": "workspace:^", + "@aztec/l1-artifacts": "workspace:^", "@aztec/merkle-tree": "workspace:^", "@aztec/p2p": "workspace:^", "@aztec/sequencer-client": "workspace:^", diff --git a/yarn-project/aztec-node/tsconfig.json b/yarn-project/aztec-node/tsconfig.json index 000ec31f76e..e67e69475f1 100644 --- a/yarn-project/aztec-node/tsconfig.json +++ b/yarn-project/aztec-node/tsconfig.json @@ -12,14 +12,11 @@ { "path": "../barretenberg.js" }, - { - "path": "../ethereum.js" - }, { "path": "../foundation" }, { - "path": "../l1-contracts" + "path": "../l1-artifacts" }, { "path": "../merkle-tree" diff --git a/yarn-project/aztec-rpc/src/account_state/account_state.ts b/yarn-project/aztec-rpc/src/account_state/account_state.ts index b639e90d1cf..c6927f3c211 100644 --- a/yarn-project/aztec-rpc/src/account_state/account_state.ts +++ b/yarn-project/aztec-rpc/src/account_state/account_state.ts @@ -3,8 +3,7 @@ import { AztecNode } from '@aztec/aztec-node'; import { Grumpkin } from '@aztec/barretenberg.js/crypto'; import { EcdsaSignature, KERNEL_NEW_COMMITMENTS_LENGTH, PrivateHistoricTreeRoots, TxRequest } from '@aztec/circuits.js'; import { KernelProver, OutputNoteData } from '@aztec/kernel-prover'; -import { INITIAL_L2_BLOCK_NUM } from '@aztec/l1-contracts'; -import { EncodedContractFunction, L2BlockContext, Tx, UnverifiedData } from '@aztec/types'; +import { EncodedContractFunction, INITIAL_L2_BLOCK_NUM, L2BlockContext, Tx, UnverifiedData } from '@aztec/types'; import { NotePreimage, TxAuxData } from '../aztec_rpc_server/tx_aux_data/index.js'; import { ContractDataOracle } from '../contract_data_oracle/index.js'; import { Database, TxAuxDataDao, TxDao } from '../database/index.js'; diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 83b9ae2dbed..c340b1593a2 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -27,7 +27,7 @@ "@aztec/aztec-node": "workspace:^", "@aztec/aztec.js": "workspace:^", "@aztec/foundation": "workspace:^", - "@aztec/l1-contracts": "workspace:^", + "@aztec/l1-artifacts": "workspace:^", "@aztec/noir-contracts": "workspace:^", "@types/jest": "^29.5.0", "jest": "^29.5.0", diff --git a/yarn-project/end-to-end/src/deploy_l1_contracts.ts b/yarn-project/end-to-end/src/deploy_l1_contracts.ts index 1de75bd4c92..48d00b3d4f8 100644 --- a/yarn-project/end-to-end/src/deploy_l1_contracts.ts +++ b/yarn-project/end-to-end/src/deploy_l1_contracts.ts @@ -5,7 +5,7 @@ import { RollupBytecode, UnverifiedDataEmitterAbi, UnverifiedDataEmitterBytecode, -} from '@aztec/l1-contracts/viem'; +} from '@aztec/l1-artifacts'; import type { Abi, Narrow } from 'abitype'; import { Account, diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index c828c58f12b..9997ec9612b 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -1,6 +1,5 @@ import { AztecNode, getConfigEnvVars } from '@aztec/aztec-node'; import { AztecRPCServer, ContractDeployer, Fr, TxStatus } from '@aztec/aztec.js'; - import { mnemonicToAccount } from 'viem/accounts'; import { createAztecRpcServer } from './create_aztec_rpc_client.js'; import { deployL1Contracts } from './deploy_l1_contracts.js'; diff --git a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts index 67824e27cb8..04e17a9b183 100644 --- a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts @@ -1,6 +1,5 @@ import { AztecNode, getConfigEnvVars } from '@aztec/aztec-node'; import { AztecAddress, AztecRPCServer, Contract, ContractDeployer, TxStatus } from '@aztec/aztec.js'; - import { ZkTokenContractAbi } from '@aztec/noir-contracts/examples'; import { mnemonicToAccount } from 'viem/accounts'; diff --git a/yarn-project/end-to-end/tsconfig.json b/yarn-project/end-to-end/tsconfig.json index a7aaa5c6afb..0f18e17e67e 100644 --- a/yarn-project/end-to-end/tsconfig.json +++ b/yarn-project/end-to-end/tsconfig.json @@ -16,7 +16,7 @@ "path": "../foundation" }, { - "path": "../l1-contracts" + "path": "../l1-artifacts" }, { "path": "../noir-contracts" diff --git a/yarn-project/ethereum.js/.eslintrc.cjs b/yarn-project/ethereum.js/.eslintrc.cjs deleted file mode 100644 index 24fdd5c8db7..00000000000 --- a/yarn-project/ethereum.js/.eslintrc.cjs +++ /dev/null @@ -1,6 +0,0 @@ -// module.exports = require('@aztec/foundation/eslint'); - -// Uncomment line 1 and remove the following to reenable the rule -const config = require('@aztec/foundation/eslint'); -config.rules['jsdoc/require-param'] = 'off'; -module.exports = config; diff --git a/yarn-project/ethereum.js/.gitignore b/yarn-project/ethereum.js/.gitignore deleted file mode 100644 index f82ac84f8d6..00000000000 --- a/yarn-project/ethereum.js/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.yarn -dest \ No newline at end of file diff --git a/yarn-project/ethereum.js/.prettierignore b/yarn-project/ethereum.js/.prettierignore deleted file mode 100644 index 5b3df259d5d..00000000000 --- a/yarn-project/ethereum.js/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -src/contract/fixtures \ No newline at end of file diff --git a/yarn-project/ethereum.js/Dockerfile b/yarn-project/ethereum.js/Dockerfile deleted file mode 100644 index b7d655a7175..00000000000 --- a/yarn-project/ethereum.js/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder - -COPY @types @types -COPY foundation foundation -COPY ethereum.js ethereum.js -WORKDIR /usr/src/yarn-project/ethereum.js -RUN yarn build && yarn formatting && yarn test - -# Prune dev dependencies. See comment in base image. -RUN yarn cache clean -RUN yarn workspaces focus --production > /dev/null - -FROM alpine:latest -COPY --from=builder /usr/src/yarn-project/ethereum.js /usr/src/yarn-project/ethereum.js diff --git a/yarn-project/ethereum.js/README.md b/yarn-project/ethereum.js/README.md deleted file mode 100644 index c0cf1698f23..00000000000 --- a/yarn-project/ethereum.js/README.md +++ /dev/null @@ -1,98 +0,0 @@ -# ethereum.js - -A streamlined L1 client library that meets Aztec's needs. Can provide full contract type safety and IDE -auto-completion by leveraging the `contract_gen_def` tool. - -There is an example project [here](./example/src/index.ts). Play with it in your IDE to experience auto-completion. - -## Installing - -`yarn add @aztec/ethereum.js` - -## Building Contract Definitions from ABIs - -Define a `contracts.json` file, e.g: - -```json -{ - "outputPath": "./src/contracts", - "contracts": { - "RollupProcessorContract": { - "source": "etherscan", - "net": "mainnet", - "address": "0x8430be7b8fd28cc58ea70a25c9c7a624f26f5d09" - }, - "ERC20Mintable": { - "source": "foundry", - "buildFile": "./src/abis/ERC20Mintable.json" - } - } -} -``` - -### Running The Generator - -If you want to generate a definition from an Etherscan ABI, you'll need to set `ETHERSCAN_API_KEY`. -If you want bytecode included for deployments, you'll need to provide an `ETHEREUM_HOST`. - -``` -export ETHEREUM_HOST=https://mainnet.infura.io/v3/ -export ETHERSCAN_API_KEY= -yarn contract_gen_def -``` - -This will output two classes: - -- `RollupProcessorContract` in `./src/contracts/RollupProcessorContract.ts` -- `ERC20Mintable` in `./src/contracts/ERC20Mintable.ts` - -They will have method definitions using sensible types, unique per parameter e.g: - -- `number` (<= 32 bits) -- `bigint` (> 32 bits) -- `string` -- `EthAddress` -- `Bytes32` - -Transaction receipts will have logs and errors decoded according to abi entries. - -### Snippet of ERC20Mintable Definition File - -```ts -interface ERC20MintableMethods { - allowance(owner: EthAddress, spender: EthAddress): TxCall; - approve(spender: EthAddress, amount: bigint): TxSend; - balanceOf(account: EthAddress): TxCall; - decimals(): TxCall; - decreaseAllowance(spender: EthAddress, subtractedValue: bigint): TxSend; - increaseAllowance(spender: EthAddress, addedValue: bigint): TxSend; - mint(_to: EthAddress, _value: bigint): TxSend; - name(): TxCall; - setDecimals(_decimals: number): TxSend; - symbol(): TxCall; - totalSupply(): TxCall; - transfer(to: EthAddress, amount: bigint): TxSend; - transferFrom(from: EthAddress, to: EthAddress, amount: bigint): TxSend; -} -``` - -## Using the Contracts - -Below is an example of using ERC20Mintable to deploy, mint, transfer and handle logs. - -```ts -// Deploy. -const contract = new ERC20Mintable(ethRpc, undefined, { from: acc1, gas: 1000000 }); -await contract.deploy('AZT').send().getReceipt(); -console.log(`Deployed ERC20 with symbol: ${await contract.methods.symbol().call()}`); - -// Mint. -console.log(`Minting 1000 tokens to ${acc1}...`); -await contract.methods.mint(acc1, toBaseUnits('1000', 18)).send().getReceipt(); - -// Transfer. -console.log(`Transferring from ${acc1} to ${acc2}`); -const receipt = await contract.methods.transfer(acc2, toBaseUnits('0.1', 18)).send().getReceipt(); -const [{ args }] = receipt.events.Transfer; -console.log(`Log shows transfer of ${args.value} from ${args.from} to ${args.to}`); -``` diff --git a/yarn-project/ethereum.js/example/.eslintrc.cjs b/yarn-project/ethereum.js/example/.eslintrc.cjs deleted file mode 100644 index 97d6f187813..00000000000 --- a/yarn-project/ethereum.js/example/.eslintrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@aztec/foundation/eslint-legacy'); diff --git a/yarn-project/ethereum.js/example/contracts.json b/yarn-project/ethereum.js/example/contracts.json deleted file mode 100644 index 696d2cb78cf..00000000000 --- a/yarn-project/ethereum.js/example/contracts.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "outputPath": "./src/contracts", - "contracts": { - "DaiContract": { - "source": "etherscan", - "net": "mainnet", - "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F" - }, - "RollupProcessorContract": { - "source": "etherscan", - "net": "mainnet", - "address": "0x8430be7b8fd28cc58ea70a25c9c7a624f26f5d09" - }, - "ERC20Mintable": { - "source": "foundry", - "buildFile": "./src/abis/ERC20Mintable.json" - }, - "ERC20Permit": { - "source": "foundry", - "buildFile": "./src/abis/ERC20Permit.json" - } - } -} diff --git a/yarn-project/ethereum.js/example/package.json b/yarn-project/ethereum.js/example/package.json deleted file mode 100644 index c97fc96986c..00000000000 --- a/yarn-project/ethereum.js/example/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@aztec/ethereum.js-example", - "version": "0.0.0", - "main": "index.js", - "license": "MIT", - "type": "module", - "scripts": { - "prepare": "", - "start": "yarn build && NODE_NO_WARNINGS=1 node ./dest", - "build": "tsc -b tsconfig.json", - "clean": "rm -rf ./dest .tsbuildinfo" - }, - "dependencies": { - "@aztec/ethereum.js": "workspace:^", - "@aztec/foundation": "workspace:^" - }, - "devDependencies": { - "@rushstack/eslint-patch": "^1.2.0", - "@types/node": "^18.15.0", - "@types/source-map-support": "^0.5.6", - "source-map-support": "^0.5.21", - "typescript": "^4.9.5" - } -} diff --git a/yarn-project/ethereum.js/example/src/abis/ERC20.json b/yarn-project/ethereum.js/example/src/abis/ERC20.json deleted file mode 100644 index 70d226fb98b..00000000000 --- a/yarn-project/ethereum.js/example/src/abis/ERC20.json +++ /dev/null @@ -1,8176 +0,0 @@ -{ - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "name_", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol_", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": { - "object": "0x60806040523480156200001157600080fd5b5060405162000c5938038062000c598339810160408190526200003491620001db565b81516200004990600390602085019062000068565b5080516200005f90600490602084019062000068565b50505062000282565b828054620000769062000245565b90600052602060002090601f0160209004810192826200009a5760008555620000e5565b82601f10620000b557805160ff1916838001178555620000e5565b82800160010185558215620000e5579182015b82811115620000e5578251825591602001919060010190620000c8565b50620000f3929150620000f7565b5090565b5b80821115620000f35760008155600101620000f8565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200013657600080fd5b81516001600160401b03808211156200015357620001536200010e565b604051601f8301601f19908116603f011681019082821181831017156200017e576200017e6200010e565b816040528381526020925086838588010111156200019b57600080fd5b600091505b83821015620001bf5785820183015181830184015290820190620001a0565b83821115620001d15760008385830101525b9695505050505050565b60008060408385031215620001ef57600080fd5b82516001600160401b03808211156200020757600080fd5b620002158683870162000124565b935060208501519150808211156200022c57600080fd5b506200023b8582860162000124565b9150509250929050565b600181811c908216806200025a57607f821691505b602082108114156200027c57634e487b7160e01b600052602260045260246000fd5b50919050565b6109c780620002926000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c80633950935111610081578063a457c2d71161005b578063a457c2d714610187578063a9059cbb1461019a578063dd62ed3e146101ad57600080fd5b8063395093511461014357806370a082311461015657806395d89b411461017f57600080fd5b806318160ddd116100b257806318160ddd1461010f57806323b872dd14610121578063313ce5671461013457600080fd5b806306fdde03146100ce578063095ea7b3146100ec575b600080fd5b6100d66101e6565b6040516100e391906107b4565b60405180910390f35b6100ff6100fa366004610843565b610278565b60405190151581526020016100e3565b6002545b6040519081526020016100e3565b6100ff61012f36600461086d565b610290565b604051601281526020016100e3565b6100ff610151366004610843565b6102b4565b6101136101643660046108a9565b6001600160a01b031660009081526020819052604090205490565b6100d66102f3565b6100ff610195366004610843565b610302565b6100ff6101a8366004610843565b6103b1565b6101136101bb3660046108cb565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101f5906108fe565b80601f0160208091040260200160405190810160405280929190818152602001828054610221906108fe565b801561026e5780601f106102435761010080835404028352916020019161026e565b820191906000526020600020905b81548152906001019060200180831161025157829003601f168201915b5050505050905090565b6000336102868185856103bf565b5060019392505050565b60003361029e858285610517565b6102a98585856105c7565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061028690829086906102ee908790610952565b6103bf565b6060600480546101f5906108fe565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156103a45760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6102a982868684036103bf565b6000336102868185856105c7565b6001600160a01b03831661043a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0382166104b65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146105c157818110156105b45760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161039b565b6105c184848484036103bf565b50505050565b6001600160a01b0383166106435760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0382166106bf5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0383166000908152602081905260409020548181101561074e5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36105c1565b600060208083528351808285015260005b818110156107e1578581018301518582016040015282016107c5565b818111156107f3576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b80356001600160a01b038116811461083e57600080fd5b919050565b6000806040838503121561085657600080fd5b61085f83610827565b946020939093013593505050565b60008060006060848603121561088257600080fd5b61088b84610827565b925061089960208501610827565b9150604084013590509250925092565b6000602082840312156108bb57600080fd5b6108c482610827565b9392505050565b600080604083850312156108de57600080fd5b6108e783610827565b91506108f560208401610827565b90509250929050565b600181811c9082168061091257607f821691505b6020821081141561094c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b6000821982111561098c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50019056fea26469706673582212208cb18943b907c1bb505283efa689b2fd9f2807908eac0b9e6fdd19403eb80d9464736f6c634300080a0033", - "sourceMap": "1401:11610:86:-:0;;;1976:113;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2042:13;;;;:5;;:13;;;;;:::i;:::-;-1:-1:-1;2065:17:86;;;;:7;;:17;;;;;:::i;:::-;;1976:113;;1401:11610;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1401:11610:86;;;-1:-1:-1;1401:11610:86;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;14:127:169;75:10;70:3;66:20;63:1;56:31;106:4;103:1;96:15;130:4;127:1;120:15;146:885;200:5;253:3;246:4;238:6;234:17;230:27;220:55;;271:1;268;261:12;220:55;294:13;;-1:-1:-1;;;;;356:10:169;;;353:36;;;369:18;;:::i;:::-;444:2;438:9;412:2;498:13;;-1:-1:-1;;494:22:169;;;518:2;490:31;486:40;474:53;;;542:18;;;562:22;;;539:46;536:72;;;588:18;;:::i;:::-;628:10;624:2;617:22;663:2;655:6;648:18;685:4;675:14;;730:3;725:2;720;712:6;708:15;704:24;701:33;698:53;;;747:1;744;737:12;698:53;769:1;760:10;;779:133;793:2;790:1;787:9;779:133;;;881:14;;;877:23;;871:30;850:14;;;846:23;;839:63;804:10;;;;779:133;;;930:2;927:1;924:9;921:80;;;989:1;984:2;979;971:6;967:15;963:24;956:35;921:80;1019:6;146:885;-1:-1:-1;;;;;;146:885:169:o;1036:562::-;1135:6;1143;1196:2;1184:9;1175:7;1171:23;1167:32;1164:52;;;1212:1;1209;1202:12;1164:52;1239:16;;-1:-1:-1;;;;;1304:14:169;;;1301:34;;;1331:1;1328;1321:12;1301:34;1354:61;1407:7;1398:6;1387:9;1383:22;1354:61;:::i;:::-;1344:71;;1461:2;1450:9;1446:18;1440:25;1424:41;;1490:2;1480:8;1477:16;1474:36;;;1506:1;1503;1496:12;1474:36;;1529:63;1584:7;1573:8;1562:9;1558:24;1529:63;:::i;:::-;1519:73;;;1036:562;;;;;:::o;1603:380::-;1682:1;1678:12;;;;1725;;;1746:61;;1800:4;1792:6;1788:17;1778:27;;1746:61;1853:2;1845:6;1842:14;1822:18;1819:38;1816:161;;;1899:10;1894:3;1890:20;1887:1;1880:31;1934:4;1931:1;1924:15;1962:4;1959:1;1952:15;1816:161;;1603:380;;;:::o;:::-;1401:11610:86;;;;;;", - "linkReferences": {} - }, - "deployedBytecode": { - "object": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c80633950935111610081578063a457c2d71161005b578063a457c2d714610187578063a9059cbb1461019a578063dd62ed3e146101ad57600080fd5b8063395093511461014357806370a082311461015657806395d89b411461017f57600080fd5b806318160ddd116100b257806318160ddd1461010f57806323b872dd14610121578063313ce5671461013457600080fd5b806306fdde03146100ce578063095ea7b3146100ec575b600080fd5b6100d66101e6565b6040516100e391906107b4565b60405180910390f35b6100ff6100fa366004610843565b610278565b60405190151581526020016100e3565b6002545b6040519081526020016100e3565b6100ff61012f36600461086d565b610290565b604051601281526020016100e3565b6100ff610151366004610843565b6102b4565b6101136101643660046108a9565b6001600160a01b031660009081526020819052604090205490565b6100d66102f3565b6100ff610195366004610843565b610302565b6100ff6101a8366004610843565b6103b1565b6101136101bb3660046108cb565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101f5906108fe565b80601f0160208091040260200160405190810160405280929190818152602001828054610221906108fe565b801561026e5780601f106102435761010080835404028352916020019161026e565b820191906000526020600020905b81548152906001019060200180831161025157829003601f168201915b5050505050905090565b6000336102868185856103bf565b5060019392505050565b60003361029e858285610517565b6102a98585856105c7565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061028690829086906102ee908790610952565b6103bf565b6060600480546101f5906108fe565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156103a45760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6102a982868684036103bf565b6000336102868185856105c7565b6001600160a01b03831661043a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0382166104b65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146105c157818110156105b45760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161039b565b6105c184848484036103bf565b50505050565b6001600160a01b0383166106435760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0382166106bf5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b0383166000908152602081905260409020548181101561074e5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161039b565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36105c1565b600060208083528351808285015260005b818110156107e1578581018301518582016040015282016107c5565b818111156107f3576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b80356001600160a01b038116811461083e57600080fd5b919050565b6000806040838503121561085657600080fd5b61085f83610827565b946020939093013593505050565b60008060006060848603121561088257600080fd5b61088b84610827565b925061089960208501610827565b9150604084013590509250925092565b6000602082840312156108bb57600080fd5b6108c482610827565b9392505050565b600080604083850312156108de57600080fd5b6108e783610827565b91506108f560208401610827565b90509250929050565b600181811c9082168061091257607f821691505b6020821081141561094c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b6000821982111561098c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50019056fea26469706673582212208cb18943b907c1bb505283efa689b2fd9f2807908eac0b9e6fdd19403eb80d9464736f6c634300080a0033", - "sourceMap": "1401:11610:86:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;4431:197;;;;;;:::i;:::-;;:::i;:::-;;;1300:14:169;;1293:22;1275:41;;1263:2;1248:18;4431:197:86;1135:187:169;3242:106:86;3329:12;;3242:106;;;1473:25:169;;;1461:2;1446:18;3242:106:86;1327:177:169;5190:286:86;;;;;;:::i;:::-;;:::i;3091:91::-;;;3173:2;1984:36:169;;1972:2;1957:18;3091:91:86;1842:184:169;5871:234:86;;;;;;:::i;:::-;;:::i;3406:125::-;;;;;;:::i;:::-;-1:-1:-1;;;;;3506:18:86;3480:7;3506:18;;;;;;;;;;;;3406:125;2365:102;;;:::i;6592:427::-;;;;;;:::i;:::-;;:::i;3727:189::-;;;;;;:::i;:::-;;:::i;3974:149::-;;;;;;:::i;:::-;-1:-1:-1;;;;;4089:18:86;;;4063:7;4089:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3974:149;2154:98;2208:13;2240:5;2233:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98;:::o;4431:197::-;4514:4;719:10:93;4568:32:86;719:10:93;4584:7:86;4593:6;4568:8;:32::i;:::-;-1:-1:-1;4617:4:86;;4431:197;-1:-1:-1;;;4431:197:86:o;5190:286::-;5317:4;719:10:93;5373:38:86;5389:4;719:10:93;5404:6:86;5373:15;:38::i;:::-;5421:27;5431:4;5437:2;5441:6;5421:9;:27::i;:::-;-1:-1:-1;5465:4:86;;5190:286;-1:-1:-1;;;;5190:286:86:o;5871:234::-;719:10:93;5959:4:86;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:86;;;;;;;;;;5959:4;;719:10:93;6013:64:86;;719:10:93;;4089:27:86;;6038:38;;6066:10;;6038:38;:::i;:::-;6013:8;:64::i;2365:102::-;2421:13;2453:7;2446:14;;;;;:::i;6592:427::-;719:10:93;6685:4:86;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:86;;;;;;;;;;6685:4;;719:10:93;6829:15:86;6809:16;:35;;6801:85;;;;-1:-1:-1;;;6801:85:86;;3418:2:169;6801:85:86;;;3400:21:169;3457:2;3437:18;;;3430:30;3496:34;3476:18;;;3469:62;3567:7;3547:18;;;3540:35;3592:19;;6801:85:86;;;;;;;;;6920:60;6929:5;6936:7;6964:15;6945:16;:34;6920:8;:60::i;3727:189::-;3806:4;719:10:93;3860:28:86;719:10:93;3877:2:86;3881:6;3860:9;:28::i;10504:370::-;-1:-1:-1;;;;;10635:19:86;;10627:68;;;;-1:-1:-1;;;10627:68:86;;3824:2:169;10627:68:86;;;3806:21:169;3863:2;3843:18;;;3836:30;3902:34;3882:18;;;3875:62;3973:6;3953:18;;;3946:34;3997:19;;10627:68:86;3622:400:169;10627:68:86;-1:-1:-1;;;;;10713:21:86;;10705:68;;;;-1:-1:-1;;;10705:68:86;;4229:2:169;10705:68:86;;;4211:21:169;4268:2;4248:18;;;4241:30;4307:34;4287:18;;;4280:62;4378:4;4358:18;;;4351:32;4400:19;;10705:68:86;4027:398:169;10705:68:86;-1:-1:-1;;;;;10784:18:86;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;:36;;;10835:32;;1473:25:169;;;10835:32:86;;1446:18:169;10835:32:86;;;;;;;10504:370;;;:::o;11155:441::-;-1:-1:-1;;;;;4089:18:86;;;11285:24;4089:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;11371:17;11351:37;;11347:243;;11432:6;11412:16;:26;;11404:68;;;;-1:-1:-1;;;11404:68:86;;4632:2:169;11404:68:86;;;4614:21:169;4671:2;4651:18;;;4644:30;4710:31;4690:18;;;4683:59;4759:18;;11404:68:86;4430:353:169;11404:68:86;11514:51;11523:5;11530:7;11558:6;11539:16;:25;11514:8;:51::i;:::-;11275:321;11155:441;;;:::o;7473:818::-;-1:-1:-1;;;;;7599:18:86;;7591:68;;;;-1:-1:-1;;;7591:68:86;;4990:2:169;7591:68:86;;;4972:21:169;5029:2;5009:18;;;5002:30;5068:34;5048:18;;;5041:62;5139:7;5119:18;;;5112:35;5164:19;;7591:68:86;4788:401:169;7591:68:86;-1:-1:-1;;;;;7677:16:86;;7669:64;;;;-1:-1:-1;;;7669:64:86;;5396:2:169;7669:64:86;;;5378:21:169;5435:2;5415:18;;;5408:30;5474:34;5454:18;;;5447:62;5545:5;5525:18;;;5518:33;5568:19;;7669:64:86;5194:399:169;7669:64:86;-1:-1:-1;;;;;7815:15:86;;7793:19;7815:15;;;;;;;;;;;7848:21;;;;7840:72;;;;-1:-1:-1;;;7840:72:86;;5800:2:169;7840:72:86;;;5782:21:169;5839:2;5819:18;;;5812:30;5878:34;5858:18;;;5851:62;5949:8;5929:18;;;5922:36;5975:19;;7840:72:86;5598:402:169;7840:72:86;-1:-1:-1;;;;;7946:15:86;;;:9;:15;;;;;;;;;;;7964:20;;;7946:38;;8161:13;;;;;;;;;;:23;;;;;;8210:26;;1473:25:169;;;8161:13:86;;8210:26;;1446:18:169;8210:26:86;;;;;;;8247:37;12180:121;14:656:169;126:4;155:2;184;173:9;166:21;216:6;210:13;259:6;254:2;243:9;239:18;232:34;284:1;294:140;308:6;305:1;302:13;294:140;;;403:14;;;399:23;;393:30;369:17;;;388:2;365:26;358:66;323:10;;294:140;;;452:6;449:1;446:13;443:91;;;522:1;517:2;508:6;497:9;493:22;489:31;482:42;443:91;-1:-1:-1;586:2:169;574:15;591:66;570:88;555:104;;;;661:2;551:113;;14:656;-1:-1:-1;;;14:656:169:o;675:196::-;743:20;;-1:-1:-1;;;;;792:54:169;;782:65;;772:93;;861:1;858;851:12;772:93;675:196;;;:::o;876:254::-;944:6;952;1005:2;993:9;984:7;980:23;976:32;973:52;;;1021:1;1018;1011:12;973:52;1044:29;1063:9;1044:29;:::i;:::-;1034:39;1120:2;1105:18;;;;1092:32;;-1:-1:-1;;;876:254:169:o;1509:328::-;1586:6;1594;1602;1655:2;1643:9;1634:7;1630:23;1626:32;1623:52;;;1671:1;1668;1661:12;1623:52;1694:29;1713:9;1694:29;:::i;:::-;1684:39;;1742:38;1776:2;1765:9;1761:18;1742:38;:::i;:::-;1732:48;;1827:2;1816:9;1812:18;1799:32;1789:42;;1509:328;;;;;:::o;2031:186::-;2090:6;2143:2;2131:9;2122:7;2118:23;2114:32;2111:52;;;2159:1;2156;2149:12;2111:52;2182:29;2201:9;2182:29;:::i;:::-;2172:39;2031:186;-1:-1:-1;;;2031:186:169:o;2222:260::-;2290:6;2298;2351:2;2339:9;2330:7;2326:23;2322:32;2319:52;;;2367:1;2364;2357:12;2319:52;2390:29;2409:9;2390:29;:::i;:::-;2380:39;;2438:38;2472:2;2461:9;2457:18;2438:38;:::i;:::-;2428:48;;2222:260;;;;;:::o;2487:437::-;2566:1;2562:12;;;;2609;;;2630:61;;2684:4;2676:6;2672:17;2662:27;;2630:61;2737:2;2729:6;2726:14;2706:18;2703:38;2700:218;;;2774:77;2771:1;2764:88;2875:4;2872:1;2865:15;2903:4;2900:1;2893:15;2700:218;;2487:437;;;:::o;2929:282::-;2969:3;3000:1;2996:6;2993:1;2990:13;2987:193;;;3036:77;3033:1;3026:88;3137:4;3134:1;3127:15;3165:4;3162:1;3155:15;2987:193;-1:-1:-1;3196:9:169;;2929:282::o", - "linkReferences": {} - }, - "methodIdentifiers": { - "allowance(address,address)": "dd62ed3e", - "approve(address,uint256)": "095ea7b3", - "balanceOf(address)": "70a08231", - "decimals()": "313ce567", - "decreaseAllowance(address,uint256)": "a457c2d7", - "increaseAllowance(address,uint256)": "39509351", - "name()": "06fdde03", - "symbol()": "95d89b41", - "totalSupply()": "18160ddd", - "transfer(address,uint256)": "a9059cbb", - "transferFrom(address,address,uint256)": "23b872dd" - }, - "rawMetadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implementation of the {IERC20} interface. This implementation is agnostic to the way tokens are created. This means that a supply mechanism has to be added in a derived contract using {_mint}. For a generic mechanism see {ERC20PresetMinterPauser}. TIP: For a detailed writeup see our guide https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How to implement supply mechanisms]. We have followed general OpenZeppelin Contracts guidelines: functions revert instead returning `false` on failure. This behavior is nonetheless conventional and does not conflict with the expectations of ERC20 applications. Additionally, an {Approval} event is emitted on calls to {transferFrom}. This allows applications to reconstruct the allowance for all accounts just by listening to said events. Other implementations of the EIP may not emit these events, as it isn't required by the specification. Finally, the non-standard {decreaseAllowance} and {increaseAllowance} functions have been added to mitigate the well-known issues around setting allowances. See {IERC20-approve}.\",\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"constructor\":{\"details\":\"Sets the values for {name} and {symbol}. The default value of {decimals} is 18. To select a different value for {decimals} you should overload it. All two of these values are immutable: they can only be set once during construction.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol\":\"ERC20\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[\":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/\",\":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/\",\":@uniswap/v2-core/=lib/v2-core/\",\":@uniswap/v2-periphery/=lib/v2-periphery/\",\":aztec-connect-bridges/=lib/aztec-connect-bridges/src/\",\":bridge-deployments/=lib/aztec-connect-bridges/src/deployment/\",\":bridge-interfaces/=lib/aztec-connect-bridges/src/interfaces/\",\":bridge-tests/=lib/aztec-connect-bridges/src/test/\",\":core/=src/core/\",\":ds-test/=lib/forge-std/lib/ds-test/src/\",\":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/\",\":forge-std/=lib/forge-std/src/\",\":mocks/=src/test/mocks/\",\":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/\",\":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/\",\":periphery/=src/periphery/\",\":rollup-encoder/=lib/rollup-encoder/src/\",\":v2-core/=lib/v2-core/contracts/\",\":v2-periphery/=lib/v2-periphery/contracts/\"]},\"sources\":{\"lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://15f52f51413a9de1ff191e2f6367c62178e1df7806d7880fe857a98b0b66253d\",\"dweb:/ipfs/QmaQG1fwfgUt5E9nu2cccFiV47B2V78MM1tCy1qB7n4MsH\"]},\"lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34\",\"dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr\"]},\"lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd\",\"dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8\"]},\"lib/openzeppelin-contracts/contracts/utils/Context.sol\":{\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92\",\"dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3\"]}},\"version\":1}", - "metadata": { - "compiler": { - "version": "0.8.10+commit.fc410830" - }, - "language": "Solidity", - "output": { - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "name_", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol_", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address", - "indexed": true - }, - { - "internalType": "address", - "name": "spender", - "type": "address", - "indexed": true - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256", - "indexed": false - } - ], - "type": "event", - "name": "Approval", - "anonymous": false - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address", - "indexed": true - }, - { - "internalType": "address", - "name": "to", - "type": "address", - "indexed": true - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256", - "indexed": false - } - ], - "type": "event", - "name": "Transfer", - "anonymous": false - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - } - ], - "devdoc": { - "kind": "dev", - "methods": { - "allowance(address,address)": { - "details": "See {IERC20-allowance}." - }, - "approve(address,uint256)": { - "details": "See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address." - }, - "balanceOf(address)": { - "details": "See {IERC20-balanceOf}." - }, - "constructor": { - "details": "Sets the values for {name} and {symbol}. The default value of {decimals} is 18. To select a different value for {decimals} you should overload it. All two of these values are immutable: they can only be set once during construction." - }, - "decimals()": { - "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." - }, - "decreaseAllowance(address,uint256)": { - "details": "Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`." - }, - "increaseAllowance(address,uint256)": { - "details": "Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address." - }, - "name()": { - "details": "Returns the name of the token." - }, - "symbol()": { - "details": "Returns the symbol of the token, usually a shorter version of the name." - }, - "totalSupply()": { - "details": "See {IERC20-totalSupply}." - }, - "transfer(address,uint256)": { - "details": "See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`." - }, - "transferFrom(address,address,uint256)": { - "details": "See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - } - }, - "settings": { - "remappings": [ - ":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - ":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", - ":@uniswap/v2-core/=lib/v2-core/", - ":@uniswap/v2-periphery/=lib/v2-periphery/", - ":aztec-connect-bridges/=lib/aztec-connect-bridges/src/", - ":bridge-deployments/=lib/aztec-connect-bridges/src/deployment/", - ":bridge-interfaces/=lib/aztec-connect-bridges/src/interfaces/", - ":bridge-tests/=lib/aztec-connect-bridges/src/test/", - ":core/=src/core/", - ":ds-test/=lib/forge-std/lib/ds-test/src/", - ":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", - ":forge-std/=lib/forge-std/src/", - ":mocks/=src/test/mocks/", - ":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - ":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", - ":periphery/=src/periphery/", - ":rollup-encoder/=lib/rollup-encoder/src/", - ":v2-core/=lib/v2-core/contracts/", - ":v2-periphery/=lib/v2-periphery/contracts/" - ], - "optimizer": { - "enabled": true, - "runs": 2000 - }, - "metadata": { - "bytecodeHash": "ipfs" - }, - "compilationTarget": { - "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol": "ERC20" - }, - "libraries": {} - }, - "sources": { - "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol": { - "keccak256": "0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d", - "urls": [ - "bzz-raw://15f52f51413a9de1ff191e2f6367c62178e1df7806d7880fe857a98b0b66253d", - "dweb:/ipfs/QmaQG1fwfgUt5E9nu2cccFiV47B2V78MM1tCy1qB7n4MsH" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": { - "keccak256": "0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b", - "urls": [ - "bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34", - "dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "keccak256": "0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca", - "urls": [ - "bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd", - "dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/utils/Context.sol": { - "keccak256": "0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7", - "urls": [ - "bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92", - "dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3" - ], - "license": "MIT" - } - }, - "version": 1 - }, - "ast": { - "absolutePath": "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol", - "id": 44252, - "exportedSymbols": { - "Context": [ - 45026 - ], - "ERC20": [ - 44251 - ], - "IERC20": [ - 44329 - ], - "IERC20Metadata": [ - 44354 - ] - }, - "nodeType": "SourceUnit", - "src": "105:12907:86", - "nodes": [ - { - "id": 43666, - "nodeType": "PragmaDirective", - "src": "105:23:86", - "nodes": [], - "literals": [ - "solidity", - "^", - "0.8", - ".0" - ] - }, - { - "id": 43667, - "nodeType": "ImportDirective", - "src": "130:22:86", - "nodes": [], - "absolutePath": "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol", - "file": "./IERC20.sol", - "nameLocation": "-1:-1:-1", - "scope": 44252, - "sourceUnit": 44330, - "symbolAliases": [], - "unitAlias": "" - }, - { - "id": 43668, - "nodeType": "ImportDirective", - "src": "153:41:86", - "nodes": [], - "absolutePath": "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol", - "file": "./extensions/IERC20Metadata.sol", - "nameLocation": "-1:-1:-1", - "scope": 44252, - "sourceUnit": 44355, - "symbolAliases": [], - "unitAlias": "" - }, - { - "id": 43669, - "nodeType": "ImportDirective", - "src": "195:33:86", - "nodes": [], - "absolutePath": "lib/openzeppelin-contracts/contracts/utils/Context.sol", - "file": "../../utils/Context.sol", - "nameLocation": "-1:-1:-1", - "scope": 44252, - "sourceUnit": 45027, - "symbolAliases": [], - "unitAlias": "" - }, - { - "id": 44251, - "nodeType": "ContractDefinition", - "src": "1401:11610:86", - "nodes": [ - { - "id": 43680, - "nodeType": "VariableDeclaration", - "src": "1457:45:86", - "nodes": [], - "constant": false, - "mutability": "mutable", - "name": "_balances", - "nameLocation": "1493:9:86", - "scope": 44251, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - }, - "typeName": { - "id": 43679, - "keyType": { - "id": 43677, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1465:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "Mapping", - "src": "1457:27:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - }, - "valueType": { - "id": 43678, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1476:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - }, - "visibility": "private" - }, - { - "id": 43686, - "nodeType": "VariableDeclaration", - "src": "1509:67:86", - "nodes": [], - "constant": false, - "mutability": "mutable", - "name": "_allowances", - "nameLocation": "1565:11:86", - "scope": 44251, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", - "typeString": "mapping(address => mapping(address => uint256))" - }, - "typeName": { - "id": 43685, - "keyType": { - "id": 43681, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1517:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "Mapping", - "src": "1509:47:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", - "typeString": "mapping(address => mapping(address => uint256))" - }, - "valueType": { - "id": 43684, - "keyType": { - "id": 43682, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1536:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "Mapping", - "src": "1528:27:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - }, - "valueType": { - "id": 43683, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1547:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - } - }, - "visibility": "private" - }, - { - "id": 43688, - "nodeType": "VariableDeclaration", - "src": "1583:28:86", - "nodes": [], - "constant": false, - "mutability": "mutable", - "name": "_totalSupply", - "nameLocation": "1599:12:86", - "scope": 44251, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43687, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1583:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "private" - }, - { - "id": 43690, - "nodeType": "VariableDeclaration", - "src": "1618:20:86", - "nodes": [], - "constant": false, - "mutability": "mutable", - "name": "_name", - "nameLocation": "1633:5:86", - "scope": 44251, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string" - }, - "typeName": { - "id": 43689, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "1618:6:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "private" - }, - { - "id": 43692, - "nodeType": "VariableDeclaration", - "src": "1644:22:86", - "nodes": [], - "constant": false, - "mutability": "mutable", - "name": "_symbol", - "nameLocation": "1659:7:86", - "scope": 44251, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string" - }, - "typeName": { - "id": 43691, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "1644:6:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "private" - }, - { - "id": 43709, - "nodeType": "FunctionDefinition", - "src": "1976:113:86", - "nodes": [], - "body": { - "id": 43708, - "nodeType": "Block", - "src": "2032:57:86", - "nodes": [], - "statements": [ - { - "expression": { - "id": 43702, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 43700, - "name": "_name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43690, - "src": "2042:5:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 43701, - "name": "name_", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43695, - "src": "2050:5:86", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - "src": "2042:13:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "id": 43703, - "nodeType": "ExpressionStatement", - "src": "2042:13:86" - }, - { - "expression": { - "id": 43706, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 43704, - "name": "_symbol", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43692, - "src": "2065:7:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 43705, - "name": "symbol_", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43697, - "src": "2075:7:86", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - "src": "2065:17:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "id": 43707, - "nodeType": "ExpressionStatement", - "src": "2065:17:86" - } - ] - }, - "documentation": { - "id": 43693, - "nodeType": "StructuredDocumentation", - "src": "1673:298:86", - "text": " @dev Sets the values for {name} and {symbol}.\n The default value of {decimals} is 18. To select a different value for\n {decimals} you should overload it.\n All two of these values are immutable: they can only be set once during\n construction." - }, - "implemented": true, - "kind": "constructor", - "modifiers": [], - "name": "", - "nameLocation": "-1:-1:-1", - "parameters": { - "id": 43698, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43695, - "mutability": "mutable", - "name": "name_", - "nameLocation": "2002:5:86", - "nodeType": "VariableDeclaration", - "scope": 43709, - "src": "1988:19:86", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 43694, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "1988:6:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43697, - "mutability": "mutable", - "name": "symbol_", - "nameLocation": "2023:7:86", - "nodeType": "VariableDeclaration", - "scope": 43709, - "src": "2009:21:86", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 43696, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "2009:6:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "1987:44:86" - }, - "returnParameters": { - "id": 43699, - "nodeType": "ParameterList", - "parameters": [], - "src": "2032:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - }, - { - "id": 43719, - "nodeType": "FunctionDefinition", - "src": "2154:98:86", - "nodes": [], - "body": { - "id": 43718, - "nodeType": "Block", - "src": "2223:29:86", - "nodes": [], - "statements": [ - { - "expression": { - "id": 43716, - "name": "_name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43690, - "src": "2240:5:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "functionReturnParameters": 43715, - "id": 43717, - "nodeType": "Return", - "src": "2233:12:86" - } - ] - }, - "baseFunctions": [ - 44341 - ], - "documentation": { - "id": 43710, - "nodeType": "StructuredDocumentation", - "src": "2095:54:86", - "text": " @dev Returns the name of the token." - }, - "functionSelector": "06fdde03", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "name", - "nameLocation": "2163:4:86", - "overrides": { - "id": 43712, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "2190:8:86" - }, - "parameters": { - "id": 43711, - "nodeType": "ParameterList", - "parameters": [], - "src": "2167:2:86" - }, - "returnParameters": { - "id": 43715, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43714, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43719, - "src": "2208:13:86", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 43713, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "2208:6:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "2207:15:86" - }, - "scope": 44251, - "stateMutability": "view", - "virtual": true, - "visibility": "public" - }, - { - "id": 43729, - "nodeType": "FunctionDefinition", - "src": "2365:102:86", - "nodes": [], - "body": { - "id": 43728, - "nodeType": "Block", - "src": "2436:31:86", - "nodes": [], - "statements": [ - { - "expression": { - "id": 43726, - "name": "_symbol", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43692, - "src": "2453:7:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "functionReturnParameters": 43725, - "id": 43727, - "nodeType": "Return", - "src": "2446:14:86" - } - ] - }, - "baseFunctions": [ - 44347 - ], - "documentation": { - "id": 43720, - "nodeType": "StructuredDocumentation", - "src": "2258:102:86", - "text": " @dev Returns the symbol of the token, usually a shorter version of the\n name." - }, - "functionSelector": "95d89b41", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "symbol", - "nameLocation": "2374:6:86", - "overrides": { - "id": 43722, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "2403:8:86" - }, - "parameters": { - "id": 43721, - "nodeType": "ParameterList", - "parameters": [], - "src": "2380:2:86" - }, - "returnParameters": { - "id": 43725, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43724, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43729, - "src": "2421:13:86", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 43723, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "2421:6:86", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "2420:15:86" - }, - "scope": 44251, - "stateMutability": "view", - "virtual": true, - "visibility": "public" - }, - { - "id": 43739, - "nodeType": "FunctionDefinition", - "src": "3091:91:86", - "nodes": [], - "body": { - "id": 43738, - "nodeType": "Block", - "src": "3156:26:86", - "nodes": [], - "statements": [ - { - "expression": { - "hexValue": "3138", - "id": 43736, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3173:2:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_18_by_1", - "typeString": "int_const 18" - }, - "value": "18" - }, - "functionReturnParameters": 43735, - "id": 43737, - "nodeType": "Return", - "src": "3166:9:86" - } - ] - }, - "baseFunctions": [ - 44353 - ], - "documentation": { - "id": 43730, - "nodeType": "StructuredDocumentation", - "src": "2473:613:86", - "text": " @dev Returns the number of decimals used to get its user representation.\n For example, if `decimals` equals `2`, a balance of `505` tokens should\n be displayed to a user as `5.05` (`505 / 10 ** 2`).\n Tokens usually opt for a value of 18, imitating the relationship between\n Ether and Wei. This is the value {ERC20} uses, unless this function is\n overridden;\n NOTE: This information is only used for _display_ purposes: it in\n no way affects any of the arithmetic of the contract, including\n {IERC20-balanceOf} and {IERC20-transfer}." - }, - "functionSelector": "313ce567", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "decimals", - "nameLocation": "3100:8:86", - "overrides": { - "id": 43732, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "3131:8:86" - }, - "parameters": { - "id": 43731, - "nodeType": "ParameterList", - "parameters": [], - "src": "3108:2:86" - }, - "returnParameters": { - "id": 43735, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43734, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43739, - "src": "3149:5:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - "typeName": { - "id": 43733, - "name": "uint8", - "nodeType": "ElementaryTypeName", - "src": "3149:5:86", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "visibility": "internal" - } - ], - "src": "3148:7:86" - }, - "scope": 44251, - "stateMutability": "view", - "virtual": true, - "visibility": "public" - }, - { - "id": 43749, - "nodeType": "FunctionDefinition", - "src": "3242:106:86", - "nodes": [], - "body": { - "id": 43748, - "nodeType": "Block", - "src": "3312:36:86", - "nodes": [], - "statements": [ - { - "expression": { - "id": 43746, - "name": "_totalSupply", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43688, - "src": "3329:12:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 43745, - "id": 43747, - "nodeType": "Return", - "src": "3322:19:86" - } - ] - }, - "baseFunctions": [ - 44278 - ], - "documentation": { - "id": 43740, - "nodeType": "StructuredDocumentation", - "src": "3188:49:86", - "text": " @dev See {IERC20-totalSupply}." - }, - "functionSelector": "18160ddd", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "totalSupply", - "nameLocation": "3251:11:86", - "overrides": { - "id": 43742, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "3285:8:86" - }, - "parameters": { - "id": 43741, - "nodeType": "ParameterList", - "parameters": [], - "src": "3262:2:86" - }, - "returnParameters": { - "id": 43745, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43744, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43749, - "src": "3303:7:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43743, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "3303:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "3302:9:86" - }, - "scope": 44251, - "stateMutability": "view", - "virtual": true, - "visibility": "public" - }, - { - "id": 43763, - "nodeType": "FunctionDefinition", - "src": "3406:125:86", - "nodes": [], - "body": { - "id": 43762, - "nodeType": "Block", - "src": "3489:42:86", - "nodes": [], - "statements": [ - { - "expression": { - "baseExpression": { - "id": 43758, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "3506:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 43760, - "indexExpression": { - "id": 43759, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43752, - "src": "3516:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3506:18:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 43757, - "id": 43761, - "nodeType": "Return", - "src": "3499:25:86" - } - ] - }, - "baseFunctions": [ - 44286 - ], - "documentation": { - "id": 43750, - "nodeType": "StructuredDocumentation", - "src": "3354:47:86", - "text": " @dev See {IERC20-balanceOf}." - }, - "functionSelector": "70a08231", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "balanceOf", - "nameLocation": "3415:9:86", - "overrides": { - "id": 43754, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "3462:8:86" - }, - "parameters": { - "id": 43753, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43752, - "mutability": "mutable", - "name": "account", - "nameLocation": "3433:7:86", - "nodeType": "VariableDeclaration", - "scope": 43763, - "src": "3425:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43751, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "3425:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "src": "3424:17:86" - }, - "returnParameters": { - "id": 43757, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43756, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43763, - "src": "3480:7:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43755, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "3480:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "3479:9:86" - }, - "scope": 44251, - "stateMutability": "view", - "virtual": true, - "visibility": "public" - }, - { - "id": 43788, - "nodeType": "FunctionDefinition", - "src": "3727:189:86", - "nodes": [], - "body": { - "id": 43787, - "nodeType": "Block", - "src": "3812:104:86", - "nodes": [], - "statements": [ - { - "assignments": [ - 43775 - ], - "declarations": [ - { - "constant": false, - "id": 43775, - "mutability": "mutable", - "name": "owner", - "nameLocation": "3830:5:86", - "nodeType": "VariableDeclaration", - "scope": 43787, - "src": "3822:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43774, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "3822:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "id": 43778, - "initialValue": { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 43776, - "name": "_msgSender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45016, - "src": "3838:10:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", - "typeString": "function () view returns (address)" - } - }, - "id": 43777, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3838:12:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "3822:28:86" - }, - { - "expression": { - "arguments": [ - { - "id": 43780, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43775, - "src": "3870:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43781, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43766, - "src": "3877:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43782, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43768, - "src": "3881:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43779, - "name": "_transfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44011, - "src": "3860:9:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43783, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3860:28:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43784, - "nodeType": "ExpressionStatement", - "src": "3860:28:86" - }, - { - "expression": { - "hexValue": "74727565", - "id": 43785, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3905:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 43773, - "id": 43786, - "nodeType": "Return", - "src": "3898:11:86" - } - ] - }, - "baseFunctions": [ - 44296 - ], - "documentation": { - "id": 43764, - "nodeType": "StructuredDocumentation", - "src": "3537:185:86", - "text": " @dev See {IERC20-transfer}.\n Requirements:\n - `to` cannot be the zero address.\n - the caller must have a balance of at least `amount`." - }, - "functionSelector": "a9059cbb", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "transfer", - "nameLocation": "3736:8:86", - "overrides": { - "id": 43770, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "3788:8:86" - }, - "parameters": { - "id": 43769, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43766, - "mutability": "mutable", - "name": "to", - "nameLocation": "3753:2:86", - "nodeType": "VariableDeclaration", - "scope": 43788, - "src": "3745:10:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43765, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "3745:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43768, - "mutability": "mutable", - "name": "amount", - "nameLocation": "3765:6:86", - "nodeType": "VariableDeclaration", - "scope": 43788, - "src": "3757:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43767, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "3757:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "3744:28:86" - }, - "returnParameters": { - "id": 43773, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43772, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43788, - "src": "3806:4:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 43771, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "3806:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - } - ], - "src": "3805:6:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "public" - }, - { - "id": 43806, - "nodeType": "FunctionDefinition", - "src": "3974:149:86", - "nodes": [], - "body": { - "id": 43805, - "nodeType": "Block", - "src": "4072:51:86", - "nodes": [], - "statements": [ - { - "expression": { - "baseExpression": { - "baseExpression": { - "id": 43799, - "name": "_allowances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43686, - "src": "4089:11:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", - "typeString": "mapping(address => mapping(address => uint256))" - } - }, - "id": 43801, - "indexExpression": { - "id": 43800, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43791, - "src": "4101:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4089:18:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 43803, - "indexExpression": { - "id": 43802, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43793, - "src": "4108:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4089:27:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 43798, - "id": 43804, - "nodeType": "Return", - "src": "4082:34:86" - } - ] - }, - "baseFunctions": [ - 44306 - ], - "documentation": { - "id": 43789, - "nodeType": "StructuredDocumentation", - "src": "3922:47:86", - "text": " @dev See {IERC20-allowance}." - }, - "functionSelector": "dd62ed3e", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "allowance", - "nameLocation": "3983:9:86", - "overrides": { - "id": 43795, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "4045:8:86" - }, - "parameters": { - "id": 43794, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43791, - "mutability": "mutable", - "name": "owner", - "nameLocation": "4001:5:86", - "nodeType": "VariableDeclaration", - "scope": 43806, - "src": "3993:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43790, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "3993:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43793, - "mutability": "mutable", - "name": "spender", - "nameLocation": "4016:7:86", - "nodeType": "VariableDeclaration", - "scope": 43806, - "src": "4008:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43792, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "4008:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "src": "3992:32:86" - }, - "returnParameters": { - "id": 43798, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43797, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43806, - "src": "4063:7:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43796, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "4063:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "4062:9:86" - }, - "scope": 44251, - "stateMutability": "view", - "virtual": true, - "visibility": "public" - }, - { - "id": 43831, - "nodeType": "FunctionDefinition", - "src": "4431:197:86", - "nodes": [], - "body": { - "id": 43830, - "nodeType": "Block", - "src": "4520:108:86", - "nodes": [], - "statements": [ - { - "assignments": [ - 43818 - ], - "declarations": [ - { - "constant": false, - "id": 43818, - "mutability": "mutable", - "name": "owner", - "nameLocation": "4538:5:86", - "nodeType": "VariableDeclaration", - "scope": 43830, - "src": "4530:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43817, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "4530:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "id": 43821, - "initialValue": { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 43819, - "name": "_msgSender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45016, - "src": "4546:10:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", - "typeString": "function () view returns (address)" - } - }, - "id": 43820, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4546:12:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "4530:28:86" - }, - { - "expression": { - "arguments": [ - { - "id": 43823, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43818, - "src": "4577:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43824, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43809, - "src": "4584:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43825, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43811, - "src": "4593:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43822, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "4568:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43826, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4568:32:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43827, - "nodeType": "ExpressionStatement", - "src": "4568:32:86" - }, - { - "expression": { - "hexValue": "74727565", - "id": 43828, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "4617:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 43816, - "id": 43829, - "nodeType": "Return", - "src": "4610:11:86" - } - ] - }, - "baseFunctions": [ - 44316 - ], - "documentation": { - "id": 43807, - "nodeType": "StructuredDocumentation", - "src": "4129:297:86", - "text": " @dev See {IERC20-approve}.\n NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n `transferFrom`. This is semantically equivalent to an infinite approval.\n Requirements:\n - `spender` cannot be the zero address." - }, - "functionSelector": "095ea7b3", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "approve", - "nameLocation": "4440:7:86", - "overrides": { - "id": 43813, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "4496:8:86" - }, - "parameters": { - "id": 43812, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43809, - "mutability": "mutable", - "name": "spender", - "nameLocation": "4456:7:86", - "nodeType": "VariableDeclaration", - "scope": 43831, - "src": "4448:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43808, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "4448:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43811, - "mutability": "mutable", - "name": "amount", - "nameLocation": "4473:6:86", - "nodeType": "VariableDeclaration", - "scope": 43831, - "src": "4465:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43810, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "4465:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "4447:33:86" - }, - "returnParameters": { - "id": 43816, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43815, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43831, - "src": "4514:4:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 43814, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "4514:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - } - ], - "src": "4513:6:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "public" - }, - { - "id": 43864, - "nodeType": "FunctionDefinition", - "src": "5190:286:86", - "nodes": [], - "body": { - "id": 43863, - "nodeType": "Block", - "src": "5323:153:86", - "nodes": [], - "statements": [ - { - "assignments": [ - 43845 - ], - "declarations": [ - { - "constant": false, - "id": 43845, - "mutability": "mutable", - "name": "spender", - "nameLocation": "5341:7:86", - "nodeType": "VariableDeclaration", - "scope": 43863, - "src": "5333:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43844, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5333:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "id": 43848, - "initialValue": { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 43846, - "name": "_msgSender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45016, - "src": "5351:10:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", - "typeString": "function () view returns (address)" - } - }, - "id": 43847, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5351:12:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "5333:30:86" - }, - { - "expression": { - "arguments": [ - { - "id": 43850, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43834, - "src": "5389:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43851, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43845, - "src": "5395:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43852, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43838, - "src": "5404:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43849, - "name": "_spendAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44228, - "src": "5373:15:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43853, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5373:38:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43854, - "nodeType": "ExpressionStatement", - "src": "5373:38:86" - }, - { - "expression": { - "arguments": [ - { - "id": 43856, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43834, - "src": "5431:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43857, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43836, - "src": "5437:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43858, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43838, - "src": "5441:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43855, - "name": "_transfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44011, - "src": "5421:9:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43859, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5421:27:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43860, - "nodeType": "ExpressionStatement", - "src": "5421:27:86" - }, - { - "expression": { - "hexValue": "74727565", - "id": 43861, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5465:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 43843, - "id": 43862, - "nodeType": "Return", - "src": "5458:11:86" - } - ] - }, - "baseFunctions": [ - 44328 - ], - "documentation": { - "id": 43832, - "nodeType": "StructuredDocumentation", - "src": "4634:551:86", - "text": " @dev See {IERC20-transferFrom}.\n Emits an {Approval} event indicating the updated allowance. This is not\n required by the EIP. See the note at the beginning of {ERC20}.\n NOTE: Does not update the allowance if the current allowance\n is the maximum `uint256`.\n Requirements:\n - `from` and `to` cannot be the zero address.\n - `from` must have a balance of at least `amount`.\n - the caller must have allowance for ``from``'s tokens of at least\n `amount`." - }, - "functionSelector": "23b872dd", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "transferFrom", - "nameLocation": "5199:12:86", - "overrides": { - "id": 43840, - "nodeType": "OverrideSpecifier", - "overrides": [], - "src": "5299:8:86" - }, - "parameters": { - "id": 43839, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43834, - "mutability": "mutable", - "name": "from", - "nameLocation": "5229:4:86", - "nodeType": "VariableDeclaration", - "scope": 43864, - "src": "5221:12:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43833, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5221:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43836, - "mutability": "mutable", - "name": "to", - "nameLocation": "5251:2:86", - "nodeType": "VariableDeclaration", - "scope": 43864, - "src": "5243:10:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43835, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5243:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43838, - "mutability": "mutable", - "name": "amount", - "nameLocation": "5271:6:86", - "nodeType": "VariableDeclaration", - "scope": 43864, - "src": "5263:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43837, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "5263:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "5211:72:86" - }, - "returnParameters": { - "id": 43843, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43842, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43864, - "src": "5317:4:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 43841, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "5317:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - } - ], - "src": "5316:6:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "public" - }, - { - "id": 43893, - "nodeType": "FunctionDefinition", - "src": "5871:234:86", - "nodes": [], - "body": { - "id": 43892, - "nodeType": "Block", - "src": "5965:140:86", - "nodes": [], - "statements": [ - { - "assignments": [ - 43875 - ], - "declarations": [ - { - "constant": false, - "id": 43875, - "mutability": "mutable", - "name": "owner", - "nameLocation": "5983:5:86", - "nodeType": "VariableDeclaration", - "scope": 43892, - "src": "5975:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43874, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5975:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "id": 43878, - "initialValue": { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 43876, - "name": "_msgSender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45016, - "src": "5991:10:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", - "typeString": "function () view returns (address)" - } - }, - "id": 43877, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5991:12:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "5975:28:86" - }, - { - "expression": { - "arguments": [ - { - "id": 43880, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43875, - "src": "6022:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43881, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43867, - "src": "6029:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 43887, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "arguments": [ - { - "id": 43883, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43875, - "src": "6048:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43884, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43867, - "src": "6055:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 43882, - "name": "allowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43806, - "src": "6038:9:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$_t_address_$returns$_t_uint256_$", - "typeString": "function (address,address) view returns (uint256)" - } - }, - "id": 43885, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6038:25:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "+", - "rightExpression": { - "id": 43886, - "name": "addedValue", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43869, - "src": "6066:10:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "6038:38:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43879, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "6013:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43888, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6013:64:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43889, - "nodeType": "ExpressionStatement", - "src": "6013:64:86" - }, - { - "expression": { - "hexValue": "74727565", - "id": 43890, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6094:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 43873, - "id": 43891, - "nodeType": "Return", - "src": "6087:11:86" - } - ] - }, - "documentation": { - "id": 43865, - "nodeType": "StructuredDocumentation", - "src": "5482:384:86", - "text": " @dev Atomically increases the allowance granted to `spender` by the caller.\n This is an alternative to {approve} that can be used as a mitigation for\n problems described in {IERC20-approve}.\n Emits an {Approval} event indicating the updated allowance.\n Requirements:\n - `spender` cannot be the zero address." - }, - "functionSelector": "39509351", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "increaseAllowance", - "nameLocation": "5880:17:86", - "parameters": { - "id": 43870, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43867, - "mutability": "mutable", - "name": "spender", - "nameLocation": "5906:7:86", - "nodeType": "VariableDeclaration", - "scope": 43893, - "src": "5898:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43866, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5898:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43869, - "mutability": "mutable", - "name": "addedValue", - "nameLocation": "5923:10:86", - "nodeType": "VariableDeclaration", - "scope": 43893, - "src": "5915:18:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43868, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "5915:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "5897:37:86" - }, - "returnParameters": { - "id": 43873, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43872, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43893, - "src": "5959:4:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 43871, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "5959:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - } - ], - "src": "5958:6:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "public" - }, - { - "id": 43934, - "nodeType": "FunctionDefinition", - "src": "6592:427:86", - "nodes": [], - "body": { - "id": 43933, - "nodeType": "Block", - "src": "6691:328:86", - "nodes": [], - "statements": [ - { - "assignments": [ - 43904 - ], - "declarations": [ - { - "constant": false, - "id": 43904, - "mutability": "mutable", - "name": "owner", - "nameLocation": "6709:5:86", - "nodeType": "VariableDeclaration", - "scope": 43933, - "src": "6701:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43903, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "6701:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "id": 43907, - "initialValue": { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 43905, - "name": "_msgSender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45016, - "src": "6717:10:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_address_$", - "typeString": "function () view returns (address)" - } - }, - "id": 43906, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6717:12:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "6701:28:86" - }, - { - "assignments": [ - 43909 - ], - "declarations": [ - { - "constant": false, - "id": 43909, - "mutability": "mutable", - "name": "currentAllowance", - "nameLocation": "6747:16:86", - "nodeType": "VariableDeclaration", - "scope": 43933, - "src": "6739:24:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43908, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "6739:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "id": 43914, - "initialValue": { - "arguments": [ - { - "id": 43911, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43904, - "src": "6776:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43912, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43896, - "src": "6783:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 43910, - "name": "allowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43806, - "src": "6766:9:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$_t_address_$returns$_t_uint256_$", - "typeString": "function (address,address) view returns (uint256)" - } - }, - "id": 43913, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6766:25:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "6739:52:86" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 43918, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 43916, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43909, - "src": "6809:16:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "id": 43917, - "name": "subtractedValue", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43898, - "src": "6829:15:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "6809:35:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f", - "id": 43919, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6846:39:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_f8b476f7d28209d77d4a4ac1fe36b9f8259aa1bb6bddfa6e89de7e51615cf8a8", - "typeString": "literal_string \"ERC20: decreased allowance below zero\"" - }, - "value": "ERC20: decreased allowance below zero" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_f8b476f7d28209d77d4a4ac1fe36b9f8259aa1bb6bddfa6e89de7e51615cf8a8", - "typeString": "literal_string \"ERC20: decreased allowance below zero\"" - } - ], - "id": 43915, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "6801:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 43920, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6801:85:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43921, - "nodeType": "ExpressionStatement", - "src": "6801:85:86" - }, - { - "id": 43930, - "nodeType": "UncheckedBlock", - "src": "6896:95:86", - "statements": [ - { - "expression": { - "arguments": [ - { - "id": 43923, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43904, - "src": "6929:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43924, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43896, - "src": "6936:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 43927, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 43925, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43909, - "src": "6945:16:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "id": 43926, - "name": "subtractedValue", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43898, - "src": "6964:15:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "6945:34:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43922, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "6920:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43928, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6920:60:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43929, - "nodeType": "ExpressionStatement", - "src": "6920:60:86" - } - ] - }, - { - "expression": { - "hexValue": "74727565", - "id": 43931, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "7008:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 43902, - "id": 43932, - "nodeType": "Return", - "src": "7001:11:86" - } - ] - }, - "documentation": { - "id": 43894, - "nodeType": "StructuredDocumentation", - "src": "6111:476:86", - "text": " @dev Atomically decreases the allowance granted to `spender` by the caller.\n This is an alternative to {approve} that can be used as a mitigation for\n problems described in {IERC20-approve}.\n Emits an {Approval} event indicating the updated allowance.\n Requirements:\n - `spender` cannot be the zero address.\n - `spender` must have allowance for the caller of at least\n `subtractedValue`." - }, - "functionSelector": "a457c2d7", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "decreaseAllowance", - "nameLocation": "6601:17:86", - "parameters": { - "id": 43899, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43896, - "mutability": "mutable", - "name": "spender", - "nameLocation": "6627:7:86", - "nodeType": "VariableDeclaration", - "scope": 43934, - "src": "6619:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43895, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "6619:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43898, - "mutability": "mutable", - "name": "subtractedValue", - "nameLocation": "6644:15:86", - "nodeType": "VariableDeclaration", - "scope": 43934, - "src": "6636:23:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43897, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "6636:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "6618:42:86" - }, - "returnParameters": { - "id": 43902, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43901, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 43934, - "src": "6685:4:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 43900, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "6685:4:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - } - ], - "src": "6684:6:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "public" - }, - { - "id": 44011, - "nodeType": "FunctionDefinition", - "src": "7473:818:86", - "nodes": [], - "body": { - "id": 44010, - "nodeType": "Block", - "src": "7581:710:86", - "nodes": [], - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 43950, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 43945, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43937, - "src": "7599:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 43948, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "7615:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 43947, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "7607:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 43946, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "7607:7:86", - "typeDescriptions": {} - } - }, - "id": 43949, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7607:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "7599:18:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373", - "id": 43951, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "7619:39:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_baecc556b46f4ed0f2b4cb599d60785ac8563dd2dc0a5bf12edea1c39e5e1fea", - "typeString": "literal_string \"ERC20: transfer from the zero address\"" - }, - "value": "ERC20: transfer from the zero address" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_baecc556b46f4ed0f2b4cb599d60785ac8563dd2dc0a5bf12edea1c39e5e1fea", - "typeString": "literal_string \"ERC20: transfer from the zero address\"" - } - ], - "id": 43944, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "7591:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 43952, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7591:68:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43953, - "nodeType": "ExpressionStatement", - "src": "7591:68:86" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 43960, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 43955, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43939, - "src": "7677:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 43958, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "7691:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 43957, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "7683:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 43956, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "7683:7:86", - "typeDescriptions": {} - } - }, - "id": 43959, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7683:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "7677:16:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a207472616e7366657220746f20746865207a65726f2061646472657373", - "id": 43961, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "7695:37:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_0557e210f7a69a685100a7e4e3d0a7024c546085cee28910fd17d0b081d9516f", - "typeString": "literal_string \"ERC20: transfer to the zero address\"" - }, - "value": "ERC20: transfer to the zero address" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_0557e210f7a69a685100a7e4e3d0a7024c546085cee28910fd17d0b081d9516f", - "typeString": "literal_string \"ERC20: transfer to the zero address\"" - } - ], - "id": 43954, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "7669:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 43962, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7669:64:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43963, - "nodeType": "ExpressionStatement", - "src": "7669:64:86" - }, - { - "expression": { - "arguments": [ - { - "id": 43965, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43937, - "src": "7765:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43966, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43939, - "src": "7771:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 43967, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43941, - "src": "7775:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43964, - "name": "_beforeTokenTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44239, - "src": "7744:20:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 43968, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7744:38:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43969, - "nodeType": "ExpressionStatement", - "src": "7744:38:86" - }, - { - "assignments": [ - 43971 - ], - "declarations": [ - { - "constant": false, - "id": 43971, - "mutability": "mutable", - "name": "fromBalance", - "nameLocation": "7801:11:86", - "nodeType": "VariableDeclaration", - "scope": 44010, - "src": "7793:19:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43970, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "7793:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "id": 43975, - "initialValue": { - "baseExpression": { - "id": 43972, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "7815:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 43974, - "indexExpression": { - "id": 43973, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43937, - "src": "7825:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "7815:15:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "7793:37:86" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 43979, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 43977, - "name": "fromBalance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43971, - "src": "7848:11:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "id": 43978, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43941, - "src": "7863:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "7848:21:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365", - "id": 43980, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "7871:40:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_4107e8a8b9e94bf8ff83080ddec1c0bffe897ebc2241b89d44f66b3d274088b6", - "typeString": "literal_string \"ERC20: transfer amount exceeds balance\"" - }, - "value": "ERC20: transfer amount exceeds balance" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_4107e8a8b9e94bf8ff83080ddec1c0bffe897ebc2241b89d44f66b3d274088b6", - "typeString": "literal_string \"ERC20: transfer amount exceeds balance\"" - } - ], - "id": 43976, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "7840:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 43981, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7840:72:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 43982, - "nodeType": "ExpressionStatement", - "src": "7840:72:86" - }, - { - "id": 43997, - "nodeType": "UncheckedBlock", - "src": "7922:273:86", - "statements": [ - { - "expression": { - "id": 43989, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "baseExpression": { - "id": 43983, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "7946:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 43985, - "indexExpression": { - "id": 43984, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43937, - "src": "7956:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "7946:15:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 43988, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 43986, - "name": "fromBalance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43971, - "src": "7964:11:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "id": 43987, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43941, - "src": "7978:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "7964:20:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "7946:38:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 43990, - "nodeType": "ExpressionStatement", - "src": "7946:38:86" - }, - { - "expression": { - "id": 43995, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "baseExpression": { - "id": 43991, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "8161:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 43993, - "indexExpression": { - "id": 43992, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43939, - "src": "8171:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "8161:13:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "+=", - "rightHandSide": { - "id": 43994, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43941, - "src": "8178:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "8161:23:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 43996, - "nodeType": "ExpressionStatement", - "src": "8161:23:86" - } - ] - }, - { - "eventCall": { - "arguments": [ - { - "id": 43999, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43937, - "src": "8219:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44000, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43939, - "src": "8225:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44001, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43941, - "src": "8229:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 43998, - "name": "Transfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44263, - "src": "8210:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44002, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8210:26:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44003, - "nodeType": "EmitStatement", - "src": "8205:31:86" - }, - { - "expression": { - "arguments": [ - { - "id": 44005, - "name": "from", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43937, - "src": "8267:4:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44006, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43939, - "src": "8273:2:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44007, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43941, - "src": "8277:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44004, - "name": "_afterTokenTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44250, - "src": "8247:19:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44008, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8247:37:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44009, - "nodeType": "ExpressionStatement", - "src": "8247:37:86" - } - ] - }, - "documentation": { - "id": 43935, - "nodeType": "StructuredDocumentation", - "src": "7025:443:86", - "text": " @dev Moves `amount` of tokens from `from` to `to`.\n This internal function is equivalent to {transfer}, and can be used to\n e.g. implement automatic token fees, slashing mechanisms, etc.\n Emits a {Transfer} event.\n Requirements:\n - `from` cannot be the zero address.\n - `to` cannot be the zero address.\n - `from` must have a balance of at least `amount`." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_transfer", - "nameLocation": "7482:9:86", - "parameters": { - "id": 43942, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 43937, - "mutability": "mutable", - "name": "from", - "nameLocation": "7509:4:86", - "nodeType": "VariableDeclaration", - "scope": 44011, - "src": "7501:12:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43936, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "7501:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43939, - "mutability": "mutable", - "name": "to", - "nameLocation": "7531:2:86", - "nodeType": "VariableDeclaration", - "scope": 44011, - "src": "7523:10:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 43938, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "7523:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 43941, - "mutability": "mutable", - "name": "amount", - "nameLocation": "7551:6:86", - "nodeType": "VariableDeclaration", - "scope": 44011, - "src": "7543:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 43940, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "7543:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "7491:72:86" - }, - "returnParameters": { - "id": 43943, - "nodeType": "ParameterList", - "parameters": [], - "src": "7581:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - }, - { - "id": 44068, - "nodeType": "FunctionDefinition", - "src": "8567:535:86", - "nodes": [], - "body": { - "id": 44067, - "nodeType": "Block", - "src": "8632:470:86", - "nodes": [], - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 44025, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44020, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44014, - "src": "8650:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 44023, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8669:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44022, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "8661:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44021, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "8661:7:86", - "typeDescriptions": {} - } - }, - "id": 44024, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8661:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "8650:21:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a206d696e7420746f20746865207a65726f2061646472657373", - "id": 44026, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8673:33:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_fc0b381caf0a47702017f3c4b358ebe3d3aff6c60ce819a8bf3ef5a95d4f202e", - "typeString": "literal_string \"ERC20: mint to the zero address\"" - }, - "value": "ERC20: mint to the zero address" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_fc0b381caf0a47702017f3c4b358ebe3d3aff6c60ce819a8bf3ef5a95d4f202e", - "typeString": "literal_string \"ERC20: mint to the zero address\"" - } - ], - "id": 44019, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "8642:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 44027, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8642:65:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44028, - "nodeType": "ExpressionStatement", - "src": "8642:65:86" - }, - { - "expression": { - "arguments": [ - { - "arguments": [ - { - "hexValue": "30", - "id": 44032, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8747:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44031, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "8739:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44030, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "8739:7:86", - "typeDescriptions": {} - } - }, - "id": 44033, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8739:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44034, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44014, - "src": "8751:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44035, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44016, - "src": "8760:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44029, - "name": "_beforeTokenTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44239, - "src": "8718:20:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44036, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8718:49:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44037, - "nodeType": "ExpressionStatement", - "src": "8718:49:86" - }, - { - "expression": { - "id": 44040, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 44038, - "name": "_totalSupply", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43688, - "src": "8778:12:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "+=", - "rightHandSide": { - "id": 44039, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44016, - "src": "8794:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "8778:22:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 44041, - "nodeType": "ExpressionStatement", - "src": "8778:22:86" - }, - { - "id": 44048, - "nodeType": "UncheckedBlock", - "src": "8810:175:86", - "statements": [ - { - "expression": { - "id": 44046, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "baseExpression": { - "id": 44042, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "8946:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 44044, - "indexExpression": { - "id": 44043, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44014, - "src": "8956:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "8946:18:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "+=", - "rightHandSide": { - "id": 44045, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44016, - "src": "8968:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "8946:28:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 44047, - "nodeType": "ExpressionStatement", - "src": "8946:28:86" - } - ] - }, - { - "eventCall": { - "arguments": [ - { - "arguments": [ - { - "hexValue": "30", - "id": 44052, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9016:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44051, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "9008:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44050, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "9008:7:86", - "typeDescriptions": {} - } - }, - "id": 44053, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9008:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44054, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44014, - "src": "9020:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44055, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44016, - "src": "9029:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44049, - "name": "Transfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44263, - "src": "8999:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44056, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8999:37:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44057, - "nodeType": "EmitStatement", - "src": "8994:42:86" - }, - { - "expression": { - "arguments": [ - { - "arguments": [ - { - "hexValue": "30", - "id": 44061, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9075:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44060, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "9067:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44059, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "9067:7:86", - "typeDescriptions": {} - } - }, - "id": 44062, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9067:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44063, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44014, - "src": "9079:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44064, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44016, - "src": "9088:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44058, - "name": "_afterTokenTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44250, - "src": "9047:19:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44065, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9047:48:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44066, - "nodeType": "ExpressionStatement", - "src": "9047:48:86" - } - ] - }, - "documentation": { - "id": 44012, - "nodeType": "StructuredDocumentation", - "src": "8297:265:86", - "text": "@dev Creates `amount` tokens and assigns them to `account`, increasing\n the total supply.\n Emits a {Transfer} event with `from` set to the zero address.\n Requirements:\n - `account` cannot be the zero address." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_mint", - "nameLocation": "8576:5:86", - "parameters": { - "id": 44017, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 44014, - "mutability": "mutable", - "name": "account", - "nameLocation": "8590:7:86", - "nodeType": "VariableDeclaration", - "scope": 44068, - "src": "8582:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44013, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "8582:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44016, - "mutability": "mutable", - "name": "amount", - "nameLocation": "8607:6:86", - "nodeType": "VariableDeclaration", - "scope": 44068, - "src": "8599:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44015, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "8599:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "8581:33:86" - }, - "returnParameters": { - "id": 44018, - "nodeType": "ParameterList", - "parameters": [], - "src": "8632:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - }, - { - "id": 44140, - "nodeType": "FunctionDefinition", - "src": "9422:659:86", - "nodes": [], - "body": { - "id": 44139, - "nodeType": "Block", - "src": "9487:594:86", - "nodes": [], - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 44082, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44077, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44071, - "src": "9505:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 44080, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9524:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44079, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "9516:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44078, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "9516:7:86", - "typeDescriptions": {} - } - }, - "id": 44081, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9516:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "9505:21:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a206275726e2066726f6d20746865207a65726f2061646472657373", - "id": 44083, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9528:35:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_b16788493b576042bb52c50ed56189e0b250db113c7bfb1c3897d25cf9632d7f", - "typeString": "literal_string \"ERC20: burn from the zero address\"" - }, - "value": "ERC20: burn from the zero address" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_b16788493b576042bb52c50ed56189e0b250db113c7bfb1c3897d25cf9632d7f", - "typeString": "literal_string \"ERC20: burn from the zero address\"" - } - ], - "id": 44076, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "9497:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 44084, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9497:67:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44085, - "nodeType": "ExpressionStatement", - "src": "9497:67:86" - }, - { - "expression": { - "arguments": [ - { - "id": 44087, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44071, - "src": "9596:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "arguments": [ - { - "hexValue": "30", - "id": 44090, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9613:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44089, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "9605:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44088, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "9605:7:86", - "typeDescriptions": {} - } - }, - "id": 44091, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9605:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44092, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44073, - "src": "9617:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44086, - "name": "_beforeTokenTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44239, - "src": "9575:20:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44093, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9575:49:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44094, - "nodeType": "ExpressionStatement", - "src": "9575:49:86" - }, - { - "assignments": [ - 44096 - ], - "declarations": [ - { - "constant": false, - "id": 44096, - "mutability": "mutable", - "name": "accountBalance", - "nameLocation": "9643:14:86", - "nodeType": "VariableDeclaration", - "scope": 44139, - "src": "9635:22:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44095, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "9635:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "id": 44100, - "initialValue": { - "baseExpression": { - "id": 44097, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "9660:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 44099, - "indexExpression": { - "id": 44098, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44071, - "src": "9670:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "9660:18:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "9635:43:86" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 44104, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44102, - "name": "accountBalance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44096, - "src": "9696:14:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "id": 44103, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44073, - "src": "9714:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "9696:24:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a206275726e20616d6f756e7420657863656564732062616c616e6365", - "id": 44105, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9722:36:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_149b126e7125232b4200af45303d04fba8b74653b1a295a6a561a528c33fefdd", - "typeString": "literal_string \"ERC20: burn amount exceeds balance\"" - }, - "value": "ERC20: burn amount exceeds balance" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_149b126e7125232b4200af45303d04fba8b74653b1a295a6a561a528c33fefdd", - "typeString": "literal_string \"ERC20: burn amount exceeds balance\"" - } - ], - "id": 44101, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "9688:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 44106, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9688:71:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44107, - "nodeType": "ExpressionStatement", - "src": "9688:71:86" - }, - { - "id": 44120, - "nodeType": "UncheckedBlock", - "src": "9769:194:86", - "statements": [ - { - "expression": { - "id": 44114, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "baseExpression": { - "id": 44108, - "name": "_balances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43680, - "src": "9793:9:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 44110, - "indexExpression": { - "id": 44109, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44071, - "src": "9803:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9793:18:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 44113, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44111, - "name": "accountBalance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44096, - "src": "9814:14:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "id": 44112, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44073, - "src": "9831:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "9814:23:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "9793:44:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 44115, - "nodeType": "ExpressionStatement", - "src": "9793:44:86" - }, - { - "expression": { - "id": 44118, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 44116, - "name": "_totalSupply", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43688, - "src": "9930:12:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "-=", - "rightHandSide": { - "id": 44117, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44073, - "src": "9946:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "9930:22:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 44119, - "nodeType": "ExpressionStatement", - "src": "9930:22:86" - } - ] - }, - { - "eventCall": { - "arguments": [ - { - "id": 44122, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44071, - "src": "9987:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "arguments": [ - { - "hexValue": "30", - "id": 44125, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "10004:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44124, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "9996:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44123, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "9996:7:86", - "typeDescriptions": {} - } - }, - "id": 44126, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9996:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44127, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44073, - "src": "10008:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44121, - "name": "Transfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44263, - "src": "9978:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44128, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9978:37:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44129, - "nodeType": "EmitStatement", - "src": "9973:42:86" - }, - { - "expression": { - "arguments": [ - { - "id": 44131, - "name": "account", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44071, - "src": "10046:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "arguments": [ - { - "hexValue": "30", - "id": 44134, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "10063:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44133, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "10055:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44132, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "10055:7:86", - "typeDescriptions": {} - } - }, - "id": 44135, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10055:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44136, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44073, - "src": "10067:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44130, - "name": "_afterTokenTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44250, - "src": "10026:19:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44137, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10026:48:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44138, - "nodeType": "ExpressionStatement", - "src": "10026:48:86" - } - ] - }, - "documentation": { - "id": 44069, - "nodeType": "StructuredDocumentation", - "src": "9108:309:86", - "text": " @dev Destroys `amount` tokens from `account`, reducing the\n total supply.\n Emits a {Transfer} event with `to` set to the zero address.\n Requirements:\n - `account` cannot be the zero address.\n - `account` must have at least `amount` tokens." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_burn", - "nameLocation": "9431:5:86", - "parameters": { - "id": 44074, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 44071, - "mutability": "mutable", - "name": "account", - "nameLocation": "9445:7:86", - "nodeType": "VariableDeclaration", - "scope": 44140, - "src": "9437:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44070, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "9437:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44073, - "mutability": "mutable", - "name": "amount", - "nameLocation": "9462:6:86", - "nodeType": "VariableDeclaration", - "scope": 44140, - "src": "9454:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44072, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "9454:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "9436:33:86" - }, - "returnParameters": { - "id": 44075, - "nodeType": "ParameterList", - "parameters": [], - "src": "9487:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - }, - { - "id": 44185, - "nodeType": "FunctionDefinition", - "src": "10504:370:86", - "nodes": [], - "body": { - "id": 44184, - "nodeType": "Block", - "src": "10617:257:86", - "nodes": [], - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 44156, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44151, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44143, - "src": "10635:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 44154, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "10652:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44153, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "10644:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44152, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "10644:7:86", - "typeDescriptions": {} - } - }, - "id": 44155, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10644:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "10635:19:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373", - "id": 44157, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "10656:38:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_c953f4879035ed60e766b34720f656aab5c697b141d924c283124ecedb91c208", - "typeString": "literal_string \"ERC20: approve from the zero address\"" - }, - "value": "ERC20: approve from the zero address" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_c953f4879035ed60e766b34720f656aab5c697b141d924c283124ecedb91c208", - "typeString": "literal_string \"ERC20: approve from the zero address\"" - } - ], - "id": 44150, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "10627:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 44158, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10627:68:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44159, - "nodeType": "ExpressionStatement", - "src": "10627:68:86" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 44166, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44161, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44145, - "src": "10713:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 44164, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "10732:1:86", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 44163, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "10724:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 44162, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "10724:7:86", - "typeDescriptions": {} - } - }, - "id": 44165, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10724:10:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "10713:21:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a20617070726f766520746f20746865207a65726f2061646472657373", - "id": 44167, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "10736:36:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_24883cc5fe64ace9d0df1893501ecb93c77180f0ff69cca79affb3c316dc8029", - "typeString": "literal_string \"ERC20: approve to the zero address\"" - }, - "value": "ERC20: approve to the zero address" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_24883cc5fe64ace9d0df1893501ecb93c77180f0ff69cca79affb3c316dc8029", - "typeString": "literal_string \"ERC20: approve to the zero address\"" - } - ], - "id": 44160, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "10705:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 44168, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10705:68:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44169, - "nodeType": "ExpressionStatement", - "src": "10705:68:86" - }, - { - "expression": { - "id": 44176, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "baseExpression": { - "baseExpression": { - "id": 44170, - "name": "_allowances", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43686, - "src": "10784:11:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", - "typeString": "mapping(address => mapping(address => uint256))" - } - }, - "id": 44173, - "indexExpression": { - "id": 44171, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44143, - "src": "10796:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "10784:18:86", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 44174, - "indexExpression": { - "id": 44172, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44145, - "src": "10803:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "10784:27:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 44175, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44147, - "src": "10814:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "10784:36:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 44177, - "nodeType": "ExpressionStatement", - "src": "10784:36:86" - }, - { - "eventCall": { - "arguments": [ - { - "id": 44179, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44143, - "src": "10844:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44180, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44145, - "src": "10851:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44181, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44147, - "src": "10860:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44178, - "name": "Approval", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44272, - "src": "10835:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44182, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "10835:32:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44183, - "nodeType": "EmitStatement", - "src": "10830:37:86" - } - ] - }, - "documentation": { - "id": 44141, - "nodeType": "StructuredDocumentation", - "src": "10087:412:86", - "text": " @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n This internal function is equivalent to `approve`, and can be used to\n e.g. set automatic allowances for certain subsystems, etc.\n Emits an {Approval} event.\n Requirements:\n - `owner` cannot be the zero address.\n - `spender` cannot be the zero address." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_approve", - "nameLocation": "10513:8:86", - "parameters": { - "id": 44148, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 44143, - "mutability": "mutable", - "name": "owner", - "nameLocation": "10539:5:86", - "nodeType": "VariableDeclaration", - "scope": 44185, - "src": "10531:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44142, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "10531:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44145, - "mutability": "mutable", - "name": "spender", - "nameLocation": "10562:7:86", - "nodeType": "VariableDeclaration", - "scope": 44185, - "src": "10554:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44144, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "10554:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44147, - "mutability": "mutable", - "name": "amount", - "nameLocation": "10587:6:86", - "nodeType": "VariableDeclaration", - "scope": 44185, - "src": "10579:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44146, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "10579:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "10521:78:86" - }, - "returnParameters": { - "id": 44149, - "nodeType": "ParameterList", - "parameters": [], - "src": "10617:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - }, - { - "id": 44228, - "nodeType": "FunctionDefinition", - "src": "11155:441:86", - "nodes": [], - "body": { - "id": 44227, - "nodeType": "Block", - "src": "11275:321:86", - "nodes": [], - "statements": [ - { - "assignments": [ - 44196 - ], - "declarations": [ - { - "constant": false, - "id": 44196, - "mutability": "mutable", - "name": "currentAllowance", - "nameLocation": "11293:16:86", - "nodeType": "VariableDeclaration", - "scope": 44227, - "src": "11285:24:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44195, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "11285:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "id": 44201, - "initialValue": { - "arguments": [ - { - "id": 44198, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44188, - "src": "11322:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44199, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44190, - "src": "11329:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 44197, - "name": "allowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43806, - "src": "11312:9:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$_t_address_$returns$_t_uint256_$", - "typeString": "function (address,address) view returns (uint256)" - } - }, - "id": 44200, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "11312:25:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "11285:52:86" - }, - { - "condition": { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 44208, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44202, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44196, - "src": "11351:16:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "expression": { - "arguments": [ - { - "id": 44205, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "11376:7:86", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_uint256_$", - "typeString": "type(uint256)" - }, - "typeName": { - "id": 44204, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "11376:7:86", - "typeDescriptions": {} - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_type$_t_uint256_$", - "typeString": "type(uint256)" - } - ], - "id": 44203, - "name": "type", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -27, - "src": "11371:4:86", - "typeDescriptions": { - "typeIdentifier": "t_function_metatype_pure$__$returns$__$", - "typeString": "function () pure" - } - }, - "id": 44206, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "11371:13:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_magic_meta_type_t_uint256", - "typeString": "type(uint256)" - } - }, - "id": 44207, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "max", - "nodeType": "MemberAccess", - "src": "11371:17:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "11351:37:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 44226, - "nodeType": "IfStatement", - "src": "11347:243:86", - "trueBody": { - "id": 44225, - "nodeType": "Block", - "src": "11390:200:86", - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 44212, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44210, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44196, - "src": "11412:16:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "id": 44211, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44192, - "src": "11432:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "11412:26:86", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45524332303a20696e73756666696369656e7420616c6c6f77616e6365", - "id": 44213, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "11440:31:86", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_3b6607e091cba9325f958656d2b5e0622ab7dc0eac71a26ac788cb25bc19f4fe", - "typeString": "literal_string \"ERC20: insufficient allowance\"" - }, - "value": "ERC20: insufficient allowance" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_3b6607e091cba9325f958656d2b5e0622ab7dc0eac71a26ac788cb25bc19f4fe", - "typeString": "literal_string \"ERC20: insufficient allowance\"" - } - ], - "id": 44209, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "11404:7:86", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 44214, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "11404:68:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44215, - "nodeType": "ExpressionStatement", - "src": "11404:68:86" - }, - { - "id": 44224, - "nodeType": "UncheckedBlock", - "src": "11486:94:86", - "statements": [ - { - "expression": { - "arguments": [ - { - "id": 44217, - "name": "owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44188, - "src": "11523:5:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 44218, - "name": "spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44190, - "src": "11530:7:86", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 44221, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 44219, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44196, - "src": "11539:16:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "id": 44220, - "name": "amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44192, - "src": "11558:6:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "11539:25:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 44216, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "11514:8:86", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 44222, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "11514:51:86", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 44223, - "nodeType": "ExpressionStatement", - "src": "11514:51:86" - } - ] - } - ] - } - } - ] - }, - "documentation": { - "id": 44186, - "nodeType": "StructuredDocumentation", - "src": "10880:270:86", - "text": " @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n Does not update the allowance amount in case of infinite allowance.\n Revert if not enough allowance is available.\n Might emit an {Approval} event." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_spendAllowance", - "nameLocation": "11164:15:86", - "parameters": { - "id": 44193, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 44188, - "mutability": "mutable", - "name": "owner", - "nameLocation": "11197:5:86", - "nodeType": "VariableDeclaration", - "scope": 44228, - "src": "11189:13:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44187, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "11189:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44190, - "mutability": "mutable", - "name": "spender", - "nameLocation": "11220:7:86", - "nodeType": "VariableDeclaration", - "scope": 44228, - "src": "11212:15:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44189, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "11212:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44192, - "mutability": "mutable", - "name": "amount", - "nameLocation": "11245:6:86", - "nodeType": "VariableDeclaration", - "scope": 44228, - "src": "11237:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44191, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "11237:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "11179:78:86" - }, - "returnParameters": { - "id": 44194, - "nodeType": "ParameterList", - "parameters": [], - "src": "11275:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - }, - { - "id": 44239, - "nodeType": "FunctionDefinition", - "src": "12180:121:86", - "nodes": [], - "body": { - "id": 44238, - "nodeType": "Block", - "src": "12299:2:86", - "nodes": [], - "statements": [] - }, - "documentation": { - "id": 44229, - "nodeType": "StructuredDocumentation", - "src": "11602:573:86", - "text": " @dev Hook that is called before any transfer of tokens. This includes\n minting and burning.\n Calling conditions:\n - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n will be transferred to `to`.\n - when `from` is zero, `amount` tokens will be minted for `to`.\n - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n - `from` and `to` are never both zero.\n To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_beforeTokenTransfer", - "nameLocation": "12189:20:86", - "parameters": { - "id": 44236, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 44231, - "mutability": "mutable", - "name": "from", - "nameLocation": "12227:4:86", - "nodeType": "VariableDeclaration", - "scope": 44239, - "src": "12219:12:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44230, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "12219:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44233, - "mutability": "mutable", - "name": "to", - "nameLocation": "12249:2:86", - "nodeType": "VariableDeclaration", - "scope": 44239, - "src": "12241:10:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44232, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "12241:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44235, - "mutability": "mutable", - "name": "amount", - "nameLocation": "12269:6:86", - "nodeType": "VariableDeclaration", - "scope": 44239, - "src": "12261:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44234, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "12261:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "12209:72:86" - }, - "returnParameters": { - "id": 44237, - "nodeType": "ParameterList", - "parameters": [], - "src": "12299:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - }, - { - "id": 44250, - "nodeType": "FunctionDefinition", - "src": "12889:120:86", - "nodes": [], - "body": { - "id": 44249, - "nodeType": "Block", - "src": "13007:2:86", - "nodes": [], - "statements": [] - }, - "documentation": { - "id": 44240, - "nodeType": "StructuredDocumentation", - "src": "12307:577:86", - "text": " @dev Hook that is called after any transfer of tokens. This includes\n minting and burning.\n Calling conditions:\n - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n has been transferred to `to`.\n - when `from` is zero, `amount` tokens have been minted for `to`.\n - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n - `from` and `to` are never both zero.\n To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]." - }, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_afterTokenTransfer", - "nameLocation": "12898:19:86", - "parameters": { - "id": 44247, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 44242, - "mutability": "mutable", - "name": "from", - "nameLocation": "12935:4:86", - "nodeType": "VariableDeclaration", - "scope": 44250, - "src": "12927:12:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44241, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "12927:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44244, - "mutability": "mutable", - "name": "to", - "nameLocation": "12957:2:86", - "nodeType": "VariableDeclaration", - "scope": 44250, - "src": "12949:10:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 44243, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "12949:7:86", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 44246, - "mutability": "mutable", - "name": "amount", - "nameLocation": "12977:6:86", - "nodeType": "VariableDeclaration", - "scope": 44250, - "src": "12969:14:86", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 44245, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "12969:7:86", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "12917:72:86" - }, - "returnParameters": { - "id": 44248, - "nodeType": "ParameterList", - "parameters": [], - "src": "13007:0:86" - }, - "scope": 44251, - "stateMutability": "nonpayable", - "virtual": true, - "visibility": "internal" - } - ], - "abstract": false, - "baseContracts": [ - { - "baseName": { - "id": 43671, - "name": "Context", - "nodeType": "IdentifierPath", - "referencedDeclaration": 45026, - "src": "1419:7:86" - }, - "id": 43672, - "nodeType": "InheritanceSpecifier", - "src": "1419:7:86" - }, - { - "baseName": { - "id": 43673, - "name": "IERC20", - "nodeType": "IdentifierPath", - "referencedDeclaration": 44329, - "src": "1428:6:86" - }, - "id": 43674, - "nodeType": "InheritanceSpecifier", - "src": "1428:6:86" - }, - { - "baseName": { - "id": 43675, - "name": "IERC20Metadata", - "nodeType": "IdentifierPath", - "referencedDeclaration": 44354, - "src": "1436:14:86" - }, - "id": 43676, - "nodeType": "InheritanceSpecifier", - "src": "1436:14:86" - } - ], - "canonicalName": "ERC20", - "contractDependencies": [], - "contractKind": "contract", - "documentation": { - "id": 43670, - "nodeType": "StructuredDocumentation", - "src": "230:1170:86", - "text": " @dev Implementation of the {IERC20} interface.\n This implementation is agnostic to the way tokens are created. This means\n that a supply mechanism has to be added in a derived contract using {_mint}.\n For a generic mechanism see {ERC20PresetMinterPauser}.\n TIP: For a detailed writeup see our guide\n https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n to implement supply mechanisms].\n We have followed general OpenZeppelin Contracts guidelines: functions revert\n instead returning `false` on failure. This behavior is nonetheless\n conventional and does not conflict with the expectations of ERC20\n applications.\n Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n This allows applications to reconstruct the allowance for all accounts just\n by listening to said events. Other implementations of the EIP may not emit\n these events, as it isn't required by the specification.\n Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n functions have been added to mitigate the well-known issues around setting\n allowances. See {IERC20-approve}." - }, - "fullyImplemented": true, - "linearizedBaseContracts": [ - 44251, - 44354, - 44329, - 45026 - ], - "name": "ERC20", - "nameLocation": "1410:5:86", - "scope": 44252, - "usedErrors": [] - } - ], - "license": "MIT" - }, - "id": 86 -} \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/abis/ERC20Mintable.json b/yarn-project/ethereum.js/example/src/abis/ERC20Mintable.json deleted file mode 100644 index 9affbc5303b..00000000000 --- a/yarn-project/ethereum.js/example/src/abis/ERC20Mintable.json +++ /dev/null @@ -1,2162 +0,0 @@ -{ - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "name": "setDecimals", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": { - "object": "0x60806040526005805460ff191660121790553480156200001e57600080fd5b5060405162000dd538038062000dd5833981016040819052620000419162000136565b8051819081906200005a9060039060208401906200007a565b508051620000709060049060208401906200007a565b505050506200024f565b828054620000889062000212565b90600052602060002090601f016020900481019282620000ac5760008555620000f7565b82601f10620000c757805160ff1916838001178555620000f7565b82800160010185558215620000f7579182015b82811115620000f7578251825591602001919060010190620000da565b506200010592915062000109565b5090565b5b808211156200010557600081556001016200010a565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200014a57600080fd5b82516001600160401b03808211156200016257600080fd5b818501915085601f8301126200017757600080fd5b8151818111156200018c576200018c62000120565b604051601f8201601f19908116603f01168101908382118183101715620001b757620001b762000120565b816040528281528886848701011115620001d057600080fd5b600093505b82841015620001f45784840186015181850187015292850192620001d5565b82841115620002065760008684830101525b98975050505050505050565b600181811c908216806200022757607f821691505b602082108114156200024957634e487b7160e01b600052602260045260246000fd5b50919050565b610b76806200025f6000396000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101f2578063a457c2d7146101fa578063a9059cbb1461020d578063dd62ed3e1461022057600080fd5b806340c10f191461017257806370a08231146101855780637a1395aa146101ae57600080fd5b806323b872dd116100bd57806323b872dd14610137578063313ce5671461014a578063395093511461015f57600080fd5b806306fdde03146100e4578063095ea7b31461010257806318160ddd14610125575b600080fd5b6100ec610259565b6040516100f99190610921565b60405180910390f35b61011561011036600461098e565b6102eb565b60405190151581526020016100f9565b6002545b6040519081526020016100f9565b6101156101453660046109b8565b610303565b60055460405160ff90911681526020016100f9565b61011561016d36600461098e565b610327565b61011561018036600461098e565b610366565b6101296101933660046109f4565b6001600160a01b031660009081526020819052604090205490565b6101f06101bc366004610a16565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b005b6100ec61037b565b61011561020836600461098e565b61038a565b61011561021b36600461098e565b610439565b61012961022e366004610a39565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461026890610a6c565b80601f016020809104026020016040519081016040528092919081815260200182805461029490610a6c565b80156102e15780601f106102b6576101008083540402835291602001916102e1565b820191906000526020600020905b8154815290600101906020018083116102c457829003601f168201915b5050505050905090565b6000336102f9818585610447565b5060019392505050565b60003361031185828561059f565b61031c858585610649565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906102f99082908690610361908790610ac0565b610447565b60006103728383610836565b50600192915050565b60606004805461026890610a6c565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091908381101561042c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61031c8286868403610447565b6000336102f9818585610649565b6001600160a01b0383166104c25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b03821661053e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461064357818110156105f861037b565b6040516020016106089190610aff565b604051602081830303815290604052906106355760405162461bcd60e51b81526004016104239190610921565b506106438484848403610447565b50505050565b6001600160a01b0383166106c55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b0382166107415760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b038316600090815260208190526040902054818110156107d05760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610643565b6001600160a01b03821661088c5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610423565b806002600082825461089e9190610ac0565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60005b838110156109105781810151838201526020016108f8565b838111156106435750506000910152565b60208152600082518060208401526109408160408501602087016108f5565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b80356001600160a01b038116811461098957600080fd5b919050565b600080604083850312156109a157600080fd5b6109aa83610972565b946020939093013593505050565b6000806000606084860312156109cd57600080fd5b6109d684610972565b92506109e460208501610972565b9150604084013590509250925092565b600060208284031215610a0657600080fd5b610a0f82610972565b9392505050565b600060208284031215610a2857600080fd5b813560ff81168114610a0f57600080fd5b60008060408385031215610a4c57600080fd5b610a5583610972565b9150610a6360208401610972565b90509250929050565b600181811c90821680610a8057607f821691505b60208210811415610aba577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60008219821115610afa577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500190565b60008251610b118184602087016108f5565b7f3a20696e73756666696369656e7420616c6c6f77616e6365000000000000000092019182525060180191905056fea2646970667358221220d5dfa0685bc929dfec54b5c67e6001c5f4941cc463ad06d3f691d75f4328810364736f6c634300080a0033", - "sourceMap": "285:936:139:-:0;;;323:32;;;-1:-1:-1;;323:32:139;353:2;323:32;;;362:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2042:13:86;;403:7:139;;;;2042:13:86;;:5;;:13;;;;;:::i;:::-;-1:-1:-1;2065:17:86;;;;:7;;:17;;;;;:::i;:::-;;1976:113;;362:61:139;285:936;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;285:936:139;;;-1:-1:-1;285:936:139;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;14:127:169;75:10;70:3;66:20;63:1;56:31;106:4;103:1;96:15;130:4;127:1;120:15;146:1087;226:6;257:2;300;288:9;279:7;275:23;271:32;268:52;;;316:1;313;306:12;268:52;343:16;;-1:-1:-1;;;;;408:14:169;;;405:34;;;435:1;432;425:12;405:34;473:6;462:9;458:22;448:32;;518:7;511:4;507:2;503:13;499:27;489:55;;540:1;537;530:12;489:55;569:2;563:9;591:2;587;584:10;581:36;;;597:18;;:::i;:::-;672:2;666:9;640:2;726:13;;-1:-1:-1;;722:22:169;;;746:2;718:31;714:40;702:53;;;770:18;;;790:22;;;767:46;764:72;;;816:18;;:::i;:::-;856:10;852:2;845:22;891:2;883:6;876:18;931:7;926:2;921;917;913:11;909:20;906:33;903:53;;;952:1;949;942:12;903:53;974:1;965:10;;984:129;998:2;995:1;992:9;984:129;;;1086:10;;;1082:19;;1076:26;1055:14;;;1051:23;;1044:59;1009:10;;;;984:129;;;1131:2;1128:1;1125:9;1122:80;;;1190:1;1185:2;1180;1172:6;1168:15;1164:24;1157:35;1122:80;1221:6;146:1087;-1:-1:-1;;;;;;;;146:1087:169:o;1238:380::-;1317:1;1313:12;;;;1360;;;1381:61;;1435:4;1427:6;1423:17;1413:27;;1381:61;1488:2;1480:6;1477:14;1457:18;1454:38;1451:161;;;1534:10;1529:3;1525:20;1522:1;1515:31;1569:4;1566:1;1559:15;1597:4;1594:1;1587:15;1451:161;;1238:380;;;:::o;:::-;285:936:139;;;;;;", - "linkReferences": {} - }, - "deployedBytecode": { - "object": "0x608060405234801561001057600080fd5b50600436106100df5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101f2578063a457c2d7146101fa578063a9059cbb1461020d578063dd62ed3e1461022057600080fd5b806340c10f191461017257806370a08231146101855780637a1395aa146101ae57600080fd5b806323b872dd116100bd57806323b872dd14610137578063313ce5671461014a578063395093511461015f57600080fd5b806306fdde03146100e4578063095ea7b31461010257806318160ddd14610125575b600080fd5b6100ec610259565b6040516100f99190610921565b60405180910390f35b61011561011036600461098e565b6102eb565b60405190151581526020016100f9565b6002545b6040519081526020016100f9565b6101156101453660046109b8565b610303565b60055460405160ff90911681526020016100f9565b61011561016d36600461098e565b610327565b61011561018036600461098e565b610366565b6101296101933660046109f4565b6001600160a01b031660009081526020819052604090205490565b6101f06101bc366004610a16565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b005b6100ec61037b565b61011561020836600461098e565b61038a565b61011561021b36600461098e565b610439565b61012961022e366004610a39565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461026890610a6c565b80601f016020809104026020016040519081016040528092919081815260200182805461029490610a6c565b80156102e15780601f106102b6576101008083540402835291602001916102e1565b820191906000526020600020905b8154815290600101906020018083116102c457829003601f168201915b5050505050905090565b6000336102f9818585610447565b5060019392505050565b60003361031185828561059f565b61031c858585610649565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906102f99082908690610361908790610ac0565b610447565b60006103728383610836565b50600192915050565b60606004805461026890610a6c565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091908381101561042c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61031c8286868403610447565b6000336102f9818585610649565b6001600160a01b0383166104c25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b03821661053e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461064357818110156105f861037b565b6040516020016106089190610aff565b604051602081830303815290604052906106355760405162461bcd60e51b81526004016104239190610921565b506106438484848403610447565b50505050565b6001600160a01b0383166106c55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b0382166107415760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b038316600090815260208190526040902054818110156107d05760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610643565b6001600160a01b03821661088c5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610423565b806002600082825461089e9190610ac0565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60005b838110156109105781810151838201526020016108f8565b838111156106435750506000910152565b60208152600082518060208401526109408160408501602087016108f5565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b80356001600160a01b038116811461098957600080fd5b919050565b600080604083850312156109a157600080fd5b6109aa83610972565b946020939093013593505050565b6000806000606084860312156109cd57600080fd5b6109d684610972565b92506109e460208501610972565b9150604084013590509250925092565b600060208284031215610a0657600080fd5b610a0f82610972565b9392505050565b600060208284031215610a2857600080fd5b813560ff81168114610a0f57600080fd5b60008060408385031215610a4c57600080fd5b610a5583610972565b9150610a6360208401610972565b90509250929050565b600181811c90821680610a8057607f821691505b60208210811415610aba577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60008219821115610afa577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500190565b60008251610b118184602087016108f5565b7f3a20696e73756666696369656e7420616c6c6f77616e6365000000000000000092019182525060180191905056fea2646970667358221220d5dfa0685bc929dfec54b5c67e6001c5f4941cc463ad06d3f691d75f4328810364736f6c634300080a0033", - "sourceMap": "285:936:139:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98:86;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;4431:197;;;;;;:::i;:::-;;:::i;:::-;;;1349:14:169;;1342:22;1324:41;;1312:2;1297:18;4431:197:86;1184:187:169;3242:106:86;3329:12;;3242:106;;;1522:25:169;;;1510:2;1495:18;3242:106:86;1376:177:169;5190:286:86;;;;;;:::i;:::-;;:::i;651:102:139:-;733:13;;651:102;;733:13;;;;2033:36:169;;2021:2;2006:18;651:102:139;1891:184:169;5871:234:86;;;;;;:::i;:::-;;:::i;524:121:139:-;;;;;;:::i;:::-;;:::i;3406:125:86:-;;;;;;:::i;:::-;-1:-1:-1;;;;;3506:18:86;3480:7;3506:18;;;;;;;;;;;;3406:125;429:89:139;;;;;;:::i;:::-;486:13;:25;;;;;;;;;;;;;;;429:89;;;2365:102:86;;;:::i;6592:427::-;;;;;;:::i;:::-;;:::i;3727:189::-;;;;;;:::i;:::-;;:::i;3974:149::-;;;;;;:::i;:::-;-1:-1:-1;;;;;4089:18:86;;;4063:7;4089:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3974:149;2154:98;2208:13;2240:5;2233:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98;:::o;4431:197::-;4514:4;719:10:93;4568:32:86;719:10:93;4584:7:86;4593:6;4568:8;:32::i;:::-;-1:-1:-1;4617:4:86;;4431:197;-1:-1:-1;;;4431:197:86:o;5190:286::-;5317:4;719:10:93;5373:38:86;5389:4;719:10:93;5404:6:86;5373:15;:38::i;:::-;5421:27;5431:4;5437:2;5441:6;5421:9;:27::i;:::-;-1:-1:-1;5465:4:86;;5190:286;-1:-1:-1;;;;5190:286:86:o;5871:234::-;719:10:93;5959:4:86;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:86;;;;;;;;;;5959:4;;719:10:93;6013:64:86;;719:10:93;;4089:27:86;;6038:38;;6066:10;;6038:38;:::i;:::-;6013:8;:64::i;524:121:139:-;583:4;599:18;605:3;610:6;599:5;:18::i;:::-;-1:-1:-1;634:4:139;524:121;;;;:::o;2365:102:86:-;2421:13;2453:7;2446:14;;;;;:::i;6592:427::-;719:10:93;6685:4:86;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:86;;;;;;;;;;6685:4;;719:10:93;6829:15:86;6809:16;:35;;6801:85;;;;-1:-1:-1;;;6801:85:86;;3741:2:169;6801:85:86;;;3723:21:169;3780:2;3760:18;;;3753:30;3819:34;3799:18;;;3792:62;3890:7;3870:18;;;3863:35;3915:19;;6801:85:86;;;;;;;;;6920:60;6929:5;6936:7;6964:15;6945:16;:34;6920:8;:60::i;3727:189::-;3806:4;719:10:93;3860:28:86;719:10:93;3877:2:86;3881:6;3860:9;:28::i;10504:370::-;-1:-1:-1;;;;;10635:19:86;;10627:68;;;;-1:-1:-1;;;10627:68:86;;4147:2:169;10627:68:86;;;4129:21:169;4186:2;4166:18;;;4159:30;4225:34;4205:18;;;4198:62;4296:6;4276:18;;;4269:34;4320:19;;10627:68:86;3945:400:169;10627:68:86;-1:-1:-1;;;;;10713:21:86;;10705:68;;;;-1:-1:-1;;;10705:68:86;;4552:2:169;10705:68:86;;;4534:21:169;4591:2;4571:18;;;4564:30;4630:34;4610:18;;;4603:62;4701:4;4681:18;;;4674:32;4723:19;;10705:68:86;4350:398:169;10705:68:86;-1:-1:-1;;;;;10784:18:86;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;:36;;;10835:32;;1522:25:169;;;10835:32:86;;1495:18:169;10835:32:86;;;;;;;10504:370;;;:::o;759:460:139:-;-1:-1:-1;;;;;4089:18:86;;;871:24:139;4089:18:86;;;:11;:18;;;;;;;;:27;;;;;;;;;;959:17:139;939:37;;935:278;;1020:7;1000:16;:27;;1053:8;:6;:8::i;:::-;1036:54;;;;;;;;:::i;:::-;;;;;;;;;;;;;992:100;;;;;-1:-1:-1;;;992:100:139;;;;;;;;:::i;:::-;;1134:54;1143:6;1151:8;1180:7;1161:16;:26;1134:8;:54::i;:::-;861:358;759:460;;;:::o;7473:818:86:-;-1:-1:-1;;;;;7599:18:86;;7591:68;;;;-1:-1:-1;;;7591:68:86;;5423:2:169;7591:68:86;;;5405:21:169;5462:2;5442:18;;;5435:30;5501:34;5481:18;;;5474:62;5572:7;5552:18;;;5545:35;5597:19;;7591:68:86;5221:401:169;7591:68:86;-1:-1:-1;;;;;7677:16:86;;7669:64;;;;-1:-1:-1;;;7669:64:86;;5829:2:169;7669:64:86;;;5811:21:169;5868:2;5848:18;;;5841:30;5907:34;5887:18;;;5880:62;5978:5;5958:18;;;5951:33;6001:19;;7669:64:86;5627:399:169;7669:64:86;-1:-1:-1;;;;;7815:15:86;;7793:19;7815:15;;;;;;;;;;;7848:21;;;;7840:72;;;;-1:-1:-1;;;7840:72:86;;6233:2:169;7840:72:86;;;6215:21:169;6272:2;6252:18;;;6245:30;6311:34;6291:18;;;6284:62;6382:8;6362:18;;;6355:36;6408:19;;7840:72:86;6031:402:169;7840:72:86;-1:-1:-1;;;;;7946:15:86;;;:9;:15;;;;;;;;;;;7964:20;;;7946:38;;8161:13;;;;;;;;;;:23;;;;;;8210:26;;1522:25:169;;;8161:13:86;;8210:26;;1495:18:169;8210:26:86;;;;;;;8247:37;12180:121;8567:535;-1:-1:-1;;;;;8650:21:86;;8642:65;;;;-1:-1:-1;;;8642:65:86;;6640:2:169;8642:65:86;;;6622:21:169;6679:2;6659:18;;;6652:30;6718:33;6698:18;;;6691:61;6769:18;;8642:65:86;6438:355:169;8642:65:86;8794:6;8778:12;;:22;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;8946:18:86;;:9;:18;;;;;;;;;;;:28;;;;;;8999:37;1522:25:169;;;8999:37:86;;1495:18:169;8999:37:86;;;;;;;8567:535;;:::o;14:258:169:-;86:1;96:113;110:6;107:1;104:13;96:113;;;186:11;;;180:18;167:11;;;160:39;132:2;125:10;96:113;;;227:6;224:1;221:13;218:48;;;-1:-1:-1;;262:1:169;244:16;;237:27;14:258::o;277:442::-;426:2;415:9;408:21;389:4;458:6;452:13;501:6;496:2;485:9;481:18;474:34;517:66;576:6;571:2;560:9;556:18;551:2;543:6;539:15;517:66;:::i;:::-;635:2;623:15;640:66;619:88;604:104;;;;710:2;600:113;;277:442;-1:-1:-1;;277:442:169:o;724:196::-;792:20;;-1:-1:-1;;;;;841:54:169;;831:65;;821:93;;910:1;907;900:12;821:93;724:196;;;:::o;925:254::-;993:6;1001;1054:2;1042:9;1033:7;1029:23;1025:32;1022:52;;;1070:1;1067;1060:12;1022:52;1093:29;1112:9;1093:29;:::i;:::-;1083:39;1169:2;1154:18;;;;1141:32;;-1:-1:-1;;;925:254:169:o;1558:328::-;1635:6;1643;1651;1704:2;1692:9;1683:7;1679:23;1675:32;1672:52;;;1720:1;1717;1710:12;1672:52;1743:29;1762:9;1743:29;:::i;:::-;1733:39;;1791:38;1825:2;1814:9;1810:18;1791:38;:::i;:::-;1781:48;;1876:2;1865:9;1861:18;1848:32;1838:42;;1558:328;;;;;:::o;2080:186::-;2139:6;2192:2;2180:9;2171:7;2167:23;2163:32;2160:52;;;2208:1;2205;2198:12;2160:52;2231:29;2250:9;2231:29;:::i;:::-;2221:39;2080:186;-1:-1:-1;;;2080:186:169:o;2271:269::-;2328:6;2381:2;2369:9;2360:7;2356:23;2352:32;2349:52;;;2397:1;2394;2387:12;2349:52;2436:9;2423:23;2486:4;2479:5;2475:16;2468:5;2465:27;2455:55;;2506:1;2503;2496:12;2545:260;2613:6;2621;2674:2;2662:9;2653:7;2649:23;2645:32;2642:52;;;2690:1;2687;2680:12;2642:52;2713:29;2732:9;2713:29;:::i;:::-;2703:39;;2761:38;2795:2;2784:9;2780:18;2761:38;:::i;:::-;2751:48;;2545:260;;;;;:::o;2810:437::-;2889:1;2885:12;;;;2932;;;2953:61;;3007:4;2999:6;2995:17;2985:27;;2953:61;3060:2;3052:6;3049:14;3029:18;3026:38;3023:218;;;3097:77;3094:1;3087:88;3198:4;3195:1;3188:15;3226:4;3223:1;3216:15;3023:218;;2810:437;;;:::o;3252:282::-;3292:3;3323:1;3319:6;3316:1;3313:13;3310:193;;;3359:77;3356:1;3349:88;3460:4;3457:1;3450:15;3488:4;3485:1;3478:15;3310:193;-1:-1:-1;3519:9:169;;3252:282::o;4753:463::-;4985:3;5023:6;5017:13;5039:53;5085:6;5080:3;5073:4;5065:6;5061:17;5039:53;:::i;:::-;5153:26;5114:16;;5139:41;;;-1:-1:-1;5207:2:169;5196:14;;4753:463;-1:-1:-1;4753:463:169:o", - "linkReferences": {} - }, - "methodIdentifiers": { - "allowance(address,address)": "dd62ed3e", - "approve(address,uint256)": "095ea7b3", - "balanceOf(address)": "70a08231", - "decimals()": "313ce567", - "decreaseAllowance(address,uint256)": "a457c2d7", - "increaseAllowance(address,uint256)": "39509351", - "mint(address,uint256)": "40c10f19", - "name()": "06fdde03", - "setDecimals(uint8)": "7a1395aa", - "symbol()": "95d89b41", - "totalSupply()": "18160ddd", - "transfer(address,uint256)": "a9059cbb", - "transferFrom(address,address,uint256)": "23b872dd" - }, - "rawMetadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_decimals\",\"type\":\"uint8\"}],\"name\":\"setDecimals\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Warning: do not deploy in real environments, for testing only ERC20 contract where anybody is able to mint\",\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/test/mocks/ERC20Mintable.sol\":\"ERC20Mintable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[\":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/\",\":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/\",\":@uniswap/v2-core/=lib/v2-core/\",\":@uniswap/v2-periphery/=lib/v2-periphery/\",\":aztec-connect-bridges/=lib/aztec-connect-bridges/src/\",\":bridge-deployments/=lib/aztec-connect-bridges/src/deployment/\",\":bridge-interfaces/=lib/aztec-connect-bridges/src/interfaces/\",\":bridge-tests/=lib/aztec-connect-bridges/src/test/\",\":core/=src/core/\",\":ds-test/=lib/forge-std/lib/ds-test/src/\",\":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/\",\":forge-std/=lib/forge-std/src/\",\":mocks/=src/test/mocks/\",\":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/\",\":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/\",\":periphery/=src/periphery/\",\":rollup-encoder/=lib/rollup-encoder/src/\",\":v2-core/=lib/v2-core/contracts/\",\":v2-periphery/=lib/v2-periphery/contracts/\"]},\"sources\":{\"lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://15f52f51413a9de1ff191e2f6367c62178e1df7806d7880fe857a98b0b66253d\",\"dweb:/ipfs/QmaQG1fwfgUt5E9nu2cccFiV47B2V78MM1tCy1qB7n4MsH\"]},\"lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34\",\"dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr\"]},\"lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd\",\"dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8\"]},\"lib/openzeppelin-contracts/contracts/utils/Context.sol\":{\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92\",\"dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3\"]},\"src/test/mocks/ERC20Mintable.sol\":{\"keccak256\":\"0x8fcc72dc6c49fd6878d8d2162b02591a5858ad9ae3f474afee9241bd82f743d9\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://f6b2e40b3edc06ad215d0156601e1f08074ed83ff5b6c15808db313e85c2f0a2\",\"dweb:/ipfs/QmVZV3vsv4q7DbDW4k58TQJvPA68hus96Q5ck3FJx8Td6M\"]}},\"version\":1}", - "metadata": { - "compiler": { - "version": "0.8.10+commit.fc410830" - }, - "language": "Solidity", - "output": { - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address", - "indexed": true - }, - { - "internalType": "address", - "name": "spender", - "type": "address", - "indexed": true - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256", - "indexed": false - } - ], - "type": "event", - "name": "Approval", - "anonymous": false - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address", - "indexed": true - }, - { - "internalType": "address", - "name": "to", - "type": "address", - "indexed": true - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256", - "indexed": false - } - ], - "type": "event", - "name": "Transfer", - "anonymous": false - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "setDecimals" - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - } - ], - "devdoc": { - "kind": "dev", - "methods": { - "allowance(address,address)": { - "details": "See {IERC20-allowance}." - }, - "approve(address,uint256)": { - "details": "See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address." - }, - "balanceOf(address)": { - "details": "See {IERC20-balanceOf}." - }, - "decimals()": { - "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." - }, - "decreaseAllowance(address,uint256)": { - "details": "Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`." - }, - "increaseAllowance(address,uint256)": { - "details": "Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address." - }, - "name()": { - "details": "Returns the name of the token." - }, - "symbol()": { - "details": "Returns the symbol of the token, usually a shorter version of the name." - }, - "totalSupply()": { - "details": "See {IERC20-totalSupply}." - }, - "transfer(address,uint256)": { - "details": "See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`." - }, - "transferFrom(address,address,uint256)": { - "details": "See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - } - }, - "settings": { - "remappings": [ - ":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - ":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", - ":@uniswap/v2-core/=lib/v2-core/", - ":@uniswap/v2-periphery/=lib/v2-periphery/", - ":aztec-connect-bridges/=lib/aztec-connect-bridges/src/", - ":bridge-deployments/=lib/aztec-connect-bridges/src/deployment/", - ":bridge-interfaces/=lib/aztec-connect-bridges/src/interfaces/", - ":bridge-tests/=lib/aztec-connect-bridges/src/test/", - ":core/=src/core/", - ":ds-test/=lib/forge-std/lib/ds-test/src/", - ":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", - ":forge-std/=lib/forge-std/src/", - ":mocks/=src/test/mocks/", - ":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - ":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", - ":periphery/=src/periphery/", - ":rollup-encoder/=lib/rollup-encoder/src/", - ":v2-core/=lib/v2-core/contracts/", - ":v2-periphery/=lib/v2-periphery/contracts/" - ], - "optimizer": { - "enabled": true, - "runs": 2000 - }, - "metadata": { - "bytecodeHash": "ipfs" - }, - "compilationTarget": { - "src/test/mocks/ERC20Mintable.sol": "ERC20Mintable" - }, - "libraries": {} - }, - "sources": { - "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol": { - "keccak256": "0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d", - "urls": [ - "bzz-raw://15f52f51413a9de1ff191e2f6367c62178e1df7806d7880fe857a98b0b66253d", - "dweb:/ipfs/QmaQG1fwfgUt5E9nu2cccFiV47B2V78MM1tCy1qB7n4MsH" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": { - "keccak256": "0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b", - "urls": [ - "bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34", - "dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "keccak256": "0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca", - "urls": [ - "bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd", - "dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/utils/Context.sol": { - "keccak256": "0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7", - "urls": [ - "bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92", - "dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3" - ], - "license": "MIT" - }, - "src/test/mocks/ERC20Mintable.sol": { - "keccak256": "0x8fcc72dc6c49fd6878d8d2162b02591a5858ad9ae3f474afee9241bd82f743d9", - "urls": [ - "bzz-raw://f6b2e40b3edc06ad215d0156601e1f08074ed83ff5b6c15808db313e85c2f0a2", - "dweb:/ipfs/QmVZV3vsv4q7DbDW4k58TQJvPA68hus96Q5ck3FJx8Td6M" - ], - "license": "Apache-2.0" - } - }, - "version": 1 - }, - "ast": { - "absolutePath": "src/test/mocks/ERC20Mintable.sol", - "id": 63785, - "exportedSymbols": { - "ERC20": [ - 44251 - ], - "ERC20Mintable": [ - 63784 - ] - }, - "nodeType": "SourceUnit", - "src": "63:1159:139", - "nodes": [ - { - "id": 63676, - "nodeType": "PragmaDirective", - "src": "63:24:139", - "nodes": [], - "literals": [ - "solidity", - ">=", - "0.8", - ".4" - ] - }, - { - "id": 63678, - "nodeType": "ImportDirective", - "src": "89:68:139", - "nodes": [], - "absolutePath": "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol", - "file": "@openzeppelin/contracts/token/ERC20/ERC20.sol", - "nameLocation": "-1:-1:-1", - "scope": 63785, - "sourceUnit": 44252, - "symbolAliases": [ - { - "foreign": { - "id": 63677, - "name": "ERC20", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "src": "97:5:139", - "typeDescriptions": {} - }, - "nameLocation": "-1:-1:-1" - } - ], - "unitAlias": "" - }, - { - "id": 63784, - "nodeType": "ContractDefinition", - "src": "285:936:139", - "nodes": [ - { - "id": 63684, - "nodeType": "VariableDeclaration", - "src": "323:32:139", - "nodes": [], - "constant": false, - "mutability": "mutable", - "name": "assetDecimals", - "nameLocation": "337:13:139", - "scope": 63784, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - "typeName": { - "id": 63682, - "name": "uint8", - "nodeType": "ElementaryTypeName", - "src": "323:5:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "value": { - "hexValue": "3138", - "id": 63683, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "353:2:139", - "typeDescriptions": { - "typeIdentifier": "t_rational_18_by_1", - "typeString": "int_const 18" - }, - "value": "18" - }, - "visibility": "private" - }, - { - "id": 63694, - "nodeType": "FunctionDefinition", - "src": "362:61:139", - "nodes": [], - "body": { - "id": 63693, - "nodeType": "Block", - "src": "421:2:139", - "nodes": [], - "statements": [] - }, - "implemented": true, - "kind": "constructor", - "modifiers": [ - { - "arguments": [ - { - "id": 63689, - "name": "_symbol", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63686, - "src": "403:7:139", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - { - "id": 63690, - "name": "_symbol", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63686, - "src": "412:7:139", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - } - ], - "id": 63691, - "kind": "baseConstructorSpecifier", - "modifierName": { - "id": 63688, - "name": "ERC20", - "nodeType": "IdentifierPath", - "referencedDeclaration": 44251, - "src": "397:5:139" - }, - "nodeType": "ModifierInvocation", - "src": "397:23:139" - } - ], - "name": "", - "nameLocation": "-1:-1:-1", - "parameters": { - "id": 63687, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 63686, - "mutability": "mutable", - "name": "_symbol", - "nameLocation": "388:7:139", - "nodeType": "VariableDeclaration", - "scope": 63694, - "src": "374:21:139", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 63685, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "374:6:139", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "373:23:139" - }, - "returnParameters": { - "id": 63692, - "nodeType": "ParameterList", - "parameters": [], - "src": "421:0:139" - }, - "scope": 63784, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - }, - { - "id": 63704, - "nodeType": "FunctionDefinition", - "src": "429:89:139", - "nodes": [], - "body": { - "id": 63703, - "nodeType": "Block", - "src": "476:42:139", - "nodes": [], - "statements": [ - { - "expression": { - "id": 63701, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 63699, - "name": "assetDecimals", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63684, - "src": "486:13:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 63700, - "name": "_decimals", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63696, - "src": "502:9:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "src": "486:25:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "id": 63702, - "nodeType": "ExpressionStatement", - "src": "486:25:139" - } - ] - }, - "functionSelector": "7a1395aa", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "setDecimals", - "nameLocation": "438:11:139", - "parameters": { - "id": 63697, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 63696, - "mutability": "mutable", - "name": "_decimals", - "nameLocation": "456:9:139", - "nodeType": "VariableDeclaration", - "scope": 63704, - "src": "450:15:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - "typeName": { - "id": 63695, - "name": "uint8", - "nodeType": "ElementaryTypeName", - "src": "450:5:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "visibility": "internal" - } - ], - "src": "449:17:139" - }, - "returnParameters": { - "id": 63698, - "nodeType": "ParameterList", - "parameters": [], - "src": "476:0:139" - }, - "scope": 63784, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "external" - }, - { - "id": 63721, - "nodeType": "FunctionDefinition", - "src": "524:121:139", - "nodes": [], - "body": { - "id": 63720, - "nodeType": "Block", - "src": "589:56:139", - "nodes": [], - "statements": [ - { - "expression": { - "arguments": [ - { - "id": 63714, - "name": "_to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63706, - "src": "605:3:139", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 63715, - "name": "_value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63708, - "src": "610:6:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 63713, - "name": "_mint", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44068, - "src": "599:5:139", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,uint256)" - } - }, - "id": 63716, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "599:18:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 63717, - "nodeType": "ExpressionStatement", - "src": "599:18:139" - }, - { - "expression": { - "hexValue": "74727565", - "id": 63718, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "634:4:139", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 63712, - "id": 63719, - "nodeType": "Return", - "src": "627:11:139" - } - ] - }, - "functionSelector": "40c10f19", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "mint", - "nameLocation": "533:4:139", - "parameters": { - "id": 63709, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 63706, - "mutability": "mutable", - "name": "_to", - "nameLocation": "546:3:139", - "nodeType": "VariableDeclaration", - "scope": 63721, - "src": "538:11:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 63705, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "538:7:139", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 63708, - "mutability": "mutable", - "name": "_value", - "nameLocation": "559:6:139", - "nodeType": "VariableDeclaration", - "scope": 63721, - "src": "551:14:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 63707, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "551:7:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "537:29:139" - }, - "returnParameters": { - "id": 63712, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 63711, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 63721, - "src": "583:4:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 63710, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "583:4:139", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - } - ], - "src": "582:6:139" - }, - "scope": 63784, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - }, - { - "id": 63731, - "nodeType": "FunctionDefinition", - "src": "651:102:139", - "nodes": [], - "body": { - "id": 63730, - "nodeType": "Block", - "src": "716:37:139", - "nodes": [], - "statements": [ - { - "expression": { - "id": 63728, - "name": "assetDecimals", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63684, - "src": "733:13:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "functionReturnParameters": 63727, - "id": 63729, - "nodeType": "Return", - "src": "726:20:139" - } - ] - }, - "baseFunctions": [ - 43739 - ], - "functionSelector": "313ce567", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "decimals", - "nameLocation": "660:8:139", - "overrides": { - "id": 63724, - "nodeType": "OverrideSpecifier", - "overrides": [ - { - "id": 63723, - "name": "ERC20", - "nodeType": "IdentifierPath", - "referencedDeclaration": 44251, - "src": "693:5:139" - } - ], - "src": "683:16:139" - }, - "parameters": { - "id": 63722, - "nodeType": "ParameterList", - "parameters": [], - "src": "668:2:139" - }, - "returnParameters": { - "id": 63727, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 63726, - "mutability": "mutable", - "name": "", - "nameLocation": "-1:-1:-1", - "nodeType": "VariableDeclaration", - "scope": 63731, - "src": "709:5:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - "typeName": { - "id": 63725, - "name": "uint8", - "nodeType": "ElementaryTypeName", - "src": "709:5:139", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "visibility": "internal" - } - ], - "src": "708:7:139" - }, - "scope": 63784, - "stateMutability": "view", - "virtual": false, - "visibility": "public" - }, - { - "id": 63783, - "nodeType": "FunctionDefinition", - "src": "759:460:139", - "nodes": [], - "body": { - "id": 63782, - "nodeType": "Block", - "src": "861:358:139", - "nodes": [], - "statements": [ - { - "assignments": [ - 63743 - ], - "declarations": [ - { - "constant": false, - "id": 63743, - "mutability": "mutable", - "name": "currentAllowance", - "nameLocation": "879:16:139", - "nodeType": "VariableDeclaration", - "scope": 63782, - "src": "871:24:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 63742, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "871:7:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "id": 63748, - "initialValue": { - "arguments": [ - { - "id": 63745, - "name": "_owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63733, - "src": "908:6:139", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 63746, - "name": "_spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63735, - "src": "916:8:139", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 63744, - "name": "allowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43806, - "src": "898:9:139", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$_t_address_$returns$_t_uint256_$", - "typeString": "function (address,address) view returns (uint256)" - } - }, - "id": 63747, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "898:27:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "871:54:139" - }, - { - "condition": { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 63755, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 63749, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63743, - "src": "939:16:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "expression": { - "arguments": [ - { - "id": 63752, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "964:7:139", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_uint256_$", - "typeString": "type(uint256)" - }, - "typeName": { - "id": 63751, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "964:7:139", - "typeDescriptions": {} - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_type$_t_uint256_$", - "typeString": "type(uint256)" - } - ], - "id": 63750, - "name": "type", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -27, - "src": "959:4:139", - "typeDescriptions": { - "typeIdentifier": "t_function_metatype_pure$__$returns$__$", - "typeString": "function () pure" - } - }, - "id": 63753, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "959:13:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_magic_meta_type_t_uint256", - "typeString": "type(uint256)" - } - }, - "id": 63754, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "max", - "nodeType": "MemberAccess", - "src": "959:17:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "939:37:139", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 63781, - "nodeType": "IfStatement", - "src": "935:278:139", - "trueBody": { - "id": 63780, - "nodeType": "Block", - "src": "978:235:139", - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 63759, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 63757, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63743, - "src": "1000:16:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "id": 63758, - "name": "_amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63737, - "src": "1020:7:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1000:27:139", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "arguments": [ - { - "arguments": [ - { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 63764, - "name": "symbol", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43729, - "src": "1053:6:139", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_string_memory_ptr_$", - "typeString": "function () view returns (string memory)" - } - }, - "id": 63765, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1053:8:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - { - "hexValue": "3a20696e73756666696369656e7420616c6c6f77616e6365", - "id": 63766, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1063:26:139", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_529347701dc2164bd866b42ef6d099cba7896d70c000efa63827b157f0086ce2", - "typeString": "literal_string \": insufficient allowance\"" - }, - "value": ": insufficient allowance" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - }, - { - "typeIdentifier": "t_stringliteral_529347701dc2164bd866b42ef6d099cba7896d70c000efa63827b157f0086ce2", - "typeString": "literal_string \": insufficient allowance\"" - } - ], - "expression": { - "id": 63762, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -1, - "src": "1036:3:139", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 63763, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "src": "1036:16:139", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 63767, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1036:54:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 63761, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "1029:6:139", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_string_storage_ptr_$", - "typeString": "type(string storage pointer)" - }, - "typeName": { - "id": 63760, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "1029:6:139", - "typeDescriptions": {} - } - }, - "id": 63768, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1029:62:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - ], - "id": 63756, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "992:7:139", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 63769, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "992:100:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 63770, - "nodeType": "ExpressionStatement", - "src": "992:100:139" - }, - { - "id": 63779, - "nodeType": "UncheckedBlock", - "src": "1106:97:139", - "statements": [ - { - "expression": { - "arguments": [ - { - "id": 63772, - "name": "_owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63733, - "src": "1143:6:139", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 63773, - "name": "_spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63735, - "src": "1151:8:139", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 63776, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 63774, - "name": "currentAllowance", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63743, - "src": "1161:16:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "id": 63775, - "name": "_amount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 63737, - "src": "1180:7:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1161:26:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 63771, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "1134:8:139", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 63777, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1134:54:139", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 63778, - "nodeType": "ExpressionStatement", - "src": "1134:54:139" - } - ] - } - ] - } - } - ] - }, - "baseFunctions": [ - 44228 - ], - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_spendAllowance", - "nameLocation": "768:15:139", - "overrides": { - "id": 63740, - "nodeType": "OverrideSpecifier", - "overrides": [ - { - "id": 63739, - "name": "ERC20", - "nodeType": "IdentifierPath", - "referencedDeclaration": 44251, - "src": "854:5:139" - } - ], - "src": "844:16:139" - }, - "parameters": { - "id": 63738, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 63733, - "mutability": "mutable", - "name": "_owner", - "nameLocation": "792:6:139", - "nodeType": "VariableDeclaration", - "scope": 63783, - "src": "784:14:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 63732, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "784:7:139", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 63735, - "mutability": "mutable", - "name": "_spender", - "nameLocation": "808:8:139", - "nodeType": "VariableDeclaration", - "scope": 63783, - "src": "800:16:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 63734, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "800:7:139", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 63737, - "mutability": "mutable", - "name": "_amount", - "nameLocation": "826:7:139", - "nodeType": "VariableDeclaration", - "scope": 63783, - "src": "818:15:139", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 63736, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "818:7:139", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "src": "783:51:139" - }, - "returnParameters": { - "id": 63741, - "nodeType": "ParameterList", - "parameters": [], - "src": "861:0:139" - }, - "scope": 63784, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "internal" - } - ], - "abstract": false, - "baseContracts": [ - { - "baseName": { - "id": 63680, - "name": "ERC20", - "nodeType": "IdentifierPath", - "referencedDeclaration": 44251, - "src": "311:5:139" - }, - "id": 63681, - "nodeType": "InheritanceSpecifier", - "src": "311:5:139" - } - ], - "canonicalName": "ERC20Mintable", - "contractDependencies": [], - "contractKind": "contract", - "documentation": { - "id": 63679, - "nodeType": "StructuredDocumentation", - "src": "159:125:139", - "text": " @dev Warning: do not deploy in real environments, for testing only\n ERC20 contract where anybody is able to mint" - }, - "fullyImplemented": true, - "linearizedBaseContracts": [ - 63784, - 44251, - 44354, - 44329, - 45026 - ], - "name": "ERC20Mintable", - "nameLocation": "294:13:139", - "scope": 63785, - "usedErrors": [] - } - ], - "license": "Apache-2.0" - }, - "id": 139 -} \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/abis/ERC20Permit.json b/yarn-project/ethereum.js/example/src/abis/ERC20Permit.json deleted file mode 100644 index c4bb43cba39..00000000000 --- a/yarn-project/ethereum.js/example/src/abis/ERC20Permit.json +++ /dev/null @@ -1,4623 +0,0 @@ -{ - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PERMIT_TYPEHASH_NON_STANDARD", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_holder", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_nonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_expiry", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_allowed", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "_v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_deadline", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "_v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "name": "setDecimals", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": { - "object": "0x60806040526005805460ff191660121790553480156200001e57600080fd5b506040516200162d3803806200162d833981016040819052620000419162000282565b80808181600390805190602001906200005c929190620001c6565b50805162000072906004906020840190620001c6565b505050507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000a76200012c60201b60201c565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160408051601f198184030181529190528051602090910120600655506200039b565b6060600380546200013d906200035e565b80601f01602080910402602001604051908101604052809291908181526020018280546200016b906200035e565b8015620001bc5780601f106200019057610100808354040283529160200191620001bc565b820191906000526020600020905b8154815290600101906020018083116200019e57829003601f168201915b5050505050905090565b828054620001d4906200035e565b90600052602060002090601f016020900481019282620001f8576000855562000243565b82601f106200021357805160ff191683800117855562000243565b8280016001018555821562000243579182015b828111156200024357825182559160200191906001019062000226565b506200025192915062000255565b5090565b5b8082111562000251576000815560010162000256565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200029657600080fd5b82516001600160401b0380821115620002ae57600080fd5b818501915085601f830112620002c357600080fd5b815181811115620002d857620002d86200026c565b604051601f8201601f19908116603f011681019083821181831017156200030357620003036200026c565b8160405282815288868487010111156200031c57600080fd5b600093505b8284101562000340578484018601518185018701529285019262000321565b82841115620003525760008684830101525b98975050505050505050565b600181811c908216806200037357607f821691505b602082108114156200039557634e487b7160e01b600052602260045260246000fd5b50919050565b61128280620003ab6000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c806340c10f19116100cd57806395d89b4111610081578063a9059cbb11610066578063a9059cbb1461030d578063d505accf14610320578063dd62ed3e1461033357600080fd5b806395d89b41146102f2578063a457c2d7146102fa57600080fd5b80637a1395aa116100b25780637a1395aa1461027b5780637ecebe00146102bf5780638fcbaf0c146102df57600080fd5b806340c10f191461023f57806370a082311461025257600080fd5b806323b872dd11610124578063313ce56711610109578063313ce5671461020e5780633644e51514610223578063395093511461022c57600080fd5b806323b872dd146101d457806330adf81f146101e757600080fd5b806306fdde0314610156578063095ea7b3146101745780630f96c5f41461019757806318160ddd146101cc575b600080fd5b61015e61036c565b60405161016b9190610f33565b60405180910390f35b610187610182366004610f82565b6103fe565b604051901515815260200161016b565b6101be7fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb81565b60405190815260200161016b565b6002546101be565b6101876101e2366004610fac565b610416565b6101be7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460405160ff909116815260200161016b565b6101be60065481565b61018761023a366004610f82565b61043a565b61018761024d366004610f82565b610479565b6101be610260366004610fe8565b6001600160a01b031660009081526020819052604090205490565b6102bd61028936600461101b565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b005b6101be6102cd366004610fe8565b60076020526000908152604090205481565b6102bd6102ed366004611036565b61048e565b61015e610776565b610187610308366004610f82565b610785565b61018761031b366004610f82565b61082f565b6102bd61032e3660046110b8565b61083d565b6101be610341366004611122565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461037b90611155565b80601f01602080910402602001604051908101604052809291908181526020018280546103a790611155565b80156103f45780601f106103c9576101008083540402835291602001916103f4565b820191906000526020600020905b8154815290600101906020018083116103d757829003601f168201915b5050505050905090565b60003361040c818585610a77565b5060019392505050565b600033610424858285610bcf565b61042f858585610c5b565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061040c90829086906104749087906111d8565b610a77565b60006104858383610e48565b50600192915050565b600654604080517fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60208201526001600160a01b03808c169282019290925290891660608201526080810188905260a0810187905285151560c08201526000919060e0016040516020818303038152906040528051906020012060405160200161054a9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f19818403018152919052805160209091012090506001600160a01b0389166105bf5760405162461bcd60e51b815260206004820152600e60248201527f494e56414c49445f484f4c44455200000000000000000000000000000000000060448201526064015b60405180910390fd5b60408051600081526020810180835283905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610612573d6000803e3d6000fd5b505050602060405103516001600160a01b0316896001600160a01b03161461067c5760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f5349474e415455524500000000000000000000000000000060448201526064016105b6565b8515806106895750428610155b6106d55760405162461bcd60e51b815260206004820152600760248201527f455850495245440000000000000000000000000000000000000000000000000060448201526064016105b6565b6001600160a01b03891660009081526007602052604081208054916106f9836111f0565b91905055871461074b5760405162461bcd60e51b815260206004820152600d60248201527f494e56414c49445f4e4f4e43450000000000000000000000000000000000000060448201526064016105b6565b60008561075957600061075d565b6000195b905061076a8a8a83610a77565b50505050505050505050565b60606004805461037b90611155565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156108225760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016105b6565b61042f8286868403610a77565b60003361040c818585610c5b565b4284101561088d5760405162461bcd60e51b815260206004820152600760248201527f455850495245440000000000000000000000000000000000000000000000000060448201526064016105b6565b6006546001600160a01b038816600090815260076020526040812080549192917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b9190876108e0836111f0565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e001604051602081830303815290604052805190602001206040516020016109749291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa1580156109df573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610a155750886001600160a01b0316816001600160a01b0316145b610a615760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f5349474e415455524500000000000000000000000000000060448201526064016105b6565b610a6c898989610a77565b505050505050505050565b6001600160a01b038316610af25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b038216610b6e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610c555781811015610c0a610776565b604051602001610c1a919061120b565b60405160208183030381529060405290610c475760405162461bcd60e51b81526004016105b69190610f33565b50610c558484848403610a77565b50505050565b6001600160a01b038316610cd75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b038216610d535760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b03831660009081526020819052604090205481811015610de25760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610c55565b6001600160a01b038216610e9e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105b6565b8060026000828254610eb091906111d8565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60005b83811015610f22578181015183820152602001610f0a565b83811115610c555750506000910152565b6020815260008251806020840152610f52816040850160208701610f07565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610f7d57600080fd5b919050565b60008060408385031215610f9557600080fd5b610f9e83610f66565b946020939093013593505050565b600080600060608486031215610fc157600080fd5b610fca84610f66565b9250610fd860208501610f66565b9150604084013590509250925092565b600060208284031215610ffa57600080fd5b61100382610f66565b9392505050565b803560ff81168114610f7d57600080fd5b60006020828403121561102d57600080fd5b6110038261100a565b600080600080600080600080610100898b03121561105357600080fd5b61105c89610f66565b975061106a60208a01610f66565b965060408901359550606089013594506080890135801515811461108d57600080fd5b935061109b60a08a0161100a565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a0312156110d357600080fd5b6110dc88610f66565b96506110ea60208901610f66565b955060408801359450606088013593506111066080890161100a565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561113557600080fd5b61113e83610f66565b915061114c60208401610f66565b90509250929050565b600181811c9082168061116957607f821691505b602082108114156111a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156111eb576111eb6111a9565b500190565b6000600019821415611204576112046111a9565b5060010190565b6000825161121d818460208701610f07565b7f3a20696e73756666696369656e7420616c6c6f77616e6365000000000000000092019182525060180191905056fea264697066735822122054a35da2d250cd8d2d2f0d51975894ad0a754c0f6a8cb964d529e70c7ebf096664736f6c634300080a0033", - "sourceMap": "289:2544:138:-:0;;;323:32:137;;;-1:-1:-1;;323:32:137;353:2;323:32;;;825:407:138;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;874:7;403::137;412;2050:5:86;2042;:13;;;;;;;;;;;;:::i;:::-;-1:-1:-1;2065:17:86;;;;:7;;:17;;;;;:::i;:::-;;1976:113;;362:61:137;963:95:138::1;1092:6;:4;;;:6;;:::i;:::-;1076:24:::0;;::::1;::::0;;::::1;::::0;1128:10:::1;::::0;;;;::::1;::::0;;::::1;::::0;;-1:-1:-1;;;1128:10:138;;::::1;::::0;935:280;;;;::::1;1497:25:146::0;;;;1538:18;;;1531:34;;;;1118:21:138;1581:18:146;;;1574:34;1157:13:138::1;1624:18:146::0;;;1617:34;1196:4:138::1;1667:19:146::0;;;1660:61;1469:19;;935:280:138::1;::::0;;-1:-1:-1;;935:280:138;;::::1;::::0;;;;;;912:313;;935:280:::1;912:313:::0;;::::1;::::0;893:16:::1;:332:::0;-1:-1:-1;289:2544:138;;2154:98:86;2208:13;2240:5;2233:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98;:::o;289:2544:138:-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;289:2544:138;;;-1:-1:-1;289:2544:138;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;14:127:146;75:10;70:3;66:20;63:1;56:31;106:4;103:1;96:15;130:4;127:1;120:15;146:1087;226:6;257:2;300;288:9;279:7;275:23;271:32;268:52;;;316:1;313;306:12;268:52;343:16;;-1:-1:-1;;;;;408:14:146;;;405:34;;;435:1;432;425:12;405:34;473:6;462:9;458:22;448:32;;518:7;511:4;507:2;503:13;499:27;489:55;;540:1;537;530:12;489:55;569:2;563:9;591:2;587;584:10;581:36;;;597:18;;:::i;:::-;672:2;666:9;640:2;726:13;;-1:-1:-1;;722:22:146;;;746:2;718:31;714:40;702:53;;;770:18;;;790:22;;;767:46;764:72;;;816:18;;:::i;:::-;856:10;852:2;845:22;891:2;883:6;876:18;931:7;926:2;921;917;913:11;909:20;906:33;903:53;;;952:1;949;942:12;903:53;974:1;965:10;;984:129;998:2;995:1;992:9;984:129;;;1086:10;;;1082:19;;1076:26;1055:14;;;1051:23;;1044:59;1009:10;;;;984:129;;;1131:2;1128:1;1125:9;1122:80;;;1190:1;1185:2;1180;1172:6;1168:15;1164:24;1157:35;1122:80;1221:6;146:1087;-1:-1:-1;;;;;;;;146:1087:146:o;1732:380::-;1811:1;1807:12;;;;1854;;;1875:61;;1929:4;1921:6;1917:17;1907:27;;1875:61;1982:2;1974:6;1971:14;1951:18;1948:38;1945:161;;;2028:10;2023:3;2019:20;2016:1;2009:31;2063:4;2060:1;2053:15;2091:4;2088:1;2081:15;1945:161;;1732:380;;;:::o;:::-;289:2544:138;;;;;;", - "linkReferences": {} - }, - "deployedBytecode": { - "object": "0x608060405234801561001057600080fd5b50600436106101515760003560e01c806340c10f19116100cd57806395d89b4111610081578063a9059cbb11610066578063a9059cbb1461030d578063d505accf14610320578063dd62ed3e1461033357600080fd5b806395d89b41146102f2578063a457c2d7146102fa57600080fd5b80637a1395aa116100b25780637a1395aa1461027b5780637ecebe00146102bf5780638fcbaf0c146102df57600080fd5b806340c10f191461023f57806370a082311461025257600080fd5b806323b872dd11610124578063313ce56711610109578063313ce5671461020e5780633644e51514610223578063395093511461022c57600080fd5b806323b872dd146101d457806330adf81f146101e757600080fd5b806306fdde0314610156578063095ea7b3146101745780630f96c5f41461019757806318160ddd146101cc575b600080fd5b61015e61036c565b60405161016b9190610f33565b60405180910390f35b610187610182366004610f82565b6103fe565b604051901515815260200161016b565b6101be7fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb81565b60405190815260200161016b565b6002546101be565b6101876101e2366004610fac565b610416565b6101be7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460405160ff909116815260200161016b565b6101be60065481565b61018761023a366004610f82565b61043a565b61018761024d366004610f82565b610479565b6101be610260366004610fe8565b6001600160a01b031660009081526020819052604090205490565b6102bd61028936600461101b565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b005b6101be6102cd366004610fe8565b60076020526000908152604090205481565b6102bd6102ed366004611036565b61048e565b61015e610776565b610187610308366004610f82565b610785565b61018761031b366004610f82565b61082f565b6102bd61032e3660046110b8565b61083d565b6101be610341366004611122565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461037b90611155565b80601f01602080910402602001604051908101604052809291908181526020018280546103a790611155565b80156103f45780601f106103c9576101008083540402835291602001916103f4565b820191906000526020600020905b8154815290600101906020018083116103d757829003601f168201915b5050505050905090565b60003361040c818585610a77565b5060019392505050565b600033610424858285610bcf565b61042f858585610c5b565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061040c90829086906104749087906111d8565b610a77565b60006104858383610e48565b50600192915050565b600654604080517fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60208201526001600160a01b03808c169282019290925290891660608201526080810188905260a0810187905285151560c08201526000919060e0016040516020818303038152906040528051906020012060405160200161054a9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f19818403018152919052805160209091012090506001600160a01b0389166105bf5760405162461bcd60e51b815260206004820152600e60248201527f494e56414c49445f484f4c44455200000000000000000000000000000000000060448201526064015b60405180910390fd5b60408051600081526020810180835283905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610612573d6000803e3d6000fd5b505050602060405103516001600160a01b0316896001600160a01b03161461067c5760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f5349474e415455524500000000000000000000000000000060448201526064016105b6565b8515806106895750428610155b6106d55760405162461bcd60e51b815260206004820152600760248201527f455850495245440000000000000000000000000000000000000000000000000060448201526064016105b6565b6001600160a01b03891660009081526007602052604081208054916106f9836111f0565b91905055871461074b5760405162461bcd60e51b815260206004820152600d60248201527f494e56414c49445f4e4f4e43450000000000000000000000000000000000000060448201526064016105b6565b60008561075957600061075d565b6000195b905061076a8a8a83610a77565b50505050505050505050565b60606004805461037b90611155565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156108225760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016105b6565b61042f8286868403610a77565b60003361040c818585610c5b565b4284101561088d5760405162461bcd60e51b815260206004820152600760248201527f455850495245440000000000000000000000000000000000000000000000000060448201526064016105b6565b6006546001600160a01b038816600090815260076020526040812080549192917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b9190876108e0836111f0565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e001604051602081830303815290604052805190602001206040516020016109749291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa1580156109df573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610a155750886001600160a01b0316816001600160a01b0316145b610a615760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f5349474e415455524500000000000000000000000000000060448201526064016105b6565b610a6c898989610a77565b505050505050505050565b6001600160a01b038316610af25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b038216610b6e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610c555781811015610c0a610776565b604051602001610c1a919061120b565b60405160208183030381529060405290610c475760405162461bcd60e51b81526004016105b69190610f33565b50610c558484848403610a77565b50505050565b6001600160a01b038316610cd75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b038216610d535760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b03831660009081526020819052604090205481811015610de25760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610c55565b6001600160a01b038216610e9e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105b6565b8060026000828254610eb091906111d8565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60005b83811015610f22578181015183820152602001610f0a565b83811115610c555750506000910152565b6020815260008251806020840152610f52816040850160208701610f07565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610f7d57600080fd5b919050565b60008060408385031215610f9557600080fd5b610f9e83610f66565b946020939093013593505050565b600080600060608486031215610fc157600080fd5b610fca84610f66565b9250610fd860208501610f66565b9150604084013590509250925092565b600060208284031215610ffa57600080fd5b61100382610f66565b9392505050565b803560ff81168114610f7d57600080fd5b60006020828403121561102d57600080fd5b6110038261100a565b600080600080600080600080610100898b03121561105357600080fd5b61105c89610f66565b975061106a60208a01610f66565b965060408901359550606089013594506080890135801515811461108d57600080fd5b935061109b60a08a0161100a565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a0312156110d357600080fd5b6110dc88610f66565b96506110ea60208901610f66565b955060408801359450606088013593506111066080890161100a565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561113557600080fd5b61113e83610f66565b915061114c60208401610f66565b90509250929050565b600181811c9082168061116957607f821691505b602082108114156111a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156111eb576111eb6111a9565b500190565b6000600019821415611204576112046111a9565b5060010190565b6000825161121d818460208701610f07565b7f3a20696e73756666696369656e7420616c6c6f77616e6365000000000000000092019182525060180191905056fea264697066735822122054a35da2d250cd8d2d2f0d51975894ad0a754c0f6a8cb964d529e70c7ebf096664736f6c634300080a0033", - "sourceMap": "289:2544:138:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98:86;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;4431:197;;;;;;:::i;:::-;;:::i;:::-;;;1349:14:146;;1342:22;1324:41;;1312:2;1297:18;4431:197:86;1184:187:146;689:129:138;;752:66;689:129;;;;;1522:25:146;;;1510:2;1495:18;689:129:138;1376:177:146;3242:106:86;3329:12;;3242:106;;5190:286;;;;;;:::i;:::-;;:::i;370:108:138:-;;412:66;370:108;;651:101:137;732:13;;651:101;;732:13;;;;2215:36:146;;2203:2;2188:18;651:101:137;2073:184:146;333:31:138;;;;;;5871:234:86;;;;;;:::i;:::-;;:::i;524:121:137:-;;;;;;:::i;:::-;;:::i;3406:125:86:-;;;;;;:::i;:::-;-1:-1:-1;;;;;3506:18:86;3480:7;3506:18;;;;;;;;;;;;3406:125;429:89:137;;;;;;:::i;:::-;486:13;:25;;;;;;;;;;;;;;;429:89;;;484:41:138;;;;;;:::i;:::-;;;;;;;;;;;;;;1972:859;;;;;;:::i;:::-;;:::i;2365:102:86:-;;;:::i;6592:427::-;;;;;;:::i;:::-;;:::i;3727:189::-;;;;;;:::i;:::-;;:::i;1238:728:138:-;;;;;;:::i;:::-;;:::i;3974:149:86:-;;;;;;:::i;:::-;-1:-1:-1;;;;;4089:18:86;;;4063:7;4089:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3974:149;2154:98;2208:13;2240:5;2233:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2154:98;:::o;4431:197::-;4514:4;719:10:93;4568:32:86;719:10:93;4584:7:86;4593:6;4568:8;:32::i;:::-;-1:-1:-1;4617:4:86;;4431:197;-1:-1:-1;;;4431:197:86:o;5190:286::-;5317:4;719:10:93;5373:38:86;5389:4;719:10:93;5404:6:86;5373:15;:38::i;:::-;5421:27;5431:4;5437:2;5441:6;5421:9;:27::i;:::-;-1:-1:-1;5465:4:86;;5190:286;-1:-1:-1;;;;5190:286:86:o;5871:234::-;719:10:93;5959:4:86;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:86;;;;;;;;;;5959:4;;719:10:93;6013:64:86;;719:10:93;;4089:27:86;;6038:38;;6066:10;;6038:38;:::i;:::-;6013:8;:64::i;524:121:137:-;583:4;599:18;605:3;610:6;599:5;:18::i;:::-;-1:-1:-1;634:4:137;524:121;;;;:::o;1972:859:138:-;2296:16;;2340:86;;;752:66;2340:86;;;5495:25:146;-1:-1:-1;;;;;5617:15:146;;;5597:18;;;5590:43;;;;5669:15;;;5649:18;;;5642:43;5701:18;;;5694:34;;;5744:19;;;5737:35;;;5816:14;;5809:22;5788:19;;;5781:51;2194:14:138;;2296:16;5467:19:146;;2340:86:138;;;;;;;;;;;;2330:97;;;;;;2234:207;;;;;;;;6113:66:146;6101:79;;6205:1;6196:11;;6189:27;;;;6241:2;6232:12;;6225:28;6278:2;6269:12;;5843:444;2234:207:138;;;;-1:-1:-1;;2234:207:138;;;;;;;;;2211:240;;2234:207;2211:240;;;;;-1:-1:-1;;;;;;2470:21:138;;2462:48;;;;-1:-1:-1;;;2462:48:138;;6494:2:146;2462:48:138;;;6476:21:146;6533:2;6513:18;;;6506:30;6572:16;6552:18;;;6545:44;6606:18;;2462:48:138;;;;;;;;;2539:29;;;;;;;;;;;;6862:25:146;;;6935:4;6923:17;;6903:18;;;6896:45;;;;6957:18;;;6950:34;;;7000:18;;;6993:34;;;2539:29:138;;6834:19:146;;2539:29:138;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2528:40:138;:7;-1:-1:-1;;;;;2528:40:138;;2520:70;;;;-1:-1:-1;;;2520:70:138;;7240:2:146;2520:70:138;;;7222:21:146;7279:2;7259:18;;;7252:30;7318:19;7298:18;;;7291:47;7355:18;;2520:70:138;7038:341:146;2520:70:138;2608:12;;;:42;;;2635:15;2624:7;:26;;2608:42;2600:62;;;;-1:-1:-1;;;2600:62:138;;7586:2:146;2600:62:138;;;7568:21:146;7625:1;7605:18;;;7598:29;7663:9;7643:18;;;7636:37;7690:18;;2600:62:138;7384:330:146;2600:62:138;-1:-1:-1;;;;;2690:15:138;;;;;;:6;:15;;;;;:17;;;;;;:::i;:::-;;;;;2680:6;:27;2672:53;;;;-1:-1:-1;;;2672:53:138;;8121:2:146;2672:53:138;;;8103:21:146;8160:2;8140:18;;;8133:30;8199:15;8179:18;;;8172:43;8232:18;;2672:53:138;7919:337:146;2672:53:138;2735:13;2751:8;:29;;2779:1;2751:29;;;-1:-1:-1;;2751:29:138;2735:45;;2790:34;2799:7;2808:8;2818:5;2790:8;:34::i;:::-;2184:647;;1972:859;;;;;;;;:::o;2365:102:86:-;2421:13;2453:7;2446:14;;;;;:::i;6592:427::-;719:10:93;6685:4:86;4089:18;;;:11;:18;;;;;;;;-1:-1:-1;;;;;4089:27:86;;;;;;;;;;6685:4;;719:10:93;6829:15:86;6809:16;:35;;6801:85;;;;-1:-1:-1;;;6801:85:86;;8463:2:146;6801:85:86;;;8445:21:146;8502:2;8482:18;;;8475:30;8541:34;8521:18;;;8514:62;8612:7;8592:18;;;8585:35;8637:19;;6801:85:86;8261:401:146;6801:85:86;6920:60;6929:5;6936:7;6964:15;6945:16;:34;6920:8;:60::i;3727:189::-;3806:4;719:10:93;3860:28:86;719:10:93;3877:2:86;3881:6;3860:9;:28::i;1238:728:138:-;1459:15;1446:9;:28;;1438:48;;;;-1:-1:-1;;;1438:48:138;;7586:2:146;1438:48:138;;;7568:21:146;7625:1;7605:18;;;7598:29;7663:9;7643:18;;;7636:37;7690:18;;1438:48:138;7384:330:146;1438:48:138;1598:16;;-1:-1:-1;;;;;1696:14:138;;1496;1696;;;:6;:14;;;;;:16;;1496:14;;1598:16;412:66;;1670:6;;1678:8;;1688:6;;1696:16;1496:14;1696:16;;;:::i;:::-;;;;-1:-1:-1;1642:82:138;;;;;;8954:25:146;;;;-1:-1:-1;;;;;9076:15:146;;;9056:18;;;9049:43;9128:15;;;;9108:18;;;9101:43;9160:18;;;9153:34;9203:19;;;9196:35;9247:19;;;9240:35;;;8926:19;;1642:82:138;;;;;;;;;;;;1632:93;;;;;;1536:203;;;;;;;;6113:66:146;6101:79;;6205:1;6196:11;;6189:27;;;;6241:2;6232:12;;6225:28;6278:2;6269:12;;5843:444;1536:203:138;;;;-1:-1:-1;;1536:203:138;;;;;;;;;1513:236;;1536:203;1513:236;;;;1759:24;1786:29;;;;;;;;;6862:25:146;;;6935:4;6923:17;;6903:18;;;6896:45;;;;6957:18;;;6950:34;;;7000:18;;;6993:34;;;1513:236:138;;-1:-1:-1;1759:24:138;1786:29;;6834:19:146;;1786:29:138;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1786:29:138;;-1:-1:-1;;1786:29:138;;;-1:-1:-1;;;;;;;1833:30:138;;;;;;:60;;;1887:6;-1:-1:-1;;;;;1867:26:138;:16;-1:-1:-1;;;;;1867:26:138;;1833:60;1825:90;;;;-1:-1:-1;;;1825:90:138;;7240:2:146;1825:90:138;;;7222:21:146;7279:2;7259:18;;;7252:30;7318:19;7298:18;;;7291:47;7355:18;;1825:90:138;7038:341:146;1825:90:138;1925:34;1934:6;1942:8;1952:6;1925:8;:34::i;:::-;1428:538;;1238:728;;;;;;;:::o;10504:370:86:-;-1:-1:-1;;;;;10635:19:86;;10627:68;;;;-1:-1:-1;;;10627:68:86;;9488:2:146;10627:68:86;;;9470:21:146;9527:2;9507:18;;;9500:30;9566:34;9546:18;;;9539:62;9637:6;9617:18;;;9610:34;9661:19;;10627:68:86;9286:400:146;10627:68:86;-1:-1:-1;;;;;10713:21:86;;10705:68;;;;-1:-1:-1;;;10705:68:86;;9893:2:146;10705:68:86;;;9875:21:146;9932:2;9912:18;;;9905:30;9971:34;9951:18;;;9944:62;10042:4;10022:18;;;10015:32;10064:19;;10705:68:86;9691:398:146;10705:68:86;-1:-1:-1;;;;;10784:18:86;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;:36;;;10835:32;;1522:25:146;;;10835:32:86;;1495:18:146;10835:32:86;;;;;;;10504:370;;;:::o;758:459:137:-;-1:-1:-1;;;;;4089:18:86;;;869:24:137;4089:18:86;;;:11;:18;;;;;;;;:27;;;;;;;;;;-1:-1:-1;;937:37:137;;933:278;;1018:7;998:16;:27;;1051:8;:6;:8::i;:::-;1034:54;;;;;;;;:::i;:::-;;;;;;;;;;;;;990:100;;;;;-1:-1:-1;;;990:100:137;;;;;;;;:::i;:::-;;1132:54;1141:6;1149:8;1178:7;1159:16;:26;1132:8;:54::i;:::-;859:358;758:459;;;:::o;7473:818:86:-;-1:-1:-1;;;;;7599:18:86;;7591:68;;;;-1:-1:-1;;;7591:68:86;;10764:2:146;7591:68:86;;;10746:21:146;10803:2;10783:18;;;10776:30;10842:34;10822:18;;;10815:62;10913:7;10893:18;;;10886:35;10938:19;;7591:68:86;10562:401:146;7591:68:86;-1:-1:-1;;;;;7677:16:86;;7669:64;;;;-1:-1:-1;;;7669:64:86;;11170:2:146;7669:64:86;;;11152:21:146;11209:2;11189:18;;;11182:30;11248:34;11228:18;;;11221:62;11319:5;11299:18;;;11292:33;11342:19;;7669:64:86;10968:399:146;7669:64:86;-1:-1:-1;;;;;7815:15:86;;7793:19;7815:15;;;;;;;;;;;7848:21;;;;7840:72;;;;-1:-1:-1;;;7840:72:86;;11574:2:146;7840:72:86;;;11556:21:146;11613:2;11593:18;;;11586:30;11652:34;11632:18;;;11625:62;11723:8;11703:18;;;11696:36;11749:19;;7840:72:86;11372:402:146;7840:72:86;-1:-1:-1;;;;;7946:15:86;;;:9;:15;;;;;;;;;;;7964:20;;;7946:38;;8161:13;;;;;;;;;;:23;;;;;;8210:26;;1522:25:146;;;8161:13:86;;8210:26;;1495:18:146;8210:26:86;;;;;;;8247:37;12180:121;8567:535;-1:-1:-1;;;;;8650:21:86;;8642:65;;;;-1:-1:-1;;;8642:65:86;;11981:2:146;8642:65:86;;;11963:21:146;12020:2;12000:18;;;11993:30;12059:33;12039:18;;;12032:61;12110:18;;8642:65:86;11779:355:146;8642:65:86;8794:6;8778:12;;:22;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;8946:18:86;;:9;:18;;;;;;;;;;;:28;;;;;;8999:37;1522:25:146;;;8999:37:86;;1495:18:146;8999:37:86;;;;;;;8567:535;;:::o;14:258:146:-;86:1;96:113;110:6;107:1;104:13;96:113;;;186:11;;;180:18;167:11;;;160:39;132:2;125:10;96:113;;;227:6;224:1;221:13;218:48;;;-1:-1:-1;;262:1:146;244:16;;237:27;14:258::o;277:442::-;426:2;415:9;408:21;389:4;458:6;452:13;501:6;496:2;485:9;481:18;474:34;517:66;576:6;571:2;560:9;556:18;551:2;543:6;539:15;517:66;:::i;:::-;635:2;623:15;-1:-1:-1;;619:88:146;604:104;;;;710:2;600:113;;277:442;-1:-1:-1;;277:442:146:o;724:196::-;792:20;;-1:-1:-1;;;;;841:54:146;;831:65;;821:93;;910:1;907;900:12;821:93;724:196;;;:::o;925:254::-;993:6;1001;1054:2;1042:9;1033:7;1029:23;1025:32;1022:52;;;1070:1;1067;1060:12;1022:52;1093:29;1112:9;1093:29;:::i;:::-;1083:39;1169:2;1154:18;;;;1141:32;;-1:-1:-1;;;925:254:146:o;1740:328::-;1817:6;1825;1833;1886:2;1874:9;1865:7;1861:23;1857:32;1854:52;;;1902:1;1899;1892:12;1854:52;1925:29;1944:9;1925:29;:::i;:::-;1915:39;;1973:38;2007:2;1996:9;1992:18;1973:38;:::i;:::-;1963:48;;2058:2;2047:9;2043:18;2030:32;2020:42;;1740:328;;;;;:::o;2262:186::-;2321:6;2374:2;2362:9;2353:7;2349:23;2345:32;2342:52;;;2390:1;2387;2380:12;2342:52;2413:29;2432:9;2413:29;:::i;:::-;2403:39;2262:186;-1:-1:-1;;;2262:186:146:o;2453:156::-;2519:20;;2579:4;2568:16;;2558:27;;2548:55;;2599:1;2596;2589:12;2614:182;2671:6;2724:2;2712:9;2703:7;2699:23;2695:32;2692:52;;;2740:1;2737;2730:12;2692:52;2763:27;2780:9;2763:27;:::i;2801:768::-;2918:6;2926;2934;2942;2950;2958;2966;2974;3027:3;3015:9;3006:7;3002:23;2998:33;2995:53;;;3044:1;3041;3034:12;2995:53;3067:29;3086:9;3067:29;:::i;:::-;3057:39;;3115:38;3149:2;3138:9;3134:18;3115:38;:::i;:::-;3105:48;;3200:2;3189:9;3185:18;3172:32;3162:42;;3251:2;3240:9;3236:18;3223:32;3213:42;;3305:3;3294:9;3290:19;3277:33;3353:5;3346:13;3339:21;3332:5;3329:32;3319:60;;3375:1;3372;3365:12;3319:60;3398:5;-1:-1:-1;3422:37:146;3454:3;3439:19;;3422:37;:::i;:::-;3412:47;;3506:3;3495:9;3491:19;3478:33;3468:43;;3558:3;3547:9;3543:19;3530:33;3520:43;;2801:768;;;;;;;;;;;:::o;3574:606::-;3685:6;3693;3701;3709;3717;3725;3733;3786:3;3774:9;3765:7;3761:23;3757:33;3754:53;;;3803:1;3800;3793:12;3754:53;3826:29;3845:9;3826:29;:::i;:::-;3816:39;;3874:38;3908:2;3897:9;3893:18;3874:38;:::i;:::-;3864:48;;3959:2;3948:9;3944:18;3931:32;3921:42;;4010:2;3999:9;3995:18;3982:32;3972:42;;4033:37;4065:3;4054:9;4050:19;4033:37;:::i;:::-;4023:47;;4117:3;4106:9;4102:19;4089:33;4079:43;;4169:3;4158:9;4154:19;4141:33;4131:43;;3574:606;;;;;;;;;;:::o;4185:260::-;4253:6;4261;4314:2;4302:9;4293:7;4289:23;4285:32;4282:52;;;4330:1;4327;4320:12;4282:52;4353:29;4372:9;4353:29;:::i;:::-;4343:39;;4401:38;4435:2;4424:9;4420:18;4401:38;:::i;:::-;4391:48;;4185:260;;;;;:::o;4450:437::-;4529:1;4525:12;;;;4572;;;4593:61;;4647:4;4639:6;4635:17;4625:27;;4593:61;4700:2;4692:6;4689:14;4669:18;4666:38;4663:218;;;4737:77;4734:1;4727:88;4838:4;4835:1;4828:15;4866:4;4863:1;4856:15;4663:218;;4450:437;;;:::o;4892:184::-;4944:77;4941:1;4934:88;5041:4;5038:1;5031:15;5065:4;5062:1;5055:15;5081:128;5121:3;5152:1;5148:6;5145:1;5142:13;5139:39;;;5158:18;;:::i;:::-;-1:-1:-1;5194:9:146;;5081:128::o;7719:195::-;7758:3;-1:-1:-1;;7782:5:146;7779:77;7776:103;;;7859:18;;:::i;:::-;-1:-1:-1;7906:1:146;7895:13;;7719:195::o;10094:463::-;10326:3;10364:6;10358:13;10380:53;10426:6;10421:3;10414:4;10406:6;10402:17;10380:53;:::i;:::-;10494:26;10455:16;;10480:41;;;-1:-1:-1;10548:2:146;10537:14;;10094:463;-1:-1:-1;10094:463:146:o", - "linkReferences": {} - }, - "methodIdentifiers": { - "DOMAIN_SEPARATOR()": "3644e515", - "PERMIT_TYPEHASH()": "30adf81f", - "PERMIT_TYPEHASH_NON_STANDARD()": "0f96c5f4", - "allowance(address,address)": "dd62ed3e", - "approve(address,uint256)": "095ea7b3", - "balanceOf(address)": "70a08231", - "decimals()": "313ce567", - "decreaseAllowance(address,uint256)": "a457c2d7", - "increaseAllowance(address,uint256)": "39509351", - "mint(address,uint256)": "40c10f19", - "name()": "06fdde03", - "nonces(address)": "7ecebe00", - "permit(address,address,uint256,uint256,bool,uint8,bytes32,bytes32)": "8fcbaf0c", - "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": "d505accf", - "setDecimals(uint8)": "7a1395aa", - "symbol()": "95d89b41", - "totalSupply()": "18160ddd", - "transfer(address,uint256)": "a9059cbb", - "transferFrom(address,address,uint256)": "23b872dd" - }, - "rawMetadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH_NON_STANDARD\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_holder\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_expiry\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_allowed\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_decimals\",\"type\":\"uint8\"}],\"name\":\"setDecimals\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Warning: do not deploy in real environments, for testing only ERC20 contract which has permit implementation and is mintable\",\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/test/mocks/ERC20Permit.sol\":\"ERC20Permit\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[\":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/\",\":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/\",\":@uniswap/v2-core/=lib/v2-core/\",\":@uniswap/v2-periphery/=lib/v2-periphery/\",\":aztec-connect-bridges/=lib/aztec-connect-bridges/src/\",\":bridge-deployments/=lib/aztec-connect-bridges/src/deployment/\",\":bridge-interfaces/=lib/aztec-connect-bridges/src/interfaces/\",\":bridge-tests/=lib/aztec-connect-bridges/src/test/\",\":core/=src/core/\",\":ds-test/=lib/forge-std/lib/ds-test/src/\",\":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/\",\":forge-std/=lib/forge-std/src/\",\":mocks/=src/test/mocks/\",\":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/\",\":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/\",\":periphery/=src/periphery/\",\":rollup-encoder/=lib/rollup-encoder/src/\",\":v2-core/=lib/v2-core/contracts/\",\":v2-periphery/=lib/v2-periphery/contracts/\"]},\"sources\":{\"lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://15f52f51413a9de1ff191e2f6367c62178e1df7806d7880fe857a98b0b66253d\",\"dweb:/ipfs/QmaQG1fwfgUt5E9nu2cccFiV47B2V78MM1tCy1qB7n4MsH\"]},\"lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34\",\"dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr\"]},\"lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd\",\"dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8\"]},\"lib/openzeppelin-contracts/contracts/utils/Context.sol\":{\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92\",\"dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3\"]},\"src/test/mocks/ERC20Mintable.sol\":{\"keccak256\":\"0x5efe5798690f436d8940048d6563266b102ca2b66f367b422f303d3eb034127a\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://9d696543deb5ecb352ed3eb54029ab51e13b09f5ca9de23dea0b19e06734fba5\",\"dweb:/ipfs/QmYRm8dWT12sh96DLzkGZV4VBGs8anSpn4MWmhWZEHx5Zg\"]},\"src/test/mocks/ERC20Permit.sol\":{\"keccak256\":\"0x467c97886e845d3586abf688bdfbd1b2f52b70a03e86e45d51fc879c72385682\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://dd2fb2c76fd3bd54cbde67ad8321abb0af744f6b3d1f99696030d21eec134d81\",\"dweb:/ipfs/QmNnnKr9NsJmVcP8oBNQqX8MeXmHopYQHCmnYPhbR5Jece\"]}},\"version\":1}", - "metadata": { - "compiler": { - "version": "0.8.10+commit.fc410830" - }, - "language": "Solidity", - "output": { - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address", - "indexed": true - }, - { - "internalType": "address", - "name": "spender", - "type": "address", - "indexed": true - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256", - "indexed": false - } - ], - "type": "event", - "name": "Approval", - "anonymous": false - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address", - "indexed": true - }, - { - "internalType": "address", - "name": "to", - "type": "address", - "indexed": true - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256", - "indexed": false - } - ], - "type": "event", - "name": "Transfer", - "anonymous": false - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "PERMIT_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "PERMIT_TYPEHASH_NON_STANDARD", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function", - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_holder", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_nonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_expiry", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_allowed", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "_v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_s", - "type": "bytes32" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "permit" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_deadline", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "_v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_s", - "type": "bytes32" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "permit" - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "setDecimals" - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "inputs": [], - "stateMutability": "view", - "type": "function", - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function", - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ] - } - ], - "devdoc": { - "kind": "dev", - "methods": { - "allowance(address,address)": { - "details": "See {IERC20-allowance}." - }, - "approve(address,uint256)": { - "details": "See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address." - }, - "balanceOf(address)": { - "details": "See {IERC20-balanceOf}." - }, - "decimals()": { - "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." - }, - "decreaseAllowance(address,uint256)": { - "details": "Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`." - }, - "increaseAllowance(address,uint256)": { - "details": "Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address." - }, - "name()": { - "details": "Returns the name of the token." - }, - "symbol()": { - "details": "Returns the symbol of the token, usually a shorter version of the name." - }, - "totalSupply()": { - "details": "See {IERC20-totalSupply}." - }, - "transfer(address,uint256)": { - "details": "See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`." - }, - "transferFrom(address,address,uint256)": { - "details": "See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - } - }, - "settings": { - "remappings": [ - ":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - ":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", - ":@uniswap/v2-core/=lib/v2-core/", - ":@uniswap/v2-periphery/=lib/v2-periphery/", - ":aztec-connect-bridges/=lib/aztec-connect-bridges/src/", - ":bridge-deployments/=lib/aztec-connect-bridges/src/deployment/", - ":bridge-interfaces/=lib/aztec-connect-bridges/src/interfaces/", - ":bridge-tests/=lib/aztec-connect-bridges/src/test/", - ":core/=src/core/", - ":ds-test/=lib/forge-std/lib/ds-test/src/", - ":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", - ":forge-std/=lib/forge-std/src/", - ":mocks/=src/test/mocks/", - ":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", - ":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", - ":periphery/=src/periphery/", - ":rollup-encoder/=lib/rollup-encoder/src/", - ":v2-core/=lib/v2-core/contracts/", - ":v2-periphery/=lib/v2-periphery/contracts/" - ], - "optimizer": { - "enabled": true, - "runs": 2000 - }, - "metadata": { - "bytecodeHash": "ipfs" - }, - "compilationTarget": { - "src/test/mocks/ERC20Permit.sol": "ERC20Permit" - }, - "libraries": {} - }, - "sources": { - "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol": { - "keccak256": "0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d", - "urls": [ - "bzz-raw://15f52f51413a9de1ff191e2f6367c62178e1df7806d7880fe857a98b0b66253d", - "dweb:/ipfs/QmaQG1fwfgUt5E9nu2cccFiV47B2V78MM1tCy1qB7n4MsH" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": { - "keccak256": "0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b", - "urls": [ - "bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34", - "dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "keccak256": "0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca", - "urls": [ - "bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd", - "dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8" - ], - "license": "MIT" - }, - "lib/openzeppelin-contracts/contracts/utils/Context.sol": { - "keccak256": "0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7", - "urls": [ - "bzz-raw://6df0ddf21ce9f58271bdfaa85cde98b200ef242a05a3f85c2bc10a8294800a92", - "dweb:/ipfs/QmRK2Y5Yc6BK7tGKkgsgn3aJEQGi5aakeSPZvS65PV8Xp3" - ], - "license": "MIT" - }, - "src/test/mocks/ERC20Mintable.sol": { - "keccak256": "0x5efe5798690f436d8940048d6563266b102ca2b66f367b422f303d3eb034127a", - "urls": [ - "bzz-raw://9d696543deb5ecb352ed3eb54029ab51e13b09f5ca9de23dea0b19e06734fba5", - "dweb:/ipfs/QmYRm8dWT12sh96DLzkGZV4VBGs8anSpn4MWmhWZEHx5Zg" - ], - "license": "Apache-2.0" - }, - "src/test/mocks/ERC20Permit.sol": { - "keccak256": "0x467c97886e845d3586abf688bdfbd1b2f52b70a03e86e45d51fc879c72385682", - "urls": [ - "bzz-raw://dd2fb2c76fd3bd54cbde67ad8321abb0af744f6b3d1f99696030d21eec134d81", - "dweb:/ipfs/QmNnnKr9NsJmVcP8oBNQqX8MeXmHopYQHCmnYPhbR5Jece" - ], - "license": "Apache-2.0" - } - }, - "version": 1 - }, - "ast": { - "absolutePath": "src/test/mocks/ERC20Permit.sol", - "id": 62093, - "exportedSymbols": { - "ERC20Mintable": [ - 61851 - ], - "ERC20Permit": [ - 62092 - ] - }, - "nodeType": "SourceUnit", - "src": "63:2771:138", - "nodes": [ - { - "id": 61853, - "nodeType": "PragmaDirective", - "src": "63:24:138", - "nodes": [], - "literals": [ - "solidity", - ">=", - "0.8", - ".4" - ] - }, - { - "id": 61855, - "nodeType": "ImportDirective", - "src": "89:54:138", - "nodes": [], - "absolutePath": "src/test/mocks/ERC20Mintable.sol", - "file": "mocks/ERC20Mintable.sol", - "nameLocation": "-1:-1:-1", - "scope": 62093, - "sourceUnit": 61852, - "symbolAliases": [ - { - "foreign": { - "id": 61854, - "name": "ERC20Mintable", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "src": "97:13:138", - "typeDescriptions": {} - }, - "nameLocation": "-1:-1:-1" - } - ], - "unitAlias": "" - }, - { - "id": 62092, - "nodeType": "ContractDefinition", - "src": "289:2544:138", - "nodes": [ - { - "id": 61860, - "nodeType": "VariableDeclaration", - "src": "333:31:138", - "nodes": [], - "constant": false, - "functionSelector": "3644e515", - "mutability": "mutable", - "name": "DOMAIN_SEPARATOR", - "nameLocation": "348:16:138", - "scope": 62092, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 61859, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "333:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "public" - }, - { - "id": 61863, - "nodeType": "VariableDeclaration", - "src": "370:108:138", - "nodes": [], - "constant": true, - "functionSelector": "30adf81f", - "mutability": "constant", - "name": "PERMIT_TYPEHASH", - "nameLocation": "394:15:138", - "scope": 62092, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 61861, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "370:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": { - "hexValue": "307836653731656461653132623162393766346431663630333730666566313031303566613266616165303132363131346131363963363438343564363132366339", - "id": 61862, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "412:66:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_49955707469362902507454157297736832118868343942642399513960811609542965143241_by_1", - "typeString": "int_const 4995...(69 digits omitted)...3241" - }, - "value": "0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9" - }, - "visibility": "public" - }, - { - "id": 61867, - "nodeType": "VariableDeclaration", - "src": "484:41:138", - "nodes": [], - "constant": false, - "functionSelector": "7ecebe00", - "mutability": "mutable", - "name": "nonces", - "nameLocation": "519:6:138", - "scope": 62092, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - }, - "typeName": { - "id": 61866, - "keyType": { - "id": 61864, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "492:7:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "Mapping", - "src": "484:27:138", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - }, - "valueType": { - "id": 61865, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "503:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - }, - "visibility": "public" - }, - { - "id": 61870, - "nodeType": "VariableDeclaration", - "src": "689:129:138", - "nodes": [], - "constant": true, - "functionSelector": "0f96c5f4", - "mutability": "constant", - "name": "PERMIT_TYPEHASH_NON_STANDARD", - "nameLocation": "713:28:138", - "scope": 62092, - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 61868, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "689:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": { - "hexValue": "307865613261613061316265313161303765643836643735356339333436376634663832333632623435323337316431626139346431373135313233353131616362", - "id": 61869, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "752:66:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_105916522785188513640362517802612480037966763957092682311465172263008277174987_by_1", - "typeString": "int_const 1059...(70 digits omitted)...4987" - }, - "value": "0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb" - }, - "visibility": "public" - }, - { - "id": 61909, - "nodeType": "FunctionDefinition", - "src": "825:407:138", - "nodes": [], - "body": { - "id": 61908, - "nodeType": "Block", - "src": "883:349:138", - "nodes": [], - "statements": [ - { - "expression": { - "id": 61906, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 61878, - "name": "DOMAIN_SEPARATOR", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61860, - "src": "893:16:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "arguments": [ - { - "arguments": [ - { - "arguments": [ - { - "hexValue": "454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429", - "id": 61883, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "973:84:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f", - "typeString": "literal_string \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"" - }, - "value": "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_stringliteral_8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f", - "typeString": "literal_string \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"" - } - ], - "id": 61882, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "963:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 61884, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "963:95:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "arguments": [ - { - "arguments": [ - { - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 61888, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 43719, - "src": "1092:4:138", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_string_memory_ptr_$", - "typeString": "function () view returns (string memory)" - } - }, - "id": 61889, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1092:6:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - ], - "id": 61887, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "1086:5:138", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_bytes_storage_ptr_$", - "typeString": "type(bytes storage pointer)" - }, - "typeName": { - "id": 61886, - "name": "bytes", - "nodeType": "ElementaryTypeName", - "src": "1086:5:138", - "typeDescriptions": {} - } - }, - "id": 61890, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1086:13:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 61885, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "1076:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 61891, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1076:24:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "arguments": [ - { - "arguments": [ - { - "hexValue": "31", - "id": 61895, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1134:3:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6", - "typeString": "literal_string \"1\"" - }, - "value": "1" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_stringliteral_c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6", - "typeString": "literal_string \"1\"" - } - ], - "id": 61894, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "1128:5:138", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_bytes_storage_ptr_$", - "typeString": "type(bytes storage pointer)" - }, - "typeName": { - "id": 61893, - "name": "bytes", - "nodeType": "ElementaryTypeName", - "src": "1128:5:138", - "typeDescriptions": {} - } - }, - "id": 61896, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1128:10:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 61892, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "1118:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 61897, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1118:21:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "expression": { - "id": 61898, - "name": "block", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -4, - "src": "1157:5:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_block", - "typeString": "block" - } - }, - "id": 61899, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "chainid", - "nodeType": "MemberAccess", - "src": "1157:13:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "arguments": [ - { - "id": 61902, - "name": "this", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -28, - "src": "1196:4:138", - "typeDescriptions": { - "typeIdentifier": "t_contract$_ERC20Permit_$62092", - "typeString": "contract ERC20Permit" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_contract$_ERC20Permit_$62092", - "typeString": "contract ERC20Permit" - } - ], - "id": 61901, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "1188:7:138", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 61900, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1188:7:138", - "typeDescriptions": {} - } - }, - "id": 61903, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1188:13:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "expression": { - "id": 61880, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -1, - "src": "935:3:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 61881, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encode", - "nodeType": "MemberAccess", - "src": "935:10:138", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencode_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 61904, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "935:280:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 61879, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "912:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 61905, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "912:313:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "src": "893:332:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "id": 61907, - "nodeType": "ExpressionStatement", - "src": "893:332:138" - } - ] - }, - "implemented": true, - "kind": "constructor", - "modifiers": [ - { - "arguments": [ - { - "id": 61875, - "name": "_symbol", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61872, - "src": "874:7:138", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - } - ], - "id": 61876, - "kind": "baseConstructorSpecifier", - "modifierName": { - "id": 61874, - "name": "ERC20Mintable", - "nodeType": "IdentifierPath", - "referencedDeclaration": 61851, - "src": "860:13:138" - }, - "nodeType": "ModifierInvocation", - "src": "860:22:138" - } - ], - "name": "", - "nameLocation": "-1:-1:-1", - "parameters": { - "id": 61873, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 61872, - "mutability": "mutable", - "name": "_symbol", - "nameLocation": "851:7:138", - "nodeType": "VariableDeclaration", - "scope": 61909, - "src": "837:21:138", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 61871, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "837:6:138", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "836:23:138" - }, - "returnParameters": { - "id": 61877, - "nodeType": "ParameterList", - "parameters": [], - "src": "883:0:138" - }, - "scope": 62092, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - }, - { - "id": 61988, - "nodeType": "FunctionDefinition", - "src": "1238:728:138", - "nodes": [], - "body": { - "id": 61987, - "nodeType": "Block", - "src": "1428:538:138", - "nodes": [], - "statements": [ - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 61930, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 61927, - "name": "_deadline", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61917, - "src": "1446:9:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "expression": { - "id": 61928, - "name": "block", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -4, - "src": "1459:5:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_block", - "typeString": "block" - } - }, - "id": 61929, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "timestamp", - "nodeType": "MemberAccess", - "src": "1459:15:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1446:28:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45585049524544", - "id": 61931, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1476:9:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_bd725cfb5ba01ea5dc5a7159cf41eaa54c28dc001805ce2361d3c894e7c2f72a", - "typeString": "literal_string \"EXPIRED\"" - }, - "value": "EXPIRED" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_bd725cfb5ba01ea5dc5a7159cf41eaa54c28dc001805ce2361d3c894e7c2f72a", - "typeString": "literal_string \"EXPIRED\"" - } - ], - "id": 61926, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "1438:7:138", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 61932, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1438:48:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 61933, - "nodeType": "ExpressionStatement", - "src": "1438:48:138" - }, - { - "assignments": [ - 61935 - ], - "declarations": [ - { - "constant": false, - "id": 61935, - "mutability": "mutable", - "name": "digest", - "nameLocation": "1504:6:138", - "nodeType": "VariableDeclaration", - "scope": 61987, - "src": "1496:14:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 61934, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1496:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "internal" - } - ], - "id": 61957, - "initialValue": { - "arguments": [ - { - "arguments": [ - { - "hexValue": "1901", - "id": 61939, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1570:10:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_301a50b291d33ce1e8e9064e3f6a6c51d902ec22892b50d58abf6357c6a45541", - "typeString": "literal_string hex\"1901\"" - }, - "value": "\u0019\u0001" - }, - { - "id": 61940, - "name": "DOMAIN_SEPARATOR", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61860, - "src": "1598:16:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "arguments": [ - { - "arguments": [ - { - "id": 61944, - "name": "PERMIT_TYPEHASH", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61863, - "src": "1653:15:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "id": 61945, - "name": "_owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61911, - "src": "1670:6:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 61946, - "name": "_spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61913, - "src": "1678:8:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 61947, - "name": "_value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61915, - "src": "1688:6:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "id": 61951, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "1696:16:138", - "subExpression": { - "baseExpression": { - "id": 61948, - "name": "nonces", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61867, - "src": "1696:6:138", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 61950, - "indexExpression": { - "id": 61949, - "name": "_owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61911, - "src": "1703:6:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "1696:14:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "id": 61952, - "name": "_deadline", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61917, - "src": "1714:9:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "id": 61942, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -1, - "src": "1642:3:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 61943, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encode", - "nodeType": "MemberAccess", - "src": "1642:10:138", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencode_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 61953, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1642:82:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 61941, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "1632:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 61954, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1632:93:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_stringliteral_301a50b291d33ce1e8e9064e3f6a6c51d902ec22892b50d58abf6357c6a45541", - "typeString": "literal_string hex\"1901\"" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "expression": { - "id": 61937, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -1, - "src": "1536:3:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 61938, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "src": "1536:16:138", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 61955, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1536:203:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 61936, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "1513:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 61956, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1513:236:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "1496:253:138" - }, - { - "assignments": [ - 61959 - ], - "declarations": [ - { - "constant": false, - "id": 61959, - "mutability": "mutable", - "name": "recoveredAddress", - "nameLocation": "1767:16:138", - "nodeType": "VariableDeclaration", - "scope": 61987, - "src": "1759:24:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 61958, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1759:7:138", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - } - ], - "id": 61966, - "initialValue": { - "arguments": [ - { - "id": 61961, - "name": "digest", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61935, - "src": "1796:6:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "id": 61962, - "name": "_v", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61919, - "src": "1804:2:138", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - { - "id": 61963, - "name": "_r", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61921, - "src": "1808:2:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "id": 61964, - "name": "_s", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61923, - "src": "1812:2:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 61960, - "name": "ecrecover", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -6, - "src": "1786:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_ecrecover_pure$_t_bytes32_$_t_uint8_$_t_bytes32_$_t_bytes32_$returns$_t_address_$", - "typeString": "function (bytes32,uint8,bytes32,bytes32) pure returns (address)" - } - }, - "id": 61965, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1786:29:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "1759:56:138" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 61977, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 61973, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 61968, - "name": "recoveredAddress", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61959, - "src": "1833:16:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 61971, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1861:1:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 61970, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "1853:7:138", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 61969, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1853:7:138", - "typeDescriptions": {} - } - }, - "id": 61972, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1853:10:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "1833:30:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "&&", - "rightExpression": { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 61976, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 61974, - "name": "recoveredAddress", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61959, - "src": "1867:16:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "id": 61975, - "name": "_owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61911, - "src": "1887:6:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "1867:26:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "1833:60:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "494e56414c49445f5349474e4154555245", - "id": 61978, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1895:19:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_5e2e9eaa2d734966dea0900deacd15b20129fbce05255d633a3ce5ebca181b88", - "typeString": "literal_string \"INVALID_SIGNATURE\"" - }, - "value": "INVALID_SIGNATURE" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_5e2e9eaa2d734966dea0900deacd15b20129fbce05255d633a3ce5ebca181b88", - "typeString": "literal_string \"INVALID_SIGNATURE\"" - } - ], - "id": 61967, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "1825:7:138", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 61979, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1825:90:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 61980, - "nodeType": "ExpressionStatement", - "src": "1825:90:138" - }, - { - "expression": { - "arguments": [ - { - "id": 61982, - "name": "_owner", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61911, - "src": "1934:6:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 61983, - "name": "_spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61913, - "src": "1942:8:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 61984, - "name": "_value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61915, - "src": "1952:6:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 61981, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "1925:8:138", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 61985, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1925:34:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 61986, - "nodeType": "ExpressionStatement", - "src": "1925:34:138" - } - ] - }, - "functionSelector": "d505accf", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "permit", - "nameLocation": "1247:6:138", - "parameters": { - "id": 61924, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 61911, - "mutability": "mutable", - "name": "_owner", - "nameLocation": "1271:6:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1263:14:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 61910, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1263:7:138", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61913, - "mutability": "mutable", - "name": "_spender", - "nameLocation": "1295:8:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1287:16:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 61912, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1287:7:138", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61915, - "mutability": "mutable", - "name": "_value", - "nameLocation": "1321:6:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1313:14:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 61914, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1313:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61917, - "mutability": "mutable", - "name": "_deadline", - "nameLocation": "1345:9:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1337:17:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 61916, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1337:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61919, - "mutability": "mutable", - "name": "_v", - "nameLocation": "1370:2:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1364:8:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - "typeName": { - "id": 61918, - "name": "uint8", - "nodeType": "ElementaryTypeName", - "src": "1364:5:138", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61921, - "mutability": "mutable", - "name": "_r", - "nameLocation": "1390:2:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1382:10:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 61920, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1382:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61923, - "mutability": "mutable", - "name": "_s", - "nameLocation": "1410:2:138", - "nodeType": "VariableDeclaration", - "scope": 61988, - "src": "1402:10:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 61922, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1402:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "internal" - } - ], - "src": "1253:165:138" - }, - "returnParameters": { - "id": 61925, - "nodeType": "ParameterList", - "parameters": [], - "src": "1428:0:138" - }, - "scope": 62092, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "external" - }, - { - "id": 62091, - "nodeType": "FunctionDefinition", - "src": "1972:859:138", - "nodes": [], - "body": { - "id": 62090, - "nodeType": "Block", - "src": "2184:647:138", - "nodes": [], - "statements": [ - { - "assignments": [ - 62008 - ], - "declarations": [ - { - "constant": false, - "id": 62008, - "mutability": "mutable", - "name": "digest", - "nameLocation": "2202:6:138", - "nodeType": "VariableDeclaration", - "scope": 62090, - "src": "2194:14:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 62007, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "2194:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "internal" - } - ], - "id": 62027, - "initialValue": { - "arguments": [ - { - "arguments": [ - { - "hexValue": "1901", - "id": 62012, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2268:10:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_301a50b291d33ce1e8e9064e3f6a6c51d902ec22892b50d58abf6357c6a45541", - "typeString": "literal_string hex\"1901\"" - }, - "value": "\u0019\u0001" - }, - { - "id": 62013, - "name": "DOMAIN_SEPARATOR", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61860, - "src": "2296:16:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "arguments": [ - { - "arguments": [ - { - "id": 62017, - "name": "PERMIT_TYPEHASH_NON_STANDARD", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61870, - "src": "2351:28:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "id": 62018, - "name": "_holder", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61990, - "src": "2381:7:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 62019, - "name": "_spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61992, - "src": "2390:8:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 62020, - "name": "_nonce", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61994, - "src": "2400:6:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "id": 62021, - "name": "_expiry", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61996, - "src": "2408:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "id": 62022, - "name": "_allowed", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61998, - "src": "2417:8:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "expression": { - "id": 62015, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -1, - "src": "2340:3:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 62016, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encode", - "nodeType": "MemberAccess", - "src": "2340:10:138", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencode_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 62023, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2340:86:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 62014, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "2330:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 62024, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2330:97:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_stringliteral_301a50b291d33ce1e8e9064e3f6a6c51d902ec22892b50d58abf6357c6a45541", - "typeString": "literal_string hex\"1901\"" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "expression": { - "id": 62010, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -1, - "src": "2234:3:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 62011, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "src": "2234:16:138", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 62025, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2234:207:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 62009, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -8, - "src": "2211:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 62026, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2211:240:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "2194:257:138" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 62034, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 62029, - "name": "_holder", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61990, - "src": "2470:7:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "arguments": [ - { - "hexValue": "30", - "id": 62032, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2489:1:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 62031, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "2481:7:138", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": { - "id": 62030, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2481:7:138", - "typeDescriptions": {} - } - }, - "id": 62033, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2481:10:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "2470:21:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "494e56414c49445f484f4c444552", - "id": 62035, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2493:16:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_3ba0cc199df56dc996b7a3759c1e23e7ce6440366b87724fb8e360ad5d4d76d0", - "typeString": "literal_string \"INVALID_HOLDER\"" - }, - "value": "INVALID_HOLDER" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_3ba0cc199df56dc996b7a3759c1e23e7ce6440366b87724fb8e360ad5d4d76d0", - "typeString": "literal_string \"INVALID_HOLDER\"" - } - ], - "id": 62028, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "2462:7:138", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 62036, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2462:48:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 62037, - "nodeType": "ExpressionStatement", - "src": "2462:48:138" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 62046, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 62039, - "name": "_holder", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61990, - "src": "2528:7:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "arguments": [ - { - "id": 62041, - "name": "digest", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 62008, - "src": "2549:6:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "id": 62042, - "name": "_v", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 62000, - "src": "2557:2:138", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - { - "id": 62043, - "name": "_r", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 62002, - "src": "2561:2:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "id": 62044, - "name": "_s", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 62004, - "src": "2565:2:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 62040, - "name": "ecrecover", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -6, - "src": "2539:9:138", - "typeDescriptions": { - "typeIdentifier": "t_function_ecrecover_pure$_t_bytes32_$_t_uint8_$_t_bytes32_$_t_bytes32_$returns$_t_address_$", - "typeString": "function (bytes32,uint8,bytes32,bytes32) pure returns (address)" - } - }, - "id": 62045, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2539:29:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "2528:40:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "494e56414c49445f5349474e4154555245", - "id": 62047, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2570:19:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_5e2e9eaa2d734966dea0900deacd15b20129fbce05255d633a3ce5ebca181b88", - "typeString": "literal_string \"INVALID_SIGNATURE\"" - }, - "value": "INVALID_SIGNATURE" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_5e2e9eaa2d734966dea0900deacd15b20129fbce05255d633a3ce5ebca181b88", - "typeString": "literal_string \"INVALID_SIGNATURE\"" - } - ], - "id": 62038, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "2520:7:138", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 62048, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2520:70:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 62049, - "nodeType": "ExpressionStatement", - "src": "2520:70:138" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 62058, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 62053, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 62051, - "name": "_expiry", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61996, - "src": "2608:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "hexValue": "30", - "id": 62052, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2619:1:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "2608:12:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "||", - "rightExpression": { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 62057, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 62054, - "name": "_expiry", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61996, - "src": "2624:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "expression": { - "id": 62055, - "name": "block", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": -4, - "src": "2635:5:138", - "typeDescriptions": { - "typeIdentifier": "t_magic_block", - "typeString": "block" - } - }, - "id": 62056, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "timestamp", - "nodeType": "MemberAccess", - "src": "2635:15:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "2624:26:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2608:42:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "45585049524544", - "id": 62059, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2652:9:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_bd725cfb5ba01ea5dc5a7159cf41eaa54c28dc001805ce2361d3c894e7c2f72a", - "typeString": "literal_string \"EXPIRED\"" - }, - "value": "EXPIRED" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_bd725cfb5ba01ea5dc5a7159cf41eaa54c28dc001805ce2361d3c894e7c2f72a", - "typeString": "literal_string \"EXPIRED\"" - } - ], - "id": 62050, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "2600:7:138", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 62060, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2600:62:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 62061, - "nodeType": "ExpressionStatement", - "src": "2600:62:138" - }, - { - "expression": { - "arguments": [ - { - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 62068, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "id": 62063, - "name": "_nonce", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61994, - "src": "2680:6:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "id": 62067, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "2690:17:138", - "subExpression": { - "baseExpression": { - "id": 62064, - "name": "nonces", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61867, - "src": "2690:6:138", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", - "typeString": "mapping(address => uint256)" - } - }, - "id": 62066, - "indexExpression": { - "id": 62065, - "name": "_holder", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61990, - "src": "2697:7:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "2690:15:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "2680:27:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "hexValue": "494e56414c49445f4e4f4e4345", - "id": 62069, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2709:15:138", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_a19e25beaf00f467d35fbe7e167b5794fca796dbfd417dd2accc8f5303300b99", - "typeString": "literal_string \"INVALID_NONCE\"" - }, - "value": "INVALID_NONCE" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_a19e25beaf00f467d35fbe7e167b5794fca796dbfd417dd2accc8f5303300b99", - "typeString": "literal_string \"INVALID_NONCE\"" - } - ], - "id": 62062, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - -18, - -18 - ], - "referencedDeclaration": -18, - "src": "2672:7:138", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 62070, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2672:53:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 62071, - "nodeType": "ExpressionStatement", - "src": "2672:53:138" - }, - { - "assignments": [ - 62073 - ], - "declarations": [ - { - "constant": false, - "id": 62073, - "mutability": "mutable", - "name": "value", - "nameLocation": "2743:5:138", - "nodeType": "VariableDeclaration", - "scope": 62090, - "src": "2735:13:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 62072, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2735:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - } - ], - "id": 62083, - "initialValue": { - "condition": { - "id": 62074, - "name": "_allowed", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61998, - "src": "2751:8:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseExpression": { - "hexValue": "30", - "id": 62081, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2779:1:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "id": 62082, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "Conditional", - "src": "2751:29:138", - "trueExpression": { - "commonType": { - "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1", - "typeString": "int_const 1157...(70 digits omitted)...9935" - }, - "id": 62080, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "components": [ - { - "commonType": { - "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1", - "typeString": "int_const 1157...(70 digits omitted)...9936" - }, - "id": 62077, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "hexValue": "32", - "id": 62075, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2763:1:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "hexValue": "323536", - "id": 62076, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2768:3:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_256_by_1", - "typeString": "int_const 256" - }, - "value": "256" - }, - "src": "2763:8:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1", - "typeString": "int_const 1157...(70 digits omitted)...9936" - } - } - ], - "id": 62078, - "isConstant": false, - "isInlineArray": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "TupleExpression", - "src": "2762:10:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1", - "typeString": "int_const 1157...(70 digits omitted)...9936" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "hexValue": "31", - "id": 62079, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2775:1:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "2762:14:138", - "typeDescriptions": { - "typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1", - "typeString": "int_const 1157...(70 digits omitted)...9935" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "2735:45:138" - }, - { - "expression": { - "arguments": [ - { - "id": 62085, - "name": "_holder", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61990, - "src": "2799:7:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 62086, - "name": "_spender", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 61992, - "src": "2808:8:138", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "id": 62087, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 62073, - "src": "2818:5:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 62084, - "name": "_approve", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 44185, - "src": "2790:8:138", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", - "typeString": "function (address,address,uint256)" - } - }, - "id": 62088, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2790:34:138", - "tryCall": false, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 62089, - "nodeType": "ExpressionStatement", - "src": "2790:34:138" - } - ] - }, - "functionSelector": "8fcbaf0c", - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "permit", - "nameLocation": "1981:6:138", - "parameters": { - "id": 62005, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 61990, - "mutability": "mutable", - "name": "_holder", - "nameLocation": "2005:7:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "1997:15:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 61989, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1997:7:138", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61992, - "mutability": "mutable", - "name": "_spender", - "nameLocation": "2030:8:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2022:16:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 61991, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2022:7:138", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61994, - "mutability": "mutable", - "name": "_nonce", - "nameLocation": "2056:6:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2048:14:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 61993, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2048:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61996, - "mutability": "mutable", - "name": "_expiry", - "nameLocation": "2080:7:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2072:15:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 61995, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2072:7:138", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 61998, - "mutability": "mutable", - "name": "_allowed", - "nameLocation": "2102:8:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2097:13:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 61997, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "2097:4:138", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 62000, - "mutability": "mutable", - "name": "_v", - "nameLocation": "2126:2:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2120:8:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - }, - "typeName": { - "id": 61999, - "name": "uint8", - "nodeType": "ElementaryTypeName", - "src": "2120:5:138", - "typeDescriptions": { - "typeIdentifier": "t_uint8", - "typeString": "uint8" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 62002, - "mutability": "mutable", - "name": "_r", - "nameLocation": "2146:2:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2138:10:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 62001, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "2138:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "internal" - }, - { - "constant": false, - "id": 62004, - "mutability": "mutable", - "name": "_s", - "nameLocation": "2166:2:138", - "nodeType": "VariableDeclaration", - "scope": 62091, - "src": "2158:10:138", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 62003, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "2158:7:138", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "visibility": "internal" - } - ], - "src": "1987:187:138" - }, - "returnParameters": { - "id": 62006, - "nodeType": "ParameterList", - "parameters": [], - "src": "2184:0:138" - }, - "scope": 62092, - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "external" - } - ], - "abstract": false, - "baseContracts": [ - { - "baseName": { - "id": 61857, - "name": "ERC20Mintable", - "nodeType": "IdentifierPath", - "referencedDeclaration": 61851, - "src": "313:13:138" - }, - "id": 61858, - "nodeType": "InheritanceSpecifier", - "src": "313:13:138" - } - ], - "canonicalName": "ERC20Permit", - "contractDependencies": [], - "contractKind": "contract", - "documentation": { - "id": 61856, - "nodeType": "StructuredDocumentation", - "src": "145:143:138", - "text": " @dev Warning: do not deploy in real environments, for testing only\n ERC20 contract which has permit implementation and is mintable" - }, - "fullyImplemented": true, - "linearizedBaseContracts": [ - 62092, - 61851, - 44251, - 44354, - 44329, - 45026 - ], - "name": "ERC20Permit", - "nameLocation": "298:11:138", - "scope": 62093, - "usedErrors": [] - } - ], - "license": "Apache-2.0" - }, - "id": 138 -} \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/contracts/DaiContract.ts b/yarn-project/ethereum.js/example/src/contracts/DaiContract.ts deleted file mode 100644 index 1b526c14946..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/DaiContract.ts +++ /dev/null @@ -1,85 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from "@aztec/ethereum.js/eth_address"; -import { EthereumRpc } from "@aztec/ethereum.js/eth_rpc"; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from "@aztec/ethereum.js/contract"; -import * as Bytes from "@aztec/ethereum.js/contract/bytes.js"; -import abi from "./DaiContractAbi.js"; -export type ApprovalEvent = { - src: EthAddress; - guy: EthAddress; - wad: bigint; -}; -export type LogNoteEvent = { - sig: Bytes.Bytes4; - usr: EthAddress; - arg1: Bytes.Bytes32; - arg2: Bytes.Bytes32; - data: Bytes.Bytes; -}; -export type TransferEvent = { - src: EthAddress; - dst: EthAddress; - wad: bigint; -}; -export interface ApprovalEventLog extends EventLog { -} -export interface LogNoteEventLog extends EventLog { -} -export interface TransferEventLog extends EventLog { -} -interface DaiContractEvents { - Approval: ApprovalEvent; - LogNote: LogNoteEvent; - Transfer: TransferEvent; -} -interface DaiContractEventLogs { - Approval: ApprovalEventLog; - LogNote: LogNoteEventLog; - Transfer: TransferEventLog; -} -interface DaiContractTxEventLogs { - Approval: ApprovalEventLog[]; - LogNote: LogNoteEventLog[]; - Transfer: TransferEventLog[]; -} -export interface DaiContractTransactionReceipt extends ContractTxReceipt { -} -interface DaiContractMethods { - DOMAIN_SEPARATOR(): TxCall; - PERMIT_TYPEHASH(): TxCall; - allowance(a0: EthAddress, a1: EthAddress): TxCall; - approve(usr: EthAddress, wad: bigint): TxSend; - balanceOf(a0: EthAddress): TxCall; - burn(usr: EthAddress, wad: bigint): TxSend; - decimals(): TxCall; - deny(guy: EthAddress): TxSend; - mint(usr: EthAddress, wad: bigint): TxSend; - move(src: EthAddress, dst: EthAddress, wad: bigint): TxSend; - name(): TxCall; - nonces(a0: EthAddress): TxCall; - permit(holder: EthAddress, spender: EthAddress, nonce: bigint, expiry: bigint, allowed: boolean, v: number, r: Bytes.Bytes32, s: Bytes.Bytes32): TxSend; - pull(usr: EthAddress, wad: bigint): TxSend; - push(usr: EthAddress, wad: bigint): TxSend; - rely(guy: EthAddress): TxSend; - symbol(): TxCall; - totalSupply(): TxCall; - transfer(dst: EthAddress, wad: bigint): TxSend; - transferFrom(src: EthAddress, dst: EthAddress, wad: bigint): TxSend; - version(): TxCall; - wards(a0: EthAddress): TxCall; -} -export interface DaiContractDefinition { - methods: DaiContractMethods; - events: DaiContractEvents; - eventLogs: DaiContractEventLogs; -} -export class DaiContract extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(chainId_: bigint): TxSend { - return super.deployBytecode("0x608060405234801561001057600080fd5b50600436106101425760003560e01c80637ecebe00116100b8578063a9059cbb1161007c578063a9059cbb146106b4578063b753a98c1461071a578063bb35783b14610768578063bf353dbb146107d6578063dd62ed3e1461082e578063f2d5d56b146108a657610142565b80637ecebe00146104a15780638fcbaf0c146104f957806395d89b411461059f5780639c52a7f1146106225780639dc29fac1461066657610142565b8063313ce5671161010a578063313ce567146102f25780633644e5151461031657806340c10f191461033457806354fd4d501461038257806365fae35e1461040557806370a082311461044957610142565b806306fdde0314610147578063095ea7b3146101ca57806318160ddd1461023057806323b872dd1461024e57806330adf81f146102d4575b600080fd5b61014f6108f4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561018f578082015181840152602081019050610174565b50505050905090810190601f1680156101bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610216600480360360408110156101e057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061092d565b604051808215151515815260200191505060405180910390f35b610238610a1f565b6040518082815260200191505060405180910390f35b6102ba6004803603606081101561026457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a25565b604051808215151515815260200191505060405180910390f35b6102dc610f3a565b6040518082815260200191505060405180910390f35b6102fa610f61565b604051808260ff1660ff16815260200191505060405180910390f35b61031e610f66565b6040518082815260200191505060405180910390f35b6103806004803603604081101561034a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6c565b005b61038a611128565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ca5780820151818401526020810190506103af565b50505050905090810190601f1680156103f75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104476004803603602081101561041b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611161565b005b61048b6004803603602081101561045f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061128f565b6040518082815260200191505060405180910390f35b6104e3600480360360208110156104b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112a7565b6040518082815260200191505060405180910390f35b61059d600480360361010081101561051057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803515159060200190929190803560ff16906020019092919080359060200190929190803590602001909291905050506112bf565b005b6105a76117fa565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e75780820151818401526020810190506105cc565b50505050905090810190601f1680156106145780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106646004803603602081101561063857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611833565b005b6106b26004803603604081101561067c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611961565b005b610700600480360360408110156106ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611df4565b604051808215151515815260200191505060405180910390f35b6107666004803603604081101561073057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611e09565b005b6107d46004803603606081101561077e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611e19565b005b610818600480360360208110156107ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e2a565b6040518082815260200191505060405180910390f35b6108906004803603604081101561084457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e42565b6040518082815260200191505060405180910390f35b6108f2600480360360408110156108bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611e67565b005b6040518060400160405280600e81526020017f44616920537461626c65636f696e00000000000000000000000000000000000081525081565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60015481565b600081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610adc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f4461692f696e73756666696369656e742d62616c616e6365000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610bb457507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b15610db25781600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f4461692f696e73756666696369656e742d616c6c6f77616e636500000000000081525060200191505060405180910390fd5b610d31600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611e77565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b610dfb600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611e77565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e87600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611e91565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b7fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60001b81565b601281565b60055481565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414611020576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4461692f6e6f742d617574686f72697a6564000000000000000000000000000081525060200191505060405180910390fd5b611069600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611e91565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110b860015482611e91565b6001819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414611215576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4461692f6e6f742d617574686f72697a6564000000000000000000000000000081525060200191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b60026020528060005260406000206000915090505481565b60046020528060005260406000206000915090505481565b60006005547fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60001b8a8a8a8a8a604051602001808781526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018381526020018215151515815260200196505050505050506040516020818303038152906040528051906020012060405160200180807f190100000000000000000000000000000000000000000000000000000000000081525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff16141561148c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4461692f696e76616c69642d616464726573732d30000000000000000000000081525060200191505060405180910390fd5b60018185858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156114e9573d6000803e3d6000fd5b5050506020604051035173ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614611593576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4461692f696e76616c69642d7065726d6974000000000000000000000000000081525060200191505060405180910390fd5b60008614806115a25750854211155b611614576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4461692f7065726d69742d65787069726564000000000000000000000000000081525060200191505060405180910390fd5b600460008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906001019190505587146116d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4461692f696e76616c69642d6e6f6e636500000000000000000000000000000081525060200191505060405180910390fd5b6000856116e4576000611706565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b905080600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508873ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a350505050505050505050565b6040518060400160405280600381526020017f444149000000000000000000000000000000000000000000000000000000000081525081565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146118e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4461692f6e6f742d617574686f72697a6564000000000000000000000000000081525060200191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611a16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f4461692f696e73756666696369656e742d62616c616e6365000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614158015611aee57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b15611cec5780600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611be5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f4461692f696e73756666696369656e742d616c6c6f77616e636500000000000081525060200191505060405180910390fd5b611c6b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611e77565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b611d35600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611e77565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d8460015482611e77565b600181905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000611e01338484610a25565b905092915050565b611e14338383610a25565b505050565b611e24838383610a25565b50505050565b60006020528060005260406000206000915090505481565b6003602052816000526040600020602052806000526040600020600091509150505481565b611e72823383610a25565b505050565b6000828284039150811115611e8b57600080fd5b92915050565b6000828284019150811015611ea557600080fd5b9291505056fea265627a7a72315820c0ae2c29860c0a59d5586a579abbcddfe4bcef0524a87301425cbc58c3e94e3164736f6c634300050c0032", chainId_) as any; - } -} -export var DaiContractAbi = abi; diff --git a/yarn-project/ethereum.js/example/src/contracts/DaiContractAbi.ts b/yarn-project/ethereum.js/example/src/contracts/DaiContractAbi.ts deleted file mode 100644 index 61aa7562e0d..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/DaiContractAbi.ts +++ /dev/null @@ -1,564 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - "inputs": [ - { - "internalType": "uint256", - "name": "chainId_", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "guy", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": true, - "inputs": [ - { - "indexed": true, - "internalType": "bytes4", - "name": "sig", - "type": "bytes4" - }, - { - "indexed": true, - "internalType": "address", - "name": "usr", - "type": "address" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "arg1", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "arg2", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "LogNote", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "usr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "usr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "guy", - "type": "address" - } - ], - "name": "deny", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "usr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "move", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "holder", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expiry", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "allowed", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "usr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "pull", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "usr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "push", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "guy", - "type": "address" - } - ], - "name": "rely", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "wad", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "version", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "wards", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } -]); \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/contracts/ERC20Mintable.ts b/yarn-project/ethereum.js/example/src/contracts/ERC20Mintable.ts deleted file mode 100644 index 12ebd9f6c23..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/ERC20Mintable.ts +++ /dev/null @@ -1,64 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from "@aztec/ethereum.js/eth_address"; -import { EthereumRpc } from "@aztec/ethereum.js/eth_rpc"; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from "@aztec/ethereum.js/contract"; -import * as Bytes from "@aztec/ethereum.js/contract/bytes.js"; -import abi from "./ERC20MintableAbi.js"; -export type ApprovalEvent = { - owner: EthAddress; - spender: EthAddress; - value: bigint; -}; -export type TransferEvent = { - from: EthAddress; - to: EthAddress; - value: bigint; -}; -export interface ApprovalEventLog extends EventLog { -} -export interface TransferEventLog extends EventLog { -} -interface ERC20MintableEvents { - Approval: ApprovalEvent; - Transfer: TransferEvent; -} -interface ERC20MintableEventLogs { - Approval: ApprovalEventLog; - Transfer: TransferEventLog; -} -interface ERC20MintableTxEventLogs { - Approval: ApprovalEventLog[]; - Transfer: TransferEventLog[]; -} -export interface ERC20MintableTransactionReceipt extends ContractTxReceipt { -} -interface ERC20MintableMethods { - allowance(owner: EthAddress, spender: EthAddress): TxCall; - approve(spender: EthAddress, amount: bigint): TxSend; - balanceOf(account: EthAddress): TxCall; - decimals(): TxCall; - decreaseAllowance(spender: EthAddress, subtractedValue: bigint): TxSend; - increaseAllowance(spender: EthAddress, addedValue: bigint): TxSend; - mint(_to: EthAddress, _value: bigint): TxSend; - name(): TxCall; - setDecimals(_decimals: number): TxSend; - symbol(): TxCall; - totalSupply(): TxCall; - transfer(to: EthAddress, amount: bigint): TxSend; - transferFrom(from: EthAddress, to: EthAddress, amount: bigint): TxSend; -} -export interface ERC20MintableDefinition { - methods: ERC20MintableMethods; - events: ERC20MintableEvents; - eventLogs: ERC20MintableEventLogs; -} -export class ERC20Mintable extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(_symbol: string): TxSend { - return super.deployBytecode("0x60806040526005805460ff191660121790553480156200001e57600080fd5b5060405162000dd538038062000dd5833981016040819052620000419162000136565b8051819081906200005a9060039060208401906200007a565b508051620000709060049060208401906200007a565b505050506200024f565b828054620000889062000212565b90600052602060002090601f016020900481019282620000ac5760008555620000f7565b82601f10620000c757805160ff1916838001178555620000f7565b82800160010185558215620000f7579182015b82811115620000f7578251825591602001919060010190620000da565b506200010592915062000109565b5090565b5b808211156200010557600081556001016200010a565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200014a57600080fd5b82516001600160401b03808211156200016257600080fd5b818501915085601f8301126200017757600080fd5b8151818111156200018c576200018c62000120565b604051601f8201601f19908116603f01168101908382118183101715620001b757620001b762000120565b816040528281528886848701011115620001d057600080fd5b600093505b82841015620001f45784840186015181850187015292850192620001d5565b82841115620002065760008684830101525b98975050505050505050565b600181811c908216806200022757607f821691505b602082108114156200024957634e487b7160e01b600052602260045260246000fd5b50919050565b610b76806200025f6000396000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101f2578063a457c2d7146101fa578063a9059cbb1461020d578063dd62ed3e1461022057600080fd5b806340c10f191461017257806370a08231146101855780637a1395aa146101ae57600080fd5b806323b872dd116100bd57806323b872dd14610137578063313ce5671461014a578063395093511461015f57600080fd5b806306fdde03146100e4578063095ea7b31461010257806318160ddd14610125575b600080fd5b6100ec610259565b6040516100f99190610921565b60405180910390f35b61011561011036600461098e565b6102eb565b60405190151581526020016100f9565b6002545b6040519081526020016100f9565b6101156101453660046109b8565b610303565b60055460405160ff90911681526020016100f9565b61011561016d36600461098e565b610327565b61011561018036600461098e565b610366565b6101296101933660046109f4565b6001600160a01b031660009081526020819052604090205490565b6101f06101bc366004610a16565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b005b6100ec61037b565b61011561020836600461098e565b61038a565b61011561021b36600461098e565b610439565b61012961022e366004610a39565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461026890610a6c565b80601f016020809104026020016040519081016040528092919081815260200182805461029490610a6c565b80156102e15780601f106102b6576101008083540402835291602001916102e1565b820191906000526020600020905b8154815290600101906020018083116102c457829003601f168201915b5050505050905090565b6000336102f9818585610447565b5060019392505050565b60003361031185828561059f565b61031c858585610649565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906102f99082908690610361908790610ac0565b610447565b60006103728383610836565b50600192915050565b60606004805461026890610a6c565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091908381101561042c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61031c8286868403610447565b6000336102f9818585610649565b6001600160a01b0383166104c25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b03821661053e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461064357818110156105f861037b565b6040516020016106089190610aff565b604051602081830303815290604052906106355760405162461bcd60e51b81526004016104239190610921565b506106438484848403610447565b50505050565b6001600160a01b0383166106c55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b0382166107415760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b038316600090815260208190526040902054818110156107d05760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610423565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610643565b6001600160a01b03821661088c5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610423565b806002600082825461089e9190610ac0565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60005b838110156109105781810151838201526020016108f8565b838111156106435750506000910152565b60208152600082518060208401526109408160408501602087016108f5565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b80356001600160a01b038116811461098957600080fd5b919050565b600080604083850312156109a157600080fd5b6109aa83610972565b946020939093013593505050565b6000806000606084860312156109cd57600080fd5b6109d684610972565b92506109e460208501610972565b9150604084013590509250925092565b600060208284031215610a0657600080fd5b610a0f82610972565b9392505050565b600060208284031215610a2857600080fd5b813560ff81168114610a0f57600080fd5b60008060408385031215610a4c57600080fd5b610a5583610972565b9150610a6360208401610972565b90509250929050565b600181811c90821680610a8057607f821691505b60208210811415610aba577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60008219821115610afa577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500190565b60008251610b118184602087016108f5565b7f3a20696e73756666696369656e7420616c6c6f77616e6365000000000000000092019182525060180191905056fea2646970667358221220d5dfa0685bc929dfec54b5c67e6001c5f4941cc463ad06d3f691d75f4328810364736f6c634300080a0033", _symbol) as any; - } -} -export var ERC20MintableAbi = abi; diff --git a/yarn-project/ethereum.js/example/src/contracts/ERC20MintableAbi.ts b/yarn-project/ethereum.js/example/src/contracts/ERC20MintableAbi.ts deleted file mode 100644 index 7d460bacacd..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/ERC20MintableAbi.ts +++ /dev/null @@ -1,321 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "name": "setDecimals", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -]); \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/contracts/ERC20Permit.ts b/yarn-project/ethereum.js/example/src/contracts/ERC20Permit.ts deleted file mode 100644 index 493f9704def..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/ERC20Permit.ts +++ /dev/null @@ -1,70 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from "@aztec/ethereum.js/eth_address"; -import { EthereumRpc } from "@aztec/ethereum.js/eth_rpc"; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from "@aztec/ethereum.js/contract"; -import * as Bytes from "@aztec/ethereum.js/contract/bytes.js"; -import abi from "./ERC20PermitAbi.js"; -export type ApprovalEvent = { - owner: EthAddress; - spender: EthAddress; - value: bigint; -}; -export type TransferEvent = { - from: EthAddress; - to: EthAddress; - value: bigint; -}; -export interface ApprovalEventLog extends EventLog { -} -export interface TransferEventLog extends EventLog { -} -interface ERC20PermitEvents { - Approval: ApprovalEvent; - Transfer: TransferEvent; -} -interface ERC20PermitEventLogs { - Approval: ApprovalEventLog; - Transfer: TransferEventLog; -} -interface ERC20PermitTxEventLogs { - Approval: ApprovalEventLog[]; - Transfer: TransferEventLog[]; -} -export interface ERC20PermitTransactionReceipt extends ContractTxReceipt { -} -interface ERC20PermitMethods { - DOMAIN_SEPARATOR(): TxCall; - PERMIT_TYPEHASH(): TxCall; - PERMIT_TYPEHASH_NON_STANDARD(): TxCall; - allowance(owner: EthAddress, spender: EthAddress): TxCall; - approve(spender: EthAddress, amount: bigint): TxSend; - balanceOf(account: EthAddress): TxCall; - decimals(): TxCall; - decreaseAllowance(spender: EthAddress, subtractedValue: bigint): TxSend; - increaseAllowance(spender: EthAddress, addedValue: bigint): TxSend; - mint(_to: EthAddress, _value: bigint): TxSend; - name(): TxCall; - nonces(a0: EthAddress): TxCall; - permit(_holder: EthAddress, _spender: EthAddress, _nonce: bigint, _expiry: bigint, _allowed: boolean, _v: number, _r: Bytes.Bytes32, _s: Bytes.Bytes32): TxSend; - permit(_owner: EthAddress, _spender: EthAddress, _value: bigint, _deadline: bigint, _v: number, _r: Bytes.Bytes32, _s: Bytes.Bytes32): TxSend; - setDecimals(_decimals: number): TxSend; - symbol(): TxCall; - totalSupply(): TxCall; - transfer(to: EthAddress, amount: bigint): TxSend; - transferFrom(from: EthAddress, to: EthAddress, amount: bigint): TxSend; -} -export interface ERC20PermitDefinition { - methods: ERC20PermitMethods; - events: ERC20PermitEvents; - eventLogs: ERC20PermitEventLogs; -} -export class ERC20Permit extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(_symbol: string): TxSend { - return super.deployBytecode("0x60806040526005805460ff191660121790553480156200001e57600080fd5b506040516200162d3803806200162d833981016040819052620000419162000282565b80808181600390805190602001906200005c929190620001c6565b50805162000072906004906020840190620001c6565b505050507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000a76200012c60201b60201c565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160408051601f198184030181529190528051602090910120600655506200039b565b6060600380546200013d906200035e565b80601f01602080910402602001604051908101604052809291908181526020018280546200016b906200035e565b8015620001bc5780601f106200019057610100808354040283529160200191620001bc565b820191906000526020600020905b8154815290600101906020018083116200019e57829003601f168201915b5050505050905090565b828054620001d4906200035e565b90600052602060002090601f016020900481019282620001f8576000855562000243565b82601f106200021357805160ff191683800117855562000243565b8280016001018555821562000243579182015b828111156200024357825182559160200191906001019062000226565b506200025192915062000255565b5090565b5b8082111562000251576000815560010162000256565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200029657600080fd5b82516001600160401b0380821115620002ae57600080fd5b818501915085601f830112620002c357600080fd5b815181811115620002d857620002d86200026c565b604051601f8201601f19908116603f011681019083821181831017156200030357620003036200026c565b8160405282815288868487010111156200031c57600080fd5b600093505b8284101562000340578484018601518185018701529285019262000321565b82841115620003525760008684830101525b98975050505050505050565b600181811c908216806200037357607f821691505b602082108114156200039557634e487b7160e01b600052602260045260246000fd5b50919050565b61128280620003ab6000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c806340c10f19116100cd57806395d89b4111610081578063a9059cbb11610066578063a9059cbb1461030d578063d505accf14610320578063dd62ed3e1461033357600080fd5b806395d89b41146102f2578063a457c2d7146102fa57600080fd5b80637a1395aa116100b25780637a1395aa1461027b5780637ecebe00146102bf5780638fcbaf0c146102df57600080fd5b806340c10f191461023f57806370a082311461025257600080fd5b806323b872dd11610124578063313ce56711610109578063313ce5671461020e5780633644e51514610223578063395093511461022c57600080fd5b806323b872dd146101d457806330adf81f146101e757600080fd5b806306fdde0314610156578063095ea7b3146101745780630f96c5f41461019757806318160ddd146101cc575b600080fd5b61015e61036c565b60405161016b9190610f33565b60405180910390f35b610187610182366004610f82565b6103fe565b604051901515815260200161016b565b6101be7fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb81565b60405190815260200161016b565b6002546101be565b6101876101e2366004610fac565b610416565b6101be7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460405160ff909116815260200161016b565b6101be60065481565b61018761023a366004610f82565b61043a565b61018761024d366004610f82565b610479565b6101be610260366004610fe8565b6001600160a01b031660009081526020819052604090205490565b6102bd61028936600461101b565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055565b005b6101be6102cd366004610fe8565b60076020526000908152604090205481565b6102bd6102ed366004611036565b61048e565b61015e610776565b610187610308366004610f82565b610785565b61018761031b366004610f82565b61082f565b6102bd61032e3660046110b8565b61083d565b6101be610341366004611122565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461037b90611155565b80601f01602080910402602001604051908101604052809291908181526020018280546103a790611155565b80156103f45780601f106103c9576101008083540402835291602001916103f4565b820191906000526020600020905b8154815290600101906020018083116103d757829003601f168201915b5050505050905090565b60003361040c818585610a77565b5060019392505050565b600033610424858285610bcf565b61042f858585610c5b565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061040c90829086906104749087906111d8565b610a77565b60006104858383610e48565b50600192915050565b600654604080517fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60208201526001600160a01b03808c169282019290925290891660608201526080810188905260a0810187905285151560c08201526000919060e0016040516020818303038152906040528051906020012060405160200161054a9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f19818403018152919052805160209091012090506001600160a01b0389166105bf5760405162461bcd60e51b815260206004820152600e60248201527f494e56414c49445f484f4c44455200000000000000000000000000000000000060448201526064015b60405180910390fd5b60408051600081526020810180835283905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610612573d6000803e3d6000fd5b505050602060405103516001600160a01b0316896001600160a01b03161461067c5760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f5349474e415455524500000000000000000000000000000060448201526064016105b6565b8515806106895750428610155b6106d55760405162461bcd60e51b815260206004820152600760248201527f455850495245440000000000000000000000000000000000000000000000000060448201526064016105b6565b6001600160a01b03891660009081526007602052604081208054916106f9836111f0565b91905055871461074b5760405162461bcd60e51b815260206004820152600d60248201527f494e56414c49445f4e4f4e43450000000000000000000000000000000000000060448201526064016105b6565b60008561075957600061075d565b6000195b905061076a8a8a83610a77565b50505050505050505050565b60606004805461037b90611155565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156108225760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016105b6565b61042f8286868403610a77565b60003361040c818585610c5b565b4284101561088d5760405162461bcd60e51b815260206004820152600760248201527f455850495245440000000000000000000000000000000000000000000000000060448201526064016105b6565b6006546001600160a01b038816600090815260076020526040812080549192917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b9190876108e0836111f0565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e001604051602081830303815290604052805190602001206040516020016109749291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa1580156109df573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610a155750886001600160a01b0316816001600160a01b0316145b610a615760405162461bcd60e51b815260206004820152601160248201527f494e56414c49445f5349474e415455524500000000000000000000000000000060448201526064016105b6565b610a6c898989610a77565b505050505050505050565b6001600160a01b038316610af25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b038216610b6e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610c555781811015610c0a610776565b604051602001610c1a919061120b565b60405160208183030381529060405290610c475760405162461bcd60e51b81526004016105b69190610f33565b50610c558484848403610a77565b50505050565b6001600160a01b038316610cd75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b038216610d535760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b03831660009081526020819052604090205481811015610de25760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016105b6565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610c55565b6001600160a01b038216610e9e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105b6565b8060026000828254610eb091906111d8565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60005b83811015610f22578181015183820152602001610f0a565b83811115610c555750506000910152565b6020815260008251806020840152610f52816040850160208701610f07565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610f7d57600080fd5b919050565b60008060408385031215610f9557600080fd5b610f9e83610f66565b946020939093013593505050565b600080600060608486031215610fc157600080fd5b610fca84610f66565b9250610fd860208501610f66565b9150604084013590509250925092565b600060208284031215610ffa57600080fd5b61100382610f66565b9392505050565b803560ff81168114610f7d57600080fd5b60006020828403121561102d57600080fd5b6110038261100a565b600080600080600080600080610100898b03121561105357600080fd5b61105c89610f66565b975061106a60208a01610f66565b965060408901359550606089013594506080890135801515811461108d57600080fd5b935061109b60a08a0161100a565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a0312156110d357600080fd5b6110dc88610f66565b96506110ea60208901610f66565b955060408801359450606088013593506111066080890161100a565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561113557600080fd5b61113e83610f66565b915061114c60208401610f66565b90509250929050565b600181811c9082168061116957607f821691505b602082108114156111a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156111eb576111eb6111a9565b500190565b6000600019821415611204576112046111a9565b5060010190565b6000825161121d818460208701610f07565b7f3a20696e73756666696369656e7420616c6c6f77616e6365000000000000000092019182525060180191905056fea264697066735822122054a35da2d250cd8d2d2f0d51975894ad0a754c0f6a8cb964d529e70c7ebf096664736f6c634300080a0033", _symbol) as any; - } -} -export var ERC20PermitAbi = abi; diff --git a/yarn-project/ethereum.js/example/src/contracts/ERC20PermitAbi.ts b/yarn-project/ethereum.js/example/src/contracts/ERC20PermitAbi.ts deleted file mode 100644 index 847cc29b649..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/ERC20PermitAbi.ts +++ /dev/null @@ -1,470 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PERMIT_TYPEHASH_NON_STANDARD", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_holder", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_nonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_expiry", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_allowed", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "_v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_deadline", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "_v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "_r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_decimals", - "type": "uint8" - } - ], - "name": "setDecimals", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -]); \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/contracts/RollupProcessorContract.ts b/yarn-project/ethereum.js/example/src/contracts/RollupProcessorContract.ts deleted file mode 100644 index ab249f9703e..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/RollupProcessorContract.ts +++ /dev/null @@ -1,298 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from "@aztec/ethereum.js/eth_address"; -import { EthereumRpc } from "@aztec/ethereum.js/eth_rpc"; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from "@aztec/ethereum.js/contract"; -import * as Bytes from "@aztec/ethereum.js/contract/bytes.js"; -import abi from "./RollupProcessorContractAbi.js"; -export type AllowThirdPartyContractsUpdatedEvent = { - allowed: boolean; -}; -export type AssetAddedEvent = { - assetId: bigint; - assetAddress: EthAddress; - assetGasLimit: bigint; -}; -export type AssetCapUpdatedEvent = { - assetId: bigint; - pendingCap: bigint; - dailyCap: bigint; -}; -export type AsyncDefiBridgeProcessedEvent = { - encodedBridgeCallData: bigint; - nonce: bigint; - totalInputValue: bigint; -}; -export type BridgeAddedEvent = { - bridgeAddressId: bigint; - bridgeAddress: EthAddress; - bridgeGasLimit: bigint; -}; -export type CappedUpdatedEvent = { - isCapped: boolean; -}; -export type DefiBridgeProcessedEvent = { - encodedBridgeCallData: bigint; - nonce: bigint; - totalInputValue: bigint; - totalOutputValueA: bigint; - totalOutputValueB: bigint; - result: boolean; - errorReason: Bytes.Bytes; -}; -export type DefiBridgeProxyUpdatedEvent = { - defiBridgeProxy: EthAddress; -}; -export type DelayBeforeEscapeHatchUpdatedEvent = { - delay: number; -}; -export type DepositEvent = { - assetId: bigint; - depositorAddress: EthAddress; - depositValue: bigint; -}; -export type InitializedEvent = { - version: number; -}; -export type OffchainDataEvent = { - rollupId: bigint; - chunk: bigint; - totalChunks: bigint; - sender: EthAddress; -}; -export type PausedEvent = { - account: EthAddress; -}; -export type RoleAdminChangedEvent = { - role: Bytes.Bytes32; - previousAdminRole: Bytes.Bytes32; - newAdminRole: Bytes.Bytes32; -}; -export type RoleGrantedEvent = { - role: Bytes.Bytes32; - account: EthAddress; - sender: EthAddress; -}; -export type RoleRevokedEvent = { - role: Bytes.Bytes32; - account: EthAddress; - sender: EthAddress; -}; -export type RollupProcessedEvent = { - rollupId: bigint; - nextExpectedDefiHashes: Bytes.Bytes32[]; - sender: EthAddress; -}; -export type RollupProviderUpdatedEvent = { - providerAddress: EthAddress; - valid: boolean; -}; -export type UnpausedEvent = { - account: EthAddress; -}; -export type VerifierUpdatedEvent = { - verifierAddress: EthAddress; -}; -export interface AllowThirdPartyContractsUpdatedEventLog extends EventLog { -} -export interface AssetAddedEventLog extends EventLog { -} -export interface AssetCapUpdatedEventLog extends EventLog { -} -export interface AsyncDefiBridgeProcessedEventLog extends EventLog { -} -export interface BridgeAddedEventLog extends EventLog { -} -export interface CappedUpdatedEventLog extends EventLog { -} -export interface DefiBridgeProcessedEventLog extends EventLog { -} -export interface DefiBridgeProxyUpdatedEventLog extends EventLog { -} -export interface DelayBeforeEscapeHatchUpdatedEventLog extends EventLog { -} -export interface DepositEventLog extends EventLog { -} -export interface InitializedEventLog extends EventLog { -} -export interface OffchainDataEventLog extends EventLog { -} -export interface PausedEventLog extends EventLog { -} -export interface RoleAdminChangedEventLog extends EventLog { -} -export interface RoleGrantedEventLog extends EventLog { -} -export interface RoleRevokedEventLog extends EventLog { -} -export interface RollupProcessedEventLog extends EventLog { -} -export interface RollupProviderUpdatedEventLog extends EventLog { -} -export interface UnpausedEventLog extends EventLog { -} -export interface VerifierUpdatedEventLog extends EventLog { -} -interface RollupProcessorContractEvents { - AllowThirdPartyContractsUpdated: AllowThirdPartyContractsUpdatedEvent; - AssetAdded: AssetAddedEvent; - AssetCapUpdated: AssetCapUpdatedEvent; - AsyncDefiBridgeProcessed: AsyncDefiBridgeProcessedEvent; - BridgeAdded: BridgeAddedEvent; - CappedUpdated: CappedUpdatedEvent; - DefiBridgeProcessed: DefiBridgeProcessedEvent; - DefiBridgeProxyUpdated: DefiBridgeProxyUpdatedEvent; - DelayBeforeEscapeHatchUpdated: DelayBeforeEscapeHatchUpdatedEvent; - Deposit: DepositEvent; - Initialized: InitializedEvent; - OffchainData: OffchainDataEvent; - Paused: PausedEvent; - RoleAdminChanged: RoleAdminChangedEvent; - RoleGranted: RoleGrantedEvent; - RoleRevoked: RoleRevokedEvent; - RollupProcessed: RollupProcessedEvent; - RollupProviderUpdated: RollupProviderUpdatedEvent; - Unpaused: UnpausedEvent; - VerifierUpdated: VerifierUpdatedEvent; -} -interface RollupProcessorContractEventLogs { - AllowThirdPartyContractsUpdated: AllowThirdPartyContractsUpdatedEventLog; - AssetAdded: AssetAddedEventLog; - AssetCapUpdated: AssetCapUpdatedEventLog; - AsyncDefiBridgeProcessed: AsyncDefiBridgeProcessedEventLog; - BridgeAdded: BridgeAddedEventLog; - CappedUpdated: CappedUpdatedEventLog; - DefiBridgeProcessed: DefiBridgeProcessedEventLog; - DefiBridgeProxyUpdated: DefiBridgeProxyUpdatedEventLog; - DelayBeforeEscapeHatchUpdated: DelayBeforeEscapeHatchUpdatedEventLog; - Deposit: DepositEventLog; - Initialized: InitializedEventLog; - OffchainData: OffchainDataEventLog; - Paused: PausedEventLog; - RoleAdminChanged: RoleAdminChangedEventLog; - RoleGranted: RoleGrantedEventLog; - RoleRevoked: RoleRevokedEventLog; - RollupProcessed: RollupProcessedEventLog; - RollupProviderUpdated: RollupProviderUpdatedEventLog; - Unpaused: UnpausedEventLog; - VerifierUpdated: VerifierUpdatedEventLog; -} -interface RollupProcessorContractTxEventLogs { - AllowThirdPartyContractsUpdated: AllowThirdPartyContractsUpdatedEventLog[]; - AssetAdded: AssetAddedEventLog[]; - AssetCapUpdated: AssetCapUpdatedEventLog[]; - AsyncDefiBridgeProcessed: AsyncDefiBridgeProcessedEventLog[]; - BridgeAdded: BridgeAddedEventLog[]; - CappedUpdated: CappedUpdatedEventLog[]; - DefiBridgeProcessed: DefiBridgeProcessedEventLog[]; - DefiBridgeProxyUpdated: DefiBridgeProxyUpdatedEventLog[]; - DelayBeforeEscapeHatchUpdated: DelayBeforeEscapeHatchUpdatedEventLog[]; - Deposit: DepositEventLog[]; - Initialized: InitializedEventLog[]; - OffchainData: OffchainDataEventLog[]; - Paused: PausedEventLog[]; - RoleAdminChanged: RoleAdminChangedEventLog[]; - RoleGranted: RoleGrantedEventLog[]; - RoleRevoked: RoleRevokedEventLog[]; - RollupProcessed: RollupProcessedEventLog[]; - RollupProviderUpdated: RollupProviderUpdatedEventLog[]; - Unpaused: UnpausedEventLog[]; - VerifierUpdated: VerifierUpdatedEventLog[]; -} -export interface RollupProcessorContractTransactionReceipt extends ContractTxReceipt { -} -interface RollupProcessorContractMethods { - DEFAULT_ADMIN_ROLE(): TxCall; - EMERGENCY_ROLE(): TxCall; - LISTER_ROLE(): TxCall; - OWNER_ROLE(): TxCall; - RESUME_ROLE(): TxCall; - allowThirdPartyContracts(): TxCall; - approveProof(_proofHash: Bytes.Bytes32): TxSend; - assetGasLimits(a0: bigint): TxCall; - asyncDefiInteractionHashes(a0: bigint): TxCall; - bridgeGasLimits(a0: bigint): TxCall; - caps(a0: bigint): TxCall<{ - "available": bigint; - 0: bigint; - "lastUpdatedTimestamp": number; - 1: number; - "pendingCap": number; - 2: number; - "dailyCap": number; - 3: number; - "precision": number; - 4: number; - }>; - defiBridgeProxy(): TxCall; - defiInteractionHashes(a0: bigint): TxCall; - delayBeforeEscapeHatch(): TxCall; - depositPendingFunds(_assetId: bigint, _amount: bigint, _owner: EthAddress, _proofHash: Bytes.Bytes32): TxSend; - depositProofApprovals(a0: EthAddress, a1: Bytes.Bytes32): TxCall; - escapeBlockLowerBound(): TxCall; - escapeBlockUpperBound(): TxCall; - ethPayments(a0: bigint): TxCall; - getAsyncDefiInteractionHashesLength(): TxCall; - getCapped(): TxCall; - getDataSize(): TxCall; - getDefiInteractionHashesLength(): TxCall; - getEscapeHatchStatus(): TxCall<{ - 0: boolean; - 1: bigint; - }>; - getImplementationVersion(): TxCall; - getPendingDefiInteractionHashesLength(): TxCall; - getRoleAdmin(role: Bytes.Bytes32): TxCall; - getSupportedAsset(_assetId: bigint): TxCall; - getSupportedAssetsLength(): TxCall; - getSupportedBridge(_bridgeAddressId: bigint): TxCall; - getSupportedBridgesLength(): TxCall; - grantRole(role: Bytes.Bytes32, account: EthAddress): TxSend; - hasRole(role: Bytes.Bytes32, account: EthAddress): TxCall; - initialize(): TxSend; - lastRollupTimeStamp(): TxCall; - offchainData(_rollupId: bigint, _chunk: bigint, _totalChunks: bigint, a3: Bytes.Bytes): TxSend; - pause(): TxSend; - paused(): TxCall; - pendingDefiInteractions(a0: bigint): TxCall<{ - "encodedBridgeCallData": bigint; - 0: bigint; - "totalInputValue": bigint; - 1: bigint; - }>; - prevDefiInteractionsHash(): TxCall; - processAsyncDefiInteraction(_interactionNonce: bigint): TxSend; - processRollup(a0: Bytes.Bytes, _signatures: Bytes.Bytes): TxSend; - receiveEthFromBridge(_interactionNonce: bigint): TxSend; - renounceRole(role: Bytes.Bytes32, account: EthAddress): TxSend; - revokeRole(role: Bytes.Bytes32, account: EthAddress): TxSend; - rollupProviders(a0: EthAddress): TxCall; - rollupStateHash(): TxCall; - setAllowThirdPartyContracts(_allowThirdPartyContracts: boolean): TxSend; - setAssetCap(_assetId: bigint, _pendingCap: number, _dailyCap: number, _precision: number): TxSend; - setCapped(_isCapped: boolean): TxSend; - setDefiBridgeProxy(_defiBridgeProxy: EthAddress): TxSend; - setDelayBeforeEscapeHatch(_delay: number): TxSend; - setRollupProvider(_provider: EthAddress, _valid: boolean): TxSend; - setSupportedAsset(_token: EthAddress, _gasLimit: bigint): TxSend; - setSupportedBridge(_bridge: EthAddress, _gasLimit: bigint): TxSend; - setVerifier(_verifier: EthAddress): TxSend; - supportsInterface(interfaceId: Bytes.Bytes4): TxCall; - unpause(): TxSend; - userPendingDeposits(a0: bigint, a1: EthAddress): TxCall; - verifier(): TxCall; -} -export interface RollupProcessorContractDefinition { - methods: RollupProcessorContractMethods; - events: RollupProcessorContractEvents; - eventLogs: RollupProcessorContractEventLogs; -} -export class RollupProcessorContract extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(_escapeBlockLowerBound: bigint, _escapeBlockUpperBound: bigint): TxSend { - return super.deployBytecode("0x6080604052600436106103975760003560e01c80638666c0a9116101dc578063c37c656d11610102578063dcefed85116100a0578063e58378bb1161006f578063e58378bb14610c72578063f21c69bb14610ca6578063f81cccbe14610cd3578063fb0ce18514610cf357600080fd5b8063dcefed8514610bd1578063deb26b9414610bfe578063e0d16c3214610c32578063e393635514610c5257600080fd5b8063cd12bf62116100dc578063cd12bf6214610b19578063d547741f14610b46578063d8ba363714610b66578063db1533aa14610b9a57600080fd5b8063c37c656d14610a21578063c4a7a35f14610ad4578063caa3455314610af957600080fd5b8063a2b096e41161017a578063b3a07b9811610149578063b3a07b98146109a4578063bc327e40146109c4578063be71f8a4146109e0578063c0fd22b714610a0c57600080fd5b8063a2b096e41461090e578063a33dc5e71461092e578063a8d1eae71461095b578063b045009c1461097057600080fd5b806391dfe78f116101b657806391dfe78f14610899578063999e3614146108b95780639b60ae2b146108da578063a217fddf146108f957600080fd5b80638666c0a9146107ea5780638afceb391461080a57806391d148541461085357600080fd5b806336ce0a92116102c1578063781e04321161025f5780637ff48afb1161022e5780637ff48afb1461078d5780638129fc1c146107a05780638188f468146107b55780638456cb59146107d557600080fd5b8063781e0432146106fa5780637ba3e7ae146107355780637baf71181461074b5780637d036b271461076b57600080fd5b80635ad1def31161029b5780635ad1def31461066b5780635c975abb1461069b57806360a8b18a146106ba5780636a0214a9146106da57600080fd5b806336ce0a92146105fe5780633f4ba83a146106365780635437988d1461064b57600080fd5b806320825443116103395780632b7ac3f3116103085780632b7ac3f31461056c5780632de03aa11461058a5780632f2ff15d146105be57806336568abe146105de57600080fd5b806320825443146104b557806320a23dd3146104d557806320df435914610507578063248a9ca31461053b57600080fd5b80630ceee68c116103755780630ceee68c146104215780630d698f6f1461045957806312a536231461047b5780631ab9c6031461049f57600080fd5b806301ffc9a71461039c57806302f6ccd4146103d157806303561119146103f4575b600080fd5b3480156103a857600080fd5b506103bc6103b736600461575f565b610d13565b60405190151581526020015b60405180910390f35b3480156103dd57600080fd5b506103e6610dac565b6040519081526020016103c8565b34801561040057600080fd5b506103e661040f3660046157a1565b600e6020526000908152604090205481565b34801561042d57600080fd5b50600a54610441906001600160a01b031681565b6040516001600160a01b0390911681526020016103c8565b34801561046557600080fd5b506104796104743660046157c8565b610df0565b005b6104796104893660046157a1565b6000908152600d60205260409020805434019055565b3480156104ab57600080fd5b506103e660095481565b3480156104c157600080fd5b506104796104d036600461582e565b610f39565b3480156104e157600080fd5b506011546104f29063ffffffff1681565b60405163ffffffff90911681526020016103c8565b34801561051357600080fd5b506103e67fbf233dd2aafeb4d50879c4aa5c81e96d92f6e6945c906a58f9f2d1c1631b4b2681565b34801561054757600080fd5b506103e66105563660046157a1565b6000908152600160208190526040909120015490565b34801561057857600080fd5b506002546001600160a01b0316610441565b34801561059657600080fd5b506103e67f2fc10cc8ae19568712f7a176fb4978616a610650813c9d05326c34abb62749c781565b3480156105ca57600080fd5b506104796105d93660046158a6565b610fad565b3480156105ea57600080fd5b506104796105f93660046158a6565b610fd8565b34801561060a57600080fd5b506103e66106193660046158a6565b600760209081526000928352604080842090915290825290205481565b34801561064257600080fd5b50610479611069565b34801561065757600080fd5b506104796106663660046158d2565b611186565b34801561067757600080fd5b506103bc6106863660046158d2565b600b6020526000908152604090205460ff1681565b3480156106a757600080fd5b50600254600160e81b900460ff166103bc565b3480156106c657600080fd5b506104416106d53660046157a1565b611297565b3480156106e657600080fd5b506104796106f5366004615901565b611343565b34801561070657600080fd5b506103bc61071536600461591c565b600860209081526000928352604080842090915290825290205460ff1681565b34801561074157600080fd5b506103e660105481565b34801561075757600080fd5b50600254600160c01b900461ffff166103e6565b34801561077757600080fd5b50600254600160a01b900463ffffffff166103e6565b61047961079b366004615946565b61142b565b3480156107ac57600080fd5b50610479611693565b3480156107c157600080fd5b506103bc6107d03660046157a1565b611ae9565b3480156107e157600080fd5b5061047961238f565b3480156107f657600080fd5b5061047961080536600461591c565b61249a565b34801561081657600080fd5b5061083e6108253660046157a1565b600c602052600090815260409020805460019091015482565b604080519283526020830191909152016103c8565b34801561085f57600080fd5b506103bc61086e3660046158a6565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156108a557600080fd5b506104796108b4366004615983565b6126c4565b3480156108c557600080fd5b50600a546103bc90600160a01b900460ff1681565b3480156108e657600080fd5b50600254600160f01b900460ff166103bc565b34801561090557600080fd5b506103e6600081565b34801561091a57600080fd5b506104796109293660046157c8565b6127ad565b34801561093a57600080fd5b506103e66109493660046157a1565b60066020526000908152604090205481565b34801561096757600080fd5b506004546103e6565b34801561097c57600080fd5b506103e67f000000000000000000000000000000000000000000000000000000000000087081565b3480156109b057600080fd5b506104796109bf3660046159ba565b612891565b3480156109d057600080fd5b50604051600281526020016103c8565b3480156109ec57600080fd5b506109f5612aa4565b6040805192151583526020830191909152016103c8565b348015610a1857600080fd5b506003546103e6565b348015610a2d57600080fd5b50610a93610a3c3660046157a1565b6012602052600090815260409020546001600160801b0381169063ffffffff7001000000000000000000000000000000008204811691600160a01b8104821691600160c01b8204169060ff600160e01b9091041685565b604080516001600160801b03909616865263ffffffff94851660208701529284169285019290925291909116606083015260ff16608082015260a0016103c8565b348015610ae057600080fd5b506011546104f290640100000000900463ffffffff1681565b348015610b0557600080fd5b50610479610b143660046158d2565b612be5565b348015610b2557600080fd5b506103e6610b343660046157a1565b60056020526000908152604090205481565b348015610b5257600080fd5b50610479610b613660046158a6565b612ce3565b348015610b7257600080fd5b506103e67f000000000000000000000000000000000000000000000000000000000000096081565b348015610ba657600080fd5b506002547a010000000000000000000000000000000000000000000000000000900461ffff166103e6565b348015610bdd57600080fd5b506103e6610bec3660046157a1565b600d6020526000908152604090205481565b348015610c0a57600080fd5b506103e67ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c81565b348015610c3e57600080fd5b50610441610c4d3660046157a1565b612d09565b348015610c5e57600080fd5b50610479610c6d3660046157a1565b612d43565b348015610c7e57600080fd5b506103e67fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e81565b348015610cb257600080fd5b506103e6610cc13660046157a1565b600f6020526000908152604090205481565b348015610cdf57600080fd5b50610479610cee366004615a0f565b612d8e565b348015610cff57600080fd5b50610479610d0e36600461591c565b612f23565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610da657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b600254600090610de79061ffff7a0100000000000000000000000000000000000000000000000000008204811691600160c01b900416615a91565b61ffff16905090565b7fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e610e1a8161312e565b600060028054600160e01b900460ff1690811115610e3a57610e3a615ab7565b14610e5857604051631e7b117d60e01b815260040160405180910390fd5b60028054819060ff60e01b1916600160e01b820217905550600254600160f01b900460ff1615158215151415610e8d57610f1a565b8115610ea9576011805463ffffffff19164263ffffffff161790555b60028054831515600160f01b027fff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091161790556040517f99895cad53cbbff374fbe3c76182ad42a6cb1c0c7306d3b6651786e7154ccbe690610f1190841515815260200190565b60405180910390a15b600280546000919060ff60e01b1916600160e01b835b02179055505050565b600254600160e81b900460ff1615610f6457604051632a6ab56360e21b815260040160405180910390fd5b60408051858152602081018590523381830152905186917fb92710e3fad9222f817fcd828bd1ce3612ad0cd1c8bd5f3a3f4b8d85c4444621919081900360600190a25050505050565b60008281526001602081905260409091200154610fc98161312e565b610fd3838361313b565b505050565b6001600160a01b038116331461105b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b61106582826131c2565b5050565b600254600160e81b900460ff166110ac576040517f395fbd0500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f2fc10cc8ae19568712f7a176fb4978616a610650813c9d05326c34abb62749c76110d68161312e565b600060028054600160e01b900460ff16908111156110f6576110f6615ab7565b1461111457604051631e7b117d60e01b815260040160405180910390fd5b600280547fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e11b1790556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa906020015b60405180910390a1506002805460ff60e01b19169055565b7fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e6111b08161312e565b600060028054600160e01b900460ff16908111156111d0576111d0615ab7565b146111ee57604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b1790556001600160a01b0382163b611229576040516310a0493960e11b815260040160405180910390fd5b6002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091556040517fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee32790600090a2600280546000919060ff60e01b1916600160e01b83610f30565b600081631fffffff8111156112bf57604051630104ef3360e21b815260040160405180910390fd5b826112cd576000915061133d565b600060036112dc600186615acd565b815481106112ec576112ec615ae4565b6000918252602090912001546001600160a01b031690508061133a576040517ffc3be2bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b91505b50919050565b7fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e61136d8161312e565b600060028054600160e01b900460ff169081111561138d5761138d615ab7565b146113ab57604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b179055601180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff1664010000000063ffffffff8516908102919091179091556040519081527f536948e5a71b8ffbb707a6903b99b812c8c291a711ed188e54d36505127d1c3590602001610f11565b600254600160e81b900460ff161561145657604051632a6ab56360e21b815260040160405180910390fd5b600060028054600160e01b900460ff169081111561147657611476615ab7565b1461149457604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b179055831580156114b55750823414155b156114ec576040517ff2be5ced00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83158015906114fa57503415155b15611531576040517fd08ba85b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61153c848385613245565b801561154b5761154b81612d43565b816001600160a01b0316847feaa18152488ce5959073c9c79c88ca90b3d96c00de1f118cfaad664c3dab06b98560405161158791815260200190565b60405180910390a383156116725760006115a085611297565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815233600482015230602482015290915084906001600160a01b0383169063dd62ed3e90604401602060405180830381865afa158015611608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162c9190615afa565b1015611664576040517f7bf8af0300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611670813330876135f6565b505b600280546000919060ff60e01b1916600160e01b835b021790555050505050565b6002600054610100900460ff161580156116b4575060005460ff8083169116105b6117265760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401611052565b806000806101000a81548160ff021916908360ff1602179055506001600060016101000a81548160ff02191690831515021790555060016002600001601e6101000a81548160ff02191690831515021790555042601160006101000a81548163ffffffff021916908363ffffffff1602179055506040518060a00160405280683635c9adc5dea000006001600160801b031681526020014263ffffffff168152602001600663ffffffff1681526020016103e863ffffffff168152602001601260ff168152506012600080815260200190815260200160002060008201518160000160006101000a8154816001600160801b0302191690836001600160801b0316021790555060208201518160000160106101000a81548163ffffffff021916908363ffffffff16021790555060408201518160000160146101000a81548163ffffffff021916908363ffffffff16021790555060608201518160000160186101000a81548163ffffffff021916908363ffffffff160217905550608082015181600001601c6101000a81548160ff021916908360ff1602179055509050506040518060a0016040528069d3c21bcecceda10000006001600160801b031681526020014263ffffffff16815260200161277463ffffffff168152602001620f424063ffffffff168152602001601260ff16815250601260006001815260200190815260200160002060008201518160000160006101000a8154816001600160801b0302191690836001600160801b0316021790555060208201518160000160106101000a81548163ffffffff021916908363ffffffff16021790555060408201518160000160146101000a81548163ffffffff021916908363ffffffff16021790555060608201518160000160186101000a81548163ffffffff021916908363ffffffff160217905550608082015181600001601c6101000a81548160ff021916908360ff1602179055509050507f2c87e4aece114a15933668e808bd3756196c2fb05a4902851081ed8584f8690e600060066103e8604051611a3c939291909283526020830191909152604082015260600190565b60405180910390a160408051600181526127746020820152620f42408183015290517f2c87e4aece114a15933668e808bd3756196c2fb05a4902851081ed8584f8690e9181900360600190a1600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b600254600090600160e81b900460ff1615611b1757604051632a6ab56360e21b815260040160405180910390fd5b600254600160e01b900460ff166001816002811115611b3857611b38615ab7565b1415611f3c576000838152600c60205260409020805460019091015481611b8b576040517f973e3ae300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611b9683613675565b9050600080600080611ba8858b6138e5565b60046000527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19a63ffffffff8c160154939750919550935091506001600160a01b031680611c21576040517fbb65988600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600c60008d815260200190815260200160002060000181905550600060405180606001604052808981526020018d81526020018860c0015167ffffffffffffffff1681525090506000806000846001600160a01b0316639b07d3428a8a8a8a89602001518a604001516040518763ffffffff1660e01b8152600401611cad96959493929190615b58565b6060604051808303816000875af1158015611ccc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf09190615bb2565b92509250925080611d26575050506020908101516000908152600c90915260408120989098555095975061133d95505050505050565b600082118015611d4b5750600086604001516003811115611d4957611d49615ab7565b145b15611d85576040517f26e939c600000000000000000000000000000000000000000000000000000000815260048101839052602401611052565b82158015611d91575081155b15611dc357611daa858a86600001518760200151613bcb565b611dbe858986600001518760200151613bcb565b611de3565b611dd38588858760200151613bcb565b611de38587848760200151613bcb565b6000845160208601516000851460008714161592506040518f81528160208201528260408201528660608201528560808201528360a08201526020600060c08360025afa505050507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001600051066002548060c01c6103ff168160d01c6103ff166102008183600101011115611e8357632c52558760e11b60005260046000fd5b50600081815260056020908152604080832095909555600190920160c090811b7ffffffffffffffc00ffffffffffffffffffffffffffffffffffffffffffffffff909416939093176002558882015189518551908152928301899052938201879052841515606083015260a0608083018190528201528f917f692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c910160405180910390a360019e505050505050505050505050505061133d565b6000816002811115611f5057611f50615ab7565b1415612376576002805460ff60e01b1916600160e01b1790556000838152600c6020526040902080546001919091015481611fb7576040517f973e3ae300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fc283613675565b9050600080600080611fd4858b6138e5565b60046000527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19a63ffffffff8c160154939750919550935091506001600160a01b03168061204d576040517fbb65988600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600c60008d815260200190815260200160002060000181905550600060405180606001604052808981526020018d81526020018860c0015167ffffffffffffffff1681525090506000806000846001600160a01b0316639b07d3428a8a8a8a89602001518a604001516040518763ffffffff1660e01b81526004016120d996959493929190615b58565b6060604051808303816000875af11580156120f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211c9190615bb2565b92509250925080612152575050506020908101516000908152600c90915260408120989098555095975061236495505050505050565b600082118015612177575060008660400151600381111561217557612175615ab7565b145b156121b1576040517f26e939c600000000000000000000000000000000000000000000000000000000815260048101839052602401611052565b821580156121bd575081155b156121ef576121d6858a86600001518760200151613bcb565b6121ea858986600001518760200151613bcb565b61220f565b6121ff8588858760200151613bcb565b61220f8587848760200151613bcb565b6000845160208601516000851460008714161592506040518f81528160208201528260408201528660608201528560808201528360a08201526020600060c08360025afa505050507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001600051066002548060c01c6103ff168160d01c6103ff1661020081836001010111156122af57632c52558760e11b60005260046000fd5b50600081815260056020908152604080832095909555600190920160c090811b7ffffffffffffffc00ffffffffffffffffffffffffffffffffffffffffffffffff909416939093176002558882015189518551908152928301899052938201879052841515606083015260a0608083018190528201528f917f692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c910160405180910390a360019e50505050505050505050505050505b6002805460ff60e01b1916905561133d565b604051631e7b117d60e01b815260040160405180910390fd5b600254600160e81b900460ff16156123ba57604051632a6ab56360e21b815260040160405180910390fd5b7fbf233dd2aafeb4d50879c4aa5c81e96d92f6e6945c906a58f9f2d1c1631b4b266123e48161312e565b600060028054600160e01b900460ff169081111561240457612404615ab7565b1461242257604051631e7b117d60e01b815260040160405180910390fd5b600280547fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff167d0102000000000000000000000000000000000000000000000000000000001790556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2589060200161116e565b600254600160e81b900460ff16156124c557604051632a6ab56360e21b815260040160405180910390fd5b3360009081527f65ab7acc1bb8390bd4d3ba8eb4987cf212c814cedeacf3ad4b0583b29d65f538602052604090205460ff1615801561250e5750600a54600160a01b900460ff16155b15612545576040517f11d74fb800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060028054600160e01b900460ff169081111561256557612565615ab7565b1461258357604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b1790556001600160a01b0382163b6125be576040516310a0493960e11b815260040160405180910390fd5b6188b88110806125d05750624c4b4081115b15612607576040517f037bbe6d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480546001810182557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03851690811790915590546000818152600f6020908152604091829020859055905184815291929183917f0e62be7fe47a9095143143f8ee61bab3ade27b661223fed33e16122ffe1f284d91015b60405180910390a350600280546000919060ff60e01b1916600160e01b83610f30565b7fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e6126ee8161312e565b600060028054600160e01b900460ff169081111561270e5761270e615ab7565b1461272c57604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b1790556001600160a01b0383166000818152600b6020908152604091829020805460ff1916861515908117909155825190815291517f46359ce9dbb6c7f9a375b44072210287916d3de725fc8927a8e762047e4a84249281900390910190a250506002805460ff60e01b1916905550565b7fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e6127d78161312e565b600060028054600160e01b900460ff16908111156127f7576127f7615ab7565b1461281557604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b179055600a8054831515600160a01b81027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179091556040519081527fad6b1fc8881be24fc1ad35119b136f0026a4496e6251980e325ddcf86dab394390602001610f11565b7ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6128bb8161312e565b600060028054600160e01b900460ff16908111156128db576128db615ab7565b146128f957604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b1790556040805160a081019091528061293b61292685600a615ccf565b6129369063ffffffff8816615cde565b613c86565b6001600160801b03908116825263ffffffff4281166020808501919091528882166040808601829052898416606080880182905260ff8b81166080998a015260008f8152601287528490208a5181548c8901518d8801518e8701519e909d0151909416600160e01b0260ff60e01b199d8b16600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff9d8c16600160a01b029d909d167fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff95909b167001000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1990921692909b169190911717919091169690961797909717979097169490941790925582518a815290810191909152908101929092527f2c87e4aece114a15933668e808bd3756196c2fb05a4902851081ed8584f8690e910160405180910390a150506002805460ff60e01b19169055505050565b60008043817f0000000000000000000000000000000000000000000000000000000000000870612af47f000000000000000000000000000000000000000000000000000000000000096084615d13565b1015905060008115612b8457601154612b1d9063ffffffff640100000000820481169116615d27565b421015612b2957600091505b612b537f000000000000000000000000000000000000000000000000000000000000096084615d13565b612b7d907f0000000000000000000000000000000000000000000000000000000000000960615acd565b9050612bdb565b612bae7f000000000000000000000000000000000000000000000000000000000000096084615d13565b612bd8907f0000000000000000000000000000000000000000000000000000000000000870615acd565b90505b9094909350915050565b7fb19546dff01e856fb3f010c267a7b1c60363cf8a4664e21cc89c26224620214e612c0f8161312e565b600060028054600160e01b900460ff1690811115612c2f57612c2f615ab7565b14612c4d57604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b1790556001600160a01b0382163b612c88576040516310a0493960e11b815260040160405180910390fd5b600a805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091556040519081527fc4fc5cbf094d63a6fb20dc7cb9b0236e7dba8c04667182ec259a00a74f95901890602001610f11565b60008281526001602081905260409091200154612cff8161312e565b610fd383836131c2565b60006004612d18600184615acd565b81548110612d2857612d28615ae4565b6000918252602090912001546001600160a01b031692915050565b600254600160e81b900460ff1615612d6e57604051632a6ab56360e21b815260040160405180910390fd5b336000526008602052604060002060205280600052600160406000205550565b600254600160e81b900460ff1615612db957604051632a6ab56360e21b815260040160405180910390fd5b600060028054600160e01b900460ff1690811115612dd957612dd9615ab7565b14612df757604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e01b179055336000908152600b602052604090205460ff1615612e4f57600254600160f01b900460ff1615612e4a576011805463ffffffff19164263ffffffff161790555b612e95565b6000612e59612aa4565b50905080612e93576040517f83633aab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b6000806000612ea2613ccd565b9250925092506000612eb384614069565b9050612efa8487878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250889250879150869050614088565b612f0484826140f2565b5050600280546000935090915060ff60e01b1916600160e01b83611688565b600254600160e81b900460ff1615612f4e57604051632a6ab56360e21b815260040160405180910390fd5b3360009081527f65ab7acc1bb8390bd4d3ba8eb4987cf212c814cedeacf3ad4b0583b29d65f538602052604090205460ff16158015612f975750600a54600160a01b900460ff16155b15612fce576040517f11d74fb800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060028054600160e01b900460ff1690811115612fee57612fee615ab7565b1461300c57604051631e7b117d60e01b815260040160405180910390fd5b6002805460ff60e01b1916600160e11b1790556001600160a01b0382163b613047576040516310a0493960e11b815260040160405180910390fd5b61d6d881108061305957506216e36081115b15613090576040517f11e80d6c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380546001810182557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b01805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03851690811790915590546000818152600e6020908152604091829020859055905184815291929183917f85ac039d1da307b778050ca29271ac915424bac011342c9452960f6679b18ff091016126a1565b6131388133614177565b50565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff166110655760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16156110655760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b82631fffffff81111561326b57604051630104ef3360e21b815260040160405180910390fd5b60008481526007602090815260408083206001600160a01b0387168452909152902054600254600160f01b900460ff16156135be576000858152601260209081526040808320815160a08101835290546001600160801b038116825263ffffffff7001000000000000000000000000000000008204811694830194909452600160a01b8104841692820192909252600160c01b8204909216606083015260ff600160e01b909104166080820181905290919061332890600a615ccf565b9050816040015163ffffffff1660001480613360575080826040015163ffffffff166133549190615cde565b61335e8685615d27565b115b15613397576040517ffb1837c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606082015163ffffffff166133d8576040517fd014828600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081836060015163ffffffff166133f09190615cde565b905060006134016201518083615d3f565b9050613426846020015163ffffffff164261341c9190615acd565b6129369083615cde565b84518590613435908390615d53565b6001600160801b0390811690915285511683101590506134645761345882613c86565b6001600160801b031684525b83516001600160801b03168711156134a8576040517fd014828600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134b187613c86565b845185906134c0908390615d75565b6001600160801b0390811690915263ffffffff428116602080890191825260008e81526012909152604090819020895181549351928b015160608c015160808d015160ff16600160e01b0260ff60e01b19918816600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff938916600160a01b02939093167fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff969098167001000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff199097169390981692909217949094179290921693909317919091171691909117905550505050505b6135c88382615d27565b60009586526007602090815260408088206001600160a01b0390971688529590529390942092909255505050565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152836004820152826024820152816044820152843b613645576310a0493960e11b60005260046000fd5b602060006064836000895af190506001600051163d151780821661366d573d6000803e3d6000fd5b505050505050565b604080516101c081018252600060208083018290526101a083019190915263ffffffff8416808352633fffffff9185901c821693830193909352603e84901c81166060830152605c84901c81166080830152607a84901c1660a082015267ffffffffffffffff60b884901c1660c08201526001603d84901c811660e0830152605b84901c8116610100830152607984901c8116610120830152609784901c8116610140830152609884901c81168114610160830152609984901c81168114610180830152909160049161374791615acd565b8154811061375757613757615ae4565b60009182526020808320909101546001600160a01b03168382015282518252600f905260409020546101a082015261016081015115801561379c575060008160600151115b156137d3576040517f3448066300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8061018001511580156137ea575060008160a00151115b15613821576040517f3448066300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806101600151801561383a575080606001518160400151145b156138795780604001516040517f760558e800000000000000000000000000000000000000000000000000000000815260040161105291815260200190565b600081610180015180156138905750816101400151155b90508080156138a657508160a001518260800151145b1561133d5781608001516040517ff23e3f9500000000000000000000000000000000000000000000000000000000815260040161105291815260200190565b61390660408051606081018252600080825260208201819052909182015290565b61392760408051606081018252600080825260208201819052909182015290565b61394860408051606081018252600080825260208201819052909182015290565b61396960408051606081018252600080825260208201819052909182015290565b8560e001511561399c57632000000086604001516139879190615acd565b845260006020850152600360408501526139fa565b6040860180518552516139ae90611297565b6001600160a01b031660208501819052156139ca5760026139cd565b60015b846040019060038111156139e3576139e3615ab7565b908160038111156139f6576139f6615ab7565b9052505b85610120015115613a1b578482526000602083015260036040830152613a79565b608086018051835251613a2d90611297565b6001600160a01b03166020830181905215613a49576002613a4c565b60015b82604001906003811115613a6257613a62615ab7565b90816003811115613a7557613a75615ab7565b9052505b85610100015115613ac35763200000008660600151613a989190615acd565b8352600060208401526040830160035b90816003811115613abb57613abb615ab7565b905250613b27565b85610160015115613b1557606086018051845251613ae090611297565b6001600160a01b03166020840181905215613afc576002613aff565b60015b83604001906003811115613aa857613aa8615ab7565b60008084526020840181905260408401525b85610140015115613b5e57848152600060208201526040810160035b90816003811115613b5657613b56615ab7565b905250613bc2565b85610180015115613bb05760a086018051825251613b7b90611297565b6001600160a01b03166020820181905215613b97576002613b9a565b60015b81604001906003811115613b4357613b43615ab7565b60008082526020820181905260408201525b92959194509250565b81613bd557613c80565b600183604001516003811115613bed57613bed615ab7565b1415613c4f576000818152600d6020526040902054821115613c3b576040517fcbbf6eca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600d6020526040812055613c80565b600283604001516003811115613c6757613c67615ab7565b1415613c80576020830151613c7e818630866135f6565b505b50505050565b60006001600160801b03821115613cc9576040517f7a781de100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5090565b6040805161010080820183526141ec82526141f360208084018290528385019190915261421e606084018190526080840181905260a0840181905260c084015261423360e084015283516111c46004359081013560448201359081046111c883013563ffffffff908116828104808402821415019092029096028481016111e0019098526111c08881018086529498919760009795968a0195602486019589948594615755949391926111cc013590911690888a376111c098909801976111a9888101988a97509091010193505b86841115613dd15760078735168089528060051b830151935050613dc387898563ffffffff16565b965061010088019750613d9b565b505050506111c088810151604051600092828604808c048082028d1415019384900393909261010084029260043560240182376111c08101905060208202810191505b81811015613e635760206000848960025afa613e2f57600080fd5b6000517f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000019006815295820195602001613e14565b8415613fe057600092508360208114613eaf5760108114613ed75760408114613eff5760018114613f275760028114613f4f5760048114613f775760088114613f9f5760019650613fc3565b7f0df0e06ab8a02ce2ff08babd7144ab23ca2e99ddf318080cf88602eeb8913d449350613fc3565b7f1c52c159b4dae66c3dcf33b44d4d61ead6bc4d260f882ac6ba34dccf78892ca49350613fc3565b7f1f83672815ac9b3ca31732d641784035834e96b269eaf6a2e759bf4fcc8e5bfd9350613fc3565b7f22dd983f8337d97d56071f7986209ab2ee6039a422242e89126701c6ee005af09350613fc3565b7f076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f365609350613fc3565b7f2f0c70a5bf5460465e9902f9c96be324e8064e762a5de52589fdb97cbce3c6ee9350613fc3565b7f240ed0de145447ff0ceff2aa477f43e0e2ed7f3543ee3d8832f158ec76b183a993505b5060208502820191505b81811015613fe057828152602001613fcd565b6040519450602060008683038760025afa613ffa57600080fd5b50505050507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001600051069650801561405e576040517f3259ec1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050909192565b6111a08101516001600160a01b0381111561408357600080fd5b919050565b60006140948684614267565b90506140a1868587614338565b60006140ad8784614400565b9050817f14054a15b39bfd65ec00fc6d15c7e5f9cbc1dc6f452cbefa359b4da61ad89fb682336040516140e1929190615d9d565b60405180910390a250505050505050565b60005b6010811015610fd3576000614111848360200201610b80015190565b9050801561416e576000614125858461493e565b90508061413e57600080600080858861c350f15061416c565b600061414982611297565b905061416a818685600e60008781526020019081526020016000205461495a565b505b505b506001016140f5565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16611065576141aa816149aa565b6141b58360206149bc565b6040516020016141c6929190615e1d565b60408051601f198184030181529082905262461bcd60e51b825261105291600401615e9e565b5060010190565b600060a0602084016020840137601460c0840160cc840137600460d4840160fc840137505060b90190565b60006080602084016020840137505060810190565b60006040517fd0426f7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405160009063ffffffff600480356111cc810135929092168083016111ec01939290910135037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee38019060ac815360316001820153608c6002820153605d600382015360406004820152846024820152816044820152818360648301376001600160a01b03600254169250823b614309576310a0493960e11b60005260046000fd5b6000806064840183865afa9250505080614327573d6000803e3d6000fd5b5061433183614be5565b9392505050565b60006111e08085019061010085028601015b8082101561366d5760a082015180156143f357825160e084015160c085015160018314156143db5761010086206001600160a01b038216600090815260086020908152604080832084845290915290205460ff166143ce5788880180516060825260006143b684614d98565b90506143c3818487614eb1565b509052606097909701965b6143d9838387614ffd565b505b82600214156143ef576143ef84828461507e565b5050505b610100830192505061434a565b606060008061441185611180015190565b9050601054811461445c576010546040517f88011dd6000000000000000000000000000000000000000000000000000000008152611052918391600401918252602082015260400190565b6000614466615101565b90935090506144758184615acd565b600280547ffffffffffc00ffffffffffffffffffffffffffffffffffffffffffffffffffff1660d083901b1790556020878101519194506000935091506144bc9190615cde565b6040805160808082018352600080835260208301819052828401819052606090920182905282519081019092529192506101808701915b6020811015614870578251806145095750614870565b61040084015180614546576040517fb246041300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061455183613675565b9050600080600080614563858c6138e5565b93509350935093506040517f4bd947a800000000000000000000000000000000000000000000000000000000815260048101905060208601518082525084516020820152602085015160408201526040850151606082015283516080820152602084015160a0820152604084015160c0820152825160e082015260208301516101008201526040830151610120820152815161014082015260208201516101608201526040820151610180820152866101a08201528b6101c082015260c0860151806101e083015250600d6102008201528e610220820152600a54803b614655576310a0493960e11b60005260046000fd5b60008061024460048503846101a08c0151f490503d6000833e80600181146146955760008c52600060208d0152600060408d0152600060608d01526146b5565b82518c52602083015160208d0152604083015160408d0152600160608d01525b5050508461018001516146ca57600060208a01525b60408901516001811461480a576040518781528a51602082015260208b0151604082015260608b0151606082015260a0608082015260608b01511561473857600060a08201528c897f692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c60c084a35b60608b0151614792573d60a08201523d602081066020038115150281600060c085013e60008260c0018401528e8b7f692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c83850160c00186a350505b8881528c60208201528760408201528a51606082015260208b0151608082015260608b015160a08201526020600060c08360025afa50507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001600051068d6000526006602052806040600020555060018d019c50614851565b6040518781528c897f38ce48f4c2f3454bcf130721f25a4262b2ff2c8e36af937b30edf01ba481eb1d602084a3508b600052600c6020526040600020888155876001820155505b5060018b019a5060208a019950876001019750505050505050506144f3565b506002548060c01c6103ff166103ff86820111801561489a57632c52558760e11b60005260046000fd5b506040516006602052600560605260005b828110156148cf5787810160009081526040828152808020549120556001016148ab565b506040527ffffffffffffffc00ffffffffffffffffffffffffffffffffffffffffffffffff90860160d01b167ffffffffffc00fc00ffffffffffffffffffffffffffffffffffffffffffffffff9091161760025560008061492e615123565b6010559998505050505050505050565b602081028201610980015163ffffffff811115610da657600080fd5b5a81156149645750805b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815284600482015283602482015260008060448360008a87f150505050505050565b6060610da66001600160a01b03831660145b606060006149cb836002615cde565b6149d6906002615d27565b67ffffffffffffffff8111156149ee576149ee615ed1565b6040519080825280601f01601f191660200182016040528015614a18576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110614a4f57614a4f615ae4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110614ab257614ab2615ae4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000614aee846002615cde565b614af9906001615d27565b90505b6001811115614b96577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110614b3a57614b3a615ae4565b1a60f81b828281518110614b5057614b50615ae4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93614b8f81615ee7565b9050614afc565b5083156143315760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611052565b600080600080600080614bf7876151ff565b945094509450945094506009548414614c46576040517f34fddf400000000000000000000000000000000000000000000000000000000081526004810185905260248101849052604401611052565b60025463ffffffff600160a01b90910481169083168181614c6957614c69615cfd565b0663ffffffff1660001415614cd2578063ffffffff168263ffffffff1614614ccd576040517f7861e6c600000000000000000000000000000000000000000000000000000000815263ffffffff808416600483015282166024820152604401611052565b614d4c565b60008363ffffffff168263ffffffff1681614cef57614cef615cfd565b068483010363ffffffff169050808363ffffffff1614614d4a576040517f7861e6c600000000000000000000000000000000000000000000000000000000815263ffffffff8416600482015260248101829052604401611052565b505b506009929092556002805463ffffffff9390920192909216600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff9091161790555092915050565b600080614da4836152a8565b90506040517f19457468657265756d205369676e6564204d6573736167653a0a32313000000060208201527f5369676e696e672074686973206d6573736167652077696c6c20616c6c6f7720603d8201527f796f75722070656e64696e672066756e647320746f206265207370656e742069605d8201527f6e20417a746563207472616e73616374696f6e3a0a0a30780000000000000000607d82015260208201516095820152604082015160b58201527f0a0a494d504f5254414e543a204f6e6c79207369676e20746865206d6573736160d58201527f676520696620796f752074727573742074686520636c69656e7400000000000060f582015260ef602082012092505050919050565b6000806001600160a01b038316614ef4576040517fd57e351000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8351858552606085015160408601518060608801526020870151604088015281602088015260208760808960015afa601c8314601b84141760608514167f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a183101616945050508451861460008114614f6b57614f70565b855192505b508452801519919091169081614fb2576040517f8a3e28aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826001600160a01b0316816001600160a01b031614613c7e576040517fa3402a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82631fffffff81111561502357604051630104ef3360e21b815260040160405180910390fd5b60008481526007602090815260408083209091528482529020805483810390915582118015613c7e576040517f8e8af4f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166150be576040517f6df19fea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806150d5576000806000808686617530f150505050565b60006150e082611297565b9050613c80818486600e60008781526020019081526020016000205461495a565b6002546103ff60d082901c16908190602082111561511e57602091505b509091565b60606000806000615132615101565b909250905060006151438284615acd565b90506040519450602085016020610400018601604052828652600660205260005b83811015615188578281016000908152604090205460208202830152600101615164565b5b60208110156151c2577f2d25a1e3a51eb293004c4b56abe12ed0da6bca2b4a21936752a85d102593c1b460208202830152600101615189565b50602060006104008360025afa50507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000016000510693505050509091565b604081015160608201516000918291829160011b906020860163ffffffff808411908311171561522e57600080fd5b805195506040518681526060820151602082015260a0820151604082015260e08201516060820152610120820151608082015260a0812095506001870181526080820151602082015260c082015160408201526101008201516060820152610140820151608082015260a081209450505091939590929450565b606081615310576040519050604081527f303030303030303030303030303030303030303030303030303030303030303060208201527f3030303030303030303030303030303030303030303030303030303030303030604082015260608101604052919050565b506040517f3030303130323033303430353036303730383039306130623063306430653066607e8201527f3130313131323133313431353136313731383139316131623163316431653166609e8201527f323032313232323332343235323632373238323932613262326332643265326660be8201527f333033313332333333343335333633373338333933613362336333643365336660de8201527f343034313432343334343435343634373438343934613462346334643465346660fe8201527f353035313532353335343535353635373538353935613562356335643565356661011e8201527f363036313632363336343635363636373638363936613662366336643665366661013e8201527f373037313732373337343735373637373738373937613762376337643765376661015e8201527f383038313832383338343835383638373838383938613862386338643865386661017e8201527f393039313932393339343935393639373938393939613962396339643965396661019e8201527f61306131613261336134613561366137613861396161616261636164616561666101be8201527f62306231623262336234623562366237623862396261626262636264626562666101de8201527f63306331633263336334633563366337633863396361636263636364636563666101fe8201527f643064316432643364346435643664376438643964616462646364646465646661021e8201527f653065316532653365346535653665376538653965616562656365646565656661023e8201527f663066316632663366346635663666376638663966616662666366646665666661025e820152606081018260408352600181901b6101fe908116830151601e52600782901c8116830151601c52600f82901c8116830151601a52601782901c8116830151601852601f82901c8116830151601652602782901c8116830151601452602f82901c8116830151601252603782901c8116830151601052603f82901c8116830151600e52604782901c8116830151600c52604f82901c8116830151600a52605782901c8116830151600852605f82901c8116830151600652606782901c8116830151600452606f82901c8116830151600252607782901c16820151600052601e51604084015260801c61573f82826101fe600182901b8116830151601e52600782901c8116830151601c52600f82901c8116830151601a52601782901c8116830151601852601f82901c8116830151601652602782901c8116830151601452602f82901c8116830151601252603782901c8116830151601052603f82901c8116830151600e52604782901c8116830151600c52604f82901c8116830151600a52605782901c8116830151600852605f82901c8116830151600652606782901c8116830151600452606f82901c811683015160025260779190911c160151600052565b5050601e51602082015260608101604052919050565b61575d615efe565b565b60006020828403121561577157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461433157600080fd5b6000602082840312156157b357600080fd5b5035919050565b801515811461313857600080fd5b6000602082840312156157da57600080fd5b8135614331816157ba565b60008083601f8401126157f757600080fd5b50813567ffffffffffffffff81111561580f57600080fd5b60208301915083602082850101111561582757600080fd5b9250929050565b60008060008060006080868803121561584657600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff81111561587257600080fd5b61587e888289016157e5565b969995985093965092949392505050565b80356001600160a01b038116811461408357600080fd5b600080604083850312156158b957600080fd5b823591506158c96020840161588f565b90509250929050565b6000602082840312156158e457600080fd5b6143318261588f565b803563ffffffff8116811461408357600080fd5b60006020828403121561591357600080fd5b614331826158ed565b6000806040838503121561592f57600080fd5b6159388361588f565b946020939093013593505050565b6000806000806080858703121561595c57600080fd5b84359350602085013592506159736040860161588f565b9396929550929360600135925050565b6000806040838503121561599657600080fd5b61599f8361588f565b915060208301356159af816157ba565b809150509250929050565b600080600080608085870312156159d057600080fd5b843593506159e0602086016158ed565b92506159ee604086016158ed565b9150606085013560ff81168114615a0457600080fd5b939692955090935050565b60008060008060408587031215615a2557600080fd5b843567ffffffffffffffff80821115615a3d57600080fd5b615a49888389016157e5565b90965094506020870135915080821115615a6257600080fd5b50615a6f878288016157e5565b95989497509550505050565b634e487b7160e01b600052601160045260246000fd5b600061ffff808316818516808303821115615aae57615aae615a7b565b01949350505050565b634e487b7160e01b600052602160045260246000fd5b600082821015615adf57615adf615a7b565b500390565b634e487b7160e01b600052603260045260246000fd5b600060208284031215615b0c57600080fd5b5051919050565b805182526001600160a01b036020820151166020830152604081015160048110615b4d57634e487b7160e01b600052602160045260246000fd5b806040840152505050565b6101c08101615b678289615b13565b615b746060830188615b13565b615b8160c0830187615b13565b615b8f610120830186615b13565b8361018083015267ffffffffffffffff83166101a0830152979650505050505050565b600080600060608486031215615bc757600080fd5b83519250602084015191506040840151615be0816157ba565b809150509250925092565b600181815b80851115615c26578160001904821115615c0c57615c0c615a7b565b80851615615c1957918102915b93841c9390800290615bf0565b509250929050565b600082615c3d57506001610da6565b81615c4a57506000610da6565b8160018114615c605760028114615c6a57615c86565b6001915050610da6565b60ff841115615c7b57615c7b615a7b565b50506001821b610da6565b5060208310610133831016604e8410600b8410161715615ca9575081810a610da6565b615cb38383615beb565b8060001904821115615cc757615cc7615a7b565b029392505050565b600061433160ff841683615c2e565b6000816000190483118215151615615cf857615cf8615a7b565b500290565b634e487b7160e01b600052601260045260246000fd5b600082615d2257615d22615cfd565b500690565b60008219821115615d3a57615d3a615a7b565b500190565b600082615d4e57615d4e615cfd565b500490565b60006001600160801b03808316818516808303821115615aae57615aae615a7b565b60006001600160801b0383811690831681811015615d9557615d95615a7b565b039392505050565b604080825283519082018190526000906020906060840190828701845b82811015615dd657815184529284019290840190600101615dba565b5050506001600160a01b039490941692019190915250919050565b60005b83811015615e0c578181015183820152602001615df4565b83811115613c805750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615e55816017850160208801615df1565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615e92816028840160208801615df1565b01602801949350505050565b6020815260008251806020840152615ebd816040850160208701615df1565b601f01601f19169190910160400192915050565b634e487b7160e01b600052604160045260246000fd5b600081615ef657615ef6615a7b565b506000190190565b634e487b7160e01b600052605160045260246000fdfea26469706673582212204986047a3c1dc740c0f7b2da538464da5d8465856c4b6d0dec03c81aa8d6df1564736f6c634300080a0033", _escapeBlockLowerBound, _escapeBlockUpperBound) as any; - } -} -export var RollupProcessorContractAbi = abi; diff --git a/yarn-project/ethereum.js/example/src/contracts/RollupProcessorContractAbi.ts b/yarn-project/ethereum.js/example/src/contracts/RollupProcessorContractAbi.ts deleted file mode 100644 index cf36e71d4d0..00000000000 --- a/yarn-project/ethereum.js/example/src/contracts/RollupProcessorContractAbi.ts +++ /dev/null @@ -1,1682 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - "inputs": [ - { - "internalType": "uint256", - "name": "_escapeBlockLowerBound", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_escapeBlockUpperBound", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "ARRAY_OVERFLOW", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "inputAssetId", - "type": "uint256" - } - ], - "name": "BRIDGE_WITH_IDENTICAL_INPUT_ASSETS", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "outputAssetId", - "type": "uint256" - } - ], - "name": "BRIDGE_WITH_IDENTICAL_OUTPUT_ASSETS", - "type": "error" - }, - { - "inputs": [], - "name": "DAILY_CAP_SURPASSED", - "type": "error" - }, - { - "inputs": [], - "name": "DEPOSIT_TOKENS_WRONG_PAYMENT_TYPE", - "type": "error" - }, - { - "inputs": [], - "name": "ENCODING_BYTE_INVALID", - "type": "error" - }, - { - "inputs": [], - "name": "INCONSISTENT_BRIDGE_CALL_DATA", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "providedIndex", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expectedIndex", - "type": "uint256" - } - ], - "name": "INCORRECT_DATA_START_INDEX", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "providedDefiInteractionHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "expectedDefiInteractionHash", - "type": "bytes32" - } - ], - "name": "INCORRECT_PREVIOUS_DEFI_INTERACTION_HASH", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "oldStateHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "newStateHash", - "type": "bytes32" - } - ], - "name": "INCORRECT_STATE_HASH", - "type": "error" - }, - { - "inputs": [], - "name": "INSUFFICIENT_DEPOSIT", - "type": "error" - }, - { - "inputs": [], - "name": "INSUFFICIENT_ETH_PAYMENT", - "type": "error" - }, - { - "inputs": [], - "name": "INSUFFICIENT_TOKEN_APPROVAL", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ADDRESS_NO_CODE", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ASSET_ADDRESS", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ASSET_GAS", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ASSET_ID", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_BRIDGE_ADDRESS", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_BRIDGE_CALL_DATA", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_BRIDGE_GAS", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ESCAPE_BOUNDS", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_PROVIDER", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ROLLUP_TOPOLOGY", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_SIGNATURE", - "type": "error" - }, - { - "inputs": [], - "name": "LOCKED_NO_REENTER", - "type": "error" - }, - { - "inputs": [], - "name": "MSG_VALUE_WRONG_AMOUNT", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "outputValue", - "type": "uint256" - } - ], - "name": "NONZERO_OUTPUT_VALUE_ON_NOT_USED_ASSET", - "type": "error" - }, - { - "inputs": [], - "name": "NOT_PAUSED", - "type": "error" - }, - { - "inputs": [], - "name": "PAUSED", - "type": "error" - }, - { - "inputs": [], - "name": "PENDING_CAP_SURPASSED", - "type": "error" - }, - { - "inputs": [], - "name": "PROOF_VERIFICATION_FAILED", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "PUBLIC_INPUTS_HASH_VERIFICATION_FAILED", - "type": "error" - }, - { - "inputs": [], - "name": "SAFE_CAST_OVERFLOW", - "type": "error" - }, - { - "inputs": [], - "name": "SIGNATURE_ADDRESS_IS_ZERO", - "type": "error" - }, - { - "inputs": [], - "name": "SIGNATURE_RECOVERY_FAILED", - "type": "error" - }, - { - "inputs": [], - "name": "THIRD_PARTY_CONTRACTS_FLAG_NOT_SET", - "type": "error" - }, - { - "inputs": [], - "name": "WITHDRAW_TO_ZERO_ADDRESS", - "type": "error" - }, - { - "inputs": [], - "name": "ZERO_TOTAL_INPUT_VALUE", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "allowed", - "type": "bool" - } - ], - "name": "AllowThirdPartyContractsUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "assetId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "assetAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "assetGasLimit", - "type": "uint256" - } - ], - "name": "AssetAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "assetId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "pendingCap", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "dailyCap", - "type": "uint256" - } - ], - "name": "AssetCapUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "encodedBridgeCallData", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalInputValue", - "type": "uint256" - } - ], - "name": "AsyncDefiBridgeProcessed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "bridgeAddressId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "bridgeAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bridgeGasLimit", - "type": "uint256" - } - ], - "name": "BridgeAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "isCapped", - "type": "bool" - } - ], - "name": "CappedUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "encodedBridgeCallData", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalInputValue", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalOutputValueA", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalOutputValueB", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bool", - "name": "result", - "type": "bool" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "errorReason", - "type": "bytes" - } - ], - "name": "DefiBridgeProcessed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "defiBridgeProxy", - "type": "address" - } - ], - "name": "DefiBridgeProxyUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint32", - "name": "delay", - "type": "uint32" - } - ], - "name": "DelayBeforeEscapeHatchUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "assetId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "depositorAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "depositValue", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "rollupId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "chunk", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalChunks", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "OffchainData", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "rollupId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32[]", - "name": "nextExpectedDefiHashes", - "type": "bytes32[]" - }, - { - "indexed": false, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RollupProcessed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "providerAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "valid", - "type": "bool" - } - ], - "name": "RollupProviderUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "verifierAddress", - "type": "address" - } - ], - "name": "VerifierUpdated", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "EMERGENCY_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "LISTER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "OWNER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "RESUME_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "allowThirdPartyContracts", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_proofHash", - "type": "bytes32" - } - ], - "name": "approveProof", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "assetGasLimits", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "asyncDefiInteractionHashes", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "bridgeGasLimits", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "caps", - "outputs": [ - { - "internalType": "uint128", - "name": "available", - "type": "uint128" - }, - { - "internalType": "uint32", - "name": "lastUpdatedTimestamp", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "pendingCap", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "dailyCap", - "type": "uint32" - }, - { - "internalType": "uint8", - "name": "precision", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "defiBridgeProxy", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "defiInteractionHashes", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "delayBeforeEscapeHatch", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_assetId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "_proofHash", - "type": "bytes32" - } - ], - "name": "depositPendingFunds", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "depositProofApprovals", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "escapeBlockLowerBound", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "escapeBlockUpperBound", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "ethPayments", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getAsyncDefiInteractionHashesLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCapped", - "outputs": [ - { - "internalType": "bool", - "name": "capped", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getDataSize", - "outputs": [ - { - "internalType": "uint256", - "name": "dataSize", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getDefiInteractionHashesLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEscapeHatchStatus", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getImplementationVersion", - "outputs": [ - { - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getPendingDefiInteractionHashesLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_assetId", - "type": "uint256" - } - ], - "name": "getSupportedAsset", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getSupportedAssetsLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_bridgeAddressId", - "type": "uint256" - } - ], - "name": "getSupportedBridge", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getSupportedBridgesLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "lastRollupTimeStamp", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_rollupId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_chunk", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_totalChunks", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "offchainData", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "isPaused", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "pendingDefiInteractions", - "outputs": [ - { - "internalType": "uint256", - "name": "encodedBridgeCallData", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalInputValue", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "prevDefiInteractionsHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_interactionNonce", - "type": "uint256" - } - ], - "name": "processAsyncDefiInteraction", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "_signatures", - "type": "bytes" - } - ], - "name": "processRollup", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_interactionNonce", - "type": "uint256" - } - ], - "name": "receiveEthFromBridge", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "rollupProviders", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rollupStateHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_allowThirdPartyContracts", - "type": "bool" - } - ], - "name": "setAllowThirdPartyContracts", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_assetId", - "type": "uint256" - }, - { - "internalType": "uint32", - "name": "_pendingCap", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "_dailyCap", - "type": "uint32" - }, - { - "internalType": "uint8", - "name": "_precision", - "type": "uint8" - } - ], - "name": "setAssetCap", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_isCapped", - "type": "bool" - } - ], - "name": "setCapped", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_defiBridgeProxy", - "type": "address" - } - ], - "name": "setDefiBridgeProxy", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "_delay", - "type": "uint32" - } - ], - "name": "setDelayBeforeEscapeHatch", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_provider", - "type": "address" - }, - { - "internalType": "bool", - "name": "_valid", - "type": "bool" - } - ], - "name": "setRollupProvider", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_gasLimit", - "type": "uint256" - } - ], - "name": "setSupportedAsset", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_bridge", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_gasLimit", - "type": "uint256" - } - ], - "name": "setSupportedBridge", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_verifier", - "type": "address" - } - ], - "name": "setVerifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "userPendingDeposits", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "verifier", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -]); \ No newline at end of file diff --git a/yarn-project/ethereum.js/example/src/create_permit_data.ts b/yarn-project/ethereum.js/example/src/create_permit_data.ts deleted file mode 100644 index 1d704c4a16a..00000000000 --- a/yarn-project/ethereum.js/example/src/create_permit_data.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { TypedData } from '@aztec/ethereum.js/eth_typed_data'; - -/** - * Generates the TypedData for performing a permit. - */ -export function createPermitData( - name: string, - owner: EthAddress, - spender: EthAddress, - value: bigint, - nonce: bigint, - deadline: bigint, - verifyingContract: EthAddress, - chainId: number, - version = '1', -): TypedData { - const types = { - EIP712Domain: [ - { name: 'name', type: 'string' }, - { name: 'version', type: 'string' }, - { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' }, - ], - Permit: [ - { - name: 'owner', - type: 'address', - }, - { - name: 'spender', - type: 'address', - }, - { - name: 'value', - type: 'uint256', - }, - { - name: 'nonce', - type: 'uint256', - }, - { - name: 'deadline', - type: 'uint256', - }, - ], - }; - const domain = { - name, - version, - chainId: chainId, - verifyingContract: verifyingContract.toString(), - }; - const message = { - owner: owner.toString(), - spender: spender.toString(), - value: value.toString(), - nonce: nonce.toString(), - deadline: deadline.toString(), - }; - return { types, domain, message, primaryType: 'Permit' }; -} diff --git a/yarn-project/ethereum.js/example/src/index.ts b/yarn-project/ethereum.js/example/src/index.ts deleted file mode 100644 index dd67cb60963..00000000000 --- a/yarn-project/ethereum.js/example/src/index.ts +++ /dev/null @@ -1,214 +0,0 @@ -import sourceMapSupport from 'source-map-support'; -sourceMapSupport.install(); -import { EthAddress } from '@aztec/foundation/eslint-legacy'; -import { WalletProvider } from '@aztec/ethereum.js/provider'; -import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; -import { fromBaseUnits, toBaseUnits } from '@aztec/ethereum.js/units'; -import { ERC20Permit } from './contracts/ERC20Permit.js'; -import { EthAccount } from '@aztec/ethereum.js/eth_account'; -import { EthWallet } from '@aztec/ethereum.js/eth_wallet'; -import { Contract, ContractAbi } from '@aztec/ethereum.js/contract'; -import { RollupProcessorContract } from './contracts/RollupProcessorContract.js'; -import { DaiContract } from './contracts/DaiContract.js'; -import { ERC20Mintable } from './contracts/ERC20Mintable.js'; -import { createPermitData } from './create_permit_data.js'; - -/** - * Launch forked local chain e.g: `anvil -f https://mainnet.infura.io/v3/` - * Set ETHEREUM_HOST to e.g: `http://127.0.0.1:8545`. - */ -const { ETHEREUM_HOST } = process.env; - -// Contract addresses. -const rollupProcessorAddr = EthAddress.fromString('0xFF1F2B4ADb9dF6FC8eAFecDcbF96A2B351680455'); -const daiAddr = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F'); - -/** - * A few examples of how to use ethereum.js. - * The imported contracts are created by gen_def and provide complete type safety on methods, logs, receipts etc. - * See `contracts.json` in project root, and run `yarn contract_gen_def` to rebuild contract definitions. - */ -async function main() { - if (!ETHEREUM_HOST) { - throw new Error('No ETHEREUM_HOST provided.'); - } - - // We could allow the ETHEREUM_HOST to do the signing if the host is something like anvil. - // However, that's not very realistic, most hosts don't have accounts on them. - // We construct a local wallet using the same mnemonic that anvil uses, and create a provider from it. - // This means all signing happens locally before being sent to the ETHEREUM_HOST. - const wallet = EthWallet.fromMnemonic('test test test test test test test test test test test junk', 2); - const provider = WalletProvider.fromHost(ETHEREUM_HOST, wallet); - const ethRpc = new EthereumRpc(provider); - - // Grab a couple of account addresses from our wallet. - const [acc1, acc2] = wallet.accounts.map(a => a.address); - - console.log(`Chain Id: ${await ethRpc.getChainId()}`); - console.log(`ETH balance of ${acc1}: ${fromBaseUnits(await ethRpc.getBalance(acc1), 18, 2)}`); - console.log(''); - - await demoUsefulReceiptError(ethRpc, acc1); - await demoPrintingEventLogs(ethRpc); - await demoDaiContractCalls(ethRpc); - await demoGenericFunctionCall(ethRpc); - await demoERC20DeployAndTransfer(ethRpc, acc1, acc2); - await demoPermit(ethRpc, wallet, acc1, acc2); - await demoEncryptDecryptWallet(wallet); - demoSignMessage(wallet.accounts[0]); -} - -/** - * Demonstrate a failed tx receipt has a useful error message. - */ -async function demoUsefulReceiptError(ethRpc: EthereumRpc, acc1: EthAddress) { - console.log('Demoing decoded errors on receipts, should see INVALID_PROVIDER...'); - const contract = new RollupProcessorContract(ethRpc, rollupProcessorAddr, { from: acc1, gas: 5000000 }); - const { 0: escapeHatchOpen, 1: until } = await contract.methods.getEscapeHatchStatus().call(); - - if (!escapeHatchOpen) { - // First we can do a call that will fail (or estimateGas). This will throw. - try { - await contract.methods.processRollup(Buffer.alloc(0), Buffer.alloc(0)).call(); - } catch (err: any) { - console.log(`Call failed (expectedly) on RollupProcessor with: ${err.message}`); - } - - // Second make an actual send, request not to throw on error, and explicitly check the receipt. - const receipt = await contract.methods.processRollup(Buffer.alloc(0), Buffer.alloc(0)).send().getReceipt(false); - if (receipt.error) { - console.log(`Send receipt shows failure (expectedly) on RollupProcessor with: ${receipt.error.message}`); - } - } else { - console.log(`Skipping until escape hatch closes in ${until} blocks.`); - } - console.log(''); -} - -/** - * Demonstrate printing some event logs from the rollup processor. - */ -async function demoPrintingEventLogs(ethRpc: EthereumRpc) { - console.log('Demoing fetching RollupProcessed event logs from last 1000 blocks...'); - const contract = new RollupProcessorContract(ethRpc, rollupProcessorAddr); - const blockNumber = await ethRpc.blockNumber(); - const events = await contract.getLogs('RollupProcessed', { fromBlock: blockNumber - 1000 }); - events.forEach(e => - console.log( - `Rollup ${e.args.rollupId}: from: ${e.args.sender}, defiHashes: ${e.args.nextExpectedDefiHashes.length}`, - ), - ); - console.log(''); -} - -/** - * Get Dai balance of rollup processor. - * Doesn't really need the DaiContract explicitly to do this, but there are other methods unique to Dai. - */ -async function demoDaiContractCalls(ethRpc: EthereumRpc) { - console.log('Demoing DAI contract calls...'); - const contract = new DaiContract(ethRpc, daiAddr); - const balance = await contract.methods.balanceOf(rollupProcessorAddr).call(); - console.log(`DAI contract version: ${await contract.methods.version().call()}`); - console.log(`DAI Balance of ${rollupProcessorAddr}: ${fromBaseUnits(balance, 18, 2)}`); - console.log(''); -} - -/** - * Demonstrates calling a function not present on the abi. - */ -async function demoGenericFunctionCall(ethRpc: EthereumRpc) { - console.log('Demoing generic function contract calls...'); - const contract = new Contract(ethRpc, new ContractAbi([]), daiAddr); - const balance = await contract.getMethod('balanceOf', ['address'], ['uint'])(rollupProcessorAddr).call(); - console.log(`DAI Balance of ${rollupProcessorAddr}: ${fromBaseUnits(balance, 18, 2)}`); - console.log(''); -} - -/** - * Deploy an ERC20 and do a transfer. - */ -async function demoERC20DeployAndTransfer(ethRpc: EthereumRpc, acc1: EthAddress, acc2: EthAddress) { - console.log('Demoing ERC20 deployment, minting, transfer and log handling...'); - const contract = new ERC20Mintable(ethRpc, undefined, { from: acc1, gas: 1000000 }); - const symbol = 'AZT'; - await contract.deploy(symbol).send().getReceipt(); - console.log(`Deployed ERC20 with symbol: ${await contract.methods.symbol().call()}`); - - console.log(`Transferring from ${acc1} to ${acc2}`); - await contract.methods.mint(acc1, toBaseUnits('1000', 18)).send().getReceipt(); - console.log(`Balance of ${acc1}: ${fromBaseUnits(await contract.methods.balanceOf(acc1).call(), 18)}`); - - const receipt = await contract.methods.transfer(acc2, toBaseUnits('0.1', 18)).send().getReceipt(); - const [{ args }] = receipt.events.Transfer; - if (args) { - console.log(`Log shows transfer of ${args.value} from ${args.from} to ${args.to}`); - } - console.log(`${symbol} balance of ${acc1}: ${fromBaseUnits(await contract.methods.balanceOf(acc1).call(), 18)}`); - console.log(`${symbol} balance of ${acc2}: ${fromBaseUnits(await contract.methods.balanceOf(acc2).call(), 18)}`); - console.log(''); -} - -/** - * Lets use permit to demonstrate signing typed data. Normally one wouldn't call permit as a tx, as it's meant - * to be used within another tx to save on gas. Here we'll just check it correctly updates the allowance. - */ -async function demoPermit(ethRpc: EthereumRpc, wallet: EthWallet, acc1: EthAddress, acc2: EthAddress) { - console.log('Demoing signing typed data by using permit to increase allowance...'); - const contract = new ERC20Permit(ethRpc, undefined, { from: acc1, gas: 2000000 }); - const symbol = 'AZT'; - await contract.deploy(symbol).send().getReceipt(); - await contract.methods.mint(acc1, toBaseUnits('1000', 18)).send().getReceipt(); - - console.log(`Allowance of ${acc2} to transfer from ${acc1}: ${await contract.methods.allowance(acc1, acc2).call()}`); - const deadline = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); - const nonce = await contract.methods.nonces(acc1).call(); - const chainId = await ethRpc.getChainId(); - const permitData = createPermitData(symbol, acc1, acc2, 10n, nonce, deadline, contract.address, chainId); - const sig = wallet.accounts[0].signTypedData(permitData); - await contract.methods.permit(acc1, acc2, 10n, deadline, sig.v, sig.r, sig.s).send().getReceipt(); - console.log(`Allowance of ${acc2} to transfer from ${acc1}: ${await contract.methods.allowance(acc1, acc2).call()}`); - - // We can also pass the typed data to the ETHEREUM_HOST to sign. - // In this case it's intercepted by the WalletProvider. - const sig2 = await ethRpc.signTypedDataV4(acc1, permitData); - console.log(`Direct sign vs provider sign equality check: ${sig.toString() === sig2.toString()}`); - console.log(''); -} - -/** - * Demonstrates encrypting a wallet to KeyStoreJson (which could be written to a file), and restoring it. - */ -async function demoEncryptDecryptWallet(wallet: EthWallet) { - console.log('Demoing wallet encryption and decryption...'); - console.log(`Encrypting wallet with ${wallet.length} accounts...`); - const password = 'mypassword'; - const encryptedWallet = await wallet.encrypt(password); - const decryptedWallet = await EthWallet.fromKeystores(encryptedWallet, password); - - console.log(`Decrypted wallet has ${decryptedWallet.length} accounts:`); - wallet.accounts.map(a => console.log(a.address.toString())); - console.log(''); -} - -/** - * Demonstrates signing a message and verifying signer. - */ -function demoSignMessage(signingAccount: EthAccount) { - console.log('Demoing signing a message locally and recovering the signer...'); - - // Sign a message. - console.log(`Signing message with address: ${signingAccount.address}`); - const msg = Buffer.from('My signed text'); - const sig = signingAccount.signMessage(msg); - - // Verify message was signed by account. - if (signingAccount.signedMessage(msg, sig)) { - console.log(`Message was signed by: ${signingAccount.address}`); - } else { - console.log(`Message was NOT signed by: ${signingAccount.address}`); - } - console.log(''); -} - -main().catch(console.error); diff --git a/yarn-project/ethereum.js/example/tsconfig.json b/yarn-project/ethereum.js/example/tsconfig.json deleted file mode 100644 index 5ad84b348a0..00000000000 --- a/yarn-project/ethereum.js/example/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "..", - "compilerOptions": { - "outDir": "dest", - "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo" - }, - "include": [ - "src" - ], - "references": [ - { - "path": ".." - }, - { - "path": "../../foundation" - } - ] -} diff --git a/yarn-project/ethereum.js/package.json b/yarn-project/ethereum.js/package.json deleted file mode 100644 index aa630dcd31f..00000000000 --- a/yarn-project/ethereum.js/package.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "name": "@aztec/ethereum.js", - "version": "0.0.0", - "main": "index.js", - "license": "MIT", - "type": "module", - "exports": { - "./eth_account": "./dest/eth_account/index.js", - "./eth_address": "./dest/eth_address/index.js", - "./eth_rpc": "./dest/eth_rpc/index.js", - "./eth_sign": "./dest/eth_sign/index.js", - "./eth_transaction": "./dest/eth_transaction/index.js", - "./eth_typed_data": "./dest/eth_typed_data/index.js", - "./eth_wallet": "./dest/eth_wallet/index.js", - "./contract": "./dest/contract/index.js", - "./contract/bytes.js": "./dest/contract/bytes.js", - "./provider": "./dest/provider/index.js", - "./units": "./dest/units/index.js", - "./serialize": "./dest/serialize/index.js", - "./log": "./dest/log/index.js", - "./timer": "./dest/timer/index.js", - "./bigint_buffer": "./dest/bigint_buffer/index.js", - "./crypto": "./dest/crypto/index.js" - }, - "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", - "build": "yarn clean && tsc -b", - "build:dev": "tsc -b --watch", - "clean": "rm -rf ./dest .tsbuildinfo", - "formatting": "run -T prettier --check ./src && run -T eslint ./src", - "formatting:fix": "run -T prettier -w ./src", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests", - "gen_fixtures": "NODE_NO_WARNINGS=1 node ./dest/contract/gen_def/index.js ./src/contract/fixtures/contracts.json" - }, - "inherits": [ - "../package.common.json" - ], - "bin": { - "contract_gen_def": "./dest/contract/gen_def/index.js" - }, - "jest": { - "preset": "ts-jest/presets/default-esm", - "globals": { - "ts-jest": { - "useESM": true - } - }, - "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" - }, - "testRegex": "./src/.*\\.test\\.ts$", - "rootDir": "./src" - }, - "dependencies": { - "@aztec/foundation": "workspace:^", - "bip39": "^3.0.4", - "browserify-aes": "^1.2.0", - "debug": "^4.3.4", - "detect-node": "^2.1.0", - "elliptic": "^6.5.4", - "hdkey": "^2.1.0", - "pbkdf2": "^3.1.2", - "rlp": "^3.0.0", - "sha3": "^2.1.4", - "source-map-support": "^0.5.21", - "uuid": "^9.0.0" - }, - "devDependencies": { - "@jest/globals": "^29.5.0", - "@rushstack/eslint-patch": "^1.2.0", - "@types/elliptic": "^6.4.14", - "@types/hdkey": "^2.0.1", - "@types/jest": "^29.5.0", - "@types/node": "^18.14.6", - "@types/uuid": "^9.0.0", - "jest": "^29.5.0", - "jest-mock-extended": "^3.0.1", - "ts-jest": "^29.1.0", - "ts-node": "^10.9.1", - "typescript": "^5.0.4" - }, - "files": [ - "dest", - "src", - "!*.test.*" - ], - "types": "./dest/index.d.ts" -} diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_log.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_log.test.ts deleted file mode 100644 index 090dfff50bd..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_log.test.ts +++ /dev/null @@ -1,252 +0,0 @@ -/* - This file is part of web3x. - - web3x is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - web3x is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with web3x. If not, see . -*/ - -import { abiCoder } from './index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; - -const tests = [ - { - params: [ - [ - { - type: 'string', - name: 'myString', - }, - { - type: 'uint256', - name: 'myNumber', - indexed: true, - }, - { - type: 'uint8', - name: 'mySmallNumber', - indexed: true, - }, - ], - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000748656c6c6f252100000000000000000000000000000000000000000000000000', - [ - '0x000000000000000000000000000000000000000000000000000000000000f310', - '0x0000000000000000000000000000000000000000000000000000000000000010', - ], - ], - result: { - '0': 'Hello%!', - '1': 62224n, - '2': 16, - myString: 'Hello%!', - myNumber: 62224n, - mySmallNumber: 16, - __length__: 3, - }, - }, - { - params: [ - [ - { - type: 'bytes', - name: 'HelloBytes', - }, - { - type: 'uint8', - name: 'myNumberWork', - indexed: true, - }, - ], - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000748656c6c6f252100000000000000000000000000000000000000000000000000', - ['0x00000000000000000000000000000000000000000000000000000000000000f3'], - ], - result: { - '0': '0x48656c6c6f2521', - '1': 243, - HelloBytes: '0x48656c6c6f2521', - myNumberWork: 243, - __length__: 2, - }, - }, - { - params: [ - [ - { - type: 'bytes32', - name: 'HelloBytes', - indexed: true, - }, - { - type: 'bool', - name: 'IsTrue', - indexed: true, - }, - { - type: 'uint8', - name: 'myNumberWork', - indexed: true, - }, - ], - '', - [ - '0xffdd0000000000000000000000000000000000000000000000000000000000f3', - '0x0000000000000000000000000000000000000000000000000000000000000001', - '0x00000000000000000000000000000000000000000000000000000000000000f3', - ], - ], - result: { - '0': '0xffdd0000000000000000000000000000000000000000000000000000000000f3', - '1': true, - '2': 243, - HelloBytes: '0xffdd0000000000000000000000000000000000000000000000000000000000f3', - IsTrue: true, - myNumberWork: 243, - __length__: 3, - }, - }, - { - params: [ - [ - { - type: 'string', - name: 'MyString', - indexed: true, - }, - { - type: 'bool', - name: 'IsTrue', - indexed: true, - }, - { - type: 'uint8', - name: 'myNumberWork', - indexed: true, - }, - ], - '', - [ - '0xffdd000000000000000000000000000000000000000000000000000000000003', - '0x0000000000000000000000000000000000000000000000000000000000000000', - '0x000000000000000000000000000000000000000000000000000000000000fd44', - ], - ], - result: { - '0': '0xffdd000000000000000000000000000000000000000000000000000000000003', - '1': false, - '2': 68, - MyString: '0xffdd000000000000000000000000000000000000000000000000000000000003', - IsTrue: false, - myNumberWork: 68, - __length__: 3, - }, - }, - { - params: [ - [ - { - indexed: true, - name: 'from', - type: 'address', - }, - { - indexed: true, - name: 'to', - type: 'address', - }, - { - indexed: false, - name: 'amount', - type: 'uint256', - }, - { - indexed: false, - name: 'narrative', - type: 'string', - }, - ], - '0x0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000067465737420780000000000000000000000000000000000000000000000000000', - [ - '0x000000000000000000000000ae653250b4220835050b75d3bc91433246903a95', - '0x00000000000000000000000094011c67bc1e6448ed4b8682047358ca6cd09470', - ], - ], - result: { - '0': EthAddress.fromString('0xae653250B4220835050B75D3bC91433246903A95'), - '1': EthAddress.fromString('0x94011c67BC1E6448ed4b8682047358ca6cD09470'), - '2': 10000n, - '3': 'test x', - from: EthAddress.fromString('0xae653250B4220835050B75D3bC91433246903A95'), - to: EthAddress.fromString('0x94011c67BC1E6448ed4b8682047358ca6cD09470'), - amount: 10000n, - narrative: 'test x', - __length__: 4, - }, - }, - { - params: [ - [ - { - indexed: true, - name: 'from', - type: 'address', - }, - { - indexed: true, - name: 'to', - type: 'address', - }, - { - indexed: false, - name: 'amount', - type: 'uint256', - }, - { - indexed: false, - name: 'narrative', - type: 'string', - }, - ], - '0x00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000', - [ - '0x000000000000000000000000ae653250b4220835050b75d3bc91433246903a95', - '0x00000000000000000000000094011c67bc1e6448ed4b8682047358ca6cd09470', - ], - ], - result: { - '0': EthAddress.fromString('0xae653250B4220835050B75D3bC91433246903A95'), - '1': EthAddress.fromString('0x94011c67BC1E6448ed4b8682047358ca6cD09470'), - '2': 10000n, - '3': 'Hello!%!', - from: EthAddress.fromString('0xae653250B4220835050B75D3bC91433246903A95'), - to: EthAddress.fromString('0x94011c67BC1E6448ed4b8682047358ca6cD09470'), - amount: 10000n, - narrative: 'Hello!%!', - __length__: 4, - }, - }, -]; - -describe('decodeLog', () => { - tests.forEach(test => { - it('should convert correctly', () => { - expect(abiCoder.decodeLog(...(test.params as [any, any, any]))).toEqual(test.result); - }); - }); - - it('should correctly handle zero data', () => { - const expected = { - __length__: 0, - }; - const result = abiCoder.decodeLog([], '0x', []); - expect(result).toEqual(expected); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_parameter.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_parameter.test.ts deleted file mode 100644 index e54bf1f70db..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_parameter.test.ts +++ /dev/null @@ -1,606 +0,0 @@ -import { abiCoder } from './index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; - -const address1 = EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); -const address2 = EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c2'); -const address3 = EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c3'); -const address4 = EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c4'); -const address5 = EthAddress.fromString('0xbbf289d846208c16edc8474705c748aff07732db'); -const address6 = EthAddress.fromString('0x1234567890123456789012345678901234567890'); - -describe('decodeParameter', () => { - const tests = [ - { - params: ['uint256', '0x0000000000000000000000000000000000000000000000000000000000000010'], - result: 16n, - }, - { - params: [ - 'string', - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000', - ], - result: 'Hello!%!', - }, - ]; - - tests.forEach(test => { - it('should convert correctly', () => { - expect(abiCoder.decodeParameter(test.params[0], test.params[1])).toEqual(test.result); - }); - }); -}); - -describe('decodeParameter', () => { - const test = t => { - it('should decode parameter correctly', () => { - expect(abiCoder.decodeParameter(t.type, t.value)).toEqual(t.expected); - }); - }; - - test({ - type: 'address', - expected: address1, - value: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1', - }); - test({ - type: 'address[2]', - expected: [address1, address3], - value: - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3', - }); - test({ - type: 'address[]', - expected: [address1, address3], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3', - }); - test({ - type: 'address[][2]', - expected: [ - [address1, address2], - [address3, address4], - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c2' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c4', - }); - test({ - type: 'address[2][]', - expected: [ - [address1, address2], - [address3, address4], - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' /* 20 */ + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c2' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c4', - }); - // test({ - // type: 'address[][]', - // expected: [ - // [address1, address2], - // [address3, address4], - // ], - // value: - // '0000000000000000000000000000000000000000000000000000000000000020' + - // '0000000000000000000000000000000000000000000000000000000000000002' /* 20 */ + - // '0000000000000000000000000000000000000000000000000000000000000080' + - // '00000000000000000000000000000000000000000000000000000000000000e0' + - // '0000000000000000000000000000000000000000000000000000000000000002' /* 80 */ + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' /* a0 */ + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c2' + - // '0000000000000000000000000000000000000000000000000000000000000002' /* e0 */ + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c4', - // }); - test({ type: 'bool', expected: true, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'bool', expected: false, value: '0000000000000000000000000000000000000000000000000000000000000000' }); - test({ - type: 'bool[2]', - expected: [true, false], - value: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bool[]', - expected: [true, true, false], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - - test({ type: 'int', expected: 1n, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'int', expected: 1n, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'int', expected: 16n, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'int', expected: -1n, value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' }); - test({ type: 'int256', expected: 1n, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'int256', expected: 16n, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'int256', expected: -1n, value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' }); - test({ type: 'int8', expected: 16, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ - type: 'int8[2]', - expected: [16, 2], - value: - '0000000000000000000000000000000000000000000000000000000000000010' + - '0000000000000000000000000000000000000000000000000000000000000002', - }); - test({ type: 'int32', expected: 16, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'int64', expected: 16n, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'int128', expected: 16n, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ - type: 'int[]', - expected: [], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'int[]', - expected: [3n], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'int256[]', - expected: [3n], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'int[]', - expected: [1n, 2n, 3n], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'int[3][]', - expected: [ - [1n, 2n, 3n], - [4n, 5n, 6n], - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006', - }); - - test({ type: 'uint', expected: 1n, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'uint', expected: 1n, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'uint', expected: 16n, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ - type: 'uint', - expected: 115792089237316195423570985008687907853269984665640564039457584007913129639935n, // old 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - }); - test({ type: 'uint256', expected: 1n, value: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ - type: 'uint256', - expected: 16n, - value: '0000000000000000000000000000000000000000000000000000000000000010', - }); - test({ type: 'uint8', expected: 16, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'uint32', expected: 16, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'uint64', expected: 16n, value: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ - type: 'uint128', - expected: 16n, - value: '0000000000000000000000000000000000000000000000000000000000000010', - }); - test({ - type: 'uint[]', - expected: [], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'uint[]', - expected: [3n], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'uint256[]', - expected: [3n], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'uint[]', - expected: [1n, 2n, 3n], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'uint[3][]', - expected: [ - [1n, 2n, 3n], - [4n, 5n, 6n], - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006', - }); - test({ - type: 'bytes', - expected: '0x6761766f66796f726b', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes', - expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'bytes', - expected: - '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'bytes', - expected: - '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'bytes[2]', - expected: [ - '0x00000c8c18f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff', - '0x21f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff', - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000022' + - '00000c8c18f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f61' + - '7fff000000000000000000000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000001e' + - '21f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff0000', - }); - - test({ - type: 'bytes[][2]', - expected: [ - [ - '0x00000c8c18f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff', - '0x21f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff', - ], - [ - '0x00000c8c18f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff', - '0x21f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff', - ], - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000140' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000022' + - '00000c8c18f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f61' + - '7fff000000000000000000000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000001e' + - '21f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff0000' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000022' + - '00000c8c18f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f61' + - '7fff000000000000000000000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000001e' + - '21f9252830fb3c56471c51335a8262f16a6d70e276417a7c7d897f617fff0000', - }); - - test({ - type: 'bytes1', - expected: '0xcf', - value: 'cf00000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes1[4]', - expected: ['0xcf', '0x68', '0x4d', '0xfb'], - value: - 'cf00000000000000000000000000000000000000000000000000000000000000' + - '6800000000000000000000000000000000000000000000000000000000000000' + - '4d00000000000000000000000000000000000000000000000000000000000000' + - 'fb00000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes32', - expected: '0x6761766f66796f726b0000000000000000000000000000000000000000000000', - value: '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - - test({ - type: 'string', - expected: 'gavofyork', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - expected: 'ää', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000008' + - 'c383c2a4c383c2a4000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - expected: 'ü', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - 'c3bc000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - expected: '', - value: - '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - expected: 'Ã', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - 'c383000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - expected: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', - value: - '00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026486565c3a4c3b6c3b6c3a4f09f9185443334c99dc9a33234d084cdbd2d2e2cc3a4c3bc2b232f0000000000000000000000000000000000000000000000000000', - }); - - test({ - type: 'bytes', - expected: '0xc3a40000c3a4', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000006' + - 'c3a40000c3a40000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes32', - expected: '0xc3a40000c3a40000000000000000000000000000000000000000000000000000', - value: 'c3a40000c3a40000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'address', - expected: address1, - value: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1', - }); - test({ - type: 'string', - expected: 'welcome to ethereum. welcome to ethereum. welcome to ethereum.', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '000000000000000000000000000000000000000000000000000000000000003e' + - '77656c636f6d6520746f20657468657265756d2e2077656c636f6d6520746f20' + - '657468657265756d2e2077656c636f6d6520746f20657468657265756d2e0000', - }); - test({ - type: 'bytes', - expected: - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1', - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '000000000000000000000000000000000000000000000000000000000000009f' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100', - }); - test({ - type: 'tuple(address)', - expected: [address5], - value: '000000000000000000000000bbf289d846208c16edc8474705c748aff07732db', - }); - test({ - type: 'tuple(address,address)', - expected: [address5, address5], - value: - '000000000000000000000000bbf289d846208c16edc8474705c748aff07732db' + - '000000000000000000000000bbf289d846208c16edc8474705c748aff07732db', - }); - test({ - type: 'tuple(uint256,uint256)', - expected: [5n, 5n], - value: - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000005', - }); - test({ - type: 'tuple(string,string)', - expected: ['hello', 'world'], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '68656c6c6f000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '776f726c64000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(bytes,bytes)', - expected: ['0x01fe517acd15ff', '0xabcdef12345678'], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000007' + - '01fe517acd15ff00000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000007' + - 'abcdef1234567800000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(bool,bool)', - expected: [false, true], - value: - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - - test({ - type: 'tuple(uint256,string,bytes)', - expected: [4n, 'what what', '0xabcdef12345678'], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '7768617420776861740000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000007' + - 'abcdef1234567800000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(uint128,string,bytes)', - expected: [666n, 'encode your kids', '0x656e636f646520796f75722077696665'], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '000000000000000000000000000000000000000000000000000000000000029a' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000010' + - '656e636f646520796f7572206b69647300000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000010' + - '656e636f646520796f7572207769666500000000000000000000000000000000', - }); - test({ - type: 'tuple(string,bytes32,uint256,bool)', - expected: ['foo bar', '0xaabbccddeeff0000000000000000000000000000000000000000000000000000', 321n, true], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000080' + - 'aabbccddeeff0000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000141' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000007' + - '666f6f2062617200000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(uint8,uint8,uint8,uint8,string,address,bool)', - expected: [1, 2, 3, 4, 'five', EthAddress.fromString('0x0000000000000000000000000000000000000006'), true], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '6669766500000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(tuple(address,address),tuple(uint256,uint256))', - expected: [ - [address6, address6], - [5n, 6n], - ], - value: - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006', - }); - test({ - type: 'tuple(tuple(address,address),tuple(uint256,uint256),tuple(string,string))', - expected: [ - [address6, address6], - [5n, 6n], - ['a string', 'another string'], - ], - value: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000008' + - '6120737472696e67000000000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000e' + - '616e6f7468657220737472696e67000000000000000000000000000000000000', - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_parameters.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_parameters.test.ts deleted file mode 100644 index 9dde20dc312..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/decode_parameters.test.ts +++ /dev/null @@ -1,619 +0,0 @@ -import { abiCoder } from './index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; - -const address1 = EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); -const address2 = EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c3'); -const address3 = EthAddress.fromString('0x1234567890123456789012345678901234567890'); - -describe('decodeParameters', () => { - const tests = [ - { - params: [ - ['string', 'uint256'], - '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000ea000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000', - ], - result: { - '0': 'Hello!%!', - '1': 234n, - __length__: 2, - }, - }, - { - params: [ - [ - { - type: 'string', - name: 'myString', - }, - { - type: 'uint256', - name: 'myNumber', - }, - ], - '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000ea000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000', - ], - result: { - '0': 'Hello!%!', - '1': 234n, - myString: 'Hello!%!', - myNumber: 234n, - __length__: 2, - }, - }, - { - params: [ - ['string'], - '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - ], - result: { '0': '', __length__: 1 }, - }, - { - params: [['int256'], '0x0000000000000000000000000000000000000000000000000000000000000000'], - result: { '0': 0n, __length__: 1 }, - }, - { - params: [['uint256'], '0x0000000000000000000000000000000000000000000000000000000000000000'], - result: { '0': 0n, __length__: 1 }, - }, - { - params: [ - ['bytes'], - '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - ], - result: { '0': null, __length__: 1 }, - }, - { - params: [['address'], '0x0000000000000000000000000000000000000000000000000000000000000000'], - result: { '0': EthAddress.fromString('0x0000000000000000000000000000000000000000'), __length__: 1 }, - }, - { - params: [['bytes32'], '0x0000000000000000000000000000000000000000000000000000000000000000'], - result: { '0': '0x0000000000000000000000000000000000000000000000000000000000000000', __length__: 1 }, - }, - { - params: [['bool'], '0x0000000000000000000000000000000000000000000000000000000000000000'], - result: { '0': false, __length__: 1 }, - }, - ]; - tests.forEach(test => { - it('should convert correctly', () => { - expect(abiCoder.decodeParameters(...(test.params as [any, any]))).toEqual(test.result); - }); - }); - - const failures = [ - { - params: [['string', 'uint256'], '0x'], - }, - { - params: [ - [ - { - type: 'string', - name: 'myString', - }, - { - type: 'uint256', - name: 'myNumber', - }, - ], - '0x', - ], - }, - { - params: [['string'], '0x'], - }, - { - params: [['int256'], '0x'], - }, - { - params: [['uint256'], '0x'], - }, - { - params: [['bytes'], '0x'], - }, - { - params: [['address'], '0x'], - }, - { - params: [['bytes32'], '0x'], - }, - { - params: [['bool'], '0x'], - }, - ]; - - failures.forEach(test => { - it('should not convert ' + test.params[1] + ' to ' + test.params[0], () => { - expect(() => abiCoder.decodeParameters(...(test.params as [any, any]))).toThrow(); - }); - }); -}); - -describe('decodeParameters', () => { - const test = t => { - it('should decode parameters correctly', () => { - const result = abiCoder.decodeParameters(t.types, t.values); - - const resultArray: any = []; - Object.entries(result).forEach(([key, res]) => { - if (isFinite(+key)) { - resultArray.push(res); - } - }); - - expect(resultArray).toEqual(t.expected); - }); - }; - - test({ - types: ['address'], - expected: [address1], - values: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1', - }); - test({ - types: ['address', 'address'], - expected: [address1, address2], - values: - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3', - }); - test({ - types: ['bool[2]', 'bool[3]'], - expected: [ - [true, false], - [false, false, true], - ], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['int[2]', 'int256[3]'], - expected: [ - [1n, 2n], - [3n, 4n, 5n], - ], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000005', - }); - test({ - types: ['int'], - expected: [1n], - values: '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['uint[2]', 'uint256[3]'], - expected: [ - [1n, 2n], - [3n, 4n, 5n], - ], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000005', - }); - test({ - types: ['uint'], - expected: [1n], - values: '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['bytes1', 'bytes1'], - expected: ['0xaa', '0xbb'], - values: - 'aa00000000000000000000000000000000000000000000000000000000000000' + - 'bb00000000000000000000000000000000000000000000000000000000000000', - }); - test({ - types: ['bytes1[2]', 'bytes1'], - expected: [['0xaa', '0xbb'], '0xcc'], - values: - 'aa00000000000000000000000000000000000000000000000000000000000000' + - 'bb00000000000000000000000000000000000000000000000000000000000000' + - 'cc00000000000000000000000000000000000000000000000000000000000000', - }); - test({ - types: ['bytes', 'bytes'], - expected: [ - '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134c', - ], - values: - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134c', - }); - test({ - types: ['int', 'string', 'int'], - expected: [1n, 'gavofyork', 5n], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['bytes32', 'int'], - expected: ['0x6761766f66796f726b0000000000000000000000000000000000000000000000', 5n], - values: - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000005', - }); - test({ - types: ['int', 'bytes32'], - expected: [5n, '0x6761766f66796f726b0000000000000000000000000000000000000000000000'], - values: - '0000000000000000000000000000000000000000000000000000000000000005' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['int', 'string', 'int', 'int', 'int', 'int[]'], - expected: [1n, 'gavofyork', 2n, 3n, 4n, [5n, 6n, 7n]], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000100' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '0000000000000000000000000000000000000000000000000000000000000007', - }); - test({ - types: ['int', 'bytes', 'int', 'bytes'], - expected: [ - 5n, - '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - 3n, - '0x331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - ], - values: - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - types: ['address[2][1]', 'bool'], - expected: [[[address1, address2]], false], - values: - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - types: ['bool[2][1]', 'bool'], - expected: [[[true, false]], true], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['bytes1[2][1]', 'bool'], - expected: [[['0xaa', '0xbb']], true], - values: - 'aa00000000000000000000000000000000000000000000000000000000000000' + - 'bb00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['int[2][1]', 'bool'], - expected: [[[1n, 2n]], true], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['uint[2][1]', 'bool'], - expected: [[[1n, 2n]], true], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['tuple(address,address)', 'tuple(string,string)', 'bool'], - expected: [[address3, address3], ['hello', 'world'], false], - values: - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '68656c6c6f000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '776f726c64000000000000000000000000000000000000000000000000000000', - }); - - test({ - types: ['string', 'tuple(uint256,string)', 'bool', 'tuple(bytes32,bytes)'], - expected: [ - 'the string', - [56n, 'some string'], - true, - ['0x1234567890123456789012345678901234567890123456789012345678901234', '0x129581'], - ], - values: - '0000000000000000000000000000000000000000000000000000000000000080' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000140' + - '000000000000000000000000000000000000000000000000000000000000000a' + - '74686520737472696e6700000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000038' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '736f6d6520737472696e67000000000000000000000000000000000000000000' + - '1234567890123456789012345678901234567890123456789012345678901234' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '1295810000000000000000000000000000000000000000000000000000000000', - }); - test({ - types: [ - 'bool', - 'tuple(bool,tuple(bool,tuple(bool,bool)))', - 'tuple(uint256,tuple(uint256,uint256,tuple(uint256,string)))', - 'string', - ], - expected: [true, [false, [true, [false, true]]], [256n, [76n, 67n, [1337n, 'hello']]], 'last param'], - values: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000200' + - '0000000000000000000000000000000000000000000000000000000000000100' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '000000000000000000000000000000000000000000000000000000000000004c' + - '0000000000000000000000000000000000000000000000000000000000000043' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000539' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '68656c6c6f000000000000000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000a' + - '6c61737420706172616d00000000000000000000000000000000000000000000', - }); - - test({ - types: ['string', 'tuple(string,string,tuple(string,string))', 'bytes', 'tuple(bytes,tuple(bytes,string))'], - expected: [ - 'hello world', - ['what', 'is', ['even', 'happening']], - '0x696e', - ['0x74686973', ['0x676f64666f7273616b656e', 'test']], - ], - values: - '0000000000000000000000000000000000000000000000000000000000000080' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000260' + - '00000000000000000000000000000000000000000000000000000000000002a0' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '68656c6c6f20776f726c64000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '7768617400000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '6973000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '6576656e00000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '68617070656e696e670000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '696e000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '7468697300000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '676f64666f7273616b656e000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '7465737400000000000000000000000000000000000000000000000000000000', - }); - test({ - types: [ - 'string', - 'bool', - 'tuple(string,tuple(tuple(bool,string,bool),tuple(string,bytes32,bytes)))', - 'bytes', - 'tuple(bool,tuple(bytes32,address),bytes)', - ], - expected: [ - 'this', - true, - [ - 'is', - [ - [true, 'utter', true], - [ - 'madness', - '0x1234567890123456789012345678901234567890123456789012345678901234', - '0x6275742049206c6f7665206974', - ], - ], - ], - '0x6265636175736520697420776f726b73', - [ - true, - [ - '0x1234567890123456789012345678901234567890123456789012345678901234', - EthAddress.fromString('0x1337133713371337133713371337133713371337'), - ], - '0x6265636175736520697420776f726b736265636175736520697420776f726b73', - ], - ], - values: - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000320' + - '0000000000000000000000000000000000000000000000000000000000000360' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '7468697300000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '6973000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '7574746572000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '1234567890123456789012345678901234567890123456789012345678901234' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000007' + - '6d61646e65737300000000000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000d' + - '6275742049206c6f766520697400000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000010' + - '6265636175736520697420776f726b7300000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '1234567890123456789012345678901234567890123456789012345678901234' + - '0000000000000000000000001337133713371337133713371337133713371337' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '6265636175736520697420776f726b736265636175736520697420776f726b73', - }); - test({ - types: [ - 'tuple(string,tuple(bool,bool))', - 'address', - 'bytes', - 'tuple(bytes,bytes,string,bool,address)', - 'int256', - 'tuple(int256,uint256,tuple(string,int256,address))', - ], - expected: [ - ['this is more reasonable', [true, false]], - EthAddress.fromString('0x1b3F5FE0Fd513E6cbdEE459F0b0e19095FE91958'), - '0x6c6f6c6f6c6f6c6f6c', - [ - '0xabcdef12345678', - '0x87654321fedcba', - 'bazbar', - false, - EthAddress.fromString('0xd13b6e9058E58B8677233CEc2315e1D9e77C79C4'), - ], - -6n, - [-7n, 5n, ['foobar', -8n, EthAddress.fromString('0xB1eeF147028E9f480DbC5ccaA3277D417D1b85F0')]], - ], - values: - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000001b3f5fe0fd513e6cbdee459f0b0e19095fe91958' + - '0000000000000000000000000000000000000000000000000000000000000160' + - '00000000000000000000000000000000000000000000000000000000000001a0' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa' + - '0000000000000000000000000000000000000000000000000000000000000300' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000017' + - '74686973206973206d6f726520726561736f6e61626c65000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6c6f6c6f6c6f6c6f6c0000000000000000000000000000000000000000000000' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000120' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '000000000000000000000000d13b6e9058e58b8677233cec2315e1d9e77c79c4' + - '0000000000000000000000000000000000000000000000000000000000000007' + - 'abcdef1234567800000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000007' + - '87654321fedcba00000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '62617a6261720000000000000000000000000000000000000000000000000000' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000060' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8' + - '000000000000000000000000b1eef147028e9f480dbc5ccaa3277d417d1b85f0' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '666f6f6261720000000000000000000000000000000000000000000000000000', - }); - test({ - types: [ - 'tuple(bytes32,bool,bytes32)', - 'address', - 'tuple(bytes32,bytes32,string)', - 'tuple(tuple(address,bool),tuple(address,bytes32),tuple(int256,uint256))', - ], - expected: [ - [ - '0xffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae', - true, - '0xffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae', - ], - address3, - [ - '0x0ab3e6dfa1594c15af0000000000000000000000000000000000000000000000', - '0xffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae', - 'string', - ], - [ - [address3, true], - [address3, '0xffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae'], - [-6124612n, 89000n], - ], - ], - values: - 'ffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'ffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae' + - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000000000000000000000000000000000000000000160' + - '0000000000000000000000001234567890123456789012345678901234567890' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000001234567890123456789012345678901234567890' + - 'ffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa28bbc' + - '0000000000000000000000000000000000000000000000000000000000015ba8' + - '0ab3e6dfa1594c15af0000000000000000000000000000000000000000000000' + - 'ffffffffffffffffffffffffffffffffabdef123849181759adebfadecaefbae' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '737472696e670000000000000000000000000000000000000000000000000000', - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_event_signature.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_event_signature.test.ts deleted file mode 100644 index ca3993ec522..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_event_signature.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { abiCoder } from './index.js'; - -const tests = [ - { - params: [ - { - name: 'myEvent', - type: 'event', - inputs: [ - { - type: 'uint256', - name: 'myNumber', - }, - { - type: 'bytes32', - name: 'myBytes', - }, - ], - }, - ], - result: '0xf2eeb729e636a8cb783be044acf6b7b1e2c5863735b60d6daae84c366ee87d97', - }, - { - params: [ - { - name: 'SomeEvent', - type: 'event', - inputs: [ - { - type: 'bytes', - name: 'somebytes', - }, - { - type: 'byte16', - name: 'myBytes', - }, - ], - }, - ], - result: '0xab132b6cdd50f8d4d2ea33c3f140a9b3cf40f451540c69765c4842508bb13838', - }, - { - params: [ - { - name: 'AnotherEvent', - type: 'event', - inputs: [], - }, - ], - result: '0x601d819e31a3cd164f83f7a7cf9cb5042ab1acff87b773c68f63d059c0af2dc0', - }, -]; - -describe('encodeEventSignature', () => { - tests.forEach(test => { - it('should convert correctly', () => { - expect(abiCoder.encodeEventSignature(...(test.params as [any]))).toEqual(test.result); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_function_call.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_function_call.test.ts deleted file mode 100644 index 43ae15e7108..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_function_call.test.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { abiCoder } from './index.js'; - -const tests = [ - { - params: [ - { - name: 'myMethod', - type: 'function', - inputs: [ - { - type: 'uint256', - name: 'myNumber', - }, - { - type: 'string', - name: 'myString', - }, - ], - }, - ['2345675643', 'Hello!%'], - ], - result: - '0x24ee0097000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000748656c6c6f212500000000000000000000000000000000000000000000000000', - }, - { - params: [ - { - name: 'myOtherMethod', - type: 'function', - inputs: [ - { - type: 'uint16', - name: 'myNumberdd', - }, - { - type: 'bytes32', - name: 'myBytes', - }, - ], - }, - [2323, '0x234567432145678543213456'], - ], - result: - '0xed6d6f8500000000000000000000000000000000000000000000000000000000000009132345674321456785432134560000000000000000000000000000000000000000', - }, - { - params: [ - { - name: 'myMethod', - type: 'function', - inputs: [ - { - type: 'uint256', - name: 'myNumber', - }, - { - type: 'bytes', - name: 'myBytes', - }, - ], - }, - ['2345675643', Buffer.from('23456743214567854321ffffdddddd', 'hex')], - ], - result: - '0x4c6a9980000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000f23456743214567854321ffffdddddd0000000000000000000000000000000000', - }, -]; - -describe('encodeFunctionCall', () => { - tests.forEach(test => { - it('should convert correctly', () => { - expect(abiCoder.encodeFunctionCall(...(test.params as [any, any]))).toEqual(test.result); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_function_signature.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_function_signature.test.ts deleted file mode 100644 index 5ed13b55ae2..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_function_signature.test.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { abiCoder } from './index.js'; - -const tests = [ - { - params: [ - { - name: 'myMethod', - type: 'function', - inputs: [ - { - type: 'uint256', - name: 'myNumber', - }, - { - type: 'string', - name: 'myString', - }, - ], - }, - ], - result: '0x24ee0097', - }, - { - params: [ - { - name: 'myMethod', - type: 'function', - inputs: [ - { - type: 'string', - name: 'myNumber', - }, - { - type: 'bytes8', - name: 'myString', - }, - ], - }, - ], - result: '0x27b00c93', - }, - { - params: [ - { - name: 'Somthing', - type: 'function', - inputs: [ - { - type: 'uint16', - name: 'myNumber', - }, - { - type: 'bytes', - name: 'myString', - }, - ], - }, - ], - result: '0x724ff7a1', - }, - { - params: [ - { - name: 'something', - type: 'function', - inputs: [], - }, - ], - result: '0xa7a0d537', - }, - { - params: [ - { - name: 'create', - type: 'function', - inputs: [ - { - name: 'tokenId', - type: 'uint256', - }, - { - name: 'itemOwner', - type: 'address', - }, - { - name: 'keys', - type: 'bytes32[]', - }, - { - name: 'values', - type: 'bytes32[]', - }, - ], - }, - ], - result: '0x04d36f08', - }, -]; - -describe('encodeFunctionSignature', () => { - tests.forEach(test => { - it('should convert correctly', () => { - expect(abiCoder.encodeFunctionSignature(...(test.params as [any]))).toEqual(test.result); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_parameter.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_parameter.test.ts deleted file mode 100644 index 26ada05f636..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_parameter.test.ts +++ /dev/null @@ -1,505 +0,0 @@ -import { abiCoder } from './index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { bufferToHex } from '../../../hex_string/index.js'; - -describe('encodeParameter', () => { - const tests = [ - { - params: ['uint256', '2345675643'], - result: '0x000000000000000000000000000000000000000000000000000000008bd02b7b', - }, - { - params: ['bytes32', '0xdf3234'], - result: '0xdf32340000000000000000000000000000000000000000000000000000000000', - }, - { - params: ['bytes32[]', ['0xdf3234', '0xfdfd']], - result: - '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002df32340000000000000000000000000000000000000000000000000000000000fdfd000000000000000000000000000000000000000000000000000000000000', - }, - ]; - - tests.forEach(test => { - it('should convert correctly', () => { - expect(bufferToHex(abiCoder.encodeParameter(test.params[0], test.params[1]))).toEqual(test.result); - }); - }); -}); - -describe('encodeParameter', () => { - it('should correctly encode a BigInt', () => { - expect(bufferToHex(abiCoder.encodeParameter('uint256', 1000n))).toBe( - '0x00000000000000000000000000000000000000000000000000000000000003e8', - ); - }); - - it('should correctly encode a number', () => { - expect(bufferToHex(abiCoder.encodeParameter('uint256', 1000))).toBe( - '0x00000000000000000000000000000000000000000000000000000000000003e8', - ); - }); - - const test = t => { - it('should correctly encode parameter', () => { - expect(abiCoder.encodeParameter(t.type, t.value).toString('hex')).toBe(t.expected); - }); - }; - - test({ - type: 'address', - value: EthAddress.fromString('0x407d73d8a49eeb85d32cf465507dd71d507100c1'), - expected: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1', - }); - test({ - type: 'address[2]', - value: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x407d73d8a49eeb85d32cf465507dd71d507100c3'], - expected: - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3', - }); - test({ - type: 'address[]', - value: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x407d73d8a49eeb85d32cf465507dd71d507100c3'], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3', - }); - test({ - type: 'address[][2]', - value: [ - ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x407d73d8a49eeb85d32cf465507dd71d507100c2'], - ['0x407d73d8a49eeb85d32cf465507dd71d507100c3', '0x407d73d8a49eeb85d32cf465507dd71d507100c4'], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c2' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c4', - }); - test({ - type: 'address[2][]', - value: [ - ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x407d73d8a49eeb85d32cf465507dd71d507100c2'], - ['0x407d73d8a49eeb85d32cf465507dd71d507100c3', '0x407d73d8a49eeb85d32cf465507dd71d507100c4'], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c2' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c4', - }); - // test({ type: 'address[][]', value: [['0x407d73d8a49eeb85d32cf465507dd71d507100c5'], - // ['0x407d73d8a49eeb85d32cf465507dd71d507100c3']], - // expected: '0000000000000000000000000000000000000000000000000000000000000020' + - // '0000000000000000000000000000000000000000000000000000000000000002' + - // '0000000000000000000000000000000000000000000000000000000000000080' + - // '00000000000000000000000000000000000000000000000000000000000000c0' + - // '0000000000000000000000000000000000000000000000000000000000000001' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c5' + - // '0000000000000000000000000000000000000000000000000000000000000001' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' }); - // test({ type: 'address[][]', value: [['0x407d73d8a49eeb85d32cf465507dd71d507100cf', '0x407d73d8a49eeb85d32cf465507dd71d507100c2'], - // ['0x407d73d8a49eeb85d32cf465507dd71d507100c3', '0x407d73d8a49eeb85d32cf465507dd71d507100c4']], - // expected: '0000000000000000000000000000000000000000000000000000000000000020' + - // '0000000000000000000000000000000000000000000000000000000000000002' + - // '0000000000000000000000000000000000000000000000000000000000000080' + - // '00000000000000000000000000000000000000000000000000000000000000e0' + - // '0000000000000000000000000000000000000000000000000000000000000002' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100cf' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c2' + - // '0000000000000000000000000000000000000000000000000000000000000002' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3' + - // '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c4' }); - test({ type: 'bool', value: true, expected: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'bool', value: false, expected: '0000000000000000000000000000000000000000000000000000000000000000' }); - test({ - type: 'bool[1][2]', - value: [[false], [false]], - expected: - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bool[2]', - value: [true, false], - expected: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bool[]', - value: [true, true, false], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - - test({ type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' }); - // test({ type: 'int', value: 0.1, expected: '0000000000000000000000000000000000000000000000000000000000000000'}); - // test({ type: 'int', value: 3.9, expected: '0000000000000000000000000000000000000000000000000000000000000003'}); - test({ type: 'int256', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'int256', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ type: 'int256', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' }); - - test({ type: 'uint', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'uint', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010' }); - // test({ type: 'uint', value: 0.1, expected: '0000000000000000000000000000000000000000000000000000000000000000'}); - // test({ type: 'uint', value: 3.9, expected: '0000000000000000000000000000000000000000000000000000000000000003'}); - test({ type: 'uint256', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ type: 'uint256', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010' }); - test({ - type: 'uint256', - value: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - }); - test({ - type: 'bytes32', - value: '0x6761766f66796f726b', - expected: '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes32', - value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - expected: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'bytes32', - value: '0x02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29', - expected: '02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29', - }); - test({ - type: 'bytes', - value: '0x6761766f66796f726b', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes', - value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'bytes', - value: - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '000000000000000000000000000000000000000000000000000000000000009f' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff100', - }); - test({ - type: 'string', - value: 'gavofyork', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - - test({ - type: 'string', - value: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', - expected: - '00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026486565c3a4c3b6c3b6c3a4f09f9185443334c99dc9a33234d084cdbd2d2e2cc3a4c3bc2b232f0000000000000000000000000000000000000000000000000000', - }); - - test({ - type: 'bytes', - value: '0xc3a40000c3a4', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000006' + - 'c3a40000c3a40000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'bytes32', - value: '0xc3a40000c3a4', - expected: 'c3a40000c3a40000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - value: 'ää', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000008' + - 'c383c2a4c383c2a4000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - value: 'ü', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - 'c3bc000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'string', - value: 'Ã', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000002' + - 'c383000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'int[]', - value: [], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'int[]', - value: [3], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'int256[]', - value: [3], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'int[]', - value: [1, 2, 3], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - type: 'bytes1[4]', - value: ['0xcf', '0x68', '0x4d', '0xfb'], - expected: - 'cf00000000000000000000000000000000000000000000000000000000000000' + - '6800000000000000000000000000000000000000000000000000000000000000' + - '4d00000000000000000000000000000000000000000000000000000000000000' + - 'fb00000000000000000000000000000000000000000000000000000000000000', - }); - - test({ - type: 'bytes', - value: - '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'bytes', - value: - '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - type: 'string', - value: 'welcome to ethereum. welcome to ethereum. welcome to ethereum.', - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '000000000000000000000000000000000000000000000000000000000000003e' + - '77656c636f6d6520746f20657468657265756d2e2077656c636f6d6520746f20' + - '657468657265756d2e2077656c636f6d6520746f20657468657265756d2e0000', - }); - test({ - type: 'tuple(string,string)', - value: ['welcome to ethereum.', 'welcome to ethereum.'], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000014' + - '77656c636f6d6520746f20657468657265756d2e000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000014' + - '77656c636f6d6520746f20657468657265756d2e000000000000000000000000', - }); - test({ - type: 'tuple(bytes,bytes)', - value: ['0x77656c636f6d6520746f20657468657265756d2e', '0x77656c636f6d6520746f20657468657265756d2e'], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000014' + - '77656c636f6d6520746f20657468657265756d2e000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000014' + - '77656c636f6d6520746f20657468657265756d2e000000000000000000000000', - }); - test({ - type: 'tuple(bytes,bool,uint256)', - value: ['0x77656c636f6d6520746f20657468657265756d2e', true, 124515], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '000000000000000000000000000000000000000000000000000000000001e663' + - '0000000000000000000000000000000000000000000000000000000000000014' + - '77656c636f6d6520746f20657468657265756d2e000000000000000000000000', - }); - test({ - type: 'tuple(string,tuple(bool,int256),address)', - value: ['hello', [true, -151], '0x0175010374017501037401750103740175010374'], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff69' + - '0000000000000000000000000175010374017501037401750103740175010374' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '68656c6c6f000000000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(tuple(bool,bool),tuple(address,address),tuple(string,string))', - value: [ - [true, false], - ['0x81017589ab81017589ab81017589ab81017589ab', '0x81017589ab81017589ab81017589ab81017589ab'], - ['string One', 'string Two'], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '00000000000000000000000081017589ab81017589ab81017589ab81017589ab' + - '00000000000000000000000081017589ab81017589ab81017589ab81017589ab' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '000000000000000000000000000000000000000000000000000000000000000a' + - '737472696e67204f6e6500000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000a' + - '737472696e672054776f00000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(tuple(tuple(bool,bool),tuple(bytes,bytes),tuple(address,bool)),address)', - value: [ - [ - [false, false], - ['0xab1394581edfa2ef9ca71', '0x15abe391df19aef19a4561'], - ['0xec2270c849236333c86834728e783cd2f789088e', true], - ], - '0x81017589ab81017589ab81017589ab81017589ab', - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000081017589ab81017589ab81017589ab81017589ab' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '000000000000000000000000ec2270c849236333c86834728e783cd2f789088e' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '0ab1394581edfa2ef9ca71000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '15abe391df19aef19a4561000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(bool,string,bool,tuple(address,address))', - value: [ - true, - 'testing', - false, - ['0x1981710abe1981710abe1981710abe1981710abe', '0x1981710abe1981710abe1981710abe1981710abe'], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000001981710abe1981710abe1981710abe1981710abe' + - '0000000000000000000000001981710abe1981710abe1981710abe1981710abe' + - '0000000000000000000000000000000000000000000000000000000000000007' + - '74657374696e6700000000000000000000000000000000000000000000000000', - }); - test({ - type: 'tuple(address,address,tuple(string,tuple(int256,int256),string))', - value: [ - '0x1981710abe1981710abe1981710abe1981710abe', - '0x1981710abe1981710abe1981710abe1981710abe', - ['structs are great', [-1951, 194018], 'so many possibilities'], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000001981710abe1981710abe1981710abe1981710abe' + - '0000000000000000000000001981710abe1981710abe1981710abe1981710abe' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000080' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff861' + - '000000000000000000000000000000000000000000000000000000000002f5e2' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000011' + - '7374727563747320617265206772656174000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000015' + - '736f206d616e7920706f73736962696c69746965730000000000000000000000', - }); - test({ - type: 'tuple(bool,tuple(bytes32,int256,tuple(bytes24,bytes8)),tuple(bool,bool,bool),string)', - value: [ - true, - [ - '0xabdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', - -18291849, - ['0xabdef18710a18a18abdef18710a18a18abdef18710a18a18', '0xabdef18710a18a18'], - ], - [false, true, false], - 'testing testing', - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'abdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18' + - 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffee8e377' + - 'abdef18710a18a18abdef18710a18a18abdef18710a18a180000000000000000' + - 'abdef18710a18a18000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000120' + - '000000000000000000000000000000000000000000000000000000000000000f' + - '74657374696e672074657374696e670000000000000000000000000000000000', - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_parameters.test.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_parameters.test.ts deleted file mode 100644 index 27ad5ee5a60..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/encode_parameters.test.ts +++ /dev/null @@ -1,607 +0,0 @@ -import { bufferToHex } from '../../../hex_string/index.js'; -import { abiCoder } from './index.js'; - -describe('encodeParameters', () => { - const tests = [ - { - params: [ - ['uint256', 'string'], - ['2345675643', 'Hello!%'], - ], - result: - '0x000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000748656c6c6f212500000000000000000000000000000000000000000000000000', - }, - { - params: [ - ['uint64[]', 'bytes32'], - [['34', '434'], '0x324567dfff'], - ], - result: - '0x0000000000000000000000000000000000000000000000000000000000000040324567dfff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000001b2', - }, - { - params: [ - ['address', 'address', 'address', 'address'], - [ - '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', - '0x10f8bf6a479f320ead074411a4b0e7944ea8c9c1', - '0xfff8bf6a479f320ead074411a4b0e7944ea8c9c1', - '0xddd8bf6a479f320ead074411a4b0e7944ea8c9c1', - ], - ], - result: - '0x00000000000000000000000090f8bf6a479f320ead074411a4b0e7944ea8c9c100000000000000000000000010f8bf6a479f320ead074411a4b0e7944ea8c9c1000000000000000000000000fff8bf6a479f320ead074411a4b0e7944ea8c9c1000000000000000000000000ddd8bf6a479f320ead074411a4b0e7944ea8c9c1', - }, - ]; - - tests.forEach(test => { - it('should convert correctly', () => { - expect(bufferToHex(abiCoder.encodeParameters(test.params[0], test.params[1]))).toEqual(test.result); - }); - }); -}); - -describe('encodeParameters', () => { - const test = t => { - it('should correct encode paramters', () => { - expect(abiCoder.encodeParameters(t.types, t.values).toString('hex')).toBe(t.expected); - }); - }; - - test({ - types: ['address', 'address'], - values: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x407d73d8a49eeb85d32cf465507dd71d507100c3'], - expected: - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1' + - '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c3', - }); - test({ - types: ['bool[2]', 'bool[3]'], - values: [ - [true, false], - [false, false, true], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ types: ['int'], values: [1], expected: '0000000000000000000000000000000000000000000000000000000000000001' }); - test({ - types: ['int'], - values: [16], - expected: '0000000000000000000000000000000000000000000000000000000000000010', - }); - test({ - types: ['int'], - values: [-1], - expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - }); - test({ - types: ['int256'], - values: [1], - expected: '0000000000000000000000000000000000000000000000000000000000000001', - }); - test({ - types: ['int256'], - values: [16], - expected: '0000000000000000000000000000000000000000000000000000000000000010', - }); - test({ - types: ['int256'], - values: [-1], - expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - }); - test({ - types: ['int[]'], - values: [[3]], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - types: ['int256[]'], - values: [[3]], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - types: ['int256[]'], - values: [[1, 2, 3]], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - types: ['int[]', 'int[]'], - values: [ - [1, 2], - [3, 4], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004', - }); - test({ - types: ['int[]', 'int[]', 'int[]'], - values: [ - [1, 2], - [3, 4], - [5, 6, 7], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000120' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '0000000000000000000000000000000000000000000000000000000000000007', - }); - test({ - types: ['bytes32'], - values: ['0x6761766f66796f726b'], - expected: '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['string'], - values: ['gavofyork'], - expected: - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['string', 'string'], - values: ['gavofyork', 'gavofyork'], - expected: - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - - test({ - types: ['bytes32', 'int'], - values: ['0x6761766f66796f726b', 5], - expected: - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000005', - }); - test({ - types: ['int', 'bytes32'], - values: [5, '0x6761766f66796f726b'], - expected: - '0000000000000000000000000000000000000000000000000000000000000005' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['int', 'string'], - values: [5, 'gavofyork'], - expected: - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['string', 'int'], - values: ['gavofyork', 5], - expected: - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['string', 'bool', 'int[]'], - values: ['gavofyork', true, [1, 2, 3]], - expected: - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - types: ['string', 'int[]'], - values: ['gavofyork', [1, 2, 3]], - expected: - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003', - }); - test({ - types: ['int', 'string'], - values: [5, 'gavofyork'], - expected: - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', - }); - test({ - types: ['int', 'string', 'int', 'int', 'int', 'int[]'], - values: [1, 'gavofyork', 2, 3, 4, [5, 6, 7]], - expected: - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000100' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '0000000000000000000000000000000000000000000000000000000000000007', - }); - test({ - types: ['int', 'bytes', 'int', 'bytes'], - values: [ - 5, - '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - 3, - '0x331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + - '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', - }); - test({ - types: ['bytes3', 'bytes'], - values: ['0xcf0011', '0x4d00000000000000000000000000000000000000000000000000000000000012'], - expected: - 'cf00110000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '4d00000000000000000000000000000000000000000000000000000000000012', - }); - test({ - types: ['string', 'tuple(string,string)'], - values: ['what', ['what what', 'what what']], - expected: - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '7768617400000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '7768617420776861740000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '7768617420776861740000000000000000000000000000000000000000000000', - }); - test({ - types: ['tuple(bytes32,bool)', 'tuple(bool,address)'], - values: [ - ['0xabdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', true], - [true, '0x77656c636f6d6520746f20657468657265756d2e'], - ], - expected: - 'abdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e', - }); - test({ - types: ['tuple(bytes32,bool)', 'tuple(bool,address)'], - values: [ - ['0xabdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', true], - [true, '0x77656c636f6d6520746f20657468657265756d2e'], - ], - expected: - 'abdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e', - }); - test({ - types: ['tuple(address,uint256)', 'tuple(uint256,bool)', 'tuple(bytes32,bytes32)'], - values: [ - ['0x77656c636f6d6520746f20657468657265756d2e', '148'], - ['5910', true], - [ - '0xabdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', - '0xabdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', - ], - ], - expected: - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000094' + - '0000000000000000000000000000000000000000000000000000000000001716' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'abdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18' + - 'abdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', - }); - - test({ - types: [ - 'tuple(tuple(address,address),tuple(bool,bool))', - 'tuple(tuple(bool,bool),tuple(bytes,bytes),tuple(uint256,uint256))', - 'address', - ], - values: [ - [ - ['0x77656c636f6d6520746f20657468657265756d2e', '0x77656c636f6d6520746f20657468657265756d2e'], - [true, false], - ], - [ - [false, true], - ['0xab1394581edfa2ef9ca71', '0x15abe391df19aef19a4561'], - ['182', '1937'], - ], - '0x77656c636f6d6520746f20657468657265756d2e', - ], - expected: - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '00000000000000000000000000000000000000000000000000000000000000b6' + - '0000000000000000000000000000000000000000000000000000000000000791' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '0ab1394581edfa2ef9ca71000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '15abe391df19aef19a4561000000000000000000000000000000000000000000', - }); - - test({ - types: [ - 'tuple(tuple(uint256,bool),tuple(uint256,tuple(bytes,bytes)))', - 'bytes', - 'tuple(bool,tuple(bytes,address),bytes)', - ], - values: [ - [ - ['18320', true], - ['691', ['0xab1394581edfa2ef9ca71', '0x15abe391df19aef19a4561']], - ], - '0xab1394581edfa2ef9ca71', - [ - false, - ['0xfe', '0x77656c636f6d6520746f20657468657265756d2e'], - '0xabdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', - ], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000001c0' + - '0000000000000000000000000000000000000000000000000000000000000200' + - '0000000000000000000000000000000000000000000000000000000000004790' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000002b3' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '0ab1394581edfa2ef9ca71000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '15abe391df19aef19a4561000000000000000000000000000000000000000000' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '0ab1394581edfa2ef9ca71000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'fe00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000020' + - 'abdef18710a18a18abdef18710a18a18abdef18710a18a18abdef18710a18a18', - }); - - test({ - types: ['address', 'tuple(bool,tuple(address,address))', 'tuple(tuple(address,tuple(int256,int256)),bool)'], - values: [ - '0x77656c636f6d6520746f20657468657265756d2e', - [true, ['0x77656c636f6d6520746f20657468657265756d2e', '0x77656c636f6d6520746f20657468657265756d2e']], - [['0x77656c636f6d6520746f20657468657265756d2e', ['-12451', '-12451018']], false], - ], - expected: - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcf5d' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff420336' + - '0000000000000000000000000000000000000000000000000000000000000000', - }); - - test({ - types: [ - 'bytes', - 'tuple(tuple(bool,bool,bool),tuple(bytes,bytes,bytes),tuple(bytes,bool,address),tuple(uint256,int256,address))', - 'tuple(bytes,tuple(tuple(int256,bool),tuple(uint256,bytes)))', - ], - values: [ - '0xabef15', - [ - [true, false, true], - ['0xabef15', '0xcdef151', '0xabfe151'], - ['0x15abe391df19aef19a4561', true, '0x77656c636f6d6520746f20657468657265756d2e'], - ['1840181', '-819184919', '0x77656c636f6d6520746f20657468657265756d2e'], - ], - [ - '0x77656c636f6d6520746f20657468657265756d2e', - [ - ['-18491', false], - ['1918491', '0xabdcf151dae'], - ], - ], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '0000000000000000000000000000000000000000000000000000000000000360' + - '0000000000000000000000000000000000000000000000000000000000000003' + - 'abef150000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000100' + - '0000000000000000000000000000000000000000000000000000000000000220' + - '00000000000000000000000000000000000000000000000000000000001c1435' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffcf2c3ae9' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000003' + - 'abef150000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0cdef15100000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0abfe15100000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '000000000000000000000000000000000000000000000000000000000000000b' + - '15abe391df19aef19a4561000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000014' + - '77656c636f6d6520746f20657468657265756d2e000000000000000000000000' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb7c5' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000001d461b' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '0abdcf151dae0000000000000000000000000000000000000000000000000000', - }); - - test({ - types: [ - 'tuple(bytes,tuple(address,address))', - 'tuple(address,address,address,bytes,address)', - 'tuple(address,tuple(address,tuple(address,bool)))', - ], - values: [ - ['0xabef15', ['0x77656c636f6d6520746f20657468657265756d2e', '0x77656c636f6d6520746f20657468657265756d2e']], - [ - '0x77656c636f6d6520746f20657468657265756d2e', - '0x77656c636f6d6520746f20657468657265756d2e', - '0x77656c636f6d6520746f20657468657265756d2e', - '0xabef15', - '0x77656c636f6d6520746f20657468657265756d2e', - ], - [ - '0x81017589ab81017589ab81017589ab81017589ab', - ['0x77656c636f6d6520746f20657468657265756d2e', ['0x81017589ab81017589ab81017589ab81017589ab', false]], - ], - ], - expected: - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000160' + - '00000000000000000000000081017589ab81017589ab81017589ab81017589ab' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000081017589ab81017589ab81017589ab81017589ab' + - '0000000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000003' + - 'abef150000000000000000000000000000000000000000000000000000000000' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '00000000000000000000000077656c636f6d6520746f20657468657265756d2e' + - '0000000000000000000000000000000000000000000000000000000000000003' + - 'abef150000000000000000000000000000000000000000000000000000000000', - }); - - test({ - types: ['tuple(bytes,bytes)', 'bytes', 'tuple(tuple(bytes),tuple(bytes,bytes),tuple(bytes,bytes,bytes))'], - values: [ - ['0xabef15', '0xa'], - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - [['0xaf'], ['0xaf', '0xbc'], ['0xaf', '0xbc', '0xde']], - ], - expected: - '0000000000000000000000000000000000000000000000000000000000000060' + - '0000000000000000000000000000000000000000000000000000000000000120' + - '0000000000000000000000000000000000000000000000000000000000000160' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000003' + - 'abef150000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0a00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000020' + - 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000180' + - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'af00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000040' + - '0000000000000000000000000000000000000000000000000000000000000080' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'af00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'bc00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000060' + - '00000000000000000000000000000000000000000000000000000000000000a0' + - '00000000000000000000000000000000000000000000000000000000000000e0' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'af00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'bc00000000000000000000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000001' + - 'de00000000000000000000000000000000000000000000000000000000000000', - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/ethers/abi-coder.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/ethers/abi-coder.ts deleted file mode 100644 index 8b5edb0d909..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/ethers/abi-coder.ts +++ /dev/null @@ -1,1541 +0,0 @@ -import { toBufferBE, toBigIntBE } from '@aztec/foundation/bigint-buffer'; -import { bufferToHex, hexToBuffer } from '../../../../hex_string/index.js'; -import * as errors from './errors.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; - -const NegativeOne = BigInt(-1); -const Zero = BigInt(0); -const MaxUint256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); - -/** - * Type representing a parameter for Ethereum contract events and functions. - */ -type ParamType = { - /** - * The name of the parameter or variable. - */ - name?: string; - /** - * The data type for a specific parameter. - */ - type: string; - /** - * Indicates whether the event parameter is indexed or not. - */ - indexed?: boolean; - /** - * An array of component objects representing the structure and types of a tuple. - */ - components?: Array; -}; - -// type EventFragment = { -// type: string; -// name: string; - -// anonymous: boolean; - -// inputs: Array; -// }; - -// type FunctionFragment = { -// type: string; -// name?: string; - -// constant: boolean; - -// inputs: Array; -// outputs?: Array; - -// payable: boolean; -// stateMutability: string | null; - -// gas: bigint | null; -// }; - -const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); -const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); -const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); - -/////////////////////////////////// -// Parsing for Solidity Signatures - -// const regexParen = new RegExp('^([^)(]*)\\((.*)\\)([^)(]*)$'); -// const regexIdentifier = new RegExp('^[A-Za-z_][A-Za-z0-9_]*$'); - -/** - * Verifies and transforms the given type string to its full description if necessary. - * This function handles cases where the input type is a shorthand for specific types - * like 'uint' or 'int', converting them into their complete representations, such as 'uint256' or 'int256'. - * In all other cases, the input type is returned as-is. - * - * @param type - The data type string to be verified and transformed if necessary. - * @returns A string representing the full description of the input type. - */ -function verifyType(type: string): string { - // These need to be transformed to their full description - if (type.match(/^uint($|[^1-9])/)) { - type = 'uint256' + type.substring(4); - } else if (type.match(/^int($|[^1-9])/)) { - type = 'int256' + type.substring(3); - } - - return type; -} - -/** - * Type representing the state of a parser for parsing and validating Solidity signatures. - */ -type ParseState = { - /** - * Indicates whether an array type is allowed. - */ - allowArray?: boolean; - /** - * Determines if a name is allowed for the parameter. - */ - allowName?: boolean; - /** - * Indicates whether parameters are allowed for the current node. - */ - allowParams?: boolean; - /** - * Determines if type can be accepted or not. - */ - allowType?: boolean; - /** - * Indicates whether the array is being read during parsing. - */ - readArray?: boolean; -}; - -/** - * Represents a node in the Abstract Syntax Tree (AST) during the parsing of Solidity signatures. It contains all necessary information about the current parsing state, such as type, name, parent, and components. - */ -type ParseNode = { - /** - * The parent node of the current parse tree. - */ - parent?: any; - /** - * The data type of the parameter. - */ - type?: string; - /** - * The name representing an identifiable entity. - */ - name?: string; - /** - * Represents the current state of parsing in a given node. - */ - state?: ParseState; - /** - * Indicates if the parameter is indexed in event logs. - */ - indexed?: boolean; - /** - * An array of nested parameter types. - */ - components?: Array; -}; - -/** - * Parses a parameter string into a ParamType object with its type, name, components, and indexed information. - * This function supports parsing complex types, such as tuples and arrays, as well as simple types like uint, int, etc. - * It also handles optional indexed property for event parameters. - * Throws an error if there is an unexpected character or mismatched parentheses in the input param string. - * - * @param param - The parameter string to be parsed. - * @param allowIndexed - Optional flag indicating whether to parse indexed property for event parameters. - * @returns A ParamType object with the parsed information. - */ -function parseParam(param: string, allowIndexed?: boolean): ParamType { - /** - * Throws a custom error with the specified reason, code, and additional error information. - * This function is used to generate standardized error messages for better error handling - * and debugging throughout the codebase. - * - * @param reason - The main reason for the error being thrown. - * @param code - The error code associated with the particular type of error. - * @param params - An optional object containing any additional information related to the error. - * @throws Error - A custom error with the provided details. - */ - function throwError(i: number) { - throw new Error('unexpected character "' + param[i] + '" at position ' + i + ' in "' + param + '"'); - } - - const parent: ParseNode = { type: '', name: '', state: { allowType: true } }; - let node: any = parent; - - for (let i = 0; i < param.length; i++) { - const c = param[i]; - switch (c) { - case '(': - if (!node.state.allowParams) { - throwError(i); - } - node.state.allowType = false; - node.type = verifyType(node.type); - node.components = [{ type: '', name: '', parent: node, state: { allowType: true } }]; - node = node.components[0]; - break; - - case ')': { - delete node.state; - if (allowIndexed && node.name === 'indexed') { - node.indexed = true; - node.name = ''; - } - node.type = verifyType(node.type); - - const child = node; - node = node.parent; - if (!node) { - throwError(i); - } - delete child.parent; - node.state.allowParams = false; - node.state.allowName = true; - node.state.allowArray = true; - break; - } - case ',': { - delete node.state; - if (allowIndexed && node.name === 'indexed') { - node.indexed = true; - node.name = ''; - } - node.type = verifyType(node.type); - - const sibling: ParseNode = { type: '', name: '', parent: node.parent, state: { allowType: true } }; - node.parent.components.push(sibling); - delete node.parent; - node = sibling; - break; - } - // Hit a space... - case ' ': - // If reading type, the type is done and may read a param or name - if (node.state.allowType) { - if (node.type !== '') { - node.type = verifyType(node.type); - delete node.state.allowType; - node.state.allowName = true; - node.state.allowParams = true; - } - } - - // If reading name, the name is done - if (node.state.allowName) { - if (node.name !== '') { - if (allowIndexed && node.name === 'indexed') { - node.indexed = true; - node.name = ''; - } else { - node.state.allowName = false; - } - } - } - - break; - - case '[': - if (!node.state.allowArray) { - throwError(i); - } - - node.type += c; - - node.state.allowArray = false; - node.state.allowName = false; - node.state.readArray = true; - break; - - case ']': - if (!node.state.readArray) { - throwError(i); - } - - node.type += c; - - node.state.readArray = false; - node.state.allowArray = true; - node.state.allowName = true; - break; - - default: - if (node.state.allowType) { - node.type += c; - node.state.allowParams = true; - node.state.allowArray = true; - } else if (node.state.allowName) { - node.name += c; - delete node.state.allowArray; - } else if (node.state.readArray) { - node.type += c; - } else { - throwError(i); - } - } - } - - if (node.parent) { - throw new Error('unexpected eof'); - } - - delete parent.state; - - if (allowIndexed && node.name === 'indexed') { - node.indexed = true; - node.name = ''; - } - - parent.type = verifyType(parent.type!); - - return parent; -} - -// @TODO: Better return type -// function parseSignatureEvent(fragment: string): EventFragment { -// var abi: EventFragment = { -// anonymous: false, -// inputs: [], -// name: '', -// type: 'event', -// }; - -// var match = fragment.match(regexParen); -// if (!match) { -// throw new Error('invalid event: ' + fragment); -// } - -// abi.name = match[1].trim(); - -// splitNesting(match[2]).forEach(function (param) { -// param = parseParam(param, true); -// param.indexed = !!param.indexed; -// abi.inputs.push(param); -// }); - -// match[3].split(' ').forEach(function (modifier) { -// switch (modifier) { -// case 'anonymous': -// abi.anonymous = true; -// break; -// case '': -// break; -// default: -// console.log('unknown modifier: ' + modifier); -// } -// }); - -// if (abi.name && !abi.name.match(regexIdentifier)) { -// throw new Error('invalid identifier: "' + abi.name + '"'); -// } - -// return abi; -// } - -// function parseSignatureFunction(fragment: string): FunctionFragment { -// var abi: FunctionFragment = { -// constant: false, -// gas: null, -// inputs: [], -// name: '', -// outputs: [], -// payable: false, -// stateMutability: null, // @TODO: Should this be initialized to 'nonpayable'? -// type: 'function', -// }; - -// let comps = fragment.split('@'); -// if (comps.length !== 1) { -// if (comps.length > 2) { -// throw new Error('invalid signature'); -// } -// if (!comps[1].match(/^[0-9]+$/)) { -// throw new Error('invalid signature gas'); -// } -// abi.gas = BigInt(comps[1]); -// fragment = comps[0]; -// } - -// comps = fragment.split(' returns '); -// var left = comps[0].match(regexParen); -// if (!left) { -// throw new Error('invalid signature'); -// } - -// abi.name = left[1].trim(); -// if (!abi.name.match(regexIdentifier)) { -// throw new Error('invalid identifier: "' + left[1] + '"'); -// } - -// splitNesting(left[2]).forEach(function (param) { -// abi.inputs.push(parseParam(param)); -// }); - -// left[3].split(' ').forEach(function (modifier) { -// switch (modifier) { -// case 'constant': -// abi.constant = true; -// break; -// case 'payable': -// abi.payable = true; -// abi.stateMutability = 'payable'; -// break; -// case 'pure': -// abi.constant = true; -// abi.stateMutability = 'pure'; -// break; -// case 'view': -// abi.constant = true; -// abi.stateMutability = 'view'; -// break; -// case 'external': -// case 'public': -// case '': -// break; -// default: -// console.log('unknown modifier: ' + modifier); -// } -// }); - -// // We have outputs -// if (comps.length > 1) { -// var right: any = comps[1].match(regexParen); -// if (right[1].trim() != '' || right[3].trim() != '') { -// throw new Error('unexpected tokens'); -// } - -// splitNesting(right[2]).forEach(function (param) { -// abi.outputs!.push(parseParam(param)); -// }); -// } - -// if (abi.name === 'constructor') { -// abi.type = 'constructor'; - -// if (abi.outputs!.length) { -// throw new Error('constructor may not have outputs'); -// } - -// delete abi.name; -// delete abi.outputs; -// } - -// return abi; -// } - -// export function parseParamType(type: string): ParamType { -// return parseParam(type, true); -// } - -// // @TODO: Allow a second boolean to expose names -// export function formatParamType(paramType: ParamType): string { -// return getParamCoder(paramType).type; -// } - -// // @TODO: Allow a second boolean to expose names and modifiers -// export function formatSignature(fragment: EventFragment | FunctionFragment): string { -// return fragment.name + '(' + fragment.inputs.map(i => formatParamType(i)).join(',') + ')'; -// } - -// export function parseSignature(fragment: string): EventFragment | FunctionFragment { -// if (typeof fragment === 'string') { -// // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space -// fragment = fragment.replace(/\(/g, ' (').replace(/\)/g, ') ').replace(/\s+/g, ' '); -// fragment = fragment.trim(); - -// if (fragment.substring(0, 6) === 'event ') { -// return parseSignatureEvent(fragment.substring(6).trim()); -// } else { -// if (fragment.substring(0, 9) === 'function ') { -// fragment = fragment.substring(9); -// } -// return parseSignatureFunction(fragment.trim()); -// } -// } - -// throw new Error('unknown signature'); -// } - -/////////////////////////////////// -// Coders -/** - * Represents the result of a decoding operation, containing both the decoded value and the number of bytes consumed during the process. - * This type is used to return information from functions that decode binary data according to specific data types or encoding schemes. - */ -type DecodedResult = { - /** - * The number of bytes consumed during decoding. - */ - consumed: number; - /** - * The actual data value for the corresponding coder type. - */ - value: T; -}; -/** - * The Coder class is an abstract base class that provides encoding and decoding functionality - * for specific types in the Ethereum ABI (Application Binary Interface) format. It handles the - * conversion of Solidity types to JavaScript types and vice versa, allowing for easy interaction - * with Ethereum smart contracts. Each derived Coder class corresponds to a specific Solidity type, - * implementing the necessary logic for encoding and decoding values of that type. - */ -abstract class Coder { - readonly name: string; - readonly type: string; - readonly localName: string; - readonly dynamic: boolean; - constructor(name: string, type: string, localName = '', dynamic: boolean) { - this.name = name; - this.type = type; - this.localName = localName; - this.dynamic = dynamic; - } - - /** - * Encode the given value using the coder's type and rules. - * The function takes a value as input, processes it according to the specific - * coder implementation and returns a buffer containing the encoded value. - * Throws an error if the input value is not valid for the coder's type. - * - * @param value - The value to be encoded. - * @returns A Buffer containing the encoded value. - */ - abstract encode(value: any): Buffer; - /** - * Decodes the given data buffer at the specified offset using the coder's type and properties. - * Returns an object containing the number of bytes consumed during decoding and the decoded value. - * Throws an error if there is insufficient data or any issues encountered during the decoding process. - * - * @param data - The input data buffer to be decoded. - * @param offset - The starting position in the data buffer where decoding should begin. - * @returns A DecodedResult object with the 'consumed' and 'value' properties. - */ - abstract decode(data: Buffer, offset: number): DecodedResult; -} - -/** - * Clones the functionality of an existing Coder, but without a localName. - */ -class CoderAnonymous extends Coder { - constructor(private coder: Coder) { - super(coder.name, coder.type, undefined, coder.dynamic); - } - /** - * Encode the given value into a Buffer based on the coder type. - * This function handles various data types such as numbers, booleans, fixed bytes, and strings. - * Throws an error if the input value is invalid or not compatible with the coder type. - * - * @param value - The value to be encoded according to the coder type. - * @returns A Buffer containing the encoded value. - */ - encode(value: any): Buffer { - return this.coder.encode(value); - } - /** - * Decodes the given data starting from the specified offset using the associated coder. - * Returns an object containing the consumed bytes and the decoded value. - * Throws an error if there is insufficient data for decoding or any other issue occurs during decoding. - * - * @param data - The buffer containing the encoded data to be decoded. - * @param offset - The position in the buffer where the decoding should start. - * @returns An object with 'consumed' property indicating the number of bytes consumed during decoding, - * and 'value' property holding the decoded value. - */ - decode(data: Buffer, offset: number): DecodedResult { - return this.coder.decode(data, offset); - } -} - -/** - * CoderNull is a specific coder class for handling null values in encoding and decoding operations. - * It extends the base Coder class and provides custom implementations for encoding and decoding null values - * while complying with the Ethereum ABI specification. The encoded output for a null value is an empty buffer - * and consumes no data during the decoding process, returning a null value as the result. - */ -class CoderNull extends Coder { - constructor(localName: string) { - super('null', '', localName, false); - } - - /** - * Encode the given value using the Coder's type and rules. - * Converts various data types (boolean, number, string, etc.) into a Buffer representation - * based on the ABI encoding specifications. Throws an error if the input value is invalid - * or cannot be encoded according to the Coder's rules. - * - * @param value - The value to be encoded according to the Coder's type and rules. - * @returns A Buffer containing the encoded representation of the input value. - */ - encode(): Buffer { - return Buffer.alloc(0); - } - - /** - * Decodes the provided data buffer starting from the given offset and returns an object with - * the decoded value and the number of bytes consumed during the decoding process. - * This function is used to decode ABI-encoded data for the specific coder type. - * - * @param data - The buffer containing the ABI-encoded data to be decoded. - * @param offset - The index at which to start decoding in the data buffer. - * @returns An object with the following properties: - * - `value`: The decoded value according to the coder type. - * - `consumed`: The number of bytes consumed during the decoding process. - * @throws An error if there is insufficient data or the data is invalid for the coder type. - */ - decode(data: Buffer, offset: number): DecodedResult { - if (offset > data.length) { - throw new Error('invalid null'); - } - return { - consumed: 0, - value: null, - }; - } -} - -/** - * CoderNumber is a class that represents numeric values in the Ethereum ABI encoding/decoding process. - * It handles encoding and decoding of signed and unsigned integers of various sizes (number of bits). - * This class supports fixed-size integer types like int8, uint16, int256, etc. The encoded output - * is a Buffer of 32 bytes containing the value in big-endian format. When decoding, it returns the decoded - * result as a JavaScript BigInt or number (based on the size) along with the number of bytes consumed. - */ -class CoderNumber extends Coder { - readonly size: number; - readonly signed: boolean; - constructor(size: number, signed: boolean, localName: string) { - const name = (signed ? 'int' : 'uint') + size * 8; - super(name, name, localName, false); - - this.size = size; - this.signed = signed; - } - - /** - * Encodes the given array of values according to the CoderArray rules. - * The input value must be an array, and its length should match - * the length specified in the CoderArray instance. If the length is dynamic, - * any number of elements are allowed. Throws an error if the input is not an array - * or its length does not match the expected length. - * - * @param value - The array of values to be encoded. - * @returns A Buffer containing the encoded data. - */ - encode(value: any): Buffer { - try { - let v = BigInt(value); - if (this.signed) { - let bounds = BigInt(1) << BigInt(this.size * 8 - 1); - if (v > bounds) { - throw new Error(`out-of-bounds: ${v} > ${bounds}`); - } - bounds = (bounds + 1n) * NegativeOne; - if (v < bounds) { - throw new Error(`out-of-bounds: ${v} < ${bounds}`); - } - } else if (v < Zero || v >= BigInt(1) << BigInt(this.size * 8)) { - throw new Error(`out-of-bounds: 0 <= ${v} <= ${BigInt(1) << BigInt(this.size * 8)} `); - } - - if (this.signed && v < 0) { - // Compute twos complement. - const absV = v * -1n; - v = MaxUint256 - absV + 1n; - } - - return toBufferBE(v, 32); - } catch (error: any) { - return errors.throwError('invalid number value', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: this.name, - value: value, - msg: error.message, - size: this.size, - }); - } - } - - /** - * Decodes the provided data buffer at the specified offset using the current coder instance. - * Consumes a certain number of bytes from the data buffer and returns the decoded value along with the consumed byte count. - * Throws an error if there is insufficient data or any issues while decoding the given data. - * - * @param data - The data buffer to decode. - * @param offset - The starting offset in the data buffer for decoding. - * @returns An object containing the decoded value and the number of bytes consumed from the data buffer. - */ - decode(data: Buffer, offset: number): DecodedResult { - if (data.length < offset + 32) { - errors.throwError('insufficient data for ' + this.name + ' type', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: this.name, - value: bufferToHex(data.subarray(offset, offset + 32)), - }); - } - const junkLength = 32 - this.size; - let value = toBigIntBE(Buffer.from(data.subarray(offset + junkLength, offset + 32))); - if (this.signed && value > BigInt(1) << BigInt(this.size * 8 - 1)) { - value = value - MaxUint256 - 1n; - } - - return { - consumed: 32, - value: this.size <= 6 ? Number(value) : value, - }; - } -} -const uint256Coder = new CoderNumber(32, false, 'none'); - -/** - * CoderBoolean is a class that represents the 'bool' data type in Ethereum ABI encoding. - * It provides methods to encode and decode boolean values into their binary representation - * for use in Ethereum function calls and event logs. The class extends the abstract Coder class, - * inheriting its properties and methods while also implementing custom logic for handling boolean types. - * Instances of this class can be used to encode and decode boolean data, ensuring proper - * formatting and compatibility with the Ethereum blockchain. - */ -class CoderBoolean extends Coder { - constructor(localName: string) { - super('bool', 'bool', localName, false); - } - - /** - * Encodes the given value using the appropriate Coder, resulting in a Buffer. - * The encoded data can be later decoded using the corresponding 'decode' function. - * Throws an error if the input value is invalid or not compatible with the Coder type. - * - * @param value - The value to be encoded according to the Coder's type. - * @returns A Buffer containing the encoded data. - */ - encode(value: boolean): Buffer { - return uint256Coder.encode(value ? 1 : 0); - } - - /** - * Decodes the binary data from the provided buffer using the coder's associated type and offset. - * Throws an error if there is insufficient data, or if the decoded value does not match the expected format. - * - * @param data - The buffer containing the binary data to decode. - * @param offset - The starting position within the buffer to begin decoding. - * @returns An object containing the number of bytes consumed and the decoded value of the specified type. - */ - decode(data: Buffer, offset: number): DecodedResult { - try { - const result = uint256Coder.decode(data, offset); - return { - consumed: result.consumed, - value: !!Number(result.value), - }; - } catch (error: any) { - if (error.reason === 'insufficient data for uint256 type') { - errors.throwError('insufficient data for boolean type', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'boolean', - value: error.value, - }); - } - throw error; - } - } -} - -/** - * The CoderFixedBytes class is responsible for encoding and decoding fixed-length byte arrays in ABI format. - * It inherits from the Coder base class and provides methods to encode and decode values of 'bytes' type with a specified length. - * The encoded data is compatible with Ethereum smart contracts, and this class plays a vital role in handling contract interactions. - */ -class CoderFixedBytes extends Coder { - readonly length: number; - constructor(length: number, localName: string) { - const name = 'bytes' + length; - super(name, name, localName, false); - this.length = length; - } - - /** - * Encodes the given value using the coder and returns a Buffer. - * This function handles various data types such as numbers, booleans, fixed bytes, - * addresses, dynamic bytes, strings, arrays and tuples. It validates the input value - * based on the coder properties and converts them into a suitable binary format - * compatible with Ethereum encoding standards. - * - * @param value - The value to be encoded. - * @returns A Buffer containing the encoded value. - */ - encode(value: Buffer | string): Buffer { - if (typeof value === 'string') { - value = hexToBuffer(value); - } - - try { - if (value.length > this.length) { - throw new Error(`incorrect data length`); - } - } catch (error: any) { - errors.throwError('invalid ' + this.name + ' value', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: this.name, - value: error.value || value, - }); - } - - return value; - } - - /** - * Decode the given data buffer starting from the specified offset using the implemented coder. - * Returns an object containing the decoded value and the number of bytes consumed during decoding. - * Throws an error if the input data is insufficient or invalid for the implemented coder type. - * - * @param data - The data buffer to be decoded. - * @param offset - The starting index for decoding in the data buffer. - * @returns DecodedResult object containing the decoded value and the consumed bytes count. - */ - decode(data: Buffer, offset: number): DecodedResult { - if (data.length < offset + 32) { - errors.throwError('insufficient data for ' + name + ' type', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: this.name, - value: bufferToHex(data.subarray(offset, offset + 32)), - }); - } - - return { - consumed: 32, - // TODO: Just return buffer. - value: bufferToHex(Buffer.from(data.subarray(offset, offset + this.length))), - }; - } -} - -/** - * The CoderAddress class extends the Coder base class, providing specific encoding and decoding - * functionality for Ethereum addresses. It ensures that address values are properly formatted - * and converted between different representations such as strings, BigNumber, and hexadecimal. - * This class facilitates ABI encoding and decoding of contract function parameters and event logs - * that involve Ethereum addresses. - */ -class CoderAddress extends Coder { - constructor(localName: string) { - super('address', 'address', localName, false); - } - - /** - * Encode the provided value according to the Coder type rules. - * This function converts any given value into a Buffer format based on the specific - * encoding rules defined for each Coder type, such as address, boolean, number, etc. - * Throws an error if the input value is not compatible with the Coder type or if - * any internal encoding operation fails. - * - * @param value - The value to be encoded according to the Coder rules. - * @returns A Buffer instance containing the encoded value. - */ - encode(value: EthAddress | string): Buffer { - if (typeof value === 'string') { - value = EthAddress.fromString(value); - } - try { - return value.toBuffer32(); - } catch (error: any) { - errors.throwError(`invalid address (${error.message})`, errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'address', - value: value.toString(), - }); - } - } - - /** - * Decode the data buffer at the given offset according to the coder's type. - * This function extracts and interprets the relevant data from the buffer based on the coder specification, - * consuming a specific number of bytes in the process. It returns an object containing the decoded value - * and the number of bytes consumed during decoding. - * - * @param data - The data buffer to decode. - * @param offset - The starting offset within the data buffer to begin decoding. - * @returns An object containing the decoded value and the number of bytes consumed during decoding. - */ - decode(data: Buffer, offset: number): DecodedResult { - if (data.length < offset + 32) { - errors.throwError('insufficuent data for address type', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'address', - value: bufferToHex(data.subarray(offset, offset + 32)), - }); - } - return { - consumed: 32, - value: new EthAddress(Buffer.from(data.subarray(offset + 12, offset + 32))), - }; - } -} - -/** - * Encodes the given dynamic bytes value into a buffer with its length as a prefix. - * The function first encodes the length of the byte array as a uint256 and then concatenates - * the actual byte array followed by padding to align it to 32-byte boundary. - * - * @param value - The buffer or hex string representing the dynamic bytes value to be encoded. - * @returns A buffer containing the encoded dynamic bytes value, including length prefix and proper padding. - */ -function _encodeDynamicBytes(value: Buffer): Buffer { - const dataLength = 32 * Math.ceil(value.length / 32); - const padding = new Buffer(dataLength - value.length); - - return Buffer.concat([uint256Coder.encode(value.length), value, padding]); -} - -/** - * Decodes dynamic bytes from a given data buffer at the specified offset. - * Handles errors such as insufficient data, and returns an object containing - * the consumed size (number of bytes used) and the resulting value (the decoded bytes). - * - * @param data - The data buffer to decode from. - * @param offset - The starting position in the data buffer to begin decoding. - * @param localName - The name of the argument being processed, used for error reporting. - * @returns An object containing the number of bytes consumed and the decoded bytes as a Buffer. - */ -function _decodeDynamicBytes(data: Buffer, offset: number, localName: string): DecodedResult { - if (data.length < offset + 32) { - errors.throwError('insufficient data for dynamicBytes length', errors.INVALID_ARGUMENT, { - arg: localName, - coderType: 'dynamicBytes', - value: bufferToHex(data.subarray(offset, offset + 32)), - }); - } - - const lengthBI = uint256Coder.decode(data, offset).value; - if (lengthBI > Number.MAX_SAFE_INTEGER) { - errors.throwError('dynamic bytes count too large', errors.INVALID_ARGUMENT, { - arg: localName, - coderType: 'dynamicBytes', - value: lengthBI.toString(), - }); - } - const length = Number(lengthBI); - - if (data.length < offset + 32 + length) { - errors.throwError('insufficient data for dynamicBytes type', errors.INVALID_ARGUMENT, { - arg: localName, - coderType: 'dynamicBytes', - value: bufferToHex(data.subarray(offset, offset + 32 + length)), - }); - } - - return { - consumed: 32 + 32 * Math.ceil(length / 32), - value: data.subarray(offset + 32, offset + 32 + length), - }; -} - -/** - * The CoderDynamicBytes class is a coder for encoding and decoding dynamic bytes data types in ABI. - * It handles the variable-length byte arrays, allowing efficient serialization and deserialization of - * such data while interacting with the Ethereum blockchain through smart contracts. The class extends the - * base Coder class and overrides its methods to provide specific implementation for dynamic bytes. - */ -class CoderDynamicBytes extends Coder { - constructor(localName: string) { - super('bytes', 'bytes', localName, true); - } - - /** - * Encodes the input values according to the specified ABI types, returning a hex-encoded string of the packed data. - * This function takes an array of types and an array of corresponding values as input, and generates a representation - * that can be used in Ethereum smart contracts for function calls or events. - * - * @param types - An array of strings or ParamType objects describing the types of the input values. - * @param values - An array of input values matching the types specified in the "types" parameter. - * @returns A hex-encoded string representing the packed data according to the ABI types. - */ - encode(value: Buffer | string): Buffer { - try { - if (typeof value === 'string') { - value = hexToBuffer(value); - } - return _encodeDynamicBytes(value); - } catch (error: any) { - return errors.throwError('invalid bytes value', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'bytes', - value: error.value, - }); - } - } - - /** - * Decodes the given data according to the specified parameter types. - * The types array represents the data types of the expected decoding results, - * where each type is either a string or a ParamType object. - * The data argument should be a buffer containing the encoded data. - * Returns an array of decoded values, with each value corresponding to the provided types. - * - * @param types - An array of strings or ParamType objects representing the data types to decode. - * @param data - A Buffer containing the encoded data to be decoded. - * @returns An array of decoded values corresponding to the specified types. - */ - decode(data: Buffer, offset: number): DecodedResult { - const result = _decodeDynamicBytes(data, offset, this.localName); - result.value = bufferToHex(result.value); - return result; - } -} - -/** - * The CoderString class is responsible for encoding and decoding string values in the ABI format. - * It inherits from the Coder class and overrides the encode and decode methods to specifically handle - * string data types. This class enables efficient and accurate serialization and deserialization - * of string values within the context of Ethereum contract function calls and events. - */ -class CoderString extends Coder { - constructor(localName: string) { - super('string', 'string', localName, true); - } - - /** - * Encodes the given types and values into a single ABI-formatted hex string. - * The types array should contain a list of type strings or ParamType objects that describe each value's type. - * The values array should have the same length as the types array and contain the data to be encoded. - * Throws an error if the types/values length mismatch or if any invalid argument is encountered during encoding. - * - * @param types - An array of type strings or ParamType objects describing each value's type. - * @param values - An array of values corresponding to the types provided. - * @returns A hex-encoded ABI-formatted string representing the encoded values. - */ - encode(value: string): Buffer { - if (typeof value !== 'string') { - errors.throwError('invalid string value', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'string', - value: value, - }); - } - return _encodeDynamicBytes(Buffer.from(new TextEncoder().encode(value))); - } - - /** - * Decodes the ABI-encoded data based on the specified input types. - * Takes an array of input types (strings or ParamType objects) and a buffer containing - * the ABI-encoded data. Returns an array or an object containing the decoded values, depending - * on whether the local names are available in the input types. If any error occurs during decoding, - * it throws an exception with a detailed message about the issue. - * - * @param types - An array of input types, either as strings or ParamType objects. - * @param data - A Buffer containing the ABI-encoded data to decode. - * @returns An array or an object containing the decoded values based on the input types. - */ - decode(data: Buffer, offset: number): DecodedResult { - const result = _decodeDynamicBytes(data, offset, this.localName); - result.value = new TextDecoder('utf-8').decode(result.value); - return result; - } -} - -/** - * Calculate the aligned size of a value, rounding up to the nearest multiple of 32. - * This function is commonly used when dealing with tightly packed data structures in - * ABI encoding and decoding where data needs to be aligned to 32-byte boundaries. - * - * @param size - The original size of a value in bytes. - * @returns The aligned size, rounded up to the nearest multiple of 32 bytes. - */ -function alignSize(size: number): number { - return 32 * Math.ceil(size / 32); -} - -/** - * Packs an array of values according to their respective coders into a single Buffer. - * The 'coders' and 'values' arrays must have the same length. Each value in the 'values' array - * will be encoded using its corresponding coder in the 'coders' array, then combined into - * a single Buffer with proper padding and dynamic content offsets. - * - * @param coders - An array of Coder instances used to encode each value. - * @param values - An array of values to be packed together into a single Buffer. - * @returns A Buffer containing the packed values according to their coders. - */ -function pack(coders: Array, values: Array): Buffer { - if (Array.isArray(values)) { - // do nothing - } else if (values && typeof values === 'object') { - const arrayValues: Array = []; - coders.forEach(function (coder) { - arrayValues.push((values)[coder.localName]); - }); - values = arrayValues; - } else { - errors.throwError('invalid tuple value', errors.INVALID_ARGUMENT, { - coderType: 'tuple', - value: values, - }); - } - - if (coders.length !== values.length) { - errors.throwError('types/value length mismatch', errors.INVALID_ARGUMENT, { - coderType: 'tuple', - value: values, - }); - } - - const parts: Array<{ - /** - * Indicates if the coder has a dynamic size. - */ - /** - * Indicates if the coder has a dynamic size. - */ - dynamic: boolean; - /** - * The encoded or decoded value based on the ABI data type. - */ - /** - * The encoded or decoded value based on the ABI data type. - */ - value: any; - }> = []; - - coders.forEach(function (coder, index) { - parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) }); - }); - - let staticSize = 0, - dynamicSize = 0; - parts.forEach(function (part) { - if (part.dynamic) { - staticSize += 32; - dynamicSize += alignSize(part.value.length); - } else { - staticSize += alignSize(part.value.length); - } - }); - - let offset = 0, - dynamicOffset = staticSize; - const data = new Buffer(staticSize + dynamicSize); - - parts.forEach(function (part) { - if (part.dynamic) { - data.set(uint256Coder.encode(dynamicOffset), offset); - offset += 32; - - data.set(part.value, dynamicOffset); - dynamicOffset += alignSize(part.value.length); - } else { - data.set(part.value, offset); - offset += alignSize(part.value.length); - } - }); - - return data; -} - -/** - * Unpack the values from the provided coders and data buffer at the specified offset. - * The function iterates through each coder, decodes its corresponding value in the data buffer, - * and appends it to an array of decoded values. If the coder has a localName, the decoded value - * is also assigned to the resulting object using the localName as the key. - * - * @param coders - Array of Coder instances to decode the data buffer. - * @param data - Buffer containing the encoded data to be unpacked. - * @param offset - The starting position of the data buffer to begin decoding from. - * @returns An object with two properties: 'value', which is an array of decoded values, and 'consumed', which is the number of bytes consumed during decoding. - */ -function unpack(coders: Array, data: Buffer, offset: number): DecodedResult { - const baseOffset = offset; - let consumed = 0; - const value: any = []; - coders.forEach(function (coder) { - let result; - if (coder.dynamic) { - const dynamicOffset = uint256Coder.decode(data, offset); - result = coder.decode(data, baseOffset + Number(dynamicOffset.value)); - // The dynamic part is leap-frogged somewhere else; doesn't count towards size - result.consumed = dynamicOffset.consumed; - } else { - result = coder.decode(data, offset); - } - - if (result.value != undefined) { - value.push(result.value); - } - - offset += result.consumed; - consumed += result.consumed; - }); - - coders.forEach(function (coder: Coder, index: number) { - let name: string = coder.localName; - if (!name) { - return; - } - - if (name === 'length') { - name = '_length'; - } - - if (value[name] != null) { - return; - } - - value[name] = value[index]; - }); - - return { - value: value, - consumed: consumed, - }; -} - -/** - * The CoderArray class extends the Coder class for encoding and decoding array data types in Ethereum ABI. - * It handles fixed-size arrays (e.g., uint256[5]) and dynamic-size arrays (e.g., address[]), providing - * methods to encode and decode values according to the specified element type and length. By leveraging - * the base Coder implementation and an additional coder for nested elements, CoderArray ensures proper - * handling of both simple and complex arrays within contract function signatures and event topics. - */ -class CoderArray extends Coder { - readonly coder: Coder; - readonly length: number; - constructor(coder: Coder, length: number, localName: string) { - const type = coder.type + '[' + (length >= 0 ? length : '') + ']'; - const dynamic = length === -1 || coder.dynamic; - super('array', type, localName, dynamic); - - this.coder = coder; - this.length = length; - } - - /** - * Encode the given input types and values into a hexadecimal string according to the ABI specification. - * The function takes an array of types and values, and encodes them into a single data string, - * which can be used for contract function calls or event encoding. The types array should contain - * strings representing Ethereum Solidity types (e.g. 'uint256', 'address', 'bytes32'), - * and the values array should contain corresponding JavaScript values to be encoded. - * Throws an error if the types and values length mismatch or if there's an issue during encoding. - * - * @param types - An array of strings or ParamType objects representing the Ethereum Solidity types. - * @param values - An array of JavaScript values corresponding to the input types. - * @returns A hex-encoded string of the encoded input types and values. - */ - encode(value: Array): Buffer { - if (!Array.isArray(value)) { - errors.throwError('expected array value', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'array', - value: value, - }); - } - - let count = this.length; - - let result = new Buffer(0); - if (count === -1) { - count = value.length; - result = uint256Coder.encode(count); - } - - errors.checkArgumentCount(count, value.length, 'in coder array' + (this.localName ? ' ' + this.localName : '')); - - const coders: any[] = []; - for (let i = 0; i < value.length; i++) { - coders.push(this.coder); - } - - return Buffer.concat([result, pack(coders, value)]); - } - - /** - * Decodes the ABI (Application Binary Interface) encoded data based on the specified types. - * The function takes an array of type descriptors and a buffer containing the ABI encoded data, - * and returns an object with decoded values. - * - * @param types - An array of type descriptors, either as strings or ParamType objects. - * @param data - A Buffer containing the ABI encoded data to be decoded. - * @returns - An object with the decoded values based on the provided types. - */ - decode(data: Buffer, offset: number) { - // @TODO: - //if (data.length < offset + length * 32) { throw new Error('invalid array'); } - - let consumed = 0; - - let count = this.length; - - if (count === -1) { - let decodedLength: any; - try { - decodedLength = uint256Coder.decode(data, offset); - } catch (error: any) { - return errors.throwError('insufficient data for dynamic array length', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'array', - value: error.value, - }); - } - if (decodedLength.value > Number.MAX_SAFE_INTEGER) { - errors.throwError('array count too large', errors.INVALID_ARGUMENT, { - arg: this.localName, - coderType: 'array', - value: decodedLength.value.toString(), - }); - } - count = Number(decodedLength.value); - consumed += decodedLength.consumed; - offset += decodedLength.consumed; - } - - const coders: any[] = []; - for (let i = 0; i < count; i++) { - coders.push(new CoderAnonymous(this.coder)); - } - - const result = unpack(coders, data, offset); - result.consumed += consumed; - return result; - } -} - -/** - * The CoderTuple class is responsible for encoding and decoding tuple data types in the ABI encoding format. - * It extends the Coder class and takes an array of coders representing each component. - * When encoding, it processes the components using the appropriate coder instances and returns the encoded data. - * When decoding, it parses the encoded data and constructs the tuple by applying each coder's decode method to their respective components. - */ -class CoderTuple extends Coder { - constructor(private coders: Array, localName: string) { - let dynamic = false; - const types: Array = []; - coders.forEach(function (coder) { - if (coder.dynamic) { - dynamic = true; - } - types.push(coder.type); - }); - const type = 'tuple(' + types.join(',') + ')'; - - super('tuple', type, localName, dynamic); - this.coders = coders; - } - - /** - * Encodes the given function signature with the corresponding parameter types and values. - * This function takes an array of parameter types, such as strings or ParamType objects, - * and an array of corresponding parameter values to generate the ABI-encoded data. - * The generated encoded data is useful for interacting with smart contracts. - * Throws an error if the length of the input types and values mismatch. - * - * @param types - An array of parameter types represented as strings or ParamType objects. - * @param values - An array of corresponding values to be encoded with the parameter types. - * @returns A hex-encoded string representing the ABI-encoded data. - */ - encode(value: Array): Buffer { - return pack(this.coders, value); - } - - /** - * Decodes the provided data using the specified input types and returns an array of decoded values. - * The input 'types' is an array of either strings or ParamType objects representing the expected data types. - * The input 'data' should be a Buffer containing the encoded data to decode. - * Throws an error if the number of input types does not match the number of values in the data or if decoding fails. - * - * @param types - Array of strings or ParamType objects representing the expected data types. - * @param data - Buffer containing the encoded data to decode. - * @returns An array of decoded values. - */ - decode(data: Buffer, offset: number): DecodedResult { - const result = unpack(this.coders, data, offset); - return result; - } -} - -// function splitNesting(value: string): Array { -// value = value.trim(); - -// var result: string[] = []; -// var accum = ''; -// var depth = 0; -// for (var offset = 0; offset < value.length; offset++) { -// var c = value[offset]; -// if (c === ',' && depth === 0) { -// result.push(accum); -// accum = ''; -// } else { -// accum += c; -// if (c === '(') { -// depth++; -// } else if (c === ')') { -// depth--; -// if (depth === -1) { -// throw new Error('unbalanced parenthsis'); -// } -// } -// } -// } -// if (accum) { -// result.push(accum); -// } - -// return result; -// } - -const paramTypeSimple: { [key: string]: any } = { - address: CoderAddress, - bool: CoderBoolean, - string: CoderString, - bytes: CoderDynamicBytes, -}; - -/** - * Creates a CoderTuple instance from an array of components with their corresponding local names. - * The 'components' should be an array of ParamType objects, each containing the type and name of each component. - * Throws an error if the input components are invalid or any ParamType is not supported. - * - * @param components - An array of ParamType objects representing the components of the tuple. - * @param localName - The string representing the local name of the tuple. - * @returns A CoderTuple instance for encoding and decoding the tuple values. - */ -function getTupleParamCoder(components: Array, localName: string): CoderTuple { - if (!components) { - components = []; - } - const coders: Array = []; - components.forEach(function (component) { - coders.push(getParamCoder(component)); - }); - - return new CoderTuple(coders, localName); -} - -/** - * Returns an instance of the appropriate Coder class based on the given ParamType. - * This function is responsible for selecting the correct coder to handle encoding and - * decoding of various data types specified in the ABI. It supports basic types like 'address', - * 'bool', 'string', and 'bytes', as well as more complex types like fixed-size arrays, dynamic arrays, - * and tuples with nested components. - * - * @param param - The ParamType object containing the type and name of the parameter. - * @returns An instance of a Coder subclass corresponding to the given ParamType. - */ -function getParamCoder(param: ParamType): Coder { - const coder = paramTypeSimple[param.type]; - if (coder) { - return new coder(param.name); - } - let match = param.type.match(paramTypeNumber); - if (match) { - const size = parseInt(match[2] || '256'); - if (size === 0 || size > 256 || size % 8 !== 0) { - return errors.throwError('invalid ' + match[1] + ' bit length', errors.INVALID_ARGUMENT, { - arg: 'param', - value: param, - }); - } - return new CoderNumber(size / 8, match[1] === 'int', param.name!); - } - - match = param.type.match(paramTypeBytes); - if (match) { - const size = parseInt(match[1]); - if (size === 0 || size > 32) { - errors.throwError('invalid bytes length', errors.INVALID_ARGUMENT, { - arg: 'param', - value: param, - }); - } - return new CoderFixedBytes(size, param.name!); - } - - match = param.type.match(paramTypeArray); - if (match) { - const size = parseInt(match[2] || '-1'); - param = { - ...param, - type: match[1], - }; - return new CoderArray(getParamCoder(param), size, param.name!); - } - - if (param.type.substring(0, 5) === 'tuple') { - return getTupleParamCoder(param.components!, param.name!); - } - - if (param.type === '') { - return new CoderNull(param.name!); - } - - return errors.throwError('invalid type', errors.INVALID_ARGUMENT, { - arg: 'type', - value: param.type, - }); -} - -/** - * The AbiCoder class provides an interface for encoding and decoding contract function calls and events - * using Ethereum's Application Binary Interface (ABI). It supports the conversion of Solidity data types - * to JavaScript and vice versa. This class enables encoding of function arguments for contract method calls, - * as well as decoding of event logs and return values from transactions and contract calls. - */ -export class AbiCoder { - constructor() {} - - /** - * Encodes the given types and values into a hex-encoded ABI string. - * Takes an array of types (strings or ParamType objects) and an array of corresponding values. - * Each type in the 'types' array should have a corresponding value in the 'values' array. - * Throws an error if the length of types and values arrays do not match, or if there are any issues during encoding. - * - * @param types - An array of strings or ParamType objects representing the data types. - * @param values - An array of values corresponding to the types. - * @returns A hex-encoded string representing the encoded ABI data. - */ - encode(types: Array, values: Array): string { - if (types.length !== values.length) { - errors.throwError('types/values length mismatch', errors.INVALID_ARGUMENT, { - count: { types: types.length, values: values.length }, - value: { types: types, values: values }, - }); - } - - const coders: Array = []; - types.forEach(type => { - // Convert types to type objects - // - "uint foo" => { type: "uint", name: "foo" } - // - "tuple(uint, uint)" => { type: "tuple", components: [ { type: "uint" }, { type: "uint" }, ] } - - let typeObject: ParamType; - if (typeof type === 'string') { - typeObject = parseParam(type); - } else { - typeObject = type; - } - - coders.push(getParamCoder(typeObject)); - }); - - return bufferToHex(new CoderTuple(coders, '_').encode(values)); - } - - /** - * Decodes the ABI-encoded data using the provided array of types and returns the corresponding values. - * Each type can be a string or a ParamType object, which includes type information and an optional name. - * The input 'data' should be a valid ABI-encoded Buffer. - * Throws an error if the types and data do not match, or if any decoding issues occur. - * - * @param types - An array of strings or ParamType objects representing the expected types of the decoded data. - * @param data - A Buffer containing the ABI-encoded data to be decoded. - * @returns An array or an object containing the decoded values, with optional keys if names are provided in the types. - */ - decode(types: Array, data: Buffer): any { - const coders = types.map(type => { - if (typeof type === 'string') { - type = parseParam(type); - } - return getParamCoder(type); - }); - - return new CoderTuple(coders, '_').decode(data, 0).value; - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/ethers/errors.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/ethers/errors.ts deleted file mode 100644 index 5e284c83b2a..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/ethers/errors.ts +++ /dev/null @@ -1,83 +0,0 @@ -// Unknown Error -export const UNKNOWN_ERROR = 'UNKNOWN_ERROR'; - -// Invalid argument (e.g. value is incompatible with type) to a function: -// - arg: The argument name that was invalid -// - value: The value of the argument -export const INVALID_ARGUMENT = 'INVALID_ARGUMENT'; - -// Missing argument to a function: -// - count: The number of arguments received -// - expectedCount: The number of arguments expected -export const MISSING_ARGUMENT = 'MISSING_ARGUMENT'; - -// Too many arguments -// - count: The number of arguments received -// - expectedCount: The number of arguments expected -export const UNEXPECTED_ARGUMENT = 'UNEXPECTED_ARGUMENT'; - -const _censorErrors = false; - -/** - * Throws a detailed error with a custom message, code, and additional information. - * The error message can be censored by setting the '_censorErrors' variable to true. - * In that case, a generic 'unknown error' message will be thrown instead of the custom message. - * - * @param message - The custom error message to display. - * @param code - The specific error code for this error (default is UNKNOWN_ERROR). - * @param params - An object containing additional information related to the error. - * @returns - This function always throws an error and does not return any value. - */ -export function throwError(message: string, code: string = UNKNOWN_ERROR, params: any = {}): never { - if (_censorErrors) { - throw new Error('unknown error'); - } - - const messageDetails: Array = []; - Object.keys(params).forEach(key => { - try { - messageDetails.push(key + '=' + JSON.stringify(params[key])); - } catch (error) { - messageDetails.push(key + '=' + JSON.stringify(params[key].toString())); - } - }); - messageDetails.push('version=1'); - - const reason = message; - if (messageDetails.length) { - message += ' (' + messageDetails.join(', ') + ')'; - } - - // @TODO: Any?? - const error: any = new Error(message); - error.reason = reason; - error.code = code; - - Object.keys(params).forEach(function (key) { - error[key] = params[key]; - }); - - throw error; -} - -/** - * Validates the number of arguments provided against the expected count and throws an error if they do not match. - * This function is useful for checking the right number of arguments are passed to a function, especially in cases - * where optional arguments are involved. It appends a custom message suffix when provided. - * - * @param count - The actual number of arguments received by the function. - * @param expectedCount - The expected number of arguments for the function. - * @param suffix - Optional string to be appended to the error message when thrown. - * @throws If either too few or too many arguments are provided. - */ -export function checkArgumentCount(count: number, expectedCount: number, suffix?: string): void { - if (!suffix) { - suffix = ''; - } - if (count < expectedCount) { - throwError('missing argument' + suffix, MISSING_ARGUMENT, { count: count, expectedCount: expectedCount }); - } - if (count > expectedCount) { - throwError('too many arguments' + suffix, UNEXPECTED_ARGUMENT, { count: count, expectedCount: expectedCount }); - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/abi-coder/index.ts b/yarn-project/ethereum.js/src/contract/abi/abi-coder/index.ts deleted file mode 100644 index 1c55bbaa3f1..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/abi-coder/index.ts +++ /dev/null @@ -1,321 +0,0 @@ -import { keccak256String } from '../../../crypto/index.js'; -import { AbiCoder as EthersAbi } from './ethers/abi-coder.js'; -import { AbiInput } from '../contract_abi_definition.js'; -import { hexToBuffer } from '../../../hex_string/index.js'; - -/** - * ABICoder prototype should be used to encode/decode solidity params of any type. - */ -export class ABICoder { - private ethersAbiCoder: EthersAbi; - - constructor() { - this.ethersAbiCoder = new EthersAbi(); - } - - /** - * EncodeFunctionSignature. - * Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types. - * @param functionName - Name of the function. - * @returns Encoded function name. - */ - public encodeFunctionSignature(functionName) { - if (typeof functionName === 'object') { - functionName = this.abiMethodToString(functionName); - } - - return '0x' + keccak256String(functionName).slice(0, 8); - } - - /** - * Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types. - *EncodeEventSignature. - * @param functionName - Name of the function. - * @returns Encoded function name. - */ - public encodeEventSignature(functionName) { - if (typeof functionName === 'object') { - functionName = this.abiMethodToString(functionName); - } - - return '0x' + keccak256String(functionName); - } - - /** - * Should be used to encode plain param. - * EncodeParameter. - * @param type - Type of the param. - * @param param - Param to be encoded. - * @returns Encoded plain param. - */ - public encodeParameter(type, param) { - return this.encodeParameters([type], [param]); - } - - /** - * Should be used to encode list of params. - * EncodeParameters. - * @param types - Array of types. - * @param params - Params to be encoded. - * @returns Encoded list of params. - */ - public encodeParameters(types, params) { - return hexToBuffer(this.ethersAbiCoder.encode(this.mapTypes(types), params)); - } - - /** - * Encodes a function call from its json interface and parameters. - * EncodeFunctionCall. - * @param jsonInterface - Interface of the function call represented in JSON. - * @param params - Parameters of the function call. - * @returns The encoded ABI for this function call. - */ - public encodeFunctionCall(jsonInterface, params) { - return ( - this.encodeFunctionSignature(jsonInterface) + this.encodeParameters(jsonInterface.inputs, params).toString('hex') - ); - } - - /** - * Should be used to decode bytes to plain param. - * DecodeParameter. - * @param type - Of param. - * @param bytes - To be decoded. - * @returns Plain param. - */ - public decodeParameter(type, bytes: Buffer | string) { - return this.decodeParameters([type], bytes)[0]; - } - - /** - * Should be used to decode list of params. - * @returns Decoded list of params. - */ - public decodeParameters(outputs, bytes: Buffer | string): { [k: string | number]: any } { - const returnValue: { [k: string | number]: any } = { __length__: 0 }; - - if (typeof bytes === 'string') { - bytes = hexToBuffer(bytes); - } - - if (!bytes || bytes.length === 0) { - if (outputs.length === 0) { - return returnValue; - } - throw new Error('decodeParameters: Buffer length is 0.'); - } - - const res = this.ethersAbiCoder.decode(this.mapTypes(outputs), bytes); - - outputs.forEach((output, i) => { - let decodedValue = res[returnValue.__length__]; - decodedValue = decodedValue === '0x' ? null : decodedValue; - - returnValue[i] = decodedValue; - - if (typeof output === 'object' && output.name) { - returnValue[output.name] = decodedValue; - } - - returnValue.__length__++; - }); - - return returnValue; - } - - /** - * Decodes events non- and indexed parameters. - * DecodeLog. - * @param inputs - Abi inputs. - * @param data - Event data. - * @param topics - Event topics. - * @returns Array of plain params. - */ - public decodeLog(inputs: AbiInput[], data, topics) { - topics = Array.isArray(topics) ? topics : [topics]; - - data = data || ''; - - const notIndexedInputs: any[] = []; - const indexedParams: any[] = []; - let topicCount = 0; - - // TODO check for anonymous logs? - - inputs.forEach((input, i) => { - if (input.indexed) { - indexedParams[i] = ['bool', 'int', 'uint', 'address', 'fixed', 'ufixed'].some(t => input.type.includes(t)) - ? this.decodeParameter(input.type, topics[topicCount]) - : topics[topicCount]; - topicCount++; - } else { - notIndexedInputs[i] = input; - } - }); - - const nonIndexedData = data; - const notIndexedParams = - nonIndexedData && nonIndexedData !== '0x' ? this.decodeParameters(notIndexedInputs, nonIndexedData) : []; - - const returnValue: any = {}; - returnValue.__length__ = 0; - - inputs.forEach((res, i) => { - returnValue[i] = res.type === 'string' ? '' : null; - - if (typeof notIndexedParams[i] !== 'undefined') { - returnValue[i] = notIndexedParams[i]; - } - if (typeof indexedParams[i] !== 'undefined') { - returnValue[i] = indexedParams[i]; - } - - if (res.name) { - returnValue[res.name] = returnValue[i]; - } - - returnValue.__length__++; - }); - - return returnValue; - } - - /** - * Map types if simplified format is used. - * MapTypes. - * @param types - Types to be mapped. - * @returns Array. - */ - private mapTypes(types) { - const mappedTypes: any[] = []; - types.forEach(type => { - if (this.isSimplifiedStructFormat(type)) { - const structName = Object.keys(type)[0]; - mappedTypes.push( - Object.assign(this.mapStructNameAndType(structName), { - components: this.mapStructToCoderFormat(type[structName]), - }), - ); - - return; - } - - mappedTypes.push(type); - }); - - return mappedTypes; - } - - /** - * Check if type is simplified struct format. - * IsSimplifiedStructFormat. - * @param type - The type. - * @returns A boolean. - */ - private isSimplifiedStructFormat(type) { - return typeof type === 'object' && typeof type.components === 'undefined' && typeof type.name === 'undefined'; - } - - /** - * Maps the correct tuple type and name when the simplified format in encode/decodeParameter is used. - * MapStructNameAndType. - * @param structName - Name. - * @returns \{type: string, name: *\}. - */ - private mapStructNameAndType(structName) { - let type = 'tuple'; - - if (structName.indexOf('[]') > -1) { - type = 'tuple[]'; - structName = structName.slice(0, -2); - } - - return { type, name: structName }; - } - - /** - * Maps the simplified format in to the expected format of the ABICoder. - * MapStructToCoderFormat. - * @param struct - Simplified format. - * @returns Array. - */ - private mapStructToCoderFormat(struct) { - const components: any[] = []; - Object.keys(struct).forEach(key => { - if (typeof struct[key] === 'object') { - components.push( - Object.assign(this.mapStructNameAndType(key), { - components: this.mapStructToCoderFormat(struct[key]), - }), - ); - - return; - } - - components.push({ - name: key, - type: struct[key], - }); - }); - - return components; - } - - /** - * Should be used to create full function/event name from json abi. - * JsonInterfaceMethodToString. - * @param json - JSON abi. - * @returns Full function/event name. - */ - public abiMethodToString(json) { - if (typeof json === 'object' && json.name && json.name.indexOf('(') !== -1) { - return json.name; - } - - return json.name + '(' + flattenTypes(false, json.inputs).join(',') + ')'; - } -} - -/** - * Should be used to flatten json abi inputs/outputs into an array of type-representing-strings. - * FlattenTypes. - * @param includeTuple - Bool. - * @param puts - Inputs/outputs. - * @returns Array of Parameters as strings. - */ -function flattenTypes(includeTuple: boolean, puts: any[]) { - // console.log("entered _flattenTypes. inputs/outputs: " + puts) - const types: any[] = []; - - puts.forEach(param => { - if (typeof param.components === 'object') { - if (param.type.substring(0, 5) !== 'tuple') { - throw new Error('components found but type is not tuple; report on GitHub'); - } - let suffix = ''; - const arrayBracket = param.type.indexOf('['); - if (arrayBracket >= 0) { - suffix = param.type.substring(arrayBracket); - } - const result = flattenTypes(includeTuple, param.components); - // console.log("result should have things: " + result) - if (Array.isArray(result) && includeTuple) { - // console.log("include tuple word, and its an array. joining...: " + result.types) - types.push('tuple(' + result.join(',') + ')' + suffix); - } else if (!includeTuple) { - // console.log("don't include tuple, but its an array. joining...: " + result) - types.push('(' + result.join(',') + ')' + suffix); - } else { - // console.log("its a single type within a tuple: " + result.types) - types.push('(' + result + ')'); - } - } else { - // console.log("its a type and not directly in a tuple: " + param.type) - types.push(param.type); - } - }); - - return types; -} - -export const abiCoder = new ABICoder(); diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_abi.test.ts b/yarn-project/ethereum.js/src/contract/abi/contract_abi.test.ts deleted file mode 100644 index 49635cbbdc2..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_abi.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { ContractAbi } from './contract_abi.js'; - -describe('contract', () => { - describe('contract-abi', () => { - it('should correctly decode tx data', () => { - const testContractAbi = new ContractAbi([ - { - name: 'myOtherMethod', - type: 'function', - inputs: [ - { - type: 'uint16', - name: 'myNumberdd', - }, - { - type: 'bytes32', - name: 'myBytes', - }, - ], - }, - { - name: 'hasALotOfParams', - inputs: [ - { - name: 'var1', - type: 'bytes32', - }, - { - name: 'var2', - type: 'string', - }, - { - name: 'var3', - type: 'bytes32[]', - }, - ], - outputs: [ - { - name: 'owner', - type: 'address', - }, - ], - constant: false, - payable: false, - type: 'function', - }, - ]); - - const input = [ - '0x1111111111111111111111111111111111111111111111111111111111111111', - 'Hello World', - [ - '0x2222222222222222222222222222222222222222222222222222222222222222', - '0x3333333333333333333333333333333333333333333333333333333333333333', - ], - ]; - - const encoded = testContractAbi.functions[1].encodeABI(input); - const result = testContractAbi.decodeFunctionData(encoded); - - expect(result).not.toBeUndefined(); - expect(result![0]).toBe(input[0]); - expect(result![1]).toBe(input[1]); - expect(result![2]).toEqual(input[2]); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_abi.ts b/yarn-project/ethereum.js/src/contract/abi/contract_abi.ts deleted file mode 100644 index 1512220018a..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_abi.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { LogResponse } from '../../eth_rpc/types/log_response.js'; -import { bufferToHex } from '../../hex_string/index.js'; -import { ContractAbiDefinition, ContractErrorEntry, ContractEventEntry, ContractFunctionEntry } from './index.js'; - -/** - * The ContractAbi class represents the ABI (Application Binary Interface) of a smart contract. - * It provides methods for decoding logs, events, and function data according to the contract's ABI definition. - * With a ContractAbi instance, you can match, decode and process logs and events generated by the smart contract, - * as well as decode input data provided when calling one of its functions. - */ -export class ContractAbi { - /** - * A list of contract functions. - */ - public functions: ContractFunctionEntry[]; - /** - * An array containing contract event entries. - */ - public events: ContractEventEntry[]; - /** - * A collection of error entries in the contract ABI. - */ - public errors: ContractErrorEntry[]; - /** - * The constructor entry for the contract. - */ - public ctor: ContractFunctionEntry; - /** - * The fallback function to be executed when no other function matches the provided signature. - */ - public fallback?: ContractFunctionEntry; - - constructor(definition: ContractAbiDefinition) { - this.functions = definition.filter(e => e.type === 'function').map(entry => new ContractFunctionEntry(entry)); - this.events = definition.filter(e => e.type === 'event').map(entry => new ContractEventEntry(entry)); - this.errors = definition.filter(e => e.type === 'error').map(entry => new ContractErrorEntry(entry)); - const ctor = definition.find(e => e.type === 'constructor'); - this.ctor = new ContractFunctionEntry(ctor || { type: 'constructor' }); - const fallback = definition.find(e => e.type === 'fallback'); - if (fallback) { - this.fallback = new ContractFunctionEntry(fallback); - } - } - - /** - * Find the matching event entry for a given log response in the contract ABI. - * This function iterates through the events defined in the ABI and compares their signatures with the log's topic. - * Returns the first matching event entry, or undefined if no match is found. - * - * @param log - The LogResponse object containing the log data to be matched against event signatures. - * @returns A ContractEventEntry instance that matches the log's topic, or undefined if no match is found. - */ - public findEntryForLog(log: LogResponse) { - return this.events.find(abiDef => abiDef.signature === log.topics[0]); - } - - /** - * Decodes the event log data using the Contract ABI event definitions. - * Finds the matching event signature in the ABI, then decodes the log data accordingly. - * Throws an error if no matching event signature is found for the given log. - * - * @param log - The LogResponse object containing the event log data to be decoded. - * @returns A decoded event object with event name and decoded parameters. - */ - public decodeEvent(log: LogResponse) { - const event = this.findEntryForLog(log); - if (!event) { - throw new Error(`Unable to find matching event signature for log: ${log.id}`); - } - return event.decodeEvent(log); - } - - /** - * Decodes the function data from a given buffer and returns the decoded parameters. - * The input 'data' should contain the first 4 bytes as the function signature, followed by the encoded parameters. - * Returns undefined if no matching function is found in the ABI for the provided signature. - * - * @param data - The buffer containing the function signature and encoded parameters. - * @returns An object with the decoded parameters or undefined if no matching function is found. - */ - public decodeFunctionData(data: Buffer) { - const funcSig = bufferToHex(data.subarray(0, 4)); - const func = this.functions.find(f => f.signature === funcSig); - return func ? func.decodeParameters(data.slice(4)) : undefined; - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_abi_definition.ts b/yarn-project/ethereum.js/src/contract/abi/contract_abi_definition.ts deleted file mode 100644 index 2c97fd32066..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_abi_definition.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Represents the supported data types in Ethereum ABI (Application Binary Interface) for encoding and decoding contract interactions. - */ -export type AbiDataTypes = 'bool' | 'string' | 'address' | 'function' | 'uint' | 'int' | 'bytes' | string; - -/** - * Type representing an individual input parameter in the ABI (Application Binary Interface) of a smart contract. - * It includes properties for the input's name, data type, and other relevant information used in encoding/decoding - * contract function calls and events. - */ -export type AbiInput = { - /** - * Represents the structure of nested tuple elements. - */ - components?: any; - /** - * The name identifier for the contract entry. - */ - name: string; - /** - * Represents the type of a Contract Entry in the ABI (Application Binary Interface) definition. - */ - type: AbiDataTypes; - /** - * Indicates if the parameter is indexed in events. - */ - indexed?: boolean; - /** - * The internal representation of the data type. - */ - internalType?: string; -}; - -/** - * Represents the type definition for a single output parameter in a contract's ABI. - */ -export type AbiOutput = { - /** - * Nested structure defining the data type components. - */ - components?: any; - /** - * The name identifier of the contract entry. - */ - name: string; - /** - * The type of contract entry, such as function, constructor, event, fallback, error, or receive. - */ - type: AbiDataTypes; - /** - * Represents the internal Solidity type of the input/output. - */ - internalType?: string; -}; - -/** - * Represents a single entry in a smart contract's ABI definition. - * Provides essential information about the contract's functions, events, constructors, and other elements, - * allowing effective interaction with the Ethereum blockchain. - */ -export interface ContractEntryDefinition { - /** - * Indicates if the contract entry is constant (read-only). - */ - constant?: boolean; - /** - * Indicates whether the contract entry can receive Ether. - */ - payable?: boolean; - /** - * Indicates if the event is anonymous, omitting event signature from logs. - */ - anonymous?: boolean; - /** - * An array of input parameters for the contract function or event. - */ - inputs?: AbiInput[]; - /** - * The identifier for the contract function, event, or variable. - */ - name?: string; - /** - * An array of output parameters for the contract function or event. - */ - outputs?: AbiOutput[]; - /** - * The type of contract entry, representing its purpose and functionality. - */ - type: 'function' | 'constructor' | 'event' | 'fallback' | 'error' | 'receive'; - /** - * Represents the mutability of a contract's state during function execution. - */ - stateMutability?: 'pure' | 'view' | 'payable' | 'nonpayable'; - /** - * The unique function identifier generated from the function's name and input types. - */ - signature?: string; - /** - * The estimated gas cost for executing the function. - */ - gas?: number; -} - -/** - * Type representing the Application Binary Interface (ABI) definition for a smart contract, - * which consists of an array of ContractEntryDefinition objects. The ABI defines the - * structure of functions, events, and data types of a contract that can be interacted with. - */ -export type ContractAbiDefinition = ContractEntryDefinition[]; diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_entry.ts b/yarn-project/ethereum.js/src/contract/abi/contract_entry.ts deleted file mode 100644 index 0c91ea18a2f..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_entry.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { abiCoder } from './abi-coder/index.js'; -import { ContractEntryDefinition } from './contract_abi_definition.js'; - -/** - * The ContractEntry class represents a single entry within an Ethereum smart contract's ABI definition. - * It provides easy access to the name of the function or event, as well as its anonymous status. - * Additionally, it offers a method to convert the entry into a human-readable string format. - * This class is primarily used for parsing and interacting with contract ABI definitions. - */ -export class ContractEntry { - constructor(protected entry: ContractEntryDefinition) {} - // eslint-disable-next-line jsdoc/require-jsdoc - public get name() { - return this.entry.name; - } - // eslint-disable-next-line jsdoc/require-jsdoc - public get anonymous() { - return this.entry.anonymous || false; - } - - /** - * Returns a string representation of the ContractEntry instance using ABI encoding. - * This method utilizes the 'abiCoder' module to convert the contract entry definition - * into a readable and formatted string. - * - * @returns A string representation of the ContractEntry instance with ABI encoding. - */ - public asString() { - return abiCoder.abiMethodToString(this.entry); - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_error_entry.ts b/yarn-project/ethereum.js/src/contract/abi/contract_error_entry.ts deleted file mode 100644 index bc3fccf8c17..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_error_entry.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { hexToBuffer } from '../../hex_string/index.js'; -import { abiCoder } from './abi-coder/index.js'; -import { ContractEntryDefinition } from './contract_abi_definition.js'; -import { ContractEntry } from './contract_entry.js'; - -/** - * The ContractErrorEntry class extends the functionalities of the ContractEntry class for error handling in smart contracts. - * It handles encoding, decoding and managing error entries in a contract's ABI (Application Binary Interface). - * This class provides methods to encode and decode parameters, return values, and ABI for contract errors, ensuring proper communication with the blockchain. - */ -export class ContractErrorEntry extends ContractEntry { - /** - * The encoded function signature for the contract entry. - */ - public readonly signature: Buffer; - - constructor(entry: ContractEntryDefinition) { - entry.inputs = entry.inputs || []; - super(entry); - this.signature = hexToBuffer(abiCoder.encodeFunctionSignature(abiCoder.abiMethodToString(entry))); - } - - /** - * Retrieve the number of input arguments for this contract error entry. - * This function returns the length of the 'inputs' array, which represents - * the input arguments required by the entry. If no inputs are defined, - * it returns 0. - * - * @returns The number of input arguments for the contract error entry. - */ - public numArgs() { - return this.entry.inputs ? this.entry.inputs.length : 0; - } - - /** - * Decodes the return value of a contract function call using the ABI output definition. - * If there is only one output, returns the decoded output value directly; otherwise, - * returns an object containing the decoded values with the output names as keys. - * If the input returnValue buffer is empty, returns null. - * - * @param returnValue - The Buffer containing the encoded return value of the contract function call. - * @returns Decoded output value(s) or null if returnValue is empty. - */ - public decodeReturnValue(returnValue: Buffer) { - if (!returnValue.length) { - return null; - } - - const result = abiCoder.decodeParameters(this.entry.outputs, returnValue); - - if (result.__length__ === 1) { - return result[0]; - } else { - delete result.__length__; - return result; - } - } - - /** - * Encodes the ABI (Application Binary Interface) of a function call by concatenating the function's signature - * and encoded input parameters. This resulting buffer can be used for encoding the data field of a transaction. - * The 'args' array should contain values that match the expected input types of the function. - * - * @param args - An array of arguments matching the function's input parameters. - * @returns A Buffer containing the encoded ABI for the function call. - */ - public encodeABI(args: any[]) { - return Buffer.concat([this.signature, this.encodeParameters(args)]); - } - - /** - * Encode the input parameters according to the contract entry inputs. - * This function takes an array of arguments and encodes them into a Buffer - * following the Solidity contract's entry ABI specifications. - * - * @param args - An array of input values matching the contract entry inputs. - * @returns A Buffer containing the encoded parameters. - */ - public encodeParameters(args: any[]) { - return abiCoder.encodeParameters(this.entry.inputs, args); - } - - /** - * Decode the provided bytes buffer into parameters based on the entry inputs. - * This function helps in interpreting the raw bytes buffer received from a contract call - * or an event log, by decoding it based on the ABI input types, and returning the - * decoded values as an object with the input names as keys. - * - * @param bytes - The Buffer containing the encoded parameters to be decoded. - * @returns An object with decoded parameters, keys mapped to the input names defined in the ABI. - */ - public decodeParameters(bytes: Buffer) { - return abiCoder.decodeParameters(this.entry.inputs, bytes); - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_event_entry.test.ts b/yarn-project/ethereum.js/src/contract/abi/contract_event_entry.test.ts deleted file mode 100644 index 1620541b2df..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_event_entry.test.ts +++ /dev/null @@ -1,287 +0,0 @@ -import { keccak256String } from '../../crypto/index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { TxHash } from '../../eth_rpc/index.js'; -import { ContractEventEntry } from './contract_event_entry.js'; - -describe('contract', () => { - describe('contract event entry', () => { - it('should return the decoded event object with topics', () => { - const address = EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); - const signature = 'Changed(address,uint256,uint256,uint256)'; - - const contractEventEntry = new ContractEventEntry({ - name: 'Changed', - type: 'event', - inputs: [ - { name: 'from', type: 'address', indexed: true }, - { name: 'amount', type: 'uint256', indexed: true }, - { name: 't1', type: 'uint256', indexed: false }, - { name: 't2', type: 'uint256', indexed: false }, - ], - }); - - const result = contractEventEntry.decodeEvent({ - id: '', - address, - topics: [ - keccak256String(signature), - '0x000000000000000000000000' + address.toString().replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000001', - ], - blockNumber: 3, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1345', - transactionIndex: 0, - logIndex: 4, - data: - '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008', - }); - - expect(result.args.from).toEqual(address); - expect(result.args.amount).toBe(1n); - expect(result.args.t1).toBe(1n); - expect(result.args.t2).toBe(8n); - }); - - const name = 'event1'; - const address = '0xffdDb67890123456789012345678901234567890'; - - const tests: any = [ - { - abi: { - name, - type: 'event', - inputs: [], - }, - data: { - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - }, - expected: { - event: name, - signature: null, - args: {}, - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - raw: { - topics: [], - data: '', - }, - }, - }, - { - abi: { - name, - inputs: [ - { - name: 'a', - type: 'int', - indexed: false, - }, - ], - }, - data: { - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - data: '0x0000000000000000000000000000000000000000000000000000000000000001', - }, - expected: { - event: name, - signature: null, - args: { - 0: 1n, - a: 1n, - }, - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - raw: { - data: '0x0000000000000000000000000000000000000000000000000000000000000001', - topics: [], - }, - }, - }, - { - abi: { - name, - inputs: [ - { - name: 'a', - type: 'int', - indexed: false, - }, - { - name: 'b', - type: 'int', - indexed: true, - }, - { - name: 'c', - type: 'int', - indexed: false, - }, - { - name: 'd', - type: 'int', - indexed: true, - }, - ], - }, - data: { - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - data: - '0x' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000004', - topics: [ - address, - '0x000000000000000000000000000000000000000000000000000000000000000a', - '0x0000000000000000000000000000000000000000000000000000000000000010', - ], - }, - expected: { - event: name, - signature: address, - args: { - 0: 1n, - 1: 10n, - 2: 4n, - 3: 16n, - a: 1n, - b: 10n, - c: 4n, - d: 16n, - }, - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - raw: { - data: - '0x' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000004', - topics: [ - address, - '0x000000000000000000000000000000000000000000000000000000000000000a', - '0x0000000000000000000000000000000000000000000000000000000000000010', - ], - }, - }, - }, - { - abi: { - name, - anonymous: true, - inputs: [ - { - name: 'a', - type: 'int', - indexed: false, - }, - { - name: 'b', - type: 'int', - indexed: true, - }, - { - name: 'c', - type: 'int', - indexed: false, - }, - { - name: 'd', - type: 'int', - indexed: true, - }, - ], - }, - data: { - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - data: - '0x' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000004', - topics: [ - '0x000000000000000000000000000000000000000000000000000000000000000a', - '0x0000000000000000000000000000000000000000000000000000000000000010', - ], - }, - expected: { - event: name, - signature: null, - args: { - 0: 1n, - 1: 10n, - 2: 4n, - 3: 16n, - a: 1n, - b: 10n, - c: 4n, - d: 16n, - }, - logIndex: 1, - transactionIndex: 16, - transactionHash: '0x1234567890', - address, - blockHash: '0x1234567890', - blockNumber: 1, - id: 'log_c71f2e84', - raw: { - data: - '0x' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000004', - topics: [ - '0x000000000000000000000000000000000000000000000000000000000000000a', - '0x0000000000000000000000000000000000000000000000000000000000000010', - ], - }, - }, - }, - ]; - - tests.forEach((test, index) => { - it('test no: ' + index, () => { - const contractEventEntry = new ContractEventEntry(test.abi); - const result = contractEventEntry.decodeEvent(test.data); - expect(result).toEqual(test.expected); - }); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_event_entry.ts b/yarn-project/ethereum.js/src/contract/abi/contract_event_entry.ts deleted file mode 100644 index 71c2cd9ba38..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_event_entry.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { LogResponse } from '../../eth_rpc/index.js'; -import { hexToBuffer } from '../../hex_string/index.js'; -import { EventLog } from '../contract_tx_receipt.js'; -import { abiCoder } from './abi-coder/index.js'; -import { ContractEntryDefinition } from './contract_abi_definition.js'; -import { ContractEntry } from './contract_entry.js'; - -/** - * The ContractEventEntry class represents a single event entry within a smart contract. - * It provides functionality to encode and decode event topics and logs, as well as - * handling filter parameters for indexed inputs of the event. This class extends the - * ContractEntry base class, adding specific features for event handling in Ethereum - * contracts. By utilizing this class, users can seamlessly interact with events emitted - * by a smart contract, making it easier to track and process data related to those events. - */ -export class ContractEventEntry extends ContractEntry { - /** - * The unique event identifier derived from ABI. - */ - public readonly signature: string; - - constructor(entry: ContractEntryDefinition) { - super(entry); - this.signature = abiCoder.encodeEventSignature(abiCoder.abiMethodToString(entry)); - } - - /** - * Generate an array of event topics by encoding the filter values provided for indexed inputs. - * For events which are not anonymous, the first topic will be the event's signature. - * Each subsequent topic corresponds to an indexed input, with null values for missing filters. - * Supports array values for indexed inputs, which will generate multiple topics for that input. - * - * @param filter - An object containing the filter values to encode as event topics. - * @returns An array of encoded event topics (Buffer or Buffer[]), including the event signature if not anonymous. - */ - public getEventTopics(filter: object = {}) { - const topics: (Buffer | Buffer[])[] = []; - - if (!this.entry.anonymous && this.signature) { - topics.push(hexToBuffer(this.signature)); - } - - const indexedTopics = (this.entry.inputs || []) - .filter(input => input.indexed === true) - .map(input => { - const value = filter[input.name]; - if (!value) { - return null; - } - - // TODO: https://github.com/ethereum/web3.js/issues/344 - // TODO: deal properly with components - - if (Array.isArray(value)) { - return value.map(v => abiCoder.encodeParameter(input.type, v)); - } else { - return abiCoder.encodeParameter(input.type, value); - } - }); - - return [...topics, ...indexedTopics]; - } - - /** - * Decodes an event log response from a contract execution. - * The input 'log' is an object containing data and topics received from the Ethereum transaction receipt. - * This method returns an EventLog object containing the decoded event along with its metadata. - * - * @param log - The LogResponse object containing data and topics from the contract execution. - * @returns An EventLog object with the decoded event, signature, arguments, and raw data. - */ - public decodeEvent(log: LogResponse): EventLog { - const { data = '', topics = [], ...formattedLog } = log; - const { anonymous, inputs = [], name = '' } = this.entry; - - const argTopics = anonymous ? topics : topics.slice(1); - const returnValues = abiCoder.decodeLog(inputs, data, argTopics); - delete returnValues.__length__; - - return { - ...formattedLog, - event: name, - args: returnValues, - signature: anonymous || !topics[0] ? null : topics[0], - raw: { - data, - topics, - }, - }; - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/contract_function_entry.ts b/yarn-project/ethereum.js/src/contract/abi/contract_function_entry.ts deleted file mode 100644 index ae1ef5e20bd..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/contract_function_entry.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { hexToBuffer } from '../../hex_string/index.js'; -import { abiCoder } from './abi-coder/index.js'; -import { ContractEntryDefinition } from './contract_abi_definition.js'; -import { ContractEntry } from './contract_entry.js'; - -/** - * The ContractFunctionEntry class represents a function entry within a smart contract ABI definition. - * It provides methods for encoding and decoding parameters, as well as determining the function's constant and payable properties. - * This class extends the ContractEntry base class and adds functionality specific to smart contract functions such as constructors and regular methods. - */ -export class ContractFunctionEntry extends ContractEntry { - /** - * The unique identifier of the contract function. - */ - public readonly signature: string; - - constructor(entry: ContractEntryDefinition) { - entry.inputs = entry.inputs || []; - super(entry); - this.signature = - entry.type === 'constructor' - ? 'constructor' - : abiCoder.encodeFunctionSignature(abiCoder.abiMethodToString(entry)); - } - // eslint-disable-next-line jsdoc/require-jsdoc - public get constant() { - return this.entry.stateMutability === 'view' || this.entry.stateMutability === 'pure' || this.entry.constant; - } - // eslint-disable-next-line jsdoc/require-jsdoc - public get payable() { - return this.entry.stateMutability === 'payable' || this.entry.payable; - } - - /** - * Returns the number of input arguments required for the contract function. - * This value is derived from the 'inputs' property of the contract entry definition. - * - * @returns The number of input arguments required for the function. - */ - public numArgs() { - return this.entry.inputs ? this.entry.inputs.length : 0; - } - - /** - * Decodes the return value of a contract function call. - * This method takes a Buffer containing the raw return value from a contract function call - * and decodes it according to the output parameters defined in the ABI. - * If the decoded result contains only one value, it returns that value directly; - * otherwise, an object with named properties is returned, excluding the '__length__' property. - * - * @param returnValue - The raw return value from a contract function call as a Buffer. - * @returns The decoded value(s) according to the output parameters defined in the ABI, - * either as a single value or an object with named properties. - */ - public decodeReturnValue(returnValue: Buffer) { - if (!returnValue.length) { - return null; - } - - const result = abiCoder.decodeParameters(this.entry.outputs, returnValue); - - if (result.__length__ === 1) { - return result[0]; - } else { - delete result.__length__; - return result; - } - } - - /** - * Encodes the function call and its arguments into ABI format (Application Binary Interface). - * This representation is used for interacting with the Ethereum blockchain. - * The encoded result is a Buffer that can be sent as data in a transaction or used to invoke contract functions. - * - * @param args - An array of values representing the arguments to pass in the function call. - * @returns A Buffer containing the encoded function signature and parameters in ABI format. - */ - public encodeABI(args: any[]) { - return Buffer.concat([hexToBuffer(this.signature), this.encodeParameters(args)]); - } - - /** - * Encode the provided arguments based on the contract function's input parameters. - * This is useful when preparing ABI-encoded data to interact with a smart contract function. - * Throws an error if the provided arguments don't match the expected input parameters. - * - * @param args - An array of values representing the arguments for the contract function. - * @returns A Buffer containing the ABI-encoded parameters. - */ - public encodeParameters(args: any[]) { - return abiCoder.encodeParameters(this.entry.inputs, args); - } - - /** - * Decode the parameters from a given buffer using the input types defined in the contract entry. - * This function is useful for unpacking parameters from encoded data or transaction payloads. - * - * @param bytes - The buffer containing the encoded parameters. - * @returns An object with the decoded parameters mapped to their respective names as defined in the contract entry. - */ - public decodeParameters(bytes: Buffer) { - return abiCoder.decodeParameters(this.entry.inputs, bytes); - } -} diff --git a/yarn-project/ethereum.js/src/contract/abi/index.ts b/yarn-project/ethereum.js/src/contract/abi/index.ts deleted file mode 100644 index 896b3e15a3a..00000000000 --- a/yarn-project/ethereum.js/src/contract/abi/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './abi-coder/index.js'; -export * from './contract_entry.js'; -export * from './contract_function_entry.js'; -export * from './contract_event_entry.js'; -export * from './contract_error_entry.js'; -export * from './contract_abi_definition.js'; -export * from './contract_abi.js'; diff --git a/yarn-project/ethereum.js/src/contract/bytes.ts b/yarn-project/ethereum.js/src/contract/bytes.ts deleted file mode 100644 index a1e541f62d6..00000000000 --- a/yarn-project/ethereum.js/src/contract/bytes.ts +++ /dev/null @@ -1,66 +0,0 @@ -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes1 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes2 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes3 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes4 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes5 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes6 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes7 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes8 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes9 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes10 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes11 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes12 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes13 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes14 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes15 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes16 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes17 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes18 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes19 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes20 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes21 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes22 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes23 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes24 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes25 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes26 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes27 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes28 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes29 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes30 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes31 extends Buffer {} -// eslint-disable-next-line jsdoc/require-jsdoc -export class Bytes32 extends Buffer {} diff --git a/yarn-project/ethereum.js/src/contract/constructor_interaction.ts b/yarn-project/ethereum.js/src/contract/constructor_interaction.ts deleted file mode 100644 index 8748317b36f..00000000000 --- a/yarn-project/ethereum.js/src/contract/constructor_interaction.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc, SentTx } from '../eth_rpc/index.js'; -import { ContractAbi, ContractFunctionEntry } from './abi/index.js'; -import { SentDeployContractTx } from './sent_deploy_contract_tx.js'; -import { Options, SendOptions, FunctionInteraction } from './function_interaction.js'; - -/** - * Extends the plain FunctionInteraction to provide the extended abi encoding for constructor calls (deployments). - */ -export class ConstructorInteraction extends FunctionInteraction { - constructor( - eth: EthereumRpc, - contractEntry: ContractFunctionEntry, - contractAbi: ContractAbi, - private deployData: Buffer, - args: any[] = [], - defaultOptions: Options = {}, - private onDeployed: (address: EthAddress) => void = x => x, - ) { - super(eth, contractEntry, contractAbi, undefined, args, defaultOptions); - } - - /** - * Sends a transaction with the encoded contract bytecode and constructor arguments, creating a new deployment of the contract. - * Returns a SentDeployContractTx instance that can be used to track the transaction status and retrieve the deployed contract address. - * The 'options' parameter can be used to customize the transaction, such as specifying gas price, gas limit, or value to send. - * - * @param options - An object containing optional parameters for customizing the transaction. - * @returns A SentDeployContractTx instance representing the sent transaction. - */ - public send(options: SendOptions): SentTx { - const sentTx = super.send(options); - return new SentDeployContractTx(this.eth, this.contractAbi, sentTx.getTxHash(), this.onDeployed); - } - - /** - * Encodes the ABI (Application Binary Interface) for the function interaction with the provided arguments. - * The encoded ABI is a serialized representation of the function's signature and its arguments, which can be used by the Ethereum client to process the method call or transaction. - * This is useful for encoding contract function calls when interacting with the Ethereum blockchain. - * @returns The contract bytecode concatenated with the abi encoded constructor arguments. - */ - public encodeABI() { - return Buffer.concat([this.deployData, this.contractEntry.encodeParameters(this.args)]); - } -} diff --git a/yarn-project/ethereum.js/src/contract/contract.test.ts b/yarn-project/ethereum.js/src/contract/contract.test.ts deleted file mode 100644 index f53793b9ea1..00000000000 --- a/yarn-project/ethereum.js/src/contract/contract.test.ts +++ /dev/null @@ -1,1743 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc } from '../eth_rpc/ethereum_rpc.js'; -import { mock } from 'jest-mock-extended'; -import { EthereumProvider } from '../provider/ethereum_provider.js'; -import { sha3 } from '../crypto/index.js'; -import { bufferToHex, hexToBuffer } from '../hex_string/index.js'; -import { Contract } from './contract.js'; -import { TestContract } from './fixtures/TestContract.js'; -import TestContractAbi from './fixtures/TestContractAbi.js'; -import { TestNoCtorContract } from './fixtures/TestNoCtorContract.js'; -import { RawTransactionReceipt, TxHash } from '../eth_rpc/index.js'; -import { ContractAbi } from './abi/index.js'; - -describe('contract', () => { - const address = EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); - const addressLowercase = address.toString().toLowerCase(); - const addressUnprefixedLowercase = addressLowercase.slice(2); - const address2 = EthAddress.fromString('0x5555567890123456789012345678901234567891'); - const address2Lowercase = address2.toString().toLowerCase(); - let eth: EthereumRpc; - let mockEthereumProvider: ReturnType>; - - beforeEach(() => { - mockEthereumProvider = mock(); - eth = new EthereumRpc(mockEthereumProvider); - }); - - describe('instantiation', () => { - it('should construct without address', () => { - const contract = new TestContract(eth); - expect(contract.address).toEqual(EthAddress.ZERO); - }); - - it('should transform address from checksum addresses', () => { - const contract = new TestContract(eth, address); - expect(contract.address).toBe(address); - }); - - it('should transform address to checksum address', () => { - const contract = new TestContract(eth, address); - expect(contract.address).toBe(address); - }); - }); - - // describe('event', () => { - // const signature = 'Changed(address,uint256,uint256,uint256)'; - - // function emitData(delayMs: number = 0, extend?: object) { - // setTimeout(() => { - // mockEthereumProvider.emit('notification', { - // subscription: '0x123', - // result: { - // address: addressLowercase, - // topics: [ - // sha3(signature), - // '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - // '0x0000000000000000000000000000000000000000000000000000000000000001', - // ], - // blockNumber: '0x3', - // transactionIndex: '0x0', - // transactionHash: '0x1234', - // blockHash: '0x1345', - // logIndex: '0x4', - // data: - // '0x0000000000000000000000000000000000000000000000000000000000000001' + - // '0000000000000000000000000000000000000000000000000000000000000008', - // ...extend, - // }, - // }); - // }, delayMs); - // } - - // function mockEthSubscribe() { - // mockEthereumProvider.send.mockImplementationOnce(async (method, params) => { - // expect(method).toBe('eth_subscribe'); - // expect(params[1]).toEqual({ - // topics: [sha3(signature), '0x000000000000000000000000' + addressUnprefixedLowercase, null], - // address: addressLowercase, - // }); - - // emitData(10); - - // return '0x123'; - // }); - // } - - // it('should create event subscription', done => { - // mockEthSubscribe(); - - // const contract = new TestContract(eth, address); - - // const event = contract.events.Changed({ filter: { from: address } }, (err, result) => { - // if (err) { - // return done(err); - // } - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('1'); - // expect(result.args.t1).toBe('1'); - // expect(result.args.t2).toBe('8'); - - // event.unsubscribe(); - // done(); - // }); - // }); - - // it('should create event from the events object using a signature and callback', done => { - // mockEthSubscribe(); - - // const contract = new TestContract(eth, address); - - // const event = contract.events['0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651']( - // { filter: { from: address } }, - // (err, result) => { - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('1'); - // expect(result.args.t1).toBe('1'); - // expect(result.args.t2).toBe('8'); - - // event.unsubscribe(); - // done(); - // }, - // ); - // }); - - // it('should create event from the events object using event name and parameters', done => { - // mockEthSubscribe(); - - // const contract = new TestContract(eth, address); - - // const event = contract.events[signature]({ filter: { from: address } }, (err, result) => { - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('1'); - // expect(result.args.t1).toBe('1'); - // expect(result.args.t2).toBe('8'); - - // event.unsubscribe(); - // done(); - // }); - // }); - - // it('should create event from the events object and use the fromBlock option', done => { - // mockEthereumProvider.send.mockImplementationOnce(method => { - // expect(method).toBe('eth_getLogs'); - // return [ - // { - // address: addressLowercase, - // topics: [ - // sha3(signature), - // '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - // '0x0000000000000000000000000000000000000000000000000000000000000002', - // ], - // blockNumber: '0x3', - // transactionHash: '0x1234', - // transactionIndex: '0x0', - // blockHash: '0x1345', - // logIndex: '0x4', - // data: - // '0x0000000000000000000000000000000000000000000000000000000000000002' + - // '0000000000000000000000000000000000000000000000000000000000000009', - // }, - // { - // address: addressLowercase, - // topics: [ - // sha3(signature), - // '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - // '0x0000000000000000000000000000000000000000000000000000000000000003', - // ], - // blockNumber: '0x4', - // transactionHash: '0x1235', - // transactionIndex: '0x1', - // blockHash: '0x1346', - // logIndex: '0x1', - // data: - // '0x0000000000000000000000000000000000000000000000000000000000000004' + - // '0000000000000000000000000000000000000000000000000000000000000005', - // }, - // ] as RawLogResponse[]; - // }); - - // mockEthSubscribe(); - - // const contract = new TestContract(eth, address); - // let count = 0; - - // const event = contract.events.Changed({ fromBlock: 0, filter: { from: address } }).on('data', result => { - // count++; - - // if (count === 1) { - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('2'); - // expect(result.args.t1).toBe('2'); - // expect(result.args.t2).toBe('9'); - // } - // if (count === 2) { - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('3'); - // expect(result.args.t1).toBe('4'); - // expect(result.args.t2).toBe('5'); - // } - // if (count === 3) { - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('1'); - // expect(result.args.t1).toBe('1'); - // expect(result.args.t2).toBe('8'); - - // event.unsubscribe(); - // done(); - // } - // }); - // }); - - // it('should create event using the function and unsubscribe after one log received', async () => { - // mockEthSubscribe(); - - // let count = 0; - - // const contract = new TestContract(eth, address); - - // await new Promise(resolve => { - // contract.once('Changed', { filter: { from: address } }, (err, result, sub) => { - // count++; - // resolve(); - // }); - // }); - - // // Emit a second. - // mockEthereumProvider.emit('notification', { - // subscription: '0x123', - // result: { - // blockHash: '0x1345', - // }, - // }); - - // expect(count).toBe(1); - // }); - - // it('should create event subscription and fire the changed event, if log.removed = true', done => { - // mockEthSubscribe(); - // emitData(200, { removed: true }); - - // let count = 1; - // const contract = new TestContract(eth, address); - - // contract.events - // .Changed({ filter: { from: address } }) - // .on('data', result => { - // expect(count).toBe(1); - // count++; - // }) - // .on('changed', result => { - // expect(result.removed).toBe(true); - // expect(count).toBe(2); - // done(); - // }); - // }); - - // it('should create all event filter and receive two logs', done => { - // mockEthereumProvider.send.mockImplementationOnce(async (method, params) => { - // expect(method).toBe('eth_subscribe'); - // expect(params[1]).toEqual({ - // topics: [], - // address: addressLowercase, - // }); - - // emitData(100); - // emitData(200, { - // topics: [ - // sha3('Unchanged(uint256,address,uint256)'), - // '0x0000000000000000000000000000000000000000000000000000000000000002', - // '0x000000000000000000000000' + address.toString().replace('0x', ''), - // ], - // data: '0x0000000000000000000000000000000000000000000000000000000000000005', - // }); - - // return '0x123'; - // }); - - // const contract = new TestContract(eth, address); - - // let count = 0; - // const event = contract.events.allEvents({}, (_, result) => { - // count++; - - // if (count === 1 && result.event === 'Changed') { - // expect(result.args.from).toEqual(address); - // expect(result.args.amount).toBe('1'); - // expect(result.args.t1).toBe('1'); - // expect(result.args.t2).toBe('8'); - // } - // if (count === 2 && result.event === 'Unchanged') { - // expect(result.args.addressFrom).toEqual(address); - // expect(result.args.value).toBe('2'); - // expect(result.args.t1).toBe('5'); - - // event.unsubscribe(); - // done(); - // } - // }); - // }); - // }); - - describe('balance call', () => { - const signature = 'balance(address)'; - - it('should encode a function call', () => { - const contract = new TestContract(eth, address); - - const result = contract.methods.balance(address).encodeABI(); - - expect(bufferToHex(result)).toBe( - sha3(signature).slice(0, 10) + '000000000000000000000000' + addressUnprefixedLowercase, - ); - }); - - it('should encode a constructor call with data', () => { - const contract = new TestContract(eth, address); - - const result = contract.deployBytecode('0x1234', address, 10).encodeABI(); - - expect(bufferToHex(result)).toBe( - '0x1234' + - '000000000000000000000000' + - addressLowercase.replace('0x', '') + - '000000000000000000000000000000000000000000000000000000000000000a', - ); - }); - - it('should estimate a function', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_estimateGas'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - }, - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000032'); - }); - - const contract = new TestContract(eth, address); - - const res = await contract.methods.balance(address).estimateGas(); - expect(res).toBe(50); - }); - - it('should estimate the constructor', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_estimateGas'); - expect(params).toEqual([ - { - data: - '0x1234000000000000000000000000' + - addressLowercase.replace('0x', '') + - '0000000000000000000000000000000000000000000000000000000000000032', - }, - ]); - return Promise.resolve('0x000000000000000000000000000000000000000000000000000000000000000a'); - }); - - const contract = new TestContract(eth, address); - - const res = await contract.deployBytecode('0x1234', address, 50).estimateGas(); - expect(res).toBe(10); - }); - - it('should send with many parameters', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: '0x817a9dc00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000a68656c6c6f776f726c64000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ff245453450000000000000000000000000000000000000000000000000000005345000000000000000000000000000000000000000000000000000000000000', - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x000000000000000000000000' + addressLowercase.replace('0x', '')); - }); - - const contract = new TestContract(eth, address); - - const res = await contract.methods - .hasALotOfParams(1, 'helloworld', [hexToBuffer('0xff24545345'), hexToBuffer('0x5345')]) - .call(); - expect(res).toEqual(address); - }); - - it('should send overload functions with zero parameters', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: '0xbb853481', - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000005'); - }); - - const contract = new TestContract(eth, address); - const res = await contract.methods.overloadedFunction().call(); - expect(res).toBe(5n); - }); - - it('should send overload functions with one parameters', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: '0x533678270000000000000000000000000000000000000000000000000000000000000006', - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000006'); - }); - - const contract = new TestContract(eth, address); - - const res = await contract.methods.overloadedFunction(6n).call(); - expect(res).toBe(6n); - }); - - it('should call constant function', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000032'); - }); - - const contract = new TestContract(eth, address); - - const res = await contract.methods.balance(address).call(); - expect(res).toBe(50n); - }); - - it('should call constant function with default block', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - }, - '0xb', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000032'); - }); - - const contract = new TestContract(eth, address); - - const res = await contract.methods.balance(address).call({}, 11); - expect(res).toBe(50n); - }); - - it('should call constant concurrently', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: - sha3('balance(address)').slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x000000000000000000000000000000000000000000000000000000000000000a'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3('owner()').slice(0, 10), - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x00000000000000000000000011f4d0a3c12e86b4b5f39b213f7e19d048276dae'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3('getStr()').slice(0, 10), - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve( - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000', - ); - }); - - const contract = new TestContract(eth, address); - - const [m1, m2, m3] = await Promise.all([ - contract.methods.balance(address).call(), - contract.methods.owner().call(), - contract.methods.getStr().call(), - ]); - - expect(m1).toBe(10n); - expect(m2).toEqual(address); - expect(m3).toBe('Hello!%!'); - }); - - it('should return an error when returned string is 0x', async () => { - const signature = 'getStr()'; - - const contract = new TestContract(eth, address); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10), - to: addressLowercase, - from: address2, - }, - 'latest', - ]); - return Promise.resolve('0x'); - }); - - await expect(contract.methods.getStr().call({ from: address2 })).rejects.toBeInstanceOf(Error); - }); - - it('should return an empty string when 0x0', async () => { - const signature = 'getStr()'; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10), - to: addressLowercase, - from: address2.toString().toLowerCase(), - }, - 'latest', - ]); - return Promise.resolve( - '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000', - ); - }); - - const contract = new TestContract(eth, address); - - const result = await contract.methods.getStr().call({ from: address2 }); - expect(result).toBe(''); - }); - }); - - describe('send', () => { - const signature = sha3('mySend(address,uint256)').slice(0, 10); - - /** - * Sets up the initial state for the mock Ethereum provider by resolving the required RPC calls. - * This function helps prepare the test environment before executing test cases related to contract methods. - * The bootstrap function configures the responses for eth_sendTransaction, eth_blockNumber, - * and eth_getTransactionReceipt in the mock Ethereum provider. - */ - function bootstrap() { - // eth_sendTransaction - mockEthereumProvider.request.mockResolvedValueOnce( - '0x1234000000000000000000000000000000000000000000000000000000056789', - ); - - // eth_blockNumber - mockEthereumProvider.request.mockResolvedValueOnce('0xa'); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - from: address2Lowercase, - to: addressLowercase, - contractAddress: null, - cumulativeGasUsed: '0xa', - transactionIndex: '0x3', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - blockNumber: '0xa', - blockHash: '0x1234', - gasUsed: '0x0', - status: '0x1', - logs: [ - { - address: addressLowercase, - topics: [ - sha3('Unchanged(uint256,address,uint256)'), - '0x0000000000000000000000000000000000000000000000000000000000000002', - '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - ], - blockNumber: '0xa', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1345', - logIndex: '0x0', - data: '0x0000000000000000000000000000000000000000000000000000000000000005', - }, - { - address: addressLowercase, - topics: [ - sha3('Changed(address,uint256,uint256,uint256)'), - '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000001', - ], - blockNumber: '0xa', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1345', - logIndex: '0x1', - data: - '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008', - }, - { - address: address2Lowercase, - topics: [sha3('IgnoredDueToUnmatchingAddress()')], - blockNumber: '0xa', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1345', - logIndex: '0x2', - data: '0x', - }, - ], - }); - } - - it('should create correct receipt', async () => { - bootstrap(); - - const contract = new TestContract(eth, address); - - const receipt = await contract.methods - .mySend(address, 10n) - .send({ from: address2, maxFeePerGas: 21345678654321n }) - .getReceipt(); - - expect(receipt).toEqual({ - from: address2, - to: address, - cumulativeGasUsed: 10, - transactionIndex: 3, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockNumber: 10, - blockHash: '0x1234', - gasUsed: 0, - contractAddress: undefined, - status: true, - logs: expect.any(Array), - anonymousLogs: expect.any(Array), - events: expect.any(Object), - }); - }); - - it('should correctly filter receipts anonymous logs', async () => { - bootstrap(); - - const contract = new TestContract(eth, address); - - const receipt = await contract.methods - .mySend(address, 10n) - .send({ from: address2, maxFeePerGas: 21345678654321n }) - .getReceipt(); - - expect(receipt.anonymousLogs).toMatchObject([ - { - address: address2, - topics: [sha3('IgnoredDueToUnmatchingAddress()')], - blockNumber: 10, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - transactionIndex: 0, - blockHash: '0x1345', - logIndex: 2, - data: '0x', - }, - ]); - }); - - it('should correctly extract receipts events', async () => { - bootstrap(); - - const contract = new TestContract(eth, address); - - const receipt = await contract.methods - .mySend(address, 10n) - .send({ from: address2, maxFeePerGas: 21345678654321n }) - .getReceipt(); - - expect(receipt.events).toMatchObject({ - Unchanged: [ - { - address, - blockNumber: 10, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1345', - logIndex: 0, - transactionIndex: 0, - args: expect.any(Object), - event: 'Unchanged', - signature: '0xf359668f205d0b5cfdc20d11353e05f633f83322e96f15486cbb007d210d66e5', - raw: { - topics: [ - '0xf359668f205d0b5cfdc20d11353e05f633f83322e96f15486cbb007d210d66e5', - '0x0000000000000000000000000000000000000000000000000000000000000002', - '0x000000000000000000000000' + addressUnprefixedLowercase, - ], - data: '0x0000000000000000000000000000000000000000000000000000000000000005', - }, - }, - ], - Changed: [ - { - address, - blockNumber: 10, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1345', - logIndex: 1, - transactionIndex: 0, - args: expect.any(Object), - event: 'Changed', - signature: '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - raw: { - topics: [ - '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - '0x000000000000000000000000' + addressUnprefixedLowercase, - '0x0000000000000000000000000000000000000000000000000000000000000001', - ], - data: '0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008', - }, - }, - ], - }); - }); - - it('should correctly decode receipts event logs', async () => { - bootstrap(); - - const contract = new TestContract(eth, address); - - const receipt = await contract.methods - .mySend(address, 10n) - .send({ from: address2, maxFeePerGas: 21345678654321n }) - .getReceipt(); - - expect(receipt.events!.Changed[0].args).toEqual({ - 0: address, - 1: 1n, - 2: 1n, - 3: 8n, - from: address, - amount: 1n, - t1: 1n, - t2: 8n, - }); - - expect(receipt.events!.Unchanged[0].args).toEqual({ - 0: 2n, - 1: address, - 2: 5n, - value: 2n, - addressFrom: address, - t1: 5n, - }); - }); - - it('should correctly decode multiple of the same event log', async () => { - // eth_sendTransaction - mockEthereumProvider.request.mockResolvedValueOnce( - '0x1234000000000000000000000000000000000000000000000000000000056789', - ); - - // eth_blockNumber - mockEthereumProvider.request.mockResolvedValueOnce('0xa'); - - mockEthereumProvider.request.mockResolvedValueOnce({ - from: address2Lowercase, - to: addressLowercase, - contractAddress: null, - cumulativeGasUsed: '0xa', - transactionIndex: '0x3', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - blockNumber: '0xa', - blockHash: '0x1234', - gasUsed: '0x0', - status: '0x1', - logs: [ - { - address: address.toString(), - topics: [ - sha3('Changed(address,uint256,uint256,uint256)'), - '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000001', - ], - blockNumber: '0xa', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1345', - logIndex: '0x4', - data: - '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008', - }, - { - address: address.toString(), - topics: [ - sha3('Changed(address,uint256,uint256,uint256)'), - '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000002', - ], - blockNumber: '0xa', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1345', - logIndex: '0x5', - data: - '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008', - }, - ], - }); - - const contract = new TestContract(eth, address); - - const receipt = await contract.methods - .mySend(address, 10n) - .send({ from: address2, maxFeePerGas: 21345678654321n }) - .getReceipt(); - - expect(receipt.events).toMatchObject({ - Changed: [ - { - address, - blockNumber: 10, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1345', - logIndex: 4, - transactionIndex: 0, - args: { - 0: address, - 1: 1n, - 2: 1n, - 3: 8n, - from: address, - amount: 1n, - t1: 1n, - t2: 8n, - }, - event: 'Changed', - signature: '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - raw: { - topics: [ - '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000001', - ], - data: '0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008', - }, - }, - { - address, - blockNumber: 10, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1345', - logIndex: 5, - transactionIndex: 0, - args: { - 0: address, - 1: 2n, - 2: 1n, - 3: 8n, - from: address, - amount: 2n, - t1: 1n, - t2: 8n, - }, - event: 'Changed', - signature: '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - raw: { - topics: [ - '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - '0x000000000000000000000000' + addressLowercase.replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000002', - ], - data: '0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008', - }, - }, - ], - }); - }); - - it('should sendTransaction and receive multiple confirmations', async () => { - // eth_sendTransaction - mockEthereumProvider.request.mockResolvedValueOnce( - '0x1234000000000000000000000000000000000000000000000000000000056789', - ); - - // eth_blockNumber - mockEthereumProvider.request.mockResolvedValueOnce('0xa'); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - from: address2Lowercase, - cumulativeGasUsed: '0xa', - transactionIndex: '0x3', - transactionHash: '0x1234000000000000000000000000000000000000000000000000000000056789', - blockNumber: '0xa', - blockHash: '0x1234', - gasUsed: '0x0', - logs: [], - status: '0x1', - }); - - // eth_blockNumber - mockEthereumProvider.request.mockResolvedValueOnce('0xb'); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - from: address2Lowercase, - cumulativeGasUsed: '0xa', - transactionIndex: '0x3', - transactionHash: '0x1234000000000000000000000000000000000000000000000000000000056789', - blockNumber: '0xa', - blockHash: '0x1234', - gasUsed: '0x0', - logs: [], - status: '0x1', - }); - - const contract = new TestContract(eth, address); - - const receipt = await contract.methods - .mySend(address, 10n) - .send({ from: address2, maxFeePerGas: 21345678654321n }) - .getReceipt(true, 2, 0, 0); - - expect(receipt).toEqual({ - from: address2, - cumulativeGasUsed: 10, - transactionIndex: 3, - transactionHash: TxHash.fromString('0x1234000000000000000000000000000000000000000000000000000000056789'), - blockNumber: 10, - blockHash: '0x1234', - gasUsed: 0, - logs: [], - anonymousLogs: [], - events: {}, - status: true, - }); - }); - - it('should sendTransaction to contract function', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: - signature + - '000000000000000000000000' + - addressLowercase.replace('0x', '') + - '0000000000000000000000000000000000000000000000000000000000000011', - from: addressLowercase, - to: addressLowercase, - maxFeePerGas: '0x369d1f7fd2', - }, - ]); - return Promise.resolve(); - }); - - const contract = new TestContract(eth, address); - - await contract.methods.mySend(address, 17n).send({ from: address, maxFeePerGas: 234564321234n }).getTxHash(); - }); - - it('should throw error when trying to send ether to a non payable contract function', () => { - const contract = new TestContract(eth, address); - - expect(() => contract.methods.myDisallowedSend(address, 17n).send({ from: address, value: 123n })).toThrowError( - /non-payable/, - ); - }); - - it('should not throw error when trying to not send ether to a non payable contract function', async () => { - // const signature = 'myDisallowedSend(address,uint256)'; - - // mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - // expect(method).toBe('eth_sendTransaction'); - // expect(params).toEqual([ - // { - // data: - // sha3(signature).slice(0, 10) + - // '000000000000000000000000' + - // addressLowercase.replace('0x', '') + - // '0000000000000000000000000000000000000000000000000000000000000011', - // from: addressLowercase, - // to: addressLowercase, - // maxFeePerGas: '0x1555757ee6b1', - // }, - // ]); - // return Promise.resolve(); - // }); - - // mockEthereumProvider.request.mockResolvedValueOnce({ - // contractAddress: null, - // cumulativeGasUsed: '0xa', - // transactionIndex: '0x3', - // transactionHash: '0x1234', - // blockNumber: '0xa', - // blockHash: '0x1234', - // gasUsed: '0x0', - // logs: [], - // }); - - const contract = new TestContract(eth, address); - - await contract.methods - .myDisallowedSend(address, 17n) - .send({ from: address, maxFeePerGas: 23456787654321n }) - .getTxHash(); - }); - - it('should sendTransaction to contract function using the function name incl. parameters', async () => { - // eth_sendTransaction - mockEthereumProvider.request.mockResolvedValueOnce( - '0x1234000000000000000000000000000000000000000000000000000000056789', - ); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - await contract.methods['mySend(address,uint256)'](address, 17) - .send({ - from: address, - maxFeePerGas: 23456787654321n, - }) - .getTxHash(); - - expect(mockEthereumProvider.request).toHaveBeenCalledWith({ - method: 'eth_sendTransaction', - params: [ - { - data: - signature + - '000000000000000000000000' + - addressLowercase.replace('0x', '') + - '0000000000000000000000000000000000000000000000000000000000000011', - from: addressLowercase, - to: addressLowercase, - maxFeePerGas: '0x1555757ee6b1', - }, - ], - }); - }); - - it('should sendTransaction to contract function using the signature', async () => { - // eth_sendTransaction - mockEthereumProvider.request.mockResolvedValueOnce( - '0x1234000000000000000000000000000000000000000000000000000000056789', - ); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - await contract.methods[signature](address, 17).send({ from: address, maxFeePerGas: 1230000000n }).getTxHash(); - - expect(mockEthereumProvider.request).toHaveBeenCalledWith({ - method: 'eth_sendTransaction', - params: [ - { - data: - signature + - '000000000000000000000000' + - addressLowercase.replace('0x', '') + - '0000000000000000000000000000000000000000000000000000000000000011', - from: addressLowercase, - to: addressLowercase, - maxFeePerGas: '0x49504f80', - }, - ], - }); - }); - - it('should throw when trying to create a tx object and wrong amount of params', () => { - const contract = new Contract(eth, TestContractAbi, address); - expect(() => contract.methods.mySend(address)).toThrowError('No matching method with 1 arguments for mySend.'); - }); - - it('should make a call with optional params', async () => { - const signature = 'balance(address)'; - let count = 0; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - count++; - if (count > 1) { - return Promise.resolve(); - } - - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - from: addressLowercase, - gas: '0xc350', - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000032'); - }); - - const contract = new TestContract(eth, address); - - const r = await contract.methods.balance(address).call({ from: address, gas: 50000 }); - expect(r).toBe(50n); - }); - - it('should explicitly make a call with optional params', async () => { - const signature = 'balance(address)'; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - from: addressLowercase, - gas: '0xc350', - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000032'); - }); - - const contract = new TestContract(eth, address); - - const r = await contract.methods.balance(address).call({ from: address, gas: 50000 }); - expect(r).toBe(50n); - }); - - it('should explicitly make a call with optional params and defaultBlock', async () => { - const signature = 'balance(address)'; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10) + '000000000000000000000000' + addressLowercase.replace('0x', ''), - to: addressLowercase, - from: addressLowercase, - gas: '0xc350', - }, - '0xb', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000032'); - }); - - const contract = new TestContract(eth, address); - - const r = await contract.methods.balance(address).call({ from: address, gas: 50000 }, 11); - expect(r).toBe(50n); - }); - - it('should sendTransaction with optional params', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: - signature + - '000000000000000000000000' + - addressLowercase.replace('0x', '') + - '0000000000000000000000000000000000000000000000000000000000000011', - to: addressLowercase, - from: addressLowercase, - gas: '0xc350', - maxFeePerGas: '0xbb8', - value: '0x2710', - }, - ]); - return Promise.resolve(); - }); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - await contract.methods - .mySend(address, 17n) - .send({ from: address, gas: 50000, maxFeePerGas: 3000n, value: 10000n }) - .getTxHash(); - }); - - // it.only('should sendTransaction and fill in default gasPrice', async () => { - // mockEthereumProvider.request.mockImplementationOnce(async ({ method, params }) => { - // expect(method).toBe('eth_gasPrice'); - // return '0x45656456456456'; - // }); - - // mockEthereumProvider.request.mockImplementationOnce(async ({ method, params }) => { - // expect(method).toBe('eth_sendTransaction'); - // expect(params).toEqual([ - // { - // data: - // signature + - // '000000000000000000000000' + - // addressLowercase.replace('0x', '') + - // '0000000000000000000000000000000000000000000000000000000000000011', - // to: addressLowercase, - // from: addressLowercase, - // maxFeePerGas: '0x45656456456456', - // }, - // ]); - // }); - - // // eth_getTransactionReceipt - // mockEthereumProvider.request.mockResolvedValueOnce({ - // blockHash: '0x1234', - // }); - - // const contract = new TestContract(eth, address); - - // await contract.methods.mySend(address, 17).send({ from: address }); - // }); - - it('should explicitly sendTransaction with optional params', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: - signature + - '000000000000000000000000' + - addressLowercase.replace('0x', '') + - '0000000000000000000000000000000000000000000000000000000000000011', - to: addressLowercase, - from: addressLowercase, - gas: '0xc350', - maxFeePerGas: '0xbb8', - value: '0x2710', - }, - ]); - return Promise.resolve(); - }); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - await contract.methods - .mySend(address, 17n) - .send({ from: address, gas: 50000, maxFeePerGas: 3000n, value: 10000n }) - .getTxHash(); - }); - - it('should explicitly estimateGas with optional params', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_estimateGas'); - expect(params).toEqual([ - { - data: - signature + - '000000000000000000000000' + - addressUnprefixedLowercase + - '0000000000000000000000000000000000000000000000000000000000000011', - to: addressLowercase, - from: addressLowercase, - gas: '0xc350', - maxFeePerGas: '0xbb8', - value: '0x2710', - }, - ]); - - return Promise.resolve('0x10'); - }); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - const gasUsed = await contract.methods - .mySend(address, 17n) - .estimateGas({ from: address, gas: 50000, maxFeePerGas: 3000n, value: 10000n }); - - expect(gasUsed).toBe(16); - }); - - it('getPastEvents should get past events and format them correctly', async () => { - const signature = 'Changed(address,uint256,uint256,uint256)'; - - const topic1 = [ - sha3(signature), - '0x000000000000000000000000' + address.toString().replace('0x', ''), - '0x000000000000000000000000000000000000000000000000000000000000000a', - ]; - const topic2 = [ - sha3(signature), - '0x000000000000000000000000' + address.toString().replace('0x', ''), - '0x0000000000000000000000000000000000000000000000000000000000000003', - ]; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getLogs'); - expect(params).toEqual([ - { - address: addressLowercase, - topics: [ - '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - '0x000000000000000000000000' + address2.toString().replace('0x', ''), - null, - ], - }, - ]); - - return Promise.resolve([ - { - address: address.toString(), - topics: topic1, - blockNumber: '0x3', - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1345', - logIndex: '0x4', - data: - '0x0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000009', - }, - { - address: address.toString(), - topics: topic2, - blockNumber: '0x4', - transactionHash: '0x1235555555555555555555555555555555555555555555555555555555555555', - transactionIndex: '0x0', - blockHash: '0x1346', - logIndex: '0x1', - data: - '0x0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000005', - }, - ]); - }); - - const contract = new TestContract(eth, address); - - const result = await contract.getLogs('Changed', { filter: { from: address2 } }); - - expect(result).toMatchObject([ - { - event: 'Changed', - signature: '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - address, - blockNumber: 3, - transactionHash: TxHash.fromString('0x1234555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1345', - logIndex: 4, - transactionIndex: 0, - raw: { - data: - '0x0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000009', - topics: topic1, - }, - args: { - 0: address, - 1: 10n, - 2: 2n, - 3: 9n, - from: address, - amount: 10n, - t1: 2n, - t2: 9n, - }, - }, - { - event: 'Changed', - signature: '0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651', - address, - blockNumber: 4, - transactionHash: TxHash.fromString('0x1235555555555555555555555555555555555555555555555555555555555555'), - blockHash: '0x1346', - logIndex: 1, - transactionIndex: 0, - raw: { - data: - '0x0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000005', - topics: topic2, - }, - args: { - 0: address, - 1: 3n, - 2: 4n, - 3: 5n, - from: address, - amount: 3n, - t1: 4n, - t2: 5n, - }, - }, - ]); - }); - - it('should call testArr method and properly parse result', async () => { - const signature = 'testArr(int[])'; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: - sha3(signature).slice(0, 10) + - '0000000000000000000000000000000000000000000000000000000000000020' + - '0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000003', - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000005'); - }); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - const result = await contract.methods.testArr([3n]).call(); - expect(result).toBe(5n); - }); - - it('should call owner method, properly', async () => { - const signature = 'owner()'; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: sha3(signature).slice(0, 10), - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x000000000000000000000000' + addressLowercase.replace('0x', '')); - }); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - const result = await contract.methods.owner().call(); - expect(result).toEqual(address); - }); - - it('should decode an struct correctly', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: '0x2a4aedd5000000000000000000000000' + addressUnprefixedLowercase, - to: addressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x0000000000000000000000000000000000000000000000000000000000000001'); - }); - - const contract = new TestContract(eth, address); - - const result = await contract.methods.listOfNestedStructs(address).call(); - const expectedArray: any = []; - expectedArray[0] = true; - expectedArray.status = true; - - expect(result).toEqual(expectedArray); - }); - - it('should call an contract method with an struct as parameter', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: '0x814a4d160000000000000000000000000000000000000000000000000000000000000001', - from: addressLowercase, - gas: '0xc350', - maxFeePerGas: '0xbb8', - to: addressLowercase, - }, - ]); - return Promise.resolve(); - }); - - // eth_getTransactionReceipt - mockEthereumProvider.request.mockResolvedValueOnce({ - blockHash: '0x1234', - }); - - const contract = new TestContract(eth, address); - - await contract.methods - .addStruct({ status: true }) - .send({ - from: address, - gas: 50000, - maxFeePerGas: 3000n, - }) - .getTxHash(); - }); - }); - - describe('encodeABI', () => { - const abi = new ContractAbi([ - { - constant: true, - inputs: [ - { - name: 'a', - type: 'bytes32', - }, - { - name: 'b', - type: 'bytes32', - }, - ], - name: 'takesTwoBytes32', - outputs: [ - { - name: '', - type: 'bytes32', - }, - ], - payable: false, - type: 'function', - stateMutability: 'view', - }, - ]); - const contractAddress = EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); - const mockEthereumProvider = mock(); - const eth = new EthereumRpc(mockEthereumProvider); - - it('should handle bytes32 arrays that only contain 1 byte', () => { - const contract = new Contract(eth, abi, contractAddress); - - const result = contract.methods.takesTwoBytes32('0xaa', '0xbb').encodeABI(); - - expect(bufferToHex(result)).toBe( - [ - '0x1323517e', - 'aa00000000000000000000000000000000000000000000000000000000000000', - 'bb00000000000000000000000000000000000000000000000000000000000000', - ].join(''), - ); - }); - - it('should handle bytes32 arrays that are short 1 byte', () => { - const contract = new Contract(eth, abi, contractAddress); - - const result = contract.methods - .takesTwoBytes32('0x'.concat('a'.repeat(62)), '0x'.concat('b'.repeat(62))) - .encodeABI(); - - expect(bufferToHex(result)).toBe( - [ - '0x1323517e', - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00', - 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00', - ].join(''), - ); - }); - - it('should handle bytes32 arrays that are full', () => { - const contract = new Contract(eth, abi, contractAddress); - - const result = contract.methods - .takesTwoBytes32('0x'.concat('a'.repeat(64)), '0x'.concat('b'.repeat(64))) - .encodeABI(); - - expect(bufferToHex(result)).toBe( - [ - '0x1323517e', - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', - ].join(''), - ); - }); - - it('should throw an exception on bytes32 arrays that are too long', () => { - const contract = new Contract(eth, abi, contractAddress); - - const test = () => - contract.methods.takesTwoBytes32('0x'.concat('a'.repeat(66)), '0x'.concat('b'.repeat(66))).encodeABI(); - - expect(test).toThrow(); - }); - }); - - describe('deploy', () => { - const txReceipt: RawTransactionReceipt = { - transactionHash: '0x1234555555555555555555555555555555555555555555555555555555555555', - to: null, - from: addressLowercase, - contractAddress: address2Lowercase, - blockHash: '0xffdd', - transactionIndex: '0x0', - blockNumber: '0x1', - cumulativeGasUsed: '0x1', - gasUsed: '0x1', - logs: [], - status: '0x1', - }; - - it('should deploy a contract and use all promise steps', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: - '0x01234567000000000000000000000000' + - addressUnprefixedLowercase + - '00000000000000000000000000000000000000000000000000000000000000c8', - from: addressLowercase, - gas: '0xc350', - maxFeePerGas: '0xbb8', - }, - ]); - return Promise.resolve('0x5550000000000000000000000000000000000000000000000000000000000032'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method }) => { - expect(method).toBe('eth_blockNumber'); - return Promise.resolve('0x0'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getTransactionReceipt'); - expect(params).toEqual(['0x5550000000000000000000000000000000000000000000000000000000000032']); - return Promise.resolve(null); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method }) => { - expect(method).toBe('eth_blockNumber'); - return Promise.resolve('0x1'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getTransactionReceipt'); - expect(params).toEqual(['0x5550000000000000000000000000000000000000000000000000000000000032']); - return Promise.resolve(txReceipt); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getCode'); - expect(params).toEqual([address2Lowercase, 'latest']); - return Promise.resolve('0x321'); - }); - - const contract = new TestContract(eth); - - const sendTx = contract.deployBytecode('0x01234567', address, 200).send({ - from: address, - gas: 50000, - maxFeePerGas: 3000n, - }); - - const txHash = await sendTx.getTxHash(); - const receipt = await sendTx.getReceipt(true, 1, 0, 0); - - expect(txHash).toBe('0x5550000000000000000000000000000000000000000000000000000000000032'); - expect(receipt.contractAddress).toEqual(address2); - }); - - it('should deploy a contract with no ctor', async () => { - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: '0x01234567', - from: addressLowercase, - gas: '0xc350', - maxFeePerGas: '0xbb8', - }, - ]); - return Promise.resolve('0x5550000000000000000000000000000000000000000000000000000000000032'); - }); - - // eth_blockNumber - mockEthereumProvider.request.mockResolvedValueOnce('0x1'); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getTransactionReceipt'); - expect(params).toEqual(['0x5550000000000000000000000000000000000000000000000000000000000032']); - return Promise.resolve(txReceipt); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getCode'); - expect(params).toEqual([address2Lowercase, 'latest']); - return Promise.resolve('0x321100'); - }); - - const contract = new TestNoCtorContract(eth); - - const sendTx = contract.deploy().send({ - from: address, - gas: 50000, - maxFeePerGas: 3000n, - }); - - const txHash = await sendTx.getTxHash(); - const receipt = await sendTx.getReceipt(); - - expect(txHash.toString()).toBe('0x5550000000000000000000000000000000000000000000000000000000000032'); - expect(receipt.contractAddress).toEqual(address2); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/contract.ts b/yarn-project/ethereum.js/src/contract/contract.ts deleted file mode 100644 index be99d606423..00000000000 --- a/yarn-project/ethereum.js/src/contract/contract.ts +++ /dev/null @@ -1,415 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc, LogRequest } from '../eth_rpc/index.js'; -import { AbiDataTypes, ContractAbi, ContractEntryDefinition, ContractFunctionEntry } from './abi/index.js'; -import { EventLog } from './contract_tx_receipt.js'; -import { FunctionInteraction } from './function_interaction.js'; -import { ConstructorInteraction } from './constructor_interaction.js'; - -/** - * Represents configuration options for interacting with an Ethereum contract. - * Provides optional settings for specifying the sender address, gas price, and gas limit when creating contract transactions. - */ -export interface ContractOptions { - /** - * The Ethereum address initiating the contract interaction. - */ - from?: EthAddress; - /** - * Gas price for executing contract transactions. - */ - gasPrice?: string | number; - /** - * The maximum amount of gas units allowed for the contract execution. - */ - gas?: number; -} - -/** - * Represents a contract definition for interacting with Ethereum smart contracts. - * Provides a structure to define methods, events, and event logs associated with a specific contract. - * Enables type safety when calling contract methods, accessing event logs, and return values. - */ -interface ContractDefinition { - /** - * Collection of named functions to interact with the contract methods. - */ - methods: any; - /** - * Collection of contract event definitions for ease of interaction. - */ - events?: any; - /** - * A collection of event logs for the contract. - */ - eventLogs?: any; -} - -/** - * TxFactory is a type representing a factory function that produces FunctionInteraction instances. - * It takes any number of arguments and returns a FunctionInteraction instance for interacting with - * the smart contract methods based on the provided arguments. - */ -type TxFactory = (...args: any[]) => FunctionInteraction; - -/** - * Type representing the names of the events present in a given contract definition. - * Used for accessing event logs and interacting with specific events on the contract. - */ -type Events = T extends ContractDefinition - ? Extract - : string; - -/** - * Type representing the event log for a specific event in a contract definition. - * Extracts the event log type based on the given contract definition and event name. - */ -type GetEventLog> = T extends ContractDefinition - ? T['eventLogs'][P] - : EventLog; - -/** - * GetEvent type represents a contract event type from the given ContractDefinition. - * Used to extract appropriate event information for a specific event within the contract. - */ -type GetEvent> = T extends ContractDefinition - ? T['events'][P] - : any; - -/** - * Type representing the contract methods available for interaction. - * It extracts the 'methods' property from the given ContractDefinition type parameter, - * providing a mapping of method names to their respective FunctionInteraction instances. - */ -type GetContractMethods = T extends ContractDefinition - ? T['methods'] - : { [key: string]: (...args: any[]) => FunctionInteraction }; - -/** - * Provides a class to interact with a contract. - * - * Given an ABI, it generates a collection of named functions on the public `methods` property. - * - * Can take a `ContractDefinition` as a type parameter to provide full type safety when calling methods, accessing - * event logs, return values, etc. - * The `gen_def` tool will generate this definiton and then extend this class to use it, giving the user the ability - * to just use that class directly. - * - * Default options can be provided, these can be used to save having on to specify e.g. `from` and `gas` on every call. - */ -export class Contract { - /** - * Collection of named functions for interacting with the contract methods. - */ - public readonly methods: GetContractMethods; - // public readonly events: GetContractEvents; - private linkTable: { [name: string]: EthAddress } = {}; - - constructor( - private eth: EthereumRpc, - private contractAbi: ContractAbi, - /** - * Ethereum contract address for interaction. - */ - public address = EthAddress.ZERO, - private defaultOptions: ContractOptions = {}, - ) { - this.methods = this.buildMethods(); - // this.events = this.buildEvents(); - } - - /** - * When deploying bytecode that needs to be linked first, call this function to establish the link name to address - * mapping. When `deployBytecode` is called it will perform the substitutions first. - */ - public link(name: string, address: EthAddress) { - this.linkTable[name] = address; - } - - /** - * DeployBytecode. - * @param data - Contract bytecode as a hex string. - * @param args - Constructor arguments. - * @returns ConstructorInteraction. - */ - public deployBytecode(data: string, ...args: any[]) { - const linkedData = Object.entries(this.linkTable).reduce( - (data, [name, address]) => - data.replace(new RegExp(`_+${name}_+`, 'gi'), address.toString().slice(2).toLowerCase()), - data, - ); - - if (linkedData.includes('_')) { - throw new Error('Bytecode has not been fully linked.'); - } - - return new ConstructorInteraction( - this.eth, - this.contractAbi.ctor, - this.contractAbi, - Buffer.from(linkedData.slice(2), 'hex'), - args, - this.defaultOptions, - addr => (this.address = addr), - ); - } - - /** - * Retrieves event logs from the contract based on the specified event and options. - * If 'allevents' is passed as the event, it will return logs for all events in the contract. - * Otherwise, it returns logs for the specific event name or signature provided. - * The LogRequest options allow filtering, such as setting a block range or topics to search for logs. - * - * @param event - The event name, signature, or 'allevents' to retrieve logs for. - * @param options - Optional LogRequest object to filter the log results. - * @returns An array of EventLog objects for the specified event(s) and filtered based on the provided options. - */ - public async getLogs>( - event: Event, - options: LogRequest>, - ): Promise[]>; - /** - * Retrieves event logs for the specified event or all events emitted by the contract. - * This function takes an event name and optional log request options as parameters, then - * fetches the matching event logs from the Ethereum blockchain. If the event name is 'allevents', - * it will retrieve logs for all events emitted by the contract. The resulting event logs are - * decoded according to the contract's ABI before being returned as an array. - * - * @param event - The name of the event or 'allevents' to retrieve logs for all events. - * @param options - Optional log request options such as filter, address, and topics. - * @returns An array of decoded event logs matching the specified event name and options. - */ - public async getLogs(event: 'allevents', options: LogRequest): Promise[]>; - /** - * Fetches event logs from the blockchain based on the given event and options. - * This function can either retrieve logs for a specific event or all events in a contract. - * It returns an array of decoded event logs based on the ContractDefinition type parameter. - * The `eventName` parameter should be the name or signature of the event, or 'allevents' to fetch - * logs for all events in a contract. The `options` parameter allows filtering logs by block range, - * address, and other criteria. - * - * @param eventName - The name, signature, or 'allevents' string representing the event(s) to fetch logs for. - * @param options - A LogRequest object with optional properties to filter event logs. - * @returns A Promise that resolves to an array of decoded event logs. - */ - public async getLogs(event: Events & 'allevents', options: LogRequest = {}): Promise[]> { - const logOptions = this.getLogOptions(event, options); - const result = await this.eth.getLogs(logOptions); - return result.map(log => this.contractAbi.decodeEvent(log)); - } - - /** - * Retrieves a contract method by name and input/output types as an executor factory. - * The method can be called with the specified arguments to create a FunctionInteraction instance. - * Throws an error if no contract address is available or if there is no matching method with the provided arguments length. - * - * @param name - The name of the contract method. - * @param inputTypes - An array of input data types for the method. - * @param outputTypes - An array of output data types for the method. - * @returns A TxFactory instance representing the contract method. - */ - public getMethod(name: string, inputTypes: AbiDataTypes[], outputTypes: AbiDataTypes[]) { - const abiEntry: ContractEntryDefinition = { - inputs: inputTypes.map((type, i) => ({ name: `a${i}`, type })), - name, - outputs: outputTypes.map((type, i) => ({ name: `a${i}`, type })), - stateMutability: 'nonpayable', - type: 'function', - }; - return this.executorFactory([new ContractFunctionEntry(abiEntry)]); - } - - /** - * PRIVATE METHODS. - */ - - // eslint-disable-next-line jsdoc/require-jsdoc - private executorFactory(functions: ContractFunctionEntry[]): TxFactory { - return (...args: any[]): FunctionInteraction => { - if (this.address.equals(EthAddress.ZERO)) { - throw new Error('No contract address.'); - } - - const firstMatchingOverload = functions.find(f => args.length === f.numArgs()); - - if (!firstMatchingOverload) { - throw new Error(`No matching method with ${args.length} arguments for ${functions[0].name}.`); - } - - return new FunctionInteraction( - this.eth, - firstMatchingOverload, - this.contractAbi, - this.address, - args, - this.defaultOptions, - ); - }; - } - - /** - * Generates a collection of named functions on the public `methods` property based on the contract ABI. - * It groups and assigns contract functions to their respective method names. - * In case of function overloads, it will create an executor factory for all matching functions. - * - * - * @returns An object containing the generated methods mapped to their respective names. - */ - private buildMethods() { - const methods: any = {}; - - this.contractAbi.functions.forEach(f => { - const executor = this.executorFactory([f]); - methods[f.asString()] = executor; - methods[f.signature] = executor; - }); - - const grouped = this.contractAbi.functions.reduce((acc, method) => { - const funcs = [...(acc[method.name!] || []), method]; - return { ...acc, [method.name!]: funcs }; - }, {} as { [name: string]: ContractFunctionEntry[] }); - - Object.entries(grouped).map(([name, funcs]) => { - methods[name] = this.executorFactory(funcs); - }); - - return methods; - } - - /** - * Generates a LogRequest object for the specified event and request options. - * This is used to filter and retrieve logs related to a contract event. - * Throws an error if no contract address is available or the specified event is not found in the ABI. - * - * @param eventName - The name or signature of the contract event. - * @param options - A LogRequest object containing filter and topic options for the log query. - * @returns A LogRequest object with the specified event and request options combined. - */ - private getLogOptions(eventName = 'allevents', options: LogRequest): LogRequest { - if (!this.address) { - throw new Error('No contract address.'); - } - - if (eventName.toLowerCase() === 'allevents') { - return { - ...options, - address: this.address, - }; - } - - const event = this.contractAbi.events.find( - e => e.name === eventName || e.signature === '0x' + eventName.replace('0x', ''), - ); - - if (!event) { - throw new Error(`Event ${eventName} not found.`); - } - - return { - ...options, - address: this.address, - topics: event.getEventTopics(options.filter), - }; - } - - // This class used to provide the ability to register for events using subscriptions. - // We don't need this functionality right now so have commented out. - - // export type EventSubscriptionFactory> = ( - // options?: object, - // callback?: ( - // err: Error, - // result: Result, - // subscription: Subscription - // ) => void - // ) => Subscription; - // type GetContractEvents = T extends ContractDefinition - // ? T['events'] & { - // allEvents: EventSubscriptionFactory]>; - // } - // : { [key: string]: EventSubscriptionFactory }; - - // public once>( - // event: Event, - // options: { - // filter?: object; - // topics?: string[]; - // }, - // callback: (err, res: GetEventLog, sub) => void, - // ); - // public once(event: Events, options: LogRequest, callback: (err, res, sub) => void): void { - // this.on(event, options, (err, res, sub) => { - // sub.unsubscribe(); - // callback(err, res, sub); - // }); - // } - - // private buildEvents() { - // const events: any = {}; - - // this.contractAbi.events.forEach((e) => { - // const event = this.on.bind(this, e.signature!); - - // if (!events[e.name!]) { - // events[e.name!] = event; - // } - - // events[e.asString()] = event; - // events[e.signature] = event; - // }); - - // events.allEvents = this.on.bind(this, "allevents"); - - // return events; - // } - - // private on( - // event: string, - // options: LogRequest = {}, - // callback?: (err, res, sub) => void - // ) { - // const logOptions = this.getLogOptions(event, options); - // const { fromBlock, ...subLogOptions } = logOptions; - // const params = [toRawLogRequest(subLogOptions)]; - - // const subscription = new Subscription( - // "eth", - // "logs", - // params, - // this.eth.provider, - // (result, sub) => { - // const output = fromRawLogResponse(result); - // const eventLog = this.contractAbi.decodeEvent(output); - // sub.emit(output.removed ? "changed" : "data", eventLog); - // if (callback) { - // callback(undefined, eventLog, sub); - // } - // }, - // false - // ); - - // subscription.on("error", (err) => { - // if (callback) { - // callback(err, undefined, subscription); - // } - // }); - - // if (fromBlock !== undefined) { - // this.eth - // .getPastLogs(logOptions) - // .then((logs) => { - // logs.forEach((result) => { - // const output = this.contractAbi.decodeEvent(result); - // subscription.emit("data", output); - // }); - // subscription.subscribe(); - // }) - // .catch((err) => { - // subscription.emit("error", err); - // }); - // } else { - // subscription.subscribe(); - // } - - // return subscription; - // } -} diff --git a/yarn-project/ethereum.js/src/contract/contract_tx_receipt.ts b/yarn-project/ethereum.js/src/contract/contract_tx_receipt.ts deleted file mode 100644 index 526cccc59ff..00000000000 --- a/yarn-project/ethereum.js/src/contract/contract_tx_receipt.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { LogResponse, TransactionReceipt, TxHash } from '../eth_rpc/index.js'; -import { DecodedError } from './decode_error.js'; - -/** - * Represents a parsed Ethereum event log specific to Ethereum contracts. - * Contains information about the event, such as its name, address, arguments, block data, and signature. - * Useful for tracking contract interactions and state changes on the blockchain. - */ -export interface EventLog { - /** - * A unique identifier for the event log. - */ - id: string | null; - /** - * Indicates whether the event log has been removed due to a chain reorganization. - */ - removed?: boolean; - /** - * The name of the emitted event. - */ - event: Name; - /** - * The Ethereum address of the contract emitting the event. - */ - address: EthAddress; - /** - * Arguments associated with the emitted event. - */ - args: Args; - /** - * The index position of the log entry in the block. - */ - logIndex: number | null; - /** - * The index of the transaction within the block containing it. - */ - transactionIndex: number | null; - /** - * The unique identifier of the transaction. - */ - transactionHash: TxHash | null; - /** - * The hash of the block containing this event. - */ - blockHash: string | null; - /** - * The block number containing the event. - */ - blockNumber: number | null; - /** - * Raw event data and topics emitted by the contract. - */ - raw: { - /** - * The raw hexadecimal representation of the event data. - */ - data: string; - /** - * An array of indexed event arguments encoded as hexadecimal strings. - */ - topics: string[]; - }; - /** - * The unique identifier of the event signature. - */ - signature: string | null; -} - -/** - * Represents a contract transaction receipt in the Ethereum network. - * Extends the standard transaction receipt with additional information about anonymous logs and - * decoded events specific to the contract. It also includes optional error details in case of a failed transaction. - */ -export interface ContractTxReceipt extends TransactionReceipt { - /** - * An array of logs without specific event signatures. - */ - anonymousLogs: LogResponse[]; - /** - * An object containing arrays of various event logs, keyed by their respective event names. - */ - events: Events extends void ? { [eventName: string]: EventLog[] } : Events; - /** - * An optional field containing error information, including a message and decodedError if available. - */ - error?: { - /** - * The human-readable error message. - */ - message: string; - /** - * Decoded information from a failing transaction error. - */ - decodedError?: DecodedError; - }; -} diff --git a/yarn-project/ethereum.js/src/contract/decode_error.test.ts b/yarn-project/ethereum.js/src/contract/decode_error.test.ts deleted file mode 100644 index d2bdbc11c38..00000000000 --- a/yarn-project/ethereum.js/src/contract/decode_error.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { hexToBuffer } from '../hex_string/index.js'; -import { ContractAbi, ContractAbiDefinition } from './abi/index.js'; -import { decodeErrorFromContract } from './decode_error.js'; - -describe('decode_error', () => { - it('should decode error', () => { - const abi: ContractAbiDefinition = [ - { - inputs: [ - { - internalType: 'bytes32', - name: 'oldStateHash', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 'newStateHash', - type: 'bytes32', - }, - ], - name: 'INCORRECT_STATE_HASH', - type: 'error', - }, - ]; - const data = hexToBuffer( - '0x34fddf40160e1512008ebe521f7650fddad39c8a4f092fc451263be0190d631da26d345f88b748f29261d3cc053519106d94b965cd94d9143d58104f9becb80814d6917c', - ); - - const error = decodeErrorFromContract(new ContractAbi(abi), data); - - expect(error).not.toBeUndefined(); - expect(error).toEqual({ - name: 'INCORRECT_STATE_HASH', - params: [ - '0x160e1512008ebe521f7650fddad39c8a4f092fc451263be0190d631da26d345f', - '0x88b748f29261d3cc053519106d94b965cd94d9143d58104f9becb80814d6917c', - ], - message: - 'INCORRECT_STATE_HASH(0x160e1512008ebe521f7650fddad39c8a4f092fc451263be0190d631da26d345f,0x88b748f29261d3cc053519106d94b965cd94d9143d58104f9becb80814d6917c)', - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/decode_error.ts b/yarn-project/ethereum.js/src/contract/decode_error.ts deleted file mode 100644 index 09e99c72cdd..00000000000 --- a/yarn-project/ethereum.js/src/contract/decode_error.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { CallRequest, EthereumRpc, TxHash } from '../eth_rpc/index.js'; -import { hexToBuffer } from '../hex_string/index.js'; -import { ContractAbi } from './abi/contract_abi.js'; - -/** - * Represents a decoded error from a contract execution. - * Contains optional name and params properties, as well as a mandatory message property - * providing a human-readable description of the error. - */ -export interface DecodedError { - /** - * The name of the decoded error. - */ - name?: string; - - /** - * An array of decoded error parameters. - */ - params?: any[]; - /** - * A human-readable description of the error. - */ - message: string; -} - -/** - * Given a ContractAbi and a data buffer containing the return data of a failed call(), will attempt to lookup the - * error in the contracts abi and to decode the return data. - */ -export function decodeErrorFromContract(contractAbi: ContractAbi, data: Buffer) { - const sigHash = data.subarray(0, 4); - const args = data.subarray(4); - - const error = contractAbi.errors.find(e => e.signature.equals(sigHash)); - if (!error) { - return; - } - const decoded = error.decodeParameters(args); - const params = Array.from({ length: decoded.__length__ }).map((_, i) => decoded[i]); - - const errorValue: DecodedError = { - name: error.name!, - params, - message: `${error.name!}(${params.map(p => p.toString()).join(',')})`, - }; - - return errorValue; -} - -/** - * If a transaction fails, you can call this to decode the error. - * It locates the block within which the tx failed, and then "replays" the tx via a call against the state of the prior - * block. This should reproduce the error deterministically, but will return data that can be decoded to show the error. - */ -export async function decodeErrorFromContractByTxHash( - contractAbi: ContractAbi, - txHash: TxHash, - ethRpc: EthereumRpc, -): Promise { - const { from, gas, to, maxFeePerGas, maxPriorityFeePerGas, value, input, blockNumber } = - await ethRpc.getTransactionByHash(txHash); - const callReq: CallRequest = { - from, - gas, - to: to!, - maxFeePerGas, - maxPriorityFeePerGas, - value, - data: input, - }; - try { - await ethRpc.call(callReq, blockNumber! - 1); - // We expect the call the throw. - return { message: 'Cannot determine failure, as call succeeded when replaying transaction.' }; - } catch (err: any) { - if (err.data && err.data.length > 2) { - const decodedError = decodeErrorFromContract(contractAbi, hexToBuffer(err.data)); - if (decodedError) { - return decodedError; - } - } - return { message: err.message }; - } -} diff --git a/yarn-project/ethereum.js/src/contract/fixtures/TestContract.ts b/yarn-project/ethereum.js/src/contract/fixtures/TestContract.ts deleted file mode 100644 index ec50affeddb..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/TestContract.ts +++ /dev/null @@ -1,181 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc } from '../../eth_rpc/index.js'; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from '../../contract/index.js'; -import * as Bytes from '../../contract/bytes.js'; -import abi from './TestContractAbi.js'; -/** - * Type representing the 'ChangedEvent' that contains details about the change in balance, - * such as the sender's address, the amount changed, and two timestamps for tracking. - */ -export type ChangedEvent = { - /** - * The Ethereum address initiating the event. - */ - from: EthAddress; - /** - * The amount involved in the transaction. - */ - amount: bigint; - /** - * Timestamp of the first event occurrence. - */ - t1: bigint; - /** - * Timestamp indicating the end time of an event. - */ - t2: bigint; -}; -/** - * Type representing the 'UnchangedEvent', which is emitted when a specific condition in the contract remains unchanged. - */ -export type UnchangedEvent = { - /** - * The monetary amount associated with the transaction. - */ - value: bigint; - /** - * The originating Ethereum address. - */ - addressFrom: EthAddress; - /** - * The timestamp of the first event. - */ - t1: bigint; -}; -/** - * Represents the ChangedEventLog interface for the TestContract. - * Contains all the properties of a Changed event log, including event name and payload. - */ -export interface ChangedEventLog extends EventLog {} -/** - * Represents the log interface for UnchangedEvent in the TestContract. - * Provides event details such as value, addressFrom, and t1 from the emitted Unchanged event. - */ -export interface UnchangedEventLog extends EventLog {} -/** - * Represents the event types for the TestContract. - * Provides a mapped definition of each event with its respective data structure. - */ -interface TestContractEvents { - /** - * Event emitted when a change occurs in the contract state. - */ - Changed: ChangedEvent; - /** - * An event indicating no change in the value. - */ - Unchanged: UnchangedEvent; -} -/** - * Represents the event logs for the TestContract interface. - * Contains the mapping of event names to their corresponding event log interfaces for easy access and organization. - */ -interface TestContractEventLogs { - /** - * Represents an event triggered when a change occurs in the contract state. - */ - Changed: ChangedEventLog; - /** - * Event triggered when a value remains unchanged. - */ - Unchanged: UnchangedEventLog; -} -/** - * Represents the event logs for all transactions involving the TestContract. - * Contains an organized collection of event logs for each specific event in the contract, allowing easy access to relevant transaction information. - */ -interface TestContractTxEventLogs { - /** - * Triggered when a state change occurs in the contract. - */ - Changed: ChangedEventLog[]; - /** - * An event representing unaltered data. - */ - Unchanged: UnchangedEventLog[]; -} -/** - * Represents a TestContract transaction receipt. - * Provides details about the transaction events, status, and other relevant information after executing a method call on the TestContract. - */ -export interface TestContractTransactionReceipt extends ContractTxReceipt {} -/** - * Represents the methods available in the TestContract. - * Provides functionality for interacting with and invoking smart contract functions, - * handling various use cases such as adding structs, managing balances, performing transactions, - * and working with event logs. - */ -interface TestContractMethods { - addStruct(nestedStruct: { - /** - * Represents the active state of a specific object or process. - */ - status: boolean; - }): TxSend; - listOfNestedStructs(a0: EthAddress): TxCall<{ - /** - * Represents the active state of an entity. - */ - status: boolean; - }>; - balance(who: EthAddress): TxCall; - hasALotOfParams( - _var1: number, - _var2: string, - _var3: Bytes.Bytes32[], - ): TxSend; - getStr(): TxCall; - owner(): TxCall; - mySend(to: EthAddress, value: bigint): TxSend; - myDisallowedSend(to: EthAddress, value: bigint): TxSend; - testArr(value: bigint[]): TxCall; - overloadedFunction(a: bigint): TxCall; - overloadedFunction(): TxCall; -} -/** - * Represents a TestContract definition interface. - * Contains methods, events, and eventLogs related to the TestContract. - * Provides functionality for interacting with the TestContract on the Ethereum network. - */ -export interface TestContractDefinition { - /** - * Collection of smart contract methods. - */ - methods: TestContractMethods; - /** - * A collection of event definitions for the TestContract. - */ - events: TestContractEvents; - /** - * Collection of logs for emitted events. - */ - eventLogs: TestContractEventLogs; -} -/** - * The TestContract class represents a smart contract deployed on the Ethereum blockchain. - * This class provides methods to interact with the contract, including invoking its functions, - * querying its state, and listening for events. It extends the Contract base class and implements - * the TestContractDefinition interface, which defines the structure of the contract's ABI. - * Instances of this class can be created with an optional address and options, allowing the user - * to easily connect to existing contracts or deploy new ones. - */ -export class TestContract extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - /** - * Deploy a new instance of the TestContract smart contract to the Ethereum network. - * The 'deploy' function takes the initial 'who' address and 'myValue' as arguments for the constructor of the TestContract. - * Returns a transaction receipt containing the contract address, gas used, and other details on successful deployment. - * - * @param who - The Ethereum address that will be set as the 'owner' of the newly deployed contract. - * @param myValue - The initial value (in bigint) to be set in the smart contract's internal state. - * @returns A promise that resolves to a TestContractTransactionReceipt with information about the deployed contract. - */ - deploy(who: EthAddress, myValue: bigint): TxSend { - return super.deployBytecode('0x01234567', who, myValue) as any; - } -} -export var TestContractAbi = abi; diff --git a/yarn-project/ethereum.js/src/contract/fixtures/TestContractAbi.ts b/yarn-project/ethereum.js/src/contract/fixtures/TestContractAbi.ts deleted file mode 100644 index 15a6fb947d5..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/TestContractAbi.ts +++ /dev/null @@ -1,257 +0,0 @@ -import { ContractAbi } from '../../contract/index.js'; -export default new ContractAbi([ - { - "type": "constructor", - "inputs": [ - { - "name": "who", - "type": "address" - }, - { - "name": "myValue", - "type": "uint256" - } - ] - }, - { - "constant": false, - "inputs": [ - { - "components": [ - { - "name": "status", - "type": "bool" - } - ], - "name": "nestedStruct", - "type": "tuple" - } - ], - "name": "addStruct", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "address" - } - ], - "name": "listOfNestedStructs", - "outputs": [ - { - "components": [ - { - "name": "status", - "type": "bool" - } - ], - "name": "nestedStruct", - "type": "tuple" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "name": "balance", - "type": "function", - "inputs": [ - { - "name": "who", - "type": "address" - } - ], - "constant": true, - "outputs": [ - { - "name": "value", - "type": "uint256" - } - ] - }, - { - "name": "hasALotOfParams", - "inputs": [ - { - "name": "_var1", - "type": "uint8" - }, - { - "name": "_var2", - "type": "string" - }, - { - "name": "_var3", - "type": "bytes32[]" - } - ], - "outputs": [ - { - "name": "owner", - "type": "address" - } - ], - "constant": false, - "payable": false, - "type": "function" - }, - { - "name": "getStr", - "type": "function", - "inputs": [], - "constant": true, - "outputs": [ - { - "name": "myString", - "type": "string" - } - ] - }, - { - "name": "owner", - "type": "function", - "inputs": [], - "constant": true, - "outputs": [ - { - "name": "owner", - "type": "address" - } - ] - }, - { - "name": "mySend", - "type": "function", - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "name": "myDisallowedSend", - "type": "function", - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - } - ], - "outputs": [], - "payable": false - }, - { - "name": "testArr", - "type": "function", - "inputs": [ - { - "name": "value", - "type": "int[]" - } - ], - "constant": true, - "outputs": [ - { - "name": "d", - "type": "int" - } - ] - }, - { - "name": "Changed", - "type": "event", - "inputs": [ - { - "name": "from", - "type": "address", - "indexed": true - }, - { - "name": "amount", - "type": "uint256", - "indexed": true - }, - { - "name": "t1", - "type": "uint256", - "indexed": false - }, - { - "name": "t2", - "type": "uint256", - "indexed": false - } - ] - }, - { - "name": "Unchanged", - "type": "event", - "inputs": [ - { - "name": "value", - "type": "uint256", - "indexed": true - }, - { - "name": "addressFrom", - "type": "address", - "indexed": true - }, - { - "name": "t1", - "type": "uint256", - "indexed": false - } - ] - }, - { - "name": "overloadedFunction", - "type": "function", - "inputs": [ - { - "name": "a", - "type": "uint256" - } - ], - "constant": true, - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view" - }, - { - "name": "overloadedFunction", - "type": "function", - "inputs": [], - "constant": true, - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view" - } -]); \ No newline at end of file diff --git a/yarn-project/ethereum.js/src/contract/fixtures/TestNoCtorContract.ts b/yarn-project/ethereum.js/src/contract/fixtures/TestNoCtorContract.ts deleted file mode 100644 index 5517d448d28..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/TestNoCtorContract.ts +++ /dev/null @@ -1,79 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc } from '../../eth_rpc/index.js'; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from '../../contract/index.js'; - -import abi from './TestNoCtorContractAbi.js'; -/** - * Represents the events emitted by the TestNoCtorContract. - * Provides an interface for accessing the event log data associated with the contract. - */ -interface TestNoCtorContractEvents {} -/** - * Represents the event logs for the TestNoCtorContract. - * Provides an interface for accessing and managing the emitted events in the contract. - */ -interface TestNoCtorContractEventLogs {} -/** - * Represents the transaction event logs for the TestNoCtorContract. - * Provides a structured interface for accessing event logs emitted during contract transactions. - */ -interface TestNoCtorContractTxEventLogs {} -/** - * Represents the transaction receipt for a TestNoCtorContract operation. - * Contains detailed information about the transaction status and event logs specific to the TestNoCtorContract instance. - */ -export interface TestNoCtorContractTransactionReceipt extends ContractTxReceipt {} -/** - * Represents the TestNoCtorContract methods interface. - * Provides a collection of methods for interacting with and executing transactions on the TestNoCtorContract smart contract. - */ -interface TestNoCtorContractMethods { - addStruct(nestedStruct: { - /** - * Indicates the active state of an element. - */ - status: boolean; - }): TxSend; -} -/** - * Represents a TestNoCtorContract definition. - * Provides functionality for interacting with methods and events specific to the TestNoCtorContract smart contract. - */ -export interface TestNoCtorContractDefinition { - /** - * Collection of smart contract methods. - */ - methods: TestNoCtorContractMethods; - /** - * Collection of contract event definitions. - */ - events: TestNoCtorContractEvents; - /** - * Holds the event logs data for the contract. - */ - eventLogs: TestNoCtorContractEventLogs; -} -/** - * The TestNoCtorContract class represents a smart contract on the Ethereum blockchain. - * It provides methods to interact with the contract both for reading data and sending transactions. - * The class also defines the structure of events emitted by the contract and facilitates listening to those events. - * This class is particularly useful when working with contracts that do not have a constructor function. - */ -export class TestNoCtorContract extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - /** - * Deploy the TestNoCtorContract smart contract to the Ethereum blockchain. - * Uses a fixed bytecode "0x01234567" as the deployment data. - * Returns a transaction object with the contract deployment details and receipt. - * - * @returns {TxSend} A transaction object for the deployment of TestNoCtorContract. - */ - deploy(): TxSend { - return super.deployBytecode('0x01234567') as any; - } -} -export var TestNoCtorContractAbi = abi; diff --git a/yarn-project/ethereum.js/src/contract/fixtures/TestNoCtorContractAbi.ts b/yarn-project/ethereum.js/src/contract/fixtures/TestNoCtorContractAbi.ts deleted file mode 100644 index 17196886424..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/TestNoCtorContractAbi.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ContractAbi } from '../../contract/index.js'; -export default new ContractAbi([ - { - "constant": false, - "inputs": [ - { - "components": [ - { - "name": "status", - "type": "bool" - } - ], - "name": "nestedStruct", - "type": "tuple" - } - ], - "name": "addStruct", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -]); \ No newline at end of file diff --git a/yarn-project/ethereum.js/src/contract/fixtures/contracts.json b/yarn-project/ethereum.js/src/contract/fixtures/contracts.json deleted file mode 100644 index 7214ebab1f8..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/contracts.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "importPath": "../..", - "outputPath": ".", - "contracts": { - "TestContract": { - "source": "files", - "abiFile": "./test-contract-abi.json", - "initDataFile": "./test-contract-bytecode" - }, - "TestNoCtorContract": { - "source": "files", - "abiFile": "./test-contract-no-ctor-abi.json", - "initDataFile": "./test-contract-bytecode" - } - } -} diff --git a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-abi.json b/yarn-project/ethereum.js/src/contract/fixtures/test-contract-abi.json deleted file mode 100644 index 31f342529dd..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-abi.json +++ /dev/null @@ -1,256 +0,0 @@ -[ - { - "type": "constructor", - "inputs": [ - { - "name": "who", - "type": "address" - }, - { - "name": "myValue", - "type": "uint256" - } - ] - }, - { - "constant": false, - "inputs": [ - { - "components": [ - { - "name": "status", - "type": "bool" - } - ], - "name": "nestedStruct", - "type": "tuple" - } - ], - "name": "addStruct", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "address" - } - ], - "name": "listOfNestedStructs", - "outputs": [ - { - "components": [ - { - "name": "status", - "type": "bool" - } - ], - "name": "nestedStruct", - "type": "tuple" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "name": "balance", - "type": "function", - "inputs": [ - { - "name": "who", - "type": "address" - } - ], - "constant": true, - "outputs": [ - { - "name": "value", - "type": "uint256" - } - ] - }, - { - "name": "hasALotOfParams", - "inputs": [ - { - "name": "_var1", - "type": "uint8" - }, - { - "name": "_var2", - "type": "string" - }, - { - "name": "_var3", - "type": "bytes32[]" - } - ], - "outputs": [ - { - "name": "owner", - "type": "address" - } - ], - "constant": false, - "payable": false, - "type": "function" - }, - { - "name": "getStr", - "type": "function", - "inputs": [], - "constant": true, - "outputs": [ - { - "name": "myString", - "type": "string" - } - ] - }, - { - "name": "owner", - "type": "function", - "inputs": [], - "constant": true, - "outputs": [ - { - "name": "owner", - "type": "address" - } - ] - }, - { - "name": "mySend", - "type": "function", - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "name": "myDisallowedSend", - "type": "function", - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - } - ], - "outputs": [], - "payable": false - }, - { - "name": "testArr", - "type": "function", - "inputs": [ - { - "name": "value", - "type": "int[]" - } - ], - "constant": true, - "outputs": [ - { - "name": "d", - "type": "int" - } - ] - }, - { - "name": "Changed", - "type": "event", - "inputs": [ - { - "name": "from", - "type": "address", - "indexed": true - }, - { - "name": "amount", - "type": "uint256", - "indexed": true - }, - { - "name": "t1", - "type": "uint256", - "indexed": false - }, - { - "name": "t2", - "type": "uint256", - "indexed": false - } - ] - }, - { - "name": "Unchanged", - "type": "event", - "inputs": [ - { - "name": "value", - "type": "uint256", - "indexed": true - }, - { - "name": "addressFrom", - "type": "address", - "indexed": true - }, - { - "name": "t1", - "type": "uint256", - "indexed": false - } - ] - }, - { - "name": "overloadedFunction", - "type": "function", - "inputs": [ - { - "name": "a", - "type": "uint256" - } - ], - "constant": true, - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view" - }, - { - "name": "overloadedFunction", - "type": "function", - "inputs": [], - "constant": true, - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view" - } -] diff --git a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-bytecode b/yarn-project/ethereum.js/src/contract/fixtures/test-contract-bytecode deleted file mode 100644 index 8abcbb00b85..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-bytecode +++ /dev/null @@ -1 +0,0 @@ -0x01234567 \ No newline at end of file diff --git a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-link-bytecode b/yarn-project/ethereum.js/src/contract/fixtures/test-contract-link-bytecode deleted file mode 100644 index 5cb5090623b..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-link-bytecode +++ /dev/null @@ -1 +0,0 @@ -0x608060__LinkMe_______________________63b54040 \ No newline at end of file diff --git a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-no-ctor-abi.json b/yarn-project/ethereum.js/src/contract/fixtures/test-contract-no-ctor-abi.json deleted file mode 100644 index 0d0b10e9f58..00000000000 --- a/yarn-project/ethereum.js/src/contract/fixtures/test-contract-no-ctor-abi.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "constant": false, - "inputs": [ - { - "components": [ - { - "name": "status", - "type": "bool" - } - ], - "name": "nestedStruct", - "type": "tuple" - } - ], - "name": "addStruct", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/yarn-project/ethereum.js/src/contract/function_interaction.test.ts b/yarn-project/ethereum.js/src/contract/function_interaction.test.ts deleted file mode 100644 index df4ca91c815..00000000000 --- a/yarn-project/ethereum.js/src/contract/function_interaction.test.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { mock } from 'jest-mock-extended'; -import { EthereumProvider } from '../provider/ethereum_provider.js'; -import { sha3 } from '../crypto/index.js'; -import { ContractAbi } from './abi/contract_abi.js'; -import { FunctionInteraction } from './function_interaction.js'; -import { TxHash, EthereumRpc } from '../eth_rpc/index.js'; - -describe('contract', () => { - describe('function_interaction', () => { - const contractAddress = EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); - const contractAddressLowercase = contractAddress.toString().toLowerCase(); - const contractAddressUnprefixedLowercase = contractAddressLowercase.slice(2); - const from = EthAddress.fromString('0x5555567890123456789012345678901234567891'); - const fromAddressLowercase = from.toString().toLowerCase(); - let mockEthereumProvider: ReturnType>; - - beforeEach(() => { - mockEthereumProvider = mock(); - }); - - it('should emit correct transaction hash and receipt on send', async () => { - const signature = sha3('mySend(address,uint256)').slice(0, 10); - - const contractAbi = new ContractAbi([ - { - name: 'mySend', - type: 'function', - inputs: [ - { - name: 'to', - type: 'address', - }, - { - name: 'value', - type: 'uint256', - }, - ], - outputs: [], - }, - ]); - const methodAbi = contractAbi.functions[0]; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_sendTransaction'); - expect(params).toEqual([ - { - data: - signature + - '000000000000000000000000' + - contractAddressUnprefixedLowercase + - '000000000000000000000000000000000000000000000000000000000000000a', - from: fromAddressLowercase, - to: contractAddressLowercase, - // gasPrice: '0x5af3107a4000', - }, - ]); - return Promise.resolve('0x1234000000000000000000000000000000000000000000000000000000056789'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method }) => { - expect(method).toBe('eth_blockNumber'); - return Promise.resolve('0xa'); - }); - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_getTransactionReceipt'); - expect(params).toEqual(['0x1234000000000000000000000000000000000000000000000000000000056789']); - return Promise.resolve({ - from: fromAddressLowercase, - contractAddress: contractAddressLowercase, - cumulativeGasUsed: '0xa', - transactionIndex: '0x3', - transactionHash: '0x1234000000000000000000000000000000000000000000000000000000056789', - blockNumber: '0xa', - blockHash: '0xbf1234', - gasUsed: '0x0', - status: '0x1', - logs: [], - }); - }); - - const args = [contractAddress, 10]; - const tx = new FunctionInteraction( - new EthereumRpc(mockEthereumProvider), - methodAbi, - contractAbi, - contractAddress, - args, - ); - - const txSend = tx.send({ from }); - - expect(await txSend.getTxHash()).toBe('0x1234000000000000000000000000000000000000000000000000000000056789'); - expect(await txSend.getReceipt()).toEqual({ - from, - contractAddress, - cumulativeGasUsed: 10, - transactionIndex: 3, - transactionHash: TxHash.fromString('0x1234000000000000000000000000000000000000000000000000000000056789'), - blockNumber: 10, - blockHash: '0xbf1234', - gasUsed: 0, - logs: [], - anonymousLogs: [], - events: {}, - status: true, - }); - }); - - it('should return correct result on call', async () => { - const signature = sha3('balance(address)').slice(0, 10); - - const contractAbi = new ContractAbi([ - { - name: 'balance', - type: 'function', - inputs: [ - { - name: 'who', - type: 'address', - }, - ], - constant: true, - outputs: [ - { - name: 'value', - type: 'uint256', - }, - ], - }, - ]); - const methodAbi = contractAbi.functions[0]; - - mockEthereumProvider.request.mockImplementationOnce(({ method, params }) => { - expect(method).toBe('eth_call'); - expect(params).toEqual([ - { - data: signature + '000000000000000000000000' + contractAddressUnprefixedLowercase, - from: from.toString().toLowerCase(), - to: contractAddressLowercase, - }, - 'latest', - ]); - return Promise.resolve('0x000000000000000000000000000000000000000000000000000000000000000a'); - }); - - const args = [contractAddress]; - const tx = new FunctionInteraction( - new EthereumRpc(mockEthereumProvider), - methodAbi, - contractAbi, - contractAddress, - args, - ); - - const result = await tx.call({ from }); - expect(result).toBe(10n); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/contract/function_interaction.ts b/yarn-project/ethereum.js/src/contract/function_interaction.ts deleted file mode 100644 index 18df0c023bd..00000000000 --- a/yarn-project/ethereum.js/src/contract/function_interaction.ts +++ /dev/null @@ -1,224 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { - CallRequest, - EthereumRpc, - NumberOrTag, - SentTx, - TransactionReceipt, - TransactionRequest, -} from '../eth_rpc/index.js'; -import { hexToBuffer } from '../hex_string/index.js'; -import { ContractAbi, ContractFunctionEntry } from './abi/index.js'; -import { decodeErrorFromContract } from './decode_error.js'; -import { SentContractTx } from './sent_contract_tx.js'; - -/** - * Represents the optional parameters for interacting with a contract. - * Provides customization options like sender address, maximum gas fees, and gas limit. - */ -export interface Options { - /** - * The Ethereum address initiating the transaction. - */ - from?: EthAddress; - /** - * The maximum fee per gas unit for the transaction. - */ - maxFeePerGas?: bigint; - /** - * The maximum priority fee per gas unit for the transaction. - */ - maxPriorityFeePerGas?: bigint; - /** - * The maximum amount of gas units to be used for the transaction. - */ - gas?: number; -} - -/** - * Represents the call options for a contract function interaction. - * These options include the sender address (from), maximum fee per gas (maxFeePerGas), - * maximum priority fee per gas (maxPriorityFeePerGas), gas limit (gas), and value. - */ -export interface CallOptions extends Options { - /** - * The amount of ether (in wei) to transfer during the transaction. - */ - value?: bigint; -} - -/** - * Represents the options for sending a transaction in the Ethereum network. - * Provides optional parameters to control the execution of a transaction, such as gas limits, value, and nonce. - */ -export interface SendOptions extends CallOptions { - /** - * The nonce value representing the number of transactions sent from the sender's address. - */ - nonce?: number; -} - -/** - * The interactions available when making a call. - */ -export interface TxCall { - call(options?: CallOptions, block?: NumberOrTag): Promise; - estimateGas(options?: CallOptions): Promise; - encodeABI(): Buffer; -} - -/** - * The interactions available when performing a tx send. - */ -export interface TxSend { - call(options?: CallOptions, block?: NumberOrTag): Promise; - send(options?: SendOptions): SentTx; - estimateGas(options?: CallOptions): Promise; - encodeABI(): Buffer; -} - -/** - * This is the class that is returned when calling e.g. `contract.methods.myMethod(arg1, arg2)`. - * It represents an interaction that can occur with that method and arguments. Interactions are:. - * - `estimateGas`. - * - `call`. - * - `send`. - * - `encodeAbi`. - */ -export class FunctionInteraction implements TxCall, TxSend { - constructor( - protected eth: EthereumRpc, - protected contractEntry: ContractFunctionEntry, - protected contractAbi: ContractAbi, - protected contractAddress?: EthAddress, - protected args: any[] = [], - protected defaultOptions: Options = {}, - ) {} - - /** - * Estimate the amount of gas required to perform a transaction for the function interaction. - * The gas estimation is based on the provided 'options' object, which can include parameters such as 'from', 'maxFeePerGas', 'maxPriorityFeePerGas', and 'gas'. - * If the transaction execution fails or there's an error in the call, it attempts to handle the error gracefully by providing a meaningful message. - * - * @param options - An optional object containing transaction parameters and overrides for the function interaction. - * @returns A Promise that resolves to the estimated gas amount required for the transaction. - * @throws Will throw an error if the call fails with a decoded error message, or a generic error message if decoding fails. - */ - public async estimateGas(options: CallOptions = {}) { - try { - return await this.eth.estimateGas(this.getCallRequest(options)); - } catch (err: any) { - this.handleError(err); - } - } - - /** - * Executes a read-only contract function call, returning the decoded result. - * This interaction does not require a transaction on the blockchain and is thus gas-free. - * If the call encounters an error, it attempts to decode the error message from the contract - * and throws an error with a meaningful message. Otherwise, it throws the original error. - * - * @param options - Optional settings specifying "from", "value", "maxFeePerGas", "maxPriorityFeePerGas" and "gas". - * @param block - Optional specification of the block number or tag at which the call must be executed. - * @returns The return value of the contract function call after successful decoding. - */ - public async call(options: CallOptions = {}, block?: NumberOrTag) { - try { - const result = await this.eth.call(this.getCallRequest(options), block); - return this.contractEntry.decodeReturnValue(result); - } catch (err: any) { - this.handleError(err); - } - } - - /** - * Sends a transaction to the specified contract method with given options. - * It returns a SentTx instance containing the transaction receipt and decoded return value (if any). - * Throws an error if the from address is not specified or attempting to send value to a non-payable method. - * - * @param options - An object containing optional parameters: from, nonce, value, maxFeePerGas, maxPriorityFeePerGas, and gas. - * @returns A SentTx instance representing the sent transaction. - */ - public send(options: SendOptions): SentTx { - const tx = this.getTxRequest(options); - - if (!this.contractEntry.payable && tx.value !== undefined && tx.value > 0) { - throw new Error('Cannot send value to non-payable contract method.'); - } - - const promise = this.eth.sendTransaction(tx).getTxHash(); - - return new SentContractTx(this.eth, this.contractAbi, promise); - } - - /** - * Encodes the ABI (Application Binary Interface) for the function interaction with the provided arguments. - * The encoded ABI is a serialized representation of the function's signature and its arguments, which can be used - * by the Ethereum client to process the method call or transaction. This is useful for encoding contract function - * calls when interacting with the Ethereum blockchain. - * - * @returns A Buffer containing the encoded ABI for the function interaction. - */ - public encodeABI() { - return this.contractEntry.encodeABI(this.args); - } - - /** - * Construct a transaction request object by merging the provided send options with the default options, `from` address, contract address, and encoded ABI data. - * This transaction request object is used for sending transactions to the Ethereum network. - * Throws an error if the `from` address is not specified. - * - * @param options - The send options containing information required for constructing the transaction request object. - * @returns A TransactionRequest instance with all necessary data for sending the transaction. - */ - private getTxRequest(options: SendOptions = {}): TransactionRequest { - const from = options.from || this.defaultOptions.from; - if (!from) { - throw new Error('You must specify a from address to send a tx.'); - } - return { - ...this.defaultOptions, - ...options, - from, - to: this.contractAddress!, - data: this.encodeABI(), - }; - } - - /** - * Constructs and returns a CallRequest object for the current contract function interaction. - * The CallRequest object combines the provided options with the default options and includes - * the encoded ABI data of the function call. This object can be used to perform various - * interactions such as estimating gas, making calls, or sending transactions. - * - * @param options - An optional CallOptions object containing values such as from address, - * maxFeePerGas, maxPriorityFeePerGas, gas, and value. - * @returns A CallRequest object with the necessary information for further interactions. - */ - private getCallRequest(options: CallOptions = {}): CallRequest { - return { - ...this.defaultOptions, - ...options, - to: this.contractAddress!, - data: this.encodeABI(), - }; - } - - /** - * Handles errors occurring during the execution of a contract function call. - * If the error data contains a decodable error message, throws an error with a decoded message. - * Otherwise, throws the original error with its message. - * - * @param err - The error object caught during the contract function call execution. - * @throws An error with either the decoded error message or the original error message. - */ - private handleError(err: any): never { - if (err.data && err.data.length > 2) { - const decoded = decodeErrorFromContract(this.contractAbi, hexToBuffer(err.data)); - if (decoded) { - throw new Error(`call() failed: ${decoded.message}`); - } - } - throw new Error(`call() failed: ${err.message}`); - } -} diff --git a/yarn-project/ethereum.js/src/contract/gen_def/index.ts b/yarn-project/ethereum.js/src/contract/gen_def/index.ts deleted file mode 100644 index 6f6abcae7cf..00000000000 --- a/yarn-project/ethereum.js/src/contract/gen_def/index.ts +++ /dev/null @@ -1,750 +0,0 @@ -#!/usr/bin/env node -import sourceMapSupport from 'source-map-support'; -sourceMapSupport.install(); -import fs from 'fs'; -import ts, { ClassElement, PropertySignature, TypeNode } from 'typescript'; -import { AbiInput, AbiOutput, ContractAbiDefinition, ContractEntryDefinition } from '../abi/index.js'; -import { ContractBuildData, loadDataFromConfig } from './sources/index.js'; -import { Config } from './sources/config.js'; -import { dirname } from 'path'; - -Error.stackTraceLimit = Infinity; - -const printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, -}); - -const getImport = (importPath: string, module: string) => - importPath[0] === '.' ? `${importPath}/${module}/index.js` : `${importPath}/${module}`; - -/** - * Generate an array of import declarations for the necessary modules and types used in the generated contract file. - * This function handles relative or absolute import paths, and appends the appropriate module names. - * - * @param name - The name of the contract. - * @param importPath - The base path for importing necessary modules. - * @returns An array of TypeScript import declarations. - */ -function makeImports(name: string, importPath: string) { - return [ - ts.factory.createImportDeclaration( - undefined, - ts.factory.createImportClause( - false, - undefined, - ts.factory.createNamedImports([ - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('EthAddress')), - ]), - ), - ts.factory.createStringLiteral('@aztec/foundation/eth-address'), - ), - ts.factory.createImportDeclaration( - undefined, - ts.factory.createImportClause( - false, - undefined, - ts.factory.createNamedImports([ - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('EthereumRpc')), - ]), - ), - ts.factory.createStringLiteral(getImport(importPath, 'eth_rpc')), - ), - ts.factory.createImportDeclaration( - undefined, - ts.factory.createImportClause( - false, - undefined, - ts.factory.createNamedImports([ - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('Contract')), - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('ContractTxReceipt')), - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('EventLog')), - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('Options')), - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('TxCall')), - ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('TxSend')), - // ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('EventSubscriptionFactory')), - ]), - ), - ts.factory.createStringLiteral(getImport(importPath, 'contract')), - ), - ts.factory.createImportDeclaration( - undefined, - ts.factory.createImportClause(false, ts.factory.createIdentifier('* as Bytes'), undefined), - ts.factory.createStringLiteral(`${importPath}/contract/bytes.js`), - ), - ts.factory.createImportDeclaration( - undefined, - ts.factory.createImportClause(false, ts.factory.createIdentifier('abi'), undefined), - ts.factory.createStringLiteral(`./${name}Abi.js`), - ), - ]; -} - -/** - * Generate a TypeScript type alias for an Ethereum contract event. - * The resulting type alias represents the structure of the event arguments as an object, - * with each property having the appropriate TypeScript type based on the Solidity type - * of the corresponding event input. - * - * @param definition - The ContractEntryDefinition representing the Ethereum contract event. - * @returns A TypeScript TypeAliasDeclaration representing the event structure. - */ -function makeEventType(definition: ContractEntryDefinition) { - const props = ts.factory.createTypeLiteralNode( - definition.inputs!.map(input => - ts.factory.createPropertySignature(undefined, input.name, undefined, getTsTypeFromSolidityType(input)), - ), - ); - - return ts.factory.createTypeAliasDeclaration( - [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], - `${definition.name}Event`, - undefined, - props, - ); -} - -/** - * Generate TypeScript type aliases for the event types specified in the given Contract ABI definition. - * Each event type alias is created by mapping the corresponding inputs of the event to their appropriate - * TypeScript types based on their Solidity data types. - * - * @param abi - The ContractAbiDefinition containing the events for which type aliases will be generated. - * @returns An array of TypeScript type alias declarations for the event types. - */ -function makeEventTypes(abi: ContractAbiDefinition) { - return abi.filter(def => def.type === 'event').map(makeEventType); -} - -/** - * Create an interface for event logs of a given ContractEntryDefinition. - * The generated interface extends 'EventLog' with the name and structure of the specific event log in the given definition. - * This helps in creating type-safe event logs for Ethereum smart contracts using the ABI. - * - * @param definition - The ContractEntryDefinition representing an event from the ABI. - * @returns A TypeScript interface declaration for the event log based on the given definition. - */ -function makeEventLogInterface(definition: ContractEntryDefinition) { - const eventName = `${definition.name!}Event`; - return ts.factory.createInterfaceDeclaration( - [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], - `${eventName}Log`, - undefined, - [ - ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ - ts.factory.createExpressionWithTypeArguments(ts.factory.createRegularExpressionLiteral('EventLog'), [ - ts.factory.createTypeReferenceNode(eventName, undefined), - ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(definition.name!)), - ]), - ]), - ], - [], - ); -} - -/** - * Generate TypeScript interface declarations for event logs of a contract. - * For each event in the ABI, it creates an exported interface extending 'EventLog' with event-specific properties. - * - * @param abi - The ContractAbiDefinition object representing the contract's ABI. - * @returns An array of TypeScript InterfaceDeclaration nodes representing the event log interfaces. - */ -function makeEventLogInterfaces(abi: ContractAbiDefinition) { - return abi.filter(def => def.type === 'event').map(makeEventLogInterface); -} - -/** - * Generate TypeScript interface for events in a given contract ABI. - * The interface contains typed definitions of each event present in the ABI, - * allowing them to be accessed and used effectively when working with the contract. - * - * @param name - The name of the contract. - * @param abi - The ContractAbiDefinition array from the contract's ABI JSON. - * @returns A TypeScript InterfaceDeclaration representing the events in the contract. - */ -function makeEventsInterface(name: string, abi: ContractAbiDefinition) { - const events = abi.filter(def => def.type === 'event').map(event => event.name!); - return ts.factory.createInterfaceDeclaration( - undefined, - `${name}Events`, - undefined, - undefined, - events.map(eventName => - ts.factory.createPropertySignature( - undefined, - eventName, - undefined, - ts.factory.createTypeReferenceNode(`${eventName}Event`, undefined), - // ts.factory.createTypeReferenceNode(`EventSubscriptionFactory`, [ - // ts.factory.createTypeReferenceNode(`${eventName}EventLog`, undefined), - // ]), - ), - ), - ); -} - -/** - * Generates an interface for Event Logs of the given name and Contract ABI definition. - * The generated interface consists of property signatures with each property representing - * an event log type for a specific event in the contract. It provides a way to access event logs - * based on the event names. - * - * @param name - The name of the contract. - * @param abi - The Contract ABI definition object containing event definitions. - * @returns A TypeScript InterfaceDeclaration for the contract's event logs. - */ -function makeEventLogsInterface(name: string, abi: ContractAbiDefinition) { - const events = abi.filter(def => def.type === 'event').map(event => event.name!); - return ts.factory.createInterfaceDeclaration( - undefined, - `${name}EventLogs`, - undefined, - undefined, - events.map(eventName => - ts.factory.createPropertySignature( - undefined, - eventName, - undefined, - ts.factory.createTypeReferenceNode(`${eventName}EventLog`, undefined), - ), - ), - ); -} - -/** - * Generates a TypeScript interface for the given contract's transaction event logs. - * The generated interface includes properties for each event in the ABI, with their respective - * log types as array values. This allows easier interaction and validation with contract events - * during transaction execution. - * - * @param name - The name of the contract. - * @param abi - The Contract ABI definition. - * @returns A TypeScript InterfaceDeclaration for the contract's transaction event logs. - */ -function makeTxEventLogsInterface(name: string, abi: ContractAbiDefinition) { - const events = abi.filter(def => def.type === 'event').map(event => event.name!); - return ts.factory.createInterfaceDeclaration( - undefined, - `${name}TxEventLogs`, - undefined, - undefined, - events.map(eventName => - ts.factory.createPropertySignature( - undefined, - eventName, - undefined, - ts.factory.createArrayTypeNode(ts.factory.createTypeReferenceNode(`${eventName}EventLog`, undefined)), - ), - ), - ); -} - -/** - * Generate a TypeScript interface for the transaction receipt of the given contract name. - * The generated interface extends the 'ContractTxReceipt' type with the contract's specific event log types. - * - * @param name - The name of the contract. - * @returns A TypeScript interface node representing the contract's transaction receipt. - */ -function makeTransactionReceiptInterface(name: string) { - return ts.factory.createInterfaceDeclaration( - [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], - `${name}TransactionReceipt`, - undefined, - [ - ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ - ts.factory.createExpressionWithTypeArguments(ts.factory.createRegularExpressionLiteral('ContractTxReceipt'), [ - ts.factory.createTypeReferenceNode(`${name}TxEventLogs`, undefined), - ]), - ]), - ], - [], - ); -} - -/** - * Get the TypeScript base type from a given Solidity type string. - * Handles cases for unsigned and signed integer types, fixed types, byte arrays, - * boolean, and Ethereum address types. For other types, it defaults to string. - * - * @param type - The Solidity type string to be converted. - * @returns A TypeScript TypeNode representing the corresponding TypeScript type. - */ -function getBaseType(type: string /*, returnValue: boolean*/) { - let m: RegExpMatchArray | null; - if ((m = type.match(/u?int(\d*)/) || type.match(/u?fixed([0-9x]*)/))) { - const width = m[1] ? +m[1] : 256; - if (width <= 32) { - return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - // return !returnValue - // ? ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword) - // : ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); - } else { - return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BigIntKeyword); - // return !returnValue - // ? ts.factory.createKeywordTypeNode(ts.SyntaxKind.BigIntKeyword) - // : ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); - } - } - - if ((m = type.match(/bytes(\d*)/))) { - return ts.factory.createTypeReferenceNode(`Bytes.Bytes${m[1]}`, undefined); - } - - if (type === 'bool') { - return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword); - } - - if (type === 'address') { - return ts.factory.createTypeReferenceNode('EthAddress', undefined); - } - - return ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); -} - -/** - * Generate a TypeScript TypeLiteralNode representing a tuple type from an array of ABI inputs. - * The resulting tuple type will have the corresponding TypeScript types based on the Solidity types - * in the input components. - * - * @param components - An array of AbiInput objects that make up the tuple type. - * @returns A TypeLiteralNode representing the generated tuple type in TypeScript. - */ -function getTupleType(components: AbiInput[]): ts.TypeLiteralNode { - return ts.factory.createTypeLiteralNode( - components!.map(prop => - ts.factory.createPropertySignature(undefined, prop.name, undefined, getTsTypeFromSolidityType(prop)), - ), - ); -} - -/** - * Generates the TypeScript type corresponding to a given Solidity type. - * Handles base types, tuples and arrays, including nested arrays. - * For tuple types, generates a TypeLiteralNode with the components as properties. - * - * @param input - The AbiInput object containing information about the Solidity type. - * @param type - An optional string representing the Solidity type (defaults to input.type). - * @returns A TypeScript TypeNode representing the corresponding TypeScript type. - */ -function getTsTypeFromSolidityType(input: AbiInput, type?: string) { - type = type || input.type; - const arrayMatched = type.match(/(.+)\[\d*\]$/); - if (arrayMatched) { - const tsType = getTsTypeFromSolidityType(input, arrayMatched[1]); - return ts.factory.createArrayTypeNode(tsType); - } else { - const isTuple = type === 'tuple'; - return isTuple ? getTupleType(input.components) : getBaseType(type); - } -} - -/** - * Create a TypeScript parameter declaration from an ABI input. - * This function is used to generate TypeScript method signatures for smart contract methods based on their inputs. - * It takes an AbiInput object, which contains information about the name and type of the input, - * and its index in the inputs array, to generate a matching TypeScript parameter with the appropriate type. - * - * @param input - The AbiInput object containing the name and type of the input parameter. - * @param index - The index of the input parameter in the inputs array. - * @returns A TypeScript ParameterDeclaration for the given input. - */ -function makeParameter(input: AbiInput, index: number) { - return ts.factory.createParameterDeclaration( - undefined, - undefined, - input.name || `a${index}`, - undefined, - getTsTypeFromSolidityType(input), - ); -} - -/** - * Generate TypeScript return type nodes for a given array of ABI outputs. - * Handles multiple return values by creating an object with properties corresponding to the output names and indices. - * Supports base types, tuple types, and array types based on the provided ABI outputs. - * - * @param outputs - Array of ABI outputs from a contract function. - * @returns An array of TypeScript TypeNodes representing the return types. - */ -function generateReturnTypes(outputs: AbiOutput[]): ReadonlyArray { - if (outputs.length === 0) { - return []; - } else if (outputs.length === 1) { - // original return value. - return [getTsTypeFromSolidityType(outputs[0])]; - } else { - // multiple return values: return an object. - const propSigs: PropertySignature[] = []; - for (let index = 0; index < outputs.length; index++) { - const output = outputs[index]; - const type = getTsTypeFromSolidityType(output as AbiInput); - if (output.name) { - // name exists for the output: create a key for that - const nameSig = ts.factory.createPropertySignature( - undefined, - ts.factory.createStringLiteral(output.name), - undefined, - type, - ); - propSigs.push(nameSig); - } - // always create a key for the index. - const indexSig = ts.factory.createPropertySignature( - undefined, - ts.factory.createNumericLiteral(index.toString()), - undefined, - type, - ); - propSigs.push(indexSig); - } - return [ts.factory.createTypeLiteralNode(propSigs)]; - } -} - -/** - * Determine the TypeScript type representing the output of a given contract function based on its definition. - * The output type is either 'TxCall' for view or pure functions, or 'TxSend' for functions that mutate state. - * For multiple return values, the output type will be an object containing each of them. - * - * @param name - The name of the smart contract. - * @param definition - The ContractEntryDefinition object representing the contract function. - * @returns A TypeScript TypeNode representing the output type of the contract function. - */ -function getOutputType(name: string, definition: ContractEntryDefinition) { - if (!definition.stateMutability) { - if (definition.constant && definition.constant === true) { - return ts.factory.createTypeReferenceNode('TxCall', generateReturnTypes(definition.outputs || [])); - } else { - return ts.factory.createTypeReferenceNode('TxSend', [ - ts.factory.createTypeReferenceNode(`${name}TransactionReceipt`, undefined), - ...generateReturnTypes(definition.outputs || []), - ]); - } - } - if (definition.stateMutability === 'view' || definition.stateMutability === 'pure') { - if (definition.outputs && definition.outputs.length) { - return ts.factory.createTypeReferenceNode('TxCall', generateReturnTypes(definition.outputs)); - } else { - return ts.factory.createTypeReferenceNode('TxCall', [ - ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword), - ]); - } - } else { - return ts.factory.createTypeReferenceNode('TxSend', [ - ts.factory.createTypeReferenceNode(`${name}TransactionReceipt`, undefined), - ...generateReturnTypes(definition.outputs || []), - ]); - } -} - -/** - * Generates a method signature for a contract function based on its ABI definition. - * This method takes the name of the contract and the entry definition from the ABI, - * creates TypeScript parameter declarations for the inputs of the function, and - * sets the appropriate return type based on the stateMutability and outputs of the function. - * - * @param name - The name of the contract. - * @param definition - The ABI entry definition for the contract function. - * @returns A TypeScript methodSignature with the proper input parameters and output type. - */ -function makeMethodSignature(name: string, definition: ContractEntryDefinition) { - return ts.factory.createMethodSignature( - undefined, - definition.name!, - undefined, - undefined, - definition.inputs!.map(makeParameter), - getOutputType(name, definition), - ); -} - -/** - * Generate a TypeScript interface for the contract methods based on the ABI definition. - * The generated interface includes method signatures with input parameters and return types - * according to the contract's ABI, which can be used for type checking and code generation. - * - * @param name - The name of the contract. - * @param abi - The ContractAbiDefinition object containing the contract's ABI information. - * @returns A TypeScript InterfaceDeclaration for the contract methods. - */ -function makeMethodsInterface(name: string, abi: ContractAbiDefinition) { - const methods = abi.filter(def => def.type === 'function').map(def => makeMethodSignature(name, def)); - return ts.factory.createInterfaceDeclaration(undefined, `${name}Methods`, undefined, undefined, methods); -} - -/** - * Generate TypeScript code for a contract class which extends the Contract class. - * The generated contract class includes methods, events, and event logs from the ABI. - * If initData is provided, it also creates a deployment method. - * - * @param name - The name of the generated contract. - * @param initData - The initialization data (constructor bytecode) for deploying the contract. Optional. - * @param abi - The contract's ABI definition. - * @returns A TypeScript ClassDeclaration node for the contract class. - */ -function makeContract(name: string, initData: string | undefined, abi: ContractAbiDefinition) { - const members: ClassElement[] = []; - - const ctor = ts.factory.createConstructorDeclaration( - undefined, - [ - ts.factory.createParameterDeclaration( - undefined, - undefined, - 'eth', - undefined, - ts.factory.createTypeReferenceNode('EthereumRpc', undefined), - ), - ts.factory.createParameterDeclaration( - undefined, - undefined, - 'address', - ts.factory.createToken(ts.SyntaxKind.QuestionToken), - ts.factory.createTypeReferenceNode('EthAddress', undefined), - ), - ts.factory.createParameterDeclaration( - undefined, - undefined, - 'options', - ts.factory.createToken(ts.SyntaxKind.QuestionToken), - ts.factory.createTypeReferenceNode('Options', undefined), - ), - ], - ts.factory.createBlock( - [ - ts.factory.createExpressionStatement( - ts.factory.createCallExpression(ts.factory.createSuper(), undefined, [ - ts.factory.createIdentifier('eth'), - ts.factory.createIdentifier('abi'), - ts.factory.createIdentifier('address'), - ts.factory.createIdentifier('options'), - ]), - ), - ], - true, - ), - ); - - members.push(ctor); - - if (initData) { - const ctorDef = abi.find(def => def.type === 'constructor')!; - const inputs = ctorDef && ctorDef.inputs ? ctorDef.inputs : []; - const deployMethod = ts.factory.createMethodDeclaration( - undefined, - undefined, - 'deploy', - undefined, - undefined, - inputs.map(makeParameter), - ts.factory.createTypeReferenceNode('TxSend', [ - ts.factory.createTypeReferenceNode(`${name}TransactionReceipt`, undefined), - ]), - ts.factory.createBlock( - [ - ts.factory.createReturnStatement( - ts.factory.createAsExpression( - ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression(ts.factory.createSuper(), 'deployBytecode'), - undefined, - [ - ts.factory.createStringLiteral(initData), - ...inputs.map(input => ts.factory.createIdentifier(input.name)), - ], - ), - ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), - ), - ), - ], - true, - ), - ); - members.push(deployMethod); - } - - return ts.factory.createClassDeclaration( - [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], - name, - undefined, - [ - ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ - ts.factory.createExpressionWithTypeArguments(ts.factory.createRegularExpressionLiteral('Contract'), [ - ts.factory.createTypeReferenceNode(`${name}Definition`, undefined), - ]), - ]), - ], - members, - ); -} - -/** - * Creates and returns a TypeScript interface declaration for the contract definition. - * The generated interface contains property signatures for 'methods', 'events', and 'eventLogs'. - * This interface serves as a type definition for the contract instance, providing type information - * for its methods, events, and event logs, making it easier to interact with the contract in a type-safe manner. - * - * @param name - The name of the contract. - * @returns A TypeScript InterfaceDeclaration representing the contract definition. - */ -function makeDefinitionInterface(name: string) { - const props = [ - ts.factory.createPropertySignature( - undefined, - 'methods', - undefined, - ts.factory.createTypeReferenceNode(`${name}Methods`, undefined), - ), - ts.factory.createPropertySignature( - undefined, - 'events', - undefined, - ts.factory.createTypeReferenceNode(`${name}Events`, undefined), - ), - ts.factory.createPropertySignature( - undefined, - 'eventLogs', - undefined, - ts.factory.createTypeReferenceNode(`${name}EventLogs`, undefined), - ), - ]; - - return ts.factory.createInterfaceDeclaration( - [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], - `${name}Definition`, - undefined, - undefined, - props, - ); -} - -/** - * Generate a TypeScript export statement for the given ABI name. - * The exported variable is named '$(name)Abi' and its value is the 'abi' identifier. - * - * @param name - The name of the contract ABI to be exported. - * @returns A TypeScript export statement node. - */ -function makeAbiExport(name: string) { - return ts.factory.createVariableStatement( - [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], - [ts.factory.createVariableDeclaration(`${name}Abi`, undefined, undefined, ts.factory.createIdentifier('abi'))], - ); -} - -/** - * Generate TypeScript source code as AST nodes for a Contract based on the provided ABI and initialization data. - * The generated code includes imports, event types, event log interfaces, events interface, transaction receipt interface, - * methods interface, definition interface, contract class, and ABI export. - * - * @param name - The name of the Contract. - * @param abi - The Contract ABI Definition. - * @param initData - The initialization data (bytecode) of the Contract. - * @param importPath - Path to '\@aztec/ethereum.js' package used for generating import statements. - * @returns An array of TypeScript Nodes representing the generated source code. - */ -function makeFile(name: string, abi: ContractAbiDefinition, initData: string | undefined, importPath: string) { - const imports = makeImports(name, importPath); - const eventTypes = makeEventTypes(abi); - const eventLogTypes = makeEventLogInterfaces(abi); - const eventsInterface = makeEventsInterface(name, abi); - const eventLogsInterface = makeEventLogsInterface(name, abi); - const eventTxLogsInterface = makeTxEventLogsInterface(name, abi); - const txReceiptInterface = makeTransactionReceiptInterface(name); - const methodsInterface = makeMethodsInterface(name, abi); - const definitionInterface = makeDefinitionInterface(name); - const contract = makeContract(name, initData, abi); - const abiExport = makeAbiExport(name); - - return ts.factory.createNodeArray([ - ...imports, - ...eventTypes, - ...eventLogTypes, - eventsInterface, - eventLogsInterface, - eventTxLogsInterface, - txReceiptInterface, - methodsInterface, - definitionInterface, - contract, - abiExport, - ]); -} - -/** - * Generate the ABI (Application Binary Interface) for a contract and write it to a file. - * The output file will be named as '(name)Abi.ts' in the specified 'outputPath'. - * The generated file contains an exported default instance of ContractAbi class created - * with the provided ABI definition. The import path for the required modules is also generated. - * - * @param outputPath - The path where the generated ABI file will be saved. - * @param name - The name of the contract for which the ABI file is being generated. - * @param abi - The ContractAbiDefinition object containing the ABI details of the contract. - * @param importPath - The import path for the required modules in the generated file. - */ -function makeAndWriteAbi(outputPath: string, name: string, abi: ContractAbiDefinition, importPath: string) { - const abiOutputFile = `${outputPath}/${name}Abi.ts`; - const output = `import { ContractAbi } from '${getImport( - importPath, - 'contract', - )}';\nexport default new ContractAbi(${JSON.stringify(abi, undefined, 2)});`; - fs.writeFileSync(abiOutputFile, output); -} - -/** - * Generate and write TypeScript interface and ABI files for a contract, based on the ABI - * and other data from the build artifact. The generated files will be written to the specified - * outputPath with the provided name. - * - * @param outputPath - The path where the output files will be created. - * @param name - The name of the contract used as a prefix for the generated files. - * @param buildData - An object containing the ABI and initData of the contract. - * @param importPath - The import path for the '\@aztec/ethereum.js' module. - * @returns A Promise that resolves when all files have been written. - */ -export async function makeAndWriteFiles( - outputPath: string, - name: string, - { abi, initData }: ContractBuildData, - importPath: string, -) { - const interfaceOutputFile = `${outputPath}/${name}.ts`; - - const resultFile = ts.createSourceFile('', '', ts.ScriptTarget.Latest, false, ts.ScriptKind.TS); - const nodes = makeFile(name, abi, initData, importPath); - - // Not sure how to make a single Node out of the NodeArray. Otherwise this would be a clean one liner. - await fs.promises.unlink(interfaceOutputFile).catch(() => {}); - fs.appendFileSync(interfaceOutputFile, '// THIS IS GENERATED CODE, DO NOT EDIT!\n'); - fs.appendFileSync(interfaceOutputFile, '/* eslint-disable */\n'); - for (const node of nodes) { - fs.appendFileSync(interfaceOutputFile, printer.printNode(ts.EmitHint.Unspecified, node, resultFile) + '\n'); - } - - makeAndWriteAbi(outputPath, name, abi, importPath); -} - -/** - * Execute the main function to generate and write contract files. - * It reads the configuration from the provided JSON file or a default 'contracts.json'. - * The function will output generated contract files into the specified outputPath, - * and use the importPath for resolving imports in the generated code. - * - * @throws If an error occurs while reading the config file, creating directories, or generating output files. - */ -async function main() { - const configFile = process.argv[2] || 'contracts.json'; - const config = JSON.parse(fs.readFileSync(configFile).toString()) as Config; - const { outputPath = './contracts', importPath = '@aztec/ethereum.js' } = config; - - process.chdir(dirname(configFile)); - fs.mkdirSync(outputPath, { recursive: true }); - - await Promise.all( - Object.entries(config.contracts).map(async entry => { - const buildData = await loadDataFromConfig(entry[1]); - return makeAndWriteFiles(outputPath, entry[0], buildData, importPath); - }), - ); -} - -main().catch(console.error); diff --git a/yarn-project/ethereum.js/src/contract/gen_def/sources/config.ts b/yarn-project/ethereum.js/src/contract/gen_def/sources/config.ts deleted file mode 100644 index ada755b63dc..00000000000 --- a/yarn-project/ethereum.js/src/contract/gen_def/sources/config.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (c) 2019 xf00f - - This file is part of web3x and is released under the MIT License. - https://opensource.org/licenses/MIT -*/ - -import { ContractAbiDefinition } from '../../abi/index.js'; - -/** - * Represents a file-based source for contract ABI and initialization data. - * Provides a convenient way to specify the contract name, ABI file location, - * and optional initialization data file location when generating contract interfaces. - */ -interface FileSource { - /** - * The origin of contract configuration data. - */ - source: 'files'; - /** - * The unique identifier for the contract configuration. - */ - name: string; - /** - * Path to the contract's ABI file. - */ - abiFile: string; - /** - * Optional file containing initialization data for the contract. - */ - initDataFile?: string; -} - -/** - * Represents an Etherscan source configuration for a smart contract. - * Provides necessary information to fetch the ABI and contract details from the Etherscan API. - */ -interface EtherscanSource { - /** - * The source from which the contract definition is obtained. - */ - source: 'etherscan'; - /** - * The unique identifier for the contract. - */ - name: string; - /** - * The Ethereum network identifier. - */ - net: string; - /** - * The Ethereum contract address. - */ - address: string; -} - -/** - * Represents a Truffle-based source configuration for contract information. - * Provides properties to identify the contract name and associated build file - * in order to extract ABI and other necessary data for further web3x usage. - */ -interface TruffleSource { - /** - * The origin of contract information. - */ - source: 'truffle'; - /** - * The unique identifier for the contract. - */ - name: string; - /** - * The path to the build file containing contract information. - */ - buildFile: string; -} - -/** - * Represents a Foundry build file source for contract configuration. - * Provides necessary details to locate and use the Foundry generated build files for smart contracts. - */ -interface FoundrySource { - /** - * The origin of the contract configuration data. - */ - source: 'foundry'; - /** - * The unique identifier for a contract. - */ - name: string; - /** - * The path to the build file containing contract information. - */ - buildFile: string; -} - -/** - * Represents an inline contract source configuration. - * Provides a convenient way to directly specify the contract ABI and optional initialization data in the configuration object. - */ -interface InlineSource { - /** - * The origin of contract ABI and initialization data. - */ - source: 'inline'; - /** - * The name identifier for the contract. - */ - name: string; - /** - * The contract's Application Binary Interface (ABI) definition. - */ - abi: ContractAbiDefinition; - /** - * Initialization data for contract deployment. - */ - initData?: string; -} - -/** - * Union type representing various contract configuration sources including file, Etherscan, Truffle, Foundry, and inline. - */ -export type ContractConfig = FileSource | EtherscanSource | TruffleSource | InlineSource | FoundrySource; - -/** - * Represents a configuration object for web3x contract generation. - * Provides options to specify import paths, output paths, and various contract source types for generating contract interfaces. - */ -export interface Config { - /** - * The path to import contracts from. - */ - importPath?: string; - /** - * The destination path for generated output files. - */ - outputPath?: string; - /** - * An array of contract configurations for various sources. - */ - contracts: ContractConfig[]; -} diff --git a/yarn-project/ethereum.js/src/contract/gen_def/sources/index.ts b/yarn-project/ethereum.js/src/contract/gen_def/sources/index.ts deleted file mode 100644 index 13ac2a48165..00000000000 --- a/yarn-project/ethereum.js/src/contract/gen_def/sources/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (c) 2019 xf00f - - This file is part of web3x and is released under the MIT License. - https://opensource.org/licenses/MIT -*/ - -import { ContractAbiDefinition } from '../../abi/index.js'; -import { ContractConfig } from './config.js'; -import { getFromEtherscan } from './source-etherscan.js'; -import { getFromFiles } from './source-files.js'; -import { getFromFoundry } from './source-foundry.js'; -import { getFromTruffle } from './source-truffle.js'; - -/** - * Represents contract build data for a smart contract. - * Contains the ABI definition and optional initialization data required for deploying and interacting with the contract. - */ -export interface ContractBuildData { - /** - * The Application Binary Interface (ABI) for a smart contract. - */ - abi: ContractAbiDefinition; - /** - * Initial deployment data for the contract. - */ - initData?: string; -} - -const { ETHERSCAN_API_KEY = '', ETHEREUM_HOST = '' } = process.env; - -/** - * Loads contract build data (ABI and initialization data) from the provided configuration object. - * Supports various sources such as Etherscan, files, Truffle, Foundry, and inline configuration. - * Throws an error if the source is not supported or if there's an issue with loading the data. - * - * @param contract - The ContractConfig object containing source and other required details. - * @returns A Promise that resolves to a ContractBuildData object containing ABI and optional initData. - */ -export async function loadDataFromConfig(contract: ContractConfig): Promise { - switch (contract.source) { - case 'etherscan': - return await getFromEtherscan(contract.net, contract.address, ETHERSCAN_API_KEY, ETHEREUM_HOST); - case 'files': - return getFromFiles(contract.abiFile, contract.initDataFile); - case 'truffle': - return getFromTruffle(contract.buildFile); - case 'foundry': - return getFromFoundry(contract.buildFile); - case 'inline': - return { abi: contract.abi, initData: contract.initData }; - } -} diff --git a/yarn-project/ethereum.js/src/contract/gen_def/sources/source-etherscan.ts b/yarn-project/ethereum.js/src/contract/gen_def/sources/source-etherscan.ts deleted file mode 100644 index 6bfc98f1e6f..00000000000 --- a/yarn-project/ethereum.js/src/contract/gen_def/sources/source-etherscan.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (c) 2019 xf00f - - This file is part of web3x and is released under the MIT License. - https://opensource.org/licenses/MIT -*/ - -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc } from '../../../eth_rpc/index.js'; -import { bufferToHex } from '../../../hex_string/index.js'; -import { JsonRpcProvider } from '../../../provider/json_rpc_provider.js'; -import { ContractAbiDefinition } from '../../abi/index.js'; - -/** - * Get the API host for a given Ethereum network. - * The function maps an input network string to its corresponding etherscan.io API host URL. - * Supported networks are 'mainnet', 'kovan', and 'ropsten'. Throws an error if an unknown network is provided. - * - * @param net - The Ethereum network string (e.g., 'mainnet', 'kovan', or 'ropsten'). - * @returns The etherscan.io API host URL for the specified network. - */ -function getApiHost(net: string) { - switch (net) { - case 'mainnet': - return 'api.etherscan.io'; - case 'kovan': - return 'api-kovan.etherscan.io'; - case 'ropsten': - return 'api-ropsten.etherscan.io'; - default: - throw new Error(`Unknown network ${net}`); - } -} - -/** - * Fetches the Contract Application Binary Interface (ABI) for a given Ethereum contract address from Etherscan API. - * The ABI is essential for interacting with smart contracts and decoding transactions in Ethereum. - * - * @param net - The Ethereum network identifier, such as 'mainnet', 'kovan', or 'ropsten'. - * @param address - The Ethereum contract address to fetch the ABI for. - * @param apiKey - The Etherscan API key for accessing their services. - * @returns A Promise that resolves to the ContractAbiDefinition containing the fetched ABI. - * @throws An Error if the network is unknown, or fetching the ABI fails. - */ -async function getAbi(net: string, address: string, apiKey: string): Promise { - const host = getApiHost(net); - const abiUrl = `http://${host}/api?module=contract&action=getabi&address=${address}&format=raw&apikey=${apiKey}`; - const response = await fetch(abiUrl); - const abi = await response.json(); - if (abi.status === '0') { - throw new Error(`Failed to fetch abi from etherscan: ${abi.result}`); - } - return abi; -} - -// async function getInitData(address: string, ethHost: string) { -// const host = getHost(net); -// const response: string = await fetch(`https://${host}/address/${address}`).then(r => r.text()); -// console.log(response); -// const initCodeMd = response.match(/
([0-9a-f]+)([0-9a-f]+)) { - super(ethRpc, promise); - } - - /** - * Processes the transaction receipt by decoding events, handling errors, and populating anonymous logs. - * The function takes a TransactionReceipt, a ContractAbi, and an EthereumRpc as its input parameters, - * and returns a Promise that resolves to a ContractTxReceipt containing the processed data. - * It separates logs into anonymousLogs (emitted by external contract calls) and decodes events - * according to the contract's ABI. If the transaction status is falsy, it attempts to decode - * the error using the provided ABI and includes it in the resulting ContractTxReceipt. - * - * @param receipt - The TransactionReceipt to be processed. - * @param contractAbi - The ContractAbi instance used for event decoding and error handling. - * @param ethRpc - The EthereumRpc instance used for interacting with the Ethereum network. - * @returns A Promise that resolves to a ContractTxReceipt object containing anonymousLogs, decoded events, and optional error information. - */ - protected async handleReceipt(throwOnError = true, receipt: TransactionReceipt) { - const result = await handleReceipt(receipt, this.contractAbi, this.ethRpc); - if (result.error && throwOnError) { - throw new Error(`Receipt indicates transaction failed: ${result.error.message}`); - } - return result; - } -} - -/** - * Handle and process a contract transaction receipt by decoding the events and extending - * the original receipt with additional properties (anonymousLogs, events, error) related - * to the contract function call. This function filters out anonymous logs that were emitted - * as part of external contract calls and decodes known events based on the provided ABI. - * If the receipt indicates a failure, it also attempts to decode the error message. - * - * @param receipt - The TransactionReceipt object for the contract function call. - * @param contractAbi - The ContractAbi instance representing the contract's ABI. - * @param ethRpc - The EthereumRpc instance for making RPC calls. - * @returns A Promise resolving to a ContractTxReceipt object with decoded events and extended properties. - */ -export async function handleReceipt( - receipt: TransactionReceipt, - contractAbi: ContractAbi, - ethRpc: EthereumRpc, -): Promise { - const { logs, to, contractAddress = to!, status, transactionHash } = receipt; - - if (!status) { - const error = await decodeErrorFromContractByTxHash(contractAbi, transactionHash, ethRpc); - return { ...receipt, anonymousLogs: [], events: {}, error }; - } - - if (!Array.isArray(logs)) { - return { ...receipt, anonymousLogs: [], events: {} }; - } - - const isAnonymous = (log: LogResponse) => !log.address.equals(contractAddress) || !contractAbi.findEntryForLog(log); - - const anonymousLogs = logs.filter(isAnonymous); - - const events = logs.reduce((a, log) => { - if (isAnonymous(log)) { - return a; - } - const ev = contractAbi.decodeEvent(log); - a[ev.event] = a[ev.event] || []; - a[ev.event].push(ev); - return a; - }, {}); - - return { ...receipt, anonymousLogs, events }; -} diff --git a/yarn-project/ethereum.js/src/contract/sent_deploy_contract_tx.ts b/yarn-project/ethereum.js/src/contract/sent_deploy_contract_tx.ts deleted file mode 100644 index 442f97ae8a0..00000000000 --- a/yarn-project/ethereum.js/src/contract/sent_deploy_contract_tx.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc, TransactionReceipt, TxHash } from '../eth_rpc/index.js'; -import { ContractAbi } from './abi/index.js'; -import { ContractTxReceipt } from './contract_tx_receipt.js'; -import { SentContractTx } from './sent_contract_tx.js'; - -/** - * Extends the standard contract SentContractTx class to execute a callback, which is currently used to set the - * contract address on the original Contract instance. - */ -export class SentDeployContractTx extends SentContractTx { - constructor( - eth: EthereumRpc, - contractAbi: ContractAbi, - promise: Promise, - private onDeployed: (address: EthAddress) => void, - ) { - super(eth, contractAbi, promise); - } - - /** - * Handles the transaction receipt for a contract deployment, executing a callback - * with the deployed contract address when it is available in the receipt. - * Extends the base class method to include the onDeployed callback execution. - * - * @param throwOnError - A boolean flag indicating whether to throw an error on non-zero exit status. - * @param receipt - The transaction receipt object containing the contract address and other details. - * @returns A Promise resolving to a ContractTxReceipt instance containing transaction receipt data. - */ - protected async handleReceipt(throwOnError = true, receipt: TransactionReceipt): Promise { - if (receipt.contractAddress) { - this.onDeployed(receipt.contractAddress); - } - - return await super.handleReceipt(throwOnError, receipt); - } -} diff --git a/yarn-project/ethereum.js/src/crypto/index.ts b/yarn-project/ethereum.js/src/crypto/index.ts deleted file mode 100644 index d1088140294..00000000000 --- a/yarn-project/ethereum.js/src/crypto/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './random/index.js'; -export * from './keccak256/index.js'; -export * from './pbkdf2/index.js'; -export * from './scrypt/index.js'; diff --git a/yarn-project/ethereum.js/src/crypto/keccak256/index.ts b/yarn-project/ethereum.js/src/crypto/keccak256/index.ts deleted file mode 100644 index 932ae901e39..00000000000 --- a/yarn-project/ethereum.js/src/crypto/keccak256/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Keccak } from 'sha3'; - -/** - * Generate a Keccak-256 hash of the given input Buffer. - * The function takes a Buffer as an input and returns a Buffer containing the hash result. - * It is commonly used for hashing data in Ethereum and other blockchain applications. - * - * @param input - The input data to be hashed, provided as a Buffer. - * @returns A Buffer representing the Keccak-256 hash of the input data. - */ -export function keccak256(input: Buffer) { - const hash = new Keccak(256); - return hash.update(input).digest(); -} - -/** - * Takes a string hex input e.g. `deadbeef` and returns the same. - */ -export function keccak256String(input: string) { - const hash = new Keccak(256); - hash.reset(); - hash.update(input); - return hash.digest('hex'); -} - -/** - * Generates a sha3 hash by applying the keccak256 hashing algorithm to a given input string. - * The resulting hash is then prefixed with '0x' to indicate that it's a hex-encoded value. - * This function is commonly used for Ethereum address hashing and smart contract function signatures. - * - * @param input - The input string to be hashed using the keccak256 algorithm. - * @returns A hex-encoded sha3 hash string, prefixed with '0x'. - */ -export function sha3(input: string) { - return '0x' + keccak256String(input); -} diff --git a/yarn-project/ethereum.js/src/crypto/pbkdf2/index.ts b/yarn-project/ethereum.js/src/crypto/pbkdf2/index.ts deleted file mode 100644 index 1817cfbe8fb..00000000000 --- a/yarn-project/ethereum.js/src/crypto/pbkdf2/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import pbkdf2Lib from 'pbkdf2'; - -/** - * Derives a cryptographic key from a password using the PBKDF2 (Password-Based Key Derivation Function 2) algorithm. - * This function returns a Promise that resolves to a Buffer containing the derived key. - * It uses the 'sha256' hash algorithm as the underlying pseudorandom function. - * - * @param password - The input password as a Buffer. - * @param salt - A unique and random salt value as a Buffer to protect against rainbow table attacks. - * @param iterations - The number of iterations to perform, which determines the computational cost of the key derivation. - * @param dklen - The desired length of the derived key in bytes. - * @returns A Promise that resolves to a Buffer containing the derived key. - */ -export function pbkdf2(password: Buffer, salt: Buffer, iterations: number, dklen: number): Promise { - return new Promise((resolve, reject) => { - pbkdf2Lib.pbkdf2(password, salt, iterations, dklen, 'sha256', (err, result) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); -} - -/** - * Synchronously generates a derived key from the given password and salt using the PBKDF2 algorithm with SHA-256. - * This function is useful when a non-blocking, synchronous operation is required for key derivation. - * - * @param password - The input password as a Buffer. - * @param salt - The salt value as a Buffer. - * @param iterations - The number of iterations to perform in the PBKDF2 algorithm. - * @param dklen - The length of the derived key to generate, in bytes. - * @returns A Buffer containing the derived key. - */ -export function pbkdf2Sync(password: Buffer, salt: Buffer, iterations: number, dklen: number) { - return pbkdf2Lib.pbkdf2Sync(password, salt, iterations, dklen, 'sha256'); -} diff --git a/yarn-project/ethereum.js/src/crypto/random/index.test.ts b/yarn-project/ethereum.js/src/crypto/random/index.test.ts deleted file mode 100644 index 7aa2c740374..00000000000 --- a/yarn-project/ethereum.js/src/crypto/random/index.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { randomBytes } from './index.js'; - -describe('random', () => { - it('randomBytes returns a filled byte array', () => { - const data = randomBytes(32); - expect(data.length).toEqual(32); - let identical = true; - for (let i = 1; i < data.length; ++i) { - identical = identical && data[i] == data[i - 1]; - } - expect(identical).toEqual(false); - }); -}); diff --git a/yarn-project/ethereum.js/src/crypto/random/index.ts b/yarn-project/ethereum.js/src/crypto/random/index.ts deleted file mode 100644 index 8b5df8f5643..00000000000 --- a/yarn-project/ethereum.js/src/crypto/random/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import isNode from 'detect-node'; -import nodeCrypto from 'crypto'; - -// limit of Crypto.getRandomValues() -// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues -const MAX_BYTES = 65536; - -const getWebCrypto = () => { - if (typeof window !== 'undefined' && window.crypto) return window.crypto; - if (typeof self !== 'undefined' && self.crypto) return self.crypto; - return undefined; -}; - -export const randomBytes = (len: number) => { - if (isNode) { - return nodeCrypto.randomBytes(len) as Buffer; - } - - const crypto = getWebCrypto(); - if (!crypto) { - throw new Error('randomBytes UnsupportedEnvironment'); - } - - const buf = Buffer.allocUnsafe(len); - if (len > MAX_BYTES) { - // this is the max bytes crypto.getRandomValues - // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues - for (let generated = 0; generated < len; generated += MAX_BYTES) { - // buffer.slice automatically checks if the end is past the end of - // the buffer so we don't have to here - crypto.getRandomValues(buf.slice(generated, generated + MAX_BYTES)); - } - } else { - crypto.getRandomValues(buf); - } - - return buf; -}; diff --git a/yarn-project/ethereum.js/src/crypto/scrypt/index.ts b/yarn-project/ethereum.js/src/crypto/scrypt/index.ts deleted file mode 100644 index 9fedc6cbc95..00000000000 --- a/yarn-project/ethereum.js/src/crypto/scrypt/index.ts +++ /dev/null @@ -1,322 +0,0 @@ -import { pbkdf2, pbkdf2Sync } from '../pbkdf2/index.js'; - -const MAX_VALUE = 0x7fffffff; -/** - * The following is an adaptation of scryptsy. - * See: https://www.npmjs.com/package/scryptsy. - * - */ -function blockmixSalsa8(BY, Yi, r, x, _X) { - let i; - - arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16); - for (i = 0; i < 2 * r; i++) { - blockxor(BY, i * 16, _X, 16); - salsa208(_X, x); - arraycopy(_X, 0, BY, Yi + i * 16, 16); - } - - for (i = 0; i < r; i++) { - arraycopy(BY, Yi + i * 2 * 16, BY, i * 16, 16); - } - - for (i = 0; i < r; i++) { - arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16); - } -} - -/** - * Perform a bitwise rotation operation on the given input values. - * The value 'a' is left-shifted by 'b' bits, while the remaining rightmost bits are rotated to the left side. - * This operation is useful in cryptographic algorithms and hash functions. - * - * @param a - The initial integer value to be rotated. - * @param b - The number of bits to perform the rotation operation. - * @returns The resulting integer value after the bitwise rotation. - */ -function R(a, b) { - return (a << b) | (a >>> (32 - b)); -} - -/** - * Perform the Salsa20/8 core hashing operation on a given input block. - * This function modifies the provided 512-bit 'B' array in place, applying - * the Salsa20/8 hash function. The '_X' parameter is used as temporary storage - * during the computation to avoid additional memory allocations. - * - * @param B - The 16-element Uint32Array containing the input block to be hashed. - * @param _X - A 16-element Uint32Array used as scratch space during computation. - */ -function salsa208(B, x) { - arraycopy(B, 0, x, 0, 16); - - for (let i = 8; i > 0; i -= 2) { - x[4] ^= R(x[0] + x[12], 7); - x[8] ^= R(x[4] + x[0], 9); - x[12] ^= R(x[8] + x[4], 13); - x[0] ^= R(x[12] + x[8], 18); - x[9] ^= R(x[5] + x[1], 7); - x[13] ^= R(x[9] + x[5], 9); - x[1] ^= R(x[13] + x[9], 13); - x[5] ^= R(x[1] + x[13], 18); - x[14] ^= R(x[10] + x[6], 7); - x[2] ^= R(x[14] + x[10], 9); - x[6] ^= R(x[2] + x[14], 13); - x[10] ^= R(x[6] + x[2], 18); - x[3] ^= R(x[15] + x[11], 7); - x[7] ^= R(x[3] + x[15], 9); - x[11] ^= R(x[7] + x[3], 13); - x[15] ^= R(x[11] + x[7], 18); - x[1] ^= R(x[0] + x[3], 7); - x[2] ^= R(x[1] + x[0], 9); - x[3] ^= R(x[2] + x[1], 13); - x[0] ^= R(x[3] + x[2], 18); - x[6] ^= R(x[5] + x[4], 7); - x[7] ^= R(x[6] + x[5], 9); - x[4] ^= R(x[7] + x[6], 13); - x[5] ^= R(x[4] + x[7], 18); - x[11] ^= R(x[10] + x[9], 7); - x[8] ^= R(x[11] + x[10], 9); - x[9] ^= R(x[8] + x[11], 13); - x[10] ^= R(x[9] + x[8], 18); - x[12] ^= R(x[15] + x[14], 7); - x[13] ^= R(x[12] + x[15], 9); - x[14] ^= R(x[13] + x[12], 13); - x[15] ^= R(x[14] + x[13], 18); - } - - for (let i = 0; i < 16; ++i) { - B[i] += x[i]; - } -} -/** - * Naive approach; going back to loop unrolling may yield additional performance. - */ -function blockxor(S, Si, D, len) { - for (let i = 0; i < len; i++) { - D[i] ^= S[Si + i]; - } -} - -/** - * Copies elements from the source array to the destination array. - * Starts copying elements from 'srcPos' index in the source array to 'destPos' index in the destination array, until the given length is reached. - * - * @param src - The source array to copy elements from. - * @param srcPos - The starting position in the source array to begin copying from. - * @param dest - The destination array to copy elements to. - * @param destPos - The starting position in the destination array to begin copying to. - * @param length - The number of elements to be copied from the source to destination array. - */ -function arraycopy(src, srcPos, dest, destPos, length) { - while (length--) { - dest[destPos++] = src[srcPos++]; - } -} - -/** - * Ensures the provided value is an integer. - * Parses the given value to an integer and checks if it's equal to the original value. - * Throws an error if the parsed and the original values are not equal, indicating that the value is not an integer. - * - * @param value - The value to be checked as an integer. - * @param name - A string representing the name of the parameter, used in the error message if the value is not an integer. - * @returns The integer value if the value is a valid integer. - * @throws If the provided value is not an integer. - */ -function ensureInteger(value, name) { - const intValue = parseInt(value, 10); - if (value !== intValue) { - throw new Error('invalid ' + name); - } - return intValue; -} -/** - * N = Cpu cost, r = Memory cost, p = parallelization cost. - * Callback(error, progress, key). - */ -export function scrypt(password, salt, N, r, p, dkLen, callback?: (progress: number) => boolean) { - return new Promise((resolve, reject) => { - N = ensureInteger(N, 'N'); - r = ensureInteger(r, 'r'); - p = ensureInteger(p, 'p'); - - dkLen = ensureInteger(dkLen, 'dkLen'); - - if (N === 0 || (N & (N - 1)) !== 0) { - reject(new Error('N must be power of 2')); - } - - if (N > MAX_VALUE / 128 / r) { - reject(new Error('N too large')); - } - if (r > MAX_VALUE / 128 / p) { - reject(new Error('r too large')); - } - - let b = [...pbkdf2Sync(password, salt, 1, p * 128 * r)]; - const B = new Uint32Array(p * 32 * r); - for (let i = 0; i < B.length; i++) { - const j = i * 4; - B[i] = - ((b[j + 3] & 0xff) << 24) | ((b[j + 2] & 0xff) << 16) | ((b[j + 1] & 0xff) << 8) | ((b[j + 0] & 0xff) << 0); - } - - const XY = new Uint32Array(64 * r); - const V = new Uint32Array(32 * r * N); - - const Yi = 32 * r; - - // scratch space - const x = new Uint32Array(16); // salsa20_8 - const _X = new Uint32Array(16); // blockmix_salsa8 - - const totalOps = p * N * 2; - let currentOp = 0; - let lastPercent10: any = null; - - // Set this to true to abandon the scrypt on the next step - let stop = false; - - // State information - let state = 0; - let i0 = 0; - let i1 = 0; - let Bi; - - // How many blockmix_salsa8 can we do per step? - const limit = Math.trunc(1000 / r); - - // Trick from scrypt-async; if there is a setImmediate shim in place, use it - const nextTick: any = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout; - - // This is really all I changed; making scryptsy a state machine so we occasionally - // stop and give other evnts on the evnt loop a chance to run. ~RicMoo - const incrementalSMix = async () => { - if (stop) { - if (callback) { - callback(currentOp / totalOps); - } - reject(new Error('cancelled')); - return; - } - - switch (state) { - case 0: - // for (var i = 0; i < p; i++)... - Bi = i0 * 32 * r; - - arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1 - - state = 1; // Move to ROMix 2 - i1 = 0; - - // Fall through - - case 1: { - // Run up to 1000 steps of the first inner smix loop - let steps = N - i1; - if (steps > limit) { - steps = limit; - } - for (let i = 0; i < steps; i++) { - // ROMix - 2 - arraycopy(XY, 0, V, (i1 + i) * Yi, Yi); // ROMix - 3 - blockmixSalsa8(XY, Yi, r, x, _X); // ROMix - 4 - } - - // for (var i = 0; i < N; i++) - i1 += steps; - currentOp += steps; - - // Call the callback with the progress (optionally stopping us) - const percent10 = Math.trunc((1000 * currentOp) / totalOps); - if (percent10 !== lastPercent10) { - if (callback) { - stop = callback(currentOp / totalOps); - } - if (stop) { - break; - } - lastPercent10 = percent10; - } - - if (i1 < N) { - break; - } - - i1 = 0; // Move to ROMix 6 - state = 2; - } - // Fall through - - case 2: { - // Run up to 1000 steps of the second inner smix loop - let steps = N - i1; - if (steps > limit) { - steps = limit; - } - for (let i = 0; i < steps; i++) { - // ROMix - 6 - const offset = (2 * r - 1) * 16; // ROMix - 7 - const j = XY[offset] & (N - 1); - blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner) - blockmixSalsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer) - } - - // for (var i = 0; i < N; i++)... - i1 += steps; - currentOp += steps; - - // Call the callback with the progress (optionally stopping us) - const percent10 = Math.trunc((1000 * currentOp) / totalOps); - if (percent10 !== lastPercent10) { - if (callback) { - stop = callback(currentOp / totalOps); - } - if (stop) { - break; - } - lastPercent10 = percent10; - } - - if (i1 < N) { - break; - } - - arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10 - - // for (var i = 0; i < p; i++)... - i0++; - if (i0 < p) { - state = 0; - break; - } - - b = []; - for (const bb of B) { - b.push((bb >> 0) & 0xff); - b.push((bb >> 8) & 0xff); - b.push((bb >> 16) & 0xff); - b.push((bb >> 24) & 0xff); - } - - const derivedKey = await pbkdf2(password, Buffer.from(b), 1, dkLen); - - // Done; don't break (which would reschedule) - if (callback) { - callback(1.0); - } - resolve(derivedKey); - return; - } - } - - // Schedule the next steps - nextTick(incrementalSMix); - }; - - // Bootstrap the incremental smix - void incrementalSMix(); - }); -} diff --git a/yarn-project/ethereum.js/src/eth_account/eth_account.test.ts b/yarn-project/ethereum.js/src/eth_account/eth_account.test.ts deleted file mode 100644 index 88a7095d216..00000000000 --- a/yarn-project/ethereum.js/src/eth_account/eth_account.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthTransaction } from '../eth_transaction/index.js'; -import { EthAccount } from './eth_account.js'; - -describe('eth_account', () => { - it('should create account', () => { - const account = EthAccount.create(); - expect(account).toBeInstanceOf(EthAccount); - }); - - it('should create account from private key', () => { - const privateKey = Buffer.from('7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d', 'hex'); - const account = new EthAccount(privateKey); - expect(account.address.toChecksumString()).toBe('0x008AeEda4D805471dF9b2A5B0f38A0C3bCBA786b'); - }); - - it('should create account from mnemonic and path', () => { - const mnemonic = 'uncover parade truck rhythm cinnamon cattle polar luxury chest anchor cinnamon coil'; - const path = "m/44'/60'/0'/0/0"; - const account = EthAccount.fromMnemonicAndPath(mnemonic, path); - expect(account.address.toChecksumString()).toBe('0xb897DF5d6c6D5b15E7340D7Ea2A8B8dC776B43F4'); - expect(account.privateKey.toString('hex')).toBe('dc21e91bcb468f2c2484f44f947f38625b441366f9afe82cda6f3d9de0135c3b'); - }); - - it('should encrypt and decrypt account', async () => { - const account = EthAccount.create(); - const keyStore = await account.toKeyStoreJson('password'); - const decrypted = await EthAccount.fromKeyStoreJson(keyStore, 'password'); - expect(decrypted.address).toEqual(account.address); - expect(decrypted.privateKey).toEqual(account.privateKey); - }); - - it('should sign message', () => { - const privateKey = Buffer.from('7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d', 'hex'); - const account = new EthAccount(privateKey); - const message = Buffer.from('data to sign'); - const signature = account.signMessage(message); - expect(account.signedMessage(message, signature)).toBe(true); - }); - - it('should sign transaction', () => { - const privateKey = Buffer.from('4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', 'hex'); - const tx: EthTransaction = { - chainId: 1, - nonce: 0, - maxFeePerGas: BigInt('20000000000'), - maxPriorityFeePerGas: BigInt('10000000000'), - gas: 21000, - to: EthAddress.fromString('0xF0109fC8DF283027b6285cc889F5aA624EaC1F55'), - value: BigInt('1000000000'), - }; - const account = new EthAccount(privateKey); - const signedTx = account.signTransaction(tx); - expect(account.signedTransaction(tx, signedTx.signature)).toBe(true); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_account/eth_account.ts b/yarn-project/ethereum.js/src/eth_account/eth_account.ts deleted file mode 100644 index 8592bf8616e..00000000000 --- a/yarn-project/ethereum.js/src/eth_account/eth_account.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { mnemonicToSeedSync } from 'bip39'; -import hdkey from 'hdkey'; -import { default as elliptic } from 'elliptic'; -import { keccak256, randomBytes } from '../crypto/index.js'; -import { decryptFromKeyStoreJson, encryptToKeyStoreJson, KeyStoreJson } from '../keystore/index.js'; -import { EthSignature, hashMessage, recoverFromSignature, signMessage } from '../eth_sign/index.js'; -import { EthTransaction, signedTransaction, signTransaction } from '../eth_transaction/index.js'; -import { TypedData } from '../eth_typed_data/typed_data.js'; -import { getTypedDataHash } from '../eth_typed_data/index.js'; - -const secp256k1 = new elliptic.ec('secp256k1'); - -/** - * The EthAccount class represents an Ethereum account with associated private and public keys - * and provides methods for creating accounts, signing transactions, messages, and typed data. - * It also supports operations like validating signatures, generating KeyStore JSON, and creating - * accounts from mnemonics or seeds using HD wallet derivation paths. - */ -export class EthAccount { - /** - * The Ethereum address associated with the account. - */ - public readonly address: EthAddress; - /** - * The public key associated with the Ethereum account. - */ - public readonly publicKey: Buffer; - - constructor( - /** - * The private key of the Ethereum account. - */ - public readonly privateKey: Buffer, - ) { - const ecKey = secp256k1.keyFromPrivate(privateKey); - this.publicKey = Buffer.from(ecKey.getPublic(false, 'hex'), 'hex'); - // Why discarding first byte? - const publicHash = keccak256(this.publicKey.slice(1)); - this.address = new EthAddress(publicHash.slice(-20)); - } - - /** - * Create a new EthAccount instance using optional entropy. - * This function generates a random private key, optionally combined with the provided entropy, - * and creates an EthAccount instance with the corresponding address and public key. - * Throws an error if the generated private key is invalid. - * - * @param entropy - Optional buffer containing entropy to be combined with the randomly generated private key. Default is a 32-byte random buffer. - * @returns A new EthAccount instance with the generated private key, address, and public key. - */ - public static create(entropy: Buffer = randomBytes(32)) { - const innerHex = keccak256(Buffer.concat([randomBytes(32), entropy])); - const middleHex = Buffer.concat([randomBytes(32), innerHex, randomBytes(32)]); - const outerHex = keccak256(middleHex); - return new EthAccount(outerHex); - } - - /** - * Creates an EthAccount instance from a mnemonic phrase and a derivation path. - * The mnemonic is used to generate the seed, which is then used with the provided derivation path - * to derive the private key for the account. This function is useful when working with - * Hierarchical Deterministic (HD) wallets. - * - * @param mnemonic - The mnemonic phrase representing the seed for the HD wallet. - * @param derivationPath - The derivation path to generate the EthAccount's private key. - * @returns An EthAccount instance with the derived private key. - */ - public static fromMnemonicAndPath(mnemonic: string, derivationPath: string) { - const seed = mnemonicToSeedSync(mnemonic); - return EthAccount.fromSeedAndPath(seed, derivationPath); - } - - /** - * Create an EthAccount instance from a seed and derivation path. - * The function takes a Buffer containing the seed and a string with the derivation path, - * and generates the corresponding private key by following the BIP32 HD wallet standard. - * It then creates and returns an EthAccount object using the derived private key. - * - * @param seed - A Buffer containing the seed for the HD wallet. - * @param derivationPath - A string representing the BIP32 derivation path. - * @returns An EthAccount instance with the derived private key. - */ - public static fromSeedAndPath(seed: Buffer, derivationPath: string) { - const root = hdkey.fromMasterSeed(seed); - const addrNode = root.derive(derivationPath); - const privateKey = addrNode.privateKey; - return new EthAccount(privateKey); - } - - /** - * Create an EthAccount instance from a KeyStoreJson object. - * This method decrypts the encrypted private key in the v3 keystore with the provided password, - * and initializes the EthAccount instance with the decrypted private key. - * Throws an error if the password is incorrect or the decryption process fails. - * - * @param v3Keystore - The KeyStoreJson object representing the Ethereum keystore (v3 format). - * @param password - The password used to encrypt the private key in the keystore. - * @returns A Promise that resolves to an EthAccount instance. - */ - public static async fromKeyStoreJson(v3Keystore: KeyStoreJson, password: string) { - return new EthAccount(await decryptFromKeyStoreJson(v3Keystore, password)); - } - - /** - * Sign an Ethereum transaction using the account's private key. - * This method generates a digital signature for the provided transaction object - * by leveraging the private key of the account instance. The signed transaction can then - * be broadcasted to the Ethereum network for execution. - * - * @param tx - The EthTransaction object representing the details of the transaction to be signed. - * @returns An EthSignature object containing the generated signature for the transaction. - */ - public signTransaction(tx: EthTransaction) { - return signTransaction(tx, this.privateKey); - } - - /** - * Checks if a signed Ethereum transaction matches the expected address. - * The function takes an unsigned Ethereum transaction and its corresponding signature, - * then recovers the signer's Ethereum address from the signature and compares it - * to the current EthAccount instance's address. - * - * @param tx - The unsigned Ethereum transaction object. - * @param signature - The Ethereum signature object for the given transaction. - * @returns A boolean indicating whether the recovered address matches the EthAccount's address. - */ - public signedTransaction(tx: EthTransaction, signature: EthSignature) { - return signedTransaction(tx, signature).equals(this.address); - } - - /** - * Prefixes the arbitrary length message with the 'x19Ethereum Signed Message:n' preamble, and signs the message. - * @returns An EthSignature instance with the signature components (r, s, v). - */ - public signMessage(message: Buffer) { - return signMessage(hashMessage(message), this.privateKey); - } - - /** - * Signs a 32 byte digest. - * @returns An EthSignature instance with the signature components (r, s, v). - */ - public signDigest(digest: Buffer) { - if (digest.length !== 32) { - throw new Error('Expected digest to be 32 bytes.'); - } - return signMessage(digest, this.privateKey); - } - - /** - * Sign the typed data by first getting its hashed digest using the provided 'data' parameter, - * and then signing the resulting 32-byte digest with the account's private key. - * This function is useful for signing structured data according to EIP-712 standard. - * - * @param data - A TypedData object containing the type information and values to be signed. - * @returns An EthSignature representing the signature of the hashed typed data. - */ - public signTypedData(data: TypedData) { - return this.signDigest(getTypedDataHash(data)); - } - - /** - * Verifies if the given signature corresponds to the message signed by this EthAccount instance. - * It hashes the input message with the Ethereum Signed Message preamble, recovers the signer's address - * from the signature, and compares it against the EthAccount's address. - * - * @param message - The Buffer containing the message to be verified. - * @param signature - The EthSignature instance representing the signature of the message. - * @returns A boolean value indicating whether the signature corresponds to the message signed by this EthAccount. - */ - public signedMessage(message: Buffer, signature: EthSignature) { - return recoverFromSignature(hashMessage(message), signature).equals(this.address); - } - - /** - * Encrypts the EthAccount's private key into a KeyStore JSON format using the provided password. - * The KeyStore JSON can be stored securely and used later to recreate the EthAccount instance. - * The optional 'options' parameter can be used to customize the encryption process. - * - * @param password - The password used for encrypting the private key. - * @param options - Optional configuration object for the encryption process. - * @returns A KeyStoreJson instance representing the encrypted private key. - */ - public toKeyStoreJson(password: string, options?: any) { - return encryptToKeyStoreJson(this.privateKey, this.address, password, options); - } -} diff --git a/yarn-project/ethereum.js/src/eth_account/index.ts b/yarn-project/ethereum.js/src/eth_account/index.ts deleted file mode 100644 index bfa077c20cb..00000000000 --- a/yarn-project/ethereum.js/src/eth_account/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './eth_account.js'; diff --git a/yarn-project/ethereum.js/src/eth_rpc/ethereum_rpc.ts b/yarn-project/ethereum.js/src/eth_rpc/ethereum_rpc.ts deleted file mode 100644 index d77b7d85b0a..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/ethereum_rpc.ts +++ /dev/null @@ -1,339 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthSignature } from '../eth_sign/index.js'; -import { TypedData } from '../eth_typed_data/index.js'; -import { hexToBuffer } from '../hex_string/index.js'; -import { EthereumProvider } from '../provider/index.js'; -import { SentTx, SentTransaction } from './sent_tx.js'; -import { TxHash } from './tx_hash.js'; -import { - CallRequest, - fromRawBlockResponse, - fromRawLogResponse, - fromRawTransactionReceipt, - fromRawTransactionResponse, - NumberOrTag, - numberOrTagToHex, - RawLogResponse, - toRawCallRequest, - toRawEstimateRequest, - toRawTransactionRequest, - TransactionRequest, -} from './types/index.js'; -import { LogRequest, toRawLogRequest } from './types/log_request.js'; - -/** - * Provides a direct 1 to 1 mapping with the ethereum JSON-RPC specification. - * Link - https://ethereum.org/en/developers/docs/apis/json-rpc. - * - * Types are marshalled to/from sensible types. - * Number. - * BigInt. - * Buffer. - * TxHash. - * EthAddress. - */ -export class EthereumRpc { - constructor(private provider: EthereumProvider) {} - - /** - * Retrieves the currently implemented Ethereum protocol version. - * The returned value follows the semantic versioning specification (semver). - * This may be useful for determining compatibility between client and server implementations. - * - * @returns A Promise that resolves to a number representing the Ethereum protocol version. - */ - public async protocolVersion() { - const result = await this.provider.request({ method: 'eth_protocolVersion' }); - return Number(result); - } - - /** - * Retrieves the syncing status of the connected Ethereum node. - * When the node is not syncing, returns false. If syncing, returns an object containing - * startingBlock, currentBlock, and highestBlock which represent the block numbers of - * the syncing process's start point, current progress, and end point respectively. - * - * @returns A Promise that resolves to either false or an object with syncing status data. - */ - public async syncing() { - const result = await this.provider.request({ method: 'eth_syncing' }); - return { - startingBlock: Number(result.startingBlock), - currentBlock: Number(result.currentBlock), - highestBlock: Number(result.highestBlock), - }; - } - - /** - * Retrieve the currently configured chain ID of the Ethereum network. - * The chain ID is a unique identifier for each Ethereum network, allowing clients to distinguish - * between multiple networks and ensuring transaction replay protection. - * - * @returns A number representing the current chain ID. - */ - public async getChainId() { - const result = await this.provider.request({ method: 'eth_chainId' }); - return Number(result); - } - - /** - * Retrieve the contract code of a given `address` at a specific block number or block tag. - * The function allows querying the Ethereum blockchain for smart contract bytecode. - * Results are returned as a Buffer containing the bytecode in hexadecimal format. - * - * @param address - The EthAddress instance representing the Ethereum address of the smart contract. - * @param numberOrTag - Optional parameter specifying the block number or block tag (default is 'latest'). - * @returns A Promise that resolves to a Buffer containing the contract code in hexadecimal format. - */ - public async getCode(address: EthAddress, numberOrTag: NumberOrTag = 'latest') { - const result = await this.provider.request({ - method: 'eth_getCode', - params: [address.toString(), numberOrTagToHex(numberOrTag)], - }); - return hexToBuffer(result); - } - - /** - * Retrieves a list of Ethereum accounts available on the connected node. - * Each account is represented by an EthAddress instance. Useful for - * querying and interacting with accounts managed by the connected Ethereum node. - * - * @returns An array of EthAddress instances representing the available accounts. - */ - public async getAccounts() { - const result: string[] = await this.provider.request({ - method: 'eth_accounts', - }); - return result.map(EthAddress.fromString); - } - - /** - * Retrieves the number of transactions sent from the specified Ethereum address. - * This function sends a request to the 'eth_getTransactionCount' method with the address and 'latest' as parameters. - * The response is then converted to a Number before being returned. - * - * @param addr - The EthAddress instance representing the Ethereum address. - * @returns The number of transactions sent from the given address. - */ - public async getTransactionCount(addr: EthAddress) { - const result = await this.provider.request({ - method: 'eth_getTransactionCount', - params: [addr.toString(), 'latest'], - }); - return Number(result); - } - - /** - * Retrieves the current balance of the given Ethereum address. - * The balance is returned as a BigInt representing the amount of wei held by the address. - * - * @param addr - The EthAddress instance representing the Ethereum address to fetch the balance for. - * @returns A BigInt representing the balance of the given address in wei. - */ - public async getBalance(addr: EthAddress) { - const result = await this.provider.request({ - method: 'eth_getBalance', - params: [addr.toString(), 'latest'], - }); - return BigInt(result); - } - - /** - * Retrieves a transaction by its hash. - * The function returns the transaction details such as block hash, block number, from/to addresses, etc., by querying the Ethereum blockchain. - * - * @param txHash - The transaction hash of the target transaction. - * @returns A Promise that resolves to the transaction details in a human-readable format. - */ - public async getTransactionByHash(txHash: TxHash) { - const result = await this.provider.request({ - method: 'eth_getTransactionByHash', - params: [txHash.toString()], - }); - return fromRawTransactionResponse(result); - } - - /** - * Retrieves the transaction receipt for the given transaction hash. - * The transaction receipt contains information about the execution of a transaction, - * such as the status, gas used, and logs generated by the transaction. - * Returns undefined if the transaction hash is not found or the transaction is pending. - * - * @param txHash - The TxHash object representing the transaction hash. - * @returns A Promise that resolves to an object containing transaction receipt details or undefined if not found. - */ - public async getTransactionReceipt(txHash: TxHash) { - const result = await this.provider.request({ - method: 'eth_getTransactionReceipt', - params: [txHash.toString()], - }); - return fromRawTransactionReceipt(result); - } - - /** - * Retrieves the current block number from the Ethereum blockchain. - * The result is a decimal representation of the latest mined block number. - * - * @returns A Promise that resolves to the current block number as a Number. - */ - public async blockNumber() { - const result = await this.provider.request({ - method: 'eth_blockNumber', - params: [], - }); - return Number(result); - } - - /** - * Retrieve the block information by its block number or block tag. - * The block information includes data such as block hash, parent hash, miner, difficulty, etc. - * The transactions in the block can be optionally fetched in full detail by setting 'fullTxs' to true. - * - * @param numberOrTag - The block number or block tag ('earliest', 'latest', 'pending') to fetch the block information for. - * @param fullTxs - If set to true, the block information will include full transaction details. Defaults to false. - * @returns An object containing the detailed block information or undefined if the block is not found. - */ - public async getBlockByNumber(numberOrTag: NumberOrTag, fullTxs = false) { - const result = await this.provider.request({ - method: 'eth_getBlockByNumber', - params: [numberOrTagToHex(numberOrTag), fullTxs], - }); - return result ? fromRawBlockResponse(result) : undefined; - } - - /** - * Sign a message with the specified Ethereum address using the 'eth_sign' JSON-RPC method. - * The resulting signature can be used to verify that the message was signed by the owner of the provided address. - * - * @param address - The EthAddress instance representing the Ethereum address to sign the message with. - * @param message - The Buffer instance representing the message to be signed. - * @returns A Promise that resolves to an EthSignature instance representing the signed message. - */ - public async sign(address: EthAddress, message: Buffer) { - const result = await this.provider.request({ - method: 'eth_sign', - params: [address.toString(), `0x${message.toString('hex')}`], - }); - return EthSignature.fromString(result); - } - - /** - * Sign a message using the 'personal_sign' Ethereum JSON-RPC method with a specified Ethereum address. - * The provided message should be a Buffer, and the Ethereum address should be an EthAddress instance. - * This method is commonly used for signing messages to verify the ownership of an Ethereum account. - * - * @param message - The message to be signed as a Buffer. - * @param address - The EthAddress instance representing the Ethereum account used to sign the message. - * @returns An EthSignature instance containing the signed message from the provided Ethereum address. - */ - public async personalSign(message: Buffer, address: EthAddress) { - const result = await this.provider.request({ - method: 'personal_sign', - params: [`0x${message.toString('hex')}`, address.toString()], - }); - return EthSignature.fromString(result); - } - - /** - * Sign typed data using the EIP-712 Typed Data v4 standard. - * This function sends an 'eth_signTypedData_v4' JSON-RPC request to the Ethereum provider - * with the given address and data. The result is a signature in hex format which can be - * used to verify the signer of the typed data. - * - * @param address - The EthAddress of the signer. - * @param data - The TypedData object representing the structured data to be signed. - * @returns An EthSignature instance representing the signed message. - */ - public async signTypedDataV4(address: EthAddress, data: TypedData) { - const result = await this.provider.request({ - method: 'eth_signTypedData_v4', - params: [address.toString(), data], - }); - return EthSignature.fromString(result); - } - - /** - * Estimate the amount of gas needed for a given transaction to succeed. - * The 'estimateGas' function sends a simulated call request to the Ethereum network - * and returns the estimated gas required for the transaction to be executed. - * This is useful for determining the gas limit to set when sending a real transaction, - * helping to ensure that transactions are executed successfully and avoiding - * unnecessary gas consumption. - * - * @param tx - The CallRequest object containing transaction details. - * @returns A number representing the estimated gas required for the transaction. - */ - public async estimateGas(tx: CallRequest) { - const result = await this.provider.request({ - method: 'eth_estimateGas', - params: [toRawEstimateRequest(tx)], - }); - return Number(result); - } - - /** - * Executes a call to a smart contract function without modifying the blockchain state. - * The 'call' function returns the result of the executed code, and any gas used during execution is not deducted from the account. - * Useful for querying information from the blockchain or testing if a transaction would succeed without actually sending it. - * - * @param tx - The transaction request object containing information such as 'from', 'to', 'gas', 'gasPrice', 'value', and 'data'. - * @param numberOrTag - (Optional) A block number or one of the string tags "latest", "earliest", or "pending". Default is "latest". - * @returns A Buffer containing the return value of the executed function, if any. - */ - public async call(tx: CallRequest, numberOrTag: NumberOrTag = 'latest') { - const data = await this.provider.request({ - method: 'eth_call', - params: [toRawCallRequest(tx), numberOrTagToHex(numberOrTag)], - }); - return Buffer.from(data.slice(2), 'hex'); - } - - /** - * Sends a signed transaction to the Ethereum network and returns a SentTx instance. - * The 'sendTransaction' method takes a TransactionRequest object as input, converts it to a raw transaction, - * and sends it to the network using the 'eth_sendTransaction' JSON-RPC method. It then returns a SentTx instance - * which can be used to track the status of the submitted transaction, such as fetching the transaction receipt. - * - * @param tx - The TransactionRequest object containing the details of the transaction to be sent. - * @returns A SentTx instance for tracking the submitted transaction's status. - */ - public sendTransaction(tx: TransactionRequest): SentTx { - const txHashPromise = this.provider.request({ - method: 'eth_sendTransaction', - params: [toRawTransactionRequest(tx)], - }); - return new SentTransaction(this, txHashPromise); - } - - /** - * Sign a given Ethereum transaction using the specified private key. - * The 'TransactionRequest' object contains necessary information to sign the transaction such as nonce, gas price, gas limit, etc. - * Returns a Promise that resolves with a Buffer containing the signed transaction in raw bytes format. - * - * @param tx - The TransactionRequest object containing information required to sign the transaction. - * @returns A Promise that resolves with a raw signed transaction in buffer format. - */ - public async signTransaction(tx: TransactionRequest) { - const result = await this.provider.request({ - method: 'eth_signTransaction', - params: [toRawTransactionRequest(tx)], - }); - return hexToBuffer(result); - } - - /** - * Retrieve logs from Ethereum nodes based on the log request provided. - * This function queries the Ethereum node using JSON-RPC and returns an array of logs matching - * the given filters specified in the logRequest object. - * - * @param logRequest - An object containing the filter parameters for the logs to be retrieved. - * @returns An array of log objects matching the filter parameters. - */ - public async getLogs(logRequest: LogRequest) { - const result: RawLogResponse[] = await this.provider.request({ - method: 'eth_getLogs', - params: [toRawLogRequest(logRequest)], - }); - return result.map(fromRawLogResponse); - } -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/index.ts b/yarn-project/ethereum.js/src/eth_rpc/index.ts deleted file mode 100644 index 1d3129b3df7..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './types/index.js'; -export * from './ethereum_rpc.js'; -export * from './sent_tx.js'; -export * from './tx_hash.js'; diff --git a/yarn-project/ethereum.js/src/eth_rpc/sent_tx.ts b/yarn-project/ethereum.js/src/eth_rpc/sent_tx.ts deleted file mode 100644 index 3eb162fca97..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/sent_tx.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { retryUntil } from '../retry/index.js'; -import { EthereumRpc } from './ethereum_rpc.js'; -import { TxHash } from './tx_hash.js'; -import { TransactionReceipt } from './types/index.js'; - -/** - * Represents a transaction that has been sent. - * It can be queried for its transaction hash, or its transaction receipt. - * As it can be typed on a specific TxReceipt type, the receipt can have full type information regarding event logs. - */ -export interface SentTx { - getTxHash(): Promise; - getReceipt( - throwOnError?: boolean, - numConfirmations?: number, - timeout?: number, - interval?: number, - ): Promise; -} - -/** - * A standard implementation of SentTx. - * This is returned by the `EthereumRpc.sendTransaction` call. - * Can be extended to perform additional receipt handling in the `contract` module. - */ -export class SentTransaction implements SentTx { - private receipt?: TransactionReceipt | null; - - constructor(protected ethRpc: EthereumRpc, protected txHashPromise: Promise) {} - - /** - * Retrieve the transaction hash of the sent transaction. - * This function returns a promise that resolves with the TxHash of the transaction. - * Useful in tracking the status or obtaining the receipt of the transaction on the blockchain. - * - * @returns A Promise that resolves with the TxHash of the sent transaction. - */ - public async getTxHash(): Promise { - return await this.txHashPromise; - } - - /** - * Retrieve the transaction receipt for a given SentTx instance. - * This function will wait until the transaction has at least 'numConfirmations' confirmations before - * returning the receipt. If 'throwOnError' is set to true, it will throw an error if the receipt - * indicates that the transaction failed. Allows setting a 'timeout' and custom polling 'interval'. - * - * @param throwOnError - Whether to throw an error if the receipt status indicates failure. - * @param numConfirmations - The minimum number of confirmations required before returning the receipt. - * @param timeout - The maximum time in seconds to wait for the receipt before giving up. A value of 0 disables the timeout. - * @param interval - The time in seconds between polling attempts to fetch the receipt. - * @returns A promise that resolves to the fetched transaction receipt. - */ - public async getReceipt( - throwOnError = true, - numConfirmations = 1, - timeout = 0, - interval = 1, - ): Promise { - if (this.receipt) { - return this.receipt; - } - - const txHash = await this.getTxHash(); - const receipt = await waitForTxReceipt(txHash, this.ethRpc, numConfirmations, timeout, interval); - return await this.handleReceipt(throwOnError, receipt); - } - - /** - * Handles the transaction receipt based on the provided parameters. - * If throwOnError is true and the receipt status is false, an error will be thrown. - * Otherwise, returns the received transaction receipt as a resolved promise. - * - * @param throwOnError - A boolean flag indicating whether to throw an error if receipt status is false. - * @param receipt - The TransactionReceipt object received from the Ethereum network. - * @returns A Promise resolving to the given TransactionReceipt. - */ - protected handleReceipt(throwOnError = true, receipt: TransactionReceipt) { - if (throwOnError && !receipt.status) { - throw new Error('Receipt indicates transaction failed. Try a call() to determine cause of failure.'); - } - return Promise.resolve(receipt); - } -} - -/** - * A simple function to wait until a tx as a given number of confirmations, and return its receipt. - */ -export async function waitForTxReceipt(txHash: TxHash, eth: EthereumRpc, confirmations = 1, timeout = 0, interval = 1) { - return await retryUntil( - async () => { - const blockNumber = await eth.blockNumber(); - const receipt = await eth.getTransactionReceipt(txHash); - - if (!receipt) { - return; - } - - if (receipt.status === false) { - return receipt; - } - - if (blockNumber - receipt.blockNumber + 1 >= confirmations) { - return receipt; - } - }, - 'waitForTxReceipt', - timeout, - interval, - ); -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/tx_hash.ts b/yarn-project/ethereum.js/src/eth_rpc/tx_hash.ts deleted file mode 100644 index 870c23d0da6..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/tx_hash.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { randomBytes } from '../crypto/random/index.js'; - -/** - * The TxHash class represents a transaction hash in the form of a 32-byte buffer. - * It provides methods to create a TxHash instance from different input formats such as Buffer, string, or random bytes, - * as well as methods to compare, convert, and serialize the hash value. - * This class ensures that the transaction hash is valid and properly formatted. - */ -export class TxHash { - constructor(private buffer: Buffer) { - if (buffer.length !== 32) { - throw new Error('Invalid hash buffer.'); - } - } - - /** - * Create a TxHash instance from a given buffer. - * The input 'buffer' should be a Buffer with exactly 32 bytes length. - * Throws an error if the input buffer length is invalid. - * - * @param buffer - The Buffer representing the transaction hash. - * @returns A TxHash instance. - */ - static fromBuffer(buffer: Buffer) { - return new TxHash(buffer); - } - - /** - * Deserialize a Buffer into a TxHash instance starting at the specified offset. - * The function takes a buffer and an optional offset as input, slices the buffer - * from the offset to offset + 32 bytes, and creates a new TxHash object using this slice. - * Returns an object containing the created TxHash instance ('elem') and the number - * of bytes advanced in the buffer ('adv'), which is always 32 for a valid deserialization. - * - * @param buffer - The input Buffer containing the serialized TxHash data. - * @param offset - The optional starting position within the buffer to begin deserialization. Defaults to 0. - * @returns An object with properties 'elem' (TxHash instance) and 'adv' (number of bytes advanced). - */ - static deserialize(buffer: Buffer, offset: number) { - return { elem: new TxHash(buffer.slice(offset, offset + 32)), adv: 32 }; - } - - /** - * Create a TxHash instance from a hex-encoded string. - * The input 'hash' should be prefixed with '0x' or not, and have exactly 64 hex characters. - * Throws an error if the input length is invalid or the hash value is out of range. - * - * @param hash - The hex-encoded string representing the transaction hash. - * @returns A TxHash instance. - */ - public static fromString(hash: string) { - return new TxHash(Buffer.from(hash.replace(/^0x/i, ''), 'hex')); - } - - /** - * Generate a random TxHash instance with a buffer of 32 random bytes. - * This function utilizes the 'randomBytes' function from the crypto library to generate - * a buffer filled with cryptographically secure random bytes, which is then used to create - * the new TxHash instance. - * - * @returns A random TxHash instance. - */ - public static random() { - return new TxHash(randomBytes(32)); - } - - /** - * Compares the current TxHash instance with the provided TxHash instance. - * Returns true if their buffer contents are equal, otherwise returns false. - * - * @param rhs - The TxHash instance to compare with the current instance. - * @returns A boolean indicating whether the two TxHash instances have identical buffer contents. - */ - equals(rhs: TxHash) { - return this.toBuffer().equals(rhs.toBuffer()); - } - - /** - * Converts the current TxHash instance to a Buffer. - * The resulting buffer will have a length of 32 bytes. - * - * @returns A Buffer representation of the transaction hash. - */ - toBuffer() { - return this.buffer; - } - - /** - * Converts the TxHash instance to a hex-encoded string representation. - * The resulting string is prefixed with '0x' and contains exactly 64 hex characters. - * - * @returns A string representing the TxHash in hex format. - */ - toString() { - return `0x${this.toBuffer().toString('hex')}`; - } -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/block_response.test.ts b/yarn-project/ethereum.js/src/eth_rpc/types/block_response.test.ts deleted file mode 100644 index f24e7b461c6..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/block_response.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { hexToBuffer } from '../../hex_string/index.js'; -import { fromRawBlockResponse } from './block_response.js'; - -describe('formatters', () => { - describe('outputBlockFormatter', () => { - it('should return the correct value', () => { - expect( - fromRawBlockResponse({ - hash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - parentHash: '0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265', - miner: '0xdcc6960376d6c6dea93647383ffb245cfced97cf', - stateRoot: '0x54dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', - transactionsRoot: '0x64dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', - receiptsRoot: '0x74dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', - sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', - logsBloom: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - difficulty: '0x3e8', - totalDifficulty: '0x3e8', - number: '0x3e8', - gasLimit: '0x3e8', - gasUsed: '0x3e8', - timestamp: '0x3e8', - extraData: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - nonce: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - size: '0x3e8', - transactions: [], - uncles: [], - baseFeePerGas: '0x3e8', - }), - ).toEqual({ - hash: hexToBuffer('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - parentHash: hexToBuffer('0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265'), - miner: EthAddress.fromString('0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf'), - stateRoot: hexToBuffer('0x54dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583'), - transactionsRoot: hexToBuffer('0x64dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583'), - receiptsRoot: hexToBuffer('0x74dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583'), - sha3Uncles: hexToBuffer('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'), - logsBloom: hexToBuffer('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - difficulty: 1000n, - totalDifficulty: 1000n, - number: 1000, - gasLimit: 1000, - gasUsed: 1000, - timestamp: 1000, - extraData: hexToBuffer('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - nonce: hexToBuffer('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - size: 1000, - transactions: [], - uncles: [], - baseFeePerGas: 1000n, - }); - }); - it('should return the correct value, when null values are present', () => { - expect( - fromRawBlockResponse({ - hash: null, - parentHash: '0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265', - miner: '0xdcc6960376d6c6dea93647383ffb245cfced97cf', - stateRoot: '0x54dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', - transactionsRoot: '0x64dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', - receiptsRoot: '0x74dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', - sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', - logsBloom: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - difficulty: '0x3e8', - totalDifficulty: '0x3e8', - number: null, - gasLimit: '0x3e8', - gasUsed: '0x3e8', - timestamp: '0x3e8', - extraData: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - nonce: null, - size: '0x3e8', - transactions: [], - uncles: [], - baseFeePerGas: '0x3e8', - }), - ).toEqual({ - hash: null, - parentHash: hexToBuffer('0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265'), - miner: EthAddress.fromString('0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf'), - stateRoot: hexToBuffer('0x54dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583'), - transactionsRoot: hexToBuffer('0x64dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583'), - receiptsRoot: hexToBuffer('0x74dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583'), - sha3Uncles: hexToBuffer('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'), - logsBloom: hexToBuffer('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - difficulty: 1000n, - totalDifficulty: 1000n, - number: null, - gasLimit: 1000, - gasUsed: 1000, - timestamp: 1000, - extraData: hexToBuffer('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - nonce: null, - size: 1000, - transactions: [], - uncles: [], - baseFeePerGas: 1000n, - }); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/block_response.ts b/yarn-project/ethereum.js/src/eth_rpc/types/block_response.ts deleted file mode 100644 index 850fff388aa..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/block_response.ts +++ /dev/null @@ -1,301 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { - bigIntToHex, - bufferToHex, - hexToBigInt, - hexToBuffer, - hexToNumber, - numberToHex, -} from '../../hex_string/index.js'; -import { - fromRawTransactionResponse, - RawTransactionResponse, - toRawTransactionResponse, - TransactionResponse, -} from './transaction_response.js'; - -/** - * Represents a raw block header response in Ethereum. - * Contains all the essential information of a block, such as hash, parentHash, miner, and other details - * fetched from an Ethereum node, with values encoded as hexadecimal strings. - */ -export interface RawBlockHeaderResponse { - /** - * The unique identifier of a block. - */ - hash: string | null; - /** - * The parent block's hash value. - */ - parentHash: string; - /** - * The Keccak-256 hash of the uncles data in the block. - */ - sha3Uncles: string; - /** - * The Ethereum address of the block miner. - */ - miner: string; - /** - * The root hash of the Ethereum state trie. - */ - stateRoot: string; - /** - * The root hash of the merkle tree representing all transactions in the block. - */ - transactionsRoot: string; - /** - * The root hash of the trie structure containing all transaction receipts in the block. - */ - receiptsRoot: string; - /** - * Bloom filter containing logs for all transactions in the block. - */ - logsBloom: string | null; - /** - * The computational effort required to mine a new block. - */ - difficulty: string; - /** - * The block number in the blockchain. - */ - number: string | null; - /** - * The maximum amount of gas allowed in the block. - */ - gasLimit: string; - /** - * The total amount of gas consumed by all transactions in the block. - */ - gasUsed: string; - /** - * Unix timestamp representing the block creation time. - */ - timestamp: string; - /** - * Extra arbitrary metadata included in the block. - */ - extraData: string; - /** - * A unique number used to prevent double-spending and ensure the validity of a transaction. - */ - nonce: string | null; - /** - * The base fee per gas for each block, used in EIP-1559. - */ - baseFeePerGas: string | null; -} - -/** - * Represents a raw block response in the Ethereum blockchain. - * Contains information pertaining to the block header, transactions, and uncles in their raw hexadecimal format. - */ -export interface RawBlockResponse extends RawBlockHeaderResponse { - /** - * The total accumulated difficulty of the blockchain up to this block. - */ - totalDifficulty: string; - /** - * Size of the block in bytes. - */ - size: string; - /** - * A list of transactions included within the block. - */ - transactions: (RawTransactionResponse | string)[]; - /** - * An array of uncle blocks in the blockchain. - */ - uncles: string[]; -} - -/** - * Represents a block header response in the Ethereum blockchain. - * Provides essential information about a specific block, including its hash, parent hash, miner address, and other properties. - */ -export interface BlockHeaderResponse { - /** - * The hash representing the unique identifier of a block. - */ - hash: Buffer | null; - /** - * The hash of the parent block in the blockchain. - */ - parentHash: Buffer; - /** - * The Keccak-256 hash of the uncle blocks included in the block. - */ - sha3Uncles: Buffer; - /** - * The Ethereum address of the miner who successfully mined the block. - */ - miner: EthAddress; - /** - * The root hash of the state trie after applying transactions. - */ - stateRoot: Buffer; - /** - * The root hash of the Merkle tree containing all transaction hashes in the block. - */ - transactionsRoot: Buffer; - /** - * The root hash of the Merkle tree containing transaction receipts. - */ - receiptsRoot: Buffer; - /** - * A compressed representation of logs' topics and data for efficient filtering. - */ - logsBloom: Buffer | null; - /** - * The computational effort required to mine a new block. - */ - difficulty: bigint; - /** - * The block number within the blockchain. - */ - number: number | null; - /** - * The maximum amount of gas allowed in a block. - */ - gasLimit: number; - /** - * The total amount of gas consumed by all transactions in the block. - */ - gasUsed: number; - /** - * The UNIX timestamp when the block was mined. - */ - timestamp: number; - /** - * Arbitrary data included by the block miner. - */ - extraData: Buffer; - /** - * A unique value used to prevent duplicate transactions and secure block mining. - */ - nonce: Buffer | null; - /** - * The base fee per gas for the block, used in EIP-1559 transactions. - */ - baseFeePerGas: bigint | null; -} - -/** - * Represents a block on the Ethereum blockchain. - * Contains information about the block header, transactions, and other metadata. - */ -export interface BlockResponse extends BlockHeaderResponse { - /** - * The cumulative proof-of-work difficulty of the blockchain up to this block. - */ - totalDifficulty: bigint; - /** - * The byte size of the block. - */ - size: number; - /** - * Array of transactions included in the block. - */ - transactions: T[]; - /** - * Uncles are stale blocks included in the main chain to provide a reward for partially mined blocks. - */ - uncles: string[]; -} - -/** - * Convert a BlockHeaderResponse object to its raw representation (RawBlockHeaderResponse). - * The function takes a BlockHeaderResponse containing Buffers and BigInts and converts - * them to appropriate hex strings, preserving the structure of the original object. - * - * @param block - The BlockHeaderResponse object to be converted to RawBlockHeaderResponse. - * @returns A RawBlockHeaderResponse object with hex-encoded values. - */ -export function toRawBlockHeaderResponse(block: BlockHeaderResponse): RawBlockHeaderResponse { - return { - hash: block.hash ? bufferToHex(block.hash) : null, - parentHash: bufferToHex(block.parentHash), - sha3Uncles: bufferToHex(block.sha3Uncles), - miner: block.miner.toString(), - stateRoot: bufferToHex(block.stateRoot), - transactionsRoot: bufferToHex(block.transactionsRoot), - receiptsRoot: bufferToHex(block.receiptsRoot), - logsBloom: block.logsBloom ? bufferToHex(block.logsBloom) : null, - difficulty: bigIntToHex(block.difficulty), - number: block.number !== null ? numberToHex(block.number)! : null, - gasLimit: numberToHex(block.gasLimit)!, - gasUsed: numberToHex(block.gasUsed)!, - timestamp: numberToHex(block.timestamp)!, - extraData: bufferToHex(block.extraData), - nonce: block.nonce !== null ? bufferToHex(block.nonce) : null, - baseFeePerGas: block.baseFeePerGas !== null ? bigIntToHex(block.baseFeePerGas) : null, - }; -} - -/** - * Converts a BlockResponse object into its corresponding RawBlockResponse representation. - * The function maps the properties in the input BlockResponse object to their respective hex-encoded string (where applicable) or appropriate raw format. - * It handles the conversion of transaction objects as well, invoking 'toRawTransactionResponse' for each entry. - * - * @param block - The BlockResponse object to be converted into a RawBlockResponse. - * @returns A RawBlockResponse object with the same data as the input BlockResponse, but in raw form. - */ -export function toRawBlockResponse(block: BlockResponse): RawBlockResponse { - return { - ...toRawBlockHeaderResponse(block), - totalDifficulty: bigIntToHex(block.totalDifficulty), - size: numberToHex(block.size)!, - transactions: block.transactions.map(tx => (Buffer.isBuffer(tx) ? bufferToHex(tx) : toRawTransactionResponse(tx))), - uncles: block.uncles, - }; -} - -/** - * Convert a raw block header response object to a formatted block header response object. - * The function takes a raw block header response object with hex-encoded values and converts - * them into appropriate data types such as Buffer, BigInt, or Number. It also converts the miner address - * from a string to an EthAddress instance. - * - * @param block - The raw block header response object with hex-encoded values. - * @returns A formatted block header response object with appropriate data types. - */ -export function fromRawBlockHeaderResponse(block: RawBlockHeaderResponse): BlockHeaderResponse { - return { - hash: block.hash ? hexToBuffer(block.hash) : null, - parentHash: hexToBuffer(block.parentHash), - sha3Uncles: hexToBuffer(block.sha3Uncles), - miner: EthAddress.fromString(block.miner), - stateRoot: hexToBuffer(block.stateRoot), - transactionsRoot: hexToBuffer(block.transactionsRoot), - receiptsRoot: hexToBuffer(block.receiptsRoot), - logsBloom: block.logsBloom ? hexToBuffer(block.logsBloom) : null, - difficulty: hexToBigInt(block.difficulty), - number: block.number ? hexToNumber(block.number) : null, - gasLimit: hexToNumber(block.gasLimit), - gasUsed: hexToNumber(block.gasUsed), - timestamp: hexToNumber(block.timestamp), - extraData: hexToBuffer(block.extraData), - nonce: block.nonce ? hexToBuffer(block.nonce) : null, - baseFeePerGas: block.baseFeePerGas ? hexToBigInt(block.baseFeePerGas) : null, - }; -} - -/** - * Converts a RawBlockResponse object into a BlockResponse object by parsing hex-encoded strings to their corresponding types. - * This function is useful for converting raw block responses received from external sources into a more manageable format - * with proper data types like Buffer, EthAddress, and bigint. - * - * @param block - The RawBlockResponse object containing hex-encoded strings and other raw values. - * @returns A BlockResponse object with parsed values and proper data types. - */ -export function fromRawBlockResponse(block: RawBlockResponse): BlockResponse { - return { - ...fromRawBlockHeaderResponse(block), - totalDifficulty: hexToBigInt(block.totalDifficulty), - size: hexToNumber(block.size), - transactions: block.transactions.map(tx => - typeof tx === 'string' ? hexToBuffer(tx) : fromRawTransactionResponse(tx), - ), - uncles: block.uncles, - }; -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/call_request.ts b/yarn-project/ethereum.js/src/eth_rpc/types/call_request.ts deleted file mode 100644 index a2700350854..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/call_request.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { - bigIntToHex, - bufferToHex, - hexToBigInt, - hexToBuffer, - hexToNumber, - numberToHex, -} from '../../hex_string/index.js'; - -/** - * Represents a call request object for Ethereum transactions. - * Contains optional parameters such as 'from', 'to', 'gas', 'maxFeePerGas', 'maxPriorityFeePerGas', 'value', and 'data'. - * Used to define the structure of the transaction details when making a function call or sending Ether between addresses. - */ -export interface CallRequest { - /** - * The sender's Ethereum address. - */ - from?: EthAddress; - /** - * The destination Ethereum address for the call request. - */ - to?: EthAddress; - /** - * The maximum amount of gas units to be used for the transaction execution. - */ - gas?: number; - /** - * Maximum fee per gas unit for transaction processing. - */ - maxFeePerGas?: bigint; - /** - * Maximum fee per gas for transaction priority. - */ - maxPriorityFeePerGas?: bigint; - /** - * The amount of Ether (in wei) to be transferred with the call. - */ - value?: bigint; - /** - * The input data to be executed by the called contract. - */ - data?: Buffer; -} - -/** - * Represents a raw Ethereum call request object with fields in hexadecimal string format. - * This interface is used to convert and interact with the CallRequest object, which uses - * more specific data types like bigint and Buffer for better type safety and readability. - */ -export interface RawCallRequest { - /** - * The Ethereum address initiating the call. - */ - from?: string; - /** - * The destination Ethereum address for the call request. - */ - to?: string; - /** - * The maximum amount of gas allowed for executing the transaction. - */ - gas?: string; - /** - * Maximum fee per gas unit for transaction processing. - */ - maxFeePerGas?: string; - /** - * The maximum fee per gas unit prioritized for transaction inclusion. - */ - maxPriorityFeePerGas?: string; - /** - * The amount of Ether to be transferred in the transaction, represented as a bigint. - */ - value?: string; - /** - * The encoded function call data for the contract method. - */ - data?: string; -} - -/** - * Convert a CallRequest object to its RawCallRequest representation. - * This function takes a CallRequest object with typed properties (EthAddress, bigint, Buffer) - * and returns a RawCallRequest object with the corresponding hex string representations. - * - * @param tx - The CallRequest object containing Ethereum transaction data in typed format. - * @returns A RawCallRequest object with the same transaction data in hex string format. - */ -export function toRawCallRequest(tx: CallRequest): RawCallRequest { - const { from, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, data } = tx; - return { - from: from ? from.toString().toLowerCase() : undefined, - to: to ? to.toString().toLowerCase() : undefined, - data: data ? bufferToHex(data) : undefined, - value: value ? bigIntToHex(value) : undefined, - gas: gas ? numberToHex(gas) : undefined, - maxFeePerGas: maxFeePerGas ? bigIntToHex(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas ? bigIntToHex(maxPriorityFeePerGas) : undefined, - }; -} - -/** - * Convert a RawCallRequest object into a CallRequest object by parsing and converting - * its properties from hex-encoded strings to their respective data types. - * This function handles 'from', 'to', 'gas', 'maxFeePerGas', 'maxPriorityFeePerGas', - * 'value', and 'data' properties. It also creates EthAddress instances for 'from' and 'to'. - * If any property is not present in the input, it will remain undefined in the output. - * - * @param tx - The RawCallRequest object with hex-encoded string properties. - * @returns A CallRequest object with parsed and converted properties. - */ -export function fromRawCallRequest(tx: RawCallRequest): CallRequest { - const { from, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, data } = tx; - return { - from: from ? EthAddress.fromString(from) : undefined, - to: to ? EthAddress.fromString(to) : undefined, - data: data ? hexToBuffer(data) : undefined, - value: value ? hexToBigInt(value) : undefined, - gas: gas ? hexToNumber(gas) : undefined, - maxFeePerGas: maxFeePerGas ? hexToBigInt(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas ? hexToBigInt(maxPriorityFeePerGas) : undefined, - }; -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/estimate_gas_request.ts b/yarn-project/ethereum.js/src/eth_rpc/types/estimate_gas_request.ts deleted file mode 100644 index 014066b266b..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/estimate_gas_request.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { - bigIntToHex, - bufferToHex, - hexToBigInt, - hexToBuffer, - hexToNumber, - numberToHex, -} from '../../hex_string/index.js'; - -/** - * Represents an Ethereum transaction estimate request. - * Contains information about the sender, receiver, gas limit, and other transaction-related details - * necessary for estimating the gas cost of a transaction on the Ethereum network. - */ -export interface EstimateRequest { - /** - * The Ethereum address of the transaction sender. - */ - from?: EthAddress; - /** - * The destination Ethereum address for the transaction. - */ - to?: EthAddress; - /** - * The maximum amount of gas units allowed for the transaction execution. - */ - gas?: number; - /** - * The maximum fee per gas unit for the transaction. - */ - maxFeePerGas?: bigint; - /** - * The maximum fee per gas unit for transaction prioritization. - */ - maxPriorityFeePerGas?: bigint; - /** - * The amount of Ether to be sent in the transaction, represented as a bigint. - */ - value?: bigint; - /** - * The byte array of the transaction's input data. - */ - data?: Buffer; -} - -/** - * Represents a raw estimate request object for Ethereum transactions. - * Contains essential transaction parameters in hexadecimal string format. - * This format is commonly used when interacting with Ethereum nodes or web3.js library. - */ -export interface RawEstimateRequest { - /** - * The Ethereum address initiating the transaction. - */ - from?: string; - /** - * The destination Ethereum address for the transaction. - */ - to?: string; - /** - * The maximum amount of gas units to be used for the transaction. - */ - gas?: string; - /** - * Maximum fee per gas unit for the transaction. - */ - maxFeePerGas?: string; - /** - * The maximum fee per gas unit to prioritize transaction processing. - */ - maxPriorityFeePerGas?: string; - /** - * The amount of Ether to be transferred in the transaction, represented as a BigInt. - */ - value?: string; - /** - * The transaction's input data as a Buffer. - */ - data?: string; -} - -/** - * Converts an EstimateRequest object into a RawEstimateRequest object by transforming its properties. - * This function is useful for preparing an EstimateRequest to be sent over RPC or other serialization protocols. - * It converts EthAddress instances to strings, BigInt values to hex-encoded strings, and Buffers to hex-encoded strings. - * - * @param tx - The EstimateRequest object containing transaction properties. - * @returns A RawEstimateRequest object with transformed properties. - */ -export function toRawEstimateRequest(tx: EstimateRequest): RawEstimateRequest { - const { from, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, data } = tx; - return { - from: from ? from.toString().toLowerCase() : undefined, - to: to ? to.toString().toLowerCase() : undefined, - data: data ? bufferToHex(data) : undefined, - value: value ? bigIntToHex(value) : undefined, - gas: gas ? numberToHex(gas) : undefined, - maxFeePerGas: maxFeePerGas ? bigIntToHex(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas ? bigIntToHex(maxPriorityFeePerGas) : undefined, - }; -} - -/** - * Converts a RawEstimateRequest object with hex-encoded strings to an EstimateRequest object - * with appropriate data types, such as BigInt and Buffer. This is useful when working with - * Ethereum transaction estimates received from external sources in a raw format. - * - * @param tx - The RawEstimateRequest object with hex-encoded string values. - * @returns An EstimateRequest object with appropriate data types. - */ -export function fromRawEstimateRequest(tx: RawEstimateRequest): EstimateRequest { - const { from, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, data } = tx; - return { - from: from ? EthAddress.fromString(from) : undefined, - to: to ? EthAddress.fromString(to) : undefined, - data: data ? hexToBuffer(data) : undefined, - value: value ? hexToBigInt(value) : undefined, - gas: gas ? hexToNumber(gas) : undefined, - maxFeePerGas: maxFeePerGas ? hexToBigInt(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas ? hexToBigInt(maxPriorityFeePerGas) : undefined, - }; -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/index.ts b/yarn-project/ethereum.js/src/eth_rpc/types/index.ts deleted file mode 100644 index 2a4927b9ba8..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './block_response.js'; -export * from './call_request.js'; -export * from './estimate_gas_request.js'; -export * from './number_or_tag.js'; -export * from './log_request.js'; -export * from './log_response.js'; -export * from './transaction_receipt.js'; -export * from './transaction_request.js'; -export * from './transaction_response.js'; diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/log_request.ts b/yarn-project/ethereum.js/src/eth_rpc/types/log_request.ts deleted file mode 100644 index 05668fac605..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/log_request.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { bufferToHex } from '../../hex_string/index.js'; -import { NumberOrTag, numberOrTagToHex } from './number_or_tag.js'; - -/** - * Represents a log request configuration for Ethereum events. - * Contains optional filter criteria, block range, contract addresses, and topics to refine the log search. - */ -export interface LogRequest { - /** - * Filter object for specifying event fields to be matched in logs. - */ - filter?: Partial; - /** - * The block number or block tag to end the log search. - */ - toBlock?: NumberOrTag; - /** - * The starting block number or identifier to fetch logs from. - */ - fromBlock?: NumberOrTag; - /** - * Ethereum address or array of addresses to filter logs by. - */ - address?: EthAddress | EthAddress[]; - /** - * An array of topic filters for log events, allowing the selection of specific events or a combination thereof. - */ - topics?: (Buffer | Buffer[] | null)[]; -} - -/** - * Represents a raw log request object for querying logs from Ethereum nodes. - * Contains optional parameters to filter and format the logs based on block range, address, and topics. - */ -export interface RawLogRequest { - /** - * The block number or tag until which logs should be fetched, inclusive. - */ - toBlock?: string; - /** - * The starting block for the log search, inclusive. - */ - fromBlock?: string; - /** - * Ethereum address or an array of addresses, used as a filter for the logs. - */ - address?: string | string[]; - /** - * An array of topics used for filtering specific event logs. - */ - topics?: ((string | null) | (string | null)[])[]; -} - -/** - * Converts a LogRequest object into a RawLogRequest object with hex string values. - * This function is useful for preparing log requests to be sent to Ethereum nodes. - * - * @param logRequest - A LogRequest object containing the filter, block range, address, and topics for events. - * @returns A RawLogRequest object with converted hex string values for block numbers and topics. - */ -export function toRawLogRequest(logRequest: LogRequest = {}): RawLogRequest { - const rawLogRequest: RawLogRequest = {}; - - if (logRequest.fromBlock !== undefined) { - rawLogRequest.fromBlock = numberOrTagToHex(logRequest.fromBlock); - } - - if (logRequest.toBlock !== undefined) { - rawLogRequest.toBlock = numberOrTagToHex(logRequest.toBlock); - } - - // Convert topics to hex. - rawLogRequest.topics = (logRequest.topics || []).map(topic => { - const toTopic = (value: Buffer | null) => { - if (!value) { - return null; - } - return bufferToHex(value); - }; - return Array.isArray(topic) ? topic.map(toTopic) : toTopic(topic); - }); - - if (logRequest.address) { - rawLogRequest.address = Array.isArray(logRequest.address) - ? logRequest.address.map(a => a.toString().toLowerCase()) - : logRequest.address.toString().toLowerCase(); - } - - return rawLogRequest; -} - -// export function fromRawLogRequest(rawLogRequest: RawLogRequest): LogRequest { -// const { toBlock, fromBlock, address, topics } = rawLogRequest; -// return { -// toBlock: toBlock ? hexToNumber(toBlock) : undefined, -// fromBlock: fromBlock ? hexToNumber(fromBlock) : undefined, -// address: address -// ? Array.isArray(address) -// ? address.map(EthAddress.fromString) -// : EthAddress.fromString(address) -// : undefined, -// topics: topics -// ? topics.map(topicOrArr => (Array.isArray(topicOrArr) ? topicOrArr.map(t => hexToBuffer(t) : null) : hexToBuffer(topicOrArr!))) -// : undefined, -// }; -// } diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/log_response.test.ts b/yarn-project/ethereum.js/src/eth_rpc/types/log_response.test.ts deleted file mode 100644 index a31e33217b3..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/log_response.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { TxHash } from '../tx_hash.js'; -import { fromRawLogResponse } from './log_response.js'; - -describe('formatters', () => { - describe('outputLogFormatter', () => { - it('should return the correct value', () => { - expect( - fromRawLogResponse({ - transactionIndex: '0x3e8', - logIndex: '0x3e8', - blockNumber: '0x3e8', - transactionHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - blockHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - data: '0x7b2274657374223a2274657374227', - address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - topics: ['0x68656c6c6f', '0x6d79746f70696373'], - }), - ).toEqual({ - transactionIndex: 1000, - logIndex: 1000, - blockNumber: 1000, - transactionHash: TxHash.fromString('0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'), - blockHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f', '0x6d79746f70696373'], - address: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - id: 'log_2b801386', - }); - }); - - it('should return the correct value, when null values are present', () => { - expect( - fromRawLogResponse({ - transactionIndex: null, - logIndex: null, - blockNumber: null, - transactionHash: null, - blockHash: null, - data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f', '0x6d79746f70696373'], - address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - }), - ).toEqual({ - transactionIndex: null, - logIndex: null, - blockNumber: null, - transactionHash: null, - blockHash: null, - id: null, - data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f', '0x6d79746f70696373'], - address: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - }); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/log_response.ts b/yarn-project/ethereum.js/src/eth_rpc/types/log_response.ts deleted file mode 100644 index b1a47e46751..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/log_response.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { keccak256String } from '../../crypto/index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { numberToHex } from '../../hex_string/index.js'; -import { TxHash } from '../tx_hash.js'; - -/** - * Represents the raw log response data structure from an Ethereum node. - * Contains information about events emitted during the execution of a smart contract transaction. - */ -export interface RawLogResponse { - /** - * Unique identifier for a log event. - */ - id?: string; - /** - * Indicates if the log entry has been removed due to a chain reorganization. - */ - removed?: boolean; - /** - * The index of the log entry within its corresponding block. - */ - logIndex: string | null; - /** - * The block number where the log was generated. - */ - blockNumber: string | null; - /** - * The unique identifier (hash) of the block containing the log event. - */ - blockHash: string | null; - /** - * The unique hash identifying a specific transaction. - */ - transactionHash: string | null; - /** - * The index position of the transaction within a block. - */ - transactionIndex: string | null; - /** - * The Ethereum address associated with the log event. - */ - address: string; - /** - * The hexadecimal encoded data associated with the log event. - */ - data: string; - /** - * An array of indexed event parameters. - */ - topics: string[]; -} - -/** - * Represents a log response from the Ethereum network. - * Contains information about events emitted by smart contracts during transaction execution, - * such as event signatures, topics, and data associated with the event. - */ -export interface LogResponse { - /** - * Unique identifier for the log event. - */ - id: string | null; - /** - * Indicates whether the log entry has been removed due to a chain reorganization. - */ - removed?: boolean; - /** - * The index position of the log entry within the block. - */ - logIndex: number | null; - /** - * The block number in which the log was generated. - */ - blockNumber: number | null; - /** - * The unique hash identifier of the block containing the log entry. - */ - blockHash: string | null; - /** - * The unique identifier of the transaction in the blockchain. - */ - transactionHash: TxHash | null; - /** - * The index position of the transaction within the block. - */ - transactionIndex: number | null; - /** - * The Ethereum address associated with the log event. - */ - address: EthAddress; - /** - * The data field of a logged event in the Ethereum contract. - */ - data: string; - /** - * An array of indexed event arguments. - */ - topics: string[]; -} - -/** - * Converts a RawLogResponse object into a LogResponse object. - * The function generates a custom log id, if not provided, by concatenating the blockHash, transactionHash, and logIndex values after removing the '0x' prefix. - * It also converts string representations of blockNumber, transactionIndex, and logIndex to their corresponding numeric values. - * Additionally, it creates EthAddress and TxHash instances for address and transactionHash fields, respectively. - * - * @param log - The RawLogResponse object to be converted. - * @returns A LogResponse object with proper data types and structure. - */ -export function fromRawLogResponse(log: RawLogResponse): LogResponse { - let id: string | null = log.id || null; - - // Generate a custom log id. - if ( - typeof log.blockHash === 'string' && - typeof log.transactionHash === 'string' && - typeof log.logIndex === 'string' - ) { - const shaId = keccak256String( - log.blockHash.replace('0x', '') + log.transactionHash.replace('0x', '') + log.logIndex.replace('0x', ''), - ); - id = 'log_' + shaId.replace('0x', '').substring(0, 8); - } - - const blockNumber = log.blockNumber !== null ? Number(log.blockNumber) : null; - const transactionIndex = log.transactionIndex !== null ? Number(log.transactionIndex) : null; - const logIndex = log.logIndex !== null ? Number(log.logIndex) : null; - const address = EthAddress.fromString(log.address); - const transactionHash = log.transactionHash !== null ? TxHash.fromString(log.transactionHash) : null; - - return { ...log, id, blockNumber, transactionIndex, transactionHash, logIndex, address }; -} - -/** - * Converts a LogResponse object to its corresponding RawLogResponse format. - * This function is used to revert the processed LogResponse back to its raw format, - * primarily for compatibility with Ethereum JSON-RPC API or other libraries that - * expect raw log data. The output will have all number properties converted to hex-strings - * and addresses in lowercase representation where applicable. - * - * @param log - The LogResponse object to be converted to RawLogResponse format. - * @returns A RawLogResponse object containing original raw log data. - */ -export function toRawLogResponse(log: LogResponse): RawLogResponse { - const { id, blockNumber, transactionIndex, logIndex, address, transactionHash } = log; - return { - ...log, - id: id ? id : undefined, - blockNumber: blockNumber !== null ? numberToHex(blockNumber) : null, - transactionIndex: transactionIndex !== null ? numberToHex(transactionIndex) : null, - logIndex: logIndex !== null ? numberToHex(logIndex) : null, - address: address.toString().toLowerCase(), - transactionHash: transactionHash !== null ? transactionHash.toString() : null, - }; -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/number_or_tag.ts b/yarn-project/ethereum.js/src/eth_rpc/types/number_or_tag.ts deleted file mode 100644 index 366bf37edb1..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/number_or_tag.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { numberToHex } from '../../hex_string/index.js'; - -/** - * Type representing Ethereum block numbers or tags, used to specify a particular block when querying blockchain data. - */ -export type NumberOrTag = number | 'latest' | 'earliest' | 'pending'; - -export const numberOrTagToHex = (numberOrTag: NumberOrTag) => - typeof numberOrTag === 'number' ? numberToHex(numberOrTag) : numberOrTag; diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_receipt.ts b/yarn-project/ethereum.js/src/eth_rpc/types/transaction_receipt.ts deleted file mode 100644 index 4ce95c82435..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_receipt.ts +++ /dev/null @@ -1,162 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { fromRawLogResponse, LogResponse, RawLogResponse, toRawLogResponse } from './log_response.js'; -import { numberToHex } from '../../hex_string/index.js'; -import { TxHash } from '../tx_hash.js'; - -/** - * Represents a raw Ethereum transaction receipt object. - * Contains essential information about the transaction, including its hash, index, block number, and gas usage. - * Also includes details about the sender, recipient, contract address, logs, and the transaction's status. - */ -export interface RawTransactionReceipt { - /** - * The unique identifier of the transaction. - */ - transactionHash: string; - /** - * The index of the transaction within the block. - */ - transactionIndex: string; - /** - * The hash identifier of the block containing the transaction. - */ - blockHash: string; - /** - * The block number in which the transaction was included. - */ - blockNumber: string; - /** - * The Ethereum address of the transaction sender. - */ - from: string; - /** - * The destination Ethereum address involved in the transaction. - */ - to: string | null; - /** - * The total amount of gas used by all transactions in the block up to and including this transaction. - */ - cumulativeGasUsed: string; - /** - * The amount of gas consumed by the transaction. - */ - gasUsed: string; - /** - * Address of the deployed contract, if applicable. - */ - contractAddress: string | null; - /** - * An array of event logs emitted by the smart contract during the transaction execution. - */ - logs: RawLogResponse[]; - /** - * The transaction success status, where 'true' indicates success and 'false' indicates failure. - */ - status: string; -} - -/** - * Represents a transaction receipt on the Ethereum blockchain. - * Contains detailed information about a processed transaction, including its status, gas usage, and associated logs. - */ -export interface TransactionReceipt { - /** - * The unique hash identifier of the transaction. - */ - transactionHash: TxHash; - /** - * The index of the transaction within its containing block. - */ - transactionIndex: number; - /** - * The unique identifier of the block containing the transaction. - */ - blockHash: string; - /** - * The block number containing the transaction. - */ - blockNumber: number; - /** - * The Ethereum address of the transaction sender. - */ - from: EthAddress; - /** - * The destination Ethereum address involved in the transaction. - */ - to?: EthAddress; - /** - * The total amount of gas used by all transactions up to and including this one in the block. - */ - cumulativeGasUsed: number; - /** - * The amount of gas utilized during the transaction execution. - */ - gasUsed: number; - /** - * The Ethereum address of the deployed smart contract, if applicable. - */ - contractAddress?: EthAddress; - /** - * An array of log events emitted by the transaction. - */ - logs: LogResponse[]; - /** - * The transaction execution status; true if successful, false otherwise. - */ - status: boolean; -} - -/** - * Converts a RawTransactionReceipt object to a TransactionReceipt object. - * Transforms string representations of properties such as transaction index, block number, - * cumulative gas used, and gas used into their respective numeric types. Additionally, - * it converts the 'from', 'to', and 'contractAddress' properties to EthAddress instances, - * and the 'logs' property to LogResponse objects. The function also converts the 'status' - * property to a boolean value, indicating the success or failure of the transaction. - * - * @param receipt - The RawTransactionReceipt object to be converted. - * @returns A TransactionReceipt object with transformed properties or undefined if the input receipt is invalid or missing. - */ -export function fromRawTransactionReceipt(receipt?: RawTransactionReceipt): TransactionReceipt | undefined { - if (!receipt || !receipt.blockHash) { - return; - } - - return { - ...receipt, - to: receipt.to ? EthAddress.fromString(receipt.to) : undefined, - from: EthAddress.fromString(receipt.from), - blockNumber: Number(receipt.blockNumber), - transactionIndex: Number(receipt.transactionIndex), - transactionHash: TxHash.fromString(receipt.transactionHash), - cumulativeGasUsed: Number(receipt.cumulativeGasUsed), - gasUsed: Number(receipt.gasUsed), - logs: receipt.logs.map(fromRawLogResponse), - contractAddress: receipt.contractAddress ? EthAddress.fromString(receipt.contractAddress) : undefined, - status: Boolean(Number(receipt.status)), - }; -} - -/** - * Converts a TransactionReceipt object to its raw form, which is an object containing string representations of all properties. - * The function takes care of converting the properties such as EthAddress objects, numbers, and booleans to their corresponding - * string forms. Useful for serialization or converting the data back to a format that can be sent over the network or stored. - * - * @param receipt - The TransactionReceipt object to be converted to its raw form. - * @returns A RawTransactionReceipt object containing string representations of all properties from the input TransactionReceipt. - */ -export function toRawTransactionReceipt(receipt: TransactionReceipt): RawTransactionReceipt { - return { - ...receipt, - to: receipt.to ? receipt.to.toString() : null, - from: receipt.from.toString(), - blockNumber: numberToHex(receipt.blockNumber), - transactionIndex: numberToHex(receipt.transactionIndex), - transactionHash: receipt.transactionHash.toString(), - cumulativeGasUsed: numberToHex(receipt.cumulativeGasUsed), - gasUsed: numberToHex(receipt.gasUsed)!, - logs: receipt.logs.map(toRawLogResponse), - contractAddress: receipt.contractAddress ? receipt.contractAddress.toString() : null, - status: numberToHex(receipt.status ? 1 : 0), - }; -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_request.test.ts b/yarn-project/ethereum.js/src/eth_rpc/types/transaction_request.test.ts deleted file mode 100644 index a007f72067a..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_request.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { toRawTransactionRequest } from './transaction_request.js'; - -const tests = [ - { - input: { - data: Buffer.from('34234bf23bf423', 'hex'), - value: 100n, - from: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - to: EthAddress.fromString('0x00c5496aee77c1ba1f0854206a26dda82a81d6d8'), - nonce: 1000, - gas: 1000, - maxFeePerGas: 1000n, - maxPriorityFeePerGas: 1001n, - }, - result: { - data: '0x34234bf23bf423', - value: '0x64', - from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - to: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', - nonce: '0x3e8', - gas: '0x3e8', - maxFeePerGas: '0x3e8', - maxPriorityFeePerGas: '0x3e9', - }, - }, - { - input: { - data: Buffer.from('34234bf23bf423', 'hex'), - value: 100n, - from: EthAddress.fromString('00c5496aee77c1ba1f0854206a26dda82a81d6d8'), - to: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - }, - result: { - data: '0x34234bf23bf423', - value: '0x64', - from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', - to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - }, - }, - { - input: { - data: Buffer.from('34234bf23bf423', 'hex'), - value: 100n, - from: EthAddress.fromString('00c5496aee77c1ba1f0854206a26dda82a81d6d8'), - to: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - gas: 1000, - }, - result: { - data: '0x34234bf23bf423', - value: '0x64', - from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', - to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - gas: '0x3e8', - }, - }, -]; - -describe('formatters', () => { - describe('toRawTransactionRequest', () => { - tests.forEach(test => { - it('should return the correct value', () => { - expect(toRawTransactionRequest(test.input)).toEqual(test.result); - }); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_request.ts b/yarn-project/ethereum.js/src/eth_rpc/types/transaction_request.ts deleted file mode 100644 index a71aca96946..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_request.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { - bigIntToHex, - bufferToHex, - hexToBigInt, - hexToBuffer, - hexToNumber, - numberToHex, -} from '../../hex_string/index.js'; - -/** - * Represents an Ethereum transaction request. - * Provides a structured format for specifying the required parameters when sending a new transaction on the Ethereum network. - */ -export interface TransactionRequest { - /** - * The Ethereum address initiating the transaction. - */ - from: EthAddress; - /** - * The destination Ethereum address for the transaction. - */ - to?: EthAddress; - /** - * The maximum amount of gas units allowed for the transaction execution. - */ - gas?: number; - /** - * The maximum fee per gas unit for the transaction. - */ - maxFeePerGas?: bigint; - /** - * The maximum fee per gas unit that the sender is willing to pay for transaction priority. - */ - maxPriorityFeePerGas?: bigint; - /** - * The amount of Ether to be transferred in the transaction. - */ - value?: bigint; - /** - * The encoded contract function call data. - */ - data?: Buffer; - /** - * A unique number that prevents double-spending in transactions. - */ - nonce?: number; -} - -/** - * Type representing a raw Ethereum transaction request, where all properties are encoded as hexadecimal strings. - * Useful for serialization and deserialization of transaction data to and from external systems or storage. - */ -export type RawTransactionRequest = { [k in keyof TransactionRequest]: string }; - -/** - * Converts a TransactionRequest object into a RawTransactionRequest object by converting all properties to string format. - * The function ensures that the 'from' and 'to' addresses are in lowercase, and bigint, number, and Buffer values are converted to hexadecimal strings. - * If a property is not present in the input TransactionRequest object, it will be set to 'undefined' in the output RawTransactionRequest object. - * - * @param tx - The TransactionRequest object to be converted. - * @returns A RawTransactionRequest object with all properties in string format. - */ -export function toRawTransactionRequest(tx: TransactionRequest): RawTransactionRequest { - const { from, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, nonce, data } = tx; - return { - from: from.toString().toLowerCase(), - to: to ? to.toString().toLowerCase() : undefined, - gas: gas ? numberToHex(gas) : undefined, - value: value ? bigIntToHex(value) : undefined, - data: data ? bufferToHex(data) : undefined, - nonce: nonce ? numberToHex(nonce) : undefined, - maxFeePerGas: maxFeePerGas ? bigIntToHex(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas ? bigIntToHex(maxPriorityFeePerGas) : undefined, - }; -} - -/** - * Convert a raw transaction request object with its properties as hex-encoded strings into a TransactionRequest object - * with the corresponding native JavaScript types. This function is useful for decoding raw transaction requests received - * from external sources, such as APIs or user inputs, and converting them into a format suitable for further processing. - * - * @param tx - The raw transaction request object with its properties as hex-encoded strings. - * @returns A TransactionRequest object with the corresponding native JavaScript types. - */ -export function fromRawTransactionRequest(tx: RawTransactionRequest): TransactionRequest { - const { from, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, nonce, data } = tx; - return { - from: EthAddress.fromString(from), - to: to ? EthAddress.fromString(to) : undefined, - gas: gas ? hexToNumber(gas) : undefined, - value: value ? hexToBigInt(value) : undefined, - data: data ? hexToBuffer(data) : undefined, - nonce: nonce ? hexToNumber(nonce) : undefined, - maxFeePerGas: maxFeePerGas ? hexToBigInt(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas ? hexToBigInt(maxPriorityFeePerGas) : undefined, - }; -} diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_response.test.ts b/yarn-project/ethereum.js/src/eth_rpc/types/transaction_response.test.ts deleted file mode 100644 index 33542f5395f..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_response.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { hexToBuffer } from '../../hex_string/index.js'; -import { fromRawTransactionResponse } from './transaction_response.js'; - -describe('formatters', () => { - describe('transactionResponseFormatter', () => { - it('should return the correct value', () => { - expect( - fromRawTransactionResponse({ - input: '0x3454645634534', - from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', - to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - value: '0x3e8', - gas: '0x3e8', - gasPrice: '0x3e8', - nonce: '0xb', - transactionIndex: '0x1', - blockNumber: '0x3e8', - blockHash: '0xc9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', - hash: '0xd9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', - type: '0x0', - v: 'v', - r: 'r', - s: 's', - }), - ).toEqual({ - input: hexToBuffer('0x3454645634534'), - from: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - to: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - value: 1000n, - gas: 1000, - gasPrice: 1000n, - nonce: 11, - blockNumber: 1000, - blockHash: '0xc9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', - transactionIndex: 1, - hash: '0xd9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', - type: 0, - v: 'v', - r: 'r', - s: 's', - }); - }); - - it('should return the correct value, when null values are present', () => { - expect( - fromRawTransactionResponse({ - input: '0x3454645634534', - from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', - to: null, - value: '0x3e8', - gas: '0x3e8', - gasPrice: '0x3e8', - nonce: '0xb', - transactionIndex: null, - blockNumber: null, - blockHash: null, - hash: '0xd9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', - type: '0x0', - v: 'v', - r: 'r', - s: 's', - }), - ).toEqual({ - input: hexToBuffer('0x3454645634534'), - from: EthAddress.fromString('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'), - to: null, - value: 1000n, - gas: 1000, - gasPrice: 1000n, - nonce: 11, - blockNumber: null, - blockHash: null, - transactionIndex: null, - hash: '0xd9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', - type: 0, - v: 'v', - r: 'r', - s: 's', - }); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_response.ts b/yarn-project/ethereum.js/src/eth_rpc/types/transaction_response.ts deleted file mode 100644 index 6506ef189c5..00000000000 --- a/yarn-project/ethereum.js/src/eth_rpc/types/transaction_response.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { - bigIntToHex, - bufferToHex, - hexToBigInt, - hexToBuffer, - hexToNumber, - numberToHex, -} from '../../hex_string/index.js'; - -/** - * Represents a raw Ethereum transaction response. - * Contains unprocessed data fields in hexadecimal string format, typically received from an Ethereum node API. - */ -export interface RawTransactionResponse { - /** - * The hash of the block containing the transaction. - */ - blockHash: string | null; - /** - * The block number in which the transaction is included. - */ - blockNumber: string | null; - /** - * The originating Ethereum address of the transaction. - */ - from: string; - /** - * The amount of gas required for the transaction execution. - */ - gas: string; - /** - * The price per unit of gas in the transaction. - */ - gasPrice: string; - /** - * Maximum fee per gas unit for a transaction. - */ - maxFeePerGas?: string; - /** - * The maximum fee per gas unit for transaction prioritization. - */ - maxPriorityFeePerGas?: string; - /** - * The unique identifier of the transaction. - */ - hash: string; - /** - * Raw input data of the transaction. - */ - input: string; - /** - * A unique transaction counter for the sender. - */ - nonce: string; - /** - * The destination Ethereum address involved in the transaction. - */ - to: string | null; - /** - * The index of the transaction within its containing block. - */ - transactionIndex: string | null; - /** - * The Ethereum transaction type identifier. - */ - type: string; - /** - * The amount of Ether transferred in the transaction. - */ - value: string; - /** - * The recovery identifier of the transaction signature. - */ - v: string; - /** - * The 'r' value of the transaction's ECDSA signature. - */ - r: string; - /** - * Signature component for transaction verification. - */ - s: string; -} - -/** - * Represents an Ethereum transaction response with decoded data types. - * Provides a structured interface for working with transaction responses returned from the Ethereum network. - */ -export interface TransactionResponse { - /** - * The hash of the block containing the transaction. - */ - blockHash: string | null; - /** - * The block number containing the transaction, or null if not yet mined. - */ - blockNumber: number | null; - /** - * The originating Ethereum address of the transaction. - */ - from: EthAddress; - /** - * Amount of gas units required for executing the transaction. - */ - gas: number; - /** - * The amount of Ether paid per unit of gas for the transaction. - */ - gasPrice: bigint; - /** - * The maximum fee per gas unit for the transaction. - */ - maxFeePerGas?: bigint; - /** - * The maximum fee per gas a user is willing to pay for transaction priority. - */ - maxPriorityFeePerGas?: bigint; - /** - * The unique identifier of the transaction. - */ - hash: string; - /** - * Raw binary data representing smart contract method calls and parameters. - */ - input: Buffer; - /** - * An integer value representing the number of transactions sent by the sender. - */ - nonce: number; - /** - * The destination Ethereum address for the transaction. - */ - to: EthAddress | null; - /** - * The position of the transaction within the block. - */ - transactionIndex: number | null; - /** - * Transaction type identifier. - */ - type: number; - /** - * The value transferred in the transaction, represented as a bigint. - */ - value: bigint; - /** - * The recovery identifier of the ECDSA signature. - */ - v: string; - /** - * The 'r' value of the ECDSA signature. - */ - r: string; - /** - * Signature recovery value for ECDSA. - */ - s: string; -} - -/** - * Converts a raw transaction response object into a more structured and typed TransactionResponse object. - * This function decodes hex-encoded strings, converts number values to their respective types (BigInt or Number), - * and represents Ethereum addresses as EthAddress instances. It can handle both EIP-1559 and legacy transactions. - * - * @param tx - The raw transaction response object, typically retrieved from an Ethereum node API. - * @returns A structured and typed TransactionResponse object with decoded values for easier handling and manipulation. - */ -export function fromRawTransactionResponse(tx: RawTransactionResponse): TransactionResponse { - return { - ...tx, - blockNumber: tx.blockNumber ? hexToNumber(tx.blockNumber) : null, - transactionIndex: tx.transactionIndex ? hexToNumber(tx.transactionIndex) : null, - nonce: hexToNumber(tx.nonce), - gas: hexToNumber(tx.gas), - gasPrice: hexToBigInt(tx.gasPrice), - maxFeePerGas: tx.maxFeePerGas ? hexToBigInt(tx.gasPrice) : undefined, - maxPriorityFeePerGas: tx.maxPriorityFeePerGas ? hexToBigInt(tx.gasPrice) : undefined, - value: hexToBigInt(tx.value), - type: hexToNumber(tx.type), - to: tx.to ? EthAddress.fromString(tx.to) : null, - from: EthAddress.fromString(tx.from), - input: hexToBuffer(tx.input), - }; -} - -/** - * Converts a TransactionResponse object into a RawTransactionResponse object by transforming its field values to their raw string or number format. - * This function is useful when dealing with APIs or systems that expect transaction data in raw string or number format. - * - * @param tx - The TransactionResponse object containing the transaction data in bigint, Buffer, or EthAddress format. - * @returns A RawTransactionResponse object containing the transaction data in raw string or number format. - */ -export function toRawTransactionResponse(tx: TransactionResponse): RawTransactionResponse { - return { - ...tx, - blockNumber: tx.blockNumber ? numberToHex(tx.blockNumber) : null, - transactionIndex: tx.transactionIndex ? numberToHex(tx.transactionIndex) : null, - nonce: numberToHex(tx.nonce)!, - gas: numberToHex(tx.gas)!, - gasPrice: bigIntToHex(tx.gasPrice), - maxFeePerGas: tx.maxFeePerGas ? bigIntToHex(tx.maxFeePerGas) : undefined, - maxPriorityFeePerGas: tx.maxPriorityFeePerGas ? bigIntToHex(tx.maxPriorityFeePerGas) : undefined, - value: bigIntToHex(tx.value), - type: numberToHex(tx.type), - to: tx.to ? tx.to.toString() : null, - from: tx.from.toString(), - input: bufferToHex(tx.input), - }; -} diff --git a/yarn-project/ethereum.js/src/eth_sign/hash_message.ts b/yarn-project/ethereum.js/src/eth_sign/hash_message.ts deleted file mode 100644 index 96316c5ea97..00000000000 --- a/yarn-project/ethereum.js/src/eth_sign/hash_message.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { keccak256 } from '../crypto/index.js'; - -/** - * Generate a keccak256 hash of the given Ethereum message following its signed message format. - * The function adds the Ethereum Signed Message preamble and message length before hashing the data. - * This helps ensure that the data being signed cannot be misinterpreted as a transaction or other data. - * - * @param data - A Buffer containing the data to be hashed. - * @returns A Buffer containing the keccak256 hashed Ethereum message. - */ -export function hashMessage(data: Buffer) { - const preamble = '\x19Ethereum Signed Message:\n' + data.length; - const preambleBuffer = Buffer.from(preamble); - const ethMessage = Buffer.concat([preambleBuffer, data]); - return keccak256(ethMessage); -} diff --git a/yarn-project/ethereum.js/src/eth_sign/index.ts b/yarn-project/ethereum.js/src/eth_sign/index.ts deleted file mode 100644 index 6fb9d4c01a8..00000000000 --- a/yarn-project/ethereum.js/src/eth_sign/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './sign.js'; -export * from './hash_message.js'; diff --git a/yarn-project/ethereum.js/src/eth_sign/sign.test.ts b/yarn-project/ethereum.js/src/eth_sign/sign.test.ts deleted file mode 100644 index 26af29ec018..00000000000 --- a/yarn-project/ethereum.js/src/eth_sign/sign.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { hashMessage } from './hash_message.js'; -import { recoverFromSigBuffer, recoverFromSignature, recoverFromVRS, sign } from './sign.js'; - -const tests = [ - { - address: EthAddress.fromString('0xEB014f8c8B418Db6b45774c326A0E64C78914dC0'), - privateKey: Buffer.from('be6383dad004f233317e46ddb46ad31b16064d14447a95cc1d8c8d4bc61c3728', 'hex'), - data: hashMessage(Buffer.from('Some data')), - signature: Buffer.from( - 'a8037a6116c176a25e6fc224947fde9e79a2deaa0dd8b67b366fbdfdbffc01f953e41351267b20d4a89ebfe9c8f03c04de9b345add4a52f15bd026b63c8fb1501b', - 'hex', - ), - }, - { - address: EthAddress.fromString('0xEB014f8c8B418Db6b45774c326A0E64C78914dC0'), - privateKey: Buffer.from('be6383dad004f233317e46ddb46ad31b16064d14447a95cc1d8c8d4bc61c3728', 'hex'), - data: hashMessage(Buffer.from('Some data!%$$%&@*')), - signature: Buffer.from( - '05252412b097c5d080c994d1ea12abcee6f1cae23feb225517a0b691a66e12866b3f54292f9cfef98f390670b4d010fc4af7fcd46e41d72870602c117b14921c1c', - 'hex', - ), - }, -]; - -describe('eth_account sign', () => { - tests.forEach(test => { - it('sign data', () => { - const data = sign(test.data, test.privateKey, 27); - expect(data.toBuffer()).toEqual(test.signature); - }); - - it('recover signature from signature buffer', () => { - const address1 = recoverFromSigBuffer(test.data, test.signature); - - expect(address1).toEqual(test.address); - }); - - it('recover signature using a hash and r s v values', () => { - const sig = sign(test.data, test.privateKey); - const address1 = recoverFromVRS(test.data, sig.v, sig.r, sig.s); - - expect(address1).toEqual(test.address); - }); - - it('recover signature using a signature object', () => { - const sig = sign(test.data, test.privateKey); - const address1 = recoverFromSignature(test.data, sig); - - expect(address1).toEqual(test.address); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_sign/sign.ts b/yarn-project/ethereum.js/src/eth_sign/sign.ts deleted file mode 100644 index 7b2445b1b3d..00000000000 --- a/yarn-project/ethereum.js/src/eth_sign/sign.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { numToUInt8 } from '../serialize/index.js'; -import { keccak256 } from '../crypto/index.js'; -import elliptic from 'elliptic'; -import { hexToBuffer } from '../hex_string/index.js'; - -const secp256k1 = new elliptic.ec('secp256k1'); - -/** - * The EthSignature class represents an Ethereum signature consisting of 'r', 's', and 'v' components. - * It provides methods to convert signatures between string, buffer, and object formats for easy manipulation - * and usage in signing and recovering operations. This class is particularly useful when working with - * Ethereum transactions that require signing and validation processes. - */ -export class EthSignature { - constructor( - /** - * The 'r' value of an ECDSA signature. - */ - public r: Buffer, - /** - * The 's' value of the ECDSA signature. - */ public s: Buffer, - /** - * The recovery parameter used in ECDSA signatures. - */ public v: number, - ) {} - - /** - * Create an EthSignature instance from a given buffer. - * The input 'buf' should be a Buffer containing the 'r', 's', and 'v' values of the signature. - * 'r' and 's' values are each 32 bytes long, while 'v' is a single byte. - * Throws an error if the input buffer length is not exactly 65 bytes. - * - * @param buf - The Buffer containing the 'r', 's', and 'v' values of the signature. - * @returns An EthSignature instance. - */ - static fromBuffer(buf: Buffer) { - return new EthSignature(buf.subarray(0, 32), buf.subarray(32, 64), buf[64]); - } - - /** - * Create an EthSignature instance from a hex-encoded string. - * The input 'hex' should be prefixed with '0x', followed by 128 hex characters (for r, s) and 2 hex characters for the `v` value. - * Throws an error if the input length is invalid or any of the r, s, v values are out of range. - * - * @param hex - The hex-encoded string representing the Ethereum signature. - * @returns An EthSignature instance. - */ - static fromString(hex: string) { - return EthSignature.fromBuffer(hexToBuffer(hex)); - } - - /** - * Converts the EthSignature instance to a Buffer representation. - * The resulting buffer contains the concatenated 'r', 's', and 'v' values of the signature. - * This function is useful when working with raw binary data or when storing the signature. - * - * @returns A Buffer containing the concatenated 'r', 's', and 'v' values of the EthSignature instance. - */ - toBuffer() { - return Buffer.concat([this.r, this.s, numToUInt8(this.v)]); - } - - /** - * Convert the EthSignature instance into a hex-encoded string. - * The resulting string is prefixed with '0x' and represents the concatenated r, s, and v values of the signature. - * - * @returns A hex-encoded string representing the EthSignature instance. - */ - toString() { - return '0x' + this.toBuffer().toString('hex'); - } -} - -/** - * Sign a message hash using the provided private key and add 27 to the recovery value. - * This function produces an Ethereum-compatible signature, which can be used for verifying - * the signer's address. It returns an EthSignature object containing the 'r', 's', and 'v' values. - * - * @param messageHash - The Buffer containing the hashed message to be signed. - * @param privateKey - The Buffer containing the private key used for signing the message hash. - * @returns An EthSignature instance with the signature components (r, s, v). - */ -export function signMessage(messageHash: Buffer, privateKey: Buffer) { - return sign(messageHash, privateKey, 27); -} - -/** - * Generate an Ethereum signature for a given message hash and private key. - * The 'sign' function takes a message hash (Buffer), a private key (Buffer), and an optional addToV parameter, - * and returns an EthSignature object containing the r, s, and v components of the signature. - * The 'addToV' parameter can be used to adjust the recovery ID of the signature (default is 0). - * - * @param messageHash - The message hash to be signed, as a Buffer. - * @param privateKey - The signer's private key, as a Buffer. - * @param addToV - Optional value to add to the recovery ID of the signature (default is 0). - * @returns An instance of EthSignature containing the r, s, and v components of the signed message. - */ -export function sign(messageHash: Buffer, privateKey: Buffer, addToV = 0): EthSignature { - const signature = secp256k1.keyFromPrivate(privateKey).sign(messageHash, { canonical: true }); - const v = signature.recoveryParam! + addToV; - const r = signature.r.toBuffer('be', 32); - const s = signature.s.toBuffer('be', 32); - return new EthSignature(r, s, v); -} - -/** - * Recover the Ethereum address from a signature and message hash. - * This function takes the message hash and an EthSignature object, which contains r, s, and v values, - * and returns the corresponding Ethereum address that signed the message. - * The recovered address is returned as an EthAddress instance. - * - * @param messageHash - The hash of the message that was signed. - * @param signature - An EthSignature object containing r, s, and v values. - * @returns An EthAddress instance representing the address that signed the message. - */ -export function recoverFromSignature(messageHash: Buffer, { v, r, s }: EthSignature) { - return recoverFromVRS(messageHash, v, r, s); -} - -/** - * Recover the Ethereum address from a message hash, using the provided signature parameters (v, r, s). - * The function uses elliptic curve cryptography (secp256k1) to recover the public key and then derives - * the Ethereum address by hashing the public key with keccak256. - * - * @param messageHash - The hashed message that was signed. - * @param v - The recovery identifier value, used to determine which of the two possible keys was used for signing. - * @param r - The 'r' component of the ECDSA signature. - * @param s - The 's' component of the ECDSA signature. - * @returns An EthAddress instance representing the recovered Ethereum address. - */ -export function recoverFromVRS(messageHash: Buffer, v: number, r: Buffer, s: Buffer) { - const ecPublicKey = secp256k1.recoverPubKey( - messageHash, - { - r, - s, - }, - v < 2 ? v : 1 - (v % 2), - ); - const publicKey = Buffer.from(ecPublicKey.encode('hex', false).slice(2), 'hex'); - const publicHash = keccak256(publicKey); - return new EthAddress(publicHash.subarray(-20)); -} - -/** - * Recover an Ethereum address from a given message hash and signature buffer. - * This function uses the EthSignature.fromBuffer() method to convert the signature buffer into an - * EthSignature instance, then calls the recoverFromSignature() function with the message hash and - * the EthSignature instance to recover the Ethereum address. - * - * @param messageHash - The Buffer containing the hash of the message that was signed. - * @param signature - The Buffer containing the signature generated from signing the message. - * @returns An EthAddress instance representing the recovered Ethereum address. - */ -export function recoverFromSigBuffer(messageHash: Buffer, signature: Buffer) { - return recoverFromSignature(messageHash, EthSignature.fromBuffer(signature)); -} diff --git a/yarn-project/ethereum.js/src/eth_transaction/eth_transaction.ts b/yarn-project/ethereum.js/src/eth_transaction/eth_transaction.ts deleted file mode 100644 index 87b304c143e..00000000000 --- a/yarn-project/ethereum.js/src/eth_transaction/eth_transaction.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; - -/** - * A protocol level, type 2, EIP-1559 transaction. - * This is what's rlp encoded, hashed, and signed over. - * It's distinct from ETH JSON RPC types, which are much less strict. - */ -export interface EthTransaction { - /** - * The unique identifier for the Ethereum network. - */ - chainId: number; - /** - * The destination Ethereum address for the transaction. - */ - to?: EthAddress; - /** - * The maximum amount of gas units allocated for the execution of the transaction. - */ - gas: number; - /** - * The maximum fee per gas unit for the transaction, expressed in Gwei. - */ - maxFeePerGas: bigint; - /** - * Maximum fee per gas unit to prioritize the transaction inclusion. - */ - maxPriorityFeePerGas: bigint; - /** - * The amount of Ether to be transferred in the transaction. - */ - value: bigint; - /** - * The input data for the transaction execution. - */ - data?: Buffer; - /** - * A unique value representing the number of transactions sent from a specific address. - */ - nonce: number; -} diff --git a/yarn-project/ethereum.js/src/eth_transaction/index.ts b/yarn-project/ethereum.js/src/eth_transaction/index.ts deleted file mode 100644 index 881c6cfdc7a..00000000000 --- a/yarn-project/ethereum.js/src/eth_transaction/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './eth_transaction.js'; -export * from './populate_transaction.js'; -export * from './sign_transaction.js'; diff --git a/yarn-project/ethereum.js/src/eth_transaction/populate_transaction.ts b/yarn-project/ethereum.js/src/eth_transaction/populate_transaction.ts deleted file mode 100644 index fe1ea0b4116..00000000000 --- a/yarn-project/ethereum.js/src/eth_transaction/populate_transaction.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { EthereumRpc } from '../eth_rpc/ethereum_rpc.js'; -import { EthAccount } from '../eth_account/index.js'; -import { EthTransaction } from './eth_transaction.js'; -import { BlockResponse } from '../eth_rpc/index.js'; - -/** - * Populate a partial EthTransaction by querying node for defaults. - * `to` can be optional when creating a new contract. - * `data` is optional when just doing value sends. - * `gas` must be provided. - * Everything else should be populated. - */ -export async function populateTransaction( - tx: Partial, - privateKey: Buffer, - eth: EthereumRpc, -): Promise { - if (!tx.gas) { - throw new Error('gas is missing or 0.'); - } - - // Get the missing info from the Ethereum node. - const promises: [Promise, Promise | undefined, Promise] = [ - tx.chainId === undefined ? eth.getChainId() : Promise.resolve(tx.chainId), - tx.maxFeePerGas === undefined ? eth.getBlockByNumber('latest') : undefined, - tx.nonce === undefined ? eth.getTransactionCount(new EthAccount(privateKey).address) : Promise.resolve(tx.nonce), - ]; - - const [chainId, block, nonce] = await Promise.all(promises); - - const maxPriorityFeePerGas = tx.maxPriorityFeePerGas !== undefined ? tx.maxPriorityFeePerGas : BigInt(2500000000); // 2.5 gwei - const maxFeePerGas = block - ? (block.baseFeePerGas! * BigInt(115)) / BigInt(100) + maxPriorityFeePerGas - : tx.maxFeePerGas!; - const { to, gas, value = BigInt(0), data } = tx; - - return { - chainId, - to, - gas, - maxFeePerGas, - maxPriorityFeePerGas, - value, - data, - nonce, - }; -} diff --git a/yarn-project/ethereum.js/src/eth_transaction/sign_transaction.test.ts b/yarn-project/ethereum.js/src/eth_transaction/sign_transaction.test.ts deleted file mode 100644 index e5e60b55b52..00000000000 --- a/yarn-project/ethereum.js/src/eth_transaction/sign_transaction.test.ts +++ /dev/null @@ -1,239 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { recoverTransaction, signTransaction } from './sign_transaction.js'; - -// For test with accessList below, not yet supported. -// var accessList = [ -// { -// address: '0x0000000000000000000000000000000000000101', -// storageKeys: [ -// "0x0000000000000000000000000000000000000000000000000000000000000000", -// "0x00000000000000000000000000000000000000000000000000000000000060a7" -// ] -// } -// ]; - -describe('eth_account sign transaction', () => { - // const testData = { - // address: EthAddress.fromString('0x2c7536E3605D9C16a7a3D7b1898e529396a65c23'), - // iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - // privateKey: Buffer.from('4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', 'hex'), - // transaction: { - // chainId: 1, - // nonce: 0, - // maxFeePerGas: BigInt(20000000000), - // maxPriorityFeePerGas: BigInt(0), - // gas: 21000, - // to: EthAddress.fromString('0xF0109fC8DF283027b6285cc889F5aA624EaC1F55'), - // value: BigInt(1000000000), - // } as EthTransaction, - // rawTransaction: Buffer.from( - // 'f868808504a817c80082520894f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008026a0afa02d193471bb974081585daabf8a751d4decbb519604ac7df612cc11e9226da04bf1bd55e82cebb2b09ed39bbffe35107ea611fa212c2d9a1f1ada4952077118', - // 'hex', - // ), - // }; - - const testData = - //[ - // { - // // test #24 - // address: EthAddress.fromString('0x2c7536E3605D9C16a7a3D7b1898e529396a65c23'), - // // iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - // privateKey: Buffer.from('4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', 'hex'), - // transaction: { - // chainId: 1, - // nonce: 0, - // maxPriorityFeePerGas: BigInt('1000000000'), - // maxFeePerGas: BigInt('3000000000'), - // gas: 27200, - // to: EthAddress.fromString('0xF0109fC8DF283027b6285cc889F5aA624EaC1F55'), - // // toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - // value: BigInt('1000000000'), - // // accessList: accessList, - // }, - // // signature from eth_signTransaction - // rawTransaction: - // '0x02f8ca0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a701a0e86d3360f40f934686e1f9e53d5f49634adb0227169dd8a93b66683eb32b9c1ca04e5851b4601e2e9178148ca0f4f8360d9fba16baf272931debdf270ffa6fafc9', - // oldSignature: - // '0x02f8ca0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a701a0e86d3360f40f934686e1f9e53d5f49634adb0227169dd8a93b66683eb32b9c1ca04e5851b4601e2e9178148ca0f4f8360d9fba16baf272931debdf270ffa6fafc9', - // transactionHash: '0xc102cf9a2cfa23b06d013970497793077c2fa2a203ec32ddeee2ec87a4ab1cb8', - // messageHash: '0x69325a2750893097fb1b7ab621bacef5fc20fd33374e1c3f44a79f9f35602b59', - // }; - { - // test #25 - address: EthAddress.fromString('0x2c7536E3605D9C16a7a3D7b1898e529396a65c23'), - // iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: Buffer.from('4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', 'hex'), - transaction: { - chainId: 1, - nonce: 0, - maxPriorityFeePerGas: BigInt('0x3B9ACA00'), - maxFeePerGas: BigInt('0xB2D05E00'), - gas: 27200, - to: EthAddress.fromString('0xF0109fC8DF283027b6285cc889F5aA624EaC1F55'), - // toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: BigInt('1000000000'), - // data: , - // common: commonLondon, - }, - // signature from eth_signTransaction - rawTransaction: Buffer.from( - '02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36', - 'hex', - ), - oldSignature: Buffer.from( - '02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36', - 'hex', - ), - transactionHash: Buffer.from('82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e', 'hex'), - messageHash: Buffer.from('e3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b', 'hex'), - }; - /* - { - // test #26 - address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', - iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', - transaction: { - chainId: 1, - nonce: 0, - gas: 27200, - maxPriorityFeePerGas: '0x3B9ACA00', - gasLimit: '0x6A40', - to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', - toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: '1000000000', - data: '', - common: commonLondon, - }, - // signature from eth_signTransaction - rawTransaction: - '0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833', - oldSignature: - '0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833', - transactionHash: '0x488a813f2286f7c015947aa13133bdae49ec75ae1c8f5eba80034d71a038dca8', - messageHash: '0xcd6d6dee80ecc38f1b22f2d128bf6043dc41079fc913183a8995b5b3e187df61', - }, - { - // test #27 - address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', - iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', - transaction: { - chainId: 1, - nonce: 0, - gas: 27200, - maxPriorityFeePerGas: '0x3B9ACA00', - gasLimit: '0x6A40', - to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', - toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: '1000000000', - data: '', - common: commonLondon, - accessList: accessList, - }, - // signature from eth_signTransaction - rawTransaction: - '0x02f8ca0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a780a0e3a2e10c7d3af3407ec2d38c64788d6673926e9b28d6d2e7df3c94cdf0548233a00ad3e5faafaf3a9350ab16c1be0198ce9ff3c6bef0b91e05488d757f07de9557', - oldSignature: - '0x02f8ca0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a780a0e3a2e10c7d3af3407ec2d38c64788d6673926e9b28d6d2e7df3c94cdf0548233a00ad3e5faafaf3a9350ab16c1be0198ce9ff3c6bef0b91e05488d757f07de9557', - transactionHash: '0xbc2c9edab3d4e3a795fa402b52d6149e874de15f0cc6c0858eb34e1fe1ef31fe', - messageHash: '0xa3a2cdc45e9cefb9a614ead90ce65f68bcf8a90dbe0ccbd84c1b62403bd05346', - }, - { - // test #28 - address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', - iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', - transaction: { - chainId: 1, - nonce: 0, - maxPriorityFeePerGas: new bn('c7331248', 16), - maxFeePerGas: new bn('cb72ec20', 16), - gasLimit: '0x6A40', - to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', - toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: '1000000000', - data: '', - common: commonLondon, - }, - // signature from eth_signTransaction - rawTransaction: - '0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3', - oldSignature: - '0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3', - transactionHash: '0xd5b7290a477b9c421d39e61d0f566ec33276fb49b9ff85cfd6152a18f1c92dab', - messageHash: '0x17e20e530a889ce52057de228b5b97edcad6002468d723346cd0b6b7a9943457', - }, - { - // test #29 - address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', - iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', - transaction: { - chainId: 1, - nonce: 0, - maxPriorityFeePerGas: '1000000000', - maxFeePerGas: '3000000000', - gasLimit: '0x6A40', - to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', - toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: '1000000000', - data: '', - common: commonLondon, - }, - // signature from eth_signTransaction - rawTransaction: - '0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36', - oldSignature: - '0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36', - transactionHash: '0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e', - messageHash: '0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b', - }, - { - // test #30 - address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', - iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', - transaction: { - chainId: 1, - nonce: 0, - maxPriorityFeePerGas: new utils.BN('0x3B9ACA00'), - maxFeePerGas: new utils.BN('0xB2D05E00'), - gasLimit: '0x6A40', - to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', - toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: '1000000000', - data: '', - common: commonLondon, - }, - // signature from eth_signTransaction - rawTransaction: - '0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36', - oldSignature: - '0x02f86e018084c733124884cb72ec20826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c001a08896fb9a5c033e0163b073cf7a951a1db2dca41b26b4188f13a05158eb26fd32a005e8855691199cd0b6dcae88f3325c374e2f0697b9c528a5c10d5bd8dfb6a3e3', - transactionHash: '0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e', - messageHash: '0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b', - }, - ]; - */ - - // it('signTransaction using the iban as "to" must compare to eth_signTransaction', () => { - // const transaction = { - // ...testData.transaction, - // to: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT' as any, - // }; - // const tx = signTransaction(transaction, testData.privateKey); - // expect(tx.rawTransaction).toEqual(testData.rawTransaction); - // }); - - it('should create correct signature', () => { - const tx = signTransaction(testData.transaction, testData.privateKey); - expect(tx.messageHash).toEqual(testData.messageHash); - expect(tx.rawTransaction).toEqual(testData.rawTransaction); - }); - - it('should recover address from signature', () => { - const tx = signTransaction(testData.transaction, testData.privateKey); - expect(recoverTransaction(tx.rawTransaction)).toEqual(testData.address); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_transaction/sign_transaction.ts b/yarn-project/ethereum.js/src/eth_transaction/sign_transaction.ts deleted file mode 100644 index 5c6674e4937..00000000000 --- a/yarn-project/ethereum.js/src/eth_transaction/sign_transaction.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { decode, encode } from 'rlp'; -import { EthTransaction } from './eth_transaction.js'; -import { sign, EthSignature, recoverFromSignature } from '../eth_sign/index.js'; -import { keccak256 } from '../crypto/index.js'; -import { numToUInt8 } from '../serialize/index.js'; - -/** - * Represents a signed Ethereum transaction object. - * Contains the signature, message hash, and raw transaction data for a valid Ethereum transaction. - */ -export interface SignedEthTransaction { - /** - * The cryptographic signature of the transaction. - */ - signature: EthSignature; - /** - * The Keccak-256 hash of the signed transaction message. - */ - messageHash: Buffer; - /** - * The serialized raw Ethereum transaction in RLP-encoded format. - */ - rawTransaction: Buffer; -} - -/** - * Recover the sender's address from a raw Ethereum transaction buffer. - * This function takes in a raw transaction buffer, extracts the signature, - * and uses it to recover the Ethereum address of the sender. It works with - * EIP-1559 transactions only (transaction type 2). Throws an error if there's - * any issue during the recovery process. - * - * @param rawTx - The raw transaction buffer containing nonce, gas, max fees, - * chainId, and signature information. - * @returns An Ethereum address as Buffer representing the transaction sender. - */ -export function recoverTransaction(rawTx: Buffer) { - const txType = numToUInt8(rawTx[0]); - // Slice off txType. - const values = decode(new Uint8Array(rawTx.slice(1))); - const v = values[9][0] || 0; - const r = Buffer.from(values[10] as Uint8Array); - const s = Buffer.from(values[11] as Uint8Array); - const signature = new EthSignature(r, s, v); - const signingDataBuf = Buffer.from(encode(values.slice(0, 9))); - const messageHash = keccak256(Buffer.concat([txType, signingDataBuf])); - return recoverFromSignature(messageHash, signature); -} - -/** - * Transaction type 2 (EIP1559 as per https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md). - */ -export function signTransaction(tx: EthTransaction, privateKey: Buffer): SignedEthTransaction { - const { nonce, gas, maxFeePerGas, maxPriorityFeePerGas, chainId } = tx; - if (nonce < 0 || gas < 0 || maxFeePerGas < 0 || maxPriorityFeePerGas < 0 || chainId < 0) { - throw new Error('negative input value.'); - } - - const txType = numToUInt8(0x2); - - const toEncode = [ - tx.chainId, - tx.nonce, - tx.maxPriorityFeePerGas, - tx.maxFeePerGas, - tx.gas, - new Uint8Array(tx.to ? tx.to.toBuffer() : []), - tx.value, - new Uint8Array(tx.data || []), - [], // access_list - ]; - - const rlpEncoded = Buffer.from(encode(toEncode)); - const messageHash = keccak256(Buffer.concat([txType, rlpEncoded])); - const signature = sign(messageHash, privateKey); - const { v, r, s } = signature; - - const rawTx = [...toEncode, v, r, s]; - const rawTransaction = Buffer.concat([txType, Buffer.from(encode(rawTx))]); - - return { - signature, - messageHash, - rawTransaction, - }; -} - -/** - * Constructs a signed Ethereum transaction object from the given EthTransaction and EthSignature objects. - * This function calculates the message hash by concatenating transaction type (EIP-1559) and RLP-encoded - * transaction data, then hashing it using keccak256. The sender's address is recovered from the signature - * and message hash using the 'recoverFromSignature' function. - * - * @param tx - An EthTransaction object containing transaction details such as nonce, gas, maxFeePerGas, etc. - * @param signature - An EthSignature object containing the signature components (r, s, and v) for the transaction. - * @returns The sender's Ethereum address recovered from the given signature and transaction data. - */ -export function signedTransaction(tx: EthTransaction, signature: EthSignature) { - const txType = numToUInt8(0x2); - - const toEncode = [ - tx.chainId, - tx.nonce, - tx.maxPriorityFeePerGas, - tx.maxFeePerGas, - tx.gas, - new Uint8Array(tx.to ? tx.to.toBuffer() : []), - tx.value, - new Uint8Array(tx.data || []), - [], // access_list - ]; - - const rlpEncoded = Buffer.from(encode(toEncode)); - const messageHash = keccak256(Buffer.concat([txType, rlpEncoded])); - - return recoverFromSignature(messageHash, signature); -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/eip-712.test.ts b/yarn-project/ethereum.js/src/eth_typed_data/eip-712.test.ts deleted file mode 100644 index c3d061cc4ae..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/eip-712.test.ts +++ /dev/null @@ -1,285 +0,0 @@ -import invalidArrayLength from './fixtures/invalid-array-length.json'; -import invalidArrayType from './fixtures/invalid-array-type.json'; -import invalidMissingData from './fixtures/invalid-missing-data.json'; -import invalidMissingType from './fixtures/invalid-missing-type.json'; -import invalidSchema from './fixtures/invalid-schema.json'; -import invalidType from './fixtures/invalid-type.json'; -import mailTypedData from './fixtures/typed-data-1.json'; -import approvalTypedData from './fixtures/typed-data-2.json'; -import arrayTypedData from './fixtures/typed-data-3.json'; -import customTypedData from './fixtures/typed-data-4.json'; -import { asArray, encodeData, encodeType, getDependencies, getMessage, getStructHash, getTypeHash } from './eip-712.js'; - -const bytesToHex = (buf: Buffer) => buf.toString('hex'); - -describe('getDependencies', () => { - it('returns all dependencies for the primary type', () => { - expect(getDependencies(mailTypedData, 'EIP712Domain')).toStrictEqual(['EIP712Domain']); - expect(getDependencies(mailTypedData, 'Person')).toStrictEqual(['Person']); - expect(getDependencies(mailTypedData, 'Mail')).toStrictEqual(['Mail', 'Person']); - - expect(getDependencies(approvalTypedData, 'EIP712Domain')).toStrictEqual(['EIP712Domain']); - expect(getDependencies(approvalTypedData, 'Transaction')).toStrictEqual(['Transaction']); - expect(getDependencies(approvalTypedData, 'TransactionApproval')).toStrictEqual([ - 'TransactionApproval', - 'Transaction', - ]); - - expect(getDependencies(arrayTypedData, 'EIP712Domain')).toStrictEqual(['EIP712Domain']); - expect(getDependencies(arrayTypedData, 'Person')).toStrictEqual(['Person']); - expect(getDependencies(arrayTypedData, 'Mail')).toStrictEqual(['Mail', 'Person']); - - expect(getDependencies(customTypedData, 'FooBarDomain')).toStrictEqual(['FooBarDomain']); - }); - - it.skip('throws for invalid JSON data', () => { - expect(() => getDependencies(invalidSchema as any, 'EIP712Domain')).toThrow(); - }); - - it('throws for invalid types', () => { - expect(() => getDependencies(invalidType, 'EIP712Domain')).toThrow(); - expect(() => getDependencies(invalidType, 'Person')).toThrow(); - expect(() => getDependencies(invalidType, 'Mail')).toThrow(); - }); -}); - -describe('encodeType', () => { - it('encodes a type to a hashable string', () => { - expect(encodeType(mailTypedData, 'EIP712Domain')).toBe( - 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)', - ); - expect(encodeType(mailTypedData, 'Person')).toBe('Person(string name,address wallet)'); - expect(encodeType(mailTypedData, 'Mail')).toBe( - 'Mail(Person from,Person to,string contents)Person(string name,address wallet)', - ); - - expect(encodeType(approvalTypedData, 'EIP712Domain')).toBe( - 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)', - ); - expect(encodeType(approvalTypedData, 'Transaction')).toBe( - 'Transaction(address to,uint256 amount,bytes data,uint256 nonce)', - ); - expect(encodeType(approvalTypedData, 'TransactionApproval')).toBe( - 'TransactionApproval(address owner,Transaction transaction)Transaction(address to,uint256 amount,bytes data,uint256 nonce)', - ); - - expect(encodeType(customTypedData, 'FooBarDomain')).toBe( - 'FooBarDomain(string name,string version,uint256 chainId,address verifyingContract)', - ); - }); - - it.skip('throws for invalid JSON data', () => { - expect(() => encodeType(invalidSchema as any, 'EIP712Domain')).toThrow(); - }); - - it('throws for invalid types', () => { - expect(() => encodeType(invalidType, 'EIP712Domain')).toThrow(); - expect(() => encodeType(invalidType, 'Person')).toThrow(); - expect(() => encodeType(invalidType, 'Mail')).toThrow(); - }); -}); - -describe('getTypeHash', () => { - it('returns a 32 byte hash for a type', () => { - expect(bytesToHex(getTypeHash(mailTypedData, 'EIP712Domain'))).toBe( - '8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f', - ); - expect(bytesToHex(getTypeHash(mailTypedData, 'Person'))).toBe( - 'b9d8c78acf9b987311de6c7b45bb6a9c8e1bf361fa7fd3467a2163f994c79500', - ); - expect(bytesToHex(getTypeHash(mailTypedData, 'Mail'))).toBe( - 'a0cedeb2dc280ba39b857546d74f5549c3a1d7bdc2dd96bf881f76108e23dac2', - ); - - expect(bytesToHex(getTypeHash(approvalTypedData, 'EIP712Domain'))).toBe( - 'd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472', - ); - expect(bytesToHex(getTypeHash(approvalTypedData, 'Transaction'))).toBe( - 'a826c254899945d99ae513c9f1275b904f19492f4438f3d8364fa98e70fbf233', - ); - expect(bytesToHex(getTypeHash(approvalTypedData, 'TransactionApproval'))).toBe( - '5b360b7b2cc780b6a0687ac409805af3219ef7d9dcc865669e39a1dc7394ffc5', - ); - - expect(bytesToHex(getTypeHash(arrayTypedData, 'EIP712Domain'))).toBe( - '8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f', - ); - expect(bytesToHex(getTypeHash(arrayTypedData, 'Mail'))).toBe( - 'c81112a69b6596b8bc0678e67d97fbf9bed619811fc781419323ec02d1c7290d', - ); - expect(bytesToHex(getTypeHash(arrayTypedData, 'Person'))).toBe( - 'b9d8c78acf9b987311de6c7b45bb6a9c8e1bf361fa7fd3467a2163f994c79500', - ); - - expect(bytesToHex(getTypeHash(customTypedData, 'FooBarDomain'))).toBe( - '85b412c5db9e26aa4f6bf794e72b1557f463a0978ceef9acaff7f6ff1eb24e57', - ); - }); - - it.skip('throws for invalid JSON data', () => { - expect(() => getTypeHash(invalidSchema as any, 'EIP712Domain')).toThrow(); - }); -}); - -describe('encodeData', () => { - it('encodes data to an ABI encoded string', () => { - expect(bytesToHex(encodeData(mailTypedData, 'EIP712Domain', mailTypedData.domain))).toBe( - '8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400fc70ef06638535b4881fafcac8287e210e3769ff1a8e91f1b95d6246e61e4d3c6c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cccccccccccccccccccccccccccccccccccccccc', - ); - expect(bytesToHex(encodeData(mailTypedData, 'Person', mailTypedData.message.from))).toBe( - 'b9d8c78acf9b987311de6c7b45bb6a9c8e1bf361fa7fd3467a2163f994c795008c1d2bd5348394761719da11ec67eedae9502d137e8940fee8ecd6f641ee1648000000000000000000000000cd2a3d9f938e13cd947ec05abc7fe734df8dd826', - ); - expect(bytesToHex(encodeData(mailTypedData, 'Mail', mailTypedData.message))).toBe( - 'a0cedeb2dc280ba39b857546d74f5549c3a1d7bdc2dd96bf881f76108e23dac2fc71e5fa27ff56c350aa531bc129ebdf613b772b6604664f5d8dbe21b85eb0c8cd54f074a4af31b4411ff6a60c9719dbd559c221c8ac3492d9d872b041d703d1b5aadf3154a261abdd9086fc627b61efca26ae5702701d05cd2305f7c52a2fc8', - ); - - expect(bytesToHex(encodeData(approvalTypedData, 'EIP712Domain', approvalTypedData.domain))).toBe( - 'd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472d210ccb0bd8574cfdb6efd17ae4e6ab527687a29dcf03060d4a41b9b56d0b637c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1dbbd6c8d75f4b446bcb44cee3ba5da8120e056d4d2f817213df8703ef065ed3', - ); - expect(bytesToHex(encodeData(approvalTypedData, 'Transaction', approvalTypedData.message.transaction))).toBe( - 'a826c254899945d99ae513c9f1275b904f19492f4438f3d8364fa98e70fbf2330000000000000000000000004bbeeb066ed09b7aed07bf39eee0460dfa2615200000000000000000000000000000000000000000000000000de0b6b3a7640000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4700000000000000000000000000000000000000000000000000000000000000001', - ); - expect(bytesToHex(encodeData(approvalTypedData, 'TransactionApproval', approvalTypedData.message))).toBe( - '5b360b7b2cc780b6a0687ac409805af3219ef7d9dcc865669e39a1dc7394ffc5000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb9e7ba42b4ace63ae7d8ee163d5e642a085b32c2553717dcb37974e83fad289d0', - ); - - expect(bytesToHex(encodeData(arrayTypedData, 'Mail', arrayTypedData.message))).toBe( - 'c81112a69b6596b8bc0678e67d97fbf9bed619811fc781419323ec02d1c7290dafd2599280d009dcb3e261f4bccebec901d67c3f54b56d49bf8327359fc69cd7392bb8ab5338a9075ce8fec1b431e334007d4de1e5e83201ca35762e24428e24b7c4150525d88db452c5f08f93f4593daa458ab6280b012532183aed3a8e4a01', - ); - - expect(bytesToHex(encodeData(customTypedData, 'FooBarDomain', customTypedData.domain))).toBe( - '85b412c5db9e26aa4f6bf794e72b1557f463a0978ceef9acaff7f6ff1eb24e57c70ef06638535b4881fafcac8287e210e3769ff1a8e91f1b95d6246e61e4d3c6c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cccccccccccccccccccccccccccccccccccccccc', - ); - }); - - it('throws for invalid JSON data', () => { - expect(() => encodeData(invalidSchema as any, 'EIP712Domain', invalidSchema.domain)).toThrow(); - }); - - it('throws when a type is missing', () => { - expect(() => encodeData(invalidMissingData, 'Mail', invalidMissingData.message)).toThrow(); - }); - - it('throws when data is missing', () => { - expect(() => encodeData(invalidMissingType, 'Mail', invalidMissingType.message)).toThrow(); - }); - - it('throws if the type is not an array', () => { - expect(() => encodeData(invalidArrayType, 'Mail', invalidArrayType.message)).toThrow(); - }); - - it('throws if the array length is invalid', () => { - expect(() => encodeData(invalidArrayLength, 'Mail', invalidArrayLength.message)).toThrow(); - }); -}); - -describe('getStructHash', () => { - it('returns a 32 byte hash for a struct', () => { - expect(bytesToHex(getStructHash(mailTypedData, 'EIP712Domain', mailTypedData.domain))).toBe( - 'f2cee375fa42b42143804025fc449deafd50cc031ca257e0b194a650a912090f', - ); - expect(bytesToHex(getStructHash(mailTypedData, 'Person', mailTypedData.message.from))).toBe( - 'fc71e5fa27ff56c350aa531bc129ebdf613b772b6604664f5d8dbe21b85eb0c8', - ); - expect(bytesToHex(getStructHash(mailTypedData, 'Mail', mailTypedData.message))).toBe( - 'c52c0ee5d84264471806290a3f2c4cecfc5490626bf912d01f240d7a274b371e', - ); - - expect(bytesToHex(getStructHash(approvalTypedData, 'EIP712Domain', approvalTypedData.domain))).toBe( - '67083568259b4a947b02ce4dca4cc91f1e7f01d109c8805668755be5ab5adbb9', - ); - expect(bytesToHex(getStructHash(approvalTypedData, 'Transaction', approvalTypedData.message.transaction))).toBe( - '9e7ba42b4ace63ae7d8ee163d5e642a085b32c2553717dcb37974e83fad289d0', - ); - expect(bytesToHex(getStructHash(approvalTypedData, 'TransactionApproval', approvalTypedData.message))).toBe( - '309886ad75ec7c2c6a69bffa2669bad00e3b1e0a85221eff4e8926a2f8ff5077', - ); - - expect(bytesToHex(getStructHash(customTypedData, 'FooBarDomain', customTypedData.domain))).toBe( - '6ff4505ed33bedaadf3491aa039d9ccb91a3114eeab940e69fdecb809fb26882', - ); - }); - - it('throws for invalid JSON data', () => { - expect(() => getStructHash(invalidSchema as any, 'EIP712Domain', invalidSchema.domain)).toThrow(); - }); - - it('throws when a type is missing', () => { - expect(() => encodeData(invalidMissingType, 'Mail', invalidSchema.message)).toThrow(); - }); - - it('throws when data is missing', () => { - expect(() => encodeData(invalidMissingType, 'Mail', invalidSchema.message)).toThrow(); - }); -}); - -describe('getMessage', () => { - it('returns the full encoded and hashed message to sign', () => { - expect(bytesToHex(getMessage(mailTypedData))).toBe( - '1901f2cee375fa42b42143804025fc449deafd50cc031ca257e0b194a650a912090fc52c0ee5d84264471806290a3f2c4cecfc5490626bf912d01f240d7a274b371e', - ); - expect(bytesToHex(getMessage(approvalTypedData))).toBe( - '190167083568259b4a947b02ce4dca4cc91f1e7f01d109c8805668755be5ab5adbb9309886ad75ec7c2c6a69bffa2669bad00e3b1e0a85221eff4e8926a2f8ff5077', - ); - expect(bytesToHex(getMessage(arrayTypedData))).toBe( - '1901f2cee375fa42b42143804025fc449deafd50cc031ca257e0b194a650a912090f6757567025d2ba15d5ebb228ea677055b8b601007e60e9463f6ed7c68f918189', - ); - expect(bytesToHex(getMessage(customTypedData, false, 'FooBarDomain'))).toBe( - '19016ff4505ed33bedaadf3491aa039d9ccb91a3114eeab940e69fdecb809fb268826757567025d2ba15d5ebb228ea677055b8b601007e60e9463f6ed7c68f918189', - ); - }); - - it('hashes the message with Keccak-256', () => { - expect(bytesToHex(getMessage(mailTypedData, true))).toBe( - 'be609aee343fb3c4b28e1df9e632fca64fcfaede20f02e86244efddf30957bd2', - ); - expect(bytesToHex(getMessage(approvalTypedData, true))).toBe( - 'ee0cdea747f4a81355be92dbf30e209dbd2954a82d5a82482b7c7800089c7f57', - ); - expect(bytesToHex(getMessage(arrayTypedData, true))).toBe( - 'c6f6c8028eadb17bc5c9e2ea2f738e92e49cfa627d19896c250fd2eac653e4e0', - ); - expect(bytesToHex(getMessage(customTypedData, true, 'FooBarDomain'))).toBe( - 'e028c0622beef9bde70e78a98c1d09a95ffe0cd9cfa5ff6a99f7db7c9245e103', - ); - }); - - it.skip('throws for invalid JSON data', () => { - expect(() => getMessage(invalidSchema as any)).toThrow(); - }); - - it('throws when a type is missing', () => { - expect(() => getMessage(invalidMissingType)).toThrow(); - }); - - it('throws when data is missing', () => { - expect(() => getMessage(invalidMissingData)).toThrow(); - }); -}); - -describe('asArray', () => { - it('returns the typed data as array', () => { - expect(asArray(mailTypedData)).toStrictEqual([ - ['Cow', '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'], - ['Bob', '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'], - 'Hello, Bob!', - ]); - - expect(asArray(approvalTypedData)).toStrictEqual([ - '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', - ['0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520', '1000000000000000000', '', '1'], - ]); - }); - - it.skip('throws for invalid JSON data', () => { - expect(() => asArray(invalidSchema as any)).toThrow(); - }); - - it('throws when a type is missing', () => { - expect(() => asArray(invalidMissingType)).toThrow(); - }); - - it('throws when data is missing', () => { - expect(() => asArray(invalidMissingData)).toThrow(); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_typed_data/eip-712.ts b/yarn-project/ethereum.js/src/eth_typed_data/eip-712.ts deleted file mode 100644 index 421af8a841c..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/eip-712.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { TypedData } from './typed_data.js'; -import { keccak256 } from '../crypto/index.js'; -import { abiCoder } from '../contract/index.js'; - -const EIP_191_PREFIX = Buffer.from('1901', 'hex'); - -/** - * Get the dependencies of a struct type. If a struct has the same dependency multiple times, it's only included once - * in the resulting array. - */ -export const getDependencies = (typedData: TypedData, type: string, dependencies: string[] = []): string[] => { - const TYPE_REGEX = /^\w+/; - const match = type.match(TYPE_REGEX)!; - const actualType = match[0]; - if (dependencies.includes(actualType)) { - return dependencies; - } - - if (!typedData.types[actualType]) { - return dependencies; - } - - return [ - actualType, - ...typedData.types[actualType].reduce( - (previous, type) => [ - ...previous, - ...getDependencies(typedData, type.type, previous).filter(dependency => !previous.includes(dependency)), - ], - [], - ), - ]; -}; - -/** - * Encode a type to a string. All dependant types are alphabetically sorted. - * - * @param typedData -. - * @param type -. - */ -export const encodeType = (typedData: TypedData, type: string): string => { - const [primary, ...dependencies] = getDependencies(typedData, type); - const types = [primary, ...dependencies.sort()]; - - return types - .map(dependency => { - return `${dependency}(${typedData.types[dependency].map(type => `${type.type} ${type.name}`)})`; - }) - .join(''); -}; - -/** - * Get a type string as hash. - */ -export const getTypeHash = (typedData: TypedData, type: string) => { - return keccak256(Buffer.from(encodeType(typedData, type))); -}; - -/** - * Encodes a single value to an ABI serialisable string, number or Buffer. Returns the data as tuple, which consists of - * an array of ABI compatible types, and an array of corresponding values. - */ -const encodeValue = (typedData: TypedData, type: string, data: unknown): [string, Buffer | string] => { - // Checks for array types - const ARRAY_REGEX = /^(.*)\[([0-9]*?)]$/; - const match = type.match(ARRAY_REGEX); - if (match) { - const arrayType = match[1]; - const length = Number(match[2]) || undefined; - - if (!Array.isArray(data)) { - throw new Error('Cannot encode data: value is not of array type'); - } - - if (length && data.length !== length) { - throw new Error(`Cannot encode data: expected length of ${length}, but got ${data.length}`); - } - - const encodedData = data.map(item => encodeValue(typedData, arrayType, item)); - const types = encodedData.map(item => item[0]); - const values = encodedData.map(item => item[1]); - - return ['bytes32', keccak256(abiCoder.encodeParameters(types, values))]; - } - - if (typedData.types[type]) { - return ['bytes32', getStructHash(typedData, type, data as Record)]; - } - - // Strings and arbitrary byte arrays are hashed to bytes32 - if (type === 'string') { - return ['bytes32', keccak256(Buffer.from(data as string))]; - } - - if (type === 'bytes') { - return ['bytes32', keccak256(Buffer.isBuffer(data) ? data : Buffer.from(data as string))]; - } - - return [type, data as string]; -}; - -/** - * Encode the data to an ABI encoded Buffer. The data should be a key -\> value object with all the required values. All - * dependant types are automatically encoded. - */ -export const encodeData = (typedData: TypedData, type: string, data: Record): Buffer => { - const [types, values] = typedData.types[type].reduce<[string[], unknown[]]>( - ([types, values], field) => { - if (data[field.name] === undefined || data[field.name] === null) { - throw new Error(`Cannot encode data: missing data for '${field.name}'`); - } - - const value = data[field.name]; - const [type, encodedValue] = encodeValue(typedData, field.type, value); - - return [ - [...types, type], - [...values, encodedValue], - ]; - }, - [['bytes32'], [getTypeHash(typedData, type)]], - ); - - return abiCoder.encodeParameters(types, values); -}; - -/** - * Get encoded data as a hash. The data should be a key -\> value object with all the required values. All dependant - * types are automatically encoded. - */ -export const getStructHash = (typedData: TypedData, type: string, data: Record) => { - return keccak256(encodeData(typedData, type, data)); -}; - -/** - * Get the EIP-191 encoded message to sign, from the typedData object. If `hash` is enabled, the message will be hashed - * with Keccak256. - */ -export const getMessage = (typedData: TypedData, hash?: boolean, domain = 'EIP712Domain') => { - const message = Buffer.concat([ - EIP_191_PREFIX, - getStructHash(typedData, domain, typedData.domain as Record), - getStructHash(typedData, typedData.primaryType, typedData.message), - ]); - - if (hash) { - return keccak256(message); - } - - return message; -}; - -/** - * Get the typed data as array. This can be useful for encoding the typed data with the contract ABI. - */ -export const asArray = ( - typedData: TypedData, - type: string = typedData.primaryType, - data: Record = typedData.message, -): unknown[] => { - if (!typedData.types[type]) { - throw new Error('Cannot get data as array: type does not exist'); - } - - return typedData.types[type].reduce((array, { name, type }) => { - if (typedData.types[type]) { - if (!data[name]) { - throw new Error(`Cannot get data as array: missing data for '${name}'`); - } - - return [...array, asArray(typedData, type, data[name] as Record)]; - } - - const value = data[name]; - return [...array, value]; - }, []); -}; diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-array-length.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-array-length.json deleted file mode 100644 index 574c6a14d99..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-array-length.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person" - }, - { - "name": "to", - "type": "Person[]" - }, - { - "name": "contents", - "type": "string[3]" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": [ - { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - { - "name": "Alice", - "wallet": "0xdddddddddddddddddddddddddddddddddddddddd" - }, - { - "name": "Michael", - "wallet": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - } - ], - "contents": ["Hello, Bob!", "Hello, Alice!"] - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-array-type.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-array-type.json deleted file mode 100644 index 03d0e518a99..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-array-type.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person" - }, - { - "name": "to", - "type": "Person[]" - }, - { - "name": "contents", - "type": "string[3]" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": "Bob", - "contents": ["Hello, Bob!", "Hello, Alice!", "Hello, Michael!"] - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-missing-data.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-missing-data.json deleted file mode 100644 index 1ea7f69842d..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-missing-data.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person" - }, - { - "name": "to", - "type": "Person" - }, - { - "name": "contents", - "type": "string" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "contents": "Hello, Bob!" - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-missing-type.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-missing-type.json deleted file mode 100644 index aa30d4536fd..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-missing-type.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - "contents": "Hello, Bob!" - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-schema.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-schema.json deleted file mode 100644 index 3d128edac35..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-schema.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person" - }, - { - "name": "to", - "type": "Person" - }, - { - "name": "contents", - "type": "string" - } - ] - }, - "primaryType": "Mail", - "domain": { - "foo": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - "contents": "Hello, Bob!" - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-type.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-type.json deleted file mode 100644 index 9c0ee371db2..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/invalid-type.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "[]" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "-string" - }, - { - "name": "to", - "type": "Person" - }, - { - "name": "contents", - "type": "string" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - "contents": "Hello, Bob!" - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-1.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-1.json deleted file mode 100644 index fff8e28cbf6..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-1.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person" - }, - { - "name": "to", - "type": "Person" - }, - { - "name": "contents", - "type": "string" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - "contents": "Hello, Bob!" - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-2.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-2.json deleted file mode 100644 index 9307aa23785..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-2.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - }, - { - "name": "salt", - "type": "bytes32" - } - ], - "Transaction": [ - { - "name": "to", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - }, - { - "name": "nonce", - "type": "uint256" - } - ], - "TransactionApproval": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "transaction", - "type": "Transaction" - } - ] - }, - "primaryType": "TransactionApproval", - "domain": { - "name": "Multisig Wallet", - "version": "1", - "chainId": 1, - "verifyingContract": "0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa", - "salt": "0x1dbbd6c8d75f4b446bcb44cee3ba5da8120e056d4d2f817213df8703ef065ed3" - }, - "message": { - "owner": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB", - "transaction": { - "to": "0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520", - "amount": "1000000000000000000", - "data": "", - "nonce": "1" - } - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-3.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-3.json deleted file mode 100644 index eed1c7e443d..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-3.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person[]" - }, - { - "name": "to", - "type": "Person[]" - }, - { - "name": "contents", - "type": "string[3]" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": [ - { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - } - ], - "to": [ - { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - { - "name": "Alice", - "wallet": "0xdddddddddddddddddddddddddddddddddddddddd" - }, - { - "name": "Michael", - "wallet": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - } - ], - "contents": ["Hello, Bob!", "Hello, Alice!", "Hello, Michael!"] - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-4.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-4.json deleted file mode 100644 index d076bd4dcdb..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-4.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "types": { - "FooBarDomain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person[]" - }, - { - "name": "to", - "type": "Person[]" - }, - { - "name": "contents", - "type": "string[3]" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" - }, - "message": { - "from": [ - { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - } - ], - "to": [ - { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - { - "name": "Alice", - "wallet": "0xdddddddddddddddddddddddddddddddddddddddd" - }, - { - "name": "Michael", - "wallet": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - } - ], - "contents": ["Hello, Bob!", "Hello, Alice!", "Hello, Michael!"] - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-5.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-5.json deleted file mode 100644 index 1f9652d8ce8..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/typed-data-5.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "types": { - "FooBarDomain": [ - { - "name": "foo", - "type": "string" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person[]" - }, - { - "name": "to", - "type": "Person[]" - }, - { - "name": "contents", - "type": "string[3]" - } - ] - }, - "primaryType": "Mail", - "domain": { - "foo": "Ether Mail" - }, - "message": { - "from": [ - { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - } - ], - "to": [ - { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - { - "name": "Alice", - "wallet": "0xdddddddddddddddddddddddddddddddddddddddd" - }, - { - "name": "Michael", - "wallet": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - } - ], - "contents": ["Hello, Bob!", "Hello, Alice!", "Hello, Michael!"] - } -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/types.json b/yarn-project/ethereum.js/src/eth_typed_data/fixtures/types.json deleted file mode 100644 index 4740b493ce0..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/fixtures/types.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "context": { - "EIP712Domain": [{ "name": "name", "type": "string" }] - } - } -] diff --git a/yarn-project/ethereum.js/src/eth_typed_data/index.ts b/yarn-project/ethereum.js/src/eth_typed_data/index.ts deleted file mode 100644 index 189a68570a6..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { getMessage } from './eip-712.js'; -import { TypedData } from './typed_data.js'; - -export * from './typed_data.js'; - -/** - * Computes the hash of the given TypedData object according to EIP-712. - * This function helps in creating a unique representation of the typed data - * which can be used for signing or verifying signatures in Ethereum transactions. - * The input 'data' should be a valid TypedData object containing types, domain, and message information. - * Throws an error if the input is not a valid TypedData object. - * - * @param data - The TypedData object to be hashed. - * @returns A string representing the hash of the typed data. - */ -export function getTypedDataHash(data: TypedData) { - return getMessage(data, true); -} diff --git a/yarn-project/ethereum.js/src/eth_typed_data/typed_data.ts b/yarn-project/ethereum.js/src/eth_typed_data/typed_data.ts deleted file mode 100644 index 8454f586768..00000000000 --- a/yarn-project/ethereum.js/src/eth_typed_data/typed_data.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Represents the typed data structure used in EIP-712 for signing messages. - * Provides a consistent format to create domain, message types and message values - * that can be encoded and signed, improving security and user experience in blockchain transactions. - */ -export interface TypedData { - /** - * Represents EIP-712 domain data containing application-specific information for signing typed data. - */ - domain: { - /** - * The identifying name of the domain. - */ - name: string; - /** - * Version identifier for the domain. - */ - version: string; - /** - * The unique identifier of the blockchain network. - */ - chainId: number; - /** - * The address of the contract responsible for data verification. - */ - verifyingContract: string; - }; - /** - * An object containing structured data types for EIP-712 signing. - */ - types: { - [key: string]: { - /** - * The name of the domain in which the TypedData is structured. - */ - name: string; - /** - * A mapping of data types with their corresponding properties, including name and type. - */ - type: string; - }[]; - }; - /** - * The specific structured data to be signed and verified. - */ - message: any; - /** - * The main type used for structuring and verifying the EIP-712 typed data. - */ - primaryType: string; -} diff --git a/yarn-project/ethereum.js/src/eth_wallet/eth_wallet.test.ts b/yarn-project/ethereum.js/src/eth_wallet/eth_wallet.test.ts deleted file mode 100644 index d59ba0f9c3b..00000000000 --- a/yarn-project/ethereum.js/src/eth_wallet/eth_wallet.test.ts +++ /dev/null @@ -1,189 +0,0 @@ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthAccount } from '../eth_account/index.js'; -import { EthWallet } from './eth_wallet.js'; - -describe('wallet', () => { - const address = EthAddress.fromString('0xEB014f8c8B418Db6b45774c326A0E64C78914dC0'); - const privateKey = Buffer.from('be6383dad004f233317e46ddb46ad31b16064d14447a95cc1d8c8d4bc61c3728', 'hex'); - - it('creates the right number of wallets', () => { - const wallet = new EthWallet(); - expect(wallet.length).toBe(0); - - wallet.create(2, Buffer.from('542342f!@#$$')); - expect(wallet.length).toBe(2); - - wallet.create(3); - expect(wallet.length).toBe(5); - - expect(EthAddress.isAddress(wallet.accounts[1].address.toString())).toBe(true); - expect(EthAddress.isAddress(wallet.accounts[2].address.toString())).toBe(true); - }); - - it('add wallet using a privatekey', () => { - const wallet = new EthWallet(); - - const account = wallet.add(privateKey); - - expect(account.address).toEqual(address); - expect(account.privateKey).toEqual(privateKey); - expect(wallet.getAccountIndex(account.address)).toBe(0); - - expect(wallet.getAccount(address)!.address).toEqual(address); - expect(wallet.getAccount(0)!.address).toEqual(address); - expect(wallet.length).toBe(1); - }); - - it('add wallet using an account', () => { - const wallet = new EthWallet(); - - const account = new EthAccount(privateKey); - wallet.add(account); - - expect(account.address).toEqual(address); - expect(account.privateKey).toEqual(privateKey); - expect(wallet.getAccountIndex(account.address)).toBe(0); - - expect(wallet.getAccount(address)!.address).toEqual(address); - expect(wallet.getAccount(0)!.address).toEqual(address); - expect(wallet.length).toBe(1); - }); - - it('should not add wallet twice work', () => { - const wallet = new EthWallet(); - - const account = new EthAccount(privateKey); - wallet.add(account); - wallet.add(account); - - expect(account.address).toEqual(address); - expect(account.privateKey).toEqual(privateKey); - expect(wallet.getAccountIndex(account.address)).toBe(0); - - expect(wallet.getAccount(address)!.address).toEqual(address); - expect(wallet.getAccount(0)!.address).toEqual(address); - expect(wallet.length).toBe(1); - }); - - it('remove wallet using an index', () => { - const wallet = new EthWallet(); - - wallet.add(privateKey); - expect(wallet.length).toBe(1); - - wallet.remove(0); - expect(wallet.getAccount(address)).toBeUndefined(); - expect(wallet.getAccount(0)).toBeUndefined(); - expect(wallet.length).toBe(0); - }); - - it('remove wallet using an address', () => { - const wallet = new EthWallet(); - - wallet.add(privateKey); - expect(wallet.length).toBe(1); - - wallet.remove(address); - expect(wallet.length).toBe(0); - }); - - it('create 5 wallets, remove two, create two more and check for overwrites', () => { - const count = 5; - const wallet = new EthWallet(); - expect(wallet.length).toBe(0); - - wallet.create(count); - const initialAddresses = [0, 1, 2, 3, 4].map(n => wallet.getAccount(n)!.address); - expect(wallet.length).toBe(count); - - const remainingAddresses = [0, 1, 3]; - const beforeRemoval = remainingAddresses.map(n => wallet.getAccount(n)!.address); - - wallet.remove(2); - wallet.remove(4); - - expect(wallet.getAccount(2)).toBeUndefined(); - expect(wallet.getAccount(4)).toBeUndefined(); - - const afterRemoval = remainingAddresses.map(n => wallet.getAccount(n)!.address); - - expect(wallet.length).toBe(3); - - wallet.create(2); - expect(EthAddress.isAddress(wallet.accounts[2].address.toString())).toBe(true); - expect(EthAddress.isAddress(wallet.accounts[4].address.toString())).toBe(true); - expect(wallet.getAccount(5)).toBeUndefined(); - - const afterMoreCreation = remainingAddresses.map(n => wallet.getAccount(n)!.address); - const newAddresses = [0, 1, 2, 3, 4].map(n => wallet.getAccount(n)!.address); - - // Checks for account overwrites - expect(wallet.length).toBe(count); - expect(beforeRemoval).toEqual(afterMoreCreation); - expect(afterRemoval).toEqual(afterMoreCreation); - expect(initialAddresses).not.toEqual(newAddresses); - }); - - it('clear wallet', () => { - const count = 10; - const wallet = new EthWallet(); - - wallet.create(count); - expect(wallet.length).toBe(10); - - wallet.clear(); - - for (let i = 0; i < count; i++) { - expect(wallet.getAccount(i)).toBeUndefined(); - } - expect(wallet.length).toBe(0); - }); - - it('encrypt then decrypt wallet', async () => { - const wallet = new EthWallet(); - const password = 'qwerty'; - - wallet.create(5); - const addressFromWallet = wallet.accounts[0].address; - expect(wallet.length).toBe(5); - - wallet.remove(2); - expect(wallet.length).toBe(4); - - const keystore = await wallet.encrypt(password); - expect(wallet.length).toBe(4); - - wallet.clear(); - expect(wallet.length).toBe(0); - - await wallet.decrypt(keystore, password); - expect(wallet.length).toBe(4); - - const addressFromKeystore = wallet.accounts[0].address; - expect(addressFromKeystore).toEqual(addressFromWallet); - }, 30000); - - it('should create correct accounts from mnemonic', () => { - const mnemonic = 'profit gather crucial census birth effort clinic roast harvest rebuild hidden bamboo'; - const addresses = [ - '0xa97ab6ec66bc2354a7d880bae18fea633752ca85', - '0x7048779748e8899c8f8baa9dd6c8973411d0fa17', - '0xe8d62adfc3584a444546f17cd1bb3c327767edb0', - '0x951afb198aaa10702f456bcc61aa8f59c4f17a2f', - '0x0598ce5f520574b5b8bd9651971c7767e4354189', - '0xa2e8c16c765ab30900e205a7ea240df7cbe63548', - '0x107d4df66df086faaa66690fadd5d3ed1ca630d1', - '0x070b4ed7bee40216355cf84d88a7ab2696caf373', - '0x87fa6ff918e36b7b73ed99c1ae5e7c3d63edb44b', - '0xc174aec38d282396604130e65b59d0096ca53fd7', - ]; - - const wallet = EthWallet.fromMnemonic(mnemonic, 10); - - expect(wallet.accounts.map(a => a.address.toString().toLowerCase())).toEqual(addresses); - - addresses.forEach((address, i) => { - expect(wallet.getAccount(i)!.address.toString().toLowerCase()).toBe(address); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/eth_wallet/eth_wallet.ts b/yarn-project/ethereum.js/src/eth_wallet/eth_wallet.ts deleted file mode 100644 index 3f6179a6ac9..00000000000 --- a/yarn-project/ethereum.js/src/eth_wallet/eth_wallet.ts +++ /dev/null @@ -1,244 +0,0 @@ -import { EthAccount } from '../eth_account/index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { decryptFromKeyStoreJson, KeyStoreEncryptOptions, KeyStoreJson } from '../keystore/index.js'; - -/** - * The EthWallet class represents an Ethereum wallet consisting of multiple Ethereum accounts. - * It provides methods for creating and managing accounts, importing wallets from mnemonics, seeds, and keystores, - * as well as encrypting and decrypting wallets. The class supports account addition, removal, retrieval, - * and management of the wallet's length and index pointers. - */ -export class EthWallet { - /** - * The total number of accounts stored in the wallet. - */ - public length = 0; - /** - * Array containing Ethereum accounts in the wallet. - */ - public accounts: EthAccount[] = []; - - constructor(numberOfAccounts = 0) { - this.create(numberOfAccounts); - } - - /** - * Create an EthWallet instance from a mnemonic string for the specified number of accounts. - * The mnemonic should be a BIP-39 compliant seed phrase containing a series of words, used for generating deterministic keys. - * This function generates EthAccounts based on the given mnemonic and adds them to the wallet. - * - * @param mnemonic - The BIP-39 compliant seed phrase as a string. - * @param numberOfAccounts - The number of accounts to generate and add to the wallet. - * @returns An EthWallet instance containing the generated accounts. - */ - public static fromMnemonic(mnemonic: string, numberOfAccounts: number) { - const wallet = new EthWallet(); - for (let i = 0; i < numberOfAccounts; ++i) { - const path = `m/44'/60'/0'/0/${i}`; - wallet.add(EthAccount.fromMnemonicAndPath(mnemonic, path)); - } - return wallet; - } - - /** - * Create an EthWallet instance from a provided seed Buffer and number of accounts. - * The function generates the specified number of EthAccounts using the seed and - * BIP44 derivation path, then adds them to the newly created EthWallet. - * - * @param seed - A Buffer containing the seed for generating the HD wallet. - * @param numberOfAccounts - The number of EthAccounts to generate using the seed. - * @returns An EthWallet instance containing the generated EthAccounts. - */ - public static fromSeed(seed: Buffer, numberOfAccounts: number) { - const wallet = new EthWallet(); - for (let i = 0; i < numberOfAccounts; ++i) { - const path = `m/44'/60'/0'/0/${i}`; - wallet.add(EthAccount.fromSeedAndPath(seed, path)); - } - return wallet; - } - - /** - * Create an EthWallet instance from an array of KeyStoreJson objects. - * Decrypts each keystore using the provided password, adds the accounts to the wallet, - * and returns the wallet with decrypted accounts. Throws an error if decryption fails - * due to an incorrect password or other issues. - * - * @param keyStores - An array of KeyStoreJson objects representing encrypted Ethereum accounts. - * @param password - The password used for decrypting the keystores. - * @returns A Promise that resolves to an EthWallet instance with decrypted accounts. - */ - public static async fromKeystores(keyStores: KeyStoreJson[], password: string) { - const wallet = new EthWallet(); - await wallet.decrypt(keyStores, password); - return wallet; - } - - /** - * Create a specified number of Ethereum accounts and add them to the wallet. - * Generates new Ethereum accounts using an optional entropy buffer for randomness. - * Returns an array of the created EthAccount instances. - * - * @param numberOfAccounts - The number of accounts to create. - * @param entropy - Optional buffer containing entropy bytes for creating accounts. - * @returns An array of created EthAccount instances. - */ - public create(numberOfAccounts: number, entropy?: Buffer): EthAccount[] { - for (let i = 0; i < numberOfAccounts; ++i) { - this.add(EthAccount.create(entropy).privateKey); - } - return this.accounts; - } - - /** - * Retrieve an EthAccount instance from the wallet using either an Ethereum address or a numeric index. - * The function searches for an account based on the provided input and returns it if found. - * If multiple accounts are present, use the address or index to specify a unique account. - * - * @param addressOrIndex - An EthAddress instance or a number representing the account's index in the wallet. - * @returns The EthAccount instance corresponding to the provided address or index, or undefined if not found. - */ - public getAccount(addressOrIndex: EthAddress | number) { - if (addressOrIndex instanceof EthAddress) { - return this.accounts.find(a => a && a.address.equals(addressOrIndex)); - } - return this.accounts[addressOrIndex]; - } - - /** - * Retrieve the index of an account in the wallet based on the provided address or index. - * If the input is an EthAddress, this function searches for an account with a matching address and returns its index. - * If the input is a number, it directly returns the input number as the index. Returns -1 if no matching account is found. - * - * @param addressOrIndex - An EthAddress object representing the Ethereum address or a number representing the account index. - * @returns The index of the account within the wallet or -1 if not found. - */ - public getAccountIndex(addressOrIndex: EthAddress | number) { - if (addressOrIndex instanceof EthAddress) { - return this.accounts.findIndex(a => a && a.address.equals(addressOrIndex)); - } - return addressOrIndex; - } - - /** - * Get an array of the indices of all EthAccounts stored in the wallet. - * The returned indices can be used to access EthAccount instances through the 'getAccount' function. - * - * @returns An array of integers representing the indices of the EthAccounts in the wallet. - */ - public getAccountIndicies() { - return Object.keys(this.accounts).map(key => +key); - } - - /** - * Retrieve the Ethereum addresses of all accounts in the wallet. - * This function maps the accounts to their corresponding addresses - * and returns an array of EthAddress instances. - * - * @returns An array of EthAddress instances representing the Ethereum addresses of the accounts in the wallet. - */ - public getAccountAddresses() { - return this.accounts.map(account => account.address); - } - - /** - * Add an EthAccount instance or a private key to the wallet. - * If an account with the same address already exists in the wallet, it returns the existing account. - * Otherwise, it adds the new account at a safe index and increments the wallet length. - * - * @param accountOrKey - An EthAccount instance or a Buffer containing the private key. - * @returns The added or existing EthAccount instance. - */ - public add(accountOrKey: Buffer | EthAccount): EthAccount { - const account = Buffer.isBuffer(accountOrKey) ? new EthAccount(accountOrKey) : accountOrKey; - - const existing = this.getAccount(account.address); - if (existing) { - return existing; - } - - const index = this.findSafeIndex(); - this.accounts[index] = account; - this.length++; - - return account; - } - - /** - * Removes an account from the wallet based on the provided address or index. - * If the given address or index matches one of the existing accounts in the wallet, the account will be removed, - * and the function returns true. If the address or index is not found in the wallet, the function returns false. - * - * @param addressOrIndex - The EthAddress or index number of the account to be removed from the wallet. - * @returns A boolean value indicating whether the removal was successful. - */ - public remove(addressOrIndex: number | EthAddress) { - const index = this.getAccountIndex(addressOrIndex); - - if (index === -1) { - return false; - } - - delete this.accounts[index]; - this.length--; - - return true; - } - - /** - * Clears all the accounts stored in the EthWallet instance. - * The length of EthWallet will be set to 0 and the accounts array will become empty. - */ - public clear() { - this.accounts = []; - this.length = 0; - } - - /** - * Encrypts the account private keys in the wallet using the provided password and returns an array of KeyStoreJson objects. - * The KeyStoreJson objects follow the Ethereum keystore format (UTC / JSON) standard and can be later used to decrypt the accounts. - * The optional 'options' parameter allows customizing the encryption process, such as the number of iterations or salt. - * - * @param password - The user-defined password to use for encrypting the account private keys. - * @param options - Optional KeyStoreEncryptOptions object for customizing the encryption process. - * @returns A Promise that resolves to an array of encrypted KeyStoreJson objects. - */ - public encrypt(password: string, options?: KeyStoreEncryptOptions) { - return Promise.all(this.getAccountIndicies().map(index => this.accounts[index].toKeyStoreJson(password, options))); - } - - /** - * Decrypts an array of KeyStoreJson objects using the provided password and adds the decrypted accounts to the wallet. - * If any of the accounts cannot be decrypted, it will throw an error with a message indicating that the password might be wrong. - * - * @param encryptedWallet - Array of KeyStoreJson objects representing the encrypted wallet. - * @param password - The password used to decrypt the encrypted wallet. - * @returns An array of EthAccount instances stored in the wallet after successful decryption. - */ - public async decrypt(encryptedWallet: KeyStoreJson[], password: string) { - const decrypted = await Promise.all(encryptedWallet.map(keystore => decryptFromKeyStoreJson(keystore, password))); - decrypted.forEach(account => { - if (!account) { - throw new Error("Couldn't decrypt accounts. Password wrong?"); - } - - this.add(account); - }); - - return this.accounts; - } - - /** - * Find an available index to safely add a new account in the accounts array. - * The method iterates through the accounts array, incrementing the pointer until it finds an empty position. - * - * @param pointer - Optional starting index for the search. Default value is 0. - * @returns The index of the first empty position in the accounts array. - */ - private findSafeIndex(pointer = 0) { - while (this.accounts[pointer]) { - ++pointer; - } - return pointer; - } -} diff --git a/yarn-project/ethereum.js/src/eth_wallet/index.ts b/yarn-project/ethereum.js/src/eth_wallet/index.ts deleted file mode 100644 index 67f6718f6ad..00000000000 --- a/yarn-project/ethereum.js/src/eth_wallet/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './eth_wallet.js'; diff --git a/yarn-project/ethereum.js/src/hex_string/index.ts b/yarn-project/ethereum.js/src/hex_string/index.ts deleted file mode 100644 index bf58b73419c..00000000000 --- a/yarn-project/ethereum.js/src/hex_string/index.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Convert a buffer to a hex-encoded string with a '0x' prefix. - * The conversion is done by first converting the buffer data to a hexadecimal string - * and then appending the '0x' prefix to it. This function can be used to convert - * binary data into a human-readable format that can be easily manipulated or displayed. - * - * @param b - The buffer object containing the binary data to be converted. - * @returns A hex-encoded string with a '0x' prefix representing the input buffer data. - */ -export function bufferToHex(b: Buffer) { - return '0x' + b.toString('hex'); -} - -/** - * Converts a hex-encoded string to a Buffer object. - * The input 'h' can be prefixed with '0x' or not, and may have an odd or even number of hex characters. - * If the input length is odd, a leading '0' will be added before conversion. - * - * @param h - The hex-encoded string to be converted to a Buffer. - * @returns A Buffer object representing the input hex-encoded string. - */ -export function hexToBuffer(h: string) { - return Buffer.from((h.length % 2 ? '0' : '') + h.replace(/^0x/, ''), 'hex'); -} - -/** - * Convert a given number to its hexadecimal representation as a string. - * The output hex string will be prefixed with '0x'. - * - * @param n - The number to be converted to hex. - * @returns The hexadecimal representation of the input number as a string. - */ -export function numberToHex(n: number) { - return '0x' + n.toString(16); -} - -/** - * Convert a hex-encoded string to its equivalent number representation. - * The input 'h' should be prefixed with '0x' or not, and consist of valid hex characters. - * Note that the result might lose precision for large hex values due to JavaScript's number limitations. - * - * @param h - The hex-encoded string to convert to a number. - * @returns The numeric representation of the input hex string. - */ -export function hexToNumber(h: string) { - return Number(h); -} - -/** - * Converts a BigInt value to its corresponding hexadecimal representation. - * The output string will be prefixed with '0x' to indicate hexadecimal notation. - * - * @param n - The BigInt value to be converted to hexadecimal. - * @returns The hexadecimal representation of the input BigInt value as a string. - */ -export function bigIntToHex(n: bigint) { - return '0x' + n.toString(16); -} - -/** - * Convert a hex-encoded string to a BigInt. - * The input 'h' can be prefixed with '0x' or not, and it should have an even number of hex characters. - * If the input is not valid, this function will throw a RangeError. - * - * @param h - The hex-encoded string representing the input value. - * @returns A BigInt representation of the input hex value. - */ -export function hexToBigInt(h: string) { - return BigInt(h); -} diff --git a/yarn-project/ethereum.js/src/keystore/index.test.ts b/yarn-project/ethereum.js/src/keystore/index.test.ts deleted file mode 100644 index cfcc0251802..00000000000 --- a/yarn-project/ethereum.js/src/keystore/index.test.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { decryptFromKeyStoreJson, encryptToKeyStoreJson, KeyStoreJson } from './index.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; - -const staticTests: { - /** - * A JSON representation of the encrypted key store for an Ethereum account. - */ - json: KeyStoreJson; - /** - * The password used to encrypt and decrypt the keystore file. - */ - password: string; - /** - * The private key associated with the Ethereum address. - */ - priv: string; -}[] = [ - { - json: { - crypto: { - cipher: 'aes-128-ctr', - cipherparams: { - iv: '83dbcc02d8ccb40e466191a123791e0e', - }, - ciphertext: 'd172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c', - kdf: 'scrypt', - kdfparams: { - dklen: 32, - n: 262144, - r: 1, - p: 8, - salt: 'ab0c7876052600dd703518d6fc3fe8984592145b591fc8fb5c6d43190334ba19', - }, - mac: '2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097', - }, - address: '0000000000000000000000000000000000000000', - id: '3198bc9c-6672-5ab3-d995-4942343ae5b6', - version: 3, - }, - password: 'testpassword', - priv: '7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d', - }, - { - json: { - crypto: { - cipher: 'aes-128-ctr', - cipherparams: { - iv: 'e0c41130a323adc1446fc82f724bca2f', - }, - ciphertext: '9517cd5bdbe69076f9bf5057248c6c050141e970efa36ce53692d5d59a3984', - kdf: 'scrypt', - kdfparams: { - dklen: 32, - n: 2, - r: 8, - p: 1, - salt: '711f816911c92d649fb4c84b047915679933555030b3552c1212609b38208c63', - }, - mac: 'd5e116151c6aa71470e67a7d42c9620c75c4d23229847dcc127794f0732b0db5', - }, - address: '0000000000000000000000000000000000000000', - id: 'fecfc4ce-e956-48fd-953b-30f8b52ed66c', - version: 3, - }, - password: 'foo', - priv: 'fa7b3db73dc7dfdf8c5fbdb796d741e4488628c41fc4febd9160a866ba0f35', - }, - { - json: { - crypto: { - cipher: 'aes-128-ctr', - cipherparams: { - iv: '3ca92af36ad7c2cd92454c59cea5ef00', - }, - ciphertext: '108b7d34f3442fc26ab1ab90ca91476ba6bfa8c00975a49ef9051dc675aa', - kdf: 'scrypt', - kdfparams: { - dklen: 32, - n: 2, - r: 8, - p: 1, - salt: 'd0769e608fb86cda848065642a9c6fa046845c928175662b8e356c77f914cd3b', - }, - mac: '75d0e6759f7b3cefa319c3be41680ab6beea7d8328653474bd06706d4cc67420', - }, - address: '0000000000000000000000000000000000000000', - id: 'a37e1559-5955-450d-8075-7b8931b392b2', - version: 3, - }, - password: 'foo', - priv: '81c29e8142bb6a81bef5a92bda7a8328a5c85bb2f9542e76f9b0f94fc018', - }, - { - json: { - crypto: { - cipher: 'aes-128-ctr', - cipherparams: { - iv: '6087dab2f9fdbbfaddc31a909735c1e6', - }, - ciphertext: '5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46', - kdf: 'pbkdf2', - kdfparams: { - c: 262144, - dklen: 32, - prf: 'hmac-sha256', - salt: 'ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd', - }, - mac: '517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2', - }, - address: '0000000000000000000000000000000000000000', - id: '3198bc9c-6672-5ab3-d995-4942343ae5b6', - version: 3, - }, - password: 'testpassword', - priv: '7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d', - }, -]; - -describe('utils', () => { - describe('encryption', () => { - staticTests.forEach(test => { - it('encrypt staticTests and compare to keystore', async () => { - const { n, p, r } = test.json.crypto.kdfparams as any; - const keystore = await encryptToKeyStoreJson(Buffer.from(test.priv, 'hex'), EthAddress.ZERO, test.password, { - id: test.json.id, - iv: Buffer.from(test.json.crypto.cipherparams.iv, 'hex'), - kdf: test.json.crypto.kdf as any, - salt: Buffer.from(test.json.crypto.kdfparams.salt, 'hex'), - n, - p, - r, - }); - expect(keystore).toEqual(test.json); - }, 30000); - }); - - staticTests.forEach(test => { - it('decrypt staticTests and compare to private key', async () => { - const privateKey = await decryptFromKeyStoreJson(test.json, test.password); - expect(privateKey).toEqual(Buffer.from(test.priv, 'hex')); - }, 30000); - }); - }); -}); diff --git a/yarn-project/ethereum.js/src/keystore/index.ts b/yarn-project/ethereum.js/src/keystore/index.ts deleted file mode 100644 index cba36dfc0bb..00000000000 --- a/yarn-project/ethereum.js/src/keystore/index.ts +++ /dev/null @@ -1,280 +0,0 @@ -import aes from 'browserify-aes'; -import { v4 } from 'uuid'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { pbkdf2, scrypt, keccak256, randomBytes } from '../crypto/index.js'; - -/** - * Represents the Scrypt key derivation function parameters. - * Provides a set of properties required for deriving cryptographic keys using the Scrypt algorithm. - */ -interface ScryptKdfParams { - /** - * The desired output key length in bytes. - */ - dklen: number; - /** - * The cost factor for scrypt key derivation function. - */ - n: number; - /** - * The parallelization factor for the scrypt key derivation function. - */ - p: number; - /** - * The CPU/memory cost factor for scrypt key derivation. - */ - r: number; - /** - * A cryptographic element used to enhance password security. - */ - salt: string; -} - -/** - * Represents the PBKDF2 key derivation function parameters. - * Provides the necessary information and options for the PBKDF2 algorithm to derive a cryptographic key from a password. - */ -interface PbKdf2Params { - /** - * The desired length of the derived key in bytes. - */ - dklen: number; - /** - * The iteration count for the PBKDF2 key derivation function. - */ - c: number; - /** - * Pseudorandom function (PRF) used for key derivation. - */ - prf: string; - /** - * A random sequence of bytes used as an additional input for the key derivation function. - */ - salt: string; -} - -/** - * Represents a keystore object in JSON format. - * Contains necessary information required to encrypt and decrypt private keys using a user-provided password. - */ -export interface KeyStoreJson { - /** - * Ethereum address associated with the keystore. - */ - address?: string; - /** - * Cryptographic configurations and encrypted data. - */ - crypto: { - /** - * The encryption algorithm used to secure the private key. - */ - cipher: string; - /** - * The encrypted private key in hexadecimal format. - */ - ciphertext: string; - /** - * Parameters required for cipher initialization. - */ - cipherparams: { - /** - * Initialization vector for the cipher algorithm. - */ - iv: string; - }; - /** - * Key derivation function used for encryption. - */ - kdf: string; - /** - * Key derivation function parameters for password-based key generation. - */ - kdfparams: ScryptKdfParams | PbKdf2Params; - /** - * Message authentication code generated from encrypted data. - */ - mac: string; - }; - /** - * Unique identifier for the keystore object. - */ - id: string; - /** - * The version of the key store format. - */ - version: number; -} - -/** - * Decrypt a private key from a V3 keystore JSON object using the provided password. - * Supports 'scrypt' and 'pbkdf2' key derivation functions. Throws an error if the - * password is incorrect, keystore format is invalid, or unsupported key derivation - * or cipher schemes are used. - * - * @param v3Keystore - The V3 keystore JSON object containing encrypted private key information. - * @param password - The password used for encryption/decryption of the private key. - * @returns A Promise that resolves to the decrypted private key as a Buffer. - */ -export async function decryptFromKeyStoreJson(v3Keystore: KeyStoreJson, password: string): Promise { - if (!password.length) { - throw new Error('No password given.'); - } - - const json = v3Keystore; - - if (json.version !== 3) { - throw new Error('Not a valid V3 wallet'); - } - - let derivedKey: Buffer; - - if (json.crypto.kdf === 'scrypt') { - const { n, r, p, dklen, salt } = json.crypto.kdfparams as ScryptKdfParams; - - derivedKey = await scrypt(Buffer.from(password), Buffer.from(salt, 'hex'), n, r, p, dklen); - } else if (json.crypto.kdf === 'pbkdf2') { - const { prf, c, dklen, salt } = json.crypto.kdfparams as PbKdf2Params; - - if (prf !== 'hmac-sha256') { - throw new Error('Unsupported parameters to PBKDF2'); - } - - derivedKey = await pbkdf2(Buffer.from(password), Buffer.from(salt, 'hex'), c, dklen); - } else { - throw new Error('Unsupported key derivation scheme'); - } - - const ciphertext = Buffer.from(json.crypto.ciphertext, 'hex'); - - const mac = keccak256(Buffer.concat([derivedKey.slice(16, 32), ciphertext])); - if (mac.toString('hex') !== json.crypto.mac) { - throw new Error('Key derivation failed - possibly wrong password'); - } - - const iv = Buffer.from(json.crypto.cipherparams.iv, 'hex'); - const aesKey = derivedKey.slice(0, 16); - - const decipher = aes.createDecipheriv(json.crypto.cipher, aesKey, iv); - return Buffer.concat([decipher.update(ciphertext), decipher.final()]); -} - -/** - * Represents the encryption options for a KeyStore JSON file. - * Provides optional parameters to customize the encryption process, such as cipher algorithm, salt, iv, kdf, and other related attributes. - */ -export interface KeyStoreEncryptOptions { - /** - * Cipher algorithm used for encryption. - */ - cipher?: string; - /** - * A random value used to ensure unique derived encryption keys. - */ - salt?: Buffer; - /** - * Initialization Vector for the AES cipher. - */ - iv?: Buffer; - /** - * Key derivation function used for encryption/decryption. - */ - kdf?: 'scrypt' | 'pbkdf2'; - /** - * Unique identifier for the key store. - */ - id?: string; - /** - * The iteration count for the PBKDF2 key derivation function. - */ - c?: number; - /** - * Length of the derived key in bytes. - */ - dklen?: number; - /** - * The cost factor determining the CPU/memory complexity of the scrypt key derivation function. - */ - n?: number; - /** - * The scrypt memory cost factor. - */ - r?: number; - /** - * The parallelization factor for the scrypt key derivation function. - */ - p?: number; -} - -/** - * Encrypts a private key to a KeyStore JSON object using the specified password and encryption options. - * The resulting KeyStore JSON can be used to securely store the private key, and later decrypt it with the same password. - * Supports 'scrypt' and 'pbkdf2' key derivation functions (KDF) for generating the derived key. - * Uses AES-128-CTR cipher algorithm for encrypting the private key. - * Throws an error if unsupported cipher or KDF is provided. - * - * @param privateKey - The private key Buffer to be encrypted. - * @param address - The EthAddress associated with the privateKey. - * @param password - The password string used for encryption. - * @param options - Optional configuration settings for the encryption process. - * @returns A Promise resolving to a KeyStoreJson object containing the encrypted private key and related information. - */ -export async function encryptToKeyStoreJson( - privateKey: Buffer, - address: EthAddress, - password: string, - options: KeyStoreEncryptOptions = {}, -): Promise { - const cipherAlgo = options.cipher || 'aes-128-ctr'; - const salt = options.salt ? options.salt : randomBytes(32); - const iv = options.iv ? options.iv : randomBytes(16); - const kdf = options.kdf || 'scrypt'; - const id = options.id || v4({ random: randomBytes(16) }); - - if (cipherAlgo !== 'aes-128-ctr') { - throw new Error('Unsupported cipher'); - } - - let derivedKey; - let kdfparams; - - if (kdf === 'pbkdf2') { - const { c = 262144, dklen = 32 } = options; - derivedKey = await pbkdf2(Buffer.from(password), salt, c, dklen); - kdfparams = { c, dklen, prf: 'hmac-sha256', salt: salt.toString('hex') }; - } else if (kdf === 'scrypt') { - const { n = 8192, r = 8, p = 1, dklen = 32 } = options; - - derivedKey = await scrypt(Buffer.from(password), salt, n, r, p, dklen); - kdfparams = { n, r, p, dklen, salt: salt.toString('hex') }; - } else { - throw new Error('Unsupported kdf'); - } - - const aesKey = derivedKey.slice(0, 16); - - const cipher = aes.createCipheriv(cipherAlgo, aesKey, iv); - if (!cipher) { - throw new Error('Unsupported cipher'); - } - - const ciphertext = Buffer.concat([cipher.update(privateKey), cipher.final()]); - - const mac = keccak256(Buffer.concat([derivedKey.slice(16, 32), ciphertext])); - - return { - version: 3, - id, - address: address.toString().toLowerCase().replace('0x', ''), - crypto: { - ciphertext: ciphertext.toString('hex'), - cipherparams: { - iv: iv.toString('hex'), - }, - cipher: 'aes-128-ctr', - kdf, - kdfparams, - mac: mac.toString('hex'), - }, - }; -} diff --git a/yarn-project/ethereum.js/src/log/console.ts b/yarn-project/ethereum.js/src/log/console.ts deleted file mode 100644 index 07854d8cf01..00000000000 --- a/yarn-project/ethereum.js/src/log/console.ts +++ /dev/null @@ -1,21 +0,0 @@ -// eslint-disable-next-line jsdoc/require-jsdoc -export type Logger = (...args: any[]) => void; - -// eslint-disable-next-line jsdoc/require-jsdoc -class ConsoleLogger { - constructor(private prefix: string, private logger: (...args: any[]) => void = console.log) {} - - // eslint-disable-next-line jsdoc/require-jsdoc - public log(...args: any[]) { - this.logger(`${this.prefix}:`, ...args); - } -} - -// eslint-disable-next-line jsdoc/require-jsdoc -export function createLogger(prefix: string): Logger { - if (prefix) { - const logger = new ConsoleLogger(prefix, console.log); - return (...args: any[]) => logger.log(...args); - } - return console.log; -} diff --git a/yarn-project/ethereum.js/src/log/debug.ts b/yarn-project/ethereum.js/src/log/debug.ts deleted file mode 100644 index 8623ac61bee..00000000000 --- a/yarn-project/ethereum.js/src/log/debug.ts +++ /dev/null @@ -1,56 +0,0 @@ -import debug from 'debug'; - -let preLogHook: ((...args: any[]) => void) | undefined; -let postLogHook: ((...args: any[]) => void) | undefined; - -/** - * - */ -function theFunctionThroughWhichAllLogsPass(logger: any, ...args: any[]) { - if (!debug.enabled(logger.namespace)) { - return; - } - if (preLogHook) { - preLogHook(logger.namespace, ...args); - } - logger(...args); - if (postLogHook) { - postLogHook(logger.namespace, ...args); - } -} - -/** - * - */ -export function createDebugLogger(name: string): any { - const logger = debug(name); - return (...args: any[]) => theFunctionThroughWhichAllLogsPass(logger, ...args); -} - -/** - * - */ -export function setPreDebugLogHook(fn: (...args: any[]) => void) { - preLogHook = fn; -} - -/** - * - */ -export function setPostDebugLogHook(fn: (...args: any[]) => void) { - postLogHook = fn; -} - -/** - * - */ -export function enableLogs(str: string) { - debug.enable(str); -} - -/** - * - */ -export function isLogEnabled(str: string) { - return debug.enabled(str); -} diff --git a/yarn-project/ethereum.js/src/log/index.ts b/yarn-project/ethereum.js/src/log/index.ts deleted file mode 100644 index cde309b575b..00000000000 --- a/yarn-project/ethereum.js/src/log/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './console.js'; -export * from './debug.js'; diff --git a/yarn-project/ethereum.js/src/provider/ethereum_provider.ts b/yarn-project/ethereum.js/src/provider/ethereum_provider.ts deleted file mode 100644 index 8249d72b259..00000000000 --- a/yarn-project/ethereum.js/src/provider/ethereum_provider.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * ProviderError is an enumeration representing specific error codes related to Ethereum provider communication. - * These error codes can be used by applications to handle various provider-related events or issues, such as user rejection, unauthorized access, unsupported functionality, and connection problems. - * By standardizing these error codes, it allows for more consistent and robust error handling across different Ethereum providers and applications. - */ -export enum ProviderError { - USER_REJECTED = 4001, - UNAUTHORIZED = 4100, - UNSUPPORTED = 4200, - DISCONNECTED = 4900, - CHAIN_DISCONNECTED = 4901, -} - -/** - * Represents a standardized message format for communication between Ethereum providers and applications. - * Contains type information to identify the purpose of the message and data payload for further processing. - */ -export interface ProviderMessage { - /** - * The type of provider notification event. - */ - readonly type: string; - /** - * Arbitrary data associated with the provider message. - */ - readonly data: unknown; -} - -/** - * Represents the arguments for an Ethereum RPC request. - * Provides the necessary method and optional parameters to form a well-structured request to interact with the Ethereum network. - */ -export interface RequestArguments { - /** - * The JSON-RPC method to be called. - */ - readonly method: string; - /** - * An optional array of method-specific parameters. - */ - readonly params?: any[]; -} - -/** - * Represents an error encountered during Provider's RPC communication. - * It extends the native Error object and includes additional properties - * such as error code and data, providing more context about the occurred error. - */ -export interface ProviderRpcError extends Error { - /** - * Represents a provider-specific message, typically used for communicating events or updates. - */ - message: string; - /** - * The error code representing the type of provider error. - */ - code: ProviderError | number; - /** - * An arbitrary data payload related to the corresponding provider event or error. - */ - data?: unknown; -} - -/** - * Represents the connection information for an Ethereum provider. - * Provides details such as the chain ID to ensure compatibility and connectivity with the desired blockchain network. - */ -export interface ProviderConnectInfo { - /** - * The unique identifier for the connected blockchain network. - */ - readonly chainId: string; -} - -/** - * Type representing the different types of notifications that an EthereumProvider can emit. - * These notifications are related to events such as connection, disconnection, chain and account changes, and incoming messages. - */ -export type EthereumProviderNotifications = 'connect' | 'disconnect' | 'chainChanged' | 'accountsChanged' | 'message'; - -/** - * Interface defining an EIP1193 compatible provider. This is the standard that all future providers should adhere to. - * The Aztec SDK accepts such a provider. If non standard providers wish to be used, wrap them in an adapter first. - * Two adapters are provided, an EthersAdapter for ethers providers, and Web3Adapter, for legacy web3 providers. - */ -export interface EthereumProvider { - request(args: RequestArguments): Promise; - - on(notification: 'connect', listener: (connectInfo: ProviderConnectInfo) => void): this; - on(notification: 'disconnect', listener: (error: ProviderRpcError) => void): this; - on(notification: 'chainChanged', listener: (chainId: string) => void): this; - on(notification: 'accountsChanged', listener: (accounts: string[]) => void): this; - on(notification: 'message', listener: (message: ProviderMessage) => void): this; - - removeListener(notification: 'connect', listener: (connectInfo: ProviderConnectInfo) => void): this; - removeListener(notification: 'disconnect', listener: (error: ProviderRpcError) => void): this; - removeListener(notification: 'chainChanged', listener: (chainId: string) => void): this; - removeListener(notification: 'accountsChanged', listener: (accounts: string[]) => void): this; - removeListener(notification: 'message', listener: (message: ProviderMessage) => void): this; -} diff --git a/yarn-project/ethereum.js/src/provider/index.ts b/yarn-project/ethereum.js/src/provider/index.ts deleted file mode 100644 index 54e6ac3af4e..00000000000 --- a/yarn-project/ethereum.js/src/provider/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './ethereum_provider.js'; -export * from './wallet_provider.js'; -export * from './web3_adapter.js'; -export * from './web3_provider.js'; -export * from './json_rpc_provider.js'; diff --git a/yarn-project/ethereum.js/src/provider/json_rpc_provider.ts b/yarn-project/ethereum.js/src/provider/json_rpc_provider.ts deleted file mode 100644 index 5badc4faf5b..00000000000 --- a/yarn-project/ethereum.js/src/provider/json_rpc_provider.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { EthereumProvider, RequestArguments } from './ethereum_provider.js'; -import { retry } from '../retry/index.js'; -import { createDebugLogger } from '../log/index.js'; - -const log = createDebugLogger('json_rpc_provider'); - -/** - * The JsonRpcProvider class implements EthereumProvider to facilitate communication with Ethereum nodes. - * It provides a request/response API using JSON-RPC 2.0 protocol, handling requests for blockchain data and network state. - * This class does not support event subscriptions and will throw errors if event-related methods are called. - * Uses fetch to perform HTTP POST requests and can be configured to automatically retry failed requests. - */ -export class JsonRpcProvider implements EthereumProvider { - private id = 0; - - constructor(private host: string, private netMustSucceed = true) {} - - /** - * Sends a JSON-RPC request to the Ethereum provider with the given method and parameters. - * The 'method' should be a valid Ethereum JSON-RPC method, and 'params' should be an array of inputs required for that method. - * Returns a promise which resolves to the result of the request, or rejects with an error if the request fails. - * - * @param requestArguments - An object containing 'method' and 'params' properties. - * @param method - The Ethereum JSON-RPC method to call. - * @param params - The parameters required for the called method. - * @returns A promise resolving to the result of the request, or rejecting with an error if the request fails. - */ - public async request({ method, params }: RequestArguments): Promise { - const body = { - jsonrpc: '2.0', - id: this.id++, - method, - params, - }; - log(`->`, body); - const res = await this.fetch(body); - log(`<-`, res); - if (res.error) { - throw res.error; - } - return res.result; - } - - /** - * Registers an event listener for the specified event on the JsonRpcProvider instance. - * This method is not supported in the current implementation and will throw an error when called. - * - * @throws An error indicating that events are not supported by the JsonRpcProvider. - * @returns The current JsonRpcProvider instance. - */ - on(): this { - throw new Error('Events not supported.'); - } - - /** - * Remove an event listener from the Ethereum provider. This method is not supported by JsonRpcProvider - * and will throw an error when called. To use event handling, consider using a different provider implementation. - * - * @throws Throws an error indicating that events are not supported by this provider. - * @returns Returns the current instance of the class for chaining purposes. - */ - removeListener(): this { - throw new Error('Events not supported.'); - } - - /** - * Send a JSON-RPC request to the Ethereum node and return the parsed response. - * The 'body' parameter contains the JSON-RPC request payload, including method, id, and params. - * If 'netMustSucceed' is true, the function will be retried until the request succeeds. - * Throws an error if the response status is not ok or if the response body cannot be parsed as JSON. - * - * @param body - The JSON-RPC request payload containing the method, id, and params. - * @returns A Promise resolving to the parsed JSON-RPC response object. - */ - private async fetch(body: any) { - const fn = async () => { - const resp = await fetch(this.host, { - method: 'POST', - body: JSON.stringify(body), - headers: { 'content-type': 'application/json' }, - }); - - if (!resp.ok) { - throw new Error(resp.statusText); - } - - const text = await resp.text(); - try { - return JSON.parse(text); - } catch (err) { - throw new Error(`Failed to parse body as JSON: ${text}`); - } - }; - - if (this.netMustSucceed) { - return await retry(fn, 'JsonRpcProvider request'); - } - - return await fn(); - } -} diff --git a/yarn-project/ethereum.js/src/provider/wallet_provider.ts b/yarn-project/ethereum.js/src/provider/wallet_provider.ts deleted file mode 100644 index dda86f791bc..00000000000 --- a/yarn-project/ethereum.js/src/provider/wallet_provider.ts +++ /dev/null @@ -1,399 +0,0 @@ -import { - EthereumProvider, - ProviderConnectInfo, - ProviderMessage, - ProviderRpcError, - RequestArguments, -} from './ethereum_provider.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthWallet } from '../eth_wallet/index.js'; -import { readFile } from 'fs/promises'; -import { JsonRpcProvider } from './json_rpc_provider.js'; -import { EthAccount } from '../eth_account/index.js'; -import { EthTransaction, populateTransaction, signTransaction } from '../eth_transaction/index.js'; -import { EthereumRpc } from '../eth_rpc/index.js'; -import { getTypedDataHash } from '../eth_typed_data/index.js'; - -/** - * Given an EIP1193 provider, wraps it, and provides the ability to add local accounts. - */ -export class WalletProvider implements EthereumProvider { - constructor(private provider: EthereumProvider, private wallet = new EthWallet()) {} - - /** - * Create a WalletProvider instance using the given Ethereum host and an optional EthWallet instance. - * This function initializes a JsonRpcProvider with the provided Ethereum host and then - * creates a WalletProvider using the initialized JsonRpcProvider and the provided wallet. - * If no wallet is provided, a new EthWallet instance will be created. - * - * @param ethereumHost - The Ethereum host URL used to initialize the JsonRpcProvider. - * @param wallet - (Optional) An EthWallet instance to be used as the local wallet. - * @returns A WalletProvider instance with the initialized JsonRpcProvider and the given wallet. - */ - public static fromHost(ethereumHost: string, wallet = new EthWallet()) { - const provider = new JsonRpcProvider(ethereumHost); - return new WalletProvider(provider, wallet); - } - - /** - * Adds an account to the wallet using a private key. - * The input 'privateKey' should be a Buffer containing the private key bytes of the account. - * Returns the corresponding EthAddress of the added account. - * - * @param privateKey - The Buffer containing the private key bytes of the account. - * @returns An EthAddress instance. - */ - public addAccount(privateKey: Buffer) { - return this.wallet.add(privateKey).address; - } - - /** - * Add multiple accounts to the wallet using a mnemonic phrase and the specified number of accounts. - * The accounts will be generated based on the provided BIP32 account index and indexed from 0 to (num-1). - * This function is useful for importing a set of accounts that were derived from a single mnemonic. - * - * @param mnemonic - The mnemonic phrase used to generate the accounts. - * @param num - The number of accounts to add to the wallet. - * @param bip32Account - The BIP32 account index to derive the accounts from, default is 0. - */ - public addAccountsFromMnemonic(mnemonic: string, num: number, bip32Account = 0) { - for (let i = 0; i < num; ++i) { - this.addAccountFromMnemonicAndPath(mnemonic, `m/44'/60'/${bip32Account}'/0/${i}`); - } - } - - /** - * Adds an account to the wallet using a mnemonic and a specified BIP32 derivation path. - * The generated account is derived from the given mnemonic using the provided path, - * following the BIP32 hierarchical deterministic key generation standard. - * Returns the Ethereum address of the added account. - * - * @param mnemonic - The seed phrase used to generate the private key for the account. - * @param path - The BIP32 derivation path used to derive the account from the mnemonic. - * @returns The Ethereum address of the added account. - */ - public addAccountFromMnemonicAndPath(mnemonic: string, path: string) { - return this.wallet.add(EthAccount.fromMnemonicAndPath(mnemonic, path)).address; - } - - /** - * Adds an account to the wallet provider by loading a keystore file and decrypting the private key using the provided password. - * The keystore file should follow the JSON format defined in Ethereum Improvement Proposal 55 (EIP-55). - * Throws an error if the input file is invalid or decryption fails due to incorrect password. - * - * @param file - The path to the keystore file containing the encrypted private key. - * @param password - The password used for decryption of the keystore file (default: ''). - * @returns An EthAddress instance representing the address of the added account. - */ - public async addAccountFromKeystore(file: string, password = '') { - const json = JSON.parse(await readFile(file, { encoding: 'ascii' })); - return this.wallet.add(await EthAccount.fromKeyStoreJson(json, password)).address; - } - - /** - * Retrieve all available accounts in the wallet. - * This function returns an array of EthAddress instances corresponding to each account in the wallet. - * If no accounts have been added, it returns an empty array. - * - * @returns An array of EthAddress instances representing the accounts in the wallet. - */ - public getAccounts() { - return this.wallet.getAccountAddresses(); - } - - /** - * Retrieve the EthAddress instance of an account at a specific index within the wallet. - * Returns `undefined` if the provided index is out of range or does not correspond to an existing account. - * - * @param account - The index (integer) of the account to be fetched from the wallet. - * @returns The EthAddress instance corresponding to the account, or `undefined` if not found. - */ - public getAccount(account: number) { - return this.wallet.getAccount(account)?.address; - } - - /** - * Retrieve the private key associated with the specified account index. - * Returns the private key as a Buffer if the account exists in the wallet, otherwise returns undefined. - * - * @param account - The index of the account whose private key is to be retrieved. - * @returns The private key as a Buffer, or undefined if the account does not exist. - */ - public getPrivateKey(account: number) { - return this.wallet.getAccount(account)?.privateKey; - } - - /** - * Retrieves the private key associated with the given Ethereum address. - * Returns the private key as a Buffer if found within the wallet, or undefined otherwise. - * - * @param account - The EthAddress instance representing the Ethereum address to lookup. - * @returns The private key as a Buffer or undefined if not found in the wallet. - */ - public getPrivateKeyForAddress(account: EthAddress) { - return this.wallet.getAccount(account)?.privateKey; - } - - /** - * Handles the processing of various Ethereum JSON-RPC requests, delegating them to the appropriate internal methods. - * If a local account is available for signing transactions or messages, it will be used, otherwise the request - * is forwarded to the underlying provider for further processing. This allows adding and managing local accounts - * while still interacting with external providers such as remote nodes or browser-based wallets like MetaMask. - * - * @param args - The RequestArguments object containing the method to be called and any necessary parameters. - * @returns A Promise resolving to the result of the requested operation or an error if the operation fails. - */ - public async request(args: RequestArguments): Promise { - switch (args.method) { - case 'eth_accounts': - return this.wallet.length ? this.getAccounts().map(a => a.toString()) : await this.provider.request(args); - case 'eth_sign': - return await this.ethSign(args); - case 'personal_sign': - return await this.personalSign(args); - case 'eth_signTypedData_v4': - return this.signTypedData(args); - case 'eth_signTransaction': - return this.ethSignTransaction(args); - case 'eth_sendTransaction': - return this.ethSendTransaction(args); - default: { - return await this.provider.request(args); - } - } - } - - /** - * The message will be prefixed and hashed, and the hash is signed. - * @returns Promise. - */ - private async ethSign(args: RequestArguments) { - const [from, message] = args.params!; - const account = this.wallet.getAccount(EthAddress.fromString(from)); - if (account) { - const signature = account.signMessage(Buffer.from(message.slice(2), 'hex')); - return signature.toString(); - } - return await this.provider.request(args); - } - - /** - * Personal_sign is the same as eth_sign but with args reversed. - * This is favoured as it has better client support r.e. Displaying the message to the user before signing. - * @returns Promise | string. - */ - private async personalSign(args: RequestArguments) { - const [message, from] = args.params!; - const account = this.wallet.getAccount(EthAddress.fromString(from)); - if (account) { - const signature = account.signMessage(Buffer.from(message.slice(2), 'hex')); - return signature.toString(); - } - return await this.provider.request(args); - } - - /** - * Sign the provided typed data using an account's private key. - * This method is used for EIP-712 compliant signing of structured data. - * The signed digest can be used to verify the signer's identity and authenticity of the data. - * - * @param args - RequestArguments object containing the method name and input parameters. - * @returns A Promise that resolves to a string representing the signature of the typed data. - * @throws An error if the specified account is not found in the wallet or if the request to the provider fails. - */ - private async signTypedData(args: RequestArguments) { - const [from, data] = args.params!; - const account = this.wallet.getAccount(EthAddress.fromString(from)); - if (account) { - const digest = getTypedDataHash(typeof data === 'string' ? JSON.parse(data) : data); - return account.signDigest(digest).toString(); - } - return await this.provider.request(args); - } - - /** - * Given a tx in Eth Json Rpc format, create an EthTransaction, populate any missing fields, and sign. - * @returns Buffer. - */ - private async signTxLocally(tx: any, account: EthAccount) { - const { chainId, to, gas, maxFeePerGas, maxPriorityFeePerGas, value, data, nonce } = tx; - - const txReq: Partial = { - chainId: chainId !== undefined ? Number(chainId) : undefined, - to: to !== undefined ? EthAddress.fromString(to) : undefined, - gas: gas !== undefined ? Number(gas) : undefined, - maxFeePerGas: maxFeePerGas !== undefined ? BigInt(maxFeePerGas) : undefined, - maxPriorityFeePerGas: maxPriorityFeePerGas !== undefined ? BigInt(maxPriorityFeePerGas) : undefined, - value: value !== undefined ? BigInt(value) : undefined, - data: data !== undefined ? Buffer.from(data.slice(2), 'hex') : undefined, - nonce: nonce !== undefined ? Number(nonce) : undefined, - }; - const rpc = new EthereumRpc(this.provider); - const populatedTx = await populateTransaction(txReq, account.privateKey, rpc); - - return signTransaction(populatedTx, account.privateKey).rawTransaction; - } - - /** - * Sign a transaction using the local account associated with the 'from' address in the given transaction object. - * If the 'from' address is not managed by the WalletProvider, the transaction will be forwarded to the underlying provider. - * The input transaction should be in Ethereum JSON-RPC format. - * - * @param args - A RequestArguments object containing the transaction details. - * @returns A Promise that resolves to the signed transaction as a hex-encoded string. - */ - private async ethSignTransaction(args: RequestArguments) { - const tx = args.params![0]; - const account = this.wallet.getAccount(EthAddress.fromString(tx.from)); - if (account) { - const result = await this.signTxLocally(tx, account); - return '0x' + result.toString('hex'); - } - return await this.provider.request(args); - } - - /** - * Process and send a given Ethereum transaction using the EthAccount instance associated with the 'from' address. - * If the account is found in the local wallet, it will sign the transaction locally and send the raw transaction - * to the Ethereum provider. If the account is not found in the local wallet, it will forward the request to the provider. - * - * @param args - The RequestArguments object containing the Ethereum transaction details. - * @returns A promise that resolves to the transaction hash of the submitted transaction. - */ - private async ethSendTransaction(args: RequestArguments) { - const tx = args.params![0]; - const account = this.wallet.getAccount(EthAddress.fromString(tx.from)); - if (account) { - const result = await this.signTxLocally(tx, account); - return this.provider.request({ - method: 'eth_sendRawTransaction', - params: ['0x' + result.toString('hex')], - }); - } - return this.provider.request(args); - } - - /** - * Attaches a callback function to the specified event type on the Ethereum provider. - * The listener will be invoked whenever the event occurs for the given notification. - * Common events include 'connect', 'disconnect', 'chainChanged', 'accountsChanged', and 'message'. - * - * @param notification - The event type to listen for. - * @param listener - The callback function to be invoked when the event occurs. - * @returns The WalletProvider instance, allowing for method chaining. - */ - on(notification: 'connect', listener: (connectInfo: ProviderConnectInfo) => void): this; - /** - * Registers an event listener for the specified notification type. - * The listener will be invoked with the relevant data when the provider emits that notification. - * - * @param notification - The notification type to subscribe to, such as 'connect', 'disconnect', 'chainChanged', 'accountsChanged', or 'message'. - * @param listener - The callback function to be invoked when the provider emits the specified notification. - * @returns This WalletProvider instance, allowing for chained method calls. - */ - on(notification: 'disconnect', listener: (error: ProviderRpcError) => void): this; - /** - * Registers an event listener for the specified notification type. - * The listener function will be invoked when the corresponding event is emitted by the provider. - * This allows for handling of various events such as connection changes, account changes, etc. - * - * @param notification - The type of event to listen for ('connect', 'disconnect', 'chainChanged', 'accountsChanged', or 'message'). - * @param listener - The callback function to be invoked when the specified event occurs. - * @returns The WalletProvider instance for chaining purposes. - */ - on(notification: 'chainChanged', listener: (chainId: string) => void): this; - /** - * Add an event listener for the specified notification type. - * The listener function will be called whenever an event of the specified type is emitted from the provider. - * Supported notification types are: 'connect', 'disconnect', 'chainChanged', 'accountsChanged', and 'message'. - * - * @param notification - The type of event to listen for. - * @param listener - The function to be called when the event occurs. - * @returns The WalletProvider instance, allowing chained calls. - */ - on(notification: 'accountsChanged', listener: (accounts: string[]) => void): this; - /** - * Add an event listener for the specified notification on this WalletProvider instance. - * The listener will be called with relevant information when the event occurs. - * Supported notifications include 'connect', 'disconnect', 'chainChanged', 'accountsChanged', and 'message'. - * - * @param notification - The type of event to listen for. - * @param listener - The function that will be called when the event occurs, with arguments based on the event type. - * @returns This WalletProvider instance, allowing for method chaining. - */ - on(notification: 'message', listener: (message: ProviderMessage) => void): this; - /** - * Registers a listener function to be called when the specified event occurs. - * The available events are 'connect', 'disconnect', 'chainChanged', 'accountsChanged', and 'message'. - * The listener function should take the appropriate argument based on the event type. - * - * @param notification - The event type to listen for. One of: 'connect', 'disconnect', 'chainChanged', 'accountsChanged', or 'message'. - * @param listener - The function to be called when the specified event occurs, taking the appropriate argument based on the event type. - * @returns The WalletProvider instance, allowing for method chaining. - */ - on(notification: any, listener: any) { - return this.provider.on(notification, listener); - } - - /** - * Removes an event listener for the specified notification type. - * The listener should be a function previously added using the `on` method. - * If the listener is not found, this method does nothing. - * - * @param notification - The notification type to remove the listener from. - * @param listener - The event listener function to remove. - * @returns The WalletProvider instance. - */ - removeListener(notification: 'connect', listener: (connectInfo: ProviderConnectInfo) => void): this; - /** - * Removes a specified listener function from the given event notification. - * The listener function will no longer be triggered when the specified event occurs. - * - * @param notification - The event notification type for which the listener needs to be removed. - * @param listener - The listener function that was previously added and needs to be removed. - * @returns The modified WalletProvider instance. - */ - removeListener(notification: 'disconnect', listener: (error: ProviderRpcError) => void): this; - /** - * Removes a previously added listener function for the specified event notification. - * The function will no longer be invoked when the specified event is emitted. - * - * @param notification - The event notification from which to remove the listener. - * @param listener - The listener function that was previously added and now needs to be removed. - * @returns The WalletProvider instance for chaining. - */ - removeListener(notification: 'chainChanged', listener: (chainId: string) => void): this; - /** - * Removes a previously added listener function for the specified notification event. - * The listener function will no longer be called when the corresponding event occurs. - * This helps to prevent unwanted side-effects, memory leaks and improve performance - * by unregistering listeners that are no longer needed. - * - * @param notification - The event name for which the listener should be removed. - * @param listener - The callback function that was previously added as a listener for the specified event. - * @returns The WalletProvider instance, allowing for method chaining. - */ - removeListener(notification: 'accountsChanged', listener: (accounts: string[]) => void): this; - /** - * Removes a previously added event listener for the specified notification type. - * The listener function should be the same as the one used when calling 'on' to add the listener. - * If the listener is not found, this method will have no effect. - * - * @param notification - The notification type for which to remove the listener. - * @param listener - The listener function that was previously added. - * @returns The WalletProvider instance with the listener removed. - */ - removeListener(notification: 'message', listener: (message: ProviderMessage) => void): this; - /** - * Removes a specified listener function from the given event notification. - * Listeners are functions that have been previously added via the `on` method. - * If the listener is successfully removed, it will no longer be called when the corresponding event is triggered. - * - * @param notification - The event notification type from which the listener should be removed. - * @param listener - The listener function to be removed from the specified event notification. - * @returns The WalletProvider instance with the updated set of listeners. - */ - removeListener(notification: any, listener: any) { - return this.provider.removeListener(notification, listener); - } -} diff --git a/yarn-project/ethereum.js/src/provider/web3_adapter.ts b/yarn-project/ethereum.js/src/provider/web3_adapter.ts deleted file mode 100644 index e84fb29d411..00000000000 --- a/yarn-project/ethereum.js/src/provider/web3_adapter.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { EthereumProvider, RequestArguments } from './ethereum_provider.js'; -import { Web3Provider } from './web3_provider.js'; - -/** - * Adapts a legacy web3 provider into an EIP1193 compatible provider for injecting into the sdk. - */ -export class Web3Adapter implements EthereumProvider { - private id = 0; - - constructor(private provider: Web3Provider) {} - - /** - * Sends a JSON-RPC request to the legacy web3 provider and returns the result in a Promise. - * The function constructs a payload object using the method and params provided in the RequestArguments, - * and sends it to the provider for execution. It handles errors and responses accordingly, and - * resolves or rejects the Promise based on the response from the provider. - * - * @param args - A RequestArguments object containing the JSON-RPC method and parameters. - * @returns A Promise resolving with the result of the executed request or rejecting with an error. - */ - public request(args: RequestArguments): Promise { - return new Promise((resolve, reject) => { - const payload = { - jsonrpc: '2.0', - id: this.id++, - method: args.method, - params: args.params || [], - }; - - this.provider.send(payload, (err, response) => { - if (err) { - return reject(err); - } - if (!response) { - return reject(new Error('No response.')); - } - resolve(response.result); - }); - }); - } - - /** - * Adds an event listener for the specified event on the Web3Adapter instance. - * Please note that this method is not implemented and will throw an error when called, as events are not supported. - * - * @throws Will throw an error if the method is called, because events are not supported in this implementation. - * @returns Returns the Web3Adapter instance for chaining purposes (if events were supported). - */ - on(): this { - throw new Error('Events not supported.'); - } - - /** - * Remove an event listener from the Ethereum provider. - * This method is not supported for the Web3Adapter class, and calling it will result in an error being thrown. - * - * @throws - An error indicating that event removal is not supported. - * @returns - The current instance of the Web3Adapter class. - */ - removeListener(): this { - throw new Error('Events not supported.'); - } -} diff --git a/yarn-project/ethereum.js/src/provider/web3_provider.ts b/yarn-project/ethereum.js/src/provider/web3_provider.ts deleted file mode 100644 index 9565cfab9fa..00000000000 --- a/yarn-project/ethereum.js/src/provider/web3_provider.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Represents the structure of a JSON-RPC request. - * Provides a standardized format for remote procedure calls using the JSON data format. - */ -interface JsonRpcRequest { - /** - * A JSON-RPC version identifier. - */ - jsonrpc: string; - /** - * The name of the JSON-RPC method to call. - */ - method: string; - /** - * An array of method-specific parameters. - */ - params: any[]; - /** - * Unique identifier for the JSON-RPC request. - */ - id: number; -} - -/** - * Represents a JSON-RPC response object. - * Provides structured data for handling the result or error from a JSON-RPC call. - * Used commonly in web3 applications to interact with blockchain networks and services. - */ -interface JsonRpcResponse { - /** - * JSON-RPC version used for communication. - */ - jsonrpc: string; - /** - * A unique identifier for the JSON-RPC request. - */ - id: number; - /** - * The outcome of the invoked method. - */ - result?: any; - /** - * Represents error details returned in JSON-RPC response. - */ - error?: { - /** - * The numerical error code representing the type of error occurred. - */ - code: number; - /** - * The name of the method to be called on the remote server. - */ - message: string; - /** - * Additional information related to the error. - */ - data?: any; - }; -} - -/** - * Type for handling the results and errors of JSON-RPC based Web3 provider send operations. - */ -type Callback = (err?: Error, result?: JsonRpcResponse) => void; - -/** - * Represents a Web3 provider interface for JSON-RPC communication. - * Provides an abstract method for sending requests to interact with Ethereum blockchain nodes. - */ -export interface Web3Provider { - send(payload: JsonRpcRequest, callback: Callback): any; -} diff --git a/yarn-project/ethereum.js/src/retry/index.ts b/yarn-project/ethereum.js/src/retry/index.ts deleted file mode 100644 index df7ef669571..00000000000 --- a/yarn-project/ethereum.js/src/retry/index.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { sleep } from '../sleep/index.js'; -import { Timer } from '../timer/index.js'; - -/** - * - */ -export function* backoffGenerator() { - const v = [1, 1, 1, 2, 4, 8, 16, 32, 64]; - let i = 0; - while (true) { - yield v[Math.min(i++, v.length - 1)]; - } -} - -/** - * - */ -export async function retry(fn: () => Promise, name = 'Operation', backoff = backoffGenerator()) { - while (true) { - try { - return await fn(); - } catch (err: any) { - const s = backoff.next().value; - if (s === undefined) { - throw err; - } - console.log(`${name} failed. Will retry in ${s}s...`); - console.log(err); - await sleep(s * 1000); - continue; - } - } -} - -// Call `fn` repeatedly until it returns true or timeout. -// Both `interval` and `timeout` are seconds. -// Will never timeout if the value is 0. -/** - * - */ -export async function retryUntil(fn: () => Promise, name = '', timeout = 0, interval = 1) { - const timer = new Timer(); - while (true) { - const result = await fn(); - if (result) { - return result; - } - - await sleep(interval * 1000); - - if (timeout && timer.s() > timeout) { - throw new Error(name ? `Timeout awaiting ${name}` : 'Timeout'); - } - } -} diff --git a/yarn-project/ethereum.js/src/serialize/deserializer.ts b/yarn-project/ethereum.js/src/serialize/deserializer.ts deleted file mode 100644 index 42479a6cad0..00000000000 --- a/yarn-project/ethereum.js/src/serialize/deserializer.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { - deserializeArrayFromVector, - deserializeBigInt, - deserializeBool, - deserializeBufferFromVector, - deserializeInt32, - deserializeUInt32, -} from './free_funcs.js'; - -// eslint-disable-next-line jsdoc/require-jsdoc -export type DeserializeFn = ( - buf: Buffer, - offset: number, -) => { - // eslint-disable-next-line jsdoc/require-jsdoc - elem: T; - // eslint-disable-next-line jsdoc/require-jsdoc - adv: number; -}; - -// eslint-disable-next-line jsdoc/require-jsdoc -export class Deserializer { - constructor(private buf: Buffer, private offset = 0) {} - - // eslint-disable-next-line jsdoc/require-jsdoc - public bool() { - return this.exec(deserializeBool) ? true : false; - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public uInt32() { - return this.exec(deserializeUInt32); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public int32() { - return this.exec(deserializeInt32); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public bigInt(width = 32) { - return this.exec((buf: Buffer, offset: number) => deserializeBigInt(buf, offset, width)); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public vector() { - return this.exec(deserializeBufferFromVector); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public buffer(width: number) { - const buf = this.buf.slice(this.offset, this.offset + width); - this.offset += width; - return buf; - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public string() { - return this.vector().toString(); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public date() { - return new Date(Number(this.bigInt(8))); - } - // eslint-disable-next-line jsdoc/require-jsdoc - public deserializeArray(fn: DeserializeFn) { - return this.exec((buf: Buffer, offset: number) => deserializeArrayFromVector(fn, buf, offset)); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public exec(fn: DeserializeFn): T { - const { elem, adv } = fn(this.buf, this.offset); - this.offset += adv; - return elem; - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public getOffset() { - return this.offset; - } -} diff --git a/yarn-project/ethereum.js/src/serialize/free_funcs.ts b/yarn-project/ethereum.js/src/serialize/free_funcs.ts deleted file mode 100644 index 12a3298b5c9..00000000000 --- a/yarn-project/ethereum.js/src/serialize/free_funcs.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; - -// For serializing bool. -/** - * - */ -export function boolToByte(b: boolean) { - const buf = Buffer.alloc(1); - buf.writeUInt8(b ? 1 : 0); - return buf; -} - -// For serializing numbers to 32 bit little-endian form. -/** - * - */ -export function numToUInt32LE(n: number, bufferSize = 4) { - const buf = Buffer.alloc(bufferSize); - buf.writeUInt32LE(n, bufferSize - 4); - return buf; -} - -// For serializing numbers to 32 bit big-endian form. -/** - * - */ -export function numToUInt32BE(n: number, bufferSize = 4) { - const buf = Buffer.alloc(bufferSize); - buf.writeUInt32BE(n, bufferSize - 4); - return buf; -} - -// For serializing signed numbers to 32 bit big-endian form. -/** - * - */ -export function numToInt32BE(n: number, bufferSize = 4) { - const buf = Buffer.alloc(bufferSize); - buf.writeInt32BE(n, bufferSize - 4); - return buf; -} - -// For serializing numbers to 32 bit big-endian form. -/** - * - */ -export function numToUInt8(n: number) { - const bufferSize = 1; - const buf = Buffer.alloc(bufferSize); - buf.writeUInt8(n, 0); - return buf; -} - -// For serializing a buffer as a vector. -/** - * - */ -export function serializeBufferToVector(buf: Buffer) { - const lengthBuf = Buffer.alloc(4); - lengthBuf.writeUInt32BE(buf.length, 0); - return Buffer.concat([lengthBuf, buf]); -} - -/** - * Serialize a BigInt value into a buffer with specified width (number of bytes). - * The output buffer represents the big-endian encoding of the input BigInt value. - * If the width is not provided, it defaults to 32 bytes. - * - * @param n - The BigInt value to be serialized. - * @param width - The number of bytes for the output buffer (optional, default: 32). - * @returns A Buffer containing the serialized big-endian representation of the BigInt value. - */ -export function serializeBigInt(n: bigint, width = 32) { - return toBufferBE(n, width); -} - -/** - * Deserialize a bigint from a buffer with a specified offset and width. - * The function extracts a slice of the buffer based on the given offset and width, - * and converts that slice into a bigint value. - * - * @param buf - The input buffer containing the serialized bigint data. - * @param offset - The starting index within the buffer to deserialize from. Default is 0. - * @param width - The number of bytes to use for deserialization. Default is 32. - * @returns An object containing the deserialized bigint ('elem') and the advancement ('adv') in the buffer. - */ -export function deserializeBigInt(buf: Buffer, offset = 0, width = 32) { - return { elem: toBigIntBE(buf.slice(offset, offset + width)), adv: width }; -} - -/** - * Serialize a given JavaScript Date object into an 8-byte big-endian BigInt buffer. - * The function first converts the date to its corresponding UNIX timestamp (in milliseconds), - * then creates a BigInt from the timestamp and serializes it to an 8-byte buffer using - * big-endian format. This buffer can be useful for interoperability with other systems and - * data storage. - * - * @param date - The JavaScript Date object to be serialized. - * @returns A Buffer containing the serialized date as an 8-byte big-endian BigInt. - */ -export function serializeDate(date: Date) { - return serializeBigInt(BigInt(date.getTime()), 8); -} - -/** - * Deserialize a Buffer from a vector, given its starting offset. - * This function reads the length of the buffer from the vector and extracts the corresponding bytes. - * It returns an object containing the deserialized Buffer element and the total number of bytes advanced (including the length). - * - * @param vector - The input vector Buffer from which the buffer will be deserialized. - * @param offset - The starting offset in the input vector where the buffer begins. Default is 0. - * @returns An object with the deserialized Buffer element as 'elem' and the total number of bytes advanced as 'adv'. - */ -export function deserializeBufferFromVector(vector: Buffer, offset = 0) { - const length = vector.readUInt32BE(offset); - const adv = 4 + length; - return { elem: vector.slice(offset + 4, offset + adv), adv }; -} - -/** - * Deserialize a boolean value from a buffer at the specified offset. - * The function reads one byte from the buffer and returns an object with the deserialized boolean value and the number of bytes advanced (adv). - * - * @param buf - The buffer containing the serialized boolean value. - * @param offset - The starting position in the buffer to read the boolean value. Default is 0. - * @returns An object with the deserialized boolean value (elem) and the number of bytes advanced (adv). - */ -export function deserializeBool(buf: Buffer, offset = 0) { - const adv = 1; - return { elem: buf.readUInt8(offset), adv }; -} - -/** - * Deserialize a 32-bit unsigned integer from a Buffer. - * Extracts a 32-bit unsigned integer from the provided Buffer at the specified offset and - * returns the deserialized value along with the number of bytes advanced in the buffer. - * - * @param buf - The source Buffer to deserialize the unsigned integer from. - * @param offset - The starting position within the Buffer to read the unsigned integer. - * @returns An object containing the deserialized 32-bit unsigned integer (elem) and number of bytes advanced (adv). - */ -export function deserializeUInt32(buf: Buffer, offset = 0) { - const adv = 4; - return { elem: buf.readUInt32BE(offset), adv }; -} - -/** - * Deserialize a signed 32-bit integer from the given buffer at the specified offset. - * Returns the deserialized integer value along with the number of bytes advanced (4) as an object. - * - * @param buf - The input buffer containing the binary data to deserialize. - * @param offset - The optional starting position (index) in the buffer for deserialization. Default is 0. - * @returns An object containing the deserialized signed 32-bit integer ('elem') and the number of bytes advanced ('adv', always 4). - */ -export function deserializeInt32(buf: Buffer, offset = 0) { - const adv = 4; - return { elem: buf.readInt32BE(offset), adv }; -} - -/** - * Deserialize a field from a given buffer starting at the specified offset. - * This function reads a fixed size (32 bytes) slice of the buffer and returns an object containing - * the extracted field as a Buffer and the number of bytes advanced in the input buffer. - * - * @param buf - The input buffer containing the serialized data. - * @param offset - The starting position in the buffer to begin deserialization (default is 0). - * @returns An object containing the extracted field as a Buffer and the number of bytes advanced in the input buffer. - */ -export function deserializeField(buf: Buffer, offset = 0) { - const adv = 32; - return { elem: buf.slice(offset, offset + adv), adv }; -} - -// For serializing an array of fixed length elements. -/** - * - */ -export function serializeBufferArrayToVector(arr: Buffer[]) { - const lengthBuf = Buffer.alloc(4); - lengthBuf.writeUInt32BE(arr.length, 0); - return Buffer.concat([lengthBuf, ...arr]); -} - -/** - * Deserialize an array of fixed length elements from a buffer, given a deserialization function. - * Reads the size of the array from the buffer at the provided offset, then iterates through the - * elements and applies the provided deserialization function on each element. Returns an array - * of the deserialized elements and the total bytes consumed in the process. - * - * @typeparam T - The type of the deserialized elements. - * @param deserialize - The deserialization function to be applied on each element of the array. - * @param vector - The source buffer containing the serialized data. - * @param offset - The starting position in the buffer to begin deserialization (optional, default is 0). - * @returns An object containing the deserialized array of elements (elem) and the total bytes consumed in the process (adv). - */ -export function deserializeArrayFromVector( - deserialize: ( - buf: Buffer, - offset: number, - ) => { - /** - * The deserialized element from the buffer. - */ - elem: T; - /** - * The number of bytes advanced in the buffer during deserialization. - */ - adv: number; - }, - vector: Buffer, - offset = 0, -) { - let pos = offset; - const size = vector.readUInt32BE(pos); - pos += 4; - const arr = new Array(size); - for (let i = 0; i < size; ++i) { - const { elem, adv } = deserialize(vector, pos); - pos += adv; - arr[i] = elem; - } - return { elem: arr, adv: pos - offset }; -} diff --git a/yarn-project/ethereum.js/src/serialize/index.ts b/yarn-project/ethereum.js/src/serialize/index.ts deleted file mode 100644 index fed2e36332b..00000000000 --- a/yarn-project/ethereum.js/src/serialize/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './free_funcs.js'; -export * from './deserializer.js'; -export * from './serializer.js'; diff --git a/yarn-project/ethereum.js/src/serialize/serialize.test.ts b/yarn-project/ethereum.js/src/serialize/serialize.test.ts deleted file mode 100644 index 60c30af772c..00000000000 --- a/yarn-project/ethereum.js/src/serialize/serialize.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { randomBytes } from '../crypto/index.js'; -import { - serializeBufferToVector, - deserializeBufferFromVector, - deserializeUInt32, - deserializeField, - serializeBufferArrayToVector, - deserializeArrayFromVector, -} from './index.js'; - -describe('serialize', () => { - it('serialize buffer to vector and deserialize it back', () => { - const data = randomBytes(32); - const vector = serializeBufferToVector(data); - expect(vector.length).toBe(36); - - const recovered = deserializeBufferFromVector(vector); - expect(recovered.elem).toEqual(data); - expect(recovered.adv).toEqual(4 + 32); - - const paddedVector = Buffer.concat([randomBytes(10), vector, randomBytes(20)]); - const recovered2 = deserializeBufferFromVector(paddedVector, 10); - expect(recovered2.elem).toEqual(data); - expect(recovered2.adv).toEqual(4 + 32); - }); - - it('deserialize uint32', () => { - const uintBuf = Buffer.alloc(4); - uintBuf.writeUInt32BE(19, 0); - - const recovered = deserializeUInt32(uintBuf); - expect(recovered.elem).toBe(19); - expect(recovered.adv).toBe(4); - - const paddedBuf = Buffer.concat([randomBytes(10), uintBuf, randomBytes(20)]); - const recovered2 = deserializeUInt32(paddedBuf, 10); - expect(recovered2.elem).toBe(19); - expect(recovered2.adv).toBe(4); - }); - - it('deserialize field', () => { - const fieldBuf = randomBytes(32); - - const recovered = deserializeField(fieldBuf); - expect(recovered.elem).toEqual(fieldBuf); - expect(recovered.adv).toBe(32); - - const paddedBuf = Buffer.concat([randomBytes(10), fieldBuf, randomBytes(20)]); - const recovered2 = deserializeField(paddedBuf, 10); - expect(recovered2.elem).toEqual(fieldBuf); - expect(recovered2.adv).toBe(32); - }); - - it('serialize buffer array to vector and deserialize it back', () => { - // Array of uint32 - const uintArr = [7, 13, 16]; - const uintBufArr = uintArr.map(num => { - const uintBuf = Buffer.alloc(4); - uintBuf.writeUInt32BE(num, 0); - return uintBuf; - }); - const uintArrVec = serializeBufferArrayToVector(uintBufArr); - expect(uintArrVec.length).toBe(4 + 4 * 3); - - const recoveredUintArr = deserializeArrayFromVector(deserializeUInt32, uintArrVec); - expect(recoveredUintArr.elem).toEqual(uintArr); - expect(recoveredUintArr.adv).toEqual(4 + 4 * 3); - - const paddedUintArrVec = Buffer.concat([randomBytes(10), uintArrVec, randomBytes(20)]); - const recoveredUintArr2 = deserializeArrayFromVector(deserializeUInt32, paddedUintArrVec, 10); - expect(recoveredUintArr2.elem).toEqual(uintArr); - expect(recoveredUintArr2.adv).toEqual(4 + 4 * 3); - - // Array of field - const fieldArr = [randomBytes(32), randomBytes(32), randomBytes(32)]; - const fieldArrVec = serializeBufferArrayToVector(fieldArr); - expect(fieldArrVec.length).toBe(4 + 32 * 3); - - const recoveredFieldArr = deserializeArrayFromVector(deserializeField, fieldArrVec); - expect(recoveredFieldArr.elem).toEqual(fieldArr); - expect(recoveredFieldArr.adv).toEqual(4 + 32 * 3); - - const paddedFieldVec = Buffer.concat([randomBytes(10), fieldArrVec, randomBytes(20)]); - const recoveredFieldArr2 = deserializeArrayFromVector(deserializeField, paddedFieldVec, 10); - expect(recoveredFieldArr2.elem).toEqual(fieldArr); - expect(recoveredFieldArr2.adv).toEqual(4 + 32 * 3); - }); -}); diff --git a/yarn-project/ethereum.js/src/serialize/serializer.ts b/yarn-project/ethereum.js/src/serialize/serializer.ts deleted file mode 100644 index 4ed704f46d7..00000000000 --- a/yarn-project/ethereum.js/src/serialize/serializer.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { serializeBufferArrayToVector } from './index.js'; -import { - boolToByte, - numToInt32BE, - numToUInt32BE, - serializeBigInt, - serializeBufferToVector, - serializeDate, -} from './free_funcs.js'; - -// export type DeserializeFn = (buf: Buffer, offset: number) => { elem: T; adv: number }; - -/** - * The Serializer class is a utility for converting various data types into binary format (Buffer) suitable for transmission or storage. - * It offers several methods to serialize different data types, such as bool, int32, uInt32, bigInt, vector, buffer, string, and date. - * Additionally, it allows serializing arrays of elements with custom 'toBuffer' methods. Serialized data can be retrieved as a single - * Buffer using the getBuffer method. The class ensures proper serialization of variable-length data by prefixing them with their corresponding length. - */ -export class Serializer { - private buf: Buffer[] = []; - - constructor() {} - - /** - * Serializes a boolean value into a Buffer and appends it to the internal buffer array. - * The serialized byte can represent either true or false, using 1 for true and 0 for false. - * - * @param bool - The boolean value to be serialized. - */ - public bool(bool: boolean) { - this.buf.push(boolToByte(bool)); - } - - /** - * Serialize an unsigned 32-bit integer into a big-endian byte Buffer and add it to the internal buffer list. - * The input 'num' should be within the range of 0 to 2^32-1, inclusive. - * Throws an error if the input value is out of range. - * - * @param num - The unsigned 32-bit integer to be serialized. - */ - public uInt32(num: number) { - this.buf.push(numToUInt32BE(num)); - } - - /** - * Serializes the given signed 32-bit integer as a big-endian buffer and stores it in the internal buffer. - * The input 'num' should be within the range of [-2147483648, 2147483647], inclusive. - * Throws an error if the input value is out of range. - * - * @param num - The signed 32-bit integer to serialize. - */ - public int32(num: number) { - this.buf.push(numToInt32BE(num)); - } - - /** - * Serialize a bigint value into a Buffer and append it to the internal buffer array. - * The function takes care of handling large integer values that cannot be stored in - * standard JavaScript number type, allowing serialization of big integers without loss of precision. - * - * @param num - The bigint value to be serialized and added to the buffer. - */ - public bigInt(num: bigint) { - this.buf.push(serializeBigInt(num)); - } - - /** - * The given buffer is of variable length. Prefixes the buffer with its length. - */ - public vector(buf: Buffer) { - this.buf.push(serializeBufferToVector(buf)); - } - - /** - * Directly serializes a buffer that maybe of fixed, or variable length. - * It is assumed the corresponding deserialize function will handle variable length data, thus the length - * does not need to be prefixed here. - * If serializing a raw, variable length buffer, use vector(). - */ - public buffer(buf: Buffer) { - this.buf.push(buf); - } - - /** - * Serialize a given string by first converting it to a Buffer and then appending its length as a prefix. - * The converted buffer is pushed into the internal buffer array for further serialization. - * This method ensures the corresponding deserialize function can correctly read variable length strings. - * - * @param str - The input string to be serialized. - */ - public string(str: string) { - this.vector(Buffer.from(str)); - } - - /** - * Serializes a Date object and appends it to the buffer. - * The date is converted into a 64-bit integer representing the number of milliseconds since - * January 1, 1970, 00:00:00 UTC. This ensures accurate representation and reconstruction of dates - * during serialization and deserialization processes. - * - * @param date - The Date object to be serialized. - */ - public date(date: Date) { - this.buf.push(serializeDate(date)); - } - - /** - * Returns the serialized buffer obtained by concatenating all the serialized elements added to the Serializer instance. - * The resulting buffer can be used for data transmission or storage, and can be deserialized later to retrieve the original elements. - * - * @returns A Buffer containing the serialized data from the Serializer instance. - */ - public getBuffer() { - return Buffer.concat(this.buf); - } - - /** - * Serializes an array of elements and appends it to the internal buffer as a vector. - * Each element in the array is assumed to have a 'toBuffer' method which returns its serialized representation as a Buffer. - * The serialized array is prefixed with its length, allowing for variable-length arrays to be deserialized correctly. - * - * @param arr - The array of elements to be serialized. - */ - public serializeArray(arr: T[]) { - this.buf.push(serializeBufferArrayToVector(arr.map((e: any) => e.toBuffer()))); - } -} diff --git a/yarn-project/ethereum.js/src/sleep/index.ts b/yarn-project/ethereum.js/src/sleep/index.ts deleted file mode 100644 index 5300376c78f..00000000000 --- a/yarn-project/ethereum.js/src/sleep/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// eslint-disable-next-line jsdoc/require-jsdoc -export class InterruptError extends Error {} - -/** - * The InterruptableSleep class provides an enhanced sleep functionality that can be interrupted before the specified duration has elapsed. - * It allows you to create sleep instances with specified durations, which can be interrupted by calling the 'interrupt' method on the instance. - * In case of interruption, it can be configured to throw an 'InterruptError' or continue without throwing any error. - * This is useful in scenarios where you want to break out of a sleep state based on external conditions or events. - */ -export class InterruptableSleep { - private interruptResolve: (shouldThrow: boolean) => void = () => {}; - private interruptPromise = new Promise(resolve => (this.interruptResolve = resolve)); - private timeouts: NodeJS.Timeout[] = []; - - // eslint-disable-next-line jsdoc/require-jsdoc - public async sleep(ms: number) { - let timeout!: NodeJS.Timeout; - const promise = new Promise(resolve => (timeout = setTimeout(() => resolve(false), ms))); - this.timeouts.push(timeout); - const shouldThrow = await Promise.race([promise, this.interruptPromise]); - clearTimeout(timeout); - this.timeouts.splice(this.timeouts.indexOf(timeout), 1); - if (shouldThrow) { - throw new InterruptError('Interrupted.'); - } - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public interrupt(sleepShouldThrow = false) { - this.interruptResolve(sleepShouldThrow); - this.interruptPromise = new Promise(resolve => (this.interruptResolve = resolve)); - } -} - -// eslint-disable-next-line jsdoc/require-jsdoc -export function sleep(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)); -} diff --git a/yarn-project/ethereum.js/src/timer/index.ts b/yarn-project/ethereum.js/src/timer/index.ts deleted file mode 100644 index d267285d11d..00000000000 --- a/yarn-project/ethereum.js/src/timer/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -// eslint-disable-next-line jsdoc/require-jsdoc -export class Timer { - private start: number; - - constructor() { - this.start = new Date().getTime(); - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public ms() { - return new Date().getTime() - this.start; - } - - // eslint-disable-next-line jsdoc/require-jsdoc - public s() { - return (new Date().getTime() - this.start) / 1000; - } -} diff --git a/yarn-project/ethereum.js/src/units/index.ts b/yarn-project/ethereum.js/src/units/index.ts deleted file mode 100644 index a1cef9cb07e..00000000000 --- a/yarn-project/ethereum.js/src/units/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './units.js'; diff --git a/yarn-project/ethereum.js/src/units/units.test.ts b/yarn-project/ethereum.js/src/units/units.test.ts deleted file mode 100644 index c008124c8c5..00000000000 --- a/yarn-project/ethereum.js/src/units/units.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { fromBaseUnits, toBaseUnits } from './units.js'; - -describe('units', () => { - it('should format correctly', () => { - expect(fromBaseUnits(0n, 4, 2)).toBe('0'); - expect(fromBaseUnits(1299n, 4, 2)).toBe('0.12'); - expect(fromBaseUnits(198765n, 4, 2)).toBe('19.87'); - expect(fromBaseUnits(191111n, 4, 2)).toBe('19.11'); - expect(fromBaseUnits(100000n, 4, 2)).toBe('10'); - expect(fromBaseUnits(199999n, 4, 2)).toBe('19.99'); - expect(fromBaseUnits(199000n, 4, 2)).toBe('19.9'); - expect(fromBaseUnits(198765n, 4)).toBe('19.8765'); - expect(fromBaseUnits(190765n, 4, 6)).toBe('19.0765'); - expect(fromBaseUnits(-100n, 4, 2)).toBe('-0.01'); - expect(fromBaseUnits(198700n, 4, 6)).toBe('19.87'); - expect(fromBaseUnits(3000000000n, 6, 6)).toBe('3000'); - }); - - it('should convert string to bigint correctly', () => { - expect(toBaseUnits('0.0', 4)).toBe(0n); - expect(toBaseUnits('0', 4)).toBe(0n); - expect(toBaseUnits('', 4)).toBe(0n); - expect(toBaseUnits('.', 4)).toBe(0n); - expect(toBaseUnits('0.001', 3)).toBe(1n); - expect(toBaseUnits('0.1299', 4)).toBe(1299n); - expect(toBaseUnits('.1299', 4)).toBe(1299n); - expect(toBaseUnits('0.1299', 3)).toBe(129n); - expect(toBaseUnits('0.1299', 1)).toBe(1n); - expect(toBaseUnits('12.34', 3)).toBe(12340n); - expect(toBaseUnits('12.0', 3)).toBe(12000n); - expect(toBaseUnits('12', 3)).toBe(12000n); - expect(toBaseUnits('12.34', 0)).toBe(12n); - }); -}); diff --git a/yarn-project/ethereum.js/src/units/units.ts b/yarn-project/ethereum.js/src/units/units.ts deleted file mode 100644 index 274414c5bde..00000000000 --- a/yarn-project/ethereum.js/src/units/units.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Converts the value to a decimal string representation with the given precision. - * The digits outside the precision are simply discarded (i,e, the result is floored). - * This ensures we never report more funds than actually exists. - * Trailing 0's are also removed. - * @param value - To convert to string. - * @param decimals - The number of least significant digits of value that represent the decimal. - * @param precision - The number of decimal places to return. - */ -export function fromBaseUnits(value: bigint, decimals: number, precision: number = decimals) { - const neg = value < BigInt(0); - const valStr = value - .toString() - .slice(neg ? 1 : 0) - .padStart(decimals + 1, '0'); - const integer = valStr.slice(0, valStr.length - decimals); - const fractionalTrim = valStr.slice(-decimals); - let end = fractionalTrim.length - 1; - while (fractionalTrim[end] === '0') --end; - const fractional = fractionalTrim.slice(0, end + 1); - return (neg ? '-' : '') + (fractional ? `${integer}.${fractional.slice(0, precision)}` : integer); -} - -/** - * Converts the value from a decimal string to bigint value. - * @param valueString - To convert to bigint. - * @param decimals - The number of least significant digits of value that represent the decimal. - */ -export function toBaseUnits(valueString: string, decimals: number) { - const [integer, decimal] = valueString.split('.'); - const fractional = (decimal || '').replace(/0+$/, '').slice(0, decimals); - const scalingFactor = BigInt(10) ** BigInt(decimals); - const fractionalScale = scalingFactor / BigInt(10) ** BigInt(fractional.length || 0); - return BigInt(fractional || 0) * fractionalScale + BigInt(integer || 0) * scalingFactor; -} diff --git a/yarn-project/ethereum.js/tsconfig.json b/yarn-project/ethereum.js/tsconfig.json deleted file mode 100644 index 3b89ba50e7d..00000000000 --- a/yarn-project/ethereum.js/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "..", - "compilerOptions": { - "noImplicitAny": false, - "outDir": "dest", - "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo", - "skipLibCheck": true - }, - "references": [ - { - "path": "../foundation" - } - ], - "include": ["src", "src/eth_typed_data/fixtures/*.json"] -} diff --git a/yarn-project/foundation/.eslintrc.cjs b/yarn-project/foundation/.eslintrc.cjs index 497031446b0..f3332333bd0 100644 --- a/yarn-project/foundation/.eslintrc.cjs +++ b/yarn-project/foundation/.eslintrc.cjs @@ -59,8 +59,8 @@ module.exports = { files: '*.test.ts', rules: { 'jsdoc/require-jsdoc': 'off', - } - } + }, + }, ], env: { node: true, diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 1f03ee1aa06..22fb9f81f11 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -52,6 +52,7 @@ "@koa/cors": "^4.0.0", "debug": "^4.3.4", "detect-node": "^2.1.0", + "hash.js": "^1.1.7", "koa": "^2.14.1", "koa-bodyparser": "^4.4.0", "koa-compress": "^5.1.0", diff --git a/yarn-project/kernel-prover/src/kernel_prover.test.ts b/yarn-project/kernel-prover/src/kernel_prover.test.ts index 98587eea2ac..d4e33089bbc 100644 --- a/yarn-project/kernel-prover/src/kernel_prover.test.ts +++ b/yarn-project/kernel-prover/src/kernel_prover.test.ts @@ -12,7 +12,6 @@ import { makeEmptyProof, } from '@aztec/circuits.js'; import { makeTxRequest } from '@aztec/circuits.js/factories'; - import { mock } from 'jest-mock-extended'; import { KernelProver, OutputNoteData } from './kernel_prover.js'; import { ProofCreator } from './proof_creator.js'; diff --git a/yarn-project/l1-artifacts/.gitignore b/yarn-project/l1-artifacts/.gitignore new file mode 100644 index 00000000000..dc9b2375c7a --- /dev/null +++ b/yarn-project/l1-artifacts/.gitignore @@ -0,0 +1 @@ +generated \ No newline at end of file diff --git a/yarn-project/l1-contracts/Dockerfile b/yarn-project/l1-artifacts/Dockerfile similarity index 53% rename from yarn-project/l1-contracts/Dockerfile rename to yarn-project/l1-artifacts/Dockerfile index ab641a60c57..6902b8a5888 100644 --- a/yarn-project/l1-contracts/Dockerfile +++ b/yarn-project/l1-artifacts/Dockerfile @@ -1,15 +1,14 @@ FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder - COPY . . -WORKDIR /usr/src/yarn-project/l1-contracts -RUN yarn build && yarn formatting && yarn test +WORKDIR /usr/src/yarn-project/l1-artifacts +RUN yarn build # Prune dev dependencies. See comment in base image. RUN yarn cache clean RUN yarn workspaces focus --production > /dev/null FROM node:18-alpine -COPY --from=builder /usr/src/yarn-project/l1-contracts /usr/src/yarn-project/l1-contracts -WORKDIR /usr/src/yarn-project/l1-contracts +COPY --from=builder /usr/src/yarn-project/l1-artifacts /usr/src/yarn-project/l1-artifacts +WORKDIR /usr/src/yarn-project/l1-artifacts ENTRYPOINT ["yarn"] \ No newline at end of file diff --git a/yarn-project/l1-artifacts/README.md b/yarn-project/l1-artifacts/README.md new file mode 100644 index 00000000000..29f4316577f --- /dev/null +++ b/yarn-project/l1-artifacts/README.md @@ -0,0 +1,8 @@ +# L1 Artifacts + +Exposes TS-importable artifacts (bytecode + ABIs) of L1 contracts. + +## Usage + +The classes get automatically generated and built once `/bootstrap.sh` is called. +If you prefer to do so manually of `/l1-contracts`, run `./bootstrap.sh` there, and then run `yarn build` here. diff --git a/yarn-project/l1-artifacts/package.json b/yarn-project/l1-artifacts/package.json new file mode 100644 index 00000000000..21e6dcd3812 --- /dev/null +++ b/yarn-project/l1-artifacts/package.json @@ -0,0 +1,35 @@ +{ + "name": "@aztec/l1-artifacts", + "version": "0.0.0", + "type": "module", + "exports": { + ".": "./dest/index.js" + }, + "typedoc": { + "entryPoint": "./generated/index.ts", + "displayName": "L1 Contracts", + "tsconfig": "./tsconfig.json" + }, + "scripts": { + "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", + "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", + "build": "yarn clean && yarn generate && tsc -b", + "clean": "rm -rf ./dest ./generated .tsbuildinfo", + "formatting": "run -T prettier --check ./generated && run -T eslint ./generated", + "formatting:fix": "run -T prettier -w ./generated", + "generate": "bash scripts/generate-artifacts.sh && yarn formatting:fix" + }, + "dependencies": { + "tslib": "^2.4.0" + }, + "devDependencies": { + "@types/node": "^18.7.23", + "ts-node": "^10.9.1", + "typescript": "^5.0.4" + }, + "files": [ + "dest", + "generated" + ], + "types": "./dest/index.d.ts" +} diff --git a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh new file mode 100755 index 00000000000..bdf852258db --- /dev/null +++ b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh @@ -0,0 +1,35 @@ +set -euo pipefail; + +target_dir=./generated + +# create target dir if it doesn't exist +mkdir -p "$target_dir"; + +echo -ne "/**\n * DecoderHelper ABI.\n */\nexport const DecoderHelperAbi = " > "$target_dir/DecoderHelperAbi.ts"; +jq -j '.abi' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> "$target_dir/DecoderHelperAbi.ts"; +echo " as const;" >> "$target_dir/DecoderHelperAbi.ts"; +echo -ne "/**\n * DecoderHelper bytecode.\n */\nexport const DecoderHelperBytecode = \"" > "$target_dir/DecoderHelperBytecode.ts"; +jq -j '.bytecode.object' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> "$target_dir/DecoderHelperBytecode.ts"; +echo "\";" >> "$target_dir/DecoderHelperBytecode.ts"; + +echo -ne "/**\n * Rollup ABI.\n */\nexport const RollupAbi = " > "$target_dir/RollupAbi.ts"; +jq -j '.abi' ../../l1-contracts/out/Rollup.sol/Rollup.json >> "$target_dir/RollupAbi.ts"; +echo " as const;" >> "$target_dir/RollupAbi.ts"; + +echo -ne "/**\n * Rollup bytecode.\n */\nexport const RollupBytecode = '" > "$target_dir/RollupBytecode.ts"; +jq -j '.bytecode.object' ../../l1-contracts/out/Rollup.sol/Rollup.json >> "$target_dir/RollupBytecode.ts"; +echo "' as const;" >> "$target_dir/RollupBytecode.ts"; + +echo -ne "/**\n * UnverifiedDataEmitter ABI.\n */\nexport const UnverifiedDataEmitterAbi = " > "$target_dir/UnverifiedDataEmitterAbi.ts"; +jq -j '.abi' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> "$target_dir/UnverifiedDataEmitterAbi.ts"; +echo " as const;" >> "$target_dir/UnverifiedDataEmitterAbi.ts"; + +echo -ne "/**\n * UnverifiedDataEmitter bytecode.\n */\nexport const UnverifiedDataEmitterBytecode = '" > "$target_dir/UnverifiedDataEmitterBytecode.ts"; +jq -j '.bytecode.object' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> "$target_dir/UnverifiedDataEmitterBytecode.ts"; +echo "' as const;" >> "$target_dir/UnverifiedDataEmitterBytecode.ts"; + +echo -ne "export * from './DecoderHelperAbi.js';\nexport * from './DecoderHelperBytecode.js';\n" > "$target_dir/index.ts"; +echo -ne "export * from './RollupAbi.js';\nexport * from './RollupBytecode.js';\n" >> "$target_dir/index.ts"; +echo -ne "export * from './UnverifiedDataEmitterAbi.js';\nexport * from './UnverifiedDataEmitterBytecode.js';" >> "$target_dir/index.ts"; + +echo "Successfully generated TS artifacts!"; diff --git a/yarn-project/l1-artifacts/tsconfig.json b/yarn-project/l1-artifacts/tsconfig.json new file mode 100644 index 00000000000..7034f161f1f --- /dev/null +++ b/yarn-project/l1-artifacts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "..", + "compilerOptions": { + "outDir": "dest", + "rootDir": "generated", + "tsBuildInfoFile": ".tsbuildinfo" + }, + "include": ["generated"], + "references": [] +} diff --git a/yarn-project/l1-contracts/.eslintrc.cjs b/yarn-project/l1-contracts/.eslintrc.cjs deleted file mode 100644 index 97d6f187813..00000000000 --- a/yarn-project/l1-contracts/.eslintrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@aztec/foundation/eslint-legacy'); diff --git a/yarn-project/l1-contracts/README.md b/yarn-project/l1-contracts/README.md deleted file mode 100644 index 28e7f6c5be9..00000000000 --- a/yarn-project/l1-contracts/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# L1 Contracts - -Typed classes for the L1 contracts, both for `@aztec/ethereum.js` and `viem`. - -## Usage - -To update these classes, after checking out the latest version of `/l1-contracts`, run `forge build` there, and then run `yarn generate` here. diff --git a/yarn-project/l1-contracts/contracts.json b/yarn-project/l1-contracts/contracts.json deleted file mode 100644 index 327c0e99492..00000000000 --- a/yarn-project/l1-contracts/contracts.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "outputPath": "./src/ethereumjs-contracts", - "contracts": { - "DecoderHelper": { - "source": "foundry", - "buildFile": "../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json" - }, - "Rollup": { - "source": "foundry", - "buildFile": "../../l1-contracts/out/Rollup.sol/Rollup.json" - }, - "UnverifiedDataEmitter": { - "source": "foundry", - "buildFile": "../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json" - } - } -} diff --git a/yarn-project/l1-contracts/package.json b/yarn-project/l1-contracts/package.json deleted file mode 100644 index 05f01222e9d..00000000000 --- a/yarn-project/l1-contracts/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@aztec/l1-contracts", - "version": "0.0.0", - "type": "module", - "exports": { - ".": "./dest/index.js", - "./viem": "./dest/viem-contracts/index.js" - }, - "typedoc": { - "entryPoint": "./src/index.ts", - "displayName": "L1 Contracts", - "tsconfig": "./tsconfig.json" - }, - "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", - "build": "yarn clean && tsc -b", - "build:dev": "tsc -b --watch", - "clean": "rm -rf ./dest .tsbuildinfo", - "formatting": "run -T prettier --check ./src && run -T eslint ./src", - "formatting:fix": "run -T prettier -w ./src", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests", - "generate": "contract_gen_def && bash scripts/update-viem-abis.sh && yarn formatting:fix" - }, - "inherits": [ - "../package.common.json" - ], - "jest": { - "preset": "ts-jest/presets/default-esm", - "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" - }, - "testRegex": "./src/.*\\.test\\.ts$", - "rootDir": "./src" - }, - "dependencies": { - "@aztec/ethereum.js": "workspace:^", - "@aztec/foundation": "workspace:^", - "tslib": "^2.4.0" - }, - "devDependencies": { - "@jest/globals": "^29.5.0", - "@rushstack/eslint-patch": "^1.1.4", - "@types/jest": "^29.5.0", - "@types/node": "^18.7.23", - "jest": "^29.5.0", - "ts-jest": "^29.1.0", - "ts-node": "^10.9.1", - "typescript": "^5.0.4" - }, - "files": [ - "dest", - "src", - "!*.test.*" - ], - "types": "./dest/index.d.ts" -} diff --git a/yarn-project/l1-contracts/scripts/update-viem-abis.sh b/yarn-project/l1-contracts/scripts/update-viem-abis.sh deleted file mode 100755 index 52bdd3360cc..00000000000 --- a/yarn-project/l1-contracts/scripts/update-viem-abis.sh +++ /dev/null @@ -1,22 +0,0 @@ -set -euo pipefail; - -echo -ne "/**\n * DecoderHelper ABI for viem.\n */\nexport const DecoderHelperAbi = " > ./src/viem-contracts/DecoderHelper.ts; -jq -j '.abi' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> ./src/viem-contracts/DecoderHelper.ts; -echo " as const;" >> ./src/viem-contracts/DecoderHelper.ts; -echo -ne "/**\n * DecoderHelper Bytecode for viem.\n */\nexport const DecoderHelperBytecode = \"" >> ./src/viem-contracts/DecoderHelper.ts; -jq -j '.bytecode.object' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> ./src/viem-contracts/DecoderHelper.ts; -echo "\";" >> ./src/viem-contracts/DecoderHelper.ts; - -echo -ne "/**\n * Rollup ABI for viem.\n */\nexport const RollupAbi = " > ./src/viem-contracts/Rollup.ts; -jq -j '.abi' ../../l1-contracts/out/Rollup.sol/Rollup.json >> ./src/viem-contracts/Rollup.ts; -echo " as const;" >> ./src/viem-contracts/Rollup.ts; -echo -ne "/**\n * Rollup Bytecode for viem.\n */\nexport const RollupBytecode = \"" >> ./src/viem-contracts/Rollup.ts; -jq -j '.bytecode.object' ../../l1-contracts/out/Rollup.sol/Rollup.json >> ./src/viem-contracts/Rollup.ts; -echo "\";" >> ./src/viem-contracts/Rollup.ts; - -echo -ne "/**\n * UnverifiedDataEmitter ABI for viem.\n */\nexport const UnverifiedDataEmitterAbi = " > ./src/viem-contracts/UnverifiedDataEmitter.ts; -jq -j '.abi' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> ./src/viem-contracts/UnverifiedDataEmitter.ts; -echo " as const;" >> ./src/viem-contracts/UnverifiedDataEmitter.ts; -echo -ne "/**\n * UnverifiedDataEmitter Bytecode for viem.\n */\nexport const UnverifiedDataEmitterBytecode = \"" >> ./src/viem-contracts/UnverifiedDataEmitter.ts; -jq -j '.bytecode.object' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> ./src/viem-contracts/UnverifiedDataEmitter.ts; -echo "\";" >> ./src/viem-contracts/UnverifiedDataEmitter.ts; \ No newline at end of file diff --git a/yarn-project/l1-contracts/src/ethereumjs-contracts/DecoderHelper.ts b/yarn-project/l1-contracts/src/ethereumjs-contracts/DecoderHelper.ts deleted file mode 100644 index acc646ac7ec..00000000000 --- a/yarn-project/l1-contracts/src/ethereumjs-contracts/DecoderHelper.ts +++ /dev/null @@ -1,36 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from '@aztec/ethereum.js/contract'; -import * as Bytes from '@aztec/ethereum.js/contract/bytes.js'; -import abi from './DecoderHelperAbi.js'; -interface DecoderHelperEvents {} -interface DecoderHelperEventLogs {} -interface DecoderHelperTxEventLogs {} -export interface DecoderHelperTransactionReceipt extends ContractTxReceipt {} -interface DecoderHelperMethods { - computeDiffRootAndMessagesHash(_l2Block: Bytes.Bytes): TxCall<{ 0: Bytes.Bytes32; 1: Bytes.Bytes32 }>; - decode(_l2Block: Bytes.Bytes): TxCall<{ - 0: bigint; - 1: Bytes.Bytes32; - 2: Bytes.Bytes32; - 3: Bytes.Bytes32; - }>; -} -export interface DecoderHelperDefinition { - methods: DecoderHelperMethods; - events: DecoderHelperEvents; - eventLogs: DecoderHelperEventLogs; -} -export class DecoderHelper extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(): TxSend { - return super.deployBytecode( - '0x608060405234801561001057600080fd5b50610bbd806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063bdfd97c01461003b578063e5c5e9a314610068575b600080fd5b61004e610049366004610900565b61009b565b604080519283526020830191909152015b60405180910390f35b61007b610076366004610900565b6100b8565b60408051948552602085019390935291830152606082015260800161005f565b6000806000806100ab86866100d8565b9097909650945050505050565b6000806000806100c886866105b6565b9299919850965090945092505050565b60008061010d6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101466040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b61023c86013560e090811c80845260209081028801610240810135831c85830181905291820201610244810135831c60408681019190915290910201610248810135821c606085018190526054020161024c0135901c608083015260006101af60046002610988565b83516101bb91906109b5565b67ffffffffffffffff8111156101d3576101d36109c9565b6040519080825280602002602001820160405280156101fc578160200160208202803683370190505b5061024083528351909150610212906020610988565b825161021f9060046109df565b61022991906109df565b6020808401919091528381015161023f91610988565b602083015161024f9060046109df565b61025991906109df565b6040808401919091528381015161026f91610988565b604083015161027f9060046109df565b61028991906109df565b6060808401919091528301516102a0906020610988565b82606001516102af91906109df565b608083015260608301516102c4906054610988565b82608001516102d391906109df565b60a083015260005b81518110156104df57604080516104c08082526104e0820190925260009160208201818036833701905050905060208060080285518b018284013760208501516101008281019290918c01908401820137604085015161010082810192610200928d019190850101376060850151610200828101926040928d0191908501013760206002028101905060808501516020818c0183850137602c808301926014918d840160200191860101376020820191506020603482018c0183850137602c808301926014918d84016054019186010137506103bb905060046002610988565b6103c6906020610988565b845185906103d59083906109df565b9052506103e460046002610988565b6103ef906020610988565b8460200181815161040091906109df565b90525061040f60046002610988565b61041a906040610988565b8460400181815161042b91906109df565b905250606084018051604091906104439083906109df565b9052506080840180516068919061045b9083906109df565b90525060405160029061046f9083906109f2565b602060405180830381855afa15801561048c573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906104af9190610a21565b8383815181106104c1576104c1610a3a565b602090810291909101015250806104d781610a50565b9150506102db565b5060006104eb826105fd565b90506000806104fc60106020610988565b905060008167ffffffffffffffff811115610519576105196109c9565b6040519080825280601f01601f191660200182016040528015610543576020820181803683370190505b50905081601460a088015101602083013760028160405161056491906109f2565b602060405180830381855afa158015610581573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906105a49190610a21565b939b939a509298505050505050505050565b813560e01c600080806105d66105cd600186610a69565b60048888610775565b92506105e6846101208888610775565b91506105f28686610822565b905092959194509250565b6000805b825161060e826002610b60565b1015610626578061061e81610a50565b915050610601565b6000610633826002610b60565b905080845260005b828110156107505760005b8281101561073d57600286828151811061066257610662610a3a565b60200260200101518783600161067891906109df565b8151811061068857610688610a3a565b60200260200101516040516020016106aa929190918252602082015260400190565b60408051601f19818403018152908290526106c4916109f2565b602060405180830381855afa1580156106e1573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107049190610a21565b866107106002846109b5565b8151811061072057610720610a3a565b60209081029190910101526107366002826109df565b9050610646565b508061074881610a50565b91505061063b565b508360008151811061076457610764610a3a565b602002602001015192505050919050565b6040805161012080825261014082019092526000918291906020820181803683370190505090508560181c60208201538560101c60218201538560081c602282015385602382015361011c85850160248301376002816040516107d891906109f2565b602060405180830381855afa1580156107f5573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108189190610a21565b9695505050505050565b604080516102788082526102a08201909252600091908290826020820181803683370190505090508160048601602083013760008061086187876100d8565b6102588501829052610278850181905260405191935091507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001906002906108a99086906109f2565b602060405180830381855afa1580156108c6573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108e99190610a21565b6108f39190610b73565b9450505050505b92915050565b6000806020838503121561091357600080fd5b823567ffffffffffffffff8082111561092b57600080fd5b818501915085601f83011261093f57600080fd5b81358181111561094e57600080fd5b86602082850101111561096057600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176108fa576108fa610972565b634e487b7160e01b600052601260045260246000fd5b6000826109c4576109c461099f565b500490565b634e487b7160e01b600052604160045260246000fd5b808201808211156108fa576108fa610972565b6000825160005b81811015610a1357602081860181015185830152016109f9565b506000920191825250919050565b600060208284031215610a3357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b600060018201610a6257610a62610972565b5060010190565b818103818111156108fa576108fa610972565b600181815b80851115610ab7578160001904821115610a9d57610a9d610972565b80851615610aaa57918102915b93841c9390800290610a81565b509250929050565b600082610ace575060016108fa565b81610adb575060006108fa565b8160018114610af15760028114610afb57610b17565b60019150506108fa565b60ff841115610b0c57610b0c610972565b50506001821b6108fa565b5060208310610133831016604e8410600b8410161715610b3a575081810a6108fa565b610b448383610a7c565b8060001904821115610b5857610b58610972565b029392505050565b6000610b6c8383610abf565b9392505050565b600082610b8257610b8261099f565b50069056fea26469706673582212206f67550bf823fc5222b9bd273c244e63478d38338fa160a09802c12fd933f68964736f6c63430008120033', - ) as any; - } -} -export var DecoderHelperAbi = abi; diff --git a/yarn-project/l1-contracts/src/ethereumjs-contracts/DecoderHelperAbi.ts b/yarn-project/l1-contracts/src/ethereumjs-contracts/DecoderHelperAbi.ts deleted file mode 100644 index fb2cbe3e729..00000000000 --- a/yarn-project/l1-contracts/src/ethereumjs-contracts/DecoderHelperAbi.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - inputs: [ - { - internalType: 'bytes', - name: '_l2Block', - type: 'bytes', - }, - ], - name: 'computeDiffRootAndMessagesHash', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes', - name: '_l2Block', - type: 'bytes', - }, - ], - name: 'decode', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, -]); diff --git a/yarn-project/l1-contracts/src/ethereumjs-contracts/Rollup.ts b/yarn-project/l1-contracts/src/ethereumjs-contracts/Rollup.ts deleted file mode 100644 index 83f9a3971cc..00000000000 --- a/yarn-project/l1-contracts/src/ethereumjs-contracts/Rollup.ts +++ /dev/null @@ -1,43 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ - -import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from '@aztec/ethereum.js/contract'; -import * as Bytes from '@aztec/ethereum.js/contract/bytes.js'; -import abi from './RollupAbi.js'; -import { EthAddress } from '@aztec/foundation/eth-address'; -export type L2BlockProcessedEvent = { - blockNum: bigint; -}; -export interface L2BlockProcessedEventLog extends EventLog {} -interface RollupEvents { - L2BlockProcessed: L2BlockProcessedEvent; -} -interface RollupEventLogs { - L2BlockProcessed: L2BlockProcessedEventLog; -} -interface RollupTxEventLogs { - L2BlockProcessed: L2BlockProcessedEventLog[]; -} -export interface RollupTransactionReceipt extends ContractTxReceipt {} -interface RollupMethods { - VERIFIER(): TxCall; - process(_proof: Bytes.Bytes, _l2Block: Bytes.Bytes): TxSend; - rollupStateHash(): TxCall; -} -export interface RollupDefinition { - methods: RollupMethods; - events: RollupEvents; - eventLogs: RollupEventLogs; -} -export class Rollup extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(): TxSend { - return super.deployBytecode( - '0x60a060405234801561001057600080fd5b5060405161001d9061004b565b604051809103906000f080158015610039573d6000803e3d6000fd5b506001600160a01b0316608052610058565b61019d80610eef83390190565b608051610e7661007960003960008181604b015261016b0152610e766000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806308c84e70146100465780631ab9c6031461008a5780637c39d130146100a1575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61009360005481565b604051908152602001610081565b6100b46100af366004610ab9565b6100b6565b005b6000806000806100c68686610237565b60005493975091955093509150158015906100e357508260005414155b1561011357600054604051632d2ef59f60e11b815260048101919091526024810184905260440160405180910390fd5b60408051600180825281830190925260009160208083019080368337019050509050818160008151811061014957610149610b94565b6020908102919091010152604051633a94343960e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ea50d0e4906101a2908b908590600401610bce565b602060405180830381865afa1580156101bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e39190610c48565b610200576040516309bde33960e01b815260040160405180910390fd5b600083815560405186917f655779015b9b95c7fd18f01ea4619ab4c31289bbe134ba85c5b20bcdeb1dabf391a25050505050505050565b813560e01c6000808061025761024e600186610c87565b6004888861027e565b925061026784610120888861027e565b9150610273868661032b565b905092959194509250565b6040805161012080825261014082019092526000918291906020820181803683370190505090508560181c60208201538560101c60218201538560081c602282015385602382015361011c85850160248301376002816040516102e19190610c9a565b602060405180830381855afa1580156102fe573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906103219190610cb6565b9695505050505050565b604080516102788082526102a08201909252600091908290826020820181803683370190505090508160048601602083013760008061036a8787610409565b6102588501829052610278850181905260405191935091507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001906002906103b2908690610c9a565b602060405180830381855afa1580156103cf573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906103f29190610cb6565b6103fc9190610ce5565b9450505050505b92915050565b60008061043e6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6104776040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b61023c86013560e090811c80845260209081028801610240810135831c85830181905291820201610244810135831c60408681019190915290910201610248810135821c606085018190526054020161024c0135901c608083015260006104e060046002610cf9565b83516104ec9190610d10565b67ffffffffffffffff81111561050457610504610a61565b60405190808252806020026020018201604052801561052d578160200160208202803683370190505b5061024083528351909150610543906020610cf9565b8251610550906004610d24565b61055a9190610d24565b6020808401919091528381015161057091610cf9565b6020830151610580906004610d24565b61058a9190610d24565b604080840191909152838101516105a091610cf9565b60408301516105b0906004610d24565b6105ba9190610d24565b6060808401919091528301516105d1906020610cf9565b82606001516105e09190610d24565b608083015260608301516105f5906054610cf9565b82608001516106049190610d24565b60a083015260005b815181101561081057604080516104c08082526104e0820190925260009160208201818036833701905050905060208060080285518b018284013760208501516101008281019290918c01908401820137604085015161010082810192610200928d019190850101376060850151610200828101926040928d0191908501013760206002028101905060808501516020818c0183850137602c808301926014918d840160200191860101376020820191506020603482018c0183850137602c808301926014918d84016054019186010137506106ec905060046002610cf9565b6106f7906020610cf9565b84518590610706908390610d24565b90525061071560046002610cf9565b610720906020610cf9565b846020018181516107319190610d24565b90525061074060046002610cf9565b61074b906040610cf9565b8460400181815161075c9190610d24565b90525060608401805160409190610774908390610d24565b9052506080840180516068919061078c908390610d24565b9052506040516002906107a0908390610c9a565b602060405180830381855afa1580156107bd573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107e09190610cb6565b8383815181106107f2576107f2610b94565b6020908102919091010152508061080881610d37565b91505061060c565b50600061081c826108e9565b905060008061082d60106020610cf9565b905060008167ffffffffffffffff81111561084a5761084a610a61565b6040519080825280601f01601f191660200182016040528015610874576020820181803683370190505b50905081601460a08801510160208301376002816040516108959190610c9a565b602060405180830381855afa1580156108b2573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108d59190610cb6565b9398509296505050505050505b9250929050565b6000805b82516108fa826002610e34565b1015610912578061090a81610d37565b9150506108ed565b600061091f826002610e34565b905080845260005b82811015610a3c5760005b82811015610a2957600286828151811061094e5761094e610b94565b6020026020010151878360016109649190610d24565b8151811061097457610974610b94565b6020026020010151604051602001610996929190918252602082015260400190565b60408051601f19818403018152908290526109b091610c9a565b602060405180830381855afa1580156109cd573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906109f09190610cb6565b866109fc600284610d10565b81518110610a0c57610a0c610b94565b6020908102919091010152610a22600282610d24565b9050610932565b5080610a3481610d37565b915050610927565b5083600081518110610a5057610a50610b94565b602002602001015192505050919050565b634e487b7160e01b600052604160045260246000fd5b60008083601f840112610a8957600080fd5b50813567ffffffffffffffff811115610aa157600080fd5b6020830191508360208285010111156108e257600080fd5b600080600060408486031215610ace57600080fd5b833567ffffffffffffffff80821115610ae657600080fd5b818601915086601f830112610afa57600080fd5b813581811115610b0c57610b0c610a61565b604051601f8201601f19908116603f01168101908382118183101715610b3457610b34610a61565b81604052828152896020848701011115610b4d57600080fd5b826020860160208301376000602084830101528097505050506020860135915080821115610b7a57600080fd5b50610b8786828701610a77565b9497909650939450505050565b634e487b7160e01b600052603260045260246000fd5b60005b83811015610bc5578181015183820152602001610bad565b50506000910152565b60408152600083518060408401526020610bee8260608601838901610baa565b6060601f19601f93909301929092168401848103830185830152855192810183905285820192600091608001905b80831015610c3c5784518252938301936001929092019190830190610c1c565b50979650505050505050565b600060208284031215610c5a57600080fd5b81518015158114610c6a57600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561040357610403610c71565b60008251610cac818460208701610baa565b9190910192915050565b600060208284031215610cc857600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b600082610cf457610cf4610ccf565b500690565b808202811582820484141761040357610403610c71565b600082610d1f57610d1f610ccf565b500490565b8082018082111561040357610403610c71565b600060018201610d4957610d49610c71565b5060010190565b600181815b80851115610d8b578160001904821115610d7157610d71610c71565b80851615610d7e57918102915b93841c9390800290610d55565b509250929050565b600082610da257506001610403565b81610daf57506000610403565b8160018114610dc55760028114610dcf57610deb565b6001915050610403565b60ff841115610de057610de0610c71565b50506001821b610403565b5060208310610133831016604e8410600b8410161715610e0e575081810a610403565b610e188383610d50565b8060001904821115610e2c57610e2c610c71565b029392505050565b6000610c6a8383610d9356fea26469706673582212201c00b2c5d56e1c81c09d1676bc7d8d03a02f0908b4d016f19893cdd27242d27e64736f6c63430008120033608060405234801561001057600080fd5b5061017d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063937f6a101461003b578063ea50d0e41461005a575b600080fd5b60405168496d2061206d6f636b60b81b81526020015b60405180910390f35b610072610068366004610082565b6001949350505050565b6040519015158152602001610051565b6000806000806040858703121561009857600080fd5b843567ffffffffffffffff808211156100b057600080fd5b818701915087601f8301126100c457600080fd5b8135818111156100d357600080fd5b8860208285010111156100e557600080fd5b60209283019650945090860135908082111561010057600080fd5b818701915087601f83011261011457600080fd5b81358181111561012357600080fd5b8860208260051b850101111561013857600080fd5b9598949750506020019450505056fea264697066735822122079065ece8684a52b261c9ab9f34e06d3a4e53f346b36185587fd3fe29e5c9cc764736f6c63430008120033', - ) as any; - } -} -export var RollupAbi = abi; diff --git a/yarn-project/l1-contracts/src/ethereumjs-contracts/RollupAbi.ts b/yarn-project/l1-contracts/src/ethereumjs-contracts/RollupAbi.ts deleted file mode 100644 index 6162c30d545..00000000000 --- a/yarn-project/l1-contracts/src/ethereumjs-contracts/RollupAbi.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - inputs: [], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [], - name: 'InvalidProof', - type: 'error', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'expected', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 'actual', - type: 'bytes32', - }, - ], - name: 'InvalidStateHash', - type: 'error', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'blockNum', - type: 'uint256', - }, - ], - name: 'L2BlockProcessed', - type: 'event', - }, - { - inputs: [], - name: 'VERIFIER', - outputs: [ - { - internalType: 'contract MockVerifier', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes', - name: '_proof', - type: 'bytes', - }, - { - internalType: 'bytes', - name: '_l2Block', - type: 'bytes', - }, - ], - name: 'process', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'rollupStateHash', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, -]); diff --git a/yarn-project/l1-contracts/src/ethereumjs-contracts/UnverifiedDataEmitter.ts b/yarn-project/l1-contracts/src/ethereumjs-contracts/UnverifiedDataEmitter.ts deleted file mode 100644 index 357ac58763b..00000000000 --- a/yarn-project/l1-contracts/src/ethereumjs-contracts/UnverifiedDataEmitter.ts +++ /dev/null @@ -1,58 +0,0 @@ -// THIS IS GENERATED CODE, DO NOT EDIT! -/* eslint-disable */ -import { EthAddress } from '@aztec/foundation/eth-address'; -import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; -import { Contract, ContractTxReceipt, EventLog, Options, TxCall, TxSend } from '@aztec/ethereum.js/contract'; -import * as Bytes from '@aztec/ethereum.js/contract/bytes.js'; -import abi from './UnverifiedDataEmitterAbi.js'; -export type ContractDeploymentEvent = { - l2BlockNum: bigint; - aztecAddress: Bytes.Bytes32; - portalAddress: EthAddress; - acir: Bytes.Bytes; -}; -export type UnverifiedDataEvent = { - l2BlockNum: bigint; - sender: EthAddress; - data: Bytes.Bytes; -}; -export interface ContractDeploymentEventLog extends EventLog {} -export interface UnverifiedDataEventLog extends EventLog {} -interface UnverifiedDataEmitterEvents { - ContractDeployment: ContractDeploymentEvent; - UnverifiedData: UnverifiedDataEvent; -} -interface UnverifiedDataEmitterEventLogs { - ContractDeployment: ContractDeploymentEventLog; - UnverifiedData: UnverifiedDataEventLog; -} -interface UnverifiedDataEmitterTxEventLogs { - ContractDeployment: ContractDeploymentEventLog[]; - UnverifiedData: UnverifiedDataEventLog[]; -} -export interface UnverifiedDataEmitterTransactionReceipt extends ContractTxReceipt {} -interface UnverifiedDataEmitterMethods { - emitContractDeployment( - _l2BlockNum: bigint, - _aztecAddress: Bytes.Bytes32, - _portalAddress: EthAddress, - _acir: Bytes.Bytes, - ): TxSend; - emitUnverifiedData(_l2BlockNum: bigint, _data: Bytes.Bytes): TxSend; -} -export interface UnverifiedDataEmitterDefinition { - methods: UnverifiedDataEmitterMethods; - events: UnverifiedDataEmitterEvents; - eventLogs: UnverifiedDataEmitterEventLogs; -} -export class UnverifiedDataEmitter extends Contract { - constructor(eth: EthereumRpc, address?: EthAddress, options?: Options) { - super(eth, abi, address, options); - } - deploy(): TxSend { - return super.deployBytecode( - '0x608060405234801561001057600080fd5b50610268806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80631beadbf61461003b578063ec1c72ff14610050575b600080fd5b61004e610049366004610141565b610063565b005b61004e61005e3660046101b7565b6100af565b826001600160a01b031684867fc6da1a507344f9e421450cb8075906fe777b6411c1918306f6018ebb4d6b7e3785856040516100a0929190610203565b60405180910390a45050505050565b336001600160a01b0316837fb72b85ef2a843244f5ea1955248b0ac363732d2e6a98cc3641084dd5718ad8b584846040516100eb929190610203565b60405180910390a3505050565b60008083601f84011261010a57600080fd5b50813567ffffffffffffffff81111561012257600080fd5b60208301915083602082850101111561013a57600080fd5b9250929050565b60008060008060006080868803121561015957600080fd5b853594506020860135935060408601356001600160a01b038116811461017e57600080fd5b9250606086013567ffffffffffffffff81111561019a57600080fd5b6101a6888289016100f8565b969995985093965092949392505050565b6000806000604084860312156101cc57600080fd5b83359250602084013567ffffffffffffffff8111156101ea57600080fd5b6101f6868287016100f8565b9497909650939450505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f1916010191905056fea2646970667358221220444c01fee3697b99865e7d7c596fde10e007e4e7e2a1ea003b06c9290c8b67c564736f6c63430008120033', - ) as any; - } -} -export var UnverifiedDataEmitterAbi = abi; diff --git a/yarn-project/l1-contracts/src/ethereumjs-contracts/UnverifiedDataEmitterAbi.ts b/yarn-project/l1-contracts/src/ethereumjs-contracts/UnverifiedDataEmitterAbi.ts deleted file mode 100644 index 1f1670528b7..00000000000 --- a/yarn-project/l1-contracts/src/ethereumjs-contracts/UnverifiedDataEmitterAbi.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { ContractAbi } from '@aztec/ethereum.js/contract'; -export default new ContractAbi([ - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'l2BlockNum', - type: 'uint256', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'aztecAddress', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'address', - name: 'portalAddress', - type: 'address', - }, - { - indexed: false, - internalType: 'bytes', - name: 'acir', - type: 'bytes', - }, - ], - name: 'ContractDeployment', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'l2BlockNum', - type: 'uint256', - }, - { - indexed: true, - internalType: 'address', - name: 'sender', - type: 'address', - }, - { - indexed: false, - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - ], - name: 'UnverifiedData', - type: 'event', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_l2BlockNum', - type: 'uint256', - }, - { - internalType: 'bytes32', - name: '_aztecAddress', - type: 'bytes32', - }, - { - internalType: 'address', - name: '_portalAddress', - type: 'address', - }, - { - internalType: 'bytes', - name: '_acir', - type: 'bytes', - }, - ], - name: 'emitContractDeployment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_l2BlockNum', - type: 'uint256', - }, - { - internalType: 'bytes', - name: '_data', - type: 'bytes', - }, - ], - name: 'emitUnverifiedData', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, -]); diff --git a/yarn-project/l1-contracts/src/viem-contracts/DecoderHelper.ts b/yarn-project/l1-contracts/src/viem-contracts/DecoderHelper.ts deleted file mode 100644 index 7bd614dc0d6..00000000000 --- a/yarn-project/l1-contracts/src/viem-contracts/DecoderHelper.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * DecoderHelper ABI for viem. - */ -export const DecoderHelperAbi = [ - { - inputs: [ - { - internalType: 'bytes', - name: '_l2Block', - type: 'bytes', - }, - ], - name: 'computeDiffRootAndMessagesHash', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes', - name: '_l2Block', - type: 'bytes', - }, - ], - name: 'decode', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, -] as const; -/** - * DecoderHelper Bytecode for viem. - */ -export const DecoderHelperBytecode = - '0x608060405234801561001057600080fd5b50610bbd806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063bdfd97c01461003b578063e5c5e9a314610068575b600080fd5b61004e610049366004610900565b61009b565b604080519283526020830191909152015b60405180910390f35b61007b610076366004610900565b6100b8565b60408051948552602085019390935291830152606082015260800161005f565b6000806000806100ab86866100d8565b9097909650945050505050565b6000806000806100c886866105b6565b9299919850965090945092505050565b60008061010d6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101466040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b61023c86013560e090811c80845260209081028801610240810135831c85830181905291820201610244810135831c60408681019190915290910201610248810135821c606085018190526054020161024c0135901c608083015260006101af60046002610988565b83516101bb91906109b5565b67ffffffffffffffff8111156101d3576101d36109c9565b6040519080825280602002602001820160405280156101fc578160200160208202803683370190505b5061024083528351909150610212906020610988565b825161021f9060046109df565b61022991906109df565b6020808401919091528381015161023f91610988565b602083015161024f9060046109df565b61025991906109df565b6040808401919091528381015161026f91610988565b604083015161027f9060046109df565b61028991906109df565b6060808401919091528301516102a0906020610988565b82606001516102af91906109df565b608083015260608301516102c4906054610988565b82608001516102d391906109df565b60a083015260005b81518110156104df57604080516104c08082526104e0820190925260009160208201818036833701905050905060208060080285518b018284013760208501516101008281019290918c01908401820137604085015161010082810192610200928d019190850101376060850151610200828101926040928d0191908501013760206002028101905060808501516020818c0183850137602c808301926014918d840160200191860101376020820191506020603482018c0183850137602c808301926014918d84016054019186010137506103bb905060046002610988565b6103c6906020610988565b845185906103d59083906109df565b9052506103e460046002610988565b6103ef906020610988565b8460200181815161040091906109df565b90525061040f60046002610988565b61041a906040610988565b8460400181815161042b91906109df565b905250606084018051604091906104439083906109df565b9052506080840180516068919061045b9083906109df565b90525060405160029061046f9083906109f2565b602060405180830381855afa15801561048c573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906104af9190610a21565b8383815181106104c1576104c1610a3a565b602090810291909101015250806104d781610a50565b9150506102db565b5060006104eb826105fd565b90506000806104fc60106020610988565b905060008167ffffffffffffffff811115610519576105196109c9565b6040519080825280601f01601f191660200182016040528015610543576020820181803683370190505b50905081601460a088015101602083013760028160405161056491906109f2565b602060405180830381855afa158015610581573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906105a49190610a21565b939b939a509298505050505050505050565b813560e01c600080806105d66105cd600186610a69565b60048888610775565b92506105e6846101208888610775565b91506105f28686610822565b905092959194509250565b6000805b825161060e826002610b60565b1015610626578061061e81610a50565b915050610601565b6000610633826002610b60565b905080845260005b828110156107505760005b8281101561073d57600286828151811061066257610662610a3a565b60200260200101518783600161067891906109df565b8151811061068857610688610a3a565b60200260200101516040516020016106aa929190918252602082015260400190565b60408051601f19818403018152908290526106c4916109f2565b602060405180830381855afa1580156106e1573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107049190610a21565b866107106002846109b5565b8151811061072057610720610a3a565b60209081029190910101526107366002826109df565b9050610646565b508061074881610a50565b91505061063b565b508360008151811061076457610764610a3a565b602002602001015192505050919050565b6040805161012080825261014082019092526000918291906020820181803683370190505090508560181c60208201538560101c60218201538560081c602282015385602382015361011c85850160248301376002816040516107d891906109f2565b602060405180830381855afa1580156107f5573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108189190610a21565b9695505050505050565b604080516102788082526102a08201909252600091908290826020820181803683370190505090508160048601602083013760008061086187876100d8565b6102588501829052610278850181905260405191935091507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001906002906108a99086906109f2565b602060405180830381855afa1580156108c6573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108e99190610a21565b6108f39190610b73565b9450505050505b92915050565b6000806020838503121561091357600080fd5b823567ffffffffffffffff8082111561092b57600080fd5b818501915085601f83011261093f57600080fd5b81358181111561094e57600080fd5b86602082850101111561096057600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176108fa576108fa610972565b634e487b7160e01b600052601260045260246000fd5b6000826109c4576109c461099f565b500490565b634e487b7160e01b600052604160045260246000fd5b808201808211156108fa576108fa610972565b6000825160005b81811015610a1357602081860181015185830152016109f9565b506000920191825250919050565b600060208284031215610a3357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b600060018201610a6257610a62610972565b5060010190565b818103818111156108fa576108fa610972565b600181815b80851115610ab7578160001904821115610a9d57610a9d610972565b80851615610aaa57918102915b93841c9390800290610a81565b509250929050565b600082610ace575060016108fa565b81610adb575060006108fa565b8160018114610af15760028114610afb57610b17565b60019150506108fa565b60ff841115610b0c57610b0c610972565b50506001821b6108fa565b5060208310610133831016604e8410600b8410161715610b3a575081810a6108fa565b610b448383610a7c565b8060001904821115610b5857610b58610972565b029392505050565b6000610b6c8383610abf565b9392505050565b600082610b8257610b8261099f565b50069056fea26469706673582212206f67550bf823fc5222b9bd273c244e63478d38338fa160a09802c12fd933f68964736f6c63430008120033'; diff --git a/yarn-project/l1-contracts/src/viem-contracts/Rollup.ts b/yarn-project/l1-contracts/src/viem-contracts/Rollup.ts deleted file mode 100644 index 04e882b4f8c..00000000000 --- a/yarn-project/l1-contracts/src/viem-contracts/Rollup.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Rollup ABI for viem. - */ -export const RollupAbi = [ - { - inputs: [], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [], - name: 'InvalidProof', - type: 'error', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'expected', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 'actual', - type: 'bytes32', - }, - ], - name: 'InvalidStateHash', - type: 'error', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'blockNum', - type: 'uint256', - }, - ], - name: 'L2BlockProcessed', - type: 'event', - }, - { - inputs: [], - name: 'VERIFIER', - outputs: [ - { - internalType: 'contract MockVerifier', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes', - name: '_proof', - type: 'bytes', - }, - { - internalType: 'bytes', - name: '_l2Block', - type: 'bytes', - }, - ], - name: 'process', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'rollupStateHash', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, -] as const; -/** - * Rollup Bytecode for viem. - */ -export const RollupBytecode = - '0x60a060405234801561001057600080fd5b5060405161001d9061004b565b604051809103906000f080158015610039573d6000803e3d6000fd5b506001600160a01b0316608052610058565b61019d80610eef83390190565b608051610e7661007960003960008181604b015261016b0152610e766000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806308c84e70146100465780631ab9c6031461008a5780637c39d130146100a1575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61009360005481565b604051908152602001610081565b6100b46100af366004610ab9565b6100b6565b005b6000806000806100c68686610237565b60005493975091955093509150158015906100e357508260005414155b1561011357600054604051632d2ef59f60e11b815260048101919091526024810184905260440160405180910390fd5b60408051600180825281830190925260009160208083019080368337019050509050818160008151811061014957610149610b94565b6020908102919091010152604051633a94343960e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ea50d0e4906101a2908b908590600401610bce565b602060405180830381865afa1580156101bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e39190610c48565b610200576040516309bde33960e01b815260040160405180910390fd5b600083815560405186917f655779015b9b95c7fd18f01ea4619ab4c31289bbe134ba85c5b20bcdeb1dabf391a25050505050505050565b813560e01c6000808061025761024e600186610c87565b6004888861027e565b925061026784610120888861027e565b9150610273868661032b565b905092959194509250565b6040805161012080825261014082019092526000918291906020820181803683370190505090508560181c60208201538560101c60218201538560081c602282015385602382015361011c85850160248301376002816040516102e19190610c9a565b602060405180830381855afa1580156102fe573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906103219190610cb6565b9695505050505050565b604080516102788082526102a08201909252600091908290826020820181803683370190505090508160048601602083013760008061036a8787610409565b6102588501829052610278850181905260405191935091507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001906002906103b2908690610c9a565b602060405180830381855afa1580156103cf573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906103f29190610cb6565b6103fc9190610ce5565b9450505050505b92915050565b60008061043e6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6104776040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b61023c86013560e090811c80845260209081028801610240810135831c85830181905291820201610244810135831c60408681019190915290910201610248810135821c606085018190526054020161024c0135901c608083015260006104e060046002610cf9565b83516104ec9190610d10565b67ffffffffffffffff81111561050457610504610a61565b60405190808252806020026020018201604052801561052d578160200160208202803683370190505b5061024083528351909150610543906020610cf9565b8251610550906004610d24565b61055a9190610d24565b6020808401919091528381015161057091610cf9565b6020830151610580906004610d24565b61058a9190610d24565b604080840191909152838101516105a091610cf9565b60408301516105b0906004610d24565b6105ba9190610d24565b6060808401919091528301516105d1906020610cf9565b82606001516105e09190610d24565b608083015260608301516105f5906054610cf9565b82608001516106049190610d24565b60a083015260005b815181101561081057604080516104c08082526104e0820190925260009160208201818036833701905050905060208060080285518b018284013760208501516101008281019290918c01908401820137604085015161010082810192610200928d019190850101376060850151610200828101926040928d0191908501013760206002028101905060808501516020818c0183850137602c808301926014918d840160200191860101376020820191506020603482018c0183850137602c808301926014918d84016054019186010137506106ec905060046002610cf9565b6106f7906020610cf9565b84518590610706908390610d24565b90525061071560046002610cf9565b610720906020610cf9565b846020018181516107319190610d24565b90525061074060046002610cf9565b61074b906040610cf9565b8460400181815161075c9190610d24565b90525060608401805160409190610774908390610d24565b9052506080840180516068919061078c908390610d24565b9052506040516002906107a0908390610c9a565b602060405180830381855afa1580156107bd573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107e09190610cb6565b8383815181106107f2576107f2610b94565b6020908102919091010152508061080881610d37565b91505061060c565b50600061081c826108e9565b905060008061082d60106020610cf9565b905060008167ffffffffffffffff81111561084a5761084a610a61565b6040519080825280601f01601f191660200182016040528015610874576020820181803683370190505b50905081601460a08801510160208301376002816040516108959190610c9a565b602060405180830381855afa1580156108b2573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108d59190610cb6565b9398509296505050505050505b9250929050565b6000805b82516108fa826002610e34565b1015610912578061090a81610d37565b9150506108ed565b600061091f826002610e34565b905080845260005b82811015610a3c5760005b82811015610a2957600286828151811061094e5761094e610b94565b6020026020010151878360016109649190610d24565b8151811061097457610974610b94565b6020026020010151604051602001610996929190918252602082015260400190565b60408051601f19818403018152908290526109b091610c9a565b602060405180830381855afa1580156109cd573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906109f09190610cb6565b866109fc600284610d10565b81518110610a0c57610a0c610b94565b6020908102919091010152610a22600282610d24565b9050610932565b5080610a3481610d37565b915050610927565b5083600081518110610a5057610a50610b94565b602002602001015192505050919050565b634e487b7160e01b600052604160045260246000fd5b60008083601f840112610a8957600080fd5b50813567ffffffffffffffff811115610aa157600080fd5b6020830191508360208285010111156108e257600080fd5b600080600060408486031215610ace57600080fd5b833567ffffffffffffffff80821115610ae657600080fd5b818601915086601f830112610afa57600080fd5b813581811115610b0c57610b0c610a61565b604051601f8201601f19908116603f01168101908382118183101715610b3457610b34610a61565b81604052828152896020848701011115610b4d57600080fd5b826020860160208301376000602084830101528097505050506020860135915080821115610b7a57600080fd5b50610b8786828701610a77565b9497909650939450505050565b634e487b7160e01b600052603260045260246000fd5b60005b83811015610bc5578181015183820152602001610bad565b50506000910152565b60408152600083518060408401526020610bee8260608601838901610baa565b6060601f19601f93909301929092168401848103830185830152855192810183905285820192600091608001905b80831015610c3c5784518252938301936001929092019190830190610c1c565b50979650505050505050565b600060208284031215610c5a57600080fd5b81518015158114610c6a57600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561040357610403610c71565b60008251610cac818460208701610baa565b9190910192915050565b600060208284031215610cc857600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b600082610cf457610cf4610ccf565b500690565b808202811582820484141761040357610403610c71565b600082610d1f57610d1f610ccf565b500490565b8082018082111561040357610403610c71565b600060018201610d4957610d49610c71565b5060010190565b600181815b80851115610d8b578160001904821115610d7157610d71610c71565b80851615610d7e57918102915b93841c9390800290610d55565b509250929050565b600082610da257506001610403565b81610daf57506000610403565b8160018114610dc55760028114610dcf57610deb565b6001915050610403565b60ff841115610de057610de0610c71565b50506001821b610403565b5060208310610133831016604e8410600b8410161715610e0e575081810a610403565b610e188383610d50565b8060001904821115610e2c57610e2c610c71565b029392505050565b6000610c6a8383610d9356fea26469706673582212201c00b2c5d56e1c81c09d1676bc7d8d03a02f0908b4d016f19893cdd27242d27e64736f6c63430008120033608060405234801561001057600080fd5b5061017d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063937f6a101461003b578063ea50d0e41461005a575b600080fd5b60405168496d2061206d6f636b60b81b81526020015b60405180910390f35b610072610068366004610082565b6001949350505050565b6040519015158152602001610051565b6000806000806040858703121561009857600080fd5b843567ffffffffffffffff808211156100b057600080fd5b818701915087601f8301126100c457600080fd5b8135818111156100d357600080fd5b8860208285010111156100e557600080fd5b60209283019650945090860135908082111561010057600080fd5b818701915087601f83011261011457600080fd5b81358181111561012357600080fd5b8860208260051b850101111561013857600080fd5b9598949750506020019450505056fea264697066735822122079065ece8684a52b261c9ab9f34e06d3a4e53f346b36185587fd3fe29e5c9cc764736f6c63430008120033'; diff --git a/yarn-project/l1-contracts/src/viem-contracts/UnverifiedDataEmitter.ts b/yarn-project/l1-contracts/src/viem-contracts/UnverifiedDataEmitter.ts deleted file mode 100644 index eecafc00f2a..00000000000 --- a/yarn-project/l1-contracts/src/viem-contracts/UnverifiedDataEmitter.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * UnverifiedDataEmitter ABI for viem. - */ -export const UnverifiedDataEmitterAbi = [ - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'l2BlockNum', - type: 'uint256', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'aztecAddress', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'address', - name: 'portalAddress', - type: 'address', - }, - { - indexed: false, - internalType: 'bytes', - name: 'acir', - type: 'bytes', - }, - ], - name: 'ContractDeployment', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'l2BlockNum', - type: 'uint256', - }, - { - indexed: true, - internalType: 'address', - name: 'sender', - type: 'address', - }, - { - indexed: false, - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - ], - name: 'UnverifiedData', - type: 'event', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_l2BlockNum', - type: 'uint256', - }, - { - internalType: 'bytes32', - name: '_aztecAddress', - type: 'bytes32', - }, - { - internalType: 'address', - name: '_portalAddress', - type: 'address', - }, - { - internalType: 'bytes', - name: '_acir', - type: 'bytes', - }, - ], - name: 'emitContractDeployment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: '_l2BlockNum', - type: 'uint256', - }, - { - internalType: 'bytes', - name: '_data', - type: 'bytes', - }, - ], - name: 'emitUnverifiedData', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, -] as const; -/** - * UnverifiedDataEmitter Bytecode for viem. - */ -export const UnverifiedDataEmitterBytecode = - '0x608060405234801561001057600080fd5b50610268806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80631beadbf61461003b578063ec1c72ff14610050575b600080fd5b61004e610049366004610141565b610063565b005b61004e61005e3660046101b7565b6100af565b826001600160a01b031684867fc6da1a507344f9e421450cb8075906fe777b6411c1918306f6018ebb4d6b7e3785856040516100a0929190610203565b60405180910390a45050505050565b336001600160a01b0316837fb72b85ef2a843244f5ea1955248b0ac363732d2e6a98cc3641084dd5718ad8b584846040516100eb929190610203565b60405180910390a3505050565b60008083601f84011261010a57600080fd5b50813567ffffffffffffffff81111561012257600080fd5b60208301915083602082850101111561013a57600080fd5b9250929050565b60008060008060006080868803121561015957600080fd5b853594506020860135935060408601356001600160a01b038116811461017e57600080fd5b9250606086013567ffffffffffffffff81111561019a57600080fd5b6101a6888289016100f8565b969995985093965092949392505050565b6000806000604084860312156101cc57600080fd5b83359250602084013567ffffffffffffffff8111156101ea57600080fd5b6101f6868287016100f8565b9497909650939450505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f1916010191905056fea2646970667358221220444c01fee3697b99865e7d7c596fde10e007e4e7e2a1ea003b06c9290c8b67c564736f6c63430008120033'; diff --git a/yarn-project/l1-contracts/src/viem-contracts/index.ts b/yarn-project/l1-contracts/src/viem-contracts/index.ts deleted file mode 100644 index f253ede7ed5..00000000000 --- a/yarn-project/l1-contracts/src/viem-contracts/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './DecoderHelper.js'; -export * from './Rollup.js'; -export * from './UnverifiedDataEmitter.js'; diff --git a/yarn-project/l1-contracts/tsconfig.json b/yarn-project/l1-contracts/tsconfig.json deleted file mode 100644 index f9b0bcf34ce..00000000000 --- a/yarn-project/l1-contracts/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "..", - "compilerOptions": { - "outDir": "dest", - "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo" - }, - "references": [ - { - "path": "../ethereum.js" - }, - { - "path": "../foundation" - } - ], - "include": ["src"] -} diff --git a/yarn-project/package.json b/yarn-project/package.json index 4bf41648afc..bac8264404e 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -10,8 +10,8 @@ "formatting:fix": "yarn workspaces foreach -v run formatting:fix", "format": "yarn prettier --cache -w .", "test": "yarn build && yarn workspaces foreach -v run test", - "build": "tsc -b tsconfig.json", - "build:dev": "tsc -b tsconfig.json --watch", + "build": "yarn workspace @aztec/l1-artifacts generate && tsc -b tsconfig.json", + "build:dev": "yarn workspace @aztec/l1-artifacts generate && tsc -b tsconfig.json --watch", "clean": "yarn workspaces foreach -v run clean" }, "workspaces": [ @@ -24,14 +24,12 @@ "circuits.js", "docs", "end-to-end", - "ethereum.js", - "ethereum.js/example", "foundation", "kernel-prover", "key-store", "merkle-tree", "noir-contracts", - "l1-contracts", + "l1-artifacts", "p2p", "prover-client", "aztec-node", diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index 4734c098cd2..9528d8f1f52 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -34,9 +34,8 @@ "dependencies": { "@aztec/acir-simulator": "workspace:^", "@aztec/circuits.js": "workspace:^", - "@aztec/ethereum.js": "workspace:^", "@aztec/foundation": "workspace:^", - "@aztec/l1-contracts": "workspace:^", + "@aztec/l1-artifacts": "workspace:^", "@aztec/merkle-tree": "workspace:^", "@aztec/p2p": "workspace:^", "@aztec/types": "workspace:^", diff --git a/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts index 585ed7b3894..7a6bfcec83b 100644 --- a/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/circuit_block_builder.ts @@ -24,7 +24,6 @@ import { VerificationKey, } from '@aztec/circuits.js'; import { computeContractLeaf } from '@aztec/circuits.js/abis'; - import { LeafData, SiblingPath } from '@aztec/merkle-tree'; import { ContractData, L2Block, PublicDataWrite } from '@aztec/types'; import { MerkleTreeId, MerkleTreeOperations } from '@aztec/world-state'; diff --git a/yarn-project/sequencer-client/src/publisher/config.ts b/yarn-project/sequencer-client/src/publisher/config.ts index 6592e0c1777..b73374468a0 100644 --- a/yarn-project/sequencer-client/src/publisher/config.ts +++ b/yarn-project/sequencer-client/src/publisher/config.ts @@ -1,4 +1,4 @@ -import { L1Addresses } from '@aztec/l1-contracts'; +import { L1Addresses } from '@aztec/types'; /** * The configuration of the rollup transaction publisher. diff --git a/yarn-project/sequencer-client/src/publisher/ethereumjs-tx-sender.ts b/yarn-project/sequencer-client/src/publisher/ethereumjs-tx-sender.ts deleted file mode 100644 index 1758268b75d..00000000000 --- a/yarn-project/sequencer-client/src/publisher/ethereumjs-tx-sender.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { - EthereumRpc, - TransactionRequest, - TxHash, - toRawTransactionRequest, - waitForTxReceipt, -} from '@aztec/ethereum.js/eth_rpc'; -import { WalletProvider } from '@aztec/ethereum.js/provider'; -import { Rollup, UnverifiedDataEmitter } from '@aztec/l1-contracts'; -import { ContractPublicData, UnverifiedData } from '@aztec/types'; - -import { L1ProcessArgs as ProcessTxArgs, L1PublisherTxSender, MinimalTransactionReceipt } from './l1-publisher.js'; -import { TxSenderConfig } from './config.js'; -import { createDebugLogger } from '@aztec/foundation/log'; - -/** - * Pushes transactions to the L1 rollup contract using the custom aztec/ethereum.js library. - */ -export class EthereumjsTxSender implements L1PublisherTxSender { - private ethRpc: EthereumRpc; - private rollupContract: Rollup; - private unverifiedDataEmitterContract: UnverifiedDataEmitter; - private confirmations: number; - private log = createDebugLogger('aztec:sequencer:ethereum-js-tx-sender'); - - constructor(config: TxSenderConfig) { - const { - rpcUrl, - publisherPrivateKey, - rollupContract: rollupContractAddress, - unverifiedDataEmitterContract: unverifiedDataEmitterContractAddress, - requiredConfirmations, - } = config; - const provider = WalletProvider.fromHost(rpcUrl); - provider.addAccount(publisherPrivateKey); - this.ethRpc = new EthereumRpc(provider); - this.rollupContract = new Rollup(this.ethRpc, rollupContractAddress, { - from: provider.getAccount(0), - }); - this.unverifiedDataEmitterContract = new UnverifiedDataEmitter(this.ethRpc, unverifiedDataEmitterContractAddress, { - from: provider.getAccount(0), - }); - this.confirmations = requiredConfirmations; - } - - /** - * Returns a tx receipt if the tx has been mined. - * @param txHash - Hash of the tx to look for. - * @returns Undefined if the tx hasn't been mined yet, the receipt otherwise. - */ - public getTransactionReceipt(txHash: string): Promise { - return waitForTxReceipt(TxHash.fromString(txHash), this.ethRpc, this.confirmations).then( - r => r && { ...r, transactionHash: r.transactionHash.toString() }, - ); - } - - /** - * Sends a tx to the L1 rollup contract with a new L2 block. Returns once the tx has been mined. - * @param encodedData - Serialized data for processing the new L2 block. - * @returns The hash of the mined tx. - */ - async sendProcessTx(encodedData: ProcessTxArgs): Promise { - const methodCall = this.rollupContract.methods.process(encodedData.proof, encodedData.inputs); - let gas: number | undefined = undefined; - - try { - gas = await methodCall.estimateGas(); - return await methodCall - .send({ gas }) - .getTxHash() - .then(hash => hash.toString()); - } catch (err: unknown) { - const tx: TransactionRequest = (methodCall as any).getTxRequest({ gas }); - this.log(`Error sending L2 block tx:`, err, JSON.stringify(toRawTransactionRequest(tx))); - throw err; - } - } - - /** - * Sends a tx to the unverified data emitter contract with unverified data. Returns once the tx has been mined. - * @param l2BlockNum - Number of the L2 block that owns this unverified data. - * @param unverifiedData - Data to publish. - * @returns The hash of the mined tx. - */ - async sendEmitUnverifiedDataTx(l2BlockNum: number, unverifiedData: UnverifiedData): Promise { - const methodCall = this.unverifiedDataEmitterContract.methods.emitUnverifiedData( - BigInt(l2BlockNum), - unverifiedData.toBuffer(), - ); - - let gas: number | undefined = undefined; - - try { - gas = await methodCall.estimateGas(); - return await methodCall - .send({ gas }) - .getTxHash() - .then(hash => hash.toString()); - } catch (err) { - const tx: TransactionRequest = (methodCall as any).getTxRequest({ gas }); - this.log(`Error sending unverified data tx`, err, JSON.stringify(toRawTransactionRequest(tx))); - throw err; - } - } - - /** - * Sends a tx to the unverified data emitter contract with contract deployment data such as bytecode. Returns once the tx has been mined. - * @param l2BlockNum - Number of the L2 block that owns this unverified data. - * @param newContractData - Data to publish. - * @returns The hash of the mined tx. - */ - async sendEmitContractDeploymentTx( - l2BlockNum: number, - newContractData: ContractPublicData[], - ): Promise { - for (let i = 0; i < newContractData.length; i++) { - const newContract = newContractData[i]; - const methodCall = this.unverifiedDataEmitterContract.methods.emitContractDeployment( - BigInt(l2BlockNum), - newContract.contractData.contractAddress.toBuffer(), - newContract.contractData.portalContractAddress, - newContract.bytecode, - ); - const gas = await methodCall.estimateGas(); - return methodCall - .send({ gas }) - .getTxHash() - .then(hash => hash.toString()); - } - } -} diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts index 1637017192d..cdfd000b7a6 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.test.ts @@ -1,4 +1,3 @@ -import { TxHash } from '@aztec/ethereum.js/eth_rpc'; import { L2Block } from '@aztec/types'; import { mock, MockProxy } from 'jest-mock-extended'; import { sleep } from '../utils.js'; @@ -19,7 +18,7 @@ describe('L1Publisher', () => { l2Proof = Buffer.alloc(0); txSender = mock(); - txHash = TxHash.random().toString(); + txHash = `0x${Buffer.from('txHash').toString('hex')}`; // random tx hash txReceipt = { transactionHash: txHash, status: true }; txSender.sendProcessTx.mockResolvedValueOnce(txHash); txSender.getTransactionReceipt.mockResolvedValueOnce(txReceipt); diff --git a/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts b/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts index 22e924d8218..1535942b1e6 100644 --- a/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts +++ b/yarn-project/sequencer-client/src/publisher/viem-tx-sender.ts @@ -14,7 +14,7 @@ import { getContract, http, } from 'viem'; -import { RollupAbi, UnverifiedDataEmitterAbi } from '@aztec/l1-contracts/viem'; +import { RollupAbi, UnverifiedDataEmitterAbi } from '@aztec/l1-artifacts'; import { PrivateKeyAccount, privateKeyToAccount } from 'viem/accounts'; import * as chains from 'viem/chains'; import { createDebugLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/sequencer-client/src/test/l2-block-publisher.test.ts b/yarn-project/sequencer-client/src/test/l2-block-publisher.test.ts_disabled similarity index 99% rename from yarn-project/sequencer-client/src/test/l2-block-publisher.test.ts rename to yarn-project/sequencer-client/src/test/l2-block-publisher.test.ts_disabled index 774b2650ce6..e327e1ff6ce 100644 --- a/yarn-project/sequencer-client/src/test/l2-block-publisher.test.ts +++ b/yarn-project/sequencer-client/src/test/l2-block-publisher.test.ts_disabled @@ -15,7 +15,7 @@ import { } from '@aztec/circuits.js/factories'; import { EthereumRpc } from '@aztec/ethereum.js/eth_rpc'; import { WalletProvider } from '@aztec/ethereum.js/provider'; -import { DecoderHelper, Rollup, UnverifiedDataEmitter } from '@aztec/l1-contracts'; +import { DecoderHelper, Rollup, UnverifiedDataEmitter } from '@aztec/l1-artifacts'; import { Tx } from '@aztec/types'; import { MerkleTreeId, MerkleTreeOperations, MerkleTrees } from '@aztec/world-state'; import { beforeAll, describe, expect, it } from '@jest/globals'; diff --git a/yarn-project/sequencer-client/tsconfig.json b/yarn-project/sequencer-client/tsconfig.json index b9e2c05615a..df445b1e4bf 100644 --- a/yarn-project/sequencer-client/tsconfig.json +++ b/yarn-project/sequencer-client/tsconfig.json @@ -12,14 +12,11 @@ { "path": "../circuits.js" }, - { - "path": "../ethereum.js" - }, { "path": "../foundation" }, { - "path": "../l1-contracts" + "path": "../l1-artifacts" }, { "path": "../merkle-tree" diff --git a/yarn-project/tsconfig.json b/yarn-project/tsconfig.json index 444b0ff3617..0e9fc425f73 100644 --- a/yarn-project/tsconfig.json +++ b/yarn-project/tsconfig.json @@ -26,11 +26,10 @@ { "path": "barretenberg.js/tsconfig.json" }, { "path": "circuits.js/tsconfig.json" }, { "path": "end-to-end/tsconfig.json" }, - { "path": "ethereum.js/tsconfig.json" }, { "path": "foundation/tsconfig.json" }, { "path": "kernel-prover/tsconfig.json" }, { "path": "key-store/tsconfig.json" }, - { "path": "l1-contracts/tsconfig.json" }, + { "path": "l1-artifacts/tsconfig.json" }, { "path": "merkle-tree/tsconfig.json" }, { "path": "noir-contracts/tsconfig.json" }, { "path": "p2p/tsconfig.json" }, diff --git a/yarn-project/typedoc.json b/yarn-project/typedoc.json index 980e085333e..f673d6e9f06 100644 --- a/yarn-project/typedoc.json +++ b/yarn-project/typedoc.json @@ -7,7 +7,6 @@ "aztec-cli", "aztec-rpc", "aztec.js", - "ethereum.js", "kernel-prover", "key-store", "noir-contracts", diff --git a/yarn-project/types/README.md b/yarn-project/types/README.md index 4c489f776ef..0b72be149de 100644 --- a/yarn-project/types/README.md +++ b/yarn-project/types/README.md @@ -1,2 +1,2 @@ # Types -A package containing types which are relevant through all the Aztec Typescript codebase (L2Block, Tx etc.). \ No newline at end of file +A package containing types which are relevant through all the Aztec Typescript codebase (L2Block, Tx etc.). diff --git a/yarn-project/types/package.json b/yarn-project/types/package.json index 9585cb6fb34..6ecbe596dbb 100644 --- a/yarn-project/types/package.json +++ b/yarn-project/types/package.json @@ -38,7 +38,7 @@ "dependencies": { "@aztec/circuits.js": "workspace:^", "@aztec/foundation": "workspace:^", - "@aztec/l1-contracts": "workspace:^", + "@aztec/l1-artifacts": "workspace:^", "lodash.times": "^4.3.2", "tslib": "^2.5.0" }, diff --git a/yarn-project/types/src/constants.ts b/yarn-project/types/src/constants.ts new file mode 100644 index 00000000000..941eb52db9c --- /dev/null +++ b/yarn-project/types/src/constants.ts @@ -0,0 +1 @@ +export const INITIAL_L2_BLOCK_NUM = 1; diff --git a/yarn-project/types/src/index.ts b/yarn-project/types/src/index.ts index 7266fac35aa..154a5571a31 100644 --- a/yarn-project/types/src/index.ts +++ b/yarn-project/types/src/index.ts @@ -1,7 +1,9 @@ export * from './tx.js'; export * from './tx_hash.js'; +export * from './constants.js'; export * from './l2_block_downloader/index.js'; export * from './contract_data.js'; +export * from './l1_addresses.js'; export * from './l2_block.js'; export * from './l2_block_context.js'; export * from './l2_block_source.js'; diff --git a/yarn-project/l1-contracts/src/index.ts b/yarn-project/types/src/l1_addresses.ts similarity index 59% rename from yarn-project/l1-contracts/src/index.ts rename to yarn-project/types/src/l1_addresses.ts index 8b65eef3f9e..eca12b70e89 100644 --- a/yarn-project/l1-contracts/src/index.ts +++ b/yarn-project/types/src/l1_addresses.ts @@ -1,7 +1,5 @@ import { EthAddress } from '@aztec/foundation/eth-address'; -export const INITIAL_L2_BLOCK_NUM = 1; - /** * Rollup contract addresses. */ @@ -16,7 +14,3 @@ export interface L1Addresses { */ unverifiedDataEmitterContract: EthAddress; } - -export * from './ethereumjs-contracts/DecoderHelper.js'; -export * from './ethereumjs-contracts/Rollup.js'; -export * from './ethereumjs-contracts/UnverifiedDataEmitter.js'; diff --git a/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts b/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts index 4515897a5d4..4ef805ec294 100644 --- a/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts +++ b/yarn-project/types/src/l2_block_downloader/l2_block_downloader.ts @@ -1,7 +1,6 @@ -import { INITIAL_L2_BLOCK_NUM } from '@aztec/l1-contracts'; -import { L2BlockSource, L2Block } from '../index.js'; import { InterruptableSleep } from '@aztec/foundation/sleep'; import { MemoryFifo, Semaphore } from '@aztec/foundation/fifo'; +import { L2BlockSource, L2Block, INITIAL_L2_BLOCK_NUM } from '../index.js'; /** * Downloads L2 blocks from a L2BlockSource. diff --git a/yarn-project/types/tsconfig.json b/yarn-project/types/tsconfig.json index 97fd9a4ea3e..edb40e04794 100644 --- a/yarn-project/types/tsconfig.json +++ b/yarn-project/types/tsconfig.json @@ -13,7 +13,7 @@ "path": "../foundation" }, { - "path": "../l1-contracts" + "path": "../l1-artifacts" } ], "include": ["src"] diff --git a/yarn-project/yarn-project-base/Dockerfile b/yarn-project/yarn-project-base/Dockerfile index 1281e2bb05c..ca986e0f40f 100644 --- a/yarn-project/yarn-project-base/Dockerfile +++ b/yarn-project/yarn-project-base/Dockerfile @@ -1,12 +1,12 @@ # FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/circuits-x86_64-linux-clang FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/circuits-wasm-linux-clang -# FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/l1-contracts +FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/l1-contracts FROM node:18-alpine RUN apk update && apk add --no-cache build-base git python3 curl bash jq # COPY --from=0 /usr/src/circuits/build/bin /usr/src/circuits/build/bin +COPY --from=1 /usr/src/l1-contracts/out /usr/src/l1-contracts/out # COPY --from=1 /usr/src/circuits/build/bin /usr/src/circuits/build-wasm/bin -# COPY --from=2 /usr/src/l1-contracts /usr/src/l1-contracts COPY --from=0 /usr/src/circuits/cpp/build-wasm/bin/aztec3-circuits.wasm /usr/src/circuits/cpp/build-wasm/bin/aztec3-circuits.wasm COPY --from=0 /usr/src/circuits/cpp/barretenberg/cpp/build-wasm/bin/primitives.wasm /usr/src/circuits/cpp/barretenberg/cpp/build-wasm/bin/primitives.wasm @@ -25,15 +25,13 @@ COPY aztec-node/package.json aztec-node/package.json COPY aztec.js/package.json aztec.js/package.json COPY docs/package.json docs/package.json COPY end-to-end/package.json end-to-end/package.json -COPY ethereum.js/example/package.json ethereum.js/example/package.json -COPY ethereum.js/package.json ethereum.js/package.json COPY foundation/package.json foundation/package.json COPY kernel-prover/package.json kernel-prover/package.json COPY key-store/package.json key-store/package.json COPY merkle-tree/package.json merkle-tree/package.json COPY merkle-tree/package.local.json merkle-tree/package.local.json COPY noir-contracts/package.json noir-contracts/package.json -COPY l1-contracts/package.json l1-contracts/package.json +COPY l1-artifacts/package.json l1-artifacts/package.json COPY barretenberg.js/package.json barretenberg.js/package.json COPY circuits.js/package.json circuits.js/package.json COPY p2p/package.json p2p/package.json @@ -82,13 +80,12 @@ COPY aztec-rpc/tsconfig.json aztec-rpc/tsconfig.json COPY aztec-node/tsconfig.json aztec-node/tsconfig.json COPY aztec.js/tsconfig.json aztec.js/tsconfig.json COPY end-to-end/tsconfig.json end-to-end/tsconfig.json -COPY ethereum.js/tsconfig.json ethereum.js/tsconfig.json COPY foundation/tsconfig.json foundation/tsconfig.json COPY kernel-prover/tsconfig.json kernel-prover/tsconfig.json COPY key-store/tsconfig.json key-store/tsconfig.json COPY merkle-tree/tsconfig.json merkle-tree/tsconfig.json COPY noir-contracts/tsconfig.json noir-contracts/tsconfig.json -COPY l1-contracts/tsconfig.json l1-contracts/tsconfig.json +COPY l1-artifacts/tsconfig.json l1-artifacts/tsconfig.json COPY barretenberg.js/tsconfig.json barretenberg.js/tsconfig.json COPY circuits.js/tsconfig.json circuits.js/tsconfig.json COPY p2p/tsconfig.json p2p/tsconfig.json @@ -99,4 +96,11 @@ COPY world-state/tsconfig.json world-state/tsconfig.json # Check that dependencies config are up to date COPY yarn-project-base/scripts yarn-project-base/scripts -RUN yarn prepare:check \ No newline at end of file +RUN yarn prepare:check + +# Generate TS-importable contract artifacts +COPY l1-artifacts/scripts/generate-artifacts.sh l1-artifacts/scripts/generate-artifacts.sh +WORKDIR /usr/src/yarn-project/l1-artifacts +RUN ./scripts/generate-artifacts.sh + +WORKDIR /usr/src/yarn-project diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 076014e929a..674fd9df136 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -54,9 +54,8 @@ __metadata: version: 0.0.0-use.local resolution: "@aztec/archiver@workspace:archiver" dependencies: - "@aztec/ethereum.js": "workspace:^" "@aztec/foundation": "workspace:^" - "@aztec/l1-contracts": "workspace:^" + "@aztec/l1-artifacts": "workspace:^" "@aztec/types": "workspace:^" "@jest/globals": ^29.5.0 "@rushstack/eslint-patch": ^1.2.0 @@ -104,9 +103,8 @@ __metadata: dependencies: "@aztec/archiver": "workspace:^" "@aztec/barretenberg.js": "workspace:^" - "@aztec/ethereum.js": "workspace:^" "@aztec/foundation": "workspace:^" - "@aztec/l1-contracts": "workspace:^" + "@aztec/l1-artifacts": "workspace:^" "@aztec/merkle-tree": "workspace:^" "@aztec/p2p": "workspace:^" "@aztec/sequencer-client": "workspace:^" @@ -252,7 +250,7 @@ __metadata: "@aztec/aztec-node": "workspace:^" "@aztec/aztec.js": "workspace:^" "@aztec/foundation": "workspace:^" - "@aztec/l1-contracts": "workspace:^" + "@aztec/l1-artifacts": "workspace:^" "@aztec/noir-contracts": "workspace:^" "@jest/globals": ^29.5.0 "@rushstack/eslint-patch": ^1.1.4 @@ -270,53 +268,6 @@ __metadata: languageName: unknown linkType: soft -"@aztec/ethereum.js-example@workspace:ethereum.js/example": - version: 0.0.0-use.local - resolution: "@aztec/ethereum.js-example@workspace:ethereum.js/example" - dependencies: - "@aztec/ethereum.js": "workspace:^" - "@aztec/foundation": "workspace:^" - "@rushstack/eslint-patch": ^1.2.0 - "@types/node": ^18.15.0 - "@types/source-map-support": ^0.5.6 - source-map-support: ^0.5.21 - typescript: ^4.9.5 - languageName: unknown - linkType: soft - -"@aztec/ethereum.js@workspace:^, @aztec/ethereum.js@workspace:ethereum.js": - version: 0.0.0-use.local - resolution: "@aztec/ethereum.js@workspace:ethereum.js" - dependencies: - "@aztec/foundation": "workspace:^" - "@jest/globals": ^29.5.0 - "@rushstack/eslint-patch": ^1.2.0 - "@types/elliptic": ^6.4.14 - "@types/hdkey": ^2.0.1 - "@types/jest": ^29.5.0 - "@types/node": ^18.14.6 - "@types/uuid": ^9.0.0 - bip39: ^3.0.4 - browserify-aes: ^1.2.0 - debug: ^4.3.4 - detect-node: ^2.1.0 - elliptic: ^6.5.4 - hdkey: ^2.1.0 - jest: ^29.5.0 - jest-mock-extended: ^3.0.1 - pbkdf2: ^3.1.2 - rlp: ^3.0.0 - sha3: ^2.1.4 - source-map-support: ^0.5.21 - ts-jest: ^29.1.0 - ts-node: ^10.9.1 - typescript: ^5.0.4 - uuid: ^9.0.0 - bin: - contract_gen_def: ./dest/contract/gen_def/index.js - languageName: unknown - linkType: soft - "@aztec/foundation@workspace:^, @aztec/foundation@workspace:foundation": version: 0.0.0-use.local resolution: "@aztec/foundation@workspace:foundation" @@ -347,6 +298,7 @@ __metadata: eslint-config-prettier: ^8.5.0 eslint-plugin-jsdoc: ^40.1.0 eslint-plugin-tsdoc: ^0.2.17 + hash.js: ^1.1.7 jest: ^29.5.0 koa: ^2.14.1 koa-bodyparser: ^4.4.0 @@ -400,18 +352,11 @@ __metadata: languageName: unknown linkType: soft -"@aztec/l1-contracts@workspace:^, @aztec/l1-contracts@workspace:l1-contracts": +"@aztec/l1-artifacts@workspace:^, @aztec/l1-artifacts@workspace:l1-artifacts": version: 0.0.0-use.local - resolution: "@aztec/l1-contracts@workspace:l1-contracts" + resolution: "@aztec/l1-artifacts@workspace:l1-artifacts" dependencies: - "@aztec/ethereum.js": "workspace:^" - "@aztec/foundation": "workspace:^" - "@jest/globals": ^29.5.0 - "@rushstack/eslint-patch": ^1.1.4 - "@types/jest": ^29.5.0 "@types/node": ^18.7.23 - jest: ^29.5.0 - ts-jest: ^29.1.0 ts-node: ^10.9.1 tslib: ^2.4.0 typescript: ^5.0.4 @@ -511,9 +456,8 @@ __metadata: dependencies: "@aztec/acir-simulator": "workspace:^" "@aztec/circuits.js": "workspace:^" - "@aztec/ethereum.js": "workspace:^" "@aztec/foundation": "workspace:^" - "@aztec/l1-contracts": "workspace:^" + "@aztec/l1-artifacts": "workspace:^" "@aztec/merkle-tree": "workspace:^" "@aztec/p2p": "workspace:^" "@aztec/types": "workspace:^" @@ -549,7 +493,7 @@ __metadata: dependencies: "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" - "@aztec/l1-contracts": "workspace:^" + "@aztec/l1-artifacts": "workspace:^" "@jest/globals": ^29.5.0 "@rushstack/eslint-patch": ^1.1.4 "@types/jest": ^29.5.0 @@ -1628,7 +1572,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.0, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:~1.3.0": +"@noble/hashes@npm:1.3.0, @noble/hashes@npm:~1.3.0": version: 1.3.0 resolution: "@noble/hashes@npm:1.3.0" checksum: d7ddb6d7c60f1ce1f87facbbef5b724cdea536fc9e7f59ae96e0fc9de96c8f1a2ae2bdedbce10f7dcc621338dfef8533daa73c873f2b5c87fa1a4e05a95c2e2e @@ -1864,15 +1808,6 @@ __metadata: languageName: node linkType: hard -"@types/bn.js@npm:*": - version: 5.1.1 - resolution: "@types/bn.js@npm:5.1.1" - dependencies: - "@types/node": "*" - checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 - languageName: node - linkType: hard - "@types/body-parser@npm:*": version: 1.19.2 resolution: "@types/body-parser@npm:1.19.2" @@ -1934,15 +1869,6 @@ __metadata: languageName: node linkType: hard -"@types/elliptic@npm:^6.4.14": - version: 6.4.14 - resolution: "@types/elliptic@npm:6.4.14" - dependencies: - "@types/bn.js": "*" - checksum: d5a64f540e0ed4b74a12dfa5cc88c0aa7b531eab3b7a9fab17948ffbfc6e01814230e63d7417ce1b607dbd8b5d70e1b64f5afac632deabf96e44875aaac0ae1b - languageName: node - linkType: hard - "@types/express-serve-static-core@npm:^4.17.33": version: 4.17.33 resolution: "@types/express-serve-static-core@npm:4.17.33" @@ -1975,15 +1901,6 @@ __metadata: languageName: node linkType: hard -"@types/hdkey@npm:^2.0.1": - version: 2.0.1 - resolution: "@types/hdkey@npm:2.0.1" - dependencies: - "@types/node": "*" - checksum: 2593145197b17c7867987428c568f2840cbdd00eae8cfe43538dbb60b158c9e6ca2094007643f51e8dd392d00fc0e806ee22e2755180d94b19dbe3d508ecb23f - languageName: node - linkType: hard - "@types/http-assert@npm:*": version: 1.5.3 resolution: "@types/http-assert@npm:1.5.3" @@ -2246,7 +2163,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:^18.14.6, @types/node@npm:^18.15.0, @types/node@npm:^18.15.11, @types/node@npm:^18.15.3, @types/node@npm:^18.7.23": +"@types/node@npm:*, @types/node@npm:^18.14.6, @types/node@npm:^18.15.11, @types/node@npm:^18.15.3, @types/node@npm:^18.7.23": version: 18.15.11 resolution: "@types/node@npm:18.15.11" checksum: 977b4ad04708897ff0eb049ecf82246d210939c82461922d20f7d2dcfd81bbc661582ba3af28869210f7e8b1934529dcd46bff7d448551400f9d48b9d3bddec3 @@ -2307,15 +2224,6 @@ __metadata: languageName: node linkType: hard -"@types/source-map-support@npm:^0.5.6": - version: 0.5.6 - resolution: "@types/source-map-support@npm:0.5.6" - dependencies: - source-map: ^0.6.0 - checksum: b2b52b3e4901e52df30ebd23056885a352462c0d6fd73418e793684665a7602168e7c337241f0391562e8c1051ff37cbcb9b7d775990ee1f2a0d8a6ffa2cb22a - languageName: node - linkType: hard - "@types/stack-utils@npm:^2.0.0": version: 2.0.1 resolution: "@types/stack-utils@npm:2.0.1" @@ -2342,13 +2250,6 @@ __metadata: languageName: node linkType: hard -"@types/uuid@npm:^9.0.0": - version: 9.0.1 - resolution: "@types/uuid@npm:9.0.1" - checksum: c472b8a77cbeded4bc529220b8611afa39bd64677f507838f8083d8aac8033b1f88cb9ddaa2f8589e0dcd2317291d0f6e1379f82d5ceebd6f74f3b4825288e00 - languageName: node - linkType: hard - "@types/ws@npm:^8.5.4": version: 8.5.4 resolution: "@types/ws@npm:8.5.4" @@ -2827,15 +2728,6 @@ __metadata: languageName: node linkType: hard -"base-x@npm:^3.0.2": - version: 3.0.9 - resolution: "base-x@npm:3.0.9" - dependencies: - safe-buffer: ^5.0.1 - checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 - languageName: node - linkType: hard - "base64-js@npm:^1.3.1": version: 1.5.1 resolution: "base64-js@npm:1.5.1" @@ -2843,22 +2735,6 @@ __metadata: languageName: node linkType: hard -"bip39@npm:^3.0.4": - version: 3.1.0 - resolution: "bip39@npm:3.1.0" - dependencies: - "@noble/hashes": ^1.2.0 - checksum: 1224e763ffc6b097052ed8abd57f0e521ad6d31f1645be0d0a15f4417c13f8461f00e47e9cf7c8c784bd533f4fb1ee3ab020f258c7df45ee5dc722b4b0336cfc - languageName: node - linkType: hard - -"bn.js@npm:^4.11.9": - version: 4.12.0 - resolution: "bn.js@npm:4.12.0" - checksum: 39afb4f15f4ea537b55eaf1446c896af28ac948fdcf47171961475724d1bb65118cca49fa6e3d67706e4790955ec0e74de584e45c8f1ef89f46c812bee5b5a12 - languageName: node - linkType: hard - "brace-expansion@npm:^1.1.7": version: 1.1.11 resolution: "brace-expansion@npm:1.1.11" @@ -2887,14 +2763,7 @@ __metadata: languageName: node linkType: hard -"brorand@npm:^1.1.0": - version: 1.1.0 - resolution: "brorand@npm:1.1.0" - checksum: 8a05c9f3c4b46572dec6ef71012b1946db6cae8c7bb60ccd4b7dd5a84655db49fe043ecc6272e7ef1f69dc53d6730b9e2a3a03a8310509a3d797a618cbee52be - languageName: node - linkType: hard - -"browserify-aes@npm:^1.0.4, browserify-aes@npm:^1.2.0": +"browserify-aes@npm:^1.0.4": version: 1.2.0 resolution: "browserify-aes@npm:1.2.0" dependencies: @@ -2954,26 +2823,6 @@ __metadata: languageName: node linkType: hard -"bs58@npm:^4.0.0": - version: 4.0.1 - resolution: "bs58@npm:4.0.1" - dependencies: - base-x: ^3.0.2 - checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 - languageName: node - linkType: hard - -"bs58check@npm:^2.1.2": - version: 2.1.2 - resolution: "bs58check@npm:2.1.2" - dependencies: - bs58: ^4.0.0 - create-hash: ^1.1.0 - safe-buffer: ^5.1.2 - checksum: 43bdf08a5dd04581b78f040bc4169480e17008da482ffe2a6507327bbc4fc5c28de0501f7faf22901cfe57fbca79cbb202ca529003fedb4cb8dccd265b38e54d - languageName: node - linkType: hard - "bser@npm:2.1.1": version: 2.1.1 resolution: "bser@npm:2.1.1" @@ -3148,7 +2997,7 @@ __metadata: languageName: node linkType: hard -"cipher-base@npm:^1.0.0, cipher-base@npm:^1.0.1, cipher-base@npm:^1.0.3": +"cipher-base@npm:^1.0.0, cipher-base@npm:^1.0.1": version: 1.0.4 resolution: "cipher-base@npm:1.0.4" dependencies: @@ -3437,7 +3286,7 @@ __metadata: languageName: node linkType: hard -"create-hash@npm:^1.1.0, create-hash@npm:^1.1.2": +"create-hash@npm:^1.1.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" dependencies: @@ -3450,20 +3299,6 @@ __metadata: languageName: node linkType: hard -"create-hmac@npm:^1.1.4": - version: 1.1.7 - resolution: "create-hmac@npm:1.1.7" - dependencies: - cipher-base: ^1.0.3 - create-hash: ^1.1.0 - inherits: ^2.0.1 - ripemd160: ^2.0.0 - safe-buffer: ^5.0.1 - sha.js: ^2.4.8 - checksum: ba12bb2257b585a0396108c72830e85f882ab659c3320c83584b1037f8ab72415095167ced80dc4ce8e446a8ecc4b2acf36d87befe0707d73b26cf9dc77440ed - languageName: node - linkType: hard - "create-require@npm:^1.1.0": version: 1.1.1 resolution: "create-require@npm:1.1.1" @@ -3687,21 +3522,6 @@ __metadata: languageName: node linkType: hard -"elliptic@npm:^6.5.4": - version: 6.5.4 - resolution: "elliptic@npm:6.5.4" - dependencies: - bn.js: ^4.11.9 - brorand: ^1.1.0 - hash.js: ^1.0.0 - hmac-drbg: ^1.0.1 - inherits: ^2.0.4 - minimalistic-assert: ^1.0.1 - minimalistic-crypto-utils: ^1.0.1 - checksum: d56d21fd04e97869f7ffcc92e18903b9f67f2d4637a23c860492fbbff5a3155fd9ca0184ce0c865dd6eb2487d234ce9551335c021c376cd2d3b7cb749c7d10f4 - languageName: node - linkType: hard - "emittery@npm:^0.13.1": version: 0.13.1 resolution: "emittery@npm:0.13.1" @@ -4520,7 +4340,7 @@ __metadata: languageName: node linkType: hard -"hash.js@npm:^1.0.0, hash.js@npm:^1.0.3": +"hash.js@npm:^1.1.7": version: 1.1.7 resolution: "hash.js@npm:1.1.7" dependencies: @@ -4530,18 +4350,6 @@ __metadata: languageName: node linkType: hard -"hdkey@npm:^2.1.0": - version: 2.1.0 - resolution: "hdkey@npm:2.1.0" - dependencies: - bs58check: ^2.1.2 - ripemd160: ^2.0.2 - safe-buffer: ^5.1.1 - secp256k1: ^4.0.0 - checksum: 042f2d715dc4d106c868dc3791d584336845e4e53f3452e1df116d6af5d88d7084a0a73ddd8a07b4a7d9e6b29cd3b6b4174f03499f25d8ddd101642b34fabe5c - languageName: node - linkType: hard - "hexoid@npm:^1.0.0": version: 1.0.0 resolution: "hexoid@npm:1.0.0" @@ -4549,17 +4357,6 @@ __metadata: languageName: node linkType: hard -"hmac-drbg@npm:^1.0.1": - version: 1.0.1 - resolution: "hmac-drbg@npm:1.0.1" - dependencies: - hash.js: ^1.0.3 - minimalistic-assert: ^1.0.0 - minimalistic-crypto-utils: ^1.0.1 - checksum: bd30b6a68d7f22d63f10e1888aee497d7c2c5c0bb469e66bbdac99f143904d1dfe95f8131f95b3e86c86dd239963c9d972fcbe147e7cffa00e55d18585c43fe0 - languageName: node - linkType: hard - "hosted-git-info@npm:^2.1.4": version: 2.8.9 resolution: "hosted-git-info@npm:2.8.9" @@ -5145,7 +4942,7 @@ __metadata: languageName: node linkType: hard -"jest-mock-extended@npm:^3.0.1, jest-mock-extended@npm:^3.0.3, jest-mock-extended@npm:^3.0.4": +"jest-mock-extended@npm:^3.0.3, jest-mock-extended@npm:^3.0.4": version: 3.0.4 resolution: "jest-mock-extended@npm:3.0.4" dependencies: @@ -6016,13 +5813,6 @@ __metadata: languageName: node linkType: hard -"minimalistic-crypto-utils@npm:^1.0.1": - version: 1.0.1 - resolution: "minimalistic-crypto-utils@npm:1.0.1" - checksum: 6e8a0422b30039406efd4c440829ea8f988845db02a3299f372fceba56ffa94994a9c0f2fd70c17f9969eedfbd72f34b5070ead9656a34d3f71c0bd72583a0ed - languageName: node - linkType: hard - "minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": version: 3.1.2 resolution: "minimatch@npm:3.1.2" @@ -6198,15 +5988,6 @@ __metadata: languageName: node linkType: hard -"node-addon-api@npm:^2.0.0": - version: 2.0.2 - resolution: "node-addon-api@npm:2.0.2" - dependencies: - node-gyp: latest - checksum: 31fb22d674648204f8dd94167eb5aac896c841b84a9210d614bf5d97c74ef059cc6326389cf0c54d2086e35312938401d4cc82e5fcd679202503eb8ac84814f8 - languageName: node - linkType: hard - "node-cleanup@npm:^2.1.2": version: 2.1.2 resolution: "node-cleanup@npm:2.1.2" @@ -6228,7 +6009,7 @@ __metadata: languageName: node linkType: hard -"node-gyp-build@npm:^4.2.0, node-gyp-build@npm:^4.3.0": +"node-gyp-build@npm:^4.3.0": version: 4.6.0 resolution: "node-gyp-build@npm:4.6.0" bin: @@ -6510,19 +6291,6 @@ __metadata: languageName: node linkType: hard -"pbkdf2@npm:^3.1.2": - version: 3.1.2 - resolution: "pbkdf2@npm:3.1.2" - dependencies: - create-hash: ^1.1.2 - create-hmac: ^1.1.4 - ripemd160: ^2.0.1 - safe-buffer: ^5.0.1 - sha.js: ^2.4.8 - checksum: 2c950a100b1da72123449208e231afc188d980177d021d7121e96a2de7f2abbc96ead2b87d03d8fe5c318face097f203270d7e27908af9f471c165a4e8e69c92 - languageName: node - linkType: hard - "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0" @@ -6844,7 +6612,7 @@ __metadata: languageName: node linkType: hard -"ripemd160@npm:^2.0.0, ripemd160@npm:^2.0.1, ripemd160@npm:^2.0.2": +"ripemd160@npm:^2.0.1": version: 2.0.2 resolution: "ripemd160@npm:2.0.2" dependencies: @@ -6854,15 +6622,6 @@ __metadata: languageName: node linkType: hard -"rlp@npm:^3.0.0": - version: 3.0.0 - resolution: "rlp@npm:3.0.0" - bin: - rlp: bin/rlp - checksum: d1d8003b2be0b25083d842571c0cdc3f2ed4f8b6cc2edf46239e240ba7f73b57ca419cea544394c38bd6b0125e728945af5b167370385d9462e04559b2332e69 - languageName: node - linkType: hard - "rollup@npm:^3.18.0": version: 3.20.2 resolution: "rollup@npm:3.20.2" @@ -6909,18 +6668,6 @@ __metadata: languageName: node linkType: hard -"secp256k1@npm:^4.0.0": - version: 4.0.3 - resolution: "secp256k1@npm:4.0.3" - dependencies: - elliptic: ^6.5.4 - node-addon-api: ^2.0.0 - node-gyp: latest - node-gyp-build: ^4.2.0 - checksum: 21e219adc0024fbd75021001358780a3cc6ac21273c3fcaef46943af73969729709b03f1df7c012a0baab0830fb9a06ccc6b42f8d50050c665cb98078eab477b - languageName: node - linkType: hard - "semver-match@npm:0.1.1": version: 0.1.1 resolution: "semver-match@npm:0.1.1" @@ -6973,7 +6720,7 @@ __metadata: languageName: node linkType: hard -"sha.js@npm:^2.4.0, sha.js@npm:^2.4.8": +"sha.js@npm:^2.4.0": version: 2.4.11 resolution: "sha.js@npm:2.4.11" dependencies: @@ -7116,16 +6863,6 @@ __metadata: languageName: node linkType: hard -"source-map-support@npm:^0.5.21": - version: 0.5.21 - resolution: "source-map-support@npm:0.5.21" - dependencies: - buffer-from: ^1.0.0 - source-map: ^0.6.0 - checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 - languageName: node - linkType: hard - "source-map@npm:^0.6.0, source-map@npm:^0.6.1": version: 0.6.1 resolution: "source-map@npm:0.6.1" @@ -7687,16 +7424,6 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^4.9.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db - languageName: node - linkType: hard - "typescript@npm:^5.0.4": version: 5.0.4 resolution: "typescript@npm:5.0.4" @@ -7707,16 +7434,6 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@^4.9.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: ab417a2f398380c90a6cf5a5f74badd17866adf57f1165617d6a551f059c3ba0a3e4da0d147b3ac5681db9ac76a303c5876394b13b3de75fdd5b1eaa06181c9d - languageName: node - linkType: hard - "typescript@patch:typescript@^5.0.4#~builtin": version: 5.0.4 resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=1f5320" @@ -7789,15 +7506,6 @@ __metadata: languageName: node linkType: hard -"uuid@npm:^9.0.0": - version: 9.0.0 - resolution: "uuid@npm:9.0.0" - bin: - uuid: dist/bin/uuid - checksum: 8dd2c83c43ddc7e1c71e36b60aea40030a6505139af6bee0f382ebcd1a56f6cd3028f7f06ffb07f8cf6ced320b76aea275284b224b002b289f89fe89c389b028 - languageName: node - linkType: hard - "v8-compile-cache-lib@npm:^3.0.1": version: 3.0.1 resolution: "v8-compile-cache-lib@npm:3.0.1"