Skip to content

Commit d535f0a

Browse files
committed
feat(protocol): subscriptions
fix(ui): ensure feature key maps to correct RequiredFeatures entry in currentWalletVersionNotSupported feat(sdk): enhance subscription request handling with dynamic 'from' and 'network' fields feat(ui): implement cancel subscription functionality and update action types feat(subscription): update subscription feature versions to use object structure feat(sdk): validate subscription period to ensure it is a multiple of defined base periods feat(i18n): add subscription initiation and cancellation notifications in English and Russian feat(ui): add subscription management modals and refactor action handling feat(ui): flatten single-file component folders for modals components feat(ui): add subscription creation and cancellation notifications, update action names feat(sdk): add validUntil, from, and network fields to subscription requests feat(sdk): update subscription feature types and responses to use 'v2' versioning feat(ui): add createSubscription method with version validation feat(sdk): enhance subscription management with creation and cancellation actions feat(sdk): add subscription V2 event types and update request interfaces feat(sdk): implement subscription creation/cancellation actions feat(protocol): changed names for create and cancel subscription RPC methods feat(sdk): add models for subscription features feat(protocol): add subscription feature
1 parent beb31b3 commit d535f0a

File tree

64 files changed

+1829
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1829
-115
lines changed

packages/protocol/src/models/app-message/request/app-request.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { SendTransactionRpcRequest } from './send-transaction-rpc-request';
22
import { SignDataRpcRequest } from './sign-data-rpc-request';
33
import { RpcMethod } from '../../rpc-method';
44
import { DisconnectRpcRequest } from './disconnect-rpc-request';
5+
import { CreateSubscriptionV2RpcRequest } from './create-subscription-v2-rpc-request';
6+
import { CancelSubscriptionV2RpcRequest } from './cancel-subscription-v2-rpc-request';
57

68
export type RpcRequests = {
79
sendTransaction: SendTransactionRpcRequest;
810
signData: SignDataRpcRequest;
911
disconnect: DisconnectRpcRequest;
12+
createSubscriptionV2: CreateSubscriptionV2RpcRequest;
13+
cancelSubscriptionV2: CancelSubscriptionV2RpcRequest;
1014
};
1115

1216
export type AppRequest<T extends RpcMethod> = RpcRequests[T];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface CancelSubscriptionV2RpcRequest {
2+
method: 'cancelSubscriptionV2';
3+
params: [string];
4+
id: string;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface CreateSubscriptionV2RpcRequest {
2+
method: 'createSubscriptionV2';
3+
params: [string];
4+
id: string;
5+
}

packages/protocol/src/models/app-message/request/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ export { AppRequest, RpcRequests } from './app-request';
22
export { SendTransactionRpcRequest } from './send-transaction-rpc-request';
33
export { SignDataRpcRequest } from './sign-data-rpc-request';
44
export { DisconnectRpcRequest } from './disconnect-rpc-request';
5+
export { CreateSubscriptionV2RpcRequest } from './create-subscription-v2-rpc-request';
6+
export { CancelSubscriptionV2RpcRequest } from './cancel-subscription-v2-rpc-request';

packages/protocol/src/models/feature.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export type Feature = SendTransactionFeatureDeprecated | SendTransactionFeature | SignDataFeature;
1+
export type Feature =
2+
| SendTransactionFeatureDeprecated
3+
| SendTransactionFeature
4+
| SignDataFeature
5+
| SubscriptionFeature;
6+
27
export type FeatureName = Exclude<Feature, 'SendTransaction'>['name'];
38

49
export type SendTransactionFeatureDeprecated = 'SendTransaction';
@@ -10,3 +15,10 @@ export type SendTransactionFeature = {
1015

1116
export type SignDataType = 'text' | 'binary' | 'cell';
1217
export type SignDataFeature = { name: 'SignData'; types: SignDataType[] };
18+
19+
export type SubscriptionFeature = {
20+
name: 'Subscription';
21+
versions: {
22+
v2: boolean;
23+
};
24+
};

packages/protocol/src/models/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {
88
SendTransactionFeatureDeprecated,
99
SendTransactionFeature,
1010
SignDataType,
11-
SignDataFeature
11+
SignDataFeature,
12+
SubscriptionFeature
1213
} from './feature';
1314
export { CHAIN } from './CHAIN';
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export type RpcMethod = 'disconnect' | 'sendTransaction' | 'signData';
1+
export type RpcMethod =
2+
| 'disconnect'
3+
| 'sendTransaction'
4+
| 'signData'
5+
| 'createSubscriptionV2'
6+
| 'cancelSubscriptionV2';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { WalletResponseTemplateError } from './wallet-response-template';
2+
3+
export type CancelSubscriptionV2RpcResponse =
4+
| CancelSubscriptionV2RpcResponseSuccess
5+
| CancelSubscriptionV2RpcResponseError;
6+
7+
export interface CancelSubscriptionV2RpcResponseSuccess {
8+
result: { boc: string };
9+
id: string;
10+
}
11+
12+
export interface CancelSubscriptionV2RpcResponseError extends WalletResponseTemplateError {
13+
error: { code: CANCEL_SUBSCRIPTION_V2_ERROR_CODES; message: string; data?: unknown };
14+
}
15+
16+
export enum CANCEL_SUBSCRIPTION_V2_ERROR_CODES {
17+
UNKNOWN_ERROR = 0,
18+
BAD_REQUEST_ERROR = 1,
19+
UNKNOWN_APP_ERROR = 100,
20+
USER_REJECTS_ERROR = 300,
21+
METHOD_NOT_SUPPORTED = 400,
22+
EXTENSION_NOT_FOUND = 404
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { WalletResponseTemplateError } from './wallet-response-template';
2+
3+
export type CreateSubscriptionV2RpcResponse =
4+
| CreateSubscriptionV2RpcResponseSuccess
5+
| CreateSubscriptionV2RpcResponseError;
6+
7+
export interface CreateSubscriptionV2RpcResponseSuccess {
8+
result: { boc: string };
9+
id: string;
10+
}
11+
12+
export interface CreateSubscriptionV2RpcResponseError extends WalletResponseTemplateError {
13+
error: { code: CREATE_SUBSCRIPTION_V2_ERROR_CODES; message: string; data?: unknown };
14+
}
15+
16+
export enum CREATE_SUBSCRIPTION_V2_ERROR_CODES {
17+
UNKNOWN_ERROR = 0,
18+
BAD_REQUEST_ERROR = 1,
19+
UNKNOWN_APP_ERROR = 100,
20+
USER_REJECTS_ERROR = 300,
21+
METHOD_NOT_SUPPORTED = 400
22+
}

packages/protocol/src/models/wallet-message/wallet-response/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ export {
2020
SignDataRpcResponseError,
2121
SIGN_DATA_ERROR_CODES
2222
} from './sign-data-rpc-response';
23+
export {
24+
CreateSubscriptionV2RpcResponse,
25+
CreateSubscriptionV2RpcResponseSuccess,
26+
CreateSubscriptionV2RpcResponseError,
27+
CREATE_SUBSCRIPTION_V2_ERROR_CODES
28+
} from './create-subscription-v2-rpc-response';
29+
export {
30+
CancelSubscriptionV2RpcResponse,
31+
CancelSubscriptionV2RpcResponseSuccess,
32+
CancelSubscriptionV2RpcResponseError,
33+
CANCEL_SUBSCRIPTION_V2_ERROR_CODES
34+
} from './cancel-subscription-v2-rpc-response';
2335
export {
2436
DisconnectRpcResponse,
2537
DisconnectRpcResponseSuccess,

0 commit comments

Comments
 (0)