Skip to content

Commit

Permalink
refactor: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoenig134 committed Dec 10, 2024
1 parent 4cdcee4 commit 80374db
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/transport/src/modules/accounts/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class AccountController {
const signedChallenge = await this.challenges.createAccountCreationChallenge(identityKeypair);
this._log.trace("Challenge signed. Creating device...");

const [deviceResponseResult, privSync, localAddress, deviceInfo] = await Promise.all([
const [createIdentityResponse, privSync, localAddress, deviceInfo] = await Promise.all([
// Register first device (and identity) on backbone
this.identityClient.createIdentity({
devicePassword: devicePwdD1,
Expand All @@ -296,30 +296,30 @@ export class AccountController {
this.fetchDeviceInfo()
]);

if (deviceResponseResult.isError) {
const error = deviceResponseResult.error;
if (createIdentityResponse.isError) {
const error = createIdentityResponse.error;
if (error.code === "error.platform.unauthorized") {
throw TransportCoreErrors.general.platformClientInvalid();
}
}

const deviceResponse = deviceResponseResult.value;
const createdIdentity = createIdentityResponse.value;

this._log.trace(`Registered identity with address ${deviceResponse.address}, device id is ${deviceResponse.device.id}.`);
this._log.trace(`Registered identity with address ${createdIdentity.address}, device id is ${createdIdentity.device.id}.`);

if (!localAddress.equals(deviceResponse.address)) {
throw new TransportError(`The backbone address '${deviceResponse.address}' does not match the local address '${localAddress.toString()}'.`);
if (!localAddress.equals(createdIdentity.address)) {
throw new TransportError(`The backbone address '${createdIdentity.address}' does not match the local address '${localAddress.toString()}'.`);
}

const identity = Identity.from({
address: CoreAddress.from(deviceResponse.address),
address: CoreAddress.from(createdIdentity.address),
publicKey: identityKeypair.publicKey
});

const deviceId = CoreId.from(deviceResponse.device.id);
const deviceId = CoreId.from(createdIdentity.device.id);

const device = Device.from({
createdAt: CoreDate.from(deviceResponse.createdAt),
createdAt: CoreDate.from(createdIdentity.createdAt),
createdByDevice: deviceId,
id: deviceId,
name: "Device 1",
Expand All @@ -328,7 +328,7 @@ export class AccountController {
publicKey: deviceKeypair.publicKey,
type: deviceInfo.type,
certificate: "",
username: deviceResponse.device.username,
username: createdIdentity.device.username,
datawalletVersion: this._config.supportedDatawalletVersion
});

Expand All @@ -339,7 +339,7 @@ export class AccountController {

const deviceCredentials = DeviceSecretCredentials.from({
id: device.id,
username: deviceResponse.device.username,
username: createdIdentity.device.username,
password: devicePwdD1
});

Expand Down

0 comments on commit 80374db

Please sign in to comment.