Browse Source

chore: 优化授权调用

master
kiki 2 years ago
parent
commit
317a8b348b
  1. 47
      pages/index/index.vue
  2. 41
      utils/web3x/ippt-abi.json
  3. 546
      utils/web3x/usdt-abi.json

47
pages/index/index.vue

@ -57,6 +57,9 @@
import {
web3x
} from "@/utils/web3x/web3x.js"
const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186'
export default {
components: {
GeneralButton,
@ -114,13 +117,45 @@
})
//
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()
})
})
}
// USDT IPPT ( IPPT )
await web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186")
uni.hideLoading()
// IPPT
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400:
// web3x.selectedAddress:
await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress)
// 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()
// })
})
},
go(val) {

41
utils/web3x/ippt-abi.json

@ -15,5 +15,46 @@
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]

546
utils/web3x/usdt-abi.json

@ -1,88 +1,122 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"constant": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"name": "_upgradedAddress",
"type": "address"
},
}
],
"name": "deprecate",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "spender",
"name": "_spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"name": "_value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
"name": "approve",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"constant": true,
"inputs": [],
"name": "deprecated",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"name": "_evilUser",
"type": "address"
},
}
],
"name": "addBlackList",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
"name": "",
"type": "uint256"
}
],
"name": "OwnershipTransferred",
"type": "event"
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"constant": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"name": "_from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"name": "_to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"name": "_value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
"name": "transferFrom",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "_decimals",
"name": "upgradedAddress",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
"type": "address"
}
],
"payable": false,
@ -91,13 +125,17 @@
},
{
"constant": true,
"inputs": [],
"name": "_name",
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "balances",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
"type": "uint256"
}
],
"payable": false,
@ -107,12 +145,11 @@
{
"constant": true,
"inputs": [],
"name": "_symbol",
"name": "decimals",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
"type": "uint256"
}
],
"payable": false,
@ -121,22 +158,24 @@
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
"inputs": [],
"name": "maximumFee",
"outputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
"name": "",
"type": "uint256"
}
],
"name": "allowance",
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "_totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
@ -147,43 +186,47 @@
},
{
"constant": false,
"inputs": [],
"name": "unpause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "spender",
"name": "_maker",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"name": "getBlackListStatus",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "account",
"name": "",
"type": "address"
},
{
"name": "",
"type": "address"
}
],
"name": "balanceOf",
"name": "allowed",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
@ -195,12 +238,11 @@
{
"constant": true,
"inputs": [],
"name": "decimals",
"name": "paused",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
"type": "bool"
}
],
"payable": false,
@ -208,28 +250,30 @@
"type": "function"
},
{
"constant": false,
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "spender",
"name": "who",
"type": "address"
},
{
"internalType": "uint256",
"name": "subtractedValue",
"type": "uint256"
}
],
"name": "decreaseAllowance",
"name": "balanceOf",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "pause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
@ -239,7 +283,6 @@
"name": "getOwner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
@ -248,28 +291,66 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "spender",
"name": "_to",
"type": "address"
},
{
"internalType": "uint256",
"name": "addedValue",
"name": "_value",
"type": "uint256"
}
],
"name": "increaseAllowance",
"outputs": [
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
"name": "newBasisPoints",
"type": "uint256"
},
{
"name": "newMaxFee",
"type": "uint256"
}
],
"name": "setParams",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
@ -278,32 +359,47 @@
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [
"name": "issue",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
"name": "amount",
"type": "uint256"
}
],
"name": "redeem",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "name",
"inputs": [
{
"name": "_owner",
"type": "address"
},
{
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
"name": "remaining",
"type": "uint256"
}
],
"payable": false,
@ -313,22 +409,45 @@
{
"constant": true,
"inputs": [],
"name": "owner",
"name": "basisPointsRate",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "isBlackListed",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"inputs": [
{
"name": "_clearedUser",
"type": "address"
}
],
"name": "removeBlackList",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
@ -337,12 +456,11 @@
{
"constant": true,
"inputs": [],
"name": "symbol",
"name": "MAX_UINT",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
"type": "uint256"
}
],
"payable": false,
@ -350,90 +468,204 @@
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "view",
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "recipient",
"name": "_blackListedUser",
"type": "address"
}
],
"name": "destroyBlackFunds",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_initialSupply",
"type": "uint256"
},
{
"name": "_name",
"type": "string"
},
{
"name": "_symbol",
"type": "string"
},
{
"internalType": "uint256",
"name": "_decimals",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
"name": "Issue",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
"name": "Redeem",
"type": "event"
},
{
"constant": false,
"anonymous": false,
"inputs": [
{
"internalType": "address",
"name": "sender",
"indexed": false,
"name": "newAddress",
"type": "address"
}
],
"name": "Deprecate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "feeBasisPoints",
"type": "uint256"
},
{
"internalType": "address",
"name": "recipient",
"indexed": false,
"name": "maxFee",
"type": "uint256"
}
],
"name": "Params",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_blackListedUser",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"indexed": false,
"name": "_balance",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
"name": "DestroyedBlackFunds",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
"indexed": false,
"name": "_user",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
"name": "AddedBlackList",
"type": "event"
},
{
"constant": false,
"anonymous": false,
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"indexed": false,
"name": "_user",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
"name": "RemovedBlackList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"anonymous": false,
"inputs": [],
"name": "Pause",
"type": "event"
},
{
"anonymous": false,
"inputs": [],
"name": "Unpause",
"type": "event"
}
]
Loading…
Cancel
Save