@@ -152,12 +152,17 @@ export class Provider implements IProvider {
152152 if ( this . address . length > 0 ) {
153153 return this . address
154154 }
155- const result = ( await callIframe ( 'pages/dapp/auth' , {
156- appId : this . appId ,
157- params : params ? JSON . stringify ( params ) : '' ,
158- chainId : ( await this . request ( { method : 'cfx_chainId' } ) ) as string ,
159- authType : 'account' ,
160- } ) ) as IAuthResult
155+ console . log ( 'cfx_accounts参数' , paramsObj )
156+ const result = ( await callIframe (
157+ 'pages/dapp/auth' ,
158+ {
159+ appId : this . appId ,
160+ params : params ? JSON . stringify ( paramsObj ) : '' ,
161+ chainId : ( await this . request ( { method : 'cfx_chainId' } ) ) as string ,
162+ authType : 'account' ,
163+ } ,
164+ this
165+ ) ) as IAuthResult
161166 setCache ( result , this )
162167 this . events . onAccountsChanged &&
163168 this . events . onAccountsChanged ( result . address )
@@ -168,47 +173,61 @@ export class Provider implements IProvider {
168173 return this . address
169174 case 'cfx_sendTransaction' :
170175 try {
171- return await callIframe ( 'pages/dapp/auth' , {
172- appId : this . appId ,
173- chainId : ( await this . request ( { method : 'cfx_chainId' } ) ) as string ,
174- params : params ? JSON . stringify ( paramsObj ) : '' ,
175- authType :
176- params && Object . keys ( paramsObj ) . includes ( 'to' ) && paramsObj [ 'to' ]
177- ? getAddressType ( paramsObj [ 'to' ] as string ) ===
178- AddressType . CONTRACT
179- ? 'callContract'
180- : 'createTransaction'
181- : 'createContract' ,
182- } )
176+ return await callIframe (
177+ 'pages/dapp/auth' ,
178+ {
179+ appId : this . appId ,
180+ chainId : ( await this . request ( {
181+ method : 'cfx_chainId' ,
182+ } ) ) as string ,
183+ params : params ? JSON . stringify ( paramsObj ) : '' ,
184+ authType :
185+ params &&
186+ Object . keys ( paramsObj ) . includes ( 'to' ) &&
187+ paramsObj [ 'to' ]
188+ ? getAddressType ( paramsObj [ 'to' ] as string ) ===
189+ AddressType . CONTRACT
190+ ? 'callContract'
191+ : 'createTransaction'
192+ : 'createContract' ,
193+ } ,
194+ this
195+ )
183196 } catch ( e ) {
184197 console . error ( 'Error to sendTransaction' , e )
185198 return e
186199 }
187200 case 'anyweb_importAccount' :
188201 try {
189- return await callIframe ( 'pages/dapp/auth' , {
190- appId : this . appId ,
191- chainId : ( await this . request ( { method : 'cfx_chainId' } ) ) as string ,
192- params : params ? JSON . stringify ( paramsObj ) : JSON . stringify ( [ ] ) ,
193- authType : 'importAccount' ,
194- } )
202+ return await callIframe (
203+ 'pages/dapp/auth' ,
204+ {
205+ appId : this . appId ,
206+ chainId : ( await this . request ( {
207+ method : 'cfx_chainId' ,
208+ } ) ) as string ,
209+ params : params ? JSON . stringify ( paramsObj ) : JSON . stringify ( [ ] ) ,
210+ authType : 'importAccount' ,
211+ } ,
212+ this
213+ )
195214 } catch ( e ) {
196215 console . error ( 'Error to import Address' , e )
197216 return e
198217 }
199218 case 'anyweb_version' :
200219 return config . version
201220 case 'anyweb_home' :
202- return await callIframe ( 'pages/index/home' , {
203- appId : this . appId ,
204- chainId : ( await this . request ( { method : 'cfx_chainId' } ) ) as string ,
205- params : params
206- ? JSON . stringify (
207- Array . isArray ( params ) && params . length > 0 ? params [ 0 ] : params
208- )
209- : '' ,
210- waitResult : false ,
211- } )
221+ return await callIframe (
222+ 'pages/index/home' ,
223+ {
224+ appId : this . appId ,
225+ chainId : ( await this . request ( { method : 'cfx_chainId' } ) ) as string ,
226+ params : params ? JSON . stringify ( paramsObj ) : '' ,
227+ waitResult : false ,
228+ } ,
229+ this
230+ )
212231 default :
213232 return 'Unsupported method'
214233 }
0 commit comments