Skip to content
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
9 changes: 9 additions & 0 deletions yarn-project/aztec.js/src/wallet/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export interface ContractFunctionPattern {

/** Function name or '*' for any function */
function: string;

/**
* Additional addresses whose private state and keys are accessible
* when calling this function, beyond the sender's.
* - undefined: No additional scopes allowed
* - AztecAddress[]: Only these specific addresses allowed as additional scopes
* - '*': All known address allowed as an additional scope
*/
additionalScopes?: AztecAddress[] | '*';
}

/**
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/aztec.js/src/wallet/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ describe('WalletSchema', () => {
});

it('requestCapabilities', async () => {
const someAddress = await AztecAddress.random();
const anotherAddress = await AztecAddress.random();
const manifest: AppCapabilities = {
version: '1.0',
metadata: {
Expand All @@ -239,6 +241,14 @@ describe('WalletSchema', () => {
canGet: true,
canCreateAuthWit: true,
},
{
type: 'transaction',
scope: [
{ contract: someAddress, function: 'withdraw', additionalScopes: [anotherAddress] },
{ contract: someAddress, function: 'transfer' },
{ contract: someAddress, function: 'deposit', additionalScopes: '*' },
],
},
],
};
const result = await context.client.requestCapabilities(manifest);
Expand Down
1 change: 1 addition & 0 deletions yarn-project/aztec.js/src/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export const ContractClassMetadataSchema = z.object({
export const ContractFunctionPatternSchema = z.object({
contract: z.union([schemas.AztecAddress, z.literal('*')]),
function: z.union([z.string(), z.literal('*')]),
additionalScopes: optional(z.union([z.array(schemas.AztecAddress), z.literal('*')])),
});

export const AccountsCapabilitySchema = z.object({
Expand Down
Loading