Skip to content

Commit

Permalink
Merge pull request #3 from para-space/update-the-seaport-sdk
Browse files Browse the repository at this point in the history
Update the seaport sdk
  • Loading branch information
wenyuntian authored Dec 27, 2023
2 parents 8ac3746 + ee51a60 commit 19311a9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
20 changes: 13 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paraspace/seaport-js",
"version": "1.0.11",
"name": "paraspace-seaport-js",
"version": "0.0.2",
"description": "[Seaport](https://github.com/ProjectOpenSea/seaport) is a new marketplace protocol for safely and efficiently buying and selling NFTs. This is a JavaScript library intended to make interfacing with the contract reasonable and easy.",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down
21 changes: 12 additions & 9 deletions src/seaport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,19 @@ export class Seaport {
fees,
domain,
salt,
offerer,
}: CreateOrderInput,
accountAddress?: string
): Promise<OrderUseCase<CreateOrderAction>> {
const signer = this._getSigner(accountAddress);
const offerer = await signer.getAddress();
const signerAddress = await signer.getAddress();
const defaultOfferer = signerAddress;
const actualOfferer = offerer || defaultOfferer;
const offerItems = offer.map(mapInputItemToOfferItem);
const considerationItems = [
...consideration.map((consideration) => ({
...mapInputItemToOfferItem(consideration),
recipient: consideration.recipient ?? offerer,
recipient: consideration.recipient ?? actualOfferer,
})),
];

Expand All @@ -254,9 +257,9 @@ export class Seaport {
const operator = this.config.conduitKeyToConduit[conduitKey];

const [resolvedCounter, balancesAndApprovals] = await Promise.all([
counter ?? this.getCounter(offerer),
counter ?? this.getCounter(actualOfferer),
getBalancesAndApprovals({
owner: offerer,
owner: actualOfferer,
items: offerItems,
criterias: [],
multicallProvider: this.multicallProvider,
Expand Down Expand Up @@ -288,7 +291,7 @@ export class Seaport {
(domain ? generateRandomSaltWithDomain(domain) : generateRandomSalt());

const orderParameters: OrderParameters = {
offerer,
offerer: actualOfferer,
zone,
// TODO: Placeholder
zoneHash: formatBytes32String(resolvedCounter.toString()),
Expand Down Expand Up @@ -328,7 +331,7 @@ export class Seaport {
const signature = await this.signOrder(
orderParameters,
resolvedCounter,
offerer
signerAddress
);

return {
Expand Down Expand Up @@ -392,15 +395,15 @@ export class Seaport {
* Submits a request to your provider to sign the order. Signed orders are used for off-chain order books.
* @param orderParameters standard order parameter struct
* @param counter counter of the offerer
* @param accountAddress optional account address from which to sign the order with.
* @param signerAddress optional account address from which to sign the order with.
* @returns the order signature
*/
public async signOrder(
orderParameters: OrderParameters,
counter: number,
accountAddress?: string
signerAddress?: string
): Promise<string> {
const signer = this._getSigner(accountAddress);
const signer = this._getSigner(signerAddress);

const domainData = await this._getDomainData();

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export type CreateOrderInput = {
useProxy?: boolean;
domain?: string;
salt?: string;
offerer?: string;
};

export type InputCriteria = {
Expand Down

0 comments on commit 19311a9

Please sign in to comment.