Skip to content

Commit 89b473e

Browse files
authored
feat: mint_rate_limit added to state with an added check and view func (#48)
* feat: mint_rate_limit added to state with an added check and view func * fix: make total_cost == price * num of tokens * fix: test now price is flat and not extra for storage * fix: pass tests and update types * fix(CI): only test node 16 * fix(CI): switch back to normal workspaces-js * fix(CI): break up testnet into two runners * fix: ensure that linkdrop cost incorporates storage cost
1 parent e07a2e9 commit 89b473e

24 files changed

+2323
-324
lines changed

.github/workflows/testnet.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@ jobs:
44
tests:
55
strategy:
66
matrix:
7-
platform: [ubuntu-latest]
8-
node-version: ['14']
9-
toolchain: [stable]
10-
runs-on: ${{ matrix.platform }}
7+
set: ['"*/linkdrop/succ*"', "*/link*/fail*"]
8+
runs-on: ubuntu-latest
119
steps:
1210
- uses: actions/checkout@v2
13-
- name: "${{ matrix.toolchain }} with rustfmt, and wasm32"
11+
- name: "stable with rustfmt, and wasm32"
1412
uses: actions-rs/toolchain@v1
1513
with:
1614
profile: minimal
17-
toolchain: ${{ matrix.toolchain }}
15+
toolchain: stable
1816
target: wasm32-unknown-unknown
1917
- uses: Swatinem/rust-cache@v1
2018
- name: Add wasm32 target
2119
run: rustup target add wasm32-unknown-unknown
2220
- name: install node
2321
uses: actions/setup-node@v2
2422
with:
25-
node-version: ${{ matrix.node-version }}
23+
node-version: '16'
2624
- name: Run tests
27-
run: npm i && npm run test:linkdrop
25+
run: npm i && npm run test:testnet ${{ matrix.set }}

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
strategy:
66
matrix:
77
platform: [ubuntu-latest, macos-latest]
8-
node-version: ['14', '16']
8+
node-version: ['16']
99
toolchain: [stable]
1010
runs-on: ${{ matrix.platform }}
1111
steps:

__test__/allowance.ava.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Workspace } from "near-willem-workspaces-ava";
1+
import { Workspace } from "near-workspaces-ava";
22
import { NEAR } from "near-units";
33
import {
44
DEFAULT_SALE,

__test__/linkdrop/linkdrop-fail.ava.ts __test__/linkdrop/fail.ava.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import {
22
Workspace,
33
NearAccount,
44
randomAccountId,
5-
} from "near-willem-workspaces-ava";
5+
} from "near-workspaces-ava";
66
import {
77
ava
8-
} from "near-willem-workspaces-ava";
8+
} from "near-workspaces-ava";
99
import { NEAR, Gas } from "near-units";
1010
import { readFile } from "fs/promises";
1111
import {

__test__/linkdrop/linkdrop-success.ava.ts __test__/linkdrop/success.ava.ts

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
import {
2-
Workspace,
3-
NearAccount,
4-
randomAccountId,
5-
} from "near-willem-workspaces-ava";
6-
import {
7-
ava
8-
} from "near-willem-workspaces-ava";
9-
import { NEAR, Gas } from "near-units";
1+
import { Workspace, randomAccountId } from "near-workspaces-ava";
2+
import { ava } from "near-workspaces-ava";
3+
import { NEAR } from "near-units";
104
import { readFile } from "fs/promises";
115
import {
12-
ActualTestnet,
136
createLinkdrop,
147
getTokens,
158
checkKey,
16-
BalanceDelta,
179
claim,
18-
claim_raw,
19-
// repeat,
20-
// zeroDelta,
2110
hasDelta,
2211
getDelta,
2312
create_account_and_claim,
@@ -29,8 +18,6 @@ import {
2918
const base_cost = NEAR.parse("1 N");
3019
const min_cost = NEAR.parse("0.01 N");
3120

32-
33-
3421
if (Workspace.networkIsTestnet()) {
3522
const runner = Workspace.init(
3623
{ initialBalance: NEAR.parse("15 N").toString() },
@@ -69,7 +56,6 @@ if (Workspace.networkIsTestnet()) {
6956
);
7057
});
7158
await delta.isGreaterOrEqual(NEAR.from(0));
72-
t.log(await delta.toHuman());
7359
const tokens = await getTokens(tenk, alice);
7460
t.assert(tokens.length == 1, "should contain only one token");
7561
t.log(
@@ -114,8 +100,6 @@ if (Workspace.networkIsTestnet()) {
114100
}
115101
);
116102

117-
118-
119103
// runner.test(
120104
// "Spam `claim` to send to non-existent account",
121105
// async (t, { root, tenk }) => {
@@ -185,7 +169,6 @@ if (Workspace.networkIsTestnet()) {
185169
// await new_account.delete(root.accountId);
186170
}
187171
);
188-
189172
} else {
190173
ava("skipped on sandbox", (t) => t.assert(true));
191174
}

__test__/mintbase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Workspace, NearAccount, ONE_NEAR } from "near-willem-workspaces-ava";
1+
import { Workspace, NearAccount, ONE_NEAR } from "near-workspaces-ava";
22
import { NEAR, Gas } from "near-units";
33
import { nftTokensForOwner } from "./util";
44

