Skip to content

Commit

Permalink
fix: prevent missusage of cairoVersion on deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Apr 25, 2023
1 parent ef34e0a commit d920dbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 13 additions & 3 deletions __tests__/cairo1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ describeIfDevnetSequencer('Cairo 1', () => {
describe('Sequencer API', () => {
const provider = getTestProvider() as SequencerProvider;
const account = getTestAccount(provider);
let classHash: any; // = '0x3e2e625998f89befe4d429d5d958275f86421310bfb00440c2431140e8c90ba';
const classHash: any = '0x3e2e625998f89befe4d429d5d958275f86421310bfb00440c2431140e8c90ba';
let contractAddress: any;
let declareV2Tx: any;
let cairo1Contract: Contract;
initializeMatcher(expect);

beforeAll(async () => {
declareV2Tx = await account.declare({
/* declareV2Tx = await account.declare({
contract: compiledHelloSierra,
casm: compiledHelloSierraCasm,
});
classHash = declareV2Tx.class_hash;
await provider.waitForTransaction(declareV2Tx.transaction_hash);
await provider.waitForTransaction(declareV2Tx.transaction_hash); */
const { transaction_hash, contract_address } = await account.deploy({ classHash });
[contractAddress] = contract_address;
await provider.waitForTransaction(transaction_hash);
Expand All @@ -48,6 +48,16 @@ describeIfDevnetSequencer('Cairo 1', () => {
});
});

test('deployContract Cairo 1 with false cairoVersion UDC parameter', async () => {
const deploy = await account.deployContract(
{
classHash,
},
{ cairoVersion: '1' }
);
expect(deploy).toHaveProperty('address');
});

test('getCompiledClassByClassHash', async () => {
const compiledClass = await provider.getCompiledClassByClassHash(classHash);
expect(compiledClass).toMatchSchemaRef('CompiledClass');
Expand Down
5 changes: 4 additions & 1 deletion src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ export class Account extends Provider implements AccountInterface {

const calls = params.map((it) => it.call);
const addresses = params.map((it) => it.address);
const invokeResponse = await this.execute(calls, undefined, details);
const invokeResponse = await this.execute(calls, undefined, {
...details,
cairoVersion: '0', // UDC is Cairo0 Contract
});

return {
...invokeResponse,
Expand Down

0 comments on commit d920dbe

Please sign in to comment.