fix
This commit is contained in:
parent
a65546791a
commit
f67c64953c
@ -114,4 +114,11 @@ export const queryPhase3Box = (data: any) =>
|
||||
url: 'webapp/index.php?c=Market&a=sellMyNft',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
|
||||
export const getSupportedCurrenTypes = (data: any) =>
|
||||
request({
|
||||
url: 'webapp/index.php?c=Market&a=getSupportedCurrencyTypes',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
@ -37,6 +37,8 @@ export default class ChainManager {
|
||||
}
|
||||
|
||||
public async init() {
|
||||
console.log('login');
|
||||
|
||||
if (this.bc.isWalletConnect) {
|
||||
try {
|
||||
await this.bc.connect()
|
||||
|
@ -355,39 +355,27 @@ export class Blockchain {
|
||||
}
|
||||
this.provider.on('chainChanged', onChainChange)
|
||||
try {
|
||||
const data = this.chainMap.get(chainId)!
|
||||
await this.provider.request({
|
||||
method: 'wallet_switchEthereumChain',
|
||||
params: [{ chainId: hexChainId }]
|
||||
method: 'wallet_addEthereumChain',
|
||||
params: [
|
||||
{
|
||||
chainId: hexChainId,
|
||||
chainName: data.name,
|
||||
nativeCurrency: {
|
||||
name: data.symbol,
|
||||
symbol: data.symbol,
|
||||
decimals: data.decimals || 18
|
||||
},
|
||||
blockExplorerUrls: [data.explorerurl],
|
||||
rpcUrls: [data.rpc]
|
||||
}
|
||||
]
|
||||
})
|
||||
console.log('switch chain success')
|
||||
} catch (e: any) {
|
||||
console.log('switch chain error: ', e)
|
||||
if (e.code === 4902 || e.message.indexOf('Unrecognized chain ID') >= 0) {
|
||||
try {
|
||||
const data = this.chainMap.get(chainId)!
|
||||
await this.provider.request({
|
||||
method: 'wallet_addEthereumChain',
|
||||
params: [
|
||||
{
|
||||
chainId: hexChainId,
|
||||
chainName: data.name,
|
||||
nativeCurrency: {
|
||||
name: data.symbol,
|
||||
symbol: data.symbol,
|
||||
decimals: data.decimals || 18
|
||||
},
|
||||
blockExplorerUrls: [data.explorerurl],
|
||||
rpcUrls: [data.rpc]
|
||||
}
|
||||
]
|
||||
})
|
||||
console.log('add chain success')
|
||||
} catch (addError) {
|
||||
console.error('add chain error: ', addError)
|
||||
this.provider.removeListener('chainChanged', onChainChange)
|
||||
}
|
||||
}
|
||||
// console.error(e)
|
||||
console.log('add chain success')
|
||||
} catch (addError) {
|
||||
console.error('add chain error: ', addError)
|
||||
this.provider.removeListener('chainChanged', onChainChange)
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,7 +461,26 @@ export class Blockchain {
|
||||
.sell(nftToken, currency, tokenId,priceBN, amount)
|
||||
.send({ gas: 1000000 })
|
||||
}
|
||||
|
||||
|
||||
public async beginBuy(orderId:string,marketAddress:string){
|
||||
const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI)
|
||||
return marketInstance.methods
|
||||
.buy(orderId)
|
||||
.send({ gas: 1000000 })
|
||||
}
|
||||
public async beginCancelOrder (orderId:string,marketAddress:string){
|
||||
const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI)
|
||||
return marketInstance.methods
|
||||
.cancelOrder(orderId)
|
||||
.send({ gas: 1000000 })
|
||||
}
|
||||
public async beginUpdatePrice(orderId:string,price: number,marketAddress:string){
|
||||
const priceBN = this.web3.utils.toBN(this.web3.utils.toWei(price + ''))
|
||||
const marketInstance: any = await this.getContractInstance(marketAddress, MARKET_ABI)
|
||||
return marketInstance.methods
|
||||
.updatePrice(orderId,priceBN)
|
||||
.send({ gas: 1000000 })
|
||||
}
|
||||
public async signData(signObj: any, signer: string) {
|
||||
const msgParams = JSON.stringify(signObj)
|
||||
const from = signer
|
||||
|
@ -78,7 +78,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="pending">
|
||||
<div class="pending-order">PEBDING ORDER</div>
|
||||
<div class="pending-order" @click="haldBuy">PEBDING ORDER</div>
|
||||
<div class="confirm">CONFIRM</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -94,15 +94,31 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { AppModule } from "@/store/modules/app";
|
||||
import { CONTRACT_ADDRESS } from "@/configs/config_chain";
|
||||
import ChainManager from "@/chain/ChainManager";
|
||||
export default {
|
||||
props: ["isBuy", "data"],
|
||||
data() {
|
||||
return {
|
||||
piece: "",
|
||||
orderId: 0,
|
||||
chainManager: new ChainManager(),
|
||||
dialogVisible: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async haldBuy() {
|
||||
try {
|
||||
const nftres = await this.chainManager.bc.beginBuy(
|
||||
this.orderId,
|
||||
CONTRACT_ADDRESS["1338"].address
|
||||
);
|
||||
console.log(nftres, "beginSell");
|
||||
} catch (err) {
|
||||
console.log("query order status error", err);
|
||||
}
|
||||
},
|
||||
closeTip() {
|
||||
// 分发自定义事件(事件名: closeTip)
|
||||
this.$emit("handBuyHide", false);
|
||||
|
@ -35,7 +35,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="pending">
|
||||
<div class="pending-order">PEBDING ORDER</div>
|
||||
<div class="pending-order" @click="haldBuy">PEBDING ORDER</div>
|
||||
<div class="confirm">CONFIRM</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -52,16 +52,32 @@
|
||||
|
||||
<script>
|
||||
import HeroBuyTop from "./HeroBuyTop.vue";
|
||||
import { AppModule } from "@/store/modules/app";
|
||||
import { CONTRACT_ADDRESS } from "@/configs/config_chain";
|
||||
import ChainManager from "@/chain/ChainManager";
|
||||
export default {
|
||||
props: ["isBuy", "data"],
|
||||
components: { HeroBuyTop },
|
||||
data() {
|
||||
return {
|
||||
piece: "",
|
||||
orderId:'',
|
||||
chainManager: new ChainManager(),
|
||||
dialogVisible: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async haldBuy(){
|
||||
try {
|
||||
const nftres = await this.chainManager.bc.beginBuy(
|
||||
this.orderId,
|
||||
CONTRACT_ADDRESS['1338'].address
|
||||
);
|
||||
console.log(nftres, "beginSell");
|
||||
} catch (err) {
|
||||
console.log("query order status error", err);
|
||||
}
|
||||
},
|
||||
closeTip() {
|
||||
// 分发自定义事件(事件名: closeTip)
|
||||
this.$emit("handBuyHide");
|
||||
|
@ -29,8 +29,8 @@
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
:label="item.name"
|
||||
:value="item.address"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
@ -80,7 +80,9 @@ import WeaponSellTop from "./WeaponSellTop.vue";
|
||||
import PieceSellTop from "./PieceSellTop.vue";
|
||||
import HeroSellTop from "./HeroSellTop.vue";
|
||||
import ChipSellTop from "./ChipSellTop.vue";
|
||||
import { sellMyNft } from "@/api/Market";
|
||||
import { sellMyNft, getSupportedCurrenTypes } from "@/api/Market";
|
||||
import { AppModule } from "@/store/modules/app";
|
||||
import { CONTRACT_ADDRESS } from "@/configs/config_chain";
|
||||
import ChainManager from "@/chain/ChainManager";
|
||||
|
||||
export default {
|
||||
@ -95,33 +97,19 @@ export default {
|
||||
return {
|
||||
piece: "",
|
||||
price: "",
|
||||
nft_Token: "",
|
||||
chainManager: new ChainManager(),
|
||||
cunout: 1,
|
||||
dialogVisible: false,
|
||||
isWeapon: false,
|
||||
options: [
|
||||
{
|
||||
value: "选项1",
|
||||
label: "USDT",
|
||||
},
|
||||
{
|
||||
value: "选项2",
|
||||
label: "CEG",
|
||||
},
|
||||
{
|
||||
value: "选项3",
|
||||
label: "CEC",
|
||||
},
|
||||
{
|
||||
value: "选项4",
|
||||
label: "MATIC",
|
||||
},
|
||||
],
|
||||
options: [],
|
||||
value: "",
|
||||
};
|
||||
},
|
||||
created() {
|
||||
console.log(this.data, "data");
|
||||
this.getOption();
|
||||
|
||||
console.log(this.options, "87887");
|
||||
},
|
||||
methods: {
|
||||
closeTip() {
|
||||
@ -129,47 +117,63 @@ export default {
|
||||
},
|
||||
async handMessage() {
|
||||
// this.$emit("handMessage");
|
||||
const data = {
|
||||
nft_token: this.piece
|
||||
? this.piece.detail.token_id
|
||||
: this.data.detail.token_id,
|
||||
s_price: this.price,
|
||||
amount: this.piece ? this.cunout : null,
|
||||
};
|
||||
// const data = {
|
||||
// nft_token: this.piece
|
||||
// ? this.piece.detail.token_id
|
||||
// : this.data.detail.token_id,
|
||||
// s_price: this.price,
|
||||
// amount: this.piece ? this.cunout : null,
|
||||
// };
|
||||
|
||||
const res = await sellMyNft(data);
|
||||
// const res = await sellMyNft(data);
|
||||
|
||||
switch (this.type) {
|
||||
case "hero":
|
||||
console.log(this.type, "-=-",AppModule.chainId);
|
||||
'1338'
|
||||
console.log(CONTRACT_ADDRESS[AppModule.chainId]);
|
||||
this.nft_Token = CONTRACT_ADDRESS['1338'].hero;
|
||||
break;
|
||||
case "weapon":
|
||||
this.nft_Token = CONTRACT_ADDRESS['1338'].weapon;
|
||||
break;
|
||||
case "chip":
|
||||
this.nft_Token = CONTRACT_ADDRESS['1338'].chip;
|
||||
break;
|
||||
case "piece":
|
||||
this.nft_Token = CONTRACT_ADDRESS['1338'].piece;
|
||||
break;
|
||||
}
|
||||
try {
|
||||
const shellData = {
|
||||
nftToken: "",
|
||||
currency: "",
|
||||
nftToken: this.nft_Token,
|
||||
currency: this.value,
|
||||
tokenId: this.piece
|
||||
? this.piece.detail.token_id
|
||||
: this.data.detail.token_id,
|
||||
amount: this.piece ? this.cunout : null,
|
||||
amount: this.piece ? this.cunout : 1,
|
||||
price: this.price,
|
||||
marketAddress: "",
|
||||
marketAddress: CONTRACT_ADDRESS['1338'].address,
|
||||
};
|
||||
const res = await this.beginSell(shellData);
|
||||
console.log(res);
|
||||
console.log(shellData, "shellData");
|
||||
const nftres = await this.chainManager.bc.beginNftSell(
|
||||
this.nft_Token,
|
||||
this.value,
|
||||
this.piece ? this.piece.detail.token_id : this.data.detail.token_id,
|
||||
this.piece ? this.cunout : 1,
|
||||
this.price,
|
||||
CONTRACT_ADDRESS['1338'].address
|
||||
);
|
||||
console.log(nftres, "beginSell");
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
this.$message({
|
||||
type: "info",
|
||||
message: "error transfer",
|
||||
});
|
||||
console.log("query order status error", err);
|
||||
}
|
||||
|
||||
console.log("handMessage1", res);
|
||||
|
||||
},
|
||||
async beginSell(data) {
|
||||
return this.chainManager.beginNftSell({
|
||||
nftToken: data.nftToken,
|
||||
currency: data.currency,
|
||||
tokenId: data.tokenId,
|
||||
amount: data.amount,
|
||||
price: data.price,
|
||||
marketAddress: data.marketAddress,
|
||||
});
|
||||
async getOption() {
|
||||
const res = await getSupportedCurrenTypes();
|
||||
this.options = res.list;
|
||||
this.value = this.options[0].address;
|
||||
},
|
||||
init(data) {
|
||||
this.dialogVisible = true;
|
||||
|
@ -66,7 +66,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="pending">
|
||||
<div class="pending-order">PEBDING ORDER</div>
|
||||
<div class="pending-order" @click="haldBuy">PEBDING ORDER</div>
|
||||
<div class="confirm">CONFIRM</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -82,15 +82,32 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { AppModule } from "@/store/modules/app";
|
||||
import { CONTRACT_ADDRESS } from "@/configs/config_chain";
|
||||
import ChainManager from "@/chain/ChainManager";
|
||||
|
||||
export default {
|
||||
props: ["isBuy",'data'],
|
||||
data() {
|
||||
return {
|
||||
piece: "",
|
||||
orderId:'',
|
||||
chainManager: new ChainManager(),
|
||||
dialogVisible: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async haldBuy() {
|
||||
try {
|
||||
const nftres = await this.chainManager.bc.beginBuy(
|
||||
this.orderId,
|
||||
CONTRACT_ADDRESS["1338"].address
|
||||
);
|
||||
console.log(nftres, "beginSell");
|
||||
} catch (err) {
|
||||
console.log("query order status error", err);
|
||||
}
|
||||
},
|
||||
closeTip() {
|
||||
// 分发自定义事件(事件名: closeTip)
|
||||
this.$emit("handBuyHide");
|
||||
|
@ -179,6 +179,15 @@ export const AllChains = [
|
||||
symbol: 'MOVR',
|
||||
explorerurl: 'https://blockscout.moonriver.moonbeam.network/'
|
||||
},
|
||||
{
|
||||
name: "Local Testnet",
|
||||
type: "Local",
|
||||
rpc: "http://192.168.100.24:8545/",
|
||||
id: 1338,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://explorer.harmony.one",
|
||||
logo: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI0LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMiAzMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMzIgMzI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7ZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7ZmlsbDojMDA5M0REO30KCS5zdDF7ZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7ZmlsbDojRkZGRkZGO30KPC9zdHlsZT4KPGc+Cgk8Y2lyY2xlIGNsYXNzPSJzdDAiIGN4PSIxNiIgY3k9IjE2IiByPSIxNiIvPgoJPHBhdGggY2xhc3M9InN0MSIgZD0iTTEzLjUsMTZsNS4yLDUuM0wyMiwxOGMwLjYtMC42LDEuNS0wLjYsMiwwYzAsMCwwLDAsMCwwYzAuNiwwLjYsMC42LDEuNiwwLDIuMmwtNC4zLDQuNAoJCWMtMC42LDAuNi0xLjUsMC42LTIuMSwwYzAsMCwwLDAsMCwwbC02LjItNi40VjIyYzAsMC44LTAuNywxLjUtMS41LDEuNWMtMC44LDAtMS41LTAuNy0xLjUtMS41VjEwYzAtMC44LDAuNy0xLjUsMS41LTEuNQoJCWMwLjgsMCwxLjUsMC43LDEuNSwxLjV2My44bDYuMi02LjRjMC42LTAuNiwxLjUtMC42LDIuMSwwYzAsMCwwLDAsMCwwbDQuMyw0LjRjMC42LDAuNiwwLjYsMS42LDAsMi4yYy0wLjYsMC42LTEuNSwwLjYtMiwwCgkJYzAsMCwwLDAsMCwwbC0zLjMtMy40TDEzLjUsMTZ6IE0xOC43LDE0LjVjMC44LDAsMS41LDAuNywxLjUsMS41cy0wLjcsMS41LTEuNSwxLjVzLTEuNS0wLjctMS41LTEuNQoJCUMxNy4yLDE1LjIsMTcuOSwxNC41LDE4LjcsMTQuNXoiLz4KPC9nPgo8L3N2Zz4K'
|
||||
},
|
||||
{
|
||||
name: 'Fantom Testnet RPC',
|
||||
type: 'Testnet',
|
||||
|
@ -25,8 +25,8 @@ export const ALL_PROVIDERS = [
|
||||
}
|
||||
]
|
||||
|
||||
export const AVAILABLE_CHAINS = env === 'production' ? [321] : [322]
|
||||
|
||||
export const AVAILABLE_CHAINS = env === 'production' ? [321] : [80001]
|
||||
// [80001]:[1338] [322]
|
||||
export const OFFICE_ACCOUNT = env === 'production'
|
||||
? '0x565edA4ef351EB78F03B8AfCb6dCF02E29cAD62e'
|
||||
: '0x50A8e60041A206AcaA5F844a1104896224be6F39'
|
||||
@ -61,5 +61,27 @@ export const CONTRACT_ADDRESS:{[key: number]: any} = {
|
||||
ceg: '0xE388e872e63aadF5a4F1521E4d96C10A28091457',
|
||||
eth: '0xb296bab2ed122a85977423b602ddf3527582a3da',
|
||||
mall: '0xF278ff771F9E24968083B0bA54Cb42eb4B23C2d7'
|
||||
}
|
||||
},
|
||||
1338: {
|
||||
cec: '0xfeFc3aab779863c1624eE008aba485c53805dCeb',
|
||||
ceg: '0xE388e872e63aadF5a4F1521E4d96C10A28091457',
|
||||
eth: '0xb296bab2ed122a85977423b602ddf3527582a3da',
|
||||
mall: '0xF278ff771F9E24968083B0bA54Cb42eb4B23C2d7',
|
||||
hero: "0x9b1f7F645351AF3631a656421eD2e40f2802E6c0",
|
||||
weapon: "0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66",
|
||||
chip: "0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec",
|
||||
piece: "0x0E696947A06550DEf604e82C26fd9E493e576337",
|
||||
address: "0xf42Fe9b8e2009be073f1AeDc57a72623AC4F3045"
|
||||
},
|
||||
80001: {
|
||||
cec: '0xfeFc3aab779863c1624eE008aba485c53805dCeb',
|
||||
ceg: '0xE388e872e63aadF5a4F1521E4d96C10A28091457',
|
||||
eth: '0xb296bab2ed122a85977423b602ddf3527582a3da',
|
||||
mall: '0xF278ff771F9E24968083B0bA54Cb42eb4B23C2d7',
|
||||
hero: "0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62",
|
||||
weapon: "0x2F2Ed1c403cB7156617449795dE1CB47A0302a25",
|
||||
chip: "0x73482411443E87CAC124C12A10B34e9Aaa2De168",
|
||||
piece: "0xFc21A863bFb4E4534B246078772e2074e076f0a7",
|
||||
address: "0x806eA3301c2bA2a3C710D97931a6C0Fe00E45B33"
|
||||
},
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ export const setMini = (mini: string) => Cookies.set(miniKey, mini)
|
||||
|
||||
// User
|
||||
const tokenKey = 'vue_typescript_access_token'
|
||||
// export const getToken = () => localStorage.getItem(tokenKey)
|
||||
// export const setToken = (token: string) => localStorage.setItem(tokenKey, token)
|
||||
// export const removeToken = () => localStorage.removeItem(tokenKey)
|
||||
export const getToken = () => localStorage.getItem(tokenKey)
|
||||
export const setToken = (token: string) => localStorage.setItem(tokenKey, token)
|
||||
export const removeToken = () => localStorage.removeItem(tokenKey)
|
||||
|
||||
// export const getItem = (key: string) => localStorage.getItem(key)
|
||||
// export const setItem = (key: string, val: string) => localStorage.setItem(miniKey, val)
|
||||
// export const removeItem = (key: string) => localStorage.removeItem(key)
|
||||
export const getItem = (key: string) => localStorage.getItem(key)
|
||||
export const setItem = (key: string, val: string) => localStorage.setItem(key, val)
|
||||
export const removeItem = (key: string) => localStorage.removeItem(key)
|
||||
|
||||
export const getToken = () => Cookies.get(tokenKey)
|
||||
export const setToken = (token: string) => Cookies.set(tokenKey, token, { domain: 'cebg.games'})
|
||||
export const removeToken = () => Cookies.remove(tokenKey)
|
||||
// export const getToken = () => Cookies.get(tokenKey)
|
||||
// export const setToken = (token: string) => Cookies.set(tokenKey, token, { domain: 'cebg.games'})
|
||||
// export const removeToken = () => Cookies.remove(tokenKey)
|
||||
|
||||
export const getItem = (key: string) => Cookies.get(key)
|
||||
export const setItem = (key: string, val: string) => Cookies.set(key, val, { domain: 'cebg.games'})
|
||||
export const removeItem = (key: string) => Cookies.remove(key)
|
||||
// export const getItem = (key: string) => Cookies.get(key)
|
||||
// export const setItem = (key: string, val: string) => Cookies.set(key, val, { domain: 'cebg.games'})
|
||||
// export const removeItem = (key: string) => Cookies.remove(key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user