Skip to content

Commit dce7a55

Browse files
feat: add signature context
* update types * update version * fix types --------- Co-authored-by: Aliaksei <milutkin.work@gmail.com>
1 parent a7ae67d commit dce7a55

3 files changed

Lines changed: 102 additions & 25 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "everscale-inpage-provider",
3-
"version": "0.6.3",
3+
"version": "0.6.4",
44
"description": "Web3-like interface to the Everscale blockchain",
55
"repository": "https://github.com/broxus/everscale-inpage-provider",
66
"main": "dist/index.js",

src/api.ts

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
AddNetwork,
2222
IgnoreTransactionTreeSimulationError,
2323
GetterCall,
24+
SignatureContext,
2425
} from './models';
2526

2627
import { UniqueArray, Address } from './utils';
@@ -1163,8 +1164,32 @@ export type ProviderApi<Addr = Address> = {
11631164
* - If `true`, uses the signature id of the selected network (if the capability is enabled).
11641165
* - If `false`, forces signature check to ignore any signature id.
11651166
* - If `number`, uses the specified number as a signature id.
1167+
* @deprecated
1168+
* Use `signatureCtx` instead.
11661169
*/
11671170
withSignatureId?: boolean | number;
1171+
1172+
/**
1173+
* Optional advanced signature configuration.
1174+
*
1175+
* In most cases you **do not need to set this manually**.
1176+
* The wallet or network configuration will choose the correct mode.
1177+
*
1178+
* This field controls how the data is prepared before signing:
1179+
*
1180+
* - `empty` — signs the data as-is.
1181+
* Use for simple or legacy signing.
1182+
*
1183+
* - `signatureId` — signs the data together with a network-specific id.
1184+
* Prevents signatures from being reused on another network.
1185+
*
1186+
* - `signatureDomain` — uses a domain-separated signature mode.
1187+
* This is the most secure and modern option.
1188+
*
1189+
*
1190+
* If provided, this field overrides `withSignatureId`.
1191+
*/
1192+
withSignatureContext?: SignatureContext;
11681193
};
11691194
output: {
11701195
/**
@@ -1279,8 +1304,32 @@ export type ProviderApi<Addr = Address> = {
12791304
* - If `true`, uses the signature id of the selected network (if the capability is enabled).
12801305
* - If `false`, forces signature check to ignore any signature id.
12811306
* - If `number`, uses the specified number as a signature id.
1307+
* @deprecated
1308+
* Use `signatureCtx` instead.
12821309
*/
12831310
withSignatureId?: boolean | number;
1311+
1312+
/**
1313+
* Optional advanced signature configuration.
1314+
*
1315+
* In most cases you **do not need to set this manually**.
1316+
* The wallet or network configuration will choose the correct mode.
1317+
*
1318+
* This field controls how the data is prepared before signing:
1319+
*
1320+
* - `empty` — signs the data as-is.
1321+
* Use for simple or legacy signing.
1322+
*
1323+
* - `signatureId` — signs the data together with a network-specific id.
1324+
* Prevents signatures from being reused on another network.
1325+
*
1326+
* - `signatureDomain` — uses a domain-separated signature mode.
1327+
* This is the most secure and modern option.
1328+
*
1329+
*
1330+
* If provided, this field overrides `withSignatureId`.
1331+
*/
1332+
withSignatureContext?: SignatureContext;
12841333
};
12851334
output: {
12861335
/**
@@ -1333,8 +1382,32 @@ export type ProviderApi<Addr = Address> = {
13331382
* - If `true`, uses the signature id of the selected network (if the capability is enabled).
13341383
* - If `false`, forces signature check to ignore any signature id.
13351384
* - If `number`, uses the specified number as a signature id.
1385+
* @deprecated
1386+
* Use `signatureCtx` instead.
13361387
*/
13371388
withSignatureId?: boolean | number;
1389+
1390+
/**
1391+
* Optional advanced signature configuration.
1392+
*
1393+
* In most cases you **do not need to set this manually**.
1394+
* The wallet or network configuration will choose the correct mode.
1395+
*
1396+
* This field controls how the data is prepared before signing:
1397+
*
1398+
* - `empty` — signs the data as-is.
1399+
* Use for simple or legacy signing.
1400+
*
1401+
* - `signatureId` — signs the data together with a network-specific id.
1402+
* Prevents signatures from being reused on another network.
1403+
*
1404+
* - `signatureDomain` — uses a domain-separated signature mode.
1405+
* This is the most secure and modern option.
1406+
*
1407+
*
1408+
* If provided, this field overrides `withSignatureId`.
1409+
*/
1410+
withSignatureContext?: SignatureContext;
13381411
};
13391412
output: {
13401413
/**
@@ -1677,7 +1750,7 @@ export type ProviderApi<Addr = Address> = {
16771750
switchNetwork?: boolean;
16781751
};
16791752
output: {
1680-
network: Network | null
1753+
network: Network | null;
16811754
};
16821755
};
16831756

src/models.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,17 @@ export type NetworkDescription = {
321321
globalId: number;
322322
capabilities: string;
323323
signatureId: number | undefined;
324+
signatureCtx: SignatureContext;
324325
};
325326

327+
/**
328+
* @category Models
329+
*/
330+
export type SignatureContext =
331+
| { type: 'empty' } // ton/legacy networks
332+
| { type: 'signatureId'; globalId: number } // simple prefix
333+
| { type: 'signatureDomainL2'; globalId: number }; // full domain prefix
334+
326335
/**
327336
* @category Models
328337
*/
@@ -340,19 +349,19 @@ export type GqlSocketParams = {
340349
/**
341350
* Path to graphql api endpoints
342351
*/
343-
endpoints: string[]
352+
endpoints: string[];
344353
/**
345354
* Frequency of sync latency detection
346355
*/
347-
latencyDetectionInterval: number
356+
latencyDetectionInterval: number;
348357
/**
349358
* Maximum value for the endpoint's blockchain data sync latency
350359
*/
351-
maxLatency: number
360+
maxLatency: number;
352361
/**
353362
* Gql node type
354363
*/
355-
local: boolean
364+
local: boolean;
356365
};
357366

358367
/**
@@ -362,17 +371,17 @@ export type JrpcSocketParams = {
362371
/**
363372
* Path to jrpc api endpoint
364373
*/
365-
endpoint: string
374+
endpoint: string;
366375
};
367376

