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

Patch v26 #1391

Merged
merged 19 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
37989f0
test: 💍 add unit tests
prashantasdeveloper Nov 19, 2024
d14b375
test: 💍 add tests for 100% coverage
prashantasdeveloper Nov 20, 2024
095ae55
refactor: 💡 add handling of undefined gql variables
sansan Nov 20, 2024
1d96ca0
feat: 🎸 allow modification of assetType
sansan Nov 20, 2024
f0df9bd
refactor: 💡 pr comments
sansan Nov 20, 2024
55a0dac
feat: 🎸 skip RPC version check
polymath-eric Nov 25, 2024
a837525
fix: 🐛 Fix logic to check if instruction exists
prashantasdeveloper Nov 27, 2024
d646ed3
fix: 🐛 Correctly handle currency as ticker when configuring DD
prashantasdeveloper Nov 28, 2024
96152aa
fix: 🐛 Correctly return status for failed instructions
prashantasdeveloper Nov 28, 2024
096d5a6
fix: 🐛 getHistoricalAuthorization for v7 joinIdentity auth
polymath-eric Nov 26, 2024
aafdbb9
feat: 🎸 add support for padded IDs in subquery
polymath-eric Nov 21, 2024
f3a9fba
docs: ✏️ update README version
polymath-eric Nov 29, 2024
ec5ae47
style: 💄 remove unused isV6 internal function
polymath-eric Nov 29, 2024
e1ff0ff
fix: 🐛 ignore improper cased permissions
polymath-eric Nov 29, 2024
97cf2cc
test: 💍 add missing test case
polymath-eric Nov 29, 2024
64c4f1c
test: 💍 add nft creation with name test case
polymath-eric Dec 2, 2024
aab83bc
refactor: 💡 resolve merge artifacts
polymath-eric Dec 2, 2024
c0eff6d
chore: 🤖 add v26 release config
polymath-eric Dec 2, 2024
e5f8a84
refactor: 💡 bump min sq version to encourage upgrade
polymath-eric Dec 3, 2024
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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"es6": true
},
"rules": {
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-useless-constructor": "off",
"no-use-before-define": "off",
"@typescript-eslint/explicit-function-return-type": ["warn"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [master, beta, alpha]
branches: [master, beta, alpha, v26-patch]
pull_request:
types: [assigned, opened, synchronize, reopened]

Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@

## \@polymeshassociation/polymesh-sdk

<!--- This section is autogenerated, do not modify --->

## Polymesh version

This release is compatible with Polymesh v6.3 and v7.0

<!--- End of section --->
This release is compatible with Polymesh v7

## Getting Started

### Purpose

The Polymesh SDK's main goal is to provide external developers with a set of tools that will allow them to build powerful applications that interact with the Polymesh protocol. It focuses on abstracting away all the complexities of the Polymesh blockchain and expose a simple but complete interface. The result is a feature-rich, user-friendly node.js library.
The Polymesh SDK's main goal is to provide external developers with a set of tools that will allow them to build powerful applications that interact with the Polymesh protocol. It focuses on abstracting away all the complexities of the Polymesh blockchain and expose a simple but complete interface. The result is a feature-rich, user-friendly JS library.

### Technical Pre-requisites

Expand Down
4 changes: 4 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module.exports = {
name: 'alpha',
prerelease: true,
},
{
name: 'v26-patch',
range: '26.x',
},
polymath-eric marked this conversation as resolved.
Show resolved Hide resolved
],
/*
* In this order the **prepare** step of @semantic-release/npm will run first
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.organization=polymeshassociation
sonar.projectKey=PolymeshAssociation_polymesh-sdk
sonar.sources=src
sonar.coverage.exclusions=**/testUtils/**,**/polkadot/**,**/__tests__/**,**/generated/**,src/utils/typeguards.ts,src/types/internal.ts,src/middleware/enums.ts
sonar.coverage.exclusions=**/testUtils/**,**/polkadot/**,**/__tests__/**,**/generated/**,src/utils/typeguards.ts,src/types/internal.ts,src/middleware/enums.ts,src/middleware/queries/*.ts
sonar.cpd.exclusions=**/__tests__/**,**/polkadot/**
sonar.exclusions=**/polkadot/augment-**
sonar.javascript.environments=node
Expand Down
4 changes: 2 additions & 2 deletions src/api/client/Claims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export class Claims {
claims: { nodes },
},
} = await context.queryMiddleware<Ensured<Query, 'claims'>>(
claimsQuery({
claimsQuery(context.isSqIdPadded, {
dids: targetIssuers,
...filters,
})
Expand Down Expand Up @@ -555,7 +555,7 @@ export class Claims {
claims: { nodes },
},
} = await context.queryMiddleware<Ensured<Query, 'claims'>>(
claimsQuery({
claimsQuery(context.isSqIdPadded, {
trustedClaimIssuers: claimIssuers,
...filters,
})
Expand Down
2 changes: 2 additions & 0 deletions src/api/client/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class Network {
},
} = await context.queryMiddleware<Ensured<Query, 'events'>>(
eventsByArgs(
context.isSqIdPadded,
{
moduleId,
eventId,
Expand Down Expand Up @@ -338,6 +339,7 @@ export class Network {
},
} = await context.queryMiddleware<Ensured<Query, 'events'>>(
eventsByArgs(
context.isSqIdPadded,
{
moduleId,
eventId,
Expand Down
5 changes: 4 additions & 1 deletion src/api/client/Polymesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CreateTransactionBatchProcedureMethod,
ErrorCode,
MiddlewareConfig,
MiddlewareMetadata,
PolkadotConfig,
UnsubCallback,
} from '~/types';
Expand Down Expand Up @@ -194,7 +195,7 @@ export class Polymesh {
}

if (middlewareV2) {
let middlewareMetadata = null;
let middlewareMetadata: MiddlewareMetadata | null = null;

const checkMiddleware = async (): Promise<void> => {
try {
Expand All @@ -215,6 +216,8 @@ export class Polymesh {
message: 'Middleware V2 URL is for a different chain than the given node URL',
});
}

context.isSqIdPadded = middlewareMetadata.paddedIds;
};

await Promise.all([checkMiddleware(), warnUnexpectedSqVersion(context)]);
Expand Down
10 changes: 5 additions & 5 deletions src/api/client/__tests__/Claims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('Claims Class', () => {
dsMockUtils.configureMocks({ contextOptions: { withSigningManager: true } });

dsMockUtils.createApolloQueryMock(
claimsQuery({
claimsQuery(false, {
dids: [targetDid],
scope: undefined,
trustedClaimIssuers: [issuerDid],
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('Claims Class', () => {
},
},
{
query: claimsQuery({
query: claimsQuery(false, {
dids: [targetDid],
scope: undefined,
trustedClaimIssuers: undefined,
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('Claims Class', () => {
dsMockUtils.configureMocks({ contextOptions: { withSigningManager: true } });

dsMockUtils.createApolloQueryMock(
claimsQuery({
claimsQuery(false, {
dids: [targetDid],
scope: { type: 'Asset', value: '0x12341234123412341234123412341234' },
trustedClaimIssuers: [issuerDid],
Expand Down Expand Up @@ -801,7 +801,7 @@ describe('Claims Class', () => {
.mockReturnValue(fakeClaims);

dsMockUtils.createApolloQueryMock(
claimsQuery({
claimsQuery(false, {
dids: [did],
scope,
trustedClaimIssuers: [issuerDid],
Expand Down Expand Up @@ -847,7 +847,7 @@ describe('Claims Class', () => {
},
},
{
query: claimsQuery({
query: claimsQuery(false, {
dids: ['someDid'],
scope: undefined,
trustedClaimIssuers: [issuerDid],
Expand Down
5 changes: 4 additions & 1 deletion src/api/client/__tests__/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ describe('Network Class', () => {
dsMockUtils.configureMocks({ contextOptions: { withSigningManager: true } });
dsMockUtils.createApolloQueryMock(
eventsByArgs(
false,
{
...variables,
eventArg0: undefined,
Expand Down Expand Up @@ -244,6 +245,7 @@ describe('Network Class', () => {
it('should return null if the query result is empty', async () => {
dsMockUtils.createApolloQueryMock(
eventsByArgs(
false,
{
...variables,
eventArg0: 'someDid',
Expand Down Expand Up @@ -282,6 +284,7 @@ describe('Network Class', () => {

dsMockUtils.createApolloQueryMock(
eventsByArgs(
false,
{
...variables,
eventArg0: undefined,
Expand Down Expand Up @@ -317,7 +320,7 @@ describe('Network Class', () => {

it('should return null if the query result is empty', async () => {
dsMockUtils.createApolloQueryMock(
eventsByArgs({
eventsByArgs(false, {
...variables,
eventArg0: 'someDid',
eventArg1: undefined,
Expand Down
13 changes: 6 additions & 7 deletions src/api/client/__tests__/Polymesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Polymesh } from '~/api/client/Polymesh';
import { PolymeshError, PolymeshTransactionBatch } from '~/internal';
import { dsMockUtils, entityMockUtils, procedureMockUtils } from '~/testUtils/mocks';
import { ErrorCode, TransactionArray } from '~/types';
import { SUPPORTED_NODE_VERSION_RANGE } from '~/utils/constants';
import * as internalUtils from '~/utils/internal';

jest.mock(
Expand Down Expand Up @@ -44,9 +43,9 @@ jest.mock(
);

describe('Polymesh Class', () => {
let versionSpy: jest.SpyInstance;
let assertExpectedChainVersionSpy: jest.SpyInstance;
beforeEach(() => {
versionSpy = jest
assertExpectedChainVersionSpy = jest
.spyOn(internalUtils, 'assertExpectedChainVersion')
.mockClear()
.mockImplementation()
Expand Down Expand Up @@ -154,10 +153,9 @@ describe('Polymesh Class', () => {
it('should throw if the Polymesh version does not satisfy the supported version range', async () => {
const error = new PolymeshError({
code: ErrorCode.FatalError,
message: 'Unsupported Polymesh RPC node version. Please upgrade the SDK',
data: { supportedVersionRange: SUPPORTED_NODE_VERSION_RANGE },
message: 'Unsupported Polymesh spec version. Please upgrade the SDK',
});
versionSpy.mockImplementation(() => {
assertExpectedChainVersionSpy.mockImplementation(() => {
throw error;
});

Expand All @@ -173,7 +171,7 @@ describe('Polymesh Class', () => {
code: ErrorCode.FatalError,
message: 'Unable to connect',
});
versionSpy.mockImplementation(() => {
assertExpectedChainVersionSpy.mockImplementation(() => {
throw error;
});

Expand Down Expand Up @@ -398,6 +396,7 @@ describe('Polymesh Class', () => {
},
});
const context = dsMockUtils.getContextInstance();
context.isSqIdPadded = false;

const expectedTransaction = 'someTransaction' as unknown as PolymeshTransactionBatch<
[void, void]
Expand Down
1 change: 1 addition & 0 deletions src/api/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface MiddlewareMetadata {
specName: string;
targetHeight: BigNumber;
sqVersion: string;
paddedIds: boolean;
}

export interface SubmissionDetails {
Expand Down
2 changes: 2 additions & 0 deletions src/api/entities/Asset/Base/BaseAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export class BaseAsset extends Entity<UniqueIdentifiers, string> {
* Modify some properties of the Asset
*
* @throws if the passed values result in no changes being made to the Asset
* @throws if the passed assetType is not a known asset type or a custom type that has not been created on the chain
* @throws if trying to modify an NftCollection's assetType
*/
public modify: ProcedureMethod<ModifyAssetParams, Asset>;

Expand Down
3 changes: 2 additions & 1 deletion src/api/entities/Asset/Fungible/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class FungibleAsset extends BaseAsset {
tickerExternalAgentHistories: { nodes },
},
} = await context.queryMiddleware<Ensured<Query, 'tickerExternalAgentHistories'>>(
tickerExternalAgentHistoryQuery({
tickerExternalAgentHistoryQuery(context.isSqIdPadded, {
assetId: middlewareAssetId,
})
);
Expand Down Expand Up @@ -191,6 +191,7 @@ export class FungibleAsset extends BaseAsset {
},
} = await context.queryMiddleware<Ensured<Query, 'assetTransactions'>>(
assetTransactionQuery(
context.isSqIdPadded,
{
assetId: middlewareAssetId,
},
Expand Down
1 change: 1 addition & 0 deletions src/api/entities/Asset/NonFungible/NftCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export class NftCollection extends BaseAsset {
},
} = await context.queryMiddleware<Ensured<Query, 'assetTransactions'>>(
assetTransactionQuery(
context.isSqIdPadded,
{
assetId: id,
},
Expand Down
6 changes: 3 additions & 3 deletions src/api/entities/Asset/__tests__/Fungible/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ describe('Fungible class', () => {
const datetime = '2020-10-10';

dsMockUtils.createApolloQueryMock(
tickerExternalAgentHistoryQuery({
tickerExternalAgentHistoryQuery(false, {
assetId,
}),
{
Expand Down Expand Up @@ -775,7 +775,7 @@ describe('Fungible class', () => {
});

dsMockUtils.createApolloQueryMock(
tickerExternalAgentHistoryQuery({
tickerExternalAgentHistoryQuery(false, {
assetId,
}),
{
Expand Down Expand Up @@ -857,7 +857,7 @@ describe('Fungible class', () => {
.mockReturnValue(assetId);

dsMockUtils.createApolloQueryMock(
assetTransactionQuery({ assetId }, new BigNumber(3), new BigNumber(0)),
assetTransactionQuery(false, { assetId }, new BigNumber(3), new BigNumber(0)),
{
assetTransactions: transactionResponse,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ describe('NftCollection class', () => {
};

dsMockUtils.createApolloQueryMock(
assetTransactionQuery({ assetId }, new BigNumber(3), new BigNumber(0)),
assetTransactionQuery(false, { assetId }, new BigNumber(3), new BigNumber(0)),
{
assetTransactions: transactionResponse,
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/entities/DefaultTrustedClaimIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class DefaultTrustedClaimIssuer extends Identity {
},
},
} = await context.queryMiddleware<Ensured<Query, 'trustedClaimIssuers'>>(
trustedClaimIssuerQuery({
trustedClaimIssuerQuery(context.isSqIdPadded, {
assetId: middlewareAssetId,
issuer,
})
Expand Down
3 changes: 2 additions & 1 deletion src/api/entities/Identity/AssetPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class AssetPermissions extends Namespace<Identity> {
},
},
} = await context.queryMiddleware<Ensured<Query, 'tickerExternalAgents'>>(
tickerExternalAgentsQuery({
tickerExternalAgentsQuery(context.isSqIdPadded, {
assetId: middlewareAssetId,
})
);
Expand Down Expand Up @@ -387,6 +387,7 @@ export class AssetPermissions extends Namespace<Identity> {
},
} = await context.queryMiddleware<Ensured<Query, 'tickerExternalAgentActions'>>(
tickerExternalAgentActionsQuery(
context.isSqIdPadded,
{
assetId: middlewareAssetId,
callerId: did,
Expand Down
4 changes: 2 additions & 2 deletions src/api/entities/Identity/Portfolios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ export class Portfolios extends Namespace<Identity> {
}

const settlementsPromise = context.queryMiddleware<Ensured<Query, 'legs'>>(
settlementsForAllPortfoliosQuery({
settlementsForAllPortfoliosQuery(context.isSqIdPadded, {
identityId,
address: account,
assetId: middlewareAssetId,
})
);

const portfolioMovementsPromise = context.queryMiddleware<Ensured<Query, 'portfolioMovements'>>(
portfoliosMovementsQuery({
portfoliosMovementsQuery(context.isSqIdPadded, {
identityId,
address: account,
assetId: middlewareAssetId,
Expand Down
Loading
Loading