-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
197 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"goerli":{"nftContract":"0x22411b480425fe6e627fdf4d1b6ac7f8567314ada5617a0a6d8ef3e74b69436","messaging":"0x2c3d3e0c37d29364a13ba8cff046e7bc5624655a72526961876a1c8bb3f63c8","executor":"0x73148536f8ea9546e92761d11515548cc433df46883d5ee98871a6f63a0bbbc","orderbook":"0x66f1e6acf9bdbd23837b2eea271430298b355c506978edb132737e7fcb6b310"},"sepolia":{},"mainnet":{},"dev":{"messaging":"0x57267e9d7fcba7826d324b3766887fee7882e11c52553999f83bf7746ac4c65","executor":"0x78f192d8081c68ec4fcc95b17435ceaad4abb26b3227b5d86553fda351912ae","nftContract":"0x552e8522d541d69f608b30a7f5c26092003c2ac5cbdf64ac6da6a03674a56d3","eth":"0x144a0c8ae6e665dc3652e164ba2881eda87ad9cb5dcc93d30ca6d61b818014c","orderbook":"0x4b6fd3b86c499ce95497234c4cc34bc2db6ba689f8b43ae770535d882984ab7"}} | ||
{"goerli":{"nftContract":"0x22411b480425fe6e627fdf4d1b6ac7f8567314ada5617a0a6d8ef3e74b69436","messaging":"0x2c3d3e0c37d29364a13ba8cff046e7bc5624655a72526961876a1c8bb3f63c8","executor":"0x73148536f8ea9546e92761d11515548cc433df46883d5ee98871a6f63a0bbbc","orderbook":"0x66f1e6acf9bdbd23837b2eea271430298b355c506978edb132737e7fcb6b310"},"sepolia":{},"mainnet":{},"dev":{"messaging":"0x4bdd099d33838dd7aa2180541be9a665c8148be8205cdbee92a88f4f680803d","executor":"0x46187fac3431972871364fe5c784507fbe9d60e08fad91e6c983faf12b08267","nftContract":"0x1ac7982ca86262ebdc938721a8946b7d780f0b82e90bdc30c569873c5ee1ade","eth":"0x144a0c8ae6e665dc3652e164ba2881eda87ad9cb5dcc93d30ca6d61b818014c","orderbook":"0x3195b557a4e0420af3085b15ae4d45f1252f8b5f19c0eb12fd0d579dc7a5fb"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { BigNumberish, shortString } from "starknet"; | ||
|
||
import { createAccount, fetchOrCreateAccount } from "../src/actions/account/account"; | ||
import { createListing, fulfillListing } from "../src/actions/order"; | ||
import { getOrderHash, getOrderStatus } from "../src/actions/read"; | ||
import { ListingV1 } from "../src/types"; | ||
import { generateRandomTokenId, sleep } from "./utils"; | ||
|
||
import { config } from "../examples/config"; | ||
import { whitelistBroker } from "../examples/utils/whitelistBroker"; | ||
|
||
|
||
describe("ArkProject Listing", () => { | ||
it("should create and fulfill a listing", async () => { | ||
const { arkProvider, starknetProvider } = config; | ||
|
||
const solisAdminAccount = await fetchOrCreateAccount( | ||
config.arkProvider, | ||
process.env.SOLIS_ADMIN_ADDRESS_DEV, | ||
process.env.SOLIS_ADMIN_PRIVATE_KEY_DEV | ||
); | ||
|
||
await whitelistBroker( | ||
config, | ||
solisAdminAccount, | ||
123 | ||
); | ||
|
||
// Create a new account using the provider | ||
const { account: arkAccount } = await createAccount(arkProvider); | ||
const { account: starknetAccount } = await createAccount(starknetProvider); | ||
|
||
const order: ListingV1 = { | ||
brokerId: 123, // The broker ID | ||
tokenAddress: | ||
"0x01435498bf393da86b4733b9264a86b58a42b31f8d8b8ba309593e5c17847672", // The token address | ||
tokenId: generateRandomTokenId(), // The ID of the token | ||
startAmount: 600000000000000000 // The starting amount for the order | ||
}; | ||
|
||
const orderHash = await createListing(config, { | ||
starknetAccount, | ||
arkAccount, | ||
order | ||
}); | ||
|
||
await sleep(1000); | ||
|
||
const { orderStatus: orderStatusBefore } = await getOrderStatus(config, { | ||
orderHash | ||
}); | ||
|
||
expect(shortString.decodeShortString(orderStatusBefore)).toBe("OPEN"); | ||
|
||
// Create a new accounts for the fulfill using the provider | ||
const { account: starknetFulfillerAccount } = | ||
await createAccount(starknetProvider); | ||
|
||
const fulfill_info = { | ||
orderHash, | ||
tokenAddress: order.tokenAddress, | ||
tokenId: order.tokenId, | ||
brokerId: 123 | ||
}; | ||
|
||
fulfillListing( | ||
config, | ||
{ | ||
starknetAccount: starknetFulfillerAccount, | ||
arkAccount, | ||
fulfillListingInfo: fulfill_info | ||
} | ||
); | ||
await sleep(1000); | ||
|
||
const { orderStatus: orderStatusAfter } = await getOrderStatus(config, { | ||
orderHash | ||
}); | ||
|
||
expect(shortString.decodeShortString(orderStatusAfter)).toBe("FULFILLED"); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { shortString } from "starknet"; | ||
|
||
import { | ||
createAccount, | ||
createOffer, fetchOrCreateAccount, | ||
fulfillOffer, | ||
getOrderStatus, | ||
OfferV1 | ||
} from "../src"; | ||
import { generateRandomTokenId } from "./utils"; | ||
import { config } from "../examples/config"; | ||
import { whitelistBroker } from "../examples/utils/whitelistBroker"; | ||
|
||
|
||
describe("ArkProject Listing and Offer Fulfillment", () => { | ||
it("should create an offer and fulfill the offer", async function () { | ||
|
||
const { arkProvider, starknetProvider } = config; | ||
|
||
const solisAdminAccount = await fetchOrCreateAccount( | ||
config.arkProvider, | ||
process.env.SOLIS_ADMIN_ADDRESS_DEV, | ||
process.env.SOLIS_ADMIN_PRIVATE_KEY_DEV | ||
); | ||
|
||
await whitelistBroker( | ||
config, | ||
solisAdminAccount, | ||
123 | ||
); | ||
|
||
// Create a new account for the listing using the provider | ||
const { account: arkAccount } = await createAccount(arkProvider); | ||
const { account: starknetAccount } = await createAccount(starknetProvider); | ||
|
||
// Define the order details | ||
const order: OfferV1 = { | ||
brokerId: 123, // The broker ID | ||
tokenAddress: | ||
"0x01435498bf393da86b4733b9264a86b58a42b31f8d8b8ba309593e5c17847672", // The token address | ||
tokenId: generateRandomTokenId(), // The ID of the token | ||
startAmount: 600000000000000000 // The starting amount for the order | ||
}; | ||
|
||
// Create the listing on the arkchain using the order details | ||
const orderHash = await createOffer(config,{starknetAccount, arkAccount, offer: order }); | ||
|
||
expect(orderHash).toBeDefined(); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
|
||
await expect( | ||
getOrderStatus(config, {orderHash}).then((res) => | ||
shortString.decodeShortString(res.orderStatus) | ||
) | ||
).resolves.toEqual("OPEN"); | ||
|
||
|
||
// Create a new account for fulfilling the offer | ||
const { account: starknetFulfillerAccount } = | ||
await createAccount(starknetProvider); | ||
|
||
expect(starknetFulfillerAccount).toBeDefined(); | ||
|
||
// Define the fulfill details | ||
const fulfill_info = { | ||
orderHash, | ||
tokenAddress: order.tokenAddress, | ||
tokenId: order.tokenId, | ||
brokerId: 123 | ||
}; | ||
|
||
// Fulfill the offer | ||
await fulfillOffer( | ||
config, | ||
{ | ||
starknetAccount: starknetFulfillerAccount, | ||
arkAccount, | ||
fulfillOfferInfo: fulfill_info | ||
} | ||
); | ||
|
||
|
||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
|
||
await expect( | ||
getOrderStatus(config, {orderHash}).then((res) => | ||
shortString.decodeShortString(res.orderStatus) | ||
) | ||
).resolves.toEqual("FULFILLED"); | ||
|
||
}, 10000); | ||
}); |