368377
/**
369378
* @category Models
370379
*/
371380
export type ProtoSocketParams = JrpcSocketParams & {};
372381

373-
export type GqlConnection = { type: 'graphql', data: GqlSocketParams };
374-
export type JrpcConnection = { type: 'jrpc', data: JrpcSocketParams };
375-
export type ProtoConnection = { type: 'proto', data: ProtoSocketParams };
382+
export type GqlConnection = { type: 'graphql'; data: GqlSocketParams };
383+
export type JrpcConnection = { type: 'jrpc'; data: JrpcSocketParams };
384+
export type ProtoConnection = { type: 'proto'; data: ProtoSocketParams };
376385

377386
/**
378387
* @category Models
@@ -743,21 +752,21 @@ export type OutputTokenObject<O> = O extends { name: infer K; type: infer T; com
743752
export type MergeInputObjectsArray<A> = A extends readonly [infer T, ...infer Ts]
744753
? InputTokenObject<T> & MergeInputObjectsArray<[...Ts]>
745754
: A extends readonly [infer T]
746-
? InputTokenObject<T>
747-
: A extends readonly []
748-
? {}
749-
: never;
755+
? InputTokenObject<T>
756+
: A extends readonly []
757+
? {}
758+
: never;
750759

751760
/**
752761
* @category Models
753762
*/
754763
export type MergeOutputObjectsArray<A> = A extends readonly [infer T, ...infer Ts]
755764
? OutputTokenObject<T> & MergeOutputObjectsArray<[...Ts]>
756765
: A extends readonly [infer T]
757-
? OutputTokenObject<T>
758-
: A extends readonly []
759-
? {}
760-
: never;
766+
? OutputTokenObject<T>
767+
: A extends readonly []
768+
? {}
769+
: never;
761770

762771
/**
763772
* @category Models
@@ -857,19 +866,14 @@ export type AbiGetterInputs<C, T extends AbiGetterName<C>> = MergeInputObjectsAr
857866
/**
858867
* @category Models
859868
*/
860-
export type AbiGetterInputsWithDefault<C, T extends AbiGetterName<C>> = AbiGetter<
861-
C,
862-
T
863-
>['inputs'] extends readonly []
869+
export type AbiGetterInputsWithDefault<C, T extends AbiGetterName<C>> = AbiGetter<C, T>['inputs'] extends readonly []
864870
? void | Record<string, never>
865871
: AbiGetterInputs<C, T>;
866872

867873
/**
868874
* @category Models
869875
*/
870-
export type DecodedAbiGetterInputs<C, T extends AbiGetterName<C>> = MergeOutputObjectsArray<
871-
AbiGetter<C, T>['inputs']
872-
>;
876+
export type DecodedAbiGetterInputs<C, T extends AbiGetterName<C>> = MergeOutputObjectsArray<AbiGetter<C, T>['inputs']>;
873877
/**
874878
* @category Models
875879
*/

0 commit comments

Comments
 (0)