1- import { isBN } from 'bn.js' ;
2-
3- import { Account , Contract , RpcProvider } from '../src' ;
4- import { toBN } from '../src/utils/number' ;
5- import { compiledErc20 , describeIfRpc , getTestAccount , getTestProvider } from './fixtures' ;
1+ import { RpcProvider } from '../src' ;
2+ import { describeIfRpc , getTestProvider } from './fixtures' ;
63
74describeIfRpc ( 'RPCProvider' , ( ) => {
85 let provider : RpcProvider ;
@@ -17,61 +14,4 @@ describeIfRpc('RPCProvider', () => {
1714 expect ( chainId ) . toBe ( '0x534e5f474f45524c49' ) ;
1815 } ) ;
1916 } ) ;
20-
21- describe ( 'Account' , ( ) => {
22- let account : Account ;
23- let erc20Address : string ;
24- let erc20 : Contract ;
25-
26- beforeAll ( async ( ) => {
27- account = getTestAccount ( provider ) ;
28- expect ( account ) . toBeInstanceOf ( Account ) ;
29-
30- const erc20Response = await provider . deployContract ( {
31- contract : compiledErc20 ,
32- } ) ;
33-
34- erc20Address = erc20Response . contract_address ;
35- erc20 = new Contract ( compiledErc20 . abi , erc20Address , provider ) ;
36-
37- await provider . waitForTransaction ( erc20Response . transaction_hash ) ;
38- erc20 = new Contract ( compiledErc20 . abi , erc20Address , provider ) ;
39-
40- const mintResponse = await account . execute ( {
41- contractAddress : erc20Address ,
42- entrypoint : 'mint' ,
43- calldata : [ account . address , '1000' ] ,
44- } ) ;
45-
46- await provider . waitForTransaction ( mintResponse . transaction_hash ) ;
47- } ) ;
48-
49- test ( 'estimate fee' , async ( ) => {
50- const { overall_fee, gas_consumed, gas_price } = await account . estimateFee ( {
51- contractAddress : erc20Address ,
52- entrypoint : 'transfer' ,
53- calldata : [ erc20 . address , '10' ] ,
54- } ) ;
55-
56- expect ( isBN ( overall_fee ) ) . toBe ( true ) ;
57- expect ( isBN ( gas_consumed ) ) . toBe ( true ) ;
58- expect ( isBN ( gas_price ) ) . toBe ( true ) ;
59- } ) ;
60-
61- test ( 'execute by wallet owner' , async ( ) => {
62- const { res : before } = await erc20 . balance_of ( account . address ) ;
63-
64- const { transaction_hash } = await account . execute ( {
65- contractAddress : erc20Address ,
66- entrypoint : 'transfer' ,
67- calldata : [ erc20 . address , '10' ] ,
68- } ) ;
69-
70- await account . waitForTransaction ( transaction_hash ) ;
71-
72- const { res : after } = await erc20 . balance_of ( account . address ) ;
73-
74- expect ( toBN ( before ) . sub ( toBN ( after ) ) . toString ( 10 ) ) . toBe ( '10' ) ;
75- } ) ;
76- } ) ;
7717} ) ;
0 commit comments