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

4.0.0 dev compatibile #407

Merged
merged 40 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e513fd8
connects to 4.0.0-dev
KarishmaBothara Dec 24, 2021
d2ee6f2
fixed all ts errors
KarishmaBothara Feb 2, 2022
9a8112b
fix ts err
KarishmaBothara Feb 2, 2022
4c0c3bf
fix ts err
KarishmaBothara Feb 2, 2022
a91fbcb
fix test
KarishmaBothara Feb 2, 2022
7f31deb
fix custom metadata test
KarishmaBothara Feb 2, 2022
0c65f66
skip nft test for nw
KarishmaBothara Feb 2, 2022
8917268
updated docker image
KarishmaBothara Feb 2, 2022
403dbd5
remove attestation tests from ci
KarishmaBothara Feb 2, 2022
0ebbc38
skip governance test
KarishmaBothara Feb 2, 2022
2cb18d0
added entry in static metadata
KarishmaBothara Feb 2, 2022
bbbc331
fix test
KarishmaBothara Feb 2, 2022
b32220a
updated docker image to cennznet/cennznet:2.1.0-rc1
KarishmaBothara Feb 2, 2022
af18b6a
updated spec version to 46
KarishmaBothara Feb 2, 2022
a557c72
remove attestation from ci
KarishmaBothara Feb 2, 2022
b306075
fix test
KarishmaBothara Feb 2, 2022
b5385ce
updated metadata and generated type def
KarishmaBothara Feb 3, 2022
7f10d79
skipped test for custom meta - PortableRegistry lookupId
KarishmaBothara Feb 3, 2022
7644ff6
rename staking derive
KarishmaBothara Feb 3, 2022
da4c490
fix test related generic asset lock
KarishmaBothara Feb 3, 2022
eb07fb5
timebeing skip custom metadata test
KarishmaBothara Feb 3, 2022
469cea7
update derive types for staking
KarishmaBothara Feb 3, 2022
f42214c
fix build
KarishmaBothara Feb 3, 2022
196c192
updated accrued payment test
KarishmaBothara Feb 3, 2022
ab2b2b4
unskip the nft test
KarishmaBothara Feb 3, 2022
ee7dfd1
fix cennzx test
KarishmaBothara Feb 3, 2022
a77de14
fix test for nft
KarishmaBothara Feb 3, 2022
f1863e9
fix test
KarishmaBothara Feb 4, 2022
c983e3e
remove attestation test
KarishmaBothara Feb 4, 2022
e754f2e
fix lint
KarishmaBothara Feb 4, 2022
91da9d3
skip attestation related test
KarishmaBothara Feb 4, 2022
f8dad1f
updated ci to include bridge test
KarishmaBothara Feb 8, 2022
8e70476
fix build
KarishmaBothara Feb 8, 2022
1f2b72c
added env variable to ci
KarishmaBothara Feb 8, 2022
18f674c
update brige test
KarishmaBothara Feb 8, 2022
850bc25
fix and unskip custom metadata test
KarishmaBothara Feb 8, 2022
7c32071
added the missing rpc definitions
KarishmaBothara Feb 8, 2022
c5354e5
Fixed the event decoding for custom metadata
KarishmaBothara Feb 8, 2022
eead476
fix test
KarishmaBothara Feb 8, 2022
53303cd
as per review comment
KarishmaBothara Feb 9, 2022
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
access_token: ${{ github.token }}
- uses: actions/setup-node@v1
with:
node-version: '15.3'
node-version: '16'
- name: cache node modules
id: cache
uses: actions/cache@v2
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '10.19'
node-version: '16'
- name: cache node modules
id: cache
uses: actions/cache@v2
Expand All @@ -75,7 +75,7 @@ jobs:
docker run --network=host -d cennznet/cennznet:1.1.1 --dev --ws-external --ws-port=9945 --no-mdns
- name: start latest test node
run: |
docker run --pull=always --network=host -d cennznet/cennznet:f16e01b --dev --tmp --ws-external --rpc-external --no-mdns
docker run --pull=always --network=host -d cennznet/cennznet:2.1.0-rc1 --dev --tmp --ws-external --rpc-external --no-mdns
- name: test
env:
TEST_TYPE: integration
Expand All @@ -90,7 +90,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '15.3'
node-version: '16'
- name: start latest test node
run: |
docker run --pull=always --network=host -d cennznet/cennznet:latest --dev --tmp --ws-external --rpc-external --no-mdns
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
ref: master
- uses: actions/setup-node@v1
with:
node-version: '15.3'
node-version: '16'
- name: find release version
id: find_version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
ref: develop
- uses: actions/setup-node@v1
with:
node-version: '15.3'
node-version: '16'
- name: find release version
id: find_version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '15.3'
node-version: '16'
# build new project with @cennznet/api
# it will grab the latest semver compatible @polkadot releases
# if it fails, we should release a patch for @cennznet/api
Expand Down
3 changes: 0 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
module.exports = {
extends: '@polkadot/dev/config/babel-config-cjs.cjs',
plugins: [
['@babel/plugin-proposal-private-methods', { loose: true }]
]
};
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
# dev node with runtime v40 and client 1.4.0
testnet_node_alice:
container_name: testnet_node_alice
image: cennznet/cennznet:f16e01b
image: cennznet/cennznet:2.1.0-rc1
command:
- --dev
- --tmp
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"run:signer": "node ./packages/signer-cli/src/index.cjs"
},
"devDependencies": {
"@polkadot/dev": "0.62.12",
"@polkadot/dev": "0.64.18",
"@polkadot/ts": "0.3.64",
"@babel/helper-regex": "^7.10.5",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
Expand Down
12 changes: 6 additions & 6 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
},
"dependencies": {
"@cennznet/types": "^2.0.0-alpha.4",
"@polkadot/api": "^4.9.3-11",
"@polkadot/metadata": "^4.9.3-11",
"@polkadot/rpc-core": "^4.9.3-11",
"@polkadot/rpc-provider": "^4.9.3-11",
"@polkadot/types": "^4.9.3-11",
"@polkadot/api": "^7.6.1",
"@polkadot/rpc-core": "^7.6.1",
"@polkadot/rpc-provider": "^7.6.1",
"@polkadot/types": "^7.6.1",
"@polkadot/extension-dapp": "^0.36.1",
"@polkadot/x-rxjs": "^6.11.2-6",
"eventemitter3": "^4.0.0"
},
"resolutions": {
"rxjs": "7.0.0"
"rxjs": "7.2.0"
}
}
23 changes: 12 additions & 11 deletions packages/api/src/derives/attestation/attestation.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ afterAll(async () => {
await api.disconnect();
});

