Skip to content

Commit

Permalink
Merge pull request #34 from Concordium/revert-29-delegation
Browse files Browse the repository at this point in the history
Revert "Add delegation functionality"
  • Loading branch information
shjortConcordium authored Mar 9, 2022
2 parents 8beea46 + 864c63a commit 4db4216
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 1,136 deletions.
10 changes: 1 addition & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# Changelog

## 0.7.0 2022-03-09
## 0.7.1 2022-03-09

### Added

- Support for getting baker list from node.
- Support for getting status of Baker-/L-pool (required node to have protocol version 4 or later)
- Helper functions for determining the version of `BlockSummary` and nested types.
- Support for initiating and updating contracts with parameters.

### Changed

- Updated `BlockSummary` type to include new version, effective from protocol version 4.
- Updated `AccountInfo` type to include new fields related to delegation introduced with protocol version 4.

## 0.6.0 2022-02-02

### Added
Expand Down
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,26 +542,6 @@ const peersList = peerListResponse.getPeersList();
...
```

## getBakerList
Retrieves the list of ID's for registered bakers on the network at a specific block.
```js
const blockHash = "7f7409679e53875567e2ae812c9fcefe90ced8961d08554756f42bf268a42749";
const bakerIds = await client.getBakerList(blockHash);
...
```

## getPoolStatus
Retrieves the status of a pool (either L-Pool or specific baker) at a specific block.
If a baker ID is specified, the status of that baker is returned. To get the status of the L-Pool, a baker ID should be left undefined.
```js
const blockHash = "7f7409679e53875567e2ae812c9fcefe90ced8961d08554756f42bf268a42749";
const bakerId = BigInt(1);