__test__/nft.ava.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Workspace, NearAccount } from "near-willem-workspaces-ava";
1+
import { Workspace, NearAccount } from "near-workspaces-ava";
22
import { NEAR } from "near-units";
33
import {
44
costPerToken,
@@ -34,20 +34,9 @@ const runner = Workspace.init(
3434
}
3535
);
3636

37-
runner.test("can get cost per token", async (t, { root, tenk }) => {
37+
runner.test("can get cost per token", async (t, { tenk }) => {
3838
const cost = await costPerToken(tenk, 1);
39-
const storageCost = await tokenStorageCost(tenk);
40-
t.log(
41-
"One token costs " +
42-
cost.toHuman() +
43-
"to buy and " +
44-
storageCost.toHuman() +
45-
" to store"
46-
);
47-
t.deepEqual(cost.toBigInt(), price.add(storageCost).toBigInt());
48-
// if (cost.toBigInt() > 0) {
49-
// t.assert(cost.gt(await costPerToken(tenk, 24)));
50-
// }
39+
t.deepEqual(cost.toBigInt(), price.toBigInt());
5140
});
5241

5342
async function assertXTokens(t, root: NearAccount, tenk, num) {

__test__/paras.ava.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Workspace, NearAccount, ONE_NEAR } from "near-willem-workspaces-ava";
1+
import { Workspace, NearAccount, ONE_NEAR } from "near-workspaces-ava";
22
import { NEAR, Gas } from "near-units";
33
import {
44
nftTokensForOwner,

__test__/premint.ava.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ONE_NEAR, Workspace } from "near-willem-workspaces-ava";
1+
import { ONE_NEAR, Workspace } from "near-workspaces-ava";
22
import { NEAR } from "near-units";
33
import {
44
claim,

__test__/royalties.ava.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Workspace, NearAccount } from "near-willem-workspaces-ava";
1+
import { Workspace, NearAccount } from "near-workspaces-ava";
22
import { NEAR } from "near-units";
33
import { DEFAULT_SALE, deploy, getDelta, mint, now, totalCost } from "./util";
44
import { Royalties, Sale } from "..";

__test__/start_at_one.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import { Workspace, NearAccount } from "near-willem-workspaces-ava";
1+
// import { Workspace, NearAccount } from "near-workspaces-ava";
22
// import { NEAR } from "near-units";
33
// import {
44
// costPerToken,

__test__/util/delta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NEAR, NearAccount } from "near-willem-workspaces-ava";
1+
import { NEAR, NearAccount } from "near-workspaces-ava";
22

33
export class NEARDelta {
44
static readonly ZERO_NEAR = NEAR.from(0);

__test__/util/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
KeyPair,
1010
PublicKey,
1111
AccountManager,
12-
} from "near-willem-workspaces";
13-
import { ONE_NEAR, TransactionResult } from "near-willem-workspaces-ava";
12+
} from "near-workspaces";
13+
import { ONE_NEAR, TransactionResult } from "near-workspaces-ava";
1414
import { binPath } from "./bin";
1515
import { BalanceDelta, getDelta } from "./delta";
1616
import {Contract} from "../..";

ava.config.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("near-willem-workspaces-ava/ava.config.cjs")
1+
module.exports = require("near-workspaces-ava/ava.config.cjs")

0 commit comments

Comments
 (0)