forked from PolymeshAssociation/polymesh-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from PolymeshAssociation/alpha
Alpha into beta
- Loading branch information
Showing
89 changed files
with
38,289 additions
and
7,338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.