Skip to content

Commit

Permalink
feat: rpc provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Nov 21, 2023
1 parent da03c99 commit 0d9c2e5
Show file tree
Hide file tree
Showing 24 changed files with 6,462 additions and 6,148 deletions.
4 changes: 2 additions & 2 deletions __tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
erc20ClassHash,
getTestAccount,
getTestProvider,
} from './fixtures';
import { initializeMatcher } from './schema';
} from './config/fixtures';

Check failure on line 32 in __tests__/account.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/fixtures"

Check failure on line 32 in __tests__/account.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/fixtures"
import { initializeMatcher } from './config/schema';

Check failure on line 33 in __tests__/account.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/schema"

Check failure on line 33 in __tests__/account.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/schema"

const { cleanHex, hexToDecimalString, toBigInt, toHex } = num;
const { encodeShortString } = shortString;
Expand Down
22 changes: 3 additions & 19 deletions __tests__/cairo1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
DeclareDeployUDCResponse,
RawArgsArray,
RawArgsObject,
SequencerProvider,
cairo,
ec,
hash,
Expand All @@ -26,12 +25,11 @@ import {
compiledHelloSierra,
compiledHelloSierraCasm,
describeIfDevnet,
describeIfDevnetSequencer,
describeIfSequencerGoerli,
getTestAccount,
getTestProvider,
} from './fixtures';
import { initializeMatcher } from './schema';
} from './config/fixtures';

Check failure on line 31 in __tests__/cairo1.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/fixtures"

Check failure on line 31 in __tests__/cairo1.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/fixtures"
import { initializeMatcher } from './config/schema';

Check failure on line 32 in __tests__/cairo1.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/schema"

Check failure on line 32 in __tests__/cairo1.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/schema"

const { uint256, tuple, isCairo1Abi } = cairo;
const { toHex } = num;
Expand Down Expand Up @@ -491,15 +489,6 @@ describeIfDevnet('Cairo 1 Devnet', () => {
expect(callDataFromObject).toStrictEqual(expectedResult);
expect(callDataFromArray).toStrictEqual(expectedResult);
});

describeIfDevnetSequencer('Sequencer only', () => {
test('getCompiledClassByClassHash', async () => {
const compiledClass = await (provider as SequencerProvider).getCompiledClassByClassHash(
dd.deploy.classHash
);
expect(compiledClass).toMatchSchemaRef('CompiledClass');
});
});
});

