@@ -30,6 +30,7 @@ import {
3030 AbiGetterInputsWithDefault ,
3131 DecodedAbiGetterOutputs ,
3232 AbiGetterInputs ,
33+ SignatureContext ,
3334} from './models' ;
3435import { Stream , Subscriber } from './stream' ;
3536import { ProviderApiResponse , ProviderRpcClient } from './index' ;
@@ -62,37 +63,46 @@ export class Contract<Abi> {
6263
6364 this . _provider = provider ;
6465 this . _abi = JSON . stringify ( abi ) ;
65- this . methodsAbi = ( ( abi as any ) . functions as ContractFunction [ ] ) . reduce ( ( functions , item ) => {
66- if ( item . inputs == null ) {
67- item . inputs = [ ] ;
68- }
69- if ( item . outputs == null ) {
70- item . outputs = [ ] ;
71- }
66+ this . methodsAbi = ( ( abi as any ) . functions as ContractFunction [ ] ) . reduce (
67+ ( functions , item ) => {
68+ if ( item . inputs == null ) {
69+ item . inputs = [ ] ;
70+ }
71+ if ( item . outputs == null ) {
72+ item . outputs = [ ] ;
73+ }
7274
73- ( functions as any ) [ item . name ] = item ;
74- return functions ;
75- } , { } as typeof Contract . prototype . methodsAbi ) ;
75+ ( functions as any ) [ item . name ] = item ;
76+ return functions ;
77+ } ,
78+ { } as typeof Contract . prototype . methodsAbi ,
79+ ) ;
7680
77- this . gettersAbi = ( ( ( abi as any ) . getters ?? [ ] ) as ContractFunction [ ] ) . reduce ( ( getters , item ) => {
78- if ( item . inputs == null ) {
79- item . inputs = [ ] ;
80- }
81- if ( item . outputs == null ) {
82- item . outputs = [ ] ;
83- }
81+ this . gettersAbi = ( ( ( abi as any ) . getters ?? [ ] ) as ContractFunction [ ] ) . reduce (
82+ ( getters , item ) => {
83+ if ( item . inputs == null ) {
84+ item . inputs = [ ] ;
85+ }
86+ if ( item . outputs == null ) {
87+ item . outputs = [ ] ;
88+ }
8489
85- ( getters as any ) [ item . name ] = item ;
86- return getters ;
87- } , { } as typeof Contract . prototype . gettersAbi ) ;
90+ ( getters as any ) [ item . name ] = item ;
91+ return getters ;
92+ } ,
93+ { } as typeof Contract . prototype . gettersAbi ,
94+ ) ;
8895
89- this . eventsAbi = ( ( abi as any ) . events as ContractFunction [ ] ) . reduce ( ( events , item ) => {
90- if ( item . inputs == null ) {
91- item . inputs = [ ] ;
92- }
93- ( events as any ) [ item . name ] = item ;
94- return events ;
95- } , { } as typeof Contract . prototype . eventsAbi ) ;
96+ this . eventsAbi = ( ( abi as any ) . events as ContractFunction [ ] ) . reduce (
97+ ( events , item ) => {
98+ if ( item . inputs == null ) {
99+ item . inputs = [ ] ;
100+ }
101+ ( events as any ) [ item . name ] = item ;
102+ return events ;
103+ } ,
104+ { } as typeof Contract . prototype . eventsAbi ,
105+ ) ;
96106 this . fieldsAbi = ( abi as any ) . fields ;
97107
98108 this . _address = address ;
@@ -249,9 +259,10 @@ export class Contract<Abi> {
249259 subscriber = new this . _provider . Subscriber ( ) ;
250260 }
251261
252- const event = await ( range ?. fromLt != null || range ?. fromUtime != null
253- ? subscriber . oldTransactions ( this . _address , range ) . merge ( subscriber . transactions ( this . _address ) )
254- : subscriber . transactions ( this . address )
262+ const event = await (
263+ range ?. fromLt != null || range ?. fromUtime != null
264+ ? subscriber . oldTransactions ( this . _address , range ) . merge ( subscriber . transactions ( this . _address ) )
265+ : subscriber . transactions ( this . address )
255266 )
256267 . flatMap ( item => item . transactions )
257268 . takeWhile (
@@ -824,9 +835,9 @@ class ContractMethodImpl implements ContractMethod<any, any> {
824835 local : args . local ,
825836 executorParams : args . executorParams
826837 ? {
827- disableSignatureCheck : args . executorParams . disableSignatureCheck ,
828- overrideBalance : args . executorParams . overrideBalance ,
829- }
838+ disableSignatureCheck : args . executorParams . disableSignatureCheck ,
839+ overrideBalance : args . executorParams . overrideBalance ,
840+ }
830841 : undefined ,
831842 } ) ;
832843
@@ -888,6 +899,7 @@ class ContractMethodImpl implements ContractMethod<any, any> {
888899 params : this . params ,
889900 } ,
890901 withSignatureId : args . withSignatureId ,
902+ withSignatureContext : args . withSignatureContext ,
891903 libraries : args . libraries ,
892904 } ) ;
893905
@@ -921,9 +933,9 @@ class ContractMethodImpl implements ContractMethod<any, any> {
921933 executorParams :
922934 args . executorParams != null
923935 ? {
924- disableSignatureCheck : args . executorParams . disableSignatureCheck ,
925- overrideBalance : args . executorParams . overrideBalance ,
926- }
936+ disableSignatureCheck : args . executorParams . disableSignatureCheck ,
937+ overrideBalance : args . executorParams . overrideBalance ,
938+ }
927939 : undefined ,
928940 } ) ;
929941
@@ -959,9 +971,9 @@ class ContractMethodImpl implements ContractMethod<any, any> {
959971 executorParams :
960972 args . executorParams != null
961973 ? {
962- disableSignatureCheck : args . executorParams . disableSignatureCheck ,
963- overrideBalance : args . executorParams . overrideBalance ,
964- }
974+ disableSignatureCheck : args . executorParams . disableSignatureCheck ,
975+ overrideBalance : args . executorParams . overrideBalance ,
976+ }
965977 : undefined ,
966978 } ) ;
967979
@@ -1028,6 +1040,7 @@ class ContractGetterImpl implements ContractGetter<any, any> {
10281040 params : this . params ,
10291041 } ,
10301042 withSignatureId : args . withSignatureId ,
1043+ withSignatureContext : args . withSignatureContext ,
10311044 libraries : args . libraries ,
10321045 } ) ;
10331046
@@ -1100,22 +1113,25 @@ export type SendInternalWithResultParams = SendInternalParams & {
11001113/**
11011114 * @category Contract
11021115 */
1103- export type SendExternalParams = ( {
1104- /**
1105- * Whether to prepare this message without signature. Default: false
1106- */
1107- withoutSignature : true ;
1108- } | {
1109- /**
1110- * The public key of the preferred account.
1111- * It is the same publicKey as the `accountInteraction.publicKey`, but it must be explicitly provided
1112- */
1113- publicKey : string ;
1114- /**
1115- * Whether to prepare this message without signature. Default: false
1116- */
1117- withoutSignature ?: false ;
1118- } ) & {
1116+ export type SendExternalParams = (
1117+ | {
1118+ /**
1119+ * Whether to prepare this message without signature. Default: false
1120+ */
1121+ withoutSignature : true ;
1122+ }
1123+ | {
1124+ /**
1125+ * The public key of the preferred account.
1126+ * It is the same publicKey as the `accountInteraction.publicKey`, but it must be explicitly provided
1127+ */
1128+ publicKey : string ;
1129+ /**
1130+ * Whether to prepare this message without signature. Default: false
1131+ */
1132+ withoutSignature ?: false ;
1133+ }
1134+ ) & {
11191135 /**
11201136 * Optional base64 encoded TVC
11211137 */
@@ -1173,8 +1189,30 @@ export type CallParams = {
11731189 * - If `true`, uses the signature id of the selected network (if the capability is enabled).
11741190 * - If `false`, forces signature check to ignore any signature id.
11751191 * - If `number`, uses the specified number as a signature id.
1192+ * @deprecated
1193+ * Use `withSignatureContext` instead.
11761194 */
11771195 withSignatureId ?: boolean | number ;
1196+ /**
1197+ * Optional advanced signature configuration.
1198+ *
1199+ * In most cases you **do not need to set this manually**.
1200+ * The wallet or network configuration will choose the correct mode.
1201+ *
1202+ * This field controls how the data is prepared before signing:
1203+ *
1204+ * - `empty` — signs the data as-is.
1205+ * Use for simple or legacy signing.
1206+ *
1207+ * - `signatureId` — signs the data together with a network-specific id.
1208+ * Prevents signatures from being reused on another network.
1209+ *
1210+ * - `signatureDomainL2` — same as signature id but with a different prefix.
1211+ * This should be used where the `SignatureComain` capability is enabled.
1212+ *
1213+ * If provided, this field overrides `withSignatureId`.
1214+ */
1215+ withSignatureContext ?: SignatureContext ;
11781216 /**
11791217 * Optional libraries map
11801218 **/
@@ -1194,8 +1232,30 @@ export type RunGetterParams = {
11941232 * - If `true`, uses the signature id of the selected network (if the capability is enabled).
11951233 * - If `false`, forces signature check to ignore any signature id.
11961234 * - If `number`, uses the specified number as a signature id.
1235+ * @deprecated
1236+ * Use `withSignatureContext` instead.
11971237 */
11981238 withSignatureId ?: boolean | number ;
1239+ /**
1240+ * Optional advanced signature configuration.
1241+ *
1242+ * In most cases you **do not need to set this manually**.
1243+ * The wallet or network configuration will choose the correct mode.
1244+ *
1245+ * This field controls how the data is prepared before signing:
1246+ *
1247+ * - `empty` — signs the data as-is.
1248+ * Use for simple or legacy signing.
1249+ *
1250+ * - `signatureId` — signs the data together with a network-specific id.
1251+ * Prevents signatures from being reused on another network.
1252+ *
1253+ * - `signatureDomainL2` — same as signature id but with a different prefix.
1254+ * This should be used where the `SignatureComain` capability is enabled.
1255+ *
1256+ * If provided, this field overrides `withSignatureId`.
1257+ */
1258+ withSignatureContext ?: SignatureContext ;
11991259 /**
12001260 * Optional libraries map
12011261 **/
@@ -1342,9 +1402,10 @@ export type DecodeTransactionParams<Abi> = {
13421402/**
13431403 * @category Contract
13441404 */
1345- export type DecodedTransaction < Abi , T > = T extends AbiFunctionName < Abi >
1346- ? { method : T ; input : DecodedAbiFunctionInputs < Abi , T > ; output : DecodedAbiFunctionOutputs < Abi , T > }
1347- : never ;
1405+ export type DecodedTransaction < Abi , T > =
1406+ T extends AbiFunctionName < Abi >
1407+ ? { method : T ; input : DecodedAbiFunctionInputs < Abi , T > ; output : DecodedAbiFunctionOutputs < Abi , T > }
1408+ : never ;
13481409
13491410/**
13501411 * @category Contract
@@ -1358,9 +1419,8 @@ export type DecodeInputParams<Abi> = {
13581419/**
13591420 * @category Contract
13601421 */
1361- export type DecodedInput < Abi , T > = T extends AbiFunctionName < Abi >
1362- ? { method : T ; input : DecodedAbiFunctionInputs < Abi , T > }
1363- : never ;
1422+ export type DecodedInput < Abi , T > =
1423+ T extends AbiFunctionName < Abi > ? { method : T ; input : DecodedAbiFunctionInputs < Abi , T > } : never ;
13641424
13651425/**
13661426 * @category Contract
@@ -1387,9 +1447,8 @@ export type DecodeEventParams<Abi> = {
13871447/**
13881448 * @category Contract
13891449 */
1390- export type DecodedOutput < Abi , T > = T extends AbiFunctionName < Abi >
1391- ? { method : T ; output : DecodedAbiFunctionOutputs < Abi , T > }
1392- : never ;
1450+ export type DecodedOutput < Abi , T > =
1451+ T extends AbiFunctionName < Abi > ? { method : T ; output : DecodedAbiFunctionOutputs < Abi , T > } : never ;
13931452
13941453/**
13951454 * @category Contract
@@ -1401,9 +1460,8 @@ export type DecodeTransactionEventsParams = {
14011460/**
14021461 * @category Contract
14031462 */
1404- export type DecodedEvent < Abi , T > = T extends AbiEventName < Abi >
1405- ? { event : T ; data : DecodedAbiEventData < Abi , T > }
1406- : never ;
1463+ export type DecodedEvent < Abi , T > =
1464+ T extends AbiEventName < Abi > ? { event : T ; data : DecodedAbiEventData < Abi , T > } : never ;
14071465
14081466/**
14091467 * @category Contract
0 commit comments