Skip to content

Commit 7534c7d

Browse files
authored
fix: Change UpdatePassword to take multiple addresses, roll back on error (#175)
BREAKING CHANGE: Change `UpdatePassword` to take an array of addresses, roll back on error. Explanation: Currently, `UpdatePassword` takes a single address of the account to update the password. If a native application wants to change multiple accounts to the new password, it does a loop to call `UpdatePassword` multiple times. But if one of the calls has an error, the application breaks out of the loop and leaves the Keybase in an inconsistent state where some passwords are changed but not all. The application could write some logic to roll back these changes, but it is better for the Gno Native Kit service to handle this. This PR has two commits: 1. Change the `UpdatePassword` request to take a required array of account addresses. (If the application only wants to update the password of one account, it is easy to make an array of one address.) In api.go, we also change `UpdatePassword` to roll back to the old password in case of error. 2. In types.ts and GnoNativeApi.ts, change `updatePassword` to take a required array of Uint8Array for the addresses. --------- Signed-off-by: Jeff Thompson <[email protected]>
1 parent beadf11 commit 7534c7d

14 files changed

+770
-464
lines changed

api/gen/csharp/Gnonativetypes.cs

+315-137
Large diffs are not rendered by default.

api/gen/csharp/RpcGrpc.cs

+15-10
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,9 @@ public abstract partial class GnoNativeServiceBase
709709
}
710710

711711
/// <summary>
712-
/// Update the keybase to use the new password for the account in the keybase with the given address.
713-
/// Before calling this, you must call SetPassword with the current password.
712+
/// Update the keybase to use the new password for the accounts in the keybase with the given addresses.
713+
/// Before calling this, you must call SetPassword with the current password for each account.
714+
/// If there is an error, then roll back all accounts to the current password.
714715
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
715716
/// </summary>
716717
/// <param name="request">The request received from the client.</param>
@@ -1889,8 +1890,9 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
18891890
return CallInvoker.AsyncUnaryCall(__Method_SetPassword, null, options, request);
18901891
}
18911892
/// <summary>
1892-
/// Update the keybase to use the new password for the account in the keybase with the given address.
1893-
/// Before calling this, you must call SetPassword with the current password.
1893+
/// Update the keybase to use the new password for the accounts in the keybase with the given addresses.
1894+
/// Before calling this, you must call SetPassword with the current password for each account.
1895+
/// If there is an error, then roll back all accounts to the current password.
18941896
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
18951897
/// </summary>
18961898
/// <param name="request">The request to send to the server.</param>
@@ -1904,8 +1906,9 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
19041906
return UpdatePassword(request, new grpc::CallOptions(headers, deadline, cancellationToken));
19051907
}
19061908
/// <summary>
1907-
/// Update the keybase to use the new password for the account in the keybase with the given address.
1908-
/// Before calling this, you must call SetPassword with the current password.
1909+
/// Update the keybase to use the new password for the accounts in the keybase with the given addresses.
1910+
/// Before calling this, you must call SetPassword with the current password for each account.
1911+
/// If there is an error, then roll back all accounts to the current password.
19091912
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
19101913
/// </summary>
19111914
/// <param name="request">The request to send to the server.</param>
@@ -1917,8 +1920,9 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
19171920
return CallInvoker.BlockingUnaryCall(__Method_UpdatePassword, null, options, request);
19181921
}
19191922
/// <summary>
1920-
/// Update the keybase to use the new password for the account in the keybase with the given address.
1921-
/// Before calling this, you must call SetPassword with the current password.
1923+
/// Update the keybase to use the new password for the accounts in the keybase with the given addresses.
1924+
/// Before calling this, you must call SetPassword with the current password for each account.
1925+
/// If there is an error, then roll back all accounts to the current password.
19221926
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
19231927
/// </summary>
19241928
/// <param name="request">The request to send to the server.</param>
@@ -1932,8 +1936,9 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
19321936
return UpdatePasswordAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
19331937
}
19341938
/// <summary>
1935-
/// Update the keybase to use the new password for the account in the keybase with the given address.
1936-
/// Before calling this, you must call SetPassword with the current password.
1939+
/// Update the keybase to use the new password for the accounts in the keybase with the given addresses.
1940+
/// Before calling this, you must call SetPassword with the current password for each account.
1941+
/// If there is an error, then roll back all accounts to the current password.
19371942
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
19381943
/// </summary>
19391944
/// <param name="request">The request to send to the server.</param>

