Skip to content

feat: high-level did helper api #881

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

Merged
merged 78 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
22f79cc
feat: create DID signers from signers or keypairs
rflechtner Jul 2, 2024
d29002f
feat: transact first draft
abdulmth Jul 8, 2024
24eddba
feat: transact full-featured implementation
rflechtner Jul 9, 2024
70fa620
test: first unit test stub
rflechtner Jul 9, 2024
90b9119
test: commenting out require cycle that broke tests (REVERT ME)
rflechtner Jul 9, 2024
e90d302
test: some fixes to did helper tests
rflechtner Jul 10, 2024
90d5ebe
fix: checkresult
abdulmth Jul 11, 2024
8479b2c
feat: createDid draft
abdulmth Jul 15, 2024
36b0cb5
chore: add didNonce parameter
rflechtner Jul 15, 2024
bb7fe33
refactor: deduplicate transact logic
rflechtner Jul 15, 2024
ab417f7
refactor: make createDid synchronous
rflechtner Jul 16, 2024
d91af94
feat: draft set verification method
abdulmth Jul 16, 2024
c1c6169
refactor: reorganize code
rflechtner Jul 16, 2024
23be55a
fix: setVerificationMethod
abdulmth Jul 16, 2024
0bbe3bf
feat: add service methods
abdulmth Jul 16, 2024
101ae79
feat: implement claimWeb3Name
rflechtner Jul 16, 2024
44bf049
feat: implement releaseWeb3Name
rflechtner Jul 16, 2024
a21b675
fix: module error matching
rflechtner Jul 16, 2024
07e0096
test: integration tests for w3n helpers
rflechtner Jul 16, 2024
89b434b
test: add unit tests for addService & removeService
rflechtner Jul 16, 2024
c207032
test: run service unit tests for fragment- and full ids
rflechtner Jul 16, 2024
2a3fa57
fix: export service did helpers
rflechtner Jul 16, 2024
f098ec1
test: service did helpers integration tests
rflechtner Jul 16, 2024
ec0978b
fix: setVerificationMethod extrinsics and logic (#878)
rflechtner Jul 17, 2024
7a55e99
feat: removeVM
abdulmth Jul 16, 2024
ed974a3
fix: documentation
abdulmth Jul 16, 2024
bc59831
fix: export removeVerificationMethod
rflechtner Jul 16, 2024
409e2d4
test: add verificationMethods unit tests
rflechtner Jul 16, 2024
c07e3ea
fix: add x25519 to allowed public key 'type' values
rflechtner Jul 17, 2024
4b9e3de
test: add VM management integration tests
rflechtner Jul 17, 2024
42ed9a6
feat: implement deactivateDid (#877)
rflechtner Jul 17, 2024
82b0c3a
refactor: reduce getSubmittable code duplication
rflechtner Jul 17, 2024
4c0ec24
docs: fix incomplete docstrings
rflechtner Jul 17, 2024
c6e8ef8
chore: add missing deps
rflechtner Jul 17, 2024
e0b95fa
refactor: better error messages on asXxx
rflechtner Jul 17, 2024
8856df3
refactor: move selectSigner to separate file
rflechtner Jul 17, 2024
9ad9820
refactor: streamline VM helper implementation
rflechtner Jul 17, 2024
51c2aa5
fix: build error
rflechtner Jul 17, 2024
8bf30cd
refactor: various did helper refactors, code deduplication & lint fix…
abdulmth Jul 17, 2024
30d0560
test: integration test for transact
rflechtner Jul 17, 2024
280bcbc
test: transact integration test (#883)
abdulmth Jul 17, 2024
1dc7fc1
chore: refactor `createDid` and `transact` tests
abdulmth Jul 17, 2024
f1f13f3
chore: refactor `createDid` and `transact` tests (#884)
abdulmth Jul 18, 2024
6df788a
refactor: internal transact implementation with factory
rflechtner Jul 17, 2024
455d96f
test: fix unit tests
rflechtner Jul 18, 2024
ab44926
refactor: internal version of transact (#885)
abdulmth Jul 18, 2024
9e1b6b4
chore: refactor checkResult
abdulmth Jul 18, 2024
7484bd5
fix: set events
abdulmth Jul 18, 2024
331dd51
chore: set versions
rflechtner Dec 14, 2023
eda130f
chore(deps): bump jcs versions
rflechtner Jul 18, 2024
d903907
chore: set alpha.2 versions
rflechtner Jul 18, 2024
facb305
Merge branch 'develop' into rf-did-helpers
rflechtner Jul 18, 2024
7b66646
chore: use return in checkStatus
abdulmth Jul 19, 2024
3a9571a
chore: move `mapError` and `assertStatus`
abdulmth Jul 19, 2024
ab3d2ee
chore: improve performance of `checkEventsForErrors`
abdulmth Jul 19, 2024
5fa8bed
chore: improve if statement
abdulmth Jul 19, 2024
385f66a
fix: transaction result serialization
abdulmth Jul 22, 2024
f1eea0a
fix: asFailed
abdulmth Jul 22, 2024
8a9d808
Refactor `checkResult()` (#886)
abdulmth Jul 22, 2024
52e5f37
feat: generateKeypair helper
rflechtner Jul 18, 2024
035db97
refactor!: switch to using multikey encoding
rflechtner Jul 18, 2024
2c26b02
test: fix tests
rflechtner Jul 18, 2024
9f0819b
fix: add missing implementation on getSignersForKeypair
rflechtner Jul 22, 2024
b00ada1
test: use generateKeypair in did helpers integration tests
rflechtner Jul 22, 2024
e8c0654
Update packages/sdk-js/src/DidHelpers/checkResult.ts
abdulmth Jul 22, 2024
1762a29
chore: improvement
abdulmth Jul 22, 2024
975886d
feat: implement toJSON for root
abdulmth Jul 22, 2024
4b2718f
fix: lint
abdulmth Jul 22, 2024
f473255
chore: remove duplicated code
rflechtner Jul 22, 2024
8de9ded
fix: transaction result serialization (#888)
abdulmth Jul 23, 2024
fb44a82
chore: no magic numbers
rflechtner Jul 23, 2024
d69481d
docs: improve docstrings
rflechtner Jul 23, 2024
1bdf0d8
docs: streamline typings and add overload docstrings for en/decodeMul…
rflechtner Jul 23, 2024
57e6d8e
feat!: add generate keypair helper (#887)
abdulmth Jul 23, 2024
8b8c538
refactor!: align issuer/holder interfaces (#889)
rflechtner Jul 24, 2024
51e16da
fix: unsigned submittable (#890)
abdulmth Jul 24, 2024
a25c05a
fix: can't import utils in types
rflechtner Jul 24, 2024
465e54b
fix: bundle tests
rflechtner Jul 24, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
"typedoc": "^0.24.8",
"typescript": "^4.8.3"
},
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"packageManager": "yarn@4.1.1"
}
2 changes: 1 addition & 1 deletion packages/asset-credentials/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/asset-credentials",
"version": "0.100.0-alpha.1",
"version": "0.100.0-alpha.2",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/chain-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/chain-helpers",
"version": "0.100.0-alpha.1",
"version": "0.100.0-alpha.2",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
44 changes: 27 additions & 17 deletions packages/chain-helpers/src/blockchain/Blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@
* found in the LICENSE file in the root directory of this source tree.
*/

import type { ApiPromise } from '@polkadot/api'
import { ApiPromise, SubmittableResult } from '@polkadot/api'
import type { TxWithEvent } from '@polkadot/api-derive/types'
import type { Vec } from '@polkadot/types'
import type { Call, Extrinsic } from '@polkadot/types/interfaces'
import type { AnyNumber, IMethod } from '@polkadot/types/types'
import type { BN } from '@polkadot/util'

// eslint-disable-next-line @typescript-eslint/no-unused-vars -- doing this instead of import '@kiltprotocol/augment-api' to avoid creating an import at runtime
import type * as _ from '@kiltprotocol/augment-api'
import type {
ISubmittableResult,
KeyringPair,
KiltAddress,
SignerInterface,
SubmittableExtrinsic,
SubscriptionPromise,
TransactionSigner,
} from '@kiltprotocol/types'

import { SubmittableResult } from '@polkadot/api'

import { ConfigService } from '@kiltprotocol/config'
import { SDKErrors, Signers } from '@kiltprotocol/utils'

Expand Down Expand Up @@ -170,10 +167,29 @@ export async function submitSignedTx(

export const dispatchTx = submitSignedTx

export type TransactionSigner = SignerInterface<
'Ecrecover-Secp256k1-Blake2b' | 'Sr25519' | 'Ed25519',
KiltAddress
>
/**
* Signs a SubmittableExtrinsic.
*
* @param tx An unsigned SubmittableExtrinsic.
* @param signer The {@link KeyringPair} used to sign the tx.
* @param opts Additional options.
* @param opts.tip Optional amount of Femto-KILT to tip the validator.
* @returns A signed {@link SubmittableExtrinsic}.
*/
export async function signTx(
tx: SubmittableExtrinsic,
signer: KeyringPair | TransactionSigner,
{ tip }: { tip?: AnyNumber } = {}
): Promise<SubmittableExtrinsic> {
if ('address' in signer) {
return tx.signAsync(signer, { tip })
}

return tx.signAsync(signer.id, {
tip,
signer: Signers.getPolkadotSigner([signer]),
})
}

/**
* Signs and submits the SubmittableExtrinsic with optional resolution and rejection criteria.
Expand All @@ -192,13 +208,7 @@ export async function signAndSubmitTx(
...opts
}: Partial<SubscriptionPromise.Options> & Partial<{ tip: AnyNumber }> = {}
): Promise<ISubmittableResult> {
const signedTx =
'address' in signer
? await tx.signAsync(signer, { tip })
: await tx.signAsync(signer.id, {
tip,
signer: Signers.getPolkadotSigner([signer]),
})
const signedTx = await signTx(tx, signer, { tip })
return submitSignedTx(signedTx, opts)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/config",
"version": "0.100.0-alpha.1",
"version": "0.100.0-alpha.2",
"description": "",
"type": "commonjs",
"main": "./lib/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/credentials/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kiltprotocol/credentials",
"version": "0.100.0-alpha.1",
"version": "0.100.0-alpha.2",
"description": "",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down Expand Up @@ -41,10 +41,10 @@
"@kiltprotocol/chain-helpers": "workspace:*",
"@kiltprotocol/config": "workspace:*",
"@kiltprotocol/did": "workspace:*",
"@kiltprotocol/eddsa-jcs-2022": "0.1.0-rc.3",
"@kiltprotocol/es256k-jcs-2023": "0.1.0-rc.3",
"@kiltprotocol/jcs-data-integrity-proofs-common": "0.1.0-rc.3",
"@kiltprotocol/sr25519-jcs-2023": "0.1.0-rc.3",
"@kiltprotocol/eddsa-jcs-2022": "0.1.0-rc.4",
"@kiltprotocol/es256k-jcs-2023": "0.1.0-rc.4",
"@kiltprotocol/jcs-data-integrity-proofs-common": "0.1.0-rc.4",
"@kiltprotocol/sr25519-jcs-2023": "0.1.0-rc.4",
"@kiltprotocol/types": "workspace:*",
"@kiltprotocol/utils": "workspace:*",
"@polkadot/api": "^12.0.0",
Expand Down
Loading