Skip to content
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

sdk update v1.8.0 #191

Merged
merged 4 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 26 additions & 16 deletions demo/src/func-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ function getChallenge(): string {
}

async function main() {
const networkAddress = process.env.NETWORK_ADDRESS ? process.env.NETWORK_ADDRESS : 'ws://127.0.0.1:9944';
const networkAddress = process.env.NETWORK_ADDRESS
? process.env.NETWORK_ADDRESS
: 'ws://127.0.0.1:9944'
// const networkAddress = 'ws://127.0.0.1:9944'
Cord.ConfigService.set({ submitTxResolveOn: Cord.Chain.IS_IN_BLOCK })
await Cord.connect(networkAddress)
Expand Down Expand Up @@ -59,26 +61,26 @@ async function main() {

/* Creating the DIDs for the different parties involved in the demo. */
// Create Verifier DID
const { mnemonic: verifierMnemonic, document: verifierDid } = await createDid(
authorIdentity
const { mnemonic: verifierMnemonic, document: verifierDid } =
await createDid(authorIdentity)
const verifierKeys = Cord.Utils.Keys.generateKeypairs(
verifierMnemonic,
'sr25519'
)
const verifierKeys = Cord.Utils.Keys.generateKeypairs(verifierMnemonic)
console.log(
`🏢 Verifier (${verifierDid.assertionMethod![0].type}): ${verifierDid.uri}`
)
// Create Holder DID
const { mnemonic: holderMnemonic, document: holderDid } = await createDid(
authorIdentity
)
const holderKeys = Cord.Utils.Keys.generateKeypairs(holderMnemonic)
const { mnemonic: holderMnemonic, document: holderDid } =
await createDid(authorIdentity)
const holderKeys = Cord.Utils.Keys.generateKeypairs(holderMnemonic, 'sr25519')
console.log(
`👩‍⚕️ Holder (${holderDid.assertionMethod![0].type}): ${holderDid.uri}`
)
// Create issuer DID
const { mnemonic: issuerMnemonic, document: issuerDid } = await createDid(
authorIdentity
)
const issuerKeys = Cord.Utils.Keys.generateKeypairs(issuerMnemonic)
const { mnemonic: issuerMnemonic, document: issuerDid } =
await createDid(authorIdentity)
const issuerKeys = Cord.Utils.Keys.generateKeypairs(issuerMnemonic, 'sr25519')
console.log(
`🏛 Issuer (${issuerDid?.assertionMethod![0].type}): ${issuerDid.uri}`
)
Expand All @@ -93,7 +95,10 @@ async function main() {
// Create Delegate One DID
const { mnemonic: delegateOneMnemonic, document: delegateOneDid } =
await createDid(authorIdentity)
const delegateOneKeys = Cord.Utils.Keys.generateKeypairs(delegateOneMnemonic)
const delegateOneKeys = Cord.Utils.Keys.generateKeypairs(
delegateOneMnemonic,
'sr25519'
)
console.log(
`🏛 Delegate (${delegateOneDid?.assertionMethod![0].type}): ${
delegateOneDid.uri
Expand All @@ -102,7 +107,10 @@ async function main() {
// Create Delegate Two DID
const { mnemonic: delegateTwoMnemonic, document: delegateTwoDid } =
await createDid(authorIdentity)
const delegateTwoKeys = Cord.Utils.Keys.generateKeypairs(delegateTwoMnemonic)
const delegateTwoKeys = Cord.Utils.Keys.generateKeypairs(
delegateTwoMnemonic,
'sr25519'
)
console.log(
`🏛 Delegate (${delegateTwoDid?.assertionMethod![0].type}): ${
delegateTwoDid.uri
Expand All @@ -111,7 +119,10 @@ async function main() {
// Create Delegate 3 DID
const { mnemonic: delegate3Mnemonic, document: delegate3Did } =
await createDid(authorIdentity)
const delegate3Keys = Cord.Utils.Keys.generateKeypairs(delegate3Mnemonic)
const delegate3Keys = Cord.Utils.Keys.generateKeypairs(
delegate3Mnemonic,
'sr25519'
)
console.log(
`🏛 Delegate (${delegate3Did?.assertionMethod![0].type}): ${
delegate3Did.uri
Expand Down Expand Up @@ -206,7 +217,6 @@ async function main() {
)
console.log(`\n❄️ SubSpace limit is updated`)


// Step 4: Add Delelegate Two as Registry Delegate
console.log(`\n❄️ Space Delegate Authorization `)
const permission: Cord.PermissionType = Cord.Permission.ASSERT
Expand Down
2 changes: 1 addition & 1 deletion demo/src/utils/generateDid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function createDid(
keyAgreement,
assertionMethod,
capabilityDelegation,
} = Cord.Utils.Keys.generateKeypairs(mnemonic)
} = Cord.Utils.Keys.generateKeypairs(mnemonic, 'sr25519')
// Get tx that will create the DID on chain and DID-URI that can be used to resolve the DID Document.
const didCreationTx = await Cord.Did.getStoreTx(
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@commitlint/config-conventional": "^9.1.2",
"@playwright/test": "^1.41.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.6",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.56.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/augment-api/metadata/cord.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions packages/augment-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.9.3-1rc4",
"description": "",
"types": "./lib/index.d.ts",
"type": "module",
"main": "./index.cjs",
"exports": {
".": {
Expand Down Expand Up @@ -40,9 +39,9 @@
"bugs": "https://github.com/dhiway/cord.js/issues",
"homepage": "https://github.com/dhiway/cord.js#readme",
"devDependencies": {
"@polkadot/api": "^10.11.2",
"@polkadot/typegen": "^10.11.2",
"@types/node": "^20.11.17",
"@polkadot/api": "^10.12.2",
"@polkadot/typegen": "^10.12.2",
"@types/node": "^20.11.6",
"glob": "^7.1.1",
"rimraf": "^5.0.5",
"tsx": "^4.7.0",
Expand All @@ -51,8 +50,8 @@
},
"dependencies": {
"@cord.network/type-definitions": "workspace:*",
"@polkadot/rpc-augment": "^10.11.2",
"@polkadot/rpc-core": "^10.11.2",
"@polkadot/rpc-provider": "^10.11.2"
"@polkadot/rpc-augment": "^10.12.2",
"@polkadot/rpc-core": "^10.12.2",
"@polkadot/rpc-provider": "^10.12.2"
}
}
13 changes: 11 additions & 2 deletions packages/augment-api/src/interfaces/augment-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// this is required to allow for ambient/previous definitions
import '@polkadot/types/types/registry';

import type { RawDidLinkedInfo, RuntimeDispatchWeightInfo, RuntimeDispatchWeightInfoV1, RuntimeDispatchWeightInfoV2 } from '@cord.network/augment-api/extraDefs';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, F32, F64, I128, I16, I256, I32, I64, I8, ISize, Json, Null, OptionBool, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, f32, f64, i128, i16, i256, i32, i64, i8, isize, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { TAssetConversion } from '@polkadot/types/interfaces/assetConversion';
Expand All @@ -15,7 +16,7 @@ import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interface
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeGenesisConfiguration, BabeGenesisConfigurationV1, BabeWeight, Epoch, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, OpaqueKeyOwnershipProof, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import type { BeefyAuthoritySet, BeefyCommitment, BeefyEquivocationProof, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, BeefyVersionedFinalityProof, BeefyVoteMessage, MmrRootHash, ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BeefyAuthoritySet, BeefyCommitment, BeefyCompactSignedCommitment, BeefyEquivocationProof, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, BeefyVersionedFinalityProof, BeefyVoteMessage, MmrRootHash, ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BenchmarkBatch, BenchmarkConfig, BenchmarkList, BenchmarkMetadata, BenchmarkParameter, BenchmarkResult } from '@polkadot/types/interfaces/benchmark';
import type { CheckInherentsResult, InherentData, InherentIdentifier } from '@polkadot/types/interfaces/blockbuilder';
import type { BridgeMessageId, BridgedBlockHash, BridgedBlockNumber, BridgedHeader, CallOrigin, ChainId, DeliveredMessages, DispatchFeePayment, InboundLaneData, InboundRelayer, InitializationData, LaneId, MessageData, MessageKey, MessageNonce, MessagesDeliveryProofOf, MessagesProofOf, OperatingMode, OutboundLaneData, OutboundMessageFee, OutboundPayload, Parameter, RelayerId, UnrewardedRelayer, UnrewardedRelayersState } from '@polkadot/types/interfaces/bridges';
Expand All @@ -25,7 +26,7 @@ import type { StatementKind } from '@polkadot/types/interfaces/claims';
import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
import type { AliveContractInfo, CodeHash, CodeSource, CodeUploadRequest, CodeUploadResult, CodeUploadResultValue, ContractCallFlags, ContractCallRequest, ContractExecResult, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractExecResultTo267, ContractExecResultU64, ContractInfo, ContractInstantiateResult, ContractInstantiateResultTo267, ContractInstantiateResultTo299, ContractInstantiateResultU64, ContractReturnFlags, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateRequestV1, InstantiateRequestV2, InstantiateReturnValue, InstantiateReturnValueOk, InstantiateReturnValueTo267, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, StorageDeposit, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import type { ContractConstructorSpecLatest, ContractConstructorSpecV0, ContractConstructorSpecV1, ContractConstructorSpecV2, ContractConstructorSpecV3, ContractConstructorSpecV4, ContractContractSpecV0, ContractContractSpecV1, ContractContractSpecV2, ContractContractSpecV3, ContractContractSpecV4, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEnvironmentV4, ContractEventParamSpecLatest, ContractEventParamSpecV0, ContractEventParamSpecV2, ContractEventSpecLatest, ContractEventSpecV0, ContractEventSpecV1, ContractEventSpecV2, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpecLatest, ContractMessageParamSpecV0, ContractMessageParamSpecV2, ContractMessageSpecLatest, ContractMessageSpecV0, ContractMessageSpecV1, ContractMessageSpecV2, ContractMessageSpecV3, ContractMetadata, ContractMetadataLatest, ContractMetadataV0, ContractMetadataV1, ContractMetadataV2, ContractMetadataV3, ContractMetadataV4, ContractProject, ContractProjectContract, ContractProjectInfo, ContractProjectSource, ContractProjectV0, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
import type { ContractConstructorSpecLatest, ContractConstructorSpecV0, ContractConstructorSpecV1, ContractConstructorSpecV2, ContractConstructorSpecV3, ContractConstructorSpecV4, ContractContractSpecV0, ContractContractSpecV1, ContractContractSpecV2, ContractContractSpecV3, ContractContractSpecV4, ContractContractSpecV5, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEnvironmentV4, ContractEventParamSpecLatest, ContractEventParamSpecV0, ContractEventParamSpecV2, ContractEventSpecLatest, ContractEventSpecV0, ContractEventSpecV1, ContractEventSpecV2, ContractEventSpecV3, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpecLatest, ContractMessageParamSpecV0, ContractMessageParamSpecV2, ContractMessageSpecLatest, ContractMessageSpecV0, ContractMessageSpecV1, ContractMessageSpecV2, ContractMessageSpecV3, ContractMetadata, ContractMetadataLatest, ContractMetadataV0, ContractMetadataV1, ContractMetadataV2, ContractMetadataV3, ContractMetadataV4, ContractMetadataV5, ContractProject, ContractProjectContract, ContractProjectInfo, ContractProjectSource, ContractProjectV0, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
import type { FundIndex, FundInfo, LastContribution, TrieIndex } from '@polkadot/types/interfaces/crowdloan';
import type { CollationInfo, CollationInfoV1, ConfigData, MessageId, OverweightIndex, PageCounter, PageIndexData } from '@polkadot/types/interfaces/cumulus';
import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
Expand Down Expand Up @@ -153,6 +154,7 @@ declare module '@polkadot/types/types/registry' {
BalanceStatus: BalanceStatus;
BeefyAuthoritySet: BeefyAuthoritySet;
BeefyCommitment: BeefyCommitment;
BeefyCompactSignedCommitment: BeefyCompactSignedCommitment;
BeefyEquivocationProof: BeefyEquivocationProof;
BeefyId: BeefyId;
BeefyKey: BeefyKey;
Expand Down Expand Up @@ -261,6 +263,7 @@ declare module '@polkadot/types/types/registry' {
ContractContractSpecV2: ContractContractSpecV2;
ContractContractSpecV3: ContractContractSpecV3;
ContractContractSpecV4: ContractContractSpecV4;
ContractContractSpecV5: ContractContractSpecV5;
ContractCryptoHasher: ContractCryptoHasher;
ContractDiscriminant: ContractDiscriminant;
ContractDisplayName: ContractDisplayName;
Expand All @@ -272,6 +275,7 @@ declare module '@polkadot/types/types/registry' {
ContractEventSpecV0: ContractEventSpecV0;
ContractEventSpecV1: ContractEventSpecV1;
ContractEventSpecV2: ContractEventSpecV2;
ContractEventSpecV3: ContractEventSpecV3;
ContractExecResult: ContractExecResult;
ContractExecResultOk: ContractExecResultOk;
ContractExecResultResult: ContractExecResultResult;
Expand Down Expand Up @@ -309,6 +313,7 @@ declare module '@polkadot/types/types/registry' {
ContractMetadataV2: ContractMetadataV2;
ContractMetadataV3: ContractMetadataV3;
ContractMetadataV4: ContractMetadataV4;
ContractMetadataV5: ContractMetadataV5;
ContractProject: ContractProject;
ContractProjectContract: ContractProjectContract;
ContractProjectInfo: ContractProjectInfo;
Expand Down Expand Up @@ -858,6 +863,7 @@ declare module '@polkadot/types/types/registry' {
RawBabePreDigestSecondaryTo159: RawBabePreDigestSecondaryTo159;
RawBabePreDigestSecondaryVRF: RawBabePreDigestSecondaryVRF;
RawBabePreDigestTo159: RawBabePreDigestTo159;
RawDidLinkedInfo: RawDidLinkedInfo;
RawOrigin: RawOrigin;
RawSolution: RawSolution;
RawSolutionTo265: RawSolutionTo265;
Expand Down Expand Up @@ -917,6 +923,9 @@ declare module '@polkadot/types/types/registry' {
RuntimeDispatchInfo: RuntimeDispatchInfo;
RuntimeDispatchInfoV1: RuntimeDispatchInfoV1;
RuntimeDispatchInfoV2: RuntimeDispatchInfoV2;
RuntimeDispatchWeightInfo: RuntimeDispatchWeightInfo;
RuntimeDispatchWeightInfoV1: RuntimeDispatchWeightInfoV1;
RuntimeDispatchWeightInfoV2: RuntimeDispatchWeightInfoV2;
RuntimeEvent: RuntimeEvent;
RuntimeVersion: RuntimeVersion;
RuntimeVersionApi: RuntimeVersionApi;
Expand Down
4 changes: 3 additions & 1 deletion packages/augment-api/src/interfaces/extraDefs/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable */

import type { Definitions } from '@polkadot/types/types';

import {
types,
cordSignedExtensions as userExtensions,
Expand All @@ -17,4 +19,4 @@ export default {
signedExtensions: {
...userExtensions,
},
}
} as Definitions
2 changes: 0 additions & 2 deletions packages/augment-api/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"module": "ES6",
"outDir": "./lib",
"declaration": true,
"emitDeclarationOnly": true,
"skipLibCheck": true,
"noUnusedLocals": false,
"typeRoots": ["node_modules/@types", "node_modules/@polkadot"],
"paths": {
"@cord.network/augment-api/extraDefs": [
"./src/interfaces/extraDefs/index.ts"
Expand Down
8 changes: 5 additions & 3 deletions packages/config/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ export async function init<K extends Partial<ConfigService.configOpts>>(
*/
export async function connect(
blockchainRpcWsUrl: string,
{
...apiOpts
}: Omit<ApiOptions, 'provider'> = {}
{ noInitWarn = true, ...apiOptions }: Omit<ApiOptions, 'provider'> = {}
): Promise<ApiPromise> {
try {
const provider = new WsProvider(blockchainRpcWsUrl)
const apiOpts = {
noInitWarn,
...apiOptions,
}
const api = await ApiPromise.create({
provider,
typesBundle,
Expand Down
6 changes: 3 additions & 3 deletions packages/did/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"@cord.network/types": "workspace:*",
"@cord.network/utils": "workspace:*",
"@digitalbazaar/security-context": "^1.0.1",
"@polkadot/api": "^10.11.2",
"@polkadot/api": "^10.12.2",
"@polkadot/keyring": "^12.6.2",
"@polkadot/types": "^10.11.2",
"@polkadot/types-codec": "^10.11.2",
"@polkadot/types": "^10.12.2",
"@polkadot/types-codec": "^10.12.2",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@cord.network/config": "workspace:*",
"@cord.network/types": "workspace:*",
"@cord.network/utils": "workspace:*",
"@polkadot/api": "^10.11.2",
"@polkadot/types": "^10.11.2"
"@polkadot/api": "^10.12.2",
"@polkadot/types": "^10.12.2"
}
}
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"repository": "github:dhiway/cord-js",
"engines": {
"node": ">=18.0"
"node": ">=20.0"
},
"author": "",
"bugs": "https://github.com/dhiway/cord.js/issues",
Expand Down
2 changes: 1 addition & 1 deletion packages/type-definitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"bugs": "https://github.com/dhiway/cord.js/issues",
"homepage": "https://github.com/dhiway/cord.js#readme",
"dependencies": {
"@polkadot/types": "^10.11.2"
"@polkadot/types": "^10.12.2"
},
"devDependencies": {
"rimraf": "^5.0.5",
Expand Down
Loading