Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop semantic release && features #96

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
name: Publish

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write

jobs:
release:
name: Release
publish-npm:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v4
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: lts/*
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npx ci
- name: Install semantic-release extra plugins
run: npm install --save-dev @semantic-release/changelog @semantic-release/git
- name: Lint
run: npm run lint:fix
- name: Test
run: npm run test --if-present
- name: Build
run: npm run build
- name: Release
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm config set access public && npx semantic-release
run: |
RELEASE_TAG=v$(node -p "require('./package.json').version")
gh release create $RELEASE_TAG --target=$GITHUB_SHA --title="$RELEASE_TAG" --generate-notes
- name: Publish to npmjs
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: npm publish --access=public
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ This SDK is currently focused on interacting with the Itheum's Data NFT technolo
- work on typescript code in the `/src` folder
- handy tip: when developing locally, you can do integration tests by running `npm run prepare` and the `npm install --save ../sdk-mx-data-nft` in the host project

### Dev Environment

- create a '.husky' folder in the root of the project
Inside the folder:
- add a 'commit-msg' file with the following content:
```bash
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no-install commitlint --edit $1
```
- add a 'pre-commit' file with the following content:
```bash
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm test
```

### Dev Testing

- Only simple dev testing added. First **Build** as below and then run `npm run test` and work on the test.mjs file for live reload
Expand Down
11 changes: 9 additions & 2 deletions src/datanft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import {
ErrNetworkConfig,
ErrTooManyItems
} from './errors';
import { NftType, ViewDataReturnType } from './interfaces';
import { DataNftType, NftType, ViewDataReturnType } from './interfaces';
import BigNumber from 'bignumber.js';

export class DataNft {
export class DataNft implements DataNftType {
readonly tokenIdentifier: string = '';
readonly nftImgUrl: string = '';
readonly dataPreview: string = '';
Expand Down Expand Up @@ -69,6 +69,13 @@ export class DataNft {
this.overrideDataMarshalChainId = override.chainId;
}

/**
* Update any attributes for DataNft
*
*/
updateDataNft(init: Partial<DataNft>) {
Object.assign(this, init);
}
/**
* Sets the network configuration for the DataNft class.
* @param env 'devnet' | 'mainnet' | 'testnet'
Expand Down
23 changes: 23 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import BigNumber from 'bignumber.js';

export interface NftType {
identifier: string;
collection: string;
Expand Down Expand Up @@ -44,6 +46,27 @@ export interface NftType {
}[];
}

export interface DataNftType {
readonly tokenIdentifier: string;
readonly nftImgUrl: string;
readonly dataPreview: string;
readonly dataStream: string;
readonly dataMarshal: string;
readonly tokenName: string;
readonly creator: string;
readonly creationTime: Date;
readonly supply: number | BigNumber.Value;
readonly description: string;
readonly title: string;
readonly royalties: number;
readonly nonce: number;
readonly collection: string;
readonly balance: number | BigNumber.Value;
readonly owner: string;
readonly overrideDataMarshal: string;
readonly overrideDataMarshalChainId: string;
}

export enum NftEnumType {
NonFungibleESDT = 'NonFungibleESDT',
SemiFungibleESDT = 'SemiFungibleESDT',
Expand Down
8 changes: 8 additions & 0 deletions tests/datanft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,13 @@ describe('Data NFT test', () => {

expect(dataNft.overrideDataMarshal).toBe('');
expect(dataNft.overrideDataMarshalChainId).toBe('');

dataNft.updateDataNft({
overrideDataMarshal: 'overrideUrl',
overrideDataMarshalChainId: 'D'
});

expect(dataNft.overrideDataMarshal).toBe('overrideUrl');
expect(dataNft.overrideDataMarshalChainId).toBe('D');
});
});
Loading