Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ltc redeem #69

Merged
merged 5 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const supported = {
],
}

export { pTokensNode } from 'ptokens-node'
export { pTokensNode } from '@p.network/ptokens-node'

export class pTokensNodeProvider {
sendRpcRequest(_reqId, _method, _params) {
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/react-web3-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getWeb3Settings = () => ({
bsc: 'https://bsc-dataseed1.binance.org/',
gnosis: 'https://rpc.gnosischain.com',
polygon: 'https://polygon-rpc.com/',
ultra: 'https://corsproxy.ptokens.io/v1/?apiurl=http://ultra-mainnet-1.ptokens.io:8888',
ultra: 'https://corsproxy.ptokens.io/v1/?apiurl=https://api.ultra.eossweden.org',
arbitrum: 'https://arb1.arbitrum.io/rpc',
luxochain: 'https://corsproxy.ptokens.io/v1/?apiurl=https://lugano.nodes.luxochain.io',
algorand: 'https://mainnet-api.algonode.cloud',
Expand Down
1,129 changes: 567 additions & 562 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plain-dapp-update",
"private": true,
"version": "1.20.2",
"version": "1.21.0",
envin3 marked this conversation as resolved.
Show resolved Hide resolved
"type": "module",
"scripts": {
"dev": "npm run create-version-file && vite",
Expand All @@ -21,6 +21,7 @@
"@libre-chain/libre-link": "^3.5.0",
"@libre-chain/libre-link-browser-transport": "^3.4.2",
"@msgpack/msgpack": "^2.7.2",
"@p.network/ptokens": "^1.7.1",
"@perawallet/connect": "^1.3.1",
"@randlabs/myalgo-connect": "^1.2.0",
"@walletconnect/ethereum-provider": "^2.8.1",
Expand All @@ -40,7 +41,6 @@
"is-mobile": "^3.0.0",
"lodash": "^4.17.21",
"prop-types": "^15.7.2",
"ptokens": "^1.7.0",
"qrcode.react": "^3.1.0",
"query-string": "^6.11.1",
"raw-loader": "^4.0.2",
Expand Down Expand Up @@ -105,7 +105,7 @@
"@curvefi/api": {
"axios": "$axios"
},
"ptokens-assets-utxo": {
"@p.network/ptokens-assets-utxo": {
"axios": "$axios"
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/pages/swap/Swap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,7 @@ const Swap = ({
<WarningEta>High price impact!</WarningEta>
) : null}
{!onPnetworkV2 ? (
<WarningEta>
This swap is still not supported by pNetwork v2. Please visit dapp-legacy.ptokens.io.
</WarningEta>
<WarningEta>This swap is not supported by pNetwork v2. Please write to [email protected].</WarningEta>
) : null}
<ContainerSwapButton>
<Button
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringUtils } from '@p.network/ptokens-helpers'
import _ from 'lodash'
import { stringUtils } from 'ptokens-helpers'
import { useMemo, useState } from 'react'

import { offChainFormat, strip } from '../utils/amount-utils'
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-swap-info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chainIdToTypeMap, BlockchainType } from 'ptokens-constants'
import { chainIdToTypeMap, BlockchainType } from '@p.network/ptokens-constants'
import { useMemo } from 'react'

import { getAssetById } from '../store/swap/swap.selectors'
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ const useSwap = ({
}

if (!onPnetworkV2) {
updateSwapButton('Go to Legacy dApp', false, getLegacyUrl(from, to))
updateSwapButton('Disabled Swap', true)
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ const settings = {
},
ultra: {
chainId: 'a9c481dfbc7d9506dc7e87e9a137c931b0a9303f64fd7a1d08b8230133920097',
host: 'https://corsproxy.ptokens.io/v1/?apiurl=http://ultra-mainnet-1.ptokens.io:8888',
host: 'https://corsproxy.ptokens.io/v1/?apiurl=https://api.ultra.eossweden.org',
envin3 marked this conversation as resolved.
Show resolved Hide resolved
port: 443,
protocol: 'https',
endpoint: 'https://corsproxy.ptokens.io/v1/?apiurl=http://ultra-mainnet-1.ptokens.io:8888',
endpoint: 'https://corsproxy.ptokens.io/v1/?apiurl=https://api.ultra.eossweden.org',
label: 'Ultra',
},
arbitrum: {
Expand Down
2 changes: 1 addition & 1 deletion src/settings/migration-assets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from 'ptokens-constants'
import { ChainId } from '@p.network/ptokens-constants'

const migrationAssets = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/settings/swap-assets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from 'ptokens-constants'
import { ChainId } from '@p.network/ptokens-constants'

const swapAssets = [
/* ################# pTokens #################*/
Expand Down
5 changes: 3 additions & 2 deletions src/store/evm-approve.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ERC20Abi from '../utils/abi/ERC20.json'
import { stringUtils } from '@p.network/ptokens-helpers'
import BigNumber from 'bignumber.js'
import { stringUtils } from 'ptokens-helpers'

import ERC20Abi from '../utils/abi/ERC20.json'

// NOTE: avoids brave metamask gas estimation fails
function getBigNumber(amount, decimals) {
Expand Down
6 changes: 3 additions & 3 deletions src/store/migration/migrations/ethPNT-migration.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pTokensEvmAsset, pTokensEvmAssetBuilder, pTokensEvmProvider } from 'ptokens-assets-evm'
import { pTokensNode, pTokensNodeProvider } from 'ptokens-node'
import { pTokensSwapBuilder } from 'ptokens-swap'
import { pTokensEvmAsset, pTokensEvmAssetBuilder, pTokensEvmProvider } from '@p.network/ptokens-assets-evm'
import { pTokensNode, pTokensNodeProvider } from '@p.network/ptokens-node'
import { pTokensSwapBuilder } from '@p.network/ptokens-swap'
import Web3 from 'web3'

import { PNETWORK_NODE_V3 } from '../../../constants'
Expand Down
19 changes: 10 additions & 9 deletions src/store/swap/__tests__/swap.actions.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { pTokensAlgorandAsset } from '@p.network/ptokens-assets-algorand'
import { pTokensEosioAsset } from '@p.network/ptokens-assets-eosio'
import { pTokensSwapBuilder, pTokensSwap } from '@p.network/ptokens-swap'
import algosdk from 'algosdk'
import { vi, describe, expect } from 'vitest'
import * as peginWithDepositAddress from '../utils/pegin-with-deposit-address'
import * as pegout from '../utils/pegout'
import * as peginWithWallet from '../utils/pegin-with-wallet'
import { pTokensSwapBuilder, pTokensSwap } from 'ptokens-swap'
import { pTokensEosioAsset } from 'ptokens-assets-eosio'
import { pTokensAlgorandAsset } from 'ptokens-assets-algorand'

import assets from '../../../settings/swap-assets'
import * as wallets from '../../wallets/wallets.selectors'
import { swap } from '../swap.actions'
import assets from '../../../settings/swap-assets'
import algosdk from 'algosdk'
import * as peginWithDepositAddress from '../utils/pegin-with-deposit-address'
import * as peginWithWallet from '../utils/pegin-with-wallet'
import * as pegout from '../utils/pegout'

describe('swap', () => {
beforeAll(() => {
vi.mock('ptokens-node')
vi.mock('@p.network/ptokens-node')
vi.mock('react-web3-settings')
})

Expand Down
2 changes: 1 addition & 1 deletion src/store/swap/swap.actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getAmountInEosFormat } from '@p.network/ptokens-assets-eosio'
import axios from 'axios'
import BigNumber from 'bignumber.js'
import { getAmountInEosFormat } from 'ptokens-assets-eosio'
import Web3 from 'web3'

import {
Expand Down
7 changes: 4 additions & 3 deletions src/store/swap/utils/balances.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { getReadOnlyProviderByBlockchain } from '../../../utils/read-only-providers'
import Web3 from 'web3'
import { stringUtils } from '@p.network/ptokens-helpers'
import BigNumber from 'bignumber.js'
import Web3 from 'web3'

import { SWAP_BALANCE_LOADED } from '../../../constants/index'
import ERC20 from '../../../utils/abi/ERC20'
import { stringUtils } from 'ptokens-helpers'
import { getReadOnlyProviderByBlockchain } from '../../../utils/read-only-providers'

const loadEvmCompatibleBalances = async ({
assets,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/__tests__/account-validator.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validators } from 'ptokens-helpers'
import { validators } from '@p.network/ptokens-helpers'
import { test, describe, expect, vi } from 'vitest'

import { isValidAccountByBlockchain, isSmartContract } from '../account-validator'
Expand All @@ -12,8 +12,8 @@ const mockWeb3Instance = {

describe('isValidAccountByBlockchain', () => {
beforeAll(() => {
vi.mock('ptokens-helpers', async () => {
const actual = await vi.importActual('ptokens-helpers')
vi.mock('@p.network/ptokens-helpers', async () => {
const actual = await vi.importActual('@p.network/ptokens-helpers')
return {
...actual,
validators: { isValidAddressByChainId: vi.fn() },
Expand Down
7 changes: 4 additions & 3 deletions src/utils/__tests__/fee.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { test, vi, describe, expect } from 'vitest'

import { PBTC_ON_ETH_MAINNET_V1_MIGRATION, ETHPNT_ON_ETH_MAINNET, PNT_ON_ETH_MAINNET } from '../../constants'
import assets from '../../settings/swap-assets'
import {
getMigrationFees,
computeMigrationAmount,
Expand All @@ -9,8 +12,6 @@ import {
getFormattedProtocolFee,
getSwapFees,
} from '../fee'
import { PBTC_ON_ETH_MAINNET_V1_MIGRATION, ETHPNT_ON_ETH_MAINNET, PNT_ON_ETH_MAINNET } from '../../constants'
import assets from '../../settings/swap-assets'

describe('getFormattedFees with no amount', () => {
afterEach(() => {
Expand Down Expand Up @@ -232,7 +233,7 @@ describe('computeFeesAmount', () => {

describe('getSwapFees', () => {
beforeAll(() => {
vi.mock('ptokens-node')
vi.mock('@p.network/ptokens-node')
})
test('Should get fees for a native to host swap', async () => {
const from = assets.find((_el) => _el.id === 'BTC')
Expand Down
2 changes: 1 addition & 1 deletion src/utils/__tests__/ptokens.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pTokensNode, pTokensNodeProvider } from 'ptokens'
import { pTokensNode, pTokensNodeProvider } from '@p.network/ptokens'

import { PNETWORK_NODE_V3 } from '../../constants'
import { createEthPntAsset } from '../ptokens'
Expand Down
4 changes: 2 additions & 2 deletions src/utils/account-validator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChainId } from 'ptokens-constants'
import { validators, stringUtils } from 'ptokens-helpers'
import { ChainId } from '@p.network/ptokens-constants'
import { validators, stringUtils } from '@p.network/ptokens-helpers'

const isValidAccountByBlockchain = (_account, _blockchain) => {
if (!_account) return false
Expand Down
12 changes: 6 additions & 6 deletions src/utils/ptokens.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { pTokensAlgorandAssetBuilder, pTokensAlgorandProvider } from '@p.network/ptokens-assets-algorand'
import { pTokensEosioAssetBuilder, pTokensEosioProvider } from '@p.network/ptokens-assets-eosio'
import { pTokensEvmAssetBuilder, pTokensEvmProvider, pTokensEvmAsset } from '@p.network/ptokens-assets-evm'
import { pTokensUtxoAssetBuilder, pTokensBlockstreamUtxoProvider } from '@p.network/ptokens-assets-utxo'
import { pTokensNode, pTokensNodeProvider } from '@p.network/ptokens-node'
import { pTokensSwapBuilder } from '@p.network/ptokens-swap'
import _ from 'lodash'
import { pTokensAlgorandAssetBuilder, pTokensAlgorandProvider } from 'ptokens-assets-algorand'
import { pTokensEosioAssetBuilder, pTokensEosioProvider } from 'ptokens-assets-eosio'
import { pTokensEvmAssetBuilder, pTokensEvmProvider, pTokensEvmAsset } from 'ptokens-assets-evm'
import { pTokensUtxoAssetBuilder, pTokensBlockstreamUtxoProvider } from 'ptokens-assets-utxo'
import { pTokensNode, pTokensNodeProvider } from 'ptokens-node'
import { pTokensSwapBuilder } from 'ptokens-swap'

import { ETHPNT_ON_ETH_MAINNET, PNETWORK_NODE_V3 } from '../constants/index'
import swapAssets from '../settings/swap-assets'
Expand Down
Loading