Skip to content

Commit 7e10e53

Browse files
chore: rename abi-wan-kanabi to abi-wan-kanabi-v1 (#942)
This avoid `npx abi-wan-kanabi` to use the installed version and forces it to get the latest version from npm
1 parent f1744b8 commit 7e10e53

File tree

6 files changed

+61
-16
lines changed

6 files changed

+61
-16
lines changed

__tests__/cairo1_typed.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
DeclareDeployUDCResponse,
1010
RawArgsArray,
1111
RawArgsObject,
12-
TypedContract,
12+
TypedContractV1,
1313
cairo,
1414
num,
1515
selector,
@@ -35,7 +35,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
3535
const provider = getTestProvider();
3636
const account = getTestAccount(provider);
3737
let dd: DeclareDeployUDCResponse;
38-
let cairo1Contract: TypedContract<typeof tAbi>;
38+
let cairo1Contract: TypedContractV1<typeof tAbi>;
3939
initializeMatcher(expect);
4040

4141
beforeAll(async () => {
@@ -48,7 +48,7 @@ describeIfDevnet('Cairo 1 Devnet', () => {
4848
compiledHelloSierra.abi,
4949
dd.deploy.contract_address,
5050
account
51-
).typed(tAbi);
51+
).typedv1(tAbi);
5252
});
5353

5454
test('Declare & deploy v2 - Hello Cairo 1 contract', async () => {
@@ -503,7 +503,7 @@ describeIfSequencerGoerli('Cairo1 Testnet', () => {
503503
const classHash: any = '0x028b6f2ee9ae00d55a32072d939a55a6eb522974a283880f3c73a64c2f9fd6d6';
504504
const contractAddress: any =
505505
'0x771bbe2ba64fa5ab52f0c142b4296fc67460a3a2372b4cdce752c620e3e8194';
506-
let cairo1Contract: TypedContract<typeof tAbi>;
506+
let cairo1Contract: TypedContractV1<typeof tAbi>;
507507
initializeMatcher(expect);
508508

509509
test('GetClassByHash', async () => {

package-lock.json

Lines changed: 48 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@types/url-join": "^4.0.1",
6868
"@typescript-eslint/eslint-plugin": "^5.28.0",
6969
"@typescript-eslint/parser": "^5.28.0",
70-
"abi-wan-kanabi": "^1.0.3",
70+
"abi-wan-kanabi-v1": "npm:abi-wan-kanabi@^1.0.3",
7171
"abi-wan-kanabi-v2": "npm:abi-wan-kanabi@^2.1.0",
7272
"ajv": "^8.12.0",
7373
"ajv-keywords": "^5.1.0",

src/contract/default.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { CallData, cairo } from '../utils/calldata';
3131
import { createAbiParser } from '../utils/calldata/parser';
3232
import { getAbiEvents, parseEvents as parseRawEvents } from '../utils/events/index';
3333
import { cleanHex } from '../utils/num';
34-
import { ContractInterface, TypedContract } from './interface';
34+
import { ContractInterface, TypedContractV1 } from './interface';
3535

3636
export type TypedContractV2<TAbi extends AbiKanabiV2> = AbiWanTypedContractV2<TAbi> & Contract;
3737

@@ -349,8 +349,8 @@ export class Contract implements ContractInterface {
349349
return this.providerOrAccount.getContractVersion(this.address);
350350
}
351351

352-
public typed<TAbi extends AbiKanabi>(tAbi: TAbi): TypedContract<TAbi> {
353-
return this as TypedContract<typeof tAbi>;
352+
public typedv1<TAbi extends AbiKanabi>(tAbi: TAbi): TypedContractV1<TAbi> {
353+
return this as TypedContractV1<typeof tAbi>;
354354
}
355355

356356
public typedv2<TAbi extends AbiKanabiV2>(tAbi: TAbi): TypedContractV2<TAbi> {

src/contract/interface.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Abi as AbiKanabi, TypedContract as AbiWanTypedContract } from 'abi-wan-kanabi';
1+
import type { Abi as AbiKanabiV1, TypedContract as AbiWanTypedContractV1 } from 'abi-wan-kanabi-v1';
22
import type { Abi as AbiKanabiV2, TypedContract as AbiWanTypedContractV2 } from 'abi-wan-kanabi-v2';
33

44
import { AccountInterface } from '../account';
@@ -42,7 +42,8 @@ declare module 'abi-wan-kanabi-v2' {
4242
}
4343
}
4444

45-
export type TypedContract<TAbi extends AbiKanabi> = AbiWanTypedContract<TAbi> & ContractInterface;
45+
export type TypedContractV1<TAbi extends AbiKanabiV1> = AbiWanTypedContractV1<TAbi> &
46+
ContractInterface;
4647
type TypedContractV2<TAbi extends AbiKanabiV2> = AbiWanTypedContractV2<TAbi> & ContractInterface;
4748

4849
export abstract class ContractInterface {
@@ -162,6 +163,6 @@ export abstract class ContractInterface {
162163
*/
163164
public abstract getVersion(): Promise<ContractVersion>;
164165

165-
public abstract typed<TAbi extends AbiKanabi>(tAbi: TAbi): TypedContract<TAbi>;
166+
public abstract typedv1<TAbi extends AbiKanabiV1>(tAbi: TAbi): TypedContractV1<TAbi>;
166167
public abstract typedv2<TAbi extends AbiKanabiV2>(tAbi: TAbi): TypedContractV2<TAbi>;
167168
}

www/versioned_docs/version-5.19.5/guides/automatic_cairo_ABI_parsing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import { tAbi } from '../__mocks__/hello';
6363

6464
let cairo1Contract = new Contract(compiledHelloSierra.abi, dd.deploy.contract_address, account);
6565

66-
let cairo1ContractTyped = cairo1Contract.typed(tAbi);
66+
let cairo1ContractTyped = cairo1Contract.typedv1(tAbi); // or typedv2(tAbi) if you are using Cairo compiler v2
6767

6868
cairo1ContractTyped.test_bool();
6969
```

0 commit comments

Comments
 (0)