Revert "Feat/537: remove old contract for collateral bridge (#998)"
This reverts commit 1be1a78a69
.
This commit is contained in:
parent
900205ed12
commit
94373c1886
@ -3,6 +3,7 @@ NX_VEGA_ENV=TESTNET
|
|||||||
NX_ETHEREUM_PROVIDER_URL=http://localhost:8545
|
NX_ETHEREUM_PROVIDER_URL=http://localhost:8545
|
||||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||||
NX_FAIRGROUND=false
|
NX_FAIRGROUND=false
|
||||||
|
NX_IS_NEW_BRIDGE_CONTRACT=true
|
||||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||||
|
|
||||||
NX_VEGA_URL=http://localhost:3028/query
|
NX_VEGA_URL=http://localhost:3028/query
|
||||||
|
@ -5,6 +5,7 @@ NX_VEGA_URL=https://lb.testnet.vega.xyz/query
|
|||||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||||
NX_FAIRGROUND=false
|
NX_FAIRGROUND=false
|
||||||
|
NX_IS_NEW_BRIDGE_CONTRACT=true
|
||||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
NX_VEGA_WALLET_URL=http://localhost:1789/api/v1
|
NX_VEGA_WALLET_URL=http://localhost:1789/api/v1
|
||||||
|
@ -3,6 +3,7 @@ NX_VEGA_ENV=TESTNET
|
|||||||
NX_ETHEREUM_PROVIDER_URL=http://localhost:8545
|
NX_ETHEREUM_PROVIDER_URL=http://localhost:8545
|
||||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||||
NX_FAIRGROUND=false
|
NX_FAIRGROUND=false
|
||||||
|
NX_IS_NEW_BRIDGE_CONTRACT=true
|
||||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
|
|
||||||
|
@ -6,3 +6,4 @@ NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.
|
|||||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
|
NX_IS_NEW_BRIDGE_CONTRACT=false
|
||||||
|
@ -66,6 +66,9 @@ export const ENV = {
|
|||||||
MOCK: TRUTHY.includes(windowOrDefault('NX_MOCKED')),
|
MOCK: TRUTHY.includes(windowOrDefault('NX_MOCKED')),
|
||||||
FAIRGROUND: TRUTHY.includes(windowOrDefault('NX_FAIRGROUND')),
|
FAIRGROUND: TRUTHY.includes(windowOrDefault('NX_FAIRGROUND')),
|
||||||
NETWORK_LIMITS: TRUTHY.includes(windowOrDefault('NX_NETWORK_LIMITS')),
|
NETWORK_LIMITS: TRUTHY.includes(windowOrDefault('NX_NETWORK_LIMITS')),
|
||||||
|
USE_NEW_BRIDGE_CONTRACT: TRUTHY.includes(
|
||||||
|
process.env['NX_IS_NEW_BRIDGE_CONTRACT'] as string
|
||||||
|
),
|
||||||
},
|
},
|
||||||
addresses:
|
addresses:
|
||||||
ContractAddresses[(envName === 'local' ? 'CUSTOM' : envName) as Networks],
|
ContractAddresses[(envName === 'local' ? 'CUSTOM' : envName) as Networks],
|
||||||
|
@ -15,6 +15,7 @@ import type {
|
|||||||
WithdrawPageVariables,
|
WithdrawPageVariables,
|
||||||
} from './__generated__/WithdrawPage';
|
} from './__generated__/WithdrawPage';
|
||||||
import { WithdrawManager } from '@vegaprotocol/withdraws';
|
import { WithdrawManager } from '@vegaprotocol/withdraws';
|
||||||
|
import { Flags } from '../../config';
|
||||||
|
|
||||||
const Withdraw = () => {
|
const Withdraw = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -149,7 +150,11 @@ export const WithdrawContainer = ({ currVegaKey }: WithdrawContainerProps) => {
|
|||||||
</Callout>
|
</Callout>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<WithdrawManager assets={data.assets || []} accounts={accounts} />
|
<WithdrawManager
|
||||||
|
assets={data.assets || []}
|
||||||
|
accounts={accounts}
|
||||||
|
isNewContract={Flags.USE_NEW_BRIDGE_CONTRACT}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,7 @@ import { truncateMiddle } from '../../lib/truncate-middle';
|
|||||||
import type { Withdrawals_party_withdrawals } from '@vegaprotocol/withdraws';
|
import type { Withdrawals_party_withdrawals } from '@vegaprotocol/withdraws';
|
||||||
import { useCompleteWithdraw, useWithdrawals } from '@vegaprotocol/withdraws';
|
import { useCompleteWithdraw, useWithdrawals } from '@vegaprotocol/withdraws';
|
||||||
import { WithdrawalStatus } from '../../__generated__/globalTypes';
|
import { WithdrawalStatus } from '../../__generated__/globalTypes';
|
||||||
|
import { Flags } from '../../config';
|
||||||
|
|
||||||
const Withdrawals = () => {
|
const Withdrawals = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -33,7 +34,7 @@ const Withdrawals = () => {
|
|||||||
|
|
||||||
const WithdrawPendingContainer = () => {
|
const WithdrawPendingContainer = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { submit, Dialog } = useCompleteWithdraw();
|
const { submit, Dialog } = useCompleteWithdraw(Flags.USE_NEW_BRIDGE_CONTRACT);
|
||||||
const { data, loading, error } = useWithdrawals();
|
const { data, loading, error } = useWithdrawals();
|
||||||
|
|
||||||
const withdrawals = React.useMemo(() => {
|
const withdrawals = React.useMemo(() => {
|
||||||
@ -92,7 +93,7 @@ interface WithdrawalProps {
|
|||||||
export const Withdrawal = ({ withdrawal, complete }: WithdrawalProps) => {
|
export const Withdrawal = ({ withdrawal, complete }: WithdrawalProps) => {
|
||||||
const { ETHERSCAN_URL } = useEnvironment();
|
const { ETHERSCAN_URL } = useEnvironment();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
let status;
|
let status = null;
|
||||||
let footer = null;
|
let footer = null;
|
||||||
|
|
||||||
if (withdrawal.pendingOnForeignChain) {
|
if (withdrawal.pendingOnForeignChain) {
|
||||||
|
@ -87,6 +87,7 @@ export const WithdrawPageContainer = ({
|
|||||||
assets={data.assets}
|
assets={data.assets}
|
||||||
accounts={data.party?.accounts || []}
|
accounts={data.party?.accounts || []}
|
||||||
initialAssetId={assetId}
|
initialAssetId={assetId}
|
||||||
|
isNewContract={true}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -18,7 +18,7 @@ export const useDepositBalances = (isFaucetable: boolean) => {
|
|||||||
isAssetTypeERC20(asset) ? asset : undefined,
|
isAssetTypeERC20(asset) ? asset : undefined,
|
||||||
isFaucetable
|
isFaucetable
|
||||||
);
|
);
|
||||||
const bridgeContract = useBridgeContract();
|
const bridgeContract = useBridgeContract(true);
|
||||||
const getAllowance = useGetAllowance(tokenContract, asset);
|
const getAllowance = useGetAllowance(tokenContract, asset);
|
||||||
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
|
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
|
||||||
const getDepositMaximum = useGetDepositMaximum(bridgeContract, asset);
|
const getDepositMaximum = useGetDepositMaximum(bridgeContract, asset);
|
||||||
|
@ -3,10 +3,13 @@ import * as Sentry from '@sentry/react';
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import type { Asset } from '@vegaprotocol/react-helpers';
|
import type { Asset } from '@vegaprotocol/react-helpers';
|
||||||
import { addDecimal } from '@vegaprotocol/react-helpers';
|
import { addDecimal } from '@vegaprotocol/react-helpers';
|
||||||
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
import type {
|
||||||
|
CollateralBridge,
|
||||||
|
CollateralBridgeNew,
|
||||||
|
} from '@vegaprotocol/smart-contracts';
|
||||||
|
|
||||||
export const useGetDepositMaximum = (
|
export const useGetDepositMaximum = (
|
||||||
contract: CollateralBridge | null,
|
contract: CollateralBridge | CollateralBridgeNew | null,
|
||||||
asset: Asset | undefined
|
asset: Asset | undefined
|
||||||
) => {
|
) => {
|
||||||
const getDepositMaximum = useCallback(async () => {
|
const getDepositMaximum = useCallback(async () => {
|
||||||
|
@ -17,7 +17,10 @@ import {
|
|||||||
useEthereumTransaction,
|
useEthereumTransaction,
|
||||||
useTokenContract,
|
useTokenContract,
|
||||||
} from '@vegaprotocol/web3';
|
} from '@vegaprotocol/web3';
|
||||||
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
import type {
|
||||||
|
CollateralBridge,
|
||||||
|
CollateralBridgeNew,
|
||||||
|
} from '@vegaprotocol/smart-contracts';
|
||||||
import { prepend0x } from '@vegaprotocol/smart-contracts';
|
import { prepend0x } from '@vegaprotocol/smart-contracts';
|
||||||
import { useDepositStore } from './deposit-store';
|
import { useDepositStore } from './deposit-store';
|
||||||
import { useGetBalanceOfERC20Token } from './use-get-balance-of-erc20-token';
|
import { useGetBalanceOfERC20Token } from './use-get-balance-of-erc20-token';
|
||||||
@ -39,7 +42,7 @@ const DEPOSIT_EVENT_SUB = gql`
|
|||||||
export const useSubmitDeposit = () => {
|
export const useSubmitDeposit = () => {
|
||||||
const { asset, update } = useDepositStore();
|
const { asset, update } = useDepositStore();
|
||||||
const { config } = useEthereumConfig();
|
const { config } = useEthereumConfig();
|
||||||
const bridgeContract = useBridgeContract();
|
const bridgeContract = useBridgeContract(true);
|
||||||
const tokenContract = useTokenContract(
|
const tokenContract = useTokenContract(
|
||||||
isAssetTypeERC20(asset) ? asset : undefined,
|
isAssetTypeERC20(asset) ? asset : undefined,
|
||||||
true
|
true
|
||||||
@ -51,12 +54,10 @@ export const useSubmitDeposit = () => {
|
|||||||
|
|
||||||
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
|
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
|
||||||
|
|
||||||
const transaction = useEthereumTransaction<CollateralBridge, 'deposit_asset'>(
|
const transaction = useEthereumTransaction<
|
||||||
bridgeContract,
|
CollateralBridgeNew | CollateralBridge,
|
||||||
'deposit_asset',
|
'deposit_asset'
|
||||||
config?.confirmations,
|
>(bridgeContract, 'deposit_asset', config?.confirmations, true);
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
useSubscription<DepositEvent, DepositEventVariables>(DEPOSIT_EVENT_SUB, {
|
useSubscription<DepositEvent, DepositEventVariables>(DEPOSIT_EVENT_SUB, {
|
||||||
variables: { partyId: partyId ? remove0x(partyId) : '' },
|
variables: { partyId: partyId ? remove0x(partyId) : '' },
|
||||||
|
@ -5,11 +5,66 @@
|
|||||||
"internalType": "address payable",
|
"internalType": "address payable",
|
||||||
"name": "erc20_asset_pool",
|
"name": "erc20_asset_pool",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "multisig_control",
|
||||||
|
"type": "address"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
"type": "constructor"
|
"type": "constructor"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "new_maximum",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Deposit_Maximum_Set",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "new_minimum",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Deposit_Minimum_Set",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"anonymous": false,
|
"anonymous": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
@ -41,31 +96,6 @@
|
|||||||
"name": "Asset_Deposited",
|
"name": "Asset_Deposited",
|
||||||
"type": "event"
|
"type": "event"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"internalType": "address",
|
|
||||||
"name": "asset_source",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "lifetime_limit",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "withdraw_threshold",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Asset_Limits_Updated",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"anonymous": false,
|
"anonymous": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
@ -141,70 +171,6 @@
|
|||||||
"name": "Asset_Withdrawn",
|
"name": "Asset_Withdrawn",
|
||||||
"type": "event"
|
"type": "event"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "Bridge_Resumed",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "Bridge_Stopped",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "withdraw_delay",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Bridge_Withdraw_Delay_Set",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"internalType": "address",
|
|
||||||
"name": "depositor",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Depositor_Exempted",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"internalType": "address",
|
|
||||||
"name": "depositor",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Depositor_Exemption_Revoked",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [],
|
|
||||||
"name": "default_withdraw_delay",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -228,45 +194,6 @@
|
|||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"inputs": [],
|
|
||||||
"name": "erc20_asset_pool_address",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"internalType": "address payable",
|
|
||||||
"name": "",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [],
|
|
||||||
"name": "exempt_depositor",
|
|
||||||
"outputs": [],
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"internalType": "address",
|
|
||||||
"name": "asset_source",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "get_asset_deposit_lifetime_limit",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -286,6 +213,44 @@
|
|||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "get_deposit_maximum",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "get_deposit_minimum",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"inputs": [],
|
"inputs": [],
|
||||||
"name": "get_multisig_control_address",
|
"name": "get_multisig_control_address",
|
||||||
@ -318,61 +283,6 @@
|
|||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"internalType": "address",
|
|
||||||
"name": "asset_source",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "get_withdraw_threshold",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "nonce",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "bytes",
|
|
||||||
"name": "signatures",
|
|
||||||
"type": "bytes"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "global_resume",
|
|
||||||
"outputs": [],
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "nonce",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "bytes",
|
|
||||||
"name": "signatures",
|
|
||||||
"type": "bytes"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "global_stop",
|
|
||||||
"outputs": [],
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -392,38 +302,6 @@
|
|||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"internalType": "address",
|
|
||||||
"name": "depositor",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "is_exempt_depositor",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"internalType": "bool",
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [],
|
|
||||||
"name": "is_stopped",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"internalType": "bool",
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -436,16 +314,6 @@
|
|||||||
"name": "vega_asset_id",
|
"name": "vega_asset_id",
|
||||||
"type": "bytes32"
|
"type": "bytes32"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "lifetime_limit",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "withdraw_threshold",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "nonce",
|
"name": "nonce",
|
||||||
@ -486,8 +354,29 @@
|
|||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"inputs": [],
|
"inputs": [
|
||||||
"name": "revoke_exempt_depositor",
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "maximum_amount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "set_deposit_maximum",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
@ -501,12 +390,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "lifetime_limit",
|
"name": "minimum_amount",
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "threshold",
|
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -520,30 +404,7 @@
|
|||||||
"type": "bytes"
|
"type": "bytes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "set_asset_limits",
|
"name": "set_deposit_minimum",
|
||||||
"outputs": [],
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "delay",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "nonce",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "bytes",
|
|
||||||
"name": "signatures",
|
|
||||||
"type": "bytes"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "set_withdraw_delay",
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
@ -565,11 +426,6 @@
|
|||||||
"name": "target",
|
"name": "target",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "creation",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "nonce",
|
"name": "nonce",
|
||||||
|
589
libs/smart-contracts/src/abis/erc20_bridge_new_abi.json
Normal file
589
libs/smart-contracts/src/abis/erc20_bridge_new_abi.json
Normal file
@ -0,0 +1,589 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address payable",
|
||||||
|
"name": "erc20_asset_pool",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "constructor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "user_address",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "amount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "vega_public_key",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Deposited",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "lifetime_limit",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "withdraw_threshold",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Limits_Updated",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "vega_asset_id",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Listed",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Removed",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "user_address",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "amount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Asset_Withdrawn",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "Bridge_Resumed",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "Bridge_Stopped",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "withdraw_delay",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Bridge_Withdraw_Delay_Set",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "depositor",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Depositor_Exempted",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "depositor",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Depositor_Exemption_Revoked",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "default_withdraw_delay",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "amount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "vega_public_key",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "deposit_asset",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "erc20_asset_pool_address",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address payable",
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "exempt_depositor",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "get_asset_deposit_lifetime_limit",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "vega_asset_id",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "get_asset_source",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "get_multisig_control_address",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "get_vega_asset_id",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "get_withdraw_threshold",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "global_resume",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "global_stop",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "is_asset_listed",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bool",
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "depositor",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "is_exempt_depositor",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bool",
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "is_stopped",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bool",
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "vega_asset_id",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "lifetime_limit",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "withdraw_threshold",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "list_asset",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "remove_asset",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "revoke_exempt_depositor",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "lifetime_limit",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "threshold",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "set_asset_limits",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "delay",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "set_withdraw_delay",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "asset_source",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "amount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "address",
|
||||||
|
"name": "target",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "creation",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "nonce",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "bytes",
|
||||||
|
"name": "signatures",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "withdraw_asset",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
]
|
54
libs/smart-contracts/src/contracts/collateral-bridge-new.ts
Normal file
54
libs/smart-contracts/src/contracts/collateral-bridge-new.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import type { BigNumber } from 'ethers';
|
||||||
|
import { ethers } from 'ethers';
|
||||||
|
import abi from '../abis/erc20_bridge_new_abi.json';
|
||||||
|
|
||||||
|
export class CollateralBridgeNew {
|
||||||
|
public contract: ethers.Contract;
|
||||||
|
public isNewContract = true;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
address: string,
|
||||||
|
signerOrProvider: ethers.Signer | ethers.providers.Provider
|
||||||
|
) {
|
||||||
|
this.contract = new ethers.Contract(address, abi, signerOrProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
deposit_asset(assetSource: string, amount: string, vegaPublicKey: string) {
|
||||||
|
return this.contract.deposit_asset(assetSource, amount, vegaPublicKey);
|
||||||
|
}
|
||||||
|
get_asset_source(vegaAssetId: string) {
|
||||||
|
return this.contract.get_asset_source(vegaAssetId);
|
||||||
|
}
|
||||||
|
get_deposit_maximum(assetSource: string): Promise<BigNumber> {
|
||||||
|
return this.contract.get_asset_deposit_lifetime_limit(assetSource);
|
||||||
|
}
|
||||||
|
get_multisig_control_address() {
|
||||||
|
return this.contract.get_multisig_control_address();
|
||||||
|
}
|
||||||
|
get_vega_asset_id(address: string) {
|
||||||
|
return this.contract.get_vega_asset_id(address);
|
||||||
|
}
|
||||||
|
is_asset_listed(address: string) {
|
||||||
|
return this.contract.is_asset_listed(address);
|
||||||
|
}
|
||||||
|
get_withdraw_threshold(assetSource: string) {
|
||||||
|
return this.contract.get_withdraw_threshold(assetSource);
|
||||||
|
}
|
||||||
|
withdraw_asset(
|
||||||
|
assetSource: string,
|
||||||
|
amount: string,
|
||||||
|
target: string,
|
||||||
|
creation: string,
|
||||||
|
nonce: string,
|
||||||
|
signatures: string
|
||||||
|
) {
|
||||||
|
return this.contract.withdraw_asset(
|
||||||
|
assetSource,
|
||||||
|
amount,
|
||||||
|
target,
|
||||||
|
creation,
|
||||||
|
nonce,
|
||||||
|
signatures
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -4,13 +4,15 @@ import abi from '../abis/erc20_bridge_abi.json';
|
|||||||
|
|
||||||
export class CollateralBridge {
|
export class CollateralBridge {
|
||||||
public contract: ethers.Contract;
|
public contract: ethers.Contract;
|
||||||
public isNewContract = true;
|
public isNewContract = false;
|
||||||
|
public address: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address: string,
|
address: string,
|
||||||
signerOrProvider: ethers.Signer | ethers.providers.Provider
|
signerOrProvider: ethers.Signer | ethers.providers.Provider
|
||||||
) {
|
) {
|
||||||
this.contract = new ethers.Contract(address, abi, signerOrProvider);
|
this.contract = new ethers.Contract(address, abi, signerOrProvider);
|
||||||
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
deposit_asset(assetSource: string, amount: string, vegaPublicKey: string) {
|
deposit_asset(assetSource: string, amount: string, vegaPublicKey: string) {
|
||||||
@ -20,7 +22,10 @@ export class CollateralBridge {
|
|||||||
return this.contract.get_asset_source(vegaAssetId);
|
return this.contract.get_asset_source(vegaAssetId);
|
||||||
}
|
}
|
||||||
get_deposit_maximum(assetSource: string): Promise<BigNumber> {
|
get_deposit_maximum(assetSource: string): Promise<BigNumber> {
|
||||||
return this.contract.get_asset_deposit_lifetime_limit(assetSource);
|
return this.contract.get_deposit_maximum(assetSource);
|
||||||
|
}
|
||||||
|
get_deposit_minimum(assetSource: string): Promise<BigNumber> {
|
||||||
|
return this.contract.get_deposit_minimum(assetSource);
|
||||||
}
|
}
|
||||||
get_multisig_control_address() {
|
get_multisig_control_address() {
|
||||||
return this.contract.get_multisig_control_address();
|
return this.contract.get_multisig_control_address();
|
||||||
@ -38,7 +43,6 @@ export class CollateralBridge {
|
|||||||
assetSource: string,
|
assetSource: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
target: string,
|
target: string,
|
||||||
creation: string,
|
|
||||||
nonce: string,
|
nonce: string,
|
||||||
signatures: string
|
signatures: string
|
||||||
) {
|
) {
|
||||||
@ -46,7 +50,6 @@ export class CollateralBridge {
|
|||||||
assetSource,
|
assetSource,
|
||||||
amount,
|
amount,
|
||||||
target,
|
target,
|
||||||
creation,
|
|
||||||
nonce,
|
nonce,
|
||||||
signatures
|
signatures
|
||||||
);
|
);
|
||||||
|
@ -2,6 +2,7 @@ export * from './vega-web3-types';
|
|||||||
|
|
||||||
export * from './claim';
|
export * from './claim';
|
||||||
export * from './collateral-bridge';
|
export * from './collateral-bridge';
|
||||||
|
export * from './collateral-bridge-new';
|
||||||
export * from './staking-bridge';
|
export * from './staking-bridge';
|
||||||
export * from './token-vesting';
|
export * from './token-vesting';
|
||||||
export * from './token';
|
export * from './token';
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
import {
|
||||||
|
CollateralBridge,
|
||||||
|
CollateralBridgeNew,
|
||||||
|
} from '@vegaprotocol/smart-contracts';
|
||||||
import { useWeb3React } from '@web3-react/core';
|
import { useWeb3React } from '@web3-react/core';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useEthereumConfig } from './use-ethereum-config';
|
import { useEthereumConfig } from './use-ethereum-config';
|
||||||
|
|
||||||
export const useBridgeContract = () => {
|
export const useBridgeContract = (isNewContract: boolean) => {
|
||||||
const { provider } = useWeb3React();
|
const { provider } = useWeb3React();
|
||||||
const { config } = useEthereumConfig();
|
const { config } = useEthereumConfig();
|
||||||
|
|
||||||
@ -14,11 +17,16 @@ export const useBridgeContract = () => {
|
|||||||
|
|
||||||
const signer = provider.getSigner();
|
const signer = provider.getSigner();
|
||||||
|
|
||||||
return new CollateralBridge(
|
return isNewContract
|
||||||
config.collateral_bridge_contract.address,
|
? new CollateralBridgeNew(
|
||||||
signer || provider
|
config.collateral_bridge_contract.address,
|
||||||
);
|
signer || provider
|
||||||
}, [provider, config]);
|
)
|
||||||
|
: new CollateralBridge(
|
||||||
|
config.collateral_bridge_contract.address,
|
||||||
|
signer || provider
|
||||||
|
);
|
||||||
|
}, [provider, config, isNewContract]);
|
||||||
|
|
||||||
return contract;
|
return contract;
|
||||||
};
|
};
|
||||||
|
@ -34,10 +34,6 @@ export interface Erc20Approval_erc20WithdrawalApproval {
|
|||||||
* Timestamp in seconds for expiry of the approval
|
* Timestamp in seconds for expiry of the approval
|
||||||
*/
|
*/
|
||||||
expiry: string;
|
expiry: string;
|
||||||
/**
|
|
||||||
* Timestamp at which the withdrawal was created
|
|
||||||
*/
|
|
||||||
creation: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Erc20Approval {
|
export interface Erc20Approval {
|
||||||
|
52
libs/withdraws/src/lib/__generated__/Erc20ApprovalNew.ts
generated
Normal file
52
libs/withdraws/src/lib/__generated__/Erc20ApprovalNew.ts
generated
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @generated
|
||||||
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
|
// ====================================================
|
||||||
|
// GraphQL query operation: Erc20ApprovalNew
|
||||||
|
// ====================================================
|
||||||
|
|
||||||
|
export interface Erc20ApprovalNew_erc20WithdrawalApproval {
|
||||||
|
__typename: "Erc20WithdrawalApproval";
|
||||||
|
/**
|
||||||
|
* The source asset in the ethereum network
|
||||||
|
*/
|
||||||
|
assetSource: string;
|
||||||
|
/**
|
||||||
|
* The amount to be withdrawn
|
||||||
|
*/
|
||||||
|
amount: string;
|
||||||
|
/**
|
||||||
|
* The nonce to be used in the request
|
||||||
|
*/
|
||||||
|
nonce: string;
|
||||||
|
/**
|
||||||
|
* Signature aggregate from the nodes, in the following format:
|
||||||
|
* 0x + sig1 + sig2 + ... + sigN
|
||||||
|
*/
|
||||||
|
signatures: string;
|
||||||
|
/**
|
||||||
|
* The target address which will receive the funds
|
||||||
|
*/
|
||||||
|
targetAddress: string;
|
||||||
|
/**
|
||||||
|
* Timestamp in seconds for expiry of the approval
|
||||||
|
*/
|
||||||
|
expiry: string;
|
||||||
|
/**
|
||||||
|
* Timestamp at which the withdrawal was created
|
||||||
|
*/
|
||||||
|
creation: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Erc20ApprovalNew {
|
||||||
|
/**
|
||||||
|
* find an erc20 withdrawal approval using its withdrawal id
|
||||||
|
*/
|
||||||
|
erc20WithdrawalApproval: Erc20ApprovalNew_erc20WithdrawalApproval | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Erc20ApprovalNewVariables {
|
||||||
|
withdrawalId: string;
|
||||||
|
}
|
@ -2,6 +2,19 @@ import { gql } from '@apollo/client';
|
|||||||
|
|
||||||
export const ERC20_APPROVAL_QUERY = gql`
|
export const ERC20_APPROVAL_QUERY = gql`
|
||||||
query Erc20Approval($withdrawalId: ID!) {
|
query Erc20Approval($withdrawalId: ID!) {
|
||||||
|
erc20WithdrawalApproval(withdrawalId: $withdrawalId) {
|
||||||
|
assetSource
|
||||||
|
amount
|
||||||
|
nonce
|
||||||
|
signatures
|
||||||
|
targetAddress
|
||||||
|
expiry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const ERC20_APPROVAL_QUERY_NEW = gql`
|
||||||
|
query Erc20ApprovalNew($withdrawalId: ID!) {
|
||||||
erc20WithdrawalApproval(withdrawalId: $withdrawalId) {
|
erc20WithdrawalApproval(withdrawalId: $withdrawalId) {
|
||||||
assetSource
|
assetSource
|
||||||
amount
|
amount
|
||||||
|
@ -5,10 +5,10 @@ import { MockedProvider } from '@apollo/client/testing';
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { useCompleteWithdraw } from './use-complete-withdraw';
|
import { useCompleteWithdraw } from './use-complete-withdraw';
|
||||||
import type { Erc20Approval } from './__generated__/Erc20Approval';
|
import type { Erc20Approval } from './__generated__/Erc20Approval';
|
||||||
import { ERC20_APPROVAL_QUERY } from './queries';
|
import { ERC20_APPROVAL_QUERY_NEW } from './queries';
|
||||||
import * as web3 from '@vegaprotocol/web3';
|
import * as web3 from '@vegaprotocol/web3';
|
||||||
import * as sentry from '@sentry/react';
|
import * as sentry from '@sentry/react';
|
||||||
import type { Erc20Approval_erc20WithdrawalApproval } from './__generated__/Erc20Approval';
|
import type { Erc20ApprovalNew_erc20WithdrawalApproval } from './__generated__/Erc20ApprovalNew';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/web3', () => ({
|
jest.mock('@vegaprotocol/web3', () => ({
|
||||||
useBridgeContract: jest.fn().mockReturnValue({
|
useBridgeContract: jest.fn().mockReturnValue({
|
||||||
@ -22,12 +22,12 @@ function setup(mocks?: MockedResponse[]) {
|
|||||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||||
<MockedProvider mocks={mocks}>{children}</MockedProvider>
|
<MockedProvider mocks={mocks}>{children}</MockedProvider>
|
||||||
);
|
);
|
||||||
return renderHook(() => useCompleteWithdraw(), { wrapper });
|
return renderHook(() => useCompleteWithdraw(true), { wrapper });
|
||||||
}
|
}
|
||||||
|
|
||||||
it('Should perform the Ethereum transaction with the fetched approval', async () => {
|
it('Should perform the Ethereum transaction with the fetched approval', async () => {
|
||||||
const withdrawalId = 'withdrawal-id';
|
const withdrawalId = 'withdrawal-id';
|
||||||
const erc20WithdrawalApproval: Erc20Approval_erc20WithdrawalApproval = {
|
const erc20WithdrawalApproval: Erc20ApprovalNew_erc20WithdrawalApproval = {
|
||||||
__typename: 'Erc20WithdrawalApproval',
|
__typename: 'Erc20WithdrawalApproval',
|
||||||
assetSource: 'asset-source',
|
assetSource: 'asset-source',
|
||||||
amount: '100',
|
amount: '100',
|
||||||
@ -39,7 +39,7 @@ it('Should perform the Ethereum transaction with the fetched approval', async ()
|
|||||||
};
|
};
|
||||||
const mockERC20Approval: MockedResponse<Erc20Approval> = {
|
const mockERC20Approval: MockedResponse<Erc20Approval> = {
|
||||||
request: {
|
request: {
|
||||||
query: ERC20_APPROVAL_QUERY,
|
query: ERC20_APPROVAL_QUERY_NEW,
|
||||||
variables: { withdrawalId },
|
variables: { withdrawalId },
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
@ -75,7 +75,7 @@ it('Captures an error if the erc20Withdrawal is not found', async () => {
|
|||||||
const withdrawalId = 'withdrawal-id';
|
const withdrawalId = 'withdrawal-id';
|
||||||
const mockERC20Approval: MockedResponse<Erc20Approval> = {
|
const mockERC20Approval: MockedResponse<Erc20Approval> = {
|
||||||
request: {
|
request: {
|
||||||
query: ERC20_APPROVAL_QUERY,
|
query: ERC20_APPROVAL_QUERY_NEW,
|
||||||
variables: { withdrawalId },
|
variables: { withdrawalId },
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
@ -106,7 +106,7 @@ it('Captures an error if erc20 approval query fails', async () => {
|
|||||||
const withdrawalId = 'withdrawal-id';
|
const withdrawalId = 'withdrawal-id';
|
||||||
const mockERC20Approval: MockedResponse<Erc20Approval> = {
|
const mockERC20Approval: MockedResponse<Erc20Approval> = {
|
||||||
request: {
|
request: {
|
||||||
query: ERC20_APPROVAL_QUERY,
|
query: ERC20_APPROVAL_QUERY_NEW,
|
||||||
variables: { withdrawalId },
|
variables: { withdrawalId },
|
||||||
},
|
},
|
||||||
error: new Error('query failed'),
|
error: new Error('query failed'),
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
import { gql, useApolloClient } from '@apollo/client';
|
import { gql, useApolloClient } from '@apollo/client';
|
||||||
import { captureException } from '@sentry/react';
|
import { captureException } from '@sentry/react';
|
||||||
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
import type {
|
||||||
|
CollateralBridge,
|
||||||
|
CollateralBridgeNew,
|
||||||
|
} from '@vegaprotocol/smart-contracts';
|
||||||
import { useBridgeContract, useEthereumTransaction } from '@vegaprotocol/web3';
|
import { useBridgeContract, useEthereumTransaction } from '@vegaprotocol/web3';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { ERC20_APPROVAL_QUERY } from './queries';
|
import { ERC20_APPROVAL_QUERY, ERC20_APPROVAL_QUERY_NEW } from './queries';
|
||||||
import type {
|
import type {
|
||||||
Erc20Approval,
|
Erc20Approval,
|
||||||
Erc20ApprovalVariables,
|
Erc20ApprovalVariables,
|
||||||
} from './__generated__/Erc20Approval';
|
} from './__generated__/Erc20Approval';
|
||||||
|
import type { Erc20ApprovalNew } from './__generated__/Erc20ApprovalNew';
|
||||||
import type { PendingWithdrawal } from './__generated__/PendingWithdrawal';
|
import type { PendingWithdrawal } from './__generated__/PendingWithdrawal';
|
||||||
|
|
||||||
export const PENDING_WITHDRAWAL_FRAGMMENT = gql`
|
export const PENDING_WITHDRAWAL_FRAGMMENT = gql`
|
||||||
@ -17,12 +21,12 @@ export const PENDING_WITHDRAWAL_FRAGMMENT = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const useCompleteWithdraw = () => {
|
export const useCompleteWithdraw = (isNewContract: boolean) => {
|
||||||
const { query, cache } = useApolloClient();
|
const { query, cache } = useApolloClient();
|
||||||
const contract = useBridgeContract();
|
const contract = useBridgeContract(isNewContract);
|
||||||
const [id, setId] = useState('');
|
const [id, setId] = useState('');
|
||||||
const { transaction, perform, Dialog } = useEthereumTransaction<
|
const { transaction, perform, Dialog } = useEthereumTransaction<
|
||||||
CollateralBridge,
|
CollateralBridgeNew | CollateralBridge,
|
||||||
'withdraw_asset'
|
'withdraw_asset'
|
||||||
>(contract, 'withdraw_asset');
|
>(contract, 'withdraw_asset');
|
||||||
|
|
||||||
@ -33,8 +37,13 @@ export const useCompleteWithdraw = () => {
|
|||||||
if (!contract) {
|
if (!contract) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await query<Erc20Approval, Erc20ApprovalVariables>({
|
const res = await query<
|
||||||
query: ERC20_APPROVAL_QUERY,
|
Erc20Approval | Erc20ApprovalNew,
|
||||||
|
Erc20ApprovalVariables
|
||||||
|
>({
|
||||||
|
query: isNewContract
|
||||||
|
? ERC20_APPROVAL_QUERY_NEW
|
||||||
|
: ERC20_APPROVAL_QUERY,
|
||||||
variables: { withdrawalId },
|
variables: { withdrawalId },
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -43,19 +52,29 @@ export const useCompleteWithdraw = () => {
|
|||||||
throw new Error('Could not retrieve withdrawal approval');
|
throw new Error('Could not retrieve withdrawal approval');
|
||||||
}
|
}
|
||||||
|
|
||||||
perform(
|
if (contract.isNewContract && 'creation' in approval) {
|
||||||
approval.assetSource,
|
perform(
|
||||||
approval.amount,
|
approval.assetSource,
|
||||||
approval.targetAddress,
|
approval.amount,
|
||||||
approval.creation,
|
approval.targetAddress,
|
||||||
approval.nonce,
|
approval.creation,
|
||||||
approval.signatures
|
approval.nonce,
|
||||||
);
|
approval.signatures
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
perform(
|
||||||
|
approval.assetSource,
|
||||||
|
approval.amount,
|
||||||
|
approval.targetAddress,
|
||||||
|
approval.nonce,
|
||||||
|
approval.signatures
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
captureException(err);
|
captureException(err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[contract, query, perform]
|
[contract, query, isNewContract, perform]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -5,7 +5,7 @@ import type { Asset } from '@vegaprotocol/react-helpers';
|
|||||||
import { addDecimal } from '@vegaprotocol/react-helpers';
|
import { addDecimal } from '@vegaprotocol/react-helpers';
|
||||||
|
|
||||||
export const useGetWithdrawLimits = (asset?: Asset) => {
|
export const useGetWithdrawLimits = (asset?: Asset) => {
|
||||||
const contract = useBridgeContract();
|
const contract = useBridgeContract(true);
|
||||||
const getLimits = useCallback(async () => {
|
const getLimits = useCallback(async () => {
|
||||||
if (!contract || !asset || asset.source.__typename !== 'ERC20') {
|
if (!contract || !asset || asset.source.__typename !== 'ERC20') {
|
||||||
return;
|
return;
|
||||||
|
@ -2,12 +2,12 @@ import { act, renderHook } from '@testing-library/react';
|
|||||||
import type { MockedResponse } from '@apollo/client/testing';
|
import type { MockedResponse } from '@apollo/client/testing';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { ERC20_APPROVAL_QUERY } from './queries';
|
import { ERC20_APPROVAL_QUERY_NEW } from './queries';
|
||||||
import * as web3 from '@vegaprotocol/web3';
|
import * as web3 from '@vegaprotocol/web3';
|
||||||
import * as wallet from '@vegaprotocol/wallet';
|
import * as wallet from '@vegaprotocol/wallet';
|
||||||
import type { WithdrawalFields } from './use-withdraw';
|
import type { WithdrawalFields } from './use-withdraw';
|
||||||
import { useWithdraw } from './use-withdraw';
|
import { useWithdraw } from './use-withdraw';
|
||||||
import type { Erc20Approval } from './__generated__/Erc20Approval';
|
import type { Erc20ApprovalNew } from './__generated__/Erc20ApprovalNew';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/web3', () => ({
|
jest.mock('@vegaprotocol/web3', () => ({
|
||||||
useBridgeContract: jest.fn().mockReturnValue({
|
useBridgeContract: jest.fn().mockReturnValue({
|
||||||
@ -30,7 +30,7 @@ function setup(mocks?: MockedResponse[], cancelled = false) {
|
|||||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||||
<MockedProvider mocks={mocks}>{children}</MockedProvider>
|
<MockedProvider mocks={mocks}>{children}</MockedProvider>
|
||||||
);
|
);
|
||||||
return renderHook(() => useWithdraw(cancelled), { wrapper });
|
return renderHook(() => useWithdraw(cancelled, true), { wrapper });
|
||||||
}
|
}
|
||||||
|
|
||||||
const signature =
|
const signature =
|
||||||
@ -52,7 +52,7 @@ let mockPerform: jest.Mock;
|
|||||||
let mockEthReset: jest.Mock;
|
let mockEthReset: jest.Mock;
|
||||||
let mockVegaReset: jest.Mock;
|
let mockVegaReset: jest.Mock;
|
||||||
let withdrawalInput: WithdrawalFields;
|
let withdrawalInput: WithdrawalFields;
|
||||||
let mockERC20Approval: MockedResponse<Erc20Approval>;
|
let mockERC20Approval: MockedResponse<Erc20ApprovalNew>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
pubkey = 'pubkey';
|
pubkey = 'pubkey';
|
||||||
@ -85,7 +85,7 @@ beforeEach(() => {
|
|||||||
};
|
};
|
||||||
mockERC20Approval = {
|
mockERC20Approval = {
|
||||||
request: {
|
request: {
|
||||||
query: ERC20_APPROVAL_QUERY,
|
query: ERC20_APPROVAL_QUERY_NEW,
|
||||||
variables: { withdrawalId: derivedWithdrawalId },
|
variables: { withdrawalId: derivedWithdrawalId },
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
|
@ -3,13 +3,20 @@ import { determineId } from '@vegaprotocol/react-helpers';
|
|||||||
import { useBridgeContract, useEthereumTransaction } from '@vegaprotocol/web3';
|
import { useBridgeContract, useEthereumTransaction } from '@vegaprotocol/web3';
|
||||||
import { useVegaTransaction, useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaTransaction, useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { ERC20_APPROVAL_QUERY } from './queries';
|
import { ERC20_APPROVAL_QUERY, ERC20_APPROVAL_QUERY_NEW } from './queries';
|
||||||
import type {
|
import type {
|
||||||
Erc20Approval,
|
Erc20Approval,
|
||||||
Erc20Approval_erc20WithdrawalApproval,
|
|
||||||
Erc20ApprovalVariables,
|
Erc20ApprovalVariables,
|
||||||
|
Erc20Approval_erc20WithdrawalApproval,
|
||||||
} from './__generated__/Erc20Approval';
|
} from './__generated__/Erc20Approval';
|
||||||
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
import type {
|
||||||
|
Erc20ApprovalNew,
|
||||||
|
Erc20ApprovalNew_erc20WithdrawalApproval,
|
||||||
|
} from './__generated__/Erc20ApprovalNew';
|
||||||
|
import type {
|
||||||
|
CollateralBridge,
|
||||||
|
CollateralBridgeNew,
|
||||||
|
} from '@vegaprotocol/smart-contracts';
|
||||||
|
|
||||||
export interface WithdrawalFields {
|
export interface WithdrawalFields {
|
||||||
amount: string;
|
amount: string;
|
||||||
@ -17,12 +24,15 @@ export interface WithdrawalFields {
|
|||||||
receiverAddress: string;
|
receiverAddress: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWithdraw = (cancelled: boolean) => {
|
export const useWithdraw = (cancelled: boolean, isNewContract: boolean) => {
|
||||||
const [withdrawalId, setWithdrawalId] = useState<string | null>(null);
|
const [withdrawalId, setWithdrawalId] = useState<string | null>(null);
|
||||||
const [approval, setApproval] =
|
const [approval, setApproval] = useState<
|
||||||
useState<Erc20Approval_erc20WithdrawalApproval | null>(null);
|
| Erc20Approval_erc20WithdrawalApproval
|
||||||
|
| Erc20ApprovalNew_erc20WithdrawalApproval
|
||||||
|
| null
|
||||||
|
>(null);
|
||||||
|
|
||||||
const contract = useBridgeContract();
|
const contract = useBridgeContract(isNewContract);
|
||||||
const { keypair } = useVegaWallet();
|
const { keypair } = useVegaWallet();
|
||||||
const {
|
const {
|
||||||
transaction: vegaTx,
|
transaction: vegaTx,
|
||||||
@ -34,19 +44,19 @@ export const useWithdraw = (cancelled: boolean) => {
|
|||||||
transaction: ethTx,
|
transaction: ethTx,
|
||||||
perform,
|
perform,
|
||||||
reset: resetEthTx,
|
reset: resetEthTx,
|
||||||
} = useEthereumTransaction<CollateralBridge, 'withdraw_asset'>(
|
} = useEthereumTransaction<
|
||||||
contract,
|
CollateralBridgeNew | CollateralBridge,
|
||||||
'withdraw_asset'
|
'withdraw_asset'
|
||||||
);
|
>(contract, 'withdraw_asset');
|
||||||
|
|
||||||
const { data, stopPolling } = useQuery<Erc20Approval, Erc20ApprovalVariables>(
|
const { data, stopPolling } = useQuery<
|
||||||
ERC20_APPROVAL_QUERY,
|
Erc20Approval | Erc20ApprovalNew,
|
||||||
{
|
Erc20ApprovalVariables
|
||||||
variables: { withdrawalId: withdrawalId || '' },
|
>(isNewContract ? ERC20_APPROVAL_QUERY_NEW : ERC20_APPROVAL_QUERY, {
|
||||||
skip: !withdrawalId,
|
variables: { withdrawalId: withdrawalId || '' },
|
||||||
pollInterval: 1000,
|
skip: !withdrawalId,
|
||||||
}
|
pollInterval: 1000,
|
||||||
);
|
});
|
||||||
|
|
||||||
const submit = useCallback(
|
const submit = useCallback(
|
||||||
async (withdrawal: WithdrawalFields) => {
|
async (withdrawal: WithdrawalFields) => {
|
||||||
@ -87,14 +97,24 @@ export const useWithdraw = (cancelled: boolean) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (approval && contract && !cancelled) {
|
if (approval && contract && !cancelled) {
|
||||||
perform(
|
if (contract.isNewContract && 'creation' in approval) {
|
||||||
approval.assetSource,
|
perform(
|
||||||
approval.amount,
|
approval.assetSource,
|
||||||
approval.targetAddress,
|
approval.amount,
|
||||||
approval.creation,
|
approval.targetAddress,
|
||||||
approval.nonce,
|
approval.creation,
|
||||||
approval.signatures
|
approval.nonce,
|
||||||
);
|
approval.signatures
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
perform(
|
||||||
|
approval.assetSource,
|
||||||
|
approval.amount,
|
||||||
|
approval.targetAddress,
|
||||||
|
approval.nonce,
|
||||||
|
approval.signatures
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [approval, contract]);
|
}, [approval, contract]);
|
||||||
|
@ -21,7 +21,6 @@ const approval: Erc20Approval_erc20WithdrawalApproval = {
|
|||||||
signatures: 'signatures',
|
signatures: 'signatures',
|
||||||
targetAddress: 'target-address',
|
targetAddress: 'target-address',
|
||||||
expiry: 'expiry',
|
expiry: 'expiry',
|
||||||
creation: '1660158537747',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateJsx = (override?: PartialDeep<WithdrawDialogProps>) => {
|
const generateJsx = (override?: PartialDeep<WithdrawDialogProps>) => {
|
||||||
|
@ -34,6 +34,7 @@ beforeEach(() => {
|
|||||||
assets: [generateAsset()],
|
assets: [generateAsset()],
|
||||||
accounts: [generateAccount()],
|
accounts: [generateAccount()],
|
||||||
initialAssetId: undefined,
|
initialAssetId: undefined,
|
||||||
|
isNewContract: true,
|
||||||
};
|
};
|
||||||
mockSubmit = jest.fn();
|
mockSubmit = jest.fn();
|
||||||
mockReset = jest.fn();
|
mockReset = jest.fn();
|
||||||
|
@ -16,19 +16,22 @@ export interface WithdrawManagerProps {
|
|||||||
assets: Asset[];
|
assets: Asset[];
|
||||||
accounts: Account[];
|
accounts: Account[];
|
||||||
initialAssetId?: string;
|
initialAssetId?: string;
|
||||||
|
isNewContract: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WithdrawManager = ({
|
export const WithdrawManager = ({
|
||||||
assets,
|
assets,
|
||||||
accounts,
|
accounts,
|
||||||
initialAssetId,
|
initialAssetId,
|
||||||
|
isNewContract,
|
||||||
}: WithdrawManagerProps) => {
|
}: WithdrawManagerProps) => {
|
||||||
const dialogDismissed = useRef(false);
|
const dialogDismissed = useRef(false);
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [assetId, setAssetId] = useState<string | undefined>(initialAssetId);
|
const [assetId, setAssetId] = useState<string | undefined>(initialAssetId);
|
||||||
|
|
||||||
const { ethTx, vegaTx, approval, submit, reset } = useWithdraw(
|
const { ethTx, vegaTx, approval, submit, reset } = useWithdraw(
|
||||||
dialogDismissed.current
|
dialogDismissed.current,
|
||||||
|
isNewContract
|
||||||
);
|
);
|
||||||
|
|
||||||
// Find the asset object from the select box
|
// Find the asset object from the select box
|
||||||
|
@ -21,7 +21,7 @@ export interface WithdrawalsTableProps {
|
|||||||
|
|
||||||
export const WithdrawalsTable = ({ withdrawals }: WithdrawalsTableProps) => {
|
export const WithdrawalsTable = ({ withdrawals }: WithdrawalsTableProps) => {
|
||||||
const { ETHERSCAN_URL } = useEnvironment();
|
const { ETHERSCAN_URL } = useEnvironment();
|
||||||
const { submit, Dialog } = useCompleteWithdraw();
|
const { submit, Dialog } = useCompleteWithdraw(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user