describe('Attestation APIs', () => {
// Attestation module is removed in the new node version, once added back we can unskip and fix the test
describe.skip('Attestation APIs', () => {
describe('Set Claims', () => {
it('should create a claim', async done => {
it('should create a claim', async (done) => {
await api.tx.attestation
.setClaim(holder.address, topic, attestationValue.toHex())
.signAndSend(issuer, async ({ events, status }) => {
Expand All @@ -67,7 +68,7 @@ describe('Attestation APIs', () => {
});
});

it('should create a claim with a u8a', async done => {
it('should create a claim with a u8a', async (done) => {
const otherTopic = api.registry.createType('AttestationTopic', '0x72616e646f6d546f706963'); // hex for randomTopic
await api.tx.attestation
.setClaim(holder.address, otherTopic, attestationValue.toU8a())
Expand All @@ -92,7 +93,7 @@ describe('Attestation APIs', () => {
});

describe('Get Claim', () => {
it('should get a claim with a specific issuer and holder', async done => {
it('should get a claim with a specific issuer and holder', async (done) => {
const claim = await api.derive.attestation.getClaim(holder.address, issuer.address, topic);
expect(claim.value.toHex()).toEqual(attestationValue.toHex());
expect(claim.value.toU8a()).toEqual(attestationValue.toU8a());
Expand All @@ -101,7 +102,7 @@ describe('Attestation APIs', () => {
});

describe('Create Multiple Claims', () => {
it('should create a claim with issuer 1 and topic 1', async done => {
it('should create a claim with issuer 1 and topic 1', async (done) => {
await api.tx.attestation
.setClaim(holder.address, topic, attestationValue.toHex())
.signAndSend(issuer, async ({ events, status }) => {
Expand All @@ -123,7 +124,7 @@ describe('Attestation APIs', () => {
});
});

it('should create a claim with issuer 1 and topic 2', async done => {
it('should create a claim with issuer 1 and topic 2', async (done) => {
await api.tx.attestation
.setClaim(holder.address, topic2, attestationValue2.toHex())
.signAndSend(issuer, async ({ events, status }) => {
Expand All @@ -145,7 +146,7 @@ describe('Attestation APIs', () => {
});
});

it('should create a claim with issuer 2 and topic 1', async done => {
it('should create a claim with issuer 2 and topic 1', async (done) => {
await api.tx.attestation
.setClaim(holder.address, topic, attestationValue.toHex())
.signAndSend(issuer2, async ({ events, status }) => {
Expand All @@ -167,7 +168,7 @@ describe('Attestation APIs', () => {
});
});

it('should create a claim with issuer 2 and topic 2', async done => {
it('should create a claim with issuer 2 and topic 2', async (done) => {
await api.tx.attestation
.setClaim(holder.address, topic2, attestationValue2.toHex())
.signAndSend(issuer2, async ({ events, status }) => {
Expand All @@ -191,7 +192,7 @@ describe('Attestation APIs', () => {
});

describe('Get Mutiple Claims Claim', () => {
it('should get a claim with a specific issuer and holder', async done => {
it('should get a claim with a specific issuer and holder', async (done) => {
const claims = await api.derive.attestation.getClaims(
holder.address,
[issuer.address, issuer2.address],
Expand All @@ -215,7 +216,7 @@ describe('Attestation APIs', () => {
});

describe('Remove Claims', () => {
it('should create a claim', async done => {
it('should create a claim', async (done) => {
await api.tx.attestation
.setClaim(holder.address, topic, attestationValue.toHex())
.signAndSend(issuer, async ({ events, status }) => {
Expand All @@ -237,7 +238,7 @@ describe('Attestation APIs', () => {
});
});

it('should remove a claim', async done => {
it('should remove a claim', async (done) => {
// Expect holders to match
await api.tx.attestation.removeClaim(holder.address, topic).signAndSend(issuer, async ({ events, status }) => {
if (status.isInBlock && events !== undefined) {
Expand Down
22 changes: 11 additions & 11 deletions packages/api/src/derives/attestation/attestationRx.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ afterAll(async () => {
await api.disconnect();
});

describe('AttestationRx APIs', () => {
describe.skip('AttestationRx APIs', () => {
describe('Set Claims', () => {
it('should create a claim', done => {
it('should create a claim', (done) => {
const claim = api.tx.attestation.setClaim(holder.address, topic, attestationValue.toHex());

claim
Expand Down Expand Up @@ -80,8 +80,8 @@ describe('AttestationRx APIs', () => {
});

describe('Get Claim', () => {
it('should get a claim with a specific issuer and holder', done => {
api.derive.attestation.getClaim(holder.address, issuer.address, topic).subscribe(claim => {
it('should get a claim with a specific issuer and holder', (done) => {
api.derive.attestation.getClaim(holder.address, issuer.address, topic).subscribe((claim) => {
if (
claim.value.toHex() === attestationValue.toHex() &&
claim.value.toU8a().toString() === attestationValue.toU8a().toString()
Expand All @@ -93,7 +93,7 @@ describe('AttestationRx APIs', () => {
});

describe('Create Multiple Claims', () => {
it('should create a claim with issuer 1 and topic 1', done => {
it('should create a claim with issuer 1 and topic 1', (done) => {
const claim = api.tx.attestation.setClaim(holder.address, topic, attestationValue.toHex());

claim
Expand All @@ -120,7 +120,7 @@ describe('AttestationRx APIs', () => {
});
});

it('should create a claim with issuer 1 and topic 2', done => {
it('should create a claim with issuer 1 and topic 2', (done) => {
const claim = api.tx.attestation.setClaim(holder.address, topic2, attestationValue2.toHex());

claim
Expand All @@ -147,7 +147,7 @@ describe('AttestationRx APIs', () => {
});
});

it('should create a claim with issuer 2 and topic 1', done => {
it('should create a claim with issuer 2 and topic 1', (done) => {
const claim = api.tx.attestation.setClaim(holder.address, topic, attestationValue.toHex());

claim
Expand All @@ -174,7 +174,7 @@ describe('AttestationRx APIs', () => {
});
});

it('should create a claim with issuer 2 and topic 2', done => {
it('should create a claim with issuer 2 and topic 2', (done) => {
const claim = api.tx.attestation.setClaim(holder.address, topic2, attestationValue2.toHex());

claim
Expand Down Expand Up @@ -203,10 +203,10 @@ describe('AttestationRx APIs', () => {
});

describe('Get Mutiple Claims Claim', () => {
it('should get a claim with a specific issuer and holder', done => {
it('should get a claim with a specific issuer and holder', (done) => {
api.derive.attestation
.getClaims(holder.address, [issuer.address, issuer2.address], [topic, topic2])
.subscribe(claims => {
.subscribe((claims) => {
let claimsForTopic = false;
let claimsForTopic2 = false;
for (const { value } of claims) {
Expand All @@ -231,7 +231,7 @@ describe('AttestationRx APIs', () => {
});

describe('Remove Claims', () => {
it('should remove a claim', done => {
it('should remove a claim', (done) => {
const claim = api.tx.attestation.removeClaim(holder.address, topic);

// Expect holders to match
Expand Down
7 changes: 4 additions & 3 deletions packages/api/src/derives/attestation/getClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ import { Claim } from './types';
* @returns the claim
*/
export function getClaim(instanceId: string, api: ApiInterfaceRx) {
return (holder: string, issuer: string, topic: string): Observable<Claim> =>
api.query.attestation
return (holder: string, issuer: string, topic: string): Observable<Claim> => {
return api.query.attestation
.values<AttestationValue>([holder, issuer, topic])
.pipe(drr())
.pipe(
map(value => ({
map((value) => ({
holder,
issuer,
topic,
value,
}))
);
};
}
2 changes: 1 addition & 1 deletion packages/api/src/derives/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function account(
? (queryCurrentNonce(api, accountId) as Observable<Index>)
: (queryOldNonce(api, accountId) as Observable<Index>),
])
: of([api.registry.createType('AccountId'), api.registry.createType('Index')])
: of([api.registry.createType('AccountId'), api.registry.createType('u64')])
),
map((result): DeriveBalancesAccount => calcBalances(api, result))
)
Expand Down
14 changes: 6 additions & 8 deletions packages/api/src/derives/governance/overview.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { Observable } from '@polkadot/x-rxjs';
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';

import { combineLatest } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { hexToString } from '@polkadot/util';
import { Option, ProposalId, GovernanceProposal as Proposal, Vec, ProposalVotes } from '@cennznet/types';
import { DeriveProposalInfo } from '@cennznet/api/derives/governance/types';
Expand All @@ -28,11 +28,9 @@ export function proposals(instanceId: string, api: ApiInterfaceRx) {
(api.rpc as any).governance.getProposalVotes(),
]).pipe(
map(
([proposalCalls, proposals, votes]: [
[],
Vec<Option<Proposal>>,
Vec<ProposalVotes>
]): DeriveProposalInfo[] => {
([proposalCalls, proposals, votes]:
| [[], Vec<Option<Proposal>>, Vec<ProposalVotes>]
| [any]): DeriveProposalInfo[] => {
const proposalDetails = proposalCalls.map((call, idx) => {
if (proposals[idx].isSome) {
const proposalDetail = proposals[idx].unwrap().toJSON();
Expand Down
9 changes: 6 additions & 3 deletions packages/api/src/derives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ import * as cennzx from './cennzx';
import * as fees from './fees';
import * as nft from './nft';
import * as session from './session';
import * as staking from './staking';
import * as stakingCennznet from './staking';
import * as balances from './balances';
import * as governance from './governance';
// import * as governance from './governance';

export type DeriveFunc = (instanceId: string, api: ApiInterfaceRx) => (...args: any[]) => Observable<any>;

export const derive = { attestation, balances, cennzx, fees, governance, nft, staking, session };
// export const derive = { attestation, balances, cennzx, fees, governance, nft, staking, session };
// As per https://github.com/polkadot-js/api/blob/master/packages/api-derive/src/bundle.ts#L67 -
// staking derive is enabled only if it has storage for erasRewardPoints so we updated staking to stakingCennznet
export const derive = { stakingCennznet, attestation, balances, cennzx, fees, nft, session };

export type DecoratedCennznetDerive<
ApiType extends ApiTypes,
Expand Down
7 changes: 3 additions & 4 deletions packages/api/src/derives/nft/openCollectionListings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { Option } from '@polkadot/types';
import { Observable, combineLatest } from 'rxjs';
import { map, switchMap, reduce, mergeAll, first } from 'rxjs/operators';
import { ApiInterfaceRx } from '@cennznet/api/types';
import { DeriveTokenInfo } from '@cennznet/api/derives/nft/types';
import { Listing, TokenId } from '@cennznet/types';
import { Option } from '@polkadot/types/codec/Option';
import { UInt } from '@polkadot/types';

/**
* Gets all tokens in a collection that have an open listing
Expand Down Expand Up @@ -56,7 +55,7 @@ export function openCollectionListings(instanceId: string, api: ApiInterfaceRx)
first(),
map((tokenInfos: DeriveTokenInfo[]): DeriveTokenInfo[] => {
const tokenInfoWithListingId = tokenInfos.map((tokenInfo) => {
const listingIdStr = listingTokenIds.find(([_listing, tokenId]) => {
const listingIdStr = listingTokenIds.find(([, tokenId]) => {
return (
tokenId.toString() ===
[
Expand All @@ -66,7 +65,7 @@ export function openCollectionListings(instanceId: string, api: ApiInterfaceRx)
].toString()
);
})[0];
const listingId = new UInt(api.registry, parseInt(listingIdStr as string));
const listingId = api.registry.createType('ListingId', listingIdStr);
tokenInfo.listingId = listingId;
return tokenInfo;
});
Expand Down
Loading