Skip to content

Commit

Permalink
Merge pull request #11 from PolymeshAssociation/alpha
Browse files Browse the repository at this point in the history
Alpha into beta
  • Loading branch information
polymath-eric authored Mar 8, 2024
2 parents adcc387 + 8fa3596 commit fb8238c
Show file tree
Hide file tree
Showing 89 changed files with 38,289 additions and 7,338 deletions.
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, confidential-assets]
pull_request:
types: [assigned, opened, synchronize, reopened]

Expand Down
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
".vscode-insiders",
"src/polkadot",
"src/middleware",
".eslintrc",
".eslintrc"
],
"cSpell.ignoreRegExpList": [
"/from\\s+(['\"]).*\\1/", // ignore imports
"/\/\/ TODO @\\w+/", // ignore github handles in TODOs
"/// TODO @\\w+/", // ignore github handles in TODOs
"/0x.+/" // ignore hex values
],
"cSpell.words": [
Expand All @@ -35,12 +35,14 @@
"discoverability",
"dispatchable",
"dispatchables",
"Elgamal",
"Encodable",
"Externalagents",
"Extrinsics",
"Falsyable",
"Figi",
"frontends",
"Gamal",
"inmemory",
"Isin",
"millis",
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard)
[![Types](https://img.shields.io/npm/types/@polymeshassociation/polymesh-sdk)](https://)
[![npm](https://img.shields.io/npm/v/@polymeshassociation/polymesh-sdk)](https://www.npmjs.com/package/@polymeshassociation/polymesh-sdk)
[![Types](https://img.shields.io/npm/types/@polymeshassociation/polymesh-private-sdk)](https://)
[![npm](https://img.shields.io/npm/v/@polymeshassociation/polymesh-private-sdk)](https://www.npmjs.com/package/@polymeshassociation/polymesh-private-sdk)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=PolymeshAssociation_polymesh-sdk&metric=coverage)](https://sonarcloud.io/summary/new_code?id=PolymeshAssociation_polymesh-sdk)
[![Github Actions Workflow](https://github.com/PolymeshAssociation/polymesh-sdk/actions/workflows/main.yml/badge.svg)](https://github.com/PolymeshAssociation/polymesh-sdk/actions)
[![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=PolymeshAssociation_polymesh-sdk&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=PolymeshAssociation_polymesh-sdk)
[![Issues](https://img.shields.io/github/issues/PolymeshAssociation/polymesh-sdk)](https://github.com/PolymeshAssociation/polymesh-sdk/issues)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=PolymeshAssociation_polymesh-private-sdk&metric=coverage)](https://sonarcloud.io/summary/new_code?id=PolymeshAssociation_polymesh-sdk)
[![Github Actions Workflow](https://github.com/PolymeshAssociation/polymesh-private-sdk/actions/workflows/main.yml/badge.svg)](https://github.com/PolymeshAssociation/polymesh-private-sdk/actions)
[![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=PolymeshAssociation_polymesh-private-sdk&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=PolymeshAssociation_polymesh-private-sdk)
[![Issues](https://img.shields.io/github/issues/PolymeshAssociation/polymesh-private-sdk)](https://github.com/PolymeshAssociation/polymesh-private-sdk/issues)

## \@polymeshassociation/polymesh-sdk

Expand Down Expand Up @@ -42,15 +42,15 @@ https://developers.polymesh.network/sdk-docs/

#### Installation

`npm i @polymeshassociation/polymesh-sdk --save`
`npm i @polymeshassociation/polymesh-private-sdk --save`

Or, if you're using yarn

`yarn add @polymeshassociation/polymesh-sdk`
`yarn add @polymeshassociation/polymesh-private-sdk`

Or, if using pnpm

`pnpm add @polymeshassociation/polymesh-sdk`
`pnpm add @polymeshassociation/polymesh-private-sdk`

**NOTE** it is _highly_ recommended that you use one of these three package managers. This project uses package resolutions/overrides to pin certain problematic dependencies, and these are only supported by the aforementioned package managers. Using a different package manager may result in unexpected behavior

Expand All @@ -61,7 +61,7 @@ Or, if using pnpm
Before you can start registering Tickers and creating Assets, you have to connect the Polymesh SDK client to a Polymesh node. This is a pretty straightforward process:

```typescript
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
import { Polymesh } from '@polymeshassociation/polymesh-private-sdk';
import { LocalSigningManager } from '@polymeshassociation/local-signing-manager';

async function run() {
Expand Down Expand Up @@ -92,7 +92,7 @@ Here is an overview of the parameters passed to the `connect` function:
**NOTE:** if using the SDK on a browser environment \(i.e. with the Polymesh wallet browser extension\), you would use the `BrowserExtensionSigningManager` provided by `@polymeshassociation/browser-extension-signing-manager`

```typescript
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
import { Polymesh } from '@polymeshassociation/polymesh-private-sdk';
import { BrowserExtensionSigningManager } from '@polymeshassociation/browser-extension-signing-manager';

async function run() {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@polymeshassociation/polymesh-sdk",
"name": "@polymeshassociation/polymesh-private-sdk",
"version": "0.0.0",
"description": "High-level API to interact with the Polymesh blockchain",
"description": "High-level API to interact with the Polymesh Private blockchain",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Polymesh Association",
"license": "ISC",
"homepage": "https://github.com/PolymeshAssociation/polymesh-sdk/wiki",
"homepage": "https://github.com/PolymeshAssociation/polymesh-private-sdk/wiki",
"bugs": {
"url": "https://github.com/PolymeshAssociation/polymesh-sdk/issues"
"url": "https://github.com/PolymeshAssociation/polymesh-private-sdk/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/PolymeshAssociation/polymesh-sdk"
"url": "https://github.com/PolymeshAssociation/polymesh-private-sdk"
},
"keywords": [
"polymesh",
Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
repositoryUrl: 'https://github.com/PolymeshAssociation/polymesh-sdk.git',
repositoryUrl: 'https://github.com/PolymeshAssociation/polymesh-private-sdk.git',
branches: [
'master',
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/processDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const markdownLinks = getMarkdownLinks(hierarchy, 0);

fs.writeFileSync(
sidebarFilePath,
`## @polymeshassociation/polymesh-sdk
`## @polymeshassociation/polymesh-private-sdk
- [Home](../wiki/Home)
Expand Down
20 changes: 20 additions & 0 deletions scripts/transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,25 @@
"issue_nft": "issue_nft",
"redeem_nft": "redeem_nft",
"controller_transfer": "controller_transfer"
},
"ConfidentialAsset": {
"create_account": "create_account",
"create_confidential_asset": "create_confidential_asset",
"mint_confidential_asset": "mint_confidential_asset",
"apply_incoming_balance": "apply_incoming_balance",
"create_venue": "create_venue",
"set_venue_filtering": "set_venue_filtering",
"allow_venues": "allow_venues",
"disallow_venues": "disallow_venues",
"add_transaction": "add_transaction",
"affirm_transactions": "affirm_transactions",
"execute_transaction": "execute_transaction",
"reject_transaction": "reject_transaction",
"create_asset": "create_asset",
"mint": "mint",
"set_asset_frozen": "set_asset_frozen",
"set_account_asset_frozen": "set_account_asset_frozen",
"apply_incoming_balances": "apply_incoming_balances",
"burn": "burn"
}
}
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonar.organization=polymeshassociation
sonar.projectKey=PolymeshAssociation_polymesh-sdk
sonar.projectKey=PolymeshAssociation_polymesh-private-sdk
sonar.sources=src
sonar.coverage.exclusions=**/testUtils/**,**/polkadot/**,**/__tests__/**,**/generated/**,src/utils/typeguards.ts,src/types/internal.ts,src/middleware/enums.ts
sonar.cpd.exclusions=**/__tests__/**,**/polkadot/**
Expand Down
94 changes: 94 additions & 0 deletions src/api/client/ConfidentialAccounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {
applyIncomingAssetBalance,
applyIncomingConfidentialAssetBalances,
ConfidentialAccount,
Context,
createConfidentialAccount,
PolymeshError,
} from '~/internal';
import {
ApplyIncomingBalanceParams,
ApplyIncomingConfidentialAssetBalancesParams,
CreateConfidentialAccountParams,
ErrorCode,
ProcedureMethod,
} from '~/types';
import { createProcedureMethod } from '~/utils/internal';

/**
* Handles all Confidential Account related functionality
*/
export class ConfidentialAccounts {
private context: Context;

/**
* @hidden
*/
constructor(context: Context) {
this.context = context;

this.createConfidentialAccount = createProcedureMethod(
{
getProcedureAndArgs: args => [createConfidentialAccount, { ...args }],
},
context
);

this.applyIncomingBalance = createProcedureMethod(
{
getProcedureAndArgs: args => [applyIncomingAssetBalance, { ...args }],
},
context
);

this.applyIncomingBalances = createProcedureMethod(
{
getProcedureAndArgs: args => [applyIncomingConfidentialAssetBalances, { ...args }],
},
context
);
}

/**
* Retrieve a ConfidentialAccount
*/
public async getConfidentialAccount(args: { publicKey: string }): Promise<ConfidentialAccount> {
const { context } = this;
const { publicKey } = args;

const confidentialAsset = new ConfidentialAccount({ publicKey }, context);

const identity = await confidentialAsset.getIdentity();

if (!identity) {
throw new PolymeshError({
code: ErrorCode.DataUnavailable,
message: 'No confidential Account exists',
data: { publicKey },
});
}

return confidentialAsset;
}

/**
* Create a confidential Account
*/
public createConfidentialAccount: ProcedureMethod<
CreateConfidentialAccountParams,
ConfidentialAccount
>;

/**
* Applies incoming balance to a Confidential Account
*/
public applyIncomingBalance: ProcedureMethod<ApplyIncomingBalanceParams, ConfidentialAccount>;

/**
* Applies any incoming balance to a Confidential Account
*/
public applyIncomingBalances: ProcedureMethod<
ApplyIncomingConfidentialAssetBalancesParams,
ConfidentialAccount
>;
}
51 changes: 51 additions & 0 deletions src/api/client/ConfidentialAssets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ConfidentialAsset, Context, createConfidentialAsset, PolymeshError } from '~/internal';
import { CreateConfidentialAssetParams, ErrorCode, ProcedureMethod } from '~/types';
import { createProcedureMethod } from '~/utils/internal';

/**
* Handles all Confidential Asset related functionality
*/
export class ConfidentialAssets {
private context: Context;

/**
* @hidden
*/
constructor(context: Context) {
this.context = context;

this.createConfidentialAsset = createProcedureMethod(
{
getProcedureAndArgs: args => [createConfidentialAsset, { ...args }],
},
context
);
}

/**
* Retrieve a ConfidentialAsset
*/
public async getConfidentialAsset(args: { id: string }): Promise<ConfidentialAsset> {
const { context } = this;
const { id } = args;

const confidentialAsset = new ConfidentialAsset({ id }, context);

const exists = await confidentialAsset.exists();

if (!exists) {
throw new PolymeshError({
code: ErrorCode.DataUnavailable,
message: 'Confidential Asset does not exists',
data: { id },
});
}

return confidentialAsset;
}

/**
* Create a confidential Asset
*/
public createConfidentialAsset: ProcedureMethod<CreateConfidentialAssetParams, ConfidentialAsset>;
}
77 changes: 77 additions & 0 deletions src/api/client/ConfidentialSettlements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import BigNumber from 'bignumber.js';

import {
ConfidentialTransaction,
ConfidentialVenue,
Context,
createConfidentialVenue,
PolymeshError,
} from '~/internal';
import { ErrorCode, NoArgsProcedureMethod } from '~/types';
import { createProcedureMethod } from '~/utils/internal';

/**
* Handles all functionalities for venues and transactions of confidential Assets
*/
export class ConfidentialSettlements {
private context: Context;

/**
* @hidden
*/
constructor(context: Context) {
this.context = context;

this.createVenue = createProcedureMethod(
{ getProcedureAndArgs: () => [createConfidentialVenue, undefined], voidArgs: true },
context
);
}

/**
* Create a Confidential Venue under the ownership of the signing Identity
*/
public createVenue: NoArgsProcedureMethod<ConfidentialVenue>;

/**
* Retrieve a confidential Venue by its ID
*
* @param args.id - identifier number of the confidential Venue
*/
public async getVenue(args: { id: BigNumber }): Promise<ConfidentialVenue> {
const { context } = this;

const venue = new ConfidentialVenue(args, context);

const venueExists = await venue.exists();
if (!venueExists) {
throw new PolymeshError({
code: ErrorCode.DataUnavailable,
message: 'The confidential Venue does not exists',
});
}

return venue;
}

/**
* Retrieve a settlement Transaction by its ID
*
* @param args.id - identifier number of the ConfidentialTransaction
*/
public async getTransaction(args: { id: BigNumber }): Promise<ConfidentialTransaction> {
const { context } = this;

const transaction = new ConfidentialTransaction(args, context);

const exists = await transaction.exists();
if (!exists) {
throw new PolymeshError({
code: ErrorCode.DataUnavailable,
message: 'The Transaction does not exists',
});
}

return transaction;
}
}
Loading

0 comments on commit fb8238c

Please sign in to comment.