feat:

This commit is contained in:
john 2024-07-19 19:33:51 +08:00
parent 29a6ea86c1
commit 562a95ca9c
5 changed files with 357 additions and 421 deletions

View File

@ -1,12 +1,13 @@
### ###
# @LastEditors: John # @LastEditors: John
# @Date: 2024-07-02 11:31:07 # @Date: 2024-07-02 11:31:07
# @LastEditTime: 2024-07-18 17:35:13 # @LastEditTime: 2024-07-19 14:39:15
# @Author: John # @Author: John
### ###
VITE_BASE_URL=/ VITE_BASE_URL=/
VITE_BASE_API_URL=/api VITE_BASE_API_URL=
VITE_PARTICIPATE_CHAIN_ID=56 VITE_PARTICIPATE_CHAIN_ID=56
VITE_PURCHASED_CONTRACT_ADDRESS= VITE_PURCHASED_CONTRACT_ADDRESS=0xb8D623B24b6A9B7044C078B80c90B292e5b2ee13
VITE_NETWORK_USDT_ADDRESS= VITE_RECEIVE_RAMB_CONTRACT_ADDRESS=0x40b07C2944390f11bc14acF89710Bd7228Aca9bE
VITE_NETWORK_USDT_ADDRESS=0x55d398326f99059fF775485246999027B3197955
VITE_CHECK_TRANSACTION_DETAILS_URL=https://bscscan.com/ VITE_CHECK_TRANSACTION_DETAILS_URL=https://bscscan.com/

View File

@ -22,7 +22,7 @@
"type": "string" "type": "string"
} }
], ],
"name": "buyHMNFT", "name": "buyEquityNFT",
"outputs": [ "outputs": [
{ {
"internalType": "uint256", "internalType": "uint256",

View File

@ -1,205 +1,10 @@
[ [
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "constructor" "type": "constructor"
}, },
{
"inputs": [],
"name": "ECDSAInvalidSignature",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "length",
"type": "uint256"
}
],
"name": "ECDSAInvalidSignatureLength",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}
],
"name": "ECDSAInvalidSignatureS",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "allowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientAllowance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "approver",
"type": "address"
}
],
"name": "ERC20InvalidApprover",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "ERC20InvalidReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "ERC20InvalidSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "ERC20InvalidSpender",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
}
],
"name": "ERC2612ExpiredSignature",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "ERC2612InvalidSigner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256",
"name": "currentNonce",
"type": "uint256"
}
],
"name": "InvalidAccountNonce",
"type": "error"
},
{
"inputs": [],
"name": "InvalidShortString",
"type": "error"
},
{
"inputs": [
{
"internalType": "string",
"name": "str",
"type": "string"
}
],
"name": "StringTooLong",
"type": "error"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
@ -227,77 +32,23 @@
}, },
{ {
"anonymous": false, "anonymous": false,
"inputs": [], "inputs": [
"name": "EIP712DomainChanged", {
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event" "type": "event"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
},
{
"internalType": "uint8",
"name": "v",
"type": "uint8"
},
{
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}
],
"name": "permit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
@ -324,35 +75,52 @@
"type": "event" "type": "event"
}, },
{ {
"inputs": [ "constant": true,
{ "inputs": [],
"internalType": "address", "name": "_decimals",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [ "outputs": [
{ {
"internalType": "bool", "internalType": "uint8",
"name": "", "name": "",
"type": "bool" "type": "uint8"
} }
], ],
"stateMutability": "nonpayable", "payable": false,
"stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true,
"inputs": [],
"name": "_name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "_symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "address", "internalType": "address",
@ -373,10 +141,38 @@
"type": "uint256" "type": "uint256"
} }
], ],
"payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [ "inputs": [
{ {
"internalType": "address", "internalType": "address",
@ -392,10 +188,33 @@
"type": "uint256" "type": "uint256"
} }
], ],
"payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "burn",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [], "inputs": [],
"name": "decimals", "name": "decimals",
"outputs": [ "outputs": [
@ -405,66 +224,100 @@
"type": "uint8" "type": "uint8"
} }
], ],
"stateMutability": "pure", "payable": false,
"type": "function"
},
{
"inputs": [],
"name": "DOMAIN_SEPARATOR",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"inputs": [], "constant": false,
"name": "eip712Domain", "inputs": [
"outputs": [
{
"internalType": "bytes1",
"name": "fields",
"type": "bytes1"
},
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "version",
"type": "string"
},
{
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
},
{ {
"internalType": "address", "internalType": "address",
"name": "verifyingContract", "name": "spender",
"type": "address" "type": "address"
}, },
{ {
"internalType": "bytes32", "internalType": "uint256",
"name": "salt", "name": "subtractedValue",
"type": "bytes32" "type": "uint256"
},
{
"internalType": "uint256[]",
"name": "extensions",
"type": "uint256[]"
} }
], ],
"name": "decreaseAllowance",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getOwner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "addedValue",
"type": "uint256"
}
],
"name": "increaseAllowance",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [], "inputs": [],
"name": "name", "name": "name",
"outputs": [ "outputs": [
@ -474,29 +327,36 @@
"type": "string" "type": "string"
} }
], ],
"payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"inputs": [ "constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{ {
"internalType": "address", "internalType": "address",
"name": "owner", "name": "",
"type": "address" "type": "address"
} }
], ],
"name": "nonces", "payable": false,
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [], "inputs": [],
"name": "symbol", "name": "symbol",
"outputs": [ "outputs": [
@ -506,10 +366,12 @@
"type": "string" "type": "string"
} }
], ],
"payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true,
"inputs": [], "inputs": [],
"name": "totalSupply", "name": "totalSupply",
"outputs": [ "outputs": [
@ -519,7 +381,80 @@
"type": "uint256" "type": "uint256"
} }
], ],
"payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
} }
] ]