describe('Cairo1 Account contract', () => {
Expand Down Expand Up @@ -562,7 +551,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {

describeIfSequencerGoerli('Cairo1 Testnet', () => {
describe('Sequencer API - C1 Testnet C:0x00305e...', () => {
const provider = getTestProvider() as SequencerProvider;
const provider = getTestProvider();
const account = getTestAccount(provider);
const classHash: any = '0x022332bb9c1e22ae13ae7fd9f3101eced4644533c6bfe51a25cf8dea028e5045';
const contractAddress: any =
Expand All @@ -576,11 +565,6 @@ describeIfSequencerGoerli('Cairo1 Testnet', () => {
cairo1Contract = new Contract(cairoClass.abi as Abi, contractAddress, account);
});

test('getCompiledClassByClassHash', async () => {
const compiledClass = await provider.getCompiledClassByClassHash(classHash);
expect(compiledClass).toMatchSchemaRef('CompiledClass');
});

test('GetClassByHash', async () => {
const classResponse = await provider.getClassByHash(classHash);
expect(classResponse).toMatchSchemaRef('SierraContractClass');
Expand Down
18 changes: 8 additions & 10 deletions __tests__/cairo1_typed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DeclareDeployUDCResponse,
RawArgsArray,
RawArgsObject,
SequencerProvider,
TypedContract,
cairo,
num,
Expand All @@ -22,8 +21,8 @@ import {
compiledHelloSierraCasm,
getTestAccount,
getTestProvider,
} from './fixtures';
import { initializeMatcher } from './schema';
} from './config/fixtures';

Check failure on line 24 in __tests__/cairo1_typed.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/fixtures"

Check failure on line 24 in __tests__/cairo1_typed.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/fixtures"
import { initializeMatcher } from './config/schema';

Check failure on line 25 in __tests__/cairo1_typed.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/schema"

Check failure on line 25 in __tests__/cairo1_typed.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/schema"

const { uint256, tuple, isCairo1Abi } = cairo;
const { toHex } = num;
Expand Down Expand Up @@ -476,23 +475,22 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
});

xtest('getCompiledClassByClassHash', async () => {
const compiledClass = await (provider as SequencerProvider).getCompiledClassByClassHash(
dd.deploy.classHash
);
expect(compiledClass).toMatchSchemaRef('CompiledClass');
// Seqeuncer provider removed
// const compiledClass = await provider.getCompiledClassByClassHash(dd.deploy.classHash);
// expect(compiledClass).toMatchSchemaRef('CompiledClass');
});
});

describe('TS validation for Sequencer API - C1 T2 C:0x771bbe2ba64f... - tests skipped', () => {
const provider = getTestProvider() as SequencerProvider;
const provider = getTestProvider();
const classHash: any = '0x028b6f2ee9ae00d55a32072d939a55a6eb522974a283880f3c73a64c2f9fd6d6';
const contractAddress: any = '0x771bbe2ba64fa5ab52f0c142b4296fc67460a3a2372b4cdce752c620e3e8194';
let cairo1Contract: TypedContract<typeof tAbi>;
initializeMatcher(expect);

xtest('getCompiledClassByClassHash', async () => {
const compiledClass = await provider.getCompiledClassByClassHash(classHash);
expect(compiledClass).toMatchSchemaRef('CompiledClass');
// const compiledClass = await provider.getCompiledClassByClassHash(classHash);
// expect(compiledClass).toMatchSchemaRef('CompiledClass');
});

xtest('GetClassByHash', async () => {
Expand Down
15 changes: 2 additions & 13 deletions __tests__/cairo1v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
DeclareDeployUDCResponse,
RawArgsArray,
RawArgsObject,
SequencerProvider,
cairo,
ec,
hash,
Expand All @@ -31,11 +30,10 @@ import {
compiledC210,
compiledC210Casm,
compiledComplexSierra,
describeIfDevnetSequencer,
getTestAccount,
getTestProvider,
} from './fixtures';
import { initializeMatcher } from './schema';
} from './config/fixtures';

Check failure on line 35 in __tests__/cairo1v2.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/fixtures"

Check failure on line 35 in __tests__/cairo1v2.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/fixtures"
import { initializeMatcher } from './config/schema';

Check failure on line 36 in __tests__/cairo1v2.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/schema"

Check failure on line 36 in __tests__/cairo1v2.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/schema"

const { uint256, tuple, isCairo1Abi } = cairo;
const { toHex } = num;
Expand Down Expand Up @@ -674,15 +672,6 @@ describe('Cairo 1', () => {
expect(callDataFromObject).toStrictEqual(expectedResult);
expect(callDataFromArray).toStrictEqual(expectedResult);
});

describeIfDevnetSequencer('Sequencer only', () => {
test('getCompiledClassByClassHash', async () => {
const compiledClass = await (provider as SequencerProvider).getCompiledClassByClassHash(
dd.deploy.classHash
);
expect(compiledClass).toMatchSchemaRef('CompiledClass');
});
});
});

describe('Cairo1 Account contract', () => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
describeIfDevnet,
getTestAccount,
getTestProvider,
} from './fixtures';
import { initializeMatcher } from './schema';
} from './config/fixtures';

Check failure on line 25 in __tests__/contract.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/fixtures"

Check failure on line 25 in __tests__/contract.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/fixtures"
import { initializeMatcher } from './config/schema';

Check failure on line 26 in __tests__/contract.test.ts

View workflow job for this annotation

GitHub Actions / Run test on sequencer-devnet / Run tests

Missing file extension for "./config/schema"

Check failure on line 26 in __tests__/contract.test.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Missing file extension for "./config/schema"

describe('contract module', () => {
let erc20Address: string;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/defaultProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
getTestAccount,
getTestProvider,
wrongClassHash,
} from './fixtures';
import { initializeMatcher } from './schema';
} from './config/fixtures';
import { initializeMatcher } from './config/schema';

const testProvider = new Provider(getTestProvider());

Expand Down
86 changes: 0 additions & 86 deletions __tests__/fixtures.ts

This file was deleted.

36 changes: 0 additions & 36 deletions __tests__/jest.setup.ts

This file was deleted.

Loading

0 comments on commit 0d9c2e5

Please sign in to comment.