Use pricePerBytePerSecond instead of reward

This commit is contained in:
Arnaud 2025-02-07 18:28:03 +01:00
parent af70ee5330
commit 0961b50327
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
4 changed files with 13 additions and 11 deletions

View File

@ -192,7 +192,7 @@ Example:
```js
const request = await marketplace.createStorageRequest({
duration: 3000,
reward: 100,
pricePerBytePerSecond: 1,
proofProbability: 1,
nodes: 1,
tolerance: 0,

View File

@ -12,7 +12,7 @@ function createStorageRequest() {
return {
cid: randomString(64),
duration: randomInt(1, 64000),
reward: randomInt(1, 100),
pricePerBytePerSecond: randomInt(1, 100),
proofProbability: randomInt(1, 100),
nodes: randomInt(1, 5),
tolerance: randomInt(1, 100),
@ -325,12 +325,15 @@ describe("marketplace", () => {
assert.deepStrictEqual(response, minNumberValidationError("duration", 1));
});
it("returns an error when trying to create a storage request without reward", async () => {
const { reward, ...rest } = createStorageRequest();
it("returns an error when trying to create a storage request without pricePerBytePerSecond", async () => {
const { pricePerBytePerSecond, ...rest } = createStorageRequest();
const response = await marketplace.createStorageRequest(rest as any);
assert.deepStrictEqual(response, missingNumberValidationError("reward"));
assert.deepStrictEqual(
response,
missingNumberValidationError("pricePerBytePerSecond")
);
});
it("returns an error when trying to create a storage request without proof probability", async () => {

View File

@ -236,7 +236,7 @@ export class CodexMarketplace {
const {
cid,
duration,
reward,
pricePerBytePerSecond,
proofProbability,
nodes,
collateral,
@ -249,7 +249,7 @@ export class CodexMarketplace {
method: "POST",
body: JSON.stringify({
duration: duration.toString(),
reward: reward.toString(),
pricePerBytePerSecond: pricePerBytePerSecond.toString(),
proofProbability: proofProbability.toString(),
nodes,
collateral: collateral.toString(),

View File

@ -30,10 +30,9 @@ export type CodexStorageRequest = {
proofProbability: string;
/**
* The maximum amount of tokens paid per second per slot to hosts
* the client is willing to pay.
* The amount of tokens paid per byte per second per slot to hosts the client is willing to pay
*/
reward: string;
pricePerBytePerSecond: string;
/**
* Max slots that can be lost without data considered to be lost.
@ -215,7 +214,7 @@ export type CodexPurchase = {
export const CodexCreateStorageRequestInput = v.strictObject({
cid: v.string(),
duration: v.pipe(v.number(), v.minValue(1)),
reward: v.number(),
pricePerBytePerSecond: v.number(),
proofProbability: v.number(),
nodes: v.optional(v.number(), 1),
tolerance: v.optional(v.number(), 0),