Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test": "npm run compile-test && mocha 'src/**/__tests__/*.test.ts'"
},
"peerDependencies": {
"ethers": "6.13.1"
"ethers": "6.14.3"
},
"devDependencies": {
"@types/chai": "4.3.5",
Expand All @@ -37,11 +37,12 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.26.0",
"ethers": "6.13.1",
"ethers": "6.14.3",
"madge": "6.1.0",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.2",
"typescript": "5.1.3"
}
},
"packageManager": "yarn@1.22.22"
}
26 changes: 25 additions & 1 deletion src/models/broadcaster.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Authorization } from 'ethers';
import { TXIDVersion } from './engine';
import {
ChainType,
Expand Down Expand Up @@ -45,14 +46,37 @@ type BroadcasterRawParamsShared = {
maxVersion: string;
};

export type BroadcasterRawParamsTransact = BroadcasterRawParamsShared & {
export enum BroadcasterTransactRequestType {
Legacy = 'legacy',
EIP7702 = 'eip7702',
}

export type BroadcasterRawParamsTransactLegacy = BroadcasterRawParamsShared & {
transactType?: BroadcasterTransactRequestType.Legacy;
to: string;
data: string;
minGasPrice: string;
useRelayAdapt: boolean;
preTransactionPOIsPerTxidLeafPerList: PreTransactionPOIsPerTxidLeafPerList;
authorization?: never;
};

export type BroadcasterRawParamsTransactEIP7702 = BroadcasterRawParamsShared & {
transactType: BroadcasterTransactRequestType.EIP7702;
to: string;
data: string;
// Explicit EIP-1559 fee fields. These are REQUIRED for EIP-7702 (type 4).
maxFeePerGas: string;
maxPriorityFeePerGas: string;
useRelayAdapt: boolean;
preTransactionPOIsPerTxidLeafPerList: PreTransactionPOIsPerTxidLeafPerList;
authorization: Authorization;
};

export type BroadcasterRawParamsTransact =
| BroadcasterRawParamsTransactLegacy
| BroadcasterRawParamsTransactEIP7702;

export type BroadcasterRawParamsPreAuthorize = BroadcasterRawParamsShared & {
gasLimit: string;
commitmentCiphertext: CommitmentCiphertextV2 | CommitmentCiphertextV3;
Expand Down
103 changes: 103 additions & 0 deletions src/models/network-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export type Network = {
proxyContract: string;
relayAdaptContract: string;
relayAdaptHistory: string[];
supports7702: boolean;
relayAdapt7702Contract: string;
relayAdapt7702History: string[];
railgunRegistryContract: string;
deploymentBlock: number;
poseidonMerkleAccumulatorV3Contract: string;
poseidonMerkleVerifierV3Contract: string;
Expand Down Expand Up @@ -248,6 +252,50 @@ export const RailgunPoseidonMerkleAccumulatorV3DeploymentBlock: Record<
[NetworkName.PolygonMumbai_DEPRECATED]: 0,
};

// 7702 Adapt Deployer not yet deployed on mainnets/testnets
export const RailgunRegistryContract: Record<NetworkName, string> = {
// Main nets
[NetworkName.Ethereum]: '',
[NetworkName.BNBChain]: '',
[NetworkName.Polygon]: '',
[NetworkName.Arbitrum]: '',

// Test nets
[NetworkName.EthereumSepolia]: '0xFe276aD6a9Be967292D7fcb74E5510a1A6796bFb',
[NetworkName.PolygonAmoy]: '',

// Dev only
[NetworkName.Hardhat]: '',

// Deprecated
[NetworkName.EthereumRopsten_DEPRECATED]: '',
[NetworkName.EthereumGoerli_DEPRECATED]: '',
[NetworkName.ArbitrumGoerli_DEPRECATED]: '',
[NetworkName.PolygonMumbai_DEPRECATED]: '',
};

export const RelayAdapt7702Contract: Record<NetworkName, string> = {
// Main nets
[NetworkName.Ethereum]: '',
[NetworkName.BNBChain]: '',
[NetworkName.Polygon]: '',
[NetworkName.Arbitrum]: '',

// Test nets
[NetworkName.EthereumSepolia]: '0x19702345c059ac86a1f17434ebE0227D62F5965f',
[NetworkName.PolygonAmoy]: '',

// Dev only
[NetworkName.Hardhat]: '',

// Deprecated
[NetworkName.EthereumRopsten_DEPRECATED]: '',
[NetworkName.EthereumGoerli_DEPRECATED]: '',
[NetworkName.ArbitrumGoerli_DEPRECATED]: '',
[NetworkName.PolygonMumbai_DEPRECATED]: '',
};


export const NETWORK_CONFIG: Record<NetworkName, Network> = {
[NetworkName.Ethereum]: {
chain: {
Expand All @@ -272,6 +320,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0x4025ee6512DBbda97049Bcf5AA5D38C54aF6bE8a', // V3.1 Update - Jan 2023
'0xAc9f360Ae85469B27aEDdEaFC579Ef2d052aD405', // Upgrade Jul 2025
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.Ethereum],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.Ethereum],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.Ethereum],
deploymentBlockPoseidonMerkleAccumulatorV3:
RailgunPoseidonMerkleAccumulatorV3DeploymentBlock[NetworkName.Ethereum],
Expand Down Expand Up @@ -310,6 +363,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0x741936fb83DDf324636D3048b3E6bC800B8D9e12', // V3.1 Update - Jan 2023
'0xF82d00fC51F730F42A00F85E74895a2849ffF2Dd', // Upgrade Jul 2025
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.BNBChain],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.BNBChain],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.BNBChain],
defaultEVMGasType: EVMGasType.Type0,
poi: {
Expand Down Expand Up @@ -348,6 +406,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0xc7FfA542736321A3dd69246d73987566a5486968', // V3.1 Update - Jan 2023
'0xF82d00fC51F730F42A00F85E74895a2849ffF2Dd', // Upgrade Jul 2025
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.Polygon],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.Polygon],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.Polygon],
defaultEVMGasType: EVMGasType.Type2,
poi: {
Expand Down Expand Up @@ -384,6 +447,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0x5aD95C537b002770a39dea342c4bb2b68B1497aA', // Initial deployment - Feb 2023 post v3.1
'0xB4F2d77bD12c6b548Ae398244d7FAD4ABCE4D89b', // Upgrade Jul 2025
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.Arbitrum],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.Arbitrum],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.Arbitrum],
defaultEVMGasType: EVMGasType.Type2,
poi: {
Expand Down Expand Up @@ -422,6 +490,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
relayAdaptContract:
RelayAdaptContract[NetworkName.EthereumRopsten_DEPRECATED],
relayAdaptHistory: [''],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.EthereumRopsten_DEPRECATED],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.EthereumRopsten_DEPRECATED],
deploymentBlock:
RailgunProxyDeploymentBlock[NetworkName.EthereumRopsten_DEPRECATED],
isTestnet: true,
Expand Down Expand Up @@ -468,6 +541,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0x6E9C59F042acB1577A297eDE607c21Ff284846F3', // V3.1 partial update - Jan 2023
'0x14a57CA7C5c1AD54fB6c642f428d973fcD696ED4', // V3.1 Update - Jan 2023
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.EthereumGoerli_DEPRECATED],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.EthereumGoerli_DEPRECATED],
deploymentBlock:
RailgunProxyDeploymentBlock[NetworkName.EthereumGoerli_DEPRECATED],
isTestnet: true,
Expand Down Expand Up @@ -512,6 +590,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
relayAdaptHistory: [
'0x7e3d929EbD5bDC84d02Bd3205c777578f33A214D', // Deployment - Apr 2024
],
supports7702: true,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.EthereumSepolia],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.EthereumSepolia],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.EthereumSepolia],
isDevOnlyNetwork: true,
isTestnet: true,
Expand Down Expand Up @@ -553,6 +636,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
relayAdaptHistory: [
'0xc340f7E17A42154674d6B50190386C9a2982D12E', // Initial deployment
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.PolygonAmoy],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.PolygonAmoy],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.PolygonAmoy],
isDevOnlyNetwork: true,
isTestnet: true,
Expand Down Expand Up @@ -593,6 +681,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0x80efF1a8939C9B6E8C61Ed5Be683Eda21088B7E6', // V3.0 Update - Nov 2022
'0x17D36875D723Cf0dA250d404Ef4cA0aABE105837', // V3.1 Update - Jan 2023
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.PolygonMumbai_DEPRECATED],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.PolygonMumbai_DEPRECATED],
deploymentBlock:
RailgunProxyDeploymentBlock[NetworkName.PolygonMumbai_DEPRECATED],
isDevOnlyNetwork: true,
Expand Down Expand Up @@ -638,6 +731,11 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
'0x7E77d890179Aa683ac2B9A608bd8121255CAa917', // Initial deployment (post v3.0)
'0x3eAf99B5EDc79D833AA8B6d18F0a8dd041e13eF6', // V3.1 Update - Jan 2023
],
supports7702: false,
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.ArbitrumGoerli_DEPRECATED],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.ArbitrumGoerli_DEPRECATED],
deploymentBlock:
RailgunProxyDeploymentBlock[NetworkName.ArbitrumGoerli_DEPRECATED],
isTestnet: true,
Expand Down Expand Up @@ -674,8 +772,13 @@ export const NETWORK_CONFIG: Record<NetworkName, Network> = {
decimals: 18,
},
proxyContract: RailgunProxyContract[NetworkName.Hardhat],
supports7702: false,
relayAdaptContract: RelayAdaptContract[NetworkName.Hardhat],
relayAdaptHistory: [''],
relayAdapt7702Contract: RelayAdapt7702Contract[NetworkName.Hardhat],
relayAdapt7702History: [], // no need for history, theres a set on chain?
railgunRegistryContract:
RailgunRegistryContract[NetworkName.Hardhat],
deploymentBlock: RailgunProxyDeploymentBlock[NetworkName.Hardhat],
isDevOnlyNetwork: true,
isTestnet: true,
Expand Down
12 changes: 11 additions & 1 deletion src/models/response-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export enum EVMGasType {
Type0 = 0,
Type1 = 1,
Type2 = 2,
Type4 = 4,
}

