Skip to content

Commit

Permalink
Merge branch 'main' into refactor/http-module
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenVoich committed Aug 7, 2023
2 parents c39d48b + 7600c3d commit ebb6418
Show file tree
Hide file tree
Showing 69 changed files with 461 additions and 257 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: aviate-labs/[email protected].5
- uses: aviate-labs/[email protected].6
with:
vessel-version: 0.6.3
dfx-version: 0.14.1
- name: install mops
run: npm i -g ic-mops
- name: install mops packages
run: mops install
- name: test
run: |
dfx identity use anonymous
npm install
npm run replica:no-delay
npm run test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.dfx
.vessel
.mops
*.pem
.venv
registry.json
tokens.json
__pycache__
node_modules
backup/data/*
test/initArgs.did
test/e2e/initArgs.did

# remove or comment out the lines below in your forked NFT collection repository
initArgs.did
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,31 @@ So when executing `mintNFT`, the `to` address is taken from `registry.json` and

Each test suite is deployed with its own env settings.

You need to switch to an anonymous identity to run the tests.
First, start a local replica

```
dfx identity use anonymouse
npm run replica
```

First, start a local replica
Deploy and run all unit and e2e tests

```
npm run replica
npm run test
```

To deploy and run all tests
Run only unit tests

```
npm run test
npm run test:unit
```

To deploy and run specific tests
Deploy and run specific e2e tests

```
npm run test pending-sale
npm run test:e2e pending-sale
```

To run tests without deployment (useful when writing tests)
Run tests without deployment (useful when writing tests)

```
npm run vitest
Expand All @@ -176,7 +176,7 @@ or
npm run vitest:watch
```

or to run specific test suite
or run specific test suite

```
npm run vitest pending-sale
Expand Down
9 changes: 9 additions & 0 deletions backup/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import minimist from 'minimist';
import { Principal } from '@dfinity/principal';
import { ExecSyncOptions, execSync } from 'child_process';

import { getActor } from './actor';
import { type StableChunk } from '../declarations/main/staging.did';
Expand All @@ -25,6 +26,14 @@ if (!fs.existsSync(filePath)) {
throw new Error(`File ${filePath} not found`);
}

if (!pemData && network == 'local') {
let execOptions = {stdio: ['inherit', 'pipe', 'inherit']} as ExecSyncOptions;
let identityName = execSync('dfx identity whoami').toString().trim();
if (identityName !== 'anonymous') {
pemData = execSync(`dfx identity export ${identityName}`, execOptions).toString();
}
}

let identity = pemData && decode(pemData);
let mainActor = getActor(network, canisterId, identity);

Expand Down
84 changes: 56 additions & 28 deletions declarations/main/staging.did
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,23 @@ type TransferRequest =
to: User;
token: TokenIdentifier;
};
type TransactionV2 =
record {
buyer: AccountIdentifier__2;
buyerFrontend: opt text;
price: nat64;
seller: principal;
sellerFrontend: opt text;
time: Time__1;
token: TokenIdentifier__1;
};
type Transaction =
record {
buyer: AccountIdentifier__2;
buyerFrontend: opt text;
price: nat64;
seller: principal;
sellerFrontend: opt text;
time: Time__1;
token: TokenIdentifier__1;
};
Expand Down Expand Up @@ -176,36 +188,63 @@ type StableChunk__3 =
transactionCount: nat;
};
v1_chunk: record {transactionChunk: vec Transaction;};
v2:
record {
tokenListing: vec record {
TokenIndex__1;
Listing;
};
tokenSettlement: vec record {
TokenIndex__1;
Settlement;
};
transactionChunk: vec TransactionV2;
transactionCount: nat;
};
v2_chunk: record {transactionChunk: vec TransactionV2;};
};
type StableChunk__2 = opt
variant {
v1: record {disbursements: vec Disbursement;};};
type StableChunk__1 =
opt
variant {
v1: record {
assetsChunk: vec Asset;
assetsCount: nat;
};
v1_chunk: record {assetsChunk: vec Asset;};
v2:
record {
assetsChunk: vec AssetV2;
assetsCount: nat;
placeholder: AssetV2;
};
v2_chunk: record {assetsChunk: vec AssetV2;};
v3:
record {
assetsChunk: vec AssetV2;
assetsCount: nat;
isShuffled: bool;
placeholder: AssetV2;
};
v3_chunk: record {assetsChunk: vec AssetV2;};
};
type StableChunk = variant {
v1:
record {
assets: StableChunk__1;
disburser: StableChunk__2;
marketplace: StableChunk__3;
sale: StableChunk__4;
shuffle: StableChunk__5;
tokens: StableChunk__6;
};};
type StableChunk =
variant {
v1:
record {
assets: StableChunk__1;
disburser: StableChunk__2;
marketplace: StableChunk__3;
sale: StableChunk__4;
shuffle: StableChunk__5;
tokens: StableChunk__6;
};
v2:
record {
assets: StableChunk__1;
disburser: StableChunk__2;
marketplace: StableChunk__3;
sale: StableChunk__4;
tokens: StableChunk__6;
};
};
type Settlement =
record {
buyer: AccountIdentifier__2;
Expand Down Expand Up @@ -234,10 +273,6 @@ type SaleTransaction =
};
type SaleSettings =
record {
bulkPricing: vec record {
nat64;
nat64;
};
endTime: Time__2;
openEdition: bool;
price: nat64;
Expand Down Expand Up @@ -675,7 +710,7 @@ type Canister =
disbursements: nat;
failedSettlements: nat;
}) query;
reserve: (nat64, nat64, AccountIdentifier__5, SubAccount__1) -> (Result_5);
reserve: (AccountIdentifier__5) -> (Result_5);
restoreChunk: (StableChunk) -> ();
retrieve: (AccountIdentifier__5) -> (Result_4);
saleTransactions: () -> (vec SaleTransaction) query;
Expand All @@ -698,7 +733,7 @@ type Canister =
toAccountIdentifier: (text, nat) -> (AccountIdentifier__4) query;
tokens: (AccountIdentifier__3) -> (Result_1) query;
tokens_ext: (AccountIdentifier__3) -> (Result) query;
transactions: () -> (vec Transaction) query;
transactions: () -> (vec TransactionV2) query;
transfer: (TransferRequest) -> (TransferResponse);
updateCanistergeekInformation: (UpdateInformationRequest) -> ();
updateThumb: (text, File) -> (opt nat);
Expand All @@ -725,13 +760,6 @@ type AssetV2 =
thumbnail: opt File;
thumbnailUrl: opt text;
};
type Asset =
record {
metadata: opt File;
name: text;
payload: File;
thumbnail: opt File;
};
type AccountIdentifier__7 = text;
type AccountIdentifier__6 = text;
type AccountIdentifier__5 = text;
Expand Down
60 changes: 43 additions & 17 deletions declarations/main/staging.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ export type AccountIdentifier__4 = string;
export type AccountIdentifier__5 = string;
export type AccountIdentifier__6 = string;
export type AccountIdentifier__7 = string;
export interface Asset {
'thumbnail' : [] | [File],
'metadata' : [] | [File],
'name' : string,
'payload' : File,
}
export interface AssetV2 {
'thumbnail' : [] | [File],
'payloadUrl' : [] | [string],
Expand Down Expand Up @@ -80,10 +74,7 @@ export interface Canister {
[],
{ 'failedSettlements' : bigint, 'disbursements' : bigint }
>,
'reserve' : ActorMethod<
[bigint, bigint, AccountIdentifier__5, SubAccount__1],
Result_5
>,
'reserve' : ActorMethod<[AccountIdentifier__5], Result_5>,
'restoreChunk' : ActorMethod<[StableChunk], undefined>,
'retrieve' : ActorMethod<[AccountIdentifier__5], Result_4>,
'saleTransactions' : ActorMethod<[], Array<SaleTransaction>>,
Expand All @@ -107,7 +98,7 @@ export interface Canister {
'toAccountIdentifier' : ActorMethod<[string, bigint], AccountIdentifier__4>,
'tokens' : ActorMethod<[AccountIdentifier__3], Result_1>,
'tokens_ext' : ActorMethod<[AccountIdentifier__3], Result>,
'transactions' : ActorMethod<[], Array<Transaction>>,
'transactions' : ActorMethod<[], Array<TransactionV2>>,
'transfer' : ActorMethod<[TransferRequest], TransferResponse>,
'updateCanistergeekInformation' : ActorMethod<
[UpdateInformationRequest],
Expand Down Expand Up @@ -360,7 +351,6 @@ export interface SaleSettings {
'endTime' : Time__2,
'totalToSell' : bigint,
'sold' : bigint,
'bulkPricing' : Array<[bigint, bigint]>,
'whitelistTime' : Time__2,
'salePrice' : bigint,
'remaining' : bigint,
Expand Down Expand Up @@ -399,18 +389,34 @@ export type StableChunk = {
'tokens' : StableChunk__6,
'shuffle' : StableChunk__5,
}
} |
{
'v2' : {
'marketplace' : StableChunk__3,
'assets' : StableChunk__1,
'sale' : StableChunk__4,
'disburser' : StableChunk__2,
'tokens' : StableChunk__6,
}
};
export type StableChunk__1 = [] | [
{ 'v1' : { 'assetsChunk' : Array<Asset>, 'assetsCount' : bigint } } |
{
{
'v2' : {
'assetsChunk' : Array<AssetV2>,
'assetsCount' : bigint,
'placeholder' : AssetV2,
}
} |
{ 'v1_chunk' : { 'assetsChunk' : Array<Asset> } } |
{ 'v2_chunk' : { 'assetsChunk' : Array<AssetV2> } }
{
'v3' : {
'assetsChunk' : Array<AssetV2>,
'assetsCount' : bigint,
'placeholder' : AssetV2,
'isShuffled' : boolean,
}
} |
{ 'v2_chunk' : { 'assetsChunk' : Array<AssetV2> } } |
{ 'v3_chunk' : { 'assetsChunk' : Array<AssetV2> } }
];
export type StableChunk__2 = [] | [
{ 'v1' : { 'disbursements' : Array<Disbursement> } }
Expand All @@ -425,7 +431,16 @@ export type StableChunk__3 = [] | [
'transactionCount' : bigint,
}
} |
{ 'v1_chunk' : { 'transactionChunk' : Array<Transaction> } }
{
'v2' : {
'tokenSettlement' : Array<[TokenIndex__1, Settlement]>,
'tokenListing' : Array<[TokenIndex__1, Listing]>,
'transactionChunk' : Array<TransactionV2>,
'transactionCount' : bigint,
}
} |
{ 'v1_chunk' : { 'transactionChunk' : Array<Transaction> } } |
{ 'v2_chunk' : { 'transactionChunk' : Array<TransactionV2> } }
];
export type StableChunk__4 = [] | [
{
Expand Down Expand Up @@ -498,9 +513,20 @@ export type TokenIndex__2 = number;
export type TokenIndex__3 = number;
export type TokenIndex__4 = number;
export interface Transaction {
'sellerFrontend' : [] | [string],
'token' : TokenIdentifier__1,
'time' : Time__1,
'seller' : Principal,
'buyerFrontend' : [] | [string],
'buyer' : AccountIdentifier__2,
'price' : bigint,
}
export interface TransactionV2 {
'sellerFrontend' : [] | [string],
'token' : TokenIdentifier__1,
'time' : Time__1,
'seller' : Principal,
'buyerFrontend' : [] | [string],
'buyer' : AccountIdentifier__2,
'price' : bigint,
}
Expand Down
Loading

0 comments on commit ebb6418

Please sign in to comment.