Skip to content

Commit

Permalink
feat: Add Balance Subscriptions feature (#849)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
d4mr authored Feb 18, 2025
1 parent 07d1d7d commit 503f37e
Show file tree
Hide file tree
Showing 30 changed files with 1,545 additions and 10 deletions.
3 changes: 3 additions & 0 deletions sdk/src/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { PermissionsService } from './services/PermissionsService';
import { RelayerService } from './services/RelayerService';
import { TransactionService } from './services/TransactionService';
import { WalletCredentialsService } from './services/WalletCredentialsService';
import { WalletSubscriptionsService } from './services/WalletSubscriptionsService';
import { WebhooksService } from './services/WebhooksService';

type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
Expand Down Expand Up @@ -62,6 +63,7 @@ class EngineLogic {
public readonly relayer: RelayerService;
public readonly transaction: TransactionService;
public readonly walletCredentials: WalletCredentialsService;
public readonly walletSubscriptions: WalletSubscriptionsService;
public readonly webhooks: WebhooksService;

public readonly request: BaseHttpRequest;
Expand Down Expand Up @@ -104,6 +106,7 @@ class EngineLogic {
this.relayer = new RelayerService(this.request);
this.transaction = new TransactionService(this.request);
this.walletCredentials = new WalletCredentialsService(this.request);
this.walletSubscriptions = new WalletSubscriptionsService(this.request);
this.webhooks = new WebhooksService(this.request);
}
}
Expand Down
1 change: 1 addition & 0 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ export { PermissionsService } from './services/PermissionsService';
export { RelayerService } from './services/RelayerService';
export { TransactionService } from './services/TransactionService';
export { WalletCredentialsService } from './services/WalletCredentialsService';
export { WalletSubscriptionsService } from './services/WalletSubscriptionsService';
export { WebhooksService } from './services/WebhooksService';
53 changes: 50 additions & 3 deletions sdk/src/services/WalletCredentialsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export class WalletCredentialsService {
label: string;
type: 'circle';
/**
* 32-byte hex string. If not provided, a random one will be generated.
* 32-byte hex string. Consult https://developers.circle.com/w3s/entity-secret-management to create and register an entity secret.
*/
entitySecret?: string;
entitySecret: string;
/**
* Whether this credential should be set as the default for its type. Only one credential can be default per type.
*/
Expand Down Expand Up @@ -102,7 +102,7 @@ export class WalletCredentialsService {
id: string;
type: string;
label: (string | null);
isDefault: boolean;
isDefault: (boolean | null);
createdAt: string;
updatedAt: string;
deletedAt: (string | null);
Expand All @@ -122,4 +122,51 @@ export class WalletCredentialsService {
});
}

/**
* Update wallet credential
* Update a wallet credential's label, default status, and entity secret.
* @param id The ID of the wallet credential to update.
* @param requestBody
* @returns any Default Response
* @throws ApiError
*/
public updateWalletCredential(
id: string,
requestBody?: {
label?: string;
/**
* Whether this credential should be set as the default for its type. Only one credential can be default per type.
*/
isDefault?: boolean;
/**
* 32-byte hex string. Consult https://developers.circle.com/w3s/entity-secret-management to create and register an entity secret.
*/
entitySecret?: string;
},
): CancelablePromise<{
result: {
id: string;
type: string;
label: (string | null);
isDefault: (boolean | null);
createdAt: string;
updatedAt: string;
};
}> {
return this.httpRequest.request({
method: 'PUT',
url: '/wallet-credentials/{id}',
path: {
'id': id,
},
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}

}
Loading

0 comments on commit 503f37e

Please sign in to comment.