export type TransactionGasDetails =
| TransactionGasDetailsType0
| TransactionGasDetailsType1
| TransactionGasDetailsType2;
| TransactionGasDetailsType2
| TransactionGasDetailsType4;

export type TransactionGasDetailsType0 = {
evmGasType: EVMGasType.Type0;
Expand All @@ -44,6 +46,13 @@ export type TransactionGasDetailsType2 = {
maxPriorityFeePerGas: bigint;
};

export type TransactionGasDetailsType4 = {
evmGasType: EVMGasType.Type4;
gasEstimate: bigint;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
};

export type FeeTokenDetails = {
tokenAddress: string;
feePerUnitGas: bigint;
Expand Down Expand Up @@ -315,3 +324,4 @@ export type CommitmentSummary = {
commitmentCiphertext: CommitmentCiphertextV2 | CommitmentCiphertextV3;
commitmentHash: string;
};

3 changes: 2 additions & 1 deletion src/utils/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const calculateGasPrice = (gasDetails: TransactionGasDetails) => {
case EVMGasType.Type1: {
return gasDetails.gasPrice;
}
case EVMGasType.Type2: {
case EVMGasType.Type2:
case EVMGasType.Type4: {
return gasDetails.maxFeePerGas;
}
}
Expand Down
37 changes: 22 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,18 @@
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.1.tgz#2f4f65bb08bc368ac39c96da7b2f09140b26851b"
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==

"@types/node@18.15.13":
version "18.15.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469"
integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==

"@types/node@20.3.1":
version "20.3.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.1.tgz#e8a83f1aa8b649377bb1fb5d7bac5cb90e784dfe"
integrity sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==

"@types/node@22.7.5":
version "22.7.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b"
integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==
dependencies:
undici-types "~6.19.2"

"@types/semver@^7.3.12":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a"
Expand Down Expand Up @@ -1131,17 +1133,17 @@ esutils@^2.0.2:
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==

ethers@6.13.1:
version "6.13.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.1.tgz#2b9f9c7455cde9d38b30fe6589972eb083652961"
integrity sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A==
ethers@6.14.3:
version "6.14.3"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.14.3.tgz#7c4443c165ee59b2964e691600fd4586004b2000"
integrity sha512-qq7ft/oCJohoTcsNPFaXSQUm457MA5iWqkf1Mb11ujONdg7jBI6sAOrHaTi3j0CBqIGFSCeR/RMc+qwRRub7IA==
dependencies:
"@adraffy/ens-normalize" "1.10.1"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@types/node" "18.15.13"
"@types/node" "22.7.5"
aes-js "4.0.0-beta.5"
tslib "2.4.0"
tslib "2.7.0"
ws "8.17.1"

fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
Expand Down Expand Up @@ -2571,10 +2573,10 @@ tsconfig-paths@^3.10.1, tsconfig-paths@^3.14.1:
minimist "^1.2.6"
strip-bom "^3.0.0"

tslib@2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==
tslib@2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01"
integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==

tslib@^1.8.1:
version "1.14.1"
Expand Down Expand Up @@ -2637,6 +2639,11 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

undici-types@~6.19.2:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==

uniq@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
Expand Down