@aztec/aztec.js 0.1.0-alpha26 → 0.1.0-alpha28

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.
Files changed (84) hide show
  1. package/.tsbuildinfo +1 -1
  2. package/README.md +2 -2
  3. package/dest/abis/ecdsa_account_contract.json +53 -50
  4. package/dest/abis/schnorr_single_key_account_contract.json +5 -3
  5. package/dest/account_impl/account_collection.d.ts +0 -6
  6. package/dest/account_impl/account_collection.d.ts.map +1 -1
  7. package/dest/account_impl/account_collection.js +1 -7
  8. package/dest/account_impl/entrypoint_payload.d.ts.map +1 -1
  9. package/dest/account_impl/entrypoint_payload.js +4 -3
  10. package/dest/account_impl/index.d.ts +10 -1
  11. package/dest/account_impl/index.d.ts.map +1 -1
  12. package/dest/account_impl/single_key_account_contract.d.ts +2 -3
  13. package/dest/account_impl/single_key_account_contract.d.ts.map +1 -1
  14. package/dest/account_impl/single_key_account_contract.js +5 -6
  15. package/dest/account_impl/stored_key_account_contract.d.ts +2 -3
  16. package/dest/account_impl/stored_key_account_contract.d.ts.map +1 -1
  17. package/dest/account_impl/stored_key_account_contract.js +3 -4
  18. package/dest/aztec_rpc_client/aztec_rpc_client.d.ts +2 -1
  19. package/dest/aztec_rpc_client/aztec_rpc_client.d.ts.map +1 -1
  20. package/dest/aztec_rpc_client/aztec_rpc_client.js +5 -3
  21. package/dest/aztec_rpc_client/wallet.d.ts +7 -7
  22. package/dest/aztec_rpc_client/wallet.d.ts.map +1 -1
  23. package/dest/aztec_rpc_client/wallet.js +8 -5
  24. package/dest/contract/contract.d.ts +8 -54
  25. package/dest/contract/contract.d.ts.map +1 -1
  26. package/dest/contract/contract.js +13 -53
  27. package/dest/contract/contract.test.js +12 -8
  28. package/dest/contract/contract_base.d.ts +64 -0
  29. package/dest/contract/contract_base.d.ts.map +1 -0
  30. package/dest/contract/contract_base.js +60 -0
  31. package/dest/contract/contract_function_interaction.d.ts +7 -0
  32. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  33. package/dest/contract/contract_function_interaction.js +15 -4
  34. package/dest/contract/index.d.ts +1 -0
  35. package/dest/contract/index.d.ts.map +1 -1
  36. package/dest/contract/index.js +2 -1
  37. package/dest/contract/sent_tx.d.ts +10 -2
  38. package/dest/contract/sent_tx.d.ts.map +1 -1
  39. package/dest/contract/sent_tx.js +18 -3
  40. package/dest/contract_deployer/contract_deployer.d.ts +1 -0
  41. package/dest/contract_deployer/contract_deployer.d.ts.map +1 -1
  42. package/dest/contract_deployer/contract_deployer.js +2 -2
  43. package/dest/contract_deployer/contract_deployer.test.js +3 -3
  44. package/dest/contract_deployer/deploy_method.d.ts +1 -1
  45. package/dest/contract_deployer/deploy_method.d.ts.map +1 -1
  46. package/dest/contract_deployer/deploy_method.js +3 -3
  47. package/dest/index.d.ts +1 -1
  48. package/dest/index.d.ts.map +1 -1
  49. package/dest/index.js +2 -1
  50. package/dest/main.js +2 -0
  51. package/dest/main.js.LICENSE.txt +12 -0
  52. package/dest/utils/account.d.ts +3 -4
  53. package/dest/utils/account.d.ts.map +1 -1
  54. package/dest/utils/account.js +3 -4
  55. package/dest/utils/pub_key.d.ts +2 -3
  56. package/dest/utils/pub_key.d.ts.map +1 -1
  57. package/dest/utils/pub_key.js +2 -3
  58. package/package.json +8 -5
  59. package/package.local.json +5 -0
  60. package/src/abis/ecdsa_account_contract.json +53 -50
  61. package/src/abis/schnorr_single_key_account_contract.json +5 -3
  62. package/src/account_impl/account_collection.ts +0 -6
  63. package/src/account_impl/entrypoint_payload.ts +3 -2
  64. package/src/account_impl/index.ts +11 -1
  65. package/src/account_impl/single_key_account_contract.ts +12 -6
  66. package/src/account_impl/stored_key_account_contract.ts +4 -5
  67. package/src/aztec_rpc_client/aztec_rpc_client.ts +5 -2
  68. package/src/aztec_rpc_client/wallet.ts +11 -8
  69. package/src/contract/contract.test.ts +12 -9
  70. package/src/contract/contract.ts +13 -66
  71. package/src/contract/contract_base.ts +77 -0
  72. package/src/contract/contract_function_interaction.ts +17 -9
  73. package/src/contract/index.ts +1 -0
  74. package/src/contract/sent_tx.ts +20 -3
  75. package/src/contract_deployer/contract_deployer.test.ts +2 -2
  76. package/src/contract_deployer/contract_deployer.ts +1 -1
  77. package/src/contract_deployer/deploy_method.ts +2 -2
  78. package/src/index.ts +19 -1
  79. package/src/utils/account.ts +4 -5
  80. package/src/utils/pub_key.ts +3 -4
  81. package/tsconfig.dest.json +17 -0
  82. package/webpack.config.js +74 -0
  83. package/dest/abis/schnorr_account_contract.json +0 -96
  84. package/src/abis/schnorr_account_contract.json +0 -96