View File

@ -51,41 +51,6 @@
"name": "OwnershipTransferred", "name": "OwnershipTransferred",
"type": "event" "type": "event"
}, },
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "paymentTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "orderId",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "hashStr",
"type": "bytes32"
}
],
"name": "reward",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
@ -111,37 +76,17 @@
"name": "RewardSuccess", "name": "RewardSuccess",
"type": "event" "type": "event"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"name": "setUSDCAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "withdraw", "name": "R_MAB",
"outputs": [], "outputs": [
"stateMutability": "nonpayable", {
"internalType": "contract IERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
@ -178,15 +123,70 @@
}, },
{ {
"inputs": [], "inputs": [],
"name": "RMAB", "name": "renounceOwnership",
"outputs": [ "outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ {
"internalType": "contract IERC20", "internalType": "uint256",
"name": "", "name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "paymentTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "orderId",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "hashStr",
"type": "bytes32"
}
],
"name": "reward",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "addr",
"type": "address" "type": "address"
} }
], ],
"stateMutability": "view", "name": "setUSDCAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function" "type": "function"
} }
] ]

View File

@ -1,7 +1,7 @@
/* /*
* @LastEditors: John * @LastEditors: John
* @Date: 2024-06-19 15:48:57 * @Date: 2024-06-19 15:48:57
* @LastEditTime: 2024-07-18 18:33:04 * @LastEditTime: 2024-07-19 14:09:28
* @Author: John * @Author: John
*/ */
import { config } from "@/components/WalletProvider"; import { config } from "@/components/WalletProvider";
@ -168,13 +168,13 @@ export async function payByContract(
await authorizedU(amount); await authorizedU(amount);
} }
const NFTURI = const NFTURI =
"https://gateway.pinata.cloud/ipfs/QmWxBbFG3WJXVTDqrFUPhMuLmeHqKNBBkzSuvQyyk7ftfi/CodeConqueror-Bnb.json"; "https://gateway.lighthouse.storage/ipfs/bafkreicjdund46333jhrj556kkdsi7bqupyt2qi3lmylmtxcfiw7f2afe4";
console.log("参数:", amount, orderID, payInduction, NFTURI); console.log("参数:", amount, orderID, payInduction, NFTURI);
estimateGas(config, { estimateGas(config, {
to: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS, to: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS,
data: encodeFunctionData({ data: encodeFunctionData({
abi: RedDevilsAbi, abi: RedDevilsAbi,
functionName: "buyHMNFT", functionName: "buyEquityNFT",
args: [amount, orderID, payInduction, NFTURI], args: [amount, orderID, payInduction, NFTURI],
}), }),
}) })
@ -184,7 +184,7 @@ export async function payByContract(
writeContract(config, { writeContract(config, {
abi: RedDevilsAbi, abi: RedDevilsAbi,
address: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS, address: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS,
functionName: "buyHMNFT", functionName: "buyEquityNFT",
args: [amount, orderID, payInduction, NFTURI], args: [amount, orderID, payInduction, NFTURI],
gas: gasPrice, gas: gasPrice,
}) })
@ -193,12 +193,12 @@ export async function payByContract(
reslove(receipt); reslove(receipt);
}) })
.catch((err: BaseError) => { .catch((err: BaseError) => {
console.log("buyHMNFT Transaction err", err); console.log("buyEquityNFT Transaction err", err);
reject(err); reject(err);
}); });
}) })
.catch((err: BaseError) => { .catch((err: BaseError) => {
console.log("buyHMNFT estimateGas err", err); console.log("buyEquityNFT estimateGas err", err);
reject(err); reject(err);
}); });
} catch (err) { } catch (err) {