Skip to content

Commit

Permalink
chore: address clippy errors (#22)
Browse files Browse the repository at this point in the history
* chore: address clippy errors
* feat: update to newest near-sdk-rs
* feat!: break up initial args
  • Loading branch information
willemneal authored Feb 2, 2022
1 parent 1f57f61 commit e55bac8
Show file tree
Hide file tree
Showing 14 changed files with 967 additions and 198 deletions.
738 changes: 679 additions & 59 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions __test__/allowance.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ const runner = Workspace.init(
async ({ root }) => {
const alice = await root.createAccount("alice");
const tenk = await deploy(root, "tenk", {
base_cost: sale_price,
price_structure: {
base_cost: sale_price,
min_cost: sale_price,
allowance,
},
sale: {
is_premint_over: true,
allowance,
}
});
return { tenk, alice };
}
Expand All @@ -32,7 +37,7 @@ runner.test("allowance should allow only 2 tokens", async (t, { root, tenk, alic
await mint(tenk, alice, cost);
await mint(tenk, alice, cost);
let last_try = await mint_raw(tenk, alice, cost);
t.assert(last_try.failed);
t.assert(last_try.failed, "tx didn't fail");
const tokens = await getTokens(tenk, alice);
t.assert(tokens.length == 2);
});
Expand Down
3 changes: 1 addition & 2 deletions __test__/nft.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const min_cost = NEAR.parse("0.01 N");
const runner = Workspace.init(
{ initialBalance: NEAR.parse("15 N").toString() },
async ({ root }) => {
const tenk = await deploy(root, "tenk", { base_cost, min_cost });
return { tenk };
return { tenk: await deploy(root, "tenk", { price_structure: {base_cost, min_cost }}) };
}
);

Expand Down
2 changes: 1 addition & 1 deletion __test__/paras.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const runner = Workspace.init(
const bob = await root.createAccount("bob");
const eve = await root.createAccount("eve");
const royalties = getRoyalties({ root, alice, eve });
const tenk = await deploy(root, "tenk", {royalties});
const tenk = await deploy(root, "tenk", {sale:{royalties, is_premint_over: true}});
const token_id = await mint(tenk, bob, await totalCost(tenk, 1));

const paras = await delpoyParas(root, root, root, [tenk]);
Expand Down
13 changes: 9 additions & 4 deletions __test__/premint.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ const runner = Workspace.init(
async ({ root }) => {
const alice = await root.createAccount("alice");
const tenk = await deploy(root, "tenk", {
is_premint_over: false,
base_cost: sale_price,
min_cost: sale_price,
allowance,
price_structure: {
base_cost: sale_price,
min_cost: sale_price,
},
sale: {
is_premint_over: false,
allowance,
},
});
return { tenk, alice };
}
Expand Down Expand Up @@ -75,6 +79,7 @@ runner.test("premint", async (t, { root, tenk, alice }) => {
t.assert(tokens.length == 3);
});
const sale_price = await totalCost(tenk, 1, alice.accountId);
t.log(sale_price.toHuman(), cost.toHuman());
t.assert(sale_price.gt(cost), "actual sale price has increased");

t.assert((await mint_raw(tenk, alice, sale_price)).failed);
Expand Down
29 changes: 19 additions & 10 deletions __test__/royalties.ava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ if (Workspace.networkIsSandbox()) {
const [bob, alice, eve] = await subaccounts(root);
const royalties = createRoyalties({ root, bob, alice, eve });
const tenk = await deploy(root, "tenk", {
royalties,
initial_royalties: royalties,
base_cost: NEAR.parse("5 N"),
min_cost: NEAR.parse("5 N"),
sale: {
royalties,
initial_royalties: royalties,
is_premint_over: true,
},
price_structure: {
base_cost: NEAR.parse("5 N"),
min_cost: NEAR.parse("5 N"),
},
});
return { tenk, bob, alice, eve };
}
Expand All @@ -44,12 +49,16 @@ if (Workspace.networkIsSandbox()) {
balance,
max_len_payout: 10,
});
t.log(payouts)
t.log((await tenk.view_raw("nft_payout", {
token_id,
balance,
max_len_payout: 10,
})).logs);
t.log(payouts);
t.log(
(
await tenk.view_raw("nft_payout", {
token_id,
balance,
max_len_payout: 10,
})
).logs
);
let innerPayout = createRoyalties({ root, bob, alice, eve }).accounts;
t.log(innerPayout);
Object.keys(innerPayout).map(
Expand Down
35 changes: 35 additions & 0 deletions __test__/start_at_one.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// import { Workspace, NearAccount } from "near-willem-workspaces-ava";
// import { NEAR } from "near-units";
// import {
// costPerToken,
// tokenStorageCost,
// totalCost,
// MINT_ONE_GAS,
// nftTokensForOwner,
// deployEmpty,
// deploy,
// } from "./util";

// const base_cost = NEAR.parse("1 N");
// const min_cost = NEAR.parse("0.01 N");

// const runner = Workspace.init(
// { initialBalance: NEAR.parse("15 N").toString() },
// async ({ root }) => {
// const tenk = await deploy(root, "tenk", { price_structure: {base_cost, min_cost}, size: 2 });
// return { tenk };
// }
// );

// runner.test("token ids start at 1", async (t, { root, tenk }) => {
// const tokens: { token_id: string }[] = await root.call(
// tenk,
// "nft_mint_many",
// { num: 2 },
// { attachedDeposit: NEAR.parse("2.1 N") }
// );
// const token_ids = tokens.map((t) => t.token_id);
// t.is(token_ids.length, 2);
// t.true(token_ids.includes("1"));
// t.true(token_ids.includes("2"));
// });
18 changes: 12 additions & 6 deletions __test__/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ export function deploy(
method: "new_default_meta",
args: {
owner_id: owner,
name: "TENK NFT",
symbol: "TENK",
uri: "https://bafybeiehqz6vklvxkopg3un3avdtevch4cywuihgxrb4oio2qgxf4764bi.ipfs.dweb.link/",
metadata: {
name: "TENK NFT",
symbol: "TENK",
uri: "https://bafybeiehqz6vklvxkopg3un3avdtevch4cywuihgxrb4oio2qgxf4764bi.ipfs.dweb.link/",
},
size: 100,
base_cost: NEAR.parse("1 N"),
min_cost: NEAR.parse("1 N"),
is_premint_over: true,
price_structure: {
base_cost: NEAR.parse("1 N"),
min_cost: NEAR.parse("1 N"),
},
sale: {
is_premint_over: true,
},
...args,
},
});
Expand Down
4 changes: 2 additions & 2 deletions contracts/tenk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
near-sdk = { git = "https://github.com/willemneal/near-sdk-rs", branch = "release"}
near-contract-standards = { git = "https://github.com/willemneal/near-sdk-rs", branch = "release" }
near-sdk = { git = "https://github.com/near/near-sdk-rs", rev = "ea8c1f48e0f7fef8b5721848dc312646d3c1c20e"}
near-contract-standards = { git = "https://github.com/near/near-sdk-rs", rev = "ea8c1f48e0f7fef8b5721848dc312646d3c1c20e" }
serde = "1.0.0"
near-units = "0.2.0"
serde_with = "1.0.0"
Expand Down
Loading

0 comments on commit e55bac8

Please sign in to comment.