@@ -1,21 +1,8 @@
1
- import { ContractAbi, FunctionAbi, generateFunctionSelector } from '@aztec/foundation/abi';
1
+ import { ContractAbi } from '@aztec/foundation/abi';
2
2
  import { AztecAddress } from '@aztec/foundation/aztec-address';
3
- import { EthAddress } from '@aztec/foundation/eth-address';
4
- import { DeployedContract } from '@aztec/types';
5
3
 
6
4
  import { Wallet } from '../aztec_rpc_client/wallet.js';
7
- import { ContractFunctionInteraction } from './contract_function_interaction.js';
8
-
9
- /**
10
- * Type representing a contract method that returns a ContractFunctionInteraction instance
11
- * and has a readonly 'selector' property of type Buffer. Takes any number of arguments.
12
- */
13
- export type ContractMethod = ((...args: any[]) => ContractFunctionInteraction) & {
14
- /**
15
- * The unique identifier for a contract function in bytecode.
16
- */
17
- readonly selector: Buffer;
18
- };
5
+ import { ContractBase } from './contract_base.js';
19
6
 
20
7
  /**
21
8
  * The Contract class represents a contract and provides utility methods for interacting with it.
@@ -24,58 +11,18 @@ export type ContractMethod = ((...args: any[]) => ContractFunctionInteraction) &
24
11
  * to attach the contract instance to a deployed contract on-chain through the AztecRPCClient, which facilitates
25
12
  * interaction with Aztec's privacy protocol.
26
13
  */
