Skip to content

Commit

Permalink
switch to token contract, copy e2e test but not done with it
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-aztec committed Sep 20, 2023
1 parent 4811ad3 commit 2b41136
Show file tree
Hide file tree
Showing 12 changed files with 5,226 additions and 624 deletions.
106 changes: 0 additions & 106 deletions yarn-project/boxes/private-token/src/artifacts/private_token.ts

This file was deleted.

This file was deleted.

177 changes: 177 additions & 0 deletions yarn-project/boxes/private-token/src/artifacts/token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/* Autogenerated file, do not edit! */

/* eslint-disable */
import {
AztecAddress,
CompleteAddress,
ContractBase,
ContractFunctionInteraction,
ContractMethod,
DeployMethod,
FieldLike,
Wallet,
} from '@aztec/aztec.js';
import { ContractAbi } from '@aztec/foundation/abi';
import { Point } from '@aztec/foundation/fields';
import { AztecRPC, PublicKey } from '@aztec/types';

import TokenContractAbiJson from './token_contract.json' assert { type: 'json' };

export const TokenContractAbi = TokenContractAbiJson as ContractAbi;

/**
* Type-safe interface for contract Token;
*/
export class TokenContract extends ContractBase {
private constructor(
/** The deployed contract's complete address. */
completeAddress: CompleteAddress,
/** The wallet. */
wallet: Wallet,
) {
super(completeAddress, TokenContractAbi, wallet);
}

/**
* Creates a contract instance.
* @param address - The deployed contract's address.
* @param wallet - The wallet to use when interacting with the contract.
* @returns A promise that resolves to a new Contract instance.
*/
public static async at(
/** The deployed contract's address. */
address: AztecAddress,
/** The wallet. */
wallet: Wallet,
) {
const extendedContractData = await wallet.getExtendedContractData(address);
if (extendedContractData === undefined) {
throw new Error('Contract ' + address.toString() + ' is not deployed');
}
return new TokenContract(extendedContractData.getCompleteAddress(), wallet);
}

/**
* Creates a tx to deploy a new instance of this contract.
*/
public static deploy(rpc: AztecRPC) {
return new DeployMethod<TokenContract>(Point.ZERO, rpc, TokenContractAbi, Array.from(arguments).slice(1));
}

/**
* Creates a tx to deploy a new instance of this contract using the specified public key to derive the address.
*/
public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey) {
return new DeployMethod<TokenContract>(publicKey, rpc, TokenContractAbi, Array.from(arguments).slice(2));
}

/**
* Returns this contract's ABI.
*/
public static get abi(): ContractAbi {
return TokenContractAbi;
}

/** Type-safe wrappers for the public methods exposed by the contract. */
public methods!: {
/** _increase_public_balance(to: struct, amount: field) */
_increase_public_balance: ((to: { address: FieldLike }, amount: FieldLike) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** _initialize(new_admin: struct) */
_initialize: ((new_admin: { address: FieldLike }) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** _reduce_total_supply(amount: field) */
_reduce_total_supply: ((amount: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** admin() */
admin: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** balance_of_private(owner: struct) */
balance_of_private: ((owner: { address: FieldLike }) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** balance_of_public(owner: struct) */
balance_of_public: ((owner: { address: FieldLike }) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** burn(from: struct, amount: field, nonce: field) */
burn: ((from: { address: FieldLike }, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** burn_public(from: struct, amount: field, nonce: field) */
burn_public: ((from: { address: FieldLike }, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** compute_note_hash_and_nullifier(contract_address: field, nonce: field, storage_slot: field, preimage: array) */
compute_note_hash_and_nullifier: ((
contract_address: FieldLike,
nonce: FieldLike,
storage_slot: FieldLike,
preimage: FieldLike[],
) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** is_minter(minter: struct) */
is_minter: ((minter: { address: FieldLike }) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** mint_private(amount: field, secret_hash: field) */
mint_private: ((amount: FieldLike, secret_hash: FieldLike) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** mint_public(to: struct, amount: field) */
mint_public: ((to: { address: FieldLike }, amount: FieldLike) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** redeem_shield(to: struct, amount: field, secret: field) */
redeem_shield: ((to: { address: FieldLike }, amount: FieldLike, secret: FieldLike) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** set_admin(new_admin: struct) */
set_admin: ((new_admin: { address: FieldLike }) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** set_minter(minter: struct, approve: boolean) */
set_minter: ((minter: { address: FieldLike }, approve: boolean) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** shield(from: struct, amount: field, secret_hash: field, nonce: field) */
shield: ((
from: { address: FieldLike },
amount: FieldLike,
secret_hash: FieldLike,
nonce: FieldLike,
) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** total_supply() */
total_supply: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** transfer(from: struct, to: struct, amount: field, nonce: field) */
transfer: ((
from: { address: FieldLike },
to: { address: FieldLike },
amount: FieldLike,
nonce: FieldLike,
) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** transfer_public(from: struct, to: struct, amount: field, nonce: field) */
transfer_public: ((
from: { address: FieldLike },
to: { address: FieldLike },
amount: FieldLike,
nonce: FieldLike,
) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;

/** unshield(from: struct, to: struct, amount: field, nonce: field) */
unshield: ((
from: { address: FieldLike },
to: { address: FieldLike },
amount: FieldLike,
nonce: FieldLike,
) => ContractFunctionInteraction) &
Pick<ContractMethod, 'selector'>;
};
}
Loading

0 comments on commit 2b41136

Please sign in to comment.