api/gen/es/gnonativetypes_pb.d.ts

+27-3
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ export declare class UpdatePasswordRequest extends Message<UpdatePasswordRequest
240240
newPassword: string;
241241

242242
/**
243-
* The address of the account to update the password
243+
* The addresses of the account to update the password
244244
*
245-
* @generated from field: bytes address = 2;
245+
* @generated from field: repeated bytes addresses = 2;
246246
*/
247-
address: Uint8Array;
247+
addresses: Uint8Array[];
248248

249249
constructor(data?: PartialMessage<UpdatePasswordRequest>);
250250

@@ -2055,3 +2055,27 @@ export declare class HelloStreamResponse extends Message<HelloStreamResponse> {
20552055
static equals(a: HelloStreamResponse | PlainMessage<HelloStreamResponse> | undefined, b: HelloStreamResponse | PlainMessage<HelloStreamResponse> | undefined): boolean;
20562056
}
20572057

2058+
/**
2059+
* @generated from message land.gno.gnonative.v1.GNONATIVETYPES_BytesList
2060+
*/
2061+
export declare class GNONATIVETYPES_BytesList extends Message<GNONATIVETYPES_BytesList> {
2062+
/**
2063+
* @generated from field: repeated bytes Value = 1;
2064+
*/
2065+
Value: Uint8Array[];
2066+
2067+
constructor(data?: PartialMessage<GNONATIVETYPES_BytesList>);
2068+
2069+
static readonly runtime: typeof proto3;
2070+
static readonly typeName = "land.gno.gnonative.v1.GNONATIVETYPES_BytesList";
2071+
static readonly fields: FieldList;
2072+
2073+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GNONATIVETYPES_BytesList;
2074+
2075+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GNONATIVETYPES_BytesList;
2076+
2077+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GNONATIVETYPES_BytesList;
2078+
2079+
static equals(a: GNONATIVETYPES_BytesList | PlainMessage<GNONATIVETYPES_BytesList> | undefined, b: GNONATIVETYPES_BytesList | PlainMessage<GNONATIVETYPES_BytesList> | undefined): boolean;
2080+
}
2081+

api/gen/es/gnonativetypes_pb.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const UpdatePasswordRequest = proto3.makeMessageType(
105105
"land.gno.gnonative.v1.UpdatePasswordRequest",
106106
() => [
107107
{ no: 1, name: "new_password", kind: "scalar", T: 9 /* ScalarType.STRING */ },
108-
{ no: 2, name: "address", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
108+
{ no: 2, name: "addresses", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
109109
],
110110
);
111111

@@ -782,3 +782,13 @@ export const HelloStreamResponse = proto3.makeMessageType(
782782
],
783783
);
784784

785+
/**
786+
* @generated from message land.gno.gnonative.v1.GNONATIVETYPES_BytesList
787+
*/
788+
export const GNONATIVETYPES_BytesList = proto3.makeMessageType(
789+
"land.gno.gnonative.v1.GNONATIVETYPES_BytesList",
790+
() => [
791+
{ no: 1, name: "Value", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
792+
],
793+
);
794+

api/gen/es/rpc_connect.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ export declare const GnoNativeService: {
214214
readonly kind: MethodKind.Unary,
215215
},
216216
/**
217-
* Update the keybase to use the new password for the account in the keybase with the given address.
218-
* Before calling this, you must call SetPassword with the current password.
217+
* Update the keybase to use the new password for the accounts in the keybase with the given addresses.
218+
* Before calling this, you must call SetPassword with the current password for each account.
219+
* If there is an error, then roll back all accounts to the current password.
219220
* If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
220221
*
221222
* @generated from rpc land.gno.gnonative.v1.GnoNativeService.UpdatePassword

api/gen/es/rpc_connect.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ export const GnoNativeService = {
214214
kind: MethodKind.Unary,
215215
},
216216
/**
217-
* Update the keybase to use the new password for the account in the keybase with the given address.
218-
* Before calling this, you must call SetPassword with the current password.
217+
* Update the keybase to use the new password for the accounts in the keybase with the given addresses.
218+
* Before calling this, you must call SetPassword with the current password for each account.
219+
* If there is an error, then roll back all accounts to the current password.
219220
* If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
220221
*
221222
* @generated from rpc land.gno.gnonative.v1.GnoNativeService.UpdatePassword

api/gen/go/_goconnect/rpc.connect.go

+6-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)