27
- export class Contract {
28
- /**
29
- * An object containing contract methods mapped to their respective names.
30
- */
31
- public methods: { [name: string]: ContractMethod } = {};
32
-
33
- constructor(
34
- /**
35
- * The deployed contract's address.
36
- */
37
- public readonly address: AztecAddress,
38
- /**
39
- * The Application Binary Interface for the contract.
40
- */
41
- public readonly abi: ContractAbi,
42
- /**
43
- * The wallet.
44
- */
45
- protected wallet: Wallet,
46
- ) {
47
- abi.functions.forEach((f: FunctionAbi) => {
48
- const interactionFunction = (...args: any[]) => {
49
- return new ContractFunctionInteraction(this.wallet, this.address!, f, args);
50
- };
51
-
52
- this.methods[f.name] = Object.assign(interactionFunction, {
53
- /**
54
- * A getter for users to fetch the function selector.
55
- * @returns Selector of the function.
56
- */
57
- get selector() {
58
- return generateFunctionSelector(f.name, f.parameters);
59
- },
60
- });
61
- });
62
- }
63
-
14
+ export class Contract extends ContractBase {
64
15
  /**
65
- * Attach the current contract instance to a portal contract and optionally add its dependencies.
66
- * The function will return a promise that resolves when all contracts have been added to the AztecRPCClient.
67
- * This is useful when you need to interact with a deployed contract that has multiple nested contracts.
68
- *
69
- * @param portalContract - The Ethereum address of the portal contract.
70
- * @param dependencies - An optional array of additional DeployedContract instances to be attached.
71
- * @returns A promise that resolves when all contracts are successfully added to the AztecRPCClient.
16
+ * Creates a contract instance.
17
+ * @param address - The deployed contract's address.
18
+ * @param abi - The Application Binary Interface for the contract.
19
+ * @param wallet - The wallet to use when interacting with the contract.
20
+ * @returns A promise that resolves to a new Contract instance.
72
21
  */
73
- attach(portalContract: EthAddress, dependencies: DeployedContract[] = []) {
74
- const deployedContract: DeployedContract = {
75
- abi: this.abi,
76
- address: this.address,
77
- portalContract,
78
- };
79
- return this.wallet.addContracts([deployedContract, ...dependencies]);
22
+ public static async create(address: AztecAddress, abi: ContractAbi, wallet: Wallet): Promise<Contract> {
23
+ if (!(await wallet.isContractDeployed(address))) {
24
+ throw new Error('Contract ' + address.toString() + ' is not deployed');
25
+ }
26
+ return new Contract(address, abi, wallet);
80
27
  }
81
28
  }
@@ -0,0 +1,77 @@
1
+ import { ContractAbi, FunctionAbi, generateFunctionSelector } from '@aztec/foundation/abi';
2
+ import { AztecAddress } from '@aztec/foundation/aztec-address';
3
+ import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { DeployedContract } from '@aztec/types';
5
+
6
+ import { Wallet } from '../aztec_rpc_client/wallet.js';
7
+ import { ContractFunctionInteraction } from './contract_function_interaction.js';
8
+
9
+ /**
10
+ * Type representing a contract method that returns a ContractFunctionInteraction instance
11
+ * and has a readonly 'selector' property of type Buffer. Takes any number of arguments.
12
+ */
13
+ export type ContractMethod = ((...args: any[]) => ContractFunctionInteraction) & {
14
+ /**
15
+ * The unique identifier for a contract function in bytecode.
16
+ */
17
+ readonly selector: Buffer;
18
+ };
19
+
20
+ /**
21
+ * Abstract implementation of a contract extended by the Contract class and generated contract types.
22
+ */
23
+ export abstract class ContractBase {
24
+ /**
25
+ * An object containing contract methods mapped to their respective names.
26
+ */
27
+ public methods: { [name: string]: ContractMethod } = {};
28
+
29
+ protected constructor(
30
+ /**
31
+ * The deployed contract's address.
32
+ */
33
+ public readonly address: AztecAddress,
34
+ /**
35
+ * The Application Binary Interface for the contract.
36
+ */
37
+ public readonly abi: ContractAbi,
38
+ /**
39
+ * The wallet.
40
+ */
41
+ protected wallet: Wallet,
42
+ ) {
43
+ abi.functions.forEach((f: FunctionAbi) => {
44
+ const interactionFunction = (...args: any[]) => {
45
+ return new ContractFunctionInteraction(this.wallet, this.address!, f, args);
46
+ };
47
+
48
+ this.methods[f.name] = Object.assign(interactionFunction, {
49
+ /**
50
+ * A getter for users to fetch the function selector.
51
+ * @returns Selector of the function.
52
+ */
53
+ get selector() {
54
+ return generateFunctionSelector(f.name, f.parameters);
55
+ },
56
+ });
57
+ });
58
+ }
59
+
60
+ /**
61
+ * Attach the current contract instance to a portal contract and optionally add its dependencies.
62
+ * The function will return a promise that resolves when all contracts have been added to the AztecRPCClient.
63
+ * This is useful when you need to interact with a deployed contract that has multiple nested contracts.
64
+ *
65
+ * @param portalContract - The Ethereum address of the portal contract.
66
+ * @param dependencies - An optional array of additional DeployedContract instances to be attached.
67
+ * @returns A promise that resolves when all contracts are successfully added to the AztecRPCClient.
68
+ */
69
+ public attach(portalContract: EthAddress, dependencies: DeployedContract[] = []) {
70
+ const deployedContract: DeployedContract = {
71
+ abi: this.abi,
72
+ address: this.address,
73
+ portalContract,
74
+ };
75
+ return this.wallet.addContracts([deployedContract, ...dependencies]);
76
+ }
77
+ }
@@ -1,5 +1,5 @@
1
1
  import { AztecAddress, Fr, FunctionData, TxContext } from '@aztec/circuits.js';
2
- import { FunctionAbi, FunctionType, encodeArguments, generateFunctionSelector } from '@aztec/foundation/abi';
2
+ import { FunctionAbi, FunctionType, encodeArguments } from '@aztec/foundation/abi';
3
3
  import { ExecutionRequest, Tx, TxExecutionRequest } from '@aztec/types';
4
4
 
5
5
  import { Wallet } from '../aztec_rpc_client/wallet.js';
@@ -44,7 +44,11 @@ export class ContractFunctionInteraction {
44
44
  protected contractAddress: AztecAddress,
45
45
  protected functionDao: FunctionAbi,
46
46
  protected args: any[],
47
- ) {}
47
+ ) {
48
+ if (args.some(arg => arg === undefined || arg === null)) {
49
+ throw new Error('All function interaction arguments must be defined and not null. Received: ' + args);
50
+ }
51
+ }
48
52
 
49
53
  /**
50
54
  * Create an Aztec transaction instance by combining the transaction request and its signature.
@@ -80,19 +84,23 @@ export class ContractFunctionInteraction {
80
84
  return this.tx;
81
85
  }
82
86
 
87
+ /**
88
+ * Returns an execution request that represents this operation. Useful as a building
89
+ * block for constructing batch requests.
90
+ * @param options - An optional object containing additional configuration for the transaction.
91
+ * @returns An execution request.
92
+ */
93
+ public request(options: SendMethodOptions = {}): ExecutionRequest {
94
+ return this.getExecutionRequest(this.contractAddress, options.origin);
95
+ }
96
+
83
97
  protected getExecutionRequest(to: AztecAddress, from?: AztecAddress): ExecutionRequest {
84
98
  const flatArgs = encodeArguments(this.functionDao, this.args);
85
99
  from = from ?? this.wallet.getAddress();
86
100
 
87
- const functionData = new FunctionData(
88
- generateFunctionSelector(this.functionDao.name, this.functionDao.parameters),
89
- this.functionDao.functionType === FunctionType.SECRET,
90
- this.functionDao.name === 'constructor',
91
- );
92
-
93
101
  return {
94
102
  args: flatArgs,
95
- functionData,
103
+ functionData: FunctionData.fromAbi(this.functionDao),
96
104
  to,
97
105
  from,
98
106
  };
@@ -1,3 +1,4 @@
1
1
  export * from './contract.js';
2
2
  export * from './contract_function_interaction.js';
3
3
  export * from './sent_tx.js';
4
+ export * from './contract_base.js';
@@ -6,7 +6,7 @@ import { AztecRPC, TxHash, TxReceipt, TxStatus } from '@aztec/types';
6
6
  * its hash, receipt, and mining status.
7
7
  */
8
8
  export class SentTx {
9
- constructor(private arc: AztecRPC, private txHashPromise: Promise<TxHash>) {}
9
+ constructor(protected arc: AztecRPC, protected txHashPromise: Promise<TxHash>) {}
10
10
 
11
11
  /**
12
12
  * Retrieves the transaction hash of the SentTx instance.
@@ -30,6 +30,19 @@ export class SentTx {
30
30
  return await this.arc.getTxReceipt(txHash);
31
31
  }
32
32
 
33
+ /**
34
+ * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
35
+ * @param timeout - The maximum time (in seconds) to wait for the transaction to be mined. A value of 0 means no timeout.
36
+ * @param interval - The time interval (in seconds) between retries to fetch the transaction receipt.
37
+ * @returns The transaction receipt.
38
+ */
39
+ public async wait(timeout = 0, interval = 1): Promise<TxReceipt> {
40
+ const receipt = await this.waitForReceipt(timeout, interval);
41
+ if (receipt.status !== TxStatus.MINED)
42
+ throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}`);
43
+ return receipt;
44
+ }
45
+
33
46
  /**
34
47
  * Checks whether the transaction is mined or not within the specified timeout and retry interval.
35
48
  * Resolves to true if the transaction status is 'MINED', false otherwise.
@@ -40,8 +53,13 @@ export class SentTx {
40
53
  * @returns A Promise that resolves to a boolean indicating if the transaction is mined or not.
41
54
  */
42
55
  public async isMined(timeout = 0, interval = 1): Promise<boolean> {
56
+ const receipt = await this.waitForReceipt(timeout, interval);
57
+ return receipt.status === TxStatus.MINED;
58
+ }
59
+
60
+ protected async waitForReceipt(timeout = 0, interval = 1): Promise<TxReceipt> {
43
61
  const txHash = await this.getTxHash();
44
- const receipt = await retryUntil(
62
+ return await retryUntil(
45
63
  async () => {
46
64
  const txReceipt = await this.arc.getTxReceipt(txHash);
47
65
  return txReceipt.status != TxStatus.PENDING ? txReceipt : undefined;
@@ -50,6 +68,5 @@ export class SentTx {
50
68
  timeout,
51
69
  interval,
52
70
  );
53
- return receipt.status === TxStatus.MINED;
54
71
  }
55
72
  }
@@ -2,7 +2,6 @@ import { AztecAddress, EthAddress, Fr, Point } from '@aztec/circuits.js';
2
2
  import { ContractAbi, FunctionType } from '@aztec/foundation/abi';
3
3
  import { AztecRPC, PublicKey, Tx, TxHash, TxReceipt } from '@aztec/types';
4
4
 
5
- import { randomBytes } from 'crypto';
6
5
  import { MockProxy, mock } from 'jest-mock-extended';
7
6
 
8
7
  import { ContractDeployer } from './contract_deployer.js';
@@ -16,6 +15,7 @@ describe.skip('Contract Deployer', () => {
16
15
  {
17
16
  name: 'constructor',
18
17
  functionType: FunctionType.SECRET,
18
+ isInternal: false,
19
19
  parameters: [],
20
20
  returnTypes: [],
21
21
  bytecode: '0af',
@@ -24,7 +24,7 @@ describe.skip('Contract Deployer', () => {
24
24
  };
25
25
 
26
26
  const publicKey: PublicKey = Point.random();
27
- const portalContract = new EthAddress(randomBytes(EthAddress.SIZE_IN_BYTES));
27
+ const portalContract = EthAddress.random();
28
28
  const contractAddressSalt = Fr.random();
29
29
  const account = AztecAddress.random();
30
30
  const args = [12, 345n];
@@ -6,9 +6,9 @@ import { DeployMethod } from './deploy_method.js';
6
6
 
7
7
  /**
8
8
  * A class for deploying contract.
9
+ * @remarks Keeping this around even though we have noir contract types because it can be useful for non-TS users.
9
10
  */
10
11
  export class ContractDeployer {
11
- // TODO: remove this?
12
12
  constructor(private abi: ContractAbi, private arc: AztecRPC, private publicKey?: PublicKey) {}
13
13
 
14
14
  /**
@@ -149,10 +149,10 @@ export class DeployMethod extends ContractFunctionInteraction {
149
149
  * @param withWallet - The wallet to provide to the contract abstraction
150
150
  * @returns - The generated contract abstraction.
151
151
  */
152
- public getContract(withWallet: Wallet) {
152
+ public async getContract(withWallet: Wallet) {
153
153
  if (!this.completeContractAddress) {
154
154
  throw new Error(`Cannot get a contract instance for a contract not yet deployed`);
155
155
  }
156
- return new Contract(this.completeContractAddress, this.abi, withWallet);
156
+ return await Contract.create(this.completeContractAddress, this.abi, withWallet);
157
157
  }
158
158
  }
package/src/index.ts CHANGED
@@ -9,4 +9,22 @@ export * from './contract_deployer/deploy_method.js';
9
9
  // export * from '@aztec/aztec-rpc';
10
10
 
11
11
  export { AztecAddress, EthAddress, Point, Fr } from '@aztec/circuits.js';
12
- export { AztecRPC } from '@aztec/types';
12
+ export {
13
+ AztecRPC,
14
+ ContractData,
15
+ ContractDeploymentTx,
16
+ ContractPublicData,
17
+ DeployedContract,
18
+ ExecutionRequest,
19
+ L2BlockL2Logs,
20
+ NodeInfo,
21
+ PackedArguments,
22
+ PublicKey,
23
+ PrivateKey,
24
+ Tx,
25
+ TxExecutionRequest,
26
+ TxHash,
27
+ TxReceipt,
28
+ TxStatus,
29
+ emptyExecutionRequest,
30
+ } from '@aztec/types';
@@ -1,7 +1,6 @@
1
- import { Fr, getContractDeploymentInfo } from '@aztec/circuits.js';
1
+ import { Fr, PrivateKey, getContractDeploymentInfo } from '@aztec/circuits.js';
2
2
  import { Schnorr } from '@aztec/circuits.js/barretenberg';
3
3
  import { ContractAbi } from '@aztec/foundation/abi';
4
- import { randomBytes } from '@aztec/foundation/crypto';
5
4
  import { createDebugLogger } from '@aztec/foundation/log';
6
5
  import { AztecRPC, TxStatus } from '@aztec/types';
7
6
 
@@ -15,7 +14,7 @@ import { AccountCollection, ContractDeployer, SingleKeyAccountContract, generate
15
14
  export async function createAccounts(
16
15
  aztecRpcClient: AztecRPC,
17
16
  accountContractAbi: ContractAbi,
18
- privateKey?: Buffer,
17
+ privateKey?: PrivateKey,
19
18
  salt = Fr.random(),
20
19
  numberOfAccounts = 1,
21
20
  logger = createDebugLogger('aztec:aztec.js:accounts'),
@@ -24,7 +23,7 @@ export async function createAccounts(
24
23
 
25
24
  for (let i = 0; i < numberOfAccounts; ++i) {
26
25
  // TODO(#662): Let the aztec rpc server generate the keypair rather than hardcoding the private key
27
- const privKey = i == 0 && privateKey ? privateKey : randomBytes(32);
26
+ const privKey = i == 0 && privateKey ? privateKey : PrivateKey.random();
28
27
  const publicKey = await generatePublicKey(privKey);
29
28
  const deploymentInfo = await getContractDeploymentInfo(accountContractAbi, [], salt, publicKey);
30
29
  await aztecRpcClient.addAccount(privKey, deploymentInfo.address, deploymentInfo.partialAddress);
@@ -59,7 +58,7 @@ export async function createAccounts(
59
58
  export async function getAccountWallet(
60
59
  aztecRpcClient: AztecRPC,
61
60
  accountContractAbi: ContractAbi,
62
- privateKey: Buffer,
61
+ privateKey: PrivateKey,
63
62
  salt: Fr,
64
63
  ) {
65
64
  const accountCollection = new AccountCollection();
@@ -1,13 +1,12 @@
1
+ import { PrivateKey, PublicKey } from '@aztec/circuits.js';
1
2
  import { Grumpkin } from '@aztec/circuits.js/barretenberg';
2
3
 
3
- import { Point } from '../index.js';
4
-
5
4
  /**
6
5
  * Method for generating a public grumpkin key from a private key.
7
6
  * @param privateKey - The private key.
8
7
  * @returns The generated public key.
9
8
  */
10
- export async function generatePublicKey(privateKey: Buffer): Promise<Point> {
9
+ export async function generatePublicKey(privateKey: PrivateKey): Promise<PublicKey> {
11
10
  const grumpkin = await Grumpkin.new();
12
- return Point.fromBuffer(grumpkin.mul(grumpkin.generator(), privateKey));
11
+ return grumpkin.mul(grumpkin.generator(), privateKey);
13
12
  }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": ".",
3
+ "references": [
4
+ {
5
+ "path": "../circuits.js/tsconfig.dest.json"
6
+ },
7
+ {
8
+ "path": "../foundation/tsconfig.dest.json"
9
+ },
10
+ {
11
+ "path": "../types/tsconfig.dest.json"
12
+ }
13
+ ],
14
+ "exclude": [
15
+ "src/**/*.test.ts"
16
+ ]
17
+ }
@@ -0,0 +1,74 @@
1
+ // import CopyWebpackPlugin from 'copy-webpack-plugin';
2
+ import { createRequire } from 'module';
3
+ import { dirname, resolve } from 'path';
4
+ import path from 'path';
5
+ import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';
6
+ import { fileURLToPath } from 'url';
7
+ import webpack from 'webpack';
8
+
9
+ const require = createRequire(import.meta.url);
10
+
11
+ export default {
12
+ target: 'web',
13
+ mode: 'production',
14
+ devtool: false,
15
+ entry: {
16
+ main: './src/index.ts',
17
+ },
18
+ module: {
19
+ rules: [
20
+ {
21
+ test: /\.tsx?$/,
22
+ use: [
23
+ {
24
+ loader: 'ts-loader',
25
+ options: {
26
+ configFile: 'tsconfig.dest.json',
27
+ },
28
+ },
29
+ ],
30
+ },
31
+ ],
32
+ },
33
+ output: {
34
+ path: resolve(dirname(fileURLToPath(import.meta.url)), './dest'),
35
+ filename: 'main.js',
36
+ library: {
37
+ type: 'module',
38
+ },
39
+ chunkFormat: 'module',
40
+ },
41
+ experiments: {
42
+ outputModule: true,
43
+ },
44
+ plugins: [
45
+ new webpack.DefinePlugin({
46
+ 'process.env': {
47
+ NODE_ENV: JSON.stringify('production'),
48
+ },
49
+ }),
50
+ new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
51
+ ],
52
+ resolve: {
53
+ plugins: [new ResolveTypeScriptPlugin()],
54
+ alias: {
55
+ // All node specific code, wherever it's located, should be imported as below.
56
+ // Provides a clean and simple way to always strip out the node code for the web build.
57
+ './node/index.js': false,
58
+ },
59
+ fallback: {
60
+ crypto: false,
61
+ os: false,
62
+ fs: false,
63
+ path: false,
64
+ url: false,
65
+ worker_threads: false,
66
+ events: require.resolve('events/'),
67
+ buffer: require.resolve('buffer/'),
68
+ util: require.resolve('util/'),
69
+ stream: require.resolve('stream-browserify'),
70
+ string_decoder: require.resolve('string_decoder/'),
71
+ tty: require.resolve('tty-browserify'),
72
+ },
73
+ },
74
+ };
@@ -1,96 +0,0 @@
1
- {
2
- "name": "SchnorrAccount",
3
- "functions": [
4
- {
5
- "name": "constructor",
6
- "functionType": "secret",
7
- "parameters": [],
8
- "returnTypes": []
9
- },
10
- {
11
- "name": "entrypoint",
12
- "functionType": "secret",
13
- "parameters": [
14
- {
15
- "name": "payload",
16
- "type": {
17
- "kind": "struct",
18
- "fields": [
19
- {
20
- "name": "flattened_args_hashes",
21
- "type": {
22
- "kind": "array",
23
- "length": 2,
24
- "type": {
25
- "kind": "field"
26
- }
27
- }
28
- },
29
- {
30
- "name": "flattened_selectors",
31
- "type": {
32
- "kind": "array",
33
- "length": 2,
34
- "type": {
35
- "kind": "field"
36
- }
37
- }
38
- },
39
- {
40
- "name": "flattened_targets",
41
- "type": {
42
- "kind": "array",
43
- "length": 2,
44
- "type": {
45
- "kind": "field"
46
- }
47
- }
48
- },
49
- {
50
- "name": "nonce",
51
- "type": {
52
- "kind": "field"
53
- }
54
- }
55
- ]
56
- },
57
- "visibility": "public"
58
- },
59
- {
60
- "name": "owner",
61
- "type": {
62
- "kind": "array",
63
- "length": 64,
64
- "type": {
65
- "kind": "integer",
66
- "sign": "unsigned",
67
- "width": 8
68
- }
69
- },
70
- "visibility": "public"
71
- },
72
- {
73
- "name": "signature",
74
- "type": {
75
- "kind": "array",
76
- "length": 64,
77
- "type": {
78
- "kind": "integer",
79
- "sign": "unsigned",
80
- "width": 8
81
- }
82
- },
83
- "visibility": "public"
84
- },
85
- {
86
- "name": "partial_address",
87
- "type": {
88
- "kind": "field"
89
- },
90
- "visibility": "public"
91
- }
92
- ],
93
- "returnTypes": []
94
- }
95
- ]
96
- }