@aztec/accounts 1.2.1 → 2.0.0-nightly.20250813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/EcdsaKAccount.json +2010 -1667
- package/artifacts/EcdsaRAccount.json +2010 -1667
- package/artifacts/SchnorrAccount.json +2070 -1756
- package/artifacts/SchnorrSingleKeyAccount.json +1190 -905
- package/artifacts/SimulatedAccount.d.json.ts +3 -0
- package/artifacts/SimulatedAccount.json +4732 -0
- package/dest/copy_cat/base.d.ts +18 -0
- package/dest/copy_cat/base.d.ts.map +1 -0
- package/dest/copy_cat/base.js +28 -0
- package/dest/copy_cat/index.d.ts +10 -0
- package/dest/copy_cat/index.d.ts.map +1 -0
- package/dest/copy_cat/index.js +31 -0
- package/dest/copy_cat/lazy.d.ts +9 -0
- package/dest/copy_cat/lazy.d.ts.map +1 -0
- package/dest/copy_cat/lazy.js +29 -0
- package/dest/defaults/account_contract.d.ts +3 -3
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.js +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +1 -1
- package/dest/schnorr/account_contract.d.ts +1 -1
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +1 -1
- package/dest/single_key/account_contract.d.ts +1 -1
- package/dest/single_key/account_contract.d.ts.map +1 -1
- package/dest/single_key/account_contract.js +1 -1
- package/dest/testing/create_account.d.ts +4 -4
- package/dest/testing/create_account.d.ts.map +1 -1
- package/dest/testing/create_account.js +5 -5
- package/package.json +8 -7
- package/src/copy_cat/base.ts +47 -0
- package/src/copy_cat/index.ts +44 -0
- package/src/copy_cat/lazy.ts +40 -0
- package/src/defaults/account_contract.ts +3 -3
- package/src/ecdsa/ecdsa_k/account_contract.ts +1 -1
- package/src/ecdsa/ecdsa_r/account_contract.ts +1 -1
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +1 -1
- package/src/schnorr/account_contract.ts +1 -1
- package/src/single_key/account_contract.ts +1 -1
- package/src/testing/create_account.ts +9 -9
- package/dest/dapp/dapp_interface.d.ts +0 -10
- package/dest/dapp/dapp_interface.d.ts.map +0 -1
- package/dest/dapp/dapp_interface.js +0 -16
- package/dest/dapp/index.d.ts +0 -2
- package/dest/dapp/index.d.ts.map +0 -1
- package/dest/dapp/index.js +0 -1
- package/src/dapp/dapp_interface.ts +0 -38
- package/src/dapp/index.ts +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AccountInterface, AccountWalletWithSecretKey, type ContractArtifact, type PXE, TxExecutionRequest } from '@aztec/aztec.js';
|
|
2
|
+
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
+
import type { SimulationOverrides, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
4
|
+
/**
|
|
5
|
+
* An AccountWallet that copies the address of another account, and then
|
|
6
|
+
* uses the simulation overrides feature to execute different contract code under
|
|
7
|
+
* the copied address. This is used to bypass authwit verification entirely
|
|
8
|
+
* (`is_valid` always returns `true`)
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
|
|
11
|
+
private originalAddress;
|
|
12
|
+
private artifact;
|
|
13
|
+
private instance;
|
|
14
|
+
constructor(pxe: PXE, account: AccountInterface, originalAddress: CompleteAddress, artifact: ContractArtifact, instance: ContractInstanceWithAddress);
|
|
15
|
+
getCompleteAddress(): CompleteAddress;
|
|
16
|
+
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, _skipTxValidation?: boolean, _skipFeeEnforcement?: boolean, _overrides?: SimulationOverrides): Promise<TxSimulationResult>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/copy_cat/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,0BAA0B,EAC1B,KAAK,gBAAgB,EAErB,KAAK,GAAG,EACR,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;;GAKG;AACH,8BAAsB,wBAAyB,SAAQ,0BAA0B;IAI7E,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,QAAQ;gBAJhB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,gBAAgB,EACjB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,2BAA2B;IAKtC,kBAAkB,IAAI,eAAe;IAIrC,UAAU,CACjB,SAAS,EAAE,kBAAkB,EAC7B,cAAc,EAAE,OAAO,EACvB,iBAAiB,CAAC,EAAE,OAAO,EAC3B,mBAAmB,CAAC,EAAE,OAAO,EAC7B,UAAU,CAAC,EAAE,mBAAmB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;CAQ/B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AccountWalletWithSecretKey, Fr } from '@aztec/aztec.js';
|
|
2
|
+
/**
|
|
3
|
+
* An AccountWallet that copies the address of another account, and then
|
|
4
|
+
* uses the simulation overrides feature to execute different contract code under
|
|
5
|
+
* the copied address. This is used to bypass authwit verification entirely
|
|
6
|
+
* (`is_valid` always returns `true`)
|
|
7
|
+
*/ export class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
|
|
8
|
+
originalAddress;
|
|
9
|
+
artifact;
|
|
10
|
+
instance;
|
|
11
|
+
constructor(pxe, account, originalAddress, artifact, instance){
|
|
12
|
+
super(pxe, account, Fr.ZERO, Fr.ZERO), this.originalAddress = originalAddress, this.artifact = artifact, this.instance = instance;
|
|
13
|
+
}
|
|
14
|
+
getCompleteAddress() {
|
|
15
|
+
return this.originalAddress;
|
|
16
|
+
}
|
|
17
|
+
simulateTx(txRequest, simulatePublic, _skipTxValidation, _skipFeeEnforcement, _overrides) {
|
|
18
|
+
const contractOverrides = {
|
|
19
|
+
[this.originalAddress.address.toString()]: {
|
|
20
|
+
instance: this.instance,
|
|
21
|
+
artifact: this.artifact
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return this.pxe.simulateTx(txRequest, simulatePublic, true, true, {
|
|
25
|
+
contracts: contractOverrides
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AccountWallet, type PXE } from '@aztec/aztec.js';
|
|
2
|
+
import { CopyCatAccountWalletBase } from './base.js';
|
|
3
|
+
export declare const SimulatedAccountContractArtifact: import("@aztec/aztec.js").ContractArtifact;
|
|
4
|
+
/**
|
|
5
|
+
* A CopyCatAccountWallet that loads the contract artifact eagerly.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
8
|
+
static create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/copy_cat/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAIb,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,eAAO,MAAM,gCAAgC,4CAE5C,CAAC;AAEF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;WACnD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAqB7F"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DefaultAccountInterface } from '@aztec/accounts/defaults';
|
|
2
|
+
import { AuthWitness, getContractInstanceFromInstantiationParams, loadContractArtifact } from '@aztec/aztec.js';
|
|
3
|
+
import SimulatedAccountContractJson from '../../artifacts/SimulatedAccount.json' with {
|
|
4
|
+
type: 'json'
|
|
5
|
+
};
|
|
6
|
+
import { CopyCatAccountWalletBase } from './base.js';
|
|
7
|
+
export const SimulatedAccountContractArtifact = loadContractArtifact(SimulatedAccountContractJson);
|
|
8
|
+
/**
|
|
9
|
+
* A CopyCatAccountWallet that loads the contract artifact eagerly.
|
|
10
|
+
*/ export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
11
|
+
static async create(pxe, originalAccount) {
|
|
12
|
+
const simulatedAuthWitnessProvider = {
|
|
13
|
+
/**
|
|
14
|
+
* A copycat wallet always returns an empty authwitness, since it doesn't
|
|
15
|
+
* perform any verification whatsoever
|
|
16
|
+
* @param messageHash - The outer hash of the message for which the auth witness is created
|
|
17
|
+
*/ createAuthWit (messageHash) {
|
|
18
|
+
return Promise.resolve(new AuthWitness(messageHash, []));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const nodeInfo = await pxe.getNodeInfo();
|
|
22
|
+
const originalAddress = originalAccount.getCompleteAddress();
|
|
23
|
+
const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
|
|
24
|
+
if (!contractInstance) {
|
|
25
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
26
|
+
}
|
|
27
|
+
const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
|
|
28
|
+
const instance = await getContractInstanceFromInstantiationParams(SimulatedAccountContractArtifact, {});
|
|
29
|
+
return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, SimulatedAccountContractArtifact, instance);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AccountWallet, type PXE } from '@aztec/aztec.js';
|
|
2
|
+
import { CopyCatAccountWalletBase } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* A CopyCatAccountWallet that loads the contract artifact lazily.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
7
|
+
static create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/copy_cat/lazy.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAGb,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;WACnD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuB7F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DefaultAccountInterface } from '@aztec/accounts/defaults';
|
|
2
|
+
import { AuthWitness, getContractInstanceFromInstantiationParams, loadContractArtifact } from '@aztec/aztec.js';
|
|
3
|
+
import { CopyCatAccountWalletBase } from './base.js';
|
|
4
|
+
/**
|
|
5
|
+
* A CopyCatAccountWallet that loads the contract artifact lazily.
|
|
6
|
+
*/ export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
7
|
+
static async create(pxe, originalAccount) {
|
|
8
|
+
const simulatedAuthWitnessProvider = {
|
|
9
|
+
/**
|
|
10
|
+
* A copycat wallet always returns an empty authwitness, since it doesn't
|
|
11
|
+
* perform any verification whatsoever
|
|
12
|
+
* @param messageHash - The outer hash of the message for which the auth witness is created
|
|
13
|
+
*/ createAuthWit (messageHash) {
|
|
14
|
+
return Promise.resolve(new AuthWitness(messageHash, []));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const nodeInfo = await pxe.getNodeInfo();
|
|
18
|
+
const originalAddress = originalAccount.getCompleteAddress();
|
|
19
|
+
const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
|
|
20
|
+
if (!contractInstance) {
|
|
21
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
22
|
+
}
|
|
23
|
+
const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
|
|
24
|
+
const { default: simulatedAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
|
|
25
|
+
const simulatedAccountContractArtifact = loadContractArtifact(simulatedAccountContractJson);
|
|
26
|
+
const instance = await getContractInstanceFromInstantiationParams(simulatedAccountContractArtifact, {});
|
|
27
|
+
return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, simulatedAccountContractArtifact, instance);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -7,10 +7,10 @@ import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class DefaultAccountContract implements AccountContract {
|
|
9
9
|
abstract getAuthWitnessProvider(address: CompleteAddress): AuthWitnessProvider;
|
|
10
|
-
abstract
|
|
11
|
-
/** The name of the function used to
|
|
10
|
+
abstract getInitializationFunctionAndArgs(): Promise<{
|
|
11
|
+
/** The name of the function used to initialize the contract */
|
|
12
12
|
constructorName: string;
|
|
13
|
-
/** The args to the function used to
|
|
13
|
+
/** The args to the function used to initialize the contract */
|
|
14
14
|
constructorArgs: any[];
|
|
15
15
|
} | undefined>;
|
|
16
16
|
abstract getContractArtifact(): Promise<ContractArtifact>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/defaults/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIxE;;;GAGG;AACH,8BAAsB,sBAAuB,YAAW,eAAe;IACrE,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/defaults/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIxE;;;GAGG;AACH,8BAAsB,sBAAuB,YAAW,eAAe;IACrE,QAAQ,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,gCAAgC,IAAI,OAAO,CAChD;QACE,+DAA+D;QAC/D,eAAe,EAAE,MAAM,CAAC;QACxB,+DAA+D;QAC/D,eAAe,EAAE,GAAG,EAAE,CAAC;KACxB,GACD,SAAS,CACZ;IACD,QAAQ,CAAC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;;IAIzD,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,gBAAgB;CAG7E"}
|
|
@@ -10,7 +10,7 @@ import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
|
10
10
|
export declare abstract class EcdsaKBaseAccountContract extends DefaultAccountContract {
|
|
11
11
|
private signingPrivateKey;
|
|
12
12
|
constructor(signingPrivateKey: Buffer);
|
|
13
|
-
|
|
13
|
+
getInitializationFunctionAndArgs(): Promise<{
|
|
14
14
|
constructorName: string;
|
|
15
15
|
constructorArgs: Buffer<ArrayBufferLike>[];
|
|
16
16
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_k/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,yBAA0B,SAAQ,sBAAsB;IAChE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,MAAM;IAIvC,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_k/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,yBAA0B,SAAQ,sBAAsB;IAChE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,MAAM;IAIvC,gCAAgC;;;;IAQtC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE"}
|
|
@@ -11,7 +11,7 @@ import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
|
11
11
|
constructor(signingPrivateKey){
|
|
12
12
|
super(), this.signingPrivateKey = signingPrivateKey;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
14
|
+
async getInitializationFunctionAndArgs() {
|
|
15
15
|
const signingPublicKey = await new Ecdsa().computePublicKey(this.signingPrivateKey);
|
|
16
16
|
return {
|
|
17
17
|
constructorName: 'constructor',
|
|
@@ -10,7 +10,7 @@ import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
|
10
10
|
export declare abstract class EcdsaRBaseAccountContract extends DefaultAccountContract {
|
|
11
11
|
private signingPrivateKey;
|
|
12
12
|
constructor(signingPrivateKey: Buffer);
|
|
13
|
-
|
|
13
|
+
getInitializationFunctionAndArgs(): Promise<{
|
|
14
14
|
constructorName: string;
|
|
15
15
|
constructorArgs: Buffer<ArrayBufferLike>[];
|
|
16
16
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_r/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,yBAA0B,SAAQ,sBAAsB;IAChE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,MAAM;IAIvC,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_r/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,yBAA0B,SAAQ,sBAAsB;IAChE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,MAAM;IAIvC,gCAAgC;;;;IAQtC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE"}
|
|
@@ -11,7 +11,7 @@ import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
|
11
11
|
constructor(signingPrivateKey){
|
|
12
12
|
super(), this.signingPrivateKey = signingPrivateKey;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
14
|
+
async getInitializationFunctionAndArgs() {
|
|
15
15
|
const signingPublicKey = await new Ecdsa('secp256r1').computePublicKey(this.signingPrivateKey);
|
|
16
16
|
return {
|
|
17
17
|
constructorName: 'constructor',
|
|
@@ -13,7 +13,7 @@ import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
|
13
13
|
export declare abstract class EcdsaRSSHBaseAccountContract extends DefaultAccountContract {
|
|
14
14
|
private signingPublicKey;
|
|
15
15
|
constructor(signingPublicKey: Buffer);
|
|
16
|
-
|
|
16
|
+
getInitializationFunctionAndArgs(): Promise<{
|
|
17
17
|
constructorName: string;
|
|
18
18
|
constructorArgs: Buffer<ArrayBufferLike>[];
|
|
19
19
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAI5E;;;;;;;;GAQG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,MAAM;IAI5C,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAI5E;;;;;;;;GAQG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,MAAM;IAI5C,gCAAgC;;;;IAOhC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE"}
|
|
@@ -16,7 +16,7 @@ const secp256r1N = 1157920892103562487626974469494075735299969552241357603424222
|
|
|
16
16
|
constructor(signingPublicKey){
|
|
17
17
|
super(), this.signingPublicKey = signingPublicKey;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
getInitializationFunctionAndArgs() {
|
|
20
20
|
return Promise.resolve({
|
|
21
21
|
constructorName: 'constructor',
|
|
22
22
|
constructorArgs: [
|
|
@@ -12,7 +12,7 @@ import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
|
12
12
|
export declare abstract class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
13
13
|
private signingPrivateKey;
|
|
14
14
|
constructor(signingPrivateKey: GrumpkinScalar);
|
|
15
|
-
|
|
15
|
+
getInitializationFunctionAndArgs(): Promise<{
|
|
16
16
|
constructorName: string;
|
|
17
17
|
constructorArgs: Fr[];
|
|
18
18
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/schnorr/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,0BAA2B,SAAQ,sBAAsB;IACjE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAI/C,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/schnorr/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,0BAA2B,SAAQ,sBAAsB;IACjE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAI/C,gCAAgC;;;;IAKtC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE;AAED,uDAAuD;AACvD,qBAAa,0BAA2B,YAAW,mBAAmB;IACxD,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAE/C,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;CAK3D"}
|
|
@@ -11,7 +11,7 @@ import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
|
11
11
|
constructor(signingPrivateKey){
|
|
12
12
|
super(), this.signingPrivateKey = signingPrivateKey;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
14
|
+
async getInitializationFunctionAndArgs() {
|
|
15
15
|
const signingPublicKey = await new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
16
16
|
return {
|
|
17
17
|
constructorName: 'constructor',
|
|
@@ -11,7 +11,7 @@ import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
|
11
11
|
export declare abstract class SingleKeyBaseAccountContract extends DefaultAccountContract {
|
|
12
12
|
private encryptionPrivateKey;
|
|
13
13
|
constructor(encryptionPrivateKey: GrumpkinScalar);
|
|
14
|
-
|
|
14
|
+
getInitializationFunctionAndArgs(): Promise<undefined>;
|
|
15
15
|
getAuthWitnessProvider(account: CompleteAddress): AuthWitnessProvider;
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/single_key/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAW,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,oBAAoB;gBAApB,oBAAoB,EAAE,cAAc;IAIxD,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/single_key/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAW,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,oBAAoB;gBAApB,oBAAoB,EAAE,cAAc;IAIxD,gCAAgC;IAIhC,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;CAGtE"}
|
|
@@ -11,7 +11,7 @@ import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
|
11
11
|
constructor(encryptionPrivateKey){
|
|
12
12
|
super(), this.encryptionPrivateKey = encryptionPrivateKey;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
getInitializationFunctionAndArgs() {
|
|
15
15
|
return Promise.resolve(undefined);
|
|
16
16
|
}
|
|
17
17
|
getAuthWitnessProvider(account) {
|
|
@@ -25,9 +25,9 @@ type DeployAccountData = Pick<InitialAccountData, 'secret' | 'salt'> & {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function deployFundedSchnorrAccount(pxe: PXE, account: DeployAccountData, opts?: WaitOpts & {
|
|
27
27
|
/**
|
|
28
|
-
* Whether or not to skip
|
|
28
|
+
* Whether or not to skip publishing the contract class.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
skipClassPublication?: boolean;
|
|
31
31
|
}, waitForProvenOptions?: WaitForProvenOpts): Promise<AccountManager>;
|
|
32
32
|
/**
|
|
33
33
|
* Deploy schnorr account contracts.
|
|
@@ -35,9 +35,9 @@ export declare function deployFundedSchnorrAccount(pxe: PXE, account: DeployAcco
|
|
|
35
35
|
*/
|
|
36
36
|
export declare function deployFundedSchnorrAccounts(pxe: PXE, accounts: DeployAccountData[], opts?: WaitOpts & {
|
|
37
37
|
/**
|
|
38
|
-
* Whether or not to skip
|
|
38
|
+
* Whether or not to skip publishing the contract class.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
skipClassPublication?: boolean;
|
|
41
41
|
}, waitForProvenOptions?: WaitForProvenOpts): Promise<AccountManager[]>;
|
|
42
42
|
export {};
|
|
43
43
|
//# sourceMappingURL=create_account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/testing/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,gBAAgB,EAAE,MAAM;;;;;KAarE;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG;IACrE;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/testing/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,gBAAgB,EAAE,MAAM;;;;;KAarE;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG;IACrE;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACiB,EAClD,oBAAoB,CAAC,EAAE,iBAAiB,GACvC,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACiB,EAClD,oBAAoB,CAAC,EAAE,iBAAiB,GACvC,OAAO,CAAC,cAAc,EAAE,CAAC,CAiB3B"}
|
|
@@ -23,7 +23,7 @@ import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/
|
|
|
23
23
|
* It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
|
|
24
24
|
*/ export async function deployFundedSchnorrAccount(pxe, account, opts = {
|
|
25
25
|
interval: 0.1,
|
|
26
|
-
|
|
26
|
+
skipClassPublication: false
|
|
27
27
|
}, waitForProvenOptions) {
|
|
28
28
|
const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
|
|
29
29
|
const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
|
|
@@ -31,8 +31,8 @@ import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/
|
|
|
31
31
|
// This only works when the world state is prefilled with the balance for the account in test environment.
|
|
32
32
|
const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());
|
|
33
33
|
const receipt = await accountManager.deploy({
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
skipClassPublication: opts.skipClassPublication,
|
|
35
|
+
skipInstancePublication: true,
|
|
36
36
|
fee: {
|
|
37
37
|
paymentMethod
|
|
38
38
|
}
|
|
@@ -47,14 +47,14 @@ import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/
|
|
|
47
47
|
* They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
|
|
48
48
|
*/ export async function deployFundedSchnorrAccounts(pxe, accounts, opts = {
|
|
49
49
|
interval: 0.1,
|
|
50
|
-
|
|
50
|
+
skipClassPublication: false
|
|
51
51
|
}, waitForProvenOptions) {
|
|
52
52
|
const accountManagers = [];
|
|
53
53
|
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
54
54
|
for(let i = 0; i < accounts.length; i++){
|
|
55
55
|
accountManagers.push(await deployFundedSchnorrAccount(pxe, accounts[i], {
|
|
56
56
|
...opts,
|
|
57
|
-
|
|
57
|
+
skipClassPublication: i !== 0 || opts.skipClassPublication
|
|
58
58
|
}, waitForProvenOptions));
|
|
59
59
|
}
|
|
60
60
|
return accountManagers;
|
package/package.json
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
"name": "@aztec/accounts",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/accounts",
|
|
4
4
|
"description": "Implementation of sample account contracts for Aztec Network",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "2.0.0-nightly.20250813",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
|
-
"./dapp": "./dest/dapp/index.js",
|
|
9
8
|
"./defaults": "./dest/defaults/index.js",
|
|
10
9
|
"./ecdsa": "./dest/ecdsa/index.js",
|
|
11
10
|
"./ecdsa/lazy": "./dest/ecdsa/lazy.js",
|
|
@@ -15,6 +14,8 @@
|
|
|
15
14
|
"./single_key/lazy": "./dest/single_key/lazy.js",
|
|
16
15
|
"./testing": "./dest/testing/index.js",
|
|
17
16
|
"./testing/lazy": "./dest/testing/lazy.js",
|
|
17
|
+
"./copy-cat": "./dest/copy_cat/index.js",
|
|
18
|
+
"./copy-cat/lazy": "./dest/copy_cat/lazy.js",
|
|
18
19
|
"./utils": "./dest/utils/index.js"
|
|
19
20
|
},
|
|
20
21
|
"typedocOptions": {
|
|
@@ -79,11 +80,11 @@
|
|
|
79
80
|
]
|
|
80
81
|
},
|
|
81
82
|
"dependencies": {
|
|
82
|
-
"@aztec/aztec.js": "
|
|
83
|
-
"@aztec/entrypoints": "
|
|
84
|
-
"@aztec/ethereum": "
|
|
85
|
-
"@aztec/foundation": "
|
|
86
|
-
"@aztec/stdlib": "
|
|
83
|
+
"@aztec/aztec.js": "2.0.0-nightly.20250813",
|
|
84
|
+
"@aztec/entrypoints": "2.0.0-nightly.20250813",
|
|
85
|
+
"@aztec/ethereum": "2.0.0-nightly.20250813",
|
|
86
|
+
"@aztec/foundation": "2.0.0-nightly.20250813",
|
|
87
|
+
"@aztec/stdlib": "2.0.0-nightly.20250813",
|
|
87
88
|
"tslib": "^2.4.0"
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AccountInterface,
|
|
3
|
+
AccountWalletWithSecretKey,
|
|
4
|
+
type ContractArtifact,
|
|
5
|
+
Fr,
|
|
6
|
+
type PXE,
|
|
7
|
+
TxExecutionRequest,
|
|
8
|
+
} from '@aztec/aztec.js';
|
|
9
|
+
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
|
+
import type { SimulationOverrides, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An AccountWallet that copies the address of another account, and then
|
|
14
|
+
* uses the simulation overrides feature to execute different contract code under
|
|
15
|
+
* the copied address. This is used to bypass authwit verification entirely
|
|
16
|
+
* (`is_valid` always returns `true`)
|
|
17
|
+
*/
|
|
18
|
+
export abstract class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
|
|
19
|
+
constructor(
|
|
20
|
+
pxe: PXE,
|
|
21
|
+
account: AccountInterface,
|
|
22
|
+
private originalAddress: CompleteAddress,
|
|
23
|
+
private artifact: ContractArtifact,
|
|
24
|
+
private instance: ContractInstanceWithAddress,
|
|
25
|
+
) {
|
|
26
|
+
super(pxe, account, Fr.ZERO, Fr.ZERO);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override getCompleteAddress(): CompleteAddress {
|
|
30
|
+
return this.originalAddress;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override simulateTx(
|
|
34
|
+
txRequest: TxExecutionRequest,
|
|
35
|
+
simulatePublic: boolean,
|
|
36
|
+
_skipTxValidation?: boolean,
|
|
37
|
+
_skipFeeEnforcement?: boolean,
|
|
38
|
+
_overrides?: SimulationOverrides,
|
|
39
|
+
): Promise<TxSimulationResult> {
|
|
40
|
+
const contractOverrides = {
|
|
41
|
+
[this.originalAddress.address.toString()]: { instance: this.instance, artifact: this.artifact },
|
|
42
|
+
};
|
|
43
|
+
return this.pxe.simulateTx(txRequest, simulatePublic, true, true, {
|
|
44
|
+
contracts: contractOverrides,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DefaultAccountInterface } from '@aztec/accounts/defaults';
|
|
2
|
+
import {
|
|
3
|
+
AccountWallet,
|
|
4
|
+
AuthWitness,
|
|
5
|
+
Fr,
|
|
6
|
+
type NoirCompiledContract,
|
|
7
|
+
type PXE,
|
|
8
|
+
getContractInstanceFromInstantiationParams,
|
|
9
|
+
loadContractArtifact,
|
|
10
|
+
} from '@aztec/aztec.js';
|
|
11
|
+
|
|
12
|
+
import SimulatedAccountContractJson from '../../artifacts/SimulatedAccount.json' with { type: 'json' };
|
|
13
|
+
import { CopyCatAccountWalletBase } from './base.js';
|
|
14
|
+
|
|
15
|
+
export const SimulatedAccountContractArtifact = loadContractArtifact(
|
|
16
|
+
SimulatedAccountContractJson as NoirCompiledContract,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A CopyCatAccountWallet that loads the contract artifact eagerly.
|
|
21
|
+
*/
|
|
22
|
+
export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
23
|
+
static async create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet> {
|
|
24
|
+
const simulatedAuthWitnessProvider = {
|
|
25
|
+
/**
|
|
26
|
+
* A copycat wallet always returns an empty authwitness, since it doesn't
|
|
27
|
+
* perform any verification whatsoever
|
|
28
|
+
* @param messageHash - The outer hash of the message for which the auth witness is created
|
|
29
|
+
*/
|
|
30
|
+
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
31
|
+
return Promise.resolve(new AuthWitness(messageHash, []));
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const nodeInfo = await pxe.getNodeInfo();
|
|
35
|
+
const originalAddress = originalAccount.getCompleteAddress();
|
|
36
|
+
const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
|
|
37
|
+
if (!contractInstance) {
|
|
38
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
39
|
+
}
|
|
40
|
+
const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
|
|
41
|
+
const instance = await getContractInstanceFromInstantiationParams(SimulatedAccountContractArtifact, {});
|
|
42
|
+
return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, SimulatedAccountContractArtifact, instance);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DefaultAccountInterface } from '@aztec/accounts/defaults';
|
|
2
|
+
import {
|
|
3
|
+
AccountWallet,
|
|
4
|
+
AuthWitness,
|
|
5
|
+
Fr,
|
|
6
|
+
type PXE,
|
|
7
|
+
getContractInstanceFromInstantiationParams,
|
|
8
|
+
loadContractArtifact,
|
|
9
|
+
} from '@aztec/aztec.js';
|
|
10
|
+
|
|
11
|
+
import { CopyCatAccountWalletBase } from './base.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A CopyCatAccountWallet that loads the contract artifact lazily.
|
|
15
|
+
*/
|
|
16
|
+
export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
17
|
+
static async create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet> {
|
|
18
|
+
const simulatedAuthWitnessProvider = {
|
|
19
|
+
/**
|
|
20
|
+
* A copycat wallet always returns an empty authwitness, since it doesn't
|
|
21
|
+
* perform any verification whatsoever
|
|
22
|
+
* @param messageHash - The outer hash of the message for which the auth witness is created
|
|
23
|
+
*/
|
|
24
|
+
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
25
|
+
return Promise.resolve(new AuthWitness(messageHash, []));
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const nodeInfo = await pxe.getNodeInfo();
|
|
29
|
+
const originalAddress = originalAccount.getCompleteAddress();
|
|
30
|
+
const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
|
|
31
|
+
if (!contractInstance) {
|
|
32
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
33
|
+
}
|
|
34
|
+
const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
|
|
35
|
+
const { default: simulatedAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
|
|
36
|
+
const simulatedAccountContractArtifact = loadContractArtifact(simulatedAccountContractJson);
|
|
37
|
+
const instance = await getContractInstanceFromInstantiationParams(simulatedAccountContractArtifact, {});
|
|
38
|
+
return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, simulatedAccountContractArtifact, instance);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -10,11 +10,11 @@ import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export abstract class DefaultAccountContract implements AccountContract {
|
|
12
12
|
abstract getAuthWitnessProvider(address: CompleteAddress): AuthWitnessProvider;
|
|
13
|
-
abstract
|
|
13
|
+
abstract getInitializationFunctionAndArgs(): Promise<
|
|
14
14
|
| {
|
|
15
|
-
/** The name of the function used to
|
|
15
|
+
/** The name of the function used to initialize the contract */
|
|
16
16
|
constructorName: string;
|
|
17
|
-
/** The args to the function used to
|
|
17
|
+
/** The args to the function used to initialize the contract */
|
|
18
18
|
constructorArgs: any[];
|
|
19
19
|
}
|
|
20
20
|
| undefined
|
|
@@ -17,7 +17,7 @@ export abstract class EcdsaKBaseAccountContract extends DefaultAccountContract {
|
|
|
17
17
|
super();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async
|
|
20
|
+
async getInitializationFunctionAndArgs() {
|
|
21
21
|
const signingPublicKey = await new Ecdsa().computePublicKey(this.signingPrivateKey);
|
|
22
22
|
return {
|
|
23
23
|
constructorName: 'constructor',
|
|
@@ -17,7 +17,7 @@ export abstract class EcdsaRBaseAccountContract extends DefaultAccountContract {
|
|
|
17
17
|
super();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async
|
|
20
|
+
async getInitializationFunctionAndArgs() {
|
|
21
21
|
const signingPublicKey = await new Ecdsa('secp256r1').computePublicKey(this.signingPrivateKey);
|
|
22
22
|
return {
|
|
23
23
|
constructorName: 'constructor',
|
|
@@ -22,7 +22,7 @@ export abstract class EcdsaRSSHBaseAccountContract extends DefaultAccountContrac
|
|
|
22
22
|
super();
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
getInitializationFunctionAndArgs() {
|
|
26
26
|
return Promise.resolve({
|
|
27
27
|
constructorName: 'constructor',
|
|
28
28
|
constructorArgs: [this.signingPublicKey.subarray(0, 32), this.signingPublicKey.subarray(32, 64)],
|
|
@@ -17,7 +17,7 @@ export abstract class SchnorrBaseAccountContract extends DefaultAccountContract
|
|
|
17
17
|
super();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async
|
|
20
|
+
async getInitializationFunctionAndArgs() {
|
|
21
21
|
const signingPublicKey = await new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
22
22
|
return { constructorName: 'constructor', constructorArgs: [signingPublicKey.x, signingPublicKey.y] };
|
|
23
23
|
}
|