Skip to content

Add account delegation preparation #3076

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 80 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
80c98c2
add get_accounts_for_origin to account_management and get_accounts to…
LXIF May 13, 2025
daf7c2f
add authorization fn
LXIF May 13, 2025
5fb5bc1
clippy
LXIF May 13, 2025
c25a7bb
add tests for get and create
LXIF May 13, 2025
e5f72b3
clippy
LXIF May 13, 2025
07d0f73
add account updating endpoint and related account management function…
LXIF May 13, 2025
b98bc18
cwippy
LXIF May 13, 2025
55f85d9
add seed_from_anchor to Account
LXIF May 13, 2025
5a4c704
add seed_from_anchor to account struct
LXIF May 13, 2025
af693d0
add calculate_account_delegation_seed function
LXIF May 13, 2025
f10ac25
make get_accounts return a result
LXIF May 14, 2025
a281016
Merge branch 'andri/implement-get-accounts' into andri/implement-crea…
LXIF May 14, 2025
d75a785
add principal to GetAccountsError::Unauthorized
LXIF May 14, 2025
9110107
Merge branch 'andri/implement-get-accounts' into andri/implement-crea…
LXIF May 14, 2025
4355c14
add const
LXIF May 14, 2025
fe51d28
add global acc limit and unit test
LXIF May 14, 2025
c80561c
Merge branch 'andri/implement-create-account' into andri/implement-up…
LXIF May 14, 2025
dc5863d
add max acc limit to update function
LXIF May 14, 2025
a3c9501
add authorization, add checking if anchor has account (for later)
LXIF May 14, 2025
fa38325
merge main
LXIF May 14, 2025
674bbb0
clippy
LXIF May 14, 2025
72a3294
fix did
LXIF May 14, 2025
893d1f5
Merge branch 'andri/implement-create-account' into andri/implement-up…
LXIF May 14, 2025
6cefda2
add per-acc auth check in account management
LXIF May 14, 2025
a74c252
add tests, restructure per-acc auth check in update_account
LXIF May 14, 2025
81c6521
change variant name, update comment
LXIF May 15, 2025
da58a36
cleanup function inputs
LXIF May 15, 2025
206b259
merge main
LXIF May 15, 2025
037c9e8
cwippy
LXIF May 15, 2025
5e5687d
cwippy again
LXIF May 15, 2025
649bd83
Merge branch 'andri/implement-update-account' into andri/implement-cr…
LXIF May 15, 2025
eca0ed5
minor changes
LXIF May 15, 2025
8de7852
add account delegation preparation function and update endpoint
LXIF May 15, 2025
62e4012
fix did
LXIF May 15, 2025
a46738b
fix did
LXIF May 15, 2025
9e555c2
cwippy
LXIF May 15, 2025
482e80a
fix did again
LXIF May 15, 2025
845308f
cwippy fix
LXIF May 15, 2025
42999ec
fix did?
LXIF May 15, 2025
9f48cf6
fix typing
LXIF May 15, 2025
e76cc72
clippyyy
LXIF May 15, 2025
2eb418f
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 15, 2025
f0f7089
cleanup
LXIF May 15, 2025
2880261
clippy
LXIF May 15, 2025
ebb0bac
fix read_account method to account for seed_from_anchor
LXIF May 15, 2025
6785d65
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 16, 2025
7c29d5d
rename
LXIF May 16, 2025
3d38247
move seed generation function into account impl
LXIF May 16, 2025
418865c
clippy
LXIF May 16, 2025
7d45b64
cleanup delegation generation, handle default account in has_account_…
LXIF May 16, 2025
340a488
return account from anchor_has_account
LXIF May 16, 2025
90e4a34
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 16, 2025
4fab02b
cleanupt
LXIF May 16, 2025
536a80c
restructure has_account_reference and anchor_has_account
LXIF May 16, 2025
ec29af8
cwippy
LXIF May 16, 2025
b3bead0
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 16, 2025
4bc169b
return default acc if no application number
LXIF May 16, 2025
adc1ca5
cwippy
LXIF May 16, 2025
fd26acc
cleanup
LXIF May 16, 2025
f75d321
restructure storage borrowing
LXIF May 16, 2025
381d5a7
make nicer
LXIF May 16, 2025
cad122e
update list_accounts to return accounts and use read_account
LXIF May 19, 2025
068f900
remove anchor_has_account, pack everything into read_account
LXIF May 19, 2025
ffbfa93
clippy
LXIF May 19, 2025
f23c061
clippy
LXIF May 19, 2025
ed07dc1
add comment
LXIF May 19, 2025
c27bbc3
clippy
LXIF May 19, 2025
fa0773d
change error type
LXIF May 19, 2025
db7d1ed
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 19, 2025
591c28b
fix function inputs
LXIF May 19, 2025
19e0299
fix tests
LXIF May 19, 2025
52e5349
🤖 cargo-fmt auto-update
github-actions[bot] May 19, 2025
3788ba7
add tests, rename some things
LXIF May 20, 2025
a64e846
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 20, 2025
c7fc663
remove comment
LXIF May 20, 2025
ec0af93
update comments
LXIF May 20, 2025
f1a27d3
add expect message, add comments
LXIF May 20, 2025
5b7e04a
clippy
LXIF May 20, 2025
acd0dea
update match statement in calculate_seed
LXIF May 20, 2025
fe6baa1
Merge branch 'main' into andri/implement-create-account-delegation
LXIF May 20, 2025
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
15 changes: 14 additions & 1 deletion src/frontend/src/lib/generated/internet_identity_idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ export const idlFactory = ({ IDL }) => {
'expiration' : Timestamp,
'anchor_number' : UserNumber,
});
const PrepareAccountDelegation = IDL.Record({
'user_key' : UserKey,
'timestamp' : Timestamp,
});
const AccountDelegationError = IDL.Variant({
'InternalCanisterError' : IDL.Text,
'Unauthorized' : IDL.Principal,
});
const PrepareIdAliasRequest = IDL.Record({
'issuer' : FrontendHostname,
'relying_party' : FrontendHostname,
Expand Down Expand Up @@ -653,7 +661,12 @@ export const idlFactory = ({ IDL }) => {
SessionKey,
IDL.Opt(IDL.Nat64),
],
[UserKey, Timestamp],
[
IDL.Variant({
'Ok' : PrepareAccountDelegation,
'Err' : AccountDelegationError,
}),
],
[],
),
'prepare_delegation' : IDL.Func(
Expand Down
9 changes: 8 additions & 1 deletion src/frontend/src/lib/generated/internet_identity_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { Principal } from '@dfinity/principal';
import type { ActorMethod } from '@dfinity/agent';
import type { IDL } from '@dfinity/candid';

export type AccountDelegationError = { 'InternalCanisterError' : string } |
{ 'Unauthorized' : Principal };
export interface AccountInfo {
'name' : [] | [string],
'origin' : string,
Expand Down Expand Up @@ -302,6 +304,10 @@ export interface OpenIdPrepareDelegationResponse {
'expiration' : Timestamp,
'anchor_number' : UserNumber,
}
export interface PrepareAccountDelegation {
'user_key' : UserKey,
'timestamp' : Timestamp,
}
export type PrepareIdAliasError = { 'InternalCanisterError' : string } |
{ 'Unauthorized' : Principal };
export interface PrepareIdAliasRequest {
Expand Down Expand Up @@ -524,7 +530,8 @@ export interface _SERVICE {
SessionKey,
[] | [bigint],
],
[UserKey, Timestamp]
{ 'Ok' : PrepareAccountDelegation } |
{ 'Err' : AccountDelegationError }
>,
'prepare_delegation' : ActorMethod<
[UserNumber, FrontendHostname, SessionKey, [] | [bigint]],
Expand Down
12 changes: 11 additions & 1 deletion src/internet_identity/internet_identity.did
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you need to manually recreate the types. The task that used to do it got broken somehow, which we should think whether we want to fix or remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by that - which types do I need to recreate?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you change the candid file, we must also change the Typescript related files by running npm run generate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh right, doing that

Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@ type UpdateAccountError = variant {
Unauthorized : principal;
};

type AccountDelegationError = variant {
InternalCanisterError : text;
Unauthorized : principal;
};

type PrepareAccountDelegation = record {
user_key : UserKey;
timestamp : Timestamp;
};

type GetAccountsError = variant {
InternalCanisterError : text;
Unauthorized : principal;
Expand Down Expand Up @@ -873,7 +883,7 @@ service : (opt InternetIdentityInit) -> {
account_number : opt AccountNumber, // Null is unreserved default account
session_key : SessionKey,
max_ttl : opt nat64
) -> (UserKey, Timestamp);
) -> (variant { Ok : PrepareAccountDelegation; Err : AccountDelegationError });

get_account_delegation : (
anchor_number : UserNumber,
Expand Down
Loading
Loading