Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
chore: release v0.22.0 (#346)
Browse files Browse the repository at this point in the history
* chore: upgrade kilt sdk

* fix: new tx workflow

* fix: balances

* fix: new RequestClaimsForCtypes format

* fix: filter out incompatible messages

* chore: update sdk

* feat: updating to the latest rc 4

* feat: updating to the latest rc 5

* feat: updating to the latest rc 7

* fix: display attestation status in claims list (#348)

* fix: delegation revoke signandsend (#349)

* chore: bump sdk rc

* chore: upgrading to the latest sdk rc

* chore: releasing newest version

Co-authored-by: dudleyneedham <dudleyneedham1993@gmail.com>
Co-authored-by: Raphael Flechtner <39338561+rflechtner@users.noreply.github.com>
Co-authored-by: LeonFLK <51441505+LeonFLK@users.noreply.github.com>
Co-authored-by: LeonFLK <leon@kilt.io>
  • Loading branch information
5 people authored Apr 30, 2021
1 parent e529174 commit 03b257e
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 162 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kilt-demo-client",
"version": "0.21.0",
"version": "0.22.0",
"license": "BSD-4-Clause",
"private": true,
"scripts": {
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"@babel/core": "^7.10.4",
"@kiltprotocol/sdk-js": "^0.20.0",
"@kiltprotocol/sdk-js": "^0.21.0",
"@polkadot/ui-identicon": "^0.33.1",
"@types/react-select": "^2.0.11",
"@types/reselect": "^2.2.0",
Expand Down
8 changes: 2 additions & 6 deletions src/components/DelegationNode/DelegationNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,9 @@ class DelegationNode extends React.Component<Props, State> {

blockUi.updateMessage(`Revoking ${index + 1} / ${hashes.length}`)

const tx = await Attestation.revoke(
attestation.claimHash,
selectedIdentity.identity,
steps + 1
)
const tx = await Attestation.revoke(attestation.claimHash, steps + 1)

const result = await BlockchainUtils.submitTxWithReSign(
const result = await BlockchainUtils.signAndSubmitTx(
tx,
selectedIdentity.identity,
{
Expand Down
12 changes: 6 additions & 6 deletions src/components/DevTools/DevTools.anticov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ async function newDelegation(delegate: IMyIdentity): Promise<void> {
[Permission.ATTEST]
)
const signature = delegate.identity.signStr(delegationNode.generateHash())
const tx = await delegationNode.store(root, signature)
await BlockchainUtils.submitTxWithReSign(tx, root, { resolveOn: IS_IN_BLOCK })
const tx = await delegationNode.store(signature)
await BlockchainUtils.signAndSubmitTx(tx, root, { resolveOn: IS_IN_BLOCK })
notifySuccess(`Delegation successfully created for ${delegate.metaData.name}`)
await DelegationsService.importDelegation(
delegationNode.id,
Expand All @@ -94,8 +94,8 @@ async function newDelegation(delegate: IMyIdentity): Promise<void> {
async function verifyOrAddCtypeAndRoot(): Promise<void> {
const { root, delegationRoot } = setup()
if (!(await ctype.verifyStored())) {
const tx = await ctype.store(root)
await BlockchainUtils.submitTxWithReSign(tx, root, {
const tx = await ctype.store()
await BlockchainUtils.signAndSubmitTx(tx, root, {
resolveOn: IS_IN_BLOCK,
})
CTypeRepository.register({
Expand All @@ -107,8 +107,8 @@ async function verifyOrAddCtypeAndRoot(): Promise<void> {
// delegationRoot.verify() is unreliable when using the currently released mashnet-node & // workaround is checking the ctype hash of the query result; it is 0x000... if it doesn't exist on chain
const queriedRoot = await DelegationRootNode.query(delegationRoot.id)
if (queriedRoot?.cTypeHash !== ctype.hash) {
const tx = await delegationRoot.store(root)
await BlockchainUtils.submitTxWithReSign(tx, root, {
const tx = await delegationRoot.store()
await BlockchainUtils.signAndSubmitTx(tx, root, {
resolveOn: IS_IN_BLOCK,
})
const messageBody: MessageBody = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/DevTools/DevTools.ctypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class BsCType {
const ownerIdentity = (await BsIdentity.getByKey(bsCTypeData.owner))
.identity
const cType = CType.fromSchema(bsCTypeData.schema, ownerIdentity.address)
const tx = cType.store(ownerIdentity)
await BlockchainUtils.submitTxWithReSign(await tx, ownerIdentity, {
const tx = cType.store()
await BlockchainUtils.signAndSubmitTx(await tx, ownerIdentity, {
resolveOn: BlockchainUtils.IS_IN_BLOCK,
})
return tx
Expand Down
6 changes: 3 additions & 3 deletions src/components/MessageDetailView/MessageDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ class MessageDetailView extends React.Component<Props, State> {
return (
<SubmitClaimsForCType
receiverAddresses={[message.senderAddress]}
cTypeHashes={
(message.body as IRequestClaimsForCTypes).content.ctypes
}
cTypeHashes={(message.body as IRequestClaimsForCTypes).content.map(
val => val.cTypeHash
)}
onCancel={this.handleCancel}
onFinished={this.handleDelete}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/containers/CtypeCreate/CtypeCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class CTypeCreate extends React.Component<Props, State> {
metaData,
}

const tx = cType.store(selectedIdentity.identity)
await BlockchainUtils.submitTxWithReSign(
const tx = cType.store()
await BlockchainUtils.signAndSubmitTx(
await tx,
selectedIdentity.identity,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RequestClaimsForCType extends React.Component<Props, State> {
const { cTypeHashes, receiverAddresses, onFinished } = this.props

const messageBody: IRequestClaimsForCTypes = {
content: { ctypes: cTypeHashes },
content: cTypeHashes.map(cTypeHash => ({ cTypeHash })),
type: MessageBodyType.REQUEST_CLAIMS_FOR_CTYPES,
}

Expand Down
18 changes: 6 additions & 12 deletions src/services/AttestationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class AttestationService {
}

try {
const tx = await attestation.store(selectedIdentity)
await BlockchainUtils.submitTxWithReSign(tx, selectedIdentity, {
const tx = await attestation.store()
await BlockchainUtils.signAndSubmitTx(tx, selectedIdentity, {
resolveOn: IS_IN_BLOCK,
})
} catch (error) {
Expand Down Expand Up @@ -84,12 +84,9 @@ class AttestationService {
throw new Error('No identity selected')
}
try {
const tx = await attestation.revoke(
selectedIdentity,
delegationTreeTraversalSteps
)
const tx = await attestation.revoke(delegationTreeTraversalSteps)

await BlockchainUtils.submitTxWithReSign(tx, selectedIdentity, {
await BlockchainUtils.signAndSubmitTx(tx, selectedIdentity, {
resolveOn: IS_IN_BLOCK,
})
notifySuccess('Attestation successfully revoked')
Expand Down Expand Up @@ -122,12 +119,9 @@ class AttestationService {
)

try {
const tx = await attestation.revoke(
selectedIdentity,
delegationTreeTraversalSteps
)
const tx = await attestation.revoke(delegationTreeTraversalSteps)

await BlockchainUtils.submitTxWithReSign(tx, selectedIdentity, {
await BlockchainUtils.signAndSubmitTx(tx, selectedIdentity, {
resolveOn: IS_IN_BLOCK,
})

Expand Down
23 changes: 13 additions & 10 deletions src/services/BalanceUtilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
PublicIdentity,
BlockchainUtils,
} from '@kiltprotocol/sdk-js'
import { Balances as KiltBalances } from '@kiltprotocol/types'
import BN from 'bn.js'
import React from 'react'
import { Store } from 'redux'
Expand Down Expand Up @@ -46,8 +47,10 @@ class BalanceUtilities {
}

public static async getMyBalance(identity: IMyIdentity): Promise<BN> {
const balance: BN = await Balance.getBalance(identity.identity.address)
return balance
const balance: KiltBalances = await Balance.getBalances(
identity.identity.address
)
return balance.free
}

public static connectMyIdentities(
Expand Down Expand Up @@ -75,9 +78,9 @@ class BalanceUtilities {
<ContactPresentation address={receiverAddress} inline /> initiated.
</div>
)
Balance.makeTransfer(myIdentity.identity, receiverAddress, transferAmount)
Balance.makeTransfer(receiverAddress, transferAmount)
.then(tx =>
BlockchainUtils.submitTxWithReSign(tx, myIdentity.identity, {
BlockchainUtils.signAndSubmitTx(tx, myIdentity.identity, {
resolveOn: BlockchainUtils.IS_IN_BLOCK,
})
)
Expand Down Expand Up @@ -117,21 +120,21 @@ class BalanceUtilities {

private static listener(
account: PublicIdentity['address'],
balance: BN,
change: BN
balance: KiltBalances,
change: KiltBalances
): void {
if (!change.isZero()) {
const inDeCreased = `${change.gtn(0) ? 'in' : 'de'}creased`
if (!change.free.isZero()) {
const inDeCreased = `${change.free.gtn(0) ? 'in' : 'de'}creased`

notify(
<div>
Balance of <ContactPresentation address={account} /> {inDeCreased} by{' '}
<KiltToken amount={change} colored />.
<KiltToken amount={change.free} colored />.
</div>
)
}
persistentStoreInstance.store.dispatch(
Balances.Store.updateBalance(account, balance)
Balances.Store.updateBalance(account, balance.free)
)
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/services/DelegationsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class DelegationsService {
if (!selectedIdentity) {
throw new Error('No selected Identity')
}
const tx = await delegation.store(selectedIdentity, signature)
return BlockchainUtils.submitTxWithReSign(tx, selectedIdentity, {
const tx = await delegation.store(signature)
return BlockchainUtils.signAndSubmitTx(tx, selectedIdentity, {
resolveOn: BlockchainUtils.IS_IN_BLOCK,
})
}
Expand Down Expand Up @@ -138,7 +138,11 @@ class DelegationsService {
node: DelegationBaseNode,
identity: Identity
): Promise<void> {
await node.revoke(identity)
await BlockchainUtils.signAndSubmitTx(
await node.revoke(identity.address),
identity,
{ resolveOn: BlockchainUtils.IS_IN_BLOCK }
)
persistentStoreInstance.store.dispatch(
Delegations.Store.revokeDelegationAction(node.id)
)
Expand Down Expand Up @@ -169,8 +173,8 @@ class DelegationsService {
throw new Error('No selected Identity')
}

const tx = await delegation.store(selectedIdentity)
return BlockchainUtils.submitTxWithReSign(tx, selectedIdentity, {
const tx = await delegation.store()
return BlockchainUtils.signAndSubmitTx(tx, selectedIdentity, {
resolveOn: BlockchainUtils.IS_IN_BLOCK,
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/services/DidService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class DidService {
publicIdentity: myIdentity.identity.getPublicIdentity(),
} as IContact)

const tx = await did.store(myIdentity.identity)
const status = await BlockchainUtils.submitTxWithReSign(
const tx = await did.store()
const status = await BlockchainUtils.signAndSubmitTx(
tx,
myIdentity.identity,
{
Expand All @@ -110,8 +110,8 @@ class DidService {
}

public static async deleteDid(myIdentity: IMyIdentity): Promise<void> {
const tx = await Did.remove(myIdentity.identity)
const status = await BlockchainUtils.submitTxWithReSign(
const tx = await Did.remove()
const status = await BlockchainUtils.signAndSubmitTx(
tx,
myIdentity.identity,
{
Expand Down
18 changes: 14 additions & 4 deletions src/services/MessageRepository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,17 @@ class MessageRepository {
}
}
)
return decryptedMesssages.filter(filterArray)
return (
decryptedMesssages
.filter(filterArray)
// TODO: check message structure via SDK
.filter(
message =>
message.body.type !==
MessageBodyType.REQUEST_CLAIMS_FOR_CTYPES ||
Array.isArray(message.body.content)
)
)
})
}

Expand Down Expand Up @@ -262,9 +272,9 @@ class MessageRepository {
]

case MessageBodyType.REQUEST_CLAIMS_FOR_CTYPES:
return (message.body as IRequestClaimsForCTypes).content.ctypes.filter(
Boolean
)
return (message.body as IRequestClaimsForCTypes).content
.map(val => val.cTypeHash)
.filter(Boolean)
case MessageBodyType.SUBMIT_CLAIMS_FOR_CTYPES: {
const cTypeHashes = (message.body as ISubmitClaimsForCTypes).content.map(
attestedClaim => attestedClaim.request.claim.cTypeHash
Expand Down
8 changes: 7 additions & 1 deletion src/state/ducks/Claims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,13 @@ class Store {
(attestedClaim: IAttestedClaim, index: number) => {
if (attestedClaim.attestation.claimHash === revokedHash) {
// avoid changing claims while iterating
setIns.push([myClaimHash, 'attestedClaims', index, 'revoked'])
setIns.push([
myClaimHash,
'attestedClaims',
index,
'attestation',
'revoked',
])
}
}
)
Expand Down
Loading

0 comments on commit 03b257e

Please sign in to comment.