几天后,当我试图签署和提交订单时,我收到了一个糟糕的请求错误(状态代码400):
ERROR(status code 400): {
"code": 100,
"reason": "Validation Failed",
"validationErrors": [
{
"field": "",
"code": 1001,
"reason": "should be array"
}
]
}我没有改变代码中的任何东西,而且它以前也是有效的。我在Ropsten和Polygon上观察到了这种行为。status.0x.org显示在Ethereum上有一个重大事件,但在另外两个提到的网络上没有。
我们队的人能帮忙吗?
const utils = require("@0x/protocol-utils");
const contractAddresses = require("@0x/contract-addresses");
function Sign() {
async function sign() {
const CHAIN_ID = 3;
const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
const addresses = contractAddresses.getContractAddressesForChainOrThrow(CHAIN_ID);
// Calculate value for order expiry parameter (here: 50 minutes)
const getFutureExpiryInSeconds = () =>
Math.floor(Date.now() / 1000 + 3000000).toString();
// Unlock MetaMask
const accounts = await window.ethereum.request({
method: "eth_requestAccounts"
});
// Use currently connected MetaMask account as the maker account
const maker = accounts[0];
console.log("Maker address: " + maker)
const order = new utils.LimitOrder({
makerToken: "0xc03ce38bc55836a4ef61ab570253cd7bfff3af44",
takerToken: "0xad6d458402f60fd3bd25163575031acdce07538d",
makerAmount: "1000",
takerAmount: "1000",
maker: maker,
expiry: getFutureExpiryInSeconds(),
salt: Date.now().toString(),
chainId: CHAIN_ID,
verifyingContract: addresses.exchangeProxy,
takerTokenFeeAmount: "0",
sender: NULL_ADDRESS,
feeRecipient: "0x0000000000000000000000000000000000000000",
});
console.dir(order);
// Sign order conforming to the EIP712 standard
const signature = await order.getSignatureWithProviderAsync(
window.ethereum,
utils.SignatureType.EIP712
);
console.log(`Signature: ${JSON.stringify(signature, undefined, 2)}`);
// Append signature object to order object for the post of the order
const signedOrder = { ...order, signature };
console.log(signedOrder)
const resp = await fetch("https://ropsten.api.0x.org/orderbook/v1/order", {
method: "POST",
body: JSON.stringify(signedOrder),
headers: {
"Content-Type": "application/json"
}
});
// Handle response
if (resp.status === 200) {
alert("Successfully posted order to SRA");
} else {
const body = await resp.json();
alert(
`ERROR(status code ${resp.status}): ${JSON.stringify(body, undefined, 2)}`
)
}
}
return (
Sign and submit
);
}
export default Sign;`发布于 2022-03-29 19:14:25
谢谢你报道这个问题。我们的团队正在积极调查这400人为什么会出现在Ropsten Orderbook上。当我们了解得更多的时候会回来的。
https://ethereum.stackexchange.com/questions/124476
复制相似问题