looksrare / looksrare-sdk Goto Github PK
View Code? Open in Web Editor NEWLooksRare TypeScript SDK
License: MIT License
LooksRare TypeScript SDK
License: MIT License
Rinkeby Test Environment:
const signer = new ethers.Wallet(“prvatekey”);
const signerAddress = await signer.getAddress();
let nonce = await web3.eth.getTransactionCount(signerAddress);
const makerOrder: MakerOrder = {
isOrderAsk: true,
signer: signerAddress,
collection: "0xfE484120024431AFcbEadF09DcdCBe9f7e63671F",
price: "10000000000000000000", // :warning: PRICE IS ALWAYS IN WEI :warning:
tokenId: "10001", // Token id is 0 if you use the STRATEGY_COLLECTION_SALE strategy
amount: "1",
strategy: addresses.STRATEGY_STANDARD_SALE,
currency: 'ETH',
nonce: nonce,
startTime:now,
endTime: now + 86400, // 1 day validity
minPercentageToAsk: Math.min(8500, 8500),
params: paramsValue,
};
const { domain, type } = getMakerOrderTypedData(chainId, addresses.EXCHANGE);
const signature = await signer._signTypedData(domain, type, makerOrder);
error:cannot resolve ENS names without a provider (operation="resolveName", value="ETH",
code=UNSUPPORTED_OPERATION, version=wallet/5.6.1)
someone can help me?
Describe the bug
Getting an array length error during Abi encoding when calling the signMakerOrder()
function in the SDK to purchase an NFT listed on the Rinkeby testnet (any real world example JS script of a Rinkeby testnet purchase using the SDK will be appreciated).
An unexpected error occurred:
TypeError: Cannot read property 'length' of undefined
at AbiCoder.encode (/Users/nemitariajienka/Desktop/projects/heni-nftmarket-contract/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:101:19)
at /Users/nemitariajienka/Desktop/projects/heni-nftmarket-contract/node_modules/@looksrare/sdk/dist/index.cjs.js:7191:46
at Generator.next (<anonymous>)
at fulfilled (/Users/nemitariajienka/Desktop/projects/heni-nftmarket-contract/node_modules/@looksrare/sdk/dist/index.cjs.js:7086:58)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
To Reproduce
Steps to reproduce the behavior:
Create a makerOrder to purchase any NFT listed on the LooksRare Rinkeby testnet, e.g., https://rinkeby.looksrare.org/collections/0xd4C4643053E46eacffa06E2573641907a54125Fb/12
Either add or do not add the asset price in Wei
within the paramsValue array and specify the type in the paramsTypes array as ['uint']
.
The order used is as follows:
const makerOrder = {
// true --> ask / false --> bid
isOrderAsk: false,
// signer address of the maker order
signer: signers[0].address,
// collection address
collection: '0xd4C4643053E46eacffa06E2573641907a54125Fb',
// Price in WEI
price: ethers.utils.parseEther('0.0001'),
// Token ID
tokenId: 12,
// amount of tokens to sell/purchase (must be 1 for ERC721, 1+ for ERC1155)
amount: 1,
// strategy for trade execution (e.g., DutchAuction, StandardSaleForFixedPrice), see addresses in the SDK
strategy: '0x732319A3590E4fA838C111826f9584a9A2fDEa1a',
// currency address
currency: '0xc778417E063141139Fce010982780140Aa0cD5Ab', // should be eth
// order nonce (must be unique unless new maker order is meant to override existing one e.g., lower ask price)
nonce: 678,
// startTime timestamp in seconds
startTime: Date.now(),
// endTime timestamp in seconds
endTime: (Date.now()) + 604800,
// minimum ratio to be received by the user (per 10000)
minPercentageToAsk: 0, // BigNumber.from(10000).sub(protocolFees.add(creatorFees)).toNumber(),
// params (e.g., price, target account for private sale)
params: paramsValue,
};
Expected behavior
The order should be signed and broadcasted on chain with a successful purchase and transfer of ownership of the listed NFT to the buyer address.
Additional context
None.
First of all, I'm so thankful for the LooksRare dev team develop the looksrare-sdk:)
When I use the function signMakerOrder in looksare-sdk to SIGN my order data, it got
MethodNotSupportedError: Method eth_signTypedData is not supported
I am sure that is the my using ethereum rpc service doesn't support the eth_signTypedData
method, since I check on the looksrare-sdk's source code, I found we must use the Metamask like walet to reach this sigTypedData
function.
I just wonder is there any other way to finish this signature fucntion in my local server? or other third part lib?
Is your feature request related to a problem? Please describe.
Looks Rare's UI does not support EIP1271. It makes the usage of smart contract wallets impossible for certain operations e.g making an offer.
Describe the solution you'd like
Support EIP1271, it is pretty simple.
Describe alternatives you've considered
Additional context
Overview:
Items are objects working as ERC1155 and ERC20 at the same time. All Items have 18 decimals (both on ERC1155 and ERc20 side) and not 0 like standard ERC1155. Also, all Items have the same 1155 address but have virtualized Collections.
With this issue, we want to provide you with all the info to correctly show items decimal and the items collection.
If you need more info send us an email:
[email protected]
Problem:
Decimals
The LooksRare interface does not read the decimals of the Items correctly as it reads all tokens as normal ERC1155 with 0 decimals. As a result, tokens with 18 decimals result in a wrong supply/balance causing issues for users.
Collections
All Items have the same 1155 address (0x8d53aFBEB62C18917B5F71385d52E8ba87669794 on Ethereum mainnet) since they all belong to the Main Interface smart contract. Consequently they are all seen as part of the same Collection. However each Item belongs to a specific virtualized Collection defined by a bytes32
identifier. In fact, each Collection has its own specific Metadata and minting permissions.
Solution:
Decimals
All you need to do to correctly display the supply/balance of an Item is to implement the following code in your frontend: web3.utils.fromWei("1000000000000000000", 'ether')
"10000000000000000000000" would be the Item's supply.
For example, [$OS](https://etherscan.io/token/0x6100dd79fcaa88420750dcee3f735d168abcb771) is an Item, and has a supply of roughly 1 million. But, without this precaution, the supply is displayed as much, much more:
1000000000000000000000000
(i.e. without the proper decimals).web3.utils.fromWei
it displays the $OS supply as 100000000000000000000
Collections
All you need to do to correctly display Items Collection is to divide in your Interface the Items by Collection and not show them all under one "items" collection.
To do this just read from the CollectionItem
event emitted every time a new Item is mined. The event has the second bytes32
parameter that indicates the specific id
of the Collection it belongs to.
The following code can be used as a guideline:
var collectionIds = [collectionId1, collectionId2];
var allCollectionItems = await web3.eth.getPastLogs({
fromBlock: '0',
toBlock: 'latest',
address: itemMainInterface.options.address,
topics: [
web3.utils.sha3("CollectionItem(bytes32,bytes32,uint256)"),
null,
collectionIds.map(it => web3.eth.abi.encodeParameter("bytes32", it))
]
});
var collectionItems = { };
allCollectionItems.forEach(it => {
var collectionId = web3.eth.abi.decodeParameter("bytes32", it.topics[2]);
var itemId = web3.eth.abi.decodeParameter("uint256", it.topics[3]);
(collectionItems[collectionId] = collectionItems[collectionId] || []).push(objectId);
});
Resources:
https://docs.ethos.wiki/ethereansos-docs/items/items/frontend-integration/frontend-reconstruction
-1 (connected: true, keepalive socket: false, agent status: {"createSocketCount":1,"createSocketErrorCount":0,"closeSocketCount":0,"errorSocketCount":1,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{"api-rinkeby.looksrare.org:443:::::::::::::::::::::":1},"requests":{}}, socketHandledRequests: 1, socketHandledResponses: 0)
headers: {}
how to use apikey
Describe the bug
The MakerOrder
is defined here:
export interface MakerOrder {
isOrderAsk: boolean; // true --> ask / false --> bid
signer: string; // signer address of the maker order
collection: string; // collection address
price: BigNumberish;
tokenId: BigNumberish; // id of the token
amount: BigNumberish; // amount of tokens to sell/purchase (must be 1 for ERC721, 1+ for ERC1155)
strategy: string; // strategy for trade execution (e.g., DutchAuction, StandardSaleForFixedPrice)
currency: string; // currency address
nonce: BigNumberish; // order nonce (must be unique unless new maker order is meant to override existing one e.g., lower ask price)
startTime: BigNumberish; // startTime in timestamp
endTime: BigNumberish; // endTime in timestamp
minPercentageToAsk: BigNumberish;
params: any[]; // params (e.g., price, target account for private sale)
}
But its encoder function seems to be implemented bugly
params: any[];
export const encodeOrderParams = (params?: any[] | null): { paramsTypes: SolidityType[]; encodedParams: BytesLike } => {
const nonNullParams = params || [];
const paramsTypes: SolidityType[] = nonNullParams.map((param): SolidityType => {
if (utils.isAddress(param)) {
return "address";
}
if (typeof param === "boolean") {
return "bool";
}
try {
BigNumber.from(param);
return "uint256";
} catch (error) {
throw Error("Params have unsupported solidity types");
}
});
return { paramsTypes, encodedParams: utils.defaultAbiCoder.encode(paramsTypes, nonNullParams) };
};
Could you please add the rinkeby looksrare exchange contract abi to the list of abi's that you can import from "@looksrare/sdk"?
Describe the bug
Getting transaction failed with "SafeERC20: low-level call failed" when trying to execute matchAskWithTakerBid or matchAskWithTakerBidUsingETHAndWETH
To Reproduce
Steps to reproduce the behavior:
Taker order
{
isOrderAsk: false
minPercentageToAsk: 7500
params: "0x"
price: "100000000000000000"
taker: "0xe05eb8fcd5203aa6cceebc4bd5e926f1e76dc405"
tokenId: "8"
}
Maker order (valid order from API)
{
"hash": "0x263fd731080437f73c73d1402946723e066fd232fc33f8a30fc09387885999cd",
"tokenId": "8",
"isOrderAsk": true,
"signer": "0xe05eb8fCd5203aa6ccEEbC4BD5e926f1e76DC405",
"strategy": "0x579af6FD30BF83a5Ac0D636bc619f98DBdeb930c",
"amount": "1",
"price": "100000000000000000",
"nonce": "4",
"startTime": 1674760693,
"endTime": 1677319650,
"minPercentageToAsk": 9800,
"params": "0x",
"status": "VALID",
"signature": "0x2d11f72c2f564e4f3bac105c53d10bda80cadd425450bb4858bd98256000bd9d442332a33887a775f3ec43617785f4ee10f58a58bd19f8c323e2b733db264e9b1b",
"v": 27,
"r": "0x2d11f72c2f564e4f3bac105c53d10bda80cadd425450bb4858bd98256000bd9d",
"s": "0x442332a33887a775f3ec43617785f4ee10f58a58bd19f8c323e2b733db264e9b",
"collection": "0xAEBb154e912036E5DD036CAf1bDc63C85c5A37f4",
"currency": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
}
const exchangeInterface = new ethers.utils.Interface(LooksRareExchangeAbi);
const exchangeContract = new ethers.Contract(addresses.EXCHANGE, exchangeInterface, signer);
await exchangeContract.functions.matchAskWithTakerBidUsingETHAndWETH(takerOrder, makerOrder);
Provider is Metamask. Other transactions execute fine.
Please advice
Expected behavior
Transaction executed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.