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 { import {
web3x web3x
} from "@/utils/web3x/web3x.js" } from "@/utils/web3x/web3x.js"
const ipptAddress = '0x622d7b79a904e00e5fcab06396ff009e441f0186'
export default { export default {
components: { components: {
GeneralButton, GeneralButton,
@ -114,13 +117,45 @@
}) })
// //
console.log("当前钱包地址", web3x.selectedAddress); 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 ) // USDT IPPT ( IPPT )
await web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186") // web3x.usdt.approveMAX("0x622d7b79a904e00e5fcab06396ff009e441f0186")
uni.hideLoading() // .on("transactionHash", async (receipt) => {
// IPPT // console.log("transactionHash", receipt)
// 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400: // // IPPT
// web3x.selectedAddress: // // 0xFb4FC7Ddb8c4aa6b944703CE1e89D2B9Aa67a400:
await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress) // // web3x.selectedAddress:
// await web3x.ippt.$creatCode(this.form.supAddress, web3x.selectedAddress)
// uni.hideLoading()
// })
}) })
}, },
go(val) { go(val) {

41
utils/web3x/ippt-abi.json

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