const bakerStatus = await client.getPoolStatus(blockHash, bakerId);
const lPoolStatus = await client.getPoolStatus(blockHash);
...
```

## Check block for transfers with memo
The following example demonstrates how to check and parse a block
for transfers with a memo.
Expand Down
2 changes: 1 addition & 1 deletion deps/concordium-base
Submodule concordium-base updated 75 files
+4 −2 CHANGELOG.md
+5 −1 concordium-base.cabal
+10 −0 haskell-bins/genesis/Genesis.hs
+1 −0 haskell-bins/genesis/README.md
+16 −8 haskell-src/Concordium/Constants.hs
+1 −1 haskell-src/Concordium/Crypto/EncryptedTransfers.hs
+29 −0 haskell-src/Concordium/Genesis/Data.hs
+1 −1 haskell-src/Concordium/Genesis/Data/P2.hs
+107 −0 haskell-src/Concordium/Genesis/Data/P3.hs
+107 −0 haskell-src/Concordium/Genesis/Data/P4.hs
+22 −5 haskell-src/Concordium/ID/Types.hs
+62 −6 haskell-src/Concordium/Types.hs
+21 −4 haskell-src/Concordium/Types/Accounts.hs
+738 −22 haskell-src/Concordium/Types/Execution.hs
+0 −170 haskell-src/Concordium/Types/Instance.hs
+137 −0 haskell-src/Concordium/Types/InvokeContract.hs
+0 −43 haskell-src/Concordium/Types/Parameters.hs
+22 −1 haskell-src/Concordium/Types/ProtocolVersion.hs
+9 −0 haskell-src/Concordium/Types/Updates.hs
+18 −0 haskell-src/Concordium/Utils/Serialization.hs
+196 −95 haskell-src/Concordium/Wasm.hs
+24 −0 haskell-src/Data/FixedByteString.hs
+5 −1 haskell-tests/Spec.hs
+51 −0 haskell-tests/Types/AddressesSpec.hs
+52 −44 haskell-tests/Types/PayloadSerializationSpec.hs
+2 −1 haskell-tests/Types/TransactionGen.hs
+240 −0 haskell-tests/Types/TransactionSummarySpec.hs
+7 −0 idiss-csharp/CHANGELOG.md
+12 −0 idiss-csharp/IdissExample/IdissExample.csproj
+66 −0 idiss-csharp/IdissExample/Program.cs
+21 −0 idiss-csharp/IdissLib/Exceptions.cs
+107 −0 idiss-csharp/IdissLib/Idiss.cs
+8 −0 idiss-csharp/IdissLib/IdissLib.csproj
+77 −0 idiss-csharp/IdissLib/JsonConverters.cs
+302 −0 idiss-csharp/IdissLib/Types.cs
+20 −0 idiss-csharp/IdissLibTest/IdissLibTest.csproj
+63 −0 idiss-csharp/IdissLibTest/IdissTests.cs
+70 −0 idiss-csharp/README.md
+20 −0 idiss-csharp/data/alist.json
+50 −0 idiss-csharp/data/anonymity_revokers.json
+8 −0 idiss-csharp/data/global.json
+13 −0 idiss-csharp/data/identity_provider.pub.json
+57 −0 idiss-csharp/data/valid_request.json
+62 −0 idiss-csharp/idiss-csharp.sln
+11 −0 idiss/CHANGELOG.md
+41 −26 idiss/Cargo.lock
+20 −10 idiss/Cargo.toml
+59 −17 idiss/README.md
+1 −0 idiss/build.rs
+6 −2 idiss/example.js
+163 −0 idiss/src/cs_exports.rs
+99 −110 idiss/src/lib.rs
+46 −16 idiss/src/nodejs_exports.rs
+4 −6 mobile_wallet/scripts/android.Jenkinsfile
+28 −4 rust-bins/Cargo.lock
+1 −1 rust-bins/Cargo.toml
+3 −3 rust-bins/docs/id-client.md
+58 −0 rust-bins/docs/identity-provider-cli.md
+27 −2 rust-bins/docs/keygen.md
+110 −0 rust-bins/docs/user-cli.md
+22 −2 rust-bins/id-client-notes/instructions.md
+29 −20 rust-bins/src/bin/client.rs
+236 −0 rust-bins/src/bin/identity_provider_cli.rs
+131 −31 rust-bins/src/bin/keygen.rs
+553 −0 rust-bins/src/bin/user_cli.rs
+49 −1 rust-bins/src/lib.rs
+140 −182 rust-src/Cargo.lock
+1 −1 rust-src/crypto_common/Cargo.toml
+2 −1 rust-src/crypto_common/src/impls.rs
+5 −2 rust-src/eddsa_ed25519/src/eddsa_ed25519.rs
+43 −12 rust-src/id/src/types.rs
+6 −0 rust-src/keygen_bls/CHANGELOG.md
+2 −1 rust-src/keygen_bls/Cargo.toml
+149 −1 rust-src/keygen_bls/src/lib.rs
+24 −1 rust-src/ps_sig/src/public.rs
2 changes: 1 addition & 1 deletion deps/concordium-grpc-api
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concordium/node-sdk",
"version": "0.7.0",
"version": "0.7.1",
"description": "Helpers for interacting with the Concordium node",
"repository": {
"type": "git",
Expand Down
17 changes: 0 additions & 17 deletions src/accountHelpers.ts

This file was deleted.

34 changes: 0 additions & 34 deletions src/blockSummaryHelpers.ts

This file was deleted.

174 changes: 8 additions & 166 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
BlockHeight,
Empty,
GetAddressInfoRequest,
GetPoolStatusRequest,
GetModuleSourceRequest,
PeerListResponse,
PeersRequest,
Expand All @@ -27,10 +26,11 @@ import {
AccountTransaction,
AccountTransactionSignature,
ArInfo,
ReduceStakePendingChange,
RemovalPendingChange,
BakerReduceStakePendingChange,
BakerRemovalPendingChange,
BlockInfo,
BlockSummary,
ChainParameters,
ConsensusStatus,
ContractAddress,
CredentialDeploymentTransaction,
Expand All @@ -49,24 +49,9 @@ import {
Versioned,
InstanceInfo,
InstanceInfoSerialized,
BakerId,
ChainParametersV0,
ChainParametersV1,
PoolStatus,
BakerPoolStatusDetails,
CurrentPaydayBakerPoolStatus,
LPoolStatusDetails,
KeysMatching,
BakerPoolPendingChangeReduceBakerCapitalDetails,
LPoolStatus,
BakerPoolStatus,
RewardStatusV0,
RewardStatus,
RewardStatusV1,
} from './types';
import {
buildJsonResponseReviver,
intListToStringList,
intToStringTransformer,
isValidHash,
unwrapBoolResponse,
Expand All @@ -75,7 +60,6 @@ import {
import { GtuAmount } from './types/gtuAmount';
import { ModuleReference } from './types/moduleReference';
import { Buffer as BufferFormater } from 'buffer/';

/**
* A concordium-node specific gRPC client wrapper.
*
Expand Down Expand Up @@ -227,8 +211,8 @@ export default class ConcordiumNodeClient {
| keyof AccountReleaseSchedule
| keyof ReleaseSchedule
| keyof AccountBakerDetails
| keyof ReduceStakePendingChange
| keyof RemovalPendingChange
| keyof BakerReduceStakePendingChange
| keyof BakerRemovalPendingChange
)[] = [
'accountAmount',
'accountNonce',
Expand Down Expand Up @@ -334,7 +318,7 @@ export default class ConcordiumNodeClient {
| keyof PartyInfo
| keyof FinalizationData
| keyof TransactionSummary
| keyof (ChainParametersV0 & ChainParametersV1)
| keyof ChainParameters
| keyof ExchangeRate
| keyof UpdateQueue
| keyof KeysWithThreshold
Expand All @@ -348,23 +332,15 @@ export default class ConcordiumNodeClient {
'cost',
'energyCost',
'index',
'bakerCooldownEpochs',
'minimumThresholdForBaking',
'foundationAccountIndex',
'numerator',
'denominator',
'nextSequenceNumber',
'amount',
'index',
'subindex',

// v0 keys
'bakerCooldownEpochs',
'minimumThresholdForBaking',

// v1 keys
'rewardPeriodLength',
'minimumEquityCapital',
'poolOwnerCooldown',
'delegatorCooldown',
];

return unwrapJsonResponse<BlockSummary>(
Expand Down Expand Up @@ -625,140 +601,6 @@ export default class ConcordiumNodeClient {
}
}

async getRewardStatus(
blockHash: string
): Promise<RewardStatus | undefined> {
if (!isValidHash(blockHash)) {
throw new Error('The input was not a valid hash: ' + blockHash);
}

type DateKey = KeysMatching<RewardStatusV1, Date>;
type BigIntKey = KeysMatching<RewardStatusV0 & RewardStatusV1, bigint>;

const dates: DateKey[] = ['nextPaydayTime'];
const bigInts: BigIntKey[] = [
'protocolVersion',
'gasAccount',
'totalAmount',
'totalStakedCapital',
'bakingRewardAccount',
'totalEncryptedAmount',
'finalizationRewardAccount',
'foundationTransactionRewards',
];

const bh = new BlockHash();
bh.setBlockHash(blockHash);

const response = await this.sendRequest(
this.client.getRewardStatus,
bh
);

return unwrapJsonResponse<RewardStatus>(
response,
buildJsonResponseReviver(dates, bigInts),
intToStringTransformer(bigInts)
);
}

/**
* Retrieve list of bakers on the network.
* @param blockHash the block hash to get the smart contact instances at
* @returns A JSON list of baker IDs
*/
async getBakerList(blockHash: string): Promise<BakerId[] | undefined> {
if (!isValidHash(blockHash)) {
throw new Error('The input was not a valid hash: ' + blockHash);
}

const bh = new BlockHash();
bh.setBlockHash(blockHash);

const response = await this.sendRequest(this.client.getBakerList, bh);

return unwrapJsonResponse<BakerId[]>(
response,
undefined,
intListToStringList
)?.map((v) => BigInt(v));
}

/**
* Gets the status the L-pool.
* @param blockHash the block hash the status at
* @returns The status of the L-pool.
*/
async getPoolStatus(blockHash: string): Promise<LPoolStatus | undefined>;
/**
* Gets the status a baker.
* @param blockHash the block hash the status at
* @param bakerId the ID of the baker to get the status for.
* @returns The status of the corresponding baker pool.
*/
async getPoolStatus(
blockHash: string,
bakerId: BakerId
): Promise<BakerPoolStatus | undefined>;
/**
* Gets the status of either a baker, if a baker ID is supplied, or the L-pool if left undefined.
* @param blockHash the block hash the status at
* @param [bakerId] the ID of the baker to get the status for. If left undefined, the status of the L-pool is returned.
* @returns The status of the corresponding pool.
*/
async getPoolStatus(
blockHash: string,
bakerId?: BakerId
): Promise<PoolStatus | undefined>;
async getPoolStatus(
blockHash: string,
bakerId?: BakerId
): Promise<PoolStatus | undefined> {
if (!isValidHash(blockHash)) {
throw new Error('The input was not a valid hash: ' + blockHash);
}

const req = new GetPoolStatusRequest();
req.setBlockHash(blockHash);
req.setLPool(bakerId === undefined);

if (bakerId !== undefined) {
req.setBakerId(bakerId.toString());
}

type DateKey = KeysMatching<
BakerPoolPendingChangeReduceBakerCapitalDetails,
Date
>;
type BigIntKey = KeysMatching<
BakerPoolStatusDetails &
LPoolStatusDetails &
CurrentPaydayBakerPoolStatus,
bigint
>;

const dates: DateKey[] = ['effectiveTime'];
const bigInts: BigIntKey[] = [
'bakerId',
'bakerEquityCapital',
'delegatedCapital',
'delegatedCapitalCap',
'currentPaydayTransactionFeesEarned',
'currentPaydayDelegatedCapital',
'blocksBaked',
'transactionFeesEarned',
'effectiveStake',
];

const response = await this.sendRequest(this.client.getPoolStatus, req);

return unwrapJsonResponse<PoolStatus>(
response,
buildJsonResponseReviver(dates, bigInts),
intToStringTransformer(bigInts)
);
}

async getModuleSource(
blockHash: string,
moduleReference: ModuleReference
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ export {
} from './credentialDeploymentTransactions';
export { isAlias, getAlias } from './alias';
export { deserializeContractState } from './deserialization';
export * from './blockSummaryHelpers';
4 changes: 0 additions & 4 deletions src/rewardStatusHelpers.ts

This file was deleted.

Loading

0 comments on commit 4db4216

Please sign in to comment.