Feat/537: remove old contract for collateral bridge (#998)
* Feat/537: Removed old contract and branching logic for collateral bridge * Feat/537: Renamed all 'new' name instances in functions, files and types. Regenerated types. * Feat/537: Added 'creation' field to withdraw-dialog.spec.tsx test
This commit is contained in:
parent
1c4231f6fc
commit
1be1a78a69
@ -3,7 +3,6 @@ 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,7 +5,6 @@ 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,7 +3,6 @@ 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,4 +6,3 @@ 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,9 +66,6 @@ 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,7 +15,6 @@ 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();
|
||||||
@ -150,11 +149,7 @@ export const WithdrawContainer = ({ currVegaKey }: WithdrawContainerProps) => {
|
|||||||
</Callout>
|
</Callout>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<WithdrawManager
|
<WithdrawManager assets={data.assets || []} accounts={accounts} />
|
||||||
assets={data.assets || []}
|
|
||||||
accounts={accounts}
|
|
||||||
isNewContract={Flags.USE_NEW_BRIDGE_CONTRACT}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,6 @@ 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();
|
||||||
@ -34,7 +33,7 @@ const Withdrawals = () => {
|
|||||||
|
|
||||||
const WithdrawPendingContainer = () => {
|
const WithdrawPendingContainer = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { submit, Dialog } = useCompleteWithdraw(Flags.USE_NEW_BRIDGE_CONTRACT);
|
const { submit, Dialog } = useCompleteWithdraw();
|
||||||
const { data, loading, error } = useWithdrawals();
|
const { data, loading, error } = useWithdrawals();
|
||||||
|
|
||||||
const withdrawals = React.useMemo(() => {
|
const withdrawals = React.useMemo(() => {
|
||||||
@ -93,7 +92,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 = null;
|
let status;
|
||||||
let footer = null;
|
let footer = null;
|
||||||
|
|
||||||
if (withdrawal.pendingOnForeignChain) {
|
if (withdrawal.pendingOnForeignChain) {
|
||||||
|
@ -87,7 +87,6 @@ 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(true);
|
const bridgeContract = useBridgeContract();
|
||||||
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,13 +3,10 @@ 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 {
|
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
||||||
CollateralBridge,
|
|
||||||
CollateralBridgeNew,
|
|
||||||
} from '@vegaprotocol/smart-contracts';
|
|
||||||
|
|
||||||
export const useGetDepositMaximum = (
|
export const useGetDepositMaximum = (
|
||||||
contract: CollateralBridge | CollateralBridgeNew | null,
|
contract: CollateralBridge | null,
|
||||||
asset: Asset | undefined
|
asset: Asset | undefined
|
||||||
) => {
|
) => {
|
||||||
const getDepositMaximum = useCallback(async () => {
|
const getDepositMaximum = useCallback(async () => {
|
||||||
|
@ -17,10 +17,7 @@ import {
|
|||||||
useEthereumTransaction,
|
useEthereumTransaction,
|
||||||
useTokenContract,
|
useTokenContract,
|
||||||
} from '@vegaprotocol/web3';
|
} from '@vegaprotocol/web3';
|
||||||
import type {
|
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
||||||
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';
|
||||||
@ -42,7 +39,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(true);
|
const bridgeContract = useBridgeContract();
|
||||||
const tokenContract = useTokenContract(
|
const tokenContract = useTokenContract(
|
||||||
isAssetTypeERC20(asset) ? asset : undefined,
|
isAssetTypeERC20(asset) ? asset : undefined,
|
||||||
true
|
true
|
||||||
@ -54,10 +51,12 @@ export const useSubmitDeposit = () => {
|
|||||||
|
|
||||||
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
|
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
|
||||||
|
|
||||||
const transaction = useEthereumTransaction<
|
const transaction = useEthereumTransaction<CollateralBridge, 'deposit_asset'>(
|
||||||
CollateralBridgeNew | CollateralBridge,
|
bridgeContract,
|
||||||
'deposit_asset'
|
'deposit_asset',
|
||||||
>(bridgeContract, 'deposit_asset', config?.confirmations, true);
|
config?.confirmations,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
useSubscription<DepositEvent, DepositEventVariables>(DEPOSIT_EVENT_SUB, {
|
useSubscription<DepositEvent, DepositEventVariables>(DEPOSIT_EVENT_SUB, {
|
||||||
variables: { partyId: partyId ? remove0x(partyId) : '' },
|
variables: { partyId: partyId ? remove0x(partyId) : '' },
|
||||||
|
@ -5,66 +5,11 @@
|
|||||||
"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": [
|
||||||
@ -96,6 +41,31 @@
|
|||||||
"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": [
|
||||||
@ -171,6 +141,70 @@
|
|||||||
"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": [
|
||||||
{
|
{
|
||||||
@ -194,6 +228,45 @@
|
|||||||
"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": [
|
||||||
{
|
{
|
||||||
@ -213,44 +286,6 @@
|
|||||||
"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",
|
||||||
@ -283,6 +318,61 @@
|
|||||||
"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": [
|
||||||
{
|
{
|
||||||
@ -302,6 +392,38 @@
|
|||||||
"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": [
|
||||||
{
|
{
|
||||||
@ -314,6 +436,16 @@
|
|||||||
"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",
|
||||||
@ -354,29 +486,8 @@
|
|||||||
"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"
|
||||||
@ -390,7 +501,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "minimum_amount",
|
"name": "lifetime_limit",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "threshold",
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -404,7 +520,30 @@
|
|||||||
"type": "bytes"
|
"type": "bytes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "set_deposit_minimum",
|
"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": [],
|
"outputs": [],
|
||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
@ -426,6 +565,11 @@
|
|||||||
"name": "target",
|
"name": "target",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "creation",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "nonce",
|
"name": "nonce",
|
||||||
|
@ -1,589 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,54 +0,0 @@
|
|||||||
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,15 +4,13 @@ import abi from '../abis/erc20_bridge_abi.json';
|
|||||||
|
|
||||||
export class CollateralBridge {
|
export class CollateralBridge {
|
||||||
public contract: ethers.Contract;
|
public contract: ethers.Contract;
|
||||||
public isNewContract = false;
|
public isNewContract = true;
|
||||||
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) {
|
||||||
@ -22,10 +20,7 @@ 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_deposit_maximum(assetSource);
|
return this.contract.get_asset_deposit_lifetime_limit(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();
|
||||||
@ -43,6 +38,7 @@ 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
|
||||||
) {
|
) {
|
||||||
@ -50,6 +46,7 @@ export class CollateralBridge {
|
|||||||
assetSource,
|
assetSource,
|
||||||
amount,
|
amount,
|
||||||
target,
|
target,
|
||||||
|
creation,
|
||||||
nonce,
|
nonce,
|
||||||
signatures
|
signatures
|
||||||
);
|
);
|
||||||
|
@ -2,7 +2,6 @@ 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,12 +1,9 @@
|
|||||||
import {
|
import { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
||||||
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 = (isNewContract: boolean) => {
|
export const useBridgeContract = () => {
|
||||||
const { provider } = useWeb3React();
|
const { provider } = useWeb3React();
|
||||||
const { config } = useEthereumConfig();
|
const { config } = useEthereumConfig();
|
||||||
|
|
||||||
@ -17,16 +14,11 @@ export const useBridgeContract = (isNewContract: boolean) => {
|
|||||||
|
|
||||||
const signer = provider.getSigner();
|
const signer = provider.getSigner();
|
||||||
|
|
||||||
return isNewContract
|
return new CollateralBridge(
|
||||||
? new CollateralBridgeNew(
|
config.collateral_bridge_contract.address,
|
||||||
config.collateral_bridge_contract.address,
|
signer || provider
|
||||||
signer || provider
|
);
|
||||||
)
|
}, [provider, config]);
|
||||||
: new CollateralBridge(
|
|
||||||
config.collateral_bridge_contract.address,
|
|
||||||
signer || provider
|
|
||||||
);
|
|
||||||
}, [provider, config, isNewContract]);
|
|
||||||
|
|
||||||
return contract;
|
return contract;
|
||||||
};
|
};
|
||||||
|
@ -34,6 +34,10 @@ 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 {
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/* 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,19 +2,6 @@ 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_NEW } from './queries';
|
import { ERC20_APPROVAL_QUERY } 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 { Erc20ApprovalNew_erc20WithdrawalApproval } from './__generated__/Erc20ApprovalNew';
|
import type { Erc20Approval_erc20WithdrawalApproval } from './__generated__/Erc20Approval';
|
||||||
|
|
||||||
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(true), { wrapper });
|
return renderHook(() => useCompleteWithdraw(), { 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: Erc20ApprovalNew_erc20WithdrawalApproval = {
|
const erc20WithdrawalApproval: Erc20Approval_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_NEW,
|
query: ERC20_APPROVAL_QUERY,
|
||||||
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_NEW,
|
query: ERC20_APPROVAL_QUERY,
|
||||||
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_NEW,
|
query: ERC20_APPROVAL_QUERY,
|
||||||
variables: { withdrawalId },
|
variables: { withdrawalId },
|
||||||
},
|
},
|
||||||
error: new Error('query failed'),
|
error: new Error('query failed'),
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
import { gql, useApolloClient } from '@apollo/client';
|
import { gql, useApolloClient } from '@apollo/client';
|
||||||
import { captureException } from '@sentry/react';
|
import { captureException } from '@sentry/react';
|
||||||
import type {
|
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
||||||
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, ERC20_APPROVAL_QUERY_NEW } from './queries';
|
import { ERC20_APPROVAL_QUERY } 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`
|
||||||
@ -21,12 +17,12 @@ export const PENDING_WITHDRAWAL_FRAGMMENT = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const useCompleteWithdraw = (isNewContract: boolean) => {
|
export const useCompleteWithdraw = () => {
|
||||||
const { query, cache } = useApolloClient();
|
const { query, cache } = useApolloClient();
|
||||||
const contract = useBridgeContract(isNewContract);
|
const contract = useBridgeContract();
|
||||||
const [id, setId] = useState('');
|
const [id, setId] = useState('');
|
||||||
const { transaction, perform, Dialog } = useEthereumTransaction<
|
const { transaction, perform, Dialog } = useEthereumTransaction<
|
||||||
CollateralBridgeNew | CollateralBridge,
|
CollateralBridge,
|
||||||
'withdraw_asset'
|
'withdraw_asset'
|
||||||
>(contract, 'withdraw_asset');
|
>(contract, 'withdraw_asset');
|
||||||
|
|
||||||
@ -37,13 +33,8 @@ export const useCompleteWithdraw = (isNewContract: boolean) => {
|
|||||||
if (!contract) {
|
if (!contract) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await query<
|
const res = await query<Erc20Approval, Erc20ApprovalVariables>({
|
||||||
Erc20Approval | Erc20ApprovalNew,
|
query: ERC20_APPROVAL_QUERY,
|
||||||
Erc20ApprovalVariables
|
|
||||||
>({
|
|
||||||
query: isNewContract
|
|
||||||
? ERC20_APPROVAL_QUERY_NEW
|
|
||||||
: ERC20_APPROVAL_QUERY,
|
|
||||||
variables: { withdrawalId },
|
variables: { withdrawalId },
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,29 +43,19 @@ export const useCompleteWithdraw = (isNewContract: boolean) => {
|
|||||||
throw new Error('Could not retrieve withdrawal approval');
|
throw new Error('Could not retrieve withdrawal approval');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contract.isNewContract && 'creation' in approval) {
|
perform(
|
||||||
perform(
|
approval.assetSource,
|
||||||
approval.assetSource,
|
approval.amount,
|
||||||
approval.amount,
|
approval.targetAddress,
|
||||||
approval.targetAddress,
|
approval.creation,
|
||||||
approval.creation,
|
approval.nonce,
|
||||||
approval.nonce,
|
approval.signatures
|
||||||
approval.signatures
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
perform(
|
|
||||||
approval.assetSource,
|
|
||||||
approval.amount,
|
|
||||||
approval.targetAddress,
|
|
||||||
approval.nonce,
|
|
||||||
approval.signatures
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
captureException(err);
|
captureException(err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[contract, query, isNewContract, perform]
|
[contract, query, 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(true);
|
const contract = useBridgeContract();
|
||||||
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_NEW } from './queries';
|
import { ERC20_APPROVAL_QUERY } 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 { Erc20ApprovalNew } from './__generated__/Erc20ApprovalNew';
|
import type { Erc20Approval } from './__generated__/Erc20Approval';
|
||||||
|
|
||||||
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, true), { wrapper });
|
return renderHook(() => useWithdraw(cancelled), { 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<Erc20ApprovalNew>;
|
let mockERC20Approval: MockedResponse<Erc20Approval>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
pubkey = 'pubkey';
|
pubkey = 'pubkey';
|
||||||
@ -85,7 +85,7 @@ beforeEach(() => {
|
|||||||
};
|
};
|
||||||
mockERC20Approval = {
|
mockERC20Approval = {
|
||||||
request: {
|
request: {
|
||||||
query: ERC20_APPROVAL_QUERY_NEW,
|
query: ERC20_APPROVAL_QUERY,
|
||||||
variables: { withdrawalId: derivedWithdrawalId },
|
variables: { withdrawalId: derivedWithdrawalId },
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
|
@ -3,20 +3,13 @@ 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, ERC20_APPROVAL_QUERY_NEW } from './queries';
|
import { ERC20_APPROVAL_QUERY } from './queries';
|
||||||
import type {
|
import type {
|
||||||
Erc20Approval,
|
Erc20Approval,
|
||||||
Erc20ApprovalVariables,
|
|
||||||
Erc20Approval_erc20WithdrawalApproval,
|
Erc20Approval_erc20WithdrawalApproval,
|
||||||
|
Erc20ApprovalVariables,
|
||||||
} from './__generated__/Erc20Approval';
|
} from './__generated__/Erc20Approval';
|
||||||
import type {
|
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
||||||
Erc20ApprovalNew,
|
|
||||||
Erc20ApprovalNew_erc20WithdrawalApproval,
|
|
||||||
} from './__generated__/Erc20ApprovalNew';
|
|
||||||
import type {
|
|
||||||
CollateralBridge,
|
|
||||||
CollateralBridgeNew,
|
|
||||||
} from '@vegaprotocol/smart-contracts';
|
|
||||||
|
|
||||||
export interface WithdrawalFields {
|
export interface WithdrawalFields {
|
||||||
amount: string;
|
amount: string;
|
||||||
@ -24,15 +17,12 @@ export interface WithdrawalFields {
|
|||||||
receiverAddress: string;
|
receiverAddress: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWithdraw = (cancelled: boolean, isNewContract: boolean) => {
|
export const useWithdraw = (cancelled: boolean) => {
|
||||||
const [withdrawalId, setWithdrawalId] = useState<string | null>(null);
|
const [withdrawalId, setWithdrawalId] = useState<string | null>(null);
|
||||||
const [approval, setApproval] = useState<
|
const [approval, setApproval] =
|
||||||
| Erc20Approval_erc20WithdrawalApproval
|
useState<Erc20Approval_erc20WithdrawalApproval | null>(null);
|
||||||
| Erc20ApprovalNew_erc20WithdrawalApproval
|
|
||||||
| null
|
|
||||||
>(null);
|
|
||||||
|
|
||||||
const contract = useBridgeContract(isNewContract);
|
const contract = useBridgeContract();
|
||||||
const { keypair } = useVegaWallet();
|
const { keypair } = useVegaWallet();
|
||||||
const {
|
const {
|
||||||
transaction: vegaTx,
|
transaction: vegaTx,
|
||||||
@ -44,19 +34,19 @@ export const useWithdraw = (cancelled: boolean, isNewContract: boolean) => {
|
|||||||
transaction: ethTx,
|
transaction: ethTx,
|
||||||
perform,
|
perform,
|
||||||
reset: resetEthTx,
|
reset: resetEthTx,
|
||||||
} = useEthereumTransaction<
|
} = useEthereumTransaction<CollateralBridge, 'withdraw_asset'>(
|
||||||
CollateralBridgeNew | CollateralBridge,
|
contract,
|
||||||
'withdraw_asset'
|
'withdraw_asset'
|
||||||
>(contract, 'withdraw_asset');
|
);
|
||||||
|
|
||||||
const { data, stopPolling } = useQuery<
|
const { data, stopPolling } = useQuery<Erc20Approval, Erc20ApprovalVariables>(
|
||||||
Erc20Approval | Erc20ApprovalNew,
|
ERC20_APPROVAL_QUERY,
|
||||||
Erc20ApprovalVariables
|
{
|
||||||
>(isNewContract ? ERC20_APPROVAL_QUERY_NEW : ERC20_APPROVAL_QUERY, {
|
variables: { withdrawalId: withdrawalId || '' },
|
||||||
variables: { withdrawalId: withdrawalId || '' },
|
skip: !withdrawalId,
|
||||||
skip: !withdrawalId,
|
pollInterval: 1000,
|
||||||
pollInterval: 1000,
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
const submit = useCallback(
|
const submit = useCallback(
|
||||||
async (withdrawal: WithdrawalFields) => {
|
async (withdrawal: WithdrawalFields) => {
|
||||||
@ -97,24 +87,14 @@ export const useWithdraw = (cancelled: boolean, isNewContract: boolean) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (approval && contract && !cancelled) {
|
if (approval && contract && !cancelled) {
|
||||||
if (contract.isNewContract && 'creation' in approval) {
|
perform(
|
||||||
perform(
|
approval.assetSource,
|
||||||
approval.assetSource,
|
approval.amount,
|
||||||
approval.amount,
|
approval.targetAddress,
|
||||||
approval.targetAddress,
|
approval.creation,
|
||||||
approval.creation,
|
approval.nonce,
|
||||||
approval.nonce,
|
approval.signatures
|
||||||
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,6 +21,7 @@ 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,7 +34,6 @@ 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,22 +16,19 @@ 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(true);
|
const { submit, Dialog } = useCompleteWithdraw();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user