File tree Expand file tree Collapse file tree 4 files changed +34
-4
lines changed
Expand file tree Collapse file tree 4 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -620,11 +620,14 @@ export class Signer {
620620 } as any ) ,
621621 sign : ( ) => this . _sign < T > ( txs as any ) ,
622622 broadcast : function ( options ?: BroadcastOptions ) {
623- return (
624- this . sign ( )
623+ if ( _this . currentProvider ?. isSignAndBroadcastByProvider === true ) {
624+ return _this . currentProvider
625+ . sign ( txs ) ;
626+ } else {
627+ return this . sign ( )
625628 // @ts -ignore
626- . then ( ( txs ) => _this . broadcast ( txs , options ) ) as any
627- ) ;
629+ . then ( ( txs ) => _this . broadcast ( txs , options ) ) as any ;
630+ }
628631 } ,
629632 } ;
630633 }
@@ -678,6 +681,15 @@ export class Signer {
678681 private _sign < T extends SignerTx > ( toSign : T [ ] ) : Promise < SignedTx < T > [ ] > {
679682 const validation = this . _validate ( toSign ) ;
680683
684+ if ( this . currentProvider ?. isSignAndBroadcastByProvider === true ) {
685+ const error = this . _handleError ( ERRORS . PROVIDER_SIGN_NOT_SUPPORTED , [ {
686+ error : 'PROVIDER_SIGN_NOT_SUPPORTED' ,
687+ node : this . _options . NODE_URL ,
688+ } ] ) ;
689+
690+ throw error ;
691+ }
692+
681693 if ( validation . isValid ) {
682694 return this . _connectPromise . then (
683695 ( provider ) => provider . sign ( toSign as any )
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export const ERRORS = {
1010 PROVIDER_INTERNAL : 1006 as 1006 ,
1111 API_ARGUMENTS : 1007 as 1007 ,
1212 NETWORK_ERROR : 1008 as 1008 ,
13+ PROVIDER_SIGN_NOT_SUPPORTED : 1009 as 1009 ,
1314} ;
1415
1516type ErrorDetails = {
@@ -125,6 +126,19 @@ export class SignerProviderConnectError extends SignerError {
125126 }
126127}
127128
129+ export class SignerProviderSignIsNotSupport extends SignerError {
130+ constructor ( { error, node } : { error : string ; node : string } ) {
131+ super ( {
132+ code : ERRORS . PROVIDER_SIGN_NOT_SUPPORTED ,
133+ title : 'Method sign is not support for this provider. Use broadcats instead' ,
134+ type : 'validation' ,
135+ errorArgs : { error, node } ,
136+ } ) ;
137+
138+ Object . setPrototypeOf ( this , SignerProviderSignIsNotSupport . prototype ) ;
139+ }
140+ }
141+
128142export class SignerEnsureProviderError extends SignerError {
129143 constructor ( method : string ) {
130144 super ( {
Original file line number Diff line number Diff line change 88 SignerNetworkError ,
99 SignerOptionsError ,
1010 SignerProviderConnectError ,
11+ SignerProviderSignIsNotSupport ,
1112 SignerProviderInterfaceError ,
1213 SignerProviderInternalError ,
1314} from './SignerError' ;
@@ -19,6 +20,7 @@ const ERRORS_MAP = {
1920 [ ERRORS . PROVIDER_INTERFACE ] : SignerProviderInterfaceError ,
2021 [ ERRORS . API_ARGUMENTS ] : SignerApiArgumentsError ,
2122 [ ERRORS . PROVIDER_CONNECT ] : SignerProviderConnectError ,
23+ [ ERRORS . PROVIDER_SIGN_NOT_SUPPORTED ] : SignerProviderSignIsNotSupport ,
2224 [ ERRORS . ENSURE_PROVIDER ] : SignerEnsureProviderError ,
2325 [ ERRORS . PROVIDER_INTERNAL ] : SignerProviderInternalError ,
2426 [ ERRORS . NOT_AUTHORIZED ] : SignerAuthError ,
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ export interface TypedData {
4343export interface Provider {
4444 user : UserData | null ;
4545
46+ isSignAndBroadcastByProvider ?: boolean ;
47+
4648 on < EVENT extends keyof AuthEvents > (
4749 event : EVENT ,
4850 handler : Handler < AuthEvents [ EVENT ] > ,
You can’t perform that action at this time.
0 commit comments