1
1
import { getStarkKey , Signature , utils } from '@scure/starknet' ;
2
+ import { hasMixin } from 'ts-mixer' ;
3
+ import {
4
+ contracts ,
5
+ createBlockForDevnet ,
6
+ createTestProvider ,
7
+ describeIfDevnet ,
8
+ describeIfNotDevnet ,
9
+ describeIfRpc ,
10
+ describeIfTestnet ,
11
+ ETHtokenAddress ,
12
+ getTestAccount ,
13
+ waitNextBlock ,
14
+ } from './config/fixtures' ;
15
+ import { initializeMatcher } from './config/schema' ;
2
16
import typedDataExample from '../__mocks__/typedData/baseExample.json' ;
3
17
import {
4
18
Account ,
5
19
Block ,
6
20
CallData ,
7
21
Contract ,
8
22
FeeEstimate ,
23
+ LibraryError ,
9
24
ProviderInterface ,
10
25
RPC ,
11
26
RPCResponseParser ,
@@ -19,21 +34,11 @@ import {
19
34
import { StarknetChainId } from '../src/global/constants' ;
20
35
import { felt , uint256 } from '../src/utils/calldata/cairo' ;
21
36
import { toBigInt , toHexString } from '../src/utils/num' ;
22
- import {
23
- contracts ,
24
- createBlockForDevnet ,
25
- createTestProvider ,
26
- describeIfDevnet ,
27
- describeIfNotDevnet ,
28
- describeIfRpc ,
29
- describeIfTestnet ,
30
- ETHtokenAddress ,
31
- getTestAccount ,
32
- waitNextBlock ,
33
- } from './config/fixtures' ;
34
- import { initializeMatcher } from './config/schema' ;
35
- import { isBoolean } from '../src/utils/typed' ;
36
37
import { isVersion } from '../src/utils/provider' ;
38
+ import { isBoolean } from '../src/utils/typed' ;
39
+ import { RpcProvider as BaseRpcProvider } from '../src/provider/rpc' ;
40
+ import { RpcProvider as ExtendedRpcProvider } from '../src/provider/extensions/default' ;
41
+ import { StarknetId } from '../src/provider/extensions/starknetId' ;
37
42
38
43
describeIfRpc ( 'RPCProvider' , ( ) => {
39
44
let rpcProvider : RpcProvider ;
@@ -53,6 +58,16 @@ describeIfRpc('RPCProvider', () => {
53
58
await createBlockForDevnet ( ) ;
54
59
} ) ;
55
60
61
+ test ( 'create should be usable by the base and extended RpcProvider, but not Account' , async ( ) => {
62
+ const nodeUrl = process . env . TEST_RPC_URL ;
63
+ const base = await BaseRpcProvider . create ( { nodeUrl } ) ;
64
+ const extended = await ExtendedRpcProvider . create ( { nodeUrl } ) ;
65
+
66
+ expect ( hasMixin ( base , StarknetId ) ) . toBe ( false ) ;
67
+ expect ( hasMixin ( extended , StarknetId ) ) . toBe ( true ) ;
68
+ await expect ( Account . create ( ) ) . rejects . toThrow ( LibraryError ) ;
69
+ } ) ;
70
+
56
71
test ( 'detect spec version with create' , async ( ) => {
57
72
const providerTest = await RpcProvider . create ( { nodeUrl : process . env . TEST_RPC_URL } ) ;
58
73
const { channel } = providerTest ;
0 commit comments