Skip to content

Commit 503f37e

Browse files
authored
feat: Add Balance Subscriptions feature (#849)
* feat: Add Balance Subscriptions feature * remove bad logs * feat: Enhance Balance Subscriptions webhook handling - Add support for creating new webhooks with optional labels - Allow using existing webhooks by ID - Validate webhook event type and revocation status - Improve error handling for webhook creation and selection * refactor: Simplify balance retrieval using thirdweb SDK - Replace manual balance fetching with `getWalletBalance` method - Support both native token and ERC20 token balance retrieval - Remove redundant contract and RPC client initialization code * generate SDK * refactor: Rename contractAddress to tokenAddress in Balance Subscriptions - Update Prisma schema, migration, and database indexes - Modify TypeScript interfaces and schemas across services and routes - Ensure consistent naming for token-related address fields - Update worker and database interaction methods * change to wallet subscriptions pattern * addressed review comments
1 parent 07d1d7d commit 503f37e

30 files changed

+1545
-10
lines changed

sdk/src/Engine.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { PermissionsService } from './services/PermissionsService';
3131
import { RelayerService } from './services/RelayerService';
3232
import { TransactionService } from './services/TransactionService';
3333
import { WalletCredentialsService } from './services/WalletCredentialsService';
34+
import { WalletSubscriptionsService } from './services/WalletSubscriptionsService';
3435
import { WebhooksService } from './services/WebhooksService';
3536

3637
type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
@@ -62,6 +63,7 @@ class EngineLogic {
6263
public readonly relayer: RelayerService;
6364
public readonly transaction: TransactionService;
6465
public readonly walletCredentials: WalletCredentialsService;
66+
public readonly walletSubscriptions: WalletSubscriptionsService;
6567
public readonly webhooks: WebhooksService;
6668

6769
public readonly request: BaseHttpRequest;
@@ -104,6 +106,7 @@ class EngineLogic {
104106
this.relayer = new RelayerService(this.request);
105107
this.transaction = new TransactionService(this.request);
106108
this.walletCredentials = new WalletCredentialsService(this.request);
109+
this.walletSubscriptions = new WalletSubscriptionsService(this.request);
107110
this.webhooks = new WebhooksService(this.request);
108111
}
109112
}

sdk/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ export { PermissionsService } from './services/PermissionsService';
3535
export { RelayerService } from './services/RelayerService';
3636
export { TransactionService } from './services/TransactionService';
3737
export { WalletCredentialsService } from './services/WalletCredentialsService';
38+
export { WalletSubscriptionsService } from './services/WalletSubscriptionsService';
3839
export { WebhooksService } from './services/WebhooksService';

sdk/src/services/WalletCredentialsService.ts

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export class WalletCredentialsService {
2121
label: string;
2222
type: 'circle';
2323
/**
24-
* 32-byte hex string. If not provided, a random one will be generated.
24+
* 32-byte hex string. Consult https://developers.circle.com/w3s/entity-secret-management to create and register an entity secret.
2525
*/
26-
entitySecret?: string;
26+
entitySecret: string;
2727
/**
2828
* Whether this credential should be set as the default for its type. Only one credential can be default per type.
2929
*/
@@ -102,7 +102,7 @@ export class WalletCredentialsService {
102102
id: string;
103103
type: string;
104104
label: (string | null);
105-
isDefault: boolean;
105+
isDefault: (boolean | null);
106106
createdAt: string;
107107
updatedAt: string;
108108
deletedAt: (string | null);
@@ -122,4 +122,51 @@ export class WalletCredentialsService {
122122
});
123123
}
124124

125+
/**
126+
* Update wallet credential
127+
* Update a wallet credential's label, default status, and entity secret.
128+
* @param id The ID of the wallet credential to update.
129+
* @param requestBody
130+
* @returns any Default Response
131+
* @throws ApiError
132+
*/
133+
public updateWalletCredential(
134+
id: string,
135+
requestBody?: {
136+
label?: string;
137+
/**
138+
* Whether this credential should be set as the default for its type. Only one credential can be default per type.
139+
*/
140+
isDefault?: boolean;
141+
/**
142+
* 32-byte hex string. Consult https://developers.circle.com/w3s/entity-secret-management to create and register an entity secret.
143+
*/
144+
entitySecret?: string;
145+
},
146+
): CancelablePromise<{
147+
result: {
148+
id: string;
149+
type: string;
150+
label: (string | null);
151+
isDefault: (boolean | null);
152+
createdAt: string;
153+
updatedAt: string;
154+
};
155+
}> {
156+
return this.httpRequest.request({
157+
method: 'PUT',
158+
url: '/wallet-credentials/{id}',
159+
path: {
160+
'id': id,
161+
},
162+
body: requestBody,
163+
mediaType: 'application/json',
164+
errors: {
165+
400: `Bad Request`,
166+
404: `Not Found`,
167+
500: `Internal Server Error`,
168+
},
169+
});
170+
}
171+
125172
}

0 commit comments

Comments
 (0)