diff --git a/examples/wallet/src/CreateAccount.tsx b/examples/wallet/src/CreateAccount.tsx index 11694adb4..30201b4cc 100644 --- a/examples/wallet/src/CreateAccount.tsx +++ b/examples/wallet/src/CreateAccount.tsx @@ -1,5 +1,5 @@ import { - CredentialDeploymentTransaction, + CredentialDeploymentPayload, CredentialInputNoSeed, IdentityObjectV1, getAccountAddress, @@ -43,7 +43,7 @@ export function CreateAccount({ identity }: { identity: IdentityObjectV1 }) { return; } - const listener = (worker.onmessage = async (e: MessageEvent) => { + const listener = (worker.onmessage = async (e: MessageEvent) => { worker.removeEventListener('message', listener); const credentialDeploymentTransaction = e.data; const signingKey = getAccountSigningKey(seedPhrase, credentialDeploymentTransaction.unsignedCdi.ipIdentity); diff --git a/examples/wallet/src/account-worker.ts b/examples/wallet/src/account-worker.ts index c0efda708..47dddc3ca 100644 --- a/examples/wallet/src/account-worker.ts +++ b/examples/wallet/src/account-worker.ts @@ -1,8 +1,8 @@ -import { createCredentialTransactionNoSeed } from '@concordium/web-sdk'; +import { createCredentialPayloadNoSeed } from '@concordium/web-sdk'; import { AccountWorkerInput } from './types'; self.onmessage = (e: MessageEvent) => { - const credentialTransaction = createCredentialTransactionNoSeed(e.data.credentialInput, e.data.expiry); + const credentialTransaction = createCredentialPayloadNoSeed(e.data.credentialInput, e.data.expiry); self.postMessage(credentialTransaction); }; diff --git a/examples/wallet/src/util.ts b/examples/wallet/src/util.ts index 8ec30039e..a9a8d05a5 100644 --- a/examples/wallet/src/util.ts +++ b/examples/wallet/src/util.ts @@ -9,7 +9,7 @@ import { CcdAmount, ConcordiumGRPCWebClient, ConcordiumHdWallet, - CredentialDeploymentTransaction, + CredentialDeploymentPayload, CryptographicParameters, IdObjectRequestV1, IdRecoveryRequest, @@ -234,7 +234,7 @@ export function createCredentialDeploymentKeysAndRandomness( * @returns a promise with the transaction hash of the submitted credential deployment */ export async function sendCredentialDeploymentTransaction( - credentialDeployment: CredentialDeploymentTransaction, + credentialDeployment: CredentialDeploymentPayload, signature: string ) { const payload = serializeCredentialDeploymentPayload([signature], credentialDeployment); diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index b1cd14612..e58fd5546 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -17,6 +17,10 @@ - Renamed `TokenModuleRejectReason` to `EncodedTokenModuleRejectReason`, aligning with the corresponding types for `TokenModuleEvent`. `TokenModuleRejectReason` now describes the decoded version of `EncodedTokenModuleRejectReason`. - `parseTokenModuleEvent` (previously `parseModuleEvent`) now returns `TokenModuleEvent | UnknownTokenModuleEvent` +- Rename `CredentialDeploymentTransaction` to `CredentialDeploymentPayload`, and correspondingly + - `createCredentialDeploymentTransaction` -> `createCredentialDeploymentPayload` + - `createCredentialTransaction` -> `createCredentialPayload` + - `createCredentialTransactionNoSeed` -> `createCredentialPayloadNoSeed` #### GRPC API query response types @@ -40,6 +44,9 @@ - Affects `InvokeContractResultSuccess` - Affects `UpdateContractSummary` - `ContractVersion` enum has been removed and replaced with `number` where it was used. +- `VerifyKey` uses has now been wrapped in `Upward`, affecting the types + - `CredentialPublicKeys`, bleeding into top-level types `CredentialDeploymentInfo`, `InitialAccountCredential` and + `NormalAccountCredential` #### `ConcordiumGRPCClient`: diff --git a/packages/sdk/src/accountTransactions.ts b/packages/sdk/src/accountTransactions.ts index 2b43ac881..fb5d33b96 100644 --- a/packages/sdk/src/accountTransactions.ts +++ b/packages/sdk/src/accountTransactions.ts @@ -56,6 +56,7 @@ export interface AccountTransactionHandler< * * @param payload - The payload to serialize. * @returns The serialized payload. + * @throws If serializing the type was not possible. */ serialize: (payload: PayloadType) => Buffer; @@ -63,6 +64,7 @@ export interface AccountTransactionHandler< * Deserializes the serialized payload into the payload type. * @param serializedPayload - The serialized payload to be deserialized. * @returns The deserialized payload. + * @throws If deserializing the type was not possible. */ deserialize: (serializedPayload: Cursor) => PayloadType; diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index 0a49f1152..c052f9724 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -70,14 +70,15 @@ function trCommits(cmm: GRPC.CredentialCommitments): SDK.CredentialDeploymentCom }; } -function trVerifyKey(verifyKey: GRPC.AccountVerifyKey): SDK.VerifyKey { - if (verifyKey.key.oneofKind === 'ed25519Key') { - return { - schemeId: 'Ed25519', - verifyKey: unwrapToHex(verifyKey.key.ed25519Key), - }; - } else { - throw Error('AccountVerifyKey was expected to be of type "ed25519Key", but found' + verifyKey.key.oneofKind); +function trVerifyKey(verifyKey: GRPC.AccountVerifyKey): Upward { + switch (verifyKey.key.oneofKind) { + case 'ed25519Key': + return { + schemeId: 'Ed25519', + verifyKey: unwrapToHex(verifyKey.key.ed25519Key), + }; + case undefined: + return null; } } @@ -1610,9 +1611,8 @@ function trCommissionRange(range: GRPC.InclusiveRangeAmountFraction | undefined) max: trAmountFraction(range?.max), }; } -function trUpdatePublicKey(key: GRPC.UpdatePublicKey): SDK.VerifyKey { +function trUpdatePublicKey(key: GRPC.UpdatePublicKey): SDK.UpdatePublicKey { return { - schemeId: 'Ed25519', verifyKey: unwrapValToHex(key), }; } diff --git a/packages/sdk/src/grpc/upward.ts b/packages/sdk/src/grpc/upward.ts index 5793aa0bb..4341c17ec 100644 --- a/packages/sdk/src/grpc/upward.ts +++ b/packages/sdk/src/grpc/upward.ts @@ -1,15 +1,17 @@ import { bail } from '../util.js'; +export type Unknown = null; + /** * Represents types returned by the GRPC API of a Concordium node which are - * possibly unknown to the SDK version. `null` means that the type is unknown. + * possibly unknown to the SDK version. {@linkcode Unknown} means that the type is unknown. * * @template T - The type representing the known variants * * @example * // fail on unknown value * const upwardValue: Upward = ... - * if (upwardValue === null) { + * if (!isKnown(upwardValue)) { * throw new Error('Uncountered unknown value') * } * // the value is known from this point @@ -17,20 +19,40 @@ import { bail } from '../util.js'; * @example * // gracefully handle unknown values * const upwardValue: Upward = ... - * if (upwardValue === null) { + * if (!isKnown(upwardValue)) { * console.warn('Uncountered unknown value') * } else { * // the value is known from this point * } */ -export type Upward = T | null; +export type Upward = T | Unknown; + +// Recursively remove all occurrences of `null` (or `Unknown`) from a type. Since `null` is only +// used via the Upward sentinel (and never intentionally in other field types), +// this yields a type appropriate for constructing outbound payloads where all +// values must be known. +export type Known = T extends Unknown + ? never + : T extends Function + ? T + : T extends Map + ? Map, Known> + : T extends Set + ? Set> + : T extends readonly (infer U)[] + ? T extends readonly [any, ...any[]] + ? { [I in keyof T]: Known } + : Known[] + : T extends object + ? { [P in keyof T]: Known } + : T; /** * Type guard that checks whether an Upward holds a known value. * * @template T - The type representing the known variants - * @param value - The possibly-unknown value returned from gRPC. - * @returns True if value is not null (i.e., is T). + * @param value - The possibly {@linkcode Unknown} value returned from gRPC. + * @returns True if value is not {@linkcode Unknown} (i.e., is T). */ export function isKnown(value: Upward): value is T { return value !== null; @@ -39,10 +61,10 @@ export function isKnown(value: Upward): value is T { /** * Asserts that an Upward is known, otherwise throws the provided error. * - * Useful when unknowns should be treated as hard failures. + * Useful when {@linkcode Unknown} values should be treated as hard failures. * * @template T - The type representing the known variants - * @param value - The possibly-unknown value returned from gRPC. + * @param value - The possibly {@linkcode Unknown} value returned from gRPC. * @param error - Error to throw if value is unknown. * @returns True as a type predicate when value is known. */ @@ -54,7 +76,7 @@ export function assertKnown(value: Upward, error: Error | string): value i * Returns the known value or throws the provided error when unknown. * * @template T - The type representing the known variants - * @param value - The possibly-unknown value returned from gRPC. + * @param value - The possibly {@linkcode Unknown} value returned from gRPC. * @param error - Error to throw if value is unknown. * @returns The unwrapped known value of type T. */ diff --git a/packages/sdk/src/serialization.ts b/packages/sdk/src/serialization.ts index 2b3051907..48cd336db 100644 --- a/packages/sdk/src/serialization.ts +++ b/packages/sdk/src/serialization.ts @@ -2,6 +2,7 @@ import { Buffer } from 'buffer/index.js'; import { getAccountTransactionHandler } from './accountTransactions.js'; import { calculateEnergyCost } from './energyCost.js'; +import { Known, isKnown } from './grpc/upward.js'; import { sha256 } from './hash.js'; import { encodeWord8, @@ -195,9 +196,18 @@ export function serializeAccountTransactionForSubmission( * @returns the serialization of CredentialDeploymentValues */ function serializeCredentialDeploymentValues(credential: CredentialDeploymentValues) { + // Check that we don't attempt to serialize unknown variants + if (Object.values(credential.credentialPublicKeys.keys).some((v) => !isKnown(v))) + throw new Error('Cannot serialize unknown key variants'); + const buffers = []; buffers.push( - serializeMap(credential.credentialPublicKeys.keys, encodeWord8, encodeWord8FromString, serializeVerifyKey) + serializeMap( + credential.credentialPublicKeys.keys as Known, + encodeWord8, + encodeWord8FromString, + serializeVerifyKey + ) ); buffers.push(encodeWord8(credential.credentialPublicKeys.threshold)); diff --git a/packages/sdk/src/signHelpers.ts b/packages/sdk/src/signHelpers.ts index 75a523555..8874704c6 100644 --- a/packages/sdk/src/signHelpers.ts +++ b/packages/sdk/src/signHelpers.ts @@ -307,16 +307,17 @@ export async function verifyMessageSignature( } for (const keyIndex of Object.keys(credentialSignature)) { - if (!credentialKeys.keys[Number(keyIndex)]) { - throw new Error('Signature contains signature for non-existing keyIndex'); + const key = credentialKeys.keys[Number(keyIndex)]; + switch (key) { + case undefined: + throw new Error('Signature contains signature for non-existing keyIndex'); + case null: + throw new Error('Found "null" (represents unknown key variants) in credential keys'); + default: + break; } - if ( - !(await ed.verifyAsync( - credentialSignature[Number(keyIndex)], - digest, - credentialKeys.keys[Number(keyIndex)].verifyKey - )) - ) { + + if (!(await ed.verifyAsync(credentialSignature[Number(keyIndex)], digest, key.verifyKey))) { // Incorrect signature; return false; } diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 7ce0332cc..5daf63dbe 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1,7 +1,7 @@ /** * @module Common GRPC-Client */ -import type { Upward } from './grpc/index.js'; +import type { Known, Upward } from './grpc/index.js'; import type { Cbor, TokenId } from './plt/index.js'; import type { TokenAccountInfo } from './plt/types.js'; import type * as AccountAddress from './types/AccountAddress.js'; @@ -515,7 +515,8 @@ interface AuthorizationsCommon { electionDifficulty: Authorization; addAnonymityRevoker: Authorization; addIdentityProvider: Authorization; - keys: VerifyKey[]; + /** The authorization keys. */ + keys: UpdatePublicKey[]; } /** @@ -539,7 +540,8 @@ export interface AuthorizationsV1 extends AuthorizationsCommon { export type Authorizations = AuthorizationsV0 | AuthorizationsV1; export interface KeysWithThreshold { - keys: VerifyKey[]; + /** The authorization keys. */ + keys: UpdatePublicKey[]; threshold: number; } @@ -797,8 +799,25 @@ export interface VerifyKey { verifyKey: HexString; } +/** + * Represents a public key used for chain updates. + */ +export type UpdatePublicKey = { + /** The key in hex format */ + verifyKey: HexString; +}; + export interface CredentialPublicKeys { - keys: Record; + /** + * keys for the credential + * + * **Please note**, these can possibly be unknown if the SDK is not fully compatible with the Concordium + * node queried, in which case `null` is returned. + * + * In case this is used as part of a transaction sent to the node, none of the values contained can be `null`, + * as this will cause the transation to fail. + */ + keys: Record>; threshold: number; } @@ -1183,7 +1202,7 @@ export interface AccountInfoUnknown extends AccountInfoCommon { /** * This will only ever be `null`, which represents a variant of staking info for the account which is * unknown to the SDK, for known staking variants this is represented by either {@linkcode AccountInfoBaker} - * or {@linkcode AccountInfoDElegator}. + * or {@linkcode AccountInfoDelegator}. * * **Note**: This field is named `accountBaker` to align with the JSON representation produced by the * corresponding rust SDK. @@ -1667,11 +1686,10 @@ interface CdiRandomness { randomness: CommitmentsRandomness; } -// TODO Should we rename this, As it is not actually the transaction that is sent to the node. (Note that this would be a breaking change) -export type CredentialDeploymentTransaction = CredentialDeploymentDetails & CdiRandomness; +export type CredentialDeploymentPayload = CredentialDeploymentDetails & CdiRandomness; /** Internal type used when building credentials */ export type UnsignedCdiWithRandomness = { - unsignedCdi: UnsignedCredentialDeploymentInformation; + unsignedCdi: Known; } & CdiRandomness; export interface CredentialDeploymentInfo extends CredentialDeploymentValues { diff --git a/packages/sdk/src/types/VersionedModuleSource.ts b/packages/sdk/src/types/VersionedModuleSource.ts index 19b4a41f4..09b14d7e3 100644 --- a/packages/sdk/src/types/VersionedModuleSource.ts +++ b/packages/sdk/src/types/VersionedModuleSource.ts @@ -96,9 +96,9 @@ export async function parseModuleInterface(moduleSource: VersionedModuleSource): } /** - * Extract the embedded smart contract schema bytes. Returns `null` if no schema is embedded. + * Extract the embedded smart contract schema bytes. Returns `undefined` if no schema is embedded. * @param {VersionedModuleSource} moduleSource The smart contract module source. - * @returns {RawModuleSchema | null} The raw module schema if found. + * @returns {RawModuleSchema | undefined} The raw module schema if found. * @throws If the module source cannot be parsed or contains duplicate schema sections. */ export async function getEmbeddedModuleSchema({ diff --git a/packages/sdk/src/types/chainUpdate.ts b/packages/sdk/src/types/chainUpdate.ts index 055f377cc..f38840991 100644 --- a/packages/sdk/src/types/chainUpdate.ts +++ b/packages/sdk/src/types/chainUpdate.ts @@ -16,8 +16,8 @@ import type { MintRate, TimeoutParameters, TransactionFeeDistribution, + UpdatePublicKey, ValidatorScoreParameters, - VerifyKey, } from '../types.js'; import type * as CcdAmount from './CcdAmount.js'; import type * as Duration from './Duration.js'; @@ -250,7 +250,7 @@ export enum KeyUpdateEntryStatus { } export interface KeyWithStatus { - key: VerifyKey; + key: UpdatePublicKey; status: KeyUpdateEntryStatus; } @@ -261,7 +261,13 @@ export enum HigherLevelKeyUpdateType { export interface HigherLevelKeyUpdate { typeOfUpdate: HigherLevelKeyUpdateType; - updateKeys: VerifyKey[]; + /** + * The authorization keys included in the update. + */ + updateKeys: UpdatePublicKey[]; + /** + * The key threshold needed to perform the update to higher level keys. + */ threshold: number; } diff --git a/packages/sdk/src/wasm/credentialDeploymentTransactions.ts b/packages/sdk/src/wasm/credentialDeploymentTransactions.ts index 8bad1496c..cbf83fe15 100644 --- a/packages/sdk/src/wasm/credentialDeploymentTransactions.ts +++ b/packages/sdk/src/wasm/credentialDeploymentTransactions.ts @@ -4,6 +4,7 @@ import * as wasm from '@concordium/rust-bindings/wallet'; import * as ed from '@concordium/web-sdk/shims/ed25519'; import { Buffer } from 'buffer/index.js'; +import { Known } from '../grpc/upward.js'; import { sha256 } from '../hash.js'; import { getCredentialDeploymentSignDigest } from '../serialization.js'; import { @@ -12,7 +13,7 @@ import { AttributesKeys, CredentialDeploymentDetails, CredentialDeploymentInfo, - CredentialDeploymentTransaction, + CredentialDeploymentPayload, CredentialPublicKeys, CryptographicParameters, HexString, @@ -84,9 +85,9 @@ function createUnsignedCredentialInfo( } /** - * Create a credential deployment transaction, which is the transaction used - * when deploying a new account. - * @deprecated This function doesn't use allow supplying the randomness. {@link createCredentialTransaction} or {@link createCredentialTransactionNoSeed} should be used instead. + * Create a credential deployment transaction payload used when deploying a new account. + * + * @deprecated This function doesn't use allow supplying the randomness. {@link createCredentialPayload} or {@link createCredentialPayloadNoSeed} should be used instead. * @param identity the identity to create a credential for * @param cryptographicParameters the global cryptographic parameters from the chain * @param threshold the signature threshold for the credential, has to be less than number of public keys @@ -96,7 +97,7 @@ function createUnsignedCredentialInfo( * @param expiry the expiry of the transaction * @returns the details used in a credential deployment transaction */ -export function createCredentialDeploymentTransaction( +export function createCredentialDeploymentPayload( identity: IdentityInput, cryptographicParameters: CryptographicParameters, threshold: number, @@ -104,7 +105,7 @@ export function createCredentialDeploymentTransaction( credentialIndex: number, revealedAttributes: AttributeKey[], expiry: TransactionExpiry.Type -): CredentialDeploymentTransaction { +): CredentialDeploymentPayload { const unsignedCredentialInfo = createUnsignedCredentialInfo( identity, cryptographicParameters, @@ -200,17 +201,17 @@ export type CredentialInputNoSeed = CredentialInputCommon & { idCredSec: HexString; prfKey: HexString; sigRetrievelRandomness: HexString; - credentialPublicKeys: CredentialPublicKeys; + credentialPublicKeys: Known; attributeRandomness: Record; }; /** * Creates an unsigned credential for a new account, using the version 1 algorithm, which uses a seed to generate keys and commitments. */ -export function createCredentialTransaction( +export function createCredentialPayload( input: CredentialInput, expiry: TransactionExpiry.Type -): CredentialDeploymentTransaction { +): CredentialDeploymentPayload { const wallet = ConcordiumHdWallet.fromHex(input.seedAsHex, input.net); const publicKey = wallet .getAccountPublicKey(input.ipInfo.ipIdentity, input.identityIndex, input.credNumber) @@ -253,16 +254,16 @@ export function createCredentialTransaction( credNumber: input.credNumber, }; - return createCredentialTransactionNoSeed(noSeedInput, expiry); + return createCredentialPayloadNoSeed(noSeedInput, expiry); } /** * Creates an unsigned credential for a new account, using the version 1 algorithm, but without requiring the seed to be provided directly. */ -export function createCredentialTransactionNoSeed( +export function createCredentialPayloadNoSeed( input: CredentialInputNoSeed, expiry: TransactionExpiry.Type -): CredentialDeploymentTransaction { +): CredentialDeploymentPayload { const { sigRetrievelRandomness, ...other } = input; const internalInput = { ...other, diff --git a/packages/sdk/src/wasm/serialization.ts b/packages/sdk/src/wasm/serialization.ts index 83be602c6..69b5a97cd 100644 --- a/packages/sdk/src/wasm/serialization.ts +++ b/packages/sdk/src/wasm/serialization.ts @@ -2,7 +2,7 @@ import * as wasm from '@concordium/rust-bindings/wallet'; import { Buffer } from 'buffer/index.js'; import JSONbig from 'json-bigint'; -import type { CredentialDeploymentDetails, CredentialDeploymentTransaction } from '../types.js'; +import type { CredentialDeploymentDetails, CredentialDeploymentPayload } from '../types.js'; interface DeploymentDetailsResult { credInfo: string; @@ -54,7 +54,7 @@ export function serializeCredentialDeploymentTransactionForSubmission( export function serializeCredentialDeploymentPayload( signatures: string[], - credentialDeploymentTransaction: CredentialDeploymentTransaction + credentialDeploymentTransaction: CredentialDeploymentPayload ): Buffer { const payloadByteArray = wasm.serializeCredentialDeploymentPayload( signatures, diff --git a/packages/sdk/test/ci/credentialDeployment.test.ts b/packages/sdk/test/ci/credentialDeployment.test.ts index 5c673732a..352a090b8 100644 --- a/packages/sdk/test/ci/credentialDeployment.test.ts +++ b/packages/sdk/test/ci/credentialDeployment.test.ts @@ -8,16 +8,16 @@ import { getCredentialDeploymentSignDigest } from '../../src/serialization.js'; import { AttributeKey, BlockItemKind, - CredentialDeploymentTransaction, + CredentialDeploymentPayload, IdentityInput, IdentityObjectV1, VerifyKey, } from '../../src/types.js'; import { CredentialInput, - createCredentialDeploymentTransaction, - createCredentialTransaction, - createCredentialTransactionNoSeed, + createCredentialDeploymentPayload, + createCredentialPayload, + createCredentialPayloadNoSeed, } from '../../src/wasm/credentialDeploymentTransactions.js'; import { deserializeTransaction } from '../../src/wasm/deserialization.js'; import { serializeCredentialDeploymentTransactionForSubmission } from '../../src/wasm/serialization.js'; @@ -46,7 +46,7 @@ function createCredentialInput(revealedAttributes: AttributeKey[], idObject: Ide // This test was generated on an older version of the SDK to verify that the serialization remains the same. test('Test serialize v0 credential transaction', async () => { - const tx: CredentialDeploymentTransaction = JSON.parse(fs.readFileSync('./test/ci/resources/cdt.json').toString()); + const tx: CredentialDeploymentPayload = JSON.parse(fs.readFileSync('./test/ci/resources/cdt.json').toString()); tx.expiry = TransactionExpiry.fromEpochSeconds(tx.expiry as unknown as number); // convert JSON `TransactionExpiry`. const hashToSign = getCredentialDeploymentSignDigest(tx); @@ -91,7 +91,7 @@ test('test create + deserialize v0 credentialDeployment', async () => { const revealedAttributes: AttributeKey[] = ['firstName', 'nationality']; const expiry = TransactionExpiry.futureMinutes(60); - const credentialDeploymentTransaction: CredentialDeploymentTransaction = createCredentialDeploymentTransaction( + const credentialDeploymentTransaction: CredentialDeploymentPayload = createCredentialDeploymentPayload( identityInput, cryptographicParameters, threshold, @@ -135,7 +135,7 @@ test('Test createCredentialTransaction', () => { const revealedAttributes: AttributeKey[] = ['firstName']; const idObject = JSON.parse(fs.readFileSync('./test/ci/resources/identity-object.json').toString()).value; - const output = createCredentialTransaction( + const output = createCredentialPayload( createCredentialInput(revealedAttributes, idObject), TransactionExpiry.fromEpochSeconds(expiry) ); @@ -144,7 +144,7 @@ test('Test createCredentialTransaction', () => { expect(cdi.credId).toEqual( 'b317d3fea7de56f8c96f6e72820c5cd502cc0eef8454016ee548913255897c6b52156cc60df965d3efb3f160eff6ced4' ); - expect(cdi.credentialPublicKeys.keys[0].verifyKey).toEqual( + expect(cdi.credentialPublicKeys.keys[0]!.verifyKey).toEqual( '29723ec9a0b4ca16d5d548b676a1a0adbecdedc5446894151acb7699293d69b1' ); expect(cdi.credentialPublicKeys.threshold).toEqual(1); @@ -175,13 +175,13 @@ test('Test createCredentialTransactionNoSeed lastname with special characters', const input = JSON.parse(fs.readFileSync('./test/ci/resources/credential-input-no-seed.json').toString()); const expiry = 1722939941n; - const output = createCredentialTransactionNoSeed(input, TransactionExpiry.fromEpochSeconds(expiry)); + const output = createCredentialPayloadNoSeed(input, TransactionExpiry.fromEpochSeconds(expiry)); const cdi = output.unsignedCdi; expect(cdi.credId).toEqual( '930e1e148d2a08b14ed3b5569d4768c96dbea5f540822ee38a6c52ca6c172be408ca4b78d6e2956cfad157bd02804c2c' ); - expect(cdi.credentialPublicKeys.keys[0].verifyKey).toEqual( + expect(cdi.credentialPublicKeys.keys[0]!.verifyKey).toEqual( '3522291ef370e89424a2ed8a9e440963a783aec4e34377192360f763e1671d77' ); expect(cdi.credentialPublicKeys.threshold).toEqual(1); diff --git a/packages/sdk/test/client/clientV2.test.ts b/packages/sdk/test/client/clientV2.test.ts index 2522c49ca..a6cbf33dc 100644 --- a/packages/sdk/test/client/clientV2.test.ts +++ b/packages/sdk/test/client/clientV2.test.ts @@ -9,7 +9,7 @@ import { BlockHash, buildBasicAccountSigner, calculateEnergyCost, - createCredentialDeploymentTransaction, + createCredentialDeploymentPayload, getAccountTransactionHandler, getCredentialDeploymentSignDigest, serializeAccountTransaction, @@ -351,7 +351,7 @@ test.each(clients)('createAccount', async (client) => { }, ]; - const credentialDeploymentTransaction: v1.CredentialDeploymentTransaction = createCredentialDeploymentTransaction( + const credentialDeploymentTransaction: v1.CredentialDeploymentPayload = createCredentialDeploymentPayload( identityInput, cryptoParams, threshold, diff --git a/packages/sdk/test/client/resources/expectedJsons.ts b/packages/sdk/test/client/resources/expectedJsons.ts index 4a18430e7..5d6e5d1c6 100644 --- a/packages/sdk/test/client/resources/expectedJsons.ts +++ b/packages/sdk/test/client/resources/expectedJsons.ts @@ -1771,63 +1771,48 @@ export const chainParameters: ChainParametersV1 = { }, keys: [ { - schemeId: 'Ed25519', verifyKey: 'b8ddf4505a37eee2c046671f634b74cf3630f3958ad70a04f39dc843041965be', }, { - schemeId: 'Ed25519', verifyKey: '6f39b453a1f2d04be8e1d34822d4819af1bae7bd10bd0d1f05cbdbfc0907886f', }, { - schemeId: 'Ed25519', verifyKey: 'bf1dbf2070a9af3f469f829817c929ca98349bf383180abf53fa5d349c2ae72f', }, { - schemeId: 'Ed25519', verifyKey: '691dea8d3aeb620e08130d0cddb68156809e894f603763990a2b21af5b17d916', }, { - schemeId: 'Ed25519', verifyKey: 'd6e2ec35c642f52681921b313e4563fda16ab893b8597417778ffd57748a4f30', }, { - schemeId: 'Ed25519', verifyKey: '4fefb5ee8f8f46ecb86accbf44218e7699eb4937122a284d349db9f8e70a9794', }, { - schemeId: 'Ed25519', verifyKey: 'b43e41e008c520c421df2229ea2af816d907d2f085b82b3cadc156165d49ed2a', }, { - schemeId: 'Ed25519', verifyKey: '7386b8a50d01797f95e594112ca1734d2dc2984235c58c9cf5c18a07f7cef98c', }, { - schemeId: 'Ed25519', verifyKey: '56a75f4399a0671fd8a11d88b59c33be00ffb9328a31a41467ce98ddd932dcb1', }, { - schemeId: 'Ed25519', verifyKey: '9974b5868241dd1eee38edda8ad64cfb23722e280ef09286c8a1c7a3c3ba1f40', }, { - schemeId: 'Ed25519', verifyKey: 'fd363dfd04f319848c3d766bc617a5f88f0044f1813cc4a2140a6d28e9b62cce', }, { - schemeId: 'Ed25519', verifyKey: '528281d04d8d74dba67fac53460fa3e2ff2f171f16363d80f679877821b538d2', }, { - schemeId: 'Ed25519', verifyKey: '8ebab6f84c237b331d54a2f611ea8fceeba5b9e0ffff7a096a172f034257999f', }, { - schemeId: 'Ed25519', verifyKey: '616fe3f0441f87e2ba32194faf6c3ea658cac5d31353303a45ca3d1d4164a4f1', }, { - schemeId: 'Ed25519', verifyKey: 'e1f1c6971705da9c2a50be7967609c092fe295a88c71fbf18dd90cc6d81508f2', }, ],