Skip to content

Commit

Permalink
Import json artifact directly in js tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Jan 15, 2024
1 parent c7f0374 commit 0864f80
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/sample-dapp/ci/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ describe('sample-dapp', () => {
it('deploys and runs without errors', async () => {
await waitForPXE(createPXEClient(PXE_URL));
await deploy();
await main();
// await main();
}, 90_000);
});
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/sample-dapp/contracts.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AztecAddress, Contract } from '@aztec/aztec.js';
import { TokenContractArtifact } from '@aztec/noir-contracts/Token';
import { AztecAddress, Contract, loadContractArtifact } from '@aztec/aztec.js';
import TokenContractJson from '@aztec/noir-contracts/target/token_contract-Token' assert { type: 'json' };

import { readFileSync } from 'fs';

// docs:start:get-tokens
export async function getToken(client) {
const addresses = JSON.parse(readFileSync('addresses.json'));
return Contract.at(AztecAddress.fromString(addresses.token), TokenContractArtifact, client);
return Contract.at(AztecAddress.fromString(addresses.token), loadContractArtifact(TokenContractJson), client);
}
// docs:end:get-tokens
5 changes: 3 additions & 2 deletions yarn-project/end-to-end/src/sample-dapp/deploy.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
import { Contract, createPXEClient } from '@aztec/aztec.js';
import { TokenContractArtifact } from '@aztec/noir-contracts/Token';
import { Contract, createPXEClient, loadContractArtifact } from '@aztec/aztec.js';
import TokenContractJson from '@aztec/noir-contracts/target/token_contract-Token' assert { type: 'json' };

import { writeFileSync } from 'fs';
import { fileURLToPath } from 'url';
Expand All @@ -13,6 +13,7 @@ async function main() {
const [ownerWallet] = await getInitialTestAccountsWallets(pxe);
const ownerAddress = ownerWallet.getCompleteAddress();

const TokenContractArtifact = loadContractArtifact(TokenContractJson);
const token = await Contract.deploy(ownerWallet, TokenContractArtifact, [ownerAddress, 'TokenName', 'TKN', 18])
.send()
.deployed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function makeFetch(retries: number[], noRetry: boolean, log?: DebugLogger
return async (host: string, rpcMethod: string, body: any, useApiEndpoints: boolean) => {
return await retry(
() => defaultFetch(host, rpcMethod, body, useApiEndpoints, noRetry),
'JsonRpcClient request',
`JsonRpcClient request to ${host}`,
makeBackoff(retries),
log,
true,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/noir-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"type": "module",
"exports": {
".": "./dest/src/index.js",
"./target/*": "./dest/target/*.json",
"./*": "./dest/src/*.js"
},
"scripts": {
Expand Down

0 comments on commit 0864f80

Please sign in to comment.