Upgrade dsa-connect

This commit is contained in:
Georges KABBOUCHI 2021-08-22 17:20:28 +03:00
parent 27cca10cc5
commit e7f0208b4d
7 changed files with 21 additions and 13 deletions

View File

@ -67,7 +67,7 @@
</SidebarContextRootContainer>
</template>
<script>
<script lang="ts">
import { computed, defineComponent, ref } from '@nuxtjs/composition-api'
import InputNumeric from '~/components/common/input/InputNumeric.vue'
import { useAaveV2Position } from '~/composables/protocols/useAaveV2Position'
@ -87,7 +87,7 @@ import { useDSA } from '~/composables/useDSA'
import ButtonCTA from '~/components/common/input/ButtonCTA.vue'
import Button from '~/components/Button.vue'
import { useSidebar } from '~/composables/useSidebar'
import DSA from "dsa-connect"
export default defineComponent({
components: { InputNumeric, ToggleButton, ButtonCTA, Button },
props: {
@ -102,7 +102,7 @@ export default defineComponent({
const { formatNumber, formatUsdMax, formatUsd } = useFormatting()
const { isZero, gt, plus } = useBigNumber()
const { parseSafeFloat } = useParsing()
const { showPendingTransaction, showWarning } = useNotification()
const { showPendingTransaction, showWarning, showConfirmedTransaction } = useNotification()
const { status, displayPositions, maxLiquidation, liquidationPrice, liquidationMaxPrice } = useAaveV2Position({
overridePosition: (position) => {
if (rootTokenKey.value !== position.key) return position
@ -160,9 +160,12 @@ export default defineComponent({
})
try {
const txHash = await dsa.value.cast({
const txHash = await (dsa.value as DSA).cast({
spells,
from: account.value,
onReceipt: (receipt) => {
showConfirmedTransaction(receipt.transactionHash)
}
})
showPendingTransaction(txHash)

View File

@ -1,3 +1,4 @@
import { Spell } from "dsa-connect";
import { useBigNumber } from "../useBigNumber";
import { useDSA } from "../useDSA";
import { useFormatting } from "../useFormatting";
@ -35,7 +36,7 @@ export const use1InchSwap = () => {
unitAmt,
calldata,
setId
}) {
}): Spell {
if (
activeNetworkId.value === Network.Polygon ||
activeAccount.value.version == 2

View File

@ -1,6 +1,5 @@
import { computed, readonly, ref, watch } from "@nuxtjs/composition-api";
import { useWeb3 } from "./useWeb3";
//@ts-ignore
import DSA from "dsa-connect";
import addresses from "~/constant/addresses";
import abis from "~/constant/abis";
@ -69,7 +68,7 @@ export function useDSA() {
try {
const transactionHash = await dsa.value.build({ version: 2 });
accounts.value = await dsa.value.getAccounts();
accounts.value = await dsa.value.getAccounts(account.value);
return transactionHash;
} catch (error) {
} finally {

View File

@ -80,10 +80,12 @@ export function init() {
async ([route, active, dsa], [oldRoute, oldActive, oldDsa]) => {
await nextTick();
//@ts-ignore
const hasPathChanged = !oldRoute || route.path !== oldRoute.path;
const hasIsLoggedInChanged = active !== oldActive;
const hasDsaChanged = dsa !== oldDsa;
//@ts-ignore
const [hash, params] = route.hash.split("?");
if (hasPathChanged){
@ -91,6 +93,7 @@ export function init() {
return
}
//@ts-ignore
sidebar.value = sidebars[route.path + hash] || sidebars[hash];
if (!sidebar.value) {

View File

@ -23,7 +23,7 @@ const chains = [
];
const active = ref(false);
const chainId = ref<number>();
const chainId = ref<1|137>();
const networkName = computed<Network>(
() => chains.find(c => c.chainId === chainId.value)?.name || Network.Mainnet
);
@ -60,6 +60,7 @@ export function useWeb3() {
account.value = web3Provider.accounts[0];
}
let newWeb3 = new Web3(web3Provider);
//@ts-ignore
chainId.value = await newWeb3.eth.getChainId();
web3.value = newWeb3;
@ -118,6 +119,7 @@ export function useWeb3() {
return;
}
let newWeb3 = new Web3(web3Provider);
//@ts-ignore
chainId.value = await newWeb3.eth.getChainId();
web3.value = newWeb3;
};

View File

@ -18,7 +18,7 @@
"bignumber.js": "^9.0.1",
"core-js": "^3.15.1",
"css-color-function": "^1.3.3",
"dsa-connect": "^0.4.3",
"dsa-connect": "^0.4.4-beta.2",
"nuxt": "^2.15.7",
"qrcode": "^1.4.4",
"v-click-outside": "^3.1.2",

View File

@ -4675,10 +4675,10 @@ drbg.js@^1.0.1:
create-hash "^1.1.2"
create-hmac "^1.1.4"
dsa-connect@^0.4.3:
version "0.4.3"
resolved "https://registry.yarnpkg.com/dsa-connect/-/dsa-connect-0.4.3.tgz#382ad7c1b1fa54f963c84adc353dea4bde2f6e80"
integrity sha512-kbG46cvAR2muy2P5jOTVsSZmyDewTAA0lKAeddsrVtpbmys1ujSuDjY/su4At6fAg/iF9/k+ltJAOEvoqt6g9A==
dsa-connect@^0.4.4-beta.2:
version "0.4.4-beta.2"
resolved "https://registry.yarnpkg.com/dsa-connect/-/dsa-connect-0.4.4-beta.2.tgz#d26739c4d67176e7f29b08cb84ee4f510e0bb830"
integrity sha512-ZRk4OAHD0GFJW74fggNfwXCho4AdWKJdXCyGtuCxwTY7Pm1ycisa/469vD6UjcB8j2CrNDk3AsPgXs5IBmkzDQ==
duplexer3@^0.1.4:
version "0.1.4"