@@ -53,7 +53,7 @@ describe('Wallet', () => {
53
53
expect ( wallet . apiVersion ) . toBe ( '0.1.0' ) ;
54
54
expect ( typeof wallet . name ) . toBe ( 'string' ) ;
55
55
expect ( wallet . name ) . toBe ( testWallet . properties . walletName ) ;
56
- expect ( wallet . supportedExtensions ) . toEqual < WalletApiExtension [ ] > ( [ { cip : 95 } ] ) ;
56
+ expect ( wallet . supportedExtensions ) . toEqual < WalletApiExtension [ ] > ( [ { cip : 95 } , { cip : 142 } ] ) ;
57
57
expect ( typeof wallet . isEnabled ) . toBe ( 'function' ) ;
58
58
const isEnabled = await wallet . isEnabled ( ) ;
59
59
expect ( typeof isEnabled ) . toBe ( 'boolean' ) ;
@@ -98,6 +98,30 @@ describe('Wallet', () => {
98
98
expect ( await api . getExtensions ( ) ) . toEqual ( [ { cip : 95 } ] ) ;
99
99
} ) ;
100
100
101
+ test ( 'with cip142 extension' , async ( ) => {
102
+ const api = await wallet . enable ( { extensions : [ { cip : 142 } ] } ) ;
103
+ expect ( typeof api ) . toBe ( 'object' ) ;
104
+ const methods = new Set ( Object . keys ( api ) ) ;
105
+ expect ( methods ) . toEqual ( new Set ( [ ...CipMethodsMapping [ 30 ] , 'cip142' , 'experimental' ] ) ) ;
106
+ const cip142Methods = new Set ( Object . keys ( api . cip142 ! ) ) ;
107
+ expect ( cip142Methods ) . toEqual ( new Set ( CipMethodsMapping [ 142 ] ) ) ;
108
+ expect ( await wallet . isEnabled ( ) ) . toBe ( true ) ;
109
+ expect ( await api . getExtensions ( ) ) . toEqual ( [ { cip : 142 } ] ) ;
110
+ } ) ;
111
+
112
+ test ( 'with cip95 and cip142 extensions' , async ( ) => {
113
+ const api = await wallet . enable ( { extensions : [ { cip : 95 } , { cip : 142 } ] } ) ;
114
+ expect ( typeof api ) . toBe ( 'object' ) ;
115
+ const methods = new Set ( Object . keys ( api ) ) ;
116
+ expect ( methods ) . toEqual ( new Set ( [ ...CipMethodsMapping [ 30 ] , 'cip95' , 'cip142' , 'experimental' ] ) ) ;
117
+ const cip95Methods = new Set ( Object . keys ( api . cip95 ! ) ) ;
118
+ expect ( cip95Methods ) . toEqual ( new Set ( CipMethodsMapping [ 95 ] ) ) ;
119
+ const cip142Methods = new Set ( Object . keys ( api . cip142 ! ) ) ;
120
+ expect ( cip142Methods ) . toEqual ( new Set ( CipMethodsMapping [ 142 ] ) ) ;
121
+ expect ( await wallet . isEnabled ( ) ) . toBe ( true ) ;
122
+ expect ( await api . getExtensions ( ) ) . toEqual ( [ { cip : 95 } , { cip : 142 } ] ) ;
123
+ } ) ;
124
+
101
125
test ( 'no extensions wallet cannot enable cip95 extension' , async ( ) => {
102
126
const api = await walletNoExtensions . enable ( { extensions : [ { cip : 95 } ] } ) ;
103
127
expect ( await walletNoExtensions . isEnabled ( ) ) . toBe ( true ) ;
@@ -112,13 +136,15 @@ describe('Wallet', () => {
112
136
expect ( await wallet . isEnabled ( ) ) . toBe ( true ) ;
113
137
expect ( await cip30api . getExtensions ( ) ) . toEqual ( [ ] ) ;
114
138
115
- const cip95api = await wallet . enable ( { extensions : [ { cip : 95 } ] } ) ;
116
- const cip95methods = new Set ( Object . keys ( cip95api ) ) ;
117
- expect ( cip95methods ) . toEqual ( new Set ( [ ...CipMethodsMapping [ 30 ] , 'cip95' , 'experimental' ] ) ) ;
118
- const cip95InnerMethods = new Set ( Object . keys ( cip95api . cip95 ! ) ) ;
139
+ const apiWithExtension = await wallet . enable ( { extensions : [ { cip : 95 } , { cip : 142 } ] } ) ;
140
+ const cip95methods = new Set ( Object . keys ( apiWithExtension ) ) ;
141
+ expect ( cip95methods ) . toEqual ( new Set ( [ ...CipMethodsMapping [ 30 ] , 'cip95' , 'cip142' , ' experimental'] ) ) ;
142
+ const cip95InnerMethods = new Set ( Object . keys ( apiWithExtension . cip95 ! ) ) ;
119
143
expect ( cip95InnerMethods ) . toEqual ( new Set ( CipMethodsMapping [ 95 ] ) ) ;
144
+ const cip142Methods = new Set ( Object . keys ( apiWithExtension . cip142 ! ) ) ;
145
+ expect ( cip142Methods ) . toEqual ( new Set ( CipMethodsMapping [ 142 ] ) ) ;
120
146
expect ( await wallet . isEnabled ( ) ) . toBe ( true ) ;
121
- expect ( await cip95api . getExtensions ( ) ) . toEqual ( [ { cip : 95 } ] ) ;
147
+ expect ( await apiWithExtension . getExtensions ( ) ) . toEqual ( [ { cip : 95 } , { cip : 142 } ] ) ;
122
148
} ) ;
123
149
124
150
test ( 'unsupported extensions does not reject and returns cip30 methods' , async ( ) => {
0 commit comments